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

推荐订阅源

云风的 BLOG
云风的 BLOG
V
Visual Studio Blog
人人都是产品经理
人人都是产品经理
The GitHub Blog
The GitHub Blog
月光博客
月光博客
T
Tailwind CSS Blog
小众软件
小众软件
Y
Y Combinator Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
P
Proofpoint News Feed
B
Blog RSS Feed
博客园 - 司徒正美
A
About on SuperTechFans
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园 - 聂微东
Microsoft Security Blog
Microsoft Security Blog
Recent Announcements
Recent Announcements
博客园 - Franky
U
Unit 42
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Microsoft Azure Blog
Microsoft Azure Blog
T
The Blog of Author Tim Ferriss
GbyAI
GbyAI
Apple Machine Learning Research
Apple Machine Learning Research

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: serialize config mutation writes · openclaw/openclaw...
steipete · 2026-05-13 · via Recent Commits to openclaw:main

@@ -13,6 +13,45 @@ const writeConfigFileMock = vi.hoisted(() => vi.fn().mockResolvedValue(undefined

1313

const replaceConfigFileMock = vi.hoisted(() =>

1414

vi.fn(async (params: { nextConfig: unknown }) => await writeConfigFileMock(params.nextConfig)),

1515

);

16+

const transformConfigWithPendingPluginInstallsMock = vi.hoisted(() =>

17+

vi.fn(

18+

async (params: {

19+

transform: (

20+

config: Record<string, unknown>,

21+

context: {

22+

snapshot: Record<string, unknown>;

23+

previousHash: string | null;

24+

attempt: number;

25+

},

26+

) =>

27+

| Promise<{ nextConfig: unknown; result?: unknown }>

28+

| { nextConfig: unknown; result?: unknown };

29+

}) => {

30+

const snapshot = (await readConfigFileSnapshotMock()) as {

31+

path?: string;

32+

hash?: string;

33+

config?: Record<string, unknown>;

34+

sourceConfig?: Record<string, unknown>;

35+

};

36+

const transformed = await params.transform(snapshot.sourceConfig ?? snapshot.config ?? {}, {

37+

snapshot,

38+

previousHash: snapshot.hash ?? null,

39+

attempt: 0,

40+

});

41+

await writeConfigFileMock(transformed.nextConfig);

42+

return {

43+

path: snapshot.path ?? "/tmp/openclaw.json",

44+

previousHash: snapshot.hash ?? null,

45+

snapshot,

46+

nextConfig: transformed.nextConfig,

47+

result: transformed.result,

48+

attempts: 1,

49+

afterWrite: { mode: "auto" },

50+

followUp: { mode: "auto", requiresRestart: false },

51+

};

52+

},

53+

),

54+

);

16551756

const wizardMocks = vi.hoisted(() => ({

1857

createClackPrompter: vi.fn(),

@@ -25,6 +64,13 @@ vi.mock("../config/config.js", async () => ({

2564

replaceConfigFile: replaceConfigFileMock,

2665

}));

276667+

vi.mock("../cli/plugins-install-record-commit.js", async () => ({

68+

...(await vi.importActual<typeof import("../cli/plugins-install-record-commit.js")>(

69+

"../cli/plugins-install-record-commit.js",

70+

)),

71+

transformConfigWithPendingPluginInstalls: transformConfigWithPendingPluginInstallsMock,

72+

}));

73+2874

vi.mock("../wizard/clack-prompter.js", () => ({

2975

createClackPrompter: wizardMocks.createClackPrompter,

3076

}));

@@ -44,6 +90,7 @@ describe("agents add command", () => {

4490

readConfigFileSnapshotMock.mockClear();

4591

writeConfigFileMock.mockClear();

4692

replaceConfigFileMock.mockClear();

93+

transformConfigWithPendingPluginInstallsMock.mockClear();

4794

wizardMocks.createClackPrompter.mockClear();

4895

runtime.log.mockClear();

4996

runtime.error.mockClear();

@@ -227,4 +274,98 @@ describe("agents add command", () => {

227274

}),

228275

).toBe('OAuth profiles stay shared from "main" unless this agent signs in separately.');

229276

});

277+278+

describe("non-interactive config mutation", () => {

279+

it("rebases agent creation on the latest config snapshot", async () => {

280+

readConfigFileSnapshotMock

281+

.mockResolvedValueOnce({

282+

...baseConfigSnapshot,

283+

hash: "hash-1",

284+

config: { agents: { list: [] } },

285+

sourceConfig: { agents: { list: [] } },

286+

})

287+

.mockResolvedValueOnce({

288+

...baseConfigSnapshot,

289+

hash: "hash-2",

290+

config: { agents: { list: [{ id: "other-agent" }] } },

291+

sourceConfig: { agents: { list: [{ id: "other-agent" }] } },

292+

});

293+294+

await agentsAddCommand({ name: "Work", workspace: "/tmp/work" }, runtime, {

295+

hasFlags: true,

296+

});

297+298+

expect(transformConfigWithPendingPluginInstallsMock).toHaveBeenCalledOnce();

299+

expect(writeConfigFileMock).toHaveBeenCalledWith(

300+

expect.objectContaining({

301+

agents: {

302+

list: [

303+

{ id: "other-agent" },

304+

expect.objectContaining({ id: "work", workspace: "/tmp/work" }),

305+

],

306+

},

307+

}),

308+

);

309+

expect(runtime.exit).not.toHaveBeenCalled();

310+

expect(runtime.error).not.toHaveBeenCalled();

311+

});

312+313+

it("fails instead of overwriting when the same agent appears before commit", async () => {

314+

readConfigFileSnapshotMock

315+

.mockResolvedValueOnce({

316+

...baseConfigSnapshot,

317+

hash: "hash-1",

318+

config: { agents: { list: [] } },

319+

sourceConfig: { agents: { list: [] } },

320+

})

321+

.mockResolvedValueOnce({

322+

...baseConfigSnapshot,

323+

hash: "hash-2",

324+

config: { agents: { list: [{ id: "work", workspace: "/tmp/other" }] } },

325+

sourceConfig: { agents: { list: [{ id: "work", workspace: "/tmp/other" }] } },

326+

});

327+328+

await agentsAddCommand({ name: "Work", workspace: "/tmp/work" }, runtime, {

329+

hasFlags: true,

330+

});

331+332+

expect(writeConfigFileMock).not.toHaveBeenCalled();

333+

expect(runtime.error).toHaveBeenCalledWith('Agent "work" already exists.');

334+

expect(runtime.exit).toHaveBeenCalledWith(1);

335+

});

336+337+

it("reports binding conflicts from the committed mutation", async () => {

338+

readConfigFileSnapshotMock

339+

.mockResolvedValueOnce({

340+

...baseConfigSnapshot,

341+

hash: "hash-1",

342+

config: { agents: { list: [] } },

343+

sourceConfig: { agents: { list: [] } },

344+

})

345+

.mockResolvedValueOnce({

346+

...baseConfigSnapshot,

347+

hash: "hash-2",

348+

config: {

349+

agents: { list: [{ id: "other-agent" }] },

350+

bindings: [{ type: "route", agentId: "other-agent", match: { channel: "telegram" } }],

351+

},

352+

sourceConfig: {

353+

agents: { list: [{ id: "other-agent" }] },

354+

bindings: [{ type: "route", agentId: "other-agent", match: { channel: "telegram" } }],

355+

},

356+

});

357+358+

await agentsAddCommand(

359+

{ name: "Work", workspace: "/tmp/work", bind: ["telegram"], json: true },

360+

runtime,

361+

{ hasFlags: true },

362+

);

363+364+

const payload = JSON.parse(String(runtime.log.mock.calls.at(-1)?.[0])) as {

365+

bindings: { added: string[]; conflicts: string[] };

366+

};

367+

expect(payload.bindings.added).toEqual([]);

368+

expect(payload.bindings.conflicts).toEqual(["telegram (agent=other-agent)"]);

369+

});

370+

});

230371

});