@askalf/dario 6.12.8 → 6.12.9

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/dist/pool.js +21 -26
  2. package/package.json +3 -3
package/dist/pool.js CHANGED
@@ -840,42 +840,37 @@ function isAboveHeadroomFloor(headroom, floor) {
840
840
  return headroom - floor > Number.EPSILON;
841
841
  }
842
842
  /**
843
- * When a below-floor reading can retire without an upstream probe, return the
844
- * first relevant reset in epoch ms. Null means at least one bucket keeping the
845
- * seat below the floor has no future reset, so one request must refresh it.
843
+ * When a below-floor reading can retire without an upstream probe, return when
844
+ * it does, in epoch ms: the latest future reset among the buckets keeping the
845
+ * seat at or below the floor. Each of those buckets holds the seat there until
846
+ * its own reset, so the seat is parked until the last of them, and a bucket
847
+ * whose reset is unknown does not shorten that. Null only when no limiting
848
+ * bucket has a future reset: then one request must refresh the reading. A seat
849
+ * at 96% of its 5h window and 97% of its 7d window, whose representative claim
850
+ * is the 7d one, carries no 5h reset; it stays parked until the 7d reset
851
+ * rather than taking traffic, and is probed after that if the 5h reading
852
+ * still holds it below the floor.
846
853
  */
847
854
  function floorParkedUntil(snapshot, family, floor, now) {
848
855
  const rl = expireElapsedWindow(snapshot, now);
849
856
  const limiting = (util) => !isAboveHeadroomFloor(1 - util, floor);
857
+ const reset7d = () => ((rl.reset7d ?? 0) * 1000 > now
858
+ ? (rl.reset7d ?? 0) * 1000
859
+ : rl.claim.startsWith('seven_day') ? rl.reset * 1000 : 0);
850
860
  const resets = [];
851
- if (limiting(rl.util5h)) {
852
- const reset = rl.claim === 'five_hour' ? rl.reset * 1000 : 0;
853
- if (reset <= now)
854
- return null;
855
- resets.push(reset);
856
- }
857
- if (limiting(rl.util7d)) {
858
- const reset = (rl.reset7d ?? 0) * 1000 > now
859
- ? (rl.reset7d ?? 0) * 1000
860
- : rl.claim.startsWith('seven_day') ? rl.reset * 1000 : 0;
861
- if (reset <= now)
862
- return null;
863
- resets.push(reset);
864
- }
861
+ if (limiting(rl.util5h))
862
+ resets.push(rl.claim === 'five_hour' ? rl.reset * 1000 : 0);
863
+ if (limiting(rl.util7d))
864
+ resets.push(reset7d());
865
865
  if (family) {
866
866
  for (const bucket of bucketsBindingFamily(rl, family)) {
867
867
  const util = rl.perModel7d[bucket];
868
- if (util === undefined || !limiting(util))
869
- continue;
870
- const reset = (rl.reset7d ?? 0) * 1000 > now
871
- ? (rl.reset7d ?? 0) * 1000
872
- : rl.claim.startsWith('seven_day') ? rl.reset * 1000 : 0;
873
- if (reset <= now)
874
- return null;
875
- resets.push(reset);
868
+ if (util !== undefined && limiting(util))
869
+ resets.push(reset7d());
876
870
  }
877
871
  }
878
- return resets.length > 0 ? Math.min(...resets) : null;
872
+ const known = resets.filter((reset) => reset > now);
873
+ return known.length > 0 ? Math.max(...known) : null;
879
874
  }
880
875
  function pickFloorProbe(accounts, family, floor, now) {
881
876
  const stale = accounts.filter(a => floorParkedUntil(a.rateLimit, family, floor, now) === null);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@askalf/dario",
3
- "version": "6.12.8",
3
+ "version": "6.12.9",
4
4
  "description": "Use your Claude and ChatGPT subscriptions in Cursor, Cline, Aider, Claude Code and the Agent SDK — at subscription pricing, not per-token API bills. One local Anthropic + OpenAI-compatible endpoint: either plan answers either wire shape, with automatic failover when one hits its limit.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -87,8 +87,8 @@
87
87
  "node": ">=18.0.0"
88
88
  },
89
89
  "devDependencies": {
90
- "@types/node": "^26.6.1",
91
- "tsx": "^4.19.0",
90
+ "@types/node": "^26.6.2",
91
+ "tsx": "^4.23.15",
92
92
  "typescript": "^5.7.0"
93
93
  }
94
94
  }