maxpool 1.24.34 → 1.24.36
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/outside-usage.js +8 -2
- package/src/prober.js +1 -1
- package/src/server.js +24 -27
package/package.json
CHANGED
package/src/outside-usage.js
CHANGED
|
@@ -73,10 +73,16 @@ export function zaiHourlyCalls(data) {
|
|
|
73
73
|
* [max(poolUpSince ceiled to the next hour, now - window), floor(now)).
|
|
74
74
|
* Returns {hours, zaiCalls, poolCalls, outside, from, to}; hours=0 when no
|
|
75
75
|
* complete hour is comparable yet (then outside is always false). */
|
|
76
|
-
export function compareOutsideUsage(zaiHours, poolHours, { now, poolUpSince, factor = OUTSIDE_FACTOR, minCalls = OUTSIDE_MIN_CALLS, windowHours = OUTSIDE_WINDOW_HOURS } = {}) {
|
|
76
|
+
export function compareOutsideUsage(zaiHours, poolHours, { now, poolUpSince, sinceMs = null, factor = OUTSIDE_FACTOR, minCalls = OUTSIDE_MIN_CALLS, windowHours = OUTSIDE_WINDOW_HOURS } = {}) {
|
|
77
77
|
const to = hourFloor(now);
|
|
78
78
|
const upFrom = Math.ceil(poolUpSince / HOUR) * HOUR; // first hour the pool saw in full
|
|
79
|
-
|
|
79
|
+
// A JUST-ADDED account (addedAt) may share its key with its previous owner —
|
|
80
|
+
// hours BEFORE the pool adopted it are that owner's usage, not a leak. Baseline
|
|
81
|
+
// the comparison at the later of pool-up and account-added (owner-shared keys,
|
|
82
|
+
// 2026-10-28: 3 accounts added at 10:04Z flagged "outside ×490" off Andrey's own
|
|
83
|
+
// overnight pool traffic).
|
|
84
|
+
const sinceFrom = sinceMs != null ? Math.ceil(sinceMs / HOUR) * HOUR : 0;
|
|
85
|
+
const from = Math.max(upFrom, sinceFrom, to - windowHours * HOUR);
|
|
80
86
|
let zaiCalls = 0, poolCalls = 0, hours = 0;
|
|
81
87
|
for (let h = from; h < to; h += HOUR) {
|
|
82
88
|
hours++;
|
package/src/prober.js
CHANGED
|
@@ -240,7 +240,7 @@ export class Prober {
|
|
|
240
240
|
}
|
|
241
241
|
account._outsideCheckedAt = now; // stamp AFTER success (R1.5)
|
|
242
242
|
const zai = zaiHourlyCalls(data);
|
|
243
|
-
const res = compareOutsideUsage(zai, account.poolHourly, { now, poolUpSince: this.am.poolUpSince });
|
|
243
|
+
const res = compareOutsideUsage(zai, account.poolHourly, { now, poolUpSince: this.am.poolUpSince, sinceMs: account.addedAt ?? null });
|
|
244
244
|
const prev = account.outsideUsage;
|
|
245
245
|
const wasOutside = Boolean(prev?.outside);
|
|
246
246
|
account.outsideUsage = { ...res, checkedAt: now };
|
package/src/server.js
CHANGED
|
@@ -1935,7 +1935,7 @@ function isContextLengthError(errorBody) {
|
|
|
1935
1935
|
return /exceeded model token limit|maximum context length|context length exceeded|context window (?:size )?(?:exceeded|too)|prompt is too long|input is too long|reduce the length of|too many (?:input )?tokens|request too large/i.test(errorBody);
|
|
1936
1936
|
}
|
|
1937
1937
|
|
|
1938
|
-
export const __serverTest = { directiveOnlySystemMessages, rewriteBodyForAccount, sanitizeBlocksForProvider, reanchorOrphanedSystemMessages, unavailableMessage, computeQueueWindowMs, isRetriableUpstreamStatus, classifyEffortRejection, repairEffort, isCapacitySignalStatus, isStrippableThinkingBlock, stripForeignThinkingBlocks, parseRejectedBlockPath, stripRejectedBlockClass, peekRejectedBlockType, describeRejectedBlock, headerValue, getMaxpoolProfile, ensureQueueHeartbeat, clearQueueHeartbeat, commitStreamGraceHeartbeat, describeRequest, classifyRateLimit, detectTranscriptOrigin, isAnthropicIncompatBody, isContextLengthError, isProviderParamRejection, describeBodyShape, streamResponse, startIdleRequestReaper, normalizeModelEcho, classifyHeldStreamPrefix };
|
|
1938
|
+
export const __serverTest = { directiveOnlySystemMessages, rewriteBodyForAccount, sanitizeBlocksForProvider, reanchorOrphanedSystemMessages, unavailableMessage, computeQueueWindowMs, waitForAvailableRoute, isRetriableUpstreamStatus, classifyEffortRejection, repairEffort, isCapacitySignalStatus, isStrippableThinkingBlock, stripForeignThinkingBlocks, parseRejectedBlockPath, stripRejectedBlockClass, peekRejectedBlockType, describeRejectedBlock, headerValue, getMaxpoolProfile, ensureQueueHeartbeat, clearQueueHeartbeat, commitStreamGraceHeartbeat, describeRequest, classifyRateLimit, detectTranscriptOrigin, isAnthropicIncompatBody, isContextLengthError, isProviderParamRejection, describeBodyShape, streamResponse, startIdleRequestReaper, normalizeModelEcho, classifyHeldStreamPrefix };
|
|
1939
1939
|
|
|
1940
1940
|
async function readErrorBody(upstreamRes, limitBytes = 64 * 1024) {
|
|
1941
1941
|
if (!upstreamRes.body) return '';
|
|
@@ -2715,30 +2715,23 @@ async function queueAndRetry(
|
|
|
2715
2715
|
// terminal (disabled / error / auth-dead)". This is what stops an indefinite
|
|
2716
2716
|
// hold from silently hanging every session when something is actually broken
|
|
2717
2717
|
// (all accounts logged out, the only healthy account removed, etc.).
|
|
2718
|
-
const retryAfterMs = retryPlan.retryAfterMs;
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
// quota rollover, which wrongly lost the chain (red-team 2026-10-12, finding 3).
|
|
2736
|
-
if (requestInfo.stream && queueWindowMs > 0 && Number.isFinite(retryAfterMs)
|
|
2737
|
-
&& !CAPACITY_CLASS_RETRY_CAUSES.has(retryPlan.cause)) {
|
|
2738
|
-
requestInfo.queueHoldChain = true;
|
|
2739
|
-
} else {
|
|
2740
|
-
return finishQueuedStreamIfNeeded(res, requestInfo, honestMessage);
|
|
2741
|
-
}
|
|
2718
|
+
const retryAfterMs = retryPlan.retryMs ?? retryPlan.retryAfterMs;
|
|
2719
|
+
// ALWAYS HOLD FIRST (owner 2026-10-28: "zero reason to drop those requests… even
|
|
2720
|
+
// when I'm out of accounts completely, I buy new ones"). The old oracle errored
|
|
2721
|
+
// fast whenever no FINITE scheduled reset existed (no_eligible_route,
|
|
2722
|
+
// weekly_reset_unknown, reset beyond window) — but recovery does not need a
|
|
2723
|
+
// schedule: config auto-sync adopts a newly bought account in ~15s, and a sibling
|
|
2724
|
+
// completing frees a slot in seconds; hasAvailableRoute polls both every tick.
|
|
2725
|
+
// So: hold the FULL window regardless of the plan, and only at expiry end with
|
|
2726
|
+
// the ≤60s-retriable 429 (clientRetryAfterSeconds caps the header), which the
|
|
2727
|
+
// CLI obeys silently — that IS the chaining mechanism, for streams and
|
|
2728
|
+
// non-streams alike. Windows stay hard-capped at the client's own ceilings
|
|
2729
|
+
// (25m stream / 5m non-stream), so nothing can hang past what the client
|
|
2730
|
+
// survives. queueHoldChain is now purely informational in the log line.
|
|
2731
|
+
if (queueWindowMs > 0 && Number.isFinite(retryAfterMs)
|
|
2732
|
+
&& retryAfterMs > queueWindowMs
|
|
2733
|
+
&& !CAPACITY_CLASS_RETRY_CAUSES.has(retryPlan.cause)) {
|
|
2734
|
+
requestInfo.queueHoldChain = true;
|
|
2742
2735
|
}
|
|
2743
2736
|
|
|
2744
2737
|
requestInfo.queueStartedAt ||= Date.now();
|
|
@@ -2894,8 +2887,12 @@ async function waitForAvailableRoute(req, res, accountManager, requestInfo, queu
|
|
|
2894
2887
|
// removed, or the reset is unknown → retryAfterMs Infinity), stop holding
|
|
2895
2888
|
// and error fast instead of spinning to the 7d ceiling. Hold is valid only
|
|
2896
2889
|
// while ≥1 eligible route has a finite, known reset.
|
|
2897
|
-
|
|
2898
|
-
|
|
2890
|
+
// NOTE (owner 2026-10-28, queue-never-fail): the old non-finite-plan bail is
|
|
2891
|
+
// GONE. hasAvailableRoute above is checked every tick and returns true the
|
|
2892
|
+
// moment a route exists — including one created by config auto-sync adopting
|
|
2893
|
+
// a newly added account, which nextRetryForRequest cannot foresee. The
|
|
2894
|
+
// window (hard-capped at the client ceilings) bounds the poll; expiry hands
|
|
2895
|
+
// back a ≤60s-retriable 429 the client retries silently.
|
|
2899
2896
|
|
|
2900
2897
|
const remaining = maxWaitMs - (Date.now() - startedAt);
|
|
2901
2898
|
// Jitter the poll so a synchronized weekly-reset event doesn't re-align
|