@ai-sdk/openai 2.0.27 → 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.
@@ -231,9 +231,9 @@ declare const openaiResponsesProviderOptionsSchema: z.ZodObject<{
231
231
  priority: "priority";
232
232
  }>>>;
233
233
  include: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodEnum<{
234
- "reasoning.encrypted_content": "reasoning.encrypted_content";
235
234
  "file_search_call.results": "file_search_call.results";
236
235
  "message.output_text.logprobs": "message.output_text.logprobs";
236
+ "reasoning.encrypted_content": "reasoning.encrypted_content";
237
237
  }>>>>;
238
238
  textVerbosity: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
239
239
  low: "low";
@@ -231,9 +231,9 @@ declare const openaiResponsesProviderOptionsSchema: z.ZodObject<{
231
231
  priority: "priority";
232
232
  }>>>;
233
233
  include: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodEnum<{
234
- "reasoning.encrypted_content": "reasoning.encrypted_content";
235
234
  "file_search_call.results": "file_search_call.results";
236
235
  "message.output_text.logprobs": "message.output_text.logprobs";
236
+ "reasoning.encrypted_content": "reasoning.encrypted_content";
237
237
  }>>>>;
238
238
  textVerbosity: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
239
239
  low: "low";
@@ -2362,6 +2362,18 @@ var import_provider7 = require("@ai-sdk/provider");
2362
2362
  // src/tool/code-interpreter.ts
2363
2363
  var import_provider_utils13 = require("@ai-sdk/provider-utils");
2364
2364
  var import_v415 = require("zod/v4");
2365
+ var codeInterpreterInputSchema = import_v415.z.object({
2366
+ code: import_v415.z.string().nullish(),
2367
+ containerId: import_v415.z.string()
2368
+ });
2369
+ var codeInterpreterOutputSchema = import_v415.z.object({
2370
+ outputs: import_v415.z.array(
2371
+ import_v415.z.discriminatedUnion("type", [
2372
+ import_v415.z.object({ type: import_v415.z.literal("logs"), logs: import_v415.z.string() }),
2373
+ import_v415.z.object({ type: import_v415.z.literal("image"), url: import_v415.z.string() })
2374
+ ])
2375
+ ).nullish()
2376
+ });
2365
2377
  var codeInterpreterArgsSchema = import_v415.z.object({
2366
2378
  container: import_v415.z.union([
2367
2379
  import_v415.z.string(),
@@ -2370,10 +2382,11 @@ var codeInterpreterArgsSchema = import_v415.z.object({
2370
2382
  })
2371
2383
  ]).optional()
2372
2384
  });
2373
- var codeInterpreter = (0, import_provider_utils13.createProviderDefinedToolFactory)({
2385
+ var codeInterpreterToolFactory = (0, import_provider_utils13.createProviderDefinedToolFactoryWithOutputSchema)({
2374
2386
  id: "openai.code_interpreter",
2375
2387
  name: "code_interpreter",
2376
- inputSchema: import_v415.z.object({})
2388
+ inputSchema: codeInterpreterInputSchema,
2389
+ outputSchema: codeInterpreterOutputSchema
2377
2390
  });
2378
2391
 
2379
2392
  // src/tool/web-search.ts
@@ -2392,7 +2405,7 @@ var webSearchArgsSchema = import_v416.z.object({
2392
2405
  timezone: import_v416.z.string().optional()
2393
2406
  }).optional()
2394
2407
  });
2395
- var factory = (0, import_provider_utils14.createProviderDefinedToolFactory)({
2408
+ var webSearchToolFactory = (0, import_provider_utils14.createProviderDefinedToolFactory)({
2396
2409
  id: "openai.web_search",
2397
2410
  name: "web_search",
2398
2411
  inputSchema: import_v416.z.object({
@@ -2534,6 +2547,18 @@ var webSearchCallItem = import_v417.z.object({
2534
2547
  })
2535
2548
  ]).nullish()
2536
2549
  });
2550
+ var codeInterpreterCallItem = import_v417.z.object({
2551
+ type: import_v417.z.literal("code_interpreter_call"),
2552
+ id: import_v417.z.string(),
2553
+ code: import_v417.z.string().nullable(),
2554
+ container_id: import_v417.z.string(),
2555
+ outputs: import_v417.z.array(
2556
+ import_v417.z.discriminatedUnion("type", [
2557
+ import_v417.z.object({ type: import_v417.z.literal("logs"), logs: import_v417.z.string() }),
2558
+ import_v417.z.object({ type: import_v417.z.literal("image"), url: import_v417.z.string() })
2559
+ ])
2560
+ ).nullable()
2561
+ });
2537
2562
  var TOP_LOGPROBS_MAX = 20;
2538
2563
  var LOGPROBS_SCHEMA = import_v417.z.array(
2539
2564
  import_v417.z.object({
@@ -2575,7 +2600,7 @@ var OpenAIResponsesLanguageModel = class {
2575
2600
  toolChoice,
2576
2601
  responseFormat
2577
2602
  }) {
2578
- var _a, _b;
2603
+ var _a, _b, _c, _d;
2579
2604
  const warnings = [];
2580
2605
  const modelConfig = getResponsesModelConfig(this.modelId);
2581
2606
  if (topK != null) {
@@ -2611,8 +2636,17 @@ var OpenAIResponsesLanguageModel = class {
2611
2636
  schema: openaiResponsesProviderOptionsSchema
2612
2637
  });
2613
2638
  const strictJsonSchema = (_a = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _a : false;
2639
+ let include = openaiOptions == null ? void 0 : openaiOptions.include;
2614
2640
  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;
2615
- const openaiOptionsInclude = topLogprobs ? Array.isArray(openaiOptions == null ? void 0 : openaiOptions.include) ? [...openaiOptions == null ? void 0 : openaiOptions.include, "message.output_text.logprobs"] : ["message.output_text.logprobs"] : openaiOptions == null ? void 0 : openaiOptions.include;
2641
+ include = topLogprobs ? Array.isArray(include) ? [...include, "message.output_text.logprobs"] : ["message.output_text.logprobs"] : include;
2642
+ const webSearchToolName = (_b = tools == null ? void 0 : tools.find(
2643
+ (tool) => tool.type === "provider-defined" && (tool.id === "openai.web_search" || tool.id === "openai.web_search_preview")
2644
+ )) == null ? void 0 : _b.name;
2645
+ include = webSearchToolName ? Array.isArray(include) ? [...include, "web_search_call.action.sources"] : ["web_search_call.action.sources"] : include;
2646
+ const codeInterpreterToolName = (_c = tools == null ? void 0 : tools.find(
2647
+ (tool) => tool.type === "provider-defined" && tool.id === "openai.code_interpreter"
2648
+ )) == null ? void 0 : _c.name;
2649
+ include = codeInterpreterToolName ? Array.isArray(include) ? [...include, "code_interpreter_call.outputs"] : ["code_interpreter_call.outputs"] : include;
2616
2650
  const baseArgs = {
2617
2651
  model: this.modelId,
2618
2652
  input: messages,
@@ -2625,7 +2659,7 @@ var OpenAIResponsesLanguageModel = class {
2625
2659
  format: responseFormat.schema != null ? {
2626
2660
  type: "json_schema",
2627
2661
  strict: strictJsonSchema,
2628
- name: (_b = responseFormat.name) != null ? _b : "response",
2662
+ name: (_d = responseFormat.name) != null ? _d : "response",
2629
2663
  description: responseFormat.description,
2630
2664
  schema: responseFormat.schema
2631
2665
  } : { type: "json_object" }
@@ -2643,7 +2677,7 @@ var OpenAIResponsesLanguageModel = class {
2643
2677
  user: openaiOptions == null ? void 0 : openaiOptions.user,
2644
2678
  instructions: openaiOptions == null ? void 0 : openaiOptions.instructions,
2645
2679
  service_tier: openaiOptions == null ? void 0 : openaiOptions.serviceTier,
2646
- include: openaiOptionsInclude,
2680
+ include,
2647
2681
  prompt_cache_key: openaiOptions == null ? void 0 : openaiOptions.promptCacheKey,
2648
2682
  safety_identifier: openaiOptions == null ? void 0 : openaiOptions.safetyIdentifier,
2649
2683
  top_logprobs: topLogprobs,
@@ -2721,6 +2755,7 @@ var OpenAIResponsesLanguageModel = class {
2721
2755
  strictJsonSchema
2722
2756
  });
2723
2757
  return {
2758
+ webSearchToolName,
2724
2759
  args: {
2725
2760
  ...baseArgs,
2726
2761
  tools: openaiTools,
@@ -2731,7 +2766,11 @@ var OpenAIResponsesLanguageModel = class {
2731
2766
  }
2732
2767
  async doGenerate(options) {
2733
2768
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
2734
- const { args: body, warnings } = await this.getArgs(options);
2769
+ const {
2770
+ args: body,
2771
+ warnings,
2772
+ webSearchToolName
2773
+ } = await this.getArgs(options);
2735
2774
  const url = this.config.url({
2736
2775
  path: "/responses",
2737
2776
  modelId: this.modelId
@@ -2782,12 +2821,16 @@ var OpenAIResponsesLanguageModel = class {
2782
2821
  start_index: import_v417.z.number().nullish(),
2783
2822
  end_index: import_v417.z.number().nullish(),
2784
2823
  quote: import_v417.z.string().nullish()
2824
+ }),
2825
+ import_v417.z.object({
2826
+ type: import_v417.z.literal("container_file_citation")
2785
2827
  })
2786
2828
  ])
2787
2829
  )
2788
2830
  })
2789
2831
  )
2790
2832
  }),
2833
+ codeInterpreterCallItem,
2791
2834
  import_v417.z.object({
2792
2835
  type: import_v417.z.literal("function_call"),
2793
2836
  call_id: import_v417.z.string(),
@@ -2928,14 +2971,14 @@ var OpenAIResponsesLanguageModel = class {
2928
2971
  content.push({
2929
2972
  type: "tool-call",
2930
2973
  toolCallId: part.id,
2931
- toolName: "web_search_preview",
2974
+ toolName: webSearchToolName != null ? webSearchToolName : "web_search",
2932
2975
  input: JSON.stringify({ action: part.action }),
2933
2976
  providerExecuted: true
2934
2977
  });
2935
2978
  content.push({
2936
2979
  type: "tool-result",
2937
2980
  toolCallId: part.id,
2938
- toolName: "web_search_preview",
2981
+ toolName: webSearchToolName != null ? webSearchToolName : "web_search",
2939
2982
  result: { status: part.status },
2940
2983
  providerExecuted: true
2941
2984
  });
@@ -2983,6 +3026,28 @@ var OpenAIResponsesLanguageModel = class {
2983
3026
  });
2984
3027
  break;
2985
3028
  }
3029
+ case "code_interpreter_call": {
3030
+ content.push({
3031
+ type: "tool-call",
3032
+ toolCallId: part.id,
3033
+ toolName: "code_interpreter",
3034
+ input: JSON.stringify({
3035
+ code: part.code,
3036
+ containerId: part.container_id
3037
+ }),
3038
+ providerExecuted: true
3039
+ });
3040
+ content.push({
3041
+ type: "tool-result",
3042
+ toolCallId: part.id,
3043
+ toolName: "code_interpreter",
3044
+ result: {
3045
+ outputs: part.outputs
3046
+ },
3047
+ providerExecuted: true
3048
+ });
3049
+ break;
3050
+ }
2986
3051
  }
2987
3052
  }
2988
3053
  const providerMetadata = {
@@ -3020,7 +3085,11 @@ var OpenAIResponsesLanguageModel = class {
3020
3085
  };
3021
3086
  }
3022
3087
  async doStream(options) {
3023
- const { args: body, warnings } = await this.getArgs(options);
3088
+ const {
3089
+ args: body,
3090
+ warnings,
3091
+ webSearchToolName
3092
+ } = await this.getArgs(options);
3024
3093
  const { responseHeaders, value: response } = await (0, import_provider_utils15.postJsonToApi)({
3025
3094
  url: this.config.url({
3026
3095
  path: "/responses",
@@ -3081,13 +3150,13 @@ var OpenAIResponsesLanguageModel = class {
3081
3150
  });
3082
3151
  } else if (value.item.type === "web_search_call") {
3083
3152
  ongoingToolCalls[value.output_index] = {
3084
- toolName: "web_search_preview",
3153
+ toolName: webSearchToolName != null ? webSearchToolName : "web_search",
3085
3154
  toolCallId: value.item.id
3086
3155
  };
3087
3156
  controller.enqueue({
3088
3157
  type: "tool-input-start",
3089
3158
  id: value.item.id,
3090
- toolName: "web_search_preview"
3159
+ toolName: webSearchToolName != null ? webSearchToolName : "web_search"
3091
3160
  });
3092
3161
  } else if (value.item.type === "computer_call") {
3093
3162
  ongoingToolCalls[value.output_index] = {
@@ -3222,6 +3291,26 @@ var OpenAIResponsesLanguageModel = class {
3222
3291
  },
3223
3292
  providerExecuted: true
3224
3293
  });
3294
+ } else if (value.item.type === "code_interpreter_call") {
3295
+ controller.enqueue({
3296
+ type: "tool-call",
3297
+ toolCallId: value.item.id,
3298
+ toolName: "code_interpreter",
3299
+ input: JSON.stringify({
3300
+ code: value.item.code,
3301
+ containerId: value.item.container_id
3302
+ }),
3303
+ providerExecuted: true
3304
+ });
3305
+ controller.enqueue({
3306
+ type: "tool-result",
3307
+ toolCallId: value.item.id,
3308
+ toolName: "code_interpreter",
3309
+ result: {
3310
+ outputs: value.item.outputs
3311
+ },
3312
+ providerExecuted: true
3313
+ });
3225
3314
  } else if (value.item.type === "message") {
3226
3315
  controller.enqueue({
3227
3316
  type: "text-end",
@@ -3467,6 +3556,7 @@ var responseOutputItemDoneSchema = import_v417.z.object({
3467
3556
  arguments: import_v417.z.string(),
3468
3557
  status: import_v417.z.literal("completed")
3469
3558
  }),
3559
+ codeInterpreterCallItem,
3470
3560
  webSearchCallItem,
3471
3561
  import_v417.z.object({
3472
3562
  type: import_v417.z.literal("computer_call"),