claudemesh-cli 1.2.1 → 1.4.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.
@@ -88,7 +88,7 @@ __export(exports_urls, {
88
88
  VERSION: () => VERSION,
89
89
  URLS: () => URLS
90
90
  });
91
- var URLS, VERSION = "1.2.1", env;
91
+ var URLS, VERSION = "1.4.0", env;
92
92
  var init_urls = __esm(() => {
93
93
  URLS = {
94
94
  BROKER: process.env.CLAUDEMESH_BROKER_URL ?? "wss://ic.claudemesh.com/ws",
@@ -6817,26 +6817,27 @@ __export(exports_remember, {
6817
6817
  remember: () => remember
6818
6818
  });
6819
6819
  async function remember(content, opts = {}) {
6820
- const client = allClients()[0];
6821
- if (!client) {
6822
- render.err("Not connected to any mesh.");
6823
- return EXIT.NETWORK_ERROR;
6820
+ if (!content) {
6821
+ render.err("Usage: claudemesh remember <text>");
6822
+ return EXIT.INVALID_ARGS;
6824
6823
  }
6825
6824
  const tags = opts.tags?.split(",").map((t) => t.trim()).filter(Boolean);
6826
- const id = await client.remember(content, tags);
6827
- if (opts.json) {
6828
- console.log(JSON.stringify({ id, content, tags }));
6829
- return EXIT.SUCCESS;
6830
- }
6831
- if (id) {
6832
- render.ok("remembered", dim(id.slice(0, 8)));
6833
- return EXIT.SUCCESS;
6834
- }
6835
- render.err("failed to store memory");
6836
- return EXIT.INTERNAL_ERROR;
6825
+ return await withMesh({ meshSlug: opts.mesh ?? null }, async (client) => {
6826
+ const id = await client.remember(content, tags);
6827
+ if (opts.json) {
6828
+ console.log(JSON.stringify({ id, content, tags }));
6829
+ return EXIT.SUCCESS;
6830
+ }
6831
+ if (id) {
6832
+ render.ok("remembered", dim(id.slice(0, 8)));
6833
+ return EXIT.SUCCESS;
6834
+ }
6835
+ render.err("failed to store memory");
6836
+ return EXIT.INTERNAL_ERROR;
6837
+ });
6837
6838
  }
6838
6839
  var init_remember = __esm(() => {
6839
- init_facade8();
6840
+ init_connect();
6840
6841
  init_render();
6841
6842
  init_styles();
6842
6843
  init_exit_codes();
@@ -6848,35 +6849,36 @@ __export(exports_recall, {
6848
6849
  recall: () => recall
6849
6850
  });
6850
6851
  async function recall(query, opts = {}) {
6851
- const client = allClients()[0];
6852
- if (!client) {
6853
- render.err("Not connected to any mesh.");
6854
- return EXIT.NETWORK_ERROR;
6855
- }
6856
- const memories = await client.recall(query);
6857
- if (opts.json) {
6858
- console.log(JSON.stringify(memories, null, 2));
6859
- return EXIT.SUCCESS;
6860
- }
6861
- if (memories.length === 0) {
6862
- render.info(dim("no memories found."));
6863
- return EXIT.SUCCESS;
6852
+ if (!query) {
6853
+ render.err("Usage: claudemesh recall <query>");
6854
+ return EXIT.INVALID_ARGS;
6864
6855
  }
6865
- render.section(`memories (${memories.length})`);
6866
- for (const m of memories) {
6867
- const tags = m.tags.length ? dim(` [${m.tags.map((t) => clay(t)).join(dim(", "))}]`) : "";
6868
- process.stdout.write(` ${bold(m.id.slice(0, 8))}${tags}
6856
+ return await withMesh({ meshSlug: opts.mesh ?? null }, async (client) => {
6857
+ const memories = await client.recall(query);
6858
+ if (opts.json) {
6859
+ console.log(JSON.stringify(memories, null, 2));
6860
+ return EXIT.SUCCESS;
6861
+ }
6862
+ if (memories.length === 0) {
6863
+ render.info(dim("no memories found."));
6864
+ return EXIT.SUCCESS;
6865
+ }
6866
+ render.section(`memories (${memories.length})`);
6867
+ for (const m of memories) {
6868
+ const tags = m.tags.length ? dim(` [${m.tags.map((t) => clay(t)).join(dim(", "))}]`) : "";
6869
+ process.stdout.write(` ${bold(m.id.slice(0, 8))}${tags}
6869
6870
  `);
6870
- process.stdout.write(` ${m.content}
6871
+ process.stdout.write(` ${m.content}
6871
6872
  `);
6872
- process.stdout.write(` ${dim(m.rememberedBy + " · " + new Date(m.rememberedAt).toLocaleString())}
6873
+ process.stdout.write(` ${dim(m.rememberedBy + " · " + new Date(m.rememberedAt).toLocaleString())}
6873
6874
 
6874
6875
  `);
6875
- }
6876
- return EXIT.SUCCESS;
6876
+ }
6877
+ return EXIT.SUCCESS;
6878
+ });
6877
6879
  }
6878
6880
  var init_recall = __esm(() => {
6879
- init_facade8();
6881
+ init_connect();
6880
6882
  init_render();
6881
6883
  init_styles();
6882
6884
  init_exit_codes();
@@ -7330,92 +7332,6 @@ var init_remind = __esm(() => {
7330
7332
  init_styles();
7331
7333
  });
7332
7334
 
7333
- // src/commands/profile.ts
7334
- var exports_profile = {};
7335
- __export(exports_profile, {
7336
- runProfile: () => runProfile
7337
- });
7338
- async function runProfile(flags) {
7339
- const useColor = !process.env.NO_COLOR && process.env.TERM !== "dumb" && process.stdout.isTTY;
7340
- const dim2 = (s) => useColor ? `\x1B[2m${s}\x1B[22m` : s;
7341
- const green3 = (s) => useColor ? `\x1B[32m${s}\x1B[39m` : s;
7342
- const config = readConfig();
7343
- if (config.meshes.length === 0) {
7344
- console.error("No meshes joined. Run `claudemesh join <url>` first.");
7345
- process.exit(1);
7346
- }
7347
- const mesh = flags.mesh ? config.meshes.find((m) => m.slug === flags.mesh) : config.meshes[0];
7348
- if (!mesh) {
7349
- console.error(`Mesh "${flags.mesh}" not found. Joined: ${config.meshes.map((m) => m.slug).join(", ")}`);
7350
- process.exit(1);
7351
- }
7352
- const brokerUrl = mesh.brokerUrl.replace("wss://", "https://").replace("ws://", "http://").replace(/\/ws\/?$/, "");
7353
- const hasEdits = flags["role-tag"] !== undefined || flags.groups !== undefined || flags["message-mode"] !== undefined || flags.name !== undefined;
7354
- if (hasEdits) {
7355
- const targetMemberId = flags.member ?? mesh.memberId;
7356
- const body = {};
7357
- if (flags.name !== undefined)
7358
- body.displayName = flags.name;
7359
- if (flags["role-tag"] !== undefined)
7360
- body.roleTag = flags["role-tag"];
7361
- if (flags.groups !== undefined) {
7362
- body.groups = flags.groups.split(",").map((s) => {
7363
- const [name, role] = s.trim().split(":");
7364
- return role ? { name, role } : { name };
7365
- });
7366
- }
7367
- if (flags["message-mode"] !== undefined)
7368
- body.messageMode = flags["message-mode"];
7369
- const res = await fetch(`${brokerUrl}/mesh/${mesh.meshId}/member/${targetMemberId}`, {
7370
- method: "PATCH",
7371
- headers: {
7372
- "Content-Type": "application/json",
7373
- "X-Member-Id": mesh.memberId
7374
- },
7375
- body: JSON.stringify(body)
7376
- });
7377
- const result = await res.json();
7378
- if (flags.json) {
7379
- console.log(JSON.stringify(result, null, 2));
7380
- } else if (result.ok) {
7381
- console.log(green3("✓ Profile updated"));
7382
- const member = result.member;
7383
- printProfile(member, dim2);
7384
- } else {
7385
- console.error(`Error: ${result.error}`);
7386
- process.exit(1);
7387
- }
7388
- } else {
7389
- const res = await fetch(`${brokerUrl}/mesh/${mesh.meshId}/members`);
7390
- const result = await res.json();
7391
- if (!result.ok) {
7392
- console.error(`Error: ${result.error}`);
7393
- process.exit(1);
7394
- }
7395
- const me = result.members?.find((m) => m.id === mesh.memberId);
7396
- if (flags.json) {
7397
- console.log(JSON.stringify(me ?? {}, null, 2));
7398
- } else if (me) {
7399
- printProfile(me, dim2);
7400
- } else {
7401
- console.log("Member not found in mesh.");
7402
- }
7403
- }
7404
- }
7405
- function printProfile(member, dim2) {
7406
- const groups = member.groups;
7407
- const groupStr = groups?.length ? groups.map((g) => g.role ? `${g.name} (${g.role})` : g.name).join(", ") : dim2("(none)");
7408
- console.log(` Name: ${member.displayName ?? dim2("(not set)")}`);
7409
- console.log(` Role: ${member.roleTag ?? dim2("(not set)")}`);
7410
- console.log(` Groups: ${groupStr}`);
7411
- console.log(` Messages: ${member.messageMode ?? "push"}`);
7412
- console.log(` Access: ${member.permission ?? "member"}`);
7413
- console.log(` Mesh: ${dim2(String(member.id ?? ""))}`);
7414
- }
7415
- var init_profile = __esm(() => {
7416
- init_facade();
7417
- });
7418
-
7419
7335
  // src/commands/register.ts
7420
7336
  var exports_register = {};
7421
7337
  __export(exports_register, {
@@ -9563,79 +9479,925 @@ async function runRevoke(peer, caps, opts = {}) {
9563
9479
  render.kv([["now", after.length ? after.join(", ") : "(none)"]]);
9564
9480
  return EXIT.SUCCESS;
9565
9481
  }
9566
- async function runBlock(peer, opts = {}) {
9567
- if (!peer) {
9568
- render.err("Usage: claudemesh block <peer>");
9482
+ async function runBlock(peer, opts = {}) {
9483
+ if (!peer) {
9484
+ render.err("Usage: claudemesh block <peer>");
9485
+ return EXIT.INVALID_ARGS;
9486
+ }
9487
+ const mesh = pickMesh2(opts.mesh);
9488
+ if (!mesh) {
9489
+ render.err("No matching mesh.");
9490
+ return EXIT.NOT_FOUND;
9491
+ }
9492
+ const resolved = await resolvePeer(mesh, peer);
9493
+ if (!resolved) {
9494
+ render.err(`Peer "${peer}" not found on ${mesh}.`);
9495
+ return EXIT.NOT_FOUND;
9496
+ }
9497
+ const store = readGrants();
9498
+ const meshGrants = store[mesh] ?? {};
9499
+ meshGrants[resolved.pubkey] = [];
9500
+ store[mesh] = meshGrants;
9501
+ writeGrants(store);
9502
+ await syncToBroker(mesh, { [resolved.pubkey]: [] });
9503
+ render.ok(`Blocked ${resolved.displayName} on ${mesh} (all capabilities revoked).`);
9504
+ render.hint(`Undo with: claudemesh grant ${resolved.displayName} all --mesh ${mesh}`);
9505
+ return EXIT.SUCCESS;
9506
+ }
9507
+ async function runGrants(opts = {}) {
9508
+ const mesh = pickMesh2(opts.mesh);
9509
+ if (!mesh) {
9510
+ render.err("No matching mesh.");
9511
+ return EXIT.NOT_FOUND;
9512
+ }
9513
+ const store = readGrants();
9514
+ const meshGrants = store[mesh] ?? {};
9515
+ if (opts.json) {
9516
+ console.log(JSON.stringify({ schema_version: "1.0", mesh, grants: meshGrants }, null, 2));
9517
+ return EXIT.SUCCESS;
9518
+ }
9519
+ render.section(`grants on ${mesh}`);
9520
+ const peerPubkeys = Object.keys(meshGrants);
9521
+ if (peerPubkeys.length === 0) {
9522
+ render.info("(no overrides — all peers use default caps: " + DEFAULT_CAPS.join(", ") + ")");
9523
+ return EXIT.SUCCESS;
9524
+ }
9525
+ await withMesh({ meshSlug: mesh }, async (client) => {
9526
+ const peers = await client.listPeers();
9527
+ const byPk = new Map(peers.map((p) => [p.pubkey, p.displayName]));
9528
+ for (const [pk, caps] of Object.entries(meshGrants)) {
9529
+ const name = byPk.get(pk) ?? `${pk.slice(0, 10)}…`;
9530
+ render.kv([[name, caps.length ? caps.join(", ") : "(blocked)"]]);
9531
+ }
9532
+ });
9533
+ return EXIT.SUCCESS;
9534
+ }
9535
+ function isAllowed(meshSlug, peerPubkey, cap) {
9536
+ const store = readGrants();
9537
+ const entry = store[meshSlug]?.[peerPubkey];
9538
+ if (entry === undefined)
9539
+ return DEFAULT_CAPS.includes(cap);
9540
+ return entry.includes(cap);
9541
+ }
9542
+ var BROKER_HTTP7, ALL_CAPS, DEFAULT_CAPS, GRANT_FILE;
9543
+ var init_grants = __esm(() => {
9544
+ init_facade();
9545
+ init_connect();
9546
+ init_render();
9547
+ init_exit_codes();
9548
+ init_facade6();
9549
+ init_facade3();
9550
+ init_urls();
9551
+ BROKER_HTTP7 = URLS.BROKER.replace("wss://", "https://").replace("ws://", "http://").replace("/ws", "");
9552
+ ALL_CAPS = ["read", "dm", "broadcast", "state-read", "state-write", "file-read"];
9553
+ DEFAULT_CAPS = ["read", "dm", "broadcast", "state-read"];
9554
+ GRANT_FILE = join11(homedir10(), ".claudemesh", "grants.json");
9555
+ });
9556
+
9557
+ // src/commands/profile.ts
9558
+ var exports_profile = {};
9559
+ __export(exports_profile, {
9560
+ runProfile: () => runProfile
9561
+ });
9562
+ async function runProfile(flags) {
9563
+ const useColor = !process.env.NO_COLOR && process.env.TERM !== "dumb" && process.stdout.isTTY;
9564
+ const dim2 = (s) => useColor ? `\x1B[2m${s}\x1B[22m` : s;
9565
+ const green3 = (s) => useColor ? `\x1B[32m${s}\x1B[39m` : s;
9566
+ const config = readConfig();
9567
+ if (config.meshes.length === 0) {
9568
+ console.error("No meshes joined. Run `claudemesh join <url>` first.");
9569
+ process.exit(1);
9570
+ }
9571
+ const mesh = flags.mesh ? config.meshes.find((m) => m.slug === flags.mesh) : config.meshes[0];
9572
+ if (!mesh) {
9573
+ console.error(`Mesh "${flags.mesh}" not found. Joined: ${config.meshes.map((m) => m.slug).join(", ")}`);
9574
+ process.exit(1);
9575
+ }
9576
+ const brokerUrl = mesh.brokerUrl.replace("wss://", "https://").replace("ws://", "http://").replace(/\/ws\/?$/, "");
9577
+ const hasEdits = flags["role-tag"] !== undefined || flags.groups !== undefined || flags["message-mode"] !== undefined || flags.name !== undefined;
9578
+ if (hasEdits) {
9579
+ const targetMemberId = flags.member ?? mesh.memberId;
9580
+ const body = {};
9581
+ if (flags.name !== undefined)
9582
+ body.displayName = flags.name;
9583
+ if (flags["role-tag"] !== undefined)
9584
+ body.roleTag = flags["role-tag"];
9585
+ if (flags.groups !== undefined) {
9586
+ body.groups = flags.groups.split(",").map((s) => {
9587
+ const [name, role] = s.trim().split(":");
9588
+ return role ? { name, role } : { name };
9589
+ });
9590
+ }
9591
+ if (flags["message-mode"] !== undefined)
9592
+ body.messageMode = flags["message-mode"];
9593
+ const res = await fetch(`${brokerUrl}/mesh/${mesh.meshId}/member/${targetMemberId}`, {
9594
+ method: "PATCH",
9595
+ headers: {
9596
+ "Content-Type": "application/json",
9597
+ "X-Member-Id": mesh.memberId
9598
+ },
9599
+ body: JSON.stringify(body)
9600
+ });
9601
+ const result = await res.json();
9602
+ if (flags.json) {
9603
+ console.log(JSON.stringify(result, null, 2));
9604
+ } else if (result.ok) {
9605
+ console.log(green3("✓ Profile updated"));
9606
+ const member = result.member;
9607
+ printProfile(member, dim2);
9608
+ } else {
9609
+ console.error(`Error: ${result.error}`);
9610
+ process.exit(1);
9611
+ }
9612
+ } else {
9613
+ const res = await fetch(`${brokerUrl}/mesh/${mesh.meshId}/members`);
9614
+ const result = await res.json();
9615
+ if (!result.ok) {
9616
+ console.error(`Error: ${result.error}`);
9617
+ process.exit(1);
9618
+ }
9619
+ const me = result.members?.find((m) => m.id === mesh.memberId);
9620
+ if (flags.json) {
9621
+ console.log(JSON.stringify(me ?? {}, null, 2));
9622
+ } else if (me) {
9623
+ printProfile(me, dim2);
9624
+ } else {
9625
+ console.log("Member not found in mesh.");
9626
+ }
9627
+ }
9628
+ }
9629
+ function printProfile(member, dim2) {
9630
+ const groups = member.groups;
9631
+ const groupStr = groups?.length ? groups.map((g) => g.role ? `${g.name} (${g.role})` : g.name).join(", ") : dim2("(none)");
9632
+ console.log(` Name: ${member.displayName ?? dim2("(not set)")}`);
9633
+ console.log(` Role: ${member.roleTag ?? dim2("(not set)")}`);
9634
+ console.log(` Groups: ${groupStr}`);
9635
+ console.log(` Messages: ${member.messageMode ?? "push"}`);
9636
+ console.log(` Access: ${member.permission ?? "member"}`);
9637
+ console.log(` Mesh: ${dim2(String(member.id ?? ""))}`);
9638
+ }
9639
+ var init_profile = __esm(() => {
9640
+ init_facade();
9641
+ });
9642
+
9643
+ // src/commands/platform-actions.ts
9644
+ var exports_platform_actions = {};
9645
+ __export(exports_platform_actions, {
9646
+ runWebhookList: () => runWebhookList,
9647
+ runWebhookDelete: () => runWebhookDelete,
9648
+ runWatchList: () => runWatchList,
9649
+ runVectorStore: () => runVectorStore,
9650
+ runVectorSearch: () => runVectorSearch,
9651
+ runVectorDelete: () => runVectorDelete,
9652
+ runVectorCollections: () => runVectorCollections,
9653
+ runVaultList: () => runVaultList,
9654
+ runVaultDelete: () => runVaultDelete,
9655
+ runUnwatch: () => runUnwatch,
9656
+ runTaskList: () => runTaskList,
9657
+ runTaskCreate: () => runTaskCreate,
9658
+ runStreamPublish: () => runStreamPublish,
9659
+ runStreamList: () => runStreamList,
9660
+ runStreamCreate: () => runStreamCreate,
9661
+ runSqlSchema: () => runSqlSchema,
9662
+ runSqlQuery: () => runSqlQuery,
9663
+ runSqlExecute: () => runSqlExecute,
9664
+ runSkillRemove: () => runSkillRemove,
9665
+ runSkillList: () => runSkillList,
9666
+ runSkillGet: () => runSkillGet,
9667
+ runMeshMcpList: () => runMeshMcpList,
9668
+ runMeshMcpCatalog: () => runMeshMcpCatalog,
9669
+ runMeshMcpCall: () => runMeshMcpCall,
9670
+ runGraphQuery: () => runGraphQuery,
9671
+ runGraphExecute: () => runGraphExecute,
9672
+ runFileStatus: () => runFileStatus,
9673
+ runFileList: () => runFileList,
9674
+ runFileDelete: () => runFileDelete,
9675
+ runContextShare: () => runContextShare,
9676
+ runContextList: () => runContextList,
9677
+ runContextGet: () => runContextGet,
9678
+ runClockSet: () => runClockSet,
9679
+ runClockResume: () => runClockResume,
9680
+ runClockPause: () => runClockPause
9681
+ });
9682
+ function emitJson(data) {
9683
+ console.log(JSON.stringify(data, null, 2));
9684
+ }
9685
+ async function runVectorStore(collection, text, opts) {
9686
+ if (!collection || !text) {
9687
+ render.err("Usage: claudemesh vector store <collection> <text> [--metadata <json>]");
9688
+ return EXIT.INVALID_ARGS;
9689
+ }
9690
+ let metadata;
9691
+ if (opts.metadata) {
9692
+ try {
9693
+ metadata = JSON.parse(opts.metadata);
9694
+ } catch {
9695
+ render.err("--metadata must be JSON");
9696
+ return EXIT.INVALID_ARGS;
9697
+ }
9698
+ }
9699
+ return await withMesh({ meshSlug: opts.mesh ?? null }, async (client) => {
9700
+ const id = await client.vectorStore(collection, text, metadata);
9701
+ if (!id) {
9702
+ render.err("store failed");
9703
+ return EXIT.INTERNAL_ERROR;
9704
+ }
9705
+ if (opts.json)
9706
+ emitJson({ id, collection });
9707
+ else
9708
+ render.ok(`stored in ${clay(collection)}`, dim(id));
9709
+ return EXIT.SUCCESS;
9710
+ });
9711
+ }
9712
+ async function runVectorSearch(collection, query, opts) {
9713
+ if (!collection || !query) {
9714
+ render.err("Usage: claudemesh vector search <collection> <query> [--limit N]");
9715
+ return EXIT.INVALID_ARGS;
9716
+ }
9717
+ const limit = opts.limit ? parseInt(opts.limit, 10) : undefined;
9718
+ return await withMesh({ meshSlug: opts.mesh ?? null }, async (client) => {
9719
+ const hits = await client.vectorSearch(collection, query, limit);
9720
+ if (opts.json) {
9721
+ emitJson(hits);
9722
+ return EXIT.SUCCESS;
9723
+ }
9724
+ if (hits.length === 0) {
9725
+ render.info(dim("(no matches)"));
9726
+ return EXIT.SUCCESS;
9727
+ }
9728
+ render.section(`${hits.length} match${hits.length === 1 ? "" : "es"} in ${clay(collection)}`);
9729
+ for (const h of hits) {
9730
+ process.stdout.write(` ${bold(h.score.toFixed(3))} ${dim(h.id.slice(0, 8))} ${h.text}
9731
+ `);
9732
+ }
9733
+ return EXIT.SUCCESS;
9734
+ });
9735
+ }
9736
+ async function runVectorDelete(collection, id, opts) {
9737
+ if (!collection || !id) {
9738
+ render.err("Usage: claudemesh vector delete <collection> <id>");
9739
+ return EXIT.INVALID_ARGS;
9740
+ }
9741
+ return await withMesh({ meshSlug: opts.mesh ?? null }, async (client) => {
9742
+ await client.vectorDelete(collection, id);
9743
+ if (opts.json)
9744
+ emitJson({ id, deleted: true });
9745
+ else
9746
+ render.ok(`deleted ${dim(id.slice(0, 8))}`);
9747
+ return EXIT.SUCCESS;
9748
+ });
9749
+ }
9750
+ async function runVectorCollections(opts) {
9751
+ return await withMesh({ meshSlug: opts.mesh ?? null }, async (client) => {
9752
+ const cols = await client.listCollections();
9753
+ if (opts.json) {
9754
+ emitJson(cols);
9755
+ return EXIT.SUCCESS;
9756
+ }
9757
+ if (cols.length === 0) {
9758
+ render.info(dim("(no collections)"));
9759
+ return EXIT.SUCCESS;
9760
+ }
9761
+ render.section(`vector collections (${cols.length})`);
9762
+ for (const c of cols)
9763
+ process.stdout.write(` ${clay(c)}
9764
+ `);
9765
+ return EXIT.SUCCESS;
9766
+ });
9767
+ }
9768
+ async function runGraphQuery(cypher, opts) {
9769
+ if (!cypher) {
9770
+ render.err('Usage: claudemesh graph query "<cypher>"');
9771
+ return EXIT.INVALID_ARGS;
9772
+ }
9773
+ return await withMesh({ meshSlug: opts.mesh ?? null }, async (client) => {
9774
+ const rows = await client.graphQuery(cypher);
9775
+ if (opts.json) {
9776
+ emitJson(rows);
9777
+ return EXIT.SUCCESS;
9778
+ }
9779
+ if (rows.length === 0) {
9780
+ render.info(dim("(no rows)"));
9781
+ return EXIT.SUCCESS;
9782
+ }
9783
+ render.section(`${rows.length} row${rows.length === 1 ? "" : "s"}`);
9784
+ for (const r of rows)
9785
+ process.stdout.write(` ${JSON.stringify(r)}
9786
+ `);
9787
+ return EXIT.SUCCESS;
9788
+ });
9789
+ }
9790
+ async function runGraphExecute(cypher, opts) {
9791
+ if (!cypher) {
9792
+ render.err('Usage: claudemesh graph execute "<cypher>"');
9793
+ return EXIT.INVALID_ARGS;
9794
+ }
9795
+ return await withMesh({ meshSlug: opts.mesh ?? null }, async (client) => {
9796
+ const rows = await client.graphExecute(cypher);
9797
+ if (opts.json) {
9798
+ emitJson(rows);
9799
+ return EXIT.SUCCESS;
9800
+ }
9801
+ render.ok("executed", `${rows.length} row${rows.length === 1 ? "" : "s"} affected`);
9802
+ return EXIT.SUCCESS;
9803
+ });
9804
+ }
9805
+ async function runContextShare(summary, opts) {
9806
+ if (!summary) {
9807
+ render.err('Usage: claudemesh context share "<summary>" [--files a,b] [--findings x,y] [--tags t1,t2]');
9808
+ return EXIT.INVALID_ARGS;
9809
+ }
9810
+ const files = opts.files?.split(",").map((s) => s.trim()).filter(Boolean);
9811
+ const findings = opts.findings?.split(",").map((s) => s.trim()).filter(Boolean);
9812
+ const tags = opts.tags?.split(",").map((s) => s.trim()).filter(Boolean);
9813
+ return await withMesh({ meshSlug: opts.mesh ?? null }, async (client) => {
9814
+ await client.shareContext(summary, files, findings, tags);
9815
+ if (opts.json)
9816
+ emitJson({ shared: true, summary });
9817
+ else
9818
+ render.ok("context shared");
9819
+ return EXIT.SUCCESS;
9820
+ });
9821
+ }
9822
+ async function runContextGet(query, opts) {
9823
+ if (!query) {
9824
+ render.err('Usage: claudemesh context get "<query>"');
9825
+ return EXIT.INVALID_ARGS;
9826
+ }
9827
+ return await withMesh({ meshSlug: opts.mesh ?? null }, async (client) => {
9828
+ const ctxs = await client.getContext(query);
9829
+ if (opts.json) {
9830
+ emitJson(ctxs);
9831
+ return EXIT.SUCCESS;
9832
+ }
9833
+ if (ctxs.length === 0) {
9834
+ render.info(dim("(no matches)"));
9835
+ return EXIT.SUCCESS;
9836
+ }
9837
+ render.section(`${ctxs.length} context${ctxs.length === 1 ? "" : "s"}`);
9838
+ for (const c of ctxs) {
9839
+ process.stdout.write(` ${bold(c.peerName)} ${dim("·")} ${c.updatedAt}
9840
+ `);
9841
+ process.stdout.write(` ${c.summary}
9842
+ `);
9843
+ if (c.tags.length)
9844
+ process.stdout.write(` ${dim("tags: " + c.tags.join(", "))}
9845
+ `);
9846
+ }
9847
+ return EXIT.SUCCESS;
9848
+ });
9849
+ }
9850
+ async function runContextList(opts) {
9851
+ return await withMesh({ meshSlug: opts.mesh ?? null }, async (client) => {
9852
+ const ctxs = await client.listContexts();
9853
+ if (opts.json) {
9854
+ emitJson(ctxs);
9855
+ return EXIT.SUCCESS;
9856
+ }
9857
+ if (ctxs.length === 0) {
9858
+ render.info(dim("(no contexts)"));
9859
+ return EXIT.SUCCESS;
9860
+ }
9861
+ render.section(`shared contexts (${ctxs.length})`);
9862
+ for (const c of ctxs) {
9863
+ process.stdout.write(` ${bold(c.peerName)} ${dim("·")} ${c.updatedAt}
9864
+ `);
9865
+ process.stdout.write(` ${c.summary}
9866
+ `);
9867
+ }
9868
+ return EXIT.SUCCESS;
9869
+ });
9870
+ }
9871
+ async function runStreamCreate(name, opts) {
9872
+ if (!name) {
9873
+ render.err("Usage: claudemesh stream create <name>");
9874
+ return EXIT.INVALID_ARGS;
9875
+ }
9876
+ return await withMesh({ meshSlug: opts.mesh ?? null }, async (client) => {
9877
+ const id = await client.createStream(name);
9878
+ if (!id) {
9879
+ render.err("create failed");
9880
+ return EXIT.INTERNAL_ERROR;
9881
+ }
9882
+ if (opts.json)
9883
+ emitJson({ id, name });
9884
+ else
9885
+ render.ok(`created ${clay(name)}`, dim(id));
9886
+ return EXIT.SUCCESS;
9887
+ });
9888
+ }
9889
+ async function runStreamPublish(name, dataRaw, opts) {
9890
+ if (!name || dataRaw === undefined) {
9891
+ render.err("Usage: claudemesh stream publish <name> <json-or-text>");
9892
+ return EXIT.INVALID_ARGS;
9893
+ }
9894
+ let data;
9895
+ try {
9896
+ data = JSON.parse(dataRaw);
9897
+ } catch {
9898
+ data = dataRaw;
9899
+ }
9900
+ return await withMesh({ meshSlug: opts.mesh ?? null }, async (client) => {
9901
+ await client.publish(name, data);
9902
+ if (opts.json)
9903
+ emitJson({ published: true, name });
9904
+ else
9905
+ render.ok(`published to ${clay(name)}`);
9906
+ return EXIT.SUCCESS;
9907
+ });
9908
+ }
9909
+ async function runStreamList(opts) {
9910
+ return await withMesh({ meshSlug: opts.mesh ?? null }, async (client) => {
9911
+ const streams = await client.listStreams();
9912
+ if (opts.json) {
9913
+ emitJson(streams);
9914
+ return EXIT.SUCCESS;
9915
+ }
9916
+ if (streams.length === 0) {
9917
+ render.info(dim("(no streams)"));
9918
+ return EXIT.SUCCESS;
9919
+ }
9920
+ render.section(`streams (${streams.length})`);
9921
+ for (const s of streams) {
9922
+ process.stdout.write(` ${clay(s.name)} ${dim(`· ${s.subscriberCount} subscriber${s.subscriberCount === 1 ? "" : "s"} · by ${s.createdBy}`)}
9923
+ `);
9924
+ }
9925
+ return EXIT.SUCCESS;
9926
+ });
9927
+ }
9928
+ async function runSqlQuery(sql, opts) {
9929
+ if (!sql) {
9930
+ render.err('Usage: claudemesh sql query "<select>"');
9931
+ return EXIT.INVALID_ARGS;
9932
+ }
9933
+ return await withMesh({ meshSlug: opts.mesh ?? null }, async (client) => {
9934
+ const result = await client.meshQuery(sql);
9935
+ if (!result) {
9936
+ render.err("query timed out");
9937
+ return EXIT.INTERNAL_ERROR;
9938
+ }
9939
+ if (opts.json) {
9940
+ emitJson(result);
9941
+ return EXIT.SUCCESS;
9942
+ }
9943
+ render.section(`${result.rowCount} row${result.rowCount === 1 ? "" : "s"}`);
9944
+ if (result.columns.length > 0) {
9945
+ process.stdout.write(` ${dim(result.columns.join(" "))}
9946
+ `);
9947
+ for (const row of result.rows) {
9948
+ process.stdout.write(` ${result.columns.map((c) => String(row[c] ?? "")).join(" ")}
9949
+ `);
9950
+ }
9951
+ }
9952
+ return EXIT.SUCCESS;
9953
+ });
9954
+ }
9955
+ async function runSqlExecute(sql, opts) {
9956
+ if (!sql) {
9957
+ render.err('Usage: claudemesh sql execute "<statement>"');
9958
+ return EXIT.INVALID_ARGS;
9959
+ }
9960
+ return await withMesh({ meshSlug: opts.mesh ?? null }, async (client) => {
9961
+ await client.meshExecute(sql);
9962
+ if (opts.json)
9963
+ emitJson({ executed: true });
9964
+ else
9965
+ render.ok("executed");
9966
+ return EXIT.SUCCESS;
9967
+ });
9968
+ }
9969
+ async function runSqlSchema(opts) {
9970
+ return await withMesh({ meshSlug: opts.mesh ?? null }, async (client) => {
9971
+ const tables = await client.meshSchema();
9972
+ if (opts.json) {
9973
+ emitJson(tables);
9974
+ return EXIT.SUCCESS;
9975
+ }
9976
+ if (tables.length === 0) {
9977
+ render.info(dim("(no tables)"));
9978
+ return EXIT.SUCCESS;
9979
+ }
9980
+ render.section(`mesh tables (${tables.length})`);
9981
+ for (const t of tables) {
9982
+ process.stdout.write(` ${bold(t.name)}
9983
+ `);
9984
+ for (const c of t.columns) {
9985
+ const nullable = c.nullable ? "" : " not null";
9986
+ process.stdout.write(` ${c.name} ${dim(c.type + nullable)}
9987
+ `);
9988
+ }
9989
+ }
9990
+ return EXIT.SUCCESS;
9991
+ });
9992
+ }
9993
+ async function runSkillList(opts) {
9994
+ return await withMesh({ meshSlug: opts.mesh ?? null }, async (client) => {
9995
+ const skills = await client.listSkills(opts.query);
9996
+ if (opts.json) {
9997
+ emitJson(skills);
9998
+ return EXIT.SUCCESS;
9999
+ }
10000
+ if (skills.length === 0) {
10001
+ render.info(dim("(no skills)"));
10002
+ return EXIT.SUCCESS;
10003
+ }
10004
+ render.section(`mesh skills (${skills.length})`);
10005
+ for (const s of skills) {
10006
+ process.stdout.write(` ${bold(s.name)} ${dim("· by " + s.author)}
10007
+ `);
10008
+ process.stdout.write(` ${s.description}
10009
+ `);
10010
+ if (s.tags.length)
10011
+ process.stdout.write(` ${dim("tags: " + s.tags.join(", "))}
10012
+ `);
10013
+ }
10014
+ return EXIT.SUCCESS;
10015
+ });
10016
+ }
10017
+ async function runSkillGet(name, opts) {
10018
+ if (!name) {
10019
+ render.err("Usage: claudemesh skill get <name>");
10020
+ return EXIT.INVALID_ARGS;
10021
+ }
10022
+ return await withMesh({ meshSlug: opts.mesh ?? null }, async (client) => {
10023
+ const skill = await client.getSkill(name);
10024
+ if (!skill) {
10025
+ render.err(`skill "${name}" not found`);
10026
+ return EXIT.NOT_FOUND;
10027
+ }
10028
+ if (opts.json) {
10029
+ emitJson(skill);
10030
+ return EXIT.SUCCESS;
10031
+ }
10032
+ render.section(skill.name);
10033
+ render.kv([
10034
+ ["author", skill.author],
10035
+ ["created", skill.createdAt],
10036
+ ["tags", skill.tags.join(", ") || dim("(none)")]
10037
+ ]);
10038
+ render.blank();
10039
+ render.info(skill.description);
10040
+ render.blank();
10041
+ process.stdout.write(skill.instructions + `
10042
+ `);
10043
+ return EXIT.SUCCESS;
10044
+ });
10045
+ }
10046
+ async function runSkillRemove(name, opts) {
10047
+ if (!name) {
10048
+ render.err("Usage: claudemesh skill remove <name>");
10049
+ return EXIT.INVALID_ARGS;
10050
+ }
10051
+ return await withMesh({ meshSlug: opts.mesh ?? null }, async (client) => {
10052
+ const removed = await client.removeSkill(name);
10053
+ if (opts.json)
10054
+ emitJson({ name, removed });
10055
+ else if (removed)
10056
+ render.ok(`removed ${bold(name)}`);
10057
+ else
10058
+ render.err(`skill "${name}" not found`);
10059
+ return removed ? EXIT.SUCCESS : EXIT.NOT_FOUND;
10060
+ });
10061
+ }
10062
+ async function runVaultList(opts) {
10063
+ return await withMesh({ meshSlug: opts.mesh ?? null }, async (client) => {
10064
+ const entries = await client.vaultList();
10065
+ if (opts.json) {
10066
+ emitJson(entries);
10067
+ return EXIT.SUCCESS;
10068
+ }
10069
+ if (!entries || entries.length === 0) {
10070
+ render.info(dim("(vault empty)"));
10071
+ return EXIT.SUCCESS;
10072
+ }
10073
+ render.section(`vault (${entries.length})`);
10074
+ for (const e of entries) {
10075
+ const k = String(e?.key ?? "?");
10076
+ const t = String(e?.entry_type ?? "");
10077
+ process.stdout.write(` ${bold(k)} ${dim(t)}
10078
+ `);
10079
+ }
10080
+ return EXIT.SUCCESS;
10081
+ });
10082
+ }
10083
+ async function runVaultDelete(key, opts) {
10084
+ if (!key) {
10085
+ render.err("Usage: claudemesh vault delete <key>");
10086
+ return EXIT.INVALID_ARGS;
10087
+ }
10088
+ return await withMesh({ meshSlug: opts.mesh ?? null }, async (client) => {
10089
+ const ok = await client.vaultDelete(key);
10090
+ if (opts.json)
10091
+ emitJson({ key, deleted: ok });
10092
+ else if (ok)
10093
+ render.ok(`deleted ${bold(key)}`);
10094
+ else
10095
+ render.err(`vault key "${key}" not found`);
10096
+ return ok ? EXIT.SUCCESS : EXIT.NOT_FOUND;
10097
+ });
10098
+ }
10099
+ async function runWatchList(opts) {
10100
+ return await withMesh({ meshSlug: opts.mesh ?? null }, async (client) => {
10101
+ const watches = await client.watchList();
10102
+ if (opts.json) {
10103
+ emitJson(watches);
10104
+ return EXIT.SUCCESS;
10105
+ }
10106
+ if (!watches || watches.length === 0) {
10107
+ render.info(dim("(no watches)"));
10108
+ return EXIT.SUCCESS;
10109
+ }
10110
+ render.section(`url watches (${watches.length})`);
10111
+ for (const w of watches) {
10112
+ const id = String(w.id ?? "?");
10113
+ const url = String(w.url ?? "");
10114
+ const label = w.label ? ` ${dim("(" + w.label + ")")}` : "";
10115
+ process.stdout.write(` ${dim(id.slice(0, 8))} ${clay(url)}${label}
10116
+ `);
10117
+ }
10118
+ return EXIT.SUCCESS;
10119
+ });
10120
+ }
10121
+ async function runUnwatch(id, opts) {
10122
+ if (!id) {
10123
+ render.err("Usage: claudemesh watch remove <id>");
10124
+ return EXIT.INVALID_ARGS;
10125
+ }
10126
+ return await withMesh({ meshSlug: opts.mesh ?? null }, async (client) => {
10127
+ const ok = await client.unwatch(id);
10128
+ if (opts.json)
10129
+ emitJson({ id, removed: ok });
10130
+ else if (ok)
10131
+ render.ok(`unwatched ${dim(id.slice(0, 8))}`);
10132
+ else
10133
+ render.err(`watch "${id}" not found`);
10134
+ return ok ? EXIT.SUCCESS : EXIT.NOT_FOUND;
10135
+ });
10136
+ }
10137
+ async function runWebhookList(opts) {
10138
+ return await withMesh({ meshSlug: opts.mesh ?? null }, async (client) => {
10139
+ const hooks = await client.listWebhooks();
10140
+ if (opts.json) {
10141
+ emitJson(hooks);
10142
+ return EXIT.SUCCESS;
10143
+ }
10144
+ if (hooks.length === 0) {
10145
+ render.info(dim("(no webhooks)"));
10146
+ return EXIT.SUCCESS;
10147
+ }
10148
+ render.section(`webhooks (${hooks.length})`);
10149
+ for (const h of hooks) {
10150
+ const dot = h.active ? "●" : dim("○");
10151
+ process.stdout.write(` ${dot} ${bold(h.name)} ${dim("· " + h.url)}
10152
+ `);
10153
+ }
10154
+ return EXIT.SUCCESS;
10155
+ });
10156
+ }
10157
+ async function runWebhookDelete(name, opts) {
10158
+ if (!name) {
10159
+ render.err("Usage: claudemesh webhook delete <name>");
10160
+ return EXIT.INVALID_ARGS;
10161
+ }
10162
+ return await withMesh({ meshSlug: opts.mesh ?? null }, async (client) => {
10163
+ const ok = await client.deleteWebhook(name);
10164
+ if (opts.json)
10165
+ emitJson({ name, deleted: ok });
10166
+ else if (ok)
10167
+ render.ok(`deleted ${bold(name)}`);
10168
+ else
10169
+ render.err(`webhook "${name}" not found`);
10170
+ return ok ? EXIT.SUCCESS : EXIT.NOT_FOUND;
10171
+ });
10172
+ }
10173
+ async function runTaskList(opts) {
10174
+ return await withMesh({ meshSlug: opts.mesh ?? null }, async (client) => {
10175
+ const tasks = await client.listTasks(opts.status, opts.assignee);
10176
+ if (opts.json) {
10177
+ emitJson(tasks);
10178
+ return EXIT.SUCCESS;
10179
+ }
10180
+ if (tasks.length === 0) {
10181
+ render.info(dim("(no tasks)"));
10182
+ return EXIT.SUCCESS;
10183
+ }
10184
+ render.section(`tasks (${tasks.length})`);
10185
+ for (const t of tasks) {
10186
+ const dot = t.status === "done" ? "●" : t.status === "claimed" ? clay("●") : dim("○");
10187
+ const assignee = t.assignee ? dim(` → ${t.assignee}`) : "";
10188
+ process.stdout.write(` ${dot} ${dim(t.id.slice(0, 8))} ${bold(t.title)}${assignee}
10189
+ `);
10190
+ }
10191
+ return EXIT.SUCCESS;
10192
+ });
10193
+ }
10194
+ async function runTaskCreate(title, opts) {
10195
+ if (!title) {
10196
+ render.err("Usage: claudemesh task create <title> [--assignee X] [--priority P]");
10197
+ return EXIT.INVALID_ARGS;
10198
+ }
10199
+ const tags = opts.tags?.split(",").map((s) => s.trim()).filter(Boolean);
10200
+ return await withMesh({ meshSlug: opts.mesh ?? null }, async (client) => {
10201
+ const id = await client.createTask(title, opts.assignee, opts.priority, tags);
10202
+ if (!id) {
10203
+ render.err("create failed");
10204
+ return EXIT.INTERNAL_ERROR;
10205
+ }
10206
+ if (opts.json)
10207
+ emitJson({ id, title });
10208
+ else
10209
+ render.ok(`created ${dim(id.slice(0, 8))}`, title);
10210
+ return EXIT.SUCCESS;
10211
+ });
10212
+ }
10213
+ async function runClockSet(speed, opts) {
10214
+ const s = parseFloat(speed);
10215
+ if (!Number.isFinite(s) || s < 0) {
10216
+ render.err("Usage: claudemesh clock set <speed>", "speed is a non-negative number, e.g. 1.0 = realtime, 0 = paused, 60 = 60× faster");
10217
+ return EXIT.INVALID_ARGS;
10218
+ }
10219
+ return await withMesh({ meshSlug: opts.mesh ?? null }, async (client) => {
10220
+ const r = await client.setClock(s);
10221
+ if (!r) {
10222
+ render.err("clock set failed");
10223
+ return EXIT.INTERNAL_ERROR;
10224
+ }
10225
+ if (opts.json)
10226
+ emitJson(r);
10227
+ else
10228
+ render.ok(`clock set to ${bold("x" + r.speed)}`);
10229
+ return EXIT.SUCCESS;
10230
+ });
10231
+ }
10232
+ async function runClockPause(opts) {
10233
+ return await withMesh({ meshSlug: opts.mesh ?? null }, async (client) => {
10234
+ const r = await client.pauseClock();
10235
+ if (!r) {
10236
+ render.err("pause failed");
10237
+ return EXIT.INTERNAL_ERROR;
10238
+ }
10239
+ if (opts.json)
10240
+ emitJson(r);
10241
+ else
10242
+ render.ok("clock paused");
10243
+ return EXIT.SUCCESS;
10244
+ });
10245
+ }
10246
+ async function runClockResume(opts) {
10247
+ return await withMesh({ meshSlug: opts.mesh ?? null }, async (client) => {
10248
+ const r = await client.resumeClock();
10249
+ if (!r) {
10250
+ render.err("resume failed");
10251
+ return EXIT.INTERNAL_ERROR;
10252
+ }
10253
+ if (opts.json)
10254
+ emitJson(r);
10255
+ else
10256
+ render.ok("clock resumed");
10257
+ return EXIT.SUCCESS;
10258
+ });
10259
+ }
10260
+ async function runMeshMcpList(opts) {
10261
+ return await withMesh({ meshSlug: opts.mesh ?? null }, async (client) => {
10262
+ const servers = await client.mcpList();
10263
+ if (opts.json) {
10264
+ emitJson(servers);
10265
+ return EXIT.SUCCESS;
10266
+ }
10267
+ if (servers.length === 0) {
10268
+ render.info(dim("(no mesh-MCP servers)"));
10269
+ return EXIT.SUCCESS;
10270
+ }
10271
+ render.section(`mesh-MCP servers (${servers.length})`);
10272
+ for (const s of servers) {
10273
+ process.stdout.write(` ${bold(s.name)} ${dim("· hosted by " + s.hostedBy)}
10274
+ `);
10275
+ process.stdout.write(` ${s.description}
10276
+ `);
10277
+ if (s.tools.length)
10278
+ process.stdout.write(` ${dim("tools: " + s.tools.map((t) => t.name).join(", "))}
10279
+ `);
10280
+ }
10281
+ return EXIT.SUCCESS;
10282
+ });
10283
+ }
10284
+ async function runMeshMcpCall(serverName, toolName, argsRaw, opts) {
10285
+ if (!serverName || !toolName) {
10286
+ render.err("Usage: claudemesh mesh-mcp call <server> <tool> [json-args]");
9569
10287
  return EXIT.INVALID_ARGS;
9570
10288
  }
9571
- const mesh = pickMesh2(opts.mesh);
9572
- if (!mesh) {
9573
- render.err("No matching mesh.");
9574
- return EXIT.NOT_FOUND;
9575
- }
9576
- const resolved = await resolvePeer(mesh, peer);
9577
- if (!resolved) {
9578
- render.err(`Peer "${peer}" not found on ${mesh}.`);
9579
- return EXIT.NOT_FOUND;
10289
+ let args = {};
10290
+ if (argsRaw) {
10291
+ try {
10292
+ args = JSON.parse(argsRaw);
10293
+ } catch {
10294
+ render.err("args must be JSON");
10295
+ return EXIT.INVALID_ARGS;
10296
+ }
9580
10297
  }
9581
- const store = readGrants();
9582
- const meshGrants = store[mesh] ?? {};
9583
- meshGrants[resolved.pubkey] = [];
9584
- store[mesh] = meshGrants;
9585
- writeGrants(store);
9586
- await syncToBroker(mesh, { [resolved.pubkey]: [] });
9587
- render.ok(`Blocked ${resolved.displayName} on ${mesh} (all capabilities revoked).`);
9588
- render.hint(`Undo with: claudemesh grant ${resolved.displayName} all --mesh ${mesh}`);
9589
- return EXIT.SUCCESS;
10298
+ return await withMesh({ meshSlug: opts.mesh ?? null }, async (client) => {
10299
+ const r = await client.mcpCall(serverName, toolName, args);
10300
+ if (r.error) {
10301
+ if (opts.json)
10302
+ emitJson({ ok: false, error: r.error });
10303
+ else
10304
+ render.err(r.error);
10305
+ return EXIT.INTERNAL_ERROR;
10306
+ }
10307
+ if (opts.json)
10308
+ emitJson({ ok: true, result: r.result });
10309
+ else
10310
+ process.stdout.write(JSON.stringify(r.result, null, 2) + `
10311
+ `);
10312
+ return EXIT.SUCCESS;
10313
+ });
9590
10314
  }
9591
- async function runGrants(opts = {}) {
9592
- const mesh = pickMesh2(opts.mesh);
9593
- if (!mesh) {
9594
- render.err("No matching mesh.");
9595
- return EXIT.NOT_FOUND;
9596
- }
9597
- const store = readGrants();
9598
- const meshGrants = store[mesh] ?? {};
9599
- if (opts.json) {
9600
- console.log(JSON.stringify({ schema_version: "1.0", mesh, grants: meshGrants }, null, 2));
10315
+ async function runMeshMcpCatalog(opts) {
10316
+ return await withMesh({ meshSlug: opts.mesh ?? null }, async (client) => {
10317
+ const cat = await client.mcpCatalog();
10318
+ if (opts.json) {
10319
+ emitJson(cat);
10320
+ return EXIT.SUCCESS;
10321
+ }
10322
+ if (!cat || cat.length === 0) {
10323
+ render.info(dim("(catalog empty)"));
10324
+ return EXIT.SUCCESS;
10325
+ }
10326
+ render.section(`mesh-MCP catalog (${cat.length})`);
10327
+ for (const c of cat) {
10328
+ process.stdout.write(` ${bold(String(c.name ?? "?"))} ${dim(String(c.status ?? ""))}
10329
+ `);
10330
+ if (c.description)
10331
+ process.stdout.write(` ${String(c.description)}
10332
+ `);
10333
+ }
9601
10334
  return EXIT.SUCCESS;
9602
- }
9603
- render.section(`grants on ${mesh}`);
9604
- const peerPubkeys = Object.keys(meshGrants);
9605
- if (peerPubkeys.length === 0) {
9606
- render.info("(no overrides all peers use default caps: " + DEFAULT_CAPS.join(", ") + ")");
10335
+ });
10336
+ }
10337
+ async function runFileList(opts) {
10338
+ return await withMesh({ meshSlug: opts.mesh ?? null }, async (client) => {
10339
+ const files = await client.listFiles(opts.query);
10340
+ if (opts.json) {
10341
+ emitJson(files);
10342
+ return EXIT.SUCCESS;
10343
+ }
10344
+ if (files.length === 0) {
10345
+ render.info(dim("(no files)"));
10346
+ return EXIT.SUCCESS;
10347
+ }
10348
+ render.section(`mesh files (${files.length})`);
10349
+ for (const f of files) {
10350
+ const sizeKb = (f.size / 1024).toFixed(1);
10351
+ process.stdout.write(` ${bold(f.name)} ${dim(`· ${sizeKb} KB · by ${f.uploadedBy}`)}
10352
+ `);
10353
+ if (f.tags.length)
10354
+ process.stdout.write(` ${dim("tags: " + f.tags.join(", "))}
10355
+ `);
10356
+ }
9607
10357
  return EXIT.SUCCESS;
10358
+ });
10359
+ }
10360
+ async function runFileStatus(id, opts) {
10361
+ if (!id) {
10362
+ render.err("Usage: claudemesh file status <file-id>");
10363
+ return EXIT.INVALID_ARGS;
9608
10364
  }
9609
- await withMesh({ meshSlug: mesh }, async (client) => {
9610
- const peers = await client.listPeers();
9611
- const byPk = new Map(peers.map((p) => [p.pubkey, p.displayName]));
9612
- for (const [pk, caps] of Object.entries(meshGrants)) {
9613
- const name = byPk.get(pk) ?? `${pk.slice(0, 10)}…`;
9614
- render.kv([[name, caps.length ? caps.join(", ") : "(blocked)"]]);
10365
+ return await withMesh({ meshSlug: opts.mesh ?? null }, async (client) => {
10366
+ const accessors = await client.fileStatus(id);
10367
+ if (opts.json) {
10368
+ emitJson(accessors);
10369
+ return EXIT.SUCCESS;
10370
+ }
10371
+ if (accessors.length === 0) {
10372
+ render.info(dim("(no accesses recorded)"));
10373
+ return EXIT.SUCCESS;
9615
10374
  }
10375
+ render.section(`accesses for ${id.slice(0, 8)}`);
10376
+ for (const a of accessors)
10377
+ process.stdout.write(` ${bold(a.peerName)} ${dim("· " + a.accessedAt)}
10378
+ `);
10379
+ return EXIT.SUCCESS;
9616
10380
  });
9617
- return EXIT.SUCCESS;
9618
10381
  }
9619
- function isAllowed(meshSlug, peerPubkey, cap) {
9620
- const store = readGrants();
9621
- const entry = store[meshSlug]?.[peerPubkey];
9622
- if (entry === undefined)
9623
- return DEFAULT_CAPS.includes(cap);
9624
- return entry.includes(cap);
10382
+ async function runFileDelete(id, opts) {
10383
+ if (!id) {
10384
+ render.err("Usage: claudemesh file delete <file-id>");
10385
+ return EXIT.INVALID_ARGS;
10386
+ }
10387
+ return await withMesh({ meshSlug: opts.mesh ?? null }, async (client) => {
10388
+ await client.deleteFile(id);
10389
+ if (opts.json)
10390
+ emitJson({ id, deleted: true });
10391
+ else
10392
+ render.ok(`deleted ${dim(id.slice(0, 8))}`);
10393
+ return EXIT.SUCCESS;
10394
+ });
9625
10395
  }
9626
- var BROKER_HTTP7, ALL_CAPS, DEFAULT_CAPS, GRANT_FILE;
9627
- var init_grants = __esm(() => {
9628
- init_facade();
10396
+ var init_platform_actions = __esm(() => {
9629
10397
  init_connect();
9630
10398
  init_render();
10399
+ init_styles();
9631
10400
  init_exit_codes();
9632
- init_facade6();
9633
- init_facade3();
9634
- init_urls();
9635
- BROKER_HTTP7 = URLS.BROKER.replace("wss://", "https://").replace("ws://", "http://").replace("/ws", "");
9636
- ALL_CAPS = ["read", "dm", "broadcast", "state-read", "state-write", "file-read"];
9637
- DEFAULT_CAPS = ["read", "dm", "broadcast", "state-read"];
9638
- GRANT_FILE = join11(homedir10(), ".claudemesh", "grants.json");
9639
10401
  });
9640
10402
 
9641
10403
  // src/mcp/tools/definitions.ts
@@ -13299,41 +14061,65 @@ Mesh
13299
14061
  claudemesh delete [slug] delete a mesh (alias: rm)
13300
14062
  claudemesh rename <slug> <name> rename a mesh
13301
14063
  claudemesh share [email] share mesh (invite link / send email)
13302
- claudemesh disconnect <peer> soft disconnect (peer auto-reconnects)
13303
- claudemesh kick <peer> end session (peer must manually rejoin)
13304
- claudemesh kick --stale 30m kick peers idle > duration
13305
- claudemesh kick --all kick everyone except yourself
13306
- claudemesh ban <peer> kick + permanently revoke (can't rejoin)
13307
- claudemesh unban <peer> lift a ban
13308
- claudemesh bans list banned members
13309
-
13310
- Messaging
13311
- claudemesh peers see who's online
13312
- claudemesh send <to> <msg> send a message
13313
- claudemesh inbox drain pending messages
13314
- claudemesh msg-status <id> check delivery status
14064
+
14065
+ Peer (resource form, recommended)
14066
+ claudemesh peer list see who's online (alias: peers)
14067
+ claudemesh peer kick <p> end session (alias: kick)
14068
+ claudemesh peer disconnect <p> soft disconnect (alias: disconnect)
14069
+ claudemesh peer ban <p> ban + revoke (alias: ban)
14070
+ claudemesh peer unban <p> lift a ban (alias: unban)
14071
+ claudemesh peer bans list banned members (alias: bans)
14072
+ claudemesh peer verify [p] safety numbers (alias: verify)
14073
+
14074
+ Message (resource form)
14075
+ claudemesh message send <to> <m> send a message (alias: send)
14076
+ claudemesh message inbox drain pending (alias: inbox)
14077
+ claudemesh message status <id> delivery status (alias: msg-status)
14078
+
14079
+ Memory (resource form)
14080
+ claudemesh memory remember <txt> store a memory (alias: remember)
14081
+ claudemesh memory recall <q> search memories (alias: recall)
14082
+ claudemesh memory forget <id> remove a memory (alias: forget)
14083
+
14084
+ Profile / presence (resource form)
14085
+ claudemesh profile view or edit profile
14086
+ claudemesh profile summary <txt> broadcast summary (alias: summary)
14087
+ claudemesh profile visible y|n toggle visibility (alias: visible)
14088
+ claudemesh profile status set X set status idle/working/dnd (alias: status set)
14089
+ claudemesh group join @<name> join a group (--role X)
14090
+ claudemesh group leave @<name> leave a group
14091
+
14092
+ Schedule (resource form)
14093
+ claudemesh schedule msg <m> one-shot or recurring (alias: remind)
14094
+ claudemesh schedule list list pending
14095
+ claudemesh schedule cancel <id> remove a scheduled item
14096
+
14097
+ State / mesh introspection
13315
14098
  claudemesh state get|set|list shared state
13316
- claudemesh remember <text> store a memory
13317
- claudemesh recall <query> search memories
13318
- claudemesh forget <id> remove a memory
13319
- claudemesh remind ... schedule a reminder
13320
- claudemesh profile view or edit your profile
13321
14099
  claudemesh info mesh overview
13322
14100
  claudemesh stats per-peer activity counters
13323
- claudemesh clock mesh logical clock state
13324
14101
  claudemesh ping diagnostic round-trip
13325
14102
 
13326
- Identity / presence
13327
- claudemesh status set <state> set peer status (idle | working | dnd)
13328
- claudemesh summary <text> broadcast 1-2 sentence work summary
13329
- claudemesh visible <true|false> toggle peer visibility
13330
- claudemesh group join @<name> join a group (--role X optional)
13331
- claudemesh group leave @<name> leave a group
13332
-
13333
14103
  Tasks
14104
+ claudemesh task create <title> create a new task [--assignee --priority --tags]
14105
+ claudemesh task list list tasks [--status --assignee]
13334
14106
  claudemesh task claim <id> claim an unclaimed task
13335
14107
  claudemesh task complete <id> mark task done [result]
13336
14108
 
14109
+ Platform
14110
+ claudemesh vector store|search|delete|collections embedding store
14111
+ claudemesh graph query|execute "<cypher>" graph operations
14112
+ claudemesh context share|get|list work-context summaries
14113
+ claudemesh stream create|publish|list pub/sub event bus
14114
+ claudemesh sql query|execute|schema per-mesh SQL
14115
+ claudemesh skill list|get|remove mesh-published skills
14116
+ claudemesh vault list|delete encrypted secrets
14117
+ claudemesh watch list|remove URL change watchers
14118
+ claudemesh webhook list|delete outbound HTTP triggers
14119
+ claudemesh file list|status|delete shared mesh files
14120
+ claudemesh mesh-mcp list|call|catalog deployed mesh-MCP servers
14121
+ claudemesh clock set|pause|resume mesh logical clock
14122
+
13337
14123
  Auth
13338
14124
  claudemesh login sign in (browser or paste token)
13339
14125
  claudemesh register create account + sign in
@@ -13521,12 +14307,12 @@ async function main() {
13521
14307
  }
13522
14308
  case "remember": {
13523
14309
  const { remember: remember2 } = await Promise.resolve().then(() => (init_remember(), exports_remember));
13524
- process.exit(await remember2(positionals.join(" "), { tags: flags.tags, json: !!flags.json }));
14310
+ process.exit(await remember2(positionals.join(" "), { mesh: flags.mesh, tags: flags.tags, json: !!flags.json }));
13525
14311
  break;
13526
14312
  }
13527
14313
  case "recall": {
13528
14314
  const { recall: recall2 } = await Promise.resolve().then(() => (init_recall(), exports_recall));
13529
- process.exit(await recall2(positionals.join(" "), { json: !!flags.json }));
14315
+ process.exit(await recall2(positionals.join(" "), { mesh: flags.mesh, json: !!flags.json }));
13530
14316
  break;
13531
14317
  }
13532
14318
  case "forget": {
@@ -13539,11 +14325,6 @@ async function main() {
13539
14325
  await runRemind2({ mesh: flags.mesh }, positionals);
13540
14326
  break;
13541
14327
  }
13542
- case "profile": {
13543
- const { runProfile: runProfile2 } = await Promise.resolve().then(() => (init_profile(), exports_profile));
13544
- await runProfile2(flags);
13545
- break;
13546
- }
13547
14328
  case "summary": {
13548
14329
  const { runSummary: runSummary2 } = await Promise.resolve().then(() => (init_broker_actions(), exports_broker_actions));
13549
14330
  process.exit(await runSummary2(positionals.join(" "), { mesh: flags.mesh, json: !!flags.json }));
@@ -13573,11 +14354,6 @@ async function main() {
13573
14354
  process.exit(await runMsgStatus2(positionals[0], { mesh: flags.mesh, json: !!flags.json }));
13574
14355
  break;
13575
14356
  }
13576
- case "clock": {
13577
- const { runClock: runClock2 } = await Promise.resolve().then(() => (init_broker_actions(), exports_broker_actions));
13578
- process.exit(await runClock2({ mesh: flags.mesh, json: !!flags.json }));
13579
- break;
13580
- }
13581
14357
  case "stats": {
13582
14358
  const { runStats: runStats2 } = await Promise.resolve().then(() => (init_broker_actions(), exports_broker_actions));
13583
14359
  process.exit(await runStats2({ mesh: flags.mesh, json: !!flags.json }));
@@ -13588,20 +14364,6 @@ async function main() {
13588
14364
  process.exit(await runPing2({ mesh: flags.mesh, json: !!flags.json }));
13589
14365
  break;
13590
14366
  }
13591
- case "task": {
13592
- const sub = positionals[0];
13593
- if (sub === "claim") {
13594
- const { runTaskClaim: runTaskClaim2 } = await Promise.resolve().then(() => (init_broker_actions(), exports_broker_actions));
13595
- process.exit(await runTaskClaim2(positionals[1], { mesh: flags.mesh, json: !!flags.json }));
13596
- } else if (sub === "complete") {
13597
- const { runTaskComplete: runTaskComplete2 } = await Promise.resolve().then(() => (init_broker_actions(), exports_broker_actions));
13598
- process.exit(await runTaskComplete2(positionals[1], positionals.slice(2).join(" ") || undefined, { mesh: flags.mesh, json: !!flags.json }));
13599
- } else {
13600
- console.error("Usage: claudemesh task <claim|complete> <id> [result]");
13601
- process.exit(EXIT.INVALID_ARGS);
13602
- }
13603
- break;
13604
- }
13605
14367
  case "login": {
13606
14368
  const { login: login2 } = await Promise.resolve().then(() => (init_login(), exports_login));
13607
14369
  process.exit(await login2());
@@ -13713,6 +14475,340 @@ async function main() {
13713
14475
  process.exit(await runGrants2({ mesh: flags.mesh, json: !!flags.json }));
13714
14476
  break;
13715
14477
  }
14478
+ case "peer": {
14479
+ const sub = positionals[0];
14480
+ const f = { mesh: flags.mesh, json: flags.json };
14481
+ const id = positionals[1] ?? "";
14482
+ if (sub === "list") {
14483
+ const { runPeers: runPeers2 } = await Promise.resolve().then(() => (init_peers(), exports_peers));
14484
+ await runPeers2(f);
14485
+ } else if (sub === "kick") {
14486
+ const { runKick: runKick2 } = await Promise.resolve().then(() => (init_kick(), exports_kick));
14487
+ process.exit(await runKick2(id, { mesh: flags.mesh, stale: flags.stale, all: !!flags.all }));
14488
+ } else if (sub === "disconnect") {
14489
+ const { runDisconnect: runDisconnect2 } = await Promise.resolve().then(() => (init_kick(), exports_kick));
14490
+ process.exit(await runDisconnect2(id, { mesh: flags.mesh, stale: flags.stale, all: !!flags.all }));
14491
+ } else if (sub === "ban") {
14492
+ const { runBan: runBan2 } = await Promise.resolve().then(() => (init_ban(), exports_ban));
14493
+ process.exit(await runBan2(id, { mesh: flags.mesh }));
14494
+ } else if (sub === "unban") {
14495
+ const { runUnban: runUnban2 } = await Promise.resolve().then(() => (init_ban(), exports_ban));
14496
+ process.exit(await runUnban2(id, { mesh: flags.mesh }));
14497
+ } else if (sub === "bans") {
14498
+ const { runBans: runBans2 } = await Promise.resolve().then(() => (init_ban(), exports_ban));
14499
+ process.exit(await runBans2({ mesh: flags.mesh, json: !!flags.json }));
14500
+ } else if (sub === "verify") {
14501
+ const { runVerify: runVerify2 } = await Promise.resolve().then(() => (init_verify(), exports_verify));
14502
+ process.exit(await runVerify2(id || undefined, { mesh: flags.mesh, json: !!flags.json }));
14503
+ } else {
14504
+ console.error("Usage: claudemesh peer <list|kick|disconnect|ban|unban|bans|verify>");
14505
+ process.exit(EXIT.INVALID_ARGS);
14506
+ }
14507
+ break;
14508
+ }
14509
+ case "message": {
14510
+ const sub = positionals[0];
14511
+ if (sub === "send") {
14512
+ const { runSend: runSend2 } = await Promise.resolve().then(() => (init_send(), exports_send));
14513
+ await runSend2({ mesh: flags.mesh, priority: flags.priority, json: !!flags.json }, positionals[1] ?? "", positionals.slice(2).join(" "));
14514
+ } else if (sub === "inbox") {
14515
+ const { runInbox: runInbox2 } = await Promise.resolve().then(() => (init_inbox(), exports_inbox));
14516
+ await runInbox2({ json: !!flags.json });
14517
+ } else if (sub === "status") {
14518
+ const { runMsgStatus: runMsgStatus2 } = await Promise.resolve().then(() => (init_broker_actions(), exports_broker_actions));
14519
+ process.exit(await runMsgStatus2(positionals[1], { mesh: flags.mesh, json: !!flags.json }));
14520
+ } else {
14521
+ console.error("Usage: claudemesh message <send|inbox|status>");
14522
+ process.exit(EXIT.INVALID_ARGS);
14523
+ }
14524
+ break;
14525
+ }
14526
+ case "memory": {
14527
+ const sub = positionals[0];
14528
+ const f = { mesh: flags.mesh, json: !!flags.json };
14529
+ if (sub === "remember") {
14530
+ const { remember: remember2 } = await Promise.resolve().then(() => (init_remember(), exports_remember));
14531
+ process.exit(await remember2(positionals.slice(1).join(" "), { ...f, tags: flags.tags }));
14532
+ } else if (sub === "recall") {
14533
+ const { recall: recall2 } = await Promise.resolve().then(() => (init_recall(), exports_recall));
14534
+ process.exit(await recall2(positionals.slice(1).join(" "), f));
14535
+ } else if (sub === "forget") {
14536
+ const { runForget: runForget2 } = await Promise.resolve().then(() => (init_broker_actions(), exports_broker_actions));
14537
+ process.exit(await runForget2(positionals[1], f));
14538
+ } else {
14539
+ console.error("Usage: claudemesh memory <remember|recall|forget>");
14540
+ process.exit(EXIT.INVALID_ARGS);
14541
+ }
14542
+ break;
14543
+ }
14544
+ case "profile": {
14545
+ const sub = positionals[0];
14546
+ if (!sub) {
14547
+ const { runProfile: runProfile2 } = await Promise.resolve().then(() => (init_profile(), exports_profile));
14548
+ await runProfile2(flags);
14549
+ } else if (sub === "summary") {
14550
+ const { runSummary: runSummary2 } = await Promise.resolve().then(() => (init_broker_actions(), exports_broker_actions));
14551
+ process.exit(await runSummary2(positionals.slice(1).join(" "), { mesh: flags.mesh, json: !!flags.json }));
14552
+ } else if (sub === "visible") {
14553
+ const { runVisible: runVisible2 } = await Promise.resolve().then(() => (init_broker_actions(), exports_broker_actions));
14554
+ process.exit(await runVisible2(positionals[1], { mesh: flags.mesh, json: !!flags.json }));
14555
+ } else if (sub === "status") {
14556
+ if (positionals[1] === "set") {
14557
+ const { runStatusSet: runStatusSet2 } = await Promise.resolve().then(() => (init_broker_actions(), exports_broker_actions));
14558
+ process.exit(await runStatusSet2(positionals[2] ?? "", { mesh: flags.mesh, json: !!flags.json }));
14559
+ } else {
14560
+ const { runStatus: runStatus2 } = await Promise.resolve().then(() => (init_status(), exports_status));
14561
+ await runStatus2();
14562
+ }
14563
+ } else {
14564
+ console.error("Usage: claudemesh profile [summary|visible|status]");
14565
+ process.exit(EXIT.INVALID_ARGS);
14566
+ }
14567
+ break;
14568
+ }
14569
+ case "schedule": {
14570
+ const sub = positionals[0];
14571
+ if (sub === "msg" || sub === "remind" || sub === undefined || sub === "list" || sub === "cancel") {
14572
+ const { runRemind: runRemind2 } = await Promise.resolve().then(() => (init_remind(), exports_remind));
14573
+ const remindPositionals = sub === "msg" ? positionals.slice(1) : sub === "remind" ? positionals.slice(1) : positionals;
14574
+ await runRemind2({ mesh: flags.mesh, in: flags.in, at: flags.at, cron: flags.cron, to: flags.to, json: !!flags.json }, remindPositionals);
14575
+ } else if (sub === "webhook" || sub === "tool") {
14576
+ console.error(` schedule ${sub} arrives in a later release — broker primitive not yet shipped`);
14577
+ process.exit(EXIT.INVALID_ARGS);
14578
+ } else {
14579
+ console.error("Usage: claudemesh schedule <msg|list|cancel>");
14580
+ process.exit(EXIT.INVALID_ARGS);
14581
+ }
14582
+ break;
14583
+ }
14584
+ case "vector": {
14585
+ const sub = positionals[0];
14586
+ const f = { mesh: flags.mesh, json: !!flags.json };
14587
+ if (sub === "store") {
14588
+ const { runVectorStore: runVectorStore2 } = await Promise.resolve().then(() => (init_platform_actions(), exports_platform_actions));
14589
+ process.exit(await runVectorStore2(positionals[1] ?? "", positionals.slice(2).join(" "), { ...f, metadata: flags.metadata }));
14590
+ } else if (sub === "search") {
14591
+ const { runVectorSearch: runVectorSearch2 } = await Promise.resolve().then(() => (init_platform_actions(), exports_platform_actions));
14592
+ process.exit(await runVectorSearch2(positionals[1] ?? "", positionals.slice(2).join(" "), { ...f, limit: flags.limit }));
14593
+ } else if (sub === "delete") {
14594
+ const { runVectorDelete: runVectorDelete2 } = await Promise.resolve().then(() => (init_platform_actions(), exports_platform_actions));
14595
+ process.exit(await runVectorDelete2(positionals[1] ?? "", positionals[2] ?? "", f));
14596
+ } else if (sub === "collections") {
14597
+ const { runVectorCollections: runVectorCollections2 } = await Promise.resolve().then(() => (init_platform_actions(), exports_platform_actions));
14598
+ process.exit(await runVectorCollections2(f));
14599
+ } else {
14600
+ console.error("Usage: claudemesh vector <store|search|delete|collections>");
14601
+ process.exit(EXIT.INVALID_ARGS);
14602
+ }
14603
+ break;
14604
+ }
14605
+ case "graph": {
14606
+ const sub = positionals[0];
14607
+ const f = { mesh: flags.mesh, json: !!flags.json };
14608
+ if (sub === "query") {
14609
+ const { runGraphQuery: runGraphQuery2 } = await Promise.resolve().then(() => (init_platform_actions(), exports_platform_actions));
14610
+ process.exit(await runGraphQuery2(positionals.slice(1).join(" "), f));
14611
+ } else if (sub === "execute") {
14612
+ const { runGraphExecute: runGraphExecute2 } = await Promise.resolve().then(() => (init_platform_actions(), exports_platform_actions));
14613
+ process.exit(await runGraphExecute2(positionals.slice(1).join(" "), f));
14614
+ } else {
14615
+ console.error('Usage: claudemesh graph <query|execute> "<cypher>"');
14616
+ process.exit(EXIT.INVALID_ARGS);
14617
+ }
14618
+ break;
14619
+ }
14620
+ case "context": {
14621
+ const sub = positionals[0];
14622
+ const f = { mesh: flags.mesh, json: !!flags.json };
14623
+ if (sub === "share") {
14624
+ const { runContextShare: runContextShare2 } = await Promise.resolve().then(() => (init_platform_actions(), exports_platform_actions));
14625
+ process.exit(await runContextShare2(positionals.slice(1).join(" "), { ...f, files: flags.files, findings: flags.findings, tags: flags.tags }));
14626
+ } else if (sub === "get") {
14627
+ const { runContextGet: runContextGet2 } = await Promise.resolve().then(() => (init_platform_actions(), exports_platform_actions));
14628
+ process.exit(await runContextGet2(positionals.slice(1).join(" "), f));
14629
+ } else if (sub === "list") {
14630
+ const { runContextList: runContextList2 } = await Promise.resolve().then(() => (init_platform_actions(), exports_platform_actions));
14631
+ process.exit(await runContextList2(f));
14632
+ } else {
14633
+ console.error("Usage: claudemesh context <share|get|list>");
14634
+ process.exit(EXIT.INVALID_ARGS);
14635
+ }
14636
+ break;
14637
+ }
14638
+ case "stream": {
14639
+ const sub = positionals[0];
14640
+ const f = { mesh: flags.mesh, json: !!flags.json };
14641
+ if (sub === "create") {
14642
+ const { runStreamCreate: runStreamCreate2 } = await Promise.resolve().then(() => (init_platform_actions(), exports_platform_actions));
14643
+ process.exit(await runStreamCreate2(positionals[1] ?? "", f));
14644
+ } else if (sub === "publish") {
14645
+ const { runStreamPublish: runStreamPublish2 } = await Promise.resolve().then(() => (init_platform_actions(), exports_platform_actions));
14646
+ process.exit(await runStreamPublish2(positionals[1] ?? "", positionals.slice(2).join(" "), f));
14647
+ } else if (sub === "list") {
14648
+ const { runStreamList: runStreamList2 } = await Promise.resolve().then(() => (init_platform_actions(), exports_platform_actions));
14649
+ process.exit(await runStreamList2(f));
14650
+ } else {
14651
+ console.error("Usage: claudemesh stream <create|publish|list>");
14652
+ process.exit(EXIT.INVALID_ARGS);
14653
+ }
14654
+ break;
14655
+ }
14656
+ case "sql": {
14657
+ const sub = positionals[0];
14658
+ const f = { mesh: flags.mesh, json: !!flags.json };
14659
+ if (sub === "query") {
14660
+ const { runSqlQuery: runSqlQuery2 } = await Promise.resolve().then(() => (init_platform_actions(), exports_platform_actions));
14661
+ process.exit(await runSqlQuery2(positionals.slice(1).join(" "), f));
14662
+ } else if (sub === "execute") {
14663
+ const { runSqlExecute: runSqlExecute2 } = await Promise.resolve().then(() => (init_platform_actions(), exports_platform_actions));
14664
+ process.exit(await runSqlExecute2(positionals.slice(1).join(" "), f));
14665
+ } else if (sub === "schema") {
14666
+ const { runSqlSchema: runSqlSchema2 } = await Promise.resolve().then(() => (init_platform_actions(), exports_platform_actions));
14667
+ process.exit(await runSqlSchema2(f));
14668
+ } else {
14669
+ console.error("Usage: claudemesh sql <query|execute|schema>");
14670
+ process.exit(EXIT.INVALID_ARGS);
14671
+ }
14672
+ break;
14673
+ }
14674
+ case "skill": {
14675
+ const sub = positionals[0];
14676
+ const f = { mesh: flags.mesh, json: !!flags.json };
14677
+ if (sub === "list") {
14678
+ const { runSkillList: runSkillList2 } = await Promise.resolve().then(() => (init_platform_actions(), exports_platform_actions));
14679
+ process.exit(await runSkillList2({ ...f, query: positionals[1] }));
14680
+ } else if (sub === "get") {
14681
+ const { runSkillGet: runSkillGet2 } = await Promise.resolve().then(() => (init_platform_actions(), exports_platform_actions));
14682
+ process.exit(await runSkillGet2(positionals[1] ?? "", f));
14683
+ } else if (sub === "remove") {
14684
+ const { runSkillRemove: runSkillRemove2 } = await Promise.resolve().then(() => (init_platform_actions(), exports_platform_actions));
14685
+ process.exit(await runSkillRemove2(positionals[1] ?? "", f));
14686
+ } else {
14687
+ console.error("Usage: claudemesh skill <list|get|remove>");
14688
+ process.exit(EXIT.INVALID_ARGS);
14689
+ }
14690
+ break;
14691
+ }
14692
+ case "vault": {
14693
+ const sub = positionals[0];
14694
+ const f = { mesh: flags.mesh, json: !!flags.json };
14695
+ if (sub === "list") {
14696
+ const { runVaultList: runVaultList2 } = await Promise.resolve().then(() => (init_platform_actions(), exports_platform_actions));
14697
+ process.exit(await runVaultList2(f));
14698
+ } else if (sub === "delete") {
14699
+ const { runVaultDelete: runVaultDelete2 } = await Promise.resolve().then(() => (init_platform_actions(), exports_platform_actions));
14700
+ process.exit(await runVaultDelete2(positionals[1] ?? "", f));
14701
+ } else {
14702
+ console.error("Usage: claudemesh vault <list|delete> (set/get currently via MCP — needs crypto)");
14703
+ process.exit(EXIT.INVALID_ARGS);
14704
+ }
14705
+ break;
14706
+ }
14707
+ case "watch": {
14708
+ const sub = positionals[0];
14709
+ const f = { mesh: flags.mesh, json: !!flags.json };
14710
+ if (sub === "list") {
14711
+ const { runWatchList: runWatchList2 } = await Promise.resolve().then(() => (init_platform_actions(), exports_platform_actions));
14712
+ process.exit(await runWatchList2(f));
14713
+ } else if (sub === "remove") {
14714
+ const { runUnwatch: runUnwatch2 } = await Promise.resolve().then(() => (init_platform_actions(), exports_platform_actions));
14715
+ process.exit(await runUnwatch2(positionals[1] ?? "", f));
14716
+ } else {
14717
+ console.error("Usage: claudemesh watch <list|remove>");
14718
+ process.exit(EXIT.INVALID_ARGS);
14719
+ }
14720
+ break;
14721
+ }
14722
+ case "webhook": {
14723
+ const sub = positionals[0];
14724
+ const f = { mesh: flags.mesh, json: !!flags.json };
14725
+ if (sub === "list") {
14726
+ const { runWebhookList: runWebhookList2 } = await Promise.resolve().then(() => (init_platform_actions(), exports_platform_actions));
14727
+ process.exit(await runWebhookList2(f));
14728
+ } else if (sub === "delete") {
14729
+ const { runWebhookDelete: runWebhookDelete2 } = await Promise.resolve().then(() => (init_platform_actions(), exports_platform_actions));
14730
+ process.exit(await runWebhookDelete2(positionals[1] ?? "", f));
14731
+ } else {
14732
+ console.error("Usage: claudemesh webhook <list|delete>");
14733
+ process.exit(EXIT.INVALID_ARGS);
14734
+ }
14735
+ break;
14736
+ }
14737
+ case "file": {
14738
+ const sub = positionals[0];
14739
+ const f = { mesh: flags.mesh, json: !!flags.json };
14740
+ if (sub === "list") {
14741
+ const { runFileList: runFileList2 } = await Promise.resolve().then(() => (init_platform_actions(), exports_platform_actions));
14742
+ process.exit(await runFileList2({ ...f, query: positionals[1] }));
14743
+ } else if (sub === "status") {
14744
+ const { runFileStatus: runFileStatus2 } = await Promise.resolve().then(() => (init_platform_actions(), exports_platform_actions));
14745
+ process.exit(await runFileStatus2(positionals[1] ?? "", f));
14746
+ } else if (sub === "delete") {
14747
+ const { runFileDelete: runFileDelete2 } = await Promise.resolve().then(() => (init_platform_actions(), exports_platform_actions));
14748
+ process.exit(await runFileDelete2(positionals[1] ?? "", f));
14749
+ } else {
14750
+ console.error("Usage: claudemesh file <list|status|delete>");
14751
+ process.exit(EXIT.INVALID_ARGS);
14752
+ }
14753
+ break;
14754
+ }
14755
+ case "mesh-mcp": {
14756
+ const sub = positionals[0];
14757
+ const f = { mesh: flags.mesh, json: !!flags.json };
14758
+ if (sub === "list") {
14759
+ const { runMeshMcpList: runMeshMcpList2 } = await Promise.resolve().then(() => (init_platform_actions(), exports_platform_actions));
14760
+ process.exit(await runMeshMcpList2(f));
14761
+ } else if (sub === "call") {
14762
+ const { runMeshMcpCall: runMeshMcpCall2 } = await Promise.resolve().then(() => (init_platform_actions(), exports_platform_actions));
14763
+ process.exit(await runMeshMcpCall2(positionals[1] ?? "", positionals[2] ?? "", positionals.slice(3).join(" "), f));
14764
+ } else if (sub === "catalog") {
14765
+ const { runMeshMcpCatalog: runMeshMcpCatalog2 } = await Promise.resolve().then(() => (init_platform_actions(), exports_platform_actions));
14766
+ process.exit(await runMeshMcpCatalog2(f));
14767
+ } else {
14768
+ console.error("Usage: claudemesh mesh-mcp <list|call|catalog>");
14769
+ process.exit(EXIT.INVALID_ARGS);
14770
+ }
14771
+ break;
14772
+ }
14773
+ case "clock": {
14774
+ const sub = positionals[0];
14775
+ const f = { mesh: flags.mesh, json: !!flags.json };
14776
+ if (sub === "set") {
14777
+ const { runClockSet: runClockSet2 } = await Promise.resolve().then(() => (init_platform_actions(), exports_platform_actions));
14778
+ process.exit(await runClockSet2(positionals[1] ?? "", f));
14779
+ } else if (sub === "pause") {
14780
+ const { runClockPause: runClockPause2 } = await Promise.resolve().then(() => (init_platform_actions(), exports_platform_actions));
14781
+ process.exit(await runClockPause2(f));
14782
+ } else if (sub === "resume") {
14783
+ const { runClockResume: runClockResume2 } = await Promise.resolve().then(() => (init_platform_actions(), exports_platform_actions));
14784
+ process.exit(await runClockResume2(f));
14785
+ } else {
14786
+ const { runClock: runClock2 } = await Promise.resolve().then(() => (init_broker_actions(), exports_broker_actions));
14787
+ process.exit(await runClock2(f));
14788
+ }
14789
+ break;
14790
+ }
14791
+ case "task": {
14792
+ const sub = positionals[0];
14793
+ const f = { mesh: flags.mesh, json: !!flags.json };
14794
+ if (sub === "claim") {
14795
+ const { runTaskClaim: runTaskClaim2 } = await Promise.resolve().then(() => (init_broker_actions(), exports_broker_actions));
14796
+ process.exit(await runTaskClaim2(positionals[1], f));
14797
+ } else if (sub === "complete") {
14798
+ const { runTaskComplete: runTaskComplete2 } = await Promise.resolve().then(() => (init_broker_actions(), exports_broker_actions));
14799
+ process.exit(await runTaskComplete2(positionals[1], positionals.slice(2).join(" ") || undefined, f));
14800
+ } else if (sub === "list") {
14801
+ const { runTaskList: runTaskList2 } = await Promise.resolve().then(() => (init_platform_actions(), exports_platform_actions));
14802
+ process.exit(await runTaskList2({ ...f, status: flags.status, assignee: flags.assignee }));
14803
+ } else if (sub === "create") {
14804
+ const { runTaskCreate: runTaskCreate2 } = await Promise.resolve().then(() => (init_platform_actions(), exports_platform_actions));
14805
+ process.exit(await runTaskCreate2(positionals.slice(1).join(" "), { ...f, assignee: flags.assignee, priority: flags.priority, tags: flags.tags }));
14806
+ } else {
14807
+ console.error("Usage: claudemesh task <create|list|claim|complete>");
14808
+ process.exit(EXIT.INVALID_ARGS);
14809
+ }
14810
+ break;
14811
+ }
13716
14812
  case "mcp": {
13717
14813
  const { runMcp: runMcp2 } = await Promise.resolve().then(() => (init_mcp(), exports_mcp));
13718
14814
  await runMcp2();
@@ -13740,4 +14836,4 @@ main().catch((err) => {
13740
14836
  process.exit(EXIT.INTERNAL_ERROR);
13741
14837
  });
13742
14838
 
13743
- //# debugId=E126BD4968D2FCDF64756E2164756E21
14839
+ //# debugId=4E4265490A3D56F164756E2164756E21