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

推荐订阅源

Google DeepMind News
Google DeepMind News
博客园 - 司徒正美
WordPress大学
WordPress大学
爱范儿
爱范儿
小众软件
小众软件
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
罗磊的独立博客
博客园_首页
V
V2EX
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
T
Tailwind CSS Blog
大猫的无限游戏
大猫的无限游戏
The Cloudflare Blog
MyScale Blog
MyScale Blog
IT之家
IT之家
H
Help Net Security
Blog — PlanetScale
Blog — PlanetScale
Microsoft Security Blog
Microsoft Security Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Recent Announcements
Recent Announcements
F
Fortinet All Blogs
The GitHub Blog
The GitHub Blog
Y
Y Combinator Blog
人人都是产品经理
人人都是产品经理

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 test: merge chat context notice checks · openclaw/openclaw@5c2f4af 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 channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
test: mock legacy state plugin boundaries · openclaw/open...
steipete · 2026-04-17 · via Recent Commits to openclaw:main

@@ -18,6 +18,123 @@ import {

18181919

let tempRoot: string | null = null;

202021+

vi.mock("../channels/plugins/bundled.js", () => {

22+

function fileExists(filePath: string): boolean {

23+

try {

24+

return fs.existsSync(filePath) && fs.statSync(filePath).isFile();

25+

} catch {

26+

return false;

27+

}

28+

}

29+30+

function resolveTelegramAccountId(cfg: OpenClawConfig): string {

31+

const defaultAgentId = cfg.agents?.list?.find((agent) => agent.default)?.id ?? "main";

32+

const boundAccountId = cfg.bindings?.find(

33+

(binding) =>

34+

binding.agentId === defaultAgentId &&

35+

binding.match?.channel === "telegram" &&

36+

typeof binding.match.accountId === "string",

37+

)?.match.accountId;

38+

return boundAccountId ?? cfg.channels?.telegram?.defaultAccount ?? "default";

39+

}

40+41+

function detectTelegramAllowFromMigration(params: {

42+

cfg: OpenClawConfig;

43+

env: NodeJS.ProcessEnv;

44+

}) {

45+

const root = params.env.OPENCLAW_STATE_DIR;

46+

if (!root) {

47+

return [];

48+

}

49+

const legacyPath = path.join(root, "credentials", "telegram-allowFrom.json");

50+

if (!fileExists(legacyPath)) {

51+

return [];

52+

}

53+

const targetPath = path.join(

54+

root,

55+

"credentials",

56+

`telegram-${resolveTelegramAccountId(params.cfg)}-allowFrom.json`,

57+

);

58+

return fileExists(targetPath)

59+

? []

60+

: [

61+

{

62+

kind: "copy" as const,

63+

label: "Telegram pairing allowFrom",

64+

sourcePath: legacyPath,

65+

targetPath,

66+

},

67+

];

68+

}

69+70+

function detectWhatsAppLegacyStateMigrations(params: { oauthDir: string }) {

71+

let entries: fs.Dirent[] = [];

72+

try {

73+

entries = fs.readdirSync(params.oauthDir, { withFileTypes: true });

74+

} catch {

75+

return [];

76+

}

77+

return entries.flatMap((entry) => {

78+

const isLegacyAuthFile =

79+

entry.name === "creds.json" ||

80+

entry.name === "creds.json.bak" ||

81+

(/^(app-state-sync|session|sender-key|pre-key)-/.test(entry.name) &&

82+

entry.name.endsWith(".json"));

83+

if (!entry.isFile() || entry.name === "oauth.json" || !isLegacyAuthFile) {

84+

return [];

85+

}

86+

const sourcePath = path.join(params.oauthDir, entry.name);

87+

const targetPath = path.join(params.oauthDir, "whatsapp", "default", entry.name);

88+

return fileExists(targetPath)

89+

? []

90+

: [{ kind: "move" as const, label: `WhatsApp auth ${entry.name}`, sourcePath, targetPath }];

91+

});

92+

}

93+94+

return {

95+

listBundledChannelSetupPluginsByFeature: vi.fn((feature: string) => {

96+

if (feature === "legacySessionSurfaces") {

97+

return [

98+

{

99+

id: "whatsapp",

100+

messaging: {

101+

isLegacyGroupSessionKey: (key: string) => /^group:.+@g\.us$/i.test(key.trim()),

102+

canonicalizeLegacySessionKey: ({ key, agentId }: { key: string; agentId: string }) =>

103+

/^group:.+@g\.us$/i.test(key.trim())

104+

? `agent:${agentId}:whatsapp:${key.trim().toLowerCase()}`

105+

: null,

106+

},

107+

},

108+

];

109+

}

110+

if (feature === "legacyStateMigrations") {

111+

return [

112+

{

113+

id: "whatsapp",

114+

lifecycle: {

115+

detectLegacyStateMigrations: ({ oauthDir }: { oauthDir: string }) =>

116+

detectWhatsAppLegacyStateMigrations({ oauthDir }),

117+

},

118+

},

119+

{

120+

id: "telegram",

121+

lifecycle: {

122+

detectLegacyStateMigrations: ({

123+

cfg,

124+

env,

125+

}: {

126+

cfg: OpenClawConfig;

127+

env: NodeJS.ProcessEnv;

128+

}) => detectTelegramAllowFromMigration({ cfg, env }),

129+

},

130+

},

131+

];

132+

}

133+

return [];

134+

}),

135+

};

136+

});

137+21138

vi.mock("../infra/json-files.js", async () => {

22139

const actual =

23140

await vi.importActual<typeof import("../infra/json-files.js")>("../infra/json-files.js");