claudemesh-cli 1.0.0-alpha.31 → 1.0.0-alpha.32

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.0.0-alpha.31", env;
91
+ var URLS, VERSION = "1.0.0-alpha.32", env;
92
92
  var init_urls = __esm(() => {
93
93
  URLS = {
94
94
  BROKER: process.env.CLAUDEMESH_BROKER_URL ?? "wss://ic.claudemesh.com/ws",
@@ -6233,42 +6233,40 @@ var exports_inbox = {};
6233
6233
  __export(exports_inbox, {
6234
6234
  runInbox: () => runInbox
6235
6235
  });
6236
- function formatMessage(msg, useColor) {
6237
- const dim2 = (s) => useColor ? `\x1B[2m${s}\x1B[22m` : s;
6238
- const bold2 = (s) => useColor ? `\x1B[1m${s}\x1B[22m` : s;
6236
+ function formatMessage(msg) {
6239
6237
  const text = msg.plaintext ?? `[encrypted: ${msg.ciphertext.slice(0, 32)}…]`;
6240
6238
  const from = msg.senderPubkey.slice(0, 8);
6241
6239
  const time = new Date(msg.createdAt).toLocaleTimeString();
6242
6240
  const kindTag = msg.kind === "direct" ? "→ direct" : msg.kind;
6243
- return ` ${bold2(from)} ${dim2(`[${kindTag}] ${time}`)}
6241
+ return ` ${bold(from)} ${dim(`[${kindTag}] ${time}`)}
6244
6242
  ${text}`;
6245
6243
  }
6246
6244
  async function runInbox(flags) {
6247
- const useColor = !process.env.NO_COLOR && process.env.TERM !== "dumb" && process.stdout.isTTY;
6248
- const dim2 = (s) => useColor ? `\x1B[2m${s}\x1B[22m` : s;
6249
- const bold2 = (s) => useColor ? `\x1B[1m${s}\x1B[22m` : s;
6250
6245
  const waitMs = (flags.wait ?? 1) * 1000;
6251
6246
  await withMesh({ meshSlug: flags.mesh ?? null }, async (client, mesh) => {
6252
6247
  await new Promise((resolve) => setTimeout(resolve, waitMs));
6253
6248
  const messages = client.drainPushBuffer();
6254
6249
  if (flags.json) {
6255
- console.log(JSON.stringify(messages, null, 2));
6250
+ process.stdout.write(JSON.stringify(messages, null, 2) + `
6251
+ `);
6256
6252
  return;
6257
6253
  }
6258
6254
  if (messages.length === 0) {
6259
- console.log(dim2(`No messages on mesh "${mesh.slug}".`));
6255
+ render.info(dim(`No messages on mesh "${mesh.slug}".`));
6260
6256
  return;
6261
6257
  }
6262
- console.log(bold2(`Inbox — ${mesh.slug}`) + dim2(` (${messages.length} message${messages.length === 1 ? "" : "s"})`));
6263
- console.log("");
6258
+ render.section(`inbox — ${mesh.slug} (${messages.length} message${messages.length === 1 ? "" : "s"})`);
6264
6259
  for (const msg of messages) {
6265
- console.log(formatMessage(msg, useColor));
6266
- console.log("");
6260
+ process.stdout.write(formatMessage(msg) + `
6261
+
6262
+ `);
6267
6263
  }
6268
6264
  });
6269
6265
  }
6270
6266
  var init_inbox = __esm(() => {
6271
6267
  init_connect();
6268
+ init_render();
6269
+ init_styles();
6272
6270
  });
6273
6271
 
6274
6272
  // src/commands/state.ts
@@ -6339,9 +6337,6 @@ __export(exports_info, {
6339
6337
  runInfo: () => runInfo
6340
6338
  });
6341
6339
  async function runInfo(flags) {
6342
- const useColor = !process.env.NO_COLOR && process.env.TERM !== "dumb" && process.stdout.isTTY;
6343
- const dim2 = (s) => useColor ? `\x1B[2m${s}\x1B[22m` : s;
6344
- const bold2 = (s) => useColor ? `\x1B[1m${s}\x1B[22m` : s;
6345
6340
  const config = readConfig();
6346
6341
  await withMesh({ meshSlug: flags.mesh ?? null }, async (client, mesh) => {
6347
6342
  const [brokerInfo, peers, state] = await Promise.all([
@@ -6360,26 +6355,33 @@ async function runInfo(flags) {
6360
6355
  ...brokerInfo ?? {}
6361
6356
  };
6362
6357
  if (flags.json) {
6363
- console.log(JSON.stringify(output, null, 2));
6358
+ process.stdout.write(JSON.stringify(output, null, 2) + `
6359
+ `);
6364
6360
  return;
6365
6361
  }
6366
- console.log(bold2(mesh.slug) + dim2(` · ${mesh.brokerUrl}`));
6367
- console.log(dim2(` mesh: ${mesh.meshId}`));
6368
- console.log(dim2(` member: ${mesh.memberId}`));
6369
- console.log(` peers: ${peers.length} connected`);
6370
- console.log(` state: ${state.length} keys`);
6362
+ render.section(`${mesh.slug} · ${mesh.brokerUrl}`);
6363
+ render.kv([
6364
+ ["mesh", mesh.meshId],
6365
+ ["member", mesh.memberId],
6366
+ ["peers", `${peers.length} connected`],
6367
+ ["state", `${state.length} keys`]
6368
+ ]);
6371
6369
  if (brokerInfo && typeof brokerInfo === "object") {
6370
+ const extras = [];
6372
6371
  for (const [k, v] of Object.entries(brokerInfo)) {
6373
6372
  if (["slug", "meshId", "brokerUrl"].includes(k))
6374
6373
  continue;
6375
- console.log(dim2(` ${k}: ${JSON.stringify(v)}`));
6374
+ extras.push([k, JSON.stringify(v)]);
6376
6375
  }
6376
+ if (extras.length)
6377
+ render.kv(extras);
6377
6378
  }
6378
6379
  });
6379
6380
  }
6380
6381
  var init_info2 = __esm(() => {
6381
6382
  init_connect();
6382
6383
  init_facade();
6384
+ init_render();
6383
6385
  });
6384
6386
 
6385
6387
  // src/commands/remember.ts
@@ -8600,6 +8602,30 @@ __export(exports_grants, {
8600
8602
  import { existsSync as existsSync17, mkdirSync as mkdirSync5, readFileSync as readFileSync12, writeFileSync as writeFileSync9 } from "node:fs";
8601
8603
  import { homedir as homedir8 } from "node:os";
8602
8604
  import { join as join9 } from "node:path";
8605
+ async function syncToBroker(meshSlug, grants) {
8606
+ const auth = getStoredToken();
8607
+ if (!auth)
8608
+ return;
8609
+ let userId = "";
8610
+ try {
8611
+ const payload = JSON.parse(Buffer.from(auth.session_token.split(".")[1], "base64url").toString());
8612
+ userId = payload.sub ?? "";
8613
+ } catch {
8614
+ return;
8615
+ }
8616
+ if (!userId)
8617
+ return;
8618
+ try {
8619
+ await request({
8620
+ path: `/cli/mesh/${meshSlug}/grants`,
8621
+ method: "POST",
8622
+ body: { user_id: userId, grants },
8623
+ baseUrl: BROKER_HTTP7
8624
+ });
8625
+ } catch (e) {
8626
+ render.warn(`broker grant sync failed — client filter still active: ${e instanceof Error ? e.message : e}`);
8627
+ }
8628
+ }
8603
8629
  function readGrants() {
8604
8630
  if (!existsSync17(GRANT_FILE))
8605
8631
  return {};
@@ -8661,6 +8687,7 @@ async function runGrant(peer, caps, opts = {}) {
8661
8687
  meshGrants[resolved.pubkey] = merged;
8662
8688
  store[mesh] = meshGrants;
8663
8689
  writeGrants(store);
8690
+ await syncToBroker(mesh, { [resolved.pubkey]: merged });
8664
8691
  render.ok(`Granted ${wanted.join(", ")} to ${resolved.displayName} on ${mesh}.`);
8665
8692
  render.kv([["now", merged.join(", ")]]);
8666
8693
  return EXIT.SUCCESS;
@@ -8688,6 +8715,7 @@ async function runRevoke(peer, caps, opts = {}) {
8688
8715
  meshGrants[resolved.pubkey] = after;
8689
8716
  store[mesh] = meshGrants;
8690
8717
  writeGrants(store);
8718
+ await syncToBroker(mesh, { [resolved.pubkey]: after });
8691
8719
  render.ok(`Revoked ${wanted.join(", ")} from ${resolved.displayName} on ${mesh}.`);
8692
8720
  render.kv([["now", after.length ? after.join(", ") : "(none)"]]);
8693
8721
  return EXIT.SUCCESS;
@@ -8712,6 +8740,7 @@ async function runBlock(peer, opts = {}) {
8712
8740
  meshGrants[resolved.pubkey] = [];
8713
8741
  store[mesh] = meshGrants;
8714
8742
  writeGrants(store);
8743
+ await syncToBroker(mesh, { [resolved.pubkey]: [] });
8715
8744
  render.ok(`Blocked ${resolved.displayName} on ${mesh} (all capabilities revoked).`);
8716
8745
  render.hint(`Undo with: claudemesh grant ${resolved.displayName} all --mesh ${mesh}`);
8717
8746
  return EXIT.SUCCESS;
@@ -8751,12 +8780,16 @@ function isAllowed(meshSlug, peerPubkey, cap) {
8751
8780
  return DEFAULT_CAPS.includes(cap);
8752
8781
  return entry.includes(cap);
8753
8782
  }
8754
- var ALL_CAPS, DEFAULT_CAPS, GRANT_FILE;
8783
+ var BROKER_HTTP7, ALL_CAPS, DEFAULT_CAPS, GRANT_FILE;
8755
8784
  var init_grants = __esm(() => {
8756
8785
  init_facade();
8757
8786
  init_connect();
8758
8787
  init_render();
8759
8788
  init_exit_codes();
8789
+ init_facade6();
8790
+ init_facade3();
8791
+ init_urls();
8792
+ BROKER_HTTP7 = URLS.BROKER.replace("wss://", "https://").replace("ws://", "http://").replace("/ws", "");
8760
8793
  ALL_CAPS = ["read", "dm", "broadcast", "state-read", "state-write", "file-read"];
8761
8794
  DEFAULT_CAPS = ["read", "dm", "broadcast", "state-read"];
8762
8795
  GRANT_FILE = join9(homedir8(), ".claudemesh", "grants.json");
@@ -12446,4 +12479,4 @@ main().catch((err) => {
12446
12479
  process.exit(EXIT.INTERNAL_ERROR);
12447
12480
  });
12448
12481
 
12449
- //# debugId=A6858740B3A6F9A864756E2164756E21
12482
+ //# debugId=E80C818349D554BA64756E2164756E21