@ai-sdk/openai 4.0.0-beta.10 → 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 +47 -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 +3 -5
- 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
|
@@ -359,6 +359,10 @@ declare const openaiResponsesChunkSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
359
359
|
action: {
|
|
360
360
|
commands: string[];
|
|
361
361
|
};
|
|
362
|
+
} | {
|
|
363
|
+
type: "compaction";
|
|
364
|
+
id: string;
|
|
365
|
+
encrypted_content?: string | null | undefined;
|
|
362
366
|
} | {
|
|
363
367
|
type: "shell_call_output";
|
|
364
368
|
id: string;
|
|
@@ -542,6 +546,10 @@ declare const openaiResponsesChunkSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
542
546
|
action: {
|
|
543
547
|
commands: string[];
|
|
544
548
|
};
|
|
549
|
+
} | {
|
|
550
|
+
type: "compaction";
|
|
551
|
+
id: string;
|
|
552
|
+
encrypted_content: string;
|
|
545
553
|
} | {
|
|
546
554
|
type: "shell_call_output";
|
|
547
555
|
id: string;
|
|
@@ -680,6 +688,14 @@ type OpenaiResponsesReasoningProviderMetadata = {
|
|
|
680
688
|
type OpenaiResponsesProviderMetadata = {
|
|
681
689
|
openai: ResponsesProviderMetadata;
|
|
682
690
|
};
|
|
691
|
+
type ResponsesCompactionProviderMetadata = {
|
|
692
|
+
type: 'compaction';
|
|
693
|
+
itemId: string;
|
|
694
|
+
encryptedContent?: string;
|
|
695
|
+
};
|
|
696
|
+
type OpenaiResponsesCompactionProviderMetadata = {
|
|
697
|
+
openai: ResponsesCompactionProviderMetadata;
|
|
698
|
+
};
|
|
683
699
|
type ResponsesTextProviderMetadata = {
|
|
684
700
|
itemId: string;
|
|
685
701
|
phase?: 'commentary' | 'final_answer' | null;
|
|
@@ -1162,4 +1178,4 @@ declare const webSearchPreview: _ai_sdk_provider_utils.ProviderToolFactoryWithOu
|
|
|
1162
1178
|
};
|
|
1163
1179
|
}>;
|
|
1164
1180
|
|
|
1165
|
-
export { type ApplyPatchOperation, OpenAIChatLanguageModel, type OpenAIChatModelId, OpenAICompletionLanguageModel, type OpenAICompletionModelId, OpenAIEmbeddingModel, type OpenAIEmbeddingModelId, type OpenAIEmbeddingModelOptions, OpenAIImageModel, type OpenAIImageModelId, type OpenAILanguageModelChatOptions, type OpenAILanguageModelCompletionOptions, OpenAIResponsesLanguageModel, OpenAISpeechModel, type OpenAISpeechModelId, type OpenAISpeechModelOptions, type OpenAITranscriptionCallOptions, OpenAITranscriptionModel, type OpenAITranscriptionModelId, type OpenAITranscriptionModelOptions, type OpenaiResponsesProviderMetadata, type OpenaiResponsesReasoningProviderMetadata, type OpenaiResponsesSourceDocumentProviderMetadata, type OpenaiResponsesTextProviderMetadata, type ResponsesProviderMetadata, type ResponsesReasoningProviderMetadata, type ResponsesSourceDocumentProviderMetadata, type ResponsesTextProviderMetadata, applyPatch, applyPatchArgsSchema, applyPatchInputSchema, applyPatchOutputSchema, applyPatchToolFactory, codeInterpreter, codeInterpreterArgsSchema, codeInterpreterInputSchema, codeInterpreterOutputSchema, codeInterpreterToolFactory, fileSearch, fileSearchArgsSchema, fileSearchOutputSchema, hasDefaultResponseFormat, imageGeneration, imageGenerationArgsSchema, imageGenerationOutputSchema, modelMaxImagesPerCall, openAITranscriptionModelOptions, openaiEmbeddingModelOptions, openaiLanguageModelChatOptions, openaiLanguageModelCompletionOptions, openaiSpeechModelOptionsSchema, webSearchPreview, webSearchPreviewArgsSchema, webSearchPreviewInputSchema };
|
|
1181
|
+
export { type ApplyPatchOperation, OpenAIChatLanguageModel, type OpenAIChatModelId, OpenAICompletionLanguageModel, type OpenAICompletionModelId, OpenAIEmbeddingModel, type OpenAIEmbeddingModelId, type OpenAIEmbeddingModelOptions, OpenAIImageModel, type OpenAIImageModelId, type OpenAILanguageModelChatOptions, type OpenAILanguageModelCompletionOptions, OpenAIResponsesLanguageModel, OpenAISpeechModel, type OpenAISpeechModelId, type OpenAISpeechModelOptions, type OpenAITranscriptionCallOptions, OpenAITranscriptionModel, type OpenAITranscriptionModelId, type OpenAITranscriptionModelOptions, type OpenaiResponsesCompactionProviderMetadata, type OpenaiResponsesProviderMetadata, type OpenaiResponsesReasoningProviderMetadata, type OpenaiResponsesSourceDocumentProviderMetadata, type OpenaiResponsesTextProviderMetadata, type ResponsesCompactionProviderMetadata, type ResponsesProviderMetadata, type ResponsesReasoningProviderMetadata, type ResponsesSourceDocumentProviderMetadata, type ResponsesTextProviderMetadata, applyPatch, applyPatchArgsSchema, applyPatchInputSchema, applyPatchOutputSchema, applyPatchToolFactory, codeInterpreter, codeInterpreterArgsSchema, codeInterpreterInputSchema, codeInterpreterOutputSchema, codeInterpreterToolFactory, fileSearch, fileSearchArgsSchema, fileSearchOutputSchema, hasDefaultResponseFormat, imageGeneration, imageGenerationArgsSchema, imageGenerationOutputSchema, modelMaxImagesPerCall, openAITranscriptionModelOptions, openaiEmbeddingModelOptions, openaiLanguageModelChatOptions, openaiLanguageModelCompletionOptions, openaiSpeechModelOptionsSchema, webSearchPreview, webSearchPreviewArgsSchema, webSearchPreviewInputSchema };
|
package/dist/internal/index.d.ts
CHANGED
|
@@ -359,6 +359,10 @@ declare const openaiResponsesChunkSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
359
359
|
action: {
|
|
360
360
|
commands: string[];
|
|
361
361
|
};
|
|
362
|
+
} | {
|
|
363
|
+
type: "compaction";
|
|
364
|
+
id: string;
|
|
365
|
+
encrypted_content?: string | null | undefined;
|
|
362
366
|
} | {
|
|
363
367
|
type: "shell_call_output";
|
|
364
368
|
id: string;
|
|
@@ -542,6 +546,10 @@ declare const openaiResponsesChunkSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
542
546
|
action: {
|
|
543
547
|
commands: string[];
|
|
544
548
|
};
|
|
549
|
+
} | {
|
|
550
|
+
type: "compaction";
|
|
551
|
+
id: string;
|
|
552
|
+
encrypted_content: string;
|
|
545
553
|
} | {
|
|
546
554
|
type: "shell_call_output";
|
|
547
555
|
id: string;
|
|
@@ -680,6 +688,14 @@ type OpenaiResponsesReasoningProviderMetadata = {
|
|
|
680
688
|
type OpenaiResponsesProviderMetadata = {
|
|
681
689
|
openai: ResponsesProviderMetadata;
|
|
682
690
|
};
|
|
691
|
+
type ResponsesCompactionProviderMetadata = {
|
|
692
|
+
type: 'compaction';
|
|
693
|
+
itemId: string;
|
|
694
|
+
encryptedContent?: string;
|
|
695
|
+
};
|
|
696
|
+
type OpenaiResponsesCompactionProviderMetadata = {
|
|
697
|
+
openai: ResponsesCompactionProviderMetadata;
|
|
698
|
+
};
|
|
683
699
|
type ResponsesTextProviderMetadata = {
|
|
684
700
|
itemId: string;
|
|
685
701
|
phase?: 'commentary' | 'final_answer' | null;
|
|
@@ -1162,4 +1178,4 @@ declare const webSearchPreview: _ai_sdk_provider_utils.ProviderToolFactoryWithOu
|
|
|
1162
1178
|
};
|
|
1163
1179
|
}>;
|
|
1164
1180
|
|
|
1165
|
-
export { type ApplyPatchOperation, OpenAIChatLanguageModel, type OpenAIChatModelId, OpenAICompletionLanguageModel, type OpenAICompletionModelId, OpenAIEmbeddingModel, type OpenAIEmbeddingModelId, type OpenAIEmbeddingModelOptions, OpenAIImageModel, type OpenAIImageModelId, type OpenAILanguageModelChatOptions, type OpenAILanguageModelCompletionOptions, OpenAIResponsesLanguageModel, OpenAISpeechModel, type OpenAISpeechModelId, type OpenAISpeechModelOptions, type OpenAITranscriptionCallOptions, OpenAITranscriptionModel, type OpenAITranscriptionModelId, type OpenAITranscriptionModelOptions, type OpenaiResponsesProviderMetadata, type OpenaiResponsesReasoningProviderMetadata, type OpenaiResponsesSourceDocumentProviderMetadata, type OpenaiResponsesTextProviderMetadata, type ResponsesProviderMetadata, type ResponsesReasoningProviderMetadata, type ResponsesSourceDocumentProviderMetadata, type ResponsesTextProviderMetadata, applyPatch, applyPatchArgsSchema, applyPatchInputSchema, applyPatchOutputSchema, applyPatchToolFactory, codeInterpreter, codeInterpreterArgsSchema, codeInterpreterInputSchema, codeInterpreterOutputSchema, codeInterpreterToolFactory, fileSearch, fileSearchArgsSchema, fileSearchOutputSchema, hasDefaultResponseFormat, imageGeneration, imageGenerationArgsSchema, imageGenerationOutputSchema, modelMaxImagesPerCall, openAITranscriptionModelOptions, openaiEmbeddingModelOptions, openaiLanguageModelChatOptions, openaiLanguageModelCompletionOptions, openaiSpeechModelOptionsSchema, webSearchPreview, webSearchPreviewArgsSchema, webSearchPreviewInputSchema };
|
|
1181
|
+
export { type ApplyPatchOperation, OpenAIChatLanguageModel, type OpenAIChatModelId, OpenAICompletionLanguageModel, type OpenAICompletionModelId, OpenAIEmbeddingModel, type OpenAIEmbeddingModelId, type OpenAIEmbeddingModelOptions, OpenAIImageModel, type OpenAIImageModelId, type OpenAILanguageModelChatOptions, type OpenAILanguageModelCompletionOptions, OpenAIResponsesLanguageModel, OpenAISpeechModel, type OpenAISpeechModelId, type OpenAISpeechModelOptions, type OpenAITranscriptionCallOptions, OpenAITranscriptionModel, type OpenAITranscriptionModelId, type OpenAITranscriptionModelOptions, type OpenaiResponsesCompactionProviderMetadata, type OpenaiResponsesProviderMetadata, type OpenaiResponsesReasoningProviderMetadata, type OpenaiResponsesSourceDocumentProviderMetadata, type OpenaiResponsesTextProviderMetadata, type ResponsesCompactionProviderMetadata, type ResponsesProviderMetadata, type ResponsesReasoningProviderMetadata, type ResponsesSourceDocumentProviderMetadata, type ResponsesTextProviderMetadata, applyPatch, applyPatchArgsSchema, applyPatchInputSchema, applyPatchOutputSchema, applyPatchToolFactory, codeInterpreter, codeInterpreterArgsSchema, codeInterpreterInputSchema, codeInterpreterOutputSchema, codeInterpreterToolFactory, fileSearch, fileSearchArgsSchema, fileSearchOutputSchema, hasDefaultResponseFormat, imageGeneration, imageGenerationArgsSchema, imageGenerationOutputSchema, modelMaxImagesPerCall, openAITranscriptionModelOptions, openaiEmbeddingModelOptions, openaiLanguageModelChatOptions, openaiLanguageModelCompletionOptions, openaiSpeechModelOptionsSchema, webSearchPreview, webSearchPreviewArgsSchema, webSearchPreviewInputSchema };
|
package/dist/internal/index.js
CHANGED
|
@@ -2600,7 +2600,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
2600
2600
|
hasApplyPatchTool = false,
|
|
2601
2601
|
customProviderToolNames
|
|
2602
2602
|
}) {
|
|
2603
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
|
|
2603
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
|
|
2604
2604
|
let input = [];
|
|
2605
2605
|
const warnings = [];
|
|
2606
2606
|
const processedApprovalIds = /* @__PURE__ */ new Set();
|
|
@@ -2947,6 +2947,28 @@ async function convertToOpenAIResponsesInput({
|
|
|
2947
2947
|
}
|
|
2948
2948
|
break;
|
|
2949
2949
|
}
|
|
2950
|
+
case "custom": {
|
|
2951
|
+
if (part.kind === "openai-compaction") {
|
|
2952
|
+
const providerOpts = (_n = part.providerOptions) == null ? void 0 : _n[providerOptionsName];
|
|
2953
|
+
const id = providerOpts == null ? void 0 : providerOpts.itemId;
|
|
2954
|
+
if (hasConversation && id != null) {
|
|
2955
|
+
break;
|
|
2956
|
+
}
|
|
2957
|
+
if (store && id != null) {
|
|
2958
|
+
input.push({ type: "item_reference", id });
|
|
2959
|
+
break;
|
|
2960
|
+
}
|
|
2961
|
+
const encryptedContent = providerOpts == null ? void 0 : providerOpts.encryptedContent;
|
|
2962
|
+
if (id != null) {
|
|
2963
|
+
input.push({
|
|
2964
|
+
type: "compaction",
|
|
2965
|
+
id,
|
|
2966
|
+
encrypted_content: encryptedContent
|
|
2967
|
+
});
|
|
2968
|
+
}
|
|
2969
|
+
}
|
|
2970
|
+
break;
|
|
2971
|
+
}
|
|
2950
2972
|
}
|
|
2951
2973
|
}
|
|
2952
2974
|
break;
|
|
@@ -2974,7 +2996,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
2974
2996
|
}
|
|
2975
2997
|
const output = part.output;
|
|
2976
2998
|
if (output.type === "execution-denied") {
|
|
2977
|
-
const approvalId = (
|
|
2999
|
+
const approvalId = (_p = (_o = output.providerOptions) == null ? void 0 : _o.openai) == null ? void 0 : _p.approvalId;
|
|
2978
3000
|
if (approvalId) {
|
|
2979
3001
|
continue;
|
|
2980
3002
|
}
|
|
@@ -3048,7 +3070,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
3048
3070
|
outputValue = output.value;
|
|
3049
3071
|
break;
|
|
3050
3072
|
case "execution-denied":
|
|
3051
|
-
outputValue = (
|
|
3073
|
+
outputValue = (_q = output.reason) != null ? _q : "Tool execution denied.";
|
|
3052
3074
|
break;
|
|
3053
3075
|
case "json":
|
|
3054
3076
|
case "error-json":
|
|
@@ -3102,7 +3124,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
3102
3124
|
contentValue = output.value;
|
|
3103
3125
|
break;
|
|
3104
3126
|
case "execution-denied":
|
|
3105
|
-
contentValue = (
|
|
3127
|
+
contentValue = (_r = output.reason) != null ? _r : "Tool execution denied.";
|
|
3106
3128
|
break;
|
|
3107
3129
|
case "json":
|
|
3108
3130
|
case "error-json":
|
|
@@ -3354,6 +3376,11 @@ var openaiResponsesChunkSchema = (0, import_provider_utils24.lazySchema)(
|
|
|
3354
3376
|
commands: import_v417.z.array(import_v417.z.string())
|
|
3355
3377
|
})
|
|
3356
3378
|
}),
|
|
3379
|
+
import_v417.z.object({
|
|
3380
|
+
type: import_v417.z.literal("compaction"),
|
|
3381
|
+
id: import_v417.z.string(),
|
|
3382
|
+
encrypted_content: import_v417.z.string().nullish()
|
|
3383
|
+
}),
|
|
3357
3384
|
import_v417.z.object({
|
|
3358
3385
|
type: import_v417.z.literal("shell_call_output"),
|
|
3359
3386
|
id: import_v417.z.string(),
|
|
@@ -3577,6 +3604,11 @@ var openaiResponsesChunkSchema = (0, import_provider_utils24.lazySchema)(
|
|
|
3577
3604
|
commands: import_v417.z.array(import_v417.z.string())
|
|
3578
3605
|
})
|
|
3579
3606
|
}),
|
|
3607
|
+
import_v417.z.object({
|
|
3608
|
+
type: import_v417.z.literal("compaction"),
|
|
3609
|
+
id: import_v417.z.string(),
|
|
3610
|
+
encrypted_content: import_v417.z.string()
|
|
3611
|
+
}),
|
|
3580
3612
|
import_v417.z.object({
|
|
3581
3613
|
type: import_v417.z.literal("shell_call_output"),
|
|
3582
3614
|
id: import_v417.z.string(),
|
|
@@ -3974,6 +4006,11 @@ var openaiResponsesResponseSchema = (0, import_provider_utils24.lazySchema)(
|
|
|
3974
4006
|
commands: import_v417.z.array(import_v417.z.string())
|
|
3975
4007
|
})
|
|
3976
4008
|
}),
|
|
4009
|
+
import_v417.z.object({
|
|
4010
|
+
type: import_v417.z.literal("compaction"),
|
|
4011
|
+
id: import_v417.z.string(),
|
|
4012
|
+
encrypted_content: import_v417.z.string()
|
|
4013
|
+
}),
|
|
3977
4014
|
import_v417.z.object({
|
|
3978
4015
|
type: import_v417.z.literal("shell_call_output"),
|
|
3979
4016
|
id: import_v417.z.string(),
|
|
@@ -4236,7 +4273,16 @@ var openaiLanguageModelResponsesOptionsSchema = (0, import_provider_utils25.lazy
|
|
|
4236
4273
|
* When enabled, the SDK applies reasoning-model parameter compatibility rules
|
|
4237
4274
|
* and defaults `systemMessageMode` to `developer` unless overridden.
|
|
4238
4275
|
*/
|
|
4239
|
-
forceReasoning: import_v418.z.boolean().optional()
|
|
4276
|
+
forceReasoning: import_v418.z.boolean().optional(),
|
|
4277
|
+
/**
|
|
4278
|
+
* Enable server-side context management (compaction).
|
|
4279
|
+
*/
|
|
4280
|
+
contextManagement: import_v418.z.array(
|
|
4281
|
+
import_v418.z.object({
|
|
4282
|
+
type: import_v418.z.literal("compaction"),
|
|
4283
|
+
compactThreshold: import_v418.z.number()
|
|
4284
|
+
})
|
|
4285
|
+
).nullish()
|
|
4240
4286
|
})
|
|
4241
4287
|
)
|
|
4242
4288
|
);
|
|
@@ -5021,6 +5067,13 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5021
5067
|
safety_identifier: openaiOptions == null ? void 0 : openaiOptions.safetyIdentifier,
|
|
5022
5068
|
top_logprobs: topLogprobs,
|
|
5023
5069
|
truncation: openaiOptions == null ? void 0 : openaiOptions.truncation,
|
|
5070
|
+
// context management (server-side compaction):
|
|
5071
|
+
...(openaiOptions == null ? void 0 : openaiOptions.contextManagement) && {
|
|
5072
|
+
context_management: openaiOptions.contextManagement.map((cm) => ({
|
|
5073
|
+
type: cm.type,
|
|
5074
|
+
compact_threshold: cm.compactThreshold
|
|
5075
|
+
}))
|
|
5076
|
+
},
|
|
5024
5077
|
// model-specific settings:
|
|
5025
5078
|
...isReasoningModel && ((openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null || (openaiOptions == null ? void 0 : openaiOptions.reasoningSummary) != null) && {
|
|
5026
5079
|
reasoning: {
|
|
@@ -5545,6 +5598,20 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5545
5598
|
});
|
|
5546
5599
|
break;
|
|
5547
5600
|
}
|
|
5601
|
+
case "compaction": {
|
|
5602
|
+
content.push({
|
|
5603
|
+
type: "custom",
|
|
5604
|
+
kind: "openai-compaction",
|
|
5605
|
+
providerMetadata: {
|
|
5606
|
+
[providerOptionsName]: {
|
|
5607
|
+
type: "compaction",
|
|
5608
|
+
itemId: part.id,
|
|
5609
|
+
encryptedContent: part.encrypted_content
|
|
5610
|
+
}
|
|
5611
|
+
}
|
|
5612
|
+
});
|
|
5613
|
+
break;
|
|
5614
|
+
}
|
|
5548
5615
|
}
|
|
5549
5616
|
}
|
|
5550
5617
|
const providerMetadata = {
|
|
@@ -6174,6 +6241,18 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6174
6241
|
});
|
|
6175
6242
|
}
|
|
6176
6243
|
delete activeReasoning[value.item.id];
|
|
6244
|
+
} else if (value.item.type === "compaction") {
|
|
6245
|
+
controller.enqueue({
|
|
6246
|
+
type: "custom",
|
|
6247
|
+
kind: "openai-compaction",
|
|
6248
|
+
providerMetadata: {
|
|
6249
|
+
[providerOptionsName]: {
|
|
6250
|
+
type: "compaction",
|
|
6251
|
+
itemId: value.item.id,
|
|
6252
|
+
encryptedContent: value.item.encrypted_content
|
|
6253
|
+
}
|
|
6254
|
+
}
|
|
6255
|
+
});
|
|
6177
6256
|
}
|
|
6178
6257
|
} else if (isResponseFunctionCallArgumentsDeltaChunk(value)) {
|
|
6179
6258
|
const toolCall = ongoingToolCalls[value.output_index];
|