@parcha/agentrun-serve 0.1.0-beta.45 → 0.1.0-beta.47
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 +180 -0
- package/NOTICE +4 -0
- package/README.md +283 -47
- package/dist/acp-package.d.ts +35 -6
- package/dist/acp-package.js +3 -3
- package/dist/adapter-facts.d.ts +5 -2
- package/dist/adapter-facts.js +6 -3
- package/dist/adapters.d.ts +7 -0
- package/dist/adapters.js +39 -0
- package/dist/agents-store.d.ts +5 -3
- package/dist/agents-store.js +13 -8
- package/dist/api-only.d.ts +7 -10
- package/dist/api-only.js +7 -10
- package/dist/archil-routes.js +2 -1
- package/dist/cap.js +12 -2
- package/dist/chatgpt-plan.js +2 -1
- package/dist/cli.js +119 -44
- package/dist/composio-made.d.ts +19 -2
- package/dist/composio-made.js +17 -5
- package/dist/composio-preset.d.ts +42 -7
- package/dist/composio-preset.js +106 -70
- package/dist/composio-triggers.d.ts +9 -4
- package/dist/composio-triggers.js +20 -13
- package/dist/computer-attach.d.ts +11 -10
- package/dist/computer-attach.js +13 -14
- package/dist/computer-commands.d.ts +3 -0
- package/dist/computer-commands.js +3 -2
- package/dist/computer-lost.d.ts +4 -0
- package/dist/computer-lost.js +8 -3
- package/dist/computer-setting.d.ts +2 -0
- package/dist/computer-setting.js +2 -0
- package/dist/computers.d.ts +9 -75
- package/dist/computers.js +20 -66
- package/dist/console/assets/index-BBFzAxLB.js +715 -0
- package/dist/console/assets/index-BRi-Rgq6.css +1 -0
- package/dist/console/index.html +2 -2
- package/dist/cost-heal.d.ts +13 -0
- package/dist/cost-heal.js +27 -0
- package/dist/dial-relay.d.ts +6 -2
- package/dist/dial-relay.js +9 -12
- package/dist/email/routes.js +2 -1
- package/dist/errors.d.ts +2 -0
- package/dist/errors.js +5 -0
- package/dist/exa-keyless.d.ts +1 -1
- package/dist/exa-keyless.js +1 -1
- package/dist/faux-computers.d.ts +2 -3
- package/dist/faux-computers.js +9 -31
- package/dist/github-connection.js +2 -1
- package/dist/harness-archive.d.ts +19 -2
- package/dist/harness-archive.js +49 -15
- package/dist/harness-check.d.ts +73 -0
- package/dist/harness-check.js +489 -0
- package/dist/harness-cursor.d.ts +45 -0
- package/dist/harness-cursor.js +121 -0
- package/dist/harness-recipe.d.ts +127 -0
- package/dist/harness-recipe.js +357 -0
- package/dist/harness-table.d.ts +12 -0
- package/dist/harness-table.js +62 -2
- package/dist/harness.d.ts +2 -0
- package/dist/harness.js +3 -2
- package/dist/host-check.d.ts +6 -0
- package/dist/host-check.js +14 -0
- package/dist/host.d.ts +10 -3
- package/dist/host.js +17 -3
- package/dist/import-sources.d.ts +2 -0
- package/dist/import-sources.js +2 -0
- package/dist/import-summary.d.ts +15 -5
- package/dist/import-summary.js +24 -8
- package/dist/import.d.ts +34 -4
- package/dist/import.js +134 -32
- package/dist/key-refusal.d.ts +1 -0
- package/dist/key-refusal.js +8 -3
- package/dist/key-words.d.ts +1 -1
- package/dist/key-words.js +4 -4
- package/dist/learn/check.d.ts +3 -0
- package/dist/learn/check.js +31 -20
- package/dist/learn/compile.js +11 -4
- package/dist/learn/promote.d.ts +77 -4
- package/dist/learn/promote.js +123 -2
- package/dist/learned-nodes.d.ts +4 -3
- package/dist/learned-workflow.js +4 -1
- package/dist/learning-cost.d.ts +6 -16
- package/dist/learning-cost.js +6 -12
- package/dist/learning-setting.d.ts +17 -6
- package/dist/learning-setting.js +41 -5
- package/dist/learning-words.d.ts +2 -0
- package/dist/learning-words.js +1 -1
- package/dist/listen-first.d.ts +10 -0
- package/dist/listen-first.js +25 -1
- package/dist/llms.txt +1 -1
- package/dist/mcp-gateway.d.ts +2 -1
- package/dist/mcp-gateway.js +31 -15
- package/dist/mcp-probe.d.ts +18 -6
- package/dist/mcp-probe.js +41 -8
- package/dist/mcp-secret-writes.d.ts +8 -0
- package/dist/mcp-secret-writes.js +104 -4
- package/dist/mcp-servers-store.d.ts +11 -5
- package/dist/mcp-servers-store.js +46 -20
- package/dist/model-form.d.ts +2 -1
- package/dist/model-form.js +22 -8
- package/dist/model-gateway.d.ts +113 -0
- package/dist/model-gateway.js +433 -0
- package/dist/model.d.ts +2 -1
- package/dist/model.js +9 -7
- package/dist/monid.js +1 -1
- package/dist/native/binding.d.ts +4 -0
- package/dist/native/binding.js +9 -0
- package/dist/native/cli.d.ts +3 -2
- package/dist/native/cli.js +6 -5
- package/dist/openapi.d.ts +2 -0
- package/dist/openapi.js +326 -41
- package/dist/owner.d.ts +4 -2
- package/dist/owner.js +10 -4
- package/dist/page.d.ts +8 -0
- package/dist/page.js +9 -1
- package/dist/port-models.js +17 -10
- package/dist/provider.d.ts +3 -3
- package/dist/provider.js +12 -3
- package/dist/public-address.d.ts +28 -0
- package/dist/public-address.js +62 -0
- package/dist/run-launch.d.ts +1 -1
- package/dist/run-launch.js +1 -1
- package/dist/run-secrets.d.ts +3 -2
- package/dist/run-secrets.js +6 -4
- package/dist/runner/adapter-loop.d.ts +10 -7
- package/dist/runner/adapter-loop.js +57 -22
- package/dist/runner/adapter-run-spec.d.ts +12 -0
- package/dist/runner/adapter-run-spec.js +40 -6
- package/dist/runner/adapters/index.js +16 -0
- package/dist/runner/adapters/pi.d.ts +5 -2
- package/dist/runner/adapters/pi.js +7 -4
- package/dist/runner/audit.d.ts +7 -0
- package/dist/runner/audit.js +24 -6
- package/dist/runner/claim-secrets.js +5 -1
- package/dist/runner/cli-run-spec.js +15 -7
- package/dist/runner/compare-end.d.ts +43 -0
- package/dist/runner/compare-end.js +95 -0
- package/dist/runner/computer-journal.d.ts +3 -0
- package/dist/runner/computer-journal.js +22 -2
- package/dist/runner/conformance/harness.js +19 -8
- package/dist/runner/conformance/subject.d.ts +6 -0
- package/dist/runner/harness-loops.d.ts +6 -1
- package/dist/runner/harness-loops.js +94 -54
- package/dist/runner/held.d.ts +5 -4
- package/dist/runner/journal-kinds.d.ts +4 -1
- package/dist/runner/journal-kinds.js +3 -0
- package/dist/runner/loop-contract.d.ts +10 -0
- package/dist/runner/main.d.ts +5 -5
- package/dist/runner/main.js +81 -11
- package/dist/runner/mcp-claim.js +40 -12
- package/dist/runner/metrics.d.ts +26 -0
- package/dist/runner/metrics.js +44 -1
- package/dist/runner/presence.d.ts +41 -0
- package/dist/runner/presence.js +89 -0
- package/dist/runner/promotion.d.ts +10 -3
- package/dist/runner/promotion.js +42 -21
- package/dist/runner/run-child-host.js +52 -14
- package/dist/runner/runner.d.ts +5 -0
- package/dist/runner/runner.js +8 -0
- package/dist/runner/store-port.d.ts +3 -0
- package/dist/runner/store-secrets.js +19 -7
- package/dist/runner/workflow-first.d.ts +5 -2
- package/dist/runner/workflow-first.js +6 -3
- package/dist/runs-over-store.d.ts +6 -2
- package/dist/runs-over-store.js +14 -4
- package/dist/sdk/runs.d.ts +1 -1
- package/dist/sdk/runs.js +6 -1
- package/dist/sdk/schema.js +1 -1
- package/dist/secret-writes.d.ts +16 -3
- package/dist/secret-writes.js +28 -3
- package/dist/server-secrets-store.js +5 -0
- package/dist/server.d.ts +31 -2
- package/dist/server.js +326 -53
- package/dist/sign-ins-secrets.js +4 -1
- package/dist/skills/agentrun-serve/SKILL.md +11 -0
- package/dist/slack-url.d.ts +5 -0
- package/dist/slack-url.js +11 -0
- package/dist/slack.d.ts +107 -0
- package/dist/slack.js +292 -0
- package/dist/start-switches.d.ts +28 -0
- package/dist/start-switches.js +37 -0
- package/dist/stats.d.ts +1 -1
- package/dist/stats.js +2 -1
- package/dist/stop-signals.d.ts +11 -0
- package/dist/stop-signals.js +22 -0
- package/dist/store/agent-body.d.ts +1 -1
- package/dist/store/agent-body.js +2 -2
- package/dist/store/index.d.ts +3 -3
- package/dist/store/index.js +1 -1
- package/dist/store/postgres/migrations/0020_runners.sql +18 -0
- package/dist/store/postgres/store.d.ts +1 -1
- package/dist/store/postgres/store.js +4 -2
- package/dist/store/schema.d.ts +13 -5
- package/dist/store/schema.js +20 -11
- package/dist/store/seal.d.ts +16 -4
- package/dist/store/sqlite/store.d.ts +1 -1
- package/dist/store/sqlite/store.js +106 -27
- package/dist/store/store.d.ts +75 -23
- package/dist/store/store.js +11 -0
- package/dist/store-reads/analytics.js +3 -2
- package/dist/store-reads/cap.d.ts +7 -0
- package/dist/store-reads/cap.js +11 -1
- package/dist/store-reads/journal.js +27 -1
- package/dist/store-reads/learning.d.ts +23 -2
- package/dist/store-reads/learning.js +29 -8
- package/dist/store-reads/runs.d.ts +9 -0
- package/dist/store-reads/runs.js +19 -6
- package/dist/store-reads/stats.d.ts +4 -1
- package/dist/store-reads/stats.js +15 -6
- package/dist/store-view.d.ts +123 -14
- package/dist/store-view.js +154 -21
- package/dist/telemetry.d.ts +7 -7
- package/dist/telemetry.js +38 -15
- package/dist/templates.d.ts +6 -3
- package/dist/templates.js +38 -3
- package/dist/timeline/timeline.js +18 -0
- package/dist/tool-keys-store.js +2 -2
- package/dist/tool-keys.js +2 -1
- package/dist/tool-plane.js +2 -2
- package/dist/trigger-adapter.d.ts +3 -4
- package/dist/trigger-adapter.js +2 -2
- package/dist/trigger-composio.js +3 -3
- package/dist/trigger-email.js +0 -2
- package/dist/trigger-feed.js +0 -2
- package/dist/trigger-schedule.js +3 -0
- package/dist/trigger-secrets-shown.d.ts +6 -3
- package/dist/trigger-secrets-shown.js +22 -13
- package/dist/trigger-targets.d.ts +1 -1
- package/dist/trigger-targets.js +19 -8
- package/dist/triggers.d.ts +7 -3
- package/dist/triggers.js +2 -1
- package/dist/webhooks.d.ts +85 -9
- package/dist/webhooks.js +129 -46
- package/dist/wires.d.ts +6 -1
- package/dist/wires.js +5 -0
- package/dist/workspace/attach.d.ts +3 -2
- package/dist/workspace/attach.js +2 -1
- package/dist/workspace/attached-computers.d.ts +6 -8
- package/dist/workspace/attached-computers.js +27 -24
- package/dist/workspace/computer-deps.d.ts +2 -3
- package/dist/workspace/computer-deps.js +3 -6
- package/dist/workspace/computer-for-claim.js +72 -96
- package/dist/workspace/computer-kept.d.ts +0 -7
- package/dist/workspace/computer-kept.js +0 -17
- package/dist/workspace/resolve-computer.d.ts +18 -14
- package/dist/workspace/resolve-computer.js +47 -60
- package/dist/workspace/synced-folder.d.ts +20 -15
- package/dist/workspace/synced-folder.js +33 -43
- package/launcher/agentrun-serve +4 -1
- package/package.json +10 -10
- package/skills/agentrun-serve/SKILL.md +11 -0
- package/templates/README.md +1 -1
- package/templates/inbound-lead/agent.md +2 -1
- package/templates/kyb/agent.md +2 -1
- package/dist/console/assets/index-3O2Yl6hZ.js +0 -701
- package/dist/console/assets/index-DaFsZuzQ.css +0 -1
package/README.md
CHANGED
|
@@ -81,7 +81,7 @@ An edit is a new revision: `PUT $AGENTRUN_BASE_URL/agents/calc/definition` with
|
|
|
81
81
|
| `--data DIR` | `~/.local/share/agentrun/agents` | The agent store (`DIR/store.sqlite`) and its runs (`DIR/disk/agents/<agent>/runs/<id>/`). The token is `DIR/.token`, mode 0600, made once and kept, unless `AGENTRUN_TOKEN` gives it: then a `DIR/.token` from an earlier start is removed. |
|
|
82
82
|
| `--listen ADDR` | `127.0.0.1` | The address to listen on. On any other, every `Host` name is served and the token is the only lock: put TLS in front of it. |
|
|
83
83
|
| `--port N` | the first free port from `7340` | The port. `0` is any free port. |
|
|
84
|
-
| `--open` | off | Open the console in this machine's browser once the server listens; not in CI, nor on Linux with no display. |
|
|
84
|
+
| `--open` | off | Open the console in this machine's browser once the server listens; not in CI, nor on Linux with no display. While the server has no owner it opens the setup page instead, with the setup code filled in when setup takes one. |
|
|
85
85
|
| `--faux MODULE` | none | Answer every model request from the module's default export (below). |
|
|
86
86
|
| `--faux-browser MODULE` | none | With `--faux` only: the `browser` tool's provider and driver from the module's default export, a fake browser with no vendor and no key ([below](#the-faux-model)). The console's real-browser tests run on it. |
|
|
87
87
|
| `--allow-host NAME` | none | Another `Host` name to accept on a loopback address, on any port. Repeat it. |
|
|
@@ -96,7 +96,18 @@ place: a token from the environment stays out of the logs. `DIR/.token`'s token
|
|
|
96
96
|
it; a later start prints `AGENTRUN_API_KEY=<in DIR/.token>`, to read it there. With `AGENTRUN_ACCOUNTS=0` the `Open`
|
|
97
97
|
link carries a launch code this start made at random (`?launch=<code>`), never the token. `AGENTRUN_PUBLIC_URL`, when set, is the
|
|
98
98
|
address people open (a container's published port, or a proxy's URL): the printed `Open` link and `AGENTRUN_BASE_URL`
|
|
99
|
-
use it
|
|
99
|
+
use it, and on loopback its name is also an allowed `Host`. Started with `npx @parcha/agentrun`, or as its service, pass
|
|
100
|
+
`--public-url https://<name>/` instead; the launcher hands the server that address as `AGENTRUN_PUBLIC_URL`
|
|
101
|
+
([the launcher](../agentrun/README.md)). The server remembers the public address in its data directory (`DIR/.public-url`) once a start serves; a start
|
|
102
|
+
that fails remembers nothing. A start where it changed,
|
|
103
|
+
including set where there was none or unset where there was one, writes one warning line to the log
|
|
104
|
+
(`event=public_url_changed from=<old> to=<new>`). The owner signs in again at the new address, because the session
|
|
105
|
+
cookie belongs to the old host, and links in earlier webhook messages still name the old address. When the old name
|
|
106
|
+
still reaches this server and it has a new public address, a browser that opens the console at the old name gets a 308
|
|
107
|
+
redirect to the new address. The browser keeps the link's `#/runs/<id>` part across the redirect, and the redirect is
|
|
108
|
+
`no-store`, so a browser does not keep it if the address changes back. On a loopback listener, everything else under
|
|
109
|
+
the old name stays refused: the API and webhooks get a 403 `forbidden` that names the new address, and another browser
|
|
110
|
+
page gets a page that links to it. Every other name is refused as before. `AGENTRUN_FREE_MODEL_REQUESTS` (default 60) is the most requests on free models a run makes
|
|
100
111
|
([a limit on free requests](#a-limit-on-free-requests)).
|
|
101
112
|
|
|
102
113
|
`AGENTRUN_TOKENS`, when set, is a list of more tokens, each with an id: `id:secret` entries separated by commas or
|
|
@@ -174,13 +185,17 @@ One line at start, `event=boxes`, says which boxes this server has ([Sandbox](#s
|
|
|
174
185
|
package and pins; [harnesses](#harnesses)), the bulk of its start; quiet keeps it too. It is made at the start only: a
|
|
175
186
|
PUT of `/settings/tools` and a save or delete of a tool key change no harness's offer, so they remake capabilities at
|
|
176
187
|
once without checking again (a key some harness reads would, with `why=key`).
|
|
188
|
+
`event=cost_heal read=<n> healed=<n> failed=<n>` says, once after the start, what the start's sweep did: the ended runs
|
|
189
|
+
whose stored cost was unknown that it read, those whose priced booking it wrote back, and those it could not read (each
|
|
190
|
+
heals on its next read). The rest stay unknown: a charge of no known cost, or a booking with no request to read. It
|
|
191
|
+
names no run, and a store with no such run says nothing; quiet keeps it too.
|
|
177
192
|
|
|
178
193
|
## Anonymous usage counts
|
|
179
194
|
|
|
180
|
-
The server
|
|
195
|
+
The server sends three anonymous events: `server_started`, a daily `heartbeat` and `first_run_completed`. Each holds
|
|
181
196
|
a random id kept in the data directory (`.telemetry.json`), the version, the platform and how many runs ended as a
|
|
182
|
-
range; never a prompt, a file, a key or a name.
|
|
183
|
-
`AGENTRUN_TELEMETRY=0` or `DO_NOT_TRACK=1` turns it off, as do `CI` and `--faux`; `AGENTRUN_TELEMETRY=debug` prints each
|
|
197
|
+
range; never a prompt, a file, a key or a name.
|
|
198
|
+
`AGENTRUN_TELEMETRY=0` or `DO_NOT_TRACK=1` turns it off, as do `CI`, a test runner (`node --test`) and `--faux`; `AGENTRUN_TELEMETRY=debug` prints each
|
|
184
199
|
event on stderr and sends none. The start that first could send prints one notice and sends nothing at that start.
|
|
185
200
|
[docs/telemetry.md](../../docs/telemetry.md) lists every field.
|
|
186
201
|
|
|
@@ -268,7 +283,18 @@ copy: a service that loses it loses them). With no
|
|
|
268
283
|
`AGENTRUN_TOKEN` from the Environment tab, or the code the start prints in the service's log (`Set up this server: ...`). On another host, set `AGENTRUN_PUBLIC_URL` to
|
|
269
284
|
the address people open before the first start; without it, whoever opens the console first sets the password. Set
|
|
270
285
|
`AGENT_MODEL` and the provider's key there too. Render waits 30 s after SIGTERM, above the image's 6 s drain; it does not
|
|
271
|
-
let a service with a disk change that.
|
|
286
|
+
let a service with a disk change that. It sets `AGENTRUN_RUN_USER=same` (every run as the server's own user, each still
|
|
287
|
+
a process of its own), as Railway's template does: neither platform has been shown to keep the image helper's file
|
|
288
|
+
capabilities.
|
|
289
|
+
|
|
290
|
+
A runner that refuses to claim (its run isolation refused: an `AGENTRUN_RUN_USER` it does not know, or a helper that
|
|
291
|
+
can't switch users) stays up and says so in the store. While every runner there has refused, and one at least is there,
|
|
292
|
+
the server refuses a run's start, and a message to a run, with 503 `runner_refused` in the runner's words and their fix;
|
|
293
|
+
`GET /v2/capabilities` has them in `runner_refused` (null otherwise); `GET /v2/health` answers 200 `degraded`, its
|
|
294
|
+
`runner` check `refused` and the words in `runner_refused`, so a platform's health check never restarts the service over
|
|
295
|
+
a setting; and a run already queued ends `failed` with error code `runner_refused`. A run a runner claimed is left to it.
|
|
296
|
+
A server with `--no-runner` and no runner started yet refuses nothing: runs queue for the runner to come. Once a runner
|
|
297
|
+
that can claim is there, the refusal is gone.
|
|
272
298
|
|
|
273
299
|
## The disk, and earlier data directories
|
|
274
300
|
|
|
@@ -353,6 +379,25 @@ timeline and, once, to the model as an "AgentRun server note"), and the agent's
|
|
|
353
379
|
when it does and 1 when it does not, and 2 when no name is given. Name a runner you start yourself with
|
|
354
380
|
`agentrun-serve runner --data DIR --name N`.
|
|
355
381
|
|
|
382
|
+
## Start-time switches
|
|
383
|
+
|
|
384
|
+
Some of what the server reaches is set only by its operator, in its environment when it starts. No route and no console
|
|
385
|
+
page sets these, so no caller of the API can widen what the server reaches; each takes a restart. A refusal one of them
|
|
386
|
+
causes names the variable, the value that allows it and the restart (`restart the server with
|
|
387
|
+
AGENTRUN_WEBHOOK_PRIVATE_TARGETS=1 to allow it, only on a machine you alone use`), with its usual error code.
|
|
388
|
+
`GET /v2/capabilities` lists them under `switches`, each with `on`, the `value` the server read and what it `allows`.
|
|
389
|
+
|
|
390
|
+
| Variable | What it allows | Default | Why at the start only |
|
|
391
|
+
| --- | --- | --- | --- |
|
|
392
|
+
| `AGENTRUN_MCP_ALLOW_LOOPBACK=1` | An MCP server on this machine's loopback ([MCP servers](#mcp-servers)) | off | Loopback is this machine's other services too: set it only on a machine you alone use |
|
|
393
|
+
| `AGENTRUN_WEBHOOK_PRIVATE_TARGETS=1` | The outbound webhook to a private network or this machine ([Webhooks](#webhooks)) | off | Whoever may set the webhook could make the server POST inside its network: only on a machine you alone use |
|
|
394
|
+
| `AGENTRUN_BOX_ALLOW` | The hosts a run's computer may reach: a comma list, or `none` ([A run in a Docker box](#a-run-in-a-docker-box)) | the package registries and GitHub | A run's network is the operator's policy, not a caller's |
|
|
395
|
+
| `AGENTRUN_BOX_CPUS`, `AGENTRUN_BOX_MEMORY`, `AGENTRUN_BOX_PIDS` | A Docker computer's size ([Computers](#computers)) | 2 CPUs, 4 GiB, 1,024 processes | The machine's capacity is the operator's |
|
|
396
|
+
|
|
397
|
+
On a server the installer runs as a service, `agentrun service install --env AGENTRUN_MCP_ALLOW_LOOPBACK=1 --env
|
|
398
|
+
AGENTRUN_WEBHOOK_PRIVATE_TARGETS=1` saves the two yes-or-no switches in the service and restarts it; `--env KEY=` takes
|
|
399
|
+
one off.
|
|
400
|
+
|
|
356
401
|
## Sandbox
|
|
357
402
|
|
|
358
403
|
A sandbox agent's `bash` runs in a box, a machine apart from this server. Docker is the default box and the only one offered
|
|
@@ -449,7 +494,7 @@ go through `work/` by path.
|
|
|
449
494
|
`AGENTRUN_BOX_ALLOW` replaces it with a comma list of host names, such as
|
|
450
495
|
`pypi.org,files.pythonhosted.org,registry.npmjs.org,registry.yarnpkg.com,github.com,codeload.github.com,deb.debian.org`
|
|
451
496
|
to add one (`*.example.com` names the hosts below `example.com`); `AGENTRUN_BOX_ALLOW=none` is the box offline, as it
|
|
452
|
-
was: no proxy, no network at all. `*`, an address or a CIDR refuses the start.
|
|
497
|
+
was: no proxy, no network at all ([start-time switches](#start-time-switches)). `*`, an address or a CIDR refuses the start.
|
|
453
498
|
- How: the run's process starts the proxy with the list on a Unix socket in a directory of its own under
|
|
454
499
|
`/tmp/agentrun-egress-<uid>/`, bound into the box read-only at `/run/agentrun/egress/`. A `socat` in the box relays
|
|
455
500
|
`127.0.0.1:3128` to it, and `HTTP_PROXY` and `HTTPS_PROXY` (and their lowercase twins) name that port, with
|
|
@@ -524,7 +569,7 @@ go through `work/` by path.
|
|
|
524
569
|
It may use 2 CPUs' time, 4 GiB of memory, swap included, and 1,024 processes and threads (`--cpu-period 100000
|
|
525
570
|
--cpu-quota 200000 --memory 4096m --memory-swap 4096m --pids-limit 1024`), so a runaway build or a fork bomb stops in
|
|
526
571
|
the box. `AGENTRUN_BOX_CPUS`, `AGENTRUN_BOX_MEMORY` and `AGENTRUN_BOX_PIDS` change them, for Docker computers only
|
|
527
|
-
([a Docker computer's size](#computers)). `AGENTRUN_BOX_CPUS` caps CPU
|
|
572
|
+
([a Docker computer's size](#computers); [start-time switches](#start-time-switches)). `AGENTRUN_BOX_CPUS` caps CPU
|
|
528
573
|
time, as a CFS quota (the cap `--cpus` sets), so it holds whatever CPU count Docker's VM has, and where the kernel
|
|
529
574
|
gives Docker no CPU controller (a rootless Docker without one delegated), Docker ignores it with a warning.
|
|
530
575
|
- `bash` takes pi's `{command, timeout?}`, `timeout` in seconds, 300 when the call names none; a timeout kills the
|
|
@@ -695,7 +740,7 @@ Settings → Computers. The kind says what the agent is given, and the provider
|
|
|
695
740
|
| Kind | What the agent gets | Providers |
|
|
696
741
|
|---|---|---|
|
|
697
742
|
| `none` | The run's folder alone: no computer, and no provider (`{"kind": "none"}`) | |
|
|
698
|
-
| `sandbox` | A Linux shell, with files and processes | `docker`, `daytona`, `modal`, `e2b`, `boxd`, `cloudflare` (through a relay Worker you deploy) |
|
|
743
|
+
| `sandbox` | A Linux shell, with files and processes | `docker`, `daytona`, `modal`, `e2b`, `boxd`, `smolcloud`, `cloudflare` (through a relay Worker you deploy) |
|
|
699
744
|
| `desktop` | The computer's tools (`computer_observe`, `computer_act`, `computer_screenshot`), the computer as `codemode`'s `computer`, and a shell where its provider mounts the run's folder | `docker` (with an image that has an X server), `e2b`, `orgo`, `boxd`, or [a paired computer](#a-persons-own-computer) by its id |
|
|
700
745
|
| `phone` | A rented Android, through the same computer tools | `phone-harness` |
|
|
701
746
|
| `browser` | A hosted browser (the browser tools) | `browserbase`, `kernel` |
|
|
@@ -732,7 +777,7 @@ the provider with them and starts nothing. A key set in the server's environment
|
|
|
732
777
|
`DAYTONA_API_KEY` (with `DAYTONA_API_URL` and `DAYTONA_TARGET` optional), `MODAL_TOKEN_ID` and `MODAL_TOKEN_SECRET`,
|
|
733
778
|
`E2B_API_KEY`, `AGENT37_API_KEY` and `AGENT37_SSH_KEY`, `MORPH_API_KEY`, `ORGO_API_KEY`, `PHONE_HARNESS_API_KEY`,
|
|
734
779
|
`BROWSERBASE_API_KEY` and `BROWSERBASE_PROJECT_ID`, `KERNEL_API_KEY`, `BOXD_API_KEY` (with `BOXD_ORG` and
|
|
735
|
-
`BOXD_REGION` optional), `CLOUDFLARE_RELAY_URL` and `CLOUDFLARE_RELAY_TOKEN` (the relay Worker's,
|
|
780
|
+
`BOXD_REGION` optional), `SMOLCLOUD_API_KEY`, `CLOUDFLARE_RELAY_URL` and `CLOUDFLARE_RELAY_TOKEN` (the relay Worker's,
|
|
736
781
|
`packages/computer/relays/cloudflare`), and `FLY_API_TOKEN` and `FLY_APP`; Docker takes none.
|
|
737
782
|
The vendors bill their computers by time on their own pages: this server meters no
|
|
738
783
|
computer time. The older [`place`](#place) is this setting's v2 view: `{"mode": "runner"}` is kind `none`, and
|
|
@@ -748,7 +793,10 @@ size its provider makes it, and is never given them. A value the Docker provider
|
|
|
748
793
|
the provider's words.
|
|
749
794
|
|
|
750
795
|
**A lost sandbox.** A run's sandbox can be lost mid-run: its vendor deleted it (from its own console or API), or no
|
|
751
|
-
longer has it. The tool call
|
|
796
|
+
longer has it. The tool call in flight when the loss is confirmed fails with code `gone`: `the computer <name> was lost
|
|
797
|
+
while this call ran, and it was not run again: <the provider's words>. A new computer starts at the next call.` It is
|
|
798
|
+
never sent again, to the new sandbox or anywhere, so a command that is not safe to repeat runs at most once. Whatever it
|
|
799
|
+
wrote to the run's folder before the loss stays there. The run's next tool call starts a new
|
|
752
800
|
sandbox under the same claim and runs there, also when the lost one was kept through a park. A start that fails is
|
|
753
801
|
tried again at the next tool call, under the same request, and does not count. In Mode 2 the new sandbox mounts the run's folder again with a new mount
|
|
754
802
|
credential, and the lost one's credential is removed. The run's folder is kept; what was on the lost sandbox outside it
|
|
@@ -960,6 +1008,25 @@ A Daytona computer mounts the run's folder only where `DAYTONA_ARCHIL_EGRESS` na
|
|
|
960
1008
|
egress relay (see Mode 2 above), and then it needs this snapshot. A changed recipe is a new name, so build again after
|
|
961
1009
|
an upgrade that changes `box/`. A Daytona [box](#sandbox) never reads it.
|
|
962
1010
|
|
|
1011
|
+
**Before unsetting `DAYTONA_ARCHIL_EGRESS` on a server with open runs.** Each open run's folder moves from the Archil
|
|
1012
|
+
mount to a synced folder at its next claim. The synced claim reads the folder through Archil's file API, which lists a
|
|
1013
|
+
link an exec made (a venv, `node_modules/.bin`) as a file and won't read it. So it takes the folder's links from the
|
|
1014
|
+
`sync.json` beside it (`agents/<agent>/runs/<run>/sync.json`), which an Archil computer writes at its park and release
|
|
1015
|
+
from 0.1.0-beta.45 on. A run whose last Archil claim ran an earlier release, or never reached its park or release, has
|
|
1016
|
+
no record. If its folder holds a link, its next synced claim is refused. New runs need nothing, and neither do runs
|
|
1017
|
+
that take no more messages (cancelled, failed, a workflow's, an imported or a learning run). Before the switch, run
|
|
1018
|
+
0.1.0-beta.45 or later with the variable still set and count the runs at risk. The count is read-only:
|
|
1019
|
+
|
|
1020
|
+
1. List the disk under `agents/*/runs/*/` through the file API. Keep each run with files under `work/` and no
|
|
1021
|
+
`sync.json`.
|
|
1022
|
+
2. Keep only the runs that can take a message (`GET /runs`): one not ended, or an agentic run that completed or that a
|
|
1023
|
+
person stopped, since a follow-up opens it again on the same folder.
|
|
1024
|
+
3. Probe every file the listing has under each kept run's `work/` with a one-byte ranged GET. A 501 answer means a
|
|
1025
|
+
link: that run is at risk. A run with a file not yet probed stays in the count.
|
|
1026
|
+
|
|
1027
|
+
Claim each run left once on the mount (a message, or a resume), so its park or release records it, or accept that it
|
|
1028
|
+
won't continue where it syncs. Unset the variable once the count is 0.
|
|
1029
|
+
|
|
963
1030
|
A desktop, a phone and a browser run in either mode. The run's folder is at
|
|
964
1031
|
`/workspace` in every computer that mounts it: a sandbox always, and a desktop whose provider mounts the mode's folder
|
|
965
1032
|
(Docker's in Mode 1, Agent37's and E2B's in Mode 2). A phone and a browser never mount it. On a desktop that mounts it, the
|
|
@@ -1069,6 +1136,22 @@ model with no price set that the catalog does not list in any form; null while `
|
|
|
1069
1136
|
gets that as a warning. One
|
|
1070
1137
|
without a cap runs, on every harness, with each request's cost unknown: codex's and opencode's proxy books it unknown,
|
|
1071
1138
|
never $0, so the run's `cost.usd` is `null` and `/usage` counts it in `unpriced_runs`.
|
|
1139
|
+
- A model gateway saved in the console (Settings → Model keys → **Use a model gateway**), the same gateway kept in the
|
|
1140
|
+
store instead of the environment, for a LiteLLM or other OpenAI-compatible proxy the owner already runs: its address
|
|
1141
|
+
(the one rule `AGENT_MODEL_BASE_URL` follows), its key (optional; sealed under the seal key, never shown again, never in
|
|
1142
|
+
a run's environment), how it takes ids (`as_named`, or `bare` as `AGENT_MODEL_GATEWAY_IDS=bare`), and the default
|
|
1143
|
+
model of each tier (`AGENT_MODEL`, `AGENT_MODEL_FAST`, `AGENT_MODEL_STRONG`). **Test** asks the gateway's
|
|
1144
|
+
`GET <base>/v1/models` from the server, with no redirect followed, and lists the ids to pick from. A save or removal
|
|
1145
|
+
takes effect at once, with no restart: capabilities read it, and the runner reads it at each claim. Over the API:
|
|
1146
|
+
`GET`, `PUT` and `DELETE /v2/settings/model-gateway` and `POST /v2/settings/model-gateway/test`; every one but the GET
|
|
1147
|
+
takes the owner's signed-in session, never the API token. Which wins: `AGENT_MODEL_BASE_URL` set where AgentRun starts
|
|
1148
|
+
makes the environment's gateway the one in force, whole, and the saved one is not read (its `PUT` and `DELETE` are 409
|
|
1149
|
+
`key_set_by_server`); else the saved gateway is in force with its own key alone (never an `AGENT_MODEL_API_KEY` set
|
|
1150
|
+
without a base URL), and each of `AGENT_MODEL`, `AGENT_MODEL_FAST`, `AGENT_MODEL_STRONG` and
|
|
1151
|
+
`AGENT_MODEL_GATEWAY_IDS` set where AgentRun starts wins over its saved field. A saved key goes only to the origin it
|
|
1152
|
+
was saved for: changing the address to another origin asks for the key again (or `api_key: null`, no key). With no key
|
|
1153
|
+
saved, each run brings its own (`model_key`, below). Prices are read as for `AGENT_MODEL_BASE_URL`
|
|
1154
|
+
(`AGENT_MODEL_PRICE`, else the catalog). Removing it puts the provider keys back in force.
|
|
1072
1155
|
- A ChatGPT plan signed in here ([below](#on-a-chatgpt-plan)), with no provider's key: `source` is `chatgpt`, and pi
|
|
1073
1156
|
and codex run on the plan's models (`chatgpt/<model-id>`) with no key.
|
|
1074
1157
|
- Otherwise pi-ai's providers serve them, each with its key from the environment (`OPENAI_API_KEY`, `ANTHROPIC_API_KEY`,
|
|
@@ -1227,9 +1310,13 @@ even a pre-admission 429 is not retried automatically. This changes request retr
|
|
|
1227
1310
|
admission, dispatch, journal fencing, restart or cancellation behavior; the recovery models do not change.
|
|
1228
1311
|
|
|
1229
1312
|
Offline regressions cover streamed native tools, continuation, reasoning, cache accounting, missing usage, cancellation,
|
|
1230
|
-
errors, credential scoping and actual Pi conversation retries.
|
|
1231
|
-
|
|
1232
|
-
|
|
1313
|
+
errors, credential scoping and actual Pi conversation retries. A live pass against Particle's API (2026-11-18, twelve
|
|
1314
|
+
checks) saved a key, then completed a plain run, tool calls continued after the model's reasoning, a follow-up, a
|
|
1315
|
+
cancel, a capped run and a workflow's model nodes. Replies reported cached input tokens and no cache writes, and each
|
|
1316
|
+
priced run's cost equaled its tokens at list price. A later workflow run (2026-11-19, three requests) matched
|
|
1317
|
+
Particle's usage page: the same cached, uncached and output token counts, and the same cost to the six decimals the
|
|
1318
|
+
page shows. Not yet seen live: a rate limit or server error from Particle. The protocol fixtures alone are not
|
|
1319
|
+
evidence of live compatibility.
|
|
1233
1320
|
|
|
1234
1321
|
### On a ChatGPT plan
|
|
1235
1322
|
|
|
@@ -1926,7 +2013,8 @@ not known, so not cut, and the import says so.
|
|
|
1926
2013
|
## MCP servers
|
|
1927
2014
|
|
|
1928
2015
|
Add a remote MCP server once, with its credential, and see its tools before you keep it. An agent that grants one of
|
|
1929
|
-
its tools calls it on pi and on claude-agent ([below](#agents-call-a-servers-tools)).
|
|
2016
|
+
its tools calls it on pi and on claude-agent ([below](#agents-call-a-servers-tools)). Which kind of server to choose for a
|
|
2017
|
+
service's CLI, and why its token never goes in the box: [Give an agent tools](../../docs/connect-tools.md).
|
|
1930
2018
|
|
|
1931
2019
|
```sh
|
|
1932
2020
|
curl -X POST "$BASE/v2/settings/mcp-servers/preview" -H "authorization: Bearer $TOKEN" -H 'content-type: application/json' \
|
|
@@ -1951,18 +2039,58 @@ preset: you give your Composio API key, a toolkit (`github`, `slack`...), the ac
|
|
|
1951
2039
|
toolkit's list) and a server name, and the server has Composio make a managed MCP server for them, then saves it as an
|
|
1952
2040
|
ordinary MCP server with the key sealed as an `x-api-key` header. `POST /v2/settings/mcp-servers/composio/tools`
|
|
1953
2041
|
`{api_key, toolkit}` lists the actions; `PUT /v2/settings/mcp-servers/{name}/composio` `{api_key, toolkit, tools,
|
|
1954
|
-
user_id?}` makes and saves the server. When the toolkit needs your account and `user_id`
|
|
1955
|
-
active, the answer's `connect_url` is Composio's page to connect it; nothing here signs
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
2042
|
+
user_id?, auth_config_id?, price_usd?}` makes and saves the server. When the toolkit needs your account and `user_id`
|
|
2043
|
+
(default `agentrun`) has none active, the answer's `connect_url` is Composio's page to connect it; nothing here signs
|
|
2044
|
+
in. The server and its connect link are made against the toolkit's Composio-managed auth config (found, else made), or
|
|
2045
|
+
against `auth_config_id`, one you already have at Composio (your own OAuth app's, say): it is read first, and one
|
|
2046
|
+
Composio doesn't know, of another toolkit, or disabled is `422` under `auth_config_id` before anything is made. From
|
|
2047
|
+
that save on it is yours: no delete or later save removes it, even when AgentRun made it for this or another saved
|
|
2048
|
+
server. `price_usd` (0 or more, as a `prices` value) is what each call costs you: every granted action is saved at that
|
|
2049
|
+
price, so a call is held under its run's cap and booked as the run's tool cost (its trace span's `usd`, the run's
|
|
2050
|
+
`cost.usd`), as any priced MCP tool's. A re-save that names no price keeps the server's prices for the actions it still
|
|
2051
|
+
lists. Composio's server can leave out an action it was allowed (it did for `HACKERNEWS_GET_FRONTPAGE`), so the answer's
|
|
2052
|
+
`not_served` names any chosen action the saved server doesn't list. Both routes are the owner's session alone, and a
|
|
2053
|
+
saved Composio server is gated, approved and shown on the Timeline as any MCP server's tools are, "not metered" until
|
|
2054
|
+
you price them (`price_usd`, or the server's `prices`). Composio's own meta tools stay refused, and the helper actions
|
|
2055
|
+
that connect an account are left off the server's address. Deleting the server in Settings deletes what its save made in Composio too, with the saved key: the Composio MCP server, the connected account its connect link started (the link with it) and the auth config it made (Composio's "already gone" is fine). What another saved server uses is kept until the last of them goes, and what was there before the save (an auth config or account you had) is never deleted. The `DELETE` answers `200 {deleted: true, composio: {removed, note}}`: the note says what it removed, what it kept and why, and, when Composio refuses or does not answer, what is left to remove in Composio yourself (`removed: false`; the server is still forgotten here). The console shows it. A save that fails removes in Composio what it made there and never what it found, and its error names what is left when Composio refuses that too (a 422 on a field says it in `details.composio` as well). A save over a preset server removes, once it is saved, the Composio MCP server its earlier save made, and what that save made and the new one no longer stands on (the account of another `user_id`, the auth config of another toolkit), with the key it was made with, unless another saved server uses it, and answers `composio: {removed, note}` saying so. An ordinary `PUT` that moves a preset server to another address makes it another service's server: it removes what the preset made for it in Composio as its delete would, and answers `composio` too. While Composio triggers use the server, that move, and a preset save over it as another `user_id` or auth config, are refused as its delete is (`409 composio_in_use`, naming them). Preset saves and MCP server deletes run one at a time, so a delete never removes what a save in progress reuses; an ordinary save of a preset server lists its tools at once and takes its turn only to write the server and clean up.
|
|
1961
2056
|
[Connect Composio tools and triggers](../../docs/tutorials/composio.md) walks through the preset and a Composio
|
|
1962
2057
|
trigger in the console, with each step's API call.
|
|
1963
2058
|
|
|
2059
|
+
#### One Composio server, an account per run
|
|
2060
|
+
|
|
2061
|
+
A preset server is saved for one Composio user. To let each run act as its own person's account instead, save it with
|
|
2062
|
+
`user_id: "per_run"` (a word reserved for this, never a Composio user id): the server keeps no user and no connected
|
|
2063
|
+
account in its address, looks up no account and makes no connect link. Composio refuses an address that names no user,
|
|
2064
|
+
even to list its tools, so the save, a refresh, a preview and an agent's save list them as `agentrun~tool-listing`, a
|
|
2065
|
+
user no save or run can name, never stored and never used for a call. Each run then names the account its calls of that
|
|
2066
|
+
server run as, in `mcp_auth` on its start or on a message:
|
|
2067
|
+
|
|
2068
|
+
```sh
|
|
2069
|
+
curl -X POST "$BASE/v2/agents/$AGENT/runs" -H "authorization: Bearer $TOKEN" -H 'content-type: application/json' \
|
|
2070
|
+
-d '{"input": {"content": "..."}, "mcp_auth": {"mail": {"composio_user_id": "user-1234", "connected_account_id": "ca_abc123"}}}'
|
|
2071
|
+
```
|
|
2072
|
+
|
|
2073
|
+
`composio_user_id` is a Composio user id; `connected_account_id`, optional, is one of that user's connected accounts
|
|
2074
|
+
(`ca_...`), and without it Composio picks the user's account for the toolkit. Each request to the server carries that
|
|
2075
|
+
user and account, the Composio key staying the server's own. The binding is kept as a `per_run` server's headers are:
|
|
2076
|
+
sealed into the run's launch, erased by the write that ends the run, never on the server's row, the run's view, its
|
|
2077
|
+
timeline, its trace or a log line, and its values are cut from whatever the run shows. A message's binding replaces the
|
|
2078
|
+
run's for the turn it starts. A run that names no account has its calls of the server answered, unsent, that it was
|
|
2079
|
+
handed none, so a per-run server never calls as a default account. A malformed user or account is `422 input_invalid` at
|
|
2080
|
+
`mcp_auth.<server>.composio_user_id` or `.connected_account_id`, and so is a binding to the preset's default user
|
|
2081
|
+
`agentrun` (`not_allowed`: the user single-user preset servers call as); headers for such a server, or a binding for any
|
|
2082
|
+
other server, are `422` at `mcp_auth.<server>`, and no run starts. A per-run server makes no Composio trigger: a trigger
|
|
2083
|
+
runs as one account. A server saved for one user before this mode keeps calling as that user.
|
|
2084
|
+
|
|
2085
|
+
With `user_id: "per_run"`, whoever can start a run chooses its Composio user, so the host (Grep, say) owns which user
|
|
2086
|
+
each run binds: it binds each run to its own person and never takes the ids from that person. Only `agentrun` is
|
|
2087
|
+
refused, so a host must not bind a per-run server to a `user_id` that a single-user server calls as.
|
|
2088
|
+
|
|
1964
2089
|
What can go wrong, told apart:
|
|
1965
2090
|
|
|
2091
|
+
- `403 forbidden` with `details.console_url`: the API token sent, dropped or changed a credential, which only the
|
|
2092
|
+
owner's console saves. The link opens Settings → MCP servers with the form filled in (name, URL, kind of credential,
|
|
2093
|
+
toolkit; for a saved server, its Change form), never the credential. A URL that could hold one is left out.
|
|
1966
2094
|
- `422 auth_required`: the server answered 401 or 403. `details.auth` is `oauth` when it names protected-resource
|
|
1967
2095
|
metadata (in its `WWW-Authenticate`, or at `/.well-known/oauth-protected-resource`), else `bearer`.
|
|
1968
2096
|
- `422 not_mcp`: the URL answered, but nothing it answered was a JSON-RPC reply (a web page, a JSON API, a 404).
|
|
@@ -2054,7 +2182,7 @@ and `X-Forwarded-Proto: https`: without them a start reads as another address (o
|
|
|
2054
2182
|
and every start answers `409 wrong_origin`. For an MCP server whose URL is not loopback, every endpoint its authorization server names (and
|
|
2055
2183
|
every request to one) must be `https` and resolve to no private, loopback or link-local address, or the sign-in or
|
|
2056
2184
|
refresh is refused with words and nothing is sent. A loopback MCP server (a `127.0.0.1` or `localhost` URL) is taken only
|
|
2057
|
-
by a server started with `AGENTRUN_MCP_ALLOW_LOOPBACK=1
|
|
2185
|
+
by a server started with `AGENTRUN_MCP_ALLOW_LOOPBACK=1` ([start-time switches](#start-time-switches)), which says this is a local install: set it only on a machine you
|
|
2058
2186
|
alone use, since loopback is this machine's other services too. Without it such a URL is refused at the save, the preview
|
|
2059
2187
|
and the sign-in, in words naming the variable, and a runner never reaches one. The runner beside such a server reaches
|
|
2060
2188
|
one, never at that server's own ports (where it listens, and its public address when that is on loopback), which the
|
|
@@ -2220,7 +2348,7 @@ save's `422` says, under a harness id when that harness's own MCP client would d
|
|
|
2220
2348
|
|
|
2221
2349
|
One URL hears of your runs without anyone watching the page. `PUT /v2/settings/webhook` with `{url}` sets it: an `http`
|
|
2222
2350
|
or `https` address, with no user or password in it, on a public host: a loopback or private-network address is refused
|
|
2223
|
-
unless the operator allows it (`AGENTRUN_WEBHOOK_PRIVATE_TARGETS=1`, below). Two kinds of message are POSTed to it about runs: `run.needs_input` when a run comes to
|
|
2351
|
+
unless the operator allows it (`AGENTRUN_WEBHOOK_PRIVATE_TARGETS=1`, below; [start-time switches](#start-time-switches)). Two kinds of message are POSTed to it about runs: `run.needs_input` when a run comes to
|
|
2224
2352
|
need its person (`input_required`: a question, a call held for approval, a pause at its cap, an ask for its person in
|
|
2225
2353
|
its browser, desktop or phone, or a stopped turn) and `run.ended` when it ends
|
|
2226
2354
|
(completed, failed or cancelled, once the run's end is written). A [schedule](#schedules) whose firing fails sends a third,
|
|
@@ -2241,12 +2369,13 @@ the webhook was set is never sent.
|
|
|
2241
2369
|
|
|
2242
2370
|
```json
|
|
2243
2371
|
{ "type": "run.needs_input", "timestamp": "2026-11-01T12:00:00.000Z",
|
|
2244
|
-
"data": { "run_id": "…", "agent_id": "triage", "status": "input_required", "title": "…",
|
|
2372
|
+
"data": { "run_id": "…", "agent_id": "triage", "agent_name": "Triage", "status": "input_required", "title": "…",
|
|
2245
2373
|
"url": "https://agents.example.com/#/runs/…", "pending": { "kind": "question" } } }
|
|
2246
2374
|
```
|
|
2247
2375
|
|
|
2248
|
-
A message is thin: ids, the status, the title and a link to the run on the page; never a tool's
|
|
2249
|
-
or an input, which the API reads (`GET /v2/runs/{id}`).
|
|
2376
|
+
A message is thin: ids, the agent's name, the status, the title and a link to the run on the page; never a tool's
|
|
2377
|
+
arguments, an output or an input, which the API reads (`GET /v2/runs/{id}`). `agent_name` is the agent's name as the
|
|
2378
|
+
message is built (a rename after it is not sent again), or its id when it has none. The title is the run's own, as the store holds it: a trigger's
|
|
2250
2379
|
run is titled from its trigger, `<Source> <name>` and the event when its source names one ("Webhook reviews:
|
|
2251
2380
|
pull_request opened"), never from its input; a workflow run's from its agent's name and its input; any other run's
|
|
2252
2381
|
from its input. `pending.kind` is `question` (an `ask_person`),
|
|
@@ -2265,10 +2394,14 @@ it is still cut. A `PUT` that changes the URL makes a new secret and shows it on
|
|
|
2265
2394
|
URL keeps it. `GET` and the log show the URL's origin and its last four characters, never the whole URL (a chat
|
|
2266
2395
|
service's incoming-hook URL is a credential itself). The URL is refused when it is on a private network or this machine,
|
|
2267
2396
|
by address or by any address its name resolves to, and each try resolves the name again and dials the address it
|
|
2268
|
-
checked; an operator who sends to an internal receiver sets `AGENTRUN_WEBHOOK_PRIVATE_TARGETS=1` where the server starts
|
|
2397
|
+
checked; an operator who sends to an internal receiver sets `AGENTRUN_WEBHOOK_PRIVATE_TARGETS=1` where the server starts
|
|
2398
|
+
and restarts it, which the refusal says, at the `PUT` and in a try's log entry. A `DIR/webhook.json` an earlier build left is not read: the
|
|
2269
2399
|
server says so at its start (`condition=webhook_left_over`), and a `PUT` sets the webhook again. A new secret for the
|
|
2270
|
-
same URL is
|
|
2271
|
-
|
|
2400
|
+
same URL is `POST /v2/settings/webhook/secret` (Settings → Webhook → Rotate secret in the console), from the owner's
|
|
2401
|
+
signed-in session alone, as every secret write is: it answers the new secret once, as `signing_secret`, and retires the
|
|
2402
|
+
old one at once, so every try after it is signed with the new one, a message queued before it included. A `404` says no
|
|
2403
|
+
webhook is set. A secret that no longer opens under the server's key (sealed under another) is replaced, and shown
|
|
2404
|
+
once, by a rotation or the next `PUT`. The URL and its secret go live together: a `PUT` whose write the store
|
|
2272
2405
|
refuses leaves the webhook as it was, and the secret it made is never used.
|
|
2273
2406
|
|
|
2274
2407
|
A try that is not answered 2xx within 15 s fails; a redirect is not followed. A failed message is tried again on the
|
|
@@ -2283,6 +2416,45 @@ lists the last 50 attempts (`webhook_id`, type, status code, latency, error, whe
|
|
|
2283
2416
|
410 turned off sends nothing, a test or a redelivery included (`409 webhook_off`), until a `PUT` sets it again.
|
|
2284
2417
|
`DELETE /v2/settings/webhook` removes the webhook and drops its pending messages.
|
|
2285
2418
|
|
|
2419
|
+
### Post to Slack
|
|
2420
|
+
|
|
2421
|
+
Slack shows a message, not the webhook's signed JSON, so the server can post to a Slack channel itself. In Slack, add an
|
|
2422
|
+
incoming webhook to the channel (an app with Incoming Webhooks turned on), then paste its URL in the console under
|
|
2423
|
+
Settings → Slack, or `PUT /v2/settings/slack` with `{"url": "https://hooks.slack.com/services/..."}` from the owner's
|
|
2424
|
+
signed-in session. The URL must be `https://hooks.slack.com/services/...`, with no port, query or user.
|
|
2425
|
+
|
|
2426
|
+
The URL is the credential: anyone who has it can post to the channel. So saving it is a secret write (the API token is
|
|
2427
|
+
refused `403`, with `details.console_url` opening Settings → Slack, never the URL), it is sealed under the server's seal key like a [tool key](#tool-keys), and no answer, log line or
|
|
2428
|
+
delivery shows more than its last four characters. A replaced or removed URL stays sealed in the store, so a run that
|
|
2429
|
+
echoes it, or its token, is still cut.
|
|
2430
|
+
|
|
2431
|
+
Each event posts one message (Block Kit, with `text` for notifications):
|
|
2432
|
+
|
|
2433
|
+
| Event | The message |
|
|
2434
|
+
| --- | --- |
|
|
2435
|
+
| `run.ended` | The agent (its `agent_name`: its name, else its id), the status in a word (completed, failed, was cancelled), the run's title linked to the run in the console. |
|
|
2436
|
+
| `run.needs_input` | The same, with "needs you" and what the run waits on: a question, an approval, a paused cap, a hand-over or a stopped turn. |
|
|
2437
|
+
| `trigger.failed` | The trigger's name, linked to it, and the error's code and message; and whether it turned itself off. |
|
|
2438
|
+
|
|
2439
|
+
```json
|
|
2440
|
+
{ "text": "Lead triage: run completed: Qualify ACME",
|
|
2441
|
+
"blocks": [
|
|
2442
|
+
{ "type": "section", "text": { "type": "mrkdwn", "text": "*Lead triage* · run completed\n<https://agents.example.com/#/runs/…|Qualify ACME>" } },
|
|
2443
|
+
{ "type": "context", "elements": [{ "type": "mrkdwn", "text": "AgentRun · run.ended · run `…`" }] } ] }
|
|
2444
|
+
```
|
|
2445
|
+
|
|
2446
|
+
A message never carries a run's input, its output or a tool's arguments, as the webhook's never does: open the run
|
|
2447
|
+
from the link to read them. Every string in it (an agent's or a trigger's name, a run's title, an error) is cut of the
|
|
2448
|
+
secrets the server holds before it is saved or posted: a key typed into a name reads `[redacted]`. Every event is on by default. `PUT /v2/settings/slack` with
|
|
2449
|
+
`{"events": {"run.needs_input": false}}` turns one off; a body with `events` alone is no secret write.
|
|
2450
|
+
|
|
2451
|
+
Delivery is the webhook's: the same outbox in the store, retries on the same schedule, one message per run's end or
|
|
2452
|
+
wait, deliveries at `GET /v2/settings/slack/deliveries`, a message posted again with
|
|
2453
|
+
`POST /v2/settings/slack/deliveries/{webhook_id}/redeliver`, and a test message with `POST /v2/settings/slack/test`.
|
|
2454
|
+
Slack answers `200 ok`. A `404` or `410` (`no_service`, `channel_not_found`, `channel_is_archived`) turns Slack off
|
|
2455
|
+
(`disabled` in `GET`, with Slack's word) until a URL is saved again; a test or a redelivery is then `409 slack_off`.
|
|
2456
|
+
`DELETE /v2/settings/slack` removes the URL and drops pending messages.
|
|
2457
|
+
|
|
2286
2458
|
## Schedules
|
|
2287
2459
|
|
|
2288
2460
|
A schedule starts an agent's runs with no one there. `POST /v2/triggers` with a `source` and a `target`:
|
|
@@ -2300,7 +2472,10 @@ change repeats fires once, at its first pass; one it skips fires at the first ti
|
|
|
2300
2472
|
reckoned from the last nominal one, so a timer that wakes late does not drift. Every run a trigger starts is capped: by
|
|
2301
2473
|
the target's `max_cost_usd`, else by the agent's default (its definition's `max_cost_usd`) as it stands when the firing
|
|
2302
2474
|
starts. A target with neither is `422`, and a firing that finds neither (the default removed since) fails, so no trigger
|
|
2303
|
-
starts an uncapped run, a workflow agent's included ([workflow runs](#a-workflow-run-under-its-cap)).
|
|
2475
|
+
starts an uncapped run, a workflow agent's included ([workflow runs](#a-workflow-run-under-its-cap)). The one
|
|
2476
|
+
exception is a connected agent ([native agents](../../docs/native-agents.md)): its own CLI keeps its own limits and
|
|
2477
|
+
AgentRun cannot hold it to a dollar cap, so a trigger on one takes no `max_cost_usd` (on the target or as the agent's
|
|
2478
|
+
default) and no `effort`, each `422 not_allowed`, and its runs start uncapped, as the ones a caller starts do. Each run's
|
|
2304
2479
|
input ends with a line naming the schedule and the time it fired for, in its zone, and the run's `trigger` names the
|
|
2305
2480
|
trigger and the firing, in the run's view and in the runs lists (`GET /v2/runs`, `GET /v2/agents/{id}/runs`) alike;
|
|
2306
2481
|
a run a caller started has `trigger: null`.
|
|
@@ -2316,8 +2491,10 @@ one `missed` firing with their count, and the schedule goes on from now; the lat
|
|
|
2316
2491
|
no older than the trigger's `catchup_window_s` (default an hour; 0, never), marked `catch_up`. A
|
|
2317
2492
|
firing while the last run is active (working, or parked waiting on a person) is skipped with why, never queued,
|
|
2318
2493
|
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
|
|
2319
|
-
gets a `trigger.failed` message for it (`data: {trigger_id, name, firing_key, nominal_at, error,
|
|
2320
|
-
`webhook-id` made from the firing's key, so a restart never sends it twice).
|
|
2494
|
+
gets a `trigger.failed` message for it (`data: {trigger_id, name, agent_id, agent_name, firing_key, nominal_at, error,
|
|
2495
|
+
auto_paused}`, its `webhook-id` made from the firing's key, so a restart never sends it twice). `agent_id` is the agent
|
|
2496
|
+
the trigger runs as, which every trigger has: a `start_run` target's agent, or the agent of the run a `message_run`
|
|
2497
|
+
target names; `agent_name` is that agent's name as the message is built, or its id when it has none. Five failed firings in a row turn the
|
|
2321
2498
|
trigger off (`disabled: {reason: "auto_paused"}`); a firing that starts its run resets the count, and so does turning
|
|
2322
2499
|
it on again. Run now (below) works on an auto-paused trigger too, and counts toward the streak like any firing: one that
|
|
2323
2500
|
starts its run resets it, one that fails adds to it. A trigger whose cron line or zone no longer reads here (after an
|
|
@@ -2478,14 +2655,14 @@ A string that is an address carrying a credential, in any scheme (`https`, `post
|
|
|
2478
2655
|
(`token`, `api_key`, `access_token`, `sig`) that has a value. An address with none stays as it is; one whose user part
|
|
2479
2656
|
holds no secret (`ssh://git@host`) is sealed all the same. A field the event's schema marks with `format: "password"` or
|
|
2480
2657
|
`writeOnly: true` is sealed whatever its name; the create reads the event's schema from Composio for this. A create with
|
|
2481
|
-
such a value below the config's top level is refused `422`, naming it.
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
`
|
|
2487
|
-
|
|
2488
|
-
|
|
2658
|
+
such a value below the config's top level is refused `422`, naming it. Composio's trigger schemas rarely mark a field
|
|
2659
|
+
secret, so the name mostly decides. A number is sealed as its decimal text and stays a number in what Composio gets; a
|
|
2660
|
+
run's output is cut of that text when it is 8 characters or more, as a string's is. The value is kept in the composio
|
|
2661
|
+
source's sealed settings, next to the subscription's secret. Composio gets it once, in the instance's upsert. Every
|
|
2662
|
+
answer has `"[sealed]"` in its place, and `source.sealed_config` names the field. The events list names these fields per
|
|
2663
|
+
event under `sealed`, and the console takes them as passwords. A PATCH that leaves a sealed field out or sends
|
|
2664
|
+
`"[sealed]"` keeps it. Any other value is a change to the config and is refused, as every config change is: to change a
|
|
2665
|
+
key, delete the trigger and make a new one.
|
|
2489
2666
|
The trigger's delete retires the value into a sealed row until the runs that saw it end. A trigger saved by an earlier server with such a value in plain text is answered
|
|
2490
2667
|
masked by the same rule at once, at any depth (one below the top level named in `sealed_config` by its JSON Pointer),
|
|
2491
2668
|
and sealed at the next start by the same rule. After that start, without holding it up, the server reads the schema of
|
|
@@ -2704,8 +2881,8 @@ failed, 2 when nothing ran. The runner, the graders and the report are in
|
|
|
2704
2881
|
| `GET /health` | Without a credential: whether the store reads and the disk has room ([capacity and health](#capacity-and-health)). |
|
|
2705
2882
|
| `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. |
|
|
2706
2883
|
| `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. |
|
|
2707
|
-
| `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`, the agent's default cap (an agentic agent's or a workflow's), kept by an edit that leaves it out and cleared only by 0 ([spend cap](#spend-cap)), and `output_schema` (agentic only, at most 64 KiB): the JSON Schema the final answer's last fenced json block meets, which a completed run's `result.output` then holds (null when the answer doesn't meet it), kept by an edit that leaves it out. A template's answer schema is set here at apply, and a run a trigger starts is handed that trigger's last completed `result.output` after its message. `checkout` (agentic only): `pull_request` has the server check out, before each run's first turn, the pull request the run's GitHub event names, in `repo/` at its head with its base and merge base, using a read-only token of its GitHub App that the agent never holds ([GitHub triggers](#github-triggers-connect-github)); `none` clears it, and an edit that leaves it out keeps it. A field the store does not keep (`input_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)). |
|
|
2708
|
-
| `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
|
|
2884
|
+
| `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`, the agent's default cap (an agentic agent's or a workflow's), kept by an edit that leaves it out and cleared only by 0 ([spend cap](#spend-cap)), and `output_schema` (agentic only, at most 64 KiB): the JSON Schema the final answer's last fenced json block meets, which a completed run's `result.output` then holds (null when the answer doesn't meet it), kept by an edit that leaves it out. A template's answer schema is set here at apply, and a run a schedule trigger starts is handed that trigger's last completed `result.output` after its message; no other source's runs are, since each of their firings is a different event. `checkout` (agentic only): `pull_request` has the server check out, before each run's first turn, the pull request the run's GitHub event names, in `repo/` at its head with its base and merge base, using a read-only token of its GitHub App that the agent never holds ([GitHub triggers](#github-triggers-connect-github)); `none` clears it, and an edit that leaves it out keeps it. A field the store does not keep (`input_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)). It also adds `run_blockers` (`x-agentrun-serve: "runblockers/1"`): `{message, fields}` as a start with no overrides would be refused now (`409 agent_not_runnable`), or null. It is always null for an archived, native or SDK agent and for a revision whose MCP tools its first run pins, and the read asks no other service, so under the agent's `max_cost_usd` an OpenRouter decision model's missing price is named only once a save or a start has read OpenRouter's catalog: null is no promise that a start is accepted. |
|
|
2885
|
+
| `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 and name stay those it was made with (another name is `422` on `definition.name`). Its description is a label kept on the agent, not on a revision: a PUT that names a new one makes the next revision (even when nothing else changed) and writes the description with it in one commit, so a stale or refused edit changes neither; a PUT that leaves it out keeps it. `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. |
|
|
2709
2886
|
| `GET /agents/{id}/revisions` | The agent's revisions, newest first: `revision`, `version`, `parent`, `kind`, `current`, `note`, `created_at` and the `definition`. |
|
|
2710
2887
|
| `POST /agents/{id}/current` | `{revision}`: one of the agent's revisions becomes current again. |
|
|
2711
2888
|
| `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`. |
|
|
@@ -2713,7 +2890,7 @@ failed, 2 when nothing ran. The runner, the graders and the report are in
|
|
|
2713
2890
|
| `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, or while a run it was handed is still going. |
|
|
2714
2891
|
| `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. `labels` (this server's own, `runlabels/1`) is the caller's map of its own strings for the run: at most 16 keys, each 1 to 63 letters, digits, `.`, `_`, `-` or `/` starting with a letter or a digit, each value 1 to 256 characters with no control character; kept as given, served as `labels` on every read of the run (`{}` when none), never read by the server otherwise, so no place for a secret. The agent's runs, newest first; `label` filters them as `GET /runs` does. |
|
|
2715
2892
|
| `GET /runs` | Every agent's runs, newest first, a page of at most 100; `agent`, `revision` and `status` narrow it, `label=<key>:<value>` (`runlabels/1`, split at the first `:`, once per request) keeps the runs holding that label, and `archived=true` lists only archived ones. A failed run's summary carries its `error`, and a waiting run's its `pending`. |
|
|
2716
|
-
| `GET /runs/{id}` | The run: its revision, kind, status, state, result, error, `pending` (this server's own, `pending/1`: what a waiting run waits on, by `kind`: `{kind: "question", question, asked_at}` for a question it asked a person; `approval` for a tool call held for a person's approval, with the tool, its arguments and its price; `budget` for a run paused at its cap ([a run paused at its cap](#a-run-paused-at-its-cap)); `{kind: "browser", instruction, completion_condition, asked_at, expires_at}` for its agent's ask for the owner in its browser; or `{kind: "computer", computer: "desktop" \| "phone", instruction, completion_condition, asked_at, expires_at}` for its agent's ask for the owner on its desktop or phone; else null, a stopped turn's included) and cost (`basis
|
|
2893
|
+
| `GET /runs/{id}` | The run: its revision, kind, status, state, result, error, `pending` (this server's own, `pending/1`: what a waiting run waits on, by `kind`: `{kind: "question", question, asked_at}` for a question it asked a person; `approval` for a tool call held for a person's approval, with the tool, its arguments and its price; `budget` for a run paused at its cap ([a run paused at its cap](#a-run-paused-at-its-cap)); `{kind: "browser", instruction, completion_condition, asked_at, expires_at}` for its agent's ask for the owner in its browser; or `{kind: "computer", computer: "desktop" \| "phone", instruction, completion_condition, asked_at, expires_at}` for its agent's ask for the owner on its desktop or phone; else null, a stopped turn's included) and cost (`basis` `reported`, `estimate` or `unpriced`, with its model requests' `tokens`: [A run's cost](#a-runs-cost-its-tokens-and-its-basis); $0 before its first model request, a cancelled run's included). |
|
|
2717
2894
|
| `GET /runs/{id}/timeline` | JSON pages with the change-number cursor (`after`, `next_after`, `reset`, `drop`, `has_more`, `final`, `wait_ms` long poll, and this server's own `limit`, 1 to 500 rows a page, default 500), or server-sent events with `Accept: text/event-stream` (`id` is the cursor, `Last-Event-ID` resumes). Rows sort by `seq`; the usage row (`Cost so far`), the run's running total, is always the last row, and moves to the end when a row comes after it. |
|
|
2718
2895
|
| `POST /runs/{id}/messages` | To an agentic run: `steer` while the agent works, `answer` when it asked the person, `follow_up` after a stop or after it completed: a completed run opens again, the same run on its own session and store, takes a place under `--max-runs` (it waits for one when none is free), and completes again. A failed or cancelled run, an archived run and a run of an archived agent are `409 not_continuable` (a run of an agent [being deleted](#deleting-an-agent-another-system-owns), `409 agent_not_runnable`); a workflow run takes none (`501`). |
|
|
2719
2896
|
| `POST /runs/{id}/stop`, `POST /runs/{id}/cancel` | Stop ends an agentic run's turn and leaves the run `input_required` and idle. Cancel ends a run `cancelled` once its process has exited. |
|
|
@@ -2721,7 +2898,7 @@ failed, 2 when nothing ran. The runner, the graders and the report are in
|
|
|
2721
2898
|
| `GET /runs/{id}/files`, `GET /runs/{id}/files/{path}` | The files under the run's `work/`, raw, one byte range at a time on asking (`Range`, `206`); and its screen recordings under `recordings/` ([A video of each run](#computers)). |
|
|
2722
2899
|
| `POST /files`, `PUT /files/{id}`, `GET /files`, `GET` and `DELETE /files/{id}` | [Uploads](#uploads): a file sent in one call (`POST /v2/files?path=...`, its bytes the body), or reserved and then sent (`PUT /v2/files/{id}`); the server's uploads listed, read and deleted. |
|
|
2723
2900
|
| `GET /agents/{id}/home/files`, and `GET`, `PUT`, `DELETE` on a file's path below it | The files in the agent's home, listed, read, written and deleted ([agent home](#agent-home)). This server's own routes (`x-agentrun-serve: "home/1"`). |
|
|
2724
|
-
| `GET /stats` | This server's own route, outside the contract (`x-agentrun-serve: "stats/1"`): the agents, the runs (`total`, `active`, `needs_input`, `failed`, `needs_review`, `status_unknown`), each agent's run count, the cost and what is archived, read from the agent store's aggregates alone, no run's files opened. Archived agents and runs are left out of every number but `archived`. A completed or cancelled run counts only in `runs.total`, but for an escalated one (completed, waiting for a person's review), which `needs_review` (`stats/3`) counts; `failed` never does. Each running run is in exactly one of `active` (queued or working) and `needs_input` (`input_required`), both from the runs this server holds, and `status_unknown`: a running run it does not hold, or holds as ended before its end is written. `cost.usd` sums the runs that ended with a cost and is null when none did, never $0, with `basis` `
|
|
2901
|
+
| `GET /stats` | This server's own route, outside the contract (`x-agentrun-serve: "stats/1"`): the agents, the runs (`total`, `active`, `needs_input`, `failed`, `needs_review`, `status_unknown`), each agent's run count, the cost and what is archived, read from the agent store's aggregates alone, no run's files opened. Archived agents and runs are left out of every number but `archived`. A completed or cancelled run counts only in `runs.total`, but for an escalated one (completed, waiting for a person's review), which `needs_review` (`stats/3`) counts; `failed` never does. Each running run is in exactly one of `active` (queued or working) and `needs_input` (`input_required`), both from the runs this server holds, and `status_unknown`: a running run it does not hold, or holds as ended before its end is written. `cost.usd` sums the runs that ended with a cost and is null when none did, never $0, with `basis` (`reported`, `estimate` or `unpriced`: [A run's cost](#a-runs-cost-its-tokens-and-its-basis)), or null beside a null `usd`; `unknown_runs` counts the rest. `analytics` (`stats/2`) sums the runs' metrics over the runs not archived that the `from` and `to` query parameters (RFC 3339 date-times to the millisecond, an impossible one or a finer fraction refused; runs started in [`from`, `to`)) and `agent` pick, each optional, 400 when malformed: `filter` echoes them; `totals` (runs, completed, an escalated run included, `needs_review` (`stats/3`), failed, never an escalated run, `runs_with_metrics`, tokens and each token kind, requests, unmetered, `cost_usd` and `unknown_cost_runs`), `time` (`wall_ms` over the ended runs, `active_ms` where metrics have it), `by_harness_effort`, `by_day` (UTC), `by_source` (`live` or the import source) and the top 20 `tools`. A run with no metrics counts in `runs` and in no token sum. `learning` (`learning/1`) counts the runs that tried to learn over the same filters, from the store ([Learning](#learning)). The query bounds `analytics` and `learning` alone. |
|
|
2725
2902
|
| `GET /runs/{id}/graph` | A workflow run drawn, live: its workflow, the DSL's `workflowGraph`, each node's state (a map's items with their labels and the branch each route took for them, a route's branch), every decision with its receipt (answers, evidence, the state the judge saw, image links), every call with its input and output, and the totals (cost, null when any part is unknown). While the run goes it reads the run process's `live.json`, rewritten every 300 ms, never the run's store, which the process holds; once it ended, its store is read lock-free, so a poll never waits on it and never answers `home_busy`. An agentic run has none (`404`). |
|
|
2726
2903
|
| `GET /runs/{id}/trace` | A run's trace, for a person who debugs it: each model request that answered and each tool call as one span, in the order they started. A span has its `kind` (`model` or `tool`), its `name` (the model, or the tool), when it started and ended, how it ended (`status`), and the span it ran under (`parent_id`: the request that made a call, the call a subagent's request was started by). A model request also has its `tokens` (`input` not read from cache, `cache_read`, `cache_write`, `output`, and `reasoning` where reported), and its `usd`. A tool call also has the head of its arguments and of its output, as its Timeline rows show them, and what was charged under it (`usd`, `charged`, `not_metered`). A call that asked for approval ends as its approval did: `waiting` until it is answered, `refused` on a deny, `interrupted` when it was withdrawn with its run. Nothing is measured again or estimated: `model_requests` says what the run's record keeps. `priced`: each request is a span with its cost. `tokens_only`: a workflow run. Its model nodes' requests carry tokens and no cost, since the run's cost is its booking's; each of its decisions (a judge's, a route's, a verify's request) is a span too (`decision: true`), named by the model its provider answered with and labelled by its node, with its own cost. `not_recorded`: a CLI harness's record keeps no request, so its trace is its tool calls. A computer's own time is its provider's to bill and is in no span. Readable while the run goes; one read serves the run's first 2,000 spans and counts the rest in `dropped`. Its words are cut as the Timeline's are, and a run whose handed sign-in can't be read back is refused (`403`), as its graph is. The console's Dev tools tab reads it. |
|
|
2727
2904
|
| `POST /runs/{id}/pause`, `POST /runs/{id}/resume` | A workflow run: what is in flight finishes, and no node, model call or decision starts until it is resumed. Its status reads `paused`, and stays so across a server restart. An agentic run is `501`, an ended one `409`. |
|
|
@@ -2736,7 +2913,7 @@ failed, 2 when nothing ran. The runner, the graders and the report are in
|
|
|
2736
2913
|
| `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. |
|
|
2737
2914
|
| `GET /templates`, `POST /templates/{name}/apply` | [Templates](#templates), this server's own routes (`x-agentrun-serve: "templates/1"`): the template packages it ships, and an apply that makes one's agent and triggers, all or nothing. |
|
|
2738
2915
|
| `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`. |
|
|
2739
|
-
| `GET /usage` | The runs'
|
|
2916
|
+
| `GET /usage` | The runs' costs, 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. `basis` says how the costs were reached ([A run's cost](#a-runs-cost-its-tokens-and-its-basis)). |
|
|
2740
2917
|
|
|
2741
2918
|
Quotes answer `501 unsupported_here` naming the feature. Home export and import (`GET` and `PUT /agents/{id}/home`) and
|
|
2742
2919
|
`POST /runs/{id}/kill` are not served here: they answer `404`, and the served document leaves them out (its
|
|
@@ -2986,6 +3163,22 @@ OPENROUTER_API_KEY (401: User not found): set it where AgentRun starts, or save
|
|
|
2986
3163
|
harness, with the provider's first sentence only.
|
|
2987
3164
|
Every request to OpenRouter carries AgentRun's app attribution (`HTTP-Referer: https://github.com/Parcha-ai/agentrun`, `X-OpenRouter-Title: AgentRun`), so a self-hosted server's usage on its own key counts toward AgentRun's listing on OpenRouter; `AGENTRUN_OPENROUTER_ATTRIBUTION=off` where AgentRun starts sends none.
|
|
2988
3165
|
|
|
3166
|
+
**Claude Code through a gateway.** Set `ANTHROPIC_BASE_URL` to a gateway that speaks Anthropic Messages, such as
|
|
3167
|
+
LiteLLM's `/v1/messages`, and `ANTHROPIC_API_KEY` to the key it wants, or any placeholder when it adds its own. No
|
|
3168
|
+
Anthropic key is needed, and capabilities show claude-agent ready. The base follows `AGENT_MODEL_BASE_URL`'s rules: https,
|
|
3169
|
+
or plain http to this machine only, with one trailing `/v1` dropped. The gateway must:
|
|
3170
|
+
|
|
3171
|
+
- take `POST <base>/v1/messages` (Claude Code adds `?beta=true`) with the key in `x-api-key`, never as a bearer token, and
|
|
3172
|
+
accept the `anthropic-version` and `anthropic-beta` headers the pinned CLI sends;
|
|
3173
|
+
- accept Anthropic's own model ids (`claude-haiku-5-5`, with dashes);
|
|
3174
|
+
- report each answer's usage: the run is booked from it at serve's catalog price for that id. When the gateway's
|
|
3175
|
+
response carries a positive `x-litellm-response-cost` (LiteLLM's), that figure is booked instead, with the catalog's
|
|
3176
|
+
kept beside it; a missing, malformed or zero figure (LiteLLM writes 0 on a streamed answer) leaves the catalog price.
|
|
3177
|
+
|
|
3178
|
+
AgentRun asks Anthropic's token count only on `api.anthropic.com`, so through a gateway a run's `max_cost_usd` holds each
|
|
3179
|
+
request at a bound from its size instead. The same setting routes pi's Anthropic models (above). Contract test:
|
|
3180
|
+
`test/gateway-contract.test.mjs` ("claude-agent through ANTHROPIC_BASE_URL and ANTHROPIC_API_KEY").
|
|
3181
|
+
|
|
2989
3182
|
`claude-agent` loads the revision's skills itself: the model is shown each as `agentrun:<name>`, loads one with the Skill
|
|
2990
3183
|
tool and reads its other files with `read_skill_file`, and the system prompt holds the instructions alone. A skill the
|
|
2991
3184
|
adapter does not take (a name that is not lowercase letters, digits and dashes, a `SKILL.md` without front matter giving
|
|
@@ -3273,6 +3466,11 @@ CLAUDE.md or AGENTS.md and its skill folders, and each session becomes a run you
|
|
|
3273
3466
|
this machine, and the values of key-shaped environment variables are cut out of what it writes. Run it again and it takes
|
|
3274
3467
|
only what it has not taken already. Sessions written in the last 10 minutes wait for the next import.
|
|
3275
3468
|
|
|
3469
|
+
A run's cost is what its source recorded (Claude Code's and pi's). A session its source did not price, such as a Codex
|
|
3470
|
+
session, keeps the model catalog's estimate for its tokens beside an unknown cost, and every place that shows a run's
|
|
3471
|
+
cost reads that estimate, as an estimate: the run (`cost.usd`, basis `estimate`), its usage row, `GET /stats` and its
|
|
3472
|
+
analytics, and `GET /usage`. A session on a model the catalog does not price stays unknown.
|
|
3473
|
+
|
|
3276
3474
|
- `--dry-run` lists what it would import and writes nothing.
|
|
3277
3475
|
- `--from claude-code,codex,pi` picks the sources.
|
|
3278
3476
|
- `--include-deleted` also imports the sessions of project folders that no longer exist, such as a git worktree you
|
|
@@ -3564,6 +3762,40 @@ carry) and a token sent beside the session. So is every request on a server with
|
|
|
3564
3762
|
host commit, `learning: approved by a person: <file>`, with the trailers `Changed-By: user` and `Approved-Via: console`;
|
|
3565
3763
|
the log shows `by: {user: true, via: "console"}` at the commit's time.
|
|
3566
3764
|
|
|
3765
|
+
## A run's cost: its tokens and its basis
|
|
3766
|
+
|
|
3767
|
+
A run's `cost` (on `GET /runs/{id}` and on each row of `GET /runs`, `costbasis/1`) carries its model requests' tokens
|
|
3768
|
+
and says how its figure was reached.
|
|
3769
|
+
|
|
3770
|
+
- `tokens`: `input` (cached input left out: the whole input is `input + cache_read + cache_write`), `output`,
|
|
3771
|
+
`cache_read`, `cache_write`, `requests` (every model request the run's model proxy booked: its turns, its subagents,
|
|
3772
|
+
its side calls) and `unmetered` (those that reported no tokens: refused, cut or never answered). Read from each
|
|
3773
|
+
answer's usage as the provider or gateway reported it: OpenAI's Responses `usage.input_tokens` and `output_tokens`,
|
|
3774
|
+
Anthropic's Messages `usage` with its cache reads and writes, streamed or whole. Absent while the run has booked no
|
|
3775
|
+
model request and stored none; a native or SDK run reports its whole task's tokens at its end, with no request
|
|
3776
|
+
count, and none while any count is unknown. The model proxy forwards only those two APIs (`/v1/responses`,
|
|
3777
|
+
`/v1/messages`); no harness here sends Chat Completions through it.
|
|
3778
|
+
- `basis`: `reported` when every request priced had its provider's or gateway's own figure (LiteLLM's
|
|
3779
|
+
`x-litellm-response-cost` header, OpenRouter's usage `cost`); `estimate` when any was priced from a price table (the
|
|
3780
|
+
model catalog, `AGENT_MODEL_PRICE`, a cut request counted at its hold); `unpriced` when no request was priced (none sent,
|
|
3781
|
+
every one refused at $0, or none with a known figure). Paid tool calls and decisions are charged at their own figures
|
|
3782
|
+
and do not change it. A native, SDK or imported run's figure is its harness's own, an `estimate`; so is an imported
|
|
3783
|
+
session's catalog estimate where its source priced none ([importing your sessions](#importing-your-sessions)). LiteLLM writes no
|
|
3784
|
+
cost into a streamed answer's headers, so a run whose answers stream through LiteLLM reads `estimate`.
|
|
3785
|
+
- `tools_usd` (on `GET /runs/{id}` alone, `toolsusd/1`): the part of `usd` its paid tool calls cost (monid's endpoints,
|
|
3786
|
+
MCP tools with a saved price, Parallel behind `web_search` and `web_fetch`, browser time), as the run's ledger booked
|
|
3787
|
+
them, rounded as `usd` is. It is inside `usd`, never added to it: `usd` less `tools_usd` is what its model requests and
|
|
3788
|
+
decisions cost. A paid call in a learning run's end-of-run turn is learning's (in `learning_usd`), never in
|
|
3789
|
+
`tools_usd`. 0 when it made no paid call. Null while a paid call's charge is unknown (as `usd` is then); while the run
|
|
3790
|
+
is at work (until it ended, stopped or failed); for a learning run a follow-up opened again, whose `usd` is what its
|
|
3791
|
+
first round had cost; and for an imported, native or SDK run, whose `usd` is its import's or its harness's own figure
|
|
3792
|
+
and whose tool calls the server never books. Each call's own charge is its span's `usd` on `GET /runs/{id}/trace`.
|
|
3793
|
+
- `GET /stats` (`cost.basis`) and `GET /usage` (`basis`) say the same words over the runs they sum: `estimate` when any
|
|
3794
|
+
run's is, else `reported` when any run's is, else `unpriced`. A run whose end stored no basis (one that ended before
|
|
3795
|
+
this, or a workflow run: its run read still says its basis from its booking) counts as `estimate` when it cost anything.
|
|
3796
|
+
|
|
3797
|
+
The console shows the tokens beside the run's cost, and the figure says its basis: `$0.0042 est.`, `$0.0042 reported`.
|
|
3798
|
+
|
|
3567
3799
|
## Spend cap
|
|
3568
3800
|
|
|
3569
3801
|
A run may name `max_cost_usd`, an agentic run or a workflow run ([below](#a-workflow-run-under-its-cap)). A run that names none takes its agent's default,
|
|
@@ -4002,7 +4234,11 @@ carries no cost at all, as from a provider that does not price the model. The te
|
|
|
4002
4234
|
`GET /v2/capabilities` says `run_isolation: "uid"`.
|
|
4003
4235
|
- A platform that strips the image's file capabilities, or starts it with `no-new-privileges` (Docker's
|
|
4004
4236
|
`security_opt: no-new-privileges:true`, Kubernetes' `allowPrivilegeEscalation: false`), leaves the helper unable to
|
|
4005
|
-
switch: the runner then refuses to claim, saying so and naming the setting
|
|
4237
|
+
switch, or unable to start (a spawn `EPERM`): the runner then refuses to claim, saying so and naming the setting, and
|
|
4238
|
+
stays up claiming nothing, with no heartbeat (`runner --check` says it is not alive), until it is stopped, so the
|
|
4239
|
+
container keeps running. The server still serves its console and API (`GET /v2/health` reads the store and the disk,
|
|
4240
|
+
not a runner, and `GET /v2/capabilities` says `run_isolation: "process"`), and its runs wait queued until the setting
|
|
4241
|
+
is fixed and the server restarts. `AGENTRUN_RUN_USER=same` runs every run as
|
|
4006
4242
|
the runner's own user instead, still each in a process of its own, said on the runner's log at its start. Runners in
|
|
4007
4243
|
containers of their own on one `/data` volume each take slots from an `AGENTRUN_RUN_SLOT_FIRST` of their own
|
|
4008
4244
|
(`deploy/compose.yaml`: 0 and 128). A runner told to hold more runs (`--loops`, `AGENTRUN_MAX_RUNS`) than the slots
|