@clawos-dev/clawd 0.2.6 → 0.2.8-beta.1.eafa771

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.
Files changed (2) hide show
  1. package/dist/cli.cjs +22 -5
  2. package/package.json +1 -1
package/dist/cli.cjs CHANGED
@@ -16288,6 +16288,12 @@ var LocalWsServer = class {
16288
16288
  }
16289
16289
  }
16290
16290
  }
16291
+ /** 测试 / 内部探针:返回某 client 对某 session 的当前 refCount(0 表示未订阅) */
16292
+ getSubscriptionRefCount(clientId, sessionId) {
16293
+ const c = this.clients.get(clientId);
16294
+ if (!c) return 0;
16295
+ return c.handle.subscribedSessions.get(sessionId) ?? 0;
16296
+ }
16291
16297
  // 广播给所有已连接客户端(无视 session 订阅)。
16292
16298
  // 用于 daemon 级事件,例如 tunnel:exited。未通过 auth 的连接被自动跳过。
16293
16299
  broadcastAll(frame) {
@@ -16320,7 +16326,7 @@ var LocalWsServer = class {
16320
16326
  }
16321
16327
  onConnection(socket, remoteAddress) {
16322
16328
  const id = v4_default();
16323
- const subscribedSessions = /* @__PURE__ */ new Set();
16329
+ const subscribedSessions = /* @__PURE__ */ new Map();
16324
16330
  const handle = {
16325
16331
  id,
16326
16332
  subscribedSessions,
@@ -16397,14 +16403,14 @@ var LocalWsServer = class {
16397
16403
  return;
16398
16404
  }
16399
16405
  if (frame.type === "session:subscribe" && typeof frame.sessionId === "string") {
16400
- client.subscribedSessions.add(frame.sessionId);
16406
+ addSubscription(client, frame.sessionId);
16401
16407
  if (typeof frame.requestId === "string") {
16402
16408
  this.safeSend(this.clients.get(client.id).ws, { type: "subscribed", requestId: frame.requestId, sessionId: frame.sessionId });
16403
16409
  }
16404
16410
  return;
16405
16411
  }
16406
16412
  if (frame.type === "session:unsubscribe" && typeof frame.sessionId === "string") {
16407
- client.subscribedSessions.delete(frame.sessionId);
16413
+ removeSubscription(client, frame.sessionId);
16408
16414
  if (typeof frame.requestId === "string") {
16409
16415
  this.safeSend(this.clients.get(client.id).ws, { type: "unsubscribed", requestId: frame.requestId, sessionId: frame.sessionId });
16410
16416
  }
@@ -16435,6 +16441,17 @@ var LocalWsServer = class {
16435
16441
  return this.clients.size;
16436
16442
  }
16437
16443
  };
16444
+ function addSubscription(client, sessionId) {
16445
+ const cur = client.subscribedSessions.get(sessionId) ?? 0;
16446
+ client.subscribedSessions.set(sessionId, cur + 1);
16447
+ }
16448
+ function removeSubscription(client, sessionId) {
16449
+ const cur = client.subscribedSessions.get(sessionId);
16450
+ if (cur === void 0) return;
16451
+ const next = cur - 1;
16452
+ if (next <= 0) client.subscribedSessions.delete(sessionId);
16453
+ else client.subscribedSessions.set(sessionId, next);
16454
+ }
16438
16455
 
16439
16456
  // src/transport/auth.ts
16440
16457
  var AuthGate = class {
@@ -17646,11 +17663,11 @@ function buildMethodHandlers(deps) {
17646
17663
  return { response: { type: "session:events", ...response } };
17647
17664
  },
17648
17665
  "session:subscribe": async (frame, client) => {
17649
- if (typeof frame.sessionId === "string") client.subscribedSessions.add(frame.sessionId);
17666
+ if (typeof frame.sessionId === "string") addSubscription(client, frame.sessionId);
17650
17667
  return { response: { type: "subscribed", sessionId: frame.sessionId } };
17651
17668
  },
17652
17669
  "session:unsubscribe": async (frame, client) => {
17653
- if (typeof frame.sessionId === "string") client.subscribedSessions.delete(frame.sessionId);
17670
+ if (typeof frame.sessionId === "string") removeSubscription(client, frame.sessionId);
17654
17671
  return { response: { type: "unsubscribed", sessionId: frame.sessionId } };
17655
17672
  },
17656
17673
  "session:pin": async (frame) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clawos-dev/clawd",
3
- "version": "0.2.6",
3
+ "version": "0.2.8-beta.1.eafa771",
4
4
  "description": "Standalone clawd daemon — Claude Code (and future Codex) session server over WebSocket",
5
5
  "type": "module",
6
6
  "license": "MIT",