reevesagents 1.3.2 → 1.5.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.
@@ -294,6 +294,15 @@ var PROVIDER_DEFS = Object.values(PROVIDER_REGISTRY);
294
294
 
295
295
  // src/core/providers.ts
296
296
  import { execFileSync, spawnSync } from "child_process";
297
+ function coerceExtraArgs(value) {
298
+ if (Array.isArray(value)) {
299
+ return value.filter((item) => typeof item === "string").map((item) => item.trim()).filter(Boolean);
300
+ }
301
+ if (typeof value === "string") {
302
+ return value.trim().split(/\s+/).filter(Boolean);
303
+ }
304
+ return [];
305
+ }
297
306
  var BIN = Object.fromEntries(
298
307
  PROVIDER_DEFS.map((def) => [def.id, def.bin])
299
308
  );
@@ -317,12 +326,12 @@ function providerSupportsEffort(provider) {
317
326
  return PROVIDER_REGISTRY[provider]?.supportsEffort === true;
318
327
  }
319
328
  function buildCommand(opts) {
320
- const { provider, permissions, model, auth_mode = "default", effort = "default" } = opts;
329
+ const { provider, permissions, model, auth_mode = "default", effort = "default", extra_args = [] } = opts;
321
330
  if (!isProvider(provider)) {
322
331
  throw new Error(`Unsupported provider: ${String(provider)}`);
323
332
  }
324
333
  const def = PROVIDER_REGISTRY[provider];
325
- return [def.bin, ...def.buildArgs({ permissions, model, auth_mode, effort })];
334
+ return [def.bin, ...def.buildArgs({ permissions, model, auth_mode, effort }), ...extra_args];
326
335
  }
327
336
  function detectAvailable() {
328
337
  const result = {};
@@ -802,6 +811,11 @@ function listRunHistoryUnlocked() {
802
811
  function listRuns() {
803
812
  return listRunsUnlocked();
804
813
  }
814
+ function latestActiveRun() {
815
+ const active = listRuns();
816
+ if (active.length === 0) return null;
817
+ return active.reduce((latest, run) => run.started_at > latest.started_at ? run : latest);
818
+ }
805
819
  function listRunHistory() {
806
820
  return listRunHistoryUnlocked();
807
821
  }
@@ -973,8 +987,209 @@ function autoCleanupRuns(options = {}) {
973
987
  return { removed, archived };
974
988
  }
975
989
 
976
- // src/core/doctor.ts
990
+ // src/mcp/installer.ts
977
991
  import { execFileSync as execFileSync2 } from "child_process";
992
+ import { realpathSync } from "fs";
993
+ var SERVER_NAME = "reevesagents";
994
+ var SERVER_BIN = "reevesagents";
995
+ var SERVER_ARG = "mcp";
996
+ var MGMT_TIMEOUT_MS = 15e3;
997
+ var STATUS_TIMEOUT_MS = 5e3;
998
+ var VERIFY_TIMEOUT_MS = 2e4;
999
+ function resolveLaunchCmd(entry = process.argv[1]) {
1000
+ if (entry) {
1001
+ try {
1002
+ const real = realpathSync(entry);
1003
+ if (/\.[cm]?js$/.test(real)) return { command: process.execPath, args: [real, SERVER_ARG] };
1004
+ } catch {
1005
+ }
1006
+ }
1007
+ try {
1008
+ const abs = execFileSync2("which", [SERVER_BIN], { encoding: "utf8" }).trim();
1009
+ if (abs) return { command: abs, args: [SERVER_ARG] };
1010
+ } catch {
1011
+ }
1012
+ return { command: SERVER_BIN, args: [SERVER_ARG] };
1013
+ }
1014
+ var HOSTS = [
1015
+ {
1016
+ provider: "cc",
1017
+ // Claude Code defaults a new server to `local` (this directory only); pin
1018
+ // `user` so one attach covers every project on the machine.
1019
+ add: (cmd) => ["mcp", "add", SERVER_NAME, "-s", "user", "--", cmd.command, ...cmd.args],
1020
+ remove: ["mcp", "remove", SERVER_NAME],
1021
+ list: ["mcp", "list"]
1022
+ },
1023
+ {
1024
+ provider: "codex",
1025
+ add: (cmd) => ["mcp", "add", SERVER_NAME, "--", cmd.command, ...cmd.args],
1026
+ remove: ["mcp", "remove", SERVER_NAME],
1027
+ list: ["mcp", "list"]
1028
+ },
1029
+ {
1030
+ provider: "kimi",
1031
+ add: (cmd) => ["mcp", "add", SERVER_NAME, "--", cmd.command, ...cmd.args],
1032
+ remove: ["mcp", "remove", SERVER_NAME],
1033
+ list: ["mcp", "list"]
1034
+ },
1035
+ {
1036
+ provider: "qwen",
1037
+ // qwen (a gemini-cli fork) takes `<commandOrUrl> [args...]` with no `--`
1038
+ // separator, and already defaults its scope to `user`.
1039
+ add: (cmd) => ["mcp", "add", SERVER_NAME, cmd.command, ...cmd.args],
1040
+ remove: ["mcp", "remove", SERVER_NAME],
1041
+ list: ["mcp", "list"]
1042
+ },
1043
+ {
1044
+ provider: "hermes",
1045
+ // hermes takes --command and a variadic --args, so the entry path and `mcp`
1046
+ // both ride on one --args.
1047
+ add: (cmd) => ["mcp", "add", SERVER_NAME, "--command", cmd.command, "--args", ...cmd.args],
1048
+ remove: ["mcp", "remove", SERVER_NAME],
1049
+ list: ["mcp", "list"]
1050
+ },
1051
+ {
1052
+ // opencode's `mcp add` prompts interactively and has no remove subcommand,
1053
+ // so we cannot attach or detach it without a prompt. Report it as manual.
1054
+ provider: "opencode",
1055
+ list: ["mcp", "list"]
1056
+ }
1057
+ ];
1058
+ function hostBin(host) {
1059
+ return PROVIDER_REGISTRY[host.provider].bin;
1060
+ }
1061
+ function hostLabel(host) {
1062
+ return PROVIDER_REGISTRY[host.provider].displayName;
1063
+ }
1064
+ function isInstalled(bin) {
1065
+ try {
1066
+ execFileSync2("which", [bin], { stdio: "pipe" });
1067
+ return true;
1068
+ } catch {
1069
+ return false;
1070
+ }
1071
+ }
1072
+ function isAttached(host) {
1073
+ try {
1074
+ const out = execFileSync2(hostBin(host), host.list, {
1075
+ encoding: "utf8",
1076
+ timeout: STATUS_TIMEOUT_MS,
1077
+ stdio: ["ignore", "pipe", "pipe"]
1078
+ });
1079
+ return /reevesagents(?![-\w])/i.test(out);
1080
+ } catch {
1081
+ return false;
1082
+ }
1083
+ }
1084
+ function runHostCommand(host, args) {
1085
+ execFileSync2(hostBin(host), args, {
1086
+ encoding: "utf8",
1087
+ timeout: MGMT_TIMEOUT_MS,
1088
+ stdio: ["ignore", "pipe", "pipe"]
1089
+ });
1090
+ }
1091
+ function cliError(err) {
1092
+ const stderr = err && typeof err === "object" ? err.stderr : void 0;
1093
+ const text = typeof stderr === "string" ? stderr.trim() : Buffer.isBuffer(stderr) ? stderr.toString("utf8").trim() : "";
1094
+ return text || (err instanceof Error ? err.message : String(err));
1095
+ }
1096
+ function findHost(key) {
1097
+ const host = HOSTS.find((item) => item.provider === key);
1098
+ if (!host) throw new Error(`Unknown CLI: ${key}`);
1099
+ return host;
1100
+ }
1101
+ function hostStatus() {
1102
+ return HOSTS.map((host) => {
1103
+ const installed = isInstalled(hostBin(host));
1104
+ return {
1105
+ key: host.provider,
1106
+ bin: hostBin(host),
1107
+ label: hostLabel(host),
1108
+ installed,
1109
+ attached: installed && isAttached(host),
1110
+ manual: host.add === void 0
1111
+ };
1112
+ });
1113
+ }
1114
+ function attach(key, force = false) {
1115
+ const host = findHost(key);
1116
+ const label = hostLabel(host);
1117
+ if (!host.add) {
1118
+ return {
1119
+ key,
1120
+ label,
1121
+ ok: false,
1122
+ message: `${label} must be added manually: in OpenCode, add a stdio MCP server named "${SERVER_NAME}" that runs reevesagents mcp`
1123
+ };
1124
+ }
1125
+ if (!isInstalled(hostBin(host))) {
1126
+ return { key, label, ok: false, message: `${hostBin(host)} is not installed` };
1127
+ }
1128
+ try {
1129
+ if (force && host.remove) {
1130
+ try {
1131
+ runHostCommand(host, host.remove);
1132
+ } catch {
1133
+ }
1134
+ }
1135
+ runHostCommand(host, host.add(resolveLaunchCmd()));
1136
+ return { key, label, ok: true, message: force ? "reattached" : "attached" };
1137
+ } catch (err) {
1138
+ return { key, label, ok: false, message: cliError(err) };
1139
+ }
1140
+ }
1141
+ function detach(key) {
1142
+ const host = findHost(key);
1143
+ const label = hostLabel(host);
1144
+ if (!host.remove) {
1145
+ return { key, label, ok: false, message: `${label} must be removed manually` };
1146
+ }
1147
+ if (!isInstalled(hostBin(host))) {
1148
+ return { key, label, ok: false, message: `${hostBin(host)} is not installed` };
1149
+ }
1150
+ try {
1151
+ runHostCommand(host, host.remove);
1152
+ return { key, label, ok: true, message: "detached" };
1153
+ } catch (err) {
1154
+ return { key, label, ok: false, message: cliError(err) };
1155
+ }
1156
+ }
1157
+ function attachAll(force = false) {
1158
+ return HOSTS.filter((host) => host.add && isInstalled(hostBin(host))).map((host) => {
1159
+ if (!force && isAttached(host)) {
1160
+ return { key: host.provider, label: hostLabel(host), ok: true, message: "already attached" };
1161
+ }
1162
+ return attach(host.provider, force);
1163
+ });
1164
+ }
1165
+ async function verifyServerLaunch(cmd = resolveLaunchCmd()) {
1166
+ const { Client } = await import("@modelcontextprotocol/sdk/client/index.js");
1167
+ const { StdioClientTransport } = await import("@modelcontextprotocol/sdk/client/stdio.js");
1168
+ const client = new Client({ name: "reevesagents-verify", version: "1" }, { capabilities: {} });
1169
+ const transport = new StdioClientTransport({ command: cmd.command, args: cmd.args, stderr: "ignore" });
1170
+ let timer;
1171
+ const timeout = new Promise((_, reject) => {
1172
+ timer = setTimeout(() => reject(new Error("timed out starting the MCP server")), VERIFY_TIMEOUT_MS);
1173
+ timer.unref?.();
1174
+ });
1175
+ try {
1176
+ await Promise.race([client.connect(transport), timeout]);
1177
+ const listed = await Promise.race([client.listTools(), timeout]);
1178
+ const toolCount = Array.isArray(listed.tools) ? listed.tools.length : 0;
1179
+ return { ok: true, detail: `server started, ${toolCount} tools`, toolCount };
1180
+ } catch (err) {
1181
+ return { ok: false, detail: err instanceof Error ? err.message : String(err) };
1182
+ } finally {
1183
+ if (timer) clearTimeout(timer);
1184
+ try {
1185
+ await client.close();
1186
+ } catch {
1187
+ }
1188
+ }
1189
+ }
1190
+
1191
+ // src/core/doctor.ts
1192
+ import { execFileSync as execFileSync3 } from "child_process";
978
1193
  import { accessSync, constants, existsSync as existsSync2, readFileSync as readFileSync2 } from "fs";
979
1194
  import { createRequire } from "module";
980
1195
  import { join as join2 } from "path";
@@ -1037,7 +1252,7 @@ function platformSupportCheck(platform = process.platform, env = process.env, pr
1037
1252
  }
1038
1253
  function checkTmux() {
1039
1254
  try {
1040
- const versionStr = execFileSync2("tmux", ["-V"], { encoding: "utf8" }).trim();
1255
+ const versionStr = execFileSync3("tmux", ["-V"], { encoding: "utf8" }).trim();
1041
1256
  const match = versionStr.match(/tmux (\d+)\.(\d+)/);
1042
1257
  if (!match) return { name: "tmux", status: "warn", detail: `unexpected version format: ${versionStr}` };
1043
1258
  const major = parseInt(match[1] ?? "0", 10);
@@ -1111,6 +1326,26 @@ function checkRunsState() {
1111
1326
  };
1112
1327
  }
1113
1328
  }
1329
+ function checkMcpServerCommand() {
1330
+ const cmd = resolveLaunchCmd();
1331
+ if (cmd.command === "reevesagents") {
1332
+ return {
1333
+ name: "mcp server",
1334
+ status: "warn",
1335
+ detail: "no absolute launcher resolved; attached host CLIs will fall back to their own PATH"
1336
+ };
1337
+ }
1338
+ try {
1339
+ accessSync(cmd.command, constants.X_OK);
1340
+ return { name: "mcp server", status: "ok", detail: `${cmd.command} ${cmd.args.join(" ")}` };
1341
+ } catch {
1342
+ return {
1343
+ name: "mcp server",
1344
+ status: "warn",
1345
+ detail: `${cmd.command} is not executable; re-run reevesagents attach after reinstalling`
1346
+ };
1347
+ }
1348
+ }
1114
1349
  function runDoctor() {
1115
1350
  return {
1116
1351
  checks: [
@@ -1123,7 +1358,8 @@ function runDoctor() {
1123
1358
  checkPathAccess("runs dir", runsDir()),
1124
1359
  checkPathAccess("presets dir", join2(stateRoot(), "presets")),
1125
1360
  checkRunsState(),
1126
- checkWebExtras()
1361
+ checkWebExtras(),
1362
+ checkMcpServerCommand()
1127
1363
  ]
1128
1364
  };
1129
1365
  }
@@ -1395,7 +1631,7 @@ function savePresetFromRun(runId, name, description = "") {
1395
1631
  }
1396
1632
 
1397
1633
  // src/core/runtime.ts
1398
- import { execFileSync as execFileSync3 } from "child_process";
1634
+ import { execFileSync as execFileSync4 } from "child_process";
1399
1635
  import { randomUUID as randomUUID2 } from "crypto";
1400
1636
  import stripAnsi from "strip-ansi";
1401
1637
 
@@ -1434,7 +1670,7 @@ var ALLOWED_KEYS = [
1434
1670
  ];
1435
1671
  var realDriver = {
1436
1672
  tmux(args, input) {
1437
- return execFileSync3("tmux", args, {
1673
+ return execFileSync4("tmux", args, {
1438
1674
  encoding: "utf8",
1439
1675
  input,
1440
1676
  stdio: input === void 0 ? ["ignore", "pipe", "pipe"] : ["pipe", "pipe", "pipe"]
@@ -1561,7 +1797,8 @@ function terminalShellCommand(config, permissions) {
1561
1797
  model: config.model,
1562
1798
  auth_mode: config.auth_mode,
1563
1799
  effort: config.effort,
1564
- rc_enabled: false
1800
+ rc_enabled: false,
1801
+ extra_args: config.extra_args
1565
1802
  });
1566
1803
  return `exec ${cmd.map(shellQuote).join(" ")}`;
1567
1804
  }
@@ -1972,8 +2209,8 @@ function openTmuxTarget(id, options = {}) {
1972
2209
  }
1973
2210
 
1974
2211
  export {
1975
- PROVIDER_REGISTRY,
1976
2212
  PROVIDER_DEFS,
2213
+ coerceExtraArgs,
1977
2214
  BIN,
1978
2215
  PROVIDERS,
1979
2216
  isProvider,
@@ -1997,6 +2234,7 @@ export {
1997
2234
  withRunsLock,
1998
2235
  readRun,
1999
2236
  listRuns,
2237
+ latestActiveRun,
2000
2238
  listRunHistory,
2001
2239
  deleteAgent,
2002
2240
  deleteRunHistory,
@@ -2007,6 +2245,14 @@ export {
2007
2245
  findAgent,
2008
2246
  runHasLiveTmuxTarget,
2009
2247
  autoCleanupRuns,
2248
+ resolveLaunchCmd,
2249
+ hostStatus,
2250
+ attach,
2251
+ detach,
2252
+ attachAll,
2253
+ verifyServerLaunch,
2254
+ nodeVersionCheck,
2255
+ checkTmux,
2010
2256
  runDoctor,
2011
2257
  LANGUAGE_OPTIONS,
2012
2258
  DEFAULT_LANGUAGE,
@@ -2042,4 +2288,4 @@ export {
2042
2288
  stopRun,
2043
2289
  openTmuxTarget
2044
2290
  };
2045
- //# sourceMappingURL=chunk-36SYE7IU.js.map
2291
+ //# sourceMappingURL=chunk-LKJSQLX2.js.map
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  PROVIDER_DEFS
4
- } from "./chunk-36SYE7IU.js";
4
+ } from "./chunk-LKJSQLX2.js";
5
5
 
6
6
  // src/core/model-catalog.ts
7
7
  var PROVIDER_DEFAULT_MODEL = "";
@@ -27,4 +27,4 @@ export {
27
27
  modelDisplayName,
28
28
  modelSourceForProvider
29
29
  };
30
- //# sourceMappingURL=chunk-TO32PH23.js.map
30
+ //# sourceMappingURL=chunk-LZMMFJYG.js.map
@@ -0,0 +1,61 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ attachAll,
4
+ checkTmux,
5
+ detectAvailable,
6
+ hostStatus,
7
+ nodeVersionCheck,
8
+ resolveLaunchCmd,
9
+ stateRoot,
10
+ verifyServerLaunch
11
+ } from "./chunk-LKJSQLX2.js";
12
+
13
+ // src/core/onboard.ts
14
+ function buildOnboardingState() {
15
+ const available = detectAvailable();
16
+ const installedProviders = Object.keys(available).filter((p) => available[p]);
17
+ const hosts = hostStatus();
18
+ const tmuxOk = checkTmux().status !== "fail";
19
+ return {
20
+ tmuxOk,
21
+ nodeOk: nodeVersionCheck().status === "ok",
22
+ installedProviders,
23
+ hosts,
24
+ attachable: hosts.filter((h) => h.installed && !h.manual && !h.attached).map((h) => h.key),
25
+ attachedHosts: hosts.filter((h) => h.attached).map((h) => h.key),
26
+ launcherAbsolute: resolveLaunchCmd().command !== "reevesagents",
27
+ ready: tmuxOk && installedProviders.length > 0
28
+ };
29
+ }
30
+ async function runOnboarding() {
31
+ const attached = attachAll();
32
+ const verify = attached.some((result) => result.ok) ? await verifyServerLaunch() : null;
33
+ return { attached, verify };
34
+ }
35
+
36
+ // src/core/tui-open.ts
37
+ import { mkdirSync, readFileSync, writeFileSync } from "fs";
38
+ import { join } from "path";
39
+ function tokenPath() {
40
+ return join(stateRoot(), "tui-open-token");
41
+ }
42
+ function readTuiOpenToken() {
43
+ try {
44
+ return readFileSync(tokenPath(), "utf-8").trim();
45
+ } catch {
46
+ return "";
47
+ }
48
+ }
49
+ function writeTuiOpenToken() {
50
+ mkdirSync(stateRoot(), { recursive: true });
51
+ writeFileSync(tokenPath(), `${Date.now()}
52
+ `, "utf-8");
53
+ }
54
+
55
+ export {
56
+ buildOnboardingState,
57
+ runOnboarding,
58
+ readTuiOpenToken,
59
+ writeTuiOpenToken
60
+ };
61
+ //# sourceMappingURL=chunk-OHEIERAD.js.map