@proagentstore/cli 0.4.102 → 0.4.103
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/index.js +19 -5
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1766,10 +1766,12 @@ var AutomaticUpdateController = class {
|
|
|
1766
1766
|
if (action === "cancel") return this.cancel();
|
|
1767
1767
|
if (action === "start") this.schedule(true);
|
|
1768
1768
|
}
|
|
1769
|
-
/**
|
|
1769
|
+
/**
|
|
1770
|
+
* Testable immediate entry point; production reaches it through the scheduled timer. Authority is
|
|
1771
|
+
* NOT required to get here: a failed refresh clears it, and the retry is what re-establishes it.
|
|
1772
|
+
*/
|
|
1770
1773
|
async runNow() {
|
|
1771
|
-
|
|
1772
|
-
if (this.checking || this.waiting || !current.authoritative || !current.value.autoUpdate) return;
|
|
1774
|
+
if (this.checking || this.waiting || !this.retryable()) return;
|
|
1773
1775
|
this.checking = true;
|
|
1774
1776
|
try {
|
|
1775
1777
|
if (!await this.deps.refreshPolicy() || !this.enabled()) {
|
|
@@ -1787,12 +1789,22 @@ var AutomaticUpdateController = class {
|
|
|
1787
1789
|
async installManually(plan) {
|
|
1788
1790
|
return this.install(plan, false);
|
|
1789
1791
|
}
|
|
1792
|
+
/** May observe work, install or restart: only a freshly confirmed owner ON. */
|
|
1790
1793
|
enabled() {
|
|
1791
1794
|
const { value, authoritative } = this.deps.policy();
|
|
1792
1795
|
return authoritative && value.autoUpdate;
|
|
1793
1796
|
}
|
|
1797
|
+
/**
|
|
1798
|
+
* May keep a timer to re-read the policy: anything but an explicit OFF (#1020). The relay clears
|
|
1799
|
+
* authority before every refresh, so a failed one left `enabled()` false and `schedule` refused —
|
|
1800
|
+
* no timer, until a heartbeat happened to restore authority. The retry only refreshes; every
|
|
1801
|
+
* install still passes `enabled()` and the relay's final admission.
|
|
1802
|
+
*/
|
|
1803
|
+
retryable() {
|
|
1804
|
+
return this.deps.policy().value.autoUpdate;
|
|
1805
|
+
}
|
|
1794
1806
|
schedule(initial = false) {
|
|
1795
|
-
if (!this.
|
|
1807
|
+
if (!this.retryable() || this.timer || this.waiting) return;
|
|
1796
1808
|
const delay = initial ? Math.round(5e3 + (this.deps.random ?? Math.random)() * 25e3) : nextAutoUpdateDelayMs(this.failures, this.deps.random);
|
|
1797
1809
|
this.timer = this.setTimer(() => {
|
|
1798
1810
|
this.timer = null;
|
|
@@ -1813,6 +1825,7 @@ var AutomaticUpdateController = class {
|
|
|
1813
1825
|
* until the next policy transition. `schedule` itself refuses once the policy is disabled.
|
|
1814
1826
|
*/
|
|
1815
1827
|
offline() {
|
|
1828
|
+
if (!this.retryable()) return;
|
|
1816
1829
|
this.failures++;
|
|
1817
1830
|
this.deps.status("offline", { reason: "The owner policy could not be refreshed; automatic update is deferred." });
|
|
1818
1831
|
this.schedule();
|
|
@@ -1826,7 +1839,7 @@ var AutomaticUpdateController = class {
|
|
|
1826
1839
|
const facts = await this.deps.facts();
|
|
1827
1840
|
this.checkAt = this.now();
|
|
1828
1841
|
if (facts.observations?.length) this.observations = [...this.observations, ...facts.observations].slice(-MAX_OBSERVATIONS);
|
|
1829
|
-
if (!this.enabled()) return;
|
|
1842
|
+
if (!this.enabled()) return this.offline();
|
|
1830
1843
|
const plan = this.deps.plan(facts);
|
|
1831
1844
|
this.decisionAt = this.now();
|
|
1832
1845
|
this.blockerClass = plan.action === "wait" ? blockerClassFor(plan.waitingFor) : null;
|
|
@@ -1858,6 +1871,7 @@ var AutomaticUpdateController = class {
|
|
|
1858
1871
|
defer(latest) {
|
|
1859
1872
|
if (this.waiting) return;
|
|
1860
1873
|
this.waiting = true;
|
|
1874
|
+
if (this.timer) this.clearTimer(this.timer);
|
|
1861
1875
|
this.timer = this.setTimer(() => {
|
|
1862
1876
|
this.timer = null;
|
|
1863
1877
|
this.nextRetryDueAt = null;
|