import type { SessionKey } from "@yanlinglabs/winter-agent-sdk"; import type { ProviderStateRecord } from "@yanlinglabs/winter-provider-runtime"; /** The provider-state sidecar's suffix (WS-05 §13). */ export declare const PROVIDER_STATE_SUFFIX = ".provider-state.jsonl"; /** * The label every barrier-injected entry carried, so it could never read as an ordinary message. No * handoff writes one any more (WS-23); an upgrading home's transcripts can still hold one, and the * recovery reconcile still has to recognise it. */ export declare const HANDOFF_ENTRY_LABEL = "handoff"; /** The sidecar's path for `key` — WS-05 §13's own naming, never renamed, never a different suffix. */ export declare function providerStateSidecarPath(winterHome: string, key: SessionKey): string; /** * The most record bytes one read KEEPS -- the SDK's own `PROVIDER_STATE_MAX_READ_BYTES` * (`packages/runtime/src/store/provider-state.ts`, WS-23 review r1 I-4), mirrored rather than imported * because the SDK does not export its reader. A sidecar is a few small records per assistant entry, so * this is orders of magnitude above any ordinary session; the bound exists because a file grown without * limit (a very long session, a corrupt or attacker-grown file) must not be read into memory without * limit on a switch review or a recovery reconcile. */ export declare const PROVIDER_STATE_MAX_READ_BYTES: number; /** One line longer than this is not a record Winter wrote; it is skipped unread (the SDK's own bound). */ export declare const PROVIDER_STATE_MAX_LINE_BYTES: number; /** * Reads and parses the provider-state sidecar into `ProviderStateRecord[]`. A torn tail line is * skipped, never fatal — the sidecar's own write-ahead posture means a partial line is a crash * artefact, not a corruption. An absent sidecar (no session, or one that never carried opaque state) * reads as `[]`. * * BOUNDED MEMORY, the SDK's streamed read (WS-23): the file is read in 1 MiB chunks, a line past * `PROVIDER_STATE_MAX_LINE_BYTES` is dropped without being buffered, and the records RETAINED never * exceed `PROVIDER_STATE_MAX_READ_BYTES` -- the OLDEST are let go as the read goes (and cut out of the * working list once they pass half of it), so memory tracks the bound, never the file. Keeping the * newest is what both readers want: `reviewSwitch` looks for the LIVE model (the latest origin record), * and the recovery reconcile's record-for-record recompute can only fail to match with records missing, * which excludes that transcript rather than washing an unproved line into the canonical file. * `limits` exists for tests. * * NEVER LOGGED, and `payload` is never inspected beyond passing it through opaque (WS-05 §13's global * rule): this function parses the ENVELOPE only. */ export declare function readProviderStateSidecar(winterHome: string, key: SessionKey, limits?: { maxKeptBytes?: number; maxLineBytes?: number; stats?: { peakRetained: number; }; }): Promise;