@cotal-ai/cli 0.171.4 → 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.
- package/dist/command.d.ts.map +1 -1
- package/dist/command.js +10 -4
- package/dist/command.js.map +1 -1
- package/dist/commands/ext.d.ts.map +1 -1
- package/dist/commands/ext.js +35 -7
- package/dist/commands/ext.js.map +1 -1
- package/dist/commands/service-actions.d.ts.map +1 -1
- package/dist/commands/service-actions.js +22 -12
- package/dist/commands/service-actions.js.map +1 -1
- package/dist/commands/space.d.ts.map +1 -1
- package/dist/commands/space.js +8 -6
- package/dist/commands/space.js.map +1 -1
- package/dist/commands/spawn.js +1 -1
- package/dist/commands/spawn.js.map +1 -1
- package/dist/commands/status.d.ts.map +1 -1
- package/dist/commands/status.js +9 -9
- package/dist/commands/status.js.map +1 -1
- package/dist/commands/update.d.ts +1 -0
- package/dist/commands/update.d.ts.map +1 -1
- package/dist/commands/update.js +122 -21
- package/dist/commands/update.js.map +1 -1
- package/dist/commands/whoami.d.ts.map +1 -1
- package/dist/commands/whoami.js +2 -1
- package/dist/commands/whoami.js.map +1 -1
- package/dist/lib/extension-stage.d.ts +1 -1
- package/dist/lib/extension-stage.d.ts.map +1 -1
- package/dist/lib/extension-stage.js +26 -11
- package/dist/lib/extension-stage.js.map +1 -1
- package/dist/lib/self-exec.d.ts +2 -0
- package/dist/lib/self-exec.d.ts.map +1 -1
- package/dist/lib/self-exec.js +5 -1
- package/dist/lib/self-exec.js.map +1 -1
- package/dist/lib/service-preset-target.d.ts +2 -1
- package/dist/lib/service-preset-target.d.ts.map +1 -1
- package/dist/lib/service-preset-target.js +11 -2
- package/dist/lib/service-preset-target.js.map +1 -1
- package/dist/seed/reconcile.d.ts +2 -0
- package/dist/seed/reconcile.d.ts.map +1 -1
- package/dist/seed/reconcile.js +30 -11
- package/dist/seed/reconcile.js.map +1 -1
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../src/commands/update.ts"],"names":[],"mappings":"AAMA,OAAO,EAAmB,KAAK,QAAQ,EAAE,KAAK,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjF,OAAO,
|
|
1
|
+
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../src/commands/update.ts"],"names":[],"mappings":"AAMA,OAAO,EAAmB,KAAK,QAAQ,EAAE,KAAK,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjF,OAAO,EAmCL,KAAK,kBAAkB,EAOxB,MAAM,qBAAqB,CAAC;AAQ7B,OAAO,EAAE,kBAAkB,EAAoB,MAAM,yBAAyB,CAAC;AAC/E,OAAO,EAAc,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAUpE,OAAO,EAUL,KAAK,UAAU,EAEhB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAwC,KAAK,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AACjH,OAAO,EAAuB,KAAK,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAIhG,OAAO,EAA+C,KAAK,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC5G,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,UAAU,IAAI,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAK1E;;2DAE2D;AAC3D,eAAO,MAAM,uBAAuB,8BAA8B,CAAC;AAEnE,eAAO,MAAM,WAAW,EAAE,SAAS,QAAQ,EAS1C,CAAC;AAEF,UAAU,aAAa;IACrB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC;IACxC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAA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AM,GAAG,MAAM,GAAG,SAAS,CAa5F;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,MAAM,CAgB/E"}
|
package/dist/commands/update.js
CHANGED
|
@@ -5,16 +5,17 @@ import { homedir, tmpdir } from "node:os";
|
|
|
5
5
|
import { isIP, SocketAddress } from "node:net";
|
|
6
6
|
import { basename, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
7
7
|
import { globalConfigDir } from "@cotal-ai/core";
|
|
8
|
-
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";
|
|
9
9
|
import { retainUnusableRecovery } from "../lib/update-recovery-state.js";
|
|
10
10
|
import { readUpdatePending } from "../lib/update-pending.js";
|
|
11
11
|
import { snapshotUpdateClosure } from "../lib/update-snapshot.js";
|
|
12
12
|
import { EXT_UPDATE_PARENT_ENV } from "./ext.js";
|
|
13
13
|
import { claimExtensionUpdatePass } from "../lib/ext-mutation.js";
|
|
14
|
+
import { recoverExtensionPromotion } from "../lib/extension-stage.js";
|
|
14
15
|
import { selfArgv } from "../lib/self-exec.js";
|
|
15
16
|
import { repairInstallModes, withInstallUmask } from "../lib/install-umask.js";
|
|
16
17
|
import { cliVersion, installedCliVersion } from "../lib/version.js";
|
|
17
|
-
import { runSeed, compareSemver, seedInstallationCurrent, assertReadableSeedState } from "../seed/reconcile.js";
|
|
18
|
+
import { runSeed, compareSemver, seedInstallationCurrent, assertReadableSeedState, readSeedRepairRefusal } from "../seed/reconcile.js";
|
|
18
19
|
import { operatorInstallDiffers } from "../seed/verify.js";
|
|
19
20
|
import { cliPackageRoot, entryScript, seedWriterKind } from "../seed/paths.js";
|
|
20
21
|
import { refreshConnectorInstalls } from "./setup.js";
|
|
@@ -50,6 +51,7 @@ export const updateFlags = [
|
|
|
50
51
|
...targetFlags,
|
|
51
52
|
onFlag,
|
|
52
53
|
];
|
|
54
|
+
const MISSING_NPM_REMEDY = "Install npm or add it to this command's PATH, then retry.";
|
|
53
55
|
export { installedCliVersion, repairInstallModes };
|
|
54
56
|
export const updateRuntime = {
|
|
55
57
|
env: process.env,
|
|
@@ -226,6 +228,31 @@ async function updateInstallation(args, rt) {
|
|
|
226
228
|
native: { outcome: "not-executed" },
|
|
227
229
|
});
|
|
228
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
|
+
}
|
|
229
256
|
}
|
|
230
257
|
const restored = await recoverInterruptedUpdate(rt);
|
|
231
258
|
if (restored) {
|
|
@@ -428,18 +455,36 @@ function checkUpdate(args, rt) {
|
|
|
428
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." });
|
|
429
456
|
}
|
|
430
457
|
const latest = latestVersion(rt);
|
|
458
|
+
const missingNpm = !latest.ok && latest.missingNpm;
|
|
431
459
|
if (!latest.ok)
|
|
432
|
-
warnings.push(
|
|
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." });
|
|
433
463
|
const comparison = latest.ok ? compareSemver(latest.version, current) : null;
|
|
434
|
-
|
|
435
|
-
if (
|
|
436
|
-
|
|
437
|
-
|
|
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 };
|
|
438
480
|
writeResult(presentationOf(args.values), {
|
|
439
481
|
command: "update", target: null, result, warnings,
|
|
440
|
-
...(warnings.length ? { completeness: "partial", partial: {
|
|
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
|
+
} } : {}),
|
|
441
486
|
}, (r) => ({ sections: [
|
|
442
|
-
...(
|
|
487
|
+
...(r.reconciliation.kind === "none" ? [] : [{ title: "Reconciliation", blocks: [{ kind: "lines", lines: [r.reconciliation.instruction] }] }]),
|
|
443
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"]] }] },
|
|
444
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" }] }] },
|
|
445
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" }] }] },
|
|
@@ -448,14 +493,14 @@ function checkUpdate(args, rt) {
|
|
|
448
493
|
/** Injectable command body: production keeps one process seam; the smoke covers every decision branch. */
|
|
449
494
|
export async function executeUpdate(self, rt = updateRuntime, target = {}) {
|
|
450
495
|
const current = rt.version();
|
|
451
|
-
if (self && rt.env.COTAL_AUTO_UPDATE === "1")
|
|
452
|
-
recordUpdateDeferral(current, "waiting for update preflight");
|
|
453
496
|
const child = childBinding(rt);
|
|
454
497
|
if (child.kind === "invalid") {
|
|
455
498
|
rt.err(c.red(`✗ invalid global update child binding: ${child.reason}; refusing to mutate extensions`));
|
|
456
499
|
return 1;
|
|
457
500
|
}
|
|
458
501
|
if (child.kind === "bound") {
|
|
502
|
+
if (self && rt.env.COTAL_AUTO_UPDATE === "1")
|
|
503
|
+
recordUpdateDeferral(current, "waiting for update preflight");
|
|
459
504
|
if (current !== child.target) {
|
|
460
505
|
rt.err(c.red(`✗ global update child is cotal-ai ${current}, expected ${child.target}; refusing to mutate extensions`));
|
|
461
506
|
return 1;
|
|
@@ -496,6 +541,12 @@ export async function executeUpdate(self, rt = updateRuntime, target = {}) {
|
|
|
496
541
|
if (self) {
|
|
497
542
|
const latest = latestVersion(rt);
|
|
498
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
|
+
}
|
|
499
550
|
if (rt.env.COTAL_AUTO_UPDATE === "1")
|
|
500
551
|
recordUpdateDeferral(current, "waiting for registry availability", true);
|
|
501
552
|
else if (latest.npmResult && await npmProxyRefused(latest.npmResult, rt.env)) {
|
|
@@ -505,13 +556,24 @@ export async function executeUpdate(self, rt = updateRuntime, target = {}) {
|
|
|
505
556
|
rt.out("The registry cannot be reached; nothing was changed.");
|
|
506
557
|
return 0;
|
|
507
558
|
}
|
|
508
|
-
|
|
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) {
|
|
509
570
|
const code = await upgradeAndReconcile(latest.version, current, rt, target);
|
|
510
571
|
if (code === 0 && rt.env.COTAL_AUTO_UPDATE !== "1")
|
|
511
572
|
rt.generationWaited = true;
|
|
512
573
|
return code;
|
|
513
574
|
}
|
|
514
575
|
if (rt.isCurrent?.()) {
|
|
576
|
+
reportUncheckedPreparedRecords(rt, target);
|
|
515
577
|
rt.out("No newer CLI version; installed package closure is current. No connector reconciliation was run.");
|
|
516
578
|
if (rt.env.COTAL_AUTO_UPDATE === "1")
|
|
517
579
|
recordUpdateCompletion(current, "up to date", true);
|
|
@@ -544,6 +606,25 @@ export async function executeUpdate(self, rt = updateRuntime, target = {}) {
|
|
|
544
606
|
return reconciled ? 0 : 1;
|
|
545
607
|
});
|
|
546
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
|
+
}
|
|
547
628
|
async function reconcileCurrent(current, rt, target, finish) {
|
|
548
629
|
try {
|
|
549
630
|
await rt.prepareReconciliation?.(target);
|
|
@@ -571,6 +652,7 @@ async function reconcileCurrent(current, rt, target, finish) {
|
|
|
571
652
|
rt.err(c.red(`✗ running manager continuity check: ${refusal(e)}`));
|
|
572
653
|
return finish(false, true);
|
|
573
654
|
}
|
|
655
|
+
reportUncheckedPreparedRecords(rt, target);
|
|
574
656
|
try {
|
|
575
657
|
await rt.preflightReplacement?.();
|
|
576
658
|
}
|
|
@@ -900,6 +982,16 @@ export async function readManagerContinuity(flags, options = {}) {
|
|
|
900
982
|
peek = resolveMeshTarget(process.cwd(), { server, space, offline });
|
|
901
983
|
}
|
|
902
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
|
+
}
|
|
903
995
|
if (!isWorkspaceTargetError(e))
|
|
904
996
|
throw e;
|
|
905
997
|
// Sudo can inspect another account's project without owning its controller records.
|
|
@@ -1068,6 +1160,8 @@ function latestVersion(rt) {
|
|
|
1068
1160
|
const cache = mkdtempSync(join(tmpdir(), "cotal-npm-view-"));
|
|
1069
1161
|
try {
|
|
1070
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 };
|
|
1071
1165
|
if (result.status !== 0)
|
|
1072
1166
|
return { ok: false, error: failure(result), npmResult: result };
|
|
1073
1167
|
try {
|
|
@@ -1125,12 +1219,17 @@ async function npmProxyRefused(result, env) {
|
|
|
1125
1219
|
}
|
|
1126
1220
|
}
|
|
1127
1221
|
/** Resolve installed first-party surfaces in a disposable prefix, including their npm dependencies. */
|
|
1128
|
-
function checkInstalledClosure(version, rt) {
|
|
1222
|
+
function checkInstalledClosure(version, releasePackages, rt) {
|
|
1129
1223
|
const names = [...new Set(rt.extensions().filter(entry => entry.pkg.startsWith("@cotal-ai/")).map(entry => entry.pkg))];
|
|
1130
1224
|
if (!names.length)
|
|
1131
1225
|
return;
|
|
1132
1226
|
const staging = mkdtempSync(join(tmpdir(), "cotal-closure-check-"));
|
|
1133
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
|
+
}));
|
|
1134
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}`)]);
|
|
1135
1234
|
if (result.signal)
|
|
1136
1235
|
throw new DependencyCheckInterrupted(`npm dependency check was terminated by ${result.signal}`);
|
|
@@ -1217,6 +1316,7 @@ async function checkReleaseArchives(version, rt) {
|
|
|
1217
1316
|
if (archive.status !== 0)
|
|
1218
1317
|
throw releaseReadError(archive, `archives for ${specs.join(", ")} could not be downloaded and verified`);
|
|
1219
1318
|
}
|
|
1319
|
+
return pending;
|
|
1220
1320
|
}
|
|
1221
1321
|
finally {
|
|
1222
1322
|
rmSync(cache, { recursive: true, force: true, maxRetries: 3 });
|
|
@@ -1339,8 +1439,7 @@ async function waitForReleaseArchives(version, current, rt) {
|
|
|
1339
1439
|
const deadline = now() + 10 * 60_000;
|
|
1340
1440
|
for (;;) {
|
|
1341
1441
|
try {
|
|
1342
|
-
await checkReleaseArchives(version, rt);
|
|
1343
|
-
return true;
|
|
1442
|
+
return await checkReleaseArchives(version, rt);
|
|
1344
1443
|
}
|
|
1345
1444
|
catch (error) {
|
|
1346
1445
|
if (!(error instanceof ReleaseNotAvailable))
|
|
@@ -1349,7 +1448,7 @@ async function waitForReleaseArchives(version, current, rt) {
|
|
|
1349
1448
|
if (remaining <= 0) {
|
|
1350
1449
|
recordUpdateDeferral(version, "waiting for registry or extension closure availability", true);
|
|
1351
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.`);
|
|
1352
|
-
return
|
|
1451
|
+
return undefined;
|
|
1353
1452
|
}
|
|
1354
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.`);
|
|
1355
1454
|
await (rt.sleep ?? (milliseconds => new Promise(resolveSleep => setTimeout(resolveSleep, milliseconds))))(Math.min(15_000, remaining));
|
|
@@ -1405,10 +1504,11 @@ async function upgradeAndReconcile(targetVersion, current, rt, target) {
|
|
|
1405
1504
|
const releaseChecksStarted = Date.now();
|
|
1406
1505
|
try {
|
|
1407
1506
|
rt.out(`Checking cotal-ai@${targetVersion} release archives`);
|
|
1408
|
-
|
|
1507
|
+
const releasePackages = await waitForReleaseArchives(targetVersion, current, rt);
|
|
1508
|
+
if (!releasePackages)
|
|
1409
1509
|
return 0;
|
|
1410
1510
|
rt.out(`Checking installed extension dependencies for ${targetVersion}`);
|
|
1411
|
-
checkInstalledClosure(targetVersion, rt);
|
|
1511
|
+
checkInstalledClosure(targetVersion, releasePackages, rt);
|
|
1412
1512
|
// In-place rollback downloads the previous release. Staged rollback retains its complete graph.
|
|
1413
1513
|
if (!rt.prepareExecution) {
|
|
1414
1514
|
rt.out(`Checking cotal-ai@${current} recovery archives`);
|
|
@@ -1916,10 +2016,11 @@ function runNpm(args, inherit = false) {
|
|
|
1916
2016
|
stdout: `${result.stdout ?? ""}`,
|
|
1917
2017
|
stderr: `${result.stderr ?? ""}`,
|
|
1918
2018
|
error: result.error?.message,
|
|
2019
|
+
errorCode: result.error?.code,
|
|
1919
2020
|
};
|
|
1920
2021
|
}
|
|
1921
2022
|
catch (e) {
|
|
1922
|
-
return { status: null, stdout: "", stderr: "", error: message(e) };
|
|
2023
|
+
return { status: null, stdout: "", stderr: "", error: message(e), errorCode: e?.code };
|
|
1923
2024
|
}
|
|
1924
2025
|
}
|
|
1925
2026
|
function runProcess(file, args, env, inherit = false) {
|
|
@@ -1975,7 +2076,7 @@ async function runGlobalProcess(root, operation, file, args, env, inherit = fals
|
|
|
1975
2076
|
mutation.complete(closed.status, closed.signal, closed.signal !== null
|
|
1976
2077
|
? `${operation} child terminated by ${closed.signal}`
|
|
1977
2078
|
: `Windows npm intermediary exited ${closed.status}; descendant completion is unproved`);
|
|
1978
|
-
return { status: error ? null : closed.status, stdout, stderr, ...(error ? { error } : {}) };
|
|
2079
|
+
return { status: error ? null : closed.status, signal: closed.signal, stdout, stderr, ...(error ? { error } : {}) };
|
|
1979
2080
|
}
|
|
1980
2081
|
catch (e) {
|
|
1981
2082
|
return { status: null, stdout: "", stderr: "", error: message(e) };
|
|
@@ -2000,7 +2101,7 @@ function latestNotAvailable(result, version) {
|
|
|
2000
2101
|
}
|
|
2001
2102
|
}
|
|
2002
2103
|
function failure(result) {
|
|
2003
|
-
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}`;
|
|
2004
2105
|
}
|
|
2005
2106
|
function message(value) {
|
|
2006
2107
|
return value instanceof Error ? value.message : String(value);
|