@ai-sdk/openai 4.0.60 → 4.0.61
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 +14 -0
- package/dist/index.d.ts +40 -5
- package/dist/index.js +199 -133
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +30 -2
- package/dist/internal/index.js +109 -46
- package/dist/internal/index.js.map +1 -1
- package/docs/03-openai.mdx +72 -9
- package/package.json +3 -3
- package/src/index.ts +1 -0
- package/src/{openai-responses-batch.ts → openai-batch.ts} +71 -87
- package/src/openai-language-model-capabilities.ts +2 -0
- package/src/openai-provider.ts +27 -6
- package/src/openai-tools.ts +1 -0
- package/src/responses/convert-to-openai-responses-input.ts +13 -0
- package/src/responses/openai-responses-api.ts +10 -0
- package/src/responses/openai-responses-language-model.ts +65 -29
- package/src/responses/openai-responses-prepare-tools.ts +47 -0
- package/src/responses/openai-responses-provider-metadata.ts +16 -0
- package/src/tool/custom.ts +7 -0
package/dist/internal/index.d.ts
CHANGED
|
@@ -486,6 +486,7 @@ type OpenAIResponsesFunctionCall = {
|
|
|
486
486
|
call_id: string;
|
|
487
487
|
name: string;
|
|
488
488
|
arguments: string;
|
|
489
|
+
async?: boolean;
|
|
489
490
|
id?: string;
|
|
490
491
|
namespace?: string;
|
|
491
492
|
caller?: OpenAIResponsesToolCaller;
|
|
@@ -547,6 +548,7 @@ type OpenAIResponsesCustomToolCall = {
|
|
|
547
548
|
call_id: string;
|
|
548
549
|
name: string;
|
|
549
550
|
input: string;
|
|
551
|
+
async?: boolean;
|
|
550
552
|
};
|
|
551
553
|
type OpenAIResponsesCustomToolCallOutput = {
|
|
552
554
|
type: 'custom_tool_call_output';
|
|
@@ -704,6 +706,7 @@ type OpenAIResponsesFunctionTool = {
|
|
|
704
706
|
name: string;
|
|
705
707
|
description: string | undefined;
|
|
706
708
|
parameters: JSONSchema7;
|
|
709
|
+
async?: boolean;
|
|
707
710
|
strict?: boolean;
|
|
708
711
|
defer_loading?: boolean;
|
|
709
712
|
allowed_callers?: Array<'direct' | 'programmatic'>;
|
|
@@ -815,6 +818,7 @@ type OpenAIResponsesTool = OpenAIResponsesFunctionTool | {
|
|
|
815
818
|
type: 'custom';
|
|
816
819
|
name: string;
|
|
817
820
|
description?: string;
|
|
821
|
+
async?: boolean;
|
|
818
822
|
format?: {
|
|
819
823
|
type: 'grammar';
|
|
820
824
|
syntax: 'regex' | 'lark';
|
|
@@ -1108,6 +1112,7 @@ declare const openaiResponsesChunkSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
1108
1112
|
call_id: string;
|
|
1109
1113
|
name: string;
|
|
1110
1114
|
arguments: string;
|
|
1115
|
+
async?: boolean | null | undefined;
|
|
1111
1116
|
namespace?: string | null | undefined;
|
|
1112
1117
|
caller?: {
|
|
1113
1118
|
type: "direct";
|
|
@@ -1184,6 +1189,7 @@ declare const openaiResponsesChunkSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
1184
1189
|
call_id: string;
|
|
1185
1190
|
name: string;
|
|
1186
1191
|
input: string;
|
|
1192
|
+
async?: boolean | null | undefined;
|
|
1187
1193
|
} | {
|
|
1188
1194
|
type: "shell_call";
|
|
1189
1195
|
id: string;
|
|
@@ -1360,6 +1366,7 @@ declare const openaiResponsesChunkSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
1360
1366
|
name: string;
|
|
1361
1367
|
arguments: string;
|
|
1362
1368
|
status: "completed" | "in_progress" | "incomplete";
|
|
1369
|
+
async?: boolean | null | undefined;
|
|
1363
1370
|
namespace?: string | null | undefined;
|
|
1364
1371
|
caller?: {
|
|
1365
1372
|
type: "direct";
|
|
@@ -1374,6 +1381,7 @@ declare const openaiResponsesChunkSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
1374
1381
|
name: string;
|
|
1375
1382
|
input: string;
|
|
1376
1383
|
status: "completed";
|
|
1384
|
+
async?: boolean | null | undefined;
|
|
1377
1385
|
} | {
|
|
1378
1386
|
type: "code_interpreter_call";
|
|
1379
1387
|
id: string;
|
|
@@ -1818,6 +1826,7 @@ declare const webSearch: (args?: Parameters<typeof webSearchToolFactory>[0]) =>
|
|
|
1818
1826
|
|
|
1819
1827
|
type OpenAIResponsesModelId = 'gpt-3.5-turbo-0125' | 'gpt-3.5-turbo-1106' | 'gpt-3.5-turbo' | 'gpt-4.1-2025-04-14' | 'gpt-4.1-mini-2025-04-14' | 'gpt-4.1-mini' | 'gpt-4.1-nano-2025-04-14' | 'gpt-4.1-nano' | 'gpt-4.1' | 'gpt-4o-2024-05-13' | 'gpt-4o-2024-08-06' | 'gpt-4o-2024-11-20' | 'gpt-4o-mini-2024-07-18' | 'gpt-4o-mini' | 'gpt-4o' | 'gpt-5.1' | 'gpt-5.1-2025-11-13' | 'gpt-5.1-chat-latest' | 'gpt-5.1-codex-mini' | 'gpt-5.1-codex' | 'gpt-5.1-codex-max' | 'gpt-5.2' | 'gpt-5.2-2025-12-11' | 'gpt-5.2-chat-latest' | 'gpt-5.2-pro' | 'gpt-5.2-pro-2025-12-11' | 'gpt-5.2-codex' | 'gpt-5.3-chat-latest' | 'gpt-5.3-codex' | 'gpt-5.4' | 'gpt-5.4-2026-03-05' | 'gpt-5.4-mini' | 'gpt-5.4-mini-2026-03-17' | 'gpt-5.4-nano' | 'gpt-5.4-nano-2026-03-17' | 'gpt-5.4-pro' | 'gpt-5.4-pro-2026-03-05' | 'gpt-5.5' | 'gpt-5.5-2026-04-23' | 'gpt-5.6' | 'gpt-5.6-luna' | 'gpt-5.6-sol' | 'gpt-5.6-terra' | 'gpt-6-astra' | 'gpt-5-2025-08-07' | 'gpt-5-chat-latest' | 'gpt-5-codex' | 'gpt-5-mini-2025-08-07' | 'gpt-5-mini' | 'gpt-5-nano-2025-08-07' | 'gpt-5-nano' | 'gpt-5-pro-2025-10-06' | 'gpt-5-pro' | 'gpt-5' | 'o1-2024-12-17' | 'o1' | 'o3-2025-04-16' | 'o3-mini-2025-01-31' | 'o3-mini' | 'o3' | 'o4-mini' | 'o4-mini-2025-04-16' | (string & {});
|
|
1820
1828
|
|
|
1829
|
+
declare const openaiResponsesSupportedUrls: Record<string, RegExp[]>;
|
|
1821
1830
|
declare class OpenAIResponsesLanguageModel implements LanguageModelV4 {
|
|
1822
1831
|
readonly specificationVersion = "v4";
|
|
1823
1832
|
readonly modelId: OpenAIResponsesModelId;
|
|
@@ -1833,7 +1842,11 @@ declare class OpenAIResponsesLanguageModel implements LanguageModelV4 {
|
|
|
1833
1842
|
constructor(modelId: OpenAIResponsesModelId, config: OpenAIConfig);
|
|
1834
1843
|
readonly supportedUrls: Record<string, RegExp[]>;
|
|
1835
1844
|
get provider(): string;
|
|
1836
|
-
|
|
1845
|
+
static prepareRequest({ modelId, config, options: { maxOutputTokens, temperature, stopSequences, topP, topK, presencePenalty, frequencyPenalty, seed, prompt, reasoning, providerOptions, tools, toolChoice, responseFormat, }, }: {
|
|
1846
|
+
modelId: OpenAIResponsesModelId;
|
|
1847
|
+
config: OpenAIConfig;
|
|
1848
|
+
options: LanguageModelV4CallOptions;
|
|
1849
|
+
}): Promise<{
|
|
1837
1850
|
webSearchToolName: string | undefined;
|
|
1838
1851
|
args: {
|
|
1839
1852
|
tools: OpenAIResponsesTool[] | undefined;
|
|
@@ -1923,6 +1936,7 @@ declare class OpenAIResponsesLanguageModel implements LanguageModelV4 {
|
|
|
1923
1936
|
providerOptionsName: string;
|
|
1924
1937
|
isShellProviderExecuted: boolean;
|
|
1925
1938
|
}>;
|
|
1939
|
+
private getArgs;
|
|
1926
1940
|
doGenerate(options: LanguageModelV4CallOptions): Promise<LanguageModelV4GenerateResult>;
|
|
1927
1941
|
doStream(options: LanguageModelV4CallOptions): Promise<LanguageModelV4StreamResult>;
|
|
1928
1942
|
}
|
|
@@ -1948,6 +1962,20 @@ type OpenaiResponsesReasoningProviderMetadata = {
|
|
|
1948
1962
|
type OpenaiResponsesProviderMetadata = {
|
|
1949
1963
|
openai: ResponsesProviderMetadata;
|
|
1950
1964
|
};
|
|
1965
|
+
type ResponsesToolCallProviderMetadata = {
|
|
1966
|
+
itemId: string;
|
|
1967
|
+
async?: boolean;
|
|
1968
|
+
namespace?: string;
|
|
1969
|
+
caller?: {
|
|
1970
|
+
type: 'direct';
|
|
1971
|
+
} | {
|
|
1972
|
+
type: 'program';
|
|
1973
|
+
callerId: string;
|
|
1974
|
+
};
|
|
1975
|
+
};
|
|
1976
|
+
type OpenaiResponsesToolCallProviderMetadata = {
|
|
1977
|
+
openai: ResponsesToolCallProviderMetadata;
|
|
1978
|
+
};
|
|
1951
1979
|
type ResponsesCompactionProviderMetadata = {
|
|
1952
1980
|
type: 'compaction';
|
|
1953
1981
|
itemId: string;
|
|
@@ -2472,4 +2500,4 @@ declare const webSearchPreview: _ai_sdk_provider_utils.ProviderExecutedToolFacto
|
|
|
2472
2500
|
};
|
|
2473
2501
|
}, {}>;
|
|
2474
2502
|
|
|
2475
|
-
export { type ApplyPatchOperation, OpenAIChatLanguageModel, type OpenAIChatModelId, OpenAICompletionLanguageModel, type OpenAICompletionModelId, OpenAIEmbeddingModel, type OpenAIEmbeddingModelId, type OpenAIEmbeddingModelOptions, OpenAIImageModel, type OpenAIImageModelEditOptions, type OpenAIImageModelGenerationOptions, type OpenAIImageModelId, type OpenAIImageModelOptions, type OpenAILanguageModelChatOptions, type OpenAILanguageModelCompletionOptions, OpenAIResponsesLanguageModel, OpenAISpeechModel, type OpenAISpeechModelId, type OpenAISpeechModelOptions, type OpenAITranscriptionCallOptions, OpenAITranscriptionModel, type OpenAITranscriptionModelId, type OpenAITranscriptionModelOptions, type OpenAITranscriptionStreamOptions, 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, getMaxImagesPerCall, hasDefaultResponseFormat, imageGeneration, imageGenerationArgsSchema, imageGenerationOutputSchema, mapWebSearchOutput, modelMaxImagesPerCall, openAITranscriptionModelOptions, openaiEmbeddingModelOptions, openaiImageModelEditOptions, openaiImageModelGenerationOptions, openaiImageModelOptions, openaiLanguageModelChatOptions, openaiLanguageModelCompletionOptions, openaiSpeechModelOptionsSchema, programmaticToolCalling, programmaticToolCallingInputSchema, programmaticToolCallingOutputSchema, webSearch, webSearchArgsSchema, webSearchOutputSchema, webSearchPreview, webSearchPreviewArgsSchema, webSearchPreviewInputSchema, webSearchToolFactory };
|
|
2503
|
+
export { type ApplyPatchOperation, OpenAIChatLanguageModel, type OpenAIChatModelId, OpenAICompletionLanguageModel, type OpenAICompletionModelId, OpenAIEmbeddingModel, type OpenAIEmbeddingModelId, type OpenAIEmbeddingModelOptions, OpenAIImageModel, type OpenAIImageModelEditOptions, type OpenAIImageModelGenerationOptions, type OpenAIImageModelId, type OpenAIImageModelOptions, type OpenAILanguageModelChatOptions, type OpenAILanguageModelCompletionOptions, OpenAIResponsesLanguageModel, OpenAISpeechModel, type OpenAISpeechModelId, type OpenAISpeechModelOptions, type OpenAITranscriptionCallOptions, OpenAITranscriptionModel, type OpenAITranscriptionModelId, type OpenAITranscriptionModelOptions, type OpenAITranscriptionStreamOptions, type OpenaiResponsesCompactionProviderMetadata, type OpenaiResponsesProviderMetadata, type OpenaiResponsesReasoningProviderMetadata, type OpenaiResponsesSourceDocumentProviderMetadata, type OpenaiResponsesTextProviderMetadata, type OpenaiResponsesToolCallProviderMetadata, type ResponsesCompactionProviderMetadata, type ResponsesProviderMetadata, type ResponsesReasoningProviderMetadata, type ResponsesSourceDocumentProviderMetadata, type ResponsesTextProviderMetadata, type ResponsesToolCallProviderMetadata, applyPatch, applyPatchArgsSchema, applyPatchInputSchema, applyPatchOutputSchema, applyPatchToolFactory, codeInterpreter, codeInterpreterArgsSchema, codeInterpreterInputSchema, codeInterpreterOutputSchema, codeInterpreterToolFactory, fileSearch, fileSearchArgsSchema, fileSearchOutputSchema, getMaxImagesPerCall, hasDefaultResponseFormat, imageGeneration, imageGenerationArgsSchema, imageGenerationOutputSchema, mapWebSearchOutput, modelMaxImagesPerCall, openAITranscriptionModelOptions, openaiEmbeddingModelOptions, openaiImageModelEditOptions, openaiImageModelGenerationOptions, openaiImageModelOptions, openaiLanguageModelChatOptions, openaiLanguageModelCompletionOptions, openaiResponsesSupportedUrls, openaiSpeechModelOptionsSchema, programmaticToolCalling, programmaticToolCallingInputSchema, programmaticToolCallingOutputSchema, webSearch, webSearchArgsSchema, webSearchOutputSchema, webSearchPreview, webSearchPreviewArgsSchema, webSearchPreviewInputSchema, webSearchToolFactory };
|
package/dist/internal/index.js
CHANGED
|
@@ -49,6 +49,7 @@ function getOpenAILanguageModelCapabilities(modelId) {
|
|
|
49
49
|
supportsFlexProcessing,
|
|
50
50
|
supportsPriorityProcessing,
|
|
51
51
|
supportsConfigurationUpdate: isGpt6OrLaterModel,
|
|
52
|
+
supportsAsyncToolCalling: isGpt6OrLaterModel,
|
|
52
53
|
supportedReasoningEfforts: isGpt6OrLaterModel ? ["low", "medium", "high", "xhigh", "max"] : void 0,
|
|
53
54
|
isReasoningModel,
|
|
54
55
|
systemMessageMode,
|
|
@@ -3873,7 +3874,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
3873
3874
|
customProviderToolNames,
|
|
3874
3875
|
outputSchemaToolNames
|
|
3875
3876
|
}) {
|
|
3876
|
-
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K;
|
|
3877
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P;
|
|
3877
3878
|
let input = [];
|
|
3878
3879
|
const warnings = [];
|
|
3879
3880
|
const processedApprovalIds = /* @__PURE__ */ new Set();
|
|
@@ -4093,7 +4094,8 @@ async function convertToOpenAIResponsesInput({
|
|
|
4093
4094
|
}
|
|
4094
4095
|
const id = (_f = (_c = (_b = part.providerOptions) == null ? void 0 : _b[providerOptionsName]) == null ? void 0 : _c.itemId) != null ? _f : (_e = (_d = part.providerMetadata) == null ? void 0 : _d[providerOptionsName]) == null ? void 0 : _e.itemId;
|
|
4095
4096
|
const namespace = (_k = (_h = (_g = part.providerOptions) == null ? void 0 : _g[providerOptionsName]) == null ? void 0 : _h.namespace) != null ? _k : (_j = (_i = part.providerMetadata) == null ? void 0 : _i[providerOptionsName]) == null ? void 0 : _j.namespace;
|
|
4096
|
-
const
|
|
4097
|
+
const isAsync = (_p = (_m = (_l = part.providerOptions) == null ? void 0 : _l[providerOptionsName]) == null ? void 0 : _m.async) != null ? _p : (_o = (_n = part.providerMetadata) == null ? void 0 : _n[providerOptionsName]) == null ? void 0 : _o.async;
|
|
4098
|
+
const caller = (_r = (_q = part.providerOptions) == null ? void 0 : _q[providerOptionsName]) == null ? void 0 : _r.caller;
|
|
4097
4099
|
if (hasConversation && id != null) {
|
|
4098
4100
|
break;
|
|
4099
4101
|
}
|
|
@@ -4117,7 +4119,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
4117
4119
|
type: "tool_search_call",
|
|
4118
4120
|
id: id != null ? id : part.toolCallId,
|
|
4119
4121
|
execution,
|
|
4120
|
-
call_id: (
|
|
4122
|
+
call_id: (_s = parsedInput.call_id) != null ? _s : null,
|
|
4121
4123
|
status: "completed",
|
|
4122
4124
|
arguments: parsedInput.arguments
|
|
4123
4125
|
});
|
|
@@ -4149,7 +4151,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
4149
4151
|
break;
|
|
4150
4152
|
}
|
|
4151
4153
|
}
|
|
4152
|
-
const isProviderDefinedToolCall = hasLocalShellTool && resolvedToolName === "local_shell" || hasShellTool && resolvedToolName === "shell" || hasApplyPatchTool && resolvedToolName === "apply_patch" || hasComputerTool && resolvedToolName === "computer" || ((
|
|
4154
|
+
const isProviderDefinedToolCall = hasLocalShellTool && resolvedToolName === "local_shell" || hasShellTool && resolvedToolName === "shell" || hasApplyPatchTool && resolvedToolName === "apply_patch" || hasComputerTool && resolvedToolName === "computer" || ((_t = customProviderToolNames == null ? void 0 : customProviderToolNames.has(resolvedToolName)) != null ? _t : false);
|
|
4153
4155
|
if (hasPreviousResponseId && store && id != null && isProviderDefinedToolCall) {
|
|
4154
4156
|
break;
|
|
4155
4157
|
}
|
|
@@ -4262,6 +4264,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
4262
4264
|
call_id: part.toolCallId,
|
|
4263
4265
|
name: resolvedToolName,
|
|
4264
4266
|
input: typeof part.input === "string" ? part.input : JSON.stringify(part.input),
|
|
4267
|
+
...isAsync != null && { async: isAsync },
|
|
4265
4268
|
id
|
|
4266
4269
|
});
|
|
4267
4270
|
break;
|
|
@@ -4271,6 +4274,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
4271
4274
|
call_id: part.toolCallId,
|
|
4272
4275
|
name: resolvedToolName,
|
|
4273
4276
|
arguments: serializeToolCallArguments2(part.input),
|
|
4277
|
+
...isAsync != null && { async: isAsync },
|
|
4274
4278
|
...namespace != null && { namespace },
|
|
4275
4279
|
...caller != null && {
|
|
4276
4280
|
caller: mapToolCaller(caller)
|
|
@@ -4290,7 +4294,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
4290
4294
|
part.toolName
|
|
4291
4295
|
);
|
|
4292
4296
|
if (part.toolName === toolSearchToolName) {
|
|
4293
|
-
const itemId = (
|
|
4297
|
+
const itemId = (_z = (_y = (_v = (_u = part.providerOptions) == null ? void 0 : _u[providerOptionsName]) == null ? void 0 : _v.itemId) != null ? _y : (_x = (_w = part.providerMetadata) == null ? void 0 : _w[providerOptionsName]) == null ? void 0 : _x.itemId) != null ? _z : part.toolCallId;
|
|
4294
4298
|
if (store) {
|
|
4295
4299
|
input.push({ type: "item_reference", id: itemId });
|
|
4296
4300
|
} else if (part.output.type === "json") {
|
|
@@ -4310,7 +4314,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
4310
4314
|
break;
|
|
4311
4315
|
}
|
|
4312
4316
|
if (resolvedResultToolName === "programmatic_tool_calling") {
|
|
4313
|
-
const itemId = (
|
|
4317
|
+
const itemId = (_F = (_E = (_B = (_A = part.providerOptions) == null ? void 0 : _A[providerOptionsName]) == null ? void 0 : _B.itemId) != null ? _E : (_D = (_C = part.providerMetadata) == null ? void 0 : _C[providerOptionsName]) == null ? void 0 : _D.itemId) != null ? _F : part.toolCallId;
|
|
4314
4318
|
if (store) {
|
|
4315
4319
|
input.push({ type: "item_reference", id: itemId });
|
|
4316
4320
|
} else if (part.output.type === "json") {
|
|
@@ -4350,7 +4354,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
4350
4354
|
break;
|
|
4351
4355
|
}
|
|
4352
4356
|
if (store) {
|
|
4353
|
-
const itemId = (
|
|
4357
|
+
const itemId = (_I = (_H = (_G = part.providerOptions) == null ? void 0 : _G[providerOptionsName]) == null ? void 0 : _H.itemId) != null ? _I : part.toolCallId;
|
|
4354
4358
|
input.push({ type: "item_reference", id: itemId });
|
|
4355
4359
|
} else {
|
|
4356
4360
|
warnings.push({
|
|
@@ -4435,7 +4439,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
4435
4439
|
}
|
|
4436
4440
|
case "custom": {
|
|
4437
4441
|
if (part.kind === "openai.compaction") {
|
|
4438
|
-
const providerOptions2 = (
|
|
4442
|
+
const providerOptions2 = (_J = part.providerOptions) == null ? void 0 : _J[providerOptionsName];
|
|
4439
4443
|
const id = providerOptions2 == null ? void 0 : providerOptions2.itemId;
|
|
4440
4444
|
if (hasConversation && id != null) {
|
|
4441
4445
|
break;
|
|
@@ -4541,7 +4545,7 @@ ${text}`,
|
|
|
4541
4545
|
}
|
|
4542
4546
|
const output = part.output;
|
|
4543
4547
|
if (output.type === "execution-denied") {
|
|
4544
|
-
const approvalId = (
|
|
4548
|
+
const approvalId = (_L = (_K = output.providerOptions) == null ? void 0 : _K.openai) == null ? void 0 : _L.approvalId;
|
|
4545
4549
|
if (approvalId) {
|
|
4546
4550
|
continue;
|
|
4547
4551
|
}
|
|
@@ -4621,7 +4625,7 @@ ${text}`,
|
|
|
4621
4625
|
file_id: parsedOutput.output.fileId,
|
|
4622
4626
|
detail: parsedOutput.output.detail
|
|
4623
4627
|
},
|
|
4624
|
-
acknowledged_safety_checks: (
|
|
4628
|
+
acknowledged_safety_checks: (_M = parsedOutput.acknowledgedSafetyChecks) == null ? void 0 : _M.map((safetyCheck) => ({
|
|
4625
4629
|
id: safetyCheck.id,
|
|
4626
4630
|
code: safetyCheck.code,
|
|
4627
4631
|
message: safetyCheck.message
|
|
@@ -4650,7 +4654,7 @@ ${text}`,
|
|
|
4650
4654
|
break;
|
|
4651
4655
|
case "execution-denied":
|
|
4652
4656
|
outputValue = convertScalarOutput(
|
|
4653
|
-
(
|
|
4657
|
+
(_N = output.reason) != null ? _N : "Tool call execution denied."
|
|
4654
4658
|
);
|
|
4655
4659
|
break;
|
|
4656
4660
|
case "json":
|
|
@@ -4756,7 +4760,7 @@ ${text}`,
|
|
|
4756
4760
|
warnings
|
|
4757
4761
|
});
|
|
4758
4762
|
const caller = mapToolCaller(
|
|
4759
|
-
(
|
|
4763
|
+
(_P = (_O = part.providerOptions) == null ? void 0 : _O[providerOptionsName]) == null ? void 0 : _P.caller
|
|
4760
4764
|
);
|
|
4761
4765
|
input.push({
|
|
4762
4766
|
type: "function_call_output",
|
|
@@ -5108,6 +5112,7 @@ var openaiResponsesChunkSchema = lazySchema18(
|
|
|
5108
5112
|
call_id: z20.string(),
|
|
5109
5113
|
name: z20.string(),
|
|
5110
5114
|
arguments: z20.string(),
|
|
5115
|
+
async: z20.boolean().nullish(),
|
|
5111
5116
|
namespace: z20.string().nullish(),
|
|
5112
5117
|
caller: openaiResponsesToolCallerSchema.nullish()
|
|
5113
5118
|
}),
|
|
@@ -5182,7 +5187,8 @@ var openaiResponsesChunkSchema = lazySchema18(
|
|
|
5182
5187
|
id: z20.string(),
|
|
5183
5188
|
call_id: z20.string(),
|
|
5184
5189
|
name: z20.string(),
|
|
5185
|
-
input: z20.string()
|
|
5190
|
+
input: z20.string(),
|
|
5191
|
+
async: z20.boolean().nullish()
|
|
5186
5192
|
}),
|
|
5187
5193
|
z20.object({
|
|
5188
5194
|
type: z20.literal("shell_call"),
|
|
@@ -5255,6 +5261,7 @@ var openaiResponsesChunkSchema = lazySchema18(
|
|
|
5255
5261
|
call_id: z20.string(),
|
|
5256
5262
|
name: z20.string(),
|
|
5257
5263
|
arguments: z20.string(),
|
|
5264
|
+
async: z20.boolean().nullish(),
|
|
5258
5265
|
status: z20.enum(["in_progress", "completed", "incomplete"]),
|
|
5259
5266
|
namespace: z20.string().nullish(),
|
|
5260
5267
|
caller: openaiResponsesToolCallerSchema.nullish()
|
|
@@ -5267,6 +5274,7 @@ var openaiResponsesChunkSchema = lazySchema18(
|
|
|
5267
5274
|
call_id: z20.string(),
|
|
5268
5275
|
name: z20.string(),
|
|
5269
5276
|
input: z20.string(),
|
|
5277
|
+
async: z20.boolean().nullish(),
|
|
5270
5278
|
status: z20.literal("completed")
|
|
5271
5279
|
}),
|
|
5272
5280
|
z20.object({
|
|
@@ -5704,6 +5712,7 @@ var openaiResponsesResponseSchema = lazySchema18(
|
|
|
5704
5712
|
name: z20.string(),
|
|
5705
5713
|
arguments: z20.string(),
|
|
5706
5714
|
id: z20.string(),
|
|
5715
|
+
async: z20.boolean().nullish(),
|
|
5707
5716
|
namespace: z20.string().nullish(),
|
|
5708
5717
|
caller: openaiResponsesToolCallerSchema.nullish()
|
|
5709
5718
|
}),
|
|
@@ -5714,7 +5723,8 @@ var openaiResponsesResponseSchema = lazySchema18(
|
|
|
5714
5723
|
call_id: z20.string(),
|
|
5715
5724
|
name: z20.string(),
|
|
5716
5725
|
input: z20.string(),
|
|
5717
|
-
id: z20.string()
|
|
5726
|
+
id: z20.string(),
|
|
5727
|
+
async: z20.boolean().nullish()
|
|
5718
5728
|
}),
|
|
5719
5729
|
openaiResponsesComputerCallSchema,
|
|
5720
5730
|
z20.object({
|
|
@@ -6320,6 +6330,7 @@ var customArgsSchema = lazySchema23(
|
|
|
6320
6330
|
() => zodSchema23(
|
|
6321
6331
|
z25.object({
|
|
6322
6332
|
description: z25.string().optional(),
|
|
6333
|
+
async: z25.boolean().optional(),
|
|
6323
6334
|
format: z25.union([
|
|
6324
6335
|
z25.object({
|
|
6325
6336
|
type: z25.literal("grammar"),
|
|
@@ -6525,7 +6536,8 @@ async function prepareResponsesTools({
|
|
|
6525
6536
|
allowedTools,
|
|
6526
6537
|
toolNameMapping,
|
|
6527
6538
|
customProviderToolNames,
|
|
6528
|
-
outputSchemaToolNames
|
|
6539
|
+
outputSchemaToolNames,
|
|
6540
|
+
supportsAsyncToolCalling = true
|
|
6529
6541
|
}) {
|
|
6530
6542
|
var _a2, _b, _c, _d;
|
|
6531
6543
|
tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
|
|
@@ -6559,7 +6571,13 @@ async function prepareResponsesTools({
|
|
|
6559
6571
|
}
|
|
6560
6572
|
const openaiFunctionTool = prepareFunctionTool({
|
|
6561
6573
|
tool,
|
|
6562
|
-
options: openaiOptions
|
|
6574
|
+
options: openaiOptions,
|
|
6575
|
+
async: resolveAsyncToolOption({
|
|
6576
|
+
value: openaiOptions == null ? void 0 : openaiOptions.async,
|
|
6577
|
+
supportsAsyncToolCalling,
|
|
6578
|
+
toolName: tool.name,
|
|
6579
|
+
toolWarnings
|
|
6580
|
+
})
|
|
6563
6581
|
});
|
|
6564
6582
|
const namespace = openaiOptions == null ? void 0 : openaiOptions.namespace;
|
|
6565
6583
|
if (namespace == null) {
|
|
@@ -6748,6 +6766,12 @@ async function prepareResponsesTools({
|
|
|
6748
6766
|
type: "custom",
|
|
6749
6767
|
name: tool.name,
|
|
6750
6768
|
description: args.description,
|
|
6769
|
+
...resolveAsyncToolOption({
|
|
6770
|
+
value: args.async,
|
|
6771
|
+
supportsAsyncToolCalling,
|
|
6772
|
+
toolName: tool.name,
|
|
6773
|
+
toolWarnings
|
|
6774
|
+
}) != null ? { async: args.async } : {},
|
|
6751
6775
|
format: args.format
|
|
6752
6776
|
});
|
|
6753
6777
|
resolvedCustomProviderToolNames.add(tool.name);
|
|
@@ -6927,7 +6951,8 @@ function toAllowedToolResolution(tool) {
|
|
|
6927
6951
|
}
|
|
6928
6952
|
function prepareFunctionTool({
|
|
6929
6953
|
tool,
|
|
6930
|
-
options
|
|
6954
|
+
options,
|
|
6955
|
+
async
|
|
6931
6956
|
}) {
|
|
6932
6957
|
const deferLoading = options == null ? void 0 : options.deferLoading;
|
|
6933
6958
|
return {
|
|
@@ -6935,12 +6960,29 @@ function prepareFunctionTool({
|
|
|
6935
6960
|
name: tool.name,
|
|
6936
6961
|
description: tool.description,
|
|
6937
6962
|
parameters: tool.inputSchema,
|
|
6963
|
+
...async != null ? { async } : {},
|
|
6938
6964
|
...tool.strict != null ? { strict: tool.strict } : {},
|
|
6939
6965
|
...deferLoading != null ? { defer_loading: deferLoading } : {},
|
|
6940
6966
|
...(options == null ? void 0 : options.allowedCallers) != null ? { allowed_callers: options.allowedCallers } : {},
|
|
6941
6967
|
...(options == null ? void 0 : options.outputSchema) != null ? { output_schema: options.outputSchema } : {}
|
|
6942
6968
|
};
|
|
6943
6969
|
}
|
|
6970
|
+
function resolveAsyncToolOption({
|
|
6971
|
+
value,
|
|
6972
|
+
supportsAsyncToolCalling,
|
|
6973
|
+
toolName,
|
|
6974
|
+
toolWarnings
|
|
6975
|
+
}) {
|
|
6976
|
+
if (value !== true || supportsAsyncToolCalling) {
|
|
6977
|
+
return value;
|
|
6978
|
+
}
|
|
6979
|
+
toolWarnings.push({
|
|
6980
|
+
type: "unsupported",
|
|
6981
|
+
feature: `async tool calling for "${toolName}"`,
|
|
6982
|
+
details: "Async tool calling is only supported by GPT-6 and later models."
|
|
6983
|
+
});
|
|
6984
|
+
return void 0;
|
|
6985
|
+
}
|
|
6944
6986
|
function mapShellEnvironment(environment) {
|
|
6945
6987
|
if (environment.type === "containerReference") {
|
|
6946
6988
|
const env2 = environment;
|
|
@@ -7078,13 +7120,14 @@ function mapComputerCallInput({
|
|
|
7078
7120
|
status
|
|
7079
7121
|
};
|
|
7080
7122
|
}
|
|
7123
|
+
var openaiResponsesSupportedUrls = {
|
|
7124
|
+
"image/*": [/^https?:\/\/.*$/],
|
|
7125
|
+
"application/pdf": [/^https?:\/\/.*$/]
|
|
7126
|
+
};
|
|
7081
7127
|
var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
7082
7128
|
constructor(modelId, config) {
|
|
7083
7129
|
this.specificationVersion = "v4";
|
|
7084
|
-
this.supportedUrls =
|
|
7085
|
-
"image/*": [/^https?:\/\/.*$/],
|
|
7086
|
-
"application/pdf": [/^https?:\/\/.*$/]
|
|
7087
|
-
};
|
|
7130
|
+
this.supportedUrls = openaiResponsesSupportedUrls;
|
|
7088
7131
|
this.modelId = modelId;
|
|
7089
7132
|
this.config = config;
|
|
7090
7133
|
}
|
|
@@ -7103,25 +7146,29 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
7103
7146
|
get provider() {
|
|
7104
7147
|
return this.config.provider;
|
|
7105
7148
|
}
|
|
7106
|
-
async
|
|
7107
|
-
|
|
7108
|
-
|
|
7109
|
-
|
|
7110
|
-
|
|
7111
|
-
|
|
7112
|
-
|
|
7113
|
-
|
|
7114
|
-
|
|
7115
|
-
|
|
7116
|
-
|
|
7117
|
-
|
|
7118
|
-
|
|
7119
|
-
|
|
7120
|
-
|
|
7149
|
+
static async prepareRequest({
|
|
7150
|
+
modelId,
|
|
7151
|
+
config,
|
|
7152
|
+
options: {
|
|
7153
|
+
maxOutputTokens,
|
|
7154
|
+
temperature,
|
|
7155
|
+
stopSequences,
|
|
7156
|
+
topP,
|
|
7157
|
+
topK,
|
|
7158
|
+
presencePenalty,
|
|
7159
|
+
frequencyPenalty,
|
|
7160
|
+
seed,
|
|
7161
|
+
prompt,
|
|
7162
|
+
reasoning,
|
|
7163
|
+
providerOptions,
|
|
7164
|
+
tools,
|
|
7165
|
+
toolChoice,
|
|
7166
|
+
responseFormat
|
|
7167
|
+
}
|
|
7121
7168
|
}) {
|
|
7122
7169
|
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
7123
7170
|
const warnings = [];
|
|
7124
|
-
const modelCapabilities = getOpenAILanguageModelCapabilities(
|
|
7171
|
+
const modelCapabilities = getOpenAILanguageModelCapabilities(modelId);
|
|
7125
7172
|
if (topK != null) {
|
|
7126
7173
|
warnings.push({ type: "unsupported", feature: "topK" });
|
|
7127
7174
|
}
|
|
@@ -7137,7 +7184,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
7137
7184
|
if (stopSequences != null) {
|
|
7138
7185
|
warnings.push({ type: "unsupported", feature: "stopSequences" });
|
|
7139
7186
|
}
|
|
7140
|
-
const providerOptionsName =
|
|
7187
|
+
const providerOptionsName = config.provider.includes("azure") ? "azure" : "openai";
|
|
7141
7188
|
let openaiOptions = await parseProviderOptions8({
|
|
7142
7189
|
provider: providerOptionsName,
|
|
7143
7190
|
providerOptions,
|
|
@@ -7157,7 +7204,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
7157
7204
|
warnings.push({
|
|
7158
7205
|
type: "unsupported",
|
|
7159
7206
|
feature: "reasoningEffort",
|
|
7160
|
-
details: `${
|
|
7207
|
+
details: `${modelId} only supports the following reasoning efforts: ${modelCapabilities.supportedReasoningEfforts.join(", ")}`
|
|
7161
7208
|
});
|
|
7162
7209
|
resolvedReasoningEffort = void 0;
|
|
7163
7210
|
}
|
|
@@ -7199,14 +7246,15 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
7199
7246
|
allowedTools: (_c = openaiOptions == null ? void 0 : openaiOptions.allowedTools) != null ? _c : void 0,
|
|
7200
7247
|
toolNameMapping,
|
|
7201
7248
|
customProviderToolNames,
|
|
7202
|
-
outputSchemaToolNames
|
|
7249
|
+
outputSchemaToolNames,
|
|
7250
|
+
supportsAsyncToolCalling: modelCapabilities.supportsAsyncToolCalling
|
|
7203
7251
|
});
|
|
7204
7252
|
const { input, warnings: inputWarnings } = await convertToOpenAIResponsesInput({
|
|
7205
7253
|
prompt,
|
|
7206
7254
|
toolNameMapping,
|
|
7207
7255
|
systemMessageMode: (_d = openaiOptions == null ? void 0 : openaiOptions.systemMessageMode) != null ? _d : isReasoningModel ? "developer" : modelCapabilities.systemMessageMode,
|
|
7208
7256
|
providerOptionsName,
|
|
7209
|
-
fileIdPrefixes:
|
|
7257
|
+
fileIdPrefixes: config.fileIdPrefixes,
|
|
7210
7258
|
passThroughUnsupportedFiles: (_e = openaiOptions == null ? void 0 : openaiOptions.passThroughUnsupportedFiles) != null ? _e : false,
|
|
7211
7259
|
store: (_f = openaiOptions == null ? void 0 : openaiOptions.store) != null ? _f : true,
|
|
7212
7260
|
hasConversation: (openaiOptions == null ? void 0 : openaiOptions.conversation) != null,
|
|
@@ -7271,7 +7319,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
7271
7319
|
addInclude("reasoning.encrypted_content");
|
|
7272
7320
|
}
|
|
7273
7321
|
const baseArgs = {
|
|
7274
|
-
model:
|
|
7322
|
+
model: modelId,
|
|
7275
7323
|
input,
|
|
7276
7324
|
temperature,
|
|
7277
7325
|
top_p: topP,
|
|
@@ -7437,6 +7485,13 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
7437
7485
|
isShellProviderExecuted
|
|
7438
7486
|
};
|
|
7439
7487
|
}
|
|
7488
|
+
getArgs(options) {
|
|
7489
|
+
return _OpenAIResponsesLanguageModel.prepareRequest({
|
|
7490
|
+
modelId: this.modelId,
|
|
7491
|
+
config: this.config,
|
|
7492
|
+
options
|
|
7493
|
+
});
|
|
7494
|
+
}
|
|
7440
7495
|
async doGenerate(options) {
|
|
7441
7496
|
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H;
|
|
7442
7497
|
const {
|
|
@@ -7733,6 +7788,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
7733
7788
|
providerMetadata: {
|
|
7734
7789
|
[providerOptionsName]: {
|
|
7735
7790
|
itemId: part.id,
|
|
7791
|
+
...part.async != null && { async: part.async },
|
|
7736
7792
|
...part.namespace != null && { namespace: part.namespace },
|
|
7737
7793
|
...part.caller != null && {
|
|
7738
7794
|
caller: part.caller.type === "program" ? {
|
|
@@ -7794,7 +7850,8 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
7794
7850
|
input: JSON.stringify(part.input),
|
|
7795
7851
|
providerMetadata: {
|
|
7796
7852
|
[providerOptionsName]: {
|
|
7797
|
-
itemId: part.id
|
|
7853
|
+
itemId: part.id,
|
|
7854
|
+
...part.async != null && { async: part.async }
|
|
7798
7855
|
}
|
|
7799
7856
|
}
|
|
7800
7857
|
});
|
|
@@ -8121,7 +8178,8 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
8121
8178
|
toolName: value.item.name,
|
|
8122
8179
|
toolCallId: value.item.call_id,
|
|
8123
8180
|
suppressInputStreaming,
|
|
8124
|
-
bufferedInputDeltas: suppressInputStreaming ? [] : void 0
|
|
8181
|
+
bufferedInputDeltas: suppressInputStreaming ? [] : void 0,
|
|
8182
|
+
async: value.item.async
|
|
8125
8183
|
};
|
|
8126
8184
|
if (!suppressInputStreaming) {
|
|
8127
8185
|
controller.enqueue({
|
|
@@ -8136,7 +8194,8 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
8136
8194
|
);
|
|
8137
8195
|
ongoingToolCalls[value.output_index] = {
|
|
8138
8196
|
toolName,
|
|
8139
|
-
toolCallId: value.item.call_id
|
|
8197
|
+
toolCallId: value.item.call_id,
|
|
8198
|
+
async: value.item.async
|
|
8140
8199
|
};
|
|
8141
8200
|
controller.enqueue({
|
|
8142
8201
|
type: "tool-input-start",
|
|
@@ -8387,6 +8446,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
8387
8446
|
providerMetadata: {
|
|
8388
8447
|
[providerOptionsName]: {
|
|
8389
8448
|
itemId: item.id,
|
|
8449
|
+
...item.async != null ? { async: item.async } : (ongoingToolCall == null ? void 0 : ongoingToolCall.async) != null ? { async: ongoingToolCall.async } : {},
|
|
8390
8450
|
...item.namespace != null && {
|
|
8391
8451
|
namespace: item.namespace
|
|
8392
8452
|
},
|
|
@@ -8472,6 +8532,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
8472
8532
|
}
|
|
8473
8533
|
});
|
|
8474
8534
|
} else if (value.item.type === "custom_tool_call") {
|
|
8535
|
+
const ongoingToolCall = ongoingToolCalls[value.output_index];
|
|
8475
8536
|
ongoingToolCalls[value.output_index] = void 0;
|
|
8476
8537
|
hasFunctionCall = true;
|
|
8477
8538
|
const toolName = toolNameMapping.toCustomToolName(
|
|
@@ -8488,7 +8549,8 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
|
|
|
8488
8549
|
input: JSON.stringify(value.item.input),
|
|
8489
8550
|
providerMetadata: {
|
|
8490
8551
|
[providerOptionsName]: {
|
|
8491
|
-
itemId: value.item.id
|
|
8552
|
+
itemId: value.item.id,
|
|
8553
|
+
...value.item.async != null ? { async: value.item.async } : (ongoingToolCall == null ? void 0 : ongoingToolCall.async) != null ? { async: ongoingToolCall.async } : {}
|
|
8492
8554
|
}
|
|
8493
8555
|
}
|
|
8494
8556
|
});
|
|
@@ -9316,6 +9378,7 @@ export {
|
|
|
9316
9378
|
openaiImageModelOptions,
|
|
9317
9379
|
openaiLanguageModelChatOptions,
|
|
9318
9380
|
openaiLanguageModelCompletionOptions,
|
|
9381
|
+
openaiResponsesSupportedUrls,
|
|
9319
9382
|
openaiSpeechModelOptionsSchema,
|
|
9320
9383
|
programmaticToolCalling,
|
|
9321
9384
|
programmaticToolCallingInputSchema,
|