claudemesh-cli 1.30.1 → 1.31.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/entrypoints/cli.js +158 -71
- package/dist/entrypoints/cli.js.map +12 -11
- package/dist/entrypoints/mcp.js +2 -2
- package/dist/entrypoints/mcp.js.map +1 -1
- package/package.json +1 -1
package/dist/entrypoints/cli.js
CHANGED
|
@@ -104,7 +104,7 @@ __export(exports_urls, {
|
|
|
104
104
|
VERSION: () => VERSION,
|
|
105
105
|
URLS: () => URLS
|
|
106
106
|
});
|
|
107
|
-
var URLS, VERSION = "1.
|
|
107
|
+
var URLS, VERSION = "1.31.0", env;
|
|
108
108
|
var init_urls = __esm(() => {
|
|
109
109
|
URLS = {
|
|
110
110
|
BROKER: process.env.CLAUDEMESH_BROKER_URL ?? "wss://ic.claudemesh.com/ws",
|
|
@@ -3780,6 +3780,7 @@ __export(exports_lifecycle, {
|
|
|
3780
3780
|
_resetDaemonReadyCache: () => _resetDaemonReadyCache
|
|
3781
3781
|
});
|
|
3782
3782
|
import { existsSync as existsSync6, readFileSync as readFileSync6, statSync, unlinkSync as unlinkSync2, writeFileSync as writeFileSync6 } from "node:fs";
|
|
3783
|
+
import { homedir as homedir3 } from "node:os";
|
|
3783
3784
|
import { join as join4 } from "node:path";
|
|
3784
3785
|
async function ensureDaemonReady(opts = {}) {
|
|
3785
3786
|
if (lastResultThisProcess && (lastResultThisProcess.state === "up" || lastResultThisProcess.state === "started")) {
|
|
@@ -3800,6 +3801,19 @@ async function runEnsureDaemon(opts) {
|
|
|
3800
3801
|
const probe = await probeDaemon();
|
|
3801
3802
|
if (probe === "up")
|
|
3802
3803
|
return { state: "up", durationMs: Date.now() - t0 };
|
|
3804
|
+
if (isServiceManaged()) {
|
|
3805
|
+
if (probe === "stale")
|
|
3806
|
+
cleanupStaleFiles();
|
|
3807
|
+
const polled = await pollForSocket(SERVICE_BUDGET_MS);
|
|
3808
|
+
if (polled.ok)
|
|
3809
|
+
return { state: "up", durationMs: Date.now() - t0 };
|
|
3810
|
+
const tool = process.platform === "darwin" ? `launchctl print gui/$(id -u)/${SERVICE_LABEL}` : `systemctl --user status ${SYSTEMD_UNIT}`;
|
|
3811
|
+
return {
|
|
3812
|
+
state: "service-not-ready",
|
|
3813
|
+
durationMs: Date.now() - t0,
|
|
3814
|
+
reason: `service-managed daemon not responding within ${SERVICE_BUDGET_MS}ms (run \`${tool}\`)`
|
|
3815
|
+
};
|
|
3816
|
+
}
|
|
3803
3817
|
if (probe === "stale")
|
|
3804
3818
|
cleanupStaleFiles();
|
|
3805
3819
|
if (opts.noAutoSpawn) {
|
|
@@ -3819,6 +3833,15 @@ async function runEnsureDaemon(opts) {
|
|
|
3819
3833
|
markSpawnFailure();
|
|
3820
3834
|
return { state: "spawn-failed", durationMs: Date.now() - t0, reason: spawnRes.reason };
|
|
3821
3835
|
}
|
|
3836
|
+
function isServiceManaged() {
|
|
3837
|
+
if (process.platform === "darwin") {
|
|
3838
|
+
return existsSync6(join4(homedir3(), "Library", "LaunchAgents", `${SERVICE_LABEL}.plist`));
|
|
3839
|
+
}
|
|
3840
|
+
if (process.platform === "linux") {
|
|
3841
|
+
return existsSync6(join4(homedir3(), ".config", "systemd", "user", SYSTEMD_UNIT));
|
|
3842
|
+
}
|
|
3843
|
+
return false;
|
|
3844
|
+
}
|
|
3822
3845
|
async function probeDaemon() {
|
|
3823
3846
|
if (!existsSync6(DAEMON_PATHS.SOCK_FILE))
|
|
3824
3847
|
return "absent";
|
|
@@ -3936,7 +3959,7 @@ async function resolveCliBinary() {
|
|
|
3936
3959
|
}
|
|
3937
3960
|
return argv1;
|
|
3938
3961
|
}
|
|
3939
|
-
var SPAWN_LOCK_FILE = () => join4(DAEMON_PATHS.DAEMON_DIR, ".spawn.lock"), SPAWN_FAIL_FILE = () => join4(DAEMON_PATHS.DAEMON_DIR, ".spawn-failure"), SPAWN_FAIL_TTL_MS = 30000, PROBE_TIMEOUT_MS =
|
|
3962
|
+
var SPAWN_LOCK_FILE = () => join4(DAEMON_PATHS.DAEMON_DIR, ".spawn.lock"), SPAWN_FAIL_FILE = () => join4(DAEMON_PATHS.DAEMON_DIR, ".spawn-failure"), SPAWN_FAIL_TTL_MS = 30000, PROBE_TIMEOUT_MS = 2500, SERVICE_BUDGET_MS = 8000, lastResultThisProcess = null, SERVICE_LABEL = "com.claudemesh.daemon", SYSTEMD_UNIT = "claudemesh-daemon.service";
|
|
3940
3963
|
var init_lifecycle = __esm(() => {
|
|
3941
3964
|
init_client3();
|
|
3942
3965
|
init_paths2();
|
|
@@ -3982,7 +4005,7 @@ __export(exports_launch, {
|
|
|
3982
4005
|
import { spawnSync as spawnSync2 } from "node:child_process";
|
|
3983
4006
|
import { randomUUID } from "node:crypto";
|
|
3984
4007
|
import { mkdtempSync, writeFileSync as writeFileSync7, rmSync, readdirSync, statSync as statSync2, existsSync as existsSync7, readFileSync as readFileSync7 } from "node:fs";
|
|
3985
|
-
import { tmpdir, hostname as hostname2, homedir as
|
|
4008
|
+
import { tmpdir, hostname as hostname2, homedir as homedir4 } from "node:os";
|
|
3986
4009
|
import { join as join5 } from "node:path";
|
|
3987
4010
|
import { createInterface as createInterface4 } from "node:readline";
|
|
3988
4011
|
async function ensureDaemonRunning(meshSlug, quiet) {
|
|
@@ -4329,7 +4352,7 @@ async function runLaunch(flags, rawArgs) {
|
|
|
4329
4352
|
} catch {}
|
|
4330
4353
|
await ensureDaemonRunning(mesh.slug, args.quiet);
|
|
4331
4354
|
try {
|
|
4332
|
-
const claudeConfigPath = join5(
|
|
4355
|
+
const claudeConfigPath = join5(homedir4(), ".claude.json");
|
|
4333
4356
|
if (existsSync7(claudeConfigPath)) {
|
|
4334
4357
|
const claudeConfig = JSON.parse(readFileSync7(claudeConfigPath, "utf-8"));
|
|
4335
4358
|
const mcpServers = claudeConfig.mcpServers ?? {};
|
|
@@ -4435,7 +4458,7 @@ async function runLaunch(flags, rawArgs) {
|
|
|
4435
4458
|
}
|
|
4436
4459
|
const meshMcpEntries = [];
|
|
4437
4460
|
if (serviceCatalog.length > 0) {
|
|
4438
|
-
const claudeConfigPath = join5(
|
|
4461
|
+
const claudeConfigPath = join5(homedir4(), ".claude.json");
|
|
4439
4462
|
let claudeConfig = {};
|
|
4440
4463
|
try {
|
|
4441
4464
|
claudeConfig = JSON.parse(readFileSync7(claudeConfigPath, "utf-8"));
|
|
@@ -4500,9 +4523,9 @@ async function runLaunch(flags, rawArgs) {
|
|
|
4500
4523
|
let claudeBin = "claude";
|
|
4501
4524
|
if (!isWindows2) {
|
|
4502
4525
|
const candidates = [
|
|
4503
|
-
join5(
|
|
4526
|
+
join5(homedir4(), ".local", "bin", "claude"),
|
|
4504
4527
|
"/usr/local/bin/claude",
|
|
4505
|
-
join5(
|
|
4528
|
+
join5(homedir4(), ".claude", "bin", "claude")
|
|
4506
4529
|
];
|
|
4507
4530
|
for (const c of candidates) {
|
|
4508
4531
|
if (existsSync7(c)) {
|
|
@@ -4514,7 +4537,7 @@ async function runLaunch(flags, rawArgs) {
|
|
|
4514
4537
|
const cleanup = () => {
|
|
4515
4538
|
if (meshMcpEntries.length > 0) {
|
|
4516
4539
|
try {
|
|
4517
|
-
const claudeConfigPath = join5(
|
|
4540
|
+
const claudeConfigPath = join5(homedir4(), ".claude.json");
|
|
4518
4541
|
const claudeConfig = JSON.parse(readFileSync7(claudeConfigPath, "utf-8"));
|
|
4519
4542
|
const mcpServers = claudeConfig.mcpServers ?? {};
|
|
4520
4543
|
for (const { key } of meshMcpEntries) {
|
|
@@ -5221,7 +5244,7 @@ __export(exports_join, {
|
|
|
5221
5244
|
import sodium3 from "libsodium-wrappers";
|
|
5222
5245
|
import { writeFileSync as writeFileSync8, mkdirSync as mkdirSync4 } from "node:fs";
|
|
5223
5246
|
import { join as join6, dirname as dirname3 } from "node:path";
|
|
5224
|
-
import { homedir as
|
|
5247
|
+
import { homedir as homedir5, hostname as hostname3 } from "node:os";
|
|
5225
5248
|
function deriveAppBaseUrl() {
|
|
5226
5249
|
const override = process.env.CLAUDEMESH_APP_URL;
|
|
5227
5250
|
if (override)
|
|
@@ -5340,7 +5363,7 @@ async function runJoin(args) {
|
|
|
5340
5363
|
joinedAt: new Date().toISOString()
|
|
5341
5364
|
});
|
|
5342
5365
|
writeConfig(config);
|
|
5343
|
-
const configDir = env.CLAUDEMESH_CONFIG_DIR ?? join6(
|
|
5366
|
+
const configDir = env.CLAUDEMESH_CONFIG_DIR ?? join6(homedir5(), ".claudemesh");
|
|
5344
5367
|
const inviteFile = join6(configDir, `invite-${payload.mesh_slug}.txt`);
|
|
5345
5368
|
try {
|
|
5346
5369
|
mkdirSync4(dirname3(inviteFile), { recursive: true });
|
|
@@ -7580,6 +7603,10 @@ function warnDaemonState(res, opts = {}) {
|
|
|
7580
7603
|
return true;
|
|
7581
7604
|
case "spawn-failed":
|
|
7582
7605
|
process.stderr.write(`${tag("warn")} daemon spawn failed${res.reason ? `: ${res.reason}` : ""} — using cold path ${hint("(check ~/.claudemesh/daemon/daemon.log)")}
|
|
7606
|
+
`);
|
|
7607
|
+
return true;
|
|
7608
|
+
case "service-not-ready":
|
|
7609
|
+
process.stderr.write(`${tag("warn")} ${res.reason ?? "service-managed daemon not responding"} — using cold path ${hint("(check ~/.claudemesh/daemon/daemon.log)")}
|
|
7583
7610
|
`);
|
|
7584
7611
|
return true;
|
|
7585
7612
|
}
|
|
@@ -9307,6 +9334,34 @@ function bindSseStream(res, bus) {
|
|
|
9307
9334
|
return cleanup;
|
|
9308
9335
|
}
|
|
9309
9336
|
|
|
9337
|
+
// src/daemon/process-info.ts
|
|
9338
|
+
import { execFileSync } from "node:child_process";
|
|
9339
|
+
function getProcessStartTime(pid) {
|
|
9340
|
+
if (!Number.isFinite(pid) || pid <= 0)
|
|
9341
|
+
return null;
|
|
9342
|
+
try {
|
|
9343
|
+
const out = execFileSync("ps", ["-o", "lstart=", "-p", String(pid)], {
|
|
9344
|
+
encoding: "utf8",
|
|
9345
|
+
timeout: 1000,
|
|
9346
|
+
stdio: ["ignore", "pipe", "ignore"]
|
|
9347
|
+
}).trim();
|
|
9348
|
+
return out.length > 0 ? out : null;
|
|
9349
|
+
} catch {
|
|
9350
|
+
return null;
|
|
9351
|
+
}
|
|
9352
|
+
}
|
|
9353
|
+
function isPidAlive(pid) {
|
|
9354
|
+
if (!Number.isFinite(pid) || pid <= 0)
|
|
9355
|
+
return false;
|
|
9356
|
+
try {
|
|
9357
|
+
process.kill(pid, 0);
|
|
9358
|
+
return true;
|
|
9359
|
+
} catch {
|
|
9360
|
+
return false;
|
|
9361
|
+
}
|
|
9362
|
+
}
|
|
9363
|
+
var init_process_info = () => {};
|
|
9364
|
+
|
|
9310
9365
|
// src/daemon/session-registry.ts
|
|
9311
9366
|
function startReaper() {
|
|
9312
9367
|
if (reaperHandle)
|
|
@@ -9328,7 +9383,8 @@ function registerSession(info) {
|
|
|
9328
9383
|
} catch {}
|
|
9329
9384
|
}
|
|
9330
9385
|
}
|
|
9331
|
-
const
|
|
9386
|
+
const startTime = info.startTime ?? getProcessStartTime(info.pid) ?? undefined;
|
|
9387
|
+
const stored = { ...info, startTime, registeredAt: Date.now() };
|
|
9332
9388
|
byToken.set(info.token, stored);
|
|
9333
9389
|
bySessionId.set(info.sessionId, info.token);
|
|
9334
9390
|
try {
|
|
@@ -9368,10 +9424,16 @@ function reapDead() {
|
|
|
9368
9424
|
dead.push(token);
|
|
9369
9425
|
continue;
|
|
9370
9426
|
}
|
|
9371
|
-
|
|
9372
|
-
process.kill(info.pid, 0);
|
|
9373
|
-
} catch {
|
|
9427
|
+
if (!isPidAlive(info.pid)) {
|
|
9374
9428
|
dead.push(token);
|
|
9429
|
+
continue;
|
|
9430
|
+
}
|
|
9431
|
+
if (info.startTime !== undefined) {
|
|
9432
|
+
const live = getProcessStartTime(info.pid);
|
|
9433
|
+
if (live !== null && live !== info.startTime) {
|
|
9434
|
+
dead.push(token);
|
|
9435
|
+
continue;
|
|
9436
|
+
}
|
|
9375
9437
|
}
|
|
9376
9438
|
}
|
|
9377
9439
|
for (const t of dead)
|
|
@@ -9379,8 +9441,9 @@ function reapDead() {
|
|
|
9379
9441
|
}
|
|
9380
9442
|
var TTL_MS, REAPER_INTERVAL_MS, byToken, bySessionId, hooks, reaperHandle = null;
|
|
9381
9443
|
var init_session_registry = __esm(() => {
|
|
9444
|
+
init_process_info();
|
|
9382
9445
|
TTL_MS = 24 * 60 * 60 * 1000;
|
|
9383
|
-
REAPER_INTERVAL_MS =
|
|
9446
|
+
REAPER_INTERVAL_MS = 5 * 1000;
|
|
9384
9447
|
byToken = new Map;
|
|
9385
9448
|
bySessionId = new Map;
|
|
9386
9449
|
hooks = {};
|
|
@@ -9508,7 +9571,12 @@ function makeHandler(opts) {
|
|
|
9508
9571
|
return;
|
|
9509
9572
|
}
|
|
9510
9573
|
if (req.method === "GET" && url.pathname === "/v1/health") {
|
|
9511
|
-
|
|
9574
|
+
const brokers = {};
|
|
9575
|
+
if (opts.brokers) {
|
|
9576
|
+
for (const [slug, client] of opts.brokers)
|
|
9577
|
+
brokers[slug] = client.status;
|
|
9578
|
+
}
|
|
9579
|
+
respond(res, 200, { ok: true, pid: process.pid, brokers });
|
|
9512
9580
|
return;
|
|
9513
9581
|
}
|
|
9514
9582
|
if (req.method === "POST" && url.pathname === "/v1/sessions/register") {
|
|
@@ -11463,7 +11531,7 @@ __export(exports_service_install, {
|
|
|
11463
11531
|
});
|
|
11464
11532
|
import { existsSync as existsSync12, mkdirSync as mkdirSync7, writeFileSync as writeFileSync11, unlinkSync as unlinkSync5, readFileSync as readFileSync11 } from "node:fs";
|
|
11465
11533
|
import { execSync as execSync2 } from "node:child_process";
|
|
11466
|
-
import { homedir as
|
|
11534
|
+
import { homedir as homedir6 } from "node:os";
|
|
11467
11535
|
import { join as join8, dirname as dirname5 } from "node:path";
|
|
11468
11536
|
function detectPlatform() {
|
|
11469
11537
|
if (process.platform === "darwin")
|
|
@@ -11496,7 +11564,7 @@ function uninstallService() {
|
|
|
11496
11564
|
if (platform5 === "darwin") {
|
|
11497
11565
|
const p = darwinPlistPath();
|
|
11498
11566
|
try {
|
|
11499
|
-
execSync2(`launchctl bootout gui/$(id -u)/${
|
|
11567
|
+
execSync2(`launchctl bootout gui/$(id -u)/${SERVICE_LABEL2}`, { stdio: "ignore" });
|
|
11500
11568
|
} catch {}
|
|
11501
11569
|
if (existsSync12(p)) {
|
|
11502
11570
|
unlinkSync5(p);
|
|
@@ -11505,7 +11573,7 @@ function uninstallService() {
|
|
|
11505
11573
|
} else if (platform5 === "linux") {
|
|
11506
11574
|
const p = linuxUnitPath();
|
|
11507
11575
|
try {
|
|
11508
|
-
execSync2(`systemctl --user disable --now ${
|
|
11576
|
+
execSync2(`systemctl --user disable --now ${SYSTEMD_UNIT2}`, { stdio: "ignore" });
|
|
11509
11577
|
} catch {}
|
|
11510
11578
|
if (existsSync12(p)) {
|
|
11511
11579
|
unlinkSync5(p);
|
|
@@ -11515,7 +11583,7 @@ function uninstallService() {
|
|
|
11515
11583
|
return { platform: platform5, removed };
|
|
11516
11584
|
}
|
|
11517
11585
|
function darwinPlistPath() {
|
|
11518
|
-
return join8(
|
|
11586
|
+
return join8(homedir6(), "Library", "LaunchAgents", `${SERVICE_LABEL2}.plist`);
|
|
11519
11587
|
}
|
|
11520
11588
|
function installDarwin(args) {
|
|
11521
11589
|
const plist = darwinPlistPath();
|
|
@@ -11526,8 +11594,7 @@ function installDarwin(args) {
|
|
|
11526
11594
|
`<string>${escapeXml(args.binaryPath)}</string>`,
|
|
11527
11595
|
"<string>daemon</string>",
|
|
11528
11596
|
"<string>up</string>",
|
|
11529
|
-
"<string>--mesh</string>",
|
|
11530
|
-
`<string>${escapeXml(args.meshSlug)}</string>`,
|
|
11597
|
+
...args.meshSlug ? ["<string>--mesh</string>", `<string>${escapeXml(args.meshSlug)}</string>`] : [],
|
|
11531
11598
|
...args.displayName ? ["<string>--name</string>", `<string>${escapeXml(args.displayName)}</string>`] : []
|
|
11532
11599
|
].join(`
|
|
11533
11600
|
`);
|
|
@@ -11536,7 +11603,7 @@ function installDarwin(args) {
|
|
|
11536
11603
|
<plist version="1.0">
|
|
11537
11604
|
<dict>
|
|
11538
11605
|
<key>Label</key>
|
|
11539
|
-
<string>${
|
|
11606
|
+
<string>${SERVICE_LABEL2}</string>
|
|
11540
11607
|
<key>ProgramArguments</key>
|
|
11541
11608
|
<array>
|
|
11542
11609
|
<string>${escapeXml(nodeBin)}</string>
|
|
@@ -11551,11 +11618,11 @@ function installDarwin(args) {
|
|
|
11551
11618
|
<key>StandardErrorPath</key>
|
|
11552
11619
|
<string>${escapeXml(log2)}</string>
|
|
11553
11620
|
<key>WorkingDirectory</key>
|
|
11554
|
-
<string>${escapeXml(
|
|
11621
|
+
<string>${escapeXml(homedir6())}</string>
|
|
11555
11622
|
<key>EnvironmentVariables</key>
|
|
11556
11623
|
<dict>
|
|
11557
11624
|
<key>HOME</key>
|
|
11558
|
-
<string>${escapeXml(
|
|
11625
|
+
<string>${escapeXml(homedir6())}</string>
|
|
11559
11626
|
<key>PATH</key>
|
|
11560
11627
|
<string>/usr/local/bin:/opt/homebrew/bin:/usr/bin:/bin:/usr/sbin:/sbin</string>
|
|
11561
11628
|
</dict>
|
|
@@ -11564,7 +11631,7 @@ function installDarwin(args) {
|
|
|
11564
11631
|
`;
|
|
11565
11632
|
writeFileSync11(plist, xml, { mode: 420 });
|
|
11566
11633
|
try {
|
|
11567
|
-
execSync2(`launchctl bootout gui/$(id -u)/${
|
|
11634
|
+
execSync2(`launchctl bootout gui/$(id -u)/${SERVICE_LABEL2}`, { stdio: "ignore" });
|
|
11568
11635
|
} catch {}
|
|
11569
11636
|
try {
|
|
11570
11637
|
const pidPath = DAEMON_PATHS.PID_FILE;
|
|
@@ -11584,7 +11651,7 @@ function installDarwin(args) {
|
|
|
11584
11651
|
};
|
|
11585
11652
|
}
|
|
11586
11653
|
function linuxUnitPath() {
|
|
11587
|
-
return join8(
|
|
11654
|
+
return join8(homedir6(), ".config", "systemd", "user", SYSTEMD_UNIT2);
|
|
11588
11655
|
}
|
|
11589
11656
|
function installLinux(args) {
|
|
11590
11657
|
const unit = linuxUnitPath();
|
|
@@ -11593,8 +11660,7 @@ function installLinux(args) {
|
|
|
11593
11660
|
const execArgs = [
|
|
11594
11661
|
"daemon",
|
|
11595
11662
|
"up",
|
|
11596
|
-
"--mesh",
|
|
11597
|
-
args.meshSlug,
|
|
11663
|
+
...args.meshSlug ? ["--mesh", args.meshSlug] : [],
|
|
11598
11664
|
...args.displayName ? ["--name", args.displayName] : []
|
|
11599
11665
|
].map(shellQuote).join(" ");
|
|
11600
11666
|
const content = `[Unit]
|
|
@@ -11616,7 +11682,7 @@ WantedBy=default.target
|
|
|
11616
11682
|
`;
|
|
11617
11683
|
writeFileSync11(unit, content, { mode: 420 });
|
|
11618
11684
|
try {
|
|
11619
|
-
execSync2(`systemctl --user stop ${
|
|
11685
|
+
execSync2(`systemctl --user stop ${SYSTEMD_UNIT2}`, { stdio: "ignore" });
|
|
11620
11686
|
} catch {}
|
|
11621
11687
|
try {
|
|
11622
11688
|
const pidPath = DAEMON_PATHS.PID_FILE;
|
|
@@ -11632,7 +11698,7 @@ WantedBy=default.target
|
|
|
11632
11698
|
return {
|
|
11633
11699
|
platform: "linux",
|
|
11634
11700
|
unitPath: unit,
|
|
11635
|
-
bootCommand: `systemctl --user daemon-reload && systemctl --user enable --now ${
|
|
11701
|
+
bootCommand: `systemctl --user daemon-reload && systemctl --user enable --now ${SYSTEMD_UNIT2}`
|
|
11636
11702
|
};
|
|
11637
11703
|
}
|
|
11638
11704
|
function escapeXml(s) {
|
|
@@ -11656,7 +11722,7 @@ function readInstalledUnit() {
|
|
|
11656
11722
|
return { platform: platform5, path: path2, content: null };
|
|
11657
11723
|
}
|
|
11658
11724
|
}
|
|
11659
|
-
var
|
|
11725
|
+
var SERVICE_LABEL2 = "com.claudemesh.daemon", SYSTEMD_UNIT2 = "claudemesh-daemon.service";
|
|
11660
11726
|
var init_service_install = __esm(() => {
|
|
11661
11727
|
init_paths2();
|
|
11662
11728
|
});
|
|
@@ -11817,11 +11883,6 @@ async function runInstallService(opts) {
|
|
|
11817
11883
|
const platform5 = detectPlatform2();
|
|
11818
11884
|
if (!platform5) {
|
|
11819
11885
|
process.stderr.write(`unsupported platform: ${process.platform}
|
|
11820
|
-
`);
|
|
11821
|
-
return 2;
|
|
11822
|
-
}
|
|
11823
|
-
if (!opts.mesh) {
|
|
11824
|
-
process.stderr.write(`pass --mesh <slug> so the service knows which mesh to attach to
|
|
11825
11886
|
`);
|
|
11826
11887
|
return 2;
|
|
11827
11888
|
}
|
|
@@ -11839,8 +11900,8 @@ async function runInstallService(opts) {
|
|
|
11839
11900
|
try {
|
|
11840
11901
|
const r = installService2({
|
|
11841
11902
|
binaryPath: binary,
|
|
11842
|
-
meshSlug: opts.mesh,
|
|
11843
|
-
displayName: opts.displayName
|
|
11903
|
+
...opts.mesh ? { meshSlug: opts.mesh } : {},
|
|
11904
|
+
...opts.displayName ? { displayName: opts.displayName } : {}
|
|
11844
11905
|
});
|
|
11845
11906
|
if (opts.json) {
|
|
11846
11907
|
process.stdout.write(JSON.stringify({ ok: true, ...r }) + `
|
|
@@ -11998,7 +12059,7 @@ import {
|
|
|
11998
12059
|
readFileSync as readFileSync12,
|
|
11999
12060
|
writeFileSync as writeFileSync12
|
|
12000
12061
|
} from "node:fs";
|
|
12001
|
-
import { homedir as
|
|
12062
|
+
import { homedir as homedir7, platform as platform5 } from "node:os";
|
|
12002
12063
|
import { dirname as dirname6, join as join9, resolve } from "node:path";
|
|
12003
12064
|
import { fileURLToPath } from "node:url";
|
|
12004
12065
|
import { spawnSync as spawnSync3 } from "node:child_process";
|
|
@@ -12241,7 +12302,7 @@ function installStatusLine() {
|
|
|
12241
12302
|
writeClaudeSettings(settings);
|
|
12242
12303
|
return { installed: true };
|
|
12243
12304
|
}
|
|
12244
|
-
function runInstall(args = []) {
|
|
12305
|
+
async function runInstall(args = []) {
|
|
12245
12306
|
const skipHooks = args.includes("--no-hooks");
|
|
12246
12307
|
const skipSkill = args.includes("--no-skill");
|
|
12247
12308
|
const skipService = args.includes("--no-service");
|
|
@@ -12326,17 +12387,15 @@ function runInstall(args = []) {
|
|
|
12326
12387
|
}
|
|
12327
12388
|
}
|
|
12328
12389
|
let hasMeshes = false;
|
|
12329
|
-
let primaryMesh;
|
|
12330
12390
|
try {
|
|
12331
12391
|
const meshConfig = readConfig();
|
|
12332
12392
|
hasMeshes = meshConfig.meshes.length > 0;
|
|
12333
|
-
primaryMesh = meshConfig.meshes[0]?.slug;
|
|
12334
12393
|
} catch {}
|
|
12335
|
-
if (!skipService && hasMeshes
|
|
12394
|
+
if (!skipService && hasMeshes) {
|
|
12336
12395
|
try {
|
|
12337
|
-
installDaemonService(entry
|
|
12396
|
+
await installDaemonService(entry);
|
|
12338
12397
|
} catch (e) {
|
|
12339
|
-
render.warn(`daemon service install failed: ${e instanceof Error ? e.message : String(e)}`, "Run `claudemesh daemon install-service
|
|
12398
|
+
render.warn(`daemon service install failed: ${e instanceof Error ? e.message : String(e)}`, "Run `claudemesh daemon install-service` to retry.");
|
|
12340
12399
|
}
|
|
12341
12400
|
} else if (skipService) {
|
|
12342
12401
|
render.info(dim("· Daemon service skipped (--no-service)"));
|
|
@@ -12362,7 +12421,7 @@ function runInstall(args = []) {
|
|
|
12362
12421
|
render.info(dim(` claudemesh install --status-line # live peer count in Claude Code`));
|
|
12363
12422
|
render.info(dim(` claudemesh completions zsh # shell completions`));
|
|
12364
12423
|
}
|
|
12365
|
-
function installDaemonService(binaryEntry
|
|
12424
|
+
async function installDaemonService(binaryEntry) {
|
|
12366
12425
|
const {
|
|
12367
12426
|
installService: installService2,
|
|
12368
12427
|
detectPlatform: detectPlatform2
|
|
@@ -12378,15 +12437,15 @@ function installDaemonService(binaryEntry, meshSlug) {
|
|
|
12378
12437
|
const { execSync: execSync3 } = __require("node:child_process");
|
|
12379
12438
|
binary = execSync3("which claudemesh", { encoding: "utf8" }).trim();
|
|
12380
12439
|
} catch {
|
|
12381
|
-
render.warn("couldn't resolve a 'claudemesh' binary on PATH; daemon service skipped", "Install via npm/homebrew, then run `claudemesh daemon install-service
|
|
12440
|
+
render.warn("couldn't resolve a 'claudemesh' binary on PATH; daemon service skipped", "Install via npm/homebrew, then run `claudemesh daemon install-service`");
|
|
12382
12441
|
return;
|
|
12383
12442
|
}
|
|
12384
12443
|
}
|
|
12385
|
-
const r = installService2({ binaryPath: binary
|
|
12444
|
+
const r = installService2({ binaryPath: binary });
|
|
12386
12445
|
render.ok(`daemon service installed (${r.platform})`);
|
|
12387
12446
|
render.kv([
|
|
12388
12447
|
["unit", dim(r.unitPath)],
|
|
12389
|
-
["mesh", dim(
|
|
12448
|
+
["mesh", dim("(all joined meshes)")]
|
|
12390
12449
|
]);
|
|
12391
12450
|
try {
|
|
12392
12451
|
const { execSync: execSync3 } = __require("node:child_process");
|
|
@@ -12394,7 +12453,35 @@ function installDaemonService(binaryEntry, meshSlug) {
|
|
|
12394
12453
|
render.ok("daemon started");
|
|
12395
12454
|
} catch (e) {
|
|
12396
12455
|
render.warn(`daemon service installed but failed to start: ${e instanceof Error ? e.message : String(e)}`, `Run manually: ${r.bootCommand}`);
|
|
12456
|
+
return;
|
|
12457
|
+
}
|
|
12458
|
+
await verifyBrokerConnectivity();
|
|
12459
|
+
}
|
|
12460
|
+
async function verifyBrokerConnectivity() {
|
|
12461
|
+
const VERIFY_BUDGET_MS = 15000;
|
|
12462
|
+
const POLL_INTERVAL_MS2 = 500;
|
|
12463
|
+
const { ipc: ipc2 } = await Promise.resolve().then(() => (init_client3(), exports_client));
|
|
12464
|
+
const start = Date.now();
|
|
12465
|
+
let lastBrokers = {};
|
|
12466
|
+
while (Date.now() - start < VERIFY_BUDGET_MS) {
|
|
12467
|
+
try {
|
|
12468
|
+
const res = await ipc2({
|
|
12469
|
+
path: "/v1/health",
|
|
12470
|
+
timeoutMs: 2000
|
|
12471
|
+
});
|
|
12472
|
+
lastBrokers = res.body?.brokers ?? {};
|
|
12473
|
+
const openMesh = Object.entries(lastBrokers).find(([, s]) => s === "open");
|
|
12474
|
+
if (openMesh) {
|
|
12475
|
+
const others = Object.entries(lastBrokers).filter(([slug]) => slug !== openMesh[0]);
|
|
12476
|
+
const tail = others.length > 0 ? `, ${others.length} other mesh${others.length === 1 ? "" : "es"} attaching` : "";
|
|
12477
|
+
render.ok(`broker connected (mesh=${openMesh[0]}${tail})`);
|
|
12478
|
+
return;
|
|
12479
|
+
}
|
|
12480
|
+
} catch {}
|
|
12481
|
+
await new Promise((r) => setTimeout(r, POLL_INTERVAL_MS2));
|
|
12397
12482
|
}
|
|
12483
|
+
const states = Object.keys(lastBrokers).length === 0 ? "no health response from daemon" : Object.entries(lastBrokers).map(([m, s]) => `${m}=${s}`).join(", ");
|
|
12484
|
+
render.warn(`broker did not reach open within ${Math.round(VERIFY_BUDGET_MS / 1000)}s (${states})`, "Check ~/.claudemesh/daemon/daemon.log for connect errors. Common causes: outbound :443 blocked, expired TLS, DNS resolution.");
|
|
12398
12485
|
}
|
|
12399
12486
|
function runUninstall() {
|
|
12400
12487
|
render.section("claudemesh uninstall");
|
|
@@ -12441,9 +12528,9 @@ var init_install = __esm(() => {
|
|
|
12441
12528
|
init_facade();
|
|
12442
12529
|
init_render();
|
|
12443
12530
|
init_styles();
|
|
12444
|
-
CLAUDE_CONFIG = join9(
|
|
12445
|
-
CLAUDE_SETTINGS = join9(
|
|
12446
|
-
CLAUDE_SKILLS_ROOT = join9(
|
|
12531
|
+
CLAUDE_CONFIG = join9(homedir7(), ".claude.json");
|
|
12532
|
+
CLAUDE_SETTINGS = join9(homedir7(), ".claude", "settings.json");
|
|
12533
|
+
CLAUDE_SKILLS_ROOT = join9(homedir7(), ".claude", "skills");
|
|
12447
12534
|
CLAUDEMESH_TOOLS = [
|
|
12448
12535
|
"mcp__claudemesh__cancel_scheduled",
|
|
12449
12536
|
"mcp__claudemesh__check_messages",
|
|
@@ -12500,7 +12587,7 @@ __export(exports_uninstall, {
|
|
|
12500
12587
|
});
|
|
12501
12588
|
import { readFileSync as readFileSync13, writeFileSync as writeFileSync13, existsSync as existsSync14, rmSync as rmSync2, readdirSync as readdirSync2 } from "node:fs";
|
|
12502
12589
|
import { join as join10, dirname as dirname7 } from "node:path";
|
|
12503
|
-
import { homedir as
|
|
12590
|
+
import { homedir as homedir8 } from "node:os";
|
|
12504
12591
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
12505
12592
|
function bundledSkillsDir() {
|
|
12506
12593
|
const here = fileURLToPath2(import.meta.url);
|
|
@@ -12587,7 +12674,7 @@ var init_uninstall = __esm(() => {
|
|
|
12587
12674
|
init_render();
|
|
12588
12675
|
init_styles();
|
|
12589
12676
|
init_exit_codes();
|
|
12590
|
-
CLAUDE_SKILLS_ROOT2 = join10(
|
|
12677
|
+
CLAUDE_SKILLS_ROOT2 = join10(homedir8(), ".claude", "skills");
|
|
12591
12678
|
});
|
|
12592
12679
|
|
|
12593
12680
|
// src/commands/doctor.ts
|
|
@@ -12596,7 +12683,7 @@ __export(exports_doctor, {
|
|
|
12596
12683
|
runDoctor: () => runDoctor
|
|
12597
12684
|
});
|
|
12598
12685
|
import { existsSync as existsSync15, readFileSync as readFileSync14, statSync as statSync3 } from "node:fs";
|
|
12599
|
-
import { homedir as
|
|
12686
|
+
import { homedir as homedir9, platform as platform6 } from "node:os";
|
|
12600
12687
|
import { join as join11 } from "node:path";
|
|
12601
12688
|
import { spawnSync as spawnSync4 } from "node:child_process";
|
|
12602
12689
|
function checkNode() {
|
|
@@ -12621,7 +12708,7 @@ function checkClaudeOnPath() {
|
|
|
12621
12708
|
};
|
|
12622
12709
|
}
|
|
12623
12710
|
function checkMcpRegistered() {
|
|
12624
|
-
const claudeConfig = join11(
|
|
12711
|
+
const claudeConfig = join11(homedir9(), ".claude.json");
|
|
12625
12712
|
if (!existsSync15(claudeConfig)) {
|
|
12626
12713
|
return {
|
|
12627
12714
|
name: "claudemesh MCP registered in ~/.claude.json",
|
|
@@ -12647,7 +12734,7 @@ function checkMcpRegistered() {
|
|
|
12647
12734
|
}
|
|
12648
12735
|
}
|
|
12649
12736
|
function checkHooksRegistered() {
|
|
12650
|
-
const settings = join11(
|
|
12737
|
+
const settings = join11(homedir9(), ".claude", "settings.json");
|
|
12651
12738
|
if (!existsSync15(settings)) {
|
|
12652
12739
|
return {
|
|
12653
12740
|
name: "Status hooks registered in ~/.claude/settings.json",
|
|
@@ -13581,7 +13668,7 @@ var exports_url_handler = {};
|
|
|
13581
13668
|
__export(exports_url_handler, {
|
|
13582
13669
|
runUrlHandler: () => runUrlHandler
|
|
13583
13670
|
});
|
|
13584
|
-
import { platform as platform7, homedir as
|
|
13671
|
+
import { platform as platform7, homedir as homedir10 } from "node:os";
|
|
13585
13672
|
import { existsSync as existsSync21, mkdirSync as mkdirSync9, writeFileSync as writeFileSync14, rmSync as rmSync3, chmodSync as chmodSync5 } from "node:fs";
|
|
13586
13673
|
import { join as join12 } from "node:path";
|
|
13587
13674
|
import { spawnSync as spawnSync5 } from "node:child_process";
|
|
@@ -13590,7 +13677,7 @@ function resolveClaudemeshBin() {
|
|
|
13590
13677
|
}
|
|
13591
13678
|
function installDarwin2() {
|
|
13592
13679
|
const binPath = resolveClaudemeshBin();
|
|
13593
|
-
const appDir = join12(
|
|
13680
|
+
const appDir = join12(homedir10(), "Library", "Application Support", "claudemesh", "ClaudemeshHandler.app");
|
|
13594
13681
|
const contents = join12(appDir, "Contents");
|
|
13595
13682
|
const macOS = join12(contents, "MacOS");
|
|
13596
13683
|
mkdirSync9(macOS, { recursive: true });
|
|
@@ -13642,7 +13729,7 @@ EOF
|
|
|
13642
13729
|
}
|
|
13643
13730
|
function installLinux2() {
|
|
13644
13731
|
const binPath = resolveClaudemeshBin();
|
|
13645
|
-
const appsDir = join12(
|
|
13732
|
+
const appsDir = join12(homedir10(), ".local", "share", "applications");
|
|
13646
13733
|
mkdirSync9(appsDir, { recursive: true });
|
|
13647
13734
|
const desktop = `[Desktop Entry]
|
|
13648
13735
|
Type=Application
|
|
@@ -13677,7 +13764,7 @@ function installWindows() {
|
|
|
13677
13764
|
`[HKEY_CURRENT_USER\\Software\\Classes\\claudemesh\\shell\\open\\command]`,
|
|
13678
13765
|
`@="\\"${binPath.replace(/\\/g, "\\\\")}\\" \\"%1\\""`
|
|
13679
13766
|
];
|
|
13680
|
-
const regPath = join12(
|
|
13767
|
+
const regPath = join12(homedir10(), "claudemesh-handler.reg");
|
|
13681
13768
|
writeFileSync14(regPath, lines.join(`\r
|
|
13682
13769
|
`));
|
|
13683
13770
|
const res = spawnSync5("reg.exe", ["import", regPath], { encoding: "utf-8" });
|
|
@@ -13689,14 +13776,14 @@ function installWindows() {
|
|
|
13689
13776
|
return EXIT.SUCCESS;
|
|
13690
13777
|
}
|
|
13691
13778
|
function uninstallDarwin() {
|
|
13692
|
-
const appDir = join12(
|
|
13779
|
+
const appDir = join12(homedir10(), "Library", "Application Support", "claudemesh", "ClaudemeshHandler.app");
|
|
13693
13780
|
if (existsSync21(appDir))
|
|
13694
13781
|
rmSync3(appDir, { recursive: true, force: true });
|
|
13695
13782
|
render.ok("removed claudemesh:// handler on macOS");
|
|
13696
13783
|
return EXIT.SUCCESS;
|
|
13697
13784
|
}
|
|
13698
13785
|
function uninstallLinux() {
|
|
13699
|
-
const desktopPath = join12(
|
|
13786
|
+
const desktopPath = join12(homedir10(), ".local", "share", "applications", "claudemesh.desktop");
|
|
13700
13787
|
if (existsSync21(desktopPath))
|
|
13701
13788
|
rmSync3(desktopPath, { force: true });
|
|
13702
13789
|
render.ok("removed claudemesh:// handler on Linux");
|
|
@@ -13744,7 +13831,7 @@ __export(exports_status_line, {
|
|
|
13744
13831
|
});
|
|
13745
13832
|
import { existsSync as existsSync22, readFileSync as readFileSync18 } from "node:fs";
|
|
13746
13833
|
import { join as join13 } from "node:path";
|
|
13747
|
-
import { homedir as
|
|
13834
|
+
import { homedir as homedir11 } from "node:os";
|
|
13748
13835
|
async function runStatusLine() {
|
|
13749
13836
|
try {
|
|
13750
13837
|
const config = readConfig();
|
|
@@ -13752,7 +13839,7 @@ async function runStatusLine() {
|
|
|
13752
13839
|
process.stdout.write("◇ claudemesh (not joined)");
|
|
13753
13840
|
return EXIT.SUCCESS;
|
|
13754
13841
|
}
|
|
13755
|
-
const cachePath = join13(
|
|
13842
|
+
const cachePath = join13(homedir11(), ".claudemesh", "peer-cache.json");
|
|
13756
13843
|
let cache = {};
|
|
13757
13844
|
if (existsSync22(cachePath)) {
|
|
13758
13845
|
try {
|
|
@@ -13996,7 +14083,7 @@ __export(exports_grants, {
|
|
|
13996
14083
|
isAllowed: () => isAllowed
|
|
13997
14084
|
});
|
|
13998
14085
|
import { existsSync as existsSync25, mkdirSync as mkdirSync10, readFileSync as readFileSync20, writeFileSync as writeFileSync16 } from "node:fs";
|
|
13999
|
-
import { homedir as
|
|
14086
|
+
import { homedir as homedir12 } from "node:os";
|
|
14000
14087
|
import { join as join15 } from "node:path";
|
|
14001
14088
|
async function syncToBroker(meshSlug, grants) {
|
|
14002
14089
|
const auth = getStoredToken();
|
|
@@ -14024,7 +14111,7 @@ function readGrants() {
|
|
|
14024
14111
|
}
|
|
14025
14112
|
}
|
|
14026
14113
|
function writeGrants(g) {
|
|
14027
|
-
const dir = join15(
|
|
14114
|
+
const dir = join15(homedir12(), ".claudemesh");
|
|
14028
14115
|
if (!existsSync25(dir))
|
|
14029
14116
|
mkdirSync10(dir, { recursive: true });
|
|
14030
14117
|
writeFileSync16(GRANT_FILE, JSON.stringify(g, null, 2), { mode: 384 });
|
|
@@ -14183,7 +14270,7 @@ var init_grants = __esm(() => {
|
|
|
14183
14270
|
BROKER_HTTP7 = URLS.BROKER.replace("wss://", "https://").replace("ws://", "http://").replace("/ws", "");
|
|
14184
14271
|
ALL_CAPS = ["read", "dm", "broadcast", "state-read", "state-write", "file-read"];
|
|
14185
14272
|
DEFAULT_CAPS = ["read", "dm", "broadcast", "state-read"];
|
|
14186
|
-
GRANT_FILE = join15(
|
|
14273
|
+
GRANT_FILE = join15(homedir12(), ".claudemesh", "grants.json");
|
|
14187
14274
|
});
|
|
14188
14275
|
|
|
14189
14276
|
// src/commands/profile.ts
|
|
@@ -19222,7 +19309,7 @@ async function main() {
|
|
|
19222
19309
|
}
|
|
19223
19310
|
case "install": {
|
|
19224
19311
|
const { runInstall: runInstall2 } = await Promise.resolve().then(() => (init_install(), exports_install));
|
|
19225
|
-
runInstall2(positionals);
|
|
19312
|
+
await runInstall2(positionals);
|
|
19226
19313
|
break;
|
|
19227
19314
|
}
|
|
19228
19315
|
case "uninstall": {
|
|
@@ -19902,4 +19989,4 @@ main().catch((err) => {
|
|
|
19902
19989
|
process.exit(EXIT.INTERNAL_ERROR);
|
|
19903
19990
|
});
|
|
19904
19991
|
|
|
19905
|
-
//# debugId=
|
|
19992
|
+
//# debugId=CD2B8A691C15D42A64756E2164756E21
|