@ai-sdk/openai 3.0.0-beta.27 → 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.
- package/CHANGELOG.md +6 -0
- package/dist/index.d.mts +64 -3
- package/dist/index.d.ts +64 -3
- package/dist/index.js +50 -63
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +52 -65
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +48 -59
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +52 -63
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/internal/index.mjs
CHANGED
|
@@ -2544,11 +2544,7 @@ var openaiResponsesChunkSchema = lazySchema12(
|
|
|
2544
2544
|
z14.object({
|
|
2545
2545
|
type: z14.literal("web_search_call"),
|
|
2546
2546
|
id: z14.string(),
|
|
2547
|
-
status: z14.string()
|
|
2548
|
-
action: z14.object({
|
|
2549
|
-
type: z14.literal("search"),
|
|
2550
|
-
query: z14.string().optional()
|
|
2551
|
-
}).nullish()
|
|
2547
|
+
status: z14.string()
|
|
2552
2548
|
}),
|
|
2553
2549
|
z14.object({
|
|
2554
2550
|
type: z14.literal("computer_call"),
|
|
@@ -2634,7 +2630,7 @@ var openaiResponsesChunkSchema = lazySchema12(
|
|
|
2634
2630
|
url: z14.string(),
|
|
2635
2631
|
pattern: z14.string()
|
|
2636
2632
|
})
|
|
2637
|
-
])
|
|
2633
|
+
])
|
|
2638
2634
|
}),
|
|
2639
2635
|
z14.object({
|
|
2640
2636
|
type: z14.literal("file_search_call"),
|
|
@@ -2815,7 +2811,7 @@ var openaiResponsesResponseSchema = lazySchema12(
|
|
|
2815
2811
|
url: z14.string(),
|
|
2816
2812
|
pattern: z14.string()
|
|
2817
2813
|
})
|
|
2818
|
-
])
|
|
2814
|
+
])
|
|
2819
2815
|
}),
|
|
2820
2816
|
z14.object({
|
|
2821
2817
|
type: z14.literal("file_search_call"),
|
|
@@ -3116,7 +3112,7 @@ var fileSearch = createProviderDefinedToolFactoryWithOutputSchema3({
|
|
|
3116
3112
|
|
|
3117
3113
|
// src/tool/web-search.ts
|
|
3118
3114
|
import {
|
|
3119
|
-
|
|
3115
|
+
createProviderDefinedToolFactoryWithOutputSchema as createProviderDefinedToolFactoryWithOutputSchema4,
|
|
3120
3116
|
lazySchema as lazySchema16,
|
|
3121
3117
|
zodSchema as zodSchema16
|
|
3122
3118
|
} from "@ai-sdk/provider-utils";
|
|
@@ -3124,9 +3120,7 @@ import { z as z18 } from "zod/v4";
|
|
|
3124
3120
|
var webSearchArgsSchema = lazySchema16(
|
|
3125
3121
|
() => zodSchema16(
|
|
3126
3122
|
z18.object({
|
|
3127
|
-
filters: z18.object({
|
|
3128
|
-
allowedDomains: z18.array(z18.string()).optional()
|
|
3129
|
-
}).optional(),
|
|
3123
|
+
filters: z18.object({ allowedDomains: z18.array(z18.string()).optional() }).optional(),
|
|
3130
3124
|
searchContextSize: z18.enum(["low", "medium", "high"]).optional(),
|
|
3131
3125
|
userLocation: z18.object({
|
|
3132
3126
|
type: z18.literal("approximate"),
|
|
@@ -3138,16 +3132,17 @@ var webSearchArgsSchema = lazySchema16(
|
|
|
3138
3132
|
})
|
|
3139
3133
|
)
|
|
3140
3134
|
);
|
|
3141
|
-
var webSearchInputSchema = lazySchema16(
|
|
3135
|
+
var webSearchInputSchema = lazySchema16(() => zodSchema16(z18.object({})));
|
|
3136
|
+
var webSearchOutputSchema = lazySchema16(
|
|
3142
3137
|
() => zodSchema16(
|
|
3143
3138
|
z18.object({
|
|
3144
3139
|
action: z18.discriminatedUnion("type", [
|
|
3145
3140
|
z18.object({
|
|
3146
3141
|
type: z18.literal("search"),
|
|
3147
|
-
query: z18.string().
|
|
3142
|
+
query: z18.string().optional()
|
|
3148
3143
|
}),
|
|
3149
3144
|
z18.object({
|
|
3150
|
-
type: z18.literal("
|
|
3145
|
+
type: z18.literal("openPage"),
|
|
3151
3146
|
url: z18.string()
|
|
3152
3147
|
}),
|
|
3153
3148
|
z18.object({
|
|
@@ -3155,19 +3150,20 @@ var webSearchInputSchema = lazySchema16(
|
|
|
3155
3150
|
url: z18.string(),
|
|
3156
3151
|
pattern: z18.string()
|
|
3157
3152
|
})
|
|
3158
|
-
])
|
|
3153
|
+
])
|
|
3159
3154
|
})
|
|
3160
3155
|
)
|
|
3161
3156
|
);
|
|
3162
|
-
var webSearchToolFactory =
|
|
3157
|
+
var webSearchToolFactory = createProviderDefinedToolFactoryWithOutputSchema4({
|
|
3163
3158
|
id: "openai.web_search",
|
|
3164
3159
|
name: "web_search",
|
|
3165
|
-
inputSchema: webSearchInputSchema
|
|
3160
|
+
inputSchema: webSearchInputSchema,
|
|
3161
|
+
outputSchema: webSearchOutputSchema
|
|
3166
3162
|
});
|
|
3167
3163
|
|
|
3168
3164
|
// src/tool/web-search-preview.ts
|
|
3169
3165
|
import {
|
|
3170
|
-
|
|
3166
|
+
createProviderDefinedToolFactoryWithOutputSchema as createProviderDefinedToolFactoryWithOutputSchema5,
|
|
3171
3167
|
lazySchema as lazySchema17,
|
|
3172
3168
|
zodSchema as zodSchema17
|
|
3173
3169
|
} from "@ai-sdk/provider-utils";
|
|
@@ -3175,51 +3171,30 @@ import { z as z19 } from "zod/v4";
|
|
|
3175
3171
|
var webSearchPreviewArgsSchema = lazySchema17(
|
|
3176
3172
|
() => zodSchema17(
|
|
3177
3173
|
z19.object({
|
|
3178
|
-
/**
|
|
3179
|
-
* Search context size to use for the web search.
|
|
3180
|
-
* - high: Most comprehensive context, highest cost, slower response
|
|
3181
|
-
* - medium: Balanced context, cost, and latency (default)
|
|
3182
|
-
* - low: Least context, lowest cost, fastest response
|
|
3183
|
-
*/
|
|
3184
3174
|
searchContextSize: z19.enum(["low", "medium", "high"]).optional(),
|
|
3185
|
-
/**
|
|
3186
|
-
* User location information to provide geographically relevant search results.
|
|
3187
|
-
*/
|
|
3188
3175
|
userLocation: z19.object({
|
|
3189
|
-
/**
|
|
3190
|
-
* Type of location (always 'approximate')
|
|
3191
|
-
*/
|
|
3192
3176
|
type: z19.literal("approximate"),
|
|
3193
|
-
/**
|
|
3194
|
-
* Two-letter ISO country code (e.g., 'US', 'GB')
|
|
3195
|
-
*/
|
|
3196
3177
|
country: z19.string().optional(),
|
|
3197
|
-
/**
|
|
3198
|
-
* City name (free text, e.g., 'Minneapolis')
|
|
3199
|
-
*/
|
|
3200
3178
|
city: z19.string().optional(),
|
|
3201
|
-
/**
|
|
3202
|
-
* Region name (free text, e.g., 'Minnesota')
|
|
3203
|
-
*/
|
|
3204
3179
|
region: z19.string().optional(),
|
|
3205
|
-
/**
|
|
3206
|
-
* IANA timezone (e.g., 'America/Chicago')
|
|
3207
|
-
*/
|
|
3208
3180
|
timezone: z19.string().optional()
|
|
3209
3181
|
}).optional()
|
|
3210
3182
|
})
|
|
3211
3183
|
)
|
|
3212
3184
|
);
|
|
3213
3185
|
var webSearchPreviewInputSchema = lazySchema17(
|
|
3186
|
+
() => zodSchema17(z19.object({}))
|
|
3187
|
+
);
|
|
3188
|
+
var webSearchPreviewOutputSchema = lazySchema17(
|
|
3214
3189
|
() => zodSchema17(
|
|
3215
3190
|
z19.object({
|
|
3216
3191
|
action: z19.discriminatedUnion("type", [
|
|
3217
3192
|
z19.object({
|
|
3218
3193
|
type: z19.literal("search"),
|
|
3219
|
-
query: z19.string().
|
|
3194
|
+
query: z19.string().optional()
|
|
3220
3195
|
}),
|
|
3221
3196
|
z19.object({
|
|
3222
|
-
type: z19.literal("
|
|
3197
|
+
type: z19.literal("openPage"),
|
|
3223
3198
|
url: z19.string()
|
|
3224
3199
|
}),
|
|
3225
3200
|
z19.object({
|
|
@@ -3227,19 +3202,20 @@ var webSearchPreviewInputSchema = lazySchema17(
|
|
|
3227
3202
|
url: z19.string(),
|
|
3228
3203
|
pattern: z19.string()
|
|
3229
3204
|
})
|
|
3230
|
-
])
|
|
3205
|
+
])
|
|
3231
3206
|
})
|
|
3232
3207
|
)
|
|
3233
3208
|
);
|
|
3234
|
-
var webSearchPreview =
|
|
3209
|
+
var webSearchPreview = createProviderDefinedToolFactoryWithOutputSchema5({
|
|
3235
3210
|
id: "openai.web_search_preview",
|
|
3236
3211
|
name: "web_search_preview",
|
|
3237
|
-
inputSchema: webSearchPreviewInputSchema
|
|
3212
|
+
inputSchema: webSearchPreviewInputSchema,
|
|
3213
|
+
outputSchema: webSearchPreviewOutputSchema
|
|
3238
3214
|
});
|
|
3239
3215
|
|
|
3240
3216
|
// src/tool/image-generation.ts
|
|
3241
3217
|
import {
|
|
3242
|
-
createProviderDefinedToolFactoryWithOutputSchema as
|
|
3218
|
+
createProviderDefinedToolFactoryWithOutputSchema as createProviderDefinedToolFactoryWithOutputSchema6,
|
|
3243
3219
|
lazySchema as lazySchema18,
|
|
3244
3220
|
zodSchema as zodSchema18
|
|
3245
3221
|
} from "@ai-sdk/provider-utils";
|
|
@@ -3267,7 +3243,7 @@ var imageGenerationInputSchema = lazySchema18(() => zodSchema18(z20.object({})))
|
|
|
3267
3243
|
var imageGenerationOutputSchema = lazySchema18(
|
|
3268
3244
|
() => zodSchema18(z20.object({ result: z20.string() }))
|
|
3269
3245
|
);
|
|
3270
|
-
var imageGenerationToolFactory =
|
|
3246
|
+
var imageGenerationToolFactory = createProviderDefinedToolFactoryWithOutputSchema6({
|
|
3271
3247
|
id: "openai.image_generation",
|
|
3272
3248
|
name: "image_generation",
|
|
3273
3249
|
inputSchema: imageGenerationInputSchema,
|
|
@@ -3784,14 +3760,14 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3784
3760
|
type: "tool-call",
|
|
3785
3761
|
toolCallId: part.id,
|
|
3786
3762
|
toolName: webSearchToolName != null ? webSearchToolName : "web_search",
|
|
3787
|
-
input: JSON.stringify({
|
|
3763
|
+
input: JSON.stringify({}),
|
|
3788
3764
|
providerExecuted: true
|
|
3789
3765
|
});
|
|
3790
3766
|
content.push({
|
|
3791
3767
|
type: "tool-result",
|
|
3792
3768
|
toolCallId: part.id,
|
|
3793
3769
|
toolName: webSearchToolName != null ? webSearchToolName : "web_search",
|
|
3794
|
-
result:
|
|
3770
|
+
result: mapWebSearchOutput(part.action),
|
|
3795
3771
|
providerExecuted: true
|
|
3796
3772
|
});
|
|
3797
3773
|
break;
|
|
@@ -3975,6 +3951,17 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3975
3951
|
toolName: webSearchToolName != null ? webSearchToolName : "web_search",
|
|
3976
3952
|
providerExecuted: true
|
|
3977
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
|
+
});
|
|
3978
3965
|
} else if (value.item.type === "computer_call") {
|
|
3979
3966
|
ongoingToolCalls[value.output_index] = {
|
|
3980
3967
|
toolName: "computer_use",
|
|
@@ -4068,22 +4055,11 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4068
4055
|
});
|
|
4069
4056
|
} else if (value.item.type === "web_search_call") {
|
|
4070
4057
|
ongoingToolCalls[value.output_index] = void 0;
|
|
4071
|
-
controller.enqueue({
|
|
4072
|
-
type: "tool-input-end",
|
|
4073
|
-
id: value.item.id
|
|
4074
|
-
});
|
|
4075
|
-
controller.enqueue({
|
|
4076
|
-
type: "tool-call",
|
|
4077
|
-
toolCallId: value.item.id,
|
|
4078
|
-
toolName: "web_search",
|
|
4079
|
-
input: JSON.stringify({ action: value.item.action }),
|
|
4080
|
-
providerExecuted: true
|
|
4081
|
-
});
|
|
4082
4058
|
controller.enqueue({
|
|
4083
4059
|
type: "tool-result",
|
|
4084
4060
|
toolCallId: value.item.id,
|
|
4085
4061
|
toolName: "web_search",
|
|
4086
|
-
result:
|
|
4062
|
+
result: mapWebSearchOutput(value.item.action),
|
|
4087
4063
|
providerExecuted: true
|
|
4088
4064
|
});
|
|
4089
4065
|
} else if (value.item.type === "computer_call") {
|
|
@@ -4428,6 +4404,19 @@ function getResponsesModelConfig(modelId) {
|
|
|
4428
4404
|
isReasoningModel: false
|
|
4429
4405
|
};
|
|
4430
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
|
+
}
|
|
4431
4420
|
export {
|
|
4432
4421
|
OpenAIChatLanguageModel,
|
|
4433
4422
|
OpenAICompletionLanguageModel,
|