@ai-sdk/openai 3.0.36 → 3.0.38
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 +14 -0
- package/README.md +1 -1
- package/dist/index.d.mts +53 -3
- package/dist/index.d.ts +53 -3
- package/dist/index.js +1168 -966
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1118 -912
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +20 -2
- package/dist/internal/index.d.ts +20 -2
- package/dist/internal/index.js +349 -158
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +327 -132
- package/dist/internal/index.mjs.map +1 -1
- package/docs/03-openai.mdx +79 -1
- package/package.json +2 -2
- package/src/chat/openai-chat-options.ts +0 -5
- package/src/openai-language-model-capabilities.ts +0 -2
- package/src/openai-tools.ts +13 -1
- package/src/responses/convert-to-openai-responses-input.ts +74 -0
- package/src/responses/openai-responses-api.ts +58 -0
- package/src/responses/openai-responses-language-model.ts +94 -9
- package/src/responses/openai-responses-options.ts +0 -22
- package/src/responses/openai-responses-prepare-tools.ts +41 -11
- package/src/tool/custom.ts +64 -0
package/dist/internal/index.js
CHANGED
|
@@ -83,7 +83,7 @@ var openaiFailedResponseHandler = (0, import_provider_utils.createJsonErrorRespo
|
|
|
83
83
|
function getOpenAILanguageModelCapabilities(modelId) {
|
|
84
84
|
const supportsFlexProcessing = modelId.startsWith("o3") || modelId.startsWith("o4-mini") || modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-chat");
|
|
85
85
|
const supportsPriorityProcessing = modelId.startsWith("gpt-4") || modelId.startsWith("gpt-5-mini") || modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-nano") && !modelId.startsWith("gpt-5-chat") || modelId.startsWith("o3") || modelId.startsWith("o4-mini");
|
|
86
|
-
const isReasoningModel = modelId.startsWith("o1") || modelId.startsWith("o3") || modelId.startsWith("o4-mini") || modelId.startsWith("
|
|
86
|
+
const isReasoningModel = modelId.startsWith("o1") || modelId.startsWith("o3") || modelId.startsWith("o4-mini") || modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-chat");
|
|
87
87
|
const supportsNonReasoningParameters = modelId.startsWith("gpt-5.1") || modelId.startsWith("gpt-5.2");
|
|
88
88
|
const systemMessageMode = isReasoningModel ? "developer" : "system";
|
|
89
89
|
return {
|
|
@@ -2338,7 +2338,7 @@ var OpenAISpeechModel = class {
|
|
|
2338
2338
|
|
|
2339
2339
|
// src/responses/openai-responses-language-model.ts
|
|
2340
2340
|
var import_provider8 = require("@ai-sdk/provider");
|
|
2341
|
-
var
|
|
2341
|
+
var import_provider_utils33 = require("@ai-sdk/provider-utils");
|
|
2342
2342
|
|
|
2343
2343
|
// src/responses/convert-openai-responses-usage.ts
|
|
2344
2344
|
function convertOpenAIResponsesUsage(usage) {
|
|
@@ -2564,9 +2564,10 @@ async function convertToOpenAIResponsesInput({
|
|
|
2564
2564
|
hasConversation = false,
|
|
2565
2565
|
hasLocalShellTool = false,
|
|
2566
2566
|
hasShellTool = false,
|
|
2567
|
-
hasApplyPatchTool = false
|
|
2567
|
+
hasApplyPatchTool = false,
|
|
2568
|
+
customProviderToolNames
|
|
2568
2569
|
}) {
|
|
2569
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
2570
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
2570
2571
|
const input = [];
|
|
2571
2572
|
const warnings = [];
|
|
2572
2573
|
const processedApprovalIds = /* @__PURE__ */ new Set();
|
|
@@ -2735,6 +2736,16 @@ async function convertToOpenAIResponsesInput({
|
|
|
2735
2736
|
});
|
|
2736
2737
|
break;
|
|
2737
2738
|
}
|
|
2739
|
+
if (customProviderToolNames == null ? void 0 : customProviderToolNames.has(resolvedToolName)) {
|
|
2740
|
+
input.push({
|
|
2741
|
+
type: "custom_tool_call",
|
|
2742
|
+
call_id: part.toolCallId,
|
|
2743
|
+
name: resolvedToolName,
|
|
2744
|
+
input: typeof part.input === "string" ? part.input : JSON.stringify(part.input),
|
|
2745
|
+
id
|
|
2746
|
+
});
|
|
2747
|
+
break;
|
|
2748
|
+
}
|
|
2738
2749
|
input.push({
|
|
2739
2750
|
type: "function_call",
|
|
2740
2751
|
call_id: part.toolCallId,
|
|
@@ -2939,6 +2950,61 @@ async function convertToOpenAIResponsesInput({
|
|
|
2939
2950
|
});
|
|
2940
2951
|
continue;
|
|
2941
2952
|
}
|
|
2953
|
+
if (customProviderToolNames == null ? void 0 : customProviderToolNames.has(resolvedToolName)) {
|
|
2954
|
+
let outputValue;
|
|
2955
|
+
switch (output.type) {
|
|
2956
|
+
case "text":
|
|
2957
|
+
case "error-text":
|
|
2958
|
+
outputValue = output.value;
|
|
2959
|
+
break;
|
|
2960
|
+
case "execution-denied":
|
|
2961
|
+
outputValue = (_l = output.reason) != null ? _l : "Tool execution denied.";
|
|
2962
|
+
break;
|
|
2963
|
+
case "json":
|
|
2964
|
+
case "error-json":
|
|
2965
|
+
outputValue = JSON.stringify(output.value);
|
|
2966
|
+
break;
|
|
2967
|
+
case "content":
|
|
2968
|
+
outputValue = output.value.map((item) => {
|
|
2969
|
+
var _a2;
|
|
2970
|
+
switch (item.type) {
|
|
2971
|
+
case "text":
|
|
2972
|
+
return { type: "input_text", text: item.text };
|
|
2973
|
+
case "image-data":
|
|
2974
|
+
return {
|
|
2975
|
+
type: "input_image",
|
|
2976
|
+
image_url: `data:${item.mediaType};base64,${item.data}`
|
|
2977
|
+
};
|
|
2978
|
+
case "image-url":
|
|
2979
|
+
return {
|
|
2980
|
+
type: "input_image",
|
|
2981
|
+
image_url: item.url
|
|
2982
|
+
};
|
|
2983
|
+
case "file-data":
|
|
2984
|
+
return {
|
|
2985
|
+
type: "input_file",
|
|
2986
|
+
filename: (_a2 = item.filename) != null ? _a2 : "data",
|
|
2987
|
+
file_data: `data:${item.mediaType};base64,${item.data}`
|
|
2988
|
+
};
|
|
2989
|
+
default:
|
|
2990
|
+
warnings.push({
|
|
2991
|
+
type: "other",
|
|
2992
|
+
message: `unsupported custom tool content part type: ${item.type}`
|
|
2993
|
+
});
|
|
2994
|
+
return void 0;
|
|
2995
|
+
}
|
|
2996
|
+
}).filter(import_provider_utils22.isNonNullable);
|
|
2997
|
+
break;
|
|
2998
|
+
default:
|
|
2999
|
+
outputValue = "";
|
|
3000
|
+
}
|
|
3001
|
+
input.push({
|
|
3002
|
+
type: "custom_tool_call_output",
|
|
3003
|
+
call_id: part.toolCallId,
|
|
3004
|
+
output: outputValue
|
|
3005
|
+
});
|
|
3006
|
+
continue;
|
|
3007
|
+
}
|
|
2942
3008
|
let contentValue;
|
|
2943
3009
|
switch (output.type) {
|
|
2944
3010
|
case "text":
|
|
@@ -2946,7 +3012,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
2946
3012
|
contentValue = output.value;
|
|
2947
3013
|
break;
|
|
2948
3014
|
case "execution-denied":
|
|
2949
|
-
contentValue = (
|
|
3015
|
+
contentValue = (_m = output.reason) != null ? _m : "Tool execution denied.";
|
|
2950
3016
|
break;
|
|
2951
3017
|
case "json":
|
|
2952
3018
|
case "error-json":
|
|
@@ -3161,6 +3227,13 @@ var openaiResponsesChunkSchema = (0, import_provider_utils23.lazySchema)(
|
|
|
3161
3227
|
})
|
|
3162
3228
|
])
|
|
3163
3229
|
}),
|
|
3230
|
+
import_v416.z.object({
|
|
3231
|
+
type: import_v416.z.literal("custom_tool_call"),
|
|
3232
|
+
id: import_v416.z.string(),
|
|
3233
|
+
call_id: import_v416.z.string(),
|
|
3234
|
+
name: import_v416.z.string(),
|
|
3235
|
+
input: import_v416.z.string()
|
|
3236
|
+
}),
|
|
3164
3237
|
import_v416.z.object({
|
|
3165
3238
|
type: import_v416.z.literal("shell_call"),
|
|
3166
3239
|
id: import_v416.z.string(),
|
|
@@ -3213,6 +3286,14 @@ var openaiResponsesChunkSchema = (0, import_provider_utils23.lazySchema)(
|
|
|
3213
3286
|
arguments: import_v416.z.string(),
|
|
3214
3287
|
status: import_v416.z.literal("completed")
|
|
3215
3288
|
}),
|
|
3289
|
+
import_v416.z.object({
|
|
3290
|
+
type: import_v416.z.literal("custom_tool_call"),
|
|
3291
|
+
id: import_v416.z.string(),
|
|
3292
|
+
call_id: import_v416.z.string(),
|
|
3293
|
+
name: import_v416.z.string(),
|
|
3294
|
+
input: import_v416.z.string(),
|
|
3295
|
+
status: import_v416.z.literal("completed")
|
|
3296
|
+
}),
|
|
3216
3297
|
import_v416.z.object({
|
|
3217
3298
|
type: import_v416.z.literal("code_interpreter_call"),
|
|
3218
3299
|
id: import_v416.z.string(),
|
|
@@ -3396,6 +3477,12 @@ var openaiResponsesChunkSchema = (0, import_provider_utils23.lazySchema)(
|
|
|
3396
3477
|
output_index: import_v416.z.number(),
|
|
3397
3478
|
delta: import_v416.z.string()
|
|
3398
3479
|
}),
|
|
3480
|
+
import_v416.z.object({
|
|
3481
|
+
type: import_v416.z.literal("response.custom_tool_call_input.delta"),
|
|
3482
|
+
item_id: import_v416.z.string(),
|
|
3483
|
+
output_index: import_v416.z.number(),
|
|
3484
|
+
delta: import_v416.z.string()
|
|
3485
|
+
}),
|
|
3399
3486
|
import_v416.z.object({
|
|
3400
3487
|
type: import_v416.z.literal("response.image_generation_call.partial_image"),
|
|
3401
3488
|
item_id: import_v416.z.string(),
|
|
@@ -3643,6 +3730,13 @@ var openaiResponsesResponseSchema = (0, import_provider_utils23.lazySchema)(
|
|
|
3643
3730
|
arguments: import_v416.z.string(),
|
|
3644
3731
|
id: import_v416.z.string()
|
|
3645
3732
|
}),
|
|
3733
|
+
import_v416.z.object({
|
|
3734
|
+
type: import_v416.z.literal("custom_tool_call"),
|
|
3735
|
+
call_id: import_v416.z.string(),
|
|
3736
|
+
name: import_v416.z.string(),
|
|
3737
|
+
input: import_v416.z.string(),
|
|
3738
|
+
id: import_v416.z.string()
|
|
3739
|
+
}),
|
|
3646
3740
|
import_v416.z.object({
|
|
3647
3741
|
type: import_v416.z.literal("computer_call"),
|
|
3648
3742
|
id: import_v416.z.string(),
|
|
@@ -3779,16 +3873,10 @@ var openaiResponsesReasoningModelIds = [
|
|
|
3779
3873
|
"o1-2024-12-17",
|
|
3780
3874
|
"o3",
|
|
3781
3875
|
"o3-2025-04-16",
|
|
3782
|
-
"o3-deep-research",
|
|
3783
|
-
"o3-deep-research-2025-06-26",
|
|
3784
3876
|
"o3-mini",
|
|
3785
3877
|
"o3-mini-2025-01-31",
|
|
3786
3878
|
"o4-mini",
|
|
3787
3879
|
"o4-mini-2025-04-16",
|
|
3788
|
-
"o4-mini-deep-research",
|
|
3789
|
-
"o4-mini-deep-research-2025-06-26",
|
|
3790
|
-
"codex-mini-latest",
|
|
3791
|
-
"computer-use-preview",
|
|
3792
3880
|
"gpt-5",
|
|
3793
3881
|
"gpt-5-2025-08-07",
|
|
3794
3882
|
"gpt-5-codex",
|
|
@@ -3821,7 +3909,6 @@ var openaiResponsesModelIds = [
|
|
|
3821
3909
|
"gpt-4o-2024-08-06",
|
|
3822
3910
|
"gpt-4o-2024-11-20",
|
|
3823
3911
|
"gpt-4o-audio-preview",
|
|
3824
|
-
"gpt-4o-audio-preview-2024-10-01",
|
|
3825
3912
|
"gpt-4o-audio-preview-2024-12-17",
|
|
3826
3913
|
"gpt-4o-search-preview",
|
|
3827
3914
|
"gpt-4o-search-preview-2025-03-11",
|
|
@@ -3829,19 +3916,9 @@ var openaiResponsesModelIds = [
|
|
|
3829
3916
|
"gpt-4o-mini-search-preview-2025-03-11",
|
|
3830
3917
|
"gpt-4o-mini",
|
|
3831
3918
|
"gpt-4o-mini-2024-07-18",
|
|
3832
|
-
"gpt-4-turbo",
|
|
3833
|
-
"gpt-4-turbo-2024-04-09",
|
|
3834
|
-
"gpt-4-turbo-preview",
|
|
3835
|
-
"gpt-4-0125-preview",
|
|
3836
|
-
"gpt-4-1106-preview",
|
|
3837
|
-
"gpt-4",
|
|
3838
|
-
"gpt-4-0613",
|
|
3839
|
-
"gpt-4.5-preview",
|
|
3840
|
-
"gpt-4.5-preview-2025-02-27",
|
|
3841
3919
|
"gpt-3.5-turbo-0125",
|
|
3842
3920
|
"gpt-3.5-turbo",
|
|
3843
3921
|
"gpt-3.5-turbo-1106",
|
|
3844
|
-
"chatgpt-4o-latest",
|
|
3845
3922
|
"gpt-5-chat-latest",
|
|
3846
3923
|
...openaiResponsesReasoningModelIds
|
|
3847
3924
|
];
|
|
@@ -4002,7 +4079,7 @@ var openaiLanguageModelResponsesOptionsSchema = (0, import_provider_utils24.lazy
|
|
|
4002
4079
|
|
|
4003
4080
|
// src/responses/openai-responses-prepare-tools.ts
|
|
4004
4081
|
var import_provider7 = require("@ai-sdk/provider");
|
|
4005
|
-
var
|
|
4082
|
+
var import_provider_utils32 = require("@ai-sdk/provider-utils");
|
|
4006
4083
|
|
|
4007
4084
|
// src/tool/code-interpreter.ts
|
|
4008
4085
|
var import_provider_utils25 = require("@ai-sdk/provider-utils");
|
|
@@ -4132,127 +4209,103 @@ var imageGeneration = (args = {}) => {
|
|
|
4132
4209
|
return imageGenerationToolFactory(args);
|
|
4133
4210
|
};
|
|
4134
4211
|
|
|
4135
|
-
// src/tool/
|
|
4212
|
+
// src/tool/custom.ts
|
|
4136
4213
|
var import_provider_utils28 = require("@ai-sdk/provider-utils");
|
|
4137
4214
|
var import_v421 = require("zod/v4");
|
|
4138
|
-
var
|
|
4139
|
-
() => import_v421.z.union([
|
|
4140
|
-
import_v421.z.string(),
|
|
4141
|
-
import_v421.z.number(),
|
|
4142
|
-
import_v421.z.boolean(),
|
|
4143
|
-
import_v421.z.null(),
|
|
4144
|
-
import_v421.z.array(jsonValueSchema),
|
|
4145
|
-
import_v421.z.record(import_v421.z.string(), jsonValueSchema)
|
|
4146
|
-
])
|
|
4147
|
-
);
|
|
4148
|
-
var mcpArgsSchema = (0, import_provider_utils28.lazySchema)(
|
|
4215
|
+
var customArgsSchema = (0, import_provider_utils28.lazySchema)(
|
|
4149
4216
|
() => (0, import_provider_utils28.zodSchema)(
|
|
4150
4217
|
import_v421.z.object({
|
|
4151
|
-
|
|
4152
|
-
|
|
4153
|
-
|
|
4218
|
+
name: import_v421.z.string(),
|
|
4219
|
+
description: import_v421.z.string().optional(),
|
|
4220
|
+
format: import_v421.z.union([
|
|
4154
4221
|
import_v421.z.object({
|
|
4155
|
-
|
|
4156
|
-
|
|
4157
|
-
|
|
4158
|
-
|
|
4159
|
-
authorization: import_v421.z.string().optional(),
|
|
4160
|
-
connectorId: import_v421.z.string().optional(),
|
|
4161
|
-
headers: import_v421.z.record(import_v421.z.string(), import_v421.z.string()).optional(),
|
|
4162
|
-
requireApproval: import_v421.z.union([
|
|
4163
|
-
import_v421.z.enum(["always", "never"]),
|
|
4222
|
+
type: import_v421.z.literal("grammar"),
|
|
4223
|
+
syntax: import_v421.z.enum(["regex", "lark"]),
|
|
4224
|
+
definition: import_v421.z.string()
|
|
4225
|
+
}),
|
|
4164
4226
|
import_v421.z.object({
|
|
4165
|
-
|
|
4166
|
-
toolNames: import_v421.z.array(import_v421.z.string()).optional()
|
|
4167
|
-
}).optional()
|
|
4227
|
+
type: import_v421.z.literal("text")
|
|
4168
4228
|
})
|
|
4169
|
-
]).optional()
|
|
4170
|
-
serverDescription: import_v421.z.string().optional(),
|
|
4171
|
-
serverUrl: import_v421.z.string().optional()
|
|
4172
|
-
}).refine(
|
|
4173
|
-
(v) => v.serverUrl != null || v.connectorId != null,
|
|
4174
|
-
"One of serverUrl or connectorId must be provided."
|
|
4175
|
-
)
|
|
4176
|
-
)
|
|
4177
|
-
);
|
|
4178
|
-
var mcpInputSchema = (0, import_provider_utils28.lazySchema)(() => (0, import_provider_utils28.zodSchema)(import_v421.z.object({})));
|
|
4179
|
-
var mcpOutputSchema = (0, import_provider_utils28.lazySchema)(
|
|
4180
|
-
() => (0, import_provider_utils28.zodSchema)(
|
|
4181
|
-
import_v421.z.object({
|
|
4182
|
-
type: import_v421.z.literal("call"),
|
|
4183
|
-
serverLabel: import_v421.z.string(),
|
|
4184
|
-
name: import_v421.z.string(),
|
|
4185
|
-
arguments: import_v421.z.string(),
|
|
4186
|
-
output: import_v421.z.string().nullish(),
|
|
4187
|
-
error: import_v421.z.union([import_v421.z.string(), jsonValueSchema]).optional()
|
|
4229
|
+
]).optional()
|
|
4188
4230
|
})
|
|
4189
4231
|
)
|
|
4190
4232
|
);
|
|
4191
|
-
var
|
|
4192
|
-
|
|
4193
|
-
|
|
4194
|
-
|
|
4233
|
+
var customInputSchema = (0, import_provider_utils28.lazySchema)(() => (0, import_provider_utils28.zodSchema)(import_v421.z.string()));
|
|
4234
|
+
var customToolFactory = (0, import_provider_utils28.createProviderToolFactory)({
|
|
4235
|
+
id: "openai.custom",
|
|
4236
|
+
inputSchema: customInputSchema
|
|
4195
4237
|
});
|
|
4196
4238
|
|
|
4197
|
-
// src/tool/
|
|
4239
|
+
// src/tool/mcp.ts
|
|
4198
4240
|
var import_provider_utils29 = require("@ai-sdk/provider-utils");
|
|
4199
4241
|
var import_v422 = require("zod/v4");
|
|
4200
|
-
var
|
|
4201
|
-
() =>
|
|
4202
|
-
import_v422.z.
|
|
4203
|
-
|
|
4204
|
-
|
|
4205
|
-
|
|
4206
|
-
|
|
4207
|
-
|
|
4208
|
-
|
|
4209
|
-
city: import_v422.z.string().optional(),
|
|
4210
|
-
region: import_v422.z.string().optional(),
|
|
4211
|
-
timezone: import_v422.z.string().optional()
|
|
4212
|
-
}).optional()
|
|
4213
|
-
})
|
|
4214
|
-
)
|
|
4242
|
+
var jsonValueSchema = import_v422.z.lazy(
|
|
4243
|
+
() => import_v422.z.union([
|
|
4244
|
+
import_v422.z.string(),
|
|
4245
|
+
import_v422.z.number(),
|
|
4246
|
+
import_v422.z.boolean(),
|
|
4247
|
+
import_v422.z.null(),
|
|
4248
|
+
import_v422.z.array(jsonValueSchema),
|
|
4249
|
+
import_v422.z.record(import_v422.z.string(), jsonValueSchema)
|
|
4250
|
+
])
|
|
4215
4251
|
);
|
|
4216
|
-
var
|
|
4217
|
-
var webSearchOutputSchema = (0, import_provider_utils29.lazySchema)(
|
|
4252
|
+
var mcpArgsSchema = (0, import_provider_utils29.lazySchema)(
|
|
4218
4253
|
() => (0, import_provider_utils29.zodSchema)(
|
|
4219
4254
|
import_v422.z.object({
|
|
4220
|
-
|
|
4221
|
-
|
|
4222
|
-
|
|
4223
|
-
query: import_v422.z.string().optional()
|
|
4224
|
-
}),
|
|
4255
|
+
serverLabel: import_v422.z.string(),
|
|
4256
|
+
allowedTools: import_v422.z.union([
|
|
4257
|
+
import_v422.z.array(import_v422.z.string()),
|
|
4225
4258
|
import_v422.z.object({
|
|
4226
|
-
|
|
4227
|
-
|
|
4228
|
-
})
|
|
4259
|
+
readOnly: import_v422.z.boolean().optional(),
|
|
4260
|
+
toolNames: import_v422.z.array(import_v422.z.string()).optional()
|
|
4261
|
+
})
|
|
4262
|
+
]).optional(),
|
|
4263
|
+
authorization: import_v422.z.string().optional(),
|
|
4264
|
+
connectorId: import_v422.z.string().optional(),
|
|
4265
|
+
headers: import_v422.z.record(import_v422.z.string(), import_v422.z.string()).optional(),
|
|
4266
|
+
requireApproval: import_v422.z.union([
|
|
4267
|
+
import_v422.z.enum(["always", "never"]),
|
|
4229
4268
|
import_v422.z.object({
|
|
4230
|
-
|
|
4231
|
-
|
|
4232
|
-
|
|
4269
|
+
never: import_v422.z.object({
|
|
4270
|
+
toolNames: import_v422.z.array(import_v422.z.string()).optional()
|
|
4271
|
+
}).optional()
|
|
4233
4272
|
})
|
|
4234
4273
|
]).optional(),
|
|
4235
|
-
|
|
4236
|
-
|
|
4237
|
-
|
|
4238
|
-
|
|
4239
|
-
|
|
4240
|
-
|
|
4274
|
+
serverDescription: import_v422.z.string().optional(),
|
|
4275
|
+
serverUrl: import_v422.z.string().optional()
|
|
4276
|
+
}).refine(
|
|
4277
|
+
(v) => v.serverUrl != null || v.connectorId != null,
|
|
4278
|
+
"One of serverUrl or connectorId must be provided."
|
|
4279
|
+
)
|
|
4280
|
+
)
|
|
4281
|
+
);
|
|
4282
|
+
var mcpInputSchema = (0, import_provider_utils29.lazySchema)(() => (0, import_provider_utils29.zodSchema)(import_v422.z.object({})));
|
|
4283
|
+
var mcpOutputSchema = (0, import_provider_utils29.lazySchema)(
|
|
4284
|
+
() => (0, import_provider_utils29.zodSchema)(
|
|
4285
|
+
import_v422.z.object({
|
|
4286
|
+
type: import_v422.z.literal("call"),
|
|
4287
|
+
serverLabel: import_v422.z.string(),
|
|
4288
|
+
name: import_v422.z.string(),
|
|
4289
|
+
arguments: import_v422.z.string(),
|
|
4290
|
+
output: import_v422.z.string().nullish(),
|
|
4291
|
+
error: import_v422.z.union([import_v422.z.string(), jsonValueSchema]).optional()
|
|
4241
4292
|
})
|
|
4242
4293
|
)
|
|
4243
4294
|
);
|
|
4244
|
-
var
|
|
4245
|
-
id: "openai.
|
|
4246
|
-
inputSchema:
|
|
4247
|
-
outputSchema:
|
|
4295
|
+
var mcpToolFactory = (0, import_provider_utils29.createProviderToolFactoryWithOutputSchema)({
|
|
4296
|
+
id: "openai.mcp",
|
|
4297
|
+
inputSchema: mcpInputSchema,
|
|
4298
|
+
outputSchema: mcpOutputSchema
|
|
4248
4299
|
});
|
|
4249
4300
|
|
|
4250
|
-
// src/tool/web-search
|
|
4301
|
+
// src/tool/web-search.ts
|
|
4251
4302
|
var import_provider_utils30 = require("@ai-sdk/provider-utils");
|
|
4252
4303
|
var import_v423 = require("zod/v4");
|
|
4253
|
-
var
|
|
4304
|
+
var webSearchArgsSchema = (0, import_provider_utils30.lazySchema)(
|
|
4254
4305
|
() => (0, import_provider_utils30.zodSchema)(
|
|
4255
4306
|
import_v423.z.object({
|
|
4307
|
+
externalWebAccess: import_v423.z.boolean().optional(),
|
|
4308
|
+
filters: import_v423.z.object({ allowedDomains: import_v423.z.array(import_v423.z.string()).optional() }).optional(),
|
|
4256
4309
|
searchContextSize: import_v423.z.enum(["low", "medium", "high"]).optional(),
|
|
4257
4310
|
userLocation: import_v423.z.object({
|
|
4258
4311
|
type: import_v423.z.literal("approximate"),
|
|
@@ -4264,10 +4317,8 @@ var webSearchPreviewArgsSchema = (0, import_provider_utils30.lazySchema)(
|
|
|
4264
4317
|
})
|
|
4265
4318
|
)
|
|
4266
4319
|
);
|
|
4267
|
-
var
|
|
4268
|
-
|
|
4269
|
-
);
|
|
4270
|
-
var webSearchPreviewOutputSchema = (0, import_provider_utils30.lazySchema)(
|
|
4320
|
+
var webSearchInputSchema = (0, import_provider_utils30.lazySchema)(() => (0, import_provider_utils30.zodSchema)(import_v423.z.object({})));
|
|
4321
|
+
var webSearchOutputSchema = (0, import_provider_utils30.lazySchema)(
|
|
4271
4322
|
() => (0, import_provider_utils30.zodSchema)(
|
|
4272
4323
|
import_v423.z.object({
|
|
4273
4324
|
action: import_v423.z.discriminatedUnion("type", [
|
|
@@ -4284,11 +4335,64 @@ var webSearchPreviewOutputSchema = (0, import_provider_utils30.lazySchema)(
|
|
|
4284
4335
|
url: import_v423.z.string().nullish(),
|
|
4285
4336
|
pattern: import_v423.z.string().nullish()
|
|
4286
4337
|
})
|
|
4338
|
+
]).optional(),
|
|
4339
|
+
sources: import_v423.z.array(
|
|
4340
|
+
import_v423.z.discriminatedUnion("type", [
|
|
4341
|
+
import_v423.z.object({ type: import_v423.z.literal("url"), url: import_v423.z.string() }),
|
|
4342
|
+
import_v423.z.object({ type: import_v423.z.literal("api"), name: import_v423.z.string() })
|
|
4343
|
+
])
|
|
4344
|
+
).optional()
|
|
4345
|
+
})
|
|
4346
|
+
)
|
|
4347
|
+
);
|
|
4348
|
+
var webSearchToolFactory = (0, import_provider_utils30.createProviderToolFactoryWithOutputSchema)({
|
|
4349
|
+
id: "openai.web_search",
|
|
4350
|
+
inputSchema: webSearchInputSchema,
|
|
4351
|
+
outputSchema: webSearchOutputSchema
|
|
4352
|
+
});
|
|
4353
|
+
|
|
4354
|
+
// src/tool/web-search-preview.ts
|
|
4355
|
+
var import_provider_utils31 = require("@ai-sdk/provider-utils");
|
|
4356
|
+
var import_v424 = require("zod/v4");
|
|
4357
|
+
var webSearchPreviewArgsSchema = (0, import_provider_utils31.lazySchema)(
|
|
4358
|
+
() => (0, import_provider_utils31.zodSchema)(
|
|
4359
|
+
import_v424.z.object({
|
|
4360
|
+
searchContextSize: import_v424.z.enum(["low", "medium", "high"]).optional(),
|
|
4361
|
+
userLocation: import_v424.z.object({
|
|
4362
|
+
type: import_v424.z.literal("approximate"),
|
|
4363
|
+
country: import_v424.z.string().optional(),
|
|
4364
|
+
city: import_v424.z.string().optional(),
|
|
4365
|
+
region: import_v424.z.string().optional(),
|
|
4366
|
+
timezone: import_v424.z.string().optional()
|
|
4367
|
+
}).optional()
|
|
4368
|
+
})
|
|
4369
|
+
)
|
|
4370
|
+
);
|
|
4371
|
+
var webSearchPreviewInputSchema = (0, import_provider_utils31.lazySchema)(
|
|
4372
|
+
() => (0, import_provider_utils31.zodSchema)(import_v424.z.object({}))
|
|
4373
|
+
);
|
|
4374
|
+
var webSearchPreviewOutputSchema = (0, import_provider_utils31.lazySchema)(
|
|
4375
|
+
() => (0, import_provider_utils31.zodSchema)(
|
|
4376
|
+
import_v424.z.object({
|
|
4377
|
+
action: import_v424.z.discriminatedUnion("type", [
|
|
4378
|
+
import_v424.z.object({
|
|
4379
|
+
type: import_v424.z.literal("search"),
|
|
4380
|
+
query: import_v424.z.string().optional()
|
|
4381
|
+
}),
|
|
4382
|
+
import_v424.z.object({
|
|
4383
|
+
type: import_v424.z.literal("openPage"),
|
|
4384
|
+
url: import_v424.z.string().nullish()
|
|
4385
|
+
}),
|
|
4386
|
+
import_v424.z.object({
|
|
4387
|
+
type: import_v424.z.literal("findInPage"),
|
|
4388
|
+
url: import_v424.z.string().nullish(),
|
|
4389
|
+
pattern: import_v424.z.string().nullish()
|
|
4390
|
+
})
|
|
4287
4391
|
]).optional()
|
|
4288
4392
|
})
|
|
4289
4393
|
)
|
|
4290
4394
|
);
|
|
4291
|
-
var webSearchPreview = (0,
|
|
4395
|
+
var webSearchPreview = (0, import_provider_utils31.createProviderToolFactoryWithOutputSchema)({
|
|
4292
4396
|
id: "openai.web_search_preview",
|
|
4293
4397
|
inputSchema: webSearchPreviewInputSchema,
|
|
4294
4398
|
outputSchema: webSearchPreviewOutputSchema
|
|
@@ -4297,14 +4401,18 @@ var webSearchPreview = (0, import_provider_utils30.createProviderToolFactoryWith
|
|
|
4297
4401
|
// src/responses/openai-responses-prepare-tools.ts
|
|
4298
4402
|
async function prepareResponsesTools({
|
|
4299
4403
|
tools,
|
|
4300
|
-
toolChoice
|
|
4404
|
+
toolChoice,
|
|
4405
|
+
toolNameMapping,
|
|
4406
|
+
customProviderToolNames
|
|
4301
4407
|
}) {
|
|
4408
|
+
var _a;
|
|
4302
4409
|
tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
|
|
4303
4410
|
const toolWarnings = [];
|
|
4304
4411
|
if (tools == null) {
|
|
4305
4412
|
return { tools: void 0, toolChoice: void 0, toolWarnings };
|
|
4306
4413
|
}
|
|
4307
4414
|
const openaiTools = [];
|
|
4415
|
+
const resolvedCustomProviderToolNames = customProviderToolNames != null ? customProviderToolNames : /* @__PURE__ */ new Set();
|
|
4308
4416
|
for (const tool of tools) {
|
|
4309
4417
|
switch (tool.type) {
|
|
4310
4418
|
case "function":
|
|
@@ -4319,7 +4427,7 @@ async function prepareResponsesTools({
|
|
|
4319
4427
|
case "provider": {
|
|
4320
4428
|
switch (tool.id) {
|
|
4321
4429
|
case "openai.file_search": {
|
|
4322
|
-
const args = await (0,
|
|
4430
|
+
const args = await (0, import_provider_utils32.validateTypes)({
|
|
4323
4431
|
value: tool.args,
|
|
4324
4432
|
schema: fileSearchArgsSchema
|
|
4325
4433
|
});
|
|
@@ -4342,7 +4450,7 @@ async function prepareResponsesTools({
|
|
|
4342
4450
|
break;
|
|
4343
4451
|
}
|
|
4344
4452
|
case "openai.shell": {
|
|
4345
|
-
const args = await (0,
|
|
4453
|
+
const args = await (0, import_provider_utils32.validateTypes)({
|
|
4346
4454
|
value: tool.args,
|
|
4347
4455
|
schema: shellArgsSchema
|
|
4348
4456
|
});
|
|
@@ -4361,7 +4469,7 @@ async function prepareResponsesTools({
|
|
|
4361
4469
|
break;
|
|
4362
4470
|
}
|
|
4363
4471
|
case "openai.web_search_preview": {
|
|
4364
|
-
const args = await (0,
|
|
4472
|
+
const args = await (0, import_provider_utils32.validateTypes)({
|
|
4365
4473
|
value: tool.args,
|
|
4366
4474
|
schema: webSearchPreviewArgsSchema
|
|
4367
4475
|
});
|
|
@@ -4373,7 +4481,7 @@ async function prepareResponsesTools({
|
|
|
4373
4481
|
break;
|
|
4374
4482
|
}
|
|
4375
4483
|
case "openai.web_search": {
|
|
4376
|
-
const args = await (0,
|
|
4484
|
+
const args = await (0, import_provider_utils32.validateTypes)({
|
|
4377
4485
|
value: tool.args,
|
|
4378
4486
|
schema: webSearchArgsSchema
|
|
4379
4487
|
});
|
|
@@ -4387,7 +4495,7 @@ async function prepareResponsesTools({
|
|
|
4387
4495
|
break;
|
|
4388
4496
|
}
|
|
4389
4497
|
case "openai.code_interpreter": {
|
|
4390
|
-
const args = await (0,
|
|
4498
|
+
const args = await (0, import_provider_utils32.validateTypes)({
|
|
4391
4499
|
value: tool.args,
|
|
4392
4500
|
schema: codeInterpreterArgsSchema
|
|
4393
4501
|
});
|
|
@@ -4398,7 +4506,7 @@ async function prepareResponsesTools({
|
|
|
4398
4506
|
break;
|
|
4399
4507
|
}
|
|
4400
4508
|
case "openai.image_generation": {
|
|
4401
|
-
const args = await (0,
|
|
4509
|
+
const args = await (0, import_provider_utils32.validateTypes)({
|
|
4402
4510
|
value: tool.args,
|
|
4403
4511
|
schema: imageGenerationArgsSchema
|
|
4404
4512
|
});
|
|
@@ -4421,7 +4529,7 @@ async function prepareResponsesTools({
|
|
|
4421
4529
|
break;
|
|
4422
4530
|
}
|
|
4423
4531
|
case "openai.mcp": {
|
|
4424
|
-
const args = await (0,
|
|
4532
|
+
const args = await (0, import_provider_utils32.validateTypes)({
|
|
4425
4533
|
value: tool.args,
|
|
4426
4534
|
schema: mcpArgsSchema
|
|
4427
4535
|
});
|
|
@@ -4446,6 +4554,20 @@ async function prepareResponsesTools({
|
|
|
4446
4554
|
});
|
|
4447
4555
|
break;
|
|
4448
4556
|
}
|
|
4557
|
+
case "openai.custom": {
|
|
4558
|
+
const args = await (0, import_provider_utils32.validateTypes)({
|
|
4559
|
+
value: tool.args,
|
|
4560
|
+
schema: customArgsSchema
|
|
4561
|
+
});
|
|
4562
|
+
openaiTools.push({
|
|
4563
|
+
type: "custom",
|
|
4564
|
+
name: args.name,
|
|
4565
|
+
description: args.description,
|
|
4566
|
+
format: args.format
|
|
4567
|
+
});
|
|
4568
|
+
resolvedCustomProviderToolNames.add(args.name);
|
|
4569
|
+
break;
|
|
4570
|
+
}
|
|
4449
4571
|
}
|
|
4450
4572
|
break;
|
|
4451
4573
|
}
|
|
@@ -4466,12 +4588,14 @@ async function prepareResponsesTools({
|
|
|
4466
4588
|
case "none":
|
|
4467
4589
|
case "required":
|
|
4468
4590
|
return { tools: openaiTools, toolChoice: type, toolWarnings };
|
|
4469
|
-
case "tool":
|
|
4591
|
+
case "tool": {
|
|
4592
|
+
const resolvedToolName = (_a = toolNameMapping == null ? void 0 : toolNameMapping.toProviderToolName(toolChoice.toolName)) != null ? _a : toolChoice.toolName;
|
|
4470
4593
|
return {
|
|
4471
4594
|
tools: openaiTools,
|
|
4472
|
-
toolChoice:
|
|
4595
|
+
toolChoice: resolvedToolName === "code_interpreter" || resolvedToolName === "file_search" || resolvedToolName === "image_generation" || resolvedToolName === "web_search_preview" || resolvedToolName === "web_search" || resolvedToolName === "mcp" || resolvedToolName === "apply_patch" ? { type: resolvedToolName } : resolvedCustomProviderToolNames.has(resolvedToolName) ? { type: "custom", name: resolvedToolName } : { type: "function", name: resolvedToolName },
|
|
4473
4596
|
toolWarnings
|
|
4474
4597
|
};
|
|
4598
|
+
}
|
|
4475
4599
|
default: {
|
|
4476
4600
|
const _exhaustiveCheck = type;
|
|
4477
4601
|
throw new import_provider7.UnsupportedFunctionalityError({
|
|
@@ -4590,13 +4714,13 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4590
4714
|
warnings.push({ type: "unsupported", feature: "stopSequences" });
|
|
4591
4715
|
}
|
|
4592
4716
|
const providerOptionsName = this.config.provider.includes("azure") ? "azure" : "openai";
|
|
4593
|
-
let openaiOptions = await (0,
|
|
4717
|
+
let openaiOptions = await (0, import_provider_utils33.parseProviderOptions)({
|
|
4594
4718
|
provider: providerOptionsName,
|
|
4595
4719
|
providerOptions,
|
|
4596
4720
|
schema: openaiLanguageModelResponsesOptionsSchema
|
|
4597
4721
|
});
|
|
4598
4722
|
if (openaiOptions == null && providerOptionsName !== "openai") {
|
|
4599
|
-
openaiOptions = await (0,
|
|
4723
|
+
openaiOptions = await (0, import_provider_utils33.parseProviderOptions)({
|
|
4600
4724
|
provider: "openai",
|
|
4601
4725
|
providerOptions,
|
|
4602
4726
|
schema: openaiLanguageModelResponsesOptionsSchema
|
|
@@ -4610,7 +4734,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4610
4734
|
details: "conversation and previousResponseId cannot be used together"
|
|
4611
4735
|
});
|
|
4612
4736
|
}
|
|
4613
|
-
const toolNameMapping = (0,
|
|
4737
|
+
const toolNameMapping = (0, import_provider_utils33.createToolNameMapping)({
|
|
4614
4738
|
tools,
|
|
4615
4739
|
providerToolNames: {
|
|
4616
4740
|
"openai.code_interpreter": "code_interpreter",
|
|
@@ -4622,7 +4746,19 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4622
4746
|
"openai.web_search_preview": "web_search_preview",
|
|
4623
4747
|
"openai.mcp": "mcp",
|
|
4624
4748
|
"openai.apply_patch": "apply_patch"
|
|
4625
|
-
}
|
|
4749
|
+
},
|
|
4750
|
+
resolveProviderToolName: (tool) => tool.id === "openai.custom" ? tool.args.name : void 0
|
|
4751
|
+
});
|
|
4752
|
+
const customProviderToolNames = /* @__PURE__ */ new Set();
|
|
4753
|
+
const {
|
|
4754
|
+
tools: openaiTools,
|
|
4755
|
+
toolChoice: openaiToolChoice,
|
|
4756
|
+
toolWarnings
|
|
4757
|
+
} = await prepareResponsesTools({
|
|
4758
|
+
tools,
|
|
4759
|
+
toolChoice,
|
|
4760
|
+
toolNameMapping,
|
|
4761
|
+
customProviderToolNames
|
|
4626
4762
|
});
|
|
4627
4763
|
const { input, warnings: inputWarnings } = await convertToOpenAIResponsesInput({
|
|
4628
4764
|
prompt,
|
|
@@ -4634,7 +4770,8 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4634
4770
|
hasConversation: (openaiOptions == null ? void 0 : openaiOptions.conversation) != null,
|
|
4635
4771
|
hasLocalShellTool: hasOpenAITool("openai.local_shell"),
|
|
4636
4772
|
hasShellTool: hasOpenAITool("openai.shell"),
|
|
4637
|
-
hasApplyPatchTool: hasOpenAITool("openai.apply_patch")
|
|
4773
|
+
hasApplyPatchTool: hasOpenAITool("openai.apply_patch"),
|
|
4774
|
+
customProviderToolNames: customProviderToolNames.size > 0 ? customProviderToolNames : void 0
|
|
4638
4775
|
});
|
|
4639
4776
|
warnings.push(...inputWarnings);
|
|
4640
4777
|
const strictJsonSchema = (_d = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _d : true;
|
|
@@ -4767,14 +4904,6 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4767
4904
|
});
|
|
4768
4905
|
delete baseArgs.service_tier;
|
|
4769
4906
|
}
|
|
4770
|
-
const {
|
|
4771
|
-
tools: openaiTools,
|
|
4772
|
-
toolChoice: openaiToolChoice,
|
|
4773
|
-
toolWarnings
|
|
4774
|
-
} = await prepareResponsesTools({
|
|
4775
|
-
tools,
|
|
4776
|
-
toolChoice
|
|
4777
|
-
});
|
|
4778
4907
|
const shellToolEnvType = (_i = (_h = (_g = tools == null ? void 0 : tools.find(
|
|
4779
4908
|
(tool) => tool.type === "provider" && tool.id === "openai.shell"
|
|
4780
4909
|
)) == null ? void 0 : _g.args) == null ? void 0 : _h.environment) == null ? void 0 : _i.type;
|
|
@@ -4812,12 +4941,12 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4812
4941
|
responseHeaders,
|
|
4813
4942
|
value: response,
|
|
4814
4943
|
rawValue: rawResponse
|
|
4815
|
-
} = await (0,
|
|
4944
|
+
} = await (0, import_provider_utils33.postJsonToApi)({
|
|
4816
4945
|
url,
|
|
4817
|
-
headers: (0,
|
|
4946
|
+
headers: (0, import_provider_utils33.combineHeaders)(this.config.headers(), options.headers),
|
|
4818
4947
|
body,
|
|
4819
4948
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
4820
|
-
successfulResponseHandler: (0,
|
|
4949
|
+
successfulResponseHandler: (0, import_provider_utils33.createJsonResponseHandler)(
|
|
4821
4950
|
openaiResponsesResponseSchema
|
|
4822
4951
|
),
|
|
4823
4952
|
abortSignal: options.abortSignal,
|
|
@@ -4952,7 +5081,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4952
5081
|
content.push({
|
|
4953
5082
|
type: "source",
|
|
4954
5083
|
sourceType: "url",
|
|
4955
|
-
id: (_f = (_e = (_d = this.config).generateId) == null ? void 0 : _e.call(_d)) != null ? _f : (0,
|
|
5084
|
+
id: (_f = (_e = (_d = this.config).generateId) == null ? void 0 : _e.call(_d)) != null ? _f : (0, import_provider_utils33.generateId)(),
|
|
4956
5085
|
url: annotation.url,
|
|
4957
5086
|
title: annotation.title
|
|
4958
5087
|
});
|
|
@@ -4960,7 +5089,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4960
5089
|
content.push({
|
|
4961
5090
|
type: "source",
|
|
4962
5091
|
sourceType: "document",
|
|
4963
|
-
id: (_i = (_h = (_g = this.config).generateId) == null ? void 0 : _h.call(_g)) != null ? _i : (0,
|
|
5092
|
+
id: (_i = (_h = (_g = this.config).generateId) == null ? void 0 : _h.call(_g)) != null ? _i : (0, import_provider_utils33.generateId)(),
|
|
4964
5093
|
mediaType: "text/plain",
|
|
4965
5094
|
title: annotation.filename,
|
|
4966
5095
|
filename: annotation.filename,
|
|
@@ -4976,7 +5105,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4976
5105
|
content.push({
|
|
4977
5106
|
type: "source",
|
|
4978
5107
|
sourceType: "document",
|
|
4979
|
-
id: (_l = (_k = (_j = this.config).generateId) == null ? void 0 : _k.call(_j)) != null ? _l : (0,
|
|
5108
|
+
id: (_l = (_k = (_j = this.config).generateId) == null ? void 0 : _k.call(_j)) != null ? _l : (0, import_provider_utils33.generateId)(),
|
|
4980
5109
|
mediaType: "text/plain",
|
|
4981
5110
|
title: annotation.filename,
|
|
4982
5111
|
filename: annotation.filename,
|
|
@@ -4992,7 +5121,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4992
5121
|
content.push({
|
|
4993
5122
|
type: "source",
|
|
4994
5123
|
sourceType: "document",
|
|
4995
|
-
id: (_o = (_n = (_m = this.config).generateId) == null ? void 0 : _n.call(_m)) != null ? _o : (0,
|
|
5124
|
+
id: (_o = (_n = (_m = this.config).generateId) == null ? void 0 : _n.call(_m)) != null ? _o : (0, import_provider_utils33.generateId)(),
|
|
4996
5125
|
mediaType: "application/octet-stream",
|
|
4997
5126
|
title: annotation.file_id,
|
|
4998
5127
|
filename: annotation.file_id,
|
|
@@ -5024,6 +5153,22 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5024
5153
|
});
|
|
5025
5154
|
break;
|
|
5026
5155
|
}
|
|
5156
|
+
case "custom_tool_call": {
|
|
5157
|
+
hasFunctionCall = true;
|
|
5158
|
+
const toolName = toolNameMapping.toCustomToolName(part.name);
|
|
5159
|
+
content.push({
|
|
5160
|
+
type: "tool-call",
|
|
5161
|
+
toolCallId: part.call_id,
|
|
5162
|
+
toolName,
|
|
5163
|
+
input: JSON.stringify(part.input),
|
|
5164
|
+
providerMetadata: {
|
|
5165
|
+
[providerOptionsName]: {
|
|
5166
|
+
itemId: part.id
|
|
5167
|
+
}
|
|
5168
|
+
}
|
|
5169
|
+
});
|
|
5170
|
+
break;
|
|
5171
|
+
}
|
|
5027
5172
|
case "web_search_call": {
|
|
5028
5173
|
content.push({
|
|
5029
5174
|
type: "tool-call",
|
|
@@ -5080,7 +5225,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5080
5225
|
}
|
|
5081
5226
|
case "mcp_approval_request": {
|
|
5082
5227
|
const approvalRequestId = (_q = part.approval_request_id) != null ? _q : part.id;
|
|
5083
|
-
const dummyToolCallId = (_t = (_s = (_r = this.config).generateId) == null ? void 0 : _s.call(_r)) != null ? _t : (0,
|
|
5228
|
+
const dummyToolCallId = (_t = (_s = (_r = this.config).generateId) == null ? void 0 : _s.call(_r)) != null ? _t : (0, import_provider_utils33.generateId)();
|
|
5084
5229
|
const toolName = `mcp.${part.name}`;
|
|
5085
5230
|
content.push({
|
|
5086
5231
|
type: "tool-call",
|
|
@@ -5221,18 +5366,18 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5221
5366
|
providerOptionsName,
|
|
5222
5367
|
isShellProviderExecuted
|
|
5223
5368
|
} = await this.getArgs(options);
|
|
5224
|
-
const { responseHeaders, value: response } = await (0,
|
|
5369
|
+
const { responseHeaders, value: response } = await (0, import_provider_utils33.postJsonToApi)({
|
|
5225
5370
|
url: this.config.url({
|
|
5226
5371
|
path: "/responses",
|
|
5227
5372
|
modelId: this.modelId
|
|
5228
5373
|
}),
|
|
5229
|
-
headers: (0,
|
|
5374
|
+
headers: (0, import_provider_utils33.combineHeaders)(this.config.headers(), options.headers),
|
|
5230
5375
|
body: {
|
|
5231
5376
|
...body,
|
|
5232
5377
|
stream: true
|
|
5233
5378
|
},
|
|
5234
5379
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
5235
|
-
successfulResponseHandler: (0,
|
|
5380
|
+
successfulResponseHandler: (0, import_provider_utils33.createEventSourceResponseHandler)(
|
|
5236
5381
|
openaiResponsesChunkSchema
|
|
5237
5382
|
),
|
|
5238
5383
|
abortSignal: options.abortSignal,
|
|
@@ -5282,6 +5427,19 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5282
5427
|
id: value.item.call_id,
|
|
5283
5428
|
toolName: value.item.name
|
|
5284
5429
|
});
|
|
5430
|
+
} else if (value.item.type === "custom_tool_call") {
|
|
5431
|
+
const toolName = toolNameMapping.toCustomToolName(
|
|
5432
|
+
value.item.name
|
|
5433
|
+
);
|
|
5434
|
+
ongoingToolCalls[value.output_index] = {
|
|
5435
|
+
toolName,
|
|
5436
|
+
toolCallId: value.item.call_id
|
|
5437
|
+
};
|
|
5438
|
+
controller.enqueue({
|
|
5439
|
+
type: "tool-input-start",
|
|
5440
|
+
id: value.item.call_id,
|
|
5441
|
+
toolName
|
|
5442
|
+
});
|
|
5285
5443
|
} else if (value.item.type === "web_search_call") {
|
|
5286
5444
|
ongoingToolCalls[value.output_index] = {
|
|
5287
5445
|
toolName: toolNameMapping.toCustomToolName(
|
|
@@ -5466,6 +5624,27 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5466
5624
|
}
|
|
5467
5625
|
}
|
|
5468
5626
|
});
|
|
5627
|
+
} else if (value.item.type === "custom_tool_call") {
|
|
5628
|
+
ongoingToolCalls[value.output_index] = void 0;
|
|
5629
|
+
hasFunctionCall = true;
|
|
5630
|
+
const toolName = toolNameMapping.toCustomToolName(
|
|
5631
|
+
value.item.name
|
|
5632
|
+
);
|
|
5633
|
+
controller.enqueue({
|
|
5634
|
+
type: "tool-input-end",
|
|
5635
|
+
id: value.item.call_id
|
|
5636
|
+
});
|
|
5637
|
+
controller.enqueue({
|
|
5638
|
+
type: "tool-call",
|
|
5639
|
+
toolCallId: value.item.call_id,
|
|
5640
|
+
toolName,
|
|
5641
|
+
input: JSON.stringify(value.item.input),
|
|
5642
|
+
providerMetadata: {
|
|
5643
|
+
[providerOptionsName]: {
|
|
5644
|
+
itemId: value.item.id
|
|
5645
|
+
}
|
|
5646
|
+
}
|
|
5647
|
+
});
|
|
5469
5648
|
} else if (value.item.type === "web_search_call") {
|
|
5470
5649
|
ongoingToolCalls[value.output_index] = void 0;
|
|
5471
5650
|
controller.enqueue({
|
|
@@ -5609,7 +5788,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5609
5788
|
ongoingToolCalls[value.output_index] = void 0;
|
|
5610
5789
|
} else if (value.item.type === "mcp_approval_request") {
|
|
5611
5790
|
ongoingToolCalls[value.output_index] = void 0;
|
|
5612
|
-
const dummyToolCallId = (_k = (_j = (_i = self.config).generateId) == null ? void 0 : _j.call(_i)) != null ? _k : (0,
|
|
5791
|
+
const dummyToolCallId = (_k = (_j = (_i = self.config).generateId) == null ? void 0 : _j.call(_i)) != null ? _k : (0, import_provider_utils33.generateId)();
|
|
5613
5792
|
const approvalRequestId = (_l = value.item.approval_request_id) != null ? _l : value.item.id;
|
|
5614
5793
|
approvalRequestIdToDummyToolCallIdFromStream.set(
|
|
5615
5794
|
approvalRequestId,
|
|
@@ -5715,6 +5894,15 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5715
5894
|
delta: value.delta
|
|
5716
5895
|
});
|
|
5717
5896
|
}
|
|
5897
|
+
} else if (isResponseCustomToolCallInputDeltaChunk(value)) {
|
|
5898
|
+
const toolCall = ongoingToolCalls[value.output_index];
|
|
5899
|
+
if (toolCall != null) {
|
|
5900
|
+
controller.enqueue({
|
|
5901
|
+
type: "tool-input-delta",
|
|
5902
|
+
id: toolCall.toolCallId,
|
|
5903
|
+
delta: value.delta
|
|
5904
|
+
});
|
|
5905
|
+
}
|
|
5718
5906
|
} else if (isResponseApplyPatchCallOperationDiffDeltaChunk(value)) {
|
|
5719
5907
|
const toolCall = ongoingToolCalls[value.output_index];
|
|
5720
5908
|
if (toolCall == null ? void 0 : toolCall.applyPatch) {
|
|
@@ -5881,7 +6069,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5881
6069
|
controller.enqueue({
|
|
5882
6070
|
type: "source",
|
|
5883
6071
|
sourceType: "url",
|
|
5884
|
-
id: (_w = (_v = (_u = self.config).generateId) == null ? void 0 : _v.call(_u)) != null ? _w : (0,
|
|
6072
|
+
id: (_w = (_v = (_u = self.config).generateId) == null ? void 0 : _v.call(_u)) != null ? _w : (0, import_provider_utils33.generateId)(),
|
|
5885
6073
|
url: value.annotation.url,
|
|
5886
6074
|
title: value.annotation.title
|
|
5887
6075
|
});
|
|
@@ -5889,7 +6077,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5889
6077
|
controller.enqueue({
|
|
5890
6078
|
type: "source",
|
|
5891
6079
|
sourceType: "document",
|
|
5892
|
-
id: (_z = (_y = (_x = self.config).generateId) == null ? void 0 : _y.call(_x)) != null ? _z : (0,
|
|
6080
|
+
id: (_z = (_y = (_x = self.config).generateId) == null ? void 0 : _y.call(_x)) != null ? _z : (0, import_provider_utils33.generateId)(),
|
|
5893
6081
|
mediaType: "text/plain",
|
|
5894
6082
|
title: value.annotation.filename,
|
|
5895
6083
|
filename: value.annotation.filename,
|
|
@@ -5905,7 +6093,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5905
6093
|
controller.enqueue({
|
|
5906
6094
|
type: "source",
|
|
5907
6095
|
sourceType: "document",
|
|
5908
|
-
id: (_C = (_B = (_A = self.config).generateId) == null ? void 0 : _B.call(_A)) != null ? _C : (0,
|
|
6096
|
+
id: (_C = (_B = (_A = self.config).generateId) == null ? void 0 : _B.call(_A)) != null ? _C : (0, import_provider_utils33.generateId)(),
|
|
5909
6097
|
mediaType: "text/plain",
|
|
5910
6098
|
title: value.annotation.filename,
|
|
5911
6099
|
filename: value.annotation.filename,
|
|
@@ -5921,7 +6109,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5921
6109
|
controller.enqueue({
|
|
5922
6110
|
type: "source",
|
|
5923
6111
|
sourceType: "document",
|
|
5924
|
-
id: (_F = (_E = (_D = self.config).generateId) == null ? void 0 : _E.call(_D)) != null ? _F : (0,
|
|
6112
|
+
id: (_F = (_E = (_D = self.config).generateId) == null ? void 0 : _E.call(_D)) != null ? _F : (0, import_provider_utils33.generateId)(),
|
|
5925
6113
|
mediaType: "application/octet-stream",
|
|
5926
6114
|
title: value.annotation.file_id,
|
|
5927
6115
|
filename: value.annotation.file_id,
|
|
@@ -5975,6 +6163,9 @@ function isResponseCreatedChunk(chunk) {
|
|
|
5975
6163
|
function isResponseFunctionCallArgumentsDeltaChunk(chunk) {
|
|
5976
6164
|
return chunk.type === "response.function_call_arguments.delta";
|
|
5977
6165
|
}
|
|
6166
|
+
function isResponseCustomToolCallInputDeltaChunk(chunk) {
|
|
6167
|
+
return chunk.type === "response.custom_tool_call_input.delta";
|
|
6168
|
+
}
|
|
5978
6169
|
function isResponseImageGenerationCallPartialImageChunk(chunk) {
|
|
5979
6170
|
return chunk.type === "response.image_generation_call.partial_image";
|
|
5980
6171
|
}
|