claudemesh-cli 1.0.0-alpha.11 → 1.0.0-alpha.12
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 +119 -46
- package/dist/entrypoints/cli.js.map +4 -4
- package/package.json +1 -1
package/dist/entrypoints/cli.js
CHANGED
|
@@ -4310,47 +4310,88 @@ __export(exports_delete_mesh, {
|
|
|
4310
4310
|
deleteMesh: () => deleteMesh
|
|
4311
4311
|
});
|
|
4312
4312
|
import { createInterface as createInterface3 } from "node:readline";
|
|
4313
|
+
function prompt(question) {
|
|
4314
|
+
const rl = createInterface3({ input: process.stdin, output: process.stdout });
|
|
4315
|
+
return new Promise((resolve) => {
|
|
4316
|
+
rl.question(question, (a) => {
|
|
4317
|
+
rl.close();
|
|
4318
|
+
resolve(a.trim().toLowerCase());
|
|
4319
|
+
});
|
|
4320
|
+
});
|
|
4321
|
+
}
|
|
4313
4322
|
async function deleteMesh(slug, opts = {}) {
|
|
4314
4323
|
if (!slug) {
|
|
4315
|
-
|
|
4316
|
-
|
|
4317
|
-
|
|
4318
|
-
|
|
4319
|
-
|
|
4320
|
-
if (!mesh) {
|
|
4321
|
-
console.error(` Mesh "${slug}" not found. Run \`claudemesh mesh list\` to see your meshes.`);
|
|
4322
|
-
return EXIT.NOT_FOUND;
|
|
4323
|
-
}
|
|
4324
|
-
if (!opts.yes) {
|
|
4324
|
+
const config = readConfig();
|
|
4325
|
+
if (config.meshes.length === 0) {
|
|
4326
|
+
console.error(" No meshes to delete.");
|
|
4327
|
+
return EXIT.NOT_FOUND;
|
|
4328
|
+
}
|
|
4325
4329
|
console.log(`
|
|
4326
|
-
|
|
4327
|
-
console.log(` ${dim("To delete from the server, use the dashboard.")}
|
|
4330
|
+
Select mesh to delete:
|
|
4328
4331
|
`);
|
|
4329
|
-
|
|
4330
|
-
|
|
4331
|
-
rl.question(` Delete "${slug}"? [y/N]: `, (a) => {
|
|
4332
|
-
rl.close();
|
|
4333
|
-
resolve(a.trim().toLowerCase());
|
|
4334
|
-
});
|
|
4332
|
+
config.meshes.forEach((m, i) => {
|
|
4333
|
+
console.log(` ${bold(String(i + 1) + ")")} ${m.slug} ${dim("(" + m.name + ")")}`);
|
|
4335
4334
|
});
|
|
4336
|
-
|
|
4335
|
+
console.log("");
|
|
4336
|
+
const choice = await prompt(" Choice: ");
|
|
4337
|
+
const idx = parseInt(choice, 10) - 1;
|
|
4338
|
+
if (idx < 0 || idx >= config.meshes.length) {
|
|
4337
4339
|
console.log(" Cancelled.");
|
|
4338
4340
|
return EXIT.USER_CANCELLED;
|
|
4339
4341
|
}
|
|
4342
|
+
slug = config.meshes[idx].slug;
|
|
4340
4343
|
}
|
|
4341
|
-
|
|
4342
|
-
|
|
4343
|
-
|
|
4344
|
-
|
|
4344
|
+
if (!opts.yes) {
|
|
4345
|
+
console.log(`
|
|
4346
|
+
${red("Warning:")} This will permanently delete ${bold(slug)}.`);
|
|
4347
|
+
const answer = await prompt(` Type "${slug}" to confirm: `);
|
|
4348
|
+
if (answer !== slug.toLowerCase()) {
|
|
4349
|
+
console.log(" Cancelled.");
|
|
4350
|
+
return EXIT.USER_CANCELLED;
|
|
4351
|
+
}
|
|
4345
4352
|
}
|
|
4346
|
-
|
|
4347
|
-
|
|
4353
|
+
const auth = getStoredToken();
|
|
4354
|
+
if (auth) {
|
|
4355
|
+
try {
|
|
4356
|
+
let userId = "";
|
|
4357
|
+
try {
|
|
4358
|
+
const payload = JSON.parse(Buffer.from(auth.session_token.split(".")[1], "base64url").toString());
|
|
4359
|
+
userId = payload.sub ?? "";
|
|
4360
|
+
} catch {}
|
|
4361
|
+
if (userId) {
|
|
4362
|
+
await request({
|
|
4363
|
+
path: `/cli/mesh/${slug}`,
|
|
4364
|
+
method: "DELETE",
|
|
4365
|
+
body: { user_id: userId },
|
|
4366
|
+
baseUrl: BROKER_HTTP2
|
|
4367
|
+
});
|
|
4368
|
+
console.log(` ${green(icons.check)} Deleted "${slug}" from server.`);
|
|
4369
|
+
}
|
|
4370
|
+
} catch (err) {
|
|
4371
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
4372
|
+
if (msg.includes("403")) {
|
|
4373
|
+
console.log(` ${dim("Not the owner — removing from local config only.")}`);
|
|
4374
|
+
} else if (msg.includes("404")) {
|
|
4375
|
+
console.log(` ${dim("Mesh not found on server — removing locally.")}`);
|
|
4376
|
+
} else {
|
|
4377
|
+
console.log(` ${dim("Could not delete from server: " + msg)}`);
|
|
4378
|
+
}
|
|
4379
|
+
}
|
|
4380
|
+
}
|
|
4381
|
+
leaveMesh(slug);
|
|
4382
|
+
console.log(` ${green(icons.check)} Removed "${slug}" from local config.`);
|
|
4383
|
+
return EXIT.SUCCESS;
|
|
4348
4384
|
}
|
|
4385
|
+
var BROKER_HTTP2;
|
|
4349
4386
|
var init_delete_mesh = __esm(() => {
|
|
4350
4387
|
init_facade();
|
|
4351
4388
|
init_facade9();
|
|
4389
|
+
init_facade6();
|
|
4390
|
+
init_facade3();
|
|
4391
|
+
init_urls();
|
|
4352
4392
|
init_styles();
|
|
4353
4393
|
init_exit_codes();
|
|
4394
|
+
BROKER_HTTP2 = URLS.BROKER.replace("wss://", "https://").replace("ws://", "http://").replace("/ws", "");
|
|
4354
4395
|
});
|
|
4355
4396
|
|
|
4356
4397
|
// src/commands/rename.ts
|
|
@@ -4413,6 +4454,16 @@ var exports_invite = {};
|
|
|
4413
4454
|
__export(exports_invite, {
|
|
4414
4455
|
invite: () => invite
|
|
4415
4456
|
});
|
|
4457
|
+
import { createInterface as createInterface4 } from "node:readline";
|
|
4458
|
+
function prompt2(question) {
|
|
4459
|
+
const rl = createInterface4({ input: process.stdin, output: process.stdout });
|
|
4460
|
+
return new Promise((resolve) => {
|
|
4461
|
+
rl.question(question, (a) => {
|
|
4462
|
+
rl.close();
|
|
4463
|
+
resolve(a.trim());
|
|
4464
|
+
});
|
|
4465
|
+
});
|
|
4466
|
+
}
|
|
4416
4467
|
async function invite(email, opts = {}) {
|
|
4417
4468
|
const auth = getStoredToken();
|
|
4418
4469
|
if (!auth) {
|
|
@@ -4420,11 +4471,27 @@ async function invite(email, opts = {}) {
|
|
|
4420
4471
|
return EXIT.AUTH_FAILED;
|
|
4421
4472
|
}
|
|
4422
4473
|
const config = readConfig();
|
|
4423
|
-
|
|
4424
|
-
|
|
4425
|
-
console.error(" No meshes joined. Create one with `claudemesh new <name>`.");
|
|
4474
|
+
if (config.meshes.length === 0) {
|
|
4475
|
+
console.error(" No meshes. Create one with `claudemesh mesh create <name>`.");
|
|
4426
4476
|
return EXIT.NOT_FOUND;
|
|
4427
4477
|
}
|
|
4478
|
+
let meshSlug = opts.mesh;
|
|
4479
|
+
if (!meshSlug) {
|
|
4480
|
+
if (config.meshes.length === 1) {
|
|
4481
|
+
meshSlug = config.meshes[0].slug;
|
|
4482
|
+
} else {
|
|
4483
|
+
console.log(`
|
|
4484
|
+
Select mesh to share:
|
|
4485
|
+
`);
|
|
4486
|
+
config.meshes.forEach((m, i) => {
|
|
4487
|
+
console.log(` ${bold(String(i + 1) + ")")} ${m.slug} ${dim("(" + m.name + ")")}`);
|
|
4488
|
+
});
|
|
4489
|
+
console.log("");
|
|
4490
|
+
const choice = await prompt2(" Choice [1]: ") || "1";
|
|
4491
|
+
const idx = parseInt(choice, 10) - 1;
|
|
4492
|
+
meshSlug = config.meshes[idx >= 0 && idx < config.meshes.length ? idx : 0].slug;
|
|
4493
|
+
}
|
|
4494
|
+
}
|
|
4428
4495
|
try {
|
|
4429
4496
|
const result = await exports_my.createInvite(auth.session_token, meshSlug, {
|
|
4430
4497
|
email,
|
|
@@ -4438,21 +4505,27 @@ async function invite(email, opts = {}) {
|
|
|
4438
4505
|
} else {
|
|
4439
4506
|
if (email) {
|
|
4440
4507
|
console.log(`
|
|
4441
|
-
${green(icons.check)}
|
|
4508
|
+
${green(icons.check)} Invite sent to ${bold(email)}`);
|
|
4442
4509
|
if (copied)
|
|
4443
|
-
console.log(` ${green(icons.check)}
|
|
4510
|
+
console.log(` ${green(icons.check)} Link also copied to clipboard`);
|
|
4444
4511
|
} else {
|
|
4445
4512
|
console.log(`
|
|
4446
|
-
${green(icons.check)} Invite
|
|
4513
|
+
${green(icons.check)} Invite link${copied ? " copied to clipboard" : ""}:`);
|
|
4447
4514
|
console.log(` ${result.url}`);
|
|
4448
4515
|
}
|
|
4449
4516
|
console.log(`
|
|
4450
|
-
Expires
|
|
4517
|
+
${dim("Expires " + result.expires_at + '. Anyone with this link can join "' + meshSlug + '".')}
|
|
4451
4518
|
`);
|
|
4452
4519
|
}
|
|
4453
4520
|
return EXIT.SUCCESS;
|
|
4454
4521
|
} catch (err) {
|
|
4455
|
-
|
|
4522
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
4523
|
+
if (msg.includes("403") || msg.includes("permission")) {
|
|
4524
|
+
console.error(` ${icons.cross} You don't have permission to invite to "${meshSlug}".`);
|
|
4525
|
+
console.error(` ${dim("Ask the mesh owner to grant you invite permissions.")}`);
|
|
4526
|
+
} else {
|
|
4527
|
+
console.error(` ${icons.cross} Failed: ${msg}`);
|
|
4528
|
+
}
|
|
4456
4529
|
return EXIT.INTERNAL_ERROR;
|
|
4457
4530
|
}
|
|
4458
4531
|
}
|
|
@@ -4498,9 +4571,9 @@ var exports_login = {};
|
|
|
4498
4571
|
__export(exports_login, {
|
|
4499
4572
|
login: () => login
|
|
4500
4573
|
});
|
|
4501
|
-
import { createInterface as
|
|
4502
|
-
function
|
|
4503
|
-
const rl =
|
|
4574
|
+
import { createInterface as createInterface5 } from "node:readline";
|
|
4575
|
+
function prompt3(question) {
|
|
4576
|
+
const rl = createInterface5({ input: process.stdin, output: process.stdout });
|
|
4504
4577
|
return new Promise((resolve) => {
|
|
4505
4578
|
rl.question(question, (answer) => {
|
|
4506
4579
|
rl.close();
|
|
@@ -4513,7 +4586,7 @@ async function loginWithToken() {
|
|
|
4513
4586
|
Paste a token from ${dim(URLS.API_BASE + "/token")}`);
|
|
4514
4587
|
console.log(` ${dim("Generate one in your browser, then paste it here.")}
|
|
4515
4588
|
`);
|
|
4516
|
-
const token = await
|
|
4589
|
+
const token = await prompt3(" Token: ");
|
|
4517
4590
|
if (!token) {
|
|
4518
4591
|
console.error(` ${icons.cross} No token provided.`);
|
|
4519
4592
|
return EXIT.AUTH_FAILED;
|
|
@@ -4562,7 +4635,7 @@ async function login() {
|
|
|
4562
4635
|
console.log(` ${bold("3)")} Paste a token from ${dim("claudemesh.com/token")}`);
|
|
4563
4636
|
console.log(` ${bold("4)")} Sign out`);
|
|
4564
4637
|
console.log("");
|
|
4565
|
-
const choice = await
|
|
4638
|
+
const choice = await prompt3(" Choice [1]: ") || "1";
|
|
4566
4639
|
if (choice === "1") {
|
|
4567
4640
|
console.log(`
|
|
4568
4641
|
${green(icons.check)} Continuing as ${name}.`);
|
|
@@ -4586,7 +4659,7 @@ async function login() {
|
|
|
4586
4659
|
console.log(` ${bold("1)")} Sign in via browser ${dim("(opens automatically)")}`);
|
|
4587
4660
|
console.log(` ${bold("2)")} Paste a token from ${dim("claudemesh.com/token")}`);
|
|
4588
4661
|
console.log("");
|
|
4589
|
-
const choice = await
|
|
4662
|
+
const choice = await prompt3(" Choice [1]: ") || "1";
|
|
4590
4663
|
if (choice === "2") {
|
|
4591
4664
|
return loginWithToken();
|
|
4592
4665
|
}
|
|
@@ -4627,13 +4700,13 @@ __export(exports_welcome, {
|
|
|
4627
4700
|
runWelcome: () => runWelcome,
|
|
4628
4701
|
_stub: () => runWelcome
|
|
4629
4702
|
});
|
|
4630
|
-
import { createInterface as
|
|
4703
|
+
import { createInterface as createInterface6 } from "node:readline";
|
|
4631
4704
|
async function runWelcome() {
|
|
4632
4705
|
const config = readConfig();
|
|
4633
4706
|
if (config.meshes.length > 0)
|
|
4634
4707
|
return EXIT.SUCCESS;
|
|
4635
4708
|
renderWelcome();
|
|
4636
|
-
const rl =
|
|
4709
|
+
const rl = createInterface6({ input: process.stdin, output: process.stdout });
|
|
4637
4710
|
return new Promise((resolve) => {
|
|
4638
4711
|
rl.question(" Choice [1]: ", async (answer) => {
|
|
4639
4712
|
rl.close();
|
|
@@ -7784,7 +7857,7 @@ var init_whoami = __esm(() => {
|
|
|
7784
7857
|
|
|
7785
7858
|
// src/commands/connect.ts
|
|
7786
7859
|
import { hostname as hostname4 } from "node:os";
|
|
7787
|
-
import { createInterface as
|
|
7860
|
+
import { createInterface as createInterface7 } from "node:readline";
|
|
7788
7861
|
async function pickMesh2(meshes) {
|
|
7789
7862
|
console.log(`
|
|
7790
7863
|
Select mesh:`);
|
|
@@ -7792,7 +7865,7 @@ async function pickMesh2(meshes) {
|
|
|
7792
7865
|
console.log(` ${i + 1}) ${m.slug}`);
|
|
7793
7866
|
});
|
|
7794
7867
|
console.log("");
|
|
7795
|
-
const rl =
|
|
7868
|
+
const rl = createInterface7({ input: process.stdin, output: process.stdout });
|
|
7796
7869
|
return new Promise((resolve) => {
|
|
7797
7870
|
rl.question(" Choice [1]: ", (answer) => {
|
|
7798
7871
|
rl.close();
|
|
@@ -9087,7 +9160,7 @@ var exports_sync = {};
|
|
|
9087
9160
|
__export(exports_sync, {
|
|
9088
9161
|
runSync: () => runSync
|
|
9089
9162
|
});
|
|
9090
|
-
import { createInterface as
|
|
9163
|
+
import { createInterface as createInterface8 } from "node:readline";
|
|
9091
9164
|
import { hostname as hostname5 } from "node:os";
|
|
9092
9165
|
async function runSync(args) {
|
|
9093
9166
|
const useColor = !process.env.NO_COLOR && process.env.TERM !== "dumb" && process.stdout.isTTY;
|
|
@@ -9101,7 +9174,7 @@ async function runSync(args) {
|
|
|
9101
9174
|
console.log(dim2(`Visit: ${url}`));
|
|
9102
9175
|
await openBrowser(url);
|
|
9103
9176
|
const manualPromise = new Promise((resolve2) => {
|
|
9104
|
-
const rl =
|
|
9177
|
+
const rl = createInterface8({ input: process.stdin, output: process.stdout });
|
|
9105
9178
|
rl.question("Paste sync token (or wait for browser): ", (answer) => {
|
|
9106
9179
|
rl.close();
|
|
9107
9180
|
if (answer.trim())
|
|
@@ -9696,4 +9769,4 @@ main().catch((err) => {
|
|
|
9696
9769
|
process.exit(EXIT.INTERNAL_ERROR);
|
|
9697
9770
|
});
|
|
9698
9771
|
|
|
9699
|
-
//# debugId=
|
|
9772
|
+
//# debugId=2903DE0B5859761A64756E2164756E21
|