echoclaw-relay-agent 0.23.2 → 0.23.3
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.
|
@@ -5261,20 +5261,24 @@ var StudioHandler = class {
|
|
|
5261
5261
|
_handleAIEvent(sessionId, payload) {
|
|
5262
5262
|
const session = this._activeSessions.get(sessionId);
|
|
5263
5263
|
if (!session) return;
|
|
5264
|
-
const
|
|
5265
|
-
|
|
5266
|
-
|
|
5267
|
-
session.accumulatedText
|
|
5268
|
-
|
|
5269
|
-
|
|
5270
|
-
|
|
5271
|
-
|
|
5272
|
-
|
|
5273
|
-
|
|
5274
|
-
|
|
5275
|
-
|
|
5276
|
-
|
|
5277
|
-
|
|
5264
|
+
const state = payload?.state;
|
|
5265
|
+
const messageText = this._extractText(payload?.message);
|
|
5266
|
+
if (state === "delta" && messageText) {
|
|
5267
|
+
const prevLen = session.accumulatedText.length;
|
|
5268
|
+
const incrementalDelta = messageText.length > prevLen ? messageText.slice(prevLen) : messageText;
|
|
5269
|
+
session.accumulatedText = messageText;
|
|
5270
|
+
if (incrementalDelta) {
|
|
5271
|
+
this._send({
|
|
5272
|
+
type: "studio_reply",
|
|
5273
|
+
sessionId,
|
|
5274
|
+
taskId: session.taskId,
|
|
5275
|
+
text: incrementalDelta,
|
|
5276
|
+
done: false
|
|
5277
|
+
}).catch(() => {
|
|
5278
|
+
});
|
|
5279
|
+
}
|
|
5280
|
+
} else if (state === "final") {
|
|
5281
|
+
const finalText = messageText || session.accumulatedText;
|
|
5278
5282
|
this._send({
|
|
5279
5283
|
type: "studio_reply",
|
|
5280
5284
|
sessionId,
|
|
@@ -5288,14 +5292,16 @@ var StudioHandler = class {
|
|
|
5288
5292
|
this._runToSession.delete(session.runId);
|
|
5289
5293
|
session.runId = null;
|
|
5290
5294
|
}
|
|
5295
|
+
session.accumulatedText = "";
|
|
5291
5296
|
this._sendStatus(sessionId, session.taskId, "preview_ready", "AI response complete").catch(() => {
|
|
5292
5297
|
});
|
|
5293
|
-
} else if (
|
|
5298
|
+
} else if (state === "error") {
|
|
5294
5299
|
if (session.runId) {
|
|
5295
5300
|
this._chatHandler.unregisterExternalRun(session.runId);
|
|
5296
5301
|
this._runToSession.delete(session.runId);
|
|
5297
5302
|
session.runId = null;
|
|
5298
5303
|
}
|
|
5304
|
+
session.accumulatedText = "";
|
|
5299
5305
|
this._sendStatus(sessionId, session.taskId, "error", payload.error ?? "AI error").catch(() => {
|
|
5300
5306
|
});
|
|
5301
5307
|
}
|
|
@@ -5402,6 +5408,11 @@ var StudioHandler = class {
|
|
|
5402
5408
|
await this._atomicWrite(snapshotPath, messagesJson);
|
|
5403
5409
|
}
|
|
5404
5410
|
// ── Private: Helpers ───────────────────────────────────────────
|
|
5411
|
+
/** Extract text from OpenClaw message format (content blocks array). */
|
|
5412
|
+
_extractText(message) {
|
|
5413
|
+
if (!message?.content || !Array.isArray(message.content)) return "";
|
|
5414
|
+
return message.content.filter((block) => block?.type === "text" && typeof block.text === "string").map((block) => block.text).join("");
|
|
5415
|
+
}
|
|
5405
5416
|
async _send(msg) {
|
|
5406
5417
|
if (this._sendBack) {
|
|
5407
5418
|
await this._sendBack(msg);
|
package/dist/cli.js
CHANGED
package/dist/index.js
CHANGED
|
@@ -85,6 +85,8 @@ export declare class StudioHandler {
|
|
|
85
85
|
private _persistDraft;
|
|
86
86
|
/** Persist chat-snapshot.json to workspace. */
|
|
87
87
|
private _persistChatSnapshot;
|
|
88
|
+
/** Extract text from OpenClaw message format (content blocks array). */
|
|
89
|
+
private _extractText;
|
|
88
90
|
private _send;
|
|
89
91
|
private _sendStatus;
|
|
90
92
|
private _cleanupSession;
|
package/package.json
CHANGED