@eyeclaw/eyeclaw 2.0.7 → 2.0.8

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/channel.ts +8 -38
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eyeclaw/eyeclaw",
3
- "version": "2.0.7",
3
+ "version": "2.0.8",
4
4
  "description": "EyeClaw channel plugin for OpenClaw - Connect your local OpenClaw instance to EyeClaw platform",
5
5
  "type": "module",
6
6
  "main": "./index.ts",
package/src/channel.ts CHANGED
@@ -191,7 +191,7 @@ export const eyeclawPlugin: ChannelPlugin<ResolvedEyeClawAccount> = {
191
191
  'agent',
192
192
  '--session-id', 'eyeclaw-web-chat',
193
193
  '--message', message,
194
- '--json'
194
+ // No --json flag: use plain text streaming output
195
195
  ])
196
196
 
197
197
  let outputBuffer = ''
@@ -205,32 +205,13 @@ export const eyeclawPlugin: ChannelPlugin<ResolvedEyeClawAccount> = {
205
205
  const text = data.toString()
206
206
  outputBuffer += text
207
207
 
208
- // For streaming text output, send each chunk immediately
209
- // Try to parse as JSON first
210
- try {
211
- const parsed = JSON.parse(outputBuffer)
212
- // If we can parse the complete JSON, extract the text
213
- const response = parsed.result?.payloads?.[0]?.text
214
- if (response) {
215
- // Send the text in chunks
216
- const chunkSize = 50 // Send ~50 chars at a time
217
- for (let i = 0; i < response.length; i += chunkSize) {
218
- const chunk = response.substring(i, i + chunkSize)
219
- client.sendStreamChunk('stream_chunk', streamId, chunk)
220
- }
221
- }
222
- outputBuffer = '' // Clear buffer after successful parse
223
- } catch (e) {
224
- // Not valid JSON yet, check if we have complete lines to send
225
- const lines = outputBuffer.split('\n')
226
- // Keep last incomplete line in buffer
227
- if (lines.length > 1) {
228
- for (let i = 0; i < lines.length - 1; i++) {
229
- if (lines[i].trim()) {
230
- client.sendStreamChunk('stream_chunk', streamId, lines[i] + '\n')
231
- }
232
- }
233
- outputBuffer = lines[lines.length - 1]
208
+ // Send text chunks as they arrive (real-time streaming)
209
+ const lines = text.split('\n')
210
+ for (const line of lines) {
211
+ const trimmed = line.trim()
212
+ if (trimmed && !trimmed.startsWith('{') && !trimmed.startsWith('[')) {
213
+ // Skip JSON-like lines, send only plain text
214
+ client.sendStreamChunk('stream_chunk', streamId, line + '\n')
234
215
  }
235
216
  }
236
217
  } catch (error) {
@@ -251,17 +232,6 @@ export const eyeclawPlugin: ChannelPlugin<ResolvedEyeClawAccount> = {
251
232
  // Handle process completion
252
233
  agentProcess.on('close', (code: number) => {
253
234
  try {
254
- // Send any remaining buffered content
255
- if (outputBuffer.trim()) {
256
- try {
257
- const parsed = JSON.parse(outputBuffer)
258
- const response = parsed.result?.payloads?.[0]?.text || outputBuffer.trim()
259
- client.sendStreamChunk('stream_chunk', streamId, response)
260
- } catch (e) {
261
- client.sendStreamChunk('stream_chunk', streamId, outputBuffer.trim())
262
- }
263
- }
264
-
265
235
  // Send stream_end event
266
236
  client.sendStreamChunk('stream_end', streamId, '')
267
237