@wu529778790/open-im 1.9.4-beta.6 → 1.9.4-beta.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/dist/feishu/event-handler.js +26 -28
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { resolvePlatformAiCommand } from '../config.js';
|
|
2
|
-
import { sendTextReply, startTypingLoop, sendImageReply, sendThinkingCard, streamContentUpdate, } from './message-sender.js';
|
|
2
|
+
import { sendTextReply, startTypingLoop, sendImageReply, sendThinkingCard, streamContentUpdate, sendFinalCards, sendErrorCard, } from './message-sender.js';
|
|
3
3
|
import { buildCardV2 } from './card-builder.js';
|
|
4
4
|
import { disableStreaming, updateCardFull, destroySession } from './cardkit-manager.js';
|
|
5
5
|
import { CARDKIT_THROTTLE_MS } from '../constants.js';
|
|
@@ -172,33 +172,6 @@ export function setupFeishuHandlers(config, sessionManager) {
|
|
|
172
172
|
await sendImageReply(chatId, imagePath);
|
|
173
173
|
},
|
|
174
174
|
};
|
|
175
|
-
// Feishu-specific task callbacks for CardKit streaming
|
|
176
|
-
const feishuTaskCallbacks = {
|
|
177
|
-
streamUpdate: async (content, toolNote) => {
|
|
178
|
-
if (consecutiveStreamErrors >= MAX_STREAM_ERRORS)
|
|
179
|
-
return; // Stop trying
|
|
180
|
-
const note = buildProgressNote(toolNote);
|
|
181
|
-
// Note: cardId is passed via taskKey format: userId:cardId
|
|
182
|
-
const cardId = content; // Placeholder, will be overridden via context
|
|
183
|
-
streamContentUpdate(cardId, content, note).then(() => {
|
|
184
|
-
consecutiveStreamErrors = 0;
|
|
185
|
-
}).catch((e) => {
|
|
186
|
-
consecutiveStreamErrors++;
|
|
187
|
-
if (consecutiveStreamErrors >= MAX_STREAM_ERRORS) {
|
|
188
|
-
log.warn(`Stream update failed ${consecutiveStreamErrors} times consecutively, giving up: ${e?.message ?? e}`);
|
|
189
|
-
}
|
|
190
|
-
else {
|
|
191
|
-
log.debug('Stream update failed (will retry on next update):', e?.message ?? e);
|
|
192
|
-
}
|
|
193
|
-
});
|
|
194
|
-
},
|
|
195
|
-
sendComplete: async (content, note) => {
|
|
196
|
-
// Will be customized via context
|
|
197
|
-
},
|
|
198
|
-
sendError: async (error) => {
|
|
199
|
-
// Will be customized via context
|
|
200
|
-
},
|
|
201
|
-
};
|
|
202
175
|
// Create platform-specific AI request handler
|
|
203
176
|
const handleAIRequest = createPlatformAIRequestHandler({
|
|
204
177
|
platform: 'feishu',
|
|
@@ -214,6 +187,31 @@ export function setupFeishuHandlers(config, sessionManager) {
|
|
|
214
187
|
const resetCard = buildCardV2({ content: content || '...', status: 'streaming', toolName: resolvePlatformAiCommand(config, 'feishu') }, cardId);
|
|
215
188
|
updateCardFull(cardId, resetCard).catch((e) => log.warn('Thinking→text transition update failed:', e?.message ?? e));
|
|
216
189
|
},
|
|
190
|
+
taskCallbacksFactory: ({ msgId: cardId, toolId }) => ({
|
|
191
|
+
streamUpdate: async (content, toolNote) => {
|
|
192
|
+
if (consecutiveStreamErrors >= MAX_STREAM_ERRORS)
|
|
193
|
+
return;
|
|
194
|
+
const note = buildProgressNote(toolNote);
|
|
195
|
+
streamContentUpdate(cardId, content, note).then(() => {
|
|
196
|
+
consecutiveStreamErrors = 0;
|
|
197
|
+
}).catch((e) => {
|
|
198
|
+
consecutiveStreamErrors++;
|
|
199
|
+
if (consecutiveStreamErrors >= MAX_STREAM_ERRORS) {
|
|
200
|
+
log.warn(`Stream update failed ${consecutiveStreamErrors} times consecutively, giving up: ${e?.message ?? e}`);
|
|
201
|
+
}
|
|
202
|
+
else {
|
|
203
|
+
log.debug('Stream update failed (will retry on next update):', e?.message ?? e);
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
},
|
|
207
|
+
sendComplete: async (content, note, thinkingText) => {
|
|
208
|
+
const aiTool = resolvePlatformAiCommand(config, 'feishu');
|
|
209
|
+
await sendFinalCards('', cardId, cardId, content, note ?? '', thinkingText, aiTool);
|
|
210
|
+
},
|
|
211
|
+
sendError: async (error) => {
|
|
212
|
+
await sendErrorCard(cardId, error);
|
|
213
|
+
},
|
|
214
|
+
}),
|
|
217
215
|
});
|
|
218
216
|
/**
|
|
219
217
|
* 解析 action value(兼容对象、JSON 字符串)
|