-
Notifications
You must be signed in to change notification settings - Fork 0
Support multiple AI coding agent backends (OpenCode, Aider, etc.) #2
Copy link
Copy link
Open
Description
Summary
Refactor remote-coder from a Claude Code-specific wrapper into a generic remote AI coding agent platform that supports multiple backend engines. The session management, API auth, workspace isolation, and UI remain the same — only the execution backend is swappable.
Architecture
HTTP API / UI → remote-coder (session manager) → backend engine
├─ claude-code (SDK or CLI) ← current
├─ opencode
├─ aider
├─ codex
└─ ...
Interface
Each backend engine implements a common CodingAgent interface:
interface CodingAgent {
send(message: string): Promise<AgentResponse>;
compact(): Promise<AgentResponse>; // optional, not all engines support it
getSessionId(): string | null;
getWorkingDir(): string;
getModel(): string;
}API Changes
Add an engine field when creating a session:
POST /chat
{
"message": "create a hello.ts file",
"workspace": "my-project",
"model": "sonnet",
"engine": "claude" // "claude" | "opencode" | "aider" | ...
}Default engine configurable via DEFAULT_ENGINE env var (defaults to "claude").
Backend: Claude Code (existing)
- SDK mode:
ANTHROPIC_API_KEYset → uses@anthropic-ai/claude-agent-sdkquery()(faster, no process spawn) - CLI mode:
CLAUDE_CODE_OAUTH_TOKENset → spawnsclaudeCLI - Supports
ANTHROPIC_BASE_URLfor proxy/gateway routing - Session resume via
--resumeflag / SDKresumeoption - Scoped tools: Read, Write, Edit, Glob, Grep, NotebookEdit (no Bash, no internet)
Backend: OpenCode
- Repo: https://github.com/anomalyco/opencode
- Open-source, provider-agnostic AI coding agent (supports Claude, OpenAI, Google, local LLMs)
- 120k+ GitHub stars, 800+ contributors
- Client/server architecture — could talk to its server API or spawn CLI
- Has its own session/conversation persistence
- Built-in LSP support, 75+ LLM providers
- Install:
curl -fsSL https://opencode.ai/install | bash
Integration approach options:
- CLI spawn — similar to current Claude CLI path, spawn
opencodewith prompt, parse output - Server API — OpenCode has a client/server mode, talk to its API directly (lower latency)
- Config file — OpenCode uses
~/.config/opencode/opencode.jsonfor provider config
Needs investigation:
- OpenCode CLI flags for non-interactive/headless mode
- JSON output format (if any)
- Session resume mechanism
- How to scope file access / tools
Backend: Aider (future)
- https://github.com/paul-gauthier/aider
- Python-based, spawns via CLI
- Has
--messageflag for non-interactive use - Session persistence via git
Backend: Codex CLI (future)
- https://github.com/openai/codex
- OpenAI's coding agent
- CLI-based, similar spawn pattern
Implementation Plan
- Extract
CodingAgentinterface from currentClaudeSessionclass - Rename
ClaudeSession→ClaudeCodeAgentimplementingCodingAgent - Create
OpenCodeAgentimplementingCodingAgent - Add engine registry / factory:
createAgent(engine, opts) → CodingAgent - Update
/chatendpoint to acceptengineparameter - Update UI model/engine selector (new session modal)
- Store engine type per session
- Update Dockerfile to install additional engines
- Document env vars per engine
Environment Variables (per engine)
| Engine | Required | Optional |
|---|---|---|
| claude | ANTHROPIC_API_KEY or CLAUDE_CODE_OAUTH_TOKEN |
ANTHROPIC_BASE_URL |
| opencode | Provider-specific (e.g. OPENAI_API_KEY, ANTHROPIC_API_KEY) |
OPENCODE_CONFIG_PATH |
| aider | Provider-specific | AIDER_MODEL |
Current State
The current codebase already supports:
- Dual-mode Claude Code (SDK + CLI)
- Any model name (aliases + full model IDs)
- Proxy routing via
ANTHROPIC_BASE_URL - API key auth on all endpoints
- AKS deployment with CI/CD
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels