@ai-sdk/openai 4.0.98 → 4.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 +11 -0
- package/dist/index.d.ts +14 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +92 -86
- 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 +79 -69
- package/dist/internal/index.js.map +1 -1
- package/docs/03-openai.mdx +52 -8
- package/package.json +2 -2
- package/src/chat/openai-chat-api.ts +1 -1
- package/src/completion/openai-completion-api.ts +1 -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/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/internal/index.js
CHANGED
|
@@ -2,14 +2,15 @@ import { APICallError, InvalidPromptError, InvalidResponseDataError, TooManyEmbe
|
|
|
2
2
|
import { EXPERIMENTAL_EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL, StreamingToolCallTracker, WORKFLOW_DESERIALIZE, WORKFLOW_SERIALIZE, combineHeaders, connectToWebSocket, convertBase64ToUint8Array, convertToBase64, convertToFormData, createBinaryResponseHandler, createEventSourceResponseHandler, createJsonErrorResponseHandler, createJsonResponseHandler, createLanguageModelResponseMetadata, createLanguageModelResponseMetadata as getResponseMetadata, createNullLanguageModelUsage, createProviderDefinedToolFactory, createProviderDefinedToolFactoryWithOutputSchema, createProviderExecutedToolFactory, createProviderStreamError, createToolNameMapping, downloadBlob, experimental_toolCaller, generateId, getTopLevelMediaType, isCustomReasoning, isNonNullable, isRecord, lazySchema, mediaTypeToExtension, parseJSON, parseProviderOptions, postFormDataToApi, postJsonToApi, resolveFullMediaType, resolveProviderReference, safeParseJSON, safeValidateTypes, serializeModelOptions, toWebSocketUrl, validateTypes, waitForWebSocketBufferDrain, zodSchema } from "@ai-sdk/provider-utils";
|
|
3
3
|
import { z } from "zod/v4";
|
|
4
4
|
//#region src/openai-error.ts
|
|
5
|
-
const openaiErrorDataSchema = z.object({ error: z.object({
|
|
5
|
+
const openaiErrorDataSchema = () => z.object({ error: z.object({
|
|
6
6
|
message: z.string(),
|
|
7
7
|
type: z.string().nullish(),
|
|
8
8
|
param: z.any().nullish(),
|
|
9
9
|
code: z.union([z.string(), z.number()]).nullish()
|
|
10
10
|
}) });
|
|
11
|
+
const openaiErrorDataSchemaValidator = lazySchema(() => zodSchema(openaiErrorDataSchema()));
|
|
11
12
|
const openaiFailedResponseHandler = createJsonErrorResponseHandler({
|
|
12
|
-
errorSchema:
|
|
13
|
+
errorSchema: openaiErrorDataSchemaValidator,
|
|
13
14
|
errorToMessage: (data) => data.error.message
|
|
14
15
|
});
|
|
15
16
|
//#endregion
|
|
@@ -567,7 +568,7 @@ const openaiChatChunkSchema = lazySchema(() => zodSchema(z.union([z.object({
|
|
|
567
568
|
rejected_prediction_tokens: z.number().nullish()
|
|
568
569
|
}).nullish()
|
|
569
570
|
}).nullish()
|
|
570
|
-
}), openaiErrorDataSchema])));
|
|
571
|
+
}), openaiErrorDataSchema()])));
|
|
571
572
|
//#endregion
|
|
572
573
|
//#region src/chat/openai-chat-language-model-options.ts
|
|
573
574
|
const openaiLanguageModelChatOptions = lazySchema(() => zodSchema(z.object({
|
|
@@ -1427,7 +1428,7 @@ const openaiCompletionChunkSchema = lazySchema(() => zodSchema(z.union([z.object
|
|
|
1427
1428
|
completion_tokens: z.number(),
|
|
1428
1429
|
total_tokens: z.number()
|
|
1429
1430
|
}).nullish()
|
|
1430
|
-
}), openaiErrorDataSchema])));
|
|
1431
|
+
}), openaiErrorDataSchema()])));
|
|
1431
1432
|
//#endregion
|
|
1432
1433
|
//#region src/completion/openai-completion-language-model-options.ts
|
|
1433
1434
|
const openaiLanguageModelCompletionOptions = lazySchema(() => zodSchema(z.object({
|
|
@@ -1828,7 +1829,7 @@ function hasDefaultResponseFormat(modelId) {
|
|
|
1828
1829
|
function getMaxImagesPerCall(modelId) {
|
|
1829
1830
|
return modelMaxImagesPerCall[modelId] ?? (modelId.startsWith("gpt-image-") ? 10 : 1);
|
|
1830
1831
|
}
|
|
1831
|
-
const baseImageModelOptionsObject = z.object({
|
|
1832
|
+
const baseImageModelOptionsObject = () => z.object({
|
|
1832
1833
|
/**
|
|
1833
1834
|
* Quality of the generated image(s).
|
|
1834
1835
|
*
|
|
@@ -1875,8 +1876,8 @@ const baseImageModelOptionsObject = z.object({
|
|
|
1875
1876
|
*/
|
|
1876
1877
|
user: z.string().optional()
|
|
1877
1878
|
});
|
|
1878
|
-
const openaiImageModelOptions = lazySchema(() => zodSchema(baseImageModelOptionsObject));
|
|
1879
|
-
const openaiImageModelGenerationOptions = lazySchema(() => zodSchema(baseImageModelOptionsObject.extend({
|
|
1879
|
+
const openaiImageModelOptions = lazySchema(() => zodSchema(baseImageModelOptionsObject()));
|
|
1880
|
+
const openaiImageModelGenerationOptions = lazySchema(() => zodSchema(baseImageModelOptionsObject().extend({
|
|
1880
1881
|
/**
|
|
1881
1882
|
* Style of the generated image. `vivid` produces hyper-real and
|
|
1882
1883
|
* dramatic images; `natural` produces more subdued, less hyper-real
|
|
@@ -1889,7 +1890,7 @@ const openaiImageModelGenerationOptions = lazySchema(() => zodSchema(baseImageMo
|
|
|
1889
1890
|
*/
|
|
1890
1891
|
moderation: z.enum(["auto", "low"]).optional()
|
|
1891
1892
|
})));
|
|
1892
|
-
const openaiImageModelEditOptions = lazySchema(() => zodSchema(baseImageModelOptionsObject.extend({
|
|
1893
|
+
const openaiImageModelEditOptions = lazySchema(() => zodSchema(baseImageModelOptionsObject().extend({
|
|
1893
1894
|
/**
|
|
1894
1895
|
* Fidelity of the output image(s) to the input image(s).
|
|
1895
1896
|
*/
|
|
@@ -2770,11 +2771,13 @@ const openaiLanguageModelResponsesOptionsSchema = lazySchema(() => zodSchema(z.o
|
|
|
2770
2771
|
/**
|
|
2771
2772
|
* Prompt cache behavior for GPT-5.6 and later models.
|
|
2772
2773
|
* `mode` controls whether OpenAI also places an implicit breakpoint.
|
|
2773
|
-
* `ttl` sets the minimum cache lifetime
|
|
2774
|
+
* `ttl` sets the minimum cache lifetime: `'30m'` (default) or `'12h'`.
|
|
2775
|
+
* `prewarm` writes the prompt to the cache without generating output.
|
|
2774
2776
|
*/
|
|
2775
2777
|
promptCacheOptions: z.object({
|
|
2776
2778
|
mode: z.enum(["implicit", "explicit"]).optional(),
|
|
2777
|
-
ttl: z.
|
|
2779
|
+
ttl: z.enum(["30m", "12h"]).optional(),
|
|
2780
|
+
prewarm: z.boolean().optional()
|
|
2778
2781
|
}).optional(),
|
|
2779
2782
|
/**
|
|
2780
2783
|
* The retention policy for the prompt cache.
|
|
@@ -3032,12 +3035,12 @@ const applyPatchToolFactory = createProviderDefinedToolFactoryWithOutputSchema({
|
|
|
3032
3035
|
const applyPatch = applyPatchToolFactory;
|
|
3033
3036
|
//#endregion
|
|
3034
3037
|
//#region src/tool/computer.ts
|
|
3035
|
-
const safetyCheckSchema = z.object({
|
|
3038
|
+
const safetyCheckSchema = () => z.object({
|
|
3036
3039
|
id: z.string(),
|
|
3037
3040
|
code: z.string().optional(),
|
|
3038
3041
|
message: z.string().optional()
|
|
3039
3042
|
});
|
|
3040
|
-
const computerActionSchema = z.discriminatedUnion("type", [
|
|
3043
|
+
const computerActionSchema = () => z.discriminatedUnion("type", [
|
|
3041
3044
|
z.object({
|
|
3042
3045
|
type: z.literal("click"),
|
|
3043
3046
|
button: z.enum([
|
|
@@ -3091,8 +3094,8 @@ const computerActionSchema = z.discriminatedUnion("type", [
|
|
|
3091
3094
|
z.object({ type: z.literal("wait") })
|
|
3092
3095
|
]);
|
|
3093
3096
|
const computerInputSchema = lazySchema(() => zodSchema(z.object({
|
|
3094
|
-
actions: z.array(computerActionSchema),
|
|
3095
|
-
pendingSafetyChecks: z.array(safetyCheckSchema),
|
|
3097
|
+
actions: z.array(computerActionSchema()),
|
|
3098
|
+
pendingSafetyChecks: z.array(safetyCheckSchema()),
|
|
3096
3099
|
status: z.enum([
|
|
3097
3100
|
"in_progress",
|
|
3098
3101
|
"completed",
|
|
@@ -3121,7 +3124,7 @@ const computerOutputSchema = lazySchema(() => zodSchema(z.object({
|
|
|
3121
3124
|
"original"
|
|
3122
3125
|
]).optional()
|
|
3123
3126
|
})]),
|
|
3124
|
-
acknowledgedSafetyChecks: z.array(safetyCheckSchema).optional()
|
|
3127
|
+
acknowledgedSafetyChecks: z.array(safetyCheckSchema()).optional()
|
|
3125
3128
|
})));
|
|
3126
3129
|
createProviderDefinedToolFactoryWithOutputSchema({
|
|
3127
3130
|
id: "openai.computer",
|
|
@@ -3162,7 +3165,7 @@ const shellOutputSchema = lazySchema(() => zodSchema(z.object({
|
|
|
3162
3165
|
})])
|
|
3163
3166
|
}))
|
|
3164
3167
|
})));
|
|
3165
|
-
const shellSkillsSchema = z.array(z.discriminatedUnion("type", [z.object({
|
|
3168
|
+
const shellSkillsSchema = () => z.array(z.discriminatedUnion("type", [z.object({
|
|
3166
3169
|
type: z.literal("skillReference"),
|
|
3167
3170
|
providerReference: z.record(z.string(), z.string()),
|
|
3168
3171
|
version: z.string().optional()
|
|
@@ -3195,7 +3198,7 @@ const shellArgsSchema = lazySchema(() => zodSchema(z.object({ environment: z.uni
|
|
|
3195
3198
|
value: z.string()
|
|
3196
3199
|
})).optional()
|
|
3197
3200
|
})]).optional(),
|
|
3198
|
-
skills: shellSkillsSchema
|
|
3201
|
+
skills: shellSkillsSchema()
|
|
3199
3202
|
}),
|
|
3200
3203
|
z.object({
|
|
3201
3204
|
type: z.literal("containerReference"),
|
|
@@ -4397,10 +4400,10 @@ async function convertToOpenAIResponsesInput({ prompt, toolNameMapping, systemMe
|
|
|
4397
4400
|
warnings
|
|
4398
4401
|
};
|
|
4399
4402
|
}
|
|
4400
|
-
const openaiResponsesReasoningProviderOptionsSchema = z.object({
|
|
4403
|
+
const openaiResponsesReasoningProviderOptionsSchema = lazySchema(() => zodSchema(z.object({
|
|
4401
4404
|
itemId: z.string().nullish(),
|
|
4402
4405
|
reasoningEncryptedContent: z.string().nullish()
|
|
4403
|
-
});
|
|
4406
|
+
})));
|
|
4404
4407
|
//#endregion
|
|
4405
4408
|
//#region src/responses/map-openai-responses-annotation.ts
|
|
4406
4409
|
function mapOpenAIResponsesAnnotationSource(annotation, providerOptionsName, id) {
|
|
@@ -4448,36 +4451,41 @@ function mapOpenAIResponseFinishReason({ finishReason, hasFunctionCall }) {
|
|
|
4448
4451
|
}
|
|
4449
4452
|
//#endregion
|
|
4450
4453
|
//#region src/responses/openai-responses-api.ts
|
|
4451
|
-
|
|
4454
|
+
let cachedJsonValueSchema$1;
|
|
4455
|
+
const jsonValueSchema$1 = () => cachedJsonValueSchema$1 ??= z.lazy(() => z.union([
|
|
4452
4456
|
z.string(),
|
|
4453
4457
|
z.number(),
|
|
4454
4458
|
z.boolean(),
|
|
4455
4459
|
z.null(),
|
|
4456
|
-
z.array(jsonValueSchema$1),
|
|
4457
|
-
z.record(z.string(), jsonValueSchema$1.optional())
|
|
4460
|
+
z.array(jsonValueSchema$1()),
|
|
4461
|
+
z.record(z.string(), jsonValueSchema$1().optional())
|
|
4458
4462
|
]));
|
|
4459
|
-
const jsonObjectSchema = z.record(z.string(), jsonValueSchema$1.optional());
|
|
4460
|
-
const openaiResponsesUsageSchema = z.intersection(jsonObjectSchema, z.object({
|
|
4463
|
+
const jsonObjectSchema = () => z.record(z.string(), jsonValueSchema$1().optional());
|
|
4464
|
+
const openaiResponsesUsageSchema = () => z.intersection(jsonObjectSchema(), z.object({
|
|
4461
4465
|
input_tokens: z.number(),
|
|
4462
|
-
input_tokens_details: z.intersection(jsonObjectSchema, z.object({
|
|
4466
|
+
input_tokens_details: z.intersection(jsonObjectSchema(), z.object({
|
|
4463
4467
|
cached_tokens: z.number().nullish(),
|
|
4464
4468
|
cache_write_tokens: z.number().nullish(),
|
|
4469
|
+
cache_write_tokens_details: z.intersection(jsonObjectSchema(), z.object({
|
|
4470
|
+
ttl_30m_tokens: z.number().nullish(),
|
|
4471
|
+
ttl_12h_tokens: z.number().nullish()
|
|
4472
|
+
})).nullish(),
|
|
4465
4473
|
orchestration_input_tokens: z.number().nullish(),
|
|
4466
4474
|
orchestration_input_cached_tokens: z.number().nullish()
|
|
4467
4475
|
})).nullish(),
|
|
4468
4476
|
output_tokens: z.number(),
|
|
4469
|
-
output_tokens_details: z.intersection(jsonObjectSchema, z.object({
|
|
4477
|
+
output_tokens_details: z.intersection(jsonObjectSchema(), z.object({
|
|
4470
4478
|
reasoning_tokens: z.number().nullish(),
|
|
4471
4479
|
orchestration_output_tokens: z.number().nullish()
|
|
4472
4480
|
})).nullish(),
|
|
4473
4481
|
total_tokens: z.number().optional()
|
|
4474
4482
|
}));
|
|
4475
|
-
const openaiResponsesComputerSafetyCheckSchema = z.object({
|
|
4483
|
+
const openaiResponsesComputerSafetyCheckSchema = () => z.object({
|
|
4476
4484
|
id: z.string(),
|
|
4477
4485
|
code: z.string().nullish(),
|
|
4478
4486
|
message: z.string().nullish()
|
|
4479
4487
|
});
|
|
4480
|
-
const openaiResponsesComputerActionSchema = z.discriminatedUnion("type", [
|
|
4488
|
+
const openaiResponsesComputerActionSchema = () => z.discriminatedUnion("type", [
|
|
4481
4489
|
z.object({
|
|
4482
4490
|
type: z.literal("click"),
|
|
4483
4491
|
button: z.enum([
|
|
@@ -4530,7 +4538,7 @@ const openaiResponsesComputerActionSchema = z.discriminatedUnion("type", [
|
|
|
4530
4538
|
}),
|
|
4531
4539
|
z.object({ type: z.literal("wait") })
|
|
4532
4540
|
]);
|
|
4533
|
-
const openaiResponsesComputerCallSchema = z.object({
|
|
4541
|
+
const openaiResponsesComputerCallSchema = () => z.object({
|
|
4534
4542
|
type: z.literal("computer_call"),
|
|
4535
4543
|
id: z.string(),
|
|
4536
4544
|
call_id: z.string().nullish(),
|
|
@@ -4539,29 +4547,29 @@ const openaiResponsesComputerCallSchema = z.object({
|
|
|
4539
4547
|
"completed",
|
|
4540
4548
|
"incomplete"
|
|
4541
4549
|
]),
|
|
4542
|
-
action: openaiResponsesComputerActionSchema.nullish(),
|
|
4543
|
-
actions: z.array(openaiResponsesComputerActionSchema).nullish(),
|
|
4544
|
-
pending_safety_checks: z.array(openaiResponsesComputerSafetyCheckSchema).nullish()
|
|
4550
|
+
action: openaiResponsesComputerActionSchema().nullish(),
|
|
4551
|
+
actions: z.array(openaiResponsesComputerActionSchema()).nullish(),
|
|
4552
|
+
pending_safety_checks: z.array(openaiResponsesComputerSafetyCheckSchema()).nullish()
|
|
4545
4553
|
});
|
|
4546
|
-
const openaiResponsesToolCallerSchema = z.discriminatedUnion("type", [z.object({ type: z.literal("direct") }), z.object({
|
|
4554
|
+
const openaiResponsesToolCallerSchema = () => z.discriminatedUnion("type", [z.object({ type: z.literal("direct") }), z.object({
|
|
4547
4555
|
type: z.literal("program"),
|
|
4548
4556
|
caller_id: z.string()
|
|
4549
4557
|
})]);
|
|
4550
|
-
const openaiResponsesProgramSchema = z.object({
|
|
4558
|
+
const openaiResponsesProgramSchema = () => z.object({
|
|
4551
4559
|
type: z.literal("program"),
|
|
4552
4560
|
id: z.string(),
|
|
4553
4561
|
call_id: z.string(),
|
|
4554
4562
|
code: z.string(),
|
|
4555
4563
|
fingerprint: z.string()
|
|
4556
4564
|
});
|
|
4557
|
-
const openaiResponsesProgramOutputSchema = z.object({
|
|
4565
|
+
const openaiResponsesProgramOutputSchema = () => z.object({
|
|
4558
4566
|
type: z.literal("program_output"),
|
|
4559
4567
|
id: z.string(),
|
|
4560
4568
|
call_id: z.string(),
|
|
4561
4569
|
result: z.string(),
|
|
4562
4570
|
status: z.enum(["completed", "incomplete"])
|
|
4563
4571
|
});
|
|
4564
|
-
const openaiResponsesLocalShellCallSchema = z.object({
|
|
4572
|
+
const openaiResponsesLocalShellCallSchema = () => z.object({
|
|
4565
4573
|
type: z.literal("local_shell_call"),
|
|
4566
4574
|
id: z.string(),
|
|
4567
4575
|
call_id: z.string(),
|
|
@@ -4574,7 +4582,7 @@ const openaiResponsesLocalShellCallSchema = z.object({
|
|
|
4574
4582
|
env: z.record(z.string(), z.string()).optional()
|
|
4575
4583
|
})
|
|
4576
4584
|
});
|
|
4577
|
-
const openaiResponsesNestedErrorChunkSchema = z.object({
|
|
4585
|
+
const openaiResponsesNestedErrorChunkSchema = () => z.object({
|
|
4578
4586
|
type: z.literal("error"),
|
|
4579
4587
|
sequence_number: z.number(),
|
|
4580
4588
|
error: z.object({
|
|
@@ -4584,7 +4592,7 @@ const openaiResponsesNestedErrorChunkSchema = z.object({
|
|
|
4584
4592
|
param: z.string().nullish()
|
|
4585
4593
|
})
|
|
4586
4594
|
});
|
|
4587
|
-
const openaiResponsesErrorChunkSchema = z.object({
|
|
4595
|
+
const openaiResponsesErrorChunkSchema = () => z.object({
|
|
4588
4596
|
type: z.literal("error"),
|
|
4589
4597
|
sequence_number: z.number(),
|
|
4590
4598
|
code: z.string().nullish(),
|
|
@@ -4672,7 +4680,7 @@ const openaiResponsesChunkSchema = lazySchema(() => zodSchema(z.union([
|
|
|
4672
4680
|
type: z.enum(["response.completed", "response.incomplete"]),
|
|
4673
4681
|
response: z.object({
|
|
4674
4682
|
incomplete_details: z.object({ reason: z.string() }).nullish(),
|
|
4675
|
-
usage: openaiResponsesUsageSchema.nullish(),
|
|
4683
|
+
usage: openaiResponsesUsageSchema().nullish(),
|
|
4676
4684
|
reasoning: z.object({ context: z.string().nullish() }).nullish(),
|
|
4677
4685
|
service_tier: z.string().nullish()
|
|
4678
4686
|
})
|
|
@@ -4686,7 +4694,7 @@ const openaiResponsesChunkSchema = lazySchema(() => zodSchema(z.union([
|
|
|
4686
4694
|
message: z.string()
|
|
4687
4695
|
}).nullish(),
|
|
4688
4696
|
incomplete_details: z.object({ reason: z.string() }).nullish(),
|
|
4689
|
-
usage: openaiResponsesUsageSchema.nullish(),
|
|
4697
|
+
usage: openaiResponsesUsageSchema().nullish(),
|
|
4690
4698
|
reasoning: z.object({ context: z.string().nullish() }).nullish(),
|
|
4691
4699
|
service_tier: z.string().nullish()
|
|
4692
4700
|
})
|
|
@@ -4731,21 +4739,21 @@ const openaiResponsesChunkSchema = lazySchema(() => zodSchema(z.union([
|
|
|
4731
4739
|
arguments: z.string(),
|
|
4732
4740
|
async: z.boolean().nullish(),
|
|
4733
4741
|
namespace: z.string().nullish(),
|
|
4734
|
-
caller: openaiResponsesToolCallerSchema.nullish()
|
|
4742
|
+
caller: openaiResponsesToolCallerSchema().nullish()
|
|
4735
4743
|
}),
|
|
4736
|
-
openaiResponsesProgramSchema,
|
|
4737
|
-
openaiResponsesProgramOutputSchema,
|
|
4744
|
+
openaiResponsesProgramSchema(),
|
|
4745
|
+
openaiResponsesProgramOutputSchema(),
|
|
4738
4746
|
z.object({
|
|
4739
4747
|
type: z.literal("web_search_call"),
|
|
4740
4748
|
id: z.string(),
|
|
4741
4749
|
status: z.string()
|
|
4742
4750
|
}),
|
|
4743
|
-
openaiResponsesComputerCallSchema,
|
|
4751
|
+
openaiResponsesComputerCallSchema(),
|
|
4744
4752
|
z.object({
|
|
4745
4753
|
type: z.literal("file_search_call"),
|
|
4746
4754
|
id: z.string()
|
|
4747
4755
|
}),
|
|
4748
|
-
openaiResponsesLocalShellCallSchema,
|
|
4756
|
+
openaiResponsesLocalShellCallSchema(),
|
|
4749
4757
|
z.object({
|
|
4750
4758
|
type: z.literal("image_generation_call"),
|
|
4751
4759
|
id: z.string()
|
|
@@ -4869,7 +4877,7 @@ const openaiResponsesChunkSchema = lazySchema(() => zodSchema(z.union([
|
|
|
4869
4877
|
"completed",
|
|
4870
4878
|
"incomplete"
|
|
4871
4879
|
]),
|
|
4872
|
-
tools: z.array(z.record(z.string(), jsonValueSchema$1.optional()))
|
|
4880
|
+
tools: z.array(z.record(z.string(), jsonValueSchema$1().optional()))
|
|
4873
4881
|
})
|
|
4874
4882
|
])
|
|
4875
4883
|
}),
|
|
@@ -4900,10 +4908,10 @@ const openaiResponsesChunkSchema = lazySchema(() => zodSchema(z.union([
|
|
|
4900
4908
|
"incomplete"
|
|
4901
4909
|
]),
|
|
4902
4910
|
namespace: z.string().nullish(),
|
|
4903
|
-
caller: openaiResponsesToolCallerSchema.nullish()
|
|
4911
|
+
caller: openaiResponsesToolCallerSchema().nullish()
|
|
4904
4912
|
}),
|
|
4905
|
-
openaiResponsesProgramSchema,
|
|
4906
|
-
openaiResponsesProgramOutputSchema,
|
|
4913
|
+
openaiResponsesProgramSchema(),
|
|
4914
|
+
openaiResponsesProgramOutputSchema(),
|
|
4907
4915
|
z.object({
|
|
4908
4916
|
type: z.literal("custom_tool_call"),
|
|
4909
4917
|
id: z.string(),
|
|
@@ -4975,8 +4983,8 @@ const openaiResponsesChunkSchema = lazySchema(() => zodSchema(z.union([
|
|
|
4975
4983
|
text: z.string()
|
|
4976
4984
|
})).nullish()
|
|
4977
4985
|
}),
|
|
4978
|
-
openaiResponsesLocalShellCallSchema,
|
|
4979
|
-
openaiResponsesComputerCallSchema,
|
|
4986
|
+
openaiResponsesLocalShellCallSchema(),
|
|
4987
|
+
openaiResponsesComputerCallSchema(),
|
|
4980
4988
|
z.object({
|
|
4981
4989
|
type: z.literal("mcp_call"),
|
|
4982
4990
|
id: z.string(),
|
|
@@ -5099,7 +5107,7 @@ const openaiResponsesChunkSchema = lazySchema(() => zodSchema(z.union([
|
|
|
5099
5107
|
"completed",
|
|
5100
5108
|
"incomplete"
|
|
5101
5109
|
]),
|
|
5102
|
-
tools: z.array(z.record(z.string(), jsonValueSchema$1.optional()))
|
|
5110
|
+
tools: z.array(z.record(z.string(), jsonValueSchema$1().optional()))
|
|
5103
5111
|
})
|
|
5104
5112
|
])
|
|
5105
5113
|
}),
|
|
@@ -5202,8 +5210,8 @@ const openaiResponsesChunkSchema = lazySchema(() => zodSchema(z.union([
|
|
|
5202
5210
|
output_index: z.number(),
|
|
5203
5211
|
diff: z.string()
|
|
5204
5212
|
}),
|
|
5205
|
-
openaiResponsesNestedErrorChunkSchema,
|
|
5206
|
-
openaiResponsesErrorChunkSchema,
|
|
5213
|
+
openaiResponsesNestedErrorChunkSchema(),
|
|
5214
|
+
openaiResponsesErrorChunkSchema(),
|
|
5207
5215
|
z.object({ type: z.string() }).loose().refine((value) => !isModeledOpenAIResponsesChunk(value), { message: "Known response chunk failed schema validation" }).transform((value) => ({
|
|
5208
5216
|
type: "unknown_chunk",
|
|
5209
5217
|
message: value.type
|
|
@@ -5328,7 +5336,7 @@ const openaiResponsesResponseSchema = lazySchema(() => zodSchema(z.object({
|
|
|
5328
5336
|
id: z.string(),
|
|
5329
5337
|
result: z.string()
|
|
5330
5338
|
}),
|
|
5331
|
-
openaiResponsesLocalShellCallSchema,
|
|
5339
|
+
openaiResponsesLocalShellCallSchema(),
|
|
5332
5340
|
z.object({
|
|
5333
5341
|
type: z.literal("function_call"),
|
|
5334
5342
|
call_id: z.string(),
|
|
@@ -5337,10 +5345,10 @@ const openaiResponsesResponseSchema = lazySchema(() => zodSchema(z.object({
|
|
|
5337
5345
|
id: z.string(),
|
|
5338
5346
|
async: z.boolean().nullish(),
|
|
5339
5347
|
namespace: z.string().nullish(),
|
|
5340
|
-
caller: openaiResponsesToolCallerSchema.nullish()
|
|
5348
|
+
caller: openaiResponsesToolCallerSchema().nullish()
|
|
5341
5349
|
}),
|
|
5342
|
-
openaiResponsesProgramSchema,
|
|
5343
|
-
openaiResponsesProgramOutputSchema,
|
|
5350
|
+
openaiResponsesProgramSchema(),
|
|
5351
|
+
openaiResponsesProgramOutputSchema(),
|
|
5344
5352
|
z.object({
|
|
5345
5353
|
type: z.literal("custom_tool_call"),
|
|
5346
5354
|
call_id: z.string(),
|
|
@@ -5349,7 +5357,7 @@ const openaiResponsesResponseSchema = lazySchema(() => zodSchema(z.object({
|
|
|
5349
5357
|
id: z.string(),
|
|
5350
5358
|
async: z.boolean().nullish()
|
|
5351
5359
|
}),
|
|
5352
|
-
openaiResponsesComputerCallSchema,
|
|
5360
|
+
openaiResponsesComputerCallSchema(),
|
|
5353
5361
|
z.object({
|
|
5354
5362
|
type: z.literal("reasoning"),
|
|
5355
5363
|
id: z.string(),
|
|
@@ -5481,13 +5489,13 @@ const openaiResponsesResponseSchema = lazySchema(() => zodSchema(z.object({
|
|
|
5481
5489
|
"completed",
|
|
5482
5490
|
"incomplete"
|
|
5483
5491
|
]),
|
|
5484
|
-
tools: z.array(z.record(z.string(), jsonValueSchema$1.optional()))
|
|
5492
|
+
tools: z.array(z.record(z.string(), jsonValueSchema$1().optional()))
|
|
5485
5493
|
})
|
|
5486
5494
|
])).optional(),
|
|
5487
5495
|
service_tier: z.string().nullish(),
|
|
5488
5496
|
reasoning: z.object({ context: z.string().nullish() }).nullish(),
|
|
5489
5497
|
incomplete_details: z.object({ reason: z.string() }).nullish(),
|
|
5490
|
-
usage: openaiResponsesUsageSchema.nullish()
|
|
5498
|
+
usage: openaiResponsesUsageSchema().nullish()
|
|
5491
5499
|
})));
|
|
5492
5500
|
//#endregion
|
|
5493
5501
|
//#region src/tool/code-interpreter.ts
|
|
@@ -5513,7 +5521,7 @@ const codeInterpreter = (args = {}) => {
|
|
|
5513
5521
|
};
|
|
5514
5522
|
//#endregion
|
|
5515
5523
|
//#region src/tool/file-search.ts
|
|
5516
|
-
const comparisonFilterSchema = z.object({
|
|
5524
|
+
const comparisonFilterSchema = () => z.object({
|
|
5517
5525
|
key: z.string(),
|
|
5518
5526
|
type: z.enum([
|
|
5519
5527
|
"eq",
|
|
@@ -5532,9 +5540,10 @@ const comparisonFilterSchema = z.object({
|
|
|
5532
5540
|
z.array(z.string())
|
|
5533
5541
|
])
|
|
5534
5542
|
});
|
|
5535
|
-
|
|
5543
|
+
let cachedCompoundFilterSchema;
|
|
5544
|
+
const compoundFilterSchema = () => cachedCompoundFilterSchema ??= z.object({
|
|
5536
5545
|
type: z.enum(["and", "or"]),
|
|
5537
|
-
filters: z.array(z.union([comparisonFilterSchema, z.lazy(() => compoundFilterSchema)]))
|
|
5546
|
+
filters: z.array(z.union([comparisonFilterSchema(), z.lazy(() => compoundFilterSchema())]))
|
|
5538
5547
|
});
|
|
5539
5548
|
const fileSearchArgsSchema = lazySchema(() => zodSchema(z.object({
|
|
5540
5549
|
vectorStoreIds: z.array(z.string()),
|
|
@@ -5543,7 +5552,7 @@ const fileSearchArgsSchema = lazySchema(() => zodSchema(z.object({
|
|
|
5543
5552
|
ranker: z.string().optional(),
|
|
5544
5553
|
scoreThreshold: z.number().optional()
|
|
5545
5554
|
}).optional(),
|
|
5546
|
-
filters: z.union([comparisonFilterSchema, compoundFilterSchema]).optional()
|
|
5555
|
+
filters: z.union([comparisonFilterSchema(), compoundFilterSchema()]).optional()
|
|
5547
5556
|
})));
|
|
5548
5557
|
const fileSearchOutputSchema = lazySchema(() => zodSchema(z.object({
|
|
5549
5558
|
queries: z.array(z.string()),
|
|
@@ -5630,13 +5639,14 @@ createProviderDefinedToolFactory({
|
|
|
5630
5639
|
});
|
|
5631
5640
|
//#endregion
|
|
5632
5641
|
//#region src/tool/mcp.ts
|
|
5633
|
-
|
|
5642
|
+
let cachedJsonValueSchema;
|
|
5643
|
+
const jsonValueSchema = () => cachedJsonValueSchema ??= z.lazy(() => z.union([
|
|
5634
5644
|
z.string(),
|
|
5635
5645
|
z.number(),
|
|
5636
5646
|
z.boolean(),
|
|
5637
5647
|
z.null(),
|
|
5638
|
-
z.array(jsonValueSchema),
|
|
5639
|
-
z.record(z.string(), jsonValueSchema)
|
|
5648
|
+
z.array(jsonValueSchema()),
|
|
5649
|
+
z.record(z.string(), jsonValueSchema())
|
|
5640
5650
|
]));
|
|
5641
5651
|
const mcpArgsSchema = lazySchema(() => zodSchema(z.object({
|
|
5642
5652
|
serverLabel: z.string(),
|
|
@@ -5658,7 +5668,7 @@ const mcpOutputSchema = lazySchema(() => zodSchema(z.object({
|
|
|
5658
5668
|
name: z.string(),
|
|
5659
5669
|
arguments: z.string(),
|
|
5660
5670
|
output: z.string().nullish(),
|
|
5661
|
-
error: z.union([z.string(), jsonValueSchema]).optional()
|
|
5671
|
+
error: z.union([z.string(), jsonValueSchema()]).optional()
|
|
5662
5672
|
})));
|
|
5663
5673
|
createProviderExecutedToolFactory({
|
|
5664
5674
|
id: "openai.mcp",
|