@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 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
- if (stream === "tool") {
436
- // Check if this tool call has finished with a result
437
- // data structure: { name, input, output, status, toolCallId }
438
- if (data?.status === "completed" || data?.output) {
439
- logger?.info?.(`[Dragon] Tool execution completed: ${data.name}. Syncing telemetry...`);
440
- // 1. Report to Orchestrator (Async)
441
- const accountId = sessionKey.split(':')[2] || "default";
442
- try {
443
- // We need the config to get orchestratorUrl
444
- const cfg = api.runtime?.cfg;
445
- if (cfg) {
446
- const account = entry.resolveAccount(cfg, accountId);
447
- if (account?.orchestratorUrl) {
448
- const telemetryUrl = `${account.orchestratorUrl}/api/agents/${agentId}/messages/reply`;
449
- void fetch(telemetryUrl, {
450
- method: "POST",
451
- headers: { "Content-Type": "application/json" },
452
- body: JSON.stringify({
453
- content: `[Tool Result] ${data.name}`,
454
- metadata: {
455
- isTelemetry: true,
456
- toolName: data.name,
457
- toolInput: data.input,
458
- toolOutput: data.output,
459
- toolCallId: data.toolCallId || runId,
460
- status: data.status,
461
- stream: "tool"
462
- }
463
- }),
464
- }).catch(e => logger?.error?.(`[Dragon] Failed to sync tool telemetry: ${e.message}`));
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
- catch (e) {
469
- logger?.error?.(`[Dragon] Telemetry resolution failed: ${e.message}`);
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,
@@ -2,7 +2,7 @@
2
2
  "id": "dragon",
3
3
  "name": "Dragon Workbench Channel",
4
4
  "description": "Connect OpenClaw to the Dragon agent-client workbench chat.",
5
- "version": "0.1.20",
5
+ "version": "0.1.54",
6
6
  "enabledByDefault": true,
7
7
  "activation": {
8
8
  "onCapabilities": ["hook"]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@efengx/openclaw-channel-dragon",
3
- "version": "0.1.52",
3
+ "version": "0.1.54",
4
4
  "description": "Dragon workbench channel for OpenClaw",
5
5
  "author": "feng xiang <ofengx@gmail.com>",
6
6
  "type": "module",