@ai-sdk/openai 3.0.0-beta.71 → 3.0.0-beta.72

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.
@@ -2158,7 +2158,6 @@ var localShellOutputSchema = (0, import_provider_utils19.lazySchema)(
2158
2158
  );
2159
2159
  var localShell = (0, import_provider_utils19.createProviderDefinedToolFactoryWithOutputSchema)({
2160
2160
  id: "openai.local_shell",
2161
- name: "local_shell",
2162
2161
  inputSchema: localShellInputSchema,
2163
2162
  outputSchema: localShellOutputSchema
2164
2163
  });
@@ -2170,6 +2169,7 @@ function isFileId(data, prefixes) {
2170
2169
  }
2171
2170
  async function convertToOpenAIResponsesInput({
2172
2171
  prompt,
2172
+ toolNameMapping,
2173
2173
  systemMessageMode,
2174
2174
  fileIdPrefixes,
2175
2175
  store,
@@ -2252,7 +2252,6 @@ async function convertToOpenAIResponsesInput({
2252
2252
  }
2253
2253
  case "assistant": {
2254
2254
  const reasoningMessages = {};
2255
- const toolCallParts = {};
2256
2255
  for (const part of content) {
2257
2256
  switch (part.type) {
2258
2257
  case "text": {
@@ -2269,7 +2268,6 @@ async function convertToOpenAIResponsesInput({
2269
2268
  break;
2270
2269
  }
2271
2270
  case "tool-call": {
2272
- toolCallParts[part.toolCallId] = part;
2273
2271
  if (part.providerExecuted) {
2274
2272
  break;
2275
2273
  }
@@ -2278,7 +2276,10 @@ async function convertToOpenAIResponsesInput({
2278
2276
  input.push({ type: "item_reference", id });
2279
2277
  break;
2280
2278
  }
2281
- if (hasLocalShellTool && part.toolName === "local_shell") {
2279
+ const resolvedToolName = toolNameMapping.toProviderToolName(
2280
+ part.toolName
2281
+ );
2282
+ if (hasLocalShellTool && resolvedToolName === "local_shell") {
2282
2283
  const parsedInput = await (0, import_provider_utils20.validateTypes)({
2283
2284
  value: part.input,
2284
2285
  schema: localShellInputSchema
@@ -2301,7 +2302,7 @@ async function convertToOpenAIResponsesInput({
2301
2302
  input.push({
2302
2303
  type: "function_call",
2303
2304
  call_id: part.toolCallId,
2304
- name: part.toolName,
2305
+ name: resolvedToolName,
2305
2306
  arguments: JSON.stringify(part.input),
2306
2307
  id
2307
2308
  });
@@ -2380,7 +2381,10 @@ async function convertToOpenAIResponsesInput({
2380
2381
  case "tool": {
2381
2382
  for (const part of content) {
2382
2383
  const output = part.output;
2383
- if (hasLocalShellTool && part.toolName === "local_shell" && output.type === "json") {
2384
+ const resolvedToolName = toolNameMapping.toProviderToolName(
2385
+ part.toolName
2386
+ );
2387
+ if (hasLocalShellTool && resolvedToolName === "local_shell" && output.type === "json") {
2384
2388
  const parsedOutput = await (0, import_provider_utils20.validateTypes)({
2385
2389
  value: output.value,
2386
2390
  schema: localShellOutputSchema
@@ -3182,6 +3186,7 @@ var openaiResponsesProviderOptionsSchema = (0, import_provider_utils22.lazySchem
3182
3186
 
3183
3187
  // src/responses/openai-responses-prepare-tools.ts
3184
3188
  var import_provider7 = require("@ai-sdk/provider");
3189
+ var import_provider_utils29 = require("@ai-sdk/provider-utils");
3185
3190
 
3186
3191
  // src/tool/code-interpreter.ts
3187
3192
  var import_provider_utils23 = require("@ai-sdk/provider-utils");
@@ -3220,7 +3225,6 @@ var codeInterpreterArgsSchema = (0, import_provider_utils23.lazySchema)(
3220
3225
  );
3221
3226
  var codeInterpreterToolFactory = (0, import_provider_utils23.createProviderDefinedToolFactoryWithOutputSchema)({
3222
3227
  id: "openai.code_interpreter",
3223
- name: "code_interpreter",
3224
3228
  inputSchema: codeInterpreterInputSchema,
3225
3229
  outputSchema: codeInterpreterOutputSchema
3226
3230
  });
@@ -3273,142 +3277,38 @@ var fileSearchOutputSchema = (0, import_provider_utils24.lazySchema)(
3273
3277
  );
3274
3278
  var fileSearch = (0, import_provider_utils24.createProviderDefinedToolFactoryWithOutputSchema)({
3275
3279
  id: "openai.file_search",
3276
- name: "file_search",
3277
3280
  inputSchema: import_v417.z.object({}),
3278
3281
  outputSchema: fileSearchOutputSchema
3279
3282
  });
3280
3283
 
3281
- // src/tool/web-search.ts
3284
+ // src/tool/image-generation.ts
3282
3285
  var import_provider_utils25 = require("@ai-sdk/provider-utils");
3283
3286
  var import_v418 = require("zod/v4");
3284
- var webSearchArgsSchema = (0, import_provider_utils25.lazySchema)(
3285
- () => (0, import_provider_utils25.zodSchema)(
3286
- import_v418.z.object({
3287
- externalWebAccess: import_v418.z.boolean().optional(),
3288
- filters: import_v418.z.object({ allowedDomains: import_v418.z.array(import_v418.z.string()).optional() }).optional(),
3289
- searchContextSize: import_v418.z.enum(["low", "medium", "high"]).optional(),
3290
- userLocation: import_v418.z.object({
3291
- type: import_v418.z.literal("approximate"),
3292
- country: import_v418.z.string().optional(),
3293
- city: import_v418.z.string().optional(),
3294
- region: import_v418.z.string().optional(),
3295
- timezone: import_v418.z.string().optional()
3296
- }).optional()
3297
- })
3298
- )
3299
- );
3300
- var webSearchInputSchema = (0, import_provider_utils25.lazySchema)(() => (0, import_provider_utils25.zodSchema)(import_v418.z.object({})));
3301
- var webSearchOutputSchema = (0, import_provider_utils25.lazySchema)(
3287
+ var imageGenerationArgsSchema = (0, import_provider_utils25.lazySchema)(
3302
3288
  () => (0, import_provider_utils25.zodSchema)(
3303
3289
  import_v418.z.object({
3304
- action: import_v418.z.discriminatedUnion("type", [
3305
- import_v418.z.object({
3306
- type: import_v418.z.literal("search"),
3307
- query: import_v418.z.string().optional()
3308
- }),
3309
- import_v418.z.object({
3310
- type: import_v418.z.literal("openPage"),
3311
- url: import_v418.z.string()
3312
- }),
3313
- import_v418.z.object({
3314
- type: import_v418.z.literal("find"),
3315
- url: import_v418.z.string(),
3316
- pattern: import_v418.z.string()
3317
- })
3318
- ]),
3319
- sources: import_v418.z.array(
3320
- import_v418.z.discriminatedUnion("type", [
3321
- import_v418.z.object({ type: import_v418.z.literal("url"), url: import_v418.z.string() }),
3322
- import_v418.z.object({ type: import_v418.z.literal("api"), name: import_v418.z.string() })
3323
- ])
3324
- ).optional()
3325
- })
3326
- )
3327
- );
3328
- var webSearchToolFactory = (0, import_provider_utils25.createProviderDefinedToolFactoryWithOutputSchema)({
3329
- id: "openai.web_search",
3330
- name: "web_search",
3331
- inputSchema: webSearchInputSchema,
3332
- outputSchema: webSearchOutputSchema
3333
- });
3334
-
3335
- // src/tool/web-search-preview.ts
3336
- var import_provider_utils26 = require("@ai-sdk/provider-utils");
3337
- var import_v419 = require("zod/v4");
3338
- var webSearchPreviewArgsSchema = (0, import_provider_utils26.lazySchema)(
3339
- () => (0, import_provider_utils26.zodSchema)(
3340
- import_v419.z.object({
3341
- searchContextSize: import_v419.z.enum(["low", "medium", "high"]).optional(),
3342
- userLocation: import_v419.z.object({
3343
- type: import_v419.z.literal("approximate"),
3344
- country: import_v419.z.string().optional(),
3345
- city: import_v419.z.string().optional(),
3346
- region: import_v419.z.string().optional(),
3347
- timezone: import_v419.z.string().optional()
3348
- }).optional()
3349
- })
3350
- )
3351
- );
3352
- var webSearchPreviewInputSchema = (0, import_provider_utils26.lazySchema)(
3353
- () => (0, import_provider_utils26.zodSchema)(import_v419.z.object({}))
3354
- );
3355
- var webSearchPreviewOutputSchema = (0, import_provider_utils26.lazySchema)(
3356
- () => (0, import_provider_utils26.zodSchema)(
3357
- import_v419.z.object({
3358
- action: import_v419.z.discriminatedUnion("type", [
3359
- import_v419.z.object({
3360
- type: import_v419.z.literal("search"),
3361
- query: import_v419.z.string().optional()
3362
- }),
3363
- import_v419.z.object({
3364
- type: import_v419.z.literal("openPage"),
3365
- url: import_v419.z.string()
3366
- }),
3367
- import_v419.z.object({
3368
- type: import_v419.z.literal("find"),
3369
- url: import_v419.z.string(),
3370
- pattern: import_v419.z.string()
3371
- })
3372
- ])
3373
- })
3374
- )
3375
- );
3376
- var webSearchPreview = (0, import_provider_utils26.createProviderDefinedToolFactoryWithOutputSchema)({
3377
- id: "openai.web_search_preview",
3378
- name: "web_search_preview",
3379
- inputSchema: webSearchPreviewInputSchema,
3380
- outputSchema: webSearchPreviewOutputSchema
3381
- });
3382
-
3383
- // src/tool/image-generation.ts
3384
- var import_provider_utils27 = require("@ai-sdk/provider-utils");
3385
- var import_v420 = require("zod/v4");
3386
- var imageGenerationArgsSchema = (0, import_provider_utils27.lazySchema)(
3387
- () => (0, import_provider_utils27.zodSchema)(
3388
- import_v420.z.object({
3389
- background: import_v420.z.enum(["auto", "opaque", "transparent"]).optional(),
3390
- inputFidelity: import_v420.z.enum(["low", "high"]).optional(),
3391
- inputImageMask: import_v420.z.object({
3392
- fileId: import_v420.z.string().optional(),
3393
- imageUrl: import_v420.z.string().optional()
3290
+ background: import_v418.z.enum(["auto", "opaque", "transparent"]).optional(),
3291
+ inputFidelity: import_v418.z.enum(["low", "high"]).optional(),
3292
+ inputImageMask: import_v418.z.object({
3293
+ fileId: import_v418.z.string().optional(),
3294
+ imageUrl: import_v418.z.string().optional()
3394
3295
  }).optional(),
3395
- model: import_v420.z.string().optional(),
3396
- moderation: import_v420.z.enum(["auto"]).optional(),
3397
- outputCompression: import_v420.z.number().int().min(0).max(100).optional(),
3398
- outputFormat: import_v420.z.enum(["png", "jpeg", "webp"]).optional(),
3399
- partialImages: import_v420.z.number().int().min(0).max(3).optional(),
3400
- quality: import_v420.z.enum(["auto", "low", "medium", "high"]).optional(),
3401
- size: import_v420.z.enum(["1024x1024", "1024x1536", "1536x1024", "auto"]).optional()
3296
+ model: import_v418.z.string().optional(),
3297
+ moderation: import_v418.z.enum(["auto"]).optional(),
3298
+ outputCompression: import_v418.z.number().int().min(0).max(100).optional(),
3299
+ outputFormat: import_v418.z.enum(["png", "jpeg", "webp"]).optional(),
3300
+ partialImages: import_v418.z.number().int().min(0).max(3).optional(),
3301
+ quality: import_v418.z.enum(["auto", "low", "medium", "high"]).optional(),
3302
+ size: import_v418.z.enum(["1024x1024", "1024x1536", "1536x1024", "auto"]).optional()
3402
3303
  }).strict()
3403
3304
  )
3404
3305
  );
3405
- var imageGenerationInputSchema = (0, import_provider_utils27.lazySchema)(() => (0, import_provider_utils27.zodSchema)(import_v420.z.object({})));
3406
- var imageGenerationOutputSchema = (0, import_provider_utils27.lazySchema)(
3407
- () => (0, import_provider_utils27.zodSchema)(import_v420.z.object({ result: import_v420.z.string() }))
3306
+ var imageGenerationInputSchema = (0, import_provider_utils25.lazySchema)(() => (0, import_provider_utils25.zodSchema)(import_v418.z.object({})));
3307
+ var imageGenerationOutputSchema = (0, import_provider_utils25.lazySchema)(
3308
+ () => (0, import_provider_utils25.zodSchema)(import_v418.z.object({ result: import_v418.z.string() }))
3408
3309
  );
3409
- var imageGenerationToolFactory = (0, import_provider_utils27.createProviderDefinedToolFactoryWithOutputSchema)({
3310
+ var imageGenerationToolFactory = (0, import_provider_utils25.createProviderDefinedToolFactoryWithOutputSchema)({
3410
3311
  id: "openai.image_generation",
3411
- name: "image_generation",
3412
3312
  inputSchema: imageGenerationInputSchema,
3413
3313
  outputSchema: imageGenerationOutputSchema
3414
3314
  });
@@ -3417,32 +3317,32 @@ var imageGeneration = (args = {}) => {
3417
3317
  };
3418
3318
 
3419
3319
  // src/tool/mcp.ts
3420
- var import_provider_utils28 = require("@ai-sdk/provider-utils");
3421
- var import_v421 = require("zod/v4");
3422
- var jsonValueSchema = import_v421.z.lazy(
3423
- () => import_v421.z.union([
3424
- import_v421.z.string(),
3425
- import_v421.z.number(),
3426
- import_v421.z.boolean(),
3427
- import_v421.z.null(),
3428
- import_v421.z.array(jsonValueSchema),
3429
- import_v421.z.record(import_v421.z.string(), jsonValueSchema)
3320
+ var import_provider_utils26 = require("@ai-sdk/provider-utils");
3321
+ var import_v419 = require("zod/v4");
3322
+ var jsonValueSchema = import_v419.z.lazy(
3323
+ () => import_v419.z.union([
3324
+ import_v419.z.string(),
3325
+ import_v419.z.number(),
3326
+ import_v419.z.boolean(),
3327
+ import_v419.z.null(),
3328
+ import_v419.z.array(jsonValueSchema),
3329
+ import_v419.z.record(import_v419.z.string(), jsonValueSchema)
3430
3330
  ])
3431
3331
  );
3432
- var mcpArgsSchema = (0, import_provider_utils28.lazySchema)(
3433
- () => (0, import_provider_utils28.zodSchema)(
3434
- import_v421.z.object({
3435
- serverLabel: import_v421.z.string(),
3436
- allowedTools: import_v421.z.union([
3437
- import_v421.z.array(import_v421.z.string()),
3438
- import_v421.z.object({
3439
- readOnly: import_v421.z.boolean().optional(),
3440
- toolNames: import_v421.z.array(import_v421.z.string()).optional()
3332
+ var mcpArgsSchema = (0, import_provider_utils26.lazySchema)(
3333
+ () => (0, import_provider_utils26.zodSchema)(
3334
+ import_v419.z.object({
3335
+ serverLabel: import_v419.z.string(),
3336
+ allowedTools: import_v419.z.union([
3337
+ import_v419.z.array(import_v419.z.string()),
3338
+ import_v419.z.object({
3339
+ readOnly: import_v419.z.boolean().optional(),
3340
+ toolNames: import_v419.z.array(import_v419.z.string()).optional()
3441
3341
  })
3442
3342
  ]).optional(),
3443
- authorization: import_v421.z.string().optional(),
3444
- connectorId: import_v421.z.string().optional(),
3445
- headers: import_v421.z.record(import_v421.z.string(), import_v421.z.string()).optional(),
3343
+ authorization: import_v419.z.string().optional(),
3344
+ connectorId: import_v419.z.string().optional(),
3345
+ headers: import_v419.z.record(import_v419.z.string(), import_v419.z.string()).optional(),
3446
3346
  // TODO: Integrate this MCP tool approval with our SDK's existing tool approval architecture
3447
3347
  // requireApproval: z
3448
3348
  // .union([
@@ -3453,58 +3353,156 @@ var mcpArgsSchema = (0, import_provider_utils28.lazySchema)(
3453
3353
  // }),
3454
3354
  // ])
3455
3355
  // .optional(),
3456
- serverDescription: import_v421.z.string().optional(),
3457
- serverUrl: import_v421.z.string().optional()
3356
+ serverDescription: import_v419.z.string().optional(),
3357
+ serverUrl: import_v419.z.string().optional()
3458
3358
  }).refine(
3459
3359
  (v) => v.serverUrl != null || v.connectorId != null,
3460
3360
  "One of serverUrl or connectorId must be provided."
3461
3361
  )
3462
3362
  )
3463
3363
  );
3464
- var mcpInputSchema = (0, import_provider_utils28.lazySchema)(() => (0, import_provider_utils28.zodSchema)(import_v421.z.object({})));
3465
- var mcpOutputSchema = (0, import_provider_utils28.lazySchema)(
3466
- () => (0, import_provider_utils28.zodSchema)(
3467
- import_v421.z.discriminatedUnion("type", [
3468
- import_v421.z.object({
3469
- type: import_v421.z.literal("call"),
3470
- serverLabel: import_v421.z.string(),
3471
- name: import_v421.z.string(),
3472
- arguments: import_v421.z.string(),
3473
- output: import_v421.z.string().nullable().optional(),
3474
- error: import_v421.z.union([import_v421.z.string(), jsonValueSchema]).optional()
3364
+ var mcpInputSchema = (0, import_provider_utils26.lazySchema)(() => (0, import_provider_utils26.zodSchema)(import_v419.z.object({})));
3365
+ var mcpOutputSchema = (0, import_provider_utils26.lazySchema)(
3366
+ () => (0, import_provider_utils26.zodSchema)(
3367
+ import_v419.z.discriminatedUnion("type", [
3368
+ import_v419.z.object({
3369
+ type: import_v419.z.literal("call"),
3370
+ serverLabel: import_v419.z.string(),
3371
+ name: import_v419.z.string(),
3372
+ arguments: import_v419.z.string(),
3373
+ output: import_v419.z.string().nullable().optional(),
3374
+ error: import_v419.z.union([import_v419.z.string(), jsonValueSchema]).optional()
3475
3375
  }),
3476
- import_v421.z.object({
3477
- type: import_v421.z.literal("listTools"),
3478
- serverLabel: import_v421.z.string(),
3479
- tools: import_v421.z.array(
3480
- import_v421.z.object({
3481
- name: import_v421.z.string(),
3482
- description: import_v421.z.string().optional(),
3376
+ import_v419.z.object({
3377
+ type: import_v419.z.literal("listTools"),
3378
+ serverLabel: import_v419.z.string(),
3379
+ tools: import_v419.z.array(
3380
+ import_v419.z.object({
3381
+ name: import_v419.z.string(),
3382
+ description: import_v419.z.string().optional(),
3483
3383
  inputSchema: jsonValueSchema,
3484
- annotations: import_v421.z.record(import_v421.z.string(), jsonValueSchema).optional()
3384
+ annotations: import_v419.z.record(import_v419.z.string(), jsonValueSchema).optional()
3485
3385
  })
3486
3386
  ),
3487
- error: import_v421.z.union([import_v421.z.string(), jsonValueSchema]).optional()
3387
+ error: import_v419.z.union([import_v419.z.string(), jsonValueSchema]).optional()
3488
3388
  }),
3489
- import_v421.z.object({
3490
- type: import_v421.z.literal("approvalRequest"),
3491
- serverLabel: import_v421.z.string(),
3492
- name: import_v421.z.string(),
3493
- arguments: import_v421.z.string(),
3494
- approvalRequestId: import_v421.z.string()
3389
+ import_v419.z.object({
3390
+ type: import_v419.z.literal("approvalRequest"),
3391
+ serverLabel: import_v419.z.string(),
3392
+ name: import_v419.z.string(),
3393
+ arguments: import_v419.z.string(),
3394
+ approvalRequestId: import_v419.z.string()
3495
3395
  })
3496
3396
  ])
3497
3397
  )
3498
3398
  );
3499
- var mcpToolFactory = (0, import_provider_utils28.createProviderDefinedToolFactoryWithOutputSchema)({
3399
+ var mcpToolFactory = (0, import_provider_utils26.createProviderDefinedToolFactoryWithOutputSchema)({
3500
3400
  id: "openai.mcp",
3501
- name: "mcp",
3502
3401
  inputSchema: mcpInputSchema,
3503
3402
  outputSchema: mcpOutputSchema
3504
3403
  });
3505
3404
 
3405
+ // src/tool/web-search.ts
3406
+ var import_provider_utils27 = require("@ai-sdk/provider-utils");
3407
+ var import_v420 = require("zod/v4");
3408
+ var webSearchArgsSchema = (0, import_provider_utils27.lazySchema)(
3409
+ () => (0, import_provider_utils27.zodSchema)(
3410
+ import_v420.z.object({
3411
+ externalWebAccess: import_v420.z.boolean().optional(),
3412
+ filters: import_v420.z.object({ allowedDomains: import_v420.z.array(import_v420.z.string()).optional() }).optional(),
3413
+ searchContextSize: import_v420.z.enum(["low", "medium", "high"]).optional(),
3414
+ userLocation: import_v420.z.object({
3415
+ type: import_v420.z.literal("approximate"),
3416
+ country: import_v420.z.string().optional(),
3417
+ city: import_v420.z.string().optional(),
3418
+ region: import_v420.z.string().optional(),
3419
+ timezone: import_v420.z.string().optional()
3420
+ }).optional()
3421
+ })
3422
+ )
3423
+ );
3424
+ var webSearchInputSchema = (0, import_provider_utils27.lazySchema)(() => (0, import_provider_utils27.zodSchema)(import_v420.z.object({})));
3425
+ var webSearchOutputSchema = (0, import_provider_utils27.lazySchema)(
3426
+ () => (0, import_provider_utils27.zodSchema)(
3427
+ import_v420.z.object({
3428
+ action: import_v420.z.discriminatedUnion("type", [
3429
+ import_v420.z.object({
3430
+ type: import_v420.z.literal("search"),
3431
+ query: import_v420.z.string().optional()
3432
+ }),
3433
+ import_v420.z.object({
3434
+ type: import_v420.z.literal("openPage"),
3435
+ url: import_v420.z.string()
3436
+ }),
3437
+ import_v420.z.object({
3438
+ type: import_v420.z.literal("find"),
3439
+ url: import_v420.z.string(),
3440
+ pattern: import_v420.z.string()
3441
+ })
3442
+ ]),
3443
+ sources: import_v420.z.array(
3444
+ import_v420.z.discriminatedUnion("type", [
3445
+ import_v420.z.object({ type: import_v420.z.literal("url"), url: import_v420.z.string() }),
3446
+ import_v420.z.object({ type: import_v420.z.literal("api"), name: import_v420.z.string() })
3447
+ ])
3448
+ ).optional()
3449
+ })
3450
+ )
3451
+ );
3452
+ var webSearchToolFactory = (0, import_provider_utils27.createProviderDefinedToolFactoryWithOutputSchema)({
3453
+ id: "openai.web_search",
3454
+ inputSchema: webSearchInputSchema,
3455
+ outputSchema: webSearchOutputSchema
3456
+ });
3457
+
3458
+ // src/tool/web-search-preview.ts
3459
+ var import_provider_utils28 = require("@ai-sdk/provider-utils");
3460
+ var import_v421 = require("zod/v4");
3461
+ var webSearchPreviewArgsSchema = (0, import_provider_utils28.lazySchema)(
3462
+ () => (0, import_provider_utils28.zodSchema)(
3463
+ import_v421.z.object({
3464
+ searchContextSize: import_v421.z.enum(["low", "medium", "high"]).optional(),
3465
+ userLocation: import_v421.z.object({
3466
+ type: import_v421.z.literal("approximate"),
3467
+ country: import_v421.z.string().optional(),
3468
+ city: import_v421.z.string().optional(),
3469
+ region: import_v421.z.string().optional(),
3470
+ timezone: import_v421.z.string().optional()
3471
+ }).optional()
3472
+ })
3473
+ )
3474
+ );
3475
+ var webSearchPreviewInputSchema = (0, import_provider_utils28.lazySchema)(
3476
+ () => (0, import_provider_utils28.zodSchema)(import_v421.z.object({}))
3477
+ );
3478
+ var webSearchPreviewOutputSchema = (0, import_provider_utils28.lazySchema)(
3479
+ () => (0, import_provider_utils28.zodSchema)(
3480
+ import_v421.z.object({
3481
+ action: import_v421.z.discriminatedUnion("type", [
3482
+ import_v421.z.object({
3483
+ type: import_v421.z.literal("search"),
3484
+ query: import_v421.z.string().optional()
3485
+ }),
3486
+ import_v421.z.object({
3487
+ type: import_v421.z.literal("openPage"),
3488
+ url: import_v421.z.string()
3489
+ }),
3490
+ import_v421.z.object({
3491
+ type: import_v421.z.literal("find"),
3492
+ url: import_v421.z.string(),
3493
+ pattern: import_v421.z.string()
3494
+ })
3495
+ ])
3496
+ })
3497
+ )
3498
+ );
3499
+ var webSearchPreview = (0, import_provider_utils28.createProviderDefinedToolFactoryWithOutputSchema)({
3500
+ id: "openai.web_search_preview",
3501
+ inputSchema: webSearchPreviewInputSchema,
3502
+ outputSchema: webSearchPreviewOutputSchema
3503
+ });
3504
+
3506
3505
  // src/responses/openai-responses-prepare-tools.ts
3507
- var import_provider_utils29 = require("@ai-sdk/provider-utils");
3508
3506
  async function prepareResponsesTools({
3509
3507
  tools,
3510
3508
  toolChoice,
@@ -3627,15 +3625,6 @@ async function prepareResponsesTools({
3627
3625
  authorization: args.authorization,
3628
3626
  connector_id: args.connectorId,
3629
3627
  headers: args.headers,
3630
- // require_approval:
3631
- // typeof args.requireApproval === 'string'
3632
- // ? args.requireApproval
3633
- // : args.requireApproval
3634
- // ? {
3635
- // read_only: args.requireApproval.readOnly,
3636
- // tool_names: args.requireApproval.toolNames,
3637
- // }
3638
- // : undefined,
3639
3628
  require_approval: "never",
3640
3629
  server_description: args.serverDescription,
3641
3630
  server_url: args.serverUrl
@@ -3736,8 +3725,21 @@ var OpenAIResponsesLanguageModel = class {
3736
3725
  details: "conversation and previousResponseId cannot be used together"
3737
3726
  });
3738
3727
  }
3728
+ const toolNameMapping = (0, import_provider_utils30.createToolNameMapping)({
3729
+ tools,
3730
+ providerToolNames: {
3731
+ "openai.code_interpreter": "code_interpreter",
3732
+ "openai.file_search": "file_search",
3733
+ "openai.image_generation": "image_generation",
3734
+ "openai.local_shell": "local_shell",
3735
+ "openai.web_search": "web_search",
3736
+ "openai.web_search_preview": "web_search_preview",
3737
+ "openai.mcp": "mcp"
3738
+ }
3739
+ });
3739
3740
  const { input, warnings: inputWarnings } = await convertToOpenAIResponsesInput({
3740
3741
  prompt,
3742
+ toolNameMapping,
3741
3743
  systemMessageMode: modelConfig.systemMessageMode,
3742
3744
  fileIdPrefixes: this.config.fileIdPrefixes,
3743
3745
  store: (_a = openaiOptions == null ? void 0 : openaiOptions.store) != null ? _a : true,
@@ -3891,7 +3893,8 @@ var OpenAIResponsesLanguageModel = class {
3891
3893
  tool_choice: openaiToolChoice
3892
3894
  },
3893
3895
  warnings: [...warnings, ...toolWarnings],
3894
- store
3896
+ store,
3897
+ toolNameMapping
3895
3898
  };
3896
3899
  }
3897
3900
  async doGenerate(options) {
@@ -3899,7 +3902,8 @@ var OpenAIResponsesLanguageModel = class {
3899
3902
  const {
3900
3903
  args: body,
3901
3904
  warnings,
3902
- webSearchToolName
3905
+ webSearchToolName,
3906
+ toolNameMapping
3903
3907
  } = await this.getArgs(options);
3904
3908
  const url = this.config.url({
3905
3909
  path: "/responses",
@@ -3959,14 +3963,14 @@ var OpenAIResponsesLanguageModel = class {
3959
3963
  content.push({
3960
3964
  type: "tool-call",
3961
3965
  toolCallId: part.id,
3962
- toolName: "image_generation",
3966
+ toolName: toolNameMapping.toCustomToolName("image_generation"),
3963
3967
  input: "{}",
3964
3968
  providerExecuted: true
3965
3969
  });
3966
3970
  content.push({
3967
3971
  type: "tool-result",
3968
3972
  toolCallId: part.id,
3969
- toolName: "image_generation",
3973
+ toolName: toolNameMapping.toCustomToolName("image_generation"),
3970
3974
  result: {
3971
3975
  result: part.result
3972
3976
  }
@@ -3977,7 +3981,7 @@ var OpenAIResponsesLanguageModel = class {
3977
3981
  content.push({
3978
3982
  type: "tool-call",
3979
3983
  toolCallId: part.call_id,
3980
- toolName: "local_shell",
3984
+ toolName: toolNameMapping.toCustomToolName("local_shell"),
3981
3985
  input: JSON.stringify({
3982
3986
  action: part.action
3983
3987
  }),
@@ -4087,14 +4091,18 @@ var OpenAIResponsesLanguageModel = class {
4087
4091
  content.push({
4088
4092
  type: "tool-call",
4089
4093
  toolCallId: part.id,
4090
- toolName: webSearchToolName != null ? webSearchToolName : "web_search",
4094
+ toolName: toolNameMapping.toCustomToolName(
4095
+ webSearchToolName != null ? webSearchToolName : "web_search"
4096
+ ),
4091
4097
  input: JSON.stringify({}),
4092
4098
  providerExecuted: true
4093
4099
  });
4094
4100
  content.push({
4095
4101
  type: "tool-result",
4096
4102
  toolCallId: part.id,
4097
- toolName: webSearchToolName != null ? webSearchToolName : "web_search",
4103
+ toolName: toolNameMapping.toCustomToolName(
4104
+ webSearchToolName != null ? webSearchToolName : "web_search"
4105
+ ),
4098
4106
  result: mapWebSearchOutput(part.action)
4099
4107
  });
4100
4108
  break;
@@ -4103,14 +4111,14 @@ var OpenAIResponsesLanguageModel = class {
4103
4111
  content.push({
4104
4112
  type: "tool-call",
4105
4113
  toolCallId: part.id,
4106
- toolName: "mcp",
4114
+ toolName: toolNameMapping.toCustomToolName("mcp"),
4107
4115
  input: JSON.stringify({}),
4108
4116
  providerExecuted: true
4109
4117
  });
4110
4118
  content.push({
4111
4119
  type: "tool-result",
4112
4120
  toolCallId: part.id,
4113
- toolName: "mcp",
4121
+ toolName: toolNameMapping.toCustomToolName("mcp"),
4114
4122
  result: {
4115
4123
  type: "call",
4116
4124
  serverLabel: part.server_label,
@@ -4126,14 +4134,14 @@ var OpenAIResponsesLanguageModel = class {
4126
4134
  content.push({
4127
4135
  type: "tool-call",
4128
4136
  toolCallId: part.id,
4129
- toolName: "mcp",
4137
+ toolName: toolNameMapping.toCustomToolName("mcp"),
4130
4138
  input: JSON.stringify({}),
4131
4139
  providerExecuted: true
4132
4140
  });
4133
4141
  content.push({
4134
4142
  type: "tool-result",
4135
4143
  toolCallId: part.id,
4136
- toolName: "mcp",
4144
+ toolName: toolNameMapping.toCustomToolName("mcp"),
4137
4145
  result: {
4138
4146
  type: "listTools",
4139
4147
  serverLabel: part.server_label,
@@ -4155,14 +4163,14 @@ var OpenAIResponsesLanguageModel = class {
4155
4163
  content.push({
4156
4164
  type: "tool-call",
4157
4165
  toolCallId: part.id,
4158
- toolName: "mcp",
4166
+ toolName: toolNameMapping.toCustomToolName("mcp"),
4159
4167
  input: JSON.stringify({}),
4160
4168
  providerExecuted: true
4161
4169
  });
4162
4170
  content.push({
4163
4171
  type: "tool-result",
4164
4172
  toolCallId: part.id,
4165
- toolName: "mcp",
4173
+ toolName: toolNameMapping.toCustomToolName("mcp"),
4166
4174
  result: {
4167
4175
  type: "approvalRequest",
4168
4176
  serverLabel: part.server_label,
@@ -4177,14 +4185,14 @@ var OpenAIResponsesLanguageModel = class {
4177
4185
  content.push({
4178
4186
  type: "tool-call",
4179
4187
  toolCallId: part.id,
4180
- toolName: "computer_use",
4188
+ toolName: toolNameMapping.toCustomToolName("computer_use"),
4181
4189
  input: "",
4182
4190
  providerExecuted: true
4183
4191
  });
4184
4192
  content.push({
4185
4193
  type: "tool-result",
4186
4194
  toolCallId: part.id,
4187
- toolName: "computer_use",
4195
+ toolName: toolNameMapping.toCustomToolName("computer_use"),
4188
4196
  result: {
4189
4197
  type: "computer_use_tool_result",
4190
4198
  status: part.status || "completed"
@@ -4196,14 +4204,14 @@ var OpenAIResponsesLanguageModel = class {
4196
4204
  content.push({
4197
4205
  type: "tool-call",
4198
4206
  toolCallId: part.id,
4199
- toolName: "file_search",
4207
+ toolName: toolNameMapping.toCustomToolName("file_search"),
4200
4208
  input: "{}",
4201
4209
  providerExecuted: true
4202
4210
  });
4203
4211
  content.push({
4204
4212
  type: "tool-result",
4205
4213
  toolCallId: part.id,
4206
- toolName: "file_search",
4214
+ toolName: toolNameMapping.toCustomToolName("file_search"),
4207
4215
  result: {
4208
4216
  queries: part.queries,
4209
4217
  results: (_w = (_v = part.results) == null ? void 0 : _v.map((result) => ({
@@ -4221,7 +4229,7 @@ var OpenAIResponsesLanguageModel = class {
4221
4229
  content.push({
4222
4230
  type: "tool-call",
4223
4231
  toolCallId: part.id,
4224
- toolName: "code_interpreter",
4232
+ toolName: toolNameMapping.toCustomToolName("code_interpreter"),
4225
4233
  input: JSON.stringify({
4226
4234
  code: part.code,
4227
4235
  containerId: part.container_id
@@ -4231,7 +4239,7 @@ var OpenAIResponsesLanguageModel = class {
4231
4239
  content.push({
4232
4240
  type: "tool-result",
4233
4241
  toolCallId: part.id,
4234
- toolName: "code_interpreter",
4242
+ toolName: toolNameMapping.toCustomToolName("code_interpreter"),
4235
4243
  result: {
4236
4244
  outputs: part.outputs
4237
4245
  }
@@ -4280,6 +4288,7 @@ var OpenAIResponsesLanguageModel = class {
4280
4288
  args: body,
4281
4289
  warnings,
4282
4290
  webSearchToolName,
4291
+ toolNameMapping,
4283
4292
  store
4284
4293
  } = await this.getArgs(options);
4285
4294
  const { responseHeaders, value: response } = await (0, import_provider_utils30.postJsonToApi)({
@@ -4344,13 +4353,17 @@ var OpenAIResponsesLanguageModel = class {
4344
4353
  });
4345
4354
  } else if (value.item.type === "web_search_call") {
4346
4355
  ongoingToolCalls[value.output_index] = {
4347
- toolName: webSearchToolName != null ? webSearchToolName : "web_search",
4356
+ toolName: toolNameMapping.toCustomToolName(
4357
+ webSearchToolName != null ? webSearchToolName : "web_search"
4358
+ ),
4348
4359
  toolCallId: value.item.id
4349
4360
  };
4350
4361
  controller.enqueue({
4351
4362
  type: "tool-input-start",
4352
4363
  id: value.item.id,
4353
- toolName: webSearchToolName != null ? webSearchToolName : "web_search",
4364
+ toolName: toolNameMapping.toCustomToolName(
4365
+ webSearchToolName != null ? webSearchToolName : "web_search"
4366
+ ),
4354
4367
  providerExecuted: true
4355
4368
  });
4356
4369
  controller.enqueue({
@@ -4360,24 +4373,26 @@ var OpenAIResponsesLanguageModel = class {
4360
4373
  controller.enqueue({
4361
4374
  type: "tool-call",
4362
4375
  toolCallId: value.item.id,
4363
- toolName: webSearchToolName != null ? webSearchToolName : "web_search",
4376
+ toolName: toolNameMapping.toCustomToolName(
4377
+ webSearchToolName != null ? webSearchToolName : "web_search"
4378
+ ),
4364
4379
  input: JSON.stringify({}),
4365
4380
  providerExecuted: true
4366
4381
  });
4367
4382
  } else if (value.item.type === "computer_call") {
4368
4383
  ongoingToolCalls[value.output_index] = {
4369
- toolName: "computer_use",
4384
+ toolName: toolNameMapping.toCustomToolName("computer_use"),
4370
4385
  toolCallId: value.item.id
4371
4386
  };
4372
4387
  controller.enqueue({
4373
4388
  type: "tool-input-start",
4374
4389
  id: value.item.id,
4375
- toolName: "computer_use",
4390
+ toolName: toolNameMapping.toCustomToolName("computer_use"),
4376
4391
  providerExecuted: true
4377
4392
  });
4378
4393
  } else if (value.item.type === "code_interpreter_call") {
4379
4394
  ongoingToolCalls[value.output_index] = {
4380
- toolName: "code_interpreter",
4395
+ toolName: toolNameMapping.toCustomToolName("code_interpreter"),
4381
4396
  toolCallId: value.item.id,
4382
4397
  codeInterpreter: {
4383
4398
  containerId: value.item.container_id
@@ -4386,7 +4401,7 @@ var OpenAIResponsesLanguageModel = class {
4386
4401
  controller.enqueue({
4387
4402
  type: "tool-input-start",
4388
4403
  id: value.item.id,
4389
- toolName: "code_interpreter",
4404
+ toolName: toolNameMapping.toCustomToolName("code_interpreter"),
4390
4405
  providerExecuted: true
4391
4406
  });
4392
4407
  controller.enqueue({
@@ -4398,7 +4413,7 @@ var OpenAIResponsesLanguageModel = class {
4398
4413
  controller.enqueue({
4399
4414
  type: "tool-call",
4400
4415
  toolCallId: value.item.id,
4401
- toolName: "file_search",
4416
+ toolName: toolNameMapping.toCustomToolName("file_search"),
4402
4417
  input: "{}",
4403
4418
  providerExecuted: true
4404
4419
  });
@@ -4406,7 +4421,7 @@ var OpenAIResponsesLanguageModel = class {
4406
4421
  controller.enqueue({
4407
4422
  type: "tool-call",
4408
4423
  toolCallId: value.item.id,
4409
- toolName: "image_generation",
4424
+ toolName: toolNameMapping.toCustomToolName("image_generation"),
4410
4425
  input: "{}",
4411
4426
  providerExecuted: true
4412
4427
  });
@@ -4414,7 +4429,7 @@ var OpenAIResponsesLanguageModel = class {
4414
4429
  controller.enqueue({
4415
4430
  type: "tool-call",
4416
4431
  toolCallId: value.item.id,
4417
- toolName: "mcp",
4432
+ toolName: toolNameMapping.toCustomToolName("mcp"),
4418
4433
  input: "{}",
4419
4434
  providerExecuted: true
4420
4435
  });
@@ -4482,7 +4497,9 @@ var OpenAIResponsesLanguageModel = class {
4482
4497
  controller.enqueue({
4483
4498
  type: "tool-result",
4484
4499
  toolCallId: value.item.id,
4485
- toolName: webSearchToolName != null ? webSearchToolName : "web_search",
4500
+ toolName: toolNameMapping.toCustomToolName(
4501
+ webSearchToolName != null ? webSearchToolName : "web_search"
4502
+ ),
4486
4503
  result: mapWebSearchOutput(value.item.action)
4487
4504
  });
4488
4505
  } else if (value.item.type === "computer_call") {
@@ -4494,14 +4511,14 @@ var OpenAIResponsesLanguageModel = class {
4494
4511
  controller.enqueue({
4495
4512
  type: "tool-call",
4496
4513
  toolCallId: value.item.id,
4497
- toolName: "computer_use",
4514
+ toolName: toolNameMapping.toCustomToolName("computer_use"),
4498
4515
  input: "",
4499
4516
  providerExecuted: true
4500
4517
  });
4501
4518
  controller.enqueue({
4502
4519
  type: "tool-result",
4503
4520
  toolCallId: value.item.id,
4504
- toolName: "computer_use",
4521
+ toolName: toolNameMapping.toCustomToolName("computer_use"),
4505
4522
  result: {
4506
4523
  type: "computer_use_tool_result",
4507
4524
  status: value.item.status || "completed"
@@ -4512,7 +4529,7 @@ var OpenAIResponsesLanguageModel = class {
4512
4529
  controller.enqueue({
4513
4530
  type: "tool-result",
4514
4531
  toolCallId: value.item.id,
4515
- toolName: "file_search",
4532
+ toolName: toolNameMapping.toCustomToolName("file_search"),
4516
4533
  result: {
4517
4534
  queries: value.item.queries,
4518
4535
  results: (_c = (_b = value.item.results) == null ? void 0 : _b.map((result) => ({
@@ -4529,7 +4546,7 @@ var OpenAIResponsesLanguageModel = class {
4529
4546
  controller.enqueue({
4530
4547
  type: "tool-result",
4531
4548
  toolCallId: value.item.id,
4532
- toolName: "code_interpreter",
4549
+ toolName: toolNameMapping.toCustomToolName("code_interpreter"),
4533
4550
  result: {
4534
4551
  outputs: value.item.outputs
4535
4552
  }
@@ -4538,7 +4555,7 @@ var OpenAIResponsesLanguageModel = class {
4538
4555
  controller.enqueue({
4539
4556
  type: "tool-result",
4540
4557
  toolCallId: value.item.id,
4541
- toolName: "image_generation",
4558
+ toolName: toolNameMapping.toCustomToolName("image_generation"),
4542
4559
  result: {
4543
4560
  result: value.item.result
4544
4561
  }
@@ -4548,7 +4565,7 @@ var OpenAIResponsesLanguageModel = class {
4548
4565
  controller.enqueue({
4549
4566
  type: "tool-result",
4550
4567
  toolCallId: value.item.id,
4551
- toolName: "mcp",
4568
+ toolName: toolNameMapping.toCustomToolName("mcp"),
4552
4569
  result: {
4553
4570
  type: "call",
4554
4571
  serverLabel: value.item.server_label,
@@ -4563,7 +4580,7 @@ var OpenAIResponsesLanguageModel = class {
4563
4580
  controller.enqueue({
4564
4581
  type: "tool-result",
4565
4582
  toolCallId: value.item.id,
4566
- toolName: "mcp",
4583
+ toolName: toolNameMapping.toCustomToolName("mcp"),
4567
4584
  result: {
4568
4585
  type: "listTools",
4569
4586
  serverLabel: value.item.server_label,
@@ -4584,7 +4601,7 @@ var OpenAIResponsesLanguageModel = class {
4584
4601
  controller.enqueue({
4585
4602
  type: "tool-result",
4586
4603
  toolCallId: value.item.id,
4587
- toolName: "mcp",
4604
+ toolName: toolNameMapping.toCustomToolName("mcp"),
4588
4605
  result: {
4589
4606
  type: "approvalRequest",
4590
4607
  serverLabel: value.item.server_label,
@@ -4598,7 +4615,7 @@ var OpenAIResponsesLanguageModel = class {
4598
4615
  controller.enqueue({
4599
4616
  type: "tool-call",
4600
4617
  toolCallId: value.item.call_id,
4601
- toolName: "local_shell",
4618
+ toolName: toolNameMapping.toCustomToolName("local_shell"),
4602
4619
  input: JSON.stringify({
4603
4620
  action: {
4604
4621
  type: "exec",
@@ -4647,7 +4664,7 @@ var OpenAIResponsesLanguageModel = class {
4647
4664
  controller.enqueue({
4648
4665
  type: "tool-result",
4649
4666
  toolCallId: value.item_id,
4650
- toolName: "image_generation",
4667
+ toolName: toolNameMapping.toCustomToolName("image_generation"),
4651
4668
  result: {
4652
4669
  result: value.partial_image_b64
4653
4670
  },
@@ -4679,7 +4696,7 @@ var OpenAIResponsesLanguageModel = class {
4679
4696
  controller.enqueue({
4680
4697
  type: "tool-call",
4681
4698
  toolCallId: toolCall.toolCallId,
4682
- toolName: "code_interpreter",
4699
+ toolName: toolNameMapping.toCustomToolName("code_interpreter"),
4683
4700
  input: JSON.stringify({
4684
4701
  code: value.code,
4685
4702
  containerId: toolCall.codeInterpreter.containerId