@parcha/agentrun-serve 0.1.0-beta.48 → 0.1.0-beta.49
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 +20 -0
- package/README.md +144 -16
- package/dist/agent-delete.d.ts +33 -10
- package/dist/agent-delete.js +184 -26
- package/dist/agents-store.d.ts +6 -2
- package/dist/agents-store.js +18 -5
- package/dist/agents.d.ts +8 -1
- package/dist/agents.js +14 -4
- package/dist/answer-json.d.ts +2 -2
- package/dist/answer-json.js +3 -4
- package/dist/archil-routes.d.ts +1 -1
- package/dist/archil-routes.js +4 -3
- package/dist/browser-sessions.d.ts +56 -0
- package/dist/browser-sessions.js +117 -0
- package/dist/computer-routes.d.ts +4 -15
- package/dist/computer-routes.js +6 -10
- package/dist/console/assets/index-Bzn4eUYF.js +715 -0
- package/dist/console/assets/index-CR2ZGei1.css +1 -0
- package/dist/console/index.html +2 -2
- package/dist/errors.d.ts +4 -1
- package/dist/errors.js +15 -5
- package/dist/import.js +4 -3
- package/dist/learn/check.d.ts +11 -2
- package/dist/learn/check.js +12 -9
- package/dist/learn/promote.d.ts +7 -1
- package/dist/learn/promote.js +47 -0
- package/dist/learn/repick.d.ts +34 -0
- package/dist/learn/repick.js +201 -0
- package/dist/learned-workflow.d.ts +2 -0
- package/dist/learned-workflow.js +18 -1
- package/dist/learning-setting.d.ts +13 -0
- package/dist/learning-setting.js +23 -1
- package/dist/llms.txt +1 -1
- package/dist/openapi.js +170 -12
- package/dist/paid-calls.d.ts +4 -1
- package/dist/paid-calls.js +1 -1
- package/dist/run-learning-served.d.ts +1 -1
- package/dist/run-usage.d.ts +110 -0
- package/dist/run-usage.js +312 -0
- package/dist/runner/adapter-loop.js +51 -20
- package/dist/runner/conformance/harness.d.ts +2 -0
- package/dist/runner/conformance/harness.js +18 -4
- package/dist/runner/feedback-round.d.ts +29 -1
- package/dist/runner/feedback-round.js +54 -3
- package/dist/runner/journal-kinds.d.ts +3 -1
- package/dist/runner/learning-end.js +49 -18
- package/dist/runner/loop-contract.d.ts +3 -0
- package/dist/runner/monid-run.js +2 -2
- package/dist/runner/promotion.js +8 -2
- package/dist/runner/reflect-hook.js +3 -2
- package/dist/runs-over-store.d.ts +3 -2
- package/dist/runs-over-store.js +9 -7
- package/dist/server.d.ts +3 -3
- package/dist/server.js +221 -98
- package/dist/store/index.d.ts +2 -2
- package/dist/store/index.js +1 -1
- package/dist/store/journal/storage.js +1 -1
- package/dist/store/open.d.ts +1 -1
- package/dist/store/open.js +1 -1
- package/dist/store/postgres/migrations/0021_purged.sql +13 -0
- package/dist/store/postgres/migrations/0022_computer_intervals.sql +27 -0
- package/dist/store/schema.d.ts +15 -1
- package/dist/store/schema.js +50 -5
- package/dist/store/sqlite/connection.d.ts +4 -1
- package/dist/store/sqlite/connection.js +5 -0
- package/dist/store/sqlite/run-patch.d.ts +8 -3
- package/dist/store/sqlite/run-patch.js +15 -7
- package/dist/store/sqlite/store.d.ts +5 -2
- package/dist/store/sqlite/store.js +249 -48
- package/dist/store/sqlite/worker.d.ts +9 -0
- package/dist/store/sqlite/worker.js +18 -1
- package/dist/store/store.d.ts +142 -9
- package/dist/store/store.js +63 -0
- package/dist/store-reads/analytics.js +2 -1
- package/dist/store-reads/cap.d.ts +8 -2
- package/dist/store-reads/cap.js +27 -3
- package/dist/store-reads/learning.d.ts +1 -1
- package/dist/store-reads/learning.js +5 -2
- package/dist/store-reads/runs.js +2 -0
- package/dist/store-reads/stats.js +4 -2
- package/dist/store-view.d.ts +7 -0
- package/dist/store-view.js +61 -20
- package/dist/tools.js +9 -0
- package/dist/trigger-targets.d.ts +7 -4
- package/dist/trigger-targets.js +6 -6
- package/dist/triggers.d.ts +2 -1
- package/dist/triggers.js +5 -2
- package/dist/validate.d.ts +4 -2
- package/dist/validate.js +13 -3
- package/dist/viewer-credential.d.ts +3 -4
- package/dist/viewer-credential.js +6 -4
- package/dist/workspace/computer-for-claim.d.ts +5 -1
- package/dist/workspace/computer-for-claim.js +47 -18
- package/dist/workspace/computer-intervals.d.ts +20 -0
- package/dist/workspace/computer-intervals.js +49 -0
- package/dist/workspace/computer-janitor.d.ts +7 -3
- package/dist/workspace/computer-janitor.js +14 -6
- package/dist/workspace/computer-kept.d.ts +7 -2
- package/dist/workspace/computer-kept.js +9 -2
- package/dist/workspace/resolve-computer.d.ts +7 -4
- package/dist/workspace/resolve-computer.js +21 -32
- package/dist/workspace/run-end-computers.d.ts +1 -0
- package/dist/workspace/run-end-computers.js +4 -1
- package/package.json +10 -10
- package/dist/console/assets/index-CTGegcKt.css +0 -1
- package/dist/console/assets/index-D1Se6mgG.js +0 -715
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,26 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## 0.1.0-beta.49 (2026-11-20)
|
|
6
|
+
|
|
7
|
+
- An agent's `learning` takes `repick: true` (off by default): a learned workflow compiled after it re-picks a missed <!-- changes/learning-repick-pages.md -->
|
|
8
|
+
quote from the pages its run fetched, not from its compact notes alone. The server rewrites the passing draft before it
|
|
9
|
+
commits it: the answer's re-pick loop runs the answer step as compiled first, then, on a miss, the same step reading
|
|
10
|
+
the pages, told they are untrusted data and never instructions, with no tools. `learning.repick_max_chars` (150000 by
|
|
11
|
+
default, 1 to 400000) caps the characters that second pass sends, the longest pages cut first. Its cost is the served
|
|
12
|
+
run's, under the run's cost cap. The setting is read at each compile, so a change reaches only workflows compiled after
|
|
13
|
+
it; agents whose workflows run through an SDK bridge ignore it.
|
|
14
|
+
- A purged run's or agent's content no longer stays in the SQLite store's file bytes: every store connection writes with `secure_delete` on, so a deleted or overwritten row's bytes are zeroed in its page, and a purge checkpoints the WAL (`TRUNCATE`) once it commits, so neither `store.sqlite` nor its `-wal` keeps an earlier copy. The checkpoint waits a few milliseconds for another connection, never the store's 10 s busy wait, so it holds up no other request. One another connection holds back is retried once, then logged (the next purge's checkpoint or the server's stop clears it), and never fails the `DELETE`. Postgres is not covered: `VACUUM` only makes a purged row's space reusable, so its bytes stay until a later write overwrites them; `VACUUM FULL` rewrites the table; Postgres's WAL, archived WAL and backups keep the old values for their own lifetimes. <!-- changes/purge-secure-delete.md -->
|
|
15
|
+
- `DELETE /v2/runs/{run_id}` purges a run that is not live: its launch, journal and timeline, messages, outputs and files, folders, kept answers, its agent's grades of it, its kept learning's content and what its agent's promotion records copied from it (a disagreement's input and answers; each record's decision, numbers and run ids stay) go, with the runs made from it (its audit's shadow run, the replay runs of its input, a learning run that grades it); no replay or shadow run of a purged run is started. Its row stays as a tombstone (id, agent, state, times, cost, purge time): `/usage`, `/stats` and a cap's spend read are unchanged, every route of the run answers `410 purged` with the tombstone in `details`, and no run list shows it. A second `DELETE` is `204`; a live run (queued, working, waiting on a person, or held by a runner) is `409 run_not_final`, nothing purged; a purge stopped part way is finished by the next `DELETE`. A message, a trigger's message or a grade sent to the run while its `DELETE` runs waits for it and is then `410 purged`. `DELETE /v2/agents/{agent_id}` now purges an archived agent made here the same way (its definition, learning, triggers, sign-ins, computer, disk and folders go, its runs become tombstones, its row is a tombstone answering `410 purged`); one not archived is `409 agent_not_archived`, which replaces `agent_not_external`. An unarchive or a write sent to the agent while its purge runs (its home, its definition, a move of its current revision) is `410 purged` once it ends, as is a definition edit or a template update whose body arrives after it, and a trigger made for a purged agent or moved to it: nothing of a purged agent is written again; after a purge stopped part way, each is `409 agent_not_runnable` until a `DELETE` finishes it. An agent another system owns is deleted whole, as before. Both deletes take the owner's session or the API token: any other console session is `403 forbidden`. The TypeScript client, the Python client and the CLI (`agentrun runs delete`) carry the new operation. <!-- changes/run-delete.md -->
|
|
16
|
+
- `GET /v2/runs/{run_id}/usage` (`runusage/1`) says what one run cost, line by line, and whose invoice each part lands on: `tokens` per model (`model`, and `provider` where the server sent the requests itself; null behind a gateway), `tools` per charger (`charged_by`, with calls of unpriced tools in `not_metered_calls`), and `browser_time` per browser provider (`provider`, seconds). Each line has its quantity as measured, its dollars as the run's booking holds them, and its basis (`reported`, `estimate`, `unpriced`). It reads the same for a pi run, a CLI-harness run and a workflow run (its decisions on the model that answered them). The lines join to `total`, the run's `cost.usd`; a charge of unknown cost is null with what is known beside it, never $0. `ended_at` is the end the lines cover: a follow-up can reopen an ended run, and a later read with another `ended_at` says it moved. The console's Dev tools tab shows the lines as "Cost by line". In the kernel, a paid request may say `reported` (it settles at the provider's own figure), written on its `runner.request`. <!-- changes/run-usage-lines.md -->
|
|
17
|
+
- `GET /v2/computers`' `folder` field is described by its rule alone, naming no vendor: `bind` a folder of this machine (Mode 1), `archil` the owner's Archil disk where the provider takes an Archil mount, has Archil's image and does not dial this server, `sync` a synced folder the runner keeps for any other computer that takes a folder in Mode 2, null none. The computer package's README no longer says a program of the user can join the window manager's namespace with nsenter: root made it, and the user holds no capability there. A Daytona desktop on exec is refused in the shared refusal's words alone. `runConformance` takes `onScreenshot(png)`, called with screen.screenshot-size's last whole screenshot. <!-- changes/computer-untangle-16.md -->
|
|
18
|
+
- In the console, updating an agent from a template (Update <agent>) now says it was updated and names the new revision ("Updated: rev 2"). It used to say the template was applied and "The agent is made", as if the apply had made a new agent. Only an Apply that makes a new agent says "made". <!-- changes/template-update-says-updated.md -->
|
|
19
|
+
- A scheduled run handed its previous result's `x-carried` fields is told how many entries each carried array lost from its front, "the first N entries" (the template keeps the array oldest first), no longer "the N oldest": the engine drops from the front and reads no dates. A stored `x-carried` the save would refuse (a repeated, unknown or empty name) is read as none, so its run gets the too-large line. `submitParameters` leaves every `x-` keyword out of submit tool schemas, as it does `criteria`, not only `x-carried`; a property or definition so named keeps its name. <!-- changes/x-carried-first-entries.md -->
|
|
20
|
+
- A run's look-back (its own after its job, or the feedback round a grade opens) keeps the run's end: GET, the list, SSE and the console show it completed (or failed) with its answer and `ended_at` while its learning reads `reflecting`, polled until it settles, and it tells `run.ended` once. Stop and cancel refuse it then, and a runner-side stop or cancel that lands mid-round drops only the round, so a graded run is never left cancelled or stopped. A runner lost during the look-back leaves the next one the same end at the same time. `PUT /runs/{run_id}/grade` during a look-back is `409 run_learning` (a new error code), nothing kept: grade the run once its learning moves on from `reflecting`. The console shows no Grade form then, and says why. <!-- changes/grade-keeps-run-end.md -->
|
|
21
|
+
- `GET /v2/runs/{run_id}/usage` gives `browser_sessions` (`runusage/2`): one record per browser session the run opened, with the provider's session id, when the server opened it and let it go, why it ended, the seconds charged for it, and the provider's own record of it (`provider_record`: its start, end and proxy bytes), read once when the session is let go. With it a person running AgentRun sees how long each session ran, spots one that ended late or was lost, and finds each on the provider's own dashboard and invoice by its id. A provider that keeps no record, or a read that fails, says so in `provider_record_status`, with the record null, never zeros. In the computer package, a browser provider may offer `sessionUsage(ref)`, the vendor's record of a session; Browserbase's reads `GET /v1/sessions/{id}`. <!-- changes/run-usage-browser-sessions.md -->
|
|
22
|
+
- `GET /v2/runs/{run_id}/usage` gives `computer_intervals` (`runusage/3`): one record per computer the run made through its provider (a sandbox, a desktop or a phone), by when each was made, with the provider's own id for it (`provider_id`), its `kind`, what its create asked for (`gpu`, `cpus`, `memory_mb`; null where it asked none, never a guess), when the create answered (`started_at`), when the provider's delete of it answered ok (`ended_at`), and whether the run's park kept it past its claim (`kept`). With it a person running AgentRun sees how long each of a run's computers lived, finds one left running after its run (`ended_at` null: no delete was proven, never a guessed end), and matches the provider's invoice by its id. The server writes the store's new `computer_intervals` table (Postgres migration `0022_computer_intervals.sql`; a SQLite store gets it at the server's open) at the claim's create, the park, and every delete that answers ok: the claim's release, a later claim letting an earlier one's go, the run's end, a kept computer's end, and the janitor's sweeps. A write that fails is said on the runner's log and never fails the run. The agent's own computer, a paired one and `--faux`'s have no record. Computer time is not priced: it is on no line and not in `total`. A `tools` line now names its `provider` too, the same vendor as `charged_by`; a `tokens` line behind a model gateway keeps `provider` null, since the server does not know the gateway's upstream. <!-- changes/computer-intervals.md -->
|
|
23
|
+
- An agent whose `input_schema` has fields of its own, all optional, takes a run that gives one of them and no `content`: a template's `pr_number` run by hand (`{"pr_number": 3318}`) starts, where it was refused 422 `input.content is required`, though the schema left `content` out and closed the object. A run still has to say something: an input with neither `content` nor any of those fields is refused at `input.content`, naming the fields that would do instead. A schema with no field of its own, or with one required, is unchanged. <!-- changes/input-content-or-field.md -->
|
|
24
|
+
|
|
5
25
|
## 0.1.0-beta.48 (2026-11-20)
|
|
6
26
|
|
|
7
27
|
- A harness module builds its harness the way the built-in harnesses are built: `entries(builtins, kit)` now gets a kit with `kit.adapterEntry(facts, adapter)` and `kit.acpEntry({ facts, recipe, proxy })`, so the harness is offered its wire's vendor's models, named on that vendor's and OpenRouter's key rows, and gated and named by its own facts. [HARNESS.md](../../HARNESS.md) is the guide, and `examples/harness-module` is a whole module (Goose under an id of its own). <!-- changes/harness-modules-kit.md -->
|
package/README.md
CHANGED
|
@@ -2680,8 +2680,9 @@ so the store's files keep no copy of the old row: neither the one rewritten nor
|
|
|
2680
2680
|
free space. A marker beside the database (`store.sqlite.scrub`) is written before the rewrite and removed once the
|
|
2681
2681
|
checkpoint is done. A `VACUUM` held off by another connection's write past the store's busy wait is tried once more
|
|
2682
2682
|
after a short pause. A start that finds the marker (the server stopped mid-way, or another connection held the
|
|
2683
|
-
`VACUUM` or the checkpoint back, logged as `store_scrub_not_done`) runs the scrub again. On Postgres the old row version
|
|
2684
|
-
|
|
2683
|
+
`VACUUM` or the checkpoint back, logged as `store_scrub_not_done`) runs the scrub again. On Postgres the old row version
|
|
2684
|
+
stays on disk as a purged row's does (Purging a run or an agent made here: on disk). The log line names the trigger and
|
|
2685
|
+
the field, never the value.
|
|
2685
2686
|
|
|
2686
2687
|
The create is refused before Composio is asked anything with `409 composio_no_public_url` when the server has no public
|
|
2687
2688
|
address (`AGENTRUN_PUBLIC_URL`): Composio could not reach it. `features.triggers.public_url` on `GET /v2/capabilities`
|
|
@@ -2884,12 +2885,13 @@ failed, 2 when nothing ran. The runner, the graders and the report are in
|
|
|
2884
2885
|
| `GET /health` | Without a credential: whether the store reads and the disk has room ([capacity and health](#capacity-and-health)). |
|
|
2885
2886
|
| `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. |
|
|
2886
2887
|
| `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. |
|
|
2887
|
-
| `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.
|
|
2888
|
+
| `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. |
|
|
2888
2889
|
| `PUT /agents/{id}/definition` | The same body, checked [the same way](#models): a new revision, its parent the current one, made current. Without `skills` the current revision's skill files carry over. A definition that is the current revision already writes nothing, so a PUT sent twice makes one revision. An agent's id and name stay those it was made with (another name is `422` on `definition.name`). Its description is a label kept on the agent, not on a revision: a PUT that names a new one makes the next revision (even when nothing else changed) and writes the description with it in one commit, so a stale or refused edit changes neither; a PUT that leaves it out keeps it. `If-Match` that is not the current ETag is `412 precondition_failed`; the store compares it again inside the commit, so of two edits that read the same revision exactly one lands. The contract's body is taken too: the definition itself, with `If-Match` required (`412` without it) and `definition.version` greater than the current one (`422`). Any such version is taken, and always makes a new revision, the same definition included; the revision is numbered as this server numbers them, the next, and the answer says which; the route reads a body holding `definition` as this one, any other as the contract's. |
|
|
2889
2890
|
| `GET /agents/{id}/revisions` | The agent's revisions, newest first: `revision`, `version`, `parent`, `kind`, `current`, `note`, `created_at` and the `definition`. |
|
|
2890
2891
|
| `POST /agents/{id}/current` | `{revision}`: one of the agent's revisions becomes current again. |
|
|
2891
2892
|
| `POST /agents/{id}/archive`, `POST /agents/{id}/unarchive` | [Archiving](#archiving): hides the agent and its runs from the lists, or shows them again. Answers the agent, with `archived_at`. |
|
|
2892
|
-
| `DELETE /agents/{id}` | This server's own route (`x-agentrun-serve: "agentdelete/1"`): [deletes an agent another system owns](#deleting-an-agent-another-system-owns) (one an inline run made) whole. `204`; an agent made here is `409
|
|
2893
|
+
| `DELETE /agents/{id}` | This server's own route (`x-agentrun-serve: "agentdelete/1"`): [deletes an agent another system owns](#deleting-an-agent-another-system-owns) (one an inline run made) whole, and [purges](#purging-a-run-or-an-agent-made-here) an archived agent made here. `204`; an agent made here not archived is `409 agent_not_archived`. |
|
|
2894
|
+
| `DELETE /runs/{id}` | This server's own route (`x-agentrun-serve: "purge/1"`): [purges](#purging-a-run-or-an-agent-made-here) a run that is not live, its cost kept in every total. `204`, again on a second `DELETE`; a live run is `409 run_not_final`, and every route of a purged run is `410 purged`. |
|
|
2893
2895
|
| `DELETE /agents/{id}/sign-ins/{key}` | This server's own route (`x-agentrun-serve: "signins/1"`): forgets one of the agent's [saved sign-ins](#saved-sign-ins), at its vendor and here. `409 sign_in_held` while a run holds its save lease, or while a run it was handed is still going. |
|
|
2894
2896
|
| `POST /agents/{id}/runs`, `GET /agents/{id}/runs` | A run of the current revision, or of `revision`. An agentic run's input is `{content: string}`; a workflow run's is what its workflow's input schema takes. `file_ids` names [uploaded](#uploads) files, copied into the run's `work/inputs/` before it starts and named in its first message. `labels` (this server's own, `runlabels/1`) is the caller's map of its own strings for the run: at most 16 keys, each 1 to 63 letters, digits, `.`, `_`, `-` or `/` starting with a letter or a digit, each value 1 to 256 characters with no control character; kept as given, served as `labels` on every read of the run (`{}` when none), never read by the server otherwise, so no place for a secret. The agent's runs, newest first; `label` filters them as `GET /runs` does. |
|
|
2895
2897
|
| `GET /runs` | Every agent's runs, newest first, a page of at most 100; `agent`, `revision` and `status` narrow it, `label=<key>:<value>` (`runlabels/1`, split at the first `:`, once per request) keeps the runs holding that label, and `archived=true` lists only archived ones. A failed run's summary carries its `error`, and a waiting run's its `pending`. |
|
|
@@ -2903,6 +2905,7 @@ failed, 2 when nothing ran. The runner, the graders and the report are in
|
|
|
2903
2905
|
| `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"`). |
|
|
2904
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 alone, no run's files opened. Archived agents and runs are left out of every number but `archived`. A completed or cancelled run counts only in `runs.total`, but for an escalated one (completed, waiting for a person's review), which `needs_review` (`stats/3`) counts; `failed` never does. Each running run is in exactly one of `active` (queued or working) and `needs_input` (`input_required`), both from the runs this server holds, and `status_unknown`: a running run it does not hold, or holds as ended before its end is written. `cost.usd` sums the runs that ended with a cost and is null when none did, never $0, with `basis` (`reported`, `estimate` or `unpriced`: [A run's cost](#a-runs-cost-its-tokens-and-its-basis)), or null beside a null `usd`; `unknown_runs` counts the rest. `analytics` (`stats/2`) sums the runs' metrics over the runs not archived that the `from` and `to` query parameters (RFC 3339 date-times to the millisecond, an impossible one or a finer fraction refused; runs started in [`from`, `to`)) and `agent` pick, each optional, 400 when malformed: `filter` echoes them; `totals` (runs, completed, an escalated run included, `needs_review` (`stats/3`), failed, never an escalated run, `runs_with_metrics`, tokens and each token kind, requests, unmetered, `cost_usd` and `unknown_cost_runs`), `time` (`wall_ms` over the ended runs, `active_ms` where metrics have it), `by_harness_effort`, `by_day` (UTC), `by_source` (`live` or the import source) and the top 20 `tools`. A run with no metrics counts in `runs` and in no token sum. `learning` (`learning/1`) counts the runs that tried to learn over the same filters, from the store ([Learning](#learning)). The query bounds `analytics` and `learning` alone. |
|
|
2905
2907
|
| `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. |
|
|
2906
2909
|
| `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. |
|
|
2907
2910
|
| `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`. |
|
|
2908
2911
|
| `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`. |
|
|
@@ -2985,15 +2988,8 @@ serves these routes alone:
|
|
|
2985
2988
|
- `GET /capabilities`, `GET /health` and `GET /usage`;
|
|
2986
2989
|
- a run's desktop or phone, for a backend that shows its user the live view and lets them take over: see below.
|
|
2987
2990
|
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
browser, the backend asks `POST /runs/{id}/computer/viewer` for `{ url, expires_at }`: a link on `AGENTRUN_PUBLIC_URL`
|
|
2991
|
-
(refused in words when it is unset) to the run's live page, with a viewer credential in its query that opens that run's
|
|
2992
|
-
page and socket, from the public address alone, for 5 minutes. The credential is an HMAC of the run and its expiry under
|
|
2993
|
-
a key from the seal key, so every server on the store checks it, across restarts; the run's end (completed, failed or
|
|
2994
|
-
cancelled) revokes it and closes a socket open on it, and a stop does not, as the run goes on. The person watches, and
|
|
2995
|
-
takes over and hands back in the viewer's own bar; nothing else opens to the credential. A server that is not API-only
|
|
2996
|
-
answers the mint `404`, and its live page takes the owner's sign-in alone.
|
|
2991
|
+
Here a run's computer routes take the server's token. `POST /runs/{id}/computer/viewer` mints a 5-minute link on
|
|
2992
|
+
`AGENTRUN_PUBLIC_URL` that opens that run's live page and socket until the run ends (API doc).
|
|
2997
2993
|
|
|
2998
2994
|
Every other address is `404 not_found`, answered before the request is read further: the console at `/` and its
|
|
2999
2995
|
assets, sign-in and setup, every `/settings` route, `POST /mcp`, triggers and their
|
|
@@ -3302,9 +3298,9 @@ typed answers and their probabilities.
|
|
|
3302
3298
|
|
|
3303
3299
|
## Archiving
|
|
3304
3300
|
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
archived here). These routes are this server's own, outside the `/v2` contract, like `GET /runs` and an agent's
|
|
3301
|
+
Archiving an agent made here or a run hides it and keeps everything of it; [purging](#purging-a-run-or-an-agent-made-here)
|
|
3302
|
+
removes what it was given and did, its cost kept, and an agent made here is purged only once archived (an agent another
|
|
3303
|
+
system owns is [deleted](#deleting-an-agent-another-system-owns), and is never archived here). These routes are this server's own, outside the `/v2` contract, like `GET /runs` and an agent's
|
|
3308
3304
|
revisions; capabilities list them in `features.archive`.
|
|
3309
3305
|
|
|
3310
3306
|
- `POST /v2/agents/{id}/archive` hides the agent and its runs from `GET /agents`, `GET /runs` and
|
|
@@ -3324,6 +3320,54 @@ revisions; capabilities list them in `features.archive`.
|
|
|
3324
3320
|
already going when its agent is archived keeps going.
|
|
3325
3321
|
- The store keeps an archive as `archived_at` on the agent's or the run's row, null when it is not archived.
|
|
3326
3322
|
|
|
3323
|
+
## Purging a run or an agent made here
|
|
3324
|
+
|
|
3325
|
+
An owner must be able to delete what a run read. `DELETE /v2/runs/{id}` purges a run that is not live; what it cost
|
|
3326
|
+
stays in every total.
|
|
3327
|
+
|
|
3328
|
+
| Purged | Kept |
|
|
3329
|
+
| --- | --- |
|
|
3330
|
+
| Its launch record (input, prompt), journal and timeline, messages and commands, outputs and files, the answers kept under its idempotency keys, its folders (here, and its own folder on an Archil disk; the disk is kept), its settings, its labels and summary, its agent's grades of it, and its kept learning's content | Its row, as its tombstone: id, agent, state, how it ended (a code), started and ended, `cost_usd` (an upper bound when that is all it has), its paid tools' cost, its purge time, how its learning ended (for `/stats`), and the spend figures `/usage` and a cap read from its journal, and the intervals of the computers it made (each a provider's id and its times). Its metrics keep their figures alone: counts by tool name, the effort and the cost basis, no grader's words, call arguments or results |
|
|
3331
|
+
| Its kept learning's turn and proposal | Each kept learning row as a link alone (the run's and its learning run's ids, its state): `/usage`'s learning line reads it, and it keeps its learning run out of every run list |
|
|
3332
|
+
| What a promotion record copied from it: a check's or an audit's disagreement's input, answers and the grader's words, and the words a hold's reason quoted from them | The record's decision, numbers and run ids, the run's among them |
|
|
3333
|
+
|
|
3334
|
+
- Every route of a purged run is `410 purged`, `details` its tombstone; no run list shows it. `/usage`, `/stats` and
|
|
3335
|
+
the spend a cap reads are as they were. A second `DELETE` is `204`; a run never here is `404`.
|
|
3336
|
+
- The runs made from it are purged with it, each a tombstone: its audit's shadow run, the replay runs of its input,
|
|
3337
|
+
and a learning run its kept learning names. A replay or a shadow run a check or an audit starts while the `DELETE`
|
|
3338
|
+
runs holds it: `409 run_not_final` naming that run, the run not purged, and the next `DELETE` purges both. Once the
|
|
3339
|
+
run is purged, no replay or shadow run of it is started.
|
|
3340
|
+
- A live run (queued, working, waiting on a person or an approval, or held by a runner), or a live run made from it,
|
|
3341
|
+
is `409 run_not_final` (`details.runs`), nothing purged: cancel it first. A run that ended and takes a follow-up
|
|
3342
|
+
(idle), or that a person stopped, is not live. Such a run reads idle a moment before its runner writes it ended: a
|
|
3343
|
+
`DELETE` then waits for that, up to 30 seconds, and purges it.
|
|
3344
|
+
- A message, a trigger's message or a grade sent to the run while its `DELETE` runs waits for it, then is `410 purged`:
|
|
3345
|
+
nothing opens the run again or keeps a grade of it under its purge.
|
|
3346
|
+
- `503 unavailable` while its folder on an Archil disk is not deleted there yet: the run is not purged, and the next
|
|
3347
|
+
`DELETE` finishes it, as it finishes a purge that stopped part way (its purge time is set last).
|
|
3348
|
+
- On disk. On both stores the purge deletes or blanks the rows above; what the database files keep differs.
|
|
3349
|
+
- **SQLite:** every store connection writes with `secure_delete` on, which zeroes the bytes a write frees, and a run's
|
|
3350
|
+
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 is retried once, then logged, and the
|
|
3352
|
+
next purge's checkpoint or the server's stop clears it. Copies outside the file are out of scope: backups,
|
|
3353
|
+
snapshots, the filesystem's own journal.
|
|
3354
|
+
- **PostgreSQL** (not closed): a purged row's old version stays in its table as a dead tuple. `VACUUM` (or
|
|
3355
|
+
autovacuum, on its schedule) only marks its space reusable; the bytes stay in the data file until a later write
|
|
3356
|
+
overwrites them. `VACUUM FULL` rewrites the table into a new file (under an exclusive lock), and the old file's
|
|
3357
|
+
blocks go back to the filesystem unwiped. Postgres's own WAL and its archived WAL keep the old values until they are
|
|
3358
|
+
recycled or expire, and backups keep them for their retention.
|
|
3359
|
+
- Its agent's other runs and what the agent learned are kept: a promotion record and the learning folder's history
|
|
3360
|
+
may still name the run's id.
|
|
3361
|
+
- It takes the owner's session (the password sign-in, or the console on a server bound to loopback) or the API token;
|
|
3362
|
+
any other console session is `403 forbidden`, no credential `401`.
|
|
3363
|
+
|
|
3364
|
+
An agent made here is purged the same way once archived: `DELETE /v2/agents/{id}`. Its revisions' content, name and
|
|
3365
|
+
description, learning, triggers, saved sign-ins, own computer, disk and folders go, and each of its runs is purged.
|
|
3366
|
+
Its row stays as its tombstone (id, archive and purge times): every route of it is `410 purged`, and no list shows it.
|
|
3367
|
+
Not archived: `409 agent_not_archived`. A live run of it: `409 run_not_final`. Purging one agent touches no other.
|
|
3368
|
+
An unarchive or a write to it sent while its `DELETE` runs waits for it, then is `410 purged`; after a purge stopped
|
|
3369
|
+
part way, each is `409 agent_not_runnable` until a `DELETE` finishes it.
|
|
3370
|
+
|
|
3327
3371
|
## Deleting an agent another system owns
|
|
3328
3372
|
|
|
3329
3373
|
An agent made by an inline run (`POST /v2/runs` with `external`) belongs to the system that sent it, which may have to
|
|
@@ -3682,6 +3726,14 @@ round on the agent's `main`, whatever its harness:
|
|
|
3682
3726
|
promotion check (below) decides whether it serves. A compile whose drafts all failed is recorded as the compile's
|
|
3683
3727
|
attempt (compile once), and its errors are on the run's learning (`draft_errors`), never silent.
|
|
3684
3728
|
[`src/learn/SPEC.md`](src/learn/SPEC.md) has the rules.
|
|
3729
|
+
- Its answer's quote re-pick, with `learning.repick: true` (off by default): a workflow whose answer quotes the pages
|
|
3730
|
+
its run fetched re-picks once when a quote is in none of them. Off, the re-pick reads its compact notes and its failed
|
|
3731
|
+
draft. On, the server rewrites the passing draft before it commits it, so the re-pick reads the pages themselves,
|
|
3732
|
+
sent as untrusted data (the model is told never to follow anything written in them, and the step has no tools), at
|
|
3733
|
+
most `learning.repick_max_chars` characters of them (150000 by default, 1 to 400000; past it the longest pages are
|
|
3734
|
+
cut first). Its request is the served run's, under the run's cost cap. The setting is read at each compile: turning
|
|
3735
|
+
it on or off changes only the workflows compiled after that, never one already kept. An agent whose workflows run
|
|
3736
|
+
through an SDK bridge ignores it.
|
|
3685
3737
|
|
|
3686
3738
|
The turn runs under the run's own cap, with no reserve, and within 10 minutes; its rows are labelled `learning`, and the
|
|
3687
3739
|
run's answer stays the job's. While it runs, the run reads `reflecting` on every harness. A run with no words from its
|
|
@@ -3866,6 +3918,82 @@ and says how its figure was reached.
|
|
|
3866
3918
|
|
|
3867
3919
|
The console shows the tokens beside the run's cost, and the figure says its basis: `$0.0042 est.`, `$0.0042 reported`.
|
|
3868
3920
|
|
|
3921
|
+
## A run's cost, line by line
|
|
3922
|
+
|
|
3923
|
+
`GET /runs/{id}/usage` (`runusage/1`) says what one run cost and where each part goes: its model requests by model, its
|
|
3924
|
+
paid tool calls by who charged for them, its browser time by browser provider. It answers "what did this run cost, and
|
|
3925
|
+
whose invoice does each part land on?" for every run that books its cost: a pi run, a run on a CLI harness that sends
|
|
3926
|
+
its model requests through this server, and a workflow run with its decisions. The console's Dev tools tab shows it
|
|
3927
|
+
under "Cost by line". Each line has its quantity as measured, its dollars as the run's booking holds them, and how those
|
|
3928
|
+
were reached. Nothing is priced here, and nothing is rounded to a billing increment or topped up to a minimum.
|
|
3929
|
+
|
|
3930
|
+
```json
|
|
3931
|
+
{ "run_id": "run_…", "ended_at": "2026-11-19T10:01:30.000Z", "currency": "USD", "total": { "usd": 0.0566 }, "reason": null,
|
|
3932
|
+
"lines": [
|
|
3933
|
+
{ "meter": "tokens", "model": "claude-sonnet-5-5", "provider": "anthropic", "charged_by": null, "quantity": 3300, "unit": "token",
|
|
3934
|
+
"basis": "reported", "usd": 0.0036, "requests": 3, "tokens": { "input": 3000, "output": 300, "cache_read": 0, "cache_write": 0 },
|
|
3935
|
+
"unmetered_requests": 0 },
|
|
3936
|
+
{ "meter": "tools", "model": null, "provider": "monid", "charged_by": "monid", "quantity": 1, "unit": "call", "basis": "reported", "usd": 0.003 },
|
|
3937
|
+
{ "meter": "tools", "model": null, "provider": "docs", "charged_by": "docs", "quantity": 1, "unit": "call", "basis": "estimate", "usd": 0.05,
|
|
3938
|
+
"not_metered_calls": 2 } ],
|
|
3939
|
+
"browser_sessions": [],
|
|
3940
|
+
"computer_intervals": [
|
|
3941
|
+
{ "provider": "daytona", "provider_id": "5f0c…", "kind": "sandbox", "gpu": null, "cpus": null, "memory_mb": null,
|
|
3942
|
+
"started_at": "2026-11-19T10:00:04.000Z", "ended_at": "2026-11-19T10:01:31.000Z", "kept": false } ] }
|
|
3943
|
+
```
|
|
3944
|
+
|
|
3945
|
+
- `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
|
|
3947
|
+
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
|
+
upstream. A model reached two ways is two lines, one per provider. `quantity` is the input, cache read, cache write and
|
|
3949
|
+
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
|
+
- `tools`: one line per charger (`charged_by`: `monid`, an MCP server's name, `parallel`), the vendor whose invoice the
|
|
3951
|
+
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
|
+
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). Calls of a tool with no price set ran outside the run's cost, as `GET /usage` counts
|
|
3954
|
+
them: `not_metered_calls`, in neither `quantity` nor `usd`.
|
|
3955
|
+
- `browser_time`: one line per browser provider (`provider`). `quantity` is the seconds this server's clock charged the
|
|
3956
|
+
provider's sessions for, the provider's minimum per session included as the browser charged it; `basis` is
|
|
3957
|
+
`estimate`, the provider's price per hour on this server's clock, never its invoice.
|
|
3958
|
+
- A field a meter does not use is null, and so is a name the record does not keep: never `""`.
|
|
3959
|
+
- A charge of unknown cost makes its line's `usd` null, with `so_far_usd` and `unpriced` beside it, never $0. `total`
|
|
3960
|
+
joins the lines by the rule `cost.usd` is, so `total.usd` is the run's `cost.usd`, with the same `so_far_usd`,
|
|
3961
|
+
`unpriced` and `upper_bound` beside it; the `tools` lines sum to `cost.tools_usd`.
|
|
3962
|
+
- Learning is not on the lines. A learning run's end-of-run turn is this server's work for the agent, not the run's
|
|
3963
|
+
task, and `cost.usd` leaves it out too; its spend is `learning_usd` on the run read.
|
|
3964
|
+
- When the lines can change: only while the run works. A follow-up opens an ended run again (a trigger's often does),
|
|
3965
|
+
and it ends again later. `ended_at` is the end the lines cover: keep it with them, and read again at `run.ended`, which
|
|
3966
|
+
fires at each end. A later read with another `ended_at`, or null, means the run moved since.
|
|
3967
|
+
- `lines` and `total` are null, with `reason`, while the run is at work (`running`), for a run whose figure is not its
|
|
3968
|
+
booking's (`not_booked`: an imported, native or SDK run, or a CLI run whose model requests went past its proxy), and
|
|
3969
|
+
for a learning run a follow-up opened again (`reopened`, whose booking can't be split by round).
|
|
3970
|
+
- Computer time is not priced yet: no line carries it, and its cost is not in `total`. What the run's computers did is
|
|
3971
|
+
in `computer_intervals` (below), so it can be measured and matched to the provider's invoice.
|
|
3972
|
+
- `browser_sessions` (`runusage/2`) holds one record per browser session the run opened, in the order it opened them.
|
|
3973
|
+
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
|
+
own dashboard and invoice by its id: the provider's id for the session (`provider_session_id`), when
|
|
3975
|
+
this server opened it and let it go (`started_at`, `ended_at`), why it ended (`release_reason`), the seconds charged
|
|
3976
|
+
for it (`charged_seconds`, what the line sums), and the provider's own record of it, read once when it was let go
|
|
3977
|
+
(`provider_record`: its `started_at`, `ended_at` and `proxy_bytes`). Browserbase keeps such a record; a provider that
|
|
3978
|
+
keeps none says `provider_record_status: "not_offered"`, and a read that failed says `failed`, with `provider_record`
|
|
3979
|
+
null, never zeros. A session whose end was never recorded (its run's process lost first) has `ended_at` null.
|
|
3980
|
+
`charged_seconds` are the seconds charged for the session, its provider's minimum included where the browser charged
|
|
3981
|
+
one at the release, as on the `browser_time` line; how long it ran is `ended_at` less `started_at`.
|
|
3982
|
+
- `computer_intervals` (`runusage/3`) holds one record per computer the run made through its provider (a sandbox, a
|
|
3983
|
+
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
|
+
left running after its run, and match the provider's invoice by its own id: the provider (`provider`, this server's
|
|
3985
|
+
name for it, as the agent's computer setting names it), the provider's id for the computer (`provider_id`), its
|
|
3986
|
+
`kind`, what its create asked for (`gpu` with its `type` and `count`, `cpus`, `memory_mb`; null where it asked none, as
|
|
3987
|
+
a hosted provider that sizes its own machines is never given numbers, and none is guessed), when the create answered
|
|
3988
|
+
(`started_at`), and when the provider's delete of it answered ok (`ended_at`). `ended_at` is written only on that ok:
|
|
3989
|
+
null means no delete was proven (the computer may still be running, or its delete failed or never answered), never a
|
|
3990
|
+
guessed end. `kept` is true once the run's park kept the computer past its claim, for the person's answer. A computer
|
|
3991
|
+
is ended wherever this server deletes it: the claim's release, a later claim letting an earlier one's go, the run's
|
|
3992
|
+
end, a kept computer's end at its time, and the janitor's sweeps. The agent's own persistent computer (it outlives
|
|
3993
|
+
every run), a paired computer and `--faux`'s are not the run's and have no record; a browser's sessions are in
|
|
3994
|
+
`browser_sessions`. A run's computers made before this server kept them have none either. The records are kept in the
|
|
3995
|
+
store's `computer_intervals` table (keyed by provider and the provider's id), and a purge of the run keeps them.
|
|
3996
|
+
|
|
3869
3997
|
## Spend cap
|
|
3870
3998
|
|
|
3871
3999
|
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,
|
package/dist/agent-delete.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { type Store } from "./store/index.js";
|
|
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
3
|
* folder (learn/delete.ts). Idempotent; refuses with LearningInFlight while learning work of the agent is in flight. */
|
|
4
4
|
export type DeleteLearning = (store: Store, agentId: string) => Promise<unknown>;
|
|
5
|
-
/** A point of a delete a test may stop it at (AgentDeleteHost.at): after step 1, after step 2, in step 3
|
|
6
|
-
* trigger's removal upstream and its settings', between its settings' and its row's, and in step 3 once its
|
|
7
|
-
* and the agent's first run are gone.
|
|
8
|
-
|
|
5
|
+
/** 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
|
+
* between a trigger's removal upstream and its settings', between its settings' and its row's, and in step 3 once its
|
|
7
|
+
* triggers and the agent's first run are gone (a purge's: after its learning, then the same). A run's: once the runs
|
|
8
|
+
* made from it are purged, and once its own things outside its rows are gone (its rows kept). */
|
|
9
|
+
export type AgentDeleteStep = "after_step_1" | "after_step_2" | "in_step_3_trigger" | "in_step_3_trigger_settings" | "in_step_3" | "run_made_from_gone" | "run_forgotten";
|
|
9
10
|
/** What a delete does outside the store's own rows, as the server does it. */
|
|
10
11
|
export interface AgentDeleteHost {
|
|
11
12
|
readonly store: Store;
|
|
@@ -32,19 +33,41 @@ export interface AgentDeleteHost {
|
|
|
32
33
|
removeDisk(agentId: string): Promise<void>;
|
|
33
34
|
/** A final run's things outside its rows: its folders (its own folder on an Archil disk its launch named, read from its
|
|
34
35
|
* launch record, which goes with its rows after; an ApiError (503 unavailable) while that folder is not deleted
|
|
35
|
-
* there), its settings, the answers kept under its idempotency keys.
|
|
36
|
-
|
|
36
|
+
* there), its settings, the answers kept under its idempotency keys. `alone`: its agent's Archil disk stays (a run's
|
|
37
|
+
* purge, or its agent's), so its own folder on that disk is deleted there too; with an external agent's delete that
|
|
38
|
+
* disk went whole. */
|
|
39
|
+
forgetRun(agentId: string, runId: string, alone: boolean): Promise<void>;
|
|
37
40
|
/** The agent's things outside its rows: its folders, its settings, the answers kept under its idempotency keys. */
|
|
38
41
|
forgetAgent(agentId: string): Promise<void>;
|
|
39
|
-
/**
|
|
42
|
+
/** The runs made from run `runId` (store runs.madeFrom, and its audit's shadow run), by id, whether there or not. */
|
|
43
|
+
madeFrom(runId: string): Promise<string[]>;
|
|
44
|
+
/** What agent `agentId`'s learning copied from run `runId`, gone: the grades it keeps of the run dropped, its promotion
|
|
45
|
+
* records' disagreements naming the run blanked, their decisions, numbers and run ids kept (learn/promote.ts
|
|
46
|
+
* forgetRunCopies). */
|
|
47
|
+
forgetCopies(agentId: string, runId: string): Promise<void>;
|
|
48
|
+
/** What run `runId`'s spend reads from its journal, read before its purge removes it (store-reads/cap.ts). */
|
|
49
|
+
kept(runId: string): Promise<PurgeKept>;
|
|
50
|
+
/** Whether run `runId`'s turn is over (it reads idle, a paused workflow aside): its runner writes it final next. */
|
|
51
|
+
turnOver(runId: string): Promise<boolean>;
|
|
52
|
+
/** How long step 1 waits for the agent's runs to be final (a purge: for a run whose turn is over), and how often it reads
|
|
53
|
+
* them meanwhile. */
|
|
40
54
|
readonly waitMs: number;
|
|
41
55
|
readonly pollMs: number;
|
|
42
|
-
/** A test's seam: awaited at each step's point
|
|
43
|
-
|
|
56
|
+
/** A test's seam: awaited at each step's point with the agent's id (a run's step: the run's), so a throw there stops
|
|
57
|
+
* the delete as a crash would. */
|
|
58
|
+
at?(step: AgentDeleteStep, id: string): void | Promise<void>;
|
|
44
59
|
}
|
|
45
60
|
/** Deletes agent `agentId` (another system's, as the route checked) in the three steps above. Throws ApiError
|
|
46
61
|
* runs_in_flight while a run of it is not final by the wait's end, learning_busy while its learning refuses. */
|
|
47
62
|
export declare function deleteExternalAgent(host: AgentDeleteHost, agentId: string): Promise<void>;
|
|
63
|
+
/** Purges archived agent `agentId`, made here (as the route checked), as the header says: 409 run_not_final, nothing
|
|
64
|
+
* purged, while a run of it is live; learning_busy while its learning refuses. */
|
|
65
|
+
export declare function purgeAgent(host: AgentDeleteHost, agentId: string): Promise<void>;
|
|
66
|
+
/** The setting that marks agent `agentId`'s purge begun and not finished (purgeAgent). */
|
|
67
|
+
export declare const purgingKey: (agentId: string) => string;
|
|
68
|
+
/** Purges run `runId` with every run made from it, as the header says. 404 not_found when it is not there; 409
|
|
69
|
+
* run_not_final, nothing purged, while it or a run made from it is live. A purged run is no work. */
|
|
70
|
+
export declare function purgeRun(host: AgentDeleteHost, runId: string): Promise<void>;
|
|
48
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
|
|
49
72
|
* finishes what the first left. */
|
|
50
73
|
export declare function oneAtATime(): <T>(agentId: string, work: () => Promise<T>) => Promise<T>;
|