@cotal-ai/cli 0.171.3 → 0.171.5

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.
Files changed (62) hide show
  1. package/dist/command.d.ts.map +1 -1
  2. package/dist/command.js +12 -4
  3. package/dist/command.js.map +1 -1
  4. package/dist/commands/agents.js +7 -7
  5. package/dist/commands/agents.js.map +1 -1
  6. package/dist/commands/ext.d.ts.map +1 -1
  7. package/dist/commands/ext.js +43 -10
  8. package/dist/commands/ext.js.map +1 -1
  9. package/dist/commands/service-actions.d.ts.map +1 -1
  10. package/dist/commands/service-actions.js +22 -12
  11. package/dist/commands/service-actions.js.map +1 -1
  12. package/dist/commands/space.d.ts.map +1 -1
  13. package/dist/commands/space.js +8 -6
  14. package/dist/commands/space.js.map +1 -1
  15. package/dist/commands/spawn.js +1 -1
  16. package/dist/commands/spawn.js.map +1 -1
  17. package/dist/commands/stack-down.d.ts.map +1 -1
  18. package/dist/commands/stack-down.js +3 -7
  19. package/dist/commands/stack-down.js.map +1 -1
  20. package/dist/commands/stack-up.d.ts +3 -1
  21. package/dist/commands/stack-up.d.ts.map +1 -1
  22. package/dist/commands/stack-up.js +14 -4
  23. package/dist/commands/stack-up.js.map +1 -1
  24. package/dist/commands/status.d.ts +6 -0
  25. package/dist/commands/status.d.ts.map +1 -1
  26. package/dist/commands/status.js +30 -18
  27. package/dist/commands/status.js.map +1 -1
  28. package/dist/commands/update.d.ts +2 -0
  29. package/dist/commands/update.d.ts.map +1 -1
  30. package/dist/commands/update.js +206 -50
  31. package/dist/commands/update.js.map +1 -1
  32. package/dist/commands/whoami.d.ts.map +1 -1
  33. package/dist/commands/whoami.js +2 -1
  34. package/dist/commands/whoami.js.map +1 -1
  35. package/dist/lib/extension-stage.d.ts +1 -1
  36. package/dist/lib/extension-stage.d.ts.map +1 -1
  37. package/dist/lib/extension-stage.js +26 -11
  38. package/dist/lib/extension-stage.js.map +1 -1
  39. package/dist/lib/registry-errors.d.ts +2 -1
  40. package/dist/lib/registry-errors.d.ts.map +1 -1
  41. package/dist/lib/registry-errors.js +3 -2
  42. package/dist/lib/registry-errors.js.map +1 -1
  43. package/dist/lib/self-exec.d.ts +2 -0
  44. package/dist/lib/self-exec.d.ts.map +1 -1
  45. package/dist/lib/self-exec.js +5 -1
  46. package/dist/lib/self-exec.js.map +1 -1
  47. package/dist/lib/service-preset-target.d.ts +2 -1
  48. package/dist/lib/service-preset-target.d.ts.map +1 -1
  49. package/dist/lib/service-preset-target.js +11 -2
  50. package/dist/lib/service-preset-target.js.map +1 -1
  51. package/dist/lib/stack-journal.d.ts +6 -4
  52. package/dist/lib/stack-journal.d.ts.map +1 -1
  53. package/dist/lib/stack-journal.js +11 -7
  54. package/dist/lib/stack-journal.js.map +1 -1
  55. package/dist/lib/version.d.ts.map +1 -1
  56. package/dist/lib/version.js +11 -9
  57. package/dist/lib/version.js.map +1 -1
  58. package/dist/seed/reconcile.d.ts +2 -0
  59. package/dist/seed/reconcile.d.ts.map +1 -1
  60. package/dist/seed/reconcile.js +30 -11
  61. package/dist/seed/reconcile.js.map +1 -1
  62. package/package.json +4 -4
@@ -19,6 +19,7 @@ interface CommandResult {
19
19
  readonly stdout: string;
20
20
  readonly stderr: string;
21
21
  readonly error?: string;
22
+ readonly errorCode?: string;
22
23
  }
23
24
  export interface ExecutionReplacement {
24
25
  readonly entry: string;
@@ -78,6 +79,7 @@ export interface UpdateRuntime {
78
79
  claimGlobalUpdate(root: string, onWait?: () => void): () => void;
79
80
  /** Read the selected global package again after acquiring its update reservation. */
80
81
  globalVersion?(root: string): string | undefined;
82
+ verifyUpdatedEntry?(root: string, version: string): string;
81
83
  selfArgv(): string[];
82
84
  /** Whether this CLI runs from a source checkout, where `--self` installs a separate global copy. */
83
85
  checkout(): boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../src/commands/update.ts"],"names":[],"mappings":"AAIA,OAAO,EAAmB,KAAK,QAAQ,EAAE,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Q,CAAyB,EAC/F,OAAO,GAAE;IAAE,WAAW,CAAC,EAAE,OAAO,CAAA;CAAO,GACtC,OAAO,CAAC,MAAM,GAAG,QAAQ,CAAC,CAuB5B;AAED,wBAAsB,qBAAqB,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,GAAE;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAC;IAAC,WAAW,CAAC,EAAE,OAAO,CAAC;IAAC,cAAc,CAAC,EAAE,MAAM,CAAA;CAAO,GAAG,OAAO,CAAC,MAAM,GAAG,QAAQ,CAAC,CAuL5L;AAED;;kGAEkG;AAClG,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,mBAAmB,EAC3B,KAAK,EAAE,MAAM,EACb,KAAK,GAAE,MAAM,GAAG,SAAqB,EACrC,GAAG,GAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAkB,EACzC,OAAO,CAAC,EAAE,MAAM,EAChB,QAAQ,CAAC,EAAE,mBAAmB,GAC7B,IAAI,CAcN;AA8oBD,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAYtD;AAQD;;qGAEqG;AACrG,wBAAgB,qBAAqB,CAAC,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAa5F;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,MAAM,CAgB/E"}
@@ -1,18 +1,21 @@
1
1
  import { spawn, spawnSync } from "node:child_process";
2
+ import { lookup } from "node:dns/promises";
2
3
  import { existsSync, lstatSync, mkdtempSync, readdirSync, readFileSync, realpathSync, rmSync, statSync, writeFileSync } from "node:fs";
3
4
  import { homedir, tmpdir } from "node:os";
5
+ import { isIP, SocketAddress } from "node:net";
4
6
  import { basename, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
5
7
  import { globalConfigDir } from "@cotal-ai/core";
6
- import { CommandFailure, isCommandFailure, jsonFlag, plainFlag, presentationOf, protectedLocalDirectory, renderReport, writeResult, cmdSpawnSpec, beginGlobalUpdateChild, processGroupMembers, processStartToken, claimUpdateClosureAccess, updateClosureOwner, homeCotalDir, readUpdateRecovery, clearUpdateRecovery, writeUpdateRecovery, readUpdateSettings, recordUpdateCompletion, recordUpdateDeferral, recordUpdateRefusal, recordUpdateReplacement, setUpdateSetting, bindExtensionPeers, claimGlobalNpmUpdateLock, launcherInstallRoot, logicalExecutionEntry, loadExtensionsManifest, provenance, SEEDED_EXTENSIONS, targetFlags, resolveControlTarget, recoveryDisposition, liveUpdateClosureOwner, recoveryProcessStartToken, observeUnownedRecovery, } from "@cotal-ai/workspace";
8
+ import { CommandFailure, isCommandFailure, jsonFlag, plainFlag, presentationOf, protectedLocalDirectory, renderReport, writeResult, cmdSpawnSpec, beginGlobalUpdateChild, processGroupMembers, processStartToken, claimUpdateClosureAccess, updateClosureOwner, homeCotalDir, isMeshRegistryError, preparedRecordSkipped, preparedRecordSpace, preparedSpacesDir, readPreparedSpaces, recordOperationWarning, readUpdateRecovery, clearUpdateRecovery, writeUpdateRecovery, readUpdateSettings, observeUpdateVersion, UPDATE_HOUR_MS, recordUpdateCompletion, recordUpdateDeferral, recordUpdateReleaseHold, recordUpdateRefusal, recordUpdateReplacement, prepareConnectorConfigForUpdate, setUpdateSetting, bindExtensionPeers, claimGlobalNpmUpdateLock, launcherInstallRoot, logicalExecutionEntry, loadExtensionsManifest, provenance, SEEDED_EXTENSIONS, targetFlags, resolveControlTarget, recoveryDisposition, liveUpdateClosureOwner, recoveryProcessStartToken, observeUnownedRecovery, } from "@cotal-ai/workspace";
7
9
  import { retainUnusableRecovery } from "../lib/update-recovery-state.js";
8
10
  import { readUpdatePending } from "../lib/update-pending.js";
9
11
  import { snapshotUpdateClosure } from "../lib/update-snapshot.js";
10
12
  import { EXT_UPDATE_PARENT_ENV } from "./ext.js";
11
13
  import { claimExtensionUpdatePass } from "../lib/ext-mutation.js";
14
+ import { recoverExtensionPromotion } from "../lib/extension-stage.js";
12
15
  import { selfArgv } from "../lib/self-exec.js";
13
16
  import { repairInstallModes, withInstallUmask } from "../lib/install-umask.js";
14
17
  import { cliVersion, installedCliVersion } from "../lib/version.js";
15
- import { runSeed, compareSemver, seedInstallationCurrent, assertReadableSeedState } from "../seed/reconcile.js";
18
+ import { runSeed, compareSemver, seedInstallationCurrent, assertReadableSeedState, readSeedRepairRefusal } from "../seed/reconcile.js";
16
19
  import { operatorInstallDiffers } from "../seed/verify.js";
17
20
  import { cliPackageRoot, entryScript, seedWriterKind } from "../seed/paths.js";
18
21
  import { refreshConnectorInstalls } from "./setup.js";
@@ -48,6 +51,7 @@ export const updateFlags = [
48
51
  ...targetFlags,
49
52
  onFlag,
50
53
  ];
54
+ const MISSING_NPM_REMEDY = "Install npm or add it to this command's PATH, then retry.";
51
55
  export { installedCliVersion, repairInstallModes };
52
56
  export const updateRuntime = {
53
57
  env: process.env,
@@ -87,7 +91,7 @@ export const updateRuntime = {
87
91
  extensions: () => loadExtensionsManifest().extensions,
88
92
  verifyExtension: verifyCurrentExtension,
89
93
  claimUpdatePass: () => claimExtensionUpdatePass(),
90
- claimGlobalUpdate: (root, onWait) => claimGlobalNpmUpdateLock(root, { waitMs: 10 * 60_000, onWait }),
94
+ claimGlobalUpdate: (root, onWait) => claimGlobalNpmUpdateLock(root, { waitMs: 10 * 60_000, renew: true, onWait }),
91
95
  globalVersion: (root) => {
92
96
  const path = join(root, "cotal-ai", "package.json");
93
97
  if (!existsSync(path))
@@ -224,6 +228,31 @@ async function updateInstallation(args, rt) {
224
228
  native: { outcome: "not-executed" },
225
229
  });
226
230
  }
231
+ try {
232
+ if (rt.prepareExecution) {
233
+ prepareConnectorConfigForUpdate();
234
+ if (recoverExtensionPromotion(true))
235
+ prepareConnectorConfigForUpdate();
236
+ }
237
+ else
238
+ recoverExtensionPromotion();
239
+ }
240
+ catch (error) {
241
+ const failure = isCommandFailure(error) ? error : new CommandFailure("refused", "PERMISSION_DENIED", `Cannot prepare the Cotal connector configuration: ${message(error)}. No CLI update was staged.`, {
242
+ native: { outcome: "not-executed" }, remedy: "Correct the reported connector configuration problem, then run `cotal update --self` again.",
243
+ });
244
+ recordUpdateDeferral(rt.version(), `connector configuration preflight: ${preflightDetail(failure)}`);
245
+ throw failure;
246
+ }
247
+ // Built-in self-update skips the extension overlay. Validate its inventory after recovery, not before.
248
+ try {
249
+ loadExtensionsManifest();
250
+ }
251
+ catch (error) {
252
+ rt.err(c.red(`✗ ${message(error)}`));
253
+ process.exitCode = 1;
254
+ return;
255
+ }
227
256
  }
228
257
  const restored = await recoverInterruptedUpdate(rt);
229
258
  if (restored) {
@@ -426,18 +455,36 @@ function checkUpdate(args, rt) {
426
455
  warnings.push({ code: "EXTENSION_INVENTORY_UNREADABLE", target: null, message: "The extension inventory could not be read. It was not repaired or treated as empty." });
427
456
  }
428
457
  const latest = latestVersion(rt);
458
+ const missingNpm = !latest.ok && latest.missingNpm;
429
459
  if (!latest.ok)
430
- warnings.push({ code: "LATEST_VERSION_UNAVAILABLE", target: null, message: "The registry did not return a valid latest version. Update availability is unknown." });
460
+ warnings.push(missingNpm
461
+ ? { code: "NPM_UNAVAILABLE", target: null, message: "npm is not on PATH. Update availability is unknown." }
462
+ : { code: "LATEST_VERSION_UNAVAILABLE", target: null, message: "The registry did not return a valid latest version. Update availability is unknown." });
431
463
  const comparison = latest.ok ? compareSemver(latest.version, current) : null;
432
- const pending = readUpdatePending(current);
433
- if (pending.kind === "unreadable")
434
- warnings.push({ code: "RECONCILIATION_UNREADABLE", target: null, message: `Reconciliation state could not be read: ${pending.error}` });
435
- const result = { kind: "update-check", reconciliation: pending, current, latest: latest.ok ? latest.version : null, updateAvailable: comparison === null ? null : comparison > 0, extensions, scope: "registry version and recorded installation versions", installationChanged: false, processesRestarted: false };
464
+ let reconciliation = readUpdatePending(current);
465
+ if (reconciliation.kind === "none" || reconciliation.kind === "version-mismatch") {
466
+ try {
467
+ const refusal = readSeedRepairRefusal(current);
468
+ if (refusal)
469
+ reconciliation = { kind: "seed", instruction: refusal.message };
470
+ }
471
+ catch (error) {
472
+ reconciliation = { kind: "unreadable", source: "seed", error: refusal(error), instruction: "Run `cotal ext seed --repair` to reconcile the connectors." };
473
+ }
474
+ }
475
+ if (reconciliation.kind === "unreadable")
476
+ warnings.push({ code: "RECONCILIATION_UNREADABLE", target: null, message: `Reconciliation state could not be read: ${reconciliation.error}` });
477
+ if (reconciliation.kind === "seed")
478
+ warnings.push({ code: "OPERATION_PARTIAL", target: null, message: reconciliation.instruction });
479
+ const result = { kind: "update-check", reconciliation, current, latest: latest.ok ? latest.version : null, updateAvailable: comparison === null ? null : comparison > 0, extensions, scope: "registry version and recorded installation versions", installationChanged: false, processesRestarted: false };
436
480
  writeResult(presentationOf(args.values), {
437
481
  command: "update", target: null, result, warnings,
438
- ...(warnings.length ? { completeness: "partial", partial: { message: "Some update information could not be established.", remedy: "Check registry access or the unreadable inventory and repeat update --check." } } : {}),
482
+ ...(warnings.length ? { completeness: "partial", partial: {
483
+ message: reconciliation.kind === "seed" ? "Connector seeding needs reconciliation." : "Some update information could not be established.",
484
+ remedy: reconciliation.kind === "seed" || reconciliation.kind === "unreadable" && reconciliation.source === "seed" ? reconciliation.instruction : missingNpm ? MISSING_NPM_REMEDY : "Check registry access or the unreadable inventory and repeat update --check.",
485
+ } } : {}),
439
486
  }, (r) => ({ sections: [
440
- ...(pending.kind === "none" ? [] : [{ title: "Reconciliation", blocks: [{ kind: "lines", lines: [pending.instruction] }] }]),
487
+ ...(r.reconciliation.kind === "none" ? [] : [{ title: "Reconciliation", blocks: [{ kind: "lines", lines: [r.reconciliation.instruction] }] }]),
441
488
  { title: "Update availability", blocks: [{ kind: "fields", rows: [["Running CLI", r.current], ["Registry latest", r.latest ?? "not established"], ["CLI update", r.updateAvailable === null ? { text: "unknown", tone: "waiting" } : r.updateAvailable ? { text: "available", tone: "waiting" } : comparison === 0 ? "matches latest tag" : "running version is ahead of latest tag"]] }] },
442
489
  { title: "Recorded extensions", blocks: [r.extensions === null ? { kind: "lines", lines: [{ text: "Inventory unavailable. No repair was attempted.", tone: "waiting" }] } : r.extensions.length ? { kind: "table", columns: [{ key: "package", label: "Package" }, { key: "version", label: "Recorded version" }, { key: "state", label: "Generation" }], rows: r.extensions.map((entry) => ({ package: entry.package, version: entry.version, state: !entry.firstParty ? { text: "third party", tone: "hint" } : entry.matchesCli ? { text: "matches running CLI", tone: "ok" } : { text: "differs from running CLI", tone: "waiting" } })) } : { kind: "lines", lines: ["No extensions in the recorded inventory."] }, { kind: "lines", lines: [{ text: "Version records only. Package contents, signatures and running processes were not checked. No installation was reconciled or restarted.", tone: "hint" }] }] },
443
490
  { title: "Next", blocks: [{ kind: "commands", items: [{ command: "cotal update", description: "Reconcile the current generation through the existing guarded updater" }, ...(r.updateAvailable ? [{ command: "cotal update --self", description: rt.checkout() ? "Install the verified latest CLI as a separate global copy and reconcile through it; this checkout does not change" : "Install the verified latest CLI and reconcile its generation" }] : []), { command: "cotal status", description: "Inspect this machine and its selected space" }] }] },
@@ -446,14 +493,14 @@ function checkUpdate(args, rt) {
446
493
  /** Injectable command body: production keeps one process seam; the smoke covers every decision branch. */
447
494
  export async function executeUpdate(self, rt = updateRuntime, target = {}) {
448
495
  const current = rt.version();
449
- if (self && rt.env.COTAL_AUTO_UPDATE === "1")
450
- recordUpdateDeferral(current, "waiting for update preflight");
451
496
  const child = childBinding(rt);
452
497
  if (child.kind === "invalid") {
453
498
  rt.err(c.red(`✗ invalid global update child binding: ${child.reason}; refusing to mutate extensions`));
454
499
  return 1;
455
500
  }
456
501
  if (child.kind === "bound") {
502
+ if (self && rt.env.COTAL_AUTO_UPDATE === "1")
503
+ recordUpdateDeferral(current, "waiting for update preflight");
457
504
  if (current !== child.target) {
458
505
  rt.err(c.red(`✗ global update child is cotal-ai ${current}, expected ${child.target}; refusing to mutate extensions`));
459
506
  return 1;
@@ -494,34 +541,44 @@ export async function executeUpdate(self, rt = updateRuntime, target = {}) {
494
541
  if (self) {
495
542
  const latest = latestVersion(rt);
496
543
  if (!latest.ok) {
544
+ if (latest.missingNpm) {
545
+ if (rt.env.COTAL_AUTO_UPDATE === "1")
546
+ recordUpdateDeferral(current, "waiting for npm availability", true);
547
+ rt.err(c.red(`✗ cotal-ai version check failed: ${latest.error}. ${MISSING_NPM_REMEDY}`));
548
+ return 1;
549
+ }
497
550
  if (rt.env.COTAL_AUTO_UPDATE === "1")
498
551
  recordUpdateDeferral(current, "waiting for registry availability", true);
552
+ else if (latest.npmResult && await npmProxyRefused(latest.npmResult, rt.env)) {
553
+ rt.err("The npm proxy refused the connection (ECONNREFUSED). The update did not start. Check HTTP_PROXY and HTTPS_PROXY, then retry.");
554
+ return 1;
555
+ }
499
556
  rt.out("The registry cannot be reached; nothing was changed.");
500
557
  return 0;
501
558
  }
502
- if (compareSemver(latest.version, current) > 0) {
559
+ const upgrading = compareSemver(latest.version, current) > 0;
560
+ if (rt.env.COTAL_AUTO_UPDATE === "1") {
561
+ // The live npm lookup can select a different version from the one the daemon held.
562
+ const next = await observeUpdateVersion(latest.version) + UPDATE_HOUR_MS;
563
+ if (upgrading && Date.now() < next) {
564
+ recordUpdateReleaseHold(latest.version, next);
565
+ return 0;
566
+ }
567
+ recordUpdateDeferral(current, "waiting for update preflight");
568
+ }
569
+ if (upgrading) {
503
570
  const code = await upgradeAndReconcile(latest.version, current, rt, target);
504
571
  if (code === 0 && rt.env.COTAL_AUTO_UPDATE !== "1")
505
572
  rt.generationWaited = true;
506
573
  return code;
507
574
  }
508
- if (latest.ok && rt.isCurrent?.()) {
509
- try {
510
- const custody = await rt.reportRunningManager(target);
511
- rt.out("No newer CLI version; installed package closure is current. No connector reconciliation was run.");
512
- if (custody === "legacy")
513
- rt.out("A later update will require stopping the agents listed above before replacing packages.");
514
- if (rt.env.COTAL_AUTO_UPDATE === "1")
515
- recordUpdateCompletion(current, "up to date", true);
516
- reportVersion(current, latest.version, rt, false);
517
- return 0;
518
- }
519
- catch (error) {
520
- if (rt.env.COTAL_AUTO_UPDATE === "1")
521
- recordUpdateDeferral(current, "waiting for agents to stop");
522
- rt.err(c.red(`✗ running manager continuity check: ${refusal(error)}`));
523
- return 1;
524
- }
575
+ if (rt.isCurrent?.()) {
576
+ reportUncheckedPreparedRecords(rt, target);
577
+ rt.out("No newer CLI version; installed package closure is current. No connector reconciliation was run.");
578
+ if (rt.env.COTAL_AUTO_UPDATE === "1")
579
+ recordUpdateCompletion(current, "up to date", true);
580
+ reportVersion(current, latest.version, rt, false);
581
+ return 0;
525
582
  }
526
583
  return reconcileCurrent(current, rt, target, (reconciled, deferred) => {
527
584
  if (rt.env.COTAL_AUTO_UPDATE === "1") {
@@ -549,6 +606,25 @@ export async function executeUpdate(self, rt = updateRuntime, target = {}) {
549
606
  return reconciled ? 0 : 1;
550
607
  });
551
608
  }
609
+ function reportUncheckedPreparedRecords(rt, target) {
610
+ if (["server", "creds", "on"].some(key => typeof target[key] === "string"))
611
+ return;
612
+ // The installed child may carry a daemon admission receipt and never resolve the project.
613
+ // Report read failures separately from the Manager custody verdict and package reconciliation.
614
+ try {
615
+ for (const error of readPreparedSpaces().unusable) {
616
+ if (error.refusal !== "PERMISSION_DENIED")
617
+ continue;
618
+ if (typeof target.space === "string" && target.space !== preparedRecordSpace(error.file))
619
+ continue;
620
+ recordOperationWarning(preparedRecordSkipped(error));
621
+ rt.out(c.dim(` ${error.file}: leaving its records and processes untouched, continuity not checked`));
622
+ }
623
+ }
624
+ catch (error) {
625
+ rt.err(`Could not check prepared space records: ${message(error)}; continuity not checked`);
626
+ }
627
+ }
552
628
  async function reconcileCurrent(current, rt, target, finish) {
553
629
  try {
554
630
  await rt.prepareReconciliation?.(target);
@@ -576,6 +652,7 @@ async function reconcileCurrent(current, rt, target, finish) {
576
652
  rt.err(c.red(`✗ running manager continuity check: ${refusal(e)}`));
577
653
  return finish(false, true);
578
654
  }
655
+ reportUncheckedPreparedRecords(rt, target);
579
656
  try {
580
657
  await rt.preflightReplacement?.();
581
658
  }
@@ -627,10 +704,8 @@ async function reconcileCurrent(current, rt, target, finish) {
627
704
  rt.err(c.red(`✗ could not read installed extensions: ${message(e)}`));
628
705
  return finish(false);
629
706
  }
630
- if (!entries.length) {
707
+ if (!entries.length)
631
708
  rt.out(c.dim("operator extensions: none installed"));
632
- return finish(ok);
633
- }
634
709
  for (const entry of entries) {
635
710
  if (!entry.pkg.startsWith("@cotal-ai/")) {
636
711
  rt.out(c.dim(`${entry.pkg}@${entry.version} - not auto-updated in v1 (recorded spec: ${entry.spec})`));
@@ -675,6 +750,9 @@ async function reconcileCurrent(current, rt, target, finish) {
675
750
  }
676
751
  rt.out(c.green(`✓ ${entry.pkg}@${current}`) + c.dim(` - current generation (recorded spec: ${entry.spec})`));
677
752
  }
753
+ if (ok && rt.env.COTAL_AUTO_UPDATE !== "1") {
754
+ rt.out("Cotal updates the managed pi connector, not your standalone pi extension. If you copied it, wait for the update to succeed, then reinstall `@cotal-ai/pi` at the version shown by `cotal --version` and repeat the copy. See https://docs.cotal.ai/docs/connect-pi/#load-the-extension-into-your-own-host");
755
+ }
678
756
  return finish(ok);
679
757
  }
680
758
  finally {
@@ -721,15 +799,20 @@ export async function isStoppedLocalMesh(target) {
721
799
  return false;
722
800
  return assertEndpointUnreachable(target.server).then(() => true, () => false);
723
801
  }
724
- /** A prepared controller that completed ordinary down is cold only while its own instance records
725
- * prove every process gone, no supervisor may serve it, and its recorded broker has no listener.
802
+ /** A prepared controller that completed down or failed to start any member is cold only while its
803
+ * own instance records prove every process gone, no supervisor may serve it, and its broker has no listener.
726
804
  * The target resolver refuses before returning a MeshTarget for this lifecycle. */
727
805
  async function stoppedController(d, server) {
728
806
  if (typeof d.space !== "string" || typeof d.root !== "string" || !d.stopped ||
729
807
  d.rootMissing === true || d.unsettled !== undefined || d.home !== undefined || d.stackSpace !== undefined)
730
808
  return false;
731
809
  const journal = readStackJournal(d.root)?.journal;
732
- if (!journal || journal.space !== d.space || journal.operation.kind !== "down" || journal.operation.phase !== "completed")
810
+ if (!journal || journal.space !== d.space)
811
+ return false;
812
+ const completedDown = journal.operation.kind === "down" && journal.operation.phase === "completed";
813
+ const failedStart = journal.operation.kind === "up" && journal.operation.phase === "failed" &&
814
+ journal.members.every(member => (member.state === "failed" || member.state === "not-attempted") && !member.process && !member.replacement);
815
+ if (!completedDown && !failedStart)
733
816
  return false;
734
817
  if (server !== undefined && brokerUrlKey(server) !== brokerUrlKey(journal.server))
735
818
  return false;
@@ -899,6 +982,16 @@ export async function readManagerContinuity(flags, options = {}) {
899
982
  peek = resolveMeshTarget(process.cwd(), { server, space, offline });
900
983
  }
901
984
  catch (e) {
985
+ // An unreadable prepared record is not evidence about Manager custody. The updater can
986
+ // leave it alone only if it was not asked for a broker or instance and has no potentially
987
+ // running registration or supervisor to check for the affected target.
988
+ if (isMeshRegistryError(e) && e.refusal === "PERMISSION_DENIED" && dirname(e.file) === preparedSpacesDir()) {
989
+ const name = preparedRecordSpace(e.file);
990
+ if (name !== undefined && server === undefined && on === undefined &&
991
+ !registry.entries.some(entry => space === undefined ? !offline?.includes(entry.space) : entry.space === space) &&
992
+ !supervisorMayServe(name, options.installedEntry))
993
+ return "none";
994
+ }
902
995
  if (!isWorkspaceTargetError(e))
903
996
  throw e;
904
997
  // Sudo can inspect another account's project without owning its controller records.
@@ -1067,8 +1160,10 @@ function latestVersion(rt) {
1067
1160
  const cache = mkdtempSync(join(tmpdir(), "cotal-npm-view-"));
1068
1161
  try {
1069
1162
  const result = rt.npm(["view", "cotal-ai@latest", "version", "--json", "--cache", cache, "--logs-max=0", "--update-notifier=false", "--fetch-retries=0", "--fetch-timeout=15000"]);
1163
+ if (result.errorCode === "ENOENT")
1164
+ return { ok: false, error: "npm is not on PATH", missingNpm: true };
1070
1165
  if (result.status !== 0)
1071
- return { ok: false, error: failure(result) };
1166
+ return { ok: false, error: failure(result), npmResult: result };
1072
1167
  try {
1073
1168
  return { ok: true, version: parseNpmVersion(result.stdout) };
1074
1169
  }
@@ -1080,18 +1175,70 @@ function latestVersion(rt) {
1080
1175
  rmSync(cache, { recursive: true, force: true, maxRetries: 3 });
1081
1176
  }
1082
1177
  }
1178
+ /** npm gives a generic proxy hint even for direct failures. Match the refused socket instead. */
1179
+ async function npmProxyRefused(result, env) {
1180
+ const httpsProxy = env.https_proxy || env.HTTPS_PROXY;
1181
+ const httpProxy = env.http_proxy || env.HTTP_PROXY;
1182
+ if ((!httpsProxy && !httpProxy) || result.status === null || result.error)
1183
+ return false;
1184
+ let error;
1185
+ try {
1186
+ error = JSON.parse(result.stdout)?.error;
1187
+ }
1188
+ catch {
1189
+ return false;
1190
+ }
1191
+ if (error?.code !== "ECONNREFUSED" || typeof error.summary !== "string")
1192
+ return false;
1193
+ const refused = /^(?:FetchError: )?request to (\S+) failed, reason: connect ECONNREFUSED (\S+):(\d+)$/.exec(error.summary);
1194
+ if (!refused)
1195
+ return false;
1196
+ const [, request, address, port] = refused;
1197
+ const registry = URL.parse(request);
1198
+ if (!registry || (registry.protocol !== "https:" && registry.protocol !== "http:") || !isIP(address))
1199
+ return false;
1200
+ const setting = httpsProxy || (registry.protocol === "http:" ? httpProxy : undefined);
1201
+ const proxy = setting ? URL.parse(setting) : null;
1202
+ if (!proxy || (proxy.protocol !== "http:" && proxy.protocol !== "https:"))
1203
+ return false;
1204
+ const portOf = (url) => url.port || (url.protocol === "https:" ? "443" : "80");
1205
+ if (portOf(proxy) !== port)
1206
+ return false;
1207
+ const normalize = (ip) => isIP(ip) === 6 ? new SocketAddress({ address: ip, family: "ipv6" }).address : ip;
1208
+ const matches = async (url) => {
1209
+ const host = url.hostname.replace(/^\[|\]$/g, "");
1210
+ const addresses = isIP(host) ? [host] : (await lookup(host, { all: true })).map(item => item.address);
1211
+ return addresses.some(ip => normalize(ip) === normalize(address));
1212
+ };
1213
+ try {
1214
+ // If the registry could have refused the same socket directly, do not blame the proxy.
1215
+ return await matches(proxy) && (portOf(registry) !== port || !await matches(registry));
1216
+ }
1217
+ catch {
1218
+ return false;
1219
+ }
1220
+ }
1083
1221
  /** Resolve installed first-party surfaces in a disposable prefix, including their npm dependencies. */
1084
- function checkInstalledClosure(version, rt) {
1222
+ function checkInstalledClosure(version, releasePackages, rt) {
1085
1223
  const names = [...new Set(rt.extensions().filter(entry => entry.pkg.startsWith("@cotal-ai/")).map(entry => entry.pkg))];
1086
1224
  if (!names.length)
1087
1225
  return;
1088
1226
  const staging = mkdtempSync(join(tmpdir(), "cotal-closure-check-"));
1089
1227
  try {
1228
+ // Reconciliation supplies first-party peers from the target CLI, not the registry's latest tag.
1229
+ // Constrain npm to that verified release graph without skipping third-party peers.
1230
+ writeFileSync(join(staging, "package.json"), JSON.stringify({
1231
+ overrides: Object.fromEntries([...releasePackages, ...names].map(name => [name, version])),
1232
+ }));
1090
1233
  const result = rt.npm(["install", "--prefix", staging, "--cache", join(staging, ".npm-cache"), "--logs-max=0", "--update-notifier=false", "--ignore-scripts", "--package-lock=false", "--no-audit", "--no-fund", "--fetch-retries=2", "--fetch-retry-mintimeout=1000", "--fetch-retry-maxtimeout=2000", "--fetch-timeout=15000", "--prefer-online", ...names.map(name => `${name}@${version}`)]);
1091
1234
  if (result.signal)
1092
1235
  throw new DependencyCheckInterrupted(`npm dependency check was terminated by ${result.signal}`);
1093
- if (result.status !== 0)
1094
- throw releaseReadError(result, `installed extension dependency closure is unavailable: ${failure(result)}`);
1236
+ if (result.status !== 0) {
1237
+ const detail = `installed extension dependency closure is unavailable: ${failure(result)}`;
1238
+ if (/^npm (?:error|ERR!) code ENOSPC\s*$/m.test(result.stderr))
1239
+ throw new DependencyCheckNoSpace(detail);
1240
+ throw releaseReadError(result, detail);
1241
+ }
1095
1242
  }
1096
1243
  finally {
1097
1244
  rmSync(staging, { recursive: true, force: true, maxRetries: 3 });
@@ -1169,6 +1316,7 @@ async function checkReleaseArchives(version, rt) {
1169
1316
  if (archive.status !== 0)
1170
1317
  throw releaseReadError(archive, `archives for ${specs.join(", ")} could not be downloaded and verified`);
1171
1318
  }
1319
+ return pending;
1172
1320
  }
1173
1321
  finally {
1174
1322
  rmSync(cache, { recursive: true, force: true, maxRetries: 3 });
@@ -1255,6 +1403,8 @@ class ReleaseDateExcluded extends Error {
1255
1403
  }
1256
1404
  class DependencyCheckInterrupted extends Error {
1257
1405
  }
1406
+ class DependencyCheckNoSpace extends Error {
1407
+ }
1258
1408
  class RegistryUnavailable extends Error {
1259
1409
  }
1260
1410
  const NETWORK_ERROR_CODE = /^(?:ENETUNREACH|EHOSTUNREACH|ENETDOWN|EHOSTDOWN|ECONNRESET|ECONNREFUSED|ECONNABORTED|ETIMEDOUT|ESOCKETTIMEDOUT|EAI_AGAIN|ENOTFOUND)$/;
@@ -1289,8 +1439,7 @@ async function waitForReleaseArchives(version, current, rt) {
1289
1439
  const deadline = now() + 10 * 60_000;
1290
1440
  for (;;) {
1291
1441
  try {
1292
- await checkReleaseArchives(version, rt);
1293
- return true;
1442
+ return await checkReleaseArchives(version, rt);
1294
1443
  }
1295
1444
  catch (error) {
1296
1445
  if (!(error instanceof ReleaseNotAvailable))
@@ -1299,7 +1448,7 @@ async function waitForReleaseArchives(version, current, rt) {
1299
1448
  if (remaining <= 0) {
1300
1449
  recordUpdateDeferral(version, "waiting for registry or extension closure availability", true);
1301
1450
  rt.out(`cotal-ai@${version} is still reaching the registry. Keeping cotal-ai@${current}; no global install was attempted. A later update check will try again.`);
1302
- return false;
1451
+ return undefined;
1303
1452
  }
1304
1453
  rt.out(`Waiting for cotal-ai@${version} release archives to reach the registry (${Math.ceil(remaining / 1000)} s remaining); cotal-ai@${current} stays installed.`);
1305
1454
  await (rt.sleep ?? (milliseconds => new Promise(resolveSleep => setTimeout(resolveSleep, milliseconds))))(Math.min(15_000, remaining));
@@ -1355,10 +1504,11 @@ async function upgradeAndReconcile(targetVersion, current, rt, target) {
1355
1504
  const releaseChecksStarted = Date.now();
1356
1505
  try {
1357
1506
  rt.out(`Checking cotal-ai@${targetVersion} release archives`);
1358
- if (!await waitForReleaseArchives(targetVersion, current, rt))
1507
+ const releasePackages = await waitForReleaseArchives(targetVersion, current, rt);
1508
+ if (!releasePackages)
1359
1509
  return 0;
1360
1510
  rt.out(`Checking installed extension dependencies for ${targetVersion}`);
1361
- checkInstalledClosure(targetVersion, rt);
1511
+ checkInstalledClosure(targetVersion, releasePackages, rt);
1362
1512
  // In-place rollback downloads the previous release. Staged rollback retains its complete graph.
1363
1513
  if (!rt.prepareExecution) {
1364
1514
  rt.out(`Checking cotal-ai@${current} recovery archives`);
@@ -1372,6 +1522,11 @@ async function upgradeAndReconcile(targetVersion, current, rt, target) {
1372
1522
  rt.err(c.red(`✗ ${message(e)}. No installed packages were replaced. Run \`cotal update --self\` again.`));
1373
1523
  return 1;
1374
1524
  }
1525
+ if (e instanceof DependencyCheckNoSpace) {
1526
+ recordUpdateDeferral(targetVersion, "temporary filesystem is out of space", true);
1527
+ rt.err(c.red(`✗ ${message(e)}. No global install was attempted. Free space on the temporary filesystem, then run \`cotal update --self\` again.`));
1528
+ return 1;
1529
+ }
1375
1530
  if (e instanceof ReleaseDateExcluded) {
1376
1531
  recordUpdateDeferral(targetVersion, "npm date filter excludes the release");
1377
1532
  rt.err(c.red(`✗ ${message(e)}. No global install was attempted.`));
@@ -1434,7 +1589,7 @@ async function upgradeAndReconcile(targetVersion, current, rt, target) {
1434
1589
  }
1435
1590
  let releaseGlobal;
1436
1591
  try {
1437
- releaseGlobal = rt.claimGlobalUpdate(root, () => rt.out("Waiting up to 10 minutes for another updater to release npm's global root"));
1592
+ releaseGlobal = rt.claimGlobalUpdate(root, () => rt.out("Waiting for another updater to release npm's global root"));
1438
1593
  }
1439
1594
  catch (e) {
1440
1595
  rt.err(c.red(`✗ could not reserve npm's global root for update: ${message(e)}`));
@@ -1445,7 +1600,7 @@ async function upgradeAndReconcile(targetVersion, current, rt, target) {
1445
1600
  try {
1446
1601
  const installed = rt.globalVersion?.(root);
1447
1602
  if (installed && compareSemver(installed, current) > 0 && compareSemver(installed, targetVersion) >= 0) {
1448
- const entry = rt.verifyGlobalEntry(root, installed);
1603
+ const entry = (rt.verifyUpdatedEntry ?? rt.verifyGlobalEntry)(root, installed);
1449
1604
  releaseGlobal();
1450
1605
  rt.out(`Another update installed cotal-ai@${installed}; rechecking the installed CLI`);
1451
1606
  const child = rt.spawn(rt.nodePath, [entry, "update", "--self", ...targetArgv(target), ...(target["stop-agents"] === true ? ["--stop-agents"] : [])], rt.env, true);
@@ -1861,10 +2016,11 @@ function runNpm(args, inherit = false) {
1861
2016
  stdout: `${result.stdout ?? ""}`,
1862
2017
  stderr: `${result.stderr ?? ""}`,
1863
2018
  error: result.error?.message,
2019
+ errorCode: result.error?.code,
1864
2020
  };
1865
2021
  }
1866
2022
  catch (e) {
1867
- return { status: null, stdout: "", stderr: "", error: message(e) };
2023
+ return { status: null, stdout: "", stderr: "", error: message(e), errorCode: e?.code };
1868
2024
  }
1869
2025
  }
1870
2026
  function runProcess(file, args, env, inherit = false) {
@@ -1920,7 +2076,7 @@ async function runGlobalProcess(root, operation, file, args, env, inherit = fals
1920
2076
  mutation.complete(closed.status, closed.signal, closed.signal !== null
1921
2077
  ? `${operation} child terminated by ${closed.signal}`
1922
2078
  : `Windows npm intermediary exited ${closed.status}; descendant completion is unproved`);
1923
- return { status: error ? null : closed.status, stdout, stderr, ...(error ? { error } : {}) };
2079
+ return { status: error ? null : closed.status, signal: closed.signal, stdout, stderr, ...(error ? { error } : {}) };
1924
2080
  }
1925
2081
  catch (e) {
1926
2082
  return { status: null, stdout: "", stderr: "", error: message(e) };
@@ -1945,7 +2101,7 @@ function latestNotAvailable(result, version) {
1945
2101
  }
1946
2102
  }
1947
2103
  function failure(result) {
1948
- return [result.error, result.stderr.trim(), result.stdout.trim()].filter(Boolean).join("\n") || `process exited ${result.status}`;
2104
+ return [result.signal && `process terminated by ${result.signal}`, result.error, result.stderr.trim(), result.stdout.trim()].filter(Boolean).join("\n") || `process exited ${result.status}`;
1949
2105
  }
1950
2106
  function message(value) {
1951
2107
  return value instanceof Error ? value.message : String(value);