Public: anyone can read this; the crew can change it.
API routes the Apple app lacks: the arcade's games, an app's log, pausing a runner #18075
Merged 10h 13m ago, live in production
torque/forge:torque/18038-api-routes-the-apple-app-lacks-the-arcad → main 0 commits fork
24 files
changed +581
−206
- docs/features/arcade-carts.md
- docs/features/log-reader.md
- docs/features/runners.md
- src/actions/app_log.ts
- src/actions/runners.ts
- src/arcade/games_list.ts
- src/contract/openapi/routes/getApiV1ArcadeGames.ts
- src/contract/openapi/routes/getApiV1ReposOwnerNameAppEnvLog.ts
- src/contract/openapi/routes/index.ts
- src/contract/openapi/routes/postApiV1AdminRunnersIdPause.ts
- src/contract/tags.ts
- src/generated/marks.ts
- src/http/api.ts
- src/http/api/app.ts
- src/http/api/arcade.ts
- src/http/api/runners.ts
- src/http/lazy_lists.ts
- src/http/marks/api-v1-arcade.json
- src/tui/screens/runners.ts
- test/app-log-api.test.ts
- test/arcade-host.test.ts
- test/budgets/unfixtured/api-v1-repos-owner-name-app-env-log.json
- test/route-timing-coverage.test.ts
- test/tui-runners.test.ts
docs/features/arcade-carts.md +4
| @@ -15,3 +15,7 @@ A build pin can name a **cart**: a demo of its commit that plays offline as one | ||
| 15 | 15 | - **Import.** Carts built elsewhere: `bun scripts/import-carts.ts <data-dir> <carts.json>` pins each commit (if not pinned), sets its cart and cover, and keeps its page and picture. Each entry is checked; a bad one is named and skipped. |
| 16 | 16 | |
| 17 | 17 | Left out: the Arcade itself (the shelf, the console page, covers drawn in the house style and the arcade host: #9207, #9208), a cover upload door, and capturing a page that is not the build's own HTML file. |
| 18 | ||
| 19 | ## Over the API (#18038) | |
| 20 | ||
| 21 | `GET /api/v1/arcade/games` lists the Arcade's games as the host's `games.json` does, read as a stranger reads the display, and adds `play_url` to each build (the host's address and its `file`). `{ host, items, next_cursor }`; empty `items` (and `host` null where apps do not run) when no display is the Arcade's. `src/arcade/games_list.ts`; the terminal's Display screen shows the same shelf's Launch address. |
docs/features/log-reader.md +4
| @@ -15,3 +15,7 @@ One reader for a log, drawn the same on a page (`src/web/log_reader.ts`) and in | ||
| 15 | 15 | - **Masked once:** `src/logs/game.ts` passes every line through `redactHeld` before any reader, filter or Share on mclo.gs sees it: credential shapes, and values a run holds now. A secret with no known shape that a game prints itself is not caught. |
| 16 | 16 | - **One stream:** `/games/<box>/<service>/stream` sends `lines` (rows, the state line and the age) and `blocks` (the commands' states and answers). The person is read again at each look: it ends when they are no longer a viewer, and one who is no longer an operator gets no command or answer from then on. |
| 17 | 17 | - **Answers in their place:** a command's answer stands under the last line the forge held when it was recorded (`game_command.after_log`; one from before that was kept, under the last line its time had), and stays there: later output goes below it. What still waits is by the input. A filtered log, or one shown at a line, keeps them all by the input. World and power work has no Edit and is not in up and down: it is nothing to type. **Who sees them:** the service's operators and the box's owner, on the page, its stream and in the terminal. A viewer reads the log and the server's state, never a command or what it printed. MCP `games` gives no one a command's answer. |
| 18 | ||
| 19 | ## An app's log over the API (#18038) | |
| 20 | ||
| 21 | `GET /api/v1/repos/:owner/:name/app/:env/log` answers the running environment's last 200 lines as `text/plain` (`x-log-truncated: 1` when earlier lines were left out), masked as a run's log is, for a person who may write the repository; a reader gets 403, a stranger 401. It reads the deploy run that serves the environment (`src/actions/app_log.ts`); an environment that never ran answers an empty body. Not followed: ask again. |
docs/features/runners.md +4
| @@ -201,3 +201,7 @@ A runner reports its own machine, and the forge cannot check the report. So the | ||
| 201 | 201 | ## A job given up because the machine needs itself |
| 202 | 202 | |
| 203 | 203 | A runner may answer a held job `{ "interrupted": "<why>" }` (a game box does when a server wakes, [](game-box.md)). The job goes back to queued with its claim not counted: it is no result, never red, and no nearer the check's `MAX_CLAIMS` than before. `abandon`, by contrast, ends the job and the forge runs the check itself. |
| 204 | ||
| 205 | ## Pausing a runner (#18038) | |
| 206 | ||
| 207 | An admin holds a runner without revoking it: `POST /api/v1/admin/runners/:id/pause` (beside `…/resume` and `…/revoke`), or `p` on its row in the terminal's Runners screen. Its claims are refused and a job it holds finishes; its `paused` text reads `paused by <admin>`, and `runner.paused` is written. The forge's own `local-N` runner, a revoked one and one already paused answer 422 (`local`, `revoked`, `paused`). Resume undoes it. |
src/actions/app_log.ts added +45
| @@ -0,0 +1,45 @@ | ||
| 1 | /** | |
| 2 | * An app's log (#18038): the last lines the running environment said, for a person who may write | |
| 3 | * the repository. An environment's process pumps its stdout and stderr into the log of the deploy | |
| 4 | * run that serves it (`apps/runtime.ts`), so the lines are that run's file, read the way the run | |
| 5 | * log route reads it and masked the same way (`runs/log.ts` `readRunLogTail`). Never restored from | |
| 6 | * the store and never followed: a client asks again. | |
| 7 | */ | |
| 8 | ||
| 9 | import type { App } from "../app.ts"; | |
| 10 | import { appsRuntime } from "../apps/runtime_registry.ts"; | |
| 11 | import { getAppByRepo } from "../core/apps.ts"; | |
| 12 | import type { Repo } from "../core/repos.ts"; | |
| 13 | import type { User } from "../core/users.ts"; | |
| 14 | import { err, ok, type Result } from "../kernel/result.ts"; | |
| 15 | import { readRunLogTail } from "../runs/log.ts"; | |
| 16 | import { isEnvName } from "../apps/data.ts"; | |
| 17 | import { requireWriter, type AccessError } from "./access.ts"; | |
| 18 | ||
| 19 | /** The most lines one answer carries, as the kept gate's log does. */ | |
| 20 | export const APP_LOG_LINES = 200; | |
| 21 | ||
| 22 | export type AppLogError = AccessError | "no_such_env" | "no_runtime"; | |
| 23 | ||
| 24 | /** | |
| 25 | * The environment's last lines, oldest first, or why not. An environment that never ran has none. | |
| 26 | */ | |
| 27 | export function appLog( | |
| 28 | app: App, | |
| 29 | actor: User | undefined, | |
| 30 | repo: Repo, | |
| 31 | env: string, | |
| 32 | ): Result<{ readonly lines: string[]; readonly truncated: boolean }, AppLogError> { | |
| 33 | const writer = requireWriter(app, actor, repo); | |
| 34 | if (!writer.ok) return writer; | |
| 35 | const record = getAppByRepo(app.db, repo.id); | |
| 36 | if (record === undefined) return err("not_found"); | |
| 37 | if (!isEnvName(env)) return err("no_such_env"); | |
| 38 | const runtime = appsRuntime(app); | |
| 39 | if (runtime === undefined) return err("no_runtime"); | |
| 40 | const runId = runtime.envStatus(record, env)?.runId; | |
| 41 | if (runId === undefined) return ok({ lines: [], truncated: false }); | |
| 42 | const read = readRunLogTail(app.config.dataDir, runId, APP_LOG_LINES); | |
| 43 | const all = read.lines; | |
| 44 | return ok({ lines: all.slice(-APP_LOG_LINES), truncated: read.truncated || all.length > APP_LOG_LINES }); | |
| 45 | } |
src/actions/runners.ts +15
| @@ -73,6 +73,21 @@ export function resume(app: App, actor: User | undefined, runnerId: string): Res | ||
| 73 | 73 | return ok(runner); |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | /** | |
| 77 | * An admin holds a runner: it claims nothing until resumed. The forge's own `local-N` is refused. | |
| 78 | */ | |
| 79 | export function pause(app: App, actor: User | undefined, runnerId: string): Result<Enrolled, "not_found" | "local" | "revoked" | "paused"> { | |
| 80 | const runner = enrolled(app, actor, runnerId); | |
| 81 | if (runner === undefined || !admin(actor)) return err("not_found"); | |
| 82 | if (isLocal(runner)) return err("local"); | |
| 83 | if (runner.revokedAt !== 0) return err("revoked"); | |
| 84 | if (runner.paused !== "") return err("paused"); | |
| 85 | const why = `paused by ${actor.username}`; | |
| 86 | if (!pauseRunner(app.db, runnerId, why)) return err("not_found"); | |
| 87 | app.bus.append({ kind: "runner.paused", actorId: actor.id, payload: { id: runnerId, name: runner.name, why } }); | |
| 88 | return ok({ ...runner, paused: why }); | |
| 89 | } | |
| 90 | ||
| 76 | 91 | /** The forge pauses a lent runner whose answer it caught out; the event is the record. */ |
| 77 | 92 | function pauseLent(app: App, runnerId: string, why: string): void { |
| 78 | 93 | if (!pauseRunner(app.db, runnerId, why)) return; |
src/arcade/games_list.ts added +31
| @@ -0,0 +1,31 @@ | ||
| 1 | /** | |
| 2 | * The Arcade's games as an API answers them (#18038): the same list the arcade host's | |
| 3 | * `games.json` serves (`shelf.ts`), read as a stranger reads the display, with the address to play | |
| 4 | * each build. A forge with no Arcade display, one whose display is not in the shelf layout or whose | |
| 5 | * `display.json` is invalid answers an empty list: the host's 404 is for a browser, not a client. | |
| 6 | */ | |
| 7 | ||
| 8 | import type { App } from "../app.ts"; | |
| 9 | import { displayItems } from "../display/items.ts"; | |
| 10 | import { arcadeDisplay, arcadeHome } from "./host.ts"; | |
| 11 | import type { ShelfBuild, ShelfGame } from "./shelf.ts"; | |
| 12 | import { shelfOf } from "./shelf.ts"; | |
| 13 | ||
| 14 | export interface ArcadeBuild extends ShelfBuild { | |
| 15 | /** Where the build plays: the Arcade host's address and the build's `file`. */ | |
| 16 | readonly play_url: string; | |
| 17 | } | |
| 18 | export interface ArcadeGame extends Omit<ShelfGame, "builds"> { | |
| 19 | readonly builds: ArcadeBuild[]; | |
| 20 | } | |
| 21 | ||
| 22 | /** The Arcade's address (null when apps do not run here or no display is its) and its games. */ | |
| 23 | export async function arcadeGames(app: App): Promise<{ host: string | null; items: ArcadeGame[] }> { | |
| 24 | const host = arcadeHome(app); | |
| 25 | const display = host === undefined ? undefined : await arcadeDisplay(app); | |
| 26 | if (host === undefined || display === undefined || !display.config.ok || display.config.value.layout !== "shelf") return { host: host ?? null, items: [] }; | |
| 27 | const config = display.config.value; | |
| 28 | const shelf = shelfOf(await displayItems(app, display.repo, config, undefined), config.shelf.producer); | |
| 29 | const items = shelf.games.map((g) => ({ ...g, builds: g.builds.map((b) => ({ ...b, play_url: `${host}/${b.file}` })) })); | |
| 30 | return { host, items }; | |
| 31 | } |
src/contract/openapi/routes/getApiV1ArcadeGames.ts added +19
| @@ -0,0 +1,19 @@ | ||
| 1 | import { bool, int, list, obj, orNull, str } from "../schema_kit.ts"; | |
| 2 | import type { Route } from "../shared.ts"; | |
| 3 | ||
| 4 | const build = obj( | |
| 5 | { id: str, name: str, file: str, download: str, date: str, size: int, play_url: str, label: str, art: str, titled: bool, repo: str, pin: str, oid: str }, | |
| 6 | ["label", "art", "titled", "repo", "pin", "oid"], | |
| 7 | ); | |
| 8 | const game = obj({ id: str, name: str, producer: str, builds: list(build) }); | |
| 9 | ||
| 10 | export const route: Route = { | |
| 11 | method: "get", | |
| 12 | path: "/api/v1/arcade/games", | |
| 13 | summary: "The Arcade's games and their builds, each with the URL to play it", | |
| 14 | detail: | |
| 15 | "The Arcade's games, as the arcade host's games.json lists them (id, name, producer, builds: id, name, file, label, art, download, date, size, repo), read as a stranger reads the display; each build adds play_url, the host's address and its file. host is the Arcade's address, null when apps do not run here or no display is the Arcade's; items is empty when there is no Arcade display, it is not a shelf or its display.json is invalid. Answers { host, items, next_cursor } with next_cursor always null", | |
| 16 | auth: false, | |
| 17 | role: "anonymous", | |
| 18 | response: obj({ host: orNull(str), items: list(game), next_cursor: orNull(str) }), | |
| 19 | }; |
src/contract/openapi/routes/getApiV1ReposOwnerNameAppEnvLog.ts added +14
| @@ -0,0 +1,14 @@ | ||
| 1 | import { REPO, type Route } from "../shared.ts"; | |
| 2 | ||
| 3 | export const route: Route = { | |
| 4 | method: "get", | |
| 5 | path: `${REPO}/app/{env}/log`, | |
| 6 | summary: "Read the running app's recent lines as text/plain", | |
| 7 | detail: | |
| 8 | "The last 200 lines the environment (production or pull-N) said, as text/plain, oldest first, masked as a run's log is; an environment that never ran answers an empty body; x-log-truncated: 1 when earlier lines were left out. For a person who may write the repository; 404 for a repository the caller cannot see, 401 when signed out, 403 for a reader; 422 no_such_env or no_runtime", | |
| 9 | auth: true, | |
| 10 | role: "member", | |
| 11 | refuses: [404], | |
| 12 | errorStatus: { 422: "no such environment (no_such_env), or apps do not run on this forge (no_runtime)" }, | |
| 13 | refusals: { no_such_env: "the environment is not production or a pull-N preview", no_runtime: "apps do not run on this forge" }, | |
| 14 | }; |
src/contract/openapi/routes/index.ts +3
| @@ -77,6 +77,7 @@ export { route as getApiV1AgentsUsername } from "./getApiV1AgentsUsername.ts"; | ||
| 77 | 77 | export { route as getApiV1AppTemplates } from "./getApiV1AppTemplates.ts"; |
| 78 | 78 | export { route as getApiV1Apps } from "./getApiV1Apps.ts"; |
| 79 | 79 | export { route as getApiV1AppsSlugConfig } from "./getApiV1AppsSlugConfig.ts"; |
| 80 | export { route as getApiV1ArcadeGames } from "./getApiV1ArcadeGames.ts"; | |
| 80 | 81 | export { route as getApiV1Asks } from "./getApiV1Asks.ts"; |
| 81 | 82 | export { route as getApiV1AsksAdmin } from "./getApiV1AsksAdmin.ts"; |
| 82 | 83 | export { route as getApiV1Boards } from "./getApiV1Boards.ts"; |
| @@ -161,6 +162,7 @@ export { route as getApiV1ReposOwnerName } from "./getApiV1ReposOwnerName.ts"; | ||
| 161 | 162 | export { route as getApiV1ReposOwnerNameApp } from "./getApiV1ReposOwnerNameApp.ts"; |
| 162 | 163 | export { route as getApiV1ReposOwnerNameAppDomains } from "./getApiV1ReposOwnerNameAppDomains.ts"; |
| 163 | 164 | export { route as getApiV1ReposOwnerNameAppEnv } from "./getApiV1ReposOwnerNameAppEnv.ts"; |
| 165 | export { route as getApiV1ReposOwnerNameAppEnvLog } from "./getApiV1ReposOwnerNameAppEnvLog.ts"; | |
| 164 | 166 | export { route as getApiV1ReposOwnerNameAppEnvOpen } from "./getApiV1ReposOwnerNameAppEnvOpen.ts"; |
| 165 | 167 | export { route as getApiV1ReposOwnerNameAppErrors } from "./getApiV1ReposOwnerNameAppErrors.ts"; |
| 166 | 168 | export { route as getApiV1ReposOwnerNameAppErrorsGroup } from "./getApiV1ReposOwnerNameAppErrorsGroup.ts"; |
| @@ -352,6 +354,7 @@ export { route as postApiV1AdminReleasesShaRollback } from "./postApiV1AdminRele | ||
| 352 | 354 | export { route as postApiV1AdminRequestsUsernameAllow } from "./postApiV1AdminRequestsUsernameAllow.ts"; |
| 353 | 355 | export { route as postApiV1AdminRequestsUsernameDecline } from "./postApiV1AdminRequestsUsernameDecline.ts"; |
| 354 | 356 | export { route as postApiV1AdminRunners } from "./postApiV1AdminRunners.ts"; |
| 357 | export { route as postApiV1AdminRunnersIdPause } from "./postApiV1AdminRunnersIdPause.ts"; | |
| 355 | 358 | export { route as postApiV1AdminRunnersIdResume } from "./postApiV1AdminRunnersIdResume.ts"; |
| 356 | 359 | export { route as postApiV1AdminRunnersIdRevoke } from "./postApiV1AdminRunnersIdRevoke.ts"; |
| 357 | 360 | export { route as postApiV1Agents } from "./postApiV1Agents.ts"; |
src/contract/openapi/routes/postApiV1AdminRunnersIdPause.ts added +16
| @@ -0,0 +1,16 @@ | ||
| 1 | import type { Route } from "../shared.ts"; | |
| 2 | ||
| 3 | export const route: Route = { | |
| 4 | method: "post", | |
| 5 | path: "/api/v1/admin/runners/{id}/pause", | |
| 6 | summary: "Pause a runner: it claims no more work until resumed", | |
| 7 | detail: | |
| 8 | "Hold a runner (admin scope): its claim is refused and a job it holds finishes; POST …/resume lets it claim again. The paused text names who held it. 422 local for the forge's own local-N runner, revoked for a revoked one, paused when it is paused already; 404 when there is none", | |
| 9 | auth: true, | |
| 10 | role: "admin", | |
| 11 | status: 200, | |
| 12 | reply: { id: "string", name: "string", paused: "string" }, | |
| 13 | refuses: [404], | |
| 14 | errorStatus: { 422: "the runner is the forge's own (local), revoked or paused already (paused)" }, | |
| 15 | refusals: { local: "a local-N runner is the forge's own; it cannot be paused", revoked: "that runner is revoked", paused: "that runner is paused already" }, | |
| 16 | }; |
src/contract/tags.ts +1
src/generated/marks.ts +204 −202
| @@ -10,208 +10,209 @@ import k5 from "../http/marks/api-v1-admin.json"; | ||
| 10 | 10 | import k6 from "../http/marks/api-v1-agents.json"; |
| 11 | 11 | import k7 from "../http/marks/api-v1-app-templates.json"; |
| 12 | 12 | import k8 from "../http/marks/api-v1-apps.json"; |
| 13 | import k9 from "../http/marks/api-v1-asks.json"; | |
| 14 | import k10 from "../http/marks/api-v1-boards.json"; | |
| 15 | import k11 from "../http/marks/api-v1-broker.json"; | |
| 16 | import k12 from "../http/marks/api-v1-builds.json"; | |
| 17 | import k13 from "../http/marks/api-v1-cache.json"; | |
| 18 | import k14 from "../http/marks/api-v1-changelog.json"; | |
| 19 | import k15 from "../http/marks/api-v1-cloud.json"; | |
| 20 | import k16 from "../http/marks/api-v1-codes.json"; | |
| 21 | import k17 from "../http/marks/api-v1-config.json"; | |
| 22 | import k18 from "../http/marks/api-v1-contribute.json"; | |
| 23 | import k19 from "../http/marks/api-v1-conversation-confirms.json"; | |
| 24 | import k20 from "../http/marks/api-v1-conversation-tokens.json"; | |
| 25 | import k21 from "../http/marks/api-v1-conversation.json"; | |
| 26 | import k22 from "../http/marks/api-v1-conversations.json"; | |
| 27 | import k23 from "../http/marks/api-v1-credit.json"; | |
| 28 | import k24 from "../http/marks/api-v1-crew.json"; | |
| 29 | import k25 from "../http/marks/api-v1-devices.json"; | |
| 30 | import k26 from "../http/marks/api-v1-drills.json"; | |
| 31 | import k27 from "../http/marks/api-v1-explore.json"; | |
| 32 | import k28 from "../http/marks/api-v1-family.json"; | |
| 33 | import k29 from "../http/marks/api-v1-features.json"; | |
| 34 | import k30 from "../http/marks/api-v1-feed.json"; | |
| 35 | import k31 from "../http/marks/api-v1-first-admin.json"; | |
| 36 | import k32 from "../http/marks/api-v1-flags.json"; | |
| 37 | import k33 from "../http/marks/api-v1-fleet.json"; | |
| 38 | import k34 from "../http/marks/api-v1-flow.json"; | |
| 39 | import k35 from "../http/marks/api-v1-forge-templates.json"; | |
| 40 | import k36 from "../http/marks/api-v1-forge.json"; | |
| 41 | import k37 from "../http/marks/api-v1-forges.json"; | |
| 42 | import k38 from "../http/marks/api-v1-forks.json"; | |
| 43 | import k39 from "../http/marks/api-v1-front.json"; | |
| 44 | import k40 from "../http/marks/api-v1-games.json"; | |
| 45 | import k41 from "../http/marks/api-v1-health.json"; | |
| 46 | import k42 from "../http/marks/api-v1-heartbeat.json"; | |
| 47 | import k43 from "../http/marks/api-v1-here.json"; | |
| 48 | import k44 from "../http/marks/api-v1-home.json"; | |
| 49 | import k45 from "../http/marks/api-v1-keeper.json"; | |
| 50 | import k46 from "../http/marks/api-v1-mail-key.json"; | |
| 51 | import k47 from "../http/marks/api-v1-maintenance.json"; | |
| 52 | import k48 from "../http/marks/api-v1-map.json"; | |
| 53 | import k49 from "../http/marks/api-v1-migrate.json"; | |
| 54 | import k50 from "../http/marks/api-v1-models.json"; | |
| 55 | import k51 from "../http/marks/api-v1-offers.json"; | |
| 56 | import k52 from "../http/marks/api-v1-openapi.json.json"; | |
| 57 | import k53 from "../http/marks/api-v1-orgs.json"; | |
| 58 | import k54 from "../http/marks/api-v1-packs.json"; | |
| 59 | import k55 from "../http/marks/api-v1-passport.json"; | |
| 60 | import k56 from "../http/marks/api-v1-places.json"; | |
| 61 | import k57 from "../http/marks/api-v1-plans.json"; | |
| 62 | import k58 from "../http/marks/api-v1-proof.json"; | |
| 63 | import k59 from "../http/marks/api-v1-reach.json"; | |
| 64 | import k60 from "../http/marks/api-v1-release.json"; | |
| 65 | import k61 from "../http/marks/api-v1-releases.json"; | |
| 66 | import k62 from "../http/marks/api-v1-repos.json"; | |
| 67 | import k63 from "../http/marks/api-v1-returns.json"; | |
| 68 | import k64 from "../http/marks/api-v1-runner.json"; | |
| 69 | import k65 from "../http/marks/api-v1-search.json"; | |
| 70 | import k66 from "../http/marks/api-v1-secrets.json"; | |
| 71 | import k67 from "../http/marks/api-v1-sessions.json"; | |
| 72 | import k68 from "../http/marks/api-v1-share.json"; | |
| 73 | import k69 from "../http/marks/api-v1-slash.json"; | |
| 74 | import k70 from "../http/marks/api-v1-start.json"; | |
| 75 | import k71 from "../http/marks/api-v1-status.json"; | |
| 76 | import k72 from "../http/marks/api-v1-telemetry.json"; | |
| 77 | import k73 from "../http/marks/api-v1-templates.json"; | |
| 78 | import k74 from "../http/marks/api-v1-thoughts.json"; | |
| 79 | import k75 from "../http/marks/api-v1-timers.json"; | |
| 80 | import k76 from "../http/marks/api-v1-tokens.json"; | |
| 81 | import k77 from "../http/marks/api-v1-usage.json"; | |
| 82 | import k78 from "../http/marks/api-v1-user.json"; | |
| 83 | import k79 from "../http/marks/api-v1-users.json"; | |
| 84 | import k80 from "../http/marks/api-v1-version.json"; | |
| 85 | import k81 from "../http/marks/api-v1.json"; | |
| 86 | import k82 from "../http/marks/api.json"; | |
| 87 | import k83 from "../http/marks/apple-touch-icon-precomposed.png.json"; | |
| 88 | import k84 from "../http/marks/apple-touch-icon.png.json"; | |
| 89 | import k85 from "../http/marks/apps.json"; | |
| 90 | import k86 from "../http/marks/archive.json"; | |
| 91 | import k87 from "../http/marks/asked.json"; | |
| 92 | import k88 from "../http/marks/asks.json"; | |
| 93 | import k89 from "../http/marks/assets.json"; | |
| 94 | import k90 from "../http/marks/audit.csv.json"; | |
| 95 | import k91 from "../http/marks/audit.json"; | |
| 96 | import k92 from "../http/marks/big.json"; | |
| 97 | import k93 from "../http/marks/board.json"; | |
| 98 | import k94 from "../http/marks/boards.json"; | |
| 99 | import k95 from "../http/marks/bring.json"; | |
| 100 | import k96 from "../http/marks/broker.json"; | |
| 101 | import k97 from "../http/marks/changelog.atom.json"; | |
| 102 | import k98 from "../http/marks/changelog.json"; | |
| 103 | import k99 from "../http/marks/claim.json"; | |
| 104 | import k100 from "../http/marks/client-clouds.json"; | |
| 105 | import k101 from "../http/marks/cloud.json"; | |
| 106 | import k102 from "../http/marks/cockpit.json"; | |
| 107 | import k103 from "../http/marks/contract.json"; | |
| 108 | import k104 from "../http/marks/contribute.json"; | |
| 109 | import k105 from "../http/marks/csp-report.json"; | |
| 110 | import k106 from "../http/marks/dash.json"; | |
| 111 | import k107 from "../http/marks/data.json"; | |
| 112 | import k108 from "../http/marks/dataset.json"; | |
| 113 | import k109 from "../http/marks/deploy-to.json"; | |
| 114 | import k110 from "../http/marks/design.json"; | |
| 115 | import k111 from "../http/marks/desk.json"; | |
| 116 | import k112 from "../http/marks/displays.json"; | |
| 117 | import k113 from "../http/marks/docs.json"; | |
| 118 | import k114 from "../http/marks/edge.json"; | |
| 119 | import k115 from "../http/marks/edition.json"; | |
| 120 | import k116 from "../http/marks/events.json"; | |
| 121 | import k117 from "../http/marks/explore.atom.json"; | |
| 122 | import k118 from "../http/marks/explore.json"; | |
| 123 | import k119 from "../http/marks/explore.json.json"; | |
| 124 | import k120 from "../http/marks/family.json"; | |
| 125 | import k121 from "../http/marks/favicon.ico.json"; | |
| 126 | import k122 from "../http/marks/feed.json"; | |
| 127 | import k123 from "../http/marks/feed.json.json"; | |
| 128 | import k124 from "../http/marks/first-admin.json"; | |
| 129 | import k125 from "../http/marks/fleet.json"; | |
| 130 | import k126 from "../http/marks/flow.json"; | |
| 131 | import k127 from "../http/marks/forge.json"; | |
| 132 | import k128 from "../http/marks/forges.json"; | |
| 133 | import k129 from "../http/marks/forks.json"; | |
| 134 | import k130 from "../http/marks/front.json"; | |
| 135 | import k131 from "../http/marks/funnel.json"; | |
| 136 | import k132 from "../http/marks/games.json"; | |
| 137 | import k133 from "../http/marks/go.json"; | |
| 138 | import k134 from "../http/marks/health.json"; | |
| 139 | import k135 from "../http/marks/home.json"; | |
| 140 | import k136 from "../http/marks/hooks.json"; | |
| 141 | import k137 from "../http/marks/icons.json"; | |
| 142 | import k138 from "../http/marks/infra.json"; | |
| 143 | import k139 from "../http/marks/join.json"; | |
| 144 | import k140 from "../http/marks/live.json"; | |
| 145 | import k141 from "../http/marks/llms-full.txt.json"; | |
| 146 | import k142 from "../http/marks/llms.txt.json"; | |
| 147 | import k143 from "../http/marks/login.json"; | |
| 148 | import k144 from "../http/marks/logout.json"; | |
| 149 | import k145 from "../http/marks/maintenance-json.json"; | |
| 150 | import k146 from "../http/marks/maintenance.json"; | |
| 151 | import k147 from "../http/marks/manifest.webmanifest.json"; | |
| 152 | import k148 from "../http/marks/map.json"; | |
| 153 | import k149 from "../http/marks/mcp.json"; | |
| 154 | import k150 from "../http/marks/measure.json"; | |
| 155 | import k151 from "../http/marks/metrics.json"; | |
| 156 | import k152 from "../http/marks/migrate.json"; | |
| 157 | import k153 from "../http/marks/new.json"; | |
| 158 | import k154 from "../http/marks/next.json"; | |
| 159 | import k155 from "../http/marks/notes.json"; | |
| 160 | import k156 from "../http/marks/now.json"; | |
| 161 | import k157 from "../http/marks/oauth.json"; | |
| 162 | import k158 from "../http/marks/oembed.json"; | |
| 163 | import k159 from "../http/marks/offers.json"; | |
| 164 | import k160 from "../http/marks/offline.json"; | |
| 165 | import k161 from "../http/marks/og.json"; | |
| 166 | import k162 from "../http/marks/openapi.json.json"; | |
| 167 | import k163 from "../http/marks/opensearch.xml.json"; | |
| 168 | import k164 from "../http/marks/organizations.json"; | |
| 169 | import k165 from "../http/marks/origins.json"; | |
| 170 | import k166 from "../http/marks/owner.atom.json"; | |
| 171 | import k167 from "../http/marks/owner.json"; | |
| 172 | import k168 from "../http/marks/packs.json"; | |
| 173 | import k169 from "../http/marks/peek.json"; | |
| 174 | import k170 from "../http/marks/pinned.json"; | |
| 175 | import k171 from "../http/marks/pipeline.json"; | |
| 176 | import k172 from "../http/marks/plugins.json"; | |
| 177 | import k173 from "../http/marks/pricing.json"; | |
| 178 | import k174 from "../http/marks/privacy.json"; | |
| 179 | import k175 from "../http/marks/r.json"; | |
| 180 | import k176 from "../http/marks/recover.json"; | |
| 181 | import k177 from "../http/marks/releases.json"; | |
| 182 | import k178 from "../http/marks/releases.json.json"; | |
| 183 | import k179 from "../http/marks/repos.json"; | |
| 184 | import k180 from "../http/marks/resilience.json"; | |
| 185 | import k181 from "../http/marks/review.json"; | |
| 186 | import k182 from "../http/marks/robots.txt.json"; | |
| 187 | import k183 from "../http/marks/root.json"; | |
| 188 | import k184 from "../http/marks/runs.json"; | |
| 189 | import k185 from "../http/marks/script-error.json"; | |
| 190 | import k186 from "../http/marks/search.json"; | |
| 191 | import k187 from "../http/marks/security.json"; | |
| 192 | import k188 from "../http/marks/settings.json"; | |
| 193 | import k189 from "../http/marks/sign-in.json"; | |
| 194 | import k190 from "../http/marks/signin.json"; | |
| 195 | import k191 from "../http/marks/signup.json"; | |
| 196 | import k192 from "../http/marks/sitemap.xml.json"; | |
| 197 | import k193 from "../http/marks/status.json"; | |
| 198 | import k194 from "../http/marks/support.json"; | |
| 199 | import k195 from "../http/marks/sw.js.json"; | |
| 200 | import k196 from "../http/marks/system.json"; | |
| 201 | import k197 from "../http/marks/tab.json"; | |
| 202 | import k198 from "../http/marks/tabforge.json"; | |
| 203 | import k199 from "../http/marks/talk.json"; | |
| 204 | import k200 from "../http/marks/tell.json"; | |
| 205 | import k201 from "../http/marks/templates.json"; | |
| 206 | import k202 from "../http/marks/templates.json.json"; | |
| 207 | import k203 from "../http/marks/terms.json"; | |
| 208 | import k204 from "../http/marks/theme.json"; | |
| 209 | import k205 from "../http/marks/toolbar-lab.js.json"; | |
| 210 | import k206 from "../http/marks/toolbar-lab.json"; | |
| 211 | import k207 from "../http/marks/traces.json"; | |
| 212 | import k208 from "../http/marks/verify.json"; | |
| 213 | import k209 from "../http/marks/welcome.json"; | |
| 214 | import k210 from "../http/marks/well-known.json"; | |
| 13 | import k9 from "../http/marks/api-v1-arcade.json"; | |
| 14 | import k10 from "../http/marks/api-v1-asks.json"; | |
| 15 | import k11 from "../http/marks/api-v1-boards.json"; | |
| 16 | import k12 from "../http/marks/api-v1-broker.json"; | |
| 17 | import k13 from "../http/marks/api-v1-builds.json"; | |
| 18 | import k14 from "../http/marks/api-v1-cache.json"; | |
| 19 | import k15 from "../http/marks/api-v1-changelog.json"; | |
| 20 | import k16 from "../http/marks/api-v1-cloud.json"; | |
| 21 | import k17 from "../http/marks/api-v1-codes.json"; | |
| 22 | import k18 from "../http/marks/api-v1-config.json"; | |
| 23 | import k19 from "../http/marks/api-v1-contribute.json"; | |
| 24 | import k20 from "../http/marks/api-v1-conversation-confirms.json"; | |
| 25 | import k21 from "../http/marks/api-v1-conversation-tokens.json"; | |
| 26 | import k22 from "../http/marks/api-v1-conversation.json"; | |
| 27 | import k23 from "../http/marks/api-v1-conversations.json"; | |
| 28 | import k24 from "../http/marks/api-v1-credit.json"; | |
| 29 | import k25 from "../http/marks/api-v1-crew.json"; | |
| 30 | import k26 from "../http/marks/api-v1-devices.json"; | |
| 31 | import k27 from "../http/marks/api-v1-drills.json"; | |
| 32 | import k28 from "../http/marks/api-v1-explore.json"; | |
| 33 | import k29 from "../http/marks/api-v1-family.json"; | |
| 34 | import k30 from "../http/marks/api-v1-features.json"; | |
| 35 | import k31 from "../http/marks/api-v1-feed.json"; | |
| 36 | import k32 from "../http/marks/api-v1-first-admin.json"; | |
| 37 | import k33 from "../http/marks/api-v1-flags.json"; | |
| 38 | import k34 from "../http/marks/api-v1-fleet.json"; | |
| 39 | import k35 from "../http/marks/api-v1-flow.json"; | |
| 40 | import k36 from "../http/marks/api-v1-forge-templates.json"; | |
| 41 | import k37 from "../http/marks/api-v1-forge.json"; | |
| 42 | import k38 from "../http/marks/api-v1-forges.json"; | |
| 43 | import k39 from "../http/marks/api-v1-forks.json"; | |
| 44 | import k40 from "../http/marks/api-v1-front.json"; | |
| 45 | import k41 from "../http/marks/api-v1-games.json"; | |
| 46 | import k42 from "../http/marks/api-v1-health.json"; | |
| 47 | import k43 from "../http/marks/api-v1-heartbeat.json"; | |
| 48 | import k44 from "../http/marks/api-v1-here.json"; | |
| 49 | import k45 from "../http/marks/api-v1-home.json"; | |
| 50 | import k46 from "../http/marks/api-v1-keeper.json"; | |
| 51 | import k47 from "../http/marks/api-v1-mail-key.json"; | |
| 52 | import k48 from "../http/marks/api-v1-maintenance.json"; | |
| 53 | import k49 from "../http/marks/api-v1-map.json"; | |
| 54 | import k50 from "../http/marks/api-v1-migrate.json"; | |
| 55 | import k51 from "../http/marks/api-v1-models.json"; | |
| 56 | import k52 from "../http/marks/api-v1-offers.json"; | |
| 57 | import k53 from "../http/marks/api-v1-openapi.json.json"; | |
| 58 | import k54 from "../http/marks/api-v1-orgs.json"; | |
| 59 | import k55 from "../http/marks/api-v1-packs.json"; | |
| 60 | import k56 from "../http/marks/api-v1-passport.json"; | |
| 61 | import k57 from "../http/marks/api-v1-places.json"; | |
| 62 | import k58 from "../http/marks/api-v1-plans.json"; | |
| 63 | import k59 from "../http/marks/api-v1-proof.json"; | |
| 64 | import k60 from "../http/marks/api-v1-reach.json"; | |
| 65 | import k61 from "../http/marks/api-v1-release.json"; | |
| 66 | import k62 from "../http/marks/api-v1-releases.json"; | |
| 67 | import k63 from "../http/marks/api-v1-repos.json"; | |
| 68 | import k64 from "../http/marks/api-v1-returns.json"; | |
| 69 | import k65 from "../http/marks/api-v1-runner.json"; | |
| 70 | import k66 from "../http/marks/api-v1-search.json"; | |
| 71 | import k67 from "../http/marks/api-v1-secrets.json"; | |
| 72 | import k68 from "../http/marks/api-v1-sessions.json"; | |
| 73 | import k69 from "../http/marks/api-v1-share.json"; | |
| 74 | import k70 from "../http/marks/api-v1-slash.json"; | |
| 75 | import k71 from "../http/marks/api-v1-start.json"; | |
| 76 | import k72 from "../http/marks/api-v1-status.json"; | |
| 77 | import k73 from "../http/marks/api-v1-telemetry.json"; | |
| 78 | import k74 from "../http/marks/api-v1-templates.json"; | |
| 79 | import k75 from "../http/marks/api-v1-thoughts.json"; | |
| 80 | import k76 from "../http/marks/api-v1-timers.json"; | |
| 81 | import k77 from "../http/marks/api-v1-tokens.json"; | |
| 82 | import k78 from "../http/marks/api-v1-usage.json"; | |
| 83 | import k79 from "../http/marks/api-v1-user.json"; | |
| 84 | import k80 from "../http/marks/api-v1-users.json"; | |
| 85 | import k81 from "../http/marks/api-v1-version.json"; | |
| 86 | import k82 from "../http/marks/api-v1.json"; | |
| 87 | import k83 from "../http/marks/api.json"; | |
| 88 | import k84 from "../http/marks/apple-touch-icon-precomposed.png.json"; | |
| 89 | import k85 from "../http/marks/apple-touch-icon.png.json"; | |
| 90 | import k86 from "../http/marks/apps.json"; | |
| 91 | import k87 from "../http/marks/archive.json"; | |
| 92 | import k88 from "../http/marks/asked.json"; | |
| 93 | import k89 from "../http/marks/asks.json"; | |
| 94 | import k90 from "../http/marks/assets.json"; | |
| 95 | import k91 from "../http/marks/audit.csv.json"; | |
| 96 | import k92 from "../http/marks/audit.json"; | |
| 97 | import k93 from "../http/marks/big.json"; | |
| 98 | import k94 from "../http/marks/board.json"; | |
| 99 | import k95 from "../http/marks/boards.json"; | |
| 100 | import k96 from "../http/marks/bring.json"; | |
| 101 | import k97 from "../http/marks/broker.json"; | |
| 102 | import k98 from "../http/marks/changelog.atom.json"; | |
| 103 | import k99 from "../http/marks/changelog.json"; | |
| 104 | import k100 from "../http/marks/claim.json"; | |
| 105 | import k101 from "../http/marks/client-clouds.json"; | |
| 106 | import k102 from "../http/marks/cloud.json"; | |
| 107 | import k103 from "../http/marks/cockpit.json"; | |
| 108 | import k104 from "../http/marks/contract.json"; | |
| 109 | import k105 from "../http/marks/contribute.json"; | |
| 110 | import k106 from "../http/marks/csp-report.json"; | |
| 111 | import k107 from "../http/marks/dash.json"; | |
| 112 | import k108 from "../http/marks/data.json"; | |
| 113 | import k109 from "../http/marks/dataset.json"; | |
| 114 | import k110 from "../http/marks/deploy-to.json"; | |
| 115 | import k111 from "../http/marks/design.json"; | |
| 116 | import k112 from "../http/marks/desk.json"; | |
| 117 | import k113 from "../http/marks/displays.json"; | |
| 118 | import k114 from "../http/marks/docs.json"; | |
| 119 | import k115 from "../http/marks/edge.json"; | |
| 120 | import k116 from "../http/marks/edition.json"; | |
| 121 | import k117 from "../http/marks/events.json"; | |
| 122 | import k118 from "../http/marks/explore.atom.json"; | |
| 123 | import k119 from "../http/marks/explore.json"; | |
| 124 | import k120 from "../http/marks/explore.json.json"; | |
| 125 | import k121 from "../http/marks/family.json"; | |
| 126 | import k122 from "../http/marks/favicon.ico.json"; | |
| 127 | import k123 from "../http/marks/feed.json"; | |
| 128 | import k124 from "../http/marks/feed.json.json"; | |
| 129 | import k125 from "../http/marks/first-admin.json"; | |
| 130 | import k126 from "../http/marks/fleet.json"; | |
| 131 | import k127 from "../http/marks/flow.json"; | |
| 132 | import k128 from "../http/marks/forge.json"; | |
| 133 | import k129 from "../http/marks/forges.json"; | |
| 134 | import k130 from "../http/marks/forks.json"; | |
| 135 | import k131 from "../http/marks/front.json"; | |
| 136 | import k132 from "../http/marks/funnel.json"; | |
| 137 | import k133 from "../http/marks/games.json"; | |
| 138 | import k134 from "../http/marks/go.json"; | |
| 139 | import k135 from "../http/marks/health.json"; | |
| 140 | import k136 from "../http/marks/home.json"; | |
| 141 | import k137 from "../http/marks/hooks.json"; | |
| 142 | import k138 from "../http/marks/icons.json"; | |
| 143 | import k139 from "../http/marks/infra.json"; | |
| 144 | import k140 from "../http/marks/join.json"; | |
| 145 | import k141 from "../http/marks/live.json"; | |
| 146 | import k142 from "../http/marks/llms-full.txt.json"; | |
| 147 | import k143 from "../http/marks/llms.txt.json"; | |
| 148 | import k144 from "../http/marks/login.json"; | |
| 149 | import k145 from "../http/marks/logout.json"; | |
| 150 | import k146 from "../http/marks/maintenance-json.json"; | |
| 151 | import k147 from "../http/marks/maintenance.json"; | |
| 152 | import k148 from "../http/marks/manifest.webmanifest.json"; | |
| 153 | import k149 from "../http/marks/map.json"; | |
| 154 | import k150 from "../http/marks/mcp.json"; | |
| 155 | import k151 from "../http/marks/measure.json"; | |
| 156 | import k152 from "../http/marks/metrics.json"; | |
| 157 | import k153 from "../http/marks/migrate.json"; | |
| 158 | import k154 from "../http/marks/new.json"; | |
| 159 | import k155 from "../http/marks/next.json"; | |
| 160 | import k156 from "../http/marks/notes.json"; | |
| 161 | import k157 from "../http/marks/now.json"; | |
| 162 | import k158 from "../http/marks/oauth.json"; | |
| 163 | import k159 from "../http/marks/oembed.json"; | |
| 164 | import k160 from "../http/marks/offers.json"; | |
| 165 | import k161 from "../http/marks/offline.json"; | |
| 166 | import k162 from "../http/marks/og.json"; | |
| 167 | import k163 from "../http/marks/openapi.json.json"; | |
| 168 | import k164 from "../http/marks/opensearch.xml.json"; | |
| 169 | import k165 from "../http/marks/organizations.json"; | |
| 170 | import k166 from "../http/marks/origins.json"; | |
| 171 | import k167 from "../http/marks/owner.atom.json"; | |
| 172 | import k168 from "../http/marks/owner.json"; | |
| 173 | import k169 from "../http/marks/packs.json"; | |
| 174 | import k170 from "../http/marks/peek.json"; | |
| 175 | import k171 from "../http/marks/pinned.json"; | |
| 176 | import k172 from "../http/marks/pipeline.json"; | |
| 177 | import k173 from "../http/marks/plugins.json"; | |
| 178 | import k174 from "../http/marks/pricing.json"; | |
| 179 | import k175 from "../http/marks/privacy.json"; | |
| 180 | import k176 from "../http/marks/r.json"; | |
| 181 | import k177 from "../http/marks/recover.json"; | |
| 182 | import k178 from "../http/marks/releases.json"; | |
| 183 | import k179 from "../http/marks/releases.json.json"; | |
| 184 | import k180 from "../http/marks/repos.json"; | |
| 185 | import k181 from "../http/marks/resilience.json"; | |
| 186 | import k182 from "../http/marks/review.json"; | |
| 187 | import k183 from "../http/marks/robots.txt.json"; | |
| 188 | import k184 from "../http/marks/root.json"; | |
| 189 | import k185 from "../http/marks/runs.json"; | |
| 190 | import k186 from "../http/marks/script-error.json"; | |
| 191 | import k187 from "../http/marks/search.json"; | |
| 192 | import k188 from "../http/marks/security.json"; | |
| 193 | import k189 from "../http/marks/settings.json"; | |
| 194 | import k190 from "../http/marks/sign-in.json"; | |
| 195 | import k191 from "../http/marks/signin.json"; | |
| 196 | import k192 from "../http/marks/signup.json"; | |
| 197 | import k193 from "../http/marks/sitemap.xml.json"; | |
| 198 | import k194 from "../http/marks/status.json"; | |
| 199 | import k195 from "../http/marks/support.json"; | |
| 200 | import k196 from "../http/marks/sw.js.json"; | |
| 201 | import k197 from "../http/marks/system.json"; | |
| 202 | import k198 from "../http/marks/tab.json"; | |
| 203 | import k199 from "../http/marks/tabforge.json"; | |
| 204 | import k200 from "../http/marks/talk.json"; | |
| 205 | import k201 from "../http/marks/tell.json"; | |
| 206 | import k202 from "../http/marks/templates.json"; | |
| 207 | import k203 from "../http/marks/templates.json.json"; | |
| 208 | import k204 from "../http/marks/terms.json"; | |
| 209 | import k205 from "../http/marks/theme.json"; | |
| 210 | import k206 from "../http/marks/toolbar-lab.js.json"; | |
| 211 | import k207 from "../http/marks/toolbar-lab.json"; | |
| 212 | import k208 from "../http/marks/traces.json"; | |
| 213 | import k209 from "../http/marks/verify.json"; | |
| 214 | import k210 from "../http/marks/welcome.json"; | |
| 215 | import k211 from "../http/marks/well-known.json"; | |
| 215 | 216 | |
| 216 | 217 | /** Each file of `http/marks/`, parsed, in name order. */ |
| 217 | 218 | export const MARK_FILES: readonly unknown[] = [ |
| @@ -426,4 +427,5 @@ export const MARK_FILES: readonly unknown[] = [ | ||
| 426 | 427 | k208, |
| 427 | 428 | k209, |
| 428 | 429 | k210, |
| 430 | k211, | |
| 429 | 431 | ]; |
src/http/api.ts +2
| @@ -347,6 +347,7 @@ import { visionRoutes } from "./api/vision.ts"; | ||
| 347 | 347 | import { businessPlanRoutes } from "./api/business_plan.ts"; |
| 348 | 348 | import { tokenRoutes } from "./api/tokens.ts"; |
| 349 | 349 | import { accountAdmin, adminRoutes } from "./api/admin.ts"; |
| 350 | import { arcadeRoutes } from "./api/arcade.ts"; | |
| 350 | 351 | import { runnerRoutes } from "./api/runners.ts"; |
| 351 | 352 | import { maintenanceRoutes } from "./api/maintenance.ts"; |
| 352 | 353 | import { maintenanceRunsRoutes } from "./api/maintenance_runs.ts"; |
| @@ -1285,6 +1286,7 @@ export function apiRoutes(router: Router<Handler>, isPage: (path: string) => boo | ||
| 1285 | 1286 | forgeOriginRoutes(router); |
| 1286 | 1287 | adminRoutes(router); |
| 1287 | 1288 | runnerRoutes(router); |
| 1289 | arcadeRoutes(router); | |
| 1288 | 1290 | gamesApiRoutes(router); |
| 1289 | 1291 | maintenanceRoutes(router); |
| 1290 | 1292 | maintenanceRunsRoutes(router); |
src/http/api/app.ts +18
| @@ -14,6 +14,7 @@ import { addAppDomain, claimAppDomain, claimProofRecord, checkAppDomain, keepOld | ||
| 14 | 14 | import { clearDemo, setDemo } from "../../actions/demo.ts"; |
| 15 | 15 | import { previewBuild, previewBuildRefusalText } from "../../actions/build_preview.ts"; |
| 16 | 16 | import { SETTING_WORDS } from "../../actions/setting_words.ts"; |
| 17 | import { appLog } from "../../actions/app_log.ts"; | |
| 17 | 18 | import { appsRuntime } from "../../apps/runtime_registry.ts"; |
| 18 | 19 | import { canAdmin, canRead, getRepo } from "../../core/repos.ts"; |
| 19 | 20 | import { notePhase, takeSessionTime, timePhase } from "../../core/route_timing.ts"; |
| @@ -441,6 +442,23 @@ export function appRoutes(router: Router<Handler>): void { | ||
| 441 | 442 | return json({ env: preview.value.env, url: preview.value.url }, 201); |
| 442 | 443 | }); |
| 443 | 444 | |
| 445 | // The running app's recent lines as text, for a writer (#18038): the deploy run's log tail, | |
| 446 | // bounded at `APP_LOG_LINES`; an environment that never ran answers an empty body. | |
| 447 | router.add("GET", "/api/v1/repos/:owner/:name/app/:env/log", (ctx) => { | |
| 448 | const repo = loadRepo(ctx); | |
| 449 | if (!repo) return notFound(); | |
| 450 | const read = appLog(ctx.app, ctx.auth.user, repo, ctx.params.env ?? ""); | |
| 451 | if (!read.ok) return respondAccess(read.error, 422); | |
| 452 | const text = read.value.lines.length === 0 ? "" : `${read.value.lines.join("\n")}\n`; | |
| 453 | return new Response(text, { | |
| 454 | headers: { | |
| 455 | "content-type": "text/plain; charset=utf-8", | |
| 456 | "cache-control": "no-store", | |
| 457 | ...(read.value.truncated ? { "x-log-truncated": "1" } : {}), | |
| 458 | }, | |
| 459 | }); | |
| 460 | }); | |
| 461 | ||
| 444 | 462 | // The URL to open an environment at. For a private app it carries a |
| 445 | 463 | // grant, so the answer is for the caller alone and is not cached. |
| 446 | 464 | // `openEnvUrl` decides who may enter: a person a private app names enters |
src/http/api/arcade.ts added +17
| @@ -0,0 +1,17 @@ | ||
| 1 | /** | |
| 2 | * The Arcade over the API (#18038): `GET /api/v1/arcade/games` lists its games and builds, as the | |
| 3 | * arcade host's `games.json` does, each build with the URL to play it. Public, as the host is: the | |
| 4 | * display is read as a stranger reads it, so no private source is named. | |
| 5 | */ | |
| 6 | ||
| 7 | import { arcadeGames } from "../../arcade/games_list.ts"; | |
| 8 | import type { Handler } from "../context.ts"; | |
| 9 | import { json } from "../respond.ts"; | |
| 10 | import type { Router } from "../router.ts"; | |
| 11 | ||
| 12 | export function arcadeRoutes(router: Router<Handler>): void { | |
| 13 | router.add("GET", "/api/v1/arcade/games", async (ctx) => { | |
| 14 | const { host, items } = await arcadeGames(ctx.app); | |
| 15 | return json({ host, items, next_cursor: null }); | |
| 16 | }); | |
| 17 | } |
src/http/api/runners.ts +13 −1
| @@ -12,7 +12,7 @@ | ||
| 12 | 12 | import { dropHands, takeHand } from "../../checks/runner_hands.ts"; |
| 13 | 13 | import { HAND_BYTES_MAX } from "../../checks/hand_files.ts"; |
| 14 | 14 | import { listLending, offerLending, resumeLending, stopLending } from "../../actions/lending.ts"; |
| 15 | import { enrol, hearCanary, list, remove, resume, revoke } from "../../actions/runners.ts"; | |
| 15 | import { enrol, hearCanary, list, pause, remove, resume, revoke } from "../../actions/runners.ts"; | |
| 16 | 16 | import type { LendInput } from "../../checks/lent_scope.ts"; |
| 17 | 17 | import { machineLoad, mayTakeJob, yieldThreshold } from "../../checks/lent_yield.ts"; |
| 18 | 18 | import { |
| @@ -142,6 +142,18 @@ export function runnerRoutes(router: Router<Handler>): void { | ||
| 142 | 142 | return notFound(); |
| 143 | 143 | }); |
| 144 | 144 | |
| 145 | // Beside resume: an admin holds a runner; its running job finishes, it claims no more. | |
| 146 | router.add("POST", "/api/v1/admin/runners/:id/pause", (ctx) => { | |
| 147 | const denied = accountAdmin(ctx, "admin"); | |
| 148 | if (denied) return denied; | |
| 149 | const done = pause(ctx.app, ctx.auth.user, ctx.params.id!); | |
| 150 | if (done.ok) return json({ id: done.value.id, name: done.value.name, paused: done.value.paused }); | |
| 151 | if (done.error === "local") return apiError("local", 422, "a local-N runner is the forge's own; it cannot be paused"); | |
| 152 | if (done.error === "revoked") return apiError("revoked", 422, "that runner is revoked"); | |
| 153 | if (done.error === "paused") return apiError("paused", 422, "that runner is paused already"); | |
| 154 | return notFound(); | |
| 155 | }); | |
| 156 | ||
| 145 | 157 | router.add("POST", "/api/v1/admin/runners/:id/resume", (ctx) => { |
| 146 | 158 | const denied = accountAdmin(ctx, "admin"); |
| 147 | 159 | if (denied) return denied; |
src/http/lazy_lists.ts +3
| @@ -1293,6 +1293,7 @@ export const API_ROUTES = [ | ||
| 1293 | 1293 | ["DELETE", "/api/v1/admin/accounts/:username"], |
| 1294 | 1294 | ["POST", "/api/v1/admin/runners"], |
| 1295 | 1295 | ["POST", "/api/v1/admin/runners/:id/revoke"], |
| 1296 | ["POST", "/api/v1/admin/runners/:id/pause"], | |
| 1296 | 1297 | ["POST", "/api/v1/admin/runners/:id/resume"], |
| 1297 | 1298 | ["POST", "/api/v1/admin/lending"], |
| 1298 | 1299 | ["GET", "/api/v1/admin/lending"], |
| @@ -1306,6 +1307,7 @@ export const API_ROUTES = [ | ||
| 1306 | 1307 | ["POST", "/api/v1/runner/jobs/:id/hand"], |
| 1307 | 1308 | ["GET", "/api/v1/runner/jobs/:id/git/info/refs"], |
| 1308 | 1309 | ["POST", "/api/v1/runner/jobs/:id/git/git-upload-pack"], |
| 1310 | ["GET", "/api/v1/arcade/games"], | |
| 1309 | 1311 | ["POST", "/api/v1/games/agent/sync"], |
| 1310 | 1312 | ["GET", "/api/v1/games/agent/script"], |
| 1311 | 1313 | ["GET", "/api/v1/admin/maintenance"], |
| @@ -1613,6 +1615,7 @@ export const API_ROUTES = [ | ||
| 1613 | 1615 | ["PUT", "/api/v1/repos/:owner/:name/demo"], |
| 1614 | 1616 | ["DELETE", "/api/v1/repos/:owner/:name/demo"], |
| 1615 | 1617 | ["POST", "/api/v1/repos/:owner/:name/builds/preview"], |
| 1618 | ["GET", "/api/v1/repos/:owner/:name/app/:env/log"], | |
| 1616 | 1619 | ["GET", "/api/v1/repos/:owner/:name/app/:env/open"], |
| 1617 | 1620 | ["GET", "/api/v1/repos/:owner/:name/app/pulls"], |
| 1618 | 1621 | ["GET", "/api/v1/repos/:owner/:name/pulls/:number/diff"], |
src/http/marks/api-v1-arcade.json added +4
src/tui/screens/runners.ts +11 −3
| @@ -6,7 +6,7 @@ | ||
| 6 | 6 | * offered it. |
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | import { list, removeHandMade, resume, revoke, runnerState } from "../../actions/runners.ts"; | |
| 9 | import { list, pause, removeHandMade, resume, revoke, runnerState } from "../../actions/runners.ts"; | |
| 10 | 10 | import { isLocal } from "../../checks/runner_pool.ts"; |
| 11 | 11 | import { listLending, offerLending, resumeLending, stopLending, type LendView } from "../../actions/lending.ts"; |
| 12 | 12 | import { proofByRunner, proofWords } from "../../games/lent_proof.ts"; |
| @@ -145,6 +145,7 @@ export function runnersScreen(f: Session, ctx: Ctx): Screen { | ||
| 145 | 145 | keys: [ |
| 146 | 146 | binding(["j", "k"], "move cursor"), |
| 147 | 147 | binding(["x"], "revoke or remove a runner"), |
| 148 | binding(["p"], "pause a runner"), | |
| 148 | 149 | binding(["u"], "resume"), |
| 149 | 150 | binding(["c"], "lend runners to a forge"), |
| 150 | 151 | binding(["s"], "stop lending"), |
| @@ -157,7 +158,7 @@ export function runnersScreen(f: Session, ctx: Ctx): Screen { | ||
| 157 | 158 | ? "Only a forge admin sees the runners." |
| 158 | 159 | : entries().length === 0 |
| 159 | 160 | ? "No runner is enrolled; checks run on the forge's own machine. c lends runners to another forge." |
| 160 | : "The machines that take this forge's checks; x revokes a lent one or removes a hand-made one, u resumes. c lends runners to another forge; on an offer s stops, S stops now."; | |
| 161 | : "The machines that take this forge's checks; x revokes a lent one or removes a hand-made one, p pauses, u resumes. c lends runners to another forge; on an offer s stops, S stops now."; | |
| 161 | 162 | const waiting = mayRunners(f) ? yieldNote(yieldState(process.env["FORGE_LEND_YIELD_LOAD"])) : ""; |
| 162 | 163 | s.text(head!.x, head!.y, truncate(waiting === "" ? text : waiting, head!.w), style(c.mutedFg, c.bg), head!.x + head!.w); |
| 163 | 164 | const lent = mayRunners(f) ? [lentLine(lentIn(f.db, Date.now())), lendingLine(f)].filter((l) => l !== "").join(" · ") : ""; |
| @@ -175,7 +176,14 @@ export function runnersScreen(f: Session, ctx: Ctx): Screen { | ||
| 175 | 176 | const picked = all[state.index]; |
| 176 | 177 | if (picked?.kind === "offer") return e.key === "s" || e.key === "S" || e.key === "u" ? onOffer(picked.o, e.key) : false; |
| 177 | 178 | const at = picked?.r; |
| 178 | if (at === undefined || (e.key !== "x" && e.key !== "u")) return false; | |
| 179 | if (at === undefined || (e.key !== "x" && e.key !== "u" && e.key !== "p")) return false; | |
| 180 | if (e.key === "p") { | |
| 181 | const held = pause(f.app, f.user, at.id); | |
| 182 | const why = { local: `${at.name} is the forge's own; it cannot be paused.`, revoked: "That runner is revoked.", paused: "That runner is paused already.", not_found: "That runner is not enrolled." }; | |
| 183 | ctx.toast(held.ok ? `Runner ${at.name} is paused: u resumes it.` : why[held.error], held.ok ? "success" : "danger"); | |
| 184 | ctx.invalidate(); | |
| 185 | return true; | |
| 186 | } | |
| 179 | 187 | if (e.key === "u") { |
| 180 | 188 | const done = resume(f.app, f.user, at.id); |
| 181 | 189 | ctx.toast(done.ok ? `Runner ${at.name} may claim again.` : "That runner is not paused.", done.ok ? "success" : "danger"); |
test/app-log-api.test.ts added +124
| @@ -0,0 +1,124 @@ | ||
| 1 | /** | |
| 2 | * #18038: an app's log as text (`GET …/app/:env/log`), the Arcade's games | |
| 3 | * (`GET /api/v1/arcade/games`) and pausing a runner (`POST /api/v1/admin/runners/:id/pause`), each | |
| 4 | * driven over HTTP. | |
| 5 | */ | |
| 6 | import { afterAll, beforeAll, describe, expect, test } from "bun:test"; | |
| 7 | import { mkdtemp, rm } from "node:fs/promises"; | |
| 8 | import { tmpdir } from "node:os"; | |
| 9 | import { join } from "node:path"; | |
| 10 | import { enrolRunner, getRunner } from "../src/checks/runner_jobs.ts"; | |
| 11 | import { createApp, type App } from "../src/app.ts"; | |
| 12 | import { AppsRuntime } from "../src/apps/runtime.ts"; | |
| 13 | import { createUser } from "../src/core/users.ts"; | |
| 14 | import { serve, type Servers } from "../src/http/server.ts"; | |
| 15 | import { appendRunLog, flushRunLogs } from "../src/runs/log.ts"; | |
| 16 | import { seedAdmin } from "./helpers/admin.ts"; | |
| 17 | import { tokenFor } from "./helpers/tokens.ts"; | |
| 18 | ||
| 19 | let dataDir: string; | |
| 20 | let app: App; | |
| 21 | let servers: Servers; | |
| 22 | let runtime: AppsRuntime; | |
| 23 | let alice = ""; | |
| 24 | let bob = ""; | |
| 25 | ||
| 26 | const call = (path: string, token: string | null, method = "GET", body?: unknown) => | |
| 27 | fetch(`${servers.url}${path}`, { | |
| 28 | method, | |
| 29 | headers: { | |
| 30 | ...(token === null ? {} : { authorization: `Bearer ${token}` }), | |
| 31 | ...(body === undefined ? {} : { "content-type": "application/json" }), | |
| 32 | }, | |
| 33 | ...(body === undefined ? {} : { body: JSON.stringify(body) }), | |
| 34 | }); | |
| 35 | ||
| 36 | beforeAll(async () => { | |
| 37 | dataDir = await mkdtemp(join(tmpdir(), "forge-app-log-")); | |
| 38 | app = createApp({ dataDir, port: 0 }); | |
| 39 | servers = await serve(app); | |
| 40 | runtime = new AppsRuntime(app, { domain: "apps.test", scheme: "http", publicPort: servers.port, forgeUrl: servers.url }); | |
| 41 | await runtime.start(); | |
| 42 | await seedAdmin(app, { username: "alice", email: "[email protected]", password: "a-good-passphrase" }); | |
| 43 | const b = await createUser(app.db, { origin: "seed", trusted: true, username: "bob", email: "[email protected]", password: "a-good-passphrase" }); | |
| 44 | if (!b.ok) throw new Error(b.error); | |
| 45 | alice = tokenFor(app, "alice", "admin", "a"); | |
| 46 | bob = tokenFor(app, "bob", "rw", "b"); | |
| 47 | const made = await call("/api/v1/apps", alice, "POST", { name: "noted", description: "Keep notes", visibility: "public" }); | |
| 48 | expect(made.status).toBe(201); | |
| 49 | }, 60_000); | |
| 50 | ||
| 51 | afterAll(async () => { | |
| 52 | runtime.stop?.(); | |
| 53 | app.close(); | |
| 54 | await servers.stop?.(); | |
| 55 | await rm(dataDir, { recursive: true, force: true }); | |
| 56 | }); | |
| 57 | ||
| 58 | describe("an app's log", () => { | |
| 59 | test("a writer reads the last 200 lines as text; a reader, a stranger and a bad name are refused", async () => { | |
| 60 | const lines = Array.from({ length: 250 }, (_, i) => `line ${i + 1}`); | |
| 61 | for (const l of lines) appendRunLog(dataDir, "run-for-log", l); | |
| 62 | flushRunLogs(); | |
| 63 | const was = runtime.envStatus.bind(runtime); | |
| 64 | runtime.envStatus = ((record: Parameters<typeof was>[0], env: Parameters<typeof was>[1]) => ({ ...was(record, env), runId: "run-for-log" })) as typeof runtime.envStatus; | |
| 65 | try { | |
| 66 | const res = await call("/api/v1/repos/alice/noted/app/production/log", alice); | |
| 67 | expect(res.status).toBe(200); | |
| 68 | expect(res.headers.get("content-type")).toContain("text/plain"); | |
| 69 | expect(res.headers.get("x-log-truncated")).toBe("1"); | |
| 70 | const got = (await res.text()).split("\n").filter((l) => l !== ""); | |
| 71 | expect(got).toHaveLength(200); | |
| 72 | expect(got[0]).toBe("line 51"); | |
| 73 | expect(got.at(-1)).toBe("line 250"); | |
| 74 | // A reader of a public app may not read its log. | |
| 75 | expect((await call("/api/v1/repos/alice/noted/app/production/log", bob)).status).toBe(403); | |
| 76 | expect((await call("/api/v1/repos/alice/noted/app/production/log", null)).status).toBe(401); | |
| 77 | const bad = await call("/api/v1/repos/alice/noted/app/staging/log", alice); | |
| 78 | expect(bad.status).toBe(422); | |
| 79 | expect(((await bad.json()) as { error: string }).error).toBe("no_such_env"); | |
| 80 | expect((await call("/api/v1/repos/alice/nothing/app/production/log", alice)).status).toBe(404); | |
| 81 | } finally { | |
| 82 | runtime.envStatus = was; | |
| 83 | } | |
| 84 | }); | |
| 85 | ||
| 86 | test("an environment that never ran answers an empty body", async () => { | |
| 87 | const res = await call("/api/v1/repos/alice/noted/app/pull-9/log", alice); | |
| 88 | expect(res.status).toBe(200); | |
| 89 | expect(await res.text()).toBe(""); | |
| 90 | }); | |
| 91 | }); | |
| 92 | ||
| 93 | describe("the Arcade's games", () => { | |
| 94 | test("with no Arcade display the list is empty, and anyone may ask", async () => { | |
| 95 | const res = await call("/api/v1/arcade/games", null); | |
| 96 | expect(res.status).toBe(200); | |
| 97 | const got = (await res.json()) as { host: string | null; items: unknown[]; next_cursor: null }; | |
| 98 | expect(got.items).toEqual([]); | |
| 99 | expect(got.next_cursor).toBeNull(); | |
| 100 | expect(got.host).toBeNull(); | |
| 101 | }); | |
| 102 | }); | |
| 103 | ||
| 104 | describe("pausing a runner", () => { | |
| 105 | test("an admin pauses a runner, a second pause and a local one are refused, resume undoes it", async () => { | |
| 106 | const mac = enrolRunner(app.db, "mac", (await import("../src/core/users.ts")).getUserByName(app.db, "alice")!.id); | |
| 107 | const local = enrolRunner(app.db, "local-7", (await import("../src/core/users.ts")).getUserByName(app.db, "alice")!.id); | |
| 108 | const path = (id: string, verb: string) => `/api/v1/admin/runners/${id}/${verb}`; | |
| 109 | const paused = await call(path(mac.runner.id, "pause"), alice, "POST"); | |
| 110 | expect(paused.status).toBe(200); | |
| 111 | expect(((await paused.json()) as { paused: string }).paused).toBe("paused by alice"); | |
| 112 | expect(getRunner(app.db, mac.runner.id)!.paused).toBe("paused by alice"); | |
| 113 | expect((await call(path(mac.runner.id, "pause"), alice, "POST")).status).toBe(422); | |
| 114 | expect((await call(path(local.runner.id, "pause"), alice, "POST")).status).toBe(422); | |
| 115 | expect(getRunner(app.db, local.runner.id)!.paused).toBe(""); | |
| 116 | // Not an admin's token: the same 404 a stranger gets. | |
| 117 | expect([403, 404]).toContain((await call(path(mac.runner.id, "pause"), bob, "POST")).status); | |
| 118 | expect((await call(path("nope", "pause"), alice, "POST")).status).toBe(404); | |
| 119 | expect((await call(path(mac.runner.id, "resume"), alice, "POST")).status).toBe(200); | |
| 120 | expect(getRunner(app.db, mac.runner.id)!.paused).toBe(""); | |
| 121 | const events = app.db.query<{ n: number }, []>("SELECT COUNT(*) AS n FROM event WHERE kind = 'runner.paused'").get()!.n; | |
| 122 | expect(events).toBe(1); | |
| 123 | }); | |
| 124 | }); |
test/arcade-host.test.ts +13
| @@ -98,6 +98,19 @@ describe("the Arcade host", () => { | ||
| 98 | 98 | expect(played.headers.get("content-security-policy")).toContain("frame-ancestors"); |
| 99 | 99 | }); |
| 100 | 100 | |
| 101 | test("the API lists the same games with the URL to play each (#18038)", async () => { | |
| 102 | const res = await fetch(`${servers.url}/api/v1/arcade/games`); | |
| 103 | expect(res.status).toBe(200); | |
| 104 | const got = (await res.json()) as { host: string; items: { name: string; builds: { file: string; play_url: string }[] }[] }; | |
| 105 | const host = `http://arcade.${DOMAIN}:${servers.port}`; | |
| 106 | expect(got.host).toBe(host); | |
| 107 | const games = (await (await arcade("/games.json")).json()) as { name: string; builds: { file: string }[] }[]; | |
| 108 | expect(got.items.map((g) => g.name)).toEqual(games.map((g) => g.name)); | |
| 109 | const build = got.items[0]!.builds[0]!; | |
| 110 | expect(build.file).toBe(games[0]!.builds[0]!.file); | |
| 111 | expect(build.play_url).toBe(`${host}/${build.file}`); | |
| 112 | }); | |
| 113 | ||
| 101 | 114 | test("the host answers only reads, and nothing outside the display", async () => { |
| 102 | 115 | expect((await arcade("/", { method: "POST" })).status).toBe(405); |
| 103 | 116 | expect((await arcade("/carts/alice/karts/" + "0".repeat(40) + "/index.html")).status).toBe(404); |
test/budgets/unfixtured/api-v1-repos-owner-name-app-env-log.json added +4
test/route-timing-coverage.test.ts +1
| @@ -33,6 +33,7 @@ const UNTIMED: Record<string, string> = { | ||
| 33 | 33 | "/api/v1/admin/plans": "an admin's plans with the measured median, two indexed reads; no page to phase", |
| 34 | 34 | "/api/v1/admin/infra/code": "each app's infra.json read from its repo's main branch (cached per tip) and diffed read-only; no page to phase", |
| 35 | 35 | "/api/v1/user/devices": "a person's own Apple devices, one indexed read; no page to phase", |
| 36 | "/api/v1/arcade/games": "the arcade games and their builds, read from the pinned game heads; no page to phase", | |
| 36 | 37 | "/metrics": "Prometheus text exposition, scraped by token; not a page read", |
| 37 | 38 | }; |
| 38 | 39 |
test/tui-runners.test.ts +11
| @@ -100,6 +100,17 @@ describe("runners in the terminal", () => { | ||
| 100 | 100 | expect(events("runner.removed")).toBe(0); |
| 101 | 101 | }); |
| 102 | 102 | |
| 103 | test("p pauses the runner under the cursor, a local one is refused, u resumes it (#18038)", async () => { | |
| 104 | const { text } = await drive(ada, ["p"]); | |
| 105 | expect(text).toContain("cannot be paused"); | |
| 106 | expect(events("runner.paused")).toBe(0); | |
| 107 | const held = await drive(ada, ["j", "p"]); | |
| 108 | expect(held.text).toContain("mac is paused"); | |
| 109 | expect(events("runner.paused")).toBe(1); | |
| 110 | const back = await drive(ada, ["j", "u"]); | |
| 111 | expect(back.text).toContain("Runner mac may claim again."); | |
| 112 | }); | |
| 113 | ||
| 103 | 114 | test("the owner is told when lent runners wait for a busy machine", async () => { |
| 104 | 115 | setLoadSource(() => 0.9); |
| 105 | 116 | try { |
new above
offline