@openmuster/muster 0.3.1-alpha.4 → 0.3.1-alpha.6

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.
Files changed (58) hide show
  1. package/README.md +11 -7
  2. package/dist/{args-9ZZDcPxa.js → args-CaFBa2IP.js} +305 -23
  3. package/dist/cli.js +3 -3
  4. package/dist/index.d.ts +98 -19
  5. package/dist/index.js +107 -42
  6. package/dist/inspect/app.js +49 -26
  7. package/dist/{main-Doit2DDY.js → main-3kE64MlN.js} +195 -12
  8. package/dist/main-o4m_lGDG.js +6 -0
  9. package/dist/mcp-D6Xt2ixk.js +6 -0
  10. package/dist/{module-DjDMSEKu.js → module-BX2IjSiv.js} +2 -2
  11. package/dist/{module-D8qcE3e7.js → module-D9KdbEpS.js} +1 -1
  12. package/dist/skills/board/SKILL.md +5 -0
  13. package/dist/skills/loop-card/SKILL.md +22 -3
  14. package/dist/{steps-BUPRIOe3.js → steps-cnWo2Wvx.js} +299 -12
  15. package/docs/01-concepts/09-watchers.md +4 -32
  16. package/docs/01-concepts/10-schedules.md +1 -1
  17. package/docs/01-concepts/11-access.md +19 -3
  18. package/docs/01-concepts/13-budgets.md +66 -3
  19. package/docs/01-concepts/15-outgoing-webhooks.md +6 -19
  20. package/docs/01-concepts/16-workflows.md +42 -2
  21. package/docs/01-quickstart.md +74 -45
  22. package/docs/02-sync/01-overview.md +34 -2
  23. package/docs/02-sync/02-github.md +40 -19
  24. package/docs/02-sync/03-linear.md +103 -85
  25. package/docs/02-sync/04-slack.md +116 -111
  26. package/docs/02-sync/05-notion.md +46 -25
  27. package/docs/03-guides/01-coding-agents.md +51 -33
  28. package/docs/03-guides/02-swarm.md +30 -15
  29. package/docs/03-guides/03-factory.md +193 -80
  30. package/docs/03-guides/04-inspector.md +73 -42
  31. package/docs/03-guides/05-running-agents.md +62 -35
  32. package/docs/03-guides/06-sandboxed-agents.md +535 -305
  33. package/docs/03-guides/07-build-a-ui.md +86 -31
  34. package/docs/03-guides/08-ci.md +59 -36
  35. package/docs/03-guides/09-daemon.md +121 -53
  36. package/docs/03-guides/10-two-agents.md +31 -22
  37. package/docs/03-guides/11-person-in-the-loop.md +47 -34
  38. package/docs/03-guides/12-unattended.md +46 -27
  39. package/docs/03-guides/13-terminals.md +51 -39
  40. package/docs/03-guides/14-no-cloud.md +31 -19
  41. package/docs/03-guides/15-several-boards.md +61 -27
  42. package/docs/03-guides/16-non-code.md +29 -18
  43. package/docs/03-guides/17-mcp.md +37 -30
  44. package/docs/03-guides/18-a-board-on-a-server.md +66 -43
  45. package/docs/03-guides/19-a-card-queue.md +210 -121
  46. package/docs/03-guides/20-a-feedback-loop.md +412 -135
  47. package/docs/03-guides/21-running-the-loop.md +94 -64
  48. package/docs/03-guides/22-building-from-linear.md +100 -63
  49. package/docs/04-reference/01-cli.md +7 -0
  50. package/docs/04-reference/02-handle.md +11 -15
  51. package/docs/04-reference/03-http.md +1 -1
  52. package/docs/04-reference/04-events.md +2 -1
  53. package/docs/04-reference/05-errors.md +6 -0
  54. package/docs/04-reference/08-files.md +49 -0
  55. package/docs/index.md +1 -0
  56. package/package.json +1 -1
  57. package/dist/main-D5aX7Jaj.js +0 -6
  58. package/dist/mcp-Cm96TIb3.js +0 -6
@@ -9,146 +9,157 @@ description: For running agents off your machine, in Vercel Sandbox, a Cloudflar
9
9
  > live: a Cloudflare `--ready --loop` worker, dependency installs on
10
10
  > Cloudflare, and an E2B you run yourself. Codex has run only on E2B.
11
11
 
12
- ## What a sandbox needs
12
+ ## Who this is for
13
13
 
14
- A sandbox can't open your board's file. It reaches the board over HTTP, so the
15
- board must be served at an HTTPS address the sandbox can reach, and the agent
16
- needs a token. A tunnel to your machine is enough to try it; to run it for
17
- real, see [A board on a server](./18-a-board-on-a-server.md).
14
+ You want agents to work tasks somewhere other than your machine, each in a
15
+ sandbox of its own with its own clone of the repository. You end with
16
+ `mu run` starting them there, a worker that gives each ready task its own
17
+ sandbox, and a pull request for what each agent changed.
18
+
19
+ ## Before you begin
20
+
21
+ You need:
22
+
23
+ - **A board at an HTTPS address the sandbox can reach.** A tunnel to your
24
+ machine is enough to try it; to run it for real, see
25
+ [A board on a server](./18-a-board-on-a-server.md).
26
+ - **One platform set up:** for Vercel, `@vercel/sandbox` installed and a way
27
+ to sign in to Vercel ([On Vercel](#on-vercel)); for Cloudflare, your
28
+ Worker's URL in `MUSTER_CF_WORKER` and its secret in `MUSTER_CF_SECRET`
29
+ ([On Cloudflare](#on-cloudflare)); for E2B, the `e2b` package,
30
+ `E2B_API_KEY` and a template ([On E2B](#on-e2b)).
31
+ - **A model key:** a key for the agent's model provider, set on this machine
32
+ ([Give the agent a model key](#give-the-agent-a-model-key)).
33
+ - **For pull requests:** a GitHub App installed on the repository, and `git`
34
+ on this machine ([Push what it changed](#push-what-it-changed)).
35
+
36
+ ## Connect the sandbox to the board
37
+
38
+ ### Serve the board where a sandbox can reach it
39
+
40
+ A sandbox can't open your board's file. It reaches the board over HTTP, so
41
+ serve the board at an HTTPS address, and make a token for the agent:
18
42
 
19
43
  ```bash
20
44
  mu serve --allow-host board.example.com
21
45
  mu token create --as fixer --can 'work/=read,post,react,label' --ttl 2h
22
46
  ```
23
47
 
24
- ## Start one
48
+ When this machine has the board itself, set `MUSTER_SANDBOX_URL` to the
49
+ board's address for sandboxes, a tunnel's, say. `mu run` then reads and
50
+ claims on the board here, and the sandboxes reach it at that address.
51
+
52
+ ### Choose the agent's token
53
+
54
+ Two tokens are in play:
55
+
56
+ - **`MUSTER_TOKEN` is yours,** for the `mu run` you type. It is never passed
57
+ on to the sandbox.
58
+ - **The sandbox's requests carry another, made for the agent.** Name the
59
+ agent with `--as` and `mu run` has the board make one for this run.
60
+
61
+ The token `mu run` makes is held to that
62
+ [profile](../01-concepts/06-actors.md) and to the task's channel. It lasts a
63
+ little longer than the run: 10 minutes past the sandbox, and an attached run
64
+ revokes it as soon as it ends. It is marked so that what it writes stays on
65
+ the board.
66
+
67
+ Or make one yourself and set `MUSTER_AGENT_TOKEN`. `mu run` refuses one that
68
+ isn't held to a profile and to named channels, because anything that steers
69
+ the agent can do whatever the token allows.
70
+
71
+ ### Give the agent a model key
72
+
73
+ The agent's laptop sign-in isn't available in a sandbox: it needs a key for
74
+ its model provider. Set it where you run `mu run`, in `ANTHROPIC_API_KEY` for
75
+ Claude Code or `OPENAI_API_KEY` for Codex:
76
+
77
+ ```bash
78
+ export ANTHROPIC_API_KEY=your_anthropic_api_key
79
+ mu run 12 --runner vercel --agent claude
80
+ ```
81
+
82
+ Like the board's token, the key stays out of the sandbox. The sandbox's
83
+ environment holds a placeholder, and the key is added on the way out, only
84
+ to the calls that ask the model (`POST /v1/messages` on `api.anthropic.com`;
85
+ `/v1/responses` and `/v1/chat/completions` on `api.openai.com`). Any other
86
+ request to that host is refused. On E2B the key goes on every request to
87
+ that host, and `mu run` uses it only when you accept that: see
88
+ [On E2B](#on-e2b).
89
+
90
+ Without the variable, `mu run` warns and starts the agent anyway, which
91
+ works only if the sandbox's image has a sign-in of its own. Read
92
+ [What the model key can still do](#what-the-model-key-can-still-do) before
93
+ you pick a key.
94
+
95
+ ## Run one task in a sandbox
96
+
97
+ ### Start the agent
98
+
99
+ Set the board's address and your token, then name the task, the runner and
100
+ the agent:
25
101
 
26
102
  ```bash
27
103
  export MUSTER_URL=https://board.example.com/api/board
28
- export MUSTER_TOKEN=mu1... # yours: mu run reads the task and has a token made for the agent
104
+ export MUSTER_TOKEN=your_board_token # yours: mu run reads the task and has a token made for the agent
29
105
  mu run 12 --runner vercel --agent claude --as fixer --repo https://github.com/acme/web.git
30
106
  mu run --ready work/ --runner cloudflare --agent claude --as worker-3
31
107
  ```
32
108
 
33
- What runs in the sandbox is `mu run`
34
- itself, as it runs on your machine: it claims the task, keeps the claim alive
35
- while the agent works, fails the task if the agent leaves it open, and labels
36
- it with the session, tokens and cost. With `--ready` the sandbox is a worker
37
- that takes one task after another until none is ready.
38
-
39
- On Vercel, `mu run` here stays with the run: it waits for the one in the
40
- sandbox to exit, then closes the sandbox's way out and removes it, and says
41
- how the task ended. Ctrl-C does the same, sooner. A dropped connection is
42
- waited out, not taken for an exit. `--detach` starts the run and returns,
43
- and the sandbox is left to its timeout, holding the agent's token in its
44
- policy until then. On Cloudflare the command returns once the run starts,
45
- unless it is a `--push` run or a task of a `--ready --loop` worker, which
46
- are waited on in the same way.
47
-
48
- One length of time sets the rest. `--timeout` is how long the agent works on
49
- the task: 30 minutes when you don't pass one, except on Cloudflare without
50
- `--push` and outside a worker, where the Worker gives it an hour. The sandbox lives ten
51
- minutes longer, to install muster and settle the task, so it is `mu run` in
52
- it that fails a task that ran out of time, never the platform cutting it off.
53
- A `--ready` worker's sandbox lives two hours when you pass no `--timeout`,
54
- and ends as soon as the worker finds no task. The agent's token lasts ten
55
- minutes past the sandbox, and an attached run revokes it as soon as it ends.
56
-
57
- ### A sandbox per task
109
+ What runs in the sandbox is `mu run` itself, as it runs on your machine: it
110
+ [claims](../01-concepts/08-tasks.md#claims) the task and keeps the claim
111
+ alive while the agent works. It fails the task if the agent leaves it open,
112
+ and labels it with the session, tokens and cost.
58
113
 
59
- ```bash
60
- mu run --ready work/ --loop --runner vercel --agent claude --as worker-1 --repo https://github.com/acme/web.git --push
61
- mu run --ready work/ --loop --runner cloudflare --agent claude --as worker-2 --repo https://github.com/acme/web.git --push
62
- ```
114
+ `--repo` takes an HTTPS clone address with no credential in it. A token in
115
+ the address would be readable by everything in the sandbox.
63
116
 
64
- On each of the three clouds, `--ready` with `--loop` is a worker that stays
65
- on this machine.
66
- It claims the next ready task as `worker-1`, under a claim token made for
67
- that task, and runs it as above in a sandbox of its own, which takes the same
68
- claim: no other worker can have it, and each task gets its own clone, its own
69
- token and, with `--push`, its own pull request. Then the next, until nothing
70
- is ready for `--wait` (ten minutes by default). Start as many as you want
71
- running at once; the swarm template starts one per agent. The sandbox holds
72
- the claim token for its one task. On Cloudflare each task's container is
73
- waited on and stopped once its agent exits, before the next task is claimed,
74
- so the Worker keeps none of them for its 15 minutes. A task whose run
75
- doesn't start, or ends without saying how, is given back, ready, and its
76
- token revoked. A worker stops at once when the runner refuses a start, and
77
- after three failures in a row otherwise (`runner_start_failed`).
78
-
79
- Without `--loop`, `--ready` is one sandbox, or one container, that takes
80
- task after task itself, sharing one checkout, so it can't `--push`.
81
-
82
- `MUSTER_SANDBOX_URL` is the board's address for sandboxes, when this machine
83
- has the board itself: `mu run` then reads and claims on the board here, and
84
- the sandboxes reach it at that address, a tunnel's, say.
85
-
86
- Two tokens are in play. `MUSTER_TOKEN` is yours, for the `mu run` you type.
87
- The sandbox's requests carry another, made for the agent: your own is never
88
- passed on. Name the agent with `--as` and `mu run` has the board make one for
89
- this run: that profile, the task's channel, a little longer than the run, and
90
- marked so what it writes stays on the board. Or make one yourself and set
91
- `MUSTER_AGENT_TOKEN`; `mu run` refuses one that isn't held to a profile and to
92
- named channels, since whatever it may do, anything that steers the agent may
93
- do too.
94
-
95
- `--repo` takes an HTTPS clone address with no credential in it. A token in the
96
- address would be readable by everything in the sandbox.
117
+ With `--ready`, the second command above, the sandbox is a worker that takes
118
+ one task after another until none is ready. Without `--loop`, that is one
119
+ sandbox, or one container, sharing one checkout, so it can't `--push`. For a
120
+ sandbox per task, see
121
+ [Give each task its own sandbox](#give-each-task-its-own-sandbox).
97
122
 
98
123
  In a sandbox the agent runs without its own permission prompts: headless, a
99
- prompt stops it at its first command, and the sandbox with its network policy
100
- is the boundary. `--safe` keeps the prompts on.
101
-
102
- Cloudflare also needs `MUSTER_CF_WORKER`, your Worker's URL, and
103
- `MUSTER_CF_SECRET`. Vercel needs `@vercel/sandbox` installed. E2B needs the
104
- `e2b` package, `E2B_API_KEY` and a template: see [On E2B](#on-e2b).
105
-
106
- ## What is in the sandbox
107
-
108
- The agent needs `mu` and its own CLI where it runs.
109
-
110
- - **Vercel.** Each run installs the release of muster you are running, from
111
- its tarball on GitHub. `MUSTER_INSTALL` names another tarball or path to
112
- install. The agent's CLI has to be in the sandbox's image already:
113
- `vercel/sandbox/universal` has Claude Code, Codex, git, gh, npm, pnpm and
114
- bun.
115
- - **A base, on Vercel.** Installing muster happens once per version, not per
116
- run: the first run makes a kept sandbox with muster installed and nothing
117
- else in it, no credential, repository or environment, and every run after
118
- is forked from it. Its name has a random part nobody can guess, and this
119
- machine writes it down in `~/.config/muster/vercel-bases.json`: a run
120
- forks only a base this machine made, and only one that stopped cleanly, so
121
- a sandbox someone else in the project made to look like one is never used.
122
- A base for a newer muster removes the older ones this machine made there,
123
- and nothing else. `MUSTER_VERCEL_BASE=off` sets each run up from nothing.
124
- - **Your repository, on Vercel.** `--repo` is cloned into `/vercel/<name>`
125
- as the run starts, before anything of it runs, and the agent starts there. Its dependencies
126
- are installed the way its lockfile says (pnpm, npm, yarn or bun, at the
127
- version `packageManager` pins), with no install scripts, the
128
- dependencies' own included. `--no-install` skips it. A failed install
129
- doesn't stop the run: the task gets a `deps` label and a reply that says
130
- so, and the agent starts without them.
131
- - **Cloudflare.** A run's container has no internet. `mu` and the agent's
132
- CLI are in the image you build: the template's `Dockerfile` installs both.
133
- `--repo` is cloned through the Worker, which opens that one repository's
134
- clone routes, adds the GitHub App's read token for a private one, and
135
- closes GitHub again before anything of the repository runs. Its
136
- dependencies are then installed with the same script as on Vercel, for at
137
- most three minutes (less when the clone was slow), while the Worker lets the container read the public
138
- npm registry (`registry.npmjs.org`, `registry.yarnpkg.com`,
139
- `repo.yarnpkg.com`) and nothing else there; those hosts are closed again
140
- before the agent starts. The image is built for pnpm, npm and yarn; it has no bun, so
141
- a `bun.lock` repository says `failed (exit 127)`. A private registry, a
142
- git dependency or a package fetched from anywhere else fails the install.
143
- `--no-install`, the `deps` label and the reply work as on Vercel. The Worker checks the run every minute and removes the container
144
- when the agent exits or `--timeout` has passed: without one, an hour, or 30
145
- minutes for a `--push` run or a worker's task. Each
146
- run gets a `standard-1` container (half a vCPU, 4 GiB); set `INSTANCE` in
147
- the Worker's `wrangler.jsonc` for another size. Cloudflare's default, `lite`,
148
- is too small for an agent's CLI.
124
+ prompt stops it at its first command, and the sandbox with its network
125
+ policy is the boundary. `--safe` keeps the prompts on.
126
+
127
+ ### Stay with the run, or detach
128
+
129
+ On Vercel, the `mu run` you typed stays with the run:
130
+
131
+ - **It waits for the `mu run` in the sandbox to exit,** then closes the
132
+ sandbox to every host, removes it, and says how the task ended. Ctrl-C does
133
+ the same, sooner.
134
+ - **It waits out a dropped connection** rather than taking it for an exit.
135
+ - **`--detach` starts the run and returns.** The sandbox is left to its
136
+ timeout, with the agent's token in its network policy until then.
137
+
138
+ On Cloudflare the command returns once the run starts, unless it is a
139
+ `--push` run or a task of a `--ready --loop` worker. `mu run` waits on those
140
+ in the same way.
141
+
142
+ An E2B run can't be detached: see [On E2B](#on-e2b).
143
+
144
+ ### Set how long it may run
145
+
146
+ `--timeout` is how long the agent works on the task, and it sets every other
147
+ length of time. Without it the agent gets 30 minutes, except on Cloudflare
148
+ without `--push` and outside a worker, where the Worker gives it an hour.
149
+
150
+ The sandbox lives 10 minutes longer than `--timeout`, to install muster and
151
+ settle the task. So `mu run` in the sandbox fails a task that ran out of
152
+ time, never the platform cutting it off.
153
+
154
+ A `--ready` worker's sandbox lives 2 hours when you pass no `--timeout`, and
155
+ ends as soon as the worker finds no task.
156
+
157
+ ## Turn the run into a pull request
149
158
 
150
159
  ### Push what it changed
151
160
 
161
+ Give `mu run` a GitHub App and add `--push`:
162
+
152
163
  ```bash
153
164
  export GITHUB_APP_ID=123456 # your GitHub App, installed on the repository
154
165
  export GITHUB_APP_KEY_FILE=~/.config/muster/app.pem
@@ -156,126 +167,273 @@ mu run 12 --runner vercel --agent claude --as fixer --repo https://github.com/ac
156
167
  ```
157
168
 
158
169
  `--push` takes a GitHub App, not a personal token: install it on the
159
- repository with Contents and Pull requests, read and write. For each run,
160
- `mu run` makes the App's tokens on this machine, each for this repository
161
- alone and gone within the hour: one to read, for the clone, and one to
162
- write, made when the push is. The App's key never leaves this machine.
163
- `GITHUB_APP_PRIVATE_KEY` can hold the key itself instead of a path.
164
-
165
- With `--push`, once the agent is done, `mu run` closes the sandbox to every
166
- host, commits what the agent changed on top of where the checkout started,
167
- and reads it out as a git bundle. It pushes that from this machine to
168
- `mu/task-12`, and opens a pull request into the repository's default
169
- branch. The pull request's address is on the task as a `pr` label and a
170
- reply. Nothing changed, no pull request.
170
+ repository with Contents and Pull requests, read and write.
171
+ `GITHUB_APP_PRIVATE_KEY` can hold the key itself instead of a path. For each
172
+ run, `mu run` makes the App's tokens on this machine, each for this
173
+ repository alone and gone within the hour: one to read, for the clone, and
174
+ one to write, made when the push is. The App's key never leaves this
175
+ machine.
176
+
177
+ With `--push`, once the agent is done, `mu run`:
178
+
179
+ 1. closes the sandbox to every host;
180
+ 2. commits what the agent changed on top of where the checkout started, and
181
+ reads it out as a git bundle;
182
+ 3. pushes that from this machine to `mu/task-12`;
183
+ 4. opens a pull request into the repository's default branch.
184
+
185
+ The pull request's address is on the task as a `pr` label and a reply. If
186
+ nothing changed, there's no pull request.
187
+
188
+ `--push` needs `mu run` to stay attached. It doesn't work with `--detach`,
189
+ nor with `--ready` without `--loop`, whose tasks would share one checkout.
190
+ On Cloudflare, a `--push` run is waited on, like a Vercel one, and the
191
+ Worker keeps the container for up to 15 minutes after the agent exits for
192
+ `mu run` to read; `mu run` removes it as soon as it has.
193
+
194
+ Without `--push`, `mu run` uses a GitHub App that is set to clone a private
195
+ repository, the same way, and pushes nothing. A public repository the App
196
+ isn't installed on is cloned without it.
197
+
198
+ ### Let the agent describe the pull request
199
+
200
+ The pull request's body is one line from muster: the task, the profile and
201
+ the runner. To say more, have the agent write a description to
202
+ `/tmp/mu-pull-request-<id>.md` in its sandbox, where `<id>` is its task's
203
+ number. The file is outside the checkout, so it is never committed. Tell the
204
+ agent what to put there in the task or the prompt: what changed, how it was
205
+ checked. With no such file, or an empty one, the body is muster's line
206
+ alone.
207
+
208
+ `mu run` reads the file once the agent is done, up to 256 KB; a bigger one
209
+ isn't read. Then it removes the file, so a later round starts with none. It posts the description under muster's line, made inert first:
210
+
211
+ - no character reference (`&#64;`) is read, and an `@` mentions nobody;
212
+ - every `[` and `]` is made fullwidth, so no link, image, link definition or
213
+ footnote forms, and no HTML or bare address renders;
214
+ - an image on any other host is replaced by its alt text, so GitHub fetches
215
+ nothing the agent chose;
216
+ - `#123`, `owner/repo#123`, `GH-123` and the address of an issue or pull
217
+ request refer to nothing, so a closing keyword (`Fixes #12`) closes
218
+ nothing;
219
+ - an issue key such as `ENG-123`, a letter, more letters or digits, a
220
+ hyphen and a number, in any case, gets a non-breaking hyphen (U+2011)
221
+ that looks the same, so Linear's GitHub integration links nothing, and
222
+ `Fixes ENG-123` closes nothing on merge; text of the same shape, such as
223
+ `node-22`, gets it too, so code copied from the description may need its
224
+ hyphen typed again;
225
+ - it is cut at 20,000 characters.
226
+
227
+ The one image that renders is a relative path to a file in the pushed
228
+ commit, such as `![the inbox](docs/inbox.png)`. `mu run` rewrites it to that
229
+ file's address, pinned to the commit. GitHub shows it to anyone who can read
230
+ the repository. A path that isn't in the commit, or climbs out of the
231
+ repository, stays as text, and at most 20 are shown. A shown image's path
232
+ and alt text keep letters, digits, spaces and `. - _` alone, up to 200 and
233
+ 100 characters, and name no issue key either. The pull request's title and
234
+ commit message name no issue key in the same way.
235
+
236
+ In the round that opens the pull request, the description follows muster's
237
+ line in the body. When the task's workflow step has `refs`, the body ends
238
+ with a line such as `Refs ENG-123`, added after the description is made
239
+ inert, so that key alone links: see
240
+ [Workflows](../01-concepts/16-workflows.md#asking-for-a-run). In a later round, it is a comment on the pull request:
241
+ the body, and anything a person wrote in it, stays as it is. A comment
242
+ GitHub refuses doesn't fail the run: the change is pushed, and `mu run`
243
+ prints a warning and replies on the task with `comment_failed`.
171
244
 
172
245
  ### Another round on the same pull request
173
246
 
174
247
  A task run again after it pushed, reopened with `mu tasks reopen 12 --round`
175
- or answered after it blocked, carries on from its branch. Before the sandbox
248
+ or answered after it blocked, continues from its branch. Before the sandbox
176
249
  starts, `mu run` reads where `mu/task-12` is on GitHub and checks the
177
250
  sandbox out there, so the agent's second round adds to the first, and the
178
- push lands on the same pull request. The agent is told which round it is.
251
+ push updates the same pull request. The agent is told which round it is.
179
252
 
180
253
  - **The branch only moves forward from where the run found it.** A change
181
254
  that doesn't build on that commit, or a branch someone pushed to while the
182
- agent worked, is refused with `push_conflict`, and the branch is left as
183
- it was.
184
- - **A change that wasn't pushed is said on the board.** The task gets a
185
- `push` label and a reply with why, and the tasks that wait on it are held
186
- with the same kind, so a review never goes on from a change that isn't on
187
- the branch. Read the thread, then unblock them or run the task again.
255
+ agent worked, isn't pushed: `mu run` reports `push_conflict` and leaves the
256
+ branch as it was.
257
+ - **The board shows a change that wasn't pushed.** `mu run` gives the task a
258
+ `push` label and a reply with why. It
259
+ [blocks](../01-concepts/08-tasks.md#states) the tasks that wait on it, with
260
+ the refusal as their kind (`push_conflict`, say), so a review never goes on
261
+ from a change that isn't on the branch. Read the thread, then unblock them
262
+ or run the task again.
188
263
  - **A sandbox that didn't start on the branch starts no agent.** An older
189
264
  `@vercel/sandbox`, or a Cloudflare Worker deployed before it knew the
190
- branch, would clone the default branch instead: the run is stopped with
191
- `runner_setup_failed` or `runner_too_old`.
265
+ branch, would clone the default branch instead: `mu run` stops the run
266
+ with `runner_setup_failed` or `runner_too_old`.
192
267
 
193
- - **No token is ever where the agent has been.** The read token is in the
194
- sandbox's policy only while Vercel clones the repository, before anything of the
195
- repository's runs, and only on its git fetch routes. The push is made here,
196
- from a repository made for it, and its branch is the one `mu run` names,
197
- so nothing the agent left behind, a hook, a process, a changed `git`, can
198
- use the token or pick what it writes.
199
- - **What the agent left is data.** Git runs in the sandbox with no hooks, no
200
- fsmonitor and no global config, under a policy that reaches nothing, and
201
- all that comes out is the bundle, which becomes the branch.
202
- - **The pull request is opened from your machine,** so GitHub's API is never
203
- reachable from the sandbox.
204
- - **It needs `mu run` to stay attached:** not with `--detach`, nor `--ready`,
205
- whose tasks would share one checkout. It needs `git` on this machine.
206
- - **On Cloudflare** the Worker does the closing. When it sees the agent
207
- exit, it shuts every host the run opened and kills whatever the agent left
208
- running, before anything is read. Only then does it run the bundle step and
209
- hand the bundle out, each with a time limit and a size limit. With
210
- `--push`, a Cloudflare run is waited on, like a Vercel one, and the
211
- container is kept for up to 15 minutes after the agent exits for `mu run`
212
- to read; `mu run` removes it as soon as it has. A Cloudflare run without
213
- `--push` still returns once it starts, unless it is a worker's task.
214
- - Without `--push`, a GitHub App that is set is used to clone a private
215
- repository, the same way, and nothing is pushed. A public repository the
216
- App isn't installed on is cloned without it.
268
+ ## Run a worker that gives each task a sandbox
217
269
 
218
- The write token can write any branch of the repository for its hour, though
219
- only this machine holds it, and `mu run` only ever pushes `mu/task-<id>`:
220
- protect the branches that matter on GitHub all the same.
270
+ ### Give each task its own sandbox
221
271
 
222
- ### Setting up holds no credential
272
+ Add `--loop` to `--ready`, with `--push` for a pull request per task:
223
273
 
224
- A Vercel sandbox is made under a policy of its own for setting up, with
225
- none of the credentials in it: GitHub's hosts to clone and to install
226
- muster, and every host while your repository's dependencies install, since a
227
- lockfile can name any registry. Once set up, that policy is replaced by the
228
- agent's, and the agent starts with only the board and its model's host open.
229
- Code that ran while setting up could reach the internet, but there was
230
- nothing to take: the tokens only ever go on requests after that.
274
+ ```bash
275
+ mu run --ready work/ --loop --runner vercel --agent claude --as worker-1 --repo https://github.com/acme/web.git --push
276
+ mu run --ready work/ --loop --runner cloudflare --agent claude --as worker-2 --repo https://github.com/acme/web.git --push
277
+ ```
231
278
 
232
- A Cloudflare container never has that: while dependencies install, the
233
- registries are open to read and nothing else is, the board and the model's
234
- host included. Once the install is done, the registries close, every process
235
- it left running is killed, and only then do the board and the model's host
236
- open again, for the agent.
279
+ On each of the 3 clouds, `--ready` with `--loop` is a worker that stays on
280
+ this machine:
281
+
282
+ - **It claims the next ready task** as `worker-1`, under a claim token made
283
+ for that task.
284
+ - **It runs the task as above, in a sandbox of its own,** which takes the
285
+ same claim, so no other worker can have it. The sandbox holds the claim
286
+ token for its one task.
287
+ - **Each task gets its own clone, its own token** and, with `--push`, its
288
+ own pull request.
289
+ - **It then takes the next task,** until nothing is ready for `--wait`
290
+ (10 minutes by default).
291
+
292
+ Start as many workers as you want running at once; the swarm template starts
293
+ one per agent.
294
+
295
+ The worker waits on each task's run and stops its sandbox or container once
296
+ the agent exits, before it claims the next task. So on Cloudflare the Worker
297
+ keeps none of them for its 15 minutes. When a run doesn't start, or ends
298
+ without saying how, the worker revokes the run's token and gives the claim
299
+ back, so the task is ready again. A worker stops at once when the runner
300
+ refuses a start, and after 3 failures in a row otherwise
301
+ (`runner_start_failed`).
302
+
303
+ ## What you see
304
+
305
+ `mu run` says on the task how the run went:
306
+
307
+ - **Labels for the run:** the session, tokens and cost.
308
+ - **A `pr` label and a reply** with the pull request's address, after a
309
+ `--push` run that changed something.
310
+ - **A `deps` label and a reply** when the repository's dependencies didn't
311
+ install. The agent starts without them.
312
+ - **A `push` label and a reply** when a change wasn't pushed, with the tasks
313
+ that wait on it blocked.
314
+
315
+ An attached run ends by saying how the task ended. A worker goes on until
316
+ nothing is ready.
317
+
318
+ ## What each platform does
319
+
320
+ ### On Vercel
321
+
322
+ The Vercel runner starts from `vercel/sandbox/universal`, which has Claude
323
+ Code, Codex, git, gh, npm, pnpm and bun. The agent's CLI has to be in the
324
+ sandbox's image already.
325
+
326
+ **Signing in to Vercel:** the runner signs in with an access token when
327
+ `VERCEL_TOKEN`, `VERCEL_TEAM_ID` and `VERCEL_PROJECT_ID` are all set.
328
+ Otherwise it uses a linked project's `VERCEL_OIDC_TOKEN` (an OpenID Connect
329
+ token), from `vercel env pull`. Setting only one or two of the three is an
330
+ error. None of them enters the sandbox.
237
331
 
238
- A repository's own configuration still runs at install, scripts or not: a
239
- `.pnpmfile.cjs`, a yarn plugin, an `.npmrc` pointing at a registry of its
240
- choosing. That is the repository's code, like its tests, which the agent
241
- runs anyway: launch only on code you would run.
332
+ **Installing muster:** each run installs the release of muster you are
333
+ running, from its tarball on GitHub. `MUSTER_INSTALL` names another tarball
334
+ or path to install.
335
+
336
+ **A base sandbox:** installing muster happens once per version, not per run:
337
+
338
+ - The first run makes a kept sandbox with muster installed and nothing else
339
+ in it, no credential, repository or environment. Every run after is forked
340
+ from it.
341
+ - Its name has a random part nobody can guess, and this machine writes it
342
+ down in `~/.config/muster/vercel-bases.json`.
343
+ - A run forks only a base this machine made, and only one that stopped
344
+ cleanly. So it never uses a sandbox someone else in the project made to
345
+ look like one.
346
+ - A base for a newer muster removes the older ones this machine made there,
347
+ and nothing else. `MUSTER_VERCEL_BASE=off` sets each run up from nothing.
348
+
349
+ **Your repository:** Vercel clones `--repo` into `/vercel/<name>` as the run
350
+ starts, or `git` in the sandbox does for a run forked from a base. Either way
351
+ it happens before any of the repository's code runs, and the agent starts
352
+ there. `mu run` then installs its dependencies the way its lockfile says
353
+ (pnpm, npm, yarn or bun, at the version `packageManager` pins). It runs no
354
+ install scripts, the dependencies' own included. `--no-install` skips it. A
355
+ failed install doesn't stop the run: the task gets a `deps` label and a reply
356
+ that says so, and the agent starts without them.
357
+
358
+ ### On Cloudflare
359
+
360
+ A run's container has no internet. `mu` and the agent's CLI are in the image
361
+ you build: the template's `Dockerfile` installs both.
362
+
363
+ **Your repository:** `--repo` is cloned through the Worker. The Worker opens
364
+ that one repository's clone routes, adds the GitHub App's read token for a
365
+ private one, and closes GitHub again before any of the repository's code
366
+ runs.
242
367
 
243
- ## On E2B
368
+ **Dependencies:** they are installed with the same script as on Vercel, for
369
+ at most 3 minutes (less when the clone was slow). Meanwhile the Worker lets
370
+ the container read the public npm registry (`registry.npmjs.org`,
371
+ `registry.yarnpkg.com`, `repo.yarnpkg.com`) and nothing else there. Those
372
+ hosts are closed again before the agent starts. The image is built for pnpm,
373
+ npm and yarn; it has no bun. A private registry, a git dependency or a package
374
+ fetched from anywhere else fails the install. `--no-install`, the `deps`
375
+ label and the reply work as on Vercel.
376
+
377
+ **The container's life:** the Worker checks the run every minute. It removes
378
+ the container when the agent exits or `--timeout` has passed: without one,
379
+ an hour, or 30 minutes for a `--push` run or a worker's task.
380
+
381
+ **Its size:** each run gets a `standard-1` container (half a vCPU, 4 GiB);
382
+ set `INSTANCE` in the Worker's `wrangler.jsonc` for another size.
383
+ Cloudflare's default, `lite`, is too small for an agent's CLI.
384
+
385
+ ### On E2B
386
+
387
+ Set your E2B key and template, then run as on the other platforms:
244
388
 
245
389
  ```bash
246
- export E2B_API_KEY=e2b_...
390
+ export E2B_API_KEY=your_e2b_api_key
247
391
  export MUSTER_E2B_TEMPLATE=muster-agents # built from templates/e2b-runner
248
392
  mu run 12 --runner e2b --agent claude --as fixer --repo https://github.com/acme/web.git
249
393
  ```
250
394
 
251
395
  E2B needs the `e2b` package where `mu` runs (`npm i e2b`) and a template with
252
- your agent's CLI in it: `templates/e2b-runner` builds one. There is nothing to
253
- deploy. Each run installs this release of muster in the sandbox, as on Vercel,
254
- and `--repo`, `--push`, `--ready` and `--loop` work as above: the repository is
255
- cloned into the home of the template's user. `E2B_DOMAIN` names an E2B you
256
- run yourself.
396
+ your agent's CLI in it: `templates/e2b-runner` builds one. There is nothing
397
+ to deploy. Each run installs this release of muster in the sandbox, as on
398
+ Vercel, and `--repo`, `--push`, `--ready` and `--loop` work as above: the
399
+ repository is cloned into the home of the template's user. `E2B_DOMAIN` names
400
+ an E2B you run yourself.
401
+
402
+ **A base snapshot:** the first run keeps a snapshot of the template with this
403
+ release of muster installed, with no credential, repository or environment
404
+ in it, and every run after starts from it. Its ID is written down in
405
+ `~/.config/muster/e2b-bases.json`: a run starts only from a snapshot this
406
+ machine made. A newer muster makes another and removes the older one.
407
+ `MUSTER_E2B_BASE=off` sets each run up from nothing.
408
+
409
+ **How long a sandbox lives:** a sandbox lives an hour at most on E2B's Hobby
410
+ plan. `mu run` refuses a run that wouldn't fit, its `--timeout` and
411
+ 10 minutes more, with `timeout_too_long`. A `--ready` worker with no
412
+ `--timeout` gets 50 minutes there. On a plan that allows more, set
413
+ `MUSTER_E2B_MAX_LIFETIME`, to `24h` say.
257
414
 
258
415
  E2B's network rules are for a host. They can add a header to what goes to
259
- it, and can't tell one path or method from another. Five things follow.
416
+ it, and can't tell one path or method from another. Five things follow:
260
417
 
261
- - **The board holds the agent's token to a sandbox's routes itself.** The
418
+ - **The board itself limits the agent's token to a sandbox's routes.** The
262
419
  token `mu run --as` has made is marked for a sandbox, and one you make
263
- needs `mu token create --sandbox`: the board then refuses it schedules,
264
- cursors, workflow requests, the feed, MCP and the routes that take no
265
- token. A token without the mark is refused before anything starts
266
- (`agent_token_unmarked`); so is one from a board older than this `mu`.
267
- Give the board a hostname of its own: whatever else answers on that host
268
- is sent the token too.
269
- - **A model key works on every path of its provider's host,** not only the
270
- calls that ask the model. So `mu run` refuses to use one there
271
- (`model_key_unscoped`) until you set `MUSTER_E2B_KEY_ANY_PATH=1`. Use a key
272
- made for this alone: its own workspace and a spend limit.
420
+ needs `mu token create --sandbox`. The board then refuses that token
421
+ access to schedules, cursors, workflow requests, the feed, MCP (Model
422
+ Context Protocol) and the routes that take no token. `mu run` refuses a
423
+ token without the mark before anything starts (`agent_token_unmarked`), and
424
+ a token from a board older than this `mu` the same way. Give the board
425
+ a hostname of its own: whatever else answers on that host is sent the
426
+ token too.
427
+ - **A model key works on every path of its provider's host.** It isn't
428
+ limited to the calls that ask the model, so `mu run` refuses to use one
429
+ there (`model_key_unscoped`) until you set `MUSTER_E2B_KEY_ANY_PATH=1`. Use
430
+ a key made for this alone: its own workspace and a spend limit.
273
431
  - **Credentials are stored at E2B for the length of the run.** The board's
274
432
  token and the model's key are secrets in your E2B project, under random
275
433
  names, and E2B adds them to the sandbox's requests. They are made once the
276
434
  repository is cloned and its dependencies installed, and removed when the
277
- run ends. The clone's token is stored only while the clone runs, and is
278
- on every request to github.com for that time: it is one made to read that
435
+ run ends. The clone's token is stored only while the clone runs, and is on
436
+ every request to github.com for that time: it is one made to read that
279
437
  repository alone. Anyone with the project's `E2B_API_KEY` can attach a
280
438
  stored secret to a sandbox of their own, so use a project for this and
281
439
  nothing else.
@@ -289,139 +447,211 @@ it, and can't tell one path or method from another. Five things follow.
289
447
  `MUSTER_E2B_MODEL_SECRET=<name>` uses a secret you stored at E2B yourself as
290
448
  the model's key: the key then never passes through `mu`, nothing reads it
291
449
  from this machine, and `mu` never removes it. It also halves what a run
292
- stores. A Hobby project holds 10 secrets and each run holds two, so about
293
- five runs at once, or nine with a secret of your own; a 409 from E2B is said
294
- as `runner_secrets_full`.
295
-
296
- A sandbox lives an hour at most on E2B's Hobby plan. A run that wouldn't
297
- fit, its `--timeout` and ten minutes more, is refused with
298
- `timeout_too_long`, and a `--ready` worker with no `--timeout` gets 50
299
- minutes there. On a plan that allows more, set `MUSTER_E2B_MAX_LIFETIME`, to
300
- `24h` say.
301
-
302
- Before the agent starts, `mu whoami` is run in the sandbox as the agent. E2B
303
- sends a request without its credential when it can't find the secret, and
304
- says nothing, so a run whose agent couldn't reach the board is stopped there
305
- (`runner_setup_failed`). A model key that didn't arrive shows as the agent's
306
- own 401s.
307
-
308
- Closing a sandbox's way out on E2B refuses new connections and leaves the
309
- open ones open. So once a repository's dependencies are installed, with
310
- every host open, `mu run` ends every process that wasn't running before the
311
- repository was there, as root, before the agent's credentials are stored;
312
- a run where one couldn't be ended is stopped (`runner_setup_failed`). It
313
- does the same after the agent exits, before a `--push` reads its changes
314
- out. This ends what an install left running; it is not a wall. Code in an
315
- E2B sandbox can become root there, and code that is root could hide in a
316
- process that was already running. As everywhere: launch only on code you
317
- would run.
450
+ stores. A Hobby project holds 10 secrets and each run holds 2, so about
451
+ 5 runs at once, or 9 with a secret of your own.
318
452
 
319
- E2B adds a credential only to requests for the host it is for: it connects
320
- to that host itself, whatever address the sandbox dialled, and adds nothing
321
- when the request's `Host` names another.
453
+ Before the agent starts, `mu run` runs `mu whoami` in the sandbox as the
454
+ agent. E2B sends a request without its credential when it can't find the
455
+ secret, and says nothing, so `mu run` stops a run whose agent couldn't reach
456
+ the board there (`runner_setup_failed`).
322
457
 
323
- The first run keeps a snapshot of the template with this release of muster
324
- installed, with no credential, repository or environment in it, and every
325
- run after starts from it. Its ID is written down in
326
- `~/.config/muster/e2b-bases.json`: a run starts only from a snapshot this
327
- machine made. A newer muster makes another and removes the older one.
328
- `MUSTER_E2B_BASE=off` sets each run up from nothing.
458
+ What E2B's network can't close is under
459
+ [On E2B's network](#on-e2bs-network).
329
460
 
330
- The sandbox can reach a DNS server whenever a host is open to it, and a
331
- lookup can carry data out: E2B has no way to close that and still resolve
332
- the hosts that are open. No credential is in the sandbox to take, but a
333
- private repository's code is.
461
+ ## Start a runner from code
334
462
 
335
- ## The model's key
463
+ The runners are also functions in the package. This starts a task on
464
+ Cloudflare, with the Vercel call left commented out:
336
465
 
337
- The agent's laptop sign-in doesn't travel to a sandbox: it needs a key for its
338
- model provider. Set it where you run `mu run`, in `ANTHROPIC_API_KEY` for
339
- Claude Code or `OPENAI_API_KEY` for Codex.
466
+ ```ts runners.ts
467
+ import { claude, cloudflare, vercel } from '@openmuster/muster'
468
+ // import { Sandbox } from '@vercel/sandbox'
340
469
 
341
- ```bash
342
- export ANTHROPIC_API_KEY=sk-ant-...
343
- mu run 12 --runner vercel --agent claude
470
+ const board = { url: 'https://board.example.com/api/board', token: process.env.AGENT_TOKEN! }
471
+ const prompt = 'Claim task #12 first: mu tasks claim 12'
472
+
473
+ // await vercel({ Sandbox }).start({ task: 12, agent: claude, prompt, board })
474
+ await cloudflare({ worker: 'https://runner.example.workers.dev', secret: process.env.RUNNER_SECRET! }).start({ task: 12, agent: claude, prompt, board })
344
475
  ```
345
476
 
346
- Like the board's token, the key stays out of the sandbox. Its environment
347
- holds a placeholder, and the key is added on the way out, only to the calls
348
- that ask the model (`POST /v1/messages` on `api.anthropic.com`;
349
- `/v1/responses` and `/v1/chat/completions` on `api.openai.com`). Any other
350
- request to that host is refused. On E2B the key goes on every request to
351
- that host, and is used only when you accept that: see [On E2B](#on-e2b).
477
+ The sample does what `mu run` does to start a sandbox, without the rest:
352
478
 
353
- > [!WARNING]
354
- > The agent can't read the key, but it can still use it. A request that asks
355
- > the model can also ask the provider to fetch a URL or call an outside
356
- > server, and the policy sees addresses, not request bodies. So a steered
357
- > agent could send what it has read out through the provider. Until muster
358
- > filters those requests, use a key made for this: its own workspace, a spend
359
- > limit, and the provider's web tools turned off.
479
+ - **`board`** is the board's address and the agent's token, read here from
480
+ `AGENT_TOKEN`. Use a token made for the agent, as in
481
+ [Choose the agent's token](#choose-the-agents-token).
482
+ - **`prompt`** is what the agent is told. Here it tells the agent to claim
483
+ task 12 first.
484
+ - **The last line** starts Claude Code on task 12 in a container on your
485
+ Worker, given the Worker's URL and its secret from `RUNNER_SECRET`.
486
+ - **The two commented lines** are the Vercel version: uncomment them, and
487
+ leave out the `cloudflare` call, to start the same task in a Vercel
488
+ sandbox.
360
489
 
361
- Without the variable, `mu run` warns and starts the agent anyway, which works
362
- only if the sandbox's image has a sign-in of its own.
490
+ ## What keeps credentials out of the sandbox
363
491
 
364
- The Vercel runner starts from `vercel/sandbox/universal`. It signs in to
365
- Vercel with an access token when `VERCEL_TOKEN`, `VERCEL_TEAM_ID` and
366
- `VERCEL_PROJECT_ID` are all set, and otherwise with a linked project's
367
- `VERCEL_OIDC_TOKEN`, from `vercel env pull`. Only some of the three is an
368
- error. None of them enters the sandbox.
369
-
370
- ## Where the credential is
492
+ ### Where the credential is
371
493
 
372
494
  Not in the sandbox. The sandbox's environment holds the board's URL and a
373
- placeholder. The token is added to each request after it leaves the sandbox,
495
+ placeholder. The token is added to each request after it leaves the sandbox:
374
496
  by the platform's network policy on Vercel, by your Worker on Cloudflare,
375
497
  and by E2B from a secret stored there for the run.
376
498
 
499
+ ### What the sandbox can reach
500
+
377
501
  The policy lets the sandbox reach:
378
502
 
379
503
  - the board's host, the model provider's host when its key is set, and
380
504
  nothing else you didn't add. Each credential is sent only to the host it
381
- is for, whatever the request's own Host header says. A host you add is a way out of the sandbox
382
- for whatever the agent reads, so add few;
383
- - on it, only the board's own routes, by method;
505
+ is for, whatever the request's own Host header says. The agent can send
506
+ whatever it reads to a host you add, so add few;
507
+ - on the board, only its own routes, by method: messages, tasks, files and
508
+ reads;
384
509
  - not the routes that run the board: webhooks, tokens, schedules, budgets,
385
510
  schemas.
386
511
 
387
- A path with dot segments or an encoded slash doesn't pass.
512
+ A path with dot segments or an encoded slash doesn't pass. A sandbox can't
513
+ make schedules or schemas, set budgets, or move a stored cursor. A file it
514
+ stores needs a token that may post, and a narrowed token has an allowance of
515
+ 100 MB a day.
388
516
 
389
517
  On E2B the network opens hosts, not routes: the board refuses the other
390
- routes itself, to a token made for a sandbox.
518
+ routes itself, to a token made for a sandbox ([On E2B](#on-e2b)).
391
519
 
392
- ## What is left afterwards
520
+ ### Setting up holds no credential
393
521
 
394
- Nothing, once `mu run` ends it. An E2B sandbox is removed and the secrets
395
- stored for it are too; a run that was killed leaves them until the next one
396
- removes them, as [On E2B](#on-e2b) says. A Vercel sandbox is started so that it isn't
397
- kept, and when the run exits or is stopped its way out is closed and the
398
- sandbox is deleted, so it isn't left in Vercel's list either. A setup step
399
- that fails ends it the same way. With `--detach`, or if this machine sleeps
400
- through the run, it is stopped at its timeout instead, and stays listed as
401
- stopped. A kept sandbox
402
- would hold the repository, the agent's transcript and a policy with the
403
- credentials in it.
522
+ A Vercel sandbox is made under a policy of its own for setting up, with
523
+ none of the credentials in it. It opens GitHub's hosts to clone and to
524
+ install muster, and every host while your repository's dependencies install,
525
+ since a lockfile can name any registry. Once set up, the agent's policy
526
+ replaces that one, and the agent starts with only the board and its model's
527
+ host open. Code that ran while setting up could reach the internet, but
528
+ there was nothing to take: the tokens only ever go on requests after that.
404
529
 
405
- On the board, a sandbox reaches a named list of routes: messages, tasks,
406
- files and reads. It can't make schedules or schemas, set budgets, or move a
407
- stored cursor. A file it stores needs a token that may post, and a narrowed
408
- token has an allowance of 100 MB a day.
530
+ A Cloudflare container never has that: while dependencies install, the
531
+ registries are open to read and nothing else is, the board and the model's
532
+ host included. Once the install is done, the registries close, every process
533
+ it left running is killed, and only then do the board and the model's host
534
+ open again, for the agent.
409
535
 
410
- ## From code
536
+ A repository's own configuration still runs at install, scripts or not: a
537
+ `.pnpmfile.cjs`, a yarn plugin, an `.npmrc` pointing at a registry of its
538
+ choosing. That is the repository's code, like its tests, which the agent
539
+ runs anyway.
411
540
 
412
- ```ts runners.ts
413
- import { claude, cloudflare, vercel } from '@openmuster/muster'
414
- // import { Sandbox } from '@vercel/sandbox'
541
+ ### What a push never exposes
415
542
 
416
- const board = { url: 'https://board.example.com/api/board', token: process.env.AGENT_TOKEN! }
417
- const prompt = 'Claim task #12 first: mu tasks claim 12'
543
+ - **No token is ever where the agent has been.** The read token is in the
544
+ sandbox's policy only while the repository is cloned, before any of
545
+ the repository's code runs, and only on its git fetch routes. The push is
546
+ made here, from a repository made for it, and its branch is the one
547
+ `mu run` names. So nothing the agent left behind, a hook, a process, a
548
+ changed `git`, can use the token or pick what it writes.
549
+ - **What the agent left is data.** Git runs in the sandbox with no hooks, no
550
+ fsmonitor and no global config, under a policy that reaches nothing, and
551
+ all that comes out is the bundle, which becomes the branch.
552
+ - **`mu run` opens the pull request from your machine.** GitHub's API is
553
+ never reachable from the sandbox.
554
+ - **On Cloudflare the Worker does the closing.** When it sees the agent
555
+ exit, it shuts every host the run opened and kills whatever the agent left
556
+ running, before anything is read. Only then does it run the bundle step and
557
+ return the bundle, each with a time limit and a size limit.
418
558
 
419
- // await vercel({ Sandbox }).start({ task: 12, agent: claude, prompt, board })
420
- await cloudflare({ worker: 'https://runner.example.workers.dev', secret: process.env.RUNNER_SECRET! }).start({ task: 12, agent: claude, prompt, board })
421
- ```
559
+ The write token can write any branch of the repository for its hour, though
560
+ only this machine holds it, and `mu run` only ever pushes `mu/task-<id>`:
561
+ protect the branches that matter on GitHub all the same.
422
562
 
423
- ## What it doesn't protect
563
+ ### What the model key can still do
564
+
565
+ > [!WARNING]
566
+ > The agent can't read the key, but it can still use it. A request that asks
567
+ > the model can also ask the provider to fetch a URL or call an outside
568
+ > server, and the policy sees addresses, not request bodies. So a steered
569
+ > agent could send what it has read out through the provider. Until muster
570
+ > filters those requests, use a key made for this: its own workspace, a spend
571
+ > limit, and the provider's web tools turned off.
572
+
573
+ ### On E2B's network
574
+
575
+ E2B adds a credential only to requests for the host it is for: it connects
576
+ to that host itself, whatever address the sandbox dialled, and adds nothing
577
+ when the request's `Host` names another.
578
+
579
+ Closing a sandbox's network on E2B refuses new connections and leaves the
580
+ open ones open. So once a repository's dependencies are installed, with
581
+ every host open, `mu run` ends, as root, every process that wasn't running
582
+ before the repository was there. It does this before the agent's
583
+ credentials are stored, and stops a run where one couldn't be ended
584
+ (`runner_setup_failed`). It does the same after the agent exits, before a
585
+ `--push` reads its changes out.
586
+
587
+ This ends what an install left running; it is not a security boundary. Code
588
+ in an E2B sandbox can become root there, and code that is root could hide in
589
+ a process that was already running.
590
+
591
+ The sandbox can reach a Domain Name System (DNS) server whenever a host is
592
+ open to it, and code can send data out inside a lookup: E2B has no way to
593
+ close that and still resolve the hosts that are open. No credential is in
594
+ the sandbox to take, but a private repository's code is.
595
+
596
+ ### What is left afterwards
597
+
598
+ Nothing is left once `mu run` ends the sandbox. A kept sandbox would hold the
599
+ repository, the agent's transcript and a policy with the credentials in it.
600
+
601
+ `mu run` starts a Vercel sandbox as one that isn't kept. When the run exits
602
+ or is stopped, `mu run` closes it to every host and deletes it, so it isn't
603
+ left in Vercel's list either. A setup step that fails ends it the same way.
604
+ With `--detach`, or if this machine sleeps through the run, Vercel stops it
605
+ at its timeout instead, and it stays listed as stopped.
606
+
607
+ An E2B sandbox is removed and the secrets stored for it are too; a run that
608
+ was killed leaves them until the next one removes them, as
609
+ [On E2B](#on-e2b) says.
610
+
611
+ ### What it doesn't protect
424
612
 
425
613
  Code from the repository runs in the sandbox and can use the board, as the
426
614
  agent, for as long as the sandbox lives. Hold the token to the channels the
427
615
  work needs, give it a short `--ttl`, and launch only on code you would run.
616
+
617
+ ## When not to use a sandbox
618
+
619
+ - **On code you wouldn't run yourself:** the repository's code, its install
620
+ configuration and its tests run in the sandbox, and can use the board as
621
+ the agent.
622
+ - **When the agent needs its own sign-in:** a sandbox has no laptop
623
+ sign-in, so run the agent on this machine instead, with
624
+ [Running agents](./05-running-agents.md).
625
+ - **On E2B, with a private repository whose code must not leave:** code in
626
+ the sandbox can send data out in a DNS lookup
627
+ ([On E2B's network](#on-e2bs-network)).
628
+
629
+ ## What goes wrong
630
+
631
+ - **A Cloudflare run's install says `failed (exit 127)`.** The repository
632
+ has a `bun.lock`, and the Cloudflare image has no bun. The agent starts
633
+ without its dependencies: see [On Cloudflare](#on-cloudflare).
634
+ - **The agent gets 401s from its model.** The model key didn't arrive: check
635
+ the key's variable on this machine, or on E2B the secret
636
+ ([Give the agent a model key](#give-the-agent-a-model-key)).
637
+ - **`runner_secrets_full` on E2B:** `mu run` reports a 409 from E2B this way:
638
+ the project holds no more secrets. Wait for a run to end, or use
639
+ `MUSTER_E2B_MODEL_SECRET` ([On E2B](#on-e2b)).
640
+ - **`runner_setup_failed` on E2B, before the agent starts:** the agent
641
+ couldn't reach the board as itself, or a process from the install couldn't
642
+ be ended ([On E2B](#on-e2b), [On E2B's network](#on-e2bs-network)).
643
+ - **`push_conflict`, and the tasks after it blocked:** the branch moved, or
644
+ the change didn't build on it
645
+ ([Another round on the same pull request](#another-round-on-the-same-pull-request)).
646
+ - **A worker stops with `runner_start_failed`.** The runner refused a start,
647
+ or 3 starts failed in a row
648
+ ([Give each task its own sandbox](#give-each-task-its-own-sandbox)).
649
+
650
+ ## Related
651
+
652
+ - [Runners](../01-concepts/14-runners.md): what `mu run` does, and the
653
+ runners side by side
654
+ - [Running agents](./05-running-agents.md): the same `mu run` on this machine
655
+ - [A board on a server](./18-a-board-on-a-server.md): a board a sandbox can
656
+ reach, with tokens for agents
657
+ - [Tasks](../01-concepts/08-tasks.md): claims, states and rounds