refactor: run Claude and Codex on one fixed account each
The deployment has a single Claude OAuth credential and a single Codex ChatGPT account, so the N-account rotation machinery only added state files, cooldown bookkeeping and code paths that never ran. Removed: - Claude token rotation (token-rotation.ts, token-rotation-base.ts): rotate-on-limit, per-token cooldowns, token-rotation-state.json. CLAUDE_CODE_OAUTH_TOKENS is still read, but only its first entry. - Codex account rotation (codex-token-rotation.ts): account pool, rotate-on-429/auth, dead-auth/cooldown tracking, round-robin advance, d7 auto-rotate, codex-rotation-state.json, manual account switch. - Account index plumbing in token-refresh, claude-credentials-path (CLAUDE_ACCOUNTS_DIR / ~/.claude-accounts/<n>), Claude/Codex usage collectors, the dashboard rows and the Codex warm-up. - provider-retry.ts rotation loops and the Codex retry path. Kept: - Codex exclusive auth lease (one Codex run at a time), the 15-minute waitForCodexAuthLease, and a usage-poll lease that skips while a run holds the account (codex-auth.ts). - Session auth copy and write-back of refreshed tokens (syncCodexSessionAuthBack, syncClaudeSessionAuthBack). - Codex auth path: ~/.codex-accounts/0/auth.json, else ~/.codex/auth.json (now resolved per run, so a re-login needs no restart). - Claude token refresh loop, CLAUDE_CREDENTIALS_PATH and the CLAUDE_TOKEN_REFRESH_* / CLAUDE_USAGE_USE_HOME_CREDENTIALS flags; an auth-expired run still force-refreshes the token and retries once. - Error classification (classifyClaudeTrigger, classifyCodexTrigger). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -172,40 +172,18 @@ describe('buildWebUsageRowsForSnapshot', () => {
|
||||
it('keeps real Claude rows ahead of Codex rows for snapshots', () => {
|
||||
const rows = buildWebUsageRowsForSnapshot({
|
||||
serviceAgentType: 'claude-code',
|
||||
claudeAccounts: [
|
||||
{
|
||||
index: 0,
|
||||
masked: 'claude-1',
|
||||
isActive: true,
|
||||
isRateLimited: false,
|
||||
usage: {
|
||||
five_hour: {
|
||||
utilization: 0.2,
|
||||
resets_at: '2026-04-26T12:00:00.000Z',
|
||||
},
|
||||
seven_day: {
|
||||
utilization: 0.4,
|
||||
resets_at: '2026-04-27T12:00:00.000Z',
|
||||
},
|
||||
claudeUsage: {
|
||||
usage: {
|
||||
five_hour: {
|
||||
utilization: 0.2,
|
||||
resets_at: '2026-04-26T12:00:00.000Z',
|
||||
},
|
||||
seven_day: {
|
||||
utilization: 0.4,
|
||||
resets_at: '2026-04-27T12:00:00.000Z',
|
||||
},
|
||||
},
|
||||
{
|
||||
index: 1,
|
||||
masked: 'claude-2',
|
||||
isActive: false,
|
||||
isRateLimited: false,
|
||||
usage: {
|
||||
five_hour: {
|
||||
utilization: 0.3,
|
||||
resets_at: '2026-04-26T12:00:00.000Z',
|
||||
},
|
||||
seven_day: {
|
||||
utilization: 0.5,
|
||||
resets_at: '2026-04-27T12:00:00.000Z',
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
codexRows: [
|
||||
{
|
||||
name: 'Codex1',
|
||||
@@ -218,23 +196,14 @@ describe('buildWebUsageRowsForSnapshot', () => {
|
||||
});
|
||||
|
||||
const names = rows.map((row) => row.name);
|
||||
expect(names[0]).toMatch(/^Claude1/);
|
||||
expect(names[1]).toMatch(/^Claude2/);
|
||||
expect(names[2]).toBe('Codex1');
|
||||
expect(names[0]).toMatch(/^Claude/);
|
||||
expect(names[1]).toBe('Codex1');
|
||||
});
|
||||
|
||||
it('does not invent Claude rows for codex-only services', () => {
|
||||
const rows = buildWebUsageRowsForSnapshot({
|
||||
serviceAgentType: 'codex',
|
||||
claudeAccounts: [
|
||||
{
|
||||
index: 0,
|
||||
masked: 'claude-1',
|
||||
isActive: true,
|
||||
isRateLimited: false,
|
||||
usage: null,
|
||||
},
|
||||
],
|
||||
claudeUsage: { usage: null },
|
||||
codexRows: [
|
||||
{
|
||||
name: 'Codex1',
|
||||
|
||||
Reference in New Issue
Block a user