mcp-proxy 6.4.2 → 6.4.4
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/dist/bin/mcp-proxy.mjs +28 -6
- package/dist/bin/mcp-proxy.mjs.map +1 -1
- package/dist/index.mjs +169 -145
- package/dist/index.mjs.map +1 -1
- package/dist/{stdio-CvFTizsx.mjs → stdio-BmURZCbz.mjs} +1557 -749
- package/dist/stdio-BmURZCbz.mjs.map +1 -0
- package/jsr.json +1 -1
- package/package.json +2 -2
- package/src/JSONFilterTransform.test.ts +47 -2
- package/src/JSONFilterTransform.ts +41 -8
- package/src/bin/mcp-proxy.ts +2 -3
- package/src/fixtures/noisy-stdout-server.ts +70 -0
- package/src/proxyServer.test.ts +2 -4
- package/src/startHTTPServer.test.ts +18 -51
- package/src/startStdioServer.ts +2 -3
- package/dist/stdio-CvFTizsx.mjs.map +0 -1
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
2
|
import { randomUUID } from "node:crypto";
|
|
3
|
+
import { TLSSocket } from "node:tls";
|
|
4
|
+
import { Readable } from "stream";
|
|
3
5
|
import { URL as URL$1 } from "node:url";
|
|
4
|
-
import fs from "fs";
|
|
5
6
|
import http from "http";
|
|
7
|
+
import { Http2ServerRequest } from "http2";
|
|
8
|
+
import crypto$1 from "crypto";
|
|
9
|
+
import fs from "fs";
|
|
6
10
|
import https from "https";
|
|
7
11
|
|
|
8
12
|
//#region rolldown:runtime
|
|
@@ -3324,7 +3328,7 @@ function preprocess(fn, schema) {
|
|
|
3324
3328
|
}
|
|
3325
3329
|
|
|
3326
3330
|
//#endregion
|
|
3327
|
-
//#region node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
3331
|
+
//#region node_modules/.pnpm/@modelcontextprotocol+sdk@1.27.1_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/types.js
|
|
3328
3332
|
const LATEST_PROTOCOL_VERSION = "2025-11-25";
|
|
3329
3333
|
const DEFAULT_NEGOTIATED_PROTOCOL_VERSION = "2025-03-26";
|
|
3330
3334
|
const SUPPORTED_PROTOCOL_VERSIONS = [
|
|
@@ -3357,10 +3361,12 @@ const TaskCreationParamsSchema = looseObject({
|
|
|
3357
3361
|
ttl: union([number(), _null()]).optional(),
|
|
3358
3362
|
pollInterval: number().optional()
|
|
3359
3363
|
});
|
|
3364
|
+
const TaskMetadataSchema = object({ ttl: number().optional() });
|
|
3360
3365
|
/**
|
|
3361
|
-
*
|
|
3366
|
+
* Metadata for associating messages with a task.
|
|
3367
|
+
* Include this in the `_meta` field under the key `io.modelcontextprotocol/related-task`.
|
|
3362
3368
|
*/
|
|
3363
|
-
const RelatedTaskMetadataSchema =
|
|
3369
|
+
const RelatedTaskMetadataSchema = object({ taskId: string() });
|
|
3364
3370
|
const RequestMetaSchema = looseObject({
|
|
3365
3371
|
progressToken: ProgressTokenSchema.optional(),
|
|
3366
3372
|
[RELATED_TASK_META_KEY]: RelatedTaskMetadataSchema.optional()
|
|
@@ -3368,20 +3374,28 @@ const RequestMetaSchema = looseObject({
|
|
|
3368
3374
|
/**
|
|
3369
3375
|
* Common params for any request.
|
|
3370
3376
|
*/
|
|
3371
|
-
const BaseRequestParamsSchema =
|
|
3372
|
-
|
|
3373
|
-
|
|
3374
|
-
|
|
3377
|
+
const BaseRequestParamsSchema = object({ _meta: RequestMetaSchema.optional() });
|
|
3378
|
+
/**
|
|
3379
|
+
* Common params for any task-augmented request.
|
|
3380
|
+
*/
|
|
3381
|
+
const TaskAugmentedRequestParamsSchema = BaseRequestParamsSchema.extend({ task: TaskMetadataSchema.optional() });
|
|
3382
|
+
/**
|
|
3383
|
+
* Checks if a value is a valid TaskAugmentedRequestParams.
|
|
3384
|
+
* @param value - The value to check.
|
|
3385
|
+
*
|
|
3386
|
+
* @returns True if the value is a valid TaskAugmentedRequestParams, false otherwise.
|
|
3387
|
+
*/
|
|
3388
|
+
const isTaskAugmentedRequestParams = (value) => TaskAugmentedRequestParamsSchema.safeParse(value).success;
|
|
3375
3389
|
const RequestSchema = object({
|
|
3376
3390
|
method: string(),
|
|
3377
|
-
params: BaseRequestParamsSchema.optional()
|
|
3391
|
+
params: BaseRequestParamsSchema.loose().optional()
|
|
3378
3392
|
});
|
|
3379
|
-
const NotificationsParamsSchema =
|
|
3393
|
+
const NotificationsParamsSchema = object({ _meta: RequestMetaSchema.optional() });
|
|
3380
3394
|
const NotificationSchema = object({
|
|
3381
3395
|
method: string(),
|
|
3382
|
-
params: NotificationsParamsSchema.optional()
|
|
3396
|
+
params: NotificationsParamsSchema.loose().optional()
|
|
3383
3397
|
});
|
|
3384
|
-
const ResultSchema = looseObject({ _meta:
|
|
3398
|
+
const ResultSchema = looseObject({ _meta: RequestMetaSchema.optional() });
|
|
3385
3399
|
/**
|
|
3386
3400
|
* A uniquely identifying ID for a request in JSON-RPC.
|
|
3387
3401
|
*/
|
|
@@ -3406,12 +3420,18 @@ const isJSONRPCNotification = (value) => JSONRPCNotificationSchema.safeParse(val
|
|
|
3406
3420
|
/**
|
|
3407
3421
|
* A successful (non-error) response to a request.
|
|
3408
3422
|
*/
|
|
3409
|
-
const
|
|
3423
|
+
const JSONRPCResultResponseSchema = object({
|
|
3410
3424
|
jsonrpc: literal(JSONRPC_VERSION),
|
|
3411
3425
|
id: RequestIdSchema,
|
|
3412
3426
|
result: ResultSchema
|
|
3413
3427
|
}).strict();
|
|
3414
|
-
|
|
3428
|
+
/**
|
|
3429
|
+
* Checks if a value is a valid JSONRPCResultResponse.
|
|
3430
|
+
* @param value - The value to check.
|
|
3431
|
+
*
|
|
3432
|
+
* @returns True if the value is a valid JSONRPCResultResponse, false otherwise.
|
|
3433
|
+
*/
|
|
3434
|
+
const isJSONRPCResultResponse = (value) => JSONRPCResultResponseSchema.safeParse(value).success;
|
|
3415
3435
|
/**
|
|
3416
3436
|
* Error codes defined by the JSON-RPC specification.
|
|
3417
3437
|
*/
|
|
@@ -3429,28 +3449,35 @@ var ErrorCode;
|
|
|
3429
3449
|
/**
|
|
3430
3450
|
* A response to a request that indicates an error occurred.
|
|
3431
3451
|
*/
|
|
3432
|
-
const
|
|
3452
|
+
const JSONRPCErrorResponseSchema = object({
|
|
3433
3453
|
jsonrpc: literal(JSONRPC_VERSION),
|
|
3434
|
-
id: RequestIdSchema,
|
|
3454
|
+
id: RequestIdSchema.optional(),
|
|
3435
3455
|
error: object({
|
|
3436
3456
|
code: number().int(),
|
|
3437
3457
|
message: string(),
|
|
3438
|
-
data:
|
|
3458
|
+
data: unknown().optional()
|
|
3439
3459
|
})
|
|
3440
3460
|
}).strict();
|
|
3441
|
-
|
|
3461
|
+
/**
|
|
3462
|
+
* Checks if a value is a valid JSONRPCErrorResponse.
|
|
3463
|
+
* @param value - The value to check.
|
|
3464
|
+
*
|
|
3465
|
+
* @returns True if the value is a valid JSONRPCErrorResponse, false otherwise.
|
|
3466
|
+
*/
|
|
3467
|
+
const isJSONRPCErrorResponse = (value) => JSONRPCErrorResponseSchema.safeParse(value).success;
|
|
3442
3468
|
const JSONRPCMessageSchema = union([
|
|
3443
3469
|
JSONRPCRequestSchema,
|
|
3444
3470
|
JSONRPCNotificationSchema,
|
|
3445
|
-
|
|
3446
|
-
|
|
3471
|
+
JSONRPCResultResponseSchema,
|
|
3472
|
+
JSONRPCErrorResponseSchema
|
|
3447
3473
|
]);
|
|
3474
|
+
const JSONRPCResponseSchema = union([JSONRPCResultResponseSchema, JSONRPCErrorResponseSchema]);
|
|
3448
3475
|
/**
|
|
3449
3476
|
* A response that indicates success but carries no data.
|
|
3450
3477
|
*/
|
|
3451
3478
|
const EmptyResultSchema = ResultSchema.strict();
|
|
3452
3479
|
const CancelledNotificationParamsSchema = NotificationsParamsSchema.extend({
|
|
3453
|
-
requestId: RequestIdSchema,
|
|
3480
|
+
requestId: RequestIdSchema.optional(),
|
|
3454
3481
|
reason: string().optional()
|
|
3455
3482
|
});
|
|
3456
3483
|
/**
|
|
@@ -3472,7 +3499,8 @@ const CancelledNotificationSchema = NotificationSchema.extend({
|
|
|
3472
3499
|
const IconSchema = object({
|
|
3473
3500
|
src: string(),
|
|
3474
3501
|
mimeType: string().optional(),
|
|
3475
|
-
sizes: array(string()).optional()
|
|
3502
|
+
sizes: array(string()).optional(),
|
|
3503
|
+
theme: _enum(["light", "dark"]).optional()
|
|
3476
3504
|
});
|
|
3477
3505
|
/**
|
|
3478
3506
|
* Base schema to add `icons` property.
|
|
@@ -3493,7 +3521,8 @@ const ImplementationSchema = BaseMetadataSchema.extend({
|
|
|
3493
3521
|
...BaseMetadataSchema.shape,
|
|
3494
3522
|
...IconsSchema.shape,
|
|
3495
3523
|
version: string(),
|
|
3496
|
-
websiteUrl: string().optional()
|
|
3524
|
+
websiteUrl: string().optional(),
|
|
3525
|
+
description: string().optional()
|
|
3497
3526
|
});
|
|
3498
3527
|
const FormElicitationCapabilitySchema = intersection(object({ applyDefaults: boolean().optional() }), record(string(), unknown()));
|
|
3499
3528
|
const ElicitationCapabilitySchema = preprocess((value) => {
|
|
@@ -3508,22 +3537,22 @@ const ElicitationCapabilitySchema = preprocess((value) => {
|
|
|
3508
3537
|
/**
|
|
3509
3538
|
* Task capabilities for clients, indicating which request types support task creation.
|
|
3510
3539
|
*/
|
|
3511
|
-
const ClientTasksCapabilitySchema =
|
|
3512
|
-
list: optional(
|
|
3513
|
-
cancel: optional(
|
|
3514
|
-
requests:
|
|
3515
|
-
sampling:
|
|
3516
|
-
elicitation:
|
|
3517
|
-
}).
|
|
3518
|
-
})
|
|
3540
|
+
const ClientTasksCapabilitySchema = looseObject({
|
|
3541
|
+
list: AssertObjectSchema.optional(),
|
|
3542
|
+
cancel: AssertObjectSchema.optional(),
|
|
3543
|
+
requests: looseObject({
|
|
3544
|
+
sampling: looseObject({ createMessage: AssertObjectSchema.optional() }).optional(),
|
|
3545
|
+
elicitation: looseObject({ create: AssertObjectSchema.optional() }).optional()
|
|
3546
|
+
}).optional()
|
|
3547
|
+
});
|
|
3519
3548
|
/**
|
|
3520
3549
|
* Task capabilities for servers, indicating which request types support task creation.
|
|
3521
3550
|
*/
|
|
3522
|
-
const ServerTasksCapabilitySchema =
|
|
3523
|
-
list: optional(
|
|
3524
|
-
cancel: optional(
|
|
3525
|
-
requests:
|
|
3526
|
-
})
|
|
3551
|
+
const ServerTasksCapabilitySchema = looseObject({
|
|
3552
|
+
list: AssertObjectSchema.optional(),
|
|
3553
|
+
cancel: AssertObjectSchema.optional(),
|
|
3554
|
+
requests: looseObject({ tools: looseObject({ call: AssertObjectSchema.optional() }).optional() }).optional()
|
|
3555
|
+
});
|
|
3527
3556
|
/**
|
|
3528
3557
|
* Capabilities a client may support. Known capabilities are defined here, in this schema, but this is not a closed set: any client can define its own, additional capabilities.
|
|
3529
3558
|
*/
|
|
@@ -3535,7 +3564,7 @@ const ClientCapabilitiesSchema = object({
|
|
|
3535
3564
|
}).optional(),
|
|
3536
3565
|
elicitation: ElicitationCapabilitySchema.optional(),
|
|
3537
3566
|
roots: object({ listChanged: boolean().optional() }).optional(),
|
|
3538
|
-
tasks: optional(
|
|
3567
|
+
tasks: ClientTasksCapabilitySchema.optional()
|
|
3539
3568
|
});
|
|
3540
3569
|
const InitializeRequestParamsSchema = BaseRequestParamsSchema.extend({
|
|
3541
3570
|
protocolVersion: string(),
|
|
@@ -3557,14 +3586,14 @@ const ServerCapabilitiesSchema = object({
|
|
|
3557
3586
|
experimental: record(string(), AssertObjectSchema).optional(),
|
|
3558
3587
|
logging: AssertObjectSchema.optional(),
|
|
3559
3588
|
completions: AssertObjectSchema.optional(),
|
|
3560
|
-
prompts:
|
|
3589
|
+
prompts: object({ listChanged: boolean().optional() }).optional(),
|
|
3561
3590
|
resources: object({
|
|
3562
3591
|
subscribe: boolean().optional(),
|
|
3563
3592
|
listChanged: boolean().optional()
|
|
3564
3593
|
}).optional(),
|
|
3565
3594
|
tools: object({ listChanged: boolean().optional() }).optional(),
|
|
3566
|
-
tasks: optional(
|
|
3567
|
-
})
|
|
3595
|
+
tasks: ServerTasksCapabilitySchema.optional()
|
|
3596
|
+
});
|
|
3568
3597
|
/**
|
|
3569
3598
|
* After receiving an initialize request from the client, the server sends this response.
|
|
3570
3599
|
*/
|
|
@@ -3577,12 +3606,18 @@ const InitializeResultSchema = ResultSchema.extend({
|
|
|
3577
3606
|
/**
|
|
3578
3607
|
* This notification is sent from the client to the server after initialization has finished.
|
|
3579
3608
|
*/
|
|
3580
|
-
const InitializedNotificationSchema = NotificationSchema.extend({
|
|
3609
|
+
const InitializedNotificationSchema = NotificationSchema.extend({
|
|
3610
|
+
method: literal("notifications/initialized"),
|
|
3611
|
+
params: NotificationsParamsSchema.optional()
|
|
3612
|
+
});
|
|
3581
3613
|
const isInitializedNotification = (value) => InitializedNotificationSchema.safeParse(value).success;
|
|
3582
3614
|
/**
|
|
3583
3615
|
* A ping, issued by either the server or the client, to check that the other party is still alive. The receiver must promptly respond, or else may be disconnected.
|
|
3584
3616
|
*/
|
|
3585
|
-
const PingRequestSchema = RequestSchema.extend({
|
|
3617
|
+
const PingRequestSchema = RequestSchema.extend({
|
|
3618
|
+
method: literal("ping"),
|
|
3619
|
+
params: BaseRequestParamsSchema.optional()
|
|
3620
|
+
});
|
|
3586
3621
|
const ProgressSchema = object({
|
|
3587
3622
|
progress: number(),
|
|
3588
3623
|
total: optional(number()),
|
|
@@ -3604,19 +3639,23 @@ const ProgressNotificationSchema = NotificationSchema.extend({
|
|
|
3604
3639
|
});
|
|
3605
3640
|
const PaginatedRequestParamsSchema = BaseRequestParamsSchema.extend({ cursor: CursorSchema.optional() });
|
|
3606
3641
|
const PaginatedRequestSchema = RequestSchema.extend({ params: PaginatedRequestParamsSchema.optional() });
|
|
3607
|
-
const PaginatedResultSchema = ResultSchema.extend({ nextCursor: optional(
|
|
3642
|
+
const PaginatedResultSchema = ResultSchema.extend({ nextCursor: CursorSchema.optional() });
|
|
3643
|
+
/**
|
|
3644
|
+
* The status of a task.
|
|
3645
|
+
* */
|
|
3646
|
+
const TaskStatusSchema = _enum([
|
|
3647
|
+
"working",
|
|
3648
|
+
"input_required",
|
|
3649
|
+
"completed",
|
|
3650
|
+
"failed",
|
|
3651
|
+
"cancelled"
|
|
3652
|
+
]);
|
|
3608
3653
|
/**
|
|
3609
3654
|
* A pollable state object associated with a request.
|
|
3610
3655
|
*/
|
|
3611
3656
|
const TaskSchema = object({
|
|
3612
3657
|
taskId: string(),
|
|
3613
|
-
status:
|
|
3614
|
-
"working",
|
|
3615
|
-
"input_required",
|
|
3616
|
-
"completed",
|
|
3617
|
-
"failed",
|
|
3618
|
-
"cancelled"
|
|
3619
|
-
]),
|
|
3658
|
+
status: TaskStatusSchema,
|
|
3620
3659
|
ttl: union([number(), _null()]),
|
|
3621
3660
|
createdAt: string(),
|
|
3622
3661
|
lastUpdatedAt: string(),
|
|
@@ -3657,6 +3696,13 @@ const GetTaskPayloadRequestSchema = RequestSchema.extend({
|
|
|
3657
3696
|
params: BaseRequestParamsSchema.extend({ taskId: string() })
|
|
3658
3697
|
});
|
|
3659
3698
|
/**
|
|
3699
|
+
* The response to a tasks/result request.
|
|
3700
|
+
* The structure matches the result type of the original request.
|
|
3701
|
+
* For example, a tools/call task would return the CallToolResult structure.
|
|
3702
|
+
*
|
|
3703
|
+
*/
|
|
3704
|
+
const GetTaskPayloadResultSchema = ResultSchema.loose();
|
|
3705
|
+
/**
|
|
3660
3706
|
* A request to list tasks.
|
|
3661
3707
|
*/
|
|
3662
3708
|
const ListTasksRequestSchema = PaginatedRequestSchema.extend({ method: literal("tasks/list") });
|
|
@@ -3693,16 +3739,20 @@ const Base64Schema = string().refine((val) => {
|
|
|
3693
3739
|
try {
|
|
3694
3740
|
atob(val);
|
|
3695
3741
|
return true;
|
|
3696
|
-
} catch
|
|
3742
|
+
} catch {
|
|
3697
3743
|
return false;
|
|
3698
3744
|
}
|
|
3699
3745
|
}, { message: "Invalid Base64 string" });
|
|
3700
3746
|
const BlobResourceContentsSchema = ResourceContentsSchema.extend({ blob: Base64Schema });
|
|
3701
3747
|
/**
|
|
3748
|
+
* The sender or recipient of messages and data in a conversation.
|
|
3749
|
+
*/
|
|
3750
|
+
const RoleSchema = _enum(["user", "assistant"]);
|
|
3751
|
+
/**
|
|
3702
3752
|
* Optional annotations providing clients additional context about a resource.
|
|
3703
3753
|
*/
|
|
3704
3754
|
const AnnotationsSchema = object({
|
|
3705
|
-
audience: array(
|
|
3755
|
+
audience: array(RoleSchema).optional(),
|
|
3706
3756
|
priority: number().min(0).max(1).optional(),
|
|
3707
3757
|
lastModified: datetime({ offset: true }).optional()
|
|
3708
3758
|
});
|
|
@@ -3765,7 +3815,10 @@ const ReadResourceResultSchema = ResultSchema.extend({ contents: array(union([Te
|
|
|
3765
3815
|
/**
|
|
3766
3816
|
* An optional notification from the server to the client, informing it that the list of resources it can read from has changed. This may be issued by servers without any previous subscription from the client.
|
|
3767
3817
|
*/
|
|
3768
|
-
const ResourceListChangedNotificationSchema = NotificationSchema.extend({
|
|
3818
|
+
const ResourceListChangedNotificationSchema = NotificationSchema.extend({
|
|
3819
|
+
method: literal("notifications/resources/list_changed"),
|
|
3820
|
+
params: NotificationsParamsSchema.optional()
|
|
3821
|
+
});
|
|
3769
3822
|
const SubscribeRequestParamsSchema = ResourceRequestParamsSchema;
|
|
3770
3823
|
/**
|
|
3771
3824
|
* Sent from the client to request resources/updated notifications from the server whenever a particular resource changes.
|
|
@@ -3870,9 +3923,9 @@ const ToolUseContentSchema = object({
|
|
|
3870
3923
|
type: literal("tool_use"),
|
|
3871
3924
|
name: string(),
|
|
3872
3925
|
id: string(),
|
|
3873
|
-
input:
|
|
3874
|
-
_meta:
|
|
3875
|
-
})
|
|
3926
|
+
input: record(string(), unknown()),
|
|
3927
|
+
_meta: record(string(), unknown()).optional()
|
|
3928
|
+
});
|
|
3876
3929
|
/**
|
|
3877
3930
|
* The contents of a resource, embedded into a prompt or tool call result.
|
|
3878
3931
|
*/
|
|
@@ -3902,20 +3955,23 @@ const ContentBlockSchema = union([
|
|
|
3902
3955
|
* Describes a message returned as part of a prompt.
|
|
3903
3956
|
*/
|
|
3904
3957
|
const PromptMessageSchema = object({
|
|
3905
|
-
role:
|
|
3958
|
+
role: RoleSchema,
|
|
3906
3959
|
content: ContentBlockSchema
|
|
3907
3960
|
});
|
|
3908
3961
|
/**
|
|
3909
3962
|
* The server's response to a prompts/get request from the client.
|
|
3910
3963
|
*/
|
|
3911
3964
|
const GetPromptResultSchema = ResultSchema.extend({
|
|
3912
|
-
description:
|
|
3965
|
+
description: string().optional(),
|
|
3913
3966
|
messages: array(PromptMessageSchema)
|
|
3914
3967
|
});
|
|
3915
3968
|
/**
|
|
3916
3969
|
* An optional notification from the server to the client, informing it that the list of prompts it offers has changed. This may be issued by servers without any previous subscription from the client.
|
|
3917
3970
|
*/
|
|
3918
|
-
const PromptListChangedNotificationSchema = NotificationSchema.extend({
|
|
3971
|
+
const PromptListChangedNotificationSchema = NotificationSchema.extend({
|
|
3972
|
+
method: literal("notifications/prompts/list_changed"),
|
|
3973
|
+
params: NotificationsParamsSchema.optional()
|
|
3974
|
+
});
|
|
3919
3975
|
/**
|
|
3920
3976
|
* Additional properties describing a Tool to clients.
|
|
3921
3977
|
*
|
|
@@ -3958,8 +4014,8 @@ const ToolSchema = object({
|
|
|
3958
4014
|
properties: record(string(), AssertObjectSchema).optional(),
|
|
3959
4015
|
required: array(string()).optional()
|
|
3960
4016
|
}).catchall(unknown()).optional(),
|
|
3961
|
-
annotations: optional(
|
|
3962
|
-
execution: optional(
|
|
4017
|
+
annotations: ToolAnnotationsSchema.optional(),
|
|
4018
|
+
execution: ToolExecutionSchema.optional(),
|
|
3963
4019
|
_meta: record(string(), unknown()).optional()
|
|
3964
4020
|
});
|
|
3965
4021
|
/**
|
|
@@ -3976,7 +4032,7 @@ const ListToolsResultSchema = PaginatedResultSchema.extend({ tools: array(ToolSc
|
|
|
3976
4032
|
const CallToolResultSchema = ResultSchema.extend({
|
|
3977
4033
|
content: array(ContentBlockSchema).default([]),
|
|
3978
4034
|
structuredContent: record(string(), unknown()).optional(),
|
|
3979
|
-
isError:
|
|
4035
|
+
isError: boolean().optional()
|
|
3980
4036
|
});
|
|
3981
4037
|
/**
|
|
3982
4038
|
* CallToolResultSchema extended with backwards compatibility to protocol version 2024-10-07.
|
|
@@ -3985,9 +4041,9 @@ const CompatibilityCallToolResultSchema = CallToolResultSchema.or(ResultSchema.e
|
|
|
3985
4041
|
/**
|
|
3986
4042
|
* Parameters for a `tools/call` request.
|
|
3987
4043
|
*/
|
|
3988
|
-
const CallToolRequestParamsSchema =
|
|
4044
|
+
const CallToolRequestParamsSchema = TaskAugmentedRequestParamsSchema.extend({
|
|
3989
4045
|
name: string(),
|
|
3990
|
-
arguments:
|
|
4046
|
+
arguments: record(string(), unknown()).optional()
|
|
3991
4047
|
});
|
|
3992
4048
|
/**
|
|
3993
4049
|
* Used by the client to invoke a tool provided by the server.
|
|
@@ -3999,7 +4055,18 @@ const CallToolRequestSchema = RequestSchema.extend({
|
|
|
3999
4055
|
/**
|
|
4000
4056
|
* An optional notification from the server to the client, informing it that the list of tools it offers has changed. This may be issued by servers without any previous subscription from the client.
|
|
4001
4057
|
*/
|
|
4002
|
-
const ToolListChangedNotificationSchema = NotificationSchema.extend({
|
|
4058
|
+
const ToolListChangedNotificationSchema = NotificationSchema.extend({
|
|
4059
|
+
method: literal("notifications/tools/list_changed"),
|
|
4060
|
+
params: NotificationsParamsSchema.optional()
|
|
4061
|
+
});
|
|
4062
|
+
/**
|
|
4063
|
+
* Base schema for list changed subscription options (without callback).
|
|
4064
|
+
* Used internally for Zod validation of autoRefresh and debounceMs.
|
|
4065
|
+
*/
|
|
4066
|
+
const ListChangedOptionsBaseSchema = object({
|
|
4067
|
+
autoRefresh: boolean().default(true),
|
|
4068
|
+
debounceMs: number().int().nonnegative().default(300)
|
|
4069
|
+
});
|
|
4003
4070
|
/**
|
|
4004
4071
|
* The severity of a log message.
|
|
4005
4072
|
*/
|
|
@@ -4047,19 +4114,19 @@ const ModelHintSchema = object({ name: string().optional() });
|
|
|
4047
4114
|
* The server's preferences for model selection, requested of the client during sampling.
|
|
4048
4115
|
*/
|
|
4049
4116
|
const ModelPreferencesSchema = object({
|
|
4050
|
-
hints:
|
|
4051
|
-
costPriority:
|
|
4052
|
-
speedPriority:
|
|
4053
|
-
intelligencePriority:
|
|
4117
|
+
hints: array(ModelHintSchema).optional(),
|
|
4118
|
+
costPriority: number().min(0).max(1).optional(),
|
|
4119
|
+
speedPriority: number().min(0).max(1).optional(),
|
|
4120
|
+
intelligencePriority: number().min(0).max(1).optional()
|
|
4054
4121
|
});
|
|
4055
4122
|
/**
|
|
4056
4123
|
* Controls tool usage behavior in sampling requests.
|
|
4057
4124
|
*/
|
|
4058
|
-
const ToolChoiceSchema = object({ mode:
|
|
4125
|
+
const ToolChoiceSchema = object({ mode: _enum([
|
|
4059
4126
|
"auto",
|
|
4060
4127
|
"required",
|
|
4061
4128
|
"none"
|
|
4062
|
-
])) });
|
|
4129
|
+
]).optional() });
|
|
4063
4130
|
/**
|
|
4064
4131
|
* The result of a tool execution, provided by the user (server).
|
|
4065
4132
|
* Represents the outcome of invoking a tool requested via ToolUseContent.
|
|
@@ -4068,10 +4135,10 @@ const ToolResultContentSchema = object({
|
|
|
4068
4135
|
type: literal("tool_result"),
|
|
4069
4136
|
toolUseId: string().describe("The unique identifier for the corresponding tool call."),
|
|
4070
4137
|
content: array(ContentBlockSchema).default([]),
|
|
4071
|
-
structuredContent: object({}).
|
|
4072
|
-
isError:
|
|
4073
|
-
_meta:
|
|
4074
|
-
})
|
|
4138
|
+
structuredContent: object({}).loose().optional(),
|
|
4139
|
+
isError: boolean().optional(),
|
|
4140
|
+
_meta: record(string(), unknown()).optional()
|
|
4141
|
+
});
|
|
4075
4142
|
/**
|
|
4076
4143
|
* Basic content types for sampling responses (without tool use).
|
|
4077
4144
|
* Used for backwards-compatible CreateMessageResult when tools are not used.
|
|
@@ -4096,14 +4163,14 @@ const SamplingMessageContentBlockSchema = discriminatedUnion("type", [
|
|
|
4096
4163
|
* Describes a message issued to or received from an LLM API.
|
|
4097
4164
|
*/
|
|
4098
4165
|
const SamplingMessageSchema = object({
|
|
4099
|
-
role:
|
|
4166
|
+
role: RoleSchema,
|
|
4100
4167
|
content: union([SamplingMessageContentBlockSchema, array(SamplingMessageContentBlockSchema)]),
|
|
4101
|
-
_meta:
|
|
4102
|
-
})
|
|
4168
|
+
_meta: record(string(), unknown()).optional()
|
|
4169
|
+
});
|
|
4103
4170
|
/**
|
|
4104
4171
|
* Parameters for a `sampling/createMessage` request.
|
|
4105
4172
|
*/
|
|
4106
|
-
const CreateMessageRequestParamsSchema =
|
|
4173
|
+
const CreateMessageRequestParamsSchema = TaskAugmentedRequestParamsSchema.extend({
|
|
4107
4174
|
messages: array(SamplingMessageSchema),
|
|
4108
4175
|
modelPreferences: ModelPreferencesSchema.optional(),
|
|
4109
4176
|
systemPrompt: string().optional(),
|
|
@@ -4116,8 +4183,8 @@ const CreateMessageRequestParamsSchema = BaseRequestParamsSchema.extend({
|
|
|
4116
4183
|
maxTokens: number().int(),
|
|
4117
4184
|
stopSequences: array(string()).optional(),
|
|
4118
4185
|
metadata: AssertObjectSchema.optional(),
|
|
4119
|
-
tools:
|
|
4120
|
-
toolChoice: optional(
|
|
4186
|
+
tools: array(ToolSchema).optional(),
|
|
4187
|
+
toolChoice: ToolChoiceSchema.optional()
|
|
4121
4188
|
});
|
|
4122
4189
|
/**
|
|
4123
4190
|
* A request from the server to sample an LLM via the client. The client has full discretion over which model to select. The client should also inform the user before beginning sampling, to allow them to inspect the request (human in the loop) and decide whether to approve it.
|
|
@@ -4138,7 +4205,7 @@ const CreateMessageResultSchema = ResultSchema.extend({
|
|
|
4138
4205
|
"stopSequence",
|
|
4139
4206
|
"maxTokens"
|
|
4140
4207
|
]).or(string())),
|
|
4141
|
-
role:
|
|
4208
|
+
role: RoleSchema,
|
|
4142
4209
|
content: SamplingContentSchema
|
|
4143
4210
|
});
|
|
4144
4211
|
/**
|
|
@@ -4153,7 +4220,7 @@ const CreateMessageResultWithToolsSchema = ResultSchema.extend({
|
|
|
4153
4220
|
"maxTokens",
|
|
4154
4221
|
"toolUse"
|
|
4155
4222
|
]).or(string())),
|
|
4156
|
-
role:
|
|
4223
|
+
role: RoleSchema,
|
|
4157
4224
|
content: union([SamplingMessageContentBlockSchema, array(SamplingMessageContentBlockSchema)])
|
|
4158
4225
|
});
|
|
4159
4226
|
/**
|
|
@@ -4283,7 +4350,7 @@ const PrimitiveSchemaDefinitionSchema = union([
|
|
|
4283
4350
|
/**
|
|
4284
4351
|
* Parameters for an `elicitation/create` request for form-based elicitation.
|
|
4285
4352
|
*/
|
|
4286
|
-
const ElicitRequestFormParamsSchema =
|
|
4353
|
+
const ElicitRequestFormParamsSchema = TaskAugmentedRequestParamsSchema.extend({
|
|
4287
4354
|
mode: literal("form").optional(),
|
|
4288
4355
|
message: string(),
|
|
4289
4356
|
requestedSchema: object({
|
|
@@ -4295,7 +4362,7 @@ const ElicitRequestFormParamsSchema = BaseRequestParamsSchema.extend({
|
|
|
4295
4362
|
/**
|
|
4296
4363
|
* Parameters for an `elicitation/create` request for URL-based elicitation.
|
|
4297
4364
|
*/
|
|
4298
|
-
const ElicitRequestURLParamsSchema =
|
|
4365
|
+
const ElicitRequestURLParamsSchema = TaskAugmentedRequestParamsSchema.extend({
|
|
4299
4366
|
mode: literal("url"),
|
|
4300
4367
|
message: string(),
|
|
4301
4368
|
elicitationId: string(),
|
|
@@ -4396,7 +4463,10 @@ const RootSchema = object({
|
|
|
4396
4463
|
/**
|
|
4397
4464
|
* Sent from the server to request a list of root URIs from the client.
|
|
4398
4465
|
*/
|
|
4399
|
-
const ListRootsRequestSchema = RequestSchema.extend({
|
|
4466
|
+
const ListRootsRequestSchema = RequestSchema.extend({
|
|
4467
|
+
method: literal("roots/list"),
|
|
4468
|
+
params: BaseRequestParamsSchema.optional()
|
|
4469
|
+
});
|
|
4400
4470
|
/**
|
|
4401
4471
|
* The client's response to a roots/list request from the server.
|
|
4402
4472
|
*/
|
|
@@ -4404,7 +4474,10 @@ const ListRootsResultSchema = ResultSchema.extend({ roots: array(RootSchema) });
|
|
|
4404
4474
|
/**
|
|
4405
4475
|
* A notification from the client to the server, informing it that the list of roots has changed.
|
|
4406
4476
|
*/
|
|
4407
|
-
const RootsListChangedNotificationSchema = NotificationSchema.extend({
|
|
4477
|
+
const RootsListChangedNotificationSchema = NotificationSchema.extend({
|
|
4478
|
+
method: literal("notifications/roots/list_changed"),
|
|
4479
|
+
params: NotificationsParamsSchema.optional()
|
|
4480
|
+
});
|
|
4408
4481
|
const ClientRequestSchema = union([
|
|
4409
4482
|
PingRequestSchema,
|
|
4410
4483
|
InitializeRequestSchema,
|
|
@@ -4421,7 +4494,8 @@ const ClientRequestSchema = union([
|
|
|
4421
4494
|
ListToolsRequestSchema,
|
|
4422
4495
|
GetTaskRequestSchema,
|
|
4423
4496
|
GetTaskPayloadRequestSchema,
|
|
4424
|
-
ListTasksRequestSchema
|
|
4497
|
+
ListTasksRequestSchema,
|
|
4498
|
+
CancelTaskRequestSchema
|
|
4425
4499
|
]);
|
|
4426
4500
|
const ClientNotificationSchema = union([
|
|
4427
4501
|
CancelledNotificationSchema,
|
|
@@ -4447,7 +4521,8 @@ const ServerRequestSchema = union([
|
|
|
4447
4521
|
ListRootsRequestSchema,
|
|
4448
4522
|
GetTaskRequestSchema,
|
|
4449
4523
|
GetTaskPayloadRequestSchema,
|
|
4450
|
-
ListTasksRequestSchema
|
|
4524
|
+
ListTasksRequestSchema,
|
|
4525
|
+
CancelTaskRequestSchema
|
|
4451
4526
|
]);
|
|
4452
4527
|
const ServerNotificationSchema = union([
|
|
4453
4528
|
CancelledNotificationSchema,
|
|
@@ -4502,8 +4577,7 @@ var UrlElicitationRequiredError = class extends McpError {
|
|
|
4502
4577
|
super(ErrorCode.UrlElicitationRequired, message, { elicitations });
|
|
4503
4578
|
}
|
|
4504
4579
|
get elicitations() {
|
|
4505
|
-
|
|
4506
|
-
return (_b = (_a = this.data) === null || _a === void 0 ? void 0 : _a.elicitations) !== null && _b !== void 0 ? _b : [];
|
|
4580
|
+
return this.data?.elicitations ?? [];
|
|
4507
4581
|
}
|
|
4508
4582
|
};
|
|
4509
4583
|
|
|
@@ -5003,7 +5077,7 @@ var require_setprototypeof = /* @__PURE__ */ __commonJSMin(((exports, module) =>
|
|
|
5003
5077
|
}));
|
|
5004
5078
|
|
|
5005
5079
|
//#endregion
|
|
5006
|
-
//#region node_modules/.pnpm/statuses@2.0.
|
|
5080
|
+
//#region node_modules/.pnpm/statuses@2.0.2/node_modules/statuses/codes.json
|
|
5007
5081
|
var require_codes = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
5008
5082
|
module.exports = {
|
|
5009
5083
|
"100": "Continue",
|
|
@@ -5073,7 +5147,7 @@ var require_codes = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
5073
5147
|
}));
|
|
5074
5148
|
|
|
5075
5149
|
//#endregion
|
|
5076
|
-
//#region node_modules/.pnpm/statuses@2.0.
|
|
5150
|
+
//#region node_modules/.pnpm/statuses@2.0.2/node_modules/statuses/index.js
|
|
5077
5151
|
/*!
|
|
5078
5152
|
* statuses
|
|
5079
5153
|
* Copyright(c) 2014 Jonathan Ong
|
|
@@ -5241,7 +5315,7 @@ var require_toidentifier = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
5241
5315
|
}));
|
|
5242
5316
|
|
|
5243
5317
|
//#endregion
|
|
5244
|
-
//#region node_modules/.pnpm/http-errors@2.0.
|
|
5318
|
+
//#region node_modules/.pnpm/http-errors@2.0.1/node_modules/http-errors/index.js
|
|
5245
5319
|
/*!
|
|
5246
5320
|
* http-errors
|
|
5247
5321
|
* Copyright(c) 2014 Jonathan Ong
|
|
@@ -5430,10 +5504,13 @@ var require_http_errors = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
5430
5504
|
}
|
|
5431
5505
|
/**
|
|
5432
5506
|
* Get a class name from a name identifier.
|
|
5507
|
+
*
|
|
5508
|
+
* @param {string} name
|
|
5509
|
+
* @returns {string}
|
|
5433
5510
|
* @private
|
|
5434
5511
|
*/
|
|
5435
5512
|
function toClassName(name) {
|
|
5436
|
-
return name.
|
|
5513
|
+
return name.slice(-5) === "Error" ? name : name + "Error";
|
|
5437
5514
|
}
|
|
5438
5515
|
}));
|
|
5439
5516
|
|
|
@@ -14212,7 +14289,7 @@ var require_unpipe = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
14212
14289
|
}));
|
|
14213
14290
|
|
|
14214
14291
|
//#endregion
|
|
14215
|
-
//#region node_modules/.pnpm/raw-body@3.0.
|
|
14292
|
+
//#region node_modules/.pnpm/raw-body@3.0.2/node_modules/raw-body/index.js
|
|
14216
14293
|
/*!
|
|
14217
14294
|
* raw-body
|
|
14218
14295
|
* Copyright(c) 2013-2014 Jonathan Ong
|
|
@@ -14233,7 +14310,7 @@ var require_raw_body = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
14233
14310
|
* Module exports.
|
|
14234
14311
|
* @public
|
|
14235
14312
|
*/
|
|
14236
|
-
module.exports = getRawBody$
|
|
14313
|
+
module.exports = getRawBody$1;
|
|
14237
14314
|
/**
|
|
14238
14315
|
* Module variables.
|
|
14239
14316
|
* @private
|
|
@@ -14265,7 +14342,7 @@ var require_raw_body = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
14265
14342
|
* @param {function} [callback]
|
|
14266
14343
|
* @public
|
|
14267
14344
|
*/
|
|
14268
|
-
function getRawBody$
|
|
14345
|
+
function getRawBody$1(stream, options, callback) {
|
|
14269
14346
|
var done = callback;
|
|
14270
14347
|
var opts = options || {};
|
|
14271
14348
|
if (stream === void 0) throw new TypeError("argument stream is required");
|
|
@@ -14510,10 +14587,10 @@ var require_content_type = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
14510
14587
|
}));
|
|
14511
14588
|
|
|
14512
14589
|
//#endregion
|
|
14513
|
-
//#region node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
14514
|
-
var import_raw_body
|
|
14515
|
-
var import_content_type
|
|
14516
|
-
const MAXIMUM_MESSAGE_SIZE
|
|
14590
|
+
//#region node_modules/.pnpm/@modelcontextprotocol+sdk@1.27.1_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/server/sse.js
|
|
14591
|
+
var import_raw_body = /* @__PURE__ */ __toESM(require_raw_body(), 1);
|
|
14592
|
+
var import_content_type = /* @__PURE__ */ __toESM(require_content_type(), 1);
|
|
14593
|
+
const MAXIMUM_MESSAGE_SIZE = "4mb";
|
|
14517
14594
|
/**
|
|
14518
14595
|
* Server transport for SSE: this will send messages over an SSE connection and receive messages from HTTP POST requests.
|
|
14519
14596
|
*
|
|
@@ -14563,9 +14640,8 @@ var SSEServerTransport = class {
|
|
|
14563
14640
|
this.res.write(`event: endpoint\ndata: ${relativeUrlWithSession}\n\n`);
|
|
14564
14641
|
this._sseResponse = this.res;
|
|
14565
14642
|
this.res.on("close", () => {
|
|
14566
|
-
var _a;
|
|
14567
14643
|
this._sseResponse = void 0;
|
|
14568
|
-
|
|
14644
|
+
this.onclose?.();
|
|
14569
14645
|
});
|
|
14570
14646
|
}
|
|
14571
14647
|
/**
|
|
@@ -14574,7 +14650,6 @@ var SSEServerTransport = class {
|
|
|
14574
14650
|
* This should be called when a POST request is made to send a message to the server.
|
|
14575
14651
|
*/
|
|
14576
14652
|
async handlePostMessage(req, res, parsedBody) {
|
|
14577
|
-
var _a, _b, _c, _d;
|
|
14578
14653
|
if (!this._sseResponse) {
|
|
14579
14654
|
const message = "SSE connection not established";
|
|
14580
14655
|
res.writeHead(500).end(message);
|
|
@@ -14583,22 +14658,28 @@ var SSEServerTransport = class {
|
|
|
14583
14658
|
const validationError = this.validateRequestHeaders(req);
|
|
14584
14659
|
if (validationError) {
|
|
14585
14660
|
res.writeHead(403).end(validationError);
|
|
14586
|
-
|
|
14661
|
+
this.onerror?.(new Error(validationError));
|
|
14587
14662
|
return;
|
|
14588
14663
|
}
|
|
14589
14664
|
const authInfo = req.auth;
|
|
14590
|
-
const
|
|
14665
|
+
const host = req.headers.host;
|
|
14666
|
+
const protocol = req.socket instanceof TLSSocket ? "https" : "http";
|
|
14667
|
+
const fullUrl = host && req.url ? new URL$1(req.url, `${protocol}://${host}`) : void 0;
|
|
14668
|
+
const requestInfo = {
|
|
14669
|
+
headers: req.headers,
|
|
14670
|
+
url: fullUrl
|
|
14671
|
+
};
|
|
14591
14672
|
let body;
|
|
14592
14673
|
try {
|
|
14593
|
-
const ct = import_content_type
|
|
14674
|
+
const ct = import_content_type.parse(req.headers["content-type"] ?? "");
|
|
14594
14675
|
if (ct.type !== "application/json") throw new Error(`Unsupported content-type: ${ct.type}`);
|
|
14595
|
-
body = parsedBody
|
|
14596
|
-
limit: MAXIMUM_MESSAGE_SIZE
|
|
14597
|
-
encoding:
|
|
14676
|
+
body = parsedBody ?? await (0, import_raw_body.default)(req, {
|
|
14677
|
+
limit: MAXIMUM_MESSAGE_SIZE,
|
|
14678
|
+
encoding: ct.parameters.charset ?? "utf-8"
|
|
14598
14679
|
});
|
|
14599
14680
|
} catch (error$1) {
|
|
14600
14681
|
res.writeHead(400).end(String(error$1));
|
|
14601
|
-
|
|
14682
|
+
this.onerror?.(error$1);
|
|
14602
14683
|
return;
|
|
14603
14684
|
}
|
|
14604
14685
|
try {
|
|
@@ -14606,7 +14687,7 @@ var SSEServerTransport = class {
|
|
|
14606
14687
|
requestInfo,
|
|
14607
14688
|
authInfo
|
|
14608
14689
|
});
|
|
14609
|
-
} catch
|
|
14690
|
+
} catch {
|
|
14610
14691
|
res.writeHead(400).end(`Invalid message: ${body}`);
|
|
14611
14692
|
return;
|
|
14612
14693
|
}
|
|
@@ -14616,21 +14697,19 @@ var SSEServerTransport = class {
|
|
|
14616
14697
|
* Handle a client message, regardless of how it arrived. This can be used to inform the server of messages that arrive via a means different than HTTP POST.
|
|
14617
14698
|
*/
|
|
14618
14699
|
async handleMessage(message, extra) {
|
|
14619
|
-
var _a, _b;
|
|
14620
14700
|
let parsedMessage;
|
|
14621
14701
|
try {
|
|
14622
14702
|
parsedMessage = JSONRPCMessageSchema.parse(message);
|
|
14623
14703
|
} catch (error$1) {
|
|
14624
|
-
|
|
14704
|
+
this.onerror?.(error$1);
|
|
14625
14705
|
throw error$1;
|
|
14626
14706
|
}
|
|
14627
|
-
|
|
14707
|
+
this.onmessage?.(parsedMessage, extra);
|
|
14628
14708
|
}
|
|
14629
14709
|
async close() {
|
|
14630
|
-
|
|
14631
|
-
(_a = this._sseResponse) === null || _a === void 0 || _a.end();
|
|
14710
|
+
this._sseResponse?.end();
|
|
14632
14711
|
this._sseResponse = void 0;
|
|
14633
|
-
|
|
14712
|
+
this.onclose?.();
|
|
14634
14713
|
}
|
|
14635
14714
|
async send(message) {
|
|
14636
14715
|
if (!this._sseResponse) throw new Error("Not connected");
|
|
@@ -14647,31 +14726,469 @@ var SSEServerTransport = class {
|
|
|
14647
14726
|
};
|
|
14648
14727
|
|
|
14649
14728
|
//#endregion
|
|
14650
|
-
//#region node_modules/.pnpm/@
|
|
14651
|
-
var
|
|
14652
|
-
|
|
14653
|
-
|
|
14729
|
+
//#region node_modules/.pnpm/@hono+node-server@1.19.11_hono@4.12.7/node_modules/@hono/node-server/dist/index.mjs
|
|
14730
|
+
var RequestError = class extends Error {
|
|
14731
|
+
constructor(message, options) {
|
|
14732
|
+
super(message, options);
|
|
14733
|
+
this.name = "RequestError";
|
|
14734
|
+
}
|
|
14735
|
+
};
|
|
14736
|
+
var toRequestError = (e) => {
|
|
14737
|
+
if (e instanceof RequestError) return e;
|
|
14738
|
+
return new RequestError(e.message, { cause: e });
|
|
14739
|
+
};
|
|
14740
|
+
var GlobalRequest = global.Request;
|
|
14741
|
+
var Request = class extends GlobalRequest {
|
|
14742
|
+
constructor(input, options) {
|
|
14743
|
+
if (typeof input === "object" && getRequestCache in input) input = input[getRequestCache]();
|
|
14744
|
+
if (typeof options?.body?.getReader !== "undefined") options.duplex ??= "half";
|
|
14745
|
+
super(input, options);
|
|
14746
|
+
}
|
|
14747
|
+
};
|
|
14748
|
+
var newHeadersFromIncoming = (incoming) => {
|
|
14749
|
+
const headerRecord = [];
|
|
14750
|
+
const rawHeaders = incoming.rawHeaders;
|
|
14751
|
+
for (let i$3 = 0; i$3 < rawHeaders.length; i$3 += 2) {
|
|
14752
|
+
const { [i$3]: key$1, [i$3 + 1]: value } = rawHeaders;
|
|
14753
|
+
if (key$1.charCodeAt(0) !== 58) headerRecord.push([key$1, value]);
|
|
14754
|
+
}
|
|
14755
|
+
return new Headers(headerRecord);
|
|
14756
|
+
};
|
|
14757
|
+
var wrapBodyStream = Symbol("wrapBodyStream");
|
|
14758
|
+
var newRequestFromIncoming = (method, url$1, headers, incoming, abortController) => {
|
|
14759
|
+
const init = {
|
|
14760
|
+
method,
|
|
14761
|
+
headers,
|
|
14762
|
+
signal: abortController.signal
|
|
14763
|
+
};
|
|
14764
|
+
if (method === "TRACE") {
|
|
14765
|
+
init.method = "GET";
|
|
14766
|
+
const req = new Request(url$1, init);
|
|
14767
|
+
Object.defineProperty(req, "method", { get() {
|
|
14768
|
+
return "TRACE";
|
|
14769
|
+
} });
|
|
14770
|
+
return req;
|
|
14771
|
+
}
|
|
14772
|
+
if (!(method === "GET" || method === "HEAD")) if ("rawBody" in incoming && incoming.rawBody instanceof Buffer) init.body = new ReadableStream({ start(controller) {
|
|
14773
|
+
controller.enqueue(incoming.rawBody);
|
|
14774
|
+
controller.close();
|
|
14775
|
+
} });
|
|
14776
|
+
else if (incoming[wrapBodyStream]) {
|
|
14777
|
+
let reader;
|
|
14778
|
+
init.body = new ReadableStream({ async pull(controller) {
|
|
14779
|
+
try {
|
|
14780
|
+
reader ||= Readable.toWeb(incoming).getReader();
|
|
14781
|
+
const { done, value } = await reader.read();
|
|
14782
|
+
if (done) controller.close();
|
|
14783
|
+
else controller.enqueue(value);
|
|
14784
|
+
} catch (error$1) {
|
|
14785
|
+
controller.error(error$1);
|
|
14786
|
+
}
|
|
14787
|
+
} });
|
|
14788
|
+
} else init.body = Readable.toWeb(incoming);
|
|
14789
|
+
return new Request(url$1, init);
|
|
14790
|
+
};
|
|
14791
|
+
var getRequestCache = Symbol("getRequestCache");
|
|
14792
|
+
var requestCache = Symbol("requestCache");
|
|
14793
|
+
var incomingKey = Symbol("incomingKey");
|
|
14794
|
+
var urlKey = Symbol("urlKey");
|
|
14795
|
+
var headersKey = Symbol("headersKey");
|
|
14796
|
+
var abortControllerKey = Symbol("abortControllerKey");
|
|
14797
|
+
var requestPrototype = {
|
|
14798
|
+
get method() {
|
|
14799
|
+
return this[incomingKey].method || "GET";
|
|
14800
|
+
},
|
|
14801
|
+
get url() {
|
|
14802
|
+
return this[urlKey];
|
|
14803
|
+
},
|
|
14804
|
+
get headers() {
|
|
14805
|
+
return this[headersKey] ||= newHeadersFromIncoming(this[incomingKey]);
|
|
14806
|
+
},
|
|
14807
|
+
[Symbol("getAbortController")]() {
|
|
14808
|
+
this[getRequestCache]();
|
|
14809
|
+
return this[abortControllerKey];
|
|
14810
|
+
},
|
|
14811
|
+
[getRequestCache]() {
|
|
14812
|
+
this[abortControllerKey] ||= new AbortController();
|
|
14813
|
+
return this[requestCache] ||= newRequestFromIncoming(this.method, this[urlKey], this.headers, this[incomingKey], this[abortControllerKey]);
|
|
14814
|
+
}
|
|
14815
|
+
};
|
|
14816
|
+
[
|
|
14817
|
+
"body",
|
|
14818
|
+
"bodyUsed",
|
|
14819
|
+
"cache",
|
|
14820
|
+
"credentials",
|
|
14821
|
+
"destination",
|
|
14822
|
+
"integrity",
|
|
14823
|
+
"mode",
|
|
14824
|
+
"redirect",
|
|
14825
|
+
"referrer",
|
|
14826
|
+
"referrerPolicy",
|
|
14827
|
+
"signal",
|
|
14828
|
+
"keepalive"
|
|
14829
|
+
].forEach((k) => {
|
|
14830
|
+
Object.defineProperty(requestPrototype, k, { get() {
|
|
14831
|
+
return this[getRequestCache]()[k];
|
|
14832
|
+
} });
|
|
14833
|
+
});
|
|
14834
|
+
[
|
|
14835
|
+
"arrayBuffer",
|
|
14836
|
+
"blob",
|
|
14837
|
+
"clone",
|
|
14838
|
+
"formData",
|
|
14839
|
+
"json",
|
|
14840
|
+
"text"
|
|
14841
|
+
].forEach((k) => {
|
|
14842
|
+
Object.defineProperty(requestPrototype, k, { value: function() {
|
|
14843
|
+
return this[getRequestCache]()[k]();
|
|
14844
|
+
} });
|
|
14845
|
+
});
|
|
14846
|
+
Object.setPrototypeOf(requestPrototype, Request.prototype);
|
|
14847
|
+
var newRequest = (incoming, defaultHostname) => {
|
|
14848
|
+
const req = Object.create(requestPrototype);
|
|
14849
|
+
req[incomingKey] = incoming;
|
|
14850
|
+
const incomingUrl = incoming.url || "";
|
|
14851
|
+
if (incomingUrl[0] !== "/" && (incomingUrl.startsWith("http://") || incomingUrl.startsWith("https://"))) {
|
|
14852
|
+
if (incoming instanceof Http2ServerRequest) throw new RequestError("Absolute URL for :path is not allowed in HTTP/2");
|
|
14853
|
+
try {
|
|
14854
|
+
req[urlKey] = new URL(incomingUrl).href;
|
|
14855
|
+
} catch (e) {
|
|
14856
|
+
throw new RequestError("Invalid absolute URL", { cause: e });
|
|
14857
|
+
}
|
|
14858
|
+
return req;
|
|
14859
|
+
}
|
|
14860
|
+
const host = (incoming instanceof Http2ServerRequest ? incoming.authority : incoming.headers.host) || defaultHostname;
|
|
14861
|
+
if (!host) throw new RequestError("Missing host header");
|
|
14862
|
+
let scheme;
|
|
14863
|
+
if (incoming instanceof Http2ServerRequest) {
|
|
14864
|
+
scheme = incoming.scheme;
|
|
14865
|
+
if (!(scheme === "http" || scheme === "https")) throw new RequestError("Unsupported scheme");
|
|
14866
|
+
} else scheme = incoming.socket && incoming.socket.encrypted ? "https" : "http";
|
|
14867
|
+
const url$1 = new URL(`${scheme}://${host}${incomingUrl}`);
|
|
14868
|
+
if (url$1.hostname.length !== host.length && url$1.hostname !== host.replace(/:\d+$/, "")) throw new RequestError("Invalid host header");
|
|
14869
|
+
req[urlKey] = url$1.href;
|
|
14870
|
+
return req;
|
|
14871
|
+
};
|
|
14872
|
+
var responseCache = Symbol("responseCache");
|
|
14873
|
+
var getResponseCache = Symbol("getResponseCache");
|
|
14874
|
+
var cacheKey = Symbol("cache");
|
|
14875
|
+
var GlobalResponse = global.Response;
|
|
14876
|
+
var Response2 = class _Response {
|
|
14877
|
+
#body;
|
|
14878
|
+
#init;
|
|
14879
|
+
[getResponseCache]() {
|
|
14880
|
+
delete this[cacheKey];
|
|
14881
|
+
return this[responseCache] ||= new GlobalResponse(this.#body, this.#init);
|
|
14882
|
+
}
|
|
14883
|
+
constructor(body, init) {
|
|
14884
|
+
let headers;
|
|
14885
|
+
this.#body = body;
|
|
14886
|
+
if (init instanceof _Response) {
|
|
14887
|
+
const cachedGlobalResponse = init[responseCache];
|
|
14888
|
+
if (cachedGlobalResponse) {
|
|
14889
|
+
this.#init = cachedGlobalResponse;
|
|
14890
|
+
this[getResponseCache]();
|
|
14891
|
+
return;
|
|
14892
|
+
} else {
|
|
14893
|
+
this.#init = init.#init;
|
|
14894
|
+
headers = new Headers(init.#init.headers);
|
|
14895
|
+
}
|
|
14896
|
+
} else this.#init = init;
|
|
14897
|
+
if (typeof body === "string" || typeof body?.getReader !== "undefined" || body instanceof Blob || body instanceof Uint8Array) this[cacheKey] = [
|
|
14898
|
+
init?.status || 200,
|
|
14899
|
+
body,
|
|
14900
|
+
headers || init?.headers
|
|
14901
|
+
];
|
|
14902
|
+
}
|
|
14903
|
+
get headers() {
|
|
14904
|
+
const cache = this[cacheKey];
|
|
14905
|
+
if (cache) {
|
|
14906
|
+
if (!(cache[2] instanceof Headers)) cache[2] = new Headers(cache[2] || { "content-type": "text/plain; charset=UTF-8" });
|
|
14907
|
+
return cache[2];
|
|
14908
|
+
}
|
|
14909
|
+
return this[getResponseCache]().headers;
|
|
14910
|
+
}
|
|
14911
|
+
get status() {
|
|
14912
|
+
return this[cacheKey]?.[0] ?? this[getResponseCache]().status;
|
|
14913
|
+
}
|
|
14914
|
+
get ok() {
|
|
14915
|
+
const status$1 = this.status;
|
|
14916
|
+
return status$1 >= 200 && status$1 < 300;
|
|
14917
|
+
}
|
|
14918
|
+
};
|
|
14919
|
+
[
|
|
14920
|
+
"body",
|
|
14921
|
+
"bodyUsed",
|
|
14922
|
+
"redirected",
|
|
14923
|
+
"statusText",
|
|
14924
|
+
"trailers",
|
|
14925
|
+
"type",
|
|
14926
|
+
"url"
|
|
14927
|
+
].forEach((k) => {
|
|
14928
|
+
Object.defineProperty(Response2.prototype, k, { get() {
|
|
14929
|
+
return this[getResponseCache]()[k];
|
|
14930
|
+
} });
|
|
14931
|
+
});
|
|
14932
|
+
[
|
|
14933
|
+
"arrayBuffer",
|
|
14934
|
+
"blob",
|
|
14935
|
+
"clone",
|
|
14936
|
+
"formData",
|
|
14937
|
+
"json",
|
|
14938
|
+
"text"
|
|
14939
|
+
].forEach((k) => {
|
|
14940
|
+
Object.defineProperty(Response2.prototype, k, { value: function() {
|
|
14941
|
+
return this[getResponseCache]()[k]();
|
|
14942
|
+
} });
|
|
14943
|
+
});
|
|
14944
|
+
Object.setPrototypeOf(Response2, GlobalResponse);
|
|
14945
|
+
Object.setPrototypeOf(Response2.prototype, GlobalResponse.prototype);
|
|
14946
|
+
async function readWithoutBlocking(readPromise) {
|
|
14947
|
+
return Promise.race([readPromise, Promise.resolve().then(() => Promise.resolve(void 0))]);
|
|
14948
|
+
}
|
|
14949
|
+
function writeFromReadableStreamDefaultReader(reader, writable, currentReadPromise) {
|
|
14950
|
+
const cancel = (error$1) => {
|
|
14951
|
+
reader.cancel(error$1).catch(() => {});
|
|
14952
|
+
};
|
|
14953
|
+
writable.on("close", cancel);
|
|
14954
|
+
writable.on("error", cancel);
|
|
14955
|
+
(currentReadPromise ?? reader.read()).then(flow, handleStreamError);
|
|
14956
|
+
return reader.closed.finally(() => {
|
|
14957
|
+
writable.off("close", cancel);
|
|
14958
|
+
writable.off("error", cancel);
|
|
14959
|
+
});
|
|
14960
|
+
function handleStreamError(error$1) {
|
|
14961
|
+
if (error$1) writable.destroy(error$1);
|
|
14962
|
+
}
|
|
14963
|
+
function onDrain() {
|
|
14964
|
+
reader.read().then(flow, handleStreamError);
|
|
14965
|
+
}
|
|
14966
|
+
function flow({ done, value }) {
|
|
14967
|
+
try {
|
|
14968
|
+
if (done) writable.end();
|
|
14969
|
+
else if (!writable.write(value)) writable.once("drain", onDrain);
|
|
14970
|
+
else return reader.read().then(flow, handleStreamError);
|
|
14971
|
+
} catch (e) {
|
|
14972
|
+
handleStreamError(e);
|
|
14973
|
+
}
|
|
14974
|
+
}
|
|
14975
|
+
}
|
|
14976
|
+
function writeFromReadableStream(stream, writable) {
|
|
14977
|
+
if (stream.locked) throw new TypeError("ReadableStream is locked.");
|
|
14978
|
+
else if (writable.destroyed) return;
|
|
14979
|
+
return writeFromReadableStreamDefaultReader(stream.getReader(), writable);
|
|
14980
|
+
}
|
|
14981
|
+
var buildOutgoingHttpHeaders = (headers) => {
|
|
14982
|
+
const res = {};
|
|
14983
|
+
if (!(headers instanceof Headers)) headers = new Headers(headers ?? void 0);
|
|
14984
|
+
const cookies = [];
|
|
14985
|
+
for (const [k, v] of headers) if (k === "set-cookie") cookies.push(v);
|
|
14986
|
+
else res[k] = v;
|
|
14987
|
+
if (cookies.length > 0) res["set-cookie"] = cookies;
|
|
14988
|
+
res["content-type"] ??= "text/plain; charset=UTF-8";
|
|
14989
|
+
return res;
|
|
14990
|
+
};
|
|
14991
|
+
var X_ALREADY_SENT = "x-hono-already-sent";
|
|
14992
|
+
if (typeof global.crypto === "undefined") global.crypto = crypto$1;
|
|
14993
|
+
var outgoingEnded = Symbol("outgoingEnded");
|
|
14994
|
+
var handleRequestError = () => new Response(null, { status: 400 });
|
|
14995
|
+
var handleFetchError = (e) => new Response(null, { status: e instanceof Error && (e.name === "TimeoutError" || e.constructor.name === "TimeoutError") ? 504 : 500 });
|
|
14996
|
+
var handleResponseError$1 = (e, outgoing) => {
|
|
14997
|
+
const err = e instanceof Error ? e : new Error("unknown error", { cause: e });
|
|
14998
|
+
if (err.code === "ERR_STREAM_PREMATURE_CLOSE") console.info("The user aborted a request.");
|
|
14999
|
+
else {
|
|
15000
|
+
console.error(e);
|
|
15001
|
+
if (!outgoing.headersSent) outgoing.writeHead(500, { "Content-Type": "text/plain" });
|
|
15002
|
+
outgoing.end(`Error: ${err.message}`);
|
|
15003
|
+
outgoing.destroy(err);
|
|
15004
|
+
}
|
|
15005
|
+
};
|
|
15006
|
+
var flushHeaders = (outgoing) => {
|
|
15007
|
+
if ("flushHeaders" in outgoing && outgoing.writable) outgoing.flushHeaders();
|
|
15008
|
+
};
|
|
15009
|
+
var responseViaCache = async (res, outgoing) => {
|
|
15010
|
+
let [status$1, body, header] = res[cacheKey];
|
|
15011
|
+
let hasContentLength = false;
|
|
15012
|
+
if (!header) header = { "content-type": "text/plain; charset=UTF-8" };
|
|
15013
|
+
else if (header instanceof Headers) {
|
|
15014
|
+
hasContentLength = header.has("content-length");
|
|
15015
|
+
header = buildOutgoingHttpHeaders(header);
|
|
15016
|
+
} else if (Array.isArray(header)) {
|
|
15017
|
+
const headerObj = new Headers(header);
|
|
15018
|
+
hasContentLength = headerObj.has("content-length");
|
|
15019
|
+
header = buildOutgoingHttpHeaders(headerObj);
|
|
15020
|
+
} else for (const key$1 in header) if (key$1.length === 14 && key$1.toLowerCase() === "content-length") {
|
|
15021
|
+
hasContentLength = true;
|
|
15022
|
+
break;
|
|
15023
|
+
}
|
|
15024
|
+
if (!hasContentLength) {
|
|
15025
|
+
if (typeof body === "string") header["Content-Length"] = Buffer.byteLength(body);
|
|
15026
|
+
else if (body instanceof Uint8Array) header["Content-Length"] = body.byteLength;
|
|
15027
|
+
else if (body instanceof Blob) header["Content-Length"] = body.size;
|
|
15028
|
+
}
|
|
15029
|
+
outgoing.writeHead(status$1, header);
|
|
15030
|
+
if (typeof body === "string" || body instanceof Uint8Array) outgoing.end(body);
|
|
15031
|
+
else if (body instanceof Blob) outgoing.end(new Uint8Array(await body.arrayBuffer()));
|
|
15032
|
+
else {
|
|
15033
|
+
flushHeaders(outgoing);
|
|
15034
|
+
await writeFromReadableStream(body, outgoing)?.catch((e) => handleResponseError$1(e, outgoing));
|
|
15035
|
+
}
|
|
15036
|
+
outgoing[outgoingEnded]?.();
|
|
15037
|
+
};
|
|
15038
|
+
var isPromise = (res) => typeof res.then === "function";
|
|
15039
|
+
var responseViaResponseObject = async (res, outgoing, options = {}) => {
|
|
15040
|
+
if (isPromise(res)) if (options.errorHandler) try {
|
|
15041
|
+
res = await res;
|
|
15042
|
+
} catch (err) {
|
|
15043
|
+
const errRes = await options.errorHandler(err);
|
|
15044
|
+
if (!errRes) return;
|
|
15045
|
+
res = errRes;
|
|
15046
|
+
}
|
|
15047
|
+
else res = await res.catch(handleFetchError);
|
|
15048
|
+
if (cacheKey in res) return responseViaCache(res, outgoing);
|
|
15049
|
+
const resHeaderRecord = buildOutgoingHttpHeaders(res.headers);
|
|
15050
|
+
if (res.body) {
|
|
15051
|
+
const reader = res.body.getReader();
|
|
15052
|
+
const values = [];
|
|
15053
|
+
let done = false;
|
|
15054
|
+
let currentReadPromise = void 0;
|
|
15055
|
+
if (resHeaderRecord["transfer-encoding"] !== "chunked") {
|
|
15056
|
+
let maxReadCount = 2;
|
|
15057
|
+
for (let i$3 = 0; i$3 < maxReadCount; i$3++) {
|
|
15058
|
+
currentReadPromise ||= reader.read();
|
|
15059
|
+
const chunk = await readWithoutBlocking(currentReadPromise).catch((e) => {
|
|
15060
|
+
console.error(e);
|
|
15061
|
+
done = true;
|
|
15062
|
+
});
|
|
15063
|
+
if (!chunk) {
|
|
15064
|
+
if (i$3 === 1) {
|
|
15065
|
+
await new Promise((resolve$2) => setTimeout(resolve$2));
|
|
15066
|
+
maxReadCount = 3;
|
|
15067
|
+
continue;
|
|
15068
|
+
}
|
|
15069
|
+
break;
|
|
15070
|
+
}
|
|
15071
|
+
currentReadPromise = void 0;
|
|
15072
|
+
if (chunk.value) values.push(chunk.value);
|
|
15073
|
+
if (chunk.done) {
|
|
15074
|
+
done = true;
|
|
15075
|
+
break;
|
|
15076
|
+
}
|
|
15077
|
+
}
|
|
15078
|
+
if (done && !("content-length" in resHeaderRecord)) resHeaderRecord["content-length"] = values.reduce((acc, value) => acc + value.length, 0);
|
|
15079
|
+
}
|
|
15080
|
+
outgoing.writeHead(res.status, resHeaderRecord);
|
|
15081
|
+
values.forEach((value) => {
|
|
15082
|
+
outgoing.write(value);
|
|
15083
|
+
});
|
|
15084
|
+
if (done) outgoing.end();
|
|
15085
|
+
else {
|
|
15086
|
+
if (values.length === 0) flushHeaders(outgoing);
|
|
15087
|
+
await writeFromReadableStreamDefaultReader(reader, outgoing, currentReadPromise);
|
|
15088
|
+
}
|
|
15089
|
+
} else if (resHeaderRecord[X_ALREADY_SENT]) {} else {
|
|
15090
|
+
outgoing.writeHead(res.status, resHeaderRecord);
|
|
15091
|
+
outgoing.end();
|
|
15092
|
+
}
|
|
15093
|
+
outgoing[outgoingEnded]?.();
|
|
15094
|
+
};
|
|
15095
|
+
var getRequestListener = (fetchCallback, options = {}) => {
|
|
15096
|
+
const autoCleanupIncoming = options.autoCleanupIncoming ?? true;
|
|
15097
|
+
if (options.overrideGlobalObjects !== false && global.Request !== Request) {
|
|
15098
|
+
Object.defineProperty(global, "Request", { value: Request });
|
|
15099
|
+
Object.defineProperty(global, "Response", { value: Response2 });
|
|
15100
|
+
}
|
|
15101
|
+
return async (incoming, outgoing) => {
|
|
15102
|
+
let res, req;
|
|
15103
|
+
try {
|
|
15104
|
+
req = newRequest(incoming, options.hostname);
|
|
15105
|
+
let incomingEnded = !autoCleanupIncoming || incoming.method === "GET" || incoming.method === "HEAD";
|
|
15106
|
+
if (!incomingEnded) {
|
|
15107
|
+
incoming[wrapBodyStream] = true;
|
|
15108
|
+
incoming.on("end", () => {
|
|
15109
|
+
incomingEnded = true;
|
|
15110
|
+
});
|
|
15111
|
+
if (incoming instanceof Http2ServerRequest) outgoing[outgoingEnded] = () => {
|
|
15112
|
+
if (!incomingEnded) setTimeout(() => {
|
|
15113
|
+
if (!incomingEnded) setTimeout(() => {
|
|
15114
|
+
incoming.destroy();
|
|
15115
|
+
outgoing.destroy();
|
|
15116
|
+
});
|
|
15117
|
+
});
|
|
15118
|
+
};
|
|
15119
|
+
}
|
|
15120
|
+
outgoing.on("close", () => {
|
|
15121
|
+
if (req[abortControllerKey]) {
|
|
15122
|
+
if (incoming.errored) req[abortControllerKey].abort(incoming.errored.toString());
|
|
15123
|
+
else if (!outgoing.writableFinished) req[abortControllerKey].abort("Client connection prematurely closed.");
|
|
15124
|
+
}
|
|
15125
|
+
if (!incomingEnded) setTimeout(() => {
|
|
15126
|
+
if (!incomingEnded) setTimeout(() => {
|
|
15127
|
+
incoming.destroy();
|
|
15128
|
+
});
|
|
15129
|
+
});
|
|
15130
|
+
});
|
|
15131
|
+
res = fetchCallback(req, {
|
|
15132
|
+
incoming,
|
|
15133
|
+
outgoing
|
|
15134
|
+
});
|
|
15135
|
+
if (cacheKey in res) return responseViaCache(res, outgoing);
|
|
15136
|
+
} catch (e) {
|
|
15137
|
+
if (!res) if (options.errorHandler) {
|
|
15138
|
+
res = await options.errorHandler(req ? e : toRequestError(e));
|
|
15139
|
+
if (!res) return;
|
|
15140
|
+
} else if (!req) res = handleRequestError();
|
|
15141
|
+
else res = handleFetchError(e);
|
|
15142
|
+
else return handleResponseError$1(e, outgoing);
|
|
15143
|
+
}
|
|
15144
|
+
try {
|
|
15145
|
+
return await responseViaResponseObject(res, outgoing, options);
|
|
15146
|
+
} catch (e) {
|
|
15147
|
+
return handleResponseError$1(e, outgoing);
|
|
15148
|
+
}
|
|
15149
|
+
};
|
|
15150
|
+
};
|
|
15151
|
+
|
|
15152
|
+
//#endregion
|
|
15153
|
+
//#region node_modules/.pnpm/@modelcontextprotocol+sdk@1.27.1_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/server/webStandardStreamableHttp.js
|
|
14654
15154
|
/**
|
|
14655
|
-
*
|
|
14656
|
-
*
|
|
15155
|
+
* Web Standards Streamable HTTP Server Transport
|
|
15156
|
+
*
|
|
15157
|
+
* This is the core transport implementation using Web Standard APIs (Request, Response, ReadableStream).
|
|
15158
|
+
* It can run on any runtime that supports Web Standards: Node.js 18+, Cloudflare Workers, Deno, Bun, etc.
|
|
15159
|
+
*
|
|
15160
|
+
* For Node.js Express/HTTP compatibility, use `StreamableHTTPServerTransport` which wraps this transport.
|
|
15161
|
+
*/
|
|
15162
|
+
/**
|
|
15163
|
+
* Server transport for Web Standards Streamable HTTP: this implements the MCP Streamable HTTP transport specification
|
|
15164
|
+
* using Web Standard APIs (Request, Response, ReadableStream).
|
|
15165
|
+
*
|
|
15166
|
+
* This transport works on any runtime that supports Web Standards: Node.js 18+, Cloudflare Workers, Deno, Bun, etc.
|
|
14657
15167
|
*
|
|
14658
15168
|
* Usage example:
|
|
14659
15169
|
*
|
|
14660
15170
|
* ```typescript
|
|
14661
15171
|
* // Stateful mode - server sets the session ID
|
|
14662
|
-
* const statefulTransport = new
|
|
14663
|
-
* sessionIdGenerator: () => randomUUID(),
|
|
15172
|
+
* const statefulTransport = new WebStandardStreamableHTTPServerTransport({
|
|
15173
|
+
* sessionIdGenerator: () => crypto.randomUUID(),
|
|
14664
15174
|
* });
|
|
14665
15175
|
*
|
|
14666
15176
|
* // Stateless mode - explicitly set session ID to undefined
|
|
14667
|
-
* const statelessTransport = new
|
|
15177
|
+
* const statelessTransport = new WebStandardStreamableHTTPServerTransport({
|
|
14668
15178
|
* sessionIdGenerator: undefined,
|
|
14669
15179
|
* });
|
|
14670
15180
|
*
|
|
14671
|
-
* //
|
|
14672
|
-
* app.
|
|
14673
|
-
* transport.handleRequest(req
|
|
15181
|
+
* // Hono.js usage
|
|
15182
|
+
* app.all('/mcp', async (c) => {
|
|
15183
|
+
* return transport.handleRequest(c.req.raw);
|
|
14674
15184
|
* });
|
|
15185
|
+
*
|
|
15186
|
+
* // Cloudflare Workers usage
|
|
15187
|
+
* export default {
|
|
15188
|
+
* async fetch(request: Request): Promise<Response> {
|
|
15189
|
+
* return transport.handleRequest(request);
|
|
15190
|
+
* }
|
|
15191
|
+
* };
|
|
14675
15192
|
* ```
|
|
14676
15193
|
*
|
|
14677
15194
|
* In stateful mode:
|
|
@@ -14685,10 +15202,10 @@ const MAXIMUM_MESSAGE_SIZE = "4mb";
|
|
|
14685
15202
|
* - No Session ID is included in any responses
|
|
14686
15203
|
* - No session validation is performed
|
|
14687
15204
|
*/
|
|
14688
|
-
var
|
|
14689
|
-
constructor(options) {
|
|
14690
|
-
var _a, _b;
|
|
15205
|
+
var WebStandardStreamableHTTPServerTransport = class {
|
|
15206
|
+
constructor(options = {}) {
|
|
14691
15207
|
this._started = false;
|
|
15208
|
+
this._hasHandledRequest = false;
|
|
14692
15209
|
this._streamMapping = /* @__PURE__ */ new Map();
|
|
14693
15210
|
this._requestToStreamMapping = /* @__PURE__ */ new Map();
|
|
14694
15211
|
this._requestResponseMap = /* @__PURE__ */ new Map();
|
|
@@ -14696,13 +15213,13 @@ var StreamableHTTPServerTransport = class {
|
|
|
14696
15213
|
this._enableJsonResponse = false;
|
|
14697
15214
|
this._standaloneSseStreamId = "_GET_stream";
|
|
14698
15215
|
this.sessionIdGenerator = options.sessionIdGenerator;
|
|
14699
|
-
this._enableJsonResponse =
|
|
15216
|
+
this._enableJsonResponse = options.enableJsonResponse ?? false;
|
|
14700
15217
|
this._eventStore = options.eventStore;
|
|
14701
15218
|
this._onsessioninitialized = options.onsessioninitialized;
|
|
14702
15219
|
this._onsessionclosed = options.onsessionclosed;
|
|
14703
15220
|
this._allowedHosts = options.allowedHosts;
|
|
14704
15221
|
this._allowedOrigins = options.allowedOrigins;
|
|
14705
|
-
this._enableDnsRebindingProtection =
|
|
15222
|
+
this._enableDnsRebindingProtection = options.enableDnsRebindingProtection ?? false;
|
|
14706
15223
|
this._retryInterval = options.retryInterval;
|
|
14707
15224
|
}
|
|
14708
15225
|
/**
|
|
@@ -14714,140 +15231,146 @@ var StreamableHTTPServerTransport = class {
|
|
|
14714
15231
|
this._started = true;
|
|
14715
15232
|
}
|
|
14716
15233
|
/**
|
|
15234
|
+
* Helper to create a JSON error response
|
|
15235
|
+
*/
|
|
15236
|
+
createJsonErrorResponse(status$1, code, message, options) {
|
|
15237
|
+
const error$1 = {
|
|
15238
|
+
code,
|
|
15239
|
+
message
|
|
15240
|
+
};
|
|
15241
|
+
if (options?.data !== void 0) error$1.data = options.data;
|
|
15242
|
+
return new Response(JSON.stringify({
|
|
15243
|
+
jsonrpc: "2.0",
|
|
15244
|
+
error: error$1,
|
|
15245
|
+
id: null
|
|
15246
|
+
}), {
|
|
15247
|
+
status: status$1,
|
|
15248
|
+
headers: {
|
|
15249
|
+
"Content-Type": "application/json",
|
|
15250
|
+
...options?.headers
|
|
15251
|
+
}
|
|
15252
|
+
});
|
|
15253
|
+
}
|
|
15254
|
+
/**
|
|
14717
15255
|
* Validates request headers for DNS rebinding protection.
|
|
14718
|
-
* @returns Error
|
|
15256
|
+
* @returns Error response if validation fails, undefined if validation passes.
|
|
14719
15257
|
*/
|
|
14720
15258
|
validateRequestHeaders(req) {
|
|
14721
15259
|
if (!this._enableDnsRebindingProtection) return;
|
|
14722
15260
|
if (this._allowedHosts && this._allowedHosts.length > 0) {
|
|
14723
|
-
const hostHeader = req.headers.host;
|
|
14724
|
-
if (!hostHeader || !this._allowedHosts.includes(hostHeader))
|
|
15261
|
+
const hostHeader = req.headers.get("host");
|
|
15262
|
+
if (!hostHeader || !this._allowedHosts.includes(hostHeader)) {
|
|
15263
|
+
const error$1 = `Invalid Host header: ${hostHeader}`;
|
|
15264
|
+
this.onerror?.(new Error(error$1));
|
|
15265
|
+
return this.createJsonErrorResponse(403, -32e3, error$1);
|
|
15266
|
+
}
|
|
14725
15267
|
}
|
|
14726
15268
|
if (this._allowedOrigins && this._allowedOrigins.length > 0) {
|
|
14727
|
-
const originHeader = req.headers.origin;
|
|
14728
|
-
if (originHeader && !this._allowedOrigins.includes(originHeader))
|
|
15269
|
+
const originHeader = req.headers.get("origin");
|
|
15270
|
+
if (originHeader && !this._allowedOrigins.includes(originHeader)) {
|
|
15271
|
+
const error$1 = `Invalid Origin header: ${originHeader}`;
|
|
15272
|
+
this.onerror?.(new Error(error$1));
|
|
15273
|
+
return this.createJsonErrorResponse(403, -32e3, error$1);
|
|
15274
|
+
}
|
|
14729
15275
|
}
|
|
14730
15276
|
}
|
|
14731
15277
|
/**
|
|
14732
|
-
* Handles an incoming HTTP request, whether GET or
|
|
15278
|
+
* Handles an incoming HTTP request, whether GET, POST, or DELETE
|
|
15279
|
+
* Returns a Response object (Web Standard)
|
|
14733
15280
|
*/
|
|
14734
|
-
async handleRequest(req,
|
|
14735
|
-
|
|
15281
|
+
async handleRequest(req, options) {
|
|
15282
|
+
if (!this.sessionIdGenerator && this._hasHandledRequest) throw new Error("Stateless transport cannot be reused across requests. Create a new transport per request.");
|
|
15283
|
+
this._hasHandledRequest = true;
|
|
14736
15284
|
const validationError = this.validateRequestHeaders(req);
|
|
14737
|
-
if (validationError)
|
|
14738
|
-
|
|
14739
|
-
|
|
14740
|
-
|
|
14741
|
-
|
|
14742
|
-
|
|
14743
|
-
},
|
|
14744
|
-
id: null
|
|
14745
|
-
}));
|
|
14746
|
-
(_a = this.onerror) === null || _a === void 0 || _a.call(this, new Error(validationError));
|
|
14747
|
-
return;
|
|
15285
|
+
if (validationError) return validationError;
|
|
15286
|
+
switch (req.method) {
|
|
15287
|
+
case "POST": return this.handlePostRequest(req, options);
|
|
15288
|
+
case "GET": return this.handleGetRequest(req);
|
|
15289
|
+
case "DELETE": return this.handleDeleteRequest(req);
|
|
15290
|
+
default: return this.handleUnsupportedRequest();
|
|
14748
15291
|
}
|
|
14749
|
-
if (req.method === "POST") await this.handlePostRequest(req, res, parsedBody);
|
|
14750
|
-
else if (req.method === "GET") await this.handleGetRequest(req, res);
|
|
14751
|
-
else if (req.method === "DELETE") await this.handleDeleteRequest(req, res);
|
|
14752
|
-
else await this.handleUnsupportedRequest(res);
|
|
14753
15292
|
}
|
|
14754
15293
|
/**
|
|
14755
15294
|
* Writes a priming event to establish resumption capability.
|
|
14756
15295
|
* Only sends if eventStore is configured (opt-in for resumability) and
|
|
14757
15296
|
* the client's protocol version supports empty SSE data (>= 2025-11-25).
|
|
14758
15297
|
*/
|
|
14759
|
-
async
|
|
15298
|
+
async writePrimingEvent(controller, encoder, streamId, protocolVersion) {
|
|
14760
15299
|
if (!this._eventStore) return;
|
|
14761
15300
|
if (protocolVersion < "2025-11-25") return;
|
|
14762
15301
|
const primingEventId = await this._eventStore.storeEvent(streamId, {});
|
|
14763
15302
|
let primingEvent = `id: ${primingEventId}\ndata: \n\n`;
|
|
14764
15303
|
if (this._retryInterval !== void 0) primingEvent = `id: ${primingEventId}\nretry: ${this._retryInterval}\ndata: \n\n`;
|
|
14765
|
-
|
|
15304
|
+
controller.enqueue(encoder.encode(primingEvent));
|
|
14766
15305
|
}
|
|
14767
15306
|
/**
|
|
14768
15307
|
* Handles GET requests for SSE stream
|
|
14769
15308
|
*/
|
|
14770
|
-
async handleGetRequest(req
|
|
14771
|
-
|
|
14772
|
-
|
|
14773
|
-
|
|
14774
|
-
|
|
14775
|
-
|
|
14776
|
-
|
|
14777
|
-
|
|
14778
|
-
|
|
14779
|
-
id: null
|
|
14780
|
-
}));
|
|
14781
|
-
return;
|
|
14782
|
-
}
|
|
14783
|
-
if (!this.validateSession(req, res)) return;
|
|
14784
|
-
if (!this.validateProtocolVersion(req, res)) return;
|
|
15309
|
+
async handleGetRequest(req) {
|
|
15310
|
+
if (!req.headers.get("accept")?.includes("text/event-stream")) {
|
|
15311
|
+
this.onerror?.(/* @__PURE__ */ new Error("Not Acceptable: Client must accept text/event-stream"));
|
|
15312
|
+
return this.createJsonErrorResponse(406, -32e3, "Not Acceptable: Client must accept text/event-stream");
|
|
15313
|
+
}
|
|
15314
|
+
const sessionError = this.validateSession(req);
|
|
15315
|
+
if (sessionError) return sessionError;
|
|
15316
|
+
const protocolError = this.validateProtocolVersion(req);
|
|
15317
|
+
if (protocolError) return protocolError;
|
|
14785
15318
|
if (this._eventStore) {
|
|
14786
|
-
const lastEventId = req.headers
|
|
14787
|
-
if (lastEventId)
|
|
14788
|
-
await this.replayEvents(lastEventId, res);
|
|
14789
|
-
return;
|
|
14790
|
-
}
|
|
15319
|
+
const lastEventId = req.headers.get("last-event-id");
|
|
15320
|
+
if (lastEventId) return this.replayEvents(lastEventId);
|
|
14791
15321
|
}
|
|
15322
|
+
if (this._streamMapping.get(this._standaloneSseStreamId) !== void 0) {
|
|
15323
|
+
this.onerror?.(/* @__PURE__ */ new Error("Conflict: Only one SSE stream is allowed per session"));
|
|
15324
|
+
return this.createJsonErrorResponse(409, -32e3, "Conflict: Only one SSE stream is allowed per session");
|
|
15325
|
+
}
|
|
15326
|
+
const encoder = new TextEncoder();
|
|
15327
|
+
let streamController;
|
|
15328
|
+
const readable = new ReadableStream({
|
|
15329
|
+
start: (controller) => {
|
|
15330
|
+
streamController = controller;
|
|
15331
|
+
},
|
|
15332
|
+
cancel: () => {
|
|
15333
|
+
this._streamMapping.delete(this._standaloneSseStreamId);
|
|
15334
|
+
}
|
|
15335
|
+
});
|
|
14792
15336
|
const headers = {
|
|
14793
15337
|
"Content-Type": "text/event-stream",
|
|
14794
15338
|
"Cache-Control": "no-cache, no-transform",
|
|
14795
15339
|
Connection: "keep-alive"
|
|
14796
15340
|
};
|
|
14797
15341
|
if (this.sessionId !== void 0) headers["mcp-session-id"] = this.sessionId;
|
|
14798
|
-
|
|
14799
|
-
|
|
14800
|
-
|
|
14801
|
-
|
|
14802
|
-
|
|
14803
|
-
|
|
14804
|
-
|
|
14805
|
-
|
|
14806
|
-
}
|
|
14807
|
-
return;
|
|
14808
|
-
}
|
|
14809
|
-
res.writeHead(200, headers).flushHeaders();
|
|
14810
|
-
this._streamMapping.set(this._standaloneSseStreamId, res);
|
|
14811
|
-
res.on("close", () => {
|
|
14812
|
-
this._streamMapping.delete(this._standaloneSseStreamId);
|
|
14813
|
-
});
|
|
14814
|
-
res.on("error", (error$1) => {
|
|
14815
|
-
var _a;
|
|
14816
|
-
(_a = this.onerror) === null || _a === void 0 || _a.call(this, error$1);
|
|
15342
|
+
this._streamMapping.set(this._standaloneSseStreamId, {
|
|
15343
|
+
controller: streamController,
|
|
15344
|
+
encoder,
|
|
15345
|
+
cleanup: () => {
|
|
15346
|
+
this._streamMapping.delete(this._standaloneSseStreamId);
|
|
15347
|
+
try {
|
|
15348
|
+
streamController.close();
|
|
15349
|
+
} catch {}
|
|
15350
|
+
}
|
|
14817
15351
|
});
|
|
15352
|
+
return new Response(readable, { headers });
|
|
14818
15353
|
}
|
|
14819
15354
|
/**
|
|
14820
15355
|
* Replays events that would have been sent after the specified event ID
|
|
14821
15356
|
* Only used when resumability is enabled
|
|
14822
15357
|
*/
|
|
14823
|
-
async replayEvents(lastEventId
|
|
14824
|
-
|
|
14825
|
-
|
|
15358
|
+
async replayEvents(lastEventId) {
|
|
15359
|
+
if (!this._eventStore) {
|
|
15360
|
+
this.onerror?.(/* @__PURE__ */ new Error("Event store not configured"));
|
|
15361
|
+
return this.createJsonErrorResponse(400, -32e3, "Event store not configured");
|
|
15362
|
+
}
|
|
14826
15363
|
try {
|
|
14827
15364
|
let streamId;
|
|
14828
15365
|
if (this._eventStore.getStreamIdForEventId) {
|
|
14829
15366
|
streamId = await this._eventStore.getStreamIdForEventId(lastEventId);
|
|
14830
15367
|
if (!streamId) {
|
|
14831
|
-
|
|
14832
|
-
|
|
14833
|
-
error: {
|
|
14834
|
-
code: -32e3,
|
|
14835
|
-
message: "Invalid event ID format"
|
|
14836
|
-
},
|
|
14837
|
-
id: null
|
|
14838
|
-
}));
|
|
14839
|
-
return;
|
|
15368
|
+
this.onerror?.(/* @__PURE__ */ new Error("Invalid event ID format"));
|
|
15369
|
+
return this.createJsonErrorResponse(400, -32e3, "Invalid event ID format");
|
|
14840
15370
|
}
|
|
14841
15371
|
if (this._streamMapping.get(streamId) !== void 0) {
|
|
14842
|
-
|
|
14843
|
-
|
|
14844
|
-
error: {
|
|
14845
|
-
code: -32e3,
|
|
14846
|
-
message: "Conflict: Stream already has an active connection"
|
|
14847
|
-
},
|
|
14848
|
-
id: null
|
|
14849
|
-
}));
|
|
14850
|
-
return;
|
|
15372
|
+
this.onerror?.(/* @__PURE__ */ new Error("Conflict: Stream already has an active connection"));
|
|
15373
|
+
return this.createJsonErrorResponse(409, -32e3, "Conflict: Stream already has an active connection");
|
|
14851
15374
|
}
|
|
14852
15375
|
}
|
|
14853
15376
|
const headers = {
|
|
@@ -14856,275 +15379,267 @@ var StreamableHTTPServerTransport = class {
|
|
|
14856
15379
|
Connection: "keep-alive"
|
|
14857
15380
|
};
|
|
14858
15381
|
if (this.sessionId !== void 0) headers["mcp-session-id"] = this.sessionId;
|
|
14859
|
-
|
|
15382
|
+
const encoder = new TextEncoder();
|
|
15383
|
+
let streamController;
|
|
15384
|
+
const readable = new ReadableStream({
|
|
15385
|
+
start: (controller) => {
|
|
15386
|
+
streamController = controller;
|
|
15387
|
+
},
|
|
15388
|
+
cancel: () => {}
|
|
15389
|
+
});
|
|
14860
15390
|
const replayedStreamId = await this._eventStore.replayEventsAfter(lastEventId, { send: async (eventId, message) => {
|
|
14861
|
-
|
|
14862
|
-
|
|
14863
|
-
|
|
14864
|
-
|
|
15391
|
+
if (!this.writeSSEEvent(streamController, encoder, message, eventId)) {
|
|
15392
|
+
this.onerror?.(/* @__PURE__ */ new Error("Failed replay events"));
|
|
15393
|
+
try {
|
|
15394
|
+
streamController.close();
|
|
15395
|
+
} catch {}
|
|
14865
15396
|
}
|
|
14866
15397
|
} });
|
|
14867
|
-
this._streamMapping.set(replayedStreamId,
|
|
14868
|
-
|
|
14869
|
-
|
|
14870
|
-
|
|
14871
|
-
|
|
14872
|
-
|
|
14873
|
-
|
|
15398
|
+
this._streamMapping.set(replayedStreamId, {
|
|
15399
|
+
controller: streamController,
|
|
15400
|
+
encoder,
|
|
15401
|
+
cleanup: () => {
|
|
15402
|
+
this._streamMapping.delete(replayedStreamId);
|
|
15403
|
+
try {
|
|
15404
|
+
streamController.close();
|
|
15405
|
+
} catch {}
|
|
15406
|
+
}
|
|
14874
15407
|
});
|
|
15408
|
+
return new Response(readable, { headers });
|
|
14875
15409
|
} catch (error$1) {
|
|
14876
|
-
|
|
15410
|
+
this.onerror?.(error$1);
|
|
15411
|
+
return this.createJsonErrorResponse(500, -32e3, "Error replaying events");
|
|
14877
15412
|
}
|
|
14878
15413
|
}
|
|
14879
15414
|
/**
|
|
14880
|
-
* Writes an event to
|
|
15415
|
+
* Writes an event to an SSE stream via controller with proper formatting
|
|
14881
15416
|
*/
|
|
14882
|
-
writeSSEEvent(
|
|
14883
|
-
|
|
14884
|
-
|
|
14885
|
-
|
|
14886
|
-
|
|
15417
|
+
writeSSEEvent(controller, encoder, message, eventId) {
|
|
15418
|
+
try {
|
|
15419
|
+
let eventData = `event: message\n`;
|
|
15420
|
+
if (eventId) eventData += `id: ${eventId}\n`;
|
|
15421
|
+
eventData += `data: ${JSON.stringify(message)}\n\n`;
|
|
15422
|
+
controller.enqueue(encoder.encode(eventData));
|
|
15423
|
+
return true;
|
|
15424
|
+
} catch (error$1) {
|
|
15425
|
+
this.onerror?.(error$1);
|
|
15426
|
+
return false;
|
|
15427
|
+
}
|
|
14887
15428
|
}
|
|
14888
15429
|
/**
|
|
14889
15430
|
* Handles unsupported requests (PUT, PATCH, etc.)
|
|
14890
15431
|
*/
|
|
14891
|
-
|
|
14892
|
-
|
|
15432
|
+
handleUnsupportedRequest() {
|
|
15433
|
+
this.onerror?.(/* @__PURE__ */ new Error("Method not allowed."));
|
|
15434
|
+
return new Response(JSON.stringify({
|
|
14893
15435
|
jsonrpc: "2.0",
|
|
14894
15436
|
error: {
|
|
14895
15437
|
code: -32e3,
|
|
14896
15438
|
message: "Method not allowed."
|
|
14897
15439
|
},
|
|
14898
15440
|
id: null
|
|
14899
|
-
})
|
|
15441
|
+
}), {
|
|
15442
|
+
status: 405,
|
|
15443
|
+
headers: {
|
|
15444
|
+
Allow: "GET, POST, DELETE",
|
|
15445
|
+
"Content-Type": "application/json"
|
|
15446
|
+
}
|
|
15447
|
+
});
|
|
14900
15448
|
}
|
|
14901
15449
|
/**
|
|
14902
15450
|
* Handles POST requests containing JSON-RPC messages
|
|
14903
15451
|
*/
|
|
14904
|
-
async handlePostRequest(req,
|
|
14905
|
-
var _a, _b, _c, _d, _e, _f;
|
|
15452
|
+
async handlePostRequest(req, options) {
|
|
14906
15453
|
try {
|
|
14907
|
-
const acceptHeader = req.headers.accept;
|
|
14908
|
-
if (!
|
|
14909
|
-
|
|
14910
|
-
|
|
14911
|
-
error: {
|
|
14912
|
-
code: -32e3,
|
|
14913
|
-
message: "Not Acceptable: Client must accept both application/json and text/event-stream"
|
|
14914
|
-
},
|
|
14915
|
-
id: null
|
|
14916
|
-
}));
|
|
14917
|
-
return;
|
|
15454
|
+
const acceptHeader = req.headers.get("accept");
|
|
15455
|
+
if (!acceptHeader?.includes("application/json") || !acceptHeader.includes("text/event-stream")) {
|
|
15456
|
+
this.onerror?.(/* @__PURE__ */ new Error("Not Acceptable: Client must accept both application/json and text/event-stream"));
|
|
15457
|
+
return this.createJsonErrorResponse(406, -32e3, "Not Acceptable: Client must accept both application/json and text/event-stream");
|
|
14918
15458
|
}
|
|
14919
|
-
const ct = req.headers
|
|
15459
|
+
const ct = req.headers.get("content-type");
|
|
14920
15460
|
if (!ct || !ct.includes("application/json")) {
|
|
14921
|
-
|
|
14922
|
-
|
|
14923
|
-
error: {
|
|
14924
|
-
code: -32e3,
|
|
14925
|
-
message: "Unsupported Media Type: Content-Type must be application/json"
|
|
14926
|
-
},
|
|
14927
|
-
id: null
|
|
14928
|
-
}));
|
|
14929
|
-
return;
|
|
15461
|
+
this.onerror?.(/* @__PURE__ */ new Error("Unsupported Media Type: Content-Type must be application/json"));
|
|
15462
|
+
return this.createJsonErrorResponse(415, -32e3, "Unsupported Media Type: Content-Type must be application/json");
|
|
14930
15463
|
}
|
|
14931
|
-
const
|
|
14932
|
-
|
|
15464
|
+
const requestInfo = {
|
|
15465
|
+
headers: Object.fromEntries(req.headers.entries()),
|
|
15466
|
+
url: new URL(req.url)
|
|
15467
|
+
};
|
|
14933
15468
|
let rawMessage;
|
|
14934
|
-
if (parsedBody !== void 0) rawMessage = parsedBody;
|
|
14935
|
-
else {
|
|
14936
|
-
|
|
14937
|
-
|
|
14938
|
-
|
|
14939
|
-
|
|
14940
|
-
rawMessage = JSON.parse(body.toString());
|
|
15469
|
+
if (options?.parsedBody !== void 0) rawMessage = options.parsedBody;
|
|
15470
|
+
else try {
|
|
15471
|
+
rawMessage = await req.json();
|
|
15472
|
+
} catch {
|
|
15473
|
+
this.onerror?.(/* @__PURE__ */ new Error("Parse error: Invalid JSON"));
|
|
15474
|
+
return this.createJsonErrorResponse(400, -32700, "Parse error: Invalid JSON");
|
|
14941
15475
|
}
|
|
14942
15476
|
let messages;
|
|
14943
|
-
|
|
14944
|
-
|
|
15477
|
+
try {
|
|
15478
|
+
if (Array.isArray(rawMessage)) messages = rawMessage.map((msg) => JSONRPCMessageSchema.parse(msg));
|
|
15479
|
+
else messages = [JSONRPCMessageSchema.parse(rawMessage)];
|
|
15480
|
+
} catch {
|
|
15481
|
+
this.onerror?.(/* @__PURE__ */ new Error("Parse error: Invalid JSON-RPC message"));
|
|
15482
|
+
return this.createJsonErrorResponse(400, -32700, "Parse error: Invalid JSON-RPC message");
|
|
15483
|
+
}
|
|
14945
15484
|
const isInitializationRequest = messages.some(isInitializeRequest);
|
|
14946
15485
|
if (isInitializationRequest) {
|
|
14947
15486
|
if (this._initialized && this.sessionId !== void 0) {
|
|
14948
|
-
|
|
14949
|
-
|
|
14950
|
-
error: {
|
|
14951
|
-
code: -32600,
|
|
14952
|
-
message: "Invalid Request: Server already initialized"
|
|
14953
|
-
},
|
|
14954
|
-
id: null
|
|
14955
|
-
}));
|
|
14956
|
-
return;
|
|
15487
|
+
this.onerror?.(/* @__PURE__ */ new Error("Invalid Request: Server already initialized"));
|
|
15488
|
+
return this.createJsonErrorResponse(400, -32600, "Invalid Request: Server already initialized");
|
|
14957
15489
|
}
|
|
14958
15490
|
if (messages.length > 1) {
|
|
14959
|
-
|
|
14960
|
-
|
|
14961
|
-
error: {
|
|
14962
|
-
code: -32600,
|
|
14963
|
-
message: "Invalid Request: Only one initialization request is allowed"
|
|
14964
|
-
},
|
|
14965
|
-
id: null
|
|
14966
|
-
}));
|
|
14967
|
-
return;
|
|
15491
|
+
this.onerror?.(/* @__PURE__ */ new Error("Invalid Request: Only one initialization request is allowed"));
|
|
15492
|
+
return this.createJsonErrorResponse(400, -32600, "Invalid Request: Only one initialization request is allowed");
|
|
14968
15493
|
}
|
|
14969
|
-
this.sessionId =
|
|
15494
|
+
this.sessionId = this.sessionIdGenerator?.();
|
|
14970
15495
|
this._initialized = true;
|
|
14971
15496
|
if (this.sessionId && this._onsessioninitialized) await Promise.resolve(this._onsessioninitialized(this.sessionId));
|
|
14972
15497
|
}
|
|
14973
15498
|
if (!isInitializationRequest) {
|
|
14974
|
-
|
|
14975
|
-
if (
|
|
15499
|
+
const sessionError = this.validateSession(req);
|
|
15500
|
+
if (sessionError) return sessionError;
|
|
15501
|
+
const protocolError = this.validateProtocolVersion(req);
|
|
15502
|
+
if (protocolError) return protocolError;
|
|
14976
15503
|
}
|
|
14977
|
-
|
|
14978
|
-
|
|
14979
|
-
|
|
14980
|
-
for (const message of messages) (_c = this.onmessage) === null || _c === void 0 || _c.call(this, message, {
|
|
14981
|
-
authInfo,
|
|
15504
|
+
if (!messages.some(isJSONRPCRequest)) {
|
|
15505
|
+
for (const message of messages) this.onmessage?.(message, {
|
|
15506
|
+
authInfo: options?.authInfo,
|
|
14982
15507
|
requestInfo
|
|
14983
15508
|
});
|
|
14984
|
-
|
|
14985
|
-
|
|
14986
|
-
|
|
14987
|
-
|
|
14988
|
-
|
|
14989
|
-
|
|
14990
|
-
|
|
14991
|
-
|
|
14992
|
-
|
|
14993
|
-
|
|
14994
|
-
|
|
14995
|
-
res.writeHead(200, headers);
|
|
14996
|
-
await this._maybeWritePrimingEvent(res, streamId, clientProtocolVersion);
|
|
14997
|
-
}
|
|
14998
|
-
for (const message of messages) if (isJSONRPCRequest(message)) {
|
|
14999
|
-
this._streamMapping.set(streamId, res);
|
|
15000
|
-
this._requestToStreamMapping.set(message.id, streamId);
|
|
15001
|
-
}
|
|
15002
|
-
res.on("close", () => {
|
|
15003
|
-
this._streamMapping.delete(streamId);
|
|
15509
|
+
return new Response(null, { status: 202 });
|
|
15510
|
+
}
|
|
15511
|
+
const streamId = crypto.randomUUID();
|
|
15512
|
+
const initRequest = messages.find((m) => isInitializeRequest(m));
|
|
15513
|
+
const clientProtocolVersion = initRequest ? initRequest.params.protocolVersion : req.headers.get("mcp-protocol-version") ?? DEFAULT_NEGOTIATED_PROTOCOL_VERSION;
|
|
15514
|
+
if (this._enableJsonResponse) return new Promise((resolve$2) => {
|
|
15515
|
+
this._streamMapping.set(streamId, {
|
|
15516
|
+
resolveJson: resolve$2,
|
|
15517
|
+
cleanup: () => {
|
|
15518
|
+
this._streamMapping.delete(streamId);
|
|
15519
|
+
}
|
|
15004
15520
|
});
|
|
15005
|
-
|
|
15006
|
-
|
|
15007
|
-
|
|
15521
|
+
for (const message of messages) if (isJSONRPCRequest(message)) this._requestToStreamMapping.set(message.id, streamId);
|
|
15522
|
+
for (const message of messages) this.onmessage?.(message, {
|
|
15523
|
+
authInfo: options?.authInfo,
|
|
15524
|
+
requestInfo
|
|
15008
15525
|
});
|
|
15009
|
-
|
|
15010
|
-
|
|
15011
|
-
|
|
15012
|
-
|
|
15013
|
-
|
|
15014
|
-
|
|
15015
|
-
|
|
15016
|
-
|
|
15017
|
-
|
|
15018
|
-
|
|
15526
|
+
});
|
|
15527
|
+
const encoder = new TextEncoder();
|
|
15528
|
+
let streamController;
|
|
15529
|
+
const readable = new ReadableStream({
|
|
15530
|
+
start: (controller) => {
|
|
15531
|
+
streamController = controller;
|
|
15532
|
+
},
|
|
15533
|
+
cancel: () => {
|
|
15534
|
+
this._streamMapping.delete(streamId);
|
|
15535
|
+
}
|
|
15536
|
+
});
|
|
15537
|
+
const headers = {
|
|
15538
|
+
"Content-Type": "text/event-stream",
|
|
15539
|
+
"Cache-Control": "no-cache",
|
|
15540
|
+
Connection: "keep-alive"
|
|
15541
|
+
};
|
|
15542
|
+
if (this.sessionId !== void 0) headers["mcp-session-id"] = this.sessionId;
|
|
15543
|
+
for (const message of messages) if (isJSONRPCRequest(message)) {
|
|
15544
|
+
this._streamMapping.set(streamId, {
|
|
15545
|
+
controller: streamController,
|
|
15546
|
+
encoder,
|
|
15547
|
+
cleanup: () => {
|
|
15548
|
+
this._streamMapping.delete(streamId);
|
|
15549
|
+
try {
|
|
15550
|
+
streamController.close();
|
|
15551
|
+
} catch {}
|
|
15019
15552
|
}
|
|
15020
|
-
|
|
15021
|
-
|
|
15022
|
-
|
|
15023
|
-
|
|
15024
|
-
|
|
15025
|
-
|
|
15553
|
+
});
|
|
15554
|
+
this._requestToStreamMapping.set(message.id, streamId);
|
|
15555
|
+
}
|
|
15556
|
+
await this.writePrimingEvent(streamController, encoder, streamId, clientProtocolVersion);
|
|
15557
|
+
for (const message of messages) {
|
|
15558
|
+
let closeSSEStream;
|
|
15559
|
+
let closeStandaloneSSEStream;
|
|
15560
|
+
if (isJSONRPCRequest(message) && this._eventStore && clientProtocolVersion >= "2025-11-25") {
|
|
15561
|
+
closeSSEStream = () => {
|
|
15562
|
+
this.closeSSEStream(message.id);
|
|
15563
|
+
};
|
|
15564
|
+
closeStandaloneSSEStream = () => {
|
|
15565
|
+
this.closeStandaloneSSEStream();
|
|
15566
|
+
};
|
|
15026
15567
|
}
|
|
15568
|
+
this.onmessage?.(message, {
|
|
15569
|
+
authInfo: options?.authInfo,
|
|
15570
|
+
requestInfo,
|
|
15571
|
+
closeSSEStream,
|
|
15572
|
+
closeStandaloneSSEStream
|
|
15573
|
+
});
|
|
15027
15574
|
}
|
|
15575
|
+
return new Response(readable, {
|
|
15576
|
+
status: 200,
|
|
15577
|
+
headers
|
|
15578
|
+
});
|
|
15028
15579
|
} catch (error$1) {
|
|
15029
|
-
|
|
15030
|
-
|
|
15031
|
-
error: {
|
|
15032
|
-
code: -32700,
|
|
15033
|
-
message: "Parse error",
|
|
15034
|
-
data: String(error$1)
|
|
15035
|
-
},
|
|
15036
|
-
id: null
|
|
15037
|
-
}));
|
|
15038
|
-
(_f = this.onerror) === null || _f === void 0 || _f.call(this, error$1);
|
|
15580
|
+
this.onerror?.(error$1);
|
|
15581
|
+
return this.createJsonErrorResponse(400, -32700, "Parse error", { data: String(error$1) });
|
|
15039
15582
|
}
|
|
15040
15583
|
}
|
|
15041
15584
|
/**
|
|
15042
15585
|
* Handles DELETE requests to terminate sessions
|
|
15043
15586
|
*/
|
|
15044
|
-
async handleDeleteRequest(req
|
|
15045
|
-
|
|
15046
|
-
if (
|
|
15047
|
-
|
|
15048
|
-
|
|
15587
|
+
async handleDeleteRequest(req) {
|
|
15588
|
+
const sessionError = this.validateSession(req);
|
|
15589
|
+
if (sessionError) return sessionError;
|
|
15590
|
+
const protocolError = this.validateProtocolVersion(req);
|
|
15591
|
+
if (protocolError) return protocolError;
|
|
15592
|
+
await Promise.resolve(this._onsessionclosed?.(this.sessionId));
|
|
15049
15593
|
await this.close();
|
|
15050
|
-
|
|
15594
|
+
return new Response(null, { status: 200 });
|
|
15051
15595
|
}
|
|
15052
15596
|
/**
|
|
15053
|
-
* Validates session ID for non-initialization requests
|
|
15054
|
-
* Returns
|
|
15597
|
+
* Validates session ID for non-initialization requests.
|
|
15598
|
+
* Returns Response error if invalid, undefined otherwise
|
|
15055
15599
|
*/
|
|
15056
|
-
validateSession(req
|
|
15057
|
-
if (this.sessionIdGenerator === void 0) return
|
|
15600
|
+
validateSession(req) {
|
|
15601
|
+
if (this.sessionIdGenerator === void 0) return;
|
|
15058
15602
|
if (!this._initialized) {
|
|
15059
|
-
|
|
15060
|
-
|
|
15061
|
-
error: {
|
|
15062
|
-
code: -32e3,
|
|
15063
|
-
message: "Bad Request: Server not initialized"
|
|
15064
|
-
},
|
|
15065
|
-
id: null
|
|
15066
|
-
}));
|
|
15067
|
-
return false;
|
|
15603
|
+
this.onerror?.(/* @__PURE__ */ new Error("Bad Request: Server not initialized"));
|
|
15604
|
+
return this.createJsonErrorResponse(400, -32e3, "Bad Request: Server not initialized");
|
|
15068
15605
|
}
|
|
15069
|
-
const sessionId = req.headers
|
|
15606
|
+
const sessionId = req.headers.get("mcp-session-id");
|
|
15070
15607
|
if (!sessionId) {
|
|
15071
|
-
|
|
15072
|
-
|
|
15073
|
-
|
|
15074
|
-
|
|
15075
|
-
|
|
15076
|
-
|
|
15077
|
-
id: null
|
|
15078
|
-
}));
|
|
15079
|
-
return false;
|
|
15080
|
-
} else if (Array.isArray(sessionId)) {
|
|
15081
|
-
res.writeHead(400).end(JSON.stringify({
|
|
15082
|
-
jsonrpc: "2.0",
|
|
15083
|
-
error: {
|
|
15084
|
-
code: -32e3,
|
|
15085
|
-
message: "Bad Request: Mcp-Session-Id header must be a single value"
|
|
15086
|
-
},
|
|
15087
|
-
id: null
|
|
15088
|
-
}));
|
|
15089
|
-
return false;
|
|
15090
|
-
} else if (sessionId !== this.sessionId) {
|
|
15091
|
-
res.writeHead(404).end(JSON.stringify({
|
|
15092
|
-
jsonrpc: "2.0",
|
|
15093
|
-
error: {
|
|
15094
|
-
code: -32001,
|
|
15095
|
-
message: "Session not found"
|
|
15096
|
-
},
|
|
15097
|
-
id: null
|
|
15098
|
-
}));
|
|
15099
|
-
return false;
|
|
15608
|
+
this.onerror?.(/* @__PURE__ */ new Error("Bad Request: Mcp-Session-Id header is required"));
|
|
15609
|
+
return this.createJsonErrorResponse(400, -32e3, "Bad Request: Mcp-Session-Id header is required");
|
|
15610
|
+
}
|
|
15611
|
+
if (sessionId !== this.sessionId) {
|
|
15612
|
+
this.onerror?.(/* @__PURE__ */ new Error("Session not found"));
|
|
15613
|
+
return this.createJsonErrorResponse(404, -32001, "Session not found");
|
|
15100
15614
|
}
|
|
15101
|
-
return true;
|
|
15102
15615
|
}
|
|
15103
|
-
|
|
15104
|
-
|
|
15105
|
-
|
|
15106
|
-
|
|
15107
|
-
|
|
15108
|
-
|
|
15109
|
-
|
|
15110
|
-
|
|
15111
|
-
|
|
15112
|
-
|
|
15113
|
-
|
|
15114
|
-
|
|
15115
|
-
|
|
15116
|
-
|
|
15616
|
+
/**
|
|
15617
|
+
* Validates the MCP-Protocol-Version header on incoming requests.
|
|
15618
|
+
*
|
|
15619
|
+
* For initialization: Version negotiation handles unknown versions gracefully
|
|
15620
|
+
* (server responds with its supported version).
|
|
15621
|
+
*
|
|
15622
|
+
* For subsequent requests with MCP-Protocol-Version header:
|
|
15623
|
+
* - Accept if in supported list
|
|
15624
|
+
* - 400 if unsupported
|
|
15625
|
+
*
|
|
15626
|
+
* For HTTP requests without the MCP-Protocol-Version header:
|
|
15627
|
+
* - Accept and default to the version negotiated at initialization
|
|
15628
|
+
*/
|
|
15629
|
+
validateProtocolVersion(req) {
|
|
15630
|
+
const protocolVersion = req.headers.get("mcp-protocol-version");
|
|
15631
|
+
if (protocolVersion !== null && !SUPPORTED_PROTOCOL_VERSIONS.includes(protocolVersion)) {
|
|
15632
|
+
this.onerror?.(/* @__PURE__ */ new Error(`Bad Request: Unsupported protocol version: ${protocolVersion} (supported versions: ${SUPPORTED_PROTOCOL_VERSIONS.join(", ")})`));
|
|
15633
|
+
return this.createJsonErrorResponse(400, -32e3, `Bad Request: Unsupported protocol version: ${protocolVersion} (supported versions: ${SUPPORTED_PROTOCOL_VERSIONS.join(", ")})`);
|
|
15117
15634
|
}
|
|
15118
|
-
return true;
|
|
15119
15635
|
}
|
|
15120
15636
|
async close() {
|
|
15121
|
-
|
|
15122
|
-
|
|
15123
|
-
response.end();
|
|
15637
|
+
this._streamMapping.forEach(({ cleanup }) => {
|
|
15638
|
+
cleanup();
|
|
15124
15639
|
});
|
|
15125
15640
|
this._streamMapping.clear();
|
|
15126
15641
|
this._requestResponseMap.clear();
|
|
15127
|
-
|
|
15642
|
+
this.onclose?.();
|
|
15128
15643
|
}
|
|
15129
15644
|
/**
|
|
15130
15645
|
* Close an SSE stream for a specific request, triggering client reconnection.
|
|
@@ -15135,10 +15650,7 @@ var StreamableHTTPServerTransport = class {
|
|
|
15135
15650
|
const streamId = this._requestToStreamMapping.get(requestId);
|
|
15136
15651
|
if (!streamId) return;
|
|
15137
15652
|
const stream = this._streamMapping.get(streamId);
|
|
15138
|
-
if (stream)
|
|
15139
|
-
stream.end();
|
|
15140
|
-
this._streamMapping.delete(streamId);
|
|
15141
|
-
}
|
|
15653
|
+
if (stream) stream.cleanup();
|
|
15142
15654
|
}
|
|
15143
15655
|
/**
|
|
15144
15656
|
* Close the standalone GET SSE stream, triggering client reconnection.
|
|
@@ -15146,44 +15658,46 @@ var StreamableHTTPServerTransport = class {
|
|
|
15146
15658
|
*/
|
|
15147
15659
|
closeStandaloneSSEStream() {
|
|
15148
15660
|
const stream = this._streamMapping.get(this._standaloneSseStreamId);
|
|
15149
|
-
if (stream)
|
|
15150
|
-
stream.end();
|
|
15151
|
-
this._streamMapping.delete(this._standaloneSseStreamId);
|
|
15152
|
-
}
|
|
15661
|
+
if (stream) stream.cleanup();
|
|
15153
15662
|
}
|
|
15154
15663
|
async send(message, options) {
|
|
15155
|
-
let requestId = options
|
|
15156
|
-
if (
|
|
15664
|
+
let requestId = options?.relatedRequestId;
|
|
15665
|
+
if (isJSONRPCResultResponse(message) || isJSONRPCErrorResponse(message)) requestId = message.id;
|
|
15157
15666
|
if (requestId === void 0) {
|
|
15158
|
-
if (
|
|
15667
|
+
if (isJSONRPCResultResponse(message) || isJSONRPCErrorResponse(message)) throw new Error("Cannot send a response on a standalone SSE stream unless resuming a previous client request");
|
|
15159
15668
|
let eventId;
|
|
15160
15669
|
if (this._eventStore) eventId = await this._eventStore.storeEvent(this._standaloneSseStreamId, message);
|
|
15161
15670
|
const standaloneSse = this._streamMapping.get(this._standaloneSseStreamId);
|
|
15162
15671
|
if (standaloneSse === void 0) return;
|
|
15163
|
-
this.writeSSEEvent(standaloneSse, message, eventId);
|
|
15672
|
+
if (standaloneSse.controller && standaloneSse.encoder) this.writeSSEEvent(standaloneSse.controller, standaloneSse.encoder, message, eventId);
|
|
15164
15673
|
return;
|
|
15165
15674
|
}
|
|
15166
15675
|
const streamId = this._requestToStreamMapping.get(requestId);
|
|
15167
|
-
const response = this._streamMapping.get(streamId);
|
|
15168
15676
|
if (!streamId) throw new Error(`No connection established for request ID: ${String(requestId)}`);
|
|
15169
|
-
|
|
15677
|
+
const stream = this._streamMapping.get(streamId);
|
|
15678
|
+
if (!this._enableJsonResponse && stream?.controller && stream?.encoder) {
|
|
15170
15679
|
let eventId;
|
|
15171
15680
|
if (this._eventStore) eventId = await this._eventStore.storeEvent(streamId, message);
|
|
15172
|
-
|
|
15681
|
+
this.writeSSEEvent(stream.controller, stream.encoder, message, eventId);
|
|
15173
15682
|
}
|
|
15174
|
-
if (
|
|
15683
|
+
if (isJSONRPCResultResponse(message) || isJSONRPCErrorResponse(message)) {
|
|
15175
15684
|
this._requestResponseMap.set(requestId, message);
|
|
15176
|
-
const relatedIds = Array.from(this._requestToStreamMapping.entries()).filter(([_$1,
|
|
15685
|
+
const relatedIds = Array.from(this._requestToStreamMapping.entries()).filter(([_$1, sid]) => sid === streamId).map(([id]) => id);
|
|
15177
15686
|
if (relatedIds.every((id) => this._requestResponseMap.has(id))) {
|
|
15178
|
-
if (!
|
|
15179
|
-
if (this._enableJsonResponse) {
|
|
15687
|
+
if (!stream) throw new Error(`No connection established for request ID: ${String(requestId)}`);
|
|
15688
|
+
if (this._enableJsonResponse && stream.resolveJson) {
|
|
15180
15689
|
const headers = { "Content-Type": "application/json" };
|
|
15181
15690
|
if (this.sessionId !== void 0) headers["mcp-session-id"] = this.sessionId;
|
|
15182
15691
|
const responses = relatedIds.map((id) => this._requestResponseMap.get(id));
|
|
15183
|
-
|
|
15184
|
-
|
|
15185
|
-
|
|
15186
|
-
|
|
15692
|
+
if (responses.length === 1) stream.resolveJson(new Response(JSON.stringify(responses[0]), {
|
|
15693
|
+
status: 200,
|
|
15694
|
+
headers
|
|
15695
|
+
}));
|
|
15696
|
+
else stream.resolveJson(new Response(JSON.stringify(responses), {
|
|
15697
|
+
status: 200,
|
|
15698
|
+
headers
|
|
15699
|
+
}));
|
|
15700
|
+
} else stream.cleanup();
|
|
15187
15701
|
for (const id of relatedIds) {
|
|
15188
15702
|
this._requestResponseMap.delete(id);
|
|
15189
15703
|
this._requestToStreamMapping.delete(id);
|
|
@@ -15193,6 +15707,153 @@ var StreamableHTTPServerTransport = class {
|
|
|
15193
15707
|
}
|
|
15194
15708
|
};
|
|
15195
15709
|
|
|
15710
|
+
//#endregion
|
|
15711
|
+
//#region node_modules/.pnpm/@modelcontextprotocol+sdk@1.27.1_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/server/streamableHttp.js
|
|
15712
|
+
/**
|
|
15713
|
+
* Node.js HTTP Streamable HTTP Server Transport
|
|
15714
|
+
*
|
|
15715
|
+
* This is a thin wrapper around `WebStandardStreamableHTTPServerTransport` that provides
|
|
15716
|
+
* compatibility with Node.js HTTP server (IncomingMessage/ServerResponse).
|
|
15717
|
+
*
|
|
15718
|
+
* For web-standard environments (Cloudflare Workers, Deno, Bun), use `WebStandardStreamableHTTPServerTransport` directly.
|
|
15719
|
+
*/
|
|
15720
|
+
/**
|
|
15721
|
+
* Server transport for Streamable HTTP: this implements the MCP Streamable HTTP transport specification.
|
|
15722
|
+
* It supports both SSE streaming and direct HTTP responses.
|
|
15723
|
+
*
|
|
15724
|
+
* This is a wrapper around `WebStandardStreamableHTTPServerTransport` that provides Node.js HTTP compatibility.
|
|
15725
|
+
* It uses the `@hono/node-server` library to convert between Node.js HTTP and Web Standard APIs.
|
|
15726
|
+
*
|
|
15727
|
+
* Usage example:
|
|
15728
|
+
*
|
|
15729
|
+
* ```typescript
|
|
15730
|
+
* // Stateful mode - server sets the session ID
|
|
15731
|
+
* const statefulTransport = new StreamableHTTPServerTransport({
|
|
15732
|
+
* sessionIdGenerator: () => randomUUID(),
|
|
15733
|
+
* });
|
|
15734
|
+
*
|
|
15735
|
+
* // Stateless mode - explicitly set session ID to undefined
|
|
15736
|
+
* const statelessTransport = new StreamableHTTPServerTransport({
|
|
15737
|
+
* sessionIdGenerator: undefined,
|
|
15738
|
+
* });
|
|
15739
|
+
*
|
|
15740
|
+
* // Using with pre-parsed request body
|
|
15741
|
+
* app.post('/mcp', (req, res) => {
|
|
15742
|
+
* transport.handleRequest(req, res, req.body);
|
|
15743
|
+
* });
|
|
15744
|
+
* ```
|
|
15745
|
+
*
|
|
15746
|
+
* In stateful mode:
|
|
15747
|
+
* - Session ID is generated and included in response headers
|
|
15748
|
+
* - Session ID is always included in initialization responses
|
|
15749
|
+
* - Requests with invalid session IDs are rejected with 404 Not Found
|
|
15750
|
+
* - Non-initialization requests without a session ID are rejected with 400 Bad Request
|
|
15751
|
+
* - State is maintained in-memory (connections, message history)
|
|
15752
|
+
*
|
|
15753
|
+
* In stateless mode:
|
|
15754
|
+
* - No Session ID is included in any responses
|
|
15755
|
+
* - No session validation is performed
|
|
15756
|
+
*/
|
|
15757
|
+
var StreamableHTTPServerTransport = class {
|
|
15758
|
+
constructor(options = {}) {
|
|
15759
|
+
this._requestContext = /* @__PURE__ */ new WeakMap();
|
|
15760
|
+
this._webStandardTransport = new WebStandardStreamableHTTPServerTransport(options);
|
|
15761
|
+
this._requestListener = getRequestListener(async (webRequest) => {
|
|
15762
|
+
const context = this._requestContext.get(webRequest);
|
|
15763
|
+
return this._webStandardTransport.handleRequest(webRequest, {
|
|
15764
|
+
authInfo: context?.authInfo,
|
|
15765
|
+
parsedBody: context?.parsedBody
|
|
15766
|
+
});
|
|
15767
|
+
}, { overrideGlobalObjects: false });
|
|
15768
|
+
}
|
|
15769
|
+
/**
|
|
15770
|
+
* Gets the session ID for this transport instance.
|
|
15771
|
+
*/
|
|
15772
|
+
get sessionId() {
|
|
15773
|
+
return this._webStandardTransport.sessionId;
|
|
15774
|
+
}
|
|
15775
|
+
/**
|
|
15776
|
+
* Sets callback for when the transport is closed.
|
|
15777
|
+
*/
|
|
15778
|
+
set onclose(handler) {
|
|
15779
|
+
this._webStandardTransport.onclose = handler;
|
|
15780
|
+
}
|
|
15781
|
+
get onclose() {
|
|
15782
|
+
return this._webStandardTransport.onclose;
|
|
15783
|
+
}
|
|
15784
|
+
/**
|
|
15785
|
+
* Sets callback for transport errors.
|
|
15786
|
+
*/
|
|
15787
|
+
set onerror(handler) {
|
|
15788
|
+
this._webStandardTransport.onerror = handler;
|
|
15789
|
+
}
|
|
15790
|
+
get onerror() {
|
|
15791
|
+
return this._webStandardTransport.onerror;
|
|
15792
|
+
}
|
|
15793
|
+
/**
|
|
15794
|
+
* Sets callback for incoming messages.
|
|
15795
|
+
*/
|
|
15796
|
+
set onmessage(handler) {
|
|
15797
|
+
this._webStandardTransport.onmessage = handler;
|
|
15798
|
+
}
|
|
15799
|
+
get onmessage() {
|
|
15800
|
+
return this._webStandardTransport.onmessage;
|
|
15801
|
+
}
|
|
15802
|
+
/**
|
|
15803
|
+
* Starts the transport. This is required by the Transport interface but is a no-op
|
|
15804
|
+
* for the Streamable HTTP transport as connections are managed per-request.
|
|
15805
|
+
*/
|
|
15806
|
+
async start() {
|
|
15807
|
+
return this._webStandardTransport.start();
|
|
15808
|
+
}
|
|
15809
|
+
/**
|
|
15810
|
+
* Closes the transport and all active connections.
|
|
15811
|
+
*/
|
|
15812
|
+
async close() {
|
|
15813
|
+
return this._webStandardTransport.close();
|
|
15814
|
+
}
|
|
15815
|
+
/**
|
|
15816
|
+
* Sends a JSON-RPC message through the transport.
|
|
15817
|
+
*/
|
|
15818
|
+
async send(message, options) {
|
|
15819
|
+
return this._webStandardTransport.send(message, options);
|
|
15820
|
+
}
|
|
15821
|
+
/**
|
|
15822
|
+
* Handles an incoming HTTP request, whether GET or POST.
|
|
15823
|
+
*
|
|
15824
|
+
* This method converts Node.js HTTP objects to Web Standard Request/Response
|
|
15825
|
+
* and delegates to the underlying WebStandardStreamableHTTPServerTransport.
|
|
15826
|
+
*
|
|
15827
|
+
* @param req - Node.js IncomingMessage, optionally with auth property from middleware
|
|
15828
|
+
* @param res - Node.js ServerResponse
|
|
15829
|
+
* @param parsedBody - Optional pre-parsed body from body-parser middleware
|
|
15830
|
+
*/
|
|
15831
|
+
async handleRequest(req, res, parsedBody) {
|
|
15832
|
+
const authInfo = req.auth;
|
|
15833
|
+
await getRequestListener(async (webRequest) => {
|
|
15834
|
+
return this._webStandardTransport.handleRequest(webRequest, {
|
|
15835
|
+
authInfo,
|
|
15836
|
+
parsedBody
|
|
15837
|
+
});
|
|
15838
|
+
}, { overrideGlobalObjects: false })(req, res);
|
|
15839
|
+
}
|
|
15840
|
+
/**
|
|
15841
|
+
* Close an SSE stream for a specific request, triggering client reconnection.
|
|
15842
|
+
* Use this to implement polling behavior during long-running operations -
|
|
15843
|
+
* client will reconnect after the retry interval specified in the priming event.
|
|
15844
|
+
*/
|
|
15845
|
+
closeSSEStream(requestId) {
|
|
15846
|
+
this._webStandardTransport.closeSSEStream(requestId);
|
|
15847
|
+
}
|
|
15848
|
+
/**
|
|
15849
|
+
* Close the standalone GET SSE stream, triggering client reconnection.
|
|
15850
|
+
* Use this to implement polling behavior for server-initiated notifications.
|
|
15851
|
+
*/
|
|
15852
|
+
closeStandaloneSSEStream() {
|
|
15853
|
+
this._webStandardTransport.closeStandaloneSSEStream();
|
|
15854
|
+
}
|
|
15855
|
+
};
|
|
15856
|
+
|
|
15196
15857
|
//#endregion
|
|
15197
15858
|
//#region src/startHTTPServer.ts
|
|
15198
15859
|
const getBody = (request) => {
|
|
@@ -15666,7 +16327,7 @@ const startHTTPServer = async ({ apiKey, authenticate, cors, createServer, enabl
|
|
|
15666
16327
|
};
|
|
15667
16328
|
|
|
15668
16329
|
//#endregion
|
|
15669
|
-
//#region node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
16330
|
+
//#region node_modules/.pnpm/@modelcontextprotocol+sdk@1.27.1_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js
|
|
15670
16331
|
function isZ4Schema(s) {
|
|
15671
16332
|
return !!s._zod;
|
|
15672
16333
|
}
|
|
@@ -15675,15 +16336,14 @@ function safeParse(schema, data) {
|
|
|
15675
16336
|
return schema.safeParse(data);
|
|
15676
16337
|
}
|
|
15677
16338
|
function getObjectShape(schema) {
|
|
15678
|
-
var _a, _b;
|
|
15679
16339
|
if (!schema) return void 0;
|
|
15680
16340
|
let rawShape;
|
|
15681
|
-
if (isZ4Schema(schema)) rawShape =
|
|
16341
|
+
if (isZ4Schema(schema)) rawShape = schema._zod?.def?.shape;
|
|
15682
16342
|
else rawShape = schema.shape;
|
|
15683
16343
|
if (!rawShape) return void 0;
|
|
15684
16344
|
if (typeof rawShape === "function") try {
|
|
15685
16345
|
return rawShape();
|
|
15686
|
-
} catch
|
|
16346
|
+
} catch {
|
|
15687
16347
|
return;
|
|
15688
16348
|
}
|
|
15689
16349
|
return rawShape;
|
|
@@ -15694,9 +16354,8 @@ function getObjectShape(schema) {
|
|
|
15694
16354
|
* Returns undefined if the schema is not a literal or the value cannot be determined.
|
|
15695
16355
|
*/
|
|
15696
16356
|
function getLiteralValue(schema) {
|
|
15697
|
-
var _a;
|
|
15698
16357
|
if (isZ4Schema(schema)) {
|
|
15699
|
-
const def$31 =
|
|
16358
|
+
const def$31 = schema._zod?.def;
|
|
15700
16359
|
if (def$31) {
|
|
15701
16360
|
if (def$31.value !== void 0) return def$31.value;
|
|
15702
16361
|
if (Array.isArray(def$31.values) && def$31.values.length > 0) return def$31.values[0];
|
|
@@ -15712,7 +16371,7 @@ function getLiteralValue(schema) {
|
|
|
15712
16371
|
}
|
|
15713
16372
|
|
|
15714
16373
|
//#endregion
|
|
15715
|
-
//#region node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
16374
|
+
//#region node_modules/.pnpm/@modelcontextprotocol+sdk@1.27.1_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/interfaces.js
|
|
15716
16375
|
/**
|
|
15717
16376
|
* Experimental task interfaces for MCP SDK.
|
|
15718
16377
|
* WARNING: These APIs are experimental and may change without notice.
|
|
@@ -15730,10 +16389,9 @@ function isTerminal(status$1) {
|
|
|
15730
16389
|
}
|
|
15731
16390
|
|
|
15732
16391
|
//#endregion
|
|
15733
|
-
//#region node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
16392
|
+
//#region node_modules/.pnpm/@modelcontextprotocol+sdk@1.27.1_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-json-schema-compat.js
|
|
15734
16393
|
function getMethodLiteral(schema) {
|
|
15735
|
-
const
|
|
15736
|
-
const methodSchema = shape === null || shape === void 0 ? void 0 : shape.method;
|
|
16394
|
+
const methodSchema = getObjectShape(schema)?.method;
|
|
15737
16395
|
if (!methodSchema) throw new Error("Schema is missing a method literal");
|
|
15738
16396
|
const value = getLiteralValue(methodSchema);
|
|
15739
16397
|
if (typeof value !== "string") throw new Error("Schema method literal must be a string");
|
|
@@ -15746,7 +16404,7 @@ function parseWithCompat(schema, data) {
|
|
|
15746
16404
|
}
|
|
15747
16405
|
|
|
15748
16406
|
//#endregion
|
|
15749
|
-
//#region node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
16407
|
+
//#region node_modules/.pnpm/@modelcontextprotocol+sdk@1.27.1_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/protocol.js
|
|
15750
16408
|
/**
|
|
15751
16409
|
* The default request timeout, in miliseconds.
|
|
15752
16410
|
*/
|
|
@@ -15775,8 +16433,8 @@ var Protocol = class {
|
|
|
15775
16433
|
this._onprogress(notification);
|
|
15776
16434
|
});
|
|
15777
16435
|
this.setRequestHandler(PingRequestSchema, (_request) => ({}));
|
|
15778
|
-
this._taskStore = _options
|
|
15779
|
-
this._taskMessageQueue = _options
|
|
16436
|
+
this._taskStore = _options?.taskStore;
|
|
16437
|
+
this._taskMessageQueue = _options?.taskMessageQueue;
|
|
15780
16438
|
if (this._taskStore) {
|
|
15781
16439
|
this.setRequestHandler(GetTaskRequestSchema, async (request, extra) => {
|
|
15782
16440
|
const task = await this._taskStore.getTask(request.params.taskId, extra.sessionId);
|
|
@@ -15785,7 +16443,6 @@ var Protocol = class {
|
|
|
15785
16443
|
});
|
|
15786
16444
|
this.setRequestHandler(GetTaskPayloadRequestSchema, async (request, extra) => {
|
|
15787
16445
|
const handleTaskResult = async () => {
|
|
15788
|
-
var _a;
|
|
15789
16446
|
const taskId = request.params.taskId;
|
|
15790
16447
|
if (this._taskMessageQueue) {
|
|
15791
16448
|
let queuedMessage;
|
|
@@ -15807,7 +16464,7 @@ var Protocol = class {
|
|
|
15807
16464
|
}
|
|
15808
16465
|
continue;
|
|
15809
16466
|
}
|
|
15810
|
-
await
|
|
16467
|
+
await this._transport?.send(queuedMessage.message, { relatedRequestId: extra.requestId });
|
|
15811
16468
|
}
|
|
15812
16469
|
}
|
|
15813
16470
|
const task = await this._taskStore.getTask(taskId, extra.sessionId);
|
|
@@ -15832,9 +16489,8 @@ var Protocol = class {
|
|
|
15832
16489
|
return await handleTaskResult();
|
|
15833
16490
|
});
|
|
15834
16491
|
this.setRequestHandler(ListTasksRequestSchema, async (request, extra) => {
|
|
15835
|
-
var _a;
|
|
15836
16492
|
try {
|
|
15837
|
-
const { tasks, nextCursor } = await this._taskStore.listTasks(
|
|
16493
|
+
const { tasks, nextCursor } = await this._taskStore.listTasks(request.params?.cursor, extra.sessionId);
|
|
15838
16494
|
return {
|
|
15839
16495
|
tasks,
|
|
15840
16496
|
nextCursor,
|
|
@@ -15865,8 +16521,8 @@ var Protocol = class {
|
|
|
15865
16521
|
}
|
|
15866
16522
|
}
|
|
15867
16523
|
async _oncancel(notification) {
|
|
15868
|
-
|
|
15869
|
-
|
|
16524
|
+
if (!notification.params.requestId) return;
|
|
16525
|
+
this._requestHandlerAbortControllers.get(notification.params.requestId)?.abort(notification.params.reason);
|
|
15870
16526
|
}
|
|
15871
16527
|
_setupTimeout(messageId, timeout, maxTotalTimeout, onTimeout, resetTimeoutOnProgress = false) {
|
|
15872
16528
|
this._timeoutInfo.set(messageId, {
|
|
@@ -15906,22 +16562,22 @@ var Protocol = class {
|
|
|
15906
16562
|
* The Protocol object assumes ownership of the Transport, replacing any callbacks that have already been set, and expects that it is the only user of the Transport instance going forward.
|
|
15907
16563
|
*/
|
|
15908
16564
|
async connect(transport) {
|
|
15909
|
-
|
|
16565
|
+
if (this._transport) throw new Error("Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.");
|
|
15910
16566
|
this._transport = transport;
|
|
15911
|
-
const _onclose =
|
|
16567
|
+
const _onclose = this.transport?.onclose;
|
|
15912
16568
|
this._transport.onclose = () => {
|
|
15913
|
-
_onclose
|
|
16569
|
+
_onclose?.();
|
|
15914
16570
|
this._onclose();
|
|
15915
16571
|
};
|
|
15916
|
-
const _onerror =
|
|
16572
|
+
const _onerror = this.transport?.onerror;
|
|
15917
16573
|
this._transport.onerror = (error$1) => {
|
|
15918
|
-
_onerror
|
|
16574
|
+
_onerror?.(error$1);
|
|
15919
16575
|
this._onerror(error$1);
|
|
15920
16576
|
};
|
|
15921
|
-
const _onmessage =
|
|
16577
|
+
const _onmessage = this._transport?.onmessage;
|
|
15922
16578
|
this._transport.onmessage = (message, extra) => {
|
|
15923
|
-
_onmessage
|
|
15924
|
-
if (
|
|
16579
|
+
_onmessage?.(message, extra);
|
|
16580
|
+
if (isJSONRPCResultResponse(message) || isJSONRPCErrorResponse(message)) this._onresponse(message);
|
|
15925
16581
|
else if (isJSONRPCRequest(message)) this._onrequest(message, extra);
|
|
15926
16582
|
else if (isJSONRPCNotification(message)) this._onnotification(message);
|
|
15927
16583
|
else this._onerror(/* @__PURE__ */ new Error(`Unknown message type: ${JSON.stringify(message)}`));
|
|
@@ -15929,32 +16585,30 @@ var Protocol = class {
|
|
|
15929
16585
|
await this._transport.start();
|
|
15930
16586
|
}
|
|
15931
16587
|
_onclose() {
|
|
15932
|
-
var _a;
|
|
15933
16588
|
const responseHandlers = this._responseHandlers;
|
|
15934
16589
|
this._responseHandlers = /* @__PURE__ */ new Map();
|
|
15935
16590
|
this._progressHandlers.clear();
|
|
15936
16591
|
this._taskProgressTokens.clear();
|
|
15937
16592
|
this._pendingDebouncedNotifications.clear();
|
|
16593
|
+
for (const controller of this._requestHandlerAbortControllers.values()) controller.abort();
|
|
16594
|
+
this._requestHandlerAbortControllers.clear();
|
|
15938
16595
|
const error$1 = McpError.fromError(ErrorCode.ConnectionClosed, "Connection closed");
|
|
15939
16596
|
this._transport = void 0;
|
|
15940
|
-
|
|
16597
|
+
this.onclose?.();
|
|
15941
16598
|
for (const handler of responseHandlers.values()) handler(error$1);
|
|
15942
16599
|
}
|
|
15943
16600
|
_onerror(error$1) {
|
|
15944
|
-
|
|
15945
|
-
(_a = this.onerror) === null || _a === void 0 || _a.call(this, error$1);
|
|
16601
|
+
this.onerror?.(error$1);
|
|
15946
16602
|
}
|
|
15947
16603
|
_onnotification(notification) {
|
|
15948
|
-
|
|
15949
|
-
const handler = (_a = this._notificationHandlers.get(notification.method)) !== null && _a !== void 0 ? _a : this.fallbackNotificationHandler;
|
|
16604
|
+
const handler = this._notificationHandlers.get(notification.method) ?? this.fallbackNotificationHandler;
|
|
15950
16605
|
if (handler === void 0) return;
|
|
15951
16606
|
Promise.resolve().then(() => handler(notification)).catch((error$1) => this._onerror(/* @__PURE__ */ new Error(`Uncaught error in notification handler: ${error$1}`)));
|
|
15952
16607
|
}
|
|
15953
16608
|
_onrequest(request, extra) {
|
|
15954
|
-
|
|
15955
|
-
const handler = (_a = this._requestHandlers.get(request.method)) !== null && _a !== void 0 ? _a : this.fallbackRequestHandler;
|
|
16609
|
+
const handler = this._requestHandlers.get(request.method) ?? this.fallbackRequestHandler;
|
|
15956
16610
|
const capturedTransport = this._transport;
|
|
15957
|
-
const relatedTaskId =
|
|
16611
|
+
const relatedTaskId = request.params?._meta?.[RELATED_TASK_META_KEY]?.taskId;
|
|
15958
16612
|
if (handler === void 0) {
|
|
15959
16613
|
const errorResponse = {
|
|
15960
16614
|
jsonrpc: "2.0",
|
|
@@ -15968,42 +16622,43 @@ var Protocol = class {
|
|
|
15968
16622
|
type: "error",
|
|
15969
16623
|
message: errorResponse,
|
|
15970
16624
|
timestamp: Date.now()
|
|
15971
|
-
}, capturedTransport
|
|
15972
|
-
else capturedTransport
|
|
16625
|
+
}, capturedTransport?.sessionId).catch((error$1) => this._onerror(/* @__PURE__ */ new Error(`Failed to enqueue error response: ${error$1}`)));
|
|
16626
|
+
else capturedTransport?.send(errorResponse).catch((error$1) => this._onerror(/* @__PURE__ */ new Error(`Failed to send an error response: ${error$1}`)));
|
|
15973
16627
|
return;
|
|
15974
16628
|
}
|
|
15975
16629
|
const abortController = new AbortController();
|
|
15976
16630
|
this._requestHandlerAbortControllers.set(request.id, abortController);
|
|
15977
|
-
const taskCreationParams = (
|
|
15978
|
-
const taskStore = this._taskStore ? this.requestTaskStore(request, capturedTransport
|
|
16631
|
+
const taskCreationParams = isTaskAugmentedRequestParams(request.params) ? request.params.task : void 0;
|
|
16632
|
+
const taskStore = this._taskStore ? this.requestTaskStore(request, capturedTransport?.sessionId) : void 0;
|
|
15979
16633
|
const fullExtra = {
|
|
15980
16634
|
signal: abortController.signal,
|
|
15981
|
-
sessionId: capturedTransport
|
|
15982
|
-
_meta:
|
|
16635
|
+
sessionId: capturedTransport?.sessionId,
|
|
16636
|
+
_meta: request.params?._meta,
|
|
15983
16637
|
sendNotification: async (notification) => {
|
|
16638
|
+
if (abortController.signal.aborted) return;
|
|
15984
16639
|
const notificationOptions = { relatedRequestId: request.id };
|
|
15985
16640
|
if (relatedTaskId) notificationOptions.relatedTask = { taskId: relatedTaskId };
|
|
15986
16641
|
await this.notification(notification, notificationOptions);
|
|
15987
16642
|
},
|
|
15988
16643
|
sendRequest: async (r, resultSchema, options) => {
|
|
15989
|
-
|
|
16644
|
+
if (abortController.signal.aborted) throw new McpError(ErrorCode.ConnectionClosed, "Request was cancelled");
|
|
15990
16645
|
const requestOptions = {
|
|
15991
16646
|
...options,
|
|
15992
16647
|
relatedRequestId: request.id
|
|
15993
16648
|
};
|
|
15994
16649
|
if (relatedTaskId && !requestOptions.relatedTask) requestOptions.relatedTask = { taskId: relatedTaskId };
|
|
15995
|
-
const effectiveTaskId =
|
|
16650
|
+
const effectiveTaskId = requestOptions.relatedTask?.taskId ?? relatedTaskId;
|
|
15996
16651
|
if (effectiveTaskId && taskStore) await taskStore.updateTaskStatus(effectiveTaskId, "input_required");
|
|
15997
16652
|
return await this.request(r, resultSchema, requestOptions);
|
|
15998
16653
|
},
|
|
15999
|
-
authInfo: extra
|
|
16654
|
+
authInfo: extra?.authInfo,
|
|
16000
16655
|
requestId: request.id,
|
|
16001
|
-
requestInfo: extra
|
|
16656
|
+
requestInfo: extra?.requestInfo,
|
|
16002
16657
|
taskId: relatedTaskId,
|
|
16003
16658
|
taskStore,
|
|
16004
|
-
taskRequestedTtl: taskCreationParams
|
|
16005
|
-
closeSSEStream: extra
|
|
16006
|
-
closeStandaloneSSEStream: extra
|
|
16659
|
+
taskRequestedTtl: taskCreationParams?.ttl,
|
|
16660
|
+
closeSSEStream: extra?.closeSSEStream,
|
|
16661
|
+
closeStandaloneSSEStream: extra?.closeStandaloneSSEStream
|
|
16007
16662
|
};
|
|
16008
16663
|
Promise.resolve().then(() => {
|
|
16009
16664
|
if (taskCreationParams) this.assertTaskHandlerCapability(request.method);
|
|
@@ -16018,17 +16673,16 @@ var Protocol = class {
|
|
|
16018
16673
|
type: "response",
|
|
16019
16674
|
message: response,
|
|
16020
16675
|
timestamp: Date.now()
|
|
16021
|
-
}, capturedTransport
|
|
16022
|
-
else await
|
|
16676
|
+
}, capturedTransport?.sessionId);
|
|
16677
|
+
else await capturedTransport?.send(response);
|
|
16023
16678
|
}, async (error$1) => {
|
|
16024
|
-
var _a$1;
|
|
16025
16679
|
if (abortController.signal.aborted) return;
|
|
16026
16680
|
const errorResponse = {
|
|
16027
16681
|
jsonrpc: "2.0",
|
|
16028
16682
|
id: request.id,
|
|
16029
16683
|
error: {
|
|
16030
16684
|
code: Number.isSafeInteger(error$1["code"]) ? error$1["code"] : ErrorCode.InternalError,
|
|
16031
|
-
message:
|
|
16685
|
+
message: error$1.message ?? "Internal error",
|
|
16032
16686
|
...error$1["data"] !== void 0 && { data: error$1["data"] }
|
|
16033
16687
|
}
|
|
16034
16688
|
};
|
|
@@ -16036,8 +16690,8 @@ var Protocol = class {
|
|
|
16036
16690
|
type: "error",
|
|
16037
16691
|
message: errorResponse,
|
|
16038
16692
|
timestamp: Date.now()
|
|
16039
|
-
}, capturedTransport
|
|
16040
|
-
else await
|
|
16693
|
+
}, capturedTransport?.sessionId);
|
|
16694
|
+
else await capturedTransport?.send(errorResponse);
|
|
16041
16695
|
}).catch((error$1) => this._onerror(/* @__PURE__ */ new Error(`Failed to send response: ${error$1}`))).finally(() => {
|
|
16042
16696
|
this._requestHandlerAbortControllers.delete(request.id);
|
|
16043
16697
|
});
|
|
@@ -16068,7 +16722,7 @@ var Protocol = class {
|
|
|
16068
16722
|
const resolver = this._requestResolvers.get(messageId);
|
|
16069
16723
|
if (resolver) {
|
|
16070
16724
|
this._requestResolvers.delete(messageId);
|
|
16071
|
-
if (
|
|
16725
|
+
if (isJSONRPCResultResponse(response)) resolver(response);
|
|
16072
16726
|
else resolver(new McpError(response.error.code, response.error.message, response.error.data));
|
|
16073
16727
|
return;
|
|
16074
16728
|
}
|
|
@@ -16080,7 +16734,7 @@ var Protocol = class {
|
|
|
16080
16734
|
this._responseHandlers.delete(messageId);
|
|
16081
16735
|
this._cleanupTimeout(messageId);
|
|
16082
16736
|
let isTaskResponse = false;
|
|
16083
|
-
if (
|
|
16737
|
+
if (isJSONRPCResultResponse(response) && response.result && typeof response.result === "object") {
|
|
16084
16738
|
const result = response.result;
|
|
16085
16739
|
if (result.task && typeof result.task === "object") {
|
|
16086
16740
|
const task = result.task;
|
|
@@ -16091,7 +16745,7 @@ var Protocol = class {
|
|
|
16091
16745
|
}
|
|
16092
16746
|
}
|
|
16093
16747
|
if (!isTaskResponse) this._progressHandlers.delete(messageId);
|
|
16094
|
-
if (
|
|
16748
|
+
if (isJSONRPCResultResponse(response)) handler(response);
|
|
16095
16749
|
else handler(McpError.fromError(response.error.code, response.error.message, response.error.data));
|
|
16096
16750
|
}
|
|
16097
16751
|
get transport() {
|
|
@@ -16101,8 +16755,7 @@ var Protocol = class {
|
|
|
16101
16755
|
* Closes the connection.
|
|
16102
16756
|
*/
|
|
16103
16757
|
async close() {
|
|
16104
|
-
|
|
16105
|
-
await ((_a = this._transport) === null || _a === void 0 ? void 0 : _a.close());
|
|
16758
|
+
await this._transport?.close();
|
|
16106
16759
|
}
|
|
16107
16760
|
/**
|
|
16108
16761
|
* Sends a request and returns an AsyncGenerator that yields response messages.
|
|
@@ -16132,8 +16785,7 @@ var Protocol = class {
|
|
|
16132
16785
|
* @experimental Use `client.experimental.tasks.requestStream()` to access this method.
|
|
16133
16786
|
*/
|
|
16134
16787
|
async *requestStream(request, resultSchema, options) {
|
|
16135
|
-
|
|
16136
|
-
const { task } = options !== null && options !== void 0 ? options : {};
|
|
16788
|
+
const { task } = options ?? {};
|
|
16137
16789
|
if (!task) {
|
|
16138
16790
|
try {
|
|
16139
16791
|
yield {
|
|
@@ -16186,9 +16838,9 @@ var Protocol = class {
|
|
|
16186
16838
|
};
|
|
16187
16839
|
return;
|
|
16188
16840
|
}
|
|
16189
|
-
const pollInterval =
|
|
16841
|
+
const pollInterval = task$1.pollInterval ?? this._options?.defaultTaskPollInterval ?? 1e3;
|
|
16190
16842
|
await new Promise((resolve$2) => setTimeout(resolve$2, pollInterval));
|
|
16191
|
-
|
|
16843
|
+
options?.signal?.throwIfAborted();
|
|
16192
16844
|
}
|
|
16193
16845
|
} catch (error$1) {
|
|
16194
16846
|
yield {
|
|
@@ -16203,9 +16855,8 @@ var Protocol = class {
|
|
|
16203
16855
|
* Do not use this method to emit notifications! Use notification() instead.
|
|
16204
16856
|
*/
|
|
16205
16857
|
request(request, resultSchema, options) {
|
|
16206
|
-
const { relatedRequestId, resumptionToken, onresumptiontoken, task, relatedTask } = options
|
|
16858
|
+
const { relatedRequestId, resumptionToken, onresumptiontoken, task, relatedTask } = options ?? {};
|
|
16207
16859
|
return new Promise((resolve$2, reject) => {
|
|
16208
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
16209
16860
|
const earlyReject = (error$1) => {
|
|
16210
16861
|
reject(error$1);
|
|
16211
16862
|
};
|
|
@@ -16213,26 +16864,26 @@ var Protocol = class {
|
|
|
16213
16864
|
earlyReject(/* @__PURE__ */ new Error("Not connected"));
|
|
16214
16865
|
return;
|
|
16215
16866
|
}
|
|
16216
|
-
if (
|
|
16867
|
+
if (this._options?.enforceStrictCapabilities === true) try {
|
|
16217
16868
|
this.assertCapabilityForMethod(request.method);
|
|
16218
16869
|
if (task) this.assertTaskCapability(request.method);
|
|
16219
16870
|
} catch (e) {
|
|
16220
16871
|
earlyReject(e);
|
|
16221
16872
|
return;
|
|
16222
16873
|
}
|
|
16223
|
-
|
|
16874
|
+
options?.signal?.throwIfAborted();
|
|
16224
16875
|
const messageId = this._requestMessageId++;
|
|
16225
16876
|
const jsonrpcRequest = {
|
|
16226
16877
|
...request,
|
|
16227
16878
|
jsonrpc: "2.0",
|
|
16228
16879
|
id: messageId
|
|
16229
16880
|
};
|
|
16230
|
-
if (options
|
|
16881
|
+
if (options?.onprogress) {
|
|
16231
16882
|
this._progressHandlers.set(messageId, options.onprogress);
|
|
16232
16883
|
jsonrpcRequest.params = {
|
|
16233
16884
|
...request.params,
|
|
16234
16885
|
_meta: {
|
|
16235
|
-
...
|
|
16886
|
+
...request.params?._meta || {},
|
|
16236
16887
|
progressToken: messageId
|
|
16237
16888
|
}
|
|
16238
16889
|
};
|
|
@@ -16244,16 +16895,15 @@ var Protocol = class {
|
|
|
16244
16895
|
if (relatedTask) jsonrpcRequest.params = {
|
|
16245
16896
|
...jsonrpcRequest.params,
|
|
16246
16897
|
_meta: {
|
|
16247
|
-
...
|
|
16898
|
+
...jsonrpcRequest.params?._meta || {},
|
|
16248
16899
|
[RELATED_TASK_META_KEY]: relatedTask
|
|
16249
16900
|
}
|
|
16250
16901
|
};
|
|
16251
16902
|
const cancel = (reason) => {
|
|
16252
|
-
var _a$1;
|
|
16253
16903
|
this._responseHandlers.delete(messageId);
|
|
16254
16904
|
this._progressHandlers.delete(messageId);
|
|
16255
16905
|
this._cleanupTimeout(messageId);
|
|
16256
|
-
|
|
16906
|
+
this._transport?.send({
|
|
16257
16907
|
jsonrpc: "2.0",
|
|
16258
16908
|
method: "notifications/cancelled",
|
|
16259
16909
|
params: {
|
|
@@ -16268,8 +16918,7 @@ var Protocol = class {
|
|
|
16268
16918
|
reject(reason instanceof McpError ? reason : new McpError(ErrorCode.RequestTimeout, String(reason)));
|
|
16269
16919
|
};
|
|
16270
16920
|
this._responseHandlers.set(messageId, (response) => {
|
|
16271
|
-
|
|
16272
|
-
if ((_a$1 = options === null || options === void 0 ? void 0 : options.signal) === null || _a$1 === void 0 ? void 0 : _a$1.aborted) return;
|
|
16921
|
+
if (options?.signal?.aborted) return;
|
|
16273
16922
|
if (response instanceof Error) return reject(response);
|
|
16274
16923
|
try {
|
|
16275
16924
|
const parseResult = safeParse(resultSchema, response.result);
|
|
@@ -16279,14 +16928,13 @@ var Protocol = class {
|
|
|
16279
16928
|
reject(error$1);
|
|
16280
16929
|
}
|
|
16281
16930
|
});
|
|
16282
|
-
|
|
16283
|
-
|
|
16284
|
-
cancel((_a$1 = options === null || options === void 0 ? void 0 : options.signal) === null || _a$1 === void 0 ? void 0 : _a$1.reason);
|
|
16931
|
+
options?.signal?.addEventListener("abort", () => {
|
|
16932
|
+
cancel(options?.signal?.reason);
|
|
16285
16933
|
});
|
|
16286
|
-
const timeout =
|
|
16934
|
+
const timeout = options?.timeout ?? DEFAULT_REQUEST_TIMEOUT_MSEC;
|
|
16287
16935
|
const timeoutHandler = () => cancel(McpError.fromError(ErrorCode.RequestTimeout, "Request timed out", { timeout }));
|
|
16288
|
-
this._setupTimeout(messageId, timeout, options
|
|
16289
|
-
const relatedTaskId = relatedTask
|
|
16936
|
+
this._setupTimeout(messageId, timeout, options?.maxTotalTimeout, timeoutHandler, options?.resetTimeoutOnProgress ?? false);
|
|
16937
|
+
const relatedTaskId = relatedTask?.taskId;
|
|
16290
16938
|
if (relatedTaskId) {
|
|
16291
16939
|
const responseResolver = (response) => {
|
|
16292
16940
|
const handler = this._responseHandlers.get(messageId);
|
|
@@ -16360,10 +17008,9 @@ var Protocol = class {
|
|
|
16360
17008
|
* Emits a notification, which is a one-way message that does not expect a response.
|
|
16361
17009
|
*/
|
|
16362
17010
|
async notification(notification, options) {
|
|
16363
|
-
var _a, _b, _c, _d, _e;
|
|
16364
17011
|
if (!this._transport) throw new Error("Not connected");
|
|
16365
17012
|
this.assertNotificationCapability(notification.method);
|
|
16366
|
-
const relatedTaskId =
|
|
17013
|
+
const relatedTaskId = options?.relatedTask?.taskId;
|
|
16367
17014
|
if (relatedTaskId) {
|
|
16368
17015
|
const jsonrpcNotification$1 = {
|
|
16369
17016
|
...notification,
|
|
@@ -16371,7 +17018,7 @@ var Protocol = class {
|
|
|
16371
17018
|
params: {
|
|
16372
17019
|
...notification.params,
|
|
16373
17020
|
_meta: {
|
|
16374
|
-
...
|
|
17021
|
+
...notification.params?._meta || {},
|
|
16375
17022
|
[RELATED_TASK_META_KEY]: options.relatedTask
|
|
16376
17023
|
}
|
|
16377
17024
|
}
|
|
@@ -16383,28 +17030,27 @@ var Protocol = class {
|
|
|
16383
17030
|
});
|
|
16384
17031
|
return;
|
|
16385
17032
|
}
|
|
16386
|
-
if ((
|
|
17033
|
+
if ((this._options?.debouncedNotificationMethods ?? []).includes(notification.method) && !notification.params && !options?.relatedRequestId && !options?.relatedTask) {
|
|
16387
17034
|
if (this._pendingDebouncedNotifications.has(notification.method)) return;
|
|
16388
17035
|
this._pendingDebouncedNotifications.add(notification.method);
|
|
16389
17036
|
Promise.resolve().then(() => {
|
|
16390
|
-
var _a$1, _b$1;
|
|
16391
17037
|
this._pendingDebouncedNotifications.delete(notification.method);
|
|
16392
17038
|
if (!this._transport) return;
|
|
16393
17039
|
let jsonrpcNotification$1 = {
|
|
16394
17040
|
...notification,
|
|
16395
17041
|
jsonrpc: "2.0"
|
|
16396
17042
|
};
|
|
16397
|
-
if (options
|
|
17043
|
+
if (options?.relatedTask) jsonrpcNotification$1 = {
|
|
16398
17044
|
...jsonrpcNotification$1,
|
|
16399
17045
|
params: {
|
|
16400
17046
|
...jsonrpcNotification$1.params,
|
|
16401
17047
|
_meta: {
|
|
16402
|
-
...
|
|
17048
|
+
...jsonrpcNotification$1.params?._meta || {},
|
|
16403
17049
|
[RELATED_TASK_META_KEY]: options.relatedTask
|
|
16404
17050
|
}
|
|
16405
17051
|
}
|
|
16406
17052
|
};
|
|
16407
|
-
|
|
17053
|
+
this._transport?.send(jsonrpcNotification$1, options).catch((error$1) => this._onerror(error$1));
|
|
16408
17054
|
});
|
|
16409
17055
|
return;
|
|
16410
17056
|
}
|
|
@@ -16412,12 +17058,12 @@ var Protocol = class {
|
|
|
16412
17058
|
...notification,
|
|
16413
17059
|
jsonrpc: "2.0"
|
|
16414
17060
|
};
|
|
16415
|
-
if (options
|
|
17061
|
+
if (options?.relatedTask) jsonrpcNotification = {
|
|
16416
17062
|
...jsonrpcNotification,
|
|
16417
17063
|
params: {
|
|
16418
17064
|
...jsonrpcNotification.params,
|
|
16419
17065
|
_meta: {
|
|
16420
|
-
...
|
|
17066
|
+
...jsonrpcNotification.params?._meta || {},
|
|
16421
17067
|
[RELATED_TASK_META_KEY]: options.relatedTask
|
|
16422
17068
|
}
|
|
16423
17069
|
}
|
|
@@ -16490,9 +17136,8 @@ var Protocol = class {
|
|
|
16490
17136
|
* simply propagates the error.
|
|
16491
17137
|
*/
|
|
16492
17138
|
async _enqueueTaskMessage(taskId, message, sessionId) {
|
|
16493
|
-
var _a;
|
|
16494
17139
|
if (!this._taskStore || !this._taskMessageQueue) throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");
|
|
16495
|
-
const maxQueueSize =
|
|
17140
|
+
const maxQueueSize = this._options?.maxTaskQueueSize;
|
|
16496
17141
|
await this._taskMessageQueue.enqueue(taskId, message, sessionId, maxQueueSize);
|
|
16497
17142
|
}
|
|
16498
17143
|
/**
|
|
@@ -16521,12 +17166,11 @@ var Protocol = class {
|
|
|
16521
17166
|
* @returns Promise that resolves when an update occurs or rejects if aborted
|
|
16522
17167
|
*/
|
|
16523
17168
|
async _waitForTaskUpdate(taskId, signal) {
|
|
16524
|
-
|
|
16525
|
-
let interval = (_b = (_a = this._options) === null || _a === void 0 ? void 0 : _a.defaultTaskPollInterval) !== null && _b !== void 0 ? _b : 1e3;
|
|
17169
|
+
let interval = this._options?.defaultTaskPollInterval ?? 1e3;
|
|
16526
17170
|
try {
|
|
16527
|
-
const task = await
|
|
16528
|
-
if (task
|
|
16529
|
-
} catch
|
|
17171
|
+
const task = await this._taskStore?.getTask(taskId);
|
|
17172
|
+
if (task?.pollInterval) interval = task.pollInterval;
|
|
17173
|
+
} catch {}
|
|
16530
17174
|
return new Promise((resolve$2, reject) => {
|
|
16531
17175
|
if (signal.aborted) {
|
|
16532
17176
|
reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
|
|
@@ -16611,7 +17255,7 @@ function mergeCapabilities(base, additional) {
|
|
|
16611
17255
|
}
|
|
16612
17256
|
|
|
16613
17257
|
//#endregion
|
|
16614
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
17258
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/codegen/code.js
|
|
16615
17259
|
var require_code$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
16616
17260
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16617
17261
|
exports.regexpCode = exports.getEsmExportName = exports.getProperty = exports.safeStringify = exports.stringify = exports.strConcat = exports.addCodeArg = exports.str = exports._ = exports.nil = exports._Code = exports.Name = exports.IDENTIFIER = exports._CodeOrName = void 0;
|
|
@@ -16747,7 +17391,7 @@ var require_code$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
16747
17391
|
}));
|
|
16748
17392
|
|
|
16749
17393
|
//#endregion
|
|
16750
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
17394
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/codegen/scope.js
|
|
16751
17395
|
var require_scope = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
16752
17396
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16753
17397
|
exports.ValueScope = exports.ValueScopeName = exports.Scope = exports.varKinds = exports.UsedValueState = void 0;
|
|
@@ -16885,7 +17529,7 @@ var require_scope = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
16885
17529
|
}));
|
|
16886
17530
|
|
|
16887
17531
|
//#endregion
|
|
16888
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
17532
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/codegen/index.js
|
|
16889
17533
|
var require_codegen = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
16890
17534
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16891
17535
|
exports.or = exports.and = exports.not = exports.CodeGen = exports.operators = exports.varKinds = exports.ValueScopeName = exports.ValueScope = exports.Scope = exports.Name = exports.regexpCode = exports.stringify = exports.getProperty = exports.nil = exports.strConcat = exports.str = exports._ = void 0;
|
|
@@ -17555,7 +18199,7 @@ var require_codegen = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
17555
18199
|
}));
|
|
17556
18200
|
|
|
17557
18201
|
//#endregion
|
|
17558
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
18202
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/util.js
|
|
17559
18203
|
var require_util = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
17560
18204
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17561
18205
|
exports.checkStrictMode = exports.getErrorPath = exports.Type = exports.useFunc = exports.setEvaluated = exports.evaluatedPropsToName = exports.mergeEvaluated = exports.eachItem = exports.unescapeJsonPointer = exports.escapeJsonPointer = exports.escapeFragment = exports.unescapeFragment = exports.schemaRefOrVal = exports.schemaHasRulesButRef = exports.schemaHasRules = exports.checkUnknownRules = exports.alwaysValidSchema = exports.toHash = void 0;
|
|
@@ -17697,7 +18341,7 @@ var require_util = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
17697
18341
|
}));
|
|
17698
18342
|
|
|
17699
18343
|
//#endregion
|
|
17700
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
18344
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/names.js
|
|
17701
18345
|
var require_names = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
17702
18346
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17703
18347
|
const codegen_1$36 = require_codegen();
|
|
@@ -17723,12 +18367,12 @@ var require_names = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
17723
18367
|
}));
|
|
17724
18368
|
|
|
17725
18369
|
//#endregion
|
|
17726
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
18370
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/errors.js
|
|
17727
18371
|
var require_errors = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
17728
18372
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17729
18373
|
exports.extendErrors = exports.resetErrorsCount = exports.reportExtraError = exports.reportError = exports.keyword$DataError = exports.keywordError = void 0;
|
|
17730
18374
|
const codegen_1$35 = require_codegen();
|
|
17731
|
-
const util_1$
|
|
18375
|
+
const util_1$30 = require_util();
|
|
17732
18376
|
const names_1$7 = require_names();
|
|
17733
18377
|
exports.keywordError = { message: ({ keyword }) => (0, codegen_1$35.str)`must pass "${keyword}" keyword validation` };
|
|
17734
18378
|
exports.keyword$DataError = { message: ({ keyword, schemaType }) => schemaType ? (0, codegen_1$35.str)`"${keyword}" keyword must be ${schemaType} ($data)` : (0, codegen_1$35.str)`"${keyword}" keyword is invalid ($data)` };
|
|
@@ -17801,12 +18445,12 @@ var require_errors = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
17801
18445
|
return gen.object(...keyValues);
|
|
17802
18446
|
}
|
|
17803
18447
|
function errorInstancePath({ errorPath }, { instancePath }) {
|
|
17804
|
-
const instPath = instancePath ? (0, codegen_1$35.str)`${errorPath}${(0, util_1$
|
|
18448
|
+
const instPath = instancePath ? (0, codegen_1$35.str)`${errorPath}${(0, util_1$30.getErrorPath)(instancePath, util_1$30.Type.Str)}` : errorPath;
|
|
17805
18449
|
return [names_1$7.default.instancePath, (0, codegen_1$35.strConcat)(names_1$7.default.instancePath, instPath)];
|
|
17806
18450
|
}
|
|
17807
18451
|
function errorSchemaPath({ keyword, it: { errSchemaPath } }, { schemaPath, parentSchema }) {
|
|
17808
18452
|
let schPath = parentSchema ? errSchemaPath : (0, codegen_1$35.str)`${errSchemaPath}/${keyword}`;
|
|
17809
|
-
if (schemaPath) schPath = (0, codegen_1$35.str)`${schPath}${(0, util_1$
|
|
18453
|
+
if (schemaPath) schPath = (0, codegen_1$35.str)`${schPath}${(0, util_1$30.getErrorPath)(schemaPath, util_1$30.Type.Str)}`;
|
|
17810
18454
|
return [E.schemaPath, schPath];
|
|
17811
18455
|
}
|
|
17812
18456
|
function extraErrorProps(cxt, { params, message }, keyValues) {
|
|
@@ -17820,7 +18464,7 @@ var require_errors = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
17820
18464
|
}));
|
|
17821
18465
|
|
|
17822
18466
|
//#endregion
|
|
17823
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
18467
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/validate/boolSchema.js
|
|
17824
18468
|
var require_boolSchema = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
17825
18469
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17826
18470
|
exports.boolOrEmptySchema = exports.topBoolOrEmptySchema = void 0;
|
|
@@ -17863,7 +18507,7 @@ var require_boolSchema = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
17863
18507
|
}));
|
|
17864
18508
|
|
|
17865
18509
|
//#endregion
|
|
17866
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
18510
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/rules.js
|
|
17867
18511
|
var require_rules = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
17868
18512
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17869
18513
|
exports.getRules = exports.isJSONType = void 0;
|
|
@@ -17922,7 +18566,7 @@ var require_rules = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
17922
18566
|
}));
|
|
17923
18567
|
|
|
17924
18568
|
//#endregion
|
|
17925
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
18569
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/validate/applicability.js
|
|
17926
18570
|
var require_applicability = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
17927
18571
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17928
18572
|
exports.shouldUseRule = exports.shouldUseGroup = exports.schemaHasRulesForType = void 0;
|
|
@@ -17943,7 +18587,7 @@ var require_applicability = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
17943
18587
|
}));
|
|
17944
18588
|
|
|
17945
18589
|
//#endregion
|
|
17946
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
18590
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/validate/dataType.js
|
|
17947
18591
|
var require_dataType = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
17948
18592
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17949
18593
|
exports.reportTypeError = exports.checkDataTypes = exports.checkDataType = exports.coerceAndCheckDataType = exports.getJSONTypes = exports.getSchemaTypes = exports.DataType = void 0;
|
|
@@ -17951,7 +18595,7 @@ var require_dataType = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
17951
18595
|
const applicability_1$1 = require_applicability();
|
|
17952
18596
|
const errors_1$2 = require_errors();
|
|
17953
18597
|
const codegen_1$33 = require_codegen();
|
|
17954
|
-
const util_1$
|
|
18598
|
+
const util_1$29 = require_util();
|
|
17955
18599
|
var DataType;
|
|
17956
18600
|
(function(DataType$1) {
|
|
17957
18601
|
DataType$1[DataType$1["Correct"] = 0] = "Correct";
|
|
@@ -18068,7 +18712,7 @@ var require_dataType = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
18068
18712
|
function checkDataTypes(dataTypes, data, strictNums, correct) {
|
|
18069
18713
|
if (dataTypes.length === 1) return checkDataType(dataTypes[0], data, strictNums, correct);
|
|
18070
18714
|
let cond;
|
|
18071
|
-
const types = (0, util_1$
|
|
18715
|
+
const types = (0, util_1$29.toHash)(dataTypes);
|
|
18072
18716
|
if (types.array && types.object) {
|
|
18073
18717
|
const notObj = (0, codegen_1$33._)`typeof ${data} != "object"`;
|
|
18074
18718
|
cond = types.null ? notObj : (0, codegen_1$33._)`!${data} || ${notObj}`;
|
|
@@ -18092,7 +18736,7 @@ var require_dataType = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
18092
18736
|
exports.reportTypeError = reportTypeError;
|
|
18093
18737
|
function getTypeErrorContext(it) {
|
|
18094
18738
|
const { gen, data, schema } = it;
|
|
18095
|
-
const schemaCode = (0, util_1$
|
|
18739
|
+
const schemaCode = (0, util_1$29.schemaRefOrVal)(it, schema, "type");
|
|
18096
18740
|
return {
|
|
18097
18741
|
gen,
|
|
18098
18742
|
keyword: "type",
|
|
@@ -18108,12 +18752,12 @@ var require_dataType = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
18108
18752
|
}));
|
|
18109
18753
|
|
|
18110
18754
|
//#endregion
|
|
18111
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
18755
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/validate/defaults.js
|
|
18112
18756
|
var require_defaults = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
18113
18757
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18114
18758
|
exports.assignDefaults = void 0;
|
|
18115
18759
|
const codegen_1$32 = require_codegen();
|
|
18116
|
-
const util_1$
|
|
18760
|
+
const util_1$28 = require_util();
|
|
18117
18761
|
function assignDefaults(it, ty) {
|
|
18118
18762
|
const { properties, items } = it.schema;
|
|
18119
18763
|
if (ty === "object" && properties) for (const key$1 in properties) assignDefault(it, key$1, properties[key$1].default);
|
|
@@ -18125,7 +18769,7 @@ var require_defaults = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
18125
18769
|
if (defaultValue === void 0) return;
|
|
18126
18770
|
const childData = (0, codegen_1$32._)`${data}${(0, codegen_1$32.getProperty)(prop)}`;
|
|
18127
18771
|
if (compositeRule) {
|
|
18128
|
-
(0, util_1$
|
|
18772
|
+
(0, util_1$28.checkStrictMode)(it, `default is ignored for: ${childData}`);
|
|
18129
18773
|
return;
|
|
18130
18774
|
}
|
|
18131
18775
|
let condition = (0, codegen_1$32._)`${childData} === undefined`;
|
|
@@ -18135,12 +18779,12 @@ var require_defaults = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
18135
18779
|
}));
|
|
18136
18780
|
|
|
18137
18781
|
//#endregion
|
|
18138
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
18782
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/code.js
|
|
18139
18783
|
var require_code = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
18140
18784
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18141
18785
|
exports.validateUnion = exports.validateArray = exports.usePattern = exports.callValidateCode = exports.schemaProperties = exports.allSchemaProperties = exports.noPropertyInData = exports.propertyInData = exports.isOwnProperty = exports.hasPropFunc = exports.reportMissingProp = exports.checkMissingProp = exports.checkReportMissingProp = void 0;
|
|
18142
18786
|
const codegen_1$31 = require_codegen();
|
|
18143
|
-
const util_1$
|
|
18787
|
+
const util_1$27 = require_util();
|
|
18144
18788
|
const names_1$5 = require_names();
|
|
18145
18789
|
const util_2$1 = require_util();
|
|
18146
18790
|
function checkReportMissingProp(cxt, prop) {
|
|
@@ -18186,7 +18830,7 @@ var require_code = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
18186
18830
|
}
|
|
18187
18831
|
exports.allSchemaProperties = allSchemaProperties;
|
|
18188
18832
|
function schemaProperties(it, schemaMap) {
|
|
18189
|
-
return allSchemaProperties(schemaMap).filter((p) => !(0, util_1$
|
|
18833
|
+
return allSchemaProperties(schemaMap).filter((p) => !(0, util_1$27.alwaysValidSchema)(it, schemaMap[p]));
|
|
18190
18834
|
}
|
|
18191
18835
|
exports.schemaProperties = schemaProperties;
|
|
18192
18836
|
function callValidateCode({ schemaCode, data, it: { gen, topSchemaRef, schemaPath, errorPath }, it }, func, context, passSchema) {
|
|
@@ -18231,7 +18875,7 @@ var require_code = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
18231
18875
|
cxt.subschema({
|
|
18232
18876
|
keyword,
|
|
18233
18877
|
dataProp: i$3,
|
|
18234
|
-
dataPropType: util_1$
|
|
18878
|
+
dataPropType: util_1$27.Type.Num
|
|
18235
18879
|
}, valid);
|
|
18236
18880
|
gen.if((0, codegen_1$31.not)(valid), notValid);
|
|
18237
18881
|
});
|
|
@@ -18242,7 +18886,7 @@ var require_code = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
18242
18886
|
const { gen, schema, keyword, it } = cxt;
|
|
18243
18887
|
/* istanbul ignore if */
|
|
18244
18888
|
if (!Array.isArray(schema)) throw new Error("ajv implementation error");
|
|
18245
|
-
if (schema.some((sch) => (0, util_1$
|
|
18889
|
+
if (schema.some((sch) => (0, util_1$27.alwaysValidSchema)(it, sch)) && !it.opts.unevaluated) return;
|
|
18246
18890
|
const valid = gen.let("valid", false);
|
|
18247
18891
|
const schValid = gen.name("_valid");
|
|
18248
18892
|
gen.block(() => schema.forEach((_sch, i$3) => {
|
|
@@ -18260,7 +18904,7 @@ var require_code = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
18260
18904
|
}));
|
|
18261
18905
|
|
|
18262
18906
|
//#endregion
|
|
18263
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
18907
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/validate/keyword.js
|
|
18264
18908
|
var require_keyword = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
18265
18909
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18266
18910
|
exports.validateKeywordUsage = exports.validSchemaType = exports.funcKeywordCode = exports.macroKeywordCode = void 0;
|
|
@@ -18367,12 +19011,12 @@ var require_keyword = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
18367
19011
|
}));
|
|
18368
19012
|
|
|
18369
19013
|
//#endregion
|
|
18370
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
19014
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/validate/subschema.js
|
|
18371
19015
|
var require_subschema = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
18372
19016
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18373
19017
|
exports.extendSubschemaMode = exports.extendSubschemaData = exports.getSubschema = void 0;
|
|
18374
19018
|
const codegen_1$29 = require_codegen();
|
|
18375
|
-
const util_1$
|
|
19019
|
+
const util_1$26 = require_util();
|
|
18376
19020
|
function getSubschema(it, { keyword, schemaProp, schema, schemaPath, errSchemaPath, topSchemaRef }) {
|
|
18377
19021
|
if (keyword !== void 0 && schema !== void 0) throw new Error("both \"keyword\" and \"schema\" passed, only one allowed");
|
|
18378
19022
|
if (keyword !== void 0) {
|
|
@@ -18384,7 +19028,7 @@ var require_subschema = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
18384
19028
|
} : {
|
|
18385
19029
|
schema: sch[schemaProp],
|
|
18386
19030
|
schemaPath: (0, codegen_1$29._)`${it.schemaPath}${(0, codegen_1$29.getProperty)(keyword)}${(0, codegen_1$29.getProperty)(schemaProp)}`,
|
|
18387
|
-
errSchemaPath: `${it.errSchemaPath}/${keyword}/${(0, util_1$
|
|
19031
|
+
errSchemaPath: `${it.errSchemaPath}/${keyword}/${(0, util_1$26.escapeFragment)(schemaProp)}`
|
|
18388
19032
|
};
|
|
18389
19033
|
}
|
|
18390
19034
|
if (schema !== void 0) {
|
|
@@ -18405,7 +19049,7 @@ var require_subschema = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
18405
19049
|
if (dataProp !== void 0) {
|
|
18406
19050
|
const { errorPath, dataPathArr, opts } = it;
|
|
18407
19051
|
dataContextProps(gen.let("data", (0, codegen_1$29._)`${it.data}${(0, codegen_1$29.getProperty)(dataProp)}`, true));
|
|
18408
|
-
subschema.errorPath = (0, codegen_1$29.str)`${errorPath}${(0, util_1$
|
|
19052
|
+
subschema.errorPath = (0, codegen_1$29.str)`${errorPath}${(0, util_1$26.getErrorPath)(dataProp, dpType, opts.jsPropertySyntax)}`;
|
|
18409
19053
|
subschema.parentDataProperty = (0, codegen_1$29._)`${dataProp}`;
|
|
18410
19054
|
subschema.dataPathArr = [...dataPathArr, subschema.parentDataProperty];
|
|
18411
19055
|
}
|
|
@@ -18542,11 +19186,11 @@ var require_json_schema_traverse = /* @__PURE__ */ __commonJSMin(((exports, modu
|
|
|
18542
19186
|
}));
|
|
18543
19187
|
|
|
18544
19188
|
//#endregion
|
|
18545
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
19189
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/resolve.js
|
|
18546
19190
|
var require_resolve = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
18547
19191
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18548
19192
|
exports.getSchemaRefs = exports.resolveUrl = exports.normalizeId = exports._getFullPath = exports.getFullPath = exports.inlineRef = void 0;
|
|
18549
|
-
const util_1$
|
|
19193
|
+
const util_1$25 = require_util();
|
|
18550
19194
|
const equal$2 = require_fast_deep_equal();
|
|
18551
19195
|
const traverse = require_json_schema_traverse();
|
|
18552
19196
|
const SIMPLE_INLINED = new Set([
|
|
@@ -18596,7 +19240,7 @@ var require_resolve = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
18596
19240
|
if (key$1 === "$ref") return Infinity;
|
|
18597
19241
|
count++;
|
|
18598
19242
|
if (SIMPLE_INLINED.has(key$1)) continue;
|
|
18599
|
-
if (typeof schema[key$1] == "object") (0, util_1$
|
|
19243
|
+
if (typeof schema[key$1] == "object") (0, util_1$25.eachItem)(schema[key$1], (sch) => count += countKeys(sch));
|
|
18600
19244
|
if (count === Infinity) return Infinity;
|
|
18601
19245
|
}
|
|
18602
19246
|
return count;
|
|
@@ -18670,7 +19314,7 @@ var require_resolve = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
18670
19314
|
}));
|
|
18671
19315
|
|
|
18672
19316
|
//#endregion
|
|
18673
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
19317
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/validate/index.js
|
|
18674
19318
|
var require_validate = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
18675
19319
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18676
19320
|
exports.getData = exports.KeywordCxt = exports.validateFunctionCode = void 0;
|
|
@@ -18684,7 +19328,7 @@ var require_validate = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
18684
19328
|
const codegen_1$28 = require_codegen();
|
|
18685
19329
|
const names_1$3 = require_names();
|
|
18686
19330
|
const resolve_1$3 = require_resolve();
|
|
18687
|
-
const util_1$
|
|
19331
|
+
const util_1$24 = require_util();
|
|
18688
19332
|
const errors_1 = require_errors();
|
|
18689
19333
|
function validateFunctionCode(it) {
|
|
18690
19334
|
if (isSchemaObj(it)) {
|
|
@@ -18773,7 +19417,7 @@ var require_validate = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
18773
19417
|
gen.var(valid, (0, codegen_1$28._)`${errsCount} === ${names_1$3.default.errors}`);
|
|
18774
19418
|
}
|
|
18775
19419
|
function checkKeywords(it) {
|
|
18776
|
-
(0, util_1$
|
|
19420
|
+
(0, util_1$24.checkUnknownRules)(it);
|
|
18777
19421
|
checkRefsAndKeywords(it);
|
|
18778
19422
|
}
|
|
18779
19423
|
function typeAndKeywords(it, errsCount) {
|
|
@@ -18783,11 +19427,11 @@ var require_validate = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
18783
19427
|
}
|
|
18784
19428
|
function checkRefsAndKeywords(it) {
|
|
18785
19429
|
const { schema, errSchemaPath, opts, self } = it;
|
|
18786
|
-
if (schema.$ref && opts.ignoreKeywordsWithRef && (0, util_1$
|
|
19430
|
+
if (schema.$ref && opts.ignoreKeywordsWithRef && (0, util_1$24.schemaHasRulesButRef)(schema, self.RULES)) self.logger.warn(`$ref: keywords ignored in schema at path "${errSchemaPath}"`);
|
|
18787
19431
|
}
|
|
18788
19432
|
function checkNoDefault(it) {
|
|
18789
19433
|
const { schema, opts } = it;
|
|
18790
|
-
if (schema.default !== void 0 && opts.useDefaults && opts.strictSchema) (0, util_1$
|
|
19434
|
+
if (schema.default !== void 0 && opts.useDefaults && opts.strictSchema) (0, util_1$24.checkStrictMode)(it, "default is ignored in the schema root");
|
|
18791
19435
|
}
|
|
18792
19436
|
function updateContext(it) {
|
|
18793
19437
|
const schId = it.schema[it.opts.schemaId];
|
|
@@ -18821,7 +19465,7 @@ var require_validate = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
18821
19465
|
function schemaKeywords(it, types, typeErrors, errsCount) {
|
|
18822
19466
|
const { gen, schema, data, allErrors, opts, self } = it;
|
|
18823
19467
|
const { RULES } = self;
|
|
18824
|
-
if (schema.$ref && (opts.ignoreKeywordsWithRef || !(0, util_1$
|
|
19468
|
+
if (schema.$ref && (opts.ignoreKeywordsWithRef || !(0, util_1$24.schemaHasRulesButRef)(schema, RULES))) {
|
|
18825
19469
|
gen.block(() => keywordCode(it, "$ref", RULES.all.$ref.definition));
|
|
18826
19470
|
return;
|
|
18827
19471
|
}
|
|
@@ -18896,7 +19540,7 @@ var require_validate = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
18896
19540
|
function strictTypesError(it, msg) {
|
|
18897
19541
|
const schemaPath = it.schemaEnv.baseId + it.errSchemaPath;
|
|
18898
19542
|
msg += ` at "${schemaPath}" (strictTypes)`;
|
|
18899
|
-
(0, util_1$
|
|
19543
|
+
(0, util_1$24.checkStrictMode)(it, msg, it.opts.strictTypes);
|
|
18900
19544
|
}
|
|
18901
19545
|
var KeywordCxt = class {
|
|
18902
19546
|
constructor(it, def$30, keyword) {
|
|
@@ -18907,7 +19551,7 @@ var require_validate = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
18907
19551
|
this.data = it.data;
|
|
18908
19552
|
this.schema = it.schema[keyword];
|
|
18909
19553
|
this.$data = def$30.$data && it.opts.$data && this.schema && this.schema.$data;
|
|
18910
|
-
this.schemaValue = (0, util_1$
|
|
19554
|
+
this.schemaValue = (0, util_1$24.schemaRefOrVal)(it, this.schema, keyword, this.$data);
|
|
18911
19555
|
this.schemaType = def$30.schemaType;
|
|
18912
19556
|
this.parentSchema = it.schema;
|
|
18913
19557
|
this.params = {};
|
|
@@ -19033,8 +19677,8 @@ var require_validate = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
19033
19677
|
mergeEvaluated(schemaCxt, toName) {
|
|
19034
19678
|
const { it, gen } = this;
|
|
19035
19679
|
if (!it.opts.unevaluated) return;
|
|
19036
|
-
if (it.props !== true && schemaCxt.props !== void 0) it.props = util_1$
|
|
19037
|
-
if (it.items !== true && schemaCxt.items !== void 0) it.items = util_1$
|
|
19680
|
+
if (it.props !== true && schemaCxt.props !== void 0) it.props = util_1$24.mergeEvaluated.props(gen, schemaCxt.props, it.props, toName);
|
|
19681
|
+
if (it.items !== true && schemaCxt.items !== void 0) it.items = util_1$24.mergeEvaluated.items(gen, schemaCxt.items, it.items, toName);
|
|
19038
19682
|
}
|
|
19039
19683
|
mergeValidEvaluated(schemaCxt, valid) {
|
|
19040
19684
|
const { it, gen } = this;
|
|
@@ -19078,7 +19722,7 @@ var require_validate = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
19078
19722
|
let expr = data;
|
|
19079
19723
|
const segments = jsonPointer.split("/");
|
|
19080
19724
|
for (const segment of segments) if (segment) {
|
|
19081
|
-
data = (0, codegen_1$28._)`${data}${(0, codegen_1$28.getProperty)((0, util_1$
|
|
19725
|
+
data = (0, codegen_1$28._)`${data}${(0, codegen_1$28.getProperty)((0, util_1$24.unescapeJsonPointer)(segment))}`;
|
|
19082
19726
|
expr = (0, codegen_1$28._)`${expr} && ${data}`;
|
|
19083
19727
|
}
|
|
19084
19728
|
return expr;
|
|
@@ -19090,7 +19734,7 @@ var require_validate = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
19090
19734
|
}));
|
|
19091
19735
|
|
|
19092
19736
|
//#endregion
|
|
19093
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
19737
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/runtime/validation_error.js
|
|
19094
19738
|
var require_validation_error = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
19095
19739
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19096
19740
|
var ValidationError = class extends Error {
|
|
@@ -19104,7 +19748,7 @@ var require_validation_error = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
19104
19748
|
}));
|
|
19105
19749
|
|
|
19106
19750
|
//#endregion
|
|
19107
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
19751
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/ref_error.js
|
|
19108
19752
|
var require_ref_error = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
19109
19753
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19110
19754
|
const resolve_1$2 = require_resolve();
|
|
@@ -19119,7 +19763,7 @@ var require_ref_error = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
19119
19763
|
}));
|
|
19120
19764
|
|
|
19121
19765
|
//#endregion
|
|
19122
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
19766
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/index.js
|
|
19123
19767
|
var require_compile = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
19124
19768
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19125
19769
|
exports.resolveSchema = exports.getCompilingSchema = exports.resolveRef = exports.compileSchema = exports.SchemaEnv = void 0;
|
|
@@ -19127,7 +19771,7 @@ var require_compile = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
19127
19771
|
const validation_error_1$2 = require_validation_error();
|
|
19128
19772
|
const names_1$2 = require_names();
|
|
19129
19773
|
const resolve_1$1 = require_resolve();
|
|
19130
|
-
const util_1$
|
|
19774
|
+
const util_1$23 = require_util();
|
|
19131
19775
|
const validate_1$3 = require_validate();
|
|
19132
19776
|
var SchemaEnv = class {
|
|
19133
19777
|
constructor(env) {
|
|
@@ -19311,14 +19955,14 @@ var require_compile = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
19311
19955
|
if (((_a = parsedRef.fragment) === null || _a === void 0 ? void 0 : _a[0]) !== "/") return;
|
|
19312
19956
|
for (const part of parsedRef.fragment.slice(1).split("/")) {
|
|
19313
19957
|
if (typeof schema === "boolean") return;
|
|
19314
|
-
const partSchema = schema[(0, util_1$
|
|
19958
|
+
const partSchema = schema[(0, util_1$23.unescapeFragment)(part)];
|
|
19315
19959
|
if (partSchema === void 0) return;
|
|
19316
19960
|
schema = partSchema;
|
|
19317
19961
|
const schId = typeof schema === "object" && schema[this.opts.schemaId];
|
|
19318
19962
|
if (!PREVENT_SCOPE_CHANGE.has(part) && schId) baseId = (0, resolve_1$1.resolveUrl)(this.opts.uriResolver, baseId, schId);
|
|
19319
19963
|
}
|
|
19320
19964
|
let env;
|
|
19321
|
-
if (typeof schema != "boolean" && schema.$ref && !(0, util_1$
|
|
19965
|
+
if (typeof schema != "boolean" && schema.$ref && !(0, util_1$23.schemaHasRulesButRef)(schema, this.RULES)) {
|
|
19322
19966
|
const $ref = (0, resolve_1$1.resolveUrl)(this.opts.uriResolver, baseId, schema.$ref);
|
|
19323
19967
|
env = resolveSchema.call(this, root, $ref);
|
|
19324
19968
|
}
|
|
@@ -19334,7 +19978,7 @@ var require_compile = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
19334
19978
|
}));
|
|
19335
19979
|
|
|
19336
19980
|
//#endregion
|
|
19337
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
19981
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/refs/data.json
|
|
19338
19982
|
var require_data = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
19339
19983
|
module.exports = {
|
|
19340
19984
|
"$id": "https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",
|
|
@@ -20049,7 +20693,7 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
20049
20693
|
}));
|
|
20050
20694
|
|
|
20051
20695
|
//#endregion
|
|
20052
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
20696
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/runtime/uri.js
|
|
20053
20697
|
var require_uri = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
20054
20698
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20055
20699
|
const uri$1 = require_fast_uri();
|
|
@@ -20058,7 +20702,7 @@ var require_uri = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
20058
20702
|
}));
|
|
20059
20703
|
|
|
20060
20704
|
//#endregion
|
|
20061
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
20705
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/core.js
|
|
20062
20706
|
var require_core$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
20063
20707
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20064
20708
|
exports.CodeGen = exports.Name = exports.nil = exports.stringify = exports.str = exports._ = exports.KeywordCxt = void 0;
|
|
@@ -20113,7 +20757,7 @@ var require_core$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
20113
20757
|
const codegen_2 = require_codegen();
|
|
20114
20758
|
const resolve_1 = require_resolve();
|
|
20115
20759
|
const dataType_1$1 = require_dataType();
|
|
20116
|
-
const util_1$
|
|
20760
|
+
const util_1$22 = require_util();
|
|
20117
20761
|
const $dataRefSchema = require_data();
|
|
20118
20762
|
const uri_1 = require_uri();
|
|
20119
20763
|
const defaultRegExp = (str$1, flags) => new RegExp(str$1, flags);
|
|
@@ -20375,8 +21019,8 @@ var require_core$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
20375
21019
|
return this;
|
|
20376
21020
|
}
|
|
20377
21021
|
case "object": {
|
|
20378
|
-
const cacheKey = schemaKeyRef;
|
|
20379
|
-
this._cache.delete(cacheKey);
|
|
21022
|
+
const cacheKey$1 = schemaKeyRef;
|
|
21023
|
+
this._cache.delete(cacheKey$1);
|
|
20380
21024
|
let id = schemaKeyRef[this.opts.schemaId];
|
|
20381
21025
|
if (id) {
|
|
20382
21026
|
id = (0, resolve_1.normalizeId)(id);
|
|
@@ -20407,7 +21051,7 @@ var require_core$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
20407
21051
|
} else throw new Error("invalid addKeywords parameters");
|
|
20408
21052
|
checkKeyword.call(this, keyword, def$30);
|
|
20409
21053
|
if (!def$30) {
|
|
20410
|
-
(0, util_1$
|
|
21054
|
+
(0, util_1$22.eachItem)(keyword, (kwd) => addRule.call(this, kwd));
|
|
20411
21055
|
return this;
|
|
20412
21056
|
}
|
|
20413
21057
|
keywordMetaschema.call(this, def$30);
|
|
@@ -20416,7 +21060,7 @@ var require_core$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
20416
21060
|
type: (0, dataType_1$1.getJSONTypes)(def$30.type),
|
|
20417
21061
|
schemaType: (0, dataType_1$1.getJSONTypes)(def$30.schemaType)
|
|
20418
21062
|
};
|
|
20419
|
-
(0, util_1$
|
|
21063
|
+
(0, util_1$22.eachItem)(keyword, definition.type.length === 0 ? (k) => addRule.call(this, k, definition) : (k) => definition.type.forEach((t) => addRule.call(this, k, definition, t)));
|
|
20420
21064
|
return this;
|
|
20421
21065
|
}
|
|
20422
21066
|
getKeyword(keyword) {
|
|
@@ -20572,7 +21216,7 @@ var require_core$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
20572
21216
|
const KEYWORD_NAME = /^[a-z_$][a-z0-9_$:-]*$/i;
|
|
20573
21217
|
function checkKeyword(keyword, def$30) {
|
|
20574
21218
|
const { RULES } = this;
|
|
20575
|
-
(0, util_1$
|
|
21219
|
+
(0, util_1$22.eachItem)(keyword, (kwd) => {
|
|
20576
21220
|
if (RULES.keywords[kwd]) throw new Error(`Keyword ${kwd} is already defined`);
|
|
20577
21221
|
if (!KEYWORD_NAME.test(kwd)) throw new Error(`Keyword ${kwd} has invalid name`);
|
|
20578
21222
|
});
|
|
@@ -20628,7 +21272,7 @@ var require_core$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
20628
21272
|
}));
|
|
20629
21273
|
|
|
20630
21274
|
//#endregion
|
|
20631
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
21275
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/core/id.js
|
|
20632
21276
|
var require_id = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
20633
21277
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20634
21278
|
const def$29 = {
|
|
@@ -20641,7 +21285,7 @@ var require_id = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
20641
21285
|
}));
|
|
20642
21286
|
|
|
20643
21287
|
//#endregion
|
|
20644
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
21288
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/core/ref.js
|
|
20645
21289
|
var require_ref = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
20646
21290
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20647
21291
|
exports.callRef = exports.getValidate = void 0;
|
|
@@ -20650,7 +21294,7 @@ var require_ref = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
20650
21294
|
const codegen_1$25 = require_codegen();
|
|
20651
21295
|
const names_1$1 = require_names();
|
|
20652
21296
|
const compile_1$1 = require_compile();
|
|
20653
|
-
const util_1$
|
|
21297
|
+
const util_1$21 = require_util();
|
|
20654
21298
|
const def$28 = {
|
|
20655
21299
|
keyword: "$ref",
|
|
20656
21300
|
schemaType: "string",
|
|
@@ -20727,16 +21371,16 @@ var require_ref = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
20727
21371
|
if (!it.opts.unevaluated) return;
|
|
20728
21372
|
const schEvaluated = (_a = sch === null || sch === void 0 ? void 0 : sch.validate) === null || _a === void 0 ? void 0 : _a.evaluated;
|
|
20729
21373
|
if (it.props !== true) if (schEvaluated && !schEvaluated.dynamicProps) {
|
|
20730
|
-
if (schEvaluated.props !== void 0) it.props = util_1$
|
|
21374
|
+
if (schEvaluated.props !== void 0) it.props = util_1$21.mergeEvaluated.props(gen, schEvaluated.props, it.props);
|
|
20731
21375
|
} else {
|
|
20732
21376
|
const props = gen.var("props", (0, codegen_1$25._)`${source}.evaluated.props`);
|
|
20733
|
-
it.props = util_1$
|
|
21377
|
+
it.props = util_1$21.mergeEvaluated.props(gen, props, it.props, codegen_1$25.Name);
|
|
20734
21378
|
}
|
|
20735
21379
|
if (it.items !== true) if (schEvaluated && !schEvaluated.dynamicItems) {
|
|
20736
|
-
if (schEvaluated.items !== void 0) it.items = util_1$
|
|
21380
|
+
if (schEvaluated.items !== void 0) it.items = util_1$21.mergeEvaluated.items(gen, schEvaluated.items, it.items);
|
|
20737
21381
|
} else {
|
|
20738
21382
|
const items = gen.var("items", (0, codegen_1$25._)`${source}.evaluated.items`);
|
|
20739
|
-
it.items = util_1$
|
|
21383
|
+
it.items = util_1$21.mergeEvaluated.items(gen, items, it.items, codegen_1$25.Name);
|
|
20740
21384
|
}
|
|
20741
21385
|
}
|
|
20742
21386
|
}
|
|
@@ -20745,7 +21389,7 @@ var require_ref = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
20745
21389
|
}));
|
|
20746
21390
|
|
|
20747
21391
|
//#endregion
|
|
20748
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
21392
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/core/index.js
|
|
20749
21393
|
var require_core = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
20750
21394
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20751
21395
|
const id_1 = require_id();
|
|
@@ -20764,7 +21408,7 @@ var require_core = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
20764
21408
|
}));
|
|
20765
21409
|
|
|
20766
21410
|
//#endregion
|
|
20767
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
21411
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/limitNumber.js
|
|
20768
21412
|
var require_limitNumber = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
20769
21413
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20770
21414
|
const codegen_1$24 = require_codegen();
|
|
@@ -20809,7 +21453,7 @@ var require_limitNumber = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
20809
21453
|
}));
|
|
20810
21454
|
|
|
20811
21455
|
//#endregion
|
|
20812
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
21456
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/multipleOf.js
|
|
20813
21457
|
var require_multipleOf = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
20814
21458
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20815
21459
|
const codegen_1$23 = require_codegen();
|
|
@@ -20834,7 +21478,7 @@ var require_multipleOf = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
20834
21478
|
}));
|
|
20835
21479
|
|
|
20836
21480
|
//#endregion
|
|
20837
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
21481
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/runtime/ucs2length.js
|
|
20838
21482
|
var require_ucs2length = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
20839
21483
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20840
21484
|
function ucs2length(str$1) {
|
|
@@ -20857,11 +21501,11 @@ var require_ucs2length = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
20857
21501
|
}));
|
|
20858
21502
|
|
|
20859
21503
|
//#endregion
|
|
20860
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
21504
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/limitLength.js
|
|
20861
21505
|
var require_limitLength = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
20862
21506
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20863
21507
|
const codegen_1$22 = require_codegen();
|
|
20864
|
-
const util_1$
|
|
21508
|
+
const util_1$20 = require_util();
|
|
20865
21509
|
const ucs2length_1 = require_ucs2length();
|
|
20866
21510
|
const def$25 = {
|
|
20867
21511
|
keyword: ["maxLength", "minLength"],
|
|
@@ -20878,7 +21522,7 @@ var require_limitLength = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
20878
21522
|
code(cxt) {
|
|
20879
21523
|
const { keyword, data, schemaCode, it } = cxt;
|
|
20880
21524
|
const op = keyword === "maxLength" ? codegen_1$22.operators.GT : codegen_1$22.operators.LT;
|
|
20881
|
-
const len = it.opts.unicode === false ? (0, codegen_1$22._)`${data}.length` : (0, codegen_1$22._)`${(0, util_1$
|
|
21525
|
+
const len = it.opts.unicode === false ? (0, codegen_1$22._)`${data}.length` : (0, codegen_1$22._)`${(0, util_1$20.useFunc)(cxt.gen, ucs2length_1.default)}(${data})`;
|
|
20882
21526
|
cxt.fail$data((0, codegen_1$22._)`${len} ${op} ${schemaCode}`);
|
|
20883
21527
|
}
|
|
20884
21528
|
};
|
|
@@ -20886,10 +21530,11 @@ var require_limitLength = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
20886
21530
|
}));
|
|
20887
21531
|
|
|
20888
21532
|
//#endregion
|
|
20889
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
21533
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/pattern.js
|
|
20890
21534
|
var require_pattern = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
20891
21535
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20892
21536
|
const code_1$7 = require_code();
|
|
21537
|
+
const util_1$19 = require_util();
|
|
20893
21538
|
const codegen_1$21 = require_codegen();
|
|
20894
21539
|
const def$24 = {
|
|
20895
21540
|
keyword: "pattern",
|
|
@@ -20901,17 +21546,25 @@ var require_pattern = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
20901
21546
|
params: ({ schemaCode }) => (0, codegen_1$21._)`{pattern: ${schemaCode}}`
|
|
20902
21547
|
},
|
|
20903
21548
|
code(cxt) {
|
|
20904
|
-
const { data, $data, schema, schemaCode, it } = cxt;
|
|
21549
|
+
const { gen, data, $data, schema, schemaCode, it } = cxt;
|
|
20905
21550
|
const u = it.opts.unicodeRegExp ? "u" : "";
|
|
20906
|
-
|
|
20907
|
-
|
|
21551
|
+
if ($data) {
|
|
21552
|
+
const { regExp } = it.opts.code;
|
|
21553
|
+
const regExpCode = regExp.code === "new RegExp" ? (0, codegen_1$21._)`new RegExp` : (0, util_1$19.useFunc)(gen, regExp);
|
|
21554
|
+
const valid = gen.let("valid");
|
|
21555
|
+
gen.try(() => gen.assign(valid, (0, codegen_1$21._)`${regExpCode}(${schemaCode}, ${u}).test(${data})`), () => gen.assign(valid, false));
|
|
21556
|
+
cxt.fail$data((0, codegen_1$21._)`!${valid}`);
|
|
21557
|
+
} else {
|
|
21558
|
+
const regExp = (0, code_1$7.usePattern)(cxt, schema);
|
|
21559
|
+
cxt.fail$data((0, codegen_1$21._)`!${regExp}.test(${data})`);
|
|
21560
|
+
}
|
|
20908
21561
|
}
|
|
20909
21562
|
};
|
|
20910
21563
|
exports.default = def$24;
|
|
20911
21564
|
}));
|
|
20912
21565
|
|
|
20913
21566
|
//#endregion
|
|
20914
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
21567
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/limitProperties.js
|
|
20915
21568
|
var require_limitProperties = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
20916
21569
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20917
21570
|
const codegen_1$20 = require_codegen();
|
|
@@ -20937,7 +21590,7 @@ var require_limitProperties = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
20937
21590
|
}));
|
|
20938
21591
|
|
|
20939
21592
|
//#endregion
|
|
20940
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
21593
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/required.js
|
|
20941
21594
|
var require_required = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
20942
21595
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20943
21596
|
const code_1$6 = require_code();
|
|
@@ -21005,7 +21658,7 @@ var require_required = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
21005
21658
|
}));
|
|
21006
21659
|
|
|
21007
21660
|
//#endregion
|
|
21008
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
21661
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/limitItems.js
|
|
21009
21662
|
var require_limitItems = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
21010
21663
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21011
21664
|
const codegen_1$18 = require_codegen();
|
|
@@ -21031,7 +21684,7 @@ var require_limitItems = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
21031
21684
|
}));
|
|
21032
21685
|
|
|
21033
21686
|
//#endregion
|
|
21034
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
21687
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/runtime/equal.js
|
|
21035
21688
|
var require_equal = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
21036
21689
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21037
21690
|
const equal = require_fast_deep_equal();
|
|
@@ -21040,7 +21693,7 @@ var require_equal = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
21040
21693
|
}));
|
|
21041
21694
|
|
|
21042
21695
|
//#endregion
|
|
21043
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
21696
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/uniqueItems.js
|
|
21044
21697
|
var require_uniqueItems = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
21045
21698
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21046
21699
|
const dataType_1 = require_dataType();
|
|
@@ -21105,7 +21758,7 @@ var require_uniqueItems = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
21105
21758
|
}));
|
|
21106
21759
|
|
|
21107
21760
|
//#endregion
|
|
21108
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
21761
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/const.js
|
|
21109
21762
|
var require_const = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
21110
21763
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21111
21764
|
const codegen_1$16 = require_codegen();
|
|
@@ -21128,7 +21781,7 @@ var require_const = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
21128
21781
|
}));
|
|
21129
21782
|
|
|
21130
21783
|
//#endregion
|
|
21131
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
21784
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/enum.js
|
|
21132
21785
|
var require_enum = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
21133
21786
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21134
21787
|
const codegen_1$15 = require_codegen();
|
|
@@ -21173,7 +21826,7 @@ var require_enum = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
21173
21826
|
}));
|
|
21174
21827
|
|
|
21175
21828
|
//#endregion
|
|
21176
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
21829
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/index.js
|
|
21177
21830
|
var require_validation = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
21178
21831
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21179
21832
|
const limitNumber_1 = require_limitNumber();
|
|
@@ -21210,7 +21863,7 @@ var require_validation = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
21210
21863
|
}));
|
|
21211
21864
|
|
|
21212
21865
|
//#endregion
|
|
21213
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
21866
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/additionalItems.js
|
|
21214
21867
|
var require_additionalItems = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
21215
21868
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21216
21869
|
exports.validateAdditionalItems = void 0;
|
|
@@ -21263,7 +21916,7 @@ var require_additionalItems = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
21263
21916
|
}));
|
|
21264
21917
|
|
|
21265
21918
|
//#endregion
|
|
21266
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
21919
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/items.js
|
|
21267
21920
|
var require_items = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
21268
21921
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21269
21922
|
exports.validateTuple = void 0;
|
|
@@ -21317,7 +21970,7 @@ var require_items = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
21317
21970
|
}));
|
|
21318
21971
|
|
|
21319
21972
|
//#endregion
|
|
21320
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
21973
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/prefixItems.js
|
|
21321
21974
|
var require_prefixItems = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
21322
21975
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21323
21976
|
const items_1$1 = require_items();
|
|
@@ -21332,7 +21985,7 @@ var require_prefixItems = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
21332
21985
|
}));
|
|
21333
21986
|
|
|
21334
21987
|
//#endregion
|
|
21335
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
21988
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/items2020.js
|
|
21336
21989
|
var require_items2020 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
21337
21990
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21338
21991
|
const codegen_1$12 = require_codegen();
|
|
@@ -21361,7 +22014,7 @@ var require_items2020 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
21361
22014
|
}));
|
|
21362
22015
|
|
|
21363
22016
|
//#endregion
|
|
21364
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
22017
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/contains.js
|
|
21365
22018
|
var require_contains = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
21366
22019
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21367
22020
|
const codegen_1$11 = require_codegen();
|
|
@@ -21447,7 +22100,7 @@ var require_contains = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
21447
22100
|
}));
|
|
21448
22101
|
|
|
21449
22102
|
//#endregion
|
|
21450
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
22103
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/dependencies.js
|
|
21451
22104
|
var require_dependencies = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
21452
22105
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21453
22106
|
exports.validateSchemaDeps = exports.validatePropertyDeps = exports.error = void 0;
|
|
@@ -21529,7 +22182,7 @@ var require_dependencies = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
21529
22182
|
}));
|
|
21530
22183
|
|
|
21531
22184
|
//#endregion
|
|
21532
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
22185
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/propertyNames.js
|
|
21533
22186
|
var require_propertyNames = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
21534
22187
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21535
22188
|
const codegen_1$9 = require_codegen();
|
|
@@ -21567,7 +22220,7 @@ var require_propertyNames = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
21567
22220
|
}));
|
|
21568
22221
|
|
|
21569
22222
|
//#endregion
|
|
21570
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
22223
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js
|
|
21571
22224
|
var require_additionalProperties = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
21572
22225
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21573
22226
|
const code_1$2 = require_code();
|
|
@@ -21658,7 +22311,7 @@ var require_additionalProperties = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
21658
22311
|
}));
|
|
21659
22312
|
|
|
21660
22313
|
//#endregion
|
|
21661
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
22314
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/properties.js
|
|
21662
22315
|
var require_properties = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
21663
22316
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21664
22317
|
const validate_1$1 = require_validate();
|
|
@@ -21705,7 +22358,7 @@ var require_properties = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
21705
22358
|
}));
|
|
21706
22359
|
|
|
21707
22360
|
//#endregion
|
|
21708
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
22361
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/patternProperties.js
|
|
21709
22362
|
var require_patternProperties = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
21710
22363
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21711
22364
|
const code_1 = require_code();
|
|
@@ -21762,7 +22415,7 @@ var require_patternProperties = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
21762
22415
|
}));
|
|
21763
22416
|
|
|
21764
22417
|
//#endregion
|
|
21765
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
22418
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/not.js
|
|
21766
22419
|
var require_not = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
21767
22420
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21768
22421
|
const util_1$5 = require_util();
|
|
@@ -21791,7 +22444,7 @@ var require_not = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
21791
22444
|
}));
|
|
21792
22445
|
|
|
21793
22446
|
//#endregion
|
|
21794
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
22447
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/anyOf.js
|
|
21795
22448
|
var require_anyOf = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
21796
22449
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21797
22450
|
const def$6 = {
|
|
@@ -21805,7 +22458,7 @@ var require_anyOf = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
21805
22458
|
}));
|
|
21806
22459
|
|
|
21807
22460
|
//#endregion
|
|
21808
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
22461
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/oneOf.js
|
|
21809
22462
|
var require_oneOf = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
21810
22463
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21811
22464
|
const codegen_1$6 = require_codegen();
|
|
@@ -21853,7 +22506,7 @@ var require_oneOf = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
21853
22506
|
}));
|
|
21854
22507
|
|
|
21855
22508
|
//#endregion
|
|
21856
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
22509
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/allOf.js
|
|
21857
22510
|
var require_allOf = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
21858
22511
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21859
22512
|
const util_1$3 = require_util();
|
|
@@ -21880,7 +22533,7 @@ var require_allOf = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
21880
22533
|
}));
|
|
21881
22534
|
|
|
21882
22535
|
//#endregion
|
|
21883
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
22536
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/if.js
|
|
21884
22537
|
var require_if = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
21885
22538
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21886
22539
|
const codegen_1$5 = require_codegen();
|
|
@@ -21938,7 +22591,7 @@ var require_if = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
21938
22591
|
}));
|
|
21939
22592
|
|
|
21940
22593
|
//#endregion
|
|
21941
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
22594
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/thenElse.js
|
|
21942
22595
|
var require_thenElse = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
21943
22596
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21944
22597
|
const util_1$1 = require_util();
|
|
@@ -21953,7 +22606,7 @@ var require_thenElse = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
21953
22606
|
}));
|
|
21954
22607
|
|
|
21955
22608
|
//#endregion
|
|
21956
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
22609
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/index.js
|
|
21957
22610
|
var require_applicator = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
21958
22611
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21959
22612
|
const additionalItems_1 = require_additionalItems();
|
|
@@ -21995,7 +22648,7 @@ var require_applicator = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
21995
22648
|
}));
|
|
21996
22649
|
|
|
21997
22650
|
//#endregion
|
|
21998
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
22651
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/format/format.js
|
|
21999
22652
|
var require_format$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
22000
22653
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22001
22654
|
const codegen_1$4 = require_codegen();
|
|
@@ -22085,7 +22738,7 @@ var require_format$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
22085
22738
|
}));
|
|
22086
22739
|
|
|
22087
22740
|
//#endregion
|
|
22088
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
22741
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/format/index.js
|
|
22089
22742
|
var require_format = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
22090
22743
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22091
22744
|
const format = [require_format$1().default];
|
|
@@ -22093,7 +22746,7 @@ var require_format = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
22093
22746
|
}));
|
|
22094
22747
|
|
|
22095
22748
|
//#endregion
|
|
22096
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
22749
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/metadata.js
|
|
22097
22750
|
var require_metadata = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
22098
22751
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22099
22752
|
exports.contentVocabulary = exports.metadataVocabulary = void 0;
|
|
@@ -22114,7 +22767,7 @@ var require_metadata = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
22114
22767
|
}));
|
|
22115
22768
|
|
|
22116
22769
|
//#endregion
|
|
22117
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
22770
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/draft7.js
|
|
22118
22771
|
var require_draft7 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
22119
22772
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22120
22773
|
const core_1$1 = require_core();
|
|
@@ -22134,7 +22787,7 @@ var require_draft7 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
22134
22787
|
}));
|
|
22135
22788
|
|
|
22136
22789
|
//#endregion
|
|
22137
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
22790
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/discriminator/types.js
|
|
22138
22791
|
var require_types = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
22139
22792
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22140
22793
|
exports.DiscrError = void 0;
|
|
@@ -22146,7 +22799,7 @@ var require_types = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
22146
22799
|
}));
|
|
22147
22800
|
|
|
22148
22801
|
//#endregion
|
|
22149
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
22802
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/discriminator/index.js
|
|
22150
22803
|
var require_discriminator = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
22151
22804
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22152
22805
|
const codegen_1$3 = require_codegen();
|
|
@@ -22241,7 +22894,7 @@ var require_discriminator = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
22241
22894
|
}));
|
|
22242
22895
|
|
|
22243
22896
|
//#endregion
|
|
22244
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
22897
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/refs/json-schema-draft-07.json
|
|
22245
22898
|
var require_json_schema_draft_07 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
22246
22899
|
module.exports = {
|
|
22247
22900
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
@@ -22380,7 +23033,7 @@ var require_json_schema_draft_07 = /* @__PURE__ */ __commonJSMin(((exports, modu
|
|
|
22380
23033
|
}));
|
|
22381
23034
|
|
|
22382
23035
|
//#endregion
|
|
22383
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
23036
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/ajv.js
|
|
22384
23037
|
var require_ajv = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
22385
23038
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22386
23039
|
exports.MissingRefError = exports.ValidationError = exports.CodeGen = exports.Name = exports.nil = exports.stringify = exports.str = exports._ = exports.KeywordCxt = exports.Ajv = void 0;
|
|
@@ -22473,7 +23126,7 @@ var require_ajv = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
22473
23126
|
}));
|
|
22474
23127
|
|
|
22475
23128
|
//#endregion
|
|
22476
|
-
//#region node_modules/.pnpm/ajv-formats@3.0.1_ajv@8.
|
|
23129
|
+
//#region node_modules/.pnpm/ajv-formats@3.0.1_ajv@8.18.0/node_modules/ajv-formats/dist/formats.js
|
|
22477
23130
|
var require_formats = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
22478
23131
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22479
23132
|
exports.formatNames = exports.fastFormats = exports.fullFormats = void 0;
|
|
@@ -22662,7 +23315,7 @@ var require_formats = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
22662
23315
|
}));
|
|
22663
23316
|
|
|
22664
23317
|
//#endregion
|
|
22665
|
-
//#region node_modules/.pnpm/ajv-formats@3.0.1_ajv@8.
|
|
23318
|
+
//#region node_modules/.pnpm/ajv-formats@3.0.1_ajv@8.18.0/node_modules/ajv-formats/dist/limit.js
|
|
22666
23319
|
var require_limit = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
22667
23320
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22668
23321
|
exports.formatLimitDefinition = void 0;
|
|
@@ -22742,7 +23395,7 @@ var require_limit = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
22742
23395
|
}));
|
|
22743
23396
|
|
|
22744
23397
|
//#endregion
|
|
22745
|
-
//#region node_modules/.pnpm/ajv-formats@3.0.1_ajv@8.
|
|
23398
|
+
//#region node_modules/.pnpm/ajv-formats@3.0.1_ajv@8.18.0/node_modules/ajv-formats/dist/index.js
|
|
22746
23399
|
var require_dist = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
22747
23400
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22748
23401
|
const formats_1 = require_formats();
|
|
@@ -22777,11 +23430,11 @@ var require_dist = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
22777
23430
|
}));
|
|
22778
23431
|
|
|
22779
23432
|
//#endregion
|
|
22780
|
-
//#region node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
22781
|
-
var import_ajv = require_ajv();
|
|
23433
|
+
//#region node_modules/.pnpm/@modelcontextprotocol+sdk@1.27.1_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/validation/ajv-provider.js
|
|
23434
|
+
var import_ajv = /* @__PURE__ */ __toESM(require_ajv(), 1);
|
|
22782
23435
|
var import_dist = /* @__PURE__ */ __toESM(require_dist(), 1);
|
|
22783
23436
|
function createDefaultAjvInstance() {
|
|
22784
|
-
const ajv = new import_ajv.
|
|
23437
|
+
const ajv = new import_ajv.default({
|
|
22785
23438
|
strict: false,
|
|
22786
23439
|
validateFormats: true,
|
|
22787
23440
|
validateSchema: false,
|
|
@@ -22825,7 +23478,7 @@ var AjvJsonSchemaValidator = class {
|
|
|
22825
23478
|
* ```
|
|
22826
23479
|
*/
|
|
22827
23480
|
constructor(ajv) {
|
|
22828
|
-
this._ajv = ajv
|
|
23481
|
+
this._ajv = ajv ?? createDefaultAjvInstance();
|
|
22829
23482
|
}
|
|
22830
23483
|
/**
|
|
22831
23484
|
* Create a validator for the given JSON Schema
|
|
@@ -22837,8 +23490,7 @@ var AjvJsonSchemaValidator = class {
|
|
|
22837
23490
|
* @returns A validator function that validates input data
|
|
22838
23491
|
*/
|
|
22839
23492
|
getValidator(schema) {
|
|
22840
|
-
|
|
22841
|
-
const ajvValidator = "$id" in schema && typeof schema.$id === "string" ? (_a = this._ajv.getSchema(schema.$id)) !== null && _a !== void 0 ? _a : this._ajv.compile(schema) : this._ajv.compile(schema);
|
|
23493
|
+
const ajvValidator = "$id" in schema && typeof schema.$id === "string" ? this._ajv.getSchema(schema.$id) ?? this._ajv.compile(schema) : this._ajv.compile(schema);
|
|
22842
23494
|
return (input) => {
|
|
22843
23495
|
if (ajvValidator(input)) return {
|
|
22844
23496
|
valid: true,
|
|
@@ -22855,7 +23507,7 @@ var AjvJsonSchemaValidator = class {
|
|
|
22855
23507
|
};
|
|
22856
23508
|
|
|
22857
23509
|
//#endregion
|
|
22858
|
-
//#region node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
23510
|
+
//#region node_modules/.pnpm/@modelcontextprotocol+sdk@1.27.1_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/client.js
|
|
22859
23511
|
/**
|
|
22860
23512
|
* Experimental client task features for MCP SDK.
|
|
22861
23513
|
* WARNING: These APIs are experimental and may change without notice.
|
|
@@ -22914,11 +23566,10 @@ var ExperimentalClientTasks = class {
|
|
|
22914
23566
|
* @experimental
|
|
22915
23567
|
*/
|
|
22916
23568
|
async *callToolStream(params, resultSchema = CallToolResultSchema, options) {
|
|
22917
|
-
var _a;
|
|
22918
23569
|
const clientInternal = this._client;
|
|
22919
23570
|
const optionsWithTask = {
|
|
22920
23571
|
...options,
|
|
22921
|
-
task:
|
|
23572
|
+
task: options?.task ?? (clientInternal.isToolTask(params.name) ? {} : void 0)
|
|
22922
23573
|
};
|
|
22923
23574
|
const stream = clientInternal.requestStream({
|
|
22924
23575
|
method: "tools/call",
|
|
@@ -23030,7 +23681,7 @@ var ExperimentalClientTasks = class {
|
|
|
23030
23681
|
};
|
|
23031
23682
|
|
|
23032
23683
|
//#endregion
|
|
23033
|
-
//#region node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
23684
|
+
//#region node_modules/.pnpm/@modelcontextprotocol+sdk@1.27.1_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/helpers.js
|
|
23034
23685
|
/**
|
|
23035
23686
|
* Experimental task capability assertion helpers.
|
|
23036
23687
|
* WARNING: These APIs are experimental and may change without notice.
|
|
@@ -23049,11 +23700,10 @@ var ExperimentalClientTasks = class {
|
|
|
23049
23700
|
* @experimental
|
|
23050
23701
|
*/
|
|
23051
23702
|
function assertToolsCallTaskCapability(requests, method, entityName) {
|
|
23052
|
-
var _a;
|
|
23053
23703
|
if (!requests) throw new Error(`${entityName} does not support task creation (required for ${method})`);
|
|
23054
23704
|
switch (method) {
|
|
23055
23705
|
case "tools/call":
|
|
23056
|
-
if (!
|
|
23706
|
+
if (!requests.tools?.call) throw new Error(`${entityName} does not support task creation for tools/call (required for ${method})`);
|
|
23057
23707
|
break;
|
|
23058
23708
|
default: break;
|
|
23059
23709
|
}
|
|
@@ -23070,21 +23720,20 @@ function assertToolsCallTaskCapability(requests, method, entityName) {
|
|
|
23070
23720
|
* @experimental
|
|
23071
23721
|
*/
|
|
23072
23722
|
function assertClientRequestTaskCapability(requests, method, entityName) {
|
|
23073
|
-
var _a, _b;
|
|
23074
23723
|
if (!requests) throw new Error(`${entityName} does not support task creation (required for ${method})`);
|
|
23075
23724
|
switch (method) {
|
|
23076
23725
|
case "sampling/createMessage":
|
|
23077
|
-
if (!
|
|
23726
|
+
if (!requests.sampling?.createMessage) throw new Error(`${entityName} does not support task creation for sampling/createMessage (required for ${method})`);
|
|
23078
23727
|
break;
|
|
23079
23728
|
case "elicitation/create":
|
|
23080
|
-
if (!
|
|
23729
|
+
if (!requests.elicitation?.create) throw new Error(`${entityName} does not support task creation for elicitation/create (required for ${method})`);
|
|
23081
23730
|
break;
|
|
23082
23731
|
default: break;
|
|
23083
23732
|
}
|
|
23084
23733
|
}
|
|
23085
23734
|
|
|
23086
23735
|
//#endregion
|
|
23087
|
-
//#region node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
23736
|
+
//#region node_modules/.pnpm/@modelcontextprotocol+sdk@1.27.1_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/client/index.js
|
|
23088
23737
|
/**
|
|
23089
23738
|
* Elicitation default application helper. Applies defaults to the data based on the schema.
|
|
23090
23739
|
*
|
|
@@ -23102,8 +23751,12 @@ function applyElicitationDefaults(schema, data) {
|
|
|
23102
23751
|
if (obj[key$1] !== void 0) applyElicitationDefaults(propSchema, obj[key$1]);
|
|
23103
23752
|
}
|
|
23104
23753
|
}
|
|
23105
|
-
if (Array.isArray(schema.anyOf))
|
|
23106
|
-
|
|
23754
|
+
if (Array.isArray(schema.anyOf)) {
|
|
23755
|
+
for (const sub of schema.anyOf) if (typeof sub !== "boolean") applyElicitationDefaults(sub, data);
|
|
23756
|
+
}
|
|
23757
|
+
if (Array.isArray(schema.oneOf)) {
|
|
23758
|
+
for (const sub of schema.oneOf) if (typeof sub !== "boolean") applyElicitationDefaults(sub, data);
|
|
23759
|
+
}
|
|
23107
23760
|
}
|
|
23108
23761
|
/**
|
|
23109
23762
|
* Determines which elicitation modes are supported based on declared client capabilities.
|
|
@@ -23157,14 +23810,32 @@ var Client = class extends Protocol {
|
|
|
23157
23810
|
* Initializes this client with the given name and version information.
|
|
23158
23811
|
*/
|
|
23159
23812
|
constructor(_clientInfo, options) {
|
|
23160
|
-
var _a, _b;
|
|
23161
23813
|
super(options);
|
|
23162
23814
|
this._clientInfo = _clientInfo;
|
|
23163
23815
|
this._cachedToolOutputValidators = /* @__PURE__ */ new Map();
|
|
23164
23816
|
this._cachedKnownTaskTools = /* @__PURE__ */ new Set();
|
|
23165
23817
|
this._cachedRequiredTaskTools = /* @__PURE__ */ new Set();
|
|
23166
|
-
this.
|
|
23167
|
-
this.
|
|
23818
|
+
this._listChangedDebounceTimers = /* @__PURE__ */ new Map();
|
|
23819
|
+
this._capabilities = options?.capabilities ?? {};
|
|
23820
|
+
this._jsonSchemaValidator = options?.jsonSchemaValidator ?? new AjvJsonSchemaValidator();
|
|
23821
|
+
if (options?.listChanged) this._pendingListChangedConfig = options.listChanged;
|
|
23822
|
+
}
|
|
23823
|
+
/**
|
|
23824
|
+
* Set up handlers for list changed notifications based on config and server capabilities.
|
|
23825
|
+
* This should only be called after initialization when server capabilities are known.
|
|
23826
|
+
* Handlers are silently skipped if the server doesn't advertise the corresponding listChanged capability.
|
|
23827
|
+
* @internal
|
|
23828
|
+
*/
|
|
23829
|
+
_setupListChangedHandlers(config$1) {
|
|
23830
|
+
if (config$1.tools && this._serverCapabilities?.tools?.listChanged) this._setupListChangedHandler("tools", ToolListChangedNotificationSchema, config$1.tools, async () => {
|
|
23831
|
+
return (await this.listTools()).tools;
|
|
23832
|
+
});
|
|
23833
|
+
if (config$1.prompts && this._serverCapabilities?.prompts?.listChanged) this._setupListChangedHandler("prompts", PromptListChangedNotificationSchema, config$1.prompts, async () => {
|
|
23834
|
+
return (await this.listPrompts()).prompts;
|
|
23835
|
+
});
|
|
23836
|
+
if (config$1.resources && this._serverCapabilities?.resources?.listChanged) this._setupListChangedHandler("resources", ResourceListChangedNotificationSchema, config$1.resources, async () => {
|
|
23837
|
+
return (await this.listResources()).resources;
|
|
23838
|
+
});
|
|
23168
23839
|
}
|
|
23169
23840
|
/**
|
|
23170
23841
|
* Access experimental features.
|
|
@@ -23190,35 +23861,30 @@ var Client = class extends Protocol {
|
|
|
23190
23861
|
* Override request handler registration to enforce client-side validation for elicitation.
|
|
23191
23862
|
*/
|
|
23192
23863
|
setRequestHandler(requestSchema, handler) {
|
|
23193
|
-
|
|
23194
|
-
const shape = getObjectShape(requestSchema);
|
|
23195
|
-
const methodSchema = shape === null || shape === void 0 ? void 0 : shape.method;
|
|
23864
|
+
const methodSchema = getObjectShape(requestSchema)?.method;
|
|
23196
23865
|
if (!methodSchema) throw new Error("Schema is missing a method literal");
|
|
23197
23866
|
let methodValue;
|
|
23198
23867
|
if (isZ4Schema(methodSchema)) {
|
|
23199
23868
|
const v4Schema = methodSchema;
|
|
23200
|
-
|
|
23201
|
-
methodValue = (_b = v4Def === null || v4Def === void 0 ? void 0 : v4Def.value) !== null && _b !== void 0 ? _b : v4Schema.value;
|
|
23869
|
+
methodValue = (v4Schema._zod?.def)?.value ?? v4Schema.value;
|
|
23202
23870
|
} else {
|
|
23203
23871
|
const v3Schema = methodSchema;
|
|
23204
|
-
|
|
23205
|
-
methodValue = (_c = legacyDef === null || legacyDef === void 0 ? void 0 : legacyDef.value) !== null && _c !== void 0 ? _c : v3Schema.value;
|
|
23872
|
+
methodValue = v3Schema._def?.value ?? v3Schema.value;
|
|
23206
23873
|
}
|
|
23207
23874
|
if (typeof methodValue !== "string") throw new Error("Schema method literal must be a string");
|
|
23208
23875
|
const method = methodValue;
|
|
23209
23876
|
if (method === "elicitation/create") {
|
|
23210
23877
|
const wrappedHandler = async (request, extra) => {
|
|
23211
|
-
var _a$1, _b$1, _c$1;
|
|
23212
23878
|
const validatedRequest = safeParse(ElicitRequestSchema, request);
|
|
23213
23879
|
if (!validatedRequest.success) {
|
|
23214
23880
|
const errorMessage = validatedRequest.error instanceof Error ? validatedRequest.error.message : String(validatedRequest.error);
|
|
23215
23881
|
throw new McpError(ErrorCode.InvalidParams, `Invalid elicitation request: ${errorMessage}`);
|
|
23216
23882
|
}
|
|
23217
23883
|
const { params } = validatedRequest.data;
|
|
23218
|
-
|
|
23884
|
+
params.mode = params.mode ?? "form";
|
|
23219
23885
|
const { supportsFormMode, supportsUrlMode } = getSupportedElicitationModes(this._capabilities.elicitation);
|
|
23220
|
-
if (mode === "form" && !supportsFormMode) throw new McpError(ErrorCode.InvalidParams, "Client does not support form-mode elicitation requests");
|
|
23221
|
-
if (mode === "url" && !supportsUrlMode) throw new McpError(ErrorCode.InvalidParams, "Client does not support URL-mode elicitation requests");
|
|
23886
|
+
if (params.mode === "form" && !supportsFormMode) throw new McpError(ErrorCode.InvalidParams, "Client does not support form-mode elicitation requests");
|
|
23887
|
+
if (params.mode === "url" && !supportsUrlMode) throw new McpError(ErrorCode.InvalidParams, "Client does not support URL-mode elicitation requests");
|
|
23222
23888
|
const result = await Promise.resolve(handler(request, extra));
|
|
23223
23889
|
if (params.task) {
|
|
23224
23890
|
const taskValidationResult = safeParse(CreateTaskResultSchema, result);
|
|
@@ -23234,11 +23900,11 @@ var Client = class extends Protocol {
|
|
|
23234
23900
|
throw new McpError(ErrorCode.InvalidParams, `Invalid elicitation result: ${errorMessage}`);
|
|
23235
23901
|
}
|
|
23236
23902
|
const validatedResult = validationResult.data;
|
|
23237
|
-
const requestedSchema = mode === "form" ? params.requestedSchema : void 0;
|
|
23238
|
-
if (mode === "form" && validatedResult.action === "accept" && validatedResult.content && requestedSchema) {
|
|
23239
|
-
if (
|
|
23903
|
+
const requestedSchema = params.mode === "form" ? params.requestedSchema : void 0;
|
|
23904
|
+
if (params.mode === "form" && validatedResult.action === "accept" && validatedResult.content && requestedSchema) {
|
|
23905
|
+
if (this._capabilities.elicitation?.form?.applyDefaults) try {
|
|
23240
23906
|
applyElicitationDefaults(requestedSchema, validatedResult.content);
|
|
23241
|
-
} catch
|
|
23907
|
+
} catch {}
|
|
23242
23908
|
}
|
|
23243
23909
|
return validatedResult;
|
|
23244
23910
|
};
|
|
@@ -23261,7 +23927,7 @@ var Client = class extends Protocol {
|
|
|
23261
23927
|
}
|
|
23262
23928
|
return taskValidationResult.data;
|
|
23263
23929
|
}
|
|
23264
|
-
const validationResult = safeParse(CreateMessageResultSchema, result);
|
|
23930
|
+
const validationResult = safeParse(params.tools || params.toolChoice ? CreateMessageResultWithToolsSchema : CreateMessageResultSchema, result);
|
|
23265
23931
|
if (!validationResult.success) {
|
|
23266
23932
|
const errorMessage = validationResult.error instanceof Error ? validationResult.error.message : String(validationResult.error);
|
|
23267
23933
|
throw new McpError(ErrorCode.InvalidParams, `Invalid sampling result: ${errorMessage}`);
|
|
@@ -23273,8 +23939,7 @@ var Client = class extends Protocol {
|
|
|
23273
23939
|
return super.setRequestHandler(requestSchema, handler);
|
|
23274
23940
|
}
|
|
23275
23941
|
assertCapability(capability, method) {
|
|
23276
|
-
|
|
23277
|
-
if (!((_a = this._serverCapabilities) === null || _a === void 0 ? void 0 : _a[capability])) throw new Error(`Server does not support ${capability} (required for ${method})`);
|
|
23942
|
+
if (!this._serverCapabilities?.[capability]) throw new Error(`Server does not support ${capability} (required for ${method})`);
|
|
23278
23943
|
}
|
|
23279
23944
|
async connect(transport, options) {
|
|
23280
23945
|
await super.connect(transport);
|
|
@@ -23295,6 +23960,10 @@ var Client = class extends Protocol {
|
|
|
23295
23960
|
if (transport.setProtocolVersion) transport.setProtocolVersion(result.protocolVersion);
|
|
23296
23961
|
this._instructions = result.instructions;
|
|
23297
23962
|
await this.notification({ method: "notifications/initialized" });
|
|
23963
|
+
if (this._pendingListChangedConfig) {
|
|
23964
|
+
this._setupListChangedHandlers(this._pendingListChangedConfig);
|
|
23965
|
+
this._pendingListChangedConfig = void 0;
|
|
23966
|
+
}
|
|
23298
23967
|
} catch (error$1) {
|
|
23299
23968
|
this.close();
|
|
23300
23969
|
throw error$1;
|
|
@@ -23319,39 +23988,37 @@ var Client = class extends Protocol {
|
|
|
23319
23988
|
return this._instructions;
|
|
23320
23989
|
}
|
|
23321
23990
|
assertCapabilityForMethod(method) {
|
|
23322
|
-
var _a, _b, _c, _d, _e;
|
|
23323
23991
|
switch (method) {
|
|
23324
23992
|
case "logging/setLevel":
|
|
23325
|
-
if (!
|
|
23993
|
+
if (!this._serverCapabilities?.logging) throw new Error(`Server does not support logging (required for ${method})`);
|
|
23326
23994
|
break;
|
|
23327
23995
|
case "prompts/get":
|
|
23328
23996
|
case "prompts/list":
|
|
23329
|
-
if (!
|
|
23997
|
+
if (!this._serverCapabilities?.prompts) throw new Error(`Server does not support prompts (required for ${method})`);
|
|
23330
23998
|
break;
|
|
23331
23999
|
case "resources/list":
|
|
23332
24000
|
case "resources/templates/list":
|
|
23333
24001
|
case "resources/read":
|
|
23334
24002
|
case "resources/subscribe":
|
|
23335
24003
|
case "resources/unsubscribe":
|
|
23336
|
-
if (!
|
|
24004
|
+
if (!this._serverCapabilities?.resources) throw new Error(`Server does not support resources (required for ${method})`);
|
|
23337
24005
|
if (method === "resources/subscribe" && !this._serverCapabilities.resources.subscribe) throw new Error(`Server does not support resource subscriptions (required for ${method})`);
|
|
23338
24006
|
break;
|
|
23339
24007
|
case "tools/call":
|
|
23340
24008
|
case "tools/list":
|
|
23341
|
-
if (!
|
|
24009
|
+
if (!this._serverCapabilities?.tools) throw new Error(`Server does not support tools (required for ${method})`);
|
|
23342
24010
|
break;
|
|
23343
24011
|
case "completion/complete":
|
|
23344
|
-
if (!
|
|
24012
|
+
if (!this._serverCapabilities?.completions) throw new Error(`Server does not support completions (required for ${method})`);
|
|
23345
24013
|
break;
|
|
23346
24014
|
case "initialize": break;
|
|
23347
24015
|
case "ping": break;
|
|
23348
24016
|
}
|
|
23349
24017
|
}
|
|
23350
24018
|
assertNotificationCapability(method) {
|
|
23351
|
-
var _a;
|
|
23352
24019
|
switch (method) {
|
|
23353
24020
|
case "notifications/roots/list_changed":
|
|
23354
|
-
if (!
|
|
24021
|
+
if (!this._capabilities.roots?.listChanged) throw new Error(`Client does not support roots list changed notifications (required for ${method})`);
|
|
23355
24022
|
break;
|
|
23356
24023
|
case "notifications/initialized": break;
|
|
23357
24024
|
case "notifications/cancelled": break;
|
|
@@ -23380,13 +24047,11 @@ var Client = class extends Protocol {
|
|
|
23380
24047
|
}
|
|
23381
24048
|
}
|
|
23382
24049
|
assertTaskCapability(method) {
|
|
23383
|
-
|
|
23384
|
-
assertToolsCallTaskCapability((_b = (_a = this._serverCapabilities) === null || _a === void 0 ? void 0 : _a.tasks) === null || _b === void 0 ? void 0 : _b.requests, method, "Server");
|
|
24050
|
+
assertToolsCallTaskCapability(this._serverCapabilities?.tasks?.requests, method, "Server");
|
|
23385
24051
|
}
|
|
23386
24052
|
assertTaskHandlerCapability(method) {
|
|
23387
|
-
var _a;
|
|
23388
24053
|
if (!this._capabilities) return;
|
|
23389
|
-
assertClientRequestTaskCapability(
|
|
24054
|
+
assertClientRequestTaskCapability(this._capabilities.tasks?.requests, method, "Client");
|
|
23390
24055
|
}
|
|
23391
24056
|
async ping(options) {
|
|
23392
24057
|
return this.request({ method: "ping" }, EmptyResultSchema, options);
|
|
@@ -23470,8 +24135,7 @@ var Client = class extends Protocol {
|
|
|
23470
24135
|
return result;
|
|
23471
24136
|
}
|
|
23472
24137
|
isToolTask(toolName) {
|
|
23473
|
-
|
|
23474
|
-
if (!((_d = (_c = (_b = (_a = this._serverCapabilities) === null || _a === void 0 ? void 0 : _a.tasks) === null || _b === void 0 ? void 0 : _b.requests) === null || _c === void 0 ? void 0 : _c.tools) === null || _d === void 0 ? void 0 : _d.call)) return false;
|
|
24138
|
+
if (!this._serverCapabilities?.tasks?.requests?.tools?.call) return false;
|
|
23475
24139
|
return this._cachedKnownTaskTools.has(toolName);
|
|
23476
24140
|
}
|
|
23477
24141
|
/**
|
|
@@ -23486,7 +24150,6 @@ var Client = class extends Protocol {
|
|
|
23486
24150
|
* Called after listTools() to pre-compile validators for better performance.
|
|
23487
24151
|
*/
|
|
23488
24152
|
cacheToolMetadata(tools) {
|
|
23489
|
-
var _a;
|
|
23490
24153
|
this._cachedToolOutputValidators.clear();
|
|
23491
24154
|
this._cachedKnownTaskTools.clear();
|
|
23492
24155
|
this._cachedRequiredTaskTools.clear();
|
|
@@ -23495,7 +24158,7 @@ var Client = class extends Protocol {
|
|
|
23495
24158
|
const toolValidator = this._jsonSchemaValidator.getValidator(tool.outputSchema);
|
|
23496
24159
|
this._cachedToolOutputValidators.set(tool.name, toolValidator);
|
|
23497
24160
|
}
|
|
23498
|
-
const taskSupport =
|
|
24161
|
+
const taskSupport = tool.execution?.taskSupport;
|
|
23499
24162
|
if (taskSupport === "required" || taskSupport === "optional") this._cachedKnownTaskTools.add(tool.name);
|
|
23500
24163
|
if (taskSupport === "required") this._cachedRequiredTaskTools.add(tool.name);
|
|
23501
24164
|
}
|
|
@@ -23514,13 +24177,44 @@ var Client = class extends Protocol {
|
|
|
23514
24177
|
this.cacheToolMetadata(result.tools);
|
|
23515
24178
|
return result;
|
|
23516
24179
|
}
|
|
24180
|
+
/**
|
|
24181
|
+
* Set up a single list changed handler.
|
|
24182
|
+
* @internal
|
|
24183
|
+
*/
|
|
24184
|
+
_setupListChangedHandler(listType, notificationSchema, options, fetcher) {
|
|
24185
|
+
const parseResult = ListChangedOptionsBaseSchema.safeParse(options);
|
|
24186
|
+
if (!parseResult.success) throw new Error(`Invalid ${listType} listChanged options: ${parseResult.error.message}`);
|
|
24187
|
+
if (typeof options.onChanged !== "function") throw new Error(`Invalid ${listType} listChanged options: onChanged must be a function`);
|
|
24188
|
+
const { autoRefresh, debounceMs } = parseResult.data;
|
|
24189
|
+
const { onChanged } = options;
|
|
24190
|
+
const refresh = async () => {
|
|
24191
|
+
if (!autoRefresh) {
|
|
24192
|
+
onChanged(null, null);
|
|
24193
|
+
return;
|
|
24194
|
+
}
|
|
24195
|
+
try {
|
|
24196
|
+
onChanged(null, await fetcher());
|
|
24197
|
+
} catch (e) {
|
|
24198
|
+
onChanged(e instanceof Error ? e : new Error(String(e)), null);
|
|
24199
|
+
}
|
|
24200
|
+
};
|
|
24201
|
+
const handler = () => {
|
|
24202
|
+
if (debounceMs) {
|
|
24203
|
+
const existingTimer = this._listChangedDebounceTimers.get(listType);
|
|
24204
|
+
if (existingTimer) clearTimeout(existingTimer);
|
|
24205
|
+
const timer = setTimeout(refresh, debounceMs);
|
|
24206
|
+
this._listChangedDebounceTimers.set(listType, timer);
|
|
24207
|
+
} else refresh();
|
|
24208
|
+
};
|
|
24209
|
+
this.setNotificationHandler(notificationSchema, handler);
|
|
24210
|
+
}
|
|
23517
24211
|
async sendRootsListChanged() {
|
|
23518
24212
|
return this.notification({ method: "notifications/roots/list_changed" });
|
|
23519
24213
|
}
|
|
23520
24214
|
};
|
|
23521
24215
|
|
|
23522
24216
|
//#endregion
|
|
23523
|
-
//#region node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
24217
|
+
//#region node_modules/.pnpm/@modelcontextprotocol+sdk@1.27.1_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/server.js
|
|
23524
24218
|
/**
|
|
23525
24219
|
* Experimental server task features for MCP SDK.
|
|
23526
24220
|
* WARNING: These APIs are experimental and may change without notice.
|
|
@@ -23561,6 +24255,136 @@ var ExperimentalServerTasks = class {
|
|
|
23561
24255
|
return this._server.requestStream(request, resultSchema, options);
|
|
23562
24256
|
}
|
|
23563
24257
|
/**
|
|
24258
|
+
* Sends a sampling request and returns an AsyncGenerator that yields response messages.
|
|
24259
|
+
* The generator is guaranteed to end with either a 'result' or 'error' message.
|
|
24260
|
+
*
|
|
24261
|
+
* For task-augmented requests, yields 'taskCreated' and 'taskStatus' messages
|
|
24262
|
+
* before the final result.
|
|
24263
|
+
*
|
|
24264
|
+
* @example
|
|
24265
|
+
* ```typescript
|
|
24266
|
+
* const stream = server.experimental.tasks.createMessageStream({
|
|
24267
|
+
* messages: [{ role: 'user', content: { type: 'text', text: 'Hello' } }],
|
|
24268
|
+
* maxTokens: 100
|
|
24269
|
+
* }, {
|
|
24270
|
+
* onprogress: (progress) => {
|
|
24271
|
+
* // Handle streaming tokens via progress notifications
|
|
24272
|
+
* console.log('Progress:', progress.message);
|
|
24273
|
+
* }
|
|
24274
|
+
* });
|
|
24275
|
+
*
|
|
24276
|
+
* for await (const message of stream) {
|
|
24277
|
+
* switch (message.type) {
|
|
24278
|
+
* case 'taskCreated':
|
|
24279
|
+
* console.log('Task created:', message.task.taskId);
|
|
24280
|
+
* break;
|
|
24281
|
+
* case 'taskStatus':
|
|
24282
|
+
* console.log('Task status:', message.task.status);
|
|
24283
|
+
* break;
|
|
24284
|
+
* case 'result':
|
|
24285
|
+
* console.log('Final result:', message.result);
|
|
24286
|
+
* break;
|
|
24287
|
+
* case 'error':
|
|
24288
|
+
* console.error('Error:', message.error);
|
|
24289
|
+
* break;
|
|
24290
|
+
* }
|
|
24291
|
+
* }
|
|
24292
|
+
* ```
|
|
24293
|
+
*
|
|
24294
|
+
* @param params - The sampling request parameters
|
|
24295
|
+
* @param options - Optional request options (timeout, signal, task creation params, onprogress, etc.)
|
|
24296
|
+
* @returns AsyncGenerator that yields ResponseMessage objects
|
|
24297
|
+
*
|
|
24298
|
+
* @experimental
|
|
24299
|
+
*/
|
|
24300
|
+
createMessageStream(params, options) {
|
|
24301
|
+
const clientCapabilities = this._server.getClientCapabilities();
|
|
24302
|
+
if ((params.tools || params.toolChoice) && !clientCapabilities?.sampling?.tools) throw new Error("Client does not support sampling tools capability.");
|
|
24303
|
+
if (params.messages.length > 0) {
|
|
24304
|
+
const lastMessage = params.messages[params.messages.length - 1];
|
|
24305
|
+
const lastContent = Array.isArray(lastMessage.content) ? lastMessage.content : [lastMessage.content];
|
|
24306
|
+
const hasToolResults = lastContent.some((c) => c.type === "tool_result");
|
|
24307
|
+
const previousMessage = params.messages.length > 1 ? params.messages[params.messages.length - 2] : void 0;
|
|
24308
|
+
const previousContent = previousMessage ? Array.isArray(previousMessage.content) ? previousMessage.content : [previousMessage.content] : [];
|
|
24309
|
+
const hasPreviousToolUse = previousContent.some((c) => c.type === "tool_use");
|
|
24310
|
+
if (hasToolResults) {
|
|
24311
|
+
if (lastContent.some((c) => c.type !== "tool_result")) throw new Error("The last message must contain only tool_result content if any is present");
|
|
24312
|
+
if (!hasPreviousToolUse) throw new Error("tool_result blocks are not matching any tool_use from the previous message");
|
|
24313
|
+
}
|
|
24314
|
+
if (hasPreviousToolUse) {
|
|
24315
|
+
const toolUseIds = new Set(previousContent.filter((c) => c.type === "tool_use").map((c) => c.id));
|
|
24316
|
+
const toolResultIds = new Set(lastContent.filter((c) => c.type === "tool_result").map((c) => c.toolUseId));
|
|
24317
|
+
if (toolUseIds.size !== toolResultIds.size || ![...toolUseIds].every((id) => toolResultIds.has(id))) throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match");
|
|
24318
|
+
}
|
|
24319
|
+
}
|
|
24320
|
+
return this.requestStream({
|
|
24321
|
+
method: "sampling/createMessage",
|
|
24322
|
+
params
|
|
24323
|
+
}, CreateMessageResultSchema, options);
|
|
24324
|
+
}
|
|
24325
|
+
/**
|
|
24326
|
+
* Sends an elicitation request and returns an AsyncGenerator that yields response messages.
|
|
24327
|
+
* The generator is guaranteed to end with either a 'result' or 'error' message.
|
|
24328
|
+
*
|
|
24329
|
+
* For task-augmented requests (especially URL-based elicitation), yields 'taskCreated'
|
|
24330
|
+
* and 'taskStatus' messages before the final result.
|
|
24331
|
+
*
|
|
24332
|
+
* @example
|
|
24333
|
+
* ```typescript
|
|
24334
|
+
* const stream = server.experimental.tasks.elicitInputStream({
|
|
24335
|
+
* mode: 'url',
|
|
24336
|
+
* message: 'Please authenticate',
|
|
24337
|
+
* elicitationId: 'auth-123',
|
|
24338
|
+
* url: 'https://example.com/auth'
|
|
24339
|
+
* }, {
|
|
24340
|
+
* task: { ttl: 300000 } // Task-augmented for long-running auth flow
|
|
24341
|
+
* });
|
|
24342
|
+
*
|
|
24343
|
+
* for await (const message of stream) {
|
|
24344
|
+
* switch (message.type) {
|
|
24345
|
+
* case 'taskCreated':
|
|
24346
|
+
* console.log('Task created:', message.task.taskId);
|
|
24347
|
+
* break;
|
|
24348
|
+
* case 'taskStatus':
|
|
24349
|
+
* console.log('Task status:', message.task.status);
|
|
24350
|
+
* break;
|
|
24351
|
+
* case 'result':
|
|
24352
|
+
* console.log('User action:', message.result.action);
|
|
24353
|
+
* break;
|
|
24354
|
+
* case 'error':
|
|
24355
|
+
* console.error('Error:', message.error);
|
|
24356
|
+
* break;
|
|
24357
|
+
* }
|
|
24358
|
+
* }
|
|
24359
|
+
* ```
|
|
24360
|
+
*
|
|
24361
|
+
* @param params - The elicitation request parameters
|
|
24362
|
+
* @param options - Optional request options (timeout, signal, task creation params, etc.)
|
|
24363
|
+
* @returns AsyncGenerator that yields ResponseMessage objects
|
|
24364
|
+
*
|
|
24365
|
+
* @experimental
|
|
24366
|
+
*/
|
|
24367
|
+
elicitInputStream(params, options) {
|
|
24368
|
+
const clientCapabilities = this._server.getClientCapabilities();
|
|
24369
|
+
const mode = params.mode ?? "form";
|
|
24370
|
+
switch (mode) {
|
|
24371
|
+
case "url":
|
|
24372
|
+
if (!clientCapabilities?.elicitation?.url) throw new Error("Client does not support url elicitation.");
|
|
24373
|
+
break;
|
|
24374
|
+
case "form":
|
|
24375
|
+
if (!clientCapabilities?.elicitation?.form) throw new Error("Client does not support form elicitation.");
|
|
24376
|
+
break;
|
|
24377
|
+
}
|
|
24378
|
+
const normalizedParams = mode === "form" && params.mode === void 0 ? {
|
|
24379
|
+
...params,
|
|
24380
|
+
mode: "form"
|
|
24381
|
+
} : params;
|
|
24382
|
+
return this.requestStream({
|
|
24383
|
+
method: "elicitation/create",
|
|
24384
|
+
params: normalizedParams
|
|
24385
|
+
}, ElicitResultSchema, options);
|
|
24386
|
+
}
|
|
24387
|
+
/**
|
|
23564
24388
|
* Gets the current status of a task.
|
|
23565
24389
|
*
|
|
23566
24390
|
* @param taskId - The task identifier
|
|
@@ -23611,7 +24435,7 @@ var ExperimentalServerTasks = class {
|
|
|
23611
24435
|
};
|
|
23612
24436
|
|
|
23613
24437
|
//#endregion
|
|
23614
|
-
//#region node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
24438
|
+
//#region node_modules/.pnpm/@modelcontextprotocol+sdk@1.27.1_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.js
|
|
23615
24439
|
/**
|
|
23616
24440
|
* An MCP server on top of a pluggable transport.
|
|
23617
24441
|
*
|
|
@@ -23643,7 +24467,6 @@ var Server = class extends Protocol {
|
|
|
23643
24467
|
* Initializes this server with the given name and version information.
|
|
23644
24468
|
*/
|
|
23645
24469
|
constructor(_serverInfo, options) {
|
|
23646
|
-
var _a, _b;
|
|
23647
24470
|
super(options);
|
|
23648
24471
|
this._serverInfo = _serverInfo;
|
|
23649
24472
|
this._loggingLevels = /* @__PURE__ */ new Map();
|
|
@@ -23652,17 +24475,13 @@ var Server = class extends Protocol {
|
|
|
23652
24475
|
const currentLevel = this._loggingLevels.get(sessionId);
|
|
23653
24476
|
return currentLevel ? this.LOG_LEVEL_SEVERITY.get(level) < this.LOG_LEVEL_SEVERITY.get(currentLevel) : false;
|
|
23654
24477
|
};
|
|
23655
|
-
this._capabilities =
|
|
23656
|
-
this._instructions = options
|
|
23657
|
-
this._jsonSchemaValidator =
|
|
24478
|
+
this._capabilities = options?.capabilities ?? {};
|
|
24479
|
+
this._instructions = options?.instructions;
|
|
24480
|
+
this._jsonSchemaValidator = options?.jsonSchemaValidator ?? new AjvJsonSchemaValidator();
|
|
23658
24481
|
this.setRequestHandler(InitializeRequestSchema, (request) => this._oninitialize(request));
|
|
23659
|
-
this.setNotificationHandler(InitializedNotificationSchema, () =>
|
|
23660
|
-
var _a$1;
|
|
23661
|
-
return (_a$1 = this.oninitialized) === null || _a$1 === void 0 ? void 0 : _a$1.call(this);
|
|
23662
|
-
});
|
|
24482
|
+
this.setNotificationHandler(InitializedNotificationSchema, () => this.oninitialized?.());
|
|
23663
24483
|
if (this._capabilities.logging) this.setRequestHandler(SetLevelRequestSchema, async (request, extra) => {
|
|
23664
|
-
|
|
23665
|
-
const transportSessionId = extra.sessionId || ((_a$1 = extra.requestInfo) === null || _a$1 === void 0 ? void 0 : _a$1.headers["mcp-session-id"]) || void 0;
|
|
24484
|
+
const transportSessionId = extra.sessionId || extra.requestInfo?.headers["mcp-session-id"] || void 0;
|
|
23666
24485
|
const { level } = request.params;
|
|
23667
24486
|
const parseResult = LoggingLevelSchema.safeParse(level);
|
|
23668
24487
|
if (parseResult.success) this._loggingLevels.set(transportSessionId, parseResult.data);
|
|
@@ -23693,19 +24512,15 @@ var Server = class extends Protocol {
|
|
|
23693
24512
|
* Override request handler registration to enforce server-side validation for tools/call.
|
|
23694
24513
|
*/
|
|
23695
24514
|
setRequestHandler(requestSchema, handler) {
|
|
23696
|
-
|
|
23697
|
-
const shape = getObjectShape(requestSchema);
|
|
23698
|
-
const methodSchema = shape === null || shape === void 0 ? void 0 : shape.method;
|
|
24515
|
+
const methodSchema = getObjectShape(requestSchema)?.method;
|
|
23699
24516
|
if (!methodSchema) throw new Error("Schema is missing a method literal");
|
|
23700
24517
|
let methodValue;
|
|
23701
24518
|
if (isZ4Schema(methodSchema)) {
|
|
23702
24519
|
const v4Schema = methodSchema;
|
|
23703
|
-
|
|
23704
|
-
methodValue = (_b = v4Def === null || v4Def === void 0 ? void 0 : v4Def.value) !== null && _b !== void 0 ? _b : v4Schema.value;
|
|
24520
|
+
methodValue = (v4Schema._zod?.def)?.value ?? v4Schema.value;
|
|
23705
24521
|
} else {
|
|
23706
24522
|
const v3Schema = methodSchema;
|
|
23707
|
-
|
|
23708
|
-
methodValue = (_c = legacyDef === null || legacyDef === void 0 ? void 0 : legacyDef.value) !== null && _c !== void 0 ? _c : v3Schema.value;
|
|
24523
|
+
methodValue = v3Schema._def?.value ?? v3Schema.value;
|
|
23709
24524
|
}
|
|
23710
24525
|
if (typeof methodValue !== "string") throw new Error("Schema method literal must be a string");
|
|
23711
24526
|
if (methodValue === "tools/call") {
|
|
@@ -23737,22 +24552,20 @@ var Server = class extends Protocol {
|
|
|
23737
24552
|
return super.setRequestHandler(requestSchema, handler);
|
|
23738
24553
|
}
|
|
23739
24554
|
assertCapabilityForMethod(method) {
|
|
23740
|
-
var _a, _b, _c;
|
|
23741
24555
|
switch (method) {
|
|
23742
24556
|
case "sampling/createMessage":
|
|
23743
|
-
if (!
|
|
24557
|
+
if (!this._clientCapabilities?.sampling) throw new Error(`Client does not support sampling (required for ${method})`);
|
|
23744
24558
|
break;
|
|
23745
24559
|
case "elicitation/create":
|
|
23746
|
-
if (!
|
|
24560
|
+
if (!this._clientCapabilities?.elicitation) throw new Error(`Client does not support elicitation (required for ${method})`);
|
|
23747
24561
|
break;
|
|
23748
24562
|
case "roots/list":
|
|
23749
|
-
if (!
|
|
24563
|
+
if (!this._clientCapabilities?.roots) throw new Error(`Client does not support listing roots (required for ${method})`);
|
|
23750
24564
|
break;
|
|
23751
24565
|
case "ping": break;
|
|
23752
24566
|
}
|
|
23753
24567
|
}
|
|
23754
24568
|
assertNotificationCapability(method) {
|
|
23755
|
-
var _a, _b;
|
|
23756
24569
|
switch (method) {
|
|
23757
24570
|
case "notifications/message":
|
|
23758
24571
|
if (!this._capabilities.logging) throw new Error(`Server does not support logging (required for ${method})`);
|
|
@@ -23768,7 +24581,7 @@ var Server = class extends Protocol {
|
|
|
23768
24581
|
if (!this._capabilities.prompts) throw new Error(`Server does not support notifying of prompt list changes (required for ${method})`);
|
|
23769
24582
|
break;
|
|
23770
24583
|
case "notifications/elicitation/complete":
|
|
23771
|
-
if (!
|
|
24584
|
+
if (!this._clientCapabilities?.elicitation?.url) throw new Error(`Client does not support URL elicitation (required for ${method})`);
|
|
23772
24585
|
break;
|
|
23773
24586
|
case "notifications/cancelled": break;
|
|
23774
24587
|
case "notifications/progress": break;
|
|
@@ -23807,13 +24620,11 @@ var Server = class extends Protocol {
|
|
|
23807
24620
|
}
|
|
23808
24621
|
}
|
|
23809
24622
|
assertTaskCapability(method) {
|
|
23810
|
-
|
|
23811
|
-
assertClientRequestTaskCapability((_b = (_a = this._clientCapabilities) === null || _a === void 0 ? void 0 : _a.tasks) === null || _b === void 0 ? void 0 : _b.requests, method, "Client");
|
|
24623
|
+
assertClientRequestTaskCapability(this._clientCapabilities?.tasks?.requests, method, "Client");
|
|
23812
24624
|
}
|
|
23813
24625
|
assertTaskHandlerCapability(method) {
|
|
23814
|
-
var _a;
|
|
23815
24626
|
if (!this._capabilities) return;
|
|
23816
|
-
assertToolsCallTaskCapability(
|
|
24627
|
+
assertToolsCallTaskCapability(this._capabilities.tasks?.requests, method, "Server");
|
|
23817
24628
|
}
|
|
23818
24629
|
async _oninitialize(request) {
|
|
23819
24630
|
const requestedVersion = request.params.protocolVersion;
|
|
@@ -23845,9 +24656,8 @@ var Server = class extends Protocol {
|
|
|
23845
24656
|
return this.request({ method: "ping" }, EmptyResultSchema);
|
|
23846
24657
|
}
|
|
23847
24658
|
async createMessage(params, options) {
|
|
23848
|
-
var _a, _b;
|
|
23849
24659
|
if (params.tools || params.toolChoice) {
|
|
23850
|
-
if (!
|
|
24660
|
+
if (!this._clientCapabilities?.sampling?.tools) throw new Error("Client does not support sampling tools capability.");
|
|
23851
24661
|
}
|
|
23852
24662
|
if (params.messages.length > 0) {
|
|
23853
24663
|
const lastMessage = params.messages[params.messages.length - 1];
|
|
@@ -23883,10 +24693,9 @@ var Server = class extends Protocol {
|
|
|
23883
24693
|
* @returns The result of the elicitation request.
|
|
23884
24694
|
*/
|
|
23885
24695
|
async elicitInput(params, options) {
|
|
23886
|
-
|
|
23887
|
-
switch ((_a = params.mode) !== null && _a !== void 0 ? _a : "form") {
|
|
24696
|
+
switch (params.mode ?? "form") {
|
|
23888
24697
|
case "url": {
|
|
23889
|
-
if (!
|
|
24698
|
+
if (!this._clientCapabilities?.elicitation?.url) throw new Error("Client does not support url elicitation.");
|
|
23890
24699
|
const urlParams = params;
|
|
23891
24700
|
return this.request({
|
|
23892
24701
|
method: "elicitation/create",
|
|
@@ -23894,7 +24703,7 @@ var Server = class extends Protocol {
|
|
|
23894
24703
|
}, ElicitResultSchema, options);
|
|
23895
24704
|
}
|
|
23896
24705
|
case "form": {
|
|
23897
|
-
if (!
|
|
24706
|
+
if (!this._clientCapabilities?.elicitation?.form) throw new Error("Client does not support form elicitation.");
|
|
23898
24707
|
const formParams = params.mode === "form" ? params : {
|
|
23899
24708
|
...params,
|
|
23900
24709
|
mode: "form"
|
|
@@ -23923,8 +24732,7 @@ var Server = class extends Protocol {
|
|
|
23923
24732
|
* @returns A function that emits the completion notification when awaited.
|
|
23924
24733
|
*/
|
|
23925
24734
|
createElicitationCompletionNotifier(elicitationId, options) {
|
|
23926
|
-
|
|
23927
|
-
if (!((_b = (_a = this._clientCapabilities) === null || _a === void 0 ? void 0 : _a.elicitation) === null || _b === void 0 ? void 0 : _b.url)) throw new Error("Client does not support URL elicitation (required for notifications/elicitation/complete)");
|
|
24735
|
+
if (!this._clientCapabilities?.elicitation?.url) throw new Error("Client does not support URL elicitation (required for notifications/elicitation/complete)");
|
|
23928
24736
|
return () => this.notification({
|
|
23929
24737
|
method: "notifications/elicitation/complete",
|
|
23930
24738
|
params: { elicitationId }
|
|
@@ -23969,7 +24777,7 @@ var Server = class extends Protocol {
|
|
|
23969
24777
|
};
|
|
23970
24778
|
|
|
23971
24779
|
//#endregion
|
|
23972
|
-
//#region node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
24780
|
+
//#region node_modules/.pnpm/@modelcontextprotocol+sdk@1.27.1_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.js
|
|
23973
24781
|
/**
|
|
23974
24782
|
* Buffers a continuous stdio stream into discrete JSON-RPC messages.
|
|
23975
24783
|
*/
|
|
@@ -23997,5 +24805,5 @@ function serializeMessage(message) {
|
|
|
23997
24805
|
}
|
|
23998
24806
|
|
|
23999
24807
|
//#endregion
|
|
24000
|
-
export { NEVER as C, __toESM as D, __commonJSMin as E, _coercedNumber as S, AuthenticationMiddleware as T, looseObject as _, startHTTPServer as a, string as b, LATEST_PROTOCOL_VERSION as c,
|
|
24001
|
-
//# sourceMappingURL=stdio-
|
|
24808
|
+
export { NEVER as C, __toESM as D, __commonJSMin as E, _coercedNumber as S, AuthenticationMiddleware as T, looseObject as _, startHTTPServer as a, string as b, LATEST_PROTOCOL_VERSION as c, isJSONRPCResultResponse as d, ZodNumber as f, literal as g, boolean as h, Client as i, isInitializedNotification as l, array as m, serializeMessage as n, proxyServer as o, any as p, Server as r, JSONRPCMessageSchema as s, ReadBuffer as t, isJSONRPCRequest as u, number as v, InMemoryEventStore as w, url as x, object as y };
|
|
24809
|
+
//# sourceMappingURL=stdio-BmURZCbz.mjs.map
|