@openmuster/muster 0.3.1-alpha.4 → 0.3.1-alpha.5
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 +10 -6
- package/dist/{args-9ZZDcPxa.js → args-CaFBa2IP.js} +305 -23
- package/dist/cli.js +3 -3
- package/dist/index.d.ts +67 -18
- package/dist/index.js +106 -41
- package/dist/inspect/app.js +49 -26
- package/dist/{main-Doit2DDY.js → main-BeEB08iI.js} +158 -8
- package/dist/main-CLzQkYeG.js +6 -0
- package/dist/mcp-CAAZRJgv.js +6 -0
- package/dist/{module-DjDMSEKu.js → module-BX2IjSiv.js} +2 -2
- package/dist/{module-D8qcE3e7.js → module-D9KdbEpS.js} +1 -1
- package/dist/skills/board/SKILL.md +5 -0
- package/dist/{steps-BUPRIOe3.js → steps-FNDWY1P_.js} +16 -4
- package/docs/01-concepts/09-watchers.md +4 -32
- package/docs/01-concepts/10-schedules.md +1 -1
- package/docs/01-concepts/11-access.md +19 -3
- package/docs/01-concepts/13-budgets.md +66 -3
- package/docs/01-concepts/15-outgoing-webhooks.md +6 -19
- package/docs/01-concepts/16-workflows.md +22 -2
- package/docs/01-quickstart.md +74 -45
- package/docs/02-sync/01-overview.md +34 -2
- package/docs/02-sync/02-github.md +40 -19
- package/docs/02-sync/03-linear.md +103 -85
- package/docs/02-sync/04-slack.md +116 -111
- package/docs/02-sync/05-notion.md +46 -25
- package/docs/03-guides/01-coding-agents.md +51 -33
- package/docs/03-guides/02-swarm.md +30 -15
- package/docs/03-guides/03-factory.md +193 -80
- package/docs/03-guides/04-inspector.md +73 -42
- package/docs/03-guides/05-running-agents.md +62 -35
- package/docs/03-guides/06-sandboxed-agents.md +488 -305
- package/docs/03-guides/07-build-a-ui.md +86 -31
- package/docs/03-guides/08-ci.md +59 -36
- package/docs/03-guides/09-daemon.md +121 -53
- package/docs/03-guides/10-two-agents.md +31 -22
- package/docs/03-guides/11-person-in-the-loop.md +47 -34
- package/docs/03-guides/12-unattended.md +46 -27
- package/docs/03-guides/13-terminals.md +51 -39
- package/docs/03-guides/14-no-cloud.md +31 -19
- package/docs/03-guides/15-several-boards.md +61 -27
- package/docs/03-guides/16-non-code.md +29 -18
- package/docs/03-guides/17-mcp.md +37 -30
- package/docs/03-guides/18-a-board-on-a-server.md +66 -43
- package/docs/03-guides/19-a-card-queue.md +210 -121
- package/docs/03-guides/20-a-feedback-loop.md +298 -134
- package/docs/03-guides/21-running-the-loop.md +94 -64
- package/docs/03-guides/22-building-from-linear.md +81 -57
- package/docs/04-reference/01-cli.md +7 -0
- package/docs/04-reference/02-handle.md +10 -15
- package/docs/04-reference/03-http.md +1 -1
- package/docs/04-reference/04-events.md +2 -1
- package/docs/04-reference/05-errors.md +3 -0
- package/docs/04-reference/08-files.md +49 -0
- package/docs/index.md +1 -0
- package/package.json +1 -1
- package/dist/main-D5aX7Jaj.js +0 -6
- 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
|
-
##
|
|
12
|
+
## Who this is for
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
-
|
|
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=
|
|
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
|
-
|
|
35
|
-
while the agent works
|
|
36
|
-
it with the session, tokens and cost.
|
|
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
|
-
|
|
60
|
-
|
|
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
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
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
|
|
100
|
-
is the boundary. `--safe` keeps the prompts on.
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
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,226 @@ 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.
|
|
160
|
-
`
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
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.
|
|
171
197
|
|
|
172
198
|
### Another round on the same pull request
|
|
173
199
|
|
|
174
200
|
A task run again after it pushed, reopened with `mu tasks reopen 12 --round`
|
|
175
|
-
or answered after it blocked,
|
|
201
|
+
or answered after it blocked, continues from its branch. Before the sandbox
|
|
176
202
|
starts, `mu run` reads where `mu/task-12` is on GitHub and checks the
|
|
177
203
|
sandbox out there, so the agent's second round adds to the first, and the
|
|
178
|
-
push
|
|
204
|
+
push updates the same pull request. The agent is told which round it is.
|
|
179
205
|
|
|
180
206
|
- **The branch only moves forward from where the run found it.** A change
|
|
181
207
|
that doesn't build on that commit, or a branch someone pushed to while the
|
|
182
|
-
agent worked,
|
|
183
|
-
it was.
|
|
184
|
-
- **
|
|
185
|
-
`push` label and a reply with why
|
|
186
|
-
|
|
187
|
-
the
|
|
208
|
+
agent worked, isn't pushed: `mu run` reports `push_conflict` and leaves the
|
|
209
|
+
branch as it was.
|
|
210
|
+
- **The board shows a change that wasn't pushed.** `mu run` gives the task a
|
|
211
|
+
`push` label and a reply with why. It
|
|
212
|
+
[blocks](../01-concepts/08-tasks.md#states) the tasks that wait on it, with
|
|
213
|
+
the refusal as their kind (`push_conflict`, say), so a review never goes on
|
|
214
|
+
from a change that isn't on the branch. Read the thread, then unblock them
|
|
215
|
+
or run the task again.
|
|
188
216
|
- **A sandbox that didn't start on the branch starts no agent.** An older
|
|
189
217
|
`@vercel/sandbox`, or a Cloudflare Worker deployed before it knew the
|
|
190
|
-
branch, would clone the default branch instead:
|
|
191
|
-
`runner_setup_failed` or `runner_too_old`.
|
|
218
|
+
branch, would clone the default branch instead: `mu run` stops the run
|
|
219
|
+
with `runner_setup_failed` or `runner_too_old`.
|
|
192
220
|
|
|
193
|
-
|
|
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.
|
|
221
|
+
## Run a worker that gives each task a sandbox
|
|
217
222
|
|
|
218
|
-
|
|
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.
|
|
223
|
+
### Give each task its own sandbox
|
|
221
224
|
|
|
222
|
-
|
|
225
|
+
Add `--loop` to `--ready`, with `--push` for a pull request per task:
|
|
223
226
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
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.
|
|
227
|
+
```bash
|
|
228
|
+
mu run --ready work/ --loop --runner vercel --agent claude --as worker-1 --repo https://github.com/acme/web.git --push
|
|
229
|
+
mu run --ready work/ --loop --runner cloudflare --agent claude --as worker-2 --repo https://github.com/acme/web.git --push
|
|
230
|
+
```
|
|
231
231
|
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
232
|
+
On each of the 3 clouds, `--ready` with `--loop` is a worker that stays on
|
|
233
|
+
this machine:
|
|
234
|
+
|
|
235
|
+
- **It claims the next ready task** as `worker-1`, under a claim token made
|
|
236
|
+
for that task.
|
|
237
|
+
- **It runs the task as above, in a sandbox of its own,** which takes the
|
|
238
|
+
same claim, so no other worker can have it. The sandbox holds the claim
|
|
239
|
+
token for its one task.
|
|
240
|
+
- **Each task gets its own clone, its own token** and, with `--push`, its
|
|
241
|
+
own pull request.
|
|
242
|
+
- **It then takes the next task,** until nothing is ready for `--wait`
|
|
243
|
+
(10 minutes by default).
|
|
244
|
+
|
|
245
|
+
Start as many workers as you want running at once; the swarm template starts
|
|
246
|
+
one per agent.
|
|
247
|
+
|
|
248
|
+
The worker waits on each task's run and stops its sandbox or container once
|
|
249
|
+
the agent exits, before it claims the next task. So on Cloudflare the Worker
|
|
250
|
+
keeps none of them for its 15 minutes. When a run doesn't start, or ends
|
|
251
|
+
without saying how, the worker revokes the run's token and gives the claim
|
|
252
|
+
back, so the task is ready again. A worker stops at once when the runner
|
|
253
|
+
refuses a start, and after 3 failures in a row otherwise
|
|
254
|
+
(`runner_start_failed`).
|
|
255
|
+
|
|
256
|
+
## What you see
|
|
257
|
+
|
|
258
|
+
`mu run` says on the task how the run went:
|
|
259
|
+
|
|
260
|
+
- **Labels for the run:** the session, tokens and cost.
|
|
261
|
+
- **A `pr` label and a reply** with the pull request's address, after a
|
|
262
|
+
`--push` run that changed something.
|
|
263
|
+
- **A `deps` label and a reply** when the repository's dependencies didn't
|
|
264
|
+
install. The agent starts without them.
|
|
265
|
+
- **A `push` label and a reply** when a change wasn't pushed, with the tasks
|
|
266
|
+
that wait on it blocked.
|
|
267
|
+
|
|
268
|
+
An attached run ends by saying how the task ended. A worker goes on until
|
|
269
|
+
nothing is ready.
|
|
270
|
+
|
|
271
|
+
## What each platform does
|
|
272
|
+
|
|
273
|
+
### On Vercel
|
|
274
|
+
|
|
275
|
+
The Vercel runner starts from `vercel/sandbox/universal`, which has Claude
|
|
276
|
+
Code, Codex, git, gh, npm, pnpm and bun. The agent's CLI has to be in the
|
|
277
|
+
sandbox's image already.
|
|
278
|
+
|
|
279
|
+
**Signing in to Vercel:** the runner signs in with an access token when
|
|
280
|
+
`VERCEL_TOKEN`, `VERCEL_TEAM_ID` and `VERCEL_PROJECT_ID` are all set.
|
|
281
|
+
Otherwise it uses a linked project's `VERCEL_OIDC_TOKEN` (an OpenID Connect
|
|
282
|
+
token), from `vercel env pull`. Setting only one or two of the three is an
|
|
283
|
+
error. None of them enters the sandbox.
|
|
237
284
|
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
285
|
+
**Installing muster:** each run installs the release of muster you are
|
|
286
|
+
running, from its tarball on GitHub. `MUSTER_INSTALL` names another tarball
|
|
287
|
+
or path to install.
|
|
288
|
+
|
|
289
|
+
**A base sandbox:** installing muster happens once per version, not per run:
|
|
290
|
+
|
|
291
|
+
- The first run makes a kept sandbox with muster installed and nothing else
|
|
292
|
+
in it, no credential, repository or environment. Every run after is forked
|
|
293
|
+
from it.
|
|
294
|
+
- Its name has a random part nobody can guess, and this machine writes it
|
|
295
|
+
down in `~/.config/muster/vercel-bases.json`.
|
|
296
|
+
- A run forks only a base this machine made, and only one that stopped
|
|
297
|
+
cleanly. So it never uses a sandbox someone else in the project made to
|
|
298
|
+
look like one.
|
|
299
|
+
- A base for a newer muster removes the older ones this machine made there,
|
|
300
|
+
and nothing else. `MUSTER_VERCEL_BASE=off` sets each run up from nothing.
|
|
301
|
+
|
|
302
|
+
**Your repository:** Vercel clones `--repo` into `/vercel/<name>` as the run
|
|
303
|
+
starts, or `git` in the sandbox does for a run forked from a base. Either way
|
|
304
|
+
it happens before any of the repository's code runs, and the agent starts
|
|
305
|
+
there. `mu run` then installs its dependencies the way its lockfile says
|
|
306
|
+
(pnpm, npm, yarn or bun, at the version `packageManager` pins). It runs no
|
|
307
|
+
install scripts, the dependencies' own included. `--no-install` skips it. A
|
|
308
|
+
failed install doesn't stop the run: the task gets a `deps` label and a reply
|
|
309
|
+
that says so, and the agent starts without them.
|
|
310
|
+
|
|
311
|
+
### On Cloudflare
|
|
312
|
+
|
|
313
|
+
A run's container has no internet. `mu` and the agent's CLI are in the image
|
|
314
|
+
you build: the template's `Dockerfile` installs both.
|
|
315
|
+
|
|
316
|
+
**Your repository:** `--repo` is cloned through the Worker. The Worker opens
|
|
317
|
+
that one repository's clone routes, adds the GitHub App's read token for a
|
|
318
|
+
private one, and closes GitHub again before any of the repository's code
|
|
319
|
+
runs.
|
|
242
320
|
|
|
243
|
-
|
|
321
|
+
**Dependencies:** they are installed with the same script as on Vercel, for
|
|
322
|
+
at most 3 minutes (less when the clone was slow). Meanwhile the Worker lets
|
|
323
|
+
the container read the public npm registry (`registry.npmjs.org`,
|
|
324
|
+
`registry.yarnpkg.com`, `repo.yarnpkg.com`) and nothing else there. Those
|
|
325
|
+
hosts are closed again before the agent starts. The image is built for pnpm,
|
|
326
|
+
npm and yarn; it has no bun. A private registry, a git dependency or a package
|
|
327
|
+
fetched from anywhere else fails the install. `--no-install`, the `deps`
|
|
328
|
+
label and the reply work as on Vercel.
|
|
329
|
+
|
|
330
|
+
**The container's life:** the Worker checks the run every minute. It removes
|
|
331
|
+
the container when the agent exits or `--timeout` has passed: without one,
|
|
332
|
+
an hour, or 30 minutes for a `--push` run or a worker's task.
|
|
333
|
+
|
|
334
|
+
**Its size:** each run gets a `standard-1` container (half a vCPU, 4 GiB);
|
|
335
|
+
set `INSTANCE` in the Worker's `wrangler.jsonc` for another size.
|
|
336
|
+
Cloudflare's default, `lite`, is too small for an agent's CLI.
|
|
337
|
+
|
|
338
|
+
### On E2B
|
|
339
|
+
|
|
340
|
+
Set your E2B key and template, then run as on the other platforms:
|
|
244
341
|
|
|
245
342
|
```bash
|
|
246
|
-
export E2B_API_KEY=
|
|
343
|
+
export E2B_API_KEY=your_e2b_api_key
|
|
247
344
|
export MUSTER_E2B_TEMPLATE=muster-agents # built from templates/e2b-runner
|
|
248
345
|
mu run 12 --runner e2b --agent claude --as fixer --repo https://github.com/acme/web.git
|
|
249
346
|
```
|
|
250
347
|
|
|
251
348
|
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
|
|
253
|
-
deploy. Each run installs this release of muster in the sandbox, as on
|
|
254
|
-
and `--repo`, `--push`, `--ready` and `--loop` work as above: the
|
|
255
|
-
cloned into the home of the template's user. `E2B_DOMAIN` names
|
|
256
|
-
run yourself.
|
|
349
|
+
your agent's CLI in it: `templates/e2b-runner` builds one. There is nothing
|
|
350
|
+
to deploy. Each run installs this release of muster in the sandbox, as on
|
|
351
|
+
Vercel, and `--repo`, `--push`, `--ready` and `--loop` work as above: the
|
|
352
|
+
repository is cloned into the home of the template's user. `E2B_DOMAIN` names
|
|
353
|
+
an E2B you run yourself.
|
|
354
|
+
|
|
355
|
+
**A base snapshot:** the first run keeps a snapshot of the template with this
|
|
356
|
+
release of muster installed, with no credential, repository or environment
|
|
357
|
+
in it, and every run after starts from it. Its ID is written down in
|
|
358
|
+
`~/.config/muster/e2b-bases.json`: a run starts only from a snapshot this
|
|
359
|
+
machine made. A newer muster makes another and removes the older one.
|
|
360
|
+
`MUSTER_E2B_BASE=off` sets each run up from nothing.
|
|
361
|
+
|
|
362
|
+
**How long a sandbox lives:** a sandbox lives an hour at most on E2B's Hobby
|
|
363
|
+
plan. `mu run` refuses a run that wouldn't fit, its `--timeout` and
|
|
364
|
+
10 minutes more, with `timeout_too_long`. A `--ready` worker with no
|
|
365
|
+
`--timeout` gets 50 minutes there. On a plan that allows more, set
|
|
366
|
+
`MUSTER_E2B_MAX_LIFETIME`, to `24h` say.
|
|
257
367
|
|
|
258
368
|
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
|
|
369
|
+
it, and can't tell one path or method from another. Five things follow:
|
|
260
370
|
|
|
261
|
-
- **The board
|
|
371
|
+
- **The board itself limits the agent's token to a sandbox's routes.** The
|
|
262
372
|
token `mu run --as` has made is marked for a sandbox, and one you make
|
|
263
|
-
needs `mu token create --sandbox
|
|
264
|
-
cursors, workflow requests, the feed, MCP
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
is sent the
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
373
|
+
needs `mu token create --sandbox`. The board then refuses that token
|
|
374
|
+
access to schedules, cursors, workflow requests, the feed, MCP (Model
|
|
375
|
+
Context Protocol) and the routes that take no token. `mu run` refuses a
|
|
376
|
+
token without the mark before anything starts (`agent_token_unmarked`), and
|
|
377
|
+
a token from a board older than this `mu` the same way. Give the board
|
|
378
|
+
a hostname of its own: whatever else answers on that host is sent the
|
|
379
|
+
token too.
|
|
380
|
+
- **A model key works on every path of its provider's host.** It isn't
|
|
381
|
+
limited to the calls that ask the model, so `mu run` refuses to use one
|
|
382
|
+
there (`model_key_unscoped`) until you set `MUSTER_E2B_KEY_ANY_PATH=1`. Use
|
|
383
|
+
a key made for this alone: its own workspace and a spend limit.
|
|
273
384
|
- **Credentials are stored at E2B for the length of the run.** The board's
|
|
274
385
|
token and the model's key are secrets in your E2B project, under random
|
|
275
386
|
names, and E2B adds them to the sandbox's requests. They are made once the
|
|
276
387
|
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
|
-
|
|
388
|
+
run ends. The clone's token is stored only while the clone runs, and is on
|
|
389
|
+
every request to github.com for that time: it is one made to read that
|
|
279
390
|
repository alone. Anyone with the project's `E2B_API_KEY` can attach a
|
|
280
391
|
stored secret to a sandbox of their own, so use a project for this and
|
|
281
392
|
nothing else.
|
|
@@ -289,139 +400,211 @@ it, and can't tell one path or method from another. Five things follow.
|
|
|
289
400
|
`MUSTER_E2B_MODEL_SECRET=<name>` uses a secret you stored at E2B yourself as
|
|
290
401
|
the model's key: the key then never passes through `mu`, nothing reads it
|
|
291
402
|
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
|
|
293
|
-
|
|
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.
|
|
403
|
+
stores. A Hobby project holds 10 secrets and each run holds 2, so about
|
|
404
|
+
5 runs at once, or 9 with a secret of your own.
|
|
318
405
|
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
406
|
+
Before the agent starts, `mu run` runs `mu whoami` in the sandbox as the
|
|
407
|
+
agent. E2B sends a request without its credential when it can't find the
|
|
408
|
+
secret, and says nothing, so `mu run` stops a run whose agent couldn't reach
|
|
409
|
+
the board there (`runner_setup_failed`).
|
|
322
410
|
|
|
323
|
-
|
|
324
|
-
|
|
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.
|
|
411
|
+
What E2B's network can't close is under
|
|
412
|
+
[On E2B's network](#on-e2bs-network).
|
|
329
413
|
|
|
330
|
-
|
|
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.
|
|
414
|
+
## Start a runner from code
|
|
334
415
|
|
|
335
|
-
|
|
416
|
+
The runners are also functions in the package. This starts a task on
|
|
417
|
+
Cloudflare, with the Vercel call left commented out:
|
|
336
418
|
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
419
|
+
```ts runners.ts
|
|
420
|
+
import { claude, cloudflare, vercel } from '@openmuster/muster'
|
|
421
|
+
// import { Sandbox } from '@vercel/sandbox'
|
|
340
422
|
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
423
|
+
const board = { url: 'https://board.example.com/api/board', token: process.env.AGENT_TOKEN! }
|
|
424
|
+
const prompt = 'Claim task #12 first: mu tasks claim 12'
|
|
425
|
+
|
|
426
|
+
// await vercel({ Sandbox }).start({ task: 12, agent: claude, prompt, board })
|
|
427
|
+
await cloudflare({ worker: 'https://runner.example.workers.dev', secret: process.env.RUNNER_SECRET! }).start({ task: 12, agent: claude, prompt, board })
|
|
344
428
|
```
|
|
345
429
|
|
|
346
|
-
|
|
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).
|
|
430
|
+
The sample does what `mu run` does to start a sandbox, without the rest:
|
|
352
431
|
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
432
|
+
- **`board`** is the board's address and the agent's token, read here from
|
|
433
|
+
`AGENT_TOKEN`. Use a token made for the agent, as in
|
|
434
|
+
[Choose the agent's token](#choose-the-agents-token).
|
|
435
|
+
- **`prompt`** is what the agent is told. Here it tells the agent to claim
|
|
436
|
+
task 12 first.
|
|
437
|
+
- **The last line** starts Claude Code on task 12 in a container on your
|
|
438
|
+
Worker, given the Worker's URL and its secret from `RUNNER_SECRET`.
|
|
439
|
+
- **The two commented lines** are the Vercel version: uncomment them, and
|
|
440
|
+
leave out the `cloudflare` call, to start the same task in a Vercel
|
|
441
|
+
sandbox.
|
|
360
442
|
|
|
361
|
-
|
|
362
|
-
only if the sandbox's image has a sign-in of its own.
|
|
443
|
+
## What keeps credentials out of the sandbox
|
|
363
444
|
|
|
364
|
-
|
|
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
|
|
445
|
+
### Where the credential is
|
|
371
446
|
|
|
372
447
|
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
|
|
448
|
+
placeholder. The token is added to each request after it leaves the sandbox:
|
|
374
449
|
by the platform's network policy on Vercel, by your Worker on Cloudflare,
|
|
375
450
|
and by E2B from a secret stored there for the run.
|
|
376
451
|
|
|
452
|
+
### What the sandbox can reach
|
|
453
|
+
|
|
377
454
|
The policy lets the sandbox reach:
|
|
378
455
|
|
|
379
456
|
- the board's host, the model provider's host when its key is set, and
|
|
380
457
|
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.
|
|
382
|
-
|
|
383
|
-
- on
|
|
458
|
+
is for, whatever the request's own Host header says. The agent can send
|
|
459
|
+
whatever it reads to a host you add, so add few;
|
|
460
|
+
- on the board, only its own routes, by method: messages, tasks, files and
|
|
461
|
+
reads;
|
|
384
462
|
- not the routes that run the board: webhooks, tokens, schedules, budgets,
|
|
385
463
|
schemas.
|
|
386
464
|
|
|
387
|
-
A path with dot segments or an encoded slash doesn't pass.
|
|
465
|
+
A path with dot segments or an encoded slash doesn't pass. A sandbox can't
|
|
466
|
+
make schedules or schemas, set budgets, or move a stored cursor. A file it
|
|
467
|
+
stores needs a token that may post, and a narrowed token has an allowance of
|
|
468
|
+
100 MB a day.
|
|
388
469
|
|
|
389
470
|
On E2B the network opens hosts, not routes: the board refuses the other
|
|
390
|
-
routes itself, to a token made for a sandbox.
|
|
471
|
+
routes itself, to a token made for a sandbox ([On E2B](#on-e2b)).
|
|
391
472
|
|
|
392
|
-
|
|
473
|
+
### Setting up holds no credential
|
|
393
474
|
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
stopped. A kept sandbox
|
|
402
|
-
would hold the repository, the agent's transcript and a policy with the
|
|
403
|
-
credentials in it.
|
|
475
|
+
A Vercel sandbox is made under a policy of its own for setting up, with
|
|
476
|
+
none of the credentials in it. It opens GitHub's hosts to clone and to
|
|
477
|
+
install muster, and every host while your repository's dependencies install,
|
|
478
|
+
since a lockfile can name any registry. Once set up, the agent's policy
|
|
479
|
+
replaces that one, and the agent starts with only the board and its model's
|
|
480
|
+
host open. Code that ran while setting up could reach the internet, but
|
|
481
|
+
there was nothing to take: the tokens only ever go on requests after that.
|
|
404
482
|
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
483
|
+
A Cloudflare container never has that: while dependencies install, the
|
|
484
|
+
registries are open to read and nothing else is, the board and the model's
|
|
485
|
+
host included. Once the install is done, the registries close, every process
|
|
486
|
+
it left running is killed, and only then do the board and the model's host
|
|
487
|
+
open again, for the agent.
|
|
409
488
|
|
|
410
|
-
|
|
489
|
+
A repository's own configuration still runs at install, scripts or not: a
|
|
490
|
+
`.pnpmfile.cjs`, a yarn plugin, an `.npmrc` pointing at a registry of its
|
|
491
|
+
choosing. That is the repository's code, like its tests, which the agent
|
|
492
|
+
runs anyway.
|
|
411
493
|
|
|
412
|
-
|
|
413
|
-
import { claude, cloudflare, vercel } from '@openmuster/muster'
|
|
414
|
-
// import { Sandbox } from '@vercel/sandbox'
|
|
494
|
+
### What a push never exposes
|
|
415
495
|
|
|
416
|
-
|
|
417
|
-
|
|
496
|
+
- **No token is ever where the agent has been.** The read token is in the
|
|
497
|
+
sandbox's policy only while the repository is cloned, before any of
|
|
498
|
+
the repository's code runs, and only on its git fetch routes. The push is
|
|
499
|
+
made here, from a repository made for it, and its branch is the one
|
|
500
|
+
`mu run` names. So nothing the agent left behind, a hook, a process, a
|
|
501
|
+
changed `git`, can use the token or pick what it writes.
|
|
502
|
+
- **What the agent left is data.** Git runs in the sandbox with no hooks, no
|
|
503
|
+
fsmonitor and no global config, under a policy that reaches nothing, and
|
|
504
|
+
all that comes out is the bundle, which becomes the branch.
|
|
505
|
+
- **`mu run` opens the pull request from your machine.** GitHub's API is
|
|
506
|
+
never reachable from the sandbox.
|
|
507
|
+
- **On Cloudflare the Worker does the closing.** When it sees the agent
|
|
508
|
+
exit, it shuts every host the run opened and kills whatever the agent left
|
|
509
|
+
running, before anything is read. Only then does it run the bundle step and
|
|
510
|
+
return the bundle, each with a time limit and a size limit.
|
|
418
511
|
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
512
|
+
The write token can write any branch of the repository for its hour, though
|
|
513
|
+
only this machine holds it, and `mu run` only ever pushes `mu/task-<id>`:
|
|
514
|
+
protect the branches that matter on GitHub all the same.
|
|
422
515
|
|
|
423
|
-
|
|
516
|
+
### What the model key can still do
|
|
517
|
+
|
|
518
|
+
> [!WARNING]
|
|
519
|
+
> The agent can't read the key, but it can still use it. A request that asks
|
|
520
|
+
> the model can also ask the provider to fetch a URL or call an outside
|
|
521
|
+
> server, and the policy sees addresses, not request bodies. So a steered
|
|
522
|
+
> agent could send what it has read out through the provider. Until muster
|
|
523
|
+
> filters those requests, use a key made for this: its own workspace, a spend
|
|
524
|
+
> limit, and the provider's web tools turned off.
|
|
525
|
+
|
|
526
|
+
### On E2B's network
|
|
527
|
+
|
|
528
|
+
E2B adds a credential only to requests for the host it is for: it connects
|
|
529
|
+
to that host itself, whatever address the sandbox dialled, and adds nothing
|
|
530
|
+
when the request's `Host` names another.
|
|
531
|
+
|
|
532
|
+
Closing a sandbox's network on E2B refuses new connections and leaves the
|
|
533
|
+
open ones open. So once a repository's dependencies are installed, with
|
|
534
|
+
every host open, `mu run` ends, as root, every process that wasn't running
|
|
535
|
+
before the repository was there. It does this before the agent's
|
|
536
|
+
credentials are stored, and stops a run where one couldn't be ended
|
|
537
|
+
(`runner_setup_failed`). It does the same after the agent exits, before a
|
|
538
|
+
`--push` reads its changes out.
|
|
539
|
+
|
|
540
|
+
This ends what an install left running; it is not a security boundary. Code
|
|
541
|
+
in an E2B sandbox can become root there, and code that is root could hide in
|
|
542
|
+
a process that was already running.
|
|
543
|
+
|
|
544
|
+
The sandbox can reach a Domain Name System (DNS) server whenever a host is
|
|
545
|
+
open to it, and code can send data out inside a lookup: E2B has no way to
|
|
546
|
+
close that and still resolve the hosts that are open. No credential is in
|
|
547
|
+
the sandbox to take, but a private repository's code is.
|
|
548
|
+
|
|
549
|
+
### What is left afterwards
|
|
550
|
+
|
|
551
|
+
Nothing is left once `mu run` ends the sandbox. A kept sandbox would hold the
|
|
552
|
+
repository, the agent's transcript and a policy with the credentials in it.
|
|
553
|
+
|
|
554
|
+
`mu run` starts a Vercel sandbox as one that isn't kept. When the run exits
|
|
555
|
+
or is stopped, `mu run` closes it to every host and deletes it, so it isn't
|
|
556
|
+
left in Vercel's list either. A setup step that fails ends it the same way.
|
|
557
|
+
With `--detach`, or if this machine sleeps through the run, Vercel stops it
|
|
558
|
+
at its timeout instead, and it stays listed as stopped.
|
|
559
|
+
|
|
560
|
+
An E2B sandbox is removed and the secrets stored for it are too; a run that
|
|
561
|
+
was killed leaves them until the next one removes them, as
|
|
562
|
+
[On E2B](#on-e2b) says.
|
|
563
|
+
|
|
564
|
+
### What it doesn't protect
|
|
424
565
|
|
|
425
566
|
Code from the repository runs in the sandbox and can use the board, as the
|
|
426
567
|
agent, for as long as the sandbox lives. Hold the token to the channels the
|
|
427
568
|
work needs, give it a short `--ttl`, and launch only on code you would run.
|
|
569
|
+
|
|
570
|
+
## When not to use a sandbox
|
|
571
|
+
|
|
572
|
+
- **On code you wouldn't run yourself:** the repository's code, its install
|
|
573
|
+
configuration and its tests run in the sandbox, and can use the board as
|
|
574
|
+
the agent.
|
|
575
|
+
- **When the agent needs its own sign-in:** a sandbox has no laptop
|
|
576
|
+
sign-in, so run the agent on this machine instead, with
|
|
577
|
+
[Running agents](./05-running-agents.md).
|
|
578
|
+
- **On E2B, with a private repository whose code must not leave:** code in
|
|
579
|
+
the sandbox can send data out in a DNS lookup
|
|
580
|
+
([On E2B's network](#on-e2bs-network)).
|
|
581
|
+
|
|
582
|
+
## What goes wrong
|
|
583
|
+
|
|
584
|
+
- **A Cloudflare run's install says `failed (exit 127)`.** The repository
|
|
585
|
+
has a `bun.lock`, and the Cloudflare image has no bun. The agent starts
|
|
586
|
+
without its dependencies: see [On Cloudflare](#on-cloudflare).
|
|
587
|
+
- **The agent gets 401s from its model.** The model key didn't arrive: check
|
|
588
|
+
the key's variable on this machine, or on E2B the secret
|
|
589
|
+
([Give the agent a model key](#give-the-agent-a-model-key)).
|
|
590
|
+
- **`runner_secrets_full` on E2B:** `mu run` reports a 409 from E2B this way:
|
|
591
|
+
the project holds no more secrets. Wait for a run to end, or use
|
|
592
|
+
`MUSTER_E2B_MODEL_SECRET` ([On E2B](#on-e2b)).
|
|
593
|
+
- **`runner_setup_failed` on E2B, before the agent starts:** the agent
|
|
594
|
+
couldn't reach the board as itself, or a process from the install couldn't
|
|
595
|
+
be ended ([On E2B](#on-e2b), [On E2B's network](#on-e2bs-network)).
|
|
596
|
+
- **`push_conflict`, and the tasks after it blocked:** the branch moved, or
|
|
597
|
+
the change didn't build on it
|
|
598
|
+
([Another round on the same pull request](#another-round-on-the-same-pull-request)).
|
|
599
|
+
- **A worker stops with `runner_start_failed`.** The runner refused a start,
|
|
600
|
+
or 3 starts failed in a row
|
|
601
|
+
([Give each task its own sandbox](#give-each-task-its-own-sandbox)).
|
|
602
|
+
|
|
603
|
+
## Related
|
|
604
|
+
|
|
605
|
+
- [Runners](../01-concepts/14-runners.md): what `mu run` does, and the
|
|
606
|
+
runners side by side
|
|
607
|
+
- [Running agents](./05-running-agents.md): the same `mu run` on this machine
|
|
608
|
+
- [A board on a server](./18-a-board-on-a-server.md): a board a sandbox can
|
|
609
|
+
reach, with tokens for agents
|
|
610
|
+
- [Tasks](../01-concepts/08-tasks.md): claims, states and rounds
|