Metadata-Version: 2.5
Name: acppool
Version: 0.2.0
Summary: A worker pool for coding agents (Claude Code, Codex, any ACP agent), steered by a human.
Project-URL: Homepage, https://github.com/lunochkin/acppool
Project-URL: Issues, https://github.com/lunochkin/acppool/issues
Author-email: Maksim Lunochkin <maksim@lunochkin.com>
License-Expression: MIT
License-File: LICENSE
Keywords: acp,agent-client-protocol,claude-code,codex,coding-agents,human-in-the-loop
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Operating System :: MacOS
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Software Development
Requires-Python: >=3.10
Description-Content-Type: text/markdown

# acppool

A worker pool for coding agents, steered by a human. You bring the jobs and the board; acppool runs the agents,
queues their work, holds their questions and permission requests until a person answers, and keeps every turn going
when your app restarts.

![A Claude worker asks a question, gets an answer, and finishes its turn while the board is closed](https://raw.githubusercontent.com/lunochkin/acppool/main/docs/demo.gif)

It speaks the [Agent Client Protocol](https://agentclientprotocol.com) (ACP) to the agents, so Claude Code, Codex,
Goose and any other ACP agent run behind the same API. The library is standard-library Python with no packages to
install; each agent brings its own runtime (Claude's and Codex's ACP adapters need Node.js, Goose needs nothing more).

## Why

There are SDKs that talk to one agent, and finished apps that manage many of them. acppool is the layer in between:
the part every agent board builds for itself.

- **Turns outlive your app.** A supervisor process owns the agents. Restart or redeploy the board, and running turns
  carry on; restart the supervisor, and each agent resumes its session.
- **A human stays in the loop.** An agent can `ask` the human (an MCP tool acppool gives it), and a permission
  request waits until someone answers it. Nothing is decided for the human by a timeout or a default policy.
- **It goes into your app.** No UI and no web server of its own: you call functions, read files, and decide what a
  job is. A minimal board is 100 lines ([`examples/board.py`](examples/board.py)).

## Try it

```sh
git clone https://github.com/lunochkin/acppool && cd acppool
python3 examples/board.py
```

```
> join fake /tmp ada            # a miniature agent that echoes; needs nothing installed
> give ada hello
ada > tool: Read a
ada · echo:hello
ada ends its turn
```

To run Claude instead, install its ACP adapter once (Node.js needed) and have Claude Code signed in:

```sh
(cd examples/acp && npm install)
python3 examples/board.py
> join claude /tmp/demo ada
> give ada Write hello.py that greets me. Use the ask tool to ask me which language I want.
```

Leave the board with Ctrl-D while ada works, start it again, and ada's turn is still running or done. The demo above
is [`docs/demo.tape`](docs/demo.tape), recorded with [VHS](https://github.com/charmbracelet/vhs).

## How it fits together

```
your app ──socket + files──▶ supervisor ──ACP──▶ agent adapter ──▶ the agent (claude, codex, goose …)
   │                            │                                        │
   └─ pool, push, controls      └─ one event log per agent               └─ MCP ──▶ acppool's ask and wait
```

- **`supervisor`** runs as its own process and owns one adapter process per agent. It starts, prompts, steers,
  cancels and resumes sessions, holds permission requests, and writes every event to `sessions/<name>.jsonl`. Your
  app commands it over a Unix socket (`client.call`) and reads its state from files, so a reader never waits on it.
- **`pool`** is your record of the workers: each one's job, queue, question and undelivered messages, kept in a
  `Store` (SQLite, a JSON file, memory, or your own database).
- **`push`** decides what an idle worker gets next: an answer, a message, the end of a background run it waits on,
  a compaction when its context is full, or its next job. Your `App` subclass says what a job is.
- **`control`** has the human's controls: give, say, answer, permit, clear, reset, hold, take back, end.
- **`needs`** lists what waits on the human (a question, a permission, a reply), each with a key to notify it once.
- **`mcp`** is the agents' MCP server with the pool's own tools: `ask` the human, and `wait` on a background run.
  Add your app's tools beside them in the same server.
- **`limits`** reads the plans' usage limits (the share of each window used, and when it resets) from where agents
  report them: the supervisor's record of its Claude agents' turns, a saved Claude Code status line, and Codex's app
  server. Each window's latest reading wins, and one that has reset is left out.
- **`sessions`** cuts the event logs into sessions and turns, with each turn's tokens and cost; `client.steps` reads
  a log as one line per step.

## Writing an app

Three pieces: the supervisor's configuration, an `App`, and a loop that runs the push.

```python
from acppool import claude, client, control, pool, push, supervisor

# agentd.py, run as its own process; servers() gives each session your MCP server (acppool's ask and wait in it)
config = supervisor.Config.under(STATE, kinds={"claude": claude.installed(ADAPTER_FOLDER)}, servers=servers)
supervisor.main(config)

# your app
class Board(push.App):
    home = "the board"

    def brief(self, item, worker):          # the prompt a job is sent with
        return f"Fix {item['name']}. Report with the done tool."

    def job_over(self, job, worker):        # a job ends when the agent says so, not when a turn ends
        return job.get("done", False)

app = Board(pool.SqliteStore(STATE / "pool.db"), my_supervisor)  # my_supervisor: call() and agents(), over client
threading.Thread(target=push.run, args=(lambda: app,), daemon=True).start()
control.give(app, "ada", {"kind": "issue", "name": "#42"})
```

Every `App` hook has a default, so the simplest app overrides nothing: a job is one turn, and its brief is its
name. The hooks you are likely to want are `brief`, `job_over`, `judge` (take, keep or drop a queued item at its
turn), `run_of` (jobs of one run share a session), `preamble` (standing instructions) and `record` (your activity
log). [`examples/`](examples) has a complete board and its supervisor.

## Agents

| Kind | Adapter | Steering mid-turn | After a restart | Notes |
| --- | --- | --- | --- | --- |
| `claude` | [claude-agent-acp](https://github.com/agentclientprotocol/claude-agent-acp) (npm) | yes | resumed | Agent SDK options per kind, e.g. `settingSources` |
| `codex` | [codex-acp](https://github.com/agentclientprotocol/codex-acp) (npm) | yes | resumed | sessions set to the `agent` mode |
| any ACP agent | its own, e.g. `goose acp` | if it offers it | resumed, or loaded | `Kind(command=..., options=...)` |

A `Kind` is the adapter's command line plus what it offers beyond ACP: a steering method, session options (ACP
config options set on every session), Claude-style `_meta`, a rate-limit report. Claude and Codex need Node.js for
their adapters; agents that speak ACP natively, like Goose, need nothing else. An agent that cannot resume a session
but can load one is loaded, with the history it replays kept out of the log.

## Status

0.x: in daily use by two boards, and the API may still change between minor versions. Python 3.10 or newer, on
macOS and Linux.

Neighbouring projects solve other parts: [acpx](https://github.com/openclaw/acpx) is a scriptable ACP client for
running one agent from a script or CI, with permissions decided by policy; the ACP adapters above translate each
agent to ACP. acppool is the pool between the agents and your board.

## Tests

```sh
python3 -m unittest discover -s acppool/tests -t .
```

They run the supervisor over a miniature ACP agent ([`acppool/tests/fake_agent.py`](acppool/tests/fake_agent.py))
in a temporary folder, with no network and no agent installed.

## License

MIT
