maxpool 1.24.49 → 1.24.50

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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/reset-policy.js +11 -23
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "maxpool",
3
- "version": "1.24.49",
3
+ "version": "1.24.50",
4
4
  "description": "Multi-account Claude Code proxy with adaptive, rate-aware load balancing across Claude accounts",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -65,14 +65,10 @@ export function decideZai(account, cards, now = Date.now()) {
65
65
  const wkUtil = wk; const sesUtil = ses;
66
66
 
67
67
  const weeklyCards = (cards.weekly || []).filter(c => !c.expired && c.recordId != null);
68
- const sesCards = (cards.fiveHour || []).filter(c => !c.expired && c.recordId != null);
69
68
  // R4: soonest expiry first inside each class.
70
69
  weeklyCards.sort((a, b) => (a.expiresAt ?? Infinity) - (b.expiresAt ?? Infinity));
71
- sesCards.sort((a, b) => (a.expiresAt ?? Infinity) - (b.expiresAt ?? Infinity));
72
70
 
73
71
  const weeklyCard = weeklyCards[0] || null;
74
- const sesCard = sesCards[0] || null;
75
- let weeklyHeld = false; // R6: weekly card HELD for the free refill (5h branch may still fire)
76
72
 
77
73
  // --- weekly card: clears BOTH windows (z.ai docs; measured: glm1 100%->0% both)
78
74
  if (weeklyCard) {
@@ -83,13 +79,10 @@ export function decideZai(account, cards, now = Date.now()) {
83
79
  if (atWall || dying) {
84
80
  // R6: a wall redeem waits when the FREE weekly refill is imminent and the
85
81
  // account isn't critically full (dying-value redeems stay exempt above).
86
- // A HELD weekly card is spendable-redundant, not absent: the 5h branch below
87
- // may still fire (red-team: holding must not starve a 5h wall — the 5h card
88
- // sits redundant behind the free refill anyway, so spending it is pure gain).
89
82
  if (atWall && !dying && q.providerWkReset != null
90
83
  && msLeft(q.providerWkReset, now) < POLICY.freeRefillWaitMs
91
84
  && wkUtil < POLICY.freeRefillImmediate) {
92
- weeklyHeld = true; // fall through — do NOT return; the 5h branch checks this
85
+ /* HELD for the free refill — do not redeem */
93
86
  } else {
94
87
  return { kind: 'card', card: weeklyCard, resetType: 'WEEK',
95
88
  reason: atWall ? 'weekly at wall' : 'dying value' };
@@ -97,17 +90,10 @@ export function decideZai(account, cards, now = Date.now()) {
97
90
  }
98
91
  }
99
92
 
100
- // --- 5h card: clears only the session window
101
- if (sesCard) {
102
- const atWall = sesUtil != null && sesUtil >= POLICY.wallSes
103
- && (weeklyCard == null || weeklyHeld); // R4: a weekly card can do this job AND more — except when R6 HELD it for the free refill
104
- const dying = msLeft(sesCard.expiresAt, now) < POLICY.dyingWindowMs
105
- && (sesUtil ?? 0) >= POLICY.dyingMinUtilSes;
106
- if (atWall || dying) {
107
- return { kind: 'card', card: sesCard, resetType: 'FIVE_HOUR',
108
- reason: atWall ? 'session at wall' : 'dying value' };
109
- }
110
- }
93
+ // --- 5h card: NEVER SPENT (owner, 2026-10-30: "never spend resets on session
94
+ // limits, only on weekly"). The 5h window refills ~33x per week on its own, so a
95
+ // 5h card buys minutes of capacity at the cost of a scarce card. Historically
96
+ // both the atWall and dying-value branches spent them; both are gone.
111
97
  return null;
112
98
  }
113
99
 
@@ -128,13 +114,15 @@ export function decideClaude(account, listing, now = Date.now()) {
128
114
  const sesUtil = q.unified5h ?? null;
129
115
  const clearsWk = chosen.clears?.includes('seven_day');
130
116
 
131
- let atWall = false;
132
- if (clearsWk) atWall = wkUtil != null && wkUtil >= POLICY.wallWeekly;
133
- else atWall = sesUtil != null && sesUtil >= POLICY.wallSes;
117
+ // Owner, 2026-10-30: "never spend resets on session limits, only on weekly."
118
+ // A grant that clears ONLY the session window is never spent, at wall or dying.
119
+ if (!clearsWk) return null;
120
+
121
+ const atWall = wkUtil != null && wkUtil >= POLICY.wallWeekly;
134
122
 
135
123
  // use_requires_limit: some grants may only fire AT the wall (server-enforced).
136
124
  const dying = msLeft(chosen.endsAt, now) < POLICY.dyingWindowMs
137
- && Math.max(wkUtil ?? 0, sesUtil ?? 0) >= (clearsWk ? POLICY.dyingMinUtilWeekly : POLICY.dyingMinUtilSes);
125
+ && Math.max(wkUtil ?? 0, sesUtil ?? 0) >= POLICY.dyingMinUtilWeekly;
138
126
  // A requires-limit grant cannot be redeemed pre-wall even for dying value.
139
127
  if (atWall || (dying && !chosen.requiresLimit)) {
140
128
  return { kind: 'grant', grant: chosen, reason: atWall ? 'at wall' : 'dying value' };