@wu529778790/open-im 1.9.4-beta.7 → 1.9.4-beta.9

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.
@@ -187,7 +187,7 @@ export function setupFeishuHandlers(config, sessionManager) {
187
187
  const resetCard = buildCardV2({ content: content || '...', status: 'streaming', toolName: resolvePlatformAiCommand(config, 'feishu') }, cardId);
188
188
  updateCardFull(cardId, resetCard).catch((e) => log.warn('Thinking→text transition update failed:', e?.message ?? e));
189
189
  },
190
- taskCallbacksFactory: ({ msgId: cardId, toolId }) => ({
190
+ taskCallbacksFactory: ({ chatId, msgId: cardId, toolId }) => ({
191
191
  streamUpdate: async (content, toolNote) => {
192
192
  if (consecutiveStreamErrors >= MAX_STREAM_ERRORS)
193
193
  return;
@@ -205,8 +205,7 @@ export function setupFeishuHandlers(config, sessionManager) {
205
205
  });
206
206
  },
207
207
  sendComplete: async (content, note, thinkingText) => {
208
- const aiTool = resolvePlatformAiCommand(config, 'feishu');
209
- await sendFinalCards('', cardId, cardId, content, note ?? '', thinkingText, aiTool);
208
+ await sendFinalCards(chatId, '', cardId, content, note ?? '', thinkingText, toolId);
210
209
  },
211
210
  sendError: async (error) => {
212
211
  await sendErrorCard(cardId, error);
@@ -423,6 +422,8 @@ export function setupFeishuHandlers(config, sessionManager) {
423
422
  handleAIRequest,
424
423
  sendTextReply,
425
424
  replyToMessageId: messageId,
425
+ workDir: sessionManager.getWorkDir(senderId),
426
+ convId: sessionManager.getConvId(senderId),
426
427
  });
427
428
  }
428
429
  else if (msgType === 'image') {
@@ -1,4 +1,4 @@
1
- import { sendThinkingMessage, sendTextReply, sendImageReply, sendDirectorySelection, startTypingLoop, } from "./message-sender.js";
1
+ import { sendThinkingMessage, sendFinalMessages, sendErrorMessage, sendTextReply, sendImageReply, sendDirectorySelection, startTypingLoop, } from "./message-sender.js";
2
2
  import { createLogger } from "../logger.js";
3
3
  import { buildMediaMetadataPrompt } from "../shared/media-prompt.js";
4
4
  import { buildSavedMediaBatchPrompt, buildSavedMediaPrompt } from "../shared/media-analysis-prompt.js";
@@ -153,31 +153,21 @@ export function setupQQHandlers(config, sessionManager) {
153
153
  qqTaskContextMap.delete(ctx.taskKey);
154
154
  };
155
155
  },
156
- taskCallbacks: {
157
- streamUpdate: async (content, toolNote) => {
158
- // QQ doesn't support streaming updates; this is a no-op
156
+ taskCallbacksFactory: ({ chatId, msgId, toolId }) => ({
157
+ streamUpdate: async () => {
158
+ // QQ doesn't support streaming updates
159
159
  },
160
160
  sendComplete: async (content, note) => {
161
- // QQ sends final - handled via pendingReplies in message-sender.ts
161
+ await sendFinalMessages(chatId, msgId, content, note ?? '', toolId);
162
162
  },
163
163
  sendError: async (error) => {
164
- // QQ sends error - handled via pendingReplies in message-sender.ts
164
+ await sendErrorMessage(chatId, msgId, error, toolId);
165
165
  },
166
- },
166
+ }),
167
167
  });
168
- // Wrap factory handleAIRequest to match ClaudeRequestHandler signature
169
- // (used by commandHandler.dispatch and handleTextFlow)
170
- async function handleAIRequest(userId, chatId, prompt, workDir, convId, _threadCtx, replyToMessageId, signal) {
171
- await factoryHandleAIRequest({
172
- userId,
173
- chatId,
174
- prompt,
175
- workDir,
176
- convId,
177
- replyToMessageId,
178
- signal,
179
- });
180
- }
168
+ // NOTE: handleTextFlow calls handleAIRequest with an OBJECT argument,
169
+ // so we pass factoryHandleAIRequest directly (it takes HandleAIRequestParams).
170
+ // The attachment path also uses factoryHandleAIRequest with object syntax.
181
171
  function cleanupRecentEvents(now) {
182
172
  for (const [eventId, timestamp] of recentEventIds) {
183
173
  if (now - timestamp > QQ_EVENT_DEDUP_TTL_MS) {
@@ -238,7 +228,7 @@ export function setupQQHandlers(config, sessionManager) {
238
228
  chatId,
239
229
  text,
240
230
  ctx: platformContext,
241
- handleAIRequest,
231
+ handleAIRequest: factoryHandleAIRequest,
242
232
  sendTextReply,
243
233
  workDir: sessionManager.getWorkDir(userId),
244
234
  convId: sessionManager.getConvId(userId),
@@ -266,7 +256,15 @@ export function setupQQHandlers(config, sessionManager) {
266
256
  setChatUser(chatId, userId, "qq");
267
257
  // Enqueue attachment prompt
268
258
  const enqueueResult = requestQueue.enqueue(userId, convId ?? '', attachmentPrompt, async (prompt, signal) => {
269
- await handleAIRequest(userId, chatId, prompt, workDir, convId, undefined, event.id, signal);
259
+ await factoryHandleAIRequest({
260
+ userId,
261
+ chatId,
262
+ prompt,
263
+ workDir,
264
+ convId,
265
+ replyToMessageId: event.id,
266
+ signal,
267
+ });
270
268
  });
271
269
  if (enqueueResult === "rejected") {
272
270
  await sendTextReply(chatId, "Request queue is full. Please try again later.");
@@ -143,6 +143,7 @@ export function runAITask(deps, ctx, prompt, toolAdapter, platformAdapter) {
143
143
  throttledUpdate(taskState.latestContent, true);
144
144
  },
145
145
  onComplete: async (result) => {
146
+ log.info(`[AITask] onComplete fired: settled=${settled}, success=${result.success}, platform=${ctx.platform}, taskKey=${ctx.taskKey}`);
146
147
  if (settled)
147
148
  return;
148
149
  settled = true;
@@ -296,6 +296,8 @@ export function setupTelegramHandlers(bot, config, sessionManager) {
296
296
  handleAIRequest,
297
297
  sendTextReply,
298
298
  replyToMessageId: messageId,
299
+ workDir: sessionManager.getWorkDir(userId),
300
+ convId: sessionManager.getConvId(userId),
299
301
  });
300
302
  }
301
303
  catch (err) {
@@ -281,6 +281,8 @@ export function setupWeWorkHandlers(config, sessionManager) {
281
281
  ctx,
282
282
  handleAIRequest,
283
283
  sendTextReply: (chatId, text) => sendTextReply(chatId, text, reqId),
284
+ workDir: sessionManager.getWorkDir(fromUser),
285
+ convId: sessionManager.getConvId(fromUser),
284
286
  });
285
287
  return;
286
288
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wu529778790/open-im",
3
- "version": "1.9.4-beta.7",
3
+ "version": "1.9.4-beta.9",
4
4
  "description": "Multi-platform IM bridge for AI CLI tools (Claude, Codex, CodeBuddy)",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",