@efengx/openclaw-channel-dragon 0.1.47 → 0.1.49
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 +57 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -42,7 +42,26 @@ async function ensureConnection(account, runtimeLogger) {
|
|
|
42
42
|
}
|
|
43
43
|
// Instructions from Dragon Client UI
|
|
44
44
|
if (t === "hot_control") {
|
|
45
|
-
|
|
45
|
+
const { command, payload } = msg;
|
|
46
|
+
runtimeLogger?.info?.(`dragon channel: received hot control: ${command}`);
|
|
47
|
+
if (command === "switch_model" && payload && cachedRuntime) {
|
|
48
|
+
try {
|
|
49
|
+
// Use the standard OpenClaw runtime config API to set the primary model
|
|
50
|
+
// The payload should be the model ID (e.g., "google/gemini-2.0-flash")
|
|
51
|
+
cachedRuntime.config.set("agents.defaults.model.primary", payload);
|
|
52
|
+
runtimeLogger?.info?.(`[Dragon] Successfully switched primary model to: ${payload}`);
|
|
53
|
+
// Confirm back to UI
|
|
54
|
+
client.sendJson({
|
|
55
|
+
type: "hot_control_res",
|
|
56
|
+
command: "switch_model",
|
|
57
|
+
status: "ok",
|
|
58
|
+
currentModel: payload
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
catch (e) {
|
|
62
|
+
runtimeLogger?.error?.(`[Dragon] Failed to switch model: ${e.message}`);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
46
65
|
}
|
|
47
66
|
},
|
|
48
67
|
});
|
|
@@ -415,6 +434,43 @@ const entry = defineChannelPluginEntry({
|
|
|
415
434
|
if (stream === "thinking" || stream === "tool" || stream === "item" || stream === "plan") {
|
|
416
435
|
// Extract agentId from sessionKey "dragon:agent-xxx:..."
|
|
417
436
|
const agentId = sessionKey.split(':')[1] || "";
|
|
437
|
+
const logger = cachedRuntime?.logger ?? cachedRuntime?.log;
|
|
438
|
+
if (stream === "tool") {
|
|
439
|
+
// Check if this tool call has finished with a result
|
|
440
|
+
// data structure: { name, input, output, status, toolCallId }
|
|
441
|
+
if (data?.status === "completed" || data?.output) {
|
|
442
|
+
logger?.info?.(`[Dragon] Tool execution completed: ${data.name}. Syncing telemetry...`);
|
|
443
|
+
// 1. Report to Orchestrator (Async)
|
|
444
|
+
const accountId = sessionKey.split(':')[2] || "default";
|
|
445
|
+
try {
|
|
446
|
+
// We need the config to get orchestratorUrl
|
|
447
|
+
const cfg = api.runtime?.cfg;
|
|
448
|
+
if (cfg) {
|
|
449
|
+
const account = entry.resolveAccount(cfg, accountId);
|
|
450
|
+
if (account?.orchestratorUrl) {
|
|
451
|
+
const telemetryUrl = `${account.orchestratorUrl}/api/agents/${agentId}/messages/reply`;
|
|
452
|
+
void fetch(telemetryUrl, {
|
|
453
|
+
method: "POST",
|
|
454
|
+
headers: { "Content-Type": "application/json" },
|
|
455
|
+
body: JSON.stringify({
|
|
456
|
+
content: `[Tool Call] ${data.name}\nInput: ${JSON.stringify(data.input)}\nOutput: ${typeof data.output === 'string' ? data.output : JSON.stringify(data.output)}`,
|
|
457
|
+
metadata: {
|
|
458
|
+
isTelemetry: true,
|
|
459
|
+
toolName: data.name,
|
|
460
|
+
toolCallId: data.toolCallId || runId,
|
|
461
|
+
status: data.status,
|
|
462
|
+
stream: "tool"
|
|
463
|
+
}
|
|
464
|
+
}),
|
|
465
|
+
}).catch(e => logger?.error?.(`[Dragon] Failed to sync tool telemetry: ${e.message}`));
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
catch (e) {
|
|
470
|
+
logger?.error?.(`[Dragon] Telemetry resolution failed: ${e.message}`);
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
}
|
|
418
474
|
bridgeClient.sendJson({
|
|
419
475
|
type: "agent_event",
|
|
420
476
|
channel: channelId,
|