惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Recent Announcements
Recent Announcements
爱范儿
爱范儿
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
宝玉的分享
宝玉的分享
T
Tailwind CSS Blog
博客园_首页
IT之家
IT之家
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - 三生石上(FineUI控件)
有赞技术团队
有赞技术团队
大猫的无限游戏
大猫的无限游戏
雷峰网
雷峰网
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
博客园 - 司徒正美
WordPress大学
WordPress大学
Last Week in AI
Last Week in AI
人人都是产品经理
人人都是产品经理
Jina AI
Jina AI
月光博客
月光博客
小众软件
小众软件
S
SegmentFault 最新的问题
量子位
阮一峰的网络日志
阮一峰的网络日志
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix(telegram): migrate legacy cache sidecars · openclaw/o...
obviyus · 2026-05-24 · via Recent Commits to openclaw:main

@@ -5,8 +5,14 @@ import type { Message } from "grammy/types";

55

import type { OpenClawConfig } from "openclaw/plugin-sdk/config-contracts";

66

import { resolveStorePath } from "openclaw/plugin-sdk/session-store-runtime";

77

import { describe, expect, it } from "vitest";

8+

import { resolveTelegramBotInfoCachePath } from "./bot-info-cache.js";

89

import { resolveTelegramMessageCachePath } from "./message-cache.js";

910

import { detectTelegramLegacyStateMigrations } from "./state-migrations.js";

11+

import {

12+

resolveTopicNameCacheNamespace,

13+

resolveTopicNameCachePath,

14+

resolveTopicNameCacheScope,

15+

} from "./topic-name-cache.js";

10161117

type PersistedCacheEntry = {

1218

key: string;

@@ -31,6 +37,74 @@ function persistedCacheEntry(messageId: number, text: string): PersistedCacheEnt

3137

}

32383339

describe("telegram state migrations", () => {

40+

it("detects legacy bot-info cache import", async () => {

41+

const dir = await mkdtemp(path.join(os.tmpdir(), "openclaw-telegram-state-migration-"));

42+

const env = { ...process.env, OPENCLAW_STATE_DIR: dir };

43+

const persistedPath = resolveTelegramBotInfoCachePath("ops", env);

44+

try {

45+

await mkdir(path.dirname(persistedPath), { recursive: true });

46+

await writeFile(

47+

persistedPath,

48+

JSON.stringify({

49+

version: 1,

50+

tokenFingerprint: "token:fingerprint",

51+

fetchedAt: "2026-05-24T11:00:00.000Z",

52+

botInfo: {

53+

id: 123456,

54+

is_bot: true,

55+

first_name: "OpenClaw",

56+

username: "openclaw_bot",

57+

},

58+

}),

59+

);

60+61+

const cfg = {

62+

channels: {

63+

telegram: {

64+

accounts: {

65+

ops: {

66+

botToken: "123456:secret",

67+

},

68+

},

69+

},

70+

},

71+

} as OpenClawConfig;

72+

const plans = await detectTelegramLegacyStateMigrations({ cfg, env });

73+

const botInfoPlan = plans.find(

74+

(plan) =>

75+

plan.kind === "plugin-state-import" && plan.label === "Telegram startup bot info cache",

76+

);

77+78+

expect(botInfoPlan).toMatchObject({

79+

kind: "plugin-state-import",

80+

sourcePath: persistedPath,

81+

targetPath: "plugin state:telegram.bot-info-cache",

82+

pluginId: "telegram",

83+

namespace: "telegram.bot-info-cache",

84+

scopeKey: "",

85+

});

86+

if (!botInfoPlan || botInfoPlan.kind !== "plugin-state-import") {

87+

throw new Error("expected Telegram bot-info plugin-state import plan");

88+

}

89+90+

const entries = await botInfoPlan.readEntries();

91+

expect(entries).toHaveLength(1);

92+

expect(entries[0]).toMatchObject({

93+

key: "ops",

94+

value: {

95+

tokenFingerprint: "token:fingerprint",

96+

fetchedAt: "2026-05-24T11:00:00.000Z",

97+

botInfo: {

98+

id: 123456,

99+

username: "openclaw_bot",

100+

},

101+

},

102+

});

103+

} finally {

104+

await rm(dir, { recursive: true, force: true });

105+

}

106+

});

107+34108

it("detects legacy message-cache import for the runtime sidecar path", async () => {

35109

const dir = await mkdtemp(path.join(os.tmpdir(), "openclaw-telegram-state-migration-"));

36110

const env = { ...process.env, OPENCLAW_STATE_DIR: dir };

@@ -73,4 +147,62 @@ describe("telegram state migrations", () => {

73147

await rm(dir, { recursive: true, force: true });

74148

}

75149

});

150+151+

it("detects legacy topic-name cache import for the runtime sidecar path", async () => {

152+

const dir = await mkdtemp(path.join(os.tmpdir(), "openclaw-telegram-state-migration-"));

153+

const env = { ...process.env, OPENCLAW_STATE_DIR: dir };

154+

const storePath = resolveStorePath(undefined, { env });

155+

const persistedPath = resolveTopicNameCachePath(storePath);

156+

const namespace = resolveTopicNameCacheNamespace(resolveTopicNameCacheScope(storePath));

157+

try {

158+

await mkdir(path.dirname(persistedPath), { recursive: true });

159+

await writeFile(

160+

persistedPath,

161+

JSON.stringify({

162+

"7:42": {

163+

name: "Deployments",

164+

iconColor: 0x6fb9f0,

165+

updatedAt: 1736380000,

166+

},

167+

}),

168+

);

169+170+

const cfg = {

171+

agents: {

172+

list: [{ id: "ops", default: true }],

173+

},

174+

} as OpenClawConfig;

175+

const plans = await detectTelegramLegacyStateMigrations({ cfg, env });

176+

const topicNamePlan = plans.find(

177+

(plan) =>

178+

plan.kind === "plugin-state-import" && plan.label === "Telegram forum topic-name cache",

179+

);

180+181+

expect(topicNamePlan).toMatchObject({

182+

kind: "plugin-state-import",

183+

sourcePath: persistedPath,

184+

targetPath: `plugin state:${namespace}`,

185+

pluginId: "telegram",

186+

namespace,

187+

scopeKey: "",

188+

});

189+

if (!topicNamePlan || topicNamePlan.kind !== "plugin-state-import") {

190+

throw new Error("expected Telegram topic-name plugin-state import plan");

191+

}

192+193+

const entries = await topicNamePlan.readEntries();

194+

expect(entries).toStrictEqual([

195+

{

196+

key: "7:42",

197+

value: {

198+

name: "Deployments",

199+

iconColor: 0x6fb9f0,

200+

updatedAt: 1736380000,

201+

},

202+

},

203+

]);

204+

} finally {

205+

await rm(dir, { recursive: true, force: true });

206+

}

207+

});

76208

});