claudemesh-cli 1.0.0-alpha.18 → 1.0.0-alpha.19
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 +362 -32
- package/dist/entrypoints/cli.js.map +12 -4
- package/package.json +4 -4
package/dist/entrypoints/cli.js
CHANGED
|
@@ -6341,6 +6341,331 @@ var init_sync = __esm(() => {
|
|
|
6341
6341
|
init_facade7();
|
|
6342
6342
|
});
|
|
6343
6343
|
|
|
6344
|
+
// src/services/health/check-node-version.ts
|
|
6345
|
+
function checkNodeVersion() {
|
|
6346
|
+
const major = parseInt(process.version.slice(1), 10);
|
|
6347
|
+
if (major >= 20)
|
|
6348
|
+
return { name: "node-version", ok: true, message: `Node ${process.version}` };
|
|
6349
|
+
return { name: "node-version", ok: false, message: `Node ${process.version} — requires >= 20` };
|
|
6350
|
+
}
|
|
6351
|
+
|
|
6352
|
+
// src/services/health/check-claude-binary.ts
|
|
6353
|
+
function checkClaudeBinary() {
|
|
6354
|
+
const bin = findClaudeBinary();
|
|
6355
|
+
if (bin)
|
|
6356
|
+
return { name: "claude-binary", ok: true, message: `Found at ${bin}` };
|
|
6357
|
+
return { name: "claude-binary", ok: false, message: "Claude binary not found" };
|
|
6358
|
+
}
|
|
6359
|
+
var init_check_claude_binary = __esm(() => {
|
|
6360
|
+
init_facade4();
|
|
6361
|
+
});
|
|
6362
|
+
|
|
6363
|
+
// src/services/health/check-mcp-registered.ts
|
|
6364
|
+
import { existsSync as existsSync9, readFileSync as readFileSync7 } from "node:fs";
|
|
6365
|
+
function checkMcpRegistered2() {
|
|
6366
|
+
try {
|
|
6367
|
+
if (!existsSync9(PATHS.CLAUDE_JSON)) {
|
|
6368
|
+
return { name: "mcp-registered", ok: false, message: "~/.claude.json not found" };
|
|
6369
|
+
}
|
|
6370
|
+
const raw = readFileSync7(PATHS.CLAUDE_JSON, "utf-8");
|
|
6371
|
+
const config = JSON.parse(raw);
|
|
6372
|
+
if (config.mcpServers && "claudemesh" in config.mcpServers) {
|
|
6373
|
+
return { name: "mcp-registered", ok: true, message: "MCP server registered" };
|
|
6374
|
+
}
|
|
6375
|
+
return { name: "mcp-registered", ok: false, message: "claudemesh not in mcpServers" };
|
|
6376
|
+
} catch {
|
|
6377
|
+
return { name: "mcp-registered", ok: false, message: "Could not read ~/.claude.json" };
|
|
6378
|
+
}
|
|
6379
|
+
}
|
|
6380
|
+
var init_check_mcp_registered = __esm(() => {
|
|
6381
|
+
init_paths();
|
|
6382
|
+
});
|
|
6383
|
+
|
|
6384
|
+
// src/services/health/check-hooks-registered.ts
|
|
6385
|
+
import { existsSync as existsSync10, readFileSync as readFileSync8 } from "node:fs";
|
|
6386
|
+
function checkHooksRegistered2() {
|
|
6387
|
+
try {
|
|
6388
|
+
if (!existsSync10(PATHS.CLAUDE_SETTINGS)) {
|
|
6389
|
+
return { name: "hooks-registered", ok: false, message: "~/.claude/settings.json not found" };
|
|
6390
|
+
}
|
|
6391
|
+
const raw = readFileSync8(PATHS.CLAUDE_SETTINGS, "utf-8");
|
|
6392
|
+
const config = JSON.parse(raw);
|
|
6393
|
+
if (config.hooks) {
|
|
6394
|
+
return { name: "hooks-registered", ok: true, message: "Hooks configured" };
|
|
6395
|
+
}
|
|
6396
|
+
return { name: "hooks-registered", ok: false, message: "No hooks in settings.json" };
|
|
6397
|
+
} catch {
|
|
6398
|
+
return { name: "hooks-registered", ok: false, message: "Could not read settings.json" };
|
|
6399
|
+
}
|
|
6400
|
+
}
|
|
6401
|
+
var init_check_hooks_registered = __esm(() => {
|
|
6402
|
+
init_paths();
|
|
6403
|
+
});
|
|
6404
|
+
|
|
6405
|
+
// src/services/health/check-config-perms.ts
|
|
6406
|
+
import { existsSync as existsSync11, statSync as statSync4 } from "node:fs";
|
|
6407
|
+
function checkConfigPerms() {
|
|
6408
|
+
const configFile = PATHS.CONFIG_FILE;
|
|
6409
|
+
if (!existsSync11(configFile)) {
|
|
6410
|
+
return { name: "config-perms", ok: true, message: "No config file yet (first run)" };
|
|
6411
|
+
}
|
|
6412
|
+
try {
|
|
6413
|
+
const mode = statSync4(configFile).mode & 511;
|
|
6414
|
+
if (mode <= 384) {
|
|
6415
|
+
return { name: "config-perms", ok: true, message: `config.json mode ${mode.toString(8)}` };
|
|
6416
|
+
}
|
|
6417
|
+
return { name: "config-perms", ok: false, message: `config.json mode ${mode.toString(8)} — should be 600` };
|
|
6418
|
+
} catch {
|
|
6419
|
+
return { name: "config-perms", ok: false, message: "Could not stat config.json" };
|
|
6420
|
+
}
|
|
6421
|
+
}
|
|
6422
|
+
var init_check_config_perms = __esm(() => {
|
|
6423
|
+
init_paths();
|
|
6424
|
+
});
|
|
6425
|
+
|
|
6426
|
+
// src/services/health/check-keypairs-valid.ts
|
|
6427
|
+
import { existsSync as existsSync12, readFileSync as readFileSync9 } from "node:fs";
|
|
6428
|
+
function checkKeypairsValid() {
|
|
6429
|
+
if (!existsSync12(PATHS.CONFIG_FILE)) {
|
|
6430
|
+
return { name: "keypairs-valid", ok: true, message: "No config (first run)" };
|
|
6431
|
+
}
|
|
6432
|
+
try {
|
|
6433
|
+
const raw = readFileSync9(PATHS.CONFIG_FILE, "utf-8");
|
|
6434
|
+
const config = JSON.parse(raw);
|
|
6435
|
+
const meshes = config.meshes ?? [];
|
|
6436
|
+
if (meshes.length === 0) {
|
|
6437
|
+
return { name: "keypairs-valid", ok: true, message: "No joined meshes" };
|
|
6438
|
+
}
|
|
6439
|
+
for (const m of meshes) {
|
|
6440
|
+
if (!m.pubkey || !HEX_64.test(m.pubkey)) {
|
|
6441
|
+
return { name: "keypairs-valid", ok: false, message: `Invalid pubkey for mesh ${m.slug ?? "unknown"}` };
|
|
6442
|
+
}
|
|
6443
|
+
if (!m.secretKey || !HEX_128.test(m.secretKey)) {
|
|
6444
|
+
return { name: "keypairs-valid", ok: false, message: `Invalid secretKey for mesh ${m.slug ?? "unknown"}` };
|
|
6445
|
+
}
|
|
6446
|
+
}
|
|
6447
|
+
return { name: "keypairs-valid", ok: true, message: `${meshes.length} keypair(s) valid` };
|
|
6448
|
+
} catch {
|
|
6449
|
+
return { name: "keypairs-valid", ok: false, message: "Could not parse config.json" };
|
|
6450
|
+
}
|
|
6451
|
+
}
|
|
6452
|
+
var HEX_64, HEX_128;
|
|
6453
|
+
var init_check_keypairs_valid = __esm(() => {
|
|
6454
|
+
init_paths();
|
|
6455
|
+
HEX_64 = /^[0-9a-f]{64}$/;
|
|
6456
|
+
HEX_128 = /^[0-9a-f]{128}$/;
|
|
6457
|
+
});
|
|
6458
|
+
|
|
6459
|
+
// src/services/health/facade.ts
|
|
6460
|
+
function runAllChecks() {
|
|
6461
|
+
return Object.values(CHECKS).map((fn) => fn());
|
|
6462
|
+
}
|
|
6463
|
+
var CHECKS;
|
|
6464
|
+
var init_facade13 = __esm(() => {
|
|
6465
|
+
init_check_claude_binary();
|
|
6466
|
+
init_check_mcp_registered();
|
|
6467
|
+
init_check_hooks_registered();
|
|
6468
|
+
init_check_config_perms();
|
|
6469
|
+
init_check_keypairs_valid();
|
|
6470
|
+
CHECKS = {
|
|
6471
|
+
"node-version": checkNodeVersion,
|
|
6472
|
+
"claude-binary": checkClaudeBinary,
|
|
6473
|
+
"mcp-registered": checkMcpRegistered2,
|
|
6474
|
+
"hooks-registered": checkHooksRegistered2,
|
|
6475
|
+
"config-perms": checkConfigPerms,
|
|
6476
|
+
"keypairs-valid": checkKeypairsValid
|
|
6477
|
+
};
|
|
6478
|
+
});
|
|
6479
|
+
|
|
6480
|
+
// src/commands/test.ts
|
|
6481
|
+
var exports_test = {};
|
|
6482
|
+
__export(exports_test, {
|
|
6483
|
+
runTest: () => runTest
|
|
6484
|
+
});
|
|
6485
|
+
async function run(name, fn) {
|
|
6486
|
+
const start = Date.now();
|
|
6487
|
+
try {
|
|
6488
|
+
const detail = await fn();
|
|
6489
|
+
results.push({ name, ok: true, detail, ms: Date.now() - start });
|
|
6490
|
+
console.log(` ${green(icons.check)} ${name.padEnd(18)} ${dim(detail)}`);
|
|
6491
|
+
return true;
|
|
6492
|
+
} catch (err) {
|
|
6493
|
+
const detail = err instanceof Error ? err.message : String(err);
|
|
6494
|
+
results.push({ name, ok: false, detail, ms: Date.now() - start });
|
|
6495
|
+
console.log(` ${red(icons.cross)} ${name.padEnd(18)} ${red(detail)}`);
|
|
6496
|
+
return false;
|
|
6497
|
+
}
|
|
6498
|
+
}
|
|
6499
|
+
async function runTest() {
|
|
6500
|
+
const started = Date.now();
|
|
6501
|
+
const meshSlug = `test-e2e-${Date.now().toString(36)}`;
|
|
6502
|
+
console.log("");
|
|
6503
|
+
console.log(` ${bold("claudemesh integration test")}`);
|
|
6504
|
+
console.log(` ${dim("─".repeat(40))}`);
|
|
6505
|
+
console.log("");
|
|
6506
|
+
const auth = getStoredToken();
|
|
6507
|
+
if (!auth) {
|
|
6508
|
+
console.log(` ${red(icons.cross)} Not signed in. Run ${bold("claudemesh login")} first.
|
|
6509
|
+
`);
|
|
6510
|
+
return EXIT.AUTH_FAILED;
|
|
6511
|
+
}
|
|
6512
|
+
let userId = "";
|
|
6513
|
+
try {
|
|
6514
|
+
const payload = JSON.parse(Buffer.from(auth.session_token.split(".")[1], "base64url").toString());
|
|
6515
|
+
userId = payload.sub ?? "";
|
|
6516
|
+
} catch {}
|
|
6517
|
+
await run("auth", async () => {
|
|
6518
|
+
if (!userId)
|
|
6519
|
+
throw new Error("invalid token");
|
|
6520
|
+
return `signed in as ${auth.user.display_name || auth.user.email}`;
|
|
6521
|
+
});
|
|
6522
|
+
{
|
|
6523
|
+
const checks = runAllChecks();
|
|
6524
|
+
const failed2 = checks.filter((c) => !c.ok);
|
|
6525
|
+
if (failed2.length > 0) {
|
|
6526
|
+
const warns = failed2.map((c) => c.name).join(", ");
|
|
6527
|
+
console.log(` ${yellow(icons.warn)} ${"doctor".padEnd(18)} ${dim(warns + " (non-blocking)")}`);
|
|
6528
|
+
} else {
|
|
6529
|
+
console.log(` ${green(icons.check)} ${"doctor".padEnd(18)} ${dim(checks.length + " checks passed")}`);
|
|
6530
|
+
}
|
|
6531
|
+
}
|
|
6532
|
+
await run("crypto", async () => {
|
|
6533
|
+
const kp = await generateKeypair3();
|
|
6534
|
+
const sig = await sign("test-message", kp.secretKey);
|
|
6535
|
+
const valid = await verify("test-message", sig, kp.publicKey);
|
|
6536
|
+
if (!valid)
|
|
6537
|
+
throw new Error("signature verification failed");
|
|
6538
|
+
const tampered = await verify("tampered", sig, kp.publicKey);
|
|
6539
|
+
if (tampered)
|
|
6540
|
+
throw new Error("tampered message should not verify");
|
|
6541
|
+
return "keypair + sign + verify round-trip";
|
|
6542
|
+
});
|
|
6543
|
+
let meshId = "";
|
|
6544
|
+
const createOk = await run("create", async () => {
|
|
6545
|
+
const result = await createMesh2(meshSlug);
|
|
6546
|
+
meshId = result.id;
|
|
6547
|
+
return `created "${result.slug}" (${result.id.slice(0, 8)}…)`;
|
|
6548
|
+
});
|
|
6549
|
+
if (!createOk) {
|
|
6550
|
+
console.log(`
|
|
6551
|
+
${red("Aborting — mesh creation failed.")}
|
|
6552
|
+
`);
|
|
6553
|
+
return EXIT.INTERNAL_ERROR;
|
|
6554
|
+
}
|
|
6555
|
+
await run("list", async () => {
|
|
6556
|
+
const config2 = readConfig();
|
|
6557
|
+
const found = config2.meshes.find((m) => m.slug === meshSlug);
|
|
6558
|
+
if (!found)
|
|
6559
|
+
throw new Error("mesh not in local config");
|
|
6560
|
+
return `found ${meshSlug} in local config`;
|
|
6561
|
+
});
|
|
6562
|
+
await run("server list", async () => {
|
|
6563
|
+
const res = await request({
|
|
6564
|
+
path: `/cli/meshes?user_id=${userId}`,
|
|
6565
|
+
baseUrl: BROKER_HTTP5
|
|
6566
|
+
});
|
|
6567
|
+
const found = res.meshes?.find((m) => m.slug === meshSlug);
|
|
6568
|
+
if (!found)
|
|
6569
|
+
throw new Error("mesh not on server");
|
|
6570
|
+
return `found ${meshSlug} on server (${res.meshes.length} total)`;
|
|
6571
|
+
});
|
|
6572
|
+
const config = readConfig();
|
|
6573
|
+
const meshConfig = config.meshes.find((m) => m.slug === meshSlug);
|
|
6574
|
+
let client = null;
|
|
6575
|
+
if (meshConfig) {
|
|
6576
|
+
await run("connect", async () => {
|
|
6577
|
+
client = new BrokerClient(meshConfig, { displayName: "test-runner" });
|
|
6578
|
+
await client.connect();
|
|
6579
|
+
if (client.status !== "open")
|
|
6580
|
+
throw new Error("status: " + client.status);
|
|
6581
|
+
return "broker connected, hello_ack received";
|
|
6582
|
+
});
|
|
6583
|
+
if (client) {
|
|
6584
|
+
await run("peers", async () => {
|
|
6585
|
+
const peers = await client.listPeers();
|
|
6586
|
+
return `${peers.length} peer(s) online`;
|
|
6587
|
+
});
|
|
6588
|
+
await run("send", async () => {
|
|
6589
|
+
const result = await client.send("*", "test-battery-ping", "low");
|
|
6590
|
+
if (!result.ok)
|
|
6591
|
+
throw new Error(result.error ?? "send failed");
|
|
6592
|
+
return `broadcast sent (${result.messageId?.slice(0, 8)}…)`;
|
|
6593
|
+
});
|
|
6594
|
+
let memoryId = null;
|
|
6595
|
+
await run("remember", async () => {
|
|
6596
|
+
memoryId = await client.remember("test-battery-memory", ["test", "e2e"]);
|
|
6597
|
+
if (!memoryId)
|
|
6598
|
+
throw new Error("no memory ID returned");
|
|
6599
|
+
return `stored (${memoryId.slice(0, 8)}…)`;
|
|
6600
|
+
});
|
|
6601
|
+
await run("recall", async () => {
|
|
6602
|
+
const memories = await client.recall("test-battery");
|
|
6603
|
+
if (memories.length === 0)
|
|
6604
|
+
throw new Error("no memories found");
|
|
6605
|
+
return `${memories.length} result(s)`;
|
|
6606
|
+
});
|
|
6607
|
+
await run("state set", async () => {
|
|
6608
|
+
await client.setState("test-key", "test-value-" + Date.now());
|
|
6609
|
+
return "key written";
|
|
6610
|
+
});
|
|
6611
|
+
await run("state get", async () => {
|
|
6612
|
+
const result = await client.getState("test-key");
|
|
6613
|
+
if (!result)
|
|
6614
|
+
throw new Error("key not found");
|
|
6615
|
+
if (!String(result.value).startsWith("test-value-"))
|
|
6616
|
+
throw new Error("wrong value");
|
|
6617
|
+
return `read back: ${String(result.value).slice(0, 20)}…`;
|
|
6618
|
+
});
|
|
6619
|
+
if (memoryId) {
|
|
6620
|
+
await run("forget", async () => {
|
|
6621
|
+
await client.forget(memoryId);
|
|
6622
|
+
return "memory cleaned up";
|
|
6623
|
+
});
|
|
6624
|
+
}
|
|
6625
|
+
await run("disconnect", async () => {
|
|
6626
|
+
client.close();
|
|
6627
|
+
return "connection closed";
|
|
6628
|
+
});
|
|
6629
|
+
}
|
|
6630
|
+
}
|
|
6631
|
+
await run("delete", async () => {
|
|
6632
|
+
await request({
|
|
6633
|
+
path: `/cli/mesh/${meshSlug}`,
|
|
6634
|
+
method: "DELETE",
|
|
6635
|
+
body: { user_id: userId },
|
|
6636
|
+
baseUrl: BROKER_HTTP5
|
|
6637
|
+
});
|
|
6638
|
+
leaveMesh(meshSlug);
|
|
6639
|
+
return `deleted "${meshSlug}" from server + local`;
|
|
6640
|
+
});
|
|
6641
|
+
const passed = results.filter((r) => r.ok).length;
|
|
6642
|
+
const failed = results.filter((r) => !r.ok).length;
|
|
6643
|
+
const totalMs = Date.now() - started;
|
|
6644
|
+
console.log("");
|
|
6645
|
+
if (failed === 0) {
|
|
6646
|
+
console.log(` ${green(bold(`${passed}/${results.length} passed`))} ${dim(`(${(totalMs / 1000).toFixed(1)}s)`)}`);
|
|
6647
|
+
} else {
|
|
6648
|
+
console.log(` ${red(bold(`${failed} failed`))}, ${green(`${passed} passed`)} ${dim(`(${(totalMs / 1000).toFixed(1)}s)`)}`);
|
|
6649
|
+
}
|
|
6650
|
+
console.log("");
|
|
6651
|
+
return failed > 0 ? EXIT.INTERNAL_ERROR : EXIT.SUCCESS;
|
|
6652
|
+
}
|
|
6653
|
+
var BROKER_HTTP5, results;
|
|
6654
|
+
var init_test = __esm(() => {
|
|
6655
|
+
init_facade6();
|
|
6656
|
+
init_facade11();
|
|
6657
|
+
init_facade5();
|
|
6658
|
+
init_facade2();
|
|
6659
|
+
init_facade7();
|
|
6660
|
+
init_facade9();
|
|
6661
|
+
init_urls();
|
|
6662
|
+
init_facade13();
|
|
6663
|
+
init_styles();
|
|
6664
|
+
init_exit_codes();
|
|
6665
|
+
BROKER_HTTP5 = URLS.BROKER.replace("wss://", "https://").replace("ws://", "http://").replace("/ws", "");
|
|
6666
|
+
results = [];
|
|
6667
|
+
});
|
|
6668
|
+
|
|
6344
6669
|
// src/mcp/tools/definitions.ts
|
|
6345
6670
|
var TOOLS;
|
|
6346
6671
|
var init_definitions = __esm(() => {
|
|
@@ -7661,12 +7986,12 @@ ${manifest.allowed_tools.map((t) => ` - ${t}`).join(`
|
|
|
7661
7986
|
if (!to || !message)
|
|
7662
7987
|
return text("send_message: `to` and `message` required", true);
|
|
7663
7988
|
const targets = Array.isArray(to) ? to : [to];
|
|
7664
|
-
const
|
|
7989
|
+
const results2 = [];
|
|
7665
7990
|
const seen2 = new Set;
|
|
7666
7991
|
for (const target of targets) {
|
|
7667
7992
|
const { client, targetSpec, error: error2 } = await resolveClient(target);
|
|
7668
7993
|
if (!client) {
|
|
7669
|
-
|
|
7994
|
+
results2.push(`✗ ${target}: ${error2 ?? "no client resolved"}`);
|
|
7670
7995
|
continue;
|
|
7671
7996
|
}
|
|
7672
7997
|
if (seen2.has(targetSpec))
|
|
@@ -7674,12 +7999,12 @@ ${manifest.allowed_tools.map((t) => ` - ${t}`).join(`
|
|
|
7674
7999
|
seen2.add(targetSpec);
|
|
7675
8000
|
const result = await client.send(targetSpec, message, priority ?? "next");
|
|
7676
8001
|
if (!result.ok) {
|
|
7677
|
-
|
|
8002
|
+
results2.push(`✗ ${target}: ${result.error}`);
|
|
7678
8003
|
} else {
|
|
7679
|
-
|
|
8004
|
+
results2.push(`✓ ${target} → ${result.messageId}`);
|
|
7680
8005
|
}
|
|
7681
8006
|
}
|
|
7682
|
-
return text(
|
|
8007
|
+
return text(results2.join(`
|
|
7683
8008
|
`));
|
|
7684
8009
|
}
|
|
7685
8010
|
case "list_peers": {
|
|
@@ -7959,15 +8284,15 @@ ${lines.join(`
|
|
|
7959
8284
|
const { path: filePath, name: fileName, tags, to: fileTo } = args ?? {};
|
|
7960
8285
|
if (!filePath)
|
|
7961
8286
|
return text("share_file: `path` required", true);
|
|
7962
|
-
const { existsSync:
|
|
7963
|
-
if (!
|
|
8287
|
+
const { existsSync: existsSync13 } = await import("node:fs");
|
|
8288
|
+
if (!existsSync13(filePath))
|
|
7964
8289
|
return text(`share_file: file not found: ${filePath}`, true);
|
|
7965
8290
|
const client = allClients()[0];
|
|
7966
8291
|
if (!client)
|
|
7967
8292
|
return text("share_file: not connected", true);
|
|
7968
8293
|
if (fileTo) {
|
|
7969
8294
|
const { encryptFile: encryptFile2, sealKeyForPeer: sealKeyForPeer2 } = await Promise.resolve().then(() => (init_file_crypto(), exports_file_crypto));
|
|
7970
|
-
const { readFileSync:
|
|
8295
|
+
const { readFileSync: readFileSync10, writeFileSync: writeFileSync7, mkdtempSync: mkdtempSync2, unlinkSync: unlinkSync2, rmdirSync } = await import("node:fs");
|
|
7971
8296
|
const { tmpdir: tmpdir2 } = await import("node:os");
|
|
7972
8297
|
const { join: join6, basename } = await import("node:path");
|
|
7973
8298
|
const peers = await client.listPeers();
|
|
@@ -7975,7 +8300,7 @@ ${lines.join(`
|
|
|
7975
8300
|
if (!targetPeer) {
|
|
7976
8301
|
return text(`share_file: peer not found: ${fileTo}`, true);
|
|
7977
8302
|
}
|
|
7978
|
-
const plaintext =
|
|
8303
|
+
const plaintext = readFileSync10(filePath);
|
|
7979
8304
|
const { ciphertext, nonce, key } = await encryptFile2(new Uint8Array(plaintext));
|
|
7980
8305
|
const sealedForTarget = await sealKeyForPeer2(key, targetPeer.pubkey);
|
|
7981
8306
|
const myPubkey = client.getSessionPubkey();
|
|
@@ -8142,11 +8467,11 @@ ${lines.join(`
|
|
|
8142
8467
|
const client = allClients()[0];
|
|
8143
8468
|
if (!client)
|
|
8144
8469
|
return text("vector_search: not connected", true);
|
|
8145
|
-
const
|
|
8146
|
-
if (
|
|
8470
|
+
const results2 = await client.vectorSearch(collection, query, limit);
|
|
8471
|
+
if (results2.length === 0)
|
|
8147
8472
|
return text(`No results in ${collection} for "${query}".`);
|
|
8148
|
-
const lines =
|
|
8149
|
-
return text(`${
|
|
8473
|
+
const lines = results2.map((r) => `- [${r.id.slice(0, 8)}…] (score: ${r.score.toFixed(3)}) ${r.text.slice(0, 120)}${r.text.length > 120 ? "…" : ""}`);
|
|
8474
|
+
return text(`${results2.length} result(s) in ${collection}:
|
|
8150
8475
|
${lines.join(`
|
|
8151
8476
|
`)}`);
|
|
8152
8477
|
}
|
|
@@ -8590,34 +8915,34 @@ ${lines.join(`
|
|
|
8590
8915
|
const client = allClients()[0];
|
|
8591
8916
|
if (!client)
|
|
8592
8917
|
return text("ping_mesh: not connected", true);
|
|
8593
|
-
const
|
|
8594
|
-
|
|
8595
|
-
|
|
8918
|
+
const results2 = [];
|
|
8919
|
+
results2.push(`WS status: ${client.status}`);
|
|
8920
|
+
results2.push(`Mesh: ${client.meshSlug}`);
|
|
8596
8921
|
const peers = await client.listPeers();
|
|
8597
8922
|
const selfPeer = peers.find((p) => p.displayName === myName);
|
|
8598
|
-
|
|
8599
|
-
|
|
8600
|
-
|
|
8923
|
+
results2.push(`Your status: ${selfPeer?.status ?? "not found in peer list"}`);
|
|
8924
|
+
results2.push(`Peers online: ${peers.length}`);
|
|
8925
|
+
results2.push(`Push buffer: ${client.pushHistory.length} buffered`);
|
|
8601
8926
|
for (const prio of toTest) {
|
|
8602
8927
|
const sendTime = Date.now();
|
|
8603
8928
|
const target = peers.find((p) => p.displayName !== myName);
|
|
8604
8929
|
const sendResult = await client.send(target?.pubkey ?? "*", `__ping__ ${prio} from ${myName} at ${new Date().toISOString()}`, prio);
|
|
8605
8930
|
const ackTime = Date.now();
|
|
8606
8931
|
if (!sendResult.ok) {
|
|
8607
|
-
|
|
8932
|
+
results2.push(`[${prio}] SEND FAILED: ${sendResult.error}`);
|
|
8608
8933
|
} else {
|
|
8609
|
-
|
|
8934
|
+
results2.push(`[${prio}] send→ack: ${ackTime - sendTime}ms (msgId: ${sendResult.messageId?.slice(0, 12)})`);
|
|
8610
8935
|
if (prio !== "now" && selfPeer?.status === "working") {
|
|
8611
|
-
|
|
8936
|
+
results2.push(` ⚠ peer status is "working" — broker holds "${prio}" until idle`);
|
|
8612
8937
|
}
|
|
8613
8938
|
}
|
|
8614
8939
|
}
|
|
8615
|
-
|
|
8616
|
-
|
|
8617
|
-
|
|
8618
|
-
|
|
8619
|
-
|
|
8620
|
-
return text(
|
|
8940
|
+
results2.push("");
|
|
8941
|
+
results2.push("Pipeline check:");
|
|
8942
|
+
results2.push(` onPush handlers: active`);
|
|
8943
|
+
results2.push(` messageMode: ${messageMode}`);
|
|
8944
|
+
results2.push(` server.notification: ${messageMode === "off" ? "disabled (mode=off)" : "enabled"}`);
|
|
8945
|
+
return text(results2.join(`
|
|
8621
8946
|
`));
|
|
8622
8947
|
}
|
|
8623
8948
|
case "mesh_mcp_register": {
|
|
@@ -8843,10 +9168,10 @@ ${lines.join(`
|
|
|
8843
9168
|
const entryType = vType ?? "env";
|
|
8844
9169
|
let plaintextBytes;
|
|
8845
9170
|
if (entryType === "file") {
|
|
8846
|
-
const { existsSync:
|
|
8847
|
-
if (!
|
|
9171
|
+
const { existsSync: existsSync13, readFileSync: readFileSync10 } = await import("node:fs");
|
|
9172
|
+
if (!existsSync13(value))
|
|
8848
9173
|
return text(`vault_set: file not found: ${value}`, true);
|
|
8849
|
-
plaintextBytes = new Uint8Array(
|
|
9174
|
+
plaintextBytes = new Uint8Array(readFileSync10(value));
|
|
8850
9175
|
} else {
|
|
8851
9176
|
plaintextBytes = new TextEncoder().encode(value);
|
|
8852
9177
|
}
|
|
@@ -9888,6 +10213,11 @@ async function main() {
|
|
|
9888
10213
|
await runSync2({ force: !!flags.force });
|
|
9889
10214
|
break;
|
|
9890
10215
|
}
|
|
10216
|
+
case "test": {
|
|
10217
|
+
const { runTest: runTest2 } = await Promise.resolve().then(() => (init_test(), exports_test));
|
|
10218
|
+
process.exit(await runTest2());
|
|
10219
|
+
break;
|
|
10220
|
+
}
|
|
9891
10221
|
case "mcp": {
|
|
9892
10222
|
const { runMcp: runMcp2 } = await Promise.resolve().then(() => (init_mcp(), exports_mcp));
|
|
9893
10223
|
await runMcp2();
|
|
@@ -9915,4 +10245,4 @@ main().catch((err) => {
|
|
|
9915
10245
|
process.exit(EXIT.INTERNAL_ERROR);
|
|
9916
10246
|
});
|
|
9917
10247
|
|
|
9918
|
-
//# debugId=
|
|
10248
|
+
//# debugId=7B5D9F4BBB2B855F64756E2164756E21
|