@parcha/agentrun-serve 0.1.0-beta.49 → 0.1.0-beta.51
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 +173 -9
- package/README.md +246 -39
- package/dist/agent-delete.d.ts +3 -2
- package/dist/agent-delete.js +29 -4
- package/dist/agents-store.js +7 -3
- package/dist/api-only.d.ts +8 -10
- package/dist/api-only.js +11 -12
- package/dist/capacity.d.ts +50 -0
- package/dist/capacity.js +49 -0
- package/dist/cli-learning/claude-wire.d.ts +41 -0
- package/dist/cli-learning/claude-wire.js +258 -0
- package/dist/cli-learning/cli.d.ts +11 -0
- package/dist/cli-learning/cli.js +241 -0
- package/dist/cli-learning/codex-worktree.d.ts +10 -0
- package/dist/cli-learning/codex-worktree.js +119 -0
- package/dist/cli-learning/connections.d.ts +62 -0
- package/dist/cli-learning/connections.js +87 -0
- package/dist/cli-learning/entry.d.ts +1 -0
- package/dist/cli-learning/entry.js +4 -0
- package/dist/cli-learning/evidence.d.ts +78 -0
- package/dist/cli-learning/evidence.js +492 -0
- package/dist/cli-learning/hook.d.ts +33 -0
- package/dist/cli-learning/hook.js +544 -0
- package/dist/cli-learning/install.d.ts +33 -0
- package/dist/cli-learning/install.js +335 -0
- package/dist/cli-learning/observation-proof.d.ts +14 -0
- package/dist/cli-learning/observation-proof.js +10 -0
- package/dist/cli-learning/policy.d.ts +48 -0
- package/dist/cli-learning/policy.js +363 -0
- package/dist/cli-learning/schema.d.ts +16 -0
- package/dist/cli-learning/schema.js +27 -0
- package/dist/cli-learning/state.d.ts +23 -0
- package/dist/cli-learning/state.js +61 -0
- package/dist/cli.js +24 -2
- package/dist/compute-cost.d.ts +101 -0
- package/dist/compute-cost.js +250 -0
- package/dist/console/assets/index-Bt1B51b7.js +733 -0
- package/dist/console/assets/index-sVftE9Ht.css +1 -0
- package/dist/console/index.html +2 -2
- package/dist/email/email-faux.d.ts +3 -1
- package/dist/email/email-faux.js +3 -2
- package/dist/email/routes.js +22 -12
- package/dist/eval-previous.d.ts +52 -0
- package/dist/eval-previous.js +164 -0
- package/dist/file-types.d.ts +2 -0
- package/dist/file-types.js +3 -1
- package/dist/harness-install.d.ts +6 -2
- package/dist/harness-install.js +40 -8
- package/dist/harness.d.ts +1 -1
- package/dist/harness.js +3 -2
- package/dist/learn/check.d.ts +8 -5
- package/dist/learn/check.js +25 -24
- package/dist/learn/repick.d.ts +22 -13
- package/dist/learn/repick.js +57 -56
- package/dist/learn/secrets.js +14 -3
- package/dist/learn/workflow-draft.d.ts +4 -0
- package/dist/learn/workflow-draft.js +10 -7
- package/dist/learned-workflow.js +8 -8
- package/dist/learning-setting.js +2 -2
- package/dist/learning-words.d.ts +1 -1
- package/dist/learning-words.js +1 -1
- package/dist/mcp-pin-first.js +2 -1
- package/dist/mcp-private-hosts.d.ts +24 -3
- package/dist/mcp-private-hosts.js +53 -3
- package/dist/model-gateway.d.ts +2 -0
- package/dist/model-gateway.js +3 -1
- package/dist/native/runtimes.d.ts +2 -0
- package/dist/native/runtimes.js +2 -0
- package/dist/observation/learning.d.ts +32 -0
- package/dist/observation/learning.js +66 -0
- package/dist/observation/observer.d.ts +8 -1
- package/dist/observation/observer.js +89 -9
- package/dist/observation/schema.js +12 -4
- package/dist/observation/usage-identity.d.ts +9 -0
- package/dist/observation/usage-identity.js +11 -0
- package/dist/openapi.js +113 -29
- package/dist/paid-calls.d.ts +13 -6
- package/dist/paid-calls.js +14 -8
- package/dist/run-launch.d.ts +16 -2
- package/dist/run-launch.js +6 -1
- package/dist/run-timeline-served.js +5 -3
- package/dist/run-usage.d.ts +23 -8
- package/dist/run-usage.js +100 -18
- package/dist/run-view.d.ts +2 -0
- package/dist/run-view.js +12 -7
- package/dist/runner/adapter-loop.d.ts +4 -0
- package/dist/runner/adapter-loop.js +44 -27
- package/dist/runner/adapter-run-spec.d.ts +8 -3
- package/dist/runner/adapter-run-spec.js +15 -8
- package/dist/runner/beside.d.ts +13 -0
- package/dist/runner/beside.js +27 -8
- package/dist/runner/big-writes.d.ts +33 -0
- package/dist/runner/big-writes.js +105 -0
- package/dist/runner/cli-run-spec.js +16 -8
- package/dist/runner/disk-free.d.ts +44 -0
- package/dist/runner/disk-free.js +96 -0
- package/dist/runner/feedback-round.d.ts +12 -8
- package/dist/runner/feedback-round.js +16 -30
- package/dist/runner/harness-loops.js +3 -1
- package/dist/runner/held.d.ts +4 -1
- package/dist/runner/journal-kinds.d.ts +1 -1
- package/dist/runner/learning-end.js +13 -4
- package/dist/runner/main.d.ts +17 -6
- package/dist/runner/main.js +187 -45
- package/dist/runner/metrics.d.ts +4 -0
- package/dist/runner/metrics.js +9 -0
- package/dist/runner/presence.d.ts +11 -2
- package/dist/runner/presence.js +31 -3
- package/dist/runner/run-child-host.d.ts +27 -17
- package/dist/runner/run-child-host.js +70 -116
- package/dist/runner/run-child.js +3 -0
- package/dist/runner/run-errors.js +2 -0
- package/dist/runner/runner-check.d.ts +51 -0
- package/dist/runner/runner-check.js +206 -0
- package/dist/runner/runner-metrics.d.ts +19 -0
- package/dist/runner/runner-metrics.js +49 -0
- package/dist/runner/runner.d.ts +37 -0
- package/dist/runner/runner.js +43 -3
- package/dist/runner/save-slots.d.ts +9 -0
- package/dist/runner/save-slots.js +91 -0
- package/dist/runner/sdk-loop.js +34 -22
- package/dist/runs-over-store.d.ts +8 -1
- package/dist/runs-over-store.js +57 -9
- package/dist/sdk/runs.d.ts +25 -6
- package/dist/sdk/runs.js +107 -35
- package/dist/sdk/runtimes.d.ts +19 -0
- package/dist/sdk/runtimes.js +23 -0
- package/dist/sdk/schema.d.ts +14 -8
- package/dist/sdk/schema.js +18 -6
- package/dist/server.d.ts +7 -0
- package/dist/server.js +151 -28
- package/dist/skills/agentrun-serve/SKILL.md +52 -7
- package/dist/start-switches.js +2 -0
- package/dist/stats.d.ts +4 -0
- package/dist/stats.js +1 -1
- package/dist/store/agent-body.d.ts +13 -2
- package/dist/store/agent-body.js +19 -4
- package/dist/store/dialect.d.ts +2 -0
- package/dist/store/dialect.js +1 -0
- package/dist/store/index.d.ts +3 -3
- package/dist/store/index.js +2 -2
- package/dist/store/postgres/connection.d.ts +5 -2
- package/dist/store/postgres/connection.js +19 -7
- package/dist/store/postgres/dialect.js +1 -0
- package/dist/store/postgres/migrate.d.ts +30 -0
- package/dist/store/postgres/migrate.js +72 -5
- package/dist/store/postgres/migration-lint.d.ts +8 -0
- package/dist/store/postgres/migration-lint.js +119 -0
- package/dist/store/postgres/migrations/0023_computer_interval_resources.sql +14 -0
- package/dist/store/postgres/migrations/0024_runner_capacity.sql +28 -0
- package/dist/store/postgres/store.d.ts +8 -3
- package/dist/store/postgres/store.js +31 -11
- package/dist/store/schema.d.ts +26 -4
- package/dist/store/schema.js +45 -4
- package/dist/store/sqlite/connection.d.ts +3 -3
- package/dist/store/sqlite/connection.js +3 -3
- package/dist/store/sqlite/run-launch.d.ts +9 -1
- package/dist/store/sqlite/run-launch.js +44 -0
- package/dist/store/sqlite/store.d.ts +19 -4
- package/dist/store/sqlite/store.js +180 -93
- package/dist/store/store-schema.d.ts +34 -0
- package/dist/store/store-schema.js +125 -0
- package/dist/store/store.d.ts +61 -2
- package/dist/store/store.js +13 -0
- package/dist/store-reads/analytics.d.ts +3 -2
- package/dist/store-reads/analytics.js +20 -8
- package/dist/store-reads/cap.d.ts +9 -5
- package/dist/store-reads/cap.js +28 -2
- package/dist/store-reads/decisions.d.ts +21 -0
- package/dist/store-reads/decisions.js +22 -0
- package/dist/store-reads/journal.d.ts +8 -2
- package/dist/store-reads/journal.js +27 -8
- package/dist/store-view.d.ts +9 -4
- package/dist/store-view.js +48 -25
- package/dist/template-eval.d.ts +15 -1
- package/dist/template-eval.js +92 -13
- package/dist/templates.d.ts +4 -3
- package/dist/templates.js +4 -3
- package/dist/timeline/labels.js +17 -0
- package/dist/tool-gate.d.ts +4 -2
- package/dist/tool-list.js +1 -0
- package/dist/tools.d.ts +6 -2
- package/dist/tools.js +13 -1
- package/dist/trigger-targets.d.ts +21 -5
- package/dist/trigger-targets.js +13 -10
- package/dist/unified-usage.d.ts +24 -0
- package/dist/unified-usage.js +400 -0
- package/dist/uploads-archil.d.ts +100 -0
- package/dist/uploads-archil.js +430 -0
- package/dist/uploads.d.ts +55 -1
- package/dist/uploads.js +185 -98
- package/dist/validate.js +1 -1
- package/dist/web-fake.d.ts +25 -0
- package/dist/web-fake.js +38 -1
- package/dist/web-save.d.ts +75 -0
- package/dist/web-save.js +235 -0
- package/dist/workspace/archil-claim.d.ts +5 -2
- package/dist/workspace/archil-claim.js +5 -2
- package/dist/workspace/archil-disk.d.ts +11 -1
- package/dist/workspace/archil-disk.js +43 -10
- package/dist/workspace/archil.d.ts +3 -0
- package/dist/workspace/archil.js +102 -16
- package/dist/workspace/computer-for-claim.d.ts +14 -0
- package/dist/workspace/computer-for-claim.js +46 -7
- package/dist/workspace/computer-intervals.d.ts +9 -3
- package/dist/workspace/computer-intervals.js +17 -8
- package/dist/workspace/pieced.d.ts +14 -0
- package/dist/workspace/pieced.js +23 -0
- package/dist/workspace/run-disk.js +32 -12
- package/dist/workspace/run-workspace.d.ts +1 -1
- package/dist/workspace/run-workspace.js +11 -6
- package/package.json +10 -10
- package/skills/agentrun-serve/SKILL.md +52 -7
- package/templates/README.md +36 -7
- package/dist/console/assets/index-Bzn4eUYF.js +0 -715
- package/dist/console/assets/index-CR2ZGei1.css +0 -1
package/README.md
CHANGED
|
@@ -10,16 +10,30 @@ runner starts beside the server. The capabilities document (`GET /v2/capabilitie
|
|
|
10
10
|
Already use Claude Code or Codex? Choose **Connect agent** in the console and select your coding agent from the
|
|
11
11
|
dropdown. Its skill asks whether to connect for future jobs, import past history, or both, then confirms the source
|
|
12
12
|
project and machine. No destination model key is needed for this connection: a live agent uses its existing native
|
|
13
|
-
sign-in and configuration. Turn **Self-improving** On separately to give later runs your
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
sign-in and configuration. Turn **Self-improving** On separately to give later runs your owner-written
|
|
14
|
+
corrections. Eligible server-run and SDK agents can also compile checked workflows; CLI capture has no workflow
|
|
15
|
+
bridge. Imported history stays historical and does not automatically train the agent.
|
|
16
16
|
|
|
17
17
|
For a source on a different laptop, VM or container, choose **Connection setup → Another machine** and use the
|
|
18
18
|
matching [Python source connector](../../connector/README.md). Remote execution currently needs the server and
|
|
19
19
|
connector from the same reviewed development checkout; the published observation-only CLI does not include it.
|
|
20
20
|
The source worker must stay online. See [Native agents](../../docs/native-agents.md) for setup, history scopes and
|
|
21
|
-
runtime limits. Connected agents use ordinary agent revisions
|
|
22
|
-
|
|
21
|
+
runtime limits. Connected agents use ordinary agent revisions; each connection declares whether it can launch runs
|
|
22
|
+
and execute checked workflows. The console shows server-run and source-connected agents in one inventory, with their
|
|
23
|
+
actual connection and activity state. A CLI capture profile linked to a source appears with that source; an unlinked
|
|
24
|
+
profile remains visible. A source session is not itself a recorded run. Managed adapter isolation is unchanged.
|
|
25
|
+
|
|
26
|
+
`GET /v2/observations` also reports `learning` for each observed session: `on`, `off`, `setup_required`,
|
|
27
|
+
`unknown` or `unsupported`, with a reason and verified profile IDs when available. Polling sources advertise
|
|
28
|
+
support through `cli_learning.session_association` in `/api/v2/control/connectors/capabilities`. A source may
|
|
29
|
+
attach `metadata.cli_learning` after matching the exact canonical project, runtime and server origin to an
|
|
30
|
+
existing private CLI learning connection. Its proof binds the connector, selected source, observed session,
|
|
31
|
+
runtime, connection, readiness, native-session hash and sequence using that connection's scoped credential.
|
|
32
|
+
The receiver stores verified identifiers, never the credential or proof, and returns no source paths or native
|
|
33
|
+
session hashes. On requires configured hooks and an accepted hook window for that exact native session;
|
|
34
|
+
configuration alone is `unknown` with `awaiting_activation`. Agent and server learning settings are read live.
|
|
35
|
+
Missing support, invalid proofs or revoked credentials do not interrupt activity or usage reporting. Delegated
|
|
36
|
+
subagents report `unsupported`. Observing a session never enrolls its project or changes its learning setting.
|
|
23
37
|
|
|
24
38
|
## Quick start (no key, no network)
|
|
25
39
|
|
|
@@ -362,6 +376,28 @@ entry (`max_concurrent_runs`, beside `run_memory_mib`).
|
|
|
362
376
|
A data directory serves one AgentRun Server at a time: a second server on the same data root is refused at start
|
|
363
377
|
(`server.lock`).
|
|
364
378
|
|
|
379
|
+
`GET /v2/capacity`, with the token, says how much room the runners have, read from the store alone. A server with no
|
|
380
|
+
runner beside it (`--no-runner`, `AGENTRUN_API_ONLY=1`) answers it for every runner on its store. Read it to size the
|
|
381
|
+
runners by backlog, not by CPU. It gives:
|
|
382
|
+
|
|
383
|
+
- `runs.queued`: the runs waiting for a runner now. These are queued runs, runs handed back or whose claim ran out (past
|
|
384
|
+
any backoff), and parked runs with something to wake them.
|
|
385
|
+
- `runs.executing`: the runs a live claim holds now, on any runner.
|
|
386
|
+
- `runners`: each runner that said it was there in the last 30 s, by name. Each has its build's `version`, its `slots`
|
|
387
|
+
(the most runs it holds at once), what it holds (`executing`), its `free_slots` and whether it `refused` to claim.
|
|
388
|
+
`version` and `slots` are null for a runner of an earlier build that is still running. (On Postgres, an earlier
|
|
389
|
+
runner refuses to start once the server has applied `0024_runner_capacity.sql`, so upgrade runners with the server.)
|
|
390
|
+
A runner also claims by its host's memory, so a free
|
|
391
|
+
slot is the most it may take.
|
|
392
|
+
- `free_slots`: the sum of the live runners' free slots.
|
|
393
|
+
- `hand_backs`: how many runs a runner gave back still running within `?window=` minutes (1 to 1440, default 15). A
|
|
394
|
+
drain, a loop that closed itself and a claim given back each count; a claim whose lease ran out does not.
|
|
395
|
+
|
|
396
|
+
It names no run, agent or address. Each runner also prints metric lines in the server's log format, which a log-based
|
|
397
|
+
metric counts: `runner_claimed` (`took_over=1` when it took over a run whose lease ran out), `runner_hand_back` with its
|
|
398
|
+
`cause` (`drain`, `interrupted`, `end_retry`, `give_back`, or `claim_lost` with its `why`), `runner_drained` once per close
|
|
399
|
+
that held a run (`ms`, `held`, `left`), and `runner_gauge` every minute (`active`, `slots`, `rss_mib`).
|
|
400
|
+
|
|
365
401
|
`GET /v2/health`, with no credential like capabilities, answers `200 {status: "ok", checks: {store: "ok", disk: "ok"}}`
|
|
366
402
|
when the agent store opens for a read and the data directory's disk has at least 64 MiB free (`AGENTRUN_MIN_FREE_MB`),
|
|
367
403
|
and `503` with `status: "failing"` and which check failed (`store: "does_not_open"`, `disk: "below_floor"`, or
|
|
@@ -375,8 +411,10 @@ time, writes nothing more to the run, and the store refuses any write under a cl
|
|
|
375
411
|
claim lapses another runner claims the run and resumes it from its journal. A run's own computer doesn't survive a
|
|
376
412
|
runner loss, a crash, a server stop or a park (the claim that resumes the run starts a new one, and says so on the
|
|
377
413
|
timeline and, once, to the model as an "AgentRun server note"), and the agent's own computer, a persistent setting, does. `agentrun-serve runner --check --data DIR --name N`
|
|
378
|
-
(or `AGENTRUN_RUNNER_NAME=N` in place of `--name`)
|
|
379
|
-
|
|
414
|
+
(or `AGENTRUN_RUNNER_NAME=N` in place of `--name`) checks the runner's environment by name (its store, its seal key,
|
|
415
|
+
every run-facing name its server holds, a forwarder on loopback) and whether the runner named `N` has a fresh
|
|
416
|
+
heartbeat: it exits 0 when both hold, 1 when either does not, and 2 when no name is given. `--check --env` checks the
|
|
417
|
+
environment alone, and `--check --heartbeat` the heartbeat alone ([deploy/README.md](../../deploy/README.md#the-runners-environment-runner---check)). Name a runner you start yourself with
|
|
380
418
|
`agentrun-serve runner --data DIR --name N`.
|
|
381
419
|
|
|
382
420
|
## Start-time switches
|
|
@@ -391,6 +429,7 @@ AGENTRUN_WEBHOOK_PRIVATE_TARGETS=1 to allow it, only on a machine you alone use`
|
|
|
391
429
|
| --- | --- | --- | --- |
|
|
392
430
|
| `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
431
|
| `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 |
|
|
432
|
+
| `AGENTRUN_PRIVATE_HOSTS` | Bounds the private-network hosts an owner may allow an MCP server or a calendar on (Settings → MCP servers): `none` allows none (and only an empty list can be saved), or a comma list of address ranges (`10.20.0.0/16,fd12:3456::/32`) every listed host's address must also fall in. Loopback, link-local (cloud metadata) and this machine's addresses stay refused whatever it says. A value that is neither reads as `none` | unset: the owner's list holds | On a server or runner many customers share, an owner's list would reach the operator's own private network: set `none` there, on the server and on each runner (each process holds to its own) |
|
|
394
433
|
| `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
434
|
| `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
435
|
|
|
@@ -1429,6 +1468,7 @@ agent_not_runnable`, with `details.unbound` and `details.missing`).
|
|
|
1429
1468
|
| `ask_person` | Ask the person who started the run; the turn ends until a message answers | nothing | no, no |
|
|
1430
1469
|
| `web_fetch` | Read one web page from a public host through the guarded direct fetch, or through Parallel's extract where Parallel is picked ([search and fetch](#search-and-fetch)), a part at a time: `{url, offset?, max_chars?}` in, a Page out, `{ok, url, status, title, text, chars, truncated?, original_chars?, beyond_read?, offset?, next_offset?, html_chars?, converted?, links, links_omitted?, via, parallel?, refused?, error?}` | nothing (`PARALLEL_API_KEY` for Parallel, one billed extract a page a run) | yes, yes |
|
|
1431
1470
|
| `web_search` | Search the web, natively where the harness or the model's provider can, else through Parallel where the server holds its key, else keyless through Exa, or through the provider picked ([search and fetch](#search-and-fetch)): `{query, n?}` in, `{provider, query, results: [{url, title, snippet, published?}], text?}` or `{error}` out | nothing (`PARALLEL_API_KEY` for Parallel) | yes, yes |
|
|
1471
|
+
| `web_save` | Download one file from a public URL into the run's `work/` and keep it there, for a link that expires (a generated image, audio or video): `{url, path}` in, `path` relative to `work/` and a bare name under `media/`; `{ok: true, path, bytes, content_type, url}` or `{ok: false, url, refused \| error}` out. Never overwrites | nothing | no, no |
|
|
1432
1472
|
| `browser` | A hosted browser, Browserbase's or Kernel's, on pi-browser's durable adapter: `snapshot`, `run`, `screenshot`, `browser_read`, `browser_release`, `browser_relaunch`, `browser_downloads` and `browser_upload` (into and from the run's `work/`); Kernel keeps no downloads, so a run on Kernel has no `browser_downloads` | `BROWSERBASE_API_KEY` and `BROWSERBASE_PROJECT_ID`, or `KERNEL_API_KEY` | yes, no |
|
|
1433
1473
|
| `monid:<provider>/<endpoint>`, `monid:<provider>/*` | One monid endpoint, or every endpoint monid lists for a provider (at most 50), each pinned at the save and run as a tool of its own, paid per call from the monid wallet: `{body?, queryParams?, pathParams?}` in, the run's `output`, `price` and `cost` out ([monid](#monid)) | `MONID_API_KEY` | no, no |
|
|
1434
1474
|
| `pdf_pages` | A workflow call only: `{path, maxPages?, dpi?}` in, `{name, pageCount, dpi, pages: [{page, image}], text}` out. Draws a document's first pages (3 by default, at 110 dpi) as PNGs under the run's `work/pages/<stem>/<dpi>/` (`<stem>`: the document's path below its directory made one name, with a short hash, so two documents of one file name never share pages), the dpi lowered so a page's long side is at most 1568 px, with its text (`pdftotext`, cut at 20,000 characters). A PNG or JPEG passes through as one page, scaled down to 1568 px. `path` is under `--documents` or the run's `work/`, never outside | `pdftoppm`, `pdftotext` | no, yes |
|
|
@@ -1471,6 +1511,14 @@ can branch on it. An agent gets the Page as JSON text; a workflow's `call` node
|
|
|
1471
1511
|
it as its output (`args: {url, offset?, max_chars?}`, 50,000 characters of text by default, `out` a schema of that
|
|
1472
1512
|
shape). A call node naming a tool the table cannot run that way is refused before the run starts (`409`).
|
|
1473
1513
|
|
|
1514
|
+
`web_save {url, path}` downloads one public file through the same guard (pi-browser's `publicDownload`, the same hop
|
|
1515
|
+
loop), at most 200 MiB in at most 10 minutes, into the run's Workspace (a bare name goes under `media/`), so `..`, an
|
|
1516
|
+
absolute path and a link are refused, and a path already in use is refused, never overwritten. The file is written once,
|
|
1517
|
+
after the whole download, so a failed one leaves nothing. An image, audio or video is saved only when its bytes, the
|
|
1518
|
+
declared type and the path's extension agree (`media/card.png`, never `media/card`); any other type only to a path whose
|
|
1519
|
+
extension names the declared type. It makes no paid request and is never run again after a crash. Only an agent that
|
|
1520
|
+
names `web_save` has it; no workflow node or call node may name it.
|
|
1521
|
+
|
|
1474
1522
|
On another harness, every host tool's result reaches the model within the host's bound of 120,000 characters
|
|
1475
1523
|
(`HOST_RESULT_MAX_CHARS`, `@parcha/agentrun-kernel`): the kernel's tool bridge cuts a longer one, its start with a line
|
|
1476
1524
|
saying where it was cut, and flags the call `truncated`. Each CLI adapter tells its CLI to pass a result that long to
|
|
@@ -1677,9 +1725,11 @@ Parallel's fees are the run's spend, booked as monid's are: each search and each
|
|
|
1677
1725
|
run's records before it is sent (`agentrun.tool_started`, held at its price) and settled once Parallel answers
|
|
1678
1726
|
(`agentrun.tool_cost`: `tool` `web_search` or `web_fetch`, `charged_by` `"parallel"`, `usd`), shown on its timeline
|
|
1679
1727
|
(`Tool cost: parallel charged $0.0010 for web_search`), summed into its cost and under `/usage`'s `tools` meter. Parallel
|
|
1680
|
-
answers what it used as counts, never an amount, so each is booked at Parallel's published price
|
|
1681
|
-
read 2026-11-
|
|
1682
|
-
|
|
1728
|
+
answers what it used as counts, never an amount, so each is booked at Parallel's published price
|
|
1729
|
+
([docs.parallel.ai/resources/pricing](https://docs.parallel.ai/resources/pricing), read 2026-11-20), an estimate: a
|
|
1730
|
+
search by its mode, `turbo` or `fast` $0.001 and `basic` or `advanced` $0.005, each for up to 10 results, and $0.001 for
|
|
1731
|
+
each result past them (`web_search` always searches `fast`); an extract $0.001 a URL. A search in a mode with no price
|
|
1732
|
+
here, or naming none, is never sent, as an endpoint with no price is not; on a 4xx other than a 408 nothing (Parallel refused it), and on a 408, a 5xx, a timeout or a lost
|
|
1683
1733
|
connection its price (Parallel may have billed it). Under a [spend cap](#spend-cap) each is a paid call: sent only when
|
|
1684
1734
|
what the run has spent and holds, plus its price, fits the cap. Otherwise nothing reaches Parallel: a search answers the
|
|
1685
1735
|
cap's refusal (`spend_cap_reached: Not sent: this run has spent $0 of its $0.0009 cap, and the next step, Parallel's search, could cost up to $0.001 …`) and a page is the
|
|
@@ -2818,7 +2868,9 @@ account's app password (Gmail, iCloud and Fastmail each make one in the account'
|
|
|
2818
2868
|
sign-in password is refused by most providers), at most 1,024 characters. It is sealed under the server's seal key
|
|
2819
2869
|
(`AGENTRUN_SEAL_KEY`) and is in no answer, event or log line. Every connection is TLS: 993 and 465 from the start, any
|
|
2820
2870
|
other port with STARTTLS required. Only `127.0.0.1` is reached in the clear. `POST /v2/settings/email/test` signs in to
|
|
2821
|
-
both servers and sends nothing
|
|
2871
|
+
both servers and sends nothing. A save signs in the same way first: an account either server refuses, or one a server
|
|
2872
|
+
can't be reached for, is 424 `upstream_failed` in the test's words (`details.imap` and `details.smtp`), with nothing
|
|
2873
|
+
saved and any account saved before kept as it was. `DELETE` forgets the account.
|
|
2822
2874
|
|
|
2823
2875
|
**The trigger.** `{kind: "email", mailbox?: "INBOX", every_s?: 60, accept?}` reads the mailbox every `every_s` seconds
|
|
2824
2876
|
and starts a run for each new message its `accept` takes (a rule's `where` reads `/from`, `/to`, `/subject`, `/text`).
|
|
@@ -2846,7 +2898,8 @@ after asks, saying "this run has sent 5 emails" (the count is the run's own reco
|
|
|
2846
2898
|
stops two auto-responders answering each other. On a run an email started whose `email_read` is thread-scoped (no
|
|
2847
2899
|
`scope: "mailbox"`), a send to anyone outside the thread's people
|
|
2848
2900
|
(the account's own address and every From, To and Cc of the thread's messages) asks too, naming them ("eve@example.com
|
|
2849
|
-
is outside this email's thread"). The approval
|
|
2901
|
+
is outside this email's thread"). The pending approval carries the reason as `asks_because`, which the console's card
|
|
2902
|
+
says above the call's arguments ("Asks because ..."). With accounts off, where no one can
|
|
2850
2903
|
approve, such a send is refused in those words.
|
|
2851
2904
|
|
|
2852
2905
|
## Templates
|
|
@@ -2883,6 +2936,7 @@ failed, 2 when nothing ran. The runner, the graders and the report are in
|
|
|
2883
2936
|
| Route | Here |
|
|
2884
2937
|
| --- | --- |
|
|
2885
2938
|
| `GET /health` | Without a credential: whether the store reads and the disk has room ([capacity and health](#capacity-and-health)). |
|
|
2939
|
+
| `GET /capacity` | This server's own (`capacity/1`): the runs waiting for a runner and held by one, each live runner's version, slots and free slots, and the hand-backs within `?window=` minutes, read from the store ([capacity and health](#capacity-and-health)). Served under `AGENTRUN_API_ONLY=1` too. |
|
|
2886
2940
|
| `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. |
|
|
2887
2941
|
| `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. |
|
|
2888
2942
|
| `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. Over 32 KiB, a scheduled run is handed only the fields the producing run's schema names in `x-carried`; carried arrays lose entries from the front until they fit, and the run is told how many. A save refuses an `x-carried` that is not unique root property names. `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. |
|
|
@@ -2903,9 +2957,9 @@ failed, 2 when nothing ran. The runner, the graders and the report are in
|
|
|
2903
2957
|
| `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)). |
|
|
2904
2958
|
| `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. |
|
|
2905
2959
|
| `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"`). |
|
|
2906
|
-
| `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
|
|
2960
|
+
| `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 and verified source reports; source completion counters are read when needed to separate overlapping usage. 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`, `runs_with_token_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`. Token totals sum only runs with every token counter reported, counted by `runs_with_token_metrics`; other runs remain in `runs` but cannot hide the known partial total. If runs exist but none reports a complete count, `tokens` is null; an empty scope is zero. Individual token-kind totals remain null when a measured run reports that counter as unknown. `analytics.usage` combines recorded runs and connected source reports ([Unified token usage](#unified-token-usage)). `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. |
|
|
2907
2961
|
| `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`). |
|
|
2908
|
-
| `GET /runs/{id}/usage` | This server's own (`runusage/1`): what one run cost, line by line: its model requests by model and provider, its paid tool calls by who charged for them, its browser time by provider, joining to its `cost.usd` ([A run's cost, line by line](#a-runs-cost-line-by-line)); beside them its browser sessions (`runusage/2`) and the computers it made, each from its create to its proven delete (`runusage/3`). Lines once the run ended; `reason` says why there are none. |
|
|
2962
|
+
| `GET /runs/{id}/usage` | This server's own (`runusage/1`): what one run cost, line by line: its model requests by model and provider, its paid tool calls by who charged for them, its browser time by provider, its computers' time by provider and resource (`runusage/4`), joining to its `cost.usd` ([A run's cost, line by line](#a-runs-cost-line-by-line)); beside them its browser sessions (`runusage/2`) and the computers it made, each from its create to its proven delete (`runusage/3`). Lines once the run ended; `reason` says why there are none. |
|
|
2909
2963
|
| `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. |
|
|
2910
2964
|
| `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`. |
|
|
2911
2965
|
| `POST /workflows/validate` | `{workflow, tools?}`: every issue a save would refuse (`[{path, code, message}]`, the DSL's validation with code not run) and what this host lacks as `warnings`. Writes nothing. A refused save's `422` carries each issue as a field under `definition.workflow`, with its `code`. |
|
|
@@ -2919,13 +2973,60 @@ failed, 2 when nothing ran. The runner, the graders and the report are in
|
|
|
2919
2973
|
| `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. |
|
|
2920
2974
|
| `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. |
|
|
2921
2975
|
| `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`. |
|
|
2922
|
-
| `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)). |
|
|
2976
|
+
| `GET /usage` | The runs' costs, by meter, agent, key, day or region (`key` and `region` are one line, `local`). By meter, `tools` holds the runs' paid tool calls and the workflow decisions Parallel charged on its own API, as `cost.tools_usd` does. 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)). |
|
|
2923
2977
|
|
|
2924
2978
|
Quotes answer `501 unsupported_here` naming the feature. Home export and import (`GET` and `PUT /agents/{id}/home`) and
|
|
2925
2979
|
`POST /runs/{id}/kill` are not served here: they answer `404`, and the served document leaves them out (its
|
|
2926
2980
|
`info.x-agentrun-serve.not_served` lists them). Capabilities declare each of the four false. No run waits out `input_wait_s` here (`null`). `limits.max_cost_usd` is the highest cap a run may name: `null` here, as any cap
|
|
2927
2981
|
above $0 is taken; it does not mean caps are unsupported ([spend cap](#spend-cap)).
|
|
2928
2982
|
|
|
2983
|
+
### Unified token usage
|
|
2984
|
+
|
|
2985
|
+
`GET /stats` includes `analytics.usage`, the dashboard's single reported token total across recorded runs and
|
|
2986
|
+
connected source sessions. It contains `tokens`, uncached `input`, `output`, `cache_read`, `cache_write`, `by_day`
|
|
2987
|
+
and `by_harness`. A source's inclusive input plus output can establish its total even when its cache breakdown is
|
|
2988
|
+
unavailable; the unavailable breakdown remains null. Run counts, outcomes, time and cost retain their existing
|
|
2989
|
+
meaning and do not treat an observed session as a completed run.
|
|
2990
|
+
|
|
2991
|
+
`known_runs` counts usable run contributions; `unknown_runs` marks missing counters or unresolved overlap.
|
|
2992
|
+
`observed_sessions` counts source identities with usable reports in scope, including when another view supplies
|
|
2993
|
+
the selected total; `unknown_sessions` marks missing or
|
|
2994
|
+
incomplete source coverage. Known and unknown counts can overlap: a selected aggregate can supply a lower bound
|
|
2995
|
+
without proving complete coverage. A verified native session hash and runtime link observations to CLI prompt windows,
|
|
2996
|
+
native runs, SDK runs or imported sessions. Same-source aggregates are added only when their windows prove they
|
|
2997
|
+
do not overlap. When retained daily source reports and run counters may overlap without an exact intersection,
|
|
2998
|
+
the result is a conservative lower bound and `unknown_runs` marks incomplete coverage, even when every source
|
|
2999
|
+
reported its counters. Offline prompt captures may arrive on a later day, so server timestamps alone do not
|
|
3000
|
+
prove their usage is separate from source day buckets. An imported root can include descendants with no retained
|
|
3001
|
+
identity. When its journal exactly reconciles with its saved counters, the root’s own usage can be separated and
|
|
3002
|
+
counted against source reports. Its full aggregate remains an alternative to the same runtime’s native total;
|
|
3003
|
+
the larger coherent view is retained, never added to that total. An unavailable or inconsistent journal uses the
|
|
3004
|
+
same conservative alternative. Unresolved descendant coverage stays in `unknown_runs`.
|
|
3005
|
+
CLI/SDK run metrics may also contain reflection in a separate session. When both the full metrics and immutable
|
|
3006
|
+
source completion counters are known, their nonnegative difference remains included. Historical CLI native
|
|
3007
|
+
reflections can themselves appear in source observations; when that overlap is possible, their full run is a
|
|
3008
|
+
runtime alternative too. Purged runs retain numeric counters but no private source identity: native counters
|
|
3009
|
+
remain conservative alternatives to potentially overlapping source views. Otherwise an unproven remainder is
|
|
3010
|
+
counted in `unknown_runs` coverage rather than silently discarded or guessed as zero.
|
|
3011
|
+
Historical identity remains valid when learning is
|
|
3012
|
+
disabled or revoked. Archiving a learning profile does not disconnect its observed source. Multiple collectors
|
|
3013
|
+
reporting the same verified session use the copy with the largest reported total for each UTC day, then the freshest
|
|
3014
|
+
receipt and stable session id. Disjoint days remain included; overlapping same-day copies are never added because
|
|
3015
|
+
the server retains daily aggregates rather than request identities. This may leave unknown coverage when collectors
|
|
3016
|
+
hold disjoint requests within the same day; their aggregate intersection cannot be inferred. The selected figure
|
|
3017
|
+
is then a lower bound, not a complete count of that session.
|
|
3018
|
+
Unbound observations have no native identity proof and remain distinct. Display names and project labels never
|
|
3019
|
+
establish identity, so an unbound collector cannot deduplicate a separately recorded run.
|
|
3020
|
+
|
|
3021
|
+
Run tokens use the run's start date. Source tokens use the UTC day on which usage was observed, not a session's
|
|
3022
|
+
lifetime total or an inferred request date. Only daily buckets fully inside `[from, to)` are counted; `partial_days`
|
|
3023
|
+
reports boundary days excluded because their aggregate cannot be split exactly. With no `to`, today's reported
|
|
3024
|
+
usage is included. Source history is retained for 90 days; `retention_limited` says the requested range extends
|
|
3025
|
+
beyond it. These figures are reported coverage, not a claim that unobserved history cost zero.
|
|
3026
|
+
|
|
3027
|
+
`agent` may select a recorded agent and its associated sessions, or a connected session id (`os_...`) for only that
|
|
3028
|
+
session's usage. The latter selects no recorded runs. It does not import or create an agent definition.
|
|
3029
|
+
|
|
2929
3030
|
### Feed triggers
|
|
2930
3031
|
|
|
2931
3032
|
A feed trigger starts a run for each new or updated item in one or more feeds: RSS (2.0 and 1.0), Atom, JSON Feed, or a
|
|
@@ -2976,7 +3077,10 @@ item (`["/number", "/title", "/html_url", "/user/login"]`): `item` then keeps on
|
|
|
2976
3077
|
serves these routes alone:
|
|
2977
3078
|
|
|
2978
3079
|
- a run's launch (`POST /agents/{id}/runs`, `POST /runs`), read (`GET /runs/{id}`), lists (`GET /agents/{id}/runs`,
|
|
2979
|
-
`GET /runs`), timeline, messages, stop, cancel, kill (`501` here, as above)
|
|
3080
|
+
`GET /runs`), timeline, messages, stop, cancel, kill (`501` here, as above), cap raise (`PATCH /runs/{id}`) and grade
|
|
3081
|
+
(`PUT /runs/{id}/grade`);
|
|
3082
|
+
- a run's usage lines (`GET /runs/{id}/usage`): what its `cost.usd` joins, by meter, cut of the host's secrets as the
|
|
3083
|
+
run's read is;
|
|
2980
3084
|
- its files (`GET /runs/{id}/files`, `GET /runs/{id}/files/{path}`) and [uploads](#uploads) (`/files`);
|
|
2981
3085
|
- an agent's Archil disk (`GET` and `DELETE /agents/{id}/archil`);
|
|
2982
3086
|
- the [delete of an agent another system owns](#deleting-an-agent-another-system-owns) (`DELETE /agents/{id}`), for
|
|
@@ -2985,7 +3089,13 @@ serves these routes alone:
|
|
|
2985
3089
|
key names and whether each is saved, and whether it is ready) and `GET /workspace/archil` (whether runs' folders are
|
|
2986
3090
|
on Archil, and whether its account key is saved). Neither answers a key's value. Their writes, tests and key choices
|
|
2987
3091
|
are the console's, refused here;
|
|
2988
|
-
-
|
|
3092
|
+
- what an agent learned, for the backend whose runs it learned from: the loop's compile turns
|
|
3093
|
+
(`GET /agents/{id}/learning/loop`), each learned workflow's promotion and what serves
|
|
3094
|
+
(`GET /agents/{id}/learning/promotions`), the cost per run (`GET /agents/{id}/learning/cost`) and a run's learning
|
|
3095
|
+
(`GET /runs/{id}/learning`), each cut of the host's secrets as the console's reads are;
|
|
3096
|
+
- a run's hosted machine fetching this server's computerd build (`GET /computers/daemon`), with the token its create
|
|
3097
|
+
minted;
|
|
3098
|
+
- `GET /capabilities`, `GET /health`, `GET /usage` and `GET /capacity`;
|
|
2989
3099
|
- a run's desktop or phone, for a backend that shows its user the live view and lets them take over: see below.
|
|
2990
3100
|
|
|
2991
3101
|
Here a run's computer routes take the server's token. `POST /runs/{id}/computer/viewer` mints a 5-minute link on
|
|
@@ -3049,6 +3159,25 @@ upload stays in the runs that copied it; a run started after names it in vain. E
|
|
|
3049
3159
|
logs `event=uploads_swept removed=N`. `upload.expires_at`, which the contract requires, is advisory and not enforced in
|
|
3050
3160
|
this release: a `PUT` after it is still taken.
|
|
3051
3161
|
|
|
3162
|
+
With Archil on (Mode 2), uploads live on Archil, not in `DIR`, so a runner needs no disk of the server's. The server
|
|
3163
|
+
keeps them on an Archil disk of its own, `agentrun-<server id>-files`, made by its first upload, at
|
|
3164
|
+
`files/<file_id>/` (the same bytes and record). Listing, reading and deleting read that disk; the routes, limits and
|
|
3165
|
+
answers are the ones above, but the bytes are held in the server's memory (up to 50 MiB a file) instead of streamed to
|
|
3166
|
+
disk. When a run is started with `file_ids`, the server copies each file into the run's folder on its disk, at
|
|
3167
|
+
`work/inputs/<path>` (the launch's `archil_disk`, else its agent's, made first when the agent has none), before the run
|
|
3168
|
+
is queued, for at most 45 s. The server copies 2 files at a time across all the runs it is starting, because Archil
|
|
3169
|
+
resets a connection carrying more large writes at once; 20 files of 10 MiB took 11 to 14 s. A copy that fails or takes
|
|
3170
|
+
longer refuses the start with
|
|
3171
|
+
`424 upstream_failed` ("The run's files could not be copied into its folder on Archil, so it was not started: ..."). No
|
|
3172
|
+
run is made and what was copied is removed. The run's claim then finds its files in place and reads no upload. Files
|
|
3173
|
+
uploaded while Archil was off stay in `DIR/files/` and are not seen while it is on, and the other way round.
|
|
3174
|
+
|
|
3175
|
+
In Mode 2, an uploaded file that no run names is deleted once it is older than `AGENTRUN_UPLOAD_RETENTION` (default
|
|
3176
|
+
`7d`; a whole number with `ms`, `s`, `m`, `h` or `d`, or `off` to keep every file). The server sweeps its uploads disk
|
|
3177
|
+
once an hour and logs `event=uploads_expired removed=N`. A file is kept while a run the store still has was started with
|
|
3178
|
+
it, or while a run started with it in the last hour (whose row may not be written yet). A file kept by a run that has
|
|
3179
|
+
since been deleted becomes unnamed and goes after the retention. Mode 1 keeps every upload, as before.
|
|
3180
|
+
|
|
3052
3181
|
## Agent home
|
|
3053
3182
|
|
|
3054
3183
|
Each agent has a home, a directory of its own at `<data>/homes/<key>/`, kept across its runs; runs do not see it yet.
|
|
@@ -3348,16 +3477,18 @@ stays in every total.
|
|
|
3348
3477
|
- On disk. On both stores the purge deletes or blanks the rows above; what the database files keep differs.
|
|
3349
3478
|
- **SQLite:** every store connection writes with `secure_delete` on, which zeroes the bytes a write frees, and a run's
|
|
3350
3479
|
or an agent's purge checkpoints the WAL once it commits. So the purged content is in neither `store.sqlite` nor
|
|
3351
|
-
its `-wal` after the `DELETE`. A checkpoint another connection holds back
|
|
3352
|
-
next
|
|
3353
|
-
snapshots, the filesystem's own journal.
|
|
3480
|
+
its `-wal` after the `DELETE`. A checkpoint another connection holds back leaves the store's scrub marker
|
|
3481
|
+
(`store.sqlite.scrub`), and the next start's scrub truncates the log before it serves, a crash in between
|
|
3482
|
+
included. Copies outside the file are out of scope: backups, snapshots, the filesystem's own journal.
|
|
3354
3483
|
- **PostgreSQL** (not closed): a purged row's old version stays in its table as a dead tuple. `VACUUM` (or
|
|
3355
3484
|
autovacuum, on its schedule) only marks its space reusable; the bytes stay in the data file until a later write
|
|
3356
3485
|
overwrites them. `VACUUM FULL` rewrites the table into a new file (under an exclusive lock), and the old file's
|
|
3357
3486
|
blocks go back to the filesystem unwiped. Postgres's own WAL and its archived WAL keep the old values until they are
|
|
3358
3487
|
recycled or expire, and backups keep them for their retention.
|
|
3359
|
-
- Its agent's other runs and what the agent learned are kept
|
|
3360
|
-
|
|
3488
|
+
- Its agent's other runs and what the agent learned from it are kept. A promotion record keeps the run's id. The
|
|
3489
|
+
agent's learning folder keeps what the run taught it: its merge's diff (`.agentrun/diffs/<run>.json`, with its
|
|
3490
|
+
patches) and any feedback line it added to `corrections.md`, in the folder's history too. The run's purge removes
|
|
3491
|
+
neither; the agent's purge (below) removes the whole folder.
|
|
3361
3492
|
- It takes the owner's session (the password sign-in, or the console on a server bound to loopback) or the API token;
|
|
3362
3493
|
any other console session is `403 forbidden`, no credential `401`.
|
|
3363
3494
|
|
|
@@ -3645,6 +3776,15 @@ These reads make no paid request, and saving a matching key refreshes the setup
|
|
|
3645
3776
|
Importing Claude Code, Codex or pi session history does not replay learning or connect a live learning stream.
|
|
3646
3777
|
Before/after cost and duration are observations, not an accuracy evaluation.
|
|
3647
3778
|
|
|
3779
|
+
**Existing CLI capture.** A project enrolled with `cli_learning` keeps running in its original Codex CLI or Claude
|
|
3780
|
+
Code process. Its hooks record normal prompt windows and provide the agent's explicit owner-written corrections
|
|
3781
|
+
on later prompts when learning is enabled. Capturing a prompt does not turn its content or answer into a correction.
|
|
3782
|
+
CLI capture starts no extra source prompt, native grading turn or automatic note/skill extraction. It has no
|
|
3783
|
+
approved workflow tool bridge, so it neither compiles nor executes learned workflows. The Learning tab edits
|
|
3784
|
+
corrections and shows captured runs; new captures begin with the next normal prompt after hooks are ready.
|
|
3785
|
+
Historical learning files remain stored and are not converted into owner corrections or deleted. Older stored
|
|
3786
|
+
CLI `learning: "notes"` settings read publicly as `true`; that compatibility read does not rewrite the revision.
|
|
3787
|
+
|
|
3648
3788
|
An agent that learns has a learning folder, `learning/` in its folder on the disk (`DATA/disk/agents/<key>/learning/`):
|
|
3649
3789
|
|
|
3650
3790
|
- `corrections.md`, its owner's standing corrections, one `- ` line each, at most 2048 bytes;
|
|
@@ -3904,10 +4044,11 @@ and says how its figure was reached.
|
|
|
3904
4044
|
and do not change it. A native, SDK or imported run's figure is its harness's own, an `estimate`; so is an imported
|
|
3905
4045
|
session's catalog estimate where its source priced none ([importing your sessions](#importing-your-sessions)). LiteLLM writes no
|
|
3906
4046
|
cost into a streamed answer's headers, so a run whose answers stream through LiteLLM reads `estimate`.
|
|
3907
|
-
- `tools_usd` (on `GET /runs/{id}` alone, `toolsusd/1`): the part of `usd` its paid tool calls cost (monid's endpoints,
|
|
3908
|
-
MCP tools with a saved price, Parallel behind `web_search` and `web_fetch`, browser time
|
|
3909
|
-
|
|
3910
|
-
|
|
4047
|
+
- `tools_usd` (on `GET /runs/{id}` alone, `toolsusd/1`; Parallel's decisions in it since `toolsusd/2`): the part of `usd` its paid tool calls cost (monid's endpoints,
|
|
4048
|
+
MCP tools with a saved price, Parallel behind `web_search` and `web_fetch`, browser time, and a workflow decision
|
|
4049
|
+
Parallel answered on its own API, on `PARALLEL_API_KEY`, at Parallel's list price), as the run's ledger booked them,
|
|
4050
|
+
rounded as `usd` is. It is inside `usd`, never added to it: `usd` less `tools_usd` is what its model requests and its
|
|
4051
|
+
other decisions cost (Jev's, an OpenRouter model's, Parallel's model reached through OpenRouter). A paid call in a learning run's end-of-run turn is learning's (in `learning_usd`), never in
|
|
3911
4052
|
`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
|
|
3912
4053
|
is at work (until it ended, stopped or failed); for a learning run a follow-up opened again, whose `usd` is what its
|
|
3913
4054
|
first round had cost; and for an imported, native or SDK run, whose `usd` is its import's or its harness's own figure
|
|
@@ -3943,14 +4084,17 @@ were reached. Nothing is priced here, and nothing is rounded to a billing increm
|
|
|
3943
4084
|
```
|
|
3944
4085
|
|
|
3945
4086
|
- `tokens`: one line per model the requests were sent on (`model`; a workflow decision on the model its provider
|
|
3946
|
-
answered with). `provider` is where the requests went, named only when this server sent them there itself: the run's
|
|
4087
|
+
answered with, except a decision Parallel charged for, which is on Parallel's `tools` line). `provider` is where the requests went, named only when this server sent them there itself: the run's
|
|
3947
4088
|
own model on a provider's key, or a decision's provider. Behind a model gateway it is null, since the gateway picks the
|
|
3948
4089
|
upstream. A model reached two ways is two lines, one per provider. `quantity` is the input, cache read, cache write and
|
|
3949
4090
|
output tokens as each request reported them (a decision's as its receipt does), with the split beside it; `basis` is the run's `cost.basis` rule over that model's requests alone.
|
|
3950
4091
|
- `tools`: one line per charger (`charged_by`: `monid`, an MCP server's name, `parallel`), the vendor whose invoice the
|
|
3951
4092
|
calls land on. `provider` names the same vendor: the one that charges for a call is its provider. `quantity` is the charges booked, one per paid call. `basis` is `reported` when every charge is the
|
|
3952
4093
|
vendor's own figure (monid's answer says what it charged), `estimate` when any is a price this server holds (an MCP
|
|
3953
|
-
tool's saved price, Parallel's).
|
|
4094
|
+
tool's saved price, Parallel's). A workflow decision Parallel answered on its own API (`PARALLEL_API_KEY`) is a paid
|
|
4095
|
+
call on the `parallel` line, beside `web_search` and `web_fetch`, at Parallel's list price for one decision request
|
|
4096
|
+
(`estimate`), and on no `tokens` line. A `parallel` decision sent through OpenRouter (no `PARALLEL_API_KEY`, the
|
|
4097
|
+
OpenRouter key) is OpenRouter's to charge, at the cost OpenRouter reported: a `tokens` line, as any decision model's. Calls of a tool with no price set ran outside the run's cost, as `GET /usage` counts
|
|
3954
4098
|
them: `not_metered_calls`, in neither `quantity` nor `usd`.
|
|
3955
4099
|
- `browser_time`: one line per browser provider (`provider`). `quantity` is the seconds this server's clock charged the
|
|
3956
4100
|
provider's sessions for, the provider's minimum per session included as the browser charged it; `basis` is
|
|
@@ -3967,8 +4111,19 @@ were reached. Nothing is priced here, and nothing is rounded to a billing increm
|
|
|
3967
4111
|
- `lines` and `total` are null, with `reason`, while the run is at work (`running`), for a run whose figure is not its
|
|
3968
4112
|
booking's (`not_booked`: an imported, native or SDK run, or a CLI run whose model requests went past its proxy), and
|
|
3969
4113
|
for a learning run a follow-up opened again (`reopened`, whose booking can't be split by round).
|
|
3970
|
-
-
|
|
3971
|
-
|
|
4114
|
+
- `compute_time` (`runusage/4`): one line per computer provider and resource (`resource`: `vcpu`, `memory`, `gpu` with
|
|
4115
|
+
its `gpu_type`, `disk`), for the computers the run made. Sum a provider's lines for its one compute figure. `quantity`
|
|
4116
|
+
is every second of each such computer at its figure (`vcpu_second`, `gib_second`, `gpu_second`, or `gb_month` of disk
|
|
4117
|
+
over a 730-hour month); a computer still open is counted up to `measured_to` (`open_computers` says how many). `usd` is
|
|
4118
|
+
what the run's ledger booked for it while a claim held the computer, at the operator's price ([Computer
|
|
4119
|
+
time](#computer-time)), so `total` stays the run's `cost.usd`. The part no claim held (`unheld_quantity`: a computer
|
|
4120
|
+
kept past its claim for a follow-up, one deleted after its run, one whose delete failed) is in no cost. A resource with
|
|
4121
|
+
no price set, or whose figure no one said, is `unpriced`, its `usd` null; a provider that bills nothing (`docker`) is
|
|
4122
|
+
$0. A `compute_time` line that is `unpriced` and any `unheld_quantity` are outside `total`.
|
|
4123
|
+
```json
|
|
4124
|
+
{ "meter": "compute_time", "model": null, "provider": "daytona", "charged_by": "daytona", "resource": "vcpu", "gpu_type": null,
|
|
4125
|
+
"quantity": 348, "unit": "vcpu_second", "basis": "estimate", "usd": 0.004872, "unheld_quantity": 0, "open_computers": 0 }
|
|
4126
|
+
```
|
|
3972
4127
|
- `browser_sessions` (`runusage/2`) holds one record per browser session the run opened, in the order it opened them.
|
|
3973
4128
|
With it you can see how long each session ran, spot one that ended late or was lost, and find each on the provider's
|
|
3974
4129
|
own dashboard and invoice by its id: the provider's id for the session (`provider_session_id`), when
|
|
@@ -3983,8 +4138,9 @@ were reached. Nothing is priced here, and nothing is rounded to a billing increm
|
|
|
3983
4138
|
desktop or a phone), by when each was made. With it you can see how long each of the run's computers lived, find one
|
|
3984
4139
|
left running after its run, and match the provider's invoice by its own id: the provider (`provider`, this server's
|
|
3985
4140
|
name for it, as the agent's computer setting names it), the provider's id for the computer (`provider_id`), its
|
|
3986
|
-
`kind`, what
|
|
3987
|
-
|
|
4141
|
+
`kind`, what it was made with (`gpu` with its `type` and `count`, `cpus`, `memory_mb`, `disk_gb`: the provider's own
|
|
4142
|
+
figures where its answer gave them, as Daytona's, E2B's and Fly's do, else what its create asked for; null where neither
|
|
4143
|
+
says, and none is guessed), how much of its time a claim held and booked (`booked_seconds`), when the create answered
|
|
3988
4144
|
(`started_at`), and when the provider's delete of it answered ok (`ended_at`). `ended_at` is written only on that ok:
|
|
3989
4145
|
null means no delete was proven (the computer may still be running, or its delete failed or never answered), never a
|
|
3990
4146
|
guessed end. `kept` is true once the run's park kept the computer past its claim, for the person's answer. A computer
|
|
@@ -3994,6 +4150,46 @@ were reached. Nothing is priced here, and nothing is rounded to a billing increm
|
|
|
3994
4150
|
`browser_sessions`. A run's computers made before this server kept them have none either. The records are kept in the
|
|
3995
4151
|
store's `computer_intervals` table (keyed by provider and the provider's id), and a purge of the run keeps them.
|
|
3996
4152
|
|
|
4153
|
+
### Computer time
|
|
4154
|
+
|
|
4155
|
+
A computer's time is priced the way providers bill it: by what the computer holds (its vCPUs, its memory, its GPUs, its
|
|
4156
|
+
disk), for as long as it holds them. There are no sizes. Copy your provider's per-resource rates from its price sheet
|
|
4157
|
+
into these settings on the server, each in US dollars, `<PROVIDER>` being the provider as the agent's computer setting
|
|
4158
|
+
names it and `<GPU_TYPE>` the provider's own GPU name, both in capitals with every other character an underscore:
|
|
4159
|
+
|
|
4160
|
+
| Setting | Price of |
|
|
4161
|
+
| --- | --- |
|
|
4162
|
+
| `AGENTRUN_COMPUTE_USD_PER_VCPU_SECOND_<PROVIDER>` | one vCPU for one second |
|
|
4163
|
+
| `AGENTRUN_COMPUTE_USD_PER_GIB_SECOND_<PROVIDER>` | one GiB of memory for one second |
|
|
4164
|
+
| `AGENTRUN_COMPUTE_USD_PER_GPU_SECOND_<PROVIDER>_<GPU_TYPE>` | one GPU of that type for one second (`..._DAYTONA_H100`) |
|
|
4165
|
+
| `AGENTRUN_COMPUTE_USD_PER_DISK_GB_MONTH_<PROVIDER>` | one GB of disk for a month of 730 hours |
|
|
4166
|
+
|
|
4167
|
+
A price sheet that quotes by the hour divides by 3,600 (a vCPU at $0.0504 an hour is `0.000014`). What a computer holds
|
|
4168
|
+
is its provider's own figure where the provider's answer gives one (Daytona: vCPUs, memory, disk and GPUs; E2B and Fly:
|
|
4169
|
+
vCPUs and memory), else what its create asked for. Nothing is built in: a provider that bills nothing (`docker`) is $0,
|
|
4170
|
+
a resource set to `0` is $0 (its time booked at $0, its line `estimate` with `usd` 0), and with no setting a resource
|
|
4171
|
+
is unpriced.
|
|
4172
|
+
|
|
4173
|
+
- **Priced:** the run's ledger holds the computer's time under the run's `max_cost_usd`, one stretch of 5 minutes ahead,
|
|
4174
|
+
as a browser's time is held. A claim's computer is made while the run is set up, before its cap can judge anything:
|
|
4175
|
+
its first stretch is held as soon as the cap can, so the run's first model request is judged beside it, and a cap
|
|
4176
|
+
with no room parks the run there for a raise. A computer made later in the run (a new sandbox in place of a lost one)
|
|
4177
|
+
has one stretch at what its create asks for held first, and a cap with no room for it makes nothing: the run fails in
|
|
4178
|
+
the cap's words. Each stretch the computer ran is booked (its provider is owed it, so it is never refused) and the
|
|
4179
|
+
next one held, the booked stretch's hold given back first so the cap never counts a stretch twice; a cap with no room
|
|
4180
|
+
for the next pauses the run, as a paid tool call's refusal does, and a raise lets it go on. Before the run's end or park is written, the time since is booked and the hold let go, so the end's `cost.usd`
|
|
4181
|
+
holds all of it. The booked time is in the run's `cost.usd` and on its `compute_time` lines.
|
|
4182
|
+
- **Unpriced** (no setting, or a figure no one said): nothing is held or booked, and nothing is refused. The computer
|
|
4183
|
+
runs outside the cap, as a tool call with no price does, and its `compute_time` lines say `unpriced`. An operator who
|
|
4184
|
+
sets no compute price keeps exactly the behavior before these settings.
|
|
4185
|
+
- **Not held by any claim:** a computer kept past its claim for a follow-up, one deleted after its run ended (the
|
|
4186
|
+
seconds between the end's booking and its delete included), and one whose delete failed run on with no claim to hold
|
|
4187
|
+
them. Their time is on the usage read (`unheld_quantity`, and the
|
|
4188
|
+
interval's `booked_seconds` beside its life) but in no cap and no cost: check `computer_intervals` for such a computer.
|
|
4189
|
+
A computer a later claim takes back is held again from then on.
|
|
4190
|
+
- A run whose process keeps no ledger here (a runner of its own with no run ledger) holds and books nothing, as if
|
|
4191
|
+
unpriced.
|
|
4192
|
+
|
|
3997
4193
|
## Spend cap
|
|
3998
4194
|
|
|
3999
4195
|
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,
|
|
@@ -4005,7 +4201,11 @@ before each model request, the agent's and a compaction's alike, on every harnes
|
|
|
4005
4201
|
what each request still in flight is held at, plus the most this request can cost must stay within it, or the
|
|
4006
4202
|
request is not sent and the run pauses ([below](#a-run-paused-at-its-cap)). The cap is a hard stop for everything but
|
|
4007
4203
|
the charge of a monid call priced by usage, which can pass the estimate it was held at: when it does, the run stops at
|
|
4008
|
-
once ([monid](#monid)).
|
|
4204
|
+
once ([monid](#monid)). An MCP tool counts only at the price saved for it (its server's `prices`); one with none is
|
|
4205
|
+
not metered and bills its own account outside the cap. fal's generations are such calls: they bill your fal account at
|
|
4206
|
+
fal's price for the model and the output, the fal presets save no price, and the cap does not count them. A template
|
|
4207
|
+
that uses fal caps its fal spend itself, with an input such as `max_fal_usd` that it prices its plan against before the
|
|
4208
|
+
first paid call. A request costs its input, plus the output it
|
|
4009
4209
|
is sent with at the output price, plus any fee its tokens do not show (below). Its input is priced at its worst case:
|
|
4010
4210
|
every input token at the higher of the input and cache-write prices, since the provider may bill any of it as a cache
|
|
4011
4211
|
write and a cache can miss at any request. So no request passes the cap, a cache miss included: a request costs at most
|
|
@@ -4420,16 +4620,23 @@ carries no cost at all, as from a provider that does not price the model. The te
|
|
|
4420
4620
|
process of its uid).
|
|
4421
4621
|
- In the image, each run's process also runs as a user of its own: slot `s` of its runner is uid and gid `1001 + s`
|
|
4422
4622
|
(256 slots), started through `agentrun-runas`, a helper installed root:node `0750` with the file capabilities
|
|
4423
|
-
`cap_setuid`, `cap_setgid` and `cap_setpcap`. The helper reaches only that range and refuses uid and gid 0; it sets
|
|
4623
|
+
`cap_chown`, `cap_setuid`, `cap_setgid` and `cap_setpcap`. The helper reaches only that range and refuses uid and gid 0; it sets
|
|
4424
4624
|
the run's uid, gid and groups (its slot's group alone: not node's, not the Docker socket's group compose gives the
|
|
4425
4625
|
server), empties every capability set, sets `no_new_privs` and keeps only the run's two descriptors open. So one run
|
|
4426
4626
|
reads neither another live run's folder nor its process's memory, environment or descriptors, and none reads the data
|
|
4427
4627
|
directory (`0711`: crossed to its own folders, never listed), the store's files (`0600`), the seal key or the
|
|
4428
|
-
server's memory.
|
|
4429
|
-
|
|
4430
|
-
|
|
4431
|
-
|
|
4432
|
-
|
|
4628
|
+
server's memory. The server's user (node) is in one group, its own (1000), and in no slot's; no slot is in node's.
|
|
4629
|
+
Before a run starts, its folders and everything in them are given to its slot: the slot's uid, node's group, folders
|
|
4630
|
+
`2770` with the setgid bit (`agentrun-runas own <slot>`, keeping `cap_chown` alone and changing each entry through a
|
|
4631
|
+
descriptor it opened without following a link). The run reaches them as their owner and the server reads them through
|
|
4632
|
+
its one group; no other slot can enter them. A folder the run itself shuts (`chmod 700`, which drops the setgid bit,
|
|
4633
|
+
since node's group is not the run's) the server cannot read until the run ends. At the run's end every process of its
|
|
4634
|
+
uid is killed, one in a session of its own included, its files in `/tmp`, `/var/tmp`, `/dev/shm`, `/run/lock`
|
|
4635
|
+
(`/var/lock`) and `/dev/mqueue` are removed, and its folders and everything in them go back to node
|
|
4636
|
+
(`agentrun-runas own runner`), which the slot's next run cannot enter. A give-back that fails retires the slot, as a
|
|
4637
|
+
reap that does not hold does. SysV IPC objects (`ipcs`) a run leaves are not removed.
|
|
4638
|
+
`GET /v2/capabilities` says `run_isolation: "uid"`. A runner shared by many customers: see the threat model,
|
|
4639
|
+
[docs/multi-tenant-runners.md](../../docs/multi-tenant-runners.md).
|
|
4433
4640
|
- A platform that strips the image's file capabilities, or starts it with `no-new-privileges` (Docker's
|
|
4434
4641
|
`security_opt: no-new-privileges:true`, Kubernetes' `allowPrivilegeEscalation: false`), leaves the helper unable to
|
|
4435
4642
|
switch, or unable to start (a spawn `EPERM`): the runner then refuses to claim, saying so and naming the setting, and
|
package/dist/agent-delete.d.ts
CHANGED
|
@@ -69,5 +69,6 @@ export declare const purgingKey: (agentId: string) => string;
|
|
|
69
69
|
* run_not_final, nothing purged, while it or a run made from it is live. A purged run is no work. */
|
|
70
70
|
export declare function purgeRun(host: AgentDeleteHost, runId: string): Promise<void>;
|
|
71
71
|
/** One delete of an agent at a time: a second DELETE of the same agent waits for the first, then finds it gone (404) or
|
|
72
|
-
* finishes what the first left.
|
|
73
|
-
|
|
72
|
+
* finishes what the first left. `queued`, a test's seam: told each time a work waits behind another of its agent's,
|
|
73
|
+
* with how many of that agent's wait now (the one running not counted). */
|
|
74
|
+
export declare function oneAtATime(queued?: (agentId: string, waiting: number) => void): <T>(agentId: string, work: () => Promise<T>) => Promise<T>;
|
package/dist/agent-delete.js
CHANGED
|
@@ -52,6 +52,7 @@
|
|
|
52
52
|
import { ApiError } from "./errors.js";
|
|
53
53
|
import { LearningInFlight } from "./learn/delete.js";
|
|
54
54
|
import { FINAL_STATES, RunsMadeFromLeft, StoreConstraint, TriggersLeft } from "./store/index.js";
|
|
55
|
+
import { forgetServed } from "./store-view.js";
|
|
55
56
|
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
56
57
|
const isFinal = (state) => FINAL_STATES.includes(state);
|
|
57
58
|
/** Deletes agent `agentId` (another system's, as the route checked) in the three steps above. Throws ApiError
|
|
@@ -70,6 +71,7 @@ export async function deleteExternalAgent(host, agentId) {
|
|
|
70
71
|
for (const run of await host.store.runs.every(agentId)) {
|
|
71
72
|
await host.forgetRun(agentId, run.id, false);
|
|
72
73
|
await host.store.runs.remove(run.id);
|
|
74
|
+
forgetServed(host.store, run.id);
|
|
73
75
|
if (first)
|
|
74
76
|
await host.at?.("in_step_3", agentId);
|
|
75
77
|
first = false;
|
|
@@ -162,6 +164,13 @@ async function purgeOneOrRefuse(host, agentId, runId, purged, alone) {
|
|
|
162
164
|
throw notFinal(purged, [runId]);
|
|
163
165
|
throw error;
|
|
164
166
|
}
|
|
167
|
+
finally {
|
|
168
|
+
// Its answer and input as this process last served them, dropped whatever the purge answered: every route of it is 410
|
|
169
|
+
// once it committed, so none is read again. A purge can commit and still throw (its checkpoint held back and the
|
|
170
|
+
// scrub's marker not written, sqlite/store.ts #purged), and no later DELETE comes back here (purgeRun: a purged run is
|
|
171
|
+
// no work). One that did not commit loses a cache its next read fills again.
|
|
172
|
+
forgetServed(host.store, runId);
|
|
173
|
+
}
|
|
165
174
|
}
|
|
166
175
|
/** Every run made from run `runId` that is there and not purged, each one's own before it (deepest first), never `runId`. */
|
|
167
176
|
async function madeFromAll(host, runId, seen = new Set([runId])) {
|
|
@@ -266,12 +275,28 @@ async function stopRuns(host, agentId) {
|
|
|
266
275
|
}
|
|
267
276
|
}
|
|
268
277
|
/** One delete of an agent at a time: a second DELETE of the same agent waits for the first, then finds it gone (404) or
|
|
269
|
-
* finishes what the first left.
|
|
270
|
-
|
|
278
|
+
* finishes what the first left. `queued`, a test's seam: told each time a work waits behind another of its agent's,
|
|
279
|
+
* with how many of that agent's wait now (the one running not counted). */
|
|
280
|
+
export function oneAtATime(queued) {
|
|
271
281
|
const turns = new Map();
|
|
282
|
+
const waiting = new Map();
|
|
272
283
|
return (agentId, work) => {
|
|
273
|
-
const
|
|
274
|
-
|
|
284
|
+
const held = turns.get(agentId);
|
|
285
|
+
let run = work;
|
|
286
|
+
if (held && queued) {
|
|
287
|
+
waiting.set(agentId, (waiting.get(agentId) ?? 0) + 1);
|
|
288
|
+
run = () => {
|
|
289
|
+
const left = waiting.get(agentId) - 1;
|
|
290
|
+
if (left)
|
|
291
|
+
waiting.set(agentId, left);
|
|
292
|
+
else
|
|
293
|
+
waiting.delete(agentId);
|
|
294
|
+
return work();
|
|
295
|
+
};
|
|
296
|
+
queued(agentId, waiting.get(agentId));
|
|
297
|
+
}
|
|
298
|
+
const before = held ?? Promise.resolve();
|
|
299
|
+
const turn = before.then(run, run);
|
|
275
300
|
const settled = turn.then(() => undefined, () => undefined);
|
|
276
301
|
turns.set(agentId, settled);
|
|
277
302
|
void settled.then(() => {
|