Skip to content

Commit b4191bc

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 b4191bc

4 files changed

Lines changed: 77 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: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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+
#
36+
# Version is pinned for reproducible builds (mirrors the pinned-version
37+
# pattern in Dockerfile.codex and Dockerfile.claude).
38+
# opencode releases very frequently (often daily); bump this version via
39+
# a dedicated PR when a new release is needed.
40+
#
41+
# Note: opencode does not publish SHA256 checksums for its releases,
42+
# so checksum verification is not possible at this time.
43+
USER opencode
44+
ENV HOME=/home/opencode
45+
RUN curl -fsSL https://opencode.ai/install | bash -s -- --version 1.4.3
46+
ENV PATH="/home/opencode/.opencode/bin:$PATH"
47+
48+
USER root
49+
WORKDIR /home/opencode
50+
51+
COPY --from=builder --chown=opencode:opencode /build/target/release/openab /usr/local/bin/openab
52+
53+
USER opencode
54+
HEALTHCHECK --interval=30s --timeout=5s --retries=3 \
55+
CMD pgrep -x openab || exit 1
56+
ENTRYPOINT ["openab"]
57+
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 = "/home/opencode"
161168
```
162169

163170
## Configuration Reference

config.toml.example

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,15 @@ 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+
# # Note: opencode handles tool authorization internally and never emits
34+
# # session/request_permission — all tools run without user confirmation,
35+
# # equivalent to --trust-all-tools on other backends.
36+
# # Run `opencode auth login` once before starting openab.
37+
2938
[pool]
3039
max_sessions = 10
3140
session_ttl_hours = 24

0 commit comments

Comments
 (0)