import type { LiveSteering, UserMessage } from "../../types.js"; import type { InputItem } from "./request-transformer.js"; /** Server acknowledgement of one `response.steer` submission. */ export type CodexSteerAck = { accepted: true; id: string; } | { accepted: false; code?: string; message?: string; }; /** Socket surface the pump submits through. */ export interface CodexSteerSocket { /** Sends `response.steer`; resolves on the matching acknowledgement, rejects when the socket closes first. */ steer(previousResponseId: string, input: InputItem[]): Promise; } /** Steering the server accepted, with the exact input items it queued. */ export interface CodexAcceptedSteer { id: string; items: InputItem[]; } /** What a finished pump delivered into its response. */ export interface CodexSteerOutcome { responseId: string | undefined; accepted: CodexAcceptedSteer[]; /** * A submission ended without an acknowledgement, so the server may or may * not hold it. The caller must drop the socket rather than chain from it. */ uncertain: boolean; } /** * Submits caller steering to one in-flight response. Stops after the first * rejection: the server only rejects when the response no longer accepts input, * and later submissions would reorder the caller's input. */ export declare class CodexSteerPump { #private; constructor(source: LiveSteering, socket: CodexSteerSocket, toInput: (messages: readonly UserMessage[]) => InputItem[] | undefined); /** The response this pump steers, once started. */ get responseId(): string | undefined; /** Starts submitting steering to `responseId`; later calls are ignored. */ start(responseId: string): void; /** Stops claiming input, settles the submission in flight, and reports what the server accepted. */ finish(): Promise; } /** * Converted steering input, or `undefined` when an item is not a plain user * message (the only shape `response.steer` accepts). */ export declare function toSteerInputItems(items: readonly InputItem[]): InputItem[] | undefined; /** How the request after a steered response continues on the server. */ export type CodexSteerPlan = /** The server continues on its own: read its successor, send nothing. */ { kind: "attach"; } /** The server awaits tool output: send only `input`; it prepends the accepted steering itself. */ | { kind: "create"; input: InputItem[]; } /** The request cannot line up with the server's queue: drop the socket and replay in full. */ | { kind: "discard"; }; /** * Line the next request up with steering the server accepted for the previous * response. * * `delta` is the chained input (new items after the previous response), or * `undefined` when the chain broke. The accepted steering must appear in it, in * order; what remains decides the plan: nothing means the server's automatic * successor is exactly this request, tool output means the server is waiting * for it, anything else runs concurrently with a successor and cannot be sent. */ export declare function planSteeredRequest(delta: readonly InputItem[] | undefined, steering: readonly InputItem[]): CodexSteerPlan;