tuxevil-rotator 4.2.0 → 4.2.1

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/CHANGELOG.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [4.2.1] - 2026-10-17
6
+
7
+ ### Fixed
8
+
9
+ - **Provider-scoped auth failures**: a 401/403 from one provider now invalidates only that provider's credential on that account. Previously only `openai-codex` did this; `google-antigravity`, `ollama` and `opencode-zen` quota polling, proxied requests, kickstart and token refresh called `markFlagged`, quarantining the whole account — so an OpenCode Zen API-key rotation, for example, took the same account's Google, Ollama and Codex credentials out of rotation too. Sibling providers with valid credits keep serving the account.
10
+ - **Token refresh failures**: a failed token refresh marks only the affected provider's credential invalid instead of counting errors on the whole account.
11
+
5
12
  ## [4.2.0] - 2026-10-14
6
13
 
7
14
  ### Added
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tuxevil-rotator",
3
- "version": "4.2.0",
3
+ "version": "4.2.1",
4
4
  "description": "Multi-provider, multi-account AI proxy rotator with per-model routing, real-time quota tracking, and infringement detection (Google Antigravity, Ollama Cloud)",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -216,14 +216,16 @@ export async function fetchProviderQuota(
216
216
  const errorText = await response.text();
217
217
  if (!isCurrentGeneration()) return;
218
218
  ctx.log(
219
- `${account.config.email}: quota API returned ${response.status}, flagging account`,
219
+ `${account.config.email}: quota API returned ${response.status}, invalidating provider credential`,
220
220
  );
221
221
  ctx.reportQuotaPollFlag(account, response.status, errorText);
222
- ctx.markFlagged(
223
- account,
224
- `Quota API ${response.status}: ${errorText}`,
225
- { triggerProtectivePause: false },
226
- );
222
+ if (ctx.markProviderInvalid) {
223
+ ctx.markProviderInvalid(
224
+ account,
225
+ DEFAULT_PROVIDER,
226
+ `Quota API ${response.status}: ${errorText}`,
227
+ );
228
+ }
227
229
  }
228
230
  return;
229
231
  }
@@ -50,14 +50,16 @@ export async function fetchProviderUsage(
50
50
  if (response.status === 401 || response.status === 403) {
51
51
  const errorText = await response.text().catch(() => "");
52
52
  ctx.log(
53
- `${account.config.email}: Ollama quota API returned ${response.status}, flagging account`,
53
+ `${account.config.email}: Ollama quota API returned ${response.status}, invalidating provider credential`,
54
54
  );
55
55
  ctx.reportQuotaPollFlag(account, response.status, errorText);
56
- ctx.markFlagged(
57
- account,
58
- `Ollama quota API ${response.status}: ${errorText}`,
59
- { triggerProtectivePause: false },
60
- );
56
+ if (ctx.markProviderInvalid) {
57
+ ctx.markProviderInvalid(
58
+ account,
59
+ "ollama",
60
+ `Ollama quota API ${response.status}: ${errorText}`,
61
+ );
62
+ }
61
63
  }
62
64
  return;
63
65
  }
@@ -30,13 +30,15 @@ export async function fetchOpenCodeZenQuota(
30
30
  if (!response.ok) {
31
31
  if (response.status === 401 || response.status === 403) {
32
32
  const errorText = await response.text().catch(() => "");
33
- ctx.log(`${account.config.email}: OpenCode Zen API returned ${response.status}, flagging account`);
33
+ ctx.log(`${account.config.email}: OpenCode Zen API returned ${response.status}, invalidating provider credential`);
34
34
  ctx.reportQuotaPollFlag(account, response.status, errorText);
35
- ctx.markFlagged(
36
- account,
37
- `OpenCode Zen API ${response.status}: ${errorText}`,
38
- { triggerProtectivePause: false },
39
- );
35
+ if (ctx.markProviderInvalid) {
36
+ ctx.markProviderInvalid(
37
+ account,
38
+ OPENCODE_ZEN_PROVIDER_ID,
39
+ `OpenCode Zen API ${response.status}: ${errorText}`,
40
+ );
41
+ }
40
42
  }
41
43
  return;
42
44
  }
package/src/proxy.ts CHANGED
@@ -649,9 +649,12 @@ async function handleUpstreamAccountAction(
649
649
  uptimeSeconds: ctx401.uptimeSeconds,
650
650
  timeSinceLastFlagSeconds: -1,
651
651
  });
652
- rotator.markFlagged(
652
+ // Provider-scoped invalidation: only the failing provider is taken
653
+ // out of rotation; sibling providers on the same account remain active.
654
+ rotator.markProviderInvalid(
653
655
  account,
654
- `Account blocked (401): ${action.errorText.slice(0, 300)}`,
656
+ provider.id,
657
+ `Provider credential rejected (401): ${action.errorText.slice(0, 300)}`,
655
658
  );
656
659
  logRequestEnd(401, `endpoint=${action.endpoint}`);
657
660
  if (!options.canRetry) {
@@ -661,7 +664,7 @@ async function handleUpstreamAccountAction(
661
664
  if (!nextAccount) {
662
665
  return buildNoReplacementDecision(
663
666
  options,
664
- `no replacement account remained after ${label} was flagged with 401`,
667
+ `no replacement account remained after ${label} provider was invalidated with 401`,
665
668
  );
666
669
  }
667
670
  return { kind: "retry" };
@@ -691,7 +694,14 @@ async function handleUpstreamAccountAction(
691
694
  uptimeSeconds: ctx403.uptimeSeconds,
692
695
  timeSinceLastFlagSeconds: -1,
693
696
  });
694
- rotator.markFlagged(account, action.errorText.slice(0, 300));
697
+ // Provider-scoped invalidation: a 403 with flag patterns (suspended,
698
+ // banned, etc.) indicates the upstream provider rejected this credential.
699
+ // Only the failing provider is taken out; sibling providers remain active.
700
+ rotator.markProviderInvalid(
701
+ account,
702
+ provider.id,
703
+ `Provider flagged (403): ${action.errorText.slice(0, 300)}`,
704
+ );
695
705
  if (!options.canRetry) {
696
706
  return buildFailureDecision(options, 403, action.errorText);
697
707
  }
@@ -699,7 +709,7 @@ async function handleUpstreamAccountAction(
699
709
  if (!nextAccount) {
700
710
  return buildNoReplacementDecision(
701
711
  options,
702
- `no replacement account remained after ${label} was flagged with 403`,
712
+ `no replacement account remained after ${label} provider was invalidated with 403`,
703
713
  );
704
714
  }
705
715
  return { kind: "retry" };
package/src/rotator.ts CHANGED
@@ -3712,13 +3712,13 @@ export class AccountRotator {
3712
3712
  await this.ensureValidTokenForProvider(account, adapter.id);
3713
3713
  } catch (err) {
3714
3714
  const msg = err instanceof Error ? err.message : String(err);
3715
- if (msg.startsWith("Token refresh failed") || msg.startsWith("Token refresh error:")) {
3716
- this.markError(account, msg);
3717
- throw err;
3718
- }
3719
- const wrapped = `Token refresh error: ${msg}`;
3720
- this.markError(account, wrapped);
3721
- throw new Error(wrapped, { cause: err });
3715
+ // Provider-scoped invalidation: token refresh failures only affect the
3716
+ // provider whose token could not be refreshed, not the whole account.
3717
+ const reason = msg.startsWith("Token refresh failed") || msg.startsWith("Token refresh error:")
3718
+ ? msg
3719
+ : `Token refresh error: ${msg}`;
3720
+ this.markProviderInvalid(account, adapter.id, reason);
3721
+ throw msg === reason ? err : new Error(reason, { cause: err });
3722
3722
  }
3723
3723
  }
3724
3724
 
@@ -5142,8 +5142,11 @@ export class AccountRotator {
5142
5142
  if (target.providerId === "openai-codex") {
5143
5143
  this.markProviderInvalid(account, target.providerId, failure.description);
5144
5144
  } else if (failure.accountEnforcement) {
5145
+ // Provider-scoped invalidation: even with account-enforcement language
5146
+ // in the response, only the specific provider credential is invalidated.
5147
+ // Sibling providers on the same account remain routable.
5145
5148
  this.reportQuotaPollFlag(account, response.status, errorText, upstreamModel);
5146
- this.markFlagged(account, failure.description, { triggerProtectivePause: false });
5149
+ this.markProviderInvalid(account, target.providerId, failure.description);
5147
5150
  } else {
5148
5151
  account.lastError = failure.description;
5149
5152
  this.kickstartDeniedUntil.set(denialKey, Date.now() + 30 * 60 * 1000);