claudemesh-cli 1.0.0-alpha.34 → 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 +46 -55
- package/dist/entrypoints/cli.js.map +8 -8
- package/dist/entrypoints/mcp.js +26 -23
- 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;
|
|
@@ -2479,10 +2480,9 @@ class BrokerClient {
|
|
|
2479
2480
|
if (msg.type === "ack") {
|
|
2480
2481
|
const pending = this.pendingSends.get(String(msg.id ?? ""));
|
|
2481
2482
|
if (pending) {
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
});
|
|
2483
|
+
const queued = msg.queued !== false;
|
|
2484
|
+
const errStr = typeof msg.error === "string" ? msg.error : undefined;
|
|
2485
|
+
pending.resolve(queued ? { ok: true, messageId: String(msg.messageId ?? "") } : { ok: false, error: errStr ?? "broker rejected send" });
|
|
2486
2486
|
this.pendingSends.delete(pending.id);
|
|
2487
2487
|
}
|
|
2488
2488
|
return;
|
|
@@ -2497,7 +2497,7 @@ class BrokerClient {
|
|
|
2497
2497
|
const nonce = String(msg.nonce ?? "");
|
|
2498
2498
|
const ciphertext = String(msg.ciphertext ?? "");
|
|
2499
2499
|
const senderPubkey = String(msg.senderPubkey ?? "");
|
|
2500
|
-
(async () => {
|
|
2500
|
+
this.pushChain = this.pushChain.then(async () => {
|
|
2501
2501
|
const isSystem = msg.subtype === "system" || senderPubkey === "system";
|
|
2502
2502
|
const kind = isSystem ? "broadcast" : senderPubkey ? "direct" : "unknown";
|
|
2503
2503
|
let plaintext = null;
|
|
@@ -2574,7 +2574,9 @@ class BrokerClient {
|
|
|
2574
2574
|
h(push);
|
|
2575
2575
|
} catch {}
|
|
2576
2576
|
}
|
|
2577
|
-
})()
|
|
2577
|
+
}).catch((e) => {
|
|
2578
|
+
this.debug(`push handler chain error: ${e instanceof Error ? e.message : e}`);
|
|
2579
|
+
});
|
|
2578
2580
|
return;
|
|
2579
2581
|
}
|
|
2580
2582
|
if (msg.type === "state_result") {
|
|
@@ -3020,11 +3022,17 @@ class BrokerClient {
|
|
|
3020
3022
|
send();
|
|
3021
3023
|
}
|
|
3022
3024
|
scheduleReconnect() {
|
|
3025
|
+
if (this.reconnectTimer) {
|
|
3026
|
+
this.debug("reconnect already scheduled — skipping");
|
|
3027
|
+
return;
|
|
3028
|
+
}
|
|
3023
3029
|
this.setConnStatus("reconnecting");
|
|
3024
|
-
const
|
|
3030
|
+
const base = BACKOFF_CAPS[Math.min(this.reconnectAttempt, BACKOFF_CAPS.length - 1)];
|
|
3031
|
+
const delay = Math.floor(Math.random() * base);
|
|
3025
3032
|
this.reconnectAttempt += 1;
|
|
3026
|
-
this.debug(`reconnect in ${delay}ms (attempt ${this.reconnectAttempt})`);
|
|
3033
|
+
this.debug(`reconnect in ${delay}ms (attempt ${this.reconnectAttempt}, base ${base}ms)`);
|
|
3027
3034
|
this.reconnectTimer = setTimeout(() => {
|
|
3035
|
+
this.reconnectTimer = null;
|
|
3028
3036
|
if (this.closed)
|
|
3029
3037
|
return;
|
|
3030
3038
|
this.connect().catch((e) => {
|
|
@@ -4109,19 +4117,13 @@ async function createMesh2(name, opts) {
|
|
|
4109
4117
|
const auth = getStoredToken();
|
|
4110
4118
|
if (!auth)
|
|
4111
4119
|
throw new Error("Not signed in");
|
|
4112
|
-
let userId = "";
|
|
4113
|
-
try {
|
|
4114
|
-
const payload = JSON.parse(Buffer.from(auth.session_token.split(".")[1], "base64url").toString());
|
|
4115
|
-
userId = payload.sub ?? "";
|
|
4116
|
-
} catch {}
|
|
4117
|
-
if (!userId)
|
|
4118
|
-
throw new Error("Invalid token — run `claudemesh login` again");
|
|
4119
4120
|
const kp = await generateKeypair3();
|
|
4120
4121
|
const result = await request({
|
|
4121
4122
|
path: "/cli/mesh/create",
|
|
4122
4123
|
method: "POST",
|
|
4123
|
-
body: {
|
|
4124
|
-
baseUrl: BROKER_HTTP2
|
|
4124
|
+
body: { name, pubkey: kp.publicKey, ...opts },
|
|
4125
|
+
baseUrl: BROKER_HTTP2,
|
|
4126
|
+
token: auth.session_token
|
|
4125
4127
|
});
|
|
4126
4128
|
const mesh = {
|
|
4127
4129
|
meshId: result.id,
|
|
@@ -4263,18 +4265,12 @@ async function generateInvite(meshSlug, opts) {
|
|
|
4263
4265
|
const auth = getStoredToken();
|
|
4264
4266
|
if (!auth)
|
|
4265
4267
|
throw new Error("Not signed in");
|
|
4266
|
-
let userId = "";
|
|
4267
|
-
try {
|
|
4268
|
-
const payload = JSON.parse(Buffer.from(auth.session_token.split(".")[1], "base64url").toString());
|
|
4269
|
-
userId = payload.sub ?? "";
|
|
4270
|
-
} catch {}
|
|
4271
|
-
if (!userId)
|
|
4272
|
-
throw new Error("Invalid token");
|
|
4273
4268
|
return request({
|
|
4274
4269
|
path: `/cli/mesh/${meshSlug}/invite`,
|
|
4275
4270
|
method: "POST",
|
|
4276
|
-
body: {
|
|
4277
|
-
baseUrl: BROKER_HTTP3
|
|
4271
|
+
body: { email: opts?.email, role: opts?.role },
|
|
4272
|
+
baseUrl: BROKER_HTTP3,
|
|
4273
|
+
token: auth.session_token
|
|
4278
4274
|
});
|
|
4279
4275
|
}
|
|
4280
4276
|
var BROKER_HTTP3;
|
|
@@ -4442,9 +4438,15 @@ async function claimInviteV2(opts) {
|
|
|
4442
4438
|
const s = await ensureSodium2();
|
|
4443
4439
|
const { publicKeyB64, secretKey } = await generateX25519Keypair();
|
|
4444
4440
|
const publicKeyBytes = s.from_base64(publicKeyB64, s.base64_variants.URLSAFE_NO_PADDING);
|
|
4445
|
-
const base = opts.appBaseUrl.replace(/\/$/, "");
|
|
4446
4441
|
const code = encodeURIComponent(opts.code);
|
|
4447
|
-
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
|
+
}
|
|
4448
4450
|
let res;
|
|
4449
4451
|
try {
|
|
4450
4452
|
res = await fetch(url, {
|
|
@@ -4673,18 +4675,12 @@ async function runList() {
|
|
|
4673
4675
|
let serverMeshes = [];
|
|
4674
4676
|
if (auth) {
|
|
4675
4677
|
try {
|
|
4676
|
-
|
|
4677
|
-
|
|
4678
|
-
|
|
4679
|
-
|
|
4680
|
-
}
|
|
4681
|
-
|
|
4682
|
-
const res = await request({
|
|
4683
|
-
path: `/cli/meshes?user_id=${userId}`,
|
|
4684
|
-
baseUrl: BROKER_HTTP4
|
|
4685
|
-
});
|
|
4686
|
-
serverMeshes = res.meshes ?? [];
|
|
4687
|
-
}
|
|
4678
|
+
const res = await request({
|
|
4679
|
+
path: `/cli/meshes`,
|
|
4680
|
+
baseUrl: BROKER_HTTP4,
|
|
4681
|
+
token: auth.session_token
|
|
4682
|
+
});
|
|
4683
|
+
serverMeshes = res.meshes ?? [];
|
|
4688
4684
|
} catch {}
|
|
4689
4685
|
}
|
|
4690
4686
|
const localSlugs = new Set(config.meshes.map((m) => m.slug));
|
|
@@ -8612,21 +8608,13 @@ async function syncToBroker(meshSlug, grants) {
|
|
|
8612
8608
|
const auth = getStoredToken();
|
|
8613
8609
|
if (!auth)
|
|
8614
8610
|
return;
|
|
8615
|
-
let userId = "";
|
|
8616
|
-
try {
|
|
8617
|
-
const payload = JSON.parse(Buffer.from(auth.session_token.split(".")[1], "base64url").toString());
|
|
8618
|
-
userId = payload.sub ?? "";
|
|
8619
|
-
} catch {
|
|
8620
|
-
return;
|
|
8621
|
-
}
|
|
8622
|
-
if (!userId)
|
|
8623
|
-
return;
|
|
8624
8611
|
try {
|
|
8625
8612
|
await request({
|
|
8626
8613
|
path: `/cli/mesh/${meshSlug}/grants`,
|
|
8627
8614
|
method: "POST",
|
|
8628
|
-
body: {
|
|
8629
|
-
baseUrl: BROKER_HTTP7
|
|
8615
|
+
body: { grants },
|
|
8616
|
+
baseUrl: BROKER_HTTP7,
|
|
8617
|
+
token: auth.session_token
|
|
8630
8618
|
});
|
|
8631
8619
|
} catch (e) {
|
|
8632
8620
|
render.warn(`broker grant sync failed — client filter still active: ${e instanceof Error ? e.message : e}`);
|
|
@@ -8655,8 +8643,11 @@ function resolveCaps(input) {
|
|
|
8655
8643
|
async function resolvePeer(meshSlug, name) {
|
|
8656
8644
|
return await withMesh({ meshSlug }, async (client) => {
|
|
8657
8645
|
const peers = await client.listPeers();
|
|
8658
|
-
const match = peers.find((p) => p.displayName === name || p.pubkey === name || p.pubkey.startsWith(name));
|
|
8659
|
-
|
|
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 };
|
|
8660
8651
|
});
|
|
8661
8652
|
}
|
|
8662
8653
|
function pickMesh2(slug) {
|
|
@@ -12490,4 +12481,4 @@ main().catch((err) => {
|
|
|
12490
12481
|
process.exit(EXIT.INTERNAL_ERROR);
|
|
12491
12482
|
});
|
|
12492
12483
|
|
|
12493
|
-
//# debugId=
|
|
12484
|
+
//# debugId=7F65AA4EF7F0222264756E2164756E21
|