@slexkit/mcp 0.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/dist/index.js ADDED
@@ -0,0 +1,621 @@
1
+ #!/usr/bin/env node
2
+ // @bun
3
+
4
+ // src/index.ts
5
+ import { createInterface } from "readline";
6
+ import { readFile } from "fs/promises";
7
+
8
+ // ../../dist/runtime.js
9
+ var ITERATE_KEY = Symbol("iterate");
10
+ var REVISION_KEY = Symbol("revision");
11
+ var pendingEffects = new Set;
12
+ var targetDeps = new WeakMap;
13
+ var proxyCache = new WeakMap;
14
+ var rawTargets = new WeakMap;
15
+ var rootTargets = new WeakMap;
16
+
17
+ class ReactiveScope {
18
+ cleanups = [];
19
+ effects = new Set;
20
+ disposed = false;
21
+ dispose() {
22
+ if (this.disposed)
23
+ return;
24
+ this.disposed = true;
25
+ for (const effect of Array.from(this.effects))
26
+ effect.stop();
27
+ this.effects.clear();
28
+ for (let i = this.cleanups.length - 1;i >= 0; i -= 1) {
29
+ this.cleanups[i]();
30
+ }
31
+ this.cleanups.length = 0;
32
+ }
33
+ }
34
+ var _stores = new Map;
35
+ var _registry = new Map;
36
+ var lastValues = new Map;
37
+ var SKIP_EAGER_TRACK = Symbol.for("slexkit.skipEagerTrack");
38
+ var EAGER_TRACK_TARGET = Symbol.for("slexkit.eagerTrackTarget");
39
+ var componentDisposers = new WeakMap;
40
+ var componentStateProxies = new WeakMap;
41
+ class SlexKitSyntaxError extends SyntaxError {
42
+ diagnostic;
43
+ constructor(diagnostic) {
44
+ super(formatSlexKitDiagnostic(diagnostic));
45
+ this.name = "SlexKitSyntaxError";
46
+ this.diagnostic = diagnostic;
47
+ }
48
+ }
49
+ function excerpt(source, line, column) {
50
+ const lines = source.split(`
51
+ `);
52
+ const start = Math.max(1, line - 2);
53
+ const end = Math.min(lines.length, line + 2);
54
+ const width = String(end).length;
55
+ const rows = [];
56
+ for (let current = start;current <= end; current += 1) {
57
+ const marker = current === line ? ">" : " ";
58
+ rows.push(`${marker} ${String(current).padStart(width, " ")} | ${lines[current - 1] ?? ""}`);
59
+ if (current === line) {
60
+ rows.push(` ${" ".repeat(width)} | ${" ".repeat(Math.max(0, column - 1))}^`);
61
+ }
62
+ }
63
+ return rows.join(`
64
+ `);
65
+ }
66
+ function lineColumnAt(source, index) {
67
+ const prefix = source.slice(0, Math.max(0, index));
68
+ const lines = prefix.split(`
69
+ `);
70
+ return {
71
+ line: lines.length,
72
+ column: lines[lines.length - 1].length + 1
73
+ };
74
+ }
75
+ function stackLine(error) {
76
+ if (!(error instanceof Error) || !error.stack)
77
+ return null;
78
+ const match = error.stack.match(/<parse>\s+\(:(\d+)\)/);
79
+ if (!match)
80
+ return null;
81
+ const parsed = Number(match[1]);
82
+ return Number.isFinite(parsed) ? Math.max(1, parsed - 2) : null;
83
+ }
84
+ function scanSource(source) {
85
+ const chars = [];
86
+ let quote = "";
87
+ let escaped = false;
88
+ let line = 1;
89
+ let column = 0;
90
+ for (let index = 0;index < source.length; index += 1) {
91
+ const char = source[index];
92
+ const next = source[index + 1];
93
+ column += 1;
94
+ if (char === `
95
+ `) {
96
+ line += 1;
97
+ column = 0;
98
+ if (quote === "//")
99
+ quote = "";
100
+ continue;
101
+ }
102
+ if (quote) {
103
+ if (quote === "/*" && char === "*" && next === "/") {
104
+ quote = "";
105
+ index += 1;
106
+ column += 1;
107
+ } else if (quote !== "/*" && quote !== "//" && !escaped && char === quote) {
108
+ quote = "";
109
+ }
110
+ escaped = !escaped && quote !== "/*" && quote !== "//" && char === "\\";
111
+ if (char !== "\\")
112
+ escaped = false;
113
+ continue;
114
+ }
115
+ if (char === "/" && next === "/") {
116
+ quote = "//";
117
+ index += 1;
118
+ column += 1;
119
+ continue;
120
+ }
121
+ if (char === "/" && next === "*") {
122
+ quote = "/*";
123
+ index += 1;
124
+ column += 1;
125
+ continue;
126
+ }
127
+ if (char === '"' || char === "'" || char === "`") {
128
+ quote = char;
129
+ escaped = false;
130
+ continue;
131
+ }
132
+ chars.push({ char, index, line, column });
133
+ }
134
+ return chars;
135
+ }
136
+ function tokenDiagnostic(source, message) {
137
+ const chars = scanSource(source);
138
+ const unexpectedString = message.match(/Unexpected string(?: literal)?(?: "([^"]+)")?/);
139
+ if (unexpectedString) {
140
+ const literal = unexpectedString[1];
141
+ if (literal) {
142
+ const quoted = [`"${literal}"`, `'${literal}'`, `\`${literal}\``];
143
+ const index = quoted.map((candidate) => source.indexOf(candidate)).filter((candidate) => candidate >= 0).sort((a, b) => a - b)[0];
144
+ if (index !== undefined)
145
+ return lineColumnAt(source, index);
146
+ }
147
+ const suspiciousString = source.match(/[}\])"']\s*(['"`])/);
148
+ if (suspiciousString?.index !== undefined) {
149
+ const quoteIndex = source.indexOf(suspiciousString[1], suspiciousString.index + 1);
150
+ if (quoteIndex >= 0)
151
+ return lineColumnAt(source, quoteIndex);
152
+ }
153
+ }
154
+ if (message.includes("Unexpected token ':'")) {
155
+ const doubleColon = chars.find((item, index) => item.char === ":" && chars[index - 1]?.char === ":");
156
+ if (doubleColon)
157
+ return doubleColon;
158
+ const suspiciousColon = chars.find((item, index) => {
159
+ if (item.char !== ":")
160
+ return false;
161
+ const prev = chars[index - 1]?.char;
162
+ return prev === '"' || prev === "'" || prev === "}" || prev === "]" || prev === ")";
163
+ });
164
+ if (suspiciousColon)
165
+ return suspiciousColon;
166
+ }
167
+ return null;
168
+ }
169
+ function delimiterDiagnostic(source) {
170
+ const stack = [];
171
+ const pairs = { "}": "{", "]": "[", ")": "(" };
172
+ for (const item of scanSource(source)) {
173
+ if (item.char === "{" || item.char === "[" || item.char === "(") {
174
+ stack.push(item);
175
+ continue;
176
+ }
177
+ if (item.char === "}" || item.char === "]" || item.char === ")") {
178
+ const expected = pairs[item.char];
179
+ const opener2 = stack.pop();
180
+ if (!opener2 || opener2.char !== expected) {
181
+ return {
182
+ line: item.line,
183
+ column: item.column,
184
+ detail: `Unexpected closing delimiter ${item.char}.`
185
+ };
186
+ }
187
+ }
188
+ }
189
+ const opener = stack.at(-1);
190
+ if (!opener)
191
+ return null;
192
+ const end = lineColumnAt(source, source.length);
193
+ return {
194
+ line: end.line,
195
+ column: end.column,
196
+ detail: `Expected closing delimiter for ${opener.char} opened at line ${opener.line}, column ${opener.column}.`
197
+ };
198
+ }
199
+ function locateSyntaxError(source, error) {
200
+ const rawMessage = error instanceof Error ? error.message : String(error);
201
+ const delimiter = delimiterDiagnostic(source);
202
+ const token = tokenDiagnostic(source, rawMessage);
203
+ const stack = stackLine(error);
204
+ const position = token ?? (delimiter && rawMessage.includes("Expected") ? delimiter : null) ?? (stack ? { line: stack, column: 1 } : null) ?? delimiter ?? { line: 1, column: 1 };
205
+ const detail = token ? "The parser failed at this token." : delimiter?.detail;
206
+ return {
207
+ message: rawMessage,
208
+ line: position.line,
209
+ column: position.column,
210
+ detail,
211
+ excerpt: excerpt(source, position.line, position.column)
212
+ };
213
+ }
214
+ function readStringLiteral(source, start) {
215
+ const quote = source[start];
216
+ if (quote !== '"' && quote !== "'" && quote !== "`")
217
+ return null;
218
+ let escaped = false;
219
+ for (let index = start + 1;index < source.length; index += 1) {
220
+ const char = source[index];
221
+ if (!escaped && char === quote) {
222
+ return { end: index + 1, value: source.slice(start, index + 1) };
223
+ }
224
+ escaped = !escaped && char === "\\";
225
+ if (char !== "\\")
226
+ escaped = false;
227
+ }
228
+ return null;
229
+ }
230
+ function skipWhitespace(source, index) {
231
+ let cursor = index;
232
+ while (cursor < source.length && /\s/.test(source[cursor]))
233
+ cursor += 1;
234
+ return cursor;
235
+ }
236
+ function findExpressionEnd(source, start) {
237
+ const stack = [];
238
+ let quote = "";
239
+ let escaped = false;
240
+ for (let index = start;index < source.length; index += 1) {
241
+ const char = source[index];
242
+ const next = source[index + 1];
243
+ if (quote) {
244
+ if (quote === "//" && char === `
245
+ `) {
246
+ quote = "";
247
+ } else if (quote === "/*" && char === "*" && next === "/") {
248
+ quote = "";
249
+ index += 1;
250
+ } else if (quote !== "//" && quote !== "/*" && !escaped && char === quote) {
251
+ quote = "";
252
+ }
253
+ escaped = !escaped && quote !== "//" && quote !== "/*" && char === "\\";
254
+ if (char !== "\\")
255
+ escaped = false;
256
+ continue;
257
+ }
258
+ if (char === "/" && next === "/") {
259
+ quote = "//";
260
+ index += 1;
261
+ continue;
262
+ }
263
+ if (char === "/" && next === "*") {
264
+ quote = "/*";
265
+ index += 1;
266
+ continue;
267
+ }
268
+ if (char === '"' || char === "'" || char === "`") {
269
+ quote = char;
270
+ escaped = false;
271
+ continue;
272
+ }
273
+ if (char === "{" || char === "[" || char === "(") {
274
+ stack.push(char);
275
+ continue;
276
+ }
277
+ if (char === "}" || char === "]" || char === ")") {
278
+ if (stack.length === 0)
279
+ return index;
280
+ stack.pop();
281
+ continue;
282
+ }
283
+ if (char === "," && stack.length === 0)
284
+ return index;
285
+ }
286
+ return source.length;
287
+ }
288
+ function isSingleStringLiteral(source) {
289
+ const start = skipWhitespace(source, 0);
290
+ const literal = readStringLiteral(source, start);
291
+ return Boolean(literal && skipWhitespace(source, literal.end) === source.length);
292
+ }
293
+ function transformDynamicPropExpressions(source) {
294
+ const edits = [];
295
+ const keyPattern = /(^|[,{]\s*)(\$[A-Za-z_$][\w$]*)\s*:/g;
296
+ let match;
297
+ while (match = keyPattern.exec(source)) {
298
+ const colon = source.indexOf(":", match.index + match[1].length);
299
+ const valueStart = skipWhitespace(source, colon + 1);
300
+ const valueEnd = findExpressionEnd(source, valueStart);
301
+ const rawValue = source.slice(valueStart, valueEnd);
302
+ if (!rawValue.trim() || isSingleStringLiteral(rawValue))
303
+ continue;
304
+ edits.push({
305
+ start: valueStart,
306
+ end: valueEnd,
307
+ value: JSON.stringify(rawValue.trim())
308
+ });
309
+ }
310
+ if (edits.length === 0)
311
+ return source;
312
+ let transformed = source;
313
+ for (let index = edits.length - 1;index >= 0; index -= 1) {
314
+ const edit = edits[index];
315
+ transformed = `${transformed.slice(0, edit.start)}${edit.value}${transformed.slice(edit.end)}`;
316
+ }
317
+ return transformed;
318
+ }
319
+ function formatSlexKitDiagnostic(diagnostic) {
320
+ const detail = diagnostic.detail ? `
321
+ ${diagnostic.detail}` : "";
322
+ return `${diagnostic.message} at line ${diagnostic.line}, column ${diagnostic.column}.${detail}
323
+ ${diagnostic.excerpt}`;
324
+ }
325
+ function diagnoseSlexKitSource(source, error) {
326
+ return locateSyntaxError(source, error);
327
+ }
328
+ function parseSlexSource(source) {
329
+ try {
330
+ const parseSource = transformDynamicPropExpressions(source);
331
+ return {
332
+ ok: true,
333
+ value: new Function(`"use strict";
334
+ return (
335
+ ${parseSource}
336
+ );`)()
337
+ };
338
+ } catch (error) {
339
+ const diagnostic = diagnoseSlexKitSource(source, error);
340
+ return {
341
+ ok: false,
342
+ diagnostic,
343
+ error: new SlexKitSyntaxError(diagnostic)
344
+ };
345
+ }
346
+ }
347
+ var defaultRuntimeUrl = typeof document !== "undefined" && typeof document.currentScript === "object" && document.currentScript && "src" in document.currentScript ? String(document.currentScript.src || "") : undefined;
348
+ function setSlexKitRuntimeUrl(url) {
349
+ defaultRuntimeUrl = url || undefined;
350
+ }
351
+ var schedulingSnapshot = {
352
+ setTimeout: typeof globalThis.setTimeout === "function" ? globalThis.setTimeout.bind(globalThis) : undefined,
353
+ clearTimeout: typeof globalThis.clearTimeout === "function" ? globalThis.clearTimeout.bind(globalThis) : undefined,
354
+ setInterval: typeof globalThis.setInterval === "function" ? globalThis.setInterval.bind(globalThis) : undefined,
355
+ clearInterval: typeof globalThis.clearInterval === "function" ? globalThis.clearInterval.bind(globalThis) : undefined,
356
+ requestAnimationFrame: typeof globalThis.requestAnimationFrame === "function" ? globalThis.requestAnimationFrame.bind(globalThis) : undefined,
357
+ cancelAnimationFrame: typeof globalThis.cancelAnimationFrame === "function" ? globalThis.cancelAnimationFrame.bind(globalThis) : undefined
358
+ };
359
+ var canvasSnapshot = {
360
+ getContext: typeof HTMLCanvasElement !== "undefined" ? HTMLCanvasElement.prototype.getContext : undefined,
361
+ offscreenCanvas: typeof OffscreenCanvas !== "undefined" ? OffscreenCanvas : undefined
362
+ };
363
+ setSlexKitRuntimeUrl(import.meta.url);
364
+ var parseSlexSourceApi = parseSlexSource;
365
+
366
+ // src/index.ts
367
+ var dataBase = new URL("./data/", import.meta.url);
368
+ async function readDataFile(name) {
369
+ return readFile(new URL(name, dataBase), "utf-8");
370
+ }
371
+ var manifest = JSON.parse(await readDataFile("slexkit-ai-manifest.json"));
372
+ function stringArg(args, key) {
373
+ const value = args[key];
374
+ return typeof value === "string" ? value : "";
375
+ }
376
+ function optionalStringArg(args, key) {
377
+ const value = args[key];
378
+ return typeof value === "string" && value ? value : undefined;
379
+ }
380
+ function jsonSchema(properties, required = []) {
381
+ return {
382
+ type: "object",
383
+ properties,
384
+ required,
385
+ additionalProperties: false
386
+ };
387
+ }
388
+ function pageMatches(page, query) {
389
+ const needle = query.toLowerCase();
390
+ return [
391
+ page.id,
392
+ page.group,
393
+ page.title,
394
+ page.summary,
395
+ page.href,
396
+ page.rawHref,
397
+ page.sourcePath,
398
+ page.body
399
+ ].some((value) => value.toLowerCase().includes(needle));
400
+ }
401
+ function findPage(args) {
402
+ const slug = optionalStringArg(args, "slug");
403
+ const url = optionalStringArg(args, "url");
404
+ if (url) {
405
+ const normalized = url.replace(/^https?:\/\/[^/]+/, "");
406
+ return manifest.pages.find((page) => page.rawHref === normalized || page.href === normalized || page.rawHref === url || page.href === url);
407
+ }
408
+ if (slug) {
409
+ return manifest.pages.find((page) => page.id === slug || page.id.endsWith(`/${slug}`) || page.rawHref.endsWith(`/${slug}.md`));
410
+ }
411
+ return;
412
+ }
413
+ function searchPages(args) {
414
+ const group = optionalStringArg(args, "group");
415
+ const query = optionalStringArg(args, "query");
416
+ return manifest.pages.filter((page) => !group || page.group.toLowerCase() === group.toLowerCase()).filter((page) => !query || pageMatches(page, query)).map(({ body: _body, ...page }) => page);
417
+ }
418
+ function collectComponentUsage(value, found = new Set) {
419
+ if (!value || typeof value !== "object")
420
+ return [...found].sort();
421
+ for (const [key, child] of Object.entries(value)) {
422
+ const colon = key.indexOf(":");
423
+ if (colon > 0)
424
+ found.add(key.slice(0, colon));
425
+ collectComponentUsage(child, found);
426
+ }
427
+ return [...found].sort();
428
+ }
429
+ function sourceFromTemplate(template) {
430
+ if (template === "calculator") {
431
+ return `{
432
+ slex: "0.1",
433
+ namespace: "calculator",
434
+ g: { a: 10, b: 5 },
435
+ layout: {
436
+ "card:calc": {
437
+ title: "Calculator",
438
+ "input:a": { label: "A", "$value": "String(g.a)", onchange: "g.a = Number($event || 0)" },
439
+ "input:b": { label: "B", "$value": "String(g.b)", onchange: "g.b = Number($event || 0)" },
440
+ "stat:sum": { label: "Sum", "$value": "g.a + g.b" }
441
+ }
442
+ }
443
+ }`;
444
+ }
445
+ if (template === "toolhost-form") {
446
+ return `{
447
+ slex: "0.1",
448
+ namespace: "approval_form",
449
+ g: { approved: false, reason: "" },
450
+ layout: {
451
+ "card:approval": {
452
+ title: "Review request",
453
+ "checkbox:approved": { label: "Approve", "$checked": "g.approved", onchange: "g.approved = Boolean($event)" },
454
+ "input:reason": { label: "Reason", "$value": "g.reason", onchange: "g.reason = String($event || '')" },
455
+ "submit:actions": { submitLabel: "Submit", ignoreLabel: "Ignore", returnKeys: ["approved", "reason"] }
456
+ }
457
+ }
458
+ }`;
459
+ }
460
+ if (template === "host-integration") {
461
+ return `import { createSlexKitMarkdownRuntimeHost } from "slexkit";
462
+ import "slexkit/style.css";
463
+
464
+ const runtime = createSlexKitMarkdownRuntimeHost({
465
+ mode: "secure",
466
+ secureFrame: { runtimeUrl: "/runtime.js" }
467
+ });
468
+
469
+ runtime.mountBlock({
470
+ artifactId: "message-1",
471
+ blockId: "message-1:block-1",
472
+ source,
473
+ container
474
+ });`;
475
+ }
476
+ return `{
477
+ slex: "0.1",
478
+ namespace: "status",
479
+ g: { done: 3, total: 4 },
480
+ layout: {
481
+ "card:summary": {
482
+ title: "Status",
483
+ "text:count": { "$text": "g.done + '/' + g.total + ' complete'" },
484
+ "progress:bar": { "$value": "g.done / g.total * 100" }
485
+ }
486
+ }
487
+ }`;
488
+ }
489
+ var tools = [
490
+ {
491
+ name: "slexkitDocs",
492
+ description: "Search or fetch SlexKit Markdown docs. Raw docs are .md files with explicit slex fences; no .mdx routes are used.",
493
+ inputSchema: jsonSchema({
494
+ query: { type: "string", description: "Search text. Searches titles, summaries, URLs, source paths, and body text." },
495
+ group: { type: "string", description: "Optional group filter: Guides, Components, Runtime, ToolHost, Security, Packages, Icons." },
496
+ slug: { type: "string", description: "Optional page id or slug to fetch, such as components/card or card." },
497
+ url: { type: "string", description: "Optional href or raw .md URL to fetch." }
498
+ }),
499
+ handler(args) {
500
+ const page = findPage(args);
501
+ if (page)
502
+ return { version: manifest.version, page };
503
+ return { version: manifest.version, pages: searchPages(args) };
504
+ }
505
+ },
506
+ {
507
+ name: "slexkitExamples",
508
+ description: "Browse SlexKit component examples, ToolHost examples, and host integration snippets.",
509
+ inputSchema: jsonSchema({
510
+ type: { type: "string", description: "Optional component type, such as card, input, stat, or submit." },
511
+ template: { type: "string", enum: ["status", "calculator", "toolhost-form", "host-integration"], description: "Optional generated example template." }
512
+ }),
513
+ handler(args) {
514
+ const template = optionalStringArg(args, "template");
515
+ if (template) {
516
+ const source = sourceFromTemplate(template);
517
+ const parsed = template === "host-integration" ? { ok: true } : parseSlexSourceApi(source);
518
+ return { template, source, valid: parsed.ok };
519
+ }
520
+ const type = optionalStringArg(args, "type");
521
+ const components = manifest.components.filter((component) => !type || component.type === type);
522
+ if (type && components.length === 0) {
523
+ return { error: "component_not_found", type, available: manifest.components.map((component) => component.type) };
524
+ }
525
+ return {
526
+ components: components.map((component) => ({
527
+ type: component.type,
528
+ title: component.title,
529
+ summary: component.summary,
530
+ rawHref: component.rawHref,
531
+ examples: component.examples.map((example) => ({
532
+ id: example.id,
533
+ title: example.title,
534
+ description: example.description,
535
+ source: JSON.stringify(example.source, null, 2)
536
+ }))
537
+ }))
538
+ };
539
+ }
540
+ },
541
+ {
542
+ name: "slexkitValidate",
543
+ description: "Parse Slex source and return diagnostics plus component usage.",
544
+ inputSchema: jsonSchema({ source: { type: "string", description: "Slex object literal source." } }, ["source"]),
545
+ handler(args) {
546
+ const source = stringArg(args, "source");
547
+ const parsed = parseSlexSourceApi(source);
548
+ if (!parsed.ok) {
549
+ return {
550
+ ok: false,
551
+ diagnostic: parsed.diagnostic
552
+ };
553
+ }
554
+ return {
555
+ ok: true,
556
+ componentUsage: collectComponentUsage(parsed.value)
557
+ };
558
+ }
559
+ }
560
+ ];
561
+ var toolByName = new Map(tools.map((tool) => [tool.name, tool]));
562
+ function send(message) {
563
+ process.stdout.write(`${JSON.stringify(message)}
564
+ `);
565
+ }
566
+ function respond(id, result) {
567
+ send({ jsonrpc: "2.0", id, result });
568
+ }
569
+ function respondError(id, code, message, data) {
570
+ send({ jsonrpc: "2.0", id, error: { code, message, data } });
571
+ }
572
+ async function handleRequest(request) {
573
+ if (request.id === undefined && request.method.startsWith("notifications/"))
574
+ return;
575
+ if (request.method === "initialize") {
576
+ respond(request.id, {
577
+ protocolVersion: "2025-06-18",
578
+ capabilities: { tools: {} },
579
+ serverInfo: { name: "@slexkit/mcp", version: manifest.version }
580
+ });
581
+ return;
582
+ }
583
+ if (request.method === "tools/list") {
584
+ respond(request.id, {
585
+ tools: tools.map(({ name, description, inputSchema }) => ({ name, description, inputSchema }))
586
+ });
587
+ return;
588
+ }
589
+ if (request.method === "tools/call") {
590
+ const params = request.params ?? {};
591
+ const name = typeof params.name === "string" ? params.name : "";
592
+ const args = params.arguments && typeof params.arguments === "object" ? params.arguments : {};
593
+ const tool = toolByName.get(name);
594
+ if (!tool) {
595
+ respondError(request.id, -32602, `Unknown tool: ${name}`, { available: [...toolByName.keys()] });
596
+ return;
597
+ }
598
+ const result = await tool.handler(args);
599
+ respond(request.id, {
600
+ content: [{ type: "text", text: typeof result === "string" ? result : JSON.stringify(result, null, 2) }],
601
+ structuredContent: result
602
+ });
603
+ return;
604
+ }
605
+ respondError(request.id, -32601, `Method not found: ${request.method}`);
606
+ }
607
+ var rl = createInterface({ input: process.stdin, crlfDelay: Infinity });
608
+ rl.on("line", (line) => {
609
+ const trimmed = line.trim();
610
+ if (!trimmed)
611
+ return;
612
+ (async () => {
613
+ try {
614
+ await handleRequest(JSON.parse(trimmed));
615
+ } catch (error) {
616
+ respondError(null, -32700, error instanceof Error ? error.message : String(error));
617
+ }
618
+ })();
619
+ });
620
+
621
+ //# debugId=A2A380ED9FA68E9464756E2164756E21