diff --git a/src/cli/update-cli.test.ts b/src/cli/update-cli.test.ts index 14c7a949df6..480b1b64466 100644 --- a/src/cli/update-cli.test.ts +++ b/src/cli/update-cli.test.ts @@ -782,6 +782,31 @@ describe("update-cli", () => { expect(spawn).not.toHaveBeenCalled(); }); + it("post-core resume children exit after writing a plugin update result", async () => { + const resultDir = createCaseDir("openclaw-post-core-result"); + const resultPath = path.join(resultDir, "plugins.json"); + await fs.mkdir(resultDir, { recursive: true }); + + await withEnvAsync( + { + OPENCLAW_UPDATE_POST_CORE: "1", + OPENCLAW_UPDATE_POST_CORE_CHANNEL: "stable", + OPENCLAW_UPDATE_POST_CORE_RESULT_PATH: resultPath, + }, + async () => { + await updateCommand({ restart: false }); + }, + ); + + const result = JSON.parse(await fs.readFile(resultPath, "utf-8")) as { + status?: string; + }; + expect(result.status).toBe("ok"); + expect(defaultRuntime.exit).toHaveBeenCalledWith(0); + expect(runGatewayUpdate).not.toHaveBeenCalled(); + expect(spawn).not.toHaveBeenCalled(); + }); + it("post-core resume mode persists the requested update channel with the updated process", async () => { vi.mocked(readConfigFileSnapshot).mockResolvedValue({ ...baseSnapshot, diff --git a/src/cli/update-cli/update-command.ts b/src/cli/update-cli/update-command.ts index 29aa81745a5..774eab7bf61 100644 --- a/src/cli/update-cli/update-command.ts +++ b/src/cli/update-cli/update-command.ts @@ -1831,6 +1831,10 @@ export async function updateCommand(opts: UpdateCommandOptions): Promise { defaultRuntime.exit(1); return; } + if (process.env[POST_CORE_UPDATE_RESULT_PATH_ENV]) { + defaultRuntime.exit(0); + return; + } return; }