claudemesh-cli 0.1.8 → 0.1.10
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/index.js +46 -23
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -46336,7 +46336,7 @@ async function ensureSodium() {
|
|
|
46336
46336
|
}
|
|
46337
46337
|
return import_libsodium_wrappers.default;
|
|
46338
46338
|
}
|
|
46339
|
-
async function
|
|
46339
|
+
async function generateKeypair2() {
|
|
46340
46340
|
const s = await ensureSodium();
|
|
46341
46341
|
const kp = s.crypto_sign_keypair();
|
|
46342
46342
|
return {
|
|
@@ -46399,6 +46399,8 @@ class BrokerClient {
|
|
|
46399
46399
|
pushHandlers = new Set;
|
|
46400
46400
|
pushBuffer = [];
|
|
46401
46401
|
listPeersResolvers = [];
|
|
46402
|
+
sessionPubkey = null;
|
|
46403
|
+
sessionSecretKey = null;
|
|
46402
46404
|
closed = false;
|
|
46403
46405
|
reconnectAttempt = 0;
|
|
46404
46406
|
helloTimer = null;
|
|
@@ -46427,14 +46429,18 @@ class BrokerClient {
|
|
|
46427
46429
|
this.ws = ws;
|
|
46428
46430
|
return new Promise((resolve, reject) => {
|
|
46429
46431
|
const onOpen = async () => {
|
|
46430
|
-
this.debug("ws open →
|
|
46432
|
+
this.debug("ws open → generating session keypair + signing hello");
|
|
46431
46433
|
try {
|
|
46434
|
+
const sessionKP = await generateKeypair2();
|
|
46435
|
+
this.sessionPubkey = sessionKP.publicKey;
|
|
46436
|
+
this.sessionSecretKey = sessionKP.secretKey;
|
|
46432
46437
|
const { timestamp, signature } = await signHello(this.mesh.meshId, this.mesh.memberId, this.mesh.pubkey, this.mesh.secretKey);
|
|
46433
46438
|
ws.send(JSON.stringify({
|
|
46434
46439
|
type: "hello",
|
|
46435
46440
|
meshId: this.mesh.meshId,
|
|
46436
46441
|
memberId: this.mesh.memberId,
|
|
46437
46442
|
pubkey: this.mesh.pubkey,
|
|
46443
|
+
sessionPubkey: this.sessionPubkey,
|
|
46438
46444
|
displayName: process.env.CLAUDEMESH_DISPLAY_NAME || undefined,
|
|
46439
46445
|
sessionId: `${process.pid}-${Date.now()}`,
|
|
46440
46446
|
pid: process.pid,
|
|
@@ -46498,7 +46504,7 @@ class BrokerClient {
|
|
|
46498
46504
|
let nonce;
|
|
46499
46505
|
let ciphertext;
|
|
46500
46506
|
if (isDirectTarget(targetSpec)) {
|
|
46501
|
-
const env2 = await encryptDirect(message, targetSpec, this.mesh.secretKey);
|
|
46507
|
+
const env2 = await encryptDirect(message, targetSpec, this.sessionSecretKey ?? this.mesh.secretKey);
|
|
46502
46508
|
nonce = env2.nonce;
|
|
46503
46509
|
ciphertext = env2.ciphertext;
|
|
46504
46510
|
} else {
|
|
@@ -46622,7 +46628,7 @@ class BrokerClient {
|
|
|
46622
46628
|
const kind = senderPubkey ? "direct" : "unknown";
|
|
46623
46629
|
let plaintext = null;
|
|
46624
46630
|
if (senderPubkey && nonce && ciphertext) {
|
|
46625
|
-
plaintext = await decryptDirect({ nonce, ciphertext }, senderPubkey, this.mesh.secretKey);
|
|
46631
|
+
plaintext = await decryptDirect({ nonce, ciphertext }, senderPubkey, this.sessionSecretKey ?? this.mesh.secretKey);
|
|
46626
46632
|
}
|
|
46627
46633
|
if (plaintext === null && ciphertext && !senderPubkey) {
|
|
46628
46634
|
try {
|
|
@@ -47249,7 +47255,7 @@ function extractInviteToken(input) {
|
|
|
47249
47255
|
` + ` <raw-token>
|
|
47250
47256
|
` + `Got: "${input.slice(0, 40)}${input.length > 40 ? "…" : ""}"`);
|
|
47251
47257
|
}
|
|
47252
|
-
async function
|
|
47258
|
+
async function parseInviteLink2(link) {
|
|
47253
47259
|
const encoded = extractInviteToken(link);
|
|
47254
47260
|
let json;
|
|
47255
47261
|
try {
|
|
@@ -47298,7 +47304,7 @@ function wsToHttp(wsUrl) {
|
|
|
47298
47304
|
const httpScheme = u.protocol === "wss:" ? "https:" : "http:";
|
|
47299
47305
|
return `${httpScheme}//${u.host}`;
|
|
47300
47306
|
}
|
|
47301
|
-
async function
|
|
47307
|
+
async function enrollWithBroker2(args) {
|
|
47302
47308
|
const base = wsToHttp(args.brokerWsUrl);
|
|
47303
47309
|
const res = await fetch(`${base}/join`, {
|
|
47304
47310
|
method: "POST",
|
|
@@ -47323,7 +47329,10 @@ async function enrollWithBroker(args) {
|
|
|
47323
47329
|
|
|
47324
47330
|
// src/commands/join.ts
|
|
47325
47331
|
init_config();
|
|
47326
|
-
|
|
47332
|
+
init_env();
|
|
47333
|
+
import { writeFileSync as writeFileSync3, mkdirSync as mkdirSync3 } from "node:fs";
|
|
47334
|
+
import { join as join3, dirname as dirname3 } from "node:path";
|
|
47335
|
+
import { homedir as homedir3, hostname } from "node:os";
|
|
47327
47336
|
async function runJoin(args) {
|
|
47328
47337
|
const link = args[0];
|
|
47329
47338
|
if (!link) {
|
|
@@ -47334,18 +47343,18 @@ async function runJoin(args) {
|
|
|
47334
47343
|
}
|
|
47335
47344
|
let invite;
|
|
47336
47345
|
try {
|
|
47337
|
-
invite = await
|
|
47346
|
+
invite = await parseInviteLink2(link);
|
|
47338
47347
|
} catch (e) {
|
|
47339
47348
|
console.error(`claudemesh: ${e instanceof Error ? e.message : String(e)}`);
|
|
47340
47349
|
process.exit(1);
|
|
47341
47350
|
}
|
|
47342
47351
|
const { payload, token } = invite;
|
|
47343
47352
|
console.log(`Joining mesh "${payload.mesh_slug}" (${payload.mesh_id})…`);
|
|
47344
|
-
const keypair = await
|
|
47353
|
+
const keypair = await generateKeypair2();
|
|
47345
47354
|
const displayName = `${hostname()}-${process.pid}`;
|
|
47346
47355
|
let enroll;
|
|
47347
47356
|
try {
|
|
47348
|
-
enroll = await
|
|
47357
|
+
enroll = await enrollWithBroker2({
|
|
47349
47358
|
brokerWsUrl: payload.broker_url,
|
|
47350
47359
|
inviteToken: token,
|
|
47351
47360
|
invitePayload: payload,
|
|
@@ -47369,6 +47378,12 @@ async function runJoin(args) {
|
|
|
47369
47378
|
joinedAt: new Date().toISOString()
|
|
47370
47379
|
});
|
|
47371
47380
|
saveConfig(config2);
|
|
47381
|
+
const configDir = env.CLAUDEMESH_CONFIG_DIR ?? join3(homedir3(), ".claudemesh");
|
|
47382
|
+
const inviteFile = join3(configDir, `invite-${payload.mesh_slug}.txt`);
|
|
47383
|
+
try {
|
|
47384
|
+
mkdirSync3(dirname3(inviteFile), { recursive: true });
|
|
47385
|
+
writeFileSync3(inviteFile, link, "utf-8");
|
|
47386
|
+
} catch {}
|
|
47372
47387
|
console.log("");
|
|
47373
47388
|
console.log(`✓ Joined "${payload.mesh_slug}" as ${displayName}${enroll.alreadyMember ? " (already a member — re-enrolled with same pubkey)" : ""}`);
|
|
47374
47389
|
console.log(` member id: ${enroll.memberId}`);
|
|
@@ -47530,9 +47545,9 @@ async function runHook(args) {
|
|
|
47530
47545
|
// src/commands/launch.ts
|
|
47531
47546
|
init_config();
|
|
47532
47547
|
import { spawn } from "node:child_process";
|
|
47533
|
-
import { mkdtempSync, writeFileSync as
|
|
47548
|
+
import { mkdtempSync, writeFileSync as writeFileSync4, rmSync } from "node:fs";
|
|
47534
47549
|
import { tmpdir, hostname as hostname2 } from "node:os";
|
|
47535
|
-
import { join as
|
|
47550
|
+
import { join as join4 } from "node:path";
|
|
47536
47551
|
import { createInterface } from "node:readline";
|
|
47537
47552
|
function parseArgs(argv) {
|
|
47538
47553
|
const result = {
|
|
@@ -47652,19 +47667,27 @@ async function runLaunch(extraArgs) {
|
|
|
47652
47667
|
mesh = await pickMesh(config2.meshes);
|
|
47653
47668
|
}
|
|
47654
47669
|
const displayName = args.name ?? `${hostname2()}-${process.pid}`;
|
|
47655
|
-
const tmpDir = mkdtempSync(
|
|
47670
|
+
const tmpDir = mkdtempSync(join4(tmpdir(), "claudemesh-"));
|
|
47656
47671
|
const sessionConfig = {
|
|
47657
47672
|
version: 1,
|
|
47658
47673
|
meshes: [mesh]
|
|
47659
47674
|
};
|
|
47660
|
-
|
|
47675
|
+
writeFileSync4(join4(tmpDir, "config.json"), JSON.stringify(sessionConfig, null, 2) + `
|
|
47661
47676
|
`, "utf-8");
|
|
47662
47677
|
if (!args.quiet)
|
|
47663
47678
|
printBanner(displayName, mesh.slug);
|
|
47679
|
+
const filtered = [];
|
|
47680
|
+
for (let i = 0;i < args.claudeArgs.length; i++) {
|
|
47681
|
+
if (args.claudeArgs[i] === "--dangerously-load-development-channels") {
|
|
47682
|
+
i++;
|
|
47683
|
+
continue;
|
|
47684
|
+
}
|
|
47685
|
+
filtered.push(args.claudeArgs[i]);
|
|
47686
|
+
}
|
|
47664
47687
|
const claudeArgs = [
|
|
47665
47688
|
"--dangerously-load-development-channels",
|
|
47666
47689
|
"server:claudemesh",
|
|
47667
|
-
...
|
|
47690
|
+
...filtered
|
|
47668
47691
|
];
|
|
47669
47692
|
const isWindows = process.platform === "win32";
|
|
47670
47693
|
const child = spawn("claude", claudeArgs, {
|
|
@@ -47714,7 +47737,7 @@ init_config();
|
|
|
47714
47737
|
// package.json
|
|
47715
47738
|
var package_default = {
|
|
47716
47739
|
name: "claudemesh-cli",
|
|
47717
|
-
version: "0.1.
|
|
47740
|
+
version: "0.1.10",
|
|
47718
47741
|
description: "Claude Code MCP client for claudemesh — peer mesh messaging between Claude sessions.",
|
|
47719
47742
|
keywords: [
|
|
47720
47743
|
"claude-code",
|
|
@@ -47864,8 +47887,8 @@ async function runStatus() {
|
|
|
47864
47887
|
// src/commands/doctor.ts
|
|
47865
47888
|
init_config();
|
|
47866
47889
|
import { existsSync as existsSync4, readFileSync as readFileSync3, statSync as statSync2 } from "node:fs";
|
|
47867
|
-
import { homedir as
|
|
47868
|
-
import { join as
|
|
47890
|
+
import { homedir as homedir4, platform as platform2 } from "node:os";
|
|
47891
|
+
import { join as join5 } from "node:path";
|
|
47869
47892
|
import { spawnSync as spawnSync2 } from "node:child_process";
|
|
47870
47893
|
function checkNode() {
|
|
47871
47894
|
const major = Number(process.versions.node.split(".")[0]);
|
|
@@ -47889,7 +47912,7 @@ function checkClaudeOnPath() {
|
|
|
47889
47912
|
};
|
|
47890
47913
|
}
|
|
47891
47914
|
function checkMcpRegistered() {
|
|
47892
|
-
const claudeConfig =
|
|
47915
|
+
const claudeConfig = join5(homedir4(), ".claude.json");
|
|
47893
47916
|
if (!existsSync4(claudeConfig)) {
|
|
47894
47917
|
return {
|
|
47895
47918
|
name: "claudemesh MCP registered in ~/.claude.json",
|
|
@@ -47915,7 +47938,7 @@ function checkMcpRegistered() {
|
|
|
47915
47938
|
}
|
|
47916
47939
|
}
|
|
47917
47940
|
function checkHooksRegistered() {
|
|
47918
|
-
const settings =
|
|
47941
|
+
const settings = join5(homedir4(), ".claude", "settings.json");
|
|
47919
47942
|
if (!existsSync4(settings)) {
|
|
47920
47943
|
return {
|
|
47921
47944
|
name: "Status hooks registered in ~/.claude/settings.json",
|
|
@@ -48046,10 +48069,10 @@ async function runDoctor() {
|
|
|
48046
48069
|
// src/commands/welcome.ts
|
|
48047
48070
|
init_config();
|
|
48048
48071
|
import { existsSync as existsSync5, readFileSync as readFileSync4 } from "node:fs";
|
|
48049
|
-
import { homedir as
|
|
48050
|
-
import { join as
|
|
48072
|
+
import { homedir as homedir5 } from "node:os";
|
|
48073
|
+
import { join as join6 } from "node:path";
|
|
48051
48074
|
function detectState() {
|
|
48052
|
-
const claudeConfig =
|
|
48075
|
+
const claudeConfig = join6(homedir5(), ".claude.json");
|
|
48053
48076
|
let mcpRegistered = false;
|
|
48054
48077
|
if (existsSync5(claudeConfig)) {
|
|
48055
48078
|
try {
|