@eyeclaw/eyeclaw 2.0.12 → 2.0.14
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 +1 -1
- package/src/client.ts +35 -2
package/package.json
CHANGED
package/src/client.ts
CHANGED
|
@@ -66,8 +66,10 @@ export class EyeClawClient {
|
|
|
66
66
|
|
|
67
67
|
private handleMessage(data: WebSocket.Data): void {
|
|
68
68
|
try {
|
|
69
|
-
const
|
|
70
|
-
|
|
69
|
+
const rawMessage = data.toString()
|
|
70
|
+
const message = JSON.parse(rawMessage)
|
|
71
|
+
this.logger.debug(`Raw message: ${rawMessage.substring(0, 200)}`)
|
|
72
|
+
this.logger.debug(`Parsed message type: ${message.type}, identifier: ${message.identifier}`)
|
|
71
73
|
|
|
72
74
|
// ActionCable protocol messages
|
|
73
75
|
if (message.type === 'ping') {
|
|
@@ -294,20 +296,51 @@ export class EyeClawClient {
|
|
|
294
296
|
}
|
|
295
297
|
|
|
296
298
|
sendLog(level: string, message: string): void {
|
|
299
|
+
// Send to BotChannel
|
|
297
300
|
this.sendChannelMessage('log', {
|
|
298
301
|
level,
|
|
299
302
|
message,
|
|
300
303
|
timestamp: new Date().toISOString(),
|
|
301
304
|
})
|
|
305
|
+
|
|
306
|
+
// Also broadcast directly to bot_{id} stream as backup
|
|
307
|
+
this.send({
|
|
308
|
+
command: 'message',
|
|
309
|
+
identifier: JSON.stringify({
|
|
310
|
+
channel: `bot_${this.config.botId}`,
|
|
311
|
+
}),
|
|
312
|
+
data: JSON.stringify({
|
|
313
|
+
action: 'log',
|
|
314
|
+
level,
|
|
315
|
+
message,
|
|
316
|
+
timestamp: new Date().toISOString(),
|
|
317
|
+
}),
|
|
318
|
+
})
|
|
302
319
|
}
|
|
303
320
|
|
|
304
321
|
sendStreamChunk(type: string, streamId: string, chunk: string): void {
|
|
322
|
+
// Send to BotChannel which will broadcast to bot_{id} for Rails to receive
|
|
305
323
|
this.sendChannelMessage('stream_chunk', {
|
|
306
324
|
type,
|
|
307
325
|
stream_id: streamId,
|
|
308
326
|
chunk,
|
|
309
327
|
timestamp: new Date().toISOString(),
|
|
310
328
|
})
|
|
329
|
+
|
|
330
|
+
// Also broadcast directly to bot_{id} stream as backup (Rails expects stream_type)
|
|
331
|
+
this.send({
|
|
332
|
+
command: 'message',
|
|
333
|
+
identifier: JSON.stringify({
|
|
334
|
+
channel: `bot_${this.config.botId}`,
|
|
335
|
+
}),
|
|
336
|
+
data: JSON.stringify({
|
|
337
|
+
action: 'stream_chunk',
|
|
338
|
+
stream_type: type, // Rails expects 'stream_type'
|
|
339
|
+
stream_id: streamId,
|
|
340
|
+
chunk,
|
|
341
|
+
timestamp: new Date().toISOString(),
|
|
342
|
+
}),
|
|
343
|
+
})
|
|
311
344
|
}
|
|
312
345
|
|
|
313
346
|
sendCommandResult(command: string, result: unknown, error?: string): void {
|