@ai-sdk/openai 4.0.0-beta.11 → 4.0.0-beta.12
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 +39 -33
- package/dist/index.d.mts +21 -1
- package/dist/index.d.ts +21 -1
- package/dist/index.js +85 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +85 -6
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +17 -1
- package/dist/internal/index.d.ts +17 -1
- package/dist/internal/index.js +84 -5
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +84 -5
- package/dist/internal/index.mjs.map +1 -1
- package/docs/03-openai.mdx +124 -0
- package/package.json +1 -3
- package/src/index.ts +1 -0
- package/src/responses/convert-to-openai-responses-input.ts +35 -4
- package/src/responses/openai-responses-api.ts +23 -1
- package/src/responses/openai-responses-language-model.ts +36 -0
- package/src/responses/openai-responses-options.ts +12 -0
- package/src/responses/openai-responses-provider-metadata.ts +10 -0
package/dist/internal/index.mjs
CHANGED
|
@@ -2626,7 +2626,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
2626
2626
|
hasApplyPatchTool = false,
|
|
2627
2627
|
customProviderToolNames
|
|
2628
2628
|
}) {
|
|
2629
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
|
|
2629
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
|
|
2630
2630
|
let input = [];
|
|
2631
2631
|
const warnings = [];
|
|
2632
2632
|
const processedApprovalIds = /* @__PURE__ */ new Set();
|
|
@@ -2973,6 +2973,28 @@ async function convertToOpenAIResponsesInput({
|
|
|
2973
2973
|
}
|
|
2974
2974
|
break;
|
|
2975
2975
|
}
|
|
2976
|
+
case "custom": {
|
|
2977
|
+
if (part.kind === "openai-compaction") {
|
|
2978
|
+
const providerOpts = (_n = part.providerOptions) == null ? void 0 : _n[providerOptionsName];
|
|
2979
|
+
const id = providerOpts == null ? void 0 : providerOpts.itemId;
|
|
2980
|
+
if (hasConversation && id != null) {
|
|
2981
|
+
break;
|
|
2982
|
+
}
|
|
2983
|
+
if (store && id != null) {
|
|
2984
|
+
input.push({ type: "item_reference", id });
|
|
2985
|
+
break;
|
|
2986
|
+
}
|
|
2987
|
+
const encryptedContent = providerOpts == null ? void 0 : providerOpts.encryptedContent;
|
|
2988
|
+
if (id != null) {
|
|
2989
|
+
input.push({
|
|
2990
|
+
type: "compaction",
|
|
2991
|
+
id,
|
|
2992
|
+
encrypted_content: encryptedContent
|
|
2993
|
+
});
|
|
2994
|
+
}
|
|
2995
|
+
}
|
|
2996
|
+
break;
|
|
2997
|
+
}
|
|
2976
2998
|
}
|
|
2977
2999
|
}
|
|
2978
3000
|
break;
|
|
@@ -3000,7 +3022,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
3000
3022
|
}
|
|
3001
3023
|
const output = part.output;
|
|
3002
3024
|
if (output.type === "execution-denied") {
|
|
3003
|
-
const approvalId = (
|
|
3025
|
+
const approvalId = (_p = (_o = output.providerOptions) == null ? void 0 : _o.openai) == null ? void 0 : _p.approvalId;
|
|
3004
3026
|
if (approvalId) {
|
|
3005
3027
|
continue;
|
|
3006
3028
|
}
|
|
@@ -3074,7 +3096,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
3074
3096
|
outputValue = output.value;
|
|
3075
3097
|
break;
|
|
3076
3098
|
case "execution-denied":
|
|
3077
|
-
outputValue = (
|
|
3099
|
+
outputValue = (_q = output.reason) != null ? _q : "Tool execution denied.";
|
|
3078
3100
|
break;
|
|
3079
3101
|
case "json":
|
|
3080
3102
|
case "error-json":
|
|
@@ -3128,7 +3150,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
3128
3150
|
contentValue = output.value;
|
|
3129
3151
|
break;
|
|
3130
3152
|
case "execution-denied":
|
|
3131
|
-
contentValue = (
|
|
3153
|
+
contentValue = (_r = output.reason) != null ? _r : "Tool execution denied.";
|
|
3132
3154
|
break;
|
|
3133
3155
|
case "json":
|
|
3134
3156
|
case "error-json":
|
|
@@ -3380,6 +3402,11 @@ var openaiResponsesChunkSchema = lazySchema15(
|
|
|
3380
3402
|
commands: z17.array(z17.string())
|
|
3381
3403
|
})
|
|
3382
3404
|
}),
|
|
3405
|
+
z17.object({
|
|
3406
|
+
type: z17.literal("compaction"),
|
|
3407
|
+
id: z17.string(),
|
|
3408
|
+
encrypted_content: z17.string().nullish()
|
|
3409
|
+
}),
|
|
3383
3410
|
z17.object({
|
|
3384
3411
|
type: z17.literal("shell_call_output"),
|
|
3385
3412
|
id: z17.string(),
|
|
@@ -3603,6 +3630,11 @@ var openaiResponsesChunkSchema = lazySchema15(
|
|
|
3603
3630
|
commands: z17.array(z17.string())
|
|
3604
3631
|
})
|
|
3605
3632
|
}),
|
|
3633
|
+
z17.object({
|
|
3634
|
+
type: z17.literal("compaction"),
|
|
3635
|
+
id: z17.string(),
|
|
3636
|
+
encrypted_content: z17.string()
|
|
3637
|
+
}),
|
|
3606
3638
|
z17.object({
|
|
3607
3639
|
type: z17.literal("shell_call_output"),
|
|
3608
3640
|
id: z17.string(),
|
|
@@ -4000,6 +4032,11 @@ var openaiResponsesResponseSchema = lazySchema15(
|
|
|
4000
4032
|
commands: z17.array(z17.string())
|
|
4001
4033
|
})
|
|
4002
4034
|
}),
|
|
4035
|
+
z17.object({
|
|
4036
|
+
type: z17.literal("compaction"),
|
|
4037
|
+
id: z17.string(),
|
|
4038
|
+
encrypted_content: z17.string()
|
|
4039
|
+
}),
|
|
4003
4040
|
z17.object({
|
|
4004
4041
|
type: z17.literal("shell_call_output"),
|
|
4005
4042
|
id: z17.string(),
|
|
@@ -4262,7 +4299,16 @@ var openaiLanguageModelResponsesOptionsSchema = lazySchema16(
|
|
|
4262
4299
|
* When enabled, the SDK applies reasoning-model parameter compatibility rules
|
|
4263
4300
|
* and defaults `systemMessageMode` to `developer` unless overridden.
|
|
4264
4301
|
*/
|
|
4265
|
-
forceReasoning: z18.boolean().optional()
|
|
4302
|
+
forceReasoning: z18.boolean().optional(),
|
|
4303
|
+
/**
|
|
4304
|
+
* Enable server-side context management (compaction).
|
|
4305
|
+
*/
|
|
4306
|
+
contextManagement: z18.array(
|
|
4307
|
+
z18.object({
|
|
4308
|
+
type: z18.literal("compaction"),
|
|
4309
|
+
compactThreshold: z18.number()
|
|
4310
|
+
})
|
|
4311
|
+
).nullish()
|
|
4266
4312
|
})
|
|
4267
4313
|
)
|
|
4268
4314
|
);
|
|
@@ -5077,6 +5123,13 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5077
5123
|
safety_identifier: openaiOptions == null ? void 0 : openaiOptions.safetyIdentifier,
|
|
5078
5124
|
top_logprobs: topLogprobs,
|
|
5079
5125
|
truncation: openaiOptions == null ? void 0 : openaiOptions.truncation,
|
|
5126
|
+
// context management (server-side compaction):
|
|
5127
|
+
...(openaiOptions == null ? void 0 : openaiOptions.contextManagement) && {
|
|
5128
|
+
context_management: openaiOptions.contextManagement.map((cm) => ({
|
|
5129
|
+
type: cm.type,
|
|
5130
|
+
compact_threshold: cm.compactThreshold
|
|
5131
|
+
}))
|
|
5132
|
+
},
|
|
5080
5133
|
// model-specific settings:
|
|
5081
5134
|
...isReasoningModel && ((openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null || (openaiOptions == null ? void 0 : openaiOptions.reasoningSummary) != null) && {
|
|
5082
5135
|
reasoning: {
|
|
@@ -5601,6 +5654,20 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5601
5654
|
});
|
|
5602
5655
|
break;
|
|
5603
5656
|
}
|
|
5657
|
+
case "compaction": {
|
|
5658
|
+
content.push({
|
|
5659
|
+
type: "custom",
|
|
5660
|
+
kind: "openai-compaction",
|
|
5661
|
+
providerMetadata: {
|
|
5662
|
+
[providerOptionsName]: {
|
|
5663
|
+
type: "compaction",
|
|
5664
|
+
itemId: part.id,
|
|
5665
|
+
encryptedContent: part.encrypted_content
|
|
5666
|
+
}
|
|
5667
|
+
}
|
|
5668
|
+
});
|
|
5669
|
+
break;
|
|
5670
|
+
}
|
|
5604
5671
|
}
|
|
5605
5672
|
}
|
|
5606
5673
|
const providerMetadata = {
|
|
@@ -6230,6 +6297,18 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6230
6297
|
});
|
|
6231
6298
|
}
|
|
6232
6299
|
delete activeReasoning[value.item.id];
|
|
6300
|
+
} else if (value.item.type === "compaction") {
|
|
6301
|
+
controller.enqueue({
|
|
6302
|
+
type: "custom",
|
|
6303
|
+
kind: "openai-compaction",
|
|
6304
|
+
providerMetadata: {
|
|
6305
|
+
[providerOptionsName]: {
|
|
6306
|
+
type: "compaction",
|
|
6307
|
+
itemId: value.item.id,
|
|
6308
|
+
encryptedContent: value.item.encrypted_content
|
|
6309
|
+
}
|
|
6310
|
+
}
|
|
6311
|
+
});
|
|
6233
6312
|
}
|
|
6234
6313
|
} else if (isResponseFunctionCallArgumentsDeltaChunk(value)) {
|
|
6235
6314
|
const toolCall = ongoingToolCalls[value.output_index];
|