@ai-sdk/openai 3.0.72 → 3.0.74
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/index.d.mts +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +39 -18
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +39 -18
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +6 -0
- package/dist/internal/index.d.ts +6 -0
- package/dist/internal/index.js +38 -17
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +38 -17
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/responses/convert-openai-responses-usage.ts +3 -0
- package/src/responses/convert-to-openai-responses-input.ts +23 -5
- package/src/responses/openai-responses-api.ts +27 -6
package/dist/internal/index.mjs
CHANGED
|
@@ -2743,7 +2743,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
2743
2743
|
hasApplyPatchTool = false,
|
|
2744
2744
|
customProviderToolNames
|
|
2745
2745
|
}) {
|
|
2746
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
2746
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w;
|
|
2747
2747
|
let input = [];
|
|
2748
2748
|
const warnings = [];
|
|
2749
2749
|
const processedApprovalIds = /* @__PURE__ */ new Set();
|
|
@@ -2880,10 +2880,11 @@ async function convertToOpenAIResponsesInput({
|
|
|
2880
2880
|
}
|
|
2881
2881
|
break;
|
|
2882
2882
|
}
|
|
2883
|
-
if (store && id != null) {
|
|
2884
|
-
|
|
2885
|
-
|
|
2886
|
-
|
|
2883
|
+
if (hasPreviousResponseId && store && id != null) {
|
|
2884
|
+
break;
|
|
2885
|
+
}
|
|
2886
|
+
const isProviderDefinedToolCall = hasLocalShellTool && resolvedToolName === "local_shell" || hasShellTool && resolvedToolName === "shell" || hasApplyPatchTool && resolvedToolName === "apply_patch" || ((_m = customProviderToolNames == null ? void 0 : customProviderToolNames.has(resolvedToolName)) != null ? _m : false);
|
|
2887
|
+
if (store && id != null && isProviderDefinedToolCall) {
|
|
2887
2888
|
input.push({ type: "item_reference", id });
|
|
2888
2889
|
break;
|
|
2889
2890
|
}
|
|
@@ -2954,7 +2955,6 @@ async function convertToOpenAIResponsesInput({
|
|
|
2954
2955
|
call_id: part.toolCallId,
|
|
2955
2956
|
name: resolvedToolName,
|
|
2956
2957
|
arguments: serializeToolCallArguments2(part.input),
|
|
2957
|
-
id,
|
|
2958
2958
|
...namespace != null && { namespace }
|
|
2959
2959
|
});
|
|
2960
2960
|
break;
|
|
@@ -2971,7 +2971,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
2971
2971
|
part.toolName
|
|
2972
2972
|
);
|
|
2973
2973
|
if (resolvedResultToolName === "tool_search") {
|
|
2974
|
-
const itemId = (
|
|
2974
|
+
const itemId = (_p = (_o = (_n = part.providerOptions) == null ? void 0 : _n[providerOptionsName]) == null ? void 0 : _o.itemId) != null ? _p : part.toolCallId;
|
|
2975
2975
|
if (store) {
|
|
2976
2976
|
input.push({ type: "item_reference", id: itemId });
|
|
2977
2977
|
} else if (part.output.type === "json") {
|
|
@@ -3012,7 +3012,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
3012
3012
|
break;
|
|
3013
3013
|
}
|
|
3014
3014
|
if (store) {
|
|
3015
|
-
const itemId = (
|
|
3015
|
+
const itemId = (_s = (_r = (_q = part.providerOptions) == null ? void 0 : _q[providerOptionsName]) == null ? void 0 : _r.itemId) != null ? _s : part.toolCallId;
|
|
3016
3016
|
input.push({ type: "item_reference", id: itemId });
|
|
3017
3017
|
} else {
|
|
3018
3018
|
warnings.push({
|
|
@@ -3122,7 +3122,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
3122
3122
|
}
|
|
3123
3123
|
const output = part.output;
|
|
3124
3124
|
if (output.type === "execution-denied") {
|
|
3125
|
-
const approvalId = (
|
|
3125
|
+
const approvalId = (_u = (_t = output.providerOptions) == null ? void 0 : _t.openai) == null ? void 0 : _u.approvalId;
|
|
3126
3126
|
if (approvalId) {
|
|
3127
3127
|
continue;
|
|
3128
3128
|
}
|
|
@@ -3196,7 +3196,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
3196
3196
|
outputValue = output.value;
|
|
3197
3197
|
break;
|
|
3198
3198
|
case "execution-denied":
|
|
3199
|
-
outputValue = (
|
|
3199
|
+
outputValue = (_v = output.reason) != null ? _v : "Tool execution denied.";
|
|
3200
3200
|
break;
|
|
3201
3201
|
case "json":
|
|
3202
3202
|
case "error-json":
|
|
@@ -3257,7 +3257,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
3257
3257
|
contentValue = output.value;
|
|
3258
3258
|
break;
|
|
3259
3259
|
case "execution-denied":
|
|
3260
|
-
contentValue = (
|
|
3260
|
+
contentValue = (_w = output.reason) != null ? _w : "Tool execution denied.";
|
|
3261
3261
|
break;
|
|
3262
3262
|
case "json":
|
|
3263
3263
|
case "error-json":
|
|
@@ -3400,9 +3400,16 @@ var openaiResponsesChunkSchema = lazySchema16(
|
|
|
3400
3400
|
incomplete_details: z18.object({ reason: z18.string() }).nullish(),
|
|
3401
3401
|
usage: z18.object({
|
|
3402
3402
|
input_tokens: z18.number(),
|
|
3403
|
-
input_tokens_details: z18.object({
|
|
3403
|
+
input_tokens_details: z18.object({
|
|
3404
|
+
cached_tokens: z18.number().nullish(),
|
|
3405
|
+
orchestration_input_tokens: z18.number().nullish(),
|
|
3406
|
+
orchestration_input_cached_tokens: z18.number().nullish()
|
|
3407
|
+
}).nullish(),
|
|
3404
3408
|
output_tokens: z18.number(),
|
|
3405
|
-
output_tokens_details: z18.object({
|
|
3409
|
+
output_tokens_details: z18.object({
|
|
3410
|
+
reasoning_tokens: z18.number().nullish(),
|
|
3411
|
+
orchestration_output_tokens: z18.number().nullish()
|
|
3412
|
+
}).nullish()
|
|
3406
3413
|
}),
|
|
3407
3414
|
service_tier: z18.string().nullish()
|
|
3408
3415
|
})
|
|
@@ -3417,9 +3424,16 @@ var openaiResponsesChunkSchema = lazySchema16(
|
|
|
3417
3424
|
incomplete_details: z18.object({ reason: z18.string() }).nullish(),
|
|
3418
3425
|
usage: z18.object({
|
|
3419
3426
|
input_tokens: z18.number(),
|
|
3420
|
-
input_tokens_details: z18.object({
|
|
3427
|
+
input_tokens_details: z18.object({
|
|
3428
|
+
cached_tokens: z18.number().nullish(),
|
|
3429
|
+
orchestration_input_tokens: z18.number().nullish(),
|
|
3430
|
+
orchestration_input_cached_tokens: z18.number().nullish()
|
|
3431
|
+
}).nullish(),
|
|
3421
3432
|
output_tokens: z18.number(),
|
|
3422
|
-
output_tokens_details: z18.object({
|
|
3433
|
+
output_tokens_details: z18.object({
|
|
3434
|
+
reasoning_tokens: z18.number().nullish(),
|
|
3435
|
+
orchestration_output_tokens: z18.number().nullish()
|
|
3436
|
+
}).nullish()
|
|
3423
3437
|
}).nullish(),
|
|
3424
3438
|
service_tier: z18.string().nullish()
|
|
3425
3439
|
})
|
|
@@ -4203,9 +4217,16 @@ var openaiResponsesResponseSchema = lazySchema16(
|
|
|
4203
4217
|
incomplete_details: z18.object({ reason: z18.string() }).nullish(),
|
|
4204
4218
|
usage: z18.object({
|
|
4205
4219
|
input_tokens: z18.number(),
|
|
4206
|
-
input_tokens_details: z18.object({
|
|
4220
|
+
input_tokens_details: z18.object({
|
|
4221
|
+
cached_tokens: z18.number().nullish(),
|
|
4222
|
+
orchestration_input_tokens: z18.number().nullish(),
|
|
4223
|
+
orchestration_input_cached_tokens: z18.number().nullish()
|
|
4224
|
+
}).nullish(),
|
|
4207
4225
|
output_tokens: z18.number(),
|
|
4208
|
-
output_tokens_details: z18.object({
|
|
4226
|
+
output_tokens_details: z18.object({
|
|
4227
|
+
reasoning_tokens: z18.number().nullish(),
|
|
4228
|
+
orchestration_output_tokens: z18.number().nullish()
|
|
4229
|
+
}).nullish()
|
|
4209
4230
|
}).optional()
|
|
4210
4231
|
})
|
|
4211
4232
|
)
|