@eyeclaw/eyeclaw 2.3.2 → 2.3.4

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": "@eyeclaw/eyeclaw",
3
- "version": "2.3.2",
3
+ "version": "2.3.4",
4
4
  "description": "EyeClaw plugin for OpenClaw - HTTP SSE streaming + WebSocket client",
5
5
  "type": "module",
6
6
  "main": "./index.ts",
@@ -103,11 +103,17 @@ export class EyeClawWebSocketClient {
103
103
  return
104
104
  }
105
105
 
106
- // Ping/pong
106
+ // Ping/pong (协议级别的 ping,直接响应 pong)
107
107
  if (message.type === 'ping') {
108
108
  this.send({ type: 'pong' })
109
109
  return
110
110
  }
111
+
112
+ // 处理 Rails BotChannel 的 pong 响应
113
+ if (message.type === 'pong') {
114
+ this.api.logger.debug('[EyeClaw] Received pong from server')
115
+ return
116
+ }
111
117
 
112
118
  // Subscription confirmation
113
119
  if (message.type === 'confirm_subscription') {
@@ -311,7 +317,7 @@ export class EyeClawWebSocketClient {
311
317
  this.send({
312
318
  command: 'message',
313
319
  identifier: channelIdentifier,
314
- data: { type, ...data },
320
+ data: JSON.stringify({ type, ...data }),
315
321
  })
316
322
  }
317
323
 
@@ -320,7 +326,19 @@ export class EyeClawWebSocketClient {
320
326
  */
321
327
  private startPing() {
322
328
  this.pingInterval = setInterval(() => {
323
- this.send({ type: 'ping' })
329
+ // 调用 Rails BotChannel 的 ping action
330
+ const channelIdentifier = JSON.stringify({
331
+ channel: 'BotChannel',
332
+ bot_id: this.config.botId,
333
+ })
334
+
335
+ this.send({
336
+ command: 'message',
337
+ identifier: channelIdentifier,
338
+ data: JSON.stringify({
339
+ action: 'ping',
340
+ }),
341
+ })
324
342
  }, 60000) // 60秒心跳一次
325
343
  }
326
344