@ai-sdk/openai 3.0.61 → 3.0.62
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 +6 -0
- package/dist/index.d.mts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +46 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +46 -13
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +45 -12
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +45 -12
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/responses/openai-responses-language-model.ts +1 -0
- package/src/responses/openai-responses-options.ts +17 -0
- package/src/responses/openai-responses-prepare-tools.ts +26 -1
package/CHANGELOG.md
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -1058,6 +1058,10 @@ declare const openaiLanguageModelResponsesOptionsSchema: _ai_sdk_provider_utils.
|
|
|
1058
1058
|
user?: string | null | undefined;
|
|
1059
1059
|
systemMessageMode?: "remove" | "system" | "developer" | undefined;
|
|
1060
1060
|
forceReasoning?: boolean | undefined;
|
|
1061
|
+
allowedTools?: {
|
|
1062
|
+
toolNames: string[];
|
|
1063
|
+
mode?: "auto" | "required" | undefined;
|
|
1064
|
+
} | undefined;
|
|
1061
1065
|
}>;
|
|
1062
1066
|
type OpenAILanguageModelResponsesOptions = InferSchema<typeof openaiLanguageModelResponsesOptionsSchema>;
|
|
1063
1067
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1058,6 +1058,10 @@ declare const openaiLanguageModelResponsesOptionsSchema: _ai_sdk_provider_utils.
|
|
|
1058
1058
|
user?: string | null | undefined;
|
|
1059
1059
|
systemMessageMode?: "remove" | "system" | "developer" | undefined;
|
|
1060
1060
|
forceReasoning?: boolean | undefined;
|
|
1061
|
+
allowedTools?: {
|
|
1062
|
+
toolNames: string[];
|
|
1063
|
+
mode?: "auto" | "required" | undefined;
|
|
1064
|
+
} | undefined;
|
|
1061
1065
|
}>;
|
|
1062
1066
|
type OpenAILanguageModelResponsesOptions = InferSchema<typeof openaiLanguageModelResponsesOptionsSchema>;
|
|
1063
1067
|
|
package/dist/index.js
CHANGED
|
@@ -4425,7 +4425,21 @@ var openaiLanguageModelResponsesOptionsSchema = (0, import_provider_utils28.lazy
|
|
|
4425
4425
|
* When enabled, the SDK applies reasoning-model parameter compatibility rules
|
|
4426
4426
|
* and defaults `systemMessageMode` to `developer` unless overridden.
|
|
4427
4427
|
*/
|
|
4428
|
-
forceReasoning: import_v423.z.boolean().optional()
|
|
4428
|
+
forceReasoning: import_v423.z.boolean().optional(),
|
|
4429
|
+
/**
|
|
4430
|
+
* Restrict the callable tools to a subset while keeping the full tools
|
|
4431
|
+
* list intact, so prompt caching is preserved across requests with
|
|
4432
|
+
* different allowlists.
|
|
4433
|
+
*
|
|
4434
|
+
* When set, this overrides the request-level `toolChoice` and emits
|
|
4435
|
+
* `tool_choice: { type: "allowed_tools", mode, tools }` on the wire.
|
|
4436
|
+
*
|
|
4437
|
+
* @see https://developers.openai.com/api/reference/resources/responses/methods/create#(resource)%20responses%20%3E%20(model)%20tool_choice_allowed%20%3E%20(schema)
|
|
4438
|
+
*/
|
|
4439
|
+
allowedTools: import_v423.z.object({
|
|
4440
|
+
toolNames: import_v423.z.array(import_v423.z.string()).min(1),
|
|
4441
|
+
mode: import_v423.z.enum(["auto", "required"]).optional()
|
|
4442
|
+
}).optional()
|
|
4429
4443
|
})
|
|
4430
4444
|
)
|
|
4431
4445
|
);
|
|
@@ -4436,10 +4450,11 @@ var import_provider_utils29 = require("@ai-sdk/provider-utils");
|
|
|
4436
4450
|
async function prepareResponsesTools({
|
|
4437
4451
|
tools,
|
|
4438
4452
|
toolChoice,
|
|
4453
|
+
allowedTools,
|
|
4439
4454
|
toolNameMapping,
|
|
4440
4455
|
customProviderToolNames
|
|
4441
4456
|
}) {
|
|
4442
|
-
var _a, _b;
|
|
4457
|
+
var _a, _b, _c;
|
|
4443
4458
|
tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
|
|
4444
4459
|
const toolWarnings = [];
|
|
4445
4460
|
if (tools == null) {
|
|
@@ -4630,6 +4645,23 @@ async function prepareResponsesTools({
|
|
|
4630
4645
|
break;
|
|
4631
4646
|
}
|
|
4632
4647
|
}
|
|
4648
|
+
if (allowedTools != null) {
|
|
4649
|
+
return {
|
|
4650
|
+
tools: openaiTools2,
|
|
4651
|
+
toolChoice: {
|
|
4652
|
+
type: "allowed_tools",
|
|
4653
|
+
mode: (_b = allowedTools.mode) != null ? _b : "auto",
|
|
4654
|
+
tools: allowedTools.toolNames.map((name) => {
|
|
4655
|
+
var _a2;
|
|
4656
|
+
return {
|
|
4657
|
+
type: "function",
|
|
4658
|
+
name: (_a2 = toolNameMapping == null ? void 0 : toolNameMapping.toProviderToolName(name)) != null ? _a2 : name
|
|
4659
|
+
};
|
|
4660
|
+
})
|
|
4661
|
+
},
|
|
4662
|
+
toolWarnings
|
|
4663
|
+
};
|
|
4664
|
+
}
|
|
4633
4665
|
if (toolChoice == null) {
|
|
4634
4666
|
return { tools: openaiTools2, toolChoice: void 0, toolWarnings };
|
|
4635
4667
|
}
|
|
@@ -4640,7 +4672,7 @@ async function prepareResponsesTools({
|
|
|
4640
4672
|
case "required":
|
|
4641
4673
|
return { tools: openaiTools2, toolChoice: type, toolWarnings };
|
|
4642
4674
|
case "tool": {
|
|
4643
|
-
const resolvedToolName = (
|
|
4675
|
+
const resolvedToolName = (_c = toolNameMapping == null ? void 0 : toolNameMapping.toProviderToolName(toolChoice.toolName)) != null ? _c : toolChoice.toolName;
|
|
4644
4676
|
return {
|
|
4645
4677
|
tools: openaiTools2,
|
|
4646
4678
|
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 },
|
|
@@ -4746,7 +4778,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4746
4778
|
toolChoice,
|
|
4747
4779
|
responseFormat
|
|
4748
4780
|
}) {
|
|
4749
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
4781
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
4750
4782
|
const warnings = [];
|
|
4751
4783
|
const modelCapabilities = getOpenAILanguageModelCapabilities(this.modelId);
|
|
4752
4784
|
if (topK != null) {
|
|
@@ -4809,16 +4841,17 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4809
4841
|
} = await prepareResponsesTools({
|
|
4810
4842
|
tools,
|
|
4811
4843
|
toolChoice,
|
|
4844
|
+
allowedTools: (_b = openaiOptions == null ? void 0 : openaiOptions.allowedTools) != null ? _b : void 0,
|
|
4812
4845
|
toolNameMapping,
|
|
4813
4846
|
customProviderToolNames
|
|
4814
4847
|
});
|
|
4815
4848
|
const { input, warnings: inputWarnings } = await convertToOpenAIResponsesInput({
|
|
4816
4849
|
prompt,
|
|
4817
4850
|
toolNameMapping,
|
|
4818
|
-
systemMessageMode: (
|
|
4851
|
+
systemMessageMode: (_c = openaiOptions == null ? void 0 : openaiOptions.systemMessageMode) != null ? _c : isReasoningModel ? "developer" : modelCapabilities.systemMessageMode,
|
|
4819
4852
|
providerOptionsName,
|
|
4820
4853
|
fileIdPrefixes: this.config.fileIdPrefixes,
|
|
4821
|
-
store: (
|
|
4854
|
+
store: (_d = openaiOptions == null ? void 0 : openaiOptions.store) != null ? _d : true,
|
|
4822
4855
|
hasConversation: (openaiOptions == null ? void 0 : openaiOptions.conversation) != null,
|
|
4823
4856
|
hasLocalShellTool: hasOpenAITool("openai.local_shell"),
|
|
4824
4857
|
hasShellTool: hasOpenAITool("openai.shell"),
|
|
@@ -4826,7 +4859,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4826
4859
|
customProviderToolNames: customProviderToolNames.size > 0 ? customProviderToolNames : void 0
|
|
4827
4860
|
});
|
|
4828
4861
|
warnings.push(...inputWarnings);
|
|
4829
|
-
const strictJsonSchema = (
|
|
4862
|
+
const strictJsonSchema = (_e = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _e : true;
|
|
4830
4863
|
let include = openaiOptions == null ? void 0 : openaiOptions.include;
|
|
4831
4864
|
function addInclude(key) {
|
|
4832
4865
|
if (include == null) {
|
|
@@ -4842,9 +4875,9 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4842
4875
|
if (topLogprobs) {
|
|
4843
4876
|
addInclude("message.output_text.logprobs");
|
|
4844
4877
|
}
|
|
4845
|
-
const webSearchToolName = (
|
|
4878
|
+
const webSearchToolName = (_f = tools == null ? void 0 : tools.find(
|
|
4846
4879
|
(tool) => tool.type === "provider" && (tool.id === "openai.web_search" || tool.id === "openai.web_search_preview")
|
|
4847
|
-
)) == null ? void 0 :
|
|
4880
|
+
)) == null ? void 0 : _f.name;
|
|
4848
4881
|
if (webSearchToolName) {
|
|
4849
4882
|
addInclude("web_search_call.action.sources");
|
|
4850
4883
|
}
|
|
@@ -4867,7 +4900,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4867
4900
|
format: responseFormat.schema != null ? {
|
|
4868
4901
|
type: "json_schema",
|
|
4869
4902
|
strict: strictJsonSchema,
|
|
4870
|
-
name: (
|
|
4903
|
+
name: (_g = responseFormat.name) != null ? _g : "response",
|
|
4871
4904
|
description: responseFormat.description,
|
|
4872
4905
|
schema: responseFormat.schema
|
|
4873
4906
|
} : { type: "json_object" }
|
|
@@ -4956,9 +4989,9 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4956
4989
|
});
|
|
4957
4990
|
delete baseArgs.service_tier;
|
|
4958
4991
|
}
|
|
4959
|
-
const shellToolEnvType = (
|
|
4992
|
+
const shellToolEnvType = (_j = (_i = (_h = tools == null ? void 0 : tools.find(
|
|
4960
4993
|
(tool) => tool.type === "provider" && tool.id === "openai.shell"
|
|
4961
|
-
)) == null ? void 0 :
|
|
4994
|
+
)) == null ? void 0 : _h.args) == null ? void 0 : _i.environment) == null ? void 0 : _j.type;
|
|
4962
4995
|
const isShellProviderExecuted = shellToolEnvType === "containerAuto" || shellToolEnvType === "containerReference";
|
|
4963
4996
|
return {
|
|
4964
4997
|
webSearchToolName,
|
|
@@ -6757,7 +6790,7 @@ var OpenAITranscriptionModel = class {
|
|
|
6757
6790
|
};
|
|
6758
6791
|
|
|
6759
6792
|
// src/version.ts
|
|
6760
|
-
var VERSION = true ? "3.0.
|
|
6793
|
+
var VERSION = true ? "3.0.62" : "0.0.0-test";
|
|
6761
6794
|
|
|
6762
6795
|
// src/openai-provider.ts
|
|
6763
6796
|
function createOpenAI(options = {}) {
|