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/mcp.js
CHANGED
|
@@ -1299,6 +1299,7 @@ class BrokerClient {
|
|
|
1299
1299
|
outbound = [];
|
|
1300
1300
|
pushHandlers = new Set;
|
|
1301
1301
|
pushBuffer = [];
|
|
1302
|
+
pushChain = Promise.resolve();
|
|
1302
1303
|
listPeersResolvers = new Map;
|
|
1303
1304
|
stateResolvers = new Map;
|
|
1304
1305
|
stateListResolvers = new Map;
|
|
@@ -2646,10 +2647,9 @@ class BrokerClient {
|
|
|
2646
2647
|
if (msg.type === "ack") {
|
|
2647
2648
|
const pending = this.pendingSends.get(String(msg.id ?? ""));
|
|
2648
2649
|
if (pending) {
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
});
|
|
2650
|
+
const queued = msg.queued !== false;
|
|
2651
|
+
const errStr = typeof msg.error === "string" ? msg.error : undefined;
|
|
2652
|
+
pending.resolve(queued ? { ok: true, messageId: String(msg.messageId ?? "") } : { ok: false, error: errStr ?? "broker rejected send" });
|
|
2653
2653
|
this.pendingSends.delete(pending.id);
|
|
2654
2654
|
}
|
|
2655
2655
|
return;
|
|
@@ -2664,7 +2664,7 @@ class BrokerClient {
|
|
|
2664
2664
|
const nonce = String(msg.nonce ?? "");
|
|
2665
2665
|
const ciphertext = String(msg.ciphertext ?? "");
|
|
2666
2666
|
const senderPubkey = String(msg.senderPubkey ?? "");
|
|
2667
|
-
(async () => {
|
|
2667
|
+
this.pushChain = this.pushChain.then(async () => {
|
|
2668
2668
|
const isSystem = msg.subtype === "system" || senderPubkey === "system";
|
|
2669
2669
|
const kind = isSystem ? "broadcast" : senderPubkey ? "direct" : "unknown";
|
|
2670
2670
|
let plaintext = null;
|
|
@@ -2741,7 +2741,9 @@ class BrokerClient {
|
|
|
2741
2741
|
h(push);
|
|
2742
2742
|
} catch {}
|
|
2743
2743
|
}
|
|
2744
|
-
})()
|
|
2744
|
+
}).catch((e) => {
|
|
2745
|
+
this.debug(`push handler chain error: ${e instanceof Error ? e.message : e}`);
|
|
2746
|
+
});
|
|
2745
2747
|
return;
|
|
2746
2748
|
}
|
|
2747
2749
|
if (msg.type === "state_result") {
|
|
@@ -3187,11 +3189,17 @@ class BrokerClient {
|
|
|
3187
3189
|
send();
|
|
3188
3190
|
}
|
|
3189
3191
|
scheduleReconnect() {
|
|
3192
|
+
if (this.reconnectTimer) {
|
|
3193
|
+
this.debug("reconnect already scheduled — skipping");
|
|
3194
|
+
return;
|
|
3195
|
+
}
|
|
3190
3196
|
this.setConnStatus("reconnecting");
|
|
3191
|
-
const
|
|
3197
|
+
const base = BACKOFF_CAPS[Math.min(this.reconnectAttempt, BACKOFF_CAPS.length - 1)];
|
|
3198
|
+
const delay = Math.floor(Math.random() * base);
|
|
3192
3199
|
this.reconnectAttempt += 1;
|
|
3193
|
-
this.debug(`reconnect in ${delay}ms (attempt ${this.reconnectAttempt})`);
|
|
3200
|
+
this.debug(`reconnect in ${delay}ms (attempt ${this.reconnectAttempt}, base ${base}ms)`);
|
|
3194
3201
|
this.reconnectTimer = setTimeout(() => {
|
|
3202
|
+
this.reconnectTimer = null;
|
|
3195
3203
|
if (this.closed)
|
|
3196
3204
|
return;
|
|
3197
3205
|
this.connect().catch((e) => {
|
|
@@ -3494,7 +3502,7 @@ __export(exports_urls, {
|
|
|
3494
3502
|
VERSION: () => VERSION,
|
|
3495
3503
|
URLS: () => URLS
|
|
3496
3504
|
});
|
|
3497
|
-
var URLS, VERSION = "1.0.0-alpha.
|
|
3505
|
+
var URLS, VERSION = "1.0.0-alpha.36", env;
|
|
3498
3506
|
var init_urls = __esm(() => {
|
|
3499
3507
|
URLS = {
|
|
3500
3508
|
BROKER: process.env.CLAUDEMESH_BROKER_URL ?? "wss://ic.claudemesh.com/ws",
|
|
@@ -4174,21 +4182,13 @@ async function syncToBroker(meshSlug, grants) {
|
|
|
4174
4182
|
const auth = getStoredToken();
|
|
4175
4183
|
if (!auth)
|
|
4176
4184
|
return;
|
|
4177
|
-
let userId = "";
|
|
4178
|
-
try {
|
|
4179
|
-
const payload = JSON.parse(Buffer.from(auth.session_token.split(".")[1], "base64url").toString());
|
|
4180
|
-
userId = payload.sub ?? "";
|
|
4181
|
-
} catch {
|
|
4182
|
-
return;
|
|
4183
|
-
}
|
|
4184
|
-
if (!userId)
|
|
4185
|
-
return;
|
|
4186
4185
|
try {
|
|
4187
4186
|
await request({
|
|
4188
4187
|
path: `/cli/mesh/${meshSlug}/grants`,
|
|
4189
4188
|
method: "POST",
|
|
4190
|
-
body: {
|
|
4191
|
-
baseUrl: BROKER_HTTP2
|
|
4189
|
+
body: { grants },
|
|
4190
|
+
baseUrl: BROKER_HTTP2,
|
|
4191
|
+
token: auth.session_token
|
|
4192
4192
|
});
|
|
4193
4193
|
} catch (e) {
|
|
4194
4194
|
render.warn(`broker grant sync failed — client filter still active: ${e instanceof Error ? e.message : e}`);
|
|
@@ -4217,8 +4217,11 @@ function resolveCaps(input) {
|
|
|
4217
4217
|
async function resolvePeer(meshSlug, name) {
|
|
4218
4218
|
return await withMesh({ meshSlug }, async (client) => {
|
|
4219
4219
|
const peers = await client.listPeers();
|
|
4220
|
-
const match = peers.find((p) => p.displayName === name || p.pubkey === name || p.pubkey.startsWith(name));
|
|
4221
|
-
|
|
4220
|
+
const match = peers.find((p) => p.displayName === name || p.pubkey === name || p.pubkey.startsWith(name) || p.memberPubkey === name || p.memberPubkey && p.memberPubkey.startsWith(name));
|
|
4221
|
+
if (!match)
|
|
4222
|
+
return null;
|
|
4223
|
+
const key = match.memberPubkey ?? match.pubkey;
|
|
4224
|
+
return { displayName: match.displayName, pubkey: key };
|
|
4222
4225
|
});
|
|
4223
4226
|
}
|
|
4224
4227
|
function pickMesh2(slug) {
|
|
@@ -6533,4 +6536,4 @@ startMcpServer().catch((err) => {
|
|
|
6533
6536
|
process.exit(1);
|
|
6534
6537
|
});
|
|
6535
6538
|
|
|
6536
|
-
//# debugId=
|
|
6539
|
+
//# debugId=F940F8787F28151764756E2164756E21
|