@ai-sdk/openai 3.0.101 → 3.0.104

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.js CHANGED
@@ -54,10 +54,10 @@ var openaiFailedResponseHandler = (0, import_provider_utils.createJsonErrorRespo
54
54
 
55
55
  // src/openai-language-model-capabilities.ts
56
56
  function getOpenAILanguageModelCapabilities(modelId) {
57
- var _a, _b, _c, _d, _e;
57
+ var _a2, _b, _c, _d, _e;
58
58
  const oSeriesVersion = getOSeriesVersion(modelId);
59
59
  const gptVersion = getGptVersion(modelId);
60
- const isGptChatModel = (gptVersion == null ? void 0 : gptVersion.minor) == null && ((_b = (_a = gptVersion == null ? void 0 : gptVersion.variant) == null ? void 0 : _a.startsWith("chat")) != null ? _b : false);
60
+ const isGptChatModel = (gptVersion == null ? void 0 : gptVersion.minor) == null && ((_b = (_a2 = gptVersion == null ? void 0 : gptVersion.variant) == null ? void 0 : _a2.startsWith("chat")) != null ? _b : false);
61
61
  const isGptNanoModel = (_d = (_c = gptVersion == null ? void 0 : gptVersion.variant) == null ? void 0 : _c.startsWith("nano")) != null ? _d : false;
62
62
  const supportsFlexProcessing = oSeriesVersion != null && oSeriesVersion >= 3 || gptVersion != null && gptVersion.major >= 5 && !isGptChatModel;
63
63
  const supportsPriorityProcessing = modelId.startsWith("gpt-4") || gptVersion != null && gptVersion.major >= 5 && !isGptNanoModel && !isGptChatModel || oSeriesVersion != null && oSeriesVersion >= 3;
@@ -137,10 +137,10 @@ function createOpenAIStreamError({
137
137
  requestBodyValues,
138
138
  responseHeaders
139
139
  }) {
140
- var _a;
140
+ var _a2;
141
141
  const streamError = parseStreamError(frame);
142
142
  return new import_provider.APICallError({
143
- message: (_a = streamError == null ? void 0 : streamError.message) != null ? _a : "OpenAI stream failed before any output was generated",
143
+ message: (_a2 = streamError == null ? void 0 : streamError.message) != null ? _a2 : "OpenAI stream failed before any output was generated",
144
144
  url,
145
145
  requestBodyValues,
146
146
  statusCode: streamError == null ? 500 : getStatusCode(streamError),
@@ -150,7 +150,7 @@ function createOpenAIStreamError({
150
150
  });
151
151
  }
152
152
  function parseStreamError(frame) {
153
- var _a;
153
+ var _a2;
154
154
  const value = asRecord(frame);
155
155
  if (value == null) {
156
156
  return void 0;
@@ -165,7 +165,7 @@ function parseStreamError(frame) {
165
165
  frame
166
166
  } : void 0;
167
167
  }
168
- const error = (_a = asRecord(value.error)) != null ? _a : value;
168
+ const error = (_a2 = asRecord(value.error)) != null ? _a2 : value;
169
169
  return typeof error.message === "string" && (asRecord(value.error) != null || typeof error.type === "string" || "code" in error || "param" in error) ? {
170
170
  message: error.message,
171
171
  code: getStringOrNumber(error.code),
@@ -213,7 +213,7 @@ function isHttpErrorStatusCode(value) {
213
213
 
214
214
  // src/chat/convert-openai-chat-usage.ts
215
215
  function convertOpenAIChatUsage(usage) {
216
- var _a, _b, _c, _d, _e, _f, _g, _h;
216
+ var _a2, _b, _c, _d, _e, _f, _g, _h;
217
217
  if (usage == null) {
218
218
  return {
219
219
  inputTokens: {
@@ -230,7 +230,7 @@ function convertOpenAIChatUsage(usage) {
230
230
  raw: void 0
231
231
  };
232
232
  }
233
- const promptTokens = (_a = usage.prompt_tokens) != null ? _a : 0;
233
+ const promptTokens = (_a2 = usage.prompt_tokens) != null ? _a2 : 0;
234
234
  const completionTokens = (_b = usage.completion_tokens) != null ? _b : 0;
235
235
  const cachedTokens = (_d = (_c = usage.prompt_tokens_details) == null ? void 0 : _c.cached_tokens) != null ? _d : 0;
236
236
  const cacheWriteTokens = (_f = (_e = usage.prompt_tokens_details) == null ? void 0 : _e.cache_write_tokens) != null ? _f : void 0;
@@ -255,17 +255,19 @@ function convertOpenAIChatUsage(usage) {
255
255
  var import_provider2 = require("@ai-sdk/provider");
256
256
  var import_provider_utils2 = require("@ai-sdk/provider-utils");
257
257
  function serializeToolCallArguments(input) {
258
- return JSON.stringify(input === void 0 ? {} : input);
258
+ return JSON.stringify(
259
+ typeof input === "object" && input !== null && !Array.isArray(input) ? input : {}
260
+ );
259
261
  }
260
262
  function getPromptCacheBreakpoint(providerOptions) {
261
- var _a;
262
- return (_a = providerOptions == null ? void 0 : providerOptions.openai) == null ? void 0 : _a.promptCacheBreakpoint;
263
+ var _a2;
264
+ return (_a2 = providerOptions == null ? void 0 : providerOptions.openai) == null ? void 0 : _a2.promptCacheBreakpoint;
263
265
  }
264
266
  function convertToOpenAIChatMessages({
265
267
  prompt,
266
268
  systemMessageMode = "system"
267
269
  }) {
268
- var _a, _b;
270
+ var _a2, _b;
269
271
  const messages = [];
270
272
  const warnings = [];
271
273
  for (const { role, content, providerOptions } of prompt) {
@@ -324,7 +326,7 @@ function convertToOpenAIChatMessages({
324
326
  messages.push({
325
327
  role: "user",
326
328
  content: content.map((part, index) => {
327
- var _a2, _b2, _c;
329
+ var _a3, _b2, _c;
328
330
  switch (part.type) {
329
331
  case "text": {
330
332
  const promptCacheBreakpoint = getPromptCacheBreakpoint(
@@ -349,7 +351,7 @@ function convertToOpenAIChatMessages({
349
351
  image_url: {
350
352
  url: part.data instanceof URL ? part.data.toString() : `data:${mediaType};base64,${(0, import_provider_utils2.convertToBase64)(part.data)}`,
351
353
  // OpenAI specific extension: image detail
352
- detail: (_b2 = (_a2 = part.providerOptions) == null ? void 0 : _a2.openai) == null ? void 0 : _b2.imageDetail
354
+ detail: (_b2 = (_a3 = part.providerOptions) == null ? void 0 : _a3.openai) == null ? void 0 : _b2.imageDetail
353
355
  },
354
356
  ...promptCacheBreakpoint != null && {
355
357
  prompt_cache_breakpoint: promptCacheBreakpoint
@@ -468,7 +470,7 @@ function convertToOpenAIChatMessages({
468
470
  continue;
469
471
  }
470
472
  const output = toolResponse.output;
471
- const promptCacheBreakpoint = (_a = output.type === "content" ? output.value.map((part) => getPromptCacheBreakpoint(part.providerOptions)).find((breakpoint) => breakpoint != null) : getPromptCacheBreakpoint(output.providerOptions)) != null ? _a : getPromptCacheBreakpoint(toolResponse.providerOptions);
473
+ const promptCacheBreakpoint = (_a2 = output.type === "content" ? output.value.map((part) => getPromptCacheBreakpoint(part.providerOptions)).find((breakpoint) => breakpoint != null) : getPromptCacheBreakpoint(output.providerOptions)) != null ? _a2 : getPromptCacheBreakpoint(toolResponse.providerOptions);
472
474
  let contentValue;
473
475
  switch (output.type) {
474
476
  case "text":
@@ -902,13 +904,13 @@ var OpenAIChatLanguageModel = class {
902
904
  toolChoice,
903
905
  providerOptions
904
906
  }) {
905
- var _a, _b, _c, _d, _e;
907
+ var _a2, _b, _c, _d, _e;
906
908
  const warnings = [];
907
- const openaiOptions = (_a = await (0, import_provider_utils5.parseProviderOptions)({
909
+ const openaiOptions = (_a2 = await (0, import_provider_utils5.parseProviderOptions)({
908
910
  provider: "openai",
909
911
  providerOptions,
910
912
  schema: openaiLanguageModelChatOptions
911
- })) != null ? _a : {};
913
+ })) != null ? _a2 : {};
912
914
  const modelCapabilities = getOpenAILanguageModelCapabilities(this.modelId);
913
915
  const isReasoningModel = (_b = openaiOptions.forceReasoning) != null ? _b : modelCapabilities.isReasoningModel;
914
916
  if (topK != null) {
@@ -1070,7 +1072,7 @@ var OpenAIChatLanguageModel = class {
1070
1072
  };
1071
1073
  }
1072
1074
  async doGenerate(options) {
1073
- var _a, _b, _c, _d, _e, _f, _g;
1075
+ var _a2, _b, _c, _d, _e, _f, _g;
1074
1076
  const { args: body, warnings } = await this.getArgs(options);
1075
1077
  const {
1076
1078
  responseHeaders,
@@ -1096,7 +1098,7 @@ var OpenAIChatLanguageModel = class {
1096
1098
  if (text != null && text.length > 0) {
1097
1099
  content.push({ type: "text", text });
1098
1100
  }
1099
- for (const toolCall of (_a = choice.message.tool_calls) != null ? _a : []) {
1101
+ for (const toolCall of (_a2 = choice.message.tool_calls) != null ? _a2 : []) {
1100
1102
  content.push({
1101
1103
  type: "tool-call",
1102
1104
  toolCallId: (_b = toolCall.id) != null ? _b : (0, import_provider_utils5.generateId)(),
@@ -1190,7 +1192,7 @@ var OpenAIChatLanguageModel = class {
1190
1192
  controller.enqueue({ type: "stream-start", warnings });
1191
1193
  },
1192
1194
  transform(chunk, controller) {
1193
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
1195
+ var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
1194
1196
  if (options.includeRawChunks) {
1195
1197
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
1196
1198
  }
@@ -1217,7 +1219,7 @@ var OpenAIChatLanguageModel = class {
1217
1219
  }
1218
1220
  if (value.usage != null) {
1219
1221
  usage = value.usage;
1220
- if (((_a = value.usage.completion_tokens_details) == null ? void 0 : _a.accepted_prediction_tokens) != null) {
1222
+ if (((_a2 = value.usage.completion_tokens_details) == null ? void 0 : _a2.accepted_prediction_tokens) != null) {
1221
1223
  providerMetadata.openai.acceptedPredictionTokens = (_b = value.usage.completion_tokens_details) == null ? void 0 : _b.accepted_prediction_tokens;
1222
1224
  }
1223
1225
  if (((_c = value.usage.completion_tokens_details) == null ? void 0 : _c.rejected_prediction_tokens) != null) {
@@ -1324,7 +1326,7 @@ var OpenAIChatLanguageModel = class {
1324
1326
  }
1325
1327
  },
1326
1328
  flush(controller) {
1327
- var _a;
1329
+ var _a2;
1328
1330
  if (isActiveText) {
1329
1331
  controller.enqueue({ type: "text-end", id: "0" });
1330
1332
  }
@@ -1336,7 +1338,7 @@ var OpenAIChatLanguageModel = class {
1336
1338
  });
1337
1339
  controller.enqueue({
1338
1340
  type: "tool-call",
1339
- toolCallId: (_a = toolCall.id) != null ? _a : (0, import_provider_utils5.generateId)(),
1341
+ toolCallId: (_a2 = toolCall.id) != null ? _a2 : (0, import_provider_utils5.generateId)(),
1340
1342
  toolName: toolCall.function.name,
1341
1343
  input: toolCall.function.arguments
1342
1344
  });
@@ -1373,7 +1375,7 @@ var import_provider_utils8 = require("@ai-sdk/provider-utils");
1373
1375
 
1374
1376
  // src/completion/convert-openai-completion-usage.ts
1375
1377
  function convertOpenAICompletionUsage(usage) {
1376
- var _a, _b, _c, _d;
1378
+ var _a2, _b, _c, _d;
1377
1379
  if (usage == null) {
1378
1380
  return {
1379
1381
  inputTokens: {
@@ -1390,7 +1392,7 @@ function convertOpenAICompletionUsage(usage) {
1390
1392
  raw: void 0
1391
1393
  };
1392
1394
  }
1393
- const promptTokens = (_a = usage.prompt_tokens) != null ? _a : 0;
1395
+ const promptTokens = (_a2 = usage.prompt_tokens) != null ? _a2 : 0;
1394
1396
  const completionTokens = (_b = usage.completion_tokens) != null ? _b : 0;
1395
1397
  return {
1396
1398
  inputTokens: {
@@ -1707,7 +1709,7 @@ var OpenAICompletionLanguageModel = class {
1707
1709
  };
1708
1710
  }
1709
1711
  async doGenerate(options) {
1710
- var _a;
1712
+ var _a2;
1711
1713
  const { args, warnings } = await this.getArgs(options);
1712
1714
  const {
1713
1715
  responseHeaders,
@@ -1737,7 +1739,7 @@ var OpenAICompletionLanguageModel = class {
1737
1739
  usage: convertOpenAICompletionUsage(response.usage),
1738
1740
  finishReason: {
1739
1741
  unified: mapOpenAIFinishReason2(choice.finish_reason),
1740
- raw: (_a = choice.finish_reason) != null ? _a : void 0
1742
+ raw: (_a2 = choice.finish_reason) != null ? _a2 : void 0
1741
1743
  },
1742
1744
  request: { body: args },
1743
1745
  response: {
@@ -1898,10 +1900,13 @@ var openaiTextEmbeddingResponseSchema = (0, import_provider_utils10.lazySchema)(
1898
1900
  );
1899
1901
 
1900
1902
  // src/embedding/openai-embedding-model.ts
1903
+ var _a;
1904
+ _a = import_provider_utils11.EXPERIMENTAL_EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL;
1901
1905
  var OpenAIEmbeddingModel = class {
1902
1906
  constructor(modelId, config) {
1903
1907
  this.specificationVersion = "v3";
1904
1908
  this.maxEmbeddingsPerCall = 2048;
1909
+ this[_a] = 3e5;
1905
1910
  this.supportsParallelCalls = true;
1906
1911
  this.modelId = modelId;
1907
1912
  this.config = config;
@@ -1915,7 +1920,7 @@ var OpenAIEmbeddingModel = class {
1915
1920
  abortSignal,
1916
1921
  providerOptions
1917
1922
  }) {
1918
- var _a;
1923
+ var _a2;
1919
1924
  if (values.length > this.maxEmbeddingsPerCall) {
1920
1925
  throw new import_provider6.TooManyEmbeddingValuesForCallError({
1921
1926
  provider: this.provider,
@@ -1924,11 +1929,11 @@ var OpenAIEmbeddingModel = class {
1924
1929
  values
1925
1930
  });
1926
1931
  }
1927
- const openaiOptions = (_a = await (0, import_provider_utils11.parseProviderOptions)({
1932
+ const openaiOptions = (_a2 = await (0, import_provider_utils11.parseProviderOptions)({
1928
1933
  provider: "openai",
1929
1934
  providerOptions,
1930
1935
  schema: openaiEmbeddingModelOptions
1931
- })) != null ? _a : {};
1936
+ })) != null ? _a2 : {};
1932
1937
  const {
1933
1938
  responseHeaders,
1934
1939
  value: response,
@@ -2014,8 +2019,8 @@ function hasDefaultResponseFormat(modelId) {
2014
2019
  );
2015
2020
  }
2016
2021
  function getMaxImagesPerCall(modelId) {
2017
- var _a;
2018
- return (_a = modelMaxImagesPerCall[modelId]) != null ? _a : modelId.startsWith("gpt-image-") ? 10 : 1;
2022
+ var _a2;
2023
+ return (_a2 = modelMaxImagesPerCall[modelId]) != null ? _a2 : modelId.startsWith("gpt-image-") ? 10 : 1;
2019
2024
  }
2020
2025
  var baseImageModelOptionsObject = import_v49.z.object({
2021
2026
  /**
@@ -2102,7 +2107,7 @@ var OpenAIImageModel = class {
2102
2107
  headers,
2103
2108
  abortSignal
2104
2109
  }) {
2105
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
2110
+ var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
2106
2111
  const warnings = [];
2107
2112
  if (aspectRatio != null) {
2108
2113
  warnings.push({
@@ -2114,7 +2119,7 @@ var OpenAIImageModel = class {
2114
2119
  if (seed != null) {
2115
2120
  warnings.push({ type: "unsupported", feature: "seed" });
2116
2121
  }
2117
- const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
2122
+ const currentDate = (_c = (_b = (_a2 = this.config._internal) == null ? void 0 : _a2.currentDate) == null ? void 0 : _b.call(_a2)) != null ? _c : /* @__PURE__ */ new Date();
2118
2123
  if (files != null) {
2119
2124
  const openaiOptions2 = (_d = await (0, import_provider_utils14.parseProviderOptions)({
2120
2125
  provider: "openai",
@@ -2177,10 +2182,10 @@ var OpenAIImageModel = class {
2177
2182
  providerMetadata: {
2178
2183
  openai: {
2179
2184
  images: response2.data.map((item, index) => {
2180
- var _a2, _b2, _c2, _d2, _e2, _f2;
2185
+ var _a3, _b2, _c2, _d2, _e2, _f2;
2181
2186
  return {
2182
2187
  ...item.revised_prompt ? { revisedPrompt: item.revised_prompt } : {},
2183
- created: (_a2 = response2.created) != null ? _a2 : void 0,
2188
+ created: (_a3 = response2.created) != null ? _a3 : void 0,
2184
2189
  size: (_b2 = response2.size) != null ? _b2 : void 0,
2185
2190
  quality: (_c2 = response2.quality) != null ? _c2 : void 0,
2186
2191
  background: (_d2 = response2.background) != null ? _d2 : void 0,
@@ -2244,10 +2249,10 @@ var OpenAIImageModel = class {
2244
2249
  providerMetadata: {
2245
2250
  openai: {
2246
2251
  images: response.data.map((item, index) => {
2247
- var _a2, _b2, _c2, _d2, _e2, _f2;
2252
+ var _a3, _b2, _c2, _d2, _e2, _f2;
2248
2253
  return {
2249
2254
  ...item.revised_prompt ? { revisedPrompt: item.revised_prompt } : {},
2250
- created: (_a2 = response.created) != null ? _a2 : void 0,
2255
+ created: (_a3 = response.created) != null ? _a3 : void 0,
2251
2256
  size: (_b2 = response.size) != null ? _b2 : void 0,
2252
2257
  quality: (_c2 = response.quality) != null ? _c2 : void 0,
2253
2258
  background: (_d2 = response.background) != null ? _d2 : void 0,
@@ -2937,7 +2942,7 @@ var import_provider_utils31 = require("@ai-sdk/provider-utils");
2937
2942
 
2938
2943
  // src/responses/convert-openai-responses-usage.ts
2939
2944
  function convertOpenAIResponsesUsage(usage) {
2940
- var _a, _b, _c, _d, _e, _f;
2945
+ var _a2, _b, _c, _d, _e, _f;
2941
2946
  if (usage == null) {
2942
2947
  return {
2943
2948
  inputTokens: {
@@ -2956,7 +2961,7 @@ function convertOpenAIResponsesUsage(usage) {
2956
2961
  }
2957
2962
  const inputTokens = usage.input_tokens;
2958
2963
  const outputTokens = usage.output_tokens;
2959
- const cachedTokens = (_b = (_a = usage.input_tokens_details) == null ? void 0 : _a.cached_tokens) != null ? _b : 0;
2964
+ const cachedTokens = (_b = (_a2 = usage.input_tokens_details) == null ? void 0 : _a2.cached_tokens) != null ? _b : 0;
2960
2965
  const cacheWriteTokens = (_d = (_c = usage.input_tokens_details) == null ? void 0 : _c.cache_write_tokens) != null ? _d : void 0;
2961
2966
  const reasoningTokens = (_f = (_e = usage.output_tokens_details) == null ? void 0 : _e.reasoning_tokens) != null ? _f : 0;
2962
2967
  return {
@@ -2989,8 +2994,8 @@ function getParallelToolCallMetadata({
2989
2994
  providerOptions,
2990
2995
  providerOptionsName
2991
2996
  }) {
2992
- var _a;
2993
- const metadata = (_a = providerOptions == null ? void 0 : providerOptions[providerOptionsName]) == null ? void 0 : _a.parallelToolCall;
2997
+ var _a2;
2998
+ const metadata = (_a2 = providerOptions == null ? void 0 : providerOptions[providerOptionsName]) == null ? void 0 : _a2.parallelToolCall;
2994
2999
  if (!(0, import_provider7.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) {
2995
3000
  return void 0;
2996
3001
  }
@@ -3065,19 +3070,19 @@ async function convertFunctionToolResultOutput({
3065
3070
  providerOptionsName,
3066
3071
  warnings
3067
3072
  }) {
3068
- var _a;
3073
+ var _a2;
3069
3074
  switch (output.type) {
3070
3075
  case "text":
3071
3076
  case "error-text":
3072
3077
  return output.value;
3073
3078
  case "execution-denied":
3074
- return (_a = output.reason) != null ? _a : "Tool call execution denied.";
3079
+ return (_a2 = output.reason) != null ? _a2 : "Tool call execution denied.";
3075
3080
  case "json":
3076
3081
  case "error-json":
3077
3082
  return JSON.stringify(output.value);
3078
3083
  case "content":
3079
3084
  return output.value.map((item) => {
3080
- var _a2, _b, _c, _d, _e;
3085
+ var _a3, _b, _c, _d, _e;
3081
3086
  const promptCacheBreakpoint = getPromptCacheBreakpoint2(
3082
3087
  item.providerOptions,
3083
3088
  providerOptionsName
@@ -3096,7 +3101,7 @@ async function convertFunctionToolResultOutput({
3096
3101
  return {
3097
3102
  type: "input_image",
3098
3103
  image_url: `data:${item.mediaType};base64,${item.data}`,
3099
- detail: (_b = (_a2 = item.providerOptions) == null ? void 0 : _a2[providerOptionsName]) == null ? void 0 : _b.imageDetail,
3104
+ detail: (_b = (_a3 = item.providerOptions) == null ? void 0 : _a3[providerOptionsName]) == null ? void 0 : _b.imageDetail,
3100
3105
  ...promptCacheBreakpoint != null && {
3101
3106
  prompt_cache_breakpoint: promptCacheBreakpoint
3102
3107
  }
@@ -3200,8 +3205,8 @@ function collectCompleteParallelToolResultGroups({
3200
3205
  return completeGroups;
3201
3206
  }
3202
3207
  function getPromptCacheBreakpoint2(providerOptions, providerOptionsName) {
3203
- var _a;
3204
- return (_a = providerOptions == null ? void 0 : providerOptions[providerOptionsName]) == null ? void 0 : _a.promptCacheBreakpoint;
3208
+ var _a2;
3209
+ return (_a2 = providerOptions == null ? void 0 : providerOptions[providerOptionsName]) == null ? void 0 : _a2.promptCacheBreakpoint;
3205
3210
  }
3206
3211
  function isFileId(data, prefixes) {
3207
3212
  if (!prefixes) return false;
@@ -3220,9 +3225,10 @@ async function convertToOpenAIResponsesInput({
3220
3225
  hasLocalShellTool = false,
3221
3226
  hasShellTool = false,
3222
3227
  hasApplyPatchTool = false,
3228
+ toolSearchToolName,
3223
3229
  customProviderToolNames
3224
3230
  }) {
3225
- 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;
3231
+ var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
3226
3232
  let input = [];
3227
3233
  const warnings = [];
3228
3234
  const processedApprovalIds = /* @__PURE__ */ new Set();
@@ -3290,7 +3296,7 @@ async function convertToOpenAIResponsesInput({
3290
3296
  input.push({
3291
3297
  role: "user",
3292
3298
  content: content.map((part, index) => {
3293
- var _a2, _b2, _c2;
3299
+ var _a3, _b2, _c2;
3294
3300
  switch (part.type) {
3295
3301
  case "text": {
3296
3302
  const promptCacheBreakpoint = getPromptCacheBreakpoint2(
@@ -3317,7 +3323,7 @@ async function convertToOpenAIResponsesInput({
3317
3323
  ...part.data instanceof URL ? { image_url: part.data.toString() } : typeof part.data === "string" && isFileId(part.data, fileIdPrefixes) ? { file_id: part.data } : {
3318
3324
  image_url: `data:${mediaType};base64,${(0, import_provider_utils27.convertToBase64)(part.data)}`
3319
3325
  },
3320
- detail: (_b2 = (_a2 = part.providerOptions) == null ? void 0 : _a2[providerOptionsName]) == null ? void 0 : _b2.imageDetail,
3326
+ detail: (_b2 = (_a3 = part.providerOptions) == null ? void 0 : _a3[providerOptionsName]) == null ? void 0 : _b2.imageDetail,
3321
3327
  ...promptCacheBreakpoint != null && {
3322
3328
  prompt_cache_breakpoint: promptCacheBreakpoint
3323
3329
  }
@@ -3358,7 +3364,7 @@ async function convertToOpenAIResponsesInput({
3358
3364
  for (const part of content) {
3359
3365
  switch (part.type) {
3360
3366
  case "text": {
3361
- const providerOpts = (_a = part.providerOptions) == null ? void 0 : _a[providerOptionsName];
3367
+ const providerOpts = (_a2 = part.providerOptions) == null ? void 0 : _a2[providerOptionsName];
3362
3368
  const id = providerOpts == null ? void 0 : providerOpts.itemId;
3363
3369
  const phase = providerOpts == null ? void 0 : providerOpts.phase;
3364
3370
  if (hasConversation && id != null) {
@@ -3413,7 +3419,7 @@ async function convertToOpenAIResponsesInput({
3413
3419
  const resolvedToolName = toolNameMapping.toProviderToolName(
3414
3420
  part.toolName
3415
3421
  );
3416
- if (resolvedToolName === "tool_search") {
3422
+ if (part.toolName === toolSearchToolName) {
3417
3423
  if (store && id != null) {
3418
3424
  input.push({ type: "item_reference", id });
3419
3425
  break;
@@ -3534,7 +3540,7 @@ async function convertToOpenAIResponsesInput({
3534
3540
  const resolvedResultToolName = toolNameMapping.toProviderToolName(
3535
3541
  part.toolName
3536
3542
  );
3537
- if (resolvedResultToolName === "tool_search") {
3543
+ if (part.toolName === toolSearchToolName) {
3538
3544
  const itemId = (_s = (_r = (_o = (_n = part.providerOptions) == null ? void 0 : _n[providerOptionsName]) == null ? void 0 : _o.itemId) != null ? _r : (_q = (_p = part.providerMetadata) == null ? void 0 : _p[providerOptionsName]) == null ? void 0 : _q.itemId) != null ? _s : part.toolCallId;
3539
3545
  if (store) {
3540
3546
  input.push({ type: "item_reference", id: itemId });
@@ -3732,7 +3738,7 @@ async function convertToOpenAIResponsesInput({
3732
3738
  const resolvedToolName = toolNameMapping.toProviderToolName(
3733
3739
  part.toolName
3734
3740
  );
3735
- if (resolvedToolName === "tool_search" && output.type === "json") {
3741
+ if (part.toolName === toolSearchToolName && output.type === "json") {
3736
3742
  const parsedOutput = await (0, import_provider_utils27.validateTypes)({
3737
3743
  value: output.value,
3738
3744
  schema: toolSearchOutputSchema
@@ -3806,7 +3812,7 @@ async function convertToOpenAIResponsesInput({
3806
3812
  break;
3807
3813
  case "content":
3808
3814
  outputValue = output.value.map((item) => {
3809
- var _a2, _b2, _c2, _d2, _e2;
3815
+ var _a3, _b2, _c2, _d2, _e2;
3810
3816
  const promptCacheBreakpoint = getPromptCacheBreakpoint2(
3811
3817
  item.providerOptions,
3812
3818
  providerOptionsName
@@ -3824,7 +3830,7 @@ async function convertToOpenAIResponsesInput({
3824
3830
  return {
3825
3831
  type: "input_image",
3826
3832
  image_url: `data:${item.mediaType};base64,${item.data}`,
3827
- detail: (_b2 = (_a2 = item.providerOptions) == null ? void 0 : _a2[providerOptionsName]) == null ? void 0 : _b2.imageDetail,
3833
+ detail: (_b2 = (_a3 = item.providerOptions) == null ? void 0 : _a3[providerOptionsName]) == null ? void 0 : _b2.imageDetail,
3828
3834
  ...promptCacheBreakpoint != null && {
3829
3835
  prompt_cache_breakpoint: promptCacheBreakpoint
3830
3836
  }
@@ -3942,6 +3948,22 @@ var jsonValueSchema2 = import_v422.z.lazy(
3942
3948
  import_v422.z.record(import_v422.z.string(), jsonValueSchema2.optional())
3943
3949
  ])
3944
3950
  );
3951
+ function isRecord(value) {
3952
+ return value != null && typeof value === "object" && !Array.isArray(value);
3953
+ }
3954
+ var openaiResponsesLocalShellCallSchema = import_v422.z.object({
3955
+ type: import_v422.z.literal("local_shell_call"),
3956
+ id: import_v422.z.string(),
3957
+ call_id: import_v422.z.string(),
3958
+ action: import_v422.z.object({
3959
+ type: import_v422.z.literal("exec"),
3960
+ command: import_v422.z.array(import_v422.z.string()),
3961
+ timeout_ms: import_v422.z.number().optional(),
3962
+ user: import_v422.z.string().optional(),
3963
+ working_directory: import_v422.z.string().optional(),
3964
+ env: import_v422.z.record(import_v422.z.string(), import_v422.z.string()).optional()
3965
+ })
3966
+ });
3945
3967
  var openaiResponsesNestedErrorChunkSchema = import_v422.z.object({
3946
3968
  type: import_v422.z.literal("error"),
3947
3969
  sequence_number: import_v422.z.number(),
@@ -3959,6 +3981,60 @@ var openaiResponsesErrorChunkSchema = import_v422.z.object({
3959
3981
  message: import_v422.z.string(),
3960
3982
  param: import_v422.z.string().nullish()
3961
3983
  });
3984
+ var openaiResponsesModeledChunkTypes = /* @__PURE__ */ new Set([
3985
+ "error",
3986
+ "response.apply_patch_call_operation_diff.delta",
3987
+ "response.apply_patch_call_operation_diff.done",
3988
+ "response.code_interpreter_call_code.delta",
3989
+ "response.code_interpreter_call_code.done",
3990
+ "response.completed",
3991
+ "response.created",
3992
+ "response.custom_tool_call_input.delta",
3993
+ "response.failed",
3994
+ "response.function_call_arguments.delta",
3995
+ "response.function_call_arguments.done",
3996
+ "response.image_generation_call.partial_image",
3997
+ "response.incomplete",
3998
+ "response.output_item.added",
3999
+ "response.output_item.done",
4000
+ "response.output_text.annotation.added",
4001
+ "response.output_text.delta",
4002
+ "response.reasoning_summary_part.added",
4003
+ "response.reasoning_summary_part.done",
4004
+ "response.reasoning_summary_text.delta"
4005
+ ]);
4006
+ var openaiResponsesModeledOutputItemTypes = /* @__PURE__ */ new Set([
4007
+ "apply_patch_call",
4008
+ "code_interpreter_call",
4009
+ "computer_call",
4010
+ "custom_tool_call",
4011
+ "file_search_call",
4012
+ "function_call",
4013
+ "image_generation_call",
4014
+ "local_shell_call",
4015
+ "mcp_approval_request",
4016
+ "mcp_call",
4017
+ "mcp_list_tools",
4018
+ "message",
4019
+ "reasoning",
4020
+ "shell_call",
4021
+ "shell_call_output",
4022
+ "tool_search_call",
4023
+ "tool_search_output",
4024
+ "web_search_call"
4025
+ ]);
4026
+ function isModeledOpenAIResponsesChunk(value) {
4027
+ if (typeof value.type !== "string" || !openaiResponsesModeledChunkTypes.has(value.type)) {
4028
+ return false;
4029
+ }
4030
+ if (value.type !== "response.output_item.added" && value.type !== "response.output_item.done") {
4031
+ return true;
4032
+ }
4033
+ if (!isRecord(value.item) || typeof value.item.type !== "string") {
4034
+ return true;
4035
+ }
4036
+ return openaiResponsesModeledOutputItemTypes.has(value.item.type);
4037
+ }
3962
4038
  var openaiResponsesChunkSchema = (0, import_provider_utils28.lazySchema)(
3963
4039
  () => (0, import_provider_utils28.zodSchema)(
3964
4040
  import_v422.z.union([
@@ -4077,6 +4153,7 @@ var openaiResponsesChunkSchema = (0, import_provider_utils28.lazySchema)(
4077
4153
  type: import_v422.z.literal("file_search_call"),
4078
4154
  id: import_v422.z.string()
4079
4155
  }),
4156
+ openaiResponsesLocalShellCallSchema,
4080
4157
  import_v422.z.object({
4081
4158
  type: import_v422.z.literal("image_generation_call"),
4082
4159
  id: import_v422.z.string()
@@ -4275,19 +4352,7 @@ var openaiResponsesChunkSchema = (0, import_provider_utils28.lazySchema)(
4275
4352
  })
4276
4353
  ).nullish()
4277
4354
  }),
4278
- import_v422.z.object({
4279
- type: import_v422.z.literal("local_shell_call"),
4280
- id: import_v422.z.string(),
4281
- call_id: import_v422.z.string(),
4282
- action: import_v422.z.object({
4283
- type: import_v422.z.literal("exec"),
4284
- command: import_v422.z.array(import_v422.z.string()),
4285
- timeout_ms: import_v422.z.number().optional(),
4286
- user: import_v422.z.string().optional(),
4287
- working_directory: import_v422.z.string().optional(),
4288
- env: import_v422.z.record(import_v422.z.string(), import_v422.z.string()).optional()
4289
- })
4290
- }),
4355
+ openaiResponsesLocalShellCallSchema,
4291
4356
  import_v422.z.object({
4292
4357
  type: import_v422.z.literal("computer_call"),
4293
4358
  id: import_v422.z.string(),
@@ -4414,6 +4479,14 @@ var openaiResponsesChunkSchema = (0, import_provider_utils28.lazySchema)(
4414
4479
  output_index: import_v422.z.number(),
4415
4480
  delta: import_v422.z.string()
4416
4481
  }),
4482
+ import_v422.z.object({
4483
+ // `name` is documented as required but omitted from live API events:
4484
+ // https://github.com/openai/openai-openapi/issues/545
4485
+ type: import_v422.z.literal("response.function_call_arguments.done"),
4486
+ item_id: import_v422.z.string(),
4487
+ output_index: import_v422.z.number(),
4488
+ arguments: import_v422.z.string()
4489
+ }),
4417
4490
  import_v422.z.object({
4418
4491
  type: import_v422.z.literal("response.custom_tool_call_input.delta"),
4419
4492
  item_id: import_v422.z.string(),
@@ -4500,7 +4573,9 @@ var openaiResponsesChunkSchema = (0, import_provider_utils28.lazySchema)(
4500
4573
  }),
4501
4574
  openaiResponsesNestedErrorChunkSchema,
4502
4575
  openaiResponsesErrorChunkSchema,
4503
- import_v422.z.object({ type: import_v422.z.string() }).loose().transform((value) => ({
4576
+ import_v422.z.object({ type: import_v422.z.string() }).loose().refine((value) => !isModeledOpenAIResponsesChunk(value), {
4577
+ message: "Known response chunk failed schema validation"
4578
+ }).transform((value) => ({
4504
4579
  type: "unknown_chunk",
4505
4580
  message: value.type
4506
4581
  }))
@@ -4640,19 +4715,7 @@ var openaiResponsesResponseSchema = (0, import_provider_utils28.lazySchema)(
4640
4715
  id: import_v422.z.string(),
4641
4716
  result: import_v422.z.string()
4642
4717
  }),
4643
- import_v422.z.object({
4644
- type: import_v422.z.literal("local_shell_call"),
4645
- id: import_v422.z.string(),
4646
- call_id: import_v422.z.string(),
4647
- action: import_v422.z.object({
4648
- type: import_v422.z.literal("exec"),
4649
- command: import_v422.z.array(import_v422.z.string()),
4650
- timeout_ms: import_v422.z.number().optional(),
4651
- user: import_v422.z.string().optional(),
4652
- working_directory: import_v422.z.string().optional(),
4653
- env: import_v422.z.record(import_v422.z.string(), import_v422.z.string()).optional()
4654
- })
4655
- }),
4718
+ openaiResponsesLocalShellCallSchema,
4656
4719
  import_v422.z.object({
4657
4720
  type: import_v422.z.literal("function_call"),
4658
4721
  call_id: import_v422.z.string(),
@@ -5102,7 +5165,7 @@ async function prepareResponsesTools({
5102
5165
  toolNameMapping,
5103
5166
  customProviderToolNames
5104
5167
  }) {
5105
- var _a, _b, _c, _d;
5168
+ var _a2, _b, _c, _d;
5106
5169
  tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
5107
5170
  const toolWarnings = [];
5108
5171
  if (tools == null) {
@@ -5128,7 +5191,7 @@ async function prepareResponsesTools({
5128
5191
  for (const tool of tools) {
5129
5192
  switch (tool.type) {
5130
5193
  case "function": {
5131
- const openaiOptions = (_a = tool.providerOptions) == null ? void 0 : _a.openai;
5194
+ const openaiOptions = (_a2 = tool.providerOptions) == null ? void 0 : _a2.openai;
5132
5195
  const openaiFunctionTool = prepareFunctionTool({
5133
5196
  tool,
5134
5197
  options: openaiOptions
@@ -5545,13 +5608,13 @@ function mapShellSkills(skills) {
5545
5608
 
5546
5609
  // src/responses/openai-responses-language-model.ts
5547
5610
  function extractApprovalRequestIdToToolCallIdMapping(prompt) {
5548
- var _a, _b;
5611
+ var _a2, _b;
5549
5612
  const mapping = {};
5550
5613
  for (const message of prompt) {
5551
5614
  if (message.role !== "assistant") continue;
5552
5615
  for (const part of message.content) {
5553
5616
  if (part.type !== "tool-call") continue;
5554
- const approvalRequestId = (_b = (_a = part.providerOptions) == null ? void 0 : _a.openai) == null ? void 0 : _b.approvalRequestId;
5617
+ const approvalRequestId = (_b = (_a2 = part.providerOptions) == null ? void 0 : _a2.openai) == null ? void 0 : _b.approvalRequestId;
5555
5618
  if (approvalRequestId != null) {
5556
5619
  mapping[approvalRequestId] = part.toolCallId;
5557
5620
  }
@@ -5587,7 +5650,7 @@ var OpenAIResponsesLanguageModel = class {
5587
5650
  toolChoice,
5588
5651
  responseFormat
5589
5652
  }) {
5590
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
5653
+ var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
5591
5654
  const warnings = [];
5592
5655
  const modelCapabilities = getOpenAILanguageModelCapabilities(this.modelId);
5593
5656
  if (topK != null) {
@@ -5618,7 +5681,7 @@ var OpenAIResponsesLanguageModel = class {
5618
5681
  schema: openaiLanguageModelResponsesOptionsSchema
5619
5682
  });
5620
5683
  }
5621
- const isReasoningModel = (_a = openaiOptions == null ? void 0 : openaiOptions.forceReasoning) != null ? _a : modelCapabilities.isReasoningModel;
5684
+ const isReasoningModel = (_a2 = openaiOptions == null ? void 0 : openaiOptions.forceReasoning) != null ? _a2 : modelCapabilities.isReasoningModel;
5622
5685
  if ((openaiOptions == null ? void 0 : openaiOptions.conversation) && (openaiOptions == null ? void 0 : openaiOptions.previousResponseId)) {
5623
5686
  warnings.push({
5624
5687
  type: "unsupported",
@@ -5667,6 +5730,7 @@ var OpenAIResponsesLanguageModel = class {
5667
5730
  hasLocalShellTool: hasOpenAITool("openai.local_shell"),
5668
5731
  hasShellTool: hasOpenAITool("openai.shell"),
5669
5732
  hasApplyPatchTool: hasOpenAITool("openai.apply_patch"),
5733
+ toolSearchToolName: getOpenAIToolName("openai.tool_search"),
5670
5734
  customProviderToolNames: customProviderToolNames.size > 0 ? customProviderToolNames : void 0
5671
5735
  });
5672
5736
  warnings.push(...inputWarnings);
@@ -5679,8 +5743,12 @@ var OpenAIResponsesLanguageModel = class {
5679
5743
  include = [...include, key];
5680
5744
  }
5681
5745
  }
5746
+ function getOpenAIToolName(id) {
5747
+ var _a3;
5748
+ return (_a3 = tools == null ? void 0 : tools.find((tool) => tool.type === "provider" && tool.id === id)) == null ? void 0 : _a3.name;
5749
+ }
5682
5750
  function hasOpenAITool(id) {
5683
- return (tools == null ? void 0 : tools.find((tool) => tool.type === "provider" && tool.id === id)) != null;
5751
+ return getOpenAIToolName(id) != null;
5684
5752
  }
5685
5753
  const topLogprobs = typeof (openaiOptions == null ? void 0 : openaiOptions.logprobs) === "number" ? openaiOptions == null ? void 0 : openaiOptions.logprobs : (openaiOptions == null ? void 0 : openaiOptions.logprobs) === true ? TOP_LOGPROBS_MAX : void 0;
5686
5754
  if (topLogprobs) {
@@ -5840,7 +5908,7 @@ var OpenAIResponsesLanguageModel = class {
5840
5908
  };
5841
5909
  }
5842
5910
  async doGenerate(options) {
5843
- 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;
5911
+ var _a2, _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;
5844
5912
  const {
5845
5913
  args: body,
5846
5914
  warnings,
@@ -5882,7 +5950,7 @@ var OpenAIResponsesLanguageModel = class {
5882
5950
  }
5883
5951
  const content = [];
5884
5952
  const logprobs = [];
5885
- const functionTools = (_b = (_a = options.tools) == null ? void 0 : _a.filter(
5953
+ const functionTools = (_b = (_a2 = options.tools) == null ? void 0 : _a2.filter(
5886
5954
  (tool) => tool.type === "function"
5887
5955
  )) != null ? _b : [];
5888
5956
  let hasFunctionCall = false;
@@ -6334,7 +6402,7 @@ var OpenAIResponsesLanguageModel = class {
6334
6402
  };
6335
6403
  }
6336
6404
  async doStream(options) {
6337
- var _a, _b;
6405
+ var _a2, _b;
6338
6406
  const {
6339
6407
  args: body,
6340
6408
  warnings,
@@ -6372,7 +6440,7 @@ var OpenAIResponsesLanguageModel = class {
6372
6440
  });
6373
6441
  const self = this;
6374
6442
  const approvalRequestIdToDummyToolCallIdFromPrompt = extractApprovalRequestIdToToolCallIdMapping(options.prompt);
6375
- const functionTools = (_b = (_a = options.tools) == null ? void 0 : _a.filter(
6443
+ const functionTools = (_b = (_a2 = options.tools) == null ? void 0 : _a2.filter(
6376
6444
  (tool) => tool.type === "function"
6377
6445
  )) != null ? _b : [];
6378
6446
  const approvalRequestIdToDummyToolCallIdFromStream = /* @__PURE__ */ new Map();
@@ -6399,7 +6467,7 @@ var OpenAIResponsesLanguageModel = class {
6399
6467
  controller.enqueue({ type: "stream-start", warnings });
6400
6468
  },
6401
6469
  transform(chunk, controller) {
6402
- 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;
6470
+ var _a3, _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;
6403
6471
  if (options.includeRawChunks) {
6404
6472
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
6405
6473
  }
@@ -6411,6 +6479,7 @@ var OpenAIResponsesLanguageModel = class {
6411
6479
  requestBodyValues: body,
6412
6480
  responseHeaders
6413
6481
  }) : chunk.error;
6482
+ encounteredStreamError = true;
6414
6483
  finishReason = { unified: "error", raw: void 0 };
6415
6484
  controller.enqueue({ type: "error", error });
6416
6485
  return;
@@ -6529,7 +6598,7 @@ var OpenAIResponsesLanguageModel = class {
6529
6598
  ongoingToolCalls[value.output_index] = {
6530
6599
  toolName,
6531
6600
  toolCallId,
6532
- toolSearchExecution: (_a2 = value.item.execution) != null ? _a2 : "server"
6601
+ toolSearchExecution: (_a3 = value.item.execution) != null ? _a3 : "server"
6533
6602
  };
6534
6603
  if (isHosted) {
6535
6604
  controller.enqueue({
@@ -6642,14 +6711,14 @@ var OpenAIResponsesLanguageModel = class {
6642
6711
  tools: functionTools
6643
6712
  });
6644
6713
  const enqueueUnexpandedToolCall = () => {
6645
- var _a3;
6714
+ var _a4;
6646
6715
  if (suppressInputStreaming) {
6647
6716
  controller.enqueue({
6648
6717
  type: "tool-input-start",
6649
6718
  id: item.call_id,
6650
6719
  toolName: item.name
6651
6720
  });
6652
- const bufferedInputDeltas = (_a3 = ongoingToolCall == null ? void 0 : ongoingToolCall.bufferedInputDeltas) != null ? _a3 : [];
6721
+ const bufferedInputDeltas = (_a4 = ongoingToolCall == null ? void 0 : ongoingToolCall.bufferedInputDeltas) != null ? _a4 : [];
6653
6722
  if (bufferedInputDeltas.length > 0) {
6654
6723
  for (const delta of bufferedInputDeltas) {
6655
6724
  controller.enqueue({
@@ -7210,13 +7279,15 @@ var OpenAIResponsesLanguageModel = class {
7210
7279
  activeReasoning[value.item_id].summaryParts[value.summary_index] = "can-conclude";
7211
7280
  }
7212
7281
  } else if (isResponseFinishedChunk(value)) {
7213
- finishReason = {
7214
- unified: mapOpenAIResponseFinishReason({
7215
- finishReason: (_x = value.response.incomplete_details) == null ? void 0 : _x.reason,
7216
- hasFunctionCall
7217
- }),
7218
- raw: (_z = (_y = value.response.incomplete_details) == null ? void 0 : _y.reason) != null ? _z : void 0
7219
- };
7282
+ if (!encounteredStreamError) {
7283
+ finishReason = {
7284
+ unified: mapOpenAIResponseFinishReason({
7285
+ finishReason: (_x = value.response.incomplete_details) == null ? void 0 : _x.reason,
7286
+ hasFunctionCall
7287
+ }),
7288
+ raw: (_z = (_y = value.response.incomplete_details) == null ? void 0 : _y.reason) != null ? _z : void 0
7289
+ };
7290
+ }
7220
7291
  usage = value.response.usage;
7221
7292
  if (typeof value.response.service_tier === "string") {
7222
7293
  serviceTier = value.response.service_tier;
@@ -7318,7 +7389,7 @@ var OpenAIResponsesLanguageModel = class {
7318
7389
  }
7319
7390
  },
7320
7391
  flush(controller) {
7321
- var _a2;
7392
+ var _a3;
7322
7393
  for (const toolCall of Object.values(ongoingToolCalls)) {
7323
7394
  if (!(toolCall == null ? void 0 : toolCall.suppressInputStreaming)) {
7324
7395
  continue;
@@ -7328,7 +7399,7 @@ var OpenAIResponsesLanguageModel = class {
7328
7399
  id: toolCall.toolCallId,
7329
7400
  toolName: toolCall.toolName
7330
7401
  });
7331
- for (const delta of (_a2 = toolCall.bufferedInputDeltas) != null ? _a2 : []) {
7402
+ for (const delta of (_a3 = toolCall.bufferedInputDeltas) != null ? _a3 : []) {
7332
7403
  controller.enqueue({
7333
7404
  type: "tool-input-delta",
7334
7405
  id: toolCall.toolCallId,
@@ -7433,7 +7504,7 @@ function isResponseOutputChunk(chunk) {
7433
7504
  return !(chunk.type === "response.created" || chunk.type === "response.failed" || chunk.type === "error" || chunk.type === "unknown_chunk");
7434
7505
  }
7435
7506
  function mapWebSearchOutput(action) {
7436
- var _a;
7507
+ var _a2;
7437
7508
  if (action == null) {
7438
7509
  return {};
7439
7510
  }
@@ -7442,7 +7513,7 @@ function mapWebSearchOutput(action) {
7442
7513
  return {
7443
7514
  action: {
7444
7515
  type: "search",
7445
- query: (_a = action.query) != null ? _a : void 0,
7516
+ query: (_a2 = action.query) != null ? _a2 : void 0,
7446
7517
  ...action.queries != null && { queries: action.queries }
7447
7518
  },
7448
7519
  // include sources when provided by the Responses API (behind include flag)
@@ -7545,8 +7616,8 @@ var OpenAISpeechModel = class {
7545
7616
  };
7546
7617
  }
7547
7618
  async doGenerate(options) {
7548
- var _a, _b, _c;
7549
- const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
7619
+ var _a2, _b, _c;
7620
+ const currentDate = (_c = (_b = (_a2 = this.config._internal) == null ? void 0 : _a2.currentDate) == null ? void 0 : _b.call(_a2)) != null ? _c : /* @__PURE__ */ new Date();
7550
7621
  const { requestBody, warnings } = await this.getArgs(options);
7551
7622
  const {
7552
7623
  value: audio,
@@ -7770,8 +7841,8 @@ var OpenAITranscriptionModel = class {
7770
7841
  };
7771
7842
  }
7772
7843
  async doGenerate(options) {
7773
- var _a, _b, _c, _d, _e, _f, _g, _h;
7774
- const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
7844
+ var _a2, _b, _c, _d, _e, _f, _g, _h;
7845
+ const currentDate = (_c = (_b = (_a2 = this.config._internal) == null ? void 0 : _a2.currentDate) == null ? void 0 : _b.call(_a2)) != null ? _c : /* @__PURE__ */ new Date();
7775
7846
  const { formData, warnings } = await this.getArgs(options);
7776
7847
  const {
7777
7848
  value: response,
@@ -7817,17 +7888,17 @@ var OpenAITranscriptionModel = class {
7817
7888
  };
7818
7889
 
7819
7890
  // src/version.ts
7820
- var VERSION = true ? "3.0.101" : "0.0.0-test";
7891
+ var VERSION = true ? "3.0.104" : "0.0.0-test";
7821
7892
 
7822
7893
  // src/openai-provider.ts
7823
7894
  function createOpenAI(options = {}) {
7824
- var _a, _b;
7825
- const baseURL = (_a = (0, import_provider_utils37.withoutTrailingSlash)(
7895
+ var _a2, _b;
7896
+ const baseURL = (_a2 = (0, import_provider_utils37.withoutTrailingSlash)(
7826
7897
  (0, import_provider_utils37.loadOptionalSetting)({
7827
7898
  settingValue: options.baseURL,
7828
7899
  environmentVariableName: "OPENAI_BASE_URL"
7829
7900
  })
7830
- )) != null ? _a : "https://api.openai.com/v1";
7901
+ )) != null ? _a2 : "https://api.openai.com/v1";
7831
7902
  const providerName = (_b = options.name) != null ? _b : "openai";
7832
7903
  const getHeaders = () => (0, import_provider_utils37.withUserAgentSuffix)(
7833
7904
  {