@alvin0/ai-agent-sdk-protocol-responses 0.1.2 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -4,7 +4,8 @@ import { ModelTarget, ResolvedModelInfo } from "@alvin0/ai-agent-sdk-core/provid
4
4
  /** The request fields a pure wire protocol is allowed to inspect. */
5
5
  interface ProtocolRequest {
6
6
  readonly options: GenerateOptions;
7
- readonly maxTokens: number;
7
+ /** Absent when neither the caller, the model, nor the route names an output cap. */
8
+ readonly maxTokens?: number;
8
9
  }
9
10
  /** One decoded SSE event, expressed without depending on an HTTP transport. */
10
11
  interface ProtocolSseEvent {
@@ -196,8 +197,8 @@ interface WireRequest {
196
197
  parallel_tool_calls?: boolean;
197
198
  reasoning?: WireReasoning;
198
199
  text?: WireTextControls;
199
- /** Whether the provider retains the response server-side. */
200
- store: boolean;
200
+ /** Whether the provider retains the response server-side. Omitted for endpoints that reject the field. */
201
+ store?: boolean;
201
202
  stream: boolean;
202
203
  /** Extra payloads to include, e.g. `reasoning.encrypted_content`. */
203
204
  include?: string[];
@@ -296,8 +297,11 @@ interface ResponsesDialect {
296
297
  readonly maxOutputTokens: boolean;
297
298
  /** Whether the endpoint accepts `text.format` JSON Schema controls. */
298
299
  readonly structuredOutputs: boolean;
299
- /** Value for `store`. Codex always sends false. */
300
- readonly store: boolean;
300
+ /**
301
+ * Value for `store`. Codex always sends false.
302
+ * `undefined` omits the field entirely, for an endpoint that rejects it outright.
303
+ */
304
+ readonly store?: boolean;
301
305
  /** Values for `include`. */
302
306
  readonly include: readonly string[];
303
307
  /** Whether to ask for reasoning summaries, and how detailed. */
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../src/contract.ts","../src/wire.ts","../src/protocol.ts","../src/serialize.ts","../src/translate.ts"],"mappings":";;;;UAGiB;WACN,SAAS;WACT;;;UAIM;WACN;WACA;;;KAIC,sBACR,QAA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;EACR,qBAAqB;;;UAIN;EACf;EACA,WAAW;EACX,OAAO;EACP;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;EAEA;EACA;;;;;;;;;UAUe;;;;;;;WAON;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;;;;;;;WAQA;;;;;cC9QE;UAmBH,+BAA+B;WAC9B,OAAO;WACP;aACE;aACA,SAAS,SAAS;;;;UAKd;WACN;WACA;WACA;WACA,gBAAgB;WAChB,eAAe;WACf,eAAe,SAAS,wBAAwB,SAAS;WACzD,mBAAmB,SAAS,qBAAqB,SAAS;WAC1D,YACP,SAAS,wBACT,SAAS,qBACN,SAAS;WACL,YACP,QAAQ,cAAc,mBACtB,SAAS,wBACT,wBACG,eAAe;;;cAIT,yBAAyB,mBAAmB,oBACrD;;;;;;;UC/Ba;;EAEf;;EAEA;;EAEA;;;;;;;;iBAqTc,0BACd,SAAS,iBACT,SAAS,mBACR;;;;;;;;;;;;;;iBC/EoB,yBACrB,QAAQ,cAAc,mBACtB,qBACA,UAAU,kBACT,eAAe"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/contract.ts","../src/wire.ts","../src/protocol.ts","../src/serialize.ts","../src/translate.ts"],"mappings":";;;;UAGiB;WACN,SAAS;;WAET;;;UAIM;WACN;WACA;;;KAIC,sBACR,QAAQ;WAAwB;;WACrB;WAAwB,OAAO;;;UAG7B,mBAAmB;WACzB;WACA,gBAAgB;EACzB,aAAa,SAAS,iBAAiB,SAAS;EAChD,iBAAiB,SAAS,UAAU;EACpC,UAAU,SAAS,iBAAiB,SAAS,oBAAoB;EACjE,UACE,QAAQ,cAAc,mBACtB,SAAS,iBACT,sBACC,eAAe;;;;;;;;;;;;;;;;;;;KCfR;;KAGA;EACN;EAAoB;;EACpB;EAAqB;EAAmB,SAAS;;EACjD;EAAqB;EAAiB,SAAS;;;;;;;EAK/C;EAAoB;EAAkB;;EACtC;EAAoB;;EACpB;EAAoB;;EACpB;EAAqB;EAAc,cA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,SAAS;WACL,YACP,QAAQ,cAAc,mBACtB,SAAS,wBACT,wBACG,eAAe;;;cAIT,yBAAyB,mBAAmB,oBACrD;;;;;;;UC/Ba;;EAEf;;EAEA;;EAEA;;;;;;;;iBAqTc,0BACd,SAAS,iBACT,SAAS,mBACR;;;;;;;;;;;;;;iBC/EoB,yBACrB,QAAQ,cAAc,mBACtB,qBACA,UAAU,kBACT,eAAe"}
package/dist/index.js CHANGED
@@ -258,11 +258,11 @@ function serializeResponsesRequest(request, dialect) {
258
258
  ...dialect.reasoningSummary === void 0 ? {} : { summary: dialect.reasoningSummary }
259
259
  } },
260
260
  ...text === void 0 ? {} : { text },
261
- store: dialect.store,
261
+ ...dialect.store === void 0 ? {} : { store: dialect.store },
262
262
  stream: true,
263
263
  ...dialect.include.length === 0 ? {} : { include: [...dialect.include] },
264
264
  ...dialect.promptCacheKey === void 0 ? {} : { prompt_cache_key: dialect.promptCacheKey },
265
- ...dialect.maxOutputTokens ? { max_output_tokens: request.maxTokens } : {},
265
+ ...dialect.maxOutputTokens && request.maxTokens !== void 0 ? { max_output_tokens: request.maxTokens } : {},
266
266
  ...dialect.sampling && options.temperature !== void 0 ? { temperature: options.temperature } : {},
267
267
  ...dialect.sampling && options.topP !== void 0 ? { top_p: options.topP } : {}
268
268
  };
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["textAnnotations"],"sources":["../src/serialize.ts","../src/translate.ts","../src/protocol.ts"],"sourcesContent":["/**\n * Normalized request to Responses API wire JSON.\n *\n * The interesting work is flattening. Our conversation is a list of messages,\n * each holding an ordered list of content blocks; the wire wants a FLAT list of\n * items where a tool result and a tool call are peers of a message rather than\n * parts of one. So one assistant message that reasoned, spoke, and called two\n * tools expands to four items, and their relative order must be preserved\n * because the model reads it as its own prior turn.\n *\n * @module ai-agent-sdk/providers/responses/serialize\n */\n\nimport type { ProtocolRequest } from './contract.ts'\nimport { MODEL_ERROR_CODES, ModelError } from '@alvin0/ai-agent-sdk-core'\nimport type { ContentBlock, DocumentBlock, ImageBlock, TextBlock } from '@alvin0/ai-agent-sdk-core'\nimport type { Message } from '@alvin0/ai-agent-sdk-core'\nimport {\n isNativeToolSchema,\n type ModelOutputFormat,\n type ModelToolSchema,\n type NativeImageGenerationTool,\n type NativeWebSearchTool,\n type ToolChoice,\n type ToolSchema,\n} from '@alvin0/ai-agent-sdk-core'\nimport type {\n ResponsesDialect,\n WireContentPart,\n WireInputItem,\n WireRequest,\n WireTool,\n WireToolChoice,\n WireTextControls,\n} from './wire.ts'\n\n/**\n * Adapter-private state kept on a {@link ReasoningBlock} so a reasoning item can\n * be echoed back byte-identically on the next request of a tool-use loop.\n */\nexport interface ResponsesReasoningState {\n /** Server-assigned item id. */\n id?: string\n /** Opaque encrypted chain of thought. */\n encryptedContent?: string\n /** Summary paragraphs, in order. */\n summary?: readonly string[]\n}\n\n/** Read the reasoning state back off a block, tolerating anything unexpected. */\nfunction reasoningStateOf(value: unknown): ResponsesReasoningState {\n if (typeof value !== 'object' || value === null) return {}\n const state = value as ResponsesReasoningState\n return {\n ...typeof state.id === 'string' ? { id: state.id } : {},\n ...typeof state.encryptedContent === 'string'\n ? { encryptedContent: state.encryptedContent }\n : {},\n ...Array.isArray(state.summary) ? { summary: state.summary } : {},\n }\n}\n\nfunction textAnnotations(block: TextBlock) {\n return block.annotations?.flatMap(annotation => annotation.type === 'url-citation'\n ? [{\n type: 'url_citation' as const,\n url: annotation.url,\n ...annotation.title === undefined ? {} : { title: annotation.title },\n ...annotation.startIndex === undefined ? {} : { start_index: annotation.startIndex },\n ...annotation.endIndex === undefined ? {} : { end_index: annotation.endIndex },\n }]\n : [])\n}\n\nfunction imagePart(block: ImageBlock): WireContentPart {\n const detail = block.detail\n if (block.source.kind === 'file') {\n return { type: 'input_image', file_id: block.source.fileId, ...detail === undefined ? {} : { detail } }\n }\n const image_url = block.source.kind === 'url'\n ? block.source.url\n : `data:${block.source.mediaType};base64,${block.source.data}`\n return { type: 'input_image', image_url, ...detail === undefined ? {} : { detail } }\n}\n\n/** Fallback file name for an inline document, since the API infers type from it. */\nconst DEFAULT_DOCUMENT_FILENAME = 'document.pdf'\n\nfunction documentPart(block: DocumentBlock): WireContentPart {\n if (block.source.kind === 'file') return { type: 'input_file', file_id: block.source.fileId }\n if (block.source.kind === 'url') return { type: 'input_file', file_url: block.source.url }\n return {\n type: 'input_file',\n // The API reads the file type from the extension here, so a name is required\n // rather than optional; a neutral default beats a rejected request.\n filename: block.filename ?? DEFAULT_DOCUMENT_FILENAME,\n file_data: `data:${block.source.mediaType};base64,${block.source.data}`,\n }\n}\n\n/** Convert one content block to a request-side content part. */\nfunction contentPart(block: ContentBlock, role: 'user' | 'assistant'): WireContentPart | undefined {\n if (block.type === 'text') {\n // An assistant turn's own text must come back as `output_text`; sending it as\n // `input_text` would present the model's prior words as if the user said them.\n if (role !== 'assistant') return { type: 'input_text', text: block.text }\n const annotations = textAnnotations(block)\n return {\n type: 'output_text', text: block.text,\n ...annotations === undefined ? {} : { annotations },\n }\n }\n if (block.type === 'image') return imagePart(block)\n if (block.type === 'document') return documentPart(block)\n return undefined\n}\n\n/** Render a tool result's blocks as the wire's polymorphic `output` value. */\nfunction toolResultOutput(blocks: readonly ContentBlock[]): string | WireContentPart[] {\n const hasBinary = blocks.some(block => block.type === 'image' || block.type === 'document')\n if (!hasBinary) {\n // The common case. A plain string keeps the payload small and is what the\n // API documents first.\n return blocks\n .filter((block): block is Extract<ContentBlock, { type: 'text' }> => block.type === 'text')\n .map(block => block.text)\n .join('\\n')\n }\n return blocks\n .map(block => contentPart(block, 'user'))\n .filter((part): part is WireContentPart => part !== undefined)\n}\n\n/**\n * Expand one message into zero or more wire items, appending them in order.\n *\n * Content parts accumulate into a single message item, which is FLUSHED whenever\n * a block appears that has to become its own top-level item. That flushing is\n * what preserves \"spoke, then called a tool, then spoke again\" as three items in\n * the right order instead of collapsing it.\n */\nfunction appendMessage(message: Message, items: WireInputItem[], dialectMessagePhase: boolean): void {\n const role = message.role === 'assistant' ? 'assistant' : 'user'\n let parts: WireContentPart[] = []\n let phase: Extract<ContentBlock, { type: 'text' }>['phase']\n\n const flush = (): void => {\n if (parts.length === 0) return\n items.push({\n type: 'message', role, content: parts,\n ...role === 'assistant' && dialectMessagePhase && phase !== undefined\n ? { phase: phase === 'final-answer' ? 'final_answer' as const : phase }\n : {},\n })\n parts = []\n phase = undefined\n }\n\n for (const block of message.content) {\n switch (block.type) {\n case 'text':\n case 'image':\n case 'document': {\n if (block.type === 'text' && block.phase !== undefined && phase !== undefined && phase !== block.phase) flush()\n if (block.type === 'text' && block.phase !== undefined) phase = block.phase\n const part = contentPart(block, role)\n if (part !== undefined) parts.push(part)\n break\n }\n case 'reasoning': {\n flush()\n const state = reasoningStateOf(block.providerState)\n // Prefer the recorded summary paragraphs; fall back to the block's text so\n // a hand-built or replayed message still carries something.\n const summary = state.summary !== undefined && state.summary.length > 0\n ? state.summary\n : block.text.length > 0 ? [block.text] : []\n items.push({\n type: 'reasoning',\n ...state.id === undefined ? {} : { id: state.id },\n summary: summary.map(text => ({ type: 'summary_text' as const, text })),\n ...state.encryptedContent === undefined\n ? {}\n : { encrypted_content: state.encryptedContent },\n })\n break\n }\n case 'tool-call': {\n flush()\n items.push({\n type: 'function_call',\n call_id: block.id,\n name: block.name,\n // Empty arguments must still be valid JSON, or the provider rejects it.\n arguments: block.arguments.length > 0 ? block.arguments : '{}',\n })\n break\n }\n case 'tool-result': {\n flush()\n items.push({\n type: 'function_call_output',\n call_id: block.toolCallId,\n output: toolResultOutput(block.content),\n })\n break\n }\n case 'native-tool-call': {\n flush()\n const replay = nativeReplayItem(block.providerState)\n if (replay !== undefined) items.push(replay)\n break\n }\n default:\n // A content block introduced by declaration merging. Skipping is correct:\n // this serializer cannot know its wire form, and inventing one would\n // corrupt the request.\n break\n }\n }\n flush()\n}\n\n/** Collect the system prompt from the request plus any system-role messages. */\nfunction instructionsOf(request: ProtocolRequest): string {\n const fromMessages = request.options.messages\n .filter(message => message.role === 'system')\n .flatMap(message => message.content)\n .filter((block): block is Extract<ContentBlock, { type: 'text' }> => block.type === 'text')\n .map(block => block.text)\n const all = request.options.system === undefined\n ? fromMessages\n : [request.options.system, ...fromMessages]\n return all.join('\\n\\n')\n}\n\n/** Map the neutral tool-choice vocabulary onto this API's. */\nfunction toolChoiceOf(choice: ToolChoice): WireToolChoice {\n if (typeof choice === 'string') return choice\n if (choice.type === 'native') return { type: nativeWireType(choice.name) }\n return { type: 'function', name: choice.name }\n}\n\n/** Map a tool schema; `strict: false` because caller schemas are not vetted. */\nfunction functionTool(tool: ToolSchema): WireTool {\n return {\n type: 'function',\n name: tool.name,\n description: tool.description,\n // Strict mode imposes real JSON-Schema restrictions (no optional fields\n // without null, `additionalProperties: false` required). Opting a caller's\n // schema in silently would turn a working tool into a request rejection.\n strict: false,\n parameters: tool.parameters,\n }\n}\n\nfunction nativeWireType(name: string): string {\n if (name === 'web-search') return 'web_search'\n if (name === 'image-generation') return 'image_generation'\n return name.replaceAll('-', '_')\n}\n\nfunction webSearchTool(tool: NativeWebSearchTool): WireTool {\n if (tool.blockedDomains !== undefined) {\n throw new ModelError(\n 'OpenAI Responses web search does not support blockedDomains; use allowedDomains',\n MODEL_ERROR_CODES.INVALID_REQUEST,\n )\n }\n if (tool.maxUses !== undefined) {\n throw new ModelError(\n 'OpenAI Responses web search does not support maxUses',\n MODEL_ERROR_CODES.INVALID_REQUEST,\n )\n }\n return {\n type: 'web_search',\n ...tool.searchContextSize === undefined ? {} : { search_context_size: tool.searchContextSize },\n ...tool.allowedDomains === undefined ? {} : { filters: { allowed_domains: [...tool.allowedDomains] } },\n ...tool.userLocation === undefined ? {} : {\n user_location: { type: 'approximate', ...tool.userLocation },\n },\n }\n}\n\nfunction imageGenerationTool(tool: NativeImageGenerationTool): WireTool {\n return {\n type: 'image_generation',\n ...tool.size === undefined ? {} : { size: tool.size },\n ...tool.quality === undefined ? {} : { quality: tool.quality },\n ...tool.format === undefined ? {} : { output_format: tool.format },\n ...tool.background === undefined ? {} : { background: tool.background },\n ...tool.partialImages === undefined ? {} : { partial_images: tool.partialImages },\n }\n}\n\nfunction toolOf(tool: ModelToolSchema): WireTool {\n if (!isNativeToolSchema(tool)) return functionTool(tool)\n if (tool.name === 'web-search') return webSearchTool(tool)\n return imageGenerationTool(tool)\n}\n\nfunction textControls(\n format: ModelOutputFormat | undefined,\n dialect: ResponsesDialect,\n): WireTextControls | undefined {\n if (format === undefined) return undefined\n if (format.type === 'text') {\n return dialect.structuredOutputs ? { format: { type: 'text' } } : undefined\n }\n if (!dialect.structuredOutputs) {\n throw new ModelError(\n 'This Responses endpoint does not support JSON Schema output',\n MODEL_ERROR_CODES.INVALID_REQUEST,\n )\n }\n return {\n format: {\n type: 'json_schema',\n name: format.name,\n schema: format.schema,\n strict: true,\n },\n }\n}\n\nfunction nativeReplayItem(value: unknown): WireInputItem | undefined {\n if (typeof value !== 'object' || value === null) return undefined\n const item = value as Record<string, unknown>\n if (item.type === 'web_search_call') {\n return {\n type: 'web_search_call',\n ...typeof item.id === 'string' ? { id: item.id } : {},\n ...typeof item.status === 'string' ? { status: item.status } : {},\n ...item.action === undefined ? {} : { action: structuredClone(item.action) },\n }\n }\n if (item.type === 'image_generation_call') {\n return {\n type: 'image_generation_call',\n ...typeof item.id === 'string' ? { id: item.id } : {},\n ...typeof item.status === 'string' ? { status: item.status } : {},\n ...typeof item.result === 'string' || item.result === null ? { result: item.result } : {},\n }\n }\n return undefined\n}\n\n/**\n * Build the Responses request body.\n * @param request - the resolved request, model, and connection.\n * @param dialect - which optional fields this endpoint accepts.\n * @returns the wire body, ready to serialize.\n */\nexport function serializeResponsesRequest(\n request: ProtocolRequest,\n dialect: ResponsesDialect,\n): WireRequest {\n const { options } = request\n const input: WireInputItem[] = []\n for (const message of options.messages) {\n if (message.role === 'system') continue // folded into `instructions`\n appendMessage(message, input, dialect.messagePhase === true)\n }\n\n const instructions = instructionsOf(request)\n const tools = options.tools === undefined || options.tools.length === 0\n ? undefined\n : options.tools.map(toolOf)\n const text = textControls(options.outputFormat, dialect)\n\n return {\n model: options.model,\n ...instructions.length === 0 ? {} : { instructions },\n input,\n ...tools === undefined ? {} : { tools },\n ...options.toolChoice === undefined ? {} : { tool_choice: toolChoiceOf(options.toolChoice) },\n ...tools === undefined ? {} : { parallel_tool_calls: true },\n ...options.reasoningEffort === undefined && dialect.reasoningSummary === undefined\n ? {}\n : {\n reasoning: {\n ...options.reasoningEffort === undefined\n ? {}\n : { effort: String(options.reasoningEffort) },\n ...dialect.reasoningSummary === undefined\n ? {}\n : { summary: dialect.reasoningSummary },\n },\n },\n ...text === undefined ? {} : { text },\n store: dialect.store,\n stream: true,\n ...dialect.include.length === 0 ? {} : { include: [...dialect.include] },\n ...dialect.promptCacheKey === undefined ? {} : { prompt_cache_key: dialect.promptCacheKey },\n ...dialect.maxOutputTokens ? { max_output_tokens: request.maxTokens } : {},\n ...dialect.sampling && options.temperature !== undefined\n ? { temperature: options.temperature }\n : {},\n ...dialect.sampling && options.topP !== undefined ? { top_p: options.topP } : {},\n }\n}\n","/**\n * Responses API SSE events to the SDK's chunk protocol.\n *\n * Two design notes worth reading before changing anything here.\n *\n * First, block correlation is keyed on `item_id`, not on the provider's\n * `output_index`. Item ids are stable and present on every delta event, whereas\n * index fields vary by event type, so keying on the id and assigning our OWN\n * indices in first-seen order is both simpler and closer to what our protocol\n * promises.\n *\n * Second, reasoning state is carried on the reasoning BLOCK\n * (`ReasoningBlock.providerState`) rather than in the stream's `replayState`\n * envelope. The envelope has to stay positionally aligned with emitted blocks and\n * is discarded whole when it drifts; attaching the state to the block it belongs\n * to cannot drift, and it survives assembly for free.\n *\n * @module ai-agent-sdk/providers/responses/translate\n */\n\nimport {\n CONTEXT_WINDOW_EXCEEDED_CODE,\n QUOTA_EXCEEDED_CODE,\n} from '@alvin0/ai-agent-sdk-core'\nimport { MODEL_ERROR_CODES, ModelError } from '@alvin0/ai-agent-sdk-core'\nimport { ToolCallId } from '@alvin0/ai-agent-sdk-core'\nimport { isJsonValue } from '@alvin0/ai-agent-sdk-core'\nimport type {\n AssistantTextPhase,\n ContentBlock,\n ImageMediaType,\n TextAnnotation,\n} from '@alvin0/ai-agent-sdk-core'\nimport type { FinishReason, UsageCounters } from '@alvin0/ai-agent-sdk-core'\nimport type { ProtocolRequest, ProtocolSseEvent, ProtocolStreamChunk } from './contract.ts'\nimport type { ResponsesReasoningState } from './serialize.ts'\nimport type {\n WireErrorBody,\n WireOutputItem,\n WireResponse,\n WireStreamEvent,\n WireUsage,\n} from './wire.ts'\n\n/** Which of our block types one output item maps to. */\ntype ItemKind = 'text' | 'reasoning' | 'tool-call' | 'native-tool-call'\n\ninterface OpenItem {\n readonly index: number\n readonly kind: ItemKind\n text: string\n args: string\n callId: string\n name: string\n nativeName: string\n /** Last `summary_index` seen, so a new paragraph gets a separator. */\n summaryIndex: number | undefined\n phase: AssistantTextPhase | undefined\n}\n\nfunction textPhase(value: string | undefined): AssistantTextPhase | undefined {\n if (value === 'commentary') return 'commentary'\n if (value === 'final_answer') return 'final-answer'\n return undefined\n}\n\n/** Map an output item's wire type onto one of our block types. */\nfunction itemKind(type: string | undefined): ItemKind | undefined {\n switch (type) {\n case 'message': return 'text'\n case 'reasoning': return 'reasoning'\n case 'function_call': return 'tool-call'\n case 'web_search_call': return 'native-tool-call'\n case 'image_generation_call': return 'native-tool-call'\n default: return undefined\n }\n}\n\nfunction nativeName(type: string | undefined): string {\n if (type === 'web_search_call') return 'web-search'\n if (type === 'image_generation_call') return 'image-generation'\n return type?.replace(/_call$/, '').replaceAll('_', '-') ?? 'native-tool'\n}\n\nfunction textAnnotations(item: WireOutputItem): TextAnnotation[] {\n if (!Array.isArray(item.content)) return []\n return item.content.flatMap((part) => {\n if (typeof part !== 'object' || part === null) return []\n const annotations = (part as Record<string, unknown>).annotations\n if (!Array.isArray(annotations)) return []\n return annotations.flatMap((annotation): TextAnnotation[] => {\n if (typeof annotation !== 'object' || annotation === null) return []\n const record = annotation as Record<string, unknown>\n if (record.type !== 'url_citation' || typeof record.url !== 'string') return []\n return [{\n type: 'url-citation',\n url: record.url,\n ...typeof record.title === 'string' ? { title: record.title } : {},\n ...typeof record.start_index === 'number' ? { startIndex: record.start_index } : {},\n ...typeof record.end_index === 'number' ? { endIndex: record.end_index } : {},\n }]\n })\n })\n}\n\n/** Collect the text of a done item's `content` array. */\nfunction itemText(item: WireOutputItem): string {\n const content = item.content\n if (!Array.isArray(content)) return ''\n return content\n .map((part) => {\n if (typeof part !== 'object' || part === null) return ''\n const record = part as Record<string, unknown>\n return typeof record.text === 'string' ? record.text : ''\n })\n .join('')\n}\n\n/** Collect the summary paragraphs of a done reasoning item. */\nfunction itemSummary(item: WireOutputItem): string[] {\n const summary = item.summary\n if (!Array.isArray(summary)) return []\n return summary\n .map((part) => {\n if (typeof part !== 'object' || part === null) return ''\n const record = part as Record<string, unknown>\n return typeof record.text === 'string' ? record.text : ''\n })\n .filter(text => text.length > 0)\n}\n\n/**\n * Normalize usage, honouring the SDK's disjoint-count convention.\n *\n * This API reports `input_tokens` as the TOTAL input and\n * `input_tokens_details.cached_tokens` as a subset of it. Our convention is that\n * the three input figures are disjoint and sum to what is billed, so the cached\n * portion is subtracted back out here. Skip that and every cost estimate\n * double-counts cache hits.\n */\nfunction mapUsage(usage: WireUsage): UsageCounters | undefined {\n const source = usage as unknown as Record<string, unknown>\n const details = recordOrUndefined(source.input_tokens_details)\n const outputDetails = recordOrUndefined(source.output_tokens_details)\n const rawInput = source.input_tokens\n const outputTokens = source.output_tokens\n const cacheRead = details?.cached_tokens\n const cacheWrite = details?.cache_write_tokens\n const reasoning = outputDetails?.reasoning_tokens\n const totalTokens = source.total_tokens\n const hasAny = [rawInput, outputTokens, cacheRead, cacheWrite, reasoning, totalTokens]\n .some(value => value !== undefined)\n if (!hasAny) return undefined\n\n const normalized: Record<string, unknown> = {\n ...outputTokens === undefined ? {} : { outputTokens },\n ...totalTokens === undefined ? {} : { totalTokens },\n // Omitted cache details are authoritative zero for Responses. Present\n // malformed values are retained for the accounting validator.\n ...cacheRead === undefined || cacheRead === 0 ? {} : { cacheReadTokens: cacheRead },\n ...cacheWrite === undefined || cacheWrite === 0 ? {} : { cacheWriteTokens: cacheWrite },\n ...reasoning === undefined || reasoning === 0 ? {} : { reasoningTokens: reasoning },\n }\n if (rawInput !== undefined) {\n normalized.inputTokens = typeof rawInput === 'number'\n && (cacheRead === undefined || typeof cacheRead === 'number')\n ? rawInput - (cacheRead ?? 0)\n : rawInput\n }\n return normalized as UsageCounters\n}\n\nfunction recordOrUndefined(value: unknown): Record<string, unknown> | undefined {\n return typeof value === 'object' && value !== null ? value as Record<string, unknown> : undefined\n}\n\n/** Codes that mean \"do not retry this\"; everything else stays retryable. */\nconst TERMINAL_ERROR_CODES: Readonly<Record<string, string>> = Object.freeze({\n context_length_exceeded: CONTEXT_WINDOW_EXCEEDED_CODE,\n insufficient_quota: QUOTA_EXCEEDED_CODE,\n invalid_prompt: MODEL_ERROR_CODES.INVALID_REQUEST,\n bio_policy: MODEL_ERROR_CODES.INVALID_REQUEST,\n cyber_policy: MODEL_ERROR_CODES.INVALID_REQUEST,\n misalignment_policy_violation: MODEL_ERROR_CODES.INVALID_REQUEST,\n rate_limit_exceeded: MODEL_ERROR_CODES.RATE_LIMIT,\n})\n\n/** Turn a `response.failed` payload into a typed, correctly classified error. */\nfunction failedError(response: WireResponse | undefined, displayName: string): ModelError {\n const error = response?.error ?? undefined\n const code = error?.code ?? error?.type\n const message = error?.message ?? `${displayName} reported a failed response`\n const mapped = code === undefined ? undefined : TERMINAL_ERROR_CODES[code]\n return new ModelError(\n message,\n // An unrecognized failure defaults to SERVER, which IS in the retryable set:\n // the request produced nothing, so repeating it is safe and often works.\n mapped ?? MODEL_ERROR_CODES.SERVER,\n {},\n )\n}\n\n/** Build the authoritative block for a completed item. */\nfunction doneBlock(\n item: WireOutputItem,\n open: OpenItem,\n imageMediaType: ImageMediaType,\n): ContentBlock | undefined {\n switch (open.kind) {\n case 'text': {\n const text = itemText(item)\n const phase = textPhase(item.phase) ?? open.phase\n return {\n type: 'text',\n text: text.length > 0 ? text : open.text,\n ...phase === undefined ? {} : { phase },\n ...textAnnotations(item).length === 0 ? {} : { annotations: textAnnotations(item) },\n }\n }\n case 'reasoning': {\n const summary = itemSummary(item)\n const state: ResponsesReasoningState = {\n ...typeof item.id === 'string' ? { id: item.id } : {},\n ...typeof item.encrypted_content === 'string'\n ? { encryptedContent: item.encrypted_content }\n : {},\n ...summary.length > 0 ? { summary } : {},\n }\n return {\n type: 'reasoning',\n text: summary.length > 0 ? summary.join('\\n\\n') : open.text,\n providerState: state,\n }\n }\n case 'tool-call': {\n const args = typeof item.arguments === 'string' && item.arguments.length > 0\n ? item.arguments\n : open.args\n return {\n type: 'tool-call',\n id: ToolCallId(item.call_id ?? open.callId),\n name: item.name ?? open.name,\n arguments: args.length > 0 ? args : '{}',\n }\n }\n case 'native-tool-call': {\n const content: ContentBlock[] = open.nativeName === 'image-generation'\n && typeof item.result === 'string' && item.result.length > 0\n ? [{\n type: 'image',\n source: { kind: 'base64', mediaType: imageMediaType, data: item.result },\n }]\n : []\n return {\n type: 'native-tool-call',\n id: item.id ?? open.callId,\n name: open.nativeName,\n ...typeof item.status === 'string' ? { status: item.status } : {},\n ...isJsonValue(item.action) ? { arguments: item.action } : {},\n content,\n providerState: item,\n }\n }\n default:\n return undefined\n }\n}\n\n/**\n * Translate one Responses SSE stream.\n *\n * Owns termination. This API sends no `[DONE]` sentinel: the stream ends on\n * `response.completed`, `response.failed`, or `response.incomplete`, and a body\n * that ends without one of those was truncated — which is a failure, not an\n * empty success, because a truncated turn cannot be trusted.\n * @param events - decoded SSE events.\n * @param displayName - provider name, used in diagnostics.\n * @returns the chunk stream.\n */\nexport async function* translateResponsesStream(\n events: AsyncIterable<ProtocolSseEvent>,\n displayName: string,\n request?: ProtocolRequest,\n): AsyncGenerator<ProtocolStreamChunk> {\n const open = new Map<string, OpenItem>()\n let nextIndex = 0\n let sawToolCall = false\n let terminated = false\n const imageMediaType = requestedImageMediaType(request)\n\n for await (const raw of events) {\n let event: WireStreamEvent\n try {\n event = JSON.parse(raw.data) as WireStreamEvent\n } catch (error: unknown) {\n throw new ModelError(\n `${displayName} sent a malformed stream event`,\n MODEL_ERROR_CODES.MALFORMED_RESPONSE,\n { cause: error },\n )\n }\n\n switch (event.type) {\n case 'response.output_item.added': {\n const item = event.item\n const id = item?.id ?? event.item_id\n const kind = itemKind(item?.type)\n if (item === undefined || id === undefined || kind === undefined) break\n if (open.has(id)) break\n const entry: OpenItem = {\n index: nextIndex++,\n kind,\n text: '',\n args: '',\n callId: item.call_id ?? id,\n name: item.name ?? '',\n nativeName: nativeName(item.type),\n summaryIndex: undefined,\n phase: textPhase(item.phase),\n }\n open.set(id, entry)\n if (kind === 'tool-call') sawToolCall = true\n yield { type: 'block-start', index: entry.index, blockType: kindToBlockType(kind) }\n break\n }\n\n case 'response.output_text.delta': {\n const entry = event.item_id === undefined ? undefined : open.get(event.item_id)\n if (entry === undefined || event.delta === undefined) break\n entry.text += event.delta\n yield {\n type: 'text-delta', index: entry.index, text: event.delta,\n ...entry.phase === undefined ? {} : { phase: entry.phase },\n }\n break\n }\n\n case 'response.reasoning_summary_text.delta': {\n const entry = event.item_id === undefined ? undefined : open.get(event.item_id)\n if (entry === undefined || event.delta === undefined) break\n // A new summary paragraph starts; separate it from the previous one so the\n // assembled text does not run two thoughts together.\n const separator = entry.summaryIndex !== undefined\n && event.summary_index !== undefined\n && event.summary_index !== entry.summaryIndex\n ? '\\n\\n'\n : ''\n entry.summaryIndex = event.summary_index\n const text = `${separator}${event.delta}`\n entry.text += text\n yield { type: 'reasoning-delta', index: entry.index, text }\n break\n }\n\n case 'response.reasoning_text.delta': {\n const entry = event.item_id === undefined ? undefined : open.get(event.item_id)\n if (entry === undefined || event.delta === undefined) break\n entry.text += event.delta\n yield { type: 'reasoning-delta', index: entry.index, text: event.delta }\n break\n }\n\n case 'response.function_call_arguments.delta': {\n const entry = event.item_id === undefined ? undefined : open.get(event.item_id)\n if (entry === undefined || event.delta === undefined) break\n entry.args += event.delta\n yield {\n type: 'tool-call-delta',\n index: entry.index,\n id: ToolCallId(entry.callId),\n ...entry.name.length > 0 ? { name: entry.name } : {},\n argumentsDelta: event.delta,\n }\n break\n }\n\n case 'response.image_generation_call.partial_image': {\n const itemId = event.item_id\n const entry = itemId === undefined ? undefined : open.get(itemId)\n if (itemId === undefined || entry === undefined || event.partial_image_b64 === undefined) break\n yield {\n type: 'image-delta',\n index: entry.index,\n itemId,\n data: event.partial_image_b64,\n mediaType: imageMediaType,\n ...event.partial_image_index === undefined\n ? {}\n : { partialIndex: event.partial_image_index },\n }\n break\n }\n\n case 'response.output_item.done': {\n const item = event.item\n const id = item?.id ?? event.item_id\n const entry = id === undefined ? undefined : open.get(id)\n if (item === undefined || entry === undefined) break\n const block = doneBlock(item, entry, imageMediaType)\n if (block !== undefined) yield { type: 'block-end', index: entry.index, block }\n break\n }\n\n case 'response.completed': {\n const usage = event.response?.usage ?? undefined\n const mapped = usage === undefined ? undefined : mapUsage(usage)\n if (mapped !== undefined) yield { type: 'usage', usage: mapped }\n // This API has no explicit stop reason. Tool calls in the output ARE the\n // signal that the turn expects results back, which is what an agent loop\n // branches on.\n const reason: FinishReason = sawToolCall ? { kind: 'tool-calls' } : { kind: 'stop' }\n yield { type: 'finish', reason }\n terminated = true\n return\n }\n\n case 'response.incomplete': {\n const usage = event.response?.usage ?? undefined\n const mapped = usage === undefined ? undefined : mapUsage(usage)\n if (mapped !== undefined) yield { type: 'usage', usage: mapped }\n const why = event.response?.incomplete_details?.reason\n if (why === 'max_output_tokens') {\n yield { type: 'finish', reason: { kind: 'max-tokens' } }\n terminated = true\n return\n }\n throw new ModelError(\n `${displayName} returned an incomplete response (${why ?? 'unknown reason'})`,\n MODEL_ERROR_CODES.SERVER,\n )\n }\n\n case 'response.failed':\n throw failedError(event.response, displayName)\n\n case 'error': {\n // A top-level error event carries its fields inline rather than under a\n // `response` object, so it is reshaped to reuse the same classifier.\n const inline: WireErrorBody = {\n ...event.code === undefined ? {} : { code: event.code },\n ...event.message === undefined ? {} : { message: event.message },\n }\n throw failedError({ error: inline }, displayName)\n }\n\n default:\n // Every other lifecycle and progress event (`response.created`,\n // `content_part.*`, `*.done` text echoes, `ping`) carries nothing this\n // protocol needs. Falling through is correct and keeps new event types\n // from breaking the stream.\n break\n }\n }\n\n if (!terminated) {\n throw new ModelError(\n `${displayName} stream ended before the response completed`,\n MODEL_ERROR_CODES.STREAM_CLOSED,\n )\n }\n}\n\n/** Our block-type tag for one item kind. */\nfunction kindToBlockType(kind: ItemKind): 'text' | 'reasoning' | 'tool-call' | 'native-tool-call' {\n return kind\n}\n\nfunction requestedImageMediaType(request: ProtocolRequest | undefined): ImageMediaType {\n const tool = request?.options.tools?.find(candidate => 'type' in candidate\n && candidate.type === 'native'\n && candidate.name === 'image-generation')\n if (tool === undefined || !('format' in tool)) return 'image/png'\n if (tool.format === 'jpeg') return 'image/jpeg'\n if (tool.format === 'webp') return 'image/webp'\n return 'image/png'\n}\n","/**\n * The OpenAI Responses protocol, as a reusable {@link WireProtocol}.\n *\n * Spoken by `api.openai.com`, by the ChatGPT-backed Codex endpoint, and by a\n * growing number of compatible gateways. None of them needs its own translation\n * code — they differ only in the dialect knobs below.\n *\n * @module ai-agent-sdk/providers/protocols/openai-responses\n */\n\nimport type {\n ProtocolDefinition,\n ProtocolRequest,\n ProtocolSseEvent,\n ProtocolStreamChunk,\n} from './contract.ts'\nimport type { ModelTarget, ResolvedModelInfo } from '@alvin0/ai-agent-sdk-core/provider'\nimport { serializeResponsesRequest } from './serialize.ts'\nimport { translateResponsesStream } from './translate.ts'\nimport type { ResponsesDialect } from './wire.ts'\n\n/** Protocol id, usable as a stable string in configuration. */\nexport const OPENAI_RESPONSES_PROTOCOL_ID = 'openai-responses'\n\n/**\n * Conservative defaults.\n *\n * `store: false` because retaining prompts server-side should be an explicit\n * decision, not something an SDK turns on for you. `include` carries\n * `reasoning.encrypted_content` because without it a reasoning model loses its\n * chain of thought between a tool call and the tool's result.\n */\nconst DEFAULT_DIALECT: ResponsesDialect = Object.freeze({\n sampling: true,\n maxOutputTokens: true,\n structuredOutputs: true,\n store: false,\n include: Object.freeze(['reasoning.encrypted_content']),\n reasoningSummary: 'auto',\n})\n\ninterface RuntimeProtocolRequest extends ProtocolRequest {\n readonly model: ResolvedModelInfo\n readonly connection: {\n readonly baseUrl: string\n readonly headers: Readonly<Record<string, string>>\n }\n}\n\n/** Marker-based runtime view, kept structurally independent from provider-http. */\nexport interface ResponsesProtocolDefinition {\n readonly kind: 'http-wire-protocol'\n readonly apiVersion: 1\n readonly id: string\n readonly defaultDialect: ResponsesDialect\n readonly exampleModel?: ModelTarget\n readonly endpointPath: (request: RuntimeProtocolRequest, dialect: ResponsesDialect) => string\n readonly protocolHeaders?: (dialect: ResponsesDialect) => Readonly<Record<string, string>>\n readonly serialize: (\n request: RuntimeProtocolRequest,\n dialect: ResponsesDialect,\n ) => Readonly<Record<string, unknown>>\n readonly translate: (\n events: AsyncIterable<ProtocolSseEvent>,\n request: RuntimeProtocolRequest,\n displayName: string,\n ) => AsyncGenerator<ProtocolStreamChunk>\n}\n\n/** The OpenAI Responses wire protocol. */\nexport const openAiResponsesProtocol: ProtocolDefinition<ResponsesDialect>\n & ResponsesProtocolDefinition = Object.freeze({\n kind: 'http-wire-protocol' as const,\n apiVersion: 1 as const,\n id: OPENAI_RESPONSES_PROTOCOL_ID,\n defaultDialect: DEFAULT_DIALECT,\n endpointPath: () => '/responses',\n serialize(request: ProtocolRequest, dialect: ResponsesDialect): Readonly<Record<string, unknown>> {\n return serializeResponsesRequest(request, dialect) as unknown as Readonly<Record<string, unknown>>\n },\n // Params are annotated because `Object.freeze` erases the contextual typing the\n // `WireProtocol` annotation would otherwise supply.\n translate: (\n events: AsyncIterable<ProtocolSseEvent>,\n request: ProtocolRequest,\n displayName: string,\n ): AsyncGenerator<ProtocolStreamChunk> => translateResponsesStream(events,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AO,iBAAiB,IAC3E,kBAAkB,MACpB;GACF;GAEA,KAAK,mBACH,MAAM,YAAY,MAAM,UAAU,WAAW;GAE/C,KAAK,SAOH,MAAM,YAAY,EAAE,OAAO;IAHzB,GAAG,MAAM,SAAS,SAAY,CAAC,IAAI,EAAE,MAAM,MAAM,KAAK;IACtD,GAAG,MAAM,YAAY,SAAY,CAAC,IAAI,EAAE,SAAS,MAAM,QAAQ;GAEjC,EAAE,GAAG,WAAW;EASpD;CACF;CAEA,IAAI,CAAC,YACH,MAAM,IAAI,WACR,GAAG,YAAY,8CACf,kBAAkB,aACpB;AAEJ;;AAGA,SAAS,gBAAgB,MAAyE;CAChG,OAAO;AACT;AAEA,SAAS,wBAAwB,SAAsD;CACrF,MAAM,OAAO,SAAS,QAAQ,OAAO,MAAK,cAAa,UAAU,aAC5D,UAAU,SAAS,YACnB,UAAU,SAAS,kBAAkB;CAC1C,IAAI,SAAS,UAAa,EAAE,YAAY,OAAO,OAAO;CACtD,IAAI,KAAK,WAAW,QAAQ,OAAO;CACnC,IAAI,KAAK,WAAW,QAAQ,OAAO;CACnC,OAAO;AACT;;;;;ACrcA,MAAa,+BAA+B;;;;;;;;;AAU5C,MAAM,kBAAoC,OAAO,OAAO;CACtD,UAAU;CACV,iBAAiB;CACjB,mBAAmB;CACnB,OAAO;CACP,SAAS,OAAO,OAAO,CAAC,6BAA6B,CAAC;CACtD,kBAAkB;AACpB,CAAC;;AA+BD,MAAa,0BACqB,OAAO,OAAO;CAC9C,MAAM;CACN,YAAY;CACZ,IAAI;CACJ,gBAAgB;CAChB,oBAAoB;CACpB,UAAU,SAA0B,SAA8D;EAChG,OAAO,0BAA0B,SAAS,OAAO;CACnD;CAGA,YACE,QACA,SACA,gBACwC,yBAAyB,QAAQ,aAAa,OAAO;AACjG,CAAC"}
1
+ {"version":3,"file":"index.js","names":["textAnnotations"],"sources":["../src/serialize.ts","../src/translate.ts","../src/protocol.ts"],"sourcesContent":["/**\n * Normalized request to Responses API wire JSON.\n *\n * The interesting work is flattening. Our conversation is a list of messages,\n * each holding an ordered list of content blocks; the wire wants a FLAT list of\n * items where a tool result and a tool call are peers of a message rather than\n * parts of one. So one assistant message that reasoned, spoke, and called two\n * tools expands to four items, and their relative order must be preserved\n * because the model reads it as its own prior turn.\n *\n * @module ai-agent-sdk/providers/responses/serialize\n */\n\nimport type { ProtocolRequest } from './contract.ts'\nimport { MODEL_ERROR_CODES, ModelError } from '@alvin0/ai-agent-sdk-core'\nimport type { ContentBlock, DocumentBlock, ImageBlock, TextBlock } from '@alvin0/ai-agent-sdk-core'\nimport type { Message } from '@alvin0/ai-agent-sdk-core'\nimport {\n isNativeToolSchema,\n type ModelOutputFormat,\n type ModelToolSchema,\n type NativeImageGenerationTool,\n type NativeWebSearchTool,\n type ToolChoice,\n type ToolSchema,\n} from '@alvin0/ai-agent-sdk-core'\nimport type {\n ResponsesDialect,\n WireContentPart,\n WireInputItem,\n WireRequest,\n WireTool,\n WireToolChoice,\n WireTextControls,\n} from './wire.ts'\n\n/**\n * Adapter-private state kept on a {@link ReasoningBlock} so a reasoning item can\n * be echoed back byte-identically on the next request of a tool-use loop.\n */\nexport interface ResponsesReasoningState {\n /** Server-assigned item id. */\n id?: string\n /** Opaque encrypted chain of thought. */\n encryptedContent?: string\n /** Summary paragraphs, in order. */\n summary?: readonly string[]\n}\n\n/** Read the reasoning state back off a block, tolerating anything unexpected. */\nfunction reasoningStateOf(value: unknown): ResponsesReasoningState {\n if (typeof value !== 'object' || value === null) return {}\n const state = value as ResponsesReasoningState\n return {\n ...typeof state.id === 'string' ? { id: state.id } : {},\n ...typeof state.encryptedContent === 'string'\n ? { encryptedContent: state.encryptedContent }\n : {},\n ...Array.isArray(state.summary) ? { summary: state.summary } : {},\n }\n}\n\nfunction textAnnotations(block: TextBlock) {\n return block.annotations?.flatMap(annotation => annotation.type === 'url-citation'\n ? [{\n type: 'url_citation' as const,\n url: annotation.url,\n ...annotation.title === undefined ? {} : { title: annotation.title },\n ...annotation.startIndex === undefined ? {} : { start_index: annotation.startIndex },\n ...annotation.endIndex === undefined ? {} : { end_index: annotation.endIndex },\n }]\n : [])\n}\n\nfunction imagePart(block: ImageBlock): WireContentPart {\n const detail = block.detail\n if (block.source.kind === 'file') {\n return { type: 'input_image', file_id: block.source.fileId, ...detail === undefined ? {} : { detail } }\n }\n const image_url = block.source.kind === 'url'\n ? block.source.url\n : `data:${block.source.mediaType};base64,${block.source.data}`\n return { type: 'input_image', image_url, ...detail === undefined ? {} : { detail } }\n}\n\n/** Fallback file name for an inline document, since the API infers type from it. */\nconst DEFAULT_DOCUMENT_FILENAME = 'document.pdf'\n\nfunction documentPart(block: DocumentBlock): WireContentPart {\n if (block.source.kind === 'file') return { type: 'input_file', file_id: block.source.fileId }\n if (block.source.kind === 'url') return { type: 'input_file', file_url: block.source.url }\n return {\n type: 'input_file',\n // The API reads the file type from the extension here, so a name is required\n // rather than optional; a neutral default beats a rejected request.\n filename: block.filename ?? DEFAULT_DOCUMENT_FILENAME,\n file_data: `data:${block.source.mediaType};base64,${block.source.data}`,\n }\n}\n\n/** Convert one content block to a request-side content part. */\nfunction contentPart(block: ContentBlock, role: 'user' | 'assistant'): WireContentPart | undefined {\n if (block.type === 'text') {\n // An assistant turn's own text must come back as `output_text`; sending it as\n // `input_text` would present the model's prior words as if the user said them.\n if (role !== 'assistant') return { type: 'input_text', text: block.text }\n const annotations = textAnnotations(block)\n return {\n type: 'output_text', text: block.text,\n ...annotations === undefined ? {} : { annotations },\n }\n }\n if (block.type === 'image') return imagePart(block)\n if (block.type === 'document') return documentPart(block)\n return undefined\n}\n\n/** Render a tool result's blocks as the wire's polymorphic `output` value. */\nfunction toolResultOutput(blocks: readonly ContentBlock[]): string | WireContentPart[] {\n const hasBinary = blocks.some(block => block.type === 'image' || block.type === 'document')\n if (!hasBinary) {\n // The common case. A plain string keeps the payload small and is what the\n // API documents first.\n return blocks\n .filter((block): block is Extract<ContentBlock, { type: 'text' }> => block.type === 'text')\n .map(block => block.text)\n .join('\\n')\n }\n return blocks\n .map(block => contentPart(block, 'user'))\n .filter((part): part is WireContentPart => part !== undefined)\n}\n\n/**\n * Expand one message into zero or more wire items, appending them in order.\n *\n * Content parts accumulate into a single message item, which is FLUSHED whenever\n * a block appears that has to become its own top-level item. That flushing is\n * what preserves \"spoke, then called a tool, then spoke again\" as three items in\n * the right order instead of collapsing it.\n */\nfunction appendMessage(message: Message, items: WireInputItem[], dialectMessagePhase: boolean): void {\n const role = message.role === 'assistant' ? 'assistant' : 'user'\n let parts: WireContentPart[] = []\n let phase: Extract<ContentBlock, { type: 'text' }>['phase']\n\n const flush = (): void => {\n if (parts.length === 0) return\n items.push({\n type: 'message', role, content: parts,\n ...role === 'assistant' && dialectMessagePhase && phase !== undefined\n ? { phase: phase === 'final-answer' ? 'final_answer' as const : phase }\n : {},\n })\n parts = []\n phase = undefined\n }\n\n for (const block of message.content) {\n switch (block.type) {\n case 'text':\n case 'image':\n case 'document': {\n if (block.type === 'text' && block.phase !== undefined && phase !== undefined && phase !== block.phase) flush()\n if (block.type === 'text' && block.phase !== undefined) phase = block.phase\n const part = contentPart(block, role)\n if (part !== undefined) parts.push(part)\n break\n }\n case 'reasoning': {\n flush()\n const state = reasoningStateOf(block.providerState)\n // Prefer the recorded summary paragraphs; fall back to the block's text so\n // a hand-built or replayed message still carries something.\n const summary = state.summary !== undefined && state.summary.length > 0\n ? state.summary\n : block.text.length > 0 ? [block.text] : []\n items.push({\n type: 'reasoning',\n ...state.id === undefined ? {} : { id: state.id },\n summary: summary.map(text => ({ type: 'summary_text' as const, text })),\n ...state.encryptedContent === undefined\n ? {}\n : { encrypted_content: state.encryptedContent },\n })\n break\n }\n case 'tool-call': {\n flush()\n items.push({\n type: 'function_call',\n call_id: block.id,\n name: block.name,\n // Empty arguments must still be valid JSON, or the provider rejects it.\n arguments: block.arguments.length > 0 ? block.arguments : '{}',\n })\n break\n }\n case 'tool-result': {\n flush()\n items.push({\n type: 'function_call_output',\n call_id: block.toolCallId,\n output: toolResultOutput(block.content),\n })\n break\n }\n case 'native-tool-call': {\n flush()\n const replay = nativeReplayItem(block.providerState)\n if (replay !== undefined) items.push(replay)\n break\n }\n default:\n // A content block introduced by declaration merging. Skipping is correct:\n // this serializer cannot know its wire form, and inventing one would\n // corrupt the request.\n break\n }\n }\n flush()\n}\n\n/** Collect the system prompt from the request plus any system-role messages. */\nfunction instructionsOf(request: ProtocolRequest): string {\n const fromMessages = request.options.messages\n .filter(message => message.role === 'system')\n .flatMap(message => message.content)\n .filter((block): block is Extract<ContentBlock, { type: 'text' }> => block.type === 'text')\n .map(block => block.text)\n const all = request.options.system === undefined\n ? fromMessages\n : [request.options.system, ...fromMessages]\n return all.join('\\n\\n')\n}\n\n/** Map the neutral tool-choice vocabulary onto this API's. */\nfunction toolChoiceOf(choice: ToolChoice): WireToolChoice {\n if (typeof choice === 'string') return choice\n if (choice.type === 'native') return { type: nativeWireType(choice.name) }\n return { type: 'function', name: choice.name }\n}\n\n/** Map a tool schema; `strict: false` because caller schemas are not vetted. */\nfunction functionTool(tool: ToolSchema): WireTool {\n return {\n type: 'function',\n name: tool.name,\n description: tool.description,\n // Strict mode imposes real JSON-Schema restrictions (no optional fields\n // without null, `additionalProperties: false` required). Opting a caller's\n // schema in silently would turn a working tool into a request rejection.\n strict: false,\n parameters: tool.parameters,\n }\n}\n\nfunction nativeWireType(name: string): string {\n if (name === 'web-search') return 'web_search'\n if (name === 'image-generation') return 'image_generation'\n return name.replaceAll('-', '_')\n}\n\nfunction webSearchTool(tool: NativeWebSearchTool): WireTool {\n if (tool.blockedDomains !== undefined) {\n throw new ModelError(\n 'OpenAI Responses web search does not support blockedDomains; use allowedDomains',\n MODEL_ERROR_CODES.INVALID_REQUEST,\n )\n }\n if (tool.maxUses !== undefined) {\n throw new ModelError(\n 'OpenAI Responses web search does not support maxUses',\n MODEL_ERROR_CODES.INVALID_REQUEST,\n )\n }\n return {\n type: 'web_search',\n ...tool.searchContextSize === undefined ? {} : { search_context_size: tool.searchContextSize },\n ...tool.allowedDomains === undefined ? {} : { filters: { allowed_domains: [...tool.allowedDomains] } },\n ...tool.userLocation === undefined ? {} : {\n user_location: { type: 'approximate', ...tool.userLocation },\n },\n }\n}\n\nfunction imageGenerationTool(tool: NativeImageGenerationTool): WireTool {\n return {\n type: 'image_generation',\n ...tool.size === undefined ? {} : { size: tool.size },\n ...tool.quality === undefined ? {} : { quality: tool.quality },\n ...tool.format === undefined ? {} : { output_format: tool.format },\n ...tool.background === undefined ? {} : { background: tool.background },\n ...tool.partialImages === undefined ? {} : { partial_images: tool.partialImages },\n }\n}\n\nfunction toolOf(tool: ModelToolSchema): WireTool {\n if (!isNativeToolSchema(tool)) return functionTool(tool)\n if (tool.name === 'web-search') return webSearchTool(tool)\n return imageGenerationTool(tool)\n}\n\nfunction textControls(\n format: ModelOutputFormat | undefined,\n dialect: ResponsesDialect,\n): WireTextControls | undefined {\n if (format === undefined) return undefined\n if (format.type === 'text') {\n return dialect.structuredOutputs ? { format: { type: 'text' } } : undefined\n }\n if (!dialect.structuredOutputs) {\n throw new ModelError(\n 'This Responses endpoint does not support JSON Schema output',\n MODEL_ERROR_CODES.INVALID_REQUEST,\n )\n }\n return {\n format: {\n type: 'json_schema',\n name: format.name,\n schema: format.schema,\n strict: true,\n },\n }\n}\n\nfunction nativeReplayItem(value: unknown): WireInputItem | undefined {\n if (typeof value !== 'object' || value === null) return undefined\n const item = value as Record<string, unknown>\n if (item.type === 'web_search_call') {\n return {\n type: 'web_search_call',\n ...typeof item.id === 'string' ? { id: item.id } : {},\n ...typeof item.status === 'string' ? { status: item.status } : {},\n ...item.action === undefined ? {} : { action: structuredClone(item.action) },\n }\n }\n if (item.type === 'image_generation_call') {\n return {\n type: 'image_generation_call',\n ...typeof item.id === 'string' ? { id: item.id } : {},\n ...typeof item.status === 'string' ? { status: item.status } : {},\n ...typeof item.result === 'string' || item.result === null ? { result: item.result } : {},\n }\n }\n return undefined\n}\n\n/**\n * Build the Responses request body.\n * @param request - the resolved request, model, and connection.\n * @param dialect - which optional fields this endpoint accepts.\n * @returns the wire body, ready to serialize.\n */\nexport function serializeResponsesRequest(\n request: ProtocolRequest,\n dialect: ResponsesDialect,\n): WireRequest {\n const { options } = request\n const input: WireInputItem[] = []\n for (const message of options.messages) {\n if (message.role === 'system') continue // folded into `instructions`\n appendMessage(message, input, dialect.messagePhase === true)\n }\n\n const instructions = instructionsOf(request)\n const tools = options.tools === undefined || options.tools.length === 0\n ? undefined\n : options.tools.map(toolOf)\n const text = textControls(options.outputFormat, dialect)\n\n return {\n model: options.model,\n ...instructions.length === 0 ? {} : { instructions },\n input,\n ...tools === undefined ? {} : { tools },\n ...options.toolChoice === undefined ? {} : { tool_choice: toolChoiceOf(options.toolChoice) },\n ...tools === undefined ? {} : { parallel_tool_calls: true },\n ...options.reasoningEffort === undefined && dialect.reasoningSummary === undefined\n ? {}\n : {\n reasoning: {\n ...options.reasoningEffort === undefined\n ? {}\n : { effort: String(options.reasoningEffort) },\n ...dialect.reasoningSummary === undefined\n ? {}\n : { summary: dialect.reasoningSummary },\n },\n },\n ...text === undefined ? {} : { text },\n ...dialect.store === undefined ? {} : { store: dialect.store },\n stream: true,\n ...dialect.include.length === 0 ? {} : { include: [...dialect.include] },\n ...dialect.promptCacheKey === undefined ? {} : { prompt_cache_key: dialect.promptCacheKey },\n ...dialect.maxOutputTokens && request.maxTokens !== undefined\n ? { max_output_tokens: request.maxTokens }\n : {},\n ...dialect.sampling && options.temperature !== undefined\n ? { temperature: options.temperature }\n : {},\n ...dialect.sampling && options.topP !== undefined ? { top_p: options.topP } : {},\n }\n}\n","/**\n * Responses API SSE events to the SDK's chunk protocol.\n *\n * Two design notes worth reading before changing anything here.\n *\n * First, block correlation is keyed on `item_id`, not on the provider's\n * `output_index`. Item ids are stable and present on every delta event, whereas\n * index fields vary by event type, so keying on the id and assigning our OWN\n * indices in first-seen order is both simpler and closer to what our protocol\n * promises.\n *\n * Second, reasoning state is carried on the reasoning BLOCK\n * (`ReasoningBlock.providerState`) rather than in the stream's `replayState`\n * envelope. The envelope has to stay positionally aligned with emitted blocks and\n * is discarded whole when it drifts; attaching the state to the block it belongs\n * to cannot drift, and it survives assembly for free.\n *\n * @module ai-agent-sdk/providers/responses/translate\n */\n\nimport {\n CONTEXT_WINDOW_EXCEEDED_CODE,\n QUOTA_EXCEEDED_CODE,\n} from '@alvin0/ai-agent-sdk-core'\nimport { MODEL_ERROR_CODES, ModelError } from '@alvin0/ai-agent-sdk-core'\nimport { ToolCallId } from '@alvin0/ai-agent-sdk-core'\nimport { isJsonValue } from '@alvin0/ai-agent-sdk-core'\nimport type {\n AssistantTextPhase,\n ContentBlock,\n ImageMediaType,\n TextAnnotation,\n} from '@alvin0/ai-agent-sdk-core'\nimport type { FinishReason, UsageCounters } from '@alvin0/ai-agent-sdk-core'\nimport type { ProtocolRequest, ProtocolSseEvent, ProtocolStreamChunk } from './contract.ts'\nimport type { ResponsesReasoningState } from './serialize.ts'\nimport type {\n WireErrorBody,\n WireOutputItem,\n WireResponse,\n WireStreamEvent,\n WireUsage,\n} from './wire.ts'\n\n/** Which of our block types one output item maps to. */\ntype ItemKind = 'text' | 'reasoning' | 'tool-call' | 'native-tool-call'\n\ninterface OpenItem {\n readonly index: number\n readonly kind: ItemKind\n text: string\n args: string\n callId: string\n name: string\n nativeName: string\n /** Last `summary_index` seen, so a new paragraph gets a separator. */\n summaryIndex: number | undefined\n phase: AssistantTextPhase | undefined\n}\n\nfunction textPhase(value: string | undefined): AssistantTextPhase | undefined {\n if (value === 'commentary') return 'commentary'\n if (value === 'final_answer') return 'final-answer'\n return undefined\n}\n\n/** Map an output item's wire type onto one of our block types. */\nfunction itemKind(type: string | undefined): ItemKind | undefined {\n switch (type) {\n case 'message': return 'text'\n case 'reasoning': return 'reasoning'\n case 'function_call': return 'tool-call'\n case 'web_search_call': return 'native-tool-call'\n case 'image_generation_call': return 'native-tool-call'\n default: return undefined\n }\n}\n\nfunction nativeName(type: string | undefined): string {\n if (type === 'web_search_call') return 'web-search'\n if (type === 'image_generation_call') return 'image-generation'\n return type?.replace(/_call$/, '').replaceAll('_', '-') ?? 'native-tool'\n}\n\nfunction textAnnotations(item: WireOutputItem): TextAnnotation[] {\n if (!Array.isArray(item.content)) return []\n return item.content.flatMap((part) => {\n if (typeof part !== 'object' || part === null) return []\n const annotations = (part as Record<string, unknown>).annotations\n if (!Array.isArray(annotations)) return []\n return annotations.flatMap((annotation): TextAnnotation[] => {\n if (typeof annotation !== 'object' || annotation === null) return []\n const record = annotation as Record<string, unknown>\n if (record.type !== 'url_citation' || typeof record.url !== 'string') return []\n return [{\n type: 'url-citation',\n url: record.url,\n ...typeof record.title === 'string' ? { title: record.title } : {},\n ...typeof record.start_index === 'number' ? { startIndex: record.start_index } : {},\n ...typeof record.end_index === 'number' ? { endIndex: record.end_index } : {},\n }]\n })\n })\n}\n\n/** Collect the text of a done item's `content` array. */\nfunction itemText(item: WireOutputItem): string {\n const content = item.content\n if (!Array.isArray(content)) return ''\n return content\n .map((part) => {\n if (typeof part !== 'object' || part === null) return ''\n const record = part as Record<string, unknown>\n return typeof record.text === 'string' ? record.text : ''\n })\n .join('')\n}\n\n/** Collect the summary paragraphs of a done reasoning item. */\nfunction itemSummary(item: WireOutputItem): string[] {\n const summary = item.summary\n if (!Array.isArray(summary)) return []\n return summary\n .map((part) => {\n if (typeof part !== 'object' || part === null) return ''\n const record = part as Record<string, unknown>\n return typeof record.text === 'string' ? record.text : ''\n })\n .filter(text => text.length > 0)\n}\n\n/**\n * Normalize usage, honouring the SDK's disjoint-count convention.\n *\n * This API reports `input_tokens` as the TOTAL input and\n * `input_tokens_details.cached_tokens` as a subset of it. Our convention is that\n * the three input figures are disjoint and sum to what is billed, so the cached\n * portion is subtracted back out here. Skip that and every cost estimate\n * double-counts cache hits.\n */\nfunction mapUsage(usage: WireUsage): UsageCounters | undefined {\n const source = usage as unknown as Record<string, unknown>\n const details = recordOrUndefined(source.input_tokens_details)\n const outputDetails = recordOrUndefined(source.output_tokens_details)\n const rawInput = source.input_tokens\n const outputTokens = source.output_tokens\n const cacheRead = details?.cached_tokens\n const cacheWrite = details?.cache_write_tokens\n const reasoning = outputDetails?.reasoning_tokens\n const totalTokens = source.total_tokens\n const hasAny = [rawInput, outputTokens, cacheRead, cacheWrite, reasoning, totalTokens]\n .some(value => value !== undefined)\n if (!hasAny) return undefined\n\n const normalized: Record<string, unknown> = {\n ...outputTokens === undefined ? {} : { outputTokens },\n ...totalTokens === undefined ? {} : { totalTokens },\n // Omitted cache details are authoritative zero for Responses. Present\n // malformed values are retained for the accounting validator.\n ...cacheRead === undefined || cacheRead === 0 ? {} : { cacheReadTokens: cacheRead },\n ...cacheWrite === undefined || cacheWrite === 0 ? {} : { cacheWriteTokens: cacheWrite },\n ...reasoning === undefined || reasoning === 0 ? {} : { reasoningTokens: reasoning },\n }\n if (rawInput !== undefined) {\n normalized.inputTokens = typeof rawInput === 'number'\n && (cacheRead === undefined || typeof cacheRead === 'number')\n ? rawInput - (cacheRead ?? 0)\n : rawInput\n }\n return normalized as UsageCounters\n}\n\nfunction recordOrUndefined(value: unknown): Record<string, unknown> | undefined {\n return typeof value === 'object' && value !== null ? value as Record<string, unknown> : undefined\n}\n\n/** Codes that mean \"do not retry this\"; everything else stays retryable. */\nconst TERMINAL_ERROR_CODES: Readonly<Record<string, string>> = Object.freeze({\n context_length_exceeded: CONTEXT_WINDOW_EXCEEDED_CODE,\n insufficient_quota: QUOTA_EXCEEDED_CODE,\n invalid_prompt: MODEL_ERROR_CODES.INVALID_REQUEST,\n bio_policy: MODEL_ERROR_CODES.INVALID_REQUEST,\n cyber_policy: MODEL_ERROR_CODES.INVALID_REQUEST,\n misalignment_policy_violation: MODEL_ERROR_CODES.INVALID_REQUEST,\n rate_limit_exceeded: MODEL_ERROR_CODES.RATE_LIMIT,\n})\n\n/** Turn a `response.failed` payload into a typed, correctly classified error. */\nfunction failedError(response: WireResponse | undefined, displayName: string): ModelError {\n const error = response?.error ?? undefined\n const code = error?.code ?? error?.type\n const message = error?.message ?? `${displayName} reported a failed response`\n const mapped = code === undefined ? undefined : TERMINAL_ERROR_CODES[code]\n return new ModelError(\n message,\n // An unrecognized failure defaults to SERVER, which IS in the retryable set:\n // the request produced nothing, so repeating it is safe and often works.\n mapped ?? MODEL_ERROR_CODES.SERVER,\n {},\n )\n}\n\n/** Build the authoritative block for a completed item. */\nfunction doneBlock(\n item: WireOutputItem,\n open: OpenItem,\n imageMediaType: ImageMediaType,\n): ContentBlock | undefined {\n switch (open.kind) {\n case 'text': {\n const text = itemText(item)\n const phase = textPhase(item.phase) ?? open.phase\n return {\n type: 'text',\n text: text.length > 0 ? text : open.text,\n ...phase === undefined ? {} : { phase },\n ...textAnnotations(item).length === 0 ? {} : { annotations: textAnnotations(item) },\n }\n }\n case 'reasoning': {\n const summary = itemSummary(item)\n const state: ResponsesReasoningState = {\n ...typeof item.id === 'string' ? { id: item.id } : {},\n ...typeof item.encrypted_content === 'string'\n ? { encryptedContent: item.encrypted_content }\n : {},\n ...summary.length > 0 ? { summary } : {},\n }\n return {\n type: 'reasoning',\n text: summary.length > 0 ? summary.join('\\n\\n') : open.text,\n providerState: state,\n }\n }\n case 'tool-call': {\n const args = typeof item.arguments === 'string' && item.arguments.length > 0\n ? item.arguments\n : open.args\n return {\n type: 'tool-call',\n id: ToolCallId(item.call_id ?? open.callId),\n name: item.name ?? open.name,\n arguments: args.length > 0 ? args : '{}',\n }\n }\n case 'native-tool-call': {\n const content: ContentBlock[] = open.nativeName === 'image-generation'\n && typeof item.result === 'string' && item.result.length > 0\n ? [{\n type: 'image',\n source: { kind: 'base64', mediaType: imageMediaType, data: item.result },\n }]\n : []\n return {\n type: 'native-tool-call',\n id: item.id ?? open.callId,\n name: open.nativeName,\n ...typeof item.status === 'string' ? { status: item.status } : {},\n ...isJsonValue(item.action) ? { arguments: item.action } : {},\n content,\n providerState: item,\n }\n }\n default:\n return undefined\n }\n}\n\n/**\n * Translate one Responses SSE stream.\n *\n * Owns termination. This API sends no `[DONE]` sentinel: the stream ends on\n * `response.completed`, `response.failed`, or `response.incomplete`, and a body\n * that ends without one of those was truncated — which is a failure, not an\n * empty success, because a truncated turn cannot be trusted.\n * @param events - decoded SSE events.\n * @param displayName - provider name, used in diagnostics.\n * @returns the chunk stream.\n */\nexport async function* translateResponsesStream(\n events: AsyncIterable<ProtocolSseEvent>,\n displayName: string,\n request?: ProtocolRequest,\n): AsyncGenerator<ProtocolStreamChunk> {\n const open = new Map<string, OpenItem>()\n let nextIndex = 0\n let sawToolCall = false\n let terminated = false\n const imageMediaType = requestedImageMediaType(request)\n\n for await (const raw of events) {\n let event: WireStreamEvent\n try {\n event = JSON.parse(raw.data) as WireStreamEvent\n } catch (error: unknown) {\n throw new ModelError(\n `${displayName} sent a malformed stream event`,\n MODEL_ERROR_CODES.MALFORMED_RESPONSE,\n { cause: error },\n )\n }\n\n switch (event.type) {\n case 'response.output_item.added': {\n const item = event.item\n const id = item?.id ?? event.item_id\n const kind = itemKind(item?.type)\n if (item === undefined || id === undefined || kind === undefined) break\n if (open.has(id)) break\n const entry: OpenItem = {\n index: nextIndex++,\n kind,\n text: '',\n args: '',\n callId: item.call_id ?? id,\n name: item.name ?? '',\n nativeName: nativeName(item.type),\n summaryIndex: undefined,\n phase: textPhase(item.phase),\n }\n open.set(id, entry)\n if (kind === 'tool-call') sawToolCall = true\n yield { type: 'block-start', index: entry.index, blockType: kindToBlockType(kind) }\n break\n }\n\n case 'response.output_text.delta': {\n const entry = event.item_id === undefined ? undefined : open.get(event.item_id)\n if (entry === undefined || event.delta === undefined) break\n entry.text += event.delta\n yield {\n type: 'text-delta', index: entry.index, text: event.delta,\n ...entry.phase === undefined ? {} : { phase: entry.phase },\n }\n break\n }\n\n case 'response.reasoning_summary_text.delta': {\n const entry = event.item_id === undefined ? undefined : open.get(event.item_id)\n if (entry === undefined || event.delta === undefined) break\n // A new summary paragraph starts; separate it from the previous one so the\n // assembled text does not run two thoughts together.\n const separator = entry.summaryIndex !== undefined\n && event.summary_index !== undefined\n && event.summary_index !== entry.summaryIndex\n ? '\\n\\n'\n : ''\n entry.summaryIndex = event.summary_index\n const text = `${separator}${event.delta}`\n entry.text += text\n yield { type: 'reasoning-delta', index: entry.index, text }\n break\n }\n\n case 'response.reasoning_text.delta': {\n const entry = event.item_id === undefined ? undefined : open.get(event.item_id)\n if (entry === undefined || event.delta === undefined) break\n entry.text += event.delta\n yield { type: 'reasoning-delta', index: entry.index, text: event.delta }\n break\n }\n\n case 'response.function_call_arguments.delta': {\n const entry = event.item_id === undefined ? undefined : open.get(event.item_id)\n if (entry === undefined || event.delta === undefined) break\n entry.args += event.delta\n yield {\n type: 'tool-call-delta',\n index: entry.index,\n id: ToolCallId(entry.callId),\n ...entry.name.length > 0 ? { name: entry.name } : {},\n argumentsDelta: event.delta,\n }\n break\n }\n\n case 'response.image_generation_call.partial_image': {\n const itemId = event.item_id\n const entry = itemId === undefined ? undefined : open.get(itemId)\n if (itemId === undefined || entry === undefined || event.partial_image_b64 === undefined) break\n yield {\n type: 'image-delta',\n index: entry.index,\n itemId,\n data: event.partial_image_b64,\n mediaType: imageMediaType,\n ...event.partial_image_index === undefined\n ? {}\n : { partialIndex: event.partial_image_index },\n }\n break\n }\n\n case 'response.output_item.done': {\n const item = event.item\n const id = item?.id ?? event.item_id\n const entry = id === undefined ? undefined : open.get(id)\n if (item === undefined || entry === undefined) break\n const block = doneBlock(item, entry, imageMediaType)\n if (block !== undefined) yield { type: 'block-end', index: entry.index, block }\n break\n }\n\n case 'response.completed': {\n const usage = event.response?.usage ?? undefined\n const mapped = usage === undefined ? undefined : mapUsage(usage)\n if (mapped !== undefined) yield { type: 'usage', usage: mapped }\n // This API has no explicit stop reason. Tool calls in the output ARE the\n // signal that the turn expects results back, which is what an agent loop\n // branches on.\n const reason: FinishReason = sawToolCall ? { kind: 'tool-calls' } : { kind: 'stop' }\n yield { type: 'finish', reason }\n terminated = true\n return\n }\n\n case 'response.incomplete': {\n const usage = event.response?.usage ?? undefined\n const mapped = usage === undefined ? undefined : mapUsage(usage)\n if (mapped !== undefined) yield { type: 'usage', usage: mapped }\n const why = event.response?.incomplete_details?.reason\n if (why === 'max_output_tokens') {\n yield { type: 'finish', reason: { kind: 'max-tokens' } }\n terminated = true\n return\n }\n throw new ModelError(\n `${displayName} returned an incomplete response (${why ?? 'unknown reason'})`,\n MODEL_ERROR_CODES.SERVER,\n )\n }\n\n case 'response.failed':\n throw failedError(event.response, displayName)\n\n case 'error': {\n // A top-level error event carries its fields inline rather than under a\n // `response` object, so it is reshaped to reuse the same classifier.\n const inline: WireErrorBody = {\n ...event.code === undefined ? {} : { code: event.code },\n ...event.message === undefined ? {} : { message: event.message },\n }\n throw failedError({ error: inline }, displayName)\n }\n\n default:\n // Every other lifecycle and progress event (`response.created`,\n // `content_part.*`, `*.done` text echoes, `ping`) carries nothing this\n // protocol needs. Falling through is correct and keeps new event types\n // from breaking the stream.\n break\n }\n }\n\n if (!terminated) {\n throw new ModelError(\n `${displayName} stream ended before the response completed`,\n MODEL_ERROR_CODES.STREAM_CLOSED,\n )\n }\n}\n\n/** Our block-type tag for one item kind. */\nfunction kindToBlockType(kind: ItemKind): 'text' | 'reasoning' | 'tool-call' | 'native-tool-call' {\n return kind\n}\n\nfunction requestedImageMediaType(request: ProtocolRequest | undefined): ImageMediaType {\n const tool = request?.options.tools?.find(candidate => 'type' in candidate\n && candidate.type === 'native'\n && candidate.name === 'image-generation')\n if (tool === undefined || !('format' in tool)) return 'image/png'\n if (tool.format === 'jpeg') return 'image/jpeg'\n if (tool.format === 'webp') return 'image/webp'\n return 'image/png'\n}\n","/**\n * The OpenAI Responses protocol, as a reusable {@link WireProtocol}.\n *\n * Spoken by `api.openai.com`, by the ChatGPT-backed Codex endpoint, and by a\n * growing number of compatible gateways. None of them needs its own translation\n * code — they differ only in the dialect knobs below.\n *\n * @module ai-agent-sdk/providers/protocols/openai-responses\n */\n\nimport type {\n ProtocolDefinition,\n ProtocolRequest,\n ProtocolSseEvent,\n ProtocolStreamChunk,\n} from './contract.ts'\nimport type { ModelTarget, ResolvedModelInfo } from '@alvin0/ai-agent-sdk-core/provider'\nimport { serializeResponsesRequest } from './serialize.ts'\nimport { translateResponsesStream } from './translate.ts'\nimport type { ResponsesDialect } from './wire.ts'\n\n/** Protocol id, usable as a stable string in configuration. */\nexport const OPENAI_RESPONSES_PROTOCOL_ID = 'openai-responses'\n\n/**\n * Conservative defaults.\n *\n * `store: false` because retaining prompts server-side should be an explicit\n * decision, not something an SDK turns on for you. `include` carries\n * `reasoning.encrypted_content` because without it a reasoning model loses its\n * chain of thought between a tool call and the tool's result.\n */\nconst DEFAULT_DIALECT: ResponsesDialect = Object.freeze({\n sampling: true,\n maxOutputTokens: true,\n structuredOutputs: true,\n store: false,\n include: Object.freeze(['reasoning.encrypted_content']),\n reasoningSummary: 'auto',\n})\n\ninterface RuntimeProtocolRequest extends ProtocolRequest {\n readonly model: ResolvedModelInfo\n readonly connection: {\n readonly baseUrl: string\n readonly headers: Readonly<Record<string, string>>\n }\n}\n\n/** Marker-based runtime view, kept structurally independent from provider-http. */\nexport interface ResponsesProtocolDefinition {\n readonly kind: 'http-wire-protocol'\n readonly apiVersion: 1\n readonly id: string\n readonly defaultDialect: ResponsesDialect\n readonly exampleModel?: ModelTarget\n readonly endpointPath: (request: RuntimeProtocolRequest, dialect: ResponsesDialect) => string\n readonly protocolHeaders?: (dialect: ResponsesDialect) => Readonly<Record<string, string>>\n readonly serialize: (\n request: RuntimeProtocolRequest,\n dialect: ResponsesDialect,\n ) => Readonly<Record<string, unknown>>\n readonly translate: (\n events: AsyncIterable<ProtocolSseEvent>,\n request: RuntimeProtocolRequest,\n displayName: string,\n ) => AsyncGenerator<ProtocolStreamChunk>\n}\n\n/** The OpenAI Responses wire protocol. */\nexport const openAiResponsesProtocol: ProtocolDefinition<ResponsesDialect>\n & ResponsesProtocolDefinition = Object.freeze({\n kind: 'http-wire-protocol' as const,\n apiVersion: 1 as const,\n id: OPENAI_RESPONSES_PROTOCOL_ID,\n defaultDialect: DEFAULT_DIALECT,\n endpointPath: () => '/responses',\n serialize(request: ProtocolRequest, dialect: ResponsesDialect): Readonly<Record<string, unknown>> {\n return serializeResponsesRequest(request, dialect) as unknown as Readonly<Record<string, unknown>>\n },\n // Params are annotated because `Object.freeze` erases the contextual typing the\n // `WireProtocol` annotation would otherwise supply.\n translate: (\n events: AsyncIterable<ProtocolSseEvent>,\n request: ProtocolRequest,\n displayName: string,\n ): AsyncGenerator<ProtocolStreamChunk> => translateResponsesStream(events, displayName, request),\n})\n\nexport type { ResponsesDialect }\n"],"mappings":";;;;AAkDA,SAAS,iBAAiB,OAAyC;CACjE,IAAI,OAAO,UAAU,YAAY,UAAU,MAAM,OAAO,CAAC;CACzD,MAAM,QAAQ;CACd,OAAO;EACL,GAAG,OAAO,MAAM,OAAO,WAAW,EAAE,IAAI,MAAM,GAAG,IAAI,CAAC;EACtD,GAAG,OAAO,MAAM,qBAAqB,WACjC,EAAE,kBAAkB,MAAM,iBAAiB,IAC3C,CAAC;EACL,GAAG,MAAM,QAAQ,MAAM,OAAO,IAAI,EAAE,SAAS,MAAM,QAAQ,IAAI,CAAC;CAClE;AACF;AAEA,SAASA,kBAAgB,OAAkB;CACzC,OAAO,MAAM,aAAa,SAAQ,eAAc,WAAW,SAAS,iBAChE,CAAC;EACD,MAAM;EACN,KAAK,WAAW;EAChB,GAAG,WAAW,UAAU,SAAY,CAAC,IAAI,EAAE,OAAO,WAAW,MAAM;EACnE,GAAG,WAAW,eAAe,SAAY,CAAC,IAAI,EAAE,aAAa,WAAW,WAAW;EACnF,GAAG,WAAW,aAAa,SAAY,CAAC,IAAI,EAAE,WAAW,WAAW,SAAS;CAC/E,CAAC,IACC,CAAC,CAAC;AACR;AAEA,SAAS,UAAU,OAAoC;CACrD,MAAM,SAAS,MAAM;CACrB,IAAI,MAAM,OAAO,SAAS,QACxB,OAAO;EAAE,MAAM;EAAe,SAAS,MAAM,OAAO;EAAQ,GAAG,WAAW,SAAY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AAO,CAAC,6BAA6B,CAAC;CACtD,kBAAkB;AACpB,CAAC;;AA+BD,MAAa,0BACqB,OAAO,OAAO;CAC9C,MAAM;CACN,YAAY;CACZ,IAAI;CACJ,gBAAgB;CAChB,oBAAoB;CACpB,UAAU,SAA0B,SAA8D;EAChG,OAAO,0BAA0B,SAAS,OAAO;CACnD;CAGA,YACE,QACA,SACA,gBACwC,yBAAyB,QAAQ,aAAa,OAAO;AACjG,CAAC"}
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "name": "alvin0 - chaulamdinhai",
5
5
  "email": "chaulamdinhai@gmail.com"
6
6
  },
7
- "version": "0.1.2",
7
+ "version": "0.1.4",
8
8
  "description": "Universal OpenAI Responses and Codex wire schema, serializer, translator, and dialect for ai-agent-sdk",
9
9
  "license": "MIT",
10
10
  "repository": {
@@ -38,10 +38,10 @@
38
38
  "provenance": true
39
39
  },
40
40
  "peerDependencies": {
41
- "@alvin0/ai-agent-sdk-core": "^0.1.2"
41
+ "@alvin0/ai-agent-sdk-core": "^0.1.4"
42
42
  },
43
43
  "devDependencies": {
44
- "@alvin0/ai-agent-sdk-core": "^0.1.2",
44
+ "@alvin0/ai-agent-sdk-core": "^0.1.4",
45
45
  "@arethetypeswrong/cli": "0.18.5",
46
46
  "playwright": "1.62.1",
47
47
  "publint": "0.3.24",