@wu529778790/open-im 1.8.1-beta.17 → 1.8.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.
- package/dist/feishu/event-handler.js +28 -17
- package/package.json +1 -1
|
@@ -150,27 +150,38 @@ export function setupFeishuHandlers(config, sessionManager) {
|
|
|
150
150
|
const toolId = aiCommand;
|
|
151
151
|
// 使用 CardKit 打字机效果(80ms 节流,约 12 次/秒,比 patch 5 QPS 更流畅)
|
|
152
152
|
let cardHandle;
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
// 检测是否为飞书权限不足
|
|
159
|
-
if (isPermissionError(err)) {
|
|
160
|
-
const guide = buildPermissionGuideMessage(err);
|
|
161
|
-
await sendPermissionFallback(chatId, guide).catch((err) => {
|
|
162
|
-
log.warn('Permission fallback send failed:', err);
|
|
163
|
-
});
|
|
153
|
+
const MAX_SEND_RETRIES = 3;
|
|
154
|
+
for (let attempt = 1; attempt <= MAX_SEND_RETRIES; attempt++) {
|
|
155
|
+
try {
|
|
156
|
+
cardHandle = await sendThinkingCard(chatId, toolId);
|
|
157
|
+
break;
|
|
164
158
|
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
159
|
+
catch (err) {
|
|
160
|
+
const isRetryable = err && typeof err === 'object' && 'code' in err &&
|
|
161
|
+
(err.code === 'ETIMEDOUT' || err.code === 'ECONNRESET' || err.code === 'ECONNREFUSED');
|
|
162
|
+
if (isRetryable && attempt < MAX_SEND_RETRIES) {
|
|
163
|
+
log.warn(`sendThinkingCard attempt ${attempt}/${MAX_SEND_RETRIES} failed (${err.code}), retrying...`);
|
|
164
|
+
await new Promise((r) => setTimeout(r, 1000 * attempt));
|
|
165
|
+
continue;
|
|
168
166
|
}
|
|
169
|
-
|
|
170
|
-
|
|
167
|
+
log.error(`Failed to send thinking card after ${attempt} attempts:`, err);
|
|
168
|
+
// 检测是否为飞书权限不足
|
|
169
|
+
if (isPermissionError(err)) {
|
|
170
|
+
const guide = buildPermissionGuideMessage(err);
|
|
171
|
+
await sendPermissionFallback(chatId, guide).catch((err) => {
|
|
172
|
+
log.warn('Permission fallback send failed:', err);
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
try {
|
|
177
|
+
await sendTextReply(chatId, '启动 AI 处理失败,请重试。');
|
|
178
|
+
}
|
|
179
|
+
catch (err) {
|
|
180
|
+
log.warn('Failed to send startup error reply:', err);
|
|
181
|
+
}
|
|
171
182
|
}
|
|
183
|
+
return;
|
|
172
184
|
}
|
|
173
|
-
return;
|
|
174
185
|
}
|
|
175
186
|
const { messageId: msgId, cardId } = cardHandle;
|
|
176
187
|
const stopTyping = startTypingLoop(chatId);
|