maxpool 1.24.12 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "maxpool",
3
- "version": "1.24.12",
3
+ "version": "1.24.13",
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",
@@ -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 fetch(PROFILE_URL, { headers: headers(accessToken), signal });
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 orgs = (await prof.json())?.organizations;
128
- const org = Array.isArray(orgs) && orgs.length ? orgs[0].uuid : null;
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 fetch(`https://api.anthropic.com${CLAIM_PATH}/${org}/reset_rate_limits`, {
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 }),