claudemesh-cli 1.0.0-alpha.35 → 1.0.0-alpha.36
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 +43 -51
- package/dist/entrypoints/cli.js.map +8 -8
- package/dist/entrypoints/mcp.js +23 -19
- package/dist/entrypoints/mcp.js.map +4 -4
- package/package.json +1 -1
package/dist/entrypoints/cli.js
CHANGED
|
@@ -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.
|
|
91
|
+
var URLS, VERSION = "1.0.0-alpha.36", env;
|
|
92
92
|
var init_urls = __esm(() => {
|
|
93
93
|
URLS = {
|
|
94
94
|
BROKER: process.env.CLAUDEMESH_BROKER_URL ?? "wss://ic.claudemesh.com/ws",
|
|
@@ -1132,6 +1132,7 @@ class BrokerClient {
|
|
|
1132
1132
|
outbound = [];
|
|
1133
1133
|
pushHandlers = new Set;
|
|
1134
1134
|
pushBuffer = [];
|
|
1135
|
+
pushChain = Promise.resolve();
|
|
1135
1136
|
listPeersResolvers = new Map;
|
|
1136
1137
|
stateResolvers = new Map;
|
|
1137
1138
|
stateListResolvers = new Map;
|
|
@@ -2496,7 +2497,7 @@ class BrokerClient {
|
|
|
2496
2497
|
const nonce = String(msg.nonce ?? "");
|
|
2497
2498
|
const ciphertext = String(msg.ciphertext ?? "");
|
|
2498
2499
|
const senderPubkey = String(msg.senderPubkey ?? "");
|
|
2499
|
-
(async () => {
|
|
2500
|
+
this.pushChain = this.pushChain.then(async () => {
|
|
2500
2501
|
const isSystem = msg.subtype === "system" || senderPubkey === "system";
|
|
2501
2502
|
const kind = isSystem ? "broadcast" : senderPubkey ? "direct" : "unknown";
|
|
2502
2503
|
let plaintext = null;
|
|
@@ -2573,7 +2574,9 @@ class BrokerClient {
|
|
|
2573
2574
|
h(push);
|
|
2574
2575
|
} catch {}
|
|
2575
2576
|
}
|
|
2576
|
-
})()
|
|
2577
|
+
}).catch((e) => {
|
|
2578
|
+
this.debug(`push handler chain error: ${e instanceof Error ? e.message : e}`);
|
|
2579
|
+
});
|
|
2577
2580
|
return;
|
|
2578
2581
|
}
|
|
2579
2582
|
if (msg.type === "state_result") {
|
|
@@ -3019,11 +3022,17 @@ class BrokerClient {
|
|
|
3019
3022
|
send();
|
|
3020
3023
|
}
|
|
3021
3024
|
scheduleReconnect() {
|
|
3025
|
+
if (this.reconnectTimer) {
|
|
3026
|
+
this.debug("reconnect already scheduled — skipping");
|
|
3027
|
+
return;
|
|
3028
|
+
}
|
|
3022
3029
|
this.setConnStatus("reconnecting");
|
|
3023
|
-
const
|
|
3030
|
+
const base = BACKOFF_CAPS[Math.min(this.reconnectAttempt, BACKOFF_CAPS.length - 1)];
|
|
3031
|
+
const delay = Math.floor(Math.random() * base);
|
|
3024
3032
|
this.reconnectAttempt += 1;
|
|
3025
|
-
this.debug(`reconnect in ${delay}ms (attempt ${this.reconnectAttempt})`);
|
|
3033
|
+
this.debug(`reconnect in ${delay}ms (attempt ${this.reconnectAttempt}, base ${base}ms)`);
|
|
3026
3034
|
this.reconnectTimer = setTimeout(() => {
|
|
3035
|
+
this.reconnectTimer = null;
|
|
3027
3036
|
if (this.closed)
|
|
3028
3037
|
return;
|
|
3029
3038
|
this.connect().catch((e) => {
|
|
@@ -4108,19 +4117,13 @@ async function createMesh2(name, opts) {
|
|
|
4108
4117
|
const auth = getStoredToken();
|
|
4109
4118
|
if (!auth)
|
|
4110
4119
|
throw new Error("Not signed in");
|
|
4111
|
-
let userId = "";
|
|
4112
|
-
try {
|
|
4113
|
-
const payload = JSON.parse(Buffer.from(auth.session_token.split(".")[1], "base64url").toString());
|
|
4114
|
-
userId = payload.sub ?? "";
|
|
4115
|
-
} catch {}
|
|
4116
|
-
if (!userId)
|
|
4117
|
-
throw new Error("Invalid token — run `claudemesh login` again");
|
|
4118
4120
|
const kp = await generateKeypair3();
|
|
4119
4121
|
const result = await request({
|
|
4120
4122
|
path: "/cli/mesh/create",
|
|
4121
4123
|
method: "POST",
|
|
4122
|
-
body: {
|
|
4123
|
-
baseUrl: BROKER_HTTP2
|
|
4124
|
+
body: { name, pubkey: kp.publicKey, ...opts },
|
|
4125
|
+
baseUrl: BROKER_HTTP2,
|
|
4126
|
+
token: auth.session_token
|
|
4124
4127
|
});
|
|
4125
4128
|
const mesh = {
|
|
4126
4129
|
meshId: result.id,
|
|
@@ -4262,18 +4265,12 @@ async function generateInvite(meshSlug, opts) {
|
|
|
4262
4265
|
const auth = getStoredToken();
|
|
4263
4266
|
if (!auth)
|
|
4264
4267
|
throw new Error("Not signed in");
|
|
4265
|
-
let userId = "";
|
|
4266
|
-
try {
|
|
4267
|
-
const payload = JSON.parse(Buffer.from(auth.session_token.split(".")[1], "base64url").toString());
|
|
4268
|
-
userId = payload.sub ?? "";
|
|
4269
|
-
} catch {}
|
|
4270
|
-
if (!userId)
|
|
4271
|
-
throw new Error("Invalid token");
|
|
4272
4268
|
return request({
|
|
4273
4269
|
path: `/cli/mesh/${meshSlug}/invite`,
|
|
4274
4270
|
method: "POST",
|
|
4275
|
-
body: {
|
|
4276
|
-
baseUrl: BROKER_HTTP3
|
|
4271
|
+
body: { email: opts?.email, role: opts?.role },
|
|
4272
|
+
baseUrl: BROKER_HTTP3,
|
|
4273
|
+
token: auth.session_token
|
|
4277
4274
|
});
|
|
4278
4275
|
}
|
|
4279
4276
|
var BROKER_HTTP3;
|
|
@@ -4441,9 +4438,15 @@ async function claimInviteV2(opts) {
|
|
|
4441
4438
|
const s = await ensureSodium2();
|
|
4442
4439
|
const { publicKeyB64, secretKey } = await generateX25519Keypair();
|
|
4443
4440
|
const publicKeyBytes = s.from_base64(publicKeyB64, s.base64_variants.URLSAFE_NO_PADDING);
|
|
4444
|
-
const base = opts.appBaseUrl.replace(/\/$/, "");
|
|
4445
4441
|
const code = encodeURIComponent(opts.code);
|
|
4446
|
-
const
|
|
4442
|
+
const override = process.env.CLAUDEMESH_CLAIM_URL;
|
|
4443
|
+
let url;
|
|
4444
|
+
if (override) {
|
|
4445
|
+
url = override.replace(/\{code\}/g, code);
|
|
4446
|
+
} else {
|
|
4447
|
+
const brokerBase = process.env.CLAUDEMESH_BROKER_HTTP ?? "https://ic.claudemesh.com";
|
|
4448
|
+
url = `${brokerBase.replace(/\/$/, "")}/invites/${code}/claim`;
|
|
4449
|
+
}
|
|
4447
4450
|
let res;
|
|
4448
4451
|
try {
|
|
4449
4452
|
res = await fetch(url, {
|
|
@@ -4672,18 +4675,12 @@ async function runList() {
|
|
|
4672
4675
|
let serverMeshes = [];
|
|
4673
4676
|
if (auth) {
|
|
4674
4677
|
try {
|
|
4675
|
-
|
|
4676
|
-
|
|
4677
|
-
|
|
4678
|
-
|
|
4679
|
-
}
|
|
4680
|
-
|
|
4681
|
-
const res = await request({
|
|
4682
|
-
path: `/cli/meshes?user_id=${userId}`,
|
|
4683
|
-
baseUrl: BROKER_HTTP4
|
|
4684
|
-
});
|
|
4685
|
-
serverMeshes = res.meshes ?? [];
|
|
4686
|
-
}
|
|
4678
|
+
const res = await request({
|
|
4679
|
+
path: `/cli/meshes`,
|
|
4680
|
+
baseUrl: BROKER_HTTP4,
|
|
4681
|
+
token: auth.session_token
|
|
4682
|
+
});
|
|
4683
|
+
serverMeshes = res.meshes ?? [];
|
|
4687
4684
|
} catch {}
|
|
4688
4685
|
}
|
|
4689
4686
|
const localSlugs = new Set(config.meshes.map((m) => m.slug));
|
|
@@ -8611,21 +8608,13 @@ async function syncToBroker(meshSlug, grants) {
|
|
|
8611
8608
|
const auth = getStoredToken();
|
|
8612
8609
|
if (!auth)
|
|
8613
8610
|
return;
|
|
8614
|
-
let userId = "";
|
|
8615
|
-
try {
|
|
8616
|
-
const payload = JSON.parse(Buffer.from(auth.session_token.split(".")[1], "base64url").toString());
|
|
8617
|
-
userId = payload.sub ?? "";
|
|
8618
|
-
} catch {
|
|
8619
|
-
return;
|
|
8620
|
-
}
|
|
8621
|
-
if (!userId)
|
|
8622
|
-
return;
|
|
8623
8611
|
try {
|
|
8624
8612
|
await request({
|
|
8625
8613
|
path: `/cli/mesh/${meshSlug}/grants`,
|
|
8626
8614
|
method: "POST",
|
|
8627
|
-
body: {
|
|
8628
|
-
baseUrl: BROKER_HTTP7
|
|
8615
|
+
body: { grants },
|
|
8616
|
+
baseUrl: BROKER_HTTP7,
|
|
8617
|
+
token: auth.session_token
|
|
8629
8618
|
});
|
|
8630
8619
|
} catch (e) {
|
|
8631
8620
|
render.warn(`broker grant sync failed — client filter still active: ${e instanceof Error ? e.message : e}`);
|
|
@@ -8654,8 +8643,11 @@ function resolveCaps(input) {
|
|
|
8654
8643
|
async function resolvePeer(meshSlug, name) {
|
|
8655
8644
|
return await withMesh({ meshSlug }, async (client) => {
|
|
8656
8645
|
const peers = await client.listPeers();
|
|
8657
|
-
const match = peers.find((p) => p.displayName === name || p.pubkey === name || p.pubkey.startsWith(name));
|
|
8658
|
-
|
|
8646
|
+
const match = peers.find((p) => p.displayName === name || p.pubkey === name || p.pubkey.startsWith(name) || p.memberPubkey === name || p.memberPubkey && p.memberPubkey.startsWith(name));
|
|
8647
|
+
if (!match)
|
|
8648
|
+
return null;
|
|
8649
|
+
const key = match.memberPubkey ?? match.pubkey;
|
|
8650
|
+
return { displayName: match.displayName, pubkey: key };
|
|
8659
8651
|
});
|
|
8660
8652
|
}
|
|
8661
8653
|
function pickMesh2(slug) {
|
|
@@ -12489,4 +12481,4 @@ main().catch((err) => {
|
|
|
12489
12481
|
process.exit(EXIT.INTERNAL_ERROR);
|
|
12490
12482
|
});
|
|
12491
12483
|
|
|
12492
|
-
//# debugId=
|
|
12484
|
+
//# debugId=7F65AA4EF7F0222264756E2164756E21
|