fix(openai): 修复 Agent Identity 审查问题

This commit is contained in:
cat
2026-07-15 18:30:16 +08:00
parent 12e6e70775
commit 2147da682b
6 changed files with 129 additions and 18 deletions
@@ -5515,7 +5515,10 @@ const isAgentIdentityImportContent = (content: string) => {
if (Array.isArray(value)) return value.length > 0 && value.every(isAgentIdentityValue)
if (!value || typeof value !== 'object') return false
const record = value as Record<string, unknown>
return record.auth_mode === 'agentIdentity' && !!record.agent_identity && typeof record.agent_identity === 'object'
const authMode = record.auth_mode ?? record.authMode
const agentIdentity = record.agent_identity ?? record.agentIdentity
return (typeof authMode === 'string' && authMode.toLowerCase() === 'agentidentity')
|| (!!agentIdentity && typeof agentIdentity === 'object')
}
try {
@@ -171,6 +171,22 @@ describe('CreateAccountModal OpenAI long-context billing', () => {
expect(flow.props('titleOverride')).toBe('Agent Identity')
})
it.each([
['camelCase', { authMode: 'agentIdentity', agentIdentity: { agentRuntimeId: 'runtime' } }],
['nested identity without auth_mode', { agent_identity: { agent_runtime_id: 'runtime' } }],
])('accepts backend-compatible %s Agent Identity imports', async (_name, content) => {
const wrapper = mountModal()
await selectButtonByText(wrapper, 'OpenAI')
await wrapper.get('[data-testid="openai-account-type-agent-identity"]').trigger('click')
await wrapper.get('form#create-account-form input[type="text"]').setValue('Agent Identity')
await wrapper.get('form#create-account-form').trigger('submit.prevent')
wrapper.getComponent(OAuthAuthorizationFlowStub).vm.$emit('import-codex-session', JSON.stringify(content))
await flushPromises()
expect(importCodexSessionMock).toHaveBeenCalledTimes(1)
})
it('shows Codex PAT as a separate OpenAI account type', async () => {
const wrapper = mountModal()
await selectButtonByText(wrapper, 'OpenAI')