import { type ReaderState } from "../interpretation/content.js"; import type { HarnessDescriptor, HarnessName, StreamingGranularity } from "../knowledge/descriptor.js"; import type { HarnessEvent } from "./events.js"; export interface DecodeState { /** Independent evidence: a later failure can revoke successful-turn * completion without erasing text that was already delivered. */ messageDelivered?: true; nativeTerminalSeen?: true; lastSeenId: string | null; limitSeen: boolean; /** The id this turn expects (resume paths); rotation is classified * against it. Null for fresh launches. */ requestedId: string | null; /** RFC-06: this turn rendered through the resume-last builder. The * runner sets it alongside the null requested id; every identity event * built from this state carries it. */ resumeLast?: true; /** The harness's latest model self-attestation (pi assistant message * records). Null until one is observed; used to fill observedOn.model * on a re-emitted identity when the harness announces identity before * it announces its model. Never feeds validation or refusal paths. */ observedModel: string | null; /** The provider announced alongside the observed model, if any. */ observedProvider: string | null; /** An identity event already went out on this state - the re-emit gate * for fresh launches, where requestedId is null and only an emitted * first-sight identity proves context. */ identityEmitted: boolean; /** The observedModel value the last emitted identity carried (null when * it carried the static record). A re-emit fires only on change, so one * attestation means one re-emit, not one per assistant record. */ emittedModel: string | null; /** A terminal error the harness may still supersede (pi retries a * stopReason-error assistant attempt inside one run). The error is * already emitted as NON-terminal evidence when stashed; a later * successful assistant message revokes the claim, and the pump settles * what remains at stream/turn end through `settleProvisionalError`. */ provisionalError: string | null; /** Opaque per-reader decoder state (cursor call ids and query args in * v1), owned by interpretation and held here without inspection (ADR * 0005). Threaded across the lines of one turn; reset per turn by * constructing fresh state beside every freshDecodeState call. */ readerState: ReaderState; } export declare const freshDecodeState: (requestedId?: string | null, harness?: HarnessName) => DecodeState; export declare const decodeLine: (h: HarnessDescriptor, line: string, state: DecodeState, model: string, streaming?: StreamingGranularity) => HarnessEvent[]; /** The parsed-record half of decodeLine, for pumps that already parsed the * line once (a session pump inspects `type` before routing) - the hottest * path must not JSON.parse every token delta twice. * * Model attestation (pi): the harness announces identity (the session * record) before it announces its model (the first assistant message * record), so the first identity event leaves with observedOn.model empty * and the decoder re-emits identity with the observed model once the * attestation arrives. The re-emit carries the same sessionId - * decodeIdentity dedupes on lastSeenId, so consumers that dedupe see one * identity; consumers that take the last (the settings projection that * reads observedOn.model) see the model. The observed model is * self-attestation, marked runtime-verified through the normal provenance * path, and it must never widen authority: validateModel, refusal paths, * and capability claims never read it. */ export declare const decodeParsed: (h: HarnessDescriptor, raw: unknown, state: DecodeState, model: string, streaming?: StreamingGranularity) => HarnessEvent[]; /** Settle the provisional terminal error where the harness can no longer * supersede it: the end of a one-shot stream, or the end of a session * turn. What survived is the turn's terminal error (the silent-empty-turn * shape); a superseded claim was already emitted as non-terminal evidence * and settles to nothing. Clearing on settle keeps the next turn starting * from no inherited claim. */ export declare const settleProvisionalError: (state: DecodeState) => Extract[]; //# sourceMappingURL=decode.d.ts.map