@efengx/openclaw-channel-dragon 0.1.50 → 0.1.51
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 +14 -26
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -42,26 +42,9 @@ async function ensureConnection(account, runtimeLogger) {
|
|
|
42
42
|
}
|
|
43
43
|
// Instructions from Dragon Client UI
|
|
44
44
|
if (t === "hot_control") {
|
|
45
|
-
const { command
|
|
45
|
+
const { command } = msg;
|
|
46
46
|
runtimeLogger?.info?.(`dragon channel: received hot control: ${command}`);
|
|
47
|
-
|
|
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
|
-
}
|
|
47
|
+
// Model switching is now handled directly via local openclaw.json / CLI by Dragon Client
|
|
65
48
|
}
|
|
66
49
|
},
|
|
67
50
|
});
|
|
@@ -86,16 +69,19 @@ async function startPolling(ctx) {
|
|
|
86
69
|
}
|
|
87
70
|
return;
|
|
88
71
|
}
|
|
89
|
-
const deliverToOpenClaw = async (content) => {
|
|
72
|
+
const deliverToOpenClaw = async (content, sessionId = 'default') => {
|
|
90
73
|
const msg = String(content || '').trim();
|
|
91
74
|
if (!msg)
|
|
92
75
|
return;
|
|
76
|
+
// sessionKey format: channel:agentId:direct:peerId
|
|
77
|
+
// peerId can be the sessionId for multi-session support
|
|
78
|
+
const sessionKey = `dragon:${account.agentId}:direct:${sessionId}`;
|
|
93
79
|
await replyDispatcher({
|
|
94
80
|
ctx: {
|
|
95
81
|
Body: msg,
|
|
96
82
|
BodyForAgent: msg,
|
|
97
83
|
BodyForCommands: msg,
|
|
98
|
-
From: "workbench-user"
|
|
84
|
+
From: sessionId === 'default' ? "workbench-user" : `workbench-user-${sessionId}`,
|
|
99
85
|
SenderName: "Workbench User",
|
|
100
86
|
SenderId: "workbench-user",
|
|
101
87
|
To: account.agentId,
|
|
@@ -104,7 +90,7 @@ async function startPolling(ctx) {
|
|
|
104
90
|
ChannelId: channelId,
|
|
105
91
|
Surface: "dragon-workbench",
|
|
106
92
|
AccountId: account.accountId,
|
|
107
|
-
SessionKey:
|
|
93
|
+
SessionKey: sessionKey,
|
|
108
94
|
CommandSource: "native",
|
|
109
95
|
CommandAuthorized: true,
|
|
110
96
|
Timestamp: Date.now(),
|
|
@@ -117,7 +103,7 @@ async function startPolling(ctx) {
|
|
|
117
103
|
const reasoning = payload?.reasoning_content || "";
|
|
118
104
|
if (!text && !toolCalls.length && !reasoning)
|
|
119
105
|
return;
|
|
120
|
-
logger?.info?.(`dragon channel: deliver callback. textLen=${text.length}, toolCalls=${toolCalls.length}, hasReasoning=${!!reasoning}`);
|
|
106
|
+
logger?.info?.(`dragon channel: deliver callback [Session: ${sessionId}]. textLen=${text.length}, toolCalls=${toolCalls.length}, hasReasoning=${!!reasoning}`);
|
|
121
107
|
// 1. Send to local bridge (WebSocket) for real-time UI
|
|
122
108
|
if (bridgeClient) {
|
|
123
109
|
bridgeClient.sendJson({
|
|
@@ -130,8 +116,8 @@ async function startPolling(ctx) {
|
|
|
130
116
|
route: {
|
|
131
117
|
agentId: account.agentId,
|
|
132
118
|
accountId: account.accountId,
|
|
133
|
-
peer: { kind: "direct", id:
|
|
134
|
-
sessionKey:
|
|
119
|
+
peer: { kind: "direct", id: sessionId },
|
|
120
|
+
sessionKey: sessionKey,
|
|
135
121
|
},
|
|
136
122
|
});
|
|
137
123
|
}
|
|
@@ -143,6 +129,7 @@ async function startPolling(ctx) {
|
|
|
143
129
|
headers: { "Content-Type": "application/json" },
|
|
144
130
|
body: JSON.stringify({
|
|
145
131
|
content: text,
|
|
132
|
+
sessionId,
|
|
146
133
|
tool_calls: toolCalls,
|
|
147
134
|
reasoning_content: reasoning,
|
|
148
135
|
}),
|
|
@@ -181,7 +168,7 @@ async function startPolling(ctx) {
|
|
|
181
168
|
if (!evt || evt.agentId !== agentId)
|
|
182
169
|
continue;
|
|
183
170
|
if (evt.type === 'WORKBENCH_MESSAGE') {
|
|
184
|
-
await deliverToOpenClaw(String(evt?.payload?.content || ''));
|
|
171
|
+
await deliverToOpenClaw(String(evt?.payload?.content || ''), String(evt?.payload?.sessionId || 'default'));
|
|
185
172
|
}
|
|
186
173
|
}
|
|
187
174
|
catch (e) {
|
|
@@ -425,6 +412,7 @@ const entry = defineChannelPluginEntry({
|
|
|
425
412
|
plugin,
|
|
426
413
|
registerFull(api) {
|
|
427
414
|
console.log("[Dragon] registerFull() hook called by OpenClaw gateway");
|
|
415
|
+
cachedRuntime = api.runtime;
|
|
428
416
|
// Subscribe to real-time events (thinking, tool calls, etc.)
|
|
429
417
|
// v2026.4.12+ : runtime.events.onAgentEvent
|
|
430
418
|
const agentEventHandler = api.runtime?.events?.onAgentEvent || InfraRuntime.onAgentEvent;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@efengx/openclaw-channel-dragon",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.51",
|
|
4
4
|
"description": "Dragon workbench channel for OpenClaw",
|
|
5
5
|
"author": "feng xiang <ofengx@gmail.com>",
|
|
6
6
|
"type": "module",
|
|
@@ -11,10 +11,6 @@
|
|
|
11
11
|
"openclaw.plugin.json",
|
|
12
12
|
"README.md"
|
|
13
13
|
],
|
|
14
|
-
"scripts": {
|
|
15
|
-
"build": "tsc -p tsconfig.json",
|
|
16
|
-
"lint": "echo \"(skip)\""
|
|
17
|
-
},
|
|
18
14
|
"dependencies": {
|
|
19
15
|
"openclaw": "^2026.4.12"
|
|
20
16
|
},
|
|
@@ -36,5 +32,9 @@
|
|
|
36
32
|
},
|
|
37
33
|
"publishConfig": {
|
|
38
34
|
"access": "public"
|
|
35
|
+
},
|
|
36
|
+
"scripts": {
|
|
37
|
+
"build": "tsc -p tsconfig.json",
|
|
38
|
+
"lint": "echo \"(skip)\""
|
|
39
39
|
}
|
|
40
|
-
}
|
|
40
|
+
}
|