import { CompletedToolCall, HandoffRecord, RunState, RunStateUsageByModel, RunStatus, RunTaintSummary, RunVerdicts, TodoItem, ToolApproval, Usage, WireMessage, WireRunStep } from "@graphorin/core"; //#region src/run-state/index.d.ts /** * Canonical schema id for serialized {@link RunState} payloads. * * 1.2 encodes binary message/tool-outcome payloads (`Uint8Array | URL`) * through the core `WireRunState` projection (base64 / href envelopes) * instead of letting `JSON.stringify` corrupt them. 1.0/1.1 payloads * remain readable; their corrupted numeric-key byte objects are * repaired best-effort on rehydration. * * @stable */ declare const RUN_STATE_SCHEMA_VERSION: "graphorin-run-state/1.2"; /** * Reader-supported schema id range. Major version 1 only for v0.1. * * @stable */ declare const RUN_STATE_SCHEMA_MAJOR_SUPPORTED = 1; /** * On-disk payload returned by {@link serializeRunState} and accepted * by {@link deserializeRunState}. The shape is JSON-stable: binary * message/tool-outcome payloads appear in their `WireMessage` / * `WireRunStep` (base64 / href envelope) form. * * @stable */ interface SerializedRunState { readonly version: typeof RUN_STATE_SCHEMA_VERSION; readonly id: string; readonly agentId: string; readonly currentAgentId: string; readonly sessionId: string; readonly userId?: string; readonly status: RunStatus; readonly steps: ReadonlyArray; readonly messages: ReadonlyArray; readonly pendingApprovals: ReadonlyArray; readonly handoffs: ReadonlyArray; readonly usage: Usage; readonly usageByModel?: RunStateUsageByModel; /** Coarse data-flow taint summary (no untrusted text). */ readonly taintSummary?: RunTaintSummary; /** Deferred tools promoted by `tool_search` this run. */ readonly promotedTools?: ReadonlyArray; /** Per-turn security verdicts keyed by `':'`. */ readonly verdicts?: RunVerdicts; /** Journaled structured plan/todo list. */ readonly todos?: ReadonlyArray; /** * Parked sub-agent runs. Each child snapshot is itself a full * `SerializedRunState` - version-stamped and secret-redacted * recursively, to any nesting depth. */ readonly pendingSubRuns?: ReadonlyArray; readonly startedAt: string; readonly finishedAt?: string; readonly error?: { readonly message: string; readonly code: string; readonly details?: unknown; }; } /** * Serialized twin of core's `PendingSubRun`: the parked child * state travels as its own versioned {@link SerializedRunState}. * * @stable */ interface SerializedPendingSubRun { readonly toolCallId: string; readonly toolName: string; readonly targetAgentName: string; readonly state: SerializedRunState; } /** * Options accepted by {@link serializeRunState}. * * @stable */ interface SerializeRunStateOptions { /** * Deep-redact secret-named keys (`apiKey`, `authorization`, * `bearerToken` / `accessToken` / `refreshToken`, `password`, * `secret`, …) anywhere in the snapshot - tool results and messages * included - replacing their values with `'[redacted]'`. Defaults to * `false` for the round-trip canonical helper; the agent runtime * passes `true` when persisting through the checkpoint store. * Redaction is best-effort by key name: secrets stored * under unrelated keys are not detected. */ readonly stripTracingApiKey?: boolean; } /** * Render a JSON-stable snapshot of the supplied {@link RunState}. * The returned value is plain JSON (no `Map`, `Set`, `Date`, ...). * * @stable */ declare function serializeRunState(state: RunState, options?: SerializeRunStateOptions): SerializedRunState; /** * Render the canonical JSON string representation of the supplied * {@link RunState}. `JSON.stringify(serializeRunState(state))` - * provided as a convenience. * * @stable */ declare function runStateToJSON(state: RunState, options?: SerializeRunStateOptions): string; /** * Options accepted by {@link deserializeRunState} / {@link runStateFromJSON}. * * @stable */ interface DeserializeOptions { /** * Synthesize `usageByModel` from a v0.1-alpha state that omits * the field. Defaults to `true` so callers can rehydrate older * states without explicit migration. */ readonly synthesizeUsageByModel?: boolean; /** * Logger callback for one-time INFO messages emitted on * backwards-compat synthesis. Defaults to a no-op. */ readonly logger?: (message: string) => void; } /** * Rehydrate a {@link RunState} from the on-disk payload. Throws * {@link RunStateVersionUnsupportedError} when the payload version * is from a future major; throws * {@link RunStateMalformedError} when the payload is structurally * invalid. * * Backwards-compat: a payload that omits `usageByModel` is accepted * and the field is synthesized from the aggregate `usage` with * `attemptCount: 1` for the primary model. * * @stable */ declare function deserializeRunState(payload: unknown, options?: DeserializeOptions): RunState; /** Convenience JSON-string parser pairing with {@link runStateToJSON}. */ declare function runStateFromJSON(serialized: string, options?: DeserializeOptions): RunState; /** * Build a fresh, minimal {@link RunState} for a new run. Helper used * by `createAgent({...})` so consumers can construct deterministic * run state in tests. * * @stable */ declare function createInitialRunState(args: { readonly id: string; readonly agentId: string; readonly sessionId: string; readonly userId?: string; readonly startedAt?: string; }): RunState; /** * Append a per-model usage entry to {@link RunState.usageByModel}. * Mutates the supplied state in place - used by the agent runtime's * per-step retry loop. Pure callers that need an immutable update * should clone the state first. * * @stable */ declare function addModelUsage(state: RunState, modelId: string, delta: Usage): void; /** * Recompute the aggregate usage from `usageByModel`. Returns the * sum that callers can compare against `state.usage` to verify the * per-step retry loop maintained the documented invariant. * * @stable */ declare function aggregateUsageFromByModel(byModel: RunStateUsageByModel | undefined): Usage; /** * The "tools used" surface of a completed run. Cheap to compute * from `RunState.steps`; surfaced as a stand-alone helper for * Phase 17 example apps and operator-facing dashboards. * * @stable */ declare function completedToolCallsFromState(state: RunState): ReadonlyArray; //#endregion export { DeserializeOptions, RUN_STATE_SCHEMA_MAJOR_SUPPORTED, RUN_STATE_SCHEMA_VERSION, SerializeRunStateOptions, SerializedPendingSubRun, SerializedRunState, addModelUsage, aggregateUsageFromByModel, completedToolCallsFromState, createInitialRunState, deserializeRunState, runStateFromJSON, runStateToJSON, serializeRunState }; //# sourceMappingURL=index.d.ts.map