Public: anyone can read this; the crew can change it.

server.ts imports page, studio, render and API modules on the first request to their prefix #17313

opened this

Merged 33h 25m ago, live in production

mason/forge:mason/17020-server-ts-imports-page-studio-render-and → main 0 commits fork

  • Merged. mason/17020-server-ts-imports-page-studio-render-and was merged into main as 9f6e1c4.

Review

Sign in to review this change.
24 files changed +1744 −184
AGENTS.md +2 −2
@@ -47,7 +47,7 @@ The check queue hands work to a runner through `src/checks/runner.ts` (#13652, R
4747
4848 `src/core/transfer.ts`: the old owner/name pairs a transfer left behind (`repo_redirect`), held per database after the first request reads them and dropped by `transferRepo`, so a request under a path nothing moved from costs no statement (#569).
4949
50 A route family whose module loads on its first request (#16852) is a list in `src/http/lazy_lists.ts` and one `lazyRoutes` line in `src/http/server.ts` (`/settings…`, `/forges…` and MCP so far); `test/lazy-first-use.test.ts` holds each list to its module's own routes and the boot's imports clear of the module. The search warm starts on the first search anyone makes (`warmOnFirstSearch`, `src/search/warm.ts`), not at boot. The 15 s machine sampler and the memory sampler stay at boot: their history is what a page reads later, and a sampler started on first use would have none.
50 A route family whose module loads on its first request (#16852, #17020) is a list in `src/http/lazy_lists.ts` and one `lazyRoutes` line in `src/http/server.ts`: every module under `src/http/routes/`, the JSON API and its siblings, `/settings…`, `/forges…` and MCP; `test/lazy-first-use.test.ts` and `test/boot-lazy.test.ts` hold each list to its module's own routes, the boot's imports clear of the module, and the boot's static module count under a ceiling. So the boot (`src/main.ts`, `server.ts` and what they import) does not import a page, studio or render module, nor the OpenAPI contract: a function the boot needs from one lives in a module of its own (`web/origin_icon.ts`, `spawn/preview_who.ts`) or is read with `require` or `import()` where it is first used. The search warm starts on the first search anyone makes (`warmOnFirstSearch`, `src/search/warm.ts`), not at boot. The 15 s machine sampler and the memory sampler stay at boot: their history is what a page reads later, and a sampler started on first use would have none.
5151
5252 `src/http/mcp/load.ts`: `loading`, the one import of the MCP server and its tool index (#12521), started by the first request that needs the tools; when it settles it hands the list to /llms.txt (`setMcpTools`) and the cards (`setCardTools`), so a reader of those lists awaits `loadMcp()` first. A failed import is dropped and tried again; gone on restart.
5353
@@ -108,4 +108,4 @@ A pull that adds a page (`src/web/pages/*.ts`), an MCP tool (`src/http/mcp/tools
108108 `src/crew/runner.ts`'s `work()` is the order of one agent run, and each step of it is a module that takes its state as a plain object and returns plain data (#16789): `run_spend.ts` (`settleSpend`: the account, ceilings and budget, or the refusal), `run_prompt.ts` (`promptFor`, `reviewInputs`), `run_retry.ts` (`retryNetwork`, `outagePause`), `run_limits.ts` (`limitEnding`: a provider's refusal as a pause), `run_verdict.ts` (`verdictOf`, `settleReview`: a decline or a review's verdict), `run_prepare.ts` (`prepareAgent`: the environment, sandbox, devices, model and the metered `invoke` closure, with what the `finally` must free in a `Held`), `run_wrapup.ts` (`wrapUp`: the reserve turn), `run_settle.ts` (`settleRun`: a cancel, a refused token, a verdict, or the landing, as the outcome), with `meter.ts` holding the `Outcome` and `Meter` records they share. A step imports nothing of `runner.ts` but the `CrewOptions` type; `runner.ts` re-exports the names it was imported by. Tests: `test/run-steps.test.ts`.
109109 `src/spawn/routes.ts`: `tables`, per data directory, the router's table of forges moved to another machine (#16859), read once from `routes.json` and kept by `setRoute`, the only writer (a rename of the whole file); at most one entry per moved forge, gone on restart (the file is the state). `src/spawn/machines.ts`: `registered`, the machines declared by `FORGE_MACHINES` (or put by a test), made on first read, and each process machine's `running` process groups by forge name; at most one per forge, gone on restart. `src/spawn/move_machine.ts`: `busy`, the forges being moved now, so a second ask is refused; gone when the move ends. The terminal door is `g` on the Forges screen (`src/tui/screens/forges.ts`; `planMove`/`moveToMachine` give the page, the MCP `forges` tool and the terminal the same words).
110110
111 A new route of the studio's own router (`buildRouter`, `src/http/server.ts`) is added in the module of its concept under `src/http/routes/`, named for that one concept (`talk`, `accounts`, `repo_issues`, `git_http`…), never in `server.ts`, which only calls them; `buildRouter` is the one list, so a new module is imported and called there (a test fails for a route module nothing mounts, #17036). The router matches in insertion order, so a literal route goes above the `/:owner…` ones: literal-path modules are called first, `repo_*` the `/:owner/:name` ones, and the few modules whose place is not obvious say why in their header (`repo_display`, `repo_api`, `migrate`). Smart-HTTP access (`withGitAccess`, `asStranger`) is `src/http/git_access.ts`.
111 A new route of the studio's own router (`buildRouter`, `src/http/server.ts`) is added in the module of its concept under `src/http/routes/`, named for that one concept (`talk`, `accounts`, `repo_issues`, `git_http`…), never in `server.ts`, which only mounts them; `buildRouter` is the one list, so a new module is mounted there with its route list in `lazy_lists.ts` (a test fails for a route module nothing mounts, #17036). The router matches in insertion order, so a literal route goes above the `/:owner…` ones: literal-path modules are called first, `repo_*` the `/:owner/:name` ones, and the few modules whose place is not obvious say why in their header (`repo_display`, `repo_api`, `migrate`). Smart-HTTP access (`withGitAccess`, `asStranger`) is `src/http/git_access.ts`.
src/http/admin_gate.ts +11 −6
@@ -13,11 +13,10 @@
1313 */
1414
1515 import type { App } from "../app.ts";
16 import { ROUTES } from "../contract/openapi.ts";
16 import { contract, mayBeContractRoute } from "./contract_lazy.ts";
1717 import { adminOf, adminRefusal } from "../core/everyday.ts";
1818 import { lacks } from "../core/roles.ts";
1919 import { forbiddenPage } from "../web/chrome.ts";
20 import { everydayRefusedPage } from "../web/pages/everyday.ts";
2120 import type { Auth, Ctx } from "./context.ts";
2221 import { json } from "./respond.ts";
2322 import { isAdminRoute, markOf } from "./route_marks.ts";
@@ -44,8 +43,11 @@ const shape = (method: string, pattern: string): string =>
4443 * calls admin cannot answer an everyday account with a scope error or a 404.
4544 */
4645 let contractAdmin: ReadonlySet<string> | undefined;
47 const isContractAdmin = (method: string, pattern: string): boolean =>
48 (contractAdmin ??= new Set(ROUTES.filter((r) => r.role === "admin").map((r) => shape(r.method, r.path)))).has(shape(method, pattern));
46 const isContractAdmin = (method: string, pattern: string): boolean => {
47 if (!mayBeContractRoute(pattern)) return false;
48 const { ROUTES } = contract();
49 return (contractAdmin ??= new Set(ROUTES.filter((r) => r.role === "admin").map((r) => shape(r.method, r.path)))).has(shape(method, pattern));
50 };
4951
5052 /**
5153 * The refusal for a person who may not administer, or undefined to carry on.
@@ -53,7 +55,7 @@ const isContractAdmin = (method: string, pattern: string): boolean =>
5355 * handler that would run — `/packs/demo.git/info/refs` is the git route, not
5456 * a `/packs` page; without one the path's own mark decides.
5557 */
56 export function adminGate(app: App, request: Request, url: URL, auth: Auth, pattern?: string): Response | undefined {
58 export async function adminGate(app: App, request: Request, url: URL, auth: Auth, pattern?: string): Promise<Response | undefined> {
5759 if (auth.user === undefined) return undefined;
5860 const mark = pattern === undefined ? undefined : markOf(pattern);
5961 // The router answers HEAD with the GET handler, so HEAD is judged as GET.
@@ -65,5 +67,8 @@ export function adminGate(app: App, request: Request, url: URL, auth: Auth, patt
6567 if (contract || url.pathname.startsWith("/api/")) return json({ error: "not_admin", message: why }, 403);
6668 const ctx: Ctx = { app, request, url, params: {}, auth, theme: undefined };
6769 const admin = adminOf(app.db, auth.user);
68 return admin?.isAdmin === true ? everydayRefusedPage(ctx, admin) : forbiddenPage(ctx, why);
70 if (admin?.isAdmin !== true) return forbiddenPage(ctx, why);
71 // The page is read when an everyday account first meets the gate, not by the boot (#17020).
72 const { everydayRefusedPage } = await import("../web/pages/everyday.ts");
73 return everydayRefusedPage(ctx, admin);
6974 }
src/http/contract_lazy.ts added +32
@@ -0,0 +1,32 @@
1 /**
2 * The contract (src/contract/openapi.ts) is some five hundred modules a forge answering no API
3 * request never needs, so the boot does not import it. `loadContract()` imports it on the first
4 * request that could want it; `contract()` then hands it to the synchronous guards. Never
5 * require(): a graph with a top-level await refuses that at runtime.
6 */
7
8 type Contract = typeof import("../contract/openapi.ts");
9
10 let loaded: Contract | undefined;
11
12 /** Import the contract (once); await it before any guard that reads `contract()`. */
13 export async function loadContract(): Promise<Contract> {
14 return (loaded ??= await import("../contract/openapi.ts"));
15 }
16
17 /** The contract, already loaded by `loadContract()`. */
18 export function contract(): Contract {
19 if (loaded === undefined) throw new Error("the contract is read before loadContract() was awaited");
20 return loaded;
21 }
22
23 /**
24 * The contract's admin routes outside `/api/` (`test/boot-lazy.test.ts` holds this list to the
25 * contract's), so a page request never loads it.
26 */
27 export const CONTRACT_ADMIN_OUTSIDE_API: readonly string[] = ["/metrics"];
28
29 /** True when a router pattern could be a route of the contract: under `/api/`, or `/metrics`. */
30 export function mayBeContractRoute(pattern: string): boolean {
31 return pattern.startsWith("/api/") || CONTRACT_ADMIN_OUTSIDE_API.includes(pattern);
32 }
src/http/cursor_lists.ts +31 −16
@@ -1,6 +1,6 @@
11 /** The one guard for `?page=` and `?offset=`: a list the contract says pages by `cursor` refuses them, so no handler can forget (#8386). */
22
3 import { pagesByCursor, ROUTES } from "../contract/openapi.ts";
3 import { contract } from "./contract_lazy.ts";
44 import { apiError } from "./respond.ts";
55
66 export const PAGE_PARAM_SAYS = "This list pages by cursor: pass next_cursor as ?cursor=.";
@@ -8,9 +8,32 @@ export const PAGE_PARAM_SAYS = "This list pages by cursor: pass next_cursor as ?
88 /** The router pattern of a contract path: `{owner}` is `:owner`. */
99 const patternOf = (path: string): string => path.replace(/\{(\w+)\}/g, ":$1");
1010
11 const CURSOR_LISTS: ReadonlySet<string> = new Set(
12 ROUTES.filter(pagesByCursor).map((r) => patternOf(r.path)),
13 );
11 /**
12 * What the contract says about each cursor list, read on the first call: the contract is some five
13 * hundred modules a forge answering no API request never needs, so the boot does not import it
14 * (`test/boot-lazy.test.ts`).
15 */
16 interface Lists {
17 readonly cursor: ReadonlySet<string>;
18 readonly declared: ReadonlyMap<string, readonly string[]>;
19 }
20
21 let lists: Lists | undefined;
22 function listsOfContract(): Lists {
23 if (lists !== undefined) return lists;
24 const { pagesByCursor, ROUTES } = contract();
25 const cursorRoutes = ROUTES.filter(pagesByCursor);
26 return (lists = {
27 cursor: new Set(cursorRoutes.map((r) => patternOf(r.path))),
28 // The keys each list declares for its items: `itemKeys`, or every field of its `replyShapes`.
29 declared: new Map(
30 cursorRoutes.flatMap((r) => {
31 const keys = r.itemKeys ?? (r.replyShapes === undefined ? undefined : Object.values(r.replyShapes).flatMap((s) => Object.keys(s.fields)));
32 return keys === undefined ? [] : [[patternOf(r.path), [...new Set(keys)].sort()] as const];
33 }),
34 ),
35 });
36 }
1437
1538 /** True when the caller paged the way most APIs do (`?page=` or `?offset=`). */
1639 export function pagedByNumber(q: URLSearchParams): boolean {
@@ -19,20 +42,12 @@ export function pagedByNumber(q: URLSearchParams): boolean {
1942
2043 /** A 400 when this route pages by cursor and the query pages by number; undefined otherwise. */
2144 export function pageParamRefused(pattern: string, q: URLSearchParams): Response | undefined {
22 return CURSOR_LISTS.has(pattern) && pagedByNumber(q) ? apiError("invalid_query", 400, PAGE_PARAM_SAYS) : undefined;
45 return listsOfContract().cursor.has(pattern) && pagedByNumber(q) ? apiError("invalid_query", 400, PAGE_PARAM_SAYS) : undefined;
2346 }
2447
2548 /** Lists whose own handler already reads `fields=brief`. */
2649 const OWN_BRIEF: ReadonlySet<string> = new Set(["/api/v1/repos/:owner/:name/issues"]);
2750
28 /** The keys each list declares for its items: `itemKeys`, or every field of its `replyShapes`. */
29 const DECLARED: ReadonlyMap<string, readonly string[]> = new Map(
30 ROUTES.filter(pagesByCursor).flatMap((r) => {
31 const keys = r.itemKeys ?? (r.replyShapes === undefined ? undefined : Object.values(r.replyShapes).flatMap((s) => Object.keys(s.fields)));
32 return keys === undefined ? [] : [[patternOf(r.path), [...new Set(keys)].sort()] as const];
33 }),
34 );
35
3651 /** The columns asked for, and the keys the list declares (none declared: any well-formed name). */
3752 export interface Cut {
3853 readonly names: string[];
@@ -48,7 +63,7 @@ export interface Cut {
4863 * list is not asked to be cut.
4964 */
5065 export function takeFields(pattern: string, url: URL): Cut | Response | undefined {
51 if (!CURSOR_LISTS.has(pattern)) return undefined;
66 if (!listsOfContract().cursor.has(pattern)) return undefined;
5267 const raw = url.searchParams.get("fields");
5368 if (raw === null) return undefined;
5469 if (raw === "brief" && OWN_BRIEF.has(pattern)) return undefined;
@@ -56,7 +71,7 @@ export function takeFields(pattern: string, url: URL): Cut | Response | undefine
5671 const names = raw.split(",").map((n) => n.trim());
5772 if (names.length > 50 || names.some((n) => !/^[A-Za-z0-9_]{1,64}$/.test(n)))
5873 return apiError("invalid_fields", 422, "fields is a comma-separated list of item keys, e.g. fields=number,title", "name keys like number,title; at most 50");
59 const accepted = DECLARED.get(pattern);
74 const accepted = listsOfContract().declared.get(pattern);
6075 const unknown = accepted === undefined ? [] : names.filter((f) => !accepted.includes(f));
6176 if (accepted !== undefined && unknown.length > 0)
6277 return apiError("invalid_fields", 422, `unknown field ${unknown.join(", ")}; accepted: ${accepted.join(", ")}`, `ask for some of: ${accepted.join(", ")}`);
@@ -88,7 +103,7 @@ export async function withFields(cut: Cut, response: Response): Promise<Response
88103 * header; the caller's other query values are kept and only `cursor` is replaced.
89104 */
90105 export async function withLinkNext(pattern: string, base: URL, response: Response): Promise<Response> {
91 if (!CURSOR_LISTS.has(pattern) || response.status !== 200) return response;
106 if (!listsOfContract().cursor.has(pattern) || response.status !== 200) return response;
92107 if (!(response.headers.get("content-type") ?? "").includes("json")) return response;
93108 let next: unknown;
94109 try {
src/http/lazy_lists.ts +1401
@@ -259,3 +259,1404 @@ export const FORGES_ROUTES = [
259259 ["POST", "/forges/new"],
260260 ["POST", "/forges/start"],
261261 ] as const;
262
263 /** `accountsRoutes` (`routes/accounts.ts`). */
264 export const ACCOUNTS_ROUTES = [
265 ["GET", "/claim"],
266 ["POST", "/claim"],
267 ["POST", "/claim/options"],
268 ["POST", "/claim/renew"],
269 ["GET", "/welcome"],
270 ["POST", "/welcome"],
271 ["POST", "/welcome/options"],
272 ["GET", "/first-admin"],
273 ["POST", "/first-admin"],
274 ["POST", "/first-admin/options"],
275 ["GET", "/signin"],
276 ["POST", "/signin"],
277 ["GET", "/login"],
278 ["GET", "/sign-in"],
279 ["GET", "/signin/parent"],
280 ["GET", "/signin/parent/callback"],
281 ["GET", "/signup"],
282 ["GET", "/signin/access/:token"],
283 ["POST", "/signin/access/:token"],
284 ["GET", "/claim/start/:token"],
285 ["POST", "/claim/start/:token"],
286 ["POST", "/claim/start/:token/account"],
287 ["GET", "/signup/requested"],
288 ["GET", "/join/:token"],
289 ["POST", "/join/:token"],
290 ["GET", "/verify"],
291 ["POST", "/signup"],
292 ["POST", "/logout"],
293 ["POST", "/theme"],
294 ["GET", "/-/confirm"],
295 ["POST", "/signin/passkey/options"],
296 ["POST", "/signin/passkey"],
297 ["GET", "/recover"],
298 ["POST", "/recover"],
299 ["POST", "/recover/options"],
300 ["POST", "/recover/passkey"],
301 ["POST", "/signup/passkey/options"],
302 ["POST", "/signup/passkey"],
303 ] as const;
304
305 /** `adminRoutes` (`routes/admin.ts`). */
306 export const ADMIN_ROUTES = [
307 ["GET", "/audit"],
308 ["GET", "/audit.csv"],
309 ["POST", "/audit/:owner/:name/probe"],
310 ["GET", "/system"],
311 ["GET", "/system/stream"],
312 ["POST", "/system/heap-census"],
313 ["GET", "/system/bottleneck"],
314 ["GET", "/data"],
315 ["GET", "/admin/data"],
316 ["GET", "/admin/limits"],
317 ["GET", "/admin/abstractions"],
318 ["GET", "/admin/flows"],
319 ["POST", "/admin/limits"],
320 ["POST", "/admin/quotas"],
321 ["POST", "/admin/plans"],
322 ["POST", "/admin/signup"],
323 ["POST", "/admin/agent-start"],
324 ["POST", "/admin/billing-links"],
325 ["POST", "/admin/invites"],
326 ["POST", "/admin/invites/:id/revoke"],
327 ] as const;
328
329 /** `asksRoutes` (`routes/asks.ts`). */
330 export const ASKS_ROUTES = [
331 ["GET", "/asks"],
332 ["POST", "/asks/bulk"],
333 ["POST", "/asks/bulk/:id/undo"],
334 ["POST", "/asks/listen"],
335 ["POST", "/asks/mute"],
336 ["POST", "/asks/filter"],
337 ["POST", "/asks/proposal/:id/approve"],
338 ["POST", "/asks/proposal/:id/redirect"],
339 ["POST", "/asks/proposal/:id/later"],
340 ["POST", "/asks/proposal/:id/again"],
341 ["POST", "/asks/decide"],
342 ["POST", "/asks/admin"],
343 ["POST", "/asks/admin/later"],
344 ["POST", "/asks/give-back"],
345 ["POST", "/asks/decide/:id/undo"],
346 ["GET", "/asked"],
347 ["GET", "/notes"],
348 ["POST", "/notes"],
349 ["POST", "/notes/:id/overrule"],
350 ["GET", "/review"],
351 ["POST", "/review/act"],
352 ["GET", "/big"],
353 ] as const;
354
355 /** `boardsRoutes` (`routes/boards.ts`). */
356 export const BOARDS_ROUTES = [
357 ["GET", "/boards"],
358 ["GET", "/boards/data"],
359 ["POST", "/boards/data"],
360 ["POST", "/boards/new"],
361 ["POST", "/boards/holds"],
362 ["POST", "/boards/pin"],
363 ["POST", "/boards/pin-panel"],
364 ["POST", "/boards/unpin-panel"],
365 ["POST", "/boards/move-pin"],
366 ["GET", "/boards/stream"],
367 ["GET", "/boards/:slug"],
368 ["GET", "/boards/:slug/stream"],
369 ["POST", "/boards/:slug/:op"],
370 ] as const;
371
372 /** `createRoutes` (`routes/create.ts`). */
373 export const CREATE_ROUTES = [
374 ["GET", "/new"],
375 ["GET", "/bring"],
376 ["POST", "/bring"],
377 ["POST", "/bring/connect"],
378 ["GET", "/bring/:id/:job"],
379 ["POST", "/bring/:id/:job/run"],
380 ["POST", "/bring/:id/:job/env"],
381 ["GET", "/new/issue"],
382 ["POST", "/new"],
383 ["GET", "/organizations/new"],
384 ["POST", "/organizations/new"],
385 ["GET", "/apps"],
386 ["GET", "/apps/new"],
387 ["POST", "/apps/new"],
388 ["GET", "/apps/open"],
389 ] as const;
390
391 /** `designRoutes` (`routes/design.ts`). */
392 export const DESIGN_ROUTES = [
393 ["GET", "/design"],
394 ["GET", "/design/components"],
395 ["POST", "/design/publish"],
396 ["POST", "/design/revert"],
397 ["GET", "/design/theme.css"],
398 ["GET", "/design/theme/forge/live"],
399 ["GET", "/design/gallery"],
400 ["GET", "/design/registry"],
401 ] as const;
402
403 /** `discoveryRoutes` (`routes/discovery.ts`). */
404 export const DISCOVERY_ROUTES = [
405 ["GET", "/edge/config/:file"],
406 ["GET", "/assets/:name.css"],
407 ["GET", "/.well-known/security.txt"],
408 ["GET", "/.well-known/mcp"],
409 ["GET", "/.well-known/mcp.json"],
410 ["GET", "/.well-known/mcp-server-card.json"],
411 ["GET", "/.well-known/mcp/server-card.json"],
412 ["GET", "/.well-known/agent-card.json"],
413 ["GET", "/.well-known/api-catalog"],
414 ["GET", "/.well-known/forge"],
415 ["GET", "/llms.txt"],
416 ["GET", "/llms-full.txt"],
417 ["GET", "/agents"],
418 ["GET", "/.well-known/change-password"],
419 ["GET", "/robots.txt"],
420 ["GET", "/r/:name.json"],
421 ["GET", "/toolbar-lab"],
422 ["GET", "/toolbar-lab.js"],
423 ["GET", "/edition"],
424 ["GET", "/oembed"],
425 ["GET", "/releases.json"],
426 ["GET", "/sitemap.xml"],
427 ["GET", "/manifest.webmanifest"],
428 ["GET", "/opensearch.xml"],
429 ["GET", "/icons/:spec.png"],
430 ["GET", "/favicon.ico"],
431 ["GET", "/apple-touch-icon.png"],
432 ["GET", "/apple-touch-icon-precomposed.png"],
433 ["GET", "/assets/:name.js"],
434 ["GET", "/assets/:name.svg"],
435 ["GET", "/assets/:name.wasm"],
436 ["GET", "/assets/:name.json"],
437 ["GET", "/sw.js"],
438 ["GET", "/offline"],
439 ] as const;
440
441 /** `docsRoutes` (`routes/docs.ts`). */
442 export const DOCS_ROUTES = [
443 ["GET", "/dataset"],
444 ["GET", "/privacy"],
445 ["GET", "/terms"],
446 ["GET", "/templates/:name"],
447 ["GET", "/templates/:owner/:name"],
448 ["GET", "/security"],
449 ["GET", "/status"],
450 ["GET", "/status/:token"],
451 ["GET", "/docs"],
452 ["GET", "/docs/:file"],
453 ["GET", "/docs/features/:file"],
454 ["GET", "/changelog"],
455 ["GET", "/changelog.atom"],
456 ] as const;
457
458 /** `exploreRoutes` (`routes/explore.ts`). */
459 export const EXPLORE_ROUTES = [
460 ["GET", "/explore"],
461 ["GET", "/explore/series"],
462 ["POST", "/explore/series/save"],
463 ["POST", "/explore/series/remove"],
464 ["GET", "/explore.atom"],
465 ["GET", "/explore.json"],
466 ["GET", "/search"],
467 ["GET", "/repos"],
468 ["GET", "/displays"],
469 ["GET", "/now/:stage"],
470 ["GET", "/map"],
471 ["GET", "/offers/:id"],
472 ["GET", "/contribute"],
473 ] as const;
474
475 /** `gitHttpRoutes` (`routes/git_http.ts`). */
476 export const GIT_HTTP_ROUTES = [
477 ["GET", "/:owner/:name.git/info/refs"],
478 ["POST", "/:owner/:name.git/git-upload-pack"],
479 ["POST", "/:owner/:name.git/git-receive-pack"],
480 ] as const;
481
482 /** `homeRoutes` (`routes/home.ts`). */
483 export const HOME_ROUTES = [
484 ["GET", "/"],
485 ["GET", "/home"],
486 ["POST", "/home/act"],
487 ["POST", "/desk"],
488 ["POST", "/desk/clear"],
489 ["GET", "/front"],
490 ["POST", "/front"],
491 ["POST", "/home/archive"],
492 ["GET", "/home/archived/:op"],
493 ["POST", "/home/archived/:op/undo"],
494 ["GET", "/board"],
495 ["GET", "/cockpit"],
496 ["GET", "/board/returns"],
497 ["GET", "/go/:code"],
498 ] as const;
499
500 /** `intakeRoutes` (`routes/intake.ts`). */
501 export const INTAKE_ROUTES = [
502 ["POST", "/_measure"],
503 ["POST", "/_script-error"],
504 ["POST", "/_funnel"],
505 ["POST", "/csp-report"],
506 ["POST", "/hooks/stripe"],
507 ] as const;
508
509 /** `liveRoutes` (`routes/live.ts`). */
510 export const LIVE_ROUTES = [
511 ["GET", "/live/apps"],
512 ["GET", "/live/talk-work"],
513 ["GET", "/live/talk-plan"],
514 ["GET", "/live/talk-crew"],
515 ["GET", "/live/on-you"],
516 ["GET", "/live/desk"],
517 ["GET", "/live/client-apps"],
518 ["GET", "/live/feed"],
519 ["GET", "/live/milestones"],
520 ["GET", "/live/lane"],
521 ["GET", "/live/strip"],
522 ["GET", "/live/forges"],
523 ["GET", "/live/table"],
524 ["GET", "/live/figures"],
525 ["GET", "/feed"],
526 ["GET", "/feed.json"],
527 ["GET", "/feed/likes"],
528 ["GET", "/live/home/waiting"],
529 ["GET", "/live/home/panels"],
530 ["GET", "/live/home/feed"],
531 ["POST", "/feed/like"],
532 ["POST", "/feed/back"],
533 ] as const;
534
535 /** `migrateRoutes` (`routes/migrate.ts`). */
536 export const MIGRATE_ROUTES = [
537 ["GET", "/migrate"],
538 ["POST", "/migrate"],
539 ["GET", "/migrate/inventory"],
540 ["GET", "/migrate/jobs/:job"],
541 ] as const;
542
543 /** `ogCardsRoutes` (`routes/og_cards.ts`). */
544 export const OG_CARDS_ROUTES = [
545 ["GET", "/og/repo/:ref.svg"],
546 ["GET", "/og/app/:ref.svg"],
547 ["GET", "/og/issue/:ref.svg"],
548 ["GET", "/og/pull/:ref.svg"],
549 ["GET", "/og/run/:ref.svg"],
550 ["GET", "/og/map/:ref.svg"],
551 ["GET", "/og/template/:ref.svg"],
552 ["GET", "/og/template/:ref.png"],
553 ["GET", "/og/audit.svg"],
554 ["GET", "/og/repo/:ref.png"],
555 ["GET", "/og/app/:ref.png"],
556 ["GET", "/og/issue/:ref.png"],
557 ["GET", "/og/pull/:ref.png"],
558 ["GET", "/og/run/:ref.png"],
559 ["GET", "/og/map/:ref.png"],
560 ["GET", "/og/audit.png"],
561 ["GET", "/og/site.svg"],
562 ["GET", "/og/site.png"],
563 ] as const;
564
565 /** `operationsRoutes` (`routes/operations.ts`). */
566 export const OPERATIONS_ROUTES = [
567 ["POST", "/flow/keeper/answer"],
568 ["GET", "/flow"],
569 ["POST", "/flow/valve"],
570 ["POST", "/flow/backup/retry"],
571 ["POST", "/flow/suggestion"],
572 ["GET", "/pipeline"],
573 ["GET", "/broker/origins/start"],
574 ...SETTINGS_ROUTES,
575 ["GET", "/cloud/connect"],
576 ["GET", "/cloud/connect/:provider"],
577 ["POST", "/cloud/connect/:provider"],
578 ["POST", "/cloud/connect/:provider/build"],
579 ["GET", "/plugins/claude-code/marketplace.json"],
580 ["GET", "/plugins/opencode/forge.ts"],
581 ["GET", "/pinned"],
582 ["POST", "/pinned/domain"],
583 ["POST", "/pinned/paid"],
584 ["POST", "/pinned/experiment/:act"],
585 ["POST", "/pinned/:name/:act"],
586 ["GET", "/deploy-to"],
587 ["POST", "/deploy-to"],
588 ["GET", "/infra"],
589 ["GET", "/infra/live"],
590 ["POST", "/infra/plan"],
591 ["POST", "/infra/apply"],
592 ["POST", "/infra/record"],
593 ["POST", "/infra/rebuild"],
594 ["GET", "/infra/:name/ending"],
595 ["POST", "/infra/snapshot/:id/:act"],
596 ["POST", "/infra/:name/:act"],
597 ["GET", "/games"],
598 ["GET", "/games/jar/:id/:name"],
599 ["GET", "/games/:box"],
600 ["POST", "/games/:box/grant"],
601 ["GET", "/games/:box/:service"],
602 ["GET", "/games/:box/:service/stream"],
603 ["POST", "/games/:box/:service/command"],
604 ["POST", "/games/:box/:service/power"],
605 ["POST", "/games/:box/:service/env"],
606 ["POST", "/games/:box/:service/plugin"],
607 ["POST", "/games/:box/:service/jar"],
608 ["GET", "/resilience"],
609 ["GET", "/maintenance"],
610 ["GET", "/maintenance.json"],
611 ["POST", "/maintenance/prepare"],
612 ["POST", "/maintenance/resume"],
613 ["POST", "/maintenance/budget"],
614 ["POST", "/maintenance/duties/:name"],
615 ["POST", "/maintenance/dismiss"],
616 ["POST", "/maintenance/quiet"],
617 ["POST", "/maintenance/unquiet"],
618 ["POST", "/maintenance/findings/reopen"],
619 ["POST", "/maintenance/stale/:id/:what"],
620 ["POST", "/maintenance/branches/delete"],
621 ["POST", "/maintenance/previews/remove"],
622 ["GET", "/resilience/nightly/:job"],
623 ["GET", "/fleet"],
624 ["POST", "/fleet"],
625 ["GET", "/fleet/ops/:id"],
626 ["POST", "/fleet/ops/:id/undo"],
627 ["GET", "/forks/flows"],
628 ["GET", "/fleet/graph"],
629 ["GET", "/fleet/graph/live"],
630 ["GET", "/fleet/graph.csv"],
631 ["GET", "/__forge/domains/ask"],
632 ["GET", "/runs/:id"],
633 ] as const;
634
635 /** `originsRoutes` (`routes/origins.ts`). */
636 export const ORIGINS_ROUTES = [
637 ["GET", "/origins/:id/r/:owner/:name"],
638 ["GET", "/origins/:id/r/:owner/:name/tree/:ref"],
639 ["GET", "/origins/:id/r/:owner/:name/tree/:ref/*path"],
640 ["GET", "/origins/:id/r/:owner/:name/blob/:ref/*path"],
641 ["GET", "/origins/:id/r/:owner/:name/raw/:ref/*path"],
642 ["GET", "/origins/:id/r/:owner/:name/paths/:ref"],
643 ["GET", "/origins/:id/r/:owner/:name/branches"],
644 ["GET", "/origins/:id/r/:owner/:name/commits"],
645 ["GET", "/origins/:id/r/:owner/:name/commit/:oid"],
646 ["GET", "/origins/:id/r/:owner/:name/issues"],
647 ["GET", "/origins/:id/r/:owner/:name/issues/:number"],
648 ["GET", "/origins/:id/r/:owner/:name/pulls"],
649 ["GET", "/origins/:id/r/:owner/:name/pulls/:number"],
650 ["GET", "/origins/:id/r/:owner/:name/edit/:ref/*path"],
651 ["GET", "/origins/:id/r/:owner/:name/new/:ref"],
652 ["GET", "/origins/:id/r/:owner/:name/new/:ref/*path"],
653 ["POST", "/origins/:id/r/:owner/:name/mirror"],
654 ["POST", "/origins/:id/r/:owner/:name/fork"],
655 ["POST", "/origins/:id/r/:owner/:name/contribute"],
656 ] as const;
657
658 /** `packsRoutes` (`routes/packs.ts`). */
659 export const PACKS_ROUTES = [
660 ["GET", "/packs"],
661 ["POST", "/packs/mirror"],
662 ["POST", "/packs/new"],
663 ["POST", "/packs/:name/edit"],
664 ["POST", "/packs/:name/repos"],
665 ["GET", "/packs/:name"],
666 ] as const;
667
668 /** `protocolsRoutes` (`routes/protocols.ts`). */
669 export const PROTOCOLS_ROUTES = [
670 ["POST", "/mcp"],
671 ["GET", "/mcp"],
672 ["DELETE", "/mcp"],
673 ["GET", "/contract/openapi.json"],
674 ["GET", "/openapi.json"],
675 ["GET", "/oauth/authorize"],
676 ["POST", "/oauth/authorize"],
677 ["POST", "/oauth/token"],
678 ["POST", "/oauth/revoke"],
679 ["GET", "/oauth/jwks"],
680 ["GET", "/oauth/userinfo"],
681 ["POST", "/oauth/userinfo"],
682 ["GET", "/.well-known/openid-configuration"],
683 ["GET", "/.well-known/oauth-protected-resource"],
684 ["GET", "/.well-known/oauth-authorization-server"],
685 ["POST", "/oauth/register"],
686 ] as const;
687
688 /** `releasesRoutes` (`routes/releases.ts`). */
689 export const RELEASES_ROUTES = [
690 ["GET", "/releases"],
691 ["POST", "/releases/:sha/rollback"],
692 ["POST", "/releases/hold"],
693 ["POST", "/releases/now"],
694 ["POST", "/releases/prove"],
695 ["POST", "/releases/hold/:id/lift"],
696 ] as const;
697
698 /** `repoApiRoutes` (`routes/repo_api.ts`). */
699 export const REPO_API_ROUTES = [
700 ["GET", "/:owner/:name/api"],
701 ] as const;
702
703 /** `repoAppRoutes` (`routes/repo_app.ts`). */
704 export const REPO_APP_ROUTES = [
705 ["GET", "/:owner/:name/app"],
706 ["GET", "/:owner/:name/app/state"],
707 ["GET", "/:owner/:name/app/now"],
708 ["GET", "/:owner/:name/app/milestones"],
709 ["GET", "/:owner/:name/app/answers"],
710 ["GET", "/:owner/:name/app/:env/open"],
711 ["POST", "/:owner/:name/app/notes"],
712 ["POST", "/:owner/:name/app/errors/resolve"],
713 ["POST", "/:owner/:name/app/pull"],
714 ["GET", "/:owner/:name/app/jobs"],
715 ["POST", "/:owner/:name/app/jobs/:id/:action"],
716 ["POST", "/:owner/:name/app/schedules/:schedule/:action"],
717 ["GET", "/:owner/:name/data-move"],
718 ["POST", "/:owner/:name/data-move"],
719 ["GET", "/:owner/:name/cut-over"],
720 ["POST", "/:owner/:name/cut-over"],
721 ["GET", "/:owner/:name/drop"],
722 ["POST", "/:owner/:name/drop"],
723 ["POST", "/:owner/:name/drop/remove"],
724 ["POST", "/:owner/:name/app/cache/clear"],
725 ["POST", "/:owner/:name/app/:env/redeploy"],
726 ["POST", "/:owner/:name/app/:env/stop"],
727 ["GET", "/:owner/:name/events"],
728 ["GET", "/:owner/:name/data"],
729 ["GET", "/:owner/:name/data/:file"],
730 ["GET", "/:owner/:name/runs"],
731 ["GET", "/:owner/:name/runs/:id"],
732 ["POST", "/:owner/:name/runs/:id/cancel"],
733 ["POST", "/:owner/:name/runs/:id/requeue"],
734 ["POST", "/:owner/:name/runs/:id/own-token"],
735 ["POST", "/:owner/:name/runs/:id/steer"],
736 ["GET", "/:owner/:name/looks/:env/:commit/:kind.png"],
737 ["GET", "/events"],
738 ["GET", "/:owner/:name/stream"],
739 ["POST", "/:owner/-/subscriptions"],
740 ] as const;
741
742 /** `repoBrowseRoutes` (`routes/repo_browse.ts`). */
743 export const REPO_BROWSE_ROUTES = [
744 ["GET", "/:owner.atom"],
745 ["GET", "/:owner/:name/ships.atom"],
746 ["GET", "/:owner/:name/forks.atom"],
747 ["GET", "/:owner"],
748 ["GET", "/:owner/:name"],
749 ["GET", "/:owner/:name/files"],
750 ["GET", "/:owner/:name/tree/:ref"],
751 ["GET", "/:owner/:name/tree/:ref/*path"],
752 ["GET", "/:owner/:name/blob/:ref/*path"],
753 ["GET", "/:owner/:name/raw/:ref/*path"],
754 ["GET", "/:owner/:name/archive/:file"],
755 ["GET", "/:owner/:name/AGENTS.md"],
756 ["GET", "/:owner/:name/media/:ref/*path"],
757 ["GET", "/:owner/:name/paths/:ref"],
758 ["GET", "/:owner/:name/forks"],
759 ["GET", "/:owner/:name/activity.atom"],
760 ["GET", "/:owner/:name/branches"],
761 ["POST", "/:owner/:name/branches"],
762 ["POST", "/:owner/:name/commit/:oid/offer"],
763 ["POST", "/:owner/:name/branches/:branch/delete"],
764 ["GET", "/:owner/:name/edit/:ref/*path"],
765 ["POST", "/:owner/:name/edit"],
766 ["GET", "/:owner/:name/new/:ref"],
767 ["GET", "/:owner/:name/new/:ref/*path"],
768 ["GET", "/:owner/:name/delete/:ref/*path"],
769 ["POST", "/:owner/:name/delete"],
770 ["POST", "/:owner/:name/contribute"],
771 ["GET", "/:owner/:name/commits"],
772 ["GET", "/:owner/:name/commit/:oid"],
773 ["GET", "/:owner/:name/compare/:range"],
774 ["POST", "/:owner/:name/fork"],
775 ["GET", "/:owner/:name/releases"],
776 ] as const;
777
778 /** `repoBuildsRoutes` (`routes/repo_builds.ts`). */
779 export const REPO_BUILDS_ROUTES = [
780 ["GET", "/:owner/:name/stl/:ref/*path"],
781 ["GET", "/:owner/:name/large"],
782 ["GET", "/:owner/:name/large/:oid"],
783 ["GET", "/:owner/:name/builds"],
784 ["GET", "/:owner/:name/builds/new"],
785 ["GET", "/:owner/:name/builds/:label/shots"],
786 ["GET", "/:owner/:name/builds/:label/shots/:file"],
787 ["GET", "/:owner/:name/builds/:label/cart"],
788 ["GET", "/:owner/:name/builds/:label/cart.png"],
789 ["GET", "/:owner/:name/iterations"],
790 ["POST", "/:owner/:name/builds"],
791 ["POST", "/:owner/:name/builds/preview"],
792 ["GET", "/:owner/:name/variants"],
793 ["POST", "/:owner/:name/variants"],
794 ["POST", "/:owner/:name/variants/:label/values"],
795 ["POST", "/:owner/:name/variants/:label/retire"],
796 ["POST", "/:owner/:name/variants/:label/main"],
797 ["POST", "/:owner/:name/builds/:label/delete"],
798 ["POST", "/:owner/:name/builds/:label/note"],
799 ["GET", "/:owner/:name/waves.atom"],
800 ["GET", "/:owner/:name/waves"],
801 ["GET", "/:owner/:name/waves/:version"],
802 ["GET", "/:owner/:name/offers"],
803 ["POST", "/:owner/:name/offers/:number/withdraw"],
804 ["POST", "/:owner/:name/preview"],
805 ["GET", "/:owner/:name/config/:ref/*path"],
806 ["POST", "/:owner/:name/config"],
807 ["POST", "/:owner/:name/forge"],
808 ["GET", "/:owner/:name/make-it-yours"],
809 ["POST", "/:owner/:name/make-it-yours"],
810 ["GET", "/:owner/:name/make-it-yours/receipt"],
811 ["POST", "/:owner/:name/make-it-yours/undo"],
812 ["GET", "/:owner/:name/toolbar"],
813 ["POST", "/:owner/:name/toolbar/comment"],
814 ] as const;
815
816 /** `repoDisplayRoutes` (`routes/repo_display.ts`). */
817 export const REPO_DISPLAY_ROUTES = [
818 ["GET", "/:owner/:name/display"],
819 ["POST", "/:owner/:name/display"],
820 ] as const;
821
822 /** `repoIssuesRoutes` (`routes/repo_issues.ts`). */
823 export const REPO_ISSUES_ROUTES = [
824 ["GET", "/:owner/:name/issues"],
825 ["GET", "/:owner/:name/report"],
826 ["POST", "/:owner/:name/report"],
827 ["GET", "/:owner/:name/reports"],
828 ["POST", "/:owner/:name/reports/:id/accept"],
829 ["POST", "/:owner/:name/reports/:id/dismiss"],
830 ["GET", "/:owner/:name/issues/new"],
831 ["POST", "/:owner/:name/issues/new"],
832 ["GET", "/:owner/:name/issues/:number"],
833 ["GET", "/:owner/:name/issues/:number/thread"],
834 ["GET", "/:owner/:name/issues/:number/picture"],
835 ["POST", "/:owner/:name/issues/:number/comments"],
836 ["POST", "/:owner/:name/issues/:number/comments/:id/question"],
837 ["POST", "/:owner/:name/issues/:number/seal"],
838 ["POST", "/:owner/:name/issues/:number/private"],
839 ["POST", "/:owner/:name/issues/:number/state"],
840 ["POST", "/:owner/:name/issues/:number/edit"],
841 ["POST", "/:owner/:name/issues/:number/labels"],
842 ["POST", "/:owner/:name/issues/:number/flow"],
843 ["POST", "/:owner/:name/issues/:number/teams"],
844 ["POST", "/:owner/:name/issues/:number/assignee"],
845 ["POST", "/:owner/:name/issues/:number/dependencies"],
846 ["POST", "/:owner/:name/issues/:number/lift"],
847 ["POST", "/:owner/:name/issues/:number/first"],
848 ] as const;
849
850 /** `repoPlanningRoutes` (`routes/repo_planning.ts`). */
851 export const REPO_PLANNING_ROUTES = [
852 ["GET", "/:owner/:name/findings"],
853 ["POST", "/:owner/:name/findings/:id/accept"],
854 ["GET", "/:owner/:name/queue"],
855 ["POST", "/:owner/:name/queue/planner"],
856 ["POST", "/:owner/:name/queue/ceiling"],
857 ["POST", "/:owner/:name/queue/pulls-ceiling"],
858 ["POST", "/:owner/:name/queue/defer"],
859 ["GET", "/:owner/:name/chapters"],
860 ["POST", "/:owner/:name/chapters"],
861 ["GET", "/:owner/:name/chapters/:chapter"],
862 ["POST", "/:owner/:name/chapters/:chapter/:verb"],
863 ["GET", "/:owner/:name/bets"],
864 ["POST", "/:owner/:name/bets/propose"],
865 ["GET", "/:owner/:name/bets/:id"],
866 ["GET", "/:owner/:name/bets/:id/walk/:walk"],
867 ["POST", "/:owner/:name/bets/:id/:verb"],
868 ["GET", "/:owner/:name/milestones"],
869 ["GET", "/:owner/:name/milestones/:number"],
870 ["POST", "/:owner/:name/milestones/:number/watch"],
871 ["GET", "/:owner/:name/milestones/:number/limb"],
872 ["POST", "/:owner/:name/milestones/:number/limb"],
873 ["GET", "/:owner/:name/milestones/:number/limb/:op"],
874 ["POST", "/:owner/:name/milestones/:number/limb/:op/undo"],
875 ["GET", "/:owner/:name/standing-line"],
876 ["GET", "/:owner/:name/variants/:group"],
877 ["POST", "/:owner/:name/variants/:group/:number/like"],
878 ["POST", "/:owner/:name/variants/:group/:number/dislike"],
879 ] as const;
880
881 /** `repoPullsRoutes` (`routes/repo_pulls.ts`). */
882 export const REPO_PULLS_ROUTES = [
883 ["POST", "/:owner/:name/pulls/:number/checks"],
884 ["POST", "/:owner/:name/pulls/:number/ship"],
885 ["POST", "/:owner/:name/pulls/:number/update"],
886 ["POST", "/:owner/:name/pulls/:number/say"],
887 ["POST", "/:owner/:name/pulls/:number/take-back"],
888 ["POST", "/:owner/:name/pulls/:number/hold"],
889 ["POST", "/:owner/:name/pulls/:number/release"],
890 ["POST", "/:owner/:name/pulls/:number/ask-review"],
891 ["POST", "/:owner/:name/pulls/:number/review-retry"],
892 ["GET", "/:owner/:name/pulls"],
893 ["GET", "/:owner/:name/changes"],
894 ["GET", "/:owner/:name/changes/:number"],
895 ["GET", "/:owner/:name/pulls/new"],
896 ["POST", "/:owner/:name/pulls/new"],
897 ["GET", "/:owner/:name/pulls/:number/check.txt"],
898 ["GET", "/:owner/:name/pulls/:number.diff"],
899 ["GET", "/:owner/:name/pulls/:number"],
900 ["GET", "/:owner/:name/pulls/:number/files"],
901 ["GET", "/:owner/:name/pulls/:number/resolve"],
902 ["POST", "/:owner/:name/pulls/:number/resolve"],
903 ["POST", "/:owner/:name/pulls/:number/resolve/propose"],
904 ["GET", "/:owner/:name/pulls/:number/thread"],
905 ["GET", "/:owner/:name/pulls/:number/state"],
906 ["GET", "/:owner/:name/pulls/:number/checks-line"],
907 ["POST", "/:owner/:name/pulls/:number/comments"],
908 ["GET", "/:owner/:name/pulls/:number/review/:step"],
909 ["GET", "/:owner/:name/pulls/:number/review-answers"],
910 ["POST", "/:owner/:name/pulls/:number/review-answers"],
911 ["POST", "/:owner/:name/pulls/:number/review"],
912 ["POST", "/:owner/:name/pulls/:number/review-state"],
913 ["POST", "/:owner/:name/pulls/:number/approve-here"],
914 ["POST", "/:owner/:name/pulls/:number/approve-guest"],
915 ["POST", "/:owner/:name/pulls/:number/threads/:anchor/resolve"],
916 ["POST", "/:owner/:name/pulls/:number/threads/:anchor/unresolve"],
917 ["POST", "/:owner/:name/pulls/:number/merge"],
918 ["POST", "/:owner/:name/pulls/:number/slice"],
919 ["POST", "/:owner/:name/pulls/:number/land-past"],
920 ["POST", "/:owner/:name/pulls/:number/ready"],
921 ["POST", "/:owner/:name/pulls/:number/state"],
922 ["POST", "/:owner/:name/pulls/:number/edit"],
923 ["POST", "/:owner/:name/pulls/:number/labels"],
924 ["POST", "/:owner/:name/pulls/:number/assignee"],
925 ["POST", "/:owner/:name/pulls/:number/offer"],
926 ] as const;
927
928 /** `repoSettingsRoutes` (`routes/repo_settings.ts`). */
929 export const REPO_SETTINGS_ROUTES = [
930 ["POST", "/:owner/:name/following"],
931 ["GET", "/:owner/:name/following"],
932 ["POST", "/:owner/:name/following/sever"],
933 ["POST", "/:owner/:name/following/mode"],
934 ["POST", "/:owner/:name/following/mode/:mode"],
935 ["POST", "/:owner/:name/following/take"],
936 ["POST", "/:owner/:name/following/propose"],
937 ["POST", "/:owner/:name/following/check"],
938 ["POST", "/:owner/:name/sync"],
939 ["POST", "/:owner/:name/sync/take"],
940 ["POST", "/:owner/:name/pin"],
941 ["GET", "/:owner/:name/settings"],
942 ["POST", "/:owner/:name/settings"],
943 ["POST", "/:owner/:name/settings/wave"],
944 ["POST", "/:owner/:name/settings/archive"],
945 ["POST", "/:owner/:name/archive"],
946 ["POST", "/:owner/:name/restore"],
947 ["POST", "/:owner/:name/settings/rename"],
948 ["POST", "/:owner/:name/settings/transfer"],
949 ["POST", "/:owner/:name/settings/provenance"],
950 ["POST", "/:owner/:name/settings/mirror/stop"],
951 ["POST", "/:owner/:name/settings/read-grants"],
952 ["POST", "/:owner/:name/settings/read-grants/:kind/:id/delete"],
953 ["POST", "/:owner/:name/settings/proposal-tokens"],
954 ["POST", "/:owner/:name/settings/proposal-tokens/:id/delete"],
955 ["POST", "/:owner/:name/settings/contribute-tokens/open"],
956 ["POST", "/:owner/:name/settings/reports/open"],
957 ["POST", "/:owner/:name/settings/contribute-tokens/:id/delete"],
958 ["GET", "/:owner/:name/settings/app"],
959 ["GET", "/:owner/:name/settings/app/traffic"],
960 ["GET", "/:owner/:name/settings/app/statement"],
961 ["GET", "/:owner/:name/settings/app/statement.csv"],
962 ["GET", "/:owner/:name/settings/machines"],
963 ["GET", "/:owner/:name/machines/:machine/shell"],
964 ["POST", "/:owner/:name/settings/app"],
965 ["POST", "/:owner/:name/settings/app/disable"],
966 ["POST", "/:owner/:name/settings/app/forge-template"],
967 ["POST", "/:owner/:name/settings/app/members"],
968 ["POST", "/:owner/:name/settings/app/env"],
969 ["POST", "/:owner/:name/settings/app/flags"],
970 ["GET", "/:owner/:name/settings/app/flags/:flag"],
971 ["POST", "/:owner/:name/settings/app/secrets/grant"],
972 ["POST", "/:owner/:name/settings/app/secrets/revoke"],
973 ["POST", "/:owner/:name/settings/app/env/:var/delete"],
974 ["POST", "/:owner/:name/settings/app/domains"],
975 ["POST", "/:owner/:name/settings/app/domains/:host/check"],
976 ["POST", "/:owner/:name/settings/app/domains/:host/delete"],
977 ["POST", "/:owner/:name/settings/app/egress/:destination/grant"],
978 ["POST", "/:owner/:name/settings/app/egress/:destination/revoke"],
979 ["POST", "/:owner/:name/settings/app/blocked/:destination/allow"],
980 ["POST", "/:owner/:name/settings/app/blocked/:destination/ignore"],
981 ["GET", "/:owner/:name/settings/devices"],
982 ["POST", "/:owner/:name/settings/devices"],
983 ["POST", "/:owner/:name/settings/devices/:entry/grant"],
984 ["POST", "/:owner/:name/settings/devices/:entry/delete"],
985 ["GET", "/:owner/:name/settings/prompts"],
986 ["POST", "/:owner/:name/settings/prompts"],
987 ["POST", "/:owner/:name/settings/prompts/:id/run"],
988 ["POST", "/:owner/:name/settings/prompts/:id/delete"],
989 ["GET", "/:owner/:name/wallet"],
990 ["GET", "/:owner/:name/wallet.csv"],
991 ["POST", "/:owner/:name/wallet"],
992 ["GET", "/:owner/:name/settings/crew"],
993 ["POST", "/:owner/:name/settings/crew"],
994 ["POST", "/:owner/:name/settings/crew/subscriptions"],
995 ["POST", "/:owner/:name/settings/crew/:username/remove"],
996 ["POST", "/:owner/:name/settings/crew/:username/role"],
997 ["POST", "/:owner/:name/settings/pillars"],
998 ["GET", "/:owner/:name/settings/autonomy"],
999 ["POST", "/:owner/:name/settings/autonomy"],
1000 ["POST", "/:owner/:name/settings/autonomy/raise"],
1001 ["POST", "/:owner/:name/settings/check-slots"],
1002 ["GET", "/:owner/:name/allocation"],
1003 ["POST", "/:owner/:name/allocation/move"],
1004 ["POST", "/:owner/:name/allocation/weekly"],
1005 ["POST", "/:owner/:name/settings/holds"],
1006 ["POST", "/:owner/:name/settings/upstream"],
1007 ["POST", "/:owner/:name/settings/upstream/check"],
1008 ["POST", "/:owner/:name/follow-origin"],
1009 ["POST", "/:owner/:name/settings/upstream/sever"],
1010 ["POST", "/:owner/:name/settings/sources"],
1011 ["POST", "/:owner/:name/settings/sources/check"],
1012 ["POST", "/:owner/:name/settings/sources/:id/remove"],
1013 ["GET", "/:owner/:name/settings/labels"],
1014 ["POST", "/:owner/:name/settings/labels"],
1015 ["POST", "/:owner/:name/settings/labels/:id"],
1016 ["POST", "/:owner/:name/settings/labels/:id/delete"],
1017 ["GET", "/:owner/:name/settings/hooks"],
1018 ["POST", "/:owner/:name/settings/hooks"],
1019 ["POST", "/:owner/:name/settings/hooks/:id/delete"],
1020 ["POST", "/:owner/:name/settings/hooks/:id/deliveries/:delivery/redeliver"],
1021 ["POST", "/:owner/:name/settings/hooks/:id/ping"],
1022 ["POST", "/:owner/:name/settings/hooks/:id/pause"],
1023 ["POST", "/:owner/:name/settings/hooks/:id/resume"],
1024 ["GET", "/:owner/:name/settings/danger"],
1025 ["POST", "/:owner/:name/settings/delete"],
1026 ["POST", "/:owner/:name/review"],
1027 ["POST", "/:owner/:name/review/override"],
1028 ["POST", "/:owner/:name/settings/detach"],
1029 ["POST", "/:owner/:name/settings/detach/undo"],
1030 ["POST", "/:owner/:name/settings/detach/rejoin"],
1031 ["POST", "/:owner/:name/settings/origin/reconnect"],
1032 ] as const;
1033
1034 /** `repoTellsRoutes` (`routes/repo_tells.ts`). */
1035 export const REPO_TELLS_ROUTES = [
1036 ["GET", "/:owner/:name/tells"],
1037 ["GET", "/:owner/:name/tells/new"],
1038 ["GET", "/:owner/:name/tells/:number"],
1039 ["GET", "/:owner/:name/security"],
1040 ["GET", "/:owner/:name/together"],
1041 ["GET", "/:owner/:name/tell"],
1042 ["POST", "/:owner/:name/tell"],
1043 ["POST", "/:owner/:name/tell/undo"],
1044 ["POST", "/:owner/:name/crew/seat"],
1045 ["POST", "/tell"],
1046 ["GET", "/tell"],
1047 ["POST", "/tell/share"],
1048 ["GET", "/tell/share"],
1049 ["GET", "/tell/share/:id"],
1050 ["POST", "/:owner/:name/stuck"],
1051 ["GET", "/:owner/:name/held"],
1052 ["POST", "/:owner/:name/held/apply"],
1053 ["GET", "/:owner/:name/map"],
1054 ["GET", "/:owner/:name/space"],
1055 ["GET", "/:owner/:name/space.json"],
1056 ["GET", "/next"],
1057 ["GET", "/:owner/:name/next"],
1058 ["POST", "/:owner/:name/next"],
1059 ["POST", "/:owner/:name/next/batch"],
1060 ["GET", "/:owner/:name/week"],
1061 ["GET", "/:owner/:name/cost"],
1062 ["GET", "/:owner/:name/cost.csv"],
1063 ["POST", "/:owner/:name/week"],
1064 ["GET", "/:owner/:name/flows"],
1065 ["GET", "/:owner/:name/flows/map"],
1066 ["POST", "/:owner/:name/flows/check"],
1067 ["POST", "/:owner/:name/flows/probe"],
1068 ["POST", "/:owner/:name/flows/update"],
1069 ] as const;
1070
1071 /** `talkRoutes` (`routes/talk.ts`). */
1072 export const TALK_ROUTES = [
1073 ["GET", "/talk"],
1074 ["POST", "/talk"],
1075 ["POST", "/talk/wall"],
1076 ["GET", "/talk/stream"],
1077 ["GET", "/peek"],
1078 ["POST", "/talk/again/:how"],
1079 ["POST", "/talk/queue/:id/cancel"],
1080 ["POST", "/talk/confirm/:id"],
1081 ["POST", "/talk/undo/:turn"],
1082 ["POST", "/talk/act"],
1083 ["POST", "/talk/new"],
1084 ["POST", "/talk/display"],
1085 ["POST", "/talk/build"],
1086 ["POST", "/talk/dev"],
1087 ["GET", "/talk/dev/:token"],
1088 ["GET", "/talk/dev/:token/*path"],
1089 ["GET", "/talk/:id"],
1090 ["GET", "/talk/:id/download"],
1091 ["POST", "/talk/:id"],
1092 ["POST", "/talk/:id/rename"],
1093 ["POST", "/talk/:id/model"],
1094 ["POST", "/talk/:id/archive"],
1095 ["POST", "/talk/:id/pin"],
1096 ["POST", "/talk/:id/work/save"],
1097 ["POST", "/talk/:id/work/commit"],
1098 ["POST", "/talk/:id/work/discard"],
1099 ["POST", "/talk/:id/build/restore"],
1100 ["POST", "/talk/:id/build/publish"],
1101 ["POST", "/talk/:id/again/:how"],
1102 ] as const;
1103
1104 /** `teamsRoutes` (`routes/teams.ts`). */
1105 export const TEAMS_ROUTES = [
1106 ["POST", "/:owner/-/teams"],
1107 ["GET", "/:owner/-/teams/:team"],
1108 ["POST", "/:owner/-/teams/:team/add"],
1109 ["POST", "/:owner/-/teams/:team/remove"],
1110 ["POST", "/:owner/-/teams/:team/delete"],
1111 ] as const;
1112
1113 /** `apiRoutes` (`api.ts`). */
1114 export const API_ROUTES = [
1115 ["GET", "/api/v1/passport/health"],
1116 ["POST", "/api/v1/users"],
1117 ["GET", "/api/v1/users/:username"],
1118 ["GET", "/api/v1/users/:username/repos"],
1119 ["POST", "/api/v1/sessions"],
1120 ["DELETE", "/api/v1/sessions"],
1121 ["POST", "/api/v1/tokens"],
1122 ["GET", "/api/v1/tokens"],
1123 ["DELETE", "/api/v1/tokens/:id"],
1124 ["GET", "/api/v1/user"],
1125 ["POST", "/api/v1/user/email/verify"],
1126 ["PATCH", "/api/v1/user"],
1127 ["POST", "/api/v1/user/password"],
1128 ["GET", "/api/v1/user/orgs"],
1129 ["GET", "/api/v1/user/export"],
1130 ["GET", "/api/v1/user/keys"],
1131 ["POST", "/api/v1/user/keys"],
1132 ["DELETE", "/api/v1/user/keys/:id"],
1133 ["GET", "/api/v1/user/notify"],
1134 ["PUT", "/api/v1/user/notify"],
1135 ["GET", "/api/v1/user/origins"],
1136 ["POST", "/api/v1/user/origins"],
1137 ["POST", "/api/v1/user/origins/oauth"],
1138 ["GET", "/api/v1/user/origins/oauth/:id"],
1139 ["GET", "/api/v1/user/origin-apps"],
1140 ["POST", "/api/v1/user/origin-apps"],
1141 ["DELETE", "/api/v1/user/origin-apps/:id"],
1142 ["DELETE", "/api/v1/user/origins/:id"],
1143 ["POST", "/api/v1/user/origins/:id/sync"],
1144 ["GET", "/api/v1/user/origins/:id/repos"],
1145 ["GET", "/api/v1/user/origins/:id/browse/:owner/:name"],
1146 ["GET", "/api/v1/user/origins/:id/browse/:owner/:name/branches"],
1147 ["GET", "/api/v1/user/origins/:id/browse/:owner/:name/tags"],
1148 ["GET", "/api/v1/user/origins/:id/browse/:owner/:name/labels"],
1149 ["GET", "/api/v1/user/origins/:id/browse/:owner/:name/paths/:ref"],
1150 ["GET", "/api/v1/user/origins/:id/browse/:owner/:name/tree/:ref"],
1151 ["GET", "/api/v1/user/origins/:id/browse/:owner/:name/tree/:ref/*path"],
1152 ["GET", "/api/v1/user/origins/:id/browse/:owner/:name/blob/:ref/*path"],
1153 ["GET", "/api/v1/user/origins/:id/browse/:owner/:name/commits"],
1154 ["GET", "/api/v1/user/origins/:id/browse/:owner/:name/commits/:oid"],
1155 ["GET", "/api/v1/user/origins/:id/browse/:owner/:name/issues"],
1156 ["GET", "/api/v1/user/origins/:id/browse/:owner/:name/pulls"],
1157 ["GET", "/api/v1/user/origins/:id/browse/:owner/:name/issues/:number"],
1158 ["GET", "/api/v1/user/origins/:id/browse/:owner/:name/pulls/:number"],
1159 ["POST", "/api/v1/user/origins/:id/mirror"],
1160 ["POST", "/api/v1/user/origins/:id/fork"],
1161 ["POST", "/api/v1/user/origins/:id/browse/:owner/:name/contribute"],
1162 ["GET", "/api/v1/user/origins/:id/mirror/:job"],
1163 ["GET", "/api/v1/user/origins/:id/mirror/:job/stream"],
1164 ["GET", "/api/v1/user/pins"],
1165 ["PUT", "/api/v1/user/pins/:owner/:name"],
1166 ["GET", "/api/v1/user/assigned"],
1167 ["GET", "/api/v1/user/next-steps"],
1168 ["DELETE", "/api/v1/user/pins/:owner/:name"],
1169 ["GET", "/api/v1/version"],
1170 ["GET", "/api/v1/user/repos"],
1171 ["GET", "/api/v1/admin/pinned"],
1172 ["POST", "/api/v1/admin/pinned"],
1173 ["POST", "/api/v1/admin/pinned/:name/claim"],
1174 ["POST", "/api/v1/admin/pinned/:name/update"],
1175 ["POST", "/api/v1/admin/pinned/:name/check"],
1176 ["POST", "/api/v1/admin/pinned/:name/keep"],
1177 ["GET", "/api/v1/admin/infra"],
1178 ["GET", "/api/v1/admin/infra/code"],
1179 ["POST", "/api/v1/admin/infra/plan"],
1180 ["POST", "/api/v1/admin/infra/apply"],
1181 ["POST", "/api/v1/admin/pinned/:name/retire"],
1182 ["POST", "/api/v1/admin/pinned/:name/rollback"],
1183 ["GET", "/api/v1/admin/profile"],
1184 ["GET", "/api/v1/admin/crawlers"],
1185 ["GET", "/api/v1/admin/kpis/probe"],
1186 ["GET", "/api/v1/admin/billing/funnel"],
1187 ["GET", "/api/v1/admin/traffic/probe"],
1188 ["GET", "/api/v1/admin/traffic/visitors"],
1189 ["GET", "/api/v1/admin/capacity"],
1190 ["PUT", "/api/v1/admin/capacity/:key"],
1191 ["GET", "/api/v1/admin/shield"],
1192 ["PUT", "/api/v1/admin/shield"],
1193 ["GET", "/api/v1/admin/limits"],
1194 ["PUT", "/api/v1/admin/limits/:key"],
1195 ["GET", "/api/v1/admin/plans"],
1196 ["PUT", "/api/v1/admin/plans"],
1197 ["PUT", "/api/v1/admin/billing/links"],
1198 ["GET", "/api/v1/admin/quotas"],
1199 ["PUT", "/api/v1/admin/quotas/:key"],
1200 ["GET", "/api/v1/admin/teams"],
1201 ["PUT", "/api/v1/admin/teams/:slug"],
1202 ["GET", "/api/v1/admin/settings"],
1203 ["PATCH", "/api/v1/admin/settings"],
1204 ["POST", "/api/v1/admin/invites"],
1205 ["GET", "/api/v1/admin/invites"],
1206 ["DELETE", "/api/v1/admin/invites/:id"],
1207 ["GET", "/api/v1/admin/accounts"],
1208 ["POST", "/api/v1/admin/accounts/:username/suspend"],
1209 ["POST", "/api/v1/admin/accounts/:username/model-grant"],
1210 ["GET", "/api/v1/admin/requests"],
1211 ["POST", "/api/v1/admin/requests/:username/allow"],
1212 ["POST", "/api/v1/admin/requests/:username/decline"],
1213 ["GET", "/api/v1/admin/people"],
1214 ["POST", "/api/v1/admin/accounts/:username/role"],
1215 ["POST", "/api/v1/admin/accounts/:username/ceiling"],
1216 ["POST", "/api/v1/admin/accounts/:username/unsuspend"],
1217 ["POST", "/api/v1/admin/accounts/:username/reset"],
1218 ["POST", "/api/v1/admin/accounts/:username/end-sessions"],
1219 ["POST", "/api/v1/admin/accounts/:username/verify"],
1220 ["DELETE", "/api/v1/admin/accounts/:username"],
1221 ["POST", "/api/v1/admin/runners"],
1222 ["POST", "/api/v1/admin/runners/:id/revoke"],
1223 ["POST", "/api/v1/admin/runners/:id/resume"],
1224 ["GET", "/api/v1/admin/runners"],
1225 ["DELETE", "/api/v1/admin/runners/:id"],
1226 ["POST", "/api/v1/runner/claim"],
1227 ["POST", "/api/v1/runner/jobs/:id"],
1228 ["GET", "/api/v1/runner/jobs/:id/seed"],
1229 ["GET", "/api/v1/runner/jobs/:id/git/info/refs"],
1230 ["POST", "/api/v1/runner/jobs/:id/git/git-upload-pack"],
1231 ["POST", "/api/v1/games/agent/sync"],
1232 ["GET", "/api/v1/admin/maintenance"],
1233 ["POST", "/api/v1/admin/maintenance/prepare"],
1234 ["POST", "/api/v1/admin/maintenance/resume"],
1235 ["GET", "/api/v1/maintenance/runs"],
1236 ["GET", "/api/v1/maintenance/duties"],
1237 ["POST", "/api/v1/maintenance/duties/:name"],
1238 ["GET", "/api/v1/admin/machines/:machine/disks"],
1239 ["PUT", "/api/v1/admin/machines/:machine/disks/:device"],
1240 ["GET", "/api/v1/flags"],
1241 ["GET", "/api/v1/app-templates"],
1242 ["POST", "/api/v1/admin/app-templates"],
1243 ["POST", "/api/v1/forge-templates"],
1244 ["DELETE", "/api/v1/forge-templates/:id"],
1245 ["GET", "/api/v1/telemetry/system"],
1246 ["GET", "/api/v1/telemetry/flow"],
1247 ["GET", "/api/v1/telemetry/home"],
1248 ["GET", "/api/v1/telemetry/heap-census"],
1249 ["GET", "/api/v1/telemetry/sources"],
1250 ["GET", "/api/v1/telemetry/history"],
1251 ["GET", "/api/v1/contribute"],
1252 ["POST", "/api/v1/contribute"],
1253 ["GET", "/api/v1/boards/sources"],
1254 ["POST", "/api/v1/boards/query"],
1255 ["GET", "/api/v1/boards"],
1256 ["GET", "/api/v1/boards/pins"],
1257 ["POST", "/api/v1/boards/pins"],
1258 ["GET", "/api/v1/boards/:slug"],
1259 ["GET", "/api/v1/boards/:slug/panels/:id"],
1260 ["PUT", "/api/v1/boards/:slug"],
1261 ["DELETE", "/api/v1/boards/:slug"],
1262 ["PUT", "/api/v1/repos/:owner/:name/display/builds"],
1263 ["POST", "/api/v1/drills"],
1264 ["GET", "/api/v1/crew/scorecard"],
1265 ["GET", "/api/v1/telemetry/routes"],
1266 ["GET", "/api/v1/crew/week"],
1267 ["GET", "/api/v1/crew/now"],
1268 ["POST", "/api/v1/conversation-tokens"],
1269 ["POST", "/api/v1/first-admin"],
1270 ["GET", "/api/v1/first-admin/claim"],
1271 ["POST", "/api/v1/first-admin/recover"],
1272 ["GET", "/api/v1/users/:username/signins"],
1273 ["DELETE", "/api/v1/users/:username/sessions/:id"],
1274 ["POST", "/api/v1/orgs"],
1275 ["GET", "/api/v1/orgs/:org"],
1276 ["GET", "/api/v1/orgs/:org/teams"],
1277 ["POST", "/api/v1/orgs/:org/teams"],
1278 ["DELETE", "/api/v1/orgs/:org/teams/:team"],
1279 ["GET", "/api/v1/orgs/:org/teams/:team/members"],
1280 ["POST", "/api/v1/orgs/:org/teams/:team/members"],
1281 ["DELETE", "/api/v1/orgs/:org/teams/:team/members/:username"],
1282 ["GET", "/api/v1/search"],
1283 ["GET", "/api/v1/repos"],
1284 ["GET", "/api/v1/templates"],
1285 ["POST", "/api/v1/repos"],
1286 ["GET", "/api/v1/repos/:owner/:name"],
1287 ["GET", "/api/v1/repos/:owner/:name/upstream"],
1288 ["PUT", "/api/v1/repos/:owner/:name/upstream"],
1289 ["POST", "/api/v1/repos/:owner/:name/upstream/check"],
1290 ["GET", "/api/v1/forks/flows"],
1291 ["GET", "/api/v1/repos/:owner/:name/forks/tree"],
1292 ["GET", "/api/v1/repos/:owner/:name/forks"],
1293 ["POST", "/api/v1/repos/:owner/:name/copies"],
1294 ["POST", "/api/v1/repos/:owner/:name/forks"],
1295 ["PUT", "/api/v1/repos/:owner/:name/source"],
1296 ["PATCH", "/api/v1/repos/:owner/:name"],
1297 ["DELETE", "/api/v1/repos/:owner/:name"],
1298 ["POST", "/api/v1/repos/:owner/:name/transfer"],
1299 ["GET", "/api/v1/repos/:owner/:name/events"],
1300 ["GET", "/api/v1/repos/:owner/:name/following"],
1301 ["POST", "/api/v1/repos/:owner/:name/following/take"],
1302 ["POST", "/api/v1/repos/:owner/:name/following/sever"],
1303 ["PATCH", "/api/v1/forge/following"],
1304 ["POST", "/api/v1/repos/:owner/:name/following/propose"],
1305 ["POST", "/api/v1/repos/:owner/:name/following/propose-parent"],
1306 ["GET", "/api/v1/repos/:owner/:name/following/proposals"],
1307 ["POST", "/api/v1/repos/:owner/:name/following/converge"],
1308 ["GET", "/api/v1/repos/:owner/:name/family"],
1309 ["GET", "/api/v1/repos/:owner/:name/releases"],
1310 ["GET", "/api/v1/repos/:owner/:name/branches"],
1311 ["POST", "/api/v1/repos/:owner/:name/branches"],
1312 ["DELETE", "/api/v1/repos/:owner/:name/branches/*branch"],
1313 ["GET", "/api/v1/repos/:owner/:name/tags"],
1314 ["GET", "/api/v1/repos/:owner/:name/commits"],
1315 ["GET", "/api/v1/repos/:owner/:name/commits/:oid"],
1316 ["GET", "/api/v1/repos/:owner/:name/commits/:oid/check"],
1317 ["GET", "/api/v1/repos/:owner/:name/dependencies"],
1318 ["GET", "/api/v1/repos/:owner/:name/contents"],
1319 ["GET", "/api/v1/repos/:owner/:name/contents/*path"],
1320 ["POST", "/api/v1/repos/:owner/:name/contents"],
1321 ["POST", "/api/v1/repos/:owner/:name/edits"],
1322 ["GET", "/api/v1/repos/:owner/:name/labels"],
1323 ["POST", "/api/v1/repos/:owner/:name/labels"],
1324 ["PATCH", "/api/v1/repos/:owner/:name/labels/:id"],
1325 ["DELETE", "/api/v1/repos/:owner/:name/labels/:id"],
1326 ["GET", "/api/v1/repos/:owner/:name/desk"],
1327 ["POST", "/api/v1/repos/:owner/:name/desk"],
1328 ["DELETE", "/api/v1/repos/:owner/:name/desk/:id"],
1329 ["GET", "/api/v1/repos/:owner/:name/vision"],
1330 ["GET", "/api/v1/repos/:owner/:name/data"],
1331 ["GET", "/api/v1/repos/:owner/:name/data/:env/:file/tables"],
1332 ["GET", "/api/v1/repos/:owner/:name/data/:env/:file/rows"],
1333 ["POST", "/api/v1/repos/:owner/:name/data-import"],
1334 ["GET", "/api/v1/repos/:owner/:name/data-move"],
1335 ["POST", "/api/v1/repos/:owner/:name/data-move"],
1336 ["POST", "/api/v1/repos/:owner/:name/data/:env/:file/query"],
1337 ["GET", "/api/v1/repos/:owner/:name/drop"],
1338 ["POST", "/api/v1/repos/:owner/:name/drop"],
1339 ["GET", "/api/v1/repos/:owner/:name/drop/:file"],
1340 ["DELETE", "/api/v1/repos/:owner/:name/drop/:file"],
1341 ["GET", "/api/v1/repos/:owner/:name/statement"],
1342 ["POST", "/api/v1/repos/:owner/:name/atlas"],
1343 ["PUT", "/api/v1/repos/:owner/:name/pulls/:number/labels"],
1344 ["PUT", "/api/v1/repos/:owner/:name/issues/:number/labels"],
1345 ["GET", "/api/v1/repos/:owner/:name/issues/:number/teams"],
1346 ["PUT", "/api/v1/repos/:owner/:name/issues/:number/teams"],
1347 ["GET", "/api/v1/repos/:owner/:name/security"],
1348 ["GET", "/api/v1/repos/:owner/:name/issues"],
1349 ["POST", "/api/v1/repos/:owner/:name/issues"],
1350 ["GET", "/api/v1/repos/:owner/:name/issues/:number/plan"],
1351 ["PUT", "/api/v1/repos/:owner/:name/issues/:number/plan"],
1352 ["GET", "/api/v1/repos/:owner/:name/issues/:number"],
1353 ["GET", "/api/v1/repos/:owner/:name/issues/:number/comments"],
1354 ["POST", "/api/v1/repos/:owner/:name/issues/:number/private"],
1355 ["GET", "/api/v1/repos/:owner/:name/issues/:number/estimates"],
1356 ["POST", "/api/v1/repos/:owner/:name/issues/:number/estimates"],
1357 ["GET", "/api/v1/repos/:owner/:name/issues/:number/dependencies"],
1358 ["POST", "/api/v1/repos/:owner/:name/issues/:number/dependencies"],
1359 ["DELETE", "/api/v1/repos/:owner/:name/issues/:number/dependencies/:blocker"],
1360 ["POST", "/api/v1/repos/:owner/:name/issues/:number/dependencies/:blocker/confirm"],
1361 ["PATCH", "/api/v1/repos/:owner/:name/issues/:number"],
1362 ["POST", "/api/v1/repos/:owner/:name/issues/:number/comments"],
1363 ["POST", "/api/v1/repos/:owner/:name/issues/:number/comments/:id/question"],
1364 ["GET", "/api/v1/repos/:owner/:name/chapters"],
1365 ["POST", "/api/v1/repos/:owner/:name/chapters"],
1366 ["POST", "/api/v1/repos/:owner/:name/chapters/:chapter/:verb"],
1367 ["POST", "/api/v1/repos/:owner/:name/reports"],
1368 ["GET", "/api/v1/repos/:owner/:name/reports/:id/status"],
1369 ["GET", "/api/v1/repos/:owner/:name/reports"],
1370 ["POST", "/api/v1/repos/:owner/:name/reports/:id/accept"],
1371 ["POST", "/api/v1/repos/:owner/:name/reports/:id/dismiss"],
1372 ["POST", "/api/v1/repos/:owner/:name/offers"],
1373 ["GET", "/api/v1/offers/:receipt"],
1374 ["GET", "/api/v1/status/:token"],
1375 ["POST", "/api/v1/start"],
1376 ["GET", "/api/v1/repos/:owner/:name/app/notes"],
1377 ["POST", "/api/v1/repos/:owner/:name/app/notes/:id/hide"],
1378 ["POST", "/api/v1/repos/:owner/:name/app/notes/:id/ban"],
1379 ["POST", "/api/v1/repos/:owner/:name/app/notes/:id/unban"],
1380 ["GET", "/api/v1/repos/:owner/:name/app/registry"],
1381 ["GET", "/api/v1/repos/:owner/:name/app/registry/updates"],
1382 ["POST", "/api/v1/repos/:owner/:name/app/registry/updates"],
1383 ["PUT", "/api/v1/repos/:owner/:name/app/registry/:item"],
1384 ["DELETE", "/api/v1/repos/:owner/:name/app/registry/:item"],
1385 ["GET", "/api/v1/repos/:owner/:name/changes/:room"],
1386 ["POST", "/api/v1/repos/:owner/:name/changes/:room"],
1387 ["POST", "/api/v1/admin/releases/:sha/rollback"],
1388 ["POST", "/api/v1/repos/:owner/:name/pulls/:number/take-back"],
1389 ["POST", "/api/v1/conversation-confirms/:id"],
1390 ["POST", "/api/v1/conversation/messages"],
1391 ["DELETE", "/api/v1/conversation/queue/:id"],
1392 ["POST", "/api/v1/conversation/stop"],
1393 ["POST", "/api/v1/conversation/files"],
1394 ["GET", "/api/v1/conversation/files/:id"],
1395 ["DELETE", "/api/v1/conversation/files/:id"],
1396 ["GET", "/api/v1/conversation/turns"],
1397 ["GET", "/api/v1/conversations"],
1398 ["POST", "/api/v1/conversations"],
1399 ["PATCH", "/api/v1/conversations/:id"],
1400 ["POST", "/api/v1/builds"],
1401 ["GET", "/api/v1/conversations/:id/build"],
1402 ["GET", "/api/v1/conversations/:id/build/versions/:n/diff"],
1403 ["POST", "/api/v1/conversations/:id/build/restore"],
1404 ["POST", "/api/v1/conversations/:id/build/publish"],
1405 ["GET", "/api/v1/repos/:owner/:name/flow"],
1406 ["POST", "/api/v1/repos/:owner/:name/plan"],
1407 ["GET", "/api/v1/repos/:owner/:name/milestones"],
1408 ["GET", "/api/v1/repos/:owner/:name/milestones/:number"],
1409 ["GET", "/api/v1/repos/:owner/:name/waves"],
1410 ["GET", "/api/v1/repos/:owner/:name/waves/:version"],
1411 ["POST", "/api/v1/thoughts"],
1412 ["PUT", "/api/v1/repos/:owner/:name/milestones/:number/watch"],
1413 ["DELETE", "/api/v1/repos/:owner/:name/milestones/:number/watch"],
1414 ["POST", "/api/v1/repos/:owner/:name/milestones/:number/limb"],
1415 ["GET", "/api/v1/repos/:owner/:name/queue"],
1416 ["GET", "/api/v1/repos/:owner/:name/map"],
1417 ["GET", "/api/v1/repos/:owner/:name/roadmap"],
1418 ["GET", "/api/v1/map"],
1419 ["GET", "/api/v1/repos/:owner/:name/decisions"],
1420 ["GET", "/api/v1/repos/:owner/:name/pulls"],
1421 ["POST", "/api/v1/repos/:owner/:name/proposal-tokens"],
1422 ["POST", "/api/v1/repos/:owner/:name/pulls"],
1423 ["GET", "/api/v1/repos/:owner/:name/pulls/:number"],
1424 ["PATCH", "/api/v1/repos/:owner/:name/pulls/:number"],
1425 ["PUT", "/api/v1/repos/:owner/:name/pulls/:number/hold"],
1426 ["DELETE", "/api/v1/repos/:owner/:name/pulls/:number/hold"],
1427 ["POST", "/api/v1/repos/:owner/:name/pulls/:number/ready"],
1428 ["POST", "/api/v1/repos/:owner/:name/pulls/:number/review-requests"],
1429 ["POST", "/api/v1/repos/:owner/:name/pulls/:number/merge"],
1430 ["POST", "/api/v1/repos/:owner/:name/pulls/:number/slices"],
1431 ["POST", "/api/v1/repos/:owner/:name/pulls/:number/comments"],
1432 ["POST", "/api/v1/repos/:owner/:name/pulls/:number/looks"],
1433 ["GET", "/api/v1/repos/:owner/:name/pulls/:number/looks"],
1434 ["GET", "/api/v1/repos/:owner/:name/pulls/:number/review"],
1435 ["PUT", "/api/v1/repos/:owner/:name/pulls/:number/review"],
1436 ["GET", "/api/v1/repos/:owner/:name/pulls/:number/reviews"],
1437 ["POST", "/api/v1/repos/:owner/:name/pulls/:number/reviews"],
1438 ["GET", "/api/v1/repos/:owner/:name/pulls/:number/review-states"],
1439 ["POST", "/api/v1/repos/:owner/:name/pulls/:number/review-states"],
1440 ["POST", "/api/v1/repos/:owner/:name/pulls/:number/variant"],
1441 ["POST", "/api/v1/repos/:owner/:name/pulls/:number/approve-here"],
1442 ["GET", "/api/v1/repos/:owner/:name/pulls/:number/threads"],
1443 ["POST", "/api/v1/repos/:owner/:name/pulls/:number/threads/:anchor/resolve"],
1444 ["DELETE", "/api/v1/repos/:owner/:name/pulls/:number/threads/:anchor/resolve"],
1445 ["POST", "/api/v1/repos/:owner/:name/contribute"],
1446 ["GET", "/api/v1/repos/:owner/:name/hooks"],
1447 ["GET", "/api/v1/repos/:owner/:name/hooks/:id/deliveries"],
1448 ["POST", "/api/v1/repos/:owner/:name/hooks/:id/ping"],
1449 ["POST", "/api/v1/repos/:owner/:name/hooks/:id/pause"],
1450 ["POST", "/api/v1/repos/:owner/:name/hooks/:id/resume"],
1451 ["POST", "/api/v1/repos/:owner/:name/hooks/:id/deliveries/:delivery/redeliver"],
1452 ["POST", "/api/v1/repos/:owner/:name/hooks"],
1453 ["DELETE", "/api/v1/repos/:owner/:name/hooks/:id"],
1454 ["GET", "/api/v1/keeper"],
1455 ["GET", "/api/v1/keeper/pulse"],
1456 ["POST", "/api/v1/release/heartbeat"],
1457 ["GET", "/api/v1/proof/daily"],
1458 ["POST", "/api/v1/repos/:owner/:name/sync"],
1459 ["POST", "/api/v1/repos/:owner/:name/origin/reconnect"],
1460 ["POST", "/api/v1/fleet/ops"],
1461 ["GET", "/api/v1/fleet/ops"],
1462 ["GET", "/api/v1/fleet/rows"],
1463 ["GET", "/api/v1/fleet/ops/:id"],
1464 ["POST", "/api/v1/fleet/ops/:id/undo"],
1465 ["GET", "/api/v1/health"],
1466 ["GET", "/health"],
1467 ["GET", "/metrics"],
1468 ["GET", "/api/v1/explore"],
1469 ["POST", "/api/v1/repos/:owner/:name/make-it-yours"],
1470 ["GET", "/api/v1/front"],
1471 ["PUT", "/api/v1/front"],
1472 ["GET", "/api/v1/forge"],
1473 ["POST", "/api/v1/heartbeat"],
1474 ["POST", "/api/v1/broker/origins"],
1475 ["POST", "/api/v1/repos/:owner/:name/origin-hook"],
1476 ["GET", "/api/v1/family"],
1477 ["GET", "/api/v1/plans"],
1478 ["GET", "/api/v1/forges/sizes"],
1479 ["GET", "/api/v1/forges/templates"],
1480 ["GET", "/api/v1/forges/:name/bill"],
1481 ["GET", "/api/v1/forges"],
1482 ["POST", "/api/v1/forges"],
1483 ["GET", "/api/v1/forges/recipes"],
1484 ["PUT", "/api/v1/forges/recipes/:name"],
1485 ["DELETE", "/api/v1/forges/recipes/:name"],
1486 ["PUT", "/api/v1/forges/:name/credit"],
1487 ["GET", "/api/v1/credit"],
1488 ["GET", "/api/v1/forges/:name/sandbox"],
1489 ["POST", "/api/v1/forges/:name/sandbox"],
1490 ["POST", "/api/v1/forges/:name/claim-link"],
1491 ["GET", "/api/v1/packs"],
1492 ["GET", "/api/v1/packs/:name"],
1493 ["PUT", "/api/v1/packs/:name"],
1494 ["GET", "/api/v1/forge/view"],
1495 ["GET", "/api/v1/flow/ship-time"],
1496 ["GET", "/api/v1/forge/economics"],
1497 ["PUT", "/api/v1/forge/economics"],
1498 ["GET", "/api/v1/forges/:name/plan"],
1499 ["PUT", "/api/v1/forges/:name/plan"],
1500 ["GET", "/api/v1/codes"],
1501 ["POST", "/api/v1/codes"],
1502 ["DELETE", "/api/v1/codes/:id"],
1503 ["GET", "/api/v1/releases"],
1504 ["GET", "/api/v1/apps"],
1505 ["POST", "/api/v1/apps"],
1506 ["POST", "/api/v1/migrate"],
1507 ["GET", "/api/v1/migrate/:job"],
1508 ["GET", "/api/v1/migrate/:job/stream"],
1509 ["GET", "/api/v1/repos/:owner/:name/flags"],
1510 ["PUT", "/api/v1/repos/:owner/:name/flags/:flag"],
1511 ["GET", "/api/v1/repos/:owner/:name/app"],
1512 ["POST", "/api/v1/repos/:owner/:name/app"],
1513 ["PATCH", "/api/v1/repos/:owner/:name/app"],
1514 ["DELETE", "/api/v1/repos/:owner/:name/app"],
1515 ["GET", "/api/v1/repos/:owner/:name/app/members"],
1516 ["PUT", "/api/v1/repos/:owner/:name/app/members"],
1517 ["GET", "/api/v1/repos/:owner/:name/app/domains"],
1518 ["POST", "/api/v1/repos/:owner/:name/app/domains"],
1519 ["POST", "/api/v1/repos/:owner/:name/app/domains/:host/claim"],
1520 ["POST", "/api/v1/repos/:owner/:name/app/domains/:host/check"],
1521 ["PUT", "/api/v1/repos/:owner/:name/app/domains/:host/old-records"],
1522 ["DELETE", "/api/v1/repos/:owner/:name/app/domains/:host"],
1523 ["GET", "/api/v1/repos/:owner/:name/app/env"],
1524 ["PUT", "/api/v1/repos/:owner/:name/app/env/:var"],
1525 ["DELETE", "/api/v1/repos/:owner/:name/app/env/:var"],
1526 ["POST", "/api/v1/repos/:owner/:name/app/pull"],
1527 ["POST", "/api/v1/repos/:owner/:name/app/:env/redeploy"],
1528 ["POST", "/api/v1/repos/:owner/:name/app/:env/stop"],
1529 ["PUT", "/api/v1/repos/:owner/:name/demo"],
1530 ["DELETE", "/api/v1/repos/:owner/:name/demo"],
1531 ["POST", "/api/v1/repos/:owner/:name/builds/preview"],
1532 ["GET", "/api/v1/repos/:owner/:name/app/:env/open"],
1533 ["GET", "/api/v1/repos/:owner/:name/app/pulls"],
1534 ["GET", "/api/v1/repos/:owner/:name/pulls/:number/diff"],
1535 ["GET", "/api/v1/repos/:owner/:name/pulls/:number/files"],
1536 ["GET", "/api/v1/repos/:owner/:name/builds"],
1537 ["POST", "/api/v1/repos/:owner/:name/builds"],
1538 ["DELETE", "/api/v1/repos/:owner/:name/builds/:label"],
1539 ["PATCH", "/api/v1/repos/:owner/:name/builds/:label"],
1540 ["GET", "/api/v1/repos/:owner/:name/builds/:label/shots"],
1541 ["POST", "/api/v1/repos/:owner/:name/builds/:label/shots"],
1542 ["GET", "/api/v1/repos/:owner/:name/builds/:label/shots/looks"],
1543 ["POST", "/api/v1/repos/:owner/:name/builds/:label/shots/looks"],
1544 ["POST", "/api/v1/repos/:owner/:name/builds/:label/shots/:file"],
1545 ["DELETE", "/api/v1/repos/:owner/:name/builds/:label/shots/:file"],
1546 ["GET", "/api/v1/repos/:owner/:name/builds/:label/cart"],
1547 ["POST", "/api/v1/repos/:owner/:name/builds/:label/cart"],
1548 ["GET", "/api/v1/repos/:owner/:name/iterations"],
1549 ["POST", "/api/v1/repos/:owner/:name/deepsec"],
1550 ["GET", "/api/v1/repos/:owner/:name/egress-grants"],
1551 ["POST", "/api/v1/repos/:owner/:name/egress-grants"],
1552 ["DELETE", "/api/v1/repos/:owner/:name/egress-grants"],
1553 ["GET", "/api/v1/repos/:owner/:name/crew-devices"],
1554 ["POST", "/api/v1/repos/:owner/:name/crew-devices"],
1555 ["POST", "/api/v1/repos/:owner/:name/crew-devices/grant"],
1556 ["DELETE", "/api/v1/repos/:owner/:name/crew-devices"],
1557 ["GET", "/api/v1/reach/asks"],
1558 ["POST", "/api/v1/reach/asks"],
1559 ["GET", "/api/v1/asks/admin"],
1560 ["POST", "/api/v1/asks/admin"],
1561 ["POST", "/api/v1/devices/:id/print"],
1562 ["GET", "/api/v1/devices/:id/print/:job"],
1563 ["POST", "/api/v1/timers"],
1564 ["POST", "/api/v1/timers/finish"],
1565 ["DELETE", "/api/v1/timers/:key"],
1566 ["GET", "/api/v1/repos/:owner/:name/schedules"],
1567 ["POST", "/api/v1/repos/:owner/:name/schedules/:schedule/:action"],
1568 ["GET", "/api/v1/repos/:owner/:name/jobs"],
1569 ["POST", "/api/v1/repos/:owner/:name/jobs/:id/:action"],
1570 ["GET", "/api/v1/repos/:owner/:name/prompts"],
1571 ["POST", "/api/v1/repos/:owner/:name/prompts"],
1572 ["POST", "/api/v1/repos/:owner/:name/prompts/:id/run"],
1573 ["DELETE", "/api/v1/repos/:owner/:name/prompts/:id"],
1574 ["GET", "/api/v1/cloud/accounts"],
1575 ["GET", "/api/v1/places"],
1576 ["PUT", "/api/v1/places/pin"],
1577 ["POST", "/api/:project/envelope/"],
1578 ["POST", "/api/:project/envelope"],
1579 ["POST", "/api/:project/otlp/v1/traces"],
1580 ["POST", "/api/:project/otlp/v1/logs"],
1581 ["GET", "/api/v1/repos/:owner/:name/app/errors"],
1582 ["GET", "/api/v1/repos/:owner/:name/app/errors/:group"],
1583 ["POST", "/api/v1/repos/:owner/:name/app/errors/:group/resolve"],
1584 ["GET", "/api/v1/secrets/:scope"],
1585 ["PUT", "/api/v1/secrets/:scope/:name"],
1586 ["DELETE", "/api/v1/secrets/:scope/:name"],
1587 ["GET", "/api/v1/admin/drills"],
1588 ["GET", "/api/v1/features"],
1589 ["GET", "/api/v1/features/:slug"],
1590 ["GET", "/api/v1/features/:slug/feed"],
1591 ["PUT", "/api/v1/features/:slug"],
1592 ["DELETE", "/api/v1/features/:slug"],
1593 ["PATCH", "/api/v1/features/:slug/settings"],
1594 ["GET", "/api/v1/returns"],
1595 ["POST", "/api/v1/repos/:owner/:name/spend"],
1596 ["GET", "/api/v1/usage"],
1597 ["GET", "/api/v1/repos/:owner/:name/usage"],
1598 ["GET", "/api/v1/fleet/graph"],
1599 ["GET", "/api/v1/openapi.json"],
1600 ["GET", "/api/v1/here"],
1601 ["GET", "/api/v1/repos/:owner/:name/runs"],
1602 ["GET", "/api/v1/repos/:owner/:name/runs/:id"],
1603 ["GET", "/api/v1/repos/:owner/:name/queue/gates"],
1604 ["GET", "/api/v1/repos/:owner/:name/growth"],
1605 ["GET", "/api/v1/repos/:owner/:name/gates/:id/log"],
1606 ["GET", "/api/v1/repos/:owner/:name/runs/:id/log"],
1607 ["POST", "/api/v1/repos/:owner/:name/runs/:id/cancel"],
1608 ["POST", "/api/v1/repos/:owner/:name/runs/:id/steer"],
1609 ["GET", "/api/v1/repos/:owner/:name/pulls/:number/checks"],
1610 ["POST", "/api/v1/repos/:owner/:name/pulls/:number/checks"],
1611 ["PUT", "/api/v1/repos/:owner/:name/issues/:number/assignee"],
1612 ["PUT", "/api/v1/repos/:owner/:name/pulls/:number/assignee"],
1613 ["GET", "/api/v1/agents"],
1614 ["POST", "/api/v1/agents"],
1615 ["GET", "/api/v1/agents/:username"],
1616 ["PATCH", "/api/v1/agents/:username"],
1617 ["DELETE", "/api/v1/agents/:username"],
1618 ["GET", "/api/v1/admin/subscriptions"],
1619 ["GET", "/api/v1/repos/:owner/:name/crew"],
1620 ["PUT", "/api/v1/repos/:owner/:name/crew/:username"],
1621 ["DELETE", "/api/v1/repos/:owner/:name/crew/:username"],
1622 ] as const;
1623
1624 /** `feedRoutes` (`feed.ts`). */
1625 export const FEED_ROUTES = [
1626 ["GET", "/api/v1/feed"],
1627 ["GET", "/api/v1/feed/chips"],
1628 ["POST", "/api/v1/feed/chips"],
1629 ["GET", "/api/v1/asks"],
1630 ["POST", "/api/v1/asks/bulk"],
1631 ["POST", "/api/v1/asks/bulk/:id/undo"],
1632 ["POST", "/api/v1/asks/decide"],
1633 ["POST", "/api/v1/asks/give-back"],
1634 ["POST", "/api/v1/asks/decide/:id/undo"],
1635 ["POST", "/api/v1/asks/proposal/:id/:verb"],
1636 ["POST", "/api/v1/feed/interactions"],
1637 ["GET", "/api/v1/feed/likes"],
1638 ["POST", "/api/v1/feed/tells"],
1639 ["POST", "/api/v1/share"],
1640 ] as const;
1641
1642 /** `configRoutes` (`config.ts`). */
1643 export const CONFIG_ROUTES = [
1644 ["GET", "/api/v1/config"],
1645 ["PATCH", "/api/v1/config"],
1646 ["GET", "/api/v1/apps/:slug/config"],
1647 ["PATCH", "/api/v1/apps/:slug/config"],
1648 ["GET", "/api/v1/cache"],
1649 ] as const;
1650
1651 /** `checksRecheckRoutes` (`checks_recheck.ts`). */
1652 export const CHECKS_RECHECK_ROUTES = [
1653 ["POST", "/api/v1/repos/:owner/:name/checks/recheck"],
1654 ] as const;
1655
1656 /**
1657 * The two pages `buildApiRouter` answers from their own modules: the changelog's JSON and `/api`.
1658 */
1659 export const API_PAGES_ROUTES = [
1660 ["GET", "/api/v1/changelog"],
1661 ["GET", "/api"],
1662 ] as const;
src/http/named_refusal.ts +11 −6
@@ -13,11 +13,11 @@
1313 * An extra field beside a declared one is never blamed: `{"title":"",
1414 * "bogus":1}` was refused for the empty title, not for `bogus`. Only a 422
1515 * without a message is touched, so success paths and a route's own words are
16 * kept. The matcher is built once, when the server loads, as `cursor_lists.ts`
16 * kept. The matcher is built once, on the first such 422, as `cursor_lists.ts`
1717 * builds its own.
1818 */
1919
20 import { readsJsonBody, ROUTES } from "../contract/openapi.ts";
20 import { contract, loadContract } from "./contract_lazy.ts";
2121 import { sentFor } from "./json_body.ts";
2222 import { Router } from "./router.ts";
2323
@@ -104,13 +104,17 @@ export function fieldAmiss(body: Record<string, unknown>, declared: Declared): s
104104 /**
105105 * The contract's write routes that declare a body, fewest parameters first, so a literal path wins.
106106 */
107 const DECLARED_BODIES: Router<Declared> = (() => {
107 let declaredBodies: Router<Declared> | undefined;
108 /** Built on the first 422 a JSON write answers: the contract is not imported before. */
109 function bodiesDeclared(): Router<Declared> {
110 if (declaredBodies !== undefined) return declaredBodies;
111 const { readsJsonBody, ROUTES } = contract();
108112 const matcher = new Router<Declared>();
109113 const params = (p: string) => (p.match(/\{/g) ?? []).length;
110114 for (const r of [...ROUTES].sort((a, b) => params(a.path) - params(b.path)))
111115 if (readsJsonBody(r)) matcher.add(r.method.toUpperCase(), r.path.replace(/\{([^}]+)\}/g, ":$1"), r.body!);
112 return matcher;
113 })();
116 return (declaredBodies = matcher);
117 }
114118
115119 /**
116120 * A 422 the route answered without a message, given one that names the field
@@ -122,7 +126,8 @@ export async function namedRefusal(request: Request, response: Response): Promis
122126 if (response.status !== 422) return response;
123127 const body = sentFor(request);
124128 if (body === undefined || !(response.headers.get("content-type") ?? "").startsWith("application/json")) return response;
125 const declared = DECLARED_BODIES.match(request.method, new URL(request.url).pathname)?.handler;
129 await loadContract();
130 const declared = bodiesDeclared().match(request.method, new URL(request.url).pathname)?.handler;
126131 if (declared === undefined) return response;
127132 const message = fieldAmiss(body, declared);
128133 if (message === undefined) return response;
src/http/server.ts +65 −79
@@ -5,40 +5,10 @@
55 * verdict. Auth is resolved once per request and handed to handlers as data.
66 */
77
8 import { ACCOUNTS_ROUTES, ADMIN_ROUTES, API_PAGES_ROUTES, API_ROUTES, ASKS_ROUTES, BOARDS_ROUTES, CHECKS_RECHECK_ROUTES, CONFIG_ROUTES, CREATE_ROUTES, DESIGN_ROUTES, DISCOVERY_ROUTES, DOCS_ROUTES, EXPLORE_ROUTES, FEED_ROUTES, GIT_HTTP_ROUTES, HOME_ROUTES, INTAKE_ROUTES, LIVE_ROUTES, MIGRATE_ROUTES, OG_CARDS_ROUTES, OPERATIONS_ROUTES, ORIGINS_ROUTES, PACKS_ROUTES, PROTOCOLS_ROUTES, RELEASES_ROUTES, REPO_API_ROUTES, REPO_APP_ROUTES, REPO_BROWSE_ROUTES, REPO_BUILDS_ROUTES, REPO_DISPLAY_ROUTES, REPO_ISSUES_ROUTES, REPO_PLANNING_ROUTES, REPO_PULLS_ROUTES, REPO_SETTINGS_ROUTES, REPO_TELLS_ROUTES, TALK_ROUTES, TEAMS_ROUTES } from "./lazy_lists.ts";
9 import { lazyRoutes } from "./lazy_routes.ts";
810 import { boundedSignal } from "../kernel/fetch_timeout.ts";
9 import { discoveryRoutes } from "./routes/discovery.ts";
10 import { intakeRoutes } from "./routes/intake.ts";
11 import { accountsRoutes } from "./routes/accounts.ts";
12 import { homeRoutes } from "./routes/home.ts";
1311 import { forgesRoutes } from "./routes/forges.ts";
14 import { createRoutes } from "./routes/create.ts";
15 import { repoDisplayRoutes } from "./routes/repo_display.ts";
16 import { asksRoutes } from "./routes/asks.ts";
17 import { talkRoutes } from "./routes/talk.ts";
18 import { boardsRoutes } from "./routes/boards.ts";
19 import { exploreRoutes } from "./routes/explore.ts";
20 import { designRoutes } from "./routes/design.ts";
21 import { packsRoutes } from "./routes/packs.ts";
22 import { docsRoutes } from "./routes/docs.ts";
23 import { repoApiRoutes } from "./routes/repo_api.ts";
24 import { migrateRoutes } from "./routes/migrate.ts";
25 import { releasesRoutes } from "./routes/releases.ts";
26 import { adminRoutes } from "./routes/admin.ts";
27 import { operationsRoutes } from "./routes/operations.ts";
28 import { liveRoutes } from "./routes/live.ts";
29 import { originsRoutes } from "./routes/origins.ts";
30 import { protocolsRoutes } from "./routes/protocols.ts";
31 import { repoIssuesRoutes } from "./routes/repo_issues.ts";
32 import { repoTellsRoutes } from "./routes/repo_tells.ts";
33 import { repoPullsRoutes } from "./routes/repo_pulls.ts";
34 import { repoPlanningRoutes } from "./routes/repo_planning.ts";
35 import { repoAppRoutes } from "./routes/repo_app.ts";
36 import { ogCardsRoutes } from "./routes/og_cards.ts";
37 import { teamsRoutes } from "./routes/teams.ts";
38 import { repoBrowseRoutes } from "./routes/repo_browse.ts";
39 import { repoBuildsRoutes } from "./routes/repo_builds.ts";
40 import { repoSettingsRoutes } from "./routes/repo_settings.ts";
41 import { gitHttpRoutes } from "./routes/git_http.ts";
4212 import { carrySent, InvalidJson } from "./json_body.ts";
4313 import { namedRefusal } from "./named_refusal.ts";
4414 import { answeringFor, ControlInput, controlRefusal, dirtyUrl, parseableRequest } from "./parseable_request.ts";
@@ -80,12 +50,10 @@ import type { App } from "../app.ts";
8050 import { sha256 } from "../kernel/hash.ts";
8151 import { keepReleaseAssets } from "../web/asset.ts";
8252 import { isThemeName } from "../design/themes.ts";
83 import { apiPage } from "../web/pages/api.ts";
84 import { changelogJson } from "../web/pages/changelog.ts";
8553 import { redirect } from "../web/layout.ts";
8654 import { MACHINE_PREFIX, typedMiss } from "./asset_miss.ts";
8755 import { CAME_FROM_ELSEWHERE, forbiddenPage, notFoundPage, SENT_FROM_ELSEWHERE, signInHref } from "../web/chrome.ts";
88 import { apiRoutes } from "./api.ts";
56 import { loadContract, mayBeContractRoute } from "./contract_lazy.ts";
8957 import { pageParamRefused, takeFields, withFields, withLinkNext } from "./cursor_lists.ts";
9058 import { adminGate } from "./admin_gate.ts";
9159 import { movedResponse } from "./moved.ts";
@@ -97,9 +65,6 @@ import { contributeGate } from "./contribute_gate.ts";
9765 import { runGate } from "./run_gate.ts";
9866 import { readGrantGate } from "./read_grant_gate.ts";
9967 import { viaGate } from "./via_gate.ts";
100 import { checksRecheckRoutes } from "./checks_recheck.ts";
101 import { feedRoutes } from "./feed.ts";
102 import { configRoutes } from "./config.ts";
10368 import type { Database } from "bun:sqlite";
10469 import { scheduleWarmUp, WARM, type Family } from "./warmup.ts";
10570 import { resourcePolicy } from "./corp.ts";
@@ -283,39 +248,48 @@ async function resolveAuth(app: App, request: Request): Promise<Auth> {
283248 export function buildRouter(): Router<Handler> {
284249 const router = new Router<Handler>();
285250
286 discoveryRoutes(router);
287 intakeRoutes(router, routeOf);
288 accountsRoutes(router);
289 homeRoutes(router);
251 lazyRoutes(router, "discovery", DISCOVERY_ROUTES, async () => (await import("./routes/discovery.ts")).discoveryRoutes);
252 lazyRoutes(router, "intake", INTAKE_ROUTES, async () => {
253 const { intakeRoutes } = await import("./routes/intake.ts");
254 return (own) => intakeRoutes(own, routeOf);
255 });
256 lazyRoutes(router, "accounts", ACCOUNTS_ROUTES, async () => (await import("./routes/accounts.ts")).accountsRoutes);
257 lazyRoutes(router, "home", HOME_ROUTES, async () => (await import("./routes/home.ts")).homeRoutes);
290258 forgesRoutes(router);
291 createRoutes(router);
292 repoDisplayRoutes(router);
293 asksRoutes(router);
294 talkRoutes(router);
295 boardsRoutes(router);
296 exploreRoutes(router);
297 designRoutes(router);
298 packsRoutes(router);
299 docsRoutes(router);
300 repoApiRoutes(router);
301 migrateRoutes(router);
302 releasesRoutes(router);
303 adminRoutes(router, knownPatterns);
304 operationsRoutes(router, knownPatterns);
305 liveRoutes(router);
306 originsRoutes(router);
307 protocolsRoutes(router);
308 repoIssuesRoutes(router);
309 repoTellsRoutes(router);
310 repoPullsRoutes(router);
311 repoPlanningRoutes(router);
312 repoAppRoutes(router);
313 ogCardsRoutes(router);
314 teamsRoutes(router);
315 repoBrowseRoutes(router);
316 repoBuildsRoutes(router);
317 repoSettingsRoutes(router);
318 gitHttpRoutes(router);
259 lazyRoutes(router, "create", CREATE_ROUTES, async () => (await import("./routes/create.ts")).createRoutes);
260 lazyRoutes(router, "repo-display", REPO_DISPLAY_ROUTES, async () => (await import("./routes/repo_display.ts")).repoDisplayRoutes);
261 lazyRoutes(router, "asks", ASKS_ROUTES, async () => (await import("./routes/asks.ts")).asksRoutes);
262 lazyRoutes(router, "talk", TALK_ROUTES, async () => (await import("./routes/talk.ts")).talkRoutes);
263 lazyRoutes(router, "boards", BOARDS_ROUTES, async () => (await import("./routes/boards.ts")).boardsRoutes);
264 lazyRoutes(router, "explore", EXPLORE_ROUTES, async () => (await import("./routes/explore.ts")).exploreRoutes);
265 lazyRoutes(router, "design", DESIGN_ROUTES, async () => (await import("./routes/design.ts")).designRoutes);
266 lazyRoutes(router, "packs", PACKS_ROUTES, async () => (await import("./routes/packs.ts")).packsRoutes);
267 lazyRoutes(router, "docs", DOCS_ROUTES, async () => (await import("./routes/docs.ts")).docsRoutes);
268 lazyRoutes(router, "repo-api", REPO_API_ROUTES, async () => (await import("./routes/repo_api.ts")).repoApiRoutes);
269 lazyRoutes(router, "migrate", MIGRATE_ROUTES, async () => (await import("./routes/migrate.ts")).migrateRoutes);
270 lazyRoutes(router, "releases", RELEASES_ROUTES, async () => (await import("./routes/releases.ts")).releasesRoutes);
271 lazyRoutes(router, "admin", ADMIN_ROUTES, async () => {
272 const { adminRoutes } = await import("./routes/admin.ts");
273 return (own) => adminRoutes(own, knownPatterns);
274 });
275 lazyRoutes(router, "operations", OPERATIONS_ROUTES, async () => {
276 const { operationsRoutes } = await import("./routes/operations.ts");
277 return (own) => operationsRoutes(own, knownPatterns);
278 });
279 lazyRoutes(router, "live", LIVE_ROUTES, async () => (await import("./routes/live.ts")).liveRoutes);
280 lazyRoutes(router, "origins", ORIGINS_ROUTES, async () => (await import("./routes/origins.ts")).originsRoutes);
281 lazyRoutes(router, "protocols", PROTOCOLS_ROUTES, async () => (await import("./routes/protocols.ts")).protocolsRoutes);
282 lazyRoutes(router, "repo-issues", REPO_ISSUES_ROUTES, async () => (await import("./routes/repo_issues.ts")).repoIssuesRoutes);
283 lazyRoutes(router, "repo-tells", REPO_TELLS_ROUTES, async () => (await import("./routes/repo_tells.ts")).repoTellsRoutes);
284 lazyRoutes(router, "repo-pulls", REPO_PULLS_ROUTES, async () => (await import("./routes/repo_pulls.ts")).repoPullsRoutes);
285 lazyRoutes(router, "repo-planning", REPO_PLANNING_ROUTES, async () => (await import("./routes/repo_planning.ts")).repoPlanningRoutes);
286 lazyRoutes(router, "repo-app", REPO_APP_ROUTES, async () => (await import("./routes/repo_app.ts")).repoAppRoutes);
287 lazyRoutes(router, "og-cards", OG_CARDS_ROUTES, async () => (await import("./routes/og_cards.ts")).ogCardsRoutes);
288 lazyRoutes(router, "teams", TEAMS_ROUTES, async () => (await import("./routes/teams.ts")).teamsRoutes);
289 lazyRoutes(router, "repo-browse", REPO_BROWSE_ROUTES, async () => (await import("./routes/repo_browse.ts")).repoBrowseRoutes);
290 lazyRoutes(router, "repo-builds", REPO_BUILDS_ROUTES, async () => (await import("./routes/repo_builds.ts")).repoBuildsRoutes);
291 lazyRoutes(router, "repo-settings", REPO_SETTINGS_ROUTES, async () => (await import("./routes/repo_settings.ts")).repoSettingsRoutes);
292 lazyRoutes(router, "git-http", GIT_HTTP_ROUTES, async () => (await import("./routes/git_http.ts")).gitHttpRoutes);
319293
320294 return router;
321295 }
@@ -328,16 +302,24 @@ export function buildRouter(): Router<Handler> {
328302 */
329303 export function buildApiRouter(): Router<Handler> {
330304 const router = new Router<Handler>();
331 apiRoutes(router, isPublicPage);
332 feedRoutes(router);
333 configRoutes(router);
334 checksRecheckRoutes(router);
335 // What went live, as /changelog shows it; the page's own module answers.
336 router.add("GET", "/api/v1/changelog", changelogJson);
305 lazyRoutes(router, "api", API_ROUTES, async () => {
306 const { apiRoutes } = await import("./api.ts");
307 return (own) => apiRoutes(own, isPublicPage);
308 });
309 lazyRoutes(router, "feed", FEED_ROUTES, async () => (await import("./feed.ts")).feedRoutes);
310 lazyRoutes(router, "config", CONFIG_ROUTES, async () => (await import("./config.ts")).configRoutes);
311 lazyRoutes(router, "checks-recheck", CHECKS_RECHECK_ROUTES, async () => (await import("./checks_recheck.ts")).checksRecheckRoutes);
337312 router.add("GET", "/api/v1", apiRoot);
338313 router.add("GET", "/api/v1/", apiRoot);
339 // The reference page for these routes lives at their root, so it answers here.
340 router.add("GET", "/api", apiPage);
314 // What went live, as /changelog shows it, and the reference page for these routes at their root:
315 // each page's own module answers, on the first request to it.
316 lazyRoutes(router, "api-pages", API_PAGES_ROUTES, async () => {
317 const [{ changelogJson }, { apiPage }] = await Promise.all([import("../web/pages/changelog.ts"), import("../web/pages/api.ts")]);
318 return (own) => {
319 own.add("GET", "/api/v1/changelog", changelogJson);
320 own.add("GET", "/api", apiPage);
321 };
322 });
341323 return router;
342324 }
343325
@@ -1554,7 +1536,10 @@ async function answerRoute(
15541536 if (viaRefusal !== undefined) return viaRefusal;
15551537
15561538 // Admin settings and releases are an admin's; a member is told so.
1557 const adminRefusal = adminGate(app, request, url, auth, matched.pattern);
1539 // The gate reads the contract and, for an everyday account, a page: both are loaded here, not by
1540 // the boot.
1541 if (mayBeContractRoute(matched.pattern)) await loadContract();
1542 const adminRefusal = await adminGate(app, request, url, auth, matched.pattern);
15581543 if (adminRefusal !== undefined) return adminRefusal;
15591544
15601545 // The short address people guess goes to the one form, which a stranger sees too. Not a page of
@@ -1609,6 +1594,7 @@ async function answerRoute(
16091594
16101595 // A list that pages by cursor says so to `?page=`, one guard for all of them.
16111596 if (isApiPath && routeMethod === "GET") {
1597 await loadContract();
16121598 const byNumber = pageParamRefused(matched.pattern, url.searchParams);
16131599 if (byNumber !== undefined) return withRateHeaders(byNumber, verdict);
16141600 }
src/main.ts +16 −14
@@ -45,7 +45,8 @@ import { applyBootDefaults, stopCellChildren } from "./spawn/cell.ts";
4545 import { backfillChildren } from "./spawn/forge_code_backfill.ts";
4646 import { firstBoot } from "./spawn/first-boot.ts";
4747 import { previewIdentityKey } from "./spawn/preview-owner.ts";
48 import { PREVIEW_ADMIN, seedPreview } from "./spawn/preview-seed.ts";
48 import { PREVIEW_ADMIN } from "./spawn/preview-looks.ts";
49 import { isPreviewEnv } from "./spawn/preview_who.ts";
4950 import { startHeartbeat } from "./spawn/heartbeat.ts";
5051 import { startMachineBeats } from "./spawn/machine_beats.ts";
5152 import { startUpstreamWatch } from "./spawn/upstream.ts";
@@ -59,9 +60,6 @@ import { checkDue } from "./actions/upstream_follow.ts";
5960 import { runSync } from "./origins/sync.ts";
6061 import { runAheadReads } from "./origins/ahead.ts";
6162 import { runGuardSweep } from "./origins/credential.ts";
62 import { warmHome } from "./web/pages/home_flow.ts";
63 import { warmPlans } from "./web/pages/milestones.ts";
64 import { warmBoards } from "./web/pages/boards-view.ts";
6563 import { previewIdleMs } from "./apps/sleep_window.ts";
6664 import { UPSTREAM_WAIT_MS } from "./apps/upstream_wait.ts";
6765 import { listApps } from "./core/apps.ts";
@@ -90,7 +88,6 @@ import { compactOnBoot } from "./system/compact.ts";
9088 import { resumeAtBoot } from "./maintenance/service.ts";
9189 import { failStaleSnapshots } from "./core/snapshots.ts";
9290 import { sweepStaleAsks } from "./crew/stale_asks.ts";
93 import { recordAskLedger } from "./web/studio/asks.ts";
9491 import { configProblem, dataDirOf, preflight } from "./kernel/preflight.ts";
9592 import { running } from "./kernel/version.ts";
9693 import { record as recordDegraded } from "./kernel/degraded_history.ts";
@@ -499,6 +496,9 @@ if (appDomain?.ok === true) holdAppHosts(app, appDomain.domain);
499496 // nobody's wait. Each reads in slices on turns of its own; none of them is needed for the forge to
500497 // be up.
501498 await warmFlow(app);
499 // The page modules these warm are imported here, as they were by the boot's static imports before
500 // (#17020): the server itself imports none of them until a request needs them.
501 const { warmPlans } = await import("./web/pages/milestones.ts");
502502 await warmPlans(app);
503503 await warmDisplays(app).catch(() => undefined);
504504 const servers = await serve(app, { warm: {} });
@@ -511,8 +511,8 @@ markReady();
511511 keepFlowReadings(KEPT_MS);
512512 // The home's picture is read by a worker from here, so the first page finds it
513513 // (web/pages/home_flow.ts).
514 warmHome(app);
515 warmBoards(app);
514 (await import("./web/pages/home_flow.ts")).warmHome(app);
515 (await import("./web/pages/boards-view.ts")).warmBoards(app);
516516 // The pictures the home, `/boards`, `/flow` and the front pages of the forge's own repositories
517517 // draw are
518518 // named here and read again on a timer by their workers, so the first click after a pause is drawn
@@ -841,12 +841,14 @@ await firstBoot(app);
841841 announceSandboxed(app);
842842 // A preview of this forge seeds its admin and a small world to look at
843843 // (spawn/preview-seed.ts); anywhere else this is refused and says nothing.
844 await seedPreview(app)
845 .then((seeded) => {
846 if (seeded.ok && seeded.value.seeded) app.log.info("preview seeded", { admin: PREVIEW_ADMIN });
847 else if (!seeded.ok && seeded.error !== "not_preview") app.log.warn("preview not seeded", { error: seeded.error });
848 })
849 .catch((error) => app.log.warn("preview not seeded", { error: String(error) }));
844 if (isPreviewEnv())
845 await import("./spawn/preview-seed.ts")
846 .then(({ seedPreview }) => seedPreview(app))
847 .then((seeded) => {
848 if (seeded.ok && seeded.value.seeded) app.log.info("preview seeded", { admin: PREVIEW_ADMIN });
849 else if (!seeded.ok && seeded.error !== "not_preview") app.log.warn("preview not seeded", { error: seeded.error });
850 })
851 .catch((error) => app.log.warn("preview not seeded", { error: String(error) }));
850852 // A spawned child reports its standing to its parent (spawn/heartbeat.ts).
851853 const heartbeatTimer = inert ? undefined : startHeartbeat(app);
852854 // Each machine beats its load; one that stops is named (spawn/machine_load.ts, #16860).
@@ -944,7 +946,7 @@ const tickAsks = async (): Promise<void> => {
944946 // duties when it has a thread (`engine/duties.ts`).
945947 if (!engineOn) {
946948 try {
947 recordAskLedger(app.db);
949 (await import("./web/studio/asks.ts")).recordAskLedger(app.db);
948950 } catch (error) {
949951 app.log.error("asks ledger failed", { error: String(error) });
950952 }
src/spawn/preview-owner.ts +1 −1
@@ -16,7 +16,7 @@ import { createHmac, timingSafeEqual } from "node:crypto";
1616 import type { App } from "../app.ts";
1717 import type { User } from "../core/users.ts";
1818 import { PREVIEW_EVERYDAY, PREVIEW_NEWCOMER } from "./preview-looks.ts";
19 import { isPreviewEnv, previewAdmin, previewEveryday, previewNewcomer } from "./preview-seed.ts";
19 import { isPreviewEnv, previewAdmin, previewEveryday, previewNewcomer } from "./preview_who.ts";
2020
2121 type Env = Record<string, string | undefined>;
2222
src/spawn/preview-seed.ts +4 −25
@@ -44,6 +44,7 @@ import { repoDir } from "../git/repos.ts";
4444 import { commitToBranch, createRepo, forkRepo, updateRepoSettings } from "../actions/repos.ts";
4545 import { reviewGate } from "../actions/gate_review.ts";
4646 import { forgeHttp } from "../http/server.ts";
47 import { isPreviewEnv } from "./preview_who.ts";
4748 import { transferRepository } from "../actions/transfer.ts";
4849 import { linkIssue } from "../actions/dependencies.ts";
4950 import { lastChanges } from "../settings/last_change.ts";
@@ -65,7 +66,7 @@ import { createToken, listTokens } from "../core/tokens.ts";
6566 import { enrolRunner, listRunners } from "../checks/runner_jobs.ts";
6667 import { recordUsage } from "../core/usage.ts";
6768 import { PREVIEW_SEEDED, getUserSetting, setUserSetting } from "../core/settings.ts";
68 import { adminOf, linkEveryday } from "../core/everyday.ts";
69 import { linkEveryday } from "../core/everyday.ts";
6970 import { createUser, getUserByName, type User } from "../core/users.ts";
7071 import { diskSummary, recordReading } from "../machines/disk_readings.ts";
7172 import { err, ok, type Result } from "../kernel/result.ts";
@@ -106,6 +107,8 @@ import {
106107 PREVIEW_TEMPLATE_PAGE,
107108 } from "./preview-looks.ts";
108109
110 export { isPreviewEnv, previewAdmin, previewEveryday, previewNewcomer } from "./preview_who.ts";
111
109112 export {
110113 PREVIEW_ADMIN,
111114 PREVIEW_APP,
@@ -316,30 +319,6 @@ const SETTINGS_SEEDED = "preview_settings_seeded";
316319
317320 type Env = Record<string, string | undefined>;
318321
319 /** Whether the platform says this forge is a preview. Anything else is not. */
320 export function isPreviewEnv(env: Env = process.env): boolean {
321 return (env.FORGE_APP_ENV ?? "").trim().toLowerCase() === "preview";
322 }
323
324 /** The preview admin, when this forge has one. */
325 export function previewAdmin(app: App): User | undefined {
326 const user = getUserByName(app.db, PREVIEW_ADMIN);
327 return user?.isAdmin === true && user.kind !== "agent" ? user : undefined;
328 }
329
330 /** The newcomer, when this forge has one. */
331 export function previewNewcomer(app: App): User | undefined {
332 const user = getUserByName(app.db, PREVIEW_NEWCOMER);
333 return user?.isAdmin === true && user.kind === "user" ? user : undefined;
334 }
335
336 /** The everyday account the preview pictures at an admin-only door, when this forge has one. */
337 export function previewEveryday(app: App): User | undefined {
338 const user = getUserByName(app.db, PREVIEW_EVERYDAY);
339 if (user === undefined || user.isAdmin || user.kind !== "user") return undefined;
340 return adminOf(app.db, user)?.username === PREVIEW_EVERYDAY_ADMIN ? user : undefined;
341 }
342
343322 /**
344323 * An admin of its own and that admin's everyday account (#13597), so the
345324 * looks picture the refusal an everyday account meets at an admin-only page.
src/spawn/preview_who.ts added +36
@@ -0,0 +1,36 @@
1 /**
2 * Who a preview is, and whether this forge is one: the environment word and the seeded accounts,
3 * read by the server on every request (`spawn/preview-owner.ts`). The world the seed builds is
4 * `preview-seed.ts`, which the boot imports only in a preview.
5 */
6
7 import type { App } from "../app.ts";
8 import { adminOf } from "../core/everyday.ts";
9 import { getUserByName, type User } from "../core/users.ts";
10 import { PREVIEW_ADMIN, PREVIEW_EVERYDAY, PREVIEW_EVERYDAY_ADMIN, PREVIEW_NEWCOMER } from "./preview-looks.ts";
11
12 type Env = Record<string, string | undefined>;
13
14 /** Whether the platform says this forge is a preview. Anything else is not. */
15 export function isPreviewEnv(env: Env = process.env): boolean {
16 return (env.FORGE_APP_ENV ?? "").trim().toLowerCase() === "preview";
17 }
18
19 /** The preview admin, when this forge has one. */
20 export function previewAdmin(app: App): User | undefined {
21 const user = getUserByName(app.db, PREVIEW_ADMIN);
22 return user?.isAdmin === true && user.kind !== "agent" ? user : undefined;
23 }
24
25 /** The newcomer, when this forge has one. */
26 export function previewNewcomer(app: App): User | undefined {
27 const user = getUserByName(app.db, PREVIEW_NEWCOMER);
28 return user?.isAdmin === true && user.kind === "user" ? user : undefined;
29 }
30
31 /** The everyday account the preview pictures at an admin-only door, when this forge has one. */
32 export function previewEveryday(app: App): User | undefined {
33 const user = getUserByName(app.db, PREVIEW_EVERYDAY);
34 if (user === undefined || user.isAdmin || user.kind !== "user") return undefined;
35 return adminOf(app.db, user)?.username === PREVIEW_EVERYDAY_ADMIN ? user : undefined;
36 }
src/web/origin_icon.ts added +12
@@ -0,0 +1,12 @@
1 import type { IconName } from "./icons.ts";
2
3 /**
4 * The mark a forge wears wherever it is named. Another forge speaks Gitea's
5 * API, so its kind alone would draw the cup; `software` says it is a forge.
6 */
7 export function originIcon(origin: {
8 readonly kind: "github" | "forgejo" | "gitea";
9 readonly software?: string;
10 }): IconName {
11 return origin.software === "forge" ? "anvil" : origin.kind;
12 }
src/web/pages/browse.ts +2 −1
@@ -91,7 +91,8 @@ import {
9191 finderDialog,
9292 loadExplorer,
9393 } from "./explorer.ts";
94 import { accountOnly, hostLabel, originIcon } from "./origins.ts";
94 import { accountOnly, hostLabel } from "./origins.ts";
95 import { originIcon } from "../origin_icon.ts";
9596 import { refSetFrom } from "./refs.ts";
9697 import { kindByName, needsPaths } from "../render/kinds.ts";
9798 import { stageRow, stageStateFor } from "../stage-row.ts";
src/web/pages/origin-repos.ts +1 −1
@@ -37,9 +37,9 @@ import {
3737 accountOnly,
3838 hostLabel,
3939 notFoundNote,
40 originIcon,
4140 shell,
4241 } from "./origins.ts";
42 import { originIcon } from "../origin_icon.ts";
4343
4444 // GET /settings/origins/:id/repos
4545 export async function originReposPage(ctx: Ctx): Promise<Response> {
src/web/pages/origins.ts +1 −11
@@ -17,6 +17,7 @@
1717 * where it was — that page and its poll live in `origin-flow.ts`.
1818 */
1919
20 import { originIcon } from "../origin_icon.ts";
2021 import { sshOn } from "../../settings/ssh.ts";
2122 import type { Database } from "bun:sqlite";
2223 import { upstreamBlob } from "../../core/upstream.ts";
@@ -208,17 +209,6 @@ export function accountSections(
208209 );
209210 }
210211
211 /**
212 * The mark a forge wears wherever it is named. Another forge speaks Gitea's
213 * API, so its kind alone would draw the cup; `software` says it is a forge.
214 */
215 export function originIcon(origin: {
216 readonly kind: "github" | "forgejo" | "gitea";
217 readonly software?: string;
218 }): IconName {
219 return origin.software === "forge" ? "anvil" : origin.kind;
220 }
221
222212 /** `codeberg.org` from `https://codeberg.org` — what a person calls a forge. */
223213 export function hostLabel(url: string): string {
224214 return URL.parse(url)?.host ?? url;
src/web/pages/search.ts +1 −1
@@ -49,7 +49,7 @@ import { DELETE_REPO, STOP_APP, dangerDetail } from "../danger_words.ts";
4949 import { icon } from "../icons.ts";
5050 import { page } from "../layout.ts";
5151 import { browseBase } from "../scope.ts";
52 import { originIcon } from "./origins.ts";
52 import { originIcon } from "../origin_icon.ts";
5353 import { appsOf } from "../studio/asks.ts";
5454 import { changeHref, tellHref } from "../studio/nouns.ts";
5555 import {
src/web/pages/thread.ts +1 −1
@@ -27,7 +27,7 @@ import {
2727 import { dependenciesOf } from "../../core/dependencies.ts";
2828 import { blockerByTitle, cyclePath, standingOf } from "../../core/dep_standing.ts";
2929 import { chain } from "./dep_chain.ts";
30 import { originIcon } from "./origins.ts";
30 import { originIcon } from "../origin_icon.ts";
3131 import { isCrew } from "../../core/agents.ts";
3232 import {
3333 assignIssue,
src/web/scope.ts +1 −1
@@ -44,7 +44,7 @@ import { html, when, type Html } from "./html.ts";
4444 import { repoSteps } from "./repo_steps.ts";
4545 import { icon, type IconName } from "./icons.ts";
4646 import type { PaletteItem } from "./layout.ts";
47 import { originIcon } from "./pages/origins.ts";
47 import { originIcon } from "./origin_icon.ts";
4848 import { popout, time, timeAgo } from "./ui.ts";
4949
5050 /** Which side of the world a page is reading. */
src/web/standards.ts +5 −3
@@ -64,7 +64,6 @@ import { threeDoors } from "./doors_words.ts";
6464 import { OAUTH_SCOPES } from "../core/oauth.ts";
6565 import { SERVER_CARD_PATH, wellKnownServerCard, agentCard, serverCard, toolsKey, apiCatalog, cardsLine, DISCOVERY, mcpCard, mcpDoor, offeredPlugins, mcpPointers, toolCount, offeredPluginRepo, pluginSource } from "../core/mcp_card.ts";
6666 import { forgeDocument } from "../core/standards_index.ts";
67 import { TAGS } from "../contract/served.ts";
6867 import { announcedVersion, running, shortOf, UNSTAMPED } from "../kernel/version.ts";
6968 import { GUIDE } from "../view/guide.ts";
7069 import { loadMcp } from "../http/mcp/load.ts";
@@ -534,6 +533,7 @@ const llmsBodies = new Map<string, { repos: LlmsListing; running: string; tell:
534533 */
535534 export async function llmsTxt(ctx: Ctx): Promise<Response> {
536535 await loadMcp();
536 servedTags = (await import("../contract/served.ts")).TAGS;
537537 const kept = llmsBody(ctx);
538538 // The third line names the running commit: a client revalidates (one small 304)
539539 // rather than keep an old build for an hour.
@@ -580,7 +580,9 @@ export function llmsBody(ctx: Ctx): { body: string; etag: string } {
580580 return kept;
581581 }
582582
583 /** The llms.txt document for one origin. */
583 /** The contract's tags, read when llms.txt is drawn: the contract is not imported before. */
584 let servedTags: readonly string[] = [];
585
584586 /** One llms.txt line per plugin on offer; a cloned one names its source, a served one says so. */
585587 function pluginLines(o: string, plugins: string | undefined): string[] {
586588 const lines = offeredPlugins(plugins).map((p) => {
@@ -673,7 +675,7 @@ function renderLlmsTxt(ctx: Ctx, o: string, tell: string | undefined, running: s
673675 `- API: ${o}${DISCOVERY.api} (the root lists the other URLs), Authorization: Bearer <token>`,
674676 `- API catalog (RFC 9727, one linkset of the above): ${o}${DISCOVERY.catalog}`,
675677 ]),
676 `- OpenAPI: GET ${o}${DISCOVERY.openapi}, or one slice with ?tag= (${TAGS.join(", ")})`,
678 `- OpenAPI: GET ${o}${DISCOVERY.openapi}, or one slice with ?tag= (${servedTags.join(", ")})`,
677679 "",
678680 ...mcpToolsSection(o, reader, sshOn(ctx.app.db)),
679681 cardsLine(),
test/admin-gate.test.ts +14 −10
@@ -13,6 +13,7 @@ import { SIGN_IN_AS_ADMIN, setMember } from "../src/core/roles.ts";
1313 import { createSession } from "../src/core/sessions.ts";
1414 import { createToken } from "../src/core/tokens.ts";
1515 import { createUser, type User } from "../src/core/users.ts";
16 import { loadContract } from "../src/http/contract_lazy.ts";
1617 import { adminGate, isAdminPath } from "../src/http/admin_gate.ts";
1718 import { serve, type Servers } from "../src/http/server.ts";
1819 import { quietLogs } from "./helpers/globals.ts";
@@ -103,21 +104,24 @@ describe("the admin gate", () => {
103104
104105 test("adminGate refuses a person without administer and lets everyone else carry on", async () => {
105106 const auth = (user: User | undefined) => ({ user, scope: undefined, via: "none" as const });
106 const ask = (path: string, user: User | undefined) =>
107 adminGate(app, new Request(`http://x${path}`), new URL(`http://x${path}`), auth(user));
108 expect(ask("/api/v1/admin/capacity", carol)?.status).toBe(403);
109 expect(ask("/releases", dave)?.status).toBe(403);
110 expect(ask("/api/v1/admin/capacity", alice)).toBeUndefined();
111 expect(ask("/api/v1/admin/capacity", undefined)).toBeUndefined();
112 expect(ask("/administer", carol)).toBeUndefined();
113 expect(ask("/releases.json", dave)).toBeUndefined();
107 const ask = async (path: string, user: User | undefined) => {
108 await loadContract();
109 return adminGate(app, new Request(`http://x${path}`), new URL(`http://x${path}`), auth(user));
110 };
111 expect((await ask("/api/v1/admin/capacity", carol))?.status).toBe(403);
112 expect((await ask("/releases", dave))?.status).toBe(403);
113 expect(await ask("/api/v1/admin/capacity", alice)).toBeUndefined();
114 expect(await ask("/api/v1/admin/capacity", undefined)).toBeUndefined();
115 expect(await ask("/administer", carol)).toBeUndefined();
116 expect(await ask("/releases.json", dave)).toBeUndefined();
114117 });
115118
116 test("a HEAD of a contract-admin route is refused as its GET is (#14778)", () => {
119 test("a HEAD of a contract-admin route is refused as its GET is (#14778)", async () => {
117120 const auth = { user: carol, scope: undefined, via: "none" as const };
118121 const path = "/api/v1/telemetry/routes";
119122 for (const method of ["GET", "HEAD"]) {
120 const res = adminGate(app, new Request(`http://x${path}`, { method }), new URL(`http://x${path}`), auth, path);
123 await loadContract();
124 const res = await adminGate(app, new Request(`http://x${path}`, { method }), new URL(`http://x${path}`), auth, path);
121125 expect([method, res?.status]).toEqual([method, 403]);
122126 }
123127 });
test/boot-lazy.test.ts +90
@@ -76,3 +76,93 @@ describe("lazyRoutes", () => {
7676 expect(loads).toBe(2);
7777 });
7878 });
79
80 // #17020: the page families behind server.ts (pages, studio, render, `/api/v1`) load on the first
81 // request to their prefix. Each route list in `lazy_lists.ts` is its module's own, and the boot's
82 // static imports reach none of the modules.
83 const none = () => [];
84 const FAMILIES: readonly {
85 list: string;
86 file: string;
87 add: (mod: Record<string, unknown>, r: Router<Handler>) => void;
88 }[] = [
89 ["ACCOUNTS", "routes/accounts.ts", "accountsRoutes"],
90 ["ADMIN", "routes/admin.ts", "adminRoutes", none],
91 ["ASKS", "routes/asks.ts", "asksRoutes"],
92 ["BOARDS", "routes/boards.ts", "boardsRoutes"],
93 ["CREATE", "routes/create.ts", "createRoutes"],
94 ["DESIGN", "routes/design.ts", "designRoutes"],
95 ["DISCOVERY", "routes/discovery.ts", "discoveryRoutes"],
96 ["DOCS", "routes/docs.ts", "docsRoutes"],
97 ["EXPLORE", "routes/explore.ts", "exploreRoutes"],
98 ["GIT_HTTP", "routes/git_http.ts", "gitHttpRoutes"],
99 ["HOME", "routes/home.ts", "homeRoutes"],
100 ["INTAKE", "routes/intake.ts", "intakeRoutes", (): undefined => undefined],
101 ["LIVE", "routes/live.ts", "liveRoutes"],
102 ["MIGRATE", "routes/migrate.ts", "migrateRoutes"],
103 ["OG_CARDS", "routes/og_cards.ts", "ogCardsRoutes"],
104 ["OPERATIONS", "routes/operations.ts", "operationsRoutes", none],
105 ["ORIGINS", "routes/origins.ts", "originsRoutes"],
106 ["PACKS", "routes/packs.ts", "packsRoutes"],
107 ["PROTOCOLS", "routes/protocols.ts", "protocolsRoutes"],
108 ["RELEASES", "routes/releases.ts", "releasesRoutes"],
109 ["REPO_API", "routes/repo_api.ts", "repoApiRoutes"],
110 ["REPO_APP", "routes/repo_app.ts", "repoAppRoutes"],
111 ["REPO_BROWSE", "routes/repo_browse.ts", "repoBrowseRoutes"],
112 ["REPO_BUILDS", "routes/repo_builds.ts", "repoBuildsRoutes"],
113 ["REPO_DISPLAY", "routes/repo_display.ts", "repoDisplayRoutes"],
114 ["REPO_ISSUES", "routes/repo_issues.ts", "repoIssuesRoutes"],
115 ["REPO_PLANNING", "routes/repo_planning.ts", "repoPlanningRoutes"],
116 ["REPO_PULLS", "routes/repo_pulls.ts", "repoPullsRoutes"],
117 ["REPO_SETTINGS", "routes/repo_settings.ts", "repoSettingsRoutes"],
118 ["REPO_TELLS", "routes/repo_tells.ts", "repoTellsRoutes"],
119 ["TALK", "routes/talk.ts", "talkRoutes"],
120 ["TEAMS", "routes/teams.ts", "teamsRoutes"],
121 ["API", "api.ts", "apiRoutes", () => false],
122 ["CHECKS_RECHECK", "checks_recheck.ts", "checksRecheckRoutes"],
123 ["CONFIG", "config.ts", "configRoutes"],
124 ["FEED", "feed.ts", "feedRoutes"],
125 ].map(([list, file, fn, arg]) => ({
126 list: list as string,
127 file: file as string,
128 add: (mod, r) => (mod[fn as string] as (r: Router<Handler>, arg?: unknown) => void)(r, arg),
129 }));
130
131 test("each page family's route list is the routes its module adds, in its order", async () => {
132 const lists = (await import("../src/http/lazy_lists.ts")) as unknown as Record<string, readonly (readonly [string, string])[]>;
133 for (const family of FAMILIES) {
134 const own = new Router<Handler>();
135 family.add(await import(`../src/http/${family.file}`), own);
136 const listed = lists[`${family.list}_ROUTES`];
137 expect(listed, family.list).toBeDefined();
138 expect(listed!.map(([method, pattern]) => ({ method, pattern })), family.list).toEqual(own.routes());
139 }
140 const api = new Router<Handler>();
141 api.add("GET", "/api/v1/changelog", () => new Response()).add("GET", "/api", () => new Response());
142 expect(lists.API_PAGES_ROUTES!.map(([method, pattern]) => ({ method, pattern }))).toEqual(api.routes());
143 });
144
145 test("the boot's static imports do not reach a page family's module", () => {
146 const closure = staticClosure(resolve("src/main.ts"));
147 for (const family of FAMILIES) expect(closure.has(resolve("src/http", family.file)), family.file).toBe(false);
148 });
149
150 // The static module count of the boot (`bun build --metafile` counts the same files, and more when
151 // a dynamic import is bundled in): 4061 before #17020, 2320 after. The ceiling has a little room;
152 // lower it when it drops, and a new static import of a page, a studio or a render module from the
153 // boot fails here.
154 const BOOT_MODULES_CEILING = 2400;
155
156 test("the boot's static module count stays under its ceiling", () => {
157 const count = staticClosure(resolve("src/main.ts")).size;
158 expect(count, `${count} modules`).toBeLessThanOrEqual(BOOT_MODULES_CEILING);
159 });
160
161 // The admin gate reads the contract only for a route under /api/ or one listed in the gate; a
162 // contract admin route outside both would answer an everyday account.
163 test("every contract admin route is under /api/ or listed in the admin gate", async () => {
164 const { ROUTES } = await import("../src/contract/openapi.ts");
165 const { CONTRACT_ADMIN_OUTSIDE_API } = await import("../src/http/contract_lazy.ts");
166 const outside = ROUTES.filter((r) => r.role === "admin" && !r.path.startsWith("/api/")).map((r) => r.path);
167 expect([...outside].sort()).toEqual([...CONTRACT_ADMIN_OUTSIDE_API].sort());
168 });
test/design-audit.test.ts +1 −1
@@ -21,7 +21,7 @@ const NOT_PAGES =
2121 /^\/(design\/theme\.css|design\/theme\/|assets\/|\.well-known\/|icons\/|og\/|live\/|__forge\/|go\/|new\/issue$|asked$|events$|boards\/stream$|system\/stream$|talk\/stream$|peek$|settings\/teams\/stream$|sw\.js$|offline$|robots\.txt$|favicon\.ico$|apple-touch-icon(-precomposed)?\.png$|sitemap\.xml$|edition$|oembed$|manifest\.webmanifest$|opensearch\.xml$|llms(-full)?\.txt$|openapi\.json$|releases\.json$|templates\.json$|maintenance\.json$|changelog\.atom$|explore\.(atom|json)$|feed\.json$|docs(\/[^/]*)?$|audit\.csv$|settings\/traffic\/scrapes\/export$|settings\/payments\.csv$|fleet\/graph\/live$|fleet\/graph\.csv$|forges\/export\.csv$|settings\/origins\/callback$|broker\/origins\/start$|home\/archived\/|settings\/backups\/live$|api\/v1(\/|$))/;
2222
2323 const getRoutes = [
24 ...server.matchAll(/router\.add\(\s*"GET",\s*"([^"]+)"/g),
24 ...server.matchAll(/(?:router|own)\.add\(\s*"GET",\s*"([^"]+)"/g),
2525 ].map((m) => m[1]!);
2626
2727 const pages = [
test/helpers/registered_routes.ts +3 −3
@@ -8,7 +8,7 @@ const files = () =>
88 [...readdirSync(new URL("../../src/http/", import.meta.url)), ...readdirSync(new URL("../../src/http/api/", import.meta.url)).map((f) => `api/${f}`)]
99 .filter((f) => f.endsWith(".ts"))
1010 .map((f) => ({ f, src: readFileSync(new URL(`../../src/http/${f}`, import.meta.url), "utf8") }))
11 .filter(({ src }) => src.includes("router.add("));
11 .filter(({ src }) => /\b(?:router|own)\.add\(/.test(src));
1212
1313 /**
1414 * The /api/v1 routes registered, as "METHOD /api/v1/…" with params as `{}`.
@@ -29,7 +29,7 @@ export const registered = (): string[] => {
2929 }
3030 const resolve = (p: string) => p.replace(/\$\{([A-Z_]+)\}/g, (_, n) => consts.get(n) ?? `\${${n}}`);
3131 let read = 0;
32 for (const m of src.matchAll(/router\.add\(\s*(?:"([A-Z]+)"|(method)),\s*(?:"([^"]*)"|`([^`]*)`|([A-Z_]+)\b)/g)) {
32 for (const m of src.matchAll(/\b(?:router|own)\.add\(\s*(?:"([A-Z]+)"|(method)),\s*(?:"([^"]*)"|`([^`]*)`|([A-Z_]+)\b)/g)) {
3333 read++;
3434 const path = resolve(m[3] ?? m[4] ?? consts.get(m[5]!) ?? "");
3535 if (!path.startsWith("/api/v1")) {
@@ -40,7 +40,7 @@ export const registered = (): string[] => {
4040 for (const method of m[1] ? [m[1]] : ["PUT", "DELETE"]) // `method` is the PUT/DELETE loop
4141 for (const v of path.includes("${kind}") ? ["issues", "pulls"] : [""]) found.add(`${method} ${norm(path.replace("${kind}", v))}`);
4242 }
43 const calls = src.split("router.add(").length - 1;
43 const calls = src.match(/\b(?:router|own)\.add\(/g)?.length ?? 0;
4444 if (read !== calls) throw new Error(`${f}: ${calls} router.add calls but only ${read} readable`);
4545 }
4646 return [...found].sort();
test/helpers/route-modules.ts +2 −2
@@ -5,8 +5,8 @@
55 */
66 import { readFileSync } from "node:fs";
77
8 /** Paths like `src/http/routes/talk.ts`, from server.ts's `./routes/…` imports. */
8 /** Paths like `src/http/routes/talk.ts`, from server.ts's `./routes/…` imports, static or lazy. */
99 export function routeModules(root = new URL("../../", import.meta.url).pathname): string[] {
1010 const server = readFileSync(`${root}src/http/server.ts`, "utf8");
11 return [...server.matchAll(/from "\.\/routes\/([a-z_]+\.ts)"/g)].map((m) => `src/http/routes/${m[1]}`);
11 return [...server.matchAll(/(?:from|import\() ?"\.\/routes\/([a-z_]+\.ts)"/g)].map((m) => `src/http/routes/${m[1]}`);
1212 }

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs