@ai-sdk/openai 4.0.98 → 4.0.100
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 +27 -0
- package/dist/index.d.ts +14 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +95 -89
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +31 -44
- package/dist/internal/index.d.ts.map +1 -1
- package/dist/internal/index.js +82 -72
- package/dist/internal/index.js.map +1 -1
- package/docs/03-openai.mdx +52 -8
- package/package.json +3 -3
- package/src/chat/openai-chat-api.ts +1 -1
- package/src/chat/openai-chat-language-model.ts +2 -1
- package/src/completion/openai-completion-api.ts +1 -1
- package/src/completion/openai-completion-language-model.ts +2 -1
- package/src/files/openai-files.ts +1 -11
- package/src/image/openai-image-model-options.ts +40 -39
- package/src/live/openai-realtime-model-live.ts +13 -4
- package/src/openai-batch.ts +2 -2
- package/src/openai-decision-model.ts +55 -44
- package/src/openai-error.ts +22 -14
- package/src/responses/convert-openai-responses-usage.ts +6 -0
- package/src/responses/convert-to-openai-responses-input.ts +17 -11
- package/src/responses/openai-responses-api.ts +221 -192
- package/src/responses/openai-responses-language-model-options.ts +4 -2
- package/src/responses/openai-responses-language-model.ts +2 -1
- package/src/tool/computer.ts +64 -58
- package/src/tool/file-search.ts +15 -12
- package/src/tool/mcp.ts +13 -11
- package/src/tool/shell.ts +22 -21
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EXPERIMENTAL_EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL, StreamingToolCallTracker, WORKFLOW_DESERIALIZE, WORKFLOW_SERIALIZE, combineHeaders, connectToWebSocket, convertAsyncIteratorToReadableStream, convertBase64ToUint8Array, convertInlineFileDataToUint8Array, convertToBase64, convertToFormData, convertUint8ArrayToBase64, createBinaryResponseHandler, createBinaryStreamResponseHandler, createEventSourceResponseHandler, createJsonErrorResponseHandler, createJsonLinesResponseHandler, createJsonResponseHandler, createLanguageModelResponseMetadata, createLanguageModelResponseMetadata as getResponseMetadata, createNullLanguageModelUsage, createProviderDefinedToolFactory, createProviderDefinedToolFactoryWithOutputSchema, createProviderExecutedToolFactory, createProviderStreamError, createToolNameMapping, deleteFromApi, detectMediaType, downloadBlob, experimental_toolCaller, generateId, getFromApi, getTopLevelMediaType, isCustomReasoning, isFullMediaType, isNonNullable, isRecord, lazySchema, loadApiKey, loadOptionalSetting, mediaTypeToExtension, normalizeBatchRequestCounts, parseJSON, parseProviderOptions, postFormDataToApi, postJsonToApi, postMultipartStreamToApi, postToApi, resolveFullMediaType, resolveProviderReference, safeParseJSON, safeValidateTypes, serializeModelOptions, toWebSocketUrl, validateBaseURL, validateTypes, waitForWebSocketBufferDrain, withUserAgentSuffix, withoutTrailingSlash, zodSchema } from "@ai-sdk/provider-utils";
|
|
1
|
+
import { EXPERIMENTAL_EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL, StreamingToolCallTracker, WORKFLOW_DESERIALIZE, WORKFLOW_SERIALIZE, combineHeaders, connectToWebSocket, convertAsyncIteratorToReadableStream, convertBase64ToUint8Array, convertInlineFileDataToUint8Array, convertToBase64, convertToFormData, convertUint8ArrayToBase64, createBinaryResponseHandler, createBinaryStreamResponseHandler, createEventSourceResponseHandler, createJsonErrorResponseHandler, createJsonLinesResponseHandler, createJsonResponseHandler, createLanguageModelResponseMetadata, createLanguageModelResponseMetadata as getResponseMetadata, createNullLanguageModelUsage, createProviderDefinedToolFactory, createProviderDefinedToolFactoryWithOutputSchema, createProviderExecutedToolFactory, createProviderStreamError, createToolNameMapping, deleteFromApi, detectMediaType, downloadBlob, encodePathSegment, experimental_toolCaller, generateId, getFromApi, getTopLevelMediaType, isCustomReasoning, isFullMediaType, isNonNullable, isRecord, lazySchema, loadApiKey, loadOptionalSetting, mediaTypeToExtension, normalizeBatchRequestCounts, parseJSON, parseProviderOptions, postFormDataToApi, postJsonToApi, postMultipartStreamToApi, postToApi, resolveFullMediaType, resolveProviderReference, safeParseJSON, safeValidateTypes, serializeModelOptions, toWebSocketUrl, validateBaseURL, validateTypes, waitForWebSocketBufferDrain, withUserAgentSuffix, withoutTrailingSlash, zodSchema } from "@ai-sdk/provider-utils";
|
|
2
2
|
import { APICallError, InvalidArgumentError, InvalidPromptError, InvalidResponseDataError, TooManyEmbeddingValuesForCallError, UnsupportedFunctionalityError, isJSONObject } from "@ai-sdk/provider";
|
|
3
3
|
import { z } from "zod/v4";
|
|
4
4
|
//#region src/openai-config.ts
|
|
@@ -16,14 +16,15 @@ function prepareOpenAIConfigForWorkflowDeserialize(config) {
|
|
|
16
16
|
}
|
|
17
17
|
//#endregion
|
|
18
18
|
//#region src/openai-error.ts
|
|
19
|
-
const openaiErrorDataSchema = z.object({ error: z.object({
|
|
19
|
+
const openaiErrorDataSchema = () => z.object({ error: z.object({
|
|
20
20
|
message: z.string(),
|
|
21
21
|
type: z.string().nullish(),
|
|
22
22
|
param: z.any().nullish(),
|
|
23
23
|
code: z.union([z.string(), z.number()]).nullish()
|
|
24
24
|
}) });
|
|
25
|
+
const openaiErrorDataSchemaValidator = lazySchema(() => zodSchema(openaiErrorDataSchema()));
|
|
25
26
|
const openaiFailedResponseHandler = createJsonErrorResponseHandler({
|
|
26
|
-
errorSchema:
|
|
27
|
+
errorSchema: openaiErrorDataSchemaValidator,
|
|
27
28
|
errorToMessage: (data) => data.error.message
|
|
28
29
|
});
|
|
29
30
|
//#endregion
|
|
@@ -33,8 +34,8 @@ const openaiDecisionModelOptions = lazySchema(() => zodSchema(z.object({
|
|
|
33
34
|
safetyIdentifier: z.string().max(128).optional() })));
|
|
34
35
|
//#endregion
|
|
35
36
|
//#region src/openai-decision-model.ts
|
|
36
|
-
const probability = z.number().min(0).max(1);
|
|
37
|
-
const responseSchema = z.object({
|
|
37
|
+
const probability = () => z.number().min(0).max(1);
|
|
38
|
+
const responseSchema = lazySchema(() => zodSchema(z.object({
|
|
38
39
|
model: z.string().nullish(),
|
|
39
40
|
usage: z.object({
|
|
40
41
|
input_tokens: z.number().nullish(),
|
|
@@ -54,30 +55,30 @@ const responseSchema = z.object({
|
|
|
54
55
|
z.object({
|
|
55
56
|
type: z.literal("predicate"),
|
|
56
57
|
name: z.string(),
|
|
57
|
-
probability
|
|
58
|
+
probability: probability()
|
|
58
59
|
}),
|
|
59
60
|
z.object({
|
|
60
61
|
type: z.literal("choice"),
|
|
61
62
|
name: z.string(),
|
|
62
63
|
choice: z.string(),
|
|
63
|
-
confidence: probability.nullish(),
|
|
64
|
+
confidence: probability().nullish(),
|
|
64
65
|
probabilities: z.array(z.object({
|
|
65
66
|
value: z.string(),
|
|
66
|
-
probability
|
|
67
|
+
probability: probability()
|
|
67
68
|
}))
|
|
68
69
|
}),
|
|
69
70
|
z.object({
|
|
70
71
|
type: z.literal("score"),
|
|
71
72
|
name: z.string(),
|
|
72
73
|
score: z.number(),
|
|
73
|
-
confidence: probability.nullish(),
|
|
74
|
+
confidence: probability().nullish(),
|
|
74
75
|
probabilities: z.array(z.object({
|
|
75
76
|
value: z.number().int().nonnegative(),
|
|
76
|
-
probability
|
|
77
|
+
probability: probability()
|
|
77
78
|
}))
|
|
78
79
|
})
|
|
79
80
|
]))
|
|
80
|
-
});
|
|
81
|
+
})));
|
|
81
82
|
var DecisionOpenAIModel = class DecisionOpenAIModel {
|
|
82
83
|
constructor(modelId, config) {
|
|
83
84
|
this.modelId = modelId;
|
|
@@ -814,7 +815,7 @@ const openaiChatChunkSchema = lazySchema(() => zodSchema(z.union([z.object({
|
|
|
814
815
|
rejected_prediction_tokens: z.number().nullish()
|
|
815
816
|
}).nullish()
|
|
816
817
|
}).nullish()
|
|
817
|
-
}), openaiErrorDataSchema])));
|
|
818
|
+
}), openaiErrorDataSchema()])));
|
|
818
819
|
//#endregion
|
|
819
820
|
//#region src/chat/openai-chat-language-model-options.ts
|
|
820
821
|
const openaiLanguageModelChatOptions = lazySchema(() => zodSchema(z.object({
|
|
@@ -1441,7 +1442,7 @@ var OpenAIChatLanguageModel = class OpenAIChatLanguageModel {
|
|
|
1441
1442
|
});
|
|
1442
1443
|
let toolCallTracker;
|
|
1443
1444
|
let finishReason = {
|
|
1444
|
-
unified: "
|
|
1445
|
+
unified: "interrupted",
|
|
1445
1446
|
raw: void 0
|
|
1446
1447
|
};
|
|
1447
1448
|
let usage = void 0;
|
|
@@ -1674,7 +1675,7 @@ const openaiCompletionChunkSchema = lazySchema(() => zodSchema(z.union([z.object
|
|
|
1674
1675
|
completion_tokens: z.number(),
|
|
1675
1676
|
total_tokens: z.number()
|
|
1676
1677
|
}).nullish()
|
|
1677
|
-
}), openaiErrorDataSchema])));
|
|
1678
|
+
}), openaiErrorDataSchema()])));
|
|
1678
1679
|
//#endregion
|
|
1679
1680
|
//#region src/completion/openai-completion-language-model-options.ts
|
|
1680
1681
|
const openaiLanguageModelCompletionOptions = lazySchema(() => zodSchema(z.object({
|
|
@@ -1860,7 +1861,7 @@ var OpenAICompletionLanguageModel = class OpenAICompletionLanguageModel {
|
|
|
1860
1861
|
responseHeaders
|
|
1861
1862
|
});
|
|
1862
1863
|
let finishReason = {
|
|
1863
|
-
unified: "
|
|
1864
|
+
unified: "interrupted",
|
|
1864
1865
|
raw: void 0
|
|
1865
1866
|
};
|
|
1866
1867
|
const providerMetadata = { openai: {} };
|
|
@@ -2056,10 +2057,6 @@ const openaiFilesOptionsSchema = lazySchema(() => zodSchema(z.object({
|
|
|
2056
2057
|
})));
|
|
2057
2058
|
//#endregion
|
|
2058
2059
|
//#region src/files/openai-files.ts
|
|
2059
|
-
function encodePathSegment(value) {
|
|
2060
|
-
const encodedValue = encodeURIComponent(value);
|
|
2061
|
-
return encodedValue === "." ? "%252E" : encodedValue === ".." ? "%252E%252E" : encodedValue;
|
|
2062
|
-
}
|
|
2063
2060
|
var OpenAIFiles = class {
|
|
2064
2061
|
get provider() {
|
|
2065
2062
|
return this.config.provider;
|
|
@@ -2268,7 +2265,7 @@ function hasDefaultResponseFormat(modelId) {
|
|
|
2268
2265
|
function getMaxImagesPerCall(modelId) {
|
|
2269
2266
|
return modelMaxImagesPerCall[modelId] ?? (modelId.startsWith("gpt-image-") ? 10 : 1);
|
|
2270
2267
|
}
|
|
2271
|
-
const baseImageModelOptionsObject = z.object({
|
|
2268
|
+
const baseImageModelOptionsObject = () => z.object({
|
|
2272
2269
|
/**
|
|
2273
2270
|
* Quality of the generated image(s).
|
|
2274
2271
|
*
|
|
@@ -2315,8 +2312,8 @@ const baseImageModelOptionsObject = z.object({
|
|
|
2315
2312
|
*/
|
|
2316
2313
|
user: z.string().optional()
|
|
2317
2314
|
});
|
|
2318
|
-
lazySchema(() => zodSchema(baseImageModelOptionsObject));
|
|
2319
|
-
const openaiImageModelGenerationOptions = lazySchema(() => zodSchema(baseImageModelOptionsObject.extend({
|
|
2315
|
+
lazySchema(() => zodSchema(baseImageModelOptionsObject()));
|
|
2316
|
+
const openaiImageModelGenerationOptions = lazySchema(() => zodSchema(baseImageModelOptionsObject().extend({
|
|
2320
2317
|
/**
|
|
2321
2318
|
* Style of the generated image. `vivid` produces hyper-real and
|
|
2322
2319
|
* dramatic images; `natural` produces more subdued, less hyper-real
|
|
@@ -2329,7 +2326,7 @@ const openaiImageModelGenerationOptions = lazySchema(() => zodSchema(baseImageMo
|
|
|
2329
2326
|
*/
|
|
2330
2327
|
moderation: z.enum(["auto", "low"]).optional()
|
|
2331
2328
|
})));
|
|
2332
|
-
const openaiImageModelEditOptions = lazySchema(() => zodSchema(baseImageModelOptionsObject.extend({
|
|
2329
|
+
const openaiImageModelEditOptions = lazySchema(() => zodSchema(baseImageModelOptionsObject().extend({
|
|
2333
2330
|
/**
|
|
2334
2331
|
* Fidelity of the output image(s) to the input image(s).
|
|
2335
2332
|
*/
|
|
@@ -2595,12 +2592,12 @@ const codeInterpreter = (args = {}) => {
|
|
|
2595
2592
|
};
|
|
2596
2593
|
//#endregion
|
|
2597
2594
|
//#region src/tool/computer.ts
|
|
2598
|
-
const safetyCheckSchema = z.object({
|
|
2595
|
+
const safetyCheckSchema = () => z.object({
|
|
2599
2596
|
id: z.string(),
|
|
2600
2597
|
code: z.string().optional(),
|
|
2601
2598
|
message: z.string().optional()
|
|
2602
2599
|
});
|
|
2603
|
-
const computerActionSchema = z.discriminatedUnion("type", [
|
|
2600
|
+
const computerActionSchema = () => z.discriminatedUnion("type", [
|
|
2604
2601
|
z.object({
|
|
2605
2602
|
type: z.literal("click"),
|
|
2606
2603
|
button: z.enum([
|
|
@@ -2654,8 +2651,8 @@ const computerActionSchema = z.discriminatedUnion("type", [
|
|
|
2654
2651
|
z.object({ type: z.literal("wait") })
|
|
2655
2652
|
]);
|
|
2656
2653
|
const computerInputSchema = lazySchema(() => zodSchema(z.object({
|
|
2657
|
-
actions: z.array(computerActionSchema),
|
|
2658
|
-
pendingSafetyChecks: z.array(safetyCheckSchema),
|
|
2654
|
+
actions: z.array(computerActionSchema()),
|
|
2655
|
+
pendingSafetyChecks: z.array(safetyCheckSchema()),
|
|
2659
2656
|
status: z.enum([
|
|
2660
2657
|
"in_progress",
|
|
2661
2658
|
"completed",
|
|
@@ -2684,7 +2681,7 @@ const computerOutputSchema = lazySchema(() => zodSchema(z.object({
|
|
|
2684
2681
|
"original"
|
|
2685
2682
|
]).optional()
|
|
2686
2683
|
})]),
|
|
2687
|
-
acknowledgedSafetyChecks: z.array(safetyCheckSchema).optional()
|
|
2684
|
+
acknowledgedSafetyChecks: z.array(safetyCheckSchema()).optional()
|
|
2688
2685
|
})));
|
|
2689
2686
|
const computerToolFactory = createProviderDefinedToolFactoryWithOutputSchema({
|
|
2690
2687
|
id: "openai.computer",
|
|
@@ -2711,7 +2708,7 @@ const customToolFactory = createProviderDefinedToolFactory({
|
|
|
2711
2708
|
const customTool = (args) => customToolFactory(args);
|
|
2712
2709
|
//#endregion
|
|
2713
2710
|
//#region src/tool/file-search.ts
|
|
2714
|
-
const comparisonFilterSchema = z.object({
|
|
2711
|
+
const comparisonFilterSchema = () => z.object({
|
|
2715
2712
|
key: z.string(),
|
|
2716
2713
|
type: z.enum([
|
|
2717
2714
|
"eq",
|
|
@@ -2730,9 +2727,10 @@ const comparisonFilterSchema = z.object({
|
|
|
2730
2727
|
z.array(z.string())
|
|
2731
2728
|
])
|
|
2732
2729
|
});
|
|
2733
|
-
|
|
2730
|
+
let cachedCompoundFilterSchema;
|
|
2731
|
+
const compoundFilterSchema = () => cachedCompoundFilterSchema ??= z.object({
|
|
2734
2732
|
type: z.enum(["and", "or"]),
|
|
2735
|
-
filters: z.array(z.union([comparisonFilterSchema, z.lazy(() => compoundFilterSchema)]))
|
|
2733
|
+
filters: z.array(z.union([comparisonFilterSchema(), z.lazy(() => compoundFilterSchema())]))
|
|
2736
2734
|
});
|
|
2737
2735
|
const fileSearchArgsSchema = lazySchema(() => zodSchema(z.object({
|
|
2738
2736
|
vectorStoreIds: z.array(z.string()),
|
|
@@ -2741,7 +2739,7 @@ const fileSearchArgsSchema = lazySchema(() => zodSchema(z.object({
|
|
|
2741
2739
|
ranker: z.string().optional(),
|
|
2742
2740
|
scoreThreshold: z.number().optional()
|
|
2743
2741
|
}).optional(),
|
|
2744
|
-
filters: z.union([comparisonFilterSchema, compoundFilterSchema]).optional()
|
|
2742
|
+
filters: z.union([comparisonFilterSchema(), compoundFilterSchema()]).optional()
|
|
2745
2743
|
})));
|
|
2746
2744
|
const fileSearchOutputSchema = lazySchema(() => zodSchema(z.object({
|
|
2747
2745
|
queries: z.array(z.string()),
|
|
@@ -2844,7 +2842,7 @@ const shellOutputSchema = lazySchema(() => zodSchema(z.object({
|
|
|
2844
2842
|
})])
|
|
2845
2843
|
}))
|
|
2846
2844
|
})));
|
|
2847
|
-
const shellSkillsSchema = z.array(z.discriminatedUnion("type", [z.object({
|
|
2845
|
+
const shellSkillsSchema = () => z.array(z.discriminatedUnion("type", [z.object({
|
|
2848
2846
|
type: z.literal("skillReference"),
|
|
2849
2847
|
providerReference: z.record(z.string(), z.string()),
|
|
2850
2848
|
version: z.string().optional()
|
|
@@ -2877,7 +2875,7 @@ const shellArgsSchema = lazySchema(() => zodSchema(z.object({ environment: z.uni
|
|
|
2877
2875
|
value: z.string()
|
|
2878
2876
|
})).optional()
|
|
2879
2877
|
})]).optional(),
|
|
2880
|
-
skills: shellSkillsSchema
|
|
2878
|
+
skills: shellSkillsSchema()
|
|
2881
2879
|
}),
|
|
2882
2880
|
z.object({
|
|
2883
2881
|
type: z.literal("containerReference"),
|
|
@@ -3007,13 +3005,14 @@ const webSearchPreview = createProviderExecutedToolFactory({
|
|
|
3007
3005
|
});
|
|
3008
3006
|
//#endregion
|
|
3009
3007
|
//#region src/tool/mcp.ts
|
|
3010
|
-
|
|
3008
|
+
let cachedJsonValueSchema$1;
|
|
3009
|
+
const jsonValueSchema$1 = () => cachedJsonValueSchema$1 ??= z.lazy(() => z.union([
|
|
3011
3010
|
z.string(),
|
|
3012
3011
|
z.number(),
|
|
3013
3012
|
z.boolean(),
|
|
3014
3013
|
z.null(),
|
|
3015
|
-
z.array(jsonValueSchema$1),
|
|
3016
|
-
z.record(z.string(), jsonValueSchema$1)
|
|
3014
|
+
z.array(jsonValueSchema$1()),
|
|
3015
|
+
z.record(z.string(), jsonValueSchema$1())
|
|
3017
3016
|
]));
|
|
3018
3017
|
const mcpArgsSchema = lazySchema(() => zodSchema(z.object({
|
|
3019
3018
|
serverLabel: z.string(),
|
|
@@ -3035,7 +3034,7 @@ const mcpOutputSchema = lazySchema(() => zodSchema(z.object({
|
|
|
3035
3034
|
name: z.string(),
|
|
3036
3035
|
arguments: z.string(),
|
|
3037
3036
|
output: z.string().nullish(),
|
|
3038
|
-
error: z.union([z.string(), jsonValueSchema$1]).optional()
|
|
3037
|
+
error: z.union([z.string(), jsonValueSchema$1()]).optional()
|
|
3039
3038
|
})));
|
|
3040
3039
|
const mcpToolFactory = createProviderExecutedToolFactory({
|
|
3041
3040
|
id: "openai.mcp",
|
|
@@ -3243,36 +3242,41 @@ function mapOpenAIResponseFinishReason({ finishReason, hasFunctionCall }) {
|
|
|
3243
3242
|
}
|
|
3244
3243
|
//#endregion
|
|
3245
3244
|
//#region src/responses/openai-responses-api.ts
|
|
3246
|
-
|
|
3245
|
+
let cachedJsonValueSchema;
|
|
3246
|
+
const jsonValueSchema = () => cachedJsonValueSchema ??= z.lazy(() => z.union([
|
|
3247
3247
|
z.string(),
|
|
3248
3248
|
z.number(),
|
|
3249
3249
|
z.boolean(),
|
|
3250
3250
|
z.null(),
|
|
3251
|
-
z.array(jsonValueSchema),
|
|
3252
|
-
z.record(z.string(), jsonValueSchema.optional())
|
|
3251
|
+
z.array(jsonValueSchema()),
|
|
3252
|
+
z.record(z.string(), jsonValueSchema().optional())
|
|
3253
3253
|
]));
|
|
3254
|
-
const jsonObjectSchema = z.record(z.string(), jsonValueSchema.optional());
|
|
3255
|
-
const openaiResponsesUsageSchema = z.intersection(jsonObjectSchema, z.object({
|
|
3254
|
+
const jsonObjectSchema = () => z.record(z.string(), jsonValueSchema().optional());
|
|
3255
|
+
const openaiResponsesUsageSchema = () => z.intersection(jsonObjectSchema(), z.object({
|
|
3256
3256
|
input_tokens: z.number(),
|
|
3257
|
-
input_tokens_details: z.intersection(jsonObjectSchema, z.object({
|
|
3257
|
+
input_tokens_details: z.intersection(jsonObjectSchema(), z.object({
|
|
3258
3258
|
cached_tokens: z.number().nullish(),
|
|
3259
3259
|
cache_write_tokens: z.number().nullish(),
|
|
3260
|
+
cache_write_tokens_details: z.intersection(jsonObjectSchema(), z.object({
|
|
3261
|
+
ttl_30m_tokens: z.number().nullish(),
|
|
3262
|
+
ttl_12h_tokens: z.number().nullish()
|
|
3263
|
+
})).nullish(),
|
|
3260
3264
|
orchestration_input_tokens: z.number().nullish(),
|
|
3261
3265
|
orchestration_input_cached_tokens: z.number().nullish()
|
|
3262
3266
|
})).nullish(),
|
|
3263
3267
|
output_tokens: z.number(),
|
|
3264
|
-
output_tokens_details: z.intersection(jsonObjectSchema, z.object({
|
|
3268
|
+
output_tokens_details: z.intersection(jsonObjectSchema(), z.object({
|
|
3265
3269
|
reasoning_tokens: z.number().nullish(),
|
|
3266
3270
|
orchestration_output_tokens: z.number().nullish()
|
|
3267
3271
|
})).nullish(),
|
|
3268
3272
|
total_tokens: z.number().optional()
|
|
3269
3273
|
}));
|
|
3270
|
-
const openaiResponsesComputerSafetyCheckSchema = z.object({
|
|
3274
|
+
const openaiResponsesComputerSafetyCheckSchema = () => z.object({
|
|
3271
3275
|
id: z.string(),
|
|
3272
3276
|
code: z.string().nullish(),
|
|
3273
3277
|
message: z.string().nullish()
|
|
3274
3278
|
});
|
|
3275
|
-
const openaiResponsesComputerActionSchema = z.discriminatedUnion("type", [
|
|
3279
|
+
const openaiResponsesComputerActionSchema = () => z.discriminatedUnion("type", [
|
|
3276
3280
|
z.object({
|
|
3277
3281
|
type: z.literal("click"),
|
|
3278
3282
|
button: z.enum([
|
|
@@ -3325,7 +3329,7 @@ const openaiResponsesComputerActionSchema = z.discriminatedUnion("type", [
|
|
|
3325
3329
|
}),
|
|
3326
3330
|
z.object({ type: z.literal("wait") })
|
|
3327
3331
|
]);
|
|
3328
|
-
const openaiResponsesComputerCallSchema = z.object({
|
|
3332
|
+
const openaiResponsesComputerCallSchema = () => z.object({
|
|
3329
3333
|
type: z.literal("computer_call"),
|
|
3330
3334
|
id: z.string(),
|
|
3331
3335
|
call_id: z.string().nullish(),
|
|
@@ -3334,29 +3338,29 @@ const openaiResponsesComputerCallSchema = z.object({
|
|
|
3334
3338
|
"completed",
|
|
3335
3339
|
"incomplete"
|
|
3336
3340
|
]),
|
|
3337
|
-
action: openaiResponsesComputerActionSchema.nullish(),
|
|
3338
|
-
actions: z.array(openaiResponsesComputerActionSchema).nullish(),
|
|
3339
|
-
pending_safety_checks: z.array(openaiResponsesComputerSafetyCheckSchema).nullish()
|
|
3341
|
+
action: openaiResponsesComputerActionSchema().nullish(),
|
|
3342
|
+
actions: z.array(openaiResponsesComputerActionSchema()).nullish(),
|
|
3343
|
+
pending_safety_checks: z.array(openaiResponsesComputerSafetyCheckSchema()).nullish()
|
|
3340
3344
|
});
|
|
3341
|
-
const openaiResponsesToolCallerSchema = z.discriminatedUnion("type", [z.object({ type: z.literal("direct") }), z.object({
|
|
3345
|
+
const openaiResponsesToolCallerSchema = () => z.discriminatedUnion("type", [z.object({ type: z.literal("direct") }), z.object({
|
|
3342
3346
|
type: z.literal("program"),
|
|
3343
3347
|
caller_id: z.string()
|
|
3344
3348
|
})]);
|
|
3345
|
-
const openaiResponsesProgramSchema = z.object({
|
|
3349
|
+
const openaiResponsesProgramSchema = () => z.object({
|
|
3346
3350
|
type: z.literal("program"),
|
|
3347
3351
|
id: z.string(),
|
|
3348
3352
|
call_id: z.string(),
|
|
3349
3353
|
code: z.string(),
|
|
3350
3354
|
fingerprint: z.string()
|
|
3351
3355
|
});
|
|
3352
|
-
const openaiResponsesProgramOutputSchema = z.object({
|
|
3356
|
+
const openaiResponsesProgramOutputSchema = () => z.object({
|
|
3353
3357
|
type: z.literal("program_output"),
|
|
3354
3358
|
id: z.string(),
|
|
3355
3359
|
call_id: z.string(),
|
|
3356
3360
|
result: z.string(),
|
|
3357
3361
|
status: z.enum(["completed", "incomplete"])
|
|
3358
3362
|
});
|
|
3359
|
-
const openaiResponsesLocalShellCallSchema = z.object({
|
|
3363
|
+
const openaiResponsesLocalShellCallSchema = () => z.object({
|
|
3360
3364
|
type: z.literal("local_shell_call"),
|
|
3361
3365
|
id: z.string(),
|
|
3362
3366
|
call_id: z.string(),
|
|
@@ -3369,7 +3373,7 @@ const openaiResponsesLocalShellCallSchema = z.object({
|
|
|
3369
3373
|
env: z.record(z.string(), z.string()).optional()
|
|
3370
3374
|
})
|
|
3371
3375
|
});
|
|
3372
|
-
const openaiResponsesNestedErrorChunkSchema = z.object({
|
|
3376
|
+
const openaiResponsesNestedErrorChunkSchema = () => z.object({
|
|
3373
3377
|
type: z.literal("error"),
|
|
3374
3378
|
sequence_number: z.number(),
|
|
3375
3379
|
error: z.object({
|
|
@@ -3379,7 +3383,7 @@ const openaiResponsesNestedErrorChunkSchema = z.object({
|
|
|
3379
3383
|
param: z.string().nullish()
|
|
3380
3384
|
})
|
|
3381
3385
|
});
|
|
3382
|
-
const openaiResponsesErrorChunkSchema = z.object({
|
|
3386
|
+
const openaiResponsesErrorChunkSchema = () => z.object({
|
|
3383
3387
|
type: z.literal("error"),
|
|
3384
3388
|
sequence_number: z.number(),
|
|
3385
3389
|
code: z.string().nullish(),
|
|
@@ -3467,7 +3471,7 @@ const openaiResponsesChunkSchema = lazySchema(() => zodSchema(z.union([
|
|
|
3467
3471
|
type: z.enum(["response.completed", "response.incomplete"]),
|
|
3468
3472
|
response: z.object({
|
|
3469
3473
|
incomplete_details: z.object({ reason: z.string() }).nullish(),
|
|
3470
|
-
usage: openaiResponsesUsageSchema.nullish(),
|
|
3474
|
+
usage: openaiResponsesUsageSchema().nullish(),
|
|
3471
3475
|
reasoning: z.object({ context: z.string().nullish() }).nullish(),
|
|
3472
3476
|
service_tier: z.string().nullish()
|
|
3473
3477
|
})
|
|
@@ -3481,7 +3485,7 @@ const openaiResponsesChunkSchema = lazySchema(() => zodSchema(z.union([
|
|
|
3481
3485
|
message: z.string()
|
|
3482
3486
|
}).nullish(),
|
|
3483
3487
|
incomplete_details: z.object({ reason: z.string() }).nullish(),
|
|
3484
|
-
usage: openaiResponsesUsageSchema.nullish(),
|
|
3488
|
+
usage: openaiResponsesUsageSchema().nullish(),
|
|
3485
3489
|
reasoning: z.object({ context: z.string().nullish() }).nullish(),
|
|
3486
3490
|
service_tier: z.string().nullish()
|
|
3487
3491
|
})
|
|
@@ -3526,21 +3530,21 @@ const openaiResponsesChunkSchema = lazySchema(() => zodSchema(z.union([
|
|
|
3526
3530
|
arguments: z.string(),
|
|
3527
3531
|
async: z.boolean().nullish(),
|
|
3528
3532
|
namespace: z.string().nullish(),
|
|
3529
|
-
caller: openaiResponsesToolCallerSchema.nullish()
|
|
3533
|
+
caller: openaiResponsesToolCallerSchema().nullish()
|
|
3530
3534
|
}),
|
|
3531
|
-
openaiResponsesProgramSchema,
|
|
3532
|
-
openaiResponsesProgramOutputSchema,
|
|
3535
|
+
openaiResponsesProgramSchema(),
|
|
3536
|
+
openaiResponsesProgramOutputSchema(),
|
|
3533
3537
|
z.object({
|
|
3534
3538
|
type: z.literal("web_search_call"),
|
|
3535
3539
|
id: z.string(),
|
|
3536
3540
|
status: z.string()
|
|
3537
3541
|
}),
|
|
3538
|
-
openaiResponsesComputerCallSchema,
|
|
3542
|
+
openaiResponsesComputerCallSchema(),
|
|
3539
3543
|
z.object({
|
|
3540
3544
|
type: z.literal("file_search_call"),
|
|
3541
3545
|
id: z.string()
|
|
3542
3546
|
}),
|
|
3543
|
-
openaiResponsesLocalShellCallSchema,
|
|
3547
|
+
openaiResponsesLocalShellCallSchema(),
|
|
3544
3548
|
z.object({
|
|
3545
3549
|
type: z.literal("image_generation_call"),
|
|
3546
3550
|
id: z.string()
|
|
@@ -3664,7 +3668,7 @@ const openaiResponsesChunkSchema = lazySchema(() => zodSchema(z.union([
|
|
|
3664
3668
|
"completed",
|
|
3665
3669
|
"incomplete"
|
|
3666
3670
|
]),
|
|
3667
|
-
tools: z.array(z.record(z.string(), jsonValueSchema.optional()))
|
|
3671
|
+
tools: z.array(z.record(z.string(), jsonValueSchema().optional()))
|
|
3668
3672
|
})
|
|
3669
3673
|
])
|
|
3670
3674
|
}),
|
|
@@ -3695,10 +3699,10 @@ const openaiResponsesChunkSchema = lazySchema(() => zodSchema(z.union([
|
|
|
3695
3699
|
"incomplete"
|
|
3696
3700
|
]),
|
|
3697
3701
|
namespace: z.string().nullish(),
|
|
3698
|
-
caller: openaiResponsesToolCallerSchema.nullish()
|
|
3702
|
+
caller: openaiResponsesToolCallerSchema().nullish()
|
|
3699
3703
|
}),
|
|
3700
|
-
openaiResponsesProgramSchema,
|
|
3701
|
-
openaiResponsesProgramOutputSchema,
|
|
3704
|
+
openaiResponsesProgramSchema(),
|
|
3705
|
+
openaiResponsesProgramOutputSchema(),
|
|
3702
3706
|
z.object({
|
|
3703
3707
|
type: z.literal("custom_tool_call"),
|
|
3704
3708
|
id: z.string(),
|
|
@@ -3770,8 +3774,8 @@ const openaiResponsesChunkSchema = lazySchema(() => zodSchema(z.union([
|
|
|
3770
3774
|
text: z.string()
|
|
3771
3775
|
})).nullish()
|
|
3772
3776
|
}),
|
|
3773
|
-
openaiResponsesLocalShellCallSchema,
|
|
3774
|
-
openaiResponsesComputerCallSchema,
|
|
3777
|
+
openaiResponsesLocalShellCallSchema(),
|
|
3778
|
+
openaiResponsesComputerCallSchema(),
|
|
3775
3779
|
z.object({
|
|
3776
3780
|
type: z.literal("mcp_call"),
|
|
3777
3781
|
id: z.string(),
|
|
@@ -3894,7 +3898,7 @@ const openaiResponsesChunkSchema = lazySchema(() => zodSchema(z.union([
|
|
|
3894
3898
|
"completed",
|
|
3895
3899
|
"incomplete"
|
|
3896
3900
|
]),
|
|
3897
|
-
tools: z.array(z.record(z.string(), jsonValueSchema.optional()))
|
|
3901
|
+
tools: z.array(z.record(z.string(), jsonValueSchema().optional()))
|
|
3898
3902
|
})
|
|
3899
3903
|
])
|
|
3900
3904
|
}),
|
|
@@ -3997,8 +4001,8 @@ const openaiResponsesChunkSchema = lazySchema(() => zodSchema(z.union([
|
|
|
3997
4001
|
output_index: z.number(),
|
|
3998
4002
|
diff: z.string()
|
|
3999
4003
|
}),
|
|
4000
|
-
openaiResponsesNestedErrorChunkSchema,
|
|
4001
|
-
openaiResponsesErrorChunkSchema,
|
|
4004
|
+
openaiResponsesNestedErrorChunkSchema(),
|
|
4005
|
+
openaiResponsesErrorChunkSchema(),
|
|
4002
4006
|
z.object({ type: z.string() }).loose().refine((value) => !isModeledOpenAIResponsesChunk(value), { message: "Known response chunk failed schema validation" }).transform((value) => ({
|
|
4003
4007
|
type: "unknown_chunk",
|
|
4004
4008
|
message: value.type
|
|
@@ -4123,7 +4127,7 @@ const openaiResponsesResponseSchema = lazySchema(() => zodSchema(z.object({
|
|
|
4123
4127
|
id: z.string(),
|
|
4124
4128
|
result: z.string()
|
|
4125
4129
|
}),
|
|
4126
|
-
openaiResponsesLocalShellCallSchema,
|
|
4130
|
+
openaiResponsesLocalShellCallSchema(),
|
|
4127
4131
|
z.object({
|
|
4128
4132
|
type: z.literal("function_call"),
|
|
4129
4133
|
call_id: z.string(),
|
|
@@ -4132,10 +4136,10 @@ const openaiResponsesResponseSchema = lazySchema(() => zodSchema(z.object({
|
|
|
4132
4136
|
id: z.string(),
|
|
4133
4137
|
async: z.boolean().nullish(),
|
|
4134
4138
|
namespace: z.string().nullish(),
|
|
4135
|
-
caller: openaiResponsesToolCallerSchema.nullish()
|
|
4139
|
+
caller: openaiResponsesToolCallerSchema().nullish()
|
|
4136
4140
|
}),
|
|
4137
|
-
openaiResponsesProgramSchema,
|
|
4138
|
-
openaiResponsesProgramOutputSchema,
|
|
4141
|
+
openaiResponsesProgramSchema(),
|
|
4142
|
+
openaiResponsesProgramOutputSchema(),
|
|
4139
4143
|
z.object({
|
|
4140
4144
|
type: z.literal("custom_tool_call"),
|
|
4141
4145
|
call_id: z.string(),
|
|
@@ -4144,7 +4148,7 @@ const openaiResponsesResponseSchema = lazySchema(() => zodSchema(z.object({
|
|
|
4144
4148
|
id: z.string(),
|
|
4145
4149
|
async: z.boolean().nullish()
|
|
4146
4150
|
}),
|
|
4147
|
-
openaiResponsesComputerCallSchema,
|
|
4151
|
+
openaiResponsesComputerCallSchema(),
|
|
4148
4152
|
z.object({
|
|
4149
4153
|
type: z.literal("reasoning"),
|
|
4150
4154
|
id: z.string(),
|
|
@@ -4276,13 +4280,13 @@ const openaiResponsesResponseSchema = lazySchema(() => zodSchema(z.object({
|
|
|
4276
4280
|
"completed",
|
|
4277
4281
|
"incomplete"
|
|
4278
4282
|
]),
|
|
4279
|
-
tools: z.array(z.record(z.string(), jsonValueSchema.optional()))
|
|
4283
|
+
tools: z.array(z.record(z.string(), jsonValueSchema().optional()))
|
|
4280
4284
|
})
|
|
4281
4285
|
])).optional(),
|
|
4282
4286
|
service_tier: z.string().nullish(),
|
|
4283
4287
|
reasoning: z.object({ context: z.string().nullish() }).nullish(),
|
|
4284
4288
|
incomplete_details: z.object({ reason: z.string() }).nullish(),
|
|
4285
|
-
usage: openaiResponsesUsageSchema.nullish()
|
|
4289
|
+
usage: openaiResponsesUsageSchema().nullish()
|
|
4286
4290
|
})));
|
|
4287
4291
|
const openaiLanguageModelResponsesOptionsSchema = lazySchema(() => zodSchema(z.object({
|
|
4288
4292
|
/**
|
|
@@ -4358,11 +4362,13 @@ const openaiLanguageModelResponsesOptionsSchema = lazySchema(() => zodSchema(z.o
|
|
|
4358
4362
|
/**
|
|
4359
4363
|
* Prompt cache behavior for GPT-5.6 and later models.
|
|
4360
4364
|
* `mode` controls whether OpenAI also places an implicit breakpoint.
|
|
4361
|
-
* `ttl` sets the minimum cache lifetime
|
|
4365
|
+
* `ttl` sets the minimum cache lifetime: `'30m'` (default) or `'12h'`.
|
|
4366
|
+
* `prewarm` writes the prompt to the cache without generating output.
|
|
4362
4367
|
*/
|
|
4363
4368
|
promptCacheOptions: z.object({
|
|
4364
4369
|
mode: z.enum(["implicit", "explicit"]).optional(),
|
|
4365
|
-
ttl: z.
|
|
4370
|
+
ttl: z.enum(["30m", "12h"]).optional(),
|
|
4371
|
+
prewarm: z.boolean().optional()
|
|
4366
4372
|
}).optional(),
|
|
4367
4373
|
/**
|
|
4368
4374
|
* The retention policy for the prompt cache.
|
|
@@ -5639,10 +5645,10 @@ async function convertToOpenAIResponsesInput({ prompt, toolNameMapping, systemMe
|
|
|
5639
5645
|
warnings
|
|
5640
5646
|
};
|
|
5641
5647
|
}
|
|
5642
|
-
const openaiResponsesReasoningProviderOptionsSchema = z.object({
|
|
5648
|
+
const openaiResponsesReasoningProviderOptionsSchema = lazySchema(() => zodSchema(z.object({
|
|
5643
5649
|
itemId: z.string().nullish(),
|
|
5644
5650
|
reasoningEncryptedContent: z.string().nullish()
|
|
5645
|
-
});
|
|
5651
|
+
})));
|
|
5646
5652
|
//#endregion
|
|
5647
5653
|
//#region src/responses/map-openai-responses-annotation.ts
|
|
5648
5654
|
function mapOpenAIResponsesAnnotationSource(annotation, providerOptionsName, id) {
|
|
@@ -7016,7 +7022,7 @@ var OpenAIResponsesLanguageModel = class OpenAIResponsesLanguageModel {
|
|
|
7016
7022
|
const functionTools = options.tools?.filter((tool) => tool.type === "function") ?? [];
|
|
7017
7023
|
const approvalRequestIdToDummyToolCallIdFromStream = /* @__PURE__ */ new Map();
|
|
7018
7024
|
let finishReason = {
|
|
7019
|
-
unified: "
|
|
7025
|
+
unified: "interrupted",
|
|
7020
7026
|
raw: void 0
|
|
7021
7027
|
};
|
|
7022
7028
|
let usage = void 0;
|
|
@@ -8414,7 +8420,7 @@ function convertUnixTimestamp(value) {
|
|
|
8414
8420
|
async function convertOpenAIErrorResponse({ body, statusCode }) {
|
|
8415
8421
|
const result = await safeValidateTypes({
|
|
8416
8422
|
value: body,
|
|
8417
|
-
schema:
|
|
8423
|
+
schema: openaiErrorDataSchemaValidator
|
|
8418
8424
|
});
|
|
8419
8425
|
if (!result.success) return {
|
|
8420
8426
|
message: `OpenAI batch request failed with status code ${statusCode}.`,
|
|
@@ -8933,13 +8939,13 @@ function serializeOpenAILiveClientEvent(event, modelId) {
|
|
|
8933
8939
|
}
|
|
8934
8940
|
//#endregion
|
|
8935
8941
|
//#region src/live/openai-realtime-model-live.ts
|
|
8936
|
-
const webRTCSessionSchema = z.object({
|
|
8942
|
+
const webRTCSessionSchema = lazySchema(() => zodSchema(z.object({
|
|
8937
8943
|
session: z.object({ id: z.string().min(1) }),
|
|
8938
8944
|
transport: z.object({
|
|
8939
8945
|
type: z.literal("webrtc"),
|
|
8940
8946
|
sdp: z.string().min(1)
|
|
8941
8947
|
})
|
|
8942
|
-
});
|
|
8948
|
+
})));
|
|
8943
8949
|
var OpenAIRealtimeModelLive = class {
|
|
8944
8950
|
constructor(modelId, config) {
|
|
8945
8951
|
this.modelId = modelId;
|
|
@@ -10242,7 +10248,7 @@ var OpenAISkills = class {
|
|
|
10242
10248
|
};
|
|
10243
10249
|
//#endregion
|
|
10244
10250
|
//#region src/version.ts
|
|
10245
|
-
const VERSION = "4.0.
|
|
10251
|
+
const VERSION = "4.0.100";
|
|
10246
10252
|
//#endregion
|
|
10247
10253
|
//#region src/openai-provider.ts
|
|
10248
10254
|
/**
|