/** * vigiles — parse a subagent's railway result. * * A subagent with a `result()` contract is told (in its compiled system prompt) * to end its turn with exactly one fenced block: * * ```vigiles:ok * { "files": ["a.ts"], "summary": "done" } * ``` * * or `vigiles:err` for the error track. This module extracts and validates that * block — the single primitive the railway orchestrator and the harness-test * assertions (`assertAgentOk`/`assertAgentErr`) both build on. Pure and * model-free: hand it the worker's text, get back a discriminated outcome. * * "Railway-oriented" is literal here: the parse is `text -> Result` with a * third `malformed` track for a worker that didn't honor its contract (no block, * bad JSON, or a shape that doesn't match the declared schema). */ import type { OutputContract, OutputFieldType } from "../../core/spec.js"; /** The outcome of parsing a worker's result block. */ export type ParsedAgentResult, E = Record> = { readonly kind: "ok"; readonly value: S; } | { readonly kind: "err"; readonly error: E; } | { readonly kind: "malformed"; readonly reason: string; }; /** * Validate a parsed object against a contract track; null when it conforms. * * Exported because the EXPERIMENTAL emit channel (`src/experimental-emit.ts`) * validates the SAME `OutputContract` on a different delivery. One contract, two * deliveries, one validator — a second copy would drift, and the two rails * disagreeing about what satisfies a contract is the worst outcome available. */ export declare function shapeError(obj: Record, shape: Readonly>): string | null; /** * Parse the last `vigiles:ok` / `vigiles:err` block from a worker's output. * * With a `contract`, the parsed object is validated against the matching track's * shape — a worker that emits the wrong shape is `malformed`, not a silent pass. * Without one, any well-formed JSON block is accepted. */ export declare function parseAgentResult(text: string, contract?: OutputContract): ParsedAgentResult; //# sourceMappingURL=agent-result.d.ts.map