Skip to content

Commit c747cfa

Browse files
feat: add OpenCode as ACP agent backend
OpenCode ships native ACP support via `opencode acp` — pure stdio JSON-RPC, zero adapter layer required. Integration is configuration-only: no changes to src/. - config.toml.example: add commented opencode [agent] block - Dockerfile.opencode: multi-stage build using debian:bookworm-slim + official install script (not node:22 — opencode is a self-contained binary; npm package is only a 9 KB download wrapper) - README.md: add opencode to description, features, backend table, and Manual config section Verified against opencode v1.4.3 on openab v0.7.1. Multi-turn conversations stable end-to-end via Discord.
1 parent 13cc314 commit c747cfa

4 files changed

Lines changed: 66 additions & 4 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Dockerfile.opencode

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# --- Build stage ---
2+
FROM rust:1-bookworm AS builder
3+
WORKDIR /build
4+
COPY Cargo.toml Cargo.lock ./
5+
RUN mkdir src && echo 'fn main() {}' > src/main.rs && cargo build --release && rm -rf src
6+
COPY src/ src/
7+
RUN touch src/main.rs && cargo build --release
8+
9+
# --- Runtime stage ---
10+
# debian:bookworm-slim (not node:22) — opencode ships as a self-contained binary.
11+
# The npm package (opencode-ai) is only a 9 KB postinstall wrapper that downloads
12+
# the same pre-compiled binary; using node:22 as base just to run that wrapper
13+
# adds ~170 MB for a runtime that opencode itself never needs.
14+
# We use the official install script instead: curl -fsSL https://opencode.ai/install | bash
15+
FROM debian:bookworm-slim
16+
17+
RUN apt-get update && apt-get install -y --no-install-recommends \
18+
ca-certificates curl bash \
19+
&& rm -rf /var/lib/apt/lists/*
20+
21+
# Install gh CLI (matches Dockerfile.claude / Dockerfile.gemini / Dockerfile.codex)
22+
RUN curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg \
23+
-o /usr/share/keyrings/githubcli-archive-keyring.gpg && \
24+
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" \
25+
> /etc/apt/sources.list.d/github-cli.list && \
26+
apt-get update && apt-get install -y --no-install-recommends gh && \
27+
rm -rf /var/lib/apt/lists/*
28+
29+
# Create non-root user (mirrors USER node pattern in other Dockerfiles)
30+
RUN useradd -m -s /bin/bash opencode
31+
32+
# Install opencode as the opencode user so $HOME resolves correctly.
33+
# The install script places the binary at $HOME/.opencode/bin/opencode;
34+
# we expose it on PATH via ENV so openab can spawn it without a shell login.
35+
USER opencode
36+
ENV HOME=/home/opencode
37+
RUN curl -fsSL https://opencode.ai/install | bash
38+
ENV PATH="/home/opencode/.opencode/bin:$PATH"
39+
40+
USER root
41+
WORKDIR /home/opencode
42+
43+
COPY --from=builder --chown=opencode:opencode /build/target/release/openab /usr/local/bin/openab
44+
45+
USER opencode
46+
HEALTHCHECK --interval=30s --timeout=5s --retries=3 \
47+
CMD pgrep -x openab || exit 1
48+
ENTRYPOINT ["openab"]
49+
CMD ["/etc/openab/config.toml"]

README.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# OpenAB — Open Agent Broker
22

3-
A lightweight, secure, cloud-native ACP harness that bridges Discord and any [Agent Client Protocol](https://github.com/anthropics/agent-protocol)-compatible coding CLI (Kiro CLI, Claude Code, Codex, Gemini, etc.) over stdio JSON-RPC — delivering the next-generation development experience.
3+
A lightweight, secure, cloud-native ACP harness that bridges Discord and any [Agent Client Protocol](https://github.com/anthropics/agent-protocol)-compatible coding CLI (Kiro CLI, Claude Code, Codex, Gemini, OpenCode, etc.) over stdio JSON-RPC — delivering the next-generation development experience.
44

55
🪼 **Join our community!** Come say hi on Discord — we'd love to have you: **[🪼 OpenAB — Official](https://discord.gg/YNksK9M6)** 🎉
66

@@ -17,7 +17,7 @@ A lightweight, secure, cloud-native ACP harness that bridges Discord and any [Ag
1717

1818
## Features
1919

20-
- **Pluggable agent backend** — swap between Kiro CLI, Claude Code, Codex, Gemini via config
20+
- **Pluggable agent backend** — swap between Kiro CLI, Claude Code, Codex, Gemini, OpenCode via config
2121
- **@mention trigger** — mention the bot in an allowed channel to start a conversation
2222
- **Thread-based multi-turn** — auto-creates threads; no @mention needed for follow-ups
2323
- **Edit-streaming** — live-updates the Discord message every 1.5s as tokens arrive
@@ -85,14 +85,15 @@ The bot creates a thread. After that, just type in the thread — no @mention ne
8585

8686
## Pluggable Agent Backends
8787

88-
Supports Kiro CLI, Claude Code, Codex, Gemini, and any ACP-compatible CLI.
88+
Supports Kiro CLI, Claude Code, Codex, Gemini, OpenCode, and any ACP-compatible CLI.
8989

9090
| Agent key | CLI | ACP Adapter | Auth |
9191
|-----------|-----|-------------|------|
9292
| `kiro` (default) | Kiro CLI | Native `kiro-cli acp` | `kiro-cli login --use-device-flow` |
9393
| `codex` | Codex | [@zed-industries/codex-acp](https://github.com/zed-industries/codex-acp) | `codex login --device-auth` |
9494
| `claude` | Claude Code | [@agentclientprotocol/claude-agent-acp](https://github.com/agentclientprotocol/claude-agent-acp) | `claude setup-token` |
9595
| `gemini` | Gemini CLI | Native `gemini --acp` | Google OAuth or `GEMINI_API_KEY` |
96+
| `opencode` | OpenCode | Native `opencode acp` | `opencode auth login` |
9697

9798
### Helm Install (recommended)
9899

@@ -158,6 +159,12 @@ command = "gemini"
158159
args = ["--acp"]
159160
working_dir = "/home/node"
160161
env = { GEMINI_API_KEY = "${GEMINI_API_KEY}" }
162+
163+
# OpenCode (requires opencode in PATH; run `opencode auth login` first)
164+
[agent]
165+
command = "opencode"
166+
args = ["acp"]
167+
working_dir = "/root"
161168
```
162169

163170
## Configuration Reference

config.toml.example

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ working_dir = "/home/agent"
2626
# working_dir = "/home/agent"
2727
# env = { GEMINI_API_KEY = "${GEMINI_API_KEY}" }
2828

29+
# [agent]
30+
# command = "opencode"
31+
# args = ["acp"]
32+
# working_dir = "/home/opencode"
33+
# # run `opencode auth login` once before starting openab
34+
2935
[pool]
3036
max_sessions = 10
3137
session_ttl_hours = 24

0 commit comments

Comments
 (0)