@ai-sdk/openai 3.0.98 → 3.0.100

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -3074,9 +3074,228 @@ import {
3074
3074
  validateTypes
3075
3075
  } from "@ai-sdk/provider-utils";
3076
3076
  import { z as z21 } from "zod/v4";
3077
+
3078
+ // src/responses/expand-parallel-tool-call.ts
3079
+ import {
3080
+ isJSONObject
3081
+ } from "@ai-sdk/provider";
3082
+ import { safeParseJSON } from "@ai-sdk/provider-utils";
3083
+ var parallelToolName = "parallel";
3084
+ var recipientNamePrefix = "functions.";
3085
+ function getParallelToolCallMetadata({
3086
+ providerOptions,
3087
+ providerOptionsName
3088
+ }) {
3089
+ var _a;
3090
+ const metadata = (_a = providerOptions == null ? void 0 : providerOptions[providerOptionsName]) == null ? void 0 : _a.parallelToolCall;
3091
+ if (!isJSONObject(metadata) || typeof metadata.itemId !== "string" || typeof metadata.toolCallId !== "string" || typeof metadata.toolName !== "string" || typeof metadata.input !== "string" || typeof metadata.index !== "number" || !Number.isInteger(metadata.index) || typeof metadata.count !== "number" || !Number.isInteger(metadata.count) || metadata.index < 0 || metadata.count <= metadata.index) {
3092
+ return void 0;
3093
+ }
3094
+ return metadata;
3095
+ }
3096
+ function isUndeclaredParallelToolCall({
3097
+ toolName,
3098
+ tools
3099
+ }) {
3100
+ return toolName === parallelToolName && !tools.some((tool) => tool.name === parallelToolName);
3101
+ }
3102
+ async function expandParallelToolCall({
3103
+ toolCall,
3104
+ tools,
3105
+ providerOptionsName,
3106
+ itemId
3107
+ }) {
3108
+ if (!isUndeclaredParallelToolCall({ toolName: toolCall.toolName, tools })) {
3109
+ return void 0;
3110
+ }
3111
+ const parsedInput = await safeParseJSON({ text: toolCall.input });
3112
+ if (!parsedInput.success || !isJSONObject(parsedInput.value)) {
3113
+ return void 0;
3114
+ }
3115
+ const toolUses = parsedInput.value.tool_uses;
3116
+ if (!Array.isArray(toolUses) || toolUses.length === 0) {
3117
+ return void 0;
3118
+ }
3119
+ const availableToolNames = new Set(tools.map((tool) => tool.name));
3120
+ const expandedToolCalls = [];
3121
+ for (const [index, toolUse] of toolUses.entries()) {
3122
+ if (!isJSONObject(toolUse)) {
3123
+ return void 0;
3124
+ }
3125
+ const recipientName = toolUse.recipient_name;
3126
+ const parameters = toolUse.parameters;
3127
+ if (typeof recipientName !== "string" || !recipientName.startsWith(recipientNamePrefix) || !isJSONObject(parameters)) {
3128
+ return void 0;
3129
+ }
3130
+ const toolName = recipientName.slice(recipientNamePrefix.length);
3131
+ if (toolName.length === 0 || !availableToolNames.has(toolName)) {
3132
+ return void 0;
3133
+ }
3134
+ expandedToolCalls.push({
3135
+ type: "tool-call",
3136
+ toolCallId: `${toolCall.toolCallId}_${index}`,
3137
+ toolName,
3138
+ input: JSON.stringify(parameters),
3139
+ providerMetadata: {
3140
+ [providerOptionsName]: {
3141
+ parallelToolCall: {
3142
+ itemId,
3143
+ toolCallId: toolCall.toolCallId,
3144
+ toolName: toolCall.toolName,
3145
+ input: toolCall.input,
3146
+ index,
3147
+ count: toolUses.length
3148
+ }
3149
+ }
3150
+ }
3151
+ });
3152
+ }
3153
+ return expandedToolCalls;
3154
+ }
3155
+
3156
+ // src/responses/convert-to-openai-responses-input.ts
3077
3157
  function serializeToolCallArguments2(input) {
3078
3158
  return JSON.stringify(input === void 0 ? {} : input);
3079
3159
  }
3160
+ async function convertFunctionToolResultOutput({
3161
+ output,
3162
+ providerOptionsName,
3163
+ warnings
3164
+ }) {
3165
+ var _a;
3166
+ switch (output.type) {
3167
+ case "text":
3168
+ case "error-text":
3169
+ return output.value;
3170
+ case "execution-denied":
3171
+ return (_a = output.reason) != null ? _a : "Tool call execution denied.";
3172
+ case "json":
3173
+ case "error-json":
3174
+ return JSON.stringify(output.value);
3175
+ case "content":
3176
+ return output.value.map((item) => {
3177
+ var _a2, _b, _c, _d, _e;
3178
+ const promptCacheBreakpoint = getPromptCacheBreakpoint2(
3179
+ item.providerOptions,
3180
+ providerOptionsName
3181
+ );
3182
+ switch (item.type) {
3183
+ case "text": {
3184
+ return {
3185
+ type: "input_text",
3186
+ text: item.text,
3187
+ ...promptCacheBreakpoint != null && {
3188
+ prompt_cache_breakpoint: promptCacheBreakpoint
3189
+ }
3190
+ };
3191
+ }
3192
+ case "image-data": {
3193
+ return {
3194
+ type: "input_image",
3195
+ image_url: `data:${item.mediaType};base64,${item.data}`,
3196
+ detail: (_b = (_a2 = item.providerOptions) == null ? void 0 : _a2[providerOptionsName]) == null ? void 0 : _b.imageDetail,
3197
+ ...promptCacheBreakpoint != null && {
3198
+ prompt_cache_breakpoint: promptCacheBreakpoint
3199
+ }
3200
+ };
3201
+ }
3202
+ case "image-url": {
3203
+ return {
3204
+ type: "input_image",
3205
+ image_url: item.url,
3206
+ detail: (_d = (_c = item.providerOptions) == null ? void 0 : _c[providerOptionsName]) == null ? void 0 : _d.imageDetail,
3207
+ ...promptCacheBreakpoint != null && {
3208
+ prompt_cache_breakpoint: promptCacheBreakpoint
3209
+ }
3210
+ };
3211
+ }
3212
+ case "file-data": {
3213
+ return {
3214
+ type: "input_file",
3215
+ filename: (_e = item.filename) != null ? _e : "data",
3216
+ file_data: `data:${item.mediaType};base64,${item.data}`,
3217
+ ...promptCacheBreakpoint != null && {
3218
+ prompt_cache_breakpoint: promptCacheBreakpoint
3219
+ }
3220
+ };
3221
+ }
3222
+ case "file-url": {
3223
+ return {
3224
+ type: "input_file",
3225
+ file_url: item.url,
3226
+ ...promptCacheBreakpoint != null && {
3227
+ prompt_cache_breakpoint: promptCacheBreakpoint
3228
+ }
3229
+ };
3230
+ }
3231
+ default: {
3232
+ warnings.push({
3233
+ type: "other",
3234
+ message: `unsupported tool content part type: ${item.type}`
3235
+ });
3236
+ return void 0;
3237
+ }
3238
+ }
3239
+ }).filter(isNonNullable);
3240
+ }
3241
+ }
3242
+ function hasSameParallelToolCall(first, second) {
3243
+ return first.itemId === second.itemId && first.toolCallId === second.toolCallId && first.toolName === second.toolName && first.input === second.input && first.count === second.count;
3244
+ }
3245
+ function collectCompleteParallelToolResultGroups({
3246
+ prompt,
3247
+ providerOptionsName
3248
+ }) {
3249
+ const pendingGroups = /* @__PURE__ */ new Map();
3250
+ for (const message of prompt) {
3251
+ if (message.role !== "tool") {
3252
+ continue;
3253
+ }
3254
+ for (const part of message.content) {
3255
+ if (part.type !== "tool-result") {
3256
+ continue;
3257
+ }
3258
+ const metadata = getParallelToolCallMetadata({
3259
+ providerOptions: part.providerOptions,
3260
+ providerOptionsName
3261
+ });
3262
+ if (metadata == null) {
3263
+ continue;
3264
+ }
3265
+ const existing = pendingGroups.get(metadata.toolCallId);
3266
+ if (existing == null) {
3267
+ pendingGroups.set(metadata.toolCallId, {
3268
+ metadata,
3269
+ results: /* @__PURE__ */ new Map([[metadata.index, part]]),
3270
+ invalid: false
3271
+ });
3272
+ continue;
3273
+ }
3274
+ if (!hasSameParallelToolCall(existing.metadata, metadata) || existing.results.has(metadata.index)) {
3275
+ existing.invalid = true;
3276
+ continue;
3277
+ }
3278
+ existing.results.set(metadata.index, part);
3279
+ }
3280
+ }
3281
+ const completeGroups = /* @__PURE__ */ new Map();
3282
+ for (const [toolCallId, group] of pendingGroups) {
3283
+ if (group.invalid || group.results.size !== group.metadata.count) {
3284
+ continue;
3285
+ }
3286
+ const results = Array.from(
3287
+ { length: group.metadata.count },
3288
+ (_, index) => group.results.get(index)
3289
+ );
3290
+ if (results.every(isNonNullable)) {
3291
+ completeGroups.set(toolCallId, {
3292
+ metadata: group.metadata,
3293
+ results
3294
+ });
3295
+ }
3296
+ }
3297
+ return completeGroups;
3298
+ }
3080
3299
  function getPromptCacheBreakpoint2(providerOptions, providerOptionsName) {
3081
3300
  var _a;
3082
3301
  return (_a = providerOptions == null ? void 0 : providerOptions[providerOptionsName]) == null ? void 0 : _a.promptCacheBreakpoint;
@@ -3100,10 +3319,16 @@ async function convertToOpenAIResponsesInput({
3100
3319
  hasApplyPatchTool = false,
3101
3320
  customProviderToolNames
3102
3321
  }) {
3103
- 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;
3322
+ 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;
3104
3323
  let input = [];
3105
3324
  const warnings = [];
3106
3325
  const processedApprovalIds = /* @__PURE__ */ new Set();
3326
+ const parallelToolResultGroups = hasConversation || hasPreviousResponseId ? collectCompleteParallelToolResultGroups({
3327
+ prompt,
3328
+ providerOptionsName
3329
+ }) : /* @__PURE__ */ new Map();
3330
+ const emittedParallelToolCalls = /* @__PURE__ */ new Set();
3331
+ const emittedParallelToolResults = /* @__PURE__ */ new Set();
3107
3332
  for (const { role, content, providerOptions } of prompt) {
3108
3333
  switch (role) {
3109
3334
  case "system": {
@@ -3249,6 +3474,34 @@ async function convertToOpenAIResponsesInput({
3249
3474
  break;
3250
3475
  }
3251
3476
  case "tool-call": {
3477
+ const parallelToolCallMetadata = getParallelToolCallMetadata({
3478
+ providerOptions: part.providerOptions,
3479
+ providerOptionsName
3480
+ });
3481
+ const parallelToolResultGroup = parallelToolCallMetadata == null ? void 0 : parallelToolResultGroups.get(
3482
+ parallelToolCallMetadata.toolCallId
3483
+ );
3484
+ if (parallelToolCallMetadata != null && parallelToolResultGroup != null && hasSameParallelToolCall(
3485
+ parallelToolResultGroup.metadata,
3486
+ parallelToolCallMetadata
3487
+ )) {
3488
+ if (!emittedParallelToolCalls.has(
3489
+ parallelToolResultGroup.metadata.toolCallId
3490
+ )) {
3491
+ emittedParallelToolCalls.add(
3492
+ parallelToolResultGroup.metadata.toolCallId
3493
+ );
3494
+ if (!hasConversation) {
3495
+ input.push({
3496
+ type: "function_call",
3497
+ call_id: parallelToolResultGroup.metadata.toolCallId,
3498
+ name: parallelToolResultGroup.metadata.toolName,
3499
+ arguments: parallelToolResultGroup.metadata.input
3500
+ });
3501
+ }
3502
+ }
3503
+ break;
3504
+ }
3252
3505
  const id = (_f = (_c = (_b = part.providerOptions) == null ? void 0 : _b[providerOptionsName]) == null ? void 0 : _c.itemId) != null ? _f : (_e = (_d = part.providerMetadata) == null ? void 0 : _d[providerOptionsName]) == null ? void 0 : _e.itemId;
3253
3506
  const namespace = (_k = (_h = (_g = part.providerOptions) == null ? void 0 : _g[providerOptionsName]) == null ? void 0 : _h.namespace) != null ? _k : (_j = (_i = part.providerMetadata) == null ? void 0 : _i[providerOptionsName]) == null ? void 0 : _j.namespace;
3254
3507
  if (hasConversation && id != null) {
@@ -3528,6 +3781,44 @@ async function convertToOpenAIResponsesInput({
3528
3781
  });
3529
3782
  continue;
3530
3783
  }
3784
+ const parallelToolCallMetadata = getParallelToolCallMetadata({
3785
+ providerOptions: part.providerOptions,
3786
+ providerOptionsName
3787
+ });
3788
+ const parallelToolResultGroup = parallelToolCallMetadata == null ? void 0 : parallelToolResultGroups.get(
3789
+ parallelToolCallMetadata.toolCallId
3790
+ );
3791
+ if (parallelToolCallMetadata != null && parallelToolResultGroup != null && hasSameParallelToolCall(
3792
+ parallelToolResultGroup.metadata,
3793
+ parallelToolCallMetadata
3794
+ )) {
3795
+ if (!emittedParallelToolResults.has(
3796
+ parallelToolResultGroup.metadata.toolCallId
3797
+ )) {
3798
+ emittedParallelToolResults.add(
3799
+ parallelToolResultGroup.metadata.toolCallId
3800
+ );
3801
+ const toolOutputs = await Promise.all(
3802
+ parallelToolResultGroup.results.map(
3803
+ async (result) => convertFunctionToolResultOutput({
3804
+ output: result.output,
3805
+ providerOptionsName,
3806
+ warnings
3807
+ })
3808
+ )
3809
+ );
3810
+ input.push({
3811
+ type: "function_call_output",
3812
+ call_id: parallelToolResultGroup.metadata.toolCallId,
3813
+ // The internal wrapper returns one output containing the child
3814
+ // results in the same order as the original tool_uses array.
3815
+ output: toolOutputs.map(
3816
+ (output2) => typeof output2 === "string" ? output2 : JSON.stringify(output2)
3817
+ ).join("\n")
3818
+ });
3819
+ }
3820
+ continue;
3821
+ }
3531
3822
  const output = part.output;
3532
3823
  if (output.type === "execution-denied") {
3533
3824
  const approvalId = (_x = (_w = output.providerOptions) == null ? void 0 : _w.openai) == null ? void 0 : _x.approvalId;
@@ -3680,86 +3971,11 @@ async function convertToOpenAIResponsesInput({
3680
3971
  });
3681
3972
  continue;
3682
3973
  }
3683
- let contentValue;
3684
- switch (output.type) {
3685
- case "text":
3686
- case "error-text":
3687
- contentValue = output.value;
3688
- break;
3689
- case "execution-denied":
3690
- contentValue = (_z = output.reason) != null ? _z : "Tool call execution denied.";
3691
- break;
3692
- case "json":
3693
- case "error-json":
3694
- contentValue = JSON.stringify(output.value);
3695
- break;
3696
- case "content":
3697
- contentValue = output.value.map((item) => {
3698
- var _a2, _b2, _c2, _d2, _e2;
3699
- const promptCacheBreakpoint = getPromptCacheBreakpoint2(
3700
- item.providerOptions,
3701
- providerOptionsName
3702
- );
3703
- switch (item.type) {
3704
- case "text": {
3705
- return {
3706
- type: "input_text",
3707
- text: item.text,
3708
- ...promptCacheBreakpoint != null && {
3709
- prompt_cache_breakpoint: promptCacheBreakpoint
3710
- }
3711
- };
3712
- }
3713
- case "image-data": {
3714
- return {
3715
- type: "input_image",
3716
- image_url: `data:${item.mediaType};base64,${item.data}`,
3717
- detail: (_b2 = (_a2 = item.providerOptions) == null ? void 0 : _a2[providerOptionsName]) == null ? void 0 : _b2.imageDetail,
3718
- ...promptCacheBreakpoint != null && {
3719
- prompt_cache_breakpoint: promptCacheBreakpoint
3720
- }
3721
- };
3722
- }
3723
- case "image-url": {
3724
- return {
3725
- type: "input_image",
3726
- image_url: item.url,
3727
- detail: (_d2 = (_c2 = item.providerOptions) == null ? void 0 : _c2[providerOptionsName]) == null ? void 0 : _d2.imageDetail,
3728
- ...promptCacheBreakpoint != null && {
3729
- prompt_cache_breakpoint: promptCacheBreakpoint
3730
- }
3731
- };
3732
- }
3733
- case "file-data": {
3734
- return {
3735
- type: "input_file",
3736
- filename: (_e2 = item.filename) != null ? _e2 : "data",
3737
- file_data: `data:${item.mediaType};base64,${item.data}`,
3738
- ...promptCacheBreakpoint != null && {
3739
- prompt_cache_breakpoint: promptCacheBreakpoint
3740
- }
3741
- };
3742
- }
3743
- case "file-url": {
3744
- return {
3745
- type: "input_file",
3746
- file_url: item.url,
3747
- ...promptCacheBreakpoint != null && {
3748
- prompt_cache_breakpoint: promptCacheBreakpoint
3749
- }
3750
- };
3751
- }
3752
- default: {
3753
- warnings.push({
3754
- type: "other",
3755
- message: `unsupported tool content part type: ${item.type}`
3756
- });
3757
- return void 0;
3758
- }
3759
- }
3760
- }).filter(isNonNullable);
3761
- break;
3762
- }
3974
+ const contentValue = await convertFunctionToolResultOutput({
3975
+ output,
3976
+ providerOptionsName,
3977
+ warnings
3978
+ });
3763
3979
  input.push({
3764
3980
  type: "function_call_output",
3765
3981
  call_id: part.toolCallId,
@@ -5729,7 +5945,7 @@ var OpenAIResponsesLanguageModel = class {
5729
5945
  };
5730
5946
  }
5731
5947
  async doGenerate(options) {
5732
- 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;
5948
+ 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;
5733
5949
  const {
5734
5950
  args: body,
5735
5951
  warnings,
@@ -5771,6 +5987,9 @@ var OpenAIResponsesLanguageModel = class {
5771
5987
  }
5772
5988
  const content = [];
5773
5989
  const logprobs = [];
5990
+ const functionTools = (_b = (_a = options.tools) == null ? void 0 : _a.filter(
5991
+ (tool) => tool.type === "function"
5992
+ )) != null ? _b : [];
5774
5993
  let hasFunctionCall = false;
5775
5994
  const hostedToolSearchCallIds = [];
5776
5995
  for (const part of response.output) {
@@ -5786,7 +6005,7 @@ var OpenAIResponsesLanguageModel = class {
5786
6005
  providerMetadata: {
5787
6006
  [providerOptionsName]: {
5788
6007
  itemId: part.id,
5789
- reasoningEncryptedContent: (_a = part.encrypted_content) != null ? _a : null
6008
+ reasoningEncryptedContent: (_c = part.encrypted_content) != null ? _c : null
5790
6009
  }
5791
6010
  }
5792
6011
  });
@@ -5812,7 +6031,7 @@ var OpenAIResponsesLanguageModel = class {
5812
6031
  break;
5813
6032
  }
5814
6033
  case "tool_search_call": {
5815
- const toolCallId = (_b = part.call_id) != null ? _b : part.id;
6034
+ const toolCallId = (_d = part.call_id) != null ? _d : part.id;
5816
6035
  const isHosted = part.execution === "server";
5817
6036
  if (isHosted) {
5818
6037
  hostedToolSearchCallIds.push(toolCallId);
@@ -5835,7 +6054,7 @@ var OpenAIResponsesLanguageModel = class {
5835
6054
  break;
5836
6055
  }
5837
6056
  case "tool_search_output": {
5838
- const toolCallId = (_d = (_c = part.call_id) != null ? _c : hostedToolSearchCallIds.shift()) != null ? _d : part.id;
6057
+ const toolCallId = (_f = (_e = part.call_id) != null ? _e : hostedToolSearchCallIds.shift()) != null ? _f : part.id;
5839
6058
  content.push({
5840
6059
  type: "tool-result",
5841
6060
  toolCallId,
@@ -5906,7 +6125,7 @@ var OpenAIResponsesLanguageModel = class {
5906
6125
  }
5907
6126
  case "message": {
5908
6127
  for (const contentPart of part.content) {
5909
- if (((_f = (_e = options.providerOptions) == null ? void 0 : _e[providerOptionsName]) == null ? void 0 : _f.logprobs) && contentPart.logprobs) {
6128
+ if (((_h = (_g = options.providerOptions) == null ? void 0 : _g[providerOptionsName]) == null ? void 0 : _h.logprobs) && contentPart.logprobs) {
5910
6129
  logprobs.push(contentPart.logprobs);
5911
6130
  }
5912
6131
  const providerMetadata2 = {
@@ -5928,7 +6147,7 @@ var OpenAIResponsesLanguageModel = class {
5928
6147
  content.push({
5929
6148
  type: "source",
5930
6149
  sourceType: "url",
5931
- id: (_i = (_h = (_g = this.config).generateId) == null ? void 0 : _h.call(_g)) != null ? _i : generateId2(),
6150
+ id: (_k = (_j = (_i = this.config).generateId) == null ? void 0 : _j.call(_i)) != null ? _k : generateId2(),
5932
6151
  url: annotation.url,
5933
6152
  title: annotation.title
5934
6153
  });
@@ -5936,7 +6155,7 @@ var OpenAIResponsesLanguageModel = class {
5936
6155
  content.push({
5937
6156
  type: "source",
5938
6157
  sourceType: "document",
5939
- id: (_l = (_k = (_j = this.config).generateId) == null ? void 0 : _k.call(_j)) != null ? _l : generateId2(),
6158
+ id: (_n = (_m = (_l = this.config).generateId) == null ? void 0 : _m.call(_l)) != null ? _n : generateId2(),
5940
6159
  mediaType: "text/plain",
5941
6160
  title: annotation.filename,
5942
6161
  filename: annotation.filename,
@@ -5952,7 +6171,7 @@ var OpenAIResponsesLanguageModel = class {
5952
6171
  content.push({
5953
6172
  type: "source",
5954
6173
  sourceType: "document",
5955
- id: (_o = (_n = (_m = this.config).generateId) == null ? void 0 : _n.call(_m)) != null ? _o : generateId2(),
6174
+ id: (_q = (_p = (_o = this.config).generateId) == null ? void 0 : _p.call(_o)) != null ? _q : generateId2(),
5956
6175
  mediaType: "text/plain",
5957
6176
  title: annotation.filename,
5958
6177
  filename: annotation.filename,
@@ -5968,7 +6187,7 @@ var OpenAIResponsesLanguageModel = class {
5968
6187
  content.push({
5969
6188
  type: "source",
5970
6189
  sourceType: "document",
5971
- id: (_r = (_q = (_p = this.config).generateId) == null ? void 0 : _q.call(_p)) != null ? _r : generateId2(),
6190
+ id: (_t = (_s = (_r = this.config).generateId) == null ? void 0 : _s.call(_r)) != null ? _t : generateId2(),
5972
6191
  mediaType: "application/octet-stream",
5973
6192
  title: annotation.file_id,
5974
6193
  filename: annotation.file_id,
@@ -5987,6 +6206,20 @@ var OpenAIResponsesLanguageModel = class {
5987
6206
  }
5988
6207
  case "function_call": {
5989
6208
  hasFunctionCall = true;
6209
+ const expandedToolCalls = await expandParallelToolCall({
6210
+ toolCall: {
6211
+ toolCallId: part.call_id,
6212
+ toolName: part.name,
6213
+ input: part.arguments
6214
+ },
6215
+ tools: functionTools,
6216
+ providerOptionsName,
6217
+ itemId: part.id
6218
+ });
6219
+ if (expandedToolCalls != null) {
6220
+ content.push(...expandedToolCalls);
6221
+ break;
6222
+ }
5990
6223
  content.push({
5991
6224
  type: "tool-call",
5992
6225
  toolCallId: part.call_id,
@@ -6038,7 +6271,7 @@ var OpenAIResponsesLanguageModel = class {
6038
6271
  break;
6039
6272
  }
6040
6273
  case "mcp_call": {
6041
- const toolCallId = part.approval_request_id != null ? (_s = approvalRequestIdToDummyToolCallIdFromPrompt[part.approval_request_id]) != null ? _s : part.id : part.id;
6274
+ const toolCallId = part.approval_request_id != null ? (_u = approvalRequestIdToDummyToolCallIdFromPrompt[part.approval_request_id]) != null ? _u : part.id : part.id;
6042
6275
  const toolName = `mcp.${part.name}`;
6043
6276
  content.push({
6044
6277
  type: "tool-call",
@@ -6072,8 +6305,8 @@ var OpenAIResponsesLanguageModel = class {
6072
6305
  break;
6073
6306
  }
6074
6307
  case "mcp_approval_request": {
6075
- const approvalRequestId = (_t = part.approval_request_id) != null ? _t : part.id;
6076
- const dummyToolCallId = (_w = (_v = (_u = this.config).generateId) == null ? void 0 : _v.call(_u)) != null ? _w : generateId2();
6308
+ const approvalRequestId = (_v = part.approval_request_id) != null ? _v : part.id;
6309
+ const dummyToolCallId = (_y = (_x = (_w = this.config).generateId) == null ? void 0 : _x.call(_w)) != null ? _y : generateId2();
6077
6310
  const toolName = `mcp.${part.name}`;
6078
6311
  content.push({
6079
6312
  type: "tool-call",
@@ -6123,13 +6356,13 @@ var OpenAIResponsesLanguageModel = class {
6123
6356
  toolName: toolNameMapping.toCustomToolName("file_search"),
6124
6357
  result: {
6125
6358
  queries: part.queries,
6126
- results: (_y = (_x = part.results) == null ? void 0 : _x.map((result) => ({
6359
+ results: (_A = (_z = part.results) == null ? void 0 : _z.map((result) => ({
6127
6360
  attributes: result.attributes,
6128
6361
  fileId: result.file_id,
6129
6362
  filename: result.filename,
6130
6363
  score: result.score,
6131
6364
  text: result.text
6132
- }))) != null ? _y : null
6365
+ }))) != null ? _A : null
6133
6366
  }
6134
6367
  });
6135
6368
  break;
@@ -6179,7 +6412,7 @@ var OpenAIResponsesLanguageModel = class {
6179
6412
  responseId: response.id,
6180
6413
  ...logprobs.length > 0 ? { logprobs } : {},
6181
6414
  ...typeof response.service_tier === "string" ? { serviceTier: response.service_tier } : {},
6182
- ...((_z = response.reasoning) == null ? void 0 : _z.context) != null ? { reasoningContext: response.reasoning.context } : {}
6415
+ ...((_B = response.reasoning) == null ? void 0 : _B.context) != null ? { reasoningContext: response.reasoning.context } : {}
6183
6416
  }
6184
6417
  };
6185
6418
  const usage = response.usage;
@@ -6187,10 +6420,10 @@ var OpenAIResponsesLanguageModel = class {
6187
6420
  content,
6188
6421
  finishReason: {
6189
6422
  unified: mapOpenAIResponseFinishReason({
6190
- finishReason: (_A = response.incomplete_details) == null ? void 0 : _A.reason,
6423
+ finishReason: (_C = response.incomplete_details) == null ? void 0 : _C.reason,
6191
6424
  hasFunctionCall
6192
6425
  }),
6193
- raw: (_C = (_B = response.incomplete_details) == null ? void 0 : _B.reason) != null ? _C : void 0
6426
+ raw: (_E = (_D = response.incomplete_details) == null ? void 0 : _D.reason) != null ? _E : void 0
6194
6427
  },
6195
6428
  usage: convertOpenAIResponsesUsage(usage),
6196
6429
  request: { body },
@@ -6206,6 +6439,7 @@ var OpenAIResponsesLanguageModel = class {
6206
6439
  };
6207
6440
  }
6208
6441
  async doStream(options) {
6442
+ var _a, _b;
6209
6443
  const {
6210
6444
  args: body,
6211
6445
  warnings,
@@ -6243,6 +6477,9 @@ var OpenAIResponsesLanguageModel = class {
6243
6477
  });
6244
6478
  const self = this;
6245
6479
  const approvalRequestIdToDummyToolCallIdFromPrompt = extractApprovalRequestIdToToolCallIdMapping(options.prompt);
6480
+ const functionTools = (_b = (_a = options.tools) == null ? void 0 : _a.filter(
6481
+ (tool) => tool.type === "function"
6482
+ )) != null ? _b : [];
6246
6483
  const approvalRequestIdToDummyToolCallIdFromStream = /* @__PURE__ */ new Map();
6247
6484
  let finishReason = {
6248
6485
  unified: "other",
@@ -6267,7 +6504,7 @@ var OpenAIResponsesLanguageModel = class {
6267
6504
  controller.enqueue({ type: "stream-start", warnings });
6268
6505
  },
6269
6506
  transform(chunk, controller) {
6270
- 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, _M, _N;
6507
+ var _a2, _b2, _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, _M, _N, _O, _P;
6271
6508
  if (options.includeRawChunks) {
6272
6509
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
6273
6510
  }
@@ -6286,15 +6523,23 @@ var OpenAIResponsesLanguageModel = class {
6286
6523
  const value = chunk.value;
6287
6524
  if (isResponseOutputItemAddedChunk(value)) {
6288
6525
  if (value.item.type === "function_call") {
6526
+ const suppressInputStreaming = isUndeclaredParallelToolCall({
6527
+ toolName: value.item.name,
6528
+ tools: functionTools
6529
+ });
6289
6530
  ongoingToolCalls[value.output_index] = {
6290
6531
  toolName: value.item.name,
6291
- toolCallId: value.item.call_id
6532
+ toolCallId: value.item.call_id,
6533
+ suppressInputStreaming,
6534
+ bufferedInputDeltas: suppressInputStreaming ? [] : void 0
6292
6535
  };
6293
- controller.enqueue({
6294
- type: "tool-input-start",
6295
- id: value.item.call_id,
6296
- toolName: value.item.name
6297
- });
6536
+ if (!suppressInputStreaming) {
6537
+ controller.enqueue({
6538
+ type: "tool-input-start",
6539
+ id: value.item.call_id,
6540
+ toolName: value.item.name
6541
+ });
6542
+ }
6298
6543
  } else if (value.item.type === "custom_tool_call") {
6299
6544
  const toolName = toolNameMapping.toCustomToolName(
6300
6545
  value.item.name
@@ -6389,7 +6634,7 @@ var OpenAIResponsesLanguageModel = class {
6389
6634
  ongoingToolCalls[value.output_index] = {
6390
6635
  toolName,
6391
6636
  toolCallId,
6392
- toolSearchExecution: (_a = value.item.execution) != null ? _a : "server"
6637
+ toolSearchExecution: (_a2 = value.item.execution) != null ? _a2 : "server"
6393
6638
  };
6394
6639
  if (isHosted) {
6395
6640
  controller.enqueue({
@@ -6446,7 +6691,7 @@ var OpenAIResponsesLanguageModel = class {
6446
6691
  } else if (value.item.type === "shell_call_output") {
6447
6692
  } else if (value.item.type === "message") {
6448
6693
  ongoingAnnotations.splice(0, ongoingAnnotations.length);
6449
- activeMessagePhase = (_b = value.item.phase) != null ? _b : void 0;
6694
+ activeMessagePhase = (_b2 = value.item.phase) != null ? _b2 : void 0;
6450
6695
  controller.enqueue({
6451
6696
  type: "text-start",
6452
6697
  id: value.item.id,
@@ -6493,31 +6738,99 @@ var OpenAIResponsesLanguageModel = class {
6493
6738
  }
6494
6739
  });
6495
6740
  } else if (value.item.type === "function_call") {
6741
+ const item = value.item;
6742
+ const ongoingToolCall = ongoingToolCalls[value.output_index];
6496
6743
  ongoingToolCalls[value.output_index] = void 0;
6497
6744
  hasFunctionCall = true;
6498
- controller.enqueue({
6499
- type: "tool-input-end",
6500
- id: value.item.call_id,
6501
- ...value.item.namespace != null && {
6502
- providerMetadata: {
6503
- [providerOptionsName]: {
6504
- namespace: value.item.namespace
6745
+ const suppressInputStreaming = (_e = ongoingToolCall == null ? void 0 : ongoingToolCall.suppressInputStreaming) != null ? _e : isUndeclaredParallelToolCall({
6746
+ toolName: item.name,
6747
+ tools: functionTools
6748
+ });
6749
+ const enqueueUnexpandedToolCall = () => {
6750
+ var _a3;
6751
+ if (suppressInputStreaming) {
6752
+ controller.enqueue({
6753
+ type: "tool-input-start",
6754
+ id: item.call_id,
6755
+ toolName: item.name
6756
+ });
6757
+ const bufferedInputDeltas = (_a3 = ongoingToolCall == null ? void 0 : ongoingToolCall.bufferedInputDeltas) != null ? _a3 : [];
6758
+ if (bufferedInputDeltas.length > 0) {
6759
+ for (const delta of bufferedInputDeltas) {
6760
+ controller.enqueue({
6761
+ type: "tool-input-delta",
6762
+ id: item.call_id,
6763
+ delta
6764
+ });
6505
6765
  }
6766
+ } else if (item.arguments.length > 0) {
6767
+ controller.enqueue({
6768
+ type: "tool-input-delta",
6769
+ id: item.call_id,
6770
+ delta: item.arguments
6771
+ });
6506
6772
  }
6507
6773
  }
6508
- });
6509
- controller.enqueue({
6510
- type: "tool-call",
6511
- toolCallId: value.item.call_id,
6512
- toolName: value.item.name,
6513
- input: value.item.arguments,
6514
- providerMetadata: {
6515
- [providerOptionsName]: {
6516
- itemId: value.item.id,
6517
- ...value.item.namespace != null && {
6518
- namespace: value.item.namespace
6774
+ controller.enqueue({
6775
+ type: "tool-input-end",
6776
+ id: item.call_id,
6777
+ ...item.namespace != null && {
6778
+ providerMetadata: {
6779
+ [providerOptionsName]: {
6780
+ namespace: item.namespace
6781
+ }
6519
6782
  }
6520
6783
  }
6784
+ });
6785
+ controller.enqueue({
6786
+ type: "tool-call",
6787
+ toolCallId: item.call_id,
6788
+ toolName: item.name,
6789
+ input: item.arguments,
6790
+ providerMetadata: {
6791
+ [providerOptionsName]: {
6792
+ itemId: item.id,
6793
+ ...item.namespace != null && {
6794
+ namespace: item.namespace
6795
+ }
6796
+ }
6797
+ }
6798
+ });
6799
+ };
6800
+ if (!suppressInputStreaming) {
6801
+ enqueueUnexpandedToolCall();
6802
+ return;
6803
+ }
6804
+ return expandParallelToolCall({
6805
+ toolCall: {
6806
+ toolCallId: item.call_id,
6807
+ toolName: item.name,
6808
+ input: item.arguments
6809
+ },
6810
+ tools: functionTools,
6811
+ providerOptionsName,
6812
+ itemId: item.id
6813
+ }).then((expandedToolCalls) => {
6814
+ if (expandedToolCalls == null) {
6815
+ enqueueUnexpandedToolCall();
6816
+ return;
6817
+ }
6818
+ for (const toolCall of expandedToolCalls) {
6819
+ controller.enqueue({
6820
+ type: "tool-input-start",
6821
+ id: toolCall.toolCallId,
6822
+ toolName: toolCall.toolName
6823
+ });
6824
+ controller.enqueue({
6825
+ type: "tool-input-delta",
6826
+ id: toolCall.toolCallId,
6827
+ delta: toolCall.input
6828
+ });
6829
+ controller.enqueue({
6830
+ type: "tool-input-end",
6831
+ id: toolCall.toolCallId
6832
+ });
6833
+ controller.enqueue(toolCall);
6521
6834
  }
6522
6835
  });
6523
6836
  } else if (value.item.type === "custom_tool_call") {
@@ -6581,13 +6894,13 @@ var OpenAIResponsesLanguageModel = class {
6581
6894
  toolName: toolNameMapping.toCustomToolName("file_search"),
6582
6895
  result: {
6583
6896
  queries: value.item.queries,
6584
- results: (_f = (_e = value.item.results) == null ? void 0 : _e.map((result2) => ({
6897
+ results: (_g = (_f = value.item.results) == null ? void 0 : _f.map((result2) => ({
6585
6898
  attributes: result2.attributes,
6586
6899
  fileId: result2.file_id,
6587
6900
  filename: result2.filename,
6588
6901
  score: result2.score,
6589
6902
  text: result2.text
6590
- }))) != null ? _f : null
6903
+ }))) != null ? _g : null
6591
6904
  }
6592
6905
  });
6593
6906
  } else if (value.item.type === "code_interpreter_call") {
@@ -6613,7 +6926,7 @@ var OpenAIResponsesLanguageModel = class {
6613
6926
  const toolCall = ongoingToolCalls[value.output_index];
6614
6927
  const isHosted = value.item.execution === "server";
6615
6928
  if (toolCall != null) {
6616
- const toolCallId = isHosted ? toolCall.toolCallId : (_g = value.item.call_id) != null ? _g : value.item.id;
6929
+ const toolCallId = isHosted ? toolCall.toolCallId : (_h = value.item.call_id) != null ? _h : value.item.id;
6617
6930
  if (isHosted) {
6618
6931
  hostedToolSearchCallIds.push(toolCallId);
6619
6932
  } else {
@@ -6645,7 +6958,7 @@ var OpenAIResponsesLanguageModel = class {
6645
6958
  }
6646
6959
  ongoingToolCalls[value.output_index] = void 0;
6647
6960
  } else if (value.item.type === "tool_search_output") {
6648
- const toolCallId = (_i = (_h = value.item.call_id) != null ? _h : hostedToolSearchCallIds.shift()) != null ? _i : value.item.id;
6961
+ const toolCallId = (_j = (_i = value.item.call_id) != null ? _i : hostedToolSearchCallIds.shift()) != null ? _j : value.item.id;
6649
6962
  controller.enqueue({
6650
6963
  type: "tool-result",
6651
6964
  toolCallId,
@@ -6661,10 +6974,10 @@ var OpenAIResponsesLanguageModel = class {
6661
6974
  });
6662
6975
  } else if (value.item.type === "mcp_call") {
6663
6976
  ongoingToolCalls[value.output_index] = void 0;
6664
- const approvalRequestId = (_j = value.item.approval_request_id) != null ? _j : void 0;
6665
- const aliasedToolCallId = approvalRequestId != null ? (_l = (_k = approvalRequestIdToDummyToolCallIdFromStream.get(
6977
+ const approvalRequestId = (_k = value.item.approval_request_id) != null ? _k : void 0;
6978
+ const aliasedToolCallId = approvalRequestId != null ? (_m = (_l = approvalRequestIdToDummyToolCallIdFromStream.get(
6666
6979
  approvalRequestId
6667
- )) != null ? _k : approvalRequestIdToDummyToolCallIdFromPrompt[approvalRequestId]) != null ? _l : value.item.id : value.item.id;
6980
+ )) != null ? _l : approvalRequestIdToDummyToolCallIdFromPrompt[approvalRequestId]) != null ? _m : value.item.id : value.item.id;
6668
6981
  const toolName = `mcp.${value.item.name}`;
6669
6982
  controller.enqueue({
6670
6983
  type: "tool-call",
@@ -6734,8 +7047,8 @@ var OpenAIResponsesLanguageModel = class {
6734
7047
  ongoingToolCalls[value.output_index] = void 0;
6735
7048
  } else if (value.item.type === "mcp_approval_request") {
6736
7049
  ongoingToolCalls[value.output_index] = void 0;
6737
- const dummyToolCallId = (_o = (_n = (_m = self.config).generateId) == null ? void 0 : _n.call(_m)) != null ? _o : generateId2();
6738
- const approvalRequestId = (_p = value.item.approval_request_id) != null ? _p : value.item.id;
7050
+ const dummyToolCallId = (_p = (_o = (_n = self.config).generateId) == null ? void 0 : _o.call(_n)) != null ? _p : generateId2();
7051
+ const approvalRequestId = (_q = value.item.approval_request_id) != null ? _q : value.item.id;
6739
7052
  approvalRequestIdToDummyToolCallIdFromStream.set(
6740
7053
  approvalRequestId,
6741
7054
  dummyToolCallId
@@ -6824,7 +7137,7 @@ var OpenAIResponsesLanguageModel = class {
6824
7137
  providerMetadata: {
6825
7138
  [providerOptionsName]: {
6826
7139
  itemId: value.item.id,
6827
- reasoningEncryptedContent: (_q = value.item.encrypted_content) != null ? _q : null
7140
+ reasoningEncryptedContent: (_r = value.item.encrypted_content) != null ? _r : null
6828
7141
  }
6829
7142
  }
6830
7143
  });
@@ -6834,11 +7147,15 @@ var OpenAIResponsesLanguageModel = class {
6834
7147
  } else if (isResponseFunctionCallArgumentsDeltaChunk(value)) {
6835
7148
  const toolCall = ongoingToolCalls[value.output_index];
6836
7149
  if (toolCall != null) {
6837
- controller.enqueue({
6838
- type: "tool-input-delta",
6839
- id: toolCall.toolCallId,
6840
- delta: value.delta
6841
- });
7150
+ if (toolCall.suppressInputStreaming) {
7151
+ (_s = toolCall.bufferedInputDeltas) == null ? void 0 : _s.push(value.delta);
7152
+ } else {
7153
+ controller.enqueue({
7154
+ type: "tool-input-delta",
7155
+ id: toolCall.toolCallId,
7156
+ delta: value.delta
7157
+ });
7158
+ }
6842
7159
  }
6843
7160
  } else if (isResponseCustomToolCallInputDeltaChunk(value)) {
6844
7161
  const toolCall = ongoingToolCalls[value.output_index];
@@ -6937,7 +7254,7 @@ var OpenAIResponsesLanguageModel = class {
6937
7254
  id: value.item_id,
6938
7255
  delta: value.delta
6939
7256
  });
6940
- if (((_s = (_r = options.providerOptions) == null ? void 0 : _r[providerOptionsName]) == null ? void 0 : _s.logprobs) && value.logprobs) {
7257
+ if (((_u = (_t = options.providerOptions) == null ? void 0 : _t[providerOptionsName]) == null ? void 0 : _u.logprobs) && value.logprobs) {
6941
7258
  logprobs.push(value.logprobs);
6942
7259
  }
6943
7260
  } else if (value.type === "response.reasoning_summary_part.added") {
@@ -6966,7 +7283,7 @@ var OpenAIResponsesLanguageModel = class {
6966
7283
  providerMetadata: {
6967
7284
  [providerOptionsName]: {
6968
7285
  itemId: value.item_id,
6969
- reasoningEncryptedContent: (_u = (_t = activeReasoning[value.item_id]) == null ? void 0 : _t.encryptedContent) != null ? _u : null
7286
+ reasoningEncryptedContent: (_w = (_v = activeReasoning[value.item_id]) == null ? void 0 : _v.encryptedContent) != null ? _w : null
6970
7287
  }
6971
7288
  }
6972
7289
  });
@@ -7000,20 +7317,20 @@ var OpenAIResponsesLanguageModel = class {
7000
7317
  } else if (isResponseFinishedChunk(value)) {
7001
7318
  finishReason = {
7002
7319
  unified: mapOpenAIResponseFinishReason({
7003
- finishReason: (_v = value.response.incomplete_details) == null ? void 0 : _v.reason,
7320
+ finishReason: (_x = value.response.incomplete_details) == null ? void 0 : _x.reason,
7004
7321
  hasFunctionCall
7005
7322
  }),
7006
- raw: (_x = (_w = value.response.incomplete_details) == null ? void 0 : _w.reason) != null ? _x : void 0
7323
+ raw: (_z = (_y = value.response.incomplete_details) == null ? void 0 : _y.reason) != null ? _z : void 0
7007
7324
  };
7008
7325
  usage = value.response.usage;
7009
7326
  if (typeof value.response.service_tier === "string") {
7010
7327
  serviceTier = value.response.service_tier;
7011
7328
  }
7012
- if (((_y = value.response.reasoning) == null ? void 0 : _y.context) != null) {
7329
+ if (((_A = value.response.reasoning) == null ? void 0 : _A.context) != null) {
7013
7330
  reasoningContext = value.response.reasoning.context;
7014
7331
  }
7015
7332
  } else if (isResponseFailedChunk(value)) {
7016
- const incompleteReason = (_z = value.response.incomplete_details) == null ? void 0 : _z.reason;
7333
+ const incompleteReason = (_B = value.response.incomplete_details) == null ? void 0 : _B.reason;
7017
7334
  finishReason = {
7018
7335
  unified: incompleteReason ? mapOpenAIResponseFinishReason({
7019
7336
  finishReason: incompleteReason,
@@ -7021,8 +7338,8 @@ var OpenAIResponsesLanguageModel = class {
7021
7338
  }) : "error",
7022
7339
  raw: incompleteReason != null ? incompleteReason : "error"
7023
7340
  };
7024
- usage = (_A = value.response.usage) != null ? _A : void 0;
7025
- if (((_B = value.response.reasoning) == null ? void 0 : _B.context) != null) {
7341
+ usage = (_C = value.response.usage) != null ? _C : void 0;
7342
+ if (((_D = value.response.reasoning) == null ? void 0 : _D.context) != null) {
7026
7343
  reasoningContext = value.response.reasoning.context;
7027
7344
  }
7028
7345
  if (!encounteredStreamError && value.response.error != null) {
@@ -7046,7 +7363,7 @@ var OpenAIResponsesLanguageModel = class {
7046
7363
  controller.enqueue({
7047
7364
  type: "source",
7048
7365
  sourceType: "url",
7049
- id: (_E = (_D = (_C = self.config).generateId) == null ? void 0 : _D.call(_C)) != null ? _E : generateId2(),
7366
+ id: (_G = (_F = (_E = self.config).generateId) == null ? void 0 : _F.call(_E)) != null ? _G : generateId2(),
7050
7367
  url: value.annotation.url,
7051
7368
  title: value.annotation.title
7052
7369
  });
@@ -7054,7 +7371,7 @@ var OpenAIResponsesLanguageModel = class {
7054
7371
  controller.enqueue({
7055
7372
  type: "source",
7056
7373
  sourceType: "document",
7057
- id: (_H = (_G = (_F = self.config).generateId) == null ? void 0 : _G.call(_F)) != null ? _H : generateId2(),
7374
+ id: (_J = (_I = (_H = self.config).generateId) == null ? void 0 : _I.call(_H)) != null ? _J : generateId2(),
7058
7375
  mediaType: "text/plain",
7059
7376
  title: value.annotation.filename,
7060
7377
  filename: value.annotation.filename,
@@ -7070,7 +7387,7 @@ var OpenAIResponsesLanguageModel = class {
7070
7387
  controller.enqueue({
7071
7388
  type: "source",
7072
7389
  sourceType: "document",
7073
- id: (_K = (_J = (_I = self.config).generateId) == null ? void 0 : _J.call(_I)) != null ? _K : generateId2(),
7390
+ id: (_M = (_L = (_K = self.config).generateId) == null ? void 0 : _L.call(_K)) != null ? _M : generateId2(),
7074
7391
  mediaType: "text/plain",
7075
7392
  title: value.annotation.filename,
7076
7393
  filename: value.annotation.filename,
@@ -7086,7 +7403,7 @@ var OpenAIResponsesLanguageModel = class {
7086
7403
  controller.enqueue({
7087
7404
  type: "source",
7088
7405
  sourceType: "document",
7089
- id: (_N = (_M = (_L = self.config).generateId) == null ? void 0 : _M.call(_L)) != null ? _N : generateId2(),
7406
+ id: (_P = (_O = (_N = self.config).generateId) == null ? void 0 : _O.call(_N)) != null ? _P : generateId2(),
7090
7407
  mediaType: "application/octet-stream",
7091
7408
  title: value.annotation.file_id,
7092
7409
  filename: value.annotation.file_id,
@@ -7106,6 +7423,24 @@ var OpenAIResponsesLanguageModel = class {
7106
7423
  }
7107
7424
  },
7108
7425
  flush(controller) {
7426
+ var _a2;
7427
+ for (const toolCall of Object.values(ongoingToolCalls)) {
7428
+ if (!(toolCall == null ? void 0 : toolCall.suppressInputStreaming)) {
7429
+ continue;
7430
+ }
7431
+ controller.enqueue({
7432
+ type: "tool-input-start",
7433
+ id: toolCall.toolCallId,
7434
+ toolName: toolCall.toolName
7435
+ });
7436
+ for (const delta of (_a2 = toolCall.bufferedInputDeltas) != null ? _a2 : []) {
7437
+ controller.enqueue({
7438
+ type: "tool-input-delta",
7439
+ id: toolCall.toolCallId,
7440
+ delta
7441
+ });
7442
+ }
7443
+ }
7109
7444
  const providerMetadata = {
7110
7445
  [providerOptionsName]: {
7111
7446
  responseId,
@@ -7605,7 +7940,7 @@ var OpenAITranscriptionModel = class {
7605
7940
  };
7606
7941
 
7607
7942
  // src/version.ts
7608
- var VERSION = true ? "3.0.98" : "0.0.0-test";
7943
+ var VERSION = true ? "3.0.100" : "0.0.0-test";
7609
7944
 
7610
7945
  // src/openai-provider.ts
7611
7946
  function createOpenAI(options = {}) {