maxpool 1.24.88 → 1.24.90
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/package.json +1 -1
- package/src/account-manager.js +30 -3
package/package.json
CHANGED
package/src/account-manager.js
CHANGED
|
@@ -1879,6 +1879,27 @@ export class AccountManager {
|
|
|
1879
1879
|
return !sourceDying;
|
|
1880
1880
|
}
|
|
1881
1881
|
|
|
1882
|
+
/** C3: a listing failure holds an active lift LIFT_GRACE_MS from the FIRST failure
|
|
1883
|
+
* of the streak — measured from the last good read, a failure late in the 5-min
|
|
1884
|
+
* cycle left ~3 min of hold (live 2026-11-11). A good listing rewrites capLift,
|
|
1885
|
+
* which ends the streak. */
|
|
1886
|
+
_holdLiftThroughFailure(account, now = Date.now()) {
|
|
1887
|
+
const st = account.capLift;
|
|
1888
|
+
if (!st?.active || st.failingSince != null) return;
|
|
1889
|
+
st.failingSince = now;
|
|
1890
|
+
st.graceUntil = Math.max(st.graceUntil ?? 0, now + LIFT_GRACE_MS);
|
|
1891
|
+
}
|
|
1892
|
+
|
|
1893
|
+
/** A FULL lift (a held reset that refills the whole week) makes the weekly window
|
|
1894
|
+
* not scarce: the pool picks the cheapest account, so pricing a lifted 0.97 on
|
|
1895
|
+
* its weekly usage made it worst-of-pool and starved it (reports, live
|
|
1896
|
+
* 2026-11-12). Weekly pace/utilization/pressure ignore it; the 5h window and the
|
|
1897
|
+
* load terms still apply. A give-back lift refills only what the model used, so
|
|
1898
|
+
* it keeps weekly pricing. */
|
|
1899
|
+
_weeklyRefilledByLift(account, now = Date.now()) {
|
|
1900
|
+
return this.capLiftActive(account, now) && account.capLift?.mode !== 'giveback';
|
|
1901
|
+
}
|
|
1902
|
+
|
|
1882
1903
|
/** True while the account's usage cap is suspended by a held full-refill reset. */
|
|
1883
1904
|
capLiftActive(account, now = Date.now()) {
|
|
1884
1905
|
if (!account || account.enabled === false) return false;
|
|
@@ -3833,7 +3854,8 @@ export class AccountManager {
|
|
|
3833
3854
|
if (q.unified5h != null) {
|
|
3834
3855
|
scarcity = Math.max(scarcity, this._windowScarcity(q.unified5h, q.unified5hReset, FIVE_HOUR_MS, now));
|
|
3835
3856
|
}
|
|
3836
|
-
|
|
3857
|
+
const weeklyFree = this._weeklyRefilledByLift(account, now);
|
|
3858
|
+
if (q.unified7d != null && !weeklyFree) {
|
|
3837
3859
|
scarcity = Math.max(scarcity, this._windowScarcity(q.unified7d, q.unified7dReset, WEEK_MS, now));
|
|
3838
3860
|
}
|
|
3839
3861
|
if (q.tokensLimit != null && q.tokensRemaining != null && q.tokensLimit > 0) {
|
|
@@ -3848,7 +3870,7 @@ export class AccountManager {
|
|
|
3848
3870
|
if (q.providerSes != null) {
|
|
3849
3871
|
scarcity = Math.max(scarcity, this._windowScarcity(q.providerSes, q.providerSesReset, FIVE_HOUR_MS, now));
|
|
3850
3872
|
}
|
|
3851
|
-
if (q.providerWk != null) {
|
|
3873
|
+
if (q.providerWk != null && !weeklyFree) {
|
|
3852
3874
|
scarcity = Math.max(scarcity, this._windowScarcity(q.providerWk, q.providerWkReset, WEEK_MS, now));
|
|
3853
3875
|
}
|
|
3854
3876
|
return scarcity;
|
|
@@ -3884,7 +3906,7 @@ export class AccountManager {
|
|
|
3884
3906
|
// signal (the actual fix) while capacity dying at reset stays free (the
|
|
3885
3907
|
// invariant the older tests pin). Unknown/absent reset → face value, same as
|
|
3886
3908
|
// _accountScarcity. Turn the flag off to restore session-only exactly.
|
|
3887
|
-
if (this.scheduler.weeklyAwareScoring !== false) {
|
|
3909
|
+
if (this.scheduler.weeklyAwareScoring !== false && !this._weeklyRefilledByLift(account, now)) {
|
|
3888
3910
|
if (q.unified7d != null) {
|
|
3889
3911
|
util = Math.max(util, this._windowScarcity(q.unified7d, q.unified7dReset, WEEK_MS, now));
|
|
3890
3912
|
}
|
|
@@ -4089,6 +4111,7 @@ export class AccountManager {
|
|
|
4089
4111
|
_weeklyState(account) {
|
|
4090
4112
|
const rawState = this._weeklyRawState(account);
|
|
4091
4113
|
if (rawState === 'unknown' || rawState === 'exhausted' || rawState === 'capped') return rawState;
|
|
4114
|
+
if (this._weeklyRefilledByLift(account)) return rawState;
|
|
4092
4115
|
|
|
4093
4116
|
const pressure = Math.max(clamp01(account.quota.unified7d ?? 0), this._effectiveWeeklyUsage(account));
|
|
4094
4117
|
if (pressure >= this.scheduler.weeklyCriticalThreshold) return 'critical';
|
|
@@ -4198,6 +4221,7 @@ export class AccountManager {
|
|
|
4198
4221
|
// Provider quota lives in separate fields — see _weeklyRawState.
|
|
4199
4222
|
if (account.type === 'provider') return this._weeklyRawState(account, now);
|
|
4200
4223
|
if (account.quota.unified7d == null) return 'unknown';
|
|
4224
|
+
if (this._weeklyRefilledByLift(account, now)) return this._weeklyRawState(account, now);
|
|
4201
4225
|
const effective = this._effectiveWeeklyUsage(account);
|
|
4202
4226
|
if (effective >= this.scheduler.weeklyExhaustedThreshold) return 'exhausted';
|
|
4203
4227
|
if (effective >= this.scheduler.weeklyCriticalThreshold) return 'critical';
|
|
@@ -4420,6 +4444,7 @@ export class AccountManager {
|
|
|
4420
4444
|
if (account.resetGrants) {
|
|
4421
4445
|
account.resetGrants = { ...account.resetGrants, stale: true, lastError: String(listing.error), lastErrorAt: now };
|
|
4422
4446
|
}
|
|
4447
|
+
this._holdLiftThroughFailure(account, now);
|
|
4423
4448
|
return;
|
|
4424
4449
|
}
|
|
4425
4450
|
account.resetGrants = {
|
|
@@ -4478,6 +4503,7 @@ export class AccountManager {
|
|
|
4478
4503
|
if (account.resetCards) {
|
|
4479
4504
|
account.resetCards = { ...account.resetCards, stale: true, lastError: String(cards.error), lastErrorAt: Date.now() };
|
|
4480
4505
|
}
|
|
4506
|
+
this._holdLiftThroughFailure(account);
|
|
4481
4507
|
return;
|
|
4482
4508
|
}
|
|
4483
4509
|
// DRIFT = a 200 the parser can't have meant (pre-mortem #17): expected arrays
|
|
@@ -4490,6 +4516,7 @@ export class AccountManager {
|
|
|
4490
4516
|
if (account.resetCards) {
|
|
4491
4517
|
account.resetCards = { ...account.resetCards, stale: true, lastError: 'listing drift (unexpected payload shape)', lastErrorAt: Date.now() };
|
|
4492
4518
|
}
|
|
4519
|
+
this._holdLiftThroughFailure(account);
|
|
4493
4520
|
return;
|
|
4494
4521
|
}
|
|
4495
4522
|
account.resetCards = {
|