@wu529778790/open-im 0.3.7 → 0.3.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.
@@ -12,10 +12,11 @@ function buildCompletionNote(result, sessionManager, ctx) {
12
12
  parts.push(toolInfo);
13
13
  if (result.model)
14
14
  parts.push(result.model);
15
- const totalTurns = ctx.threadId
16
- ? sessionManager.addTurnsForThread(ctx.userId, ctx.threadId, result.numTurns)
17
- : sessionManager.addTurns(ctx.userId, result.numTurns);
18
- const ctxWarning = getContextWarning(totalTurns);
15
+ // 获取当前的总轮数(不再累加,因为已经在请求开始时累加了)
16
+ const currentTurns = ctx.threadId
17
+ ? sessionManager.addTurnsForThread(ctx.userId, ctx.threadId, 0)
18
+ : sessionManager.addTurns(ctx.userId, 0);
19
+ const ctxWarning = getContextWarning(currentTurns);
19
20
  if (ctxWarning)
20
21
  parts.push(ctxWarning);
21
22
  return parts.join(' | ');
@@ -79,6 +79,9 @@ export function setupTelegramHandlers(bot, config, sessionManager) {
79
79
  });
80
80
  registerPermissionSender('telegram', {});
81
81
  async function handleAIRequest(userId, chatId, prompt, workDir, convId, _threadCtx, replyToMessageId) {
82
+ // 在用户每次发送消息时就累加计数,确保提示能轮换显示
83
+ const currentTurns = sessionManager.addTurns(userId, 1);
84
+ log.info(`User request: total turns = ${currentTurns} for user ${userId}`);
82
85
  const toolAdapter = getAdapter(config.aiCommand);
83
86
  if (!toolAdapter) {
84
87
  await sendTextReply(chatId, `未配置 AI 工具: ${config.aiCommand}`);
@@ -110,11 +110,12 @@ export async function updateMessage(chatId, messageId, content, status, note, to
110
110
  // 完成或错误时,显式移除停止按钮(使用空的 inline_keyboard)
111
111
  opts.reply_markup = { inline_keyboard: [] };
112
112
  // 添加日志,帮助诊断
113
- log.info(`Updating message to ${status} status (removing stop button) for ${chatId}:${messageId}`);
113
+ log.info(`Updating message to ${status} status (removing stop button) for ${chatId}:${messageId}, content length: ${content.length}`);
114
114
  }
115
115
  // 流式输出时使用纯文本,避免 Markdown 解析导致内容减少
116
- // 只在完成时应用 Markdown 格式
117
- const shouldParseMarkdown = status === 'done' || status === 'error';
116
+ // 完成时也暂时使用纯文本,避免 Markdown 解析错误
117
+ // TODO: 等待 Markdown 预处理稳定后再启用 Markdown
118
+ const shouldParseMarkdown = false; // 暂时禁用 Markdown 解析
118
119
  let retries = 0;
119
120
  const maxRetries = 2; // 减少重试次数,但增加等待时间
120
121
  while (retries <= maxRetries) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wu529778790/open-im",
3
- "version": "0.3.7",
3
+ "version": "0.3.9",
4
4
  "description": "Multi-platform IM bridge for AI CLI tools (Claude, Codex, Cursor)",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",