@cocorograph/hub-agent 0.7.43 → 0.7.44

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/package.json +1 -1
  2. package/src/ws-client.mjs +20 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocorograph/hub-agent",
3
- "version": "0.7.43",
3
+ "version": "0.7.44",
4
4
  "description": "Hub Hosted Cockpit のローカル常駐 agent。Hub と outbound WSS で接続し、ローカルの tmux/pty を中継する。",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",
package/src/ws-client.mjs CHANGED
@@ -86,6 +86,17 @@ const BUFFERED_CTRL_TYPES = new Set([
86
86
  const CTRL_BUFFER_MAX_FRAMES = 200
87
87
  const CTRL_BUFFER_MAX_AGE_MS = 30_000
88
88
 
89
+ /** SDK-P2 (2026-07-08): claude.event が「ephemeral な生成中 delta」かどうか。
90
+ * stream_event の content_block_delta (text_delta / thinking_delta) は高頻度で流れる
91
+ * ephemeral (liveText 用) であり、切断中に ctrl バッファへ積むと確定イベントを evict する。
92
+ * 確定イベント (assistant/result/user/system) と非 delta stream_event (message_start 等,
93
+ * 低頻度) はバッファ対象として残す。 */
94
+ function isEphemeralDeltaEvent(obj) {
95
+ const ev = obj?.event
96
+ if (!ev || ev.type !== "stream_event") return false
97
+ return ev.event?.type === "content_block_delta"
98
+ }
99
+
89
100
  export class WsClient extends EventEmitter {
90
101
  /**
91
102
  * @param {{ hub_url: string, agent_id: string, agent_token: string }} config
@@ -260,6 +271,15 @@ export class WsClient extends EventEmitter {
260
271
  return false
261
272
  }
262
273
  if (BUFFERED_CTRL_TYPES.has(type)) {
274
+ // SDK-P2 (2026-07-08): ephemeral な stream_event の content_block_delta (text/thinking
275
+ // delta) は ctrl バッファに積まない。切断中は生成が続くと大量の delta が流れ、200 frame
276
+ // の ctrl リングを埋め尽くして低頻度の確定イベント (assistant/result/user/system) を
277
+ // evict していた (再接続後に確定バブルが出ず「異常に遅い」S5 の真因)。delta は liveText
278
+ // 用の ephemeral で、確定 assistant イベント (これはバッファ対象) が全文を持つため、
279
+ // 切断中の delta を捨てても再接続後の表示は確定イベントで復元される。
280
+ if (type === "claude.event" && isEphemeralDeltaEvent(obj)) {
281
+ return false
282
+ }
263
283
  this._bufferCtrl(obj)
264
284
  return false
265
285
  }