@ai-sdk/openai 3.0.0-beta.53 → 3.0.0-beta.55
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 +12 -0
- package/dist/index.d.mts +51 -0
- package/dist/index.d.ts +51 -0
- package/dist/index.js +851 -476
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +809 -430
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +383 -25
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +365 -3
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +4 -3
package/dist/internal/index.js
CHANGED
|
@@ -2102,7 +2102,7 @@ var OpenAISpeechModel = class {
|
|
|
2102
2102
|
|
|
2103
2103
|
// src/responses/openai-responses-language-model.ts
|
|
2104
2104
|
var import_provider8 = require("@ai-sdk/provider");
|
|
2105
|
-
var
|
|
2105
|
+
var import_provider_utils30 = require("@ai-sdk/provider-utils");
|
|
2106
2106
|
|
|
2107
2107
|
// src/responses/convert-to-openai-responses-input.ts
|
|
2108
2108
|
var import_provider6 = require("@ai-sdk/provider");
|
|
@@ -2543,6 +2543,19 @@ var openaiResponsesChunkSchema = (0, import_provider_utils21.lazySchema)(
|
|
|
2543
2543
|
])
|
|
2544
2544
|
).nullable(),
|
|
2545
2545
|
status: import_v414.z.string()
|
|
2546
|
+
}),
|
|
2547
|
+
import_v414.z.object({
|
|
2548
|
+
type: import_v414.z.literal("mcp_call"),
|
|
2549
|
+
id: import_v414.z.string(),
|
|
2550
|
+
status: import_v414.z.string()
|
|
2551
|
+
}),
|
|
2552
|
+
import_v414.z.object({
|
|
2553
|
+
type: import_v414.z.literal("mcp_list_tools"),
|
|
2554
|
+
id: import_v414.z.string()
|
|
2555
|
+
}),
|
|
2556
|
+
import_v414.z.object({
|
|
2557
|
+
type: import_v414.z.literal("mcp_approval_request"),
|
|
2558
|
+
id: import_v414.z.string()
|
|
2546
2559
|
})
|
|
2547
2560
|
])
|
|
2548
2561
|
}),
|
|
@@ -2644,6 +2657,52 @@ var openaiResponsesChunkSchema = (0, import_provider_utils21.lazySchema)(
|
|
|
2644
2657
|
type: import_v414.z.literal("computer_call"),
|
|
2645
2658
|
id: import_v414.z.string(),
|
|
2646
2659
|
status: import_v414.z.literal("completed")
|
|
2660
|
+
}),
|
|
2661
|
+
import_v414.z.object({
|
|
2662
|
+
type: import_v414.z.literal("mcp_call"),
|
|
2663
|
+
id: import_v414.z.string(),
|
|
2664
|
+
status: import_v414.z.string(),
|
|
2665
|
+
arguments: import_v414.z.string(),
|
|
2666
|
+
name: import_v414.z.string(),
|
|
2667
|
+
server_label: import_v414.z.string(),
|
|
2668
|
+
output: import_v414.z.string().nullish(),
|
|
2669
|
+
error: import_v414.z.union([
|
|
2670
|
+
import_v414.z.string(),
|
|
2671
|
+
import_v414.z.object({
|
|
2672
|
+
type: import_v414.z.string().optional(),
|
|
2673
|
+
code: import_v414.z.union([import_v414.z.number(), import_v414.z.string()]).optional(),
|
|
2674
|
+
message: import_v414.z.string().optional()
|
|
2675
|
+
}).loose()
|
|
2676
|
+
]).nullish()
|
|
2677
|
+
}),
|
|
2678
|
+
import_v414.z.object({
|
|
2679
|
+
type: import_v414.z.literal("mcp_list_tools"),
|
|
2680
|
+
id: import_v414.z.string(),
|
|
2681
|
+
server_label: import_v414.z.string(),
|
|
2682
|
+
tools: import_v414.z.array(
|
|
2683
|
+
import_v414.z.object({
|
|
2684
|
+
name: import_v414.z.string(),
|
|
2685
|
+
description: import_v414.z.string().optional(),
|
|
2686
|
+
input_schema: import_v414.z.any(),
|
|
2687
|
+
annotations: import_v414.z.record(import_v414.z.string(), import_v414.z.unknown()).optional()
|
|
2688
|
+
})
|
|
2689
|
+
),
|
|
2690
|
+
error: import_v414.z.union([
|
|
2691
|
+
import_v414.z.string(),
|
|
2692
|
+
import_v414.z.object({
|
|
2693
|
+
type: import_v414.z.string().optional(),
|
|
2694
|
+
code: import_v414.z.union([import_v414.z.number(), import_v414.z.string()]).optional(),
|
|
2695
|
+
message: import_v414.z.string().optional()
|
|
2696
|
+
}).loose()
|
|
2697
|
+
]).optional()
|
|
2698
|
+
}),
|
|
2699
|
+
import_v414.z.object({
|
|
2700
|
+
type: import_v414.z.literal("mcp_approval_request"),
|
|
2701
|
+
id: import_v414.z.string(),
|
|
2702
|
+
server_label: import_v414.z.string(),
|
|
2703
|
+
name: import_v414.z.string(),
|
|
2704
|
+
arguments: import_v414.z.string(),
|
|
2705
|
+
approval_request_id: import_v414.z.string()
|
|
2647
2706
|
})
|
|
2648
2707
|
])
|
|
2649
2708
|
}),
|
|
@@ -2899,6 +2958,52 @@ var openaiResponsesResponseSchema = (0, import_provider_utils21.lazySchema)(
|
|
|
2899
2958
|
text: import_v414.z.string()
|
|
2900
2959
|
})
|
|
2901
2960
|
)
|
|
2961
|
+
}),
|
|
2962
|
+
import_v414.z.object({
|
|
2963
|
+
type: import_v414.z.literal("mcp_call"),
|
|
2964
|
+
id: import_v414.z.string(),
|
|
2965
|
+
status: import_v414.z.string(),
|
|
2966
|
+
arguments: import_v414.z.string(),
|
|
2967
|
+
name: import_v414.z.string(),
|
|
2968
|
+
server_label: import_v414.z.string(),
|
|
2969
|
+
output: import_v414.z.string().nullish(),
|
|
2970
|
+
error: import_v414.z.union([
|
|
2971
|
+
import_v414.z.string(),
|
|
2972
|
+
import_v414.z.object({
|
|
2973
|
+
type: import_v414.z.string().optional(),
|
|
2974
|
+
code: import_v414.z.union([import_v414.z.number(), import_v414.z.string()]).optional(),
|
|
2975
|
+
message: import_v414.z.string().optional()
|
|
2976
|
+
}).loose()
|
|
2977
|
+
]).nullish()
|
|
2978
|
+
}),
|
|
2979
|
+
import_v414.z.object({
|
|
2980
|
+
type: import_v414.z.literal("mcp_list_tools"),
|
|
2981
|
+
id: import_v414.z.string(),
|
|
2982
|
+
server_label: import_v414.z.string(),
|
|
2983
|
+
tools: import_v414.z.array(
|
|
2984
|
+
import_v414.z.object({
|
|
2985
|
+
name: import_v414.z.string(),
|
|
2986
|
+
description: import_v414.z.string().optional(),
|
|
2987
|
+
input_schema: import_v414.z.any(),
|
|
2988
|
+
annotations: import_v414.z.record(import_v414.z.string(), import_v414.z.unknown()).optional()
|
|
2989
|
+
})
|
|
2990
|
+
),
|
|
2991
|
+
error: import_v414.z.union([
|
|
2992
|
+
import_v414.z.string(),
|
|
2993
|
+
import_v414.z.object({
|
|
2994
|
+
type: import_v414.z.string().optional(),
|
|
2995
|
+
code: import_v414.z.union([import_v414.z.number(), import_v414.z.string()]).optional(),
|
|
2996
|
+
message: import_v414.z.string().optional()
|
|
2997
|
+
}).loose()
|
|
2998
|
+
]).optional()
|
|
2999
|
+
}),
|
|
3000
|
+
import_v414.z.object({
|
|
3001
|
+
type: import_v414.z.literal("mcp_approval_request"),
|
|
3002
|
+
id: import_v414.z.string(),
|
|
3003
|
+
server_label: import_v414.z.string(),
|
|
3004
|
+
name: import_v414.z.string(),
|
|
3005
|
+
arguments: import_v414.z.string(),
|
|
3006
|
+
approval_request_id: import_v414.z.string()
|
|
2902
3007
|
})
|
|
2903
3008
|
])
|
|
2904
3009
|
),
|
|
@@ -2921,12 +3026,16 @@ var TOP_LOGPROBS_MAX = 20;
|
|
|
2921
3026
|
var openaiResponsesReasoningModelIds = [
|
|
2922
3027
|
"o1",
|
|
2923
3028
|
"o1-2024-12-17",
|
|
2924
|
-
"o3-mini",
|
|
2925
|
-
"o3-mini-2025-01-31",
|
|
2926
3029
|
"o3",
|
|
2927
3030
|
"o3-2025-04-16",
|
|
3031
|
+
"o3-deep-research",
|
|
3032
|
+
"o3-deep-research-2025-06-26",
|
|
3033
|
+
"o3-mini",
|
|
3034
|
+
"o3-mini-2025-01-31",
|
|
2928
3035
|
"o4-mini",
|
|
2929
3036
|
"o4-mini-2025-04-16",
|
|
3037
|
+
"o4-mini-deep-research",
|
|
3038
|
+
"o4-mini-deep-research-2025-06-26",
|
|
2930
3039
|
"codex-mini-latest",
|
|
2931
3040
|
"computer-use-preview",
|
|
2932
3041
|
"gpt-5",
|
|
@@ -3258,8 +3367,95 @@ var imageGeneration = (args = {}) => {
|
|
|
3258
3367
|
return imageGenerationToolFactory(args);
|
|
3259
3368
|
};
|
|
3260
3369
|
|
|
3261
|
-
// src/
|
|
3370
|
+
// src/tool/mcp.ts
|
|
3262
3371
|
var import_provider_utils28 = require("@ai-sdk/provider-utils");
|
|
3372
|
+
var import_v421 = require("zod/v4");
|
|
3373
|
+
var jsonValueSchema = import_v421.z.lazy(
|
|
3374
|
+
() => import_v421.z.union([
|
|
3375
|
+
import_v421.z.string(),
|
|
3376
|
+
import_v421.z.number(),
|
|
3377
|
+
import_v421.z.boolean(),
|
|
3378
|
+
import_v421.z.null(),
|
|
3379
|
+
import_v421.z.array(jsonValueSchema),
|
|
3380
|
+
import_v421.z.record(import_v421.z.string(), jsonValueSchema)
|
|
3381
|
+
])
|
|
3382
|
+
);
|
|
3383
|
+
var mcpArgsSchema = (0, import_provider_utils28.lazySchema)(
|
|
3384
|
+
() => (0, import_provider_utils28.zodSchema)(
|
|
3385
|
+
import_v421.z.object({
|
|
3386
|
+
serverLabel: import_v421.z.string(),
|
|
3387
|
+
allowedTools: import_v421.z.union([
|
|
3388
|
+
import_v421.z.array(import_v421.z.string()),
|
|
3389
|
+
import_v421.z.object({
|
|
3390
|
+
readOnly: import_v421.z.boolean().optional(),
|
|
3391
|
+
toolNames: import_v421.z.array(import_v421.z.string()).optional()
|
|
3392
|
+
})
|
|
3393
|
+
]).optional(),
|
|
3394
|
+
authorization: import_v421.z.string().optional(),
|
|
3395
|
+
connectorId: import_v421.z.string().optional(),
|
|
3396
|
+
headers: import_v421.z.record(import_v421.z.string(), import_v421.z.string()).optional(),
|
|
3397
|
+
// TODO: Integrate this MCP tool approval with our SDK's existing tool approval architecture
|
|
3398
|
+
// requireApproval: z
|
|
3399
|
+
// .union([
|
|
3400
|
+
// z.enum(['always', 'never']),
|
|
3401
|
+
// z.object({
|
|
3402
|
+
// readOnly: z.boolean().optional(),
|
|
3403
|
+
// toolNames: z.array(z.string()).optional(),
|
|
3404
|
+
// }),
|
|
3405
|
+
// ])
|
|
3406
|
+
// .optional(),
|
|
3407
|
+
serverDescription: import_v421.z.string().optional(),
|
|
3408
|
+
serverUrl: import_v421.z.string().optional()
|
|
3409
|
+
}).refine(
|
|
3410
|
+
(v) => v.serverUrl != null || v.connectorId != null,
|
|
3411
|
+
"One of serverUrl or connectorId must be provided."
|
|
3412
|
+
)
|
|
3413
|
+
)
|
|
3414
|
+
);
|
|
3415
|
+
var mcpInputSchema = (0, import_provider_utils28.lazySchema)(() => (0, import_provider_utils28.zodSchema)(import_v421.z.object({})));
|
|
3416
|
+
var mcpOutputSchema = (0, import_provider_utils28.lazySchema)(
|
|
3417
|
+
() => (0, import_provider_utils28.zodSchema)(
|
|
3418
|
+
import_v421.z.discriminatedUnion("type", [
|
|
3419
|
+
import_v421.z.object({
|
|
3420
|
+
type: import_v421.z.literal("call"),
|
|
3421
|
+
serverLabel: import_v421.z.string(),
|
|
3422
|
+
name: import_v421.z.string(),
|
|
3423
|
+
arguments: import_v421.z.string(),
|
|
3424
|
+
output: import_v421.z.string().nullable().optional(),
|
|
3425
|
+
error: import_v421.z.union([import_v421.z.string(), jsonValueSchema]).optional()
|
|
3426
|
+
}),
|
|
3427
|
+
import_v421.z.object({
|
|
3428
|
+
type: import_v421.z.literal("listTools"),
|
|
3429
|
+
serverLabel: import_v421.z.string(),
|
|
3430
|
+
tools: import_v421.z.array(
|
|
3431
|
+
import_v421.z.object({
|
|
3432
|
+
name: import_v421.z.string(),
|
|
3433
|
+
description: import_v421.z.string().optional(),
|
|
3434
|
+
inputSchema: jsonValueSchema,
|
|
3435
|
+
annotations: import_v421.z.record(import_v421.z.string(), jsonValueSchema).optional()
|
|
3436
|
+
})
|
|
3437
|
+
),
|
|
3438
|
+
error: import_v421.z.union([import_v421.z.string(), jsonValueSchema]).optional()
|
|
3439
|
+
}),
|
|
3440
|
+
import_v421.z.object({
|
|
3441
|
+
type: import_v421.z.literal("approvalRequest"),
|
|
3442
|
+
serverLabel: import_v421.z.string(),
|
|
3443
|
+
name: import_v421.z.string(),
|
|
3444
|
+
arguments: import_v421.z.string(),
|
|
3445
|
+
approvalRequestId: import_v421.z.string()
|
|
3446
|
+
})
|
|
3447
|
+
])
|
|
3448
|
+
)
|
|
3449
|
+
);
|
|
3450
|
+
var mcpToolFactory = (0, import_provider_utils28.createProviderDefinedToolFactoryWithOutputSchema)({
|
|
3451
|
+
id: "openai.mcp",
|
|
3452
|
+
name: "mcp",
|
|
3453
|
+
inputSchema: mcpInputSchema,
|
|
3454
|
+
outputSchema: mcpOutputSchema
|
|
3455
|
+
});
|
|
3456
|
+
|
|
3457
|
+
// src/responses/openai-responses-prepare-tools.ts
|
|
3458
|
+
var import_provider_utils29 = require("@ai-sdk/provider-utils");
|
|
3263
3459
|
async function prepareResponsesTools({
|
|
3264
3460
|
tools,
|
|
3265
3461
|
toolChoice,
|
|
@@ -3285,7 +3481,7 @@ async function prepareResponsesTools({
|
|
|
3285
3481
|
case "provider-defined": {
|
|
3286
3482
|
switch (tool.id) {
|
|
3287
3483
|
case "openai.file_search": {
|
|
3288
|
-
const args = await (0,
|
|
3484
|
+
const args = await (0, import_provider_utils29.validateTypes)({
|
|
3289
3485
|
value: tool.args,
|
|
3290
3486
|
schema: fileSearchArgsSchema
|
|
3291
3487
|
});
|
|
@@ -3308,7 +3504,7 @@ async function prepareResponsesTools({
|
|
|
3308
3504
|
break;
|
|
3309
3505
|
}
|
|
3310
3506
|
case "openai.web_search_preview": {
|
|
3311
|
-
const args = await (0,
|
|
3507
|
+
const args = await (0, import_provider_utils29.validateTypes)({
|
|
3312
3508
|
value: tool.args,
|
|
3313
3509
|
schema: webSearchPreviewArgsSchema
|
|
3314
3510
|
});
|
|
@@ -3320,7 +3516,7 @@ async function prepareResponsesTools({
|
|
|
3320
3516
|
break;
|
|
3321
3517
|
}
|
|
3322
3518
|
case "openai.web_search": {
|
|
3323
|
-
const args = await (0,
|
|
3519
|
+
const args = await (0, import_provider_utils29.validateTypes)({
|
|
3324
3520
|
value: tool.args,
|
|
3325
3521
|
schema: webSearchArgsSchema
|
|
3326
3522
|
});
|
|
@@ -3333,7 +3529,7 @@ async function prepareResponsesTools({
|
|
|
3333
3529
|
break;
|
|
3334
3530
|
}
|
|
3335
3531
|
case "openai.code_interpreter": {
|
|
3336
|
-
const args = await (0,
|
|
3532
|
+
const args = await (0, import_provider_utils29.validateTypes)({
|
|
3337
3533
|
value: tool.args,
|
|
3338
3534
|
schema: codeInterpreterArgsSchema
|
|
3339
3535
|
});
|
|
@@ -3344,7 +3540,7 @@ async function prepareResponsesTools({
|
|
|
3344
3540
|
break;
|
|
3345
3541
|
}
|
|
3346
3542
|
case "openai.image_generation": {
|
|
3347
|
-
const args = await (0,
|
|
3543
|
+
const args = await (0, import_provider_utils29.validateTypes)({
|
|
3348
3544
|
value: tool.args,
|
|
3349
3545
|
schema: imageGenerationArgsSchema
|
|
3350
3546
|
});
|
|
@@ -3366,6 +3562,36 @@ async function prepareResponsesTools({
|
|
|
3366
3562
|
});
|
|
3367
3563
|
break;
|
|
3368
3564
|
}
|
|
3565
|
+
case "openai.mcp": {
|
|
3566
|
+
const args = await (0, import_provider_utils29.validateTypes)({
|
|
3567
|
+
value: tool.args,
|
|
3568
|
+
schema: mcpArgsSchema
|
|
3569
|
+
});
|
|
3570
|
+
openaiTools.push({
|
|
3571
|
+
type: "mcp",
|
|
3572
|
+
server_label: args.serverLabel,
|
|
3573
|
+
allowed_tools: Array.isArray(args.allowedTools) ? args.allowedTools : args.allowedTools ? {
|
|
3574
|
+
read_only: args.allowedTools.readOnly,
|
|
3575
|
+
tool_names: args.allowedTools.toolNames
|
|
3576
|
+
} : void 0,
|
|
3577
|
+
authorization: args.authorization,
|
|
3578
|
+
connector_id: args.connectorId,
|
|
3579
|
+
headers: args.headers,
|
|
3580
|
+
// require_approval:
|
|
3581
|
+
// typeof args.requireApproval === 'string'
|
|
3582
|
+
// ? args.requireApproval
|
|
3583
|
+
// : args.requireApproval
|
|
3584
|
+
// ? {
|
|
3585
|
+
// read_only: args.requireApproval.readOnly,
|
|
3586
|
+
// tool_names: args.requireApproval.toolNames,
|
|
3587
|
+
// }
|
|
3588
|
+
// : undefined,
|
|
3589
|
+
require_approval: "never",
|
|
3590
|
+
server_description: args.serverDescription,
|
|
3591
|
+
server_url: args.serverUrl
|
|
3592
|
+
});
|
|
3593
|
+
break;
|
|
3594
|
+
}
|
|
3369
3595
|
}
|
|
3370
3596
|
break;
|
|
3371
3597
|
}
|
|
@@ -3386,7 +3612,7 @@ async function prepareResponsesTools({
|
|
|
3386
3612
|
case "tool":
|
|
3387
3613
|
return {
|
|
3388
3614
|
tools: openaiTools,
|
|
3389
|
-
toolChoice: toolChoice.toolName === "code_interpreter" || toolChoice.toolName === "file_search" || toolChoice.toolName === "image_generation" || toolChoice.toolName === "web_search_preview" || toolChoice.toolName === "web_search" ? { type: toolChoice.toolName } : { type: "function", name: toolChoice.toolName },
|
|
3615
|
+
toolChoice: toolChoice.toolName === "code_interpreter" || toolChoice.toolName === "file_search" || toolChoice.toolName === "image_generation" || toolChoice.toolName === "web_search_preview" || toolChoice.toolName === "web_search" || toolChoice.toolName === "mcp" ? { type: toolChoice.toolName } : { type: "function", name: toolChoice.toolName },
|
|
3390
3616
|
toolWarnings
|
|
3391
3617
|
};
|
|
3392
3618
|
default: {
|
|
@@ -3451,7 +3677,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3451
3677
|
if (stopSequences != null) {
|
|
3452
3678
|
warnings.push({ type: "unsupported-setting", setting: "stopSequences" });
|
|
3453
3679
|
}
|
|
3454
|
-
const openaiOptions = await (0,
|
|
3680
|
+
const openaiOptions = await (0, import_provider_utils30.parseProviderOptions)({
|
|
3455
3681
|
provider: "openai",
|
|
3456
3682
|
providerOptions,
|
|
3457
3683
|
schema: openaiResponsesProviderOptionsSchema
|
|
@@ -3627,12 +3853,12 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3627
3853
|
responseHeaders,
|
|
3628
3854
|
value: response,
|
|
3629
3855
|
rawValue: rawResponse
|
|
3630
|
-
} = await (0,
|
|
3856
|
+
} = await (0, import_provider_utils30.postJsonToApi)({
|
|
3631
3857
|
url,
|
|
3632
|
-
headers: (0,
|
|
3858
|
+
headers: (0, import_provider_utils30.combineHeaders)(this.config.headers(), options.headers),
|
|
3633
3859
|
body,
|
|
3634
3860
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
3635
|
-
successfulResponseHandler: (0,
|
|
3861
|
+
successfulResponseHandler: (0, import_provider_utils30.createJsonResponseHandler)(
|
|
3636
3862
|
openaiResponsesResponseSchema
|
|
3637
3863
|
),
|
|
3638
3864
|
abortSignal: options.abortSignal,
|
|
@@ -3729,7 +3955,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3729
3955
|
content.push({
|
|
3730
3956
|
type: "source",
|
|
3731
3957
|
sourceType: "url",
|
|
3732
|
-
id: (_f = (_e = (_d = this.config).generateId) == null ? void 0 : _e.call(_d)) != null ? _f : (0,
|
|
3958
|
+
id: (_f = (_e = (_d = this.config).generateId) == null ? void 0 : _e.call(_d)) != null ? _f : (0, import_provider_utils30.generateId)(),
|
|
3733
3959
|
url: annotation.url,
|
|
3734
3960
|
title: annotation.title
|
|
3735
3961
|
});
|
|
@@ -3737,7 +3963,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3737
3963
|
content.push({
|
|
3738
3964
|
type: "source",
|
|
3739
3965
|
sourceType: "document",
|
|
3740
|
-
id: (_i = (_h = (_g = this.config).generateId) == null ? void 0 : _h.call(_g)) != null ? _i : (0,
|
|
3966
|
+
id: (_i = (_h = (_g = this.config).generateId) == null ? void 0 : _h.call(_g)) != null ? _i : (0, import_provider_utils30.generateId)(),
|
|
3741
3967
|
mediaType: "text/plain",
|
|
3742
3968
|
title: (_k = (_j = annotation.quote) != null ? _j : annotation.filename) != null ? _k : "Document",
|
|
3743
3969
|
filename: (_l = annotation.filename) != null ? _l : annotation.file_id,
|
|
@@ -3753,7 +3979,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3753
3979
|
content.push({
|
|
3754
3980
|
type: "source",
|
|
3755
3981
|
sourceType: "document",
|
|
3756
|
-
id: (_o = (_n = (_m = this.config).generateId) == null ? void 0 : _n.call(_m)) != null ? _o : (0,
|
|
3982
|
+
id: (_o = (_n = (_m = this.config).generateId) == null ? void 0 : _n.call(_m)) != null ? _o : (0, import_provider_utils30.generateId)(),
|
|
3757
3983
|
mediaType: "text/plain",
|
|
3758
3984
|
title: (_q = (_p = annotation.filename) != null ? _p : annotation.file_id) != null ? _q : "Document",
|
|
3759
3985
|
filename: (_r = annotation.filename) != null ? _r : annotation.file_id,
|
|
@@ -3769,7 +3995,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3769
3995
|
content.push({
|
|
3770
3996
|
type: "source",
|
|
3771
3997
|
sourceType: "document",
|
|
3772
|
-
id: (_u = (_t = (_s = this.config).generateId) == null ? void 0 : _t.call(_s)) != null ? _u : (0,
|
|
3998
|
+
id: (_u = (_t = (_s = this.config).generateId) == null ? void 0 : _t.call(_s)) != null ? _u : (0, import_provider_utils30.generateId)(),
|
|
3773
3999
|
mediaType: "application/octet-stream",
|
|
3774
4000
|
title: annotation.file_id,
|
|
3775
4001
|
filename: annotation.file_id,
|
|
@@ -3816,6 +4042,80 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3816
4042
|
});
|
|
3817
4043
|
break;
|
|
3818
4044
|
}
|
|
4045
|
+
case "mcp_call": {
|
|
4046
|
+
content.push({
|
|
4047
|
+
type: "tool-call",
|
|
4048
|
+
toolCallId: part.id,
|
|
4049
|
+
toolName: "mcp",
|
|
4050
|
+
input: JSON.stringify({}),
|
|
4051
|
+
providerExecuted: true
|
|
4052
|
+
});
|
|
4053
|
+
content.push({
|
|
4054
|
+
type: "tool-result",
|
|
4055
|
+
toolCallId: part.id,
|
|
4056
|
+
toolName: "mcp",
|
|
4057
|
+
result: {
|
|
4058
|
+
type: "call",
|
|
4059
|
+
serverLabel: part.server_label,
|
|
4060
|
+
name: part.name,
|
|
4061
|
+
arguments: part.arguments,
|
|
4062
|
+
...part.output != null ? { output: part.output } : {},
|
|
4063
|
+
...part.error != null ? { error: part.error } : {}
|
|
4064
|
+
}
|
|
4065
|
+
});
|
|
4066
|
+
break;
|
|
4067
|
+
}
|
|
4068
|
+
case "mcp_list_tools": {
|
|
4069
|
+
content.push({
|
|
4070
|
+
type: "tool-call",
|
|
4071
|
+
toolCallId: part.id,
|
|
4072
|
+
toolName: "mcp",
|
|
4073
|
+
input: JSON.stringify({}),
|
|
4074
|
+
providerExecuted: true
|
|
4075
|
+
});
|
|
4076
|
+
content.push({
|
|
4077
|
+
type: "tool-result",
|
|
4078
|
+
toolCallId: part.id,
|
|
4079
|
+
toolName: "mcp",
|
|
4080
|
+
result: {
|
|
4081
|
+
type: "listTools",
|
|
4082
|
+
serverLabel: part.server_label,
|
|
4083
|
+
tools: part.tools.map((t) => {
|
|
4084
|
+
var _a2, _b2;
|
|
4085
|
+
return {
|
|
4086
|
+
name: t.name,
|
|
4087
|
+
description: (_a2 = t.description) != null ? _a2 : void 0,
|
|
4088
|
+
inputSchema: t.input_schema,
|
|
4089
|
+
annotations: (_b2 = t.annotations) != null ? _b2 : void 0
|
|
4090
|
+
};
|
|
4091
|
+
}),
|
|
4092
|
+
...part.error != null ? { error: part.error } : {}
|
|
4093
|
+
}
|
|
4094
|
+
});
|
|
4095
|
+
break;
|
|
4096
|
+
}
|
|
4097
|
+
case "mcp_approval_request": {
|
|
4098
|
+
content.push({
|
|
4099
|
+
type: "tool-call",
|
|
4100
|
+
toolCallId: part.id,
|
|
4101
|
+
toolName: "mcp",
|
|
4102
|
+
input: JSON.stringify({}),
|
|
4103
|
+
providerExecuted: true
|
|
4104
|
+
});
|
|
4105
|
+
content.push({
|
|
4106
|
+
type: "tool-result",
|
|
4107
|
+
toolCallId: part.id,
|
|
4108
|
+
toolName: "mcp",
|
|
4109
|
+
result: {
|
|
4110
|
+
type: "approvalRequest",
|
|
4111
|
+
serverLabel: part.server_label,
|
|
4112
|
+
name: part.name,
|
|
4113
|
+
arguments: part.arguments,
|
|
4114
|
+
approvalRequestId: part.approval_request_id
|
|
4115
|
+
}
|
|
4116
|
+
});
|
|
4117
|
+
break;
|
|
4118
|
+
}
|
|
3819
4119
|
case "computer_call": {
|
|
3820
4120
|
content.push({
|
|
3821
4121
|
type: "tool-call",
|
|
@@ -3924,18 +4224,18 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3924
4224
|
webSearchToolName,
|
|
3925
4225
|
store
|
|
3926
4226
|
} = await this.getArgs(options);
|
|
3927
|
-
const { responseHeaders, value: response } = await (0,
|
|
4227
|
+
const { responseHeaders, value: response } = await (0, import_provider_utils30.postJsonToApi)({
|
|
3928
4228
|
url: this.config.url({
|
|
3929
4229
|
path: "/responses",
|
|
3930
4230
|
modelId: this.modelId
|
|
3931
4231
|
}),
|
|
3932
|
-
headers: (0,
|
|
4232
|
+
headers: (0, import_provider_utils30.combineHeaders)(this.config.headers(), options.headers),
|
|
3933
4233
|
body: {
|
|
3934
4234
|
...body,
|
|
3935
4235
|
stream: true
|
|
3936
4236
|
},
|
|
3937
4237
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
3938
|
-
successfulResponseHandler: (0,
|
|
4238
|
+
successfulResponseHandler: (0, import_provider_utils30.createEventSourceResponseHandler)(
|
|
3939
4239
|
openaiResponsesChunkSchema
|
|
3940
4240
|
),
|
|
3941
4241
|
abortSignal: options.abortSignal,
|
|
@@ -4050,6 +4350,14 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4050
4350
|
input: "{}",
|
|
4051
4351
|
providerExecuted: true
|
|
4052
4352
|
});
|
|
4353
|
+
} else if (value.item.type === "mcp_call" || value.item.type === "mcp_list_tools" || value.item.type === "mcp_approval_request") {
|
|
4354
|
+
controller.enqueue({
|
|
4355
|
+
type: "tool-call",
|
|
4356
|
+
toolCallId: value.item.id,
|
|
4357
|
+
toolName: "mcp",
|
|
4358
|
+
input: "{}",
|
|
4359
|
+
providerExecuted: true
|
|
4360
|
+
});
|
|
4053
4361
|
} else if (value.item.type === "message") {
|
|
4054
4362
|
controller.enqueue({
|
|
4055
4363
|
type: "text-start",
|
|
@@ -4161,6 +4469,56 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4161
4469
|
result: value.item.result
|
|
4162
4470
|
}
|
|
4163
4471
|
});
|
|
4472
|
+
} else if (value.item.type === "mcp_call") {
|
|
4473
|
+
ongoingToolCalls[value.output_index] = void 0;
|
|
4474
|
+
controller.enqueue({
|
|
4475
|
+
type: "tool-result",
|
|
4476
|
+
toolCallId: value.item.id,
|
|
4477
|
+
toolName: "mcp",
|
|
4478
|
+
result: {
|
|
4479
|
+
type: "call",
|
|
4480
|
+
serverLabel: value.item.server_label,
|
|
4481
|
+
name: value.item.name,
|
|
4482
|
+
arguments: value.item.arguments,
|
|
4483
|
+
...value.item.output != null ? { output: value.item.output } : {},
|
|
4484
|
+
...value.item.error != null ? { error: value.item.error } : {}
|
|
4485
|
+
}
|
|
4486
|
+
});
|
|
4487
|
+
} else if (value.item.type === "mcp_list_tools") {
|
|
4488
|
+
ongoingToolCalls[value.output_index] = void 0;
|
|
4489
|
+
controller.enqueue({
|
|
4490
|
+
type: "tool-result",
|
|
4491
|
+
toolCallId: value.item.id,
|
|
4492
|
+
toolName: "mcp",
|
|
4493
|
+
result: {
|
|
4494
|
+
type: "listTools",
|
|
4495
|
+
serverLabel: value.item.server_label,
|
|
4496
|
+
tools: value.item.tools.map((t) => {
|
|
4497
|
+
var _a2, _b2;
|
|
4498
|
+
return {
|
|
4499
|
+
name: t.name,
|
|
4500
|
+
description: (_a2 = t.description) != null ? _a2 : void 0,
|
|
4501
|
+
inputSchema: t.input_schema,
|
|
4502
|
+
annotations: (_b2 = t.annotations) != null ? _b2 : void 0
|
|
4503
|
+
};
|
|
4504
|
+
}),
|
|
4505
|
+
...value.item.error != null ? { error: value.item.error } : {}
|
|
4506
|
+
}
|
|
4507
|
+
});
|
|
4508
|
+
} else if (value.item.type === "mcp_approval_request") {
|
|
4509
|
+
ongoingToolCalls[value.output_index] = void 0;
|
|
4510
|
+
controller.enqueue({
|
|
4511
|
+
type: "tool-result",
|
|
4512
|
+
toolCallId: value.item.id,
|
|
4513
|
+
toolName: "mcp",
|
|
4514
|
+
result: {
|
|
4515
|
+
type: "approvalRequest",
|
|
4516
|
+
serverLabel: value.item.server_label,
|
|
4517
|
+
name: value.item.name,
|
|
4518
|
+
arguments: value.item.arguments,
|
|
4519
|
+
approvalRequestId: value.item.approval_request_id
|
|
4520
|
+
}
|
|
4521
|
+
});
|
|
4164
4522
|
} else if (value.item.type === "local_shell_call") {
|
|
4165
4523
|
ongoingToolCalls[value.output_index] = void 0;
|
|
4166
4524
|
controller.enqueue({
|
|
@@ -4346,7 +4704,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4346
4704
|
controller.enqueue({
|
|
4347
4705
|
type: "source",
|
|
4348
4706
|
sourceType: "url",
|
|
4349
|
-
id: (_p = (_o = (_n = self.config).generateId) == null ? void 0 : _o.call(_n)) != null ? _p : (0,
|
|
4707
|
+
id: (_p = (_o = (_n = self.config).generateId) == null ? void 0 : _o.call(_n)) != null ? _p : (0, import_provider_utils30.generateId)(),
|
|
4350
4708
|
url: value.annotation.url,
|
|
4351
4709
|
title: value.annotation.title
|
|
4352
4710
|
});
|
|
@@ -4354,7 +4712,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4354
4712
|
controller.enqueue({
|
|
4355
4713
|
type: "source",
|
|
4356
4714
|
sourceType: "document",
|
|
4357
|
-
id: (_s = (_r = (_q = self.config).generateId) == null ? void 0 : _r.call(_q)) != null ? _s : (0,
|
|
4715
|
+
id: (_s = (_r = (_q = self.config).generateId) == null ? void 0 : _r.call(_q)) != null ? _s : (0, import_provider_utils30.generateId)(),
|
|
4358
4716
|
mediaType: "text/plain",
|
|
4359
4717
|
title: (_u = (_t = value.annotation.quote) != null ? _t : value.annotation.filename) != null ? _u : "Document",
|
|
4360
4718
|
filename: (_v = value.annotation.filename) != null ? _v : value.annotation.file_id,
|
|
@@ -4370,7 +4728,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4370
4728
|
controller.enqueue({
|
|
4371
4729
|
type: "source",
|
|
4372
4730
|
sourceType: "document",
|
|
4373
|
-
id: (_y = (_x = (_w = self.config).generateId) == null ? void 0 : _x.call(_w)) != null ? _y : (0,
|
|
4731
|
+
id: (_y = (_x = (_w = self.config).generateId) == null ? void 0 : _x.call(_w)) != null ? _y : (0, import_provider_utils30.generateId)(),
|
|
4374
4732
|
mediaType: "text/plain",
|
|
4375
4733
|
title: (_A = (_z = value.annotation.filename) != null ? _z : value.annotation.file_id) != null ? _A : "Document",
|
|
4376
4734
|
filename: (_B = value.annotation.filename) != null ? _B : value.annotation.file_id,
|
|
@@ -4386,7 +4744,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4386
4744
|
controller.enqueue({
|
|
4387
4745
|
type: "source",
|
|
4388
4746
|
sourceType: "document",
|
|
4389
|
-
id: (_E = (_D = (_C = self.config).generateId) == null ? void 0 : _D.call(_C)) != null ? _E : (0,
|
|
4747
|
+
id: (_E = (_D = (_C = self.config).generateId) == null ? void 0 : _D.call(_C)) != null ? _E : (0, import_provider_utils30.generateId)(),
|
|
4390
4748
|
mediaType: "application/octet-stream",
|
|
4391
4749
|
title: value.annotation.file_id,
|
|
4392
4750
|
filename: value.annotation.file_id,
|