@efengx/openclaw-channel-dragon 0.1.48 → 0.1.50

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.
Files changed (2) hide show
  1. package/dist/index.js +36 -7
  2. 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
- runtimeLogger?.info?.(`dragon channel: received hot control command: ${msg.command}`);
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
  });
@@ -94,16 +113,20 @@ async function startPolling(ctx) {
94
113
  dispatcherOptions: {
95
114
  deliver: async (payload) => {
96
115
  const text = payload?.text || "";
97
- if (!text)
116
+ const toolCalls = payload?.tool_calls || [];
117
+ const reasoning = payload?.reasoning_content || "";
118
+ if (!text && !toolCalls.length && !reasoning)
98
119
  return;
99
- logger?.info?.(`dragon channel: deliver callback invoked with AI reply: "${text.substring(0, 30)}..."`);
100
- // Send to local bridge (WebSocket)
120
+ logger?.info?.(`dragon channel: deliver callback. textLen=${text.length}, toolCalls=${toolCalls.length}, hasReasoning=${!!reasoning}`);
121
+ // 1. Send to local bridge (WebSocket) for real-time UI
101
122
  if (bridgeClient) {
102
123
  bridgeClient.sendJson({
103
124
  type: "outbound_text",
104
125
  channel: channelId,
105
126
  messageId: `${Date.now()}-${Math.random().toString(16).slice(2)}`,
106
127
  text,
128
+ tool_calls: toolCalls,
129
+ reasoning_content: reasoning,
107
130
  route: {
108
131
  agentId: account.agentId,
109
132
  accountId: account.accountId,
@@ -112,13 +135,17 @@ async function startPolling(ctx) {
112
135
  },
113
136
  });
114
137
  }
115
- // Also send to Orchestrator (HTTP POST) for trajectory tracking
138
+ // 2. Also send to Orchestrator (HTTP POST) for trajectory tracking
116
139
  try {
117
140
  const replyUrl = `${orchestratorUrl}/api/agents/${account.agentId}/messages/reply`;
118
141
  await fetch(replyUrl, {
119
142
  method: "POST",
120
143
  headers: { "Content-Type": "application/json" },
121
- body: JSON.stringify({ content: text }),
144
+ body: JSON.stringify({
145
+ content: text,
146
+ tool_calls: toolCalls,
147
+ reasoning_content: reasoning,
148
+ }),
122
149
  });
123
150
  }
124
151
  catch (e) {
@@ -434,10 +461,12 @@ const entry = defineChannelPluginEntry({
434
461
  method: "POST",
435
462
  headers: { "Content-Type": "application/json" },
436
463
  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)}`,
464
+ content: `[Tool Result] ${data.name}`,
438
465
  metadata: {
439
466
  isTelemetry: true,
440
467
  toolName: data.name,
468
+ toolInput: data.input,
469
+ toolOutput: data.output,
441
470
  toolCallId: data.toolCallId || runId,
442
471
  status: data.status,
443
472
  stream: "tool"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@efengx/openclaw-channel-dragon",
3
- "version": "0.1.48",
3
+ "version": "0.1.50",
4
4
  "description": "Dragon workbench channel for OpenClaw",
5
5
  "author": "feng xiang <ofengx@gmail.com>",
6
6
  "type": "module",