feat: add pluggable multi-CLI backend system

Implement BackendAdapter interface with four CLI backends:
- ClaudeCodeBackend (extracted from AgentRuntime)
- CodexBackend (OpenAI Codex CLI)
- GeminiBackend (Google Gemini CLI)
- OpenCodeBackend (OpenCode CLI)

Add BackendRegistry for resolution/creation via AGENT_BACKEND env var.
Refactor AgentRuntime to delegate to BackendAdapter instead of
hardcoding Claude CLI. Update GatewayConfig with new env vars
(AGENT_BACKEND, BACKEND_CLI_PATH, BACKEND_MODEL, BACKEND_MAX_TURNS).

Includes 10 property-based test files and unit tests for edge cases.
This commit is contained in:
2026-02-22 23:41:30 -05:00
parent f2247ea3ac
commit 453389f55c
25 changed files with 3262 additions and 195 deletions

View File

@@ -5,7 +5,11 @@ DISCORD_BOT_TOKEN=your-discord-bot-token-here
OUTPUT_CHANNEL_ID=your-discord-channel-id-for-heartbeat-cron-output
# Optional
# CLAUDE_CLI_PATH=claude
# CLAUDE_CLI_PATH=claude # Deprecated: use BACKEND_CLI_PATH instead
# AGENT_BACKEND=claude # claude | codex | gemini | opencode
# BACKEND_CLI_PATH=claude # Path to CLI binary (defaults to backend name)
# BACKEND_MODEL= # Optional model override for the active backend
# BACKEND_MAX_TURNS=25 # Max agentic turns per query
# CONFIG_DIR=./config
# ALLOWED_TOOLS=Read,Write,Edit,Glob,Grep,WebSearch,WebFetch
# PERMISSION_MODE=bypassPermissions