@alcyone-labs/arg-parser 1.1.0 → 1.2.0
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/README.md +150 -24
- package/dist/index.cjs +21863 -2500
- package/dist/index.cjs.map +1 -1
- package/dist/index.min.mjs +14541 -1827
- package/dist/index.min.mjs.map +1 -1
- package/dist/index.mjs +21865 -2502
- package/dist/index.mjs.map +1 -1
- package/dist/src/ArgParser.d.ts +2 -10
- package/dist/src/ArgParser.d.ts.map +1 -1
- package/dist/src/ArgParserBase.d.ts.map +1 -1
- package/dist/src/mcp-integration.d.ts.map +1 -1
- package/dist/src/types.d.ts +11 -0
- package/dist/src/types.d.ts.map +1 -1
- package/package.json +25 -5
- package/dist/examples/fuzzy-demo.d.ts +0 -8
- package/dist/examples/fuzzy-demo.d.ts.map +0 -1
- package/dist/examples/fuzzy-test-example.d.ts +0 -8
- package/dist/examples/fuzzy-test-example.d.ts.map +0 -1
- package/dist/examples/fzf-search-cli.d.ts +0 -8
- package/dist/examples/fzf-search-cli.d.ts.map +0 -1
- package/dist/examples/getting-started.d.ts +0 -27
- package/dist/examples/getting-started.d.ts.map +0 -1
- package/dist/examples/mcp-preset-transports.d.ts +0 -19
- package/dist/examples/mcp-preset-transports.d.ts.map +0 -1
- package/dist/examples/simple-cli.d.ts +0 -26
- package/dist/examples/simple-cli.d.ts.map +0 -1
- package/dist/examples/v1.1.0-showcase.d.ts +0 -16
- package/dist/examples/v1.1.0-showcase.d.ts.map +0 -1
- package/dist/examples/with-env-example.d.ts +0 -3
- package/dist/examples/with-env-example.d.ts.map +0 -1
- package/dist/index-6G9StDO_.js +0 -6445
- package/dist/index-6G9StDO_.js.map +0 -1
- package/dist/index-CqU7Fj3C.cjs +0 -6444
- package/dist/index-CqU7Fj3C.cjs.map +0 -1
- package/dist/index-Dx_q1msW.js +0 -4682
- package/dist/index-Dx_q1msW.js.map +0 -1
- package/dist/sse-B5Jf_YpG.cjs +0 -121
- package/dist/sse-B5Jf_YpG.cjs.map +0 -1
- package/dist/sse-BDL3h2Ll.js +0 -121
- package/dist/sse-BDL3h2Ll.js.map +0 -1
- package/dist/sse-DSjLfGFo.js +0 -107
- package/dist/sse-DSjLfGFo.js.map +0 -1
- package/dist/stdio-Cf19UQO7.js +0 -70
- package/dist/stdio-Cf19UQO7.js.map +0 -1
- package/dist/stdio-DESvSONI.cjs +0 -94
- package/dist/stdio-DESvSONI.cjs.map +0 -1
- package/dist/stdio-DLOResWr.js +0 -94
- package/dist/stdio-DLOResWr.js.map +0 -1
- package/dist/streamableHttp-DXIdDSbF.js +0 -342
- package/dist/streamableHttp-DXIdDSbF.js.map +0 -1
- package/dist/streamableHttp-DsXlAnqJ.cjs +0 -456
- package/dist/streamableHttp-DsXlAnqJ.cjs.map +0 -1
- package/dist/streamableHttp-Vd4Qsgko.js +0 -456
- package/dist/streamableHttp-Vd4Qsgko.js.map +0 -1
- package/dist/types-DSxPEImy.cjs +0 -943
- package/dist/types-DSxPEImy.cjs.map +0 -1
- package/dist/types-DdsPVLQ5.js +0 -846
- package/dist/types-DdsPVLQ5.js.map +0 -1
- package/dist/types-DpK81FWv.js +0 -944
- package/dist/types-DpK81FWv.js.map +0 -1
package/dist/sse-B5Jf_YpG.cjs
DELETED
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const node_crypto = require("node:crypto");
|
|
4
|
-
const types = require("./types-DSxPEImy.cjs");
|
|
5
|
-
const index = require("./index-CqU7Fj3C.cjs");
|
|
6
|
-
const url = require("url");
|
|
7
|
-
const MAXIMUM_MESSAGE_SIZE = "4mb";
|
|
8
|
-
class SSEServerTransport {
|
|
9
|
-
/**
|
|
10
|
-
* Creates a new SSE server transport, which will direct the client to POST messages to the relative or absolute URL identified by `_endpoint`.
|
|
11
|
-
*/
|
|
12
|
-
constructor(_endpoint, res) {
|
|
13
|
-
this._endpoint = _endpoint;
|
|
14
|
-
this.res = res;
|
|
15
|
-
this._sessionId = node_crypto.randomUUID();
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Handles the initial SSE connection request.
|
|
19
|
-
*
|
|
20
|
-
* This should be called when a GET request is made to establish the SSE stream.
|
|
21
|
-
*/
|
|
22
|
-
async start() {
|
|
23
|
-
if (this._sseResponse) {
|
|
24
|
-
throw new Error("SSEServerTransport already started! If using Server class, note that connect() calls start() automatically.");
|
|
25
|
-
}
|
|
26
|
-
this.res.writeHead(200, {
|
|
27
|
-
"Content-Type": "text/event-stream",
|
|
28
|
-
"Cache-Control": "no-cache, no-transform",
|
|
29
|
-
Connection: "keep-alive"
|
|
30
|
-
});
|
|
31
|
-
const dummyBase = "http://localhost";
|
|
32
|
-
const endpointUrl = new url.URL(this._endpoint, dummyBase);
|
|
33
|
-
endpointUrl.searchParams.set("sessionId", this._sessionId);
|
|
34
|
-
const relativeUrlWithSession = endpointUrl.pathname + endpointUrl.search + endpointUrl.hash;
|
|
35
|
-
this.res.write(`event: endpoint
|
|
36
|
-
data: ${relativeUrlWithSession}
|
|
37
|
-
|
|
38
|
-
`);
|
|
39
|
-
this._sseResponse = this.res;
|
|
40
|
-
this.res.on("close", () => {
|
|
41
|
-
var _a;
|
|
42
|
-
this._sseResponse = void 0;
|
|
43
|
-
(_a = this.onclose) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Handles incoming POST messages.
|
|
48
|
-
*
|
|
49
|
-
* This should be called when a POST request is made to send a message to the server.
|
|
50
|
-
*/
|
|
51
|
-
async handlePostMessage(req, res, parsedBody) {
|
|
52
|
-
var _a, _b, _c;
|
|
53
|
-
if (!this._sseResponse) {
|
|
54
|
-
const message = "SSE connection not established";
|
|
55
|
-
res.writeHead(500).end(message);
|
|
56
|
-
throw new Error(message);
|
|
57
|
-
}
|
|
58
|
-
const authInfo = req.auth;
|
|
59
|
-
let body;
|
|
60
|
-
try {
|
|
61
|
-
const ct = index.contentType.parse((_a = req.headers["content-type"]) !== null && _a !== void 0 ? _a : "");
|
|
62
|
-
if (ct.type !== "application/json") {
|
|
63
|
-
throw new Error(`Unsupported content-type: ${ct}`);
|
|
64
|
-
}
|
|
65
|
-
body = parsedBody !== null && parsedBody !== void 0 ? parsedBody : await index.getRawBody(req, {
|
|
66
|
-
limit: MAXIMUM_MESSAGE_SIZE,
|
|
67
|
-
encoding: (_b = ct.parameters.charset) !== null && _b !== void 0 ? _b : "utf-8"
|
|
68
|
-
});
|
|
69
|
-
} catch (error) {
|
|
70
|
-
res.writeHead(400).end(String(error));
|
|
71
|
-
(_c = this.onerror) === null || _c === void 0 ? void 0 : _c.call(this, error);
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
try {
|
|
75
|
-
await this.handleMessage(typeof body === "string" ? JSON.parse(body) : body, { authInfo });
|
|
76
|
-
} catch (_d) {
|
|
77
|
-
res.writeHead(400).end(`Invalid message: ${body}`);
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
res.writeHead(202).end("Accepted");
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* 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.
|
|
84
|
-
*/
|
|
85
|
-
async handleMessage(message, extra) {
|
|
86
|
-
var _a, _b;
|
|
87
|
-
let parsedMessage;
|
|
88
|
-
try {
|
|
89
|
-
parsedMessage = types.JSONRPCMessageSchema.parse(message);
|
|
90
|
-
} catch (error) {
|
|
91
|
-
(_a = this.onerror) === null || _a === void 0 ? void 0 : _a.call(this, error);
|
|
92
|
-
throw error;
|
|
93
|
-
}
|
|
94
|
-
(_b = this.onmessage) === null || _b === void 0 ? void 0 : _b.call(this, parsedMessage, extra);
|
|
95
|
-
}
|
|
96
|
-
async close() {
|
|
97
|
-
var _a, _b;
|
|
98
|
-
(_a = this._sseResponse) === null || _a === void 0 ? void 0 : _a.end();
|
|
99
|
-
this._sseResponse = void 0;
|
|
100
|
-
(_b = this.onclose) === null || _b === void 0 ? void 0 : _b.call(this);
|
|
101
|
-
}
|
|
102
|
-
async send(message) {
|
|
103
|
-
if (!this._sseResponse) {
|
|
104
|
-
throw new Error("Not connected");
|
|
105
|
-
}
|
|
106
|
-
this._sseResponse.write(`event: message
|
|
107
|
-
data: ${JSON.stringify(message)}
|
|
108
|
-
|
|
109
|
-
`);
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* Returns the session ID for this transport.
|
|
113
|
-
*
|
|
114
|
-
* This can be used to route incoming POST requests.
|
|
115
|
-
*/
|
|
116
|
-
get sessionId() {
|
|
117
|
-
return this._sessionId;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
exports.SSEServerTransport = SSEServerTransport;
|
|
121
|
-
//# sourceMappingURL=sse-B5Jf_YpG.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sse-B5Jf_YpG.cjs","sources":["../node_modules/.pnpm/@modelcontextprotocol+sdk@1.13.1/node_modules/@modelcontextprotocol/sdk/dist/esm/server/sse.js"],"sourcesContent":["import { randomUUID } from \"node:crypto\";\nimport { JSONRPCMessageSchema } from \"../types.js\";\nimport getRawBody from \"raw-body\";\nimport contentType from \"content-type\";\nimport { URL } from 'url';\nconst MAXIMUM_MESSAGE_SIZE = \"4mb\";\n/**\n * Server transport for SSE: this will send messages over an SSE connection and receive messages from HTTP POST requests.\n *\n * This transport is only available in Node.js environments.\n */\nexport class SSEServerTransport {\n /**\n * Creates a new SSE server transport, which will direct the client to POST messages to the relative or absolute URL identified by `_endpoint`.\n */\n constructor(_endpoint, res) {\n this._endpoint = _endpoint;\n this.res = res;\n this._sessionId = randomUUID();\n }\n /**\n * Handles the initial SSE connection request.\n *\n * This should be called when a GET request is made to establish the SSE stream.\n */\n async start() {\n if (this._sseResponse) {\n throw new Error(\"SSEServerTransport already started! If using Server class, note that connect() calls start() automatically.\");\n }\n this.res.writeHead(200, {\n \"Content-Type\": \"text/event-stream\",\n \"Cache-Control\": \"no-cache, no-transform\",\n Connection: \"keep-alive\",\n });\n // Send the endpoint event\n // Use a dummy base URL because this._endpoint is relative.\n // This allows using URL/URLSearchParams for robust parameter handling.\n const dummyBase = 'http://localhost'; // Any valid base works\n const endpointUrl = new URL(this._endpoint, dummyBase);\n endpointUrl.searchParams.set('sessionId', this._sessionId);\n // Reconstruct the relative URL string (pathname + search + hash)\n const relativeUrlWithSession = endpointUrl.pathname + endpointUrl.search + endpointUrl.hash;\n this.res.write(`event: endpoint\\ndata: ${relativeUrlWithSession}\\n\\n`);\n this._sseResponse = this.res;\n this.res.on(\"close\", () => {\n var _a;\n this._sseResponse = undefined;\n (_a = this.onclose) === null || _a === void 0 ? void 0 : _a.call(this);\n });\n }\n /**\n * Handles incoming POST messages.\n *\n * This should be called when a POST request is made to send a message to the server.\n */\n async handlePostMessage(req, res, parsedBody) {\n var _a, _b, _c;\n if (!this._sseResponse) {\n const message = \"SSE connection not established\";\n res.writeHead(500).end(message);\n throw new Error(message);\n }\n const authInfo = req.auth;\n let body;\n try {\n const ct = contentType.parse((_a = req.headers[\"content-type\"]) !== null && _a !== void 0 ? _a : \"\");\n if (ct.type !== \"application/json\") {\n throw new Error(`Unsupported content-type: ${ct}`);\n }\n body = parsedBody !== null && parsedBody !== void 0 ? parsedBody : await getRawBody(req, {\n limit: MAXIMUM_MESSAGE_SIZE,\n encoding: (_b = ct.parameters.charset) !== null && _b !== void 0 ? _b : \"utf-8\",\n });\n }\n catch (error) {\n res.writeHead(400).end(String(error));\n (_c = this.onerror) === null || _c === void 0 ? void 0 : _c.call(this, error);\n return;\n }\n try {\n await this.handleMessage(typeof body === 'string' ? JSON.parse(body) : body, { authInfo });\n }\n catch (_d) {\n res.writeHead(400).end(`Invalid message: ${body}`);\n return;\n }\n res.writeHead(202).end(\"Accepted\");\n }\n /**\n * 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.\n */\n async handleMessage(message, extra) {\n var _a, _b;\n let parsedMessage;\n try {\n parsedMessage = JSONRPCMessageSchema.parse(message);\n }\n catch (error) {\n (_a = this.onerror) === null || _a === void 0 ? void 0 : _a.call(this, error);\n throw error;\n }\n (_b = this.onmessage) === null || _b === void 0 ? void 0 : _b.call(this, parsedMessage, extra);\n }\n async close() {\n var _a, _b;\n (_a = this._sseResponse) === null || _a === void 0 ? void 0 : _a.end();\n this._sseResponse = undefined;\n (_b = this.onclose) === null || _b === void 0 ? void 0 : _b.call(this);\n }\n async send(message) {\n if (!this._sseResponse) {\n throw new Error(\"Not connected\");\n }\n this._sseResponse.write(`event: message\\ndata: ${JSON.stringify(message)}\\n\\n`);\n }\n /**\n * Returns the session ID for this transport.\n *\n * This can be used to route incoming POST requests.\n */\n get sessionId() {\n return this._sessionId;\n }\n}\n//# sourceMappingURL=sse.js.map"],"names":["randomUUID","URL","contentType","getRawBody","JSONRPCMessageSchema"],"mappings":";;;;;;AAKA,MAAM,uBAAuB;AAMtB,MAAM,mBAAmB;AAAA;AAAA;AAAA;AAAA,EAI5B,YAAY,WAAW,KAAK;AACxB,SAAK,YAAY;AACjB,SAAK,MAAM;AACX,SAAK,aAAaA,uBAAU;AAAA,EACpC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMI,MAAM,QAAQ;AACV,QAAI,KAAK,cAAc;AACnB,YAAM,IAAI,MAAM,6GAA6G;AAAA,IACzI;AACQ,SAAK,IAAI,UAAU,KAAK;AAAA,MACpB,gBAAgB;AAAA,MAChB,iBAAiB;AAAA,MACjB,YAAY;AAAA,IACxB,CAAS;AAID,UAAM,YAAY;AAClB,UAAM,cAAc,IAAIC,IAAAA,IAAI,KAAK,WAAW,SAAS;AACrD,gBAAY,aAAa,IAAI,aAAa,KAAK,UAAU;AAEzD,UAAM,yBAAyB,YAAY,WAAW,YAAY,SAAS,YAAY;AACvF,SAAK,IAAI,MAAM;AAAA,QAA0B,sBAAsB;A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I,UAAU,GAAG,EAAE,IAAI,UAAU;AAAA,EACzC;AAAA;AAAA;AAAA;AAAA,EAII,MAAM,cAAc,SAAS,OAAO;AAChC,QAAI,IAAI;AACR,QAAI;AACJ,QAAI;AACA,sBAAgBC,MAAAA,qBAAqB,MAAM,OAAO;AAAA,IAC9D,SACe,OAAO;AACV,OAAC,KAAK,KAAK,aAAa,QAAQ,OAAO,SAAS,SAAS,GAAG,KAAK,MAAM,KAAK;AAC5E,YAAM;AAAA,IAClB;AACQ,KAAC,KAAK,KAAK,eAAe,QAAQ,OAAO,SAAS,SAAS,GAAG,KAAK,MAAM,eAAe,KAAK;AAAA,EACrG;AAAA,EACI,MAAM,QAAQ;AACV,QAAI,IAAI;AACR,KAAC,KAAK,KAAK,kBAAkB,QAAQ,OAAO,SAAS,SAAS,GAAG,IAAG;AACpE,SAAK,eAAe;AACpB,KAAC,KAAK,KAAK,aAAa,QAAQ,OAAO,SAAS,SAAS,GAAG,KAAK,IAAI;AAAA,EAC7E;AAAA,EACI,MAAM,KAAK,SAAS;AAChB,QAAI,CAAC,KAAK,cAAc;AACpB,YAAM,IAAI,MAAM,eAAe;AAAA,IAC3C;AACQ,SAAK,aAAa,MAAM;AAAA,QAAyB,KAAK,UAAU,OAAO,CAAC;AAAA;AAAA,CAAM;AAAA,EACtF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMI,IAAI,YAAY;AACZ,WAAO,KAAK;AAAA,EACpB;AACA;;","x_google_ignoreList":[0]}
|
package/dist/sse-BDL3h2Ll.js
DELETED
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import { randomUUID } from "node:crypto";
|
|
2
|
-
import { J as JSONRPCMessageSchema } from "./types-DpK81FWv.js";
|
|
3
|
-
import { c as contentType, g as getRawBody } from "./index-6G9StDO_.js";
|
|
4
|
-
import { URL } from "url";
|
|
5
|
-
const MAXIMUM_MESSAGE_SIZE = "4mb";
|
|
6
|
-
class SSEServerTransport {
|
|
7
|
-
/**
|
|
8
|
-
* Creates a new SSE server transport, which will direct the client to POST messages to the relative or absolute URL identified by `_endpoint`.
|
|
9
|
-
*/
|
|
10
|
-
constructor(_endpoint, res) {
|
|
11
|
-
this._endpoint = _endpoint;
|
|
12
|
-
this.res = res;
|
|
13
|
-
this._sessionId = randomUUID();
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Handles the initial SSE connection request.
|
|
17
|
-
*
|
|
18
|
-
* This should be called when a GET request is made to establish the SSE stream.
|
|
19
|
-
*/
|
|
20
|
-
async start() {
|
|
21
|
-
if (this._sseResponse) {
|
|
22
|
-
throw new Error("SSEServerTransport already started! If using Server class, note that connect() calls start() automatically.");
|
|
23
|
-
}
|
|
24
|
-
this.res.writeHead(200, {
|
|
25
|
-
"Content-Type": "text/event-stream",
|
|
26
|
-
"Cache-Control": "no-cache, no-transform",
|
|
27
|
-
Connection: "keep-alive"
|
|
28
|
-
});
|
|
29
|
-
const dummyBase = "http://localhost";
|
|
30
|
-
const endpointUrl = new URL(this._endpoint, dummyBase);
|
|
31
|
-
endpointUrl.searchParams.set("sessionId", this._sessionId);
|
|
32
|
-
const relativeUrlWithSession = endpointUrl.pathname + endpointUrl.search + endpointUrl.hash;
|
|
33
|
-
this.res.write(`event: endpoint
|
|
34
|
-
data: ${relativeUrlWithSession}
|
|
35
|
-
|
|
36
|
-
`);
|
|
37
|
-
this._sseResponse = this.res;
|
|
38
|
-
this.res.on("close", () => {
|
|
39
|
-
var _a;
|
|
40
|
-
this._sseResponse = void 0;
|
|
41
|
-
(_a = this.onclose) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Handles incoming POST messages.
|
|
46
|
-
*
|
|
47
|
-
* This should be called when a POST request is made to send a message to the server.
|
|
48
|
-
*/
|
|
49
|
-
async handlePostMessage(req, res, parsedBody) {
|
|
50
|
-
var _a, _b, _c;
|
|
51
|
-
if (!this._sseResponse) {
|
|
52
|
-
const message = "SSE connection not established";
|
|
53
|
-
res.writeHead(500).end(message);
|
|
54
|
-
throw new Error(message);
|
|
55
|
-
}
|
|
56
|
-
const authInfo = req.auth;
|
|
57
|
-
let body;
|
|
58
|
-
try {
|
|
59
|
-
const ct = contentType.parse((_a = req.headers["content-type"]) !== null && _a !== void 0 ? _a : "");
|
|
60
|
-
if (ct.type !== "application/json") {
|
|
61
|
-
throw new Error(`Unsupported content-type: ${ct}`);
|
|
62
|
-
}
|
|
63
|
-
body = parsedBody !== null && parsedBody !== void 0 ? parsedBody : await getRawBody(req, {
|
|
64
|
-
limit: MAXIMUM_MESSAGE_SIZE,
|
|
65
|
-
encoding: (_b = ct.parameters.charset) !== null && _b !== void 0 ? _b : "utf-8"
|
|
66
|
-
});
|
|
67
|
-
} catch (error) {
|
|
68
|
-
res.writeHead(400).end(String(error));
|
|
69
|
-
(_c = this.onerror) === null || _c === void 0 ? void 0 : _c.call(this, error);
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
try {
|
|
73
|
-
await this.handleMessage(typeof body === "string" ? JSON.parse(body) : body, { authInfo });
|
|
74
|
-
} catch (_d) {
|
|
75
|
-
res.writeHead(400).end(`Invalid message: ${body}`);
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
res.writeHead(202).end("Accepted");
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* 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.
|
|
82
|
-
*/
|
|
83
|
-
async handleMessage(message, extra) {
|
|
84
|
-
var _a, _b;
|
|
85
|
-
let parsedMessage;
|
|
86
|
-
try {
|
|
87
|
-
parsedMessage = JSONRPCMessageSchema.parse(message);
|
|
88
|
-
} catch (error) {
|
|
89
|
-
(_a = this.onerror) === null || _a === void 0 ? void 0 : _a.call(this, error);
|
|
90
|
-
throw error;
|
|
91
|
-
}
|
|
92
|
-
(_b = this.onmessage) === null || _b === void 0 ? void 0 : _b.call(this, parsedMessage, extra);
|
|
93
|
-
}
|
|
94
|
-
async close() {
|
|
95
|
-
var _a, _b;
|
|
96
|
-
(_a = this._sseResponse) === null || _a === void 0 ? void 0 : _a.end();
|
|
97
|
-
this._sseResponse = void 0;
|
|
98
|
-
(_b = this.onclose) === null || _b === void 0 ? void 0 : _b.call(this);
|
|
99
|
-
}
|
|
100
|
-
async send(message) {
|
|
101
|
-
if (!this._sseResponse) {
|
|
102
|
-
throw new Error("Not connected");
|
|
103
|
-
}
|
|
104
|
-
this._sseResponse.write(`event: message
|
|
105
|
-
data: ${JSON.stringify(message)}
|
|
106
|
-
|
|
107
|
-
`);
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* Returns the session ID for this transport.
|
|
111
|
-
*
|
|
112
|
-
* This can be used to route incoming POST requests.
|
|
113
|
-
*/
|
|
114
|
-
get sessionId() {
|
|
115
|
-
return this._sessionId;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
export {
|
|
119
|
-
SSEServerTransport
|
|
120
|
-
};
|
|
121
|
-
//# sourceMappingURL=sse-BDL3h2Ll.js.map
|
package/dist/sse-BDL3h2Ll.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sse-BDL3h2Ll.js","sources":["../node_modules/.pnpm/@modelcontextprotocol+sdk@1.13.1/node_modules/@modelcontextprotocol/sdk/dist/esm/server/sse.js"],"sourcesContent":["import { randomUUID } from \"node:crypto\";\nimport { JSONRPCMessageSchema } from \"../types.js\";\nimport getRawBody from \"raw-body\";\nimport contentType from \"content-type\";\nimport { URL } from 'url';\nconst MAXIMUM_MESSAGE_SIZE = \"4mb\";\n/**\n * Server transport for SSE: this will send messages over an SSE connection and receive messages from HTTP POST requests.\n *\n * This transport is only available in Node.js environments.\n */\nexport class SSEServerTransport {\n /**\n * Creates a new SSE server transport, which will direct the client to POST messages to the relative or absolute URL identified by `_endpoint`.\n */\n constructor(_endpoint, res) {\n this._endpoint = _endpoint;\n this.res = res;\n this._sessionId = randomUUID();\n }\n /**\n * Handles the initial SSE connection request.\n *\n * This should be called when a GET request is made to establish the SSE stream.\n */\n async start() {\n if (this._sseResponse) {\n throw new Error(\"SSEServerTransport already started! If using Server class, note that connect() calls start() automatically.\");\n }\n this.res.writeHead(200, {\n \"Content-Type\": \"text/event-stream\",\n \"Cache-Control\": \"no-cache, no-transform\",\n Connection: \"keep-alive\",\n });\n // Send the endpoint event\n // Use a dummy base URL because this._endpoint is relative.\n // This allows using URL/URLSearchParams for robust parameter handling.\n const dummyBase = 'http://localhost'; // Any valid base works\n const endpointUrl = new URL(this._endpoint, dummyBase);\n endpointUrl.searchParams.set('sessionId', this._sessionId);\n // Reconstruct the relative URL string (pathname + search + hash)\n const relativeUrlWithSession = endpointUrl.pathname + endpointUrl.search + endpointUrl.hash;\n this.res.write(`event: endpoint\\ndata: ${relativeUrlWithSession}\\n\\n`);\n this._sseResponse = this.res;\n this.res.on(\"close\", () => {\n var _a;\n this._sseResponse = undefined;\n (_a = this.onclose) === null || _a === void 0 ? void 0 : _a.call(this);\n });\n }\n /**\n * Handles incoming POST messages.\n *\n * This should be called when a POST request is made to send a message to the server.\n */\n async handlePostMessage(req, res, parsedBody) {\n var _a, _b, _c;\n if (!this._sseResponse) {\n const message = \"SSE connection not established\";\n res.writeHead(500).end(message);\n throw new Error(message);\n }\n const authInfo = req.auth;\n let body;\n try {\n const ct = contentType.parse((_a = req.headers[\"content-type\"]) !== null && _a !== void 0 ? _a : \"\");\n if (ct.type !== \"application/json\") {\n throw new Error(`Unsupported content-type: ${ct}`);\n }\n body = parsedBody !== null && parsedBody !== void 0 ? parsedBody : await getRawBody(req, {\n limit: MAXIMUM_MESSAGE_SIZE,\n encoding: (_b = ct.parameters.charset) !== null && _b !== void 0 ? _b : \"utf-8\",\n });\n }\n catch (error) {\n res.writeHead(400).end(String(error));\n (_c = this.onerror) === null || _c === void 0 ? void 0 : _c.call(this, error);\n return;\n }\n try {\n await this.handleMessage(typeof body === 'string' ? JSON.parse(body) : body, { authInfo });\n }\n catch (_d) {\n res.writeHead(400).end(`Invalid message: ${body}`);\n return;\n }\n res.writeHead(202).end(\"Accepted\");\n }\n /**\n * 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.\n */\n async handleMessage(message, extra) {\n var _a, _b;\n let parsedMessage;\n try {\n parsedMessage = JSONRPCMessageSchema.parse(message);\n }\n catch (error) {\n (_a = this.onerror) === null || _a === void 0 ? void 0 : _a.call(this, error);\n throw error;\n }\n (_b = this.onmessage) === null || _b === void 0 ? void 0 : _b.call(this, parsedMessage, extra);\n }\n async close() {\n var _a, _b;\n (_a = this._sseResponse) === null || _a === void 0 ? void 0 : _a.end();\n this._sseResponse = undefined;\n (_b = this.onclose) === null || _b === void 0 ? void 0 : _b.call(this);\n }\n async send(message) {\n if (!this._sseResponse) {\n throw new Error(\"Not connected\");\n }\n this._sseResponse.write(`event: message\\ndata: ${JSON.stringify(message)}\\n\\n`);\n }\n /**\n * Returns the session ID for this transport.\n *\n * This can be used to route incoming POST requests.\n */\n get sessionId() {\n return this._sessionId;\n }\n}\n//# sourceMappingURL=sse.js.map"],"names":[],"mappings":";;;;AAKA,MAAM,uBAAuB;AAMtB,MAAM,mBAAmB;AAAA;AAAA;AAAA;AAAA,EAI5B,YAAY,WAAW,KAAK;AACxB,SAAK,YAAY;AACjB,SAAK,MAAM;AACX,SAAK,aAAa,WAAU;AAAA,EACpC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMI,MAAM,QAAQ;AACV,QAAI,KAAK,cAAc;AACnB,YAAM,IAAI,MAAM,6GAA6G;AAAA,IACzI;AACQ,SAAK,IAAI,UAAU,KAAK;AAAA,MACpB,gBAAgB;AAAA,MAChB,iBAAiB;AAAA,MACjB,YAAY;AAAA,IACxB,CAAS;AAID,UAAM,YAAY;AAClB,UAAM,cAAc,IAAI,IAAI,KAAK,WAAW,SAAS;AACrD,gBAAY,aAAa,IAAI,aAAa,KAAK,UAAU;AAEzD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AI,UAAU,GAAG,EAAE,IAAI,oBAAoB,IAAI,EAAE;AACjD;AAAA,IACZ;AACQ,QAAI,UAAU,GAAG,EAAE,IAAI,UAAU;AAAA,EACzC;AAAA;AAAA;AAAA;AAAA,EAII,MAAM,cAAc,SAAS,OAAO;AAChC,QAAI,IAAI;AACR,QAAI;AACJ,QAAI;AACA,sBAAgB,qBAAqB,MAAM,OAAO;AAAA,IAC9D,SACe,OAAO;AACV,OAAC,KAAK,KAAK,aAAa,QAAQ,OAAO,SAAS,SAAS,GAAG,KAAK,MAAM,KAAK;AAC5E,YAAM;AAAA,IAClB;AACQ,KAAC,KAAK,KAAK,eAAe,QAAQ,OAAO,SAAS,SAAS,GAAG,KAAK,MAAM,eAAe,KAAK;AAAA,EACrG;AAAA,EACI,MAAM,QAAQ;AACV,QAAI,IAAI;AACR,KAAC,KAAK,KAAK,kBAAkB,QAAQ,OAAO,SAAS,SAAS,GAAG,IAAG;AACpE,SAAK,eAAe;AACpB,KAAC,KAAK,KAAK,aAAa,QAAQ,OAAO,SAAS,SAAS,GAAG,KAAK,IAAI;AAAA,EAC7E;AAAA,EACI,MAAM,KAAK,SAAS;AAChB,QAAI,CAAC,KAAK,cAAc;AACpB,YAAM,IAAI,MAAM,eAAe;AAAA,IAC3C;AACQ,SAAK,aAAa,MAAM;AAAA,QAAyB,KAAK,UAAU,OAAO,CAAC;AAAA;AAAA,CAAM;AAAA,EACtF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMI,IAAI,YAAY;AACZ,WAAO,KAAK;AAAA,EACpB;AACA;","x_google_ignoreList":[0]}
|
package/dist/sse-DSjLfGFo.js
DELETED
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import { randomUUID as h } from "node:crypto";
|
|
2
|
-
import { J as d } from "./types-DdsPVLQ5.js";
|
|
3
|
-
import { c as l, g as p } from "./index-Dx_q1msW.js";
|
|
4
|
-
import { URL as v } from "url";
|
|
5
|
-
const m = "4mb";
|
|
6
|
-
class g {
|
|
7
|
-
/**
|
|
8
|
-
* Creates a new SSE server transport, which will direct the client to POST messages to the relative or absolute URL identified by `_endpoint`.
|
|
9
|
-
*/
|
|
10
|
-
constructor(s, e) {
|
|
11
|
-
this._endpoint = s, this.res = e, this._sessionId = h();
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Handles the initial SSE connection request.
|
|
15
|
-
*
|
|
16
|
-
* This should be called when a GET request is made to establish the SSE stream.
|
|
17
|
-
*/
|
|
18
|
-
async start() {
|
|
19
|
-
if (this._sseResponse)
|
|
20
|
-
throw new Error("SSEServerTransport already started! If using Server class, note that connect() calls start() automatically.");
|
|
21
|
-
this.res.writeHead(200, {
|
|
22
|
-
"Content-Type": "text/event-stream",
|
|
23
|
-
"Cache-Control": "no-cache, no-transform",
|
|
24
|
-
Connection: "keep-alive"
|
|
25
|
-
});
|
|
26
|
-
const s = "http://localhost", e = new v(this._endpoint, s);
|
|
27
|
-
e.searchParams.set("sessionId", this._sessionId);
|
|
28
|
-
const o = e.pathname + e.search + e.hash;
|
|
29
|
-
this.res.write(`event: endpoint
|
|
30
|
-
data: ${o}
|
|
31
|
-
|
|
32
|
-
`), this._sseResponse = this.res, this.res.on("close", () => {
|
|
33
|
-
var t;
|
|
34
|
-
this._sseResponse = void 0, (t = this.onclose) === null || t === void 0 || t.call(this);
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Handles incoming POST messages.
|
|
39
|
-
*
|
|
40
|
-
* This should be called when a POST request is made to send a message to the server.
|
|
41
|
-
*/
|
|
42
|
-
async handlePostMessage(s, e, o) {
|
|
43
|
-
var t, r, a;
|
|
44
|
-
if (!this._sseResponse) {
|
|
45
|
-
const n = "SSE connection not established";
|
|
46
|
-
throw e.writeHead(500).end(n), new Error(n);
|
|
47
|
-
}
|
|
48
|
-
const c = s.auth;
|
|
49
|
-
let i;
|
|
50
|
-
try {
|
|
51
|
-
const n = l.parse((t = s.headers["content-type"]) !== null && t !== void 0 ? t : "");
|
|
52
|
-
if (n.type !== "application/json")
|
|
53
|
-
throw new Error(`Unsupported content-type: ${n}`);
|
|
54
|
-
i = o ?? await p(s, {
|
|
55
|
-
limit: m,
|
|
56
|
-
encoding: (r = n.parameters.charset) !== null && r !== void 0 ? r : "utf-8"
|
|
57
|
-
});
|
|
58
|
-
} catch (n) {
|
|
59
|
-
e.writeHead(400).end(String(n)), (a = this.onerror) === null || a === void 0 || a.call(this, n);
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
try {
|
|
63
|
-
await this.handleMessage(typeof i == "string" ? JSON.parse(i) : i, { authInfo: c });
|
|
64
|
-
} catch {
|
|
65
|
-
e.writeHead(400).end(`Invalid message: ${i}`);
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
e.writeHead(202).end("Accepted");
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* 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.
|
|
72
|
-
*/
|
|
73
|
-
async handleMessage(s, e) {
|
|
74
|
-
var o, t;
|
|
75
|
-
let r;
|
|
76
|
-
try {
|
|
77
|
-
r = d.parse(s);
|
|
78
|
-
} catch (a) {
|
|
79
|
-
throw (o = this.onerror) === null || o === void 0 || o.call(this, a), a;
|
|
80
|
-
}
|
|
81
|
-
(t = this.onmessage) === null || t === void 0 || t.call(this, r, e);
|
|
82
|
-
}
|
|
83
|
-
async close() {
|
|
84
|
-
var s, e;
|
|
85
|
-
(s = this._sseResponse) === null || s === void 0 || s.end(), this._sseResponse = void 0, (e = this.onclose) === null || e === void 0 || e.call(this);
|
|
86
|
-
}
|
|
87
|
-
async send(s) {
|
|
88
|
-
if (!this._sseResponse)
|
|
89
|
-
throw new Error("Not connected");
|
|
90
|
-
this._sseResponse.write(`event: message
|
|
91
|
-
data: ${JSON.stringify(s)}
|
|
92
|
-
|
|
93
|
-
`);
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Returns the session ID for this transport.
|
|
97
|
-
*
|
|
98
|
-
* This can be used to route incoming POST requests.
|
|
99
|
-
*/
|
|
100
|
-
get sessionId() {
|
|
101
|
-
return this._sessionId;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
export {
|
|
105
|
-
g as SSEServerTransport
|
|
106
|
-
};
|
|
107
|
-
//# sourceMappingURL=sse-DSjLfGFo.js.map
|
package/dist/sse-DSjLfGFo.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sse-DSjLfGFo.js","sources":["../node_modules/.pnpm/@modelcontextprotocol+sdk@1.13.1/node_modules/@modelcontextprotocol/sdk/dist/esm/server/sse.js"],"sourcesContent":["import { randomUUID } from \"node:crypto\";\nimport { JSONRPCMessageSchema } from \"../types.js\";\nimport getRawBody from \"raw-body\";\nimport contentType from \"content-type\";\nimport { URL } from 'url';\nconst MAXIMUM_MESSAGE_SIZE = \"4mb\";\n/**\n * Server transport for SSE: this will send messages over an SSE connection and receive messages from HTTP POST requests.\n *\n * This transport is only available in Node.js environments.\n */\nexport class SSEServerTransport {\n /**\n * Creates a new SSE server transport, which will direct the client to POST messages to the relative or absolute URL identified by `_endpoint`.\n */\n constructor(_endpoint, res) {\n this._endpoint = _endpoint;\n this.res = res;\n this._sessionId = randomUUID();\n }\n /**\n * Handles the initial SSE connection request.\n *\n * This should be called when a GET request is made to establish the SSE stream.\n */\n async start() {\n if (this._sseResponse) {\n throw new Error(\"SSEServerTransport already started! If using Server class, note that connect() calls start() automatically.\");\n }\n this.res.writeHead(200, {\n \"Content-Type\": \"text/event-stream\",\n \"Cache-Control\": \"no-cache, no-transform\",\n Connection: \"keep-alive\",\n });\n // Send the endpoint event\n // Use a dummy base URL because this._endpoint is relative.\n // This allows using URL/URLSearchParams for robust parameter handling.\n const dummyBase = 'http://localhost'; // Any valid base works\n const endpointUrl = new URL(this._endpoint, dummyBase);\n endpointUrl.searchParams.set('sessionId', this._sessionId);\n // Reconstruct the relative URL string (pathname + search + hash)\n const relativeUrlWithSession = endpointUrl.pathname + endpointUrl.search + endpointUrl.hash;\n this.res.write(`event: endpoint\\ndata: ${relativeUrlWithSession}\\n\\n`);\n this._sseResponse = this.res;\n this.res.on(\"close\", () => {\n var _a;\n this._sseResponse = undefined;\n (_a = this.onclose) === null || _a === void 0 ? void 0 : _a.call(this);\n });\n }\n /**\n * Handles incoming POST messages.\n *\n * This should be called when a POST request is made to send a message to the server.\n */\n async handlePostMessage(req, res, parsedBody) {\n var _a, _b, _c;\n if (!this._sseResponse) {\n const message = \"SSE connection not established\";\n res.writeHead(500).end(message);\n throw new Error(message);\n }\n const authInfo = req.auth;\n let body;\n try {\n const ct = contentType.parse((_a = req.headers[\"content-type\"]) !== null && _a !== void 0 ? _a : \"\");\n if (ct.type !== \"application/json\") {\n throw new Error(`Unsupported content-type: ${ct}`);\n }\n body = parsedBody !== null && parsedBody !== void 0 ? parsedBody : await getRawBody(req, {\n limit: MAXIMUM_MESSAGE_SIZE,\n encoding: (_b = ct.parameters.charset) !== null && _b !== void 0 ? _b : \"utf-8\",\n });\n }\n catch (error) {\n res.writeHead(400).end(String(error));\n (_c = this.onerror) === null || _c === void 0 ? void 0 : _c.call(this, error);\n return;\n }\n try {\n await this.handleMessage(typeof body === 'string' ? JSON.parse(body) : body, { authInfo });\n }\n catch (_d) {\n res.writeHead(400).end(`Invalid message: ${body}`);\n return;\n }\n res.writeHead(202).end(\"Accepted\");\n }\n /**\n * 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.\n */\n async handleMessage(message, extra) {\n var _a, _b;\n let parsedMessage;\n try {\n parsedMessage = JSONRPCMessageSchema.parse(message);\n }\n catch (error) {\n (_a = this.onerror) === null || _a === void 0 ? void 0 : _a.call(this, error);\n throw error;\n }\n (_b = this.onmessage) === null || _b === void 0 ? void 0 : _b.call(this, parsedMessage, extra);\n }\n async close() {\n var _a, _b;\n (_a = this._sseResponse) === null || _a === void 0 ? void 0 : _a.end();\n this._sseResponse = undefined;\n (_b = this.onclose) === null || _b === void 0 ? void 0 : _b.call(this);\n }\n async send(message) {\n if (!this._sseResponse) {\n throw new Error(\"Not connected\");\n }\n this._sseResponse.write(`event: message\\ndata: ${JSON.stringify(message)}\\n\\n`);\n }\n /**\n * Returns the session ID for this transport.\n *\n * This can be used to route incoming POST requests.\n */\n get sessionId() {\n return this._sessionId;\n }\n}\n//# sourceMappingURL=sse.js.map"],"names":["MAXIMUM_MESSAGE_SIZE","SSEServerTransport","_endpoint","res","randomUUID","dummyBase","endpointUrl","URL","relativeUrlWithSession","_a","req","parsedBody","_b","_c","message","authInfo","body","ct","contentType","getRawBody","error","extra","parsedMessage","JSONRPCMessageSchema"],"mappings":";;;;AAKA,MAAMA,IAAuB;AAMtB,MAAMC,EAAmB;AAAA;AAAA;AAAA;AAAA,EAI5B,YAAYC,GAAWC,GAAK;AACxB,SAAK,YAAYD,GACjB,KAAK,MAAMC,GACX,KAAK,aAAaC,EAAU;AAAA,EACpC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMI,MAAM,QAAQ;AACV,QAAI,KAAK;AACL,YAAM,IAAI,MAAM,6GAA6G;AAEjI,SAAK,IAAI,UAAU,KAAK;AAAA,MACpB,gBAAgB;AAAA,MAChB,iBAAiB;AAAA,MACjB,YAAY;AAAA,IACxB,CAAS;AAID,UAAMC,IAAY,oBACZC,IAAc,IAAIC,EAAI,KAAK,WAAWF,CAAS;AACrD,IAAAC,EAAY,aAAa,IAAI,aAAa,KAAK,UAAU;AAEzD,UAAME,IAAyBF,EAAY,WAAWA,EAAY,SAASA,EAAY;AACvF,SAAK,IAAI,MAAM;AAAA,QAA0BE,CAAsB;AAAA;AAAA,CAAM,GACrE,KAAK,eAAe,KAAK,KACzB,KAAK,IAAI,GAAG,SAAS,MAAM;AACvB,UAAIC;AACJ,WAAK,eAAe,SACnBA,IAAK,KAAK,aAAa,QAAQA,MAAO,UAAkBA,EAAG,KAAK,IAAI;AAAA,IACjF,CA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AAAA,IAC9D,SACeM,GAAO;AACV,aAACX,IAAK,KAAK,aAAa,QAAQA,MAAO,UAAkBA,EAAG,KAAK,MAAMW,CAAK,GACtEA;AAAA,IAClB;AACQ,KAACR,IAAK,KAAK,eAAe,QAAQA,MAAO,UAAkBA,EAAG,KAAK,MAAMU,GAAeD,CAAK;AAAA,EACrG;AAAA,EACI,MAAM,QAAQ;AACV,QAAIZ,GAAIG;AACR,KAACH,IAAK,KAAK,kBAAkB,QAAQA,MAAO,UAAkBA,EAAG,IAAG,GACpE,KAAK,eAAe,SACnBG,IAAK,KAAK,aAAa,QAAQA,MAAO,UAAkBA,EAAG,KAAK,IAAI;AAAA,EAC7E;AAAA,EACI,MAAM,KAAKE,GAAS;AAChB,QAAI,CAAC,KAAK;AACN,YAAM,IAAI,MAAM,eAAe;AAEnC,SAAK,aAAa,MAAM;AAAA,QAAyB,KAAK,UAAUA,CAAO,CAAC;AAAA;AAAA,CAAM;AAAA,EACtF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMI,IAAI,YAAY;AACZ,WAAO,KAAK;AAAA,EACpB;AACA;","x_google_ignoreList":[0]}
|
package/dist/stdio-Cf19UQO7.js
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import a from "node:process";
|
|
2
|
-
import { J as n } from "./types-DdsPVLQ5.js";
|
|
3
|
-
class o {
|
|
4
|
-
append(t) {
|
|
5
|
-
this._buffer = this._buffer ? Buffer.concat([this._buffer, t]) : t;
|
|
6
|
-
}
|
|
7
|
-
readMessage() {
|
|
8
|
-
if (!this._buffer)
|
|
9
|
-
return null;
|
|
10
|
-
const t = this._buffer.indexOf(`
|
|
11
|
-
`);
|
|
12
|
-
if (t === -1)
|
|
13
|
-
return null;
|
|
14
|
-
const r = this._buffer.toString("utf8", 0, t).replace(/\r$/, "");
|
|
15
|
-
return this._buffer = this._buffer.subarray(t + 1), f(r);
|
|
16
|
-
}
|
|
17
|
-
clear() {
|
|
18
|
-
this._buffer = void 0;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
function f(e) {
|
|
22
|
-
return n.parse(JSON.parse(e));
|
|
23
|
-
}
|
|
24
|
-
function d(e) {
|
|
25
|
-
return JSON.stringify(e) + `
|
|
26
|
-
`;
|
|
27
|
-
}
|
|
28
|
-
class l {
|
|
29
|
-
constructor(t = a.stdin, r = a.stdout) {
|
|
30
|
-
this._stdin = t, this._stdout = r, this._readBuffer = new o(), this._started = !1, this._ondata = (s) => {
|
|
31
|
-
this._readBuffer.append(s), this.processReadBuffer();
|
|
32
|
-
}, this._onerror = (s) => {
|
|
33
|
-
var i;
|
|
34
|
-
(i = this.onerror) === null || i === void 0 || i.call(this, s);
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Starts listening for messages on stdin.
|
|
39
|
-
*/
|
|
40
|
-
async start() {
|
|
41
|
-
if (this._started)
|
|
42
|
-
throw new Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");
|
|
43
|
-
this._started = !0, this._stdin.on("data", this._ondata), this._stdin.on("error", this._onerror);
|
|
44
|
-
}
|
|
45
|
-
processReadBuffer() {
|
|
46
|
-
for (var t, r; ; )
|
|
47
|
-
try {
|
|
48
|
-
const s = this._readBuffer.readMessage();
|
|
49
|
-
if (s === null)
|
|
50
|
-
break;
|
|
51
|
-
(t = this.onmessage) === null || t === void 0 || t.call(this, s);
|
|
52
|
-
} catch (s) {
|
|
53
|
-
(r = this.onerror) === null || r === void 0 || r.call(this, s);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
async close() {
|
|
57
|
-
var t;
|
|
58
|
-
this._stdin.off("data", this._ondata), this._stdin.off("error", this._onerror), this._stdin.listenerCount("data") === 0 && this._stdin.pause(), this._readBuffer.clear(), (t = this.onclose) === null || t === void 0 || t.call(this);
|
|
59
|
-
}
|
|
60
|
-
send(t) {
|
|
61
|
-
return new Promise((r) => {
|
|
62
|
-
const s = d(t);
|
|
63
|
-
this._stdout.write(s) ? r() : this._stdout.once("drain", r);
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
export {
|
|
68
|
-
l as StdioServerTransport
|
|
69
|
-
};
|
|
70
|
-
//# sourceMappingURL=stdio-Cf19UQO7.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stdio-Cf19UQO7.js","sources":["../node_modules/.pnpm/@modelcontextprotocol+sdk@1.13.1/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.js","../node_modules/.pnpm/@modelcontextprotocol+sdk@1.13.1/node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js"],"sourcesContent":["import { JSONRPCMessageSchema } from \"../types.js\";\n/**\n * Buffers a continuous stdio stream into discrete JSON-RPC messages.\n */\nexport class ReadBuffer {\n append(chunk) {\n this._buffer = this._buffer ? Buffer.concat([this._buffer, chunk]) : chunk;\n }\n readMessage() {\n if (!this._buffer) {\n return null;\n }\n const index = this._buffer.indexOf(\"\\n\");\n if (index === -1) {\n return null;\n }\n const line = this._buffer.toString(\"utf8\", 0, index).replace(/\\r$/, '');\n this._buffer = this._buffer.subarray(index + 1);\n return deserializeMessage(line);\n }\n clear() {\n this._buffer = undefined;\n }\n}\nexport function deserializeMessage(line) {\n return JSONRPCMessageSchema.parse(JSON.parse(line));\n}\nexport function serializeMessage(message) {\n return JSON.stringify(message) + \"\\n\";\n}\n//# sourceMappingURL=stdio.js.map","import process from \"node:process\";\nimport { ReadBuffer, serializeMessage } from \"../shared/stdio.js\";\n/**\n * Server transport for stdio: this communicates with a MCP client by reading from the current process' stdin and writing to stdout.\n *\n * This transport is only available in Node.js environments.\n */\nexport class StdioServerTransport {\n constructor(_stdin = process.stdin, _stdout = process.stdout) {\n this._stdin = _stdin;\n this._stdout = _stdout;\n this._readBuffer = new ReadBuffer();\n this._started = false;\n // Arrow functions to bind `this` properly, while maintaining function identity.\n this._ondata = (chunk) => {\n this._readBuffer.append(chunk);\n this.processReadBuffer();\n };\n this._onerror = (error) => {\n var _a;\n (_a = this.onerror) === null || _a === void 0 ? void 0 : _a.call(this, error);\n };\n }\n /**\n * Starts listening for messages on stdin.\n */\n async start() {\n if (this._started) {\n throw new Error(\"StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.\");\n }\n this._started = true;\n this._stdin.on(\"data\", this._ondata);\n this._stdin.on(\"error\", this._onerror);\n }\n processReadBuffer() {\n var _a, _b;\n while (true) {\n try {\n const message = this._readBuffer.readMessage();\n if (message === null) {\n break;\n }\n (_a = this.onmessage) === null || _a === void 0 ? void 0 : _a.call(this, message);\n }\n catch (error) {\n (_b = this.onerror) === null || _b === void 0 ? void 0 : _b.call(this, error);\n }\n }\n }\n async close() {\n var _a;\n // Remove our event listeners first\n this._stdin.off(\"data\", this._ondata);\n this._stdin.off(\"error\", this._onerror);\n // Check if we were the only data listener\n const remainingDataListeners = this._stdin.listenerCount('data');\n if (remainingDataListeners === 0) {\n // Only pause stdin if we were the only listener\n // This prevents interfering with other parts of the application that might be using stdin\n this._stdin.pause();\n }\n // Clear the buffer and notify closure\n this._readBuffer.clear();\n (_a = this.onclose) === null || _a === void 0 ? void 0 : _a.call(this);\n }\n send(message) {\n return new Promise((resolve) => {\n const json = serializeMessage(message);\n if (this._stdout.write(json)) {\n resolve();\n }\n else {\n this._stdout.once(\"drain\", resolve);\n }\n });\n }\n}\n//# sourceMappingURL=stdio.js.map"],"names":["ReadBuffer","chunk","index","line","deserializeMessage","JSONRPCMessageSchema","serializeMessage","message","StdioServerTransport","_stdin","process","_stdout","error","_a","_b","resolve","json"],"mappings":";;AAIO,MAAMA,EAAW;AAAA,EACpB,OAAOC,GAAO;AACV,SAAK,UAAU,KAAK,UAAU,OAAO,OAAO,CAAC,KAAK,SAASA,CAAK,CAAC,IAAIA;AAAA,EAC7E;AAAA,EACI,cAAc;AACV,QAAI,CAAC,KAAK;AACN,aAAO;AAEX,UAAMC,IAAQ,KAAK,QAAQ,QAAQ;AAAA,CAAI;AAC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SACmBK,GAAO;AACV,SAACE,IAAK,KAAK,aAAa,QAAQA,MAAO,UAAkBA,EAAG,KAAK,MAAMF,CAAK;AAAA,MAC5F;AAAA,EAEA;AAAA,EACI,MAAM,QAAQ;AACV,QAAIC;AAEJ,SAAK,OAAO,IAAI,QAAQ,KAAK,OAAO,GACpC,KAAK,OAAO,IAAI,SAAS,KAAK,QAAQ,GAEP,KAAK,OAAO,cAAc,MAAM,MAChC,KAG3B,KAAK,OAAO,MAAK,GAGrB,KAAK,YAAY,MAAK,IACrBA,IAAK,KAAK,aAAa,QAAQA,MAAO,UAAkBA,EAAG,KAAK,IAAI;AAAA,EAC7E;AAAA,EACI,KAAKN,GAAS;AACV,WAAO,IAAI,QAAQ,CAACQ,MAAY;AAC5B,YAAMC,IAAOV,EAAiBC,CAAO;AACrC,MAAI,KAAK,QAAQ,MAAMS,CAAI,IACvBD,EAAO,IAGP,KAAK,QAAQ,KAAK,SAASA,CAAO;AAAA,IAElD,CAAS;AAAA,EACT;AACA;","x_google_ignoreList":[0,1]}
|
package/dist/stdio-DESvSONI.cjs
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const process = require("node:process");
|
|
4
|
-
const types = require("./types-DSxPEImy.cjs");
|
|
5
|
-
class ReadBuffer {
|
|
6
|
-
append(chunk) {
|
|
7
|
-
this._buffer = this._buffer ? Buffer.concat([this._buffer, chunk]) : chunk;
|
|
8
|
-
}
|
|
9
|
-
readMessage() {
|
|
10
|
-
if (!this._buffer) {
|
|
11
|
-
return null;
|
|
12
|
-
}
|
|
13
|
-
const index = this._buffer.indexOf("\n");
|
|
14
|
-
if (index === -1) {
|
|
15
|
-
return null;
|
|
16
|
-
}
|
|
17
|
-
const line = this._buffer.toString("utf8", 0, index).replace(/\r$/, "");
|
|
18
|
-
this._buffer = this._buffer.subarray(index + 1);
|
|
19
|
-
return deserializeMessage(line);
|
|
20
|
-
}
|
|
21
|
-
clear() {
|
|
22
|
-
this._buffer = void 0;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
function deserializeMessage(line) {
|
|
26
|
-
return types.JSONRPCMessageSchema.parse(JSON.parse(line));
|
|
27
|
-
}
|
|
28
|
-
function serializeMessage(message) {
|
|
29
|
-
return JSON.stringify(message) + "\n";
|
|
30
|
-
}
|
|
31
|
-
class StdioServerTransport {
|
|
32
|
-
constructor(_stdin = process.stdin, _stdout = process.stdout) {
|
|
33
|
-
this._stdin = _stdin;
|
|
34
|
-
this._stdout = _stdout;
|
|
35
|
-
this._readBuffer = new ReadBuffer();
|
|
36
|
-
this._started = false;
|
|
37
|
-
this._ondata = (chunk) => {
|
|
38
|
-
this._readBuffer.append(chunk);
|
|
39
|
-
this.processReadBuffer();
|
|
40
|
-
};
|
|
41
|
-
this._onerror = (error) => {
|
|
42
|
-
var _a;
|
|
43
|
-
(_a = this.onerror) === null || _a === void 0 ? void 0 : _a.call(this, error);
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Starts listening for messages on stdin.
|
|
48
|
-
*/
|
|
49
|
-
async start() {
|
|
50
|
-
if (this._started) {
|
|
51
|
-
throw new Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");
|
|
52
|
-
}
|
|
53
|
-
this._started = true;
|
|
54
|
-
this._stdin.on("data", this._ondata);
|
|
55
|
-
this._stdin.on("error", this._onerror);
|
|
56
|
-
}
|
|
57
|
-
processReadBuffer() {
|
|
58
|
-
var _a, _b;
|
|
59
|
-
while (true) {
|
|
60
|
-
try {
|
|
61
|
-
const message = this._readBuffer.readMessage();
|
|
62
|
-
if (message === null) {
|
|
63
|
-
break;
|
|
64
|
-
}
|
|
65
|
-
(_a = this.onmessage) === null || _a === void 0 ? void 0 : _a.call(this, message);
|
|
66
|
-
} catch (error) {
|
|
67
|
-
(_b = this.onerror) === null || _b === void 0 ? void 0 : _b.call(this, error);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
async close() {
|
|
72
|
-
var _a;
|
|
73
|
-
this._stdin.off("data", this._ondata);
|
|
74
|
-
this._stdin.off("error", this._onerror);
|
|
75
|
-
const remainingDataListeners = this._stdin.listenerCount("data");
|
|
76
|
-
if (remainingDataListeners === 0) {
|
|
77
|
-
this._stdin.pause();
|
|
78
|
-
}
|
|
79
|
-
this._readBuffer.clear();
|
|
80
|
-
(_a = this.onclose) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
81
|
-
}
|
|
82
|
-
send(message) {
|
|
83
|
-
return new Promise((resolve) => {
|
|
84
|
-
const json = serializeMessage(message);
|
|
85
|
-
if (this._stdout.write(json)) {
|
|
86
|
-
resolve();
|
|
87
|
-
} else {
|
|
88
|
-
this._stdout.once("drain", resolve);
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
exports.StdioServerTransport = StdioServerTransport;
|
|
94
|
-
//# sourceMappingURL=stdio-DESvSONI.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stdio-DESvSONI.cjs","sources":["../node_modules/.pnpm/@modelcontextprotocol+sdk@1.13.1/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.js","../node_modules/.pnpm/@modelcontextprotocol+sdk@1.13.1/node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js"],"sourcesContent":["import { JSONRPCMessageSchema } from \"../types.js\";\n/**\n * Buffers a continuous stdio stream into discrete JSON-RPC messages.\n */\nexport class ReadBuffer {\n append(chunk) {\n this._buffer = this._buffer ? Buffer.concat([this._buffer, chunk]) : chunk;\n }\n readMessage() {\n if (!this._buffer) {\n return null;\n }\n const index = this._buffer.indexOf(\"\\n\");\n if (index === -1) {\n return null;\n }\n const line = this._buffer.toString(\"utf8\", 0, index).replace(/\\r$/, '');\n this._buffer = this._buffer.subarray(index + 1);\n return deserializeMessage(line);\n }\n clear() {\n this._buffer = undefined;\n }\n}\nexport function deserializeMessage(line) {\n return JSONRPCMessageSchema.parse(JSON.parse(line));\n}\nexport function serializeMessage(message) {\n return JSON.stringify(message) + \"\\n\";\n}\n//# sourceMappingURL=stdio.js.map","import process from \"node:process\";\nimport { ReadBuffer, serializeMessage } from \"../shared/stdio.js\";\n/**\n * Server transport for stdio: this communicates with a MCP client by reading from the current process' stdin and writing to stdout.\n *\n * This transport is only available in Node.js environments.\n */\nexport class StdioServerTransport {\n constructor(_stdin = process.stdin, _stdout = process.stdout) {\n this._stdin = _stdin;\n this._stdout = _stdout;\n this._readBuffer = new ReadBuffer();\n this._started = false;\n // Arrow functions to bind `this` properly, while maintaining function identity.\n this._ondata = (chunk) => {\n this._readBuffer.append(chunk);\n this.processReadBuffer();\n };\n this._onerror = (error) => {\n var _a;\n (_a = this.onerror) === null || _a === void 0 ? void 0 : _a.call(this, error);\n };\n }\n /**\n * Starts listening for messages on stdin.\n */\n async start() {\n if (this._started) {\n throw new Error(\"StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.\");\n }\n this._started = true;\n this._stdin.on(\"data\", this._ondata);\n this._stdin.on(\"error\", this._onerror);\n }\n processReadBuffer() {\n var _a, _b;\n while (true) {\n try {\n const message = this._readBuffer.readMessage();\n if (message === null) {\n break;\n }\n (_a = this.onmessage) === null || _a === void 0 ? void 0 : _a.call(this, message);\n }\n catch (error) {\n (_b = this.onerror) === null || _b === void 0 ? void 0 : _b.call(this, error);\n }\n }\n }\n async close() {\n var _a;\n // Remove our event listeners first\n this._stdin.off(\"data\", this._ondata);\n this._stdin.off(\"error\", this._onerror);\n // Check if we were the only data listener\n const remainingDataListeners = this._stdin.listenerCount('data');\n if (remainingDataListeners === 0) {\n // Only pause stdin if we were the only listener\n // This prevents interfering with other parts of the application that might be using stdin\n this._stdin.pause();\n }\n // Clear the buffer and notify closure\n this._readBuffer.clear();\n (_a = this.onclose) === null || _a === void 0 ? void 0 : _a.call(this);\n }\n send(message) {\n return new Promise((resolve) => {\n const json = serializeMessage(message);\n if (this._stdout.write(json)) {\n resolve();\n }\n else {\n this._stdout.once(\"drain\", resolve);\n }\n });\n }\n}\n//# sourceMappingURL=stdio.js.map"],"names":["JSONRPCMessageSchema"],"mappings":";;;;AAIO,MAAM,WAAW;AAAA,EACpB,OAAO,OAAO;AACV,SAAK,UAAU,KAAK,UAAU,OAAO,OAAO,CAAC,KAAK,SAAS,KAAK,CAAC,IAAI;AAAA,EAC7E;AAAA,EACI,cAAc;AACV,QAAI,CAAC,KAAK,SAAS;AACf,aAAO;AAAA,IACnB;AACQ,UAAM,QAAQ,KAAK,QAAQ,QAAQ,IAAI;AACvC,QAAI,UAAU,IAAI;AACd,aAAO;AAAA,IACnB;AACQ,UAAM,OAAO,KAAK,QAAQ,SAAS,QAAQ,GAAG,KAAK,EAAE,QAAQ,OAAO,EAAE;AACtE,SAAK,UAAU,KAAK,QAAQ,SAAS,QAAQ,CAAC;AAC9C,WAAO,mBAAmB,IAAI;AAAA,EACtC;AAAA,EACI,QAAQ;AACJ,SAAK,UAAU;AAAA,EACvB;AACA;AACO,SAAS,mBAAmB,MAAM;AACrC,SAAOA,MAAAA,qBAAqB,MAAM,KAAK,MAAM,IAAI,CAAC;AACtD;AACO,SAAS,iBAAiB,SAAS;AACtC,SAAO,KAAK,UAAU,OAAO,IAAI;AACrC;ACtBO,MAAM,qBAAqB;AAAA,EAC9B,YAAY,SAAS,QAAQ,OAAO,UAAU,QAAQ,QAAQ;AAC1D,SAAK,SAAS;AACd,SAAK,UAAU;AACf,SAAK,cAAc,IAAI,WAAU;AACjC,SAAK,WAAW;AAEhB,SAAK,UAAU,CAAC,UAAU;AACtB,WAAK,YAAY,OAAO,KAAK;AAC7B,WAAK,kBAAiB;AAAA,IAClC;AACQ,SAAK,WAAW,CAAC,UAAU;AACvB,UAAI;AACJ,OAAC,KAAK,KAAK,aAAa,QAAQ,OAAO,SAAS,SAAS,GAAG,KAAK,MAAM,KAAK;AAAA,IAC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