@cotal-ai/cli 0.164.15 → 0.164.17

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.
@@ -14,6 +14,14 @@ interface CommandResult {
14
14
  readonly stderr: string;
15
15
  readonly error?: string;
16
16
  }
17
+ export interface ExecutionReplacement {
18
+ readonly entry: string;
19
+ readonly journal: string;
20
+ preflight(target: Record<string, unknown>): Promise<void>;
21
+ publish(): void;
22
+ restore(): void;
23
+ verify(version: string): void;
24
+ }
17
25
  export interface UpdateRuntime {
18
26
  readonly env: NodeJS.ProcessEnv;
19
27
  readonly pid: number;
@@ -21,6 +29,13 @@ export interface UpdateRuntime {
21
29
  readonly nodePath: string;
22
30
  now?(): number;
23
31
  recoveryOwnerStart?(pid: number): string | undefined;
32
+ /** Refuse unsupported or unwritable execution destinations before any persistent writes. */
33
+ preflightExecution?(): void;
34
+ executionGlobalRoot?(): string;
35
+ /** Prepare a complete retained target under the held global root lock, without publication. */
36
+ prepareExecution?(version: string, root: string): Promise<ExecutionReplacement>;
37
+ /** Reopen only a journal already validated against this logical installation. */
38
+ recoverExecution?(journal: string): ExecutionReplacement;
24
39
  version(): string;
25
40
  /** Read package consistency only, without refreshing external harness integrations. */
26
41
  isCurrent?(): boolean;
@@ -92,7 +107,11 @@ export declare function isStoppedLocalMesh(target: MeshTarget): Promise<boolean>
92
107
  * still selects one, and every other refusal stands.
93
108
  */
94
109
  export declare function reportRunningManagers(flags: Record<string, unknown>, readOne?: (flags: Record<string, unknown>) => Promise<"none" | "legacy">, census?: (flags: Record<string, unknown>) => readonly UpdateManager[]): Promise<"none" | "legacy">;
95
- export declare function readManagerContinuity(flags: Record<string, unknown>): Promise<"none" | "legacy">;
110
+ export declare function readManagerContinuity(flags: Record<string, unknown>, options?: {
111
+ readOnly?: boolean;
112
+ retainGraph?: boolean;
113
+ installedEntry?: string;
114
+ }): Promise<"none" | "legacy">;
96
115
  /** Name legacy custody and the cold update sequence without guessing its hosting lifecycle.
97
116
  * An endpoint identity is not a saved service instance or proof of its original starter.
98
117
  * The third argument is retained for callers, but an unverified stop command is not a remedy. */
@@ -1 +1 @@
1
- {"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../src/commands/update.ts"],"names":[],"mappings":"AAIA,OAAO,EAAmB,KAAK,QAAQ,EAAE,KAAK,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjF,OAAO,EAqBL,KAAK,kBAAkB,EAOxB,MAAM,qBAAqB,CAAC;AAQ7B,OAAO,EAAc,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAUpE,OAAO,EASL,KAAK,UAAU,EAEhB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAwC,KAAK,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AACjH,OAAO,EAAuB,KAAK,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAIhG,OAAO,EAAuB,KAAK,aAAa,EAAE,MAAM,2BAA2B,CAAC;AACpF,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,UAAU,IAAI,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAM1E,eAAO,MAAM,WAAW,EAAE,SAAS,QAAQ,EAS1C,CAAC;AAEF,UAAU,aAAa;IACrB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,UAAU,CAAC;IAChC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,GAAG,CAAC,IAAI,MAA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 -3,7 +3,7 @@ import { existsSync, mkdtempSync, readFileSync, realpathSync, rmSync, statSync }
3
3
  import { tmpdir } from "node:os";
4
4
  import { basename, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
5
5
  import { globalConfigDir } from "@cotal-ai/core";
6
- import { CommandFailure, jsonFlag, plainFlag, presentationOf, protectedLocalDirectory, renderReport, writeResult, cmdSpawnSpec, beginGlobalUpdateChild, processStartToken, claimUpdateClosureAccess, updateClosureOwner, readUpdateRecovery, clearUpdateRecovery, writeUpdateRecovery, readUpdateSettings, recordUpdateCompletion, recordUpdateDeferral, recordUpdateReplacement, setUpdateSetting, bindExtensionPeers, claimGlobalNpmUpdateLock, launcherInstallRoot, loadExtensionsManifest, provenance, SEEDED_EXTENSIONS, targetFlags, resolveControlTarget, recoveryDisposition, liveUpdateClosureOwner, recoveryProcessStartToken, observeUnownedRecovery, } from "@cotal-ai/workspace";
6
+ import { CommandFailure, jsonFlag, plainFlag, presentationOf, protectedLocalDirectory, renderReport, writeResult, cmdSpawnSpec, beginGlobalUpdateChild, processStartToken, claimUpdateClosureAccess, updateClosureOwner, readUpdateRecovery, clearUpdateRecovery, writeUpdateRecovery, readUpdateSettings, recordUpdateCompletion, recordUpdateDeferral, recordUpdateReplacement, setUpdateSetting, bindExtensionPeers, claimGlobalNpmUpdateLock, launcherInstallRoot, logicalExecutionEntry, loadExtensionsManifest, provenance, SEEDED_EXTENSIONS, targetFlags, resolveControlTarget, recoveryDisposition, liveUpdateClosureOwner, recoveryProcessStartToken, observeUnownedRecovery, } from "@cotal-ai/workspace";
7
7
  import { retainUnusableRecovery } from "../lib/update-recovery-state.js";
8
8
  import { readUpdatePending } from "../lib/update-pending.js";
9
9
  import { snapshotUpdateClosure } from "../lib/update-snapshot.js";
@@ -86,7 +86,10 @@ export const updateRuntime = {
86
86
  claimGlobalUpdate: (root) => claimGlobalNpmUpdateLock(root),
87
87
  selfArgv,
88
88
  checkout: () => seedWriterKind() === "checkout",
89
- installPrefix: () => installedUpdatePrefix(cliPackageRoot(), entryScript()),
89
+ installPrefix: () => {
90
+ const logical = logicalExecutionEntry();
91
+ return installedUpdatePrefix(logical ? dirname(dirname(logical)) : cliPackageRoot(), logical ?? entryScript());
92
+ },
90
93
  npm: runNpm,
91
94
  npmAsync: runNpmAsync,
92
95
  spawn: runProcess,
@@ -122,6 +125,8 @@ export async function update(args, rt = updateRuntime) {
122
125
  remedy: "update the desktop app with its signed platform installer; no npm self-update was attempted",
123
126
  });
124
127
  }
128
+ if (args.values.self === true)
129
+ rt.preflightExecution?.();
125
130
  if (await recoverInterruptedUpdate(rt))
126
131
  return;
127
132
  // A folder above the config folder is not one this command repairs. Refuse it before the mode
@@ -139,7 +144,7 @@ export async function update(args, rt = updateRuntime) {
139
144
  // manager reads, so their modes are repaired before the continuity check rather than only when the
140
145
  // reconcile is allowed to run.
141
146
  const install = launcherInstallRoot();
142
- for (const { what, root } of [...(install ? [{ what: "install", root: install }] : []), { what: "config", root: globalConfigDir() }]) {
147
+ for (const { what, root } of args.values.self === true && rt.prepareExecution ? [] : [...(install ? [{ what: "install", root: install }] : []), { what: "config", root: globalConfigDir() }]) {
143
148
  const repaired = repairInstallModes(root);
144
149
  if (repaired)
145
150
  rt.out(c.green(`✓ removed group and other write from ${repaired} ${repaired === 1 ? "entry" : "entries"} in Cotal's ${what} at ${root}`));
@@ -208,10 +213,10 @@ export async function recoverInterruptedUpdate(rt = updateRuntime, startup = fal
208
213
  throw new Error("interrupted update has no closure snapshot");
209
214
  writeUpdateRecovery({ ...record, owner: updateClosureOwner(), phase: "restoring" });
210
215
  const snapshot = snapshotUpdateClosure(record.snapshot);
211
- const completedRollback = !startup && record.phase === "paused" && record.installed === record.previous
216
+ const completedRollback = !record.execution && !startup && record.phase === "paused" && record.installed === record.previous
212
217
  && record.renames !== undefined && record.renames.length > 0 && record.renames.every(entry => entry.done);
213
218
  const prefix = rt.installPrefix();
214
- const selected = rt.npm(["root", "-g", ...(prefix ? ["--prefix", prefix] : [])]);
219
+ const selected = record.execution && rt.executionGlobalRoot ? { status: 0, stdout: rt.executionGlobalRoot(), stderr: "" } : rt.npm(["root", "-g", ...(prefix ? ["--prefix", prefix] : [])]);
215
220
  const root = selected.stdout.trim();
216
221
  if (selected.status !== 0 || !isAbsolute(root) || /[\r\n]/.test(root))
217
222
  throw new Error("cannot identify interrupted update installation");
@@ -227,23 +232,46 @@ export async function recoverInterruptedUpdate(rt = updateRuntime, startup = fal
227
232
  const reconciled = await rt.spawnGlobal(root, "reconcile", rt.nodePath, [entry, "update"], env, true);
228
233
  if (reconciled.status !== 0)
229
234
  throw new Error(failure(reconciled));
235
+ if (!startup && rt.env.COTAL_AUTO_UPDATE !== "1") {
236
+ const currentRecovery = readUpdateRecovery();
237
+ if (currentRecovery && currentRecovery.phase !== "verified-ready")
238
+ writeUpdateRecovery({ ...currentRecovery, installed: version, phase: "verified-ready" });
239
+ await rt.waitForInstalledGeneration?.(version);
240
+ }
230
241
  snapshot.discard();
231
242
  clearUpdateRecovery();
232
243
  recordUpdateCompletion(version, `repaired paused installation at ${version}`, true);
233
244
  rt.out(`Repaired the paused installation with cotal-ai@${version}; the machine service and its hosted Managers were verified.`);
234
245
  return true;
235
246
  }
236
- checkReleaseArchives(record.previous, rt);
237
- const command = cmdSpawnSpec("npm", ["install", "-g", ...(prefix ? ["--prefix", prefix] : []), `cotal-ai@${record.previous}`]);
238
- const installed = await rt.spawnGlobal(root, "install", command.file, command.args, rt.env, true, command.windowsVerbatimArguments);
239
- if (installed.status !== 0)
240
- throw new Error(failure(installed));
241
- const entry = rt.verifyGlobalEntry(root, record.previous);
247
+ let entry;
248
+ if (record.execution) {
249
+ if (!rt.recoverExecution)
250
+ throw new Error("this binary cannot recover a staged execution transaction; rerun its installer");
251
+ const execution = rt.recoverExecution(record.execution);
252
+ execution.restore();
253
+ execution.verify(record.previous);
254
+ entry = execution.entry;
255
+ }
256
+ else {
257
+ await checkReleaseArchives(record.previous, rt);
258
+ const command = cmdSpawnSpec("npm", ["install", "-g", ...(prefix ? ["--prefix", prefix] : []), `cotal-ai@${record.previous}`]);
259
+ const installed = await rt.spawnGlobal(root, "install", command.file, command.args, rt.env, true, command.windowsVerbatimArguments);
260
+ if (installed.status !== 0)
261
+ throw new Error(failure(installed));
262
+ entry = rt.verifyGlobalEntry(root, record.previous);
263
+ }
242
264
  snapshot.restore();
243
265
  const env = { ...rt.env, [UPDATE_TARGET_ENV]: record.previous, [UPDATE_PARENT_ENV]: String(rt.pid) };
244
266
  const reconciled = await rt.spawnGlobal(root, "reconcile", rt.nodePath, [entry, "update"], env, true);
245
267
  if (reconciled.status !== 0)
246
268
  throw new Error(failure(reconciled));
269
+ if (!startup && rt.env.COTAL_AUTO_UPDATE !== "1") {
270
+ const currentRecovery = readUpdateRecovery();
271
+ if (currentRecovery && currentRecovery.phase !== "verified-ready")
272
+ writeUpdateRecovery({ ...currentRecovery, installed: record.previous, phase: "verified-ready" });
273
+ await rt.waitForInstalledGeneration?.(record.previous);
274
+ }
247
275
  snapshot.discard();
248
276
  clearUpdateRecovery();
249
277
  rt.out(`Restored cotal-ai@${record.previous} after an interrupted update.`);
@@ -374,19 +402,36 @@ export async function executeUpdate(self, rt = updateRuntime, target = {}) {
374
402
  rt.out("No newer CLI version; installed package closure is current. No connector reconciliation was run.");
375
403
  if (custody === "legacy")
376
404
  rt.out("A later update will require stopping the agents listed above before replacing packages.");
405
+ if (rt.env.COTAL_AUTO_UPDATE === "1")
406
+ recordUpdateCompletion(current, "up to date", true);
377
407
  reportVersion(current, latest.version, rt, false);
378
408
  return 0;
379
409
  }
380
410
  catch (error) {
411
+ if (rt.env.COTAL_AUTO_UPDATE === "1")
412
+ recordUpdateDeferral(current, "waiting for agents to stop");
381
413
  rt.err(c.red(`✗ running manager continuity check: ${refusal(error)}`));
382
414
  return 1;
383
415
  }
384
416
  }
385
- return reconcileCurrent(current, rt, target, (reconciled) => {
417
+ return reconcileCurrent(current, rt, target, (reconciled, deferred) => {
386
418
  if (!latest.ok) {
419
+ if (rt.env.COTAL_AUTO_UPDATE === "1")
420
+ recordUpdateDeferral(current, "waiting for registry or extension closure availability", true);
387
421
  rt.err(c.red(`✗ cotal-ai version check failed: ${latest.error}`));
388
422
  return 1;
389
423
  }
424
+ if (rt.env.COTAL_AUTO_UPDATE === "1") {
425
+ if (reconciled)
426
+ recordUpdateCompletion(current, `updated to ${current}`, true);
427
+ else if (!deferred) {
428
+ recordUpdateReplacement(current);
429
+ recordUpdateCompletion(current, `reconciliation failed at ${current}`, false);
430
+ }
431
+ }
432
+ else if (reconciled && rt === updateRuntime) {
433
+ recordUpdateCompletion(current, `updated to ${current}`, true);
434
+ }
390
435
  reportVersion(current, latest.version, rt, reconciled);
391
436
  return reconciled ? 0 : 1;
392
437
  });
@@ -409,19 +454,26 @@ async function reconcileCurrent(current, rt, target, finish) {
409
454
  // run that refused to proceed (#1620). The continuity check is a pure read of the running manager
410
455
  // and the selected target; nothing may be written until it has answered.
411
456
  try {
412
- if (await rt.reportRunningManager(target) === "legacy")
413
- return finish(false);
457
+ if (await rt.reportRunningManager(target) === "legacy") {
458
+ if (rt.env.COTAL_AUTO_UPDATE === "1")
459
+ recordUpdateDeferral(current, "waiting for agents to stop");
460
+ return finish(false, true);
461
+ }
414
462
  }
415
463
  catch (e) {
464
+ if (rt.env.COTAL_AUTO_UPDATE === "1")
465
+ recordUpdateDeferral(current, "waiting for agents to stop");
416
466
  rt.err(c.red(`✗ running manager continuity check: ${refusal(e)}`));
417
- return finish(false);
467
+ return finish(false, true);
418
468
  }
419
469
  try {
420
470
  await rt.preflightReplacement?.();
421
471
  }
422
472
  catch (error) {
473
+ if (rt.env.COTAL_AUTO_UPDATE === "1")
474
+ recordUpdateDeferral(current, "installed daemon preflight refused");
423
475
  rt.err(c.red(`✗ installed daemon preflight: ${refusal(error)}`));
424
- return finish(false);
476
+ return finish(false, true);
425
477
  }
426
478
  rt.out(c.bold("Built-in connectors"));
427
479
  try {
@@ -655,7 +707,7 @@ export async function reportRunningManagers(flags, readOne = readManagerContinui
655
707
  return verdict;
656
708
  }
657
709
  }
658
- export async function readManagerContinuity(flags) {
710
+ export async function readManagerContinuity(flags, options = {}) {
659
711
  // `--on` names the manager whose custody this install carries. An owner with several live
660
712
  // managers on a user-auth mesh (one per machine, say) gets the exchange's selection refusal
661
713
  // without it, naming `--on` as the remedy; the flag has to exist here for that remedy to be real,
@@ -674,7 +726,7 @@ export async function readManagerContinuity(flags) {
674
726
  const server = typeof flags.server === "string" ? flags.server : undefined;
675
727
  let peek;
676
728
  try {
677
- offline = space ? [] : (await pruneStaleMeshes(server)).offline;
729
+ offline = space || options.readOnly ? [] : (await pruneStaleMeshes(server)).offline;
678
730
  peek = resolveMeshTarget(process.cwd(), { server, space, offline });
679
731
  }
680
732
  catch (e) {
@@ -703,7 +755,7 @@ export async function readManagerContinuity(flags) {
703
755
  // install is untouched by replacing this one, so it is no custody here, the same as a manager
704
756
  // that runs on another machine.
705
757
  if (peek?.mode === "user" && peek.userAuth?.remote === true) {
706
- if (!supervisorMayServe(peek.space)) {
758
+ if (!supervisorMayServe(peek.space, options.installedEntry)) {
707
759
  console.log(c.dim(` ${peek.space}: this mesh's manager runs elsewhere; no custody on this machine`));
708
760
  return "none";
709
761
  }
@@ -761,6 +813,10 @@ export async function readManagerContinuity(flags) {
761
813
  : []);
762
814
  if (!report)
763
815
  return "none";
816
+ if (options.retainGraph) {
817
+ console.log(`Standalone Manager ${on ?? "(instance unavailable)"} in ${JSON.stringify(target.space)} keeps its loaded execution generation; no restart or seat stop is requested. New launches remain subject to the extension generation check.`);
818
+ return "none";
819
+ }
764
820
  const remedy = typeof flags.creds === "string" ? undefined : recordedStackRemedy(target.root, target.space, target.server, (status.data ?? {}));
765
821
  printLegacyReport(report, target.space, undefined, console.log, on, remedy);
766
822
  return "legacy";
@@ -924,7 +980,7 @@ async function upgradeAndReconcile(targetVersion, current, rt, target) {
924
980
  return 1;
925
981
  }
926
982
  try {
927
- if (await rt.reportRunningManager(target) === "legacy") {
983
+ if (!rt.prepareExecution && await rt.reportRunningManager(target) === "legacy") {
928
984
  recordUpdateDeferral(targetVersion, "waiting for agents to stop");
929
985
  return 1;
930
986
  }
@@ -940,9 +996,11 @@ async function upgradeAndReconcile(targetVersion, current, rt, target) {
940
996
  await checkReleaseArchives(targetVersion, rt);
941
997
  rt.out(`Checking installed extension dependencies for ${targetVersion}`);
942
998
  checkInstalledClosure(targetVersion, rt);
943
- // A previous generation must remain downloadable and verified before replacement begins.
944
- rt.out(`Checking cotal-ai@${current} recovery archives`);
945
- await checkReleaseArchives(current, rt);
999
+ // In-place rollback downloads the previous release. Staged rollback retains its complete graph.
1000
+ if (!rt.prepareExecution) {
1001
+ rt.out(`Checking cotal-ai@${current} recovery archives`);
1002
+ await checkReleaseArchives(current, rt);
1003
+ }
946
1004
  rt.out(`✓ release archives checked (${((Date.now() - releaseChecksStarted) / 1000).toFixed(1)} s)`);
947
1005
  }
948
1006
  catch (e) {
@@ -965,7 +1023,7 @@ async function upgradeAndReconcile(targetVersion, current, rt, target) {
965
1023
  return 1;
966
1024
  }
967
1025
  const prefixArgs = prefix ? ["--prefix", prefix] : [];
968
- const rootResult = rt.npm(["root", "-g", ...prefixArgs]);
1026
+ const rootResult = rt.executionGlobalRoot ? { status: 0, stdout: rt.executionGlobalRoot(), stderr: "" } : rt.npm(["root", "-g", ...prefixArgs]);
969
1027
  if (rootResult.status !== 0) {
970
1028
  rt.err(c.red(`✗ could not resolve npm's global root before install: ${failure(rootResult)}`));
971
1029
  return 1;
@@ -1004,6 +1062,27 @@ async function upgradeAndReconcile(targetVersion, current, rt, target) {
1004
1062
  rt.err(c.red(`✗ could not reserve npm's global root for update: ${message(e)}`));
1005
1063
  return 1;
1006
1064
  }
1065
+ let execution;
1066
+ let stagedExecution = false;
1067
+ if (rt.prepareExecution) {
1068
+ stagedExecution = true;
1069
+ const prepareStarted = Date.now();
1070
+ try {
1071
+ rt.out(c.bold("cotal-ai binary"));
1072
+ rt.out(c.dim(`installing cotal-ai@${targetVersion} beside the running version; this ${current} process stays loaded until the new version is verified`));
1073
+ execution = await rt.prepareExecution(targetVersion, root);
1074
+ await execution.preflight(target);
1075
+ if (await rt.reportRunningManager(target) === "legacy")
1076
+ throw new Error("running Manager requires a restart that cannot preserve its agents");
1077
+ rt.out(`✓ new version installed and verified (${((Date.now() - prepareStarted) / 1000).toFixed(1)} s)`);
1078
+ }
1079
+ catch (error) {
1080
+ releaseGlobal();
1081
+ recordUpdateDeferral(targetVersion, `staged pre-install check refused: ${preflightDetail(error)}`);
1082
+ rt.err(`staged pre-install check refused: ${message(error)}; no installed packages or connector state were changed`);
1083
+ return 1;
1084
+ }
1085
+ }
1007
1086
  let releaseAdmission;
1008
1087
  try {
1009
1088
  releaseAdmission = await rt.prepareReplacement?.();
@@ -1046,14 +1125,23 @@ async function upgradeAndReconcile(targetVersion, current, rt, target) {
1046
1125
  process.on("SIGINT", onInt);
1047
1126
  process.on("SIGTERM", onTerm);
1048
1127
  try {
1049
- rt.out(c.bold("cotal-ai binary"));
1050
- rt.out(c.dim(`installing cotal-ai@${targetVersion} into npm's global installation; this ${current} process remains loaded until the verified global copy takes over`));
1128
+ if (execution) {
1129
+ rt.out(`Switching to cotal-ai@${targetVersion}`);
1130
+ }
1131
+ else {
1132
+ rt.out(c.bold("cotal-ai binary"));
1133
+ rt.out(c.dim(`installing cotal-ai@${targetVersion} into npm's global installation; this ${current} process remains loaded until the verified global copy takes over`));
1134
+ }
1051
1135
  recordUpdateReplacement(targetVersion);
1052
- writeUpdateRecovery({ previous: current, target: targetVersion, installed: current, phase: "replacing", reason: "global replacement in progress", owner: updateClosureOwner(), preparedRestart: rt.preparedRestart?.() ?? false, snapshot: snapshot.path });
1136
+ writeUpdateRecovery({ previous: current, target: targetVersion, installed: current, phase: "replacing", reason: "global replacement in progress", owner: updateClosureOwner(), preparedRestart: rt.preparedRestart?.() ?? false, snapshot: snapshot.path, ...(execution ? { execution: execution.journal } : {}) });
1053
1137
  const npmInstall = cmdSpawnSpec("npm", ["install", "-g", ...prefixArgs, `cotal-ai@${targetVersion}`, "--json"]);
1054
1138
  const installStarted = Date.now();
1055
- const installed = await rt.spawnGlobal(root, "install", npmInstall.file, npmInstall.args, rt.env, false, npmInstall.windowsVerbatimArguments);
1056
- rt.out(`✓ global package install finished (${((Date.now() - installStarted) / 1000).toFixed(1)} s)`);
1139
+ const installed = execution ? (() => {
1140
+ execution.publish();
1141
+ return { status: 0, stdout: "", stderr: "" };
1142
+ })() : await rt.spawnGlobal(root, "install", npmInstall.file, npmInstall.args, rt.env, false, npmInstall.windowsVerbatimArguments);
1143
+ if (!execution)
1144
+ rt.out(`✓ global package install finished (${((Date.now() - installStarted) / 1000).toFixed(1)} s)`);
1057
1145
  if (latestNotAvailable(installed, targetVersion)) {
1058
1146
  // npm resolves the requested version before reifying the global tree. This refusal
1059
1147
  // did not replace packages, so neither rollback nor a failed-attempt charge applies.
@@ -1073,7 +1161,12 @@ async function upgradeAndReconcile(targetVersion, current, rt, target) {
1073
1161
  rt.out("Verifying installed global entry");
1074
1162
  let entry;
1075
1163
  try {
1076
- entry = rt.verifyGlobalEntry(root, targetVersion);
1164
+ if (execution) {
1165
+ execution.verify(targetVersion);
1166
+ entry = execution.entry;
1167
+ }
1168
+ else
1169
+ entry = rt.verifyGlobalEntry(root, targetVersion);
1077
1170
  }
1078
1171
  catch (e) {
1079
1172
  rt.err(c.red(`✗ installed global cotal-ai could not be verified: ${message(e)}`));
@@ -1096,16 +1189,31 @@ async function upgradeAndReconcile(targetVersion, current, rt, target) {
1096
1189
  rt.stdout(child.stdout);
1097
1190
  if (child.status !== 0) {
1098
1191
  rt.err(c.red(`✗ cotal-ai@${targetVersion} installed globally, but its reconcile failed: ${failure(child)}`));
1099
- return await repairReplacement(`reconcile failed: ${failure(child)}`, child.status ?? 1);
1192
+ return await repairReplacement(`reconcile failed: ${failure(child)}`, child.status ?? 1, readUpdateRecovery()?.phase === "verified-ready");
1193
+ }
1194
+ if (rt.env.COTAL_AUTO_UPDATE !== "1") {
1195
+ try {
1196
+ const recovery = readUpdateRecovery();
1197
+ if (recovery && recovery.phase !== "verified-ready")
1198
+ writeUpdateRecovery({ ...recovery, installed: targetVersion, phase: "verified-ready" });
1199
+ await rt.waitForInstalledGeneration?.(targetVersion);
1200
+ }
1201
+ catch (error) {
1202
+ rt.err(c.red(`✗ installed daemon generation: ${refusal(error)}`));
1203
+ return await repairReplacement(`installed daemon generation: ${message(error)}`, 1, true);
1204
+ }
1100
1205
  }
1101
1206
  rt.out("Removing completed update recovery snapshot");
1102
1207
  snapshot.discard();
1103
1208
  clearUpdateRecovery();
1104
1209
  recordUpdateCompletion(targetVersion, `updated to ${targetVersion}`, true);
1105
- rt.out(c.green(`✓ cotal-ai@${targetVersion} installed globally and reconciled`));
1210
+ if (stagedExecution)
1211
+ rt.out(c.green(`✓ cotal-ai@${targetVersion} in use and reconciled`));
1212
+ else
1213
+ rt.out(c.green(`✓ cotal-ai@${targetVersion} installed globally and reconciled`));
1106
1214
  return interrupted;
1107
1215
  async function reconcileVersion(version) {
1108
- const verified = rt.verifyGlobalEntry(root, version);
1216
+ const verified = execution ? (execution.verify(version), version === targetVersion ? execution.entry : join(root, "cotal-ai", "dist/cotal.js")) : rt.verifyGlobalEntry(root, version);
1109
1217
  const repairEnv = { ...rt.env, ...(prefix ? { npm_config_prefix: prefix } : {}), [UPDATE_TARGET_ENV]: version, [UPDATE_PARENT_ENV]: String(rt.pid) };
1110
1218
  delete repairEnv[EXT_UPDATE_PARENT_ENV];
1111
1219
  const result = await rt.spawnGlobal(root, "reconcile", rt.nodePath, [verified, "update", ...targetArgv(target)], repairEnv, true);
@@ -1113,21 +1221,31 @@ async function upgradeAndReconcile(targetVersion, current, rt, target) {
1113
1221
  rt.stderr(result.stderr);
1114
1222
  if (result.stdout)
1115
1223
  rt.stdout(result.stdout);
1116
- return result.status === 0;
1224
+ if (result.status !== 0)
1225
+ return false;
1226
+ if (rt.env.COTAL_AUTO_UPDATE !== "1") {
1227
+ const recovery = readUpdateRecovery();
1228
+ if (recovery && recovery.phase !== "verified-ready")
1229
+ writeUpdateRecovery({ ...recovery, installed: version, phase: "verified-ready" });
1230
+ await rt.waitForInstalledGeneration?.(version);
1231
+ }
1232
+ return true;
1117
1233
  }
1118
- async function repairReplacement(reason, failureStatus = 1) {
1119
- rt.err(c.yellow("Retrying reconciliation of the installed generation before rollback."));
1120
- try {
1121
- if (await reconcileVersion(targetVersion)) {
1122
- snapshot.discard();
1123
- clearUpdateRecovery();
1124
- recordUpdateCompletion(targetVersion, `repaired and updated to ${targetVersion}`, true);
1125
- rt.out(c.green(`✓ cotal-ai@${targetVersion} repaired and reconciled`));
1126
- return interrupted;
1234
+ async function repairReplacement(reason, failureStatus = 1, skipTargetRetry = false) {
1235
+ if (!skipTargetRetry) {
1236
+ rt.err(c.yellow("Retrying reconciliation of the installed generation before rollback."));
1237
+ try {
1238
+ if (await reconcileVersion(targetVersion)) {
1239
+ snapshot.discard();
1240
+ clearUpdateRecovery();
1241
+ recordUpdateCompletion(targetVersion, `repaired and updated to ${targetVersion}`, true);
1242
+ rt.out(c.green(`✓ cotal-ai@${targetVersion} repaired and reconciled`));
1243
+ return interrupted;
1244
+ }
1245
+ }
1246
+ catch (error) {
1247
+ rt.err(`reconcile retry: ${message(error)}`);
1127
1248
  }
1128
- }
1129
- catch (error) {
1130
- rt.err(`reconcile retry: ${message(error)}`);
1131
1249
  }
1132
1250
  rt.err(c.yellow(`Restoring verified cotal-ai@${current} through the global updater.`));
1133
1251
  try {
@@ -1135,13 +1253,20 @@ async function upgradeAndReconcile(targetVersion, current, rt, target) {
1135
1253
  if (!recovery)
1136
1254
  throw new Error("update recovery journal is missing");
1137
1255
  writeUpdateRecovery({ ...recovery, phase: "restoring" });
1138
- await checkReleaseArchives(current, rt);
1139
- const command = cmdSpawnSpec("npm", ["install", "-g", ...prefixArgs, `cotal-ai@${current}`]);
1140
- const restored = await rt.spawnGlobal(root, "install", command.file, command.args, rt.env, true, command.windowsVerbatimArguments);
1141
- if (restored.status !== 0)
1142
- throw new Error(failure(restored));
1143
- rt.verifyGlobalEntry(root, current);
1256
+ if (execution) {
1257
+ execution.restore();
1258
+ }
1259
+ else {
1260
+ await checkReleaseArchives(current, rt);
1261
+ const command = cmdSpawnSpec("npm", ["install", "-g", ...prefixArgs, `cotal-ai@${current}`]);
1262
+ const restored = await rt.spawnGlobal(root, "install", command.file, command.args, rt.env, true, command.windowsVerbatimArguments);
1263
+ if (restored.status !== 0)
1264
+ throw new Error(failure(restored));
1265
+ rt.verifyGlobalEntry(root, current);
1266
+ }
1144
1267
  snapshot.restore();
1268
+ if (execution)
1269
+ execution.verify(current);
1145
1270
  await releaseAdmission?.();
1146
1271
  releaseAdmission = await rt.prepareReplacement?.();
1147
1272
  if (!await reconcileVersion(current))