@ai-sdk/openai 3.0.0-beta.54 → 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 +6 -0
- package/dist/index.d.mts +51 -0
- package/dist/index.d.ts +51 -0
- package/dist/index.js +845 -474
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +803 -428
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +377 -23
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +359 -1
- 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
|
),
|
|
@@ -3262,8 +3367,95 @@ var imageGeneration = (args = {}) => {
|
|
|
3262
3367
|
return imageGenerationToolFactory(args);
|
|
3263
3368
|
};
|
|
3264
3369
|
|
|
3265
|
-
// src/
|
|
3370
|
+
// src/tool/mcp.ts
|
|
3266
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");
|
|
3267
3459
|
async function prepareResponsesTools({
|
|
3268
3460
|
tools,
|
|
3269
3461
|
toolChoice,
|
|
@@ -3289,7 +3481,7 @@ async function prepareResponsesTools({
|
|
|
3289
3481
|
case "provider-defined": {
|
|
3290
3482
|
switch (tool.id) {
|
|
3291
3483
|
case "openai.file_search": {
|
|
3292
|
-
const args = await (0,
|
|
3484
|
+
const args = await (0, import_provider_utils29.validateTypes)({
|
|
3293
3485
|
value: tool.args,
|
|
3294
3486
|
schema: fileSearchArgsSchema
|
|
3295
3487
|
});
|
|
@@ -3312,7 +3504,7 @@ async function prepareResponsesTools({
|
|
|
3312
3504
|
break;
|
|
3313
3505
|
}
|
|
3314
3506
|
case "openai.web_search_preview": {
|
|
3315
|
-
const args = await (0,
|
|
3507
|
+
const args = await (0, import_provider_utils29.validateTypes)({
|
|
3316
3508
|
value: tool.args,
|
|
3317
3509
|
schema: webSearchPreviewArgsSchema
|
|
3318
3510
|
});
|
|
@@ -3324,7 +3516,7 @@ async function prepareResponsesTools({
|
|
|
3324
3516
|
break;
|
|
3325
3517
|
}
|
|
3326
3518
|
case "openai.web_search": {
|
|
3327
|
-
const args = await (0,
|
|
3519
|
+
const args = await (0, import_provider_utils29.validateTypes)({
|
|
3328
3520
|
value: tool.args,
|
|
3329
3521
|
schema: webSearchArgsSchema
|
|
3330
3522
|
});
|
|
@@ -3337,7 +3529,7 @@ async function prepareResponsesTools({
|
|
|
3337
3529
|
break;
|
|
3338
3530
|
}
|
|
3339
3531
|
case "openai.code_interpreter": {
|
|
3340
|
-
const args = await (0,
|
|
3532
|
+
const args = await (0, import_provider_utils29.validateTypes)({
|
|
3341
3533
|
value: tool.args,
|
|
3342
3534
|
schema: codeInterpreterArgsSchema
|
|
3343
3535
|
});
|
|
@@ -3348,7 +3540,7 @@ async function prepareResponsesTools({
|
|
|
3348
3540
|
break;
|
|
3349
3541
|
}
|
|
3350
3542
|
case "openai.image_generation": {
|
|
3351
|
-
const args = await (0,
|
|
3543
|
+
const args = await (0, import_provider_utils29.validateTypes)({
|
|
3352
3544
|
value: tool.args,
|
|
3353
3545
|
schema: imageGenerationArgsSchema
|
|
3354
3546
|
});
|
|
@@ -3370,6 +3562,36 @@ async function prepareResponsesTools({
|
|
|
3370
3562
|
});
|
|
3371
3563
|
break;
|
|
3372
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
|
+
}
|
|
3373
3595
|
}
|
|
3374
3596
|
break;
|
|
3375
3597
|
}
|
|
@@ -3390,7 +3612,7 @@ async function prepareResponsesTools({
|
|
|
3390
3612
|
case "tool":
|
|
3391
3613
|
return {
|
|
3392
3614
|
tools: openaiTools,
|
|
3393
|
-
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 },
|
|
3394
3616
|
toolWarnings
|
|
3395
3617
|
};
|
|
3396
3618
|
default: {
|
|
@@ -3455,7 +3677,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3455
3677
|
if (stopSequences != null) {
|
|
3456
3678
|
warnings.push({ type: "unsupported-setting", setting: "stopSequences" });
|
|
3457
3679
|
}
|
|
3458
|
-
const openaiOptions = await (0,
|
|
3680
|
+
const openaiOptions = await (0, import_provider_utils30.parseProviderOptions)({
|
|
3459
3681
|
provider: "openai",
|
|
3460
3682
|
providerOptions,
|
|
3461
3683
|
schema: openaiResponsesProviderOptionsSchema
|
|
@@ -3631,12 +3853,12 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3631
3853
|
responseHeaders,
|
|
3632
3854
|
value: response,
|
|
3633
3855
|
rawValue: rawResponse
|
|
3634
|
-
} = await (0,
|
|
3856
|
+
} = await (0, import_provider_utils30.postJsonToApi)({
|
|
3635
3857
|
url,
|
|
3636
|
-
headers: (0,
|
|
3858
|
+
headers: (0, import_provider_utils30.combineHeaders)(this.config.headers(), options.headers),
|
|
3637
3859
|
body,
|
|
3638
3860
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
3639
|
-
successfulResponseHandler: (0,
|
|
3861
|
+
successfulResponseHandler: (0, import_provider_utils30.createJsonResponseHandler)(
|
|
3640
3862
|
openaiResponsesResponseSchema
|
|
3641
3863
|
),
|
|
3642
3864
|
abortSignal: options.abortSignal,
|
|
@@ -3733,7 +3955,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3733
3955
|
content.push({
|
|
3734
3956
|
type: "source",
|
|
3735
3957
|
sourceType: "url",
|
|
3736
|
-
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)(),
|
|
3737
3959
|
url: annotation.url,
|
|
3738
3960
|
title: annotation.title
|
|
3739
3961
|
});
|
|
@@ -3741,7 +3963,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3741
3963
|
content.push({
|
|
3742
3964
|
type: "source",
|
|
3743
3965
|
sourceType: "document",
|
|
3744
|
-
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)(),
|
|
3745
3967
|
mediaType: "text/plain",
|
|
3746
3968
|
title: (_k = (_j = annotation.quote) != null ? _j : annotation.filename) != null ? _k : "Document",
|
|
3747
3969
|
filename: (_l = annotation.filename) != null ? _l : annotation.file_id,
|
|
@@ -3757,7 +3979,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3757
3979
|
content.push({
|
|
3758
3980
|
type: "source",
|
|
3759
3981
|
sourceType: "document",
|
|
3760
|
-
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)(),
|
|
3761
3983
|
mediaType: "text/plain",
|
|
3762
3984
|
title: (_q = (_p = annotation.filename) != null ? _p : annotation.file_id) != null ? _q : "Document",
|
|
3763
3985
|
filename: (_r = annotation.filename) != null ? _r : annotation.file_id,
|
|
@@ -3773,7 +3995,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3773
3995
|
content.push({
|
|
3774
3996
|
type: "source",
|
|
3775
3997
|
sourceType: "document",
|
|
3776
|
-
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)(),
|
|
3777
3999
|
mediaType: "application/octet-stream",
|
|
3778
4000
|
title: annotation.file_id,
|
|
3779
4001
|
filename: annotation.file_id,
|
|
@@ -3820,6 +4042,80 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3820
4042
|
});
|
|
3821
4043
|
break;
|
|
3822
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
|
+
}
|
|
3823
4119
|
case "computer_call": {
|
|
3824
4120
|
content.push({
|
|
3825
4121
|
type: "tool-call",
|
|
@@ -3928,18 +4224,18 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3928
4224
|
webSearchToolName,
|
|
3929
4225
|
store
|
|
3930
4226
|
} = await this.getArgs(options);
|
|
3931
|
-
const { responseHeaders, value: response } = await (0,
|
|
4227
|
+
const { responseHeaders, value: response } = await (0, import_provider_utils30.postJsonToApi)({
|
|
3932
4228
|
url: this.config.url({
|
|
3933
4229
|
path: "/responses",
|
|
3934
4230
|
modelId: this.modelId
|
|
3935
4231
|
}),
|
|
3936
|
-
headers: (0,
|
|
4232
|
+
headers: (0, import_provider_utils30.combineHeaders)(this.config.headers(), options.headers),
|
|
3937
4233
|
body: {
|
|
3938
4234
|
...body,
|
|
3939
4235
|
stream: true
|
|
3940
4236
|
},
|
|
3941
4237
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
3942
|
-
successfulResponseHandler: (0,
|
|
4238
|
+
successfulResponseHandler: (0, import_provider_utils30.createEventSourceResponseHandler)(
|
|
3943
4239
|
openaiResponsesChunkSchema
|
|
3944
4240
|
),
|
|
3945
4241
|
abortSignal: options.abortSignal,
|
|
@@ -4054,6 +4350,14 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4054
4350
|
input: "{}",
|
|
4055
4351
|
providerExecuted: true
|
|
4056
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
|
+
});
|
|
4057
4361
|
} else if (value.item.type === "message") {
|
|
4058
4362
|
controller.enqueue({
|
|
4059
4363
|
type: "text-start",
|
|
@@ -4165,6 +4469,56 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4165
4469
|
result: value.item.result
|
|
4166
4470
|
}
|
|
4167
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
|
+
});
|
|
4168
4522
|
} else if (value.item.type === "local_shell_call") {
|
|
4169
4523
|
ongoingToolCalls[value.output_index] = void 0;
|
|
4170
4524
|
controller.enqueue({
|
|
@@ -4350,7 +4704,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4350
4704
|
controller.enqueue({
|
|
4351
4705
|
type: "source",
|
|
4352
4706
|
sourceType: "url",
|
|
4353
|
-
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)(),
|
|
4354
4708
|
url: value.annotation.url,
|
|
4355
4709
|
title: value.annotation.title
|
|
4356
4710
|
});
|
|
@@ -4358,7 +4712,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4358
4712
|
controller.enqueue({
|
|
4359
4713
|
type: "source",
|
|
4360
4714
|
sourceType: "document",
|
|
4361
|
-
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)(),
|
|
4362
4716
|
mediaType: "text/plain",
|
|
4363
4717
|
title: (_u = (_t = value.annotation.quote) != null ? _t : value.annotation.filename) != null ? _u : "Document",
|
|
4364
4718
|
filename: (_v = value.annotation.filename) != null ? _v : value.annotation.file_id,
|
|
@@ -4374,7 +4728,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4374
4728
|
controller.enqueue({
|
|
4375
4729
|
type: "source",
|
|
4376
4730
|
sourceType: "document",
|
|
4377
|
-
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)(),
|
|
4378
4732
|
mediaType: "text/plain",
|
|
4379
4733
|
title: (_A = (_z = value.annotation.filename) != null ? _z : value.annotation.file_id) != null ? _A : "Document",
|
|
4380
4734
|
filename: (_B = value.annotation.filename) != null ? _B : value.annotation.file_id,
|
|
@@ -4390,7 +4744,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4390
4744
|
controller.enqueue({
|
|
4391
4745
|
type: "source",
|
|
4392
4746
|
sourceType: "document",
|
|
4393
|
-
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)(),
|
|
4394
4748
|
mediaType: "application/octet-stream",
|
|
4395
4749
|
title: value.annotation.file_id,
|
|
4396
4750
|
filename: value.annotation.file_id,
|