claudemesh-cli 1.0.0-alpha.36 → 1.0.0-alpha.37

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.
@@ -2444,6 +2444,22 @@ class BrokerClient {
2444
2444
  return;
2445
2445
  this.ws.send(JSON.stringify(payload));
2446
2446
  }
2447
+ async sendAndWait(payload, timeoutMs = 1e4) {
2448
+ const reqId = `rw-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
2449
+ return new Promise((resolve, reject) => {
2450
+ const timer = setTimeout(() => {
2451
+ this.genericResolvers.delete(reqId);
2452
+ reject(new Error("sendAndWait timeout"));
2453
+ }, timeoutMs);
2454
+ this.genericResolvers.set(reqId, (msg) => {
2455
+ clearTimeout(timer);
2456
+ this.genericResolvers.delete(reqId);
2457
+ resolve(msg);
2458
+ });
2459
+ this.sendRaw({ ...payload, _reqId: reqId });
2460
+ });
2461
+ }
2462
+ genericResolvers = new Map;
2447
2463
  close() {
2448
2464
  this.closed = true;
2449
2465
  this.stopStatsReporting();
@@ -2644,6 +2660,11 @@ class BrokerClient {
2644
2660
  }
2645
2661
  handleServerMessage(msg) {
2646
2662
  const msgReqId = msg._reqId;
2663
+ if (msgReqId && this.genericResolvers.has(msgReqId)) {
2664
+ const resolve = this.genericResolvers.get(msgReqId);
2665
+ resolve(msg);
2666
+ return;
2667
+ }
2647
2668
  if (msg.type === "ack") {
2648
2669
  const pending = this.pendingSends.get(String(msg.id ?? ""));
2649
2670
  if (pending) {
@@ -3502,7 +3523,7 @@ __export(exports_urls, {
3502
3523
  VERSION: () => VERSION,
3503
3524
  URLS: () => URLS
3504
3525
  });
3505
- var URLS, VERSION = "1.0.0-alpha.36", env;
3526
+ var URLS, VERSION = "1.0.0-alpha.37", env;
3506
3527
  var init_urls = __esm(() => {
3507
3528
  URLS = {
3508
3529
  BROKER: process.env.CLAUDEMESH_BROKER_URL ?? "wss://ic.claudemesh.com/ws",
@@ -6536,4 +6557,4 @@ startMcpServer().catch((err) => {
6536
6557
  process.exit(1);
6537
6558
  });
6538
6559
 
6539
- //# debugId=F940F8787F28151764756E2164756E21
6560
+ //# debugId=23BB7BF268CC536764756E2164756E21