import { type AgentProxy } from '../core/proxy/http-server.js'; import { stringifyToolResult } from '../core/proxy/middleware.js'; import type { Config, Data, Middleware, Recording, ToolCall, ToolResult } from '../core/types.js'; type FunctionCallItem = { type: 'function_call'; id?: string; call_id: string; name: string; arguments: string; status?: string; [k: string]: unknown; }; type MessageItem = { type: 'message'; id?: string; role: 'assistant' | 'user' | 'system'; content: Array<{ type: string; text?: string; [k: string]: unknown; }>; [k: string]: unknown; }; type ReasoningItem = { type: 'reasoning'; id?: string; content?: unknown; summary?: unknown; [k: string]: unknown; }; type OutputItem = FunctionCallItem | MessageItem | ReasoningItem | { type: string; [k: string]: unknown; }; type OpenAIResponse = { id: string; object: 'response'; model: string; output: OutputItem[]; usage?: { input_tokens?: number; output_tokens?: number; total_tokens?: number; [k: string]: unknown; }; [k: string]: unknown; }; /** * Build the SSE event sequence the Responses API streams for a * complete `Response`. Codex requires `usage.total_tokens` on * `response.completed`; we compute it if upstream omits it. * * response.created * ├─ per-item (response.output_item.added → .done) * │ for function_call: also emit response.function_call_arguments.delta then .done * │ for message.output_text: also emit response.output_text.delta/.done inside content_part * └─ response.completed */ export declare function synthesizeResponsesSse(resp: OpenAIResponse): string; export declare function splitMcpName(name: string): { server: string; tool: string; }; /** * Build the function-call `arguments` JSON string for a redirect to * codex's `exec_command`: `{ "cmd": "" }`. base64 keeps * the payload free of shell-special chars so single-quoting is safe. */ export declare function encodeAsResponsesRedirect(synthetic: ToolResult): string; export type StartOpenAIResponsesProxyOpts = { evalName: string; config: Readonly; data: Data; middleware: readonly Middleware[]; abort: (reason?: unknown) => void; onToolCall: (call: ToolCall) => void; upstream?: string; upstreamResolver?: () => string; /** Tool name used as the redirect target on short-circuit. Codex: `exec_command`. */ redirectToolName: string; /** Build the `arguments` string for the redirect tool. */ redirectArgumentsBuilder?: (synthetic: ToolResult) => string; /** * Capture each upstream round-trip as raw bytes — used by the * runner's `record` mode to gather exchanges for later replay. */ onExchange?: (request: string, response: string) => void; /** * Map of `call_id → recorded ToolResult`. When the agent emits a * function_call with one of these ids during the replay prefix, the * proxy auto-short-circuits it with the recorded result and skips * middleware (strict replay). */ replayResults?: ReadonlyMap; /** * Replay the first `upTo` recorded exchanges before forwarding to * the live upstream. The proxy spins up an in-process replay * server and routes traffic through it. */ replay?: { recording: Recording; upTo: number; }; }; /** * Walk a `Recording`'s captured request bodies and pull out every * `function_call_output` item keyed by `call_id`. Used to auto-short- * circuit prefix tool calls during replay. */ export declare function extractResponsesReplayResults(recording: { exchanges: Array<{ request: string; response: string; }>; }): Map; export type { AgentProxy }; export declare function startOpenAIResponsesProxy(opts: StartOpenAIResponsesProxyOpts): Promise; export { stringifyToolResult }; //# sourceMappingURL=openai-responses-proxy.d.ts.map