@ai-sdk/openai 2.0.27 → 2.0.28

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";
@@ -2370,7 +2370,7 @@ var codeInterpreterArgsSchema = import_v415.z.object({
2370
2370
  })
2371
2371
  ]).optional()
2372
2372
  });
2373
- var codeInterpreter = (0, import_provider_utils13.createProviderDefinedToolFactory)({
2373
+ var codeInterpreterToolFactory = (0, import_provider_utils13.createProviderDefinedToolFactory)({
2374
2374
  id: "openai.code_interpreter",
2375
2375
  name: "code_interpreter",
2376
2376
  inputSchema: import_v415.z.object({})
@@ -2392,7 +2392,7 @@ var webSearchArgsSchema = import_v416.z.object({
2392
2392
  timezone: import_v416.z.string().optional()
2393
2393
  }).optional()
2394
2394
  });
2395
- var factory = (0, import_provider_utils14.createProviderDefinedToolFactory)({
2395
+ var webSearchToolFactory = (0, import_provider_utils14.createProviderDefinedToolFactory)({
2396
2396
  id: "openai.web_search",
2397
2397
  name: "web_search",
2398
2398
  inputSchema: import_v416.z.object({
@@ -2575,7 +2575,7 @@ var OpenAIResponsesLanguageModel = class {
2575
2575
  toolChoice,
2576
2576
  responseFormat
2577
2577
  }) {
2578
- var _a, _b;
2578
+ var _a, _b, _c;
2579
2579
  const warnings = [];
2580
2580
  const modelConfig = getResponsesModelConfig(this.modelId);
2581
2581
  if (topK != null) {
@@ -2611,8 +2611,13 @@ var OpenAIResponsesLanguageModel = class {
2611
2611
  schema: openaiResponsesProviderOptionsSchema
2612
2612
  });
2613
2613
  const strictJsonSchema = (_a = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _a : false;
2614
+ let include = openaiOptions == null ? void 0 : openaiOptions.include;
2614
2615
  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;
2616
+ include = topLogprobs ? Array.isArray(include) ? [...include, "message.output_text.logprobs"] : ["message.output_text.logprobs"] : include;
2617
+ const webSearchToolName = (_b = tools == null ? void 0 : tools.find(
2618
+ (tool) => tool.type === "provider-defined" && (tool.id === "openai.web_search" || tool.id === "openai.web_search_preview")
2619
+ )) == null ? void 0 : _b.name;
2620
+ include = webSearchToolName ? Array.isArray(include) ? [...include, "web_search_call.action.sources"] : ["web_search_call.action.sources"] : include;
2616
2621
  const baseArgs = {
2617
2622
  model: this.modelId,
2618
2623
  input: messages,
@@ -2625,7 +2630,7 @@ var OpenAIResponsesLanguageModel = class {
2625
2630
  format: responseFormat.schema != null ? {
2626
2631
  type: "json_schema",
2627
2632
  strict: strictJsonSchema,
2628
- name: (_b = responseFormat.name) != null ? _b : "response",
2633
+ name: (_c = responseFormat.name) != null ? _c : "response",
2629
2634
  description: responseFormat.description,
2630
2635
  schema: responseFormat.schema
2631
2636
  } : { type: "json_object" }
@@ -2643,7 +2648,7 @@ var OpenAIResponsesLanguageModel = class {
2643
2648
  user: openaiOptions == null ? void 0 : openaiOptions.user,
2644
2649
  instructions: openaiOptions == null ? void 0 : openaiOptions.instructions,
2645
2650
  service_tier: openaiOptions == null ? void 0 : openaiOptions.serviceTier,
2646
- include: openaiOptionsInclude,
2651
+ include,
2647
2652
  prompt_cache_key: openaiOptions == null ? void 0 : openaiOptions.promptCacheKey,
2648
2653
  safety_identifier: openaiOptions == null ? void 0 : openaiOptions.safetyIdentifier,
2649
2654
  top_logprobs: topLogprobs,
@@ -2721,6 +2726,7 @@ var OpenAIResponsesLanguageModel = class {
2721
2726
  strictJsonSchema
2722
2727
  });
2723
2728
  return {
2729
+ webSearchToolName,
2724
2730
  args: {
2725
2731
  ...baseArgs,
2726
2732
  tools: openaiTools,
@@ -2731,7 +2737,11 @@ var OpenAIResponsesLanguageModel = class {
2731
2737
  }
2732
2738
  async doGenerate(options) {
2733
2739
  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);
2740
+ const {
2741
+ args: body,
2742
+ warnings,
2743
+ webSearchToolName
2744
+ } = await this.getArgs(options);
2735
2745
  const url = this.config.url({
2736
2746
  path: "/responses",
2737
2747
  modelId: this.modelId
@@ -2782,12 +2792,18 @@ var OpenAIResponsesLanguageModel = class {
2782
2792
  start_index: import_v417.z.number().nullish(),
2783
2793
  end_index: import_v417.z.number().nullish(),
2784
2794
  quote: import_v417.z.string().nullish()
2795
+ }),
2796
+ import_v417.z.object({
2797
+ type: import_v417.z.literal("container_file_citation")
2785
2798
  })
2786
2799
  ])
2787
2800
  )
2788
2801
  })
2789
2802
  )
2790
2803
  }),
2804
+ import_v417.z.object({
2805
+ type: import_v417.z.literal("code_interpreter_call")
2806
+ }),
2791
2807
  import_v417.z.object({
2792
2808
  type: import_v417.z.literal("function_call"),
2793
2809
  call_id: import_v417.z.string(),
@@ -2928,14 +2944,14 @@ var OpenAIResponsesLanguageModel = class {
2928
2944
  content.push({
2929
2945
  type: "tool-call",
2930
2946
  toolCallId: part.id,
2931
- toolName: "web_search_preview",
2947
+ toolName: webSearchToolName != null ? webSearchToolName : "web_search",
2932
2948
  input: JSON.stringify({ action: part.action }),
2933
2949
  providerExecuted: true
2934
2950
  });
2935
2951
  content.push({
2936
2952
  type: "tool-result",
2937
2953
  toolCallId: part.id,
2938
- toolName: "web_search_preview",
2954
+ toolName: webSearchToolName != null ? webSearchToolName : "web_search",
2939
2955
  result: { status: part.status },
2940
2956
  providerExecuted: true
2941
2957
  });
@@ -3020,7 +3036,11 @@ var OpenAIResponsesLanguageModel = class {
3020
3036
  };
3021
3037
  }
3022
3038
  async doStream(options) {
3023
- const { args: body, warnings } = await this.getArgs(options);
3039
+ const {
3040
+ args: body,
3041
+ warnings,
3042
+ webSearchToolName
3043
+ } = await this.getArgs(options);
3024
3044
  const { responseHeaders, value: response } = await (0, import_provider_utils15.postJsonToApi)({
3025
3045
  url: this.config.url({
3026
3046
  path: "/responses",
@@ -3081,13 +3101,13 @@ var OpenAIResponsesLanguageModel = class {
3081
3101
  });
3082
3102
  } else if (value.item.type === "web_search_call") {
3083
3103
  ongoingToolCalls[value.output_index] = {
3084
- toolName: "web_search_preview",
3104
+ toolName: webSearchToolName != null ? webSearchToolName : "web_search",
3085
3105
  toolCallId: value.item.id
3086
3106
  };
3087
3107
  controller.enqueue({
3088
3108
  type: "tool-input-start",
3089
3109
  id: value.item.id,
3090
- toolName: "web_search_preview"
3110
+ toolName: webSearchToolName != null ? webSearchToolName : "web_search"
3091
3111
  });
3092
3112
  } else if (value.item.type === "computer_call") {
3093
3113
  ongoingToolCalls[value.output_index] = {