fix: harden agent shutdown and auth rotation
This commit is contained in:
@@ -27,6 +27,7 @@ vi.mock('./logger.js', () => ({
|
||||
import { fetchClaudeUsage } from './claude-usage.js';
|
||||
import {
|
||||
clearPrimaryCooldown,
|
||||
detectFallbackTrigger,
|
||||
getActiveProvider,
|
||||
getCooldownInfo,
|
||||
markPrimaryCooldown,
|
||||
@@ -100,4 +101,24 @@ describe('provider fallback usage recovery', () => {
|
||||
await expect(getActiveProvider()).resolves.toBe('claude');
|
||||
expect(getCooldownInfo()).toEqual({ active: false });
|
||||
});
|
||||
|
||||
it('treats terminated 401 auth failures as an auth-expired fallback trigger', () => {
|
||||
expect(
|
||||
detectFallbackTrigger('Failed to authenticate. API Error: 401 terminated'),
|
||||
).toEqual({
|
||||
shouldFallback: true,
|
||||
reason: 'auth-expired',
|
||||
});
|
||||
});
|
||||
|
||||
it('treats invalid authentication credentials as an auth-expired fallback trigger', () => {
|
||||
expect(
|
||||
detectFallbackTrigger(
|
||||
'Failed to authenticate. API Error: 401 {"type":"error","error":{"type":"authentication_error","message":"Invalid authentication credentials"}}',
|
||||
),
|
||||
).toEqual({
|
||||
shouldFallback: true,
|
||||
reason: 'auth-expired',
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user