@parcha/agentrun-serve 0.1.0-beta.50 → 0.1.0-beta.52
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 +185 -0
- package/README.md +236 -30
- package/dist/adapters.js +1 -1
- package/dist/agent-delete.d.ts +13 -2
- package/dist/agent-delete.js +14 -5
- package/dist/agents-store.d.ts +5 -1
- package/dist/agents-store.js +17 -7
- package/dist/api-only.d.ts +6 -3
- package/dist/api-only.js +8 -5
- package/dist/archil-routes.d.ts +1 -0
- package/dist/archil-routes.js +28 -2
- 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/computer-setting.d.ts +8 -0
- package/dist/computer-setting.js +11 -0
- package/dist/computers.d.ts +6 -2
- package/dist/computers.js +2 -2
- package/dist/console/assets/index-B-D0EM3j.js +733 -0
- package/dist/console/assets/{index-D0mr9wfZ.css → index-DlQepP2J.css} +1 -1
- 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/fal-price.d.ts +76 -0
- package/dist/fal-price.js +368 -0
- 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 +2 -2
- package/dist/learn/commit.d.ts +5 -0
- package/dist/learn/commit.js +4 -1
- package/dist/learn/compile.d.ts +13 -5
- package/dist/learn/compile.js +24 -7
- package/dist/learn/delete.d.ts +12 -6
- package/dist/learn/delete.js +17 -11
- package/dist/learn/folder.d.ts +11 -0
- package/dist/learn/folder.js +20 -3
- package/dist/learn/learning-of.d.ts +8 -0
- package/dist/learn/learning-of.js +8 -0
- package/dist/learn/learning.sh +14 -1
- package/dist/learn/promote.d.ts +51 -7
- package/dist/learn/promote.js +51 -8
- package/dist/learn/secrets.js +14 -3
- package/dist/learning-reset.d.ts +18 -0
- package/dist/learning-reset.js +115 -0
- package/dist/learning-routes.d.ts +1 -1
- package/dist/learning-words.d.ts +6 -1
- package/dist/learning-words.js +6 -1
- package/dist/learning.d.ts +8 -6
- package/dist/learning.js +5 -4
- package/dist/llms.txt +1 -0
- package/dist/mcp-gateway.d.ts +39 -2
- package/dist/mcp-gateway.js +41 -10
- package/dist/mcp-pin-first.js +3 -2
- package/dist/mcp-private-hosts.d.ts +24 -3
- package/dist/mcp-private-hosts.js +53 -3
- package/dist/mcp-servers-store.d.ts +1 -0
- package/dist/mcp-servers-store.js +2 -1
- package/dist/media-duration.d.ts +2 -0
- package/dist/media-duration.js +136 -0
- 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 +133 -24
- package/dist/provider.d.ts +8 -0
- package/dist/provider.js +14 -2
- package/dist/refusal-words.d.ts +0 -3
- package/dist/refusal-words.js +0 -3
- package/dist/request-metadata.d.ts +20 -0
- package/dist/request-metadata.js +24 -0
- package/dist/run-launch.d.ts +27 -4
- package/dist/run-launch.js +18 -3
- package/dist/run-learning-served.d.ts +2 -2
- package/dist/run-usage.d.ts +48 -4
- package/dist/run-usage.js +156 -39
- package/dist/run-view.d.ts +2 -0
- package/dist/run-view.js +8 -7
- package/dist/runner/adapter-loop.d.ts +3 -1
- package/dist/runner/adapter-loop.js +41 -35
- package/dist/runner/adapter-run-spec.d.ts +1 -1
- package/dist/runner/adapter-run-spec.js +15 -15
- package/dist/runner/audit.d.ts +8 -3
- package/dist/runner/audit.js +21 -6
- package/dist/runner/beside.d.ts +13 -0
- package/dist/runner/beside.js +27 -8
- package/dist/runner/claim-secrets.d.ts +2 -1
- package/dist/runner/claim-secrets.js +5 -3
- package/dist/runner/cli-run-spec.d.ts +1 -1
- package/dist/runner/cli-run-spec.js +14 -13
- package/dist/runner/conformance/harness.js +4 -2
- package/dist/runner/disk-free.d.ts +44 -0
- package/dist/runner/disk-free.js +96 -0
- package/dist/runner/dispatch.js +4 -2
- package/dist/runner/feedback-round.d.ts +12 -8
- package/dist/runner/feedback-round.js +16 -30
- package/dist/runner/harness-loops.js +8 -3
- package/dist/runner/journal-kinds.d.ts +4 -1
- package/dist/runner/learning-end.d.ts +2 -1
- package/dist/runner/learning-end.js +51 -22
- package/dist/runner/main.d.ts +17 -6
- package/dist/runner/main.js +187 -45
- package/dist/runner/mcp-claim.js +1 -1
- package/dist/runner/mcp-run.d.ts +9 -0
- package/dist/runner/mcp-run.js +16 -1
- package/dist/runner/model-route.js +7 -4
- package/dist/runner/presence.d.ts +11 -2
- package/dist/runner/presence.js +31 -3
- package/dist/runner/promotion.d.ts +40 -21
- package/dist/runner/promotion.js +130 -59
- package/dist/runner/run-child-host.d.ts +12 -15
- package/dist/runner/run-child-host.js +52 -112
- 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 +58 -6
- package/dist/runner/sdk-loop.d.ts +2 -2
- package/dist/runner/sdk-loop.js +37 -25
- package/dist/runner/store-port.d.ts +3 -0
- package/dist/runner/workflow-spec.js +3 -3
- package/dist/runs-over-store.d.ts +13 -3
- package/dist/runs-over-store.js +71 -16
- package/dist/sdk/check.d.ts +6 -5
- package/dist/sdk/check.js +17 -16
- package/dist/sdk/runs.d.ts +22 -2
- package/dist/sdk/runs.js +167 -82
- package/dist/server.d.ts +3 -0
- package/dist/server.js +230 -43
- 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 +16 -0
- package/dist/store/agent-body.js +20 -3
- 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/journal/storage.d.ts +2 -0
- package/dist/store/journal/storage.js +2 -1
- 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/0024_runner_capacity.sql +28 -0
- package/dist/store/postgres/migrations/0025_run_attempts.sql +27 -0
- package/dist/store/postgres/migrations/0026_run_disk.sql +23 -0
- package/dist/store/postgres/store.d.ts +8 -3
- package/dist/store/postgres/store.js +31 -11
- package/dist/store/schema.d.ts +32 -2
- package/dist/store/schema.js +74 -5
- package/dist/store/sqlite/run-launch.d.ts +31 -1
- package/dist/store/sqlite/run-launch.js +111 -2
- package/dist/store/sqlite/run-patch.d.ts +2 -1
- package/dist/store/sqlite/run-patch.js +4 -3
- package/dist/store/sqlite/store.d.ts +17 -0
- package/dist/store/sqlite/store.js +226 -37
- package/dist/store/store-schema.d.ts +34 -0
- package/dist/store/store-schema.js +125 -0
- package/dist/store/store.d.ts +120 -5
- 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/learning.d.ts +12 -8
- package/dist/store-reads/learning.js +33 -24
- package/dist/store-reads/loop.d.ts +4 -3
- package/dist/store-reads/loop.js +7 -5
- package/dist/store-view.d.ts +4 -3
- package/dist/store-view.js +11 -7
- package/dist/template-eval.js +4 -4
- package/dist/templates.d.ts +6 -2
- package/dist/templates.js +7 -5
- package/dist/timeline/labels.js +1 -1
- package/dist/tool-gate.d.ts +4 -2
- package/dist/tools.js +1 -1
- 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 +431 -0
- package/dist/uploads.d.ts +52 -1
- package/dist/uploads.js +186 -108
- package/dist/validate.js +5 -1
- package/dist/web-save.d.ts +3 -0
- package/dist/web-save.js +17 -2
- package/dist/workspace/archil-disk.d.ts +6 -5
- package/dist/workspace/archil-disk.js +27 -12
- package/dist/workspace/archil-exec.js +1 -1
- package/dist/workspace/archil.js +4 -3
- package/dist/workspace/revision-skills.js +24 -11
- package/dist/workspace/synced-folder.d.ts +3 -3
- package/dist/workspace/synced-folder.js +7 -6
- package/package.json +10 -10
- package/skills/agentrun-serve/SKILL.md +52 -7
- package/dist/console/assets/index-D7G6o-1E.js +0 -720
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
|
|
|
@@ -849,7 +888,9 @@ one computer that it keeps between runs, instead of a fresh one for each run:
|
|
|
849
888
|
**A video of each run.** `computer: {"kind": "desktop", "provider": "e2b", "record": true}` records the computer's
|
|
850
889
|
screen during each of the agent's runs. Off by default; a desktop, a phone or a browser (a sandbox is 422). A browser's is
|
|
851
890
|
each session's page, one file per session (its computer), from the live view's own screencast of it, which the viewer
|
|
852
|
-
shares: frames come as the page changes.
|
|
891
|
+
shares: frames come as the page changes. `GET /v2/computers` says per kind whether its runs can record here, in
|
|
892
|
+
`record` (`{"available": false, "why": "..."}` for a sandbox, for no computer, and for every kind on a server with no
|
|
893
|
+
`ffmpeg` on its PATH), and the console's Recording switch reads it.
|
|
853
894
|
|
|
854
895
|
- **It shows everything on the screen.** That includes what a person types while they have taken over the computer, and
|
|
855
896
|
any password, key or private page shown on it. Pixels can't be redacted. Turn it on only for an agent whose screen
|
|
@@ -1429,7 +1470,7 @@ agent_not_runnable`, with `details.unbound` and `details.missing`).
|
|
|
1429
1470
|
| `ask_person` | Ask the person who started the run; the turn ends until a message answers | nothing | no, no |
|
|
1430
1471
|
| `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
1472
|
| `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 |
|
|
1432
|
-
| `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 |
|
|
1473
|
+
| `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, duration_s?, url}` or `{ok: false, url, refused \| error}` out, `duration_s` an mp3, wav, mp4 or m4a's length in seconds read from its bytes. Never overwrites | nothing | no, no |
|
|
1433
1474
|
| `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 |
|
|
1434
1475
|
| `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 |
|
|
1435
1476
|
| `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 |
|
|
@@ -1477,8 +1518,9 @@ loop), at most 200 MiB in at most 10 minutes, into the run's Workspace (a bare n
|
|
|
1477
1518
|
absolute path and a link are refused, and a path already in use is refused, never overwritten. The file is written once,
|
|
1478
1519
|
after the whole download, so a failed one leaves nothing. An image, audio or video is saved only when its bytes, the
|
|
1479
1520
|
declared type and the path's extension agree (`media/card.png`, never `media/card`); any other type only to a path whose
|
|
1480
|
-
extension names the declared type.
|
|
1481
|
-
|
|
1521
|
+
extension names the declared type. A saved mp3, wav, mp4 or m4a answers its length in seconds, `duration_s`, read from
|
|
1522
|
+
its bytes (`media-duration.ts`); other files answer none. It makes no paid request and is never run again after a crash.
|
|
1523
|
+
Only an agent that names `web_save` has it; no workflow node or call node may name it.
|
|
1482
1524
|
|
|
1483
1525
|
On another harness, every host tool's result reaches the model within the host's bound of 120,000 characters
|
|
1484
1526
|
(`HOST_RESULT_MAX_CHARS`, `@parcha/agentrun-kernel`): the kernel's tool bridge cuts a longer one, its start with a line
|
|
@@ -2829,7 +2871,9 @@ account's app password (Gmail, iCloud and Fastmail each make one in the account'
|
|
|
2829
2871
|
sign-in password is refused by most providers), at most 1,024 characters. It is sealed under the server's seal key
|
|
2830
2872
|
(`AGENTRUN_SEAL_KEY`) and is in no answer, event or log line. Every connection is TLS: 993 and 465 from the start, any
|
|
2831
2873
|
other port with STARTTLS required. Only `127.0.0.1` is reached in the clear. `POST /v2/settings/email/test` signs in to
|
|
2832
|
-
both servers and sends nothing
|
|
2874
|
+
both servers and sends nothing. A save signs in the same way first: an account either server refuses, or one a server
|
|
2875
|
+
can't be reached for, is 424 `upstream_failed` in the test's words (`details.imap` and `details.smtp`), with nothing
|
|
2876
|
+
saved and any account saved before kept as it was. `DELETE` forgets the account.
|
|
2833
2877
|
|
|
2834
2878
|
**The trigger.** `{kind: "email", mailbox?: "INBOX", every_s?: 60, accept?}` reads the mailbox every `every_s` seconds
|
|
2835
2879
|
and starts a run for each new message its `accept` takes (a rule's `where` reads `/from`, `/to`, `/subject`, `/text`).
|
|
@@ -2857,7 +2901,8 @@ after asks, saying "this run has sent 5 emails" (the count is the run's own reco
|
|
|
2857
2901
|
stops two auto-responders answering each other. On a run an email started whose `email_read` is thread-scoped (no
|
|
2858
2902
|
`scope: "mailbox"`), a send to anyone outside the thread's people
|
|
2859
2903
|
(the account's own address and every From, To and Cc of the thread's messages) asks too, naming them ("eve@example.com
|
|
2860
|
-
is outside this email's thread"). The approval
|
|
2904
|
+
is outside this email's thread"). The pending approval carries the reason as `asks_because`, which the console's card
|
|
2905
|
+
says above the call's arguments ("Asks because ..."). With accounts off, where no one can
|
|
2861
2906
|
approve, such a send is refused in those words.
|
|
2862
2907
|
|
|
2863
2908
|
## Templates
|
|
@@ -2894,6 +2939,7 @@ failed, 2 when nothing ran. The runner, the graders and the report are in
|
|
|
2894
2939
|
| Route | Here |
|
|
2895
2940
|
| --- | --- |
|
|
2896
2941
|
| `GET /health` | Without a credential: whether the store reads and the disk has room ([capacity and health](#capacity-and-health)). |
|
|
2942
|
+
| `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. |
|
|
2897
2943
|
| `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. |
|
|
2898
2944
|
| `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. |
|
|
2899
2945
|
| `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. |
|
|
@@ -2914,9 +2960,9 @@ failed, 2 when nothing ran. The runner, the graders and the report are in
|
|
|
2914
2960
|
| `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)). |
|
|
2915
2961
|
| `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. |
|
|
2916
2962
|
| `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"`). |
|
|
2917
|
-
| `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
|
|
2963
|
+
| `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. |
|
|
2918
2964
|
| `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`). |
|
|
2919
|
-
| `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. |
|
|
2965
|
+
| `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`), each line by the attempt it was made in and whether that attempt is billable, with `infra_usd` beside them (`runusage/5`), 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. |
|
|
2920
2966
|
| `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. |
|
|
2921
2967
|
| `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`. |
|
|
2922
2968
|
| `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`. |
|
|
@@ -2937,6 +2983,53 @@ Quotes answer `501 unsupported_here` naming the feature. Home export and import
|
|
|
2937
2983
|
`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
|
|
2938
2984
|
above $0 is taken; it does not mean caps are unsupported ([spend cap](#spend-cap)).
|
|
2939
2985
|
|
|
2986
|
+
### Unified token usage
|
|
2987
|
+
|
|
2988
|
+
`GET /stats` includes `analytics.usage`, the dashboard's single reported token total across recorded runs and
|
|
2989
|
+
connected source sessions. It contains `tokens`, uncached `input`, `output`, `cache_read`, `cache_write`, `by_day`
|
|
2990
|
+
and `by_harness`. A source's inclusive input plus output can establish its total even when its cache breakdown is
|
|
2991
|
+
unavailable; the unavailable breakdown remains null. Run counts, outcomes, time and cost retain their existing
|
|
2992
|
+
meaning and do not treat an observed session as a completed run.
|
|
2993
|
+
|
|
2994
|
+
`known_runs` counts usable run contributions; `unknown_runs` marks missing counters or unresolved overlap.
|
|
2995
|
+
`observed_sessions` counts source identities with usable reports in scope, including when another view supplies
|
|
2996
|
+
the selected total; `unknown_sessions` marks missing or
|
|
2997
|
+
incomplete source coverage. Known and unknown counts can overlap: a selected aggregate can supply a lower bound
|
|
2998
|
+
without proving complete coverage. A verified native session hash and runtime link observations to CLI prompt windows,
|
|
2999
|
+
native runs, SDK runs or imported sessions. Same-source aggregates are added only when their windows prove they
|
|
3000
|
+
do not overlap. When retained daily source reports and run counters may overlap without an exact intersection,
|
|
3001
|
+
the result is a conservative lower bound and `unknown_runs` marks incomplete coverage, even when every source
|
|
3002
|
+
reported its counters. Offline prompt captures may arrive on a later day, so server timestamps alone do not
|
|
3003
|
+
prove their usage is separate from source day buckets. An imported root can include descendants with no retained
|
|
3004
|
+
identity. When its journal exactly reconciles with its saved counters, the root’s own usage can be separated and
|
|
3005
|
+
counted against source reports. Its full aggregate remains an alternative to the same runtime’s native total;
|
|
3006
|
+
the larger coherent view is retained, never added to that total. An unavailable or inconsistent journal uses the
|
|
3007
|
+
same conservative alternative. Unresolved descendant coverage stays in `unknown_runs`.
|
|
3008
|
+
CLI/SDK run metrics may also contain reflection in a separate session. When both the full metrics and immutable
|
|
3009
|
+
source completion counters are known, their nonnegative difference remains included. Historical CLI native
|
|
3010
|
+
reflections can themselves appear in source observations; when that overlap is possible, their full run is a
|
|
3011
|
+
runtime alternative too. Purged runs retain numeric counters but no private source identity: native counters
|
|
3012
|
+
remain conservative alternatives to potentially overlapping source views. Otherwise an unproven remainder is
|
|
3013
|
+
counted in `unknown_runs` coverage rather than silently discarded or guessed as zero.
|
|
3014
|
+
Historical identity remains valid when learning is
|
|
3015
|
+
disabled or revoked. Archiving a learning profile does not disconnect its observed source. Multiple collectors
|
|
3016
|
+
reporting the same verified session use the copy with the largest reported total for each UTC day, then the freshest
|
|
3017
|
+
receipt and stable session id. Disjoint days remain included; overlapping same-day copies are never added because
|
|
3018
|
+
the server retains daily aggregates rather than request identities. This may leave unknown coverage when collectors
|
|
3019
|
+
hold disjoint requests within the same day; their aggregate intersection cannot be inferred. The selected figure
|
|
3020
|
+
is then a lower bound, not a complete count of that session.
|
|
3021
|
+
Unbound observations have no native identity proof and remain distinct. Display names and project labels never
|
|
3022
|
+
establish identity, so an unbound collector cannot deduplicate a separately recorded run.
|
|
3023
|
+
|
|
3024
|
+
Run tokens use the run's start date. Source tokens use the UTC day on which usage was observed, not a session's
|
|
3025
|
+
lifetime total or an inferred request date. Only daily buckets fully inside `[from, to)` are counted; `partial_days`
|
|
3026
|
+
reports boundary days excluded because their aggregate cannot be split exactly. With no `to`, today's reported
|
|
3027
|
+
usage is included. Source history is retained for 90 days; `retention_limited` says the requested range extends
|
|
3028
|
+
beyond it. These figures are reported coverage, not a claim that unobserved history cost zero.
|
|
3029
|
+
|
|
3030
|
+
`agent` may select a recorded agent and its associated sessions, or a connected session id (`os_...`) for only that
|
|
3031
|
+
session's usage. The latter selects no recorded runs. It does not import or create an agent definition.
|
|
3032
|
+
|
|
2940
3033
|
### Feed triggers
|
|
2941
3034
|
|
|
2942
3035
|
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
|
|
@@ -2995,6 +3088,9 @@ serves these routes alone:
|
|
|
2995
3088
|
- an agent's Archil disk (`GET` and `DELETE /agents/{id}/archil`);
|
|
2996
3089
|
- the [delete of an agent another system owns](#deleting-an-agent-another-system-owns) (`DELETE /agents/{id}`), for
|
|
2997
3090
|
the backend whose inline runs made it;
|
|
3091
|
+
- the [purge of a run](#purging-a-run-or-an-agent-made-here) (`DELETE /runs/{id}`) of such an agent, for that
|
|
3092
|
+
backend: it erases one user's runs where deleting the agent, which every user's runs share, would take them all. A
|
|
3093
|
+
run of an agent made here is refused, as every address not listed here is;
|
|
2998
3094
|
- the computer settings' two reads, for a backend to check before it launches: `GET /computers` (each provider, its
|
|
2999
3095
|
key names and whether each is saved, and whether it is ready) and `GET /workspace/archil` (whether runs' folders are
|
|
3000
3096
|
on Archil, and whether its account key is saved). Neither answers a key's value. Their writes, tests and key choices
|
|
@@ -3002,10 +3098,11 @@ serves these routes alone:
|
|
|
3002
3098
|
- what an agent learned, for the backend whose runs it learned from: the loop's compile turns
|
|
3003
3099
|
(`GET /agents/{id}/learning/loop`), each learned workflow's promotion and what serves
|
|
3004
3100
|
(`GET /agents/{id}/learning/promotions`), the cost per run (`GET /agents/{id}/learning/cost`) and a run's learning
|
|
3005
|
-
(`GET /runs/{id}/learning`), each cut of the host's secrets as the console's reads are;
|
|
3101
|
+
(`GET /runs/{id}/learning`), each cut of the host's secrets as the console's reads are; and its reset
|
|
3102
|
+
(`DELETE /agents/{id}/learning`, the agent and its runs kept), its one learning write served here;
|
|
3006
3103
|
- a run's hosted machine fetching this server's computerd build (`GET /computers/daemon`), with the token its create
|
|
3007
3104
|
minted;
|
|
3008
|
-
- `GET /capabilities`, `GET /health` and `GET /
|
|
3105
|
+
- `GET /capabilities`, `GET /health`, `GET /usage` and `GET /capacity`;
|
|
3009
3106
|
- a run's desktop or phone, for a backend that shows its user the live view and lets them take over: see below.
|
|
3010
3107
|
|
|
3011
3108
|
Here a run's computer routes take the server's token. `POST /runs/{id}/computer/viewer` mints a 5-minute link on
|
|
@@ -3069,6 +3166,25 @@ upload stays in the runs that copied it; a run started after names it in vain. E
|
|
|
3069
3166
|
logs `event=uploads_swept removed=N`. `upload.expires_at`, which the contract requires, is advisory and not enforced in
|
|
3070
3167
|
this release: a `PUT` after it is still taken.
|
|
3071
3168
|
|
|
3169
|
+
With Archil on (Mode 2), uploads live on Archil, not in `DIR`, so a runner needs no disk of the server's. The server
|
|
3170
|
+
keeps them on an Archil disk of its own, `agentrun-<server id>-files`, made by its first upload, at
|
|
3171
|
+
`files/<file_id>/` (the same bytes and record). Listing, reading and deleting read that disk; the routes, limits and
|
|
3172
|
+
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
|
|
3173
|
+
disk. When a run is started with `file_ids`, the server copies each file into the run's folder on its disk, at
|
|
3174
|
+
`work/inputs/<path>` (the launch's `archil_disk`, else its agent's, made first when the agent has none), before the run
|
|
3175
|
+
is queued, for at most 45 s. The server copies 2 files at a time across all the runs it is starting, because Archil
|
|
3176
|
+
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
|
|
3177
|
+
longer refuses the start with
|
|
3178
|
+
`424 upstream_failed` ("The run's files could not be copied into its folder on Archil, so it was not started: ..."). No
|
|
3179
|
+
run is made and what was copied is removed. The run's claim then finds its files in place and reads no upload. Files
|
|
3180
|
+
uploaded while Archil was off stay in `DIR/files/` and are not seen while it is on, and the other way round.
|
|
3181
|
+
|
|
3182
|
+
In Mode 2, an uploaded file that no run names is deleted once it is older than `AGENTRUN_UPLOAD_RETENTION` (default
|
|
3183
|
+
`7d`; a whole number with `ms`, `s`, `m`, `h` or `d`, or `off` to keep every file). The server sweeps its uploads disk
|
|
3184
|
+
once an hour and logs `event=uploads_expired removed=N`. A file is kept while a run the store still has was started with
|
|
3185
|
+
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
|
|
3186
|
+
since been deleted becomes unnamed and goes after the retention. Mode 1 keeps every upload, as before.
|
|
3187
|
+
|
|
3072
3188
|
## Agent home
|
|
3073
3189
|
|
|
3074
3190
|
Each agent has a home, a directory of its own at `<data>/homes/<key>/`, kept across its runs; runs do not see it yet.
|
|
@@ -3381,7 +3497,8 @@ stays in every total.
|
|
|
3381
3497
|
patches) and any feedback line it added to `corrections.md`, in the folder's history too. The run's purge removes
|
|
3382
3498
|
neither; the agent's purge (below) removes the whole folder.
|
|
3383
3499
|
- It takes the owner's session (the password sign-in, or the console on a server bound to loopback) or the API token;
|
|
3384
|
-
any other console session is `403 forbidden`, no credential `401`.
|
|
3500
|
+
any other console session is `403 forbidden`, no credential `401`. An [API-only](#api-only) server purges a run of
|
|
3501
|
+
an agent another system owns alone; a run of an agent made here is its profile's `404` there.
|
|
3385
3502
|
|
|
3386
3503
|
An agent made here is purged the same way once archived: `DELETE /v2/agents/{id}`. Its revisions' content, name and
|
|
3387
3504
|
description, learning, triggers, saved sign-ins, own computer, disk and folders go, and each of its runs is purged.
|
|
@@ -3667,6 +3784,15 @@ These reads make no paid request, and saving a matching key refreshes the setup
|
|
|
3667
3784
|
Importing Claude Code, Codex or pi session history does not replay learning or connect a live learning stream.
|
|
3668
3785
|
Before/after cost and duration are observations, not an accuracy evaluation.
|
|
3669
3786
|
|
|
3787
|
+
**Existing CLI capture.** A project enrolled with `cli_learning` keeps running in its original Codex CLI or Claude
|
|
3788
|
+
Code process. Its hooks record normal prompt windows and provide the agent's explicit owner-written corrections
|
|
3789
|
+
on later prompts when learning is enabled. Capturing a prompt does not turn its content or answer into a correction.
|
|
3790
|
+
CLI capture starts no extra source prompt, native grading turn or automatic note/skill extraction. It has no
|
|
3791
|
+
approved workflow tool bridge, so it neither compiles nor executes learned workflows. The Learning tab edits
|
|
3792
|
+
corrections and shows captured runs; new captures begin with the next normal prompt after hooks are ready.
|
|
3793
|
+
Historical learning files remain stored and are not converted into owner corrections or deleted. Older stored
|
|
3794
|
+
CLI `learning: "notes"` settings read publicly as `true`; that compatibility read does not rewrite the revision.
|
|
3795
|
+
|
|
3670
3796
|
An agent that learns has a learning folder, `learning/` in its folder on the disk (`DATA/disk/agents/<key>/learning/`):
|
|
3671
3797
|
|
|
3672
3798
|
- `corrections.md`, its owner's standing corrections, one `- ` line each, at most 2048 bytes;
|
|
@@ -3789,8 +3915,10 @@ check closed.
|
|
|
3789
3915
|
The bridge posts one `workflow_check` event with the reservation's `id` and `digest`, its execution `outcome`
|
|
3790
3916
|
(`answered`, `handed_back`, `failed` or `skipped_write`), and its answer or reason. It does not choose whether the
|
|
3791
3917
|
workflow passes. The server compares the answer with the immutable native completion and applies the same
|
|
3792
|
-
`agree_min` and `alone_min` promotion policy
|
|
3793
|
-
|
|
3918
|
+
`agree_min` and `alone_min` promotion policy on the same evidence bar: the check decides once, on `compile_after`
|
|
3919
|
+
**independent native turns**, as a server check decides once on that many of the agent's inputs. Each turn is one row,
|
|
3920
|
+
kept on the promotion record (`check.turns`) while the check waits for the next turn the draft takes; the turn that
|
|
3921
|
+
makes `compile_after` decides on all of them. Agreement is whole-answer equality (JSON values or trimmed text), or equality of the owner's
|
|
3794
3922
|
configured `agree_on` fields; there is no semantic model grader on this path. A paraphrase can therefore be held even
|
|
3795
3923
|
when a person would consider it equivalent.
|
|
3796
3924
|
|
|
@@ -3874,6 +4002,15 @@ with the token, an archived agent's too:
|
|
|
3874
4002
|
- `GET .../learning/workflows/{name}/revisions` lists a learned workflow's revisions on `main`;
|
|
3875
4003
|
`GET .../learning/promotions` its promotion records; `GET .../learning/loop` each compile turn; and
|
|
3876
4004
|
`GET .../learning/cost` the agent's cost per run, run after run.
|
|
4005
|
+
- `DELETE /agents/{agent_id}/learning` resets the agent's learning: its learning folder whole (`corrections.md`, its
|
|
4006
|
+
workflows, their history and the audit ledger), here and on every Archil disk its runs used (`503` while one can't be
|
|
4007
|
+
reached), then its promotion records and grades. The agent and its runs stay,
|
|
4008
|
+
with their files, costs and each run's own learning, so the run list, `GET /stats` and `GET /usage` read the same (a
|
|
4009
|
+
served run keeps its share of its revision's compile and check); a run's learning diff goes with the folder (404);
|
|
4010
|
+
the next run takes the agent path, given nothing learned. It cancels the runs that exist only for learning (replays,
|
|
4011
|
+
audit shadows) and waits for them; while a run of the agent's own is still going it is `409 learning_busy` (each named
|
|
4012
|
+
in `details.runs`), and nothing is deleted. `204`, a second call and an agent that never learned included. The
|
|
4013
|
+
API-only profile serves it too.
|
|
3877
4014
|
- `GET /runs/{run_id}/learning`: the run's learning whole (its seed, its merge, the corrections it added, the workflow it
|
|
3878
4015
|
wrote, its compile turn's attempts and the checks' problems), `null` for a run that does not learn.
|
|
3879
4016
|
`GET /runs/{run_id}/learning/diff`: a merged run's merge commit against its parent, each file's patch as git writes it
|
|
@@ -4032,6 +4169,60 @@ were reached. Nothing is priced here, and nothing is rounded to a billing increm
|
|
|
4032
4169
|
`browser_sessions`. A run's computers made before this server kept them have none either. The records are kept in the
|
|
4033
4170
|
store's `computer_intervals` table (keyed by provider and the provider's id), and a purge of the run keeps them.
|
|
4034
4171
|
|
|
4172
|
+
### Attempts: what the infrastructure redid
|
|
4173
|
+
|
|
4174
|
+
A run's turn can be worked more than once. A runner that drains for a deploy hands its runs back mid-turn, a runner that
|
|
4175
|
+
dies leaves its claims to lapse, a runner that can't renew loses its claim, and a turn whose loop ended on its own is
|
|
4176
|
+
tried again. In each case another claim works the same turn again. It resumes from what the cut claim saved: requests
|
|
4177
|
+
already answered and calls already finished are reused, not sent again. What it does send again is each model request
|
|
4178
|
+
the cut claim sent and never finished, cut in flight or cut off by a crash. Those requests are the infrastructure's
|
|
4179
|
+
cost, not the task's.
|
|
4180
|
+
|
|
4181
|
+
The read says which is which (`runusage/5`). It does not change what anything costs: `total` and `cost.usd` still hold
|
|
4182
|
+
every line.
|
|
4183
|
+
|
|
4184
|
+
- Each line, browser session and computer interval has `attempt`: the attempt at its turn it was made in (1 for the
|
|
4185
|
+
turn's first, 2 for its first redo, and so on). A turn's charges are split into one line per attempt.
|
|
4186
|
+
- Each also has `billable`. It is false only for the model requests an attempt never finished when a later attempt
|
|
4187
|
+
worked its turn again. Everything else is billable: answered requests, paid calls, browser and computer time.
|
|
4188
|
+
- `infra_usd` is the sum of the lines that are not billable. It is 0 for a run with no such request. A request cut in
|
|
4189
|
+
flight never got an answer, so its cost is unknown, and `infra_usd` reads null for a run that has one, as `total`
|
|
4190
|
+
does. It is also null with no lines.
|
|
4191
|
+
- A run from before this server kept attempts reads `attempt: null` and `billable: true` on every line.
|
|
4192
|
+
|
|
4193
|
+
The attempts live in the store's `run_attempts` table: one row per claim, written in the claim's own transaction. Each
|
|
4194
|
+
row holds the claim's turn and attempt, and `cause`, which says why the attempt before it was cut:
|
|
4195
|
+
|
|
4196
|
+
| `cause` | What cut the attempt before |
|
|
4197
|
+
| --- | --- |
|
|
4198
|
+
| `drain` | Its runner closed (SIGTERM) and handed the run back. |
|
|
4199
|
+
| `crash` | Its lease ran out and nobody said why (its runner died). |
|
|
4200
|
+
| `lease_lapse` | Its runner was still there but could not renew the claim in time. |
|
|
4201
|
+
| `retry` | Its loop ended interrupted on its own, and the run was released to be tried again. A stopped run whose end was refused is no cut: the claim that retries the end runs no turn, so it starts a new one and redoes nothing. |
|
|
4202
|
+
|
|
4203
|
+
A turn is the work one claim starts afresh: the run's first, a follow-up's, or a resume after a park. A claim is a redo
|
|
4204
|
+
only of the claim it takes over, and only when that claim wrote its row. A runner of an earlier build, running beside
|
|
4205
|
+
this server through an upgrade, writes none. When the claim after it takes over, it starts a new turn, so no earlier
|
|
4206
|
+
recorded turn is read as redone.
|
|
4207
|
+
|
|
4208
|
+
Each part of the usage is matched to its claim this way:
|
|
4209
|
+
|
|
4210
|
+
- **Journal entries:** a claim's entries start at the run's next entry id at the moment it claimed. Anything written
|
|
4211
|
+
before the run's first recorded claim belongs to no attempt and stays billable, unless that claim was the run's first.
|
|
4212
|
+
- **Browser charges:** a charge whose booking a later claim recovered is the attempt's that wrote the charge, matched
|
|
4213
|
+
by its ref.
|
|
4214
|
+
- **Computer time:** a computer's time is split across the claims that held it, by each claim's window on the store's
|
|
4215
|
+
clock. A computer kept across a park is billed by the claim that resumed it. Its `unheld_quantity` is spread over those
|
|
4216
|
+
windows by their share of its life.
|
|
4217
|
+
- **Computer intervals:** each record's own `attempt` is the claim that made the computer.
|
|
4218
|
+
|
|
4219
|
+
Each model request a claim sends to this server's model gateway carries the run, turn and attempt as LiteLLM's
|
|
4220
|
+
spend-logs metadata, in the header `x-litellm-spend-logs-metadata` (LiteLLM v1.110.0 and later). For example:
|
|
4221
|
+
`{"agentrun_run_id":"run_…","agentrun_turn":1,"agentrun_attempt":2}`. A gateway's spend logs can then be matched to the
|
|
4222
|
+
run's lines call by call. "This server's model gateway" means `AGENT_MODEL_BASE_URL`, or `ANTHROPIC_BASE_URL` on its
|
|
4223
|
+
origin. The header is sent on pi's routes and Claude Code's; Codex's adapter takes no extra headers yet. It is never
|
|
4224
|
+
sent to a vendor's own endpoint.
|
|
4225
|
+
|
|
4035
4226
|
### Computer time
|
|
4036
4227
|
|
|
4037
4228
|
A computer's time is priced the way providers bill it: by what the computer holds (its vCPUs, its memory, its GPUs, its
|
|
@@ -4084,10 +4275,18 @@ what each request still in flight is held at, plus the most this request can cos
|
|
|
4084
4275
|
request is not sent and the run pauses ([below](#a-run-paused-at-its-cap)). The cap is a hard stop for everything but
|
|
4085
4276
|
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
|
|
4086
4277
|
once ([monid](#monid)). An MCP tool counts only at the price saved for it (its server's `prices`); one with none is
|
|
4087
|
-
not metered and bills its own account outside the cap. fal
|
|
4088
|
-
fal
|
|
4089
|
-
|
|
4090
|
-
|
|
4278
|
+
not metered and bills its own account outside the cap. fal is counted: a job sent to a fal server (one saved with the
|
|
4279
|
+
toolkit `fal`, or at `mcp.fal.ai`) through `run_model`, `submit_job` or `submit_jobs` is priced before it is sent, at
|
|
4280
|
+
fal's unit price for its endpoint (the server's own `get_pricing`, read with the run's credential and kept five
|
|
4281
|
+
minutes) times the units the job's input states: its images, their megapixels, its text's characters, the seconds it
|
|
4282
|
+
names, or the length of the audio or video it is given, read from the file first. That price is held under the cap, a
|
|
4283
|
+
job the cap can't take is refused before it is submitted, and the job is booked as the run's tool cost, charged by the
|
|
4284
|
+
server, with the price and the count it came from. It is an estimate at fal's list price, not fal's invoice: fal
|
|
4285
|
+
reports no cost for a job, and a minimum charge, a discount or a rate that depends on a setting `get_pricing` does not
|
|
4286
|
+
list are not in it. A job whose units can't be known before it runs (one billed by compute time or tokens, one that
|
|
4287
|
+
names no size or length, media whose length can't be read, an endpoint with no listed price) is refused under a cap,
|
|
4288
|
+
in words that say why; with no cap it runs, booked as an unknown charge. A price saved for a fal tool takes the place
|
|
4289
|
+
of this. A request costs its input, plus the output it
|
|
4091
4290
|
is sent with at the output price, plus any fee its tokens do not show (below). Its input is priced at its worst case:
|
|
4092
4291
|
every input token at the higher of the input and cache-write prices, since the provider may bill any of it as a cache
|
|
4093
4292
|
write and a cache can miss at any request. So no request passes the cap, a cache miss included: a request costs at most
|
|
@@ -4502,16 +4701,23 @@ carries no cost at all, as from a provider that does not price the model. The te
|
|
|
4502
4701
|
process of its uid).
|
|
4503
4702
|
- 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`
|
|
4504
4703
|
(256 slots), started through `agentrun-runas`, a helper installed root:node `0750` with the file capabilities
|
|
4505
|
-
`cap_setuid`, `cap_setgid` and `cap_setpcap`. The helper reaches only that range and refuses uid and gid 0; it sets
|
|
4704
|
+
`cap_chown`, `cap_setuid`, `cap_setgid` and `cap_setpcap`. The helper reaches only that range and refuses uid and gid 0; it sets
|
|
4506
4705
|
the run's uid, gid and groups (its slot's group alone: not node's, not the Docker socket's group compose gives the
|
|
4507
4706
|
server), empties every capability set, sets `no_new_privs` and keeps only the run's two descriptors open. So one run
|
|
4508
4707
|
reads neither another live run's folder nor its process's memory, environment or descriptors, and none reads the data
|
|
4509
4708
|
directory (`0711`: crossed to its own folders, never listed), the store's files (`0600`), the seal key or the
|
|
4510
|
-
server's memory.
|
|
4511
|
-
|
|
4512
|
-
|
|
4513
|
-
|
|
4514
|
-
|
|
4709
|
+
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.
|
|
4710
|
+
Before a run starts, its folders and everything in them are given to its slot: the slot's uid, node's group, folders
|
|
4711
|
+
`2770` with the setgid bit (`agentrun-runas own <slot>`, keeping `cap_chown` alone and changing each entry through a
|
|
4712
|
+
descriptor it opened without following a link). The run reaches them as their owner and the server reads them through
|
|
4713
|
+
its one group; no other slot can enter them. A folder the run itself shuts (`chmod 700`, which drops the setgid bit,
|
|
4714
|
+
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
|
|
4715
|
+
uid is killed, one in a session of its own included, its files in `/tmp`, `/var/tmp`, `/dev/shm`, `/run/lock`
|
|
4716
|
+
(`/var/lock`) and `/dev/mqueue` are removed, and its folders and everything in them go back to node
|
|
4717
|
+
(`agentrun-runas own runner`), which the slot's next run cannot enter. A give-back that fails retires the slot, as a
|
|
4718
|
+
reap that does not hold does. SysV IPC objects (`ipcs`) a run leaves are not removed.
|
|
4719
|
+
`GET /v2/capabilities` says `run_isolation: "uid"`. A runner shared by many customers: see the threat model,
|
|
4720
|
+
[docs/multi-tenant-runners.md](../../docs/multi-tenant-runners.md).
|
|
4515
4721
|
- A platform that strips the image's file capabilities, or starts it with `no-new-privileges` (Docker's
|
|
4516
4722
|
`security_opt: no-new-privileges:true`, Kubernetes' `allowPrivilegeEscalation: false`), leaves the helper unable to
|
|
4517
4723
|
switch, or unable to start (a spawn `EPERM`): the runner then refuses to claim, saying so and naming the setting, and
|
package/dist/adapters.js
CHANGED
|
@@ -284,7 +284,7 @@ export async function claudeOf(env, needs, load = loadClaude, sdkOf = (version,
|
|
|
284
284
|
// The CLI runs Anthropic's own id, which it knows the limits and betas of, and sends it as it is, OpenRouter too
|
|
285
285
|
// (providerFor's modelId); the key goes as the endpoint takes it, and the run is priced by the catalog entry of
|
|
286
286
|
// whoever bills it (its priceModel).
|
|
287
|
-
const endpoint = provider ? { origin: provider.origin, credential: provider.credential, auth: provider.auth } : { origin: "", credential: () => "" };
|
|
287
|
+
const endpoint = provider ? { origin: provider.origin, credential: provider.credential, auth: provider.auth, ...(provider.headers ? { headers: provider.headers } : {}) } : { origin: "", credential: () => "" };
|
|
288
288
|
const priced = provider ? { ...needs, model: provider.priceModel } : native;
|
|
289
289
|
// Its CLI checked off the event loop first (hashed and run as a child), so the server goes on answering: a pass is
|
|
290
290
|
// kept, and the adapter's own check answers from it. A CLI that fails its pins is the adapter's to report, in its
|
package/dist/agent-delete.d.ts
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
import { type PurgeKept, type Store } from "./store/index.js";
|
|
2
2
|
/** The delete of an agent's learning: the server's is the learning module's deleteLearning over the agent's learning
|
|
3
|
-
* folder
|
|
4
|
-
|
|
3
|
+
* folder, and its folder on each Archil disk a launch of its runs named, a purged run's included (learn/delete.ts;
|
|
4
|
+
* server.ts learningDisksOf), and its records. Idempotent; refuses with LearningInFlight while learning work of the
|
|
5
|
+
* agent is in flight. A reset of the agent's learning (learning-reset.ts), whose agent and runs stay, keeps its reset
|
|
6
|
+
* ledger and watermark (`keepResetLedger`) and deletes the folder on the agent's own disk too (`agentDisk`), which the
|
|
7
|
+
* agent's delete removes whole in its step 3. */
|
|
8
|
+
export type DeleteLearning = (store: Store, agentId: string, options?: {
|
|
9
|
+
keepResetLedger?: boolean;
|
|
10
|
+
agentDisk?: boolean;
|
|
11
|
+
}) => Promise<unknown>;
|
|
5
12
|
/** A point of a delete a test may stop it at (AgentDeleteHost.at). An agent's: after step 1, after step 2, in step 3
|
|
6
13
|
* between a trigger's removal upstream and its settings', between its settings' and its row's, and in step 3 once its
|
|
7
14
|
* triggers and the agent's first run are gone (a purge's: after its learning, then the same). A run's: once the runs
|
|
@@ -65,6 +72,10 @@ export declare function deleteExternalAgent(host: AgentDeleteHost, agentId: stri
|
|
|
65
72
|
export declare function purgeAgent(host: AgentDeleteHost, agentId: string): Promise<void>;
|
|
66
73
|
/** The setting that marks agent `agentId`'s purge begun and not finished (purgeAgent). */
|
|
67
74
|
export declare const purgingKey: (agentId: string) => string;
|
|
75
|
+
/** A DELETE of a run, or of agent `agentId`, already purged: 204 with no purge, but what a purge that committed and then
|
|
76
|
+
* threw left undone (its scrub's marker not written, sqlite/store.ts #purged): the scrub arranged again (store
|
|
77
|
+
* purgeScrub), and the agent's purge mark dropped (purgeAgent removes it only after its store purge returns). */
|
|
78
|
+
export declare function purgedAgain(host: AgentDeleteHost, agentId?: string): Promise<void>;
|
|
68
79
|
/** Purges run `runId` with every run made from it, as the header says. 404 not_found when it is not there; 409
|
|
69
80
|
* run_not_final, nothing purged, while it or a run made from it is live. A purged run is no work. */
|
|
70
81
|
export declare function purgeRun(host: AgentDeleteHost, runId: string): Promise<void>;
|
package/dist/agent-delete.js
CHANGED
|
@@ -32,9 +32,10 @@
|
|
|
32
32
|
// a follow-up that would open one of its runs again are refused (store AgentDeleting / AgentArchived, each read in
|
|
33
33
|
// the transaction that would start the run). Then each of its runs not yet final, its learning runs included, is
|
|
34
34
|
// cancelled through the cancel path, and waited for until it is final.
|
|
35
|
-
// 2. Its learning, by the learning module's deleteLearning (learn/delete.ts: its learning folder's files,
|
|
36
|
-
//
|
|
37
|
-
//
|
|
35
|
+
// 2. Its learning, by the learning module's deleteLearning (learn/delete.ts: its learning folder's files, here and on
|
|
36
|
+
// each Archil disk a launch of its runs named, a purged run's included, then its promotions and grades; its own
|
|
37
|
+
// disk goes whole in step 3; idempotent; it refuses with LearningInFlight while learning work is in flight, which
|
|
38
|
+
// answers 409 learning_busy with the agent left refusing runs).
|
|
38
39
|
// 3. Its things: its triggers through the trigger engine (each one's registration upstream first, then its adapter
|
|
39
40
|
// settings, then its row), its saved sign-ins (each vendor object too), its own computer, its Archil disk; then each
|
|
40
41
|
// run's folders (on a disk its launch named, the caller's, too: the run's own folder there, never the disk), settings
|
|
@@ -127,6 +128,14 @@ export async function purgeAgent(host, agentId) {
|
|
|
127
128
|
}
|
|
128
129
|
/** The setting that marks agent `agentId`'s purge begun and not finished (purgeAgent). */
|
|
129
130
|
export const purgingKey = (agentId) => `agent.purging.${agentId}`;
|
|
131
|
+
/** A DELETE of a run, or of agent `agentId`, already purged: 204 with no purge, but what a purge that committed and then
|
|
132
|
+
* threw left undone (its scrub's marker not written, sqlite/store.ts #purged): the scrub arranged again (store
|
|
133
|
+
* purgeScrub), and the agent's purge mark dropped (purgeAgent removes it only after its store purge returns). */
|
|
134
|
+
export async function purgedAgain(host, agentId) {
|
|
135
|
+
await host.store.purgeScrub();
|
|
136
|
+
if (agentId !== undefined)
|
|
137
|
+
await host.store.settings.remove(purgingKey(agentId));
|
|
138
|
+
}
|
|
130
139
|
/** Purges run `runId` with every run made from it, as the header says. 404 not_found when it is not there; 409
|
|
131
140
|
* run_not_final, nothing purged, while it or a run made from it is live. A purged run is no work. */
|
|
132
141
|
export async function purgeRun(host, runId) {
|
|
@@ -134,7 +143,7 @@ export async function purgeRun(host, runId) {
|
|
|
134
143
|
if (!run)
|
|
135
144
|
throw new ApiError("not_found", `no run ${runId}`);
|
|
136
145
|
if (run.purgedAt !== null)
|
|
137
|
-
return;
|
|
146
|
+
return purgedAgain(host);
|
|
138
147
|
const made = await madeFromAll(host, runId);
|
|
139
148
|
const live = await liveOf(host, [run, ...made]);
|
|
140
149
|
if (live.length)
|
|
@@ -168,7 +177,7 @@ async function purgeOneOrRefuse(host, agentId, runId, purged, alone) {
|
|
|
168
177
|
// Its answer and input as this process last served them, dropped whatever the purge answered: every route of it is 410
|
|
169
178
|
// once it committed, so none is read again. A purge can commit and still throw (its checkpoint held back and the
|
|
170
179
|
// scrub's marker not written, sqlite/store.ts #purged), and no later DELETE comes back here (purgeRun: a purged run is
|
|
171
|
-
//
|
|
180
|
+
// only purgedAgain). One that did not commit loses a cache its next read fills again.
|
|
172
181
|
forgetServed(host.store, runId);
|
|
173
182
|
}
|
|
174
183
|
}
|
package/dist/agents-store.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type AgentRow, type NewRevision, type RevisionPlace, type RevisionRow, type Store, type TemplatePackage } from "./store/index.js";
|
|
2
2
|
import { type DefinitionBody, type Json } from "./validate.js";
|
|
3
|
-
/** A UUIDv7: time-ordered, so a listing by (created_at, id) is stable, and unique per revision
|
|
3
|
+
/** A UUIDv7: time-ordered, so a listing by (created_at, id) is stable, and unique per revision, per minted agent and per
|
|
4
|
+
* upload (uploads.ts lists files by id, newest first). Two
|
|
4
5
|
* minted in one millisecond keep their order: the 12 bits after the time count them up (RFC 9562's monotonic counter),
|
|
5
6
|
* and a clock that steps back keeps the last millisecond, so each id sorts after the one before it. Without that, two
|
|
6
7
|
* edits in one millisecond tie on created_at and their random ids could number the newer revision first. */
|
|
@@ -20,6 +21,9 @@ export type AgentEntry = {
|
|
|
20
21
|
* apply with agent_id updates it); absent or null for one made otherwise. */
|
|
21
22
|
template?: TemplatePackage | null;
|
|
22
23
|
};
|
|
24
|
+
/** Whether another system owns `agent`: an inline run with `external` made it (its `externalRef` set), so the system that
|
|
25
|
+
* sent it sends its deletes, the agent's whole (DELETE /agents/{id}) and, on an API-only server, a run's purge. */
|
|
26
|
+
export declare const ownedElsewhere: (agent: AgentRow) => boolean;
|
|
23
27
|
/** Refuses a write to an externally owned agent: one that mirrors an agent in another system (its `externalRef` set) is
|
|
24
28
|
* read-only here — its source is the truth, which writes a new version by running it. Edits, set-current and archive are
|
|
25
29
|
* refused (403 forbidden); reads work as for any agent. */
|