@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.
@@ -2522,11 +2522,7 @@ var openaiResponsesChunkSchema = (0, import_provider_utils21.lazyValidator)(
2522
2522
  import_v414.z.object({
2523
2523
  type: import_v414.z.literal("web_search_call"),
2524
2524
  id: import_v414.z.string(),
2525
- status: import_v414.z.string(),
2526
- action: import_v414.z.object({
2527
- type: import_v414.z.literal("search"),
2528
- query: import_v414.z.string().optional()
2529
- }).nullish()
2525
+ status: import_v414.z.string()
2530
2526
  }),
2531
2527
  import_v414.z.object({
2532
2528
  type: import_v414.z.literal("computer_call"),
@@ -2612,7 +2608,7 @@ var openaiResponsesChunkSchema = (0, import_provider_utils21.lazyValidator)(
2612
2608
  url: import_v414.z.string(),
2613
2609
  pattern: import_v414.z.string()
2614
2610
  })
2615
- ]).nullish()
2611
+ ])
2616
2612
  }),
2617
2613
  import_v414.z.object({
2618
2614
  type: import_v414.z.literal("file_search_call"),
@@ -2793,7 +2789,7 @@ var openaiResponsesResponseSchema = (0, import_provider_utils21.lazyValidator)(
2793
2789
  url: import_v414.z.string(),
2794
2790
  pattern: import_v414.z.string()
2795
2791
  })
2796
- ]).nullish()
2792
+ ])
2797
2793
  }),
2798
2794
  import_v414.z.object({
2799
2795
  type: import_v414.z.literal("file_search_call"),
@@ -3088,9 +3084,7 @@ var import_v418 = require("zod/v4");
3088
3084
  var webSearchArgsSchema = (0, import_provider_utils25.lazySchema)(
3089
3085
  () => (0, import_provider_utils25.zodSchema)(
3090
3086
  import_v418.z.object({
3091
- filters: import_v418.z.object({
3092
- allowedDomains: import_v418.z.array(import_v418.z.string()).optional()
3093
- }).optional(),
3087
+ filters: import_v418.z.object({ allowedDomains: import_v418.z.array(import_v418.z.string()).optional() }).optional(),
3094
3088
  searchContextSize: import_v418.z.enum(["low", "medium", "high"]).optional(),
3095
3089
  userLocation: import_v418.z.object({
3096
3090
  type: import_v418.z.literal("approximate"),
@@ -3102,16 +3096,17 @@ var webSearchArgsSchema = (0, import_provider_utils25.lazySchema)(
3102
3096
  })
3103
3097
  )
3104
3098
  );
3105
- var webSearchInputSchema = (0, import_provider_utils25.lazySchema)(
3099
+ var webSearchInputSchema = (0, import_provider_utils25.lazySchema)(() => (0, import_provider_utils25.zodSchema)(import_v418.z.object({})));
3100
+ var webSearchOutputSchema = (0, import_provider_utils25.lazySchema)(
3106
3101
  () => (0, import_provider_utils25.zodSchema)(
3107
3102
  import_v418.z.object({
3108
3103
  action: import_v418.z.discriminatedUnion("type", [
3109
3104
  import_v418.z.object({
3110
3105
  type: import_v418.z.literal("search"),
3111
- query: import_v418.z.string().nullish()
3106
+ query: import_v418.z.string().optional()
3112
3107
  }),
3113
3108
  import_v418.z.object({
3114
- type: import_v418.z.literal("open_page"),
3109
+ type: import_v418.z.literal("openPage"),
3115
3110
  url: import_v418.z.string()
3116
3111
  }),
3117
3112
  import_v418.z.object({
@@ -3119,14 +3114,15 @@ var webSearchInputSchema = (0, import_provider_utils25.lazySchema)(
3119
3114
  url: import_v418.z.string(),
3120
3115
  pattern: import_v418.z.string()
3121
3116
  })
3122
- ]).nullish()
3117
+ ])
3123
3118
  })
3124
3119
  )
3125
3120
  );
3126
- var webSearchToolFactory = (0, import_provider_utils25.createProviderDefinedToolFactory)({
3121
+ var webSearchToolFactory = (0, import_provider_utils25.createProviderDefinedToolFactoryWithOutputSchema)({
3127
3122
  id: "openai.web_search",
3128
3123
  name: "web_search",
3129
- inputSchema: webSearchInputSchema
3124
+ inputSchema: webSearchInputSchema,
3125
+ outputSchema: webSearchOutputSchema
3130
3126
  });
3131
3127
 
3132
3128
  // src/tool/web-search-preview.ts
@@ -3135,51 +3131,30 @@ var import_v419 = require("zod/v4");
3135
3131
  var webSearchPreviewArgsSchema = (0, import_provider_utils26.lazySchema)(
3136
3132
  () => (0, import_provider_utils26.zodSchema)(
3137
3133
  import_v419.z.object({
3138
- /**
3139
- * Search context size to use for the web search.
3140
- * - high: Most comprehensive context, highest cost, slower response
3141
- * - medium: Balanced context, cost, and latency (default)
3142
- * - low: Least context, lowest cost, fastest response
3143
- */
3144
3134
  searchContextSize: import_v419.z.enum(["low", "medium", "high"]).optional(),
3145
- /**
3146
- * User location information to provide geographically relevant search results.
3147
- */
3148
3135
  userLocation: import_v419.z.object({
3149
- /**
3150
- * Type of location (always 'approximate')
3151
- */
3152
3136
  type: import_v419.z.literal("approximate"),
3153
- /**
3154
- * Two-letter ISO country code (e.g., 'US', 'GB')
3155
- */
3156
3137
  country: import_v419.z.string().optional(),
3157
- /**
3158
- * City name (free text, e.g., 'Minneapolis')
3159
- */
3160
3138
  city: import_v419.z.string().optional(),
3161
- /**
3162
- * Region name (free text, e.g., 'Minnesota')
3163
- */
3164
3139
  region: import_v419.z.string().optional(),
3165
- /**
3166
- * IANA timezone (e.g., 'America/Chicago')
3167
- */
3168
3140
  timezone: import_v419.z.string().optional()
3169
3141
  }).optional()
3170
3142
  })
3171
3143
  )
3172
3144
  );
3173
3145
  var webSearchPreviewInputSchema = (0, import_provider_utils26.lazySchema)(
3146
+ () => (0, import_provider_utils26.zodSchema)(import_v419.z.object({}))
3147
+ );
3148
+ var webSearchPreviewOutputSchema = (0, import_provider_utils26.lazySchema)(
3174
3149
  () => (0, import_provider_utils26.zodSchema)(
3175
3150
  import_v419.z.object({
3176
3151
  action: import_v419.z.discriminatedUnion("type", [
3177
3152
  import_v419.z.object({
3178
3153
  type: import_v419.z.literal("search"),
3179
- query: import_v419.z.string().nullish()
3154
+ query: import_v419.z.string().optional()
3180
3155
  }),
3181
3156
  import_v419.z.object({
3182
- type: import_v419.z.literal("open_page"),
3157
+ type: import_v419.z.literal("openPage"),
3183
3158
  url: import_v419.z.string()
3184
3159
  }),
3185
3160
  import_v419.z.object({
@@ -3187,14 +3162,15 @@ var webSearchPreviewInputSchema = (0, import_provider_utils26.lazySchema)(
3187
3162
  url: import_v419.z.string(),
3188
3163
  pattern: import_v419.z.string()
3189
3164
  })
3190
- ]).nullish()
3165
+ ])
3191
3166
  })
3192
3167
  )
3193
3168
  );
3194
- var webSearchPreview = (0, import_provider_utils26.createProviderDefinedToolFactory)({
3169
+ var webSearchPreview = (0, import_provider_utils26.createProviderDefinedToolFactoryWithOutputSchema)({
3195
3170
  id: "openai.web_search_preview",
3196
3171
  name: "web_search_preview",
3197
- inputSchema: webSearchPreviewInputSchema
3172
+ inputSchema: webSearchPreviewInputSchema,
3173
+ outputSchema: webSearchPreviewOutputSchema
3198
3174
  });
3199
3175
 
3200
3176
  // src/tool/image-generation.ts
@@ -3739,14 +3715,14 @@ var OpenAIResponsesLanguageModel = class {
3739
3715
  type: "tool-call",
3740
3716
  toolCallId: part.id,
3741
3717
  toolName: webSearchToolName != null ? webSearchToolName : "web_search",
3742
- input: JSON.stringify({ action: part.action }),
3718
+ input: JSON.stringify({}),
3743
3719
  providerExecuted: true
3744
3720
  });
3745
3721
  content.push({
3746
3722
  type: "tool-result",
3747
3723
  toolCallId: part.id,
3748
3724
  toolName: webSearchToolName != null ? webSearchToolName : "web_search",
3749
- result: { status: part.status },
3725
+ result: mapWebSearchOutput(part.action),
3750
3726
  providerExecuted: true
3751
3727
  });
3752
3728
  break;
@@ -3930,6 +3906,17 @@ var OpenAIResponsesLanguageModel = class {
3930
3906
  toolName: webSearchToolName != null ? webSearchToolName : "web_search",
3931
3907
  providerExecuted: true
3932
3908
  });
3909
+ controller.enqueue({
3910
+ type: "tool-input-end",
3911
+ id: value.item.id
3912
+ });
3913
+ controller.enqueue({
3914
+ type: "tool-call",
3915
+ toolCallId: value.item.id,
3916
+ toolName: "web_search",
3917
+ input: JSON.stringify({}),
3918
+ providerExecuted: true
3919
+ });
3933
3920
  } else if (value.item.type === "computer_call") {
3934
3921
  ongoingToolCalls[value.output_index] = {
3935
3922
  toolName: "computer_use",
@@ -4023,22 +4010,11 @@ var OpenAIResponsesLanguageModel = class {
4023
4010
  });
4024
4011
  } else if (value.item.type === "web_search_call") {
4025
4012
  ongoingToolCalls[value.output_index] = void 0;
4026
- controller.enqueue({
4027
- type: "tool-input-end",
4028
- id: value.item.id
4029
- });
4030
- controller.enqueue({
4031
- type: "tool-call",
4032
- toolCallId: value.item.id,
4033
- toolName: "web_search",
4034
- input: JSON.stringify({ action: value.item.action }),
4035
- providerExecuted: true
4036
- });
4037
4013
  controller.enqueue({
4038
4014
  type: "tool-result",
4039
4015
  toolCallId: value.item.id,
4040
4016
  toolName: "web_search",
4041
- result: { status: value.item.status },
4017
+ result: mapWebSearchOutput(value.item.action),
4042
4018
  providerExecuted: true
4043
4019
  });
4044
4020
  } else if (value.item.type === "computer_call") {
@@ -4369,6 +4345,19 @@ function getResponsesModelConfig(modelId) {
4369
4345
  isReasoningModel: false
4370
4346
  };
4371
4347
  }
4348
+ function mapWebSearchOutput(action) {
4349
+ var _a;
4350
+ switch (action.type) {
4351
+ case "search":
4352
+ return { action: { type: "search", query: (_a = action.query) != null ? _a : void 0 } };
4353
+ case "open_page":
4354
+ return { action: { type: "openPage", url: action.url } };
4355
+ case "find":
4356
+ return {
4357
+ action: { type: "find", url: action.url, pattern: action.pattern }
4358
+ };
4359
+ }
4360
+ }
4372
4361
  // Annotate the CommonJS export names for ESM import in node:
4373
4362
  0 && (module.exports = {
4374
4363
  OpenAIChatLanguageModel,