claudemesh-cli 1.0.0-alpha.8 → 1.0.0-alpha.9

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.
@@ -1408,6 +1408,57 @@ __export(exports_login, {
1408
1408
  login: () => login
1409
1409
  });
1410
1410
  import { createInterface } from "node:readline";
1411
+ function prompt(question) {
1412
+ const rl = createInterface({ input: process.stdin, output: process.stdout });
1413
+ return new Promise((resolve) => {
1414
+ rl.question(question, (answer) => {
1415
+ rl.close();
1416
+ resolve(answer.trim());
1417
+ });
1418
+ });
1419
+ }
1420
+ async function loginWithToken() {
1421
+ console.log(`
1422
+ Paste a token from ${dim(URLS.API_BASE + "/token")}`);
1423
+ console.log(` ${dim("Generate one in your browser, then paste it here.")}
1424
+ `);
1425
+ const token = await prompt(" Token: ");
1426
+ if (!token) {
1427
+ console.error(` ${icons.cross} No token provided.`);
1428
+ return EXIT.AUTH_FAILED;
1429
+ }
1430
+ let user = { id: "", display_name: "", email: "" };
1431
+ try {
1432
+ const parts = token.split(".");
1433
+ if (parts[1]) {
1434
+ const payload = JSON.parse(Buffer.from(parts[1], "base64url").toString());
1435
+ if (payload.exp && payload.exp < Date.now() / 1000) {
1436
+ console.error(` ${icons.cross} Token expired. Generate a new one.`);
1437
+ return EXIT.AUTH_FAILED;
1438
+ }
1439
+ user = {
1440
+ id: payload.sub ?? "",
1441
+ display_name: payload.name ?? payload.email ?? "",
1442
+ email: payload.email ?? ""
1443
+ };
1444
+ }
1445
+ } catch {
1446
+ console.error(` ${icons.cross} Invalid token format.`);
1447
+ return EXIT.AUTH_FAILED;
1448
+ }
1449
+ storeToken({ session_token: token, user, token_source: "manual" });
1450
+ console.log(` ${green(icons.check)} Signed in as ${user.display_name || user.email || "user"}.`);
1451
+ return EXIT.SUCCESS;
1452
+ }
1453
+ async function syncMeshes(token) {
1454
+ try {
1455
+ const meshes = await exports_my.getMeshes(token);
1456
+ if (meshes.length > 0) {
1457
+ const names = meshes.map((m) => m.slug).join(", ");
1458
+ console.log(` ${green(icons.check)} Synced ${meshes.length} mesh${meshes.length === 1 ? "" : "es"}: ${names}`);
1459
+ }
1460
+ } catch {}
1461
+ }
1411
1462
  async function login() {
1412
1463
  const existing = getStoredToken();
1413
1464
  if (existing) {
@@ -1416,39 +1467,43 @@ async function login() {
1416
1467
  Already signed in as ${bold(name)}.`);
1417
1468
  console.log("");
1418
1469
  console.log(` ${bold("1)")} Continue as ${name}`);
1419
- console.log(` ${bold("2)")} Sign in as a different account`);
1420
- console.log(` ${bold("3)")} Sign out ${dim("(claudemesh logout)")}`);
1470
+ console.log(` ${bold("2)")} Sign in via browser`);
1471
+ console.log(` ${bold("3)")} Paste a token from ${dim("claudemesh.com/token")}`);
1472
+ console.log(` ${bold("4)")} Sign out`);
1421
1473
  console.log("");
1422
- const rl = createInterface({ input: process.stdin, output: process.stdout });
1423
- const choice = await new Promise((resolve) => {
1424
- rl.question(" Choice [1]: ", (answer) => {
1425
- rl.close();
1426
- resolve(answer.trim() || "1");
1427
- });
1428
- });
1474
+ const choice = await prompt(" Choice [1]: ") || "1";
1429
1475
  if (choice === "1") {
1430
1476
  console.log(`
1431
1477
  ${green(icons.check)} Continuing as ${name}.`);
1432
1478
  return EXIT.SUCCESS;
1433
1479
  }
1434
- if (choice === "3") {
1480
+ if (choice === "4") {
1435
1481
  clearToken();
1436
1482
  console.log(` ${green(icons.check)} Signed out.`);
1437
1483
  return EXIT.SUCCESS;
1438
1484
  }
1485
+ if (choice === "3") {
1486
+ clearToken();
1487
+ return loginWithToken();
1488
+ }
1439
1489
  clearToken();
1440
- console.log(` ${dim("Signing in as a different account…")}`);
1490
+ console.log(` ${dim("Signing in…")}`);
1491
+ } else {
1492
+ console.log(`
1493
+ ${bold("claudemesh")} — sign in to connect your terminal`);
1494
+ console.log("");
1495
+ console.log(` ${bold("1)")} Sign in via browser ${dim("(opens automatically)")}`);
1496
+ console.log(` ${bold("2)")} Paste a token from ${dim("claudemesh.com/token")}`);
1497
+ console.log("");
1498
+ const choice = await prompt(" Choice [1]: ") || "1";
1499
+ if (choice === "2") {
1500
+ return loginWithToken();
1501
+ }
1441
1502
  }
1442
1503
  try {
1443
1504
  const result = await loginWithDeviceCode();
1444
1505
  console.log(` ${green(icons.check)} Signed in as ${result.user.display_name}.`);
1445
- try {
1446
- const meshes = await exports_my.getMeshes(result.session_token);
1447
- if (meshes.length > 0) {
1448
- const names = meshes.map((m) => m.slug).join(", ");
1449
- console.log(` ${green(icons.check)} Synced ${meshes.length} mesh${meshes.length === 1 ? "" : "es"}: ${names}`);
1450
- }
1451
- } catch {}
1506
+ await syncMeshes(result.session_token);
1452
1507
  return EXIT.SUCCESS;
1453
1508
  } catch (err) {
1454
1509
  console.error(` ${icons.cross} Login failed: ${err instanceof Error ? err.message : err}`);
@@ -1460,6 +1515,7 @@ var init_login = __esm(() => {
1460
1515
  init_facade2();
1461
1516
  init_styles();
1462
1517
  init_exit_codes();
1518
+ init_urls();
1463
1519
  });
1464
1520
 
1465
1521
  // src/commands/register.ts
@@ -3576,7 +3632,7 @@ function enterFullScreen() {
3576
3632
  function exitFullScreen() {
3577
3633
  process.stdout.write(SHOW_CURSOR + CLEAR_SCREEN);
3578
3634
  }
3579
- async function menuSelect(itemsOrOpts, prompt = "Choice") {
3635
+ async function menuSelect(itemsOrOpts, prompt2 = "Choice") {
3580
3636
  const items = Array.isArray(itemsOrOpts) ? itemsOrOpts : itemsOrOpts.items;
3581
3637
  const title = !Array.isArray(itemsOrOpts) ? itemsOrOpts.title : undefined;
3582
3638
  if (title)
@@ -3586,7 +3642,7 @@ async function menuSelect(itemsOrOpts, prompt = "Choice") {
3586
3642
  console.log("");
3587
3643
  const rl = createInterface3({ input: process.stdin, output: process.stdout });
3588
3644
  return new Promise((resolve) => {
3589
- rl.question(` ${prompt} [1]: `, (answer) => {
3645
+ rl.question(` ${prompt2} [1]: `, (answer) => {
3590
3646
  rl.close();
3591
3647
  const idx = parseInt(answer || "1", 10) - 1;
3592
3648
  resolve(idx >= 0 && idx < items.length ? idx : 0);
@@ -7759,7 +7815,7 @@ async function runPeers(flags) {
7759
7815
  const dim2 = (s) => useColor ? `\x1B[2m${s}\x1B[22m` : s;
7760
7816
  const bold2 = (s) => useColor ? `\x1B[1m${s}\x1B[22m` : s;
7761
7817
  const green3 = (s) => useColor ? `\x1B[32m${s}\x1B[39m` : s;
7762
- const yellow3 = (s) => useColor ? `\x1B[33m${s}\x1B[39m` : s;
7818
+ const yellow2 = (s) => useColor ? `\x1B[33m${s}\x1B[39m` : s;
7763
7819
  const config = readConfig();
7764
7820
  const slugs = flags.mesh ? [flags.mesh] : config.meshes.map((m) => m.slug);
7765
7821
  if (slugs.length === 0) {
@@ -7782,7 +7838,7 @@ async function runPeers(flags) {
7782
7838
  } else {
7783
7839
  for (const p of peers) {
7784
7840
  const groups = p.groups.length ? " [" + p.groups.map((g) => `@${g.name}${g.role ? `:${g.role}` : ""}`).join(", ") + "]" : "";
7785
- const statusIcon = p.status === "working" ? yellow3("●") : green3("●");
7841
+ const statusIcon = p.status === "working" ? yellow2("●") : green3("●");
7786
7842
  const name = bold2(p.displayName);
7787
7843
  const meta = [];
7788
7844
  if (p.peerType)
@@ -8787,7 +8843,7 @@ function runInstall(args = []) {
8787
8843
  }
8788
8844
  const useColor = !process.env.NO_COLOR && process.env.TERM !== "dumb" && process.stdout.isTTY;
8789
8845
  const bold2 = (s) => useColor ? `\x1B[1m${s}\x1B[22m` : s;
8790
- const yellow3 = (s) => useColor ? `\x1B[33m${s}\x1B[39m` : s;
8846
+ const yellow2 = (s) => useColor ? `\x1B[33m${s}\x1B[39m` : s;
8791
8847
  const dim2 = (s) => useColor ? `\x1B[2m${s}\x1B[22m` : s;
8792
8848
  console.log(`✓ MCP server "${MCP_NAME}" ${action}`);
8793
8849
  console.log(dim2(` config: ${CLAUDE_CONFIG}`));
@@ -8827,10 +8883,10 @@ function runInstall(args = []) {
8827
8883
  hasMeshes = meshConfig.meshes.length > 0;
8828
8884
  } catch {}
8829
8885
  console.log("");
8830
- console.log(yellow3(bold2("⚠ RESTART CLAUDE CODE")) + yellow3(" for MCP tools to appear."));
8886
+ console.log(yellow2(bold2("⚠ RESTART CLAUDE CODE")) + yellow2(" for MCP tools to appear."));
8831
8887
  if (!hasMeshes) {
8832
8888
  console.log("");
8833
- console.log(yellow3("No meshes joined.") + " To connect with peers:");
8889
+ console.log(yellow2("No meshes joined.") + " To connect with peers:");
8834
8890
  console.log(` ${bold2("claudemesh join <invite-url>")}` + dim2(" — join an existing mesh"));
8835
8891
  console.log(` ${dim2("Create one at")} ${bold2("https://claudemesh.com/dashboard")}`);
8836
8892
  } else {
@@ -8838,7 +8894,7 @@ function runInstall(args = []) {
8838
8894
  console.log(`Next: ${bold2("claudemesh join https://claudemesh.com/join/<token>")}`);
8839
8895
  }
8840
8896
  console.log("");
8841
- console.log(yellow3("⚠ For real-time push messages from peers, launch with:"));
8897
+ console.log(yellow2("⚠ For real-time push messages from peers, launch with:"));
8842
8898
  console.log(` ${bold2("claudemesh launch")}` + dim2(" (or: claude --dangerously-load-development-channels server:claudemesh)"));
8843
8899
  console.log(dim2(" Plain `claude` still works — messages are then pull-only via check_messages."));
8844
8900
  }
@@ -10645,4 +10701,4 @@ main().catch((err) => {
10645
10701
  process.exit(EXIT.INTERNAL_ERROR);
10646
10702
  });
10647
10703
 
10648
- //# debugId=A2CF6E1117A2110D64756E2164756E21
10704
+ //# debugId=B1D91566048A7A1864756E2164756E21