@clawos-dev/clawd 0.2.5 → 0.2.7

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 +29 -7
  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,
@@ -16388,20 +16394,23 @@ var LocalWsServer = class {
16388
16394
  }
16389
16395
  return;
16390
16396
  }
16397
+ } else if (frame.type === "auth") {
16398
+ this.safeSend(this.clients.get(client.id).ws, { type: "auth:ok" });
16399
+ return;
16391
16400
  }
16392
16401
  if (frame.type === "ping") {
16393
16402
  this.safeSend(this.clients.get(client.id).ws, { type: "pong", at: Date.now() });
16394
16403
  return;
16395
16404
  }
16396
16405
  if (frame.type === "session:subscribe" && typeof frame.sessionId === "string") {
16397
- client.subscribedSessions.add(frame.sessionId);
16406
+ addSubscription(client, frame.sessionId);
16398
16407
  if (typeof frame.requestId === "string") {
16399
16408
  this.safeSend(this.clients.get(client.id).ws, { type: "subscribed", requestId: frame.requestId, sessionId: frame.sessionId });
16400
16409
  }
16401
16410
  return;
16402
16411
  }
16403
16412
  if (frame.type === "session:unsubscribe" && typeof frame.sessionId === "string") {
16404
- client.subscribedSessions.delete(frame.sessionId);
16413
+ removeSubscription(client, frame.sessionId);
16405
16414
  if (typeof frame.requestId === "string") {
16406
16415
  this.safeSend(this.clients.get(client.id).ws, { type: "unsubscribed", requestId: frame.requestId, sessionId: frame.sessionId });
16407
16416
  }
@@ -16432,6 +16441,17 @@ var LocalWsServer = class {
16432
16441
  return this.clients.size;
16433
16442
  }
16434
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
+ }
16435
16455
 
16436
16456
  // src/transport/auth.ts
16437
16457
  var AuthGate = class {
@@ -17366,7 +17386,7 @@ function listRecentDirs(store, limit = 50) {
17366
17386
  }
17367
17387
 
17368
17388
  // src/version.ts
17369
- var version = "0.2.1";
17389
+ var version = "0.2.6".length > 0 ? "0.2.6" : "dev";
17370
17390
 
17371
17391
  // src/index.ts
17372
17392
  async function startDaemon(config) {
@@ -17643,11 +17663,11 @@ function buildMethodHandlers(deps) {
17643
17663
  return { response: { type: "session:events", ...response } };
17644
17664
  },
17645
17665
  "session:subscribe": async (frame, client) => {
17646
- if (typeof frame.sessionId === "string") client.subscribedSessions.add(frame.sessionId);
17666
+ if (typeof frame.sessionId === "string") addSubscription(client, frame.sessionId);
17647
17667
  return { response: { type: "subscribed", sessionId: frame.sessionId } };
17648
17668
  },
17649
17669
  "session:unsubscribe": async (frame, client) => {
17650
- if (typeof frame.sessionId === "string") client.subscribedSessions.delete(frame.sessionId);
17670
+ if (typeof frame.sessionId === "string") removeSubscription(client, frame.sessionId);
17651
17671
  return { response: { type: "unsubscribed", sessionId: frame.sessionId } };
17652
17672
  },
17653
17673
  "session:pin": async (frame) => {
@@ -17755,7 +17775,9 @@ function buildMethodHandlers(deps) {
17755
17775
  const caps = await manager.getCapabilities(args.tool);
17756
17776
  return { response: { type: "capabilities:get", ...caps } };
17757
17777
  },
17758
- info: async () => ({ response: buildReadyFrame(deps) }),
17778
+ // 必须带 type:ext-clawd DaemonConnection.handleFrame 看到 frame.type 不是 string
17779
+ // 直接丢弃整帧,pending requestId 永远不会被匹配,UI 端 info 调用就一直 pending 到超时。
17780
+ info: async () => ({ response: { type: "info", ...buildReadyFrame(deps) } }),
17759
17781
  ping: async () => ({ response: { type: "pong", at: Date.now() } })
17760
17782
  };
17761
17783
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clawos-dev/clawd",
3
- "version": "0.2.5",
3
+ "version": "0.2.7",
4
4
  "description": "Standalone clawd daemon — Claude Code (and future Codex) session server over WebSocket",
5
5
  "type": "module",
6
6
  "license": "MIT",