@absolutejs/absolute 0.19.0-beta.248 → 0.19.0-beta.249

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.
Files changed (38) hide show
  1. package/.absolutejs/eslint-cache +1 -1
  2. package/.absolutejs/prettier.cache.json +17 -13
  3. package/.absolutejs/vue-tsc.tsbuildinfo +1 -1
  4. package/.claude/settings.local.json +2 -1
  5. package/dist/ai/index.js +636 -1
  6. package/dist/ai/index.js.map +10 -8
  7. package/dist/ai/providers/anthropic.js.map +2 -2
  8. package/dist/ai/providers/gemini.js +331 -0
  9. package/dist/ai/providers/gemini.js.map +10 -0
  10. package/dist/ai/providers/ollama.js.map +2 -2
  11. package/dist/ai/providers/openai.js.map +2 -2
  12. package/dist/ai/providers/openaiCompatible.js.map +3 -3
  13. package/dist/ai/providers/openaiResponses.js +432 -0
  14. package/dist/ai/providers/openaiResponses.js.map +10 -0
  15. package/dist/ai-client/angular/ai/index.js +61 -1
  16. package/dist/ai-client/react/ai/index.js +61 -1
  17. package/dist/ai-client/vue/ai/index.js +61 -1
  18. package/dist/angular/ai/index.js +62 -2
  19. package/dist/angular/ai/index.js.map +5 -5
  20. package/dist/build.js +3 -1
  21. package/dist/build.js.map +3 -3
  22. package/dist/index.js +3 -1
  23. package/dist/index.js.map +3 -3
  24. package/dist/react/ai/index.js +62 -2
  25. package/dist/react/ai/index.js.map +6 -6
  26. package/dist/src/ai/client/actions.d.ts +43 -0
  27. package/dist/src/ai/index.d.ts +2 -0
  28. package/dist/src/ai/providers/gemini.d.ts +7 -0
  29. package/dist/src/ai/providers/openaiResponses.d.ts +10 -0
  30. package/dist/svelte/ai/index.js +62 -2
  31. package/dist/svelte/ai/index.js.map +5 -5
  32. package/dist/types/ai.d.ts +38 -2
  33. package/dist/vue/ai/index.js +62 -2
  34. package/dist/vue/ai/index.js.map +5 -5
  35. package/package.json +9 -1
  36. package/scripts/build.ts +2 -0
  37. package/types/ai.ts +73 -6
  38. package/types/typeGuards.ts +11 -0
@@ -2,10 +2,10 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/ai/providers/openai.ts", "../src/ai/providers/openaiCompatible.ts"],
4
4
  "sourcesContent": [
5
- "import type {\n\tAIProviderConfig,\n\tAIProviderContentBlock,\n\tAIProviderMessage,\n\tAIProviderStreamParams,\n\tAIProviderToolDefinition,\n\tAIUsage\n} from '../../../types/ai';\n\ntype OpenAIConfig = {\n\tapiKey: string;\n\tbaseUrl?: string;\n};\n\ntype OpenAIMessage = {\n\tcontent: string | Array<Record<string, unknown>> | null;\n\trole: 'user' | 'assistant' | 'system' | 'tool';\n\ttool_call_id?: string;\n\ttool_calls?: Array<{\n\t\tfunction: { arguments: string; name: string };\n\t\tid: string;\n\t\ttype: 'function';\n\t}>;\n};\n\ntype PendingToolCall = {\n\targuments: string;\n\tid: string;\n\tname: string;\n};\n\ntype UsageRef = {\n\tcurrent: AIUsage | undefined;\n};\n\ntype StreamState = {\n\tbuffer: string;\n\tpendingToolCalls: Map<number, PendingToolCall>;\n\tusageRef: UsageRef;\n};\n\nconst DEFAULT_BASE_URL = 'https://api.openai.com';\nconst SSE_DATA_PREFIX_LENGTH = 6;\nconst DONE_SENTINEL = '[DONE]';\nconst NOT_FOUND = -1;\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n\ttypeof value === 'object' && value !== null;\n\nconst isRecordArray = (\n\tvalue: unknown\n): value is Array<Record<string, unknown>> =>\n\tArray.isArray(value) && value.length > 0 && isRecord(value[0]);\n\nconst isToolResultBlock = (\n\tblock: AIProviderContentBlock\n): block is AIProviderContentBlock & {\n\tcontent: string;\n\ttool_use_id: string;\n\ttype: 'tool_result';\n} => block.type === 'tool_result';\n\nconst hasArrayContent = (\n\tmsg: AIProviderMessage\n): msg is AIProviderMessage & { content: AIProviderContentBlock[] } =>\n\ttypeof msg.content !== 'string' && Array.isArray(msg.content);\n\nconst buildToolMessages = (\n\tblocks: AIProviderContentBlock[]\n) => {\n\tconst toolUseBlocks = blocks.filter((block) => block.type === 'tool_use');\n\tconst toolResultBlocks = blocks.filter((block) => block.type === 'tool_result');\n\tconst messages: OpenAIMessage[] = [];\n\n\tif (toolUseBlocks.length > 0) {\n\t\tmessages.push({\n\t\t\tcontent: null,\n\t\t\trole: 'assistant',\n\t\t\ttool_calls: toolUseBlocks.map((block) => ({\n\t\t\t\tfunction: {\n\t\t\t\t\targuments: typeof block.input === 'string'\n\t\t\t\t\t\t? block.input\n\t\t\t\t\t\t: JSON.stringify(block.input),\n\t\t\t\t\tname: block.name\n\t\t\t\t},\n\t\t\t\tid: block.id,\n\t\t\t\ttype: 'function' as const\n\t\t\t}))\n\t\t});\n\t}\n\n\tfor (const result of toolResultBlocks) {\n\t\tmessages.push({\n\t\t\tcontent: typeof result.content === 'string' ? result.content : '',\n\t\t\trole: 'tool',\n\t\t\ttool_call_id: result.tool_use_id\n\t\t});\n\t}\n\n\treturn messages;\n};\n\nconst processMessageAtIndex = (\n\tresult: OpenAIMessage[],\n\tmsg: AIProviderMessage,\n\tidx: number\n) => {\n\tif (!hasArrayContent(msg)) {\n\t\treturn;\n\t}\n\n\tconst hasToolBlocks = msg.content.some(\n\t\t(block) => block.type === 'tool_use' || block.type === 'tool_result'\n\t);\n\n\tif (!hasToolBlocks) {\n\t\treturn;\n\t}\n\n\tconst toolMessages = buildToolMessages(msg.content);\n\tresult.splice(idx, 1, ...toolMessages);\n};\n\nconst convertSingleMessage = (\n\tresult: OpenAIMessage[],\n\tmsg: AIProviderMessage | undefined,\n\tidx: number\n) => {\n\tif (!msg) {\n\t\treturn;\n\t}\n\n\tprocessMessageAtIndex(result, msg, idx);\n};\n\nconst convertToolResultMessages = (\n\tmessages: OpenAIMessage[],\n\tparams: AIProviderStreamParams\n) => {\n\tconst result = [...messages];\n\n\tfor (let idx = 0; idx < params.messages.length; idx++) {\n\t\tconvertSingleMessage(result, params.messages[idx], idx);\n\t}\n\n\treturn result;\n};\n\nconst mapToolDefinitions = (tools: AIProviderToolDefinition[]) =>\n\ttools.map((tool) => ({\n\t\tfunction: {\n\t\t\tdescription: tool.description,\n\t\t\tname: tool.name,\n\t\t\tparameters: tool.input_schema\n\t\t},\n\t\ttype: 'function'\n\t}));\n\nconst mapOpenAIContent = (\n\tmsg: AIProviderStreamParams['messages'][number]\n): string | Array<Record<string, unknown>> | null => {\n\tif (typeof msg.content === 'string') {\n\t\treturn msg.content;\n\t}\n\n\tconst hasMedia = msg.content.some((block) => block.type === 'image' || block.type === 'document');\n\n\tif (!hasMedia) {\n\t\treturn null;\n\t}\n\n\tconst blocks: Array<Record<string, unknown>> = [];\n\n\tfor (const block of msg.content) {\n\t\tif (block.type === 'image') {\n\t\t\tblocks.push({\n\t\t\t\timage_url: {\n\t\t\t\t\turl: `data:${block.source.media_type};base64,${block.source.data}`\n\t\t\t\t},\n\t\t\t\ttype: 'image_url'\n\t\t\t});\n\t\t} else if (block.type === 'document') {\n\t\t\tblocks.push({\n\t\t\t\tfile: {\n\t\t\t\t\tfile_data: `data:${block.source.media_type};base64,${block.source.data}`,\n\t\t\t\t\tfilename: block.name ?? 'document.pdf'\n\t\t\t\t},\n\t\t\t\ttype: 'file'\n\t\t\t});\n\t\t} else if (block.type === 'text') {\n\t\t\tblocks.push({ text: block.content, type: 'text' });\n\t\t}\n\t}\n\n\treturn blocks;\n};\n\nconst buildRequestBody = (params: AIProviderStreamParams) => {\n\tconst messages = convertToolResultMessages(\n\t\tparams.messages.map((msg) => ({\n\t\t\tcontent: mapOpenAIContent(msg),\n\t\t\trole: msg.role\n\t\t})),\n\t\tparams\n\t);\n\n\tconst body: Record<string, unknown> = {\n\t\tmessages,\n\t\tmodel: params.model,\n\t\tstream: true,\n\t\tstream_options: { include_usage: true }\n\t};\n\n\tif (params.tools && params.tools.length > 0) {\n\t\tbody.tools = mapToolDefinitions(params.tools);\n\t}\n\n\treturn body;\n};\n\nconst parseToolInput = (rawArguments: string) => {\n\ttry {\n\t\treturn JSON.parse(rawArguments);\n\t} catch {\n\t\treturn rawArguments;\n\t}\n};\n\nconst flushPendingToolCalls = function* (\n\tpendingToolCalls: Map<number, PendingToolCall>\n) {\n\tfor (const [, tool] of pendingToolCalls) {\n\t\tconst input = parseToolInput(tool.arguments);\n\t\tyield {\n\t\t\tid: tool.id,\n\t\t\tinput,\n\t\t\tname: tool.name,\n\t\t\ttype: 'tool_use' as const\n\t\t};\n\t}\n\n\tpendingToolCalls.clear();\n};\n\nconst extractUsage = (parsedUsage: Record<string, number>) => ({\n\tinputTokens: parsedUsage.prompt_tokens ?? 0,\n\toutputTokens: parsedUsage.completion_tokens ?? 0\n});\n\nconst resolveToolCallIndex = (toolCall: Record<string, unknown>) => {\n\tconst raw = typeof toolCall.index === 'number' ? toolCall.index : NOT_FOUND;\n\n\treturn raw < 0 ? undefined : raw;\n};\n\nconst initPendingToolCall = (\n\ttoolCall: Record<string, unknown>,\n\tfunc: Record<string, unknown> | null,\n\tindex: number,\n\tpendingToolCalls: Map<number, PendingToolCall>\n) => {\n\tif (pendingToolCalls.has(index)) {\n\t\treturn;\n\t}\n\n\tconst toolId = typeof toolCall.id === 'string' ? toolCall.id : '';\n\tconst toolName = func && typeof func.name === 'string' ? func.name : '';\n\n\tpendingToolCalls.set(index, {\n\t\targuments: '',\n\t\tid: toolId,\n\t\tname: toolName\n\t});\n};\n\nconst updatePendingToolCall = (\n\ttoolCall: Record<string, unknown>,\n\tfunc: Record<string, unknown> | null,\n\tpending: PendingToolCall\n) => {\n\tif (typeof toolCall.id === 'string') {\n\t\tpending.id = toolCall.id;\n\t}\n\n\tif (func && typeof func.name === 'string') {\n\t\tpending.name = func.name;\n\t}\n\n\tif (func && typeof func.arguments === 'string') {\n\t\tpending.arguments += func.arguments;\n\t}\n};\n\nconst processToolCallDelta = (\n\ttoolCall: Record<string, unknown>,\n\tpendingToolCalls: Map<number, PendingToolCall>\n) => {\n\tconst index = resolveToolCallIndex(toolCall);\n\tif (index === undefined) {\n\t\treturn;\n\t}\n\n\tconst func = isRecord(toolCall.function) ? toolCall.function : null;\n\tinitPendingToolCall(toolCall, func, index, pendingToolCalls);\n\n\tconst pending = pendingToolCalls.get(index);\n\tif (!pending) {\n\t\treturn;\n\t}\n\n\tupdatePendingToolCall(toolCall, func, pending);\n};\n\nconst processToolCallDeltas = (\n\ttoolCalls: Array<Record<string, unknown>>,\n\tpendingToolCalls: Map<number, PendingToolCall>\n) => {\n\tfor (const toolCall of toolCalls) {\n\t\tprocessToolCallDelta(toolCall, pendingToolCalls);\n\t}\n};\n\nconst processDelta = function* (\n\tdelta: Record<string, unknown>,\n\tpendingToolCalls: Map<number, PendingToolCall>\n) {\n\tif (typeof delta.content === 'string') {\n\t\tyield { content: delta.content, type: 'text' as const };\n\t}\n\n\tif (isRecordArray(delta.tool_calls)) {\n\t\tprocessToolCallDeltas(delta.tool_calls, pendingToolCalls);\n\t}\n};\n\nconst processChoice = function* (\n\tchoice: Record<string, unknown>,\n\tpendingToolCalls: Map<number, PendingToolCall>\n) {\n\tconst delta = isRecord(choice.delta) ? choice.delta : null;\n\tif (delta) {\n\t\tyield* processDelta(delta, pendingToolCalls);\n\t}\n\n\tif (choice.finish_reason === 'tool_calls') {\n\t\tyield* flushPendingToolCalls(pendingToolCalls);\n\t}\n};\n\nconst narrowUsageRecord = (parsed: Record<string, unknown>) => {\n\tif (!isRecord(parsed.usage)) {\n\t\treturn undefined;\n\t}\n\n\tconst { usage } = parsed;\n\tconst promptTokens =\n\t\ttypeof usage.prompt_tokens === 'number' ? usage.prompt_tokens : 0;\n\tconst completionTokens =\n\t\ttypeof usage.completion_tokens === 'number'\n\t\t\t? usage.completion_tokens\n\t\t\t: 0;\n\n\treturn extractUsage({\n\t\tcompletion_tokens: completionTokens,\n\t\tprompt_tokens: promptTokens\n\t});\n};\n\nconst processSSELine = function* (\n\tline: string,\n\tpendingToolCalls: Map<number, PendingToolCall>,\n\tcurrentUsage: AIUsage | undefined\n) {\n\tconst trimmed = line.trim();\n\tif (!trimmed || !trimmed.startsWith('data: ')) {\n\t\treturn;\n\t}\n\n\tconst data = trimmed.slice(SSE_DATA_PREFIX_LENGTH);\n\tif (data === DONE_SENTINEL) {\n\t\tyield* flushPendingToolCalls(pendingToolCalls);\n\t\tyield { type: 'done' as const, usage: currentUsage };\n\n\t\treturn;\n\t}\n\n\tlet parsed: Record<string, unknown>;\n\ttry {\n\t\tparsed = JSON.parse(data);\n\t} catch {\n\t\treturn;\n\t}\n\n\tconst usageUpdate = narrowUsageRecord(parsed);\n\tif (usageUpdate) {\n\t\tyield { type: 'usage_update' as const, usage: usageUpdate };\n\t}\n\n\tconst { choices } = parsed;\n\tif (!isRecordArray(choices)) {\n\t\treturn;\n\t}\n\n\tconst [firstChoice] = choices;\n\tif (!firstChoice) {\n\t\treturn;\n\t}\n\n\tyield* processChoice(firstChoice, pendingToolCalls);\n};\n\nconst isUsageUpdate = (chunk: {\n\ttype: string;\n\tusage?: AIUsage;\n}): chunk is { type: 'usage_update'; usage: AIUsage } =>\n\tchunk.type === 'usage_update';\n\nconst collectYieldableChunks = (\n\tline: string,\n\tpendingToolCalls: Map<number, PendingToolCall>,\n\tusageRef: UsageRef\n) => {\n\tconst allChunks = Array.from(\n\t\tprocessSSELine(line, pendingToolCalls, usageRef.current)\n\t);\n\tconst usageChunks = allChunks.filter(isUsageUpdate);\n\tconst lastUsage = usageChunks.at(NOT_FOUND);\n\n\tif (lastUsage) {\n\t\tusageRef.current = lastUsage.usage;\n\t}\n\n\treturn allChunks.filter((chunk) => !isUsageUpdate(chunk));\n};\n\nconst processSSELines = function* (\n\tlines: string[],\n\tpendingToolCalls: Map<number, PendingToolCall>,\n\tusageRef: UsageRef\n) {\n\tfor (const line of lines) {\n\t\tyield* collectYieldableChunks(line, pendingToolCalls, usageRef);\n\t}\n};\n\nconst processStreamValue = (\n\tvalue: Uint8Array,\n\tdecoder: TextDecoder,\n\tstate: StreamState\n) => {\n\tstate.buffer += decoder.decode(value, { stream: true });\n\tconst lines = state.buffer.split('\\n');\n\tstate.buffer = lines.pop() ?? '';\n\n\treturn lines;\n};\n\nconst drainReader = async function* (\n\treader: ReadableStreamDefaultReader<Uint8Array>,\n\tdecoder: TextDecoder,\n\tstate: StreamState,\n\tsignal?: AbortSignal\n) {\n\t/* eslint-disable no-await-in-loop */\n\tfor (\n\t\tlet result = await reader.read();\n\t\t!result.done && !signal?.aborted;\n\t\tresult = await reader.read()\n\t) {\n\t\t/* eslint-enable no-await-in-loop */\n\t\tconst lines = processStreamValue(result.value, decoder, state);\n\t\tyield* processSSELines(lines, state.pendingToolCalls, state.usageRef);\n\t}\n};\n\nconst parseSSEStream = async function* (\n\tbody: ReadableStream<Uint8Array>,\n\tsignal?: AbortSignal\n) {\n\tconst reader = body.getReader();\n\tconst decoder = new TextDecoder();\n\tconst state: StreamState = {\n\t\tbuffer: '',\n\t\tpendingToolCalls: new Map<number, PendingToolCall>(),\n\t\tusageRef: { current: undefined }\n\t};\n\n\ttry {\n\t\tyield* drainReader(reader, decoder, state, signal);\n\t\tyield { type: 'done' as const, usage: state.usageRef.current };\n\t} finally {\n\t\treader.releaseLock();\n\t}\n};\n\nconst fetchOpenAIStream = async function* (\n\tbaseUrl: string,\n\tapiKey: string,\n\tbody: Record<string, unknown>,\n\tsignal?: AbortSignal\n) {\n\tconst response = await fetch(`${baseUrl}/v1/chat/completions`, {\n\t\tbody: JSON.stringify(body),\n\t\theaders: {\n\t\t\tAuthorization: `Bearer ${apiKey}`,\n\t\t\t'Content-Type': 'application/json'\n\t\t},\n\t\tmethod: 'POST',\n\t\tsignal\n\t});\n\n\tif (!response.ok) {\n\t\tconst errorText = await response.text();\n\t\tthrow new Error(`OpenAI API error ${response.status}: ${errorText}`);\n\t}\n\n\tif (!response.body) {\n\t\tthrow new Error('OpenAI API returned no response body');\n\t}\n\n\tyield* parseSSEStream(response.body, signal);\n};\n\nexport const openai = (config: OpenAIConfig): AIProviderConfig => {\n\tconst baseUrl = config.baseUrl ?? DEFAULT_BASE_URL;\n\n\treturn {\n\t\tstream: (params: AIProviderStreamParams) => {\n\t\t\tconst body = buildRequestBody(params);\n\n\t\t\treturn fetchOpenAIStream(\n\t\t\t\tbaseUrl,\n\t\t\t\tconfig.apiKey,\n\t\t\t\tbody,\n\t\t\t\tparams.signal\n\t\t\t);\n\t\t}\n\t};\n};\n",
6
- "import type { AIProviderConfig } from '../../../types/ai';\nimport { openai } from './openai';\n\n/**\n * Creates a provider for any OpenAI-compatible API.\n * Many providers (Google, xAI, DeepSeek, Mistral, etc.)\n * expose OpenAI-compatible chat completion endpoints.\n */\nexport const openaiCompatible = (config: {\n\tapiKey: string;\n\tbaseUrl: string;\n}): AIProviderConfig => openai({ apiKey: config.apiKey, baseUrl: config.baseUrl });\n\nexport const google = (config: { apiKey: string }) =>\n\topenaiCompatible({\n\t\tapiKey: config.apiKey,\n\t\tbaseUrl: 'https://generativelanguage.googleapis.com/v1beta/openai'\n\t});\n\nexport const xai = (config: { apiKey: string }) =>\n\topenaiCompatible({\n\t\tapiKey: config.apiKey,\n\t\tbaseUrl: 'https://api.x.ai'\n\t});\n\nexport const deepseek = (config: { apiKey: string }) =>\n\topenaiCompatible({\n\t\tapiKey: config.apiKey,\n\t\tbaseUrl: 'https://api.deepseek.com'\n\t});\n\nexport const mistralai = (config: { apiKey: string }) =>\n\topenaiCompatible({\n\t\tapiKey: config.apiKey,\n\t\tbaseUrl: 'https://api.mistral.ai'\n\t});\n\nexport const alibaba = (config: { apiKey: string }) =>\n\topenaiCompatible({\n\t\tapiKey: config.apiKey,\n\t\tbaseUrl: 'https://dashscope-intl.aliyuncs.com/compatible-mode'\n\t});\n\nexport const meta = (config: { apiKey: string }) =>\n\topenaiCompatible({\n\t\tapiKey: config.apiKey,\n\t\tbaseUrl: 'https://api.llama.com/compat/v1'\n\t});\n\nexport const moonshot = (config: { apiKey: string }) =>\n\topenaiCompatible({\n\t\tapiKey: config.apiKey,\n\t\tbaseUrl: 'https://api.moonshot.ai'\n\t});\n"
5
+ "import type {\n\tAIProviderConfig,\n\tAIProviderContentBlock,\n\tAIProviderMessage,\n\tAIProviderStreamParams,\n\tAIProviderToolDefinition,\n\tAIUsage\n} from '../../../types/ai';\n\ntype OpenAIConfig = {\n\tapiKey: string;\n\tbaseUrl?: string;\n};\n\ntype OpenAIMessage = {\n\tcontent: string | Array<Record<string, unknown>> | null;\n\trole: 'user' | 'assistant' | 'system' | 'tool';\n\ttool_call_id?: string;\n\ttool_calls?: Array<{\n\t\tfunction: { arguments: string; name: string };\n\t\tid: string;\n\t\ttype: 'function';\n\t}>;\n};\n\ntype PendingToolCall = {\n\targuments: string;\n\tid: string;\n\tname: string;\n};\n\ntype UsageRef = {\n\tcurrent: AIUsage | undefined;\n};\n\ntype StreamState = {\n\tbuffer: string;\n\tpendingToolCalls: Map<number, PendingToolCall>;\n\tusageRef: UsageRef;\n};\n\nconst DEFAULT_BASE_URL = 'https://api.openai.com';\nconst SSE_DATA_PREFIX_LENGTH = 6;\nconst DONE_SENTINEL = '[DONE]';\nconst NOT_FOUND = -1;\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n\ttypeof value === 'object' && value !== null;\n\nconst isRecordArray = (\n\tvalue: unknown\n): value is Array<Record<string, unknown>> =>\n\tArray.isArray(value) && value.length > 0 && isRecord(value[0]);\n\nconst isToolResultBlock = (\n\tblock: AIProviderContentBlock\n): block is AIProviderContentBlock & {\n\tcontent: string;\n\ttool_use_id: string;\n\ttype: 'tool_result';\n} => block.type === 'tool_result';\n\nconst hasArrayContent = (\n\tmsg: AIProviderMessage\n): msg is AIProviderMessage & { content: AIProviderContentBlock[] } =>\n\ttypeof msg.content !== 'string' && Array.isArray(msg.content);\n\nconst buildToolMessages = (blocks: AIProviderContentBlock[]) => {\n\tconst toolUseBlocks = blocks.filter((block) => block.type === 'tool_use');\n\tconst toolResultBlocks = blocks.filter(\n\t\t(block) => block.type === 'tool_result'\n\t);\n\tconst messages: OpenAIMessage[] = [];\n\n\tif (toolUseBlocks.length > 0) {\n\t\tmessages.push({\n\t\t\tcontent: null,\n\t\t\trole: 'assistant',\n\t\t\ttool_calls: toolUseBlocks.map((block) => ({\n\t\t\t\tfunction: {\n\t\t\t\t\targuments:\n\t\t\t\t\t\ttypeof block.input === 'string'\n\t\t\t\t\t\t\t? block.input\n\t\t\t\t\t\t\t: JSON.stringify(block.input),\n\t\t\t\t\tname: block.name\n\t\t\t\t},\n\t\t\t\tid: block.id,\n\t\t\t\ttype: 'function' as const\n\t\t\t}))\n\t\t});\n\t}\n\n\tfor (const result of toolResultBlocks) {\n\t\tmessages.push({\n\t\t\tcontent: typeof result.content === 'string' ? result.content : '',\n\t\t\trole: 'tool',\n\t\t\ttool_call_id: result.tool_use_id\n\t\t});\n\t}\n\n\treturn messages;\n};\n\nconst processMessageAtIndex = (\n\tresult: OpenAIMessage[],\n\tmsg: AIProviderMessage,\n\tidx: number\n) => {\n\tif (!hasArrayContent(msg)) {\n\t\treturn;\n\t}\n\n\tconst hasToolBlocks = msg.content.some(\n\t\t(block) => block.type === 'tool_use' || block.type === 'tool_result'\n\t);\n\n\tif (!hasToolBlocks) {\n\t\treturn;\n\t}\n\n\tconst toolMessages = buildToolMessages(msg.content);\n\tresult.splice(idx, 1, ...toolMessages);\n};\n\nconst convertSingleMessage = (\n\tresult: OpenAIMessage[],\n\tmsg: AIProviderMessage | undefined,\n\tidx: number\n) => {\n\tif (!msg) {\n\t\treturn;\n\t}\n\n\tprocessMessageAtIndex(result, msg, idx);\n};\n\nconst convertToolResultMessages = (\n\tmessages: OpenAIMessage[],\n\tparams: AIProviderStreamParams\n) => {\n\tconst result = [...messages];\n\n\tfor (let idx = 0; idx < params.messages.length; idx++) {\n\t\tconvertSingleMessage(result, params.messages[idx], idx);\n\t}\n\n\treturn result;\n};\n\nconst mapToolDefinitions = (tools: AIProviderToolDefinition[]) =>\n\ttools.map((tool) => ({\n\t\tfunction: {\n\t\t\tdescription: tool.description,\n\t\t\tname: tool.name,\n\t\t\tparameters: tool.input_schema\n\t\t},\n\t\ttype: 'function'\n\t}));\n\nconst mapOpenAIContent = (\n\tmsg: AIProviderStreamParams['messages'][number]\n): string | Array<Record<string, unknown>> | null => {\n\tif (typeof msg.content === 'string') {\n\t\treturn msg.content;\n\t}\n\n\tconst hasMedia = msg.content.some(\n\t\t(block) => block.type === 'image' || block.type === 'document'\n\t);\n\n\tif (!hasMedia) {\n\t\treturn null;\n\t}\n\n\tconst blocks: Array<Record<string, unknown>> = [];\n\n\tfor (const block of msg.content) {\n\t\tif (block.type === 'image') {\n\t\t\tblocks.push({\n\t\t\t\timage_url: {\n\t\t\t\t\turl: `data:${block.source.media_type};base64,${block.source.data}`\n\t\t\t\t},\n\t\t\t\ttype: 'image_url'\n\t\t\t});\n\t\t} else if (block.type === 'document') {\n\t\t\tblocks.push({\n\t\t\t\tfile: {\n\t\t\t\t\tfile_data: `data:${block.source.media_type};base64,${block.source.data}`,\n\t\t\t\t\tfilename: block.name ?? 'document.pdf'\n\t\t\t\t},\n\t\t\t\ttype: 'file'\n\t\t\t});\n\t\t} else if (block.type === 'text') {\n\t\t\tblocks.push({ text: block.content, type: 'text' });\n\t\t}\n\t}\n\n\treturn blocks;\n};\n\nconst buildRequestBody = (params: AIProviderStreamParams) => {\n\tconst messages = convertToolResultMessages(\n\t\tparams.messages.map((msg) => ({\n\t\t\tcontent: mapOpenAIContent(msg),\n\t\t\trole: msg.role\n\t\t})),\n\t\tparams\n\t);\n\n\tconst body: Record<string, unknown> = {\n\t\tmessages,\n\t\tmodel: params.model,\n\t\tstream: true,\n\t\tstream_options: { include_usage: true }\n\t};\n\n\tif (params.tools && params.tools.length > 0) {\n\t\tbody.tools = mapToolDefinitions(params.tools);\n\t}\n\n\treturn body;\n};\n\nconst parseToolInput = (rawArguments: string) => {\n\ttry {\n\t\treturn JSON.parse(rawArguments);\n\t} catch {\n\t\treturn rawArguments;\n\t}\n};\n\nconst flushPendingToolCalls = function* (\n\tpendingToolCalls: Map<number, PendingToolCall>\n) {\n\tfor (const [, tool] of pendingToolCalls) {\n\t\tconst input = parseToolInput(tool.arguments);\n\t\tyield {\n\t\t\tid: tool.id,\n\t\t\tinput,\n\t\t\tname: tool.name,\n\t\t\ttype: 'tool_use' as const\n\t\t};\n\t}\n\n\tpendingToolCalls.clear();\n};\n\nconst extractUsage = (parsedUsage: Record<string, number>) => ({\n\tinputTokens: parsedUsage.prompt_tokens ?? 0,\n\toutputTokens: parsedUsage.completion_tokens ?? 0\n});\n\nconst resolveToolCallIndex = (toolCall: Record<string, unknown>) => {\n\tconst raw = typeof toolCall.index === 'number' ? toolCall.index : NOT_FOUND;\n\n\treturn raw < 0 ? undefined : raw;\n};\n\nconst initPendingToolCall = (\n\ttoolCall: Record<string, unknown>,\n\tfunc: Record<string, unknown> | null,\n\tindex: number,\n\tpendingToolCalls: Map<number, PendingToolCall>\n) => {\n\tif (pendingToolCalls.has(index)) {\n\t\treturn;\n\t}\n\n\tconst toolId = typeof toolCall.id === 'string' ? toolCall.id : '';\n\tconst toolName = func && typeof func.name === 'string' ? func.name : '';\n\n\tpendingToolCalls.set(index, {\n\t\targuments: '',\n\t\tid: toolId,\n\t\tname: toolName\n\t});\n};\n\nconst updatePendingToolCall = (\n\ttoolCall: Record<string, unknown>,\n\tfunc: Record<string, unknown> | null,\n\tpending: PendingToolCall\n) => {\n\tif (typeof toolCall.id === 'string') {\n\t\tpending.id = toolCall.id;\n\t}\n\n\tif (func && typeof func.name === 'string') {\n\t\tpending.name = func.name;\n\t}\n\n\tif (func && typeof func.arguments === 'string') {\n\t\tpending.arguments += func.arguments;\n\t}\n};\n\nconst processToolCallDelta = (\n\ttoolCall: Record<string, unknown>,\n\tpendingToolCalls: Map<number, PendingToolCall>\n) => {\n\tconst index = resolveToolCallIndex(toolCall);\n\tif (index === undefined) {\n\t\treturn;\n\t}\n\n\tconst func = isRecord(toolCall.function) ? toolCall.function : null;\n\tinitPendingToolCall(toolCall, func, index, pendingToolCalls);\n\n\tconst pending = pendingToolCalls.get(index);\n\tif (!pending) {\n\t\treturn;\n\t}\n\n\tupdatePendingToolCall(toolCall, func, pending);\n};\n\nconst processToolCallDeltas = (\n\ttoolCalls: Array<Record<string, unknown>>,\n\tpendingToolCalls: Map<number, PendingToolCall>\n) => {\n\tfor (const toolCall of toolCalls) {\n\t\tprocessToolCallDelta(toolCall, pendingToolCalls);\n\t}\n};\n\nconst processDelta = function* (\n\tdelta: Record<string, unknown>,\n\tpendingToolCalls: Map<number, PendingToolCall>\n) {\n\tif (typeof delta.content === 'string') {\n\t\tyield { content: delta.content, type: 'text' as const };\n\t}\n\n\tif (isRecordArray(delta.tool_calls)) {\n\t\tprocessToolCallDeltas(delta.tool_calls, pendingToolCalls);\n\t}\n};\n\nconst processChoice = function* (\n\tchoice: Record<string, unknown>,\n\tpendingToolCalls: Map<number, PendingToolCall>\n) {\n\tconst delta = isRecord(choice.delta) ? choice.delta : null;\n\tif (delta) {\n\t\tyield* processDelta(delta, pendingToolCalls);\n\t}\n\n\tif (choice.finish_reason === 'tool_calls') {\n\t\tyield* flushPendingToolCalls(pendingToolCalls);\n\t}\n};\n\nconst narrowUsageRecord = (parsed: Record<string, unknown>) => {\n\tif (!isRecord(parsed.usage)) {\n\t\treturn undefined;\n\t}\n\n\tconst { usage } = parsed;\n\tconst promptTokens =\n\t\ttypeof usage.prompt_tokens === 'number' ? usage.prompt_tokens : 0;\n\tconst completionTokens =\n\t\ttypeof usage.completion_tokens === 'number'\n\t\t\t? usage.completion_tokens\n\t\t\t: 0;\n\n\treturn extractUsage({\n\t\tcompletion_tokens: completionTokens,\n\t\tprompt_tokens: promptTokens\n\t});\n};\n\nconst processSSELine = function* (\n\tline: string,\n\tpendingToolCalls: Map<number, PendingToolCall>,\n\tcurrentUsage: AIUsage | undefined\n) {\n\tconst trimmed = line.trim();\n\tif (!trimmed || !trimmed.startsWith('data: ')) {\n\t\treturn;\n\t}\n\n\tconst data = trimmed.slice(SSE_DATA_PREFIX_LENGTH);\n\tif (data === DONE_SENTINEL) {\n\t\tyield* flushPendingToolCalls(pendingToolCalls);\n\t\tyield { type: 'done' as const, usage: currentUsage };\n\n\t\treturn;\n\t}\n\n\tlet parsed: Record<string, unknown>;\n\ttry {\n\t\tparsed = JSON.parse(data);\n\t} catch {\n\t\treturn;\n\t}\n\n\tconst usageUpdate = narrowUsageRecord(parsed);\n\tif (usageUpdate) {\n\t\tyield { type: 'usage_update' as const, usage: usageUpdate };\n\t}\n\n\tconst { choices } = parsed;\n\tif (!isRecordArray(choices)) {\n\t\treturn;\n\t}\n\n\tconst [firstChoice] = choices;\n\tif (!firstChoice) {\n\t\treturn;\n\t}\n\n\tyield* processChoice(firstChoice, pendingToolCalls);\n};\n\nconst isUsageUpdate = (chunk: {\n\ttype: string;\n\tusage?: AIUsage;\n}): chunk is { type: 'usage_update'; usage: AIUsage } =>\n\tchunk.type === 'usage_update';\n\nconst collectYieldableChunks = (\n\tline: string,\n\tpendingToolCalls: Map<number, PendingToolCall>,\n\tusageRef: UsageRef\n) => {\n\tconst allChunks = Array.from(\n\t\tprocessSSELine(line, pendingToolCalls, usageRef.current)\n\t);\n\tconst usageChunks = allChunks.filter(isUsageUpdate);\n\tconst lastUsage = usageChunks.at(NOT_FOUND);\n\n\tif (lastUsage) {\n\t\tusageRef.current = lastUsage.usage;\n\t}\n\n\treturn allChunks.filter((chunk) => !isUsageUpdate(chunk));\n};\n\nconst processSSELines = function* (\n\tlines: string[],\n\tpendingToolCalls: Map<number, PendingToolCall>,\n\tusageRef: UsageRef\n) {\n\tfor (const line of lines) {\n\t\tyield* collectYieldableChunks(line, pendingToolCalls, usageRef);\n\t}\n};\n\nconst processStreamValue = (\n\tvalue: Uint8Array,\n\tdecoder: TextDecoder,\n\tstate: StreamState\n) => {\n\tstate.buffer += decoder.decode(value, { stream: true });\n\tconst lines = state.buffer.split('\\n');\n\tstate.buffer = lines.pop() ?? '';\n\n\treturn lines;\n};\n\nconst drainReader = async function* (\n\treader: ReadableStreamDefaultReader<Uint8Array>,\n\tdecoder: TextDecoder,\n\tstate: StreamState,\n\tsignal?: AbortSignal\n) {\n\t/* eslint-disable no-await-in-loop */\n\tfor (\n\t\tlet result = await reader.read();\n\t\t!result.done && !signal?.aborted;\n\t\tresult = await reader.read()\n\t) {\n\t\t/* eslint-enable no-await-in-loop */\n\t\tconst lines = processStreamValue(result.value, decoder, state);\n\t\tyield* processSSELines(lines, state.pendingToolCalls, state.usageRef);\n\t}\n};\n\nconst parseSSEStream = async function* (\n\tbody: ReadableStream<Uint8Array>,\n\tsignal?: AbortSignal\n) {\n\tconst reader = body.getReader();\n\tconst decoder = new TextDecoder();\n\tconst state: StreamState = {\n\t\tbuffer: '',\n\t\tpendingToolCalls: new Map<number, PendingToolCall>(),\n\t\tusageRef: { current: undefined }\n\t};\n\n\ttry {\n\t\tyield* drainReader(reader, decoder, state, signal);\n\t\tyield { type: 'done' as const, usage: state.usageRef.current };\n\t} finally {\n\t\treader.releaseLock();\n\t}\n};\n\nconst fetchOpenAIStream = async function* (\n\tbaseUrl: string,\n\tapiKey: string,\n\tbody: Record<string, unknown>,\n\tsignal?: AbortSignal\n) {\n\tconst response = await fetch(`${baseUrl}/v1/chat/completions`, {\n\t\tbody: JSON.stringify(body),\n\t\theaders: {\n\t\t\tAuthorization: `Bearer ${apiKey}`,\n\t\t\t'Content-Type': 'application/json'\n\t\t},\n\t\tmethod: 'POST',\n\t\tsignal\n\t});\n\n\tif (!response.ok) {\n\t\tconst errorText = await response.text();\n\t\tthrow new Error(`OpenAI API error ${response.status}: ${errorText}`);\n\t}\n\n\tif (!response.body) {\n\t\tthrow new Error('OpenAI API returned no response body');\n\t}\n\n\tyield* parseSSEStream(response.body, signal);\n};\n\nexport const openai = (config: OpenAIConfig): AIProviderConfig => {\n\tconst baseUrl = config.baseUrl ?? DEFAULT_BASE_URL;\n\n\treturn {\n\t\tstream: (params: AIProviderStreamParams) => {\n\t\t\tconst body = buildRequestBody(params);\n\n\t\t\treturn fetchOpenAIStream(\n\t\t\t\tbaseUrl,\n\t\t\t\tconfig.apiKey,\n\t\t\t\tbody,\n\t\t\t\tparams.signal\n\t\t\t);\n\t\t}\n\t};\n};\n",
6
+ "import type { AIProviderConfig } from '../../../types/ai';\nimport { openai } from './openai';\n\n/**\n * Creates a provider for any OpenAI-compatible API.\n * Many providers (Google, xAI, DeepSeek, Mistral, etc.)\n * expose OpenAI-compatible chat completion endpoints.\n */\nexport const openaiCompatible = (config: {\n\tapiKey: string;\n\tbaseUrl: string;\n}): AIProviderConfig =>\n\topenai({ apiKey: config.apiKey, baseUrl: config.baseUrl });\n\nexport const google = (config: { apiKey: string }) =>\n\topenaiCompatible({\n\t\tapiKey: config.apiKey,\n\t\tbaseUrl: 'https://generativelanguage.googleapis.com/v1beta/openai'\n\t});\n\nexport const xai = (config: { apiKey: string }) =>\n\topenaiCompatible({\n\t\tapiKey: config.apiKey,\n\t\tbaseUrl: 'https://api.x.ai'\n\t});\n\nexport const deepseek = (config: { apiKey: string }) =>\n\topenaiCompatible({\n\t\tapiKey: config.apiKey,\n\t\tbaseUrl: 'https://api.deepseek.com'\n\t});\n\nexport const mistralai = (config: { apiKey: string }) =>\n\topenaiCompatible({\n\t\tapiKey: config.apiKey,\n\t\tbaseUrl: 'https://api.mistral.ai'\n\t});\n\nexport const alibaba = (config: { apiKey: string }) =>\n\topenaiCompatible({\n\t\tapiKey: config.apiKey,\n\t\tbaseUrl: 'https://dashscope-intl.aliyuncs.com/compatible-mode'\n\t});\n\nexport const meta = (config: { apiKey: string }) =>\n\topenaiCompatible({\n\t\tapiKey: config.apiKey,\n\t\tbaseUrl: 'https://api.llama.com/compat/v1'\n\t});\n\nexport const moonshot = (config: { apiKey: string }) =>\n\topenaiCompatible({\n\t\tapiKey: config.apiKey,\n\t\tbaseUrl: 'https://api.moonshot.ai'\n\t});\n"
7
7
  ],
8
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCA,IAAM,mBAAmB;AACzB,IAAM,yBAAyB;AAC/B,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164756E2164756E21",
10
10
  "names": []
11
11
  }
@@ -0,0 +1,432 @@
1
+ // @bun
2
+ var __create = Object.create;
3
+ var __getProtoOf = Object.getPrototypeOf;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ function __accessProp(key) {
9
+ return this[key];
10
+ }
11
+ var __toESMCache_node;
12
+ var __toESMCache_esm;
13
+ var __toESM = (mod, isNodeMode, target) => {
14
+ var canCache = mod != null && typeof mod === "object";
15
+ if (canCache) {
16
+ var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
17
+ var cached = cache.get(mod);
18
+ if (cached)
19
+ return cached;
20
+ }
21
+ target = mod != null ? __create(__getProtoOf(mod)) : {};
22
+ const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
23
+ for (let key of __getOwnPropNames(mod))
24
+ if (!__hasOwnProp.call(to, key))
25
+ __defProp(to, key, {
26
+ get: __accessProp.bind(mod, key),
27
+ enumerable: true
28
+ });
29
+ if (canCache)
30
+ cache.set(mod, to);
31
+ return to;
32
+ };
33
+ var __toCommonJS = (from) => {
34
+ var entry = (__moduleCache ??= new WeakMap).get(from), desc;
35
+ if (entry)
36
+ return entry;
37
+ entry = __defProp({}, "__esModule", { value: true });
38
+ if (from && typeof from === "object" || typeof from === "function") {
39
+ for (var key of __getOwnPropNames(from))
40
+ if (!__hasOwnProp.call(entry, key))
41
+ __defProp(entry, key, {
42
+ get: __accessProp.bind(from, key),
43
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
44
+ });
45
+ }
46
+ __moduleCache.set(from, entry);
47
+ return entry;
48
+ };
49
+ var __moduleCache;
50
+ var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
51
+ var __returnValue = (v) => v;
52
+ function __exportSetter(name, newValue) {
53
+ this[name] = __returnValue.bind(null, newValue);
54
+ }
55
+ var __export = (target, all) => {
56
+ for (var name in all)
57
+ __defProp(target, name, {
58
+ get: all[name],
59
+ enumerable: true,
60
+ configurable: true,
61
+ set: __exportSetter.bind(all, name)
62
+ });
63
+ };
64
+ var __legacyDecorateClassTS = function(decorators, target, key, desc) {
65
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
66
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
67
+ r = Reflect.decorate(decorators, target, key, desc);
68
+ else
69
+ for (var i = decorators.length - 1;i >= 0; i--)
70
+ if (d = decorators[i])
71
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
72
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
73
+ };
74
+ var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
75
+ var __require = import.meta.require;
76
+
77
+ // src/ai/providers/openaiResponses.ts
78
+ var DEFAULT_BASE_URL = "https://api.openai.com";
79
+ var EVENT_PREFIX_LENGTH = 7;
80
+ var DATA_PREFIX_LENGTH = 6;
81
+ var isRecord = (value) => typeof value === "object" && value !== null;
82
+ var isRecordArray = (value) => Array.isArray(value) && value.length > 0 && isRecord(value[0]);
83
+ var mapContentToResponsesFormat = (content) => {
84
+ if (typeof content === "string") {
85
+ return content;
86
+ }
87
+ const parts = [];
88
+ for (const block of content) {
89
+ if (block.type === "text") {
90
+ parts.push({ text: block.content, type: "input_text" });
91
+ } else if (block.type === "image") {
92
+ parts.push({
93
+ image_url: {
94
+ url: `data:${block.source.media_type};base64,${block.source.data}`
95
+ },
96
+ type: "input_image"
97
+ });
98
+ } else if (block.type === "document") {
99
+ parts.push({
100
+ file: {
101
+ file_data: `data:${block.source.media_type};base64,${block.source.data}`,
102
+ filename: block.name ?? "document.pdf"
103
+ },
104
+ type: "input_file"
105
+ });
106
+ }
107
+ }
108
+ return parts.length > 0 ? parts : "";
109
+ };
110
+ var hasToolBlocks = (content) => content.some((block) => block.type === "tool_use" || block.type === "tool_result");
111
+ var convertToolBlocks = (content) => {
112
+ const items = [];
113
+ for (const block of content) {
114
+ if (block.type === "tool_use") {
115
+ items.push({
116
+ arguments: typeof block.input === "string" ? block.input : JSON.stringify(block.input),
117
+ call_id: block.id,
118
+ name: block.name,
119
+ type: "function_call"
120
+ });
121
+ } else if (block.type === "tool_result") {
122
+ items.push({
123
+ call_id: block.tool_use_id,
124
+ output: typeof block.content === "string" ? block.content : "",
125
+ type: "function_call_output"
126
+ });
127
+ }
128
+ }
129
+ return items;
130
+ };
131
+ var convertMessage = (msg) => {
132
+ if (typeof msg.content !== "string" && Array.isArray(msg.content)) {
133
+ if (hasToolBlocks(msg.content)) {
134
+ return convertToolBlocks(msg.content);
135
+ }
136
+ }
137
+ const content = mapContentToResponsesFormat(msg.content);
138
+ return [
139
+ {
140
+ content,
141
+ role: msg.role === "system" ? "developer" : msg.role,
142
+ type: "message"
143
+ }
144
+ ];
145
+ };
146
+ var buildInput = (messages) => {
147
+ const input = [];
148
+ for (const msg of messages) {
149
+ input.push(...convertMessage(msg));
150
+ }
151
+ return input;
152
+ };
153
+ var mapToolDefinition = (tool) => ({
154
+ description: tool.description,
155
+ name: tool.name,
156
+ parameters: tool.input_schema,
157
+ type: "function"
158
+ });
159
+ var buildTools = (tools, imageGeneration) => {
160
+ const result = [];
161
+ if (tools) {
162
+ for (const tool of tools) {
163
+ result.push(mapToolDefinition(tool));
164
+ }
165
+ }
166
+ if (imageGeneration) {
167
+ const imageGenTool = {
168
+ type: "image_generation"
169
+ };
170
+ if (imageGeneration.partialImages !== undefined) {
171
+ imageGenTool.partial_images = imageGeneration.partialImages;
172
+ }
173
+ result.push(imageGenTool);
174
+ }
175
+ return result.length > 0 ? result : undefined;
176
+ };
177
+ var buildRequestBody = (params, imageGeneration) => {
178
+ const body = {
179
+ input: buildInput(params.messages),
180
+ model: params.model,
181
+ stream: true
182
+ };
183
+ if (params.systemPrompt) {
184
+ body.instructions = params.systemPrompt;
185
+ }
186
+ const tools = buildTools(params.tools, imageGeneration);
187
+ if (tools) {
188
+ body.tools = tools;
189
+ }
190
+ return body;
191
+ };
192
+ var parseJSON = (data) => {
193
+ try {
194
+ return JSON.parse(data);
195
+ } catch {
196
+ return null;
197
+ }
198
+ };
199
+ var parseToolInput = (rawArguments) => {
200
+ try {
201
+ return JSON.parse(rawArguments);
202
+ } catch {
203
+ return rawArguments;
204
+ }
205
+ };
206
+ var extractUsage = (response) => {
207
+ if (!isRecord(response.usage)) {
208
+ return;
209
+ }
210
+ const { usage } = response;
211
+ return {
212
+ inputTokens: typeof usage.input_tokens === "number" ? usage.input_tokens : 0,
213
+ outputTokens: typeof usage.output_tokens === "number" ? usage.output_tokens : 0
214
+ };
215
+ };
216
+ var extractMimeFormat = (mimeType) => {
217
+ if (typeof mimeType !== "string") {
218
+ return "png";
219
+ }
220
+ if (mimeType.includes("jpeg"))
221
+ return "jpeg";
222
+ if (mimeType.includes("webp"))
223
+ return "webp";
224
+ return "png";
225
+ };
226
+ var processTextDelta = function* (parsed) {
227
+ if (typeof parsed.delta === "string") {
228
+ yield { content: parsed.delta, type: "text" };
229
+ }
230
+ };
231
+ var processPartialImage = function* (parsed) {
232
+ const itemId = typeof parsed.item_id === "string" ? parsed.item_id : undefined;
233
+ const b64 = typeof parsed.partial_image_b64 === "string" ? parsed.partial_image_b64 : undefined;
234
+ if (b64) {
235
+ yield {
236
+ data: b64,
237
+ format: "png",
238
+ imageId: itemId,
239
+ isPartial: true,
240
+ type: "image"
241
+ };
242
+ }
243
+ };
244
+ var processFunctionCallArgumentsDelta = (parsed, pendingCalls) => {
245
+ const itemId = typeof parsed.item_id === "string" ? parsed.item_id : "";
246
+ const callId = typeof parsed.call_id === "string" ? parsed.call_id : "";
247
+ const delta = typeof parsed.arguments_delta === "string" ? parsed.arguments_delta : "";
248
+ const existing = pendingCalls.get(itemId);
249
+ if (existing) {
250
+ existing.arguments += delta;
251
+ } else {
252
+ pendingCalls.set(itemId, {
253
+ arguments: delta,
254
+ callId,
255
+ name: ""
256
+ });
257
+ }
258
+ };
259
+ var processFunctionCallArgumentsDone = function* (parsed, pendingCalls) {
260
+ const itemId = typeof parsed.item_id === "string" ? parsed.item_id : "";
261
+ const callId = typeof parsed.call_id === "string" ? parsed.call_id : "";
262
+ const fullArgs = typeof parsed.arguments === "string" ? parsed.arguments : "";
263
+ const pending = pendingCalls.get(itemId);
264
+ const name = pending?.name ?? "";
265
+ const args = fullArgs || pending?.arguments || "";
266
+ pendingCalls.delete(itemId);
267
+ yield {
268
+ id: callId,
269
+ input: parseToolInput(args),
270
+ name,
271
+ type: "tool_use"
272
+ };
273
+ };
274
+ var processOutputItemAdded = (parsed, pendingCalls) => {
275
+ if (!isRecord(parsed.item)) {
276
+ return;
277
+ }
278
+ const { item } = parsed;
279
+ const itemId = typeof item.id === "string" ? item.id : "";
280
+ const itemType = typeof item.type === "string" ? item.type : "";
281
+ if (itemType === "function_call") {
282
+ const callId = typeof item.call_id === "string" ? item.call_id : "";
283
+ const name = typeof item.name === "string" ? item.name : "";
284
+ pendingCalls.set(itemId, {
285
+ arguments: "",
286
+ callId,
287
+ name
288
+ });
289
+ }
290
+ };
291
+ var extractImageFromOutput = function* (output) {
292
+ for (const item of output) {
293
+ if (item.type !== "image_generation_call") {
294
+ continue;
295
+ }
296
+ if (item.status !== "completed") {
297
+ continue;
298
+ }
299
+ const data = typeof item.result === "string" ? item.result : "";
300
+ if (!data) {
301
+ continue;
302
+ }
303
+ const format = extractMimeFormat(item.output_format);
304
+ const revisedPrompt = typeof item.revised_prompt === "string" ? item.revised_prompt : undefined;
305
+ const imageId = typeof item.id === "string" ? item.id : undefined;
306
+ yield {
307
+ data,
308
+ format,
309
+ imageId,
310
+ isPartial: false,
311
+ revisedPrompt,
312
+ type: "image"
313
+ };
314
+ }
315
+ };
316
+ var processCompleted = function* (parsed) {
317
+ if (!isRecord(parsed.response)) {
318
+ yield { type: "done", usage: undefined };
319
+ return;
320
+ }
321
+ const { response } = parsed;
322
+ const usage = extractUsage(response);
323
+ if (isRecordArray(response.output)) {
324
+ yield* extractImageFromOutput(response.output);
325
+ }
326
+ yield { type: "done", usage };
327
+ };
328
+ var processSSEEvent = function* (eventType, parsed, pendingCalls) {
329
+ switch (eventType) {
330
+ case "response.output_text.delta":
331
+ yield* processTextDelta(parsed);
332
+ break;
333
+ case "response.image_generation_call.partial_image":
334
+ yield* processPartialImage(parsed);
335
+ break;
336
+ case "response.output_item.added":
337
+ processOutputItemAdded(parsed, pendingCalls);
338
+ break;
339
+ case "response.function_call_arguments.delta":
340
+ processFunctionCallArgumentsDelta(parsed, pendingCalls);
341
+ break;
342
+ case "response.function_call_arguments.done":
343
+ yield* processFunctionCallArgumentsDone(parsed, pendingCalls);
344
+ break;
345
+ case "response.completed":
346
+ yield* processCompleted(parsed);
347
+ break;
348
+ }
349
+ };
350
+ var processSSELines = function* (lines, state) {
351
+ for (const line of lines) {
352
+ const trimmed = line.trim();
353
+ if (!trimmed) {
354
+ if (state.currentEvent && state.buffer) {
355
+ const parsed = parseJSON(state.buffer);
356
+ if (parsed) {
357
+ yield* processSSEEvent(state.currentEvent, parsed, state.pendingCalls);
358
+ }
359
+ state.currentEvent = "";
360
+ state.buffer = "";
361
+ }
362
+ continue;
363
+ }
364
+ if (trimmed.startsWith("event: ")) {
365
+ state.currentEvent = trimmed.slice(EVENT_PREFIX_LENGTH);
366
+ } else if (trimmed.startsWith("data: ")) {
367
+ state.buffer = trimmed.slice(DATA_PREFIX_LENGTH);
368
+ }
369
+ }
370
+ };
371
+ var drainReader = async function* (reader, decoder, state, signal) {
372
+ let textBuffer = "";
373
+ for (let result = await reader.read();!result.done && !signal?.aborted; result = await reader.read()) {
374
+ textBuffer += decoder.decode(result.value, { stream: true });
375
+ const lines = textBuffer.split(`
376
+ `);
377
+ textBuffer = lines.pop() ?? "";
378
+ yield* processSSELines(lines, state);
379
+ }
380
+ if (textBuffer.trim()) {
381
+ yield* processSSELines([textBuffer, ""], state);
382
+ }
383
+ };
384
+ var parseSSEStream = async function* (body, signal) {
385
+ const reader = body.getReader();
386
+ const decoder = new TextDecoder;
387
+ const state = {
388
+ buffer: "",
389
+ currentEvent: "",
390
+ pendingCalls: new Map,
391
+ usage: undefined
392
+ };
393
+ try {
394
+ yield* drainReader(reader, decoder, state, signal);
395
+ } finally {
396
+ reader.releaseLock();
397
+ }
398
+ };
399
+ var fetchResponsesStream = async function* (baseUrl, apiKey, body, signal) {
400
+ const response = await fetch(`${baseUrl}/v1/responses`, {
401
+ body: JSON.stringify(body),
402
+ headers: {
403
+ Authorization: `Bearer ${apiKey}`,
404
+ "Content-Type": "application/json"
405
+ },
406
+ method: "POST",
407
+ signal
408
+ });
409
+ if (!response.ok) {
410
+ const errorText = await response.text();
411
+ throw new Error(`OpenAI Responses API error ${response.status}: ${errorText}`);
412
+ }
413
+ if (!response.body) {
414
+ throw new Error("OpenAI Responses API returned no response body");
415
+ }
416
+ yield* parseSSEStream(response.body, signal);
417
+ };
418
+ var openaiResponses = (config) => {
419
+ const baseUrl = config.baseUrl ?? DEFAULT_BASE_URL;
420
+ return {
421
+ stream: (params) => {
422
+ const body = buildRequestBody(params, config.imageGeneration);
423
+ return fetchResponsesStream(baseUrl, config.apiKey, body, params.signal);
424
+ }
425
+ };
426
+ };
427
+ export {
428
+ openaiResponses
429
+ };
430
+
431
+ //# debugId=4420F3FC6A3CF19564756E2164756E21
432
+ //# sourceMappingURL=openaiResponses.js.map
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/ai/providers/openaiResponses.ts"],
4
+ "sourcesContent": [
5
+ "import type {\n\tAIChunk,\n\tAIProviderConfig,\n\tAIProviderContentBlock,\n\tAIProviderMessage,\n\tAIProviderStreamParams,\n\tAIProviderToolDefinition,\n\tAIUsage\n} from '../../../types/ai';\n\ntype OpenAIResponsesConfig = {\n\tapiKey: string;\n\tbaseUrl?: string;\n\timageGeneration?: {\n\t\tpartialImages?: number;\n\t};\n};\n\ntype PendingFunctionCall = {\n\tcallId: string;\n\tname: string;\n\targuments: string;\n};\n\ntype StreamState = {\n\tbuffer: string;\n\tcurrentEvent: string;\n\tpendingCalls: Map<string, PendingFunctionCall>;\n\tusage: AIUsage | undefined;\n};\n\nconst DEFAULT_BASE_URL = 'https://api.openai.com';\nconst EVENT_PREFIX_LENGTH = 7;\nconst DATA_PREFIX_LENGTH = 6;\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n\ttypeof value === 'object' && value !== null;\n\nconst isRecordArray = (\n\tvalue: unknown\n): value is Array<Record<string, unknown>> =>\n\tArray.isArray(value) && value.length > 0 && isRecord(value[0]);\n\n/* ─── Message conversion ─── */\n\nconst mapContentToResponsesFormat = (\n\tcontent: string | AIProviderContentBlock[]\n): string | Array<Record<string, unknown>> => {\n\tif (typeof content === 'string') {\n\t\treturn content;\n\t}\n\n\tconst parts: Array<Record<string, unknown>> = [];\n\n\tfor (const block of content) {\n\t\tif (block.type === 'text') {\n\t\t\tparts.push({ text: block.content, type: 'input_text' });\n\t\t} else if (block.type === 'image') {\n\t\t\tparts.push({\n\t\t\t\timage_url: {\n\t\t\t\t\turl: `data:${block.source.media_type};base64,${block.source.data}`\n\t\t\t\t},\n\t\t\t\ttype: 'input_image'\n\t\t\t});\n\t\t} else if (block.type === 'document') {\n\t\t\tparts.push({\n\t\t\t\tfile: {\n\t\t\t\t\tfile_data: `data:${block.source.media_type};base64,${block.source.data}`,\n\t\t\t\t\tfilename: block.name ?? 'document.pdf'\n\t\t\t\t},\n\t\t\t\ttype: 'input_file'\n\t\t\t});\n\t\t}\n\t}\n\n\treturn parts.length > 0 ? parts : '';\n};\n\nconst hasToolBlocks = (content: AIProviderContentBlock[]) =>\n\tcontent.some(\n\t\t(block) => block.type === 'tool_use' || block.type === 'tool_result'\n\t);\n\nconst convertToolBlocks = (\n\tcontent: AIProviderContentBlock[]\n): Array<Record<string, unknown>> => {\n\tconst items: Array<Record<string, unknown>> = [];\n\n\tfor (const block of content) {\n\t\tif (block.type === 'tool_use') {\n\t\t\titems.push({\n\t\t\t\targuments:\n\t\t\t\t\ttypeof block.input === 'string'\n\t\t\t\t\t\t? block.input\n\t\t\t\t\t\t: JSON.stringify(block.input),\n\t\t\t\tcall_id: block.id,\n\t\t\t\tname: block.name,\n\t\t\t\ttype: 'function_call'\n\t\t\t});\n\t\t} else if (block.type === 'tool_result') {\n\t\t\titems.push({\n\t\t\t\tcall_id: block.tool_use_id,\n\t\t\t\toutput: typeof block.content === 'string' ? block.content : '',\n\t\t\t\ttype: 'function_call_output'\n\t\t\t});\n\t\t}\n\t}\n\n\treturn items;\n};\n\nconst convertMessage = (\n\tmsg: AIProviderMessage\n): Array<Record<string, unknown>> => {\n\tif (typeof msg.content !== 'string' && Array.isArray(msg.content)) {\n\t\tif (hasToolBlocks(msg.content)) {\n\t\t\treturn convertToolBlocks(msg.content);\n\t\t}\n\t}\n\n\tconst content = mapContentToResponsesFormat(msg.content);\n\n\treturn [\n\t\t{\n\t\t\tcontent,\n\t\t\trole: msg.role === 'system' ? 'developer' : msg.role,\n\t\t\ttype: 'message'\n\t\t}\n\t];\n};\n\nconst buildInput = (messages: AIProviderMessage[]) => {\n\tconst input: Array<Record<string, unknown>> = [];\n\n\tfor (const msg of messages) {\n\t\tinput.push(...convertMessage(msg));\n\t}\n\n\treturn input;\n};\n\nconst mapToolDefinition = (tool: AIProviderToolDefinition) => ({\n\tdescription: tool.description,\n\tname: tool.name,\n\tparameters: tool.input_schema,\n\ttype: 'function'\n});\n\nconst buildTools = (\n\ttools: AIProviderToolDefinition[] | undefined,\n\timageGeneration: OpenAIResponsesConfig['imageGeneration']\n) => {\n\tconst result: Array<Record<string, unknown>> = [];\n\n\tif (tools) {\n\t\tfor (const tool of tools) {\n\t\t\tresult.push(mapToolDefinition(tool));\n\t\t}\n\t}\n\n\tif (imageGeneration) {\n\t\tconst imageGenTool: Record<string, unknown> = {\n\t\t\ttype: 'image_generation'\n\t\t};\n\n\t\tif (imageGeneration.partialImages !== undefined) {\n\t\t\timageGenTool.partial_images = imageGeneration.partialImages;\n\t\t}\n\n\t\tresult.push(imageGenTool);\n\t}\n\n\treturn result.length > 0 ? result : undefined;\n};\n\nconst buildRequestBody = (\n\tparams: AIProviderStreamParams,\n\timageGeneration: OpenAIResponsesConfig['imageGeneration']\n) => {\n\tconst body: Record<string, unknown> = {\n\t\tinput: buildInput(params.messages),\n\t\tmodel: params.model,\n\t\tstream: true\n\t};\n\n\tif (params.systemPrompt) {\n\t\tbody.instructions = params.systemPrompt;\n\t}\n\n\tconst tools = buildTools(params.tools, imageGeneration);\n\n\tif (tools) {\n\t\tbody.tools = tools;\n\t}\n\n\treturn body;\n};\n\n/* ─── SSE parsing ─── */\n\nconst parseJSON = (data: string) => {\n\ttry {\n\t\treturn JSON.parse(data);\n\t} catch {\n\t\treturn null;\n\t}\n};\n\nconst parseToolInput = (rawArguments: string) => {\n\ttry {\n\t\treturn JSON.parse(rawArguments);\n\t} catch {\n\t\treturn rawArguments;\n\t}\n};\n\nconst extractUsage = (\n\tresponse: Record<string, unknown>\n): AIUsage | undefined => {\n\tif (!isRecord(response.usage)) {\n\t\treturn undefined;\n\t}\n\n\tconst { usage } = response;\n\n\treturn {\n\t\tinputTokens:\n\t\t\ttypeof usage.input_tokens === 'number' ? usage.input_tokens : 0,\n\t\toutputTokens:\n\t\t\ttypeof usage.output_tokens === 'number' ? usage.output_tokens : 0\n\t};\n};\n\nconst extractMimeFormat = (mimeType: unknown) => {\n\tif (typeof mimeType !== 'string') {\n\t\treturn 'png';\n\t}\n\n\tif (mimeType.includes('jpeg')) return 'jpeg';\n\tif (mimeType.includes('webp')) return 'webp';\n\n\treturn 'png';\n};\n\nconst processTextDelta = function* (parsed: Record<string, unknown>) {\n\tif (typeof parsed.delta === 'string') {\n\t\tyield { content: parsed.delta, type: 'text' as const };\n\t}\n};\n\nconst processPartialImage = function* (parsed: Record<string, unknown>) {\n\tconst itemId =\n\t\ttypeof parsed.item_id === 'string' ? parsed.item_id : undefined;\n\tconst b64 =\n\t\ttypeof parsed.partial_image_b64 === 'string'\n\t\t\t? parsed.partial_image_b64\n\t\t\t: undefined;\n\n\tif (b64) {\n\t\tyield {\n\t\t\tdata: b64,\n\t\t\tformat: 'png',\n\t\t\timageId: itemId,\n\t\t\tisPartial: true,\n\t\t\ttype: 'image' as const\n\t\t};\n\t}\n};\n\nconst processFunctionCallArgumentsDelta = (\n\tparsed: Record<string, unknown>,\n\tpendingCalls: Map<string, PendingFunctionCall>\n) => {\n\tconst itemId = typeof parsed.item_id === 'string' ? parsed.item_id : '';\n\tconst callId = typeof parsed.call_id === 'string' ? parsed.call_id : '';\n\tconst delta =\n\t\ttypeof parsed.arguments_delta === 'string'\n\t\t\t? parsed.arguments_delta\n\t\t\t: '';\n\n\tconst existing = pendingCalls.get(itemId);\n\n\tif (existing) {\n\t\texisting.arguments += delta;\n\t} else {\n\t\tpendingCalls.set(itemId, {\n\t\t\targuments: delta,\n\t\t\tcallId,\n\t\t\tname: ''\n\t\t});\n\t}\n};\n\nconst processFunctionCallArgumentsDone = function* (\n\tparsed: Record<string, unknown>,\n\tpendingCalls: Map<string, PendingFunctionCall>\n) {\n\tconst itemId = typeof parsed.item_id === 'string' ? parsed.item_id : '';\n\tconst callId = typeof parsed.call_id === 'string' ? parsed.call_id : '';\n\tconst fullArgs =\n\t\ttypeof parsed.arguments === 'string' ? parsed.arguments : '';\n\n\tconst pending = pendingCalls.get(itemId);\n\tconst name = pending?.name ?? '';\n\tconst args = fullArgs || pending?.arguments || '';\n\n\tpendingCalls.delete(itemId);\n\n\tyield {\n\t\tid: callId,\n\t\tinput: parseToolInput(args),\n\t\tname,\n\t\ttype: 'tool_use' as const\n\t};\n};\n\nconst processOutputItemAdded = (\n\tparsed: Record<string, unknown>,\n\tpendingCalls: Map<string, PendingFunctionCall>\n) => {\n\tif (!isRecord(parsed.item)) {\n\t\treturn;\n\t}\n\n\tconst { item } = parsed;\n\tconst itemId = typeof item.id === 'string' ? item.id : '';\n\tconst itemType = typeof item.type === 'string' ? item.type : '';\n\n\tif (itemType === 'function_call') {\n\t\tconst callId = typeof item.call_id === 'string' ? item.call_id : '';\n\t\tconst name = typeof item.name === 'string' ? item.name : '';\n\n\t\tpendingCalls.set(itemId, {\n\t\t\targuments: '',\n\t\t\tcallId,\n\t\t\tname\n\t\t});\n\t}\n};\n\nconst extractImageFromOutput = function* (\n\toutput: Array<Record<string, unknown>>\n) {\n\tfor (const item of output) {\n\t\tif (item.type !== 'image_generation_call') {\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (item.status !== 'completed') {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst data = typeof item.result === 'string' ? item.result : '';\n\n\t\tif (!data) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst format = extractMimeFormat(item.output_format);\n\t\tconst revisedPrompt =\n\t\t\ttypeof item.revised_prompt === 'string'\n\t\t\t\t? item.revised_prompt\n\t\t\t\t: undefined;\n\t\tconst imageId = typeof item.id === 'string' ? item.id : undefined;\n\n\t\tyield {\n\t\t\tdata,\n\t\t\tformat,\n\t\t\timageId,\n\t\t\tisPartial: false,\n\t\t\trevisedPrompt,\n\t\t\ttype: 'image' as const\n\t\t};\n\t}\n};\n\nconst processCompleted = function* (\n\tparsed: Record<string, unknown>\n): Generator<AIChunk> {\n\tif (!isRecord(parsed.response)) {\n\t\tyield { type: 'done' as const, usage: undefined };\n\n\t\treturn;\n\t}\n\n\tconst { response } = parsed;\n\tconst usage = extractUsage(response);\n\n\tif (isRecordArray(response.output)) {\n\t\tyield* extractImageFromOutput(response.output);\n\t}\n\n\tyield { type: 'done' as const, usage };\n};\n\nconst processSSEEvent = function* (\n\teventType: string,\n\tparsed: Record<string, unknown>,\n\tpendingCalls: Map<string, PendingFunctionCall>\n): Generator<AIChunk> {\n\tswitch (eventType) {\n\t\tcase 'response.output_text.delta':\n\t\t\tyield* processTextDelta(parsed);\n\t\t\tbreak;\n\n\t\tcase 'response.image_generation_call.partial_image':\n\t\t\tyield* processPartialImage(parsed);\n\t\t\tbreak;\n\n\t\tcase 'response.output_item.added':\n\t\t\tprocessOutputItemAdded(parsed, pendingCalls);\n\t\t\tbreak;\n\n\t\tcase 'response.function_call_arguments.delta':\n\t\t\tprocessFunctionCallArgumentsDelta(parsed, pendingCalls);\n\t\t\tbreak;\n\n\t\tcase 'response.function_call_arguments.done':\n\t\t\tyield* processFunctionCallArgumentsDone(parsed, pendingCalls);\n\t\t\tbreak;\n\n\t\tcase 'response.completed':\n\t\t\tyield* processCompleted(parsed);\n\t\t\tbreak;\n\t}\n};\n\nconst processSSELines = function* (\n\tlines: string[],\n\tstate: StreamState\n): Generator<AIChunk> {\n\tfor (const line of lines) {\n\t\tconst trimmed = line.trim();\n\n\t\tif (!trimmed) {\n\t\t\tif (state.currentEvent && state.buffer) {\n\t\t\t\tconst parsed = parseJSON(state.buffer);\n\n\t\t\t\tif (parsed) {\n\t\t\t\t\tyield* processSSEEvent(\n\t\t\t\t\t\tstate.currentEvent,\n\t\t\t\t\t\tparsed,\n\t\t\t\t\t\tstate.pendingCalls\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tstate.currentEvent = '';\n\t\t\t\tstate.buffer = '';\n\t\t\t}\n\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (trimmed.startsWith('event: ')) {\n\t\t\tstate.currentEvent = trimmed.slice(EVENT_PREFIX_LENGTH);\n\t\t} else if (trimmed.startsWith('data: ')) {\n\t\t\tstate.buffer = trimmed.slice(DATA_PREFIX_LENGTH);\n\t\t}\n\t}\n};\n\nconst drainReader = async function* (\n\treader: ReadableStreamDefaultReader<Uint8Array>,\n\tdecoder: TextDecoder,\n\tstate: StreamState,\n\tsignal?: AbortSignal\n): AsyncGenerator<AIChunk> {\n\tlet textBuffer = '';\n\n\tfor (\n\t\tlet result = await reader.read();\n\t\t!result.done && !signal?.aborted;\n\t\t// eslint-disable-next-line no-await-in-loop\n\t\tresult = await reader.read()\n\t) {\n\t\ttextBuffer += decoder.decode(result.value, { stream: true });\n\t\tconst lines = textBuffer.split('\\n');\n\t\ttextBuffer = lines.pop() ?? '';\n\n\t\tyield* processSSELines(lines, state);\n\t}\n\n\tif (textBuffer.trim()) {\n\t\tyield* processSSELines([textBuffer, ''], state);\n\t}\n};\n\nconst parseSSEStream = async function* (\n\tbody: ReadableStream<Uint8Array>,\n\tsignal?: AbortSignal\n): AsyncGenerator<AIChunk> {\n\tconst reader = body.getReader();\n\tconst decoder = new TextDecoder();\n\tconst state: StreamState = {\n\t\tbuffer: '',\n\t\tcurrentEvent: '',\n\t\tpendingCalls: new Map(),\n\t\tusage: undefined\n\t};\n\n\ttry {\n\t\tyield* drainReader(reader, decoder, state, signal);\n\t} finally {\n\t\treader.releaseLock();\n\t}\n};\n\nconst fetchResponsesStream = async function* (\n\tbaseUrl: string,\n\tapiKey: string,\n\tbody: Record<string, unknown>,\n\tsignal?: AbortSignal\n): AsyncGenerator<AIChunk> {\n\tconst response = await fetch(`${baseUrl}/v1/responses`, {\n\t\tbody: JSON.stringify(body),\n\t\theaders: {\n\t\t\tAuthorization: `Bearer ${apiKey}`,\n\t\t\t'Content-Type': 'application/json'\n\t\t},\n\t\tmethod: 'POST',\n\t\tsignal\n\t});\n\n\tif (!response.ok) {\n\t\tconst errorText = await response.text();\n\t\tthrow new Error(\n\t\t\t`OpenAI Responses API error ${response.status}: ${errorText}`\n\t\t);\n\t}\n\n\tif (!response.body) {\n\t\tthrow new Error('OpenAI Responses API returned no response body');\n\t}\n\n\tyield* parseSSEStream(response.body, signal);\n};\n\nexport const openaiResponses = (\n\tconfig: OpenAIResponsesConfig\n): AIProviderConfig => {\n\tconst baseUrl = config.baseUrl ?? DEFAULT_BASE_URL;\n\n\treturn {\n\t\tstream: (params: AIProviderStreamParams) => {\n\t\t\tconst body = buildRequestBody(params, config.imageGeneration);\n\n\t\t\treturn fetchResponsesStream(\n\t\t\t\tbaseU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