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 event = payload?.event;
5265
- if (event === "delta") {
5266
- const delta = payload.text ?? "";
5267
- session.accumulatedText += delta;
5268
- this._send({
5269
- type: "studio_reply",
5270
- sessionId,
5271
- taskId: session.taskId,
5272
- text: delta,
5273
- done: false
5274
- }).catch(() => {
5275
- });
5276
- } else if (event === "done" || event === "final") {
5277
- const finalText = payload.text ?? session.accumulatedText;
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 (event === "error") {
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
@@ -4,7 +4,7 @@ import {
4
4
  InstallHandler,
5
5
  RelayAgent,
6
6
  StudioHandler
7
- } from "./chunk-H67DFP5T.js";
7
+ } from "./chunk-F3E5E3ZS.js";
8
8
  import "./chunk-STI2237I.js";
9
9
 
10
10
  // src/service/platform.ts
package/dist/index.js CHANGED
@@ -17,7 +17,7 @@ import {
17
17
  StudioHandler,
18
18
  TokenDiscovery,
19
19
  buildAppRequestPrompt
20
- } from "./chunk-H67DFP5T.js";
20
+ } from "./chunk-F3E5E3ZS.js";
21
21
  import {
22
22
  SessionStore
23
23
  } from "./chunk-STI2237I.js";
@@ -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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "echoclaw-relay-agent",
3
- "version": "0.23.2",
3
+ "version": "0.23.3",
4
4
  "description": "EchoClaw Relay Connection — E2E encrypted relay transport, pairing, and session management",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",