@ai-sdk/openai 2.0.28 → 2.0.29

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
@@ -1807,8 +1807,20 @@ var openaiImageResponseSchema = z10.object({
1807
1807
  });
1808
1808
 
1809
1809
  // src/tool/code-interpreter.ts
1810
- import { createProviderDefinedToolFactory as createProviderDefinedToolFactory3 } from "@ai-sdk/provider-utils";
1810
+ import { createProviderDefinedToolFactoryWithOutputSchema } from "@ai-sdk/provider-utils";
1811
1811
  import { z as z11 } from "zod/v4";
1812
+ var codeInterpreterInputSchema = z11.object({
1813
+ code: z11.string().nullish(),
1814
+ containerId: z11.string()
1815
+ });
1816
+ var codeInterpreterOutputSchema = z11.object({
1817
+ outputs: z11.array(
1818
+ z11.discriminatedUnion("type", [
1819
+ z11.object({ type: z11.literal("logs"), logs: z11.string() }),
1820
+ z11.object({ type: z11.literal("image"), url: z11.string() })
1821
+ ])
1822
+ ).nullish()
1823
+ });
1812
1824
  var codeInterpreterArgsSchema = z11.object({
1813
1825
  container: z11.union([
1814
1826
  z11.string(),
@@ -1817,17 +1829,18 @@ var codeInterpreterArgsSchema = z11.object({
1817
1829
  })
1818
1830
  ]).optional()
1819
1831
  });
1820
- var codeInterpreterToolFactory = createProviderDefinedToolFactory3({
1832
+ var codeInterpreterToolFactory = createProviderDefinedToolFactoryWithOutputSchema({
1821
1833
  id: "openai.code_interpreter",
1822
1834
  name: "code_interpreter",
1823
- inputSchema: z11.object({})
1835
+ inputSchema: codeInterpreterInputSchema,
1836
+ outputSchema: codeInterpreterOutputSchema
1824
1837
  });
1825
1838
  var codeInterpreter = (args = {}) => {
1826
1839
  return codeInterpreterToolFactory(args);
1827
1840
  };
1828
1841
 
1829
1842
  // src/tool/web-search.ts
1830
- import { createProviderDefinedToolFactory as createProviderDefinedToolFactory4 } from "@ai-sdk/provider-utils";
1843
+ import { createProviderDefinedToolFactory as createProviderDefinedToolFactory3 } from "@ai-sdk/provider-utils";
1831
1844
  import { z as z12 } from "zod/v4";
1832
1845
  var webSearchArgsSchema = z12.object({
1833
1846
  filters: z12.object({
@@ -1842,7 +1855,7 @@ var webSearchArgsSchema = z12.object({
1842
1855
  timezone: z12.string().optional()
1843
1856
  }).optional()
1844
1857
  });
1845
- var webSearchToolFactory = createProviderDefinedToolFactory4({
1858
+ var webSearchToolFactory = createProviderDefinedToolFactory3({
1846
1859
  id: "openai.web_search",
1847
1860
  name: "web_search",
1848
1861
  inputSchema: z12.object({
@@ -2272,6 +2285,18 @@ var webSearchCallItem = z14.object({
2272
2285
  })
2273
2286
  ]).nullish()
2274
2287
  });
2288
+ var codeInterpreterCallItem = z14.object({
2289
+ type: z14.literal("code_interpreter_call"),
2290
+ id: z14.string(),
2291
+ code: z14.string().nullable(),
2292
+ container_id: z14.string(),
2293
+ outputs: z14.array(
2294
+ z14.discriminatedUnion("type", [
2295
+ z14.object({ type: z14.literal("logs"), logs: z14.string() }),
2296
+ z14.object({ type: z14.literal("image"), url: z14.string() })
2297
+ ])
2298
+ ).nullable()
2299
+ });
2275
2300
  var TOP_LOGPROBS_MAX = 20;
2276
2301
  var LOGPROBS_SCHEMA = z14.array(
2277
2302
  z14.object({
@@ -2313,7 +2338,7 @@ var OpenAIResponsesLanguageModel = class {
2313
2338
  toolChoice,
2314
2339
  responseFormat
2315
2340
  }) {
2316
- var _a, _b, _c;
2341
+ var _a, _b, _c, _d;
2317
2342
  const warnings = [];
2318
2343
  const modelConfig = getResponsesModelConfig(this.modelId);
2319
2344
  if (topK != null) {
@@ -2356,6 +2381,10 @@ var OpenAIResponsesLanguageModel = class {
2356
2381
  (tool) => tool.type === "provider-defined" && (tool.id === "openai.web_search" || tool.id === "openai.web_search_preview")
2357
2382
  )) == null ? void 0 : _b.name;
2358
2383
  include = webSearchToolName ? Array.isArray(include) ? [...include, "web_search_call.action.sources"] : ["web_search_call.action.sources"] : include;
2384
+ const codeInterpreterToolName = (_c = tools == null ? void 0 : tools.find(
2385
+ (tool) => tool.type === "provider-defined" && tool.id === "openai.code_interpreter"
2386
+ )) == null ? void 0 : _c.name;
2387
+ include = codeInterpreterToolName ? Array.isArray(include) ? [...include, "code_interpreter_call.outputs"] : ["code_interpreter_call.outputs"] : include;
2359
2388
  const baseArgs = {
2360
2389
  model: this.modelId,
2361
2390
  input: messages,
@@ -2368,7 +2397,7 @@ var OpenAIResponsesLanguageModel = class {
2368
2397
  format: responseFormat.schema != null ? {
2369
2398
  type: "json_schema",
2370
2399
  strict: strictJsonSchema,
2371
- name: (_c = responseFormat.name) != null ? _c : "response",
2400
+ name: (_d = responseFormat.name) != null ? _d : "response",
2372
2401
  description: responseFormat.description,
2373
2402
  schema: responseFormat.schema
2374
2403
  } : { type: "json_object" }
@@ -2539,9 +2568,7 @@ var OpenAIResponsesLanguageModel = class {
2539
2568
  })
2540
2569
  )
2541
2570
  }),
2542
- z14.object({
2543
- type: z14.literal("code_interpreter_call")
2544
- }),
2571
+ codeInterpreterCallItem,
2545
2572
  z14.object({
2546
2573
  type: z14.literal("function_call"),
2547
2574
  call_id: z14.string(),
@@ -2737,6 +2764,28 @@ var OpenAIResponsesLanguageModel = class {
2737
2764
  });
2738
2765
  break;
2739
2766
  }
2767
+ case "code_interpreter_call": {
2768
+ content.push({
2769
+ type: "tool-call",
2770
+ toolCallId: part.id,
2771
+ toolName: "code_interpreter",
2772
+ input: JSON.stringify({
2773
+ code: part.code,
2774
+ containerId: part.container_id
2775
+ }),
2776
+ providerExecuted: true
2777
+ });
2778
+ content.push({
2779
+ type: "tool-result",
2780
+ toolCallId: part.id,
2781
+ toolName: "code_interpreter",
2782
+ result: {
2783
+ outputs: part.outputs
2784
+ },
2785
+ providerExecuted: true
2786
+ });
2787
+ break;
2788
+ }
2740
2789
  }
2741
2790
  }
2742
2791
  const providerMetadata = {
@@ -2980,6 +3029,26 @@ var OpenAIResponsesLanguageModel = class {
2980
3029
  },
2981
3030
  providerExecuted: true
2982
3031
  });
3032
+ } else if (value.item.type === "code_interpreter_call") {
3033
+ controller.enqueue({
3034
+ type: "tool-call",
3035
+ toolCallId: value.item.id,
3036
+ toolName: "code_interpreter",
3037
+ input: JSON.stringify({
3038
+ code: value.item.code,
3039
+ containerId: value.item.container_id
3040
+ }),
3041
+ providerExecuted: true
3042
+ });
3043
+ controller.enqueue({
3044
+ type: "tool-result",
3045
+ toolCallId: value.item.id,
3046
+ toolName: "code_interpreter",
3047
+ result: {
3048
+ outputs: value.item.outputs
3049
+ },
3050
+ providerExecuted: true
3051
+ });
2983
3052
  } else if (value.item.type === "message") {
2984
3053
  controller.enqueue({
2985
3054
  type: "text-end",
@@ -3225,6 +3294,7 @@ var responseOutputItemDoneSchema = z14.object({
3225
3294
  arguments: z14.string(),
3226
3295
  status: z14.literal("completed")
3227
3296
  }),
3297
+ codeInterpreterCallItem,
3228
3298
  webSearchCallItem,
3229
3299
  z14.object({
3230
3300
  type: z14.literal("computer_call"),