diff --git a/console/index.html b/console/index.html new file mode 100644 index 0000000..a4361ca --- /dev/null +++ b/console/index.html @@ -0,0 +1,16 @@ + + + + + + Operator console + + + + + + +
+ + diff --git a/console/src/api.ts b/console/src/api.ts new file mode 100644 index 0000000..477469c --- /dev/null +++ b/console/src/api.ts @@ -0,0 +1,414 @@ +/** + * The console's typed data client (W1-1). Types and fetch functions for the route + * contract in docs/plans/console-phase-1.md: the three read routes and Stop. + * + * Two feeds serve these routes (ADR-012): the orchestrator, and a local host's + * snapshot feed of static files. So: + * + * - Every URL is relative to the page (`api/waiting`, never `/api/waiting`), so + * one build works at `/` and under a source's path such as `//`. + * - The body is parsed as JSON whatever its Content-Type says: the snapshot feed + * is served as text/plain. The shape is what's checked, never the header. + * - A response that doesn't match the contract throws an ApiError. The client + * never returns partial data. + */ + +// ---- The route contract ---------------------------------------------------- + +export type Operator = { email: string; login: string }; +/** On every response (ADR-013): which source and host it describes. */ +export type Origin = { source: string | null; host: string | null }; + +export type WaitingKind = "blocked" | "approval" | "failed"; + +export type WaitingItem = { + source?: string; // combined feed only (ADR-013) + kind: WaitingKind; + repo: string; + since: string; + issue: { number: number; title: string; url: string; area: string | null }; + question: string | null; // blocked: the handoff note's Question line, as plain text + replyUrl: string | null; // blocked: the handoff note comment + pr: { + number: number; + title: string; + url: string; + tierLine: string | null; + tierFiles: string[]; + checksPassed: number; + checksTotal: number; + } | null; + failedCheck: { name: string; url: string } | null; // failed + profile: string | null; // failed + runs: number | null; // failed + costUsd: number | null; // failed +}; + +/** GET api/waiting */ +export type Waiting = Origin & { generatedAt: string; operator: Operator; items: WaitingItem[] }; + +export type RunState = "queued" | "waiting" | "running" | "blocked" | "in review" | "merged" | "failed" | "stopped"; +export type StopStepName = "requested" | "token_revoked" | "sandbox_torn_down"; + +export type Run = { + source?: string; // combined feed only (ADR-013) + id: string; + repo: string; + issue: { + number: number; + title: string; + url: string; + area: string | null; + milestone: string | null; + expectedTier: 1 | 2 | 3 | null; + holdsLock: boolean | null; + blocks: number[]; + }; + state: RunState; + startedAt: string; + endedAt: string | null; + profile: string; + model: string; + escalated: boolean; + costUsd: number | null; + budgetUsedPct: number | null; + prUrl: string | null; + logUrl: string | null; + stoppedBy: string | null; + stoppedAt: string | null; + stopSteps: Array<{ step: StopStepName; at: string }>; +}; + +/** GET api/runs?since=