/** * Build contract §1.3 — the harness's own state. Opaque to us, persisted by us, * disposable: correctness never depends on the harness's copy, because the truth * is ours (architecture §3, "Harness state"). */ import type { ThreadId, TurnState } from "@vendoai/core"; import type { UIMessage } from "ai"; /** * Where an opaque `turn.state` lives between turns. * * ONE slot per thread, carrying the name of the harness that owns it. §1.3 says a * harness swap CLEARS the state — so a swap must destroy it, not shadow it behind * a per-harness key. Keying by harness would let a stale session resurrect when * the user swapped back, handing a thinker a session id that no longer describes * a conversation that has moved on without it. */ export interface HarnessStateStore { /** The stored state iff it belongs to `harnessName`; a foreign owner CLEARS. */ get(threadId: ThreadId, harnessName: string): Promise; /** `undefined` deletes. */ set(threadId: ThreadId, harnessName: string, value: string | undefined): Promise; /** Drop the thread's state whoever owns it (an arbitrary history edit). */ clear(threadId: ThreadId): Promise; } /** The process-lifetime reference implementation, for compositions with no store * (and for suites). A session id is disposable by contract, so losing it on * restart costs a re-seed, never correctness. */ export declare function memoryHarnessStateStore(): HarnessStateStore; export type PendingState = { value: string | undefined; dirty: boolean; }; /** The §1.3 handle a harness holds for one turn. Writes are buffered and land * once, at turn end — a turn that sets a session id ten times costs one row. */ export declare function createTurnState(initial: string | undefined): TurnState & { pending(): PendingState; }; /** * How the incoming transcript relates to the one we persisted. * * `arbitrary-edit` is the only one that clears `turn.state` (§1.3): the harness's * native session no longer describes the conversation we hold. A * `prefix-truncation` is a retry of an edited message, which the harness rewinds * natively, so its session survives. */ export type HistoryChange = "append" | "prefix-truncation" | "arbitrary-edit"; export declare function classifyHistory(persisted: readonly UIMessage[], incoming: readonly UIMessage[]): HistoryChange; //# sourceMappingURL=harness-state.d.ts.map