@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.
- package/dist/chat/stdio.d.ts.map +1 -1
- package/dist/chat/stdio.js +3 -2
- package/dist/chat/stdio.js.map +1 -1
- package/dist/command.d.ts.map +1 -1
- package/dist/command.js +15 -5
- package/dist/command.js.map +1 -1
- package/dist/commands/agents.d.ts +8 -1
- package/dist/commands/agents.d.ts.map +1 -1
- package/dist/commands/agents.js +114 -25
- package/dist/commands/agents.js.map +1 -1
- package/dist/commands/chat.d.ts.map +1 -1
- package/dist/commands/chat.js +11 -1
- package/dist/commands/chat.js.map +1 -1
- package/dist/commands/doctor.js +2 -0
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/endpoint-authoring.d.ts.map +1 -1
- package/dist/commands/endpoint-authoring.js +5 -3
- package/dist/commands/endpoint-authoring.js.map +1 -1
- package/dist/commands/ext.d.ts.map +1 -1
- package/dist/commands/ext.js +25 -14
- package/dist/commands/ext.js.map +1 -1
- package/dist/commands/help.d.ts.map +1 -1
- package/dist/commands/help.js +6 -11
- package/dist/commands/help.js.map +1 -1
- package/dist/commands/join.d.ts.map +1 -1
- package/dist/commands/join.js +6 -3
- package/dist/commands/join.js.map +1 -1
- package/dist/commands/models.d.ts.map +1 -1
- package/dist/commands/models.js +6 -4
- package/dist/commands/models.js.map +1 -1
- package/dist/commands/personas.js +2 -2
- package/dist/commands/personas.js.map +1 -1
- package/dist/commands/send.d.ts.map +1 -1
- package/dist/commands/send.js +36 -18
- package/dist/commands/send.js.map +1 -1
- package/dist/commands/service-registry.d.ts.map +1 -1
- package/dist/commands/service-registry.js +2 -1
- package/dist/commands/service-registry.js.map +1 -1
- package/dist/commands/setup-current-connectors.d.ts +3 -6
- package/dist/commands/setup-current-connectors.d.ts.map +1 -1
- package/dist/commands/setup-current-connectors.js +17 -1
- package/dist/commands/setup-current-connectors.js.map +1 -1
- package/dist/commands/setup.d.ts +3 -5
- package/dist/commands/setup.d.ts.map +1 -1
- package/dist/commands/setup.js +28 -23
- package/dist/commands/setup.js.map +1 -1
- package/dist/commands/space-delete.d.ts.map +1 -1
- package/dist/commands/space-delete.js +21 -10
- package/dist/commands/space-delete.js.map +1 -1
- package/dist/commands/spawn-managed-launch.d.ts.map +1 -1
- package/dist/commands/spawn-managed-launch.js +5 -4
- package/dist/commands/spawn-managed-launch.js.map +1 -1
- package/dist/commands/spawn-preview.js +2 -2
- package/dist/commands/spawn-preview.js.map +1 -1
- package/dist/commands/spawn.d.ts.map +1 -1
- package/dist/commands/spawn.js +3 -2
- package/dist/commands/spawn.js.map +1 -1
- package/dist/commands/stack-down.d.ts +1 -1
- package/dist/commands/stack-down.d.ts.map +1 -1
- package/dist/commands/stack-down.js +19 -3
- package/dist/commands/stack-down.js.map +1 -1
- package/dist/commands/stack-lost-records.d.ts +1 -1
- package/dist/commands/stack-lost-records.d.ts.map +1 -1
- package/dist/commands/stack-lost-records.js +7 -5
- package/dist/commands/stack-lost-records.js.map +1 -1
- package/dist/commands/stack-up.js +1 -1
- package/dist/commands/stack-up.js.map +1 -1
- package/dist/commands/status-health.d.ts.map +1 -1
- package/dist/commands/status-health.js +10 -12
- package/dist/commands/status-health.js.map +1 -1
- package/dist/commands/status-model.d.ts +1 -0
- package/dist/commands/status-model.d.ts.map +1 -1
- package/dist/commands/status-render.d.ts.map +1 -1
- package/dist/commands/status-render.js +3 -1
- package/dist/commands/status-render.js.map +1 -1
- package/dist/commands/status.d.ts.map +1 -1
- package/dist/commands/status.js +4 -3
- package/dist/commands/status.js.map +1 -1
- package/dist/commands/sync.d.ts +1 -1
- package/dist/commands/sync.d.ts.map +1 -1
- package/dist/commands/sync.js +29 -8
- package/dist/commands/sync.js.map +1 -1
- package/dist/commands/up-args.d.ts +2 -0
- package/dist/commands/up-args.d.ts.map +1 -1
- package/dist/commands/up-args.js +9 -12
- package/dist/commands/up-args.js.map +1 -1
- package/dist/commands/up-broker-auth.d.ts +3 -1
- package/dist/commands/up-broker-auth.d.ts.map +1 -1
- package/dist/commands/up-broker-auth.js +9 -1
- package/dist/commands/up-broker-auth.js.map +1 -1
- package/dist/commands/up-detach.d.ts +10 -1
- package/dist/commands/up-detach.d.ts.map +1 -1
- package/dist/commands/up-detach.js +28 -13
- package/dist/commands/up-detach.js.map +1 -1
- package/dist/commands/up-foreground-listener.d.ts +1 -1
- package/dist/commands/up-foreground-listener.d.ts.map +1 -1
- package/dist/commands/up-foreground-listener.js +7 -3
- package/dist/commands/up-foreground-listener.js.map +1 -1
- package/dist/commands/up-host.d.ts +8 -0
- package/dist/commands/up-host.d.ts.map +1 -1
- package/dist/commands/up-host.js +27 -1
- package/dist/commands/up-host.js.map +1 -1
- package/dist/commands/up-resume.d.ts.map +1 -1
- package/dist/commands/up-resume.js +4 -2
- package/dist/commands/up-resume.js.map +1 -1
- package/dist/commands/up.d.ts.map +1 -1
- package/dist/commands/up.js +13 -13
- package/dist/commands/up.js.map +1 -1
- package/dist/commands/update-caches.d.ts +1 -0
- package/dist/commands/update-caches.d.ts.map +1 -1
- package/dist/commands/update-caches.js +41 -12
- package/dist/commands/update-caches.js.map +1 -1
- package/dist/commands/update-continuity.d.ts +2 -0
- package/dist/commands/update-continuity.d.ts.map +1 -1
- package/dist/commands/update-continuity.js +27 -4
- package/dist/commands/update-continuity.js.map +1 -1
- package/dist/commands/update-modes.d.ts +4 -0
- package/dist/commands/update-modes.d.ts.map +1 -0
- package/dist/commands/update-modes.js +61 -0
- package/dist/commands/update-modes.js.map +1 -0
- package/dist/commands/update-posix-gate.d.ts +2 -0
- package/dist/commands/update-posix-gate.d.ts.map +1 -0
- package/dist/commands/update-posix-gate.js +131 -0
- package/dist/commands/update-posix-gate.js.map +1 -0
- package/dist/commands/update-process.d.ts +17 -3
- package/dist/commands/update-process.d.ts.map +1 -1
- package/dist/commands/update-process.js +358 -97
- package/dist/commands/update-process.js.map +1 -1
- package/dist/commands/update-release.d.ts.map +1 -1
- package/dist/commands/update-release.js +31 -9
- package/dist/commands/update-release.js.map +1 -1
- package/dist/commands/update-windows-install.js +23 -5
- package/dist/commands/update-windows-install.js.map +1 -1
- package/dist/commands/update.d.ts +8 -7
- package/dist/commands/update.d.ts.map +1 -1
- package/dist/commands/update.js +107 -101
- package/dist/commands/update.js.map +1 -1
- package/dist/commands/who.d.ts +2 -2
- package/dist/commands/who.d.ts.map +1 -1
- package/dist/commands/who.js +14 -10
- package/dist/commands/who.js.map +1 -1
- package/dist/commands/whoami.d.ts.map +1 -1
- package/dist/commands/whoami.js +6 -4
- package/dist/commands/whoami.js.map +1 -1
- package/dist/console/app.d.ts.map +1 -1
- package/dist/console/app.js +9 -8
- package/dist/console/app.js.map +1 -1
- package/dist/console/commands.d.ts.map +1 -1
- package/dist/console/commands.js +10 -14
- package/dist/console/commands.js.map +1 -1
- package/dist/console/ui/Tiles.d.ts +1 -1
- package/dist/console/ui/Tiles.d.ts.map +1 -1
- package/dist/console/ui/Tiles.js +10 -3
- package/dist/console/ui/Tiles.js.map +1 -1
- package/dist/console/ui/theme.d.ts.map +1 -1
- package/dist/console/ui/theme.js +1 -0
- package/dist/console/ui/theme.js.map +1 -1
- package/dist/console/ui/topo/Map.js +1 -1
- package/dist/console/ui/topo/Map.js.map +1 -1
- package/dist/lib/backup-artifact.d.ts +2 -2
- package/dist/lib/backup-artifact.d.ts.map +1 -1
- package/dist/lib/backup-artifact.js +2 -2
- package/dist/lib/backup-artifact.js.map +1 -1
- package/dist/lib/broker-service.d.ts +1 -1
- package/dist/lib/broker-service.d.ts.map +1 -1
- package/dist/lib/broker-service.js +28 -23
- package/dist/lib/broker-service.js.map +1 -1
- package/dist/lib/broker-store-health.d.ts +4 -0
- package/dist/lib/broker-store-health.d.ts.map +1 -1
- package/dist/lib/broker-store-health.js +23 -2
- package/dist/lib/broker-store-health.js.map +1 -1
- package/dist/lib/choose-target.js +1 -1
- package/dist/lib/choose-target.js.map +1 -1
- package/dist/lib/held-name.d.ts +3 -2
- package/dist/lib/held-name.d.ts.map +1 -1
- package/dist/lib/held-name.js +10 -6
- package/dist/lib/held-name.js.map +1 -1
- package/dist/lib/held-seat-records.d.ts +11 -0
- package/dist/lib/held-seat-records.d.ts.map +1 -0
- package/dist/lib/held-seat-records.js +34 -0
- package/dist/lib/held-seat-records.js.map +1 -0
- package/dist/lib/install-umask.d.ts +5 -2
- package/dist/lib/install-umask.d.ts.map +1 -1
- package/dist/lib/install-umask.js +92 -9
- package/dist/lib/install-umask.js.map +1 -1
- package/dist/lib/manager-choice.d.ts +3 -3
- package/dist/lib/manager-choice.d.ts.map +1 -1
- package/dist/lib/manager-choice.js +17 -5
- package/dist/lib/manager-choice.js.map +1 -1
- package/dist/lib/manager-proc.d.ts +2 -1
- package/dist/lib/manager-proc.d.ts.map +1 -1
- package/dist/lib/manager-proc.js +17 -4
- package/dist/lib/manager-proc.js.map +1 -1
- package/dist/lib/manifest/spawn-plan.d.ts +1 -1
- package/dist/lib/manifest/spawn-plan.d.ts.map +1 -1
- package/dist/lib/manifest/spawn-plan.js +2 -2
- package/dist/lib/manifest/spawn-plan.js.map +1 -1
- package/dist/lib/npm-invocation.d.ts +3 -1
- package/dist/lib/npm-invocation.d.ts.map +1 -1
- package/dist/lib/npm-invocation.js +59 -3
- package/dist/lib/npm-invocation.js.map +1 -1
- package/dist/lib/npm-reachability.d.ts +8 -0
- package/dist/lib/npm-reachability.d.ts.map +1 -0
- package/dist/lib/npm-reachability.js +175 -0
- package/dist/lib/npm-reachability.js.map +1 -0
- package/dist/lib/restore-streams.d.ts +1 -1
- package/dist/lib/restore-streams.js +1 -1
- package/dist/lib/restore.d.ts.map +1 -1
- package/dist/lib/restore.js +22 -42
- package/dist/lib/restore.js.map +1 -1
- package/dist/lib/rolled-back-runs.d.ts.map +1 -1
- package/dist/lib/rolled-back-runs.js +3 -0
- package/dist/lib/rolled-back-runs.js.map +1 -1
- package/dist/lib/service-manager-reboot.d.ts +5 -0
- package/dist/lib/service-manager-reboot.d.ts.map +1 -0
- package/dist/lib/service-manager-reboot.js +39 -0
- package/dist/lib/service-manager-reboot.js.map +1 -0
- package/dist/lib/service-preset-target.d.ts +1 -1
- package/dist/lib/service-preset-target.d.ts.map +1 -1
- package/dist/lib/service-preset-target.js +29 -9
- package/dist/lib/service-preset-target.js.map +1 -1
- package/dist/lib/service-process.d.ts.map +1 -1
- package/dist/lib/service-process.js +10 -5
- package/dist/lib/service-process.js.map +1 -1
- package/dist/lib/spawn-defaults.d.ts.map +1 -1
- package/dist/lib/spawn-defaults.js +3 -1
- package/dist/lib/spawn-defaults.js.map +1 -1
- package/dist/lib/teardown-spare.d.ts +2 -1
- package/dist/lib/teardown-spare.d.ts.map +1 -1
- package/dist/lib/teardown-spare.js +11 -6
- package/dist/lib/teardown-spare.js.map +1 -1
- package/dist/lib/transient.d.ts +1 -0
- package/dist/lib/transient.d.ts.map +1 -1
- package/dist/lib/transient.js +3 -3
- package/dist/lib/transient.js.map +1 -1
- package/dist/lib/update-connector-config.d.ts +2 -0
- package/dist/lib/update-connector-config.d.ts.map +1 -1
- package/dist/lib/update-connector-config.js +69 -3
- package/dist/lib/update-connector-config.js.map +1 -1
- package/dist/lib/update-manager-install-linux.d.ts +6 -7
- package/dist/lib/update-manager-install-linux.d.ts.map +1 -1
- package/dist/lib/update-manager-install-linux.js +70 -43
- package/dist/lib/update-manager-install-linux.js.map +1 -1
- package/dist/lib/update-managers.d.ts +2 -0
- package/dist/lib/update-managers.d.ts.map +1 -1
- package/dist/lib/update-managers.js +14 -3
- package/dist/lib/update-managers.js.map +1 -1
- package/dist/lib/version.d.ts +9 -0
- package/dist/lib/version.d.ts.map +1 -1
- package/dist/lib/version.js +12 -4
- package/dist/lib/version.js.map +1 -1
- package/dist/render.d.ts.map +1 -1
- package/dist/render.js +2 -0
- package/dist/render.js.map +1 -1
- package/dist/seed/reconcile.d.ts.map +1 -1
- package/dist/seed/reconcile.js +9 -8
- package/dist/seed/reconcile.js.map +1 -1
- package/dist/seed/store.d.ts +1 -0
- package/dist/seed/store.d.ts.map +1 -1
- package/dist/seed/store.js +2 -0
- package/dist/seed/store.js.map +1 -1
- package/dist/telemetry.d.ts +3 -3
- package/dist/telemetry.d.ts.map +1 -1
- package/dist/telemetry.js +10 -5
- package/dist/telemetry.js.map +1 -1
- package/dist/ui.d.ts.map +1 -1
- package/dist/ui.js +2 -0
- package/dist/ui.js.map +1 -1
- package/package.json +5 -5
package/dist/commands/update.js
CHANGED
|
@@ -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 {
|
|
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,
|
|
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 {
|
|
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
|
|
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
|
-
|
|
285
|
-
|
|
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
|
-
|
|
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 (
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
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]:
|
|
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:
|
|
378
|
-
await rt.waitForInstalledGeneration?.(
|
|
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
|
-
|
|
383
|
-
rt.out(`
|
|
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
|
-
|
|
397
|
-
|
|
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
|
-
|
|
421
|
-
|
|
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
|
|
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(`✗
|
|
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
|
|
645
|
+
let extensionsCurrent;
|
|
644
646
|
try {
|
|
645
|
-
|
|
646
|
-
if (
|
|
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
|
|
655
|
+
return finish(extensionsCurrent && await refreshClients(rt));
|
|
655
656
|
}
|
|
656
|
-
/** Point the ACP clients' Cotal entries at this Cotal
|
|
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
|
-
|
|
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)}`);
|