@efengx/openclaw-channel-dragon 0.3.6 → 0.3.7

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 +19 -3
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -11,6 +11,7 @@ let cachedRuntime;
11
11
  let globalDispatcher;
12
12
  console.log("[Dragon] Plugin script is being evaluated by OpenClaw gateway...");
13
13
  const channelId = "dragon";
14
+ const processedMessageIds = new Set();
14
15
  async function ensureConnection(account, runtimeLogger) {
15
16
  if (bridgeClient)
16
17
  return;
@@ -69,10 +70,23 @@ async function startPolling(ctx) {
69
70
  }
70
71
  return;
71
72
  }
72
- const deliverToOpenClaw = async (content, sessionId = 'default', modelId, attachments) => {
73
+ const deliverToOpenClaw = async (content, sessionId = 'default', modelId, attachments, messageId) => {
73
74
  const msg = String(content || '').trim();
74
75
  if (!msg && (!attachments || attachments.length === 0))
75
76
  return;
77
+ // Deduplication check
78
+ if (messageId && processedMessageIds.has(messageId)) {
79
+ return;
80
+ }
81
+ if (messageId) {
82
+ processedMessageIds.add(messageId);
83
+ // Keep cache size manageable
84
+ if (processedMessageIds.size > 1000) {
85
+ const first = processedMessageIds.values().next().value;
86
+ if (first !== undefined)
87
+ processedMessageIds.delete(first);
88
+ }
89
+ }
76
90
  // sessionKey format: channel:agentId:direct:peerId
77
91
  // peerId can be the sessionId for multi-session support
78
92
  const sessionKey = `dragon:${account.agentId}:direct:${sessionId}`;
@@ -163,7 +177,8 @@ async function startPolling(ctx) {
163
177
  if (messages.length > 0) {
164
178
  logger?.info?.(`dragon channel: [RECOVERY] Consuming ${messages.length} pending messages via polling.`);
165
179
  for (const m of messages) {
166
- await deliverToOpenClaw(String(m.content || ''), String(m.sessionId || 'default'), m.modelId, m.attachments);
180
+ await deliverToOpenClaw(String(m.content || ''), String(m.sessionId || 'default'), m.modelId, m.attachments, m.id // Pass DB ID for deduplication
181
+ );
167
182
  }
168
183
  }
169
184
  }
@@ -212,7 +227,8 @@ async function startPolling(ctx) {
212
227
  logger?.info?.(`dragon channel: [DEBUG] Received WORKBENCH_MESSAGE via SSE. AgentID=${evt.agentId}, ContentLen=${evt.payload?.content?.length}, Latency=${latency}ms`);
213
228
  logger?.info?.(`dragon channel: [DEBUG] Payload Content: "${evt.payload?.content?.substring(0, 500)}"`);
214
229
  logger?.info?.(`dragon channel: [DEBUG] Current Account Config: ${JSON.stringify(account)}`);
215
- await deliverToOpenClaw(String(evt?.payload?.content || ''), String(evt?.payload?.sessionId || 'default'), evt?.payload?.modelId, evt?.payload?.attachments);
230
+ await deliverToOpenClaw(String(evt?.payload?.content || ''), String(evt?.payload?.sessionId || 'default'), evt?.payload?.modelId, evt?.payload?.attachments, evt?.payload?.id // Pass DB ID for deduplication
231
+ );
216
232
  }
217
233
  else if (evt.type === 'FETCH_HISTORY') {
218
234
  const { sessionId } = evt.payload;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@efengx/openclaw-channel-dragon",
3
- "version": "0.3.6",
3
+ "version": "0.3.7",
4
4
  "description": "Dragon workbench channel for OpenClaw",
5
5
  "author": "feng xiang <ofengx@gmail.com>",
6
6
  "type": "module",