(agent, config)
| 786 | * @param {object} config - Agent-specific config values |
| 787 | */ |
| 788 | export async function updateCodingAgentConfig(agent, config) { |
| 789 | await requireAdmin(); |
| 790 | try { |
| 791 | const { setConfigValue } = await import('../db/config.js'); |
| 792 | |
| 793 | if (agent === 'claude-code') { |
| 794 | if (config.enabled !== undefined) setConfigValue('CODING_AGENT_CLAUDE_CODE_ENABLED', String(config.enabled)); |
| 795 | if (config.auth !== undefined) setConfigValue('CODING_AGENT_CLAUDE_CODE_AUTH', config.auth); |
| 796 | if (config.backend !== undefined) setConfigValue('CODING_AGENT_CLAUDE_CODE_BACKEND', config.backend); |
| 797 | if (config.model !== undefined) setConfigValue('CODING_AGENT_CLAUDE_CODE_MODEL', config.model); |
| 798 | } else if (agent === 'pi-coding-agent') { |
| 799 | if (config.enabled !== undefined) setConfigValue('CODING_AGENT_PI_ENABLED', String(config.enabled)); |
| 800 | if (config.provider !== undefined) setConfigValue('CODING_AGENT_PI_PROVIDER', config.provider); |
| 801 | if (config.model !== undefined) setConfigValue('CODING_AGENT_PI_MODEL', config.model); |
| 802 | } else if (agent === 'gemini-cli') { |
| 803 | if (config.enabled !== undefined) setConfigValue('CODING_AGENT_GEMINI_CLI_ENABLED', String(config.enabled)); |
| 804 | if (config.model !== undefined) setConfigValue('CODING_AGENT_GEMINI_CLI_MODEL', config.model); |
| 805 | } else if (agent === 'codex-cli') { |
| 806 | if (config.enabled !== undefined) setConfigValue('CODING_AGENT_CODEX_CLI_ENABLED', String(config.enabled)); |
| 807 | if (config.auth !== undefined) setConfigValue('CODING_AGENT_CODEX_CLI_AUTH', config.auth); |
| 808 | if (config.model !== undefined) setConfigValue('CODING_AGENT_CODEX_CLI_MODEL', config.model); |
| 809 | } else if (agent === 'opencode') { |
| 810 | if (config.enabled !== undefined) setConfigValue('CODING_AGENT_OPENCODE_ENABLED', String(config.enabled)); |
| 811 | if (config.provider !== undefined) setConfigValue('CODING_AGENT_OPENCODE_PROVIDER', config.provider); |
| 812 | if (config.model !== undefined) setConfigValue('CODING_AGENT_OPENCODE_MODEL', config.model); |
| 813 | } else if (agent === 'kimi-cli') { |
| 814 | if (config.enabled !== undefined) setConfigValue('CODING_AGENT_KIMI_CLI_ENABLED', String(config.enabled)); |
| 815 | if (config.provider !== undefined) setConfigValue('CODING_AGENT_KIMI_CLI_PROVIDER', config.provider); |
| 816 | if (config.model !== undefined) setConfigValue('CODING_AGENT_KIMI_CLI_MODEL', config.model); |
| 817 | } else { |
| 818 | return { error: 'Invalid agent' }; |
| 819 | } |
| 820 | |
| 821 | if (agent === 'claude-code' && config.backend !== undefined) { |
| 822 | await syncLitellmConfig(); |
| 823 | } |
| 824 | return { success: true }; |
| 825 | } catch (err) { |
| 826 | console.error('Failed to update coding agent config:', err); |
| 827 | return { error: 'Failed to update config' }; |
| 828 | } |
| 829 | } |
| 830 | |
| 831 | /** |
| 832 | * Set the default coding agent. |
no test coverage detected