@ai-sdk/openai 2.0.133 → 2.0.135

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.
@@ -2350,9 +2350,10 @@ import {
2350
2350
  import {
2351
2351
  convertToBase64 as convertToBase642,
2352
2352
  parseProviderOptions as parseProviderOptions7,
2353
+ safeValidateTypes,
2353
2354
  validateTypes
2354
2355
  } from "@ai-sdk/provider-utils";
2355
- import { z as z15 } from "zod/v4";
2356
+ import { z as z16 } from "zod/v4";
2356
2357
 
2357
2358
  // src/responses/openai-responses-options.ts
2358
2359
  import {
@@ -2590,7 +2591,119 @@ var localShell = createProviderDefinedToolFactoryWithOutputSchema({
2590
2591
  outputSchema: localShellOutputSchema
2591
2592
  });
2592
2593
 
2594
+ // src/tool/web-search.ts
2595
+ import {
2596
+ createProviderDefinedToolFactoryWithOutputSchema as createProviderDefinedToolFactoryWithOutputSchema2,
2597
+ lazySchema as lazySchema2,
2598
+ zodSchema as zodSchema14
2599
+ } from "@ai-sdk/provider-utils";
2600
+ import { z as z15 } from "zod/v4";
2601
+ var webSearchArgsSchema = lazySchema2(
2602
+ () => zodSchema14(
2603
+ z15.object({
2604
+ externalWebAccess: z15.boolean().optional(),
2605
+ filters: z15.object({
2606
+ allowedDomains: z15.array(z15.string()).optional(),
2607
+ blockedDomains: z15.array(z15.string()).optional()
2608
+ }).optional(),
2609
+ searchContextSize: z15.enum(["low", "medium", "high"]).optional(),
2610
+ userLocation: z15.object({
2611
+ type: z15.literal("approximate"),
2612
+ country: z15.string().optional(),
2613
+ city: z15.string().optional(),
2614
+ region: z15.string().optional(),
2615
+ timezone: z15.string().optional()
2616
+ }).optional()
2617
+ })
2618
+ )
2619
+ );
2620
+ var webSearchInputSchema = lazySchema2(() => zodSchema14(z15.object({})));
2621
+ var webSearchOutputSchema = lazySchema2(
2622
+ () => zodSchema14(
2623
+ z15.object({
2624
+ action: z15.discriminatedUnion("type", [
2625
+ z15.object({
2626
+ type: z15.literal("search"),
2627
+ query: z15.string().optional()
2628
+ }),
2629
+ z15.object({
2630
+ type: z15.literal("openPage"),
2631
+ url: z15.string().nullish()
2632
+ }),
2633
+ z15.object({
2634
+ type: z15.literal("findInPage"),
2635
+ url: z15.string().nullish(),
2636
+ pattern: z15.string().nullish()
2637
+ })
2638
+ ]).optional(),
2639
+ sources: z15.array(
2640
+ z15.discriminatedUnion("type", [
2641
+ z15.object({ type: z15.literal("url"), url: z15.string() }),
2642
+ z15.object({ type: z15.literal("api"), name: z15.string() })
2643
+ ])
2644
+ ).optional()
2645
+ })
2646
+ )
2647
+ );
2648
+ var webSearchToolFactory = createProviderDefinedToolFactoryWithOutputSchema2({
2649
+ id: "openai.web_search",
2650
+ name: "web_search",
2651
+ inputSchema: webSearchInputSchema,
2652
+ outputSchema: webSearchOutputSchema
2653
+ });
2654
+ var webSearch = (args = {}) => webSearchToolFactory(args);
2655
+
2593
2656
  // src/responses/convert-to-openai-responses-input.ts
2657
+ async function convertWebSearchToolResultOutput({
2658
+ output,
2659
+ id
2660
+ }) {
2661
+ if (output.type !== "json") {
2662
+ return void 0;
2663
+ }
2664
+ const validation = await safeValidateTypes({
2665
+ value: output.value,
2666
+ schema: webSearchOutputSchema
2667
+ });
2668
+ if (!validation.success || validation.value.action == null) {
2669
+ return void 0;
2670
+ }
2671
+ const { action, sources } = validation.value;
2672
+ switch (action.type) {
2673
+ case "search":
2674
+ return {
2675
+ type: "web_search_call",
2676
+ id,
2677
+ status: "completed",
2678
+ action: {
2679
+ type: "search",
2680
+ ...action.query != null && { query: action.query },
2681
+ ...sources != null && { sources }
2682
+ }
2683
+ };
2684
+ case "openPage":
2685
+ return {
2686
+ type: "web_search_call",
2687
+ id,
2688
+ status: "completed",
2689
+ action: {
2690
+ type: "open_page",
2691
+ url: action.url
2692
+ }
2693
+ };
2694
+ case "findInPage":
2695
+ return {
2696
+ type: "web_search_call",
2697
+ id,
2698
+ status: "completed",
2699
+ action: {
2700
+ type: "find_in_page",
2701
+ url: action.url,
2702
+ pattern: action.pattern
2703
+ }
2704
+ };
2705
+ }
2706
+ }
2594
2707
  function getPromptCacheBreakpoint2(providerOptions) {
2595
2708
  var _a2;
2596
2709
  return (_a2 = providerOptions == null ? void 0 : providerOptions.openai) == null ? void 0 : _a2.promptCacheBreakpoint;
@@ -2606,10 +2719,12 @@ async function convertToOpenAIResponsesInput({
2606
2719
  explicitMessageItemType = false,
2607
2720
  fileIdPrefixes,
2608
2721
  store,
2722
+ isReasoningModel = false,
2609
2723
  configurationUpdateUnsupportedReason,
2610
- hasLocalShellTool = false
2724
+ hasLocalShellTool = false,
2725
+ webSearchToolName
2611
2726
  }) {
2612
- var _a2, _b, _c, _d, _e, _f, _g, _h;
2727
+ var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
2613
2728
  let input = [];
2614
2729
  const warnings = [];
2615
2730
  for (const { role, content, providerOptions } of prompt) {
@@ -2758,12 +2873,14 @@ async function convertToOpenAIResponsesInput({
2758
2873
  case "assistant": {
2759
2874
  const reasoningMessages = {};
2760
2875
  const toolCallParts = {};
2876
+ let hasPrecedingReasoning = false;
2761
2877
  for (const part of content) {
2762
2878
  switch (part.type) {
2763
2879
  case "text": {
2764
2880
  const id = (_b = (_a2 = part.providerOptions) == null ? void 0 : _a2.openai) == null ? void 0 : _b.itemId;
2765
2881
  const phase = (_d = (_c = part.providerOptions) == null ? void 0 : _c.openai) == null ? void 0 : _d.phase;
2766
- if (store && id != null) {
2882
+ const canUseItemId = id != null && (!isReasoningModel || hasPrecedingReasoning);
2883
+ if (store && canUseItemId) {
2767
2884
  input.push({ type: "item_reference", id });
2768
2885
  break;
2769
2886
  }
@@ -2771,7 +2888,7 @@ async function convertToOpenAIResponsesInput({
2771
2888
  ...explicitMessageItemType && { type: "message" },
2772
2889
  role: "assistant",
2773
2890
  content: [{ type: "output_text", text: part.text }],
2774
- id,
2891
+ id: canUseItemId ? id : void 0,
2775
2892
  ...phase != null && { phase }
2776
2893
  });
2777
2894
  break;
@@ -2783,7 +2900,8 @@ async function convertToOpenAIResponsesInput({
2783
2900
  }
2784
2901
  const id = (_f = (_e = part.providerOptions) == null ? void 0 : _e.openai) == null ? void 0 : _f.itemId;
2785
2902
  const isAsync = (_h = (_g = part.providerOptions) == null ? void 0 : _g.openai) == null ? void 0 : _h.async;
2786
- if (store && id != null) {
2903
+ const canUseItemId = id != null && (!isReasoningModel || hasPrecedingReasoning);
2904
+ if (store && canUseItemId) {
2787
2905
  input.push({ type: "item_reference", id });
2788
2906
  break;
2789
2907
  }
@@ -2813,12 +2931,27 @@ async function convertToOpenAIResponsesInput({
2813
2931
  name: part.toolName,
2814
2932
  arguments: JSON.stringify(part.input),
2815
2933
  ...isAsync != null && { async: isAsync },
2816
- id
2934
+ id: canUseItemId ? id : void 0
2817
2935
  });
2818
2936
  break;
2819
2937
  }
2820
2938
  // assistant tool result parts are from provider-executed tools:
2821
2939
  case "tool-result": {
2940
+ if (part.toolName === "web_search" || part.toolName === "web_search_preview" || part.toolName === webSearchToolName) {
2941
+ const itemId = (_k = (_j = (_i = part.providerOptions) == null ? void 0 : _i[providerOptionsName]) == null ? void 0 : _j.itemId) != null ? _k : part.toolCallId;
2942
+ if (store) {
2943
+ input.push({ type: "item_reference", id: itemId });
2944
+ break;
2945
+ }
2946
+ const webSearchCall = await convertWebSearchToolResultOutput({
2947
+ output: part.output,
2948
+ id: itemId
2949
+ });
2950
+ if (webSearchCall != null) {
2951
+ input.push(webSearchCall);
2952
+ break;
2953
+ }
2954
+ }
2822
2955
  if (store) {
2823
2956
  input.push({ type: "item_reference", id: part.toolCallId });
2824
2957
  } else {
@@ -2830,6 +2963,7 @@ async function convertToOpenAIResponsesInput({
2830
2963
  break;
2831
2964
  }
2832
2965
  case "reasoning": {
2966
+ hasPrecedingReasoning = true;
2833
2967
  const providerOptions2 = await parseProviderOptions7({
2834
2968
  provider: "openai",
2835
2969
  providerOptions: part.providerOptions,
@@ -2987,9 +3121,9 @@ async function convertToOpenAIResponsesInput({
2987
3121
  }
2988
3122
  return { input, warnings };
2989
3123
  }
2990
- var openaiResponsesReasoningProviderOptionsSchema = z15.object({
2991
- itemId: z15.string().nullish(),
2992
- reasoningEncryptedContent: z15.string().nullish()
3124
+ var openaiResponsesReasoningProviderOptionsSchema = z16.object({
3125
+ itemId: z16.string().nullish(),
3126
+ reasoningEncryptedContent: z16.string().nullish()
2993
3127
  });
2994
3128
 
2995
3129
  // src/responses/map-openai-responses-finish-reason.ts
@@ -3013,289 +3147,289 @@ function mapOpenAIResponseFinishReason({
3013
3147
  // src/responses/openai-responses-api.ts
3014
3148
  import {
3015
3149
  lazyValidator as lazyValidator13,
3016
- zodSchema as zodSchema14
3150
+ zodSchema as zodSchema15
3017
3151
  } from "@ai-sdk/provider-utils";
3018
- import { z as z16 } from "zod/v4";
3152
+ import { z as z17 } from "zod/v4";
3019
3153
  var openaiResponsesChunkSchema = lazyValidator13(
3020
- () => zodSchema14(
3021
- z16.union([
3022
- z16.object({
3023
- type: z16.literal("response.output_text.delta"),
3024
- item_id: z16.string(),
3025
- delta: z16.string(),
3026
- logprobs: z16.array(
3027
- z16.object({
3028
- token: z16.string(),
3029
- logprob: z16.number(),
3030
- top_logprobs: z16.array(
3031
- z16.object({
3032
- token: z16.string(),
3033
- logprob: z16.number()
3154
+ () => zodSchema15(
3155
+ z17.union([
3156
+ z17.object({
3157
+ type: z17.literal("response.output_text.delta"),
3158
+ item_id: z17.string(),
3159
+ delta: z17.string(),
3160
+ logprobs: z17.array(
3161
+ z17.object({
3162
+ token: z17.string(),
3163
+ logprob: z17.number(),
3164
+ top_logprobs: z17.array(
3165
+ z17.object({
3166
+ token: z17.string(),
3167
+ logprob: z17.number()
3034
3168
  })
3035
3169
  )
3036
3170
  })
3037
3171
  ).nullish()
3038
3172
  }),
3039
- z16.object({
3040
- type: z16.enum(["response.completed", "response.incomplete"]),
3041
- response: z16.object({
3042
- incomplete_details: z16.object({ reason: z16.string() }).nullish(),
3043
- usage: z16.object({
3044
- input_tokens: z16.number(),
3045
- input_tokens_details: z16.object({
3046
- cached_tokens: z16.number().nullish(),
3047
- cache_write_tokens: z16.number().nullish(),
3048
- orchestration_input_tokens: z16.number().nullish(),
3049
- orchestration_input_cached_tokens: z16.number().nullish()
3173
+ z17.object({
3174
+ type: z17.enum(["response.completed", "response.incomplete"]),
3175
+ response: z17.object({
3176
+ incomplete_details: z17.object({ reason: z17.string() }).nullish(),
3177
+ usage: z17.object({
3178
+ input_tokens: z17.number(),
3179
+ input_tokens_details: z17.object({
3180
+ cached_tokens: z17.number().nullish(),
3181
+ cache_write_tokens: z17.number().nullish(),
3182
+ orchestration_input_tokens: z17.number().nullish(),
3183
+ orchestration_input_cached_tokens: z17.number().nullish()
3050
3184
  }).nullish(),
3051
- output_tokens: z16.number(),
3052
- output_tokens_details: z16.object({
3053
- reasoning_tokens: z16.number().nullish(),
3054
- orchestration_output_tokens: z16.number().nullish()
3185
+ output_tokens: z17.number(),
3186
+ output_tokens_details: z17.object({
3187
+ reasoning_tokens: z17.number().nullish(),
3188
+ orchestration_output_tokens: z17.number().nullish()
3055
3189
  }).nullish()
3056
3190
  }),
3057
- reasoning: z16.object({
3058
- context: z16.string().nullish()
3191
+ reasoning: z17.object({
3192
+ context: z17.string().nullish()
3059
3193
  }).nullish(),
3060
- service_tier: z16.string().nullish()
3194
+ service_tier: z17.string().nullish()
3061
3195
  })
3062
3196
  }),
3063
- z16.object({
3064
- type: z16.literal("response.created"),
3065
- response: z16.object({
3066
- id: z16.string(),
3067
- created_at: z16.number(),
3068
- model: z16.string(),
3069
- service_tier: z16.string().nullish()
3197
+ z17.object({
3198
+ type: z17.literal("response.created"),
3199
+ response: z17.object({
3200
+ id: z17.string(),
3201
+ created_at: z17.number(),
3202
+ model: z17.string(),
3203
+ service_tier: z17.string().nullish()
3070
3204
  })
3071
3205
  }),
3072
- z16.object({
3073
- type: z16.literal("response.output_item.added"),
3074
- output_index: z16.number(),
3075
- item: z16.discriminatedUnion("type", [
3076
- z16.object({
3077
- type: z16.literal("message"),
3078
- id: z16.string(),
3079
- phase: z16.enum(["commentary", "final_answer"]).nullish()
3206
+ z17.object({
3207
+ type: z17.literal("response.output_item.added"),
3208
+ output_index: z17.number(),
3209
+ item: z17.discriminatedUnion("type", [
3210
+ z17.object({
3211
+ type: z17.literal("message"),
3212
+ id: z17.string(),
3213
+ phase: z17.enum(["commentary", "final_answer"]).nullish()
3080
3214
  }),
3081
- z16.object({
3082
- type: z16.literal("reasoning"),
3083
- id: z16.string(),
3084
- encrypted_content: z16.string().nullish()
3215
+ z17.object({
3216
+ type: z17.literal("reasoning"),
3217
+ id: z17.string(),
3218
+ encrypted_content: z17.string().nullish()
3085
3219
  }),
3086
- z16.object({
3087
- type: z16.literal("function_call"),
3088
- id: z16.string(),
3089
- call_id: z16.string(),
3090
- name: z16.string(),
3091
- arguments: z16.string(),
3092
- async: z16.boolean().nullish()
3220
+ z17.object({
3221
+ type: z17.literal("function_call"),
3222
+ id: z17.string(),
3223
+ call_id: z17.string(),
3224
+ name: z17.string(),
3225
+ arguments: z17.string(),
3226
+ async: z17.boolean().nullish()
3093
3227
  }),
3094
- z16.object({
3095
- type: z16.literal("web_search_call"),
3096
- id: z16.string(),
3097
- status: z16.string()
3228
+ z17.object({
3229
+ type: z17.literal("web_search_call"),
3230
+ id: z17.string(),
3231
+ status: z17.string()
3098
3232
  }),
3099
- z16.object({
3100
- type: z16.literal("computer_call"),
3101
- id: z16.string(),
3102
- status: z16.string()
3233
+ z17.object({
3234
+ type: z17.literal("computer_call"),
3235
+ id: z17.string(),
3236
+ status: z17.string()
3103
3237
  }),
3104
- z16.object({
3105
- type: z16.literal("file_search_call"),
3106
- id: z16.string()
3238
+ z17.object({
3239
+ type: z17.literal("file_search_call"),
3240
+ id: z17.string()
3107
3241
  }),
3108
- z16.object({
3109
- type: z16.literal("image_generation_call"),
3110
- id: z16.string()
3242
+ z17.object({
3243
+ type: z17.literal("image_generation_call"),
3244
+ id: z17.string()
3111
3245
  }),
3112
- z16.object({
3113
- type: z16.literal("code_interpreter_call"),
3114
- id: z16.string(),
3115
- container_id: z16.string(),
3116
- code: z16.string().nullable(),
3117
- outputs: z16.array(
3118
- z16.discriminatedUnion("type", [
3119
- z16.object({ type: z16.literal("logs"), logs: z16.string() }),
3120
- z16.object({ type: z16.literal("image"), url: z16.string() })
3246
+ z17.object({
3247
+ type: z17.literal("code_interpreter_call"),
3248
+ id: z17.string(),
3249
+ container_id: z17.string(),
3250
+ code: z17.string().nullable(),
3251
+ outputs: z17.array(
3252
+ z17.discriminatedUnion("type", [
3253
+ z17.object({ type: z17.literal("logs"), logs: z17.string() }),
3254
+ z17.object({ type: z17.literal("image"), url: z17.string() })
3121
3255
  ])
3122
3256
  ).nullable(),
3123
- status: z16.string()
3257
+ status: z17.string()
3124
3258
  })
3125
3259
  ])
3126
3260
  }),
3127
- z16.object({
3128
- type: z16.literal("response.output_item.done"),
3129
- output_index: z16.number(),
3130
- item: z16.discriminatedUnion("type", [
3131
- z16.object({
3132
- type: z16.literal("message"),
3133
- id: z16.string(),
3134
- phase: z16.enum(["commentary", "final_answer"]).nullish()
3261
+ z17.object({
3262
+ type: z17.literal("response.output_item.done"),
3263
+ output_index: z17.number(),
3264
+ item: z17.discriminatedUnion("type", [
3265
+ z17.object({
3266
+ type: z17.literal("message"),
3267
+ id: z17.string(),
3268
+ phase: z17.enum(["commentary", "final_answer"]).nullish()
3135
3269
  }),
3136
- z16.object({
3137
- type: z16.literal("reasoning"),
3138
- id: z16.string(),
3139
- encrypted_content: z16.string().nullish()
3270
+ z17.object({
3271
+ type: z17.literal("reasoning"),
3272
+ id: z17.string(),
3273
+ encrypted_content: z17.string().nullish()
3140
3274
  }),
3141
- z16.object({
3142
- type: z16.literal("function_call"),
3143
- id: z16.string(),
3144
- call_id: z16.string(),
3145
- name: z16.string(),
3146
- arguments: z16.string(),
3147
- async: z16.boolean().nullish(),
3148
- status: z16.enum(["in_progress", "completed", "incomplete"])
3275
+ z17.object({
3276
+ type: z17.literal("function_call"),
3277
+ id: z17.string(),
3278
+ call_id: z17.string(),
3279
+ name: z17.string(),
3280
+ arguments: z17.string(),
3281
+ async: z17.boolean().nullish(),
3282
+ status: z17.enum(["in_progress", "completed", "incomplete"])
3149
3283
  }),
3150
- z16.object({
3151
- type: z16.literal("code_interpreter_call"),
3152
- id: z16.string(),
3153
- code: z16.string().nullable(),
3154
- container_id: z16.string(),
3155
- outputs: z16.array(
3156
- z16.discriminatedUnion("type", [
3157
- z16.object({ type: z16.literal("logs"), logs: z16.string() }),
3158
- z16.object({ type: z16.literal("image"), url: z16.string() })
3284
+ z17.object({
3285
+ type: z17.literal("code_interpreter_call"),
3286
+ id: z17.string(),
3287
+ code: z17.string().nullable(),
3288
+ container_id: z17.string(),
3289
+ outputs: z17.array(
3290
+ z17.discriminatedUnion("type", [
3291
+ z17.object({ type: z17.literal("logs"), logs: z17.string() }),
3292
+ z17.object({ type: z17.literal("image"), url: z17.string() })
3159
3293
  ])
3160
3294
  ).nullable()
3161
3295
  }),
3162
- z16.object({
3163
- type: z16.literal("image_generation_call"),
3164
- id: z16.string(),
3165
- result: z16.string()
3296
+ z17.object({
3297
+ type: z17.literal("image_generation_call"),
3298
+ id: z17.string(),
3299
+ result: z17.string()
3166
3300
  }),
3167
- z16.object({
3168
- type: z16.literal("web_search_call"),
3169
- id: z16.string(),
3170
- status: z16.string(),
3171
- action: z16.discriminatedUnion("type", [
3172
- z16.object({
3173
- type: z16.literal("search"),
3174
- query: z16.string().nullish(),
3175
- sources: z16.array(
3176
- z16.discriminatedUnion("type", [
3177
- z16.object({ type: z16.literal("url"), url: z16.string() }),
3178
- z16.object({ type: z16.literal("api"), name: z16.string() })
3301
+ z17.object({
3302
+ type: z17.literal("web_search_call"),
3303
+ id: z17.string(),
3304
+ status: z17.string(),
3305
+ action: z17.discriminatedUnion("type", [
3306
+ z17.object({
3307
+ type: z17.literal("search"),
3308
+ query: z17.string().nullish(),
3309
+ sources: z17.array(
3310
+ z17.discriminatedUnion("type", [
3311
+ z17.object({ type: z17.literal("url"), url: z17.string() }),
3312
+ z17.object({ type: z17.literal("api"), name: z17.string() })
3179
3313
  ])
3180
3314
  ).nullish()
3181
3315
  }),
3182
- z16.object({
3183
- type: z16.literal("open_page"),
3184
- url: z16.string().nullish()
3316
+ z17.object({
3317
+ type: z17.literal("open_page"),
3318
+ url: z17.string().nullish()
3185
3319
  }),
3186
- z16.object({
3187
- type: z16.literal("find_in_page"),
3188
- url: z16.string().nullish(),
3189
- pattern: z16.string().nullish()
3320
+ z17.object({
3321
+ type: z17.literal("find_in_page"),
3322
+ url: z17.string().nullish(),
3323
+ pattern: z17.string().nullish()
3190
3324
  })
3191
3325
  ]).nullish()
3192
3326
  }),
3193
- z16.object({
3194
- type: z16.literal("file_search_call"),
3195
- id: z16.string(),
3196
- queries: z16.array(z16.string()),
3197
- results: z16.array(
3198
- z16.object({
3199
- attributes: z16.record(z16.string(), z16.unknown()),
3200
- file_id: z16.string(),
3201
- filename: z16.string(),
3202
- score: z16.number(),
3203
- text: z16.string()
3327
+ z17.object({
3328
+ type: z17.literal("file_search_call"),
3329
+ id: z17.string(),
3330
+ queries: z17.array(z17.string()),
3331
+ results: z17.array(
3332
+ z17.object({
3333
+ attributes: z17.record(z17.string(), z17.unknown()),
3334
+ file_id: z17.string(),
3335
+ filename: z17.string(),
3336
+ score: z17.number(),
3337
+ text: z17.string()
3204
3338
  })
3205
3339
  ).nullish()
3206
3340
  }),
3207
- z16.object({
3208
- type: z16.literal("local_shell_call"),
3209
- id: z16.string(),
3210
- call_id: z16.string(),
3211
- action: z16.object({
3212
- type: z16.literal("exec"),
3213
- command: z16.array(z16.string()),
3214
- timeout_ms: z16.number().optional(),
3215
- user: z16.string().optional(),
3216
- working_directory: z16.string().optional(),
3217
- env: z16.record(z16.string(), z16.string()).optional()
3341
+ z17.object({
3342
+ type: z17.literal("local_shell_call"),
3343
+ id: z17.string(),
3344
+ call_id: z17.string(),
3345
+ action: z17.object({
3346
+ type: z17.literal("exec"),
3347
+ command: z17.array(z17.string()),
3348
+ timeout_ms: z17.number().optional(),
3349
+ user: z17.string().optional(),
3350
+ working_directory: z17.string().optional(),
3351
+ env: z17.record(z17.string(), z17.string()).optional()
3218
3352
  })
3219
3353
  }),
3220
- z16.object({
3221
- type: z16.literal("computer_call"),
3222
- id: z16.string(),
3223
- status: z16.literal("completed")
3354
+ z17.object({
3355
+ type: z17.literal("computer_call"),
3356
+ id: z17.string(),
3357
+ status: z17.literal("completed")
3224
3358
  })
3225
3359
  ])
3226
3360
  }),
3227
- z16.object({
3228
- type: z16.literal("response.function_call_arguments.delta"),
3229
- item_id: z16.string(),
3230
- output_index: z16.number(),
3231
- delta: z16.string()
3361
+ z17.object({
3362
+ type: z17.literal("response.function_call_arguments.delta"),
3363
+ item_id: z17.string(),
3364
+ output_index: z17.number(),
3365
+ delta: z17.string()
3232
3366
  }),
3233
- z16.object({
3234
- type: z16.literal("response.image_generation_call.partial_image"),
3235
- item_id: z16.string(),
3236
- output_index: z16.number(),
3237
- partial_image_b64: z16.string()
3367
+ z17.object({
3368
+ type: z17.literal("response.image_generation_call.partial_image"),
3369
+ item_id: z17.string(),
3370
+ output_index: z17.number(),
3371
+ partial_image_b64: z17.string()
3238
3372
  }),
3239
- z16.object({
3240
- type: z16.literal("response.code_interpreter_call_code.delta"),
3241
- item_id: z16.string(),
3242
- output_index: z16.number(),
3243
- delta: z16.string()
3373
+ z17.object({
3374
+ type: z17.literal("response.code_interpreter_call_code.delta"),
3375
+ item_id: z17.string(),
3376
+ output_index: z17.number(),
3377
+ delta: z17.string()
3244
3378
  }),
3245
- z16.object({
3246
- type: z16.literal("response.code_interpreter_call_code.done"),
3247
- item_id: z16.string(),
3248
- output_index: z16.number(),
3249
- code: z16.string()
3379
+ z17.object({
3380
+ type: z17.literal("response.code_interpreter_call_code.done"),
3381
+ item_id: z17.string(),
3382
+ output_index: z17.number(),
3383
+ code: z17.string()
3250
3384
  }),
3251
- z16.object({
3252
- type: z16.literal("response.output_text.annotation.added"),
3253
- annotation: z16.discriminatedUnion("type", [
3254
- z16.object({
3255
- type: z16.literal("url_citation"),
3256
- start_index: z16.number(),
3257
- end_index: z16.number(),
3258
- url: z16.string(),
3259
- title: z16.string()
3385
+ z17.object({
3386
+ type: z17.literal("response.output_text.annotation.added"),
3387
+ annotation: z17.discriminatedUnion("type", [
3388
+ z17.object({
3389
+ type: z17.literal("url_citation"),
3390
+ start_index: z17.number(),
3391
+ end_index: z17.number(),
3392
+ url: z17.string(),
3393
+ title: z17.string()
3260
3394
  }),
3261
- z16.object({
3262
- type: z16.literal("file_citation"),
3263
- file_id: z16.string(),
3264
- filename: z16.string().nullish(),
3265
- index: z16.number().nullish(),
3266
- start_index: z16.number().nullish(),
3267
- end_index: z16.number().nullish(),
3268
- quote: z16.string().nullish()
3395
+ z17.object({
3396
+ type: z17.literal("file_citation"),
3397
+ file_id: z17.string(),
3398
+ filename: z17.string().nullish(),
3399
+ index: z17.number().nullish(),
3400
+ start_index: z17.number().nullish(),
3401
+ end_index: z17.number().nullish(),
3402
+ quote: z17.string().nullish()
3269
3403
  })
3270
3404
  ])
3271
3405
  }),
3272
- z16.object({
3273
- type: z16.literal("response.reasoning_summary_part.added"),
3274
- item_id: z16.string(),
3275
- summary_index: z16.number()
3406
+ z17.object({
3407
+ type: z17.literal("response.reasoning_summary_part.added"),
3408
+ item_id: z17.string(),
3409
+ summary_index: z17.number()
3276
3410
  }),
3277
- z16.object({
3278
- type: z16.literal("response.reasoning_summary_text.delta"),
3279
- item_id: z16.string(),
3280
- summary_index: z16.number(),
3281
- delta: z16.string()
3411
+ z17.object({
3412
+ type: z17.literal("response.reasoning_summary_text.delta"),
3413
+ item_id: z17.string(),
3414
+ summary_index: z17.number(),
3415
+ delta: z17.string()
3282
3416
  }),
3283
- z16.object({
3284
- type: z16.literal("response.reasoning_summary_part.done"),
3285
- item_id: z16.string(),
3286
- summary_index: z16.number()
3417
+ z17.object({
3418
+ type: z17.literal("response.reasoning_summary_part.done"),
3419
+ item_id: z17.string(),
3420
+ summary_index: z17.number()
3287
3421
  }),
3288
- z16.object({
3289
- type: z16.literal("error"),
3290
- sequence_number: z16.number(),
3291
- error: z16.object({
3292
- type: z16.string(),
3293
- code: z16.string(),
3294
- message: z16.string(),
3295
- param: z16.string().nullish()
3422
+ z17.object({
3423
+ type: z17.literal("error"),
3424
+ sequence_number: z17.number(),
3425
+ error: z17.object({
3426
+ type: z17.string(),
3427
+ code: z17.string(),
3428
+ message: z17.string(),
3429
+ param: z17.string().nullish()
3296
3430
  })
3297
3431
  }),
3298
- z16.object({ type: z16.string() }).loose().transform((value) => ({
3432
+ z17.object({ type: z17.string() }).loose().transform((value) => ({
3299
3433
  type: "unknown_chunk",
3300
3434
  message: value.type
3301
3435
  }))
@@ -3304,196 +3438,196 @@ var openaiResponsesChunkSchema = lazyValidator13(
3304
3438
  )
3305
3439
  );
3306
3440
  var openaiResponsesResponseSchema = lazyValidator13(
3307
- () => zodSchema14(
3308
- z16.object({
3309
- id: z16.string().optional(),
3310
- created_at: z16.number().optional(),
3311
- error: z16.object({
3312
- message: z16.string(),
3313
- type: z16.string(),
3314
- param: z16.string().nullish(),
3315
- code: z16.string()
3441
+ () => zodSchema15(
3442
+ z17.object({
3443
+ id: z17.string().optional(),
3444
+ created_at: z17.number().optional(),
3445
+ error: z17.object({
3446
+ message: z17.string(),
3447
+ type: z17.string(),
3448
+ param: z17.string().nullish(),
3449
+ code: z17.string()
3316
3450
  }).nullish(),
3317
- model: z16.string().optional(),
3318
- output: z16.array(
3319
- z16.discriminatedUnion("type", [
3320
- z16.object({
3321
- type: z16.literal("message"),
3322
- role: z16.literal("assistant"),
3323
- id: z16.string(),
3324
- phase: z16.enum(["commentary", "final_answer"]).nullish(),
3325
- content: z16.array(
3326
- z16.object({
3327
- type: z16.literal("output_text"),
3328
- text: z16.string(),
3329
- logprobs: z16.array(
3330
- z16.object({
3331
- token: z16.string(),
3332
- logprob: z16.number(),
3333
- top_logprobs: z16.array(
3334
- z16.object({
3335
- token: z16.string(),
3336
- logprob: z16.number()
3451
+ model: z17.string().optional(),
3452
+ output: z17.array(
3453
+ z17.discriminatedUnion("type", [
3454
+ z17.object({
3455
+ type: z17.literal("message"),
3456
+ role: z17.literal("assistant"),
3457
+ id: z17.string(),
3458
+ phase: z17.enum(["commentary", "final_answer"]).nullish(),
3459
+ content: z17.array(
3460
+ z17.object({
3461
+ type: z17.literal("output_text"),
3462
+ text: z17.string(),
3463
+ logprobs: z17.array(
3464
+ z17.object({
3465
+ token: z17.string(),
3466
+ logprob: z17.number(),
3467
+ top_logprobs: z17.array(
3468
+ z17.object({
3469
+ token: z17.string(),
3470
+ logprob: z17.number()
3337
3471
  })
3338
3472
  )
3339
3473
  })
3340
3474
  ).nullish(),
3341
- annotations: z16.array(
3342
- z16.discriminatedUnion("type", [
3343
- z16.object({
3344
- type: z16.literal("url_citation"),
3345
- start_index: z16.number(),
3346
- end_index: z16.number(),
3347
- url: z16.string(),
3348
- title: z16.string()
3475
+ annotations: z17.array(
3476
+ z17.discriminatedUnion("type", [
3477
+ z17.object({
3478
+ type: z17.literal("url_citation"),
3479
+ start_index: z17.number(),
3480
+ end_index: z17.number(),
3481
+ url: z17.string(),
3482
+ title: z17.string()
3349
3483
  }),
3350
- z16.object({
3351
- type: z16.literal("file_citation"),
3352
- file_id: z16.string(),
3353
- filename: z16.string().nullish(),
3354
- index: z16.number().nullish(),
3355
- start_index: z16.number().nullish(),
3356
- end_index: z16.number().nullish(),
3357
- quote: z16.string().nullish()
3484
+ z17.object({
3485
+ type: z17.literal("file_citation"),
3486
+ file_id: z17.string(),
3487
+ filename: z17.string().nullish(),
3488
+ index: z17.number().nullish(),
3489
+ start_index: z17.number().nullish(),
3490
+ end_index: z17.number().nullish(),
3491
+ quote: z17.string().nullish()
3358
3492
  }),
3359
- z16.object({
3360
- type: z16.literal("container_file_citation"),
3361
- container_id: z16.string(),
3362
- file_id: z16.string(),
3363
- filename: z16.string().nullish(),
3364
- start_index: z16.number().nullish(),
3365
- end_index: z16.number().nullish(),
3366
- index: z16.number().nullish()
3493
+ z17.object({
3494
+ type: z17.literal("container_file_citation"),
3495
+ container_id: z17.string(),
3496
+ file_id: z17.string(),
3497
+ filename: z17.string().nullish(),
3498
+ start_index: z17.number().nullish(),
3499
+ end_index: z17.number().nullish(),
3500
+ index: z17.number().nullish()
3367
3501
  }),
3368
- z16.object({
3369
- type: z16.literal("file_path"),
3370
- file_id: z16.string(),
3371
- index: z16.number().nullish()
3502
+ z17.object({
3503
+ type: z17.literal("file_path"),
3504
+ file_id: z17.string(),
3505
+ index: z17.number().nullish()
3372
3506
  })
3373
3507
  ])
3374
3508
  )
3375
3509
  })
3376
3510
  )
3377
3511
  }),
3378
- z16.object({
3379
- type: z16.literal("web_search_call"),
3380
- id: z16.string(),
3381
- status: z16.string(),
3382
- action: z16.discriminatedUnion("type", [
3383
- z16.object({
3384
- type: z16.literal("search"),
3385
- query: z16.string().nullish(),
3386
- sources: z16.array(
3387
- z16.discriminatedUnion("type", [
3388
- z16.object({ type: z16.literal("url"), url: z16.string() }),
3389
- z16.object({
3390
- type: z16.literal("api"),
3391
- name: z16.string()
3512
+ z17.object({
3513
+ type: z17.literal("web_search_call"),
3514
+ id: z17.string(),
3515
+ status: z17.string(),
3516
+ action: z17.discriminatedUnion("type", [
3517
+ z17.object({
3518
+ type: z17.literal("search"),
3519
+ query: z17.string().nullish(),
3520
+ sources: z17.array(
3521
+ z17.discriminatedUnion("type", [
3522
+ z17.object({ type: z17.literal("url"), url: z17.string() }),
3523
+ z17.object({
3524
+ type: z17.literal("api"),
3525
+ name: z17.string()
3392
3526
  })
3393
3527
  ])
3394
3528
  ).nullish()
3395
3529
  }),
3396
- z16.object({
3397
- type: z16.literal("open_page"),
3398
- url: z16.string().nullish()
3530
+ z17.object({
3531
+ type: z17.literal("open_page"),
3532
+ url: z17.string().nullish()
3399
3533
  }),
3400
- z16.object({
3401
- type: z16.literal("find_in_page"),
3402
- url: z16.string().nullish(),
3403
- pattern: z16.string().nullish()
3534
+ z17.object({
3535
+ type: z17.literal("find_in_page"),
3536
+ url: z17.string().nullish(),
3537
+ pattern: z17.string().nullish()
3404
3538
  })
3405
3539
  ]).nullish()
3406
3540
  }),
3407
- z16.object({
3408
- type: z16.literal("file_search_call"),
3409
- id: z16.string(),
3410
- queries: z16.array(z16.string()),
3411
- results: z16.array(
3412
- z16.object({
3413
- attributes: z16.record(
3414
- z16.string(),
3415
- z16.union([z16.string(), z16.number(), z16.boolean()])
3541
+ z17.object({
3542
+ type: z17.literal("file_search_call"),
3543
+ id: z17.string(),
3544
+ queries: z17.array(z17.string()),
3545
+ results: z17.array(
3546
+ z17.object({
3547
+ attributes: z17.record(
3548
+ z17.string(),
3549
+ z17.union([z17.string(), z17.number(), z17.boolean()])
3416
3550
  ),
3417
- file_id: z16.string(),
3418
- filename: z16.string(),
3419
- score: z16.number(),
3420
- text: z16.string()
3551
+ file_id: z17.string(),
3552
+ filename: z17.string(),
3553
+ score: z17.number(),
3554
+ text: z17.string()
3421
3555
  })
3422
3556
  ).nullish()
3423
3557
  }),
3424
- z16.object({
3425
- type: z16.literal("code_interpreter_call"),
3426
- id: z16.string(),
3427
- code: z16.string().nullable(),
3428
- container_id: z16.string(),
3429
- outputs: z16.array(
3430
- z16.discriminatedUnion("type", [
3431
- z16.object({ type: z16.literal("logs"), logs: z16.string() }),
3432
- z16.object({ type: z16.literal("image"), url: z16.string() })
3558
+ z17.object({
3559
+ type: z17.literal("code_interpreter_call"),
3560
+ id: z17.string(),
3561
+ code: z17.string().nullable(),
3562
+ container_id: z17.string(),
3563
+ outputs: z17.array(
3564
+ z17.discriminatedUnion("type", [
3565
+ z17.object({ type: z17.literal("logs"), logs: z17.string() }),
3566
+ z17.object({ type: z17.literal("image"), url: z17.string() })
3433
3567
  ])
3434
3568
  ).nullable()
3435
3569
  }),
3436
- z16.object({
3437
- type: z16.literal("image_generation_call"),
3438
- id: z16.string(),
3439
- result: z16.string()
3570
+ z17.object({
3571
+ type: z17.literal("image_generation_call"),
3572
+ id: z17.string(),
3573
+ result: z17.string()
3440
3574
  }),
3441
- z16.object({
3442
- type: z16.literal("local_shell_call"),
3443
- id: z16.string(),
3444
- call_id: z16.string(),
3445
- action: z16.object({
3446
- type: z16.literal("exec"),
3447
- command: z16.array(z16.string()),
3448
- timeout_ms: z16.number().optional(),
3449
- user: z16.string().optional(),
3450
- working_directory: z16.string().optional(),
3451
- env: z16.record(z16.string(), z16.string()).optional()
3575
+ z17.object({
3576
+ type: z17.literal("local_shell_call"),
3577
+ id: z17.string(),
3578
+ call_id: z17.string(),
3579
+ action: z17.object({
3580
+ type: z17.literal("exec"),
3581
+ command: z17.array(z17.string()),
3582
+ timeout_ms: z17.number().optional(),
3583
+ user: z17.string().optional(),
3584
+ working_directory: z17.string().optional(),
3585
+ env: z17.record(z17.string(), z17.string()).optional()
3452
3586
  })
3453
3587
  }),
3454
- z16.object({
3455
- type: z16.literal("function_call"),
3456
- call_id: z16.string(),
3457
- name: z16.string(),
3458
- arguments: z16.string(),
3459
- id: z16.string(),
3460
- async: z16.boolean().nullish()
3588
+ z17.object({
3589
+ type: z17.literal("function_call"),
3590
+ call_id: z17.string(),
3591
+ name: z17.string(),
3592
+ arguments: z17.string(),
3593
+ id: z17.string(),
3594
+ async: z17.boolean().nullish()
3461
3595
  }),
3462
- z16.object({
3463
- type: z16.literal("computer_call"),
3464
- id: z16.string(),
3465
- status: z16.string().optional()
3596
+ z17.object({
3597
+ type: z17.literal("computer_call"),
3598
+ id: z17.string(),
3599
+ status: z17.string().optional()
3466
3600
  }),
3467
- z16.object({
3468
- type: z16.literal("reasoning"),
3469
- id: z16.string(),
3470
- encrypted_content: z16.string().nullish(),
3471
- summary: z16.array(
3472
- z16.object({
3473
- type: z16.literal("summary_text"),
3474
- text: z16.string()
3601
+ z17.object({
3602
+ type: z17.literal("reasoning"),
3603
+ id: z17.string(),
3604
+ encrypted_content: z17.string().nullish(),
3605
+ summary: z17.array(
3606
+ z17.object({
3607
+ type: z17.literal("summary_text"),
3608
+ text: z17.string()
3475
3609
  })
3476
3610
  )
3477
3611
  })
3478
3612
  ])
3479
3613
  ).optional(),
3480
- service_tier: z16.string().nullish(),
3481
- reasoning: z16.object({
3482
- context: z16.string().nullish()
3614
+ service_tier: z17.string().nullish(),
3615
+ reasoning: z17.object({
3616
+ context: z17.string().nullish()
3483
3617
  }).nullish(),
3484
- incomplete_details: z16.object({ reason: z16.string() }).nullish(),
3485
- usage: z16.object({
3486
- input_tokens: z16.number(),
3487
- input_tokens_details: z16.object({
3488
- cached_tokens: z16.number().nullish(),
3489
- cache_write_tokens: z16.number().nullish(),
3490
- orchestration_input_tokens: z16.number().nullish(),
3491
- orchestration_input_cached_tokens: z16.number().nullish()
3618
+ incomplete_details: z17.object({ reason: z17.string() }).nullish(),
3619
+ usage: z17.object({
3620
+ input_tokens: z17.number(),
3621
+ input_tokens_details: z17.object({
3622
+ cached_tokens: z17.number().nullish(),
3623
+ cache_write_tokens: z17.number().nullish(),
3624
+ orchestration_input_tokens: z17.number().nullish(),
3625
+ orchestration_input_cached_tokens: z17.number().nullish()
3492
3626
  }).nullish(),
3493
- output_tokens: z16.number(),
3494
- output_tokens_details: z16.object({
3495
- reasoning_tokens: z16.number().nullish(),
3496
- orchestration_output_tokens: z16.number().nullish()
3627
+ output_tokens: z17.number(),
3628
+ output_tokens_details: z17.object({
3629
+ reasoning_tokens: z17.number().nullish(),
3630
+ orchestration_output_tokens: z17.number().nullish()
3497
3631
  }).nullish()
3498
3632
  }).optional()
3499
3633
  })
@@ -3507,44 +3641,44 @@ import {
3507
3641
 
3508
3642
  // src/tool/code-interpreter.ts
3509
3643
  import {
3510
- createProviderDefinedToolFactoryWithOutputSchema as createProviderDefinedToolFactoryWithOutputSchema2,
3511
- lazySchema as lazySchema2,
3512
- zodSchema as zodSchema15
3644
+ createProviderDefinedToolFactoryWithOutputSchema as createProviderDefinedToolFactoryWithOutputSchema3,
3645
+ lazySchema as lazySchema3,
3646
+ zodSchema as zodSchema16
3513
3647
  } from "@ai-sdk/provider-utils";
3514
- import { z as z17 } from "zod/v4";
3515
- var codeInterpreterInputSchema = lazySchema2(
3516
- () => zodSchema15(
3517
- z17.object({
3518
- code: z17.string().nullish(),
3519
- containerId: z17.string()
3648
+ import { z as z18 } from "zod/v4";
3649
+ var codeInterpreterInputSchema = lazySchema3(
3650
+ () => zodSchema16(
3651
+ z18.object({
3652
+ code: z18.string().nullish(),
3653
+ containerId: z18.string()
3520
3654
  })
3521
3655
  )
3522
3656
  );
3523
- var codeInterpreterOutputSchema = lazySchema2(
3524
- () => zodSchema15(
3525
- z17.object({
3526
- outputs: z17.array(
3527
- z17.discriminatedUnion("type", [
3528
- z17.object({ type: z17.literal("logs"), logs: z17.string() }),
3529
- z17.object({ type: z17.literal("image"), url: z17.string() })
3657
+ var codeInterpreterOutputSchema = lazySchema3(
3658
+ () => zodSchema16(
3659
+ z18.object({
3660
+ outputs: z18.array(
3661
+ z18.discriminatedUnion("type", [
3662
+ z18.object({ type: z18.literal("logs"), logs: z18.string() }),
3663
+ z18.object({ type: z18.literal("image"), url: z18.string() })
3530
3664
  ])
3531
3665
  ).nullish()
3532
3666
  })
3533
3667
  )
3534
3668
  );
3535
- var codeInterpreterArgsSchema = lazySchema2(
3536
- () => zodSchema15(
3537
- z17.object({
3538
- container: z17.union([
3539
- z17.string(),
3540
- z17.object({
3541
- fileIds: z17.array(z17.string()).optional()
3669
+ var codeInterpreterArgsSchema = lazySchema3(
3670
+ () => zodSchema16(
3671
+ z18.object({
3672
+ container: z18.union([
3673
+ z18.string(),
3674
+ z18.object({
3675
+ fileIds: z18.array(z18.string()).optional()
3542
3676
  })
3543
3677
  ]).optional()
3544
3678
  })
3545
3679
  )
3546
3680
  );
3547
- var codeInterpreterToolFactory = createProviderDefinedToolFactoryWithOutputSchema2({
3681
+ var codeInterpreterToolFactory = createProviderDefinedToolFactoryWithOutputSchema3({
3548
3682
  id: "openai.code_interpreter",
3549
3683
  name: "code_interpreter",
3550
3684
  inputSchema: codeInterpreterInputSchema,
@@ -3555,120 +3689,58 @@ var codeInterpreter = (args = {}) => {
3555
3689
  };
3556
3690
 
3557
3691
  // src/tool/file-search.ts
3558
- import {
3559
- createProviderDefinedToolFactoryWithOutputSchema as createProviderDefinedToolFactoryWithOutputSchema3,
3560
- lazySchema as lazySchema3,
3561
- zodSchema as zodSchema16
3562
- } from "@ai-sdk/provider-utils";
3563
- import { z as z18 } from "zod/v4";
3564
- var comparisonFilterSchema = z18.object({
3565
- key: z18.string(),
3566
- type: z18.enum(["eq", "ne", "gt", "gte", "lt", "lte", "in", "nin"]),
3567
- value: z18.union([z18.string(), z18.number(), z18.boolean(), z18.array(z18.string())])
3568
- });
3569
- var compoundFilterSchema = z18.object({
3570
- type: z18.enum(["and", "or"]),
3571
- filters: z18.array(
3572
- z18.union([comparisonFilterSchema, z18.lazy(() => compoundFilterSchema)])
3573
- )
3574
- });
3575
- var fileSearchArgsSchema = lazySchema3(
3576
- () => zodSchema16(
3577
- z18.object({
3578
- vectorStoreIds: z18.array(z18.string()),
3579
- maxNumResults: z18.number().optional(),
3580
- ranking: z18.object({
3581
- ranker: z18.string().optional(),
3582
- scoreThreshold: z18.number().optional()
3583
- }).optional(),
3584
- filters: z18.union([comparisonFilterSchema, compoundFilterSchema]).optional()
3585
- })
3586
- )
3587
- );
3588
- var fileSearchOutputSchema = lazySchema3(
3589
- () => zodSchema16(
3590
- z18.object({
3591
- queries: z18.array(z18.string()),
3592
- results: z18.array(
3593
- z18.object({
3594
- attributes: z18.record(z18.string(), z18.unknown()),
3595
- fileId: z18.string(),
3596
- filename: z18.string(),
3597
- score: z18.number(),
3598
- text: z18.string()
3599
- })
3600
- ).nullable()
3601
- })
3602
- )
3603
- );
3604
- var fileSearch = createProviderDefinedToolFactoryWithOutputSchema3({
3605
- id: "openai.file_search",
3606
- name: "file_search",
3607
- inputSchema: z18.object({}),
3608
- outputSchema: fileSearchOutputSchema
3609
- });
3610
-
3611
- // src/tool/web-search.ts
3612
3692
  import {
3613
3693
  createProviderDefinedToolFactoryWithOutputSchema as createProviderDefinedToolFactoryWithOutputSchema4,
3614
3694
  lazySchema as lazySchema4,
3615
3695
  zodSchema as zodSchema17
3616
3696
  } from "@ai-sdk/provider-utils";
3617
3697
  import { z as z19 } from "zod/v4";
3618
- var webSearchArgsSchema = lazySchema4(
3698
+ var comparisonFilterSchema = z19.object({
3699
+ key: z19.string(),
3700
+ type: z19.enum(["eq", "ne", "gt", "gte", "lt", "lte", "in", "nin"]),
3701
+ value: z19.union([z19.string(), z19.number(), z19.boolean(), z19.array(z19.string())])
3702
+ });
3703
+ var compoundFilterSchema = z19.object({
3704
+ type: z19.enum(["and", "or"]),
3705
+ filters: z19.array(
3706
+ z19.union([comparisonFilterSchema, z19.lazy(() => compoundFilterSchema)])
3707
+ )
3708
+ });
3709
+ var fileSearchArgsSchema = lazySchema4(
3619
3710
  () => zodSchema17(
3620
3711
  z19.object({
3621
- externalWebAccess: z19.boolean().optional(),
3622
- filters: z19.object({
3623
- allowedDomains: z19.array(z19.string()).optional(),
3624
- blockedDomains: z19.array(z19.string()).optional()
3712
+ vectorStoreIds: z19.array(z19.string()),
3713
+ maxNumResults: z19.number().optional(),
3714
+ ranking: z19.object({
3715
+ ranker: z19.string().optional(),
3716
+ scoreThreshold: z19.number().optional()
3625
3717
  }).optional(),
3626
- searchContextSize: z19.enum(["low", "medium", "high"]).optional(),
3627
- userLocation: z19.object({
3628
- type: z19.literal("approximate"),
3629
- country: z19.string().optional(),
3630
- city: z19.string().optional(),
3631
- region: z19.string().optional(),
3632
- timezone: z19.string().optional()
3633
- }).optional()
3718
+ filters: z19.union([comparisonFilterSchema, compoundFilterSchema]).optional()
3634
3719
  })
3635
3720
  )
3636
3721
  );
3637
- var webSearchInputSchema = lazySchema4(() => zodSchema17(z19.object({})));
3638
- var webSearchOutputSchema = lazySchema4(
3722
+ var fileSearchOutputSchema = lazySchema4(
3639
3723
  () => zodSchema17(
3640
3724
  z19.object({
3641
- action: z19.discriminatedUnion("type", [
3642
- z19.object({
3643
- type: z19.literal("search"),
3644
- query: z19.string().optional()
3645
- }),
3646
- z19.object({
3647
- type: z19.literal("openPage"),
3648
- url: z19.string().nullish()
3649
- }),
3725
+ queries: z19.array(z19.string()),
3726
+ results: z19.array(
3650
3727
  z19.object({
3651
- type: z19.literal("findInPage"),
3652
- url: z19.string().nullish(),
3653
- pattern: z19.string().nullish()
3728
+ attributes: z19.record(z19.string(), z19.unknown()),
3729
+ fileId: z19.string(),
3730
+ filename: z19.string(),
3731
+ score: z19.number(),
3732
+ text: z19.string()
3654
3733
  })
3655
- ]).optional(),
3656
- sources: z19.array(
3657
- z19.discriminatedUnion("type", [
3658
- z19.object({ type: z19.literal("url"), url: z19.string() }),
3659
- z19.object({ type: z19.literal("api"), name: z19.string() })
3660
- ])
3661
- ).optional()
3734
+ ).nullable()
3662
3735
  })
3663
3736
  )
3664
3737
  );
3665
- var webSearchToolFactory = createProviderDefinedToolFactoryWithOutputSchema4({
3666
- id: "openai.web_search",
3667
- name: "web_search",
3668
- inputSchema: webSearchInputSchema,
3669
- outputSchema: webSearchOutputSchema
3738
+ var fileSearch = createProviderDefinedToolFactoryWithOutputSchema4({
3739
+ id: "openai.file_search",
3740
+ name: "file_search",
3741
+ inputSchema: z19.object({}),
3742
+ outputSchema: fileSearchOutputSchema
3670
3743
  });
3671
- var webSearch = (args = {}) => webSearchToolFactory(args);
3672
3744
 
3673
3745
  // src/tool/web-search-preview.ts
3674
3746
  import {
@@ -4013,6 +4085,9 @@ var OpenAIResponsesLanguageModel = class {
4013
4085
  modelCapabilities,
4014
4086
  options: openaiOptions
4015
4087
  });
4088
+ const webSearchToolName = (_a2 = tools == null ? void 0 : tools.find(
4089
+ (tool) => tool.type === "provider-defined" && (tool.id === "openai.web_search" || tool.id === "openai.web_search_preview")
4090
+ )) == null ? void 0 : _a2.name;
4016
4091
  const { input, warnings: inputWarnings } = await convertToOpenAIResponsesInput({
4017
4092
  prompt,
4018
4093
  configurationUpdateUnsupportedReason,
@@ -4020,8 +4095,10 @@ var OpenAIResponsesLanguageModel = class {
4020
4095
  systemMessageMode: modelCapabilities.systemMessageMode,
4021
4096
  explicitMessageItemType: this.config.explicitMessageItemType,
4022
4097
  fileIdPrefixes: this.config.fileIdPrefixes,
4023
- store: (_a2 = openaiOptions == null ? void 0 : openaiOptions.store) != null ? _a2 : true,
4024
- hasLocalShellTool: hasOpenAITool("openai.local_shell")
4098
+ store: (_b = openaiOptions == null ? void 0 : openaiOptions.store) != null ? _b : true,
4099
+ isReasoningModel: modelCapabilities.isReasoningModel,
4100
+ hasLocalShellTool: hasOpenAITool("openai.local_shell"),
4101
+ webSearchToolName
4025
4102
  });
4026
4103
  warnings.push(...inputWarnings);
4027
4104
  let resolvedReasoningEffort = openaiOptions == null ? void 0 : openaiOptions.reasoningEffort;
@@ -4058,7 +4135,7 @@ var OpenAIResponsesLanguageModel = class {
4058
4135
  });
4059
4136
  }
4060
4137
  }
4061
- const strictJsonSchema = (_b = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _b : false;
4138
+ const strictJsonSchema = (_c = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _c : false;
4062
4139
  let include = openaiOptions == null ? void 0 : openaiOptions.include;
4063
4140
  function addInclude(key) {
4064
4141
  if (include == null) {
@@ -4076,9 +4153,6 @@ var OpenAIResponsesLanguageModel = class {
4076
4153
  if (topLogprobs) {
4077
4154
  addInclude("message.output_text.logprobs");
4078
4155
  }
4079
- const webSearchToolName = (_c = tools == null ? void 0 : tools.find(
4080
- (tool) => tool.type === "provider-defined" && (tool.id === "openai.web_search" || tool.id === "openai.web_search_preview")
4081
- )) == null ? void 0 : _c.name;
4082
4156
  if (webSearchToolName) {
4083
4157
  addInclude("web_search_call.action.sources");
4084
4158
  }