@ds-mo/ui 16.2.0 → 16.3.1
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/.package-ready.json +1 -1
- package/dist/agent-patterns.json +1 -1
- package/dist/agent.json +3 -3
- package/dist/docs/components.json +1 -1
- package/dist/lint/THIRD-PARTY-NOTICES +3 -3
- package/dist/lint/bundled-dependencies.json +3 -3
- package/dist/lint/index.js +155 -38
- package/dist/mcp/THIRD-PARTY-NOTICES +4 -4
- package/dist/mcp/bundled-dependencies.json +4 -4
- package/dist/mcp/cli.js +196 -69
- package/dist/mcp-data/registry/disclosure.json +1 -1
- package/dist/mcp-data/registry/drawer.json +1 -1
- package/dist/mcp-data/registry/registry.json +2 -2
- package/package.json +15 -15
package/dist/mcp/cli.js
CHANGED
|
@@ -14576,7 +14576,7 @@ function date4(params) {
|
|
|
14576
14576
|
// node_modules/zod/v4/classic/external.js
|
|
14577
14577
|
config(en_default());
|
|
14578
14578
|
|
|
14579
|
-
// node_modules/@modelcontextprotocol/core/dist/auth-
|
|
14579
|
+
// node_modules/@modelcontextprotocol/core/dist/auth-BNDyLTqp.mjs
|
|
14580
14580
|
var LATEST_PROTOCOL_VERSION = "2025-11-25";
|
|
14581
14581
|
var SUPPORTED_PROTOCOL_VERSIONS = [
|
|
14582
14582
|
LATEST_PROTOCOL_VERSION,
|
|
@@ -15413,7 +15413,8 @@ var OAuthMetadataSchema = looseObject({
|
|
|
15413
15413
|
introspection_endpoint_auth_signing_alg_values_supported: array(string2()).optional(),
|
|
15414
15414
|
code_challenge_methods_supported: array(string2()).optional(),
|
|
15415
15415
|
client_id_metadata_document_supported: boolean2().optional(),
|
|
15416
|
-
authorization_response_iss_parameter_supported: boolean2().optional().catch(void 0)
|
|
15416
|
+
authorization_response_iss_parameter_supported: boolean2().optional().catch(void 0),
|
|
15417
|
+
dpop_signing_alg_values_supported: array(string2()).optional()
|
|
15417
15418
|
});
|
|
15418
15419
|
var OpenIdProviderMetadataSchema = looseObject({
|
|
15419
15420
|
issuer: string2(),
|
|
@@ -15464,7 +15465,8 @@ var OAuthTokensSchema = object({
|
|
|
15464
15465
|
token_type: string2(),
|
|
15465
15466
|
expires_in: coerce_exports.number().optional(),
|
|
15466
15467
|
scope: string2().optional(),
|
|
15467
|
-
refresh_token: string2().optional()
|
|
15468
|
+
refresh_token: string2().optional(),
|
|
15469
|
+
issuer: string2().optional().catch(void 0)
|
|
15468
15470
|
}).strip();
|
|
15469
15471
|
var IdJagTokenExchangeResponseSchema = object({
|
|
15470
15472
|
issued_token_type: literal("urn:ietf:params:oauth:token-type:id-jag"),
|
|
@@ -15502,7 +15504,8 @@ var OAuthClientInformationSchema = object({
|
|
|
15502
15504
|
client_id: string2(),
|
|
15503
15505
|
client_secret: string2().optional(),
|
|
15504
15506
|
client_id_issued_at: number2().optional(),
|
|
15505
|
-
client_secret_expires_at: number2().optional()
|
|
15507
|
+
client_secret_expires_at: number2().optional(),
|
|
15508
|
+
issuer: string2().optional().catch(void 0)
|
|
15506
15509
|
}).strip();
|
|
15507
15510
|
var OAuthClientInformationFullSchema = OAuthClientMetadataSchema.merge(OAuthClientInformationSchema);
|
|
15508
15511
|
var OAuthClientRegistrationErrorSchema = object({
|
|
@@ -15514,7 +15517,7 @@ var OAuthTokenRevocationRequestSchema = object({
|
|
|
15514
15517
|
token_type_hint: string2().optional()
|
|
15515
15518
|
}).strip();
|
|
15516
15519
|
|
|
15517
|
-
// node_modules/@modelcontextprotocol/server/dist/src-
|
|
15520
|
+
// node_modules/@modelcontextprotocol/server/dist/src-Cqbh3MYc.mjs
|
|
15518
15521
|
var BRANDS = /* @__PURE__ */ Symbol.for("mcp.sdk.errorBrands");
|
|
15519
15522
|
function stampErrorBrands(instance, ctor) {
|
|
15520
15523
|
const brands = /* @__PURE__ */ new Set();
|
|
@@ -15628,8 +15631,18 @@ var SdkError = class extends Error {
|
|
|
15628
15631
|
if (typeof this !== "function") throw new TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");
|
|
15629
15632
|
return brandedHasInstance(this, value);
|
|
15630
15633
|
}
|
|
15631
|
-
|
|
15632
|
-
|
|
15634
|
+
/**
|
|
15635
|
+
* @param code - Stable string code identifying the failure ({@linkcode SdkErrorCode}).
|
|
15636
|
+
* @param message - Human-readable description.
|
|
15637
|
+
* @param data - Optional structured payload (for example the HTTP status carried by
|
|
15638
|
+
* {@linkcode SdkHttpError}). Opaque to the SDK: a `cause` key inside `data` is not
|
|
15639
|
+
* promoted to `Error.cause`.
|
|
15640
|
+
* @param options - Standard `ErrorOptions`, forwarded to `Error`. Pass the underlying
|
|
15641
|
+
* failure as `{ cause }` so it is reachable through the `Error.cause` chain that
|
|
15642
|
+
* loggers and error trackers walk.
|
|
15643
|
+
*/
|
|
15644
|
+
constructor(code, message, data, options) {
|
|
15645
|
+
super(message, options);
|
|
15633
15646
|
this.code = code;
|
|
15634
15647
|
this.data = data;
|
|
15635
15648
|
this.name = "SdkError";
|
|
@@ -15640,8 +15653,11 @@ var SdkHttpError = class extends SdkError {
|
|
|
15640
15653
|
static {
|
|
15641
15654
|
Object.defineProperty(this, "mcpBrand", { value: "mcp.SdkHttpError" });
|
|
15642
15655
|
}
|
|
15643
|
-
|
|
15644
|
-
|
|
15656
|
+
/**
|
|
15657
|
+
* @param options - Standard `ErrorOptions`, forwarded to `Error` (see {@linkcode SdkError}).
|
|
15658
|
+
*/
|
|
15659
|
+
constructor(code, message, data, options) {
|
|
15660
|
+
super(code, message, data, options);
|
|
15645
15661
|
this.name = "SdkHttpError";
|
|
15646
15662
|
}
|
|
15647
15663
|
get status() {
|
|
@@ -17744,7 +17760,8 @@ function build() {
|
|
|
17744
17760
|
ListResourceTemplatesResultResponseSchema: wireResultResponse(ListResourceTemplatesResultSchema$1),
|
|
17745
17761
|
ReadResourceResultResponseSchema: wireResultResponse(union([ReadResourceResultSchema$1, InputRequiredResultSchema])),
|
|
17746
17762
|
CompleteResultResponseSchema: wireResultResponse(CompleteResultSchema$1),
|
|
17747
|
-
DiscoverResultResponseSchema: wireResultResponse(DiscoverResultSchema$1)
|
|
17763
|
+
DiscoverResultResponseSchema: wireResultResponse(DiscoverResultSchema$1),
|
|
17764
|
+
SubscriptionsListenResultResponseSchema: wireResultResponse(SubscriptionsListenResultSchema$1)
|
|
17748
17765
|
};
|
|
17749
17766
|
}
|
|
17750
17767
|
var memo;
|
|
@@ -18172,6 +18189,8 @@ var rev2026Codec = {
|
|
|
18172
18189
|
const rawInputRequests = raw["inputRequests"];
|
|
18173
18190
|
const inputRequests = isPlainObject$4(rawInputRequests) ? rawInputRequests : {};
|
|
18174
18191
|
const requestState = raw["requestState"];
|
|
18192
|
+
const metaParse = raw["_meta"] === void 0 ? void 0 : buildSchemas2026().ResultMetaSchema.safeParse(raw["_meta"]);
|
|
18193
|
+
const meta3 = metaParse?.success ? metaParse.data : void 0;
|
|
18175
18194
|
if (Object.keys(inputRequests).length === 0 && typeof requestState !== "string") return {
|
|
18176
18195
|
kind: "invalid",
|
|
18177
18196
|
error: new SdkError(SdkErrorCode.InvalidResult, `Invalid result for ${method}: input_required carries neither inputRequests nor requestState (every input_required result must include at least one of the two)`, {
|
|
@@ -18182,7 +18201,8 @@ var rev2026Codec = {
|
|
|
18182
18201
|
return {
|
|
18183
18202
|
kind: "input_required",
|
|
18184
18203
|
inputRequests,
|
|
18185
|
-
...typeof requestState === "string" && { requestState }
|
|
18204
|
+
...typeof requestState === "string" && { requestState },
|
|
18205
|
+
...meta3 !== void 0 && { _meta: meta3 }
|
|
18186
18206
|
};
|
|
18187
18207
|
}
|
|
18188
18208
|
if (rawResultType !== "complete") return {
|
|
@@ -18249,6 +18269,9 @@ function isSpecRequestMethod(method) {
|
|
|
18249
18269
|
function isSpecNotificationMethod(method) {
|
|
18250
18270
|
return ALL_CODECS.some((codec2) => codec2.hasNotificationMethod(method));
|
|
18251
18271
|
}
|
|
18272
|
+
function isExtensionReusedRequestMethod(method) {
|
|
18273
|
+
return method === "tasks/get" || method === "tasks/cancel";
|
|
18274
|
+
}
|
|
18252
18275
|
var ALL_CODECS = [rev2025Codec, rev2026Codec];
|
|
18253
18276
|
function isPlainObject$3(value) {
|
|
18254
18277
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
@@ -18592,7 +18615,7 @@ var INBOUND_VALIDATION_LADDER = [
|
|
|
18592
18615
|
evaluatedAt: "pre-dispatch",
|
|
18593
18616
|
codes: [HEADER_MISMATCH_ERROR_CODE],
|
|
18594
18617
|
conformance: ["http-header-validation"],
|
|
18595
|
-
rationale: "SEP-2243 standard `Mcp-Method` / `Mcp-Name` headers \u2014 presence, sentinel decoding, and `Mcp-Name` \u2194 body cross-check \u2014 are validated by the HTTP entry on a modern-classified request after the supported-revision gate and before dispatch. The classifier\u2019s own header-mismatch cells (protocol-version, `Mcp-Method` mismatch) stay on the edge `era-classification` rung; this rung carries the entry-layer presence/`Mcp-Name` half. Evaluated before the capability gate, the factory call, and the `Mcp-Param-*` rung so a request that fails several rungs is answered by the standard-header rung first. The documented order (after method-registry 5 and request-params 6) is NOT the observed precedence: serveModern evaluates this rung immediately after the supported-revision gate, so a request that also fails a dispatch rung is answered here before the dispatch rungs (5\u20136) are consulted."
|
|
18618
|
+
rationale: "SEP-2243 standard `MCP-Protocol-Version` / `Mcp-Method` / `Mcp-Name` headers \u2014 presence, sentinel decoding, and `Mcp-Name` \u2194 body cross-check \u2014 are validated by the HTTP entry on a modern-classified request after the supported-revision gate and before dispatch. The spec requires `MCP-Protocol-Version` and `Mcp-Method` on every modern *request* POST (`Mcp-Name` only for the methods that mirror `params.name` / `params.uri` / `params.taskId`, see `MCP_NAME_HEADER_SOURCE`) and names them in that order, so a request missing several is answered by the earliest. Notification POSTs are exempt: the presence half runs on requests only, so a modern-enveloped notification is dispatched even with no standard headers at all. The classifier\u2019s own header-mismatch cells (protocol-version, `Mcp-Method` mismatch) stay on the edge `era-classification` rung; this rung carries the entry-layer presence/`Mcp-Name` half \u2014 including the missing `MCP-Protocol-Version` cell, which cannot live on the edge rung without breaking body-primary classification. Evaluated before the capability gate, the factory call, and the `Mcp-Param-*` rung so a request that fails several rungs is answered by the standard-header rung first. The documented order (after method-registry 5 and request-params 6) is NOT the observed precedence: serveModern evaluates this rung immediately after the supported-revision gate, so a request that also fails a dispatch rung is answered here before the dispatch rungs (5\u20136) are consulted."
|
|
18596
18619
|
},
|
|
18597
18620
|
{
|
|
18598
18621
|
rung: "client-capabilities",
|
|
@@ -19226,6 +19249,8 @@ var Protocol = class {
|
|
|
19226
19249
|
_transport;
|
|
19227
19250
|
_requestMessageId = 0;
|
|
19228
19251
|
_requestHandlers = /* @__PURE__ */ new Map();
|
|
19252
|
+
/** Methods registered with an explicit schema; the era gate in `_onrequest` reads it for the Tasks extension names. */
|
|
19253
|
+
_customSchemaRequestMethods = /* @__PURE__ */ new Set();
|
|
19229
19254
|
_requestHandlerAbortControllers = /* @__PURE__ */ new Map();
|
|
19230
19255
|
_notificationHandlers = /* @__PURE__ */ new Map();
|
|
19231
19256
|
_responseHandlers = /* @__PURE__ */ new Map();
|
|
@@ -19362,7 +19387,7 @@ var Protocol = class {
|
|
|
19362
19387
|
return this._requestHandlers.get(method);
|
|
19363
19388
|
}
|
|
19364
19389
|
async _oncancel(notification) {
|
|
19365
|
-
if (
|
|
19390
|
+
if (notification.params.requestId === void 0) return;
|
|
19366
19391
|
this._requestHandlerAbortControllers.get(notification.params.requestId)?.abort(notification.params.reason);
|
|
19367
19392
|
}
|
|
19368
19393
|
_setupTimeout(messageId, timeout, maxTotalTimeout, onTimeout, resetTimeoutOnProgress = false) {
|
|
@@ -19509,7 +19534,7 @@ var Protocol = class {
|
|
|
19509
19534
|
return;
|
|
19510
19535
|
}
|
|
19511
19536
|
}
|
|
19512
|
-
if (isSpecRequestMethod(request.method) && !codec2.hasRequestMethod(request.method)) {
|
|
19537
|
+
if (isSpecRequestMethod(request.method) && !codec2.hasRequestMethod(request.method) && !(isExtensionReusedRequestMethod(request.method) && this._customSchemaRequestMethods.has(request.method))) {
|
|
19513
19538
|
sendErrorResponse(ProtocolErrorCode.MethodNotFound, "Method not found");
|
|
19514
19539
|
return;
|
|
19515
19540
|
}
|
|
@@ -19642,8 +19667,11 @@ var Protocol = class {
|
|
|
19642
19667
|
}
|
|
19643
19668
|
request(request, schemaOrOptions, maybeOptions) {
|
|
19644
19669
|
const codec2 = this._resolveOutboundCodec(request.method);
|
|
19670
|
+
if (isStandardSchema(schemaOrOptions)) {
|
|
19671
|
+
if (!isExtensionReusedRequestMethod(request.method)) this._assertOutboundRequestInEra(codec2, request.method);
|
|
19672
|
+
return this._requestWithSchemaViaCodec(codec2, request, schemaOrOptions, maybeOptions);
|
|
19673
|
+
}
|
|
19645
19674
|
this._assertOutboundRequestInEra(codec2, request.method);
|
|
19646
|
-
if (isStandardSchema(schemaOrOptions)) return this._requestWithSchemaViaCodec(codec2, request, schemaOrOptions, maybeOptions);
|
|
19647
19675
|
const validate = codecResultValidator(codec2, request.method);
|
|
19648
19676
|
if (validate === void 0) throw new TypeError(`'${request.method}' is not a spec method; pass a result schema as the second argument to request().`);
|
|
19649
19677
|
return this._requestWithSchemaViaCodec(codec2, request, validate, schemaOrOptions);
|
|
@@ -19761,19 +19789,20 @@ var Protocol = class {
|
|
|
19761
19789
|
const cancel = (reason) => {
|
|
19762
19790
|
if (responseReceived) return;
|
|
19763
19791
|
this._progressHandlers.delete(messageId);
|
|
19764
|
-
if (requestAbort === void 0)
|
|
19765
|
-
|
|
19766
|
-
|
|
19767
|
-
|
|
19768
|
-
|
|
19769
|
-
|
|
19770
|
-
|
|
19771
|
-
|
|
19772
|
-
|
|
19773
|
-
|
|
19774
|
-
|
|
19775
|
-
|
|
19776
|
-
|
|
19792
|
+
if (requestAbort === void 0) {
|
|
19793
|
+
if (request.method !== "initialize") this._transport?.send(this._envelopeOutbound({
|
|
19794
|
+
jsonrpc: "2.0",
|
|
19795
|
+
method: "notifications/cancelled",
|
|
19796
|
+
params: {
|
|
19797
|
+
requestId: messageId,
|
|
19798
|
+
reason: String(reason)
|
|
19799
|
+
}
|
|
19800
|
+
}), {
|
|
19801
|
+
relatedRequestId,
|
|
19802
|
+
resumptionToken,
|
|
19803
|
+
onresumptiontoken
|
|
19804
|
+
}).catch((error51) => this._onerror(/* @__PURE__ */ new Error(`Failed to send cancellation: ${error51}`)));
|
|
19805
|
+
} else requestAbort.abort();
|
|
19777
19806
|
reject(reason instanceof SdkError ? reason : new SdkError(SdkErrorCode.RequestTimeout, String(reason)));
|
|
19778
19807
|
};
|
|
19779
19808
|
this._responseHandlers.set(messageId, (response) => {
|
|
@@ -19835,7 +19864,7 @@ var Protocol = class {
|
|
|
19835
19864
|
* Emits a notification, which is a one-way message that does not expect a response.
|
|
19836
19865
|
*/
|
|
19837
19866
|
async notification(notification, options) {
|
|
19838
|
-
return this._notificationViaCodec(this._resolveOutboundCodec(notification.method), notification, options);
|
|
19867
|
+
return await this._notificationViaCodec(this._resolveOutboundCodec(notification.method), notification, options);
|
|
19839
19868
|
}
|
|
19840
19869
|
/**
|
|
19841
19870
|
* The notification funnel proper, keyed by the resolved era codec —
|
|
@@ -19853,7 +19882,7 @@ var Protocol = class {
|
|
|
19853
19882
|
jsonrpc: "2.0",
|
|
19854
19883
|
...notification
|
|
19855
19884
|
});
|
|
19856
|
-
if ((this._options?.debouncedNotificationMethods ?? []).includes(notification.method) && !notification.params &&
|
|
19885
|
+
if ((this._options?.debouncedNotificationMethods ?? []).includes(notification.method) && !notification.params && options?.relatedRequestId === void 0) {
|
|
19857
19886
|
if (this._pendingDebouncedNotifications.has(notification.method)) return;
|
|
19858
19887
|
this._pendingDebouncedNotifications.add(notification.method);
|
|
19859
19888
|
Promise.resolve().then(() => {
|
|
@@ -19886,6 +19915,8 @@ var Protocol = class {
|
|
|
19886
19915
|
return maybeHandler(parsed.data, ctx);
|
|
19887
19916
|
};
|
|
19888
19917
|
else throw new TypeError("setRequestHandler: handler is required");
|
|
19918
|
+
if (typeof schemasOrHandler === "function") this._customSchemaRequestMethods.delete(method);
|
|
19919
|
+
else this._customSchemaRequestMethods.add(method);
|
|
19889
19920
|
this._requestHandlers.set(method, this._wrapHandler(method, stored));
|
|
19890
19921
|
}
|
|
19891
19922
|
/**
|
|
@@ -19915,6 +19946,7 @@ var Protocol = class {
|
|
|
19915
19946
|
*/
|
|
19916
19947
|
removeRequestHandler(method) {
|
|
19917
19948
|
this._requestHandlers.delete(method);
|
|
19949
|
+
this._customSchemaRequestMethods.delete(method);
|
|
19918
19950
|
}
|
|
19919
19951
|
/**
|
|
19920
19952
|
* Asserts that a request handler has not already been set for the given method, in preparation for a new one being automatically installed.
|
|
@@ -19992,7 +20024,8 @@ function manualInputRequiredValue(decoded) {
|
|
|
19992
20024
|
return {
|
|
19993
20025
|
resultType: "input_required",
|
|
19994
20026
|
inputRequests: decoded.inputRequests,
|
|
19995
|
-
...decoded.requestState !== void 0 && { requestState: decoded.requestState }
|
|
20027
|
+
...decoded.requestState !== void 0 && { requestState: decoded.requestState },
|
|
20028
|
+
...decoded._meta !== void 0 && { _meta: decoded._meta }
|
|
19996
20029
|
};
|
|
19997
20030
|
}
|
|
19998
20031
|
var require_content_type = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
@@ -27156,7 +27189,7 @@ var Ajv = import_ajv.Ajv;
|
|
|
27156
27189
|
// node_modules/@modelcontextprotocol/server/dist/shimsNode.mjs
|
|
27157
27190
|
import process2 from "node:process";
|
|
27158
27191
|
|
|
27159
|
-
// node_modules/@modelcontextprotocol/server/dist/mcp-
|
|
27192
|
+
// node_modules/@modelcontextprotocol/server/dist/mcp-DIH4cS6P.mjs
|
|
27160
27193
|
var COMPLETABLE_SYMBOL = /* @__PURE__ */ Symbol.for("mcp.completable");
|
|
27161
27194
|
function isCompletable(schema) {
|
|
27162
27195
|
return !!schema && typeof schema === "object" && COMPLETABLE_SYMBOL in schema;
|
|
@@ -27221,7 +27254,7 @@ var StdioListenRouter = class {
|
|
|
27221
27254
|
_serverCapabilities;
|
|
27222
27255
|
/**
|
|
27223
27256
|
* The serving instance's identity, stamped onto the graceful-close
|
|
27224
|
-
* results' `_meta` (the spec's `
|
|
27257
|
+
* results' `_meta` (the spec's `SubscriptionsListenResultMetaObject` extends
|
|
27225
27258
|
* `ResultMetaObject`). Handed over together with the capabilities.
|
|
27226
27259
|
*/
|
|
27227
27260
|
_serverInfo;
|
|
@@ -27349,6 +27382,9 @@ function notificationToServerEvent(method, uri) {
|
|
|
27349
27382
|
};
|
|
27350
27383
|
}
|
|
27351
27384
|
}
|
|
27385
|
+
function supportsScopeChallengeResolver(transport) {
|
|
27386
|
+
return typeof transport === "object" && transport !== null && "setScopeChallengeResolver" in transport && typeof transport.setScopeChallengeResolver === "function";
|
|
27387
|
+
}
|
|
27352
27388
|
var DEFAULT_LEGACY_SHIM_MAX_ROUNDS = 8;
|
|
27353
27389
|
var DEFAULT_LEGACY_SHIM_ROUND_TIMEOUT_MS = 6e5;
|
|
27354
27390
|
function resolveLegacyShimOptions(options) {
|
|
@@ -27550,6 +27586,11 @@ var Server = class extends Protocol {
|
|
|
27550
27586
|
if (modernProtocolVersions(this._supportedProtocolVersions).length > 0) this.setRequestHandler("server/discover", () => this._ondiscover());
|
|
27551
27587
|
if (this._capabilities.logging) this._registerLoggingHandler();
|
|
27552
27588
|
}
|
|
27589
|
+
/** Attaches to the given transport; rejects while this instance is connected to another one. */
|
|
27590
|
+
async connect(transport) {
|
|
27591
|
+
if (this.transport !== void 0) throw new SdkError(SdkErrorCode.AlreadyConnected, "Use a separate Server instance per connection: this instance is already connected to a transport. To connect it to a new transport, call close() first.");
|
|
27592
|
+
await super.connect(transport);
|
|
27593
|
+
}
|
|
27553
27594
|
/**
|
|
27554
27595
|
* Registers the built-in `logging/setLevel` request handler.
|
|
27555
27596
|
*
|
|
@@ -28103,21 +28144,41 @@ var Server = class extends Protocol {
|
|
|
28103
28144
|
function discoverAdvertisedCapabilities(capabilities) {
|
|
28104
28145
|
return { ...capabilities };
|
|
28105
28146
|
}
|
|
28147
|
+
function toolInputElementCount(value, max) {
|
|
28148
|
+
let count = 0;
|
|
28149
|
+
const stack = [value];
|
|
28150
|
+
while (stack.length > 0) {
|
|
28151
|
+
const node = stack.pop();
|
|
28152
|
+
if (node === null || typeof node !== "object") continue;
|
|
28153
|
+
if (Array.isArray(node)) for (const child of node) {
|
|
28154
|
+
if (++count > max) return count;
|
|
28155
|
+
if (child !== null && typeof child === "object") stack.push(child);
|
|
28156
|
+
}
|
|
28157
|
+
else for (const key in node) {
|
|
28158
|
+
if (!Object.prototype.hasOwnProperty.call(node, key)) continue;
|
|
28159
|
+
if (++count > max) return count;
|
|
28160
|
+
const child = node[key];
|
|
28161
|
+
if (child !== null && typeof child === "object") stack.push(child);
|
|
28162
|
+
}
|
|
28163
|
+
}
|
|
28164
|
+
return count;
|
|
28165
|
+
}
|
|
28166
|
+
function resolveMaxToolInputElements(value) {
|
|
28167
|
+
if (value === void 0 || value === Infinity) return void 0;
|
|
28168
|
+
if (typeof value !== "number" || Number.isNaN(value) || value < 1) throw new RangeError(`maxToolInputElements must be a number of at least 1, or Infinity, got ${String(value)}`);
|
|
28169
|
+
return value;
|
|
28170
|
+
}
|
|
28106
28171
|
var McpServer = class {
|
|
28107
28172
|
/**
|
|
28108
28173
|
* The underlying {@linkcode Server} instance, useful for advanced operations like sending notifications.
|
|
28109
28174
|
*/
|
|
28110
28175
|
server;
|
|
28176
|
+
_maxToolInputElements;
|
|
28111
28177
|
_registeredResources = {};
|
|
28112
28178
|
_registeredResourceTemplates = {};
|
|
28113
28179
|
_registeredTools = {};
|
|
28114
28180
|
_registeredPrompts = {};
|
|
28115
|
-
/**
|
|
28116
|
-
* Per-tool JSON-converted `inputSchema`, memoized so the SEP-2243
|
|
28117
|
-
* registration-time scan and the pre-dispatch validation step share one
|
|
28118
|
-
* conversion instead of paying it twice per request under the
|
|
28119
|
-
* per-request-factory `createMcpHandler` model.
|
|
28120
|
-
*/
|
|
28181
|
+
/** Per-tool JSON-converted `inputSchema`, filled on first use by `toolInputSchemaJson()`. */
|
|
28121
28182
|
_toolInputSchemaJson = {};
|
|
28122
28183
|
/**
|
|
28123
28184
|
* The JSON-serialized `inputSchema` of a registered tool, or `undefined`
|
|
@@ -28142,6 +28203,7 @@ var McpServer = class {
|
|
|
28142
28203
|
}
|
|
28143
28204
|
constructor(serverInfo, options) {
|
|
28144
28205
|
this.server = new Server(serverInfo, options);
|
|
28206
|
+
this._maxToolInputElements = resolveMaxToolInputElements(options?.maxToolInputElements);
|
|
28145
28207
|
if (options?.capabilities?.tools) this.setToolRequestHandlers();
|
|
28146
28208
|
if (options?.capabilities?.resources) this.setResourceRequestHandlers();
|
|
28147
28209
|
if (options?.capabilities?.prompts) this.setPromptRequestHandlers();
|
|
@@ -28159,6 +28221,7 @@ var McpServer = class {
|
|
|
28159
28221
|
* ```
|
|
28160
28222
|
*/
|
|
28161
28223
|
async connect(transport) {
|
|
28224
|
+
if (supportsScopeChallengeResolver(transport)) transport.setScopeChallengeResolver((context) => this.resolveScopeChallenge(context));
|
|
28162
28225
|
return await this.server.connect(transport);
|
|
28163
28226
|
}
|
|
28164
28227
|
/**
|
|
@@ -28167,6 +28230,41 @@ var McpServer = class {
|
|
|
28167
28230
|
async close() {
|
|
28168
28231
|
await this.server.close();
|
|
28169
28232
|
}
|
|
28233
|
+
/** @internal */
|
|
28234
|
+
resolveScopeChallenge = (context) => {
|
|
28235
|
+
switch (context.request.method) {
|
|
28236
|
+
case "tools/call": {
|
|
28237
|
+
const toolName = context.request.params?.name;
|
|
28238
|
+
if (typeof toolName !== "string") return;
|
|
28239
|
+
const tool = this._registeredTools[toolName];
|
|
28240
|
+
if (tool === void 0 || !tool.enabled) return;
|
|
28241
|
+
return tool.scopeChallenge?.(context);
|
|
28242
|
+
}
|
|
28243
|
+
case "resources/read": {
|
|
28244
|
+
const resourceUri = context.request.params?.uri;
|
|
28245
|
+
if (typeof resourceUri !== "string") return;
|
|
28246
|
+
let uri;
|
|
28247
|
+
try {
|
|
28248
|
+
uri = new URL(resourceUri);
|
|
28249
|
+
} catch {
|
|
28250
|
+
return;
|
|
28251
|
+
}
|
|
28252
|
+
const resource = this._registeredResources[uri.toString()];
|
|
28253
|
+
if (resource !== void 0) return resource.enabled ? resource.scopeChallenge?.(context) : void 0;
|
|
28254
|
+
for (const template of Object.values(this._registeredResourceTemplates)) if (template.resourceTemplate.uriTemplate.match(uri.toString())) return template.enabled ? template.scopeChallenge?.(context) : void 0;
|
|
28255
|
+
return;
|
|
28256
|
+
}
|
|
28257
|
+
case "prompts/get": {
|
|
28258
|
+
const promptName = context.request.params?.name;
|
|
28259
|
+
if (typeof promptName !== "string") return;
|
|
28260
|
+
const prompt = this._registeredPrompts[promptName];
|
|
28261
|
+
if (prompt === void 0 || !prompt.enabled) return;
|
|
28262
|
+
return prompt.scopeChallenge?.(context);
|
|
28263
|
+
}
|
|
28264
|
+
default:
|
|
28265
|
+
return;
|
|
28266
|
+
}
|
|
28267
|
+
};
|
|
28170
28268
|
_toolHandlersInitialized = false;
|
|
28171
28269
|
setToolRequestHandlers() {
|
|
28172
28270
|
if (this._toolHandlersInitialized) return;
|
|
@@ -28178,7 +28276,7 @@ var McpServer = class {
|
|
|
28178
28276
|
name,
|
|
28179
28277
|
title: tool.title,
|
|
28180
28278
|
description: tool.description,
|
|
28181
|
-
inputSchema: tool.inputSchema ?
|
|
28279
|
+
inputSchema: tool.inputSchema ? convertListedInputSchema(name, tool.inputSchema) : EMPTY_OBJECT_JSON_SCHEMA,
|
|
28182
28280
|
annotations: tool.annotations,
|
|
28183
28281
|
icons: tool.icons,
|
|
28184
28282
|
execution: tool.execution,
|
|
@@ -28223,6 +28321,7 @@ var McpServer = class {
|
|
|
28223
28321
|
* Validates tool input arguments against the tool's input schema.
|
|
28224
28322
|
*/
|
|
28225
28323
|
async validateToolInput(tool, args, toolName) {
|
|
28324
|
+
if (this._maxToolInputElements !== void 0 && toolInputElementCount(args, this._maxToolInputElements) > this._maxToolInputElements) throw new ProtocolError(ProtocolErrorCode.InvalidParams, `Invalid arguments for tool ${toolName}: arguments contain more than the maximum of ${this._maxToolInputElements} elements`);
|
|
28226
28325
|
if (!tool.inputSchema) return;
|
|
28227
28326
|
const parseResult = await validateStandardSchema(tool.inputSchema, args ?? {});
|
|
28228
28327
|
if (!parseResult.success) throw new ProtocolError(ProtocolErrorCode.InvalidParams, `Input validation error: Invalid arguments for tool ${toolName}: ${parseResult.error}`);
|
|
@@ -28333,7 +28432,10 @@ var McpServer = class {
|
|
|
28333
28432
|
}
|
|
28334
28433
|
for (const template of Object.values(this._registeredResourceTemplates)) {
|
|
28335
28434
|
const variables = template.resourceTemplate.uriTemplate.match(uri.toString());
|
|
28336
|
-
if (variables)
|
|
28435
|
+
if (variables) {
|
|
28436
|
+
if (!template.enabled) throw new ProtocolError(ProtocolErrorCode.InvalidParams, `Resource template ${template.resourceTemplate.uriTemplate} disabled`);
|
|
28437
|
+
return attachCacheHintFallback(await template.readCallback(uri, variables, ctx), template.cacheHint);
|
|
28438
|
+
}
|
|
28337
28439
|
}
|
|
28338
28440
|
throw new ResourceNotFoundError(request.params.uri);
|
|
28339
28441
|
});
|
|
@@ -28364,36 +28466,32 @@ var McpServer = class {
|
|
|
28364
28466
|
this._promptHandlersInitialized = true;
|
|
28365
28467
|
}
|
|
28366
28468
|
registerResource(name, uriOrTemplate, config2, readCallback) {
|
|
28367
|
-
const cacheHint = config2
|
|
28368
|
-
|
|
28369
|
-
if (cacheHint !== void 0) {
|
|
28370
|
-
assertValidCacheHint(cacheHint, `resource ${name}`);
|
|
28371
|
-
const rest = { ...config2 };
|
|
28372
|
-
delete rest.cacheHint;
|
|
28373
|
-
metadata = rest;
|
|
28374
|
-
}
|
|
28469
|
+
const { cacheHint, scopeChallenge, ...resourceMetadata } = config2;
|
|
28470
|
+
const metadata = resourceMetadata;
|
|
28471
|
+
if (cacheHint !== void 0) assertValidCacheHint(cacheHint, `resource ${name}`);
|
|
28375
28472
|
if (typeof uriOrTemplate === "string") {
|
|
28376
28473
|
if (this._registeredResources[uriOrTemplate]) throw new Error(`Resource ${uriOrTemplate} is already registered`);
|
|
28377
|
-
const registeredResource = this._createRegisteredResource(name, config2.title, uriOrTemplate, metadata, readCallback);
|
|
28474
|
+
const registeredResource = this._createRegisteredResource(name, config2.title, uriOrTemplate, metadata, scopeChallenge, readCallback);
|
|
28378
28475
|
if (cacheHint !== void 0) registeredResource.cacheHint = cacheHint;
|
|
28379
28476
|
this.setResourceRequestHandlers();
|
|
28380
28477
|
this.sendResourceListChanged();
|
|
28381
28478
|
return registeredResource;
|
|
28382
28479
|
} else {
|
|
28383
28480
|
if (this._registeredResourceTemplates[name]) throw new Error(`Resource template ${name} is already registered`);
|
|
28384
|
-
const registeredResourceTemplate = this._createRegisteredResourceTemplate(name, config2.title, uriOrTemplate, metadata, readCallback);
|
|
28481
|
+
const registeredResourceTemplate = this._createRegisteredResourceTemplate(name, config2.title, uriOrTemplate, metadata, scopeChallenge, readCallback);
|
|
28385
28482
|
if (cacheHint !== void 0) registeredResourceTemplate.cacheHint = cacheHint;
|
|
28386
28483
|
this.setResourceRequestHandlers();
|
|
28387
28484
|
this.sendResourceListChanged();
|
|
28388
28485
|
return registeredResourceTemplate;
|
|
28389
28486
|
}
|
|
28390
28487
|
}
|
|
28391
|
-
_createRegisteredResource(name, title, uri, metadata, readCallback) {
|
|
28488
|
+
_createRegisteredResource(name, title, uri, metadata, scopeChallenge, readCallback) {
|
|
28392
28489
|
const registeredResource = {
|
|
28393
28490
|
name,
|
|
28394
28491
|
title,
|
|
28395
28492
|
metadata,
|
|
28396
28493
|
readCallback,
|
|
28494
|
+
scopeChallenge,
|
|
28397
28495
|
enabled: true,
|
|
28398
28496
|
disable: () => registeredResource.update({ enabled: false }),
|
|
28399
28497
|
enable: () => registeredResource.update({ enabled: true }),
|
|
@@ -28407,6 +28505,7 @@ var McpServer = class {
|
|
|
28407
28505
|
if (updates.title !== void 0) registeredResource.title = updates.title;
|
|
28408
28506
|
if (updates.metadata !== void 0) registeredResource.metadata = updates.metadata;
|
|
28409
28507
|
if (updates.callback !== void 0) registeredResource.readCallback = updates.callback;
|
|
28508
|
+
if (updates.scopeChallenge !== void 0) registeredResource.scopeChallenge = updates.scopeChallenge === null ? void 0 : updates.scopeChallenge;
|
|
28410
28509
|
if (updates.enabled !== void 0) registeredResource.enabled = updates.enabled;
|
|
28411
28510
|
this.sendResourceListChanged();
|
|
28412
28511
|
}
|
|
@@ -28414,12 +28513,13 @@ var McpServer = class {
|
|
|
28414
28513
|
this._registeredResources[uri] = registeredResource;
|
|
28415
28514
|
return registeredResource;
|
|
28416
28515
|
}
|
|
28417
|
-
_createRegisteredResourceTemplate(name, title, template, metadata, readCallback) {
|
|
28516
|
+
_createRegisteredResourceTemplate(name, title, template, metadata, scopeChallenge, readCallback) {
|
|
28418
28517
|
const registeredResourceTemplate = {
|
|
28419
28518
|
resourceTemplate: template,
|
|
28420
28519
|
title,
|
|
28421
28520
|
metadata,
|
|
28422
28521
|
readCallback,
|
|
28522
|
+
scopeChallenge,
|
|
28423
28523
|
enabled: true,
|
|
28424
28524
|
disable: () => registeredResourceTemplate.update({ enabled: false }),
|
|
28425
28525
|
enable: () => registeredResourceTemplate.update({ enabled: true }),
|
|
@@ -28433,6 +28533,7 @@ var McpServer = class {
|
|
|
28433
28533
|
if (updates.template !== void 0) registeredResourceTemplate.resourceTemplate = updates.template;
|
|
28434
28534
|
if (updates.metadata !== void 0) registeredResourceTemplate.metadata = updates.metadata;
|
|
28435
28535
|
if (updates.callback !== void 0) registeredResourceTemplate.readCallback = updates.callback;
|
|
28536
|
+
if (updates.scopeChallenge !== void 0) registeredResourceTemplate.scopeChallenge = updates.scopeChallenge === null ? void 0 : updates.scopeChallenge;
|
|
28436
28537
|
if (updates.enabled !== void 0) registeredResourceTemplate.enabled = updates.enabled;
|
|
28437
28538
|
this.sendResourceListChanged();
|
|
28438
28539
|
}
|
|
@@ -28442,7 +28543,7 @@ var McpServer = class {
|
|
|
28442
28543
|
if (Array.isArray(variableNames) && variableNames.some((v) => !!template.completeCallback(v))) this.setCompletionRequestHandler();
|
|
28443
28544
|
return registeredResourceTemplate;
|
|
28444
28545
|
}
|
|
28445
|
-
_createRegisteredPrompt(name, title, description, argsSchema, callback, icons, _meta) {
|
|
28546
|
+
_createRegisteredPrompt(name, title, description, argsSchema, callback, icons, scopeChallenge, _meta) {
|
|
28446
28547
|
let currentArgsSchema = argsSchema;
|
|
28447
28548
|
let currentCallback = callback;
|
|
28448
28549
|
const registeredPrompt = {
|
|
@@ -28450,6 +28551,7 @@ var McpServer = class {
|
|
|
28450
28551
|
description,
|
|
28451
28552
|
argsSchema,
|
|
28452
28553
|
icons,
|
|
28554
|
+
scopeChallenge,
|
|
28453
28555
|
_meta,
|
|
28454
28556
|
handler: createPromptHandler(name, argsSchema, callback),
|
|
28455
28557
|
enabled: true,
|
|
@@ -28464,6 +28566,7 @@ var McpServer = class {
|
|
|
28464
28566
|
if (updates.title !== void 0) registeredPrompt.title = updates.title;
|
|
28465
28567
|
if (updates.description !== void 0) registeredPrompt.description = updates.description;
|
|
28466
28568
|
if (updates.icons !== void 0) registeredPrompt.icons = updates.icons;
|
|
28569
|
+
if (updates.scopeChallenge !== void 0) registeredPrompt.scopeChallenge = updates.scopeChallenge === null ? void 0 : updates.scopeChallenge;
|
|
28467
28570
|
if (updates._meta !== void 0) registeredPrompt._meta = updates._meta;
|
|
28468
28571
|
let needsHandlerRegen = false;
|
|
28469
28572
|
if (updates.argsSchema !== void 0) {
|
|
@@ -28491,25 +28594,25 @@ var McpServer = class {
|
|
|
28491
28594
|
}
|
|
28492
28595
|
return registeredPrompt;
|
|
28493
28596
|
}
|
|
28494
|
-
_createRegisteredTool(name, title, description, inputSchema, outputSchema, annotations, icons, execution, _meta, handler) {
|
|
28597
|
+
_createRegisteredTool(name, title, description, inputSchema, outputSchema, annotations, icons, execution, scopeChallenge, _meta, handler) {
|
|
28495
28598
|
validateAndWarnToolName(name);
|
|
28496
|
-
if (inputSchema !== void 0) try {
|
|
28497
|
-
const json2 = standardSchemaToJsonSchema(inputSchema, "input");
|
|
28498
|
-
this._toolInputSchemaJson[name] = json2;
|
|
28499
|
-
const scan = scanXMcpHeaderDeclarations(json2);
|
|
28500
|
-
if (!scan.valid) console.warn(`[mcp-sdk] tool '${name}' carries an invalid x-mcp-header declaration and will be excluded by conforming Streamable HTTP clients: ${scan.reason}`);
|
|
28501
|
-
} catch {
|
|
28502
|
-
}
|
|
28503
28599
|
let currentHandler = handler;
|
|
28600
|
+
let outputSchemaJson;
|
|
28504
28601
|
const registeredTool = {
|
|
28505
28602
|
title,
|
|
28506
28603
|
description,
|
|
28507
28604
|
inputSchema,
|
|
28508
28605
|
outputSchema,
|
|
28509
|
-
outputSchemaJson
|
|
28606
|
+
get outputSchemaJson() {
|
|
28607
|
+
return outputSchemaJson ??= convertOutputSchemaJson(registeredTool.outputSchema);
|
|
28608
|
+
},
|
|
28609
|
+
set outputSchemaJson(value) {
|
|
28610
|
+
outputSchemaJson = value;
|
|
28611
|
+
},
|
|
28510
28612
|
annotations,
|
|
28511
28613
|
icons,
|
|
28512
28614
|
execution,
|
|
28615
|
+
scopeChallenge,
|
|
28513
28616
|
_meta,
|
|
28514
28617
|
handler,
|
|
28515
28618
|
executor: createToolExecutor(inputSchema, handler),
|
|
@@ -28548,6 +28651,7 @@ var McpServer = class {
|
|
|
28548
28651
|
}
|
|
28549
28652
|
if (updates.annotations !== void 0) registeredTool.annotations = updates.annotations;
|
|
28550
28653
|
if (updates.icons !== void 0) registeredTool.icons = updates.icons;
|
|
28654
|
+
if (updates.scopeChallenge !== void 0) registeredTool.scopeChallenge = updates.scopeChallenge === null ? void 0 : updates.scopeChallenge;
|
|
28551
28655
|
if (updates._meta !== void 0) registeredTool._meta = updates._meta;
|
|
28552
28656
|
if (updates.enabled !== void 0) registeredTool.enabled = updates.enabled;
|
|
28553
28657
|
this.sendToolListChanged();
|
|
@@ -28560,13 +28664,13 @@ var McpServer = class {
|
|
|
28560
28664
|
}
|
|
28561
28665
|
registerTool(name, config2, cb) {
|
|
28562
28666
|
if (this._registeredTools[name]) throw new Error(`Tool ${name} is already registered`);
|
|
28563
|
-
const { title, description, inputSchema, outputSchema, annotations, icons, _meta } = config2;
|
|
28564
|
-
return this._createRegisteredTool(name, title, description, normalizeRawShapeSchema(inputSchema), normalizeRawShapeSchema(outputSchema), annotations, icons, void 0, _meta, cb);
|
|
28667
|
+
const { title, description, inputSchema, outputSchema, annotations, icons, scopeChallenge, _meta } = config2;
|
|
28668
|
+
return this._createRegisteredTool(name, title, description, normalizeRawShapeSchema(inputSchema), normalizeRawShapeSchema(outputSchema), annotations, icons, void 0, scopeChallenge, _meta, cb);
|
|
28565
28669
|
}
|
|
28566
28670
|
registerPrompt(name, config2, cb) {
|
|
28567
28671
|
if (this._registeredPrompts[name]) throw new Error(`Prompt ${name} is already registered`);
|
|
28568
|
-
const { title, description, argsSchema, icons, _meta } = config2;
|
|
28569
|
-
const registeredPrompt = this._createRegisteredPrompt(name, title, description, normalizeRawShapeSchema(argsSchema), cb, icons, _meta);
|
|
28672
|
+
const { title, description, argsSchema, icons, scopeChallenge, _meta } = config2;
|
|
28673
|
+
const registeredPrompt = this._createRegisteredPrompt(name, title, description, normalizeRawShapeSchema(argsSchema), cb, icons, scopeChallenge, _meta);
|
|
28570
28674
|
this.setPromptRequestHandlers();
|
|
28571
28675
|
this.sendPromptListChanged();
|
|
28572
28676
|
return registeredPrompt;
|
|
@@ -28631,6 +28735,12 @@ var EMPTY_OBJECT_JSON_SCHEMA = {
|
|
|
28631
28735
|
type: "object",
|
|
28632
28736
|
properties: {}
|
|
28633
28737
|
};
|
|
28738
|
+
function convertListedInputSchema(name, inputSchema) {
|
|
28739
|
+
const json2 = standardSchemaToJsonSchema(inputSchema, "input");
|
|
28740
|
+
const scan = scanXMcpHeaderDeclarations(json2);
|
|
28741
|
+
if (!scan.valid) console.warn(`[mcp-sdk] tool '${name}' carries an invalid x-mcp-header declaration and will be excluded by conforming Streamable HTTP clients: ${scan.reason}`);
|
|
28742
|
+
return json2;
|
|
28743
|
+
}
|
|
28634
28744
|
function convertOutputSchemaJson(outputSchema) {
|
|
28635
28745
|
if (outputSchema === void 0) return void 0;
|
|
28636
28746
|
try {
|
|
@@ -28643,7 +28753,7 @@ function createPromptHandler(name, argsSchema, callback) {
|
|
|
28643
28753
|
if (argsSchema) {
|
|
28644
28754
|
const typedCallback = callback;
|
|
28645
28755
|
return async (args, ctx) => {
|
|
28646
|
-
const parseResult = await validateStandardSchema(argsSchema, args);
|
|
28756
|
+
const parseResult = await validateStandardSchema(argsSchema, args ?? {});
|
|
28647
28757
|
if (!parseResult.success) throw new ProtocolError(ProtocolErrorCode.InvalidParams, `Invalid arguments for prompt ${name}: ${parseResult.error}`);
|
|
28648
28758
|
return typedCallback(parseResult.data, ctx);
|
|
28649
28759
|
};
|
|
@@ -28677,7 +28787,11 @@ function unwrapOptionalSchema(schema) {
|
|
|
28677
28787
|
return schema.def?.innerType ?? schema;
|
|
28678
28788
|
}
|
|
28679
28789
|
|
|
28790
|
+
// node_modules/@modelcontextprotocol/server/dist/index.mjs
|
|
28791
|
+
var DEFAULT_MAX_REQUEST_BODY_SIZE = 4 * 1024 * 1024;
|
|
28792
|
+
|
|
28680
28793
|
// node_modules/@modelcontextprotocol/server/dist/stdio.mjs
|
|
28794
|
+
var swallowsErrorsAfterClose = /* @__PURE__ */ Symbol("swallowsErrorsAfterClose");
|
|
28681
28795
|
var StdioServerTransport = class {
|
|
28682
28796
|
_readBuffer;
|
|
28683
28797
|
_started = false;
|
|
@@ -28704,18 +28818,27 @@ var StdioServerTransport = class {
|
|
|
28704
28818
|
this.onerror?.(error51);
|
|
28705
28819
|
};
|
|
28706
28820
|
_onstdouterror = (error51) => {
|
|
28821
|
+
if (this._closed) return;
|
|
28707
28822
|
this.onerror?.(error51);
|
|
28708
28823
|
this.close().catch(() => {
|
|
28709
28824
|
});
|
|
28710
28825
|
};
|
|
28826
|
+
_onstdinclose = () => {
|
|
28827
|
+
this.close().catch(() => {
|
|
28828
|
+
});
|
|
28829
|
+
};
|
|
28711
28830
|
/**
|
|
28712
28831
|
* Starts listening for messages on `stdin`.
|
|
28713
28832
|
*/
|
|
28714
28833
|
async start() {
|
|
28715
28834
|
if (this._started) throw new Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");
|
|
28716
28835
|
this._started = true;
|
|
28836
|
+
for (const listener of this._stdout.listeners("error")) if (listener[swallowsErrorsAfterClose]) this._stdout.off("error", listener);
|
|
28837
|
+
if (this._stdin.readableEnded || this._stdin.destroyed) setImmediate(this._onstdinclose);
|
|
28717
28838
|
this._stdin.on("data", this._ondata);
|
|
28718
28839
|
this._stdin.on("error", this._onerror);
|
|
28840
|
+
this._stdin.on("end", this._onstdinclose);
|
|
28841
|
+
this._stdin.on("close", this._onstdinclose);
|
|
28719
28842
|
this._stdout.on("error", this._onstdouterror);
|
|
28720
28843
|
}
|
|
28721
28844
|
processReadBuffer() {
|
|
@@ -28732,7 +28855,9 @@ var StdioServerTransport = class {
|
|
|
28732
28855
|
this._closed = true;
|
|
28733
28856
|
this._stdin.off("data", this._ondata);
|
|
28734
28857
|
this._stdin.off("error", this._onerror);
|
|
28735
|
-
this.
|
|
28858
|
+
this._stdin.off("end", this._onstdinclose);
|
|
28859
|
+
this._stdin.off("close", this._onstdinclose);
|
|
28860
|
+
this._onstdouterror[swallowsErrorsAfterClose] = true;
|
|
28736
28861
|
if (this._stdin.listenerCount("data") === 0) this._stdin.pause();
|
|
28737
28862
|
this._readBuffer.clear();
|
|
28738
28863
|
this.onclose?.();
|
|
@@ -29009,6 +29134,7 @@ function serveStdio(factory, options = {}) {
|
|
|
29009
29134
|
return;
|
|
29010
29135
|
}
|
|
29011
29136
|
if (state.era === "modern" && await tryServeListen(message)) return;
|
|
29137
|
+
if (isTornDown()) return;
|
|
29012
29138
|
state.instance.channel.deliver(message);
|
|
29013
29139
|
return;
|
|
29014
29140
|
}
|
|
@@ -29075,6 +29201,7 @@ function serveStdio(factory, options = {}) {
|
|
|
29075
29201
|
};
|
|
29076
29202
|
}
|
|
29077
29203
|
if (await tryServeListen(message)) return;
|
|
29204
|
+
if (isTornDown()) return;
|
|
29078
29205
|
state.instance.channel.deliver(message, { classification: opening.classification });
|
|
29079
29206
|
return;
|
|
29080
29207
|
case "legacy": {
|