@wu529778790/open-im 1.11.1-beta.17 → 1.11.1-beta.18

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.
@@ -110,6 +110,8 @@ function startPolling() {
110
110
  }
111
111
  // Process messages
112
112
  const messages = res.messages ?? [];
113
+ // Step 1: Extract valid USER messages and cache context tokens
114
+ const userMessages = [];
113
115
  for (const msg of messages) {
114
116
  if (signal.aborted)
115
117
  break;
@@ -120,7 +122,6 @@ function startPolling() {
120
122
  continue;
121
123
  const chatId = msg.from_user_id ?? '';
122
124
  const msgId = String(msg.message_id ?? msg.seq ?? '');
123
- const content = extracted;
124
125
  if (!chatId) {
125
126
  log.warn('ClawBot message missing from_user_id, skipping');
126
127
  continue;
@@ -130,10 +131,29 @@ function startPolling() {
130
131
  cacheContextToken(chatId, msg.context_token);
131
132
  setClawbotContextToken(msg.context_token);
132
133
  }
133
- log.info(`ClawBot message: chatId=${chatId}, msgId=${msgId}, content="${content.substring(0, 100)}"`);
134
+ userMessages.push({ chatId, msgId, content: extracted, contextToken: msg.context_token });
135
+ }
136
+ // Step 2: Aggregate consecutive messages from the same user
137
+ // ClawBot splits image+text into separate messages; combine them
138
+ const aggregated = [];
139
+ for (const m of userMessages) {
140
+ const last = aggregated[aggregated.length - 1];
141
+ if (last && last.chatId === m.chatId) {
142
+ // Same user — merge content (image marker + text)
143
+ last.content = `${last.content}\n${m.content}`;
144
+ }
145
+ else {
146
+ aggregated.push({ chatId: m.chatId, msgId: m.msgId, content: m.content });
147
+ }
148
+ }
149
+ // Step 3: Dispatch aggregated messages
150
+ for (const m of aggregated) {
151
+ if (signal.aborted)
152
+ break;
153
+ log.info(`ClawBot message: chatId=${m.chatId}, msgId=${m.msgId}, content="${m.content.substring(0, 100)}"`);
134
154
  if (messageHandler) {
135
155
  try {
136
- await messageHandler(chatId, msgId, content);
156
+ await messageHandler(m.chatId, m.msgId, m.content);
137
157
  }
138
158
  catch (err) {
139
159
  log.error('Error in ClawBot message handler:', err);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wu529778790/open-im",
3
- "version": "1.11.1-beta.17",
3
+ "version": "1.11.1-beta.18",
4
4
  "description": "Your AI coding assistant, in every chat app. Multi-platform IM bridge for Claude Code, Codex, and CodeBuddy.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",