maxpool 1.24.11 → 1.24.13
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/claude-reset-grants.js +14 -5
- package/src/index.js +10 -0
package/package.json
CHANGED
|
@@ -119,17 +119,26 @@ export async function listResetGrants(accessToken, { signal } = {}) {
|
|
|
119
119
|
* random per CALL (server treats already_used as success), so a caller retry is
|
|
120
120
|
* safe but the id is not reused across distinct decisions. Returns
|
|
121
121
|
* { ok:true } | { ok:false, error, code }. */
|
|
122
|
-
export async function claimResetGrant(accessToken, grantId, { signal, requestId } = {}) {
|
|
122
|
+
export async function claimResetGrant(accessToken, grantId, { signal, requestId, fetchImpl } = {}) {
|
|
123
123
|
if (!accessToken || !grantId) return { ok: false, error: 'missing args' };
|
|
124
|
+
const doFetch = fetchImpl || ((u, o) => fetch(u, o));
|
|
124
125
|
try {
|
|
125
|
-
const prof = await
|
|
126
|
+
const prof = await doFetch(PROFILE_URL, { headers: headers(accessToken), signal });
|
|
126
127
|
if (!prof.ok) return { ok: false, error: `profile HTTP ${prof.status}` };
|
|
127
|
-
const
|
|
128
|
-
|
|
128
|
+
const body = await prof.json();
|
|
129
|
+
// The profile returns `organization` (SINGULAR object) — measured live on
|
|
130
|
+
// maxim.krasnykh@gmail.com 2026-10-09: {account, organization, application}.
|
|
131
|
+
// v1.24.0-12 read only the plural `organizations` array (null for personal
|
|
132
|
+
// accounts), so EVERY cedar_ember claim on a personal account failed with
|
|
133
|
+
// 'no oauth organization' while the account sat exhausted with a usable reset
|
|
134
|
+
// (owner report: 'this account is exhausted but the reset is not being used').
|
|
135
|
+
// Accept both shapes; singular wins when present.
|
|
136
|
+
const org = body?.organization?.uuid
|
|
137
|
+
?? (Array.isArray(body?.organizations) && body.organizations.length ? body.organizations[0].uuid : null);
|
|
129
138
|
if (!org) return { ok: false, error: 'no oauth organization' };
|
|
130
139
|
|
|
131
140
|
const rid = requestId || randomUUID();
|
|
132
|
-
const res = await
|
|
141
|
+
const res = await doFetch(`https://api.anthropic.com${CLAIM_PATH}/${org}/reset_rate_limits`, {
|
|
133
142
|
method: 'POST',
|
|
134
143
|
headers: { ...headers(accessToken), 'Content-Type': 'application/json' },
|
|
135
144
|
body: JSON.stringify({ program: 'cedar_ember', grant_id: grantId, request_id: rid }),
|
package/src/index.js
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
import net from 'node:net';
|
|
4
|
+
|
|
5
|
+
// DUAL-STACK TUNING (2026-10-08). Node ≥20 enables happy-eyeballs with a 250ms
|
|
6
|
+
// per-family attempt timeout. On networks where IPv6 is degraded-but-not-dead and the
|
|
7
|
+
// IPv4 path needs >250ms to establish (measured today: every pool upstream call failed
|
|
8
|
+
// ETIMEDOUT in ~270ms while IPv4 alone answered in 3s — the whole fleet saw
|
|
9
|
+
// "connection dropped on every account (UPSTREAM_TTFB)"), 250ms aborts the fallback
|
|
10
|
+
// before IPv4 can win. 2000ms covers a slow IPv4 start; a healthy IPv6 still wins
|
|
11
|
+
// immediately, so well-connected networks are unaffected. Must run BEFORE any
|
|
12
|
+
// connection is opened, hence here at module top.
|
|
13
|
+
net.setDefaultAutoSelectFamilyAttemptTimeout(Number(process.env.MAXPOOL_FAMILY_ATTEMPT_MS) || 2000);
|
|
4
14
|
import { stat } from 'node:fs/promises';
|
|
5
15
|
import { spawn, spawnSync } from 'node:child_process';
|
|
6
16
|
import { createInterface } from 'node:readline';
|