@efengx/openclaw-channel-dragon 0.1.47 → 0.1.48
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 +37 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -415,6 +415,43 @@ const entry = defineChannelPluginEntry({
|
|
|
415
415
|
if (stream === "thinking" || stream === "tool" || stream === "item" || stream === "plan") {
|
|
416
416
|
// Extract agentId from sessionKey "dragon:agent-xxx:..."
|
|
417
417
|
const agentId = sessionKey.split(':')[1] || "";
|
|
418
|
+
const logger = cachedRuntime?.logger ?? cachedRuntime?.log;
|
|
419
|
+
if (stream === "tool") {
|
|
420
|
+
// Check if this tool call has finished with a result
|
|
421
|
+
// data structure: { name, input, output, status, toolCallId }
|
|
422
|
+
if (data?.status === "completed" || data?.output) {
|
|
423
|
+
logger?.info?.(`[Dragon] Tool execution completed: ${data.name}. Syncing telemetry...`);
|
|
424
|
+
// 1. Report to Orchestrator (Async)
|
|
425
|
+
const accountId = sessionKey.split(':')[2] || "default";
|
|
426
|
+
try {
|
|
427
|
+
// We need the config to get orchestratorUrl
|
|
428
|
+
const cfg = api.runtime?.cfg;
|
|
429
|
+
if (cfg) {
|
|
430
|
+
const account = entry.resolveAccount(cfg, accountId);
|
|
431
|
+
if (account?.orchestratorUrl) {
|
|
432
|
+
const telemetryUrl = `${account.orchestratorUrl}/api/agents/${agentId}/messages/reply`;
|
|
433
|
+
void fetch(telemetryUrl, {
|
|
434
|
+
method: "POST",
|
|
435
|
+
headers: { "Content-Type": "application/json" },
|
|
436
|
+
body: JSON.stringify({
|
|
437
|
+
content: `[Tool Call] ${data.name}\nInput: ${JSON.stringify(data.input)}\nOutput: ${typeof data.output === 'string' ? data.output : JSON.stringify(data.output)}`,
|
|
438
|
+
metadata: {
|
|
439
|
+
isTelemetry: true,
|
|
440
|
+
toolName: data.name,
|
|
441
|
+
toolCallId: data.toolCallId || runId,
|
|
442
|
+
status: data.status,
|
|
443
|
+
stream: "tool"
|
|
444
|
+
}
|
|
445
|
+
}),
|
|
446
|
+
}).catch(e => logger?.error?.(`[Dragon] Failed to sync tool telemetry: ${e.message}`));
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
catch (e) {
|
|
451
|
+
logger?.error?.(`[Dragon] Telemetry resolution failed: ${e.message}`);
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
}
|
|
418
455
|
bridgeClient.sendJson({
|
|
419
456
|
type: "agent_event",
|
|
420
457
|
channel: channelId,
|