@efengx/openclaw-channel-dragon 0.1.50 → 0.1.52

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 +15 -26
  2. package/package.json +1 -1
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, payload } = msg;
45
+ const { command } = msg;
46
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
- }
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', modelId) => {
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,10 +90,11 @@ async function startPolling(ctx) {
104
90
  ChannelId: channelId,
105
91
  Surface: "dragon-workbench",
106
92
  AccountId: account.accountId,
107
- SessionKey: `dragon:${account.agentId}:direct:workbench-user`,
93
+ SessionKey: sessionKey,
108
94
  CommandSource: "native",
109
95
  CommandAuthorized: true,
110
96
  Timestamp: Date.now(),
97
+ Model: modelId,
111
98
  },
112
99
  cfg: ctx.cfg,
113
100
  dispatcherOptions: {
@@ -117,7 +104,7 @@ async function startPolling(ctx) {
117
104
  const reasoning = payload?.reasoning_content || "";
118
105
  if (!text && !toolCalls.length && !reasoning)
119
106
  return;
120
- logger?.info?.(`dragon channel: deliver callback. textLen=${text.length}, toolCalls=${toolCalls.length}, hasReasoning=${!!reasoning}`);
107
+ logger?.info?.(`dragon channel: deliver callback [Session: ${sessionId}]. textLen=${text.length}, toolCalls=${toolCalls.length}, hasReasoning=${!!reasoning}`);
121
108
  // 1. Send to local bridge (WebSocket) for real-time UI
122
109
  if (bridgeClient) {
123
110
  bridgeClient.sendJson({
@@ -130,8 +117,8 @@ async function startPolling(ctx) {
130
117
  route: {
131
118
  agentId: account.agentId,
132
119
  accountId: account.accountId,
133
- peer: { kind: "direct", id: "workbench-user" },
134
- sessionKey: `dragon:${account.agentId}:direct:workbench-user`,
120
+ peer: { kind: "direct", id: sessionId },
121
+ sessionKey: sessionKey,
135
122
  },
136
123
  });
137
124
  }
@@ -143,6 +130,7 @@ async function startPolling(ctx) {
143
130
  headers: { "Content-Type": "application/json" },
144
131
  body: JSON.stringify({
145
132
  content: text,
133
+ sessionId,
146
134
  tool_calls: toolCalls,
147
135
  reasoning_content: reasoning,
148
136
  }),
@@ -181,7 +169,7 @@ async function startPolling(ctx) {
181
169
  if (!evt || evt.agentId !== agentId)
182
170
  continue;
183
171
  if (evt.type === 'WORKBENCH_MESSAGE') {
184
- await deliverToOpenClaw(String(evt?.payload?.content || ''));
172
+ await deliverToOpenClaw(String(evt?.payload?.content || ''), String(evt?.payload?.sessionId || 'default'), evt?.payload?.modelId);
185
173
  }
186
174
  }
187
175
  catch (e) {
@@ -425,6 +413,7 @@ const entry = defineChannelPluginEntry({
425
413
  plugin,
426
414
  registerFull(api) {
427
415
  console.log("[Dragon] registerFull() hook called by OpenClaw gateway");
416
+ cachedRuntime = api.runtime;
428
417
  // Subscribe to real-time events (thinking, tool calls, etc.)
429
418
  // v2026.4.12+ : runtime.events.onAgentEvent
430
419
  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.50",
3
+ "version": "0.1.52",
4
4
  "description": "Dragon workbench channel for OpenClaw",
5
5
  "author": "feng xiang <ofengx@gmail.com>",
6
6
  "type": "module",