@vibe-lark/larkpal 0.1.37 → 0.1.38
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/main.mjs +36 -6
- package/package.json +1 -1
package/dist/main.mjs
CHANGED
|
@@ -10048,7 +10048,9 @@ async function dispatchToCC(params) {
|
|
|
10048
10048
|
const replyInThread = !!threadId;
|
|
10049
10049
|
const replyToMessageId = threadId ? void 0 : ctx.messageId;
|
|
10050
10050
|
let textPrompt = formatForCC(ctx, isGroup);
|
|
10051
|
-
if (isGroup) textPrompt = `[
|
|
10051
|
+
if (isGroup && replyInThread) textPrompt = `[群聊话题] ${textPrompt}`;
|
|
10052
|
+
else if (isGroup) textPrompt = `[群聊] ${textPrompt}`;
|
|
10053
|
+
else textPrompt = `[私聊] ${textPrompt}`;
|
|
10052
10054
|
const imageResources = ctx.resources.filter((r) => r.type === "image");
|
|
10053
10055
|
let prompt = textPrompt;
|
|
10054
10056
|
if (imageResources.length > 0) {
|
|
@@ -12201,10 +12203,16 @@ const log$11 = larkLogger("converters/merge-forward");
|
|
|
12201
12203
|
*/
|
|
12202
12204
|
const convertMergeForward = async (_raw, ctx) => {
|
|
12203
12205
|
const { accountId, messageId, resolveUserName, batchResolveNames, fetchSubMessages, convertMessageContent } = ctx;
|
|
12204
|
-
if (!fetchSubMessages)
|
|
12205
|
-
|
|
12206
|
-
|
|
12207
|
-
|
|
12206
|
+
if (!fetchSubMessages) {
|
|
12207
|
+
log$11.warn("fetchSubMessages 回调未注入,无法展开合并转发消息", {
|
|
12208
|
+
messageId,
|
|
12209
|
+
accountId
|
|
12210
|
+
});
|
|
12211
|
+
return {
|
|
12212
|
+
content: "<forwarded_messages/>",
|
|
12213
|
+
resources: []
|
|
12214
|
+
};
|
|
12215
|
+
}
|
|
12208
12216
|
return {
|
|
12209
12217
|
content: await expand(accountId, messageId, resolveUserName, batchResolveNames, fetchSubMessages, convertMessageContent),
|
|
12210
12218
|
resources: []
|
|
@@ -12214,6 +12222,10 @@ async function expand(accountId, messageId, resolveUserName, batchResolveNames,
|
|
|
12214
12222
|
let items;
|
|
12215
12223
|
try {
|
|
12216
12224
|
items = await fetchSubMessages(messageId);
|
|
12225
|
+
log$11.info("fetchSubMessages 成功", {
|
|
12226
|
+
messageId,
|
|
12227
|
+
itemCount: items.length
|
|
12228
|
+
});
|
|
12217
12229
|
} catch (error) {
|
|
12218
12230
|
log$11.error("fetch sub-messages failed", {
|
|
12219
12231
|
messageId,
|
|
@@ -12221,8 +12233,16 @@ async function expand(accountId, messageId, resolveUserName, batchResolveNames,
|
|
|
12221
12233
|
});
|
|
12222
12234
|
return "<forwarded_messages/>";
|
|
12223
12235
|
}
|
|
12224
|
-
if (items.length === 0)
|
|
12236
|
+
if (items.length === 0) {
|
|
12237
|
+
log$11.warn("fetchSubMessages 返回空 items", { messageId });
|
|
12238
|
+
return "<forwarded_messages/>";
|
|
12239
|
+
}
|
|
12225
12240
|
const childrenMap = buildChildrenMap(items, messageId);
|
|
12241
|
+
log$11.info("buildChildrenMap 完成", {
|
|
12242
|
+
messageId,
|
|
12243
|
+
parentKeys: [...childrenMap.keys()],
|
|
12244
|
+
childCounts: [...childrenMap.entries()].map(([k, v]) => `${k}:${v.length}`)
|
|
12245
|
+
});
|
|
12226
12246
|
const senderIds = collectSenderIds(items, messageId);
|
|
12227
12247
|
if (senderIds.length > 0 && batchResolveNames) try {
|
|
12228
12248
|
await batchResolveNames(senderIds);
|
|
@@ -12556,6 +12576,10 @@ async function fetchCardContent(messageId, larkClient) {
|
|
|
12556
12576
|
*/
|
|
12557
12577
|
function createFetchSubMessages(larkClient) {
|
|
12558
12578
|
return async (msgId) => {
|
|
12579
|
+
log$10.info("fetchSubMessages 请求", {
|
|
12580
|
+
msgId,
|
|
12581
|
+
url: `/open-apis/im/v1/messages/${msgId}`
|
|
12582
|
+
});
|
|
12559
12583
|
const response = await larkClient.sdk.request({
|
|
12560
12584
|
method: "GET",
|
|
12561
12585
|
url: `/open-apis/im/v1/messages/${msgId}`,
|
|
@@ -12564,6 +12588,12 @@ function createFetchSubMessages(larkClient) {
|
|
|
12564
12588
|
card_msg_content_type: "raw_card_content"
|
|
12565
12589
|
}
|
|
12566
12590
|
});
|
|
12591
|
+
log$10.info("fetchSubMessages 响应", {
|
|
12592
|
+
msgId,
|
|
12593
|
+
code: response?.code,
|
|
12594
|
+
msg: response?.msg,
|
|
12595
|
+
itemCount: response?.data?.items?.length ?? 0
|
|
12596
|
+
});
|
|
12567
12597
|
if (response?.code !== 0) throw new Error(`API error: code=${response?.code} msg=${response?.msg}`);
|
|
12568
12598
|
return response?.data?.items ?? [];
|
|
12569
12599
|
};
|