@ai-sdk/openai 3.0.130 → 3.0.132
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 +16 -0
- package/dist/index.d.mts +10 -1
- package/dist/index.d.ts +10 -1
- package/dist/index.js +77 -54
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +221 -192
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +96 -3
- package/dist/internal/index.d.ts +96 -3
- package/dist/internal/index.js +85 -53
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +225 -191
- package/dist/internal/index.mjs.map +1 -1
- package/docs/03-openai.mdx +3 -3
- package/package.json +5 -5
- package/src/chat/openai-chat-api.ts +1 -1
- package/src/completion/openai-completion-api.ts +1 -1
- package/src/image/openai-image-model-options.ts +40 -39
- package/src/internal/index.ts +1 -0
- 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 +117 -94
- package/src/responses/openai-responses-language-model.ts +1 -0
- package/src/responses/openai-responses-options.ts +4 -2
- package/src/responses/openai-responses-prepare-tools.ts +4 -3
- 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
|
@@ -54,6 +54,10 @@ __export(index_exports, {
|
|
|
54
54
|
openaiLanguageModelChatOptions: () => openaiLanguageModelChatOptions,
|
|
55
55
|
openaiLanguageModelCompletionOptions: () => openaiLanguageModelCompletionOptions,
|
|
56
56
|
openaiSpeechModelOptionsSchema: () => openaiSpeechModelOptionsSchema,
|
|
57
|
+
toolSearch: () => toolSearch,
|
|
58
|
+
toolSearchArgsSchema: () => toolSearchArgsSchema,
|
|
59
|
+
toolSearchInputSchema: () => toolSearchInputSchema,
|
|
60
|
+
toolSearchOutputSchema: () => toolSearchOutputSchema,
|
|
57
61
|
webSearch: () => webSearch,
|
|
58
62
|
webSearchArgsSchema: () => webSearchArgsSchema,
|
|
59
63
|
webSearchOutputSchema: () => webSearchOutputSchema,
|
|
@@ -71,7 +75,7 @@ var import_provider_utils5 = require("@ai-sdk/provider-utils");
|
|
|
71
75
|
// src/openai-error.ts
|
|
72
76
|
var import_v4 = require("zod/v4");
|
|
73
77
|
var import_provider_utils = require("@ai-sdk/provider-utils");
|
|
74
|
-
var openaiErrorDataSchema = import_v4.z.object({
|
|
78
|
+
var openaiErrorDataSchema = () => import_v4.z.object({
|
|
75
79
|
error: import_v4.z.object({
|
|
76
80
|
message: import_v4.z.string(),
|
|
77
81
|
// The additional information below is handled loosely to support
|
|
@@ -82,8 +86,11 @@ var openaiErrorDataSchema = import_v4.z.object({
|
|
|
82
86
|
code: import_v4.z.union([import_v4.z.string(), import_v4.z.number()]).nullish()
|
|
83
87
|
})
|
|
84
88
|
});
|
|
89
|
+
var openaiErrorDataSchemaValidator = (0, import_provider_utils.lazySchema)(
|
|
90
|
+
() => (0, import_provider_utils.zodSchema)(openaiErrorDataSchema())
|
|
91
|
+
);
|
|
85
92
|
var openaiFailedResponseHandler = (0, import_provider_utils.createJsonErrorResponseHandler)({
|
|
86
|
-
errorSchema:
|
|
93
|
+
errorSchema: openaiErrorDataSchemaValidator,
|
|
87
94
|
errorToMessage: (data) => data.error.message
|
|
88
95
|
});
|
|
89
96
|
|
|
@@ -837,7 +844,7 @@ var openaiChatChunkSchema = (0, import_provider_utils3.lazySchema)(
|
|
|
837
844
|
}).nullish()
|
|
838
845
|
}).nullish()
|
|
839
846
|
}),
|
|
840
|
-
openaiErrorDataSchema
|
|
847
|
+
openaiErrorDataSchema()
|
|
841
848
|
])
|
|
842
849
|
)
|
|
843
850
|
);
|
|
@@ -1686,7 +1693,7 @@ var openaiCompletionChunkSchema = (0, import_provider_utils6.lazySchema)(
|
|
|
1686
1693
|
total_tokens: import_v44.z.number()
|
|
1687
1694
|
}).nullish()
|
|
1688
1695
|
}),
|
|
1689
|
-
openaiErrorDataSchema
|
|
1696
|
+
openaiErrorDataSchema()
|
|
1690
1697
|
])
|
|
1691
1698
|
)
|
|
1692
1699
|
);
|
|
@@ -2144,7 +2151,7 @@ function getMaxImagesPerCall(modelId) {
|
|
|
2144
2151
|
var _a2;
|
|
2145
2152
|
return (_a2 = modelMaxImagesPerCall[modelId]) != null ? _a2 : modelId.startsWith("gpt-image-") ? 10 : 1;
|
|
2146
2153
|
}
|
|
2147
|
-
var baseImageModelOptionsObject = import_v49.z.object({
|
|
2154
|
+
var baseImageModelOptionsObject = () => import_v49.z.object({
|
|
2148
2155
|
/**
|
|
2149
2156
|
* Quality of the generated image(s).
|
|
2150
2157
|
*
|
|
@@ -2175,11 +2182,11 @@ var baseImageModelOptionsObject = import_v49.z.object({
|
|
|
2175
2182
|
user: import_v49.z.string().optional()
|
|
2176
2183
|
});
|
|
2177
2184
|
var openaiImageModelOptions = (0, import_provider_utils13.lazySchema)(
|
|
2178
|
-
() => (0, import_provider_utils13.zodSchema)(baseImageModelOptionsObject)
|
|
2185
|
+
() => (0, import_provider_utils13.zodSchema)(baseImageModelOptionsObject())
|
|
2179
2186
|
);
|
|
2180
2187
|
var openaiImageModelGenerationOptions = (0, import_provider_utils13.lazySchema)(
|
|
2181
2188
|
() => (0, import_provider_utils13.zodSchema)(
|
|
2182
|
-
baseImageModelOptionsObject.extend({
|
|
2189
|
+
baseImageModelOptionsObject().extend({
|
|
2183
2190
|
/**
|
|
2184
2191
|
* Style of the generated image. `vivid` produces hyper-real and
|
|
2185
2192
|
* dramatic images; `natural` produces more subdued, less hyper-real
|
|
@@ -2196,7 +2203,7 @@ var openaiImageModelGenerationOptions = (0, import_provider_utils13.lazySchema)(
|
|
|
2196
2203
|
);
|
|
2197
2204
|
var openaiImageModelEditOptions = (0, import_provider_utils13.lazySchema)(
|
|
2198
2205
|
() => (0, import_provider_utils13.zodSchema)(
|
|
2199
|
-
baseImageModelOptionsObject.extend({
|
|
2206
|
+
baseImageModelOptionsObject().extend({
|
|
2200
2207
|
/**
|
|
2201
2208
|
* Fidelity of the output image(s) to the input image(s).
|
|
2202
2209
|
*/
|
|
@@ -2967,11 +2974,13 @@ var openaiLanguageModelResponsesOptionsSchema = (0, import_provider_utils20.lazy
|
|
|
2967
2974
|
/**
|
|
2968
2975
|
* Prompt cache behavior for GPT-5.6 and later models.
|
|
2969
2976
|
* `mode` controls whether OpenAI also places an implicit breakpoint.
|
|
2970
|
-
* `ttl` sets the minimum cache lifetime
|
|
2977
|
+
* `ttl` sets the minimum cache lifetime: `'30m'` (default) or `'12h'`.
|
|
2978
|
+
* `prewarm` writes the prompt to the cache without generating output.
|
|
2971
2979
|
*/
|
|
2972
2980
|
promptCacheOptions: import_v413.z.object({
|
|
2973
2981
|
mode: import_v413.z.enum(["implicit", "explicit"]).optional(),
|
|
2974
|
-
ttl: import_v413.z.
|
|
2982
|
+
ttl: import_v413.z.enum(["30m", "12h"]).optional(),
|
|
2983
|
+
prewarm: import_v413.z.boolean().optional()
|
|
2975
2984
|
}).optional(),
|
|
2976
2985
|
/**
|
|
2977
2986
|
* The retention policy for the prompt cache.
|
|
@@ -3217,7 +3226,7 @@ var shellOutputSchema = (0, import_provider_utils23.lazySchema)(
|
|
|
3217
3226
|
})
|
|
3218
3227
|
)
|
|
3219
3228
|
);
|
|
3220
|
-
var shellSkillsSchema = import_v416.z.array(
|
|
3229
|
+
var shellSkillsSchema = () => import_v416.z.array(
|
|
3221
3230
|
import_v416.z.discriminatedUnion("type", [
|
|
3222
3231
|
import_v416.z.object({
|
|
3223
3232
|
type: import_v416.z.literal("skillReference"),
|
|
@@ -3258,7 +3267,7 @@ var shellArgsSchema = (0, import_provider_utils23.lazySchema)(
|
|
|
3258
3267
|
).optional()
|
|
3259
3268
|
})
|
|
3260
3269
|
]).optional(),
|
|
3261
|
-
skills: shellSkillsSchema
|
|
3270
|
+
skills: shellSkillsSchema()
|
|
3262
3271
|
}),
|
|
3263
3272
|
import_v416.z.object({
|
|
3264
3273
|
type: import_v416.z.literal("containerReference"),
|
|
@@ -3316,6 +3325,7 @@ var toolSearchToolFactory = (0, import_provider_utils24.createProviderToolFactor
|
|
|
3316
3325
|
inputSchema: toolSearchInputSchema,
|
|
3317
3326
|
outputSchema: toolSearchOutputSchema
|
|
3318
3327
|
});
|
|
3328
|
+
var toolSearch = (args = {}) => toolSearchToolFactory(args);
|
|
3319
3329
|
|
|
3320
3330
|
// src/tool/web-search.ts
|
|
3321
3331
|
var import_provider_utils25 = require("@ai-sdk/provider-utils");
|
|
@@ -4487,10 +4497,14 @@ ${text}`,
|
|
|
4487
4497
|
}
|
|
4488
4498
|
return { input, warnings };
|
|
4489
4499
|
}
|
|
4490
|
-
var openaiResponsesReasoningProviderOptionsSchema =
|
|
4491
|
-
|
|
4492
|
-
|
|
4493
|
-
|
|
4500
|
+
var openaiResponsesReasoningProviderOptionsSchema = (0, import_provider_utils27.lazySchema)(
|
|
4501
|
+
() => (0, import_provider_utils27.zodSchema)(
|
|
4502
|
+
import_v419.z.object({
|
|
4503
|
+
itemId: import_v419.z.string().nullish(),
|
|
4504
|
+
reasoningEncryptedContent: import_v419.z.string().nullish()
|
|
4505
|
+
})
|
|
4506
|
+
)
|
|
4507
|
+
);
|
|
4494
4508
|
|
|
4495
4509
|
// src/responses/map-openai-responses-finish-reason.ts
|
|
4496
4510
|
function mapOpenAIResponseFinishReason({
|
|
@@ -4513,33 +4527,41 @@ function mapOpenAIResponseFinishReason({
|
|
|
4513
4527
|
// src/responses/openai-responses-api.ts
|
|
4514
4528
|
var import_provider_utils28 = require("@ai-sdk/provider-utils");
|
|
4515
4529
|
var import_v420 = require("zod/v4");
|
|
4516
|
-
var
|
|
4530
|
+
var cachedJsonValueSchema;
|
|
4531
|
+
var jsonValueSchema = () => cachedJsonValueSchema != null ? cachedJsonValueSchema : cachedJsonValueSchema = import_v420.z.lazy(
|
|
4517
4532
|
() => import_v420.z.union([
|
|
4518
4533
|
import_v420.z.string(),
|
|
4519
4534
|
import_v420.z.number(),
|
|
4520
4535
|
import_v420.z.boolean(),
|
|
4521
4536
|
import_v420.z.null(),
|
|
4522
|
-
import_v420.z.array(jsonValueSchema),
|
|
4523
|
-
import_v420.z.record(import_v420.z.string(), jsonValueSchema.optional())
|
|
4537
|
+
import_v420.z.array(jsonValueSchema()),
|
|
4538
|
+
import_v420.z.record(import_v420.z.string(), jsonValueSchema().optional())
|
|
4524
4539
|
])
|
|
4525
4540
|
);
|
|
4526
|
-
var jsonObjectSchema = import_v420.z.record(import_v420.z.string(), jsonValueSchema.optional());
|
|
4527
|
-
var openaiResponsesUsageSchema = import_v420.z.intersection(
|
|
4528
|
-
jsonObjectSchema,
|
|
4541
|
+
var jsonObjectSchema = () => import_v420.z.record(import_v420.z.string(), jsonValueSchema().optional());
|
|
4542
|
+
var openaiResponsesUsageSchema = () => import_v420.z.intersection(
|
|
4543
|
+
jsonObjectSchema(),
|
|
4529
4544
|
import_v420.z.object({
|
|
4530
4545
|
input_tokens: import_v420.z.number(),
|
|
4531
4546
|
input_tokens_details: import_v420.z.intersection(
|
|
4532
|
-
jsonObjectSchema,
|
|
4547
|
+
jsonObjectSchema(),
|
|
4533
4548
|
import_v420.z.object({
|
|
4534
4549
|
cached_tokens: import_v420.z.number().nullish(),
|
|
4535
4550
|
cache_write_tokens: import_v420.z.number().nullish(),
|
|
4551
|
+
cache_write_tokens_details: import_v420.z.intersection(
|
|
4552
|
+
jsonObjectSchema(),
|
|
4553
|
+
import_v420.z.object({
|
|
4554
|
+
ttl_30m_tokens: import_v420.z.number().nullish(),
|
|
4555
|
+
ttl_12h_tokens: import_v420.z.number().nullish()
|
|
4556
|
+
})
|
|
4557
|
+
).nullish(),
|
|
4536
4558
|
orchestration_input_tokens: import_v420.z.number().nullish(),
|
|
4537
4559
|
orchestration_input_cached_tokens: import_v420.z.number().nullish()
|
|
4538
4560
|
})
|
|
4539
4561
|
).nullish(),
|
|
4540
4562
|
output_tokens: import_v420.z.number(),
|
|
4541
4563
|
output_tokens_details: import_v420.z.intersection(
|
|
4542
|
-
jsonObjectSchema,
|
|
4564
|
+
jsonObjectSchema(),
|
|
4543
4565
|
import_v420.z.object({
|
|
4544
4566
|
reasoning_tokens: import_v420.z.number().nullish(),
|
|
4545
4567
|
orchestration_output_tokens: import_v420.z.number().nullish()
|
|
@@ -4551,7 +4573,7 @@ var openaiResponsesUsageSchema = import_v420.z.intersection(
|
|
|
4551
4573
|
function isRecord(value) {
|
|
4552
4574
|
return value != null && typeof value === "object" && !Array.isArray(value);
|
|
4553
4575
|
}
|
|
4554
|
-
var openaiResponsesLocalShellCallSchema = import_v420.z.object({
|
|
4576
|
+
var openaiResponsesLocalShellCallSchema = () => import_v420.z.object({
|
|
4555
4577
|
type: import_v420.z.literal("local_shell_call"),
|
|
4556
4578
|
id: import_v420.z.string(),
|
|
4557
4579
|
call_id: import_v420.z.string(),
|
|
@@ -4564,7 +4586,7 @@ var openaiResponsesLocalShellCallSchema = import_v420.z.object({
|
|
|
4564
4586
|
env: import_v420.z.record(import_v420.z.string(), import_v420.z.string()).optional()
|
|
4565
4587
|
})
|
|
4566
4588
|
});
|
|
4567
|
-
var openaiResponsesNestedErrorChunkSchema = import_v420.z.object({
|
|
4589
|
+
var openaiResponsesNestedErrorChunkSchema = () => import_v420.z.object({
|
|
4568
4590
|
type: import_v420.z.literal("error"),
|
|
4569
4591
|
sequence_number: import_v420.z.number(),
|
|
4570
4592
|
error: import_v420.z.object({
|
|
@@ -4574,7 +4596,7 @@ var openaiResponsesNestedErrorChunkSchema = import_v420.z.object({
|
|
|
4574
4596
|
param: import_v420.z.string().nullish()
|
|
4575
4597
|
})
|
|
4576
4598
|
});
|
|
4577
|
-
var openaiResponsesErrorChunkSchema = import_v420.z.object({
|
|
4599
|
+
var openaiResponsesErrorChunkSchema = () => import_v420.z.object({
|
|
4578
4600
|
type: import_v420.z.literal("error"),
|
|
4579
4601
|
sequence_number: import_v420.z.number(),
|
|
4580
4602
|
code: import_v420.z.string().nullish(),
|
|
@@ -4659,7 +4681,7 @@ var openaiResponsesChunkSchema = (0, import_provider_utils28.lazySchema)(
|
|
|
4659
4681
|
type: import_v420.z.enum(["response.completed", "response.incomplete"]),
|
|
4660
4682
|
response: import_v420.z.object({
|
|
4661
4683
|
incomplete_details: import_v420.z.object({ reason: import_v420.z.string() }).nullish(),
|
|
4662
|
-
usage: openaiResponsesUsageSchema.nullish(),
|
|
4684
|
+
usage: openaiResponsesUsageSchema().nullish(),
|
|
4663
4685
|
reasoning: import_v420.z.object({
|
|
4664
4686
|
context: import_v420.z.string().nullish()
|
|
4665
4687
|
}).nullish(),
|
|
@@ -4675,7 +4697,7 @@ var openaiResponsesChunkSchema = (0, import_provider_utils28.lazySchema)(
|
|
|
4675
4697
|
message: import_v420.z.string()
|
|
4676
4698
|
}).nullish(),
|
|
4677
4699
|
incomplete_details: import_v420.z.object({ reason: import_v420.z.string() }).nullish(),
|
|
4678
|
-
usage: openaiResponsesUsageSchema.nullish(),
|
|
4700
|
+
usage: openaiResponsesUsageSchema().nullish(),
|
|
4679
4701
|
reasoning: import_v420.z.object({
|
|
4680
4702
|
context: import_v420.z.string().nullish()
|
|
4681
4703
|
}).nullish(),
|
|
@@ -4728,7 +4750,7 @@ var openaiResponsesChunkSchema = (0, import_provider_utils28.lazySchema)(
|
|
|
4728
4750
|
type: import_v420.z.literal("file_search_call"),
|
|
4729
4751
|
id: import_v420.z.string()
|
|
4730
4752
|
}),
|
|
4731
|
-
openaiResponsesLocalShellCallSchema,
|
|
4753
|
+
openaiResponsesLocalShellCallSchema(),
|
|
4732
4754
|
import_v420.z.object({
|
|
4733
4755
|
type: import_v420.z.literal("image_generation_call"),
|
|
4734
4756
|
id: import_v420.z.string()
|
|
@@ -4832,7 +4854,7 @@ var openaiResponsesChunkSchema = (0, import_provider_utils28.lazySchema)(
|
|
|
4832
4854
|
execution: import_v420.z.enum(["server", "client"]),
|
|
4833
4855
|
call_id: import_v420.z.string().nullable(),
|
|
4834
4856
|
status: import_v420.z.enum(["in_progress", "completed", "incomplete"]),
|
|
4835
|
-
tools: import_v420.z.array(import_v420.z.record(import_v420.z.string(), jsonValueSchema.optional()))
|
|
4857
|
+
tools: import_v420.z.array(import_v420.z.record(import_v420.z.string(), jsonValueSchema().optional()))
|
|
4836
4858
|
})
|
|
4837
4859
|
])
|
|
4838
4860
|
}),
|
|
@@ -4930,7 +4952,7 @@ var openaiResponsesChunkSchema = (0, import_provider_utils28.lazySchema)(
|
|
|
4930
4952
|
})
|
|
4931
4953
|
).nullish()
|
|
4932
4954
|
}),
|
|
4933
|
-
openaiResponsesLocalShellCallSchema,
|
|
4955
|
+
openaiResponsesLocalShellCallSchema(),
|
|
4934
4956
|
import_v420.z.object({
|
|
4935
4957
|
type: import_v420.z.literal("computer_call"),
|
|
4936
4958
|
id: import_v420.z.string(),
|
|
@@ -5047,7 +5069,7 @@ var openaiResponsesChunkSchema = (0, import_provider_utils28.lazySchema)(
|
|
|
5047
5069
|
execution: import_v420.z.enum(["server", "client"]),
|
|
5048
5070
|
call_id: import_v420.z.string().nullable(),
|
|
5049
5071
|
status: import_v420.z.enum(["in_progress", "completed", "incomplete"]),
|
|
5050
|
-
tools: import_v420.z.array(import_v420.z.record(import_v420.z.string(), jsonValueSchema.optional()))
|
|
5072
|
+
tools: import_v420.z.array(import_v420.z.record(import_v420.z.string(), jsonValueSchema().optional()))
|
|
5051
5073
|
})
|
|
5052
5074
|
])
|
|
5053
5075
|
}),
|
|
@@ -5149,8 +5171,8 @@ var openaiResponsesChunkSchema = (0, import_provider_utils28.lazySchema)(
|
|
|
5149
5171
|
output_index: import_v420.z.number(),
|
|
5150
5172
|
diff: import_v420.z.string()
|
|
5151
5173
|
}),
|
|
5152
|
-
openaiResponsesNestedErrorChunkSchema,
|
|
5153
|
-
openaiResponsesErrorChunkSchema,
|
|
5174
|
+
openaiResponsesNestedErrorChunkSchema(),
|
|
5175
|
+
openaiResponsesErrorChunkSchema(),
|
|
5154
5176
|
import_v420.z.object({ type: import_v420.z.string() }).loose().refine((value) => !isModeledOpenAIResponsesChunk(value), {
|
|
5155
5177
|
message: "Known response chunk failed schema validation"
|
|
5156
5178
|
}).transform((value) => ({
|
|
@@ -5293,7 +5315,7 @@ var openaiResponsesResponseSchema = (0, import_provider_utils28.lazySchema)(
|
|
|
5293
5315
|
id: import_v420.z.string(),
|
|
5294
5316
|
result: import_v420.z.string()
|
|
5295
5317
|
}),
|
|
5296
|
-
openaiResponsesLocalShellCallSchema,
|
|
5318
|
+
openaiResponsesLocalShellCallSchema(),
|
|
5297
5319
|
import_v420.z.object({
|
|
5298
5320
|
type: import_v420.z.literal("function_call"),
|
|
5299
5321
|
call_id: import_v420.z.string(),
|
|
@@ -5438,7 +5460,9 @@ var openaiResponsesResponseSchema = (0, import_provider_utils28.lazySchema)(
|
|
|
5438
5460
|
execution: import_v420.z.enum(["server", "client"]),
|
|
5439
5461
|
call_id: import_v420.z.string().nullable(),
|
|
5440
5462
|
status: import_v420.z.enum(["in_progress", "completed", "incomplete"]),
|
|
5441
|
-
tools: import_v420.z.array(
|
|
5463
|
+
tools: import_v420.z.array(
|
|
5464
|
+
import_v420.z.record(import_v420.z.string(), jsonValueSchema().optional())
|
|
5465
|
+
)
|
|
5442
5466
|
})
|
|
5443
5467
|
])
|
|
5444
5468
|
).optional(),
|
|
@@ -5447,7 +5471,7 @@ var openaiResponsesResponseSchema = (0, import_provider_utils28.lazySchema)(
|
|
|
5447
5471
|
context: import_v420.z.string().nullish()
|
|
5448
5472
|
}).nullish(),
|
|
5449
5473
|
incomplete_details: import_v420.z.object({ reason: import_v420.z.string() }).nullish(),
|
|
5450
|
-
usage: openaiResponsesUsageSchema.nullish()
|
|
5474
|
+
usage: openaiResponsesUsageSchema().nullish()
|
|
5451
5475
|
})
|
|
5452
5476
|
)
|
|
5453
5477
|
);
|
|
@@ -5503,15 +5527,16 @@ var codeInterpreter = (args = {}) => {
|
|
|
5503
5527
|
// src/tool/file-search.ts
|
|
5504
5528
|
var import_provider_utils30 = require("@ai-sdk/provider-utils");
|
|
5505
5529
|
var import_v422 = require("zod/v4");
|
|
5506
|
-
var comparisonFilterSchema = import_v422.z.object({
|
|
5530
|
+
var comparisonFilterSchema = () => import_v422.z.object({
|
|
5507
5531
|
key: import_v422.z.string(),
|
|
5508
5532
|
type: import_v422.z.enum(["eq", "ne", "gt", "gte", "lt", "lte", "in", "nin"]),
|
|
5509
5533
|
value: import_v422.z.union([import_v422.z.string(), import_v422.z.number(), import_v422.z.boolean(), import_v422.z.array(import_v422.z.string())])
|
|
5510
5534
|
});
|
|
5511
|
-
var
|
|
5535
|
+
var cachedCompoundFilterSchema;
|
|
5536
|
+
var compoundFilterSchema = () => cachedCompoundFilterSchema != null ? cachedCompoundFilterSchema : cachedCompoundFilterSchema = import_v422.z.object({
|
|
5512
5537
|
type: import_v422.z.enum(["and", "or"]),
|
|
5513
5538
|
filters: import_v422.z.array(
|
|
5514
|
-
import_v422.z.union([comparisonFilterSchema, import_v422.z.lazy(() => compoundFilterSchema)])
|
|
5539
|
+
import_v422.z.union([comparisonFilterSchema(), import_v422.z.lazy(() => compoundFilterSchema())])
|
|
5515
5540
|
)
|
|
5516
5541
|
});
|
|
5517
5542
|
var fileSearchArgsSchema = (0, import_provider_utils30.lazySchema)(
|
|
@@ -5523,7 +5548,7 @@ var fileSearchArgsSchema = (0, import_provider_utils30.lazySchema)(
|
|
|
5523
5548
|
ranker: import_v422.z.string().optional(),
|
|
5524
5549
|
scoreThreshold: import_v422.z.number().optional()
|
|
5525
5550
|
}).optional(),
|
|
5526
|
-
filters: import_v422.z.union([comparisonFilterSchema, compoundFilterSchema]).optional()
|
|
5551
|
+
filters: import_v422.z.union([comparisonFilterSchema(), compoundFilterSchema()]).optional()
|
|
5527
5552
|
})
|
|
5528
5553
|
)
|
|
5529
5554
|
);
|
|
@@ -5615,14 +5640,15 @@ var customToolFactory = (0, import_provider_utils32.createProviderToolFactory)({
|
|
|
5615
5640
|
// src/tool/mcp.ts
|
|
5616
5641
|
var import_provider_utils33 = require("@ai-sdk/provider-utils");
|
|
5617
5642
|
var import_v425 = require("zod/v4");
|
|
5618
|
-
var
|
|
5643
|
+
var cachedJsonValueSchema2;
|
|
5644
|
+
var jsonValueSchema2 = () => cachedJsonValueSchema2 != null ? cachedJsonValueSchema2 : cachedJsonValueSchema2 = import_v425.z.lazy(
|
|
5619
5645
|
() => import_v425.z.union([
|
|
5620
5646
|
import_v425.z.string(),
|
|
5621
5647
|
import_v425.z.number(),
|
|
5622
5648
|
import_v425.z.boolean(),
|
|
5623
5649
|
import_v425.z.null(),
|
|
5624
|
-
import_v425.z.array(jsonValueSchema2),
|
|
5625
|
-
import_v425.z.record(import_v425.z.string(), jsonValueSchema2)
|
|
5650
|
+
import_v425.z.array(jsonValueSchema2()),
|
|
5651
|
+
import_v425.z.record(import_v425.z.string(), jsonValueSchema2())
|
|
5626
5652
|
])
|
|
5627
5653
|
);
|
|
5628
5654
|
var mcpArgsSchema = (0, import_provider_utils33.lazySchema)(
|
|
@@ -5664,7 +5690,7 @@ var mcpOutputSchema = (0, import_provider_utils33.lazySchema)(
|
|
|
5664
5690
|
name: import_v425.z.string(),
|
|
5665
5691
|
arguments: import_v425.z.string(),
|
|
5666
5692
|
output: import_v425.z.string().nullish(),
|
|
5667
|
-
error: import_v425.z.union([import_v425.z.string(), jsonValueSchema2]).optional()
|
|
5693
|
+
error: import_v425.z.union([import_v425.z.string(), jsonValueSchema2()]).optional()
|
|
5668
5694
|
})
|
|
5669
5695
|
)
|
|
5670
5696
|
);
|
|
@@ -5728,9 +5754,10 @@ async function prepareResponsesTools({
|
|
|
5728
5754
|
allowedTools,
|
|
5729
5755
|
toolNameMapping,
|
|
5730
5756
|
customProviderToolNames,
|
|
5731
|
-
supportsAsyncToolCalling = true
|
|
5757
|
+
supportsAsyncToolCalling = true,
|
|
5758
|
+
providerOptionsName = "openai"
|
|
5732
5759
|
}) {
|
|
5733
|
-
var _a2, _b, _c, _d;
|
|
5760
|
+
var _a2, _b, _c, _d, _e, _f;
|
|
5734
5761
|
tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
|
|
5735
5762
|
const toolWarnings = [];
|
|
5736
5763
|
if (tools == null) {
|
|
@@ -5756,7 +5783,7 @@ async function prepareResponsesTools({
|
|
|
5756
5783
|
for (const tool of tools) {
|
|
5757
5784
|
switch (tool.type) {
|
|
5758
5785
|
case "function": {
|
|
5759
|
-
const openaiOptions = (_a2 = tool.providerOptions) == null ? void 0 : _a2.openai;
|
|
5786
|
+
const openaiOptions = (_c = (_a2 = tool.providerOptions) == null ? void 0 : _a2[providerOptionsName]) != null ? _c : (_b = tool.providerOptions) == null ? void 0 : _b.openai;
|
|
5760
5787
|
const openaiFunctionTool = prepareFunctionTool({
|
|
5761
5788
|
tool,
|
|
5762
5789
|
options: openaiOptions,
|
|
@@ -6020,7 +6047,7 @@ async function prepareResponsesTools({
|
|
|
6020
6047
|
});
|
|
6021
6048
|
allowedToolEntries.push({
|
|
6022
6049
|
type: "function",
|
|
6023
|
-
name: (
|
|
6050
|
+
name: (_d = toolNameMapping == null ? void 0 : toolNameMapping.toProviderToolName(name)) != null ? _d : name
|
|
6024
6051
|
});
|
|
6025
6052
|
continue;
|
|
6026
6053
|
}
|
|
@@ -6046,7 +6073,7 @@ async function prepareResponsesTools({
|
|
|
6046
6073
|
tools: openaiTools,
|
|
6047
6074
|
toolChoice: {
|
|
6048
6075
|
type: "allowed_tools",
|
|
6049
|
-
mode: (
|
|
6076
|
+
mode: (_e = allowedTools.mode) != null ? _e : "auto",
|
|
6050
6077
|
tools: allowedToolEntries
|
|
6051
6078
|
},
|
|
6052
6079
|
toolWarnings
|
|
@@ -6062,7 +6089,7 @@ async function prepareResponsesTools({
|
|
|
6062
6089
|
case "required":
|
|
6063
6090
|
return { tools: openaiTools, toolChoice: type, toolWarnings };
|
|
6064
6091
|
case "tool": {
|
|
6065
|
-
const resolvedToolName = (
|
|
6092
|
+
const resolvedToolName = (_f = toolNameMapping == null ? void 0 : toolNameMapping.toProviderToolName(toolChoice.toolName)) != null ? _f : toolChoice.toolName;
|
|
6066
6093
|
return {
|
|
6067
6094
|
tools: openaiTools,
|
|
6068
6095
|
toolChoice: resolvedToolName === "code_interpreter" || resolvedToolName === "file_search" || resolvedToolName === "image_generation" || resolvedToolName === "web_search_preview" || resolvedToolName === "web_search" || resolvedToolName === "mcp" || resolvedToolName === "apply_patch" ? { type: resolvedToolName } : resolvedCustomProviderToolNames.has(resolvedToolName) ? { type: "custom", name: resolvedToolName } : { type: "function", name: resolvedToolName },
|
|
@@ -6334,7 +6361,8 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
6334
6361
|
allowedTools: (_b = openaiOptions == null ? void 0 : openaiOptions.allowedTools) != null ? _b : void 0,
|
|
6335
6362
|
toolNameMapping,
|
|
6336
6363
|
customProviderToolNames,
|
|
6337
|
-
supportsAsyncToolCalling: modelCapabilities.supportsAsyncToolCalling
|
|
6364
|
+
supportsAsyncToolCalling: modelCapabilities.supportsAsyncToolCalling,
|
|
6365
|
+
providerOptionsName
|
|
6338
6366
|
});
|
|
6339
6367
|
const configurationUpdateUnsupportedReason = getConfigurationUpdateUnsupportedReason({
|
|
6340
6368
|
modelCapabilities,
|
|
@@ -8253,6 +8281,10 @@ function escapeJSONDelta(delta) {
|
|
|
8253
8281
|
openaiLanguageModelChatOptions,
|
|
8254
8282
|
openaiLanguageModelCompletionOptions,
|
|
8255
8283
|
openaiSpeechModelOptionsSchema,
|
|
8284
|
+
toolSearch,
|
|
8285
|
+
toolSearchArgsSchema,
|
|
8286
|
+
toolSearchInputSchema,
|
|
8287
|
+
toolSearchOutputSchema,
|
|
8256
8288
|
webSearch,
|
|
8257
8289
|
webSearchArgsSchema,
|
|
8258
8290
|
webSearchOutputSchema,
|