@efengx/openclaw-channel-dragon 0.5.34 → 0.5.36

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.
@@ -23,6 +23,7 @@ export declare class SseComponent implements IComponent {
23
23
  reconnectMs?: number;
24
24
  idleTimeoutMs?: number;
25
25
  });
26
+ private logContext;
26
27
  start(): Promise<void>;
27
28
  stop(): Promise<void>;
28
29
  private connect;
@@ -15,15 +15,18 @@ export class SseComponent {
15
15
  this.channel = channel;
16
16
  this.options = options;
17
17
  }
18
+ logContext() {
19
+ return `version=${this.options.version}, channelAgent=${this.options.agentId}, account=${this.options.accountId}`;
20
+ }
18
21
  async start() {
19
- this.options.logger?.info?.(`[dragon channels][SSE] component start: version=${this.options.version}, agent=${this.options.agentId}, account=${this.options.accountId}, baseUrl=${this.http.options.baseURL}`);
22
+ this.options.logger?.info?.(`[dragon channels][SSE] component start: ${this.logContext()}, baseUrl=${this.http.options.baseURL}`);
20
23
  this.options.setStatus?.({
21
24
  accountId: this.options.accountId,
22
25
  connected: false,
23
26
  lastError: null,
24
27
  });
25
28
  this.options.abortSignal?.addEventListener('abort', () => {
26
- this.options.logger?.info?.(`[dragon channels][SSE] upstream abort received: agent=${this.options.agentId}, account=${this.options.accountId}`);
29
+ this.options.logger?.info?.(`[dragon channels][SSE] upstream abort received: ${this.logContext()}`);
27
30
  void this.stop();
28
31
  }, { once: true });
29
32
  this.connect();
@@ -50,7 +53,7 @@ export class SseComponent {
50
53
  connected: false,
51
54
  lastStopAt: Date.now(),
52
55
  });
53
- this.options.logger?.info?.(`[dragon channels][SSE] component stopped: agent=${this.options.agentId}, account=${this.options.accountId}`);
56
+ this.options.logger?.info?.(`[dragon channels][SSE] component stopped: ${this.logContext()}`);
54
57
  }
55
58
  connect() {
56
59
  if (!this.shouldReconnect)
@@ -64,12 +67,12 @@ export class SseComponent {
64
67
  });
65
68
  const url = `${this.http.options.baseURL}/api/agents/events?${params.toString()}`;
66
69
  const connectionId = `${Date.now()}-${++this.connectionSeq}`;
67
- logger?.info?.(`[dragon channels][SSE] connect start: connection=${connectionId}, attempt=${this.reconnectAttempts + 1}, version=${this.options.version}, url=${url}, agent=${agentId}, account=${this.options.accountId}`);
70
+ logger?.info?.(`[dragon channels][SSE] connect start: connection=${connectionId}, attempt=${this.reconnectAttempts + 1}, ${this.logContext()}, url=${url}`);
68
71
  try {
69
72
  void this.startSseReader(url, connectionId);
70
73
  }
71
74
  catch (err) {
72
- logger?.error?.(`[dragon channels][SSE] connect init failed: connection=${connectionId}, error=${err.message}`);
75
+ logger?.error?.(`[dragon channels][SSE] connect init failed: connection=${connectionId}, ${this.logContext()}, error=${err.message}`);
73
76
  this.markDisconnected(err?.message || String(err));
74
77
  this.scheduleReconnect('init_failed');
75
78
  }
@@ -84,7 +87,7 @@ export class SseComponent {
84
87
  lastTransportActivityAt: now,
85
88
  lastError: null,
86
89
  });
87
- this.options.logger?.debug?.(`[dragon channels][SSE] transport activity: connection=${connectionId}, reason=${reason}, at=${now}`);
90
+ this.options.logger?.debug?.(`[dragon channels][SSE] transport activity: connection=${connectionId}, ${this.logContext()}, reason=${reason}, at=${now}`);
88
91
  this.armIdleWatchdog(connectionId);
89
92
  }
90
93
  armIdleWatchdog(connectionId) {
@@ -95,7 +98,7 @@ export class SseComponent {
95
98
  if (!this.shouldReconnect)
96
99
  return;
97
100
  const idleMs = Date.now() - this.lastTransportActivityAt;
98
- this.options.logger?.warn?.(`[dragon channels][SSE] idle timeout: connection=${connectionId}, idleMs=${idleMs}, timeoutMs=${timeoutMs}; aborting fetch for reconnect`);
101
+ this.options.logger?.warn?.(`[dragon channels][SSE] idle timeout: connection=${connectionId}, ${this.logContext()}, idleMs=${idleMs}, timeoutMs=${timeoutMs}; aborting fetch for reconnect`);
99
102
  this.markDisconnected(`SSE idle timeout after ${idleMs}ms`);
100
103
  this.fetchAbort?.abort();
101
104
  }, timeoutMs);
@@ -142,14 +145,14 @@ export class SseComponent {
142
145
  lastError: null,
143
146
  reconnectAttempts: 0,
144
147
  });
145
- this.options.logger?.info?.(`[dragon channels][SSE] stream established: connection=${connectionId}, agent=${this.options.agentId}, account=${this.options.accountId}`);
148
+ this.options.logger?.info?.(`[dragon channels][SSE] stream established: connection=${connectionId}, ${this.logContext()}`);
146
149
  this.armIdleWatchdog(connectionId);
147
150
  const decoder = new TextDecoder();
148
151
  let buffer = "";
149
152
  while (this.shouldReconnect) {
150
153
  const { value, done } = await reader.read();
151
154
  if (done) {
152
- this.options.logger?.warn?.(`[dragon channels][SSE] stream ended by remote: connection=${connectionId}`);
155
+ this.options.logger?.warn?.(`[dragon channels][SSE] stream ended by remote: connection=${connectionId}, ${this.logContext()}`);
153
156
  break;
154
157
  }
155
158
  this.touchTransport(connectionId, 'chunk');
@@ -165,13 +168,13 @@ export class SseComponent {
165
168
  if (cleanLine.startsWith("data: ")) {
166
169
  try {
167
170
  const data = JSON.parse(cleanLine.slice(6));
168
- this.options.logger?.debug?.(`[dragon channels][SSE] event received: connection=${connectionId}, type=${data?.type || 'unknown'}, agent=${data?.agentId || 'unknown'}`);
171
+ this.options.logger?.debug?.(`[dragon channels][SSE] event received: connection=${connectionId}, ${this.logContext()}, type=${data?.type || 'unknown'}, eventAgent=${data?.agentId || 'unknown'}`);
169
172
  void this.handleEvent(data).catch((err) => {
170
- this.options.logger?.error?.(`[dragon channels][SSE] event handling failed: connection=${connectionId}, error=${err?.message || err}`);
173
+ this.options.logger?.error?.(`[dragon channels][SSE] event handling failed: connection=${connectionId}, ${this.logContext()}, error=${err?.message || err}`);
171
174
  });
172
175
  }
173
176
  catch (e) {
174
- this.options.logger?.error?.(`[dragon channels][SSE] event JSON parse failed: connection=${connectionId}, line="${cleanLine}", error=${e?.message || e}`);
177
+ this.options.logger?.error?.(`[dragon channels][SSE] event JSON parse failed: connection=${connectionId}, ${this.logContext()}, line="${cleanLine}", error=${e?.message || e}`);
175
178
  }
176
179
  }
177
180
  }
@@ -187,7 +190,7 @@ export class SseComponent {
187
190
  const message = err?.name === 'AbortError'
188
191
  ? 'SSE fetch aborted'
189
192
  : (err?.message || String(err));
190
- this.options.logger?.warn?.(`[dragon channels][SSE] stream disconnected: connection=${connectionId}, error=${message}`);
193
+ this.options.logger?.warn?.(`[dragon channels][SSE] stream disconnected: connection=${connectionId}, ${this.logContext()}, error=${message}`);
191
194
  this.markDisconnected(message);
192
195
  this.scheduleReconnect(message);
193
196
  }
@@ -220,12 +223,12 @@ export class SseComponent {
220
223
  // 2. Handle specific types
221
224
  if (data.type === 'WORKBENCH_MESSAGE') {
222
225
  const { content, sessionId, attachments, id, msgId } = data.payload || {};
223
- logger?.info?.(`[dragon channels][Dragon Plugin] v${this.options.version} [SSE] Received from Workbench: "${content?.substring(0, 50)}${content?.length > 50 ? '...' : ''}" [Session: ${sessionId}]`);
226
+ logger?.info?.(`[dragon channels][Dragon Plugin] [SSE] Received from Workbench: ${this.logContext()}, messageAgent=${data?.agentId || 'unknown'}, "${content?.substring(0, 50)}${content?.length > 50 ? '...' : ''}" [Session: ${sessionId}]`);
224
227
  await this.channel.deliverToOpenClaw(content, sessionId, undefined, attachments, msgId || id);
225
228
  }
226
229
  else if (data.type === 'FETCH_HISTORY') {
227
230
  const { sessionId } = data.payload || {};
228
- logger?.info?.(`[dragon channels][Dragon Plugin] Triggering history sync for session: ${sessionId}`);
231
+ logger?.info?.(`[dragon channels][Dragon Plugin] [SSE] Triggering history sync: ${this.logContext()}, session=${sessionId}`);
229
232
  // Handle history sync if needed, but deliverToOpenClaw usually handles normal chat
230
233
  }
231
234
  }
@@ -244,7 +247,7 @@ export class SseComponent {
244
247
  reconnectAttempts: this.reconnectAttempts,
245
248
  lastError: reason,
246
249
  });
247
- this.options.logger?.info?.(`[dragon channels][SSE] reconnect scheduled: attempt=${this.reconnectAttempts}, delayMs=${delayMs}, reason=${reason}, agent=${this.options.agentId}, account=${this.options.accountId}`);
250
+ this.options.logger?.info?.(`[dragon channels][SSE] reconnect scheduled: attempt=${this.reconnectAttempts}, delayMs=${delayMs}, reason=${reason}, ${this.logContext()}`);
248
251
  this.reconnectTimer = setTimeout(() => {
249
252
  this.reconnectTimer = undefined;
250
253
  this.options.setStatus?.({
@@ -85,7 +85,7 @@ export class TelemetryComponent {
85
85
  if (last && last.signature === signature && now - last.timestamp < 1000) {
86
86
  return;
87
87
  }
88
- if ((payload.kind === "assistant_delta" || payload.kind === "reasoning") && last && now - last.timestamp < 350) {
88
+ if ((payload.kind === "assistant_delta" || payload.kind === "reasoning") && last && now - last.timestamp < 1500) {
89
89
  return;
90
90
  }
91
91
  this.lastProgress.set(key, { signature, timestamp: now });
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const dragonChannelPluginVersion = "0.5.34";
1
+ export declare const dragonChannelPluginVersion = "0.5.36";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const dragonChannelPluginVersion = "0.5.34";
1
+ export const dragonChannelPluginVersion = "0.5.36";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@efengx/openclaw-channel-dragon",
3
- "version": "0.5.34",
3
+ "version": "0.5.36",
4
4
  "description": "Dragon workbench channel for OpenClaw",
5
5
  "author": "feng xiang <ofengx@gmail.com>",
6
6
  "type": "module",