acp-bridge 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 allvegetable
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,285 @@
1
+ # ACP Bridge v0.3.0
2
+
3
+ A daemon + CLI for orchestrating ACP-compatible coding agents ([OpenCode](https://opencode.ai), [Codex CLI](https://github.com/openai/codex), [Claude CLI](https://docs.anthropic.com/en/docs/claude-cli), [Gemini CLI](https://github.com/google-gemini/gemini-cli)) with structured JSON-RPC, multi-agent task execution, and a built-in diagnostics system.
4
+
5
+ ## Why
6
+
7
+ If you orchestrate multiple AI coding agents, you've probably resorted to tmux `send-keys` / `capture-pane` hacks. That approach is:
8
+
9
+ - **Wasteful** - polling burns tokens on non-semantic terminal output
10
+ - **Fragile** - ANSI escape codes, progress bars, rendering artifacts
11
+ - **Blind** - no reliable way to know if an agent is idle, running, or waiting on approval
12
+
13
+ ACP Bridge replaces that with a stable HTTP API backed by the Agent Client Protocol (ACP).
14
+
15
+ ## How it works
16
+
17
+ ```text
18
+ You / Orchestrator
19
+ ↓ HTTP
20
+ ACP Bridge Daemon
21
+ ↓ JSON-RPC over stdio
22
+ opencode / codex / claude / gemini (ACP mode)
23
+
24
+ LLM API
25
+ ```
26
+
27
+ ## Installation
28
+
29
+ ```bash
30
+ # Global install (recommended)
31
+ npm install -g acp-bridge
32
+
33
+ # Or clone and build
34
+ git clone https://github.com/allvegetable/acp-bridge.git
35
+ cd acp-bridge
36
+ npm install && npm run build
37
+ ```
38
+
39
+ ## Quick Start
40
+
41
+ ```bash
42
+ # Install globally
43
+ npm install -g acp-bridge
44
+
45
+ # Global commands installed by npm
46
+ acp-bridge --help
47
+ acp-bridged --help
48
+
49
+ # Start daemon (foreground)
50
+ ACP_BRIDGE_PORT=7800 acp-bridged
51
+
52
+ # Or manage daemon in background
53
+ acp-bridge daemon start
54
+
55
+ # Start agents
56
+ acp-bridge --url http://127.0.0.1:7800 start opencode --name my-agent --cwd ~/my-project
57
+ acp-bridge --url http://127.0.0.1:7800 start codex --name codex-agent --cwd ~/my-project
58
+ acp-bridge --url http://127.0.0.1:7800 start claude --name claude-agent --cwd ~/my-project
59
+ acp-bridge --url http://127.0.0.1:7800 start gemini --name gemini-agent --cwd ~/my-project
60
+
61
+ # Ask, stream, inspect
62
+ acp-bridge --url http://127.0.0.1:7800 ask my-agent "refactor the auth module"
63
+ acp-bridge --url http://127.0.0.1:7800 ask my-agent --stream "refactor the auth module"
64
+ acp-bridge --url http://127.0.0.1:7800 status my-agent
65
+ acp-bridge --url http://127.0.0.1:7800 list
66
+
67
+ # Permission and session control
68
+ acp-bridge --url http://127.0.0.1:7800 approve my-agent
69
+ acp-bridge --url http://127.0.0.1:7800 deny my-agent
70
+ acp-bridge --url http://127.0.0.1:7800 cancel my-agent
71
+
72
+ # Stop agent / daemon
73
+ acp-bridge --url http://127.0.0.1:7800 stop my-agent
74
+ acp-bridge daemon status
75
+ acp-bridge daemon stop
76
+ ```
77
+
78
+ Default daemon address is `127.0.0.1:7800`.
79
+
80
+ Alternative local development flow:
81
+
82
+ ```bash
83
+ git clone https://github.com/allvegetable/acp-bridge.git
84
+ cd acp-bridge
85
+ npm install
86
+ npm run build
87
+ node dist/daemon.js
88
+ ```
89
+
90
+ ## Config File
91
+
92
+ Create `~/.config/acp-bridge/config.json`:
93
+
94
+ ```json
95
+ {
96
+ "port": 7800,
97
+ "host": "127.0.0.1",
98
+ "agents": {
99
+ "opencode": {
100
+ "command": "~/.opencode/bin/opencode",
101
+ "args": ["acp"],
102
+ "env": {
103
+ "OPENAI_API_KEY": "your-key",
104
+ "OPENAI_BASE_URL": "https://api.openai.com/v1"
105
+ }
106
+ },
107
+ "claude": {
108
+ "command": "claude-agent-acp",
109
+ "env": {
110
+ "ANTHROPIC_API_KEY": "your-key",
111
+ "ANTHROPIC_BASE_URL": "https://api.anthropic.com"
112
+ }
113
+ },
114
+ "codex": {
115
+ "command": "codex-acp",
116
+ "env": {
117
+ "OPENAI_API_KEY": "your-key"
118
+ }
119
+ },
120
+ "gemini": {
121
+ "command": "gemini",
122
+ "args": ["--experimental-acp"],
123
+ "env": {
124
+ "GEMINI_API_KEY": "your-key",
125
+ "GOOGLE_GEMINI_BASE_URL": "https://generativelanguage.googleapis.com"
126
+ }
127
+ }
128
+ }
129
+ }
130
+ ```
131
+
132
+ Environment variables like `ACP_BRIDGE_PORT` and `ACP_BRIDGE_HOST` still override config file values.
133
+
134
+ ## Supported Agents
135
+
136
+ | Agent | Status | Adapter | Notes |
137
+ |-------|--------|---------|-------|
138
+ | [OpenCode](https://opencode.ai) | ✅ Working | Native | `opencode acp` - built-in ACP support |
139
+ | [Codex CLI](https://github.com/openai/codex) | ✅ Working | [codex-acp](https://github.com/cola-io/codex-acp) | Third-party adapter, patched for Codex 0.101.0 |
140
+ | [Claude CLI](https://docs.anthropic.com/en/docs/claude-cli) | ✅ Working | [claude-agent-acp](https://www.npmjs.com/package/@zed-industries/claude-agent-acp) | Zed's official ACP adapter wrapping Claude Agent SDK |
141
+ | [Gemini CLI](https://github.com/google-gemini/gemini-cli) | ✅ Working | Native | `gemini --experimental-acp` - built-in ACP support |
142
+
143
+ ### Adapter Details
144
+
145
+ Each agent type uses a different path to speak ACP over stdio:
146
+
147
+ ```text
148
+ ┌─────────────┐ ┌──────────────────┐ ┌─────────┐
149
+ │ acp-bridge │────▶│ opencode acp │────▶│ LLM API │
150
+ │ daemon │ └──────────────────┘ └─────────┘
151
+ │ │ ┌──────────────────┐ ┌─────────┐
152
+ │ │────▶│ codex-acp │────▶│ OpenAI │
153
+ │ │ └──────────────────┘ └─────────┘
154
+ │ │ ┌──────────────────┐ ┌─────────┐
155
+ │ │────▶│ claude-agent-acp │────▶│Anthropic│
156
+ │ │ └──────────────────┘ └─────────┘
157
+ │ │ ┌──────────────────┐ ┌─────────┐
158
+ │ │────▶│ gemini --exp-acp │────▶│ Google │
159
+ └─────────────┘ └──────────────────┘ └─────────┘
160
+ ```
161
+
162
+ **OpenCode** - Native ACP. Just works with `opencode acp`.
163
+
164
+ **Codex CLI** - Uses [codex-acp](https://github.com/cola-io/codex-acp), a Rust adapter that wraps the Codex CLI library as an ACP agent. We pin to the `rust-v0.101.0` revision to match Codex CLI 0.101.0. The daemon tries `codex-acp` first, then falls back to `codex mcp-server`.
165
+
166
+ **Claude CLI** - Uses [@zed-industries/claude-agent-acp](https://www.npmjs.com/package/@zed-industries/claude-agent-acp) (v0.17.1), Zed's official adapter that wraps the Claude Agent SDK as a standard ACP agent. Install with `npm install -g @zed-industries/claude-agent-acp`. Note: this adapter uses ACP protocol version `1` (numeric) instead of the date-string format used by other agents - ACP Bridge handles both transparently.
167
+
168
+ Required environment variables for Claude:
169
+ ```bash
170
+ ANTHROPIC_API_KEY="your-key" # or use ANTHROPIC_AUTH_TOKEN
171
+ ANTHROPIC_BASE_URL="https://api.anthropic.com" # optional, for proxy/custom endpoints
172
+ ```
173
+
174
+ **Gemini CLI** - Native ACP support via `gemini --experimental-acp`. Install with `npm install -g @google/gemini-cli`. The daemon spawns `gemini --experimental-acp` over stdio. Like `claude-agent-acp`, it uses ACP protocol version `1` (numeric).
175
+
176
+ Required environment variables for Gemini:
177
+ ```bash
178
+ GEMINI_API_KEY="your-key"
179
+ GOOGLE_GEMINI_BASE_URL="https://generativelanguage.googleapis.com" # optional, for proxy
180
+ # Note: do NOT include /v1 suffix - the SDK appends /v1beta/ automatically
181
+ ```
182
+
183
+ ## API
184
+
185
+ The daemon exposes a REST API:
186
+
187
+ | Method | Path | Description |
188
+ |--------|------|-------------|
189
+ | `GET` | `/health` | Health check |
190
+ | `GET` | `/doctor` | Run system-wide diagnostics for all configured agent types |
191
+ | `POST` | `/agents` | Start a new agent |
192
+ | `GET` | `/agents` | List all agents |
193
+ | `GET` | `/agents/:name` | Get agent status |
194
+ | `POST` | `/agents/:name/ask` | Send prompt, wait for response |
195
+ | `POST` | `/agents/:name/ask?stream=true` | SSE stream chunks and final result |
196
+ | `POST` | `/agents/:name/approve` | Approve next pending permission request |
197
+ | `POST` | `/agents/:name/deny` | Deny next pending permission request |
198
+ | `POST` | `/agents/:name/cancel` | Cancel current session work (`session/cancel`) |
199
+ | `GET` | `/agents/:name/diagnose` | Deep health check for a running agent |
200
+ | `DELETE` | `/agents/:name` | Stop an agent |
201
+ | `POST` | `/tasks` | Create a task graph with one or more subtasks |
202
+ | `GET` | `/tasks` | List tasks |
203
+ | `GET` | `/tasks/:id` | Get task status and aggregate output |
204
+ | `GET` | `/tasks/:id/subtasks/:subtaskId` | Get one subtask status and output |
205
+ | `DELETE` | `/tasks/:id` | Cancel a running task |
206
+
207
+ ## Task System
208
+
209
+ Use tasks to run multiple subtasks in parallel or in dependency chains across agents.
210
+
211
+ Create a parallel task:
212
+
213
+ ```bash
214
+ acp-bridge task create '{"name":"ship-auth","subtasks":[{"id":"scan","agent":"codex-agent","prompt":"scan auth module for dead code"},{"id":"tests","agent":"claude-agent","prompt":"design edge-case tests for auth module"}]}'
215
+ ```
216
+
217
+ Create a dependency chain with `dependsOn` and `{{dep.result}}` templates:
218
+
219
+ ```bash
220
+ acp-bridge task create '{"name":"fix-and-verify","subtasks":[{"id":"analyze","agent":"my-agent","prompt":"find bug in session refresh flow"},{"id":"patch","agent":"my-agent","dependsOn":["analyze"],"prompt":"apply this fix: {{analyze.result}}"},{"id":"verify","agent":"codex-agent","dependsOn":["patch"],"prompt":"review and validate patch: {{patch.result}}"}]}'
221
+ ```
222
+
223
+ Task lifecycle:
224
+
225
+ - `running` - task/subtask is actively executing
226
+ - `done` - completed successfully
227
+ - `error` - failed; inspect error payload and diagnostics
228
+ - `cancelled` - cancelled by user or cascading cancellation
229
+
230
+ Task CLI commands:
231
+
232
+ ```bash
233
+ acp-bridge task create '{"name":"...","subtasks":[...]}'
234
+ acp-bridge task status <id>
235
+ acp-bridge task list
236
+ acp-bridge task cancel <id>
237
+ ```
238
+
239
+ ## Diagnostics
240
+
241
+ ACP Bridge includes runtime diagnostics and preflight validation to catch setup issues early.
242
+
243
+ - `acp-bridge doctor` - checks all configured agent types and reports readiness
244
+ - `GET /agents/:name/diagnose` - deep health check for a running agent process
245
+ - Preflight checks run on agent start (binary presence, config completeness, protocol compatibility, upstream connectivity)
246
+ - Error classification normalizes failures into stable codes for debugging and automation
247
+
248
+ Common error classes:
249
+
250
+ - `AUTH_INVALID` - API key invalid, expired, or rejected by provider/proxy
251
+ - `UPSTREAM_UNAVAILABLE` - provider/proxy unavailable (often HTTP 503)
252
+ - `CONNECTION_REFUSED` - daemon cannot reach configured base URL/endpoint
253
+ - `BINARY_NOT_FOUND` - required CLI/adapter executable missing in PATH
254
+ - `STREAM_TERMINATED` - upstream stream ended unexpectedly without finish reason
255
+ - `PROTOCOL_MISMATCH` - ACP protocol version mismatch between bridge and agent
256
+
257
+ ## Troubleshooting
258
+
259
+ - **"API key invalid or expired"**: verify the key, and if using a proxy ensure provider-specific key format is accepted by that proxy.
260
+ - **"Service unavailable (503)"**: your proxy/provider likely has no available channels/capacity; retry later or switch endpoint.
261
+ - **"Connection refused"**: check `--url` and configured base URLs (`OPENAI_BASE_URL`, `ANTHROPIC_BASE_URL`, `GOOGLE_GEMINI_BASE_URL`).
262
+ - **"binary not found"**: install the agent CLI/adapter and confirm it is in PATH.
263
+ - **"Model stream ended without finish reason"**: usually an upstream proxy/provider stream issue, not local ACP Bridge config.
264
+ - **"protocol mismatch"**: upgrade ACP Bridge and the relevant agent adapter so protocol versions are compatible.
265
+ - Use `acp-bridge doctor` first, then call `GET /agents/:name/diagnose` for deep checks on a running agent.
266
+
267
+ ## Roadmap
268
+
269
+ - [x] Phase 1: Daemon + CLI + OpenCode support
270
+ - [x] Phase 2: Codex, Claude, Gemini support + permission/session controls
271
+ - [x] Phase 3: Parallel multi-agent tasks, dependency chains, task lifecycle APIs and CLI
272
+ - [x] Phase 4: Diagnostics, npm publish, documentation updates
273
+ - [ ] Future: OpenClaw skill integration
274
+ - [ ] Future: Web UI
275
+
276
+ ## Related
277
+
278
+ - [ACP Protocol](https://agentclientprotocol.com) - The standard this project builds on
279
+ - [agent-team](https://github.com/nekocode/agent-team) - Multi-agent CLI orchestrator (standalone)
280
+ - [codex-acp](https://github.com/cola-io/codex-acp) - Codex CLI ACP adapter (Rust)
281
+ - [claude-agent-acp](https://www.npmjs.com/package/@zed-industries/claude-agent-acp) - Claude CLI ACP adapter by Zed Industries
282
+
283
+ ## License
284
+
285
+ MIT