runtime: canonicalize Claude token env names

This commit is contained in:
ejclaw
2026-04-11 14:32:43 +09:00
parent 91caf81069
commit e458382d3d
9 changed files with 102 additions and 30 deletions

View File

@@ -31,6 +31,17 @@ vi.mock('./codex-token-rotation.js', () => ({
vi.mock('./token-rotation.js', () => ({
getCurrentToken: vi.fn(() => undefined),
getConfiguredClaudeTokens: vi.fn(
(options?: { multi?: string | undefined; single?: string | undefined }) => {
if (options?.multi) {
return options.multi
.split(',')
.map((token) => token.trim())
.filter(Boolean);
}
return options?.single ? [options.single] : [];
},
),
}));
vi.mock('./platform-prompts.js', () => ({
@@ -309,6 +320,21 @@ describe('prepareGroupEnvironment codex auth handling', () => {
]);
});
it('maps the canonical multi-token env to a single runner OAuth token', () => {
vi.mocked(serviceRouting.hasReviewerLease).mockReturnValue(true);
mockReadEnvFile.mockReturnValue({
CLAUDE_CODE_OAUTH_TOKENS: 'token-a, token-b',
});
const prepared = prepareGroupEnvironment(
{ ...group, agentType: 'claude-code' },
false,
'dc:test',
);
expect(prepared.env.CLAUDE_CODE_OAUTH_TOKEN).toBe('token-a');
});
it('returns to the normal owner prompt stack after failover is cleared', () => {
vi.mocked(config.isReviewService).mockReturnValue(true);
vi.mocked(serviceRouting.hasReviewerLease).mockReturnValue(true);