Merge pull request #81 from Vasanthdev2004/third-party-setup-fix
fix: skip Anthropic setup flow for third-party providers
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -72,7 +72,7 @@ describe('Codex provider config', () => {
|
||||
})
|
||||
|
||||
describe('Codex request translation', () => {
|
||||
test('disables strict mode for tools with optional parameters', () => {
|
||||
test('normalizes optional parameters into strict Responses schemas', () => {
|
||||
const tools = convertToolsToResponsesTools([
|
||||
{
|
||||
name: 'Agent',
|
||||
@@ -102,9 +102,10 @@ describe('Codex request translation', () => {
|
||||
prompt: { type: 'string' },
|
||||
subagent_type: { type: 'string' },
|
||||
},
|
||||
required: ['description', 'prompt'],
|
||||
required: ['description', 'prompt', 'subagent_type'],
|
||||
additionalProperties: false,
|
||||
},
|
||||
strict: true,
|
||||
},
|
||||
])
|
||||
})
|
||||
|
||||
54
src/utils/model/providers.test.ts
Normal file
54
src/utils/model/providers.test.ts
Normal file
@@ -0,0 +1,54 @@
|
||||
import { afterEach, expect, test } from 'bun:test'
|
||||
|
||||
import {
|
||||
getAPIProvider,
|
||||
usesAnthropicAccountFlow,
|
||||
} from './providers.js'
|
||||
|
||||
const originalEnv = {
|
||||
CLAUDE_CODE_USE_GEMINI: process.env.CLAUDE_CODE_USE_GEMINI,
|
||||
CLAUDE_CODE_USE_OPENAI: process.env.CLAUDE_CODE_USE_OPENAI,
|
||||
CLAUDE_CODE_USE_BEDROCK: process.env.CLAUDE_CODE_USE_BEDROCK,
|
||||
CLAUDE_CODE_USE_VERTEX: process.env.CLAUDE_CODE_USE_VERTEX,
|
||||
CLAUDE_CODE_USE_FOUNDRY: process.env.CLAUDE_CODE_USE_FOUNDRY,
|
||||
}
|
||||
|
||||
afterEach(() => {
|
||||
process.env.CLAUDE_CODE_USE_GEMINI = originalEnv.CLAUDE_CODE_USE_GEMINI
|
||||
process.env.CLAUDE_CODE_USE_OPENAI = originalEnv.CLAUDE_CODE_USE_OPENAI
|
||||
process.env.CLAUDE_CODE_USE_BEDROCK = originalEnv.CLAUDE_CODE_USE_BEDROCK
|
||||
process.env.CLAUDE_CODE_USE_VERTEX = originalEnv.CLAUDE_CODE_USE_VERTEX
|
||||
process.env.CLAUDE_CODE_USE_FOUNDRY = originalEnv.CLAUDE_CODE_USE_FOUNDRY
|
||||
})
|
||||
|
||||
function clearProviderEnv(): void {
|
||||
delete process.env.CLAUDE_CODE_USE_GEMINI
|
||||
delete process.env.CLAUDE_CODE_USE_OPENAI
|
||||
delete process.env.CLAUDE_CODE_USE_BEDROCK
|
||||
delete process.env.CLAUDE_CODE_USE_VERTEX
|
||||
delete process.env.CLAUDE_CODE_USE_FOUNDRY
|
||||
}
|
||||
|
||||
test('first-party provider keeps Anthropic account setup flow enabled', () => {
|
||||
clearProviderEnv()
|
||||
|
||||
expect(getAPIProvider()).toBe('firstParty')
|
||||
expect(usesAnthropicAccountFlow()).toBe(true)
|
||||
})
|
||||
|
||||
test.each([
|
||||
['CLAUDE_CODE_USE_OPENAI', 'openai'],
|
||||
['CLAUDE_CODE_USE_GEMINI', 'gemini'],
|
||||
['CLAUDE_CODE_USE_BEDROCK', 'bedrock'],
|
||||
['CLAUDE_CODE_USE_VERTEX', 'vertex'],
|
||||
['CLAUDE_CODE_USE_FOUNDRY', 'foundry'],
|
||||
] as const)(
|
||||
'%s disables Anthropic account setup flow',
|
||||
(envKey, provider) => {
|
||||
clearProviderEnv()
|
||||
process.env[envKey] = '1'
|
||||
|
||||
expect(getAPIProvider()).toBe(provider)
|
||||
expect(usesAnthropicAccountFlow()).toBe(false)
|
||||
},
|
||||
)
|
||||
@@ -17,6 +17,10 @@ export function getAPIProvider(): APIProvider {
|
||||
: 'firstParty'
|
||||
}
|
||||
|
||||
export function usesAnthropicAccountFlow(): boolean {
|
||||
return getAPIProvider() === 'firstParty'
|
||||
}
|
||||
|
||||
export function getAPIProviderForStatsig(): AnalyticsMetadata_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHS {
|
||||
return getAPIProvider() as AnalyticsMetadata_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHS
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user