@efengx/openclaw-channel-dragon 0.5.42 → 0.5.44
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.
|
@@ -163,8 +163,10 @@ export class ChannelComponent {
|
|
|
163
163
|
return typeof event?.result === 'string' ? event.result.trim() : '';
|
|
164
164
|
}
|
|
165
165
|
deliverToOpenClaw = async (content, sessionId = 'default', modelId, attachments, messageId) => {
|
|
166
|
-
const replyMsgId = messageId
|
|
167
|
-
|
|
166
|
+
const replyMsgId = messageId
|
|
167
|
+
? (String(messageId).startsWith('dragon_msg_') ? String(messageId) : `dragon_msg_${messageId}`)
|
|
168
|
+
: `dragon_msg_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`;
|
|
169
|
+
const isNewCmd = content?.trim() === '/new';
|
|
168
170
|
if (!isNewCmd && messageId && this.processedMessageIds.has(messageId))
|
|
169
171
|
return;
|
|
170
172
|
if (!isNewCmd && messageId) {
|
|
@@ -215,6 +217,15 @@ export class ChannelComponent {
|
|
|
215
217
|
const archivedAttachments = await this.mediaRegistry.archiveStructuredMedia(payload);
|
|
216
218
|
if (!text && !payload?.tool_calls?.length && archivedAttachments.length === 0)
|
|
217
219
|
return;
|
|
220
|
+
const stream = payload?.stream || payload?.kind || payload?.type;
|
|
221
|
+
const isToolTelemetry = stream === 'tool' ||
|
|
222
|
+
stream === 'tool_result' ||
|
|
223
|
+
stream === 'tool_call' ||
|
|
224
|
+
payload?.isTool === true ||
|
|
225
|
+
payload?.tool === true ||
|
|
226
|
+
payload?.toolName ||
|
|
227
|
+
payload?.name && (payload?.input || payload?.output || payload?.args) ||
|
|
228
|
+
payload?.tool_calls?.length;
|
|
218
229
|
await this.telemetry.reportReply({
|
|
219
230
|
content: text,
|
|
220
231
|
sessionId,
|
|
@@ -223,6 +234,14 @@ export class ChannelComponent {
|
|
|
223
234
|
attachments: archivedAttachments.length > 0 ? archivedAttachments : payload?.attachments,
|
|
224
235
|
source: "telemetry_deliver",
|
|
225
236
|
msgId: replyMsgId,
|
|
237
|
+
metadata: isToolTelemetry ? {
|
|
238
|
+
isTelemetry: true,
|
|
239
|
+
stream: 'tool',
|
|
240
|
+
toolName: payload?.toolName || payload?.name || payload?.title,
|
|
241
|
+
toolInput: payload?.input || payload?.args,
|
|
242
|
+
toolOutput: payload?.output || payload?.text || payload?.summary,
|
|
243
|
+
status: 'completed',
|
|
244
|
+
} : undefined,
|
|
226
245
|
});
|
|
227
246
|
}
|
|
228
247
|
},
|
|
@@ -256,35 +275,46 @@ export class ChannelComponent {
|
|
|
256
275
|
await progress({ kind: 'reasoning', phase: 'end', status: 'completed', title: '推理完成' });
|
|
257
276
|
},
|
|
258
277
|
onToolStart: async (payload) => {
|
|
278
|
+
const toolCallId = payload?.toolCallId || payload?.tool_call_id;
|
|
259
279
|
await progress({
|
|
260
280
|
kind: 'tool',
|
|
261
281
|
phase: payload?.phase || 'start',
|
|
262
282
|
status: 'running',
|
|
263
283
|
title: payload?.name ? `调用工具:${payload.name}` : '调用工具',
|
|
264
284
|
detail: this.stringifyProgressDetail(payload?.args),
|
|
285
|
+
toolCallId,
|
|
265
286
|
data: payload,
|
|
266
287
|
});
|
|
267
288
|
},
|
|
268
289
|
onToolResult: async (payload) => {
|
|
290
|
+
const isFailed = payload?.status === 'failed' || payload?.status === 'error' || !!payload?.error;
|
|
269
291
|
const archivedAttachments = await this.mediaRegistry.archiveStructuredMedia(payload);
|
|
292
|
+
const toolCallId = payload?.toolCallId || payload?.tool_call_id || payload?.tool;
|
|
270
293
|
await progress({
|
|
271
294
|
kind: archivedAttachments.length > 0 ? 'media' : 'tool',
|
|
272
295
|
phase: 'end',
|
|
273
|
-
status: 'completed',
|
|
274
|
-
title:
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
296
|
+
status: isFailed ? 'failed' : 'completed',
|
|
297
|
+
title: isFailed
|
|
298
|
+
? `工具执行失败:${payload?.tool || payload?.name || payload?.toolName || ''}`
|
|
299
|
+
: (archivedAttachments.length > 0 ? '媒体文件已生成' : `工具执行完成:${payload?.tool || payload?.name || payload?.toolName || ''}`),
|
|
300
|
+
detail: isFailed
|
|
301
|
+
? (payload?.error || payload?.message || this.stringifyProgressDetail(payload?.text || payload))
|
|
302
|
+
: (archivedAttachments.length > 0
|
|
303
|
+
? archivedAttachments.map((item) => item.name).join(', ')
|
|
304
|
+
: this.stringifyProgressDetail(payload?.text || payload)),
|
|
305
|
+
toolCallId,
|
|
278
306
|
data: archivedAttachments.length > 0 ? { ...payload, attachments: archivedAttachments } : payload,
|
|
279
307
|
});
|
|
280
308
|
},
|
|
281
309
|
onItemEvent: async (payload) => {
|
|
310
|
+
const toolCallId = payload?.toolCallId || payload?.tool_call_id;
|
|
282
311
|
await progress({
|
|
283
312
|
kind: payload?.kind || 'item',
|
|
284
313
|
phase: payload?.phase,
|
|
285
314
|
status: payload?.status,
|
|
286
315
|
title: payload?.title || payload?.name || '任务步骤更新',
|
|
287
316
|
detail: this.stringifyProgressDetail(payload?.progressText || payload?.summary || payload?.meta),
|
|
317
|
+
toolCallId,
|
|
288
318
|
data: payload,
|
|
289
319
|
});
|
|
290
320
|
},
|
|
@@ -465,8 +495,9 @@ export class ChannelComponent {
|
|
|
465
495
|
});
|
|
466
496
|
};
|
|
467
497
|
handleAgentEvent = async (evt) => {
|
|
468
|
-
const sessionId = evt?.
|
|
469
|
-
|
|
498
|
+
const sessionId = this.resolveWorkbenchSessionIdFromOpenClawSessionKey(evt?.sessionKey) ||
|
|
499
|
+
evt?.sessionId ||
|
|
500
|
+
'default';
|
|
470
501
|
await this.telemetry.reportEvent(evt.stream, evt.data, evt.ts, sessionId);
|
|
471
502
|
const taskCompletion = this.findTaskCompletionEvent(evt?.data);
|
|
472
503
|
if (!taskCompletion)
|
|
@@ -16,6 +16,7 @@ export declare class TelemetryComponent implements IComponent {
|
|
|
16
16
|
attachments?: any[];
|
|
17
17
|
source?: string;
|
|
18
18
|
msgId?: string;
|
|
19
|
+
metadata?: any;
|
|
19
20
|
}): Promise<void>;
|
|
20
21
|
reportEvent(stream: string, data: any, ts: number, sessionId?: string): Promise<void>;
|
|
21
22
|
reportProgress(payload: {
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const dragonChannelPluginVersion = "0.5.
|
|
1
|
+
export declare const dragonChannelPluginVersion = "0.5.44";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const dragonChannelPluginVersion = "0.5.
|
|
1
|
+
export const dragonChannelPluginVersion = "0.5.44";
|