@agentrq/acp-gateway 0.3.1 → 0.4.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/README.md +59 -169
- package/dist/__tests__/agentInfo.test.js +2 -31
- package/dist/__tests__/agentInfo.test.js.map +1 -1
- package/dist/__tests__/concurrency.test.js +1 -74
- package/dist/__tests__/concurrency.test.js.map +1 -1
- package/dist/__tests__/index.test.js +190 -2672
- package/dist/__tests__/index.test.js.map +1 -1
- package/dist/__tests__/localClient.test.js +100 -0
- package/dist/__tests__/localClient.test.js.map +1 -0
- package/dist/__tests__/log.test.js +1 -42
- package/dist/__tests__/log.test.js.map +1 -1
- package/dist/__tests__/mcpServers.test.js +62 -0
- package/dist/__tests__/mcpServers.test.js.map +1 -0
- package/dist/__tests__/models.test.js +2 -18
- package/dist/__tests__/models.test.js.map +1 -1
- package/dist/__tests__/native.test.js +294 -29
- package/dist/__tests__/native.test.js.map +1 -1
- package/dist/__tests__/nativeFrames.test.js +132 -4
- package/dist/__tests__/nativeFrames.test.js.map +1 -1
- package/dist/__tests__/nativeHeaders.test.js +34 -0
- package/dist/__tests__/nativeHeaders.test.js.map +1 -1
- package/dist/agentInfo.js +0 -31
- package/dist/agentInfo.js.map +1 -1
- package/dist/concurrency.js +6 -64
- package/dist/concurrency.js.map +1 -1
- package/dist/index.js +114 -1729
- package/dist/index.js.map +1 -1
- package/dist/localClient.js +91 -0
- package/dist/localClient.js.map +1 -0
- package/dist/log.js +0 -22
- package/dist/log.js.map +1 -1
- package/dist/mcpServers.js +60 -0
- package/dist/mcpServers.js.map +1 -0
- package/dist/models.js +0 -10
- package/dist/models.js.map +1 -1
- package/dist/native.js +243 -30
- package/dist/native.js.map +1 -1
- package/dist/nativeFrames.js +114 -12
- package/dist/nativeFrames.js.map +1 -1
- package/package.json +4 -6
- package/dist/__tests__/acpClient.test.js +0 -2346
- package/dist/__tests__/acpClient.test.js.map +0 -1
- package/dist/__tests__/collections.test.js +0 -116
- package/dist/__tests__/collections.test.js.map +0 -1
- package/dist/__tests__/commands.test.js +0 -92
- package/dist/__tests__/commands.test.js.map +0 -1
- package/dist/__tests__/mcpClient.test.js +0 -558
- package/dist/__tests__/mcpClient.test.js.map +0 -1
- package/dist/__tests__/taskIdentity.test.js +0 -63
- package/dist/__tests__/taskIdentity.test.js.map +0 -1
- package/dist/__tests__/telemetry.test.js +0 -151
- package/dist/__tests__/telemetry.test.js.map +0 -1
- package/dist/acpClient.js +0 -1112
- package/dist/acpClient.js.map +0 -1
- package/dist/collections.js +0 -105
- package/dist/collections.js.map +0 -1
- package/dist/commands.js +0 -60
- package/dist/commands.js.map +0 -1
- package/dist/mcpClient.js +0 -361
- package/dist/mcpClient.js.map +0 -1
- package/dist/taskIdentity.js +0 -41
- package/dist/taskIdentity.js.map +0 -1
- package/dist/telemetry.js +0 -106
- package/dist/telemetry.js.map +0 -1
package/README.md
CHANGED
|
@@ -4,23 +4,21 @@ Agent Client Protocol Gateway to remotely access your agents in AgentRQ.
|
|
|
4
4
|
|
|
5
5
|
## Overview
|
|
6
6
|
|
|
7
|
-
`@agentrq/acp-gateway`
|
|
7
|
+
`@agentrq/acp-gateway` connects an [Agent Client Protocol (ACP)](https://agentclientprotocol.com) agent (e.g., Gemini, Codex) to an agentrq workspace. AgentRQ speaks ACP v1 itself; the gateway runs the agent on your machine and pipes its ACP stream to AgentRQ over a WebSocket.
|
|
8
8
|
|
|
9
|
-
It
|
|
9
|
+
It:
|
|
10
10
|
|
|
11
|
-
1.
|
|
12
|
-
2.
|
|
13
|
-
3.
|
|
14
|
-
4.
|
|
15
|
-
5. Providing file read/write capabilities through the ACP protocol.
|
|
16
|
-
6. Auto-reconnecting the MCP transport on disconnection.
|
|
11
|
+
1. Reads your workspace's `.mcp.json` for the AgentRQ server's URL and token.
|
|
12
|
+
2. Starts the agent — a command you give, or one from the ACP registry.
|
|
13
|
+
3. Pipes the agent's stdio to AgentRQ's `/api/acp/v1` endpoint, line for line, without parsing it.
|
|
14
|
+
4. Resumes dropped connections and restarts an agent that dies.
|
|
17
15
|
|
|
18
16
|
## Prerequisites
|
|
19
17
|
|
|
20
|
-
- **Node.js** >=
|
|
18
|
+
- **Node.js** >= 22
|
|
21
19
|
- **npm** or **yarn**
|
|
22
20
|
- An [ACP-compatible agent](https://agentclientprotocol.com) (e.g., Gemini CLI)
|
|
23
|
-
- An [agentrq](https://agentrq.com/?utm_source=github) workspace
|
|
21
|
+
- An [agentrq](https://agentrq.com/?utm_source=github) workspace whose server offers ACP v1 (`/api/acp/v1`)
|
|
24
22
|
|
|
25
23
|
## Installation
|
|
26
24
|
|
|
@@ -37,7 +35,7 @@ npm install -g @agentrq/acp-gateway
|
|
|
37
35
|
|
|
38
36
|
## Current Version
|
|
39
37
|
|
|
40
|
-
`0.
|
|
38
|
+
`0.4.0`
|
|
41
39
|
|
|
42
40
|
## Usage
|
|
43
41
|
|
|
@@ -65,17 +63,18 @@ You can specify gateway options before the `--` separator:
|
|
|
65
63
|
- `--list-agents`: Prints every agent in the registry and how each one can run on this machine, then exits.
|
|
66
64
|
- `--list-models`: Prints the models supported by the agent, then exits.
|
|
67
65
|
- `--model <model-id>`: Selects the model a session starts on. It can be changed while running from the agentrq interface.
|
|
66
|
+
- `--effort <level>`: Selects the agent's initial reasoning effort level (e.g. `low`, `medium`, `high`).
|
|
68
67
|
- `--allow-unverified-agent`: Installs a registry binary that publishes no checksum. Off by default.
|
|
69
68
|
- `--registry-url <url>`: Reads a different registry index (for pinning, or for testing).
|
|
70
69
|
- `--mcp-json <path>`: Reads an MCP config in addition to the one found near the working directory, so the gateway can run from outside its workspace. The path is to the file itself and the filename need not be `.mcp.json`; a directory is taken to mean the `.mcp.json` inside it. Where both files define a server under the same name, the one named here wins. A path that cannot be read is an error rather than a quiet fall back to the directory.
|
|
71
70
|
- `--auth-method <id>`: The authentication method to use when the agent asks for a login. Defaults to picking one automatically.
|
|
72
|
-
- `--verbose`: Prints everything —
|
|
71
|
+
- `--verbose`: Prints everything — the connection to AgentRQ, the agent's own logs, and what the one-shot commands exchange with the agent. Without it the gateway only prints warnings and errors; the agent's logs are kept back and shown only if it fails. Commands that print something and exit, like `--list-models`, print just that.
|
|
73
72
|
- `--help` / `-h`: Explains every option, with examples. Also shown when `acp-gateway` is run with nothing to do.
|
|
74
73
|
- `--list-auth-methods`: Prints the login methods the agent advertises, then exits.
|
|
75
74
|
- `--login [method-id]`: Logs in to the agent, then exits.
|
|
76
75
|
- `--logout`: Ends the agent's authenticated state, then exits (only for agents that support logout).
|
|
77
|
-
- `--acp-
|
|
78
|
-
- `--acp-
|
|
76
|
+
- `--acp-url <url>`: The ACP endpoint, for a deployment where it cannot be worked out from `.mcp.json`.
|
|
77
|
+
- `--acp-version 1`: Still accepted so existing launch scripts keep working, but it changes nothing: ACP v1 is the only protocol. Any other version is refused.
|
|
79
78
|
|
|
80
79
|
Example:
|
|
81
80
|
```bash
|
|
@@ -181,7 +180,9 @@ Credentials are never stored by the gateway; the agent keeps its own, exactly as
|
|
|
181
180
|
|
|
182
181
|
`acp-gateway` searches for `.mcp.json` starting in the current working directory and up to 3 parent directories.
|
|
183
182
|
|
|
184
|
-
|
|
183
|
+
The gateway connects to the AgentRQ server's `/api/acp/v1` endpoint, using its `url` (and `?token=`) or `Authorization: Bearer` header — not to the MCP server itself. Every server in the file, the AgentRQ one included, is also handed to the agent in each session it opens, so it can use them as MCP tools.
|
|
184
|
+
|
|
185
|
+
`--list-models`, `--agent-info`, `--list-auth-methods`, `--login` and `--logout` only deal with the agent itself, so they never read a workspace config. `--list-models` runs the agent in an empty temporary directory, so the agent does not pick up the workspace's `.mcp.json` and get taken for the workspace's agent.
|
|
185
186
|
|
|
186
187
|
`--mcp-json <path>` names a config directly, wherever it lives and whatever it is called. It is read *as well as* whatever the search finds, with the named file winning any name collision — so a gateway started from somewhere other than its workspace still connects to the right one.
|
|
187
188
|
|
|
@@ -192,7 +193,7 @@ Example `.mcp.json`:
|
|
|
192
193
|
"mcpServers": {
|
|
193
194
|
"agentrq": {
|
|
194
195
|
"type": "http",
|
|
195
|
-
"url": "
|
|
196
|
+
"url": "https://<workspace>.mcp.agentrq.com/?token=<token>"
|
|
196
197
|
}
|
|
197
198
|
}
|
|
198
199
|
}
|
|
@@ -200,149 +201,68 @@ Example `.mcp.json`:
|
|
|
200
201
|
|
|
201
202
|
`acp-gateway` prefers servers with `agentrq` in the name; it falls back to the first HTTP server with a `url`.
|
|
202
203
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
`--max-concurrency` is the limit the gateway boots with. The workspace can change it on a gateway that is
|
|
206
|
-
already running — raising it to get through a backlog, or lowering it to drain one — without a restart that
|
|
207
|
-
would drop every session the gateway holds.
|
|
208
|
-
|
|
209
|
-
The workspace sends:
|
|
210
|
-
|
|
211
|
-
```json
|
|
212
|
-
{
|
|
213
|
-
"method": "notifications/claude/channel/set_concurrency",
|
|
214
|
-
"params": { "maxConcurrency": 4 }
|
|
215
|
-
}
|
|
216
|
-
```
|
|
217
|
-
|
|
218
|
-
This pair of notifications is camelCase, unlike the older snake_case messages on the same channel — it is new
|
|
219
|
-
enough to have no client spelling it the other way, so it carries one spelling rather than two.
|
|
220
|
-
|
|
221
|
-
The value may be a string. A value of any other shape — `null`, a boolean, an object — is accepted at the
|
|
222
|
-
door and refused downstream, so that it can still be answered; a notification dropped for being malformed
|
|
223
|
-
would be a notification the gateway never replied to. A payload that names no `maxConcurrency` at all reads
|
|
224
|
-
as absent and is answered with the limit still in force, so a mistaken sender sees an unchanged limit come
|
|
225
|
-
back rather than silence.
|
|
226
|
-
|
|
227
|
-
The gateway reports the limit in force on `notifications/claude/channel/concurrency` — on connect, on every
|
|
228
|
-
reconnect, and after every `set_concurrency`:
|
|
204
|
+
## How It Works
|
|
229
205
|
|
|
230
|
-
```json
|
|
231
|
-
{
|
|
232
|
-
"maxConcurrency": 4,
|
|
233
|
-
"active": 2,
|
|
234
|
-
"queued": 3,
|
|
235
|
-
"min": 1,
|
|
236
|
-
"max": 64,
|
|
237
|
-
"canSet": true
|
|
238
|
-
}
|
|
239
206
|
```
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
to change; versions before it report a limit and ignore the instruction, so a client should treat the flag's
|
|
244
|
-
absence as no.
|
|
245
|
-
|
|
246
|
-
Two things worth knowing about how a change lands:
|
|
247
|
-
|
|
248
|
-
- **Raising** takes effect at once — every waiting task the new headroom allows starts immediately, rather
|
|
249
|
-
than one per completion.
|
|
250
|
-
- **Lowering** never interrupts a task already in flight. Those keep the agent's attention and finish; the
|
|
251
|
-
queue simply stops handing out new ones until enough have. So `active` may exceed `maxConcurrency` for a
|
|
252
|
-
while after a lower, which is expected rather than an error.
|
|
253
|
-
|
|
254
|
-
The limit lives in memory. It survives MCP reconnects but not a gateway restart, which falls back to
|
|
255
|
-
`--max-concurrency`. A workspace that wants the setting to stick should store it and re-send it on connect.
|
|
256
|
-
|
|
257
|
-
`--max-concurrency` goes through the same reader, so the flag and the interface cannot disagree about what a
|
|
258
|
-
number means. Nothing reports a flag back to the person who typed it, so unlike the workspace's path the
|
|
259
|
-
gateway says out loud on startup when a flag value was capped or could not be read.
|
|
260
|
-
|
|
261
|
-
### Native Mode (AgentRQ Speaks ACP)
|
|
262
|
-
|
|
263
|
-
```bash
|
|
264
|
-
acp-gateway --acp-version 1 --agent codex-acp
|
|
265
|
-
acp-gateway --acp-version 1 -- your-acp-agent --flag1
|
|
207
|
+
┌─────────────┐ ACP v1 (stdio) ┌─────────────┐ ACP v1 (WebSocket) ┌─────────────────────┐
|
|
208
|
+
│ ACP Agent │ ◄────────────────► │ acp-gateway │ ◄────────────────────► │ AgentRQ /api/acp/v1 │
|
|
209
|
+
└─────────────┘ └─────────────┘ └─────────────────────┘
|
|
266
210
|
```
|
|
267
211
|
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
- **Where it connects.**
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
212
|
+
AgentRQ is the ACP client and the gateway translates nothing. It starts the agent (a registry id or the command
|
|
213
|
+
after `--`) and moves lines: each line the agent writes becomes one WebSocket text frame to AgentRQ, and each
|
|
214
|
+
frame AgentRQ sends becomes one line on the agent's stdin. It reads only the JSON-RPC envelope, for the working
|
|
215
|
+
directory and to keep the agent across a new connection (below).
|
|
216
|
+
|
|
217
|
+
- **Where it connects.** The endpoint is the AgentRQ server's own origin with the path `/api/acp/v1`, over
|
|
218
|
+
`wss://` for an `https://` server and `ws://` for `http://`. The workspace token is the URL's `?token=` or the
|
|
219
|
+
entry's `Authorization: Bearer` header. `--acp-url` names the endpoint outright.
|
|
220
|
+
- **The agent gets the workspace's MCP servers.** Every server in `.mcp.json` (and any config named with
|
|
221
|
+
`--mcp-json`) is handed to each session the agent opens — `session/new`, `session/load` and `session/resume` —
|
|
222
|
+
ahead of what AgentRQ offers, so the agent can use them as tools exactly as it did under the MCP bridge. A
|
|
223
|
+
transport the agent says it cannot take is left out; one it says nothing about is passed. Where AgentRQ offers a
|
|
224
|
+
server with the same name as one in `.mcp.json`, the `.mcp.json` one is used.
|
|
225
|
+
- **The agent works in this directory.** Sessions always open in the gateway's own working directory: whatever
|
|
226
|
+
directory AgentRQ names in `session/new`, `session/load` or `session/resume` is replaced with it. AgentRQ is told
|
|
227
|
+
the directory in the `X-AgentRQ-Cwd` header, percent-encoded (UTF-8) wherever it is not plain ASCII, since a
|
|
228
|
+
header cannot carry anything else.
|
|
277
229
|
- **Before connecting** it sends a plain `GET` with the token, so a problem is named rather than retried for ever:
|
|
278
230
|
an old server without the endpoint (404), a bad token (401/403, with the server's reason), or a proxy that does
|
|
279
231
|
not pass `Upgrade` for `/api/acp/`. Each of these exits 1.
|
|
280
|
-
- **Options travel as headers.** `--agent`, `--model`, `--max-concurrency`, `--permission-timeout` and
|
|
232
|
+
- **Options travel as headers.** `--agent`, `--model`, `--effort`, `--max-concurrency`, `--permission-timeout` and
|
|
281
233
|
`--auth-method` reach AgentRQ in the WebSocket handshake, along with the working directory every session runs in.
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
234
|
+
AgentRQ applies them, and can change the concurrency limit and model while running.
|
|
235
|
+
- **Dropped connections resume.** The gateway reconnects with backoff (1 s doubling to 60 s), for as long as it
|
|
236
|
+
takes, and AgentRQ keeps the connection for two minutes. Within that time nothing is lost or repeated: each side
|
|
237
|
+
replays what the other had not acknowledged, up to 1,024 frames or 8 MiB.
|
|
238
|
+
- **Longer outages keep the agent.** After a server restart, a deploy or an outage past those two minutes, AgentRQ
|
|
239
|
+
starts a new connection, and the same agent process serves it: its `initialize` is answered from the agent's
|
|
240
|
+
first handshake, the turns that were running are cancelled and the agent's unanswered requests are answered as
|
|
241
|
+
abandoned. Each task's conversation carries on: a prompt for a task (recognised by the `[Task <id>]` header
|
|
242
|
+
AgentRQ starts it with) goes to the session that task already had, under whatever id the new connection gave it.
|
|
243
|
+
The agent is identified to AgentRQ by `X-AgentRQ-Agent-Instance`, which stays the same for as long as it runs.
|
|
285
244
|
- **A dead agent is restarted** after 2 s, doubling to a minute. After five exits within five minutes the gateway
|
|
286
245
|
gives up and exits 1 with the agent's last output.
|
|
287
|
-
- **
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
## How It Works
|
|
295
|
-
|
|
296
|
-
```
|
|
297
|
-
┌─────────────┐ ACP (JSON-RPC) ┌──────────────────┐
|
|
298
|
-
│ ACP Agent │ ◄─────────────────────────► │ │
|
|
299
|
-
│ (Gemini) │ │ acp-gateway │
|
|
300
|
-
└─────────────┘ │ │
|
|
301
|
-
│ MCP Bridge │
|
|
302
|
-
│ │
|
|
303
|
-
┌─────────────────────────────────────────────┤ │
|
|
304
|
-
│ │ │
|
|
305
|
-
│ │ │
|
|
306
|
-
│ ▼ │
|
|
307
|
-
│ ┌──────────────────────────┐ │
|
|
308
|
-
│ │ agentrq MCP Server │ │
|
|
309
|
-
│ │ (HTTP / StreamableHTTP) │ │
|
|
310
|
-
│ └──────────────────────────┘ │
|
|
311
|
-
└────────────────────────────────────────────────────────────────┘
|
|
312
|
-
```
|
|
313
|
-
|
|
314
|
-
### Flow
|
|
315
|
-
|
|
316
|
-
1. **Config Loading** — Reads `.mcp.json` to find the agentrq MCP server.
|
|
317
|
-
2. **MCP Connection** — Establishes a `StreamableHTTPClientTransport` to the MCP server with automatic retry and reconnection.
|
|
318
|
-
3. **Agent Spawning** — Launches the specified ACP agent as a subprocess with stdio piping.
|
|
319
|
-
4. **ACP Handshake** — Initializes the ACP connection.
|
|
320
|
-
5. **Task Bridge & Multi-Session Isolation** — When a task is received from the MCP server:
|
|
321
|
-
- `acp-gateway` extracts the `chat_id` (Task ID).
|
|
322
|
-
- It checks if the task content is a duplicate of the last processed task for this Task ID. If it is repetitive, the task is dropped to prevent redundant processing.
|
|
323
|
-
- If not repetitive, the task is added to a concurrency-limiting queue (honoring the current concurrency limit — `--max-concurrency` at startup, or whatever the workspace has since set).
|
|
324
|
-
- It ensures a dedicated ACP session for that specific task. A task delivered twice at once joins the session already being opened for it rather than spawning a second agent, and the agent is fully handshaken and authenticated before it is ever prompted.
|
|
325
|
-
- A second delivery of a task that is already mid-turn waits for that turn to finish. A session takes one turn at a time, and because agentrq reuses a chat's id as the task id, two messages sent to one chat arrive as two deliveries of one task — so they are run in order rather than at once, and neither is dropped.
|
|
326
|
-
- If the task belongs to a different session than the current one, a new ACP session is initialized, providing clean state isolation between concurrent or sequential tasks.
|
|
327
|
-
6. **Permission Bridge** — Permission requests from the ACP agent are forwarded to the MCP server; verdicts are sent back.
|
|
328
|
-
7. **Concurrency Control** — The gateway reports its queue limit to the workspace on connect and on every reconnect, and applies a new limit whenever the workspace sends one (see below).
|
|
329
|
-
8. **Recursive Execution** — After each task completes, `acp-gateway` checks for the next pending task automatically.
|
|
246
|
+
- **A login AgentRQ cannot run** (a terminal login) is run here when the gateway has a terminal — a shell, or
|
|
247
|
+
agentrqd's browser terminal: the agent is stopped, logged in, started again, and the gateway reconnects. Without
|
|
248
|
+
a terminal, or when the agent asks again straight after a login, it stops with AgentRQ's instructions.
|
|
249
|
+
- **Errors that a retry cannot fix** (an agent that speaks a different ACP version) are printed and exit 1.
|
|
250
|
+
- `--login`, `--logout`, `--list-models`, `--list-auth-methods` and `--agent-info` talk to the agent locally and
|
|
251
|
+
exit; they never connect to AgentRQ.
|
|
330
252
|
|
|
331
253
|
### Key Components
|
|
332
254
|
|
|
333
255
|
| File | Description |
|
|
334
256
|
|---|---|
|
|
335
|
-
| `src/index.ts` | Entry point
|
|
336
|
-
| `src/
|
|
337
|
-
| `src/
|
|
257
|
+
| `src/index.ts` | Entry point: options, the one-shot commands, and starting the bridge. |
|
|
258
|
+
| `src/native.ts` | Runs the agent and pipes its stdio to AgentRQ's WebSocket, with resume, reconnect and respawn. |
|
|
259
|
+
| `src/nativeFrames.ts` | The bridge's pure parts: line splitting, control frames, the replay ring, the endpoint and headers. |
|
|
260
|
+
| `src/localClient.ts` | The ACP client the one-shot commands use; puts a login URL to the person at the terminal. |
|
|
338
261
|
| `src/config.ts` | Parses `.mcp.json` from the current directory tree up to 3 levels deep, plus any config named with `--mcp-json`. |
|
|
339
|
-
| `src/concurrency.ts` | How many tasks may prompt the agent at once, and the notifications that change it while the gateway runs. |
|
|
340
262
|
| `src/auth.ts` | ACP authentication — lists the agent's login methods, detects `auth_required`, and runs agent or terminal logins. |
|
|
341
263
|
| `src/registry.ts` | Reads the ACP registry index — agent lookup, host platform matching, and package launch commands. |
|
|
342
264
|
| `src/agentInstall.ts` | Downloads, verifies, unpacks and caches a registry agent's binary distribution. |
|
|
343
265
|
| `src/progress.ts` | Draws the single-line download progress bar, on a terminal and nowhere else. |
|
|
344
|
-
| `src/native.ts` | Native mode: runs the agent and pipes its stdio to AgentRQ's WebSocket, with resume, reconnect and respawn. |
|
|
345
|
-
| `src/nativeFrames.ts` | Native mode's pure parts: line splitting, control frames, the replay ring, the endpoint and headers. |
|
|
346
266
|
|
|
347
267
|
## Development
|
|
348
268
|
|
|
@@ -359,40 +279,10 @@ npm run typecheck
|
|
|
359
279
|
npm test
|
|
360
280
|
```
|
|
361
281
|
|
|
362
|
-
### Project Structure
|
|
363
|
-
|
|
364
|
-
```
|
|
365
|
-
acp-gateway/
|
|
366
|
-
├── src/
|
|
367
|
-
│ ├── acpClient.ts # ACP Client implementation
|
|
368
|
-
│ ├── agentInstall.ts # Registry binary download / verify / cache
|
|
369
|
-
│ ├── auth.ts # ACP authentication (login / logout)
|
|
370
|
-
│ ├── config.ts # .mcp.json loader
|
|
371
|
-
│ ├── index.ts # Entry point & orchestrator
|
|
372
|
-
│ ├── mcpClient.ts # MCP Bridge with auto-reconnect
|
|
373
|
-
│ ├── native.ts # Native mode byte bridge (--acp-version)
|
|
374
|
-
│ ├── nativeFrames.ts # Native mode frames, replay ring, headers
|
|
375
|
-
│ ├── progress.ts # Download progress bar
|
|
376
|
-
│ ├── registry.ts # ACP registry index client
|
|
377
|
-
│ ├── telemetry.ts # Thought / plan / usage rendering
|
|
378
|
-
│ └── __tests__/ # Unit tests
|
|
379
|
-
├── package.json
|
|
380
|
-
└── tsconfig.json
|
|
381
|
-
```
|
|
382
|
-
|
|
383
282
|
### Architecture Notes
|
|
384
283
|
|
|
385
|
-
- **Auto-reconnection**: The MCP transport auto-reconnects on disconnection with exponential backoff (1s → 30s max).
|
|
386
|
-
- **Notification-driven tasks**: The MCP server pushes task content via `notifications/claude/channel`; `acp-gateway` reacts immediately.
|
|
387
|
-
- **Permission flow**: ACP agent requests permission → `acp-gateway` forwards to MCP server → waits for verdict → resolves the ACP permission. Tool calls served by the workspace itself — replying, moving a task on, reading or writing workspace memory — are approved without asking, since the workspace is where the question would be put. Recognising one takes both halves of the call: an `agentrq` server in the title's server position, and a tool name the server actually advertised on connect. So a tool the workspace adds later is covered without a release here, while a look-alike server cannot have its whole surface waved through.
|
|
388
|
-
- **Streaming telemetry**: Reasoning, execution plans and token/cost counters are forwarded on `notifications/claude/channel/telemetry`. Reasoning is batched into one block per boundary (the agent starts answering, calls a tool, or revises its plan) rather than one message per token; plans go out as they change; only the last usage snapshot of a turn is reported. Sends are queued off the ACP stream, so a workspace that is slow or unreachable never stalls the agent.
|
|
389
|
-
- **Capabilities before the first task**: The gateway opens one ACP session before it connects to the workspace, so a workspace can say which model an agent is on, which models it offers and which slash commands it accepts — none of which exist outside a session, and ACP has no way to ask for them outside one. That session is handed to the first task rather than left running beside it, and it is opened before the workspace connection so a task can never be handed to a gateway whose agent is not ready yet. An agent that demands authentication stops and waits here, which is much of the point: the terminal you just typed into is where you can answer. If that login cannot happen — refused, or headless with nobody to ask — the gateway exits rather than sitting there looking connected and failing every task it is given. Any other startup failure is survived, and the first task tries again as before.
|
|
390
|
-
- **Agent identity**: Which agent is behind the gateway is sent to the workspace on `notifications/claude/channel/agent`. A registry id is named as soon as the workspace connection is up — the registry knows the agent before it has been started — and the agent's own name for itself, from its `initialize` handshake, replaces it once a session exists. Without it a workspace can only name its MCP client, which for anything reached through here is `acp-gateway` — the bridge rather than the agent. An agent that supplies no `agentInfo` is named by how it was launched, since that is the only name available and it beats none.
|
|
391
|
-
- **Model selection**: The models an agent offers go to the workspace on `notifications/claude/channel/models`, and one can be chosen from the interface: the workspace sends back `notifications/claude/channel/set_model` and the gateway writes it to the agent's session config. Every report carries `can_set: true`, which is what tells a workspace a picker would do something — it cannot be inferred, since gateways before this release also report their models and ignore being told to change one, and the MCP client name is `acp-gateway` on both sides of that line. What comes back is always the agent's own answer: a switch it refuses, or a model it never offered, is reported as the list that is still true, so the interface reverts rather than showing a model nothing adopted. That holds even for a session that has already ended — what each session was last on is remembered past the agent that served it, so a choice made a moment too late is answered rather than left pending. `--model` remains the starting model; a choice made while running overrides it for that session without rewriting any config.
|
|
392
|
-
- **Slash commands**: The commands an agent advertises with `available_commands_update` (`/init`, `/compact`, `/review`, …) are forwarded to the workspace on `notifications/claude/channel/commands`, so its composer can offer them. The list is replaced each time the agent sends one, and an empty list is forwarded too — that is how an agent withdraws its commands. Running one needs nothing special here: ACP carries a command as ordinary prompt text, and prompt content reaches the agent verbatim.
|
|
393
284
|
- **Registry agents**: `--agent <id>` resolves through the registry index; package distributions are preferred over binaries, and a binary without a published `sha256` is refused unless explicitly allowed.
|
|
394
285
|
- **Authentication**: Login methods come from the `initialize` handshake; an `auth_required` refusal triggers a login and one retry of `newSession`.
|
|
395
|
-
- **File I/O**: `readTextFile` / `writeTextFile` are proxied directly to the filesystem; paths are resolved relative to `process.cwd()`. Reads honour the optional 1-based `line` and `limit` bounds, returning only the requested window of the file.
|
|
396
286
|
|
|
397
287
|
## Contributing
|
|
398
288
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { describe, it, expect
|
|
2
|
-
import {
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
|
2
|
+
import { agentIdentity, describeAgentInfo, } from "../agentInfo.js";
|
|
3
3
|
/** A minimal initialize response, with only what a test cares about set. */
|
|
4
4
|
function initResult(overrides = {}) {
|
|
5
5
|
return { protocolVersion: 1, ...overrides };
|
|
@@ -108,34 +108,5 @@ describe('agentIdentity', () => {
|
|
|
108
108
|
expect(agentIdentity({ agentInfo: { name: 'gemini' } }, 'x')).toEqual({ name: 'gemini' });
|
|
109
109
|
expect(agentIdentity({ agentInfo: { name: 'gemini', title: ' ', version: ' ' } }, 'x')).toEqual({ name: 'gemini' });
|
|
110
110
|
});
|
|
111
|
-
it('publishes the channel the workspace listens on', () => {
|
|
112
|
-
expect(AGENT_NOTIFICATION_METHOD).toBe('notifications/claude/channel/agent');
|
|
113
|
-
});
|
|
114
|
-
});
|
|
115
|
-
describe('sendAgentIdentity', () => {
|
|
116
|
-
const bridge = () => ({ sendNotification: vi.fn().mockResolvedValue(undefined) });
|
|
117
|
-
it('names the agent with no task and no session, which is how startup sends it', async () => {
|
|
118
|
-
// The workspace keys this to the connection it arrived on, so neither id is
|
|
119
|
-
// needed — and requiring one is what would keep a workspace ignorant of its
|
|
120
|
-
// agent until somebody gave it work.
|
|
121
|
-
const b = bridge();
|
|
122
|
-
const quiet = vi.spyOn(console, 'error').mockImplementation(() => { });
|
|
123
|
-
await sendAgentIdentity(b, { name: 'Google Antigravity', version: '1.1.1' });
|
|
124
|
-
expect(b.sendNotification).toHaveBeenCalledWith('notifications/claude/channel/agent', {
|
|
125
|
-
task_id: '',
|
|
126
|
-
session_id: '',
|
|
127
|
-
name: 'Google Antigravity',
|
|
128
|
-
title: undefined,
|
|
129
|
-
version: '1.1.1',
|
|
130
|
-
});
|
|
131
|
-
quiet.mockRestore();
|
|
132
|
-
});
|
|
133
|
-
it('never throws, so a workspace that cannot take it costs the agent nothing', async () => {
|
|
134
|
-
const b = { sendNotification: vi.fn().mockRejectedValue(new Error('unreachable')) };
|
|
135
|
-
const quiet = vi.spyOn(console, 'error').mockImplementation(() => { });
|
|
136
|
-
await expect(sendAgentIdentity(b, { name: 'codex' })).resolves.toBeUndefined();
|
|
137
|
-
expect(quiet).toHaveBeenCalledWith(expect.stringContaining('Failed to send agent notification:'), expect.anything());
|
|
138
|
-
quiet.mockRestore();
|
|
139
|
-
});
|
|
140
111
|
});
|
|
141
112
|
//# sourceMappingURL=agentInfo.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agentInfo.test.js","sourceRoot":"","sources":["../../src/__tests__/agentInfo.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"agentInfo.test.js","sourceRoot":"","sources":["../../src/__tests__/agentInfo.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAM,MAAM,QAAQ,CAAC;AAClD,OAAO,EACL,aAAa,EACb,iBAAiB,GAClB,MAAM,iBAAiB,CAAC;AAEzB,4EAA4E;AAC5E,SAAS,UAAU,CAAC,SAAS,GAA4B,EAAE;IACzD,OAAO,EAAE,eAAe,EAAE,CAAC,EA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AAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,EAAS,EAAE,GAAG,CAAC,CACzF,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAA;IAC/B,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
|
|
2
|
-
import {
|
|
2
|
+
import { MAX_MAX_CONCURRENCY, MIN_MAX_CONCURRENCY, normalizeConcurrency, } from "../concurrency.js";
|
|
3
3
|
describe("concurrency", () => {
|
|
4
4
|
let errorSpy;
|
|
5
5
|
beforeEach(() => {
|
|
@@ -8,12 +8,6 @@ describe("concurrency", () => {
|
|
|
8
8
|
afterEach(() => {
|
|
9
9
|
errorSpy.mockRestore();
|
|
10
10
|
});
|
|
11
|
-
describe("notification methods", () => {
|
|
12
|
-
it("sits on the same channel as the rest of the workspace directives", () => {
|
|
13
|
-
expect(SET_CONCURRENCY_NOTIFICATION_METHOD).toBe("notifications/claude/channel/set_concurrency");
|
|
14
|
-
expect(CONCURRENCY_NOTIFICATION_METHOD).toBe("notifications/claude/channel/concurrency");
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
11
|
describe("normalizeConcurrency", () => {
|
|
18
12
|
it("takes a number the workspace could plausibly ask for", () => {
|
|
19
13
|
expect(normalizeConcurrency(1)).toBe(1);
|
|
@@ -48,72 +42,5 @@ describe("concurrency", () => {
|
|
|
48
42
|
expect(normalizeConcurrency(true)).toBeUndefined();
|
|
49
43
|
});
|
|
50
44
|
});
|
|
51
|
-
describe("sendConcurrencyNotification", () => {
|
|
52
|
-
it("reports the limit, the queue under it, and the range on offer", async () => {
|
|
53
|
-
const bridge = { sendNotification: vi.fn().mockResolvedValue(undefined) };
|
|
54
|
-
await sendConcurrencyNotification(bridge, {
|
|
55
|
-
maxConcurrency: 4,
|
|
56
|
-
active: 2,
|
|
57
|
-
queued: 3,
|
|
58
|
-
});
|
|
59
|
-
expect(bridge.sendNotification).toHaveBeenCalledWith(CONCURRENCY_NOTIFICATION_METHOD, expect.objectContaining({
|
|
60
|
-
maxConcurrency: 4,
|
|
61
|
-
active: 2,
|
|
62
|
-
queued: 3,
|
|
63
|
-
min: MIN_MAX_CONCURRENCY,
|
|
64
|
-
max: MAX_MAX_CONCURRENCY,
|
|
65
|
-
}));
|
|
66
|
-
});
|
|
67
|
-
it("spells every field one way, with no snake_case twin to keep in step", async () => {
|
|
68
|
-
const bridge = { sendNotification: vi.fn().mockResolvedValue(undefined) };
|
|
69
|
-
await sendConcurrencyNotification(bridge, {
|
|
70
|
-
maxConcurrency: 4,
|
|
71
|
-
active: 0,
|
|
72
|
-
queued: 0,
|
|
73
|
-
});
|
|
74
|
-
expect(Object.keys(bridge.sendNotification.mock.calls[0][1]).sort()).toEqual([
|
|
75
|
-
"active",
|
|
76
|
-
"canSet",
|
|
77
|
-
"max",
|
|
78
|
-
"maxConcurrency",
|
|
79
|
-
"min",
|
|
80
|
-
"queued",
|
|
81
|
-
"sessionId",
|
|
82
|
-
"taskId",
|
|
83
|
-
]);
|
|
84
|
-
});
|
|
85
|
-
it("declares that it will act on being told to change, so old gateways stay read-only", async () => {
|
|
86
|
-
const bridge = { sendNotification: vi.fn().mockResolvedValue(undefined) };
|
|
87
|
-
await sendConcurrencyNotification(bridge, {
|
|
88
|
-
maxConcurrency: 1,
|
|
89
|
-
active: 0,
|
|
90
|
-
queued: 0,
|
|
91
|
-
});
|
|
92
|
-
expect(bridge.sendNotification.mock.calls[0][1]).toMatchObject({ canSet: true });
|
|
93
|
-
});
|
|
94
|
-
it("sends empty task and session ids, which the workspace ignores", async () => {
|
|
95
|
-
const bridge = { sendNotification: vi.fn().mockResolvedValue(undefined) };
|
|
96
|
-
await sendConcurrencyNotification(bridge, {
|
|
97
|
-
maxConcurrency: 2,
|
|
98
|
-
active: 0,
|
|
99
|
-
queued: 0,
|
|
100
|
-
});
|
|
101
|
-
expect(bridge.sendNotification.mock.calls[0][1]).toMatchObject({
|
|
102
|
-
taskId: "",
|
|
103
|
-
sessionId: "",
|
|
104
|
-
});
|
|
105
|
-
});
|
|
106
|
-
it("never throws when the workspace cannot take the update", async () => {
|
|
107
|
-
const bridge = {
|
|
108
|
-
sendNotification: vi.fn().mockRejectedValue(new Error("socket closed")),
|
|
109
|
-
};
|
|
110
|
-
await expect(sendConcurrencyNotification(bridge, {
|
|
111
|
-
maxConcurrency: 2,
|
|
112
|
-
active: 1,
|
|
113
|
-
queued: 0,
|
|
114
|
-
})).resolves.toBeUndefined();
|
|
115
|
-
expect(errorSpy).toHaveBeenCalledWith("[bridge] Failed to send concurrency notification:", expect.any(Error));
|
|
116
|
-
});
|
|
117
|
-
});
|
|
118
45
|
});
|
|
119
46
|
//# sourceMappingURL=concurrency.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"concurrency.test.js","sourceRoot":"","sources":["../../src/__tests__/concurrency.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACzE,OAAO,EACL
|
|
1
|
+
{"version":3,"file":"concurrency.test.js","sourceRoot":"","sources":["../../src/__tests__/concurrency.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACzE,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,mBAAmB,CAAC;AAE3B,QAAQ,CAAC,aAAa,EAAE,GAAG,EAAE;IAC3B,IAAI,QAAqC,CAAC;IAE1C,UAAU,CAAC,GAAG,EAAE;QACd,QAAQ,GAAG,EAAE,CAAC,KAAK,CAAC,OAAO,EAAE,OAAO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