Files

63 lines
5.0 KiB
JavaScript
Raw Permalink Normal View History

// web/shapes.mjs -- the SPA's wire shapes: the REST responses the
// views consume. No runtime code: like server/shapes.mjs, this module
// exists so the tsc checker (JSDoc mode, no emit) and the humans
// reading the code agree on the load-bearing shapes. The server's own
// shared shapes (User, LogEvent, JobState, RunMeta) are imported from
// ../server/shapes.mjs at their use sites -- the API response
// envelopes live here because main.mjs's handlers build them as
// untyped literals; the smoke owns their behavioral truth.
export {};
/** One run card as GET /runs serves it (the clerk's listing,
* enriched by the server with the live-session state). fill is
* present exactly when the run is initialized. models is run.json
* verbatim: the spec picks. */
/** @typedef {{ id: string, package: string, models: ?{ player?: ?{ provider: string, model: string, effort: string }, housekeeper?: ?{ provider: string, model: string, effort: string } }, owner: ?string, ownerName: ?string, created: ?string, forked: ?number, pc: ?string, display: string, sessions: number, phase: ?string, ready: ?boolean, initialized: boolean, fill?: { a: number, b: number, cold: number }, open: boolean, session: ?number, pendingAsk: ?string }} RunCard */
/** One role's spec health: the resolved spec (null when unset or
* unresolvable), whether it is playable, and the note when it is
* not -- the invalidation surface the table and the model box
* render. An unset housekeeper that inherits is ok with
* inherited: true. */
/** @typedef {{ spec: ?{ provider: string, model: string, effort: string }, ok: boolean, note: ?string, inherited: boolean }} RoleHealth */
/** GET /runs/:id -- the run detail: identity, the phase bookkeeping,
* her two blocks, the fill, the context meter's numbers. models is
* run.json verbatim (the spec picks); modelState is the resolved
* truth. */
/** @typedef {{ run: { id: string, package: ?string, created: ?string, forked: ?number, owner: ?string, ownerName: ?string, models: { player?: ?{ provider: string, model: string, effort: string }, housekeeper?: ?{ provider: string, model: string, effort: string } }, modelState: { player: RoleHealth, housekeeper: RoleHealth }, providerDefaults: { slug: string, default: ?{ model: string, effort: string } }[] }, display: string, open: boolean, phase: ?string, session: ?number, sessions: number, draft: boolean, ready: ?boolean, status: string[], agenda: string[], sheet: ?Record<string, unknown>, records: number, fill: Record<string, number>, events: number, pendingAsk: ?string, usage: ?{ promptTokens: number, completionTokens: number }, context: ?{ used: number, contwin: ?number, pct: ?number } }} RunDetail */
/** One provider's /api/models payload: its registry section (phase
* 'none' when never discovered), the op's default spec, the
* curator's recommendation, and the refine job state. */
/** @typedef {{ slug: string, phase: 'none'|'preliminary'|'refined', discovered: ?string, refined: ?string, curator: ?string, recommendation: ?{ model: string, effort: string }, default: ?{ model: string, effort: string }, models: import('../server/shapes.mjs').RegistryModel[], job: ?import('../server/shapes.mjs').JobState, probe: ?{ outcome: 'ok' | 'auth' | 'error', detail: string, at: string }, hasKey: boolean }} ProviderPayload */
2026-11-16 21:32:02 +00:00
/** GET /api/models -- the per-provider registry: one payload per
* configured provider, the truth of what is selectable. */
/** @typedef {{ providers: ProviderPayload[] }} ModelsRegistryResponse */
/** GET /runs/:id/table -- the live session's projection (thinking
* never crosses the wire, variant turns carry only the picked one). */
/** @typedef {{ run: string, session: number, entries: import('../server/shapes.mjs').LogEvent[], pendingAsk: ?string }} TableResponse */
/** GET /runs/:id/carryover -- the dormant session's opening material,
* projected like the table; ends decides the opening flow. */
/** @typedef {{ run: string, session: number, ready: boolean, entries: import('../server/shapes.mjs').LogEvent[], ends: ?('gm'|'player') }} CarryoverResponse */
/** GET /runs/:id/story -- the whole deliverable, read-only: every
* non-dropped literature turn, across all sessions in order. */
2026-11-15 22:37:06 +00:00
/** @typedef {{ run: string, display: string, owner: ?string, ownerName: ?string, sessions: { session: number, turns: { who: string, text: string }[] }[] }} StoryResponse */
/** GET /api/runs/:id/files -- the editor surface: a fixed whitelist,
* each file with its phase-truth mode. */
/** @typedef {{ session: number, phase: ?string, files: Record<string, { mode: string, exists: boolean, content?: string }> }} FilesResponse */
/** GET /api/prompts -- the repo-fed prompts, read-only context. */
/** @typedef {{ system: ?string, invariants: ?string, reminder: ?string }} PromptsResponse */
/** GET /api/runs/:id/notes -- the GM's notepad. */
/** @typedef {{ content: string }} NotesResponse */
/** GET /api/runs/:id/housekeeping/log -- the latest apply log. */
/** @typedef {{ content: string }} HousekeepingLogResponse */