























@@ -34,7 +34,7 @@ describe("telegram message cache", () => {
3434chat: { id: 7, type: "private", first_name: "Ada" },
3535message_id: 9001,
3636date: 1736380750,
37-text: "r u back from hermes",
37+text: "The cache warmer is the piece I meant",
3838from: { id: 2, is_bot: false, first_name: "Ada" },
3939reply_to_message: {
4040chat: { id: 7, type: "private", first_name: "Kesava" },
@@ -56,13 +56,13 @@ describe("telegram message cache", () => {
5656msg: {
5757chat: { id: 7, type: "private", first_name: "Grace" },
5858message_id: 9002,
59-text: "why did you reply?",
59+text: "Please explain what this reply was about",
6060from: { id: 3, is_bot: false, first_name: "Grace" },
6161reply_to_message: {
6262chat: { id: 7, type: "private", first_name: "Ada" },
6363message_id: 9001,
6464date: 1736380750,
65-text: "r u back from hermes",
65+text: "The cache warmer is the piece I meant",
6666from: { id: 2, is_bot: false, first_name: "Ada" },
6767} as Message["reply_to_message"],
6868} as Message,
@@ -71,7 +71,7 @@ describe("telegram message cache", () => {
7171expect(chain).toEqual([
7272expect.objectContaining({
7373messageId: "9001",
74-body: "r u back from hermes",
74+body: "The cache warmer is the piece I meant",
7575replyToId: "9000",
7676}),
7777expect.objectContaining({
@@ -84,4 +84,67 @@ describe("telegram message cache", () => {
8484await rm(persistedPath, { force: true });
8585}
8686});
87+88+it("shares one persisted bucket across live cache instances", async () => {
89+const storePath = `/tmp/openclaw-telegram-message-cache-shared-${process.pid}-${Date.now()}.json`;
90+const persistedPath = resolveTelegramMessageCachePath(storePath);
91+await rm(persistedPath, { force: true });
92+try {
93+const firstCache = createTelegramMessageCache({ persistedPath });
94+const secondCache = createTelegramMessageCache({ persistedPath });
95+firstCache.record({
96+accountId: "default",
97+chatId: 7,
98+msg: {
99+chat: { id: 7, type: "private", first_name: "Nora" },
100+message_id: 9100,
101+date: 1736380700,
102+text: "Architecture sketch for the cache warmer",
103+from: { id: 1, is_bot: false, first_name: "Nora" },
104+} as Message,
105+});
106+secondCache.record({
107+accountId: "default",
108+chatId: 7,
109+msg: {
110+chat: { id: 7, type: "private", first_name: "Ira" },
111+message_id: 9101,
112+date: 1736380750,
113+text: "The cache warmer is the piece I meant",
114+from: { id: 2, is_bot: false, first_name: "Ira" },
115+reply_to_message: {
116+chat: { id: 7, type: "private", first_name: "Nora" },
117+message_id: 9100,
118+date: 1736380700,
119+text: "Architecture sketch for the cache warmer",
120+from: { id: 1, is_bot: false, first_name: "Nora" },
121+} as Message["reply_to_message"],
122+} as Message,
123+});
124+125+const reloadedCache = createTelegramMessageCache({ persistedPath });
126+const chain = buildTelegramReplyChain({
127+cache: reloadedCache,
128+accountId: "default",
129+chatId: 7,
130+msg: {
131+chat: { id: 7, type: "private", first_name: "Mina" },
132+message_id: 9102,
133+text: "Please explain what this reply was about",
134+from: { id: 3, is_bot: false, first_name: "Mina" },
135+reply_to_message: {
136+chat: { id: 7, type: "private", first_name: "Ira" },
137+message_id: 9101,
138+date: 1736380750,
139+text: "The cache warmer is the piece I meant",
140+from: { id: 2, is_bot: false, first_name: "Ira" },
141+} as Message["reply_to_message"],
142+} as Message,
143+});
144+145+expect(chain.map((entry) => entry.messageId)).toEqual(["9101", "9100"]);
146+} finally {
147+await rm(persistedPath, { force: true });
148+}
149+});
87150});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。