/** * Pure validation and encoding for descriptor-declared persistent-session * input, and the decoding of the session records the runner cannot read * without harness knowledge. This module owns the wire records and their * field names (ADR 0005, RFC-02 change 4); the execution layer branches * on the closed kinds it returns and holds no field name of its own. */ import type { HarnessDescriptor, SessionInputContract, SessionInputKind } from "../knowledge/descriptor.js"; export type SessionInputIssue = "missing-session-input-contract" | "unsupported-session-input-kind"; export declare class SessionInputRefusalError extends Error { readonly issue: SessionInputIssue; constructor(issue: SessionInputIssue); } /** The marker ids hcn stamps on the rpc commands it writes, so their * responses cannot be confused with anything user-visible. */ export declare const IDENTITY_PROBE_ID = "hcn-identity"; export declare const SEND_ID = "hcn-send"; /** The JSON-RPC request id of the initialize handshake line, written * before the identity probe on a codex session. Its response carries * nothing hcn needs; the marker keeps it recognizable. */ export declare const INITIALIZE_ID = "hcn-initialize"; export interface SessionInputEncodingOptions { readonly busy: boolean; readonly id: string; /** Popeye prompt frames and codex requests carry the minted session id * (popeye session, codex thread). */ readonly sessionId?: string; /** Codex steer precondition: the tracked id of the currently running * native turn. A mismatch fails the request server-side, which is the * rejected disposition. */ readonly activeTurnId?: string; } export declare const resolveSessionInput: (harness: HarnessDescriptor) => SessionInputContract; export declare const encodeSessionInput: (input: SessionInputContract, text: string, options?: SessionInputEncodingOptions) => string; /** What one spawn must write to learn the session id, or null when the * harness announces identity on its stream unprompted. pi rpc is * identity-silent at startup (spike fixtures); the response echoes the * marker id. Popeye rpc is likewise silent: the probe is a create frame, * and the snapshot response mints the session. Codex app-server is * silent AND needs a handshake: the probe is two JSON-RPC lines, * `initialize` (required before any other request - verified 0.159.2: * everything else fails with -32600 "Not initialized") then the thread * open named by the descriptor's identityProbe.command - thread/start for * a fresh session, thread/resume with the requested id when isResume. */ export declare const encodeIdentityProbe: (h: HarnessDescriptor, opts?: { readonly sessionId?: string; readonly isResume?: boolean; readonly model?: string; readonly clientVersion?: string; }) => string | null; /** Kinds whose send requests are answered by a native receipt the runner * can correlate (pi rpc responses; codex JSON-RPC responses). The runner * settles the send's disposition on that receipt. */ export declare const hasNativeReceipts: (kind: SessionInputKind) => boolean; /** What one parsed stdout record means to a session, as a closed kind. */ export type SessionRecord = /** The identity probe answered with the session id. */ { readonly kind: "identity"; readonly sessionId: string; } /** The identity probe answered without an id - surfaced, never silent. */ | { readonly kind: "probe-failed"; readonly message: string; } /** A correlated rpc command was accepted by the harness. `nativeTurnId` * is present when the response names the turn it started or steered * into (codex turn/start {turn.id}, turn/steer {turnId}); the runner * tracks it as the steer precondition for the next mid-turn send. */ | { readonly inputId: string; readonly kind: "command-accepted"; readonly nativeTurnId?: string; } /** An rpc command hcn wrote was refused by the harness. */ | { readonly inputId?: string; readonly kind: "command-failed"; readonly message: string; } /** Protocol bookkeeping with nothing to surface. */ | { readonly kind: "ignored"; } /** The record that delimits a turn, with the harness's own error flag. */ | { readonly kind: "turn-end"; readonly isError: boolean; } /** Anything else: content for the stream decoder. */ | { readonly kind: "content"; }; export declare const decodeSessionRecord: (h: HarnessDescriptor, parsed: Record) => SessionRecord; //# sourceMappingURL=session-input.d.ts.map