@coclaw/openclaw-coclaw 0.17.8 → 0.17.9

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coclaw/openclaw-coclaw",
3
- "version": "0.17.8",
3
+ "version": "0.17.9",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "description": "OpenClaw CoClaw channel plugin for remote chat",
@@ -82,7 +82,10 @@ export class RpcSendQueue {
82
82
  }
83
83
 
84
84
  // 软上限:队列已积压到 MAX(允许之前单条溢出,但新消息从此开始拒绝)
85
- if (this.queueBytes >= MAX_QUEUE_BYTES) {
85
+ // 白名单豁免:agent run RPC 响应(顶层 type=res + payload.runId 顶层存在)
86
+ // 即使队列已满也强行入队,避免 UI 端因 phase-2 res 被 drop 而无法收到 run 终态。
87
+ // 仍受 50MB 单条硬上限约束(接收端重组上限,超过也无意义)。
88
+ if (this.queueBytes >= MAX_QUEUE_BYTES && !isAgentRunResponse(jsonStr)) {
86
89
  this.droppedCount += 1;
87
90
  this.droppedBytes += totalBytes;
88
91
  // 仅状态翻转点打 log(warn + remoteLog 各一次);overflow 持续期间所有 drop 静默累加,
@@ -189,3 +192,24 @@ export class RpcSendQueue {
189
192
  return this.tag ? ` ${this.tag}` : '';
190
193
  }
191
194
  }
195
+
196
+ /**
197
+ * 判断一条 JSON 字符串是否为带 runId 的 RPC 响应(用于队列满时白名单豁免)。
198
+ *
199
+ * 命中条件(仅看顶层):`type === 'res'` 且 `payload.runId` 为 truthy。
200
+ * 设计取舍:硬编码识别、不维护方法白名单表。该条件主要为覆盖 OpenClaw `agent` 二阶段 res
201
+ * 与 `agent.wait` 全部分支(accepted/ok/error/timeout/race/dedupe);同时也会顺带豁免
202
+ * `chat.send` 等其他顶层带 `runId` 的响应——这类 rsp 极小,加白无副作用。
203
+ * 解析失败或不命中按非白名单处理。
204
+ *
205
+ * @param {string} jsonStr - 待发送的 RPC 帧 JSON 字符串
206
+ * @returns {boolean} 命中白名单返回 true;解析失败或不命中返回 false
207
+ */
208
+ function isAgentRunResponse(jsonStr) {
209
+ try {
210
+ const parsed = JSON.parse(jsonStr);
211
+ return parsed?.type === 'res' && Boolean(parsed?.payload?.runId);
212
+ } catch {
213
+ return false;
214
+ }
215
+ }