@parcha/agentrun-serve 0.1.0-beta.30 → 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 +50 -0
- package/README.md +182 -26
- package/dist/agents.d.ts +8 -3
- package/dist/agents.js +4 -1
- package/dist/app.js +23 -8
- package/dist/background.d.ts +2 -1
- package/dist/background.js +41 -20
- package/dist/box-egress-vm.d.ts +125 -0
- package/dist/box-egress-vm.js +350 -0
- package/dist/box-egress.d.ts +3 -2
- package/dist/box-relay-vm.d.ts +4 -0
- package/dist/box-relay-vm.js +76 -55
- package/dist/boxes.d.ts +7 -2
- package/dist/boxes.js +30 -11
- package/dist/cap.d.ts +2 -1
- package/dist/cap.js +2 -1
- package/dist/cli.js +30 -4
- package/dist/console/assets/{index-34jfpIbQ.js → index-CnJBf7Lc.js} +90 -85
- package/dist/console/index.html +1 -1
- package/dist/decisions.d.ts +3 -3
- package/dist/decisions.js +4 -3
- package/dist/files.d.ts +3 -0
- package/dist/files.js +3 -0
- package/dist/grade.d.ts +5 -2
- package/dist/grade.js +13 -5
- package/dist/harness-app.js +10 -1
- package/dist/host-check.d.ts +12 -0
- package/dist/host-check.js +34 -0
- package/dist/key-words.d.ts +37 -0
- package/dist/key-words.js +40 -0
- package/dist/learn/grade.d.ts +3 -0
- package/dist/learn/grade.js +3 -1
- package/dist/learn/index.d.ts +1 -1
- package/dist/learn/index.js +1 -1
- package/dist/learn/reflect.js +2 -0
- package/dist/learn/skills.d.ts +2 -0
- package/dist/learn/skills.js +16 -0
- package/dist/learning-routes.d.ts +30 -1
- package/dist/learning-routes.js +173 -19
- package/dist/learning-run.d.ts +1 -1
- package/dist/learning-run.js +25 -4
- package/dist/learning-words.d.ts +7 -3
- package/dist/learning-words.js +26 -8
- package/dist/learning.d.ts +9 -1
- package/dist/learning.js +57 -2
- 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 +26 -5
- package/dist/mcp-servers.js +53 -10
- package/dist/openapi.js +52 -9
- package/dist/page.d.ts +2 -0
- package/dist/page.js +3 -0
- package/dist/place.d.ts +3 -2
- package/dist/place.js +11 -3
- package/dist/print.d.ts +7 -0
- package/dist/print.js +13 -0
- package/dist/run-box.js +15 -5
- package/dist/runnable.d.ts +8 -1
- package/dist/runnable.js +51 -2
- package/dist/runs.d.ts +15 -8
- package/dist/runs.js +66 -13
- package/dist/secrets.d.ts +15 -0
- package/dist/secrets.js +20 -2
- package/dist/server.d.ts +10 -1
- package/dist/server.js +111 -29
- package/dist/tool-gate.d.ts +18 -3
- package/dist/tool-gate.js +44 -13
- package/dist/tool-keys.d.ts +2 -1
- package/dist/tool-keys.js +4 -8
- package/dist/tool-plane.d.ts +5 -1
- package/dist/tool-plane.js +30 -6
- package/dist/tools.js +8 -5
- package/dist/web-fetch.js +3 -3
- package/package.json +12 -16
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,56 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## 0.1.0-beta.31 (2026-11-06)
|
|
6
|
+
|
|
7
|
+
- `bash_background` takes `tty: true` to run its command on a terminal: `script -qfec` in the box gives it a pty, so a program that needs one (a prompt, a REPL, a progress display) works in the background.
|
|
8
|
+
- Paging, input and signals are the same calls. The log holds what the terminal shows, with input echoed and lines ending in `\r\n`. `bash_input` types into the terminal. `bash_signal` reaches the terminal's processes, and `INT` goes to its foreground job, as Ctrl-C does.
|
|
9
|
+
- A box with no `script` (util-linux) refuses `tty: true` in words and starts nothing. `bash_list` marks a terminal process `(tty)`.
|
|
10
|
+
- A terminal process is its terminal's session: a child its command leaves running on the terminal keeps it running, and signals and the run's end reach that child after `script` itself is gone.
|
|
11
|
+
- A browser charge now shows on the browser call's own row, not on a "Tool cost" row of its own. Before, every browser call added a row like "Tool cost: browserbase charged $0.0002 for browser", and the session's release added another, all for fractions of a cent that Usage already counts.
|
|
12
|
+
- **The call's row carries it.** The browser call's `tool_use` row has `usage: {"usd": 0.0017, "requests": 0}`: every charge booked under that call, summed. Once one of them has no price, it reads `{"usd": null, "requests": 0, "so_far_usd": ..., "unpriced": ...}`. A browser charge makes no row of its own.
|
|
13
|
+
- **A release lands on the last call.** The release's charge is booked under the session's last call, so it lands on that call's row. A charge that names no call (a session a reopened process released) goes to the last call charged for its session, else to its conversation's latest browser call.
|
|
14
|
+
- **Live, it is an update.** A charge booked after the answer is served on `/v2` as a change of that row, with the same `id` and the new `usage`. The live reducer re-emits the row.
|
|
15
|
+
- **Totals do not change.** The run's cost, its usage row ("... and 3 paid tool calls") and `/usage` count each charge once, as before. On a live run, `/usage` reads `browser_time` from these rows; for an ended run it reads the store, as before.
|
|
16
|
+
- **Other tools' charges are unchanged.** monid's and Parallel's web_search keep their own "Tool cost" row.
|
|
17
|
+
- **pi-durable-agent** exports `BROWSER_CHARGE` and `chargedTool(row)`. `chargedTool` names the tool whose charge a row carries. The text view shows a call's charge on its line ("Read the page "Example" · $0.0017").
|
|
18
|
+
- **OpenAPI** notes on `TimelineRow.usage` where it shows here. The shape stays the contract's `TimelineUsage`.
|
|
19
|
+
- `npx @parcha/agentrun` manages agents and runs from the terminal: `agents list|get|create|update`, `runs start|get|list|message|stop|cancel|raise-cap`, `triggers ...`, `usage`, `stats` and a command for every other operation the server's OpenAPI document offers, plus `api METHOD PATH [--header 'NAME: VALUE']` for any route. An operation the server turns off has no command, and neither has `learning approve`, which takes the owner's password session in the console and refuses every token. `npx @parcha/agentrun help` lists the commands and `<command> --help` gives a command's arguments. Path parameters are positional, each encoded whole (`learning read AGENT skills/find-policies/SKILL.md`) except a file's path, which keeps its slashes (`home read AGENT notes/a.md`); query parameters, header parameters (`--idempotency-key`, `--if-match`) and a JSON body's top-level scalar fields are flags (`--max-cost-usd 2`); `--body JSON|@FILE|-` gives the whole body, its fields under the flags, and `--body-type TYPE` sends a body of another type the route takes as it is (`files create --path notes.txt --body @notes.txt --body-type text/plain`). A JSON body with no flags goes byte for byte. The response's JSON goes to stdout (indented on a terminal), a file's bytes exactly as the server sent them, and an error's JSON to stderr; exit codes are 0 ok, 1 the server refused, 2 bad usage, 3 the server cannot be reached, 4 no token or the token refused. A command whose body carries a secret (`tool-keys save`, `mcp-servers save|preview`, and `api` on any path that leads to one) takes its body only from stdin or a file.
|
|
20
|
+
The server and token come from `--base-url`, else `AGENTRUN_BASE_URL` and `AGENTRUN_API_KEY`, else `base_url` and `api_key` in `$XDG_CONFIG_HOME/agentrun/config.json`, else the server started on this machine with the same `--data` (default `~/.agentrun`). The token is never a flag and never printed, a key that is not a valid header value is refused before any request, and the local server's token goes to that server only. The local token is read from `DIR/.token` alone, and the config file, `DIR/.server.json` and `DIR/.token` are used only when they are regular files of the user's own with no group or other permission (exit 4 otherwise). `api` refuses a PATH with a `.` or `..` segment, plain or encoded, or an empty one. A reader that closes stdout early (`| head`) ends the command quietly. With no positional argument the command still starts the server, and `import` and `reset-password` are still the server's.
|
|
21
|
+
`agentrun-serve` writes `DIR/.server.json` (`{base_url, pid, token_file}`, mode 0600, never the token; `token_file` is absent when the token came from `AGENTRUN_TOKEN`) once it listens and removes it on a clean exit; a file whose server is gone is reported as such, exit 3. The command table is generated from the server's document by `node scripts/generate-clients.mjs`, with names in `scripts/clients/resources.json`; its header hashes only what the table is made of, and `--check` fails when the committed table differs.
|
|
22
|
+
- The Docker box is on by default. A server started with `AGENTRUN_BOXES` not set at all (a plain `npx @parcha/agentrun`) probes Docker at its start, as if `docker` were listed, and offers it when Docker answers, so a new agent lands in the Docker box with a shell. Where Docker does not answer, new agents run on the runner, and the banner (`Boxes: none, so new agents run on the runner. Docker isn't running on this machine (no docker command on PATH): install or start Docker, then restart AgentRun.`), `capabilities.places.default_reason`, docker's `reason` and the console's new-agent form say why. With Docker on, the banner says `Boxes: docker (on by default; set AGENTRUN_BOXES to change).`
|
|
23
|
+
An `AGENTRUN_BOXES` you set still wins: a list probes only what it names, and an empty value or `none` sets up no box (`none` stands alone). Daytona, the VM box and bwrap stay yours to list. Docker's reasons say what is wrong in plain words first (`Docker isn't running on this machine`), then what to do.
|
|
24
|
+
The box image's first build is said in the terminal as it starts (`Preparing the Docker box image (first start only, a few minutes); agents can be made now, and their first run waits for it.`) and as it ends (`The Docker box image is ready.`). `npx @parcha/agentrun` now prints the `Boxes:` line and these two on stderr, after its `AgentRun is running at` line, so stdout stays that one line.
|
|
25
|
+
`@parcha/pi-transport`, where the boxes' providers live, is now a dependency of `@parcha/agentrun-serve` rather than an optional peer, so a plain install (`npx @parcha/agentrun` included) has the Docker box.
|
|
26
|
+
- Each note, skill and workflow draft in the agent's learning view says its last change, `last_change: {kind, by, at}`: `approved`, `edited`, `created`, `retired` or `restored` by a `person`, or `learned` by a `run`, from the newest commit on its file. A retired note, skill or workflow draft can be read and brought back. The agent's learning view says of each retired one when and by whom it was retired (`retired: {at, by}`, `by` a `person` or a `run`), and its file's GET serves its whole text. `POST /v2/agents/{id}/learning/files/{file}/restore` makes it active again for the next run, in one commit on main, its owner's password session alone as an approval is; a draft is restored by its README.md. A restore checks the text again as a new note or skill is (a secret's shape, the host's own values, a hidden character, its format), and every file of a skill's or a draft's folder, so a value a retire took out of every run never comes back through it. A restored note marks the notes it supersedes, as an approval does, and an item that waited for its owner's OK before its retire is recorded as their approval (`Approved-Via: console`). `retired.at` is the time of the item's retire, which an edit since moves not.
|
|
27
|
+
- On a Mac whose Docker runs in a VM (Docker Desktop, OrbStack or colima), a Docker box reaches the server's host list too, through one proxy container inside the VM. Linux keeps its own path, unchanged.
|
|
28
|
+
- The server runs the kernel's egress proxy in one container per server, `agentrun-egress-<12 hex>`, labelled `agentrun.egress`: `node:22-bookworm-slim` pinned by digest, the proxy's code bound read-only from the data root, the list as its one variable, a read-only root, no capability, the server's uid:gid. It listens on a Unix socket in a tmpfs volume owned by the server's uid, which the box mounts read-only at `/run/agentrun/egress/`. The box keeps `--network none`; the proxy container is the only container with a network, and it publishes no port.
|
|
29
|
+
- It turns on only when `docker info` names a VM runtime the server knows (`Docker Desktop`, `OrbStack`, or a colima host name), on a kernel that is not the Mac's. Anything else stays offline, with `network_reason` saying what was seen.
|
|
30
|
+
- At start the server sweeps the containers of its own label, pulls the image once if needed, starts the proxy and waits up to 10 s for it; until it is ready, or if it never is, the box's network is `none` with why. Docker restarts a proxy that dies, the server starts one that is gone again, and the server's stop removes it.
|
|
31
|
+
- pi-transport's `dockerBoxes` takes `volumes: [{ name, target, readOnly }]`, named volumes every box mounts with `--mount type=volume`.
|
|
32
|
+
- An agent that learns says how many of its learned items wait for its owner's OK: `GET /v2/agents` and `GET /v2/agents/{agent_id}` carry `learning: { pending }` (notes, skills and workflow drafts held with `status: pending` on its learning folder's main), read once per commit of main, never per list call. Absent for an agent that does not learn, and on a server whose learning is off.
|
|
33
|
+
- MCP tools pass the run's one tool gate and its one spend cap. Each call enters the gate as `mcp:<server>/<tool>` (`mcp:<server>/*` sets all of a server's tools): a denied call is refused and nothing is sent; one set to ask, the default for MCP tools, parks and ends the turn on pi and claude-agent alike, and the owner's allow runs it once and resumes the run with its result. `PUT /v2/settings/mcp-servers/{name}` takes `prices` (USD a call, per listed tool): a priced call is held at its price under `max_cost_usd`, refused unsent when the cap cannot take it, and booked as the run's tool cost; an unpriced call runs "not metered", a timeline row and the usage row's `not_metered`, and `GET /usage`'s `tools` line counts them (`not_metered_calls`).
|
|
34
|
+
- A known MCP meta tool, one that runs other actions by name (Composio's `COMPOSIO_MULTI_EXECUTE_TOOL` and workbench, Klavis Strata's `execute_action`, Zapier's execute and `write_code_action`, Arcade's `UseTool`, Docker's `mcp-exec` and code mode, Cloudflare's `portal_execute` and code mode), is not grantable: a grant of it can't name the real action. A server's tools read it `grantable: false` with the reason, a save that grants it is `422`, and a run that pinned one is refused at its launch. Upgrading: an agent that grants one must grant the server's direct tools instead.
|
|
35
|
+
- Agents call a saved MCP server's tools on pi and claude-agent: grant `mcp:<server>/<tool>` in `definition.tools`. A save checks the name against the server's saved tools (`422` naming them). A run's first launch pins the granted tools as saved and the server's URL; its credential reaches only runs that grant one of its tools, over the run's secrets pipe. pi binds each tool in the run's process; claude-agent's own MCP client calls it at the session's model proxy (`/mcp/<server>`, behind the session key), so the CLI never holds the credential. A call follows no redirect, a crash-cut call is answered interrupted and never sent again, a moved server is sent nothing, and the timeline reads `<server> · <tool>`. `features.mcp_client.harnesses` lists the harnesses that run them. Every call passes the run's tool gate and its spend cap.
|
|
36
|
+
- **Under `bash: ask`, only the background calls that start or feed a process ask: `bash_output`, `bash_list` and `bash_signal` run unasked**
|
|
37
|
+
- With `bash` set to `ask`, `bash_background` and `bash_input` (and `bash`) still park the run for the owner's approval, each under its own name. `bash_output`, `bash_list` and `bash_signal` now run without asking, so watching one approved process no longer costs an approval per page. They reach only the processes the run itself started, by its own ids: another run's id, or one never started, is answered "there is no background process <id> in this run".
|
|
38
|
+
- `bash: deny` still refuses all five, and `bash: allow` runs them. None is a settings key of its own, so no setting of one lifts `bash`'s.
|
|
39
|
+
- `capabilities.tools` and `GET /v2/agents/{id}`'s `tools` show the split: under `bash: ask`, the three watchers read `allow`, with `permission_from` where `bash`'s setting came from.
|
|
40
|
+
- On a server with accounts off, the three watchers run under `bash: ask`, where an asked call is refused.
|
|
41
|
+
- Only an `ask` set as written lets them run unasked. Where `bash` asks as a stand-in (its setting is a value not offered, or the settings file never read), they ask too. An agent's own setting that is no permission at all now reads `ask` in `capabilities` and its tools, as it already did at the gate, never the value as written.
|
|
42
|
+
- That stand-in survives a save: `PUT /v2/settings/tools` with the map as `GET` served it (as the console saves every change) keeps it a stand-in and leaves the value as written in `tool-settings.json`, so neither the save nor a restart lets the watchers run unasked. The same `ask` sent again counts as no choice, since on the wire it can't be told from the stand-in; a different permission is a choice and is written as given.
|
|
43
|
+
- A model granted both web_fetch and the browser is now told which one has cookies. Asked to "Open https://httpbin.org/cookies", a pi run picked web_fetch, which has no cookies, and answered with an empty page; it picked the browser only when told to. The tool descriptions the model reads now say:
|
|
44
|
+
- **web_fetch** has no cookies, sign-ins or session: it reads one page cold, so a page behind a sign-in, or one that depends on an earlier page, needs the browser tool, where this run has it. That holds for serve's web_fetch on every harness and for pi-browser's.
|
|
45
|
+
- **The browser's `run`** keeps this agent's saved sign-ins and cookies, for anything behind a sign-in or a page that depends on an earlier one. It says this only on a run that has a saved sign-in: in serve, a run handed its agent's sign-in; in pi-browser, a host that passes `signIns: true` or a session vault. Without one it says only that the browser keeps cookies across pages, which stays true for a local Chrome, which keeps no saved sign-in.
|
|
46
|
+
- **pi-browser** adds `browserToolsFor(signIns)` (the browser's contracts with `run`'s words for that plane), `BROWSER_KEEPS` (the two sentences), and the durable extension's `signIns` option.
|
|
47
|
+
- A trigger's message never reaches a run parked on a tool call's approval. The door's `POST /submit` with `answers: false` takes `parks` (entry kinds): it is refused with `409 WAITING`, by pi's root and by a door hook alike, while a call waits in a park of one of those kinds (an entry `{phase: "requested", id}` with no `{phase: "resolved", id}` after it). Serve sends its tool gate's park with each message a trigger sends, so a run that comes to wait on an approval just before the message reaches its door has the firing skipped ("The run is waiting on a person."), instead of taking the message, or being retried every 5 s as busy, and the approval stays pending. The park is read in one transaction (a hook's in the commit that admits the input), and only for a new admission: a requestId the door already took answers its record, so a retry of a delivered message settles sent.
|
|
48
|
+
- The `learned_workflow` tool shows each workflow's input as its schema says it, on a line under the workflow: its fields, their types, which are required (`*`) and a short description of each, so a call gives the input the workflow takes the first time. The line counts in the tool's description budget. A learned workflow draft whose output names no `path` is refused when it is kept and before a call runs any node: a learned workflow answers the value at `output.path`.
|
|
49
|
+
- A run that learns no longer keeps what the server tells it about learning, in a note or a skill, or a note beside a skill it keeps, which a grader could judge as planted and so drop the skill with it. A person's own instruction about learning is still theirs to keep. The run says it will keep what the person asked at the start of its reply, never after a sign-off they asked it to end with. When the grader keeps nothing, the run's learning names first the skill and the workflow draft it proposed, cut of the server's secrets each time it is read. A grader's answer the server cannot read is asked once more; when the second can't be read either, the run's learning is dropped and keeps that answer on the run's file, cut of the server's secrets and then to 2,000 characters, and no read serves it. Upgrading: nothing to do.
|
|
50
|
+
- A server on 127.0.0.1 answers `localhost`, `127.0.0.1` and `[::1]` on any port, so `ssh -L 8080:localhost:7340`, a proxy in front, or a start that took the next free port reach it. Before, the `Host` had to carry the server's own port, and anything else got `403 unexpected Host header`. The `AGENTRUN_PUBLIC_URL` name and each `--allow-host` name are served the same way, with or without a port, so an HTTPS proxy on the same machine that passes its own `Host` (Caddy's default) works. Every other name is still refused (the guard against DNS rebinding). A browser now gets a page that says which names work and how to add one; a script gets the same in the error's message.
|
|
51
|
+
- A key a tool needs and this server doesn't hold is named where a person fixes it, Settings first: "The tool monid.discover needs a Monid key: save one in Settings → Tool keys (or set MONID_API_KEY where the server starts)." It used to say only that the server's environment did not set MONID_API_KEY, which sent a person who had saved and removed the key in Settings to the wrong place. The same words cover every key Settings saves (Parallel, Monid, Browserbase, Kernel, TypeSafe (Jev), and the model keys): the save's warning, the run's 409, the tools view, capabilities' `reason` and `why` (a vendor picked without its key included), web_fetch's and web_search's answers, and a workflow's decision providers. A variable no key saves (AGENT_MODEL_API_KEY with AGENT_MODEL_BASE_URL) still names only where the server starts. The structured fields (`missing`, `host`) and the plane's stored values are unchanged.
|
|
52
|
+
- A VM box program whose start was still waiting on the provider when its run ended is now let go as soon as it starts. The server no longer reads its output or keeps it for ten minutes, and the run's process gets a 410 saying the run ended while the program started.
|
|
53
|
+
- The VM box tests' fake never reuses a sandbox id or directory within a process, so a server one test left still finishing its runs' ends cannot reach the next test's sandbox. The cancel test also checks that the turn's end copied the box's file back before it cancels, which shows which copy back is missing if it fails again.
|
|
54
|
+
|
|
5
55
|
## 0.1.0-beta.30 (2026-11-05)
|
|
6
56
|
|
|
7
57
|
- An agent can carry a default spend cap. A definition's `max_cost_usd` (agentic only) above 0 sets the agent's default, kept with its revision, as `maxCostUsd` on the agent store's agentic body, and read back in `GET /v2/agents/{agent_id}`; a run started with no `max_cost_usd` of its own takes its revision's default, and a run's own cap wins. An edit that leaves the field out keeps the agent's default, so leaving a field out never removes a spend limit, and only `max_cost_usd: 0` clears it (no default; through MCP's agents_revise too, where null is refused). A workflow definition with one above 0 is `422 not_allowed`, since a workflow run's spend is not capped here; 0 changes nothing there. A trigger's `start_run` target may now leave out `max_cost_usd` when its agent has a default: each firing takes the default as it stands when it starts, a target with neither is `422`, and a firing that finds neither fails rather than start an uncapped run.
|
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,15 +85,15 @@ 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,
|
|
90
97
|
github.com, and codeload.github.com.` (on Linux; elsewhere it says why the box has no
|
|
91
98
|
network: [Sandbox](#sandbox)). The first start builds [the box's image](#the-boxs-image) (python 3.12, git, curl, node, npm and rg,
|
|
92
99
|
about 300 MB, a minute or two, the build alone on the network): its banner then says `Boxes: docker is preparing
|
|
@@ -116,7 +123,7 @@ cat > box.mjs <<'JS'
|
|
|
116
123
|
export default (context, faux) => context.messages.some((m) => m.role === "toolResult") ? faux.message("Saved out.txt.")
|
|
117
124
|
: faux.message(faux.toolCall("bash", { command: "cat /etc/os-release | tee out.txt" }), { stopReason: "toolUse" });
|
|
118
125
|
JS
|
|
119
|
-
|
|
126
|
+
node packages/serve/dist/cli.js --faux box.mjs
|
|
120
127
|
```
|
|
121
128
|
|
|
122
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
|
|
@@ -285,7 +292,8 @@ workflow is never given a box.
|
|
|
285
292
|
|
|
286
293
|
`capabilities.places` says both sides. `default_place` is the place a new agent gets here. When that is the runner,
|
|
287
294
|
`default_reason` says why in docker's own words, such as `new agents run on the runner, because the docker box is
|
|
288
|
-
unavailable here:
|
|
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`,
|
|
289
297
|
because it means where a revision that names no place runs. An agent saved with no place (before this, where docker was
|
|
290
298
|
unavailable, or a workflow) keeps running on the runner, whatever the server has now. The default is never worked out
|
|
291
299
|
again at run time. The console's new-agent form starts on `default_place`, with bash ticked when that place is a sandbox.
|
|
@@ -309,7 +317,8 @@ A definition naming a box this server does not have saves with a warning on `def
|
|
|
309
317
|
|
|
310
318
|
### A run in a Docker box
|
|
311
319
|
|
|
312
|
-
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
|
|
313
322
|
`{"mode": "sandbox", "box": "docker"}` gets one container, made on its first `bash` call (a run with none gets no
|
|
314
323
|
container). Those four tools are pi's own, on every harness. `bash` runs in the container. `read`, `write` and `edit`
|
|
315
324
|
run on this server, on the `work/` the container binds, because a `docker exec` costs half a second or more per call:
|
|
@@ -362,6 +371,42 @@ go through `work/` by path.
|
|
|
362
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
|
|
363
372
|
proxy yet`. At each start the server removes the proxy directories of runs that are gone (a socket that refuses a
|
|
364
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.
|
|
365
410
|
- Capabilities give the list as `places.allow`, and each box's `network`: `allowlist` or `none`, with
|
|
366
411
|
`network_reason` when an available box has none. An image with no `socat` gets no network, and the run's timeline
|
|
367
412
|
says so once.
|
|
@@ -399,7 +444,21 @@ go through `work/` by path.
|
|
|
399
444
|
An agent whose place is a sandbox may also name `bash_background`, `bash_output`, `bash_input`, `bash_signal` and
|
|
400
445
|
`bash_list`, to run a command that outlives one call: a dev server, a watcher, a long build, a program that reads its
|
|
401
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
|
|
402
|
-
`bash` runs on,
|
|
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.
|
|
403
462
|
|
|
404
463
|
- `bash_background {command}` starts the command from `work/`, in a fresh shell (`bash`, else `sh`) under a session of
|
|
405
464
|
its own (`setsid`, its runner under `nohup`), and answers its id (`"1"`, then `"2"`, and on) at once. Its stdout and
|
|
@@ -420,6 +479,15 @@ input as it goes. Each call is one short command in the run's box, on the same p
|
|
|
420
479
|
exit code is the shell's.
|
|
421
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
|
|
422
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)`.
|
|
423
491
|
- `bash_output {id, offset?, max_bytes?}` reads the log from a byte offset (0 when absent), at most 48 KiB a call (the
|
|
424
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,
|
|
425
493
|
and the offset to read from next. Once it says the process ended, the log is whole.
|
|
@@ -553,7 +621,7 @@ never runs; the box's first process is a `sleep` of its lifetime.
|
|
|
553
621
|
### In the published image
|
|
554
622
|
|
|
555
623
|
The published image, `ghcr.io/parcha-ai/agentrun-server`, cannot host boxes yet. It has no `docker` command and no
|
|
556
|
-
Docker daemon, so
|
|
624
|
+
Docker daemon, so capabilities and the start's `event=boxes` line say docker is
|
|
557
625
|
unavailable, and a sandbox agent's runs are `409 agent_not_runnable`. Runner agents work as before. Do not mount the
|
|
558
626
|
host's Docker socket into the container to get around it: whatever can reach that socket is root on the host, and a
|
|
559
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
|
|
@@ -563,18 +631,29 @@ inside the image itself (bwrap, on Linux) comes in a later release.
|
|
|
563
631
|
### Boxes
|
|
564
632
|
|
|
565
633
|
A box is a machine apart from this one where a run's tools run. Runs execute in `docker`, `daytona` and `modal` boxes
|
|
566
|
-
([place](#place)); the others are set up and probed, and say runs in them are not available yet.
|
|
567
|
-
|
|
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
|
|
568
645
|
refuses the start. At start the server probes each listed box once. The probes run at once, each within 5 s. Then one
|
|
569
646
|
log line says what the server found:
|
|
570
647
|
|
|
571
648
|
event=boxes available=<ids or none> unavailable=<ids> <id>="<why>" ...
|
|
572
649
|
|
|
573
650
|
The line gives a reason for each listed box that is unavailable, and the banner says the same in words
|
|
574
|
-
(`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
|
|
575
653
|
does not name says `not enabled on this server: start AgentRun with AGENTRUN_BOXES=docker` (keeping the boxes it already
|
|
576
|
-
lists),
|
|
577
|
-
|
|
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
|
|
578
657
|
provider's answer.
|
|
579
658
|
|
|
580
659
|
- `docker`: the `docker` command on PATH, with a daemon that answers `docker version` for this server's user. It needs no key.
|
|
@@ -599,7 +678,8 @@ provider's answer.
|
|
|
599
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).
|
|
600
679
|
- `bwrap` is not in this release yet.
|
|
601
680
|
|
|
602
|
-
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.
|
|
603
683
|
The keys belong to the server alone. The launcher hands them over with the server's other secrets, and no run's process
|
|
604
684
|
gets them, in its environment or on its pipe.
|
|
605
685
|
|
|
@@ -683,7 +763,7 @@ agent_not_runnable`, with `details.unbound` and `details.missing`).
|
|
|
683
763
|
| `write` | Write a file in the run's `work/` | nothing | yes, no |
|
|
684
764
|
| `edit` | Edit a file in the run's `work/` | nothing | yes, no |
|
|
685
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 |
|
|
686
|
-
| `bash_background` | Start a shell command in the background in the run's box, from its `work/`, and answer its id at once: `{command}` in. 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 |
|
|
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 |
|
|
687
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 |
|
|
688
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 |
|
|
689
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 |
|
|
@@ -894,9 +974,12 @@ the sessions it still holds are released at their vendor. An agent's browser sta
|
|
|
894
974
|
([saved sign-ins](#saved-sign-ins)).
|
|
895
975
|
|
|
896
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
|
|
897
|
-
last charge, and the release books the rest, topped up to the provider's minimum. Each is
|
|
898
|
-
|
|
899
|
-
|
|
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):
|
|
900
983
|
|
|
901
984
|
| Provider | List price | Minimum | Its own price |
|
|
902
985
|
| --- | --- | --- | --- |
|
|
@@ -1058,8 +1141,8 @@ not known, so not cut, and the import says so.
|
|
|
1058
1141
|
|
|
1059
1142
|
## MCP servers
|
|
1060
1143
|
|
|
1061
|
-
Add a remote MCP server once, with its credential, and see its tools before you keep it.
|
|
1062
|
-
|
|
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)).
|
|
1063
1146
|
|
|
1064
1147
|
```sh
|
|
1065
1148
|
curl -X POST "$BASE/v2/settings/mcp-servers/preview" -H "authorization: Bearer $TOKEN" -H 'content-type: application/json' \
|
|
@@ -1113,6 +1196,66 @@ says `transports: ["streamable-http"]`, the `auth` types and `at_rest` (`sealed`
|
|
|
1113
1196
|
answers `{url, log, tools, close}`; it serves `add`, `slow_write`, `delete_thing` and `paid`, and logs each request's
|
|
1114
1197
|
method, tool and whether an `Authorization` header came, never its value.
|
|
1115
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
|
+
|
|
1116
1259
|
## Webhooks
|
|
1117
1260
|
|
|
1118
1261
|
One URL hears of your runs without anyone watching the page. `PUT /v2/settings/webhook` with `{url}` sets it: an `http`
|
|
@@ -1856,6 +1999,16 @@ with the token, an archived agent's too:
|
|
|
1856
1999
|
`learning: <edited, created or retired> by a person: <file>` with a `Changed-By: user` trailer, with `MEMORY.md`
|
|
1857
2000
|
rebuilt, `main` moved only from the commit it was made on, and the folder's files brought in line; it answers the
|
|
1858
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).
|
|
1859
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
|
|
1860
2013
|
each new note, `{file, keep, question, why}`, `question` the rubric's question a dropped note failed, the checker's
|
|
1861
2014
|
problems, what the grade cost), `null` for a run that does not learn; `verdict` is `null` until a grade ran.
|
|
@@ -1875,7 +2028,7 @@ followed: a read or a write there answers `500`, and nothing is written.
|
|
|
1875
2028
|
|
|
1876
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.
|
|
1877
2030
|
|
|
1878
|
-
`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
|
|
1879
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
|
|
1880
2033
|
carry), a run's door token, and a token sent beside the session. So is every request on a server with accounts off
|
|
1881
2034
|
(`AGENTRUN_ACCOUNTS=0`), whose page cookie any token holder can mint. With no credential it is 401, as every route.
|
|
@@ -2112,8 +2265,11 @@ carries no cost at all, as from a provider that does not price the model. The te
|
|
|
2112
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
|
|
2113
2266
|
run's process gets over its pipe and its tools and model never see. Anyone holding the vendor's key can open that
|
|
2114
2267
|
context or profile there.
|
|
2115
|
-
- It binds 127.0.0.1 by default, and there refuses a request whose `Host`
|
|
2116
|
-
|
|
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.
|
|
2117
2273
|
It sends no CORS headers, so a page on another origin cannot read an answer.
|
|
2118
2274
|
- Every route but `GET /capabilities` needs `Authorization: Bearer <the token>`, compared in constant time, or the
|
|
2119
2275
|
browser's cookie under the rules of [the console](#the-console). The console's own files (its HTML, scripts, styles
|
package/dist/agents.d.ts
CHANGED
|
@@ -92,7 +92,14 @@ export declare const etagOf: (entry: AgentEntry) => string;
|
|
|
92
92
|
/** A revision as a definition, as `POST /agents` takes one, numbered. */
|
|
93
93
|
export declare function definitionOf(agent: Agent, revision: Revision, version: number): Json;
|
|
94
94
|
/** `Agent` as the contract shows it, with its current revision and its saved sign-ins (sign-ins.ts view: never a ref). */
|
|
95
|
-
export declare function agentView(entry: AgentEntry, signIns?: readonly SignInView[]
|
|
95
|
+
export declare function agentView(entry: AgentEntry, signIns?: readonly SignInView[], learning?: {
|
|
96
|
+
pending: number;
|
|
97
|
+
}): {
|
|
98
|
+
created_at: string;
|
|
99
|
+
updated_at: string;
|
|
100
|
+
learning?: {
|
|
101
|
+
pending: number;
|
|
102
|
+
} | undefined;
|
|
96
103
|
agent_id: string;
|
|
97
104
|
definition: Json | null;
|
|
98
105
|
kind: "workflow" | "agentic" | null;
|
|
@@ -112,8 +119,6 @@ export declare function agentView(entry: AgentEntry, signIns?: readonly SignInVi
|
|
|
112
119
|
region: string;
|
|
113
120
|
home_etag: string;
|
|
114
121
|
archived_at: string | null;
|
|
115
|
-
created_at: string;
|
|
116
|
-
updated_at: string;
|
|
117
122
|
};
|
|
118
123
|
/** One revision as `GET .../revisions` lists it. */
|
|
119
124
|
export declare function revisionView(agent: Agent, row: RevisionRow & {
|
package/dist/agents.js
CHANGED
|
@@ -283,7 +283,7 @@ export function definitionOf(agent, revision, version) {
|
|
|
283
283
|
return { id: agent.id, version, name: agent.name, ...(agent.description !== undefined ? { description: agent.description } : {}), ...body, harness: harnessOfBody(revision.body), ...(revision.body.place ? { place: revision.body.place } : {}), skills: skillNames(Object.keys(revision.body.skills)), tools: revision.body.tools, ...(revision.body.toolSettings ? { tool_settings: revision.body.toolSettings } : {}) };
|
|
284
284
|
}
|
|
285
285
|
/** `Agent` as the contract shows it, with its current revision and its saved sign-ins (sign-ins.ts view: never a ref). */
|
|
286
|
-
export function agentView(entry, signIns = []) {
|
|
286
|
+
export function agentView(entry, signIns = [], learning) {
|
|
287
287
|
const { agent, revision } = entry;
|
|
288
288
|
return {
|
|
289
289
|
agent_id: agent.id,
|
|
@@ -298,6 +298,9 @@ export function agentView(entry, signIns = []) {
|
|
|
298
298
|
region: "local",
|
|
299
299
|
home_etag: etagOf(entry),
|
|
300
300
|
archived_at: agent.archivedAt ?? null,
|
|
301
|
+
// How many of its learned items wait for its owner's OK (learning-routes.ts pendingCount): only for an agent that
|
|
302
|
+
// learns on a server whose learning is on.
|
|
303
|
+
...(learning ? { learning } : {}),
|
|
301
304
|
created_at: agent.createdAt,
|
|
302
305
|
updated_at: revision && revision.createdAt > agent.createdAt ? revision.createdAt : agent.createdAt,
|
|
303
306
|
};
|
package/dist/app.js
CHANGED
|
@@ -8,11 +8,11 @@
|
|
|
8
8
|
// workflow ends the app writes the run's final status, with the outcome, and releases the run. The server carries
|
|
9
9
|
// it back once this process has exited: this process holds the run's store until then.
|
|
10
10
|
// First: the secrets serve hands this process over a pipe, read and the pipe closed before anything else runs.
|
|
11
|
-
import { authContextOf, withSecrets } from "./secrets.js";
|
|
11
|
+
import { authContextOf, mcpCredentials, withSecrets } from "./secrets.js";
|
|
12
12
|
import { mkdir } from "node:fs/promises";
|
|
13
13
|
import { BACKGROUND_CONTEXT as BACKGROUND } from "@earendil-works/chord/context";
|
|
14
14
|
import { basename, join, resolve } from "node:path";
|
|
15
|
-
import { createRegistry, ROOT_CONVERSATION_ID } from "@earendil-works/pi-durable";
|
|
15
|
+
import { createRegistry, defineExtension, ROOT_CONVERSATION_ID } from "@earendil-works/pi-durable";
|
|
16
16
|
import { openStoreReader, RUN_STORE_FILE } from "@parcha/pi-durable-agent";
|
|
17
17
|
import { RUN_RESUMED } from "@parcha/pi-durable-agent/timeline";
|
|
18
18
|
import { settleIn } from "./paid-calls.js";
|
|
@@ -24,9 +24,9 @@ import { FOLLOW_UP_OPEN_ENV, readJson, RUN_META } from "./files.js";
|
|
|
24
24
|
import { adapterFor, claudeModel, claudePriceModel, claudeSkillCheck, codexModel, learnedRoute, learnedWorkflowsOff, openRouterOnly, thinkingFor } from "./adapters.js";
|
|
25
25
|
import { DEFAULT_HARNESS, FAUX_HARNESS_ENV } from "./harness.js";
|
|
26
26
|
import { adapterRun } from "./harness-app.js";
|
|
27
|
+
import { MCP_PIN, mcpGateway, mcpNameOf, mcpRegistrations } from "./mcp-gateway.js";
|
|
27
28
|
import { pinnedWorkflows, readPin, withLearned } from "./learning.js";
|
|
28
29
|
import { LEARNED_WORKFLOW_TOOL, learnedWorkflowTool } from "./learned-workflow.js";
|
|
29
|
-
import { defineExtension } from "@earendil-works/pi-durable";
|
|
30
30
|
import { completer } from "./llm.js";
|
|
31
31
|
import { searchOn } from "./hosted-search.js";
|
|
32
32
|
import { imageLoader } from "./pdf-pages.js";
|
|
@@ -137,6 +137,13 @@ export default async function app(where) {
|
|
|
137
137
|
// registry composes each agent's, another harness's host tools in their call. An approved call runs on this coding
|
|
138
138
|
// source, as the run's own would.
|
|
139
139
|
const toolGate = runGate(where, run.id, revision);
|
|
140
|
+
// Its remote MCP servers, as its first launch pinned them, with the credentials this launch handed it (mcp-gateway.ts).
|
|
141
|
+
const pinned = (await readJson(join(where.root, MCP_PIN)));
|
|
142
|
+
// Its records (a held ask, a priced call's mark and charge, an unpriced call's "not metered") go on the run's root, once
|
|
143
|
+
// the run is open.
|
|
144
|
+
let runHarness;
|
|
145
|
+
const commit = () => runHarness && ((change) => runHarness.commit(change, BACKGROUND));
|
|
146
|
+
const gateway = pinned && Object.keys(pinned).length ? mcpGateway({ pin: pinned, credentials: mcpCredentials(), work: () => where.work, commit, gate: toolGate }) : undefined;
|
|
140
147
|
const registry = createRegistry();
|
|
141
148
|
// An agentic run's system prompt starts with the date and the workspace (environment.ts). On pi it is a section,
|
|
142
149
|
// installed first so it comes before every other extension's and the instructions.
|
|
@@ -176,9 +183,10 @@ export default async function app(where) {
|
|
|
176
183
|
const { system: instructions, native } = await systemOf(learned.instructions, learned.skills, where.work, check, { onDemand: readsFiles(revision.body.tools) });
|
|
177
184
|
// The session's system prompt starts with the line, made as this process opens it: a run resumed on a later day is
|
|
178
185
|
// opened with that day.
|
|
179
|
-
const spec = { key: `run:${run.id}`, label: run.agent, system: [environmentLine(), instructions, guidance].filter((text) => Boolean(text)), context: "fresh", thinking: thinkingFor(harness, thinkingLevel) };
|
|
180
|
-
// ask_person stays pi's (runnable.ts refuses a run that names it here); the file tools are pi's own
|
|
181
|
-
|
|
186
|
+
const spec = { key: `run:${run.id}`, label: run.agent, system: [environmentLine(), instructions, guidance].filter((text) => Boolean(text)), context: "fresh", thinking: thinkingFor(harness, thinkingLevel), ...(gateway ? { mcp: gateway } : {}) };
|
|
187
|
+
// ask_person stays pi's (runnable.ts refuses a run that names it here); the file tools are pi's own; the MCP tools
|
|
188
|
+
// are the harness's own client's, at the session's proxy.
|
|
189
|
+
const named = revision.body.tools.filter((name) => name !== ASK_TOOL && !mcpNameOf(name));
|
|
182
190
|
// The harness's own files (its homes, its state) go in a private directory beside the workspace, never in it. It works
|
|
183
191
|
// in the workspace itself (where.work), the directory the run's file tools confine to: a path the model builds from
|
|
184
192
|
// its working directory is then one they take.
|
|
@@ -196,7 +204,7 @@ export default async function app(where) {
|
|
|
196
204
|
const { door, onOpen } = adapterRun(make, harness, spec, BACKGROUND, cap, learnedTool ? [...named, LEARNED_WORKFLOW_TOOL] : named, dir, guard, cancelledIn(where.root), where.work, coding.tools, stopRecord, toolGate, learnedTool ? [learnedTool] : []);
|
|
197
205
|
// A paid host tool's settle goes to the run's root, as on pi (paid-calls.ts settleIn).
|
|
198
206
|
// A learned workflow's model requests go through the run's models, marked on its store once it opens (markRequests).
|
|
199
|
-
return { models: {}, registry: createRegistry(), door, onOpen: async (durable) => (settleIn(rootRecordOf(durable.harness)), learnedTool && marked.open(durable), onOpen(durable)), beforeResume: markResumed };
|
|
207
|
+
return { models: {}, registry: createRegistry(), door, onOpen: async (durable) => ((runHarness = durable.harness), settleIn(rootRecordOf(durable.harness)), learnedTool && marked.open(durable), onOpen(durable)), beforeResume: markResumed };
|
|
200
208
|
}
|
|
201
209
|
// Each tool the revision names is bound once, from the table: its extensions installed here, its documents written in
|
|
202
210
|
// each conversation's creating commit, what it settles done before anything resumes, and what it lets go done before
|
|
@@ -233,7 +241,13 @@ export default async function app(where) {
|
|
|
233
241
|
await durable.setStatus("sleeping", { reason: "drained" }, { wakeAt: at === null ? null : new Date(at).toISOString() });
|
|
234
242
|
};
|
|
235
243
|
if (revision.kind === "agentic") {
|
|
236
|
-
const tools = (await Promise.all(revision.body.tools.map((name) => bind(name)))).flatMap((binding) => binding.tools);
|
|
244
|
+
const tools = (await Promise.all(revision.body.tools.filter((name) => !mcpNameOf(name)).map((name) => bind(name)))).flatMap((binding) => binding.tools);
|
|
245
|
+
// The MCP tools pass the gate in the gateway (mcp-gateway.ts) and carry its mark (GATED_BY_GATEWAY), so the gate's
|
|
246
|
+
// extension leaves exactly those; every other tool, any mcp__ name included, it wraps.
|
|
247
|
+
const mcp = gateway ? mcpRegistrations(gateway) : [];
|
|
248
|
+
if (mcp.length)
|
|
249
|
+
registry.install(defineExtension({ name: "mcp", tools: mcp }));
|
|
250
|
+
tools.push(...mcp);
|
|
237
251
|
if (learnedTool) {
|
|
238
252
|
registry.install(defineExtension({ name: "learned-workflow", tools: [learnedTool] }));
|
|
239
253
|
tools.push(learnedTool);
|
|
@@ -243,6 +257,7 @@ export default async function app(where) {
|
|
|
243
257
|
const instructions = [await promptOf(learned.instructions, learned.skills, where.work, { onDemand: readsFiles(revision.body.tools) }), guidance].filter(Boolean).join("\n\n");
|
|
244
258
|
// The calls that wait for a person's approval are read as the run opens, and their answers acted on from then.
|
|
245
259
|
const onOpen = async (durable) => {
|
|
260
|
+
runHarness = durable.harness;
|
|
246
261
|
settleIn(rootRecordOf(durable.harness));
|
|
247
262
|
marked.open(durable);
|
|
248
263
|
await toolGate.load(durable, BACKGROUND, coding.tools, learnedTool ? [learnedTool] : []);
|
package/dist/background.d.ts
CHANGED
|
@@ -18,7 +18,8 @@ export declare const BACKGROUND_SIGNALS: readonly ["TERM", "INT", "KILL"];
|
|
|
18
18
|
/** The tools, by name. */
|
|
19
19
|
export declare const BACKGROUND_TOOLS: readonly ["bash_background", "bash_output", "bash_input", "bash_signal", "bash_list"];
|
|
20
20
|
/** The tools that run a command in the box, never on this server: bash, and the background tools. The tool gate holds
|
|
21
|
-
* each to bash's setting (tool-gate.ts SHELL_FAMILY)
|
|
21
|
+
* each to bash's setting (tool-gate.ts SHELL_FAMILY); under bash: ask, bash_output, bash_list and bash_signal run unasked
|
|
22
|
+
* (tool-gate.ts SHELL_WATCHERS), since an id reaches only this run's own processes (idOf, noSuch). */
|
|
22
23
|
export declare const SHELL_TOOLS: readonly string[];
|
|
23
24
|
/** The background tools, each run on the environment its call gives (the box's, coding-tools.ts). */
|
|
24
25
|
export declare const backgroundTools: () => ToolRegistration[];
|