qwen-alpha 1.0.5 → 1.0.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qwen-alpha",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "description": "Telegram bot for Qwen Code integration — AI-powered code review, bug detection, and code generation",
5
5
  "main": "src/index.js",
6
6
  "bin": {
package/src/bot/bot.js CHANGED
@@ -24,7 +24,7 @@ const fileHandler = require('./handlers/file');
24
24
  */
25
25
  async function initBot(token, config = {}) {
26
26
  const bot = new Telegraf(token, {
27
- handlerTimeout: 30000, // Таймаут обработки (30 секунд)
27
+ handlerTimeout: 120000, // Таймаут обработки (120 секунд)
28
28
  });
29
29
 
30
30
  // Глобальная обработка ошибок
@@ -142,41 +142,49 @@ class QwenService {
142
142
  _parseJsonResponse(stdout) {
143
143
  try {
144
144
  const messages = JSON.parse(stdout.trim());
145
-
145
+
146
146
  if (!Array.isArray(messages)) {
147
147
  logger.warn({ stdout }, 'Unexpected Qwen response format');
148
148
  return stdout.trim();
149
149
  }
150
-
151
- // Поиск сообщения от assistant
152
- const assistantMessage = messages.find(m => m.type === 'assistant');
153
-
154
- if (assistantMessage?.message?.content) {
155
- const content = assistantMessage.message.content;
156
-
150
+
151
+ // Поиск последнего сообщения от assistant с текстом
152
+ const assistantMessages = messages.filter(m => m.type === 'assistant' && m.message?.content);
153
+ const lastAssistantMessage = assistantMessages.length > 0
154
+ ? assistantMessages[assistantMessages.length - 1]
155
+ : null;
156
+
157
+ if (lastAssistantMessage?.message?.content) {
158
+ const content = lastAssistantMessage.message.content;
159
+
157
160
  // Content может быть строкой или массивом
158
161
  if (typeof content === 'string') {
159
162
  return content;
160
163
  }
161
-
164
+
162
165
  if (Array.isArray(content)) {
163
- // Объединение текстовых частей
166
+ // Поиск текстовой части (может быть thinking + text)
167
+ const textPart = content.find(part => part.type === 'text');
168
+ if (textPart?.text) {
169
+ return textPart.text;
170
+ }
171
+ // Fallback: объединение всех текстовых частей
164
172
  return content
165
173
  .filter(part => part.type === 'text')
166
174
  .map(part => part.text)
167
175
  .join('\n');
168
176
  }
169
177
  }
170
-
171
- // Поиск result сообщения
178
+
179
+ // Поиск result сообщения (fallback)
172
180
  const resultMessage = messages.find(m => m.type === 'result');
173
181
  if (resultMessage?.result) {
174
182
  return resultMessage.result;
175
183
  }
176
-
184
+
177
185
  // Fallback: возврат всего stdout
178
186
  return stdout.trim();
179
-
187
+
180
188
  } catch (parseError) {
181
189
  logger.warn({ parseError, stdout }, 'Failed to parse Qwen JSON response');
182
190
  return stdout.trim();