@parcha/agentrun-serve 0.1.0-beta.29 → 0.1.0-beta.31
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/CHANGELOG.md +238 -0
- package/README.md +739 -116
- package/dist/adapters.d.ts +35 -6
- package/dist/adapters.js +152 -26
- package/dist/agents.d.ts +18 -7
- package/dist/agents.js +19 -10
- package/dist/app.js +101 -26
- package/dist/background.d.ts +29 -0
- package/dist/background.js +397 -0
- package/dist/box-egress-vm.d.ts +125 -0
- package/dist/box-egress-vm.js +350 -0
- package/dist/box-egress.d.ts +99 -0
- package/dist/box-egress.js +259 -0
- package/dist/box-image.d.ts +1 -1
- package/dist/box-image.js +9 -7
- package/dist/box-relay-vm.d.ts +84 -0
- package/dist/box-relay-vm.js +410 -0
- package/dist/box-relay.d.ts +8 -5
- package/dist/box-relay.js +14 -9
- package/dist/boxes.d.ts +28 -5
- package/dist/boxes.js +44 -18
- package/dist/browser-cost.d.ts +41 -0
- package/dist/browser-cost.js +158 -0
- package/dist/cap.d.ts +130 -21
- package/dist/cap.js +339 -67
- package/dist/cli.js +30 -4
- package/dist/coding-tools.d.ts +7 -3
- package/dist/coding-tools.js +16 -10
- package/dist/console/THIRD-PARTY-NOTICES.txt +580 -0
- package/dist/console/assets/index-CnJBf7Lc.js +486 -0
- package/dist/console/assets/index-DUHbWcIP.css +1 -0
- package/dist/console/index.html +2 -2
- package/dist/content-filter.d.ts +7 -0
- package/dist/content-filter.js +23 -0
- package/dist/decision-rows.d.ts +11 -3
- package/dist/decision-rows.js +18 -11
- package/dist/decisions.d.ts +3 -3
- package/dist/decisions.js +4 -3
- package/dist/errors.d.ts +2 -0
- package/dist/errors.js +5 -2
- package/dist/files.d.ts +9 -1
- package/dist/files.js +10 -2
- package/dist/grade.d.ts +11 -11
- package/dist/grade.js +43 -55
- package/dist/graph-served.d.ts +23 -0
- package/dist/graph-served.js +75 -0
- package/dist/graph-view.d.ts +7 -5
- package/dist/graph-view.js +10 -3
- package/dist/harness-app.d.ts +4 -2
- package/dist/harness-app.js +110 -19
- package/dist/harness-opencode/adapter.d.ts +45 -0
- package/dist/harness-opencode/adapter.js +272 -0
- package/dist/harness-opencode/binary.d.ts +18 -0
- package/dist/harness-opencode/binary.js +87 -0
- package/dist/harness-opencode/config.d.ts +24 -0
- package/dist/harness-opencode/config.js +61 -0
- package/dist/harness-opencode/harness.d.ts +77 -0
- package/dist/harness-opencode/harness.js +620 -0
- package/dist/harness-opencode/host/mcp.d.ts +40 -0
- package/dist/harness-opencode/host/mcp.js +208 -0
- package/dist/harness-opencode/host/policy.d.ts +71 -0
- package/dist/harness-opencode/host/policy.js +419 -0
- package/dist/harness-opencode/host/server.d.ts +55 -0
- package/dist/harness-opencode/host/server.js +165 -0
- package/dist/harness-opencode/index.d.ts +9 -0
- package/dist/harness-opencode/index.js +6 -0
- package/dist/harness-opencode/verify.d.ts +32 -0
- package/dist/harness-opencode/verify.js +75 -0
- package/dist/harness-opencode/versions.d.ts +33 -0
- package/dist/harness-opencode/versions.js +64 -0
- package/dist/harness.d.ts +4 -1
- package/dist/harness.js +5 -2
- package/dist/host-check.d.ts +12 -0
- package/dist/host-check.js +34 -0
- package/dist/host-tools.d.ts +12 -2
- package/dist/host-tools.js +26 -12
- package/dist/host.js +6 -2
- package/dist/hosted-search.js +5 -1
- package/dist/import.d.ts +2 -2
- package/dist/import.js +4 -3
- package/dist/key-check.d.ts +3 -2
- package/dist/key-check.js +7 -3
- package/dist/key-refusal.js +8 -4
- package/dist/key-words.d.ts +37 -0
- package/dist/key-words.js +40 -0
- package/dist/learn/check.d.ts +10 -1
- package/dist/learn/check.js +19 -1
- package/dist/learn/grade.d.ts +6 -2
- package/dist/learn/grade.js +28 -14
- package/dist/learn/index.d.ts +3 -3
- package/dist/learn/index.js +3 -3
- package/dist/learn/notes.js +2 -1
- package/dist/learn/reflect.d.ts +2 -2
- package/dist/learn/reflect.js +53 -5
- package/dist/learn/secrets.js +28 -8
- package/dist/learn/skills.d.ts +19 -4
- package/dist/learn/skills.js +95 -6
- package/dist/learned-workflow.d.ts +59 -0
- package/dist/learned-workflow.js +191 -0
- package/dist/learning-routes.d.ts +30 -1
- package/dist/learning-routes.js +173 -19
- package/dist/learning-run.d.ts +8 -6
- package/dist/learning-run.js +70 -27
- package/dist/learning-words.d.ts +12 -5
- package/dist/learning-words.js +34 -13
- package/dist/learning.d.ts +52 -3
- package/dist/learning.js +204 -4
- package/dist/mcp-gateway.d.ts +96 -0
- package/dist/mcp-gateway.js +408 -0
- package/dist/mcp-meta.d.ts +17 -0
- package/dist/mcp-meta.js +38 -0
- package/dist/mcp-servers.d.ts +33 -9
- package/dist/mcp-servers.js +58 -10
- package/dist/mcp.js +5 -5
- package/dist/model.d.ts +13 -11
- package/dist/model.js +11 -10
- package/dist/openapi/agentrun-v2.openapi.json +1 -0
- package/dist/openapi.js +407 -54
- package/dist/page.d.ts +2 -0
- package/dist/page.js +3 -0
- package/dist/paid-calls.d.ts +5 -1
- package/dist/paid-calls.js +1 -1
- package/dist/pause.d.ts +2 -0
- package/dist/place.d.ts +29 -5
- package/dist/place.js +51 -11
- package/dist/print.d.ts +7 -0
- package/dist/print.js +13 -0
- package/dist/propose.d.ts +2 -0
- package/dist/propose.js +38 -8
- package/dist/request-start.d.ts +12 -4
- package/dist/request-start.js +139 -15
- package/dist/run-box.d.ts +56 -4
- package/dist/run-box.js +183 -23
- package/dist/runnable.d.ts +13 -3
- package/dist/runnable.js +63 -6
- package/dist/runs.d.ts +266 -37
- package/dist/runs.js +884 -90
- package/dist/secrets.d.ts +27 -0
- package/dist/secrets.js +38 -2
- package/dist/server.d.ts +141 -36
- package/dist/server.js +562 -118
- package/dist/sign-ins.d.ts +99 -0
- package/dist/sign-ins.js +288 -0
- package/dist/skills.d.ts +16 -4
- package/dist/skills.js +35 -7
- package/dist/stats.d.ts +7 -2
- package/dist/stats.js +28 -7
- package/dist/tool-gate.d.ts +281 -0
- package/dist/tool-gate.js +585 -0
- package/dist/tool-keys.d.ts +48 -11
- package/dist/tool-keys.js +46 -8
- package/dist/tool-plane.d.ts +116 -27
- package/dist/tool-plane.js +232 -50
- package/dist/tools.d.ts +69 -14
- package/dist/tools.js +148 -26
- package/dist/trigger-secrets.d.ts +32 -0
- package/dist/trigger-secrets.js +143 -0
- package/dist/triggers.d.ts +439 -0
- package/dist/triggers.js +863 -0
- package/dist/turn-end.d.ts +3 -2
- package/dist/turn-end.js +3 -2
- package/dist/usage-lines.d.ts +26 -0
- package/dist/usage-lines.js +28 -0
- package/dist/validate.d.ts +2 -0
- package/dist/validate.js +11 -2
- package/dist/web-fetch.js +3 -3
- package/dist/webhooks.d.ts +11 -4
- package/dist/webhooks.js +17 -1
- package/launcher/agentrun-serve +1 -1
- package/package.json +16 -14
- package/dist/console/assets/index-BN7oVcO4.js +0 -445
- package/dist/console/assets/index-By-jkqki.css +0 -1
package/README.md
CHANGED
|
@@ -31,10 +31,17 @@ agentrun-serve on http://127.0.0.1:7340/v2 (agent store in ~/.local/share/agentr
|
|
|
31
31
|
AGENTRUN_BASE_URL=http://127.0.0.1:7340/v2
|
|
32
32
|
AGENTRUN_API_KEY=ar_local_...
|
|
33
33
|
Open http://127.0.0.1:7340/
|
|
34
|
-
Boxes:
|
|
34
|
+
Boxes: docker (on by default; set AGENTRUN_BOXES to change).
|
|
35
35
|
Set your password: http://127.0.0.1:7340/setup (the first visit sets it)
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
+
When the box image is not built yet, a line after the banner says its first build is under way (`Preparing the Docker
|
|
39
|
+
box image (first start only, a few minutes); agents can be made now, and their first run waits for it.`), and another
|
|
40
|
+
when it ends (`The Docker box image is ready.`, or why it failed). `npx @parcha/agentrun` prints the `Boxes:` line and
|
|
41
|
+
these two on stderr, after its own line on stdout. On a machine where Docker is not running, the `Boxes:` line says so instead (`Boxes: none, so new agents run on the
|
|
42
|
+
runner. Docker isn't running on this machine (no docker command on PATH): install or start Docker, then restart
|
|
43
|
+
AgentRun.`); see [Boxes](#boxes).
|
|
44
|
+
|
|
38
45
|
`Open` is [the console](#the-console), which takes [your password](#your-password). For a client, export the two lines before
|
|
39
46
|
it, then make an agent, start a run, and read its timeline until a page says `final`:
|
|
40
47
|
|
|
@@ -59,7 +66,7 @@ An edit is a new revision: `PUT $AGENTRUN_BASE_URL/agents/calc/definition` with
|
|
|
59
66
|
| `--port N` | the first free port from `7340` | The port. `0` is any free port. |
|
|
60
67
|
| `--open` | off | Open the console in this machine's browser once the server listens; not in CI, nor on Linux with no display. |
|
|
61
68
|
| `--faux MODULE` | none | Answer every model request from the module's default export (below). |
|
|
62
|
-
| `--allow-host NAME` | none | Another `Host` name to accept. Repeat it. |
|
|
69
|
+
| `--allow-host NAME` | none | Another `Host` name to accept on a loopback address, on any port. Repeat it. |
|
|
63
70
|
| `--max-runs N` | `AGENTRUN_MAX_RUNS`, else as many pi runs as fit | The most runs at once, beside the memory each run's harness reserves ([capacity](#capacity-and-health)). Over either, a new run is `429 rate_limited`. |
|
|
64
71
|
| `--documents DIR` | `AGENTRUN_SERVE_DOCUMENTS` | A read-only directory of documents a workflow's `pdf_pages` calls read by file name, confined to it. |
|
|
65
72
|
| `--allow-code-nodes` | off (`AGENTRUN_SERVE_CODE_NODES=1` turns it on) | Run workflows' `code` nodes. They run in the run's process through the DSL's `new Function` transform, which is no sandbox, so only turn it on for workflows you wrote. Off, a workflow with a code node saves with a `not_set_up_here` warning and its runs are `409 agent_not_runnable` with `details.code: true`. A call `via: "shell"` or `"executor"` is refused either way. |
|
|
@@ -78,17 +85,19 @@ use it.
|
|
|
78
85
|
## Sandbox in 60 seconds
|
|
79
86
|
|
|
80
87
|
An agent with a shell, in a Docker container of its own: on a machine with Docker, in a checkout built as above, with
|
|
81
|
-
a model key. Start the server
|
|
88
|
+
a model key. Start the server; the Docker box is on by default wherever Docker answers:
|
|
82
89
|
|
|
83
90
|
```sh
|
|
84
91
|
export AGENT_MODEL=openrouter/anthropic/claude-sonnet-5.5 OPENROUTER_API_KEY=...
|
|
85
|
-
|
|
92
|
+
node packages/serve/dist/cli.js
|
|
86
93
|
```
|
|
87
94
|
|
|
88
|
-
Its log says `event=boxes available=docker`, and its banner's last line `Boxes: docker
|
|
89
|
-
|
|
95
|
+
Its log says `event=boxes available=docker`, and its banner's last line `Boxes: docker (on by default; set
|
|
96
|
+
AGENTRUN_BOXES to change). docker boxes reach only pypi.org, files.pythonhosted.org, registry.npmjs.org, registry.yarnpkg.com,
|
|
97
|
+
github.com, and codeload.github.com.` (on Linux; elsewhere it says why the box has no
|
|
98
|
+
network: [Sandbox](#sandbox)). The first start builds [the box's image](#the-boxs-image) (python 3.12, git, curl, node, npm and rg,
|
|
90
99
|
about 300 MB, a minute or two, the build alone on the network): its banner then says `Boxes: docker is preparing
|
|
91
|
-
(building the box image (python, git, curl, node, rg)).`, and the log `event=box_image ... state=preparing`, then
|
|
100
|
+
(building the box image (python, git, curl, node, npm, rg)).`, and the log `event=box_image ... state=preparing`, then
|
|
92
101
|
`state=ready` with how long it took; a later start finds it built. A run that needs its box sooner waits for it, with a
|
|
93
102
|
row on its timeline saying so. In a second shell, export the two `AGENTRUN_` lines it printed (a later start prints
|
|
94
103
|
where the key is: `export AGENTRUN_API_KEY=$(cat ~/.local/share/agentrun/agents/.token)`). Then make a sandbox agent,
|
|
@@ -102,6 +111,9 @@ curl -sN "$AGENTRUN_BASE_URL/runs/$run/timeline" -H "$H" -H 'accept: text/event-
|
|
|
102
111
|
curl -s "$AGENTRUN_BASE_URL/runs/$run/files" -H "$H"; curl -s "$AGENTRUN_BASE_URL/runs/$run/files/out.txt" -H "$H"
|
|
103
112
|
```
|
|
104
113
|
|
|
114
|
+
The `place` above is what a new agent gets anyway on a server with docker, so a definition that names only its name and
|
|
115
|
+
instructions lands in the box too, with `bash` as its one tool ([Place](#place)).
|
|
116
|
+
|
|
105
117
|
The timeline ends when the run does. `out.txt` names the image's Debian, whatever this machine runs, and it is in
|
|
106
118
|
the run's `work/`, the one directory the container binds. No key? Start the server with `--faux box.mjs`, a
|
|
107
119
|
[faux model](#the-faux-model) that makes one `bash` call and then answers, and run the same commands:
|
|
@@ -111,11 +123,12 @@ cat > box.mjs <<'JS'
|
|
|
111
123
|
export default (context, faux) => context.messages.some((m) => m.role === "toolResult") ? faux.message("Saved out.txt.")
|
|
112
124
|
: faux.message(faux.toolCall("bash", { command: "cat /etc/os-release | tee out.txt" }), { stopReason: "toolUse" });
|
|
113
125
|
JS
|
|
114
|
-
|
|
126
|
+
node packages/serve/dist/cli.js --faux box.mjs
|
|
115
127
|
```
|
|
116
128
|
|
|
117
|
-
The box has python 3.12, git, curl, node and rg
|
|
118
|
-
|
|
129
|
+
The box has python 3.12, git, curl, node, npm and rg. On Linux it reaches Python's and npm's package registries and
|
|
130
|
+
GitHub, and nothing else: `pip install` and `npm install` work in it. [The box's image](#the-boxs-image) says how to give
|
|
131
|
+
it more. The rest is under [Sandbox](#sandbox).
|
|
119
132
|
|
|
120
133
|
## Logs
|
|
121
134
|
|
|
@@ -214,14 +227,16 @@ container's limit when it has one (cgroup), else the machine's, less the server'
|
|
|
214
227
|
| pi | 128 MiB | up to 106 MB |
|
|
215
228
|
| codex | 192 MiB | up to 143 MB |
|
|
216
229
|
| claude-agent | 288 MiB | up to 215 MB |
|
|
230
|
+
| opencode | 704 MiB | up to 524 MB |
|
|
217
231
|
|
|
218
232
|
The measure is a short task (write a file, read it back, answer) on a real server in a container of its own; the table
|
|
219
233
|
in `src/harness.ts` says how it was taken. So a 512 MB instance holds 3 pi runs, 2 codex runs or 1 claude-agent run at
|
|
220
|
-
once (or 1 codex and 1 pi), 1 GB holds 7, 4 or 3, and 8 GB 63, 42 or 28
|
|
234
|
+
once (or 1 codex and 1 pi), 1 GB holds 7, 4 or 3, and 8 GB 63, 42 or 28; an opencode run, OpenCode's own process with
|
|
235
|
+
it, needs a 1 GB instance for one and 2 GB for two. A start that does not fit in what is left is
|
|
221
236
|
`429 rate_limited` with `retry-after`, its message naming the harness and the memory, and nothing starts: there is no
|
|
222
237
|
queue, so the client tries again once a run ends. A harness whose one run needs more than all the memory for runs (claude-agent
|
|
223
|
-
on a host under 416 MB) is unavailable: capabilities say why in its `harnesses` entry, and
|
|
224
|
-
agent_not_runnable` with that reason. pi always has one place, however small the host.
|
|
238
|
+
on a host under 416 MB, opencode under 832 MB) is unavailable: capabilities say why in its `harnesses` entry, and
|
|
239
|
+
its runs are `409 agent_not_runnable` with that reason. pi always has one place, however small the host.
|
|
225
240
|
|
|
226
241
|
`--max-runs N` or `AGENTRUN_MAX_RUNS` caps the count as well (by default, as many as pi runs fit), and both limits
|
|
227
242
|
apply. Capabilities report pi's count in `limits.max_concurrent_runs`, and each harness's own in its `harnesses` entry
|
|
@@ -248,8 +263,9 @@ of a process that is gone is not trusted.
|
|
|
248
263
|
## Sandbox
|
|
249
264
|
|
|
250
265
|
A sandbox agent's `bash` runs in a box, a machine apart from this server: today a Docker container made for each run,
|
|
251
|
-
which binds the run's `work/` and nothing else, or a Daytona sandbox, which gets a copy of it
|
|
252
|
-
|
|
266
|
+
which binds the run's `work/` and nothing else, or a Daytona sandbox, which gets a copy of it. Neither holds a key. A
|
|
267
|
+
Docker box on Linux reaches the package registries and GitHub through a proxy, and nothing else; a Daytona box reaches
|
|
268
|
+
them through Daytona's domain list. Its `read`, `write` and `edit` work on that same `work/`: on this server, where the box binds it and this server
|
|
253
269
|
holds directory handles (Docker on Linux), else in the box. The agent's loop, its log, its model calls and every key stay
|
|
254
270
|
on the server. An agent says so in its [place](#place); the server says which [boxes](#boxes) it has; [a run in a Docker
|
|
255
271
|
box](#a-run-in-a-docker-box) is what the container gets, and [a run in a Daytona box](#a-run-in-a-daytona-box) what a
|
|
@@ -263,11 +279,27 @@ A definition may name where its runs execute: `{"mode": "runner"}` or `{"mode":
|
|
|
263
279
|
the ids under [Boxes](#boxes). A runner has no shell. In a sandbox the agent's `bash` runs in the named box and its
|
|
264
280
|
file tools (`read`, `write`, `edit`) work on the `work/` the box has ([a run in a Docker box](#a-run-in-a-docker-box)),
|
|
265
281
|
while the agent's loop, its log and every key stay on the server, whatever its harness. Any other shape is `422 input_invalid` on `definition.place`, whose `fix` is the change to make: the field to
|
|
266
|
-
remove, or the place it most likely meant, to copy (`"place": {"mode": "sandbox", "box": "docker"}`).
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
282
|
+
remove, or the place it most likely meant, to copy (`"place": {"mode": "sandbox", "box": "docker"}`). One that names a
|
|
283
|
+
place keeps it, `runner` included. An edit that names no place keeps the agent's.
|
|
284
|
+
|
|
285
|
+
The box is a new agent's default machine. A new agentic agent whose definition names no place is saved in the Docker box
|
|
286
|
+
(`{"mode": "sandbox", "box": "docker"}`) wherever this server has docker, ready or still preparing its image (its first
|
|
287
|
+
run then waits for the image, with one timeline row). The place is written on the agent's first revision, so its answers
|
|
288
|
+
show it. If that definition names no `tools` either, it gets `["bash"]`, so the agent has a shell. A definition that
|
|
289
|
+
names its tools keeps exactly those, an empty list included. Where docker is unavailable, a new agent is saved as before,
|
|
290
|
+
with no place, and runs on the runner. So is one whose tools name one the box refuses (`browser`, runner-only for now). A
|
|
291
|
+
workflow is never given a box.
|
|
292
|
+
|
|
293
|
+
`capabilities.places` says both sides. `default_place` is the place a new agent gets here. When that is the runner,
|
|
294
|
+
`default_reason` says why in docker's own words, such as `new agents run on the runner, because the docker box is
|
|
295
|
+
unavailable here: Docker isn't running on this machine (no docker command on PATH): install or start Docker, then
|
|
296
|
+
restart AgentRun`. The console's new-agent form says docker's reason too, under its place picker. `default` stays `runner`,
|
|
297
|
+
because it means where a revision that names no place runs. An agent saved with no place (before this, where docker was
|
|
298
|
+
unavailable, or a workflow) keeps running on the runner, whatever the server has now. The default is never worked out
|
|
299
|
+
again at run time. The console's new-agent form starts on `default_place`, with bash ticked when that place is a sandbox.
|
|
300
|
+
What a person picks or unticks there is what is sent.
|
|
301
|
+
|
|
302
|
+
A run runs in its revision's place, else on the runner. A run request names no place: `POST /agents/{id}/runs`
|
|
271
303
|
with `place` is `422 input_invalid`, as with any field the body does not keep. The run keeps the place it resolved to,
|
|
272
304
|
and `GET /v2/runs/{id}` shows it as `place`. A harness's own tools in the box, when they come, will be an option of
|
|
273
305
|
`sandbox` (such as `native_tools: true`), never a third mode.
|
|
@@ -277,15 +309,16 @@ the sandbox place as its `fix`), and a workflow's place is `runner` or none (`42
|
|
|
277
309
|
its `fix`). In `capabilities.tools`, `bash` is `available: false` with a `reason` (`no box is set up on this server: …`,
|
|
278
310
|
each box's own reason) when no box this server has can run it.
|
|
279
311
|
|
|
280
|
-
`GET /v2/capabilities` lists `places`: the modes, the default, and each box with `available`, its `state` (`ready`,
|
|
312
|
+
`GET /v2/capabilities` lists `places`: the modes, the default, a new agent's place, and each box with `available`, its `state` (`ready`,
|
|
281
313
|
`preparing` while the server builds or pulls its image, or `unavailable`) and, when it is not ready, the `reason`.
|
|
282
314
|
A definition naming a box this server does not have saves with a warning on `definition.place`, and a run of it is
|
|
283
315
|
`409 agent_not_runnable` with `details.box`. `GET /v2/openapi.json` marks `definition.place`, the run's `place` and
|
|
284
|
-
`capabilities.places` `x-agentrun-serve: "place/1"`.
|
|
316
|
+
`capabilities.places` `x-agentrun-serve: "place/1"`, and `default_place` and `default_reason` `"place/3"`.
|
|
285
317
|
|
|
286
318
|
### A run in a Docker box
|
|
287
319
|
|
|
288
|
-
With `AGENTRUN_BOXES
|
|
320
|
+
With docker on (by default, when `AGENTRUN_BOXES` is not set; or listed in it) and a Docker daemon this server's user
|
|
321
|
+
may use, a run whose place is
|
|
289
322
|
`{"mode": "sandbox", "box": "docker"}` gets one container, made on its first `bash` call (a run with none gets no
|
|
290
323
|
container). Those four tools are pi's own, on every harness. `bash` runs in the container. `read`, `write` and `edit`
|
|
291
324
|
run on this server, on the `work/` the container binds, because a `docker exec` costs half a second or more per call:
|
|
@@ -307,7 +340,80 @@ go through `work/` by path.
|
|
|
307
340
|
one); any other (another path of this machine, `..` out of it, `~`) is refused as outside the workspace, and their
|
|
308
341
|
errors name the box's paths, never this machine's. A mount source that is, or passes through, a link below the data directory is
|
|
309
342
|
refused: the tool call fails, and no container is made. The data directory is resolved to its real path once, at start.
|
|
310
|
-
- It has no network (`--network none`)
|
|
343
|
+
- It has no network of Docker's (`--network none`). On Linux, with a Docker daemon of this machine's own, it reaches a
|
|
344
|
+
list of hosts alone, on ports 80 and 443, through the run's egress proxy. The list, by default: `pypi.org`,
|
|
345
|
+
`files.pythonhosted.org`, `registry.npmjs.org`, `registry.yarnpkg.com`, `github.com` and `codeload.github.com`.
|
|
346
|
+
`AGENTRUN_BOX_ALLOW` replaces it with a comma list of host names, such as
|
|
347
|
+
`pypi.org,files.pythonhosted.org,registry.npmjs.org,registry.yarnpkg.com,github.com,codeload.github.com,deb.debian.org`
|
|
348
|
+
to add one (`*.example.com` names the hosts below `example.com`); `AGENTRUN_BOX_ALLOW=none` is the box offline, as it
|
|
349
|
+
was: no proxy, no network at all. `*`, an address or a CIDR refuses the start.
|
|
350
|
+
- How: the run's process starts the proxy with the list on a Unix socket in a directory of its own under
|
|
351
|
+
`/tmp/agentrun-egress-<uid>/`, bound into the box read-only at `/run/agentrun/egress/`. A `socat` in the box relays
|
|
352
|
+
`127.0.0.1:3128` to it, and `HTTP_PROXY` and `HTTPS_PROXY` (and their lowercase twins) name that port, with
|
|
353
|
+
`NO_PROXY` for loopback. pip, npm, git and curl read them. A program that skips them has no route out.
|
|
354
|
+
- A host off the list, an address and any other port are refused before any lookup, in words: `403 example.com is
|
|
355
|
+
not on this box's network list: use web_fetch for web pages, or ask the operator to add it to AGENTRUN_BOX_ALLOW`.
|
|
356
|
+
So is a listed name whose address is private, this machine's or a cloud's metadata. The proxy holds no key and adds
|
|
357
|
+
none. Its decisions are in the run's process log (`box_egress`: host, port, address, class).
|
|
358
|
+
- Only a Docker daemon on this same Linux machine can reach the proxy's socket. The server checks it once, at start,
|
|
359
|
+
and fails closed: the box has the list only when this machine is Linux, the docker CLI's endpoint is a local unix
|
|
360
|
+
socket, and `docker info` answers within 5 s with Linux containers on this machine's own kernel, keeping its data
|
|
361
|
+
in a directory this server sees. The kernel is the evidence, not the runtime's name:
|
|
362
|
+
- a Docker whose kernel differs from this server's (Docker Desktop on a Mac, OrbStack, Colima) sees a socket bound
|
|
363
|
+
in from the host but cannot connect to it, so its box has no network;
|
|
364
|
+
- a Docker on this server's kernel passes whatever it calls itself, if its data directory is one this server sees:
|
|
365
|
+
Docker Desktop with WSL2 shares the kernel string, but keeps its data outside the distro, so it gets none unless
|
|
366
|
+
the distro has that directory (`/var/lib/docker`); where it passes, the proxy enforces the list as anywhere;
|
|
367
|
+
- a server in a container given the host's docker socket shares the host's kernel but not its files (docker
|
|
368
|
+
info's `DockerRootDir` is not there), so its box has no network rather than every tool call failing.
|
|
369
|
+
|
|
370
|
+
Capabilities and the banner say why, naming what was found: `docker boxes have no network: this Docker (OrbStack)
|
|
371
|
+
runs in a VM (its kernel is "6.15.11-orbstack-…", this machine's "6.1.0-…") that can't reach this server's egress
|
|
372
|
+
proxy yet`. At each start the server removes the proxy directories of runs that are gone (a socket that refuses a
|
|
373
|
+
connect, over a minute old); a live run's, of any server of this user's, stays.
|
|
374
|
+
- On a Mac, where Docker runs in a VM, a socket bound in from the Mac does not connect, so the proxy runs inside the
|
|
375
|
+
VM instead: one container per server, `agentrun-egress-<12 hex of the data root>`, labelled `agentrun.egress`. It
|
|
376
|
+
is `node:22-bookworm-slim` pinned by digest, with the kernel's two proxy files and a short entry bound read-only from
|
|
377
|
+
`<data>/egress/`, the list as its one variable, a read-only root, no capability, the server's uid:gid, 256 MiB and
|
|
378
|
+
256 processes. It listens on a Unix socket in a tmpfs volume of the same name, owned by the server's uid, and the
|
|
379
|
+
box mounts that volume read-only at `/run/agentrun/egress/`. The box keeps `--network none`, its `socat` and its
|
|
380
|
+
proxy variables; the proxy container is the only container with a network (Docker's default), and it publishes no
|
|
381
|
+
port. The server turns this on only when `docker info` names a VM runtime it knows, on a kernel that is not the
|
|
382
|
+
Mac's: `Operating System: Docker Desktop` (Docker Desktop), `OrbStack` (OrbStack), or a host name of `colima` or
|
|
383
|
+
`colima-<profile>` (colima). Anything else on a Mac (Rancher Desktop, a Podman machine, a colima whose host name
|
|
384
|
+
was changed, a daemon elsewhere) has no network, and `network_reason` says what was seen. At each start, before any
|
|
385
|
+
run gets the volume's name, the server makes the volume if it is missing; a volume named exactly this server's
|
|
386
|
+
`agentrun-egress-<12 hex>` that lacks its label (Docker made it with its defaults when a box mounted it first) is
|
|
387
|
+
replaced, and no other volume is touched. It removes every container of its own label, pulls the image once if
|
|
388
|
+
Docker lacks it, starts the proxy and waits up to 10 s for it to say it is ready; until then, and if it never does,
|
|
389
|
+
the box's network is `none` with why. Docker restarts a proxy that dies (`--restart unless-stopped`); the server
|
|
390
|
+
starts one that is gone again within about 10 s; its stop removes it, by the id Docker gave it, never by its name.
|
|
391
|
+
Linux keeps the path above, unchanged.
|
|
392
|
+
- The proxy's code is bound from the data directory (`<data>/egress/`), so Docker Desktop must share that path with its
|
|
393
|
+
VM. The default data directory, under your home in `/Users`, is shared. One elsewhere (`XDG_DATA_HOME` or `--data`
|
|
394
|
+
outside Docker Desktop's shared paths) makes the bind fail: the box's network is then `none`, and `network_reason`
|
|
395
|
+
says the proxy did not start. Add the path under Docker Desktop's Settings > Resources > File sharing, or keep the
|
|
396
|
+
data directory under `/Users`.
|
|
397
|
+
- The proxy container's own threat model, on a Mac. It has a network: Docker's bridge, the VM's NAT, then the Mac, its
|
|
398
|
+
LAN and the internet. Nothing reaches it but through the socket in the volume: no TCP listener, no published port,
|
|
399
|
+
no Docker socket, no key, and a variable that is the list alone; its entry refuses to start with no list, since a
|
|
400
|
+
proxy with none would reach every public host. The host list comes first, so an unlisted name is never looked up
|
|
401
|
+
and an address is never dialled: `host.docker.internal`, `gateway.docker.internal`, `host.orb.internal`,
|
|
402
|
+
`host.lima.internal` and the VM's own addresses cannot even be asked for. A listed name that resolves to the VM or
|
|
403
|
+
the Mac is refused by the same address rule as on Linux: OrbStack's Mac host and gateway (seen at addresses in
|
|
404
|
+
`0.0.0.0/8`, which the rule refuses as unspecified; OrbStack's docs do not name them), Docker Desktop's VM network
|
|
405
|
+
and colima's host address (both in RFC 1918 private space), the Docker bridge, a home LAN, a Tailscale address,
|
|
406
|
+
cloud metadata and IPv6 unique local. What stays: the rule checks the container's own interfaces, not the Mac's, so
|
|
407
|
+
a listed name that DNS points at the Mac's public address, or at the router through hairpin NAT, would be dialled;
|
|
408
|
+
and the cap of 256 connections open at once is the server's, shared by all its runs, not each run's, so one run that
|
|
409
|
+
holds many open can starve the others until its connections close.
|
|
410
|
+
- Capabilities give the list as `places.allow`, and each box's `network`: `allowlist` or `none`, with
|
|
411
|
+
`network_reason` when an available box has none. An image with no `socat` gets no network, and the run's timeline
|
|
412
|
+
says so once.
|
|
413
|
+
- What it allows, and what it does not: a box reaches no cloud metadata address, nothing of this machine or its
|
|
414
|
+
network, and no resolver, so no name leaves this machine but a listed one. It can send what its run has to a listed
|
|
415
|
+
host with the agent's own credentials (an `npm publish`, a `git push`), as `web_fetch` can send to any public host.
|
|
416
|
+
Docker still binds its copies of this machine's
|
|
311
417
|
`/etc/resolv.conf`, `/etc/hostname` and `/etc/hosts` into it, read-only, so a box's command can read this machine's
|
|
312
418
|
resolver settings (its nameservers and search domains), with no network to use them. Its environment is
|
|
313
419
|
`LANG=C.UTF-8` and `HOME=/tmp` and the image's own: never this server's, so no key or token is in it. It runs as this
|
|
@@ -321,6 +427,8 @@ go through `work/` by path.
|
|
|
321
427
|
- `bash` takes pi's `{command, timeout?}`, `timeout` in seconds, 300 when the call names none; a timeout kills the
|
|
322
428
|
command's process group in the container. Its answer is its output's last 2,000 lines or 50 KB. Each call is a fresh
|
|
323
429
|
shell in `work/`.
|
|
430
|
+
- A command that should outlive one call (a server, a watcher, a long build) goes in the background instead
|
|
431
|
+
([background processes](#background-processes)).
|
|
324
432
|
- It has no capability and can gain none (`--cap-drop ALL`, `--security-opt no-new-privileges`), so even as root (a
|
|
325
433
|
server run as uid 0) it cannot make a device node in `work/`. Its Docker daemon must be this machine's: where
|
|
326
434
|
`DOCKER_HOST`, or the docker context, names another machine (tcp://, ssh://), no box is made, since that daemon would
|
|
@@ -331,6 +439,68 @@ go through `work/` by path.
|
|
|
331
439
|
`work/`) and when the run is archived. A start destroys every such container whose run has ended or is archived; one
|
|
332
440
|
of a run this data directory does not know is left to its 24-hour lifetime.
|
|
333
441
|
|
|
442
|
+
### Background processes
|
|
443
|
+
|
|
444
|
+
An agent whose place is a sandbox may also name `bash_background`, `bash_output`, `bash_input`, `bash_signal` and
|
|
445
|
+
`bash_list`, to run a command that outlives one call: a dev server, a watcher, a long build, a program that reads its
|
|
446
|
+
input as it goes. Each call is one short command in the run's box, on the same path as `bash`, so they work on every box
|
|
447
|
+
`bash` runs on, and nothing new runs on this server.
|
|
448
|
+
|
|
449
|
+
The permission gate holds all five to `bash`'s setting (none is a settings key of its own, so no setting of one lifts
|
|
450
|
+
`bash`'s), and `capabilities.tools` and an agent's `tools` show each as the gate takes it, `permission_from` being
|
|
451
|
+
where `bash`'s setting came from:
|
|
452
|
+
|
|
453
|
+
- `bash: deny` refuses all five, as it refuses `bash`, with no shell at all.
|
|
454
|
+
- `bash: ask` parks only the calls that start or feed a process: `bash_background` and `bash_input` (and `bash`
|
|
455
|
+
itself), each under its own name, so an approval runs that call. `bash_output`, `bash_list` and `bash_signal` run
|
|
456
|
+
unasked: they reach only the processes this run started, by its own ids (another run's id, or one never started, is
|
|
457
|
+
answered "there is no background process"), so watching an approved process costs no approval per page. They run so
|
|
458
|
+
on a server with accounts off too, where an ask is refused. Only an `ask` set as written lets them: where `bash` asks
|
|
459
|
+
because its setting is a value not offered, or because the settings file never read, they ask too. A save of the
|
|
460
|
+
settings as served keeps that stand-in, and the file keeps the value as written; only a different permission sets it.
|
|
461
|
+
- `bash: allow` runs all five.
|
|
462
|
+
|
|
463
|
+
- `bash_background {command}` starts the command from `work/`, in a fresh shell (`bash`, else `sh`) under a session of
|
|
464
|
+
its own (`setsid`, its runner under `nohup`), and answers its id (`"1"`, then `"2"`, and on) at once. Its stdout and
|
|
465
|
+
stderr go together to `work/background/<id>/output.log`, beside `command`, `started`, `pid` (its process group) and,
|
|
466
|
+
once it ends, `exit` (its code; 128 + n for signal n). The run's files show them (`GET /v2/runs/{id}/files`), so the
|
|
467
|
+
console and the API show each log, during the run and after it.
|
|
468
|
+
- Those files are for people to read: the run's own file tools can write anything in `work/`, so no call trusts one.
|
|
469
|
+
The group a signal goes to, the exit code, the start time, the command and the run's-end mark are kept in the box's
|
|
470
|
+
own directory (its `TMPDIR`, else `/tmp`), out of `work/`; a copy in `work/` is written in that directory and moved
|
|
471
|
+
over its name from inside `work/background/<id>`, entered and checked by its real path, so a link planted at the name
|
|
472
|
+
or at the directory is never followed (a failed check skips the copy). `output.log` is opened first and then checked as opened
|
|
473
|
+
(through `/proc`: the file reached is `work/background/<id>/output.log` itself, by its real path, and a regular file),
|
|
474
|
+
and every read is of that open file, so a link swapped in after the check is never read. A link planted at it is
|
|
475
|
+
refused, saying so; so is any log in a box with no `/proc` to check it by. A directory made in `work/background/` that this box
|
|
476
|
+
did not start reads as gone, and is never signalled.
|
|
477
|
+
- A process runs until no live process of its group is left: a child the command starts with `&` (a server, its
|
|
478
|
+
output sent elsewhere) keeps it running, counted against the cap, signalled with it and ended at the run's end; its
|
|
479
|
+
exit code is the shell's.
|
|
480
|
+
- At most 8 run at once in a run's box: a ninth start is refused, saying so, until one ends. Each log keeps the first
|
|
481
|
+
16 MiB of the output; later output is dropped while the process runs on, and `bash_output` says so.
|
|
482
|
+
- `bash_background {command, tty: true}` runs the command on a terminal instead: `script -qfec` (util-linux) in the box
|
|
483
|
+
gives it a pty, so a program that needs one works (a prompt, a REPL, a progress display). Paging, input and signals are
|
|
484
|
+
the same calls: the log holds what the terminal shows (input echoed, lines ending in `\r\n`), `bash_input` types into
|
|
485
|
+
the terminal, and `bash_signal` reaches the terminal's processes: `INT` goes to its foreground job, as Ctrl-C does, so an
|
|
486
|
+
interactive shell's running command stops and the shell runs on; `TERM` and `KILL` go to every process group of the
|
|
487
|
+
terminal's session. That session is tracked as the process: a child its command leaves running on the terminal keeps
|
|
488
|
+
the process running, counted against the cap, reached by `bash_signal` and ended at the run's end, after `script`
|
|
489
|
+
itself is gone. A box with no `script` refuses `tty: true`, saying so, and starts nothing. `bash_list` marks such a
|
|
490
|
+
process `(tty)`.
|
|
491
|
+
- `bash_output {id, offset?, max_bytes?}` reads the log from a byte offset (0 when absent), at most 48 KiB a call (the
|
|
492
|
+
default), never splitting a character (a page too small for the character it starts at is refused, saying so): whether the process still runs, its exit code once it ended, the log's size,
|
|
493
|
+
and the offset to read from next. Once it says the process ended, the log is whole.
|
|
494
|
+
- `bash_input {id, text, close?}` writes `text` to the process's stdin as given (end a line with `\n`), at most 64 KiB a
|
|
495
|
+
call; `close: true` closes its stdin after it, so the process reads the end of its input. The stdin is a fifo in the
|
|
496
|
+
box's `TMPDIR` (else `/tmp`), never in `work/`.
|
|
497
|
+
- `bash_signal {id, signal}` sends the process's group `TERM`, `INT` or `KILL`, and answers its state after up to 2 s.
|
|
498
|
+
- `bash_list` names each process: running or how it ended, its output's size, when it started and its command's start
|
|
499
|
+
(every running one, then the newest that ended, 40 at most).
|
|
500
|
+
- The run's end ends them: before its box is copied back and destroyed, the server sends each running group `TERM`,
|
|
501
|
+
then `KILL` after 3 s, and marks each with `ended` beside its log, which stays in the run's files; the server's log says
|
|
502
|
+
`background_ended` with how many. A follow-up's box starts with none running, and its ids go on from the last.
|
|
503
|
+
|
|
334
504
|
### A run in a Daytona box
|
|
335
505
|
|
|
336
506
|
With `AGENTRUN_BOXES=daytona` and `DAYTONA_API_KEY`, a run whose place is `{"mode": "sandbox", "box": "daytona"}` gets one
|
|
@@ -344,9 +514,25 @@ since nothing binds `work/` there):
|
|
|
344
514
|
the key to the calls a run's tools make of their own sandbox (a read of it, and its toolbox's programs and files). It
|
|
345
515
|
refuses every other call (a create, a listing, a stop, a delete, another run's sandbox or token, any other host), and
|
|
346
516
|
it never follows a redirect, nor does the server's own Daytona client: a redirect would carry the key.
|
|
347
|
-
-
|
|
348
|
-
|
|
349
|
-
|
|
517
|
+
- It reaches the hosts `AGENTRUN_BOX_ALLOW` names, and no other: Daytona's domain list (`domainAllowList`), which
|
|
518
|
+
Daytona's egress proxy enforces. Unset or empty, the list is the package registries and GitHub: `pypi.org`,
|
|
519
|
+
`files.pythonhosted.org`, `registry.npmjs.org`, `registry.yarnpkg.com`, `github.com` and `codeload.github.com`. A
|
|
520
|
+
comma list of hosts (a `*.` wildcard allowed, at most 100) replaces it, so to add one, copy this list and extend it.
|
|
521
|
+
`AGENTRUN_BOX_ALLOW=none` blocks its network (`networkBlockAll`), as before the list. `*`, an IP address, a CIDR, a
|
|
522
|
+
port or a URL refuses the start. Capabilities show the hosts in `places.allow`, and the box's `network` (`allowlist` or
|
|
523
|
+
`none`) in its `places.boxes` entry. Daytona's proxy re-signs each TLS connection with Daytona's own CA, which the
|
|
524
|
+
sandbox's environment names to pip, npm, git and curl (`REQUESTS_CA_BUNDLE`, `NODE_EXTRA_CA_CERTS`, `GIT_SSL_CAINFO`,
|
|
525
|
+
`CURL_CA_BUNDLE`, `SSL_CERT_FILE`).
|
|
526
|
+
- A sandbox whose own read does not carry the list it was asked for is deleted. Daytona takes a domain list on its tier 3
|
|
527
|
+
and 4 only: where it keeps none, or refuses it, the server makes the run's box again with its network blocked, never
|
|
528
|
+
open, and makes every later Daytona box that way until it starts again. The log says so once, with Daytona's own
|
|
529
|
+
words (`event=box_network box=daytona network=none refused=<code> message="…"`), and capabilities show the box's
|
|
530
|
+
`network` as `none` with its `network_reason`. A box the server finds is kept when it has no network, or the list the
|
|
531
|
+
setting names now (the same hosts, in any order, as Daytona reads them back); any other (a wider or narrower list, a
|
|
532
|
+
list when the setting is `none`) is destroyed and made again, so a changed list holds for a run's box after a restart.
|
|
533
|
+
- A sandbox Daytona does not report blocked, when blocked was asked, is deleted, and the tool call fails saying so. An
|
|
534
|
+
organization on Daytona's tier 1 or 2 keeps its own network policy, which a sandbox cannot override, so a run there
|
|
535
|
+
gets no Daytona box unless that policy blocks it.
|
|
350
536
|
- A sandbox cannot bind `work/`. The server copies `work/` into it at `/run/agentrun/run/work` when it makes it, and
|
|
351
537
|
copies what changed back at each turn's end (a read of the run's files waits for that copy) and once more before the
|
|
352
538
|
run's end is recorded. Daytona's answer is never trusted: the copy back writes regular files and directories only,
|
|
@@ -373,22 +559,52 @@ since nothing binds `work/` there):
|
|
|
373
559
|
what only it holds stays.
|
|
374
560
|
- The sandbox is Daytona's default snapshot, made as its user, with `sudo -n` making `/run/agentrun/run/work`.
|
|
375
561
|
|
|
562
|
+
### A run in a Modal sandbox
|
|
563
|
+
|
|
564
|
+
With `modal` listed in `AGENTRUN_BOXES`, its token set and its SDK installed, a run whose place is
|
|
565
|
+
`{"mode": "sandbox", "box": "modal"}` gets one Modal sandbox, made on its first `read`, `write`, `edit` or `bash` call. It
|
|
566
|
+
is Modal's default sandbox runtime (gVisor), not a virtual machine: the server does not ask Modal for its VM runtime. It works like a
|
|
567
|
+
[Daytona box](#a-run-in-a-daytona-box): the same tools, path rules, environment and labels, and its `read`, `write` and
|
|
568
|
+
`edit` run in the sandbox too. What differs:
|
|
569
|
+
|
|
570
|
+
- The token and the SDK's client are this server's alone. The server makes the sandbox, copies `work/` into it at
|
|
571
|
+
`/run/agentrun/run/work`, copies what changed back at each turn's end and once more before the run's end is recorded,
|
|
572
|
+
and ends it after that last copy, at the run's end, a cancel included, and at an archive. The copy rules (no link,
|
|
573
|
+
nothing outside `work/`, a file this server changed stays as it has it) are Daytona's.
|
|
574
|
+
- The run's process holds no token. Its calls to its sandbox go through the server's box relay, on loopback, with that
|
|
575
|
+
run's own door token. The relay makes only the calls a run's tools make of their own sandbox, with the server's
|
|
576
|
+
client: finding it, reading its state and tags, and starting a program in it with that program's input, output and
|
|
577
|
+
exit. It refuses everything else: a create, a listing, an end, a tag change, or another run's sandbox or program.
|
|
578
|
+
- It has no network, whatever `AGENTRUN_BOX_ALLOW` names. The provider takes a domain list when a sandbox is made, but
|
|
579
|
+
its SDK cannot read a sandbox's list back, so this server cannot check that a box holds the list it asked for (as it
|
|
580
|
+
does for Daytona). Each box is made with its network blocked, never with the provider's open default. Capabilities
|
|
581
|
+
show the box's `network` as `none`, with `network_reason`, unless the setting is `none`.
|
|
582
|
+
- A sandbox that is gone (it ended, or its lifetime ran out) is made again on the run's next tool call and seeded
|
|
583
|
+
with the run's `work/`. The call that met the gone box fails, saying so.
|
|
584
|
+
- Each Modal sandbox reserves 2 CPUs and 4 GiB of memory by default, which the provider bills for while the box lives:
|
|
585
|
+
the Docker box's defaults, asked of the provider as the sandbox's CPU and memory. `AGENTRUN_BOX_CPUS` and
|
|
586
|
+
`AGENTRUN_BOX_MEMORY` change both boxes alike (such as `AGENTRUN_BOX_CPUS=1 AGENTRUN_BOX_MEMORY=1g`). The provider has
|
|
587
|
+
no process limit, so `AGENTRUN_BOX_PIDS` does not apply. Its lifetime is 24 hours, as every box's is.
|
|
588
|
+
- A start copies back, then ends, the sandbox of every run that has ended or is archived.
|
|
589
|
+
|
|
376
590
|
### The box's image
|
|
377
591
|
|
|
378
592
|
A Docker box starts from this server's own image by default: `agentrun-box`, python 3.12 (`python:3.12-slim`, pinned by
|
|
379
|
-
its digest) with git, curl, node (Debian's `nodejs
|
|
593
|
+
its digest) with git, curl, node and npm (Debian's `nodejs` and `npm`), rg (`ripgrep`), `socat` (the relay to the box's
|
|
594
|
+
network proxy, when it has one) and their certificates, about 360 MB. Its
|
|
380
595
|
recipe is `BOX_RECIPE` in `src/box-image.ts`, its base `BOX_BASE` there. The server builds it on first use
|
|
381
596
|
(`docker build`, at most 10 minutes, its context a private directory under `TMPDIR` holding the recipe alone as its
|
|
382
597
|
`Dockerfile`, removed after), tags it with the recipe's hash (`agentrun-box:<12 hex>`) and labels it with the whole hash
|
|
383
598
|
(`agentrun.box-image`), and builds again only when the recipe changes: a start that finds the image with this recipe's
|
|
384
599
|
hash uses it. To move the base, read the tag's index digest again from Docker Hub (the comment beside `BOX_BASE` says
|
|
385
600
|
how) and put it there: the recipe's hash changes, and so does the image's tag, so the next start builds it. The build
|
|
386
|
-
reaches the network, for the base image and apt; a box made from it never does (`--network none`). A build that fails
|
|
601
|
+
reaches the network, for the base image and apt; a box made from it never does through Docker's (`--network none`). A build that fails
|
|
387
602
|
leaves the box unavailable with the reason ([Boxes](#boxes)). Images of older recipes stay until you remove them:
|
|
388
603
|
`docker image ls --filter label=agentrun.box-image` lists them all, and `docker image rm agentrun-box:<12 hex>` removes
|
|
389
604
|
one.
|
|
390
605
|
|
|
391
|
-
A box
|
|
606
|
+
A box reaches its package registries (on Linux), so `pip install` and `npm install` work in it, but not `apt-get`: the
|
|
607
|
+
box runs as this server's user, with no root. For other tools, name another image
|
|
392
608
|
in `AGENTRUN_DOCKER_IMAGE`: the server then pulls it when Docker has none (at most 10 minutes) and builds nothing.
|
|
393
609
|
This image, its build and the wait for it are the Docker box's alone: a Daytona box is made by the server from
|
|
394
610
|
Daytona's own image, and a Daytona run never waits on this one.
|
|
@@ -405,7 +621,7 @@ never runs; the box's first process is a `sleep` of its lifetime.
|
|
|
405
621
|
### In the published image
|
|
406
622
|
|
|
407
623
|
The published image, `ghcr.io/parcha-ai/agentrun-server`, cannot host boxes yet. It has no `docker` command and no
|
|
408
|
-
Docker daemon, so
|
|
624
|
+
Docker daemon, so capabilities and the start's `event=boxes` line say docker is
|
|
409
625
|
unavailable, and a sandbox agent's runs are `409 agent_not_runnable`. Runner agents work as before. Do not mount the
|
|
410
626
|
host's Docker socket into the container to get around it: whatever can reach that socket is root on the host, and a
|
|
411
627
|
box's bind of `work/` names a path in the server's container, which the host's daemon does not have. For sandboxes, run
|
|
@@ -414,28 +630,39 @@ inside the image itself (bwrap, on Linux) comes in a later release.
|
|
|
414
630
|
|
|
415
631
|
### Boxes
|
|
416
632
|
|
|
417
|
-
A box is a machine apart from this one where a run's tools run. Runs execute in `docker` and `
|
|
418
|
-
([place](#place)); the others are set up and probed, and say runs in them are not available yet.
|
|
419
|
-
|
|
633
|
+
A box is a machine apart from this one where a run's tools run. Runs execute in `docker`, `daytona` and `modal` boxes
|
|
634
|
+
([place](#place)); the others are set up and probed, and say runs in them are not available yet.
|
|
635
|
+
|
|
636
|
+
Docker is on by default. With `AGENTRUN_BOXES` not set at all (a plain `npx @parcha/agentrun`), the server probes
|
|
637
|
+
`docker` as if it were listed, and offers it when Docker answers (`ready`, or `preparing` while its image comes), so a
|
|
638
|
+
new agent lands in the Docker box with a shell. When Docker does not answer, new agents run on the runner, and the
|
|
639
|
+
banner, `capabilities.places.default_reason`, docker's own `reason` and the console's new-agent form say why. Every
|
|
640
|
+
other box is yours to list.
|
|
641
|
+
|
|
642
|
+
`AGENTRUN_BOXES`, when set, wins: it lists the boxes to set up, as a comma list of the ids below
|
|
643
|
+
(`AGENTRUN_BOXES=docker,daytona`), and the server never probes a box the list does not name, Docker included. An empty
|
|
644
|
+
value (`AGENTRUN_BOXES=`) or `AGENTRUN_BOXES=none` sets up no box. `none` stands alone, and a name that is no box
|
|
420
645
|
refuses the start. At start the server probes each listed box once. The probes run at once, each within 5 s. Then one
|
|
421
646
|
log line says what the server found:
|
|
422
647
|
|
|
423
648
|
event=boxes available=<ids or none> unavailable=<ids> <id>="<why>" ...
|
|
424
649
|
|
|
425
650
|
The line gives a reason for each listed box that is unavailable, and the banner says the same in words
|
|
426
|
-
(`Boxes: docker is ready, so sandbox agents run their tools there.`
|
|
651
|
+
(`Boxes: docker is ready, so sandbox agents run their tools there.` with a list; `Boxes: docker (on by default; set
|
|
652
|
+
AGENTRUN_BOXES to change).` without one). Each reason says what to do next: a box the list
|
|
427
653
|
does not name says `not enabled on this server: start AgentRun with AGENTRUN_BOXES=docker` (keeping the boxes it already
|
|
428
|
-
lists),
|
|
429
|
-
|
|
654
|
+
lists), a missing `docker` command says `Docker isn't running on this machine (no docker command on PATH): install or
|
|
655
|
+
start Docker, then restart AgentRun`, and a `docker` whose daemon does not answer says to start Docker or add this
|
|
656
|
+
user to the `docker` group, then restart AgentRun, since the probe runs once. A reason never holds a key, a command's output or a
|
|
430
657
|
provider's answer.
|
|
431
658
|
|
|
432
659
|
- `docker`: the `docker` command on PATH, with a daemon that answers `docker version` for this server's user. It needs no key.
|
|
433
660
|
Then the server asks Docker for [the box's image](#the-boxs-image) (`docker image inspect`). When Docker has it (the
|
|
434
661
|
default with this recipe's hash), the box is `ready`. When not, the server builds the default, or pulls the image
|
|
435
662
|
`AGENTRUN_DOCKER_IMAGE` names, once, in the background, for at most 10 minutes. Meanwhile the box is available and
|
|
436
|
-
`preparing` (`building the box image (python, git, curl, node, rg)`, or `pulling <image>`), and a sandbox run whose
|
|
663
|
+
`preparing` (`building the box image (python, git, curl, node, npm, rg)`, or `pulling <image>`), and a sandbox run whose
|
|
437
664
|
first box comes then waits for the image, with one row on its timeline (`Preparing the box image: building it (python,
|
|
438
|
-
git, curl, node, rg)…`), instead of a first tool call that pulls it silently. A build or pull that fails is tried once
|
|
665
|
+
git, curl, node, npm, rg)…`), instead of a first tool call that pulls it silently. A build or pull that fails is tried once
|
|
439
666
|
more, 5 seconds later, the box `preparing` meanwhile with what failed (`trying once more: the build of the box image
|
|
440
667
|
could not reach the network (…)`). One that fails again, or takes longer, makes the box unavailable with the reason
|
|
441
668
|
(the build could not reach the network, pull its base or install a package, ran out of disk; the registry refused the
|
|
@@ -448,10 +675,11 @@ provider's answer.
|
|
|
448
675
|
The probe makes one authenticated read, of a box that does not exist. If Daytona refuses the key, the box is unavailable.
|
|
449
676
|
- `modal`: needs `MODAL_TOKEN_ID`, `MODAL_TOKEN_SECRET` and the SDK, which the host installs (`npm install modal`).
|
|
450
677
|
Its sandboxes live in the app that `AGENTRUN_BOX_APP` names (default `agentrun`). The probe checks that the SDK loads
|
|
451
|
-
and the token is set. It asks nothing of the provider.
|
|
678
|
+
and the token is set. It asks nothing of the provider. Runs execute in it: [a run in a Modal sandbox](#a-run-in-a-modal-sandbox).
|
|
452
679
|
- `bwrap` is not in this release yet.
|
|
453
680
|
|
|
454
|
-
The boxes come from `@parcha/pi-transport`,
|
|
681
|
+
The boxes come from `@parcha/pi-transport`, a dependency of this package, so every install of the server, `npx
|
|
682
|
+
@parcha/agentrun`'s included, has the Docker box's provider.
|
|
455
683
|
The keys belong to the server alone. The launcher hands them over with the server's other secrets, and no run's process
|
|
456
684
|
gets them, in its environment or on its pipe.
|
|
457
685
|
|
|
@@ -535,17 +763,22 @@ agent_not_runnable`, with `details.unbound` and `details.missing`).
|
|
|
535
763
|
| `write` | Write a file in the run's `work/` | nothing | yes, no |
|
|
536
764
|
| `edit` | Edit a file in the run's `work/` | nothing | yes, no |
|
|
537
765
|
| `bash` | Run a shell command in the run's box, from its `work/`: pi's `{command, timeout?}`, 300 s when the call names no timeout | an agentic definition whose place is a sandbox ([Sandbox](#sandbox)) | no, no |
|
|
766
|
+
| `bash_background` | Start a shell command in the background in the run's box, from its `work/`, and answer its id at once: `{command, tty?}` in, `tty: true` for a terminal. Its stdout and stderr go to `work/background/<id>/output.log`, the first 16 MiB; at most 8 run at once ([background processes](#background-processes)) | an agentic definition whose place is a sandbox | no, no |
|
|
767
|
+
| `bash_output` | Read a background process's output from a byte offset: `{id, offset?, max_bytes?}` in (at most 48 KiB a call), its state, exit code, the log's size and the next offset out | an agentic definition whose place is a sandbox | no, no |
|
|
768
|
+
| `bash_input` | Write to a running background process's stdin: `{id, text, close?}` (at most 64 KiB a call) | an agentic definition whose place is a sandbox | no, no |
|
|
769
|
+
| `bash_signal` | Send a background process's group `TERM`, `INT` or `KILL`: `{id, signal}` | an agentic definition whose place is a sandbox | no, no |
|
|
770
|
+
| `bash_list` | List the run's background processes: id, state or exit code, output size, start time and command | an agentic definition whose place is a sandbox | no, no |
|
|
538
771
|
| `ask_person` | Ask the person who started the run; the turn ends until a message answers | nothing | no, no |
|
|
539
772
|
| `web_fetch` | Read one web page from a public host through the guarded direct fetch, or through Parallel's extract where Parallel is picked ([search and fetch](#search-and-fetch)), a part at a time: `{url, offset?, max_chars?}` in, a Page out, `{ok, url, status, title, text, chars, truncated?, original_chars?, beyond_read?, offset?, next_offset?, html_chars?, converted?, links, links_omitted?, via, parallel?, refused?, error?}` | nothing (`PARALLEL_API_KEY` for Parallel, one billed extract a page a run) | yes, yes |
|
|
540
773
|
| `web_search` | Search the web, natively where the harness or the model's provider can, else through Parallel where the server holds its key, else keyless through Exa, or through the provider picked ([search and fetch](#search-and-fetch)): `{query, n?}` in, `{provider, query, results: [{url, title, snippet, published?}], text?}` or `{error}` out | nothing (`PARALLEL_API_KEY` for Parallel) | yes, yes |
|
|
541
|
-
| `browser` | A
|
|
774
|
+
| `browser` | A hosted browser, Browserbase's or Kernel's, on pi-browser's durable adapter: `snapshot`, `run`, `screenshot`, `browser_read`, `browser_release`, `browser_relaunch`, `browser_downloads` and `browser_upload` (into and from the run's `work/`); Kernel keeps no downloads, so a run on Kernel has no `browser_downloads` | `BROWSERBASE_API_KEY` and `BROWSERBASE_PROJECT_ID`, or `KERNEL_API_KEY` | yes, no |
|
|
542
775
|
| `monid.discover` | Search monid's catalog of paid data endpoints in plain words: `{query, limit?, minScore?}` in, `{results: [{provider, endpoint, description, score, price}]}` out | `MONID_API_KEY` | no, no |
|
|
543
776
|
| `monid.inspect` | One monid endpoint before it runs: `{provider, endpoint}` in, the JSON Schemas of its input (`pathParams`, `queryParams`, `body`), its price, notes and documentation out | `MONID_API_KEY` | no, no |
|
|
544
777
|
| `monid.run` | Run one monid endpoint, paid per call from the monid wallet: `{provider, endpoint, input}` in, the run's `output`, `price` and `cost` out | `MONID_API_KEY` | no, no |
|
|
545
778
|
| `pdf_pages` | A workflow call only: `{path, maxPages?, dpi?}` in, `{name, pageCount, dpi, pages: [{page, image}], text}` out. Draws a document's first pages (3 by default, at 110 dpi) as PNGs under the run's `work/pages/<stem>/<dpi>/` (`<stem>`: the document's path below its directory made one name, with a short hash, so two documents of one file name never share pages), the dpi lowered so a page's long side is at most 1568 px, with its text (`pdftotext`, cut at 20,000 characters). A PNG or JPEG passes through as one page, scaled down to 1568 px. `path` is under `--documents` or the run's `work/`, never outside | `pdftoppm`, `pdftotext` | no, yes |
|
|
546
779
|
| `llm` | A workflow call only: `{prompt, system?, maxTokens?, tier?}` in, `{text, model, usage, cost_usd}` out. One completion on the run's model of the tier (`default`; a tier the state fills in, such as `"{requestedTier}"`, may be any of the three, and a tier with no model fails the call), no tools and no loop; `cost_usd` is null when the model has no price, never 0 | a model | no, yes |
|
|
547
780
|
|
|
548
|
-
`bash`
|
|
781
|
+
`bash` and the background tools run only in a box: a runner agent, and a workflow, get no shell on this machine (see [Safety](#safety)). In a
|
|
549
782
|
sandbox place `read`, `write` and `edit` run in the box too. `fetch_page` is a legacy name for `web_fetch`: a
|
|
550
783
|
revision, a model node or a call node that names it still saves and runs, and gets `web_fetch` under that name (the
|
|
551
784
|
same Page with `via`, resolved as `web_fetch` is: the guarded fetch, Parallel only where picked). The table lists it no
|
|
@@ -585,7 +818,8 @@ On another harness, every host tool's result reaches the model within the host's
|
|
|
585
818
|
(`HOST_RESULT_MAX_CHARS`, `@parcha/agentrun-kernel`): the kernel's tool bridge cuts a longer one, its start with a line
|
|
586
819
|
saying where it was cut, and flags the call `truncated`. Each CLI adapter tells its CLI to pass a result that long to
|
|
587
820
|
the model whole: the Claude Agent CLI would otherwise save a result past 50,000 characters to a file and tell the model
|
|
588
|
-
to read it, which a run's confinement refuses,
|
|
821
|
+
to read it, which a run's confinement refuses, Codex keeps only the ends of a result past 10,000 tokens, and OpenCode
|
|
822
|
+
would cut one past 2,000 lines or 51,200 bytes and save the rest to a file the session has no tool to read. A
|
|
589
823
|
`web_search` answer past 100,000 characters leaves out its least relevant results, `omitted` counting them.
|
|
590
824
|
|
|
591
825
|
### Search and fetch
|
|
@@ -615,14 +849,17 @@ unavailable for a workflow.
|
|
|
615
849
|
| `web_fetch`, `kernel` (the default) | the guarded direct fetch | the same | the same |
|
|
616
850
|
| either, `parallel` | Parallel's search and extract, host tools | the same | the same |
|
|
617
851
|
|
|
618
|
-
`GET /settings/tools` answers the server's settings, `{web_search: {provider}, web_fetch: {provider}}`, the default
|
|
852
|
+
`GET /settings/tools` answers the server's settings, `{web_search: {provider}, web_fetch: {provider}, browser: {provider}}`, the default
|
|
619
853
|
where none is set; `PUT /settings/tools` takes the same map and replaces it (a capability it leaves out takes its
|
|
620
854
|
default). An agent's `definition.tool_settings` has the same shape and is over the server's. A provider is one offered
|
|
621
|
-
for its capability (`auto`, `native`, `exa-keyless` or `parallel` for `web_search`; `kernel` or `parallel` for `web_fetch
|
|
622
|
-
|
|
623
|
-
|
|
855
|
+
for its capability (`auto`, `native`, `exa-keyless` or `parallel` for `web_search`; `kernel` or `parallel` for `web_fetch`;
|
|
856
|
+
`auto`, `browserbase`, `kernel` or `chrome` for `browser`, [below](#tools)); an
|
|
857
|
+
unknown capability or provider is `422`. Any tool's settings also take a `permission`, `allow`, `ask` or `deny`, which the
|
|
858
|
+
tool gate holds every call to (an ask parks the run for the owner's approval); a workflow's call node, which cannot wait
|
|
859
|
+
for an approval, refuses its run when its tool is set to ask or deny (`409`, `details.asks` or `details.denied`). The
|
|
860
|
+
settings are kept in the data directory
|
|
624
861
|
(`tool-settings.json`, 0600, written whole and durably), not a secret, and read by every run launched from then on.
|
|
625
|
-
`GET /capabilities` is the one tool catalog: each of the
|
|
862
|
+
`GET /capabilities` is the one tool catalog: each of the three tools there gives the providers offered (`providers`), the
|
|
626
863
|
server's (`provider`, its default where it sets none), the built-in default (`default_provider`) and `resolves`, what it
|
|
627
864
|
resolves to on each harness under the server's settings and default model (`native`, `kernel`, `exa-keyless`,
|
|
628
865
|
`parallel`, or `unavailable: <reason>`), with `why`, keyed the same, one plain sentence for each (`Codex's own search`,
|
|
@@ -640,6 +877,10 @@ Parallel key gone since makes Parallel unavailable, never another provider), and
|
|
|
640
877
|
description with no secret in it (`AGENTRUN_SERVE_TOOL_PLANE`); the run reads its providers there, never from a request.
|
|
641
878
|
A workflow's tools are those its revision lists and those its model and call nodes name.
|
|
642
879
|
|
|
880
|
+
Upgrading to the tool gate: a workflow whose call node's tool is set to ask, by a setting or a default, now refuses its
|
|
881
|
+
run (`409` with `details.asks`); set that tool to allow for the agent (`definition.tool_settings`). Built-in tools are
|
|
882
|
+
allowed by default; catalog (`monid.*`) and MCP tools, which ask by default, are no call node's tools here.
|
|
883
|
+
|
|
643
884
|
Upgrading: a server holding `PARALLEL_API_KEY` used to read every `web_fetch` page through Parallel's extract on its own.
|
|
644
885
|
Now `web_fetch` is the guarded direct fetch unless Parallel is picked; to keep the old behaviour, set
|
|
645
886
|
`PUT /v2/settings/tools {"web_fetch": {"provider": "parallel"}}` once (or `tool_settings` in an agent). Parallel's key reaches an agentic run only when one of its capabilities resolves to Parallel (see
|
|
@@ -698,7 +939,7 @@ read 2026-11-03), an estimate: a `fast` search $0.001 for up to 10 results and $
|
|
|
698
939
|
$0.001 a URL; on a 4xx other than a 408 nothing (Parallel refused it), and on a 408, a 5xx, a timeout or a lost
|
|
699
940
|
connection its price (Parallel may have billed it). Under a [spend cap](#spend-cap) each is a paid call: sent only when
|
|
700
941
|
what the run has spent and holds, plus its price, fits the cap. Otherwise nothing reaches Parallel: a search answers the
|
|
701
|
-
cap's refusal (`spend_cap_reached:
|
|
942
|
+
cap's refusal (`spend_cap_reached: Not sent: the run has spent $0 of its $0.0009 cap, and Parallel's search could cost up to $0.001 …`) and a page is the
|
|
702
943
|
guarded direct fetch, with `parallel` giving the same words. One sent holds its price until Parallel answers: a model
|
|
703
944
|
request checked meanwhile, from any branch, tool round or harness, counts it beside what the run has spent, so the two
|
|
704
945
|
never pass the cap together. A workflow's `call` node naming either tool is booked the same way, under the node's own
|
|
@@ -715,12 +956,87 @@ snippet of at most 3,000 characters and its date when Exa knows it, then a line
|
|
|
715
956
|
relies on. Keyless Exa is the default for a harness with no native search when the server holds no Parallel key; `off`
|
|
716
957
|
turns `web_search` off, keyless Exa included.
|
|
717
958
|
|
|
718
|
-
The `browser` tool runs
|
|
719
|
-
|
|
959
|
+
The `browser` tool runs hosted sessions, at Browserbase or at Kernel, never a Chrome on this machine. Which one is
|
|
960
|
+
picked like `web_search`'s provider: the agent's own (`definition.tool_settings.browser.provider`) over the server's
|
|
961
|
+
(`PUT /settings/tools`), one of `auto` (the default), `browserbase`, `kernel` and `chrome`. `auto` is Browserbase where
|
|
962
|
+
the server holds its keys (`BROWSERBASE_API_KEY` and `BROWSERBASE_PROJECT_ID`), else Kernel where it holds
|
|
963
|
+
`KERNEL_API_KEY`, else unavailable, saying which keys would do. A vendor picked is that vendor alone: without its key
|
|
964
|
+
it is unavailable, never the other one. `chrome`, a Chrome on the server's own host, is in the list but not set up on
|
|
965
|
+
any server yet: it reads unavailable (`a local Chrome is not set up on this server`), and a run that would get it is
|
|
966
|
+
`409`. Capabilities' `tools[]` give the browser's providers, the server's pick and what it resolves to; a run keeps the
|
|
967
|
+
vendor its first launch resolved for its life, and one whose vendor's key is gone since is refused each browser call,
|
|
968
|
+
saying why. Kernel's browsers run headless, and keep no downloads, so a run on Kernel has no `browser_downloads`. The keys come from the server's environment or Tool keys and reach the
|
|
969
|
+
run's process over its pipe, as the rest do. A session's custody (its lease, its tag, what it was
|
|
720
970
|
doing) is kept in the run's own store, so a run opened again on its directory reconciles the sessions it held. Each
|
|
721
971
|
page it reads is filed under the run's `work/evidence/`, each read in a file of its own (`0001-browser_read.md`, ...),
|
|
722
972
|
reads at once included. There is no recording and no live view. When the run is let go (its work done, or a SIGTERM)
|
|
723
|
-
the sessions it still holds are released at
|
|
973
|
+
the sessions it still holds are released at their vendor. An agent's browser stays signed in from one run to the next
|
|
974
|
+
([saved sign-ins](#saved-sign-ins)).
|
|
975
|
+
|
|
976
|
+
A session's time is the run's spend, as a paid tool's charge is: each browser call books what its session ran since the
|
|
977
|
+
last charge, and the release books the rest, topped up to the provider's minimum. Each is part of its `cost.usd` and
|
|
978
|
+
`/usage`'s `browser_time` meter (dollars, and seconds once the run has ended). On the timeline a charge has no row of its
|
|
979
|
+
own: it shows on the row of the browser call it was booked under, that call's `tool_use` row, as `usage`
|
|
980
|
+
(`{"usd": 0.0017, "requests": 0}`, every charge of that call summed). The release's charge goes under the session's
|
|
981
|
+
last call, so it lands on that call's row. Booked after the answer, it is served as a change of that row (the same `id`,
|
|
982
|
+
its new `usage`), never a new row. Prices are by provider (pi-browser's provider name):
|
|
983
|
+
|
|
984
|
+
| Provider | List price | Minimum | Its own price |
|
|
985
|
+
| --- | --- | --- | --- |
|
|
986
|
+
| `browserbase` | $0.12 an hour | 60 s | `AGENTRUN_BROWSER_USD_PER_HOUR_BROWSERBASE` |
|
|
987
|
+
| `kernel` (headless) | about $0.06 an hour, by the second | none | `AGENTRUN_BROWSER_USD_PER_HOUR_KERNEL` |
|
|
988
|
+
| `cdp` (a local Chrome) | $0 | none | `AGENTRUN_BROWSER_USD_PER_HOUR_CDP` |
|
|
989
|
+
|
|
990
|
+
A variable gives the provider's price in US dollars an hour (a contract rate; the minimum stays). A provider with no price,
|
|
991
|
+
or a variable that is not a non-negative decimal, has no price: its time is booked as an unknown cost, and under a cap
|
|
992
|
+
every browser call is refused. Under a cap the browser's time is held before it runs (see [Spend cap](#spend-cap)).
|
|
993
|
+
|
|
994
|
+
### Saved sign-ins
|
|
995
|
+
|
|
996
|
+
Sign in once in one of an agent's runs (for now, through the run's browser while it runs), and every later run of that
|
|
997
|
+
agent starts from that signed-in browser. Sign-ins are kept per agent, never shared between agents, and the server
|
|
998
|
+
picks which one a run gets, never the model.
|
|
999
|
+
|
|
1000
|
+
- **Where the cookies are.** At the browser's vendor: a Browserbase context, or a Kernel profile under a random name
|
|
1001
|
+
(`agentrun-` and 24 hex digits: Kernel's names are its account's, so a name derived from the agent would be any
|
|
1002
|
+
server's that shares the key). This
|
|
1003
|
+
server keeps only a pointer per agent and vendor, sealed under the seal key (`AGENTRUN_SEAL_KEY`) and bound to its
|
|
1004
|
+
agent, in `<data>/homes/<key>/sign-ins/sign-ins.json`. With no seal key nothing is kept and runs start signed out;
|
|
1005
|
+
capabilities say `sign_ins: true` only with a seal key and a browser vendor here. A local Chrome keeps none: its
|
|
1006
|
+
cookies would sit on this server's disk.
|
|
1007
|
+
- **How a run gets it.** Before a run with the `browser` tool is launched, the server makes the agent's context at
|
|
1008
|
+
Browserbase (`POST /v1/contexts`, which opens no session; Browserbase bills sessions, not contexts) or its profile at
|
|
1009
|
+
Kernel (`POST /profiles`, which starts no browser) if it has none,
|
|
1010
|
+
and hands the run's process the pointer over its pipe, with its secrets, never in its environment. The run's process
|
|
1011
|
+
never gets the seal key. Every session the run opens uses that profile, by the name `default`; the model never sees
|
|
1012
|
+
the pointer. A vendor that does not answer leaves that run's browser signed out, said in the server's log.
|
|
1013
|
+
- **One run saves at a time.** The first run of an agent to start with the browser holds the sign-in's save lease, and
|
|
1014
|
+
its sessions save what changed (Browserbase `persist`, Kernel `save_changes`). A run of the same agent started while
|
|
1015
|
+
another holds it starts signed in and saves nothing. The lease ends when its run ends (completed, failed or
|
|
1016
|
+
cancelled) or lets go cleanly to wait for its person. A run whose process went, or a server restart, keeps it with
|
|
1017
|
+
the run for its relaunch, since a session it opened before may still write back at the vendor, but for no longer than
|
|
1018
|
+
such a session can live (pi-browser's session timeout, 30 minutes) while its process stays gone: a run that waits on
|
|
1019
|
+
its person after its process died, or is never opened again, lets the others save after that. A run whose process
|
|
1020
|
+
went without letting its sessions go keeps the lease that way even once it ends. Each launch decides again whether
|
|
1021
|
+
its run saves: a follow-up of a run that saved, opened while another run holds the lease, saves nothing. One that names a run
|
|
1022
|
+
that ended while the server was down counts as let go. Browserbase writes a saved context back a few seconds after
|
|
1023
|
+
its session ends, so a Browserbase saver's lease stays named for it 10 seconds past its end (a bound this server
|
|
1024
|
+
chose; Browserbase publishes none): a run started in that time starts from the context as it was, and saves nothing
|
|
1025
|
+
over it, and the saver itself, resumed in that time, waits it out before it saves again. A gone holder's Browserbase
|
|
1026
|
+
lease gets the same 10 seconds past the 30 minutes. A V1 limit: the lease goes to the first run of the agent to
|
|
1027
|
+
start with the browser in its tools, whether or not it opens a browser, and stays with it until it ends, so a long
|
|
1028
|
+
run that never browses keeps the others of that agent from saving meanwhile.
|
|
1029
|
+
- **What you see.** `GET /v2/agents/{id}` lists `sign_ins`: `{key: "default", provider, state, held_by, verified_at}`,
|
|
1030
|
+
`held` with the run's id while a run holds the lease, else `ready`; `verified_at` is when a saving session last ended.
|
|
1031
|
+
`unreadable` (this server's own state, marked `signins/1` in the served contract) is a pointer that does not open
|
|
1032
|
+
under the seal key the server has now (none, or another): runs start signed out, and none is made in its place until
|
|
1033
|
+
you forget it, since the vendor's object it points to would be left behind. Its `held_by` still names a run that
|
|
1034
|
+
holds its lease, as a held one does.
|
|
1035
|
+
Never the pointer. `DELETE /v2/agents/{id}/sign-ins/{key}` forgets one: the vendor's context or profile is deleted,
|
|
1036
|
+
then the pointer. A delete the vendor does not answer is said in the answer (`at_vendor: "not_deleted"`), and the
|
|
1037
|
+
pointer goes all the same. It is `409 sign_in_held` while a run holds the lease. A run of the agent that is still
|
|
1038
|
+
going without the lease keeps the pointer it was handed: once the vendor's object is gone, its later sessions fail. Archiving an agent keeps its
|
|
1039
|
+
sign-ins; this server has no route that deletes an agent.
|
|
724
1040
|
|
|
725
1041
|
`monid.discover`, `monid.inspect` and `monid.run` give an agent [monid](https://monid.ai)'s whole catalog of data
|
|
726
1042
|
endpoints on one key, `MONID_API_KEY`: it finds an endpoint in plain words, reads its input schemas and price, and runs
|
|
@@ -756,13 +1072,14 @@ the model keys: a run's process gets it over its pipe, never in its environment.
|
|
|
756
1072
|
## Tool keys
|
|
757
1073
|
|
|
758
1074
|
A tool's key comes from one of two places. The server's own environment, through its launcher: `PARALLEL_API_KEY`,
|
|
759
|
-
`MONID_API_KEY` and `
|
|
1075
|
+
`MONID_API_KEY`, `BROWSERBASE_API_KEY` and `KERNEL_API_KEY` are among the secrets it hands the server over its pipe. Or the page, by name:
|
|
760
1076
|
`PUT /v2/settings/tool-keys/{id}` with `{values: {NAME: "..."}}` saves one, field by field (`parallel` takes
|
|
761
1077
|
`PARALLEL_API_KEY`, `monid` `MONID_API_KEY`, `browserbase` `BROWSERBASE_API_KEY` and `BROWSERBASE_PROJECT_ID`,
|
|
762
|
-
`typesafe` `TYPESAFE_API_KEY`, which unlocks Jev's decisions, `decisions.jev`), and `DELETE` forgets it. A model
|
|
1078
|
+
`kernel` `KERNEL_API_KEY`, `typesafe` `TYPESAFE_API_KEY`, which unlocks Jev's decisions, `decisions.jev`), and `DELETE` forgets it. A model
|
|
763
1079
|
provider's key is saved the same way (`anthropic`, `openai` and `openrouter`, each `kind: "model"`, the others
|
|
764
1080
|
`"tool"`): every run gets it, as every run gets the launcher's model keys, and with no `AGENT_MODEL` it gives the
|
|
765
|
-
default model ([models](#models)); its `harnesses` are pi and the provider's
|
|
1081
|
+
default model ([models](#models)); its `harnesses` are pi and the harnesses that talk to that provider's API (OpenAI's:
|
|
1082
|
+
codex and opencode; OpenRouter's, all four), of
|
|
766
1083
|
those this server runs or would run once the key is set, so a row names them before it is saved: one left out is one
|
|
767
1084
|
this server cannot run for another reason (not installed, not the pinned build, more than this host's memory). `GET
|
|
768
1085
|
/v2/settings/tool-keys` lists each key, what it unlocks and the harnesses that run that, and each field's `set` and
|
|
@@ -772,20 +1089,28 @@ none of still lists, with nothing in `unlocks`. A field the server is started wi
|
|
|
772
1089
|
it is `409 key_set_by_server`. A value is text of at most 1024 bytes with no control character (`422` otherwise).
|
|
773
1090
|
|
|
774
1091
|
A key is checked against its provider before it is kept, with one call that costs nothing, given 5 s: monid's
|
|
775
|
-
discover of one result, Parallel's list of monitors, Browserbase's list of projects
|
|
776
|
-
`BROWSERBASE_BASE_URL` or `TYPESAFE_BASE_URL` when the server
|
|
1092
|
+
discover of one result, Parallel's list of monitors, Browserbase's list of projects, Kernel's list of browsers (at most
|
|
1093
|
+
one) and TypeSafe's list of models (at `BROWSERBASE_BASE_URL`, `KERNEL_BASE_URL` or `TYPESAFE_BASE_URL` when the server
|
|
1094
|
+
is started with one). A key the provider refuses (401)
|
|
777
1095
|
is `422 input_invalid`, its field's reason `refused_by_provider`, in plain words with the provider's first sentence
|
|
778
1096
|
(`Monid refused this key (401: Invalid API key format)`) and never any of the key, and nothing is kept: a key saved
|
|
779
1097
|
before stays as it was. Otherwise it is kept, and `GET` gives its row a `check`: `{state: "accepted", at}`, or
|
|
780
1098
|
`{state: "not_checked", reason, at}` when the provider would not answer the check (403: a key scoped away from that
|
|
781
1099
|
call may still work for its tools), did not answer in 5 s, could not be reached, answered a redirect (never followed,
|
|
782
|
-
so the key goes nowhere else) or something else, or has no call that costs nothing.
|
|
783
|
-
|
|
784
|
-
`
|
|
1100
|
+
so the key goes nowhere else) or something else, or has no call that costs nothing. A tool's key the server is
|
|
1101
|
+
started with is checked once as it starts, with the same call, in the background (the start never waits on it): its
|
|
1102
|
+
row's `check` is `accepted`, `not_checked`, or `{state: "refused", reason, at}` (`Browserbase refused
|
|
1103
|
+
BROWSERBASE_API_KEY (401: Unauthorized) when this server started: set the right one where AgentRun starts, then
|
|
1104
|
+
restart it`), and a tool that needs a refused key reads unavailable in capabilities with the same words. `check` is
|
|
1105
|
+
null when the key is not set, or is the server's and its check has not answered yet; a key saved before this server
|
|
1106
|
+
checked keys reads `not_checked`, and is checked when saved again. A model key the server is started with is not
|
|
1107
|
+
checked here: a run on a refused one fails at its first request, saying so. A save of Browserbase's project id alone sends no key, and leaves its
|
|
785
1108
|
check as it was. A save whose check is still waiting when the server begins to close keeps nothing (`503
|
|
786
1109
|
unavailable`, while its connection lasts): the check stops waiting, and the server's lock, released at close, may be
|
|
787
1110
|
another server's by then. Under `--faux` a key is checked only against the fake its runs are given (`fauxMonid`,
|
|
788
|
-
`fauxParallel`, `fauxJev`); with none it is `not_checked`, and nothing reaches the network.
|
|
1111
|
+
`fauxParallel`, `fauxJev`); with none it is `not_checked`, and nothing reaches the network. A key the server starts
|
|
1112
|
+
with is checked under `--faux` only against a check's own fake (`fauxBrowserbase`, `fauxMonidCheck`, `fauxKernel`), so the fakes the runs use see the
|
|
1113
|
+
runs' calls alone; with none, its `check` stays null.
|
|
789
1114
|
|
|
790
1115
|
A saved key is kept only as ciphertext: AES-256-GCM in `DIR/tool-keys.json` (0600), each value bound to its field's
|
|
791
1116
|
name, under the seal key `AGENTRUN_SEAL_KEY`, which only the server opens it with. A run's process never gets the seal
|
|
@@ -809,15 +1134,15 @@ answers once capabilities, a save's checks and a run's checks see the change, in
|
|
|
809
1134
|
key, so a key leaves what each harness offers as it is, and the harnesses are not checked again. A run already
|
|
810
1135
|
running keeps what it was handed; the next run started, or a run's process started again, takes what is saved then.
|
|
811
1136
|
`BROWSERBASE_PROJECT_ID` is on the launcher's list for this, as every field a person may save is. Capabilities name each
|
|
812
|
-
tool's key (`tools[].key`, a `GET /settings/tool-keys` id, `
|
|
1137
|
+
tool's key (`tools[].key`, a `GET /settings/tool-keys` id; for `browser` its vendor's, `kernel` where Kernel is picked or resolved, else `browserbase`), so a page can link a tool's
|
|
813
1138
|
missing names to where its key is saved. `agentrun-serve import` opens the saved keys in its data directory too and
|
|
814
1139
|
cuts each out of what it writes, as it cuts a key-shaped variable of its environment; one that does not open there is
|
|
815
1140
|
not known, so not cut, and the import says so.
|
|
816
1141
|
|
|
817
1142
|
## MCP servers
|
|
818
1143
|
|
|
819
|
-
Add a remote MCP server once, with its credential, and see its tools before you keep it.
|
|
820
|
-
|
|
1144
|
+
Add a remote MCP server once, with its credential, and see its tools before you keep it. An agent that grants one of
|
|
1145
|
+
its tools calls it on pi and on claude-agent ([below](#agents-call-a-servers-tools)).
|
|
821
1146
|
|
|
822
1147
|
```sh
|
|
823
1148
|
curl -X POST "$BASE/v2/settings/mcp-servers/preview" -H "authorization: Bearer $TOKEN" -H 'content-type: application/json' \
|
|
@@ -871,13 +1196,74 @@ says `transports: ["streamable-http"]`, the `auth` types and `at_rest` (`sealed`
|
|
|
871
1196
|
answers `{url, log, tools, close}`; it serves `add`, `slow_write`, `delete_thing` and `paid`, and logs each request's
|
|
872
1197
|
method, tool and whether an `Authorization` header came, never its value.
|
|
873
1198
|
|
|
1199
|
+
### Agents call a server's tools
|
|
1200
|
+
|
|
1201
|
+
An agent grants a saved server's tool by its catalog name, `mcp:<server>/<tool>`, in `definition.tools`
|
|
1202
|
+
(`"tools": ["mcp:github/list_issues"]`). A save checks each one against the server's saved tools: a server that is not
|
|
1203
|
+
saved, or a tool it did not list, is `422` naming the server's tools, and so is a name whose wire name,
|
|
1204
|
+
`mcp__<server>__<tool>`, is over 52 characters, or a tool whose `x-mcp-header` declaration cannot be sent (on a
|
|
1205
|
+
property not reached through `properties` alone, not a string, integer or boolean, not a header name, or declared twice). pi and claude-agent run them (`features.mcp_client.harnesses`); on
|
|
1206
|
+
another harness the save warns that they are not bound there yet, and a run is refused.
|
|
1207
|
+
|
|
1208
|
+
A known **meta tool**, one that runs other actions by name, is never granted: Composio's `COMPOSIO_MULTI_EXECUTE_TOOL`,
|
|
1209
|
+
`COMPOSIO_REMOTE_WORKBENCH`, `COMPOSIO_REMOTE_BASH_TOOL` and `COMPOSIO_PROXY_EXECUTE`, Klavis Strata's `execute_action`
|
|
1210
|
+
(on `klavis.ai`), Zapier's `execute_zapier_read_action`, `execute_zapier_write_action` and `write_code_action` (on
|
|
1211
|
+
`mcp.zapier.com`), Arcade's `Arcade_UseTool`, Docker's `mcp-exec` and generated `code-mode-*` tools, and Cloudflare's
|
|
1212
|
+
`portal_execute` and `portal_codemode_execute`. A grant of one couldn't name the real action, so allow would cover every
|
|
1213
|
+
action it runs and deny could target none. Reads mark it `grantable: false` with its `reason`, a save that grants it is
|
|
1214
|
+
`422` in those words, and a run that pinned one before is refused at its launch. Use the server's direct tools instead:
|
|
1215
|
+
each of these providers has a direct mode. The list is closed: a meta tool it doesn't know is an MCP tool like any other,
|
|
1216
|
+
asked by default.
|
|
1217
|
+
|
|
1218
|
+
- **Pinned.** A run's first launch keeps each granted tool as the server listed it when you saved it (its description
|
|
1219
|
+
and schema) and the server's URL then, in the run's directory (`mcp-tools.json`). A refresh or a new save never
|
|
1220
|
+
changes a running agent's tools. If the server's URL has changed since, that run's calls answer "the server's
|
|
1221
|
+
address changed since this run started" and nothing is sent, the new credential least of all.
|
|
1222
|
+
- **The credential.** A run whose revision grants a server's tool is handed that server's credential at each launch
|
|
1223
|
+
(so a new one counts at the next), over its secrets pipe, never its environment; a run that grants none of a
|
|
1224
|
+
server's tools gets none of it. It stays in the run's process: no harness's CLI, file or log holds it, and a run
|
|
1225
|
+
that writes it into a learned note is refused by the secret scan.
|
|
1226
|
+
- **pi** binds each granted tool in the run's process as `mcp__<server>__<tool>`, with the pinned description and
|
|
1227
|
+
schema, and calls the server from there.
|
|
1228
|
+
- **claude-agent** uses the Claude CLI's own MCP client: one HTTP server entry per granted server at the session's
|
|
1229
|
+
model proxy, `/mcp/<server>`, behind the session's key, sent over the CLI's stdin (never its arguments), with only
|
|
1230
|
+
those servers (`strictMcpConfig`) and only the granted tools allowed. The proxy answers the MCP exchange itself and
|
|
1231
|
+
makes the call with the credential. The CLI's tool search is off in such a session, so the granted tools are
|
|
1232
|
+
offered whole. A server the CLI cannot connect to fails the turn, never a turn without its tools.
|
|
1233
|
+
- **A call** goes to the pinned URL alone, the 2026-07-28 revision first and a 2025-era server through its
|
|
1234
|
+
`initialize`; on 2026-07-28 each `x-mcp-header` parameter of the pinned tool is sent as its `Mcp-Param-*` header. No
|
|
1235
|
+
redirect is followed, at most 4 MiB is read, and it may take 120 s. The
|
|
1236
|
+
model reads the text blocks joined; past 60,000 characters, or with blocks that are not text, the whole answer is
|
|
1237
|
+
filed under the run's `evidence/mcp/<server>/` and the text says where. A tool's own error (`isError`) reaches the
|
|
1238
|
+
model as its error. A refused credential (401, 403) reads "the MCP server <name> refused its credential; update it
|
|
1239
|
+
in Settings → MCP servers"; another failure names the server and the HTTP status, never a header. A stop, or a
|
|
1240
|
+
client that goes away, cancels the call at the server. A call a crash cut off is answered interrupted on the
|
|
1241
|
+
resumed run and never sent again.
|
|
1242
|
+
- **The gate.** Every call passes the run's one tool gate as `mcp:<server>/<tool>`, on every harness. Set
|
|
1243
|
+
`mcp:<server>/<tool>` or, for all of a server's tools, `mcp:<server>/*` to `allow`, `ask` or `deny` in
|
|
1244
|
+
`PUT /v2/settings/tools` or an agent's `definition.tool_settings` (the agent's exact key, then its server-wide key,
|
|
1245
|
+
then the server's two, then the default). An MCP tool with no setting asks. A denied call is refused and the model
|
|
1246
|
+
reads why; nothing is sent. An asked call parks, as any tool's does: its turn ends, nothing is sent, and the run
|
|
1247
|
+
reads `input_required` with `pending.kind: "approval"`, the tool, its arguments and its price (or "not metered"),
|
|
1248
|
+
until the owner answers `POST /v2/runs/{id}/approvals/{approval_id}` from their password session. Allowed, the run
|
|
1249
|
+
sends the call once and resumes with its result; denied, it resumes with the refusal. A restart while a call is
|
|
1250
|
+
parked loses nothing.
|
|
1251
|
+
- **Prices.** `PUT /v2/settings/mcp-servers/{name}` takes `prices`, each tool's price in USD a call
|
|
1252
|
+
(`{"prices": {"search": 0.01}}`; a finite number, 0 or more, for a tool the server lists; else `422`). A priced call
|
|
1253
|
+
is held at its price under the run's `max_cost_usd`, refused unsent when the cap cannot take it, and booked as the
|
|
1254
|
+
run's tool cost (a `Tool cost` row, the `tools` meter of `GET /usage`). A tool with no price runs "not metered": a
|
|
1255
|
+
row says so, the run's usage row counts it (`not_metered`), and `GET /usage`'s `tools` line counts the calls
|
|
1256
|
+
(`not_metered_calls`); it is outside the run's cost and its cap. A run keeps the prices its first launch saw.
|
|
1257
|
+
- **The timeline** shows each call as `<server> · <tool>`.
|
|
1258
|
+
|
|
874
1259
|
## Webhooks
|
|
875
1260
|
|
|
876
1261
|
One URL hears of your runs without anyone watching the page. `PUT /v2/settings/webhook` with `{url}` sets it: an `http`
|
|
877
1262
|
or `https` address, with no user or password in it. Loopback and private-network addresses are allowed, so a receiver
|
|
878
|
-
on your own machine or network works. Two kinds of message are POSTed to it: `run.needs_input` when a run comes to
|
|
1263
|
+
on your own machine or network works. Two kinds of message are POSTed to it about runs: `run.needs_input` when a run comes to
|
|
879
1264
|
need its person (`input_required`: an `ask_person` question, or a stopped turn) and `run.ended` when it ends
|
|
880
|
-
(completed, failed or cancelled, once carried back).
|
|
1265
|
+
(completed, failed or cancelled, once carried back). A [schedule](#schedules) whose firing fails sends a third,
|
|
1266
|
+
`trigger.failed`; a server with no triggers never sends one.
|
|
881
1267
|
|
|
882
1268
|
A run's end and its `run.ended` are one durable step. The server chooses the end's time once and gives it to the agent
|
|
883
1269
|
store, so the row's `ended_at` and the message's `webhook-id` name one time. `run.ended` is queued only once the agent
|
|
@@ -922,6 +1308,85 @@ lists the last 50 attempts (`webhook_id`, type, status code, latency, error, whe
|
|
|
922
1308
|
410 turned off sends nothing, a test or a redelivery included (`409 webhook_off`), until a `PUT` sets it again.
|
|
923
1309
|
`DELETE /v2/settings/webhook` removes the webhook and drops its pending messages.
|
|
924
1310
|
|
|
1311
|
+
## Schedules
|
|
1312
|
+
|
|
1313
|
+
A schedule starts an agent's runs with no one there. `POST /v2/triggers` with a `source` and a `target`:
|
|
1314
|
+
|
|
1315
|
+
```json
|
|
1316
|
+
{ "name": "nightly triage",
|
|
1317
|
+
"source": { "kind": "schedule", "cron": "30 1 * * *", "timezone": "America/Los_Angeles" },
|
|
1318
|
+
"target": { "kind": "start_run", "agent_id": "triage", "input": { "content": "Triage last night's issues." },
|
|
1319
|
+
"max_cost_usd": 2 } }
|
|
1320
|
+
```
|
|
1321
|
+
|
|
1322
|
+
A source is a cron line of five fields in an IANA zone (default UTC), `{at}` for one time (the trigger turns itself off
|
|
1323
|
+
after it fires), or `{every_s, start_at?}` for every N seconds, from 60 to a year and a day, on the grid from `start_at`. A time a clock
|
|
1324
|
+
change repeats fires once, at its first pass; one it skips fires at the first time after the gap. Each next time is
|
|
1325
|
+
reckoned from the last nominal one, so a timer that wakes late does not drift. Every run a trigger starts is capped: by
|
|
1326
|
+
the target's `max_cost_usd`, else by the agent's default (its definition's `max_cost_usd`) as it stands when the firing
|
|
1327
|
+
starts. A target with neither is `422`, and a firing that finds neither (the default removed since) fails, so no trigger
|
|
1328
|
+
starts an uncapped run. A workflow agent is refused, since a workflow run's spend is not capped here. Each run's
|
|
1329
|
+
input ends with a line naming the schedule and the time it fired for, in its zone, and the run's `trigger` names the
|
|
1330
|
+
trigger and the firing, in the run's view and in the runs lists (`GET /v2/runs`, `GET /v2/agents/{id}/runs`) alike;
|
|
1331
|
+
a run a caller started has `trigger: null`.
|
|
1332
|
+
|
|
1333
|
+
A firing starts its run once. Its key comes from the trigger and its nominal time, it is recorded `due` in
|
|
1334
|
+
`DIR/triggers.json` (written whole and synced) before its run starts, and the run is started under that key, so a firing
|
|
1335
|
+
a restart drives again finds its run. A firing's key stays bound to that run: when the server stopped while setting the
|
|
1336
|
+
run up, the firing reads `failed` ("The server stopped while setting up the run.") with that run's id, it never fires
|
|
1337
|
+
again, the next firing goes ahead, and `POST /v2/triggers/{id}/fire` is how a person tries it again. While the trigger's last run is active (working, or waiting on a person), a firing
|
|
1338
|
+
is `skipped`, with why; a full server (`429`) keeps it due and tries again. Times missed while the server was down are
|
|
1339
|
+
one `missed` firing with their count, and the schedule goes on from now; the latest of them still fires, once, when it is
|
|
1340
|
+
no older than the trigger's `catchup_window_s` (default an hour; 0, never), marked `catch_up`. Overlap is `skip` alone:
|
|
1341
|
+
a firing while the last run is active (working, or parked waiting on a person) is skipped with why, never queued,
|
|
1342
|
+
because a firing queued behind a parked run would wait as long as the person does. A firing whose run is refused is `failed`, and a webhook set on this server
|
|
1343
|
+
gets a `trigger.failed` message for it (`data: {trigger_id, name, firing_key, nominal_at, error, auto_paused}`, its
|
|
1344
|
+
`webhook-id` made from the firing's key, so a restart never sends it twice). Five failed firings in a row turn the
|
|
1345
|
+
trigger off (`disabled: {reason: "auto_paused"}`); a firing that starts its run resets the count, and so does turning
|
|
1346
|
+
it on again. Run now (below) works on an auto-paused trigger too, and counts toward the streak like any firing: one that
|
|
1347
|
+
starts its run resets it, one that fails adds to it. A trigger whose cron line or zone no longer reads here (after an
|
|
1348
|
+
upgrade of the cron library or of the time zone data) is turned off alone, at a start or when it comes due
|
|
1349
|
+
(`disabled: {reason: "source_unreadable", detail}`), and every other schedule goes on firing; turning it on again takes a
|
|
1350
|
+
new source. A trigger's firings are driven one at a time, in order, so a firing a crash left due settles to its run
|
|
1351
|
+
before the next one's overlap is checked. `PATCH /v2/triggers/{id}` changes it, and
|
|
1352
|
+
`{enabled: false}` pauses it: the time it was off is skipped, not caught up. `POST /v2/triggers/{id}/fire` runs it now,
|
|
1353
|
+
once per `Idempotency-Key` (required): the same key within `limits.idempotency_ttl_s` answers its firing, after the
|
|
1354
|
+
firing has left the history too, and later it is a new firing that a run the key started still answers. `GET /v2/triggers/{id}/firings` lists its last 200 firings.
|
|
1355
|
+
|
|
1356
|
+
### Webhook triggers
|
|
1357
|
+
|
|
1358
|
+
A trigger with `source: {kind: "webhook"}` fires on each request to `POST /v2/hooks/{trigger_id}`: this server's one
|
|
1359
|
+
route with no token. The request is signed by the trigger's own secret under the
|
|
1360
|
+
[Standard Webhooks](https://www.standardwebhooks.com) spec, the one this server's outbound [webhooks](#webhooks) sign
|
|
1361
|
+
with, so a sender uses any of its libraries: `webhook-id` (1 to 255 printable ASCII characters, no space), `webhook-timestamp` (Unix seconds, within 5 minutes of this
|
|
1362
|
+
server's clock either way) and `webhook-signature: v1,<base64 HMAC-SHA256 of "{id}.{timestamp}.{body}">` under the
|
|
1363
|
+
secret's bytes (several, space-separated, and any one may match). The signature is checked on the raw body, as sent and whatever its content type, before
|
|
1364
|
+
anything else. A bad signature, a stale timestamp, an unknown trigger, one that is off and one that is not a webhook's all
|
|
1365
|
+
answer the same `401`, so no trigger id can be found by asking; a body past 256 KiB is `413`.
|
|
1366
|
+
|
|
1367
|
+
The secret, `whsec_` and 32 random bytes in base64, is made with the trigger and shown in the `201` once; no `GET`
|
|
1368
|
+
shows it. It is kept sealed under `AGENTRUN_SEAL_KEY` in `DIR/trigger-secrets.json`, so with no seal key no webhook
|
|
1369
|
+
trigger is made (`409 no_sealing_key`). `POST /v2/triggers/{id}/secret` makes a new one, shown once, and the old one
|
|
1370
|
+
signs nothing from then on. An import cuts these secrets out of what it keeps, and no learning text shows one. A
|
|
1371
|
+
`trigger-secrets.json` that does not read is never written over: until it is fixed or moved away, no webhook trigger is
|
|
1372
|
+
made or rotated (`409 store_unreadable`) and none fires.
|
|
1373
|
+
|
|
1374
|
+
The request's `webhook-id` is its firing's key: the first answers `202` once the firing is recorded, and its run starts
|
|
1375
|
+
after; the same `webhook-id` again, for a day after (even once the firing has left the history of 200), answers `200` with that
|
|
1376
|
+
firing and starts nothing. The agent gets the trigger's input,
|
|
1377
|
+
then the body, cut at 16 KiB, inside `<trigger-payload source="webhook" untrusted>...</trigger-payload>`: whatever the
|
|
1378
|
+
sender wrote is data, not an instruction.
|
|
1379
|
+
|
|
1380
|
+
A trigger's target may also be `{kind: "message_run", run_id, input: {content}}`, with a webhook or a schedule source:
|
|
1381
|
+
each firing sends its input to that run as `POST /v2/runs/{id}/messages` would (a steer, or a follow-up that opens a
|
|
1382
|
+
completed run again), under its own cap. The run must have a cap (`422` on `target.run_id` otherwise, and a firing to a
|
|
1383
|
+
run that has none fails), and a firing never answers a run that waits on its person (a question, an approval, its
|
|
1384
|
+
cap): it is `skipped`, "The run is waiting on a person.", and the run still waits. The firing's key is the message's id in the run's store, which takes
|
|
1385
|
+
one message per id; a firing driven again after a restart first looks for it there, so it sends the message once and
|
|
1386
|
+
never opens a completed run again for one it already has. A firing to a run that is working waits for it (tried every
|
|
1387
|
+
5 s), and a trigger holds at most 20 firings due: past them a webhook event and a run now answer `429 rate_limited`
|
|
1388
|
+
with `Retry-After: 30`, recording nothing, and a schedule's time is `skipped`.
|
|
1389
|
+
|
|
925
1390
|
## What it serves
|
|
926
1391
|
|
|
927
1392
|
| Route | Here |
|
|
@@ -929,11 +1394,12 @@ lists the last 50 attempts (`webhook_id`, type, status code, latency, error, whe
|
|
|
929
1394
|
| `GET /health` | Without a credential: whether the store reads and the disk has room ([capacity and health](#capacity-and-health)). |
|
|
930
1395
|
| `GET /openapi.json` | Without a credential: this API as an OpenAPI 3.1 document, the `agentrun.v2/0` contract (vendored in `src/openapi/`, its source in `info`) with this server's own routes marked `x-agentrun-serve` the operations it answers `501` marked `x-agentrun-serve-unsupported`, and a contract operation that takes more than the contract gives marked `x-agentrun-serve-changed` with each change named; `links.openapi` in capabilities points at it. |
|
|
931
1396
|
| `GET /capabilities` | Without a credential. `backend: local`, every feature flag present and true only when it works; `tools`, the tools an agentic revision may name; `workflows`, what a workflow revision's model nodes get and, in `workflows.decisions.providers`, the decision providers its typed questions run on; `models`, where models come from and the model of each tier. |
|
|
932
|
-
| `POST /agents`, `GET /agents`, `GET /agents/{id}` | `POST` takes `{definition, skills?, note?}` and makes the agent with its first revision, current. A definition has `instructions` (an agentic revision) or `workflow` (a workflow revision, checked by the DSL first), and `name`, `description`, `model` and `thinking` (agentic only), `harness` ([harnesses](#harnesses)), `place` ([place](#place)), `tools`, `tool_settings` ([search and fetch](#search-and-fetch)), `skills` (names; each `<name>/SKILL.md` is in `skills`) and `version`, which is the number the revision gets. A field the store does not keep (`input_schema`, `output_schema
|
|
1397
|
+
| `POST /agents`, `GET /agents`, `GET /agents/{id}` | `POST` takes `{definition, skills?, note?}` and makes the agent with its first revision, current. A definition has `instructions` (an agentic revision) or `workflow` (a workflow revision, checked by the DSL first), and `name`, `description`, `model` and `thinking` (agentic only), `harness` ([harnesses](#harnesses)), `place` ([place](#place)), `tools`, `tool_settings` ([search and fetch](#search-and-fetch)), `skills` (names; each `<name>/SKILL.md` is in `skills`) and `version`, which is the number the revision gets, and `max_cost_usd` (agentic only), the agent's default cap, kept by an edit that leaves it out and cleared only by 0 ([spend cap](#spend-cap)). A field the store does not keep (`input_schema`, `output_schema`) is `422 input_invalid` by name, and so is a definition that can never run here; one this host cannot run yet saves with `warnings` ([models](#models)). The ETag (`home_etag`) is the current revision's id. `GET /agents/{id}` adds `tools`, the tools its current revision grants with each one's provider ([search and fetch](#search-and-fetch)). |
|
|
933
1398
|
| `PUT /agents/{id}/definition` | The same body, checked [the same way](#models): a new revision, its parent the current one, made current. Without `skills` the current revision's skill files carry over. A definition that is the current revision already writes nothing, so a PUT sent twice makes one revision. An agent's id, name and description stay those it was made with. `If-Match` that is not the current ETag is `412 precondition_failed`; the store compares it again inside the commit, so of two edits that read the same revision exactly one lands. The contract's body is taken too: the definition itself, with `If-Match` required (`412` without it) and `definition.version` greater than the current one (`422`). Any such version is taken, and always makes a new revision, the same definition included; the revision is numbered as this server numbers them, the next, and the answer says which; the route reads a body holding `definition` as this one, any other as the contract's. |
|
|
934
1399
|
| `GET /agents/{id}/revisions` | The agent's revisions, newest first: `revision`, `version`, `parent`, `kind`, `current`, `note`, `created_at` and the `definition`. |
|
|
935
1400
|
| `POST /agents/{id}/current` | `{revision}`: one of the agent's revisions becomes current again. |
|
|
936
1401
|
| `POST /agents/{id}/archive`, `POST /agents/{id}/unarchive` | [Archiving](#archiving): hides the agent and its runs from the lists, or shows them again. Answers the agent, with `archived_at`. |
|
|
1402
|
+
| `DELETE /agents/{id}/sign-ins/{key}` | This server's own route (`x-agentrun-serve: "signins/1"`): forgets one of the agent's [saved sign-ins](#saved-sign-ins), at its vendor and here. `409 sign_in_held` while a run holds its save lease. |
|
|
937
1403
|
| `POST /agents/{id}/runs`, `GET /agents/{id}/runs` | A run of the current revision, or of `revision`. An agentic run's input is `{content: string}`; a workflow run's is what its workflow's input schema takes. `file_ids` names [uploaded](#uploads) files, copied into the run's `work/inputs/` before it starts and named in its first message. The agent's runs, newest first. |
|
|
938
1404
|
| `GET /runs` | Every agent's runs, newest first, a page of at most 100; `agent`, `revision` and `status` narrow it, and `archived=true` lists only archived ones. A failed run's summary carries its `error`, and a waiting run's its `pending`. |
|
|
939
1405
|
| `GET /runs/{id}` | The run: its revision, kind, status, state, result, error, `pending` (this server's own, `pending/1`: what it waits on, by `kind`, such as `{kind: "question", question, asked_at}` for a question it asked a person; else null) and cost (`basis: estimate`; $0 before its first model request, a cancelled run's included). |
|
|
@@ -950,14 +1416,14 @@ lists the last 50 attempts (`webhook_id`, type, status code, latency, error, whe
|
|
|
950
1416
|
| `POST /workflows/validate` | `{workflow, tools?}`: every issue a save would refuse (`[{path, code, message}]`, the DSL's validation with code not run) and what this host lacks as `warnings`. Writes nothing. A refused save's `422` carries each issue as a field under `definition.workflow`, with its `code`. |
|
|
951
1417
|
| `GET /settings/tool-keys`, `PUT` and `DELETE /settings/tool-keys/{id}` | [Tool keys](#tool-keys), this server's own routes (`x-agentrun-serve: "toolkeys/1"`): each key's fields by name and where each is set, never a value; save one sealed, or forget it. |
|
|
952
1418
|
| `GET /settings/mcp-servers`, `POST /settings/mcp-servers/preview`, `GET`, `PUT` and `DELETE /settings/mcp-servers/{name}`, `POST .../{name}/refresh` | [MCP servers](#mcp-servers), this server's own routes (`x-agentrun-serve: "mcpservers/1"`): preview a remote MCP server's tools, save it with its credential sealed, read it back without the credential, refresh its tools, or forget it. |
|
|
953
|
-
| `GET /settings/tools`, `PUT /settings/tools` | This server's own: the providers of `web_search` and `
|
|
1419
|
+
| `GET /settings/tools`, `PUT /settings/tools` | This server's own: the providers of `web_search`, `web_fetch` and `browser` ([search and fetch](#search-and-fetch)). |
|
|
954
1420
|
| `GET`, `PUT` and `DELETE /settings/webhook`, `POST /settings/webhook/test`, `GET /settings/webhook/deliveries` and `POST .../deliveries/{webhook_id}/redeliver` | [Webhooks](#webhooks), this server's own routes (`x-agentrun-serve: "webhook/1"`): the URL run notices are POSTed to, signed by the Standard Webhooks spec; never its secret but once. |
|
|
1421
|
+
| `GET` and `POST /triggers`, `GET`, `PATCH` and `DELETE /triggers/{id}`, `POST /triggers/{id}/fire`, `GET /triggers/{id}/firings`, `POST /triggers/{id}/secret`, `POST /hooks/{id}` (no token: [signed](#webhook-triggers)) | [Schedules](#schedules), this server's own routes (`x-agentrun-serve: "trigger/1"`): schedules that start an agent's capped runs, each firing once, and their history. |
|
|
955
1422
|
| `POST /mcp` | This server's own route (`x-agentrun-serve: "mcp/1"`): the [MCP endpoint](#for-coding-agents), Streamable HTTP with one JSON-RPC message per POST (`initialize`, `ping`, `tools/list`, `tools/call`), answered as JSON, stateless. Its ten tools call these routes in process with the caller's token. The Bearer token only, never the page's cookie; a browser `Origin` other than this server's own is `403`; any other method is `405`. |
|
|
956
|
-
| `GET /usage` | The runs' cost estimates, by meter, agent, key, day or region (`key` and `region` are one line, `local`). A run of unknown cost adds
|
|
1423
|
+
| `GET /usage` | The runs' cost estimates, by meter, agent, key, day or region (`key` and `region` are one line, `local`). A run of unknown cost adds what it is known to have spent so far (its `so_far_usd`: each priced charge, browser time and paid tools included) and is counted in `unpriced_runs` (in the total and in each line it is unknown on), so no sum is ever null, it never passes as $0, and a total is never below a line of its own: with `unpriced_runs` above 0 the total is a lower bound. |
|
|
957
1424
|
|
|
958
1425
|
Home export and import, quotes and `POST /runs/{id}/kill` answer `501 unsupported_here` naming the feature, and
|
|
959
|
-
capabilities declare each one false. No run waits out `input_wait_s` here (`null`),
|
|
960
|
-
browser sign-ins (`sign_ins: false`). `limits.max_cost_usd` is the highest cap a run may name: `null` here, as any cap
|
|
1426
|
+
capabilities declare each one false. No run waits out `input_wait_s` here (`null`). `limits.max_cost_usd` is the highest cap a run may name: `null` here, as any cap
|
|
961
1427
|
above $0 is taken; it does not mean caps are unsupported ([spend cap](#spend-cap)).
|
|
962
1428
|
|
|
963
1429
|
## Uploads
|
|
@@ -1019,11 +1485,12 @@ at once, the last wins. A body over `capabilities.home.max_file_bytes` (`limits.
|
|
|
1019
1485
|
`DELETE` removes a file (`204`; `404` when it is not there) and leaves an emptied directory in place. Paths are checked
|
|
1020
1486
|
as a run's are, a write goes at most 16 directories deep (as deep as the list goes), and a link anywhere on the way is
|
|
1021
1487
|
never followed: a read is `404`, a write or a delete
|
|
1022
|
-
`403 system_file_forbidden`. `learning/`
|
|
1023
|
-
`{"path": "learning", "host_owned":
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1488
|
+
`403 system_file_forbidden`. `learning/` and `sign-ins/` (the agent's [saved sign-ins](#saved-sign-ins)) are the
|
|
1489
|
+
server's alone (`capabilities.home.host_owned`): the list shows each as one entry, `{"path": "learning", "host_owned":
|
|
1490
|
+
true}`, with none of what is in it, and a `GET`, `PUT` or `DELETE` at or under one, however the path is spelled
|
|
1491
|
+
(`./Learning/x`), is `403 system_file_forbidden` (`details.reason` `host_owned`). A read's refusal names where to read
|
|
1492
|
+
it instead: the learning API (`/v2/agents/{id}/learning`) on a server that has that route (on one that does not, `the
|
|
1493
|
+
server keeps learning/ for itself; this server has no learning API yet`), and `/v2/agents/{id}` for `sign-ins/`. A host-owned name is matched by its
|
|
1027
1494
|
first segment folded (compatibility form, any case, no combining marks) and, where that segment and `learning/` are both
|
|
1028
1495
|
on disk, by identity (the same
|
|
1029
1496
|
device and inode), so a disk that takes another spelling for one name is refused the same way. A path takes only plain
|
|
@@ -1068,7 +1535,7 @@ codex mcp add agentrun --url "$AGENTRUN_BASE_URL/mcp" --bearer-token-env-var AGE
|
|
|
1068
1535
|
## Harnesses
|
|
1069
1536
|
|
|
1070
1537
|
A definition names the harness that runs it: `pi` (the default, and what a definition that names none gets),
|
|
1071
|
-
`claude-agent` or `
|
|
1538
|
+
`claude-agent`, `codex` or `opencode`; any other is `422 input_invalid` on `definition.harness`. Every answer names it. An edit
|
|
1072
1539
|
(`PUT /agents/{id}/definition`) that names no harness keeps the agent's, as it keeps its skill files; name `pi` to move it
|
|
1073
1540
|
back.
|
|
1074
1541
|
`GET /v2/capabilities` lists each in `harnesses`, with `available` and, when not, the `reason`, and `default_model`: the
|
|
@@ -1077,8 +1544,11 @@ it runs none (the harness does not run here, or no default model here runs on it
|
|
|
1077
1544
|
model). A definition naming a
|
|
1078
1545
|
harness this server does not run yet saves with a warning on `definition.harness`, and a run of it is
|
|
1079
1546
|
`409 agent_not_runnable` with `details.harness`; it never runs on pi instead. This server runs pi always, and
|
|
1080
|
-
`claude-agent` and `
|
|
1081
|
-
says what is missing.
|
|
1547
|
+
`claude-agent`, `codex` and `opencode` when each adapter's package, pins and provider endpoint check out; the harness's
|
|
1548
|
+
`reason` says what is missing. `opencode` needs `opencode-ai@1.19.5` installed beside the server (an exact optional peer of
|
|
1549
|
+
it), and its model goes where codex's does: the gateway at `AGENT_MODEL_BASE_URL`, or
|
|
1550
|
+
OpenAI with `OPENAI_API_KEY`, on the Responses API. The packages and pins are checked once, at the start
|
|
1551
|
+
(`event=harness_offers why=start`): a harness
|
|
1082
1552
|
installed after it, or put back on its pinned build, stays unavailable until AgentRun restarts, and its reason ends
|
|
1083
1553
|
saying so, `once it is installed, restart AgentRun to pick it up` or `once the pinned build is installed, restart
|
|
1084
1554
|
AgentRun`. Run from npx, a reason whose install line is the npx line that starts the server with what is missing needs
|
|
@@ -1086,13 +1556,13 @@ no such clause: running that line is the restart. A reason a setting fixes (a mo
|
|
|
1086
1556
|
|
|
1087
1557
|
`claude-agent` sends its requests to `ANTHROPIC_BASE_URL` (else Anthropic) with `ANTHROPIC_API_KEY` and Anthropic's own
|
|
1088
1558
|
model id, and prices the run by it: a revision's `anthropic/<model-id>`, its dots as dashes, so OpenRouter's dotted name
|
|
1089
|
-
(`anthropic/claude-sonnet-5.5`) and Anthropic's own (`claude-sonnet-5-5`) are one model. `codex`
|
|
1090
|
-
serve's gateway (`AGENT_MODEL_BASE_URL`), else OpenAI with `OPENAI_API_KEY`. A harness with none of its own settings, where
|
|
1559
|
+
(`anthropic/claude-sonnet-5.5`) and Anthropic's own (`claude-sonnet-5-5`) are one model. `codex` and `opencode` send their requests
|
|
1560
|
+
to serve's gateway (`AGENT_MODEL_BASE_URL`), else OpenAI with `OPENAI_API_KEY`. A harness with none of its own settings, where
|
|
1091
1561
|
`OPENROUTER_API_KEY` is set, runs through OpenRouter (`https://openrouter.ai/api`, the key as a bearer token):
|
|
1092
1562
|
claude-agent on its Messages endpoint, with Anthropic's own id on the wire (OpenRouter takes it: its Claude Code guide
|
|
1093
|
-
says its "Anthropic Skin … handles model mapping") and the run priced by OpenRouter's catalog entry; codex on its Responses API, with the model's whole id (`openai/gpt-6-sol`). On that key alone the defaults are
|
|
1563
|
+
says its "Anthropic Skin … handles model mapping") and the run priced by OpenRouter's catalog entry; codex and opencode on its Responses API, with the model's whole id (`openai/gpt-6-sol`). On that key alone the defaults are
|
|
1094
1564
|
`openrouter/openai/gpt-6-sol` for pi (pi-ai's OpenRouter provider, on the bearer route), `anthropic/claude-sonnet-5.5` for
|
|
1095
|
-
claude-agent and `openai/gpt-6-sol` for codex; a direct provider's key gives the default for its harnesses where it is
|
|
1565
|
+
claude-agent and `openai/gpt-6-sol` for codex and opencode; a direct provider's key gives the default for its harnesses where it is
|
|
1096
1566
|
set. A model named `openrouter/<vendor>/<model>` (pi's name for it) goes through OpenRouter on every harness. An endpoint
|
|
1097
1567
|
the host names never gets OpenRouter's key: `ANTHROPIC_BASE_URL` without `ANTHROPIC_API_KEY` is refused. A model with more
|
|
1098
1568
|
than one segment after its provider (`anthropic/anthropic/claude-sonnet-5.5`) is refused, naming the form to use. A provider
|
|
@@ -1104,7 +1574,10 @@ harness, with the provider's first sentence only.
|
|
|
1104
1574
|
tool and reads its other files with `read_skill_file`, and the system prompt holds the instructions alone. A skill the
|
|
1105
1575
|
adapter does not take (a name that is not lowercase letters, digits and dashes, a `SKILL.md` without front matter giving
|
|
1106
1576
|
its `name` and a `description`, a file path that is not plain or is deeper than five segments) stays inlined in the
|
|
1107
|
-
system prompt
|
|
1577
|
+
system prompt; so do all of them when together they hold more than 1 MiB. On `pi`, `codex` and `opencode`, a run with the
|
|
1578
|
+
`read` or `bash` tool is told each skill's name, what it is for (its `description`) and its `SKILL.md`'s path under
|
|
1579
|
+
`.agents/skills/`, and reads the file when the skill fits the step it is on; a run with neither gets every `SKILL.md`
|
|
1580
|
+
inlined in its system prompt.
|
|
1108
1581
|
|
|
1109
1582
|
`definition.harness` and `capabilities.harnesses` are this server's, outside the `agentrun.v2/0` contract:
|
|
1110
1583
|
`GET /v2/openapi.json` marks each `x-agentrun-serve: "harness/1"`, beside the other properties it adds (`model/1`,
|
|
@@ -1264,7 +1737,15 @@ left out: 2 sessions still being written: they come in next time
|
|
|
1264
1737
|
[sandbox](#sandbox), where it and the file tools run in the run's box. The run is `queued` until its first message shows; while the process runs, the
|
|
1265
1738
|
timeline comes from its door's events through `@parcha/pi-durable-agent/timeline`. Once the run is idle and its
|
|
1266
1739
|
newest row is the agent's answer, the server sends the process SIGTERM. A model error ends it `failed`
|
|
1267
|
-
(`run_failed`)
|
|
1740
|
+
(`run_failed`). A run whose `max_cost_usd` cannot buy its next request is paused, `input_required` and `waiting`
|
|
1741
|
+
with `pending.kind` `budget`; one its cap refuses for a reason no cap fixes ends `failed` (`spend_cap_reached`,
|
|
1742
|
+
[below](#spend-cap)). A
|
|
1743
|
+
provider's content filter stopping the answer ends it `failed` with `moderated` on every harness, saying so in plain
|
|
1744
|
+
words ("The model provider stopped this answer (its content filter). Rephrase the request, or try another model.");
|
|
1745
|
+
the Timeline's error row keeps the harness's own words for the stop: pi-ai's on pi ("Response incomplete:
|
|
1746
|
+
content_filter", say), the kernel's on claude-agent and codex ("content_filter: the model provider stopped this
|
|
1747
|
+
answer"), never the provider's own. On claude-agent and codex the session's model proxy reads
|
|
1748
|
+
the provider's stop and ends the turn at once, so the CLI never asks for the refused answer again.
|
|
1268
1749
|
A stop sent while the run still reads `queued` (a message sent to it not yet in its timeline) waits, up to a
|
|
1269
1750
|
request's deadline, for that message to show, then stops the turn as it stops any working run.
|
|
1270
1751
|
A stopped run can be continued: a follow-up starts a fresh turn on the whole history, and the turn the stop cut is
|
|
@@ -1289,8 +1770,11 @@ left out: 2 sessions still being written: they come in next time
|
|
|
1289
1770
|
agentic run waiting for an answer waits without one, until a message). A carry back that finds the store held by
|
|
1290
1771
|
another writer is tried again with backoff, and at the next start.
|
|
1291
1772
|
|
|
1292
|
-
An `Idempotency-Key` answer is kept in `DATA/.idempotency.json` for `limits.idempotency_ttl_s` (a day),
|
|
1293
|
-
the answer is sent, so a retry after a restart gets the first answer
|
|
1773
|
+
An `Idempotency-Key` answer is kept in `DATA/.idempotency.json` for `limits.idempotency_ttl_s` (a day), saved once the
|
|
1774
|
+
work is done and before the answer is sent, so a retry after a restart gets the first answer; a server that goes down
|
|
1775
|
+
between the work and the save loses it, and a save that fails still answers. A run create's key is also kept with its
|
|
1776
|
+
run in the agent store, written with the run itself, so a retry after any restart, or after that day, gets that run (as
|
|
1777
|
+
it is now, marked `Idempotent-Replayed: true`), and another body under the key is still `409 idempotency_mismatch`.
|
|
1294
1778
|
|
|
1295
1779
|
A completed agentic run's `result` is `{output: null, final_answer}`; a completed workflow run's is
|
|
1296
1780
|
`{output: <the workflow's output>, final_answer: null}`.
|
|
@@ -1352,6 +1836,31 @@ Each run of an agent that learns starts from `main` as it is when the run is mad
|
|
|
1352
1836
|
follow-up gets them laid again, fresh, whatever the run wrote over them; one the work no longer holds whole when the
|
|
1353
1837
|
run's process starts is left out of what its harness gets, and the run goes on. A skill whose name or files are out
|
|
1354
1838
|
of shape is not read, and a symbolic link or a submodule at `skills/` or anywhere under it is a learning fault.
|
|
1839
|
+
- The workflows the agent learned, each a folder `workflows/<name>/` on `main` with its `workflow.json` and its
|
|
1840
|
+
`README.md`, are the run's as one tool, `learned_workflow {name, input}`, on every harness (pi, claude-agent, codex),
|
|
1841
|
+
with no edit of the agent's definition. Only an active one is, by a skill's rule: its `README.md` sets no status, or
|
|
1842
|
+
`active`. Its description names each workflow with the line its README gives, 8 KiB of lines in all: by name, each
|
|
1843
|
+
while its line fits, and one that does not, or holds one of the server's secrets, is left out. A README whose front
|
|
1844
|
+
matter does not read one way (not closed, or a line that is no key at its left edge) is not read. The pin names the
|
|
1845
|
+
ones the run gets (`workflows`), each kept whole in the run's directory (`learned-workflows.json`), outside its work,
|
|
1846
|
+
and the ones left out (`workflows_left_out`). The list is fixed when the run starts: a workflow approved or retired
|
|
1847
|
+
while it runs is the next run's to get or not, as a note or a skill is. A call checks the workflow again against the
|
|
1848
|
+
agent's own tools as its run resolves them, as the merge did: one whose call node names a tool the agent was not
|
|
1849
|
+
granted (or one its run resolves unavailable), whose model node names any tool (a learned model node runs without
|
|
1850
|
+
tools, so the merge refuses one too), or that holds a code node or a shell or executor call, is refused before any of
|
|
1851
|
+
its nodes runs. It runs with the workflow DSL: each model node on the run's own model (the one the run was made with
|
|
1852
|
+
and handed the key of; a tier the run has no model of runs there too), in a session of its own with no tool of its
|
|
1853
|
+
own, each call node `via: "tool"` on a tool the agent has, its paid requests booked under
|
|
1854
|
+
the `learned_workflow` call, and web_search on the provider's own search where it resolves native, through the run's
|
|
1855
|
+
models. Its model requests are the run's, under its cap and on its timeline as side requests labelled
|
|
1856
|
+
`learned_workflow`: on claude-agent and codex, the harness's requests and the workflow's count against one total, and
|
|
1857
|
+
each holds its worst case in flight where the other's check sees it, and the workflow's go where the harness's go (on
|
|
1858
|
+
OPENROUTER_API_KEY alone, through OpenRouter, by OpenRouter's name for the run's model; claude-agent through the
|
|
1859
|
+
operator's own gateway at ANTHROPIC_BASE_URL, or any harness at an origin its requests could not follow, is offered
|
|
1860
|
+
none, which its pin names in `workflows_off`; opencode takes codex's route). A call a crash cut off is answered interrupted,
|
|
1861
|
+
never run again. The tool gate holds
|
|
1862
|
+
`learned_workflow` like any tool: its settings key is `learned_workflow`, allowed by default (the agent's own graded
|
|
1863
|
+
workflow, each node checked), and tool settings may set it to ask (the run parks until an owner answers) or deny.
|
|
1355
1864
|
|
|
1356
1865
|
The server reads the commit with git plumbing, never the working tree. What it holds that is not a regular UTF-8 file of
|
|
1357
1866
|
1 MiB or less, or a note out of shape, is not read, and the server's stderr names it. A learning fault never blocks a
|
|
@@ -1381,7 +1890,8 @@ path that is not a `.md` file at the top, a bad name, front matter out of shape
|
|
|
1381
1890
|
naming a note that is not active, more than 8 notes superseded, more than 8 new notes or a note over 4068 bytes (4096,
|
|
1382
1891
|
less the 28 the server's own `origin` and `status` lines may take once it merges the note), an
|
|
1383
1892
|
index past 200 lines, hidden characters, and text shaped like a secret or holding one of the server's own secrets (the
|
|
1384
|
-
launcher's, the keys and tokens in its environment, its API and door tokens
|
|
1893
|
+
launcher's, the keys and tokens in its environment, its API and door tokens, each webhook trigger's signing secret as it
|
|
1894
|
+
is now), in a note or its name. A `MEMORY.md` the
|
|
1385
1895
|
answer gives is ignored. What passes is kept as the run's proposal, `runs/<id>/learning-proposal.json`, with what the
|
|
1386
1896
|
user said, each message cut of the server's secrets.
|
|
1387
1897
|
|
|
@@ -1393,8 +1903,8 @@ neither, on the agent's own model. `GET /capabilities` names it as `learning.gra
|
|
|
1393
1903
|
cheap model is a poor grader, so point the strong tier (or `--grade-model`) at a strong one. The grader reads each active
|
|
1394
1904
|
note's index line, the whole text only of the notes the proposal supersedes, what the user said in the run (cut of the
|
|
1395
1905
|
server's secrets, as the proposal keeps it), and the new notes, so its prompt stays under 200,000 characters however
|
|
1396
|
-
many notes the folder holds.
|
|
1397
|
-
|
|
1906
|
+
many notes the folder holds. No injection screen runs before it: a page classifier cannot see where a note came
|
|
1907
|
+
from, and read a preference the user stated as a planted instruction; the grader's Planted question decides. What the
|
|
1398
1908
|
grade spends is in no run's totals: it is kept on the run's learning, and counted once on `GET /usage` under the meter
|
|
1399
1909
|
`learning`, by agent and by day; a call cut off at its bound spent what nobody knows, so its cost is unknown, never $0.
|
|
1400
1910
|
|
|
@@ -1414,8 +1924,8 @@ The run's `learning` (on `GET /runs/{run_id}`, and `{state, reason, detail}` in
|
|
|
1414
1924
|
characters and no time) says how it went: `seeded`, then
|
|
1415
1925
|
`reflecting` during the turn and until what it answered is checked, `proposed` while it is graded, and `merged`, or
|
|
1416
1926
|
`dropped` with a reason from a closed list (`seed_failed`, `no_budget`, `unknown_cost`, `cancelled`, `crashed`,
|
|
1417
|
-
`reflect_timeout`, `reflect_failed`, `empty`, `unparsed`, `propose_failed`, `checker`, `
|
|
1418
|
-
`
|
|
1927
|
+
`reflect_timeout`, `reflect_failed`, `empty`, `unparsed`, `propose_failed`, `checker`, `grader`, `grade_failed`;
|
|
1928
|
+
`no_write_tool`, `tool_denied`, `screen` and `screen_down` are an older server's, still read and counted, and no run
|
|
1419
1929
|
gets them now). It is `null` for a
|
|
1420
1930
|
run that does not learn (its agent's `learning` is not true, the server's switch was off when it started, or it is a
|
|
1421
1931
|
workflow's or an imported run). Its `detail` says the same in a person's words, never the machine's: "Started from 2
|
|
@@ -1489,6 +1999,16 @@ with the token, an archived agent's too:
|
|
|
1489
1999
|
`learning: <edited, created or retired> by a person: <file>` with a `Changed-By: user` trailer, with `MEMORY.md`
|
|
1490
2000
|
rebuilt, `main` moved only from the commit it was made on, and the folder's files brought in line; it answers the
|
|
1491
2001
|
note as it now is, with its new `ETag`. `MEMORY.md` itself is never written (400).
|
|
2002
|
+
- `POST .../learning/files/{file}/restore` under `If-Match` makes a retired note active again, and gives a retired skill
|
|
2003
|
+
(its `SKILL.md`) or workflow draft (its `README.md`) to every later run again: one commit, `learning: restored by a
|
|
2004
|
+
person: <file>`, with `MEMORY.md` rebuilt and the notes it supersedes marked superseded, as an approval marks them.
|
|
2005
|
+
Unlike a retire, a restore checks the text again as a new note or skill is checked (secret shapes, the server's
|
|
2006
|
+
values, hidden characters, its format, and every file of a skill's or a draft's folder): a refusal is 400 with
|
|
2007
|
+
`problems`, and the item stays retired. Only a retired item is restored (else 400). It takes the owner's password
|
|
2008
|
+
session alone, as an approval does; one that waited for its owner's OK before its retire is recorded as their approval
|
|
2009
|
+
too (`Approved-Via: console`). The learning view gives each item `last_change` (`{kind, by, at}`: `approved`,
|
|
2010
|
+
`edited`, `created`, `retired` or `restored` by a `person`, or `learned` by a `run`) and each retired one `retired`
|
|
2011
|
+
(`{at, by}`, the time of its retire, which an edit since moves not).
|
|
1492
2012
|
- `GET /runs/{run_id}/learning`: the run's learning whole (its `used` and `learned` as on its read, its seed, its merge, the grader's verdict with its item for
|
|
1493
2013
|
each new note, `{file, keep, question, why}`, `question` the rubric's question a dropped note failed, the checker's
|
|
1494
2014
|
problems, what the grade cost), `null` for a run that does not learn; `verdict` is `null` until a grade ran.
|
|
@@ -1508,7 +2028,7 @@ followed: a read or a write there answers `500`, and nothing is written.
|
|
|
1508
2028
|
|
|
1509
2029
|
Who can approve: the owner, signed in with their password. No token approves, the server's own included, so a run that reaches this server only through its API (its MCP tools, a sandbox run) can't approve its own notes. Runs that use bash on the host run as you: they can read this server's files, its session key among them, so no route keeps them from approving. For untrusted tasks, use the sandbox.
|
|
1510
2030
|
|
|
1511
|
-
`POST .../learning/files/{file}/approve` takes the console's password session, sent from this server's own origin with
|
|
2031
|
+
`POST .../learning/files/{file}/approve` (and `.../restore`, which puts a retired item back into every run) takes the console's password session, sent from this server's own origin with
|
|
1512
2032
|
a JSON body as every page write is. Any token is 403: the server's own (what scripts and the MCP endpoint's tools
|
|
1513
2033
|
carry), a run's door token, and a token sent beside the session. So is every request on a server with accounts off
|
|
1514
2034
|
(`AGENTRUN_ACCOUNTS=0`), whose page cookie any token holder can mint. With no credential it is 401, as every route.
|
|
@@ -1519,28 +2039,54 @@ log shows `by: {user: true, via: "console"}` at the commit's time, never the not
|
|
|
1519
2039
|
|
|
1520
2040
|
## Spend cap
|
|
1521
2041
|
|
|
1522
|
-
An agentic run may name `max_cost_usd` (a workflow run may not: `422`).
|
|
2042
|
+
An agentic run may name `max_cost_usd` (a workflow run may not: `422`). A run that names none takes its agent's default,
|
|
2043
|
+
the `max_cost_usd` of the revision it runs, kept with the revision; a run's own cap wins, since its caller chose it. A
|
|
2044
|
+
definition's `max_cost_usd` above 0 sets that default, and 0 clears it (no default); anything else is `422`. An edit that
|
|
2045
|
+
leaves the field out keeps the agent's default, as it keeps its harness and place: leaving a field out never removes a
|
|
2046
|
+
spend limit. A workflow definition keeps none: above 0 is `422 not_allowed`, and 0 changes nothing. The cap is checked in the run's own process
|
|
1523
2047
|
before each model request, the agent's and a compaction's alike, on every harness: what the run has spent so far, plus
|
|
1524
2048
|
the worst case of each request still in flight, plus this request's worst case must stay within it, or the request is
|
|
1525
|
-
not sent and the run
|
|
2049
|
+
not sent and the run pauses ([below](#a-run-paused-at-its-cap)). A request's worst case is its input bound at the higher of
|
|
1526
2050
|
the model's input and cache-write prices (the provider may bill any of the input as a cache write), plus the output it is
|
|
1527
2051
|
sent with at the output price, plus any fee its tokens do not show (below). Under a cap each request is limited to the
|
|
1528
2052
|
output tokens what is left of the cap can buy, thinking included, never more than it asks for or than the model's
|
|
1529
2053
|
ceiling (its max output tokens, else its context window, clamped to what the window leaves): on pi through the request's
|
|
1530
|
-
own options (its max tokens, and on Anthropic's API its thinking budget), on claude-agent and
|
|
2054
|
+
own options (its max tokens, and on Anthropic's API its thinking budget), on claude-agent, codex and opencode written into its body
|
|
1531
2055
|
by the model proxy (`max_tokens` and `thinking.budget_tokens`, or `max_output_tokens`). The limit is what it is held at,
|
|
1532
2056
|
so the cap stays exact. A request is refused only when what is left cannot buy its least: 1,024
|
|
1533
2057
|
tokens for its answer (what it asks for, when that is fewer), and when it thinks, the provider's least thinking budget
|
|
1534
2058
|
where thinking takes one (Anthropic's, 1,024, the budget squeezed to it at the least) or else its thinking level's
|
|
1535
2059
|
budget, since its reasoning then shares the limit (minimal 1,024, low 2,048, medium 8,192, high 16,384). The input bound is one token per UTF-8 byte of what is sent (a byte-level tokenizer never makes
|
|
1536
2060
|
a token of less than one byte, and an image's base64 is far more bytes than its tokens), plus what the provider adds
|
|
1537
|
-
server-side (a tool-use prompt, each image), from the same table the model proxy of claude-agent and
|
|
2061
|
+
server-side (a tool-use prompt, each image), from the same table the model proxy of claude-agent, codex and opencode uses; there
|
|
1538
2062
|
the proxy measures each request's body. A request in flight holds its worst case until it answers, so requests sent side
|
|
1539
2063
|
by side cannot pass the cap together. Spent so far is read from the run's store each time its process starts, so it
|
|
1540
2064
|
survives a restart, plus each response since, and with them each charge a paid tool booked (`monid.run`, which is itself
|
|
1541
2065
|
refused once the spend reaches the cap; see [monid](#tools)).
|
|
1542
2066
|
|
|
1543
|
-
|
|
2067
|
+
The `browser` tool's session time is held the same way, before it runs, so no browser minute passes the cap. Its next
|
|
2068
|
+
stretch is the most a session can run before the run can check again: the provider's minimum (what its release may top
|
|
2069
|
+
it up to), pi-browser's idle window before it releases a session nobody calls (180 s), and 30 s for that release to be
|
|
2070
|
+
confirmed at the provider; at Browserbase's price, 270 s or $0.009. Before each browser call, the call is held at what its
|
|
2071
|
+
session ran since its last charge plus two stretches (one for the call's own time, one for a session it opens): spent, plus
|
|
2072
|
+
every hold, plus that must stay within the cap. Otherwise the call is not made: the model gets the cap's words
|
|
2073
|
+
(`spend_cap_reached: Not sent: the run has spent $X of its $C cap, and this browser call could cost up to $0.018 ...`), and
|
|
2074
|
+
the run's session is released.
|
|
2075
|
+
A session's first charge moves one stretch of its call's hold to the session, held until its release is booked, which
|
|
2076
|
+
covers its idle time, its top-up and its release; each call's charge comes out of the call's hold, which goes when the
|
|
2077
|
+
call returns. So what the run spent plus what it holds stays within the cap through a session's create, its calls, the
|
|
2078
|
+
idle time between them and its release. A session a create's lost answer left to a release after the create deadline is
|
|
2079
|
+
held for that deadline and a stretch until its release is billed. Across a restart of the run's process, every session
|
|
2080
|
+
custody still tracks (kept, unreached, still releasing) is held from the reopen, at a stretch beside what it ran since
|
|
2081
|
+
its last charge, and one kept is released an idle window later unless a call uses it. Three
|
|
2082
|
+
things can still pass the cap, each by what it ran over, booked and shown: a single browser call that runs longer than a
|
|
2083
|
+
stretch, a release that takes longer than 30 s to be confirmed, and the time a run's process was down while it held a
|
|
2084
|
+
session (spent before any process could hold it). A session whose release is never confirmed is billed in full
|
|
2085
|
+
(what it ran and its minimum) when the run gives up on it. When the run is let go, its sessions are released and their
|
|
2086
|
+
last charges booked before its process exits.
|
|
2087
|
+
|
|
2088
|
+
Under a cap, whatever cannot be priced is refused, never passed as $0, and the run ends `failed` with
|
|
2089
|
+
`spend_cap_reached`, since no cap would send it:
|
|
1544
2090
|
|
|
1545
2091
|
- A model serve has no price for (a gateway id pi-ai's catalog does not know, with no `AGENT_MODEL_PRICE`): its first
|
|
1546
2092
|
request is refused before anything is sent, and the run ends `spend_cap_reached` at $0. With no cap its run's cost
|
|
@@ -1553,14 +2099,40 @@ Under a cap, whatever cannot be priced is refused, never passed as $0:
|
|
|
1553
2099
|
after a cut, at the worst case the cap held, as pi does.
|
|
1554
2100
|
|
|
1555
2101
|
A request you stop counts what it streamed plus up to 1,024 output tokens the provider may have produced after the last
|
|
1556
|
-
word we read; never more than it was held. That is its input bound and each byte it streamed (text,
|
|
1557
|
-
calls on pi;
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
request
|
|
2102
|
+
word we read; never more than it was held. That is its input bound and each byte of content it streamed (its text,
|
|
2103
|
+
thinking and tool calls on pi; on `claude-agent`, `codex` and `opencode`, the text, reasoning and tool-argument deltas
|
|
2104
|
+
the response sent, never the provider's framing around them, which runs to about 12 bytes a character on the Responses
|
|
2105
|
+
API and 24 on the Messages API) as a token, plus 1,024 tokens of output (`STOP_ALLOWANCE_TOKENS`), at the model's price, and at most
|
|
2106
|
+
the worst case the cap held for it. The cut stream's own usage is never read: it is not what the provider billed (the
|
|
2107
|
+
Responses API reports none until the end, and Anthropic's output count comes at the end). The 1,024 tokens are a stated
|
|
2108
|
+
bound, as the native search allowance is: a provider that went on producing for longer after the stop could bill past
|
|
2109
|
+
what is counted. A request that ended on an error after its response began (an overload part way, a reset), or a summary
|
|
2110
|
+
that failed, still counts at its worst case, and so does a request cut by a crash (its process gone mid-request). A
|
|
2111
|
+
request stopped before the provider's first header counts its input and the 1,024 tokens, on every harness.
|
|
2112
|
+
|
|
2113
|
+
Reasoning the provider never streams counts too. A model whose reasoning streams only as a summary (the Responses API's
|
|
2114
|
+
reasoning; Claude 4-class thinking, and redacted thinking) or not at all is billed for far more than the summary's
|
|
2115
|
+
bytes, so a stopped request that reasons also counts the part of its reasoning budget that did not stream: input +
|
|
2116
|
+
streamed + 1,024 + max(0, reasoning budget - reasoning streamed), never more than the hold. Reasoning streamed is its
|
|
2117
|
+
thinking's bytes on pi, and on `claude-agent`, `codex` and `opencode` the bytes of the reasoning events the response
|
|
2118
|
+
sent (a thinking delta, a reasoning summary delta); answer text never stands in for it. The budget is its effort's or thinking
|
|
2119
|
+
level's (minimal 1,024, low 2,048, medium 8,192, high 16,384; on Anthropic's API, the `budget_tokens` it was sent with).
|
|
2120
|
+
A Claude model whose thinking is adaptive (pi-ai sends every current one `thinking: {type: "adaptive"}`, no budget) thinks
|
|
2121
|
+
within its output limit as it sees fit, so on pi it counts that limit less 1,024 tokens, as `claude-agent` counts
|
|
2122
|
+
`max_tokens`, and is sent the limit it is held at. With no effort or level given, on an API whose model then reasons at
|
|
2123
|
+
its own default (OpenAI's), it counts its whole output limit, the conservative side; with thinking off on Anthropic's
|
|
2124
|
+
API, none, unless the model thinks adaptively at any level (pi-ai's models with mid-conversation effort). On
|
|
2125
|
+
`claude-agent`, every request that thinks counts its budget, since Claude 4-class models stream only a summary of their
|
|
2126
|
+
thinking; thinking that streamed is subtracted, so a stop after a budget's worth of visible thinking counts nothing on
|
|
2127
|
+
top. The figure is an estimate: an effort's budget is not a limit the provider keeps, so a request can reason past it.
|
|
2128
|
+
It is bounded by the request's hold, and its real usage replaces it when that comes.
|
|
2129
|
+
|
|
2130
|
+
So on a model whose thinking is adaptive (every current Claude model, on pi and on `claude-agent`), a stopped request
|
|
2131
|
+
counts up to its hold: the provider is given no thinking budget, and what streamed says nothing of the thinking billed.
|
|
2132
|
+
That whole budget is the safe figure, kept on purpose: the stream reports the thinking billed only on its final
|
|
2133
|
+
`message_delta` (`usage.output_tokens_details.thinking_tokens`), which a stopped stream never receives, and the live
|
|
2134
|
+
`thinking_delta.estimated_tokens` is a display hint that can under-count. Under a cap with little left beside that hold,
|
|
2135
|
+
the request after the stop can be refused, and the run then pauses for a raise.
|
|
1564
2136
|
|
|
1565
2137
|
On pi the figure is written on the request's start mark (`agentrun.request_started`, its worst case) and on the end mark
|
|
1566
2138
|
of one stopped (`agentrun.request_ended`, what it counts at), as `heldUsd`; on `claude-agent` and `codex` on the
|
|
@@ -1568,7 +2140,8 @@ request's `runner.request` record (its worst case) and, for one stopped, on its
|
|
|
1568
2140
|
the same: a capped run stopped and sent another message, or opened again after its process died, goes on while its cap
|
|
1569
2141
|
allows. A cut request from a store written before serve kept the figure has none, and is a spend no one knows.
|
|
1570
2142
|
|
|
1571
|
-
A refusal says so in plain words, with the numbers, on
|
|
2143
|
+
A refusal says so in plain words, with the numbers, on its timeline row and on the run's `pending` (or, for a refusal
|
|
2144
|
+
no cap fixes, its error): "Not sent: this run's
|
|
1572
2145
|
cap of $0.01 can't cover one Claude Sonnet 5.5 request (at least $0.03). Raise the cap to at least $0.03 to run it.", and
|
|
1573
2146
|
once a run has spent: "Not sent: the run has spent $0.45 of its $0.50 cap, and its next Claude Sonnet 5.5 request needs at
|
|
1574
2147
|
least $0.03. Raise the cap to at least $0.48 to run it." The cap that would run it is what was spent, what requests still
|
|
@@ -1579,6 +2152,51 @@ refused was never sent: the run's usage counts no request for it, and a run whos
|
|
|
1579
2152
|
request sent". A reply the limit cut short says so on the run's timeline: "The reply stopped at 1,500 tokens: all that
|
|
1580
2153
|
the $0.15 left of the run's $0.50 cap could buy."
|
|
1581
2154
|
|
|
2155
|
+
### A run paused at its cap
|
|
2156
|
+
|
|
2157
|
+
A refusal for room (what is left of the cap cannot buy the next request's least) pauses the run instead of ending it: the
|
|
2158
|
+
refused request was not sent, so the cap holds, and a higher cap would send it. The run is `input_required` and
|
|
2159
|
+
`waiting`, `error` null, with `pending: {kind: "budget", cap_usd, spent_usd, needs_usd, suggested_cap_usd, said, at}`:
|
|
2160
|
+
its cap, what the cap counted as taken (spent, and held for requests still answering) and the least the refused request
|
|
2161
|
+
needs (a cap above their sum sends it), the raise it is offered, the refusal's words above, and when it came. The
|
|
2162
|
+
offered raise, `suggested_cap_usd`, is `spent_usd` + 10 × `needs_usd` rounded up to a whole dollar, and always above the
|
|
2163
|
+
cap, so a `PATCH` with it (below) resumes the run; it is absent with the other figures. The figures come from the refusal's own start mark, so a
|
|
2164
|
+
server started again says them too, shown as `cost.usd` is (to a millionth of a dollar), except `spent_usd` once the paused process is gone: the refusal counted requests
|
|
2165
|
+
still answering at what it held for them, so then it is the store's spend, when that is lower, and `suggested_cap_usd`
|
|
2166
|
+
follows it. The refusal's words (`said`) keep its own figures. Its timeline shows the refusal's row, then a waiting row: "Paused at the run's $0.05 cap: Not sent: …". The
|
|
2167
|
+
webhook's `run.needs_input` says `pending.kind: "budget"`. Its process is let go while it waits (SIGTERM: it drains and
|
|
2168
|
+
releases the run), so a paused run holds no place; a server started again reads it paused from its store. A paused
|
|
2169
|
+
process that does not let go within the drain timeout (`--drain-timeout`, 30 s by default) is killed, and the run ends
|
|
2170
|
+
`failed`, as any run whose process is killed does, unless its cap was raised meanwhile: it held nothing, so the raise's
|
|
2171
|
+
follow-up goes (below). A message to a
|
|
2172
|
+
paused run is `409 budget_reached`; a stop does nothing more, and a cancel ends it `cancelled`. Only a refusal for room
|
|
2173
|
+
pauses a run: one no cap fixes (above) ends it `failed`, as does a cost found past the cap after a response.
|
|
2174
|
+
|
|
2175
|
+
A paid tool call (monid's run, a search or a fetch through Parallel, browser time) that the cap refuses for room pauses
|
|
2176
|
+
the run the same way. The call is not sent, and its result says so in the cap's words. The model's next request is
|
|
2177
|
+
refused in those words, so the turn ends there and the model gets no turn to work around it. The run's `pending`
|
|
2178
|
+
holds what was taken (`spent_usd`), the call's hold as what it needs (`needs_usd`), and the raise it is offered. A
|
|
2179
|
+
raise sends the run on, and the model makes the call again if it still needs it: each call the model makes is one
|
|
2180
|
+
call, and nothing is retried for it. The refusal answers that turn's next request alone: a stop in between, then a
|
|
2181
|
+
message, starts a turn that is judged as any other. A paid call refused because what the run has spent is unknown
|
|
2182
|
+
still ends the run `failed`.
|
|
2183
|
+
|
|
2184
|
+
`PATCH /runs/{run_id}` with `{max_cost_usd}` raises the cap, and only raises it: the new cap is above the run's current
|
|
2185
|
+
cap, its last raise included, by more than a float's tail (1e-9; `422` otherwise, and for a run with no cap or a workflow
|
|
2186
|
+
run; `409 not_continuable` for an ended run). The same raise sent again (a retry), within that tail, changes nothing and
|
|
2187
|
+
answers as the first did. The run's serve.json keeps the raise before any answer, with each raise in `cap_raised`, so its
|
|
2188
|
+
next process opens under it, as does a server started again; a raise it could not keep is not taken (an error answers it),
|
|
2189
|
+
and the same raise again is taken anew. A run paused at its cap goes on: the answer is `{run_id, max_cost_usd, resumed: true,
|
|
2190
|
+
message_id, status, state}` at once, and the pause gets one follow-up turn, "The cap was raised to $2; continue the
|
|
2191
|
+
task.", under that `message_id`, which the server sends once the process being let go is gone, and which runs under the
|
|
2192
|
+
new cap. A second raise before it goes raises the cap it names and answers the same `message_id`. It is sent once: a
|
|
2193
|
+
server stopped before it went, or between starting its process and sending it, sends it when it starts again. One that
|
|
2194
|
+
cannot be sent is tried again (after 1 s, then 3 s); after 3 tries the run ends `failed`, saying the cap was raised but
|
|
2195
|
+
the run could not be sent on. The follow-up shows in the run's timeline as the server's, "AgentRun: The cap was raised…", never as the
|
|
2196
|
+
person's message (its submit names the server as its origin, `cap_raised`). A working run's
|
|
2197
|
+
live process keeps the cap it was opened with until its next one, and the answer's `note` says so. The raise is keyed to
|
|
2198
|
+
the refusal's own start mark, so a row shown after the refusal never reads the run paused again.
|
|
2199
|
+
|
|
1582
2200
|
A request carrying a native web search tool reads pages into its input that its body does not hold (the provider bills
|
|
1583
2201
|
them as input): under a cap its input bound is its body's plus an allowance. Claude's own search, an explicit `native`
|
|
1584
2202
|
pick, does not run under a cap: each search has a per-use fee the cap cannot reserve yet, so a capped claude-agent run
|
|
@@ -1611,8 +2229,8 @@ export default function reply(context, faux) {
|
|
|
1611
2229
|
```
|
|
1612
2230
|
|
|
1613
2231
|
`startServe({ faux, fauxBrowser, fauxWeb })` (the tests', not the CLI's) also names modules whose default exports give
|
|
1614
|
-
the `browser` tool's `{ provider, driver }` in place of Browserbase's (pi-browser's fake backend,
|
|
1615
|
-
`test/fixtures/faux-browser.mjs`), `web_fetch`'s direct fetch's `{ lookup, fetchImpl }` in place of the system's resolver and
|
|
2232
|
+
the `browser` tool's `{ provider, driver }` in place of Browserbase's or Kernel's (pi-browser's fake backend, told the
|
|
2233
|
+
vendor the run's plane names and the saved sign-in the run was handed: `test/fixtures/faux-browser.mjs`), `web_fetch`'s direct fetch's `{ lookup, fetchImpl }` in place of the system's resolver and
|
|
1616
2234
|
undici (a table of names and pages, `test/fixtures/faux-web.mjs`), and, as `fauxMonid`, the fetch the monid tools send
|
|
1617
2235
|
through in place of monid's API (`test/fixtures/faux-monid.mjs`). Each is honored only with `faux`.
|
|
1618
2236
|
|
|
@@ -1642,11 +2260,16 @@ carries no cost at all, as from a provider that does not price the model. The te
|
|
|
1642
2260
|
pipe.
|
|
1643
2261
|
- `web_fetch`'s direct fetch dials public addresses only, each hop checked and pinned (see [Tools](#tools)): a run cannot reach this
|
|
1644
2262
|
machine, its network or a cloud's metadata address through it.
|
|
1645
|
-
- A `browser` session runs at Browserbase, not on this machine: a page the model opens is reached from
|
|
1646
|
-
network, so what the model may reach there is the operator's choice of keys and project. Its downloads and uploads stay
|
|
1647
|
-
in the run's `work/`.
|
|
1648
|
-
|
|
1649
|
-
|
|
2263
|
+
- A `browser` session runs at Browserbase or Kernel, not on this machine: a page the model opens is reached from that
|
|
2264
|
+
vendor's network, so what the model may reach there is the operator's choice of vendor, keys and project. Its downloads and uploads stay
|
|
2265
|
+
in the run's `work/`. An agent's saved sign-in stays at the vendor; this server keeps a sealed pointer to it, which a
|
|
2266
|
+
run's process gets over its pipe and its tools and model never see. Anyone holding the vendor's key can open that
|
|
2267
|
+
context or profile there.
|
|
2268
|
+
- It binds 127.0.0.1 by default, and there refuses a request whose `Host` names something other than this machine
|
|
2269
|
+
(DNS rebinding): `localhost`, `127.0.0.1`, `[::1]`, the `AGENTRUN_PUBLIC_URL` name and each `--allow-host` name are
|
|
2270
|
+
served, on any port, so a tunnel (`ssh -L 8080:localhost:7340`) or a proxy in front works; any other name is `403`, a
|
|
2271
|
+
page in a browser and a JSON error for a script, each saying which names work. On another address (`--listen`, the
|
|
2272
|
+
container's `0.0.0.0`) it serves every `Host` name, and the token is its only lock.
|
|
1650
2273
|
It sends no CORS headers, so a page on another origin cannot read an answer.
|
|
1651
2274
|
- Every route but `GET /capabilities` needs `Authorization: Bearer <the token>`, compared in constant time, or the
|
|
1652
2275
|
browser's cookie under the rules of [the console](#the-console). The console's own files (its HTML, scripts, styles
|
|
@@ -1661,7 +2284,7 @@ carries no cost at all, as from a provider that does not price the model. The te
|
|
|
1661
2284
|
`SENTRY_DSN`, `DB_PWD`; never `PWD` or `OLDPWD`), whether the launcher's list names it or not. The rule is
|
|
1662
2285
|
pi-durable-disk's (`@parcha/pi-durable-disk/secret-name`), which an import's cut and a harness's log take too. The keys it
|
|
1663
2286
|
needs come over its pipe. It gets none of the boxes' keys ([Boxes](#boxes)). A tool key reaches it only when its
|
|
1664
|
-
revision names a tool the key unlocks (`MONID_API_KEY` a monid tool, `BROWSERBASE_API_KEY` `browser`; a workflow's
|
|
2287
|
+
revision names a tool the key unlocks (`MONID_API_KEY` a monid tool, `BROWSERBASE_API_KEY` and `KERNEL_API_KEY` `browser`; a workflow's
|
|
1665
2288
|
tools are those its model and call nodes name), and a model key only when its model needs it ([Models](#models)), read
|
|
1666
2289
|
from the revision at each launch, a relaunch or a resume after a restart included.
|
|
1667
2290
|
- A variable named like a key that is not on the launcher's list (`capabilities.secrets.names`) is left out of every
|