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

推荐订阅源

aimingoo的专栏
aimingoo的专栏
G
Google Developers Blog
B
Blog RSS Feed
A
About on SuperTechFans
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
V
V2EX
Stack Overflow Blog
Stack Overflow Blog
C
Check Point Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Engineering at Meta
Engineering at Meta
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园 - 司徒正美
D
Docker
F
Fortinet All Blogs
Hugging Face - Blog
Hugging Face - Blog
Last Week in AI
Last Week in AI
H
Help Net Security
WordPress大学
WordPress大学
MyScale Blog
MyScale Blog
博客园 - Franky
人人都是产品经理
人人都是产品经理
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Blog — PlanetScale
Blog — PlanetScale
L
LangChain 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 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
refactor: move MS Teams state migration to doctor · openc...
steipete · 2026-06-04 · via Recent Commits to openclaw:main

@@ -12,6 +12,27 @@ import type {

1212

} from "openclaw/plugin-sdk/runtime-doctor";

1313

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

1414

import { stateMigrations } from "./doctor-contract-api.js";

15+

import {

16+

buildMSTeamsConversationStateKey,

17+

MSTEAMS_CONVERSATIONS_NAMESPACE,

18+

type MSTeamsLegacyConversationStoreData,

19+

} from "./src/conversation-store-state.js";

20+

import type { StoredConversationReference } from "./src/conversation-store.js";

21+

import {

22+

buildMSTeamsPollStateKey,

23+

buildMSTeamsPollVoteBucketKey,

24+

MSTEAMS_POLL_VOTE_BUCKETS_NAMESPACE,

25+

MSTEAMS_POLLS_NAMESPACE,

26+

selectMSTeamsPollVoteBucket,

27+

type MSTeamsPoll,

28+

type StoredMSTeamsPoll,

29+

type StoredMSTeamsPollVoteBucket,

30+

} from "./src/polls.js";

31+

import {

32+

makeMSTeamsSsoTokenStoreKey,

33+

MSTEAMS_SSO_TOKENS_NAMESPACE,

34+

type MSTeamsSsoStoredToken,

35+

} from "./src/sso-token-store.js";

15361637

function createDoctorContext(env: NodeJS.ProcessEnv): PluginDoctorStateMigrationContext {

1738

return {

@@ -32,6 +53,14 @@ function learningStoreKey(storePath: string, sessionKey: string): string {

3253

return createHash("sha256").update(`${storePath}\0${sessionKey}`, "utf8").digest("hex");

3354

}

345556+

function migrationById(id: string) {

57+

const migration = stateMigrations.find((entry) => entry.id === id);

58+

if (!migration) {

59+

throw new Error(`missing migration ${id}`);

60+

}

61+

return migration;

62+

}

63+3564

describe("msteams doctor state migration", () => {

3665

let stateDir = "";

3766

let env: NodeJS.ProcessEnv;

@@ -46,6 +75,187 @@ describe("msteams doctor state migration", () => {

4675

await fs.rm(stateDir, { recursive: true, force: true });

4776

});

487778+

it("imports legacy conversations into plugin state", async () => {

79+

const filePath = path.join(stateDir, "msteams-conversations.json");

80+

const ref: StoredConversationReference = {

81+

conversation: { id: "19:conv@thread.tacv2" },

82+

channelId: "msteams",

83+

serviceUrl: "https://service.example.com",

84+

user: { id: "user-1" },

85+

};

86+

await fs.writeFile(

87+

filePath,

88+

`${JSON.stringify({

89+

version: 1,

90+

conversations: {

91+

"19:conv@thread.tacv2": ref,

92+

},

93+

} satisfies MSTeamsLegacyConversationStoreData)}\n`,

94+

);

95+96+

const migration = migrationById("msteams-conversations-json-to-plugin-state");

97+

const context = createDoctorContext(env);

98+

await expect(

99+

migration.detectLegacyState({

100+

config: {},

101+

env,

102+

stateDir,

103+

oauthDir: path.join(stateDir, "oauth"),

104+

context,

105+

}),

106+

).resolves.toMatchObject({

107+

preview: [expect.stringContaining("Microsoft Teams conversations")],

108+

});

109+110+

const result = await migration.migrateLegacyState({

111+

config: {},

112+

env,

113+

stateDir,

114+

oauthDir: path.join(stateDir, "oauth"),

115+

context,

116+

});

117+118+

expect(result.warnings).toEqual([]);

119+

expect(result.changes).toEqual([

120+

expect.stringContaining("Migrated 1 Microsoft Teams conversation entry"),

121+

expect.stringContaining("Archived Microsoft Teams conversation legacy source"),

122+

]);

123+

await expect(fs.access(filePath)).rejects.toThrow();

124+

await expect(fs.access(`${filePath}.migrated`)).resolves.toBeUndefined();

125+

const store = context.openPluginStateKeyedStore<StoredConversationReference>({

126+

namespace: MSTEAMS_CONVERSATIONS_NAMESPACE,

127+

maxEntries: 2000,

128+

});

129+

await expect(

130+

store.lookup(buildMSTeamsConversationStateKey("19:conv@thread.tacv2")),

131+

).resolves.toMatchObject({

132+

conversation: { id: "19:conv@thread.tacv2" },

133+

user: { id: "user-1" },

134+

});

135+

});

136+137+

it("imports legacy polls and vote buckets into plugin state", async () => {

138+

const filePath = path.join(stateDir, "msteams-polls.json");

139+

const poll: MSTeamsPoll = {

140+

id: "poll-legacy",

141+

question: "Lunch?",

142+

options: ["Pizza", "Sushi"],

143+

maxSelections: 1,

144+

createdAt: new Date().toISOString(),

145+

votes: {

146+

"user-legacy": ["0"],

147+

"user-new": ["1"],

148+

},

149+

};

150+

await fs.writeFile(

151+

filePath,

152+

`${JSON.stringify({

153+

version: 1,

154+

polls: {

155+

"poll-legacy": poll,

156+

},

157+

})}\n`,

158+

);

159+

const context = createDoctorContext(env);

160+

const voteBucketStore = context.openPluginStateKeyedStore<StoredMSTeamsPollVoteBucket>({

161+

namespace: MSTEAMS_POLL_VOTE_BUCKETS_NAMESPACE,

162+

maxEntries: 32_032,

163+

});

164+

const legacyBucket = selectMSTeamsPollVoteBucket("poll-legacy", "user-legacy");

165+

await voteBucketStore.register(buildMSTeamsPollVoteBucketKey("poll-legacy", legacyBucket), {

166+

pollId: "poll-legacy",

167+

bucket: legacyBucket,

168+

votes: { "user-legacy": ["1"] },

169+

updatedAt: poll.createdAt,

170+

});

171+172+

const migration = migrationById("msteams-polls-json-to-plugin-state");

173+

const result = await migration.migrateLegacyState({

174+

config: {},

175+

env,

176+

stateDir,

177+

oauthDir: path.join(stateDir, "oauth"),

178+

context,

179+

});

180+181+

expect(result.warnings).toEqual([]);

182+

expect(result.changes).toEqual([

183+

expect.stringContaining("Migrated 1 Microsoft Teams poll entry"),

184+

expect.stringContaining("Archived Microsoft Teams poll legacy source"),

185+

]);

186+

const pollStore = context.openPluginStateKeyedStore<StoredMSTeamsPoll>({

187+

namespace: MSTEAMS_POLLS_NAMESPACE,

188+

maxEntries: 2000,

189+

});

190+

await expect(pollStore.lookup(buildMSTeamsPollStateKey("poll-legacy"))).resolves.toMatchObject({

191+

id: "poll-legacy",

192+

question: "Lunch?",

193+

});

194+

const newBucket = selectMSTeamsPollVoteBucket("poll-legacy", "user-new");

195+

await expect(

196+

voteBucketStore.lookup(buildMSTeamsPollVoteBucketKey("poll-legacy", legacyBucket)),

197+

).resolves.toMatchObject({

198+

votes: { "user-legacy": ["1"] },

199+

});

200+

await expect(

201+

voteBucketStore.lookup(buildMSTeamsPollVoteBucketKey("poll-legacy", newBucket)),

202+

).resolves.toMatchObject({

203+

votes: { "user-new": ["1"] },

204+

});

205+

await expect(fs.access(`${filePath}.migrated`)).resolves.toBeUndefined();

206+

});

207+208+

it("imports legacy SSO tokens into the existing plugin-state token namespace", async () => {

209+

const filePath = path.join(stateDir, "msteams-sso-tokens.json");

210+

const token: MSTeamsSsoStoredToken = {

211+

connectionName: "conn::alpha",

212+

userId: "user::one",

213+

token: "test-token-value",

214+

updatedAt: "2026-04-10T00:00:00.000Z",

215+

};

216+

await fs.writeFile(

217+

filePath,

218+

`${JSON.stringify({

219+

version: 1,

220+

tokens: {

221+

"legacy::wrong-key": token,

222+

},

223+

})}\n`,

224+

);

225+226+

const migration = migrationById("msteams-sso-tokens-json-to-plugin-state");

227+

const context = createDoctorContext(env);

228+

const result = await migration.migrateLegacyState({

229+

config: {},

230+

env,

231+

stateDir,

232+

oauthDir: path.join(stateDir, "oauth"),

233+

context,

234+

});

235+236+

expect(result.warnings).toEqual([]);

237+

expect(result.changes).toEqual([

238+

expect.stringContaining("Migrated 1 Microsoft Teams SSO token entry"),

239+

expect.stringContaining("Archived Microsoft Teams SSO-token legacy source"),

240+

]);

241+

const store = context.openPluginStateKeyedStore<MSTeamsSsoStoredToken>({

242+

namespace: MSTEAMS_SSO_TOKENS_NAMESPACE,

243+

maxEntries: 5000,

244+

});

245+

await expect(

246+

store.lookup(makeMSTeamsSsoTokenStoreKey("conn::alpha", "user::one")),

247+

).resolves.toEqual(token);

248+

expect(result.changes.join("\n")).not.toContain(token.token);

249+

expect(result.warnings.join("\n")).not.toContain(token.token);

250+

await expect(fs.access(`${filePath}.migrated`)).resolves.toBeUndefined();

251+

});

252+253+

it("does not register a doctor migration for pending-upload cache files", () => {

254+

expect(stateMigrations.map((migration) => migration.id)).not.toContain(

255+

"msteams-pending-uploads-json-to-plugin-state",

256+

);

257+

});

258+49259

it("imports legacy feedback learnings into plugin state", async () => {

50260

const agentStoreTemplate = path.join(stateDir, "agents", "{agentId}", "sessions");

51261

const mainStorePath = path.join(stateDir, "agents", "main", "sessions");

@@ -69,7 +279,7 @@ describe("msteams doctor state migration", () => {

69279

await fs.writeFile(encodedSourcePath, JSON.stringify(["Be concise", "Use examples"]));

70280

await fs.writeFile(sanitizedSourcePath, JSON.stringify(["Prefer cards for channel feedback"]));

7128172-

const migration = stateMigrations[0];

282+

const migration = migrationById("msteams-feedback-learnings-json-to-plugin-state");

73283

const context = createDoctorContext(env);

74284

await context

75285

.openPluginStateKeyedStore({