Files
tiny-worlds/web/shapes.mjs
T

44 lines
3.3 KiB
JavaScript

// 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. */
/** @typedef {{ id: string, package: string, models: ?{ player?: ?string, housekeeper?: ?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 */
/** GET /runs/:id -- the run detail: identity, the phase bookkeeping,
* her two blocks, the fill, the context meter's numbers. */
/** @typedef {{ run: { id: string, package: ?string, created: ?string, forked: ?number, owner: ?string, ownerName: ?string, models: { player?: ?string, housekeeper?: ?string }, modelDefaults: { player?: ?string, housekeeper?: ?string } }, display: string, open: boolean, phase: ?string, session: ?number, sessions: number, draft: boolean, ready: ?boolean, status: string[], agenda: string[], records: number, fill: Record<string, number>, events: number, pendingAsk: ?string, usage: ?{ promptTokens: number, completionTokens: number }, context: ?{ used: number, contwin: ?boolean, pct: ?number } }} RunDetail */
/** 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. */
/** @typedef {{ run: 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 */