Current architecture is tightly coupled to ACP (Agent Client Protocol):
- Vendor lock-in - Only works with ACP-compatible agents (claude-code-acp, opencode-acp)
- No direct API support - Can't use Anthropic/OpenAI APIs directly
- Inconsistent tool handling - claude-code-acp respects ClientCapabilities, opencode-acp ignores them
- Coupled permission logic - Permission handling embedded in ACP message handling
- No tool executor - Agents execute their own tools, we can't intercept
Unified backend interface that supports:
- ACP backends (claude-code, opencode, future agents)
- Direct API backends (Anthropic, OpenAI)
- Consistent permission flow regardless of backend
- Optional client-side tool execution
┌─────────────────────────────────────────────────────────────────────┐
│ Frontend │
│ - ToolCard, ChatContent (unchanged) │
│ - Emits 'permission_response' │
└─────────────────────────────────┬───────────────────────────────────┘
│ Wails Events
┌─────────────────────────────────┴───────────────────────────────────┐
│ Permission Layer │
│ - Deterministic rules (read=auto, write=ask, bash=check) │
│ - Emits permission requests to frontend │
│ - Waits for user response │
└─────────────────────────────────┬───────────────────────────────────┘
│
┌─────────────────────────────────┴───────────────────────────────────┐
│ Tool Executor │
│ - fs read/write, bash, glob, grep, etc │
│ - Used by Direct API backend │
│ - Optionally used by ACP via MCP │
└─────────────────────────────────┬───────────────────────────────────┘
│
┌─────────────────────────────────┴───────────────────────────────────┐
│ AgentBackend Interface │
│ NewSession(ctx, opts) (Session, error) │
│ Session: Prompt(), Events(), Cancel(), Close() │
└─────────────────────────────────┬───────────────────────────────────┘
│
┌───────────────────────┼───────────────────────┐
▼ ▼ ▼
ACP (claude-code) ACP (opencode) Direct API
- Permission: agent - Permission: agent - Permission: us
- Execution: agent - Execution: agent - Execution: us
| Phase | Description | Status |
|---|---|---|
| 1 | Architecture refactor - extract layers | Planned |
| 2 | Direct API backend - Anthropic | Planned |
| 3 | Direct API backend - OpenAI | Planned |
| 4 | MCP tool execution (optional) | Planned |
- Permission flow stays the same - Frontend UI unchanged, same events
- ACP agents keep their tool execution - We don't fight their architecture
- Direct API = we execute tools - We control the loop
- Shared types - ToolState, PermissionOptions work across all backends