@ai-sdk/openai 3.0.0-beta.109 → 3.0.0-beta.110
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 +9 -0
- package/dist/index.d.mts +5 -16
- package/dist/index.d.ts +5 -16
- package/dist/index.js +23 -117
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +23 -117
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +22 -116
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +22 -116
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @ai-sdk/openai
|
|
2
2
|
|
|
3
|
+
## 3.0.0-beta.110
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 2625a04: feat(openai); update spec for mcp approval
|
|
8
|
+
- Updated dependencies [2625a04]
|
|
9
|
+
- @ai-sdk/provider@3.0.0-beta.31
|
|
10
|
+
- @ai-sdk/provider-utils@4.0.0-beta.58
|
|
11
|
+
|
|
3
12
|
## 3.0.0-beta.109
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -417,6 +417,11 @@ declare const openaiTools: {
|
|
|
417
417
|
authorization?: string;
|
|
418
418
|
connectorId?: string;
|
|
419
419
|
headers?: Record<string, string>;
|
|
420
|
+
requireApproval?: "always" | "never" | {
|
|
421
|
+
never?: {
|
|
422
|
+
toolNames?: string[];
|
|
423
|
+
};
|
|
424
|
+
};
|
|
420
425
|
serverDescription?: string;
|
|
421
426
|
serverUrl?: string;
|
|
422
427
|
}) => _ai_sdk_provider_utils.Tool<{}, {
|
|
@@ -426,22 +431,6 @@ declare const openaiTools: {
|
|
|
426
431
|
arguments: string;
|
|
427
432
|
output?: string | null;
|
|
428
433
|
error?: _ai_sdk_provider.JSONValue;
|
|
429
|
-
} | {
|
|
430
|
-
type: "listTools";
|
|
431
|
-
serverLabel: string;
|
|
432
|
-
tools: Array<{
|
|
433
|
-
name: string;
|
|
434
|
-
description?: string;
|
|
435
|
-
inputSchema: unknown;
|
|
436
|
-
annotations?: unknown;
|
|
437
|
-
}>;
|
|
438
|
-
error?: _ai_sdk_provider.JSONValue;
|
|
439
|
-
} | {
|
|
440
|
-
type: "approvalRequest";
|
|
441
|
-
serverLabel: string;
|
|
442
|
-
name: string;
|
|
443
|
-
arguments: string;
|
|
444
|
-
approvalRequestId: string;
|
|
445
434
|
}>;
|
|
446
435
|
};
|
|
447
436
|
|
package/dist/index.d.ts
CHANGED
|
@@ -417,6 +417,11 @@ declare const openaiTools: {
|
|
|
417
417
|
authorization?: string;
|
|
418
418
|
connectorId?: string;
|
|
419
419
|
headers?: Record<string, string>;
|
|
420
|
+
requireApproval?: "always" | "never" | {
|
|
421
|
+
never?: {
|
|
422
|
+
toolNames?: string[];
|
|
423
|
+
};
|
|
424
|
+
};
|
|
420
425
|
serverDescription?: string;
|
|
421
426
|
serverUrl?: string;
|
|
422
427
|
}) => _ai_sdk_provider_utils.Tool<{}, {
|
|
@@ -426,22 +431,6 @@ declare const openaiTools: {
|
|
|
426
431
|
arguments: string;
|
|
427
432
|
output?: string | null;
|
|
428
433
|
error?: _ai_sdk_provider.JSONValue;
|
|
429
|
-
} | {
|
|
430
|
-
type: "listTools";
|
|
431
|
-
serverLabel: string;
|
|
432
|
-
tools: Array<{
|
|
433
|
-
name: string;
|
|
434
|
-
description?: string;
|
|
435
|
-
inputSchema: unknown;
|
|
436
|
-
annotations?: unknown;
|
|
437
|
-
}>;
|
|
438
|
-
error?: _ai_sdk_provider.JSONValue;
|
|
439
|
-
} | {
|
|
440
|
-
type: "approvalRequest";
|
|
441
|
-
serverLabel: string;
|
|
442
|
-
name: string;
|
|
443
|
-
arguments: string;
|
|
444
|
-
approvalRequestId: string;
|
|
445
434
|
}>;
|
|
446
435
|
};
|
|
447
436
|
|
package/dist/index.js
CHANGED
|
@@ -256,6 +256,9 @@ function convertToOpenAIChatMessages({
|
|
|
256
256
|
}
|
|
257
257
|
case "tool": {
|
|
258
258
|
for (const toolResponse of content) {
|
|
259
|
+
if (toolResponse.type === "tool-approval-response") {
|
|
260
|
+
continue;
|
|
261
|
+
}
|
|
259
262
|
const output = toolResponse.output;
|
|
260
263
|
let contentValue;
|
|
261
264
|
switch (output.type) {
|
|
@@ -2280,16 +2283,14 @@ var mcpArgsSchema = (0, import_provider_utils22.lazySchema)(
|
|
|
2280
2283
|
authorization: import_v417.z.string().optional(),
|
|
2281
2284
|
connectorId: import_v417.z.string().optional(),
|
|
2282
2285
|
headers: import_v417.z.record(import_v417.z.string(), import_v417.z.string()).optional(),
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
// ])
|
|
2292
|
-
// .optional(),
|
|
2286
|
+
requireApproval: import_v417.z.union([
|
|
2287
|
+
import_v417.z.enum(["always", "never"]),
|
|
2288
|
+
import_v417.z.object({
|
|
2289
|
+
never: import_v417.z.object({
|
|
2290
|
+
toolNames: import_v417.z.array(import_v417.z.string()).optional()
|
|
2291
|
+
}).optional()
|
|
2292
|
+
})
|
|
2293
|
+
]).optional(),
|
|
2293
2294
|
serverDescription: import_v417.z.string().optional(),
|
|
2294
2295
|
serverUrl: import_v417.z.string().optional()
|
|
2295
2296
|
}).refine(
|
|
@@ -2301,36 +2302,14 @@ var mcpArgsSchema = (0, import_provider_utils22.lazySchema)(
|
|
|
2301
2302
|
var mcpInputSchema = (0, import_provider_utils22.lazySchema)(() => (0, import_provider_utils22.zodSchema)(import_v417.z.object({})));
|
|
2302
2303
|
var mcpOutputSchema = (0, import_provider_utils22.lazySchema)(
|
|
2303
2304
|
() => (0, import_provider_utils22.zodSchema)(
|
|
2304
|
-
import_v417.z.
|
|
2305
|
-
import_v417.z.
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
}),
|
|
2313
|
-
import_v417.z.object({
|
|
2314
|
-
type: import_v417.z.literal("listTools"),
|
|
2315
|
-
serverLabel: import_v417.z.string(),
|
|
2316
|
-
tools: import_v417.z.array(
|
|
2317
|
-
import_v417.z.object({
|
|
2318
|
-
name: import_v417.z.string(),
|
|
2319
|
-
description: import_v417.z.string().optional(),
|
|
2320
|
-
inputSchema: jsonValueSchema,
|
|
2321
|
-
annotations: import_v417.z.record(import_v417.z.string(), jsonValueSchema).optional()
|
|
2322
|
-
})
|
|
2323
|
-
),
|
|
2324
|
-
error: import_v417.z.union([import_v417.z.string(), jsonValueSchema]).optional()
|
|
2325
|
-
}),
|
|
2326
|
-
import_v417.z.object({
|
|
2327
|
-
type: import_v417.z.literal("approvalRequest"),
|
|
2328
|
-
serverLabel: import_v417.z.string(),
|
|
2329
|
-
name: import_v417.z.string(),
|
|
2330
|
-
arguments: import_v417.z.string(),
|
|
2331
|
-
approvalRequestId: import_v417.z.string()
|
|
2332
|
-
})
|
|
2333
|
-
])
|
|
2305
|
+
import_v417.z.object({
|
|
2306
|
+
type: import_v417.z.literal("call"),
|
|
2307
|
+
serverLabel: import_v417.z.string(),
|
|
2308
|
+
name: import_v417.z.string(),
|
|
2309
|
+
arguments: import_v417.z.string(),
|
|
2310
|
+
output: import_v417.z.string().nullable().optional(),
|
|
2311
|
+
error: import_v417.z.union([import_v417.z.string(), jsonValueSchema]).optional()
|
|
2312
|
+
})
|
|
2334
2313
|
)
|
|
2335
2314
|
);
|
|
2336
2315
|
var mcpToolFactory = (0, import_provider_utils22.createProviderToolFactoryWithOutputSchema)({
|
|
@@ -2722,6 +2701,9 @@ async function convertToOpenAIResponsesInput({
|
|
|
2722
2701
|
}
|
|
2723
2702
|
case "tool": {
|
|
2724
2703
|
for (const part of content) {
|
|
2704
|
+
if (part.type === "tool-approval-response") {
|
|
2705
|
+
continue;
|
|
2706
|
+
}
|
|
2725
2707
|
const output = part.output;
|
|
2726
2708
|
const resolvedToolName = toolNameMapping.toProviderToolName(
|
|
2727
2709
|
part.toolName
|
|
@@ -4416,54 +4398,9 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4416
4398
|
break;
|
|
4417
4399
|
}
|
|
4418
4400
|
case "mcp_list_tools": {
|
|
4419
|
-
content.push({
|
|
4420
|
-
type: "tool-call",
|
|
4421
|
-
toolCallId: part.id,
|
|
4422
|
-
toolName: toolNameMapping.toCustomToolName("mcp"),
|
|
4423
|
-
input: JSON.stringify({}),
|
|
4424
|
-
providerExecuted: true
|
|
4425
|
-
});
|
|
4426
|
-
content.push({
|
|
4427
|
-
type: "tool-result",
|
|
4428
|
-
toolCallId: part.id,
|
|
4429
|
-
toolName: toolNameMapping.toCustomToolName("mcp"),
|
|
4430
|
-
result: {
|
|
4431
|
-
type: "listTools",
|
|
4432
|
-
serverLabel: part.server_label,
|
|
4433
|
-
tools: part.tools.map((t) => {
|
|
4434
|
-
var _a2, _b2;
|
|
4435
|
-
return {
|
|
4436
|
-
name: t.name,
|
|
4437
|
-
description: (_a2 = t.description) != null ? _a2 : void 0,
|
|
4438
|
-
inputSchema: t.input_schema,
|
|
4439
|
-
annotations: (_b2 = t.annotations) != null ? _b2 : void 0
|
|
4440
|
-
};
|
|
4441
|
-
}),
|
|
4442
|
-
...part.error != null ? { error: part.error } : {}
|
|
4443
|
-
}
|
|
4444
|
-
});
|
|
4445
4401
|
break;
|
|
4446
4402
|
}
|
|
4447
4403
|
case "mcp_approval_request": {
|
|
4448
|
-
content.push({
|
|
4449
|
-
type: "tool-call",
|
|
4450
|
-
toolCallId: part.id,
|
|
4451
|
-
toolName: toolNameMapping.toCustomToolName("mcp"),
|
|
4452
|
-
input: JSON.stringify({}),
|
|
4453
|
-
providerExecuted: true
|
|
4454
|
-
});
|
|
4455
|
-
content.push({
|
|
4456
|
-
type: "tool-result",
|
|
4457
|
-
toolCallId: part.id,
|
|
4458
|
-
toolName: toolNameMapping.toCustomToolName("mcp"),
|
|
4459
|
-
result: {
|
|
4460
|
-
type: "approvalRequest",
|
|
4461
|
-
serverLabel: part.server_label,
|
|
4462
|
-
name: part.name,
|
|
4463
|
-
arguments: part.arguments,
|
|
4464
|
-
approvalRequestId: part.approval_request_id
|
|
4465
|
-
}
|
|
4466
|
-
});
|
|
4467
4404
|
break;
|
|
4468
4405
|
}
|
|
4469
4406
|
case "computer_call": {
|
|
@@ -4901,25 +4838,6 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4901
4838
|
});
|
|
4902
4839
|
} else if (value.item.type === "mcp_list_tools") {
|
|
4903
4840
|
ongoingToolCalls[value.output_index] = void 0;
|
|
4904
|
-
controller.enqueue({
|
|
4905
|
-
type: "tool-result",
|
|
4906
|
-
toolCallId: value.item.id,
|
|
4907
|
-
toolName: toolNameMapping.toCustomToolName("mcp"),
|
|
4908
|
-
result: {
|
|
4909
|
-
type: "listTools",
|
|
4910
|
-
serverLabel: value.item.server_label,
|
|
4911
|
-
tools: value.item.tools.map((t) => {
|
|
4912
|
-
var _a2, _b2;
|
|
4913
|
-
return {
|
|
4914
|
-
name: t.name,
|
|
4915
|
-
description: (_a2 = t.description) != null ? _a2 : void 0,
|
|
4916
|
-
inputSchema: t.input_schema,
|
|
4917
|
-
annotations: (_b2 = t.annotations) != null ? _b2 : void 0
|
|
4918
|
-
};
|
|
4919
|
-
}),
|
|
4920
|
-
...value.item.error != null ? { error: value.item.error } : {}
|
|
4921
|
-
}
|
|
4922
|
-
});
|
|
4923
4841
|
} else if (value.item.type === "apply_patch_call") {
|
|
4924
4842
|
ongoingToolCalls[value.output_index] = void 0;
|
|
4925
4843
|
if (value.item.status === "completed") {
|
|
@@ -4940,18 +4858,6 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4940
4858
|
}
|
|
4941
4859
|
} else if (value.item.type === "mcp_approval_request") {
|
|
4942
4860
|
ongoingToolCalls[value.output_index] = void 0;
|
|
4943
|
-
controller.enqueue({
|
|
4944
|
-
type: "tool-result",
|
|
4945
|
-
toolCallId: value.item.id,
|
|
4946
|
-
toolName: toolNameMapping.toCustomToolName("mcp"),
|
|
4947
|
-
result: {
|
|
4948
|
-
type: "approvalRequest",
|
|
4949
|
-
serverLabel: value.item.server_label,
|
|
4950
|
-
name: value.item.name,
|
|
4951
|
-
arguments: value.item.arguments,
|
|
4952
|
-
approvalRequestId: value.item.approval_request_id
|
|
4953
|
-
}
|
|
4954
|
-
});
|
|
4955
4861
|
} else if (value.item.type === "local_shell_call") {
|
|
4956
4862
|
ongoingToolCalls[value.output_index] = void 0;
|
|
4957
4863
|
controller.enqueue({
|
|
@@ -5639,7 +5545,7 @@ var OpenAITranscriptionModel = class {
|
|
|
5639
5545
|
};
|
|
5640
5546
|
|
|
5641
5547
|
// src/version.ts
|
|
5642
|
-
var VERSION = true ? "3.0.0-beta.
|
|
5548
|
+
var VERSION = true ? "3.0.0-beta.110" : "0.0.0-test";
|
|
5643
5549
|
|
|
5644
5550
|
// src/openai-provider.ts
|
|
5645
5551
|
function createOpenAI(options = {}) {
|