@efengx/openclaw-channel-dragon 0.1.52 → 0.1.54
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/dist/index.js +62 -33
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -428,48 +428,77 @@ const entry = defineChannelPluginEntry({
|
|
|
428
428
|
// Extract details
|
|
429
429
|
const { stream, data, runId } = evt;
|
|
430
430
|
// We care about certain streams for the UI "Thinking" status
|
|
431
|
+
// We care about certain streams for the UI "Thinking" status
|
|
431
432
|
if (stream === "thinking" || stream === "tool" || stream === "item" || stream === "plan") {
|
|
432
433
|
// Extract agentId from sessionKey "dragon:agent-xxx:..."
|
|
433
434
|
const agentId = sessionKey.split(':')[1] || "";
|
|
435
|
+
const accountId = sessionKey.split(':')[2] || "default";
|
|
434
436
|
const logger = cachedRuntime?.logger ?? cachedRuntime?.log;
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
if (
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
}
|
|
464
|
-
}
|
|
437
|
+
// 1. Report to Orchestrator (Async) for Web UI / Trajectory
|
|
438
|
+
try {
|
|
439
|
+
const cfg = api.runtime?.cfg;
|
|
440
|
+
if (cfg) {
|
|
441
|
+
const account = entry.resolveAccount(cfg, accountId);
|
|
442
|
+
if (account?.orchestratorUrl) {
|
|
443
|
+
const telemetryUrl = `${account.orchestratorUrl}/api/agents/${agentId}/messages/reply`;
|
|
444
|
+
// Decide what to send to orchestrator
|
|
445
|
+
let telemetryPayload = null;
|
|
446
|
+
if (stream === "thinking") {
|
|
447
|
+
telemetryPayload = {
|
|
448
|
+
content: "", // Content can be empty for pure reasoning update
|
|
449
|
+
metadata: { isTelemetry: true, reasoning_content: data, stream: "thinking" }
|
|
450
|
+
};
|
|
451
|
+
}
|
|
452
|
+
else if (stream === "tool" || (stream === "item" && data?.kind === "tool")) {
|
|
453
|
+
const toolName = data?.name || data?.title || "unknown tool";
|
|
454
|
+
if (data?.status === "completed" || data?.phase === "end" || data?.output) {
|
|
455
|
+
telemetryPayload = {
|
|
456
|
+
content: `[Tool Result] ${toolName}`,
|
|
457
|
+
metadata: {
|
|
458
|
+
isTelemetry: true,
|
|
459
|
+
toolName: toolName,
|
|
460
|
+
toolInput: data?.input,
|
|
461
|
+
toolOutput: data?.output || data?.summary,
|
|
462
|
+
toolCallId: data?.toolCallId || runId,
|
|
463
|
+
status: "completed",
|
|
464
|
+
stream: "tool"
|
|
465
|
+
}
|
|
466
|
+
};
|
|
467
|
+
}
|
|
468
|
+
else {
|
|
469
|
+
// Initial tool call info
|
|
470
|
+
telemetryPayload = {
|
|
471
|
+
content: `[Tool Call] ${toolName}...`,
|
|
472
|
+
metadata: {
|
|
473
|
+
isTelemetry: true,
|
|
474
|
+
toolName: toolName,
|
|
475
|
+
toolInput: data?.input,
|
|
476
|
+
status: "running",
|
|
477
|
+
stream: "tool"
|
|
478
|
+
}
|
|
479
|
+
};
|
|
465
480
|
}
|
|
466
481
|
}
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
482
|
+
else if (stream === "plan") {
|
|
483
|
+
telemetryPayload = {
|
|
484
|
+
content: `[Plan] ${data.title || "Updating steps..."}`,
|
|
485
|
+
metadata: { isTelemetry: true, data, stream: "plan" }
|
|
486
|
+
};
|
|
487
|
+
}
|
|
488
|
+
if (telemetryPayload) {
|
|
489
|
+
void fetch(telemetryUrl, {
|
|
490
|
+
method: "POST",
|
|
491
|
+
headers: { "Content-Type": "application/json" },
|
|
492
|
+
body: JSON.stringify(telemetryPayload),
|
|
493
|
+
}).catch(e => logger?.error?.(`[Dragon] Failed to sync telemetry: ${e.message}`));
|
|
494
|
+
}
|
|
470
495
|
}
|
|
471
496
|
}
|
|
472
497
|
}
|
|
498
|
+
catch (e) {
|
|
499
|
+
logger?.error?.(`[Dragon] Telemetry resolution failed: ${e.message}`);
|
|
500
|
+
}
|
|
501
|
+
// 2. Also send to local bridge (WebSocket)
|
|
473
502
|
bridgeClient.sendJson({
|
|
474
503
|
type: "agent_event",
|
|
475
504
|
channel: channelId,
|
package/openclaw.plugin.json
CHANGED