xiaotime 0.6.1 → 0.8.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/background.d.ts +47 -0
- package/dist/background.d.ts.map +1 -0
- package/dist/background.js +110 -0
- package/dist/background.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +70 -1
- package/dist/index.js.map +1 -1
- package/dist/ink/App.d.ts +1 -0
- package/dist/ink/App.d.ts.map +1 -1
- package/dist/ink/App.js +11 -3
- package/dist/ink/App.js.map +1 -1
- package/dist/ink/runSessionInk.d.ts.map +1 -1
- package/dist/ink/runSessionInk.js +50 -2
- package/dist/ink/runSessionInk.js.map +1 -1
- package/dist/ink/store.d.ts +11 -0
- package/dist/ink/store.d.ts.map +1 -1
- package/dist/ink/store.js +12 -0
- package/dist/ink/store.js.map +1 -1
- package/dist/mcp.d.ts +94 -0
- package/dist/mcp.d.ts.map +1 -0
- package/dist/mcp.js +282 -0
- package/dist/mcp.js.map +1 -0
- package/dist/room_agent.d.ts +7 -0
- package/dist/room_agent.d.ts.map +1 -0
- package/dist/room_agent.js +395 -0
- package/dist/room_agent.js.map +1 -0
- package/dist/settings.d.ts +9 -1
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js +46 -4
- package/dist/settings.js.map +1 -1
- package/dist/skills.d.ts +14 -0
- package/dist/skills.d.ts.map +1 -0
- package/dist/skills.js +112 -0
- package/dist/skills.js.map +1 -0
- package/dist/todos.d.ts +26 -0
- package/dist/todos.d.ts.map +1 -0
- package/dist/todos.js +55 -0
- package/dist/todos.js.map +1 -0
- package/dist/tools.d.ts +26 -0
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +496 -1
- package/dist/tools.js.map +1 -1
- package/dist/ws.d.ts.map +1 -1
- package/dist/ws.js +34 -2
- package/dist/ws.js.map +1 -1
- package/package.json +2 -1
package/dist/ink/store.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.js","sourceRoot":"","sources":["../../src/ink/store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"store.js","sourceRoot":"","sources":["../../src/ink/store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAC;AA+D7C,IAAI,KAAK,GAAiB;IACxB,KAAK,EAAE,EAAE;IACT,QAAQ,EAAE,IAAI;IACd,SAAS,EAAE,IAAI;IACf,IAAI,EAAE,KAAK;IACX,SAAS,EAAE,KAAK;IAChB,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,iBAAiB,IAAI,WAAW;IACrD,YAAY,EAAE,EAAE;IAChB,UAAU,EAAE,aAAa;IACzB,eAAe,EAAE,IAAI;CACtB,CAAC;AAGF,MAAM,SAAS,GAAG,IAAI,GAAG,EAAY,CAAC;AAEtC,SAAS,IAAI;IACX,KAAK,MAAM,CAAC,IAAI,SAAS;QAAE,CAAC,EAAE,CAAC;AACjC,CAAC;AAED,SAAS,GAAG,CAAC,KAA4B;IACvC,KAAK,GAAG,EAAE,GAAG,KAAK,EAAE,GAAG,KAAK,EAAE,CAAC;IAC/B,IAAI,EAAE,CAAC;AACT,CAAC;AAED,gFAAgF;AAChF,SAAS,SAAS,CAAC,CAAW;IAC5B,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IACjB,OAAO,GAAG,EAAE;QACV,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IACtB,CAAC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,WAAW;IACzB,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,UAAU,UAAU;IACxB,OAAO,oBAAoB,CAAC,SAAS,EAAE,WAAW,EAAE,WAAW,CAAC,CAAC;AACnE,CAAC;AAED,gFAAgF;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;QAC9D,SAAS,EAAE,IAAI;QACf,IAAI,EAAE,KAAK;KACZ,CAAC,CAAC;AACL,CAAC;AAED,gFAAgF;AAChF,IAAI,gBAAgB,GAA2C,IAAI,CAAC;AAEpE;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,CAAkB;IAChD,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,gBAAgB,GAAG,OAAO,CAAC;QAC3B,GAAG,CAAC,EAAE,eAAe,EAAE,CAAC,EAAE,CAAC,CAAC;IAC9B,CAAC,CAAC,CAAC;AACL,CAAC;AAED,sEAAsE;AACtE,MAAM,UAAU,eAAe,CAAC,QAA0B;IACxD,MAAM,OAAO,GAAG,gBAAgB,CAAC;IACjC,gBAAgB,GAAG,IAAI,CAAC;IACxB,GAAG,CAAC,EAAE,eAAe,EAAE,IAAI,EAAE,CAAC,CAAC;IAC/B,OAAO,EAAE,CAAC,QAAQ,CAAC,CAAC;AACtB,CAAC;AAED,uDAAuD;AACvD,MAAM,UAAU,aAAa;IAC3B,gBAAgB,GAAG,IAAI,CAAC;IACxB,KAAK,GAAG;QACN,KAAK,EAAE,EAAE;QACT,QAAQ,EAAE,IAAI;QACd,SAAS,EAAE,IAAI;QACf,IAAI,EAAE,KAAK;QACX,SAAS,EAAE,KAAK;QAChB,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,iBAAiB,IAAI,WAAW;QACrD,YAAY,EAAE,EAAE;QAChB,UAAU,EAAE,aAAa;QACzB,eAAe,EAAE,IAAI;KACtB,CAAC;IACF,IAAI,EAAE,CAAC;AACT,CAAC"}
|
package/dist/mcp.d.ts
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP (Model Context Protocol) client — SPRINT-CLI-CAPABILITY-PARITY-1
|
|
3
|
+
* (#14608).
|
|
4
|
+
*
|
|
5
|
+
* Lets the terminal agent reach external tool servers (the KB/estate,
|
|
6
|
+
* a browser driver, platform connectors) the same way Claude Code
|
|
7
|
+
* does: spawn the servers declared in `~/.xiaotime/mcp.json`, discover
|
|
8
|
+
* their tools over stdio JSON-RPC, and expose them to the LLM as extra
|
|
9
|
+
* entries in the connect manifest. A tool_use for one of these names is
|
|
10
|
+
* routed to its server's `tools/call` instead of the local executeTool
|
|
11
|
+
* switch.
|
|
12
|
+
*
|
|
13
|
+
* Transport: newline-delimited JSON-RPC 2.0 over the child's stdio
|
|
14
|
+
* (the MCP stdio contract — one JSON message per line, no embedded
|
|
15
|
+
* newlines).
|
|
16
|
+
*
|
|
17
|
+
* Tool naming: `mcp__<server>__<tool>` so two servers can expose a tool
|
|
18
|
+
* of the same bare name without colliding, and the dispatcher can parse
|
|
19
|
+
* the server back out of the name.
|
|
20
|
+
*
|
|
21
|
+
* Config shape (Claude-Code-compatible):
|
|
22
|
+
* { "mcpServers": { "<name>": { "command": "...", "args": [...],
|
|
23
|
+
* "env": { ... } } } }
|
|
24
|
+
*
|
|
25
|
+
* Governance: MCP tools ride the SAME tool_call → tool_result round-trip
|
|
26
|
+
* as the built-in tools, so they surface in the transcript. Per-tool
|
|
27
|
+
* approval on outbound MCP calls lands with the #14605 room; today the
|
|
28
|
+
* mediation is the config file itself (only servers the user declared
|
|
29
|
+
* are spawned).
|
|
30
|
+
*/
|
|
31
|
+
import type { ToolManifestEntry, ToolResult } from "./tools.js";
|
|
32
|
+
export interface McpServerConfig {
|
|
33
|
+
command: string;
|
|
34
|
+
args?: string[];
|
|
35
|
+
env?: Record<string, string>;
|
|
36
|
+
}
|
|
37
|
+
export interface McpConfig {
|
|
38
|
+
mcpServers: Record<string, McpServerConfig>;
|
|
39
|
+
}
|
|
40
|
+
export declare const MCP_TOOL_PREFIX = "mcp__";
|
|
41
|
+
export declare function mcpConfigPath(): string;
|
|
42
|
+
/**
|
|
43
|
+
* Read `~/.xiaotime/mcp.json`. Returns an empty server set for any
|
|
44
|
+
* failure (missing / unreadable / malformed) — a broken MCP config
|
|
45
|
+
* must never stop the CLI from starting (mirrors settings.ts's
|
|
46
|
+
* never-throw allowlist load).
|
|
47
|
+
*/
|
|
48
|
+
export declare function loadMcpConfig(): McpConfig;
|
|
49
|
+
export declare function isMcpTool(name: string): boolean;
|
|
50
|
+
/** Parse `mcp__<server>__<tool>` back into its parts (null if malformed). */
|
|
51
|
+
export declare function parseMcpToolName(name: string): {
|
|
52
|
+
server: string;
|
|
53
|
+
tool: string;
|
|
54
|
+
} | null;
|
|
55
|
+
/** One live connection to a spawned MCP server. */
|
|
56
|
+
export declare class McpConnection {
|
|
57
|
+
readonly name: string;
|
|
58
|
+
private cfg;
|
|
59
|
+
private child;
|
|
60
|
+
private buf;
|
|
61
|
+
private nextId;
|
|
62
|
+
private pending;
|
|
63
|
+
private closed;
|
|
64
|
+
tools: ToolManifestEntry[];
|
|
65
|
+
constructor(name: string, cfg: McpServerConfig);
|
|
66
|
+
start(timeoutMs?: number): Promise<void>;
|
|
67
|
+
callTool(tool: string, args: Record<string, unknown>, timeoutMs?: number): Promise<{
|
|
68
|
+
text: string;
|
|
69
|
+
isError: boolean;
|
|
70
|
+
}>;
|
|
71
|
+
stop(): void;
|
|
72
|
+
private _onData;
|
|
73
|
+
private _request;
|
|
74
|
+
private _notify;
|
|
75
|
+
private _fail;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Owns every live MCP connection for a session. Connects all configured
|
|
79
|
+
* servers concurrently, aggregates their tools into one manifest slice,
|
|
80
|
+
* and routes tool calls to the right server. A server that fails to
|
|
81
|
+
* start is skipped (reported in `errors`), never fatal.
|
|
82
|
+
*/
|
|
83
|
+
export declare class McpManager {
|
|
84
|
+
private conns;
|
|
85
|
+
startAll(cfg?: McpConfig): Promise<{
|
|
86
|
+
tools: ToolManifestEntry[];
|
|
87
|
+
errors: string[];
|
|
88
|
+
}>;
|
|
89
|
+
hasServers(): boolean;
|
|
90
|
+
serverNames(): string[];
|
|
91
|
+
call(name: string, input: Record<string, unknown>, tool_use_id: string): Promise<ToolResult>;
|
|
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AAG,EAAE,eAAe;IAKxC,KAAK,CAAC,SAAS,SAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;IAoCvC,QAAQ,CACZ,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,SAAS,SAAS,GACjB,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC;IAc9C,IAAI,IAAI,IAAI;IAcZ,OAAO,CAAC,OAAO;IAwBf,OAAO,CAAC,QAAQ;IAsBhB,OAAO,CAAC,OAAO;IASf,OAAO,CAAC,KAAK;CAQd;AAcD;;;;;GAKG;AACH,qBAAa,UAAU;IACrB,OAAO,CAAC,KAAK,CAAoC;IAE3C,QAAQ,CACZ,GAAG,GAAE,SAA2B,GAC/B,OAAO,CAAC;QAAE,KAAK,EAAE,iBAAiB,EAAE,CAAC;QAAC,MAAM,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC;IAoB5D,UAAU,IAAI,OAAO;IAIrB,WAAW,IAAI,MAAM,EAAE;IAIjB,IAAI,CACR,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,UAAU,CAAC;IAyBtB,OAAO,IAAI,IAAI;CAIhB"}
|
package/dist/mcp.js
ADDED
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP (Model Context Protocol) client — SPRINT-CLI-CAPABILITY-PARITY-1
|
|
3
|
+
* (#14608).
|
|
4
|
+
*
|
|
5
|
+
* Lets the terminal agent reach external tool servers (the KB/estate,
|
|
6
|
+
* a browser driver, platform connectors) the same way Claude Code
|
|
7
|
+
* does: spawn the servers declared in `~/.xiaotime/mcp.json`, discover
|
|
8
|
+
* their tools over stdio JSON-RPC, and expose them to the LLM as extra
|
|
9
|
+
* entries in the connect manifest. A tool_use for one of these names is
|
|
10
|
+
* routed to its server's `tools/call` instead of the local executeTool
|
|
11
|
+
* switch.
|
|
12
|
+
*
|
|
13
|
+
* Transport: newline-delimited JSON-RPC 2.0 over the child's stdio
|
|
14
|
+
* (the MCP stdio contract — one JSON message per line, no embedded
|
|
15
|
+
* newlines).
|
|
16
|
+
*
|
|
17
|
+
* Tool naming: `mcp__<server>__<tool>` so two servers can expose a tool
|
|
18
|
+
* of the same bare name without colliding, and the dispatcher can parse
|
|
19
|
+
* the server back out of the name.
|
|
20
|
+
*
|
|
21
|
+
* Config shape (Claude-Code-compatible):
|
|
22
|
+
* { "mcpServers": { "<name>": { "command": "...", "args": [...],
|
|
23
|
+
* "env": { ... } } } }
|
|
24
|
+
*
|
|
25
|
+
* Governance: MCP tools ride the SAME tool_call → tool_result round-trip
|
|
26
|
+
* as the built-in tools, so they surface in the transcript. Per-tool
|
|
27
|
+
* approval on outbound MCP calls lands with the #14605 room; today the
|
|
28
|
+
* mediation is the config file itself (only servers the user declared
|
|
29
|
+
* are spawned).
|
|
30
|
+
*/
|
|
31
|
+
import * as fs from "fs";
|
|
32
|
+
import * as os from "os";
|
|
33
|
+
import * as path from "path";
|
|
34
|
+
import { spawn } from "child_process";
|
|
35
|
+
const PROTOCOL_VERSION = "2024-11-05";
|
|
36
|
+
export const MCP_TOOL_PREFIX = "mcp__";
|
|
37
|
+
export function mcpConfigPath() {
|
|
38
|
+
return (process.env.XIAOTIME_MCP_CONFIG ??
|
|
39
|
+
path.join(os.homedir(), ".xiaotime", "mcp.json"));
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Read `~/.xiaotime/mcp.json`. Returns an empty server set for any
|
|
43
|
+
* failure (missing / unreadable / malformed) — a broken MCP config
|
|
44
|
+
* must never stop the CLI from starting (mirrors settings.ts's
|
|
45
|
+
* never-throw allowlist load).
|
|
46
|
+
*/
|
|
47
|
+
export function loadMcpConfig() {
|
|
48
|
+
const p = mcpConfigPath();
|
|
49
|
+
if (!fs.existsSync(p))
|
|
50
|
+
return { mcpServers: {} };
|
|
51
|
+
try {
|
|
52
|
+
const parsed = JSON.parse(fs.readFileSync(p, "utf-8"));
|
|
53
|
+
const servers = parsed?.mcpServers;
|
|
54
|
+
if (!servers || typeof servers !== "object")
|
|
55
|
+
return { mcpServers: {} };
|
|
56
|
+
return { mcpServers: servers };
|
|
57
|
+
}
|
|
58
|
+
catch (e) {
|
|
59
|
+
process.stderr.write(`[xiaotime] ~/.xiaotime/mcp.json unreadable: ${e.message}\n`);
|
|
60
|
+
return { mcpServers: {} };
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
export function isMcpTool(name) {
|
|
64
|
+
return name.startsWith(MCP_TOOL_PREFIX);
|
|
65
|
+
}
|
|
66
|
+
/** Parse `mcp__<server>__<tool>` back into its parts (null if malformed). */
|
|
67
|
+
export function parseMcpToolName(name) {
|
|
68
|
+
if (!isMcpTool(name))
|
|
69
|
+
return null;
|
|
70
|
+
const rest = name.slice(MCP_TOOL_PREFIX.length);
|
|
71
|
+
const idx = rest.indexOf("__");
|
|
72
|
+
if (idx === -1 || idx === 0 || idx + 2 >= rest.length)
|
|
73
|
+
return null;
|
|
74
|
+
return { server: rest.slice(0, idx), tool: rest.slice(idx + 2) };
|
|
75
|
+
}
|
|
76
|
+
/** One live connection to a spawned MCP server. */
|
|
77
|
+
export class McpConnection {
|
|
78
|
+
name;
|
|
79
|
+
cfg;
|
|
80
|
+
child = null;
|
|
81
|
+
buf = "";
|
|
82
|
+
nextId = 1;
|
|
83
|
+
pending = new Map();
|
|
84
|
+
closed = false;
|
|
85
|
+
tools = [];
|
|
86
|
+
constructor(name, cfg) {
|
|
87
|
+
this.name = name;
|
|
88
|
+
this.cfg = cfg;
|
|
89
|
+
}
|
|
90
|
+
async start(timeoutMs = 15000) {
|
|
91
|
+
this.child = spawn(this.cfg.command, this.cfg.args ?? [], {
|
|
92
|
+
env: { ...process.env, ...(this.cfg.env ?? {}) },
|
|
93
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
94
|
+
});
|
|
95
|
+
this.child.stdout.setEncoding("utf-8");
|
|
96
|
+
this.child.stdout.on("data", (chunk) => this._onData(chunk));
|
|
97
|
+
this.child.on("exit", () => this._fail(new Error(`MCP server '${this.name}' exited`)));
|
|
98
|
+
this.child.on("error", (e) => this._fail(e));
|
|
99
|
+
await this._request("initialize", {
|
|
100
|
+
protocolVersion: PROTOCOL_VERSION,
|
|
101
|
+
capabilities: {},
|
|
102
|
+
clientInfo: { name: "xiaotime-cli", version: "0.6.1" },
|
|
103
|
+
}, timeoutMs);
|
|
104
|
+
this._notify("notifications/initialized", {});
|
|
105
|
+
const listed = (await this._request("tools/list", {}, timeoutMs));
|
|
106
|
+
const raw = Array.isArray(listed?.tools) ? listed.tools : [];
|
|
107
|
+
this.tools = raw
|
|
108
|
+
.filter((t) => t && typeof t.name === "string")
|
|
109
|
+
.map((t) => ({
|
|
110
|
+
name: `${MCP_TOOL_PREFIX}${this.name}__${t.name}`,
|
|
111
|
+
description: t.description ?? `(${this.name}) ${t.name}`,
|
|
112
|
+
input_schema: _normalizeSchema(t.inputSchema),
|
|
113
|
+
}));
|
|
114
|
+
}
|
|
115
|
+
async callTool(tool, args, timeoutMs = 120000) {
|
|
116
|
+
const res = (await this._request("tools/call", { name: tool, arguments: args }, timeoutMs));
|
|
117
|
+
const content = Array.isArray(res?.content) ? res.content : [];
|
|
118
|
+
const text = content
|
|
119
|
+
.map((c) => (typeof c?.text === "string" ? c.text : ""))
|
|
120
|
+
.join("\n")
|
|
121
|
+
.trim();
|
|
122
|
+
return { text: text || "(empty result)", isError: Boolean(res?.isError) };
|
|
123
|
+
}
|
|
124
|
+
stop() {
|
|
125
|
+
this.closed = true;
|
|
126
|
+
for (const [, p] of this.pending) {
|
|
127
|
+
clearTimeout(p.timer);
|
|
128
|
+
p.reject(new Error("connection closed"));
|
|
129
|
+
}
|
|
130
|
+
this.pending.clear();
|
|
131
|
+
try {
|
|
132
|
+
this.child?.kill();
|
|
133
|
+
}
|
|
134
|
+
catch {
|
|
135
|
+
/* already gone */
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
_onData(chunk) {
|
|
139
|
+
this.buf += chunk;
|
|
140
|
+
let nl;
|
|
141
|
+
while ((nl = this.buf.indexOf("\n")) !== -1) {
|
|
142
|
+
const line = this.buf.slice(0, nl).trim();
|
|
143
|
+
this.buf = this.buf.slice(nl + 1);
|
|
144
|
+
if (!line)
|
|
145
|
+
continue;
|
|
146
|
+
let msg;
|
|
147
|
+
try {
|
|
148
|
+
msg = JSON.parse(line);
|
|
149
|
+
}
|
|
150
|
+
catch {
|
|
151
|
+
continue; // non-JSON stderr-ish noise on stdout — skip
|
|
152
|
+
}
|
|
153
|
+
if (typeof msg.id === "number" && this.pending.has(msg.id)) {
|
|
154
|
+
const p = this.pending.get(msg.id);
|
|
155
|
+
clearTimeout(p.timer);
|
|
156
|
+
this.pending.delete(msg.id);
|
|
157
|
+
if (msg.error)
|
|
158
|
+
p.reject(new Error(msg.error.message ?? "MCP error"));
|
|
159
|
+
else
|
|
160
|
+
p.resolve(msg.result);
|
|
161
|
+
}
|
|
162
|
+
// server-initiated notifications are ignored (no id)
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
_request(method, params, timeoutMs) {
|
|
166
|
+
if (this.closed || !this.child) {
|
|
167
|
+
return Promise.reject(new Error("MCP connection not open"));
|
|
168
|
+
}
|
|
169
|
+
const id = this.nextId++;
|
|
170
|
+
const payload = JSON.stringify({ jsonrpc: "2.0", id, method, params }) + "\n";
|
|
171
|
+
return new Promise((resolve, reject) => {
|
|
172
|
+
const timer = setTimeout(() => {
|
|
173
|
+
this.pending.delete(id);
|
|
174
|
+
reject(new Error(`MCP '${this.name}' ${method} timed out`));
|
|
175
|
+
}, timeoutMs);
|
|
176
|
+
this.pending.set(id, { resolve, reject, timer });
|
|
177
|
+
try {
|
|
178
|
+
this.child.stdin.write(payload);
|
|
179
|
+
}
|
|
180
|
+
catch (e) {
|
|
181
|
+
clearTimeout(timer);
|
|
182
|
+
this.pending.delete(id);
|
|
183
|
+
reject(e);
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
_notify(method, params) {
|
|
188
|
+
if (this.closed || !this.child)
|
|
189
|
+
return;
|
|
190
|
+
try {
|
|
191
|
+
this.child.stdin.write(JSON.stringify({ jsonrpc: "2.0", method, params }) + "\n");
|
|
192
|
+
}
|
|
193
|
+
catch {
|
|
194
|
+
/* best-effort */
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
_fail(err) {
|
|
198
|
+
if (this.closed)
|
|
199
|
+
return;
|
|
200
|
+
for (const [, p] of this.pending) {
|
|
201
|
+
clearTimeout(p.timer);
|
|
202
|
+
p.reject(err);
|
|
203
|
+
}
|
|
204
|
+
this.pending.clear();
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
function _normalizeSchema(s) {
|
|
208
|
+
if (s && typeof s === "object" && s.type === "object") {
|
|
209
|
+
const obj = s;
|
|
210
|
+
return {
|
|
211
|
+
type: "object",
|
|
212
|
+
properties: obj.properties ?? {},
|
|
213
|
+
required: Array.isArray(obj.required) ? obj.required : undefined,
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
return { type: "object", properties: {} };
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Owns every live MCP connection for a session. Connects all configured
|
|
220
|
+
* servers concurrently, aggregates their tools into one manifest slice,
|
|
221
|
+
* and routes tool calls to the right server. A server that fails to
|
|
222
|
+
* start is skipped (reported in `errors`), never fatal.
|
|
223
|
+
*/
|
|
224
|
+
export class McpManager {
|
|
225
|
+
conns = new Map();
|
|
226
|
+
async startAll(cfg = loadMcpConfig()) {
|
|
227
|
+
const errors = [];
|
|
228
|
+
const names = Object.keys(cfg.mcpServers);
|
|
229
|
+
await Promise.all(names.map(async (name) => {
|
|
230
|
+
const conn = new McpConnection(name, cfg.mcpServers[name]);
|
|
231
|
+
try {
|
|
232
|
+
await conn.start();
|
|
233
|
+
this.conns.set(name, conn);
|
|
234
|
+
}
|
|
235
|
+
catch (e) {
|
|
236
|
+
errors.push(`${name}: ${e.message}`);
|
|
237
|
+
conn.stop();
|
|
238
|
+
}
|
|
239
|
+
}));
|
|
240
|
+
const tools = [];
|
|
241
|
+
for (const c of this.conns.values())
|
|
242
|
+
tools.push(...c.tools);
|
|
243
|
+
return { tools, errors };
|
|
244
|
+
}
|
|
245
|
+
hasServers() {
|
|
246
|
+
return this.conns.size > 0;
|
|
247
|
+
}
|
|
248
|
+
serverNames() {
|
|
249
|
+
return [...this.conns.keys()];
|
|
250
|
+
}
|
|
251
|
+
async call(name, input, tool_use_id) {
|
|
252
|
+
const parsed = parseMcpToolName(name);
|
|
253
|
+
if (!parsed) {
|
|
254
|
+
return { tool_use_id, content: `Not an MCP tool: ${name}`, is_error: true };
|
|
255
|
+
}
|
|
256
|
+
const conn = this.conns.get(parsed.server);
|
|
257
|
+
if (!conn) {
|
|
258
|
+
return {
|
|
259
|
+
tool_use_id,
|
|
260
|
+
content: `MCP server not connected: ${parsed.server}`,
|
|
261
|
+
is_error: true,
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
try {
|
|
265
|
+
const { text, isError } = await conn.callTool(parsed.tool, input);
|
|
266
|
+
return { tool_use_id, content: text, is_error: isError };
|
|
267
|
+
}
|
|
268
|
+
catch (e) {
|
|
269
|
+
return {
|
|
270
|
+
tool_use_id,
|
|
271
|
+
content: `MCP call failed: ${e.message}`,
|
|
272
|
+
is_error: true,
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
stopAll() {
|
|
277
|
+
for (const c of this.conns.values())
|
|
278
|
+
c.stop();
|
|
279
|
+
this.conns.clear();
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
//# sourceMappingURL=mcp.js.map
|
package/dist/mcp.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"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AE;YAAE,CAAC,CAAC,IAAI,EAAE,CAAC;QAC9C,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;IACrB,CAAC;CACF"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Supervised entry point: connect, and on any close reconnect with capped
|
|
3
|
+
* exponential backoff (reset after an established connection drops). Runs until
|
|
4
|
+
* the process is killed by its supervisor.
|
|
5
|
+
*/
|
|
6
|
+
export declare function runRoomAgent(sessionId: string): Promise<void>;
|
|
7
|
+
//# sourceMappingURL=room_agent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"room_agent.d.ts","sourceRoot":"","sources":["../src/room_agent.ts"],"names":[],"mappings":"AAkaA;;;;GAIG;AACH,wBAAsB,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAgBnE"}
|