mcp-proxy 6.4.3 → 6.4.5
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 +1 -1
- 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-_93Y9W6l.mjs} +1562 -751
- package/dist/stdio-_93Y9W6l.mjs.map +1 -0
- package/jsr.json +1 -1
- package/package.json +2 -2
- package/src/bin/mcp-proxy.ts +2 -3
- package/src/proxyServer.test.ts +2 -4
- package/src/startHTTPServer.test.ts +72 -51
- package/src/startHTTPServer.ts +11 -6
- 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) => {
|
|
@@ -15592,6 +16253,10 @@ const startHTTPServer = async ({ apiKey, authenticate, cors, createServer, enabl
|
|
|
15592
16253
|
res.writeHead(200).end("pong");
|
|
15593
16254
|
return;
|
|
15594
16255
|
}
|
|
16256
|
+
if (onUnhandledRequest) {
|
|
16257
|
+
await onUnhandledRequest(req, res);
|
|
16258
|
+
if (res.writableEnded) return;
|
|
16259
|
+
}
|
|
15595
16260
|
if (!authMiddleware.validateRequest(req)) {
|
|
15596
16261
|
const authResponse = authMiddleware.getUnauthorizedResponse();
|
|
15597
16262
|
res.writeHead(401, authResponse.headers);
|
|
@@ -15622,8 +16287,7 @@ const startHTTPServer = async ({ apiKey, authenticate, cors, createServer, enabl
|
|
|
15622
16287
|
res,
|
|
15623
16288
|
stateless
|
|
15624
16289
|
})) return;
|
|
15625
|
-
|
|
15626
|
-
else res.writeHead(404).end();
|
|
16290
|
+
res.writeHead(404).end();
|
|
15627
16291
|
};
|
|
15628
16292
|
let httpServer;
|
|
15629
16293
|
if (sslCa || sslCert || sslKey) {
|
|
@@ -15666,7 +16330,7 @@ const startHTTPServer = async ({ apiKey, authenticate, cors, createServer, enabl
|
|
|
15666
16330
|
};
|
|
15667
16331
|
|
|
15668
16332
|
//#endregion
|
|
15669
|
-
//#region node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
16333
|
+
//#region node_modules/.pnpm/@modelcontextprotocol+sdk@1.27.1_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js
|
|
15670
16334
|
function isZ4Schema(s) {
|
|
15671
16335
|
return !!s._zod;
|
|
15672
16336
|
}
|
|
@@ -15675,15 +16339,14 @@ function safeParse(schema, data) {
|
|
|
15675
16339
|
return schema.safeParse(data);
|
|
15676
16340
|
}
|
|
15677
16341
|
function getObjectShape(schema) {
|
|
15678
|
-
var _a, _b;
|
|
15679
16342
|
if (!schema) return void 0;
|
|
15680
16343
|
let rawShape;
|
|
15681
|
-
if (isZ4Schema(schema)) rawShape =
|
|
16344
|
+
if (isZ4Schema(schema)) rawShape = schema._zod?.def?.shape;
|
|
15682
16345
|
else rawShape = schema.shape;
|
|
15683
16346
|
if (!rawShape) return void 0;
|
|
15684
16347
|
if (typeof rawShape === "function") try {
|
|
15685
16348
|
return rawShape();
|
|
15686
|
-
} catch
|
|
16349
|
+
} catch {
|
|
15687
16350
|
return;
|
|
15688
16351
|
}
|
|
15689
16352
|
return rawShape;
|
|
@@ -15694,9 +16357,8 @@ function getObjectShape(schema) {
|
|
|
15694
16357
|
* Returns undefined if the schema is not a literal or the value cannot be determined.
|
|
15695
16358
|
*/
|
|
15696
16359
|
function getLiteralValue(schema) {
|
|
15697
|
-
var _a;
|
|
15698
16360
|
if (isZ4Schema(schema)) {
|
|
15699
|
-
const def$31 =
|
|
16361
|
+
const def$31 = schema._zod?.def;
|
|
15700
16362
|
if (def$31) {
|
|
15701
16363
|
if (def$31.value !== void 0) return def$31.value;
|
|
15702
16364
|
if (Array.isArray(def$31.values) && def$31.values.length > 0) return def$31.values[0];
|
|
@@ -15712,7 +16374,7 @@ function getLiteralValue(schema) {
|
|
|
15712
16374
|
}
|
|
15713
16375
|
|
|
15714
16376
|
//#endregion
|
|
15715
|
-
//#region node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
16377
|
+
//#region node_modules/.pnpm/@modelcontextprotocol+sdk@1.27.1_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/interfaces.js
|
|
15716
16378
|
/**
|
|
15717
16379
|
* Experimental task interfaces for MCP SDK.
|
|
15718
16380
|
* WARNING: These APIs are experimental and may change without notice.
|
|
@@ -15730,10 +16392,9 @@ function isTerminal(status$1) {
|
|
|
15730
16392
|
}
|
|
15731
16393
|
|
|
15732
16394
|
//#endregion
|
|
15733
|
-
//#region node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
16395
|
+
//#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
16396
|
function getMethodLiteral(schema) {
|
|
15735
|
-
const
|
|
15736
|
-
const methodSchema = shape === null || shape === void 0 ? void 0 : shape.method;
|
|
16397
|
+
const methodSchema = getObjectShape(schema)?.method;
|
|
15737
16398
|
if (!methodSchema) throw new Error("Schema is missing a method literal");
|
|
15738
16399
|
const value = getLiteralValue(methodSchema);
|
|
15739
16400
|
if (typeof value !== "string") throw new Error("Schema method literal must be a string");
|
|
@@ -15746,7 +16407,7 @@ function parseWithCompat(schema, data) {
|
|
|
15746
16407
|
}
|
|
15747
16408
|
|
|
15748
16409
|
//#endregion
|
|
15749
|
-
//#region node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
16410
|
+
//#region node_modules/.pnpm/@modelcontextprotocol+sdk@1.27.1_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/protocol.js
|
|
15750
16411
|
/**
|
|
15751
16412
|
* The default request timeout, in miliseconds.
|
|
15752
16413
|
*/
|
|
@@ -15775,8 +16436,8 @@ var Protocol = class {
|
|
|
15775
16436
|
this._onprogress(notification);
|
|
15776
16437
|
});
|
|
15777
16438
|
this.setRequestHandler(PingRequestSchema, (_request) => ({}));
|
|
15778
|
-
this._taskStore = _options
|
|
15779
|
-
this._taskMessageQueue = _options
|
|
16439
|
+
this._taskStore = _options?.taskStore;
|
|
16440
|
+
this._taskMessageQueue = _options?.taskMessageQueue;
|
|
15780
16441
|
if (this._taskStore) {
|
|
15781
16442
|
this.setRequestHandler(GetTaskRequestSchema, async (request, extra) => {
|
|
15782
16443
|
const task = await this._taskStore.getTask(request.params.taskId, extra.sessionId);
|
|
@@ -15785,7 +16446,6 @@ var Protocol = class {
|
|
|
15785
16446
|
});
|
|
15786
16447
|
this.setRequestHandler(GetTaskPayloadRequestSchema, async (request, extra) => {
|
|
15787
16448
|
const handleTaskResult = async () => {
|
|
15788
|
-
var _a;
|
|
15789
16449
|
const taskId = request.params.taskId;
|
|
15790
16450
|
if (this._taskMessageQueue) {
|
|
15791
16451
|
let queuedMessage;
|
|
@@ -15807,7 +16467,7 @@ var Protocol = class {
|
|
|
15807
16467
|
}
|
|
15808
16468
|
continue;
|
|
15809
16469
|
}
|
|
15810
|
-
await
|
|
16470
|
+
await this._transport?.send(queuedMessage.message, { relatedRequestId: extra.requestId });
|
|
15811
16471
|
}
|
|
15812
16472
|
}
|
|
15813
16473
|
const task = await this._taskStore.getTask(taskId, extra.sessionId);
|
|
@@ -15832,9 +16492,8 @@ var Protocol = class {
|
|
|
15832
16492
|
return await handleTaskResult();
|
|
15833
16493
|
});
|
|
15834
16494
|
this.setRequestHandler(ListTasksRequestSchema, async (request, extra) => {
|
|
15835
|
-
var _a;
|
|
15836
16495
|
try {
|
|
15837
|
-
const { tasks, nextCursor } = await this._taskStore.listTasks(
|
|
16496
|
+
const { tasks, nextCursor } = await this._taskStore.listTasks(request.params?.cursor, extra.sessionId);
|
|
15838
16497
|
return {
|
|
15839
16498
|
tasks,
|
|
15840
16499
|
nextCursor,
|
|
@@ -15865,8 +16524,8 @@ var Protocol = class {
|
|
|
15865
16524
|
}
|
|
15866
16525
|
}
|
|
15867
16526
|
async _oncancel(notification) {
|
|
15868
|
-
|
|
15869
|
-
|
|
16527
|
+
if (!notification.params.requestId) return;
|
|
16528
|
+
this._requestHandlerAbortControllers.get(notification.params.requestId)?.abort(notification.params.reason);
|
|
15870
16529
|
}
|
|
15871
16530
|
_setupTimeout(messageId, timeout, maxTotalTimeout, onTimeout, resetTimeoutOnProgress = false) {
|
|
15872
16531
|
this._timeoutInfo.set(messageId, {
|
|
@@ -15906,22 +16565,22 @@ var Protocol = class {
|
|
|
15906
16565
|
* 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
16566
|
*/
|
|
15908
16567
|
async connect(transport) {
|
|
15909
|
-
|
|
16568
|
+
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
16569
|
this._transport = transport;
|
|
15911
|
-
const _onclose =
|
|
16570
|
+
const _onclose = this.transport?.onclose;
|
|
15912
16571
|
this._transport.onclose = () => {
|
|
15913
|
-
_onclose
|
|
16572
|
+
_onclose?.();
|
|
15914
16573
|
this._onclose();
|
|
15915
16574
|
};
|
|
15916
|
-
const _onerror =
|
|
16575
|
+
const _onerror = this.transport?.onerror;
|
|
15917
16576
|
this._transport.onerror = (error$1) => {
|
|
15918
|
-
_onerror
|
|
16577
|
+
_onerror?.(error$1);
|
|
15919
16578
|
this._onerror(error$1);
|
|
15920
16579
|
};
|
|
15921
|
-
const _onmessage =
|
|
16580
|
+
const _onmessage = this._transport?.onmessage;
|
|
15922
16581
|
this._transport.onmessage = (message, extra) => {
|
|
15923
|
-
_onmessage
|
|
15924
|
-
if (
|
|
16582
|
+
_onmessage?.(message, extra);
|
|
16583
|
+
if (isJSONRPCResultResponse(message) || isJSONRPCErrorResponse(message)) this._onresponse(message);
|
|
15925
16584
|
else if (isJSONRPCRequest(message)) this._onrequest(message, extra);
|
|
15926
16585
|
else if (isJSONRPCNotification(message)) this._onnotification(message);
|
|
15927
16586
|
else this._onerror(/* @__PURE__ */ new Error(`Unknown message type: ${JSON.stringify(message)}`));
|
|
@@ -15929,32 +16588,30 @@ var Protocol = class {
|
|
|
15929
16588
|
await this._transport.start();
|
|
15930
16589
|
}
|
|
15931
16590
|
_onclose() {
|
|
15932
|
-
var _a;
|
|
15933
16591
|
const responseHandlers = this._responseHandlers;
|
|
15934
16592
|
this._responseHandlers = /* @__PURE__ */ new Map();
|
|
15935
16593
|
this._progressHandlers.clear();
|
|
15936
16594
|
this._taskProgressTokens.clear();
|
|
15937
16595
|
this._pendingDebouncedNotifications.clear();
|
|
16596
|
+
for (const controller of this._requestHandlerAbortControllers.values()) controller.abort();
|
|
16597
|
+
this._requestHandlerAbortControllers.clear();
|
|
15938
16598
|
const error$1 = McpError.fromError(ErrorCode.ConnectionClosed, "Connection closed");
|
|
15939
16599
|
this._transport = void 0;
|
|
15940
|
-
|
|
16600
|
+
this.onclose?.();
|
|
15941
16601
|
for (const handler of responseHandlers.values()) handler(error$1);
|
|
15942
16602
|
}
|
|
15943
16603
|
_onerror(error$1) {
|
|
15944
|
-
|
|
15945
|
-
(_a = this.onerror) === null || _a === void 0 || _a.call(this, error$1);
|
|
16604
|
+
this.onerror?.(error$1);
|
|
15946
16605
|
}
|
|
15947
16606
|
_onnotification(notification) {
|
|
15948
|
-
|
|
15949
|
-
const handler = (_a = this._notificationHandlers.get(notification.method)) !== null && _a !== void 0 ? _a : this.fallbackNotificationHandler;
|
|
16607
|
+
const handler = this._notificationHandlers.get(notification.method) ?? this.fallbackNotificationHandler;
|
|
15950
16608
|
if (handler === void 0) return;
|
|
15951
16609
|
Promise.resolve().then(() => handler(notification)).catch((error$1) => this._onerror(/* @__PURE__ */ new Error(`Uncaught error in notification handler: ${error$1}`)));
|
|
15952
16610
|
}
|
|
15953
16611
|
_onrequest(request, extra) {
|
|
15954
|
-
|
|
15955
|
-
const handler = (_a = this._requestHandlers.get(request.method)) !== null && _a !== void 0 ? _a : this.fallbackRequestHandler;
|
|
16612
|
+
const handler = this._requestHandlers.get(request.method) ?? this.fallbackRequestHandler;
|
|
15956
16613
|
const capturedTransport = this._transport;
|
|
15957
|
-
const relatedTaskId =
|
|
16614
|
+
const relatedTaskId = request.params?._meta?.[RELATED_TASK_META_KEY]?.taskId;
|
|
15958
16615
|
if (handler === void 0) {
|
|
15959
16616
|
const errorResponse = {
|
|
15960
16617
|
jsonrpc: "2.0",
|
|
@@ -15968,42 +16625,43 @@ var Protocol = class {
|
|
|
15968
16625
|
type: "error",
|
|
15969
16626
|
message: errorResponse,
|
|
15970
16627
|
timestamp: Date.now()
|
|
15971
|
-
}, capturedTransport
|
|
15972
|
-
else capturedTransport
|
|
16628
|
+
}, capturedTransport?.sessionId).catch((error$1) => this._onerror(/* @__PURE__ */ new Error(`Failed to enqueue error response: ${error$1}`)));
|
|
16629
|
+
else capturedTransport?.send(errorResponse).catch((error$1) => this._onerror(/* @__PURE__ */ new Error(`Failed to send an error response: ${error$1}`)));
|
|
15973
16630
|
return;
|
|
15974
16631
|
}
|
|
15975
16632
|
const abortController = new AbortController();
|
|
15976
16633
|
this._requestHandlerAbortControllers.set(request.id, abortController);
|
|
15977
|
-
const taskCreationParams = (
|
|
15978
|
-
const taskStore = this._taskStore ? this.requestTaskStore(request, capturedTransport
|
|
16634
|
+
const taskCreationParams = isTaskAugmentedRequestParams(request.params) ? request.params.task : void 0;
|
|
16635
|
+
const taskStore = this._taskStore ? this.requestTaskStore(request, capturedTransport?.sessionId) : void 0;
|
|
15979
16636
|
const fullExtra = {
|
|
15980
16637
|
signal: abortController.signal,
|
|
15981
|
-
sessionId: capturedTransport
|
|
15982
|
-
_meta:
|
|
16638
|
+
sessionId: capturedTransport?.sessionId,
|
|
16639
|
+
_meta: request.params?._meta,
|
|
15983
16640
|
sendNotification: async (notification) => {
|
|
16641
|
+
if (abortController.signal.aborted) return;
|
|
15984
16642
|
const notificationOptions = { relatedRequestId: request.id };
|
|
15985
16643
|
if (relatedTaskId) notificationOptions.relatedTask = { taskId: relatedTaskId };
|
|
15986
16644
|
await this.notification(notification, notificationOptions);
|
|
15987
16645
|
},
|
|
15988
16646
|
sendRequest: async (r, resultSchema, options) => {
|
|
15989
|
-
|
|
16647
|
+
if (abortController.signal.aborted) throw new McpError(ErrorCode.ConnectionClosed, "Request was cancelled");
|
|
15990
16648
|
const requestOptions = {
|
|
15991
16649
|
...options,
|
|
15992
16650
|
relatedRequestId: request.id
|
|
15993
16651
|
};
|
|
15994
16652
|
if (relatedTaskId && !requestOptions.relatedTask) requestOptions.relatedTask = { taskId: relatedTaskId };
|
|
15995
|
-
const effectiveTaskId =
|
|
16653
|
+
const effectiveTaskId = requestOptions.relatedTask?.taskId ?? relatedTaskId;
|
|
15996
16654
|
if (effectiveTaskId && taskStore) await taskStore.updateTaskStatus(effectiveTaskId, "input_required");
|
|
15997
16655
|
return await this.request(r, resultSchema, requestOptions);
|
|
15998
16656
|
},
|
|
15999
|
-
authInfo: extra
|
|
16657
|
+
authInfo: extra?.authInfo,
|
|
16000
16658
|
requestId: request.id,
|
|
16001
|
-
requestInfo: extra
|
|
16659
|
+
requestInfo: extra?.requestInfo,
|
|
16002
16660
|
taskId: relatedTaskId,
|
|
16003
16661
|
taskStore,
|
|
16004
|
-
taskRequestedTtl: taskCreationParams
|
|
16005
|
-
closeSSEStream: extra
|
|
16006
|
-
closeStandaloneSSEStream: extra
|
|
16662
|
+
taskRequestedTtl: taskCreationParams?.ttl,
|
|
16663
|
+
closeSSEStream: extra?.closeSSEStream,
|
|
16664
|
+
closeStandaloneSSEStream: extra?.closeStandaloneSSEStream
|
|
16007
16665
|
};
|
|
16008
16666
|
Promise.resolve().then(() => {
|
|
16009
16667
|
if (taskCreationParams) this.assertTaskHandlerCapability(request.method);
|
|
@@ -16018,17 +16676,16 @@ var Protocol = class {
|
|
|
16018
16676
|
type: "response",
|
|
16019
16677
|
message: response,
|
|
16020
16678
|
timestamp: Date.now()
|
|
16021
|
-
}, capturedTransport
|
|
16022
|
-
else await
|
|
16679
|
+
}, capturedTransport?.sessionId);
|
|
16680
|
+
else await capturedTransport?.send(response);
|
|
16023
16681
|
}, async (error$1) => {
|
|
16024
|
-
var _a$1;
|
|
16025
16682
|
if (abortController.signal.aborted) return;
|
|
16026
16683
|
const errorResponse = {
|
|
16027
16684
|
jsonrpc: "2.0",
|
|
16028
16685
|
id: request.id,
|
|
16029
16686
|
error: {
|
|
16030
16687
|
code: Number.isSafeInteger(error$1["code"]) ? error$1["code"] : ErrorCode.InternalError,
|
|
16031
|
-
message:
|
|
16688
|
+
message: error$1.message ?? "Internal error",
|
|
16032
16689
|
...error$1["data"] !== void 0 && { data: error$1["data"] }
|
|
16033
16690
|
}
|
|
16034
16691
|
};
|
|
@@ -16036,8 +16693,8 @@ var Protocol = class {
|
|
|
16036
16693
|
type: "error",
|
|
16037
16694
|
message: errorResponse,
|
|
16038
16695
|
timestamp: Date.now()
|
|
16039
|
-
}, capturedTransport
|
|
16040
|
-
else await
|
|
16696
|
+
}, capturedTransport?.sessionId);
|
|
16697
|
+
else await capturedTransport?.send(errorResponse);
|
|
16041
16698
|
}).catch((error$1) => this._onerror(/* @__PURE__ */ new Error(`Failed to send response: ${error$1}`))).finally(() => {
|
|
16042
16699
|
this._requestHandlerAbortControllers.delete(request.id);
|
|
16043
16700
|
});
|
|
@@ -16068,7 +16725,7 @@ var Protocol = class {
|
|
|
16068
16725
|
const resolver = this._requestResolvers.get(messageId);
|
|
16069
16726
|
if (resolver) {
|
|
16070
16727
|
this._requestResolvers.delete(messageId);
|
|
16071
|
-
if (
|
|
16728
|
+
if (isJSONRPCResultResponse(response)) resolver(response);
|
|
16072
16729
|
else resolver(new McpError(response.error.code, response.error.message, response.error.data));
|
|
16073
16730
|
return;
|
|
16074
16731
|
}
|
|
@@ -16080,7 +16737,7 @@ var Protocol = class {
|
|
|
16080
16737
|
this._responseHandlers.delete(messageId);
|
|
16081
16738
|
this._cleanupTimeout(messageId);
|
|
16082
16739
|
let isTaskResponse = false;
|
|
16083
|
-
if (
|
|
16740
|
+
if (isJSONRPCResultResponse(response) && response.result && typeof response.result === "object") {
|
|
16084
16741
|
const result = response.result;
|
|
16085
16742
|
if (result.task && typeof result.task === "object") {
|
|
16086
16743
|
const task = result.task;
|
|
@@ -16091,7 +16748,7 @@ var Protocol = class {
|
|
|
16091
16748
|
}
|
|
16092
16749
|
}
|
|
16093
16750
|
if (!isTaskResponse) this._progressHandlers.delete(messageId);
|
|
16094
|
-
if (
|
|
16751
|
+
if (isJSONRPCResultResponse(response)) handler(response);
|
|
16095
16752
|
else handler(McpError.fromError(response.error.code, response.error.message, response.error.data));
|
|
16096
16753
|
}
|
|
16097
16754
|
get transport() {
|
|
@@ -16101,8 +16758,7 @@ var Protocol = class {
|
|
|
16101
16758
|
* Closes the connection.
|
|
16102
16759
|
*/
|
|
16103
16760
|
async close() {
|
|
16104
|
-
|
|
16105
|
-
await ((_a = this._transport) === null || _a === void 0 ? void 0 : _a.close());
|
|
16761
|
+
await this._transport?.close();
|
|
16106
16762
|
}
|
|
16107
16763
|
/**
|
|
16108
16764
|
* Sends a request and returns an AsyncGenerator that yields response messages.
|
|
@@ -16132,8 +16788,7 @@ var Protocol = class {
|
|
|
16132
16788
|
* @experimental Use `client.experimental.tasks.requestStream()` to access this method.
|
|
16133
16789
|
*/
|
|
16134
16790
|
async *requestStream(request, resultSchema, options) {
|
|
16135
|
-
|
|
16136
|
-
const { task } = options !== null && options !== void 0 ? options : {};
|
|
16791
|
+
const { task } = options ?? {};
|
|
16137
16792
|
if (!task) {
|
|
16138
16793
|
try {
|
|
16139
16794
|
yield {
|
|
@@ -16186,9 +16841,9 @@ var Protocol = class {
|
|
|
16186
16841
|
};
|
|
16187
16842
|
return;
|
|
16188
16843
|
}
|
|
16189
|
-
const pollInterval =
|
|
16844
|
+
const pollInterval = task$1.pollInterval ?? this._options?.defaultTaskPollInterval ?? 1e3;
|
|
16190
16845
|
await new Promise((resolve$2) => setTimeout(resolve$2, pollInterval));
|
|
16191
|
-
|
|
16846
|
+
options?.signal?.throwIfAborted();
|
|
16192
16847
|
}
|
|
16193
16848
|
} catch (error$1) {
|
|
16194
16849
|
yield {
|
|
@@ -16203,9 +16858,8 @@ var Protocol = class {
|
|
|
16203
16858
|
* Do not use this method to emit notifications! Use notification() instead.
|
|
16204
16859
|
*/
|
|
16205
16860
|
request(request, resultSchema, options) {
|
|
16206
|
-
const { relatedRequestId, resumptionToken, onresumptiontoken, task, relatedTask } = options
|
|
16861
|
+
const { relatedRequestId, resumptionToken, onresumptiontoken, task, relatedTask } = options ?? {};
|
|
16207
16862
|
return new Promise((resolve$2, reject) => {
|
|
16208
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
16209
16863
|
const earlyReject = (error$1) => {
|
|
16210
16864
|
reject(error$1);
|
|
16211
16865
|
};
|
|
@@ -16213,26 +16867,26 @@ var Protocol = class {
|
|
|
16213
16867
|
earlyReject(/* @__PURE__ */ new Error("Not connected"));
|
|
16214
16868
|
return;
|
|
16215
16869
|
}
|
|
16216
|
-
if (
|
|
16870
|
+
if (this._options?.enforceStrictCapabilities === true) try {
|
|
16217
16871
|
this.assertCapabilityForMethod(request.method);
|
|
16218
16872
|
if (task) this.assertTaskCapability(request.method);
|
|
16219
16873
|
} catch (e) {
|
|
16220
16874
|
earlyReject(e);
|
|
16221
16875
|
return;
|
|
16222
16876
|
}
|
|
16223
|
-
|
|
16877
|
+
options?.signal?.throwIfAborted();
|
|
16224
16878
|
const messageId = this._requestMessageId++;
|
|
16225
16879
|
const jsonrpcRequest = {
|
|
16226
16880
|
...request,
|
|
16227
16881
|
jsonrpc: "2.0",
|
|
16228
16882
|
id: messageId
|
|
16229
16883
|
};
|
|
16230
|
-
if (options
|
|
16884
|
+
if (options?.onprogress) {
|
|
16231
16885
|
this._progressHandlers.set(messageId, options.onprogress);
|
|
16232
16886
|
jsonrpcRequest.params = {
|
|
16233
16887
|
...request.params,
|
|
16234
16888
|
_meta: {
|
|
16235
|
-
...
|
|
16889
|
+
...request.params?._meta || {},
|
|
16236
16890
|
progressToken: messageId
|
|
16237
16891
|
}
|
|
16238
16892
|
};
|
|
@@ -16244,16 +16898,15 @@ var Protocol = class {
|
|
|
16244
16898
|
if (relatedTask) jsonrpcRequest.params = {
|
|
16245
16899
|
...jsonrpcRequest.params,
|
|
16246
16900
|
_meta: {
|
|
16247
|
-
...
|
|
16901
|
+
...jsonrpcRequest.params?._meta || {},
|
|
16248
16902
|
[RELATED_TASK_META_KEY]: relatedTask
|
|
16249
16903
|
}
|
|
16250
16904
|
};
|
|
16251
16905
|
const cancel = (reason) => {
|
|
16252
|
-
var _a$1;
|
|
16253
16906
|
this._responseHandlers.delete(messageId);
|
|
16254
16907
|
this._progressHandlers.delete(messageId);
|
|
16255
16908
|
this._cleanupTimeout(messageId);
|
|
16256
|
-
|
|
16909
|
+
this._transport?.send({
|
|
16257
16910
|
jsonrpc: "2.0",
|
|
16258
16911
|
method: "notifications/cancelled",
|
|
16259
16912
|
params: {
|
|
@@ -16268,8 +16921,7 @@ var Protocol = class {
|
|
|
16268
16921
|
reject(reason instanceof McpError ? reason : new McpError(ErrorCode.RequestTimeout, String(reason)));
|
|
16269
16922
|
};
|
|
16270
16923
|
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;
|
|
16924
|
+
if (options?.signal?.aborted) return;
|
|
16273
16925
|
if (response instanceof Error) return reject(response);
|
|
16274
16926
|
try {
|
|
16275
16927
|
const parseResult = safeParse(resultSchema, response.result);
|
|
@@ -16279,14 +16931,13 @@ var Protocol = class {
|
|
|
16279
16931
|
reject(error$1);
|
|
16280
16932
|
}
|
|
16281
16933
|
});
|
|
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);
|
|
16934
|
+
options?.signal?.addEventListener("abort", () => {
|
|
16935
|
+
cancel(options?.signal?.reason);
|
|
16285
16936
|
});
|
|
16286
|
-
const timeout =
|
|
16937
|
+
const timeout = options?.timeout ?? DEFAULT_REQUEST_TIMEOUT_MSEC;
|
|
16287
16938
|
const timeoutHandler = () => cancel(McpError.fromError(ErrorCode.RequestTimeout, "Request timed out", { timeout }));
|
|
16288
|
-
this._setupTimeout(messageId, timeout, options
|
|
16289
|
-
const relatedTaskId = relatedTask
|
|
16939
|
+
this._setupTimeout(messageId, timeout, options?.maxTotalTimeout, timeoutHandler, options?.resetTimeoutOnProgress ?? false);
|
|
16940
|
+
const relatedTaskId = relatedTask?.taskId;
|
|
16290
16941
|
if (relatedTaskId) {
|
|
16291
16942
|
const responseResolver = (response) => {
|
|
16292
16943
|
const handler = this._responseHandlers.get(messageId);
|
|
@@ -16360,10 +17011,9 @@ var Protocol = class {
|
|
|
16360
17011
|
* Emits a notification, which is a one-way message that does not expect a response.
|
|
16361
17012
|
*/
|
|
16362
17013
|
async notification(notification, options) {
|
|
16363
|
-
var _a, _b, _c, _d, _e;
|
|
16364
17014
|
if (!this._transport) throw new Error("Not connected");
|
|
16365
17015
|
this.assertNotificationCapability(notification.method);
|
|
16366
|
-
const relatedTaskId =
|
|
17016
|
+
const relatedTaskId = options?.relatedTask?.taskId;
|
|
16367
17017
|
if (relatedTaskId) {
|
|
16368
17018
|
const jsonrpcNotification$1 = {
|
|
16369
17019
|
...notification,
|
|
@@ -16371,7 +17021,7 @@ var Protocol = class {
|
|
|
16371
17021
|
params: {
|
|
16372
17022
|
...notification.params,
|
|
16373
17023
|
_meta: {
|
|
16374
|
-
...
|
|
17024
|
+
...notification.params?._meta || {},
|
|
16375
17025
|
[RELATED_TASK_META_KEY]: options.relatedTask
|
|
16376
17026
|
}
|
|
16377
17027
|
}
|
|
@@ -16383,28 +17033,27 @@ var Protocol = class {
|
|
|
16383
17033
|
});
|
|
16384
17034
|
return;
|
|
16385
17035
|
}
|
|
16386
|
-
if ((
|
|
17036
|
+
if ((this._options?.debouncedNotificationMethods ?? []).includes(notification.method) && !notification.params && !options?.relatedRequestId && !options?.relatedTask) {
|
|
16387
17037
|
if (this._pendingDebouncedNotifications.has(notification.method)) return;
|
|
16388
17038
|
this._pendingDebouncedNotifications.add(notification.method);
|
|
16389
17039
|
Promise.resolve().then(() => {
|
|
16390
|
-
var _a$1, _b$1;
|
|
16391
17040
|
this._pendingDebouncedNotifications.delete(notification.method);
|
|
16392
17041
|
if (!this._transport) return;
|
|
16393
17042
|
let jsonrpcNotification$1 = {
|
|
16394
17043
|
...notification,
|
|
16395
17044
|
jsonrpc: "2.0"
|
|
16396
17045
|
};
|
|
16397
|
-
if (options
|
|
17046
|
+
if (options?.relatedTask) jsonrpcNotification$1 = {
|
|
16398
17047
|
...jsonrpcNotification$1,
|
|
16399
17048
|
params: {
|
|
16400
17049
|
...jsonrpcNotification$1.params,
|
|
16401
17050
|
_meta: {
|
|
16402
|
-
...
|
|
17051
|
+
...jsonrpcNotification$1.params?._meta || {},
|
|
16403
17052
|
[RELATED_TASK_META_KEY]: options.relatedTask
|
|
16404
17053
|
}
|
|
16405
17054
|
}
|
|
16406
17055
|
};
|
|
16407
|
-
|
|
17056
|
+
this._transport?.send(jsonrpcNotification$1, options).catch((error$1) => this._onerror(error$1));
|
|
16408
17057
|
});
|
|
16409
17058
|
return;
|
|
16410
17059
|
}
|
|
@@ -16412,12 +17061,12 @@ var Protocol = class {
|
|
|
16412
17061
|
...notification,
|
|
16413
17062
|
jsonrpc: "2.0"
|
|
16414
17063
|
};
|
|
16415
|
-
if (options
|
|
17064
|
+
if (options?.relatedTask) jsonrpcNotification = {
|
|
16416
17065
|
...jsonrpcNotification,
|
|
16417
17066
|
params: {
|
|
16418
17067
|
...jsonrpcNotification.params,
|
|
16419
17068
|
_meta: {
|
|
16420
|
-
...
|
|
17069
|
+
...jsonrpcNotification.params?._meta || {},
|
|
16421
17070
|
[RELATED_TASK_META_KEY]: options.relatedTask
|
|
16422
17071
|
}
|
|
16423
17072
|
}
|
|
@@ -16490,9 +17139,8 @@ var Protocol = class {
|
|
|
16490
17139
|
* simply propagates the error.
|
|
16491
17140
|
*/
|
|
16492
17141
|
async _enqueueTaskMessage(taskId, message, sessionId) {
|
|
16493
|
-
var _a;
|
|
16494
17142
|
if (!this._taskStore || !this._taskMessageQueue) throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");
|
|
16495
|
-
const maxQueueSize =
|
|
17143
|
+
const maxQueueSize = this._options?.maxTaskQueueSize;
|
|
16496
17144
|
await this._taskMessageQueue.enqueue(taskId, message, sessionId, maxQueueSize);
|
|
16497
17145
|
}
|
|
16498
17146
|
/**
|
|
@@ -16521,12 +17169,11 @@ var Protocol = class {
|
|
|
16521
17169
|
* @returns Promise that resolves when an update occurs or rejects if aborted
|
|
16522
17170
|
*/
|
|
16523
17171
|
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;
|
|
17172
|
+
let interval = this._options?.defaultTaskPollInterval ?? 1e3;
|
|
16526
17173
|
try {
|
|
16527
|
-
const task = await
|
|
16528
|
-
if (task
|
|
16529
|
-
} catch
|
|
17174
|
+
const task = await this._taskStore?.getTask(taskId);
|
|
17175
|
+
if (task?.pollInterval) interval = task.pollInterval;
|
|
17176
|
+
} catch {}
|
|
16530
17177
|
return new Promise((resolve$2, reject) => {
|
|
16531
17178
|
if (signal.aborted) {
|
|
16532
17179
|
reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
|
|
@@ -16611,7 +17258,7 @@ function mergeCapabilities(base, additional) {
|
|
|
16611
17258
|
}
|
|
16612
17259
|
|
|
16613
17260
|
//#endregion
|
|
16614
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
17261
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/codegen/code.js
|
|
16615
17262
|
var require_code$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
16616
17263
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16617
17264
|
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 +17394,7 @@ var require_code$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
16747
17394
|
}));
|
|
16748
17395
|
|
|
16749
17396
|
//#endregion
|
|
16750
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
17397
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/codegen/scope.js
|
|
16751
17398
|
var require_scope = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
16752
17399
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16753
17400
|
exports.ValueScope = exports.ValueScopeName = exports.Scope = exports.varKinds = exports.UsedValueState = void 0;
|
|
@@ -16885,7 +17532,7 @@ var require_scope = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
16885
17532
|
}));
|
|
16886
17533
|
|
|
16887
17534
|
//#endregion
|
|
16888
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
17535
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/codegen/index.js
|
|
16889
17536
|
var require_codegen = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
16890
17537
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16891
17538
|
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 +18202,7 @@ var require_codegen = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
17555
18202
|
}));
|
|
17556
18203
|
|
|
17557
18204
|
//#endregion
|
|
17558
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
18205
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/util.js
|
|
17559
18206
|
var require_util = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
17560
18207
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17561
18208
|
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 +18344,7 @@ var require_util = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
17697
18344
|
}));
|
|
17698
18345
|
|
|
17699
18346
|
//#endregion
|
|
17700
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
18347
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/names.js
|
|
17701
18348
|
var require_names = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
17702
18349
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17703
18350
|
const codegen_1$36 = require_codegen();
|
|
@@ -17723,12 +18370,12 @@ var require_names = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
17723
18370
|
}));
|
|
17724
18371
|
|
|
17725
18372
|
//#endregion
|
|
17726
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
18373
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/errors.js
|
|
17727
18374
|
var require_errors = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
17728
18375
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17729
18376
|
exports.extendErrors = exports.resetErrorsCount = exports.reportExtraError = exports.reportError = exports.keyword$DataError = exports.keywordError = void 0;
|
|
17730
18377
|
const codegen_1$35 = require_codegen();
|
|
17731
|
-
const util_1$
|
|
18378
|
+
const util_1$30 = require_util();
|
|
17732
18379
|
const names_1$7 = require_names();
|
|
17733
18380
|
exports.keywordError = { message: ({ keyword }) => (0, codegen_1$35.str)`must pass "${keyword}" keyword validation` };
|
|
17734
18381
|
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 +18448,12 @@ var require_errors = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
17801
18448
|
return gen.object(...keyValues);
|
|
17802
18449
|
}
|
|
17803
18450
|
function errorInstancePath({ errorPath }, { instancePath }) {
|
|
17804
|
-
const instPath = instancePath ? (0, codegen_1$35.str)`${errorPath}${(0, util_1$
|
|
18451
|
+
const instPath = instancePath ? (0, codegen_1$35.str)`${errorPath}${(0, util_1$30.getErrorPath)(instancePath, util_1$30.Type.Str)}` : errorPath;
|
|
17805
18452
|
return [names_1$7.default.instancePath, (0, codegen_1$35.strConcat)(names_1$7.default.instancePath, instPath)];
|
|
17806
18453
|
}
|
|
17807
18454
|
function errorSchemaPath({ keyword, it: { errSchemaPath } }, { schemaPath, parentSchema }) {
|
|
17808
18455
|
let schPath = parentSchema ? errSchemaPath : (0, codegen_1$35.str)`${errSchemaPath}/${keyword}`;
|
|
17809
|
-
if (schemaPath) schPath = (0, codegen_1$35.str)`${schPath}${(0, util_1$
|
|
18456
|
+
if (schemaPath) schPath = (0, codegen_1$35.str)`${schPath}${(0, util_1$30.getErrorPath)(schemaPath, util_1$30.Type.Str)}`;
|
|
17810
18457
|
return [E.schemaPath, schPath];
|
|
17811
18458
|
}
|
|
17812
18459
|
function extraErrorProps(cxt, { params, message }, keyValues) {
|
|
@@ -17820,7 +18467,7 @@ var require_errors = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
17820
18467
|
}));
|
|
17821
18468
|
|
|
17822
18469
|
//#endregion
|
|
17823
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
18470
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/validate/boolSchema.js
|
|
17824
18471
|
var require_boolSchema = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
17825
18472
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17826
18473
|
exports.boolOrEmptySchema = exports.topBoolOrEmptySchema = void 0;
|
|
@@ -17863,7 +18510,7 @@ var require_boolSchema = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
17863
18510
|
}));
|
|
17864
18511
|
|
|
17865
18512
|
//#endregion
|
|
17866
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
18513
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/rules.js
|
|
17867
18514
|
var require_rules = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
17868
18515
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17869
18516
|
exports.getRules = exports.isJSONType = void 0;
|
|
@@ -17922,7 +18569,7 @@ var require_rules = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
17922
18569
|
}));
|
|
17923
18570
|
|
|
17924
18571
|
//#endregion
|
|
17925
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
18572
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/validate/applicability.js
|
|
17926
18573
|
var require_applicability = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
17927
18574
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17928
18575
|
exports.shouldUseRule = exports.shouldUseGroup = exports.schemaHasRulesForType = void 0;
|
|
@@ -17943,7 +18590,7 @@ var require_applicability = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
17943
18590
|
}));
|
|
17944
18591
|
|
|
17945
18592
|
//#endregion
|
|
17946
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
18593
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/validate/dataType.js
|
|
17947
18594
|
var require_dataType = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
17948
18595
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17949
18596
|
exports.reportTypeError = exports.checkDataTypes = exports.checkDataType = exports.coerceAndCheckDataType = exports.getJSONTypes = exports.getSchemaTypes = exports.DataType = void 0;
|
|
@@ -17951,7 +18598,7 @@ var require_dataType = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
17951
18598
|
const applicability_1$1 = require_applicability();
|
|
17952
18599
|
const errors_1$2 = require_errors();
|
|
17953
18600
|
const codegen_1$33 = require_codegen();
|
|
17954
|
-
const util_1$
|
|
18601
|
+
const util_1$29 = require_util();
|
|
17955
18602
|
var DataType;
|
|
17956
18603
|
(function(DataType$1) {
|
|
17957
18604
|
DataType$1[DataType$1["Correct"] = 0] = "Correct";
|
|
@@ -18068,7 +18715,7 @@ var require_dataType = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
18068
18715
|
function checkDataTypes(dataTypes, data, strictNums, correct) {
|
|
18069
18716
|
if (dataTypes.length === 1) return checkDataType(dataTypes[0], data, strictNums, correct);
|
|
18070
18717
|
let cond;
|
|
18071
|
-
const types = (0, util_1$
|
|
18718
|
+
const types = (0, util_1$29.toHash)(dataTypes);
|
|
18072
18719
|
if (types.array && types.object) {
|
|
18073
18720
|
const notObj = (0, codegen_1$33._)`typeof ${data} != "object"`;
|
|
18074
18721
|
cond = types.null ? notObj : (0, codegen_1$33._)`!${data} || ${notObj}`;
|
|
@@ -18092,7 +18739,7 @@ var require_dataType = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
18092
18739
|
exports.reportTypeError = reportTypeError;
|
|
18093
18740
|
function getTypeErrorContext(it) {
|
|
18094
18741
|
const { gen, data, schema } = it;
|
|
18095
|
-
const schemaCode = (0, util_1$
|
|
18742
|
+
const schemaCode = (0, util_1$29.schemaRefOrVal)(it, schema, "type");
|
|
18096
18743
|
return {
|
|
18097
18744
|
gen,
|
|
18098
18745
|
keyword: "type",
|
|
@@ -18108,12 +18755,12 @@ var require_dataType = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
18108
18755
|
}));
|
|
18109
18756
|
|
|
18110
18757
|
//#endregion
|
|
18111
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
18758
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/validate/defaults.js
|
|
18112
18759
|
var require_defaults = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
18113
18760
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18114
18761
|
exports.assignDefaults = void 0;
|
|
18115
18762
|
const codegen_1$32 = require_codegen();
|
|
18116
|
-
const util_1$
|
|
18763
|
+
const util_1$28 = require_util();
|
|
18117
18764
|
function assignDefaults(it, ty) {
|
|
18118
18765
|
const { properties, items } = it.schema;
|
|
18119
18766
|
if (ty === "object" && properties) for (const key$1 in properties) assignDefault(it, key$1, properties[key$1].default);
|
|
@@ -18125,7 +18772,7 @@ var require_defaults = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
18125
18772
|
if (defaultValue === void 0) return;
|
|
18126
18773
|
const childData = (0, codegen_1$32._)`${data}${(0, codegen_1$32.getProperty)(prop)}`;
|
|
18127
18774
|
if (compositeRule) {
|
|
18128
|
-
(0, util_1$
|
|
18775
|
+
(0, util_1$28.checkStrictMode)(it, `default is ignored for: ${childData}`);
|
|
18129
18776
|
return;
|
|
18130
18777
|
}
|
|
18131
18778
|
let condition = (0, codegen_1$32._)`${childData} === undefined`;
|
|
@@ -18135,12 +18782,12 @@ var require_defaults = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
18135
18782
|
}));
|
|
18136
18783
|
|
|
18137
18784
|
//#endregion
|
|
18138
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
18785
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/code.js
|
|
18139
18786
|
var require_code = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
18140
18787
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18141
18788
|
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
18789
|
const codegen_1$31 = require_codegen();
|
|
18143
|
-
const util_1$
|
|
18790
|
+
const util_1$27 = require_util();
|
|
18144
18791
|
const names_1$5 = require_names();
|
|
18145
18792
|
const util_2$1 = require_util();
|
|
18146
18793
|
function checkReportMissingProp(cxt, prop) {
|
|
@@ -18186,7 +18833,7 @@ var require_code = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
18186
18833
|
}
|
|
18187
18834
|
exports.allSchemaProperties = allSchemaProperties;
|
|
18188
18835
|
function schemaProperties(it, schemaMap) {
|
|
18189
|
-
return allSchemaProperties(schemaMap).filter((p) => !(0, util_1$
|
|
18836
|
+
return allSchemaProperties(schemaMap).filter((p) => !(0, util_1$27.alwaysValidSchema)(it, schemaMap[p]));
|
|
18190
18837
|
}
|
|
18191
18838
|
exports.schemaProperties = schemaProperties;
|
|
18192
18839
|
function callValidateCode({ schemaCode, data, it: { gen, topSchemaRef, schemaPath, errorPath }, it }, func, context, passSchema) {
|
|
@@ -18231,7 +18878,7 @@ var require_code = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
18231
18878
|
cxt.subschema({
|
|
18232
18879
|
keyword,
|
|
18233
18880
|
dataProp: i$3,
|
|
18234
|
-
dataPropType: util_1$
|
|
18881
|
+
dataPropType: util_1$27.Type.Num
|
|
18235
18882
|
}, valid);
|
|
18236
18883
|
gen.if((0, codegen_1$31.not)(valid), notValid);
|
|
18237
18884
|
});
|
|
@@ -18242,7 +18889,7 @@ var require_code = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
18242
18889
|
const { gen, schema, keyword, it } = cxt;
|
|
18243
18890
|
/* istanbul ignore if */
|
|
18244
18891
|
if (!Array.isArray(schema)) throw new Error("ajv implementation error");
|
|
18245
|
-
if (schema.some((sch) => (0, util_1$
|
|
18892
|
+
if (schema.some((sch) => (0, util_1$27.alwaysValidSchema)(it, sch)) && !it.opts.unevaluated) return;
|
|
18246
18893
|
const valid = gen.let("valid", false);
|
|
18247
18894
|
const schValid = gen.name("_valid");
|
|
18248
18895
|
gen.block(() => schema.forEach((_sch, i$3) => {
|
|
@@ -18260,7 +18907,7 @@ var require_code = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
18260
18907
|
}));
|
|
18261
18908
|
|
|
18262
18909
|
//#endregion
|
|
18263
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
18910
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/validate/keyword.js
|
|
18264
18911
|
var require_keyword = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
18265
18912
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18266
18913
|
exports.validateKeywordUsage = exports.validSchemaType = exports.funcKeywordCode = exports.macroKeywordCode = void 0;
|
|
@@ -18367,12 +19014,12 @@ var require_keyword = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
18367
19014
|
}));
|
|
18368
19015
|
|
|
18369
19016
|
//#endregion
|
|
18370
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
19017
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/validate/subschema.js
|
|
18371
19018
|
var require_subschema = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
18372
19019
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18373
19020
|
exports.extendSubschemaMode = exports.extendSubschemaData = exports.getSubschema = void 0;
|
|
18374
19021
|
const codegen_1$29 = require_codegen();
|
|
18375
|
-
const util_1$
|
|
19022
|
+
const util_1$26 = require_util();
|
|
18376
19023
|
function getSubschema(it, { keyword, schemaProp, schema, schemaPath, errSchemaPath, topSchemaRef }) {
|
|
18377
19024
|
if (keyword !== void 0 && schema !== void 0) throw new Error("both \"keyword\" and \"schema\" passed, only one allowed");
|
|
18378
19025
|
if (keyword !== void 0) {
|
|
@@ -18384,7 +19031,7 @@ var require_subschema = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
18384
19031
|
} : {
|
|
18385
19032
|
schema: sch[schemaProp],
|
|
18386
19033
|
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$
|
|
19034
|
+
errSchemaPath: `${it.errSchemaPath}/${keyword}/${(0, util_1$26.escapeFragment)(schemaProp)}`
|
|
18388
19035
|
};
|
|
18389
19036
|
}
|
|
18390
19037
|
if (schema !== void 0) {
|
|
@@ -18405,7 +19052,7 @@ var require_subschema = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
18405
19052
|
if (dataProp !== void 0) {
|
|
18406
19053
|
const { errorPath, dataPathArr, opts } = it;
|
|
18407
19054
|
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$
|
|
19055
|
+
subschema.errorPath = (0, codegen_1$29.str)`${errorPath}${(0, util_1$26.getErrorPath)(dataProp, dpType, opts.jsPropertySyntax)}`;
|
|
18409
19056
|
subschema.parentDataProperty = (0, codegen_1$29._)`${dataProp}`;
|
|
18410
19057
|
subschema.dataPathArr = [...dataPathArr, subschema.parentDataProperty];
|
|
18411
19058
|
}
|
|
@@ -18542,11 +19189,11 @@ var require_json_schema_traverse = /* @__PURE__ */ __commonJSMin(((exports, modu
|
|
|
18542
19189
|
}));
|
|
18543
19190
|
|
|
18544
19191
|
//#endregion
|
|
18545
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
19192
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/resolve.js
|
|
18546
19193
|
var require_resolve = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
18547
19194
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18548
19195
|
exports.getSchemaRefs = exports.resolveUrl = exports.normalizeId = exports._getFullPath = exports.getFullPath = exports.inlineRef = void 0;
|
|
18549
|
-
const util_1$
|
|
19196
|
+
const util_1$25 = require_util();
|
|
18550
19197
|
const equal$2 = require_fast_deep_equal();
|
|
18551
19198
|
const traverse = require_json_schema_traverse();
|
|
18552
19199
|
const SIMPLE_INLINED = new Set([
|
|
@@ -18596,7 +19243,7 @@ var require_resolve = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
18596
19243
|
if (key$1 === "$ref") return Infinity;
|
|
18597
19244
|
count++;
|
|
18598
19245
|
if (SIMPLE_INLINED.has(key$1)) continue;
|
|
18599
|
-
if (typeof schema[key$1] == "object") (0, util_1$
|
|
19246
|
+
if (typeof schema[key$1] == "object") (0, util_1$25.eachItem)(schema[key$1], (sch) => count += countKeys(sch));
|
|
18600
19247
|
if (count === Infinity) return Infinity;
|
|
18601
19248
|
}
|
|
18602
19249
|
return count;
|
|
@@ -18670,7 +19317,7 @@ var require_resolve = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
18670
19317
|
}));
|
|
18671
19318
|
|
|
18672
19319
|
//#endregion
|
|
18673
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
19320
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/validate/index.js
|
|
18674
19321
|
var require_validate = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
18675
19322
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18676
19323
|
exports.getData = exports.KeywordCxt = exports.validateFunctionCode = void 0;
|
|
@@ -18684,7 +19331,7 @@ var require_validate = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
18684
19331
|
const codegen_1$28 = require_codegen();
|
|
18685
19332
|
const names_1$3 = require_names();
|
|
18686
19333
|
const resolve_1$3 = require_resolve();
|
|
18687
|
-
const util_1$
|
|
19334
|
+
const util_1$24 = require_util();
|
|
18688
19335
|
const errors_1 = require_errors();
|
|
18689
19336
|
function validateFunctionCode(it) {
|
|
18690
19337
|
if (isSchemaObj(it)) {
|
|
@@ -18773,7 +19420,7 @@ var require_validate = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
18773
19420
|
gen.var(valid, (0, codegen_1$28._)`${errsCount} === ${names_1$3.default.errors}`);
|
|
18774
19421
|
}
|
|
18775
19422
|
function checkKeywords(it) {
|
|
18776
|
-
(0, util_1$
|
|
19423
|
+
(0, util_1$24.checkUnknownRules)(it);
|
|
18777
19424
|
checkRefsAndKeywords(it);
|
|
18778
19425
|
}
|
|
18779
19426
|
function typeAndKeywords(it, errsCount) {
|
|
@@ -18783,11 +19430,11 @@ var require_validate = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
18783
19430
|
}
|
|
18784
19431
|
function checkRefsAndKeywords(it) {
|
|
18785
19432
|
const { schema, errSchemaPath, opts, self } = it;
|
|
18786
|
-
if (schema.$ref && opts.ignoreKeywordsWithRef && (0, util_1$
|
|
19433
|
+
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
19434
|
}
|
|
18788
19435
|
function checkNoDefault(it) {
|
|
18789
19436
|
const { schema, opts } = it;
|
|
18790
|
-
if (schema.default !== void 0 && opts.useDefaults && opts.strictSchema) (0, util_1$
|
|
19437
|
+
if (schema.default !== void 0 && opts.useDefaults && opts.strictSchema) (0, util_1$24.checkStrictMode)(it, "default is ignored in the schema root");
|
|
18791
19438
|
}
|
|
18792
19439
|
function updateContext(it) {
|
|
18793
19440
|
const schId = it.schema[it.opts.schemaId];
|
|
@@ -18821,7 +19468,7 @@ var require_validate = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
18821
19468
|
function schemaKeywords(it, types, typeErrors, errsCount) {
|
|
18822
19469
|
const { gen, schema, data, allErrors, opts, self } = it;
|
|
18823
19470
|
const { RULES } = self;
|
|
18824
|
-
if (schema.$ref && (opts.ignoreKeywordsWithRef || !(0, util_1$
|
|
19471
|
+
if (schema.$ref && (opts.ignoreKeywordsWithRef || !(0, util_1$24.schemaHasRulesButRef)(schema, RULES))) {
|
|
18825
19472
|
gen.block(() => keywordCode(it, "$ref", RULES.all.$ref.definition));
|
|
18826
19473
|
return;
|
|
18827
19474
|
}
|
|
@@ -18896,7 +19543,7 @@ var require_validate = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
18896
19543
|
function strictTypesError(it, msg) {
|
|
18897
19544
|
const schemaPath = it.schemaEnv.baseId + it.errSchemaPath;
|
|
18898
19545
|
msg += ` at "${schemaPath}" (strictTypes)`;
|
|
18899
|
-
(0, util_1$
|
|
19546
|
+
(0, util_1$24.checkStrictMode)(it, msg, it.opts.strictTypes);
|
|
18900
19547
|
}
|
|
18901
19548
|
var KeywordCxt = class {
|
|
18902
19549
|
constructor(it, def$30, keyword) {
|
|
@@ -18907,7 +19554,7 @@ var require_validate = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
18907
19554
|
this.data = it.data;
|
|
18908
19555
|
this.schema = it.schema[keyword];
|
|
18909
19556
|
this.$data = def$30.$data && it.opts.$data && this.schema && this.schema.$data;
|
|
18910
|
-
this.schemaValue = (0, util_1$
|
|
19557
|
+
this.schemaValue = (0, util_1$24.schemaRefOrVal)(it, this.schema, keyword, this.$data);
|
|
18911
19558
|
this.schemaType = def$30.schemaType;
|
|
18912
19559
|
this.parentSchema = it.schema;
|
|
18913
19560
|
this.params = {};
|
|
@@ -19033,8 +19680,8 @@ var require_validate = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
19033
19680
|
mergeEvaluated(schemaCxt, toName) {
|
|
19034
19681
|
const { it, gen } = this;
|
|
19035
19682
|
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$
|
|
19683
|
+
if (it.props !== true && schemaCxt.props !== void 0) it.props = util_1$24.mergeEvaluated.props(gen, schemaCxt.props, it.props, toName);
|
|
19684
|
+
if (it.items !== true && schemaCxt.items !== void 0) it.items = util_1$24.mergeEvaluated.items(gen, schemaCxt.items, it.items, toName);
|
|
19038
19685
|
}
|
|
19039
19686
|
mergeValidEvaluated(schemaCxt, valid) {
|
|
19040
19687
|
const { it, gen } = this;
|
|
@@ -19078,7 +19725,7 @@ var require_validate = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
19078
19725
|
let expr = data;
|
|
19079
19726
|
const segments = jsonPointer.split("/");
|
|
19080
19727
|
for (const segment of segments) if (segment) {
|
|
19081
|
-
data = (0, codegen_1$28._)`${data}${(0, codegen_1$28.getProperty)((0, util_1$
|
|
19728
|
+
data = (0, codegen_1$28._)`${data}${(0, codegen_1$28.getProperty)((0, util_1$24.unescapeJsonPointer)(segment))}`;
|
|
19082
19729
|
expr = (0, codegen_1$28._)`${expr} && ${data}`;
|
|
19083
19730
|
}
|
|
19084
19731
|
return expr;
|
|
@@ -19090,7 +19737,7 @@ var require_validate = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
19090
19737
|
}));
|
|
19091
19738
|
|
|
19092
19739
|
//#endregion
|
|
19093
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
19740
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/runtime/validation_error.js
|
|
19094
19741
|
var require_validation_error = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
19095
19742
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19096
19743
|
var ValidationError = class extends Error {
|
|
@@ -19104,7 +19751,7 @@ var require_validation_error = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
19104
19751
|
}));
|
|
19105
19752
|
|
|
19106
19753
|
//#endregion
|
|
19107
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
19754
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/ref_error.js
|
|
19108
19755
|
var require_ref_error = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
19109
19756
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19110
19757
|
const resolve_1$2 = require_resolve();
|
|
@@ -19119,7 +19766,7 @@ var require_ref_error = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
19119
19766
|
}));
|
|
19120
19767
|
|
|
19121
19768
|
//#endregion
|
|
19122
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
19769
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/compile/index.js
|
|
19123
19770
|
var require_compile = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
19124
19771
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19125
19772
|
exports.resolveSchema = exports.getCompilingSchema = exports.resolveRef = exports.compileSchema = exports.SchemaEnv = void 0;
|
|
@@ -19127,7 +19774,7 @@ var require_compile = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
19127
19774
|
const validation_error_1$2 = require_validation_error();
|
|
19128
19775
|
const names_1$2 = require_names();
|
|
19129
19776
|
const resolve_1$1 = require_resolve();
|
|
19130
|
-
const util_1$
|
|
19777
|
+
const util_1$23 = require_util();
|
|
19131
19778
|
const validate_1$3 = require_validate();
|
|
19132
19779
|
var SchemaEnv = class {
|
|
19133
19780
|
constructor(env) {
|
|
@@ -19311,14 +19958,14 @@ var require_compile = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
19311
19958
|
if (((_a = parsedRef.fragment) === null || _a === void 0 ? void 0 : _a[0]) !== "/") return;
|
|
19312
19959
|
for (const part of parsedRef.fragment.slice(1).split("/")) {
|
|
19313
19960
|
if (typeof schema === "boolean") return;
|
|
19314
|
-
const partSchema = schema[(0, util_1$
|
|
19961
|
+
const partSchema = schema[(0, util_1$23.unescapeFragment)(part)];
|
|
19315
19962
|
if (partSchema === void 0) return;
|
|
19316
19963
|
schema = partSchema;
|
|
19317
19964
|
const schId = typeof schema === "object" && schema[this.opts.schemaId];
|
|
19318
19965
|
if (!PREVENT_SCOPE_CHANGE.has(part) && schId) baseId = (0, resolve_1$1.resolveUrl)(this.opts.uriResolver, baseId, schId);
|
|
19319
19966
|
}
|
|
19320
19967
|
let env;
|
|
19321
|
-
if (typeof schema != "boolean" && schema.$ref && !(0, util_1$
|
|
19968
|
+
if (typeof schema != "boolean" && schema.$ref && !(0, util_1$23.schemaHasRulesButRef)(schema, this.RULES)) {
|
|
19322
19969
|
const $ref = (0, resolve_1$1.resolveUrl)(this.opts.uriResolver, baseId, schema.$ref);
|
|
19323
19970
|
env = resolveSchema.call(this, root, $ref);
|
|
19324
19971
|
}
|
|
@@ -19334,7 +19981,7 @@ var require_compile = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
19334
19981
|
}));
|
|
19335
19982
|
|
|
19336
19983
|
//#endregion
|
|
19337
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
19984
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/refs/data.json
|
|
19338
19985
|
var require_data = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
19339
19986
|
module.exports = {
|
|
19340
19987
|
"$id": "https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",
|
|
@@ -20049,7 +20696,7 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
20049
20696
|
}));
|
|
20050
20697
|
|
|
20051
20698
|
//#endregion
|
|
20052
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
20699
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/runtime/uri.js
|
|
20053
20700
|
var require_uri = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
20054
20701
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20055
20702
|
const uri$1 = require_fast_uri();
|
|
@@ -20058,7 +20705,7 @@ var require_uri = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
20058
20705
|
}));
|
|
20059
20706
|
|
|
20060
20707
|
//#endregion
|
|
20061
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
20708
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/core.js
|
|
20062
20709
|
var require_core$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
20063
20710
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20064
20711
|
exports.CodeGen = exports.Name = exports.nil = exports.stringify = exports.str = exports._ = exports.KeywordCxt = void 0;
|
|
@@ -20113,7 +20760,7 @@ var require_core$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
20113
20760
|
const codegen_2 = require_codegen();
|
|
20114
20761
|
const resolve_1 = require_resolve();
|
|
20115
20762
|
const dataType_1$1 = require_dataType();
|
|
20116
|
-
const util_1$
|
|
20763
|
+
const util_1$22 = require_util();
|
|
20117
20764
|
const $dataRefSchema = require_data();
|
|
20118
20765
|
const uri_1 = require_uri();
|
|
20119
20766
|
const defaultRegExp = (str$1, flags) => new RegExp(str$1, flags);
|
|
@@ -20375,8 +21022,8 @@ var require_core$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
20375
21022
|
return this;
|
|
20376
21023
|
}
|
|
20377
21024
|
case "object": {
|
|
20378
|
-
const cacheKey = schemaKeyRef;
|
|
20379
|
-
this._cache.delete(cacheKey);
|
|
21025
|
+
const cacheKey$1 = schemaKeyRef;
|
|
21026
|
+
this._cache.delete(cacheKey$1);
|
|
20380
21027
|
let id = schemaKeyRef[this.opts.schemaId];
|
|
20381
21028
|
if (id) {
|
|
20382
21029
|
id = (0, resolve_1.normalizeId)(id);
|
|
@@ -20407,7 +21054,7 @@ var require_core$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
20407
21054
|
} else throw new Error("invalid addKeywords parameters");
|
|
20408
21055
|
checkKeyword.call(this, keyword, def$30);
|
|
20409
21056
|
if (!def$30) {
|
|
20410
|
-
(0, util_1$
|
|
21057
|
+
(0, util_1$22.eachItem)(keyword, (kwd) => addRule.call(this, kwd));
|
|
20411
21058
|
return this;
|
|
20412
21059
|
}
|
|
20413
21060
|
keywordMetaschema.call(this, def$30);
|
|
@@ -20416,7 +21063,7 @@ var require_core$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
20416
21063
|
type: (0, dataType_1$1.getJSONTypes)(def$30.type),
|
|
20417
21064
|
schemaType: (0, dataType_1$1.getJSONTypes)(def$30.schemaType)
|
|
20418
21065
|
};
|
|
20419
|
-
(0, util_1$
|
|
21066
|
+
(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
21067
|
return this;
|
|
20421
21068
|
}
|
|
20422
21069
|
getKeyword(keyword) {
|
|
@@ -20572,7 +21219,7 @@ var require_core$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
20572
21219
|
const KEYWORD_NAME = /^[a-z_$][a-z0-9_$:-]*$/i;
|
|
20573
21220
|
function checkKeyword(keyword, def$30) {
|
|
20574
21221
|
const { RULES } = this;
|
|
20575
|
-
(0, util_1$
|
|
21222
|
+
(0, util_1$22.eachItem)(keyword, (kwd) => {
|
|
20576
21223
|
if (RULES.keywords[kwd]) throw new Error(`Keyword ${kwd} is already defined`);
|
|
20577
21224
|
if (!KEYWORD_NAME.test(kwd)) throw new Error(`Keyword ${kwd} has invalid name`);
|
|
20578
21225
|
});
|
|
@@ -20628,7 +21275,7 @@ var require_core$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
20628
21275
|
}));
|
|
20629
21276
|
|
|
20630
21277
|
//#endregion
|
|
20631
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
21278
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/core/id.js
|
|
20632
21279
|
var require_id = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
20633
21280
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20634
21281
|
const def$29 = {
|
|
@@ -20641,7 +21288,7 @@ var require_id = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
20641
21288
|
}));
|
|
20642
21289
|
|
|
20643
21290
|
//#endregion
|
|
20644
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
21291
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/core/ref.js
|
|
20645
21292
|
var require_ref = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
20646
21293
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20647
21294
|
exports.callRef = exports.getValidate = void 0;
|
|
@@ -20650,7 +21297,7 @@ var require_ref = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
20650
21297
|
const codegen_1$25 = require_codegen();
|
|
20651
21298
|
const names_1$1 = require_names();
|
|
20652
21299
|
const compile_1$1 = require_compile();
|
|
20653
|
-
const util_1$
|
|
21300
|
+
const util_1$21 = require_util();
|
|
20654
21301
|
const def$28 = {
|
|
20655
21302
|
keyword: "$ref",
|
|
20656
21303
|
schemaType: "string",
|
|
@@ -20727,16 +21374,16 @@ var require_ref = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
20727
21374
|
if (!it.opts.unevaluated) return;
|
|
20728
21375
|
const schEvaluated = (_a = sch === null || sch === void 0 ? void 0 : sch.validate) === null || _a === void 0 ? void 0 : _a.evaluated;
|
|
20729
21376
|
if (it.props !== true) if (schEvaluated && !schEvaluated.dynamicProps) {
|
|
20730
|
-
if (schEvaluated.props !== void 0) it.props = util_1$
|
|
21377
|
+
if (schEvaluated.props !== void 0) it.props = util_1$21.mergeEvaluated.props(gen, schEvaluated.props, it.props);
|
|
20731
21378
|
} else {
|
|
20732
21379
|
const props = gen.var("props", (0, codegen_1$25._)`${source}.evaluated.props`);
|
|
20733
|
-
it.props = util_1$
|
|
21380
|
+
it.props = util_1$21.mergeEvaluated.props(gen, props, it.props, codegen_1$25.Name);
|
|
20734
21381
|
}
|
|
20735
21382
|
if (it.items !== true) if (schEvaluated && !schEvaluated.dynamicItems) {
|
|
20736
|
-
if (schEvaluated.items !== void 0) it.items = util_1$
|
|
21383
|
+
if (schEvaluated.items !== void 0) it.items = util_1$21.mergeEvaluated.items(gen, schEvaluated.items, it.items);
|
|
20737
21384
|
} else {
|
|
20738
21385
|
const items = gen.var("items", (0, codegen_1$25._)`${source}.evaluated.items`);
|
|
20739
|
-
it.items = util_1$
|
|
21386
|
+
it.items = util_1$21.mergeEvaluated.items(gen, items, it.items, codegen_1$25.Name);
|
|
20740
21387
|
}
|
|
20741
21388
|
}
|
|
20742
21389
|
}
|
|
@@ -20745,7 +21392,7 @@ var require_ref = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
20745
21392
|
}));
|
|
20746
21393
|
|
|
20747
21394
|
//#endregion
|
|
20748
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
21395
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/core/index.js
|
|
20749
21396
|
var require_core = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
20750
21397
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20751
21398
|
const id_1 = require_id();
|
|
@@ -20764,7 +21411,7 @@ var require_core = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
20764
21411
|
}));
|
|
20765
21412
|
|
|
20766
21413
|
//#endregion
|
|
20767
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
21414
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/limitNumber.js
|
|
20768
21415
|
var require_limitNumber = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
20769
21416
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20770
21417
|
const codegen_1$24 = require_codegen();
|
|
@@ -20809,7 +21456,7 @@ var require_limitNumber = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
20809
21456
|
}));
|
|
20810
21457
|
|
|
20811
21458
|
//#endregion
|
|
20812
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
21459
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/multipleOf.js
|
|
20813
21460
|
var require_multipleOf = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
20814
21461
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20815
21462
|
const codegen_1$23 = require_codegen();
|
|
@@ -20834,7 +21481,7 @@ var require_multipleOf = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
20834
21481
|
}));
|
|
20835
21482
|
|
|
20836
21483
|
//#endregion
|
|
20837
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
21484
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/runtime/ucs2length.js
|
|
20838
21485
|
var require_ucs2length = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
20839
21486
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20840
21487
|
function ucs2length(str$1) {
|
|
@@ -20857,11 +21504,11 @@ var require_ucs2length = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
20857
21504
|
}));
|
|
20858
21505
|
|
|
20859
21506
|
//#endregion
|
|
20860
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
21507
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/limitLength.js
|
|
20861
21508
|
var require_limitLength = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
20862
21509
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20863
21510
|
const codegen_1$22 = require_codegen();
|
|
20864
|
-
const util_1$
|
|
21511
|
+
const util_1$20 = require_util();
|
|
20865
21512
|
const ucs2length_1 = require_ucs2length();
|
|
20866
21513
|
const def$25 = {
|
|
20867
21514
|
keyword: ["maxLength", "minLength"],
|
|
@@ -20878,7 +21525,7 @@ var require_limitLength = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
20878
21525
|
code(cxt) {
|
|
20879
21526
|
const { keyword, data, schemaCode, it } = cxt;
|
|
20880
21527
|
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$
|
|
21528
|
+
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
21529
|
cxt.fail$data((0, codegen_1$22._)`${len} ${op} ${schemaCode}`);
|
|
20883
21530
|
}
|
|
20884
21531
|
};
|
|
@@ -20886,10 +21533,11 @@ var require_limitLength = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
20886
21533
|
}));
|
|
20887
21534
|
|
|
20888
21535
|
//#endregion
|
|
20889
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
21536
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/pattern.js
|
|
20890
21537
|
var require_pattern = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
20891
21538
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20892
21539
|
const code_1$7 = require_code();
|
|
21540
|
+
const util_1$19 = require_util();
|
|
20893
21541
|
const codegen_1$21 = require_codegen();
|
|
20894
21542
|
const def$24 = {
|
|
20895
21543
|
keyword: "pattern",
|
|
@@ -20901,17 +21549,25 @@ var require_pattern = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
20901
21549
|
params: ({ schemaCode }) => (0, codegen_1$21._)`{pattern: ${schemaCode}}`
|
|
20902
21550
|
},
|
|
20903
21551
|
code(cxt) {
|
|
20904
|
-
const { data, $data, schema, schemaCode, it } = cxt;
|
|
21552
|
+
const { gen, data, $data, schema, schemaCode, it } = cxt;
|
|
20905
21553
|
const u = it.opts.unicodeRegExp ? "u" : "";
|
|
20906
|
-
|
|
20907
|
-
|
|
21554
|
+
if ($data) {
|
|
21555
|
+
const { regExp } = it.opts.code;
|
|
21556
|
+
const regExpCode = regExp.code === "new RegExp" ? (0, codegen_1$21._)`new RegExp` : (0, util_1$19.useFunc)(gen, regExp);
|
|
21557
|
+
const valid = gen.let("valid");
|
|
21558
|
+
gen.try(() => gen.assign(valid, (0, codegen_1$21._)`${regExpCode}(${schemaCode}, ${u}).test(${data})`), () => gen.assign(valid, false));
|
|
21559
|
+
cxt.fail$data((0, codegen_1$21._)`!${valid}`);
|
|
21560
|
+
} else {
|
|
21561
|
+
const regExp = (0, code_1$7.usePattern)(cxt, schema);
|
|
21562
|
+
cxt.fail$data((0, codegen_1$21._)`!${regExp}.test(${data})`);
|
|
21563
|
+
}
|
|
20908
21564
|
}
|
|
20909
21565
|
};
|
|
20910
21566
|
exports.default = def$24;
|
|
20911
21567
|
}));
|
|
20912
21568
|
|
|
20913
21569
|
//#endregion
|
|
20914
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
21570
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/limitProperties.js
|
|
20915
21571
|
var require_limitProperties = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
20916
21572
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20917
21573
|
const codegen_1$20 = require_codegen();
|
|
@@ -20937,7 +21593,7 @@ var require_limitProperties = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
20937
21593
|
}));
|
|
20938
21594
|
|
|
20939
21595
|
//#endregion
|
|
20940
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
21596
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/required.js
|
|
20941
21597
|
var require_required = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
20942
21598
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20943
21599
|
const code_1$6 = require_code();
|
|
@@ -21005,7 +21661,7 @@ var require_required = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
21005
21661
|
}));
|
|
21006
21662
|
|
|
21007
21663
|
//#endregion
|
|
21008
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
21664
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/limitItems.js
|
|
21009
21665
|
var require_limitItems = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
21010
21666
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21011
21667
|
const codegen_1$18 = require_codegen();
|
|
@@ -21031,7 +21687,7 @@ var require_limitItems = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
21031
21687
|
}));
|
|
21032
21688
|
|
|
21033
21689
|
//#endregion
|
|
21034
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
21690
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/runtime/equal.js
|
|
21035
21691
|
var require_equal = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
21036
21692
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21037
21693
|
const equal = require_fast_deep_equal();
|
|
@@ -21040,7 +21696,7 @@ var require_equal = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
21040
21696
|
}));
|
|
21041
21697
|
|
|
21042
21698
|
//#endregion
|
|
21043
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
21699
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/uniqueItems.js
|
|
21044
21700
|
var require_uniqueItems = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
21045
21701
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21046
21702
|
const dataType_1 = require_dataType();
|
|
@@ -21105,7 +21761,7 @@ var require_uniqueItems = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
21105
21761
|
}));
|
|
21106
21762
|
|
|
21107
21763
|
//#endregion
|
|
21108
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
21764
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/const.js
|
|
21109
21765
|
var require_const = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
21110
21766
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21111
21767
|
const codegen_1$16 = require_codegen();
|
|
@@ -21128,7 +21784,7 @@ var require_const = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
21128
21784
|
}));
|
|
21129
21785
|
|
|
21130
21786
|
//#endregion
|
|
21131
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
21787
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/enum.js
|
|
21132
21788
|
var require_enum = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
21133
21789
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21134
21790
|
const codegen_1$15 = require_codegen();
|
|
@@ -21173,7 +21829,7 @@ var require_enum = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
21173
21829
|
}));
|
|
21174
21830
|
|
|
21175
21831
|
//#endregion
|
|
21176
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
21832
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/validation/index.js
|
|
21177
21833
|
var require_validation = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
21178
21834
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21179
21835
|
const limitNumber_1 = require_limitNumber();
|
|
@@ -21210,7 +21866,7 @@ var require_validation = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
21210
21866
|
}));
|
|
21211
21867
|
|
|
21212
21868
|
//#endregion
|
|
21213
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
21869
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/additionalItems.js
|
|
21214
21870
|
var require_additionalItems = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
21215
21871
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21216
21872
|
exports.validateAdditionalItems = void 0;
|
|
@@ -21263,7 +21919,7 @@ var require_additionalItems = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
21263
21919
|
}));
|
|
21264
21920
|
|
|
21265
21921
|
//#endregion
|
|
21266
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
21922
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/items.js
|
|
21267
21923
|
var require_items = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
21268
21924
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21269
21925
|
exports.validateTuple = void 0;
|
|
@@ -21317,7 +21973,7 @@ var require_items = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
21317
21973
|
}));
|
|
21318
21974
|
|
|
21319
21975
|
//#endregion
|
|
21320
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
21976
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/prefixItems.js
|
|
21321
21977
|
var require_prefixItems = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
21322
21978
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21323
21979
|
const items_1$1 = require_items();
|
|
@@ -21332,7 +21988,7 @@ var require_prefixItems = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
21332
21988
|
}));
|
|
21333
21989
|
|
|
21334
21990
|
//#endregion
|
|
21335
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
21991
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/items2020.js
|
|
21336
21992
|
var require_items2020 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
21337
21993
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21338
21994
|
const codegen_1$12 = require_codegen();
|
|
@@ -21361,7 +22017,7 @@ var require_items2020 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
21361
22017
|
}));
|
|
21362
22018
|
|
|
21363
22019
|
//#endregion
|
|
21364
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
22020
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/contains.js
|
|
21365
22021
|
var require_contains = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
21366
22022
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21367
22023
|
const codegen_1$11 = require_codegen();
|
|
@@ -21447,7 +22103,7 @@ var require_contains = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
21447
22103
|
}));
|
|
21448
22104
|
|
|
21449
22105
|
//#endregion
|
|
21450
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
22106
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/dependencies.js
|
|
21451
22107
|
var require_dependencies = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
21452
22108
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21453
22109
|
exports.validateSchemaDeps = exports.validatePropertyDeps = exports.error = void 0;
|
|
@@ -21529,7 +22185,7 @@ var require_dependencies = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
21529
22185
|
}));
|
|
21530
22186
|
|
|
21531
22187
|
//#endregion
|
|
21532
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
22188
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/propertyNames.js
|
|
21533
22189
|
var require_propertyNames = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
21534
22190
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21535
22191
|
const codegen_1$9 = require_codegen();
|
|
@@ -21567,7 +22223,7 @@ var require_propertyNames = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
21567
22223
|
}));
|
|
21568
22224
|
|
|
21569
22225
|
//#endregion
|
|
21570
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
22226
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js
|
|
21571
22227
|
var require_additionalProperties = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
21572
22228
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21573
22229
|
const code_1$2 = require_code();
|
|
@@ -21658,7 +22314,7 @@ var require_additionalProperties = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
21658
22314
|
}));
|
|
21659
22315
|
|
|
21660
22316
|
//#endregion
|
|
21661
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
22317
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/properties.js
|
|
21662
22318
|
var require_properties = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
21663
22319
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21664
22320
|
const validate_1$1 = require_validate();
|
|
@@ -21705,7 +22361,7 @@ var require_properties = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
21705
22361
|
}));
|
|
21706
22362
|
|
|
21707
22363
|
//#endregion
|
|
21708
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
22364
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/patternProperties.js
|
|
21709
22365
|
var require_patternProperties = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
21710
22366
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21711
22367
|
const code_1 = require_code();
|
|
@@ -21762,7 +22418,7 @@ var require_patternProperties = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
21762
22418
|
}));
|
|
21763
22419
|
|
|
21764
22420
|
//#endregion
|
|
21765
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
22421
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/not.js
|
|
21766
22422
|
var require_not = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
21767
22423
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21768
22424
|
const util_1$5 = require_util();
|
|
@@ -21791,7 +22447,7 @@ var require_not = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
21791
22447
|
}));
|
|
21792
22448
|
|
|
21793
22449
|
//#endregion
|
|
21794
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
22450
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/anyOf.js
|
|
21795
22451
|
var require_anyOf = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
21796
22452
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21797
22453
|
const def$6 = {
|
|
@@ -21805,7 +22461,7 @@ var require_anyOf = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
21805
22461
|
}));
|
|
21806
22462
|
|
|
21807
22463
|
//#endregion
|
|
21808
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
22464
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/oneOf.js
|
|
21809
22465
|
var require_oneOf = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
21810
22466
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21811
22467
|
const codegen_1$6 = require_codegen();
|
|
@@ -21853,7 +22509,7 @@ var require_oneOf = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
21853
22509
|
}));
|
|
21854
22510
|
|
|
21855
22511
|
//#endregion
|
|
21856
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
22512
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/allOf.js
|
|
21857
22513
|
var require_allOf = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
21858
22514
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21859
22515
|
const util_1$3 = require_util();
|
|
@@ -21880,7 +22536,7 @@ var require_allOf = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
21880
22536
|
}));
|
|
21881
22537
|
|
|
21882
22538
|
//#endregion
|
|
21883
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
22539
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/if.js
|
|
21884
22540
|
var require_if = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
21885
22541
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21886
22542
|
const codegen_1$5 = require_codegen();
|
|
@@ -21938,7 +22594,7 @@ var require_if = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
21938
22594
|
}));
|
|
21939
22595
|
|
|
21940
22596
|
//#endregion
|
|
21941
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
22597
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/thenElse.js
|
|
21942
22598
|
var require_thenElse = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
21943
22599
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21944
22600
|
const util_1$1 = require_util();
|
|
@@ -21953,7 +22609,7 @@ var require_thenElse = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
21953
22609
|
}));
|
|
21954
22610
|
|
|
21955
22611
|
//#endregion
|
|
21956
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
22612
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/applicator/index.js
|
|
21957
22613
|
var require_applicator = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
21958
22614
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21959
22615
|
const additionalItems_1 = require_additionalItems();
|
|
@@ -21995,7 +22651,7 @@ var require_applicator = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
21995
22651
|
}));
|
|
21996
22652
|
|
|
21997
22653
|
//#endregion
|
|
21998
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
22654
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/format/format.js
|
|
21999
22655
|
var require_format$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
22000
22656
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22001
22657
|
const codegen_1$4 = require_codegen();
|
|
@@ -22085,7 +22741,7 @@ var require_format$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
22085
22741
|
}));
|
|
22086
22742
|
|
|
22087
22743
|
//#endregion
|
|
22088
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
22744
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/format/index.js
|
|
22089
22745
|
var require_format = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
22090
22746
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22091
22747
|
const format = [require_format$1().default];
|
|
@@ -22093,7 +22749,7 @@ var require_format = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
22093
22749
|
}));
|
|
22094
22750
|
|
|
22095
22751
|
//#endregion
|
|
22096
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
22752
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/metadata.js
|
|
22097
22753
|
var require_metadata = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
22098
22754
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22099
22755
|
exports.contentVocabulary = exports.metadataVocabulary = void 0;
|
|
@@ -22114,7 +22770,7 @@ var require_metadata = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
22114
22770
|
}));
|
|
22115
22771
|
|
|
22116
22772
|
//#endregion
|
|
22117
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
22773
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/draft7.js
|
|
22118
22774
|
var require_draft7 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
22119
22775
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22120
22776
|
const core_1$1 = require_core();
|
|
@@ -22134,7 +22790,7 @@ var require_draft7 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
22134
22790
|
}));
|
|
22135
22791
|
|
|
22136
22792
|
//#endregion
|
|
22137
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
22793
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/discriminator/types.js
|
|
22138
22794
|
var require_types = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
22139
22795
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22140
22796
|
exports.DiscrError = void 0;
|
|
@@ -22146,7 +22802,7 @@ var require_types = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
22146
22802
|
}));
|
|
22147
22803
|
|
|
22148
22804
|
//#endregion
|
|
22149
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
22805
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/vocabularies/discriminator/index.js
|
|
22150
22806
|
var require_discriminator = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
22151
22807
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22152
22808
|
const codegen_1$3 = require_codegen();
|
|
@@ -22241,7 +22897,7 @@ var require_discriminator = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
22241
22897
|
}));
|
|
22242
22898
|
|
|
22243
22899
|
//#endregion
|
|
22244
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
22900
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/refs/json-schema-draft-07.json
|
|
22245
22901
|
var require_json_schema_draft_07 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
22246
22902
|
module.exports = {
|
|
22247
22903
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
@@ -22380,7 +23036,7 @@ var require_json_schema_draft_07 = /* @__PURE__ */ __commonJSMin(((exports, modu
|
|
|
22380
23036
|
}));
|
|
22381
23037
|
|
|
22382
23038
|
//#endregion
|
|
22383
|
-
//#region node_modules/.pnpm/ajv@8.
|
|
23039
|
+
//#region node_modules/.pnpm/ajv@8.18.0/node_modules/ajv/dist/ajv.js
|
|
22384
23040
|
var require_ajv = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
22385
23041
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22386
23042
|
exports.MissingRefError = exports.ValidationError = exports.CodeGen = exports.Name = exports.nil = exports.stringify = exports.str = exports._ = exports.KeywordCxt = exports.Ajv = void 0;
|
|
@@ -22473,7 +23129,7 @@ var require_ajv = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
22473
23129
|
}));
|
|
22474
23130
|
|
|
22475
23131
|
//#endregion
|
|
22476
|
-
//#region node_modules/.pnpm/ajv-formats@3.0.1_ajv@8.
|
|
23132
|
+
//#region node_modules/.pnpm/ajv-formats@3.0.1_ajv@8.18.0/node_modules/ajv-formats/dist/formats.js
|
|
22477
23133
|
var require_formats = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
22478
23134
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22479
23135
|
exports.formatNames = exports.fastFormats = exports.fullFormats = void 0;
|
|
@@ -22662,7 +23318,7 @@ var require_formats = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
22662
23318
|
}));
|
|
22663
23319
|
|
|
22664
23320
|
//#endregion
|
|
22665
|
-
//#region node_modules/.pnpm/ajv-formats@3.0.1_ajv@8.
|
|
23321
|
+
//#region node_modules/.pnpm/ajv-formats@3.0.1_ajv@8.18.0/node_modules/ajv-formats/dist/limit.js
|
|
22666
23322
|
var require_limit = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
22667
23323
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22668
23324
|
exports.formatLimitDefinition = void 0;
|
|
@@ -22742,7 +23398,7 @@ var require_limit = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
22742
23398
|
}));
|
|
22743
23399
|
|
|
22744
23400
|
//#endregion
|
|
22745
|
-
//#region node_modules/.pnpm/ajv-formats@3.0.1_ajv@8.
|
|
23401
|
+
//#region node_modules/.pnpm/ajv-formats@3.0.1_ajv@8.18.0/node_modules/ajv-formats/dist/index.js
|
|
22746
23402
|
var require_dist = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
22747
23403
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22748
23404
|
const formats_1 = require_formats();
|
|
@@ -22777,11 +23433,11 @@ var require_dist = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
22777
23433
|
}));
|
|
22778
23434
|
|
|
22779
23435
|
//#endregion
|
|
22780
|
-
//#region node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
22781
|
-
var import_ajv = require_ajv();
|
|
23436
|
+
//#region node_modules/.pnpm/@modelcontextprotocol+sdk@1.27.1_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/validation/ajv-provider.js
|
|
23437
|
+
var import_ajv = /* @__PURE__ */ __toESM(require_ajv(), 1);
|
|
22782
23438
|
var import_dist = /* @__PURE__ */ __toESM(require_dist(), 1);
|
|
22783
23439
|
function createDefaultAjvInstance() {
|
|
22784
|
-
const ajv = new import_ajv.
|
|
23440
|
+
const ajv = new import_ajv.default({
|
|
22785
23441
|
strict: false,
|
|
22786
23442
|
validateFormats: true,
|
|
22787
23443
|
validateSchema: false,
|
|
@@ -22825,7 +23481,7 @@ var AjvJsonSchemaValidator = class {
|
|
|
22825
23481
|
* ```
|
|
22826
23482
|
*/
|
|
22827
23483
|
constructor(ajv) {
|
|
22828
|
-
this._ajv = ajv
|
|
23484
|
+
this._ajv = ajv ?? createDefaultAjvInstance();
|
|
22829
23485
|
}
|
|
22830
23486
|
/**
|
|
22831
23487
|
* Create a validator for the given JSON Schema
|
|
@@ -22837,8 +23493,7 @@ var AjvJsonSchemaValidator = class {
|
|
|
22837
23493
|
* @returns A validator function that validates input data
|
|
22838
23494
|
*/
|
|
22839
23495
|
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);
|
|
23496
|
+
const ajvValidator = "$id" in schema && typeof schema.$id === "string" ? this._ajv.getSchema(schema.$id) ?? this._ajv.compile(schema) : this._ajv.compile(schema);
|
|
22842
23497
|
return (input) => {
|
|
22843
23498
|
if (ajvValidator(input)) return {
|
|
22844
23499
|
valid: true,
|
|
@@ -22855,7 +23510,7 @@ var AjvJsonSchemaValidator = class {
|
|
|
22855
23510
|
};
|
|
22856
23511
|
|
|
22857
23512
|
//#endregion
|
|
22858
|
-
//#region node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
23513
|
+
//#region node_modules/.pnpm/@modelcontextprotocol+sdk@1.27.1_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/client.js
|
|
22859
23514
|
/**
|
|
22860
23515
|
* Experimental client task features for MCP SDK.
|
|
22861
23516
|
* WARNING: These APIs are experimental and may change without notice.
|
|
@@ -22914,11 +23569,10 @@ var ExperimentalClientTasks = class {
|
|
|
22914
23569
|
* @experimental
|
|
22915
23570
|
*/
|
|
22916
23571
|
async *callToolStream(params, resultSchema = CallToolResultSchema, options) {
|
|
22917
|
-
var _a;
|
|
22918
23572
|
const clientInternal = this._client;
|
|
22919
23573
|
const optionsWithTask = {
|
|
22920
23574
|
...options,
|
|
22921
|
-
task:
|
|
23575
|
+
task: options?.task ?? (clientInternal.isToolTask(params.name) ? {} : void 0)
|
|
22922
23576
|
};
|
|
22923
23577
|
const stream = clientInternal.requestStream({
|
|
22924
23578
|
method: "tools/call",
|
|
@@ -23030,7 +23684,7 @@ var ExperimentalClientTasks = class {
|
|
|
23030
23684
|
};
|
|
23031
23685
|
|
|
23032
23686
|
//#endregion
|
|
23033
|
-
//#region node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
23687
|
+
//#region node_modules/.pnpm/@modelcontextprotocol+sdk@1.27.1_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/helpers.js
|
|
23034
23688
|
/**
|
|
23035
23689
|
* Experimental task capability assertion helpers.
|
|
23036
23690
|
* WARNING: These APIs are experimental and may change without notice.
|
|
@@ -23049,11 +23703,10 @@ var ExperimentalClientTasks = class {
|
|
|
23049
23703
|
* @experimental
|
|
23050
23704
|
*/
|
|
23051
23705
|
function assertToolsCallTaskCapability(requests, method, entityName) {
|
|
23052
|
-
var _a;
|
|
23053
23706
|
if (!requests) throw new Error(`${entityName} does not support task creation (required for ${method})`);
|
|
23054
23707
|
switch (method) {
|
|
23055
23708
|
case "tools/call":
|
|
23056
|
-
if (!
|
|
23709
|
+
if (!requests.tools?.call) throw new Error(`${entityName} does not support task creation for tools/call (required for ${method})`);
|
|
23057
23710
|
break;
|
|
23058
23711
|
default: break;
|
|
23059
23712
|
}
|
|
@@ -23070,21 +23723,20 @@ function assertToolsCallTaskCapability(requests, method, entityName) {
|
|
|
23070
23723
|
* @experimental
|
|
23071
23724
|
*/
|
|
23072
23725
|
function assertClientRequestTaskCapability(requests, method, entityName) {
|
|
23073
|
-
var _a, _b;
|
|
23074
23726
|
if (!requests) throw new Error(`${entityName} does not support task creation (required for ${method})`);
|
|
23075
23727
|
switch (method) {
|
|
23076
23728
|
case "sampling/createMessage":
|
|
23077
|
-
if (!
|
|
23729
|
+
if (!requests.sampling?.createMessage) throw new Error(`${entityName} does not support task creation for sampling/createMessage (required for ${method})`);
|
|
23078
23730
|
break;
|
|
23079
23731
|
case "elicitation/create":
|
|
23080
|
-
if (!
|
|
23732
|
+
if (!requests.elicitation?.create) throw new Error(`${entityName} does not support task creation for elicitation/create (required for ${method})`);
|
|
23081
23733
|
break;
|
|
23082
23734
|
default: break;
|
|
23083
23735
|
}
|
|
23084
23736
|
}
|
|
23085
23737
|
|
|
23086
23738
|
//#endregion
|
|
23087
|
-
//#region node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
23739
|
+
//#region node_modules/.pnpm/@modelcontextprotocol+sdk@1.27.1_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/client/index.js
|
|
23088
23740
|
/**
|
|
23089
23741
|
* Elicitation default application helper. Applies defaults to the data based on the schema.
|
|
23090
23742
|
*
|
|
@@ -23102,8 +23754,12 @@ function applyElicitationDefaults(schema, data) {
|
|
|
23102
23754
|
if (obj[key$1] !== void 0) applyElicitationDefaults(propSchema, obj[key$1]);
|
|
23103
23755
|
}
|
|
23104
23756
|
}
|
|
23105
|
-
if (Array.isArray(schema.anyOf))
|
|
23106
|
-
|
|
23757
|
+
if (Array.isArray(schema.anyOf)) {
|
|
23758
|
+
for (const sub of schema.anyOf) if (typeof sub !== "boolean") applyElicitationDefaults(sub, data);
|
|
23759
|
+
}
|
|
23760
|
+
if (Array.isArray(schema.oneOf)) {
|
|
23761
|
+
for (const sub of schema.oneOf) if (typeof sub !== "boolean") applyElicitationDefaults(sub, data);
|
|
23762
|
+
}
|
|
23107
23763
|
}
|
|
23108
23764
|
/**
|
|
23109
23765
|
* Determines which elicitation modes are supported based on declared client capabilities.
|
|
@@ -23157,14 +23813,32 @@ var Client = class extends Protocol {
|
|
|
23157
23813
|
* Initializes this client with the given name and version information.
|
|
23158
23814
|
*/
|
|
23159
23815
|
constructor(_clientInfo, options) {
|
|
23160
|
-
var _a, _b;
|
|
23161
23816
|
super(options);
|
|
23162
23817
|
this._clientInfo = _clientInfo;
|
|
23163
23818
|
this._cachedToolOutputValidators = /* @__PURE__ */ new Map();
|
|
23164
23819
|
this._cachedKnownTaskTools = /* @__PURE__ */ new Set();
|
|
23165
23820
|
this._cachedRequiredTaskTools = /* @__PURE__ */ new Set();
|
|
23166
|
-
this.
|
|
23167
|
-
this.
|
|
23821
|
+
this._listChangedDebounceTimers = /* @__PURE__ */ new Map();
|
|
23822
|
+
this._capabilities = options?.capabilities ?? {};
|
|
23823
|
+
this._jsonSchemaValidator = options?.jsonSchemaValidator ?? new AjvJsonSchemaValidator();
|
|
23824
|
+
if (options?.listChanged) this._pendingListChangedConfig = options.listChanged;
|
|
23825
|
+
}
|
|
23826
|
+
/**
|
|
23827
|
+
* Set up handlers for list changed notifications based on config and server capabilities.
|
|
23828
|
+
* This should only be called after initialization when server capabilities are known.
|
|
23829
|
+
* Handlers are silently skipped if the server doesn't advertise the corresponding listChanged capability.
|
|
23830
|
+
* @internal
|
|
23831
|
+
*/
|
|
23832
|
+
_setupListChangedHandlers(config$1) {
|
|
23833
|
+
if (config$1.tools && this._serverCapabilities?.tools?.listChanged) this._setupListChangedHandler("tools", ToolListChangedNotificationSchema, config$1.tools, async () => {
|
|
23834
|
+
return (await this.listTools()).tools;
|
|
23835
|
+
});
|
|
23836
|
+
if (config$1.prompts && this._serverCapabilities?.prompts?.listChanged) this._setupListChangedHandler("prompts", PromptListChangedNotificationSchema, config$1.prompts, async () => {
|
|
23837
|
+
return (await this.listPrompts()).prompts;
|
|
23838
|
+
});
|
|
23839
|
+
if (config$1.resources && this._serverCapabilities?.resources?.listChanged) this._setupListChangedHandler("resources", ResourceListChangedNotificationSchema, config$1.resources, async () => {
|
|
23840
|
+
return (await this.listResources()).resources;
|
|
23841
|
+
});
|
|
23168
23842
|
}
|
|
23169
23843
|
/**
|
|
23170
23844
|
* Access experimental features.
|
|
@@ -23190,35 +23864,30 @@ var Client = class extends Protocol {
|
|
|
23190
23864
|
* Override request handler registration to enforce client-side validation for elicitation.
|
|
23191
23865
|
*/
|
|
23192
23866
|
setRequestHandler(requestSchema, handler) {
|
|
23193
|
-
|
|
23194
|
-
const shape = getObjectShape(requestSchema);
|
|
23195
|
-
const methodSchema = shape === null || shape === void 0 ? void 0 : shape.method;
|
|
23867
|
+
const methodSchema = getObjectShape(requestSchema)?.method;
|
|
23196
23868
|
if (!methodSchema) throw new Error("Schema is missing a method literal");
|
|
23197
23869
|
let methodValue;
|
|
23198
23870
|
if (isZ4Schema(methodSchema)) {
|
|
23199
23871
|
const v4Schema = methodSchema;
|
|
23200
|
-
|
|
23201
|
-
methodValue = (_b = v4Def === null || v4Def === void 0 ? void 0 : v4Def.value) !== null && _b !== void 0 ? _b : v4Schema.value;
|
|
23872
|
+
methodValue = (v4Schema._zod?.def)?.value ?? v4Schema.value;
|
|
23202
23873
|
} else {
|
|
23203
23874
|
const v3Schema = methodSchema;
|
|
23204
|
-
|
|
23205
|
-
methodValue = (_c = legacyDef === null || legacyDef === void 0 ? void 0 : legacyDef.value) !== null && _c !== void 0 ? _c : v3Schema.value;
|
|
23875
|
+
methodValue = v3Schema._def?.value ?? v3Schema.value;
|
|
23206
23876
|
}
|
|
23207
23877
|
if (typeof methodValue !== "string") throw new Error("Schema method literal must be a string");
|
|
23208
23878
|
const method = methodValue;
|
|
23209
23879
|
if (method === "elicitation/create") {
|
|
23210
23880
|
const wrappedHandler = async (request, extra) => {
|
|
23211
|
-
var _a$1, _b$1, _c$1;
|
|
23212
23881
|
const validatedRequest = safeParse(ElicitRequestSchema, request);
|
|
23213
23882
|
if (!validatedRequest.success) {
|
|
23214
23883
|
const errorMessage = validatedRequest.error instanceof Error ? validatedRequest.error.message : String(validatedRequest.error);
|
|
23215
23884
|
throw new McpError(ErrorCode.InvalidParams, `Invalid elicitation request: ${errorMessage}`);
|
|
23216
23885
|
}
|
|
23217
23886
|
const { params } = validatedRequest.data;
|
|
23218
|
-
|
|
23887
|
+
params.mode = params.mode ?? "form";
|
|
23219
23888
|
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");
|
|
23889
|
+
if (params.mode === "form" && !supportsFormMode) throw new McpError(ErrorCode.InvalidParams, "Client does not support form-mode elicitation requests");
|
|
23890
|
+
if (params.mode === "url" && !supportsUrlMode) throw new McpError(ErrorCode.InvalidParams, "Client does not support URL-mode elicitation requests");
|
|
23222
23891
|
const result = await Promise.resolve(handler(request, extra));
|
|
23223
23892
|
if (params.task) {
|
|
23224
23893
|
const taskValidationResult = safeParse(CreateTaskResultSchema, result);
|
|
@@ -23234,11 +23903,11 @@ var Client = class extends Protocol {
|
|
|
23234
23903
|
throw new McpError(ErrorCode.InvalidParams, `Invalid elicitation result: ${errorMessage}`);
|
|
23235
23904
|
}
|
|
23236
23905
|
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 (
|
|
23906
|
+
const requestedSchema = params.mode === "form" ? params.requestedSchema : void 0;
|
|
23907
|
+
if (params.mode === "form" && validatedResult.action === "accept" && validatedResult.content && requestedSchema) {
|
|
23908
|
+
if (this._capabilities.elicitation?.form?.applyDefaults) try {
|
|
23240
23909
|
applyElicitationDefaults(requestedSchema, validatedResult.content);
|
|
23241
|
-
} catch
|
|
23910
|
+
} catch {}
|
|
23242
23911
|
}
|
|
23243
23912
|
return validatedResult;
|
|
23244
23913
|
};
|
|
@@ -23261,7 +23930,7 @@ var Client = class extends Protocol {
|
|
|
23261
23930
|
}
|
|
23262
23931
|
return taskValidationResult.data;
|
|
23263
23932
|
}
|
|
23264
|
-
const validationResult = safeParse(CreateMessageResultSchema, result);
|
|
23933
|
+
const validationResult = safeParse(params.tools || params.toolChoice ? CreateMessageResultWithToolsSchema : CreateMessageResultSchema, result);
|
|
23265
23934
|
if (!validationResult.success) {
|
|
23266
23935
|
const errorMessage = validationResult.error instanceof Error ? validationResult.error.message : String(validationResult.error);
|
|
23267
23936
|
throw new McpError(ErrorCode.InvalidParams, `Invalid sampling result: ${errorMessage}`);
|
|
@@ -23273,8 +23942,7 @@ var Client = class extends Protocol {
|
|
|
23273
23942
|
return super.setRequestHandler(requestSchema, handler);
|
|
23274
23943
|
}
|
|
23275
23944
|
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})`);
|
|
23945
|
+
if (!this._serverCapabilities?.[capability]) throw new Error(`Server does not support ${capability} (required for ${method})`);
|
|
23278
23946
|
}
|
|
23279
23947
|
async connect(transport, options) {
|
|
23280
23948
|
await super.connect(transport);
|
|
@@ -23295,6 +23963,10 @@ var Client = class extends Protocol {
|
|
|
23295
23963
|
if (transport.setProtocolVersion) transport.setProtocolVersion(result.protocolVersion);
|
|
23296
23964
|
this._instructions = result.instructions;
|
|
23297
23965
|
await this.notification({ method: "notifications/initialized" });
|
|
23966
|
+
if (this._pendingListChangedConfig) {
|
|
23967
|
+
this._setupListChangedHandlers(this._pendingListChangedConfig);
|
|
23968
|
+
this._pendingListChangedConfig = void 0;
|
|
23969
|
+
}
|
|
23298
23970
|
} catch (error$1) {
|
|
23299
23971
|
this.close();
|
|
23300
23972
|
throw error$1;
|
|
@@ -23319,39 +23991,37 @@ var Client = class extends Protocol {
|
|
|
23319
23991
|
return this._instructions;
|
|
23320
23992
|
}
|
|
23321
23993
|
assertCapabilityForMethod(method) {
|
|
23322
|
-
var _a, _b, _c, _d, _e;
|
|
23323
23994
|
switch (method) {
|
|
23324
23995
|
case "logging/setLevel":
|
|
23325
|
-
if (!
|
|
23996
|
+
if (!this._serverCapabilities?.logging) throw new Error(`Server does not support logging (required for ${method})`);
|
|
23326
23997
|
break;
|
|
23327
23998
|
case "prompts/get":
|
|
23328
23999
|
case "prompts/list":
|
|
23329
|
-
if (!
|
|
24000
|
+
if (!this._serverCapabilities?.prompts) throw new Error(`Server does not support prompts (required for ${method})`);
|
|
23330
24001
|
break;
|
|
23331
24002
|
case "resources/list":
|
|
23332
24003
|
case "resources/templates/list":
|
|
23333
24004
|
case "resources/read":
|
|
23334
24005
|
case "resources/subscribe":
|
|
23335
24006
|
case "resources/unsubscribe":
|
|
23336
|
-
if (!
|
|
24007
|
+
if (!this._serverCapabilities?.resources) throw new Error(`Server does not support resources (required for ${method})`);
|
|
23337
24008
|
if (method === "resources/subscribe" && !this._serverCapabilities.resources.subscribe) throw new Error(`Server does not support resource subscriptions (required for ${method})`);
|
|
23338
24009
|
break;
|
|
23339
24010
|
case "tools/call":
|
|
23340
24011
|
case "tools/list":
|
|
23341
|
-
if (!
|
|
24012
|
+
if (!this._serverCapabilities?.tools) throw new Error(`Server does not support tools (required for ${method})`);
|
|
23342
24013
|
break;
|
|
23343
24014
|
case "completion/complete":
|
|
23344
|
-
if (!
|
|
24015
|
+
if (!this._serverCapabilities?.completions) throw new Error(`Server does not support completions (required for ${method})`);
|
|
23345
24016
|
break;
|
|
23346
24017
|
case "initialize": break;
|
|
23347
24018
|
case "ping": break;
|
|
23348
24019
|
}
|
|
23349
24020
|
}
|
|
23350
24021
|
assertNotificationCapability(method) {
|
|
23351
|
-
var _a;
|
|
23352
24022
|
switch (method) {
|
|
23353
24023
|
case "notifications/roots/list_changed":
|
|
23354
|
-
if (!
|
|
24024
|
+
if (!this._capabilities.roots?.listChanged) throw new Error(`Client does not support roots list changed notifications (required for ${method})`);
|
|
23355
24025
|
break;
|
|
23356
24026
|
case "notifications/initialized": break;
|
|
23357
24027
|
case "notifications/cancelled": break;
|
|
@@ -23380,13 +24050,11 @@ var Client = class extends Protocol {
|
|
|
23380
24050
|
}
|
|
23381
24051
|
}
|
|
23382
24052
|
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");
|
|
24053
|
+
assertToolsCallTaskCapability(this._serverCapabilities?.tasks?.requests, method, "Server");
|
|
23385
24054
|
}
|
|
23386
24055
|
assertTaskHandlerCapability(method) {
|
|
23387
|
-
var _a;
|
|
23388
24056
|
if (!this._capabilities) return;
|
|
23389
|
-
assertClientRequestTaskCapability(
|
|
24057
|
+
assertClientRequestTaskCapability(this._capabilities.tasks?.requests, method, "Client");
|
|
23390
24058
|
}
|
|
23391
24059
|
async ping(options) {
|
|
23392
24060
|
return this.request({ method: "ping" }, EmptyResultSchema, options);
|
|
@@ -23470,8 +24138,7 @@ var Client = class extends Protocol {
|
|
|
23470
24138
|
return result;
|
|
23471
24139
|
}
|
|
23472
24140
|
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;
|
|
24141
|
+
if (!this._serverCapabilities?.tasks?.requests?.tools?.call) return false;
|
|
23475
24142
|
return this._cachedKnownTaskTools.has(toolName);
|
|
23476
24143
|
}
|
|
23477
24144
|
/**
|
|
@@ -23486,7 +24153,6 @@ var Client = class extends Protocol {
|
|
|
23486
24153
|
* Called after listTools() to pre-compile validators for better performance.
|
|
23487
24154
|
*/
|
|
23488
24155
|
cacheToolMetadata(tools) {
|
|
23489
|
-
var _a;
|
|
23490
24156
|
this._cachedToolOutputValidators.clear();
|
|
23491
24157
|
this._cachedKnownTaskTools.clear();
|
|
23492
24158
|
this._cachedRequiredTaskTools.clear();
|
|
@@ -23495,7 +24161,7 @@ var Client = class extends Protocol {
|
|
|
23495
24161
|
const toolValidator = this._jsonSchemaValidator.getValidator(tool.outputSchema);
|
|
23496
24162
|
this._cachedToolOutputValidators.set(tool.name, toolValidator);
|
|
23497
24163
|
}
|
|
23498
|
-
const taskSupport =
|
|
24164
|
+
const taskSupport = tool.execution?.taskSupport;
|
|
23499
24165
|
if (taskSupport === "required" || taskSupport === "optional") this._cachedKnownTaskTools.add(tool.name);
|
|
23500
24166
|
if (taskSupport === "required") this._cachedRequiredTaskTools.add(tool.name);
|
|
23501
24167
|
}
|
|
@@ -23514,13 +24180,44 @@ var Client = class extends Protocol {
|
|
|
23514
24180
|
this.cacheToolMetadata(result.tools);
|
|
23515
24181
|
return result;
|
|
23516
24182
|
}
|
|
24183
|
+
/**
|
|
24184
|
+
* Set up a single list changed handler.
|
|
24185
|
+
* @internal
|
|
24186
|
+
*/
|
|
24187
|
+
_setupListChangedHandler(listType, notificationSchema, options, fetcher) {
|
|
24188
|
+
const parseResult = ListChangedOptionsBaseSchema.safeParse(options);
|
|
24189
|
+
if (!parseResult.success) throw new Error(`Invalid ${listType} listChanged options: ${parseResult.error.message}`);
|
|
24190
|
+
if (typeof options.onChanged !== "function") throw new Error(`Invalid ${listType} listChanged options: onChanged must be a function`);
|
|
24191
|
+
const { autoRefresh, debounceMs } = parseResult.data;
|
|
24192
|
+
const { onChanged } = options;
|
|
24193
|
+
const refresh = async () => {
|
|
24194
|
+
if (!autoRefresh) {
|
|
24195
|
+
onChanged(null, null);
|
|
24196
|
+
return;
|
|
24197
|
+
}
|
|
24198
|
+
try {
|
|
24199
|
+
onChanged(null, await fetcher());
|
|
24200
|
+
} catch (e) {
|
|
24201
|
+
onChanged(e instanceof Error ? e : new Error(String(e)), null);
|
|
24202
|
+
}
|
|
24203
|
+
};
|
|
24204
|
+
const handler = () => {
|
|
24205
|
+
if (debounceMs) {
|
|
24206
|
+
const existingTimer = this._listChangedDebounceTimers.get(listType);
|
|
24207
|
+
if (existingTimer) clearTimeout(existingTimer);
|
|
24208
|
+
const timer = setTimeout(refresh, debounceMs);
|
|
24209
|
+
this._listChangedDebounceTimers.set(listType, timer);
|
|
24210
|
+
} else refresh();
|
|
24211
|
+
};
|
|
24212
|
+
this.setNotificationHandler(notificationSchema, handler);
|
|
24213
|
+
}
|
|
23517
24214
|
async sendRootsListChanged() {
|
|
23518
24215
|
return this.notification({ method: "notifications/roots/list_changed" });
|
|
23519
24216
|
}
|
|
23520
24217
|
};
|
|
23521
24218
|
|
|
23522
24219
|
//#endregion
|
|
23523
|
-
//#region node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
24220
|
+
//#region node_modules/.pnpm/@modelcontextprotocol+sdk@1.27.1_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/server.js
|
|
23524
24221
|
/**
|
|
23525
24222
|
* Experimental server task features for MCP SDK.
|
|
23526
24223
|
* WARNING: These APIs are experimental and may change without notice.
|
|
@@ -23561,6 +24258,136 @@ var ExperimentalServerTasks = class {
|
|
|
23561
24258
|
return this._server.requestStream(request, resultSchema, options);
|
|
23562
24259
|
}
|
|
23563
24260
|
/**
|
|
24261
|
+
* Sends a sampling request and returns an AsyncGenerator that yields response messages.
|
|
24262
|
+
* The generator is guaranteed to end with either a 'result' or 'error' message.
|
|
24263
|
+
*
|
|
24264
|
+
* For task-augmented requests, yields 'taskCreated' and 'taskStatus' messages
|
|
24265
|
+
* before the final result.
|
|
24266
|
+
*
|
|
24267
|
+
* @example
|
|
24268
|
+
* ```typescript
|
|
24269
|
+
* const stream = server.experimental.tasks.createMessageStream({
|
|
24270
|
+
* messages: [{ role: 'user', content: { type: 'text', text: 'Hello' } }],
|
|
24271
|
+
* maxTokens: 100
|
|
24272
|
+
* }, {
|
|
24273
|
+
* onprogress: (progress) => {
|
|
24274
|
+
* // Handle streaming tokens via progress notifications
|
|
24275
|
+
* console.log('Progress:', progress.message);
|
|
24276
|
+
* }
|
|
24277
|
+
* });
|
|
24278
|
+
*
|
|
24279
|
+
* for await (const message of stream) {
|
|
24280
|
+
* switch (message.type) {
|
|
24281
|
+
* case 'taskCreated':
|
|
24282
|
+
* console.log('Task created:', message.task.taskId);
|
|
24283
|
+
* break;
|
|
24284
|
+
* case 'taskStatus':
|
|
24285
|
+
* console.log('Task status:', message.task.status);
|
|
24286
|
+
* break;
|
|
24287
|
+
* case 'result':
|
|
24288
|
+
* console.log('Final result:', message.result);
|
|
24289
|
+
* break;
|
|
24290
|
+
* case 'error':
|
|
24291
|
+
* console.error('Error:', message.error);
|
|
24292
|
+
* break;
|
|
24293
|
+
* }
|
|
24294
|
+
* }
|
|
24295
|
+
* ```
|
|
24296
|
+
*
|
|
24297
|
+
* @param params - The sampling request parameters
|
|
24298
|
+
* @param options - Optional request options (timeout, signal, task creation params, onprogress, etc.)
|
|
24299
|
+
* @returns AsyncGenerator that yields ResponseMessage objects
|
|
24300
|
+
*
|
|
24301
|
+
* @experimental
|
|
24302
|
+
*/
|
|
24303
|
+
createMessageStream(params, options) {
|
|
24304
|
+
const clientCapabilities = this._server.getClientCapabilities();
|
|
24305
|
+
if ((params.tools || params.toolChoice) && !clientCapabilities?.sampling?.tools) throw new Error("Client does not support sampling tools capability.");
|
|
24306
|
+
if (params.messages.length > 0) {
|
|
24307
|
+
const lastMessage = params.messages[params.messages.length - 1];
|
|
24308
|
+
const lastContent = Array.isArray(lastMessage.content) ? lastMessage.content : [lastMessage.content];
|
|
24309
|
+
const hasToolResults = lastContent.some((c) => c.type === "tool_result");
|
|
24310
|
+
const previousMessage = params.messages.length > 1 ? params.messages[params.messages.length - 2] : void 0;
|
|
24311
|
+
const previousContent = previousMessage ? Array.isArray(previousMessage.content) ? previousMessage.content : [previousMessage.content] : [];
|
|
24312
|
+
const hasPreviousToolUse = previousContent.some((c) => c.type === "tool_use");
|
|
24313
|
+
if (hasToolResults) {
|
|
24314
|
+
if (lastContent.some((c) => c.type !== "tool_result")) throw new Error("The last message must contain only tool_result content if any is present");
|
|
24315
|
+
if (!hasPreviousToolUse) throw new Error("tool_result blocks are not matching any tool_use from the previous message");
|
|
24316
|
+
}
|
|
24317
|
+
if (hasPreviousToolUse) {
|
|
24318
|
+
const toolUseIds = new Set(previousContent.filter((c) => c.type === "tool_use").map((c) => c.id));
|
|
24319
|
+
const toolResultIds = new Set(lastContent.filter((c) => c.type === "tool_result").map((c) => c.toolUseId));
|
|
24320
|
+
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");
|
|
24321
|
+
}
|
|
24322
|
+
}
|
|
24323
|
+
return this.requestStream({
|
|
24324
|
+
method: "sampling/createMessage",
|
|
24325
|
+
params
|
|
24326
|
+
}, CreateMessageResultSchema, options);
|
|
24327
|
+
}
|
|
24328
|
+
/**
|
|
24329
|
+
* Sends an elicitation request and returns an AsyncGenerator that yields response messages.
|
|
24330
|
+
* The generator is guaranteed to end with either a 'result' or 'error' message.
|
|
24331
|
+
*
|
|
24332
|
+
* For task-augmented requests (especially URL-based elicitation), yields 'taskCreated'
|
|
24333
|
+
* and 'taskStatus' messages before the final result.
|
|
24334
|
+
*
|
|
24335
|
+
* @example
|
|
24336
|
+
* ```typescript
|
|
24337
|
+
* const stream = server.experimental.tasks.elicitInputStream({
|
|
24338
|
+
* mode: 'url',
|
|
24339
|
+
* message: 'Please authenticate',
|
|
24340
|
+
* elicitationId: 'auth-123',
|
|
24341
|
+
* url: 'https://example.com/auth'
|
|
24342
|
+
* }, {
|
|
24343
|
+
* task: { ttl: 300000 } // Task-augmented for long-running auth flow
|
|
24344
|
+
* });
|
|
24345
|
+
*
|
|
24346
|
+
* for await (const message of stream) {
|
|
24347
|
+
* switch (message.type) {
|
|
24348
|
+
* case 'taskCreated':
|
|
24349
|
+
* console.log('Task created:', message.task.taskId);
|
|
24350
|
+
* break;
|
|
24351
|
+
* case 'taskStatus':
|
|
24352
|
+
* console.log('Task status:', message.task.status);
|
|
24353
|
+
* break;
|
|
24354
|
+
* case 'result':
|
|
24355
|
+
* console.log('User action:', message.result.action);
|
|
24356
|
+
* break;
|
|
24357
|
+
* case 'error':
|
|
24358
|
+
* console.error('Error:', message.error);
|
|
24359
|
+
* break;
|
|
24360
|
+
* }
|
|
24361
|
+
* }
|
|
24362
|
+
* ```
|
|
24363
|
+
*
|
|
24364
|
+
* @param params - The elicitation request parameters
|
|
24365
|
+
* @param options - Optional request options (timeout, signal, task creation params, etc.)
|
|
24366
|
+
* @returns AsyncGenerator that yields ResponseMessage objects
|
|
24367
|
+
*
|
|
24368
|
+
* @experimental
|
|
24369
|
+
*/
|
|
24370
|
+
elicitInputStream(params, options) {
|
|
24371
|
+
const clientCapabilities = this._server.getClientCapabilities();
|
|
24372
|
+
const mode = params.mode ?? "form";
|
|
24373
|
+
switch (mode) {
|
|
24374
|
+
case "url":
|
|
24375
|
+
if (!clientCapabilities?.elicitation?.url) throw new Error("Client does not support url elicitation.");
|
|
24376
|
+
break;
|
|
24377
|
+
case "form":
|
|
24378
|
+
if (!clientCapabilities?.elicitation?.form) throw new Error("Client does not support form elicitation.");
|
|
24379
|
+
break;
|
|
24380
|
+
}
|
|
24381
|
+
const normalizedParams = mode === "form" && params.mode === void 0 ? {
|
|
24382
|
+
...params,
|
|
24383
|
+
mode: "form"
|
|
24384
|
+
} : params;
|
|
24385
|
+
return this.requestStream({
|
|
24386
|
+
method: "elicitation/create",
|
|
24387
|
+
params: normalizedParams
|
|
24388
|
+
}, ElicitResultSchema, options);
|
|
24389
|
+
}
|
|
24390
|
+
/**
|
|
23564
24391
|
* Gets the current status of a task.
|
|
23565
24392
|
*
|
|
23566
24393
|
* @param taskId - The task identifier
|
|
@@ -23611,7 +24438,7 @@ var ExperimentalServerTasks = class {
|
|
|
23611
24438
|
};
|
|
23612
24439
|
|
|
23613
24440
|
//#endregion
|
|
23614
|
-
//#region node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
24441
|
+
//#region node_modules/.pnpm/@modelcontextprotocol+sdk@1.27.1_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.js
|
|
23615
24442
|
/**
|
|
23616
24443
|
* An MCP server on top of a pluggable transport.
|
|
23617
24444
|
*
|
|
@@ -23643,7 +24470,6 @@ var Server = class extends Protocol {
|
|
|
23643
24470
|
* Initializes this server with the given name and version information.
|
|
23644
24471
|
*/
|
|
23645
24472
|
constructor(_serverInfo, options) {
|
|
23646
|
-
var _a, _b;
|
|
23647
24473
|
super(options);
|
|
23648
24474
|
this._serverInfo = _serverInfo;
|
|
23649
24475
|
this._loggingLevels = /* @__PURE__ */ new Map();
|
|
@@ -23652,17 +24478,13 @@ var Server = class extends Protocol {
|
|
|
23652
24478
|
const currentLevel = this._loggingLevels.get(sessionId);
|
|
23653
24479
|
return currentLevel ? this.LOG_LEVEL_SEVERITY.get(level) < this.LOG_LEVEL_SEVERITY.get(currentLevel) : false;
|
|
23654
24480
|
};
|
|
23655
|
-
this._capabilities =
|
|
23656
|
-
this._instructions = options
|
|
23657
|
-
this._jsonSchemaValidator =
|
|
24481
|
+
this._capabilities = options?.capabilities ?? {};
|
|
24482
|
+
this._instructions = options?.instructions;
|
|
24483
|
+
this._jsonSchemaValidator = options?.jsonSchemaValidator ?? new AjvJsonSchemaValidator();
|
|
23658
24484
|
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
|
-
});
|
|
24485
|
+
this.setNotificationHandler(InitializedNotificationSchema, () => this.oninitialized?.());
|
|
23663
24486
|
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;
|
|
24487
|
+
const transportSessionId = extra.sessionId || extra.requestInfo?.headers["mcp-session-id"] || void 0;
|
|
23666
24488
|
const { level } = request.params;
|
|
23667
24489
|
const parseResult = LoggingLevelSchema.safeParse(level);
|
|
23668
24490
|
if (parseResult.success) this._loggingLevels.set(transportSessionId, parseResult.data);
|
|
@@ -23693,19 +24515,15 @@ var Server = class extends Protocol {
|
|
|
23693
24515
|
* Override request handler registration to enforce server-side validation for tools/call.
|
|
23694
24516
|
*/
|
|
23695
24517
|
setRequestHandler(requestSchema, handler) {
|
|
23696
|
-
|
|
23697
|
-
const shape = getObjectShape(requestSchema);
|
|
23698
|
-
const methodSchema = shape === null || shape === void 0 ? void 0 : shape.method;
|
|
24518
|
+
const methodSchema = getObjectShape(requestSchema)?.method;
|
|
23699
24519
|
if (!methodSchema) throw new Error("Schema is missing a method literal");
|
|
23700
24520
|
let methodValue;
|
|
23701
24521
|
if (isZ4Schema(methodSchema)) {
|
|
23702
24522
|
const v4Schema = methodSchema;
|
|
23703
|
-
|
|
23704
|
-
methodValue = (_b = v4Def === null || v4Def === void 0 ? void 0 : v4Def.value) !== null && _b !== void 0 ? _b : v4Schema.value;
|
|
24523
|
+
methodValue = (v4Schema._zod?.def)?.value ?? v4Schema.value;
|
|
23705
24524
|
} else {
|
|
23706
24525
|
const v3Schema = methodSchema;
|
|
23707
|
-
|
|
23708
|
-
methodValue = (_c = legacyDef === null || legacyDef === void 0 ? void 0 : legacyDef.value) !== null && _c !== void 0 ? _c : v3Schema.value;
|
|
24526
|
+
methodValue = v3Schema._def?.value ?? v3Schema.value;
|
|
23709
24527
|
}
|
|
23710
24528
|
if (typeof methodValue !== "string") throw new Error("Schema method literal must be a string");
|
|
23711
24529
|
if (methodValue === "tools/call") {
|
|
@@ -23737,22 +24555,20 @@ var Server = class extends Protocol {
|
|
|
23737
24555
|
return super.setRequestHandler(requestSchema, handler);
|
|
23738
24556
|
}
|
|
23739
24557
|
assertCapabilityForMethod(method) {
|
|
23740
|
-
var _a, _b, _c;
|
|
23741
24558
|
switch (method) {
|
|
23742
24559
|
case "sampling/createMessage":
|
|
23743
|
-
if (!
|
|
24560
|
+
if (!this._clientCapabilities?.sampling) throw new Error(`Client does not support sampling (required for ${method})`);
|
|
23744
24561
|
break;
|
|
23745
24562
|
case "elicitation/create":
|
|
23746
|
-
if (!
|
|
24563
|
+
if (!this._clientCapabilities?.elicitation) throw new Error(`Client does not support elicitation (required for ${method})`);
|
|
23747
24564
|
break;
|
|
23748
24565
|
case "roots/list":
|
|
23749
|
-
if (!
|
|
24566
|
+
if (!this._clientCapabilities?.roots) throw new Error(`Client does not support listing roots (required for ${method})`);
|
|
23750
24567
|
break;
|
|
23751
24568
|
case "ping": break;
|
|
23752
24569
|
}
|
|
23753
24570
|
}
|
|
23754
24571
|
assertNotificationCapability(method) {
|
|
23755
|
-
var _a, _b;
|
|
23756
24572
|
switch (method) {
|
|
23757
24573
|
case "notifications/message":
|
|
23758
24574
|
if (!this._capabilities.logging) throw new Error(`Server does not support logging (required for ${method})`);
|
|
@@ -23768,7 +24584,7 @@ var Server = class extends Protocol {
|
|
|
23768
24584
|
if (!this._capabilities.prompts) throw new Error(`Server does not support notifying of prompt list changes (required for ${method})`);
|
|
23769
24585
|
break;
|
|
23770
24586
|
case "notifications/elicitation/complete":
|
|
23771
|
-
if (!
|
|
24587
|
+
if (!this._clientCapabilities?.elicitation?.url) throw new Error(`Client does not support URL elicitation (required for ${method})`);
|
|
23772
24588
|
break;
|
|
23773
24589
|
case "notifications/cancelled": break;
|
|
23774
24590
|
case "notifications/progress": break;
|
|
@@ -23807,13 +24623,11 @@ var Server = class extends Protocol {
|
|
|
23807
24623
|
}
|
|
23808
24624
|
}
|
|
23809
24625
|
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");
|
|
24626
|
+
assertClientRequestTaskCapability(this._clientCapabilities?.tasks?.requests, method, "Client");
|
|
23812
24627
|
}
|
|
23813
24628
|
assertTaskHandlerCapability(method) {
|
|
23814
|
-
var _a;
|
|
23815
24629
|
if (!this._capabilities) return;
|
|
23816
|
-
assertToolsCallTaskCapability(
|
|
24630
|
+
assertToolsCallTaskCapability(this._capabilities.tasks?.requests, method, "Server");
|
|
23817
24631
|
}
|
|
23818
24632
|
async _oninitialize(request) {
|
|
23819
24633
|
const requestedVersion = request.params.protocolVersion;
|
|
@@ -23845,9 +24659,8 @@ var Server = class extends Protocol {
|
|
|
23845
24659
|
return this.request({ method: "ping" }, EmptyResultSchema);
|
|
23846
24660
|
}
|
|
23847
24661
|
async createMessage(params, options) {
|
|
23848
|
-
var _a, _b;
|
|
23849
24662
|
if (params.tools || params.toolChoice) {
|
|
23850
|
-
if (!
|
|
24663
|
+
if (!this._clientCapabilities?.sampling?.tools) throw new Error("Client does not support sampling tools capability.");
|
|
23851
24664
|
}
|
|
23852
24665
|
if (params.messages.length > 0) {
|
|
23853
24666
|
const lastMessage = params.messages[params.messages.length - 1];
|
|
@@ -23883,10 +24696,9 @@ var Server = class extends Protocol {
|
|
|
23883
24696
|
* @returns The result of the elicitation request.
|
|
23884
24697
|
*/
|
|
23885
24698
|
async elicitInput(params, options) {
|
|
23886
|
-
|
|
23887
|
-
switch ((_a = params.mode) !== null && _a !== void 0 ? _a : "form") {
|
|
24699
|
+
switch (params.mode ?? "form") {
|
|
23888
24700
|
case "url": {
|
|
23889
|
-
if (!
|
|
24701
|
+
if (!this._clientCapabilities?.elicitation?.url) throw new Error("Client does not support url elicitation.");
|
|
23890
24702
|
const urlParams = params;
|
|
23891
24703
|
return this.request({
|
|
23892
24704
|
method: "elicitation/create",
|
|
@@ -23894,7 +24706,7 @@ var Server = class extends Protocol {
|
|
|
23894
24706
|
}, ElicitResultSchema, options);
|
|
23895
24707
|
}
|
|
23896
24708
|
case "form": {
|
|
23897
|
-
if (!
|
|
24709
|
+
if (!this._clientCapabilities?.elicitation?.form) throw new Error("Client does not support form elicitation.");
|
|
23898
24710
|
const formParams = params.mode === "form" ? params : {
|
|
23899
24711
|
...params,
|
|
23900
24712
|
mode: "form"
|
|
@@ -23923,8 +24735,7 @@ var Server = class extends Protocol {
|
|
|
23923
24735
|
* @returns A function that emits the completion notification when awaited.
|
|
23924
24736
|
*/
|
|
23925
24737
|
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)");
|
|
24738
|
+
if (!this._clientCapabilities?.elicitation?.url) throw new Error("Client does not support URL elicitation (required for notifications/elicitation/complete)");
|
|
23928
24739
|
return () => this.notification({
|
|
23929
24740
|
method: "notifications/elicitation/complete",
|
|
23930
24741
|
params: { elicitationId }
|
|
@@ -23969,7 +24780,7 @@ var Server = class extends Protocol {
|
|
|
23969
24780
|
};
|
|
23970
24781
|
|
|
23971
24782
|
//#endregion
|
|
23972
|
-
//#region node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
24783
|
+
//#region node_modules/.pnpm/@modelcontextprotocol+sdk@1.27.1_zod@3.25.76/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.js
|
|
23973
24784
|
/**
|
|
23974
24785
|
* Buffers a continuous stdio stream into discrete JSON-RPC messages.
|
|
23975
24786
|
*/
|
|
@@ -23997,5 +24808,5 @@ function serializeMessage(message) {
|
|
|
23997
24808
|
}
|
|
23998
24809
|
|
|
23999
24810
|
//#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-
|
|
24811
|
+
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 };
|
|
24812
|
+
//# sourceMappingURL=stdio-_93Y9W6l.mjs.map
|