@cotal-ai/cli 0.185.3 → 0.186.0

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 (269) hide show
  1. package/dist/chat/stdio.d.ts.map +1 -1
  2. package/dist/chat/stdio.js +3 -2
  3. package/dist/chat/stdio.js.map +1 -1
  4. package/dist/command.d.ts.map +1 -1
  5. package/dist/command.js +15 -5
  6. package/dist/command.js.map +1 -1
  7. package/dist/commands/agents.d.ts +8 -1
  8. package/dist/commands/agents.d.ts.map +1 -1
  9. package/dist/commands/agents.js +114 -25
  10. package/dist/commands/agents.js.map +1 -1
  11. package/dist/commands/chat.d.ts.map +1 -1
  12. package/dist/commands/chat.js +11 -1
  13. package/dist/commands/chat.js.map +1 -1
  14. package/dist/commands/doctor.js +2 -0
  15. package/dist/commands/doctor.js.map +1 -1
  16. package/dist/commands/endpoint-authoring.d.ts.map +1 -1
  17. package/dist/commands/endpoint-authoring.js +5 -3
  18. package/dist/commands/endpoint-authoring.js.map +1 -1
  19. package/dist/commands/ext.d.ts.map +1 -1
  20. package/dist/commands/ext.js +25 -14
  21. package/dist/commands/ext.js.map +1 -1
  22. package/dist/commands/help.d.ts.map +1 -1
  23. package/dist/commands/help.js +6 -11
  24. package/dist/commands/help.js.map +1 -1
  25. package/dist/commands/join.d.ts.map +1 -1
  26. package/dist/commands/join.js +6 -3
  27. package/dist/commands/join.js.map +1 -1
  28. package/dist/commands/models.d.ts.map +1 -1
  29. package/dist/commands/models.js +6 -4
  30. package/dist/commands/models.js.map +1 -1
  31. package/dist/commands/personas.js +2 -2
  32. package/dist/commands/personas.js.map +1 -1
  33. package/dist/commands/send.d.ts.map +1 -1
  34. package/dist/commands/send.js +36 -18
  35. package/dist/commands/send.js.map +1 -1
  36. package/dist/commands/service-registry.d.ts.map +1 -1
  37. package/dist/commands/service-registry.js +2 -1
  38. package/dist/commands/service-registry.js.map +1 -1
  39. package/dist/commands/setup-current-connectors.d.ts +3 -6
  40. package/dist/commands/setup-current-connectors.d.ts.map +1 -1
  41. package/dist/commands/setup-current-connectors.js +17 -1
  42. package/dist/commands/setup-current-connectors.js.map +1 -1
  43. package/dist/commands/setup.d.ts +3 -5
  44. package/dist/commands/setup.d.ts.map +1 -1
  45. package/dist/commands/setup.js +28 -23
  46. package/dist/commands/setup.js.map +1 -1
  47. package/dist/commands/space-delete.d.ts.map +1 -1
  48. package/dist/commands/space-delete.js +21 -10
  49. package/dist/commands/space-delete.js.map +1 -1
  50. package/dist/commands/spawn-managed-launch.d.ts.map +1 -1
  51. package/dist/commands/spawn-managed-launch.js +5 -4
  52. package/dist/commands/spawn-managed-launch.js.map +1 -1
  53. package/dist/commands/spawn-preview.js +2 -2
  54. package/dist/commands/spawn-preview.js.map +1 -1
  55. package/dist/commands/spawn.d.ts.map +1 -1
  56. package/dist/commands/spawn.js +3 -2
  57. package/dist/commands/spawn.js.map +1 -1
  58. package/dist/commands/stack-down.d.ts +1 -1
  59. package/dist/commands/stack-down.d.ts.map +1 -1
  60. package/dist/commands/stack-down.js +19 -3
  61. package/dist/commands/stack-down.js.map +1 -1
  62. package/dist/commands/stack-lost-records.d.ts +1 -1
  63. package/dist/commands/stack-lost-records.d.ts.map +1 -1
  64. package/dist/commands/stack-lost-records.js +7 -5
  65. package/dist/commands/stack-lost-records.js.map +1 -1
  66. package/dist/commands/stack-up.js +1 -1
  67. package/dist/commands/stack-up.js.map +1 -1
  68. package/dist/commands/status-health.d.ts.map +1 -1
  69. package/dist/commands/status-health.js +10 -12
  70. package/dist/commands/status-health.js.map +1 -1
  71. package/dist/commands/status-model.d.ts +1 -0
  72. package/dist/commands/status-model.d.ts.map +1 -1
  73. package/dist/commands/status-render.d.ts.map +1 -1
  74. package/dist/commands/status-render.js +3 -1
  75. package/dist/commands/status-render.js.map +1 -1
  76. package/dist/commands/status.d.ts.map +1 -1
  77. package/dist/commands/status.js +4 -3
  78. package/dist/commands/status.js.map +1 -1
  79. package/dist/commands/sync.d.ts +1 -1
  80. package/dist/commands/sync.d.ts.map +1 -1
  81. package/dist/commands/sync.js +29 -8
  82. package/dist/commands/sync.js.map +1 -1
  83. package/dist/commands/up-args.d.ts +2 -0
  84. package/dist/commands/up-args.d.ts.map +1 -1
  85. package/dist/commands/up-args.js +9 -12
  86. package/dist/commands/up-args.js.map +1 -1
  87. package/dist/commands/up-broker-auth.d.ts +3 -1
  88. package/dist/commands/up-broker-auth.d.ts.map +1 -1
  89. package/dist/commands/up-broker-auth.js +9 -1
  90. package/dist/commands/up-broker-auth.js.map +1 -1
  91. package/dist/commands/up-detach.d.ts +10 -1
  92. package/dist/commands/up-detach.d.ts.map +1 -1
  93. package/dist/commands/up-detach.js +28 -13
  94. package/dist/commands/up-detach.js.map +1 -1
  95. package/dist/commands/up-foreground-listener.d.ts +1 -1
  96. package/dist/commands/up-foreground-listener.d.ts.map +1 -1
  97. package/dist/commands/up-foreground-listener.js +7 -3
  98. package/dist/commands/up-foreground-listener.js.map +1 -1
  99. package/dist/commands/up-host.d.ts +8 -0
  100. package/dist/commands/up-host.d.ts.map +1 -1
  101. package/dist/commands/up-host.js +27 -1
  102. package/dist/commands/up-host.js.map +1 -1
  103. package/dist/commands/up-resume.d.ts.map +1 -1
  104. package/dist/commands/up-resume.js +4 -2
  105. package/dist/commands/up-resume.js.map +1 -1
  106. package/dist/commands/up.d.ts.map +1 -1
  107. package/dist/commands/up.js +13 -13
  108. package/dist/commands/up.js.map +1 -1
  109. package/dist/commands/update-caches.d.ts +1 -0
  110. package/dist/commands/update-caches.d.ts.map +1 -1
  111. package/dist/commands/update-caches.js +41 -12
  112. package/dist/commands/update-caches.js.map +1 -1
  113. package/dist/commands/update-continuity.d.ts +2 -0
  114. package/dist/commands/update-continuity.d.ts.map +1 -1
  115. package/dist/commands/update-continuity.js +27 -4
  116. package/dist/commands/update-continuity.js.map +1 -1
  117. package/dist/commands/update-modes.d.ts +4 -0
  118. package/dist/commands/update-modes.d.ts.map +1 -0
  119. package/dist/commands/update-modes.js +61 -0
  120. package/dist/commands/update-modes.js.map +1 -0
  121. package/dist/commands/update-posix-gate.d.ts +2 -0
  122. package/dist/commands/update-posix-gate.d.ts.map +1 -0
  123. package/dist/commands/update-posix-gate.js +131 -0
  124. package/dist/commands/update-posix-gate.js.map +1 -0
  125. package/dist/commands/update-process.d.ts +17 -3
  126. package/dist/commands/update-process.d.ts.map +1 -1
  127. package/dist/commands/update-process.js +358 -97
  128. package/dist/commands/update-process.js.map +1 -1
  129. package/dist/commands/update-release.d.ts.map +1 -1
  130. package/dist/commands/update-release.js +31 -9
  131. package/dist/commands/update-release.js.map +1 -1
  132. package/dist/commands/update-windows-install.js +23 -5
  133. package/dist/commands/update-windows-install.js.map +1 -1
  134. package/dist/commands/update.d.ts +8 -7
  135. package/dist/commands/update.d.ts.map +1 -1
  136. package/dist/commands/update.js +107 -101
  137. package/dist/commands/update.js.map +1 -1
  138. package/dist/commands/who.d.ts +2 -2
  139. package/dist/commands/who.d.ts.map +1 -1
  140. package/dist/commands/who.js +14 -10
  141. package/dist/commands/who.js.map +1 -1
  142. package/dist/commands/whoami.d.ts.map +1 -1
  143. package/dist/commands/whoami.js +6 -4
  144. package/dist/commands/whoami.js.map +1 -1
  145. package/dist/console/app.d.ts.map +1 -1
  146. package/dist/console/app.js +9 -8
  147. package/dist/console/app.js.map +1 -1
  148. package/dist/console/commands.d.ts.map +1 -1
  149. package/dist/console/commands.js +10 -14
  150. package/dist/console/commands.js.map +1 -1
  151. package/dist/console/ui/Tiles.d.ts +1 -1
  152. package/dist/console/ui/Tiles.d.ts.map +1 -1
  153. package/dist/console/ui/Tiles.js +10 -3
  154. package/dist/console/ui/Tiles.js.map +1 -1
  155. package/dist/console/ui/theme.d.ts.map +1 -1
  156. package/dist/console/ui/theme.js +1 -0
  157. package/dist/console/ui/theme.js.map +1 -1
  158. package/dist/console/ui/topo/Map.js +1 -1
  159. package/dist/console/ui/topo/Map.js.map +1 -1
  160. package/dist/lib/backup-artifact.d.ts +2 -2
  161. package/dist/lib/backup-artifact.d.ts.map +1 -1
  162. package/dist/lib/backup-artifact.js +2 -2
  163. package/dist/lib/backup-artifact.js.map +1 -1
  164. package/dist/lib/broker-service.d.ts +1 -1
  165. package/dist/lib/broker-service.d.ts.map +1 -1
  166. package/dist/lib/broker-service.js +28 -23
  167. package/dist/lib/broker-service.js.map +1 -1
  168. package/dist/lib/broker-store-health.d.ts +4 -0
  169. package/dist/lib/broker-store-health.d.ts.map +1 -1
  170. package/dist/lib/broker-store-health.js +23 -2
  171. package/dist/lib/broker-store-health.js.map +1 -1
  172. package/dist/lib/choose-target.js +1 -1
  173. package/dist/lib/choose-target.js.map +1 -1
  174. package/dist/lib/held-name.d.ts +3 -2
  175. package/dist/lib/held-name.d.ts.map +1 -1
  176. package/dist/lib/held-name.js +10 -6
  177. package/dist/lib/held-name.js.map +1 -1
  178. package/dist/lib/held-seat-records.d.ts +11 -0
  179. package/dist/lib/held-seat-records.d.ts.map +1 -0
  180. package/dist/lib/held-seat-records.js +34 -0
  181. package/dist/lib/held-seat-records.js.map +1 -0
  182. package/dist/lib/install-umask.d.ts +5 -2
  183. package/dist/lib/install-umask.d.ts.map +1 -1
  184. package/dist/lib/install-umask.js +92 -9
  185. package/dist/lib/install-umask.js.map +1 -1
  186. package/dist/lib/manager-choice.d.ts +3 -3
  187. package/dist/lib/manager-choice.d.ts.map +1 -1
  188. package/dist/lib/manager-choice.js +17 -5
  189. package/dist/lib/manager-choice.js.map +1 -1
  190. package/dist/lib/manager-proc.d.ts +2 -1
  191. package/dist/lib/manager-proc.d.ts.map +1 -1
  192. package/dist/lib/manager-proc.js +17 -4
  193. package/dist/lib/manager-proc.js.map +1 -1
  194. package/dist/lib/manifest/spawn-plan.d.ts +1 -1
  195. package/dist/lib/manifest/spawn-plan.d.ts.map +1 -1
  196. package/dist/lib/manifest/spawn-plan.js +2 -2
  197. package/dist/lib/manifest/spawn-plan.js.map +1 -1
  198. package/dist/lib/npm-invocation.d.ts +3 -1
  199. package/dist/lib/npm-invocation.d.ts.map +1 -1
  200. package/dist/lib/npm-invocation.js +59 -3
  201. package/dist/lib/npm-invocation.js.map +1 -1
  202. package/dist/lib/npm-reachability.d.ts +8 -0
  203. package/dist/lib/npm-reachability.d.ts.map +1 -0
  204. package/dist/lib/npm-reachability.js +175 -0
  205. package/dist/lib/npm-reachability.js.map +1 -0
  206. package/dist/lib/restore-streams.d.ts +1 -1
  207. package/dist/lib/restore-streams.js +1 -1
  208. package/dist/lib/restore.d.ts.map +1 -1
  209. package/dist/lib/restore.js +22 -42
  210. package/dist/lib/restore.js.map +1 -1
  211. package/dist/lib/rolled-back-runs.d.ts.map +1 -1
  212. package/dist/lib/rolled-back-runs.js +3 -0
  213. package/dist/lib/rolled-back-runs.js.map +1 -1
  214. package/dist/lib/service-manager-reboot.d.ts +5 -0
  215. package/dist/lib/service-manager-reboot.d.ts.map +1 -0
  216. package/dist/lib/service-manager-reboot.js +39 -0
  217. package/dist/lib/service-manager-reboot.js.map +1 -0
  218. package/dist/lib/service-preset-target.d.ts +1 -1
  219. package/dist/lib/service-preset-target.d.ts.map +1 -1
  220. package/dist/lib/service-preset-target.js +29 -9
  221. package/dist/lib/service-preset-target.js.map +1 -1
  222. package/dist/lib/service-process.d.ts.map +1 -1
  223. package/dist/lib/service-process.js +10 -5
  224. package/dist/lib/service-process.js.map +1 -1
  225. package/dist/lib/spawn-defaults.d.ts.map +1 -1
  226. package/dist/lib/spawn-defaults.js +3 -1
  227. package/dist/lib/spawn-defaults.js.map +1 -1
  228. package/dist/lib/teardown-spare.d.ts +2 -1
  229. package/dist/lib/teardown-spare.d.ts.map +1 -1
  230. package/dist/lib/teardown-spare.js +11 -6
  231. package/dist/lib/teardown-spare.js.map +1 -1
  232. package/dist/lib/transient.d.ts +1 -0
  233. package/dist/lib/transient.d.ts.map +1 -1
  234. package/dist/lib/transient.js +3 -3
  235. package/dist/lib/transient.js.map +1 -1
  236. package/dist/lib/update-connector-config.d.ts +2 -0
  237. package/dist/lib/update-connector-config.d.ts.map +1 -1
  238. package/dist/lib/update-connector-config.js +69 -3
  239. package/dist/lib/update-connector-config.js.map +1 -1
  240. package/dist/lib/update-manager-install-linux.d.ts +6 -7
  241. package/dist/lib/update-manager-install-linux.d.ts.map +1 -1
  242. package/dist/lib/update-manager-install-linux.js +70 -43
  243. package/dist/lib/update-manager-install-linux.js.map +1 -1
  244. package/dist/lib/update-managers.d.ts +2 -0
  245. package/dist/lib/update-managers.d.ts.map +1 -1
  246. package/dist/lib/update-managers.js +14 -3
  247. package/dist/lib/update-managers.js.map +1 -1
  248. package/dist/lib/version.d.ts +9 -0
  249. package/dist/lib/version.d.ts.map +1 -1
  250. package/dist/lib/version.js +12 -4
  251. package/dist/lib/version.js.map +1 -1
  252. package/dist/render.d.ts.map +1 -1
  253. package/dist/render.js +2 -0
  254. package/dist/render.js.map +1 -1
  255. package/dist/seed/reconcile.d.ts.map +1 -1
  256. package/dist/seed/reconcile.js +9 -8
  257. package/dist/seed/reconcile.js.map +1 -1
  258. package/dist/seed/store.d.ts +1 -0
  259. package/dist/seed/store.d.ts.map +1 -1
  260. package/dist/seed/store.js +2 -0
  261. package/dist/seed/store.js.map +1 -1
  262. package/dist/telemetry.d.ts +3 -3
  263. package/dist/telemetry.d.ts.map +1 -1
  264. package/dist/telemetry.js +10 -5
  265. package/dist/telemetry.js.map +1 -1
  266. package/dist/ui.d.ts.map +1 -1
  267. package/dist/ui.js +2 -0
  268. package/dist/ui.js.map +1 -1
  269. package/package.json +5 -5
@@ -1,15 +1,16 @@
1
1
  import { existsSync, mkdtempSync, readFileSync, realpathSync, rmSync } from "node:fs";
2
2
  import { homedir, tmpdir } from "node:os";
3
3
  import { dirname, isAbsolute, join } from "node:path";
4
- import { globalConfigDir } from "@cotal-ai/core";
5
- import { CommandFailure, isCommandFailure, jsonFlag, plainFlag, presentationOf, renderReport, writeResult, claimUpdateClosureAccess, updateClosureOwner, withWindowsUpdateIdentity, homeCotalDir, readUpdateRecovery, clearUpdateRecovery, writeUpdateRecovery, readUpdateSettings, observeUpdateVersion, UPDATE_HOUR_MS, recordOperationContext, recordUpdateCompletion, recordUpdateDeferral, recordUpdateReleaseHold, recordUpdateRefusal, recordUpdateReplacement, setUpdateSetting, bindExtensionPeers, claimGlobalNpmUpdateLock, launcherInstallRoot, logicalExecutionEntry, loadExtensionsManifest, provenance, SEEDED_EXTENSIONS, targetFlags, recoveryDisposition, liveUpdateClosureOwner, recoveryProcessStartToken, observeUnownedRecovery, UnreadableConnectorSelection, } from "@cotal-ai/workspace";
4
+ import {} from "@cotal-ai/core";
5
+ import { CommandFailure, isCommandFailure, jsonFlag, plainFlag, presentationOf, renderReport, writeResult, claimUpdateClosureAccess, updateClosureOwner, withWindowsUpdateIdentity, homeCotalDir, readUpdateRecovery, clearUpdateRecovery, writeUpdateRecovery, readUpdateSettings, observeUpdateVersion, UPDATE_HOUR_MS, recordOperationContext, recordUpdateCompletion, recordUpdateDeferral, recordUpdateReleaseHold, recordUpdateRefusal, recordUpdateReplacement, setUpdateSetting, bindExtensionPeers, claimGlobalNpmUpdateLock, logicalExecutionEntry, loadExtensionsManifest, provenance, SEEDED_EXTENSIONS, targetFlags, recoveryDisposition, liveUpdateClosureOwner, recoveryProcessStartToken, observeUnownedRecovery, UnreadableConnectorSelection, } from "@cotal-ai/workspace";
6
6
  import { resumePublishedUpdate, retainUnusableRecovery } from "../lib/update-recovery-state.js";
7
7
  import { readUpdatePending } from "../lib/update-pending.js";
8
8
  import { snapshotUpdateClosure } from "../lib/update-snapshot.js";
9
- import { assertConfigAncestorProtected, connectorConfigPreflightFailure, manifestAccessReporter, prepareUpdateConnectorConfig, repairCurrentUpdateConnectorSelection, repairUpdateConnectorSelection, restoreUpdateManifestAccess } from "../lib/update-connector-config.js";
9
+ import { assertConfigAncestorProtected, connectorBootstrapPending, connectorConfigPreflightFailure, manifestAccessReporter, prepareUpdateConnectorConfig, repairCurrentUpdateConnectorSelection, repairUpdateConnectorSelection, restoreUpdateManifestAccess } from "../lib/update-connector-config.js";
10
10
  import { reclaimPreviousExtensionStages } from "../lib/extension-stage.js";
11
11
  import { EXT_UPDATE_PARENT_ENV } from "./ext.js";
12
12
  import { collectUpdateCaches } from "./update-caches.js";
13
+ import { repairOwnedModes } from "./update-modes.js";
13
14
  import { repairOfflineExtensions } from "./update-offline.js";
14
15
  import { claimExtensionUpdatePass } from "../lib/ext-mutation.js";
15
16
  import { selfArgv } from "../lib/self-exec.js";
@@ -19,15 +20,15 @@ import { runSeed, compareSemver, seedInstallationCurrent, assertReadableSeedStat
19
20
  import { operatorInstallDiffers, operatorUpdateSpec, reconcilesOperatorExtension } from "../seed/verify.js";
20
21
  import { cliPackageRoot, entryScript, seedWriterKind } from "../seed/paths.js";
21
22
  import { refreshClientInstalls, refreshConnectorInstalls } from "./setup.js";
22
- import { reportCurrentConnectorState } from "./setup-current-connectors.js";
23
+ import { reportWithoutConnectorReconciliation } from "./setup-current-connectors.js";
23
24
  import { c } from "../ui.js";
24
25
  import { refreshOwnedCompletions } from "../lib/completion-install.js";
25
26
  import { onFlag } from "../lib/control.js";
26
27
  import { ownStdoutErrors } from "../lib/stdout-owner.js";
27
- import { STRICT_SEMVER, installedUpdatePrefix, verifyGlobalEntry, runNpmAsync, runNpm, runProcess, runGlobalProcess, latestNotAvailable, failure, message, } from "./update-process.js";
28
+ import { STRICT_SEMVER, installedUpdatePrefix, verifyGlobalEntry, runNpmAsync, runNpm, runProcess, runGlobalProcess, pinPosixGateIfNeeded, withPosixGateScratch, latestNotAvailable, failure, message, } from "./update-process.js";
28
29
  import { latestVersion, latestVersionCheckRemedy, latestVersionCheckWarning, handleLatestVersionFailure, reportConnectorAccessRestored, checkReleaseArchives, ReleaseNotAvailable, ReleaseDateExcluded, DependencyCheckInterrupted, DependencyCheckNoSpace, registryNetworkFailure, deferStagingFailure, offlineUpdateMessage, waitForReleasePreflight, } from "./update-release.js";
29
- import { admitReconciliation, refusal, reportRunningManagers, reportUncheckedPreparedRecords } from "./update-continuity.js";
30
- export { isStoppedLocalMesh, reportRunningManagers, readUpdateManagerContinuity, readManagerContinuity, printLegacyReport } from "./update-continuity.js";
30
+ import { admitReconciliation, refusal, reportRunningManagers } from "./update-continuity.js";
31
+ export { hasUnreadMappedUpdateManager, isStoppedLocalMesh, reportRunningManagers, readUpdateManagerContinuity, readManagerContinuity, printLegacyReport } from "./update-continuity.js";
31
32
  export { parseNpmVersion, installedUpdatePrefix, verifyGlobalEntry } from "./update-process.js";
32
33
  export { localUpdateManagers } from "../lib/update-managers.js";
33
34
  export { managerPin as updateManagerPin } from "../lib/manager-choice.js";
@@ -54,6 +55,7 @@ export const updateRuntime = {
54
55
  parentPid: process.ppid,
55
56
  nodePath: process.execPath,
56
57
  version: cliVersion,
58
+ canDeferConnectorBootstrap: connectorBootstrapPending,
57
59
  isCurrent: () => {
58
60
  if (process.platform !== "linux")
59
61
  return false;
@@ -177,7 +179,7 @@ export async function update(args, rt = updateRuntime) {
177
179
  try {
178
180
  for (const env of environments)
179
181
  Object.assign(env, { TMPDIR: scratch, TMP: scratch, TEMP: scratch });
180
- continuation = await (args.values.self === true ? withWindowsUpdateIdentity(() => updateInstallation(args, rt)) : updateInstallation(args, rt));
182
+ continuation = await withPosixGateScratch(scratch, () => args.values.self === true ? withWindowsUpdateIdentity(() => updateInstallation(args, rt)) : updateInstallation(args, rt));
181
183
  }
182
184
  finally {
183
185
  for (const { env, values } of previous)
@@ -221,7 +223,7 @@ async function updateInstallation(args, rt) {
221
223
  let connectorSelection;
222
224
  let preflightChanged = false;
223
225
  let permissionsRestored = false;
224
- let promotionRecovered = false;
226
+ let promotionRecovered = false, hadUpdateRecovery = false;
225
227
  if (args.values.self === true) {
226
228
  const reportManifestAccess = manifestAccessReporter(line => { preflightChanged = true; rt.out(line); });
227
229
  try {
@@ -263,7 +265,7 @@ async function updateInstallation(args, rt) {
263
265
  }
264
266
  }
265
267
  }
266
- const restored = await recoverInterruptedUpdate(rt, false, targetArgv(args.values));
268
+ const restored = await recoverInterruptedUpdate(rt, false, targetArgv(args.values), () => { hadUpdateRecovery = true; });
267
269
  if (restored && (args.values.self !== true || restored.resumed))
268
270
  return;
269
271
  if (restored && restored.version !== rt.version())
@@ -281,17 +283,11 @@ async function updateInstallation(args, rt) {
281
283
  // Removing group and other write from Cotal's install and config folder changes nothing a running
282
284
  // manager reads, so their modes are repaired before the continuity check rather than only when the
283
285
  // reconcile is allowed to run.
284
- const install = launcherInstallRoot();
285
- for (const { what, root } of args.values.self === true && rt.prepareExecution ? [] : [...(install ? [{ what: "install", root: install }] : []), { what: "config", root: globalConfigDir() }]) {
286
- const repaired = (rt.repairInstallModes ?? repairInstallModes)(root);
287
- if (repaired) {
288
- preflightChanged = true;
289
- rt.out(c.green(`✓ removed group and other write from ${repaired} ${repaired === 1 ? "entry" : "entries"} in Cotal's ${what} at ${root}`));
290
- }
291
- }
286
+ if (!(args.values.self === true && rt.prepareExecution) && repairOwnedModes(rt))
287
+ preflightChanged = true;
292
288
  if (childBinding(rt).kind === "none")
293
289
  reclaimPreviousExtensionStages();
294
- const code = await executeUpdate(Boolean(args.values.self), rt, args.values, restored ? undefined : connectorSelection, preflightChanged, promotionRecovered, permissionsRestored);
290
+ const code = await executeUpdate(Boolean(args.values.self), rt, args.values, restored ? undefined : connectorSelection, preflightChanged, promotionRecovered, permissionsRestored, hadUpdateRecovery);
295
291
  if (code !== 0)
296
292
  process.exitCode = code;
297
293
  else if (args.values.self !== true && childBinding(rt).kind !== "bound") {
@@ -300,12 +296,13 @@ async function updateInstallation(args, rt) {
300
296
  }
301
297
  }
302
298
  /** Resume an abandoned replacement before a command or daemon can activate its closure. */
303
- export async function recoverInterruptedUpdate(rt = updateRuntime, startup = false, flags = []) {
299
+ export async function recoverInterruptedUpdate(rt = updateRuntime, startup = false, flags = [], onRecovery) {
304
300
  if (childBinding(rt).kind === "bound")
305
301
  return;
306
302
  const observed = readUpdateRecovery();
307
303
  if (!observed)
308
304
  return;
305
+ onRecovery?.();
309
306
  if (startup) {
310
307
  // A restarted daemon must answer the updater that still owns the closure. It may only
311
308
  // observe that live transaction here, never compete with it for restoration authority.
@@ -347,84 +344,87 @@ export async function recoverInterruptedUpdate(rt = updateRuntime, startup = fal
347
344
  throw new CommandFailure("refused", decision.action === "active" ? "LIFECYCLE_BLOCKED" : decision.action === "wait" ? "CONFLICT" : "DEPENDENCY_UNAVAILABLE", decision.instruction, { native: { code: decision.action === "active" ? "UPDATE_RECOVERY_OWNER_ACTIVE" : decision.action === "wait" ? "UPDATE_RECOVERY_OBSERVATION_WAIT" : "UPDATE_RECOVERY_INSPECTION_FAILED" }, ...(decision.action === "active" ? {} : { remedy: "follow the recovery instruction above, then run `cotal update --self`" }) });
348
345
  if (!record.owner)
349
346
  return;
350
- try {
351
- if (!record.snapshot)
352
- throw new Error("interrupted update has no closure snapshot");
353
- writeUpdateRecovery({ ...record, owner: updateClosureOwner(), phase: "restoring" });
354
- const snapshot = snapshotUpdateClosure(record.snapshot);
355
- const completedRollback = !record.execution && !startup && record.phase === "paused" && record.installed === record.previous
356
- && record.renames !== undefined && record.renames.length > 0 && record.renames.every(entry => entry.done);
357
- const prefix = rt.installPrefix();
358
- const selected = record.execution && rt.executionGlobalRoot ? { status: 0, stdout: rt.executionGlobalRoot(), stderr: "" } : rt.npm(["root", "-g", ...(prefix ? ["--prefix", prefix] : [])]);
359
- const root = selected.stdout.trim();
360
- if (selected.status !== 0 || !isAbsolute(root) || /[\r\n]/.test(root))
361
- throw new Error("cannot identify interrupted update installation");
362
- const releaseGlobal = rt.claimGlobalUpdate(root);
347
+ return await withPosixGateScratch(undefined, async () => {
363
348
  try {
364
- if (completedRollback) {
365
- const version = rt.version();
366
- const entry = rt.verifyGlobalEntry(root, version);
367
- if (realpathSync(entry) !== realpathSync(entryScript()))
368
- throw new Error("paused repair must run from the verified installed CLI");
349
+ if (!record.snapshot)
350
+ throw new Error("interrupted update has no closure snapshot");
351
+ pinPosixGateIfNeeded(rt.env);
352
+ writeUpdateRecovery({ ...record, owner: updateClosureOwner(), phase: "restoring" });
353
+ const snapshot = snapshotUpdateClosure(record.snapshot);
354
+ const completedRollback = !record.execution && !startup && record.phase === "paused" && record.installed === record.previous
355
+ && record.renames !== undefined && record.renames.length > 0 && record.renames.every(entry => entry.done);
356
+ const prefix = rt.installPrefix();
357
+ const selected = record.execution && rt.executionGlobalRoot ? { status: 0, stdout: rt.executionGlobalRoot(), stderr: "" } : rt.npm(["root", "-g", ...(prefix ? ["--prefix", prefix] : [])]);
358
+ const root = selected.stdout.trim();
359
+ if (selected.status !== 0 || !isAbsolute(root) || /[\r\n]/.test(root))
360
+ throw new Error("cannot identify interrupted update installation");
361
+ const releaseGlobal = rt.claimGlobalUpdate(root);
362
+ try {
363
+ if (completedRollback) {
364
+ const version = rt.version();
365
+ const entry = rt.verifyGlobalEntry(root, version);
366
+ if (realpathSync(entry) !== realpathSync(entryScript()))
367
+ throw new Error("paused repair must run from the verified installed CLI");
368
+ snapshot.restore();
369
+ const env = { ...rt.env, [UPDATE_TARGET_ENV]: version, [UPDATE_PARENT_ENV]: String(rt.pid), ...(!startup && rt.env.COTAL_AUTO_UPDATE !== "1" ? { [UPDATE_PARENT_WAITS_ENV]: "1" } : {}) };
370
+ const reconciled = await rt.spawnGlobal(root, "reconcile", rt.nodePath, [entry, "update"], env, true);
371
+ if (reconciled.status !== 0)
372
+ throw new Error(failure(reconciled));
373
+ if (!startup && rt.env.COTAL_AUTO_UPDATE !== "1") {
374
+ const currentRecovery = readUpdateRecovery();
375
+ if (currentRecovery && currentRecovery.phase !== "verified-ready")
376
+ writeUpdateRecovery({ ...currentRecovery, installed: version, phase: "verified-ready" });
377
+ await rt.waitForInstalledGeneration?.(version);
378
+ }
379
+ snapshot.discard();
380
+ clearUpdateRecovery();
381
+ recordUpdateCompletion(version, `repaired paused installation at ${version}`, true);
382
+ rt.out(`Repaired the paused installation with cotal-ai@${version}; the machine service and its hosted Managers were verified.`);
383
+ return { entry, version };
384
+ }
385
+ let entry;
386
+ let recoveredExecution;
387
+ if (record.execution) {
388
+ if (!rt.recoverExecution)
389
+ throw new Error("this binary cannot recover a staged execution transaction; rerun its installer");
390
+ const execution = recoveredExecution = rt.recoverExecution(record.execution);
391
+ execution.restore();
392
+ execution.verify(record.previous);
393
+ entry = execution.entry;
394
+ }
395
+ else {
396
+ await checkReleaseArchives(record.previous, rt);
397
+ const installed = await rt.spawnGlobal(root, "install", "npm", ["install", "-g", ...(prefix ? ["--prefix", prefix] : []), `cotal-ai@${record.previous}`], rt.env, true);
398
+ if (installed.status !== 0)
399
+ throw new Error(failure(installed));
400
+ entry = rt.verifyGlobalEntry(root, record.previous);
401
+ }
369
402
  snapshot.restore();
370
- const env = { ...rt.env, [UPDATE_TARGET_ENV]: version, [UPDATE_PARENT_ENV]: String(rt.pid), ...(!startup && rt.env.COTAL_AUTO_UPDATE !== "1" ? { [UPDATE_PARENT_WAITS_ENV]: "1" } : {}) };
403
+ const env = { ...rt.env, [UPDATE_TARGET_ENV]: record.previous, [UPDATE_PARENT_ENV]: String(rt.pid), ...(!startup && rt.env.COTAL_AUTO_UPDATE !== "1" ? { [UPDATE_PARENT_WAITS_ENV]: "1" } : {}) };
371
404
  const reconciled = await rt.spawnGlobal(root, "reconcile", rt.nodePath, [entry, "update"], env, true);
372
405
  if (reconciled.status !== 0)
373
406
  throw new Error(failure(reconciled));
374
407
  if (!startup && rt.env.COTAL_AUTO_UPDATE !== "1") {
375
408
  const currentRecovery = readUpdateRecovery();
376
409
  if (currentRecovery && currentRecovery.phase !== "verified-ready")
377
- writeUpdateRecovery({ ...currentRecovery, installed: version, phase: "verified-ready" });
378
- await rt.waitForInstalledGeneration?.(version);
410
+ writeUpdateRecovery({ ...currentRecovery, installed: record.previous, phase: "verified-ready" });
411
+ await rt.waitForInstalledGeneration?.(record.previous);
379
412
  }
380
413
  snapshot.discard();
381
414
  clearUpdateRecovery();
382
- recordUpdateCompletion(version, `repaired paused installation at ${version}`, true);
383
- rt.out(`Repaired the paused installation with cotal-ai@${version}; the machine service and its hosted Managers were verified.`);
384
- return { entry, version };
385
- }
386
- let entry;
387
- let recoveredExecution;
388
- if (record.execution) {
389
- if (!rt.recoverExecution)
390
- throw new Error("this binary cannot recover a staged execution transaction; rerun its installer");
391
- const execution = recoveredExecution = rt.recoverExecution(record.execution);
392
- execution.restore();
393
- execution.verify(record.previous);
394
- entry = execution.entry;
415
+ recoveredExecution?.complete?.();
416
+ rt.out(`Restored cotal-ai@${record.previous} after an interrupted update.`);
417
+ return { entry, version: record.previous };
395
418
  }
396
- else {
397
- await checkReleaseArchives(record.previous, rt);
398
- const installed = await rt.spawnGlobal(root, "install", "npm", ["install", "-g", ...(prefix ? ["--prefix", prefix] : []), `cotal-ai@${record.previous}`], rt.env, true);
399
- if (installed.status !== 0)
400
- throw new Error(failure(installed));
401
- entry = rt.verifyGlobalEntry(root, record.previous);
402
- }
403
- snapshot.restore();
404
- const env = { ...rt.env, [UPDATE_TARGET_ENV]: record.previous, [UPDATE_PARENT_ENV]: String(rt.pid), ...(!startup && rt.env.COTAL_AUTO_UPDATE !== "1" ? { [UPDATE_PARENT_WAITS_ENV]: "1" } : {}) };
405
- const reconciled = await rt.spawnGlobal(root, "reconcile", rt.nodePath, [entry, "update"], env, true);
406
- if (reconciled.status !== 0)
407
- throw new Error(failure(reconciled));
408
- if (!startup && rt.env.COTAL_AUTO_UPDATE !== "1") {
409
- const currentRecovery = readUpdateRecovery();
410
- if (currentRecovery && currentRecovery.phase !== "verified-ready")
411
- writeUpdateRecovery({ ...currentRecovery, installed: record.previous, phase: "verified-ready" });
412
- await rt.waitForInstalledGeneration?.(record.previous);
419
+ finally {
420
+ releaseGlobal();
413
421
  }
414
- snapshot.discard();
415
- clearUpdateRecovery();
416
- recoveredExecution?.complete?.();
417
- rt.out(`Restored cotal-ai@${record.previous} after an interrupted update.`);
418
- return { entry, version: record.previous };
419
422
  }
420
- finally {
421
- releaseGlobal();
423
+ catch (error) {
424
+ writeUpdateRecovery({ ...readUpdateRecovery(), phase: "paused", reason: `interrupted update restore failed: ${message(error)}` });
425
+ throw error;
422
426
  }
423
- }
424
- catch (error) {
425
- writeUpdateRecovery({ ...readUpdateRecovery(), phase: "paused", reason: `interrupted update restore failed: ${message(error)}` });
426
- throw error;
427
- }
427
+ });
428
428
  }
429
429
  finally {
430
430
  release();
@@ -500,7 +500,7 @@ function checkUpdate(args, rt) {
500
500
  ] }));
501
501
  }
502
502
  /** Injectable command body: production keeps one process seam; the smoke covers every decision branch. */
503
- export async function executeUpdate(self, rt = updateRuntime, target = {}, unreadableSelection, preflightChanged = false, promotionRecovered = false, permissionsRestored = false) {
503
+ export async function executeUpdate(self, rt = updateRuntime, target = {}, unreadableSelection, preflightChanged = false, promotionRecovered = false, permissionsRestored = false, hadUpdateRecovery = false) {
504
504
  const current = rt.version();
505
505
  const child = childBinding(rt);
506
506
  if (child.kind === "invalid") {
@@ -568,11 +568,13 @@ export async function executeUpdate(self, rt = updateRuntime, target = {}, unrea
568
568
  }
569
569
  if (upgrading) {
570
570
  reportConnectorAccessRestored(rt, permissionsRestored);
571
- const code = await upgradeAndReconcile(latest.version, current, rt, target, preflightChanged, !permissionsRestored);
571
+ const code = await withPosixGateScratch(undefined, () => upgradeAndReconcile(latest.version, current, rt, target, preflightChanged, !permissionsRestored));
572
572
  if (code === 0 && rt.env.COTAL_AUTO_UPDATE !== "1")
573
573
  rt.generationWaited = true;
574
574
  return code;
575
575
  }
576
+ if (rt.prepareExecution)
577
+ repairOwnedModes(rt);
576
578
  if (unreadableSelection) {
577
579
  const repaired = repairCurrentUpdateConnectorSelection(Boolean(rt.prepareExecution), unreadableSelection, line => rt.err(line), () => { permissionsRestored = true; });
578
580
  reportConnectorAccessRestored(rt, permissionsRestored);
@@ -581,9 +583,7 @@ export async function executeUpdate(self, rt = updateRuntime, target = {}, unrea
581
583
  return 0;
582
584
  }
583
585
  reportConnectorAccessRestored(rt, permissionsRestored);
584
- if (rt.isCurrent?.()) {
585
- reportUncheckedPreparedRecords(rt, target);
586
- await reportCurrentConnectorState(current, rt);
586
+ if (await reportWithoutConnectorReconciliation(current, rt, target, hadUpdateRecovery || promotionRecovered)) {
587
587
  if (rt.env.COTAL_AUTO_UPDATE === "1")
588
588
  recordUpdateCompletion(current, "up to date", true);
589
589
  reportVersion(current, latest.version, rt, false);
@@ -614,12 +614,14 @@ export async function executeUpdate(self, rt = updateRuntime, target = {}, unrea
614
614
  async function reconcileCurrent(current, rt, target, finish, selfUpdate = false) {
615
615
  if (!await admitReconciliation(current, rt, target))
616
616
  return finish(false, true);
617
- rt.out(c.bold("Built-in connectors"));
617
+ rt.out(c.bold("Built-in connectors and extensions"));
618
618
  try {
619
619
  await rt.reconcile(selfUpdate);
620
620
  }
621
621
  catch (e) {
622
- rt.err(c.red(`✗ built-in connectors: ${message(e)}`));
622
+ rt.err(c.red(`✗ connector and extension reconciliation: ${refusal(e)}`));
623
+ if (isCommandFailure(e))
624
+ recordOperationContext({ reportedFailure: { outcome: e.outcome, code: e.code } });
623
625
  return finish(false);
624
626
  }
625
627
  try {
@@ -640,35 +642,38 @@ async function reconcileCurrent(current, rt, target, finish, selfUpdate = false)
640
642
  rt.err(c.red(`✗ could not reserve the extension update pass: ${message(e)}`));
641
643
  return finish(false);
642
644
  }
643
- let code;
645
+ let extensionsCurrent;
644
646
  try {
645
- const ok = await updateOperatorExtensions(rt, current);
646
- if (ok && rt.env.COTAL_AUTO_UPDATE !== "1") {
647
+ extensionsCurrent = await updateOperatorExtensions(rt, current);
648
+ if (extensionsCurrent && rt.env.COTAL_AUTO_UPDATE !== "1") {
647
649
  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");
648
650
  }
649
- code = finish(ok);
650
651
  }
651
652
  finally {
652
653
  releaseMutation();
653
654
  }
654
- return code === 0 ? refreshClients(rt) : code;
655
+ return finish(extensionsCurrent && await refreshClients(rt));
655
656
  }
656
- /** Point the ACP clients' Cotal entries at this Cotal, and return the exit status. A client provider
657
+ /** Point the ACP clients' Cotal entries at this Cotal. A client provider
657
658
  * ships in an operator extension, so this runs once the pass has made them current, and after the
658
659
  * pass is released, because loading a provider takes the extension lock the pass holds. */
659
660
  async function refreshClients(rt) {
661
+ const failures = [];
662
+ const failed = (problem, error) => { failures.push(error); rt.err(c.red(`✗ client integrations: ${problem}`)); };
660
663
  try {
661
- const lines = await rt.refreshClients();
664
+ const lines = await rt.refreshClients(failed);
662
665
  if (lines.length > 0)
663
666
  rt.out(c.bold("Client integrations"));
664
667
  for (const line of lines)
665
668
  rt.out(c.green(`✓ ${line}`));
666
- return 0;
667
669
  }
668
670
  catch (e) {
669
- rt.err(c.red(`✗ client integrations: ${message(e)}`));
670
- return 1;
671
+ failed(message(e), e);
671
672
  }
673
+ const first = failures[0];
674
+ if (isCommandFailure(first) && failures.every(e => isCommandFailure(e) && e.code === first.code && e.outcome === first.outcome))
675
+ recordOperationContext({ reportedFailure: { outcome: first.outcome, code: first.code } });
676
+ return failures.length === 0;
672
677
  }
673
678
  /** Bring every first-party operator extension to `current`, under the update pass the caller holds,
674
679
  * and say whether all of them are. */
@@ -779,6 +784,7 @@ async function upgradeAndReconcile(targetVersion, current, rt, target, preflight
779
784
  let repairedSelection = false, selectionAccessRestored = false;
780
785
  const releaseChecksStarted = Date.now();
781
786
  try {
787
+ pinPosixGateIfNeeded(rt.env);
782
788
  const release = await waitForReleasePreflight(targetVersion, current, rt, () => {
783
789
  try {
784
790
  repairedSelection = repairUpdateConnectorSelection(Boolean(rt.prepareExecution), line => rt.err(line), () => { selectionAccessRestored = true; });
@@ -1034,7 +1040,7 @@ async function upgradeAndReconcile(targetVersion, current, rt, target, preflight
1034
1040
  if (hangup)
1035
1041
  return 129;
1036
1042
  if (installed.stderr)
1037
- rt.stderr(installed.stderr);
1043
+ rt.stderr(installed.scrub?.(installed.stderr) ?? installed.stderr);
1038
1044
  if (installed.status !== 0) {
1039
1045
  rt.err(c.red(`✗ global cotal-ai@${targetVersion} install failed: ${failure(installed)}`));
1040
1046
  return await repairReplacement(`global install failed: ${failure(installed)}`);