@ai-sdk/openai 3.0.0-beta.26 → 3.0.0-beta.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.
@@ -2175,7 +2175,7 @@ async function convertToOpenAIResponsesInput({
2175
2175
  store,
2176
2176
  hasLocalShellTool = false
2177
2177
  }) {
2178
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
2178
+ var _a, _b, _c, _d, _e;
2179
2179
  const input = [];
2180
2180
  const warnings = [];
2181
2181
  for (const { role, content } of prompt) {
@@ -2256,10 +2256,15 @@ async function convertToOpenAIResponsesInput({
2256
2256
  for (const part of content) {
2257
2257
  switch (part.type) {
2258
2258
  case "text": {
2259
+ const id = (_b = (_a = part.providerOptions) == null ? void 0 : _a.openai) == null ? void 0 : _b.itemId;
2260
+ if (store && id != null) {
2261
+ input.push({ type: "item_reference", id });
2262
+ break;
2263
+ }
2259
2264
  input.push({
2260
2265
  role: "assistant",
2261
2266
  content: [{ type: "output_text", text: part.text }],
2262
- id: (_c = (_b = (_a = part.providerOptions) == null ? void 0 : _a.openai) == null ? void 0 : _b.itemId) != null ? _c : void 0
2267
+ id
2263
2268
  });
2264
2269
  break;
2265
2270
  }
@@ -2268,6 +2273,11 @@ async function convertToOpenAIResponsesInput({
2268
2273
  if (part.providerExecuted) {
2269
2274
  break;
2270
2275
  }
2276
+ const id = (_d = (_c = part.providerOptions) == null ? void 0 : _c.openai) == null ? void 0 : _d.itemId;
2277
+ if (store && id != null) {
2278
+ input.push({ type: "item_reference", id });
2279
+ break;
2280
+ }
2271
2281
  if (hasLocalShellTool && part.toolName === "local_shell") {
2272
2282
  const parsedInput = await (0, import_provider_utils20.validateTypes)({
2273
2283
  value: part.input,
@@ -2276,7 +2286,7 @@ async function convertToOpenAIResponsesInput({
2276
2286
  input.push({
2277
2287
  type: "local_shell_call",
2278
2288
  call_id: part.toolCallId,
2279
- id: (_f = (_e = (_d = part.providerOptions) == null ? void 0 : _d.openai) == null ? void 0 : _e.itemId) != null ? _f : void 0,
2289
+ id,
2280
2290
  action: {
2281
2291
  type: "exec",
2282
2292
  command: parsedInput.action.command,
@@ -2293,7 +2303,7 @@ async function convertToOpenAIResponsesInput({
2293
2303
  call_id: part.toolCallId,
2294
2304
  name: part.toolName,
2295
2305
  arguments: JSON.stringify(part.input),
2296
- id: (_i = (_h = (_g = part.providerOptions) == null ? void 0 : _g.openai) == null ? void 0 : _h.itemId) != null ? _i : void 0
2306
+ id
2297
2307
  });
2298
2308
  break;
2299
2309
  }
@@ -2386,7 +2396,7 @@ async function convertToOpenAIResponsesInput({
2386
2396
  contentValue = output.value;
2387
2397
  break;
2388
2398
  case "execution-denied":
2389
- contentValue = (_j = output.reason) != null ? _j : "Tool execution denied.";
2399
+ contentValue = (_e = output.reason) != null ? _e : "Tool execution denied.";
2390
2400
  break;
2391
2401
  case "json":
2392
2402
  case "error-json":
@@ -2519,11 +2529,7 @@ var openaiResponsesChunkSchema = (0, import_provider_utils21.lazySchema)(
2519
2529
  import_v414.z.object({
2520
2530
  type: import_v414.z.literal("web_search_call"),
2521
2531
  id: import_v414.z.string(),
2522
- status: import_v414.z.string(),
2523
- action: import_v414.z.object({
2524
- type: import_v414.z.literal("search"),
2525
- query: import_v414.z.string().optional()
2526
- }).nullish()
2532
+ status: import_v414.z.string()
2527
2533
  }),
2528
2534
  import_v414.z.object({
2529
2535
  type: import_v414.z.literal("computer_call"),
@@ -2609,7 +2615,7 @@ var openaiResponsesChunkSchema = (0, import_provider_utils21.lazySchema)(
2609
2615
  url: import_v414.z.string(),
2610
2616
  pattern: import_v414.z.string()
2611
2617
  })
2612
- ]).nullish()
2618
+ ])
2613
2619
  }),
2614
2620
  import_v414.z.object({
2615
2621
  type: import_v414.z.literal("file_search_call"),
@@ -2790,7 +2796,7 @@ var openaiResponsesResponseSchema = (0, import_provider_utils21.lazySchema)(
2790
2796
  url: import_v414.z.string(),
2791
2797
  pattern: import_v414.z.string()
2792
2798
  })
2793
- ]).nullish()
2799
+ ])
2794
2800
  }),
2795
2801
  import_v414.z.object({
2796
2802
  type: import_v414.z.literal("file_search_call"),
@@ -3085,9 +3091,7 @@ var import_v418 = require("zod/v4");
3085
3091
  var webSearchArgsSchema = (0, import_provider_utils25.lazySchema)(
3086
3092
  () => (0, import_provider_utils25.zodSchema)(
3087
3093
  import_v418.z.object({
3088
- filters: import_v418.z.object({
3089
- allowedDomains: import_v418.z.array(import_v418.z.string()).optional()
3090
- }).optional(),
3094
+ filters: import_v418.z.object({ allowedDomains: import_v418.z.array(import_v418.z.string()).optional() }).optional(),
3091
3095
  searchContextSize: import_v418.z.enum(["low", "medium", "high"]).optional(),
3092
3096
  userLocation: import_v418.z.object({
3093
3097
  type: import_v418.z.literal("approximate"),
@@ -3099,16 +3103,17 @@ var webSearchArgsSchema = (0, import_provider_utils25.lazySchema)(
3099
3103
  })
3100
3104
  )
3101
3105
  );
3102
- var webSearchInputSchema = (0, import_provider_utils25.lazySchema)(
3106
+ var webSearchInputSchema = (0, import_provider_utils25.lazySchema)(() => (0, import_provider_utils25.zodSchema)(import_v418.z.object({})));
3107
+ var webSearchOutputSchema = (0, import_provider_utils25.lazySchema)(
3103
3108
  () => (0, import_provider_utils25.zodSchema)(
3104
3109
  import_v418.z.object({
3105
3110
  action: import_v418.z.discriminatedUnion("type", [
3106
3111
  import_v418.z.object({
3107
3112
  type: import_v418.z.literal("search"),
3108
- query: import_v418.z.string().nullish()
3113
+ query: import_v418.z.string().optional()
3109
3114
  }),
3110
3115
  import_v418.z.object({
3111
- type: import_v418.z.literal("open_page"),
3116
+ type: import_v418.z.literal("openPage"),
3112
3117
  url: import_v418.z.string()
3113
3118
  }),
3114
3119
  import_v418.z.object({
@@ -3116,14 +3121,15 @@ var webSearchInputSchema = (0, import_provider_utils25.lazySchema)(
3116
3121
  url: import_v418.z.string(),
3117
3122
  pattern: import_v418.z.string()
3118
3123
  })
3119
- ]).nullish()
3124
+ ])
3120
3125
  })
3121
3126
  )
3122
3127
  );
3123
- var webSearchToolFactory = (0, import_provider_utils25.createProviderDefinedToolFactory)({
3128
+ var webSearchToolFactory = (0, import_provider_utils25.createProviderDefinedToolFactoryWithOutputSchema)({
3124
3129
  id: "openai.web_search",
3125
3130
  name: "web_search",
3126
- inputSchema: webSearchInputSchema
3131
+ inputSchema: webSearchInputSchema,
3132
+ outputSchema: webSearchOutputSchema
3127
3133
  });
3128
3134
 
3129
3135
  // src/tool/web-search-preview.ts
@@ -3132,51 +3138,30 @@ var import_v419 = require("zod/v4");
3132
3138
  var webSearchPreviewArgsSchema = (0, import_provider_utils26.lazySchema)(
3133
3139
  () => (0, import_provider_utils26.zodSchema)(
3134
3140
  import_v419.z.object({
3135
- /**
3136
- * Search context size to use for the web search.
3137
- * - high: Most comprehensive context, highest cost, slower response
3138
- * - medium: Balanced context, cost, and latency (default)
3139
- * - low: Least context, lowest cost, fastest response
3140
- */
3141
3141
  searchContextSize: import_v419.z.enum(["low", "medium", "high"]).optional(),
3142
- /**
3143
- * User location information to provide geographically relevant search results.
3144
- */
3145
3142
  userLocation: import_v419.z.object({
3146
- /**
3147
- * Type of location (always 'approximate')
3148
- */
3149
3143
  type: import_v419.z.literal("approximate"),
3150
- /**
3151
- * Two-letter ISO country code (e.g., 'US', 'GB')
3152
- */
3153
3144
  country: import_v419.z.string().optional(),
3154
- /**
3155
- * City name (free text, e.g., 'Minneapolis')
3156
- */
3157
3145
  city: import_v419.z.string().optional(),
3158
- /**
3159
- * Region name (free text, e.g., 'Minnesota')
3160
- */
3161
3146
  region: import_v419.z.string().optional(),
3162
- /**
3163
- * IANA timezone (e.g., 'America/Chicago')
3164
- */
3165
3147
  timezone: import_v419.z.string().optional()
3166
3148
  }).optional()
3167
3149
  })
3168
3150
  )
3169
3151
  );
3170
3152
  var webSearchPreviewInputSchema = (0, import_provider_utils26.lazySchema)(
3153
+ () => (0, import_provider_utils26.zodSchema)(import_v419.z.object({}))
3154
+ );
3155
+ var webSearchPreviewOutputSchema = (0, import_provider_utils26.lazySchema)(
3171
3156
  () => (0, import_provider_utils26.zodSchema)(
3172
3157
  import_v419.z.object({
3173
3158
  action: import_v419.z.discriminatedUnion("type", [
3174
3159
  import_v419.z.object({
3175
3160
  type: import_v419.z.literal("search"),
3176
- query: import_v419.z.string().nullish()
3161
+ query: import_v419.z.string().optional()
3177
3162
  }),
3178
3163
  import_v419.z.object({
3179
- type: import_v419.z.literal("open_page"),
3164
+ type: import_v419.z.literal("openPage"),
3180
3165
  url: import_v419.z.string()
3181
3166
  }),
3182
3167
  import_v419.z.object({
@@ -3184,14 +3169,15 @@ var webSearchPreviewInputSchema = (0, import_provider_utils26.lazySchema)(
3184
3169
  url: import_v419.z.string(),
3185
3170
  pattern: import_v419.z.string()
3186
3171
  })
3187
- ]).nullish()
3172
+ ])
3188
3173
  })
3189
3174
  )
3190
3175
  );
3191
- var webSearchPreview = (0, import_provider_utils26.createProviderDefinedToolFactory)({
3176
+ var webSearchPreview = (0, import_provider_utils26.createProviderDefinedToolFactoryWithOutputSchema)({
3192
3177
  id: "openai.web_search_preview",
3193
3178
  name: "web_search_preview",
3194
- inputSchema: webSearchPreviewInputSchema
3179
+ inputSchema: webSearchPreviewInputSchema,
3180
+ outputSchema: webSearchPreviewOutputSchema
3195
3181
  });
3196
3182
 
3197
3183
  // src/tool/image-generation.ts
@@ -3737,14 +3723,14 @@ var OpenAIResponsesLanguageModel = class {
3737
3723
  type: "tool-call",
3738
3724
  toolCallId: part.id,
3739
3725
  toolName: webSearchToolName != null ? webSearchToolName : "web_search",
3740
- input: JSON.stringify({ action: part.action }),
3726
+ input: JSON.stringify({}),
3741
3727
  providerExecuted: true
3742
3728
  });
3743
3729
  content.push({
3744
3730
  type: "tool-result",
3745
3731
  toolCallId: part.id,
3746
3732
  toolName: webSearchToolName != null ? webSearchToolName : "web_search",
3747
- result: { status: part.status },
3733
+ result: mapWebSearchOutput(part.action),
3748
3734
  providerExecuted: true
3749
3735
  });
3750
3736
  break;
@@ -3928,6 +3914,17 @@ var OpenAIResponsesLanguageModel = class {
3928
3914
  toolName: webSearchToolName != null ? webSearchToolName : "web_search",
3929
3915
  providerExecuted: true
3930
3916
  });
3917
+ controller.enqueue({
3918
+ type: "tool-input-end",
3919
+ id: value.item.id
3920
+ });
3921
+ controller.enqueue({
3922
+ type: "tool-call",
3923
+ toolCallId: value.item.id,
3924
+ toolName: "web_search",
3925
+ input: JSON.stringify({}),
3926
+ providerExecuted: true
3927
+ });
3931
3928
  } else if (value.item.type === "computer_call") {
3932
3929
  ongoingToolCalls[value.output_index] = {
3933
3930
  toolName: "computer_use",
@@ -4021,22 +4018,11 @@ var OpenAIResponsesLanguageModel = class {
4021
4018
  });
4022
4019
  } else if (value.item.type === "web_search_call") {
4023
4020
  ongoingToolCalls[value.output_index] = void 0;
4024
- controller.enqueue({
4025
- type: "tool-input-end",
4026
- id: value.item.id
4027
- });
4028
- controller.enqueue({
4029
- type: "tool-call",
4030
- toolCallId: value.item.id,
4031
- toolName: "web_search",
4032
- input: JSON.stringify({ action: value.item.action }),
4033
- providerExecuted: true
4034
- });
4035
4021
  controller.enqueue({
4036
4022
  type: "tool-result",
4037
4023
  toolCallId: value.item.id,
4038
4024
  toolName: "web_search",
4039
- result: { status: value.item.status },
4025
+ result: mapWebSearchOutput(value.item.action),
4040
4026
  providerExecuted: true
4041
4027
  });
4042
4028
  } else if (value.item.type === "computer_call") {
@@ -4381,6 +4367,19 @@ function getResponsesModelConfig(modelId) {
4381
4367
  isReasoningModel: false
4382
4368
  };
4383
4369
  }
4370
+ function mapWebSearchOutput(action) {
4371
+ var _a;
4372
+ switch (action.type) {
4373
+ case "search":
4374
+ return { action: { type: "search", query: (_a = action.query) != null ? _a : void 0 } };
4375
+ case "open_page":
4376
+ return { action: { type: "openPage", url: action.url } };
4377
+ case "find":
4378
+ return {
4379
+ action: { type: "find", url: action.url, pattern: action.pattern }
4380
+ };
4381
+ }
4382
+ }
4384
4383
  // Annotate the CommonJS export names for ESM import in node:
4385
4384
  0 && (module.exports = {
4386
4385
  OpenAIChatLanguageModel,