deepseeker-code 1.0.68 → 1.0.70
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/cli.mjs +46 -21
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -3858,7 +3858,7 @@ var init_approval = __esm({
|
|
|
3858
3858
|
// ../core/src/batch/feishu/reconcile.ts
|
|
3859
3859
|
import fs16 from "fs/promises";
|
|
3860
3860
|
import path17 from "path";
|
|
3861
|
-
var cursorPath, FIRST_RUN_WINDOW_MS, loadCursor, saveCursor,
|
|
3861
|
+
var cursorPath, FIRST_RUN_WINDOW_MS, loadCursor, saveCursor, knownChatsPath, legacyP2pChatsPath, readChatsFile, loadKnownChats, recordKnownChat, RECONCILE_MSG, msg5, runReconcile;
|
|
3862
3862
|
var init_reconcile = __esm({
|
|
3863
3863
|
"../core/src/batch/feishu/reconcile.ts"() {
|
|
3864
3864
|
"use strict";
|
|
@@ -3881,23 +3881,29 @@ var init_reconcile = __esm({
|
|
|
3881
3881
|
await fs16.writeFile(tmp, JSON.stringify(value, null, 2), "utf-8");
|
|
3882
3882
|
await fs16.rename(tmp, cursorPath());
|
|
3883
3883
|
};
|
|
3884
|
-
|
|
3885
|
-
|
|
3884
|
+
knownChatsPath = () => path17.join(batchQueueRoot(), "feishu-known-chats.json");
|
|
3885
|
+
legacyP2pChatsPath = () => path17.join(batchQueueRoot(), "feishu-p2p-chats.json");
|
|
3886
|
+
readChatsFile = async (p) => {
|
|
3886
3887
|
try {
|
|
3887
|
-
const raw = JSON.parse(await fs16.readFile(
|
|
3888
|
+
const raw = JSON.parse(await fs16.readFile(p, "utf-8"));
|
|
3888
3889
|
return Array.isArray(raw?.chats) ? raw.chats.filter((x) => typeof x === "string") : [];
|
|
3889
3890
|
} catch {
|
|
3890
3891
|
return [];
|
|
3891
3892
|
}
|
|
3892
3893
|
};
|
|
3893
|
-
|
|
3894
|
-
const
|
|
3894
|
+
loadKnownChats = async () => {
|
|
3895
|
+
const known = await readChatsFile(knownChatsPath());
|
|
3896
|
+
if (known.length > 0) return known;
|
|
3897
|
+
return readChatsFile(legacyP2pChatsPath());
|
|
3898
|
+
};
|
|
3899
|
+
recordKnownChat = async (chatId) => {
|
|
3900
|
+
const chats = await loadKnownChats();
|
|
3895
3901
|
if (chats.includes(chatId)) return false;
|
|
3896
3902
|
const next = { chats: [...chats, chatId], updatedAt: (/* @__PURE__ */ new Date()).toISOString() };
|
|
3897
|
-
await fs16.mkdir(path17.dirname(
|
|
3898
|
-
const tmp = `${
|
|
3903
|
+
await fs16.mkdir(path17.dirname(knownChatsPath()), { recursive: true });
|
|
3904
|
+
const tmp = `${knownChatsPath()}.tmp-${process.pid}-${Math.random().toString(36).slice(2, 8)}`;
|
|
3899
3905
|
await fs16.writeFile(tmp, JSON.stringify(next, null, 2), "utf-8");
|
|
3900
|
-
await fs16.rename(tmp,
|
|
3906
|
+
await fs16.rename(tmp, knownChatsPath());
|
|
3901
3907
|
return true;
|
|
3902
3908
|
};
|
|
3903
3909
|
RECONCILE_MSG = {
|
|
@@ -4554,7 +4560,7 @@ var init_listen = __esm({
|
|
|
4554
4560
|
botInfoFail: (e) => `\u26A0\uFE0F \u83B7\u53D6\u673A\u5668\u4EBA open_id \u5931\u8D25\uFF08${e}\uFF09\uFF1AmentionOnlyInGroup=true \u4E0B\u7FA4\u6D88\u606F\u5C06\u5168\u90E8\u62D2\u6536\uFF0C\u8BF7\u68C0\u67E5\u5E94\u7528\u6743\u9650\u6216\u628A mentionOnlyInGroup \u914D\u4E3A false\u3002`,
|
|
4555
4561
|
msgSkip: (why) => `\u23ED\uFE0F [feishu] \u8DF3\u8FC7\u6D88\u606F\uFF1A${why}`,
|
|
4556
4562
|
msgFail: (e) => `\u274C [feishu] \u6D88\u606F\u5904\u7406\u5F02\u5E38\uFF08\u4E0D\u4E2D\u65AD\u76D1\u542C\uFF09\uFF1A${e}`,
|
|
4557
|
-
|
|
4563
|
+
chatLearned: (chatId) => `\u{1F4AC} \u4F1A\u8BDD\u5DF2\u7EB3\u5165\u65AD\u7EBF\u5BF9\u8D26\uFF08${chatId.slice(0, 12)}\u2026\uFF09\uFF1A\u6B64\u540E\u65AD\u7EBF\u7A97\u53E3\u5185\u8BE5\u4F1A\u8BDD\u6F0F\u7968\u53EF\u56DE\u8865`,
|
|
4558
4564
|
cardDenied: (who) => `\u{1F6AB} \u70B9\u5361\u4EBA\u4E0D\u5728 users \u767D\u540D\u5355\uFF0C\u62D2\u7EDD\u5BA1\u6279\uFF1A${who}`,
|
|
4559
4565
|
cardOk: (id, d) => `\u{1F3B4} \u5BA1\u6279\u51B3\u5B9A\u5DF2\u843D\u76D8 [${id.slice(0, 8)}\u2026] ${d}`,
|
|
4560
4566
|
cardFail: (e) => `\u26A0\uFE0F \u5361\u7247\u51B3\u5B9A\u5199\u5165\u5931\u8D25\uFF1A${e}`,
|
|
@@ -4573,7 +4579,7 @@ var init_listen = __esm({
|
|
|
4573
4579
|
botInfoFail: (e) => `\u26A0\uFE0F Failed to fetch bot open_id (${e}): with mentionOnlyInGroup=true all group messages will be rejected \u2014 check app permissions or set mentionOnlyInGroup=false.`,
|
|
4574
4580
|
msgSkip: (why) => `\u23ED\uFE0F [feishu] message skipped: ${why}`,
|
|
4575
4581
|
msgFail: (e) => `\u274C [feishu] message handling error (listener keeps running): ${e}`,
|
|
4576
|
-
|
|
4582
|
+
chatLearned: (chatId) => `\u{1F4AC} chat registered for reconcile backfill (${chatId.slice(0, 12)}\u2026): missed tickets in this chat are now recoverable after reconnects`,
|
|
4577
4583
|
cardDenied: (who) => `\u{1F6AB} clicker not in the users whitelist, approval refused: ${who}`,
|
|
4578
4584
|
cardOk: (id, d) => `\u{1F3B4} approval decision recorded [${id.slice(0, 8)}\u2026] ${d}`,
|
|
4579
4585
|
cardFail: (e) => `\u26A0\uFE0F failed to write the approval decision: ${e}`,
|
|
@@ -4589,7 +4595,10 @@ var init_listen = __esm({
|
|
|
4589
4595
|
const spec = SDK_SPECIFIER;
|
|
4590
4596
|
return await import(spec);
|
|
4591
4597
|
};
|
|
4592
|
-
defaultSleep2 = (ms) => new Promise((res) =>
|
|
4598
|
+
defaultSleep2 = (ms) => new Promise((res) => {
|
|
4599
|
+
const t = setTimeout(res, ms);
|
|
4600
|
+
if (typeof t?.unref === "function") t.unref();
|
|
4601
|
+
});
|
|
4593
4602
|
makeDefaultLog = () => {
|
|
4594
4603
|
const file = path19.join(batchQueueRoot(), "feishu-listen.log");
|
|
4595
4604
|
return (line) => {
|
|
@@ -4768,8 +4777,24 @@ var init_listen = __esm({
|
|
|
4768
4777
|
return { code: 1 };
|
|
4769
4778
|
}
|
|
4770
4779
|
let stopReason = null;
|
|
4780
|
+
const sleepers = /* @__PURE__ */ new Set();
|
|
4781
|
+
const sleepInterruptible = async (ms) => {
|
|
4782
|
+
let mine;
|
|
4783
|
+
try {
|
|
4784
|
+
await Promise.race([
|
|
4785
|
+
sleep2(ms),
|
|
4786
|
+
new Promise((res) => {
|
|
4787
|
+
mine = res;
|
|
4788
|
+
sleepers.add(res);
|
|
4789
|
+
})
|
|
4790
|
+
]);
|
|
4791
|
+
} finally {
|
|
4792
|
+
if (mine) sleepers.delete(mine);
|
|
4793
|
+
}
|
|
4794
|
+
};
|
|
4771
4795
|
const requestStop = (why) => {
|
|
4772
4796
|
if (stopReason === null) stopReason = why;
|
|
4797
|
+
for (const res of [...sleepers]) res();
|
|
4773
4798
|
};
|
|
4774
4799
|
let wsExitCode = 0;
|
|
4775
4800
|
const wsHooks = {
|
|
@@ -4799,8 +4824,8 @@ var init_listen = __esm({
|
|
|
4799
4824
|
log(msg6(locale2, "alreadyRunning", lock.holderPid));
|
|
4800
4825
|
return { code: 1 };
|
|
4801
4826
|
}
|
|
4802
|
-
const
|
|
4803
|
-
for (const c of await
|
|
4827
|
+
const learnedChats = /* @__PURE__ */ new Set();
|
|
4828
|
+
for (const c of await loadKnownChats()) learnedChats.add(c);
|
|
4804
4829
|
const handleDeps = {
|
|
4805
4830
|
botOpenId,
|
|
4806
4831
|
download: deps?.download ?? makeSdkDownload(client),
|
|
@@ -4820,11 +4845,11 @@ var init_listen = __esm({
|
|
|
4820
4845
|
log(msg6(locale2, "msgSkip", `\u7C7B\u578B\u4E0D\u652F\u6301\u6216\u5F62\u6001\u5F02\u5E38\uFF08${type}\uFF09`));
|
|
4821
4846
|
return;
|
|
4822
4847
|
}
|
|
4823
|
-
if (candidate.
|
|
4824
|
-
const learned = await
|
|
4848
|
+
if (candidate.chatId && fcfg.users.includes(candidate.senderOpenId)) {
|
|
4849
|
+
const learned = await recordKnownChat(candidate.chatId).catch(() => false);
|
|
4825
4850
|
if (learned) {
|
|
4826
|
-
|
|
4827
|
-
log(msg6(locale2, "
|
|
4851
|
+
learnedChats.add(candidate.chatId);
|
|
4852
|
+
log(msg6(locale2, "chatLearned", candidate.chatId));
|
|
4828
4853
|
}
|
|
4829
4854
|
}
|
|
4830
4855
|
const r = await handleFeishuMessage(candidate, fcfg, handleDeps);
|
|
@@ -4868,10 +4893,10 @@ var init_listen = __esm({
|
|
|
4868
4893
|
process.once("SIGTERM", () => onSignal("SIGTERM"));
|
|
4869
4894
|
}
|
|
4870
4895
|
const reconcileLoop = async () => {
|
|
4871
|
-
const pull = makeSdkPull(client, fcfg, log, locale2, () => [...
|
|
4896
|
+
const pull = makeSdkPull(client, fcfg, log, locale2, () => [...learnedChats]);
|
|
4872
4897
|
let first = true;
|
|
4873
4898
|
for (; ; ) {
|
|
4874
|
-
if (!first) await
|
|
4899
|
+
if (!first) await sleepInterruptible(reconcileMs);
|
|
4875
4900
|
first = false;
|
|
4876
4901
|
if (shouldStop() || stopReason !== null) return;
|
|
4877
4902
|
await runReconcile({
|
|
@@ -4908,7 +4933,7 @@ var init_listen = __esm({
|
|
|
4908
4933
|
}
|
|
4909
4934
|
} catch {
|
|
4910
4935
|
}
|
|
4911
|
-
await
|
|
4936
|
+
await sleepInterruptible(scanMs);
|
|
4912
4937
|
}
|
|
4913
4938
|
};
|
|
4914
4939
|
await Promise.all([scanLoop(), reconcileLoop()]);
|