fix: stop silent Claude 401 stalls and token-family revocations
- Refreshing the OAuth token revokes the old access token, and agents hold it in CLAUDE_CODE_OAUTH_TOKEN (Claude Code keeps env tokens on 401). Refresh early only while no run is active; keep the 1h hard deadline. - forceRefreshToken (after a 401) now probes /api/oauth/profile: a revoked token keeps its expiresAt, so it was handed back unchanged forever. A rejected token is refreshed; if that fails, re-login is flagged at once and held until a different token appears. - Classify "OAuth access token has been revoked" as auth-expired. When the login is gone, close the paired task and tell the room to re-login instead of looping owner/arbiter retries with suppressed output. - Only suppress the CLI's own short 401 banner, not an answer quoting it (a sketchup-app TASK_DONE report was swallowed this way). - Runner denies Bash commands that copy or write .credentials.json: a CLI test against a copied login refreshed the real token family on 2026-11-02 and logged out every room. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -3,6 +3,7 @@ import { describe, expect, it } from 'vitest';
|
||||
import {
|
||||
applyUpdatedTokenToEnvContent,
|
||||
collectSessionCredentialPaths,
|
||||
isRefreshDue,
|
||||
pickFreshestOAuth,
|
||||
shouldAdoptSessionOAuth,
|
||||
shouldStartTokenRefreshLoop,
|
||||
@@ -166,3 +167,19 @@ describe('collectSessionCredentialPaths (real session layout)', () => {
|
||||
expect(collectSessionCredentialPaths('/s', () => [])).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('isRefreshDue', () => {
|
||||
const min = 60 * 1000;
|
||||
it('refreshes early only while no agent is running', () => {
|
||||
expect(isRefreshDue(150 * min, false)).toBe(true);
|
||||
expect(isRefreshDue(150 * min, true)).toBe(false);
|
||||
});
|
||||
|
||||
it('always refreshes inside the last hour, busy or not', () => {
|
||||
expect(isRefreshDue(55 * min, true)).toBe(true);
|
||||
});
|
||||
|
||||
it('leaves a token with more than three hours alone', () => {
|
||||
expect(isRefreshDue(200 * min, false)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user