/** * run-state-contract.ts — locked read-only shape for the desktop * client (spec §7A.3 / §10 RL-9). * * The desktop client observes an in-flight bee through a single * JSON file. This module locks the shape so the desktop can render * progress without holding a lock on the asset: * * { * bee_id: string, * status: "running" | "paused" | "done" | "failed" | "blocked", * current_step: string, * started_at: ISO8601 string, * updated_at: ISO8601 string, * last_evaluator_verdict: string | null, * last_user_choice: string | null * } * * Hard rules (spec §7A.3): * - The contract is read-only for the desktop client. Only the * running bee (and peaks CLI) may write it. * - The shape is locked — adding a field is a schema-version * bump; removing or renaming a field is a breaking change. * * This module exposes: * - A Zod schema (`RunStateContractSchema`) that validates the * shape with strict rules (no extra keys, exact enum for * status). * - A type alias (`RunStateContract`). * - A constructor-like factory (for testing / fixtures). * * It does NOT expose any mutation helpers — there are no setters, * because the contract is read-only at the desktop. The running * bee writes the file via the existing dispatch flow; the desktop * client reads via a separate channel. */ import { z } from 'zod'; /** * The five status values an in-flight bee may report. The * desktop-client UI renders the status badge; only the running bee * transitions between them. */ export declare const RUN_STATE_STATUSES: readonly ["running", "paused", "done", "failed", "blocked"]; export type RunStateStatus = (typeof RUN_STATE_STATUSES)[number]; /** * RunStateContract — the locked read-only shape (spec §7A.3). * * Notes: * - `bee_id`, `current_step`: non-empty NL strings. * - `started_at`, `updated_at`: ISO8601; updated_at >= started_at * is the caller's job (the schema does not check ordering * because a clock skew between the dispatcher and the receiver * is a transient runtime issue, not a shape invariant). * - `last_evaluator_verdict`: optional NL string; null when no * evaluator has fired yet. * - `last_user_choice`: optional NL choice summary; null when * the user has not made a pick yet. * * `.strict()` rejects unknown keys — adding a field is a * schema-version bump, not a quiet extension. */ export declare const RunStateContractSchema: z.ZodObject<{ bee_id: z.ZodString; status: z.ZodEnum<{ blocked: "blocked"; failed: "failed"; done: "done"; running: "running"; paused: "paused"; }>; current_step: z.ZodString; started_at: z.ZodString; updated_at: z.ZodString; last_evaluator_verdict: z.ZodNullable; last_user_choice: z.ZodNullable; }, z.core.$strict>; export type RunStateContract = z.infer; /** * Strict-parse an unknown value as a RunStateContract. Throws * `ZodError` on failure. The desktop client uses this at the read * boundary; the running bee writes the file via the existing * dispatch flow (separate write path). */ export declare function parseRunStateContract(input: unknown): RunStateContract; /** * Safe-parse twin — same Result-like envelope shape used elsewhere. */ export declare function safeParseRunStateContract(input: unknown): { ok: true; contract: RunStateContract; } | { ok: false; findings: Array<{ path: string; message: string; }>; }; /** * Server-side factory used by the dispatch flow to write the file. * This helper is exported for testing purposes; the desktop client * is read-only and SHOULD NOT call this. * * The function returns a brand-new `RunStateContract` value; it * does NOT mutate any external state. Persistence is the caller's * responsibility (the dispatch flow writes a JSON file at a * well-known path under `.peaks/_runtime///`). */ export declare function buildRunState(args: { bee_id: string; status: RunStateStatus; current_step: string; started_at: string; updated_at: string; last_evaluator_verdict?: string | null; last_user_choice?: string | null; }): RunStateContract;