@eyeclaw/eyeclaw 2.3.4 → 2.3.6

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.4",
3
+ "version": "2.3.6",
4
4
  "description": "EyeClaw plugin for OpenClaw - HTTP SSE streaming + WebSocket client",
5
5
  "type": "module",
6
6
  "main": "./index.ts",
package/src/types.ts CHANGED
@@ -20,3 +20,18 @@ export interface BotStatus {
20
20
  total_sessions: number
21
21
  uptime: number
22
22
  }
23
+
24
+ export interface WebSocketMessage {
25
+ type: string
26
+ command?: string
27
+ params?: {
28
+ message?: string
29
+ [key: string]: any
30
+ }
31
+ metadata?: {
32
+ session_id?: string
33
+ source?: string
34
+ [key: string]: any
35
+ }
36
+ [key: string]: any
37
+ }
@@ -161,23 +161,28 @@ export class EyeClawWebSocketClient {
161
161
  * 处理命令消息
162
162
  */
163
163
  private async handleCommand(payload: WebSocketMessage) {
164
- const { type, message: text, session_id, command } = payload
164
+ const { type, params, metadata, command } = payload
165
165
 
166
166
  // 只处理 execute_command 类型的消息
167
167
  if (type !== 'execute_command' && type !== 'chat') {
168
168
  return
169
169
  }
170
-
171
- const userMessage = text || command
170
+
171
+ // params.message command 提取用户消息
172
+ const userMessage = params?.message || command
172
173
  if (!userMessage) {
173
174
  this.api.logger.warn('[EyeClaw] No message content')
174
175
  return
175
176
  }
176
-
177
+
178
+ // 从 metadata 提取 session_id
179
+ const sessionId = metadata?.session_id
180
+
177
181
  this.api.logger.info(`[EyeClaw] Processing: ${userMessage.substring(0, 50)}...`)
182
+ this.api.logger.info(`[EyeClaw] Session ID: ${sessionId}`)
178
183
 
179
184
  // 通过 OpenClaw API 处理消息,获取流式响应
180
- await this.processWithOpenClaw(userMessage, session_id)
185
+ await this.processWithOpenClaw(userMessage, sessionId)
181
186
  }
182
187
 
183
188
  /**
@@ -265,6 +270,8 @@ export class EyeClawWebSocketClient {
265
270
  // stream_end 事件:流结束(由 HTTP handler 发送)
266
271
  if (currentEvent === 'stream_end') {
267
272
  this.api.logger.info(`[EyeClaw] Stream ended: ${eventData.stream_id}`)
273
+ // 通知 Rails 流已结束
274
+ this.sendMessage('stream_end', { session_id: sessionId })
268
275
  }
269
276
 
270
277
  // stream_error 事件:错误