@ai-sdk/openai 4.0.0-beta.2 → 4.0.0-beta.21

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 (48) hide show
  1. package/CHANGELOG.md +234 -22
  2. package/README.md +2 -0
  3. package/dist/index.d.mts +134 -35
  4. package/dist/index.d.ts +134 -35
  5. package/dist/index.js +1700 -1139
  6. package/dist/index.js.map +1 -1
  7. package/dist/index.mjs +1697 -1117
  8. package/dist/index.mjs.map +1 -1
  9. package/dist/internal/index.d.mts +107 -41
  10. package/dist/internal/index.d.ts +107 -41
  11. package/dist/internal/index.js +1380 -939
  12. package/dist/internal/index.js.map +1 -1
  13. package/dist/internal/index.mjs +1371 -917
  14. package/dist/internal/index.mjs.map +1 -1
  15. package/docs/03-openai.mdx +274 -9
  16. package/package.json +3 -5
  17. package/src/chat/convert-openai-chat-usage.ts +2 -2
  18. package/src/chat/convert-to-openai-chat-messages.ts +26 -15
  19. package/src/chat/map-openai-finish-reason.ts +2 -2
  20. package/src/chat/openai-chat-language-model.ts +32 -24
  21. package/src/chat/openai-chat-options.ts +5 -0
  22. package/src/chat/openai-chat-prepare-tools.ts +6 -6
  23. package/src/completion/convert-openai-completion-usage.ts +2 -2
  24. package/src/completion/convert-to-openai-completion-prompt.ts +2 -2
  25. package/src/completion/map-openai-finish-reason.ts +2 -2
  26. package/src/completion/openai-completion-language-model.ts +20 -20
  27. package/src/embedding/openai-embedding-model.ts +5 -5
  28. package/src/files/openai-files-api.ts +17 -0
  29. package/src/files/openai-files-options.ts +18 -0
  30. package/src/files/openai-files.ts +102 -0
  31. package/src/image/openai-image-model.ts +9 -9
  32. package/src/index.ts +2 -0
  33. package/src/openai-config.ts +5 -5
  34. package/src/openai-language-model-capabilities.ts +3 -2
  35. package/src/openai-provider.ts +39 -21
  36. package/src/openai-tools.ts +12 -1
  37. package/src/responses/convert-openai-responses-usage.ts +2 -2
  38. package/src/responses/convert-to-openai-responses-input.ts +188 -14
  39. package/src/responses/map-openai-responses-finish-reason.ts +2 -2
  40. package/src/responses/openai-responses-api.ts +136 -2
  41. package/src/responses/openai-responses-language-model.ts +233 -37
  42. package/src/responses/openai-responses-options.ts +24 -2
  43. package/src/responses/openai-responses-prepare-tools.ts +34 -9
  44. package/src/responses/openai-responses-provider-metadata.ts +10 -0
  45. package/src/speech/openai-speech-model.ts +7 -7
  46. package/src/tool/custom.ts +0 -6
  47. package/src/tool/tool-search.ts +98 -0
  48. package/src/transcription/openai-transcription-model.ts +8 -8
@@ -18,8 +18,8 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
 
20
20
  // src/internal/index.ts
21
- var internal_exports = {};
22
- __export(internal_exports, {
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
23
  OpenAIChatLanguageModel: () => OpenAIChatLanguageModel,
24
24
  OpenAICompletionLanguageModel: () => OpenAICompletionLanguageModel,
25
25
  OpenAIEmbeddingModel: () => OpenAIEmbeddingModel,
@@ -54,7 +54,7 @@ __export(internal_exports, {
54
54
  webSearchPreviewArgsSchema: () => webSearchPreviewArgsSchema,
55
55
  webSearchPreviewInputSchema: () => webSearchPreviewInputSchema
56
56
  });
57
- module.exports = __toCommonJS(internal_exports);
57
+ module.exports = __toCommonJS(index_exports);
58
58
 
59
59
  // src/chat/openai-chat-language-model.ts
60
60
  var import_provider3 = require("@ai-sdk/provider");
@@ -82,9 +82,9 @@ var openaiFailedResponseHandler = (0, import_provider_utils.createJsonErrorRespo
82
82
  // src/openai-language-model-capabilities.ts
83
83
  function getOpenAILanguageModelCapabilities(modelId) {
84
84
  const supportsFlexProcessing = modelId.startsWith("o3") || modelId.startsWith("o4-mini") || modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-chat");
85
- const supportsPriorityProcessing = modelId.startsWith("gpt-4") || modelId.startsWith("gpt-5-mini") || modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-nano") && !modelId.startsWith("gpt-5-chat") || modelId.startsWith("o3") || modelId.startsWith("o4-mini");
85
+ const supportsPriorityProcessing = modelId.startsWith("gpt-4") || modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-nano") && !modelId.startsWith("gpt-5-chat") && !modelId.startsWith("gpt-5.4-nano") || modelId.startsWith("o3") || modelId.startsWith("o4-mini");
86
86
  const isReasoningModel = modelId.startsWith("o1") || modelId.startsWith("o3") || modelId.startsWith("o4-mini") || modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-chat");
87
- const supportsNonReasoningParameters = modelId.startsWith("gpt-5.1") || modelId.startsWith("gpt-5.2") || modelId.startsWith("gpt-5.4");
87
+ const supportsNonReasoningParameters = modelId.startsWith("gpt-5.1") || modelId.startsWith("gpt-5.2") || modelId.startsWith("gpt-5.3") || modelId.startsWith("gpt-5.4");
88
88
  const systemMessageMode = isReasoningModel ? "developer" : "system";
89
89
  return {
90
90
  supportsFlexProcessing,
@@ -186,13 +186,23 @@ function convertToOpenAIChatMessages({
186
186
  return { type: "text", text: part.text };
187
187
  }
188
188
  case "file": {
189
+ if ((0, import_provider_utils2.isProviderReference)(part.data)) {
190
+ return {
191
+ type: "file",
192
+ file: {
193
+ file_id: (0, import_provider_utils2.resolveProviderReference)({
194
+ reference: part.data,
195
+ provider: "openai"
196
+ })
197
+ }
198
+ };
199
+ }
189
200
  if (part.mediaType.startsWith("image/")) {
190
201
  const mediaType = part.mediaType === "image/*" ? "image/jpeg" : part.mediaType;
191
202
  return {
192
203
  type: "image_url",
193
204
  image_url: {
194
205
  url: part.data instanceof URL ? part.data.toString() : `data:${mediaType};base64,${(0, import_provider_utils2.convertToBase64)(part.data)}`,
195
- // OpenAI specific extension: image detail
196
206
  detail: (_b = (_a2 = part.providerOptions) == null ? void 0 : _a2.openai) == null ? void 0 : _b.imageDetail
197
207
  }
198
208
  };
@@ -236,7 +246,7 @@ function convertToOpenAIChatMessages({
236
246
  }
237
247
  return {
238
248
  type: "file",
239
- file: typeof part.data === "string" && part.data.startsWith("file-") ? { file_id: part.data } : {
249
+ file: {
240
250
  filename: (_c = part.filename) != null ? _c : `part-${index}.pdf`,
241
251
  file_data: `data:application/pdf;base64,${(0, import_provider_utils2.convertToBase64)(part.data)}`
242
252
  }
@@ -675,7 +685,7 @@ function prepareChatTools({
675
685
  // src/chat/openai-chat-language-model.ts
676
686
  var OpenAIChatLanguageModel = class {
677
687
  constructor(modelId, config) {
678
- this.specificationVersion = "v3";
688
+ this.specificationVersion = "v4";
679
689
  this.supportedUrls = {
680
690
  "image/*": [/^https?:\/\/.*$/]
681
691
  };
@@ -698,9 +708,10 @@ var OpenAIChatLanguageModel = class {
698
708
  seed,
699
709
  tools,
700
710
  toolChoice,
711
+ reasoning,
701
712
  providerOptions
702
713
  }) {
703
- var _a, _b, _c, _d, _e;
714
+ var _a, _b, _c, _d, _e, _f;
704
715
  const warnings = [];
705
716
  const openaiOptions = (_a = await (0, import_provider_utils5.parseProviderOptions)({
706
717
  provider: "openai",
@@ -708,18 +719,19 @@ var OpenAIChatLanguageModel = class {
708
719
  schema: openaiLanguageModelChatOptions
709
720
  })) != null ? _a : {};
710
721
  const modelCapabilities = getOpenAILanguageModelCapabilities(this.modelId);
711
- const isReasoningModel = (_b = openaiOptions.forceReasoning) != null ? _b : modelCapabilities.isReasoningModel;
722
+ const resolvedReasoningEffort = (_b = openaiOptions.reasoningEffort) != null ? _b : (0, import_provider_utils5.isCustomReasoning)(reasoning) ? reasoning : void 0;
723
+ const isReasoningModel = (_c = openaiOptions.forceReasoning) != null ? _c : modelCapabilities.isReasoningModel;
712
724
  if (topK != null) {
713
725
  warnings.push({ type: "unsupported", feature: "topK" });
714
726
  }
715
727
  const { messages, warnings: messageWarnings } = convertToOpenAIChatMessages(
716
728
  {
717
729
  prompt,
718
- systemMessageMode: (_c = openaiOptions.systemMessageMode) != null ? _c : isReasoningModel ? "developer" : modelCapabilities.systemMessageMode
730
+ systemMessageMode: (_d = openaiOptions.systemMessageMode) != null ? _d : isReasoningModel ? "developer" : modelCapabilities.systemMessageMode
719
731
  }
720
732
  );
721
733
  warnings.push(...messageWarnings);
722
- const strictJsonSchema = (_d = openaiOptions.strictJsonSchema) != null ? _d : true;
734
+ const strictJsonSchema = (_e = openaiOptions.strictJsonSchema) != null ? _e : true;
723
735
  const baseArgs = {
724
736
  // model id:
725
737
  model: this.modelId,
@@ -740,7 +752,7 @@ var OpenAIChatLanguageModel = class {
740
752
  json_schema: {
741
753
  schema: responseFormat.schema,
742
754
  strict: strictJsonSchema,
743
- name: (_e = responseFormat.name) != null ? _e : "response",
755
+ name: (_f = responseFormat.name) != null ? _f : "response",
744
756
  description: responseFormat.description
745
757
  }
746
758
  } : { type: "json_object" } : void 0,
@@ -753,7 +765,7 @@ var OpenAIChatLanguageModel = class {
753
765
  store: openaiOptions.store,
754
766
  metadata: openaiOptions.metadata,
755
767
  prediction: openaiOptions.prediction,
756
- reasoning_effort: openaiOptions.reasoningEffort,
768
+ reasoning_effort: resolvedReasoningEffort,
757
769
  service_tier: openaiOptions.serviceTier,
758
770
  prompt_cache_key: openaiOptions.promptCacheKey,
759
771
  prompt_cache_retention: openaiOptions.promptCacheRetention,
@@ -762,7 +774,7 @@ var OpenAIChatLanguageModel = class {
762
774
  messages
763
775
  };
764
776
  if (isReasoningModel) {
765
- if (openaiOptions.reasoningEffort !== "none" || !modelCapabilities.supportsNonReasoningParameters) {
777
+ if (resolvedReasoningEffort !== "none" || !modelCapabilities.supportsNonReasoningParameters) {
766
778
  if (baseArgs.temperature != null) {
767
779
  baseArgs.temperature = void 0;
768
780
  warnings.push({
@@ -1410,7 +1422,7 @@ var openaiLanguageModelCompletionOptions = (0, import_provider_utils7.lazySchema
1410
1422
  // src/completion/openai-completion-language-model.ts
1411
1423
  var OpenAICompletionLanguageModel = class {
1412
1424
  constructor(modelId, config) {
1413
- this.specificationVersion = "v3";
1425
+ this.specificationVersion = "v4";
1414
1426
  this.supportedUrls = {
1415
1427
  // No URLs are supported for completion models.
1416
1428
  };
@@ -1675,7 +1687,7 @@ var openaiTextEmbeddingResponseSchema = (0, import_provider_utils10.lazySchema)(
1675
1687
  // src/embedding/openai-embedding-model.ts
1676
1688
  var OpenAIEmbeddingModel = class {
1677
1689
  constructor(modelId, config) {
1678
- this.specificationVersion = "v3";
1690
+ this.specificationVersion = "v4";
1679
1691
  this.maxEmbeddingsPerCall = 2048;
1680
1692
  this.supportsParallelCalls = true;
1681
1693
  this.modelId = modelId;
@@ -1796,7 +1808,7 @@ var OpenAIImageModel = class {
1796
1808
  constructor(modelId, config) {
1797
1809
  this.modelId = modelId;
1798
1810
  this.config = config;
1799
- this.specificationVersion = "v3";
1811
+ this.specificationVersion = "v4";
1800
1812
  }
1801
1813
  get maxImagesPerCall() {
1802
1814
  var _a;
@@ -2117,7 +2129,7 @@ var OpenAITranscriptionModel = class {
2117
2129
  constructor(modelId, config) {
2118
2130
  this.modelId = modelId;
2119
2131
  this.config = config;
2120
- this.specificationVersion = "v3";
2132
+ this.specificationVersion = "v4";
2121
2133
  }
2122
2134
  get provider() {
2123
2135
  return this.config.provider;
@@ -2240,7 +2252,7 @@ var OpenAISpeechModel = class {
2240
2252
  constructor(modelId, config) {
2241
2253
  this.modelId = modelId;
2242
2254
  this.config = config;
2243
- this.specificationVersion = "v3";
2255
+ this.specificationVersion = "v4";
2244
2256
  }
2245
2257
  get provider() {
2246
2258
  return this.config.provider;
@@ -2338,7 +2350,7 @@ var OpenAISpeechModel = class {
2338
2350
 
2339
2351
  // src/responses/openai-responses-language-model.ts
2340
2352
  var import_provider8 = require("@ai-sdk/provider");
2341
- var import_provider_utils33 = require("@ai-sdk/provider-utils");
2353
+ var import_provider_utils34 = require("@ai-sdk/provider-utils");
2342
2354
 
2343
2355
  // src/responses/convert-openai-responses-usage.ts
2344
2356
  function convertOpenAIResponsesUsage(usage) {
@@ -2381,8 +2393,8 @@ function convertOpenAIResponsesUsage(usage) {
2381
2393
 
2382
2394
  // src/responses/convert-to-openai-responses-input.ts
2383
2395
  var import_provider6 = require("@ai-sdk/provider");
2384
- var import_provider_utils22 = require("@ai-sdk/provider-utils");
2385
- var import_v415 = require("zod/v4");
2396
+ var import_provider_utils23 = require("@ai-sdk/provider-utils");
2397
+ var import_v416 = require("zod/v4");
2386
2398
 
2387
2399
  // src/tool/apply-patch.ts
2388
2400
  var import_provider_utils19 = require("@ai-sdk/provider-utils");
@@ -2549,6 +2561,39 @@ var shell = (0, import_provider_utils21.createProviderToolFactoryWithOutputSchem
2549
2561
  outputSchema: shellOutputSchema
2550
2562
  });
2551
2563
 
2564
+ // src/tool/tool-search.ts
2565
+ var import_provider_utils22 = require("@ai-sdk/provider-utils");
2566
+ var import_v415 = require("zod/v4");
2567
+ var toolSearchArgsSchema = (0, import_provider_utils22.lazySchema)(
2568
+ () => (0, import_provider_utils22.zodSchema)(
2569
+ import_v415.z.object({
2570
+ execution: import_v415.z.enum(["server", "client"]).optional(),
2571
+ description: import_v415.z.string().optional(),
2572
+ parameters: import_v415.z.record(import_v415.z.string(), import_v415.z.unknown()).optional()
2573
+ })
2574
+ )
2575
+ );
2576
+ var toolSearchInputSchema = (0, import_provider_utils22.lazySchema)(
2577
+ () => (0, import_provider_utils22.zodSchema)(
2578
+ import_v415.z.object({
2579
+ arguments: import_v415.z.unknown().optional(),
2580
+ call_id: import_v415.z.string().nullish()
2581
+ })
2582
+ )
2583
+ );
2584
+ var toolSearchOutputSchema = (0, import_provider_utils22.lazySchema)(
2585
+ () => (0, import_provider_utils22.zodSchema)(
2586
+ import_v415.z.object({
2587
+ tools: import_v415.z.array(import_v415.z.record(import_v415.z.string(), import_v415.z.unknown()))
2588
+ })
2589
+ )
2590
+ );
2591
+ var toolSearchToolFactory = (0, import_provider_utils22.createProviderToolFactoryWithOutputSchema)({
2592
+ id: "openai.tool_search",
2593
+ inputSchema: toolSearchInputSchema,
2594
+ outputSchema: toolSearchOutputSchema
2595
+ });
2596
+
2552
2597
  // src/responses/convert-to-openai-responses-input.ts
2553
2598
  function isFileId(data, prefixes) {
2554
2599
  if (!prefixes) return false;
@@ -2567,8 +2612,8 @@ async function convertToOpenAIResponsesInput({
2567
2612
  hasApplyPatchTool = false,
2568
2613
  customProviderToolNames
2569
2614
  }) {
2570
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
2571
- const input = [];
2615
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
2616
+ let input = [];
2572
2617
  const warnings = [];
2573
2618
  const processedApprovalIds = /* @__PURE__ */ new Set();
2574
2619
  for (const { role, content } of prompt) {
@@ -2603,20 +2648,37 @@ async function convertToOpenAIResponsesInput({
2603
2648
  input.push({
2604
2649
  role: "user",
2605
2650
  content: content.map((part, index) => {
2606
- var _a2, _b2, _c2;
2651
+ var _a2, _b2, _c2, _d2, _e2;
2607
2652
  switch (part.type) {
2608
2653
  case "text": {
2609
2654
  return { type: "input_text", text: part.text };
2610
2655
  }
2611
2656
  case "file": {
2657
+ if ((0, import_provider_utils23.isProviderReference)(part.data)) {
2658
+ const fileId = (0, import_provider_utils23.resolveProviderReference)({
2659
+ reference: part.data,
2660
+ provider: providerOptionsName
2661
+ });
2662
+ if (part.mediaType.startsWith("image/")) {
2663
+ return {
2664
+ type: "input_image",
2665
+ file_id: fileId,
2666
+ detail: (_b2 = (_a2 = part.providerOptions) == null ? void 0 : _a2[providerOptionsName]) == null ? void 0 : _b2.imageDetail
2667
+ };
2668
+ }
2669
+ return {
2670
+ type: "input_file",
2671
+ file_id: fileId
2672
+ };
2673
+ }
2612
2674
  if (part.mediaType.startsWith("image/")) {
2613
2675
  const mediaType = part.mediaType === "image/*" ? "image/jpeg" : part.mediaType;
2614
2676
  return {
2615
2677
  type: "input_image",
2616
2678
  ...part.data instanceof URL ? { image_url: part.data.toString() } : typeof part.data === "string" && isFileId(part.data, fileIdPrefixes) ? { file_id: part.data } : {
2617
- image_url: `data:${mediaType};base64,${(0, import_provider_utils22.convertToBase64)(part.data)}`
2679
+ image_url: `data:${mediaType};base64,${(0, import_provider_utils23.convertToBase64)(part.data)}`
2618
2680
  },
2619
- detail: (_b2 = (_a2 = part.providerOptions) == null ? void 0 : _a2[providerOptionsName]) == null ? void 0 : _b2.imageDetail
2681
+ detail: (_d2 = (_c2 = part.providerOptions) == null ? void 0 : _c2[providerOptionsName]) == null ? void 0 : _d2.imageDetail
2620
2682
  };
2621
2683
  } else if (part.mediaType === "application/pdf") {
2622
2684
  if (part.data instanceof URL) {
@@ -2628,8 +2690,8 @@ async function convertToOpenAIResponsesInput({
2628
2690
  return {
2629
2691
  type: "input_file",
2630
2692
  ...typeof part.data === "string" && isFileId(part.data, fileIdPrefixes) ? { file_id: part.data } : {
2631
- filename: (_c2 = part.filename) != null ? _c2 : `part-${index}.pdf`,
2632
- file_data: `data:application/pdf;base64,${(0, import_provider_utils22.convertToBase64)(part.data)}`
2693
+ filename: (_e2 = part.filename) != null ? _e2 : `part-${index}.pdf`,
2694
+ file_data: `data:application/pdf;base64,${(0, import_provider_utils23.convertToBase64)(part.data)}`
2633
2695
  }
2634
2696
  };
2635
2697
  } else {
@@ -2671,6 +2733,32 @@ async function convertToOpenAIResponsesInput({
2671
2733
  if (hasConversation && id != null) {
2672
2734
  break;
2673
2735
  }
2736
+ const resolvedToolName = toolNameMapping.toProviderToolName(
2737
+ part.toolName
2738
+ );
2739
+ if (resolvedToolName === "tool_search") {
2740
+ if (store && id != null) {
2741
+ input.push({ type: "item_reference", id });
2742
+ break;
2743
+ }
2744
+ const parsedInput = typeof part.input === "string" ? await (0, import_provider_utils23.parseJSON)({
2745
+ text: part.input,
2746
+ schema: toolSearchInputSchema
2747
+ }) : await (0, import_provider_utils23.validateTypes)({
2748
+ value: part.input,
2749
+ schema: toolSearchInputSchema
2750
+ });
2751
+ const execution = parsedInput.call_id != null ? "client" : "server";
2752
+ input.push({
2753
+ type: "tool_search_call",
2754
+ id: id != null ? id : part.toolCallId,
2755
+ execution,
2756
+ call_id: (_g = parsedInput.call_id) != null ? _g : null,
2757
+ status: "completed",
2758
+ arguments: parsedInput.arguments
2759
+ });
2760
+ break;
2761
+ }
2674
2762
  if (part.providerExecuted) {
2675
2763
  if (store && id != null) {
2676
2764
  input.push({ type: "item_reference", id });
@@ -2681,11 +2769,8 @@ async function convertToOpenAIResponsesInput({
2681
2769
  input.push({ type: "item_reference", id });
2682
2770
  break;
2683
2771
  }
2684
- const resolvedToolName = toolNameMapping.toProviderToolName(
2685
- part.toolName
2686
- );
2687
2772
  if (hasLocalShellTool && resolvedToolName === "local_shell") {
2688
- const parsedInput = await (0, import_provider_utils22.validateTypes)({
2773
+ const parsedInput = await (0, import_provider_utils23.validateTypes)({
2689
2774
  value: part.input,
2690
2775
  schema: localShellInputSchema
2691
2776
  });
@@ -2705,7 +2790,7 @@ async function convertToOpenAIResponsesInput({
2705
2790
  break;
2706
2791
  }
2707
2792
  if (hasShellTool && resolvedToolName === "shell") {
2708
- const parsedInput = await (0, import_provider_utils22.validateTypes)({
2793
+ const parsedInput = await (0, import_provider_utils23.validateTypes)({
2709
2794
  value: part.input,
2710
2795
  schema: shellInputSchema
2711
2796
  });
@@ -2723,7 +2808,7 @@ async function convertToOpenAIResponsesInput({
2723
2808
  break;
2724
2809
  }
2725
2810
  if (hasApplyPatchTool && resolvedToolName === "apply_patch") {
2726
- const parsedInput = await (0, import_provider_utils22.validateTypes)({
2811
+ const parsedInput = await (0, import_provider_utils23.validateTypes)({
2727
2812
  value: part.input,
2728
2813
  schema: applyPatchInputSchema
2729
2814
  });
@@ -2766,9 +2851,29 @@ async function convertToOpenAIResponsesInput({
2766
2851
  const resolvedResultToolName = toolNameMapping.toProviderToolName(
2767
2852
  part.toolName
2768
2853
  );
2854
+ if (resolvedResultToolName === "tool_search") {
2855
+ const itemId = (_j = (_i = (_h = part.providerOptions) == null ? void 0 : _h[providerOptionsName]) == null ? void 0 : _i.itemId) != null ? _j : part.toolCallId;
2856
+ if (store) {
2857
+ input.push({ type: "item_reference", id: itemId });
2858
+ } else if (part.output.type === "json") {
2859
+ const parsedOutput = await (0, import_provider_utils23.validateTypes)({
2860
+ value: part.output.value,
2861
+ schema: toolSearchOutputSchema
2862
+ });
2863
+ input.push({
2864
+ type: "tool_search_output",
2865
+ id: itemId,
2866
+ execution: "server",
2867
+ call_id: null,
2868
+ status: "completed",
2869
+ tools: parsedOutput.tools
2870
+ });
2871
+ }
2872
+ break;
2873
+ }
2769
2874
  if (hasShellTool && resolvedResultToolName === "shell") {
2770
2875
  if (part.output.type === "json") {
2771
- const parsedOutput = await (0, import_provider_utils22.validateTypes)({
2876
+ const parsedOutput = await (0, import_provider_utils23.validateTypes)({
2772
2877
  value: part.output.value,
2773
2878
  schema: shellOutputSchema
2774
2879
  });
@@ -2788,7 +2893,7 @@ async function convertToOpenAIResponsesInput({
2788
2893
  break;
2789
2894
  }
2790
2895
  if (store) {
2791
- const itemId = (_i = (_h = (_g = part.providerOptions) == null ? void 0 : _g[providerOptionsName]) == null ? void 0 : _h.itemId) != null ? _i : part.toolCallId;
2896
+ const itemId = (_m = (_l = (_k = part.providerOptions) == null ? void 0 : _k[providerOptionsName]) == null ? void 0 : _l.itemId) != null ? _m : part.toolCallId;
2792
2897
  input.push({ type: "item_reference", id: itemId });
2793
2898
  } else {
2794
2899
  warnings.push({
@@ -2799,7 +2904,7 @@ async function convertToOpenAIResponsesInput({
2799
2904
  break;
2800
2905
  }
2801
2906
  case "reasoning": {
2802
- const providerOptions = await (0, import_provider_utils22.parseProviderOptions)({
2907
+ const providerOptions = await (0, import_provider_utils23.parseProviderOptions)({
2803
2908
  provider: providerOptionsName,
2804
2909
  providerOptions: part.providerOptions,
2805
2910
  schema: openaiResponsesReasoningProviderOptionsSchema
@@ -2871,6 +2976,28 @@ async function convertToOpenAIResponsesInput({
2871
2976
  }
2872
2977
  break;
2873
2978
  }
2979
+ case "custom": {
2980
+ if (part.kind === "openai.compaction") {
2981
+ const providerOpts = (_n = part.providerOptions) == null ? void 0 : _n[providerOptionsName];
2982
+ const id = providerOpts == null ? void 0 : providerOpts.itemId;
2983
+ if (hasConversation && id != null) {
2984
+ break;
2985
+ }
2986
+ if (store && id != null) {
2987
+ input.push({ type: "item_reference", id });
2988
+ break;
2989
+ }
2990
+ const encryptedContent = providerOpts == null ? void 0 : providerOpts.encryptedContent;
2991
+ if (id != null) {
2992
+ input.push({
2993
+ type: "compaction",
2994
+ id,
2995
+ encrypted_content: encryptedContent
2996
+ });
2997
+ }
2998
+ }
2999
+ break;
3000
+ }
2874
3001
  }
2875
3002
  }
2876
3003
  break;
@@ -2898,7 +3025,7 @@ async function convertToOpenAIResponsesInput({
2898
3025
  }
2899
3026
  const output = part.output;
2900
3027
  if (output.type === "execution-denied") {
2901
- const approvalId = (_k = (_j = output.providerOptions) == null ? void 0 : _j.openai) == null ? void 0 : _k.approvalId;
3028
+ const approvalId = (_p = (_o = output.providerOptions) == null ? void 0 : _o.openai) == null ? void 0 : _p.approvalId;
2902
3029
  if (approvalId) {
2903
3030
  continue;
2904
3031
  }
@@ -2906,8 +3033,22 @@ async function convertToOpenAIResponsesInput({
2906
3033
  const resolvedToolName = toolNameMapping.toProviderToolName(
2907
3034
  part.toolName
2908
3035
  );
3036
+ if (resolvedToolName === "tool_search" && output.type === "json") {
3037
+ const parsedOutput = await (0, import_provider_utils23.validateTypes)({
3038
+ value: output.value,
3039
+ schema: toolSearchOutputSchema
3040
+ });
3041
+ input.push({
3042
+ type: "tool_search_output",
3043
+ execution: "client",
3044
+ call_id: part.toolCallId,
3045
+ status: "completed",
3046
+ tools: parsedOutput.tools
3047
+ });
3048
+ continue;
3049
+ }
2909
3050
  if (hasLocalShellTool && resolvedToolName === "local_shell" && output.type === "json") {
2910
- const parsedOutput = await (0, import_provider_utils22.validateTypes)({
3051
+ const parsedOutput = await (0, import_provider_utils23.validateTypes)({
2911
3052
  value: output.value,
2912
3053
  schema: localShellOutputSchema
2913
3054
  });
@@ -2919,7 +3060,7 @@ async function convertToOpenAIResponsesInput({
2919
3060
  continue;
2920
3061
  }
2921
3062
  if (hasShellTool && resolvedToolName === "shell" && output.type === "json") {
2922
- const parsedOutput = await (0, import_provider_utils22.validateTypes)({
3063
+ const parsedOutput = await (0, import_provider_utils23.validateTypes)({
2923
3064
  value: output.value,
2924
3065
  schema: shellOutputSchema
2925
3066
  });
@@ -2938,7 +3079,7 @@ async function convertToOpenAIResponsesInput({
2938
3079
  continue;
2939
3080
  }
2940
3081
  if (hasApplyPatchTool && part.toolName === "apply_patch" && output.type === "json") {
2941
- const parsedOutput = await (0, import_provider_utils22.validateTypes)({
3082
+ const parsedOutput = await (0, import_provider_utils23.validateTypes)({
2942
3083
  value: output.value,
2943
3084
  schema: applyPatchOutputSchema
2944
3085
  });
@@ -2958,7 +3099,7 @@ async function convertToOpenAIResponsesInput({
2958
3099
  outputValue = output.value;
2959
3100
  break;
2960
3101
  case "execution-denied":
2961
- outputValue = (_l = output.reason) != null ? _l : "Tool execution denied.";
3102
+ outputValue = (_q = output.reason) != null ? _q : "Tool execution denied.";
2962
3103
  break;
2963
3104
  case "json":
2964
3105
  case "error-json":
@@ -2986,6 +3127,11 @@ async function convertToOpenAIResponsesInput({
2986
3127
  filename: (_a2 = item.filename) != null ? _a2 : "data",
2987
3128
  file_data: `data:${item.mediaType};base64,${item.data}`
2988
3129
  };
3130
+ case "file-url":
3131
+ return {
3132
+ type: "input_file",
3133
+ file_url: item.url
3134
+ };
2989
3135
  default:
2990
3136
  warnings.push({
2991
3137
  type: "other",
@@ -2993,7 +3139,7 @@ async function convertToOpenAIResponsesInput({
2993
3139
  });
2994
3140
  return void 0;
2995
3141
  }
2996
- }).filter(import_provider_utils22.isNonNullable);
3142
+ }).filter(import_provider_utils23.isNonNullable);
2997
3143
  break;
2998
3144
  default:
2999
3145
  outputValue = "";
@@ -3012,7 +3158,7 @@ async function convertToOpenAIResponsesInput({
3012
3158
  contentValue = output.value;
3013
3159
  break;
3014
3160
  case "execution-denied":
3015
- contentValue = (_m = output.reason) != null ? _m : "Tool execution denied.";
3161
+ contentValue = (_r = output.reason) != null ? _r : "Tool execution denied.";
3016
3162
  break;
3017
3163
  case "json":
3018
3164
  case "error-json":
@@ -3044,6 +3190,12 @@ async function convertToOpenAIResponsesInput({
3044
3190
  file_data: `data:${item.mediaType};base64,${item.data}`
3045
3191
  };
3046
3192
  }
3193
+ case "file-url": {
3194
+ return {
3195
+ type: "input_file",
3196
+ file_url: item.url
3197
+ };
3198
+ }
3047
3199
  default: {
3048
3200
  warnings.push({
3049
3201
  type: "other",
@@ -3052,7 +3204,7 @@ async function convertToOpenAIResponsesInput({
3052
3204
  return void 0;
3053
3205
  }
3054
3206
  }
3055
- }).filter(import_provider_utils22.isNonNullable);
3207
+ }).filter(import_provider_utils23.isNonNullable);
3056
3208
  break;
3057
3209
  }
3058
3210
  input.push({
@@ -3069,11 +3221,22 @@ async function convertToOpenAIResponsesInput({
3069
3221
  }
3070
3222
  }
3071
3223
  }
3224
+ if (!store && input.some(
3225
+ (item) => "type" in item && item.type === "reasoning" && item.encrypted_content == null
3226
+ )) {
3227
+ warnings.push({
3228
+ type: "other",
3229
+ message: "Reasoning parts without encrypted content are not supported when store is false. Skipping reasoning parts."
3230
+ });
3231
+ input = input.filter(
3232
+ (item) => !("type" in item) || item.type !== "reasoning" || item.encrypted_content != null
3233
+ );
3234
+ }
3072
3235
  return { input, warnings };
3073
3236
  }
3074
- var openaiResponsesReasoningProviderOptionsSchema = import_v415.z.object({
3075
- itemId: import_v415.z.string().nullish(),
3076
- reasoningEncryptedContent: import_v415.z.string().nullish()
3237
+ var openaiResponsesReasoningProviderOptionsSchema = import_v416.z.object({
3238
+ itemId: import_v416.z.string().nullish(),
3239
+ reasoningEncryptedContent: import_v416.z.string().nullish()
3077
3240
  });
3078
3241
 
3079
3242
  // src/responses/map-openai-responses-finish-reason.ts
@@ -3095,483 +3258,552 @@ function mapOpenAIResponseFinishReason({
3095
3258
  }
3096
3259
 
3097
3260
  // src/responses/openai-responses-api.ts
3098
- var import_provider_utils23 = require("@ai-sdk/provider-utils");
3099
- var import_v416 = require("zod/v4");
3100
- var openaiResponsesChunkSchema = (0, import_provider_utils23.lazySchema)(
3101
- () => (0, import_provider_utils23.zodSchema)(
3102
- import_v416.z.union([
3103
- import_v416.z.object({
3104
- type: import_v416.z.literal("response.output_text.delta"),
3105
- item_id: import_v416.z.string(),
3106
- delta: import_v416.z.string(),
3107
- logprobs: import_v416.z.array(
3108
- import_v416.z.object({
3109
- token: import_v416.z.string(),
3110
- logprob: import_v416.z.number(),
3111
- top_logprobs: import_v416.z.array(
3112
- import_v416.z.object({
3113
- token: import_v416.z.string(),
3114
- logprob: import_v416.z.number()
3261
+ var import_provider_utils24 = require("@ai-sdk/provider-utils");
3262
+ var import_v417 = require("zod/v4");
3263
+ var jsonValueSchema = import_v417.z.lazy(
3264
+ () => import_v417.z.union([
3265
+ import_v417.z.string(),
3266
+ import_v417.z.number(),
3267
+ import_v417.z.boolean(),
3268
+ import_v417.z.null(),
3269
+ import_v417.z.array(jsonValueSchema),
3270
+ import_v417.z.record(import_v417.z.string(), jsonValueSchema.optional())
3271
+ ])
3272
+ );
3273
+ var openaiResponsesChunkSchema = (0, import_provider_utils24.lazySchema)(
3274
+ () => (0, import_provider_utils24.zodSchema)(
3275
+ import_v417.z.union([
3276
+ import_v417.z.object({
3277
+ type: import_v417.z.literal("response.output_text.delta"),
3278
+ item_id: import_v417.z.string(),
3279
+ delta: import_v417.z.string(),
3280
+ logprobs: import_v417.z.array(
3281
+ import_v417.z.object({
3282
+ token: import_v417.z.string(),
3283
+ logprob: import_v417.z.number(),
3284
+ top_logprobs: import_v417.z.array(
3285
+ import_v417.z.object({
3286
+ token: import_v417.z.string(),
3287
+ logprob: import_v417.z.number()
3115
3288
  })
3116
3289
  )
3117
3290
  })
3118
3291
  ).nullish()
3119
3292
  }),
3120
- import_v416.z.object({
3121
- type: import_v416.z.enum(["response.completed", "response.incomplete"]),
3122
- response: import_v416.z.object({
3123
- incomplete_details: import_v416.z.object({ reason: import_v416.z.string() }).nullish(),
3124
- usage: import_v416.z.object({
3125
- input_tokens: import_v416.z.number(),
3126
- input_tokens_details: import_v416.z.object({ cached_tokens: import_v416.z.number().nullish() }).nullish(),
3127
- output_tokens: import_v416.z.number(),
3128
- output_tokens_details: import_v416.z.object({ reasoning_tokens: import_v416.z.number().nullish() }).nullish()
3293
+ import_v417.z.object({
3294
+ type: import_v417.z.enum(["response.completed", "response.incomplete"]),
3295
+ response: import_v417.z.object({
3296
+ incomplete_details: import_v417.z.object({ reason: import_v417.z.string() }).nullish(),
3297
+ usage: import_v417.z.object({
3298
+ input_tokens: import_v417.z.number(),
3299
+ input_tokens_details: import_v417.z.object({ cached_tokens: import_v417.z.number().nullish() }).nullish(),
3300
+ output_tokens: import_v417.z.number(),
3301
+ output_tokens_details: import_v417.z.object({ reasoning_tokens: import_v417.z.number().nullish() }).nullish()
3129
3302
  }),
3130
- service_tier: import_v416.z.string().nullish()
3303
+ service_tier: import_v417.z.string().nullish()
3304
+ })
3305
+ }),
3306
+ import_v417.z.object({
3307
+ type: import_v417.z.literal("response.failed"),
3308
+ response: import_v417.z.object({
3309
+ error: import_v417.z.object({
3310
+ code: import_v417.z.string().nullish(),
3311
+ message: import_v417.z.string()
3312
+ }).nullish(),
3313
+ incomplete_details: import_v417.z.object({ reason: import_v417.z.string() }).nullish(),
3314
+ usage: import_v417.z.object({
3315
+ input_tokens: import_v417.z.number(),
3316
+ input_tokens_details: import_v417.z.object({ cached_tokens: import_v417.z.number().nullish() }).nullish(),
3317
+ output_tokens: import_v417.z.number(),
3318
+ output_tokens_details: import_v417.z.object({ reasoning_tokens: import_v417.z.number().nullish() }).nullish()
3319
+ }).nullish(),
3320
+ service_tier: import_v417.z.string().nullish()
3131
3321
  })
3132
3322
  }),
3133
- import_v416.z.object({
3134
- type: import_v416.z.literal("response.created"),
3135
- response: import_v416.z.object({
3136
- id: import_v416.z.string(),
3137
- created_at: import_v416.z.number(),
3138
- model: import_v416.z.string(),
3139
- service_tier: import_v416.z.string().nullish()
3323
+ import_v417.z.object({
3324
+ type: import_v417.z.literal("response.created"),
3325
+ response: import_v417.z.object({
3326
+ id: import_v417.z.string(),
3327
+ created_at: import_v417.z.number(),
3328
+ model: import_v417.z.string(),
3329
+ service_tier: import_v417.z.string().nullish()
3140
3330
  })
3141
3331
  }),
3142
- import_v416.z.object({
3143
- type: import_v416.z.literal("response.output_item.added"),
3144
- output_index: import_v416.z.number(),
3145
- item: import_v416.z.discriminatedUnion("type", [
3146
- import_v416.z.object({
3147
- type: import_v416.z.literal("message"),
3148
- id: import_v416.z.string(),
3149
- phase: import_v416.z.enum(["commentary", "final_answer"]).nullish()
3332
+ import_v417.z.object({
3333
+ type: import_v417.z.literal("response.output_item.added"),
3334
+ output_index: import_v417.z.number(),
3335
+ item: import_v417.z.discriminatedUnion("type", [
3336
+ import_v417.z.object({
3337
+ type: import_v417.z.literal("message"),
3338
+ id: import_v417.z.string(),
3339
+ phase: import_v417.z.enum(["commentary", "final_answer"]).nullish()
3150
3340
  }),
3151
- import_v416.z.object({
3152
- type: import_v416.z.literal("reasoning"),
3153
- id: import_v416.z.string(),
3154
- encrypted_content: import_v416.z.string().nullish()
3341
+ import_v417.z.object({
3342
+ type: import_v417.z.literal("reasoning"),
3343
+ id: import_v417.z.string(),
3344
+ encrypted_content: import_v417.z.string().nullish()
3155
3345
  }),
3156
- import_v416.z.object({
3157
- type: import_v416.z.literal("function_call"),
3158
- id: import_v416.z.string(),
3159
- call_id: import_v416.z.string(),
3160
- name: import_v416.z.string(),
3161
- arguments: import_v416.z.string()
3346
+ import_v417.z.object({
3347
+ type: import_v417.z.literal("function_call"),
3348
+ id: import_v417.z.string(),
3349
+ call_id: import_v417.z.string(),
3350
+ name: import_v417.z.string(),
3351
+ arguments: import_v417.z.string()
3162
3352
  }),
3163
- import_v416.z.object({
3164
- type: import_v416.z.literal("web_search_call"),
3165
- id: import_v416.z.string(),
3166
- status: import_v416.z.string()
3353
+ import_v417.z.object({
3354
+ type: import_v417.z.literal("web_search_call"),
3355
+ id: import_v417.z.string(),
3356
+ status: import_v417.z.string()
3167
3357
  }),
3168
- import_v416.z.object({
3169
- type: import_v416.z.literal("computer_call"),
3170
- id: import_v416.z.string(),
3171
- status: import_v416.z.string()
3358
+ import_v417.z.object({
3359
+ type: import_v417.z.literal("computer_call"),
3360
+ id: import_v417.z.string(),
3361
+ status: import_v417.z.string()
3172
3362
  }),
3173
- import_v416.z.object({
3174
- type: import_v416.z.literal("file_search_call"),
3175
- id: import_v416.z.string()
3363
+ import_v417.z.object({
3364
+ type: import_v417.z.literal("file_search_call"),
3365
+ id: import_v417.z.string()
3176
3366
  }),
3177
- import_v416.z.object({
3178
- type: import_v416.z.literal("image_generation_call"),
3179
- id: import_v416.z.string()
3367
+ import_v417.z.object({
3368
+ type: import_v417.z.literal("image_generation_call"),
3369
+ id: import_v417.z.string()
3180
3370
  }),
3181
- import_v416.z.object({
3182
- type: import_v416.z.literal("code_interpreter_call"),
3183
- id: import_v416.z.string(),
3184
- container_id: import_v416.z.string(),
3185
- code: import_v416.z.string().nullable(),
3186
- outputs: import_v416.z.array(
3187
- import_v416.z.discriminatedUnion("type", [
3188
- import_v416.z.object({ type: import_v416.z.literal("logs"), logs: import_v416.z.string() }),
3189
- import_v416.z.object({ type: import_v416.z.literal("image"), url: import_v416.z.string() })
3371
+ import_v417.z.object({
3372
+ type: import_v417.z.literal("code_interpreter_call"),
3373
+ id: import_v417.z.string(),
3374
+ container_id: import_v417.z.string(),
3375
+ code: import_v417.z.string().nullable(),
3376
+ outputs: import_v417.z.array(
3377
+ import_v417.z.discriminatedUnion("type", [
3378
+ import_v417.z.object({ type: import_v417.z.literal("logs"), logs: import_v417.z.string() }),
3379
+ import_v417.z.object({ type: import_v417.z.literal("image"), url: import_v417.z.string() })
3190
3380
  ])
3191
3381
  ).nullable(),
3192
- status: import_v416.z.string()
3382
+ status: import_v417.z.string()
3193
3383
  }),
3194
- import_v416.z.object({
3195
- type: import_v416.z.literal("mcp_call"),
3196
- id: import_v416.z.string(),
3197
- status: import_v416.z.string(),
3198
- approval_request_id: import_v416.z.string().nullish()
3384
+ import_v417.z.object({
3385
+ type: import_v417.z.literal("mcp_call"),
3386
+ id: import_v417.z.string(),
3387
+ status: import_v417.z.string(),
3388
+ approval_request_id: import_v417.z.string().nullish()
3199
3389
  }),
3200
- import_v416.z.object({
3201
- type: import_v416.z.literal("mcp_list_tools"),
3202
- id: import_v416.z.string()
3390
+ import_v417.z.object({
3391
+ type: import_v417.z.literal("mcp_list_tools"),
3392
+ id: import_v417.z.string()
3203
3393
  }),
3204
- import_v416.z.object({
3205
- type: import_v416.z.literal("mcp_approval_request"),
3206
- id: import_v416.z.string()
3394
+ import_v417.z.object({
3395
+ type: import_v417.z.literal("mcp_approval_request"),
3396
+ id: import_v417.z.string()
3207
3397
  }),
3208
- import_v416.z.object({
3209
- type: import_v416.z.literal("apply_patch_call"),
3210
- id: import_v416.z.string(),
3211
- call_id: import_v416.z.string(),
3212
- status: import_v416.z.enum(["in_progress", "completed"]),
3213
- operation: import_v416.z.discriminatedUnion("type", [
3214
- import_v416.z.object({
3215
- type: import_v416.z.literal("create_file"),
3216
- path: import_v416.z.string(),
3217
- diff: import_v416.z.string()
3398
+ import_v417.z.object({
3399
+ type: import_v417.z.literal("apply_patch_call"),
3400
+ id: import_v417.z.string(),
3401
+ call_id: import_v417.z.string(),
3402
+ status: import_v417.z.enum(["in_progress", "completed"]),
3403
+ operation: import_v417.z.discriminatedUnion("type", [
3404
+ import_v417.z.object({
3405
+ type: import_v417.z.literal("create_file"),
3406
+ path: import_v417.z.string(),
3407
+ diff: import_v417.z.string()
3218
3408
  }),
3219
- import_v416.z.object({
3220
- type: import_v416.z.literal("delete_file"),
3221
- path: import_v416.z.string()
3409
+ import_v417.z.object({
3410
+ type: import_v417.z.literal("delete_file"),
3411
+ path: import_v417.z.string()
3222
3412
  }),
3223
- import_v416.z.object({
3224
- type: import_v416.z.literal("update_file"),
3225
- path: import_v416.z.string(),
3226
- diff: import_v416.z.string()
3413
+ import_v417.z.object({
3414
+ type: import_v417.z.literal("update_file"),
3415
+ path: import_v417.z.string(),
3416
+ diff: import_v417.z.string()
3227
3417
  })
3228
3418
  ])
3229
3419
  }),
3230
- import_v416.z.object({
3231
- type: import_v416.z.literal("custom_tool_call"),
3232
- id: import_v416.z.string(),
3233
- call_id: import_v416.z.string(),
3234
- name: import_v416.z.string(),
3235
- input: import_v416.z.string()
3420
+ import_v417.z.object({
3421
+ type: import_v417.z.literal("custom_tool_call"),
3422
+ id: import_v417.z.string(),
3423
+ call_id: import_v417.z.string(),
3424
+ name: import_v417.z.string(),
3425
+ input: import_v417.z.string()
3236
3426
  }),
3237
- import_v416.z.object({
3238
- type: import_v416.z.literal("shell_call"),
3239
- id: import_v416.z.string(),
3240
- call_id: import_v416.z.string(),
3241
- status: import_v416.z.enum(["in_progress", "completed", "incomplete"]),
3242
- action: import_v416.z.object({
3243
- commands: import_v416.z.array(import_v416.z.string())
3427
+ import_v417.z.object({
3428
+ type: import_v417.z.literal("shell_call"),
3429
+ id: import_v417.z.string(),
3430
+ call_id: import_v417.z.string(),
3431
+ status: import_v417.z.enum(["in_progress", "completed", "incomplete"]),
3432
+ action: import_v417.z.object({
3433
+ commands: import_v417.z.array(import_v417.z.string())
3244
3434
  })
3245
3435
  }),
3246
- import_v416.z.object({
3247
- type: import_v416.z.literal("shell_call_output"),
3248
- id: import_v416.z.string(),
3249
- call_id: import_v416.z.string(),
3250
- status: import_v416.z.enum(["in_progress", "completed", "incomplete"]),
3251
- output: import_v416.z.array(
3252
- import_v416.z.object({
3253
- stdout: import_v416.z.string(),
3254
- stderr: import_v416.z.string(),
3255
- outcome: import_v416.z.discriminatedUnion("type", [
3256
- import_v416.z.object({ type: import_v416.z.literal("timeout") }),
3257
- import_v416.z.object({
3258
- type: import_v416.z.literal("exit"),
3259
- exit_code: import_v416.z.number()
3436
+ import_v417.z.object({
3437
+ type: import_v417.z.literal("compaction"),
3438
+ id: import_v417.z.string(),
3439
+ encrypted_content: import_v417.z.string().nullish()
3440
+ }),
3441
+ import_v417.z.object({
3442
+ type: import_v417.z.literal("shell_call_output"),
3443
+ id: import_v417.z.string(),
3444
+ call_id: import_v417.z.string(),
3445
+ status: import_v417.z.enum(["in_progress", "completed", "incomplete"]),
3446
+ output: import_v417.z.array(
3447
+ import_v417.z.object({
3448
+ stdout: import_v417.z.string(),
3449
+ stderr: import_v417.z.string(),
3450
+ outcome: import_v417.z.discriminatedUnion("type", [
3451
+ import_v417.z.object({ type: import_v417.z.literal("timeout") }),
3452
+ import_v417.z.object({
3453
+ type: import_v417.z.literal("exit"),
3454
+ exit_code: import_v417.z.number()
3260
3455
  })
3261
3456
  ])
3262
3457
  })
3263
3458
  )
3459
+ }),
3460
+ import_v417.z.object({
3461
+ type: import_v417.z.literal("tool_search_call"),
3462
+ id: import_v417.z.string(),
3463
+ execution: import_v417.z.enum(["server", "client"]),
3464
+ call_id: import_v417.z.string().nullable(),
3465
+ status: import_v417.z.enum(["in_progress", "completed", "incomplete"]),
3466
+ arguments: import_v417.z.unknown()
3467
+ }),
3468
+ import_v417.z.object({
3469
+ type: import_v417.z.literal("tool_search_output"),
3470
+ id: import_v417.z.string(),
3471
+ execution: import_v417.z.enum(["server", "client"]),
3472
+ call_id: import_v417.z.string().nullable(),
3473
+ status: import_v417.z.enum(["in_progress", "completed", "incomplete"]),
3474
+ tools: import_v417.z.array(import_v417.z.record(import_v417.z.string(), jsonValueSchema.optional()))
3264
3475
  })
3265
3476
  ])
3266
3477
  }),
3267
- import_v416.z.object({
3268
- type: import_v416.z.literal("response.output_item.done"),
3269
- output_index: import_v416.z.number(),
3270
- item: import_v416.z.discriminatedUnion("type", [
3271
- import_v416.z.object({
3272
- type: import_v416.z.literal("message"),
3273
- id: import_v416.z.string(),
3274
- phase: import_v416.z.enum(["commentary", "final_answer"]).nullish()
3478
+ import_v417.z.object({
3479
+ type: import_v417.z.literal("response.output_item.done"),
3480
+ output_index: import_v417.z.number(),
3481
+ item: import_v417.z.discriminatedUnion("type", [
3482
+ import_v417.z.object({
3483
+ type: import_v417.z.literal("message"),
3484
+ id: import_v417.z.string(),
3485
+ phase: import_v417.z.enum(["commentary", "final_answer"]).nullish()
3275
3486
  }),
3276
- import_v416.z.object({
3277
- type: import_v416.z.literal("reasoning"),
3278
- id: import_v416.z.string(),
3279
- encrypted_content: import_v416.z.string().nullish()
3487
+ import_v417.z.object({
3488
+ type: import_v417.z.literal("reasoning"),
3489
+ id: import_v417.z.string(),
3490
+ encrypted_content: import_v417.z.string().nullish()
3280
3491
  }),
3281
- import_v416.z.object({
3282
- type: import_v416.z.literal("function_call"),
3283
- id: import_v416.z.string(),
3284
- call_id: import_v416.z.string(),
3285
- name: import_v416.z.string(),
3286
- arguments: import_v416.z.string(),
3287
- status: import_v416.z.literal("completed")
3492
+ import_v417.z.object({
3493
+ type: import_v417.z.literal("function_call"),
3494
+ id: import_v417.z.string(),
3495
+ call_id: import_v417.z.string(),
3496
+ name: import_v417.z.string(),
3497
+ arguments: import_v417.z.string(),
3498
+ status: import_v417.z.literal("completed")
3288
3499
  }),
3289
- import_v416.z.object({
3290
- type: import_v416.z.literal("custom_tool_call"),
3291
- id: import_v416.z.string(),
3292
- call_id: import_v416.z.string(),
3293
- name: import_v416.z.string(),
3294
- input: import_v416.z.string(),
3295
- status: import_v416.z.literal("completed")
3500
+ import_v417.z.object({
3501
+ type: import_v417.z.literal("custom_tool_call"),
3502
+ id: import_v417.z.string(),
3503
+ call_id: import_v417.z.string(),
3504
+ name: import_v417.z.string(),
3505
+ input: import_v417.z.string(),
3506
+ status: import_v417.z.literal("completed")
3296
3507
  }),
3297
- import_v416.z.object({
3298
- type: import_v416.z.literal("code_interpreter_call"),
3299
- id: import_v416.z.string(),
3300
- code: import_v416.z.string().nullable(),
3301
- container_id: import_v416.z.string(),
3302
- outputs: import_v416.z.array(
3303
- import_v416.z.discriminatedUnion("type", [
3304
- import_v416.z.object({ type: import_v416.z.literal("logs"), logs: import_v416.z.string() }),
3305
- import_v416.z.object({ type: import_v416.z.literal("image"), url: import_v416.z.string() })
3508
+ import_v417.z.object({
3509
+ type: import_v417.z.literal("code_interpreter_call"),
3510
+ id: import_v417.z.string(),
3511
+ code: import_v417.z.string().nullable(),
3512
+ container_id: import_v417.z.string(),
3513
+ outputs: import_v417.z.array(
3514
+ import_v417.z.discriminatedUnion("type", [
3515
+ import_v417.z.object({ type: import_v417.z.literal("logs"), logs: import_v417.z.string() }),
3516
+ import_v417.z.object({ type: import_v417.z.literal("image"), url: import_v417.z.string() })
3306
3517
  ])
3307
3518
  ).nullable()
3308
3519
  }),
3309
- import_v416.z.object({
3310
- type: import_v416.z.literal("image_generation_call"),
3311
- id: import_v416.z.string(),
3312
- result: import_v416.z.string()
3520
+ import_v417.z.object({
3521
+ type: import_v417.z.literal("image_generation_call"),
3522
+ id: import_v417.z.string(),
3523
+ result: import_v417.z.string()
3313
3524
  }),
3314
- import_v416.z.object({
3315
- type: import_v416.z.literal("web_search_call"),
3316
- id: import_v416.z.string(),
3317
- status: import_v416.z.string(),
3318
- action: import_v416.z.discriminatedUnion("type", [
3319
- import_v416.z.object({
3320
- type: import_v416.z.literal("search"),
3321
- query: import_v416.z.string().nullish(),
3322
- sources: import_v416.z.array(
3323
- import_v416.z.discriminatedUnion("type", [
3324
- import_v416.z.object({ type: import_v416.z.literal("url"), url: import_v416.z.string() }),
3325
- import_v416.z.object({ type: import_v416.z.literal("api"), name: import_v416.z.string() })
3525
+ import_v417.z.object({
3526
+ type: import_v417.z.literal("web_search_call"),
3527
+ id: import_v417.z.string(),
3528
+ status: import_v417.z.string(),
3529
+ action: import_v417.z.discriminatedUnion("type", [
3530
+ import_v417.z.object({
3531
+ type: import_v417.z.literal("search"),
3532
+ query: import_v417.z.string().nullish(),
3533
+ sources: import_v417.z.array(
3534
+ import_v417.z.discriminatedUnion("type", [
3535
+ import_v417.z.object({ type: import_v417.z.literal("url"), url: import_v417.z.string() }),
3536
+ import_v417.z.object({ type: import_v417.z.literal("api"), name: import_v417.z.string() })
3326
3537
  ])
3327
3538
  ).nullish()
3328
3539
  }),
3329
- import_v416.z.object({
3330
- type: import_v416.z.literal("open_page"),
3331
- url: import_v416.z.string().nullish()
3540
+ import_v417.z.object({
3541
+ type: import_v417.z.literal("open_page"),
3542
+ url: import_v417.z.string().nullish()
3332
3543
  }),
3333
- import_v416.z.object({
3334
- type: import_v416.z.literal("find_in_page"),
3335
- url: import_v416.z.string().nullish(),
3336
- pattern: import_v416.z.string().nullish()
3544
+ import_v417.z.object({
3545
+ type: import_v417.z.literal("find_in_page"),
3546
+ url: import_v417.z.string().nullish(),
3547
+ pattern: import_v417.z.string().nullish()
3337
3548
  })
3338
3549
  ]).nullish()
3339
3550
  }),
3340
- import_v416.z.object({
3341
- type: import_v416.z.literal("file_search_call"),
3342
- id: import_v416.z.string(),
3343
- queries: import_v416.z.array(import_v416.z.string()),
3344
- results: import_v416.z.array(
3345
- import_v416.z.object({
3346
- attributes: import_v416.z.record(
3347
- import_v416.z.string(),
3348
- import_v416.z.union([import_v416.z.string(), import_v416.z.number(), import_v416.z.boolean()])
3551
+ import_v417.z.object({
3552
+ type: import_v417.z.literal("file_search_call"),
3553
+ id: import_v417.z.string(),
3554
+ queries: import_v417.z.array(import_v417.z.string()),
3555
+ results: import_v417.z.array(
3556
+ import_v417.z.object({
3557
+ attributes: import_v417.z.record(
3558
+ import_v417.z.string(),
3559
+ import_v417.z.union([import_v417.z.string(), import_v417.z.number(), import_v417.z.boolean()])
3349
3560
  ),
3350
- file_id: import_v416.z.string(),
3351
- filename: import_v416.z.string(),
3352
- score: import_v416.z.number(),
3353
- text: import_v416.z.string()
3561
+ file_id: import_v417.z.string(),
3562
+ filename: import_v417.z.string(),
3563
+ score: import_v417.z.number(),
3564
+ text: import_v417.z.string()
3354
3565
  })
3355
3566
  ).nullish()
3356
3567
  }),
3357
- import_v416.z.object({
3358
- type: import_v416.z.literal("local_shell_call"),
3359
- id: import_v416.z.string(),
3360
- call_id: import_v416.z.string(),
3361
- action: import_v416.z.object({
3362
- type: import_v416.z.literal("exec"),
3363
- command: import_v416.z.array(import_v416.z.string()),
3364
- timeout_ms: import_v416.z.number().optional(),
3365
- user: import_v416.z.string().optional(),
3366
- working_directory: import_v416.z.string().optional(),
3367
- env: import_v416.z.record(import_v416.z.string(), import_v416.z.string()).optional()
3568
+ import_v417.z.object({
3569
+ type: import_v417.z.literal("local_shell_call"),
3570
+ id: import_v417.z.string(),
3571
+ call_id: import_v417.z.string(),
3572
+ action: import_v417.z.object({
3573
+ type: import_v417.z.literal("exec"),
3574
+ command: import_v417.z.array(import_v417.z.string()),
3575
+ timeout_ms: import_v417.z.number().optional(),
3576
+ user: import_v417.z.string().optional(),
3577
+ working_directory: import_v417.z.string().optional(),
3578
+ env: import_v417.z.record(import_v417.z.string(), import_v417.z.string()).optional()
3368
3579
  })
3369
3580
  }),
3370
- import_v416.z.object({
3371
- type: import_v416.z.literal("computer_call"),
3372
- id: import_v416.z.string(),
3373
- status: import_v416.z.literal("completed")
3581
+ import_v417.z.object({
3582
+ type: import_v417.z.literal("computer_call"),
3583
+ id: import_v417.z.string(),
3584
+ status: import_v417.z.literal("completed")
3374
3585
  }),
3375
- import_v416.z.object({
3376
- type: import_v416.z.literal("mcp_call"),
3377
- id: import_v416.z.string(),
3378
- status: import_v416.z.string(),
3379
- arguments: import_v416.z.string(),
3380
- name: import_v416.z.string(),
3381
- server_label: import_v416.z.string(),
3382
- output: import_v416.z.string().nullish(),
3383
- error: import_v416.z.union([
3384
- import_v416.z.string(),
3385
- import_v416.z.object({
3386
- type: import_v416.z.string().optional(),
3387
- code: import_v416.z.union([import_v416.z.number(), import_v416.z.string()]).optional(),
3388
- message: import_v416.z.string().optional()
3586
+ import_v417.z.object({
3587
+ type: import_v417.z.literal("mcp_call"),
3588
+ id: import_v417.z.string(),
3589
+ status: import_v417.z.string(),
3590
+ arguments: import_v417.z.string(),
3591
+ name: import_v417.z.string(),
3592
+ server_label: import_v417.z.string(),
3593
+ output: import_v417.z.string().nullish(),
3594
+ error: import_v417.z.union([
3595
+ import_v417.z.string(),
3596
+ import_v417.z.object({
3597
+ type: import_v417.z.string().optional(),
3598
+ code: import_v417.z.union([import_v417.z.number(), import_v417.z.string()]).optional(),
3599
+ message: import_v417.z.string().optional()
3389
3600
  }).loose()
3390
3601
  ]).nullish(),
3391
- approval_request_id: import_v416.z.string().nullish()
3602
+ approval_request_id: import_v417.z.string().nullish()
3392
3603
  }),
3393
- import_v416.z.object({
3394
- type: import_v416.z.literal("mcp_list_tools"),
3395
- id: import_v416.z.string(),
3396
- server_label: import_v416.z.string(),
3397
- tools: import_v416.z.array(
3398
- import_v416.z.object({
3399
- name: import_v416.z.string(),
3400
- description: import_v416.z.string().optional(),
3401
- input_schema: import_v416.z.any(),
3402
- annotations: import_v416.z.record(import_v416.z.string(), import_v416.z.unknown()).optional()
3604
+ import_v417.z.object({
3605
+ type: import_v417.z.literal("mcp_list_tools"),
3606
+ id: import_v417.z.string(),
3607
+ server_label: import_v417.z.string(),
3608
+ tools: import_v417.z.array(
3609
+ import_v417.z.object({
3610
+ name: import_v417.z.string(),
3611
+ description: import_v417.z.string().optional(),
3612
+ input_schema: import_v417.z.any(),
3613
+ annotations: import_v417.z.record(import_v417.z.string(), import_v417.z.unknown()).optional()
3403
3614
  })
3404
3615
  ),
3405
- error: import_v416.z.union([
3406
- import_v416.z.string(),
3407
- import_v416.z.object({
3408
- type: import_v416.z.string().optional(),
3409
- code: import_v416.z.union([import_v416.z.number(), import_v416.z.string()]).optional(),
3410
- message: import_v416.z.string().optional()
3616
+ error: import_v417.z.union([
3617
+ import_v417.z.string(),
3618
+ import_v417.z.object({
3619
+ type: import_v417.z.string().optional(),
3620
+ code: import_v417.z.union([import_v417.z.number(), import_v417.z.string()]).optional(),
3621
+ message: import_v417.z.string().optional()
3411
3622
  }).loose()
3412
3623
  ]).optional()
3413
3624
  }),
3414
- import_v416.z.object({
3415
- type: import_v416.z.literal("mcp_approval_request"),
3416
- id: import_v416.z.string(),
3417
- server_label: import_v416.z.string(),
3418
- name: import_v416.z.string(),
3419
- arguments: import_v416.z.string(),
3420
- approval_request_id: import_v416.z.string().optional()
3625
+ import_v417.z.object({
3626
+ type: import_v417.z.literal("mcp_approval_request"),
3627
+ id: import_v417.z.string(),
3628
+ server_label: import_v417.z.string(),
3629
+ name: import_v417.z.string(),
3630
+ arguments: import_v417.z.string(),
3631
+ approval_request_id: import_v417.z.string().optional()
3421
3632
  }),
3422
- import_v416.z.object({
3423
- type: import_v416.z.literal("apply_patch_call"),
3424
- id: import_v416.z.string(),
3425
- call_id: import_v416.z.string(),
3426
- status: import_v416.z.enum(["in_progress", "completed"]),
3427
- operation: import_v416.z.discriminatedUnion("type", [
3428
- import_v416.z.object({
3429
- type: import_v416.z.literal("create_file"),
3430
- path: import_v416.z.string(),
3431
- diff: import_v416.z.string()
3633
+ import_v417.z.object({
3634
+ type: import_v417.z.literal("apply_patch_call"),
3635
+ id: import_v417.z.string(),
3636
+ call_id: import_v417.z.string(),
3637
+ status: import_v417.z.enum(["in_progress", "completed"]),
3638
+ operation: import_v417.z.discriminatedUnion("type", [
3639
+ import_v417.z.object({
3640
+ type: import_v417.z.literal("create_file"),
3641
+ path: import_v417.z.string(),
3642
+ diff: import_v417.z.string()
3432
3643
  }),
3433
- import_v416.z.object({
3434
- type: import_v416.z.literal("delete_file"),
3435
- path: import_v416.z.string()
3644
+ import_v417.z.object({
3645
+ type: import_v417.z.literal("delete_file"),
3646
+ path: import_v417.z.string()
3436
3647
  }),
3437
- import_v416.z.object({
3438
- type: import_v416.z.literal("update_file"),
3439
- path: import_v416.z.string(),
3440
- diff: import_v416.z.string()
3648
+ import_v417.z.object({
3649
+ type: import_v417.z.literal("update_file"),
3650
+ path: import_v417.z.string(),
3651
+ diff: import_v417.z.string()
3441
3652
  })
3442
3653
  ])
3443
3654
  }),
3444
- import_v416.z.object({
3445
- type: import_v416.z.literal("shell_call"),
3446
- id: import_v416.z.string(),
3447
- call_id: import_v416.z.string(),
3448
- status: import_v416.z.enum(["in_progress", "completed", "incomplete"]),
3449
- action: import_v416.z.object({
3450
- commands: import_v416.z.array(import_v416.z.string())
3655
+ import_v417.z.object({
3656
+ type: import_v417.z.literal("shell_call"),
3657
+ id: import_v417.z.string(),
3658
+ call_id: import_v417.z.string(),
3659
+ status: import_v417.z.enum(["in_progress", "completed", "incomplete"]),
3660
+ action: import_v417.z.object({
3661
+ commands: import_v417.z.array(import_v417.z.string())
3451
3662
  })
3452
3663
  }),
3453
- import_v416.z.object({
3454
- type: import_v416.z.literal("shell_call_output"),
3455
- id: import_v416.z.string(),
3456
- call_id: import_v416.z.string(),
3457
- status: import_v416.z.enum(["in_progress", "completed", "incomplete"]),
3458
- output: import_v416.z.array(
3459
- import_v416.z.object({
3460
- stdout: import_v416.z.string(),
3461
- stderr: import_v416.z.string(),
3462
- outcome: import_v416.z.discriminatedUnion("type", [
3463
- import_v416.z.object({ type: import_v416.z.literal("timeout") }),
3464
- import_v416.z.object({
3465
- type: import_v416.z.literal("exit"),
3466
- exit_code: import_v416.z.number()
3664
+ import_v417.z.object({
3665
+ type: import_v417.z.literal("compaction"),
3666
+ id: import_v417.z.string(),
3667
+ encrypted_content: import_v417.z.string()
3668
+ }),
3669
+ import_v417.z.object({
3670
+ type: import_v417.z.literal("shell_call_output"),
3671
+ id: import_v417.z.string(),
3672
+ call_id: import_v417.z.string(),
3673
+ status: import_v417.z.enum(["in_progress", "completed", "incomplete"]),
3674
+ output: import_v417.z.array(
3675
+ import_v417.z.object({
3676
+ stdout: import_v417.z.string(),
3677
+ stderr: import_v417.z.string(),
3678
+ outcome: import_v417.z.discriminatedUnion("type", [
3679
+ import_v417.z.object({ type: import_v417.z.literal("timeout") }),
3680
+ import_v417.z.object({
3681
+ type: import_v417.z.literal("exit"),
3682
+ exit_code: import_v417.z.number()
3467
3683
  })
3468
3684
  ])
3469
3685
  })
3470
3686
  )
3687
+ }),
3688
+ import_v417.z.object({
3689
+ type: import_v417.z.literal("tool_search_call"),
3690
+ id: import_v417.z.string(),
3691
+ execution: import_v417.z.enum(["server", "client"]),
3692
+ call_id: import_v417.z.string().nullable(),
3693
+ status: import_v417.z.enum(["in_progress", "completed", "incomplete"]),
3694
+ arguments: import_v417.z.unknown()
3695
+ }),
3696
+ import_v417.z.object({
3697
+ type: import_v417.z.literal("tool_search_output"),
3698
+ id: import_v417.z.string(),
3699
+ execution: import_v417.z.enum(["server", "client"]),
3700
+ call_id: import_v417.z.string().nullable(),
3701
+ status: import_v417.z.enum(["in_progress", "completed", "incomplete"]),
3702
+ tools: import_v417.z.array(import_v417.z.record(import_v417.z.string(), jsonValueSchema.optional()))
3471
3703
  })
3472
3704
  ])
3473
3705
  }),
3474
- import_v416.z.object({
3475
- type: import_v416.z.literal("response.function_call_arguments.delta"),
3476
- item_id: import_v416.z.string(),
3477
- output_index: import_v416.z.number(),
3478
- delta: import_v416.z.string()
3706
+ import_v417.z.object({
3707
+ type: import_v417.z.literal("response.function_call_arguments.delta"),
3708
+ item_id: import_v417.z.string(),
3709
+ output_index: import_v417.z.number(),
3710
+ delta: import_v417.z.string()
3479
3711
  }),
3480
- import_v416.z.object({
3481
- type: import_v416.z.literal("response.custom_tool_call_input.delta"),
3482
- item_id: import_v416.z.string(),
3483
- output_index: import_v416.z.number(),
3484
- delta: import_v416.z.string()
3712
+ import_v417.z.object({
3713
+ type: import_v417.z.literal("response.custom_tool_call_input.delta"),
3714
+ item_id: import_v417.z.string(),
3715
+ output_index: import_v417.z.number(),
3716
+ delta: import_v417.z.string()
3485
3717
  }),
3486
- import_v416.z.object({
3487
- type: import_v416.z.literal("response.image_generation_call.partial_image"),
3488
- item_id: import_v416.z.string(),
3489
- output_index: import_v416.z.number(),
3490
- partial_image_b64: import_v416.z.string()
3718
+ import_v417.z.object({
3719
+ type: import_v417.z.literal("response.image_generation_call.partial_image"),
3720
+ item_id: import_v417.z.string(),
3721
+ output_index: import_v417.z.number(),
3722
+ partial_image_b64: import_v417.z.string()
3491
3723
  }),
3492
- import_v416.z.object({
3493
- type: import_v416.z.literal("response.code_interpreter_call_code.delta"),
3494
- item_id: import_v416.z.string(),
3495
- output_index: import_v416.z.number(),
3496
- delta: import_v416.z.string()
3724
+ import_v417.z.object({
3725
+ type: import_v417.z.literal("response.code_interpreter_call_code.delta"),
3726
+ item_id: import_v417.z.string(),
3727
+ output_index: import_v417.z.number(),
3728
+ delta: import_v417.z.string()
3497
3729
  }),
3498
- import_v416.z.object({
3499
- type: import_v416.z.literal("response.code_interpreter_call_code.done"),
3500
- item_id: import_v416.z.string(),
3501
- output_index: import_v416.z.number(),
3502
- code: import_v416.z.string()
3730
+ import_v417.z.object({
3731
+ type: import_v417.z.literal("response.code_interpreter_call_code.done"),
3732
+ item_id: import_v417.z.string(),
3733
+ output_index: import_v417.z.number(),
3734
+ code: import_v417.z.string()
3503
3735
  }),
3504
- import_v416.z.object({
3505
- type: import_v416.z.literal("response.output_text.annotation.added"),
3506
- annotation: import_v416.z.discriminatedUnion("type", [
3507
- import_v416.z.object({
3508
- type: import_v416.z.literal("url_citation"),
3509
- start_index: import_v416.z.number(),
3510
- end_index: import_v416.z.number(),
3511
- url: import_v416.z.string(),
3512
- title: import_v416.z.string()
3736
+ import_v417.z.object({
3737
+ type: import_v417.z.literal("response.output_text.annotation.added"),
3738
+ annotation: import_v417.z.discriminatedUnion("type", [
3739
+ import_v417.z.object({
3740
+ type: import_v417.z.literal("url_citation"),
3741
+ start_index: import_v417.z.number(),
3742
+ end_index: import_v417.z.number(),
3743
+ url: import_v417.z.string(),
3744
+ title: import_v417.z.string()
3513
3745
  }),
3514
- import_v416.z.object({
3515
- type: import_v416.z.literal("file_citation"),
3516
- file_id: import_v416.z.string(),
3517
- filename: import_v416.z.string(),
3518
- index: import_v416.z.number()
3746
+ import_v417.z.object({
3747
+ type: import_v417.z.literal("file_citation"),
3748
+ file_id: import_v417.z.string(),
3749
+ filename: import_v417.z.string(),
3750
+ index: import_v417.z.number()
3519
3751
  }),
3520
- import_v416.z.object({
3521
- type: import_v416.z.literal("container_file_citation"),
3522
- container_id: import_v416.z.string(),
3523
- file_id: import_v416.z.string(),
3524
- filename: import_v416.z.string(),
3525
- start_index: import_v416.z.number(),
3526
- end_index: import_v416.z.number()
3752
+ import_v417.z.object({
3753
+ type: import_v417.z.literal("container_file_citation"),
3754
+ container_id: import_v417.z.string(),
3755
+ file_id: import_v417.z.string(),
3756
+ filename: import_v417.z.string(),
3757
+ start_index: import_v417.z.number(),
3758
+ end_index: import_v417.z.number()
3527
3759
  }),
3528
- import_v416.z.object({
3529
- type: import_v416.z.literal("file_path"),
3530
- file_id: import_v416.z.string(),
3531
- index: import_v416.z.number()
3760
+ import_v417.z.object({
3761
+ type: import_v417.z.literal("file_path"),
3762
+ file_id: import_v417.z.string(),
3763
+ index: import_v417.z.number()
3532
3764
  })
3533
3765
  ])
3534
3766
  }),
3535
- import_v416.z.object({
3536
- type: import_v416.z.literal("response.reasoning_summary_part.added"),
3537
- item_id: import_v416.z.string(),
3538
- summary_index: import_v416.z.number()
3767
+ import_v417.z.object({
3768
+ type: import_v417.z.literal("response.reasoning_summary_part.added"),
3769
+ item_id: import_v417.z.string(),
3770
+ summary_index: import_v417.z.number()
3539
3771
  }),
3540
- import_v416.z.object({
3541
- type: import_v416.z.literal("response.reasoning_summary_text.delta"),
3542
- item_id: import_v416.z.string(),
3543
- summary_index: import_v416.z.number(),
3544
- delta: import_v416.z.string()
3772
+ import_v417.z.object({
3773
+ type: import_v417.z.literal("response.reasoning_summary_text.delta"),
3774
+ item_id: import_v417.z.string(),
3775
+ summary_index: import_v417.z.number(),
3776
+ delta: import_v417.z.string()
3545
3777
  }),
3546
- import_v416.z.object({
3547
- type: import_v416.z.literal("response.reasoning_summary_part.done"),
3548
- item_id: import_v416.z.string(),
3549
- summary_index: import_v416.z.number()
3778
+ import_v417.z.object({
3779
+ type: import_v417.z.literal("response.reasoning_summary_part.done"),
3780
+ item_id: import_v417.z.string(),
3781
+ summary_index: import_v417.z.number()
3550
3782
  }),
3551
- import_v416.z.object({
3552
- type: import_v416.z.literal("response.apply_patch_call_operation_diff.delta"),
3553
- item_id: import_v416.z.string(),
3554
- output_index: import_v416.z.number(),
3555
- delta: import_v416.z.string(),
3556
- obfuscation: import_v416.z.string().nullish()
3783
+ import_v417.z.object({
3784
+ type: import_v417.z.literal("response.apply_patch_call_operation_diff.delta"),
3785
+ item_id: import_v417.z.string(),
3786
+ output_index: import_v417.z.number(),
3787
+ delta: import_v417.z.string(),
3788
+ obfuscation: import_v417.z.string().nullish()
3557
3789
  }),
3558
- import_v416.z.object({
3559
- type: import_v416.z.literal("response.apply_patch_call_operation_diff.done"),
3560
- item_id: import_v416.z.string(),
3561
- output_index: import_v416.z.number(),
3562
- diff: import_v416.z.string()
3790
+ import_v417.z.object({
3791
+ type: import_v417.z.literal("response.apply_patch_call_operation_diff.done"),
3792
+ item_id: import_v417.z.string(),
3793
+ output_index: import_v417.z.number(),
3794
+ diff: import_v417.z.string()
3563
3795
  }),
3564
- import_v416.z.object({
3565
- type: import_v416.z.literal("error"),
3566
- sequence_number: import_v416.z.number(),
3567
- error: import_v416.z.object({
3568
- type: import_v416.z.string(),
3569
- code: import_v416.z.string(),
3570
- message: import_v416.z.string(),
3571
- param: import_v416.z.string().nullish()
3796
+ import_v417.z.object({
3797
+ type: import_v417.z.literal("error"),
3798
+ sequence_number: import_v417.z.number(),
3799
+ error: import_v417.z.object({
3800
+ type: import_v417.z.string(),
3801
+ code: import_v417.z.string(),
3802
+ message: import_v417.z.string(),
3803
+ param: import_v417.z.string().nullish()
3572
3804
  })
3573
3805
  }),
3574
- import_v416.z.object({ type: import_v416.z.string() }).loose().transform((value) => ({
3806
+ import_v417.z.object({ type: import_v417.z.string() }).loose().transform((value) => ({
3575
3807
  type: "unknown_chunk",
3576
3808
  message: value.type
3577
3809
  }))
@@ -3579,294 +3811,315 @@ var openaiResponsesChunkSchema = (0, import_provider_utils23.lazySchema)(
3579
3811
  ])
3580
3812
  )
3581
3813
  );
3582
- var openaiResponsesResponseSchema = (0, import_provider_utils23.lazySchema)(
3583
- () => (0, import_provider_utils23.zodSchema)(
3584
- import_v416.z.object({
3585
- id: import_v416.z.string().optional(),
3586
- created_at: import_v416.z.number().optional(),
3587
- error: import_v416.z.object({
3588
- message: import_v416.z.string(),
3589
- type: import_v416.z.string(),
3590
- param: import_v416.z.string().nullish(),
3591
- code: import_v416.z.string()
3814
+ var openaiResponsesResponseSchema = (0, import_provider_utils24.lazySchema)(
3815
+ () => (0, import_provider_utils24.zodSchema)(
3816
+ import_v417.z.object({
3817
+ id: import_v417.z.string().optional(),
3818
+ created_at: import_v417.z.number().optional(),
3819
+ error: import_v417.z.object({
3820
+ message: import_v417.z.string(),
3821
+ type: import_v417.z.string(),
3822
+ param: import_v417.z.string().nullish(),
3823
+ code: import_v417.z.string()
3592
3824
  }).nullish(),
3593
- model: import_v416.z.string().optional(),
3594
- output: import_v416.z.array(
3595
- import_v416.z.discriminatedUnion("type", [
3596
- import_v416.z.object({
3597
- type: import_v416.z.literal("message"),
3598
- role: import_v416.z.literal("assistant"),
3599
- id: import_v416.z.string(),
3600
- phase: import_v416.z.enum(["commentary", "final_answer"]).nullish(),
3601
- content: import_v416.z.array(
3602
- import_v416.z.object({
3603
- type: import_v416.z.literal("output_text"),
3604
- text: import_v416.z.string(),
3605
- logprobs: import_v416.z.array(
3606
- import_v416.z.object({
3607
- token: import_v416.z.string(),
3608
- logprob: import_v416.z.number(),
3609
- top_logprobs: import_v416.z.array(
3610
- import_v416.z.object({
3611
- token: import_v416.z.string(),
3612
- logprob: import_v416.z.number()
3825
+ model: import_v417.z.string().optional(),
3826
+ output: import_v417.z.array(
3827
+ import_v417.z.discriminatedUnion("type", [
3828
+ import_v417.z.object({
3829
+ type: import_v417.z.literal("message"),
3830
+ role: import_v417.z.literal("assistant"),
3831
+ id: import_v417.z.string(),
3832
+ phase: import_v417.z.enum(["commentary", "final_answer"]).nullish(),
3833
+ content: import_v417.z.array(
3834
+ import_v417.z.object({
3835
+ type: import_v417.z.literal("output_text"),
3836
+ text: import_v417.z.string(),
3837
+ logprobs: import_v417.z.array(
3838
+ import_v417.z.object({
3839
+ token: import_v417.z.string(),
3840
+ logprob: import_v417.z.number(),
3841
+ top_logprobs: import_v417.z.array(
3842
+ import_v417.z.object({
3843
+ token: import_v417.z.string(),
3844
+ logprob: import_v417.z.number()
3613
3845
  })
3614
3846
  )
3615
3847
  })
3616
3848
  ).nullish(),
3617
- annotations: import_v416.z.array(
3618
- import_v416.z.discriminatedUnion("type", [
3619
- import_v416.z.object({
3620
- type: import_v416.z.literal("url_citation"),
3621
- start_index: import_v416.z.number(),
3622
- end_index: import_v416.z.number(),
3623
- url: import_v416.z.string(),
3624
- title: import_v416.z.string()
3849
+ annotations: import_v417.z.array(
3850
+ import_v417.z.discriminatedUnion("type", [
3851
+ import_v417.z.object({
3852
+ type: import_v417.z.literal("url_citation"),
3853
+ start_index: import_v417.z.number(),
3854
+ end_index: import_v417.z.number(),
3855
+ url: import_v417.z.string(),
3856
+ title: import_v417.z.string()
3625
3857
  }),
3626
- import_v416.z.object({
3627
- type: import_v416.z.literal("file_citation"),
3628
- file_id: import_v416.z.string(),
3629
- filename: import_v416.z.string(),
3630
- index: import_v416.z.number()
3858
+ import_v417.z.object({
3859
+ type: import_v417.z.literal("file_citation"),
3860
+ file_id: import_v417.z.string(),
3861
+ filename: import_v417.z.string(),
3862
+ index: import_v417.z.number()
3631
3863
  }),
3632
- import_v416.z.object({
3633
- type: import_v416.z.literal("container_file_citation"),
3634
- container_id: import_v416.z.string(),
3635
- file_id: import_v416.z.string(),
3636
- filename: import_v416.z.string(),
3637
- start_index: import_v416.z.number(),
3638
- end_index: import_v416.z.number()
3864
+ import_v417.z.object({
3865
+ type: import_v417.z.literal("container_file_citation"),
3866
+ container_id: import_v417.z.string(),
3867
+ file_id: import_v417.z.string(),
3868
+ filename: import_v417.z.string(),
3869
+ start_index: import_v417.z.number(),
3870
+ end_index: import_v417.z.number()
3639
3871
  }),
3640
- import_v416.z.object({
3641
- type: import_v416.z.literal("file_path"),
3642
- file_id: import_v416.z.string(),
3643
- index: import_v416.z.number()
3872
+ import_v417.z.object({
3873
+ type: import_v417.z.literal("file_path"),
3874
+ file_id: import_v417.z.string(),
3875
+ index: import_v417.z.number()
3644
3876
  })
3645
3877
  ])
3646
3878
  )
3647
3879
  })
3648
3880
  )
3649
3881
  }),
3650
- import_v416.z.object({
3651
- type: import_v416.z.literal("web_search_call"),
3652
- id: import_v416.z.string(),
3653
- status: import_v416.z.string(),
3654
- action: import_v416.z.discriminatedUnion("type", [
3655
- import_v416.z.object({
3656
- type: import_v416.z.literal("search"),
3657
- query: import_v416.z.string().nullish(),
3658
- sources: import_v416.z.array(
3659
- import_v416.z.discriminatedUnion("type", [
3660
- import_v416.z.object({ type: import_v416.z.literal("url"), url: import_v416.z.string() }),
3661
- import_v416.z.object({
3662
- type: import_v416.z.literal("api"),
3663
- name: import_v416.z.string()
3882
+ import_v417.z.object({
3883
+ type: import_v417.z.literal("web_search_call"),
3884
+ id: import_v417.z.string(),
3885
+ status: import_v417.z.string(),
3886
+ action: import_v417.z.discriminatedUnion("type", [
3887
+ import_v417.z.object({
3888
+ type: import_v417.z.literal("search"),
3889
+ query: import_v417.z.string().nullish(),
3890
+ sources: import_v417.z.array(
3891
+ import_v417.z.discriminatedUnion("type", [
3892
+ import_v417.z.object({ type: import_v417.z.literal("url"), url: import_v417.z.string() }),
3893
+ import_v417.z.object({
3894
+ type: import_v417.z.literal("api"),
3895
+ name: import_v417.z.string()
3664
3896
  })
3665
3897
  ])
3666
3898
  ).nullish()
3667
3899
  }),
3668
- import_v416.z.object({
3669
- type: import_v416.z.literal("open_page"),
3670
- url: import_v416.z.string().nullish()
3900
+ import_v417.z.object({
3901
+ type: import_v417.z.literal("open_page"),
3902
+ url: import_v417.z.string().nullish()
3671
3903
  }),
3672
- import_v416.z.object({
3673
- type: import_v416.z.literal("find_in_page"),
3674
- url: import_v416.z.string().nullish(),
3675
- pattern: import_v416.z.string().nullish()
3904
+ import_v417.z.object({
3905
+ type: import_v417.z.literal("find_in_page"),
3906
+ url: import_v417.z.string().nullish(),
3907
+ pattern: import_v417.z.string().nullish()
3676
3908
  })
3677
3909
  ]).nullish()
3678
3910
  }),
3679
- import_v416.z.object({
3680
- type: import_v416.z.literal("file_search_call"),
3681
- id: import_v416.z.string(),
3682
- queries: import_v416.z.array(import_v416.z.string()),
3683
- results: import_v416.z.array(
3684
- import_v416.z.object({
3685
- attributes: import_v416.z.record(
3686
- import_v416.z.string(),
3687
- import_v416.z.union([import_v416.z.string(), import_v416.z.number(), import_v416.z.boolean()])
3911
+ import_v417.z.object({
3912
+ type: import_v417.z.literal("file_search_call"),
3913
+ id: import_v417.z.string(),
3914
+ queries: import_v417.z.array(import_v417.z.string()),
3915
+ results: import_v417.z.array(
3916
+ import_v417.z.object({
3917
+ attributes: import_v417.z.record(
3918
+ import_v417.z.string(),
3919
+ import_v417.z.union([import_v417.z.string(), import_v417.z.number(), import_v417.z.boolean()])
3688
3920
  ),
3689
- file_id: import_v416.z.string(),
3690
- filename: import_v416.z.string(),
3691
- score: import_v416.z.number(),
3692
- text: import_v416.z.string()
3921
+ file_id: import_v417.z.string(),
3922
+ filename: import_v417.z.string(),
3923
+ score: import_v417.z.number(),
3924
+ text: import_v417.z.string()
3693
3925
  })
3694
3926
  ).nullish()
3695
3927
  }),
3696
- import_v416.z.object({
3697
- type: import_v416.z.literal("code_interpreter_call"),
3698
- id: import_v416.z.string(),
3699
- code: import_v416.z.string().nullable(),
3700
- container_id: import_v416.z.string(),
3701
- outputs: import_v416.z.array(
3702
- import_v416.z.discriminatedUnion("type", [
3703
- import_v416.z.object({ type: import_v416.z.literal("logs"), logs: import_v416.z.string() }),
3704
- import_v416.z.object({ type: import_v416.z.literal("image"), url: import_v416.z.string() })
3928
+ import_v417.z.object({
3929
+ type: import_v417.z.literal("code_interpreter_call"),
3930
+ id: import_v417.z.string(),
3931
+ code: import_v417.z.string().nullable(),
3932
+ container_id: import_v417.z.string(),
3933
+ outputs: import_v417.z.array(
3934
+ import_v417.z.discriminatedUnion("type", [
3935
+ import_v417.z.object({ type: import_v417.z.literal("logs"), logs: import_v417.z.string() }),
3936
+ import_v417.z.object({ type: import_v417.z.literal("image"), url: import_v417.z.string() })
3705
3937
  ])
3706
3938
  ).nullable()
3707
3939
  }),
3708
- import_v416.z.object({
3709
- type: import_v416.z.literal("image_generation_call"),
3710
- id: import_v416.z.string(),
3711
- result: import_v416.z.string()
3940
+ import_v417.z.object({
3941
+ type: import_v417.z.literal("image_generation_call"),
3942
+ id: import_v417.z.string(),
3943
+ result: import_v417.z.string()
3712
3944
  }),
3713
- import_v416.z.object({
3714
- type: import_v416.z.literal("local_shell_call"),
3715
- id: import_v416.z.string(),
3716
- call_id: import_v416.z.string(),
3717
- action: import_v416.z.object({
3718
- type: import_v416.z.literal("exec"),
3719
- command: import_v416.z.array(import_v416.z.string()),
3720
- timeout_ms: import_v416.z.number().optional(),
3721
- user: import_v416.z.string().optional(),
3722
- working_directory: import_v416.z.string().optional(),
3723
- env: import_v416.z.record(import_v416.z.string(), import_v416.z.string()).optional()
3945
+ import_v417.z.object({
3946
+ type: import_v417.z.literal("local_shell_call"),
3947
+ id: import_v417.z.string(),
3948
+ call_id: import_v417.z.string(),
3949
+ action: import_v417.z.object({
3950
+ type: import_v417.z.literal("exec"),
3951
+ command: import_v417.z.array(import_v417.z.string()),
3952
+ timeout_ms: import_v417.z.number().optional(),
3953
+ user: import_v417.z.string().optional(),
3954
+ working_directory: import_v417.z.string().optional(),
3955
+ env: import_v417.z.record(import_v417.z.string(), import_v417.z.string()).optional()
3724
3956
  })
3725
3957
  }),
3726
- import_v416.z.object({
3727
- type: import_v416.z.literal("function_call"),
3728
- call_id: import_v416.z.string(),
3729
- name: import_v416.z.string(),
3730
- arguments: import_v416.z.string(),
3731
- id: import_v416.z.string()
3958
+ import_v417.z.object({
3959
+ type: import_v417.z.literal("function_call"),
3960
+ call_id: import_v417.z.string(),
3961
+ name: import_v417.z.string(),
3962
+ arguments: import_v417.z.string(),
3963
+ id: import_v417.z.string()
3732
3964
  }),
3733
- import_v416.z.object({
3734
- type: import_v416.z.literal("custom_tool_call"),
3735
- call_id: import_v416.z.string(),
3736
- name: import_v416.z.string(),
3737
- input: import_v416.z.string(),
3738
- id: import_v416.z.string()
3965
+ import_v417.z.object({
3966
+ type: import_v417.z.literal("custom_tool_call"),
3967
+ call_id: import_v417.z.string(),
3968
+ name: import_v417.z.string(),
3969
+ input: import_v417.z.string(),
3970
+ id: import_v417.z.string()
3739
3971
  }),
3740
- import_v416.z.object({
3741
- type: import_v416.z.literal("computer_call"),
3742
- id: import_v416.z.string(),
3743
- status: import_v416.z.string().optional()
3972
+ import_v417.z.object({
3973
+ type: import_v417.z.literal("computer_call"),
3974
+ id: import_v417.z.string(),
3975
+ status: import_v417.z.string().optional()
3744
3976
  }),
3745
- import_v416.z.object({
3746
- type: import_v416.z.literal("reasoning"),
3747
- id: import_v416.z.string(),
3748
- encrypted_content: import_v416.z.string().nullish(),
3749
- summary: import_v416.z.array(
3750
- import_v416.z.object({
3751
- type: import_v416.z.literal("summary_text"),
3752
- text: import_v416.z.string()
3977
+ import_v417.z.object({
3978
+ type: import_v417.z.literal("reasoning"),
3979
+ id: import_v417.z.string(),
3980
+ encrypted_content: import_v417.z.string().nullish(),
3981
+ summary: import_v417.z.array(
3982
+ import_v417.z.object({
3983
+ type: import_v417.z.literal("summary_text"),
3984
+ text: import_v417.z.string()
3753
3985
  })
3754
3986
  )
3755
3987
  }),
3756
- import_v416.z.object({
3757
- type: import_v416.z.literal("mcp_call"),
3758
- id: import_v416.z.string(),
3759
- status: import_v416.z.string(),
3760
- arguments: import_v416.z.string(),
3761
- name: import_v416.z.string(),
3762
- server_label: import_v416.z.string(),
3763
- output: import_v416.z.string().nullish(),
3764
- error: import_v416.z.union([
3765
- import_v416.z.string(),
3766
- import_v416.z.object({
3767
- type: import_v416.z.string().optional(),
3768
- code: import_v416.z.union([import_v416.z.number(), import_v416.z.string()]).optional(),
3769
- message: import_v416.z.string().optional()
3988
+ import_v417.z.object({
3989
+ type: import_v417.z.literal("mcp_call"),
3990
+ id: import_v417.z.string(),
3991
+ status: import_v417.z.string(),
3992
+ arguments: import_v417.z.string(),
3993
+ name: import_v417.z.string(),
3994
+ server_label: import_v417.z.string(),
3995
+ output: import_v417.z.string().nullish(),
3996
+ error: import_v417.z.union([
3997
+ import_v417.z.string(),
3998
+ import_v417.z.object({
3999
+ type: import_v417.z.string().optional(),
4000
+ code: import_v417.z.union([import_v417.z.number(), import_v417.z.string()]).optional(),
4001
+ message: import_v417.z.string().optional()
3770
4002
  }).loose()
3771
4003
  ]).nullish(),
3772
- approval_request_id: import_v416.z.string().nullish()
4004
+ approval_request_id: import_v417.z.string().nullish()
3773
4005
  }),
3774
- import_v416.z.object({
3775
- type: import_v416.z.literal("mcp_list_tools"),
3776
- id: import_v416.z.string(),
3777
- server_label: import_v416.z.string(),
3778
- tools: import_v416.z.array(
3779
- import_v416.z.object({
3780
- name: import_v416.z.string(),
3781
- description: import_v416.z.string().optional(),
3782
- input_schema: import_v416.z.any(),
3783
- annotations: import_v416.z.record(import_v416.z.string(), import_v416.z.unknown()).optional()
4006
+ import_v417.z.object({
4007
+ type: import_v417.z.literal("mcp_list_tools"),
4008
+ id: import_v417.z.string(),
4009
+ server_label: import_v417.z.string(),
4010
+ tools: import_v417.z.array(
4011
+ import_v417.z.object({
4012
+ name: import_v417.z.string(),
4013
+ description: import_v417.z.string().optional(),
4014
+ input_schema: import_v417.z.any(),
4015
+ annotations: import_v417.z.record(import_v417.z.string(), import_v417.z.unknown()).optional()
3784
4016
  })
3785
4017
  ),
3786
- error: import_v416.z.union([
3787
- import_v416.z.string(),
3788
- import_v416.z.object({
3789
- type: import_v416.z.string().optional(),
3790
- code: import_v416.z.union([import_v416.z.number(), import_v416.z.string()]).optional(),
3791
- message: import_v416.z.string().optional()
4018
+ error: import_v417.z.union([
4019
+ import_v417.z.string(),
4020
+ import_v417.z.object({
4021
+ type: import_v417.z.string().optional(),
4022
+ code: import_v417.z.union([import_v417.z.number(), import_v417.z.string()]).optional(),
4023
+ message: import_v417.z.string().optional()
3792
4024
  }).loose()
3793
4025
  ]).optional()
3794
4026
  }),
3795
- import_v416.z.object({
3796
- type: import_v416.z.literal("mcp_approval_request"),
3797
- id: import_v416.z.string(),
3798
- server_label: import_v416.z.string(),
3799
- name: import_v416.z.string(),
3800
- arguments: import_v416.z.string(),
3801
- approval_request_id: import_v416.z.string().optional()
4027
+ import_v417.z.object({
4028
+ type: import_v417.z.literal("mcp_approval_request"),
4029
+ id: import_v417.z.string(),
4030
+ server_label: import_v417.z.string(),
4031
+ name: import_v417.z.string(),
4032
+ arguments: import_v417.z.string(),
4033
+ approval_request_id: import_v417.z.string().optional()
3802
4034
  }),
3803
- import_v416.z.object({
3804
- type: import_v416.z.literal("apply_patch_call"),
3805
- id: import_v416.z.string(),
3806
- call_id: import_v416.z.string(),
3807
- status: import_v416.z.enum(["in_progress", "completed"]),
3808
- operation: import_v416.z.discriminatedUnion("type", [
3809
- import_v416.z.object({
3810
- type: import_v416.z.literal("create_file"),
3811
- path: import_v416.z.string(),
3812
- diff: import_v416.z.string()
4035
+ import_v417.z.object({
4036
+ type: import_v417.z.literal("apply_patch_call"),
4037
+ id: import_v417.z.string(),
4038
+ call_id: import_v417.z.string(),
4039
+ status: import_v417.z.enum(["in_progress", "completed"]),
4040
+ operation: import_v417.z.discriminatedUnion("type", [
4041
+ import_v417.z.object({
4042
+ type: import_v417.z.literal("create_file"),
4043
+ path: import_v417.z.string(),
4044
+ diff: import_v417.z.string()
3813
4045
  }),
3814
- import_v416.z.object({
3815
- type: import_v416.z.literal("delete_file"),
3816
- path: import_v416.z.string()
4046
+ import_v417.z.object({
4047
+ type: import_v417.z.literal("delete_file"),
4048
+ path: import_v417.z.string()
3817
4049
  }),
3818
- import_v416.z.object({
3819
- type: import_v416.z.literal("update_file"),
3820
- path: import_v416.z.string(),
3821
- diff: import_v416.z.string()
4050
+ import_v417.z.object({
4051
+ type: import_v417.z.literal("update_file"),
4052
+ path: import_v417.z.string(),
4053
+ diff: import_v417.z.string()
3822
4054
  })
3823
4055
  ])
3824
4056
  }),
3825
- import_v416.z.object({
3826
- type: import_v416.z.literal("shell_call"),
3827
- id: import_v416.z.string(),
3828
- call_id: import_v416.z.string(),
3829
- status: import_v416.z.enum(["in_progress", "completed", "incomplete"]),
3830
- action: import_v416.z.object({
3831
- commands: import_v416.z.array(import_v416.z.string())
4057
+ import_v417.z.object({
4058
+ type: import_v417.z.literal("shell_call"),
4059
+ id: import_v417.z.string(),
4060
+ call_id: import_v417.z.string(),
4061
+ status: import_v417.z.enum(["in_progress", "completed", "incomplete"]),
4062
+ action: import_v417.z.object({
4063
+ commands: import_v417.z.array(import_v417.z.string())
3832
4064
  })
3833
4065
  }),
3834
- import_v416.z.object({
3835
- type: import_v416.z.literal("shell_call_output"),
3836
- id: import_v416.z.string(),
3837
- call_id: import_v416.z.string(),
3838
- status: import_v416.z.enum(["in_progress", "completed", "incomplete"]),
3839
- output: import_v416.z.array(
3840
- import_v416.z.object({
3841
- stdout: import_v416.z.string(),
3842
- stderr: import_v416.z.string(),
3843
- outcome: import_v416.z.discriminatedUnion("type", [
3844
- import_v416.z.object({ type: import_v416.z.literal("timeout") }),
3845
- import_v416.z.object({
3846
- type: import_v416.z.literal("exit"),
3847
- exit_code: import_v416.z.number()
4066
+ import_v417.z.object({
4067
+ type: import_v417.z.literal("compaction"),
4068
+ id: import_v417.z.string(),
4069
+ encrypted_content: import_v417.z.string()
4070
+ }),
4071
+ import_v417.z.object({
4072
+ type: import_v417.z.literal("shell_call_output"),
4073
+ id: import_v417.z.string(),
4074
+ call_id: import_v417.z.string(),
4075
+ status: import_v417.z.enum(["in_progress", "completed", "incomplete"]),
4076
+ output: import_v417.z.array(
4077
+ import_v417.z.object({
4078
+ stdout: import_v417.z.string(),
4079
+ stderr: import_v417.z.string(),
4080
+ outcome: import_v417.z.discriminatedUnion("type", [
4081
+ import_v417.z.object({ type: import_v417.z.literal("timeout") }),
4082
+ import_v417.z.object({
4083
+ type: import_v417.z.literal("exit"),
4084
+ exit_code: import_v417.z.number()
3848
4085
  })
3849
4086
  ])
3850
4087
  })
3851
4088
  )
4089
+ }),
4090
+ import_v417.z.object({
4091
+ type: import_v417.z.literal("tool_search_call"),
4092
+ id: import_v417.z.string(),
4093
+ execution: import_v417.z.enum(["server", "client"]),
4094
+ call_id: import_v417.z.string().nullable(),
4095
+ status: import_v417.z.enum(["in_progress", "completed", "incomplete"]),
4096
+ arguments: import_v417.z.unknown()
4097
+ }),
4098
+ import_v417.z.object({
4099
+ type: import_v417.z.literal("tool_search_output"),
4100
+ id: import_v417.z.string(),
4101
+ execution: import_v417.z.enum(["server", "client"]),
4102
+ call_id: import_v417.z.string().nullable(),
4103
+ status: import_v417.z.enum(["in_progress", "completed", "incomplete"]),
4104
+ tools: import_v417.z.array(import_v417.z.record(import_v417.z.string(), jsonValueSchema.optional()))
3852
4105
  })
3853
4106
  ])
3854
4107
  ).optional(),
3855
- service_tier: import_v416.z.string().nullish(),
3856
- incomplete_details: import_v416.z.object({ reason: import_v416.z.string() }).nullish(),
3857
- usage: import_v416.z.object({
3858
- input_tokens: import_v416.z.number(),
3859
- input_tokens_details: import_v416.z.object({ cached_tokens: import_v416.z.number().nullish() }).nullish(),
3860
- output_tokens: import_v416.z.number(),
3861
- output_tokens_details: import_v416.z.object({ reasoning_tokens: import_v416.z.number().nullish() }).nullish()
4108
+ service_tier: import_v417.z.string().nullish(),
4109
+ incomplete_details: import_v417.z.object({ reason: import_v417.z.string() }).nullish(),
4110
+ usage: import_v417.z.object({
4111
+ input_tokens: import_v417.z.number(),
4112
+ input_tokens_details: import_v417.z.object({ cached_tokens: import_v417.z.number().nullish() }).nullish(),
4113
+ output_tokens: import_v417.z.number(),
4114
+ output_tokens_details: import_v417.z.object({ reasoning_tokens: import_v417.z.number().nullish() }).nullish()
3862
4115
  }).optional()
3863
4116
  })
3864
4117
  )
3865
4118
  );
3866
4119
 
3867
4120
  // src/responses/openai-responses-options.ts
3868
- var import_provider_utils24 = require("@ai-sdk/provider-utils");
3869
- var import_v417 = require("zod/v4");
4121
+ var import_provider_utils25 = require("@ai-sdk/provider-utils");
4122
+ var import_v418 = require("zod/v4");
3870
4123
  var TOP_LOGPROBS_MAX = 20;
3871
4124
  var openaiResponsesReasoningModelIds = [
3872
4125
  "o1",
@@ -3895,11 +4148,16 @@ var openaiResponsesReasoningModelIds = [
3895
4148
  "gpt-5.2-chat-latest",
3896
4149
  "gpt-5.2-pro",
3897
4150
  "gpt-5.2-codex",
4151
+ "gpt-5.3-chat-latest",
4152
+ "gpt-5.3-codex",
3898
4153
  "gpt-5.4",
3899
4154
  "gpt-5.4-2026-03-05",
4155
+ "gpt-5.4-mini",
4156
+ "gpt-5.4-mini-2026-03-17",
4157
+ "gpt-5.4-nano",
4158
+ "gpt-5.4-nano-2026-03-17",
3900
4159
  "gpt-5.4-pro",
3901
- "gpt-5.4-pro-2026-03-05",
3902
- "gpt-5.3-codex"
4160
+ "gpt-5.4-pro-2026-03-05"
3903
4161
  ];
3904
4162
  var openaiResponsesModelIds = [
3905
4163
  "gpt-4.1",
@@ -3926,9 +4184,9 @@ var openaiResponsesModelIds = [
3926
4184
  "gpt-5-chat-latest",
3927
4185
  ...openaiResponsesReasoningModelIds
3928
4186
  ];
3929
- var openaiLanguageModelResponsesOptionsSchema = (0, import_provider_utils24.lazySchema)(
3930
- () => (0, import_provider_utils24.zodSchema)(
3931
- import_v417.z.object({
4187
+ var openaiLanguageModelResponsesOptionsSchema = (0, import_provider_utils25.lazySchema)(
4188
+ () => (0, import_provider_utils25.zodSchema)(
4189
+ import_v418.z.object({
3932
4190
  /**
3933
4191
  * The ID of the OpenAI Conversation to continue.
3934
4192
  * You must create a conversation first via the OpenAI API.
@@ -3936,13 +4194,13 @@ var openaiLanguageModelResponsesOptionsSchema = (0, import_provider_utils24.lazy
3936
4194
  * Defaults to `undefined`.
3937
4195
  * @see https://platform.openai.com/docs/api-reference/conversations/create
3938
4196
  */
3939
- conversation: import_v417.z.string().nullish(),
4197
+ conversation: import_v418.z.string().nullish(),
3940
4198
  /**
3941
4199
  * The set of extra fields to include in the response (advanced, usually not needed).
3942
4200
  * Example values: 'reasoning.encrypted_content', 'file_search_call.results', 'message.output_text.logprobs'.
3943
4201
  */
3944
- include: import_v417.z.array(
3945
- import_v417.z.enum([
4202
+ include: import_v418.z.array(
4203
+ import_v418.z.enum([
3946
4204
  "reasoning.encrypted_content",
3947
4205
  // handled internally by default, only needed for unknown reasoning models
3948
4206
  "file_search_call.results",
@@ -3954,7 +4212,7 @@ var openaiLanguageModelResponsesOptionsSchema = (0, import_provider_utils24.lazy
3954
4212
  * They can be used to change the system or developer message when continuing a conversation using the `previousResponseId` option.
3955
4213
  * Defaults to `undefined`.
3956
4214
  */
3957
- instructions: import_v417.z.string().nullish(),
4215
+ instructions: import_v418.z.string().nullish(),
3958
4216
  /**
3959
4217
  * Return the log probabilities of the tokens. Including logprobs will increase
3960
4218
  * the response size and can slow down response times. However, it can
@@ -3969,30 +4227,30 @@ var openaiLanguageModelResponsesOptionsSchema = (0, import_provider_utils24.lazy
3969
4227
  * @see https://platform.openai.com/docs/api-reference/responses/create
3970
4228
  * @see https://cookbook.openai.com/examples/using_logprobs
3971
4229
  */
3972
- logprobs: import_v417.z.union([import_v417.z.boolean(), import_v417.z.number().min(1).max(TOP_LOGPROBS_MAX)]).optional(),
4230
+ logprobs: import_v418.z.union([import_v418.z.boolean(), import_v418.z.number().min(1).max(TOP_LOGPROBS_MAX)]).optional(),
3973
4231
  /**
3974
4232
  * The maximum number of total calls to built-in tools that can be processed in a response.
3975
4233
  * This maximum number applies across all built-in tool calls, not per individual tool.
3976
4234
  * Any further attempts to call a tool by the model will be ignored.
3977
4235
  */
3978
- maxToolCalls: import_v417.z.number().nullish(),
4236
+ maxToolCalls: import_v418.z.number().nullish(),
3979
4237
  /**
3980
4238
  * Additional metadata to store with the generation.
3981
4239
  */
3982
- metadata: import_v417.z.any().nullish(),
4240
+ metadata: import_v418.z.any().nullish(),
3983
4241
  /**
3984
4242
  * Whether to use parallel tool calls. Defaults to `true`.
3985
4243
  */
3986
- parallelToolCalls: import_v417.z.boolean().nullish(),
4244
+ parallelToolCalls: import_v418.z.boolean().nullish(),
3987
4245
  /**
3988
4246
  * The ID of the previous response. You can use it to continue a conversation.
3989
4247
  * Defaults to `undefined`.
3990
4248
  */
3991
- previousResponseId: import_v417.z.string().nullish(),
4249
+ previousResponseId: import_v418.z.string().nullish(),
3992
4250
  /**
3993
4251
  * Sets a cache key to tie this prompt to cached prefixes for better caching performance.
3994
4252
  */
3995
- promptCacheKey: import_v417.z.string().nullish(),
4253
+ promptCacheKey: import_v418.z.string().nullish(),
3996
4254
  /**
3997
4255
  * The retention policy for the prompt cache.
3998
4256
  * - 'in_memory': Default. Standard prompt caching behavior.
@@ -4001,7 +4259,7 @@ var openaiLanguageModelResponsesOptionsSchema = (0, import_provider_utils24.lazy
4001
4259
  *
4002
4260
  * @default 'in_memory'
4003
4261
  */
4004
- promptCacheRetention: import_v417.z.enum(["in_memory", "24h"]).nullish(),
4262
+ promptCacheRetention: import_v418.z.enum(["in_memory", "24h"]).nullish(),
4005
4263
  /**
4006
4264
  * Reasoning effort for reasoning models. Defaults to `medium`. If you use
4007
4265
  * `providerOptions` to set the `reasoningEffort` option, this model setting will be ignored.
@@ -4012,17 +4270,17 @@ var openaiLanguageModelResponsesOptionsSchema = (0, import_provider_utils24.lazy
4012
4270
  * OpenAI's GPT-5.1-Codex-Max model. Setting `reasoningEffort` to 'none' or 'xhigh' with unsupported models will result in
4013
4271
  * an error.
4014
4272
  */
4015
- reasoningEffort: import_v417.z.string().nullish(),
4273
+ reasoningEffort: import_v418.z.string().nullish(),
4016
4274
  /**
4017
4275
  * Controls reasoning summary output from the model.
4018
4276
  * Set to "auto" to automatically receive the richest level available,
4019
4277
  * or "detailed" for comprehensive summaries.
4020
4278
  */
4021
- reasoningSummary: import_v417.z.string().nullish(),
4279
+ reasoningSummary: import_v418.z.string().nullish(),
4022
4280
  /**
4023
4281
  * The identifier for safety monitoring and tracking.
4024
4282
  */
4025
- safetyIdentifier: import_v417.z.string().nullish(),
4283
+ safetyIdentifier: import_v418.z.string().nullish(),
4026
4284
  /**
4027
4285
  * Service tier for the request.
4028
4286
  * Set to 'flex' for 50% cheaper processing at the cost of increased latency (available for o3, o4-mini, and gpt-5 models).
@@ -4030,34 +4288,34 @@ var openaiLanguageModelResponsesOptionsSchema = (0, import_provider_utils24.lazy
4030
4288
  *
4031
4289
  * Defaults to 'auto'.
4032
4290
  */
4033
- serviceTier: import_v417.z.enum(["auto", "flex", "priority", "default"]).nullish(),
4291
+ serviceTier: import_v418.z.enum(["auto", "flex", "priority", "default"]).nullish(),
4034
4292
  /**
4035
4293
  * Whether to store the generation. Defaults to `true`.
4036
4294
  */
4037
- store: import_v417.z.boolean().nullish(),
4295
+ store: import_v418.z.boolean().nullish(),
4038
4296
  /**
4039
4297
  * Whether to use strict JSON schema validation.
4040
4298
  * Defaults to `true`.
4041
4299
  */
4042
- strictJsonSchema: import_v417.z.boolean().nullish(),
4300
+ strictJsonSchema: import_v418.z.boolean().nullish(),
4043
4301
  /**
4044
4302
  * Controls the verbosity of the model's responses. Lower values ('low') will result
4045
4303
  * in more concise responses, while higher values ('high') will result in more verbose responses.
4046
4304
  * Valid values: 'low', 'medium', 'high'.
4047
4305
  */
4048
- textVerbosity: import_v417.z.enum(["low", "medium", "high"]).nullish(),
4306
+ textVerbosity: import_v418.z.enum(["low", "medium", "high"]).nullish(),
4049
4307
  /**
4050
4308
  * Controls output truncation. 'auto' (default) performs truncation automatically;
4051
4309
  * 'disabled' turns truncation off.
4052
4310
  */
4053
- truncation: import_v417.z.enum(["auto", "disabled"]).nullish(),
4311
+ truncation: import_v418.z.enum(["auto", "disabled"]).nullish(),
4054
4312
  /**
4055
4313
  * A unique identifier representing your end-user, which can help OpenAI to
4056
4314
  * monitor and detect abuse.
4057
4315
  * Defaults to `undefined`.
4058
4316
  * @see https://platform.openai.com/docs/guides/safety-best-practices/end-user-ids
4059
4317
  */
4060
- user: import_v417.z.string().nullish(),
4318
+ user: import_v418.z.string().nullish(),
4061
4319
  /**
4062
4320
  * Override the system message mode for this model.
4063
4321
  * - 'system': Use the 'system' role for system messages (default for most models)
@@ -4066,7 +4324,7 @@ var openaiLanguageModelResponsesOptionsSchema = (0, import_provider_utils24.lazy
4066
4324
  *
4067
4325
  * If not specified, the mode is automatically determined based on the model.
4068
4326
  */
4069
- systemMessageMode: import_v417.z.enum(["system", "developer", "remove"]).optional(),
4327
+ systemMessageMode: import_v418.z.enum(["system", "developer", "remove"]).optional(),
4070
4328
  /**
4071
4329
  * Force treating this model as a reasoning model.
4072
4330
  *
@@ -4076,51 +4334,60 @@ var openaiLanguageModelResponsesOptionsSchema = (0, import_provider_utils24.lazy
4076
4334
  * When enabled, the SDK applies reasoning-model parameter compatibility rules
4077
4335
  * and defaults `systemMessageMode` to `developer` unless overridden.
4078
4336
  */
4079
- forceReasoning: import_v417.z.boolean().optional()
4337
+ forceReasoning: import_v418.z.boolean().optional(),
4338
+ /**
4339
+ * Enable server-side context management (compaction).
4340
+ */
4341
+ contextManagement: import_v418.z.array(
4342
+ import_v418.z.object({
4343
+ type: import_v418.z.literal("compaction"),
4344
+ compactThreshold: import_v418.z.number()
4345
+ })
4346
+ ).nullish()
4080
4347
  })
4081
4348
  )
4082
4349
  );
4083
4350
 
4084
4351
  // src/responses/openai-responses-prepare-tools.ts
4085
4352
  var import_provider7 = require("@ai-sdk/provider");
4086
- var import_provider_utils32 = require("@ai-sdk/provider-utils");
4353
+ var import_provider_utils33 = require("@ai-sdk/provider-utils");
4087
4354
 
4088
4355
  // src/tool/code-interpreter.ts
4089
- var import_provider_utils25 = require("@ai-sdk/provider-utils");
4090
- var import_v418 = require("zod/v4");
4091
- var codeInterpreterInputSchema = (0, import_provider_utils25.lazySchema)(
4092
- () => (0, import_provider_utils25.zodSchema)(
4093
- import_v418.z.object({
4094
- code: import_v418.z.string().nullish(),
4095
- containerId: import_v418.z.string()
4356
+ var import_provider_utils26 = require("@ai-sdk/provider-utils");
4357
+ var import_v419 = require("zod/v4");
4358
+ var codeInterpreterInputSchema = (0, import_provider_utils26.lazySchema)(
4359
+ () => (0, import_provider_utils26.zodSchema)(
4360
+ import_v419.z.object({
4361
+ code: import_v419.z.string().nullish(),
4362
+ containerId: import_v419.z.string()
4096
4363
  })
4097
4364
  )
4098
4365
  );
4099
- var codeInterpreterOutputSchema = (0, import_provider_utils25.lazySchema)(
4100
- () => (0, import_provider_utils25.zodSchema)(
4101
- import_v418.z.object({
4102
- outputs: import_v418.z.array(
4103
- import_v418.z.discriminatedUnion("type", [
4104
- import_v418.z.object({ type: import_v418.z.literal("logs"), logs: import_v418.z.string() }),
4105
- import_v418.z.object({ type: import_v418.z.literal("image"), url: import_v418.z.string() })
4366
+ var codeInterpreterOutputSchema = (0, import_provider_utils26.lazySchema)(
4367
+ () => (0, import_provider_utils26.zodSchema)(
4368
+ import_v419.z.object({
4369
+ outputs: import_v419.z.array(
4370
+ import_v419.z.discriminatedUnion("type", [
4371
+ import_v419.z.object({ type: import_v419.z.literal("logs"), logs: import_v419.z.string() }),
4372
+ import_v419.z.object({ type: import_v419.z.literal("image"), url: import_v419.z.string() })
4106
4373
  ])
4107
4374
  ).nullish()
4108
4375
  })
4109
4376
  )
4110
4377
  );
4111
- var codeInterpreterArgsSchema = (0, import_provider_utils25.lazySchema)(
4112
- () => (0, import_provider_utils25.zodSchema)(
4113
- import_v418.z.object({
4114
- container: import_v418.z.union([
4115
- import_v418.z.string(),
4116
- import_v418.z.object({
4117
- fileIds: import_v418.z.array(import_v418.z.string()).optional()
4378
+ var codeInterpreterArgsSchema = (0, import_provider_utils26.lazySchema)(
4379
+ () => (0, import_provider_utils26.zodSchema)(
4380
+ import_v419.z.object({
4381
+ container: import_v419.z.union([
4382
+ import_v419.z.string(),
4383
+ import_v419.z.object({
4384
+ fileIds: import_v419.z.array(import_v419.z.string()).optional()
4118
4385
  })
4119
4386
  ]).optional()
4120
4387
  })
4121
4388
  )
4122
4389
  );
4123
- var codeInterpreterToolFactory = (0, import_provider_utils25.createProviderToolFactoryWithOutputSchema)({
4390
+ var codeInterpreterToolFactory = (0, import_provider_utils26.createProviderToolFactoryWithOutputSchema)({
4124
4391
  id: "openai.code_interpreter",
4125
4392
  inputSchema: codeInterpreterInputSchema,
4126
4393
  outputSchema: codeInterpreterOutputSchema
@@ -4130,81 +4397,81 @@ var codeInterpreter = (args = {}) => {
4130
4397
  };
4131
4398
 
4132
4399
  // src/tool/file-search.ts
4133
- var import_provider_utils26 = require("@ai-sdk/provider-utils");
4134
- var import_v419 = require("zod/v4");
4135
- var comparisonFilterSchema = import_v419.z.object({
4136
- key: import_v419.z.string(),
4137
- type: import_v419.z.enum(["eq", "ne", "gt", "gte", "lt", "lte", "in", "nin"]),
4138
- value: import_v419.z.union([import_v419.z.string(), import_v419.z.number(), import_v419.z.boolean(), import_v419.z.array(import_v419.z.string())])
4400
+ var import_provider_utils27 = require("@ai-sdk/provider-utils");
4401
+ var import_v420 = require("zod/v4");
4402
+ var comparisonFilterSchema = import_v420.z.object({
4403
+ key: import_v420.z.string(),
4404
+ type: import_v420.z.enum(["eq", "ne", "gt", "gte", "lt", "lte", "in", "nin"]),
4405
+ value: import_v420.z.union([import_v420.z.string(), import_v420.z.number(), import_v420.z.boolean(), import_v420.z.array(import_v420.z.string())])
4139
4406
  });
4140
- var compoundFilterSchema = import_v419.z.object({
4141
- type: import_v419.z.enum(["and", "or"]),
4142
- filters: import_v419.z.array(
4143
- import_v419.z.union([comparisonFilterSchema, import_v419.z.lazy(() => compoundFilterSchema)])
4407
+ var compoundFilterSchema = import_v420.z.object({
4408
+ type: import_v420.z.enum(["and", "or"]),
4409
+ filters: import_v420.z.array(
4410
+ import_v420.z.union([comparisonFilterSchema, import_v420.z.lazy(() => compoundFilterSchema)])
4144
4411
  )
4145
4412
  });
4146
- var fileSearchArgsSchema = (0, import_provider_utils26.lazySchema)(
4147
- () => (0, import_provider_utils26.zodSchema)(
4148
- import_v419.z.object({
4149
- vectorStoreIds: import_v419.z.array(import_v419.z.string()),
4150
- maxNumResults: import_v419.z.number().optional(),
4151
- ranking: import_v419.z.object({
4152
- ranker: import_v419.z.string().optional(),
4153
- scoreThreshold: import_v419.z.number().optional()
4413
+ var fileSearchArgsSchema = (0, import_provider_utils27.lazySchema)(
4414
+ () => (0, import_provider_utils27.zodSchema)(
4415
+ import_v420.z.object({
4416
+ vectorStoreIds: import_v420.z.array(import_v420.z.string()),
4417
+ maxNumResults: import_v420.z.number().optional(),
4418
+ ranking: import_v420.z.object({
4419
+ ranker: import_v420.z.string().optional(),
4420
+ scoreThreshold: import_v420.z.number().optional()
4154
4421
  }).optional(),
4155
- filters: import_v419.z.union([comparisonFilterSchema, compoundFilterSchema]).optional()
4422
+ filters: import_v420.z.union([comparisonFilterSchema, compoundFilterSchema]).optional()
4156
4423
  })
4157
4424
  )
4158
4425
  );
4159
- var fileSearchOutputSchema = (0, import_provider_utils26.lazySchema)(
4160
- () => (0, import_provider_utils26.zodSchema)(
4161
- import_v419.z.object({
4162
- queries: import_v419.z.array(import_v419.z.string()),
4163
- results: import_v419.z.array(
4164
- import_v419.z.object({
4165
- attributes: import_v419.z.record(import_v419.z.string(), import_v419.z.unknown()),
4166
- fileId: import_v419.z.string(),
4167
- filename: import_v419.z.string(),
4168
- score: import_v419.z.number(),
4169
- text: import_v419.z.string()
4426
+ var fileSearchOutputSchema = (0, import_provider_utils27.lazySchema)(
4427
+ () => (0, import_provider_utils27.zodSchema)(
4428
+ import_v420.z.object({
4429
+ queries: import_v420.z.array(import_v420.z.string()),
4430
+ results: import_v420.z.array(
4431
+ import_v420.z.object({
4432
+ attributes: import_v420.z.record(import_v420.z.string(), import_v420.z.unknown()),
4433
+ fileId: import_v420.z.string(),
4434
+ filename: import_v420.z.string(),
4435
+ score: import_v420.z.number(),
4436
+ text: import_v420.z.string()
4170
4437
  })
4171
4438
  ).nullable()
4172
4439
  })
4173
4440
  )
4174
4441
  );
4175
- var fileSearch = (0, import_provider_utils26.createProviderToolFactoryWithOutputSchema)({
4442
+ var fileSearch = (0, import_provider_utils27.createProviderToolFactoryWithOutputSchema)({
4176
4443
  id: "openai.file_search",
4177
- inputSchema: import_v419.z.object({}),
4444
+ inputSchema: import_v420.z.object({}),
4178
4445
  outputSchema: fileSearchOutputSchema
4179
4446
  });
4180
4447
 
4181
4448
  // src/tool/image-generation.ts
4182
- var import_provider_utils27 = require("@ai-sdk/provider-utils");
4183
- var import_v420 = require("zod/v4");
4184
- var imageGenerationArgsSchema = (0, import_provider_utils27.lazySchema)(
4185
- () => (0, import_provider_utils27.zodSchema)(
4186
- import_v420.z.object({
4187
- background: import_v420.z.enum(["auto", "opaque", "transparent"]).optional(),
4188
- inputFidelity: import_v420.z.enum(["low", "high"]).optional(),
4189
- inputImageMask: import_v420.z.object({
4190
- fileId: import_v420.z.string().optional(),
4191
- imageUrl: import_v420.z.string().optional()
4449
+ var import_provider_utils28 = require("@ai-sdk/provider-utils");
4450
+ var import_v421 = require("zod/v4");
4451
+ var imageGenerationArgsSchema = (0, import_provider_utils28.lazySchema)(
4452
+ () => (0, import_provider_utils28.zodSchema)(
4453
+ import_v421.z.object({
4454
+ background: import_v421.z.enum(["auto", "opaque", "transparent"]).optional(),
4455
+ inputFidelity: import_v421.z.enum(["low", "high"]).optional(),
4456
+ inputImageMask: import_v421.z.object({
4457
+ fileId: import_v421.z.string().optional(),
4458
+ imageUrl: import_v421.z.string().optional()
4192
4459
  }).optional(),
4193
- model: import_v420.z.string().optional(),
4194
- moderation: import_v420.z.enum(["auto"]).optional(),
4195
- outputCompression: import_v420.z.number().int().min(0).max(100).optional(),
4196
- outputFormat: import_v420.z.enum(["png", "jpeg", "webp"]).optional(),
4197
- partialImages: import_v420.z.number().int().min(0).max(3).optional(),
4198
- quality: import_v420.z.enum(["auto", "low", "medium", "high"]).optional(),
4199
- size: import_v420.z.enum(["1024x1024", "1024x1536", "1536x1024", "auto"]).optional()
4460
+ model: import_v421.z.string().optional(),
4461
+ moderation: import_v421.z.enum(["auto"]).optional(),
4462
+ outputCompression: import_v421.z.number().int().min(0).max(100).optional(),
4463
+ outputFormat: import_v421.z.enum(["png", "jpeg", "webp"]).optional(),
4464
+ partialImages: import_v421.z.number().int().min(0).max(3).optional(),
4465
+ quality: import_v421.z.enum(["auto", "low", "medium", "high"]).optional(),
4466
+ size: import_v421.z.enum(["1024x1024", "1024x1536", "1536x1024", "auto"]).optional()
4200
4467
  }).strict()
4201
4468
  )
4202
4469
  );
4203
- var imageGenerationInputSchema = (0, import_provider_utils27.lazySchema)(() => (0, import_provider_utils27.zodSchema)(import_v420.z.object({})));
4204
- var imageGenerationOutputSchema = (0, import_provider_utils27.lazySchema)(
4205
- () => (0, import_provider_utils27.zodSchema)(import_v420.z.object({ result: import_v420.z.string() }))
4470
+ var imageGenerationInputSchema = (0, import_provider_utils28.lazySchema)(() => (0, import_provider_utils28.zodSchema)(import_v421.z.object({})));
4471
+ var imageGenerationOutputSchema = (0, import_provider_utils28.lazySchema)(
4472
+ () => (0, import_provider_utils28.zodSchema)(import_v421.z.object({ result: import_v421.z.string() }))
4206
4473
  );
4207
- var imageGenerationToolFactory = (0, import_provider_utils27.createProviderToolFactoryWithOutputSchema)({
4474
+ var imageGenerationToolFactory = (0, import_provider_utils28.createProviderToolFactoryWithOutputSchema)({
4208
4475
  id: "openai.image_generation",
4209
4476
  inputSchema: imageGenerationInputSchema,
4210
4477
  outputSchema: imageGenerationOutputSchema
@@ -4214,153 +4481,101 @@ var imageGeneration = (args = {}) => {
4214
4481
  };
4215
4482
 
4216
4483
  // src/tool/custom.ts
4217
- var import_provider_utils28 = require("@ai-sdk/provider-utils");
4218
- var import_v421 = require("zod/v4");
4219
- var customArgsSchema = (0, import_provider_utils28.lazySchema)(
4220
- () => (0, import_provider_utils28.zodSchema)(
4221
- import_v421.z.object({
4222
- name: import_v421.z.string(),
4223
- description: import_v421.z.string().optional(),
4224
- format: import_v421.z.union([
4225
- import_v421.z.object({
4226
- type: import_v421.z.literal("grammar"),
4227
- syntax: import_v421.z.enum(["regex", "lark"]),
4228
- definition: import_v421.z.string()
4484
+ var import_provider_utils29 = require("@ai-sdk/provider-utils");
4485
+ var import_v422 = require("zod/v4");
4486
+ var customArgsSchema = (0, import_provider_utils29.lazySchema)(
4487
+ () => (0, import_provider_utils29.zodSchema)(
4488
+ import_v422.z.object({
4489
+ description: import_v422.z.string().optional(),
4490
+ format: import_v422.z.union([
4491
+ import_v422.z.object({
4492
+ type: import_v422.z.literal("grammar"),
4493
+ syntax: import_v422.z.enum(["regex", "lark"]),
4494
+ definition: import_v422.z.string()
4229
4495
  }),
4230
- import_v421.z.object({
4231
- type: import_v421.z.literal("text")
4496
+ import_v422.z.object({
4497
+ type: import_v422.z.literal("text")
4232
4498
  })
4233
4499
  ]).optional()
4234
4500
  })
4235
4501
  )
4236
4502
  );
4237
- var customInputSchema = (0, import_provider_utils28.lazySchema)(() => (0, import_provider_utils28.zodSchema)(import_v421.z.string()));
4238
- var customToolFactory = (0, import_provider_utils28.createProviderToolFactory)({
4503
+ var customInputSchema = (0, import_provider_utils29.lazySchema)(() => (0, import_provider_utils29.zodSchema)(import_v422.z.string()));
4504
+ var customToolFactory = (0, import_provider_utils29.createProviderToolFactory)({
4239
4505
  id: "openai.custom",
4240
4506
  inputSchema: customInputSchema
4241
4507
  });
4242
4508
 
4243
4509
  // src/tool/mcp.ts
4244
- var import_provider_utils29 = require("@ai-sdk/provider-utils");
4245
- var import_v422 = require("zod/v4");
4246
- var jsonValueSchema = import_v422.z.lazy(
4247
- () => import_v422.z.union([
4248
- import_v422.z.string(),
4249
- import_v422.z.number(),
4250
- import_v422.z.boolean(),
4251
- import_v422.z.null(),
4252
- import_v422.z.array(jsonValueSchema),
4253
- import_v422.z.record(import_v422.z.string(), jsonValueSchema)
4510
+ var import_provider_utils30 = require("@ai-sdk/provider-utils");
4511
+ var import_v423 = require("zod/v4");
4512
+ var jsonValueSchema2 = import_v423.z.lazy(
4513
+ () => import_v423.z.union([
4514
+ import_v423.z.string(),
4515
+ import_v423.z.number(),
4516
+ import_v423.z.boolean(),
4517
+ import_v423.z.null(),
4518
+ import_v423.z.array(jsonValueSchema2),
4519
+ import_v423.z.record(import_v423.z.string(), jsonValueSchema2)
4254
4520
  ])
4255
4521
  );
4256
- var mcpArgsSchema = (0, import_provider_utils29.lazySchema)(
4257
- () => (0, import_provider_utils29.zodSchema)(
4258
- import_v422.z.object({
4259
- serverLabel: import_v422.z.string(),
4260
- allowedTools: import_v422.z.union([
4261
- import_v422.z.array(import_v422.z.string()),
4262
- import_v422.z.object({
4263
- readOnly: import_v422.z.boolean().optional(),
4264
- toolNames: import_v422.z.array(import_v422.z.string()).optional()
4522
+ var mcpArgsSchema = (0, import_provider_utils30.lazySchema)(
4523
+ () => (0, import_provider_utils30.zodSchema)(
4524
+ import_v423.z.object({
4525
+ serverLabel: import_v423.z.string(),
4526
+ allowedTools: import_v423.z.union([
4527
+ import_v423.z.array(import_v423.z.string()),
4528
+ import_v423.z.object({
4529
+ readOnly: import_v423.z.boolean().optional(),
4530
+ toolNames: import_v423.z.array(import_v423.z.string()).optional()
4265
4531
  })
4266
4532
  ]).optional(),
4267
- authorization: import_v422.z.string().optional(),
4268
- connectorId: import_v422.z.string().optional(),
4269
- headers: import_v422.z.record(import_v422.z.string(), import_v422.z.string()).optional(),
4270
- requireApproval: import_v422.z.union([
4271
- import_v422.z.enum(["always", "never"]),
4272
- import_v422.z.object({
4273
- never: import_v422.z.object({
4274
- toolNames: import_v422.z.array(import_v422.z.string()).optional()
4533
+ authorization: import_v423.z.string().optional(),
4534
+ connectorId: import_v423.z.string().optional(),
4535
+ headers: import_v423.z.record(import_v423.z.string(), import_v423.z.string()).optional(),
4536
+ requireApproval: import_v423.z.union([
4537
+ import_v423.z.enum(["always", "never"]),
4538
+ import_v423.z.object({
4539
+ never: import_v423.z.object({
4540
+ toolNames: import_v423.z.array(import_v423.z.string()).optional()
4275
4541
  }).optional()
4276
4542
  })
4277
4543
  ]).optional(),
4278
- serverDescription: import_v422.z.string().optional(),
4279
- serverUrl: import_v422.z.string().optional()
4544
+ serverDescription: import_v423.z.string().optional(),
4545
+ serverUrl: import_v423.z.string().optional()
4280
4546
  }).refine(
4281
4547
  (v) => v.serverUrl != null || v.connectorId != null,
4282
4548
  "One of serverUrl or connectorId must be provided."
4283
4549
  )
4284
4550
  )
4285
4551
  );
4286
- var mcpInputSchema = (0, import_provider_utils29.lazySchema)(() => (0, import_provider_utils29.zodSchema)(import_v422.z.object({})));
4287
- var mcpOutputSchema = (0, import_provider_utils29.lazySchema)(
4288
- () => (0, import_provider_utils29.zodSchema)(
4289
- import_v422.z.object({
4290
- type: import_v422.z.literal("call"),
4291
- serverLabel: import_v422.z.string(),
4292
- name: import_v422.z.string(),
4293
- arguments: import_v422.z.string(),
4294
- output: import_v422.z.string().nullish(),
4295
- error: import_v422.z.union([import_v422.z.string(), jsonValueSchema]).optional()
4552
+ var mcpInputSchema = (0, import_provider_utils30.lazySchema)(() => (0, import_provider_utils30.zodSchema)(import_v423.z.object({})));
4553
+ var mcpOutputSchema = (0, import_provider_utils30.lazySchema)(
4554
+ () => (0, import_provider_utils30.zodSchema)(
4555
+ import_v423.z.object({
4556
+ type: import_v423.z.literal("call"),
4557
+ serverLabel: import_v423.z.string(),
4558
+ name: import_v423.z.string(),
4559
+ arguments: import_v423.z.string(),
4560
+ output: import_v423.z.string().nullish(),
4561
+ error: import_v423.z.union([import_v423.z.string(), jsonValueSchema2]).optional()
4296
4562
  })
4297
4563
  )
4298
4564
  );
4299
- var mcpToolFactory = (0, import_provider_utils29.createProviderToolFactoryWithOutputSchema)({
4565
+ var mcpToolFactory = (0, import_provider_utils30.createProviderToolFactoryWithOutputSchema)({
4300
4566
  id: "openai.mcp",
4301
4567
  inputSchema: mcpInputSchema,
4302
4568
  outputSchema: mcpOutputSchema
4303
4569
  });
4304
4570
 
4305
4571
  // src/tool/web-search.ts
4306
- var import_provider_utils30 = require("@ai-sdk/provider-utils");
4307
- var import_v423 = require("zod/v4");
4308
- var webSearchArgsSchema = (0, import_provider_utils30.lazySchema)(
4309
- () => (0, import_provider_utils30.zodSchema)(
4310
- import_v423.z.object({
4311
- externalWebAccess: import_v423.z.boolean().optional(),
4312
- filters: import_v423.z.object({ allowedDomains: import_v423.z.array(import_v423.z.string()).optional() }).optional(),
4313
- searchContextSize: import_v423.z.enum(["low", "medium", "high"]).optional(),
4314
- userLocation: import_v423.z.object({
4315
- type: import_v423.z.literal("approximate"),
4316
- country: import_v423.z.string().optional(),
4317
- city: import_v423.z.string().optional(),
4318
- region: import_v423.z.string().optional(),
4319
- timezone: import_v423.z.string().optional()
4320
- }).optional()
4321
- })
4322
- )
4323
- );
4324
- var webSearchInputSchema = (0, import_provider_utils30.lazySchema)(() => (0, import_provider_utils30.zodSchema)(import_v423.z.object({})));
4325
- var webSearchOutputSchema = (0, import_provider_utils30.lazySchema)(
4326
- () => (0, import_provider_utils30.zodSchema)(
4327
- import_v423.z.object({
4328
- action: import_v423.z.discriminatedUnion("type", [
4329
- import_v423.z.object({
4330
- type: import_v423.z.literal("search"),
4331
- query: import_v423.z.string().optional()
4332
- }),
4333
- import_v423.z.object({
4334
- type: import_v423.z.literal("openPage"),
4335
- url: import_v423.z.string().nullish()
4336
- }),
4337
- import_v423.z.object({
4338
- type: import_v423.z.literal("findInPage"),
4339
- url: import_v423.z.string().nullish(),
4340
- pattern: import_v423.z.string().nullish()
4341
- })
4342
- ]).optional(),
4343
- sources: import_v423.z.array(
4344
- import_v423.z.discriminatedUnion("type", [
4345
- import_v423.z.object({ type: import_v423.z.literal("url"), url: import_v423.z.string() }),
4346
- import_v423.z.object({ type: import_v423.z.literal("api"), name: import_v423.z.string() })
4347
- ])
4348
- ).optional()
4349
- })
4350
- )
4351
- );
4352
- var webSearchToolFactory = (0, import_provider_utils30.createProviderToolFactoryWithOutputSchema)({
4353
- id: "openai.web_search",
4354
- inputSchema: webSearchInputSchema,
4355
- outputSchema: webSearchOutputSchema
4356
- });
4357
-
4358
- // src/tool/web-search-preview.ts
4359
4572
  var import_provider_utils31 = require("@ai-sdk/provider-utils");
4360
4573
  var import_v424 = require("zod/v4");
4361
- var webSearchPreviewArgsSchema = (0, import_provider_utils31.lazySchema)(
4574
+ var webSearchArgsSchema = (0, import_provider_utils31.lazySchema)(
4362
4575
  () => (0, import_provider_utils31.zodSchema)(
4363
4576
  import_v424.z.object({
4577
+ externalWebAccess: import_v424.z.boolean().optional(),
4578
+ filters: import_v424.z.object({ allowedDomains: import_v424.z.array(import_v424.z.string()).optional() }).optional(),
4364
4579
  searchContextSize: import_v424.z.enum(["low", "medium", "high"]).optional(),
4365
4580
  userLocation: import_v424.z.object({
4366
4581
  type: import_v424.z.literal("approximate"),
@@ -4372,10 +4587,8 @@ var webSearchPreviewArgsSchema = (0, import_provider_utils31.lazySchema)(
4372
4587
  })
4373
4588
  )
4374
4589
  );
4375
- var webSearchPreviewInputSchema = (0, import_provider_utils31.lazySchema)(
4376
- () => (0, import_provider_utils31.zodSchema)(import_v424.z.object({}))
4377
- );
4378
- var webSearchPreviewOutputSchema = (0, import_provider_utils31.lazySchema)(
4590
+ var webSearchInputSchema = (0, import_provider_utils31.lazySchema)(() => (0, import_provider_utils31.zodSchema)(import_v424.z.object({})));
4591
+ var webSearchOutputSchema = (0, import_provider_utils31.lazySchema)(
4379
4592
  () => (0, import_provider_utils31.zodSchema)(
4380
4593
  import_v424.z.object({
4381
4594
  action: import_v424.z.discriminatedUnion("type", [
@@ -4392,11 +4605,64 @@ var webSearchPreviewOutputSchema = (0, import_provider_utils31.lazySchema)(
4392
4605
  url: import_v424.z.string().nullish(),
4393
4606
  pattern: import_v424.z.string().nullish()
4394
4607
  })
4608
+ ]).optional(),
4609
+ sources: import_v424.z.array(
4610
+ import_v424.z.discriminatedUnion("type", [
4611
+ import_v424.z.object({ type: import_v424.z.literal("url"), url: import_v424.z.string() }),
4612
+ import_v424.z.object({ type: import_v424.z.literal("api"), name: import_v424.z.string() })
4613
+ ])
4614
+ ).optional()
4615
+ })
4616
+ )
4617
+ );
4618
+ var webSearchToolFactory = (0, import_provider_utils31.createProviderToolFactoryWithOutputSchema)({
4619
+ id: "openai.web_search",
4620
+ inputSchema: webSearchInputSchema,
4621
+ outputSchema: webSearchOutputSchema
4622
+ });
4623
+
4624
+ // src/tool/web-search-preview.ts
4625
+ var import_provider_utils32 = require("@ai-sdk/provider-utils");
4626
+ var import_v425 = require("zod/v4");
4627
+ var webSearchPreviewArgsSchema = (0, import_provider_utils32.lazySchema)(
4628
+ () => (0, import_provider_utils32.zodSchema)(
4629
+ import_v425.z.object({
4630
+ searchContextSize: import_v425.z.enum(["low", "medium", "high"]).optional(),
4631
+ userLocation: import_v425.z.object({
4632
+ type: import_v425.z.literal("approximate"),
4633
+ country: import_v425.z.string().optional(),
4634
+ city: import_v425.z.string().optional(),
4635
+ region: import_v425.z.string().optional(),
4636
+ timezone: import_v425.z.string().optional()
4637
+ }).optional()
4638
+ })
4639
+ )
4640
+ );
4641
+ var webSearchPreviewInputSchema = (0, import_provider_utils32.lazySchema)(
4642
+ () => (0, import_provider_utils32.zodSchema)(import_v425.z.object({}))
4643
+ );
4644
+ var webSearchPreviewOutputSchema = (0, import_provider_utils32.lazySchema)(
4645
+ () => (0, import_provider_utils32.zodSchema)(
4646
+ import_v425.z.object({
4647
+ action: import_v425.z.discriminatedUnion("type", [
4648
+ import_v425.z.object({
4649
+ type: import_v425.z.literal("search"),
4650
+ query: import_v425.z.string().optional()
4651
+ }),
4652
+ import_v425.z.object({
4653
+ type: import_v425.z.literal("openPage"),
4654
+ url: import_v425.z.string().nullish()
4655
+ }),
4656
+ import_v425.z.object({
4657
+ type: import_v425.z.literal("findInPage"),
4658
+ url: import_v425.z.string().nullish(),
4659
+ pattern: import_v425.z.string().nullish()
4660
+ })
4395
4661
  ]).optional()
4396
4662
  })
4397
4663
  )
4398
4664
  );
4399
- var webSearchPreview = (0, import_provider_utils31.createProviderToolFactoryWithOutputSchema)({
4665
+ var webSearchPreview = (0, import_provider_utils32.createProviderToolFactoryWithOutputSchema)({
4400
4666
  id: "openai.web_search_preview",
4401
4667
  inputSchema: webSearchPreviewInputSchema,
4402
4668
  outputSchema: webSearchPreviewOutputSchema
@@ -4409,7 +4675,7 @@ async function prepareResponsesTools({
4409
4675
  toolNameMapping,
4410
4676
  customProviderToolNames
4411
4677
  }) {
4412
- var _a;
4678
+ var _a, _b;
4413
4679
  tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
4414
4680
  const toolWarnings = [];
4415
4681
  if (tools == null) {
@@ -4419,19 +4685,23 @@ async function prepareResponsesTools({
4419
4685
  const resolvedCustomProviderToolNames = customProviderToolNames != null ? customProviderToolNames : /* @__PURE__ */ new Set();
4420
4686
  for (const tool of tools) {
4421
4687
  switch (tool.type) {
4422
- case "function":
4688
+ case "function": {
4689
+ const openaiOptions = (_a = tool.providerOptions) == null ? void 0 : _a.openai;
4690
+ const deferLoading = openaiOptions == null ? void 0 : openaiOptions.deferLoading;
4423
4691
  openaiTools.push({
4424
4692
  type: "function",
4425
4693
  name: tool.name,
4426
4694
  description: tool.description,
4427
4695
  parameters: tool.inputSchema,
4428
- ...tool.strict != null ? { strict: tool.strict } : {}
4696
+ ...tool.strict != null ? { strict: tool.strict } : {},
4697
+ ...deferLoading != null ? { defer_loading: deferLoading } : {}
4429
4698
  });
4430
4699
  break;
4700
+ }
4431
4701
  case "provider": {
4432
4702
  switch (tool.id) {
4433
4703
  case "openai.file_search": {
4434
- const args = await (0, import_provider_utils32.validateTypes)({
4704
+ const args = await (0, import_provider_utils33.validateTypes)({
4435
4705
  value: tool.args,
4436
4706
  schema: fileSearchArgsSchema
4437
4707
  });
@@ -4454,7 +4724,7 @@ async function prepareResponsesTools({
4454
4724
  break;
4455
4725
  }
4456
4726
  case "openai.shell": {
4457
- const args = await (0, import_provider_utils32.validateTypes)({
4727
+ const args = await (0, import_provider_utils33.validateTypes)({
4458
4728
  value: tool.args,
4459
4729
  schema: shellArgsSchema
4460
4730
  });
@@ -4473,7 +4743,7 @@ async function prepareResponsesTools({
4473
4743
  break;
4474
4744
  }
4475
4745
  case "openai.web_search_preview": {
4476
- const args = await (0, import_provider_utils32.validateTypes)({
4746
+ const args = await (0, import_provider_utils33.validateTypes)({
4477
4747
  value: tool.args,
4478
4748
  schema: webSearchPreviewArgsSchema
4479
4749
  });
@@ -4485,7 +4755,7 @@ async function prepareResponsesTools({
4485
4755
  break;
4486
4756
  }
4487
4757
  case "openai.web_search": {
4488
- const args = await (0, import_provider_utils32.validateTypes)({
4758
+ const args = await (0, import_provider_utils33.validateTypes)({
4489
4759
  value: tool.args,
4490
4760
  schema: webSearchArgsSchema
4491
4761
  });
@@ -4499,7 +4769,7 @@ async function prepareResponsesTools({
4499
4769
  break;
4500
4770
  }
4501
4771
  case "openai.code_interpreter": {
4502
- const args = await (0, import_provider_utils32.validateTypes)({
4772
+ const args = await (0, import_provider_utils33.validateTypes)({
4503
4773
  value: tool.args,
4504
4774
  schema: codeInterpreterArgsSchema
4505
4775
  });
@@ -4510,7 +4780,7 @@ async function prepareResponsesTools({
4510
4780
  break;
4511
4781
  }
4512
4782
  case "openai.image_generation": {
4513
- const args = await (0, import_provider_utils32.validateTypes)({
4783
+ const args = await (0, import_provider_utils33.validateTypes)({
4514
4784
  value: tool.args,
4515
4785
  schema: imageGenerationArgsSchema
4516
4786
  });
@@ -4533,7 +4803,7 @@ async function prepareResponsesTools({
4533
4803
  break;
4534
4804
  }
4535
4805
  case "openai.mcp": {
4536
- const args = await (0, import_provider_utils32.validateTypes)({
4806
+ const args = await (0, import_provider_utils33.validateTypes)({
4537
4807
  value: tool.args,
4538
4808
  schema: mcpArgsSchema
4539
4809
  });
@@ -4559,17 +4829,30 @@ async function prepareResponsesTools({
4559
4829
  break;
4560
4830
  }
4561
4831
  case "openai.custom": {
4562
- const args = await (0, import_provider_utils32.validateTypes)({
4832
+ const args = await (0, import_provider_utils33.validateTypes)({
4563
4833
  value: tool.args,
4564
4834
  schema: customArgsSchema
4565
4835
  });
4566
4836
  openaiTools.push({
4567
4837
  type: "custom",
4568
- name: args.name,
4838
+ name: tool.name,
4569
4839
  description: args.description,
4570
4840
  format: args.format
4571
4841
  });
4572
- resolvedCustomProviderToolNames.add(args.name);
4842
+ resolvedCustomProviderToolNames.add(tool.name);
4843
+ break;
4844
+ }
4845
+ case "openai.tool_search": {
4846
+ const args = await (0, import_provider_utils33.validateTypes)({
4847
+ value: tool.args,
4848
+ schema: toolSearchArgsSchema
4849
+ });
4850
+ openaiTools.push({
4851
+ type: "tool_search",
4852
+ ...args.execution != null ? { execution: args.execution } : {},
4853
+ ...args.description != null ? { description: args.description } : {},
4854
+ ...args.parameters != null ? { parameters: args.parameters } : {}
4855
+ });
4573
4856
  break;
4574
4857
  }
4575
4858
  }
@@ -4593,7 +4876,7 @@ async function prepareResponsesTools({
4593
4876
  case "required":
4594
4877
  return { tools: openaiTools, toolChoice: type, toolWarnings };
4595
4878
  case "tool": {
4596
- const resolvedToolName = (_a = toolNameMapping == null ? void 0 : toolNameMapping.toProviderToolName(toolChoice.toolName)) != null ? _a : toolChoice.toolName;
4879
+ const resolvedToolName = (_b = toolNameMapping == null ? void 0 : toolNameMapping.toProviderToolName(toolChoice.toolName)) != null ? _b : toolChoice.toolName;
4597
4880
  return {
4598
4881
  tools: openaiTools,
4599
4882
  toolChoice: resolvedToolName === "code_interpreter" || resolvedToolName === "file_search" || resolvedToolName === "image_generation" || resolvedToolName === "web_search_preview" || resolvedToolName === "web_search" || resolvedToolName === "mcp" || resolvedToolName === "apply_patch" ? { type: resolvedToolName } : resolvedCustomProviderToolNames.has(resolvedToolName) ? { type: "custom", name: resolvedToolName } : { type: "function", name: resolvedToolName },
@@ -4673,7 +4956,7 @@ function extractApprovalRequestIdToToolCallIdMapping(prompt) {
4673
4956
  }
4674
4957
  var OpenAIResponsesLanguageModel = class {
4675
4958
  constructor(modelId, config) {
4676
- this.specificationVersion = "v3";
4959
+ this.specificationVersion = "v4";
4677
4960
  this.supportedUrls = {
4678
4961
  "image/*": [/^https?:\/\/.*$/],
4679
4962
  "application/pdf": [/^https?:\/\/.*$/]
@@ -4694,12 +4977,13 @@ var OpenAIResponsesLanguageModel = class {
4694
4977
  frequencyPenalty,
4695
4978
  seed,
4696
4979
  prompt,
4980
+ reasoning,
4697
4981
  providerOptions,
4698
4982
  tools,
4699
4983
  toolChoice,
4700
4984
  responseFormat
4701
4985
  }) {
4702
- var _a, _b, _c, _d, _e, _f, _g, _h, _i;
4986
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
4703
4987
  const warnings = [];
4704
4988
  const modelCapabilities = getOpenAILanguageModelCapabilities(this.modelId);
4705
4989
  if (topK != null) {
@@ -4718,19 +5002,20 @@ var OpenAIResponsesLanguageModel = class {
4718
5002
  warnings.push({ type: "unsupported", feature: "stopSequences" });
4719
5003
  }
4720
5004
  const providerOptionsName = this.config.provider.includes("azure") ? "azure" : "openai";
4721
- let openaiOptions = await (0, import_provider_utils33.parseProviderOptions)({
5005
+ let openaiOptions = await (0, import_provider_utils34.parseProviderOptions)({
4722
5006
  provider: providerOptionsName,
4723
5007
  providerOptions,
4724
5008
  schema: openaiLanguageModelResponsesOptionsSchema
4725
5009
  });
4726
5010
  if (openaiOptions == null && providerOptionsName !== "openai") {
4727
- openaiOptions = await (0, import_provider_utils33.parseProviderOptions)({
5011
+ openaiOptions = await (0, import_provider_utils34.parseProviderOptions)({
4728
5012
  provider: "openai",
4729
5013
  providerOptions,
4730
5014
  schema: openaiLanguageModelResponsesOptionsSchema
4731
5015
  });
4732
5016
  }
4733
- const isReasoningModel = (_a = openaiOptions == null ? void 0 : openaiOptions.forceReasoning) != null ? _a : modelCapabilities.isReasoningModel;
5017
+ const resolvedReasoningEffort = (_a = openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null ? _a : (0, import_provider_utils34.isCustomReasoning)(reasoning) ? reasoning : void 0;
5018
+ const isReasoningModel = (_b = openaiOptions == null ? void 0 : openaiOptions.forceReasoning) != null ? _b : modelCapabilities.isReasoningModel;
4734
5019
  if ((openaiOptions == null ? void 0 : openaiOptions.conversation) && (openaiOptions == null ? void 0 : openaiOptions.previousResponseId)) {
4735
5020
  warnings.push({
4736
5021
  type: "unsupported",
@@ -4738,7 +5023,7 @@ var OpenAIResponsesLanguageModel = class {
4738
5023
  details: "conversation and previousResponseId cannot be used together"
4739
5024
  });
4740
5025
  }
4741
- const toolNameMapping = (0, import_provider_utils33.createToolNameMapping)({
5026
+ const toolNameMapping = (0, import_provider_utils34.createToolNameMapping)({
4742
5027
  tools,
4743
5028
  providerToolNames: {
4744
5029
  "openai.code_interpreter": "code_interpreter",
@@ -4749,9 +5034,9 @@ var OpenAIResponsesLanguageModel = class {
4749
5034
  "openai.web_search": "web_search",
4750
5035
  "openai.web_search_preview": "web_search_preview",
4751
5036
  "openai.mcp": "mcp",
4752
- "openai.apply_patch": "apply_patch"
4753
- },
4754
- resolveProviderToolName: (tool) => tool.id === "openai.custom" ? tool.args.name : void 0
5037
+ "openai.apply_patch": "apply_patch",
5038
+ "openai.tool_search": "tool_search"
5039
+ }
4755
5040
  });
4756
5041
  const customProviderToolNames = /* @__PURE__ */ new Set();
4757
5042
  const {
@@ -4767,10 +5052,10 @@ var OpenAIResponsesLanguageModel = class {
4767
5052
  const { input, warnings: inputWarnings } = await convertToOpenAIResponsesInput({
4768
5053
  prompt,
4769
5054
  toolNameMapping,
4770
- systemMessageMode: (_b = openaiOptions == null ? void 0 : openaiOptions.systemMessageMode) != null ? _b : isReasoningModel ? "developer" : modelCapabilities.systemMessageMode,
5055
+ systemMessageMode: (_c = openaiOptions == null ? void 0 : openaiOptions.systemMessageMode) != null ? _c : isReasoningModel ? "developer" : modelCapabilities.systemMessageMode,
4771
5056
  providerOptionsName,
4772
5057
  fileIdPrefixes: this.config.fileIdPrefixes,
4773
- store: (_c = openaiOptions == null ? void 0 : openaiOptions.store) != null ? _c : true,
5058
+ store: (_d = openaiOptions == null ? void 0 : openaiOptions.store) != null ? _d : true,
4774
5059
  hasConversation: (openaiOptions == null ? void 0 : openaiOptions.conversation) != null,
4775
5060
  hasLocalShellTool: hasOpenAITool("openai.local_shell"),
4776
5061
  hasShellTool: hasOpenAITool("openai.shell"),
@@ -4778,7 +5063,7 @@ var OpenAIResponsesLanguageModel = class {
4778
5063
  customProviderToolNames: customProviderToolNames.size > 0 ? customProviderToolNames : void 0
4779
5064
  });
4780
5065
  warnings.push(...inputWarnings);
4781
- const strictJsonSchema = (_d = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _d : true;
5066
+ const strictJsonSchema = (_e = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _e : true;
4782
5067
  let include = openaiOptions == null ? void 0 : openaiOptions.include;
4783
5068
  function addInclude(key) {
4784
5069
  if (include == null) {
@@ -4794,9 +5079,9 @@ var OpenAIResponsesLanguageModel = class {
4794
5079
  if (topLogprobs) {
4795
5080
  addInclude("message.output_text.logprobs");
4796
5081
  }
4797
- const webSearchToolName = (_e = tools == null ? void 0 : tools.find(
5082
+ const webSearchToolName = (_f = tools == null ? void 0 : tools.find(
4798
5083
  (tool) => tool.type === "provider" && (tool.id === "openai.web_search" || tool.id === "openai.web_search_preview")
4799
- )) == null ? void 0 : _e.name;
5084
+ )) == null ? void 0 : _f.name;
4800
5085
  if (webSearchToolName) {
4801
5086
  addInclude("web_search_call.action.sources");
4802
5087
  }
@@ -4819,7 +5104,7 @@ var OpenAIResponsesLanguageModel = class {
4819
5104
  format: responseFormat.schema != null ? {
4820
5105
  type: "json_schema",
4821
5106
  strict: strictJsonSchema,
4822
- name: (_f = responseFormat.name) != null ? _f : "response",
5107
+ name: (_g = responseFormat.name) != null ? _g : "response",
4823
5108
  description: responseFormat.description,
4824
5109
  schema: responseFormat.schema
4825
5110
  } : { type: "json_object" }
@@ -4845,11 +5130,18 @@ var OpenAIResponsesLanguageModel = class {
4845
5130
  safety_identifier: openaiOptions == null ? void 0 : openaiOptions.safetyIdentifier,
4846
5131
  top_logprobs: topLogprobs,
4847
5132
  truncation: openaiOptions == null ? void 0 : openaiOptions.truncation,
5133
+ // context management (server-side compaction):
5134
+ ...(openaiOptions == null ? void 0 : openaiOptions.contextManagement) && {
5135
+ context_management: openaiOptions.contextManagement.map((cm) => ({
5136
+ type: cm.type,
5137
+ compact_threshold: cm.compactThreshold
5138
+ }))
5139
+ },
4848
5140
  // model-specific settings:
4849
- ...isReasoningModel && ((openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null || (openaiOptions == null ? void 0 : openaiOptions.reasoningSummary) != null) && {
5141
+ ...isReasoningModel && (resolvedReasoningEffort != null || (openaiOptions == null ? void 0 : openaiOptions.reasoningSummary) != null) && {
4850
5142
  reasoning: {
4851
- ...(openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null && {
4852
- effort: openaiOptions.reasoningEffort
5143
+ ...resolvedReasoningEffort != null && {
5144
+ effort: resolvedReasoningEffort
4853
5145
  },
4854
5146
  ...(openaiOptions == null ? void 0 : openaiOptions.reasoningSummary) != null && {
4855
5147
  summary: openaiOptions.reasoningSummary
@@ -4858,7 +5150,7 @@ var OpenAIResponsesLanguageModel = class {
4858
5150
  }
4859
5151
  };
4860
5152
  if (isReasoningModel) {
4861
- if (!((openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) === "none" && modelCapabilities.supportsNonReasoningParameters)) {
5153
+ if (!(resolvedReasoningEffort === "none" && modelCapabilities.supportsNonReasoningParameters)) {
4862
5154
  if (baseArgs.temperature != null) {
4863
5155
  baseArgs.temperature = void 0;
4864
5156
  warnings.push({
@@ -4908,9 +5200,9 @@ var OpenAIResponsesLanguageModel = class {
4908
5200
  });
4909
5201
  delete baseArgs.service_tier;
4910
5202
  }
4911
- const shellToolEnvType = (_i = (_h = (_g = tools == null ? void 0 : tools.find(
5203
+ const shellToolEnvType = (_j = (_i = (_h = tools == null ? void 0 : tools.find(
4912
5204
  (tool) => tool.type === "provider" && tool.id === "openai.shell"
4913
- )) == null ? void 0 : _g.args) == null ? void 0 : _h.environment) == null ? void 0 : _i.type;
5205
+ )) == null ? void 0 : _h.args) == null ? void 0 : _i.environment) == null ? void 0 : _j.type;
4914
5206
  const isShellProviderExecuted = shellToolEnvType === "containerAuto" || shellToolEnvType === "containerReference";
4915
5207
  return {
4916
5208
  webSearchToolName,
@@ -4927,7 +5219,7 @@ var OpenAIResponsesLanguageModel = class {
4927
5219
  };
4928
5220
  }
4929
5221
  async doGenerate(options) {
4930
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
5222
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B;
4931
5223
  const {
4932
5224
  args: body,
4933
5225
  warnings,
@@ -4945,12 +5237,12 @@ var OpenAIResponsesLanguageModel = class {
4945
5237
  responseHeaders,
4946
5238
  value: response,
4947
5239
  rawValue: rawResponse
4948
- } = await (0, import_provider_utils33.postJsonToApi)({
5240
+ } = await (0, import_provider_utils34.postJsonToApi)({
4949
5241
  url,
4950
- headers: (0, import_provider_utils33.combineHeaders)(this.config.headers(), options.headers),
5242
+ headers: (0, import_provider_utils34.combineHeaders)(this.config.headers(), options.headers),
4951
5243
  body,
4952
5244
  failedResponseHandler: openaiFailedResponseHandler,
4953
- successfulResponseHandler: (0, import_provider_utils33.createJsonResponseHandler)(
5245
+ successfulResponseHandler: (0, import_provider_utils34.createJsonResponseHandler)(
4954
5246
  openaiResponsesResponseSchema
4955
5247
  ),
4956
5248
  abortSignal: options.abortSignal,
@@ -4970,6 +5262,7 @@ var OpenAIResponsesLanguageModel = class {
4970
5262
  const content = [];
4971
5263
  const logprobs = [];
4972
5264
  let hasFunctionCall = false;
5265
+ const hostedToolSearchCallIds = [];
4973
5266
  for (const part of response.output) {
4974
5267
  switch (part.type) {
4975
5268
  case "reasoning": {
@@ -5008,6 +5301,46 @@ var OpenAIResponsesLanguageModel = class {
5008
5301
  });
5009
5302
  break;
5010
5303
  }
5304
+ case "tool_search_call": {
5305
+ const toolCallId = (_b = part.call_id) != null ? _b : part.id;
5306
+ const isHosted = part.execution === "server";
5307
+ if (isHosted) {
5308
+ hostedToolSearchCallIds.push(toolCallId);
5309
+ }
5310
+ content.push({
5311
+ type: "tool-call",
5312
+ toolCallId,
5313
+ toolName: toolNameMapping.toCustomToolName("tool_search"),
5314
+ input: JSON.stringify({
5315
+ arguments: part.arguments,
5316
+ call_id: part.call_id
5317
+ }),
5318
+ ...isHosted ? { providerExecuted: true } : {},
5319
+ providerMetadata: {
5320
+ [providerOptionsName]: {
5321
+ itemId: part.id
5322
+ }
5323
+ }
5324
+ });
5325
+ break;
5326
+ }
5327
+ case "tool_search_output": {
5328
+ const toolCallId = (_d = (_c = part.call_id) != null ? _c : hostedToolSearchCallIds.shift()) != null ? _d : part.id;
5329
+ content.push({
5330
+ type: "tool-result",
5331
+ toolCallId,
5332
+ toolName: toolNameMapping.toCustomToolName("tool_search"),
5333
+ result: {
5334
+ tools: part.tools
5335
+ },
5336
+ providerMetadata: {
5337
+ [providerOptionsName]: {
5338
+ itemId: part.id
5339
+ }
5340
+ }
5341
+ });
5342
+ break;
5343
+ }
5011
5344
  case "local_shell_call": {
5012
5345
  content.push({
5013
5346
  type: "tool-call",
@@ -5063,7 +5396,7 @@ var OpenAIResponsesLanguageModel = class {
5063
5396
  }
5064
5397
  case "message": {
5065
5398
  for (const contentPart of part.content) {
5066
- if (((_c = (_b = options.providerOptions) == null ? void 0 : _b[providerOptionsName]) == null ? void 0 : _c.logprobs) && contentPart.logprobs) {
5399
+ if (((_f = (_e = options.providerOptions) == null ? void 0 : _e[providerOptionsName]) == null ? void 0 : _f.logprobs) && contentPart.logprobs) {
5067
5400
  logprobs.push(contentPart.logprobs);
5068
5401
  }
5069
5402
  const providerMetadata2 = {
@@ -5085,7 +5418,7 @@ var OpenAIResponsesLanguageModel = class {
5085
5418
  content.push({
5086
5419
  type: "source",
5087
5420
  sourceType: "url",
5088
- id: (_f = (_e = (_d = this.config).generateId) == null ? void 0 : _e.call(_d)) != null ? _f : (0, import_provider_utils33.generateId)(),
5421
+ id: (_i = (_h = (_g = this.config).generateId) == null ? void 0 : _h.call(_g)) != null ? _i : (0, import_provider_utils34.generateId)(),
5089
5422
  url: annotation.url,
5090
5423
  title: annotation.title
5091
5424
  });
@@ -5093,7 +5426,7 @@ var OpenAIResponsesLanguageModel = class {
5093
5426
  content.push({
5094
5427
  type: "source",
5095
5428
  sourceType: "document",
5096
- id: (_i = (_h = (_g = this.config).generateId) == null ? void 0 : _h.call(_g)) != null ? _i : (0, import_provider_utils33.generateId)(),
5429
+ id: (_l = (_k = (_j = this.config).generateId) == null ? void 0 : _k.call(_j)) != null ? _l : (0, import_provider_utils34.generateId)(),
5097
5430
  mediaType: "text/plain",
5098
5431
  title: annotation.filename,
5099
5432
  filename: annotation.filename,
@@ -5109,7 +5442,7 @@ var OpenAIResponsesLanguageModel = class {
5109
5442
  content.push({
5110
5443
  type: "source",
5111
5444
  sourceType: "document",
5112
- id: (_l = (_k = (_j = this.config).generateId) == null ? void 0 : _k.call(_j)) != null ? _l : (0, import_provider_utils33.generateId)(),
5445
+ id: (_o = (_n = (_m = this.config).generateId) == null ? void 0 : _n.call(_m)) != null ? _o : (0, import_provider_utils34.generateId)(),
5113
5446
  mediaType: "text/plain",
5114
5447
  title: annotation.filename,
5115
5448
  filename: annotation.filename,
@@ -5125,7 +5458,7 @@ var OpenAIResponsesLanguageModel = class {
5125
5458
  content.push({
5126
5459
  type: "source",
5127
5460
  sourceType: "document",
5128
- id: (_o = (_n = (_m = this.config).generateId) == null ? void 0 : _n.call(_m)) != null ? _o : (0, import_provider_utils33.generateId)(),
5461
+ id: (_r = (_q = (_p = this.config).generateId) == null ? void 0 : _q.call(_p)) != null ? _r : (0, import_provider_utils34.generateId)(),
5129
5462
  mediaType: "application/octet-stream",
5130
5463
  title: annotation.file_id,
5131
5464
  filename: annotation.file_id,
@@ -5194,7 +5527,7 @@ var OpenAIResponsesLanguageModel = class {
5194
5527
  break;
5195
5528
  }
5196
5529
  case "mcp_call": {
5197
- const toolCallId = part.approval_request_id != null ? (_p = approvalRequestIdToDummyToolCallIdFromPrompt[part.approval_request_id]) != null ? _p : part.id : part.id;
5530
+ const toolCallId = part.approval_request_id != null ? (_s = approvalRequestIdToDummyToolCallIdFromPrompt[part.approval_request_id]) != null ? _s : part.id : part.id;
5198
5531
  const toolName = `mcp.${part.name}`;
5199
5532
  content.push({
5200
5533
  type: "tool-call",
@@ -5228,8 +5561,8 @@ var OpenAIResponsesLanguageModel = class {
5228
5561
  break;
5229
5562
  }
5230
5563
  case "mcp_approval_request": {
5231
- const approvalRequestId = (_q = part.approval_request_id) != null ? _q : part.id;
5232
- const dummyToolCallId = (_t = (_s = (_r = this.config).generateId) == null ? void 0 : _s.call(_r)) != null ? _t : (0, import_provider_utils33.generateId)();
5564
+ const approvalRequestId = (_t = part.approval_request_id) != null ? _t : part.id;
5565
+ const dummyToolCallId = (_w = (_v = (_u = this.config).generateId) == null ? void 0 : _v.call(_u)) != null ? _w : (0, import_provider_utils34.generateId)();
5233
5566
  const toolName = `mcp.${part.name}`;
5234
5567
  content.push({
5235
5568
  type: "tool-call",
@@ -5279,13 +5612,13 @@ var OpenAIResponsesLanguageModel = class {
5279
5612
  toolName: toolNameMapping.toCustomToolName("file_search"),
5280
5613
  result: {
5281
5614
  queries: part.queries,
5282
- results: (_v = (_u = part.results) == null ? void 0 : _u.map((result) => ({
5615
+ results: (_y = (_x = part.results) == null ? void 0 : _x.map((result) => ({
5283
5616
  attributes: result.attributes,
5284
5617
  fileId: result.file_id,
5285
5618
  filename: result.filename,
5286
5619
  score: result.score,
5287
5620
  text: result.text
5288
- }))) != null ? _v : null
5621
+ }))) != null ? _y : null
5289
5622
  }
5290
5623
  });
5291
5624
  break;
@@ -5328,6 +5661,20 @@ var OpenAIResponsesLanguageModel = class {
5328
5661
  });
5329
5662
  break;
5330
5663
  }
5664
+ case "compaction": {
5665
+ content.push({
5666
+ type: "custom",
5667
+ kind: "openai.compaction",
5668
+ providerMetadata: {
5669
+ [providerOptionsName]: {
5670
+ type: "compaction",
5671
+ itemId: part.id,
5672
+ encryptedContent: part.encrypted_content
5673
+ }
5674
+ }
5675
+ });
5676
+ break;
5677
+ }
5331
5678
  }
5332
5679
  }
5333
5680
  const providerMetadata = {
@@ -5342,10 +5689,10 @@ var OpenAIResponsesLanguageModel = class {
5342
5689
  content,
5343
5690
  finishReason: {
5344
5691
  unified: mapOpenAIResponseFinishReason({
5345
- finishReason: (_w = response.incomplete_details) == null ? void 0 : _w.reason,
5692
+ finishReason: (_z = response.incomplete_details) == null ? void 0 : _z.reason,
5346
5693
  hasFunctionCall
5347
5694
  }),
5348
- raw: (_y = (_x = response.incomplete_details) == null ? void 0 : _x.reason) != null ? _y : void 0
5695
+ raw: (_B = (_A = response.incomplete_details) == null ? void 0 : _A.reason) != null ? _B : void 0
5349
5696
  },
5350
5697
  usage: convertOpenAIResponsesUsage(usage),
5351
5698
  request: { body },
@@ -5370,18 +5717,18 @@ var OpenAIResponsesLanguageModel = class {
5370
5717
  providerOptionsName,
5371
5718
  isShellProviderExecuted
5372
5719
  } = await this.getArgs(options);
5373
- const { responseHeaders, value: response } = await (0, import_provider_utils33.postJsonToApi)({
5720
+ const { responseHeaders, value: response } = await (0, import_provider_utils34.postJsonToApi)({
5374
5721
  url: this.config.url({
5375
5722
  path: "/responses",
5376
5723
  modelId: this.modelId
5377
5724
  }),
5378
- headers: (0, import_provider_utils33.combineHeaders)(this.config.headers(), options.headers),
5725
+ headers: (0, import_provider_utils34.combineHeaders)(this.config.headers(), options.headers),
5379
5726
  body: {
5380
5727
  ...body,
5381
5728
  stream: true
5382
5729
  },
5383
5730
  failedResponseHandler: openaiFailedResponseHandler,
5384
- successfulResponseHandler: (0, import_provider_utils33.createEventSourceResponseHandler)(
5731
+ successfulResponseHandler: (0, import_provider_utils34.createEventSourceResponseHandler)(
5385
5732
  openaiResponsesChunkSchema
5386
5733
  ),
5387
5734
  abortSignal: options.abortSignal,
@@ -5403,6 +5750,7 @@ var OpenAIResponsesLanguageModel = class {
5403
5750
  let hasFunctionCall = false;
5404
5751
  const activeReasoning = {};
5405
5752
  let serviceTier;
5753
+ const hostedToolSearchCallIds = [];
5406
5754
  return {
5407
5755
  stream: response.pipeThrough(
5408
5756
  new TransformStream({
@@ -5410,7 +5758,7 @@ var OpenAIResponsesLanguageModel = class {
5410
5758
  controller.enqueue({ type: "stream-start", warnings });
5411
5759
  },
5412
5760
  transform(chunk, controller) {
5413
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F;
5761
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L;
5414
5762
  if (options.includeRawChunks) {
5415
5763
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
5416
5764
  }
@@ -5518,6 +5866,24 @@ var OpenAIResponsesLanguageModel = class {
5518
5866
  input: "{}",
5519
5867
  providerExecuted: true
5520
5868
  });
5869
+ } else if (value.item.type === "tool_search_call") {
5870
+ const toolCallId = value.item.id;
5871
+ const toolName = toolNameMapping.toCustomToolName("tool_search");
5872
+ const isHosted = value.item.execution === "server";
5873
+ ongoingToolCalls[value.output_index] = {
5874
+ toolName,
5875
+ toolCallId,
5876
+ toolSearchExecution: (_a = value.item.execution) != null ? _a : "server"
5877
+ };
5878
+ if (isHosted) {
5879
+ controller.enqueue({
5880
+ type: "tool-input-start",
5881
+ id: toolCallId,
5882
+ toolName,
5883
+ providerExecuted: true
5884
+ });
5885
+ }
5886
+ } else if (value.item.type === "tool_search_output") {
5521
5887
  } else if (value.item.type === "mcp_call" || value.item.type === "mcp_list_tools" || value.item.type === "mcp_approval_request") {
5522
5888
  } else if (value.item.type === "apply_patch_call") {
5523
5889
  const { call_id: callId, operation } = value.item;
@@ -5564,7 +5930,7 @@ var OpenAIResponsesLanguageModel = class {
5564
5930
  } else if (value.item.type === "shell_call_output") {
5565
5931
  } else if (value.item.type === "message") {
5566
5932
  ongoingAnnotations.splice(0, ongoingAnnotations.length);
5567
- activeMessagePhase = (_a = value.item.phase) != null ? _a : void 0;
5933
+ activeMessagePhase = (_b = value.item.phase) != null ? _b : void 0;
5568
5934
  controller.enqueue({
5569
5935
  type: "text-start",
5570
5936
  id: value.item.id,
@@ -5588,14 +5954,14 @@ var OpenAIResponsesLanguageModel = class {
5588
5954
  providerMetadata: {
5589
5955
  [providerOptionsName]: {
5590
5956
  itemId: value.item.id,
5591
- reasoningEncryptedContent: (_b = value.item.encrypted_content) != null ? _b : null
5957
+ reasoningEncryptedContent: (_c = value.item.encrypted_content) != null ? _c : null
5592
5958
  }
5593
5959
  }
5594
5960
  });
5595
5961
  }
5596
5962
  } else if (isResponseOutputItemDoneChunk(value)) {
5597
5963
  if (value.item.type === "message") {
5598
- const phase = (_c = value.item.phase) != null ? _c : activeMessagePhase;
5964
+ const phase = (_d = value.item.phase) != null ? _d : activeMessagePhase;
5599
5965
  activeMessagePhase = void 0;
5600
5966
  controller.enqueue({
5601
5967
  type: "text-end",
@@ -5689,13 +6055,13 @@ var OpenAIResponsesLanguageModel = class {
5689
6055
  toolName: toolNameMapping.toCustomToolName("file_search"),
5690
6056
  result: {
5691
6057
  queries: value.item.queries,
5692
- results: (_e = (_d = value.item.results) == null ? void 0 : _d.map((result) => ({
6058
+ results: (_f = (_e = value.item.results) == null ? void 0 : _e.map((result) => ({
5693
6059
  attributes: result.attributes,
5694
6060
  fileId: result.file_id,
5695
6061
  filename: result.filename,
5696
6062
  score: result.score,
5697
6063
  text: result.text
5698
- }))) != null ? _e : null
6064
+ }))) != null ? _f : null
5699
6065
  }
5700
6066
  });
5701
6067
  } else if (value.item.type === "code_interpreter_call") {
@@ -5717,12 +6083,62 @@ var OpenAIResponsesLanguageModel = class {
5717
6083
  result: value.item.result
5718
6084
  }
5719
6085
  });
6086
+ } else if (value.item.type === "tool_search_call") {
6087
+ const toolCall = ongoingToolCalls[value.output_index];
6088
+ const isHosted = value.item.execution === "server";
6089
+ if (toolCall != null) {
6090
+ const toolCallId = isHosted ? toolCall.toolCallId : (_g = value.item.call_id) != null ? _g : value.item.id;
6091
+ if (isHosted) {
6092
+ hostedToolSearchCallIds.push(toolCallId);
6093
+ } else {
6094
+ controller.enqueue({
6095
+ type: "tool-input-start",
6096
+ id: toolCallId,
6097
+ toolName: toolCall.toolName
6098
+ });
6099
+ }
6100
+ controller.enqueue({
6101
+ type: "tool-input-end",
6102
+ id: toolCallId
6103
+ });
6104
+ controller.enqueue({
6105
+ type: "tool-call",
6106
+ toolCallId,
6107
+ toolName: toolCall.toolName,
6108
+ input: JSON.stringify({
6109
+ arguments: value.item.arguments,
6110
+ call_id: isHosted ? null : toolCallId
6111
+ }),
6112
+ ...isHosted ? { providerExecuted: true } : {},
6113
+ providerMetadata: {
6114
+ [providerOptionsName]: {
6115
+ itemId: value.item.id
6116
+ }
6117
+ }
6118
+ });
6119
+ }
6120
+ ongoingToolCalls[value.output_index] = void 0;
6121
+ } else if (value.item.type === "tool_search_output") {
6122
+ const toolCallId = (_i = (_h = value.item.call_id) != null ? _h : hostedToolSearchCallIds.shift()) != null ? _i : value.item.id;
6123
+ controller.enqueue({
6124
+ type: "tool-result",
6125
+ toolCallId,
6126
+ toolName: toolNameMapping.toCustomToolName("tool_search"),
6127
+ result: {
6128
+ tools: value.item.tools
6129
+ },
6130
+ providerMetadata: {
6131
+ [providerOptionsName]: {
6132
+ itemId: value.item.id
6133
+ }
6134
+ }
6135
+ });
5720
6136
  } else if (value.item.type === "mcp_call") {
5721
6137
  ongoingToolCalls[value.output_index] = void 0;
5722
- const approvalRequestId = (_f = value.item.approval_request_id) != null ? _f : void 0;
5723
- const aliasedToolCallId = approvalRequestId != null ? (_h = (_g = approvalRequestIdToDummyToolCallIdFromStream.get(
6138
+ const approvalRequestId = (_j = value.item.approval_request_id) != null ? _j : void 0;
6139
+ const aliasedToolCallId = approvalRequestId != null ? (_l = (_k = approvalRequestIdToDummyToolCallIdFromStream.get(
5724
6140
  approvalRequestId
5725
- )) != null ? _g : approvalRequestIdToDummyToolCallIdFromPrompt[approvalRequestId]) != null ? _h : value.item.id : value.item.id;
6141
+ )) != null ? _k : approvalRequestIdToDummyToolCallIdFromPrompt[approvalRequestId]) != null ? _l : value.item.id : value.item.id;
5726
6142
  const toolName = `mcp.${value.item.name}`;
5727
6143
  controller.enqueue({
5728
6144
  type: "tool-call",
@@ -5792,8 +6208,8 @@ var OpenAIResponsesLanguageModel = class {
5792
6208
  ongoingToolCalls[value.output_index] = void 0;
5793
6209
  } else if (value.item.type === "mcp_approval_request") {
5794
6210
  ongoingToolCalls[value.output_index] = void 0;
5795
- const dummyToolCallId = (_k = (_j = (_i = self.config).generateId) == null ? void 0 : _j.call(_i)) != null ? _k : (0, import_provider_utils33.generateId)();
5796
- const approvalRequestId = (_l = value.item.approval_request_id) != null ? _l : value.item.id;
6211
+ const dummyToolCallId = (_o = (_n = (_m = self.config).generateId) == null ? void 0 : _n.call(_m)) != null ? _o : (0, import_provider_utils34.generateId)();
6212
+ const approvalRequestId = (_p = value.item.approval_request_id) != null ? _p : value.item.id;
5797
6213
  approvalRequestIdToDummyToolCallIdFromStream.set(
5798
6214
  approvalRequestId,
5799
6215
  dummyToolCallId
@@ -5882,12 +6298,24 @@ var OpenAIResponsesLanguageModel = class {
5882
6298
  providerMetadata: {
5883
6299
  [providerOptionsName]: {
5884
6300
  itemId: value.item.id,
5885
- reasoningEncryptedContent: (_m = value.item.encrypted_content) != null ? _m : null
6301
+ reasoningEncryptedContent: (_q = value.item.encrypted_content) != null ? _q : null
5886
6302
  }
5887
6303
  }
5888
6304
  });
5889
6305
  }
5890
6306
  delete activeReasoning[value.item.id];
6307
+ } else if (value.item.type === "compaction") {
6308
+ controller.enqueue({
6309
+ type: "custom",
6310
+ kind: "openai.compaction",
6311
+ providerMetadata: {
6312
+ [providerOptionsName]: {
6313
+ type: "compaction",
6314
+ itemId: value.item.id,
6315
+ encryptedContent: value.item.encrypted_content
6316
+ }
6317
+ }
6318
+ });
5891
6319
  }
5892
6320
  } else if (isResponseFunctionCallArgumentsDeltaChunk(value)) {
5893
6321
  const toolCall = ongoingToolCalls[value.output_index];
@@ -5995,7 +6423,7 @@ var OpenAIResponsesLanguageModel = class {
5995
6423
  id: value.item_id,
5996
6424
  delta: value.delta
5997
6425
  });
5998
- if (((_o = (_n = options.providerOptions) == null ? void 0 : _n[providerOptionsName]) == null ? void 0 : _o.logprobs) && value.logprobs) {
6426
+ if (((_s = (_r = options.providerOptions) == null ? void 0 : _r[providerOptionsName]) == null ? void 0 : _s.logprobs) && value.logprobs) {
5999
6427
  logprobs.push(value.logprobs);
6000
6428
  }
6001
6429
  } else if (value.type === "response.reasoning_summary_part.added") {
@@ -6024,7 +6452,7 @@ var OpenAIResponsesLanguageModel = class {
6024
6452
  providerMetadata: {
6025
6453
  [providerOptionsName]: {
6026
6454
  itemId: value.item_id,
6027
- reasoningEncryptedContent: (_q = (_p = activeReasoning[value.item_id]) == null ? void 0 : _p.encryptedContent) != null ? _q : null
6455
+ reasoningEncryptedContent: (_u = (_t = activeReasoning[value.item_id]) == null ? void 0 : _t.encryptedContent) != null ? _u : null
6028
6456
  }
6029
6457
  }
6030
6458
  });
@@ -6058,22 +6486,32 @@ var OpenAIResponsesLanguageModel = class {
6058
6486
  } else if (isResponseFinishedChunk(value)) {
6059
6487
  finishReason = {
6060
6488
  unified: mapOpenAIResponseFinishReason({
6061
- finishReason: (_r = value.response.incomplete_details) == null ? void 0 : _r.reason,
6489
+ finishReason: (_v = value.response.incomplete_details) == null ? void 0 : _v.reason,
6062
6490
  hasFunctionCall
6063
6491
  }),
6064
- raw: (_t = (_s = value.response.incomplete_details) == null ? void 0 : _s.reason) != null ? _t : void 0
6492
+ raw: (_x = (_w = value.response.incomplete_details) == null ? void 0 : _w.reason) != null ? _x : void 0
6065
6493
  };
6066
6494
  usage = value.response.usage;
6067
6495
  if (typeof value.response.service_tier === "string") {
6068
6496
  serviceTier = value.response.service_tier;
6069
6497
  }
6498
+ } else if (isResponseFailedChunk(value)) {
6499
+ const incompleteReason = (_y = value.response.incomplete_details) == null ? void 0 : _y.reason;
6500
+ finishReason = {
6501
+ unified: incompleteReason ? mapOpenAIResponseFinishReason({
6502
+ finishReason: incompleteReason,
6503
+ hasFunctionCall
6504
+ }) : "error",
6505
+ raw: incompleteReason != null ? incompleteReason : "error"
6506
+ };
6507
+ usage = (_z = value.response.usage) != null ? _z : void 0;
6070
6508
  } else if (isResponseAnnotationAddedChunk(value)) {
6071
6509
  ongoingAnnotations.push(value.annotation);
6072
6510
  if (value.annotation.type === "url_citation") {
6073
6511
  controller.enqueue({
6074
6512
  type: "source",
6075
6513
  sourceType: "url",
6076
- id: (_w = (_v = (_u = self.config).generateId) == null ? void 0 : _v.call(_u)) != null ? _w : (0, import_provider_utils33.generateId)(),
6514
+ id: (_C = (_B = (_A = self.config).generateId) == null ? void 0 : _B.call(_A)) != null ? _C : (0, import_provider_utils34.generateId)(),
6077
6515
  url: value.annotation.url,
6078
6516
  title: value.annotation.title
6079
6517
  });
@@ -6081,7 +6519,7 @@ var OpenAIResponsesLanguageModel = class {
6081
6519
  controller.enqueue({
6082
6520
  type: "source",
6083
6521
  sourceType: "document",
6084
- id: (_z = (_y = (_x = self.config).generateId) == null ? void 0 : _y.call(_x)) != null ? _z : (0, import_provider_utils33.generateId)(),
6522
+ id: (_F = (_E = (_D = self.config).generateId) == null ? void 0 : _E.call(_D)) != null ? _F : (0, import_provider_utils34.generateId)(),
6085
6523
  mediaType: "text/plain",
6086
6524
  title: value.annotation.filename,
6087
6525
  filename: value.annotation.filename,
@@ -6097,7 +6535,7 @@ var OpenAIResponsesLanguageModel = class {
6097
6535
  controller.enqueue({
6098
6536
  type: "source",
6099
6537
  sourceType: "document",
6100
- id: (_C = (_B = (_A = self.config).generateId) == null ? void 0 : _B.call(_A)) != null ? _C : (0, import_provider_utils33.generateId)(),
6538
+ id: (_I = (_H = (_G = self.config).generateId) == null ? void 0 : _H.call(_G)) != null ? _I : (0, import_provider_utils34.generateId)(),
6101
6539
  mediaType: "text/plain",
6102
6540
  title: value.annotation.filename,
6103
6541
  filename: value.annotation.filename,
@@ -6113,7 +6551,7 @@ var OpenAIResponsesLanguageModel = class {
6113
6551
  controller.enqueue({
6114
6552
  type: "source",
6115
6553
  sourceType: "document",
6116
- id: (_F = (_E = (_D = self.config).generateId) == null ? void 0 : _E.call(_D)) != null ? _F : (0, import_provider_utils33.generateId)(),
6554
+ id: (_L = (_K = (_J = self.config).generateId) == null ? void 0 : _K.call(_J)) != null ? _L : (0, import_provider_utils34.generateId)(),
6117
6555
  mediaType: "application/octet-stream",
6118
6556
  title: value.annotation.file_id,
6119
6557
  filename: value.annotation.file_id,
@@ -6161,6 +6599,9 @@ function isResponseOutputItemDoneChunk(chunk) {
6161
6599
  function isResponseFinishedChunk(chunk) {
6162
6600
  return chunk.type === "response.completed" || chunk.type === "response.incomplete";
6163
6601
  }
6602
+ function isResponseFailedChunk(chunk) {
6603
+ return chunk.type === "response.failed";
6604
+ }
6164
6605
  function isResponseCreatedChunk(chunk) {
6165
6606
  return chunk.type === "response.created";
6166
6607
  }