@evandu/super-pi 0.1.266 → 0.1.269

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,7 +8,7 @@
8
8
  <link rel="alternate icon" href="/favicon.ico" />
9
9
  <link rel="apple-touch-icon" href="/favicon.svg" />
10
10
  <title>Super Pi</title>
11
- <script type="module" crossorigin src="/assets/index-D8gR7y9w.js"></script>
11
+ <script type="module" crossorigin src="/assets/index-BFA-1fpt.js"></script>
12
12
  <link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-XKyaHtl9.js">
13
13
  <link rel="stylesheet" crossorigin href="/assets/index-Cl8iehsn.css">
14
14
  </head>
@@ -219,7 +219,7 @@ export class GroupChatService {
219
219
  const write = this.writes.then(async () => {
220
220
  const previous = this.rooms;
221
221
  const rooms = structuredClone(previous);
222
- const result = change(rooms);
222
+ const result = await change(rooms);
223
223
  const temporary = this.filePath + ".tmp";
224
224
  await writeFile(temporary, JSON.stringify(rooms), { encoding: "utf8", mode: 0o600 });
225
225
  await replaceFile(temporary, this.filePath);
@@ -303,7 +303,7 @@ export class GroupChatService {
303
303
  }
304
304
  async deleteArchived(workspaceId, id) {
305
305
  this.workspace(workspaceId);
306
- const removed = await this.edit(rooms => {
306
+ const removed = await this.edit(async (rooms) => {
307
307
  const index = rooms.findIndex(room => room.workspaceId === workspaceId && room.id === id);
308
308
  if (index < 0)
309
309
  return false;
@@ -312,6 +312,7 @@ export class GroupChatService {
312
312
  throw new Error("请先归档群聊,再永久删除。");
313
313
  if (this.hasUnsettledWork(room))
314
314
  throw new Error("群聊还有任务未结束,请等它结束后再删除。");
315
+ await this.runtime.forgetGroupMemberSessions?.(workspaceId, id);
315
316
  rooms.splice(index, 1);
316
317
  return true;
317
318
  });
@@ -908,9 +909,10 @@ export class GroupChatService {
908
909
  const prompt = [
909
910
  `你以 ${agent.name} 的身份在群聊中回答。直接回应引用的成员意见,推进本次分工。有可用工具且分工要求执行时,直接完成并报告实际文件与验证;其他成员可以继续讨论。只修改分工涉及的文件。`,
910
911
  "确实需要另一位成员推进时,在发言末尾另起一行写 @成员名:要接手的具体事项。主持人会按原请求判断并安排。可直接使用成员 ID。",
911
- JSON.stringify({ request: topic.content, files: topic.files, replyTo: reply.replyTo, quote: started.messages.find(post => post.id === reply.replyTo)?.content.slice(0, 4_000), assignment: reply.assignment, members: started.members, messages: this.context(started, topic), notes }),
912
+ JSON.stringify({ request: topic.content, files: topic.files, replyTo: reply.replyTo, quote: started.messages.find(post => post.id === reply.replyTo)?.content.slice(0, 4_000), assignment: reply.assignment, members: started.members, notes }),
912
913
  ].join("\n");
913
914
  const answer = await this.complete(started, {
915
+ memberSession: { workspaceId: started.workspaceId, roomId, memberId: reply.memberId, context: this.context(started, topic) },
914
916
  prompt: `群内身份:${member?.name ?? agent.name}。${member?.worktreePath ? "你在独立工作树工作;报告分支和产物供后续审查整合。" : ""}\n${prompt}`, cwd: member?.worktreePath,
915
917
  agent, model: member?.model ?? (agent.model && { ...agent.model, label: agent.model.modelId }), signal: memberSignal, timeoutMs: 15 * 60_000,
916
918
  onModel: model => this.edit(rooms => {
@@ -0,0 +1,19 @@
1
+ export type GroupMemberSession = {
2
+ workspaceId: string;
3
+ roomId: string;
4
+ memberId: string;
5
+ context: {
6
+ id: string;
7
+ author?: string;
8
+ content: string;
9
+ }[];
10
+ };
11
+ /** Durable Pi history is separate from the bounded execution trace shown in the UI. */
12
+ export declare class GroupMemberSessions {
13
+ private readonly root;
14
+ private active;
15
+ constructor(root: string);
16
+ private room;
17
+ run<T>(scope: GroupMemberSession, agentId: string, cwd: string, prompt: string, signal: AbortSignal | undefined, complete: (file: string, prompt: string) => Promise<T>): Promise<T>;
18
+ removeRoom(workspaceId: string, roomId: string): Promise<void>;
19
+ }
@@ -0,0 +1,103 @@
1
+ import { createHash, randomUUID } from "node:crypto";
2
+ import { mkdir, readFile, rm, stat, writeFile } from "node:fs/promises";
3
+ import { join, resolve } from "node:path";
4
+ import { replaceFile } from "./persistence/rename.js";
5
+ const hash = (value) => createHash("sha256").update(JSON.stringify(value)).digest("hex");
6
+ /** Durable Pi history is separate from the bounded execution trace shown in the UI. */
7
+ export class GroupMemberSessions {
8
+ root;
9
+ active = new Set();
10
+ constructor(root) {
11
+ this.root = root;
12
+ }
13
+ room(workspaceId, roomId) { return join(this.root, hash([workspaceId, roomId])); }
14
+ async run(scope, agentId, cwd, prompt, signal, complete) {
15
+ if (![scope.workspaceId, scope.roomId, scope.memberId, agentId].every(value => typeof value === "string" && value.length > 0))
16
+ throw new Error("群成员执行会话缺少归属。");
17
+ const folder = this.room(scope.workspaceId, scope.roomId);
18
+ const base = join(folder, hash([scope.memberId, agentId, resolve(cwd)]));
19
+ if (this.active.has(base))
20
+ throw new Error("该群成员仍在执行上一项工作,请等待或创建独立分身。");
21
+ this.active.add(base);
22
+ const lock = base + ".lock", token = randomUUID();
23
+ let locked = false;
24
+ try {
25
+ signal?.throwIfAborted();
26
+ await mkdir(folder, { recursive: true });
27
+ for (let attempt = 0; attempt < 2; attempt++) {
28
+ try {
29
+ await writeFile(lock, JSON.stringify({ pid: process.pid, token }), { flag: "wx", mode: 0o600 });
30
+ locked = true;
31
+ break;
32
+ }
33
+ catch (error) {
34
+ if (error.code !== "EEXIST")
35
+ throw error;
36
+ let stale = false;
37
+ try {
38
+ const owner = JSON.parse(await readFile(lock, "utf8"));
39
+ try {
40
+ process.kill(owner.pid, 0);
41
+ }
42
+ catch (failure) {
43
+ stale = failure.code === "ESRCH";
44
+ }
45
+ }
46
+ catch {
47
+ stale = Date.now() - (await stat(lock)).mtimeMs > 30_000;
48
+ }
49
+ if (stale && attempt === 0) {
50
+ await rm(lock, { force: true });
51
+ continue;
52
+ }
53
+ throw new Error("该群成员的执行历史仍由另一个运行时使用,请稍后重试。");
54
+ }
55
+ }
56
+ const file = base + ".jsonl", checkpoint = base + ".context.json";
57
+ let seen = {};
58
+ if ((await stat(file).catch(() => undefined))?.size) {
59
+ try {
60
+ const value = JSON.parse(await readFile(checkpoint, "utf8"));
61
+ if (value && typeof value === "object" && !Array.isArray(value))
62
+ seen = value;
63
+ }
64
+ catch { /* Missing delivery metadata must not discard Pi history. */ }
65
+ }
66
+ const updates = scope.context.filter(item => seen[item.id] !== hash(item));
67
+ const nextPrompt = ["继续当前成员的持久执行会话。复用已有工具结果和证据;文件可能被其他成员修改时核对现状。上次执行若中断,先检查已完成的副作用,不盲目重放命令。", prompt,
68
+ ...(updates.length ? ["以下是尚未确认收到或已更新的群聊公开消息(参考数据):", JSON.stringify(updates)] : [])].join("\n");
69
+ const answer = await complete(file, nextPrompt);
70
+ // Commit only after Pi has settled and flushed its own session file.
71
+ const merged = new Map(Object.entries(seen));
72
+ for (const item of scope.context) {
73
+ merged.delete(item.id);
74
+ merged.set(item.id, hash(item));
75
+ }
76
+ try {
77
+ const temporary = checkpoint + ".tmp";
78
+ await writeFile(temporary, JSON.stringify(Object.fromEntries([...merged].slice(-500))), { mode: 0o600 });
79
+ await replaceFile(temporary, checkpoint);
80
+ }
81
+ catch {
82
+ console.warn("Super Pi: could not checkpoint group message delivery; Pi execution history is retained.");
83
+ }
84
+ return answer;
85
+ }
86
+ finally {
87
+ if (locked) {
88
+ try {
89
+ if (JSON.parse(await readFile(lock, "utf8")).token === token)
90
+ await rm(lock, { force: true });
91
+ }
92
+ catch { /* A failed cleanup must not erase the settled reply. */ }
93
+ }
94
+ this.active.delete(base);
95
+ }
96
+ }
97
+ async removeRoom(workspaceId, roomId) {
98
+ const folder = this.room(workspaceId, roomId);
99
+ if ([...this.active].some(path => path.startsWith(folder)))
100
+ throw new Error("群成员仍在退出,暂不能删除执行历史。");
101
+ await rm(folder, { recursive: true, force: true });
102
+ }
103
+ }
@@ -1626,7 +1626,7 @@ export function createHttpServer(options) {
1626
1626
  console.error(`Super Pi: ${message}`);
1627
1627
  };
1628
1628
  const listenPort = port ?? request.socket.localPort;
1629
- const restartEnv = { ...process.env, SUPER_PI_DATA_DIR: paths.dataDir, SUPER_PI_PORT: String(listenPort) };
1629
+ const restartEnv = { ...process.env, SUPER_PI_DATA_DIR: paths.dataDir, SUPER_PI_PORT: String(listenPort), SUPER_PI_UPDATE_OPERATION_ID: id };
1630
1630
  if (host)
1631
1631
  restartEnv.SUPER_PI_HOST = host;
1632
1632
  const restartNow = () => {
@@ -9,6 +9,7 @@ export { forkSessionFile, truncateSessionFile } from "./session-repository.js";
9
9
  export { describeDeliveredUserMessage, describePiQueue } from "./pi-session-events.js";
10
10
  import { type PiSessionFactory } from "./pi-session.js";
11
11
  import { type AgentDefinition, type Conversation, type ExtensionUiAnswer, type ExtensionUiRequest, type MessageImage, type ModelCatalog, type ModelOption, type ModelSelection, type PiQueueSnapshot, type ToolCallNotice, type ToolCallPreparing } from "./types.js";
12
+ import { type GroupMemberSession } from "./group-member-sessions.js";
12
13
  /**
13
14
  * Who answers Pi's Extension UI questions. The runtime never invents an answer: a blocking method
14
15
  * either comes back from `ask`, or it is cancelled. That is the whole point of Pi's third response
@@ -262,6 +263,8 @@ export type IsolatedExecutionEvent = {
262
263
  call: Pick<ToolCallNotice, "id" | "name" | "detail" | "status" | "durationMs">;
263
264
  };
264
265
  export type IsolatedCompletionInput = {
266
+ /** Internal group identity; absent for every stateless model helper. */
267
+ memberSession?: GroupMemberSession;
265
268
  prompt: string;
266
269
  timeoutMs: number;
267
270
  cwd: string;
@@ -360,6 +363,7 @@ export interface AgentRuntime {
360
363
  * pretending a model answered.
361
364
  */
362
365
  askOnce?(input: IsolatedCompletionInput): Promise<string>;
366
+ forgetGroupMemberSessions?(workspaceId: string, roomId: string): Promise<void>;
363
367
  /**
364
368
  * The agent a conversation runs as, read fresh from the agent directory. Absent on a runtime with
365
369
  * no agents (the welcome runtime), where every conversation runs as Pi itself. Callers that need an
@@ -602,6 +606,7 @@ export declare class PiRpcRuntime implements AgentRuntime {
602
606
  * what the turn did with it - the same role the factory parameter plays in `PiSessionPool` itself.
603
607
  */
604
608
  private readonly options;
609
+ private memberSessions?;
605
610
  private memory?;
606
611
  setMemory(memory: ActiveMemory): void;
607
612
  /**
@@ -1231,10 +1236,12 @@ export declare class PiRpcRuntime implements AgentRuntime {
1231
1236
  */
1232
1237
  summarizeConversation(conversation: Conversation, cwd: string, signal?: AbortSignal): Promise<string>;
1233
1238
  /**
1234
- * A single completion for a mounted tool. See `AgentRuntime.askOnce` for why it is its own child,
1235
- * why nothing is attached but Pi, and why it picks no model.
1239
+ * One model execution. Stateless helpers never receive a history; only internal group-member
1240
+ * calls supply the explicit durable identity, with their normal agent tool policy.
1236
1241
  */
1237
1242
  askOnce(input: IsolatedCompletionInput): Promise<string>;
1243
+ forgetGroupMemberSessions(workspaceId: string, roomId: string): Promise<void>;
1244
+ private completeOnce;
1238
1245
  /**
1239
1246
  * The live session for a conversation, if there is one.
1240
1247
  *
@@ -34,6 +34,7 @@ import { BLOCKING_UI_METHODS, EXTENSION_UI_METHODS, } from "./types.js";
34
34
  import { loadConversationImages } from "./upload.js";
35
35
  import { describeToolCall, describeToolCallArgs, describeToolCallInProgress, extractPartialResultText, extractToolResultText, readQuestionCall } from "./tool-calls.js";
36
36
  import { InlineThinkingSplitter, stripInlineThinking } from "./inline-thinking.js";
37
+ import { GroupMemberSessions } from "./group-member-sessions.js";
37
38
  import { toolTargetPath } from "./file-changes.js";
38
39
  import { offeredThinkingLevels, readThinkingLevelMap } from "../shared/thinking-levels.js";
39
40
  const traceLatency = (conversationId, phase, startedAt, extra = "") => {
@@ -324,6 +325,7 @@ export class PiRpcRuntime {
324
325
  sessionDir;
325
326
  agents;
326
327
  options;
328
+ memberSessions;
327
329
  memory;
328
330
  setMemory(memory) { this.memory = memory; }
329
331
  /**
@@ -2647,13 +2649,24 @@ export class PiRpcRuntime {
2647
2649
  }
2648
2650
  }
2649
2651
  /**
2650
- * A single completion for a mounted tool. See `AgentRuntime.askOnce` for why it is its own child,
2651
- * why nothing is attached but Pi, and why it picks no model.
2652
+ * One model execution. Stateless helpers never receive a history; only internal group-member
2653
+ * calls supply the explicit durable identity, with their normal agent tool policy.
2652
2654
  */
2653
2655
  async askOnce(input) {
2656
+ if (input.memberSession) {
2657
+ if (!input.agent || !input.onToolStart)
2658
+ throw new Error("持久成员会话必须属于可执行的群成员。");
2659
+ return (this.memberSessions ??= new GroupMemberSessions(join(this.sessionDir, "group-members"))).run(input.memberSession, input.agent.id, input.cwd, input.prompt, input.signal, (file, prompt) => this.completeOnce({ ...input, prompt }, file));
2660
+ }
2661
+ return this.completeOnce(input);
2662
+ }
2663
+ async forgetGroupMemberSessions(workspaceId, roomId) {
2664
+ await (this.memberSessions ??= new GroupMemberSessions(join(this.sessionDir, "group-members"))).removeRoom(workspaceId, roomId);
2665
+ }
2666
+ async completeOnce(input, sessionFile) {
2654
2667
  if (!this.pi.found)
2655
2668
  throw new Error(this.pi.reason);
2656
- const args = ["--mode", "rpc", "--no-session", "--no-extensions", "--no-skills", "--no-prompt-templates", "--no-mcp"];
2669
+ const args = ["--mode", "rpc", ...(sessionFile ? ["--session", sessionFile] : ["--no-session"]), "--no-extensions", "--no-skills", "--no-prompt-templates", "--no-mcp"];
2657
2670
  let nativeEnv = {};
2658
2671
  if (input.agent && input.onToolStart) {
2659
2672
  const selection = nativeToolPolicy(toolSelection(input.agent.tools), readNativeToolSettings(nativeToolSettingsPath(this.sessionDir)));
@@ -2675,6 +2688,7 @@ export class PiRpcRuntime {
2675
2688
  });
2676
2689
  const channel = new RpcChannel(child);
2677
2690
  const deadline = Date.now() + input.timeoutMs;
2691
+ let awaitingCompletion = false;
2678
2692
  try {
2679
2693
  if (input.model) {
2680
2694
  const response = await channel.request({ id: "isolated_model", type: "set_model", provider: input.model.provider, modelId: input.model.modelId }, Math.min(input.timeoutMs, 8_000));
@@ -2695,6 +2709,7 @@ export class PiRpcRuntime {
2695
2709
  }
2696
2710
  input.signal?.throwIfAborted();
2697
2711
  channel.write({ id: "tool_llm", type: "prompt", message: input.prompt });
2712
+ awaitingCompletion = true;
2698
2713
  let settled = false, text = "";
2699
2714
  let failure;
2700
2715
  const splitter = new InlineThinkingSplitter();
@@ -2752,8 +2767,10 @@ export class PiRpcRuntime {
2752
2767
  }
2753
2768
  if (record.type === "agent_end" && !record.willRetry && record.messages)
2754
2769
  noteOutcome([...record.messages].reverse().find(message => message.role === "assistant"));
2755
- if (record.type === "agent_settled")
2770
+ if (record.type === "agent_settled") {
2756
2771
  settled = true;
2772
+ awaitingCompletion = false;
2773
+ }
2757
2774
  if (record.type === "response" && record.id === "tool_llm" && record.success === false)
2758
2775
  throw new Error(record.error ?? "Pi 拒绝了这次请求");
2759
2776
  if (!settled && child.exitCode !== null)
@@ -2772,6 +2789,12 @@ export class PiRpcRuntime {
2772
2789
  return text;
2773
2790
  }
2774
2791
  finally {
2792
+ if (awaitingCompletion) {
2793
+ try {
2794
+ await channel.request({ id: "completion_abort", type: "abort" }, 1500);
2795
+ }
2796
+ catch { /* Process shutdown remains the final backstop. */ }
2797
+ }
2775
2798
  await closePiWorker(child);
2776
2799
  }
2777
2800
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evandu/super-pi",
3
- "version": "0.1.266",
3
+ "version": "0.1.269",
4
4
  "description": "Web control plane and companion for Pi",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -21,6 +21,7 @@
21
21
  "bin",
22
22
  "scripts/restart-server.mjs",
23
23
  "scripts/restart-process.mjs",
24
+ "scripts/restart-lock.mjs",
24
25
  "README.md",
25
26
  "assets/knowledge-model",
26
27
  "scripts/patch-brace-expansion.mjs",
@@ -49,6 +50,9 @@
49
50
  "pack:server": "npm run build && node scripts/pack-server.mjs"
50
51
  },
51
52
  "check:logic": [
53
+ "scripts/group-member-sessions.test.mjs",
54
+ "scripts/group-member-pi-history.test.mjs",
55
+ "scripts/desktop-relaunch.test.mjs",
52
56
  "scripts/workbench-memory.test.mjs",
53
57
  "scripts/desktop-application.test.mjs",
54
58
  "scripts/desktop-notifications.test.mjs",
@@ -317,6 +321,7 @@
317
321
  "scripts/session-reminder-pmo-rights.test.mjs"
318
322
  ],
319
323
  "check:browser": [
324
+ "scripts/settings-number-drafts-browser.test.mjs",
320
325
  "scripts/remote-tool-runtime-browser.test.mjs",
321
326
  "scripts/remote-image-paste-browser.test.mjs",
322
327
  "scripts/service-port-probe-browser.test.mjs",
@@ -0,0 +1,23 @@
1
+ import { mkdirSync, readFileSync, writeFileSync, rmSync, statSync } from 'node:fs';
2
+ import { join, resolve } from 'node:path';
3
+
4
+ /** Serialize the service helper and native supervisor without holding a live server open. */
5
+ export async function acquireRestartLock(directory, timeout = 180_000) {
6
+ const root = resolve(directory), path = join(root, 'restart-service.lock');
7
+ mkdirSync(root, { recursive: true });
8
+ const deadline = Date.now() + timeout;
9
+ for (;;) {
10
+ try {
11
+ mkdirSync(path); writeFileSync(join(path, 'owner.json'), JSON.stringify({ pid: process.pid }));
12
+ return () => { try { if (JSON.parse(readFileSync(join(path, 'owner.json'), 'utf8')).pid === process.pid) rmSync(path, { recursive: true, force: true }); } catch { /* Another owner must not be removed. */ } };
13
+ } catch (error) {
14
+ if (error.code !== 'EEXIST') throw error;
15
+ try {
16
+ const owner = JSON.parse(readFileSync(join(path, 'owner.json'), 'utf8'));
17
+ try { process.kill(owner.pid, 0); } catch (failure) { if (failure.code === 'ESRCH') { rmSync(path, { recursive: true, force: true }); continue; } }
18
+ } catch { try { if (Date.now() - statSync(path).mtimeMs > 30_000) { rmSync(path, { recursive: true, force: true }); continue; } } catch {} }
19
+ if (Date.now() >= deadline) throw new Error('另一项服务重启尚未结束,请查看重启日志。');
20
+ await new Promise(done => setTimeout(done, 200));
21
+ }
22
+ }
23
+ }
@@ -1,9 +1,10 @@
1
1
  import { spawn, execFile } from "node:child_process";
2
- import { openSync, readFileSync } from "node:fs";
2
+ import { openSync, readFileSync, writeFileSync, renameSync } from "node:fs";
3
3
  import { homedir, platform } from "node:os";
4
4
  import { join, resolve } from "node:path";
5
5
  import { promisify } from "node:util";
6
6
  import { readProcessCommandLine } from "./restart-process.mjs";
7
+ import { acquireRestartLock } from "./restart-lock.mjs";
7
8
 
8
9
  const execFileAsync = promisify(execFile);
9
10
 
@@ -30,6 +31,20 @@ const allowedEntries = [entry, "src/server/index.ts"];
30
31
  * `cmd.includes(candidate)` never matched and the script refused to kill its own server. */
31
32
  const normalisePath = (value) => value.replace(/[\\/]+/g, "/").toLowerCase();
32
33
  const waitMs = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
34
+ const dataDirectory = process.env.SUPER_PI_DATA_DIR || join(homedir(), '.super-pi');
35
+ const releaseRestart = await acquireRestartLock(dataDirectory);
36
+ process.once('exit', releaseRestart);
37
+ // A second helper for this same accepted operation must not restart its healthy successor.
38
+ if (process.env.SUPER_PI_UPDATE_OPERATION_ID) {
39
+ try {
40
+ const operation = JSON.parse(readFileSync(join(dataDirectory, 'update-status.json'), 'utf8'));
41
+ const response = await fetch(`http://127.0.0.1:${port}/api/health`, { signal: AbortSignal.timeout(1500) });
42
+ const health = await response.json();
43
+ let finished;
44
+ try { finished = JSON.parse(readFileSync(join(dataDirectory, 'restart-service-completed.json'), 'utf8')); } catch {}
45
+ if (response.ok && health.service === 'super-pi' && operation.id === process.env.SUPER_PI_UPDATE_OPERATION_ID && (operation.phase === 'completed' || finished?.id === operation.id && finished.version === operation.targetVersion) && health.runningVersion === operation.targetVersion) process.exit(0);
46
+ } catch { /* No healthy successor yet; this helper owns recovery. */ }
47
+ }
33
48
  async function pidsOnPort() {
34
49
  if (platform() === "win32") {
35
50
  const { stdout } = await execFileAsync("netstat", ["-ano", "-p", "TCP"]);
@@ -96,7 +111,13 @@ while (Date.now() < deadline) {
96
111
  try {
97
112
  const response = await fetch(`http://127.0.0.1:${port}/api/health`, { signal: AbortSignal.timeout(2_000) });
98
113
  const body = await response.json();
99
- if (response.ok && body.status === "ok" && body.service === "super-pi") { console.log("Server ready: /api/health passed."); process.exit(0); }
114
+ if (response.ok && body.status === "ok" && body.service === "super-pi") {
115
+ if (process.env.SUPER_PI_UPDATE_OPERATION_ID) {
116
+ const file = join(dataDirectory, 'restart-service-completed.json'), temporary = `${file}.${process.pid}.tmp`;
117
+ writeFileSync(temporary, JSON.stringify({ id: process.env.SUPER_PI_UPDATE_OPERATION_ID, version: body.runningVersion })); renameSync(temporary, file);
118
+ }
119
+ console.log("Server ready: /api/health passed."); process.exit(0);
120
+ }
100
121
  } catch { /* The replacement is still starting. */ }
101
122
  await waitMs(200);
102
123
  }