reevesagents 1.2.0 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,622 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ REEVESAGENTS_VERSION,
4
+ attach,
5
+ attachAll,
6
+ createRunApproval,
7
+ detach,
8
+ hostStatus,
9
+ listRunApprovals,
10
+ readRunApproval,
11
+ resolveRunApproval
12
+ } from "./chunk-Z2JHNE7V.js";
13
+ import {
14
+ ALLOWED_KEYS,
15
+ BIN,
16
+ CONFIG_FIELDS,
17
+ PROVIDER_DEFS,
18
+ archiveAndRemoveRun,
19
+ deleteAgent,
20
+ deletePreset,
21
+ deleteRunHistory,
22
+ detectAvailable,
23
+ findAgent,
24
+ interrupt,
25
+ isProvider,
26
+ killAgent,
27
+ listAgents,
28
+ listPresets,
29
+ listRunHistory,
30
+ listRuns,
31
+ loadConfig,
32
+ openTmuxTarget,
33
+ peekAgent,
34
+ readRun,
35
+ runDoctor,
36
+ savePresetFromRun,
37
+ sendKey,
38
+ sendText,
39
+ setConfigValues,
40
+ spawnWorker,
41
+ startRun,
42
+ startRunFromPreset,
43
+ startRunWithHead,
44
+ stopRun
45
+ } from "./chunk-65LHCGPC.js";
46
+ import "./chunk-D24DQQ6V.js";
47
+
48
+ // src/mcp/server.ts
49
+ import { Server } from "@modelcontextprotocol/sdk/server/index.js";
50
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
51
+ import {
52
+ CallToolRequestSchema,
53
+ ListResourcesRequestSchema,
54
+ ListToolsRequestSchema,
55
+ ReadResourceRequestSchema
56
+ } from "@modelcontextprotocol/sdk/types.js";
57
+
58
+ // src/mcp/host.ts
59
+ import { execFileSync } from "child_process";
60
+ import { readFileSync } from "fs";
61
+ import { basename } from "path";
62
+ var PROVIDER_BY_BIN = Object.fromEntries(
63
+ Object.entries(BIN).map(([provider, bin]) => [bin, provider])
64
+ );
65
+ function providerFromParent(comm, argv) {
66
+ const byComm = comm ? PROVIDER_BY_BIN[basename(comm)] : void 0;
67
+ if (byComm) return byComm;
68
+ for (const arg of argv) {
69
+ if (!arg) continue;
70
+ const match = PROVIDER_BY_BIN[basename(arg)];
71
+ if (match) return match;
72
+ }
73
+ return null;
74
+ }
75
+ function readParentComm(ppid) {
76
+ try {
77
+ return readFileSync(`/proc/${ppid}/comm`, "utf8").trim();
78
+ } catch {
79
+ return execFileSync("ps", ["-o", "comm=", "-p", String(ppid)], { encoding: "utf8" }).trim();
80
+ }
81
+ }
82
+ function readParentArgv(ppid) {
83
+ try {
84
+ return readFileSync(`/proc/${ppid}/cmdline`, "utf8").split("\0").filter(Boolean);
85
+ } catch {
86
+ try {
87
+ return execFileSync("ps", ["-o", "args=", "-p", String(ppid)], { encoding: "utf8" }).trim().split(/\s+/).filter(Boolean);
88
+ } catch {
89
+ return [];
90
+ }
91
+ }
92
+ }
93
+ function detectHostProvider() {
94
+ try {
95
+ return providerFromParent(readParentComm(process.ppid), readParentArgv(process.ppid));
96
+ } catch {
97
+ return null;
98
+ }
99
+ }
100
+
101
+ // src/mcp/server.ts
102
+ var hostProvider = detectHostProvider();
103
+ var sessionRunId = null;
104
+ function ok(data) {
105
+ return { content: [{ type: "text", text: JSON.stringify(data) }] };
106
+ }
107
+ function fail(message) {
108
+ return {
109
+ content: [{ type: "text", text: JSON.stringify({ error: message }) }],
110
+ isError: true
111
+ };
112
+ }
113
+ function asString(value, fallback = "") {
114
+ return typeof value === "string" ? value : fallback;
115
+ }
116
+ function parseProvider(value) {
117
+ if (isProvider(value)) return value;
118
+ throw new Error(`Unsupported provider: ${String(value)}`);
119
+ }
120
+ function parseKey(value) {
121
+ if (typeof value === "string" && ALLOWED_KEYS.includes(value)) return value;
122
+ throw new Error(`Unsupported key: ${String(value)}. Allowed: ${ALLOWED_KEYS.join(", ")}`);
123
+ }
124
+ function parseRisk(value) {
125
+ return value === "low" || value === "high" ? value : "medium";
126
+ }
127
+ function parseApprovalStatus(value) {
128
+ if (value === "pending" || value === "approved" || value === "denied" || value === "expired") return value;
129
+ return void 0;
130
+ }
131
+ function parsePermissions(value) {
132
+ return value === "ask" || value === "skip" ? value : void 0;
133
+ }
134
+ function parseAuthMode(value) {
135
+ return value === "default" || value === "api-key" ? value : void 0;
136
+ }
137
+ function parseEffort(value) {
138
+ if (value === "default" || value === "low" || value === "medium" || value === "high" || value === "xhigh" || value === "max") return value;
139
+ return void 0;
140
+ }
141
+ function sessionRunIsLive(runId) {
142
+ try {
143
+ const run = readRun(runId);
144
+ return run.status !== "ended" && run.ended_at === null;
145
+ } catch {
146
+ return false;
147
+ }
148
+ }
149
+ var PROVIDER_CATALOG_URI = "reevesagents://providers";
150
+ function buildProviderCatalog() {
151
+ const available = detectAvailable();
152
+ return PROVIDER_DEFS.map((def) => ({
153
+ id: def.id,
154
+ display_name: def.displayName,
155
+ bin: def.bin,
156
+ available: available[def.id],
157
+ aliases: [...def.aliases],
158
+ models: [...def.models],
159
+ model_source: def.modelSource
160
+ }));
161
+ }
162
+ function spawnHandler(a) {
163
+ const provider = parseProvider(a.provider);
164
+ const config = {
165
+ provider,
166
+ model: asString(a.model),
167
+ task: asString(a.task),
168
+ nickname: typeof a.nickname === "string" ? a.nickname : void 0,
169
+ working_dir: typeof a.working_dir === "string" ? a.working_dir : void 0,
170
+ permissions: parsePermissions(a.permissions),
171
+ auth_mode: parseAuthMode(a.auth_mode),
172
+ effort: parseEffort(a.effort)
173
+ };
174
+ if (typeof a.run_id === "string" && a.run_id.trim()) {
175
+ const cap = loadConfig().global.max_agents;
176
+ const live = listAgents(a.run_id).filter((agent) => !agent.ended_at && !agent.headless).length;
177
+ if (live >= cap) return fail(`run ${a.run_id} is at the agent cap (${cap}); raise max_agents in config to add more`);
178
+ return ok(spawnWorker({ ...config, run_id: a.run_id }));
179
+ }
180
+ if (sessionRunId && sessionRunIsLive(sessionRunId)) {
181
+ const cap = loadConfig().global.max_agents;
182
+ const live = listAgents(sessionRunId).filter((agent) => !agent.ended_at && !agent.headless).length;
183
+ if (live >= cap) return fail(`run ${sessionRunId} is at the agent cap (${cap}); raise max_agents in config to add more`);
184
+ return ok(spawnWorker({ ...config, run_id: sessionRunId }));
185
+ }
186
+ sessionRunId = null;
187
+ if (hostProvider) {
188
+ const result2 = startRunWithHead(hostProvider, config);
189
+ sessionRunId = result2.run.id;
190
+ return ok({ run: result2.run, agents: result2.agents });
191
+ }
192
+ const runName = typeof a.name === "string" && a.name.trim() ? a.name : config.nickname ?? provider;
193
+ const result = startRun({
194
+ name: runName,
195
+ working_dir: asString(a.working_dir, process.cwd()),
196
+ root: config
197
+ });
198
+ sessionRunId = result.run.id;
199
+ return ok({ run: result.run, agents: result.agents });
200
+ }
201
+ var TOOLS = [
202
+ {
203
+ name: "spawn",
204
+ description: "Start a CLI agent in its own tmux window and return its agent_id (use it with send_text, send_key, read, kill) and run_id. Omit run_id to add the agent to this MCP session run, created on the first spawn so a chain of spawns stays in one run; pass run_id to add it to an existing run. Call list_providers for valid provider keys.",
205
+ inputSchema: {
206
+ type: "object",
207
+ properties: {
208
+ run_id: { type: "string", description: "Add to this run. Omit to start a new run." },
209
+ provider: { type: "string", description: "Provider key, e.g. cc, codex, kimi, qwen, opencode, hermes." },
210
+ model: { type: "string", description: "Model id. Blank keeps the provider default." },
211
+ task: { type: "string", description: "Initial prompt pasted into the agent on startup." },
212
+ nickname: { type: "string" },
213
+ name: { type: "string", description: "Run name when starting a new run." },
214
+ working_dir: { type: "string" },
215
+ permissions: { type: "string", enum: ["ask", "skip"], description: "ask prompts for each action; skip runs autonomously. Blank uses the global default." },
216
+ auth_mode: { type: "string", enum: ["default", "api-key"], description: "How the CLI authenticates. Blank uses the provider default." },
217
+ effort: { type: "string", enum: ["default", "low", "medium", "high", "xhigh", "max"], description: "Reasoning effort, for providers that support it. Blank uses the provider default." }
218
+ },
219
+ required: ["provider"]
220
+ },
221
+ handler: spawnHandler
222
+ },
223
+ {
224
+ name: "kill",
225
+ description: "Stop one agent and close its tmux window. Pass an agent_id from spawn or list. Once it is ended you can remove its record with delete.",
226
+ inputSchema: {
227
+ type: "object",
228
+ properties: { agent_id: { type: "string" } },
229
+ required: ["agent_id"]
230
+ },
231
+ handler: (a) => ok(killAgent(String(a.agent_id)))
232
+ },
233
+ {
234
+ name: "stop",
235
+ description: "Stop a whole run: end every agent in it and tear down its tmux session. Pass a run_id from spawn or list. Once ended, remove it with delete_run.",
236
+ inputSchema: {
237
+ type: "object",
238
+ properties: { run_id: { type: "string" } },
239
+ required: ["run_id"]
240
+ },
241
+ handler: (a) => ok(stopRun(String(a.run_id)))
242
+ },
243
+ {
244
+ name: "send_text",
245
+ description: "Paste text into one agent at its prompt. This does NOT submit it: follow with send_key enter to send. Use it to give a running agent a new instruction.",
246
+ inputSchema: {
247
+ type: "object",
248
+ properties: {
249
+ agent_id: { type: "string" },
250
+ text: { type: "string" }
251
+ },
252
+ required: ["agent_id", "text"]
253
+ },
254
+ handler: (a) => {
255
+ sendText(String(a.agent_id), asString(a.text));
256
+ return ok({ sent: true });
257
+ }
258
+ },
259
+ {
260
+ name: "send_key",
261
+ description: "Press one key in an agent: enter, escape, tab, space, up, down, left, right, backspace, or ctrl-c. Send enter after send_text to submit the pasted text.",
262
+ inputSchema: {
263
+ type: "object",
264
+ properties: {
265
+ agent_id: { type: "string" },
266
+ key: { type: "string", enum: [...ALLOWED_KEYS] }
267
+ },
268
+ required: ["agent_id", "key"]
269
+ },
270
+ handler: (a) => {
271
+ sendKey(String(a.agent_id), parseKey(a.key));
272
+ return ok({ sent: true });
273
+ }
274
+ },
275
+ {
276
+ name: "interrupt",
277
+ description: "Press ctrl-c in one agent to interrupt whatever it is doing.",
278
+ inputSchema: {
279
+ type: "object",
280
+ properties: { agent_id: { type: "string" } },
281
+ required: ["agent_id"]
282
+ },
283
+ handler: (a) => {
284
+ interrupt(String(a.agent_id));
285
+ return ok({ sent: true });
286
+ }
287
+ },
288
+ {
289
+ name: "read",
290
+ description: "Read one agent's recent terminal output, ANSI-stripped and secret-redacted. Use it to see what the agent printed or is waiting on. Defaults to the last 20 lines.",
291
+ inputSchema: {
292
+ type: "object",
293
+ properties: {
294
+ agent_id: { type: "string" },
295
+ lines: { type: "number", description: "How many lines, default 20." }
296
+ },
297
+ required: ["agent_id"]
298
+ },
299
+ handler: (a) => {
300
+ findAgent(String(a.agent_id));
301
+ const lines = typeof a.lines === "number" && a.lines > 0 ? Math.floor(a.lines) : 20;
302
+ return ok(peekAgent(String(a.agent_id), lines));
303
+ }
304
+ },
305
+ {
306
+ name: "list",
307
+ description: "List every live run and the agents in each, with their ids, status, provider, and tmux info. Start here to find a run_id or agent_id for the other tools. Ended runs are in list_history.",
308
+ inputSchema: { type: "object", properties: {} },
309
+ handler: () => ok(listRuns().map((run) => ({ ...run, agents: listAgents(run.id) })))
310
+ },
311
+ {
312
+ name: "list_providers",
313
+ description: "List the CLI providers this machine can launch: id, display name, whether it is installed, aliases, and known models. Pass an id as the provider for spawn.",
314
+ inputSchema: { type: "object", properties: {} },
315
+ handler: () => ok(buildProviderCatalog())
316
+ },
317
+ {
318
+ name: "request_approval",
319
+ description: "Ask for approval before a risky action. Creates a pending approval that a human or another agent clears with resolve_approval, and returns it with its approval_id.",
320
+ inputSchema: {
321
+ type: "object",
322
+ properties: {
323
+ agent_id: { type: "string", description: "The agent asking for approval." },
324
+ action: { type: "string" },
325
+ summary: { type: "string" },
326
+ details: { type: "object" },
327
+ risk: { type: "string", enum: ["low", "medium", "high"] }
328
+ },
329
+ required: ["agent_id", "action", "summary"]
330
+ },
331
+ handler: (a) => {
332
+ const action = asString(a.action).trim();
333
+ const summary = asString(a.summary).trim();
334
+ if (!action) return fail("approval action is required");
335
+ if (!summary) return fail("approval summary is required");
336
+ return ok(createRunApproval({
337
+ agent_id: String(a.agent_id),
338
+ action,
339
+ summary,
340
+ details: typeof a.details === "object" && a.details !== null ? a.details : {},
341
+ risk: parseRisk(a.risk)
342
+ }));
343
+ }
344
+ },
345
+ {
346
+ name: "resolve_approval",
347
+ description: "Approve or deny one pending approval by its approval_id (from list_approvals). An optional note records why.",
348
+ inputSchema: {
349
+ type: "object",
350
+ properties: {
351
+ approval_id: { type: "string" },
352
+ decision: { type: "string", enum: ["approved", "denied"] },
353
+ note: { type: "string" }
354
+ },
355
+ required: ["approval_id", "decision"]
356
+ },
357
+ handler: (a) => {
358
+ const decision = a.decision === "approved" ? "approved" : a.decision === "denied" ? "denied" : null;
359
+ if (!decision) throw new Error("decision must be approved or denied");
360
+ return ok(resolveRunApproval(String(a.approval_id), decision, typeof a.note === "string" ? a.note : ""));
361
+ }
362
+ },
363
+ {
364
+ name: "check_approval",
365
+ description: "Read one approval's current status (pending, approved, denied, or expired) by its approval_id.",
366
+ inputSchema: {
367
+ type: "object",
368
+ properties: { approval_id: { type: "string" } },
369
+ required: ["approval_id"]
370
+ },
371
+ handler: (a) => {
372
+ const approval = listRunApprovals().find((item) => item.id === String(a.approval_id));
373
+ if (!approval) throw new Error(`Approval not found: ${String(a.approval_id)}`);
374
+ return ok(readRunApproval(approval.run_id, approval.id));
375
+ }
376
+ },
377
+ {
378
+ name: "list_approvals",
379
+ description: "List approval requests, optionally filtered by run_id or status (pending, approved, denied, expired). Use it to find an approval_id to resolve.",
380
+ inputSchema: {
381
+ type: "object",
382
+ properties: {
383
+ run_id: { type: "string" },
384
+ status: { type: "string", enum: ["pending", "approved", "denied", "expired"] }
385
+ }
386
+ },
387
+ handler: (a) => ok(listRunApprovals(typeof a.run_id === "string" ? a.run_id : void 0, parseApprovalStatus(a.status)))
388
+ },
389
+ {
390
+ name: "list_history",
391
+ description: "List archived run history: runs that have ended or gone stale. Live runs are in list, not here.",
392
+ inputSchema: { type: "object", properties: {} },
393
+ handler: () => ok(listRunHistory())
394
+ },
395
+ {
396
+ name: "delete",
397
+ description: "Permanently remove one ended agent's record. Kill the agent first; a still-running agent is rejected.",
398
+ inputSchema: {
399
+ type: "object",
400
+ properties: { agent_id: { type: "string" } },
401
+ required: ["agent_id"]
402
+ },
403
+ handler: (a) => {
404
+ const agent = findAgent(String(a.agent_id));
405
+ if (!agent.ended_at) return fail("Stop agent before deleting it");
406
+ return ok(deleteAgent(String(a.agent_id)));
407
+ }
408
+ },
409
+ {
410
+ name: "delete_run",
411
+ description: "Permanently remove one ended run, archiving it to history. Stop the run first; a still-running run is rejected.",
412
+ inputSchema: {
413
+ type: "object",
414
+ properties: { run_id: { type: "string" } },
415
+ required: ["run_id"]
416
+ },
417
+ handler: (a) => {
418
+ const run = readRun(String(a.run_id));
419
+ if (run.status !== "ended" && run.ended_at === null) return fail("Stop run before deleting it");
420
+ return ok(archiveAndRemoveRun(run.id, "ended"));
421
+ }
422
+ },
423
+ {
424
+ name: "delete_history",
425
+ description: "Permanently remove one archived run history record by its id (from list_history).",
426
+ inputSchema: {
427
+ type: "object",
428
+ properties: { id: { type: "string" } },
429
+ required: ["id"]
430
+ },
431
+ handler: (a) => {
432
+ const id = String(a.id);
433
+ if (!listRunHistory().some((record) => record.id === id)) return fail("history record not found");
434
+ deleteRunHistory(id);
435
+ return ok({ deleted: true, id });
436
+ }
437
+ },
438
+ {
439
+ name: "open",
440
+ description: "Open a run or agent in tmux for the user: switch the attached tmux client to a run (its reeves tab) or to a specific agent window. Works for any run, whether this agent started it or not, so you can surface any run for the user on request. No effect when nobody is attached.",
441
+ inputSchema: {
442
+ type: "object",
443
+ properties: {
444
+ id: { type: "string", description: "A run id or an agent id (from list). A run id opens its reeves tab; an agent id opens that agent window." }
445
+ },
446
+ required: ["id"]
447
+ },
448
+ handler: (a) => ok(openTmuxTarget(asString(a.id)))
449
+ },
450
+ {
451
+ name: "doctor",
452
+ description: "Check this machine for running agents: tmux availability, which provider CLIs are installed, and the state directories. Returns each check with an ok/warn/fail status and a detail string. Run it when a spawn fails to see what is missing.",
453
+ inputSchema: { type: "object", properties: {} },
454
+ handler: () => ok(runDoctor().checks)
455
+ },
456
+ {
457
+ name: "get_config",
458
+ description: "Read the global reevesagents settings: peek_interval_ms, peek_lines, max_depth, max_agents (the per-run agent cap), ready_delay_ms, default_permissions, and language. Check max_agents here when a spawn is rejected for hitting the cap.",
459
+ inputSchema: { type: "object", properties: {} },
460
+ handler: () => ok(loadConfig().global)
461
+ },
462
+ {
463
+ name: "set_config",
464
+ description: 'Change one or more global settings and save them. Pass only the fields to change. Counts must be positive integers (ready_delay_ms may be 0); default_permissions is ask or skip; language is a supported code such as en or tr. Example: raise the per-run agent cap with { "max_agents": 20 }. Returns the saved settings.',
465
+ inputSchema: {
466
+ type: "object",
467
+ properties: {
468
+ peek_interval_ms: { type: "number", description: "Milliseconds between output peek polls." },
469
+ peek_lines: { type: "number", description: "Lines captured per peek." },
470
+ max_depth: { type: "number", description: "Spawn recursion cap." },
471
+ max_agents: { type: "number", description: "Max agents per run." },
472
+ ready_delay_ms: { type: "number", description: "Delay before the startup prompt is injected." },
473
+ default_permissions: { type: "string", enum: ["ask", "skip"], description: "Permission mode used when a spawn omits one." },
474
+ language: { type: "string", description: "UI language code for the TUI and web UI, e.g. en, tr." }
475
+ }
476
+ },
477
+ handler: (a) => {
478
+ const patch = {};
479
+ for (const field of CONFIG_FIELDS) {
480
+ if (a[field.key] !== void 0) patch[field.key] = a[field.key];
481
+ }
482
+ if (Object.keys(patch).length === 0) return fail("no config fields to set");
483
+ return ok(setConfigValues(patch).global);
484
+ }
485
+ },
486
+ {
487
+ name: "list_presets",
488
+ description: "List saved run presets: reusable agent-team templates, each with a root agent and workers. Launch a whole team at once by passing a preset name to start_preset.",
489
+ inputSchema: { type: "object", properties: {} },
490
+ handler: () => ok(listPresets())
491
+ },
492
+ {
493
+ name: "save_preset",
494
+ description: "Save a live run's agent line-up as a reusable preset under a name, so the same team can be relaunched later with start_preset. Pass a run_id from list. Re-saving the same name updates it. Note: a captured agent's auth_mode and effort are not stored (they default).",
495
+ inputSchema: {
496
+ type: "object",
497
+ properties: {
498
+ run_id: { type: "string", description: "The run whose agents become the preset (from list)." },
499
+ name: { type: "string", description: "Preset name; characters that are not filename-safe are replaced." },
500
+ description: { type: "string" }
501
+ },
502
+ required: ["run_id", "name"]
503
+ },
504
+ handler: (a) => ok(savePresetFromRun(String(a.run_id), asString(a.name), asString(a.description)))
505
+ },
506
+ {
507
+ name: "start_preset",
508
+ description: "Launch a new run from a saved preset (see list_presets), starting its root agent and every worker at once. Optionally override the run name and working_dir. Returns the new run and its agents.",
509
+ inputSchema: {
510
+ type: "object",
511
+ properties: {
512
+ name: { type: "string", description: "Preset name to launch (from list_presets)." },
513
+ run_name: { type: "string", description: "Run name; defaults to the preset name." },
514
+ working_dir: { type: "string" }
515
+ },
516
+ required: ["name"]
517
+ },
518
+ handler: (a) => {
519
+ const presetName = asString(a.name);
520
+ if (!listPresets().some((preset) => preset.name === presetName)) return fail(`preset not found: ${presetName}`);
521
+ const result = startRunFromPreset(presetName, {
522
+ name: typeof a.run_name === "string" ? a.run_name : void 0,
523
+ working_dir: typeof a.working_dir === "string" ? a.working_dir : void 0
524
+ });
525
+ return ok({ run: result.run, agents: result.agents });
526
+ }
527
+ },
528
+ {
529
+ name: "delete_preset",
530
+ description: "Permanently delete a saved preset by its name (from list_presets). Does not affect any running run.",
531
+ inputSchema: {
532
+ type: "object",
533
+ properties: { name: { type: "string" } },
534
+ required: ["name"]
535
+ },
536
+ handler: (a) => {
537
+ const name = asString(a.name);
538
+ if (!listPresets().some((preset) => preset.name === name)) return fail("preset not found");
539
+ deletePreset(name);
540
+ return ok({ deleted: true, name });
541
+ }
542
+ },
543
+ {
544
+ name: "list_hosts",
545
+ description: "List the AI CLIs on this machine that can host the reevesagents MCP and whether reevesagents is attached to each. Use it to see where this control surface is wired before attach_host or detach_host.",
546
+ inputSchema: { type: "object", properties: {} },
547
+ handler: () => ok(hostStatus())
548
+ },
549
+ {
550
+ name: "attach_host",
551
+ description: "Attach the reevesagents MCP to one host CLI by its key (from list_hosts), or to every installed host when key is omitted. After attaching, that CLI can drive agents through these same tools.",
552
+ inputSchema: {
553
+ type: "object",
554
+ properties: { key: { type: "string", description: "Host key from list_hosts, e.g. cc or codex. Omit to attach all installed hosts." } }
555
+ },
556
+ handler: (a) => {
557
+ const key = asString(a.key).trim();
558
+ return ok(key ? [attach(key)] : attachAll());
559
+ }
560
+ },
561
+ {
562
+ name: "detach_host",
563
+ description: "Detach the reevesagents MCP from one host CLI by its key (from list_hosts). The CLI keeps running but can no longer drive agents through reevesagents.",
564
+ inputSchema: {
565
+ type: "object",
566
+ properties: { key: { type: "string" } },
567
+ required: ["key"]
568
+ },
569
+ handler: (a) => ok(detach(asString(a.key)))
570
+ }
571
+ ];
572
+ var MCP_TOOLS = TOOLS.map(({ name, description, inputSchema }) => ({ name, description, inputSchema }));
573
+ var TOOL_BY_NAME = new Map(TOOLS.map((tool) => [tool.name, tool]));
574
+ function handleAgentMcpTool(name, a) {
575
+ const tool = TOOL_BY_NAME.get(name);
576
+ if (!tool) return fail(`Unknown tool: ${name}`);
577
+ try {
578
+ return tool.handler(a);
579
+ } catch (e) {
580
+ return fail(e instanceof Error ? e.message : String(e));
581
+ }
582
+ }
583
+ async function startAgentMcpServer() {
584
+ const server = new Server(
585
+ { name: "reevesagents", version: REEVESAGENTS_VERSION },
586
+ { capabilities: { tools: {}, resources: {} } }
587
+ );
588
+ server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: MCP_TOOLS }));
589
+ server.setRequestHandler(CallToolRequestSchema, async (request) => {
590
+ const { name, arguments: args = {} } = request.params;
591
+ return handleAgentMcpTool(name, args);
592
+ });
593
+ server.setRequestHandler(ListResourcesRequestSchema, async () => ({
594
+ resources: [
595
+ {
596
+ uri: PROVIDER_CATALOG_URI,
597
+ name: "Providers and models",
598
+ description: "CLI providers this machine can launch and their known models.",
599
+ mimeType: "application/json"
600
+ }
601
+ ]
602
+ }));
603
+ server.setRequestHandler(ReadResourceRequestSchema, async (request) => {
604
+ const { uri } = request.params;
605
+ if (uri !== PROVIDER_CATALOG_URI) throw new Error(`Unknown resource: ${uri}`);
606
+ return {
607
+ contents: [
608
+ { uri, mimeType: "application/json", text: JSON.stringify(buildProviderCatalog()) }
609
+ ]
610
+ };
611
+ });
612
+ const transport = new StdioServerTransport();
613
+ await server.connect(transport);
614
+ }
615
+ export {
616
+ MCP_TOOLS,
617
+ buildProviderCatalog,
618
+ handleAgentMcpTool,
619
+ sessionRunIsLive,
620
+ startAgentMcpServer
621
+ };
622
+ //# sourceMappingURL=server-H2XEJQYT.js.map
@@ -2,9 +2,9 @@
2
2
  import {
3
3
  closeTuiWebServer,
4
4
  startWebFromTui
5
- } from "./chunk-4Q3JF22J.js";
5
+ } from "./chunk-2LC6V55H.js";
6
6
  export {
7
7
  closeTuiWebServer,
8
8
  startWebFromTui
9
9
  };
10
- //# sourceMappingURL=tui-launch-7RGFE5KY.js.map
10
+ //# sourceMappingURL=tui-launch-45ERRX5M.js.map