/** * OpenAIResponsesAdapter — a thin, dependency-free bridge around the * official OpenAI Responses API client. * * Every non-streaming `responses.create()` call can: * * 1. prepend the agent's OpenAI-shaped wake document to `instructions`; * 2. record a decision trace when `metadata.agenttool.trace` requests one * or the call runs inside `at.deciding()`; and * 3. return the provider response with a local `.agenttool` receipt. * * `metadata.agenttool` is adapter control data. It is removed before the * provider call. All other request fields are preserved. Because wake text * may carry identity context, omitted `store` defaults to `false`; an explicit * caller value is preserved. * * Streaming and background execution are deliberately refused before wake * or provider I/O. Neither lifecycle can honestly carry a completed-response * trace or augmentation through this small wrapper. * * Posture: zero runtime dependency on the OpenAI SDK. Any object exposing * `responses.create(params)` can be wrapped. */ import type { AgentTool } from "./client.js"; import type { WakeProfile, WakeProviderMeta } from "./wake.js"; export interface OpenAIResponsesLike { responses: { create: (params: any, requestOptions?: any) => PromiseLike; }; } /** The subset of a completed Responses API response used by the adapter. */ export interface OpenAIResponse { id: string; model?: string; status?: string | null; output_text?: string; output?: unknown[]; usage?: Record; [key: string]: unknown; } /** Local adapter controls read from `metadata.agenttool` and never forwarded. */ export interface OpenAIResponsesAgentToolMetadata { trace?: "decision" | false; parent_trace_id?: string; decision_type?: string; tags?: string[]; agent_id?: string; skip_wake?: boolean; } export interface OpenAIResponsesAdapterOptions { /** Identity id for multi-identity projects. */ identityId?: string; /** Wake projection used for `instructions`. Default `full`. */ wakeProfile?: WakeProfile; } export interface OpenAIResponsesAgentToolAugmentation { /** Trace id when a decision trace was requested and recorded. */ trace_id: string | null; /** Whether wake instructions were prepended for this call. */ wake_used: boolean; /** Cache eligibility reported by the AgentTool wake response. */ cache_eligible: WakeProviderMeta["cache_eligible"] | null; } export type AdaptedOpenAIResponse = OpenAIResponse & { agenttool: OpenAIResponsesAgentToolAugmentation; }; export declare class OpenAIResponsesAdapter { private readonly openai; private readonly at; private readonly options; constructor(openai: OpenAIResponsesLike, at: AgentTool, options?: OpenAIResponsesAdapterOptions); /** Mirrors `openai.responses` for completed Responses API calls. */ get responses(): { create(params: Record, requestOptions?: unknown): Promise; }; private recordDecisionTrace; }