@ai-sdk/openai 3.0.98 → 3.0.99
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.js +564 -231
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +488 -153
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +584 -253
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +485 -152
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/responses/convert-to-openai-responses-input.ts +309 -90
- package/src/responses/expand-parallel-tool-call.ts +142 -0
- package/src/responses/openai-responses-language-model.ts +171 -29
package/dist/internal/index.js
CHANGED
|
@@ -2678,8 +2678,8 @@ var OpenAISpeechModel = class {
|
|
|
2678
2678
|
};
|
|
2679
2679
|
|
|
2680
2680
|
// src/responses/openai-responses-language-model.ts
|
|
2681
|
-
var
|
|
2682
|
-
var
|
|
2681
|
+
var import_provider10 = require("@ai-sdk/provider");
|
|
2682
|
+
var import_provider_utils36 = require("@ai-sdk/provider-utils");
|
|
2683
2683
|
|
|
2684
2684
|
// src/responses/convert-openai-responses-usage.ts
|
|
2685
2685
|
function convertOpenAIResponsesUsage(usage) {
|
|
@@ -2722,8 +2722,8 @@ function convertOpenAIResponsesUsage(usage) {
|
|
|
2722
2722
|
}
|
|
2723
2723
|
|
|
2724
2724
|
// src/responses/convert-to-openai-responses-input.ts
|
|
2725
|
-
var
|
|
2726
|
-
var
|
|
2725
|
+
var import_provider8 = require("@ai-sdk/provider");
|
|
2726
|
+
var import_provider_utils25 = require("@ai-sdk/provider-utils");
|
|
2727
2727
|
var import_v417 = require("zod/v4");
|
|
2728
2728
|
|
|
2729
2729
|
// src/tool/apply-patch.ts
|
|
@@ -2924,10 +2924,225 @@ var toolSearchToolFactory = (0, import_provider_utils23.createProviderToolFactor
|
|
|
2924
2924
|
outputSchema: toolSearchOutputSchema
|
|
2925
2925
|
});
|
|
2926
2926
|
|
|
2927
|
+
// src/responses/expand-parallel-tool-call.ts
|
|
2928
|
+
var import_provider7 = require("@ai-sdk/provider");
|
|
2929
|
+
var import_provider_utils24 = require("@ai-sdk/provider-utils");
|
|
2930
|
+
var parallelToolName = "parallel";
|
|
2931
|
+
var recipientNamePrefix = "functions.";
|
|
2932
|
+
function getParallelToolCallMetadata({
|
|
2933
|
+
providerOptions,
|
|
2934
|
+
providerOptionsName
|
|
2935
|
+
}) {
|
|
2936
|
+
var _a;
|
|
2937
|
+
const metadata = (_a = providerOptions == null ? void 0 : providerOptions[providerOptionsName]) == null ? void 0 : _a.parallelToolCall;
|
|
2938
|
+
if (!(0, import_provider7.isJSONObject)(metadata) || typeof metadata.itemId !== "string" || typeof metadata.toolCallId !== "string" || typeof metadata.toolName !== "string" || typeof metadata.input !== "string" || typeof metadata.index !== "number" || !Number.isInteger(metadata.index) || typeof metadata.count !== "number" || !Number.isInteger(metadata.count) || metadata.index < 0 || metadata.count <= metadata.index) {
|
|
2939
|
+
return void 0;
|
|
2940
|
+
}
|
|
2941
|
+
return metadata;
|
|
2942
|
+
}
|
|
2943
|
+
function isUndeclaredParallelToolCall({
|
|
2944
|
+
toolName,
|
|
2945
|
+
tools
|
|
2946
|
+
}) {
|
|
2947
|
+
return toolName === parallelToolName && !tools.some((tool) => tool.name === parallelToolName);
|
|
2948
|
+
}
|
|
2949
|
+
async function expandParallelToolCall({
|
|
2950
|
+
toolCall,
|
|
2951
|
+
tools,
|
|
2952
|
+
providerOptionsName,
|
|
2953
|
+
itemId
|
|
2954
|
+
}) {
|
|
2955
|
+
if (!isUndeclaredParallelToolCall({ toolName: toolCall.toolName, tools })) {
|
|
2956
|
+
return void 0;
|
|
2957
|
+
}
|
|
2958
|
+
const parsedInput = await (0, import_provider_utils24.safeParseJSON)({ text: toolCall.input });
|
|
2959
|
+
if (!parsedInput.success || !(0, import_provider7.isJSONObject)(parsedInput.value)) {
|
|
2960
|
+
return void 0;
|
|
2961
|
+
}
|
|
2962
|
+
const toolUses = parsedInput.value.tool_uses;
|
|
2963
|
+
if (!Array.isArray(toolUses) || toolUses.length === 0) {
|
|
2964
|
+
return void 0;
|
|
2965
|
+
}
|
|
2966
|
+
const availableToolNames = new Set(tools.map((tool) => tool.name));
|
|
2967
|
+
const expandedToolCalls = [];
|
|
2968
|
+
for (const [index, toolUse] of toolUses.entries()) {
|
|
2969
|
+
if (!(0, import_provider7.isJSONObject)(toolUse)) {
|
|
2970
|
+
return void 0;
|
|
2971
|
+
}
|
|
2972
|
+
const recipientName = toolUse.recipient_name;
|
|
2973
|
+
const parameters = toolUse.parameters;
|
|
2974
|
+
if (typeof recipientName !== "string" || !recipientName.startsWith(recipientNamePrefix) || !(0, import_provider7.isJSONObject)(parameters)) {
|
|
2975
|
+
return void 0;
|
|
2976
|
+
}
|
|
2977
|
+
const toolName = recipientName.slice(recipientNamePrefix.length);
|
|
2978
|
+
if (toolName.length === 0 || !availableToolNames.has(toolName)) {
|
|
2979
|
+
return void 0;
|
|
2980
|
+
}
|
|
2981
|
+
expandedToolCalls.push({
|
|
2982
|
+
type: "tool-call",
|
|
2983
|
+
toolCallId: `${toolCall.toolCallId}_${index}`,
|
|
2984
|
+
toolName,
|
|
2985
|
+
input: JSON.stringify(parameters),
|
|
2986
|
+
providerMetadata: {
|
|
2987
|
+
[providerOptionsName]: {
|
|
2988
|
+
parallelToolCall: {
|
|
2989
|
+
itemId,
|
|
2990
|
+
toolCallId: toolCall.toolCallId,
|
|
2991
|
+
toolName: toolCall.toolName,
|
|
2992
|
+
input: toolCall.input,
|
|
2993
|
+
index,
|
|
2994
|
+
count: toolUses.length
|
|
2995
|
+
}
|
|
2996
|
+
}
|
|
2997
|
+
}
|
|
2998
|
+
});
|
|
2999
|
+
}
|
|
3000
|
+
return expandedToolCalls;
|
|
3001
|
+
}
|
|
3002
|
+
|
|
2927
3003
|
// src/responses/convert-to-openai-responses-input.ts
|
|
2928
3004
|
function serializeToolCallArguments2(input) {
|
|
2929
3005
|
return JSON.stringify(input === void 0 ? {} : input);
|
|
2930
3006
|
}
|
|
3007
|
+
async function convertFunctionToolResultOutput({
|
|
3008
|
+
output,
|
|
3009
|
+
providerOptionsName,
|
|
3010
|
+
warnings
|
|
3011
|
+
}) {
|
|
3012
|
+
var _a;
|
|
3013
|
+
switch (output.type) {
|
|
3014
|
+
case "text":
|
|
3015
|
+
case "error-text":
|
|
3016
|
+
return output.value;
|
|
3017
|
+
case "execution-denied":
|
|
3018
|
+
return (_a = output.reason) != null ? _a : "Tool call execution denied.";
|
|
3019
|
+
case "json":
|
|
3020
|
+
case "error-json":
|
|
3021
|
+
return JSON.stringify(output.value);
|
|
3022
|
+
case "content":
|
|
3023
|
+
return output.value.map((item) => {
|
|
3024
|
+
var _a2, _b, _c, _d, _e;
|
|
3025
|
+
const promptCacheBreakpoint = getPromptCacheBreakpoint2(
|
|
3026
|
+
item.providerOptions,
|
|
3027
|
+
providerOptionsName
|
|
3028
|
+
);
|
|
3029
|
+
switch (item.type) {
|
|
3030
|
+
case "text": {
|
|
3031
|
+
return {
|
|
3032
|
+
type: "input_text",
|
|
3033
|
+
text: item.text,
|
|
3034
|
+
...promptCacheBreakpoint != null && {
|
|
3035
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
3036
|
+
}
|
|
3037
|
+
};
|
|
3038
|
+
}
|
|
3039
|
+
case "image-data": {
|
|
3040
|
+
return {
|
|
3041
|
+
type: "input_image",
|
|
3042
|
+
image_url: `data:${item.mediaType};base64,${item.data}`,
|
|
3043
|
+
detail: (_b = (_a2 = item.providerOptions) == null ? void 0 : _a2[providerOptionsName]) == null ? void 0 : _b.imageDetail,
|
|
3044
|
+
...promptCacheBreakpoint != null && {
|
|
3045
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
3046
|
+
}
|
|
3047
|
+
};
|
|
3048
|
+
}
|
|
3049
|
+
case "image-url": {
|
|
3050
|
+
return {
|
|
3051
|
+
type: "input_image",
|
|
3052
|
+
image_url: item.url,
|
|
3053
|
+
detail: (_d = (_c = item.providerOptions) == null ? void 0 : _c[providerOptionsName]) == null ? void 0 : _d.imageDetail,
|
|
3054
|
+
...promptCacheBreakpoint != null && {
|
|
3055
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
3056
|
+
}
|
|
3057
|
+
};
|
|
3058
|
+
}
|
|
3059
|
+
case "file-data": {
|
|
3060
|
+
return {
|
|
3061
|
+
type: "input_file",
|
|
3062
|
+
filename: (_e = item.filename) != null ? _e : "data",
|
|
3063
|
+
file_data: `data:${item.mediaType};base64,${item.data}`,
|
|
3064
|
+
...promptCacheBreakpoint != null && {
|
|
3065
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
3066
|
+
}
|
|
3067
|
+
};
|
|
3068
|
+
}
|
|
3069
|
+
case "file-url": {
|
|
3070
|
+
return {
|
|
3071
|
+
type: "input_file",
|
|
3072
|
+
file_url: item.url,
|
|
3073
|
+
...promptCacheBreakpoint != null && {
|
|
3074
|
+
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
3075
|
+
}
|
|
3076
|
+
};
|
|
3077
|
+
}
|
|
3078
|
+
default: {
|
|
3079
|
+
warnings.push({
|
|
3080
|
+
type: "other",
|
|
3081
|
+
message: `unsupported tool content part type: ${item.type}`
|
|
3082
|
+
});
|
|
3083
|
+
return void 0;
|
|
3084
|
+
}
|
|
3085
|
+
}
|
|
3086
|
+
}).filter(import_provider_utils25.isNonNullable);
|
|
3087
|
+
}
|
|
3088
|
+
}
|
|
3089
|
+
function hasSameParallelToolCall(first, second) {
|
|
3090
|
+
return first.itemId === second.itemId && first.toolCallId === second.toolCallId && first.toolName === second.toolName && first.input === second.input && first.count === second.count;
|
|
3091
|
+
}
|
|
3092
|
+
function collectCompleteParallelToolResultGroups({
|
|
3093
|
+
prompt,
|
|
3094
|
+
providerOptionsName
|
|
3095
|
+
}) {
|
|
3096
|
+
const pendingGroups = /* @__PURE__ */ new Map();
|
|
3097
|
+
for (const message of prompt) {
|
|
3098
|
+
if (message.role !== "tool") {
|
|
3099
|
+
continue;
|
|
3100
|
+
}
|
|
3101
|
+
for (const part of message.content) {
|
|
3102
|
+
if (part.type !== "tool-result") {
|
|
3103
|
+
continue;
|
|
3104
|
+
}
|
|
3105
|
+
const metadata = getParallelToolCallMetadata({
|
|
3106
|
+
providerOptions: part.providerOptions,
|
|
3107
|
+
providerOptionsName
|
|
3108
|
+
});
|
|
3109
|
+
if (metadata == null) {
|
|
3110
|
+
continue;
|
|
3111
|
+
}
|
|
3112
|
+
const existing = pendingGroups.get(metadata.toolCallId);
|
|
3113
|
+
if (existing == null) {
|
|
3114
|
+
pendingGroups.set(metadata.toolCallId, {
|
|
3115
|
+
metadata,
|
|
3116
|
+
results: /* @__PURE__ */ new Map([[metadata.index, part]]),
|
|
3117
|
+
invalid: false
|
|
3118
|
+
});
|
|
3119
|
+
continue;
|
|
3120
|
+
}
|
|
3121
|
+
if (!hasSameParallelToolCall(existing.metadata, metadata) || existing.results.has(metadata.index)) {
|
|
3122
|
+
existing.invalid = true;
|
|
3123
|
+
continue;
|
|
3124
|
+
}
|
|
3125
|
+
existing.results.set(metadata.index, part);
|
|
3126
|
+
}
|
|
3127
|
+
}
|
|
3128
|
+
const completeGroups = /* @__PURE__ */ new Map();
|
|
3129
|
+
for (const [toolCallId, group] of pendingGroups) {
|
|
3130
|
+
if (group.invalid || group.results.size !== group.metadata.count) {
|
|
3131
|
+
continue;
|
|
3132
|
+
}
|
|
3133
|
+
const results = Array.from(
|
|
3134
|
+
{ length: group.metadata.count },
|
|
3135
|
+
(_, index) => group.results.get(index)
|
|
3136
|
+
);
|
|
3137
|
+
if (results.every(import_provider_utils25.isNonNullable)) {
|
|
3138
|
+
completeGroups.set(toolCallId, {
|
|
3139
|
+
metadata: group.metadata,
|
|
3140
|
+
results
|
|
3141
|
+
});
|
|
3142
|
+
}
|
|
3143
|
+
}
|
|
3144
|
+
return completeGroups;
|
|
3145
|
+
}
|
|
2931
3146
|
function getPromptCacheBreakpoint2(providerOptions, providerOptionsName) {
|
|
2932
3147
|
var _a;
|
|
2933
3148
|
return (_a = providerOptions == null ? void 0 : providerOptions[providerOptionsName]) == null ? void 0 : _a.promptCacheBreakpoint;
|
|
@@ -2951,10 +3166,16 @@ async function convertToOpenAIResponsesInput({
|
|
|
2951
3166
|
hasApplyPatchTool = false,
|
|
2952
3167
|
customProviderToolNames
|
|
2953
3168
|
}) {
|
|
2954
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y
|
|
3169
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
|
|
2955
3170
|
let input = [];
|
|
2956
3171
|
const warnings = [];
|
|
2957
3172
|
const processedApprovalIds = /* @__PURE__ */ new Set();
|
|
3173
|
+
const parallelToolResultGroups = hasConversation || hasPreviousResponseId ? collectCompleteParallelToolResultGroups({
|
|
3174
|
+
prompt,
|
|
3175
|
+
providerOptionsName
|
|
3176
|
+
}) : /* @__PURE__ */ new Map();
|
|
3177
|
+
const emittedParallelToolCalls = /* @__PURE__ */ new Set();
|
|
3178
|
+
const emittedParallelToolResults = /* @__PURE__ */ new Set();
|
|
2958
3179
|
for (const { role, content, providerOptions } of prompt) {
|
|
2959
3180
|
switch (role) {
|
|
2960
3181
|
case "system": {
|
|
@@ -3038,7 +3259,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
3038
3259
|
return {
|
|
3039
3260
|
type: "input_image",
|
|
3040
3261
|
...part.data instanceof URL ? { image_url: part.data.toString() } : typeof part.data === "string" && isFileId(part.data, fileIdPrefixes) ? { file_id: part.data } : {
|
|
3041
|
-
image_url: `data:${mediaType};base64,${(0,
|
|
3262
|
+
image_url: `data:${mediaType};base64,${(0, import_provider_utils25.convertToBase64)(part.data)}`
|
|
3042
3263
|
},
|
|
3043
3264
|
detail: (_b2 = (_a2 = part.providerOptions) == null ? void 0 : _a2[providerOptionsName]) == null ? void 0 : _b2.imageDetail,
|
|
3044
3265
|
...promptCacheBreakpoint != null && {
|
|
@@ -3056,7 +3277,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
3056
3277
|
};
|
|
3057
3278
|
}
|
|
3058
3279
|
if (mediaType !== "application/pdf" && !passThroughUnsupportedFiles) {
|
|
3059
|
-
throw new
|
|
3280
|
+
throw new import_provider8.UnsupportedFunctionalityError({
|
|
3060
3281
|
functionality: `file part media type ${mediaType}`
|
|
3061
3282
|
});
|
|
3062
3283
|
}
|
|
@@ -3064,7 +3285,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
3064
3285
|
type: "input_file",
|
|
3065
3286
|
...typeof part.data === "string" && isFileId(part.data, fileIdPrefixes) ? { file_id: part.data } : {
|
|
3066
3287
|
filename: (_c2 = part.filename) != null ? _c2 : mediaType === "application/pdf" ? `part-${index}.pdf` : `part-${index}`,
|
|
3067
|
-
file_data: `data:${mediaType};base64,${(0,
|
|
3288
|
+
file_data: `data:${mediaType};base64,${(0, import_provider_utils25.convertToBase64)(part.data)}`
|
|
3068
3289
|
},
|
|
3069
3290
|
...promptCacheBreakpoint != null && {
|
|
3070
3291
|
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
@@ -3100,6 +3321,34 @@ async function convertToOpenAIResponsesInput({
|
|
|
3100
3321
|
break;
|
|
3101
3322
|
}
|
|
3102
3323
|
case "tool-call": {
|
|
3324
|
+
const parallelToolCallMetadata = getParallelToolCallMetadata({
|
|
3325
|
+
providerOptions: part.providerOptions,
|
|
3326
|
+
providerOptionsName
|
|
3327
|
+
});
|
|
3328
|
+
const parallelToolResultGroup = parallelToolCallMetadata == null ? void 0 : parallelToolResultGroups.get(
|
|
3329
|
+
parallelToolCallMetadata.toolCallId
|
|
3330
|
+
);
|
|
3331
|
+
if (parallelToolCallMetadata != null && parallelToolResultGroup != null && hasSameParallelToolCall(
|
|
3332
|
+
parallelToolResultGroup.metadata,
|
|
3333
|
+
parallelToolCallMetadata
|
|
3334
|
+
)) {
|
|
3335
|
+
if (!emittedParallelToolCalls.has(
|
|
3336
|
+
parallelToolResultGroup.metadata.toolCallId
|
|
3337
|
+
)) {
|
|
3338
|
+
emittedParallelToolCalls.add(
|
|
3339
|
+
parallelToolResultGroup.metadata.toolCallId
|
|
3340
|
+
);
|
|
3341
|
+
if (!hasConversation) {
|
|
3342
|
+
input.push({
|
|
3343
|
+
type: "function_call",
|
|
3344
|
+
call_id: parallelToolResultGroup.metadata.toolCallId,
|
|
3345
|
+
name: parallelToolResultGroup.metadata.toolName,
|
|
3346
|
+
arguments: parallelToolResultGroup.metadata.input
|
|
3347
|
+
});
|
|
3348
|
+
}
|
|
3349
|
+
}
|
|
3350
|
+
break;
|
|
3351
|
+
}
|
|
3103
3352
|
const id = (_f = (_c = (_b = part.providerOptions) == null ? void 0 : _b[providerOptionsName]) == null ? void 0 : _c.itemId) != null ? _f : (_e = (_d = part.providerMetadata) == null ? void 0 : _d[providerOptionsName]) == null ? void 0 : _e.itemId;
|
|
3104
3353
|
const namespace = (_k = (_h = (_g = part.providerOptions) == null ? void 0 : _g[providerOptionsName]) == null ? void 0 : _h.namespace) != null ? _k : (_j = (_i = part.providerMetadata) == null ? void 0 : _i[providerOptionsName]) == null ? void 0 : _j.namespace;
|
|
3105
3354
|
if (hasConversation && id != null) {
|
|
@@ -3113,10 +3362,10 @@ async function convertToOpenAIResponsesInput({
|
|
|
3113
3362
|
input.push({ type: "item_reference", id });
|
|
3114
3363
|
break;
|
|
3115
3364
|
}
|
|
3116
|
-
const parsedInput = typeof part.input === "string" ? await (0,
|
|
3365
|
+
const parsedInput = typeof part.input === "string" ? await (0, import_provider_utils25.parseJSON)({
|
|
3117
3366
|
text: part.input,
|
|
3118
3367
|
schema: toolSearchInputSchema
|
|
3119
|
-
}) : await (0,
|
|
3368
|
+
}) : await (0, import_provider_utils25.validateTypes)({
|
|
3120
3369
|
value: part.input,
|
|
3121
3370
|
schema: toolSearchInputSchema
|
|
3122
3371
|
});
|
|
@@ -3148,7 +3397,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
3148
3397
|
break;
|
|
3149
3398
|
}
|
|
3150
3399
|
if (hasLocalShellTool && resolvedToolName === "local_shell") {
|
|
3151
|
-
const parsedInput = await (0,
|
|
3400
|
+
const parsedInput = await (0, import_provider_utils25.validateTypes)({
|
|
3152
3401
|
value: part.input,
|
|
3153
3402
|
schema: localShellInputSchema
|
|
3154
3403
|
});
|
|
@@ -3168,7 +3417,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
3168
3417
|
break;
|
|
3169
3418
|
}
|
|
3170
3419
|
if (hasShellTool && resolvedToolName === "shell") {
|
|
3171
|
-
const parsedInput = await (0,
|
|
3420
|
+
const parsedInput = await (0, import_provider_utils25.validateTypes)({
|
|
3172
3421
|
value: part.input,
|
|
3173
3422
|
schema: shellInputSchema
|
|
3174
3423
|
});
|
|
@@ -3186,7 +3435,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
3186
3435
|
break;
|
|
3187
3436
|
}
|
|
3188
3437
|
if (hasApplyPatchTool && resolvedToolName === "apply_patch") {
|
|
3189
|
-
const parsedInput = await (0,
|
|
3438
|
+
const parsedInput = await (0, import_provider_utils25.validateTypes)({
|
|
3190
3439
|
value: part.input,
|
|
3191
3440
|
schema: applyPatchInputSchema
|
|
3192
3441
|
});
|
|
@@ -3234,7 +3483,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
3234
3483
|
if (store) {
|
|
3235
3484
|
input.push({ type: "item_reference", id: itemId });
|
|
3236
3485
|
} else if (part.output.type === "json") {
|
|
3237
|
-
const parsedOutput = await (0,
|
|
3486
|
+
const parsedOutput = await (0, import_provider_utils25.validateTypes)({
|
|
3238
3487
|
value: part.output.value,
|
|
3239
3488
|
schema: toolSearchOutputSchema
|
|
3240
3489
|
});
|
|
@@ -3251,7 +3500,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
3251
3500
|
}
|
|
3252
3501
|
if (hasShellTool && resolvedResultToolName === "shell") {
|
|
3253
3502
|
if (part.output.type === "json") {
|
|
3254
|
-
const parsedOutput = await (0,
|
|
3503
|
+
const parsedOutput = await (0, import_provider_utils25.validateTypes)({
|
|
3255
3504
|
value: part.output.value,
|
|
3256
3505
|
schema: shellOutputSchema
|
|
3257
3506
|
});
|
|
@@ -3282,7 +3531,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
3282
3531
|
break;
|
|
3283
3532
|
}
|
|
3284
3533
|
case "reasoning": {
|
|
3285
|
-
const providerOptions2 = await (0,
|
|
3534
|
+
const providerOptions2 = await (0, import_provider_utils25.parseProviderOptions)({
|
|
3286
3535
|
provider: providerOptionsName,
|
|
3287
3536
|
providerOptions: part.providerOptions,
|
|
3288
3537
|
schema: openaiResponsesReasoningProviderOptionsSchema
|
|
@@ -3379,6 +3628,44 @@ async function convertToOpenAIResponsesInput({
|
|
|
3379
3628
|
});
|
|
3380
3629
|
continue;
|
|
3381
3630
|
}
|
|
3631
|
+
const parallelToolCallMetadata = getParallelToolCallMetadata({
|
|
3632
|
+
providerOptions: part.providerOptions,
|
|
3633
|
+
providerOptionsName
|
|
3634
|
+
});
|
|
3635
|
+
const parallelToolResultGroup = parallelToolCallMetadata == null ? void 0 : parallelToolResultGroups.get(
|
|
3636
|
+
parallelToolCallMetadata.toolCallId
|
|
3637
|
+
);
|
|
3638
|
+
if (parallelToolCallMetadata != null && parallelToolResultGroup != null && hasSameParallelToolCall(
|
|
3639
|
+
parallelToolResultGroup.metadata,
|
|
3640
|
+
parallelToolCallMetadata
|
|
3641
|
+
)) {
|
|
3642
|
+
if (!emittedParallelToolResults.has(
|
|
3643
|
+
parallelToolResultGroup.metadata.toolCallId
|
|
3644
|
+
)) {
|
|
3645
|
+
emittedParallelToolResults.add(
|
|
3646
|
+
parallelToolResultGroup.metadata.toolCallId
|
|
3647
|
+
);
|
|
3648
|
+
const toolOutputs = await Promise.all(
|
|
3649
|
+
parallelToolResultGroup.results.map(
|
|
3650
|
+
async (result) => convertFunctionToolResultOutput({
|
|
3651
|
+
output: result.output,
|
|
3652
|
+
providerOptionsName,
|
|
3653
|
+
warnings
|
|
3654
|
+
})
|
|
3655
|
+
)
|
|
3656
|
+
);
|
|
3657
|
+
input.push({
|
|
3658
|
+
type: "function_call_output",
|
|
3659
|
+
call_id: parallelToolResultGroup.metadata.toolCallId,
|
|
3660
|
+
// The internal wrapper returns one output containing the child
|
|
3661
|
+
// results in the same order as the original tool_uses array.
|
|
3662
|
+
output: toolOutputs.map(
|
|
3663
|
+
(output2) => typeof output2 === "string" ? output2 : JSON.stringify(output2)
|
|
3664
|
+
).join("\n")
|
|
3665
|
+
});
|
|
3666
|
+
}
|
|
3667
|
+
continue;
|
|
3668
|
+
}
|
|
3382
3669
|
const output = part.output;
|
|
3383
3670
|
if (output.type === "execution-denied") {
|
|
3384
3671
|
const approvalId = (_x = (_w = output.providerOptions) == null ? void 0 : _w.openai) == null ? void 0 : _x.approvalId;
|
|
@@ -3390,7 +3677,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
3390
3677
|
part.toolName
|
|
3391
3678
|
);
|
|
3392
3679
|
if (resolvedToolName === "tool_search" && output.type === "json") {
|
|
3393
|
-
const parsedOutput = await (0,
|
|
3680
|
+
const parsedOutput = await (0, import_provider_utils25.validateTypes)({
|
|
3394
3681
|
value: output.value,
|
|
3395
3682
|
schema: toolSearchOutputSchema
|
|
3396
3683
|
});
|
|
@@ -3404,7 +3691,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
3404
3691
|
continue;
|
|
3405
3692
|
}
|
|
3406
3693
|
if (hasLocalShellTool && resolvedToolName === "local_shell" && output.type === "json") {
|
|
3407
|
-
const parsedOutput = await (0,
|
|
3694
|
+
const parsedOutput = await (0, import_provider_utils25.validateTypes)({
|
|
3408
3695
|
value: output.value,
|
|
3409
3696
|
schema: localShellOutputSchema
|
|
3410
3697
|
});
|
|
@@ -3416,7 +3703,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
3416
3703
|
continue;
|
|
3417
3704
|
}
|
|
3418
3705
|
if (hasShellTool && resolvedToolName === "shell" && output.type === "json") {
|
|
3419
|
-
const parsedOutput = await (0,
|
|
3706
|
+
const parsedOutput = await (0, import_provider_utils25.validateTypes)({
|
|
3420
3707
|
value: output.value,
|
|
3421
3708
|
schema: shellOutputSchema
|
|
3422
3709
|
});
|
|
@@ -3435,7 +3722,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
3435
3722
|
continue;
|
|
3436
3723
|
}
|
|
3437
3724
|
if (hasApplyPatchTool && part.toolName === "apply_patch" && output.type === "json") {
|
|
3438
|
-
const parsedOutput = await (0,
|
|
3725
|
+
const parsedOutput = await (0, import_provider_utils25.validateTypes)({
|
|
3439
3726
|
value: output.value,
|
|
3440
3727
|
schema: applyPatchOutputSchema
|
|
3441
3728
|
});
|
|
@@ -3519,7 +3806,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
3519
3806
|
});
|
|
3520
3807
|
return void 0;
|
|
3521
3808
|
}
|
|
3522
|
-
}).filter(
|
|
3809
|
+
}).filter(import_provider_utils25.isNonNullable);
|
|
3523
3810
|
break;
|
|
3524
3811
|
default:
|
|
3525
3812
|
outputValue = "";
|
|
@@ -3531,86 +3818,11 @@ async function convertToOpenAIResponsesInput({
|
|
|
3531
3818
|
});
|
|
3532
3819
|
continue;
|
|
3533
3820
|
}
|
|
3534
|
-
|
|
3535
|
-
|
|
3536
|
-
|
|
3537
|
-
|
|
3538
|
-
|
|
3539
|
-
break;
|
|
3540
|
-
case "execution-denied":
|
|
3541
|
-
contentValue = (_z = output.reason) != null ? _z : "Tool call execution denied.";
|
|
3542
|
-
break;
|
|
3543
|
-
case "json":
|
|
3544
|
-
case "error-json":
|
|
3545
|
-
contentValue = JSON.stringify(output.value);
|
|
3546
|
-
break;
|
|
3547
|
-
case "content":
|
|
3548
|
-
contentValue = output.value.map((item) => {
|
|
3549
|
-
var _a2, _b2, _c2, _d2, _e2;
|
|
3550
|
-
const promptCacheBreakpoint = getPromptCacheBreakpoint2(
|
|
3551
|
-
item.providerOptions,
|
|
3552
|
-
providerOptionsName
|
|
3553
|
-
);
|
|
3554
|
-
switch (item.type) {
|
|
3555
|
-
case "text": {
|
|
3556
|
-
return {
|
|
3557
|
-
type: "input_text",
|
|
3558
|
-
text: item.text,
|
|
3559
|
-
...promptCacheBreakpoint != null && {
|
|
3560
|
-
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
3561
|
-
}
|
|
3562
|
-
};
|
|
3563
|
-
}
|
|
3564
|
-
case "image-data": {
|
|
3565
|
-
return {
|
|
3566
|
-
type: "input_image",
|
|
3567
|
-
image_url: `data:${item.mediaType};base64,${item.data}`,
|
|
3568
|
-
detail: (_b2 = (_a2 = item.providerOptions) == null ? void 0 : _a2[providerOptionsName]) == null ? void 0 : _b2.imageDetail,
|
|
3569
|
-
...promptCacheBreakpoint != null && {
|
|
3570
|
-
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
3571
|
-
}
|
|
3572
|
-
};
|
|
3573
|
-
}
|
|
3574
|
-
case "image-url": {
|
|
3575
|
-
return {
|
|
3576
|
-
type: "input_image",
|
|
3577
|
-
image_url: item.url,
|
|
3578
|
-
detail: (_d2 = (_c2 = item.providerOptions) == null ? void 0 : _c2[providerOptionsName]) == null ? void 0 : _d2.imageDetail,
|
|
3579
|
-
...promptCacheBreakpoint != null && {
|
|
3580
|
-
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
3581
|
-
}
|
|
3582
|
-
};
|
|
3583
|
-
}
|
|
3584
|
-
case "file-data": {
|
|
3585
|
-
return {
|
|
3586
|
-
type: "input_file",
|
|
3587
|
-
filename: (_e2 = item.filename) != null ? _e2 : "data",
|
|
3588
|
-
file_data: `data:${item.mediaType};base64,${item.data}`,
|
|
3589
|
-
...promptCacheBreakpoint != null && {
|
|
3590
|
-
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
3591
|
-
}
|
|
3592
|
-
};
|
|
3593
|
-
}
|
|
3594
|
-
case "file-url": {
|
|
3595
|
-
return {
|
|
3596
|
-
type: "input_file",
|
|
3597
|
-
file_url: item.url,
|
|
3598
|
-
...promptCacheBreakpoint != null && {
|
|
3599
|
-
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
3600
|
-
}
|
|
3601
|
-
};
|
|
3602
|
-
}
|
|
3603
|
-
default: {
|
|
3604
|
-
warnings.push({
|
|
3605
|
-
type: "other",
|
|
3606
|
-
message: `unsupported tool content part type: ${item.type}`
|
|
3607
|
-
});
|
|
3608
|
-
return void 0;
|
|
3609
|
-
}
|
|
3610
|
-
}
|
|
3611
|
-
}).filter(import_provider_utils24.isNonNullable);
|
|
3612
|
-
break;
|
|
3613
|
-
}
|
|
3821
|
+
const contentValue = await convertFunctionToolResultOutput({
|
|
3822
|
+
output,
|
|
3823
|
+
providerOptionsName,
|
|
3824
|
+
warnings
|
|
3825
|
+
});
|
|
3614
3826
|
input.push({
|
|
3615
3827
|
type: "function_call_output",
|
|
3616
3828
|
call_id: part.toolCallId,
|
|
@@ -3662,7 +3874,7 @@ function mapOpenAIResponseFinishReason({
|
|
|
3662
3874
|
}
|
|
3663
3875
|
|
|
3664
3876
|
// src/responses/openai-responses-api.ts
|
|
3665
|
-
var
|
|
3877
|
+
var import_provider_utils26 = require("@ai-sdk/provider-utils");
|
|
3666
3878
|
var import_v418 = require("zod/v4");
|
|
3667
3879
|
var jsonValueSchema = import_v418.z.lazy(
|
|
3668
3880
|
() => import_v418.z.union([
|
|
@@ -3691,8 +3903,8 @@ var openaiResponsesErrorChunkSchema = import_v418.z.object({
|
|
|
3691
3903
|
message: import_v418.z.string(),
|
|
3692
3904
|
param: import_v418.z.string().nullish()
|
|
3693
3905
|
});
|
|
3694
|
-
var openaiResponsesChunkSchema = (0,
|
|
3695
|
-
() => (0,
|
|
3906
|
+
var openaiResponsesChunkSchema = (0, import_provider_utils26.lazySchema)(
|
|
3907
|
+
() => (0, import_provider_utils26.zodSchema)(
|
|
3696
3908
|
import_v418.z.union([
|
|
3697
3909
|
import_v418.z.object({
|
|
3698
3910
|
type: import_v418.z.literal("response.output_text.delta"),
|
|
@@ -4240,8 +4452,8 @@ var openaiResponsesChunkSchema = (0, import_provider_utils25.lazySchema)(
|
|
|
4240
4452
|
])
|
|
4241
4453
|
)
|
|
4242
4454
|
);
|
|
4243
|
-
var openaiResponsesResponseSchema = (0,
|
|
4244
|
-
() => (0,
|
|
4455
|
+
var openaiResponsesResponseSchema = (0, import_provider_utils26.lazySchema)(
|
|
4456
|
+
() => (0, import_provider_utils26.zodSchema)(
|
|
4245
4457
|
import_v418.z.object({
|
|
4246
4458
|
id: import_v418.z.string().optional(),
|
|
4247
4459
|
created_at: import_v418.z.number().optional(),
|
|
@@ -4555,7 +4767,7 @@ var openaiResponsesResponseSchema = (0, import_provider_utils25.lazySchema)(
|
|
|
4555
4767
|
);
|
|
4556
4768
|
|
|
4557
4769
|
// src/responses/openai-responses-options.ts
|
|
4558
|
-
var
|
|
4770
|
+
var import_provider_utils27 = require("@ai-sdk/provider-utils");
|
|
4559
4771
|
var import_v419 = require("zod/v4");
|
|
4560
4772
|
var TOP_LOGPROBS_MAX = 20;
|
|
4561
4773
|
var openaiResponsesReasoningModelIds = [
|
|
@@ -4627,8 +4839,8 @@ var openaiResponsesModelIds = [
|
|
|
4627
4839
|
"gpt-5-chat-latest",
|
|
4628
4840
|
...openaiResponsesReasoningModelIds
|
|
4629
4841
|
];
|
|
4630
|
-
var openaiLanguageModelResponsesOptionsSchema = (0,
|
|
4631
|
-
() => (0,
|
|
4842
|
+
var openaiLanguageModelResponsesOptionsSchema = (0, import_provider_utils27.lazySchema)(
|
|
4843
|
+
() => (0, import_provider_utils27.zodSchema)(
|
|
4632
4844
|
import_v419.z.object({
|
|
4633
4845
|
/**
|
|
4634
4846
|
* The ID of the OpenAI Conversation to continue.
|
|
@@ -4825,22 +5037,22 @@ var openaiLanguageModelResponsesOptionsSchema = (0, import_provider_utils26.lazy
|
|
|
4825
5037
|
);
|
|
4826
5038
|
|
|
4827
5039
|
// src/responses/openai-responses-prepare-tools.ts
|
|
4828
|
-
var
|
|
4829
|
-
var
|
|
5040
|
+
var import_provider9 = require("@ai-sdk/provider");
|
|
5041
|
+
var import_provider_utils35 = require("@ai-sdk/provider-utils");
|
|
4830
5042
|
|
|
4831
5043
|
// src/tool/code-interpreter.ts
|
|
4832
|
-
var
|
|
5044
|
+
var import_provider_utils28 = require("@ai-sdk/provider-utils");
|
|
4833
5045
|
var import_v420 = require("zod/v4");
|
|
4834
|
-
var codeInterpreterInputSchema = (0,
|
|
4835
|
-
() => (0,
|
|
5046
|
+
var codeInterpreterInputSchema = (0, import_provider_utils28.lazySchema)(
|
|
5047
|
+
() => (0, import_provider_utils28.zodSchema)(
|
|
4836
5048
|
import_v420.z.object({
|
|
4837
5049
|
code: import_v420.z.string().nullish(),
|
|
4838
5050
|
containerId: import_v420.z.string()
|
|
4839
5051
|
})
|
|
4840
5052
|
)
|
|
4841
5053
|
);
|
|
4842
|
-
var codeInterpreterOutputSchema = (0,
|
|
4843
|
-
() => (0,
|
|
5054
|
+
var codeInterpreterOutputSchema = (0, import_provider_utils28.lazySchema)(
|
|
5055
|
+
() => (0, import_provider_utils28.zodSchema)(
|
|
4844
5056
|
import_v420.z.object({
|
|
4845
5057
|
outputs: import_v420.z.array(
|
|
4846
5058
|
import_v420.z.discriminatedUnion("type", [
|
|
@@ -4851,8 +5063,8 @@ var codeInterpreterOutputSchema = (0, import_provider_utils27.lazySchema)(
|
|
|
4851
5063
|
})
|
|
4852
5064
|
)
|
|
4853
5065
|
);
|
|
4854
|
-
var codeInterpreterArgsSchema = (0,
|
|
4855
|
-
() => (0,
|
|
5066
|
+
var codeInterpreterArgsSchema = (0, import_provider_utils28.lazySchema)(
|
|
5067
|
+
() => (0, import_provider_utils28.zodSchema)(
|
|
4856
5068
|
import_v420.z.object({
|
|
4857
5069
|
container: import_v420.z.union([
|
|
4858
5070
|
import_v420.z.string(),
|
|
@@ -4863,7 +5075,7 @@ var codeInterpreterArgsSchema = (0, import_provider_utils27.lazySchema)(
|
|
|
4863
5075
|
})
|
|
4864
5076
|
)
|
|
4865
5077
|
);
|
|
4866
|
-
var codeInterpreterToolFactory = (0,
|
|
5078
|
+
var codeInterpreterToolFactory = (0, import_provider_utils28.createProviderToolFactoryWithOutputSchema)({
|
|
4867
5079
|
id: "openai.code_interpreter",
|
|
4868
5080
|
inputSchema: codeInterpreterInputSchema,
|
|
4869
5081
|
outputSchema: codeInterpreterOutputSchema
|
|
@@ -4873,7 +5085,7 @@ var codeInterpreter = (args = {}) => {
|
|
|
4873
5085
|
};
|
|
4874
5086
|
|
|
4875
5087
|
// src/tool/file-search.ts
|
|
4876
|
-
var
|
|
5088
|
+
var import_provider_utils29 = require("@ai-sdk/provider-utils");
|
|
4877
5089
|
var import_v421 = require("zod/v4");
|
|
4878
5090
|
var comparisonFilterSchema = import_v421.z.object({
|
|
4879
5091
|
key: import_v421.z.string(),
|
|
@@ -4886,8 +5098,8 @@ var compoundFilterSchema = import_v421.z.object({
|
|
|
4886
5098
|
import_v421.z.union([comparisonFilterSchema, import_v421.z.lazy(() => compoundFilterSchema)])
|
|
4887
5099
|
)
|
|
4888
5100
|
});
|
|
4889
|
-
var fileSearchArgsSchema = (0,
|
|
4890
|
-
() => (0,
|
|
5101
|
+
var fileSearchArgsSchema = (0, import_provider_utils29.lazySchema)(
|
|
5102
|
+
() => (0, import_provider_utils29.zodSchema)(
|
|
4891
5103
|
import_v421.z.object({
|
|
4892
5104
|
vectorStoreIds: import_v421.z.array(import_v421.z.string()),
|
|
4893
5105
|
maxNumResults: import_v421.z.number().optional(),
|
|
@@ -4899,8 +5111,8 @@ var fileSearchArgsSchema = (0, import_provider_utils28.lazySchema)(
|
|
|
4899
5111
|
})
|
|
4900
5112
|
)
|
|
4901
5113
|
);
|
|
4902
|
-
var fileSearchOutputSchema = (0,
|
|
4903
|
-
() => (0,
|
|
5114
|
+
var fileSearchOutputSchema = (0, import_provider_utils29.lazySchema)(
|
|
5115
|
+
() => (0, import_provider_utils29.zodSchema)(
|
|
4904
5116
|
import_v421.z.object({
|
|
4905
5117
|
queries: import_v421.z.array(import_v421.z.string()),
|
|
4906
5118
|
results: import_v421.z.array(
|
|
@@ -4915,17 +5127,17 @@ var fileSearchOutputSchema = (0, import_provider_utils28.lazySchema)(
|
|
|
4915
5127
|
})
|
|
4916
5128
|
)
|
|
4917
5129
|
);
|
|
4918
|
-
var fileSearch = (0,
|
|
5130
|
+
var fileSearch = (0, import_provider_utils29.createProviderToolFactoryWithOutputSchema)({
|
|
4919
5131
|
id: "openai.file_search",
|
|
4920
5132
|
inputSchema: import_v421.z.object({}),
|
|
4921
5133
|
outputSchema: fileSearchOutputSchema
|
|
4922
5134
|
});
|
|
4923
5135
|
|
|
4924
5136
|
// src/tool/image-generation.ts
|
|
4925
|
-
var
|
|
5137
|
+
var import_provider_utils30 = require("@ai-sdk/provider-utils");
|
|
4926
5138
|
var import_v422 = require("zod/v4");
|
|
4927
|
-
var imageGenerationArgsSchema = (0,
|
|
4928
|
-
() => (0,
|
|
5139
|
+
var imageGenerationArgsSchema = (0, import_provider_utils30.lazySchema)(
|
|
5140
|
+
() => (0, import_provider_utils30.zodSchema)(
|
|
4929
5141
|
import_v422.z.object({
|
|
4930
5142
|
background: import_v422.z.enum(["auto", "opaque", "transparent"]).optional(),
|
|
4931
5143
|
inputFidelity: import_v422.z.enum(["low", "high"]).optional(),
|
|
@@ -4943,11 +5155,11 @@ var imageGenerationArgsSchema = (0, import_provider_utils29.lazySchema)(
|
|
|
4943
5155
|
}).strict()
|
|
4944
5156
|
)
|
|
4945
5157
|
);
|
|
4946
|
-
var imageGenerationInputSchema = (0,
|
|
4947
|
-
var imageGenerationOutputSchema = (0,
|
|
4948
|
-
() => (0,
|
|
5158
|
+
var imageGenerationInputSchema = (0, import_provider_utils30.lazySchema)(() => (0, import_provider_utils30.zodSchema)(import_v422.z.object({})));
|
|
5159
|
+
var imageGenerationOutputSchema = (0, import_provider_utils30.lazySchema)(
|
|
5160
|
+
() => (0, import_provider_utils30.zodSchema)(import_v422.z.object({ result: import_v422.z.string() }))
|
|
4949
5161
|
);
|
|
4950
|
-
var imageGenerationToolFactory = (0,
|
|
5162
|
+
var imageGenerationToolFactory = (0, import_provider_utils30.createProviderToolFactoryWithOutputSchema)({
|
|
4951
5163
|
id: "openai.image_generation",
|
|
4952
5164
|
inputSchema: imageGenerationInputSchema,
|
|
4953
5165
|
outputSchema: imageGenerationOutputSchema
|
|
@@ -4957,10 +5169,10 @@ var imageGeneration = (args = {}) => {
|
|
|
4957
5169
|
};
|
|
4958
5170
|
|
|
4959
5171
|
// src/tool/custom.ts
|
|
4960
|
-
var
|
|
5172
|
+
var import_provider_utils31 = require("@ai-sdk/provider-utils");
|
|
4961
5173
|
var import_v423 = require("zod/v4");
|
|
4962
|
-
var customArgsSchema = (0,
|
|
4963
|
-
() => (0,
|
|
5174
|
+
var customArgsSchema = (0, import_provider_utils31.lazySchema)(
|
|
5175
|
+
() => (0, import_provider_utils31.zodSchema)(
|
|
4964
5176
|
import_v423.z.object({
|
|
4965
5177
|
name: import_v423.z.string(),
|
|
4966
5178
|
description: import_v423.z.string().optional(),
|
|
@@ -4977,14 +5189,14 @@ var customArgsSchema = (0, import_provider_utils30.lazySchema)(
|
|
|
4977
5189
|
})
|
|
4978
5190
|
)
|
|
4979
5191
|
);
|
|
4980
|
-
var customInputSchema = (0,
|
|
4981
|
-
var customToolFactory = (0,
|
|
5192
|
+
var customInputSchema = (0, import_provider_utils31.lazySchema)(() => (0, import_provider_utils31.zodSchema)(import_v423.z.string()));
|
|
5193
|
+
var customToolFactory = (0, import_provider_utils31.createProviderToolFactory)({
|
|
4982
5194
|
id: "openai.custom",
|
|
4983
5195
|
inputSchema: customInputSchema
|
|
4984
5196
|
});
|
|
4985
5197
|
|
|
4986
5198
|
// src/tool/mcp.ts
|
|
4987
|
-
var
|
|
5199
|
+
var import_provider_utils32 = require("@ai-sdk/provider-utils");
|
|
4988
5200
|
var import_v424 = require("zod/v4");
|
|
4989
5201
|
var jsonValueSchema2 = import_v424.z.lazy(
|
|
4990
5202
|
() => import_v424.z.union([
|
|
@@ -4996,8 +5208,8 @@ var jsonValueSchema2 = import_v424.z.lazy(
|
|
|
4996
5208
|
import_v424.z.record(import_v424.z.string(), jsonValueSchema2)
|
|
4997
5209
|
])
|
|
4998
5210
|
);
|
|
4999
|
-
var mcpArgsSchema = (0,
|
|
5000
|
-
() => (0,
|
|
5211
|
+
var mcpArgsSchema = (0, import_provider_utils32.lazySchema)(
|
|
5212
|
+
() => (0, import_provider_utils32.zodSchema)(
|
|
5001
5213
|
import_v424.z.object({
|
|
5002
5214
|
serverLabel: import_v424.z.string(),
|
|
5003
5215
|
allowedTools: import_v424.z.union([
|
|
@@ -5026,9 +5238,9 @@ var mcpArgsSchema = (0, import_provider_utils31.lazySchema)(
|
|
|
5026
5238
|
)
|
|
5027
5239
|
)
|
|
5028
5240
|
);
|
|
5029
|
-
var mcpInputSchema = (0,
|
|
5030
|
-
var mcpOutputSchema = (0,
|
|
5031
|
-
() => (0,
|
|
5241
|
+
var mcpInputSchema = (0, import_provider_utils32.lazySchema)(() => (0, import_provider_utils32.zodSchema)(import_v424.z.object({})));
|
|
5242
|
+
var mcpOutputSchema = (0, import_provider_utils32.lazySchema)(
|
|
5243
|
+
() => (0, import_provider_utils32.zodSchema)(
|
|
5032
5244
|
import_v424.z.object({
|
|
5033
5245
|
type: import_v424.z.literal("call"),
|
|
5034
5246
|
serverLabel: import_v424.z.string(),
|
|
@@ -5039,17 +5251,17 @@ var mcpOutputSchema = (0, import_provider_utils31.lazySchema)(
|
|
|
5039
5251
|
})
|
|
5040
5252
|
)
|
|
5041
5253
|
);
|
|
5042
|
-
var mcpToolFactory = (0,
|
|
5254
|
+
var mcpToolFactory = (0, import_provider_utils32.createProviderToolFactoryWithOutputSchema)({
|
|
5043
5255
|
id: "openai.mcp",
|
|
5044
5256
|
inputSchema: mcpInputSchema,
|
|
5045
5257
|
outputSchema: mcpOutputSchema
|
|
5046
5258
|
});
|
|
5047
5259
|
|
|
5048
5260
|
// src/tool/web-search.ts
|
|
5049
|
-
var
|
|
5261
|
+
var import_provider_utils33 = require("@ai-sdk/provider-utils");
|
|
5050
5262
|
var import_v425 = require("zod/v4");
|
|
5051
|
-
var webSearchArgsSchema = (0,
|
|
5052
|
-
() => (0,
|
|
5263
|
+
var webSearchArgsSchema = (0, import_provider_utils33.lazySchema)(
|
|
5264
|
+
() => (0, import_provider_utils33.zodSchema)(
|
|
5053
5265
|
import_v425.z.object({
|
|
5054
5266
|
externalWebAccess: import_v425.z.boolean().optional(),
|
|
5055
5267
|
filters: import_v425.z.object({
|
|
@@ -5067,9 +5279,9 @@ var webSearchArgsSchema = (0, import_provider_utils32.lazySchema)(
|
|
|
5067
5279
|
})
|
|
5068
5280
|
)
|
|
5069
5281
|
);
|
|
5070
|
-
var webSearchInputSchema = (0,
|
|
5071
|
-
var webSearchOutputSchema = (0,
|
|
5072
|
-
() => (0,
|
|
5282
|
+
var webSearchInputSchema = (0, import_provider_utils33.lazySchema)(() => (0, import_provider_utils33.zodSchema)(import_v425.z.object({})));
|
|
5283
|
+
var webSearchOutputSchema = (0, import_provider_utils33.lazySchema)(
|
|
5284
|
+
() => (0, import_provider_utils33.zodSchema)(
|
|
5073
5285
|
import_v425.z.object({
|
|
5074
5286
|
action: import_v425.z.discriminatedUnion("type", [
|
|
5075
5287
|
import_v425.z.object({
|
|
@@ -5096,7 +5308,7 @@ var webSearchOutputSchema = (0, import_provider_utils32.lazySchema)(
|
|
|
5096
5308
|
})
|
|
5097
5309
|
)
|
|
5098
5310
|
);
|
|
5099
|
-
var webSearchToolFactory = (0,
|
|
5311
|
+
var webSearchToolFactory = (0, import_provider_utils33.createProviderToolFactoryWithOutputSchema)({
|
|
5100
5312
|
id: "openai.web_search",
|
|
5101
5313
|
inputSchema: webSearchInputSchema,
|
|
5102
5314
|
outputSchema: webSearchOutputSchema
|
|
@@ -5104,10 +5316,10 @@ var webSearchToolFactory = (0, import_provider_utils32.createProviderToolFactory
|
|
|
5104
5316
|
var webSearch = (args = {}) => webSearchToolFactory(args);
|
|
5105
5317
|
|
|
5106
5318
|
// src/tool/web-search-preview.ts
|
|
5107
|
-
var
|
|
5319
|
+
var import_provider_utils34 = require("@ai-sdk/provider-utils");
|
|
5108
5320
|
var import_v426 = require("zod/v4");
|
|
5109
|
-
var webSearchPreviewArgsSchema = (0,
|
|
5110
|
-
() => (0,
|
|
5321
|
+
var webSearchPreviewArgsSchema = (0, import_provider_utils34.lazySchema)(
|
|
5322
|
+
() => (0, import_provider_utils34.zodSchema)(
|
|
5111
5323
|
import_v426.z.object({
|
|
5112
5324
|
searchContextSize: import_v426.z.enum(["low", "medium", "high"]).optional(),
|
|
5113
5325
|
userLocation: import_v426.z.object({
|
|
@@ -5120,11 +5332,11 @@ var webSearchPreviewArgsSchema = (0, import_provider_utils33.lazySchema)(
|
|
|
5120
5332
|
})
|
|
5121
5333
|
)
|
|
5122
5334
|
);
|
|
5123
|
-
var webSearchPreviewInputSchema = (0,
|
|
5124
|
-
() => (0,
|
|
5335
|
+
var webSearchPreviewInputSchema = (0, import_provider_utils34.lazySchema)(
|
|
5336
|
+
() => (0, import_provider_utils34.zodSchema)(import_v426.z.object({}))
|
|
5125
5337
|
);
|
|
5126
|
-
var webSearchPreviewOutputSchema = (0,
|
|
5127
|
-
() => (0,
|
|
5338
|
+
var webSearchPreviewOutputSchema = (0, import_provider_utils34.lazySchema)(
|
|
5339
|
+
() => (0, import_provider_utils34.zodSchema)(
|
|
5128
5340
|
import_v426.z.object({
|
|
5129
5341
|
action: import_v426.z.discriminatedUnion("type", [
|
|
5130
5342
|
import_v426.z.object({
|
|
@@ -5144,7 +5356,7 @@ var webSearchPreviewOutputSchema = (0, import_provider_utils33.lazySchema)(
|
|
|
5144
5356
|
})
|
|
5145
5357
|
)
|
|
5146
5358
|
);
|
|
5147
|
-
var webSearchPreview = (0,
|
|
5359
|
+
var webSearchPreview = (0, import_provider_utils34.createProviderToolFactoryWithOutputSchema)({
|
|
5148
5360
|
id: "openai.web_search_preview",
|
|
5149
5361
|
inputSchema: webSearchPreviewInputSchema,
|
|
5150
5362
|
outputSchema: webSearchPreviewOutputSchema
|
|
@@ -5204,7 +5416,7 @@ async function prepareResponsesTools({
|
|
|
5204
5416
|
namespaceTools.set(namespace.name, namespaceTool);
|
|
5205
5417
|
openaiTools.push(namespaceTool);
|
|
5206
5418
|
} else if (namespaceTool.description !== namespace.description) {
|
|
5207
|
-
throw new
|
|
5419
|
+
throw new import_provider9.UnsupportedFunctionalityError({
|
|
5208
5420
|
functionality: `conflicting descriptions for OpenAI tool namespace "${namespace.name}"`
|
|
5209
5421
|
});
|
|
5210
5422
|
}
|
|
@@ -5230,7 +5442,7 @@ async function prepareResponsesTools({
|
|
|
5230
5442
|
const openaiToolCountBefore = openaiTools.length;
|
|
5231
5443
|
switch (tool.id) {
|
|
5232
5444
|
case "openai.file_search": {
|
|
5233
|
-
const args = await (0,
|
|
5445
|
+
const args = await (0, import_provider_utils35.validateTypes)({
|
|
5234
5446
|
value: tool.args,
|
|
5235
5447
|
schema: fileSearchArgsSchema
|
|
5236
5448
|
});
|
|
@@ -5253,7 +5465,7 @@ async function prepareResponsesTools({
|
|
|
5253
5465
|
break;
|
|
5254
5466
|
}
|
|
5255
5467
|
case "openai.shell": {
|
|
5256
|
-
const args = await (0,
|
|
5468
|
+
const args = await (0, import_provider_utils35.validateTypes)({
|
|
5257
5469
|
value: tool.args,
|
|
5258
5470
|
schema: shellArgsSchema
|
|
5259
5471
|
});
|
|
@@ -5272,7 +5484,7 @@ async function prepareResponsesTools({
|
|
|
5272
5484
|
break;
|
|
5273
5485
|
}
|
|
5274
5486
|
case "openai.web_search_preview": {
|
|
5275
|
-
const args = await (0,
|
|
5487
|
+
const args = await (0, import_provider_utils35.validateTypes)({
|
|
5276
5488
|
value: tool.args,
|
|
5277
5489
|
schema: webSearchPreviewArgsSchema
|
|
5278
5490
|
});
|
|
@@ -5284,7 +5496,7 @@ async function prepareResponsesTools({
|
|
|
5284
5496
|
break;
|
|
5285
5497
|
}
|
|
5286
5498
|
case "openai.web_search": {
|
|
5287
|
-
const args = await (0,
|
|
5499
|
+
const args = await (0, import_provider_utils35.validateTypes)({
|
|
5288
5500
|
value: tool.args,
|
|
5289
5501
|
schema: webSearchArgsSchema
|
|
5290
5502
|
});
|
|
@@ -5301,7 +5513,7 @@ async function prepareResponsesTools({
|
|
|
5301
5513
|
break;
|
|
5302
5514
|
}
|
|
5303
5515
|
case "openai.code_interpreter": {
|
|
5304
|
-
const args = await (0,
|
|
5516
|
+
const args = await (0, import_provider_utils35.validateTypes)({
|
|
5305
5517
|
value: tool.args,
|
|
5306
5518
|
schema: codeInterpreterArgsSchema
|
|
5307
5519
|
});
|
|
@@ -5312,7 +5524,7 @@ async function prepareResponsesTools({
|
|
|
5312
5524
|
break;
|
|
5313
5525
|
}
|
|
5314
5526
|
case "openai.image_generation": {
|
|
5315
|
-
const args = await (0,
|
|
5527
|
+
const args = await (0, import_provider_utils35.validateTypes)({
|
|
5316
5528
|
value: tool.args,
|
|
5317
5529
|
schema: imageGenerationArgsSchema
|
|
5318
5530
|
});
|
|
@@ -5335,7 +5547,7 @@ async function prepareResponsesTools({
|
|
|
5335
5547
|
break;
|
|
5336
5548
|
}
|
|
5337
5549
|
case "openai.mcp": {
|
|
5338
|
-
const args = await (0,
|
|
5550
|
+
const args = await (0, import_provider_utils35.validateTypes)({
|
|
5339
5551
|
value: tool.args,
|
|
5340
5552
|
schema: mcpArgsSchema
|
|
5341
5553
|
});
|
|
@@ -5361,7 +5573,7 @@ async function prepareResponsesTools({
|
|
|
5361
5573
|
break;
|
|
5362
5574
|
}
|
|
5363
5575
|
case "openai.custom": {
|
|
5364
|
-
const args = await (0,
|
|
5576
|
+
const args = await (0, import_provider_utils35.validateTypes)({
|
|
5365
5577
|
value: tool.args,
|
|
5366
5578
|
schema: customArgsSchema
|
|
5367
5579
|
});
|
|
@@ -5375,7 +5587,7 @@ async function prepareResponsesTools({
|
|
|
5375
5587
|
break;
|
|
5376
5588
|
}
|
|
5377
5589
|
case "openai.tool_search": {
|
|
5378
|
-
const args = await (0,
|
|
5590
|
+
const args = await (0, import_provider_utils35.validateTypes)({
|
|
5379
5591
|
value: tool.args,
|
|
5380
5592
|
schema: toolSearchArgsSchema
|
|
5381
5593
|
});
|
|
@@ -5452,7 +5664,7 @@ async function prepareResponsesTools({
|
|
|
5452
5664
|
allowedToolEntries.push(resolution.entry);
|
|
5453
5665
|
}
|
|
5454
5666
|
if (allowedToolEntries.length === 0) {
|
|
5455
|
-
throw new
|
|
5667
|
+
throw new import_provider9.UnsupportedFunctionalityError({
|
|
5456
5668
|
functionality: `allowedTools with only tools that cannot be allow-listed (${droppedToolNames.join(
|
|
5457
5669
|
", "
|
|
5458
5670
|
)})`
|
|
@@ -5487,7 +5699,7 @@ async function prepareResponsesTools({
|
|
|
5487
5699
|
}
|
|
5488
5700
|
default: {
|
|
5489
5701
|
const _exhaustiveCheck = type;
|
|
5490
|
-
throw new
|
|
5702
|
+
throw new import_provider9.UnsupportedFunctionalityError({
|
|
5491
5703
|
functionality: `tool choice type: ${_exhaustiveCheck}`
|
|
5492
5704
|
});
|
|
5493
5705
|
}
|
|
@@ -5662,13 +5874,13 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5662
5874
|
warnings.push({ type: "unsupported", feature: "stopSequences" });
|
|
5663
5875
|
}
|
|
5664
5876
|
const providerOptionsName = this.config.provider.includes("azure") ? "azure" : "openai";
|
|
5665
|
-
let openaiOptions = await (0,
|
|
5877
|
+
let openaiOptions = await (0, import_provider_utils36.parseProviderOptions)({
|
|
5666
5878
|
provider: providerOptionsName,
|
|
5667
5879
|
providerOptions,
|
|
5668
5880
|
schema: openaiLanguageModelResponsesOptionsSchema
|
|
5669
5881
|
});
|
|
5670
5882
|
if (openaiOptions == null && providerOptionsName !== "openai") {
|
|
5671
|
-
openaiOptions = await (0,
|
|
5883
|
+
openaiOptions = await (0, import_provider_utils36.parseProviderOptions)({
|
|
5672
5884
|
provider: "openai",
|
|
5673
5885
|
providerOptions,
|
|
5674
5886
|
schema: openaiLanguageModelResponsesOptionsSchema
|
|
@@ -5682,7 +5894,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5682
5894
|
details: "conversation and previousResponseId cannot be used together"
|
|
5683
5895
|
});
|
|
5684
5896
|
}
|
|
5685
|
-
const toolNameMapping = (0,
|
|
5897
|
+
const toolNameMapping = (0, import_provider_utils36.createToolNameMapping)({
|
|
5686
5898
|
tools,
|
|
5687
5899
|
providerToolNames: {
|
|
5688
5900
|
"openai.code_interpreter": "code_interpreter",
|
|
@@ -5896,7 +6108,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5896
6108
|
};
|
|
5897
6109
|
}
|
|
5898
6110
|
async doGenerate(options) {
|
|
5899
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C;
|
|
6111
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E;
|
|
5900
6112
|
const {
|
|
5901
6113
|
args: body,
|
|
5902
6114
|
warnings,
|
|
@@ -5914,19 +6126,19 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5914
6126
|
responseHeaders,
|
|
5915
6127
|
value: response,
|
|
5916
6128
|
rawValue: rawResponse
|
|
5917
|
-
} = await (0,
|
|
6129
|
+
} = await (0, import_provider_utils36.postJsonToApi)({
|
|
5918
6130
|
url,
|
|
5919
|
-
headers: (0,
|
|
6131
|
+
headers: (0, import_provider_utils36.combineHeaders)(this.config.headers(), options.headers),
|
|
5920
6132
|
body,
|
|
5921
6133
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
5922
|
-
successfulResponseHandler: (0,
|
|
6134
|
+
successfulResponseHandler: (0, import_provider_utils36.createJsonResponseHandler)(
|
|
5923
6135
|
openaiResponsesResponseSchema
|
|
5924
6136
|
),
|
|
5925
6137
|
abortSignal: options.abortSignal,
|
|
5926
6138
|
fetch: this.config.fetch
|
|
5927
6139
|
});
|
|
5928
6140
|
if (response.error) {
|
|
5929
|
-
throw new
|
|
6141
|
+
throw new import_provider10.APICallError({
|
|
5930
6142
|
message: response.error.message,
|
|
5931
6143
|
url,
|
|
5932
6144
|
requestBodyValues: body,
|
|
@@ -5938,6 +6150,9 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5938
6150
|
}
|
|
5939
6151
|
const content = [];
|
|
5940
6152
|
const logprobs = [];
|
|
6153
|
+
const functionTools = (_b = (_a = options.tools) == null ? void 0 : _a.filter(
|
|
6154
|
+
(tool) => tool.type === "function"
|
|
6155
|
+
)) != null ? _b : [];
|
|
5941
6156
|
let hasFunctionCall = false;
|
|
5942
6157
|
const hostedToolSearchCallIds = [];
|
|
5943
6158
|
for (const part of response.output) {
|
|
@@ -5953,7 +6168,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5953
6168
|
providerMetadata: {
|
|
5954
6169
|
[providerOptionsName]: {
|
|
5955
6170
|
itemId: part.id,
|
|
5956
|
-
reasoningEncryptedContent: (
|
|
6171
|
+
reasoningEncryptedContent: (_c = part.encrypted_content) != null ? _c : null
|
|
5957
6172
|
}
|
|
5958
6173
|
}
|
|
5959
6174
|
});
|
|
@@ -5979,7 +6194,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5979
6194
|
break;
|
|
5980
6195
|
}
|
|
5981
6196
|
case "tool_search_call": {
|
|
5982
|
-
const toolCallId = (
|
|
6197
|
+
const toolCallId = (_d = part.call_id) != null ? _d : part.id;
|
|
5983
6198
|
const isHosted = part.execution === "server";
|
|
5984
6199
|
if (isHosted) {
|
|
5985
6200
|
hostedToolSearchCallIds.push(toolCallId);
|
|
@@ -6002,7 +6217,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6002
6217
|
break;
|
|
6003
6218
|
}
|
|
6004
6219
|
case "tool_search_output": {
|
|
6005
|
-
const toolCallId = (
|
|
6220
|
+
const toolCallId = (_f = (_e = part.call_id) != null ? _e : hostedToolSearchCallIds.shift()) != null ? _f : part.id;
|
|
6006
6221
|
content.push({
|
|
6007
6222
|
type: "tool-result",
|
|
6008
6223
|
toolCallId,
|
|
@@ -6073,7 +6288,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6073
6288
|
}
|
|
6074
6289
|
case "message": {
|
|
6075
6290
|
for (const contentPart of part.content) {
|
|
6076
|
-
if (((
|
|
6291
|
+
if (((_h = (_g = options.providerOptions) == null ? void 0 : _g[providerOptionsName]) == null ? void 0 : _h.logprobs) && contentPart.logprobs) {
|
|
6077
6292
|
logprobs.push(contentPart.logprobs);
|
|
6078
6293
|
}
|
|
6079
6294
|
const providerMetadata2 = {
|
|
@@ -6095,7 +6310,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6095
6310
|
content.push({
|
|
6096
6311
|
type: "source",
|
|
6097
6312
|
sourceType: "url",
|
|
6098
|
-
id: (
|
|
6313
|
+
id: (_k = (_j = (_i = this.config).generateId) == null ? void 0 : _j.call(_i)) != null ? _k : (0, import_provider_utils36.generateId)(),
|
|
6099
6314
|
url: annotation.url,
|
|
6100
6315
|
title: annotation.title
|
|
6101
6316
|
});
|
|
@@ -6103,7 +6318,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6103
6318
|
content.push({
|
|
6104
6319
|
type: "source",
|
|
6105
6320
|
sourceType: "document",
|
|
6106
|
-
id: (
|
|
6321
|
+
id: (_n = (_m = (_l = this.config).generateId) == null ? void 0 : _m.call(_l)) != null ? _n : (0, import_provider_utils36.generateId)(),
|
|
6107
6322
|
mediaType: "text/plain",
|
|
6108
6323
|
title: annotation.filename,
|
|
6109
6324
|
filename: annotation.filename,
|
|
@@ -6119,7 +6334,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6119
6334
|
content.push({
|
|
6120
6335
|
type: "source",
|
|
6121
6336
|
sourceType: "document",
|
|
6122
|
-
id: (
|
|
6337
|
+
id: (_q = (_p = (_o = this.config).generateId) == null ? void 0 : _p.call(_o)) != null ? _q : (0, import_provider_utils36.generateId)(),
|
|
6123
6338
|
mediaType: "text/plain",
|
|
6124
6339
|
title: annotation.filename,
|
|
6125
6340
|
filename: annotation.filename,
|
|
@@ -6135,7 +6350,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6135
6350
|
content.push({
|
|
6136
6351
|
type: "source",
|
|
6137
6352
|
sourceType: "document",
|
|
6138
|
-
id: (
|
|
6353
|
+
id: (_t = (_s = (_r = this.config).generateId) == null ? void 0 : _s.call(_r)) != null ? _t : (0, import_provider_utils36.generateId)(),
|
|
6139
6354
|
mediaType: "application/octet-stream",
|
|
6140
6355
|
title: annotation.file_id,
|
|
6141
6356
|
filename: annotation.file_id,
|
|
@@ -6154,6 +6369,20 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6154
6369
|
}
|
|
6155
6370
|
case "function_call": {
|
|
6156
6371
|
hasFunctionCall = true;
|
|
6372
|
+
const expandedToolCalls = await expandParallelToolCall({
|
|
6373
|
+
toolCall: {
|
|
6374
|
+
toolCallId: part.call_id,
|
|
6375
|
+
toolName: part.name,
|
|
6376
|
+
input: part.arguments
|
|
6377
|
+
},
|
|
6378
|
+
tools: functionTools,
|
|
6379
|
+
providerOptionsName,
|
|
6380
|
+
itemId: part.id
|
|
6381
|
+
});
|
|
6382
|
+
if (expandedToolCalls != null) {
|
|
6383
|
+
content.push(...expandedToolCalls);
|
|
6384
|
+
break;
|
|
6385
|
+
}
|
|
6157
6386
|
content.push({
|
|
6158
6387
|
type: "tool-call",
|
|
6159
6388
|
toolCallId: part.call_id,
|
|
@@ -6205,7 +6434,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6205
6434
|
break;
|
|
6206
6435
|
}
|
|
6207
6436
|
case "mcp_call": {
|
|
6208
|
-
const toolCallId = part.approval_request_id != null ? (
|
|
6437
|
+
const toolCallId = part.approval_request_id != null ? (_u = approvalRequestIdToDummyToolCallIdFromPrompt[part.approval_request_id]) != null ? _u : part.id : part.id;
|
|
6209
6438
|
const toolName = `mcp.${part.name}`;
|
|
6210
6439
|
content.push({
|
|
6211
6440
|
type: "tool-call",
|
|
@@ -6239,8 +6468,8 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6239
6468
|
break;
|
|
6240
6469
|
}
|
|
6241
6470
|
case "mcp_approval_request": {
|
|
6242
|
-
const approvalRequestId = (
|
|
6243
|
-
const dummyToolCallId = (
|
|
6471
|
+
const approvalRequestId = (_v = part.approval_request_id) != null ? _v : part.id;
|
|
6472
|
+
const dummyToolCallId = (_y = (_x = (_w = this.config).generateId) == null ? void 0 : _x.call(_w)) != null ? _y : (0, import_provider_utils36.generateId)();
|
|
6244
6473
|
const toolName = `mcp.${part.name}`;
|
|
6245
6474
|
content.push({
|
|
6246
6475
|
type: "tool-call",
|
|
@@ -6290,13 +6519,13 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6290
6519
|
toolName: toolNameMapping.toCustomToolName("file_search"),
|
|
6291
6520
|
result: {
|
|
6292
6521
|
queries: part.queries,
|
|
6293
|
-
results: (
|
|
6522
|
+
results: (_A = (_z = part.results) == null ? void 0 : _z.map((result) => ({
|
|
6294
6523
|
attributes: result.attributes,
|
|
6295
6524
|
fileId: result.file_id,
|
|
6296
6525
|
filename: result.filename,
|
|
6297
6526
|
score: result.score,
|
|
6298
6527
|
text: result.text
|
|
6299
|
-
}))) != null ?
|
|
6528
|
+
}))) != null ? _A : null
|
|
6300
6529
|
}
|
|
6301
6530
|
});
|
|
6302
6531
|
break;
|
|
@@ -6346,7 +6575,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6346
6575
|
responseId: response.id,
|
|
6347
6576
|
...logprobs.length > 0 ? { logprobs } : {},
|
|
6348
6577
|
...typeof response.service_tier === "string" ? { serviceTier: response.service_tier } : {},
|
|
6349
|
-
...((
|
|
6578
|
+
...((_B = response.reasoning) == null ? void 0 : _B.context) != null ? { reasoningContext: response.reasoning.context } : {}
|
|
6350
6579
|
}
|
|
6351
6580
|
};
|
|
6352
6581
|
const usage = response.usage;
|
|
@@ -6354,10 +6583,10 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6354
6583
|
content,
|
|
6355
6584
|
finishReason: {
|
|
6356
6585
|
unified: mapOpenAIResponseFinishReason({
|
|
6357
|
-
finishReason: (
|
|
6586
|
+
finishReason: (_C = response.incomplete_details) == null ? void 0 : _C.reason,
|
|
6358
6587
|
hasFunctionCall
|
|
6359
6588
|
}),
|
|
6360
|
-
raw: (
|
|
6589
|
+
raw: (_E = (_D = response.incomplete_details) == null ? void 0 : _D.reason) != null ? _E : void 0
|
|
6361
6590
|
},
|
|
6362
6591
|
usage: convertOpenAIResponsesUsage(usage),
|
|
6363
6592
|
request: { body },
|
|
@@ -6373,6 +6602,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6373
6602
|
};
|
|
6374
6603
|
}
|
|
6375
6604
|
async doStream(options) {
|
|
6605
|
+
var _a, _b;
|
|
6376
6606
|
const {
|
|
6377
6607
|
args: body,
|
|
6378
6608
|
warnings,
|
|
@@ -6386,15 +6616,15 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6386
6616
|
path: "/responses",
|
|
6387
6617
|
modelId: this.modelId
|
|
6388
6618
|
});
|
|
6389
|
-
const { responseHeaders, value: response } = await (0,
|
|
6619
|
+
const { responseHeaders, value: response } = await (0, import_provider_utils36.postJsonToApi)({
|
|
6390
6620
|
url,
|
|
6391
|
-
headers: (0,
|
|
6621
|
+
headers: (0, import_provider_utils36.combineHeaders)(this.config.headers(), options.headers),
|
|
6392
6622
|
body: {
|
|
6393
6623
|
...body,
|
|
6394
6624
|
stream: true
|
|
6395
6625
|
},
|
|
6396
6626
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
6397
|
-
successfulResponseHandler: (0,
|
|
6627
|
+
successfulResponseHandler: (0, import_provider_utils36.createEventSourceResponseHandler)(
|
|
6398
6628
|
openaiResponsesChunkSchema
|
|
6399
6629
|
),
|
|
6400
6630
|
abortSignal: options.abortSignal,
|
|
@@ -6410,6 +6640,9 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6410
6640
|
});
|
|
6411
6641
|
const self = this;
|
|
6412
6642
|
const approvalRequestIdToDummyToolCallIdFromPrompt = extractApprovalRequestIdToToolCallIdMapping(options.prompt);
|
|
6643
|
+
const functionTools = (_b = (_a = options.tools) == null ? void 0 : _a.filter(
|
|
6644
|
+
(tool) => tool.type === "function"
|
|
6645
|
+
)) != null ? _b : [];
|
|
6413
6646
|
const approvalRequestIdToDummyToolCallIdFromStream = /* @__PURE__ */ new Map();
|
|
6414
6647
|
let finishReason = {
|
|
6415
6648
|
unified: "other",
|
|
@@ -6434,7 +6667,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6434
6667
|
controller.enqueue({ type: "stream-start", warnings });
|
|
6435
6668
|
},
|
|
6436
6669
|
transform(chunk, controller) {
|
|
6437
|
-
var
|
|
6670
|
+
var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P;
|
|
6438
6671
|
if (options.includeRawChunks) {
|
|
6439
6672
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
6440
6673
|
}
|
|
@@ -6453,15 +6686,23 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6453
6686
|
const value = chunk.value;
|
|
6454
6687
|
if (isResponseOutputItemAddedChunk(value)) {
|
|
6455
6688
|
if (value.item.type === "function_call") {
|
|
6689
|
+
const suppressInputStreaming = isUndeclaredParallelToolCall({
|
|
6690
|
+
toolName: value.item.name,
|
|
6691
|
+
tools: functionTools
|
|
6692
|
+
});
|
|
6456
6693
|
ongoingToolCalls[value.output_index] = {
|
|
6457
6694
|
toolName: value.item.name,
|
|
6458
|
-
toolCallId: value.item.call_id
|
|
6695
|
+
toolCallId: value.item.call_id,
|
|
6696
|
+
suppressInputStreaming,
|
|
6697
|
+
bufferedInputDeltas: suppressInputStreaming ? [] : void 0
|
|
6459
6698
|
};
|
|
6460
|
-
|
|
6461
|
-
|
|
6462
|
-
|
|
6463
|
-
|
|
6464
|
-
|
|
6699
|
+
if (!suppressInputStreaming) {
|
|
6700
|
+
controller.enqueue({
|
|
6701
|
+
type: "tool-input-start",
|
|
6702
|
+
id: value.item.call_id,
|
|
6703
|
+
toolName: value.item.name
|
|
6704
|
+
});
|
|
6705
|
+
}
|
|
6465
6706
|
} else if (value.item.type === "custom_tool_call") {
|
|
6466
6707
|
const toolName = toolNameMapping.toCustomToolName(
|
|
6467
6708
|
value.item.name
|
|
@@ -6556,7 +6797,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6556
6797
|
ongoingToolCalls[value.output_index] = {
|
|
6557
6798
|
toolName,
|
|
6558
6799
|
toolCallId,
|
|
6559
|
-
toolSearchExecution: (
|
|
6800
|
+
toolSearchExecution: (_a2 = value.item.execution) != null ? _a2 : "server"
|
|
6560
6801
|
};
|
|
6561
6802
|
if (isHosted) {
|
|
6562
6803
|
controller.enqueue({
|
|
@@ -6613,7 +6854,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6613
6854
|
} else if (value.item.type === "shell_call_output") {
|
|
6614
6855
|
} else if (value.item.type === "message") {
|
|
6615
6856
|
ongoingAnnotations.splice(0, ongoingAnnotations.length);
|
|
6616
|
-
activeMessagePhase = (
|
|
6857
|
+
activeMessagePhase = (_b2 = value.item.phase) != null ? _b2 : void 0;
|
|
6617
6858
|
controller.enqueue({
|
|
6618
6859
|
type: "text-start",
|
|
6619
6860
|
id: value.item.id,
|
|
@@ -6660,31 +6901,99 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6660
6901
|
}
|
|
6661
6902
|
});
|
|
6662
6903
|
} else if (value.item.type === "function_call") {
|
|
6904
|
+
const item = value.item;
|
|
6905
|
+
const ongoingToolCall = ongoingToolCalls[value.output_index];
|
|
6663
6906
|
ongoingToolCalls[value.output_index] = void 0;
|
|
6664
6907
|
hasFunctionCall = true;
|
|
6665
|
-
|
|
6666
|
-
|
|
6667
|
-
|
|
6668
|
-
|
|
6669
|
-
|
|
6670
|
-
|
|
6671
|
-
|
|
6908
|
+
const suppressInputStreaming = (_e = ongoingToolCall == null ? void 0 : ongoingToolCall.suppressInputStreaming) != null ? _e : isUndeclaredParallelToolCall({
|
|
6909
|
+
toolName: item.name,
|
|
6910
|
+
tools: functionTools
|
|
6911
|
+
});
|
|
6912
|
+
const enqueueUnexpandedToolCall = () => {
|
|
6913
|
+
var _a3;
|
|
6914
|
+
if (suppressInputStreaming) {
|
|
6915
|
+
controller.enqueue({
|
|
6916
|
+
type: "tool-input-start",
|
|
6917
|
+
id: item.call_id,
|
|
6918
|
+
toolName: item.name
|
|
6919
|
+
});
|
|
6920
|
+
const bufferedInputDeltas = (_a3 = ongoingToolCall == null ? void 0 : ongoingToolCall.bufferedInputDeltas) != null ? _a3 : [];
|
|
6921
|
+
if (bufferedInputDeltas.length > 0) {
|
|
6922
|
+
for (const delta of bufferedInputDeltas) {
|
|
6923
|
+
controller.enqueue({
|
|
6924
|
+
type: "tool-input-delta",
|
|
6925
|
+
id: item.call_id,
|
|
6926
|
+
delta
|
|
6927
|
+
});
|
|
6672
6928
|
}
|
|
6929
|
+
} else if (item.arguments.length > 0) {
|
|
6930
|
+
controller.enqueue({
|
|
6931
|
+
type: "tool-input-delta",
|
|
6932
|
+
id: item.call_id,
|
|
6933
|
+
delta: item.arguments
|
|
6934
|
+
});
|
|
6673
6935
|
}
|
|
6674
6936
|
}
|
|
6675
|
-
|
|
6676
|
-
|
|
6677
|
-
|
|
6678
|
-
|
|
6679
|
-
|
|
6680
|
-
|
|
6681
|
-
|
|
6682
|
-
|
|
6683
|
-
|
|
6684
|
-
|
|
6685
|
-
|
|
6937
|
+
controller.enqueue({
|
|
6938
|
+
type: "tool-input-end",
|
|
6939
|
+
id: item.call_id,
|
|
6940
|
+
...item.namespace != null && {
|
|
6941
|
+
providerMetadata: {
|
|
6942
|
+
[providerOptionsName]: {
|
|
6943
|
+
namespace: item.namespace
|
|
6944
|
+
}
|
|
6945
|
+
}
|
|
6946
|
+
}
|
|
6947
|
+
});
|
|
6948
|
+
controller.enqueue({
|
|
6949
|
+
type: "tool-call",
|
|
6950
|
+
toolCallId: item.call_id,
|
|
6951
|
+
toolName: item.name,
|
|
6952
|
+
input: item.arguments,
|
|
6953
|
+
providerMetadata: {
|
|
6954
|
+
[providerOptionsName]: {
|
|
6955
|
+
itemId: item.id,
|
|
6956
|
+
...item.namespace != null && {
|
|
6957
|
+
namespace: item.namespace
|
|
6958
|
+
}
|
|
6686
6959
|
}
|
|
6687
6960
|
}
|
|
6961
|
+
});
|
|
6962
|
+
};
|
|
6963
|
+
if (!suppressInputStreaming) {
|
|
6964
|
+
enqueueUnexpandedToolCall();
|
|
6965
|
+
return;
|
|
6966
|
+
}
|
|
6967
|
+
return expandParallelToolCall({
|
|
6968
|
+
toolCall: {
|
|
6969
|
+
toolCallId: item.call_id,
|
|
6970
|
+
toolName: item.name,
|
|
6971
|
+
input: item.arguments
|
|
6972
|
+
},
|
|
6973
|
+
tools: functionTools,
|
|
6974
|
+
providerOptionsName,
|
|
6975
|
+
itemId: item.id
|
|
6976
|
+
}).then((expandedToolCalls) => {
|
|
6977
|
+
if (expandedToolCalls == null) {
|
|
6978
|
+
enqueueUnexpandedToolCall();
|
|
6979
|
+
return;
|
|
6980
|
+
}
|
|
6981
|
+
for (const toolCall of expandedToolCalls) {
|
|
6982
|
+
controller.enqueue({
|
|
6983
|
+
type: "tool-input-start",
|
|
6984
|
+
id: toolCall.toolCallId,
|
|
6985
|
+
toolName: toolCall.toolName
|
|
6986
|
+
});
|
|
6987
|
+
controller.enqueue({
|
|
6988
|
+
type: "tool-input-delta",
|
|
6989
|
+
id: toolCall.toolCallId,
|
|
6990
|
+
delta: toolCall.input
|
|
6991
|
+
});
|
|
6992
|
+
controller.enqueue({
|
|
6993
|
+
type: "tool-input-end",
|
|
6994
|
+
id: toolCall.toolCallId
|
|
6995
|
+
});
|
|
6996
|
+
controller.enqueue(toolCall);
|
|
6688
6997
|
}
|
|
6689
6998
|
});
|
|
6690
6999
|
} else if (value.item.type === "custom_tool_call") {
|
|
@@ -6748,13 +7057,13 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6748
7057
|
toolName: toolNameMapping.toCustomToolName("file_search"),
|
|
6749
7058
|
result: {
|
|
6750
7059
|
queries: value.item.queries,
|
|
6751
|
-
results: (
|
|
7060
|
+
results: (_g = (_f = value.item.results) == null ? void 0 : _f.map((result2) => ({
|
|
6752
7061
|
attributes: result2.attributes,
|
|
6753
7062
|
fileId: result2.file_id,
|
|
6754
7063
|
filename: result2.filename,
|
|
6755
7064
|
score: result2.score,
|
|
6756
7065
|
text: result2.text
|
|
6757
|
-
}))) != null ?
|
|
7066
|
+
}))) != null ? _g : null
|
|
6758
7067
|
}
|
|
6759
7068
|
});
|
|
6760
7069
|
} else if (value.item.type === "code_interpreter_call") {
|
|
@@ -6780,7 +7089,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6780
7089
|
const toolCall = ongoingToolCalls[value.output_index];
|
|
6781
7090
|
const isHosted = value.item.execution === "server";
|
|
6782
7091
|
if (toolCall != null) {
|
|
6783
|
-
const toolCallId = isHosted ? toolCall.toolCallId : (
|
|
7092
|
+
const toolCallId = isHosted ? toolCall.toolCallId : (_h = value.item.call_id) != null ? _h : value.item.id;
|
|
6784
7093
|
if (isHosted) {
|
|
6785
7094
|
hostedToolSearchCallIds.push(toolCallId);
|
|
6786
7095
|
} else {
|
|
@@ -6812,7 +7121,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6812
7121
|
}
|
|
6813
7122
|
ongoingToolCalls[value.output_index] = void 0;
|
|
6814
7123
|
} else if (value.item.type === "tool_search_output") {
|
|
6815
|
-
const toolCallId = (
|
|
7124
|
+
const toolCallId = (_j = (_i = value.item.call_id) != null ? _i : hostedToolSearchCallIds.shift()) != null ? _j : value.item.id;
|
|
6816
7125
|
controller.enqueue({
|
|
6817
7126
|
type: "tool-result",
|
|
6818
7127
|
toolCallId,
|
|
@@ -6828,10 +7137,10 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6828
7137
|
});
|
|
6829
7138
|
} else if (value.item.type === "mcp_call") {
|
|
6830
7139
|
ongoingToolCalls[value.output_index] = void 0;
|
|
6831
|
-
const approvalRequestId = (
|
|
6832
|
-
const aliasedToolCallId = approvalRequestId != null ? (
|
|
7140
|
+
const approvalRequestId = (_k = value.item.approval_request_id) != null ? _k : void 0;
|
|
7141
|
+
const aliasedToolCallId = approvalRequestId != null ? (_m = (_l = approvalRequestIdToDummyToolCallIdFromStream.get(
|
|
6833
7142
|
approvalRequestId
|
|
6834
|
-
)) != null ?
|
|
7143
|
+
)) != null ? _l : approvalRequestIdToDummyToolCallIdFromPrompt[approvalRequestId]) != null ? _m : value.item.id : value.item.id;
|
|
6835
7144
|
const toolName = `mcp.${value.item.name}`;
|
|
6836
7145
|
controller.enqueue({
|
|
6837
7146
|
type: "tool-call",
|
|
@@ -6901,8 +7210,8 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6901
7210
|
ongoingToolCalls[value.output_index] = void 0;
|
|
6902
7211
|
} else if (value.item.type === "mcp_approval_request") {
|
|
6903
7212
|
ongoingToolCalls[value.output_index] = void 0;
|
|
6904
|
-
const dummyToolCallId = (
|
|
6905
|
-
const approvalRequestId = (
|
|
7213
|
+
const dummyToolCallId = (_p = (_o = (_n = self.config).generateId) == null ? void 0 : _o.call(_n)) != null ? _p : (0, import_provider_utils36.generateId)();
|
|
7214
|
+
const approvalRequestId = (_q = value.item.approval_request_id) != null ? _q : value.item.id;
|
|
6906
7215
|
approvalRequestIdToDummyToolCallIdFromStream.set(
|
|
6907
7216
|
approvalRequestId,
|
|
6908
7217
|
dummyToolCallId
|
|
@@ -6991,7 +7300,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6991
7300
|
providerMetadata: {
|
|
6992
7301
|
[providerOptionsName]: {
|
|
6993
7302
|
itemId: value.item.id,
|
|
6994
|
-
reasoningEncryptedContent: (
|
|
7303
|
+
reasoningEncryptedContent: (_r = value.item.encrypted_content) != null ? _r : null
|
|
6995
7304
|
}
|
|
6996
7305
|
}
|
|
6997
7306
|
});
|
|
@@ -7001,11 +7310,15 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
7001
7310
|
} else if (isResponseFunctionCallArgumentsDeltaChunk(value)) {
|
|
7002
7311
|
const toolCall = ongoingToolCalls[value.output_index];
|
|
7003
7312
|
if (toolCall != null) {
|
|
7004
|
-
|
|
7005
|
-
|
|
7006
|
-
|
|
7007
|
-
|
|
7008
|
-
|
|
7313
|
+
if (toolCall.suppressInputStreaming) {
|
|
7314
|
+
(_s = toolCall.bufferedInputDeltas) == null ? void 0 : _s.push(value.delta);
|
|
7315
|
+
} else {
|
|
7316
|
+
controller.enqueue({
|
|
7317
|
+
type: "tool-input-delta",
|
|
7318
|
+
id: toolCall.toolCallId,
|
|
7319
|
+
delta: value.delta
|
|
7320
|
+
});
|
|
7321
|
+
}
|
|
7009
7322
|
}
|
|
7010
7323
|
} else if (isResponseCustomToolCallInputDeltaChunk(value)) {
|
|
7011
7324
|
const toolCall = ongoingToolCalls[value.output_index];
|
|
@@ -7104,7 +7417,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
7104
7417
|
id: value.item_id,
|
|
7105
7418
|
delta: value.delta
|
|
7106
7419
|
});
|
|
7107
|
-
if (((
|
|
7420
|
+
if (((_u = (_t = options.providerOptions) == null ? void 0 : _t[providerOptionsName]) == null ? void 0 : _u.logprobs) && value.logprobs) {
|
|
7108
7421
|
logprobs.push(value.logprobs);
|
|
7109
7422
|
}
|
|
7110
7423
|
} else if (value.type === "response.reasoning_summary_part.added") {
|
|
@@ -7133,7 +7446,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
7133
7446
|
providerMetadata: {
|
|
7134
7447
|
[providerOptionsName]: {
|
|
7135
7448
|
itemId: value.item_id,
|
|
7136
|
-
reasoningEncryptedContent: (
|
|
7449
|
+
reasoningEncryptedContent: (_w = (_v = activeReasoning[value.item_id]) == null ? void 0 : _v.encryptedContent) != null ? _w : null
|
|
7137
7450
|
}
|
|
7138
7451
|
}
|
|
7139
7452
|
});
|
|
@@ -7167,20 +7480,20 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
7167
7480
|
} else if (isResponseFinishedChunk(value)) {
|
|
7168
7481
|
finishReason = {
|
|
7169
7482
|
unified: mapOpenAIResponseFinishReason({
|
|
7170
|
-
finishReason: (
|
|
7483
|
+
finishReason: (_x = value.response.incomplete_details) == null ? void 0 : _x.reason,
|
|
7171
7484
|
hasFunctionCall
|
|
7172
7485
|
}),
|
|
7173
|
-
raw: (
|
|
7486
|
+
raw: (_z = (_y = value.response.incomplete_details) == null ? void 0 : _y.reason) != null ? _z : void 0
|
|
7174
7487
|
};
|
|
7175
7488
|
usage = value.response.usage;
|
|
7176
7489
|
if (typeof value.response.service_tier === "string") {
|
|
7177
7490
|
serviceTier = value.response.service_tier;
|
|
7178
7491
|
}
|
|
7179
|
-
if (((
|
|
7492
|
+
if (((_A = value.response.reasoning) == null ? void 0 : _A.context) != null) {
|
|
7180
7493
|
reasoningContext = value.response.reasoning.context;
|
|
7181
7494
|
}
|
|
7182
7495
|
} else if (isResponseFailedChunk(value)) {
|
|
7183
|
-
const incompleteReason = (
|
|
7496
|
+
const incompleteReason = (_B = value.response.incomplete_details) == null ? void 0 : _B.reason;
|
|
7184
7497
|
finishReason = {
|
|
7185
7498
|
unified: incompleteReason ? mapOpenAIResponseFinishReason({
|
|
7186
7499
|
finishReason: incompleteReason,
|
|
@@ -7188,8 +7501,8 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
7188
7501
|
}) : "error",
|
|
7189
7502
|
raw: incompleteReason != null ? incompleteReason : "error"
|
|
7190
7503
|
};
|
|
7191
|
-
usage = (
|
|
7192
|
-
if (((
|
|
7504
|
+
usage = (_C = value.response.usage) != null ? _C : void 0;
|
|
7505
|
+
if (((_D = value.response.reasoning) == null ? void 0 : _D.context) != null) {
|
|
7193
7506
|
reasoningContext = value.response.reasoning.context;
|
|
7194
7507
|
}
|
|
7195
7508
|
if (!encounteredStreamError && value.response.error != null) {
|
|
@@ -7213,7 +7526,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
7213
7526
|
controller.enqueue({
|
|
7214
7527
|
type: "source",
|
|
7215
7528
|
sourceType: "url",
|
|
7216
|
-
id: (
|
|
7529
|
+
id: (_G = (_F = (_E = self.config).generateId) == null ? void 0 : _F.call(_E)) != null ? _G : (0, import_provider_utils36.generateId)(),
|
|
7217
7530
|
url: value.annotation.url,
|
|
7218
7531
|
title: value.annotation.title
|
|
7219
7532
|
});
|
|
@@ -7221,7 +7534,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
7221
7534
|
controller.enqueue({
|
|
7222
7535
|
type: "source",
|
|
7223
7536
|
sourceType: "document",
|
|
7224
|
-
id: (
|
|
7537
|
+
id: (_J = (_I = (_H = self.config).generateId) == null ? void 0 : _I.call(_H)) != null ? _J : (0, import_provider_utils36.generateId)(),
|
|
7225
7538
|
mediaType: "text/plain",
|
|
7226
7539
|
title: value.annotation.filename,
|
|
7227
7540
|
filename: value.annotation.filename,
|
|
@@ -7237,7 +7550,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
7237
7550
|
controller.enqueue({
|
|
7238
7551
|
type: "source",
|
|
7239
7552
|
sourceType: "document",
|
|
7240
|
-
id: (
|
|
7553
|
+
id: (_M = (_L = (_K = self.config).generateId) == null ? void 0 : _L.call(_K)) != null ? _M : (0, import_provider_utils36.generateId)(),
|
|
7241
7554
|
mediaType: "text/plain",
|
|
7242
7555
|
title: value.annotation.filename,
|
|
7243
7556
|
filename: value.annotation.filename,
|
|
@@ -7253,7 +7566,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
7253
7566
|
controller.enqueue({
|
|
7254
7567
|
type: "source",
|
|
7255
7568
|
sourceType: "document",
|
|
7256
|
-
id: (
|
|
7569
|
+
id: (_P = (_O = (_N = self.config).generateId) == null ? void 0 : _O.call(_N)) != null ? _P : (0, import_provider_utils36.generateId)(),
|
|
7257
7570
|
mediaType: "application/octet-stream",
|
|
7258
7571
|
title: value.annotation.file_id,
|
|
7259
7572
|
filename: value.annotation.file_id,
|
|
@@ -7273,6 +7586,24 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
7273
7586
|
}
|
|
7274
7587
|
},
|
|
7275
7588
|
flush(controller) {
|
|
7589
|
+
var _a2;
|
|
7590
|
+
for (const toolCall of Object.values(ongoingToolCalls)) {
|
|
7591
|
+
if (!(toolCall == null ? void 0 : toolCall.suppressInputStreaming)) {
|
|
7592
|
+
continue;
|
|
7593
|
+
}
|
|
7594
|
+
controller.enqueue({
|
|
7595
|
+
type: "tool-input-start",
|
|
7596
|
+
id: toolCall.toolCallId,
|
|
7597
|
+
toolName: toolCall.toolName
|
|
7598
|
+
});
|
|
7599
|
+
for (const delta of (_a2 = toolCall.bufferedInputDeltas) != null ? _a2 : []) {
|
|
7600
|
+
controller.enqueue({
|
|
7601
|
+
type: "tool-input-delta",
|
|
7602
|
+
id: toolCall.toolCallId,
|
|
7603
|
+
delta
|
|
7604
|
+
});
|
|
7605
|
+
}
|
|
7606
|
+
}
|
|
7276
7607
|
const providerMetadata = {
|
|
7277
7608
|
[providerOptionsName]: {
|
|
7278
7609
|
responseId,
|
|
@@ -7310,7 +7641,7 @@ function createOpenAIResponsesChatCompletionsMismatchError({
|
|
|
7310
7641
|
requestBodyValues,
|
|
7311
7642
|
responseHeaders
|
|
7312
7643
|
}) {
|
|
7313
|
-
return new
|
|
7644
|
+
return new import_provider10.APICallError({
|
|
7314
7645
|
message: "Received a Chat Completions stream while using the OpenAI Responses API. The default OpenAI provider model uses the Responses API. If your custom baseURL targets a Chat Completions-compatible endpoint, use openai.chat('model-id') or createOpenAI(...).chat('model-id') instead. You can also use @ai-sdk/openai-compatible for OpenAI-compatible providers.",
|
|
7315
7646
|
url,
|
|
7316
7647
|
requestBodyValues,
|