@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.
@@ -2190,7 +2190,7 @@ async function convertToOpenAIResponsesInput({
2190
2190
  store,
2191
2191
  hasLocalShellTool = false
2192
2192
  }) {
2193
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
2193
+ var _a, _b, _c, _d, _e;
2194
2194
  const input = [];
2195
2195
  const warnings = [];
2196
2196
  for (const { role, content } of prompt) {
@@ -2271,10 +2271,15 @@ async function convertToOpenAIResponsesInput({
2271
2271
  for (const part of content) {
2272
2272
  switch (part.type) {
2273
2273
  case "text": {
2274
+ const id = (_b = (_a = part.providerOptions) == null ? void 0 : _a.openai) == null ? void 0 : _b.itemId;
2275
+ if (store && id != null) {
2276
+ input.push({ type: "item_reference", id });
2277
+ break;
2278
+ }
2274
2279
  input.push({
2275
2280
  role: "assistant",
2276
2281
  content: [{ type: "output_text", text: part.text }],
2277
- id: (_c = (_b = (_a = part.providerOptions) == null ? void 0 : _a.openai) == null ? void 0 : _b.itemId) != null ? _c : void 0
2282
+ id
2278
2283
  });
2279
2284
  break;
2280
2285
  }
@@ -2283,6 +2288,11 @@ async function convertToOpenAIResponsesInput({
2283
2288
  if (part.providerExecuted) {
2284
2289
  break;
2285
2290
  }
2291
+ const id = (_d = (_c = part.providerOptions) == null ? void 0 : _c.openai) == null ? void 0 : _d.itemId;
2292
+ if (store && id != null) {
2293
+ input.push({ type: "item_reference", id });
2294
+ break;
2295
+ }
2286
2296
  if (hasLocalShellTool && part.toolName === "local_shell") {
2287
2297
  const parsedInput = await validateTypes({
2288
2298
  value: part.input,
@@ -2291,7 +2301,7 @@ async function convertToOpenAIResponsesInput({
2291
2301
  input.push({
2292
2302
  type: "local_shell_call",
2293
2303
  call_id: part.toolCallId,
2294
- id: (_f = (_e = (_d = part.providerOptions) == null ? void 0 : _d.openai) == null ? void 0 : _e.itemId) != null ? _f : void 0,
2304
+ id,
2295
2305
  action: {
2296
2306
  type: "exec",
2297
2307
  command: parsedInput.action.command,
@@ -2308,7 +2318,7 @@ async function convertToOpenAIResponsesInput({
2308
2318
  call_id: part.toolCallId,
2309
2319
  name: part.toolName,
2310
2320
  arguments: JSON.stringify(part.input),
2311
- id: (_i = (_h = (_g = part.providerOptions) == null ? void 0 : _g.openai) == null ? void 0 : _h.itemId) != null ? _i : void 0
2321
+ id
2312
2322
  });
2313
2323
  break;
2314
2324
  }
@@ -2401,7 +2411,7 @@ async function convertToOpenAIResponsesInput({
2401
2411
  contentValue = output.value;
2402
2412
  break;
2403
2413
  case "execution-denied":
2404
- contentValue = (_j = output.reason) != null ? _j : "Tool execution denied.";
2414
+ contentValue = (_e = output.reason) != null ? _e : "Tool execution denied.";
2405
2415
  break;
2406
2416
  case "json":
2407
2417
  case "error-json":
@@ -2534,11 +2544,7 @@ var openaiResponsesChunkSchema = lazySchema12(
2534
2544
  z14.object({
2535
2545
  type: z14.literal("web_search_call"),
2536
2546
  id: z14.string(),
2537
- status: z14.string(),
2538
- action: z14.object({
2539
- type: z14.literal("search"),
2540
- query: z14.string().optional()
2541
- }).nullish()
2547
+ status: z14.string()
2542
2548
  }),
2543
2549
  z14.object({
2544
2550
  type: z14.literal("computer_call"),
@@ -2624,7 +2630,7 @@ var openaiResponsesChunkSchema = lazySchema12(
2624
2630
  url: z14.string(),
2625
2631
  pattern: z14.string()
2626
2632
  })
2627
- ]).nullish()
2633
+ ])
2628
2634
  }),
2629
2635
  z14.object({
2630
2636
  type: z14.literal("file_search_call"),
@@ -2805,7 +2811,7 @@ var openaiResponsesResponseSchema = lazySchema12(
2805
2811
  url: z14.string(),
2806
2812
  pattern: z14.string()
2807
2813
  })
2808
- ]).nullish()
2814
+ ])
2809
2815
  }),
2810
2816
  z14.object({
2811
2817
  type: z14.literal("file_search_call"),
@@ -3106,7 +3112,7 @@ var fileSearch = createProviderDefinedToolFactoryWithOutputSchema3({
3106
3112
 
3107
3113
  // src/tool/web-search.ts
3108
3114
  import {
3109
- createProviderDefinedToolFactory,
3115
+ createProviderDefinedToolFactoryWithOutputSchema as createProviderDefinedToolFactoryWithOutputSchema4,
3110
3116
  lazySchema as lazySchema16,
3111
3117
  zodSchema as zodSchema16
3112
3118
  } from "@ai-sdk/provider-utils";
@@ -3114,9 +3120,7 @@ import { z as z18 } from "zod/v4";
3114
3120
  var webSearchArgsSchema = lazySchema16(
3115
3121
  () => zodSchema16(
3116
3122
  z18.object({
3117
- filters: z18.object({
3118
- allowedDomains: z18.array(z18.string()).optional()
3119
- }).optional(),
3123
+ filters: z18.object({ allowedDomains: z18.array(z18.string()).optional() }).optional(),
3120
3124
  searchContextSize: z18.enum(["low", "medium", "high"]).optional(),
3121
3125
  userLocation: z18.object({
3122
3126
  type: z18.literal("approximate"),
@@ -3128,16 +3132,17 @@ var webSearchArgsSchema = lazySchema16(
3128
3132
  })
3129
3133
  )
3130
3134
  );
3131
- var webSearchInputSchema = lazySchema16(
3135
+ var webSearchInputSchema = lazySchema16(() => zodSchema16(z18.object({})));
3136
+ var webSearchOutputSchema = lazySchema16(
3132
3137
  () => zodSchema16(
3133
3138
  z18.object({
3134
3139
  action: z18.discriminatedUnion("type", [
3135
3140
  z18.object({
3136
3141
  type: z18.literal("search"),
3137
- query: z18.string().nullish()
3142
+ query: z18.string().optional()
3138
3143
  }),
3139
3144
  z18.object({
3140
- type: z18.literal("open_page"),
3145
+ type: z18.literal("openPage"),
3141
3146
  url: z18.string()
3142
3147
  }),
3143
3148
  z18.object({
@@ -3145,19 +3150,20 @@ var webSearchInputSchema = lazySchema16(
3145
3150
  url: z18.string(),
3146
3151
  pattern: z18.string()
3147
3152
  })
3148
- ]).nullish()
3153
+ ])
3149
3154
  })
3150
3155
  )
3151
3156
  );
3152
- var webSearchToolFactory = createProviderDefinedToolFactory({
3157
+ var webSearchToolFactory = createProviderDefinedToolFactoryWithOutputSchema4({
3153
3158
  id: "openai.web_search",
3154
3159
  name: "web_search",
3155
- inputSchema: webSearchInputSchema
3160
+ inputSchema: webSearchInputSchema,
3161
+ outputSchema: webSearchOutputSchema
3156
3162
  });
3157
3163
 
3158
3164
  // src/tool/web-search-preview.ts
3159
3165
  import {
3160
- createProviderDefinedToolFactory as createProviderDefinedToolFactory2,
3166
+ createProviderDefinedToolFactoryWithOutputSchema as createProviderDefinedToolFactoryWithOutputSchema5,
3161
3167
  lazySchema as lazySchema17,
3162
3168
  zodSchema as zodSchema17
3163
3169
  } from "@ai-sdk/provider-utils";
@@ -3165,51 +3171,30 @@ import { z as z19 } from "zod/v4";
3165
3171
  var webSearchPreviewArgsSchema = lazySchema17(
3166
3172
  () => zodSchema17(
3167
3173
  z19.object({
3168
- /**
3169
- * Search context size to use for the web search.
3170
- * - high: Most comprehensive context, highest cost, slower response
3171
- * - medium: Balanced context, cost, and latency (default)
3172
- * - low: Least context, lowest cost, fastest response
3173
- */
3174
3174
  searchContextSize: z19.enum(["low", "medium", "high"]).optional(),
3175
- /**
3176
- * User location information to provide geographically relevant search results.
3177
- */
3178
3175
  userLocation: z19.object({
3179
- /**
3180
- * Type of location (always 'approximate')
3181
- */
3182
3176
  type: z19.literal("approximate"),
3183
- /**
3184
- * Two-letter ISO country code (e.g., 'US', 'GB')
3185
- */
3186
3177
  country: z19.string().optional(),
3187
- /**
3188
- * City name (free text, e.g., 'Minneapolis')
3189
- */
3190
3178
  city: z19.string().optional(),
3191
- /**
3192
- * Region name (free text, e.g., 'Minnesota')
3193
- */
3194
3179
  region: z19.string().optional(),
3195
- /**
3196
- * IANA timezone (e.g., 'America/Chicago')
3197
- */
3198
3180
  timezone: z19.string().optional()
3199
3181
  }).optional()
3200
3182
  })
3201
3183
  )
3202
3184
  );
3203
3185
  var webSearchPreviewInputSchema = lazySchema17(
3186
+ () => zodSchema17(z19.object({}))
3187
+ );
3188
+ var webSearchPreviewOutputSchema = lazySchema17(
3204
3189
  () => zodSchema17(
3205
3190
  z19.object({
3206
3191
  action: z19.discriminatedUnion("type", [
3207
3192
  z19.object({
3208
3193
  type: z19.literal("search"),
3209
- query: z19.string().nullish()
3194
+ query: z19.string().optional()
3210
3195
  }),
3211
3196
  z19.object({
3212
- type: z19.literal("open_page"),
3197
+ type: z19.literal("openPage"),
3213
3198
  url: z19.string()
3214
3199
  }),
3215
3200
  z19.object({
@@ -3217,19 +3202,20 @@ var webSearchPreviewInputSchema = lazySchema17(
3217
3202
  url: z19.string(),
3218
3203
  pattern: z19.string()
3219
3204
  })
3220
- ]).nullish()
3205
+ ])
3221
3206
  })
3222
3207
  )
3223
3208
  );
3224
- var webSearchPreview = createProviderDefinedToolFactory2({
3209
+ var webSearchPreview = createProviderDefinedToolFactoryWithOutputSchema5({
3225
3210
  id: "openai.web_search_preview",
3226
3211
  name: "web_search_preview",
3227
- inputSchema: webSearchPreviewInputSchema
3212
+ inputSchema: webSearchPreviewInputSchema,
3213
+ outputSchema: webSearchPreviewOutputSchema
3228
3214
  });
3229
3215
 
3230
3216
  // src/tool/image-generation.ts
3231
3217
  import {
3232
- createProviderDefinedToolFactoryWithOutputSchema as createProviderDefinedToolFactoryWithOutputSchema4,
3218
+ createProviderDefinedToolFactoryWithOutputSchema as createProviderDefinedToolFactoryWithOutputSchema6,
3233
3219
  lazySchema as lazySchema18,
3234
3220
  zodSchema as zodSchema18
3235
3221
  } from "@ai-sdk/provider-utils";
@@ -3257,7 +3243,7 @@ var imageGenerationInputSchema = lazySchema18(() => zodSchema18(z20.object({})))
3257
3243
  var imageGenerationOutputSchema = lazySchema18(
3258
3244
  () => zodSchema18(z20.object({ result: z20.string() }))
3259
3245
  );
3260
- var imageGenerationToolFactory = createProviderDefinedToolFactoryWithOutputSchema4({
3246
+ var imageGenerationToolFactory = createProviderDefinedToolFactoryWithOutputSchema6({
3261
3247
  id: "openai.image_generation",
3262
3248
  name: "image_generation",
3263
3249
  inputSchema: imageGenerationInputSchema,
@@ -3774,14 +3760,14 @@ var OpenAIResponsesLanguageModel = class {
3774
3760
  type: "tool-call",
3775
3761
  toolCallId: part.id,
3776
3762
  toolName: webSearchToolName != null ? webSearchToolName : "web_search",
3777
- input: JSON.stringify({ action: part.action }),
3763
+ input: JSON.stringify({}),
3778
3764
  providerExecuted: true
3779
3765
  });
3780
3766
  content.push({
3781
3767
  type: "tool-result",
3782
3768
  toolCallId: part.id,
3783
3769
  toolName: webSearchToolName != null ? webSearchToolName : "web_search",
3784
- result: { status: part.status },
3770
+ result: mapWebSearchOutput(part.action),
3785
3771
  providerExecuted: true
3786
3772
  });
3787
3773
  break;
@@ -3965,6 +3951,17 @@ var OpenAIResponsesLanguageModel = class {
3965
3951
  toolName: webSearchToolName != null ? webSearchToolName : "web_search",
3966
3952
  providerExecuted: true
3967
3953
  });
3954
+ controller.enqueue({
3955
+ type: "tool-input-end",
3956
+ id: value.item.id
3957
+ });
3958
+ controller.enqueue({
3959
+ type: "tool-call",
3960
+ toolCallId: value.item.id,
3961
+ toolName: "web_search",
3962
+ input: JSON.stringify({}),
3963
+ providerExecuted: true
3964
+ });
3968
3965
  } else if (value.item.type === "computer_call") {
3969
3966
  ongoingToolCalls[value.output_index] = {
3970
3967
  toolName: "computer_use",
@@ -4058,22 +4055,11 @@ var OpenAIResponsesLanguageModel = class {
4058
4055
  });
4059
4056
  } else if (value.item.type === "web_search_call") {
4060
4057
  ongoingToolCalls[value.output_index] = void 0;
4061
- controller.enqueue({
4062
- type: "tool-input-end",
4063
- id: value.item.id
4064
- });
4065
- controller.enqueue({
4066
- type: "tool-call",
4067
- toolCallId: value.item.id,
4068
- toolName: "web_search",
4069
- input: JSON.stringify({ action: value.item.action }),
4070
- providerExecuted: true
4071
- });
4072
4058
  controller.enqueue({
4073
4059
  type: "tool-result",
4074
4060
  toolCallId: value.item.id,
4075
4061
  toolName: "web_search",
4076
- result: { status: value.item.status },
4062
+ result: mapWebSearchOutput(value.item.action),
4077
4063
  providerExecuted: true
4078
4064
  });
4079
4065
  } else if (value.item.type === "computer_call") {
@@ -4418,6 +4404,19 @@ function getResponsesModelConfig(modelId) {
4418
4404
  isReasoningModel: false
4419
4405
  };
4420
4406
  }
4407
+ function mapWebSearchOutput(action) {
4408
+ var _a;
4409
+ switch (action.type) {
4410
+ case "search":
4411
+ return { action: { type: "search", query: (_a = action.query) != null ? _a : void 0 } };
4412
+ case "open_page":
4413
+ return { action: { type: "openPage", url: action.url } };
4414
+ case "find":
4415
+ return {
4416
+ action: { type: "find", url: action.url, pattern: action.pattern }
4417
+ };
4418
+ }
4419
+ }
4421
4420
  export {
4422
4421
  OpenAIChatLanguageModel,
4423
4422
  OpenAICompletionLanguageModel,