@efengx/openclaw-channel-dragon 0.5.28 → 0.5.29

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
@@ -159,46 +159,57 @@ const plugin = createChatChannelPlugin({
159
159
  },
160
160
  handleAction: async (ctx) => {
161
161
  const { action, params, cfg, accountId } = ctx;
162
+ const logger = ctx?.logger ?? ctx?.log ?? cachedRuntime?.logger ?? cachedRuntime?.log;
163
+ logger?.info?.(`[Dragon Plugin] handleAction start: action=${action}, accountId=${accountId}, paramsKeys=${Object.keys(params || {})}`);
162
164
  if (action === "send") {
163
165
  const account = base.config.resolveAccount(cfg, accountId);
164
166
  const container = await getOrCreateContainer(account, ctx);
165
167
  const channel = container.get('channel');
166
168
  let target = params.to || params.target || ctx.toolContext?.currentChannelId || "default";
169
+ logger?.info?.(`[Dragon Plugin] handleAction target resolution input: ${target}`);
167
170
  for (const prefix of ["dragon-workbench-", "dragon-workbench:", "dragon-", "dragon:"]) {
168
171
  if (target.startsWith(prefix)) {
169
172
  target = target.substring(prefix.length);
170
173
  }
171
174
  }
172
175
  const sessionId = target || "default";
176
+ logger?.info?.(`[Dragon Plugin] handleAction target resolved: sessionId=${sessionId}, rawTarget=${target}`);
173
177
  // Collect ALL media URLs from the params (mirrors what OpenClaw tracks internally
174
178
  // via collectMessagingMediaUrlsFromRecord when the tool call starts, so that
175
179
  // hasGatewayAgentDeliveredExpectedMedia can match them against expectedMediaUrls).
176
180
  const sentMediaUrls = [];
177
- const pushMedia = (v) => {
178
- if (typeof v === 'string' && v.trim())
179
- sentMediaUrls.push(v.trim());
181
+ const pushMedia = (v, source) => {
182
+ if (typeof v === 'string' && v.trim()) {
183
+ const url = v.trim();
184
+ sentMediaUrls.push(url);
185
+ logger?.info?.(`[Dragon Plugin] handleAction extracted media URL from ${source}: ${url}`);
186
+ }
180
187
  };
181
- pushMedia(params.media);
182
- pushMedia(params.mediaUrl);
183
- pushMedia(params.path);
184
- pushMedia(params.filePath);
185
- pushMedia(params.fileUrl);
188
+ pushMedia(params.media, "params.media");
189
+ pushMedia(params.mediaUrl, "params.mediaUrl");
190
+ pushMedia(params.path, "params.path");
191
+ pushMedia(params.filePath, "params.filePath");
192
+ pushMedia(params.fileUrl, "params.fileUrl");
186
193
  if (Array.isArray(params.mediaUrls)) {
194
+ logger?.info?.(`[Dragon Plugin] handleAction found params.mediaUrls array, size=${params.mediaUrls.length}`);
187
195
  for (const u of params.mediaUrls)
188
- pushMedia(u);
196
+ pushMedia(u, "params.mediaUrls");
189
197
  }
190
198
  if (Array.isArray(params.attachments)) {
199
+ logger?.info?.(`[Dragon Plugin] handleAction found params.attachments array, size=${params.attachments.length}`);
191
200
  for (const a of params.attachments) {
192
201
  if (a && typeof a === 'object') {
193
- pushMedia(a.media);
194
- pushMedia(a.mediaUrl);
195
- pushMedia(a.path);
196
- pushMedia(a.filePath);
197
- pushMedia(a.fileUrl);
202
+ pushMedia(a.media, "attachment.media");
203
+ pushMedia(a.mediaUrl, "attachment.mediaUrl");
204
+ pushMedia(a.path, "attachment.path");
205
+ pushMedia(a.filePath, "attachment.filePath");
206
+ pushMedia(a.fileUrl, "attachment.fileUrl");
198
207
  }
199
208
  }
200
209
  }
210
+ logger?.info?.(`[Dragon Plugin] handleAction total media URLs extracted: count=${sentMediaUrls.length}, urls=${JSON.stringify(sentMediaUrls)}`);
201
211
  let text = params.message || params.text || "";
212
+ logger?.info?.(`[Dragon Plugin] handleAction base message text length: ${text.length}`);
202
213
  // Append media path to text so the Workbench can render the image
203
214
  for (const url of sentMediaUrls) {
204
215
  const mediaLine = `MEDIA: ${url}`;
@@ -206,11 +217,13 @@ const plugin = createChatChannelPlugin({
206
217
  text = text ? `${text}\n${mediaLine}` : mediaLine;
207
218
  }
208
219
  }
220
+ logger?.info?.(`[Dragon Plugin] handleAction sending text over channel: text_len=${text.length}, targetSession=${sessionId}`);
209
221
  const result = await channel.handleOutboundText({
210
222
  text,
211
223
  peer: { id: sessionId }
212
224
  });
213
- return {
225
+ logger?.info?.(`[Dragon Plugin] handleAction channel send result: ok=${result.ok}, messageId=${result.messageId || "none"}`);
226
+ const evidence = {
214
227
  ok: result.ok,
215
228
  ...result.messageId ? { messageId: result.messageId } : {},
216
229
  // Evidence fields that OpenClaw checks via hasMessagingToolDeliveryEvidence
@@ -220,7 +233,10 @@ const plugin = createChatChannelPlugin({
220
233
  messagingToolSentMediaUrls: sentMediaUrls,
221
234
  messagingToolSentTargets: [{ to: target, ...(sentMediaUrls.length > 0 ? { mediaUrls: sentMediaUrls } : {}) }],
222
235
  };
236
+ logger?.info?.(`[Dragon Plugin] handleAction returning evidence to OpenClaw: didSendViaMessagingTool=${evidence.didSendViaMessagingTool}, sentMediaUrlsCount=${evidence.messagingToolSentMediaUrls.length}`);
237
+ return evidence;
223
238
  }
239
+ logger?.warn?.(`[Dragon Plugin] handleAction action "${action}" is not supported. Ignoring.`);
224
240
  throw new Error(`Action "${action}" is not supported by the dragon channel plugin.`);
225
241
  }
226
242
  }
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const dragonChannelPluginVersion = "0.5.28";
1
+ export declare const dragonChannelPluginVersion = "0.5.29";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const dragonChannelPluginVersion = "0.5.28";
1
+ export const dragonChannelPluginVersion = "0.5.29";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@efengx/openclaw-channel-dragon",
3
- "version": "0.5.28",
3
+ "version": "0.5.29",
4
4
  "description": "Dragon workbench channel for OpenClaw",
5
5
  "author": "feng xiang <ofengx@gmail.com>",
6
6
  "type": "module",