cotal-ai 0.164.7 → 0.164.9
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.
- package/dist/daemon/auto-update.js +11 -7
- package/dist/daemon/client.js +25 -3
- package/dist/daemon/command.js +44 -6
- package/dist/daemon/desktop.js +12 -2
- package/dist/daemon/install.js +7 -3
- package/dist/daemon/lifetime.js +9 -5
- package/dist/daemon/update-entry.js +202 -187
- package/dist/update-notice.js +2 -2
- package/package.json +19 -19
- package/seeded-connectors/_shared/docs-bundle.bin +0 -0
- package/seeded-connectors/_shared/docs-index.bin +0 -0
- package/seeded-connectors/_shared/placements.json +2 -2
- package/seeded-connectors/claude/dist/index.js +1 -1
- package/seeded-connectors/claude/dist/mcp.cjs +6 -6
- package/seeded-connectors/claude/package.json +1 -1
- package/seeded-connectors/codex/dist/host.js +6 -6
- package/seeded-connectors/codex/dist/index.js +1 -1
- package/seeded-connectors/codex/dist/personal.js +6 -6
- package/seeded-connectors/codex/package.json +1 -1
- package/seeded-connectors/hermes/dist/index.js +1 -1
- package/seeded-connectors/hermes/dist/launch.js +6 -6
- package/seeded-connectors/hermes/package.json +1 -1
- package/seeded-connectors/hermes/plugin/cotal/_sidecar/standalone.cjs +6 -6
- package/seeded-connectors/jcode/dist/host.js +6 -6
- package/seeded-connectors/jcode/dist/index.js +1 -1
- package/seeded-connectors/jcode/dist/mcp.js +4 -4
- package/seeded-connectors/jcode/package.json +1 -1
- package/seeded-connectors/opencode/dist/index.js +1 -1
- package/seeded-connectors/opencode/dist/plugin/index.js +6 -6
- package/seeded-connectors/opencode/package.json +1 -1
- package/seeded-connectors/pi/dist/index.js +2 -2
- package/seeded-connectors/pi/dist/standalone.js +6 -6
- package/seeded-connectors/pi/package.json +1 -1
- package/seeded-connectors/web/package.json +1 -1
|
@@ -3,7 +3,7 @@ import { readFileSync, existsSync, closeSync, ftruncateSync } from "node:fs";
|
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
4
|
import { join } from "node:path";
|
|
5
5
|
import { openPrivateAppend, writeSecretFileAtomic } from "@cotal-ai/core";
|
|
6
|
-
import { checkForUpdate, homeCotalDir, newerUpdate, readUpdateCheck, readUpdateRecovery, readUpdateSettings, UPDATE_DAY_MS, UPDATE_HOUR_MS } from "@cotal-ai/workspace";
|
|
6
|
+
import { checkForUpdate, homeCotalDir, newerUpdate, readUpdateCheck, readUpdateRecovery, readUpdateSettings, recoveryDisposition, UPDATE_DAY_MS, UPDATE_HOUR_MS } from "@cotal-ai/workspace";
|
|
7
7
|
import { cleanLaunchUpdate, startLaunchUpdate } from "./update-launchd.js";
|
|
8
8
|
/** Schedule only the existing updater. Manager preparation holds its native empty-seat admission fence. */
|
|
9
9
|
export function automaticUpdates(host) {
|
|
@@ -46,8 +46,10 @@ export function automaticUpdates(host) {
|
|
|
46
46
|
automatic = ["linux", "darwin"].includes(process.platform) && !desktop && settings.auto && process.env.COTAL_NO_UPDATE_CHECK !== "1" && host.eligible();
|
|
47
47
|
const recovery = readUpdateRecovery();
|
|
48
48
|
if (recovery) {
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
const decision = recoveryDisposition(recovery);
|
|
50
|
+
if (decision.action !== "retire")
|
|
51
|
+
automatic = false;
|
|
52
|
+
reason = `automatic updates ${decision.action === "retire" ? "can resume" : "paused"}: installed ${recovery.installed}; ${recovery.reason}; ${decision.instruction}`;
|
|
51
53
|
}
|
|
52
54
|
}
|
|
53
55
|
catch (error) {
|
|
@@ -81,7 +83,9 @@ export function automaticUpdates(host) {
|
|
|
81
83
|
}
|
|
82
84
|
const settings = readUpdateSettings();
|
|
83
85
|
const cached = process.env.COTAL_NO_UPDATE_CHECK !== "1" && (settings.auto || settings.notify) ? await checkForUpdate() : readUpdateCheck();
|
|
84
|
-
|
|
86
|
+
const recovery = readUpdateRecovery();
|
|
87
|
+
const retiring = recovery !== undefined && recoveryDisposition(recovery).action === "retire";
|
|
88
|
+
if (closed || !retiring && Date.now() < state.next)
|
|
85
89
|
return;
|
|
86
90
|
if (desktop) {
|
|
87
91
|
state = { ...state, next: Date.now() + UPDATE_DAY_MS + Math.random() * UPDATE_HOUR_MS };
|
|
@@ -99,17 +103,17 @@ export function automaticUpdates(host) {
|
|
|
99
103
|
}
|
|
100
104
|
if (state.version !== cached.latest)
|
|
101
105
|
state = { version: cached.latest, failures: 0, result: "new release observed", next: 0 };
|
|
102
|
-
if (state.failures >= 2) {
|
|
106
|
+
if (!retiring && state.failures >= 2) {
|
|
103
107
|
state = { ...state, result: `version ${cached.latest} failed twice; waiting for a newer version or manual update`, next: Date.now() + UPDATE_DAY_MS };
|
|
104
108
|
persist();
|
|
105
109
|
return;
|
|
106
110
|
}
|
|
107
|
-
if (!newerUpdate(cached.latest, host.version)) {
|
|
111
|
+
if (!retiring && !newerUpdate(cached.latest, host.version)) {
|
|
108
112
|
state = { ...state, result: "up to date", next: Date.now() + UPDATE_DAY_MS + Math.random() * UPDATE_HOUR_MS };
|
|
109
113
|
persist();
|
|
110
114
|
return;
|
|
111
115
|
}
|
|
112
|
-
if (Date.now() - (cached.firstSeenAt ?? Date.now()) < UPDATE_HOUR_MS) {
|
|
116
|
+
if (!retiring && Date.now() - (cached.firstSeenAt ?? Date.now()) < UPDATE_HOUR_MS) {
|
|
113
117
|
state = { ...state, result: "waiting for release hold", next: (cached.firstSeenAt ?? Date.now()) + UPDATE_HOUR_MS };
|
|
114
118
|
persist();
|
|
115
119
|
return;
|
package/dist/daemon/client.js
CHANGED
|
@@ -15,7 +15,7 @@ import { randomUUID } from "node:crypto";
|
|
|
15
15
|
import { connectPipe, windowsUserSid } from "@cotal-ai/seat";
|
|
16
16
|
import { DAEMON_PROTOCOL_VERSION, MAX_LINE_BYTES, EndpointRefusal, adoptPipe, assertSupportedPlatform, checkDir, checkSocket, defaultPeerPid, defaultPeerUid } from "./endpoint.js";
|
|
17
17
|
import { encode } from "./protocol.js";
|
|
18
|
-
import { processBirth, readLifetimeRecord } from "./lifetime.js";
|
|
18
|
+
import { observeLifetimeRecord, processBirth, readLifetimeRecord } from "./lifetime.js";
|
|
19
19
|
import { CommandFailure } from "@cotal-ai/workspace";
|
|
20
20
|
/** Read or change shared update preferences, or run the existing cached check without installing. */
|
|
21
21
|
export async function updateViaDaemon(opts, request) {
|
|
@@ -230,6 +230,21 @@ function isLockOwner(lock, pid, birth) {
|
|
|
230
230
|
/** The pipe-open steps that read the server's identity. A failure in one means that identity could
|
|
231
231
|
* not be established, so nothing may be sent. */
|
|
232
232
|
const IDENTITY_STEPS = new Set(["GetNamedPipeServerProcessId", "OpenProcess", "GetProcessTimes", "OpenProcessToken", "GetTokenInformation", "ConvertSidToStringSidW"]);
|
|
233
|
+
/** A refused Windows pipe whose original lifetime read contained zero bytes. It is never writable. */
|
|
234
|
+
export class EmptyLifetimeRefusal extends EndpointRefusal {
|
|
235
|
+
pid;
|
|
236
|
+
birth;
|
|
237
|
+
constructor(message, pid, birth) {
|
|
238
|
+
super("PEER_NOT_LOCK_OWNER", message);
|
|
239
|
+
this.pid = pid;
|
|
240
|
+
this.birth = birth;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
/** Shutdown waits may reobserve only the exact previously pinned lifetime, never treat it as absent. */
|
|
244
|
+
export function isStoppingLifetime(error, owner) {
|
|
245
|
+
return error instanceof EmptyLifetimeRefusal && owner?.start !== undefined && owner.start.length > 0
|
|
246
|
+
&& error.pid === owner.pid && error.birth === owner.start;
|
|
247
|
+
}
|
|
233
248
|
/** Windows: open the daemon's pipe, which the native side authenticates, and keep it only when its
|
|
234
249
|
* server is this user and the holder of the lifetime lock. Nothing is written before both. */
|
|
235
250
|
async function openPipe(paths, timeoutMs) {
|
|
@@ -259,8 +274,15 @@ async function openPipe(paths, timeoutMs) {
|
|
|
259
274
|
const own = windowsUserSid();
|
|
260
275
|
if (peer.user !== own)
|
|
261
276
|
refuse("PEER_UID_MISMATCH", `the process answering at ${paths.socket} runs as ${peer.user}, not ${own}; nothing was sent`);
|
|
262
|
-
|
|
263
|
-
|
|
277
|
+
const observation = observeLifetimeRecord(paths.lock);
|
|
278
|
+
const owner = observation.record;
|
|
279
|
+
if (!owner || owner.pid !== peer.pid || owner.start === undefined || peer.birth !== owner.start) {
|
|
280
|
+
const message = `the process answering at ${paths.socket} is not the daemon holding ${paths.lock}; nothing was sent`;
|
|
281
|
+
closeSync(peer.fd);
|
|
282
|
+
if (observation.empty)
|
|
283
|
+
throw new EmptyLifetimeRefusal(message, peer.pid, peer.birth);
|
|
284
|
+
throw new EndpointRefusal("PEER_NOT_LOCK_OWNER", message);
|
|
285
|
+
}
|
|
264
286
|
return adoptPipe(peer.fd);
|
|
265
287
|
}
|
|
266
288
|
/** Ask the daemon to sign in, show its prompt, and return its single result. */
|
package/dist/daemon/command.js
CHANGED
|
@@ -25,7 +25,7 @@ import { readFileSync, realpathSync } from "node:fs";
|
|
|
25
25
|
import { dirname, isAbsolute, join } from "node:path";
|
|
26
26
|
import { fileURLToPath } from "node:url";
|
|
27
27
|
import { registry } from "@cotal-ai/core";
|
|
28
|
-
import { CommandFailure, codeSpan, homeCotalDir, keptCatalogCredentials,
|
|
28
|
+
import { CommandFailure, codeSpan, homeCotalDir, keptCatalogCredentials, jsonFlag, plainFlag, presentationOf, recordOperationContext, renderReport, writeResult } from "@cotal-ai/workspace";
|
|
29
29
|
import { openLoginBrowser, isDiscoveryName, resolveDiscoveryLogin } from "@cotal-ai/workspace";
|
|
30
30
|
import { chooseAccountChoice, IdpConfigurationError, normalizeIdpUrl } from "@cotal-ai/auth";
|
|
31
31
|
import { EndpointRefusal, defaultPeerUid, defaultPeerPid, checkDir, daemonPaths, daemonPathsFor } from "./endpoint.js";
|
|
@@ -41,6 +41,7 @@ import { automaticUpdates } from "./auto-update.js";
|
|
|
41
41
|
import { watchDaemonGeneration } from "./generation.js";
|
|
42
42
|
import { SPACE_PATTERN } from "./protocol.js";
|
|
43
43
|
import { nativeDaemonLog } from "./native-log.js";
|
|
44
|
+
import { liveUpdateClosureOwner, readUpdateRecovery } from "@cotal-ai/workspace";
|
|
44
45
|
export const daemonFlags = [
|
|
45
46
|
jsonFlag,
|
|
46
47
|
plainFlag,
|
|
@@ -522,10 +523,11 @@ async function setupUnderClosure(args) {
|
|
|
522
523
|
}
|
|
523
524
|
async function serve(args) {
|
|
524
525
|
const { recoverInterruptedUpdate } = await import("@cotal-ai/cli/update");
|
|
525
|
-
//
|
|
526
|
-
//
|
|
527
|
-
|
|
528
|
-
|
|
526
|
+
// Unusable abandoned records retire under the updater lock. Unknown owners remain paused
|
|
527
|
+
// without blocking startup. A valid snapshot whose restoration failed still waits for repair.
|
|
528
|
+
const deferredRecovery = readUpdateRecovery();
|
|
529
|
+
const observedLiveUpdater = deferredRecovery !== undefined && liveUpdateClosureOwner(deferredRecovery);
|
|
530
|
+
if (await recoverInterruptedUpdate(undefined, true))
|
|
529
531
|
throw new Error("interrupted update restored the previous installation; restart the daemon with the restored CLI");
|
|
530
532
|
const { paths, home } = resolveTarget(args);
|
|
531
533
|
let running;
|
|
@@ -573,6 +575,42 @@ async function serve(args) {
|
|
|
573
575
|
await new Promise((resolve, reject) => {
|
|
574
576
|
let closed = false;
|
|
575
577
|
let stopWatching = () => { };
|
|
578
|
+
let recoveryTimer;
|
|
579
|
+
let recoveryBusy = false;
|
|
580
|
+
if (observedLiveUpdater) {
|
|
581
|
+
recoveryTimer = setInterval(() => {
|
|
582
|
+
if (closed || recoveryBusy)
|
|
583
|
+
return;
|
|
584
|
+
const record = readUpdateRecovery();
|
|
585
|
+
if (!record) {
|
|
586
|
+
clearInterval(recoveryTimer);
|
|
587
|
+
return;
|
|
588
|
+
}
|
|
589
|
+
if (liveUpdateClosureOwner(record))
|
|
590
|
+
return;
|
|
591
|
+
recoveryBusy = true;
|
|
592
|
+
clearInterval(recoveryTimer);
|
|
593
|
+
process.stderr.write("daemon: observed updater ended; checking guarded interrupted-update recovery\n");
|
|
594
|
+
void running.prepareGenerationRestart().then(() => recoverInterruptedUpdate(undefined, true)).then(async (restored) => {
|
|
595
|
+
if (restored) {
|
|
596
|
+
process.stderr.write("daemon: interrupted update restored the previous installation; restarting the recorded service\n");
|
|
597
|
+
await updates?.close();
|
|
598
|
+
await running.close();
|
|
599
|
+
resolve();
|
|
600
|
+
}
|
|
601
|
+
else if (readUpdateRecovery()) {
|
|
602
|
+
process.stderr.write("daemon: interrupted update remains paused; read daemon status and run `cotal update --self`\n");
|
|
603
|
+
}
|
|
604
|
+
else
|
|
605
|
+
process.stderr.write("daemon: updater completed; no interrupted-update recovery remains\n");
|
|
606
|
+
}).catch((error) => {
|
|
607
|
+
process.stderr.write(`daemon: guarded interrupted-update recovery refused: ${error instanceof Error ? error.message : String(error)}; run \`cotal update --self\`\n`);
|
|
608
|
+
}).finally(() => running.abortGenerationRestart().catch((error) => {
|
|
609
|
+
process.stderr.write(`daemon: interrupted-update admission release refused: ${error instanceof Error ? error.message : String(error)}\n`);
|
|
610
|
+
}));
|
|
611
|
+
}, 1000);
|
|
612
|
+
recoveryTimer.unref();
|
|
613
|
+
}
|
|
576
614
|
void ownership.then(observation => {
|
|
577
615
|
if (closed)
|
|
578
616
|
return;
|
|
@@ -598,7 +636,7 @@ async function serve(args) {
|
|
|
598
636
|
resolve();
|
|
599
637
|
}, (line) => process.stderr.write(`${line}\n`), (version, reason) => running.generationPending(version, reason), verified);
|
|
600
638
|
});
|
|
601
|
-
const stop = () => { closed = true; provenance.abort(); stopWatching(); void updates.close().then(() => running.close()).then(resolve, reject); };
|
|
639
|
+
const stop = () => { closed = true; clearInterval(recoveryTimer); provenance.abort(); stopWatching(); void updates.close().then(() => running.close()).then(resolve, reject); };
|
|
602
640
|
void running.stopped.then(stop, reject);
|
|
603
641
|
process.once("SIGTERM", stop);
|
|
604
642
|
process.once("SIGINT", stop);
|
package/dist/daemon/desktop.js
CHANGED
|
@@ -3,7 +3,7 @@ import { randomUUID } from "node:crypto";
|
|
|
3
3
|
import { defaultComputerName } from "./computer-name.js";
|
|
4
4
|
import { computerName } from "./name-validation.js";
|
|
5
5
|
import { arch, platform, release, totalmem } from "node:os";
|
|
6
|
-
import { CommandFailure } from "@cotal-ai/workspace";
|
|
6
|
+
import { CommandFailure, readUpdateSettings, setUpdateSetting } from "@cotal-ai/workspace";
|
|
7
7
|
import { normalizeIdpUrl } from "@cotal-ai/auth";
|
|
8
8
|
import { loginViaDaemon, updateViaDaemon, openVerified, queryDaemon, readLine } from "./client.js";
|
|
9
9
|
import { DAEMON_PROTOCOL_VERSION, MAX_LINE_BYTES, EndpointRefusal } from "./endpoint.js";
|
|
@@ -18,9 +18,14 @@ export function parseDesktopRequest(value) {
|
|
|
18
18
|
const o = value;
|
|
19
19
|
const simple = ["about", "status", "install", "update-check"].includes(String(o.op));
|
|
20
20
|
const scoped = ["connect-check", "register", "service-connect", "service-disconnect", "service-status"].includes(String(o.op));
|
|
21
|
-
const fields = o.op === "update-release" ? ["op", "version"] : o.op === "update-settings" ? ["op", "auto", "notify"] : o.op === "name" ? ["op", "name"] : o.op === "space-intent" ? ["op", "space", "enabled"] : simple ? ["op"] : scoped ? ["op", "space"] : o.op === "setup" ? ["op", "space", "idp"] : (o.op === "login" || o.op === "logout") ? ["op", "idp"] : o.op === "spaces" ? ["op", "refresh"] : [];
|
|
21
|
+
const fields = o.op === "update-policy" ? ["op", "auto"] : o.op === "update-release" ? ["op", "version"] : o.op === "update-settings" ? ["op", "auto", "notify"] : o.op === "name" ? ["op", "name"] : o.op === "space-intent" ? ["op", "space", "enabled"] : simple ? ["op"] : scoped ? ["op", "space"] : o.op === "setup" ? ["op", "space", "idp"] : (o.op === "login" || o.op === "logout") ? ["op", "idp"] : o.op === "spaces" ? ["op", "refresh"] : [];
|
|
22
22
|
if (!fields.length || Object.keys(o).some((key) => !fields.includes(key)))
|
|
23
23
|
throw new Error("unknown operation or field");
|
|
24
|
+
if (o.op === "update-policy") {
|
|
25
|
+
if (o.auto !== undefined && typeof o.auto !== "boolean")
|
|
26
|
+
throw new Error("invalid update preference");
|
|
27
|
+
return { op: "update-policy", ...(o.auto !== undefined ? { auto: o.auto } : {}) };
|
|
28
|
+
}
|
|
24
29
|
if (o.op === "update-release") {
|
|
25
30
|
if (typeof o.version !== "string" || !/^\d+\.\d+\.\d+$/.test(o.version))
|
|
26
31
|
throw new Error("invalid release version");
|
|
@@ -93,6 +98,11 @@ export async function runDesktopBridge(opts) {
|
|
|
93
98
|
return;
|
|
94
99
|
}
|
|
95
100
|
try {
|
|
101
|
+
if (req.op === "update-policy") {
|
|
102
|
+
const settings = req.auto === undefined ? readUpdateSettings() : setUpdateSetting("auto", req.auto);
|
|
103
|
+
emit({ v: 1, event: "result", ok: true, result: settings });
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
96
106
|
if (req.op === "about") {
|
|
97
107
|
emit({ v: 1, event: "result", ok: true, result: { version: opts.version, machine: defaultComputerName(), platform: platform(), arch: arch(), release: release(), memoryBytes: totalmem() } });
|
|
98
108
|
return;
|
package/dist/daemon/install.js
CHANGED
|
@@ -43,7 +43,7 @@ import { mkSecretDir, writeSecretFile, writeSecretFileAtomic } from "@cotal-ai/c
|
|
|
43
43
|
import { codeSpan, CommandFailure, readLocalRecordSource } from "@cotal-ai/workspace";
|
|
44
44
|
import { assertSystemdSource, assertSystemdSourceDirectory, createSystemdSource, daemonArgv, submitSystemdUnitControl, submitSystemdUnitRegistration, systemdUserUnitDirectory } from "@cotal-ai/cli";
|
|
45
45
|
import { checkDir, EndpointRefusal, DAEMON_PROTOCOL_VERSION } from "./endpoint.js";
|
|
46
|
-
import { openVerified, readLine } from "./client.js";
|
|
46
|
+
import { isStoppingLifetime, openVerified, readLine } from "./client.js";
|
|
47
47
|
import { excludeLifetime, processBirth, readLifetimeRecord } from "./lifetime.js";
|
|
48
48
|
import { windowsUserSid } from "@cotal-ai/seat";
|
|
49
49
|
import { encode } from "./protocol.js";
|
|
@@ -487,6 +487,7 @@ async function restartWindowsInstalled(paths, daemonHome, expectedVersion, repor
|
|
|
487
487
|
const owner = readLifetimeRecord(paths.lock);
|
|
488
488
|
let phase = "prepare";
|
|
489
489
|
let pauseAttempted = false;
|
|
490
|
+
let stopCommitted = false;
|
|
490
491
|
const progress = (detail) => { phase = detail; report?.(detail); };
|
|
491
492
|
const startedAt = Date.now();
|
|
492
493
|
const heartbeat = setInterval(() => report?.(`${phase} (${Math.floor((Date.now() - startedAt) / 1000)}s elapsed)`), 5000);
|
|
@@ -507,6 +508,7 @@ async function restartWindowsInstalled(paths, daemonHome, expectedVersion, repor
|
|
|
507
508
|
await task.pause(receipt);
|
|
508
509
|
phase = "stop-commit";
|
|
509
510
|
if (processBirth(owner.pid) === owner.start) {
|
|
511
|
+
stopCommitted = true;
|
|
510
512
|
try {
|
|
511
513
|
await request("daemon-stop", true);
|
|
512
514
|
}
|
|
@@ -528,7 +530,7 @@ async function restartWindowsInstalled(paths, daemonHome, expectedVersion, repor
|
|
|
528
530
|
catch (error) {
|
|
529
531
|
if (error instanceof EndpointRefusal && error.code === "NOT_RUNNING")
|
|
530
532
|
absent = true;
|
|
531
|
-
else if (error.code !== "ECONNRESET")
|
|
533
|
+
else if (error.code !== "ECONNRESET" && !(stopCommitted && isStoppingLifetime(error, owner)))
|
|
532
534
|
throw error;
|
|
533
535
|
}
|
|
534
536
|
if (absent && processBirth(owner.pid) !== owner.start)
|
|
@@ -669,6 +671,7 @@ export async function applyUninstall(paths, daemonHome) {
|
|
|
669
671
|
// stop only that listener, never a reused PID or a later daemon generation.
|
|
670
672
|
const before = readLifetimeRecord(paths.lock);
|
|
671
673
|
let socket;
|
|
674
|
+
let stopCommitted = false;
|
|
672
675
|
try {
|
|
673
676
|
socket = await openVerified({ paths });
|
|
674
677
|
}
|
|
@@ -711,6 +714,7 @@ export async function applyUninstall(paths, daemonHome) {
|
|
|
711
714
|
}
|
|
712
715
|
if (socket && owner?.start && processBirth(owner.pid) === owner.start) {
|
|
713
716
|
const id = randomUUID().replaceAll("-", "");
|
|
717
|
+
stopCommitted = true;
|
|
714
718
|
socket.write(encode({ v: DAEMON_PROTOCOL_VERSION, id, op: "daemon-stop", commit: true }));
|
|
715
719
|
try {
|
|
716
720
|
const reply = JSON.parse(await readLine(socket, 5000));
|
|
@@ -741,7 +745,7 @@ export async function applyUninstall(paths, daemonHome) {
|
|
|
741
745
|
absent = true;
|
|
742
746
|
// The native CI reproducer observed a connect reset while close() tears down
|
|
743
747
|
// accepted sockets. It proves neither a live endpoint nor absence. Reobserve.
|
|
744
|
-
else if (error.code !== "ECONNRESET")
|
|
748
|
+
else if (error.code !== "ECONNRESET" && !(process.platform === "win32" && stopCommitted && isStoppingLifetime(error, owner)))
|
|
745
749
|
throw error;
|
|
746
750
|
}
|
|
747
751
|
if (absent && (!socket || !owner || (owner.start && processBirth(owner.pid) !== owner.start)) && Date.now() >= observeUntil)
|
package/dist/daemon/lifetime.js
CHANGED
|
@@ -66,17 +66,21 @@ function parse(raw) {
|
|
|
66
66
|
return undefined;
|
|
67
67
|
return { v: 1, pid: r.pid, ...start, startedAt: r.startedAt, socket: { path: s.path, dev: s.dev, ino: s.ino } };
|
|
68
68
|
}
|
|
69
|
-
/**
|
|
70
|
-
|
|
71
|
-
export function readLifetimeRecord(path) {
|
|
69
|
+
/** One original record read. Only zero bytes establish an empty lifetime record. */
|
|
70
|
+
export function observeLifetimeRecord(path) {
|
|
72
71
|
try {
|
|
73
72
|
const raw = readFileSync(path, "utf8");
|
|
74
|
-
return raw.
|
|
73
|
+
return raw.length === 0 ? { empty: true } : { empty: false, record: parse(raw) };
|
|
75
74
|
}
|
|
76
75
|
catch {
|
|
77
|
-
return
|
|
76
|
+
return { empty: false };
|
|
78
77
|
}
|
|
79
78
|
}
|
|
79
|
+
/** The record at `path`, for a client deciding whether the process answering a socket is its
|
|
80
|
+
* holder. Undefined when there is none, when it is unreadable, or when it is not one of ours. */
|
|
81
|
+
export function readLifetimeRecord(path) {
|
|
82
|
+
return observeLifetimeRecord(path).record;
|
|
83
|
+
}
|
|
80
84
|
/** Exclude new starters during uninstall without writing or clearing the holder's record. */
|
|
81
85
|
export function excludeLifetime(path) {
|
|
82
86
|
const fd = openSync(path, constants.O_RDWR | constants.O_CREAT, 0o600);
|