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

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 (44) hide show
  1. package/CHANGELOG.md +225 -22
  2. package/README.md +2 -0
  3. package/dist/index.d.mts +124 -35
  4. package/dist/index.d.ts +124 -35
  5. package/dist/index.js +1319 -895
  6. package/dist/index.js.map +1 -1
  7. package/dist/index.mjs +1275 -844
  8. package/dist/index.mjs.map +1 -1
  9. package/dist/internal/index.d.mts +102 -36
  10. package/dist/internal/index.d.ts +102 -36
  11. package/dist/internal/index.js +1348 -934
  12. package/dist/internal/index.js.map +1 -1
  13. package/dist/internal/index.mjs +1332 -911
  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 +5 -5
  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/image/openai-image-model.ts +9 -9
  29. package/src/index.ts +1 -0
  30. package/src/openai-language-model-capabilities.ts +3 -2
  31. package/src/openai-provider.ts +21 -21
  32. package/src/openai-tools.ts +12 -1
  33. package/src/responses/convert-openai-responses-usage.ts +2 -2
  34. package/src/responses/convert-to-openai-responses-input.ts +159 -12
  35. package/src/responses/map-openai-responses-finish-reason.ts +2 -2
  36. package/src/responses/openai-responses-api.ts +136 -2
  37. package/src/responses/openai-responses-language-model.ts +233 -37
  38. package/src/responses/openai-responses-options.ts +24 -2
  39. package/src/responses/openai-responses-prepare-tools.ts +34 -9
  40. package/src/responses/openai-responses-provider-metadata.ts +10 -0
  41. package/src/speech/openai-speech-model.ts +7 -7
  42. package/src/tool/custom.ts +0 -6
  43. package/src/tool/tool-search.ts +98 -0
  44. package/src/transcription/openai-transcription-model.ts +8 -8
@@ -7,6 +7,7 @@ import {
7
7
  createEventSourceResponseHandler,
8
8
  createJsonResponseHandler,
9
9
  generateId,
10
+ isCustomReasoning,
10
11
  isParsableJson,
11
12
  parseProviderOptions,
12
13
  postJsonToApi
@@ -34,9 +35,9 @@ var openaiFailedResponseHandler = createJsonErrorResponseHandler({
34
35
  // src/openai-language-model-capabilities.ts
35
36
  function getOpenAILanguageModelCapabilities(modelId) {
36
37
  const supportsFlexProcessing = modelId.startsWith("o3") || modelId.startsWith("o4-mini") || modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-chat");
37
- 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");
38
+ 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");
38
39
  const isReasoningModel = modelId.startsWith("o1") || modelId.startsWith("o3") || modelId.startsWith("o4-mini") || modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-chat");
39
- const supportsNonReasoningParameters = modelId.startsWith("gpt-5.1") || modelId.startsWith("gpt-5.2") || modelId.startsWith("gpt-5.4");
40
+ const supportsNonReasoningParameters = modelId.startsWith("gpt-5.1") || modelId.startsWith("gpt-5.2") || modelId.startsWith("gpt-5.3") || modelId.startsWith("gpt-5.4");
40
41
  const systemMessageMode = isReasoningModel ? "developer" : "system";
41
42
  return {
42
43
  supportsFlexProcessing,
@@ -631,7 +632,7 @@ function prepareChatTools({
631
632
  // src/chat/openai-chat-language-model.ts
632
633
  var OpenAIChatLanguageModel = class {
633
634
  constructor(modelId, config) {
634
- this.specificationVersion = "v3";
635
+ this.specificationVersion = "v4";
635
636
  this.supportedUrls = {
636
637
  "image/*": [/^https?:\/\/.*$/]
637
638
  };
@@ -654,9 +655,10 @@ var OpenAIChatLanguageModel = class {
654
655
  seed,
655
656
  tools,
656
657
  toolChoice,
658
+ reasoning,
657
659
  providerOptions
658
660
  }) {
659
- var _a, _b, _c, _d, _e;
661
+ var _a, _b, _c, _d, _e, _f;
660
662
  const warnings = [];
661
663
  const openaiOptions = (_a = await parseProviderOptions({
662
664
  provider: "openai",
@@ -664,18 +666,19 @@ var OpenAIChatLanguageModel = class {
664
666
  schema: openaiLanguageModelChatOptions
665
667
  })) != null ? _a : {};
666
668
  const modelCapabilities = getOpenAILanguageModelCapabilities(this.modelId);
667
- const isReasoningModel = (_b = openaiOptions.forceReasoning) != null ? _b : modelCapabilities.isReasoningModel;
669
+ const resolvedReasoningEffort = (_b = openaiOptions.reasoningEffort) != null ? _b : isCustomReasoning(reasoning) ? reasoning : void 0;
670
+ const isReasoningModel = (_c = openaiOptions.forceReasoning) != null ? _c : modelCapabilities.isReasoningModel;
668
671
  if (topK != null) {
669
672
  warnings.push({ type: "unsupported", feature: "topK" });
670
673
  }
671
674
  const { messages, warnings: messageWarnings } = convertToOpenAIChatMessages(
672
675
  {
673
676
  prompt,
674
- systemMessageMode: (_c = openaiOptions.systemMessageMode) != null ? _c : isReasoningModel ? "developer" : modelCapabilities.systemMessageMode
677
+ systemMessageMode: (_d = openaiOptions.systemMessageMode) != null ? _d : isReasoningModel ? "developer" : modelCapabilities.systemMessageMode
675
678
  }
676
679
  );
677
680
  warnings.push(...messageWarnings);
678
- const strictJsonSchema = (_d = openaiOptions.strictJsonSchema) != null ? _d : true;
681
+ const strictJsonSchema = (_e = openaiOptions.strictJsonSchema) != null ? _e : true;
679
682
  const baseArgs = {
680
683
  // model id:
681
684
  model: this.modelId,
@@ -696,7 +699,7 @@ var OpenAIChatLanguageModel = class {
696
699
  json_schema: {
697
700
  schema: responseFormat.schema,
698
701
  strict: strictJsonSchema,
699
- name: (_e = responseFormat.name) != null ? _e : "response",
702
+ name: (_f = responseFormat.name) != null ? _f : "response",
700
703
  description: responseFormat.description
701
704
  }
702
705
  } : { type: "json_object" } : void 0,
@@ -709,7 +712,7 @@ var OpenAIChatLanguageModel = class {
709
712
  store: openaiOptions.store,
710
713
  metadata: openaiOptions.metadata,
711
714
  prediction: openaiOptions.prediction,
712
- reasoning_effort: openaiOptions.reasoningEffort,
715
+ reasoning_effort: resolvedReasoningEffort,
713
716
  service_tier: openaiOptions.serviceTier,
714
717
  prompt_cache_key: openaiOptions.promptCacheKey,
715
718
  prompt_cache_retention: openaiOptions.promptCacheRetention,
@@ -718,7 +721,7 @@ var OpenAIChatLanguageModel = class {
718
721
  messages
719
722
  };
720
723
  if (isReasoningModel) {
721
- if (openaiOptions.reasoningEffort !== "none" || !modelCapabilities.supportsNonReasoningParameters) {
724
+ if (resolvedReasoningEffort !== "none" || !modelCapabilities.supportsNonReasoningParameters) {
722
725
  if (baseArgs.temperature != null) {
723
726
  baseArgs.temperature = void 0;
724
727
  warnings.push({
@@ -1375,7 +1378,7 @@ var openaiLanguageModelCompletionOptions = lazySchema4(
1375
1378
  // src/completion/openai-completion-language-model.ts
1376
1379
  var OpenAICompletionLanguageModel = class {
1377
1380
  constructor(modelId, config) {
1378
- this.specificationVersion = "v3";
1381
+ this.specificationVersion = "v4";
1379
1382
  this.supportedUrls = {
1380
1383
  // No URLs are supported for completion models.
1381
1384
  };
@@ -1647,7 +1650,7 @@ var openaiTextEmbeddingResponseSchema = lazySchema6(
1647
1650
  // src/embedding/openai-embedding-model.ts
1648
1651
  var OpenAIEmbeddingModel = class {
1649
1652
  constructor(modelId, config) {
1650
- this.specificationVersion = "v3";
1653
+ this.specificationVersion = "v4";
1651
1654
  this.maxEmbeddingsPerCall = 2048;
1652
1655
  this.supportsParallelCalls = true;
1653
1656
  this.modelId = modelId;
@@ -1776,7 +1779,7 @@ var OpenAIImageModel = class {
1776
1779
  constructor(modelId, config) {
1777
1780
  this.modelId = modelId;
1778
1781
  this.config = config;
1779
- this.specificationVersion = "v3";
1782
+ this.specificationVersion = "v4";
1780
1783
  }
1781
1784
  get maxImagesPerCall() {
1782
1785
  var _a;
@@ -2104,7 +2107,7 @@ var OpenAITranscriptionModel = class {
2104
2107
  constructor(modelId, config) {
2105
2108
  this.modelId = modelId;
2106
2109
  this.config = config;
2107
- this.specificationVersion = "v3";
2110
+ this.specificationVersion = "v4";
2108
2111
  }
2109
2112
  get provider() {
2110
2113
  return this.config.provider;
@@ -2232,7 +2235,7 @@ var OpenAISpeechModel = class {
2232
2235
  constructor(modelId, config) {
2233
2236
  this.modelId = modelId;
2234
2237
  this.config = config;
2235
- this.specificationVersion = "v3";
2238
+ this.specificationVersion = "v4";
2236
2239
  }
2237
2240
  get provider() {
2238
2241
  return this.config.provider;
@@ -2338,6 +2341,7 @@ import {
2338
2341
  createJsonResponseHandler as createJsonResponseHandler6,
2339
2342
  createToolNameMapping,
2340
2343
  generateId as generateId2,
2344
+ isCustomReasoning as isCustomReasoning2,
2341
2345
  parseProviderOptions as parseProviderOptions7,
2342
2346
  postJsonToApi as postJsonToApi6
2343
2347
  } from "@ai-sdk/provider-utils";
@@ -2388,10 +2392,11 @@ import {
2388
2392
  import {
2389
2393
  convertToBase64 as convertToBase642,
2390
2394
  isNonNullable,
2395
+ parseJSON,
2391
2396
  parseProviderOptions as parseProviderOptions6,
2392
2397
  validateTypes
2393
2398
  } from "@ai-sdk/provider-utils";
2394
- import { z as z15 } from "zod/v4";
2399
+ import { z as z16 } from "zod/v4";
2395
2400
 
2396
2401
  // src/tool/apply-patch.ts
2397
2402
  import {
@@ -2570,6 +2575,43 @@ var shell = createProviderToolFactoryWithOutputSchema3({
2570
2575
  outputSchema: shellOutputSchema
2571
2576
  });
2572
2577
 
2578
+ // src/tool/tool-search.ts
2579
+ import {
2580
+ createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema4,
2581
+ lazySchema as lazySchema14,
2582
+ zodSchema as zodSchema14
2583
+ } from "@ai-sdk/provider-utils";
2584
+ import { z as z15 } from "zod/v4";
2585
+ var toolSearchArgsSchema = lazySchema14(
2586
+ () => zodSchema14(
2587
+ z15.object({
2588
+ execution: z15.enum(["server", "client"]).optional(),
2589
+ description: z15.string().optional(),
2590
+ parameters: z15.record(z15.string(), z15.unknown()).optional()
2591
+ })
2592
+ )
2593
+ );
2594
+ var toolSearchInputSchema = lazySchema14(
2595
+ () => zodSchema14(
2596
+ z15.object({
2597
+ arguments: z15.unknown().optional(),
2598
+ call_id: z15.string().nullish()
2599
+ })
2600
+ )
2601
+ );
2602
+ var toolSearchOutputSchema = lazySchema14(
2603
+ () => zodSchema14(
2604
+ z15.object({
2605
+ tools: z15.array(z15.record(z15.string(), z15.unknown()))
2606
+ })
2607
+ )
2608
+ );
2609
+ var toolSearchToolFactory = createProviderToolFactoryWithOutputSchema4({
2610
+ id: "openai.tool_search",
2611
+ inputSchema: toolSearchInputSchema,
2612
+ outputSchema: toolSearchOutputSchema
2613
+ });
2614
+
2573
2615
  // src/responses/convert-to-openai-responses-input.ts
2574
2616
  function isFileId(data, prefixes) {
2575
2617
  if (!prefixes) return false;
@@ -2588,8 +2630,8 @@ async function convertToOpenAIResponsesInput({
2588
2630
  hasApplyPatchTool = false,
2589
2631
  customProviderToolNames
2590
2632
  }) {
2591
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
2592
- const input = [];
2633
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
2634
+ let input = [];
2593
2635
  const warnings = [];
2594
2636
  const processedApprovalIds = /* @__PURE__ */ new Set();
2595
2637
  for (const { role, content } of prompt) {
@@ -2692,6 +2734,32 @@ async function convertToOpenAIResponsesInput({
2692
2734
  if (hasConversation && id != null) {
2693
2735
  break;
2694
2736
  }
2737
+ const resolvedToolName = toolNameMapping.toProviderToolName(
2738
+ part.toolName
2739
+ );
2740
+ if (resolvedToolName === "tool_search") {
2741
+ if (store && id != null) {
2742
+ input.push({ type: "item_reference", id });
2743
+ break;
2744
+ }
2745
+ const parsedInput = typeof part.input === "string" ? await parseJSON({
2746
+ text: part.input,
2747
+ schema: toolSearchInputSchema
2748
+ }) : await validateTypes({
2749
+ value: part.input,
2750
+ schema: toolSearchInputSchema
2751
+ });
2752
+ const execution = parsedInput.call_id != null ? "client" : "server";
2753
+ input.push({
2754
+ type: "tool_search_call",
2755
+ id: id != null ? id : part.toolCallId,
2756
+ execution,
2757
+ call_id: (_g = parsedInput.call_id) != null ? _g : null,
2758
+ status: "completed",
2759
+ arguments: parsedInput.arguments
2760
+ });
2761
+ break;
2762
+ }
2695
2763
  if (part.providerExecuted) {
2696
2764
  if (store && id != null) {
2697
2765
  input.push({ type: "item_reference", id });
@@ -2702,9 +2770,6 @@ async function convertToOpenAIResponsesInput({
2702
2770
  input.push({ type: "item_reference", id });
2703
2771
  break;
2704
2772
  }
2705
- const resolvedToolName = toolNameMapping.toProviderToolName(
2706
- part.toolName
2707
- );
2708
2773
  if (hasLocalShellTool && resolvedToolName === "local_shell") {
2709
2774
  const parsedInput = await validateTypes({
2710
2775
  value: part.input,
@@ -2787,6 +2852,26 @@ async function convertToOpenAIResponsesInput({
2787
2852
  const resolvedResultToolName = toolNameMapping.toProviderToolName(
2788
2853
  part.toolName
2789
2854
  );
2855
+ if (resolvedResultToolName === "tool_search") {
2856
+ const itemId = (_j = (_i = (_h = part.providerOptions) == null ? void 0 : _h[providerOptionsName]) == null ? void 0 : _i.itemId) != null ? _j : part.toolCallId;
2857
+ if (store) {
2858
+ input.push({ type: "item_reference", id: itemId });
2859
+ } else if (part.output.type === "json") {
2860
+ const parsedOutput = await validateTypes({
2861
+ value: part.output.value,
2862
+ schema: toolSearchOutputSchema
2863
+ });
2864
+ input.push({
2865
+ type: "tool_search_output",
2866
+ id: itemId,
2867
+ execution: "server",
2868
+ call_id: null,
2869
+ status: "completed",
2870
+ tools: parsedOutput.tools
2871
+ });
2872
+ }
2873
+ break;
2874
+ }
2790
2875
  if (hasShellTool && resolvedResultToolName === "shell") {
2791
2876
  if (part.output.type === "json") {
2792
2877
  const parsedOutput = await validateTypes({
@@ -2809,7 +2894,7 @@ async function convertToOpenAIResponsesInput({
2809
2894
  break;
2810
2895
  }
2811
2896
  if (store) {
2812
- const itemId = (_i = (_h = (_g = part.providerOptions) == null ? void 0 : _g[providerOptionsName]) == null ? void 0 : _h.itemId) != null ? _i : part.toolCallId;
2897
+ const itemId = (_m = (_l = (_k = part.providerOptions) == null ? void 0 : _k[providerOptionsName]) == null ? void 0 : _l.itemId) != null ? _m : part.toolCallId;
2813
2898
  input.push({ type: "item_reference", id: itemId });
2814
2899
  } else {
2815
2900
  warnings.push({
@@ -2892,6 +2977,28 @@ async function convertToOpenAIResponsesInput({
2892
2977
  }
2893
2978
  break;
2894
2979
  }
2980
+ case "custom": {
2981
+ if (part.kind === "openai.compaction") {
2982
+ const providerOpts = (_n = part.providerOptions) == null ? void 0 : _n[providerOptionsName];
2983
+ const id = providerOpts == null ? void 0 : providerOpts.itemId;
2984
+ if (hasConversation && id != null) {
2985
+ break;
2986
+ }
2987
+ if (store && id != null) {
2988
+ input.push({ type: "item_reference", id });
2989
+ break;
2990
+ }
2991
+ const encryptedContent = providerOpts == null ? void 0 : providerOpts.encryptedContent;
2992
+ if (id != null) {
2993
+ input.push({
2994
+ type: "compaction",
2995
+ id,
2996
+ encrypted_content: encryptedContent
2997
+ });
2998
+ }
2999
+ }
3000
+ break;
3001
+ }
2895
3002
  }
2896
3003
  }
2897
3004
  break;
@@ -2919,7 +3026,7 @@ async function convertToOpenAIResponsesInput({
2919
3026
  }
2920
3027
  const output = part.output;
2921
3028
  if (output.type === "execution-denied") {
2922
- const approvalId = (_k = (_j = output.providerOptions) == null ? void 0 : _j.openai) == null ? void 0 : _k.approvalId;
3029
+ const approvalId = (_p = (_o = output.providerOptions) == null ? void 0 : _o.openai) == null ? void 0 : _p.approvalId;
2923
3030
  if (approvalId) {
2924
3031
  continue;
2925
3032
  }
@@ -2927,6 +3034,20 @@ async function convertToOpenAIResponsesInput({
2927
3034
  const resolvedToolName = toolNameMapping.toProviderToolName(
2928
3035
  part.toolName
2929
3036
  );
3037
+ if (resolvedToolName === "tool_search" && output.type === "json") {
3038
+ const parsedOutput = await validateTypes({
3039
+ value: output.value,
3040
+ schema: toolSearchOutputSchema
3041
+ });
3042
+ input.push({
3043
+ type: "tool_search_output",
3044
+ execution: "client",
3045
+ call_id: part.toolCallId,
3046
+ status: "completed",
3047
+ tools: parsedOutput.tools
3048
+ });
3049
+ continue;
3050
+ }
2930
3051
  if (hasLocalShellTool && resolvedToolName === "local_shell" && output.type === "json") {
2931
3052
  const parsedOutput = await validateTypes({
2932
3053
  value: output.value,
@@ -2979,7 +3100,7 @@ async function convertToOpenAIResponsesInput({
2979
3100
  outputValue = output.value;
2980
3101
  break;
2981
3102
  case "execution-denied":
2982
- outputValue = (_l = output.reason) != null ? _l : "Tool execution denied.";
3103
+ outputValue = (_q = output.reason) != null ? _q : "Tool execution denied.";
2983
3104
  break;
2984
3105
  case "json":
2985
3106
  case "error-json":
@@ -3007,6 +3128,11 @@ async function convertToOpenAIResponsesInput({
3007
3128
  filename: (_a2 = item.filename) != null ? _a2 : "data",
3008
3129
  file_data: `data:${item.mediaType};base64,${item.data}`
3009
3130
  };
3131
+ case "file-url":
3132
+ return {
3133
+ type: "input_file",
3134
+ file_url: item.url
3135
+ };
3010
3136
  default:
3011
3137
  warnings.push({
3012
3138
  type: "other",
@@ -3033,7 +3159,7 @@ async function convertToOpenAIResponsesInput({
3033
3159
  contentValue = output.value;
3034
3160
  break;
3035
3161
  case "execution-denied":
3036
- contentValue = (_m = output.reason) != null ? _m : "Tool execution denied.";
3162
+ contentValue = (_r = output.reason) != null ? _r : "Tool execution denied.";
3037
3163
  break;
3038
3164
  case "json":
3039
3165
  case "error-json":
@@ -3065,6 +3191,12 @@ async function convertToOpenAIResponsesInput({
3065
3191
  file_data: `data:${item.mediaType};base64,${item.data}`
3066
3192
  };
3067
3193
  }
3194
+ case "file-url": {
3195
+ return {
3196
+ type: "input_file",
3197
+ file_url: item.url
3198
+ };
3199
+ }
3068
3200
  default: {
3069
3201
  warnings.push({
3070
3202
  type: "other",
@@ -3090,11 +3222,22 @@ async function convertToOpenAIResponsesInput({
3090
3222
  }
3091
3223
  }
3092
3224
  }
3225
+ if (!store && input.some(
3226
+ (item) => "type" in item && item.type === "reasoning" && item.encrypted_content == null
3227
+ )) {
3228
+ warnings.push({
3229
+ type: "other",
3230
+ message: "Reasoning parts without encrypted content are not supported when store is false. Skipping reasoning parts."
3231
+ });
3232
+ input = input.filter(
3233
+ (item) => !("type" in item) || item.type !== "reasoning" || item.encrypted_content != null
3234
+ );
3235
+ }
3093
3236
  return { input, warnings };
3094
3237
  }
3095
- var openaiResponsesReasoningProviderOptionsSchema = z15.object({
3096
- itemId: z15.string().nullish(),
3097
- reasoningEncryptedContent: z15.string().nullish()
3238
+ var openaiResponsesReasoningProviderOptionsSchema = z16.object({
3239
+ itemId: z16.string().nullish(),
3240
+ reasoningEncryptedContent: z16.string().nullish()
3098
3241
  });
3099
3242
 
3100
3243
  // src/responses/map-openai-responses-finish-reason.ts
@@ -3116,483 +3259,552 @@ function mapOpenAIResponseFinishReason({
3116
3259
  }
3117
3260
 
3118
3261
  // src/responses/openai-responses-api.ts
3119
- import { lazySchema as lazySchema14, zodSchema as zodSchema14 } from "@ai-sdk/provider-utils";
3120
- import { z as z16 } from "zod/v4";
3121
- var openaiResponsesChunkSchema = lazySchema14(
3122
- () => zodSchema14(
3123
- z16.union([
3124
- z16.object({
3125
- type: z16.literal("response.output_text.delta"),
3126
- item_id: z16.string(),
3127
- delta: z16.string(),
3128
- logprobs: z16.array(
3129
- z16.object({
3130
- token: z16.string(),
3131
- logprob: z16.number(),
3132
- top_logprobs: z16.array(
3133
- z16.object({
3134
- token: z16.string(),
3135
- logprob: z16.number()
3262
+ import { lazySchema as lazySchema15, zodSchema as zodSchema15 } from "@ai-sdk/provider-utils";
3263
+ import { z as z17 } from "zod/v4";
3264
+ var jsonValueSchema = z17.lazy(
3265
+ () => z17.union([
3266
+ z17.string(),
3267
+ z17.number(),
3268
+ z17.boolean(),
3269
+ z17.null(),
3270
+ z17.array(jsonValueSchema),
3271
+ z17.record(z17.string(), jsonValueSchema.optional())
3272
+ ])
3273
+ );
3274
+ var openaiResponsesChunkSchema = lazySchema15(
3275
+ () => zodSchema15(
3276
+ z17.union([
3277
+ z17.object({
3278
+ type: z17.literal("response.output_text.delta"),
3279
+ item_id: z17.string(),
3280
+ delta: z17.string(),
3281
+ logprobs: z17.array(
3282
+ z17.object({
3283
+ token: z17.string(),
3284
+ logprob: z17.number(),
3285
+ top_logprobs: z17.array(
3286
+ z17.object({
3287
+ token: z17.string(),
3288
+ logprob: z17.number()
3136
3289
  })
3137
3290
  )
3138
3291
  })
3139
3292
  ).nullish()
3140
3293
  }),
3141
- z16.object({
3142
- type: z16.enum(["response.completed", "response.incomplete"]),
3143
- response: z16.object({
3144
- incomplete_details: z16.object({ reason: z16.string() }).nullish(),
3145
- usage: z16.object({
3146
- input_tokens: z16.number(),
3147
- input_tokens_details: z16.object({ cached_tokens: z16.number().nullish() }).nullish(),
3148
- output_tokens: z16.number(),
3149
- output_tokens_details: z16.object({ reasoning_tokens: z16.number().nullish() }).nullish()
3294
+ z17.object({
3295
+ type: z17.enum(["response.completed", "response.incomplete"]),
3296
+ response: z17.object({
3297
+ incomplete_details: z17.object({ reason: z17.string() }).nullish(),
3298
+ usage: z17.object({
3299
+ input_tokens: z17.number(),
3300
+ input_tokens_details: z17.object({ cached_tokens: z17.number().nullish() }).nullish(),
3301
+ output_tokens: z17.number(),
3302
+ output_tokens_details: z17.object({ reasoning_tokens: z17.number().nullish() }).nullish()
3150
3303
  }),
3151
- service_tier: z16.string().nullish()
3304
+ service_tier: z17.string().nullish()
3305
+ })
3306
+ }),
3307
+ z17.object({
3308
+ type: z17.literal("response.failed"),
3309
+ response: z17.object({
3310
+ error: z17.object({
3311
+ code: z17.string().nullish(),
3312
+ message: z17.string()
3313
+ }).nullish(),
3314
+ incomplete_details: z17.object({ reason: z17.string() }).nullish(),
3315
+ usage: z17.object({
3316
+ input_tokens: z17.number(),
3317
+ input_tokens_details: z17.object({ cached_tokens: z17.number().nullish() }).nullish(),
3318
+ output_tokens: z17.number(),
3319
+ output_tokens_details: z17.object({ reasoning_tokens: z17.number().nullish() }).nullish()
3320
+ }).nullish(),
3321
+ service_tier: z17.string().nullish()
3152
3322
  })
3153
3323
  }),
3154
- z16.object({
3155
- type: z16.literal("response.created"),
3156
- response: z16.object({
3157
- id: z16.string(),
3158
- created_at: z16.number(),
3159
- model: z16.string(),
3160
- service_tier: z16.string().nullish()
3324
+ z17.object({
3325
+ type: z17.literal("response.created"),
3326
+ response: z17.object({
3327
+ id: z17.string(),
3328
+ created_at: z17.number(),
3329
+ model: z17.string(),
3330
+ service_tier: z17.string().nullish()
3161
3331
  })
3162
3332
  }),
3163
- z16.object({
3164
- type: z16.literal("response.output_item.added"),
3165
- output_index: z16.number(),
3166
- item: z16.discriminatedUnion("type", [
3167
- z16.object({
3168
- type: z16.literal("message"),
3169
- id: z16.string(),
3170
- phase: z16.enum(["commentary", "final_answer"]).nullish()
3333
+ z17.object({
3334
+ type: z17.literal("response.output_item.added"),
3335
+ output_index: z17.number(),
3336
+ item: z17.discriminatedUnion("type", [
3337
+ z17.object({
3338
+ type: z17.literal("message"),
3339
+ id: z17.string(),
3340
+ phase: z17.enum(["commentary", "final_answer"]).nullish()
3171
3341
  }),
3172
- z16.object({
3173
- type: z16.literal("reasoning"),
3174
- id: z16.string(),
3175
- encrypted_content: z16.string().nullish()
3342
+ z17.object({
3343
+ type: z17.literal("reasoning"),
3344
+ id: z17.string(),
3345
+ encrypted_content: z17.string().nullish()
3176
3346
  }),
3177
- z16.object({
3178
- type: z16.literal("function_call"),
3179
- id: z16.string(),
3180
- call_id: z16.string(),
3181
- name: z16.string(),
3182
- arguments: z16.string()
3347
+ z17.object({
3348
+ type: z17.literal("function_call"),
3349
+ id: z17.string(),
3350
+ call_id: z17.string(),
3351
+ name: z17.string(),
3352
+ arguments: z17.string()
3183
3353
  }),
3184
- z16.object({
3185
- type: z16.literal("web_search_call"),
3186
- id: z16.string(),
3187
- status: z16.string()
3354
+ z17.object({
3355
+ type: z17.literal("web_search_call"),
3356
+ id: z17.string(),
3357
+ status: z17.string()
3188
3358
  }),
3189
- z16.object({
3190
- type: z16.literal("computer_call"),
3191
- id: z16.string(),
3192
- status: z16.string()
3359
+ z17.object({
3360
+ type: z17.literal("computer_call"),
3361
+ id: z17.string(),
3362
+ status: z17.string()
3193
3363
  }),
3194
- z16.object({
3195
- type: z16.literal("file_search_call"),
3196
- id: z16.string()
3364
+ z17.object({
3365
+ type: z17.literal("file_search_call"),
3366
+ id: z17.string()
3197
3367
  }),
3198
- z16.object({
3199
- type: z16.literal("image_generation_call"),
3200
- id: z16.string()
3368
+ z17.object({
3369
+ type: z17.literal("image_generation_call"),
3370
+ id: z17.string()
3201
3371
  }),
3202
- z16.object({
3203
- type: z16.literal("code_interpreter_call"),
3204
- id: z16.string(),
3205
- container_id: z16.string(),
3206
- code: z16.string().nullable(),
3207
- outputs: z16.array(
3208
- z16.discriminatedUnion("type", [
3209
- z16.object({ type: z16.literal("logs"), logs: z16.string() }),
3210
- z16.object({ type: z16.literal("image"), url: z16.string() })
3372
+ z17.object({
3373
+ type: z17.literal("code_interpreter_call"),
3374
+ id: z17.string(),
3375
+ container_id: z17.string(),
3376
+ code: z17.string().nullable(),
3377
+ outputs: z17.array(
3378
+ z17.discriminatedUnion("type", [
3379
+ z17.object({ type: z17.literal("logs"), logs: z17.string() }),
3380
+ z17.object({ type: z17.literal("image"), url: z17.string() })
3211
3381
  ])
3212
3382
  ).nullable(),
3213
- status: z16.string()
3383
+ status: z17.string()
3214
3384
  }),
3215
- z16.object({
3216
- type: z16.literal("mcp_call"),
3217
- id: z16.string(),
3218
- status: z16.string(),
3219
- approval_request_id: z16.string().nullish()
3385
+ z17.object({
3386
+ type: z17.literal("mcp_call"),
3387
+ id: z17.string(),
3388
+ status: z17.string(),
3389
+ approval_request_id: z17.string().nullish()
3220
3390
  }),
3221
- z16.object({
3222
- type: z16.literal("mcp_list_tools"),
3223
- id: z16.string()
3391
+ z17.object({
3392
+ type: z17.literal("mcp_list_tools"),
3393
+ id: z17.string()
3224
3394
  }),
3225
- z16.object({
3226
- type: z16.literal("mcp_approval_request"),
3227
- id: z16.string()
3395
+ z17.object({
3396
+ type: z17.literal("mcp_approval_request"),
3397
+ id: z17.string()
3228
3398
  }),
3229
- z16.object({
3230
- type: z16.literal("apply_patch_call"),
3231
- id: z16.string(),
3232
- call_id: z16.string(),
3233
- status: z16.enum(["in_progress", "completed"]),
3234
- operation: z16.discriminatedUnion("type", [
3235
- z16.object({
3236
- type: z16.literal("create_file"),
3237
- path: z16.string(),
3238
- diff: z16.string()
3399
+ z17.object({
3400
+ type: z17.literal("apply_patch_call"),
3401
+ id: z17.string(),
3402
+ call_id: z17.string(),
3403
+ status: z17.enum(["in_progress", "completed"]),
3404
+ operation: z17.discriminatedUnion("type", [
3405
+ z17.object({
3406
+ type: z17.literal("create_file"),
3407
+ path: z17.string(),
3408
+ diff: z17.string()
3239
3409
  }),
3240
- z16.object({
3241
- type: z16.literal("delete_file"),
3242
- path: z16.string()
3410
+ z17.object({
3411
+ type: z17.literal("delete_file"),
3412
+ path: z17.string()
3243
3413
  }),
3244
- z16.object({
3245
- type: z16.literal("update_file"),
3246
- path: z16.string(),
3247
- diff: z16.string()
3414
+ z17.object({
3415
+ type: z17.literal("update_file"),
3416
+ path: z17.string(),
3417
+ diff: z17.string()
3248
3418
  })
3249
3419
  ])
3250
3420
  }),
3251
- z16.object({
3252
- type: z16.literal("custom_tool_call"),
3253
- id: z16.string(),
3254
- call_id: z16.string(),
3255
- name: z16.string(),
3256
- input: z16.string()
3421
+ z17.object({
3422
+ type: z17.literal("custom_tool_call"),
3423
+ id: z17.string(),
3424
+ call_id: z17.string(),
3425
+ name: z17.string(),
3426
+ input: z17.string()
3257
3427
  }),
3258
- z16.object({
3259
- type: z16.literal("shell_call"),
3260
- id: z16.string(),
3261
- call_id: z16.string(),
3262
- status: z16.enum(["in_progress", "completed", "incomplete"]),
3263
- action: z16.object({
3264
- commands: z16.array(z16.string())
3428
+ z17.object({
3429
+ type: z17.literal("shell_call"),
3430
+ id: z17.string(),
3431
+ call_id: z17.string(),
3432
+ status: z17.enum(["in_progress", "completed", "incomplete"]),
3433
+ action: z17.object({
3434
+ commands: z17.array(z17.string())
3265
3435
  })
3266
3436
  }),
3267
- z16.object({
3268
- type: z16.literal("shell_call_output"),
3269
- id: z16.string(),
3270
- call_id: z16.string(),
3271
- status: z16.enum(["in_progress", "completed", "incomplete"]),
3272
- output: z16.array(
3273
- z16.object({
3274
- stdout: z16.string(),
3275
- stderr: z16.string(),
3276
- outcome: z16.discriminatedUnion("type", [
3277
- z16.object({ type: z16.literal("timeout") }),
3278
- z16.object({
3279
- type: z16.literal("exit"),
3280
- exit_code: z16.number()
3437
+ z17.object({
3438
+ type: z17.literal("compaction"),
3439
+ id: z17.string(),
3440
+ encrypted_content: z17.string().nullish()
3441
+ }),
3442
+ z17.object({
3443
+ type: z17.literal("shell_call_output"),
3444
+ id: z17.string(),
3445
+ call_id: z17.string(),
3446
+ status: z17.enum(["in_progress", "completed", "incomplete"]),
3447
+ output: z17.array(
3448
+ z17.object({
3449
+ stdout: z17.string(),
3450
+ stderr: z17.string(),
3451
+ outcome: z17.discriminatedUnion("type", [
3452
+ z17.object({ type: z17.literal("timeout") }),
3453
+ z17.object({
3454
+ type: z17.literal("exit"),
3455
+ exit_code: z17.number()
3281
3456
  })
3282
3457
  ])
3283
3458
  })
3284
3459
  )
3460
+ }),
3461
+ z17.object({
3462
+ type: z17.literal("tool_search_call"),
3463
+ id: z17.string(),
3464
+ execution: z17.enum(["server", "client"]),
3465
+ call_id: z17.string().nullable(),
3466
+ status: z17.enum(["in_progress", "completed", "incomplete"]),
3467
+ arguments: z17.unknown()
3468
+ }),
3469
+ z17.object({
3470
+ type: z17.literal("tool_search_output"),
3471
+ id: z17.string(),
3472
+ execution: z17.enum(["server", "client"]),
3473
+ call_id: z17.string().nullable(),
3474
+ status: z17.enum(["in_progress", "completed", "incomplete"]),
3475
+ tools: z17.array(z17.record(z17.string(), jsonValueSchema.optional()))
3285
3476
  })
3286
3477
  ])
3287
3478
  }),
3288
- z16.object({
3289
- type: z16.literal("response.output_item.done"),
3290
- output_index: z16.number(),
3291
- item: z16.discriminatedUnion("type", [
3292
- z16.object({
3293
- type: z16.literal("message"),
3294
- id: z16.string(),
3295
- phase: z16.enum(["commentary", "final_answer"]).nullish()
3479
+ z17.object({
3480
+ type: z17.literal("response.output_item.done"),
3481
+ output_index: z17.number(),
3482
+ item: z17.discriminatedUnion("type", [
3483
+ z17.object({
3484
+ type: z17.literal("message"),
3485
+ id: z17.string(),
3486
+ phase: z17.enum(["commentary", "final_answer"]).nullish()
3296
3487
  }),
3297
- z16.object({
3298
- type: z16.literal("reasoning"),
3299
- id: z16.string(),
3300
- encrypted_content: z16.string().nullish()
3488
+ z17.object({
3489
+ type: z17.literal("reasoning"),
3490
+ id: z17.string(),
3491
+ encrypted_content: z17.string().nullish()
3301
3492
  }),
3302
- z16.object({
3303
- type: z16.literal("function_call"),
3304
- id: z16.string(),
3305
- call_id: z16.string(),
3306
- name: z16.string(),
3307
- arguments: z16.string(),
3308
- status: z16.literal("completed")
3493
+ z17.object({
3494
+ type: z17.literal("function_call"),
3495
+ id: z17.string(),
3496
+ call_id: z17.string(),
3497
+ name: z17.string(),
3498
+ arguments: z17.string(),
3499
+ status: z17.literal("completed")
3309
3500
  }),
3310
- z16.object({
3311
- type: z16.literal("custom_tool_call"),
3312
- id: z16.string(),
3313
- call_id: z16.string(),
3314
- name: z16.string(),
3315
- input: z16.string(),
3316
- status: z16.literal("completed")
3501
+ z17.object({
3502
+ type: z17.literal("custom_tool_call"),
3503
+ id: z17.string(),
3504
+ call_id: z17.string(),
3505
+ name: z17.string(),
3506
+ input: z17.string(),
3507
+ status: z17.literal("completed")
3317
3508
  }),
3318
- z16.object({
3319
- type: z16.literal("code_interpreter_call"),
3320
- id: z16.string(),
3321
- code: z16.string().nullable(),
3322
- container_id: z16.string(),
3323
- outputs: z16.array(
3324
- z16.discriminatedUnion("type", [
3325
- z16.object({ type: z16.literal("logs"), logs: z16.string() }),
3326
- z16.object({ type: z16.literal("image"), url: z16.string() })
3509
+ z17.object({
3510
+ type: z17.literal("code_interpreter_call"),
3511
+ id: z17.string(),
3512
+ code: z17.string().nullable(),
3513
+ container_id: z17.string(),
3514
+ outputs: z17.array(
3515
+ z17.discriminatedUnion("type", [
3516
+ z17.object({ type: z17.literal("logs"), logs: z17.string() }),
3517
+ z17.object({ type: z17.literal("image"), url: z17.string() })
3327
3518
  ])
3328
3519
  ).nullable()
3329
3520
  }),
3330
- z16.object({
3331
- type: z16.literal("image_generation_call"),
3332
- id: z16.string(),
3333
- result: z16.string()
3521
+ z17.object({
3522
+ type: z17.literal("image_generation_call"),
3523
+ id: z17.string(),
3524
+ result: z17.string()
3334
3525
  }),
3335
- z16.object({
3336
- type: z16.literal("web_search_call"),
3337
- id: z16.string(),
3338
- status: z16.string(),
3339
- action: z16.discriminatedUnion("type", [
3340
- z16.object({
3341
- type: z16.literal("search"),
3342
- query: z16.string().nullish(),
3343
- sources: z16.array(
3344
- z16.discriminatedUnion("type", [
3345
- z16.object({ type: z16.literal("url"), url: z16.string() }),
3346
- z16.object({ type: z16.literal("api"), name: z16.string() })
3526
+ z17.object({
3527
+ type: z17.literal("web_search_call"),
3528
+ id: z17.string(),
3529
+ status: z17.string(),
3530
+ action: z17.discriminatedUnion("type", [
3531
+ z17.object({
3532
+ type: z17.literal("search"),
3533
+ query: z17.string().nullish(),
3534
+ sources: z17.array(
3535
+ z17.discriminatedUnion("type", [
3536
+ z17.object({ type: z17.literal("url"), url: z17.string() }),
3537
+ z17.object({ type: z17.literal("api"), name: z17.string() })
3347
3538
  ])
3348
3539
  ).nullish()
3349
3540
  }),
3350
- z16.object({
3351
- type: z16.literal("open_page"),
3352
- url: z16.string().nullish()
3541
+ z17.object({
3542
+ type: z17.literal("open_page"),
3543
+ url: z17.string().nullish()
3353
3544
  }),
3354
- z16.object({
3355
- type: z16.literal("find_in_page"),
3356
- url: z16.string().nullish(),
3357
- pattern: z16.string().nullish()
3545
+ z17.object({
3546
+ type: z17.literal("find_in_page"),
3547
+ url: z17.string().nullish(),
3548
+ pattern: z17.string().nullish()
3358
3549
  })
3359
3550
  ]).nullish()
3360
3551
  }),
3361
- z16.object({
3362
- type: z16.literal("file_search_call"),
3363
- id: z16.string(),
3364
- queries: z16.array(z16.string()),
3365
- results: z16.array(
3366
- z16.object({
3367
- attributes: z16.record(
3368
- z16.string(),
3369
- z16.union([z16.string(), z16.number(), z16.boolean()])
3552
+ z17.object({
3553
+ type: z17.literal("file_search_call"),
3554
+ id: z17.string(),
3555
+ queries: z17.array(z17.string()),
3556
+ results: z17.array(
3557
+ z17.object({
3558
+ attributes: z17.record(
3559
+ z17.string(),
3560
+ z17.union([z17.string(), z17.number(), z17.boolean()])
3370
3561
  ),
3371
- file_id: z16.string(),
3372
- filename: z16.string(),
3373
- score: z16.number(),
3374
- text: z16.string()
3562
+ file_id: z17.string(),
3563
+ filename: z17.string(),
3564
+ score: z17.number(),
3565
+ text: z17.string()
3375
3566
  })
3376
3567
  ).nullish()
3377
3568
  }),
3378
- z16.object({
3379
- type: z16.literal("local_shell_call"),
3380
- id: z16.string(),
3381
- call_id: z16.string(),
3382
- action: z16.object({
3383
- type: z16.literal("exec"),
3384
- command: z16.array(z16.string()),
3385
- timeout_ms: z16.number().optional(),
3386
- user: z16.string().optional(),
3387
- working_directory: z16.string().optional(),
3388
- env: z16.record(z16.string(), z16.string()).optional()
3569
+ z17.object({
3570
+ type: z17.literal("local_shell_call"),
3571
+ id: z17.string(),
3572
+ call_id: z17.string(),
3573
+ action: z17.object({
3574
+ type: z17.literal("exec"),
3575
+ command: z17.array(z17.string()),
3576
+ timeout_ms: z17.number().optional(),
3577
+ user: z17.string().optional(),
3578
+ working_directory: z17.string().optional(),
3579
+ env: z17.record(z17.string(), z17.string()).optional()
3389
3580
  })
3390
3581
  }),
3391
- z16.object({
3392
- type: z16.literal("computer_call"),
3393
- id: z16.string(),
3394
- status: z16.literal("completed")
3582
+ z17.object({
3583
+ type: z17.literal("computer_call"),
3584
+ id: z17.string(),
3585
+ status: z17.literal("completed")
3395
3586
  }),
3396
- z16.object({
3397
- type: z16.literal("mcp_call"),
3398
- id: z16.string(),
3399
- status: z16.string(),
3400
- arguments: z16.string(),
3401
- name: z16.string(),
3402
- server_label: z16.string(),
3403
- output: z16.string().nullish(),
3404
- error: z16.union([
3405
- z16.string(),
3406
- z16.object({
3407
- type: z16.string().optional(),
3408
- code: z16.union([z16.number(), z16.string()]).optional(),
3409
- message: z16.string().optional()
3587
+ z17.object({
3588
+ type: z17.literal("mcp_call"),
3589
+ id: z17.string(),
3590
+ status: z17.string(),
3591
+ arguments: z17.string(),
3592
+ name: z17.string(),
3593
+ server_label: z17.string(),
3594
+ output: z17.string().nullish(),
3595
+ error: z17.union([
3596
+ z17.string(),
3597
+ z17.object({
3598
+ type: z17.string().optional(),
3599
+ code: z17.union([z17.number(), z17.string()]).optional(),
3600
+ message: z17.string().optional()
3410
3601
  }).loose()
3411
3602
  ]).nullish(),
3412
- approval_request_id: z16.string().nullish()
3603
+ approval_request_id: z17.string().nullish()
3413
3604
  }),
3414
- z16.object({
3415
- type: z16.literal("mcp_list_tools"),
3416
- id: z16.string(),
3417
- server_label: z16.string(),
3418
- tools: z16.array(
3419
- z16.object({
3420
- name: z16.string(),
3421
- description: z16.string().optional(),
3422
- input_schema: z16.any(),
3423
- annotations: z16.record(z16.string(), z16.unknown()).optional()
3605
+ z17.object({
3606
+ type: z17.literal("mcp_list_tools"),
3607
+ id: z17.string(),
3608
+ server_label: z17.string(),
3609
+ tools: z17.array(
3610
+ z17.object({
3611
+ name: z17.string(),
3612
+ description: z17.string().optional(),
3613
+ input_schema: z17.any(),
3614
+ annotations: z17.record(z17.string(), z17.unknown()).optional()
3424
3615
  })
3425
3616
  ),
3426
- error: z16.union([
3427
- z16.string(),
3428
- z16.object({
3429
- type: z16.string().optional(),
3430
- code: z16.union([z16.number(), z16.string()]).optional(),
3431
- message: z16.string().optional()
3617
+ error: z17.union([
3618
+ z17.string(),
3619
+ z17.object({
3620
+ type: z17.string().optional(),
3621
+ code: z17.union([z17.number(), z17.string()]).optional(),
3622
+ message: z17.string().optional()
3432
3623
  }).loose()
3433
3624
  ]).optional()
3434
3625
  }),
3435
- z16.object({
3436
- type: z16.literal("mcp_approval_request"),
3437
- id: z16.string(),
3438
- server_label: z16.string(),
3439
- name: z16.string(),
3440
- arguments: z16.string(),
3441
- approval_request_id: z16.string().optional()
3626
+ z17.object({
3627
+ type: z17.literal("mcp_approval_request"),
3628
+ id: z17.string(),
3629
+ server_label: z17.string(),
3630
+ name: z17.string(),
3631
+ arguments: z17.string(),
3632
+ approval_request_id: z17.string().optional()
3442
3633
  }),
3443
- z16.object({
3444
- type: z16.literal("apply_patch_call"),
3445
- id: z16.string(),
3446
- call_id: z16.string(),
3447
- status: z16.enum(["in_progress", "completed"]),
3448
- operation: z16.discriminatedUnion("type", [
3449
- z16.object({
3450
- type: z16.literal("create_file"),
3451
- path: z16.string(),
3452
- diff: z16.string()
3634
+ z17.object({
3635
+ type: z17.literal("apply_patch_call"),
3636
+ id: z17.string(),
3637
+ call_id: z17.string(),
3638
+ status: z17.enum(["in_progress", "completed"]),
3639
+ operation: z17.discriminatedUnion("type", [
3640
+ z17.object({
3641
+ type: z17.literal("create_file"),
3642
+ path: z17.string(),
3643
+ diff: z17.string()
3453
3644
  }),
3454
- z16.object({
3455
- type: z16.literal("delete_file"),
3456
- path: z16.string()
3645
+ z17.object({
3646
+ type: z17.literal("delete_file"),
3647
+ path: z17.string()
3457
3648
  }),
3458
- z16.object({
3459
- type: z16.literal("update_file"),
3460
- path: z16.string(),
3461
- diff: z16.string()
3649
+ z17.object({
3650
+ type: z17.literal("update_file"),
3651
+ path: z17.string(),
3652
+ diff: z17.string()
3462
3653
  })
3463
3654
  ])
3464
3655
  }),
3465
- z16.object({
3466
- type: z16.literal("shell_call"),
3467
- id: z16.string(),
3468
- call_id: z16.string(),
3469
- status: z16.enum(["in_progress", "completed", "incomplete"]),
3470
- action: z16.object({
3471
- commands: z16.array(z16.string())
3656
+ z17.object({
3657
+ type: z17.literal("shell_call"),
3658
+ id: z17.string(),
3659
+ call_id: z17.string(),
3660
+ status: z17.enum(["in_progress", "completed", "incomplete"]),
3661
+ action: z17.object({
3662
+ commands: z17.array(z17.string())
3472
3663
  })
3473
3664
  }),
3474
- z16.object({
3475
- type: z16.literal("shell_call_output"),
3476
- id: z16.string(),
3477
- call_id: z16.string(),
3478
- status: z16.enum(["in_progress", "completed", "incomplete"]),
3479
- output: z16.array(
3480
- z16.object({
3481
- stdout: z16.string(),
3482
- stderr: z16.string(),
3483
- outcome: z16.discriminatedUnion("type", [
3484
- z16.object({ type: z16.literal("timeout") }),
3485
- z16.object({
3486
- type: z16.literal("exit"),
3487
- exit_code: z16.number()
3665
+ z17.object({
3666
+ type: z17.literal("compaction"),
3667
+ id: z17.string(),
3668
+ encrypted_content: z17.string()
3669
+ }),
3670
+ z17.object({
3671
+ type: z17.literal("shell_call_output"),
3672
+ id: z17.string(),
3673
+ call_id: z17.string(),
3674
+ status: z17.enum(["in_progress", "completed", "incomplete"]),
3675
+ output: z17.array(
3676
+ z17.object({
3677
+ stdout: z17.string(),
3678
+ stderr: z17.string(),
3679
+ outcome: z17.discriminatedUnion("type", [
3680
+ z17.object({ type: z17.literal("timeout") }),
3681
+ z17.object({
3682
+ type: z17.literal("exit"),
3683
+ exit_code: z17.number()
3488
3684
  })
3489
3685
  ])
3490
3686
  })
3491
3687
  )
3688
+ }),
3689
+ z17.object({
3690
+ type: z17.literal("tool_search_call"),
3691
+ id: z17.string(),
3692
+ execution: z17.enum(["server", "client"]),
3693
+ call_id: z17.string().nullable(),
3694
+ status: z17.enum(["in_progress", "completed", "incomplete"]),
3695
+ arguments: z17.unknown()
3696
+ }),
3697
+ z17.object({
3698
+ type: z17.literal("tool_search_output"),
3699
+ id: z17.string(),
3700
+ execution: z17.enum(["server", "client"]),
3701
+ call_id: z17.string().nullable(),
3702
+ status: z17.enum(["in_progress", "completed", "incomplete"]),
3703
+ tools: z17.array(z17.record(z17.string(), jsonValueSchema.optional()))
3492
3704
  })
3493
3705
  ])
3494
3706
  }),
3495
- z16.object({
3496
- type: z16.literal("response.function_call_arguments.delta"),
3497
- item_id: z16.string(),
3498
- output_index: z16.number(),
3499
- delta: z16.string()
3707
+ z17.object({
3708
+ type: z17.literal("response.function_call_arguments.delta"),
3709
+ item_id: z17.string(),
3710
+ output_index: z17.number(),
3711
+ delta: z17.string()
3500
3712
  }),
3501
- z16.object({
3502
- type: z16.literal("response.custom_tool_call_input.delta"),
3503
- item_id: z16.string(),
3504
- output_index: z16.number(),
3505
- delta: z16.string()
3713
+ z17.object({
3714
+ type: z17.literal("response.custom_tool_call_input.delta"),
3715
+ item_id: z17.string(),
3716
+ output_index: z17.number(),
3717
+ delta: z17.string()
3506
3718
  }),
3507
- z16.object({
3508
- type: z16.literal("response.image_generation_call.partial_image"),
3509
- item_id: z16.string(),
3510
- output_index: z16.number(),
3511
- partial_image_b64: z16.string()
3719
+ z17.object({
3720
+ type: z17.literal("response.image_generation_call.partial_image"),
3721
+ item_id: z17.string(),
3722
+ output_index: z17.number(),
3723
+ partial_image_b64: z17.string()
3512
3724
  }),
3513
- z16.object({
3514
- type: z16.literal("response.code_interpreter_call_code.delta"),
3515
- item_id: z16.string(),
3516
- output_index: z16.number(),
3517
- delta: z16.string()
3725
+ z17.object({
3726
+ type: z17.literal("response.code_interpreter_call_code.delta"),
3727
+ item_id: z17.string(),
3728
+ output_index: z17.number(),
3729
+ delta: z17.string()
3518
3730
  }),
3519
- z16.object({
3520
- type: z16.literal("response.code_interpreter_call_code.done"),
3521
- item_id: z16.string(),
3522
- output_index: z16.number(),
3523
- code: z16.string()
3731
+ z17.object({
3732
+ type: z17.literal("response.code_interpreter_call_code.done"),
3733
+ item_id: z17.string(),
3734
+ output_index: z17.number(),
3735
+ code: z17.string()
3524
3736
  }),
3525
- z16.object({
3526
- type: z16.literal("response.output_text.annotation.added"),
3527
- annotation: z16.discriminatedUnion("type", [
3528
- z16.object({
3529
- type: z16.literal("url_citation"),
3530
- start_index: z16.number(),
3531
- end_index: z16.number(),
3532
- url: z16.string(),
3533
- title: z16.string()
3737
+ z17.object({
3738
+ type: z17.literal("response.output_text.annotation.added"),
3739
+ annotation: z17.discriminatedUnion("type", [
3740
+ z17.object({
3741
+ type: z17.literal("url_citation"),
3742
+ start_index: z17.number(),
3743
+ end_index: z17.number(),
3744
+ url: z17.string(),
3745
+ title: z17.string()
3534
3746
  }),
3535
- z16.object({
3536
- type: z16.literal("file_citation"),
3537
- file_id: z16.string(),
3538
- filename: z16.string(),
3539
- index: z16.number()
3747
+ z17.object({
3748
+ type: z17.literal("file_citation"),
3749
+ file_id: z17.string(),
3750
+ filename: z17.string(),
3751
+ index: z17.number()
3540
3752
  }),
3541
- z16.object({
3542
- type: z16.literal("container_file_citation"),
3543
- container_id: z16.string(),
3544
- file_id: z16.string(),
3545
- filename: z16.string(),
3546
- start_index: z16.number(),
3547
- end_index: z16.number()
3753
+ z17.object({
3754
+ type: z17.literal("container_file_citation"),
3755
+ container_id: z17.string(),
3756
+ file_id: z17.string(),
3757
+ filename: z17.string(),
3758
+ start_index: z17.number(),
3759
+ end_index: z17.number()
3548
3760
  }),
3549
- z16.object({
3550
- type: z16.literal("file_path"),
3551
- file_id: z16.string(),
3552
- index: z16.number()
3761
+ z17.object({
3762
+ type: z17.literal("file_path"),
3763
+ file_id: z17.string(),
3764
+ index: z17.number()
3553
3765
  })
3554
3766
  ])
3555
3767
  }),
3556
- z16.object({
3557
- type: z16.literal("response.reasoning_summary_part.added"),
3558
- item_id: z16.string(),
3559
- summary_index: z16.number()
3768
+ z17.object({
3769
+ type: z17.literal("response.reasoning_summary_part.added"),
3770
+ item_id: z17.string(),
3771
+ summary_index: z17.number()
3560
3772
  }),
3561
- z16.object({
3562
- type: z16.literal("response.reasoning_summary_text.delta"),
3563
- item_id: z16.string(),
3564
- summary_index: z16.number(),
3565
- delta: z16.string()
3773
+ z17.object({
3774
+ type: z17.literal("response.reasoning_summary_text.delta"),
3775
+ item_id: z17.string(),
3776
+ summary_index: z17.number(),
3777
+ delta: z17.string()
3566
3778
  }),
3567
- z16.object({
3568
- type: z16.literal("response.reasoning_summary_part.done"),
3569
- item_id: z16.string(),
3570
- summary_index: z16.number()
3779
+ z17.object({
3780
+ type: z17.literal("response.reasoning_summary_part.done"),
3781
+ item_id: z17.string(),
3782
+ summary_index: z17.number()
3571
3783
  }),
3572
- z16.object({
3573
- type: z16.literal("response.apply_patch_call_operation_diff.delta"),
3574
- item_id: z16.string(),
3575
- output_index: z16.number(),
3576
- delta: z16.string(),
3577
- obfuscation: z16.string().nullish()
3784
+ z17.object({
3785
+ type: z17.literal("response.apply_patch_call_operation_diff.delta"),
3786
+ item_id: z17.string(),
3787
+ output_index: z17.number(),
3788
+ delta: z17.string(),
3789
+ obfuscation: z17.string().nullish()
3578
3790
  }),
3579
- z16.object({
3580
- type: z16.literal("response.apply_patch_call_operation_diff.done"),
3581
- item_id: z16.string(),
3582
- output_index: z16.number(),
3583
- diff: z16.string()
3791
+ z17.object({
3792
+ type: z17.literal("response.apply_patch_call_operation_diff.done"),
3793
+ item_id: z17.string(),
3794
+ output_index: z17.number(),
3795
+ diff: z17.string()
3584
3796
  }),
3585
- z16.object({
3586
- type: z16.literal("error"),
3587
- sequence_number: z16.number(),
3588
- error: z16.object({
3589
- type: z16.string(),
3590
- code: z16.string(),
3591
- message: z16.string(),
3592
- param: z16.string().nullish()
3797
+ z17.object({
3798
+ type: z17.literal("error"),
3799
+ sequence_number: z17.number(),
3800
+ error: z17.object({
3801
+ type: z17.string(),
3802
+ code: z17.string(),
3803
+ message: z17.string(),
3804
+ param: z17.string().nullish()
3593
3805
  })
3594
3806
  }),
3595
- z16.object({ type: z16.string() }).loose().transform((value) => ({
3807
+ z17.object({ type: z17.string() }).loose().transform((value) => ({
3596
3808
  type: "unknown_chunk",
3597
3809
  message: value.type
3598
3810
  }))
@@ -3600,294 +3812,315 @@ var openaiResponsesChunkSchema = lazySchema14(
3600
3812
  ])
3601
3813
  )
3602
3814
  );
3603
- var openaiResponsesResponseSchema = lazySchema14(
3604
- () => zodSchema14(
3605
- z16.object({
3606
- id: z16.string().optional(),
3607
- created_at: z16.number().optional(),
3608
- error: z16.object({
3609
- message: z16.string(),
3610
- type: z16.string(),
3611
- param: z16.string().nullish(),
3612
- code: z16.string()
3815
+ var openaiResponsesResponseSchema = lazySchema15(
3816
+ () => zodSchema15(
3817
+ z17.object({
3818
+ id: z17.string().optional(),
3819
+ created_at: z17.number().optional(),
3820
+ error: z17.object({
3821
+ message: z17.string(),
3822
+ type: z17.string(),
3823
+ param: z17.string().nullish(),
3824
+ code: z17.string()
3613
3825
  }).nullish(),
3614
- model: z16.string().optional(),
3615
- output: z16.array(
3616
- z16.discriminatedUnion("type", [
3617
- z16.object({
3618
- type: z16.literal("message"),
3619
- role: z16.literal("assistant"),
3620
- id: z16.string(),
3621
- phase: z16.enum(["commentary", "final_answer"]).nullish(),
3622
- content: z16.array(
3623
- z16.object({
3624
- type: z16.literal("output_text"),
3625
- text: z16.string(),
3626
- logprobs: z16.array(
3627
- z16.object({
3628
- token: z16.string(),
3629
- logprob: z16.number(),
3630
- top_logprobs: z16.array(
3631
- z16.object({
3632
- token: z16.string(),
3633
- logprob: z16.number()
3826
+ model: z17.string().optional(),
3827
+ output: z17.array(
3828
+ z17.discriminatedUnion("type", [
3829
+ z17.object({
3830
+ type: z17.literal("message"),
3831
+ role: z17.literal("assistant"),
3832
+ id: z17.string(),
3833
+ phase: z17.enum(["commentary", "final_answer"]).nullish(),
3834
+ content: z17.array(
3835
+ z17.object({
3836
+ type: z17.literal("output_text"),
3837
+ text: z17.string(),
3838
+ logprobs: z17.array(
3839
+ z17.object({
3840
+ token: z17.string(),
3841
+ logprob: z17.number(),
3842
+ top_logprobs: z17.array(
3843
+ z17.object({
3844
+ token: z17.string(),
3845
+ logprob: z17.number()
3634
3846
  })
3635
3847
  )
3636
3848
  })
3637
3849
  ).nullish(),
3638
- annotations: z16.array(
3639
- z16.discriminatedUnion("type", [
3640
- z16.object({
3641
- type: z16.literal("url_citation"),
3642
- start_index: z16.number(),
3643
- end_index: z16.number(),
3644
- url: z16.string(),
3645
- title: z16.string()
3850
+ annotations: z17.array(
3851
+ z17.discriminatedUnion("type", [
3852
+ z17.object({
3853
+ type: z17.literal("url_citation"),
3854
+ start_index: z17.number(),
3855
+ end_index: z17.number(),
3856
+ url: z17.string(),
3857
+ title: z17.string()
3646
3858
  }),
3647
- z16.object({
3648
- type: z16.literal("file_citation"),
3649
- file_id: z16.string(),
3650
- filename: z16.string(),
3651
- index: z16.number()
3859
+ z17.object({
3860
+ type: z17.literal("file_citation"),
3861
+ file_id: z17.string(),
3862
+ filename: z17.string(),
3863
+ index: z17.number()
3652
3864
  }),
3653
- z16.object({
3654
- type: z16.literal("container_file_citation"),
3655
- container_id: z16.string(),
3656
- file_id: z16.string(),
3657
- filename: z16.string(),
3658
- start_index: z16.number(),
3659
- end_index: z16.number()
3865
+ z17.object({
3866
+ type: z17.literal("container_file_citation"),
3867
+ container_id: z17.string(),
3868
+ file_id: z17.string(),
3869
+ filename: z17.string(),
3870
+ start_index: z17.number(),
3871
+ end_index: z17.number()
3660
3872
  }),
3661
- z16.object({
3662
- type: z16.literal("file_path"),
3663
- file_id: z16.string(),
3664
- index: z16.number()
3873
+ z17.object({
3874
+ type: z17.literal("file_path"),
3875
+ file_id: z17.string(),
3876
+ index: z17.number()
3665
3877
  })
3666
3878
  ])
3667
3879
  )
3668
3880
  })
3669
3881
  )
3670
3882
  }),
3671
- z16.object({
3672
- type: z16.literal("web_search_call"),
3673
- id: z16.string(),
3674
- status: z16.string(),
3675
- action: z16.discriminatedUnion("type", [
3676
- z16.object({
3677
- type: z16.literal("search"),
3678
- query: z16.string().nullish(),
3679
- sources: z16.array(
3680
- z16.discriminatedUnion("type", [
3681
- z16.object({ type: z16.literal("url"), url: z16.string() }),
3682
- z16.object({
3683
- type: z16.literal("api"),
3684
- name: z16.string()
3883
+ z17.object({
3884
+ type: z17.literal("web_search_call"),
3885
+ id: z17.string(),
3886
+ status: z17.string(),
3887
+ action: z17.discriminatedUnion("type", [
3888
+ z17.object({
3889
+ type: z17.literal("search"),
3890
+ query: z17.string().nullish(),
3891
+ sources: z17.array(
3892
+ z17.discriminatedUnion("type", [
3893
+ z17.object({ type: z17.literal("url"), url: z17.string() }),
3894
+ z17.object({
3895
+ type: z17.literal("api"),
3896
+ name: z17.string()
3685
3897
  })
3686
3898
  ])
3687
3899
  ).nullish()
3688
3900
  }),
3689
- z16.object({
3690
- type: z16.literal("open_page"),
3691
- url: z16.string().nullish()
3901
+ z17.object({
3902
+ type: z17.literal("open_page"),
3903
+ url: z17.string().nullish()
3692
3904
  }),
3693
- z16.object({
3694
- type: z16.literal("find_in_page"),
3695
- url: z16.string().nullish(),
3696
- pattern: z16.string().nullish()
3905
+ z17.object({
3906
+ type: z17.literal("find_in_page"),
3907
+ url: z17.string().nullish(),
3908
+ pattern: z17.string().nullish()
3697
3909
  })
3698
3910
  ]).nullish()
3699
3911
  }),
3700
- z16.object({
3701
- type: z16.literal("file_search_call"),
3702
- id: z16.string(),
3703
- queries: z16.array(z16.string()),
3704
- results: z16.array(
3705
- z16.object({
3706
- attributes: z16.record(
3707
- z16.string(),
3708
- z16.union([z16.string(), z16.number(), z16.boolean()])
3912
+ z17.object({
3913
+ type: z17.literal("file_search_call"),
3914
+ id: z17.string(),
3915
+ queries: z17.array(z17.string()),
3916
+ results: z17.array(
3917
+ z17.object({
3918
+ attributes: z17.record(
3919
+ z17.string(),
3920
+ z17.union([z17.string(), z17.number(), z17.boolean()])
3709
3921
  ),
3710
- file_id: z16.string(),
3711
- filename: z16.string(),
3712
- score: z16.number(),
3713
- text: z16.string()
3922
+ file_id: z17.string(),
3923
+ filename: z17.string(),
3924
+ score: z17.number(),
3925
+ text: z17.string()
3714
3926
  })
3715
3927
  ).nullish()
3716
3928
  }),
3717
- z16.object({
3718
- type: z16.literal("code_interpreter_call"),
3719
- id: z16.string(),
3720
- code: z16.string().nullable(),
3721
- container_id: z16.string(),
3722
- outputs: z16.array(
3723
- z16.discriminatedUnion("type", [
3724
- z16.object({ type: z16.literal("logs"), logs: z16.string() }),
3725
- z16.object({ type: z16.literal("image"), url: z16.string() })
3929
+ z17.object({
3930
+ type: z17.literal("code_interpreter_call"),
3931
+ id: z17.string(),
3932
+ code: z17.string().nullable(),
3933
+ container_id: z17.string(),
3934
+ outputs: z17.array(
3935
+ z17.discriminatedUnion("type", [
3936
+ z17.object({ type: z17.literal("logs"), logs: z17.string() }),
3937
+ z17.object({ type: z17.literal("image"), url: z17.string() })
3726
3938
  ])
3727
3939
  ).nullable()
3728
3940
  }),
3729
- z16.object({
3730
- type: z16.literal("image_generation_call"),
3731
- id: z16.string(),
3732
- result: z16.string()
3941
+ z17.object({
3942
+ type: z17.literal("image_generation_call"),
3943
+ id: z17.string(),
3944
+ result: z17.string()
3733
3945
  }),
3734
- z16.object({
3735
- type: z16.literal("local_shell_call"),
3736
- id: z16.string(),
3737
- call_id: z16.string(),
3738
- action: z16.object({
3739
- type: z16.literal("exec"),
3740
- command: z16.array(z16.string()),
3741
- timeout_ms: z16.number().optional(),
3742
- user: z16.string().optional(),
3743
- working_directory: z16.string().optional(),
3744
- env: z16.record(z16.string(), z16.string()).optional()
3946
+ z17.object({
3947
+ type: z17.literal("local_shell_call"),
3948
+ id: z17.string(),
3949
+ call_id: z17.string(),
3950
+ action: z17.object({
3951
+ type: z17.literal("exec"),
3952
+ command: z17.array(z17.string()),
3953
+ timeout_ms: z17.number().optional(),
3954
+ user: z17.string().optional(),
3955
+ working_directory: z17.string().optional(),
3956
+ env: z17.record(z17.string(), z17.string()).optional()
3745
3957
  })
3746
3958
  }),
3747
- z16.object({
3748
- type: z16.literal("function_call"),
3749
- call_id: z16.string(),
3750
- name: z16.string(),
3751
- arguments: z16.string(),
3752
- id: z16.string()
3959
+ z17.object({
3960
+ type: z17.literal("function_call"),
3961
+ call_id: z17.string(),
3962
+ name: z17.string(),
3963
+ arguments: z17.string(),
3964
+ id: z17.string()
3753
3965
  }),
3754
- z16.object({
3755
- type: z16.literal("custom_tool_call"),
3756
- call_id: z16.string(),
3757
- name: z16.string(),
3758
- input: z16.string(),
3759
- id: z16.string()
3966
+ z17.object({
3967
+ type: z17.literal("custom_tool_call"),
3968
+ call_id: z17.string(),
3969
+ name: z17.string(),
3970
+ input: z17.string(),
3971
+ id: z17.string()
3760
3972
  }),
3761
- z16.object({
3762
- type: z16.literal("computer_call"),
3763
- id: z16.string(),
3764
- status: z16.string().optional()
3973
+ z17.object({
3974
+ type: z17.literal("computer_call"),
3975
+ id: z17.string(),
3976
+ status: z17.string().optional()
3765
3977
  }),
3766
- z16.object({
3767
- type: z16.literal("reasoning"),
3768
- id: z16.string(),
3769
- encrypted_content: z16.string().nullish(),
3770
- summary: z16.array(
3771
- z16.object({
3772
- type: z16.literal("summary_text"),
3773
- text: z16.string()
3978
+ z17.object({
3979
+ type: z17.literal("reasoning"),
3980
+ id: z17.string(),
3981
+ encrypted_content: z17.string().nullish(),
3982
+ summary: z17.array(
3983
+ z17.object({
3984
+ type: z17.literal("summary_text"),
3985
+ text: z17.string()
3774
3986
  })
3775
3987
  )
3776
3988
  }),
3777
- z16.object({
3778
- type: z16.literal("mcp_call"),
3779
- id: z16.string(),
3780
- status: z16.string(),
3781
- arguments: z16.string(),
3782
- name: z16.string(),
3783
- server_label: z16.string(),
3784
- output: z16.string().nullish(),
3785
- error: z16.union([
3786
- z16.string(),
3787
- z16.object({
3788
- type: z16.string().optional(),
3789
- code: z16.union([z16.number(), z16.string()]).optional(),
3790
- message: z16.string().optional()
3989
+ z17.object({
3990
+ type: z17.literal("mcp_call"),
3991
+ id: z17.string(),
3992
+ status: z17.string(),
3993
+ arguments: z17.string(),
3994
+ name: z17.string(),
3995
+ server_label: z17.string(),
3996
+ output: z17.string().nullish(),
3997
+ error: z17.union([
3998
+ z17.string(),
3999
+ z17.object({
4000
+ type: z17.string().optional(),
4001
+ code: z17.union([z17.number(), z17.string()]).optional(),
4002
+ message: z17.string().optional()
3791
4003
  }).loose()
3792
4004
  ]).nullish(),
3793
- approval_request_id: z16.string().nullish()
4005
+ approval_request_id: z17.string().nullish()
3794
4006
  }),
3795
- z16.object({
3796
- type: z16.literal("mcp_list_tools"),
3797
- id: z16.string(),
3798
- server_label: z16.string(),
3799
- tools: z16.array(
3800
- z16.object({
3801
- name: z16.string(),
3802
- description: z16.string().optional(),
3803
- input_schema: z16.any(),
3804
- annotations: z16.record(z16.string(), z16.unknown()).optional()
4007
+ z17.object({
4008
+ type: z17.literal("mcp_list_tools"),
4009
+ id: z17.string(),
4010
+ server_label: z17.string(),
4011
+ tools: z17.array(
4012
+ z17.object({
4013
+ name: z17.string(),
4014
+ description: z17.string().optional(),
4015
+ input_schema: z17.any(),
4016
+ annotations: z17.record(z17.string(), z17.unknown()).optional()
3805
4017
  })
3806
4018
  ),
3807
- error: z16.union([
3808
- z16.string(),
3809
- z16.object({
3810
- type: z16.string().optional(),
3811
- code: z16.union([z16.number(), z16.string()]).optional(),
3812
- message: z16.string().optional()
4019
+ error: z17.union([
4020
+ z17.string(),
4021
+ z17.object({
4022
+ type: z17.string().optional(),
4023
+ code: z17.union([z17.number(), z17.string()]).optional(),
4024
+ message: z17.string().optional()
3813
4025
  }).loose()
3814
4026
  ]).optional()
3815
4027
  }),
3816
- z16.object({
3817
- type: z16.literal("mcp_approval_request"),
3818
- id: z16.string(),
3819
- server_label: z16.string(),
3820
- name: z16.string(),
3821
- arguments: z16.string(),
3822
- approval_request_id: z16.string().optional()
4028
+ z17.object({
4029
+ type: z17.literal("mcp_approval_request"),
4030
+ id: z17.string(),
4031
+ server_label: z17.string(),
4032
+ name: z17.string(),
4033
+ arguments: z17.string(),
4034
+ approval_request_id: z17.string().optional()
3823
4035
  }),
3824
- z16.object({
3825
- type: z16.literal("apply_patch_call"),
3826
- id: z16.string(),
3827
- call_id: z16.string(),
3828
- status: z16.enum(["in_progress", "completed"]),
3829
- operation: z16.discriminatedUnion("type", [
3830
- z16.object({
3831
- type: z16.literal("create_file"),
3832
- path: z16.string(),
3833
- diff: z16.string()
4036
+ z17.object({
4037
+ type: z17.literal("apply_patch_call"),
4038
+ id: z17.string(),
4039
+ call_id: z17.string(),
4040
+ status: z17.enum(["in_progress", "completed"]),
4041
+ operation: z17.discriminatedUnion("type", [
4042
+ z17.object({
4043
+ type: z17.literal("create_file"),
4044
+ path: z17.string(),
4045
+ diff: z17.string()
3834
4046
  }),
3835
- z16.object({
3836
- type: z16.literal("delete_file"),
3837
- path: z16.string()
4047
+ z17.object({
4048
+ type: z17.literal("delete_file"),
4049
+ path: z17.string()
3838
4050
  }),
3839
- z16.object({
3840
- type: z16.literal("update_file"),
3841
- path: z16.string(),
3842
- diff: z16.string()
4051
+ z17.object({
4052
+ type: z17.literal("update_file"),
4053
+ path: z17.string(),
4054
+ diff: z17.string()
3843
4055
  })
3844
4056
  ])
3845
4057
  }),
3846
- z16.object({
3847
- type: z16.literal("shell_call"),
3848
- id: z16.string(),
3849
- call_id: z16.string(),
3850
- status: z16.enum(["in_progress", "completed", "incomplete"]),
3851
- action: z16.object({
3852
- commands: z16.array(z16.string())
4058
+ z17.object({
4059
+ type: z17.literal("shell_call"),
4060
+ id: z17.string(),
4061
+ call_id: z17.string(),
4062
+ status: z17.enum(["in_progress", "completed", "incomplete"]),
4063
+ action: z17.object({
4064
+ commands: z17.array(z17.string())
3853
4065
  })
3854
4066
  }),
3855
- z16.object({
3856
- type: z16.literal("shell_call_output"),
3857
- id: z16.string(),
3858
- call_id: z16.string(),
3859
- status: z16.enum(["in_progress", "completed", "incomplete"]),
3860
- output: z16.array(
3861
- z16.object({
3862
- stdout: z16.string(),
3863
- stderr: z16.string(),
3864
- outcome: z16.discriminatedUnion("type", [
3865
- z16.object({ type: z16.literal("timeout") }),
3866
- z16.object({
3867
- type: z16.literal("exit"),
3868
- exit_code: z16.number()
4067
+ z17.object({
4068
+ type: z17.literal("compaction"),
4069
+ id: z17.string(),
4070
+ encrypted_content: z17.string()
4071
+ }),
4072
+ z17.object({
4073
+ type: z17.literal("shell_call_output"),
4074
+ id: z17.string(),
4075
+ call_id: z17.string(),
4076
+ status: z17.enum(["in_progress", "completed", "incomplete"]),
4077
+ output: z17.array(
4078
+ z17.object({
4079
+ stdout: z17.string(),
4080
+ stderr: z17.string(),
4081
+ outcome: z17.discriminatedUnion("type", [
4082
+ z17.object({ type: z17.literal("timeout") }),
4083
+ z17.object({
4084
+ type: z17.literal("exit"),
4085
+ exit_code: z17.number()
3869
4086
  })
3870
4087
  ])
3871
4088
  })
3872
4089
  )
4090
+ }),
4091
+ z17.object({
4092
+ type: z17.literal("tool_search_call"),
4093
+ id: z17.string(),
4094
+ execution: z17.enum(["server", "client"]),
4095
+ call_id: z17.string().nullable(),
4096
+ status: z17.enum(["in_progress", "completed", "incomplete"]),
4097
+ arguments: z17.unknown()
4098
+ }),
4099
+ z17.object({
4100
+ type: z17.literal("tool_search_output"),
4101
+ id: z17.string(),
4102
+ execution: z17.enum(["server", "client"]),
4103
+ call_id: z17.string().nullable(),
4104
+ status: z17.enum(["in_progress", "completed", "incomplete"]),
4105
+ tools: z17.array(z17.record(z17.string(), jsonValueSchema.optional()))
3873
4106
  })
3874
4107
  ])
3875
4108
  ).optional(),
3876
- service_tier: z16.string().nullish(),
3877
- incomplete_details: z16.object({ reason: z16.string() }).nullish(),
3878
- usage: z16.object({
3879
- input_tokens: z16.number(),
3880
- input_tokens_details: z16.object({ cached_tokens: z16.number().nullish() }).nullish(),
3881
- output_tokens: z16.number(),
3882
- output_tokens_details: z16.object({ reasoning_tokens: z16.number().nullish() }).nullish()
4109
+ service_tier: z17.string().nullish(),
4110
+ incomplete_details: z17.object({ reason: z17.string() }).nullish(),
4111
+ usage: z17.object({
4112
+ input_tokens: z17.number(),
4113
+ input_tokens_details: z17.object({ cached_tokens: z17.number().nullish() }).nullish(),
4114
+ output_tokens: z17.number(),
4115
+ output_tokens_details: z17.object({ reasoning_tokens: z17.number().nullish() }).nullish()
3883
4116
  }).optional()
3884
4117
  })
3885
4118
  )
3886
4119
  );
3887
4120
 
3888
4121
  // src/responses/openai-responses-options.ts
3889
- import { lazySchema as lazySchema15, zodSchema as zodSchema15 } from "@ai-sdk/provider-utils";
3890
- import { z as z17 } from "zod/v4";
4122
+ import { lazySchema as lazySchema16, zodSchema as zodSchema16 } from "@ai-sdk/provider-utils";
4123
+ import { z as z18 } from "zod/v4";
3891
4124
  var TOP_LOGPROBS_MAX = 20;
3892
4125
  var openaiResponsesReasoningModelIds = [
3893
4126
  "o1",
@@ -3916,11 +4149,16 @@ var openaiResponsesReasoningModelIds = [
3916
4149
  "gpt-5.2-chat-latest",
3917
4150
  "gpt-5.2-pro",
3918
4151
  "gpt-5.2-codex",
4152
+ "gpt-5.3-chat-latest",
4153
+ "gpt-5.3-codex",
3919
4154
  "gpt-5.4",
3920
4155
  "gpt-5.4-2026-03-05",
4156
+ "gpt-5.4-mini",
4157
+ "gpt-5.4-mini-2026-03-17",
4158
+ "gpt-5.4-nano",
4159
+ "gpt-5.4-nano-2026-03-17",
3921
4160
  "gpt-5.4-pro",
3922
- "gpt-5.4-pro-2026-03-05",
3923
- "gpt-5.3-codex"
4161
+ "gpt-5.4-pro-2026-03-05"
3924
4162
  ];
3925
4163
  var openaiResponsesModelIds = [
3926
4164
  "gpt-4.1",
@@ -3947,9 +4185,9 @@ var openaiResponsesModelIds = [
3947
4185
  "gpt-5-chat-latest",
3948
4186
  ...openaiResponsesReasoningModelIds
3949
4187
  ];
3950
- var openaiLanguageModelResponsesOptionsSchema = lazySchema15(
3951
- () => zodSchema15(
3952
- z17.object({
4188
+ var openaiLanguageModelResponsesOptionsSchema = lazySchema16(
4189
+ () => zodSchema16(
4190
+ z18.object({
3953
4191
  /**
3954
4192
  * The ID of the OpenAI Conversation to continue.
3955
4193
  * You must create a conversation first via the OpenAI API.
@@ -3957,13 +4195,13 @@ var openaiLanguageModelResponsesOptionsSchema = lazySchema15(
3957
4195
  * Defaults to `undefined`.
3958
4196
  * @see https://platform.openai.com/docs/api-reference/conversations/create
3959
4197
  */
3960
- conversation: z17.string().nullish(),
4198
+ conversation: z18.string().nullish(),
3961
4199
  /**
3962
4200
  * The set of extra fields to include in the response (advanced, usually not needed).
3963
4201
  * Example values: 'reasoning.encrypted_content', 'file_search_call.results', 'message.output_text.logprobs'.
3964
4202
  */
3965
- include: z17.array(
3966
- z17.enum([
4203
+ include: z18.array(
4204
+ z18.enum([
3967
4205
  "reasoning.encrypted_content",
3968
4206
  // handled internally by default, only needed for unknown reasoning models
3969
4207
  "file_search_call.results",
@@ -3975,7 +4213,7 @@ var openaiLanguageModelResponsesOptionsSchema = lazySchema15(
3975
4213
  * They can be used to change the system or developer message when continuing a conversation using the `previousResponseId` option.
3976
4214
  * Defaults to `undefined`.
3977
4215
  */
3978
- instructions: z17.string().nullish(),
4216
+ instructions: z18.string().nullish(),
3979
4217
  /**
3980
4218
  * Return the log probabilities of the tokens. Including logprobs will increase
3981
4219
  * the response size and can slow down response times. However, it can
@@ -3990,30 +4228,30 @@ var openaiLanguageModelResponsesOptionsSchema = lazySchema15(
3990
4228
  * @see https://platform.openai.com/docs/api-reference/responses/create
3991
4229
  * @see https://cookbook.openai.com/examples/using_logprobs
3992
4230
  */
3993
- logprobs: z17.union([z17.boolean(), z17.number().min(1).max(TOP_LOGPROBS_MAX)]).optional(),
4231
+ logprobs: z18.union([z18.boolean(), z18.number().min(1).max(TOP_LOGPROBS_MAX)]).optional(),
3994
4232
  /**
3995
4233
  * The maximum number of total calls to built-in tools that can be processed in a response.
3996
4234
  * This maximum number applies across all built-in tool calls, not per individual tool.
3997
4235
  * Any further attempts to call a tool by the model will be ignored.
3998
4236
  */
3999
- maxToolCalls: z17.number().nullish(),
4237
+ maxToolCalls: z18.number().nullish(),
4000
4238
  /**
4001
4239
  * Additional metadata to store with the generation.
4002
4240
  */
4003
- metadata: z17.any().nullish(),
4241
+ metadata: z18.any().nullish(),
4004
4242
  /**
4005
4243
  * Whether to use parallel tool calls. Defaults to `true`.
4006
4244
  */
4007
- parallelToolCalls: z17.boolean().nullish(),
4245
+ parallelToolCalls: z18.boolean().nullish(),
4008
4246
  /**
4009
4247
  * The ID of the previous response. You can use it to continue a conversation.
4010
4248
  * Defaults to `undefined`.
4011
4249
  */
4012
- previousResponseId: z17.string().nullish(),
4250
+ previousResponseId: z18.string().nullish(),
4013
4251
  /**
4014
4252
  * Sets a cache key to tie this prompt to cached prefixes for better caching performance.
4015
4253
  */
4016
- promptCacheKey: z17.string().nullish(),
4254
+ promptCacheKey: z18.string().nullish(),
4017
4255
  /**
4018
4256
  * The retention policy for the prompt cache.
4019
4257
  * - 'in_memory': Default. Standard prompt caching behavior.
@@ -4022,7 +4260,7 @@ var openaiLanguageModelResponsesOptionsSchema = lazySchema15(
4022
4260
  *
4023
4261
  * @default 'in_memory'
4024
4262
  */
4025
- promptCacheRetention: z17.enum(["in_memory", "24h"]).nullish(),
4263
+ promptCacheRetention: z18.enum(["in_memory", "24h"]).nullish(),
4026
4264
  /**
4027
4265
  * Reasoning effort for reasoning models. Defaults to `medium`. If you use
4028
4266
  * `providerOptions` to set the `reasoningEffort` option, this model setting will be ignored.
@@ -4033,17 +4271,17 @@ var openaiLanguageModelResponsesOptionsSchema = lazySchema15(
4033
4271
  * OpenAI's GPT-5.1-Codex-Max model. Setting `reasoningEffort` to 'none' or 'xhigh' with unsupported models will result in
4034
4272
  * an error.
4035
4273
  */
4036
- reasoningEffort: z17.string().nullish(),
4274
+ reasoningEffort: z18.string().nullish(),
4037
4275
  /**
4038
4276
  * Controls reasoning summary output from the model.
4039
4277
  * Set to "auto" to automatically receive the richest level available,
4040
4278
  * or "detailed" for comprehensive summaries.
4041
4279
  */
4042
- reasoningSummary: z17.string().nullish(),
4280
+ reasoningSummary: z18.string().nullish(),
4043
4281
  /**
4044
4282
  * The identifier for safety monitoring and tracking.
4045
4283
  */
4046
- safetyIdentifier: z17.string().nullish(),
4284
+ safetyIdentifier: z18.string().nullish(),
4047
4285
  /**
4048
4286
  * Service tier for the request.
4049
4287
  * Set to 'flex' for 50% cheaper processing at the cost of increased latency (available for o3, o4-mini, and gpt-5 models).
@@ -4051,34 +4289,34 @@ var openaiLanguageModelResponsesOptionsSchema = lazySchema15(
4051
4289
  *
4052
4290
  * Defaults to 'auto'.
4053
4291
  */
4054
- serviceTier: z17.enum(["auto", "flex", "priority", "default"]).nullish(),
4292
+ serviceTier: z18.enum(["auto", "flex", "priority", "default"]).nullish(),
4055
4293
  /**
4056
4294
  * Whether to store the generation. Defaults to `true`.
4057
4295
  */
4058
- store: z17.boolean().nullish(),
4296
+ store: z18.boolean().nullish(),
4059
4297
  /**
4060
4298
  * Whether to use strict JSON schema validation.
4061
4299
  * Defaults to `true`.
4062
4300
  */
4063
- strictJsonSchema: z17.boolean().nullish(),
4301
+ strictJsonSchema: z18.boolean().nullish(),
4064
4302
  /**
4065
4303
  * Controls the verbosity of the model's responses. Lower values ('low') will result
4066
4304
  * in more concise responses, while higher values ('high') will result in more verbose responses.
4067
4305
  * Valid values: 'low', 'medium', 'high'.
4068
4306
  */
4069
- textVerbosity: z17.enum(["low", "medium", "high"]).nullish(),
4307
+ textVerbosity: z18.enum(["low", "medium", "high"]).nullish(),
4070
4308
  /**
4071
4309
  * Controls output truncation. 'auto' (default) performs truncation automatically;
4072
4310
  * 'disabled' turns truncation off.
4073
4311
  */
4074
- truncation: z17.enum(["auto", "disabled"]).nullish(),
4312
+ truncation: z18.enum(["auto", "disabled"]).nullish(),
4075
4313
  /**
4076
4314
  * A unique identifier representing your end-user, which can help OpenAI to
4077
4315
  * monitor and detect abuse.
4078
4316
  * Defaults to `undefined`.
4079
4317
  * @see https://platform.openai.com/docs/guides/safety-best-practices/end-user-ids
4080
4318
  */
4081
- user: z17.string().nullish(),
4319
+ user: z18.string().nullish(),
4082
4320
  /**
4083
4321
  * Override the system message mode for this model.
4084
4322
  * - 'system': Use the 'system' role for system messages (default for most models)
@@ -4087,7 +4325,7 @@ var openaiLanguageModelResponsesOptionsSchema = lazySchema15(
4087
4325
  *
4088
4326
  * If not specified, the mode is automatically determined based on the model.
4089
4327
  */
4090
- systemMessageMode: z17.enum(["system", "developer", "remove"]).optional(),
4328
+ systemMessageMode: z18.enum(["system", "developer", "remove"]).optional(),
4091
4329
  /**
4092
4330
  * Force treating this model as a reasoning model.
4093
4331
  *
@@ -4097,7 +4335,16 @@ var openaiLanguageModelResponsesOptionsSchema = lazySchema15(
4097
4335
  * When enabled, the SDK applies reasoning-model parameter compatibility rules
4098
4336
  * and defaults `systemMessageMode` to `developer` unless overridden.
4099
4337
  */
4100
- forceReasoning: z17.boolean().optional()
4338
+ forceReasoning: z18.boolean().optional(),
4339
+ /**
4340
+ * Enable server-side context management (compaction).
4341
+ */
4342
+ contextManagement: z18.array(
4343
+ z18.object({
4344
+ type: z18.literal("compaction"),
4345
+ compactThreshold: z18.number()
4346
+ })
4347
+ ).nullish()
4101
4348
  })
4102
4349
  )
4103
4350
  );
@@ -4110,44 +4357,44 @@ import { validateTypes as validateTypes2 } from "@ai-sdk/provider-utils";
4110
4357
 
4111
4358
  // src/tool/code-interpreter.ts
4112
4359
  import {
4113
- createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema4,
4114
- lazySchema as lazySchema16,
4115
- zodSchema as zodSchema16
4360
+ createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema5,
4361
+ lazySchema as lazySchema17,
4362
+ zodSchema as zodSchema17
4116
4363
  } from "@ai-sdk/provider-utils";
4117
- import { z as z18 } from "zod/v4";
4118
- var codeInterpreterInputSchema = lazySchema16(
4119
- () => zodSchema16(
4120
- z18.object({
4121
- code: z18.string().nullish(),
4122
- containerId: z18.string()
4364
+ import { z as z19 } from "zod/v4";
4365
+ var codeInterpreterInputSchema = lazySchema17(
4366
+ () => zodSchema17(
4367
+ z19.object({
4368
+ code: z19.string().nullish(),
4369
+ containerId: z19.string()
4123
4370
  })
4124
4371
  )
4125
4372
  );
4126
- var codeInterpreterOutputSchema = lazySchema16(
4127
- () => zodSchema16(
4128
- z18.object({
4129
- outputs: z18.array(
4130
- z18.discriminatedUnion("type", [
4131
- z18.object({ type: z18.literal("logs"), logs: z18.string() }),
4132
- z18.object({ type: z18.literal("image"), url: z18.string() })
4373
+ var codeInterpreterOutputSchema = lazySchema17(
4374
+ () => zodSchema17(
4375
+ z19.object({
4376
+ outputs: z19.array(
4377
+ z19.discriminatedUnion("type", [
4378
+ z19.object({ type: z19.literal("logs"), logs: z19.string() }),
4379
+ z19.object({ type: z19.literal("image"), url: z19.string() })
4133
4380
  ])
4134
4381
  ).nullish()
4135
4382
  })
4136
4383
  )
4137
4384
  );
4138
- var codeInterpreterArgsSchema = lazySchema16(
4139
- () => zodSchema16(
4140
- z18.object({
4141
- container: z18.union([
4142
- z18.string(),
4143
- z18.object({
4144
- fileIds: z18.array(z18.string()).optional()
4385
+ var codeInterpreterArgsSchema = lazySchema17(
4386
+ () => zodSchema17(
4387
+ z19.object({
4388
+ container: z19.union([
4389
+ z19.string(),
4390
+ z19.object({
4391
+ fileIds: z19.array(z19.string()).optional()
4145
4392
  })
4146
4393
  ]).optional()
4147
4394
  })
4148
4395
  )
4149
4396
  );
4150
- var codeInterpreterToolFactory = createProviderToolFactoryWithOutputSchema4({
4397
+ var codeInterpreterToolFactory = createProviderToolFactoryWithOutputSchema5({
4151
4398
  id: "openai.code_interpreter",
4152
4399
  inputSchema: codeInterpreterInputSchema,
4153
4400
  outputSchema: codeInterpreterOutputSchema
@@ -4158,88 +4405,88 @@ var codeInterpreter = (args = {}) => {
4158
4405
 
4159
4406
  // src/tool/file-search.ts
4160
4407
  import {
4161
- createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema5,
4162
- lazySchema as lazySchema17,
4163
- zodSchema as zodSchema17
4408
+ createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema6,
4409
+ lazySchema as lazySchema18,
4410
+ zodSchema as zodSchema18
4164
4411
  } from "@ai-sdk/provider-utils";
4165
- import { z as z19 } from "zod/v4";
4166
- var comparisonFilterSchema = z19.object({
4167
- key: z19.string(),
4168
- type: z19.enum(["eq", "ne", "gt", "gte", "lt", "lte", "in", "nin"]),
4169
- value: z19.union([z19.string(), z19.number(), z19.boolean(), z19.array(z19.string())])
4412
+ import { z as z20 } from "zod/v4";
4413
+ var comparisonFilterSchema = z20.object({
4414
+ key: z20.string(),
4415
+ type: z20.enum(["eq", "ne", "gt", "gte", "lt", "lte", "in", "nin"]),
4416
+ value: z20.union([z20.string(), z20.number(), z20.boolean(), z20.array(z20.string())])
4170
4417
  });
4171
- var compoundFilterSchema = z19.object({
4172
- type: z19.enum(["and", "or"]),
4173
- filters: z19.array(
4174
- z19.union([comparisonFilterSchema, z19.lazy(() => compoundFilterSchema)])
4418
+ var compoundFilterSchema = z20.object({
4419
+ type: z20.enum(["and", "or"]),
4420
+ filters: z20.array(
4421
+ z20.union([comparisonFilterSchema, z20.lazy(() => compoundFilterSchema)])
4175
4422
  )
4176
4423
  });
4177
- var fileSearchArgsSchema = lazySchema17(
4178
- () => zodSchema17(
4179
- z19.object({
4180
- vectorStoreIds: z19.array(z19.string()),
4181
- maxNumResults: z19.number().optional(),
4182
- ranking: z19.object({
4183
- ranker: z19.string().optional(),
4184
- scoreThreshold: z19.number().optional()
4424
+ var fileSearchArgsSchema = lazySchema18(
4425
+ () => zodSchema18(
4426
+ z20.object({
4427
+ vectorStoreIds: z20.array(z20.string()),
4428
+ maxNumResults: z20.number().optional(),
4429
+ ranking: z20.object({
4430
+ ranker: z20.string().optional(),
4431
+ scoreThreshold: z20.number().optional()
4185
4432
  }).optional(),
4186
- filters: z19.union([comparisonFilterSchema, compoundFilterSchema]).optional()
4433
+ filters: z20.union([comparisonFilterSchema, compoundFilterSchema]).optional()
4187
4434
  })
4188
4435
  )
4189
4436
  );
4190
- var fileSearchOutputSchema = lazySchema17(
4191
- () => zodSchema17(
4192
- z19.object({
4193
- queries: z19.array(z19.string()),
4194
- results: z19.array(
4195
- z19.object({
4196
- attributes: z19.record(z19.string(), z19.unknown()),
4197
- fileId: z19.string(),
4198
- filename: z19.string(),
4199
- score: z19.number(),
4200
- text: z19.string()
4437
+ var fileSearchOutputSchema = lazySchema18(
4438
+ () => zodSchema18(
4439
+ z20.object({
4440
+ queries: z20.array(z20.string()),
4441
+ results: z20.array(
4442
+ z20.object({
4443
+ attributes: z20.record(z20.string(), z20.unknown()),
4444
+ fileId: z20.string(),
4445
+ filename: z20.string(),
4446
+ score: z20.number(),
4447
+ text: z20.string()
4201
4448
  })
4202
4449
  ).nullable()
4203
4450
  })
4204
4451
  )
4205
4452
  );
4206
- var fileSearch = createProviderToolFactoryWithOutputSchema5({
4453
+ var fileSearch = createProviderToolFactoryWithOutputSchema6({
4207
4454
  id: "openai.file_search",
4208
- inputSchema: z19.object({}),
4455
+ inputSchema: z20.object({}),
4209
4456
  outputSchema: fileSearchOutputSchema
4210
4457
  });
4211
4458
 
4212
4459
  // src/tool/image-generation.ts
4213
4460
  import {
4214
- createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema6,
4215
- lazySchema as lazySchema18,
4216
- zodSchema as zodSchema18
4461
+ createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema7,
4462
+ lazySchema as lazySchema19,
4463
+ zodSchema as zodSchema19
4217
4464
  } from "@ai-sdk/provider-utils";
4218
- import { z as z20 } from "zod/v4";
4219
- var imageGenerationArgsSchema = lazySchema18(
4220
- () => zodSchema18(
4221
- z20.object({
4222
- background: z20.enum(["auto", "opaque", "transparent"]).optional(),
4223
- inputFidelity: z20.enum(["low", "high"]).optional(),
4224
- inputImageMask: z20.object({
4225
- fileId: z20.string().optional(),
4226
- imageUrl: z20.string().optional()
4465
+ import { z as z21 } from "zod/v4";
4466
+ var imageGenerationArgsSchema = lazySchema19(
4467
+ () => zodSchema19(
4468
+ z21.object({
4469
+ background: z21.enum(["auto", "opaque", "transparent"]).optional(),
4470
+ inputFidelity: z21.enum(["low", "high"]).optional(),
4471
+ inputImageMask: z21.object({
4472
+ fileId: z21.string().optional(),
4473
+ imageUrl: z21.string().optional()
4227
4474
  }).optional(),
4228
- model: z20.string().optional(),
4229
- moderation: z20.enum(["auto"]).optional(),
4230
- outputCompression: z20.number().int().min(0).max(100).optional(),
4231
- outputFormat: z20.enum(["png", "jpeg", "webp"]).optional(),
4232
- partialImages: z20.number().int().min(0).max(3).optional(),
4233
- quality: z20.enum(["auto", "low", "medium", "high"]).optional(),
4234
- size: z20.enum(["1024x1024", "1024x1536", "1536x1024", "auto"]).optional()
4475
+ model: z21.string().optional(),
4476
+ moderation: z21.enum(["auto"]).optional(),
4477
+ outputCompression: z21.number().int().min(0).max(100).optional(),
4478
+ outputFormat: z21.enum(["png", "jpeg", "webp"]).optional(),
4479
+ partialImages: z21.number().int().min(0).max(3).optional(),
4480
+ quality: z21.enum(["auto", "low", "medium", "high"]).optional(),
4481
+ size: z21.enum(["1024x1024", "1024x1536", "1536x1024", "auto"]).optional()
4235
4482
  }).strict()
4236
4483
  )
4237
4484
  );
4238
- var imageGenerationInputSchema = lazySchema18(() => zodSchema18(z20.object({})));
4239
- var imageGenerationOutputSchema = lazySchema18(
4240
- () => zodSchema18(z20.object({ result: z20.string() }))
4485
+ var imageGenerationInputSchema = lazySchema19(() => zodSchema19(z21.object({})));
4486
+ var imageGenerationOutputSchema = lazySchema19(
4487
+ () => zodSchema19(z21.object({ result: z21.string() }))
4241
4488
  );
4242
- var imageGenerationToolFactory = createProviderToolFactoryWithOutputSchema6({
4489
+ var imageGenerationToolFactory = createProviderToolFactoryWithOutputSchema7({
4243
4490
  id: "openai.image_generation",
4244
4491
  inputSchema: imageGenerationInputSchema,
4245
4492
  outputSchema: imageGenerationOutputSchema
@@ -4251,29 +4498,28 @@ var imageGeneration = (args = {}) => {
4251
4498
  // src/tool/custom.ts
4252
4499
  import {
4253
4500
  createProviderToolFactory,
4254
- lazySchema as lazySchema19,
4255
- zodSchema as zodSchema19
4501
+ lazySchema as lazySchema20,
4502
+ zodSchema as zodSchema20
4256
4503
  } from "@ai-sdk/provider-utils";
4257
- import { z as z21 } from "zod/v4";
4258
- var customArgsSchema = lazySchema19(
4259
- () => zodSchema19(
4260
- z21.object({
4261
- name: z21.string(),
4262
- description: z21.string().optional(),
4263
- format: z21.union([
4264
- z21.object({
4265
- type: z21.literal("grammar"),
4266
- syntax: z21.enum(["regex", "lark"]),
4267
- definition: z21.string()
4504
+ import { z as z22 } from "zod/v4";
4505
+ var customArgsSchema = lazySchema20(
4506
+ () => zodSchema20(
4507
+ z22.object({
4508
+ description: z22.string().optional(),
4509
+ format: z22.union([
4510
+ z22.object({
4511
+ type: z22.literal("grammar"),
4512
+ syntax: z22.enum(["regex", "lark"]),
4513
+ definition: z22.string()
4268
4514
  }),
4269
- z21.object({
4270
- type: z21.literal("text")
4515
+ z22.object({
4516
+ type: z22.literal("text")
4271
4517
  })
4272
4518
  ]).optional()
4273
4519
  })
4274
4520
  )
4275
4521
  );
4276
- var customInputSchema = lazySchema19(() => zodSchema19(z21.string()));
4522
+ var customInputSchema = lazySchema20(() => zodSchema20(z22.string()));
4277
4523
  var customToolFactory = createProviderToolFactory({
4278
4524
  id: "openai.custom",
4279
4525
  inputSchema: customInputSchema
@@ -4281,137 +4527,82 @@ var customToolFactory = createProviderToolFactory({
4281
4527
 
4282
4528
  // src/tool/mcp.ts
4283
4529
  import {
4284
- createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema7,
4285
- lazySchema as lazySchema20,
4286
- zodSchema as zodSchema20
4530
+ createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema8,
4531
+ lazySchema as lazySchema21,
4532
+ zodSchema as zodSchema21
4287
4533
  } from "@ai-sdk/provider-utils";
4288
- import { z as z22 } from "zod/v4";
4289
- var jsonValueSchema = z22.lazy(
4290
- () => z22.union([
4291
- z22.string(),
4292
- z22.number(),
4293
- z22.boolean(),
4294
- z22.null(),
4295
- z22.array(jsonValueSchema),
4296
- z22.record(z22.string(), jsonValueSchema)
4534
+ import { z as z23 } from "zod/v4";
4535
+ var jsonValueSchema2 = z23.lazy(
4536
+ () => z23.union([
4537
+ z23.string(),
4538
+ z23.number(),
4539
+ z23.boolean(),
4540
+ z23.null(),
4541
+ z23.array(jsonValueSchema2),
4542
+ z23.record(z23.string(), jsonValueSchema2)
4297
4543
  ])
4298
4544
  );
4299
- var mcpArgsSchema = lazySchema20(
4300
- () => zodSchema20(
4301
- z22.object({
4302
- serverLabel: z22.string(),
4303
- allowedTools: z22.union([
4304
- z22.array(z22.string()),
4305
- z22.object({
4306
- readOnly: z22.boolean().optional(),
4307
- toolNames: z22.array(z22.string()).optional()
4545
+ var mcpArgsSchema = lazySchema21(
4546
+ () => zodSchema21(
4547
+ z23.object({
4548
+ serverLabel: z23.string(),
4549
+ allowedTools: z23.union([
4550
+ z23.array(z23.string()),
4551
+ z23.object({
4552
+ readOnly: z23.boolean().optional(),
4553
+ toolNames: z23.array(z23.string()).optional()
4308
4554
  })
4309
4555
  ]).optional(),
4310
- authorization: z22.string().optional(),
4311
- connectorId: z22.string().optional(),
4312
- headers: z22.record(z22.string(), z22.string()).optional(),
4313
- requireApproval: z22.union([
4314
- z22.enum(["always", "never"]),
4315
- z22.object({
4316
- never: z22.object({
4317
- toolNames: z22.array(z22.string()).optional()
4556
+ authorization: z23.string().optional(),
4557
+ connectorId: z23.string().optional(),
4558
+ headers: z23.record(z23.string(), z23.string()).optional(),
4559
+ requireApproval: z23.union([
4560
+ z23.enum(["always", "never"]),
4561
+ z23.object({
4562
+ never: z23.object({
4563
+ toolNames: z23.array(z23.string()).optional()
4318
4564
  }).optional()
4319
4565
  })
4320
4566
  ]).optional(),
4321
- serverDescription: z22.string().optional(),
4322
- serverUrl: z22.string().optional()
4567
+ serverDescription: z23.string().optional(),
4568
+ serverUrl: z23.string().optional()
4323
4569
  }).refine(
4324
4570
  (v) => v.serverUrl != null || v.connectorId != null,
4325
4571
  "One of serverUrl or connectorId must be provided."
4326
4572
  )
4327
4573
  )
4328
4574
  );
4329
- var mcpInputSchema = lazySchema20(() => zodSchema20(z22.object({})));
4330
- var mcpOutputSchema = lazySchema20(
4331
- () => zodSchema20(
4332
- z22.object({
4333
- type: z22.literal("call"),
4334
- serverLabel: z22.string(),
4335
- name: z22.string(),
4336
- arguments: z22.string(),
4337
- output: z22.string().nullish(),
4338
- error: z22.union([z22.string(), jsonValueSchema]).optional()
4575
+ var mcpInputSchema = lazySchema21(() => zodSchema21(z23.object({})));
4576
+ var mcpOutputSchema = lazySchema21(
4577
+ () => zodSchema21(
4578
+ z23.object({
4579
+ type: z23.literal("call"),
4580
+ serverLabel: z23.string(),
4581
+ name: z23.string(),
4582
+ arguments: z23.string(),
4583
+ output: z23.string().nullish(),
4584
+ error: z23.union([z23.string(), jsonValueSchema2]).optional()
4339
4585
  })
4340
4586
  )
4341
4587
  );
4342
- var mcpToolFactory = createProviderToolFactoryWithOutputSchema7({
4588
+ var mcpToolFactory = createProviderToolFactoryWithOutputSchema8({
4343
4589
  id: "openai.mcp",
4344
4590
  inputSchema: mcpInputSchema,
4345
4591
  outputSchema: mcpOutputSchema
4346
4592
  });
4347
4593
 
4348
4594
  // src/tool/web-search.ts
4349
- import {
4350
- createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema8,
4351
- lazySchema as lazySchema21,
4352
- zodSchema as zodSchema21
4353
- } from "@ai-sdk/provider-utils";
4354
- import { z as z23 } from "zod/v4";
4355
- var webSearchArgsSchema = lazySchema21(
4356
- () => zodSchema21(
4357
- z23.object({
4358
- externalWebAccess: z23.boolean().optional(),
4359
- filters: z23.object({ allowedDomains: z23.array(z23.string()).optional() }).optional(),
4360
- searchContextSize: z23.enum(["low", "medium", "high"]).optional(),
4361
- userLocation: z23.object({
4362
- type: z23.literal("approximate"),
4363
- country: z23.string().optional(),
4364
- city: z23.string().optional(),
4365
- region: z23.string().optional(),
4366
- timezone: z23.string().optional()
4367
- }).optional()
4368
- })
4369
- )
4370
- );
4371
- var webSearchInputSchema = lazySchema21(() => zodSchema21(z23.object({})));
4372
- var webSearchOutputSchema = lazySchema21(
4373
- () => zodSchema21(
4374
- z23.object({
4375
- action: z23.discriminatedUnion("type", [
4376
- z23.object({
4377
- type: z23.literal("search"),
4378
- query: z23.string().optional()
4379
- }),
4380
- z23.object({
4381
- type: z23.literal("openPage"),
4382
- url: z23.string().nullish()
4383
- }),
4384
- z23.object({
4385
- type: z23.literal("findInPage"),
4386
- url: z23.string().nullish(),
4387
- pattern: z23.string().nullish()
4388
- })
4389
- ]).optional(),
4390
- sources: z23.array(
4391
- z23.discriminatedUnion("type", [
4392
- z23.object({ type: z23.literal("url"), url: z23.string() }),
4393
- z23.object({ type: z23.literal("api"), name: z23.string() })
4394
- ])
4395
- ).optional()
4396
- })
4397
- )
4398
- );
4399
- var webSearchToolFactory = createProviderToolFactoryWithOutputSchema8({
4400
- id: "openai.web_search",
4401
- inputSchema: webSearchInputSchema,
4402
- outputSchema: webSearchOutputSchema
4403
- });
4404
-
4405
- // src/tool/web-search-preview.ts
4406
4595
  import {
4407
4596
  createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema9,
4408
4597
  lazySchema as lazySchema22,
4409
4598
  zodSchema as zodSchema22
4410
4599
  } from "@ai-sdk/provider-utils";
4411
4600
  import { z as z24 } from "zod/v4";
4412
- var webSearchPreviewArgsSchema = lazySchema22(
4601
+ var webSearchArgsSchema = lazySchema22(
4413
4602
  () => zodSchema22(
4414
4603
  z24.object({
4604
+ externalWebAccess: z24.boolean().optional(),
4605
+ filters: z24.object({ allowedDomains: z24.array(z24.string()).optional() }).optional(),
4415
4606
  searchContextSize: z24.enum(["low", "medium", "high"]).optional(),
4416
4607
  userLocation: z24.object({
4417
4608
  type: z24.literal("approximate"),
@@ -4423,10 +4614,8 @@ var webSearchPreviewArgsSchema = lazySchema22(
4423
4614
  })
4424
4615
  )
4425
4616
  );
4426
- var webSearchPreviewInputSchema = lazySchema22(
4427
- () => zodSchema22(z24.object({}))
4428
- );
4429
- var webSearchPreviewOutputSchema = lazySchema22(
4617
+ var webSearchInputSchema = lazySchema22(() => zodSchema22(z24.object({})));
4618
+ var webSearchOutputSchema = lazySchema22(
4430
4619
  () => zodSchema22(
4431
4620
  z24.object({
4432
4621
  action: z24.discriminatedUnion("type", [
@@ -4443,11 +4632,68 @@ var webSearchPreviewOutputSchema = lazySchema22(
4443
4632
  url: z24.string().nullish(),
4444
4633
  pattern: z24.string().nullish()
4445
4634
  })
4635
+ ]).optional(),
4636
+ sources: z24.array(
4637
+ z24.discriminatedUnion("type", [
4638
+ z24.object({ type: z24.literal("url"), url: z24.string() }),
4639
+ z24.object({ type: z24.literal("api"), name: z24.string() })
4640
+ ])
4641
+ ).optional()
4642
+ })
4643
+ )
4644
+ );
4645
+ var webSearchToolFactory = createProviderToolFactoryWithOutputSchema9({
4646
+ id: "openai.web_search",
4647
+ inputSchema: webSearchInputSchema,
4648
+ outputSchema: webSearchOutputSchema
4649
+ });
4650
+
4651
+ // src/tool/web-search-preview.ts
4652
+ import {
4653
+ createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema10,
4654
+ lazySchema as lazySchema23,
4655
+ zodSchema as zodSchema23
4656
+ } from "@ai-sdk/provider-utils";
4657
+ import { z as z25 } from "zod/v4";
4658
+ var webSearchPreviewArgsSchema = lazySchema23(
4659
+ () => zodSchema23(
4660
+ z25.object({
4661
+ searchContextSize: z25.enum(["low", "medium", "high"]).optional(),
4662
+ userLocation: z25.object({
4663
+ type: z25.literal("approximate"),
4664
+ country: z25.string().optional(),
4665
+ city: z25.string().optional(),
4666
+ region: z25.string().optional(),
4667
+ timezone: z25.string().optional()
4668
+ }).optional()
4669
+ })
4670
+ )
4671
+ );
4672
+ var webSearchPreviewInputSchema = lazySchema23(
4673
+ () => zodSchema23(z25.object({}))
4674
+ );
4675
+ var webSearchPreviewOutputSchema = lazySchema23(
4676
+ () => zodSchema23(
4677
+ z25.object({
4678
+ action: z25.discriminatedUnion("type", [
4679
+ z25.object({
4680
+ type: z25.literal("search"),
4681
+ query: z25.string().optional()
4682
+ }),
4683
+ z25.object({
4684
+ type: z25.literal("openPage"),
4685
+ url: z25.string().nullish()
4686
+ }),
4687
+ z25.object({
4688
+ type: z25.literal("findInPage"),
4689
+ url: z25.string().nullish(),
4690
+ pattern: z25.string().nullish()
4691
+ })
4446
4692
  ]).optional()
4447
4693
  })
4448
4694
  )
4449
4695
  );
4450
- var webSearchPreview = createProviderToolFactoryWithOutputSchema9({
4696
+ var webSearchPreview = createProviderToolFactoryWithOutputSchema10({
4451
4697
  id: "openai.web_search_preview",
4452
4698
  inputSchema: webSearchPreviewInputSchema,
4453
4699
  outputSchema: webSearchPreviewOutputSchema
@@ -4460,7 +4706,7 @@ async function prepareResponsesTools({
4460
4706
  toolNameMapping,
4461
4707
  customProviderToolNames
4462
4708
  }) {
4463
- var _a;
4709
+ var _a, _b;
4464
4710
  tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
4465
4711
  const toolWarnings = [];
4466
4712
  if (tools == null) {
@@ -4470,15 +4716,19 @@ async function prepareResponsesTools({
4470
4716
  const resolvedCustomProviderToolNames = customProviderToolNames != null ? customProviderToolNames : /* @__PURE__ */ new Set();
4471
4717
  for (const tool of tools) {
4472
4718
  switch (tool.type) {
4473
- case "function":
4719
+ case "function": {
4720
+ const openaiOptions = (_a = tool.providerOptions) == null ? void 0 : _a.openai;
4721
+ const deferLoading = openaiOptions == null ? void 0 : openaiOptions.deferLoading;
4474
4722
  openaiTools.push({
4475
4723
  type: "function",
4476
4724
  name: tool.name,
4477
4725
  description: tool.description,
4478
4726
  parameters: tool.inputSchema,
4479
- ...tool.strict != null ? { strict: tool.strict } : {}
4727
+ ...tool.strict != null ? { strict: tool.strict } : {},
4728
+ ...deferLoading != null ? { defer_loading: deferLoading } : {}
4480
4729
  });
4481
4730
  break;
4731
+ }
4482
4732
  case "provider": {
4483
4733
  switch (tool.id) {
4484
4734
  case "openai.file_search": {
@@ -4616,11 +4866,24 @@ async function prepareResponsesTools({
4616
4866
  });
4617
4867
  openaiTools.push({
4618
4868
  type: "custom",
4619
- name: args.name,
4869
+ name: tool.name,
4620
4870
  description: args.description,
4621
4871
  format: args.format
4622
4872
  });
4623
- resolvedCustomProviderToolNames.add(args.name);
4873
+ resolvedCustomProviderToolNames.add(tool.name);
4874
+ break;
4875
+ }
4876
+ case "openai.tool_search": {
4877
+ const args = await validateTypes2({
4878
+ value: tool.args,
4879
+ schema: toolSearchArgsSchema
4880
+ });
4881
+ openaiTools.push({
4882
+ type: "tool_search",
4883
+ ...args.execution != null ? { execution: args.execution } : {},
4884
+ ...args.description != null ? { description: args.description } : {},
4885
+ ...args.parameters != null ? { parameters: args.parameters } : {}
4886
+ });
4624
4887
  break;
4625
4888
  }
4626
4889
  }
@@ -4644,7 +4907,7 @@ async function prepareResponsesTools({
4644
4907
  case "required":
4645
4908
  return { tools: openaiTools, toolChoice: type, toolWarnings };
4646
4909
  case "tool": {
4647
- const resolvedToolName = (_a = toolNameMapping == null ? void 0 : toolNameMapping.toProviderToolName(toolChoice.toolName)) != null ? _a : toolChoice.toolName;
4910
+ const resolvedToolName = (_b = toolNameMapping == null ? void 0 : toolNameMapping.toProviderToolName(toolChoice.toolName)) != null ? _b : toolChoice.toolName;
4648
4911
  return {
4649
4912
  tools: openaiTools,
4650
4913
  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 },
@@ -4724,7 +4987,7 @@ function extractApprovalRequestIdToToolCallIdMapping(prompt) {
4724
4987
  }
4725
4988
  var OpenAIResponsesLanguageModel = class {
4726
4989
  constructor(modelId, config) {
4727
- this.specificationVersion = "v3";
4990
+ this.specificationVersion = "v4";
4728
4991
  this.supportedUrls = {
4729
4992
  "image/*": [/^https?:\/\/.*$/],
4730
4993
  "application/pdf": [/^https?:\/\/.*$/]
@@ -4745,12 +5008,13 @@ var OpenAIResponsesLanguageModel = class {
4745
5008
  frequencyPenalty,
4746
5009
  seed,
4747
5010
  prompt,
5011
+ reasoning,
4748
5012
  providerOptions,
4749
5013
  tools,
4750
5014
  toolChoice,
4751
5015
  responseFormat
4752
5016
  }) {
4753
- var _a, _b, _c, _d, _e, _f, _g, _h, _i;
5017
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
4754
5018
  const warnings = [];
4755
5019
  const modelCapabilities = getOpenAILanguageModelCapabilities(this.modelId);
4756
5020
  if (topK != null) {
@@ -4781,7 +5045,8 @@ var OpenAIResponsesLanguageModel = class {
4781
5045
  schema: openaiLanguageModelResponsesOptionsSchema
4782
5046
  });
4783
5047
  }
4784
- const isReasoningModel = (_a = openaiOptions == null ? void 0 : openaiOptions.forceReasoning) != null ? _a : modelCapabilities.isReasoningModel;
5048
+ const resolvedReasoningEffort = (_a = openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null ? _a : isCustomReasoning2(reasoning) ? reasoning : void 0;
5049
+ const isReasoningModel = (_b = openaiOptions == null ? void 0 : openaiOptions.forceReasoning) != null ? _b : modelCapabilities.isReasoningModel;
4785
5050
  if ((openaiOptions == null ? void 0 : openaiOptions.conversation) && (openaiOptions == null ? void 0 : openaiOptions.previousResponseId)) {
4786
5051
  warnings.push({
4787
5052
  type: "unsupported",
@@ -4800,9 +5065,9 @@ var OpenAIResponsesLanguageModel = class {
4800
5065
  "openai.web_search": "web_search",
4801
5066
  "openai.web_search_preview": "web_search_preview",
4802
5067
  "openai.mcp": "mcp",
4803
- "openai.apply_patch": "apply_patch"
4804
- },
4805
- resolveProviderToolName: (tool) => tool.id === "openai.custom" ? tool.args.name : void 0
5068
+ "openai.apply_patch": "apply_patch",
5069
+ "openai.tool_search": "tool_search"
5070
+ }
4806
5071
  });
4807
5072
  const customProviderToolNames = /* @__PURE__ */ new Set();
4808
5073
  const {
@@ -4818,10 +5083,10 @@ var OpenAIResponsesLanguageModel = class {
4818
5083
  const { input, warnings: inputWarnings } = await convertToOpenAIResponsesInput({
4819
5084
  prompt,
4820
5085
  toolNameMapping,
4821
- systemMessageMode: (_b = openaiOptions == null ? void 0 : openaiOptions.systemMessageMode) != null ? _b : isReasoningModel ? "developer" : modelCapabilities.systemMessageMode,
5086
+ systemMessageMode: (_c = openaiOptions == null ? void 0 : openaiOptions.systemMessageMode) != null ? _c : isReasoningModel ? "developer" : modelCapabilities.systemMessageMode,
4822
5087
  providerOptionsName,
4823
5088
  fileIdPrefixes: this.config.fileIdPrefixes,
4824
- store: (_c = openaiOptions == null ? void 0 : openaiOptions.store) != null ? _c : true,
5089
+ store: (_d = openaiOptions == null ? void 0 : openaiOptions.store) != null ? _d : true,
4825
5090
  hasConversation: (openaiOptions == null ? void 0 : openaiOptions.conversation) != null,
4826
5091
  hasLocalShellTool: hasOpenAITool("openai.local_shell"),
4827
5092
  hasShellTool: hasOpenAITool("openai.shell"),
@@ -4829,7 +5094,7 @@ var OpenAIResponsesLanguageModel = class {
4829
5094
  customProviderToolNames: customProviderToolNames.size > 0 ? customProviderToolNames : void 0
4830
5095
  });
4831
5096
  warnings.push(...inputWarnings);
4832
- const strictJsonSchema = (_d = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _d : true;
5097
+ const strictJsonSchema = (_e = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _e : true;
4833
5098
  let include = openaiOptions == null ? void 0 : openaiOptions.include;
4834
5099
  function addInclude(key) {
4835
5100
  if (include == null) {
@@ -4845,9 +5110,9 @@ var OpenAIResponsesLanguageModel = class {
4845
5110
  if (topLogprobs) {
4846
5111
  addInclude("message.output_text.logprobs");
4847
5112
  }
4848
- const webSearchToolName = (_e = tools == null ? void 0 : tools.find(
5113
+ const webSearchToolName = (_f = tools == null ? void 0 : tools.find(
4849
5114
  (tool) => tool.type === "provider" && (tool.id === "openai.web_search" || tool.id === "openai.web_search_preview")
4850
- )) == null ? void 0 : _e.name;
5115
+ )) == null ? void 0 : _f.name;
4851
5116
  if (webSearchToolName) {
4852
5117
  addInclude("web_search_call.action.sources");
4853
5118
  }
@@ -4870,7 +5135,7 @@ var OpenAIResponsesLanguageModel = class {
4870
5135
  format: responseFormat.schema != null ? {
4871
5136
  type: "json_schema",
4872
5137
  strict: strictJsonSchema,
4873
- name: (_f = responseFormat.name) != null ? _f : "response",
5138
+ name: (_g = responseFormat.name) != null ? _g : "response",
4874
5139
  description: responseFormat.description,
4875
5140
  schema: responseFormat.schema
4876
5141
  } : { type: "json_object" }
@@ -4896,11 +5161,18 @@ var OpenAIResponsesLanguageModel = class {
4896
5161
  safety_identifier: openaiOptions == null ? void 0 : openaiOptions.safetyIdentifier,
4897
5162
  top_logprobs: topLogprobs,
4898
5163
  truncation: openaiOptions == null ? void 0 : openaiOptions.truncation,
5164
+ // context management (server-side compaction):
5165
+ ...(openaiOptions == null ? void 0 : openaiOptions.contextManagement) && {
5166
+ context_management: openaiOptions.contextManagement.map((cm) => ({
5167
+ type: cm.type,
5168
+ compact_threshold: cm.compactThreshold
5169
+ }))
5170
+ },
4899
5171
  // model-specific settings:
4900
- ...isReasoningModel && ((openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null || (openaiOptions == null ? void 0 : openaiOptions.reasoningSummary) != null) && {
5172
+ ...isReasoningModel && (resolvedReasoningEffort != null || (openaiOptions == null ? void 0 : openaiOptions.reasoningSummary) != null) && {
4901
5173
  reasoning: {
4902
- ...(openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null && {
4903
- effort: openaiOptions.reasoningEffort
5174
+ ...resolvedReasoningEffort != null && {
5175
+ effort: resolvedReasoningEffort
4904
5176
  },
4905
5177
  ...(openaiOptions == null ? void 0 : openaiOptions.reasoningSummary) != null && {
4906
5178
  summary: openaiOptions.reasoningSummary
@@ -4909,7 +5181,7 @@ var OpenAIResponsesLanguageModel = class {
4909
5181
  }
4910
5182
  };
4911
5183
  if (isReasoningModel) {
4912
- if (!((openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) === "none" && modelCapabilities.supportsNonReasoningParameters)) {
5184
+ if (!(resolvedReasoningEffort === "none" && modelCapabilities.supportsNonReasoningParameters)) {
4913
5185
  if (baseArgs.temperature != null) {
4914
5186
  baseArgs.temperature = void 0;
4915
5187
  warnings.push({
@@ -4959,9 +5231,9 @@ var OpenAIResponsesLanguageModel = class {
4959
5231
  });
4960
5232
  delete baseArgs.service_tier;
4961
5233
  }
4962
- const shellToolEnvType = (_i = (_h = (_g = tools == null ? void 0 : tools.find(
5234
+ const shellToolEnvType = (_j = (_i = (_h = tools == null ? void 0 : tools.find(
4963
5235
  (tool) => tool.type === "provider" && tool.id === "openai.shell"
4964
- )) == null ? void 0 : _g.args) == null ? void 0 : _h.environment) == null ? void 0 : _i.type;
5236
+ )) == null ? void 0 : _h.args) == null ? void 0 : _i.environment) == null ? void 0 : _j.type;
4965
5237
  const isShellProviderExecuted = shellToolEnvType === "containerAuto" || shellToolEnvType === "containerReference";
4966
5238
  return {
4967
5239
  webSearchToolName,
@@ -4978,7 +5250,7 @@ var OpenAIResponsesLanguageModel = class {
4978
5250
  };
4979
5251
  }
4980
5252
  async doGenerate(options) {
4981
- 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;
5253
+ 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;
4982
5254
  const {
4983
5255
  args: body,
4984
5256
  warnings,
@@ -5021,6 +5293,7 @@ var OpenAIResponsesLanguageModel = class {
5021
5293
  const content = [];
5022
5294
  const logprobs = [];
5023
5295
  let hasFunctionCall = false;
5296
+ const hostedToolSearchCallIds = [];
5024
5297
  for (const part of response.output) {
5025
5298
  switch (part.type) {
5026
5299
  case "reasoning": {
@@ -5059,6 +5332,46 @@ var OpenAIResponsesLanguageModel = class {
5059
5332
  });
5060
5333
  break;
5061
5334
  }
5335
+ case "tool_search_call": {
5336
+ const toolCallId = (_b = part.call_id) != null ? _b : part.id;
5337
+ const isHosted = part.execution === "server";
5338
+ if (isHosted) {
5339
+ hostedToolSearchCallIds.push(toolCallId);
5340
+ }
5341
+ content.push({
5342
+ type: "tool-call",
5343
+ toolCallId,
5344
+ toolName: toolNameMapping.toCustomToolName("tool_search"),
5345
+ input: JSON.stringify({
5346
+ arguments: part.arguments,
5347
+ call_id: part.call_id
5348
+ }),
5349
+ ...isHosted ? { providerExecuted: true } : {},
5350
+ providerMetadata: {
5351
+ [providerOptionsName]: {
5352
+ itemId: part.id
5353
+ }
5354
+ }
5355
+ });
5356
+ break;
5357
+ }
5358
+ case "tool_search_output": {
5359
+ const toolCallId = (_d = (_c = part.call_id) != null ? _c : hostedToolSearchCallIds.shift()) != null ? _d : part.id;
5360
+ content.push({
5361
+ type: "tool-result",
5362
+ toolCallId,
5363
+ toolName: toolNameMapping.toCustomToolName("tool_search"),
5364
+ result: {
5365
+ tools: part.tools
5366
+ },
5367
+ providerMetadata: {
5368
+ [providerOptionsName]: {
5369
+ itemId: part.id
5370
+ }
5371
+ }
5372
+ });
5373
+ break;
5374
+ }
5062
5375
  case "local_shell_call": {
5063
5376
  content.push({
5064
5377
  type: "tool-call",
@@ -5114,7 +5427,7 @@ var OpenAIResponsesLanguageModel = class {
5114
5427
  }
5115
5428
  case "message": {
5116
5429
  for (const contentPart of part.content) {
5117
- if (((_c = (_b = options.providerOptions) == null ? void 0 : _b[providerOptionsName]) == null ? void 0 : _c.logprobs) && contentPart.logprobs) {
5430
+ if (((_f = (_e = options.providerOptions) == null ? void 0 : _e[providerOptionsName]) == null ? void 0 : _f.logprobs) && contentPart.logprobs) {
5118
5431
  logprobs.push(contentPart.logprobs);
5119
5432
  }
5120
5433
  const providerMetadata2 = {
@@ -5136,7 +5449,7 @@ var OpenAIResponsesLanguageModel = class {
5136
5449
  content.push({
5137
5450
  type: "source",
5138
5451
  sourceType: "url",
5139
- id: (_f = (_e = (_d = this.config).generateId) == null ? void 0 : _e.call(_d)) != null ? _f : generateId2(),
5452
+ id: (_i = (_h = (_g = this.config).generateId) == null ? void 0 : _h.call(_g)) != null ? _i : generateId2(),
5140
5453
  url: annotation.url,
5141
5454
  title: annotation.title
5142
5455
  });
@@ -5144,7 +5457,7 @@ var OpenAIResponsesLanguageModel = class {
5144
5457
  content.push({
5145
5458
  type: "source",
5146
5459
  sourceType: "document",
5147
- id: (_i = (_h = (_g = this.config).generateId) == null ? void 0 : _h.call(_g)) != null ? _i : generateId2(),
5460
+ id: (_l = (_k = (_j = this.config).generateId) == null ? void 0 : _k.call(_j)) != null ? _l : generateId2(),
5148
5461
  mediaType: "text/plain",
5149
5462
  title: annotation.filename,
5150
5463
  filename: annotation.filename,
@@ -5160,7 +5473,7 @@ var OpenAIResponsesLanguageModel = class {
5160
5473
  content.push({
5161
5474
  type: "source",
5162
5475
  sourceType: "document",
5163
- id: (_l = (_k = (_j = this.config).generateId) == null ? void 0 : _k.call(_j)) != null ? _l : generateId2(),
5476
+ id: (_o = (_n = (_m = this.config).generateId) == null ? void 0 : _n.call(_m)) != null ? _o : generateId2(),
5164
5477
  mediaType: "text/plain",
5165
5478
  title: annotation.filename,
5166
5479
  filename: annotation.filename,
@@ -5176,7 +5489,7 @@ var OpenAIResponsesLanguageModel = class {
5176
5489
  content.push({
5177
5490
  type: "source",
5178
5491
  sourceType: "document",
5179
- id: (_o = (_n = (_m = this.config).generateId) == null ? void 0 : _n.call(_m)) != null ? _o : generateId2(),
5492
+ id: (_r = (_q = (_p = this.config).generateId) == null ? void 0 : _q.call(_p)) != null ? _r : generateId2(),
5180
5493
  mediaType: "application/octet-stream",
5181
5494
  title: annotation.file_id,
5182
5495
  filename: annotation.file_id,
@@ -5245,7 +5558,7 @@ var OpenAIResponsesLanguageModel = class {
5245
5558
  break;
5246
5559
  }
5247
5560
  case "mcp_call": {
5248
- const toolCallId = part.approval_request_id != null ? (_p = approvalRequestIdToDummyToolCallIdFromPrompt[part.approval_request_id]) != null ? _p : part.id : part.id;
5561
+ const toolCallId = part.approval_request_id != null ? (_s = approvalRequestIdToDummyToolCallIdFromPrompt[part.approval_request_id]) != null ? _s : part.id : part.id;
5249
5562
  const toolName = `mcp.${part.name}`;
5250
5563
  content.push({
5251
5564
  type: "tool-call",
@@ -5279,8 +5592,8 @@ var OpenAIResponsesLanguageModel = class {
5279
5592
  break;
5280
5593
  }
5281
5594
  case "mcp_approval_request": {
5282
- const approvalRequestId = (_q = part.approval_request_id) != null ? _q : part.id;
5283
- const dummyToolCallId = (_t = (_s = (_r = this.config).generateId) == null ? void 0 : _s.call(_r)) != null ? _t : generateId2();
5595
+ const approvalRequestId = (_t = part.approval_request_id) != null ? _t : part.id;
5596
+ const dummyToolCallId = (_w = (_v = (_u = this.config).generateId) == null ? void 0 : _v.call(_u)) != null ? _w : generateId2();
5284
5597
  const toolName = `mcp.${part.name}`;
5285
5598
  content.push({
5286
5599
  type: "tool-call",
@@ -5330,13 +5643,13 @@ var OpenAIResponsesLanguageModel = class {
5330
5643
  toolName: toolNameMapping.toCustomToolName("file_search"),
5331
5644
  result: {
5332
5645
  queries: part.queries,
5333
- results: (_v = (_u = part.results) == null ? void 0 : _u.map((result) => ({
5646
+ results: (_y = (_x = part.results) == null ? void 0 : _x.map((result) => ({
5334
5647
  attributes: result.attributes,
5335
5648
  fileId: result.file_id,
5336
5649
  filename: result.filename,
5337
5650
  score: result.score,
5338
5651
  text: result.text
5339
- }))) != null ? _v : null
5652
+ }))) != null ? _y : null
5340
5653
  }
5341
5654
  });
5342
5655
  break;
@@ -5379,6 +5692,20 @@ var OpenAIResponsesLanguageModel = class {
5379
5692
  });
5380
5693
  break;
5381
5694
  }
5695
+ case "compaction": {
5696
+ content.push({
5697
+ type: "custom",
5698
+ kind: "openai.compaction",
5699
+ providerMetadata: {
5700
+ [providerOptionsName]: {
5701
+ type: "compaction",
5702
+ itemId: part.id,
5703
+ encryptedContent: part.encrypted_content
5704
+ }
5705
+ }
5706
+ });
5707
+ break;
5708
+ }
5382
5709
  }
5383
5710
  }
5384
5711
  const providerMetadata = {
@@ -5393,10 +5720,10 @@ var OpenAIResponsesLanguageModel = class {
5393
5720
  content,
5394
5721
  finishReason: {
5395
5722
  unified: mapOpenAIResponseFinishReason({
5396
- finishReason: (_w = response.incomplete_details) == null ? void 0 : _w.reason,
5723
+ finishReason: (_z = response.incomplete_details) == null ? void 0 : _z.reason,
5397
5724
  hasFunctionCall
5398
5725
  }),
5399
- raw: (_y = (_x = response.incomplete_details) == null ? void 0 : _x.reason) != null ? _y : void 0
5726
+ raw: (_B = (_A = response.incomplete_details) == null ? void 0 : _A.reason) != null ? _B : void 0
5400
5727
  },
5401
5728
  usage: convertOpenAIResponsesUsage(usage),
5402
5729
  request: { body },
@@ -5454,6 +5781,7 @@ var OpenAIResponsesLanguageModel = class {
5454
5781
  let hasFunctionCall = false;
5455
5782
  const activeReasoning = {};
5456
5783
  let serviceTier;
5784
+ const hostedToolSearchCallIds = [];
5457
5785
  return {
5458
5786
  stream: response.pipeThrough(
5459
5787
  new TransformStream({
@@ -5461,7 +5789,7 @@ var OpenAIResponsesLanguageModel = class {
5461
5789
  controller.enqueue({ type: "stream-start", warnings });
5462
5790
  },
5463
5791
  transform(chunk, controller) {
5464
- 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;
5792
+ 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;
5465
5793
  if (options.includeRawChunks) {
5466
5794
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
5467
5795
  }
@@ -5569,6 +5897,24 @@ var OpenAIResponsesLanguageModel = class {
5569
5897
  input: "{}",
5570
5898
  providerExecuted: true
5571
5899
  });
5900
+ } else if (value.item.type === "tool_search_call") {
5901
+ const toolCallId = value.item.id;
5902
+ const toolName = toolNameMapping.toCustomToolName("tool_search");
5903
+ const isHosted = value.item.execution === "server";
5904
+ ongoingToolCalls[value.output_index] = {
5905
+ toolName,
5906
+ toolCallId,
5907
+ toolSearchExecution: (_a = value.item.execution) != null ? _a : "server"
5908
+ };
5909
+ if (isHosted) {
5910
+ controller.enqueue({
5911
+ type: "tool-input-start",
5912
+ id: toolCallId,
5913
+ toolName,
5914
+ providerExecuted: true
5915
+ });
5916
+ }
5917
+ } else if (value.item.type === "tool_search_output") {
5572
5918
  } else if (value.item.type === "mcp_call" || value.item.type === "mcp_list_tools" || value.item.type === "mcp_approval_request") {
5573
5919
  } else if (value.item.type === "apply_patch_call") {
5574
5920
  const { call_id: callId, operation } = value.item;
@@ -5615,7 +5961,7 @@ var OpenAIResponsesLanguageModel = class {
5615
5961
  } else if (value.item.type === "shell_call_output") {
5616
5962
  } else if (value.item.type === "message") {
5617
5963
  ongoingAnnotations.splice(0, ongoingAnnotations.length);
5618
- activeMessagePhase = (_a = value.item.phase) != null ? _a : void 0;
5964
+ activeMessagePhase = (_b = value.item.phase) != null ? _b : void 0;
5619
5965
  controller.enqueue({
5620
5966
  type: "text-start",
5621
5967
  id: value.item.id,
@@ -5639,14 +5985,14 @@ var OpenAIResponsesLanguageModel = class {
5639
5985
  providerMetadata: {
5640
5986
  [providerOptionsName]: {
5641
5987
  itemId: value.item.id,
5642
- reasoningEncryptedContent: (_b = value.item.encrypted_content) != null ? _b : null
5988
+ reasoningEncryptedContent: (_c = value.item.encrypted_content) != null ? _c : null
5643
5989
  }
5644
5990
  }
5645
5991
  });
5646
5992
  }
5647
5993
  } else if (isResponseOutputItemDoneChunk(value)) {
5648
5994
  if (value.item.type === "message") {
5649
- const phase = (_c = value.item.phase) != null ? _c : activeMessagePhase;
5995
+ const phase = (_d = value.item.phase) != null ? _d : activeMessagePhase;
5650
5996
  activeMessagePhase = void 0;
5651
5997
  controller.enqueue({
5652
5998
  type: "text-end",
@@ -5740,13 +6086,13 @@ var OpenAIResponsesLanguageModel = class {
5740
6086
  toolName: toolNameMapping.toCustomToolName("file_search"),
5741
6087
  result: {
5742
6088
  queries: value.item.queries,
5743
- results: (_e = (_d = value.item.results) == null ? void 0 : _d.map((result) => ({
6089
+ results: (_f = (_e = value.item.results) == null ? void 0 : _e.map((result) => ({
5744
6090
  attributes: result.attributes,
5745
6091
  fileId: result.file_id,
5746
6092
  filename: result.filename,
5747
6093
  score: result.score,
5748
6094
  text: result.text
5749
- }))) != null ? _e : null
6095
+ }))) != null ? _f : null
5750
6096
  }
5751
6097
  });
5752
6098
  } else if (value.item.type === "code_interpreter_call") {
@@ -5768,12 +6114,62 @@ var OpenAIResponsesLanguageModel = class {
5768
6114
  result: value.item.result
5769
6115
  }
5770
6116
  });
6117
+ } else if (value.item.type === "tool_search_call") {
6118
+ const toolCall = ongoingToolCalls[value.output_index];
6119
+ const isHosted = value.item.execution === "server";
6120
+ if (toolCall != null) {
6121
+ const toolCallId = isHosted ? toolCall.toolCallId : (_g = value.item.call_id) != null ? _g : value.item.id;
6122
+ if (isHosted) {
6123
+ hostedToolSearchCallIds.push(toolCallId);
6124
+ } else {
6125
+ controller.enqueue({
6126
+ type: "tool-input-start",
6127
+ id: toolCallId,
6128
+ toolName: toolCall.toolName
6129
+ });
6130
+ }
6131
+ controller.enqueue({
6132
+ type: "tool-input-end",
6133
+ id: toolCallId
6134
+ });
6135
+ controller.enqueue({
6136
+ type: "tool-call",
6137
+ toolCallId,
6138
+ toolName: toolCall.toolName,
6139
+ input: JSON.stringify({
6140
+ arguments: value.item.arguments,
6141
+ call_id: isHosted ? null : toolCallId
6142
+ }),
6143
+ ...isHosted ? { providerExecuted: true } : {},
6144
+ providerMetadata: {
6145
+ [providerOptionsName]: {
6146
+ itemId: value.item.id
6147
+ }
6148
+ }
6149
+ });
6150
+ }
6151
+ ongoingToolCalls[value.output_index] = void 0;
6152
+ } else if (value.item.type === "tool_search_output") {
6153
+ const toolCallId = (_i = (_h = value.item.call_id) != null ? _h : hostedToolSearchCallIds.shift()) != null ? _i : value.item.id;
6154
+ controller.enqueue({
6155
+ type: "tool-result",
6156
+ toolCallId,
6157
+ toolName: toolNameMapping.toCustomToolName("tool_search"),
6158
+ result: {
6159
+ tools: value.item.tools
6160
+ },
6161
+ providerMetadata: {
6162
+ [providerOptionsName]: {
6163
+ itemId: value.item.id
6164
+ }
6165
+ }
6166
+ });
5771
6167
  } else if (value.item.type === "mcp_call") {
5772
6168
  ongoingToolCalls[value.output_index] = void 0;
5773
- const approvalRequestId = (_f = value.item.approval_request_id) != null ? _f : void 0;
5774
- const aliasedToolCallId = approvalRequestId != null ? (_h = (_g = approvalRequestIdToDummyToolCallIdFromStream.get(
6169
+ const approvalRequestId = (_j = value.item.approval_request_id) != null ? _j : void 0;
6170
+ const aliasedToolCallId = approvalRequestId != null ? (_l = (_k = approvalRequestIdToDummyToolCallIdFromStream.get(
5775
6171
  approvalRequestId
5776
- )) != null ? _g : approvalRequestIdToDummyToolCallIdFromPrompt[approvalRequestId]) != null ? _h : value.item.id : value.item.id;
6172
+ )) != null ? _k : approvalRequestIdToDummyToolCallIdFromPrompt[approvalRequestId]) != null ? _l : value.item.id : value.item.id;
5777
6173
  const toolName = `mcp.${value.item.name}`;
5778
6174
  controller.enqueue({
5779
6175
  type: "tool-call",
@@ -5843,8 +6239,8 @@ var OpenAIResponsesLanguageModel = class {
5843
6239
  ongoingToolCalls[value.output_index] = void 0;
5844
6240
  } else if (value.item.type === "mcp_approval_request") {
5845
6241
  ongoingToolCalls[value.output_index] = void 0;
5846
- const dummyToolCallId = (_k = (_j = (_i = self.config).generateId) == null ? void 0 : _j.call(_i)) != null ? _k : generateId2();
5847
- const approvalRequestId = (_l = value.item.approval_request_id) != null ? _l : value.item.id;
6242
+ const dummyToolCallId = (_o = (_n = (_m = self.config).generateId) == null ? void 0 : _n.call(_m)) != null ? _o : generateId2();
6243
+ const approvalRequestId = (_p = value.item.approval_request_id) != null ? _p : value.item.id;
5848
6244
  approvalRequestIdToDummyToolCallIdFromStream.set(
5849
6245
  approvalRequestId,
5850
6246
  dummyToolCallId
@@ -5933,12 +6329,24 @@ var OpenAIResponsesLanguageModel = class {
5933
6329
  providerMetadata: {
5934
6330
  [providerOptionsName]: {
5935
6331
  itemId: value.item.id,
5936
- reasoningEncryptedContent: (_m = value.item.encrypted_content) != null ? _m : null
6332
+ reasoningEncryptedContent: (_q = value.item.encrypted_content) != null ? _q : null
5937
6333
  }
5938
6334
  }
5939
6335
  });
5940
6336
  }
5941
6337
  delete activeReasoning[value.item.id];
6338
+ } else if (value.item.type === "compaction") {
6339
+ controller.enqueue({
6340
+ type: "custom",
6341
+ kind: "openai.compaction",
6342
+ providerMetadata: {
6343
+ [providerOptionsName]: {
6344
+ type: "compaction",
6345
+ itemId: value.item.id,
6346
+ encryptedContent: value.item.encrypted_content
6347
+ }
6348
+ }
6349
+ });
5942
6350
  }
5943
6351
  } else if (isResponseFunctionCallArgumentsDeltaChunk(value)) {
5944
6352
  const toolCall = ongoingToolCalls[value.output_index];
@@ -6046,7 +6454,7 @@ var OpenAIResponsesLanguageModel = class {
6046
6454
  id: value.item_id,
6047
6455
  delta: value.delta
6048
6456
  });
6049
- if (((_o = (_n = options.providerOptions) == null ? void 0 : _n[providerOptionsName]) == null ? void 0 : _o.logprobs) && value.logprobs) {
6457
+ if (((_s = (_r = options.providerOptions) == null ? void 0 : _r[providerOptionsName]) == null ? void 0 : _s.logprobs) && value.logprobs) {
6050
6458
  logprobs.push(value.logprobs);
6051
6459
  }
6052
6460
  } else if (value.type === "response.reasoning_summary_part.added") {
@@ -6075,7 +6483,7 @@ var OpenAIResponsesLanguageModel = class {
6075
6483
  providerMetadata: {
6076
6484
  [providerOptionsName]: {
6077
6485
  itemId: value.item_id,
6078
- reasoningEncryptedContent: (_q = (_p = activeReasoning[value.item_id]) == null ? void 0 : _p.encryptedContent) != null ? _q : null
6486
+ reasoningEncryptedContent: (_u = (_t = activeReasoning[value.item_id]) == null ? void 0 : _t.encryptedContent) != null ? _u : null
6079
6487
  }
6080
6488
  }
6081
6489
  });
@@ -6109,22 +6517,32 @@ var OpenAIResponsesLanguageModel = class {
6109
6517
  } else if (isResponseFinishedChunk(value)) {
6110
6518
  finishReason = {
6111
6519
  unified: mapOpenAIResponseFinishReason({
6112
- finishReason: (_r = value.response.incomplete_details) == null ? void 0 : _r.reason,
6520
+ finishReason: (_v = value.response.incomplete_details) == null ? void 0 : _v.reason,
6113
6521
  hasFunctionCall
6114
6522
  }),
6115
- raw: (_t = (_s = value.response.incomplete_details) == null ? void 0 : _s.reason) != null ? _t : void 0
6523
+ raw: (_x = (_w = value.response.incomplete_details) == null ? void 0 : _w.reason) != null ? _x : void 0
6116
6524
  };
6117
6525
  usage = value.response.usage;
6118
6526
  if (typeof value.response.service_tier === "string") {
6119
6527
  serviceTier = value.response.service_tier;
6120
6528
  }
6529
+ } else if (isResponseFailedChunk(value)) {
6530
+ const incompleteReason = (_y = value.response.incomplete_details) == null ? void 0 : _y.reason;
6531
+ finishReason = {
6532
+ unified: incompleteReason ? mapOpenAIResponseFinishReason({
6533
+ finishReason: incompleteReason,
6534
+ hasFunctionCall
6535
+ }) : "error",
6536
+ raw: incompleteReason != null ? incompleteReason : "error"
6537
+ };
6538
+ usage = (_z = value.response.usage) != null ? _z : void 0;
6121
6539
  } else if (isResponseAnnotationAddedChunk(value)) {
6122
6540
  ongoingAnnotations.push(value.annotation);
6123
6541
  if (value.annotation.type === "url_citation") {
6124
6542
  controller.enqueue({
6125
6543
  type: "source",
6126
6544
  sourceType: "url",
6127
- id: (_w = (_v = (_u = self.config).generateId) == null ? void 0 : _v.call(_u)) != null ? _w : generateId2(),
6545
+ id: (_C = (_B = (_A = self.config).generateId) == null ? void 0 : _B.call(_A)) != null ? _C : generateId2(),
6128
6546
  url: value.annotation.url,
6129
6547
  title: value.annotation.title
6130
6548
  });
@@ -6132,7 +6550,7 @@ var OpenAIResponsesLanguageModel = class {
6132
6550
  controller.enqueue({
6133
6551
  type: "source",
6134
6552
  sourceType: "document",
6135
- id: (_z = (_y = (_x = self.config).generateId) == null ? void 0 : _y.call(_x)) != null ? _z : generateId2(),
6553
+ id: (_F = (_E = (_D = self.config).generateId) == null ? void 0 : _E.call(_D)) != null ? _F : generateId2(),
6136
6554
  mediaType: "text/plain",
6137
6555
  title: value.annotation.filename,
6138
6556
  filename: value.annotation.filename,
@@ -6148,7 +6566,7 @@ var OpenAIResponsesLanguageModel = class {
6148
6566
  controller.enqueue({
6149
6567
  type: "source",
6150
6568
  sourceType: "document",
6151
- id: (_C = (_B = (_A = self.config).generateId) == null ? void 0 : _B.call(_A)) != null ? _C : generateId2(),
6569
+ id: (_I = (_H = (_G = self.config).generateId) == null ? void 0 : _H.call(_G)) != null ? _I : generateId2(),
6152
6570
  mediaType: "text/plain",
6153
6571
  title: value.annotation.filename,
6154
6572
  filename: value.annotation.filename,
@@ -6164,7 +6582,7 @@ var OpenAIResponsesLanguageModel = class {
6164
6582
  controller.enqueue({
6165
6583
  type: "source",
6166
6584
  sourceType: "document",
6167
- id: (_F = (_E = (_D = self.config).generateId) == null ? void 0 : _E.call(_D)) != null ? _F : generateId2(),
6585
+ id: (_L = (_K = (_J = self.config).generateId) == null ? void 0 : _K.call(_J)) != null ? _L : generateId2(),
6168
6586
  mediaType: "application/octet-stream",
6169
6587
  title: value.annotation.file_id,
6170
6588
  filename: value.annotation.file_id,
@@ -6212,6 +6630,9 @@ function isResponseOutputItemDoneChunk(chunk) {
6212
6630
  function isResponseFinishedChunk(chunk) {
6213
6631
  return chunk.type === "response.completed" || chunk.type === "response.incomplete";
6214
6632
  }
6633
+ function isResponseFailedChunk(chunk) {
6634
+ return chunk.type === "response.failed";
6635
+ }
6215
6636
  function isResponseCreatedChunk(chunk) {
6216
6637
  return chunk.type === "response.created";
6217
6638
  }