@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.
- package/package.json +1 -1
- package/src/channel.ts +8 -38
package/package.json
CHANGED
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
|
-
|
|
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
|
-
//
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
const
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
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
|
|