@ai-sdk/openai 2.0.50 → 2.0.51

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.
@@ -2561,11 +2561,7 @@ var openaiResponsesChunkSchema = lazyValidator11(
2561
2561
  z14.object({
2562
2562
  type: z14.literal("web_search_call"),
2563
2563
  id: z14.string(),
2564
- status: z14.string(),
2565
- action: z14.object({
2566
- type: z14.literal("search"),
2567
- query: z14.string().optional()
2568
- }).nullish()
2564
+ status: z14.string()
2569
2565
  }),
2570
2566
  z14.object({
2571
2567
  type: z14.literal("computer_call"),
@@ -2651,7 +2647,7 @@ var openaiResponsesChunkSchema = lazyValidator11(
2651
2647
  url: z14.string(),
2652
2648
  pattern: z14.string()
2653
2649
  })
2654
- ]).nullish()
2650
+ ])
2655
2651
  }),
2656
2652
  z14.object({
2657
2653
  type: z14.literal("file_search_call"),
@@ -2832,7 +2828,7 @@ var openaiResponsesResponseSchema = lazyValidator11(
2832
2828
  url: z14.string(),
2833
2829
  pattern: z14.string()
2834
2830
  })
2835
- ]).nullish()
2831
+ ])
2836
2832
  }),
2837
2833
  z14.object({
2838
2834
  type: z14.literal("file_search_call"),
@@ -3136,7 +3132,7 @@ var fileSearch = createProviderDefinedToolFactoryWithOutputSchema3({
3136
3132
 
3137
3133
  // src/tool/web-search.ts
3138
3134
  import {
3139
- createProviderDefinedToolFactory,
3135
+ createProviderDefinedToolFactoryWithOutputSchema as createProviderDefinedToolFactoryWithOutputSchema4,
3140
3136
  lazySchema as lazySchema4,
3141
3137
  zodSchema as zodSchema16
3142
3138
  } from "@ai-sdk/provider-utils";
@@ -3144,9 +3140,7 @@ import { z as z18 } from "zod/v4";
3144
3140
  var webSearchArgsSchema = lazySchema4(
3145
3141
  () => zodSchema16(
3146
3142
  z18.object({
3147
- filters: z18.object({
3148
- allowedDomains: z18.array(z18.string()).optional()
3149
- }).optional(),
3143
+ filters: z18.object({ allowedDomains: z18.array(z18.string()).optional() }).optional(),
3150
3144
  searchContextSize: z18.enum(["low", "medium", "high"]).optional(),
3151
3145
  userLocation: z18.object({
3152
3146
  type: z18.literal("approximate"),
@@ -3158,16 +3152,17 @@ var webSearchArgsSchema = lazySchema4(
3158
3152
  })
3159
3153
  )
3160
3154
  );
3161
- var webSearchInputSchema = lazySchema4(
3155
+ var webSearchInputSchema = lazySchema4(() => zodSchema16(z18.object({})));
3156
+ var webSearchOutputSchema = lazySchema4(
3162
3157
  () => zodSchema16(
3163
3158
  z18.object({
3164
3159
  action: z18.discriminatedUnion("type", [
3165
3160
  z18.object({
3166
3161
  type: z18.literal("search"),
3167
- query: z18.string().nullish()
3162
+ query: z18.string().optional()
3168
3163
  }),
3169
3164
  z18.object({
3170
- type: z18.literal("open_page"),
3165
+ type: z18.literal("openPage"),
3171
3166
  url: z18.string()
3172
3167
  }),
3173
3168
  z18.object({
@@ -3175,19 +3170,20 @@ var webSearchInputSchema = lazySchema4(
3175
3170
  url: z18.string(),
3176
3171
  pattern: z18.string()
3177
3172
  })
3178
- ]).nullish()
3173
+ ])
3179
3174
  })
3180
3175
  )
3181
3176
  );
3182
- var webSearchToolFactory = createProviderDefinedToolFactory({
3177
+ var webSearchToolFactory = createProviderDefinedToolFactoryWithOutputSchema4({
3183
3178
  id: "openai.web_search",
3184
3179
  name: "web_search",
3185
- inputSchema: webSearchInputSchema
3180
+ inputSchema: webSearchInputSchema,
3181
+ outputSchema: webSearchOutputSchema
3186
3182
  });
3187
3183
 
3188
3184
  // src/tool/web-search-preview.ts
3189
3185
  import {
3190
- createProviderDefinedToolFactory as createProviderDefinedToolFactory2,
3186
+ createProviderDefinedToolFactoryWithOutputSchema as createProviderDefinedToolFactoryWithOutputSchema5,
3191
3187
  lazySchema as lazySchema5,
3192
3188
  zodSchema as zodSchema17
3193
3189
  } from "@ai-sdk/provider-utils";
@@ -3195,51 +3191,30 @@ import { z as z19 } from "zod/v4";
3195
3191
  var webSearchPreviewArgsSchema = lazySchema5(
3196
3192
  () => zodSchema17(
3197
3193
  z19.object({
3198
- /**
3199
- * Search context size to use for the web search.
3200
- * - high: Most comprehensive context, highest cost, slower response
3201
- * - medium: Balanced context, cost, and latency (default)
3202
- * - low: Least context, lowest cost, fastest response
3203
- */
3204
3194
  searchContextSize: z19.enum(["low", "medium", "high"]).optional(),
3205
- /**
3206
- * User location information to provide geographically relevant search results.
3207
- */
3208
3195
  userLocation: z19.object({
3209
- /**
3210
- * Type of location (always 'approximate')
3211
- */
3212
3196
  type: z19.literal("approximate"),
3213
- /**
3214
- * Two-letter ISO country code (e.g., 'US', 'GB')
3215
- */
3216
3197
  country: z19.string().optional(),
3217
- /**
3218
- * City name (free text, e.g., 'Minneapolis')
3219
- */
3220
3198
  city: z19.string().optional(),
3221
- /**
3222
- * Region name (free text, e.g., 'Minnesota')
3223
- */
3224
3199
  region: z19.string().optional(),
3225
- /**
3226
- * IANA timezone (e.g., 'America/Chicago')
3227
- */
3228
3200
  timezone: z19.string().optional()
3229
3201
  }).optional()
3230
3202
  })
3231
3203
  )
3232
3204
  );
3233
3205
  var webSearchPreviewInputSchema = lazySchema5(
3206
+ () => zodSchema17(z19.object({}))
3207
+ );
3208
+ var webSearchPreviewOutputSchema = lazySchema5(
3234
3209
  () => zodSchema17(
3235
3210
  z19.object({
3236
3211
  action: z19.discriminatedUnion("type", [
3237
3212
  z19.object({
3238
3213
  type: z19.literal("search"),
3239
- query: z19.string().nullish()
3214
+ query: z19.string().optional()
3240
3215
  }),
3241
3216
  z19.object({
3242
- type: z19.literal("open_page"),
3217
+ type: z19.literal("openPage"),
3243
3218
  url: z19.string()
3244
3219
  }),
3245
3220
  z19.object({
@@ -3247,19 +3222,20 @@ var webSearchPreviewInputSchema = lazySchema5(
3247
3222
  url: z19.string(),
3248
3223
  pattern: z19.string()
3249
3224
  })
3250
- ]).nullish()
3225
+ ])
3251
3226
  })
3252
3227
  )
3253
3228
  );
3254
- var webSearchPreview = createProviderDefinedToolFactory2({
3229
+ var webSearchPreview = createProviderDefinedToolFactoryWithOutputSchema5({
3255
3230
  id: "openai.web_search_preview",
3256
3231
  name: "web_search_preview",
3257
- inputSchema: webSearchPreviewInputSchema
3232
+ inputSchema: webSearchPreviewInputSchema,
3233
+ outputSchema: webSearchPreviewOutputSchema
3258
3234
  });
3259
3235
 
3260
3236
  // src/tool/image-generation.ts
3261
3237
  import {
3262
- createProviderDefinedToolFactoryWithOutputSchema as createProviderDefinedToolFactoryWithOutputSchema4,
3238
+ createProviderDefinedToolFactoryWithOutputSchema as createProviderDefinedToolFactoryWithOutputSchema6,
3263
3239
  lazySchema as lazySchema6,
3264
3240
  zodSchema as zodSchema18
3265
3241
  } from "@ai-sdk/provider-utils";
@@ -3287,7 +3263,7 @@ var imageGenerationInputSchema = lazySchema6(() => zodSchema18(z20.object({})));
3287
3263
  var imageGenerationOutputSchema = lazySchema6(
3288
3264
  () => zodSchema18(z20.object({ result: z20.string() }))
3289
3265
  );
3290
- var imageGenerationToolFactory = createProviderDefinedToolFactoryWithOutputSchema4({
3266
+ var imageGenerationToolFactory = createProviderDefinedToolFactoryWithOutputSchema6({
3291
3267
  id: "openai.image_generation",
3292
3268
  name: "image_generation",
3293
3269
  inputSchema: imageGenerationInputSchema,
@@ -3803,14 +3779,14 @@ var OpenAIResponsesLanguageModel = class {
3803
3779
  type: "tool-call",
3804
3780
  toolCallId: part.id,
3805
3781
  toolName: webSearchToolName != null ? webSearchToolName : "web_search",
3806
- input: JSON.stringify({ action: part.action }),
3782
+ input: JSON.stringify({}),
3807
3783
  providerExecuted: true
3808
3784
  });
3809
3785
  content.push({
3810
3786
  type: "tool-result",
3811
3787
  toolCallId: part.id,
3812
3788
  toolName: webSearchToolName != null ? webSearchToolName : "web_search",
3813
- result: { status: part.status },
3789
+ result: mapWebSearchOutput(part.action),
3814
3790
  providerExecuted: true
3815
3791
  });
3816
3792
  break;
@@ -3994,6 +3970,17 @@ var OpenAIResponsesLanguageModel = class {
3994
3970
  toolName: webSearchToolName != null ? webSearchToolName : "web_search",
3995
3971
  providerExecuted: true
3996
3972
  });
3973
+ controller.enqueue({
3974
+ type: "tool-input-end",
3975
+ id: value.item.id
3976
+ });
3977
+ controller.enqueue({
3978
+ type: "tool-call",
3979
+ toolCallId: value.item.id,
3980
+ toolName: "web_search",
3981
+ input: JSON.stringify({}),
3982
+ providerExecuted: true
3983
+ });
3997
3984
  } else if (value.item.type === "computer_call") {
3998
3985
  ongoingToolCalls[value.output_index] = {
3999
3986
  toolName: "computer_use",
@@ -4087,22 +4074,11 @@ var OpenAIResponsesLanguageModel = class {
4087
4074
  });
4088
4075
  } else if (value.item.type === "web_search_call") {
4089
4076
  ongoingToolCalls[value.output_index] = void 0;
4090
- controller.enqueue({
4091
- type: "tool-input-end",
4092
- id: value.item.id
4093
- });
4094
- controller.enqueue({
4095
- type: "tool-call",
4096
- toolCallId: value.item.id,
4097
- toolName: "web_search",
4098
- input: JSON.stringify({ action: value.item.action }),
4099
- providerExecuted: true
4100
- });
4101
4077
  controller.enqueue({
4102
4078
  type: "tool-result",
4103
4079
  toolCallId: value.item.id,
4104
4080
  toolName: "web_search",
4105
- result: { status: value.item.status },
4081
+ result: mapWebSearchOutput(value.item.action),
4106
4082
  providerExecuted: true
4107
4083
  });
4108
4084
  } else if (value.item.type === "computer_call") {
@@ -4433,6 +4409,19 @@ function getResponsesModelConfig(modelId) {
4433
4409
  isReasoningModel: false
4434
4410
  };
4435
4411
  }
4412
+ function mapWebSearchOutput(action) {
4413
+ var _a;
4414
+ switch (action.type) {
4415
+ case "search":
4416
+ return { action: { type: "search", query: (_a = action.query) != null ? _a : void 0 } };
4417
+ case "open_page":
4418
+ return { action: { type: "openPage", url: action.url } };
4419
+ case "find":
4420
+ return {
4421
+ action: { type: "find", url: action.url, pattern: action.pattern }
4422
+ };
4423
+ }
4424
+ }
4436
4425
  export {
4437
4426
  OpenAIChatLanguageModel,
4438
4427
  OpenAICompletionLanguageModel,