@ai-sdk/openai 2.0.49 → 2.0.51
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 +12 -0
- package/dist/index.d.mts +64 -3
- package/dist/index.d.ts +64 -3
- package/dist/index.js +64 -67
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +66 -69
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +62 -63
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +66 -67
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/internal/index.mjs
CHANGED
|
@@ -2207,7 +2207,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
2207
2207
|
store,
|
|
2208
2208
|
hasLocalShellTool = false
|
|
2209
2209
|
}) {
|
|
2210
|
-
var _a, _b, _c, _d
|
|
2210
|
+
var _a, _b, _c, _d;
|
|
2211
2211
|
const input = [];
|
|
2212
2212
|
const warnings = [];
|
|
2213
2213
|
for (const { role, content } of prompt) {
|
|
@@ -2288,10 +2288,15 @@ async function convertToOpenAIResponsesInput({
|
|
|
2288
2288
|
for (const part of content) {
|
|
2289
2289
|
switch (part.type) {
|
|
2290
2290
|
case "text": {
|
|
2291
|
+
const id = (_b = (_a = part.providerOptions) == null ? void 0 : _a.openai) == null ? void 0 : _b.itemId;
|
|
2292
|
+
if (store && id != null) {
|
|
2293
|
+
input.push({ type: "item_reference", id });
|
|
2294
|
+
break;
|
|
2295
|
+
}
|
|
2291
2296
|
input.push({
|
|
2292
2297
|
role: "assistant",
|
|
2293
2298
|
content: [{ type: "output_text", text: part.text }],
|
|
2294
|
-
id
|
|
2299
|
+
id
|
|
2295
2300
|
});
|
|
2296
2301
|
break;
|
|
2297
2302
|
}
|
|
@@ -2300,6 +2305,11 @@ async function convertToOpenAIResponsesInput({
|
|
|
2300
2305
|
if (part.providerExecuted) {
|
|
2301
2306
|
break;
|
|
2302
2307
|
}
|
|
2308
|
+
const id = (_d = (_c = part.providerOptions) == null ? void 0 : _c.openai) == null ? void 0 : _d.itemId;
|
|
2309
|
+
if (store && id != null) {
|
|
2310
|
+
input.push({ type: "item_reference", id });
|
|
2311
|
+
break;
|
|
2312
|
+
}
|
|
2303
2313
|
if (hasLocalShellTool && part.toolName === "local_shell") {
|
|
2304
2314
|
const parsedInput = await validateTypes({
|
|
2305
2315
|
value: part.input,
|
|
@@ -2308,7 +2318,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
2308
2318
|
input.push({
|
|
2309
2319
|
type: "local_shell_call",
|
|
2310
2320
|
call_id: part.toolCallId,
|
|
2311
|
-
id
|
|
2321
|
+
id,
|
|
2312
2322
|
action: {
|
|
2313
2323
|
type: "exec",
|
|
2314
2324
|
command: parsedInput.action.command,
|
|
@@ -2325,7 +2335,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
2325
2335
|
call_id: part.toolCallId,
|
|
2326
2336
|
name: part.toolName,
|
|
2327
2337
|
arguments: JSON.stringify(part.input),
|
|
2328
|
-
id
|
|
2338
|
+
id
|
|
2329
2339
|
});
|
|
2330
2340
|
break;
|
|
2331
2341
|
}
|
|
@@ -2551,11 +2561,7 @@ var openaiResponsesChunkSchema = lazyValidator11(
|
|
|
2551
2561
|
z14.object({
|
|
2552
2562
|
type: z14.literal("web_search_call"),
|
|
2553
2563
|
id: z14.string(),
|
|
2554
|
-
status: z14.string()
|
|
2555
|
-
action: z14.object({
|
|
2556
|
-
type: z14.literal("search"),
|
|
2557
|
-
query: z14.string().optional()
|
|
2558
|
-
}).nullish()
|
|
2564
|
+
status: z14.string()
|
|
2559
2565
|
}),
|
|
2560
2566
|
z14.object({
|
|
2561
2567
|
type: z14.literal("computer_call"),
|
|
@@ -2641,7 +2647,7 @@ var openaiResponsesChunkSchema = lazyValidator11(
|
|
|
2641
2647
|
url: z14.string(),
|
|
2642
2648
|
pattern: z14.string()
|
|
2643
2649
|
})
|
|
2644
|
-
])
|
|
2650
|
+
])
|
|
2645
2651
|
}),
|
|
2646
2652
|
z14.object({
|
|
2647
2653
|
type: z14.literal("file_search_call"),
|
|
@@ -2822,7 +2828,7 @@ var openaiResponsesResponseSchema = lazyValidator11(
|
|
|
2822
2828
|
url: z14.string(),
|
|
2823
2829
|
pattern: z14.string()
|
|
2824
2830
|
})
|
|
2825
|
-
])
|
|
2831
|
+
])
|
|
2826
2832
|
}),
|
|
2827
2833
|
z14.object({
|
|
2828
2834
|
type: z14.literal("file_search_call"),
|
|
@@ -3126,7 +3132,7 @@ var fileSearch = createProviderDefinedToolFactoryWithOutputSchema3({
|
|
|
3126
3132
|
|
|
3127
3133
|
// src/tool/web-search.ts
|
|
3128
3134
|
import {
|
|
3129
|
-
|
|
3135
|
+
createProviderDefinedToolFactoryWithOutputSchema as createProviderDefinedToolFactoryWithOutputSchema4,
|
|
3130
3136
|
lazySchema as lazySchema4,
|
|
3131
3137
|
zodSchema as zodSchema16
|
|
3132
3138
|
} from "@ai-sdk/provider-utils";
|
|
@@ -3134,9 +3140,7 @@ import { z as z18 } from "zod/v4";
|
|
|
3134
3140
|
var webSearchArgsSchema = lazySchema4(
|
|
3135
3141
|
() => zodSchema16(
|
|
3136
3142
|
z18.object({
|
|
3137
|
-
filters: z18.object({
|
|
3138
|
-
allowedDomains: z18.array(z18.string()).optional()
|
|
3139
|
-
}).optional(),
|
|
3143
|
+
filters: z18.object({ allowedDomains: z18.array(z18.string()).optional() }).optional(),
|
|
3140
3144
|
searchContextSize: z18.enum(["low", "medium", "high"]).optional(),
|
|
3141
3145
|
userLocation: z18.object({
|
|
3142
3146
|
type: z18.literal("approximate"),
|
|
@@ -3148,16 +3152,17 @@ var webSearchArgsSchema = lazySchema4(
|
|
|
3148
3152
|
})
|
|
3149
3153
|
)
|
|
3150
3154
|
);
|
|
3151
|
-
var webSearchInputSchema = lazySchema4(
|
|
3155
|
+
var webSearchInputSchema = lazySchema4(() => zodSchema16(z18.object({})));
|
|
3156
|
+
var webSearchOutputSchema = lazySchema4(
|
|
3152
3157
|
() => zodSchema16(
|
|
3153
3158
|
z18.object({
|
|
3154
3159
|
action: z18.discriminatedUnion("type", [
|
|
3155
3160
|
z18.object({
|
|
3156
3161
|
type: z18.literal("search"),
|
|
3157
|
-
query: z18.string().
|
|
3162
|
+
query: z18.string().optional()
|
|
3158
3163
|
}),
|
|
3159
3164
|
z18.object({
|
|
3160
|
-
type: z18.literal("
|
|
3165
|
+
type: z18.literal("openPage"),
|
|
3161
3166
|
url: z18.string()
|
|
3162
3167
|
}),
|
|
3163
3168
|
z18.object({
|
|
@@ -3165,19 +3170,20 @@ var webSearchInputSchema = lazySchema4(
|
|
|
3165
3170
|
url: z18.string(),
|
|
3166
3171
|
pattern: z18.string()
|
|
3167
3172
|
})
|
|
3168
|
-
])
|
|
3173
|
+
])
|
|
3169
3174
|
})
|
|
3170
3175
|
)
|
|
3171
3176
|
);
|
|
3172
|
-
var webSearchToolFactory =
|
|
3177
|
+
var webSearchToolFactory = createProviderDefinedToolFactoryWithOutputSchema4({
|
|
3173
3178
|
id: "openai.web_search",
|
|
3174
3179
|
name: "web_search",
|
|
3175
|
-
inputSchema: webSearchInputSchema
|
|
3180
|
+
inputSchema: webSearchInputSchema,
|
|
3181
|
+
outputSchema: webSearchOutputSchema
|
|
3176
3182
|
});
|
|
3177
3183
|
|
|
3178
3184
|
// src/tool/web-search-preview.ts
|
|
3179
3185
|
import {
|
|
3180
|
-
|
|
3186
|
+
createProviderDefinedToolFactoryWithOutputSchema as createProviderDefinedToolFactoryWithOutputSchema5,
|
|
3181
3187
|
lazySchema as lazySchema5,
|
|
3182
3188
|
zodSchema as zodSchema17
|
|
3183
3189
|
} from "@ai-sdk/provider-utils";
|
|
@@ -3185,51 +3191,30 @@ import { z as z19 } from "zod/v4";
|
|
|
3185
3191
|
var webSearchPreviewArgsSchema = lazySchema5(
|
|
3186
3192
|
() => zodSchema17(
|
|
3187
3193
|
z19.object({
|
|
3188
|
-
/**
|
|
3189
|
-
* Search context size to use for the web search.
|
|
3190
|
-
* - high: Most comprehensive context, highest cost, slower response
|
|
3191
|
-
* - medium: Balanced context, cost, and latency (default)
|
|
3192
|
-
* - low: Least context, lowest cost, fastest response
|
|
3193
|
-
*/
|
|
3194
3194
|
searchContextSize: z19.enum(["low", "medium", "high"]).optional(),
|
|
3195
|
-
/**
|
|
3196
|
-
* User location information to provide geographically relevant search results.
|
|
3197
|
-
*/
|
|
3198
3195
|
userLocation: z19.object({
|
|
3199
|
-
/**
|
|
3200
|
-
* Type of location (always 'approximate')
|
|
3201
|
-
*/
|
|
3202
3196
|
type: z19.literal("approximate"),
|
|
3203
|
-
/**
|
|
3204
|
-
* Two-letter ISO country code (e.g., 'US', 'GB')
|
|
3205
|
-
*/
|
|
3206
3197
|
country: z19.string().optional(),
|
|
3207
|
-
/**
|
|
3208
|
-
* City name (free text, e.g., 'Minneapolis')
|
|
3209
|
-
*/
|
|
3210
3198
|
city: z19.string().optional(),
|
|
3211
|
-
/**
|
|
3212
|
-
* Region name (free text, e.g., 'Minnesota')
|
|
3213
|
-
*/
|
|
3214
3199
|
region: z19.string().optional(),
|
|
3215
|
-
/**
|
|
3216
|
-
* IANA timezone (e.g., 'America/Chicago')
|
|
3217
|
-
*/
|
|
3218
3200
|
timezone: z19.string().optional()
|
|
3219
3201
|
}).optional()
|
|
3220
3202
|
})
|
|
3221
3203
|
)
|
|
3222
3204
|
);
|
|
3223
3205
|
var webSearchPreviewInputSchema = lazySchema5(
|
|
3206
|
+
() => zodSchema17(z19.object({}))
|
|
3207
|
+
);
|
|
3208
|
+
var webSearchPreviewOutputSchema = lazySchema5(
|
|
3224
3209
|
() => zodSchema17(
|
|
3225
3210
|
z19.object({
|
|
3226
3211
|
action: z19.discriminatedUnion("type", [
|
|
3227
3212
|
z19.object({
|
|
3228
3213
|
type: z19.literal("search"),
|
|
3229
|
-
query: z19.string().
|
|
3214
|
+
query: z19.string().optional()
|
|
3230
3215
|
}),
|
|
3231
3216
|
z19.object({
|
|
3232
|
-
type: z19.literal("
|
|
3217
|
+
type: z19.literal("openPage"),
|
|
3233
3218
|
url: z19.string()
|
|
3234
3219
|
}),
|
|
3235
3220
|
z19.object({
|
|
@@ -3237,19 +3222,20 @@ var webSearchPreviewInputSchema = lazySchema5(
|
|
|
3237
3222
|
url: z19.string(),
|
|
3238
3223
|
pattern: z19.string()
|
|
3239
3224
|
})
|
|
3240
|
-
])
|
|
3225
|
+
])
|
|
3241
3226
|
})
|
|
3242
3227
|
)
|
|
3243
3228
|
);
|
|
3244
|
-
var webSearchPreview =
|
|
3229
|
+
var webSearchPreview = createProviderDefinedToolFactoryWithOutputSchema5({
|
|
3245
3230
|
id: "openai.web_search_preview",
|
|
3246
3231
|
name: "web_search_preview",
|
|
3247
|
-
inputSchema: webSearchPreviewInputSchema
|
|
3232
|
+
inputSchema: webSearchPreviewInputSchema,
|
|
3233
|
+
outputSchema: webSearchPreviewOutputSchema
|
|
3248
3234
|
});
|
|
3249
3235
|
|
|
3250
3236
|
// src/tool/image-generation.ts
|
|
3251
3237
|
import {
|
|
3252
|
-
createProviderDefinedToolFactoryWithOutputSchema as
|
|
3238
|
+
createProviderDefinedToolFactoryWithOutputSchema as createProviderDefinedToolFactoryWithOutputSchema6,
|
|
3253
3239
|
lazySchema as lazySchema6,
|
|
3254
3240
|
zodSchema as zodSchema18
|
|
3255
3241
|
} from "@ai-sdk/provider-utils";
|
|
@@ -3277,7 +3263,7 @@ var imageGenerationInputSchema = lazySchema6(() => zodSchema18(z20.object({})));
|
|
|
3277
3263
|
var imageGenerationOutputSchema = lazySchema6(
|
|
3278
3264
|
() => zodSchema18(z20.object({ result: z20.string() }))
|
|
3279
3265
|
);
|
|
3280
|
-
var imageGenerationToolFactory =
|
|
3266
|
+
var imageGenerationToolFactory = createProviderDefinedToolFactoryWithOutputSchema6({
|
|
3281
3267
|
id: "openai.image_generation",
|
|
3282
3268
|
name: "image_generation",
|
|
3283
3269
|
inputSchema: imageGenerationInputSchema,
|
|
@@ -3793,14 +3779,14 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3793
3779
|
type: "tool-call",
|
|
3794
3780
|
toolCallId: part.id,
|
|
3795
3781
|
toolName: webSearchToolName != null ? webSearchToolName : "web_search",
|
|
3796
|
-
input: JSON.stringify({
|
|
3782
|
+
input: JSON.stringify({}),
|
|
3797
3783
|
providerExecuted: true
|
|
3798
3784
|
});
|
|
3799
3785
|
content.push({
|
|
3800
3786
|
type: "tool-result",
|
|
3801
3787
|
toolCallId: part.id,
|
|
3802
3788
|
toolName: webSearchToolName != null ? webSearchToolName : "web_search",
|
|
3803
|
-
result:
|
|
3789
|
+
result: mapWebSearchOutput(part.action),
|
|
3804
3790
|
providerExecuted: true
|
|
3805
3791
|
});
|
|
3806
3792
|
break;
|
|
@@ -3984,6 +3970,17 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3984
3970
|
toolName: webSearchToolName != null ? webSearchToolName : "web_search",
|
|
3985
3971
|
providerExecuted: true
|
|
3986
3972
|
});
|
|
3973
|
+
controller.enqueue({
|
|
3974
|
+
type: "tool-input-end",
|
|
3975
|
+
id: value.item.id
|
|
3976
|
+
});
|
|
3977
|
+
controller.enqueue({
|
|
3978
|
+
type: "tool-call",
|
|
3979
|
+
toolCallId: value.item.id,
|
|
3980
|
+
toolName: "web_search",
|
|
3981
|
+
input: JSON.stringify({}),
|
|
3982
|
+
providerExecuted: true
|
|
3983
|
+
});
|
|
3987
3984
|
} else if (value.item.type === "computer_call") {
|
|
3988
3985
|
ongoingToolCalls[value.output_index] = {
|
|
3989
3986
|
toolName: "computer_use",
|
|
@@ -4077,22 +4074,11 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4077
4074
|
});
|
|
4078
4075
|
} else if (value.item.type === "web_search_call") {
|
|
4079
4076
|
ongoingToolCalls[value.output_index] = void 0;
|
|
4080
|
-
controller.enqueue({
|
|
4081
|
-
type: "tool-input-end",
|
|
4082
|
-
id: value.item.id
|
|
4083
|
-
});
|
|
4084
|
-
controller.enqueue({
|
|
4085
|
-
type: "tool-call",
|
|
4086
|
-
toolCallId: value.item.id,
|
|
4087
|
-
toolName: "web_search",
|
|
4088
|
-
input: JSON.stringify({ action: value.item.action }),
|
|
4089
|
-
providerExecuted: true
|
|
4090
|
-
});
|
|
4091
4077
|
controller.enqueue({
|
|
4092
4078
|
type: "tool-result",
|
|
4093
4079
|
toolCallId: value.item.id,
|
|
4094
4080
|
toolName: "web_search",
|
|
4095
|
-
result:
|
|
4081
|
+
result: mapWebSearchOutput(value.item.action),
|
|
4096
4082
|
providerExecuted: true
|
|
4097
4083
|
});
|
|
4098
4084
|
} else if (value.item.type === "computer_call") {
|
|
@@ -4423,6 +4409,19 @@ function getResponsesModelConfig(modelId) {
|
|
|
4423
4409
|
isReasoningModel: false
|
|
4424
4410
|
};
|
|
4425
4411
|
}
|
|
4412
|
+
function mapWebSearchOutput(action) {
|
|
4413
|
+
var _a;
|
|
4414
|
+
switch (action.type) {
|
|
4415
|
+
case "search":
|
|
4416
|
+
return { action: { type: "search", query: (_a = action.query) != null ? _a : void 0 } };
|
|
4417
|
+
case "open_page":
|
|
4418
|
+
return { action: { type: "openPage", url: action.url } };
|
|
4419
|
+
case "find":
|
|
4420
|
+
return {
|
|
4421
|
+
action: { type: "find", url: action.url, pattern: action.pattern }
|
|
4422
|
+
};
|
|
4423
|
+
}
|
|
4424
|
+
}
|
|
4426
4425
|
export {
|
|
4427
4426
|
OpenAIChatLanguageModel,
|
|
4428
4427
|
OpenAICompletionLanguageModel,
|