@ai-sdk/openai 4.0.91 → 4.0.93

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/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # @ai-sdk/openai
2
2
 
3
+ ## 4.0.93
4
+
5
+ ### Patch Changes
6
+
7
+ - 216e2c9: fix(openai): send assistant text with content instead of an item reference when its reasoning was removed
8
+
9
+ With reasoning models and `store: true`, pruning reasoning (e.g. `pruneMessages({ reasoning: 'all' })`) caused follow-up requests to fail with "Item 'msg\_...' of type 'message' was provided without its required 'reasoning' item". Assistant text parts are now only sent as item references when they are preceded by reasoning in the same assistant message.
10
+
11
+ ## 4.0.92
12
+
13
+ ### Patch Changes
14
+
15
+ - 6aedb07: fix(openai): replay web search results when response storage is disabled
16
+ - e57803c: Expose complete retrieved web-search URLs and file-search documents as sources, and normalize inline references separately as citations on text parts and text-end events. Preserve citation-derived sources when retrieval data is unavailable, including web-search-preview and Azure responses. Keep raw annotations, citation titles, and text locations available. Deduplicate file-search passages by file ID.
17
+ - 1f7e5ad: fix(openai): JSON-encode custom tool input deltas for progressive UI updates
18
+ - Updated dependencies [9667bf2]
19
+ - Updated dependencies [e57803c]
20
+ - Updated dependencies [81663cc]
21
+ - @ai-sdk/provider-utils@5.0.59
22
+ - @ai-sdk/provider@4.0.27
23
+
3
24
  ## 4.0.91
4
25
 
5
26
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -1925,6 +1925,9 @@ type OpenaiResponsesTextProviderMetadata = {
1925
1925
  openai: ResponsesTextProviderMetadata;
1926
1926
  };
1927
1927
  type ResponsesSourceDocumentProviderMetadata = {
1928
+ type: 'file_search';
1929
+ fileId: string;
1930
+ } | {
1928
1931
  type: 'file_citation';
1929
1932
  fileId: string;
1930
1933
  index: number;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":["_$__tool_apply_patch0.ApplyPatchOperation","_$__tool_custom0.customToolFactory","_$_0.OpenAIComputerAction","_$_0.OpenAIComputerSafetyCheck","_$__responses_openai_responses_api0.OpenAIResponsesFileSearchToolComparisonFilter","_$__responses_openai_responses_api0.OpenAIResponsesFileSearchToolCompoundFilter","_$__tool_web_search0.webSearchToolFactory","RealtimeModelV4ClientSecretOptions","RealtimeModelV4ClientSecretResult","RealtimeModelV4ServerEvent","RealtimeModelV4ClientEvent","RealtimeModelV4SessionConfig","RealtimeModelV4","RealtimeModelV4SessionConfig","RealtimeModelV4ClientEvent","RealtimeModelV4","RealtimeModelV4","RealtimeFactoryV4","DecisionModelV4","SpeechTranslationModelV4","BatchV4","SpeechTranslationModelV4StreamOptions","SpeechTranslationModelV4"],"sources":["../src/openai-config.ts","../src/openai-decision-model.ts","../src/chat/openai-chat-language-model-options.ts","../src/completion/openai-completion-language-model-options.ts","../src/embedding/openai-embedding-model-options.ts","../src/image/openai-image-model-options.ts","../src/tool/apply-patch.ts","../src/tool/custom.ts","../src/responses/openai-responses-api.ts","../src/tool/web-search.ts","../src/openai-tools.ts","../src/live/openai-realtime-model-live-options.ts","../src/realtime/openai-realtime-model.ts","../src/live/openai-realtime-model-live.ts","../src/realtime/openai-realtime-factory.ts","../src/responses/openai-responses-language-model-options.ts","../src/speech/openai-speech-model-options.ts","../src/transcription/openai-transcription-model-options.ts","../src/speech-translation/openai-speech-translation-model-options.ts","../src/openai-provider.ts","../src/responses/openai-responses-prepare-tools.ts","../src/speech-translation/openai-speech-translation-model.ts","../src/files/openai-files-options.ts","../src/tool/computer.ts","../src/responses/openai-responses-provider-metadata.ts","../src/version.ts","../src/openai-decision-model-options.ts"],"mappings":";;;;KAKK,gBAAgB;KAMT;EACV;EACA;EACA,MAAM;IAAW;IAAiB;;EAClC,gBAAgB;EAChB,QAAQ;EACR,YAAY;EACZ;;;;;;;EAOA;;;;;;;EAOA;;;;;;;;;EASA;;;;KCdU;;;KCnBA;cAsEC,iEAA8B;;;;;;;;;;;;;;;;;;;;;;;KAwJ/B,iCAAiC,mBAC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EI,sBAAoB,EAAA,uBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CxB,EAAA,KAAA;KAkCU,uBAAuB,EAAE,aAAa;KACtC,4BAA4B,EAAE,aAAa;;;KCzFlD,uBAAuB,mBAAmB;KAE1C,gDAAgD,QACnD;EACE;;KAGQ;EACV;EACA,WAAW,MAAM;EACjB;EACA;;KAGU;EACV;EACA;;KAGU;EACV,QAAQ;;KAGE;EACV,QAAQ;;KAGE;EACV;EACA;EACA;EACA;IACM;;IAEA;IACA;;;KAII;EACV,QAAQ;;KAGE;EACV;EACA;EACA;;KAGU;EACV,QAAQ;;KAGE;EACV;EACA;EACA,cAAc,MAAM;;KAGV;EACV,QAAQ;;KAGE;EAEN;EACA;EACA;;EAGA;EACA;EACA;;EAGA;EACA;EACA;;KAGM;EACV,QAAQ;;;;qBCrFG;;;cCKA,6DAA0B;EAAA;;KAS3B,6BAA6B,mBAChC"}
1
+ {"version":3,"file":"index.d.ts","names":["_$__tool_apply_patch0.ApplyPatchOperation","_$__tool_custom0.customToolFactory","_$_0.OpenAIComputerAction","_$_0.OpenAIComputerSafetyCheck","_$__responses_openai_responses_api0.OpenAIResponsesFileSearchToolComparisonFilter","_$__responses_openai_responses_api0.OpenAIResponsesFileSearchToolCompoundFilter","_$__tool_web_search0.webSearchToolFactory","RealtimeModelV4ClientSecretOptions","RealtimeModelV4ClientSecretResult","RealtimeModelV4ServerEvent","RealtimeModelV4ClientEvent","RealtimeModelV4SessionConfig","RealtimeModelV4","RealtimeModelV4SessionConfig","RealtimeModelV4ClientEvent","RealtimeModelV4","RealtimeModelV4","RealtimeFactoryV4","DecisionModelV4","SpeechTranslationModelV4","BatchV4","SpeechTranslationModelV4StreamOptions","SpeechTranslationModelV4"],"sources":["../src/openai-config.ts","../src/openai-decision-model.ts","../src/chat/openai-chat-language-model-options.ts","../src/completion/openai-completion-language-model-options.ts","../src/embedding/openai-embedding-model-options.ts","../src/image/openai-image-model-options.ts","../src/tool/apply-patch.ts","../src/tool/custom.ts","../src/responses/openai-responses-api.ts","../src/tool/web-search.ts","../src/openai-tools.ts","../src/live/openai-realtime-model-live-options.ts","../src/realtime/openai-realtime-model.ts","../src/live/openai-realtime-model-live.ts","../src/realtime/openai-realtime-factory.ts","../src/responses/openai-responses-language-model-options.ts","../src/speech/openai-speech-model-options.ts","../src/transcription/openai-transcription-model-options.ts","../src/speech-translation/openai-speech-translation-model-options.ts","../src/openai-provider.ts","../src/responses/openai-responses-prepare-tools.ts","../src/speech-translation/openai-speech-translation-model.ts","../src/files/openai-files-options.ts","../src/tool/computer.ts","../src/responses/openai-responses-provider-metadata.ts","../src/version.ts","../src/openai-decision-model-options.ts"],"mappings":";;;;KAKK,gBAAgB;KAMT;EACV;EACA;EACA,MAAM;IAAW;IAAiB;;EAClC,gBAAgB;EAChB,QAAQ;EACR,YAAY;EACZ;;;;;;;EAOA;;;;;;;EAOA;;;;;;;;;EASA;;;;KCdU;;;KCnBA;cAsEC,iEAA8B;;;;;;;;;;;;;;;;;;;;;;;KAwJ/B,iCAAiC,mBACpC;;;KC/NG;cAKC,uEAAoC;;cAApC;;;;;KAiDD,uCAAuC,mBAC1C;;;KCxDG;cAMC,8DAA2B;;;;KAkB5B,8BAA8B,mBACjC;;;KCzBG;cAiFC,0DAAuB;;;;;;;KAIxB,0BAA0B,mBAC7B;cAGI,oEAAiC;;;;;;;;;KAmBlC,oCAAoC,mBACvC;cAGI,8DAA2B;;;;;;;;KAW5B,8BAA8B,mBACjC;;;;;;KCzEG;EAEN;;;;EAIA;;;;EAIA;;EAGA;;;;EAIA;;EAGA;;;;EAIA;;;;EAIA;;;;cCxDO,oDAAiB;;;;EAMZ;;;;;EAMN;;;;;EAOJ;IACE;IACA;IACA;;IAGA;;;;;;;;KCocE;;;;EAIV;;;;EAKA;;;;EAKA;;;;;KAMU;;;;EAIV;;;;EAKA,SAAS,MACL,gDACA;;cAkVO,6DAA0B;;;;;;;;;;;;;;;;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AAQ;;;;qBCzFG;;;cCKA,6DAA0B;EAAA;;KAS3B,6BAA6B,mBAChC"}
package/dist/index.js CHANGED
@@ -4580,6 +4580,47 @@ function mapToolCaller(caller) {
4580
4580
  caller_id: caller.callerId
4581
4581
  } : caller;
4582
4582
  }
4583
+ async function convertWebSearchToolResultOutput({ output, id }) {
4584
+ if (output.type !== "json") return;
4585
+ const validation = await safeValidateTypes({
4586
+ value: output.value,
4587
+ schema: webSearchOutputSchema
4588
+ });
4589
+ if (!validation.success || validation.value.action == null) return;
4590
+ const { action, sources } = validation.value;
4591
+ switch (action.type) {
4592
+ case "search": return {
4593
+ type: "web_search_call",
4594
+ id,
4595
+ status: "completed",
4596
+ action: {
4597
+ type: "search",
4598
+ ...action.query != null && { query: action.query },
4599
+ ...action.queries != null && { queries: action.queries },
4600
+ ...sources != null && { sources }
4601
+ }
4602
+ };
4603
+ case "openPage": return {
4604
+ type: "web_search_call",
4605
+ id,
4606
+ status: "completed",
4607
+ action: {
4608
+ type: "open_page",
4609
+ url: action.url
4610
+ }
4611
+ };
4612
+ case "findInPage": return {
4613
+ type: "web_search_call",
4614
+ id,
4615
+ status: "completed",
4616
+ action: {
4617
+ type: "find_in_page",
4618
+ url: action.url,
4619
+ pattern: action.pattern
4620
+ }
4621
+ };
4622
+ }
4623
+ }
4583
4624
  async function convertFunctionToolResultOutput({ output, toolName, outputSchemaToolNames, promptCacheBreakpoint, providerOptionsName, warnings }) {
4584
4625
  const hasOutputSchema = outputSchemaToolNames?.has(toolName);
4585
4626
  const convertScalarOutput = (value) => promptCacheBreakpoint == null ? value : [{
@@ -4725,7 +4766,7 @@ function isFileId(data, prefixes) {
4725
4766
  if (!prefixes) return false;
4726
4767
  return prefixes.some((prefix) => data.startsWith(prefix));
4727
4768
  }
4728
- async function convertToOpenAIResponsesInput({ prompt, toolNameMapping, systemMessageMode, providerOptionsName, explicitMessageItemType = false, fileIdPrefixes, passThroughUnsupportedFiles = false, store, hasConversation = false, hasPreviousResponseId = false, hasLocalShellTool = false, hasShellTool = false, hasApplyPatchTool = false, hasComputerTool = false, toolSearchToolName, customProviderToolNames, outputSchemaToolNames, configurationUpdateUnsupportedReason }) {
4769
+ async function convertToOpenAIResponsesInput({ prompt, toolNameMapping, systemMessageMode, providerOptionsName, explicitMessageItemType = false, fileIdPrefixes, passThroughUnsupportedFiles = false, store, isReasoningModel = false, hasConversation = false, hasPreviousResponseId = false, hasLocalShellTool = false, hasShellTool = false, hasApplyPatchTool = false, hasComputerTool = false, toolSearchToolName, customProviderToolNames, outputSchemaToolNames, configurationUpdateUnsupportedReason }) {
4729
4770
  let input = [];
4730
4771
  const warnings = [];
4731
4772
  const processedApprovalIds = /* @__PURE__ */ new Set();
@@ -4866,13 +4907,14 @@ async function convertToOpenAIResponsesInput({ prompt, toolNameMapping, systemMe
4866
4907
  case "assistant": {
4867
4908
  const reasoningMessages = {};
4868
4909
  const emittedTextItemIds = /* @__PURE__ */ new Set();
4910
+ let hasPrecedingReasoning = false;
4869
4911
  for (const part of content) switch (part.type) {
4870
4912
  case "text": {
4871
4913
  const providerOptions = part.providerOptions?.[providerOptionsName];
4872
4914
  const id = providerOptions?.itemId;
4873
4915
  const phase = providerOptions?.phase;
4874
4916
  if (hasConversation && id != null) break;
4875
- if (store && id != null) {
4917
+ if (store && id != null && (!isReasoningModel || hasPrecedingReasoning)) {
4876
4918
  if (!emittedTextItemIds.has(id)) {
4877
4919
  emittedTextItemIds.add(id);
4878
4920
  input.push({
@@ -5097,6 +5139,24 @@ async function convertToOpenAIResponsesInput({ prompt, toolNameMapping, systemMe
5097
5139
  if (part.output.type === "execution-denied" || part.output.type === "json" && typeof part.output.value === "object" && part.output.value != null && "type" in part.output.value && part.output.value.type === "execution-denied") break;
5098
5140
  if (hasConversation) break;
5099
5141
  const resolvedResultToolName = toolNameMapping.toProviderToolName(part.toolName);
5142
+ if (resolvedResultToolName === "web_search" || resolvedResultToolName === "web_search_preview") {
5143
+ const itemId = (part.providerOptions?.[providerOptionsName])?.itemId ?? part.toolCallId;
5144
+ if (store) {
5145
+ input.push({
5146
+ type: "item_reference",
5147
+ id: itemId
5148
+ });
5149
+ break;
5150
+ }
5151
+ const webSearchCall = await convertWebSearchToolResultOutput({
5152
+ output: part.output,
5153
+ id: itemId
5154
+ });
5155
+ if (webSearchCall != null) {
5156
+ input.push(webSearchCall);
5157
+ break;
5158
+ }
5159
+ }
5100
5160
  if (part.toolName === toolSearchToolName) {
5101
5161
  const itemId = part.providerOptions?.[providerOptionsName]?.itemId ?? part.providerMetadata?.[providerOptionsName]?.itemId ?? part.toolCallId;
5102
5162
  if (store) input.push({
@@ -5174,6 +5234,7 @@ async function convertToOpenAIResponsesInput({ prompt, toolNameMapping, systemMe
5174
5234
  break;
5175
5235
  }
5176
5236
  case "reasoning": {
5237
+ hasPrecedingReasoning = true;
5177
5238
  const providerOptions = await parseProviderOptions({
5178
5239
  provider: providerOptionsName,
5179
5240
  providerOptions: part.providerOptions,
@@ -5532,6 +5593,40 @@ const openaiResponsesReasoningProviderOptionsSchema = z.object({
5532
5593
  reasoningEncryptedContent: z.string().nullish()
5533
5594
  });
5534
5595
  //#endregion
5596
+ //#region src/responses/map-openai-responses-annotation.ts
5597
+ function mapOpenAIResponsesAnnotationSource(annotation, providerOptionsName, id) {
5598
+ if (annotation.type === "url_citation") return {
5599
+ type: "source",
5600
+ sourceType: "url",
5601
+ id,
5602
+ url: annotation.url,
5603
+ title: annotation.title
5604
+ };
5605
+ const filename = annotation.type === "file_path" ? annotation.file_id : annotation.filename;
5606
+ return {
5607
+ type: "source",
5608
+ sourceType: "document",
5609
+ id,
5610
+ mediaType: annotation.type === "file_path" ? "application/octet-stream" : "text/plain",
5611
+ title: filename,
5612
+ filename,
5613
+ providerMetadata: { [providerOptionsName]: {
5614
+ type: annotation.type,
5615
+ fileId: annotation.file_id,
5616
+ ...annotation.type === "container_file_citation" ? { containerId: annotation.container_id } : { index: annotation.index }
5617
+ } }
5618
+ };
5619
+ }
5620
+ function mapOpenAIResponsesCitations(annotations, providerOptionsName) {
5621
+ return annotations.flatMap((annotation) => annotation.type === "file_path" ? [] : [{
5622
+ source: mapOpenAIResponsesAnnotationSource(annotation, providerOptionsName, annotation.type === "url_citation" ? annotation.url : annotation.file_id),
5623
+ ..."start_index" in annotation ? {
5624
+ startIndex: annotation.start_index,
5625
+ endIndex: annotation.end_index
5626
+ } : {}
5627
+ }]);
5628
+ }
5629
+ //#endregion
5535
5630
  //#region src/responses/openai-responses-prepare-tools.ts
5536
5631
  async function prepareResponsesTools({ tools, toolChoice, allowedTools, toolNameMapping, customProviderToolNames, outputSchemaToolNames, supportsAsyncToolCalling = true }) {
5537
5632
  tools = tools?.length ? tools : void 0;
@@ -6179,6 +6274,7 @@ var OpenAIResponsesLanguageModel = class OpenAIResponsesLanguageModel {
6179
6274
  fileIdPrefixes: config.fileIdPrefixes,
6180
6275
  passThroughUnsupportedFiles: openaiOptions?.passThroughUnsupportedFiles ?? false,
6181
6276
  store: openaiOptions?.store ?? true,
6277
+ isReasoningModel,
6182
6278
  hasConversation: openaiOptions?.conversation != null,
6183
6279
  hasPreviousResponseId: openaiOptions?.previousResponseId != null,
6184
6280
  hasLocalShellTool: hasOpenAITool("openai.local_shell"),
@@ -6418,6 +6514,9 @@ var OpenAIResponsesLanguageModel = class OpenAIResponsesLanguageModel {
6418
6514
  const content = [];
6419
6515
  const logprobs = [];
6420
6516
  const functionTools = options.tools?.filter((tool) => tool.type === "function") ?? [];
6517
+ const hasWebSearchActionSources = response.output.some((part) => part.type === "web_search_call" && part.action?.type === "search" && part.action.sources?.some((source) => source.type === "url"));
6518
+ const hasFileSearchResults = response.output.some((part) => part.type === "file_search_call" && (part.results?.length ?? 0) > 0);
6519
+ const retrievedFileIds = /* @__PURE__ */ new Set();
6421
6520
  let hasFunctionCall = false;
6422
6521
  const hostedToolSearchCallIds = [];
6423
6522
  for (const part of response.output) switch (part.type) {
@@ -6523,54 +6622,13 @@ var OpenAIResponsesLanguageModel = class OpenAIResponsesLanguageModel {
6523
6622
  content.push({
6524
6623
  type: "text",
6525
6624
  text: contentPart.text,
6625
+ ...contentPart.annotations.some((annotation) => annotation.type !== "file_path") && { citations: mapOpenAIResponsesCitations(contentPart.annotations, providerOptionsName) },
6526
6626
  providerMetadata: { [providerOptionsName]: providerMetadata }
6527
6627
  });
6528
- for (const annotation of contentPart.annotations) if (annotation.type === "url_citation") content.push({
6529
- type: "source",
6530
- sourceType: "url",
6531
- id: this.config.generateId?.() ?? generateId(),
6532
- url: annotation.url,
6533
- title: annotation.title
6534
- });
6535
- else if (annotation.type === "file_citation") content.push({
6536
- type: "source",
6537
- sourceType: "document",
6538
- id: this.config.generateId?.() ?? generateId(),
6539
- mediaType: "text/plain",
6540
- title: annotation.filename,
6541
- filename: annotation.filename,
6542
- providerMetadata: { [providerOptionsName]: {
6543
- type: annotation.type,
6544
- fileId: annotation.file_id,
6545
- index: annotation.index
6546
- } }
6547
- });
6548
- else if (annotation.type === "container_file_citation") content.push({
6549
- type: "source",
6550
- sourceType: "document",
6551
- id: this.config.generateId?.() ?? generateId(),
6552
- mediaType: "text/plain",
6553
- title: annotation.filename,
6554
- filename: annotation.filename,
6555
- providerMetadata: { [providerOptionsName]: {
6556
- type: annotation.type,
6557
- fileId: annotation.file_id,
6558
- containerId: annotation.container_id
6559
- } }
6560
- });
6561
- else if (annotation.type === "file_path") content.push({
6562
- type: "source",
6563
- sourceType: "document",
6564
- id: this.config.generateId?.() ?? generateId(),
6565
- mediaType: "application/octet-stream",
6566
- title: annotation.file_id,
6567
- filename: annotation.file_id,
6568
- providerMetadata: { [providerOptionsName]: {
6569
- type: annotation.type,
6570
- fileId: annotation.file_id,
6571
- index: annotation.index
6572
- } }
6573
- });
6628
+ for (const annotation of contentPart.annotations) {
6629
+ if (annotation.type === "url_citation" && hasWebSearchActionSources || annotation.type === "file_citation" && hasFileSearchResults) continue;
6630
+ content.push(mapOpenAIResponsesAnnotationSource(annotation, providerOptionsName, this.config.generateId?.() ?? generateId()));
6631
+ }
6574
6632
  }
6575
6633
  break;
6576
6634
  case "function_call": {
@@ -6663,6 +6721,14 @@ var OpenAIResponsesLanguageModel = class OpenAIResponsesLanguageModel {
6663
6721
  result: { status: part.status }
6664
6722
  } : { result: mapWebSearchOutput(part.action) }
6665
6723
  });
6724
+ if (part.action?.type === "search") {
6725
+ for (const source of part.action.sources ?? []) if (source.type === "url") content.push({
6726
+ type: "source",
6727
+ sourceType: "url",
6728
+ id: this.config.generateId?.() ?? generateId(),
6729
+ url: source.url
6730
+ });
6731
+ }
6666
6732
  break;
6667
6733
  case "mcp_call": {
6668
6734
  const toolCallId = part.approval_request_id != null ? approvalRequestIdToDummyToolCallIdFromPrompt[part.approval_request_id] ?? part.id : part.id;
@@ -6765,6 +6831,22 @@ var OpenAIResponsesLanguageModel = class OpenAIResponsesLanguageModel {
6765
6831
  })) ?? null
6766
6832
  }
6767
6833
  });
6834
+ for (const result of part.results ?? []) {
6835
+ if (retrievedFileIds.has(result.file_id)) continue;
6836
+ retrievedFileIds.add(result.file_id);
6837
+ content.push({
6838
+ type: "source",
6839
+ sourceType: "document",
6840
+ id: this.config.generateId?.() ?? generateId(),
6841
+ mediaType: "text/plain",
6842
+ title: result.filename,
6843
+ filename: result.filename,
6844
+ providerMetadata: { [providerOptionsName]: {
6845
+ type: "file_search",
6846
+ fileId: result.file_id
6847
+ } }
6848
+ });
6849
+ }
6768
6850
  break;
6769
6851
  case "code_interpreter_call":
6770
6852
  content.push({
@@ -6875,7 +6957,11 @@ var OpenAIResponsesLanguageModel = class OpenAIResponsesLanguageModel {
6875
6957
  const logprobs = [];
6876
6958
  let responseId = null;
6877
6959
  const ongoingToolCalls = {};
6878
- const ongoingAnnotations = [];
6960
+ let ongoingAnnotations = [];
6961
+ let hasWebSearchActionSources = false;
6962
+ let hasFileSearchResults = false;
6963
+ const retrievedFileIds = /* @__PURE__ */ new Set();
6964
+ const fallbackAnnotations = [];
6879
6965
  let activeMessagePhase;
6880
6966
  let hasFunctionCall = false;
6881
6967
  const activeReasoning = {};
@@ -6948,6 +7034,11 @@ var OpenAIResponsesLanguageModel = class OpenAIResponsesLanguageModel {
6948
7034
  id: value.item.call_id,
6949
7035
  toolName
6950
7036
  });
7037
+ controller.enqueue({
7038
+ type: "tool-input-delta",
7039
+ id: value.item.call_id,
7040
+ delta: "\""
7041
+ });
6951
7042
  } else if (value.item.type === "web_search_call") {
6952
7043
  ongoingToolCalls[value.output_index] = {
6953
7044
  toolName: toolNameMapping.toCustomToolName(webSearchToolName ?? "web_search"),
@@ -7067,7 +7158,7 @@ var OpenAIResponsesLanguageModel = class OpenAIResponsesLanguageModel {
7067
7158
  };
7068
7159
  else if (value.item.type === "shell_call_output") {} else if (value.item.type === "message") {
7069
7160
  activeOutputItemIds[value.output_index] = value.item.id;
7070
- ongoingAnnotations.splice(0);
7161
+ ongoingAnnotations = [];
7071
7162
  activeMessagePhase = value.item.phase ?? void 0;
7072
7163
  controller.enqueue({
7073
7164
  type: "text-start",
@@ -7103,6 +7194,7 @@ var OpenAIResponsesLanguageModel = class OpenAIResponsesLanguageModel {
7103
7194
  controller.enqueue({
7104
7195
  type: "text-end",
7105
7196
  id: itemId,
7197
+ ...ongoingAnnotations.some((annotation) => annotation.type !== "file_path") && { citations: mapOpenAIResponsesCitations(ongoingAnnotations, providerOptionsName) },
7106
7198
  providerMetadata: { [providerOptionsName]: {
7107
7199
  itemId,
7108
7200
  ...phase != null && { phase },
@@ -7221,6 +7313,11 @@ var OpenAIResponsesLanguageModel = class OpenAIResponsesLanguageModel {
7221
7313
  ongoingToolCalls[value.output_index] = void 0;
7222
7314
  hasFunctionCall = true;
7223
7315
  const toolName = toolNameMapping.toCustomToolName(value.item.name);
7316
+ controller.enqueue({
7317
+ type: "tool-input-delta",
7318
+ id: value.item.call_id,
7319
+ delta: "\""
7320
+ });
7224
7321
  controller.enqueue({
7225
7322
  type: "tool-input-end",
7226
7323
  id: value.item.call_id
@@ -7246,6 +7343,17 @@ var OpenAIResponsesLanguageModel = class OpenAIResponsesLanguageModel {
7246
7343
  result: { status: value.item.status }
7247
7344
  } : { result: mapWebSearchOutput(value.item.action) }
7248
7345
  });
7346
+ if (value.item.action?.type === "search") {
7347
+ for (const source of value.item.action.sources ?? []) if (source.type === "url") {
7348
+ hasWebSearchActionSources = true;
7349
+ controller.enqueue({
7350
+ type: "source",
7351
+ sourceType: "url",
7352
+ id: self.config.generateId?.() ?? generateId(),
7353
+ url: source.url
7354
+ });
7355
+ }
7356
+ }
7249
7357
  } else if (value.item.type === "computer_call") {
7250
7358
  ongoingToolCalls[value.output_index] = void 0;
7251
7359
  if (value.item.call_id == null) {
@@ -7307,6 +7415,23 @@ var OpenAIResponsesLanguageModel = class OpenAIResponsesLanguageModel {
7307
7415
  })) ?? null
7308
7416
  }
7309
7417
  });
7418
+ for (const result of value.item.results ?? []) {
7419
+ hasFileSearchResults = true;
7420
+ if (retrievedFileIds.has(result.file_id)) continue;
7421
+ retrievedFileIds.add(result.file_id);
7422
+ controller.enqueue({
7423
+ type: "source",
7424
+ sourceType: "document",
7425
+ id: self.config.generateId?.() ?? generateId(),
7426
+ mediaType: "text/plain",
7427
+ title: result.filename,
7428
+ filename: result.filename,
7429
+ providerMetadata: { [providerOptionsName]: {
7430
+ type: "file_search",
7431
+ fileId: result.file_id
7432
+ } }
7433
+ });
7434
+ }
7310
7435
  } else if (value.item.type === "code_interpreter_call") {
7311
7436
  ongoingToolCalls[value.output_index] = void 0;
7312
7437
  controller.enqueue({
@@ -7520,7 +7645,7 @@ var OpenAIResponsesLanguageModel = class OpenAIResponsesLanguageModel {
7520
7645
  if (toolCall != null) controller.enqueue({
7521
7646
  type: "tool-input-delta",
7522
7647
  id: toolCall.toolCallId,
7523
- delta: value.delta
7648
+ delta: escapeJSONDelta(value.delta)
7524
7649
  });
7525
7650
  } else if (isResponseApplyPatchCallOperationDiffDeltaChunk(value)) {
7526
7651
  const toolCall = ongoingToolCalls[value.output_index];
@@ -7704,52 +7829,8 @@ var OpenAIResponsesLanguageModel = class OpenAIResponsesLanguageModel {
7704
7829
  }
7705
7830
  } else if (isResponseAnnotationAddedChunk(value)) {
7706
7831
  ongoingAnnotations.push(value.annotation);
7707
- if (value.annotation.type === "url_citation") controller.enqueue({
7708
- type: "source",
7709
- sourceType: "url",
7710
- id: self.config.generateId?.() ?? generateId(),
7711
- url: value.annotation.url,
7712
- title: value.annotation.title
7713
- });
7714
- else if (value.annotation.type === "file_citation") controller.enqueue({
7715
- type: "source",
7716
- sourceType: "document",
7717
- id: self.config.generateId?.() ?? generateId(),
7718
- mediaType: "text/plain",
7719
- title: value.annotation.filename,
7720
- filename: value.annotation.filename,
7721
- providerMetadata: { [providerOptionsName]: {
7722
- type: value.annotation.type,
7723
- fileId: value.annotation.file_id,
7724
- index: value.annotation.index
7725
- } }
7726
- });
7727
- else if (value.annotation.type === "container_file_citation") controller.enqueue({
7728
- type: "source",
7729
- sourceType: "document",
7730
- id: self.config.generateId?.() ?? generateId(),
7731
- mediaType: "text/plain",
7732
- title: value.annotation.filename,
7733
- filename: value.annotation.filename,
7734
- providerMetadata: { [providerOptionsName]: {
7735
- type: value.annotation.type,
7736
- fileId: value.annotation.file_id,
7737
- containerId: value.annotation.container_id
7738
- } }
7739
- });
7740
- else if (value.annotation.type === "file_path") controller.enqueue({
7741
- type: "source",
7742
- sourceType: "document",
7743
- id: self.config.generateId?.() ?? generateId(),
7744
- mediaType: "application/octet-stream",
7745
- title: value.annotation.file_id,
7746
- filename: value.annotation.file_id,
7747
- providerMetadata: { [providerOptionsName]: {
7748
- type: value.annotation.type,
7749
- fileId: value.annotation.file_id,
7750
- index: value.annotation.index
7751
- } }
7752
- });
7832
+ if (value.annotation.type === "url_citation" || value.annotation.type === "file_citation") fallbackAnnotations.push(value.annotation);
7833
+ else controller.enqueue(mapOpenAIResponsesAnnotationSource(value.annotation, providerOptionsName, self.config.generateId?.() ?? generateId()));
7753
7834
  } else if (isErrorChunk(value)) {
7754
7835
  encounteredStreamError = true;
7755
7836
  finishReason = {
@@ -7763,6 +7844,10 @@ var OpenAIResponsesLanguageModel = class OpenAIResponsesLanguageModel {
7763
7844
  }
7764
7845
  },
7765
7846
  flush(controller) {
7847
+ for (const annotation of fallbackAnnotations) {
7848
+ if (annotation.type === "url_citation" && hasWebSearchActionSources || annotation.type === "file_citation" && hasFileSearchResults) continue;
7849
+ controller.enqueue(mapOpenAIResponsesAnnotationSource(annotation, providerOptionsName, self.config.generateId?.() ?? generateId()));
7850
+ }
7766
7851
  for (const toolCall of Object.values(ongoingToolCalls)) {
7767
7852
  if (!toolCall?.suppressInputStreaming) continue;
7768
7853
  controller.enqueue({
@@ -10086,7 +10171,7 @@ var OpenAISkills = class {
10086
10171
  };
10087
10172
  //#endregion
10088
10173
  //#region src/version.ts
10089
- const VERSION = "4.0.91";
10174
+ const VERSION = "4.0.93";
10090
10175
  //#endregion
10091
10176
  //#region src/openai-provider.ts
10092
10177
  /**