@parcha/agentrun-serve 0.1.0-beta.49 → 0.1.0-beta.50
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 +26 -9
- package/README.md +104 -22
- package/dist/agent-delete.d.ts +3 -2
- package/dist/agent-delete.js +29 -4
- package/dist/api-only.d.ts +7 -10
- package/dist/api-only.js +9 -11
- package/dist/compute-cost.d.ts +101 -0
- package/dist/compute-cost.js +250 -0
- package/dist/console/assets/{index-CR2ZGei1.css → index-D0mr9wfZ.css} +1 -1
- package/dist/console/assets/index-D7G6o-1E.js +720 -0
- package/dist/console/index.html +2 -2
- package/dist/eval-previous.d.ts +52 -0
- package/dist/eval-previous.js +164 -0
- package/dist/file-types.d.ts +2 -0
- package/dist/file-types.js +3 -1
- package/dist/harness.js +2 -1
- package/dist/learn/check.d.ts +8 -5
- package/dist/learn/check.js +25 -24
- package/dist/learn/repick.d.ts +22 -13
- package/dist/learn/repick.js +57 -56
- package/dist/learn/workflow-draft.d.ts +4 -0
- package/dist/learn/workflow-draft.js +10 -7
- package/dist/learned-workflow.js +8 -8
- package/dist/learning-setting.js +2 -2
- package/dist/openapi.js +25 -17
- package/dist/paid-calls.d.ts +13 -6
- package/dist/paid-calls.js +14 -8
- package/dist/run-launch.d.ts +2 -2
- package/dist/run-launch.js +2 -1
- package/dist/run-timeline-served.js +5 -3
- package/dist/run-usage.d.ts +23 -8
- package/dist/run-usage.js +100 -18
- package/dist/runner/adapter-loop.d.ts +4 -0
- package/dist/runner/adapter-loop.js +15 -1
- package/dist/runner/adapter-run-spec.d.ts +8 -3
- package/dist/runner/adapter-run-spec.js +13 -6
- package/dist/runner/big-writes.d.ts +33 -0
- package/dist/runner/big-writes.js +105 -0
- package/dist/runner/cli-run-spec.js +14 -6
- package/dist/runner/held.d.ts +4 -1
- package/dist/runner/learning-end.js +9 -4
- package/dist/runner/metrics.d.ts +4 -0
- package/dist/runner/metrics.js +9 -0
- package/dist/runner/run-child-host.d.ts +15 -2
- package/dist/runner/run-child-host.js +24 -8
- package/dist/runner/run-child.js +3 -0
- package/dist/runner/save-slots.d.ts +9 -0
- package/dist/runner/save-slots.js +91 -0
- package/dist/sdk/runs.d.ts +3 -4
- package/dist/sdk/runs.js +10 -7
- package/dist/sdk/runtimes.d.ts +19 -0
- package/dist/sdk/runtimes.js +23 -0
- package/dist/sdk/schema.d.ts +14 -8
- package/dist/sdk/schema.js +18 -6
- package/dist/server.d.ts +4 -0
- package/dist/server.js +3 -3
- package/dist/store/agent-body.d.ts +2 -3
- package/dist/store/agent-body.js +3 -2
- package/dist/store/postgres/migrations/0023_computer_interval_resources.sql +14 -0
- package/dist/store/schema.d.ts +8 -3
- package/dist/store/schema.js +12 -2
- package/dist/store/sqlite/connection.d.ts +3 -3
- package/dist/store/sqlite/connection.js +3 -3
- package/dist/store/sqlite/store.d.ts +2 -4
- package/dist/store/sqlite/store.js +95 -85
- package/dist/store/store.d.ts +8 -1
- package/dist/store-reads/cap.d.ts +9 -5
- package/dist/store-reads/cap.js +28 -2
- package/dist/store-reads/decisions.d.ts +21 -0
- package/dist/store-reads/decisions.js +22 -0
- package/dist/store-reads/journal.d.ts +8 -2
- package/dist/store-reads/journal.js +27 -8
- package/dist/store-view.d.ts +5 -1
- package/dist/store-view.js +37 -18
- package/dist/template-eval.d.ts +15 -1
- package/dist/template-eval.js +92 -13
- package/dist/templates.d.ts +1 -1
- package/dist/templates.js +4 -3
- package/dist/timeline/labels.js +17 -0
- package/dist/tool-list.js +1 -0
- package/dist/tools.d.ts +6 -2
- package/dist/tools.js +13 -1
- package/dist/trigger-targets.d.ts +21 -5
- package/dist/trigger-targets.js +13 -10
- package/dist/web-fake.d.ts +25 -0
- package/dist/web-fake.js +38 -1
- package/dist/web-save.d.ts +75 -0
- package/dist/web-save.js +235 -0
- package/dist/workspace/archil-claim.d.ts +5 -2
- package/dist/workspace/archil-claim.js +5 -2
- package/dist/workspace/archil-disk.d.ts +10 -1
- package/dist/workspace/archil-disk.js +19 -1
- package/dist/workspace/archil.d.ts +3 -0
- package/dist/workspace/archil.js +101 -16
- package/dist/workspace/computer-for-claim.d.ts +14 -0
- package/dist/workspace/computer-for-claim.js +46 -7
- package/dist/workspace/computer-intervals.d.ts +9 -3
- package/dist/workspace/computer-intervals.js +17 -8
- package/dist/workspace/pieced.d.ts +14 -0
- package/dist/workspace/pieced.js +23 -0
- package/dist/workspace/run-disk.js +32 -12
- package/dist/workspace/run-workspace.d.ts +1 -1
- package/dist/workspace/run-workspace.js +11 -6
- package/package.json +10 -10
- package/templates/README.md +36 -7
- package/dist/console/assets/index-Bzn4eUYF.js +0 -715
package/CHANGELOG.md
CHANGED
|
@@ -2,25 +2,42 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## 0.1.0-beta.50 (2026-11-20)
|
|
6
|
+
|
|
7
|
+
- An API-only server (`AGENTRUN_API_ONLY=1`) serves four learning reads with its token: an agent's loop, promotions and cost per run, and a run's learning. <!-- changes/api-only-learning-reads.md -->
|
|
8
|
+
- Computer time is priced the way providers bill it: by the resources a computer holds, never by a size. An operator copies its provider's per-resource rates from the provider's price sheet into `AGENTRUN_COMPUTE_USD_PER_VCPU_SECOND_<PROVIDER>`, `AGENTRUN_COMPUTE_USD_PER_GIB_SECOND_<PROVIDER>`, `AGENTRUN_COMPUTE_USD_PER_GPU_SECOND_<PROVIDER>_<GPU_TYPE>` and `AGENTRUN_COMPUTE_USD_PER_DISK_GB_MONTH_<PROVIDER>` (a month of 730 hours). A priced computer's time is held on the run's ledger under its `max_cost_usd`, one 5-minute stretch ahead, as browser time is: a claim's computer, made while the run is set up, has its first stretch held as soon as the run's cap can judge, so the run's first request is judged beside it (a cap with no room parks the run there); a computer made later in the run (a lost sandbox's new one) has its first stretch held before its create, and a cap with no room makes nothing and fails the run in the cap's words; a cap with no room for a later stretch pauses the run for a raise; and the time it ran is booked before the run's end is written, so the end's `cost.usd` holds it all. The run's ledger tells a caller whether its cap can judge yet (`RunLedger.judges`), and a paid step asked while the run's spec is built waits for it instead of failing. With no price set nothing changes: the computer runs outside the cap, as a tool call with no price does, and is never refused. A resource set to `0` is booked at $0 and reads $0, never `unpriced`. `GET /v2/runs/{run_id}/usage` gives `compute_time` lines (`runusage/4`), one per provider and resource, with the raw quantity, its unit, its basis and the dollars the run's ledger booked, so `total` stays the run's `cost.usd`; the time no claim held (a computer kept for a follow-up, one deleted after its run, one whose delete failed) is said apart as `unheld_quantity` and is in no cost. Each computer interval gives `disk_gb` and `booked_seconds` (Postgres migration `0023_computer_interval_resources.sql`; a SQLite store gets both columns at the server's open). A computer's figures are its provider's own where its answer gives them: `CreatedComputer.resources` in `@parcha/agentrun-computer`, filled from Daytona's sandbox (vCPUs, memory, disk and GPUs), E2B's `getInfo` and Fly's machine guest (vCPUs and memory), and `Machine.resources` for a hosted provider's read of its machine. <!-- changes/compute-prices.md -->
|
|
9
|
+
- The file viewer shows images and plays video and audio from the run's file route, which now serves `.webm`, `.mp3`, `.wav`, `.m4a` and `.ogg` inline with their types. Settings → MCP servers has two fal presets, fal (key) and fal (sign in); fal bills your fal account, and a run's spend cap does not count it. <!-- changes/console-media-viewer-and-fal-preset.md -->
|
|
10
|
+
- A template eval case can name `previous: fixtures/previous.json`, the earlier completed results of the package's schedule trigger, each checked against its own `output_schema` (else the package's) when the case is read; the eval writes them in its own server's store as completed runs of the run's agent, each started by a firing of that trigger, then fires the trigger on its clock, so the run is handed its last result whole, as its `x-carried` fields with the first entries dropped and counted, or nothing, said so, exactly as a scheduled run is. What the run was handed is on its report as `handed_previous`, and a new `handed` grader checks it (`expect: whole | carried | too_large | none`, with `dropped` counts for carried arrays). <!-- changes/eval-previous-run.md -->
|
|
11
|
+
- A workflow decision Parallel answered on its own API (the `parallel` provider on the server's `PARALLEL_API_KEY`, booked at Parallel's list price, $0.001 a request) now counts as a paid call Parallel charged, beside `web_search` and `web_fetch`: it is in the run's `cost.tools_usd` (`toolsusd/2`), on the `parallel` `tools` line of `GET /v2/runs/{run_id}/usage` (`charged_by` and `provider` `parallel`, one call each, `basis` `estimate`), and on the `tools` meter of `GET /v2/usage`. It used to be on a `tokens` line under its model (`parallel-fast`). It moves; it is not added: `total` is still the run's `cost.usd`, and `cost.usd` does not change. A `parallel` decision sent through OpenRouter (no `PARALLEL_API_KEY`, on the OpenRouter key) is OpenRouter's to charge, at the cost OpenRouter reported, and stays a `tokens` line, as Jev's and other decision models' do. <!-- changes/parallel-decision-tool-lines.md -->
|
|
12
|
+
|
|
13
|
+
A Parallel search is now priced by its `mode`, from [Parallel's pricing page](https://docs.parallel.ai/resources/pricing) (read 2026-11-20): `turbo` or `fast` $0.001 a request, `basic` or `advanced` $0.005, each with 10 results included, and $0.001 for each result past them. `web_search` always searches `fast`, so what it books does not change. A search body in a mode with no price here, or naming none, is never sent, as a request to an endpoint with no price is not: it is never booked at $0 or at `fast`'s price.
|
|
14
|
+
- SDK runs accept externally executed agents through `sdk: {runtime: "external", platform: "OpenClaw"}`. Use `"Capy"` or another platform label without adding a runtime. The required label is 1–80 Unicode characters with no leading or trailing whitespace, control characters or unpaired UTF-16 surrogates; it is preserved in the console and on each recorded run. Registration and run start must name the same runtime and platform. Other SDK runtimes reject `platform`. See [Report runs from an external platform](../../docs/tutorials/platform-sdk-runs.md). <!-- changes/sdk-runs-openclaw-capy.md -->
|
|
15
|
+
Execution stays on the platform: managed launch, stop, cancel and follow-up requests are refused. External sources receive the owner's corrections when learning is on, with no workflows. Starts carrying `workflow_tools` or `workflow_adapters` are refused (422) before recording a run. `BackendLearningClient`, imported from `@parcha/agentrun-client/learning`, accepts the external binding and refuses a `workflows` bridge before any request. Existing Claude Agent SDK, Codex SDK and eve integrations retain their behavior.
|
|
16
|
+
The generated TypeScript `StartSdkRunBody` is now a union. Consumers that extend it with an interface or index its workflow fields must use a type intersection or select the SDK branch; the [client README](../client/README.md#learning-for-existing-backend-sdk-agents) describes the migration. `BackendLearningStart` remains extensible, and existing Python TypedDict constructors and CLI flags are preserved.
|
|
17
|
+
- `web_save {url, path}`, a new host tool, saves one public file (at most 200 MiB) into the run's `work/`, a bare name under `media/`. It downloads through `web_fetch`'s guard, never overwrites, and saves media only when the bytes, the declared type and the extension agree. An agent gets it by naming it. pi-browser adds `publicDownload`, the bytes version of `publicFetch`. A template eval's `web:` fixture takes an optional `save` section. <!-- changes/web-save-tool.md -->
|
|
18
|
+
- An API-only server (`AGENTRUN_API_ONLY=1`) now serves `GET /v2/runs/{run_id}/usage`, a run's usage lines. It answered `404` before, so a backend could read a run and its `cost.usd` but not the lines that make it up. The route reads only that run, takes the server's token, and cuts the host's secrets out of its names as `GET /v2/runs/{run_id}` does. Every other route the profile refused is still refused. <!-- changes/api-only-run-usage.md -->
|
|
19
|
+
- A run on an Archil disk that Archil no longer has fails at its claim, before any file call, saying so: the agent's disk is read at Archil at every claim (one GET), as a launch's disk already was, and a disk that is gone, or one in another region than the key's, refuses the run naming the disk, the region and the way out (`DELETE /v2/agents/{id}/archil` drops it, and the agent's next run makes a new one). No new disk is made in its place: the agent's learning and its runs' folders were on it. Before, such a run failed at its first claim with `".agents/skills" is not there`, since every call on the missing disk answered 404 and a 404 read as a folder that was not there. <!-- changes/archil-disk-gone.md -->
|
|
20
|
+
- An Archil run folder makes its folders before it writes: Archil can answer 404 to a put whose folder is not there (it made no parent for an expert run's `.agents/skills/` on a fresh run folder, so every expert run failed at its claim with `".agents/skills" is not there`). A write, an append, a mkdir, the run folder's own put and a synced folder's push now make each missing folder above the key, from the highest down, and put again; a folder already there is left as it is.
|
|
21
|
+
- An Archil workspace keeps Archil's own words in a failure: a missing file or folder is still `NOT_FOUND`, naming the call (list, read, write, append, mkdir, put) and what Archil said after it, and a disk Archil has no record of is `UNAVAILABLE` naming the disk and its region, never a missing folder.
|
|
22
|
+
- A run's folder on its Archil disk that can't be made fails the claim with the reason, where it was a log line; a folder already there is not put again, so a later claim whose kept computer holds it opens at once.
|
|
23
|
+
- With `learning.repick: true`, a learned workflow whose answer is written by a composed workflow now re-picks from the pages in that composed workflow, where before it was committed as compiled without a word. A re-pick the rewrite still does not reach (one that is not a single model step, or whose marker names are taken) is kept as compiled, and the server's log says so. <!-- changes/learning-repick-reach.md -->
|
|
24
|
+
- `POST /v2/templates/{template}/apply` now answers `revision_version`: the number of the agent's revision the apply wrote, its current one now (`1` for an agent it made; on an update with `agent_id`, the new revision's). This is a public API addition: the TypeScript and Python clients carry the field, and the console says "Updated: rev N" from it with no second read of the agent. A purged run's answer and input no longer stay in the server's in-process caches after its `DELETE` (or its agent's): the purge drops them, and a read under way when the purge lands keeps none of them. A SQLite purge whose WAL checkpoint another connection holds back now leaves the store's scrub marker (`store.sqlite.scrub`), and the next start's scrub truncates the log before it serves, a crash in between included; it no longer retries or logs a warning. A secret rewrite running beside the purge never removes the marker the purge left. When that marker cannot be written (a full disk), the purge has still committed: the `DELETE` answers 500 `internal`, saying so, and the server logs it; the run's cached answer and input are dropped all the same, and the next `DELETE` answers 204. <!-- changes/purge-tidy.md -->
|
|
25
|
+
|
|
26
|
+
Upgrade note: a retried apply whose answer was saved before the upgrade replays without `revision_version`; it ages out within a day.
|
|
27
|
+
|
|
5
28
|
## 0.1.0-beta.49 (2026-11-20)
|
|
6
29
|
|
|
7
|
-
-
|
|
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.
|
|
30
|
+
- `learning.repick: true` (off by default) has a learned workflow's quote re-pick read the pages its run fetched, sent as untrusted data to a step with no tools; `learning.repick_max_chars` (150,000 by default) caps what it sends. It reaches workflows compiled after it is set, and agents on an SDK bridge ignore it. <!-- changes/learning-repick-pages.md -->
|
|
14
31
|
- 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
32
|
- `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
33
|
- `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
34
|
- `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
35
|
- 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
36
|
- 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`.
|
|
37
|
+
- 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 /v2/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`. <!-- changes/grade-keeps-run-end.md -->
|
|
21
38
|
- `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
39
|
- `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`
|
|
40
|
+
- An agent whose `input_schema` fields are all optional takes a run that gives one of them and no `content` (`{"pr_number": 3318}` was refused 422). An input with neither is still refused at `input.content`. <!-- changes/input-content-or-field.md -->
|
|
24
41
|
|
|
25
42
|
## 0.1.0-beta.48 (2026-11-20)
|
|
26
43
|
|
package/README.md
CHANGED
|
@@ -1429,6 +1429,7 @@ agent_not_runnable`, with `details.unbound` and `details.missing`).
|
|
|
1429
1429
|
| `ask_person` | Ask the person who started the run; the turn ends until a message answers | nothing | no, no |
|
|
1430
1430
|
| `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
1431
|
| `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 |
|
|
1432
1433
|
| `browser` | A hosted browser, Browserbase's or Kernel's, on pi-browser's durable adapter: `snapshot`, `run`, `screenshot`, `browser_read`, `browser_release`, `browser_relaunch`, `browser_downloads` and `browser_upload` (into and from the run's `work/`); Kernel keeps no downloads, so a run on Kernel has no `browser_downloads` | `BROWSERBASE_API_KEY` and `BROWSERBASE_PROJECT_ID`, or `KERNEL_API_KEY` | yes, no |
|
|
1433
1434
|
| `monid:<provider>/<endpoint>`, `monid:<provider>/*` | One monid endpoint, or every endpoint monid lists for a provider (at most 50), each pinned at the save and run as a tool of its own, paid per call from the monid wallet: `{body?, queryParams?, pathParams?}` in, the run's `output`, `price` and `cost` out ([monid](#monid)) | `MONID_API_KEY` | no, no |
|
|
1434
1435
|
| `pdf_pages` | A workflow call only: `{path, maxPages?, dpi?}` in, `{name, pageCount, dpi, pages: [{page, image}], text}` out. Draws a document's first pages (3 by default, at 110 dpi) as PNGs under the run's `work/pages/<stem>/<dpi>/` (`<stem>`: the document's path below its directory made one name, with a short hash, so two documents of one file name never share pages), the dpi lowered so a page's long side is at most 1568 px, with its text (`pdftotext`, cut at 20,000 characters). A PNG or JPEG passes through as one page, scaled down to 1568 px. `path` is under `--documents` or the run's `work/`, never outside | `pdftoppm`, `pdftotext` | no, yes |
|
|
@@ -1471,6 +1472,14 @@ can branch on it. An agent gets the Page as JSON text; a workflow's `call` node
|
|
|
1471
1472
|
it as its output (`args: {url, offset?, max_chars?}`, 50,000 characters of text by default, `out` a schema of that
|
|
1472
1473
|
shape). A call node naming a tool the table cannot run that way is refused before the run starts (`409`).
|
|
1473
1474
|
|
|
1475
|
+
`web_save {url, path}` downloads one public file through the same guard (pi-browser's `publicDownload`, the same hop
|
|
1476
|
+
loop), at most 200 MiB in at most 10 minutes, into the run's Workspace (a bare name goes under `media/`), so `..`, an
|
|
1477
|
+
absolute path and a link are refused, and a path already in use is refused, never overwritten. The file is written once,
|
|
1478
|
+
after the whole download, so a failed one leaves nothing. An image, audio or video is saved only when its bytes, the
|
|
1479
|
+
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. It makes no paid request and is never run again after a crash. Only an agent that
|
|
1481
|
+
names `web_save` has it; no workflow node or call node may name it.
|
|
1482
|
+
|
|
1474
1483
|
On another harness, every host tool's result reaches the model within the host's bound of 120,000 characters
|
|
1475
1484
|
(`HOST_RESULT_MAX_CHARS`, `@parcha/agentrun-kernel`): the kernel's tool bridge cuts a longer one, its start with a line
|
|
1476
1485
|
saying where it was cut, and flags the call `truncated`. Each CLI adapter tells its CLI to pass a result that long to
|
|
@@ -1677,9 +1686,11 @@ Parallel's fees are the run's spend, booked as monid's are: each search and each
|
|
|
1677
1686
|
run's records before it is sent (`agentrun.tool_started`, held at its price) and settled once Parallel answers
|
|
1678
1687
|
(`agentrun.tool_cost`: `tool` `web_search` or `web_fetch`, `charged_by` `"parallel"`, `usd`), shown on its timeline
|
|
1679
1688
|
(`Tool cost: parallel charged $0.0010 for web_search`), summed into its cost and under `/usage`'s `tools` meter. Parallel
|
|
1680
|
-
answers what it used as counts, never an amount, so each is booked at Parallel's published price
|
|
1681
|
-
read 2026-11-
|
|
1682
|
-
|
|
1689
|
+
answers what it used as counts, never an amount, so each is booked at Parallel's published price
|
|
1690
|
+
([docs.parallel.ai/resources/pricing](https://docs.parallel.ai/resources/pricing), read 2026-11-20), an estimate: a
|
|
1691
|
+
search by its mode, `turbo` or `fast` $0.001 and `basic` or `advanced` $0.005, each for up to 10 results, and $0.001 for
|
|
1692
|
+
each result past them (`web_search` always searches `fast`); an extract $0.001 a URL. A search in a mode with no price
|
|
1693
|
+
here, or naming none, is never sent, as an endpoint with no price is not; on a 4xx other than a 408 nothing (Parallel refused it), and on a 408, a 5xx, a timeout or a lost
|
|
1683
1694
|
connection its price (Parallel may have billed it). Under a [spend cap](#spend-cap) each is a paid call: sent only when
|
|
1684
1695
|
what the run has spent and holds, plus its price, fits the cap. Otherwise nothing reaches Parallel: a search answers the
|
|
1685
1696
|
cap's refusal (`spend_cap_reached: Not sent: this run has spent $0 of its $0.0009 cap, and the next step, Parallel's search, could cost up to $0.001 …`) and a page is the
|
|
@@ -2905,7 +2916,7 @@ failed, 2 when nothing ran. The runner, the graders and the report are in
|
|
|
2905
2916
|
| `GET /agents/{id}/home/files`, and `GET`, `PUT`, `DELETE` on a file's path below it | The files in the agent's home, listed, read, written and deleted ([agent home](#agent-home)). This server's own routes (`x-agentrun-serve: "home/1"`). |
|
|
2906
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 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. |
|
|
2907
2918
|
| `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. |
|
|
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. |
|
|
2909
2920
|
| `GET /runs/{id}/trace` | A run's trace, for a person who debugs it: each model request that answered and each tool call as one span, in the order they started. A span has its `kind` (`model` or `tool`), its `name` (the model, or the tool), when it started and ended, how it ended (`status`), and the span it ran under (`parent_id`: the request that made a call, the call a subagent's request was started by). A model request also has its `tokens` (`input` not read from cache, `cache_read`, `cache_write`, `output`, and `reasoning` where reported), and its `usd`. A tool call also has the head of its arguments and of its output, as its Timeline rows show them, and what was charged under it (`usd`, `charged`, `not_metered`). A call that asked for approval ends as its approval did: `waiting` until it is answered, `refused` on a deny, `interrupted` when it was withdrawn with its run. Nothing is measured again or estimated: `model_requests` says what the run's record keeps. `priced`: each request is a span with its cost. `tokens_only`: a workflow run. Its model nodes' requests carry tokens and no cost, since the run's cost is its booking's; each of its decisions (a judge's, a route's, a verify's request) is a span too (`decision: true`), named by the model its provider answered with and labelled by its node, with its own cost. `not_recorded`: a CLI harness's record keeps no request, so its trace is its tool calls. A computer's own time is its provider's to bill and is in no span. Readable while the run goes; one read serves the run's first 2,000 spans and counts the rest in `dropped`. Its words are cut as the Timeline's are, and a run whose handed sign-in can't be read back is refused (`403`), as its graph is. The console's Dev tools tab reads it. |
|
|
2910
2921
|
| `POST /runs/{id}/pause`, `POST /runs/{id}/resume` | A workflow run: what is in flight finishes, and no node, model call or decision starts until it is resumed. Its status reads `paused`, and stays so across a server restart. An agentic run is `501`, an ended one `409`. |
|
|
2911
2922
|
| `POST /workflows/validate` | `{workflow, tools?}`: every issue a save would refuse (`[{path, code, message}]`, the DSL's validation with code not run) and what this host lacks as `warnings`. Writes nothing. A refused save's `422` carries each issue as a field under `definition.workflow`, with its `code`. |
|
|
@@ -2919,7 +2930,7 @@ failed, 2 when nothing ran. The runner, the graders and the report are in
|
|
|
2919
2930
|
| `GET` and `POST /triggers`, `GET`, `PATCH` and `DELETE /triggers/{id}`, `POST /triggers/{id}/fire`, `GET /triggers/{id}/firings`, `POST /triggers/{id}/secret`, `POST /hooks/{id}` (no token: [signed](#webhook-triggers)) | [Schedules](#schedules), this server's own routes (`x-agentrun-serve: "trigger/1"`): schedules that start an agent's capped runs, each firing once, and their history. |
|
|
2920
2931
|
| `GET /templates`, `POST /templates/{name}/apply` | [Templates](#templates), this server's own routes (`x-agentrun-serve: "templates/1"`): the template packages it ships, and an apply that makes one's agent and triggers, all or nothing. |
|
|
2921
2932
|
| `POST /mcp` | This server's own route (`x-agentrun-serve: "mcp/1"`): the [MCP endpoint](#for-coding-agents), Streamable HTTP with one JSON-RPC message per POST (`initialize`, `ping`, `tools/list`, `tools/call`), answered as JSON, stateless. Its ten tools call these routes in process with the caller's token. The Bearer token only, never the page's cookie; a browser `Origin` other than this server's own is `403`; any other method is `405`. |
|
|
2922
|
-
| `GET /usage` | The runs' costs, by meter, agent, key, day or region (`key` and `region` are one line, `local`). A run of unknown cost adds what it is known to have spent so far (its `so_far_usd`: each priced charge, browser time and paid tools included) and is counted in `unpriced_runs` (in the total and in each line it is unknown on), so no sum is ever null, it never passes as $0, and a total is never below a line of its own: with `unpriced_runs` above 0 the total is a lower bound. `basis` says how the costs were reached ([A run's cost](#a-runs-cost-its-tokens-and-its-basis)). |
|
|
2933
|
+
| `GET /usage` | The runs' costs, by meter, agent, key, day or region (`key` and `region` are one line, `local`). By meter, `tools` holds the runs' paid tool calls and the workflow decisions Parallel charged on its own API, as `cost.tools_usd` does. A run of unknown cost adds what it is known to have spent so far (its `so_far_usd`: each priced charge, browser time and paid tools included) and is counted in `unpriced_runs` (in the total and in each line it is unknown on), so no sum is ever null, it never passes as $0, and a total is never below a line of its own: with `unpriced_runs` above 0 the total is a lower bound. `basis` says how the costs were reached ([A run's cost](#a-runs-cost-its-tokens-and-its-basis)). |
|
|
2923
2934
|
|
|
2924
2935
|
Quotes answer `501 unsupported_here` naming the feature. Home export and import (`GET` and `PUT /agents/{id}/home`) and
|
|
2925
2936
|
`POST /runs/{id}/kill` are not served here: they answer `404`, and the served document leaves them out (its
|
|
@@ -2976,7 +2987,10 @@ item (`["/number", "/title", "/html_url", "/user/login"]`): `item` then keeps on
|
|
|
2976
2987
|
serves these routes alone:
|
|
2977
2988
|
|
|
2978
2989
|
- a run's launch (`POST /agents/{id}/runs`, `POST /runs`), read (`GET /runs/{id}`), lists (`GET /agents/{id}/runs`,
|
|
2979
|
-
`GET /runs`), timeline, messages, stop, cancel, kill (`501` here, as above)
|
|
2990
|
+
`GET /runs`), timeline, messages, stop, cancel, kill (`501` here, as above), cap raise (`PATCH /runs/{id}`) and grade
|
|
2991
|
+
(`PUT /runs/{id}/grade`);
|
|
2992
|
+
- a run's usage lines (`GET /runs/{id}/usage`): what its `cost.usd` joins, by meter, cut of the host's secrets as the
|
|
2993
|
+
run's read is;
|
|
2980
2994
|
- its files (`GET /runs/{id}/files`, `GET /runs/{id}/files/{path}`) and [uploads](#uploads) (`/files`);
|
|
2981
2995
|
- an agent's Archil disk (`GET` and `DELETE /agents/{id}/archil`);
|
|
2982
2996
|
- the [delete of an agent another system owns](#deleting-an-agent-another-system-owns) (`DELETE /agents/{id}`), for
|
|
@@ -2985,6 +2999,12 @@ serves these routes alone:
|
|
|
2985
2999
|
key names and whether each is saved, and whether it is ready) and `GET /workspace/archil` (whether runs' folders are
|
|
2986
3000
|
on Archil, and whether its account key is saved). Neither answers a key's value. Their writes, tests and key choices
|
|
2987
3001
|
are the console's, refused here;
|
|
3002
|
+
- what an agent learned, for the backend whose runs it learned from: the loop's compile turns
|
|
3003
|
+
(`GET /agents/{id}/learning/loop`), each learned workflow's promotion and what serves
|
|
3004
|
+
(`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;
|
|
3006
|
+
- a run's hosted machine fetching this server's computerd build (`GET /computers/daemon`), with the token its create
|
|
3007
|
+
minted;
|
|
2988
3008
|
- `GET /capabilities`, `GET /health` and `GET /usage`;
|
|
2989
3009
|
- a run's desktop or phone, for a backend that shows its user the live view and lets them take over: see below.
|
|
2990
3010
|
|
|
@@ -3348,16 +3368,18 @@ stays in every total.
|
|
|
3348
3368
|
- On disk. On both stores the purge deletes or blanks the rows above; what the database files keep differs.
|
|
3349
3369
|
- **SQLite:** every store connection writes with `secure_delete` on, which zeroes the bytes a write frees, and a run's
|
|
3350
3370
|
or an agent's purge checkpoints the WAL once it commits. So the purged content is in neither `store.sqlite` nor
|
|
3351
|
-
its `-wal` after the `DELETE`. A checkpoint another connection holds back
|
|
3352
|
-
next
|
|
3353
|
-
snapshots, the filesystem's own journal.
|
|
3371
|
+
its `-wal` after the `DELETE`. A checkpoint another connection holds back leaves the store's scrub marker
|
|
3372
|
+
(`store.sqlite.scrub`), and the next start's scrub truncates the log before it serves, a crash in between
|
|
3373
|
+
included. Copies outside the file are out of scope: backups, snapshots, the filesystem's own journal.
|
|
3354
3374
|
- **PostgreSQL** (not closed): a purged row's old version stays in its table as a dead tuple. `VACUUM` (or
|
|
3355
3375
|
autovacuum, on its schedule) only marks its space reusable; the bytes stay in the data file until a later write
|
|
3356
3376
|
overwrites them. `VACUUM FULL` rewrites the table into a new file (under an exclusive lock), and the old file's
|
|
3357
3377
|
blocks go back to the filesystem unwiped. Postgres's own WAL and its archived WAL keep the old values until they are
|
|
3358
3378
|
recycled or expire, and backups keep them for their retention.
|
|
3359
|
-
- Its agent's other runs and what the agent learned are kept
|
|
3360
|
-
|
|
3379
|
+
- Its agent's other runs and what the agent learned from it are kept. A promotion record keeps the run's id. The
|
|
3380
|
+
agent's learning folder keeps what the run taught it: its merge's diff (`.agentrun/diffs/<run>.json`, with its
|
|
3381
|
+
patches) and any feedback line it added to `corrections.md`, in the folder's history too. The run's purge removes
|
|
3382
|
+
neither; the agent's purge (below) removes the whole folder.
|
|
3361
3383
|
- It takes the owner's session (the password sign-in, or the console on a server bound to loopback) or the API token;
|
|
3362
3384
|
any other console session is `403 forbidden`, no credential `401`.
|
|
3363
3385
|
|
|
@@ -3904,10 +3926,11 @@ and says how its figure was reached.
|
|
|
3904
3926
|
and do not change it. A native, SDK or imported run's figure is its harness's own, an `estimate`; so is an imported
|
|
3905
3927
|
session's catalog estimate where its source priced none ([importing your sessions](#importing-your-sessions)). LiteLLM writes no
|
|
3906
3928
|
cost into a streamed answer's headers, so a run whose answers stream through LiteLLM reads `estimate`.
|
|
3907
|
-
- `tools_usd` (on `GET /runs/{id}` alone, `toolsusd/1`): the part of `usd` its paid tool calls cost (monid's endpoints,
|
|
3908
|
-
MCP tools with a saved price, Parallel behind `web_search` and `web_fetch`, browser time
|
|
3909
|
-
|
|
3910
|
-
|
|
3929
|
+
- `tools_usd` (on `GET /runs/{id}` alone, `toolsusd/1`; Parallel's decisions in it since `toolsusd/2`): the part of `usd` its paid tool calls cost (monid's endpoints,
|
|
3930
|
+
MCP tools with a saved price, Parallel behind `web_search` and `web_fetch`, browser time, and a workflow decision
|
|
3931
|
+
Parallel answered on its own API, on `PARALLEL_API_KEY`, at Parallel's list price), as the run's ledger booked them,
|
|
3932
|
+
rounded as `usd` is. It is inside `usd`, never added to it: `usd` less `tools_usd` is what its model requests and its
|
|
3933
|
+
other decisions cost (Jev's, an OpenRouter model's, Parallel's model reached through OpenRouter). A paid call in a learning run's end-of-run turn is learning's (in `learning_usd`), never in
|
|
3911
3934
|
`tools_usd`. 0 when it made no paid call. Null while a paid call's charge is unknown (as `usd` is then); while the run
|
|
3912
3935
|
is at work (until it ended, stopped or failed); for a learning run a follow-up opened again, whose `usd` is what its
|
|
3913
3936
|
first round had cost; and for an imported, native or SDK run, whose `usd` is its import's or its harness's own figure
|
|
@@ -3943,14 +3966,17 @@ were reached. Nothing is priced here, and nothing is rounded to a billing increm
|
|
|
3943
3966
|
```
|
|
3944
3967
|
|
|
3945
3968
|
- `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
|
|
3969
|
+
answered with, except a decision Parallel charged for, which is on Parallel's `tools` line). `provider` is where the requests went, named only when this server sent them there itself: the run's
|
|
3947
3970
|
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
3971
|
upstream. A model reached two ways is two lines, one per provider. `quantity` is the input, cache read, cache write and
|
|
3949
3972
|
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
3973
|
- `tools`: one line per charger (`charged_by`: `monid`, an MCP server's name, `parallel`), the vendor whose invoice the
|
|
3951
3974
|
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
3975
|
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).
|
|
3976
|
+
tool's saved price, Parallel's). A workflow decision Parallel answered on its own API (`PARALLEL_API_KEY`) is a paid
|
|
3977
|
+
call on the `parallel` line, beside `web_search` and `web_fetch`, at Parallel's list price for one decision request
|
|
3978
|
+
(`estimate`), and on no `tokens` line. A `parallel` decision sent through OpenRouter (no `PARALLEL_API_KEY`, the
|
|
3979
|
+
OpenRouter key) is OpenRouter's to charge, at the cost OpenRouter reported: a `tokens` line, as any decision model's. Calls of a tool with no price set ran outside the run's cost, as `GET /usage` counts
|
|
3954
3980
|
them: `not_metered_calls`, in neither `quantity` nor `usd`.
|
|
3955
3981
|
- `browser_time`: one line per browser provider (`provider`). `quantity` is the seconds this server's clock charged the
|
|
3956
3982
|
provider's sessions for, the provider's minimum per session included as the browser charged it; `basis` is
|
|
@@ -3967,8 +3993,19 @@ were reached. Nothing is priced here, and nothing is rounded to a billing increm
|
|
|
3967
3993
|
- `lines` and `total` are null, with `reason`, while the run is at work (`running`), for a run whose figure is not its
|
|
3968
3994
|
booking's (`not_booked`: an imported, native or SDK run, or a CLI run whose model requests went past its proxy), and
|
|
3969
3995
|
for a learning run a follow-up opened again (`reopened`, whose booking can't be split by round).
|
|
3970
|
-
-
|
|
3971
|
-
|
|
3996
|
+
- `compute_time` (`runusage/4`): one line per computer provider and resource (`resource`: `vcpu`, `memory`, `gpu` with
|
|
3997
|
+
its `gpu_type`, `disk`), for the computers the run made. Sum a provider's lines for its one compute figure. `quantity`
|
|
3998
|
+
is every second of each such computer at its figure (`vcpu_second`, `gib_second`, `gpu_second`, or `gb_month` of disk
|
|
3999
|
+
over a 730-hour month); a computer still open is counted up to `measured_to` (`open_computers` says how many). `usd` is
|
|
4000
|
+
what the run's ledger booked for it while a claim held the computer, at the operator's price ([Computer
|
|
4001
|
+
time](#computer-time)), so `total` stays the run's `cost.usd`. The part no claim held (`unheld_quantity`: a computer
|
|
4002
|
+
kept past its claim for a follow-up, one deleted after its run, one whose delete failed) is in no cost. A resource with
|
|
4003
|
+
no price set, or whose figure no one said, is `unpriced`, its `usd` null; a provider that bills nothing (`docker`) is
|
|
4004
|
+
$0. A `compute_time` line that is `unpriced` and any `unheld_quantity` are outside `total`.
|
|
4005
|
+
```json
|
|
4006
|
+
{ "meter": "compute_time", "model": null, "provider": "daytona", "charged_by": "daytona", "resource": "vcpu", "gpu_type": null,
|
|
4007
|
+
"quantity": 348, "unit": "vcpu_second", "basis": "estimate", "usd": 0.004872, "unheld_quantity": 0, "open_computers": 0 }
|
|
4008
|
+
```
|
|
3972
4009
|
- `browser_sessions` (`runusage/2`) holds one record per browser session the run opened, in the order it opened them.
|
|
3973
4010
|
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
4011
|
own dashboard and invoice by its id: the provider's id for the session (`provider_session_id`), when
|
|
@@ -3983,8 +4020,9 @@ were reached. Nothing is priced here, and nothing is rounded to a billing increm
|
|
|
3983
4020
|
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
4021
|
left running after its run, and match the provider's invoice by its own id: the provider (`provider`, this server's
|
|
3985
4022
|
name for it, as the agent's computer setting names it), the provider's id for the computer (`provider_id`), its
|
|
3986
|
-
`kind`, what
|
|
3987
|
-
|
|
4023
|
+
`kind`, what it was made with (`gpu` with its `type` and `count`, `cpus`, `memory_mb`, `disk_gb`: the provider's own
|
|
4024
|
+
figures where its answer gave them, as Daytona's, E2B's and Fly's do, else what its create asked for; null where neither
|
|
4025
|
+
says, and none is guessed), how much of its time a claim held and booked (`booked_seconds`), when the create answered
|
|
3988
4026
|
(`started_at`), and when the provider's delete of it answered ok (`ended_at`). `ended_at` is written only on that ok:
|
|
3989
4027
|
null means no delete was proven (the computer may still be running, or its delete failed or never answered), never a
|
|
3990
4028
|
guessed end. `kept` is true once the run's park kept the computer past its claim, for the person's answer. A computer
|
|
@@ -3994,6 +4032,46 @@ were reached. Nothing is priced here, and nothing is rounded to a billing increm
|
|
|
3994
4032
|
`browser_sessions`. A run's computers made before this server kept them have none either. The records are kept in the
|
|
3995
4033
|
store's `computer_intervals` table (keyed by provider and the provider's id), and a purge of the run keeps them.
|
|
3996
4034
|
|
|
4035
|
+
### Computer time
|
|
4036
|
+
|
|
4037
|
+
A computer's time is priced the way providers bill it: by what the computer holds (its vCPUs, its memory, its GPUs, its
|
|
4038
|
+
disk), for as long as it holds them. There are no sizes. Copy your provider's per-resource rates from its price sheet
|
|
4039
|
+
into these settings on the server, each in US dollars, `<PROVIDER>` being the provider as the agent's computer setting
|
|
4040
|
+
names it and `<GPU_TYPE>` the provider's own GPU name, both in capitals with every other character an underscore:
|
|
4041
|
+
|
|
4042
|
+
| Setting | Price of |
|
|
4043
|
+
| --- | --- |
|
|
4044
|
+
| `AGENTRUN_COMPUTE_USD_PER_VCPU_SECOND_<PROVIDER>` | one vCPU for one second |
|
|
4045
|
+
| `AGENTRUN_COMPUTE_USD_PER_GIB_SECOND_<PROVIDER>` | one GiB of memory for one second |
|
|
4046
|
+
| `AGENTRUN_COMPUTE_USD_PER_GPU_SECOND_<PROVIDER>_<GPU_TYPE>` | one GPU of that type for one second (`..._DAYTONA_H100`) |
|
|
4047
|
+
| `AGENTRUN_COMPUTE_USD_PER_DISK_GB_MONTH_<PROVIDER>` | one GB of disk for a month of 730 hours |
|
|
4048
|
+
|
|
4049
|
+
A price sheet that quotes by the hour divides by 3,600 (a vCPU at $0.0504 an hour is `0.000014`). What a computer holds
|
|
4050
|
+
is its provider's own figure where the provider's answer gives one (Daytona: vCPUs, memory, disk and GPUs; E2B and Fly:
|
|
4051
|
+
vCPUs and memory), else what its create asked for. Nothing is built in: a provider that bills nothing (`docker`) is $0,
|
|
4052
|
+
a resource set to `0` is $0 (its time booked at $0, its line `estimate` with `usd` 0), and with no setting a resource
|
|
4053
|
+
is unpriced.
|
|
4054
|
+
|
|
4055
|
+
- **Priced:** the run's ledger holds the computer's time under the run's `max_cost_usd`, one stretch of 5 minutes ahead,
|
|
4056
|
+
as a browser's time is held. A claim's computer is made while the run is set up, before its cap can judge anything:
|
|
4057
|
+
its first stretch is held as soon as the cap can, so the run's first model request is judged beside it, and a cap
|
|
4058
|
+
with no room parks the run there for a raise. A computer made later in the run (a new sandbox in place of a lost one)
|
|
4059
|
+
has one stretch at what its create asks for held first, and a cap with no room for it makes nothing: the run fails in
|
|
4060
|
+
the cap's words. Each stretch the computer ran is booked (its provider is owed it, so it is never refused) and the
|
|
4061
|
+
next one held, the booked stretch's hold given back first so the cap never counts a stretch twice; a cap with no room
|
|
4062
|
+
for the next pauses the run, as a paid tool call's refusal does, and a raise lets it go on. Before the run's end or park is written, the time since is booked and the hold let go, so the end's `cost.usd`
|
|
4063
|
+
holds all of it. The booked time is in the run's `cost.usd` and on its `compute_time` lines.
|
|
4064
|
+
- **Unpriced** (no setting, or a figure no one said): nothing is held or booked, and nothing is refused. The computer
|
|
4065
|
+
runs outside the cap, as a tool call with no price does, and its `compute_time` lines say `unpriced`. An operator who
|
|
4066
|
+
sets no compute price keeps exactly the behavior before these settings.
|
|
4067
|
+
- **Not held by any claim:** a computer kept past its claim for a follow-up, one deleted after its run ended (the
|
|
4068
|
+
seconds between the end's booking and its delete included), and one whose delete failed run on with no claim to hold
|
|
4069
|
+
them. Their time is on the usage read (`unheld_quantity`, and the
|
|
4070
|
+
interval's `booked_seconds` beside its life) but in no cap and no cost: check `computer_intervals` for such a computer.
|
|
4071
|
+
A computer a later claim takes back is held again from then on.
|
|
4072
|
+
- A run whose process keeps no ledger here (a runner of its own with no run ledger) holds and books nothing, as if
|
|
4073
|
+
unpriced.
|
|
4074
|
+
|
|
3997
4075
|
## Spend cap
|
|
3998
4076
|
|
|
3999
4077
|
A run may name `max_cost_usd`, an agentic run or a workflow run ([below](#a-workflow-run-under-its-cap)). A run that names none takes its agent's default,
|
|
@@ -4005,7 +4083,11 @@ before each model request, the agent's and a compaction's alike, on every harnes
|
|
|
4005
4083
|
what each request still in flight is held at, plus the most this request can cost must stay within it, or the
|
|
4006
4084
|
request is not sent and the run pauses ([below](#a-run-paused-at-its-cap)). The cap is a hard stop for everything but
|
|
4007
4085
|
the charge of a monid call priced by usage, which can pass the estimate it was held at: when it does, the run stops at
|
|
4008
|
-
once ([monid](#monid)).
|
|
4086
|
+
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's generations are such calls: they bill your fal account at
|
|
4088
|
+
fal's price for the model and the output, the fal presets save no price, and the cap does not count them. A template
|
|
4089
|
+
that uses fal caps its fal spend itself, with an input such as `max_fal_usd` that it prices its plan against before the
|
|
4090
|
+
first paid call. A request costs its input, plus the output it
|
|
4009
4091
|
is sent with at the output price, plus any fee its tokens do not show (below). Its input is priced at its worst case:
|
|
4010
4092
|
every input token at the higher of the input and cache-write prices, since the provider may bill any of it as a cache
|
|
4011
4093
|
write and a cache can miss at any request. So no request passes the cap, a cache miss included: a request costs at most
|
package/dist/agent-delete.d.ts
CHANGED
|
@@ -69,5 +69,6 @@ export declare const purgingKey: (agentId: string) => string;
|
|
|
69
69
|
* run_not_final, nothing purged, while it or a run made from it is live. A purged run is no work. */
|
|
70
70
|
export declare function purgeRun(host: AgentDeleteHost, runId: string): Promise<void>;
|
|
71
71
|
/** One delete of an agent at a time: a second DELETE of the same agent waits for the first, then finds it gone (404) or
|
|
72
|
-
* finishes what the first left.
|
|
73
|
-
|
|
72
|
+
* finishes what the first left. `queued`, a test's seam: told each time a work waits behind another of its agent's,
|
|
73
|
+
* with how many of that agent's wait now (the one running not counted). */
|
|
74
|
+
export declare function oneAtATime(queued?: (agentId: string, waiting: number) => void): <T>(agentId: string, work: () => Promise<T>) => Promise<T>;
|
package/dist/agent-delete.js
CHANGED
|
@@ -52,6 +52,7 @@
|
|
|
52
52
|
import { ApiError } from "./errors.js";
|
|
53
53
|
import { LearningInFlight } from "./learn/delete.js";
|
|
54
54
|
import { FINAL_STATES, RunsMadeFromLeft, StoreConstraint, TriggersLeft } from "./store/index.js";
|
|
55
|
+
import { forgetServed } from "./store-view.js";
|
|
55
56
|
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
56
57
|
const isFinal = (state) => FINAL_STATES.includes(state);
|
|
57
58
|
/** Deletes agent `agentId` (another system's, as the route checked) in the three steps above. Throws ApiError
|
|
@@ -70,6 +71,7 @@ export async function deleteExternalAgent(host, agentId) {
|
|
|
70
71
|
for (const run of await host.store.runs.every(agentId)) {
|
|
71
72
|
await host.forgetRun(agentId, run.id, false);
|
|
72
73
|
await host.store.runs.remove(run.id);
|
|
74
|
+
forgetServed(host.store, run.id);
|
|
73
75
|
if (first)
|
|
74
76
|
await host.at?.("in_step_3", agentId);
|
|
75
77
|
first = false;
|
|
@@ -162,6 +164,13 @@ async function purgeOneOrRefuse(host, agentId, runId, purged, alone) {
|
|
|
162
164
|
throw notFinal(purged, [runId]);
|
|
163
165
|
throw error;
|
|
164
166
|
}
|
|
167
|
+
finally {
|
|
168
|
+
// Its answer and input as this process last served them, dropped whatever the purge answered: every route of it is 410
|
|
169
|
+
// once it committed, so none is read again. A purge can commit and still throw (its checkpoint held back and the
|
|
170
|
+
// scrub's marker not written, sqlite/store.ts #purged), and no later DELETE comes back here (purgeRun: a purged run is
|
|
171
|
+
// no work). One that did not commit loses a cache its next read fills again.
|
|
172
|
+
forgetServed(host.store, runId);
|
|
173
|
+
}
|
|
165
174
|
}
|
|
166
175
|
/** Every run made from run `runId` that is there and not purged, each one's own before it (deepest first), never `runId`. */
|
|
167
176
|
async function madeFromAll(host, runId, seen = new Set([runId])) {
|
|
@@ -266,12 +275,28 @@ async function stopRuns(host, agentId) {
|
|
|
266
275
|
}
|
|
267
276
|
}
|
|
268
277
|
/** One delete of an agent at a time: a second DELETE of the same agent waits for the first, then finds it gone (404) or
|
|
269
|
-
* finishes what the first left.
|
|
270
|
-
|
|
278
|
+
* finishes what the first left. `queued`, a test's seam: told each time a work waits behind another of its agent's,
|
|
279
|
+
* with how many of that agent's wait now (the one running not counted). */
|
|
280
|
+
export function oneAtATime(queued) {
|
|
271
281
|
const turns = new Map();
|
|
282
|
+
const waiting = new Map();
|
|
272
283
|
return (agentId, work) => {
|
|
273
|
-
const
|
|
274
|
-
|
|
284
|
+
const held = turns.get(agentId);
|
|
285
|
+
let run = work;
|
|
286
|
+
if (held && queued) {
|
|
287
|
+
waiting.set(agentId, (waiting.get(agentId) ?? 0) + 1);
|
|
288
|
+
run = () => {
|
|
289
|
+
const left = waiting.get(agentId) - 1;
|
|
290
|
+
if (left)
|
|
291
|
+
waiting.set(agentId, left);
|
|
292
|
+
else
|
|
293
|
+
waiting.delete(agentId);
|
|
294
|
+
return work();
|
|
295
|
+
};
|
|
296
|
+
queued(agentId, waiting.get(agentId));
|
|
297
|
+
}
|
|
298
|
+
const before = held ?? Promise.resolve();
|
|
299
|
+
const turn = before.then(run, run);
|
|
275
300
|
const settled = turn.then(() => undefined, () => undefined);
|
|
276
301
|
turns.set(agentId, settled);
|
|
277
302
|
void settled.then(() => {
|
package/dist/api-only.d.ts
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
import type { Route } from "./server.js";
|
|
2
2
|
/** The variable that turns the profile on. */
|
|
3
3
|
export declare const API_ONLY_ENV = "AGENTRUN_API_ONLY";
|
|
4
|
-
/** The routes (server.ts ROUTES, by name) an API-only server serves.
|
|
5
|
-
* -
|
|
6
|
-
*
|
|
7
|
-
* -
|
|
8
|
-
*
|
|
9
|
-
* -
|
|
10
|
-
*
|
|
11
|
-
* - getRunComputer, takeOverRunComputer, handBackRunComputer, createRunComputerViewer: a run's computer, its take-over
|
|
12
|
-
* and hand-back, and its viewer credential's mint (viewer-credential.ts), by the server's token, the backend's own;
|
|
13
|
-
* the live page and socket take that credential. */
|
|
4
|
+
/** The routes (server.ts ROUTES, by name) an API-only server serves. Past a run's own, why each group is here:
|
|
5
|
+
* - a run's hosted machine fetches computerd with the token its create minted, not the server's;
|
|
6
|
+
* - the computers list and the Archil settings are read before a launch, naming keys, never a value;
|
|
7
|
+
* - an agent its inline runs made has its disk and its delete sent by the backend that made it;
|
|
8
|
+
* - a run's computer, take-over, hand-back and viewer link go to the backend, which has no owner's session here;
|
|
9
|
+
* - a backend reads what its agents learned (loop, promotions, cost per run, a run's learning), cut as the console's;
|
|
10
|
+
* - a run's usage lines (what its cost.usd joins, by meter) are a read of that run alone, cut as the run's read is. */
|
|
14
11
|
export declare const API_ONLY_ROUTES: ReadonlySet<string>;
|
|
15
12
|
/** Whether `env` turns the profile on: `1` or `true` on; unset, empty, `0` or `false` off. Any other value is refused in
|
|
16
13
|
* words (a TypeError), so a typo never leaves the console open on a server meant to be API-only. */
|
package/dist/api-only.js
CHANGED
|
@@ -1,21 +1,19 @@
|
|
|
1
1
|
/** The variable that turns the profile on. */
|
|
2
2
|
export const API_ONLY_ENV = "AGENTRUN_API_ONLY";
|
|
3
|
-
/** The routes (server.ts ROUTES, by name) an API-only server serves.
|
|
4
|
-
* -
|
|
5
|
-
*
|
|
6
|
-
* -
|
|
7
|
-
*
|
|
8
|
-
* -
|
|
9
|
-
*
|
|
10
|
-
* - getRunComputer, takeOverRunComputer, handBackRunComputer, createRunComputerViewer: a run's computer, its take-over
|
|
11
|
-
* and hand-back, and its viewer credential's mint (viewer-credential.ts), by the server's token, the backend's own;
|
|
12
|
-
* the live page and socket take that credential. */
|
|
3
|
+
/** The routes (server.ts ROUTES, by name) an API-only server serves. Past a run's own, why each group is here:
|
|
4
|
+
* - a run's hosted machine fetches computerd with the token its create minted, not the server's;
|
|
5
|
+
* - the computers list and the Archil settings are read before a launch, naming keys, never a value;
|
|
6
|
+
* - an agent its inline runs made has its disk and its delete sent by the backend that made it;
|
|
7
|
+
* - a run's computer, take-over, hand-back and viewer link go to the backend, which has no owner's session here;
|
|
8
|
+
* - a backend reads what its agents learned (loop, promotions, cost per run, a run's learning), cut as the console's;
|
|
9
|
+
* - a run's usage lines (what its cost.usd joins, by meter) are a read of that run alone, cut as the run's read is. */
|
|
13
10
|
export const API_ONLY_ROUTES = new Set([
|
|
14
11
|
"createRun", "createInlineRun", "getComputerDaemon",
|
|
15
12
|
"getRunComputer", "takeOverRunComputer", "handBackRunComputer", "createRunComputerViewer",
|
|
16
13
|
"listComputers", "getWorkspaceArchil",
|
|
17
14
|
"getAgentArchil", "deleteAgentArchil", "deleteAgent",
|
|
18
|
-
"
|
|
15
|
+
"getLearningLoop", "listLearningPromotions", "getLearningCost", "getRunLearning",
|
|
16
|
+
"getRun", "getRunUsage", "listRuns", "listAllRuns", "getTimeline",
|
|
19
17
|
"sendMessage", "stopRun", "cancelRun", "raiseRunCap", "gradeRun",
|
|
20
18
|
"listRunFiles", "readRunFile",
|
|
21
19
|
"createFile", "listFiles", "getFile", "uploadFile", "deleteFile",
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import type { Refusal } from "@parcha/agentrun-kernel";
|
|
2
|
+
import { type PaidBooking } from "./paid-calls.js";
|
|
3
|
+
/** The resources computer time is priced by. */
|
|
4
|
+
export type ComputeResource = "vcpu" | "memory" | "gpu" | "disk";
|
|
5
|
+
/** The unit each resource's time is counted in. */
|
|
6
|
+
export declare const COMPUTE_UNITS: {
|
|
7
|
+
readonly vcpu: "vcpu_second";
|
|
8
|
+
readonly memory: "gib_second";
|
|
9
|
+
readonly gpu: "gpu_second";
|
|
10
|
+
readonly disk: "gb_month";
|
|
11
|
+
};
|
|
12
|
+
export type ComputeUnit = (typeof COMPUTE_UNITS)[ComputeResource];
|
|
13
|
+
/** A month of disk, as providers bill one: 730 hours. */
|
|
14
|
+
export declare const SECONDS_PER_MONTH: number;
|
|
15
|
+
/** The settings' prefixes, by resource (the provider's name, and a GPU's type, follow in capitals). */
|
|
16
|
+
export declare const COMPUTE_PRICE_ENV: {
|
|
17
|
+
readonly vcpu: "AGENTRUN_COMPUTE_USD_PER_VCPU_SECOND_";
|
|
18
|
+
readonly memory: "AGENTRUN_COMPUTE_USD_PER_GIB_SECOND_";
|
|
19
|
+
readonly gpu: "AGENTRUN_COMPUTE_USD_PER_GPU_SECOND_";
|
|
20
|
+
readonly disk: "AGENTRUN_COMPUTE_USD_PER_DISK_GB_MONTH_";
|
|
21
|
+
};
|
|
22
|
+
/** The setting that prices `resource` of `provider` (a GPU's by its type). */
|
|
23
|
+
export declare const computePriceEnvOf: (resource: ComputeResource, provider: string, gpuType?: string | null) => string;
|
|
24
|
+
/** What a computer held, as its interval keeps it (store computer_intervals): each null where nothing says it. */
|
|
25
|
+
export type ComputeFigures = {
|
|
26
|
+
readonly cpus: number | null;
|
|
27
|
+
readonly memoryMb: number | null;
|
|
28
|
+
readonly gpuType: string | null;
|
|
29
|
+
readonly gpuCount: number | null;
|
|
30
|
+
readonly diskGb: number | null;
|
|
31
|
+
};
|
|
32
|
+
/** One resource of a computer: its line's key (a GPU's by its type), and how many of its unit each second of the
|
|
33
|
+
* computer's life is (null when its figure is unknown). */
|
|
34
|
+
export type ResourceOf = {
|
|
35
|
+
readonly resource: ComputeResource;
|
|
36
|
+
readonly gpuType: string | null;
|
|
37
|
+
readonly perSecond: number | null;
|
|
38
|
+
};
|
|
39
|
+
/** The resources a computer held: its vCPUs and memory always (a figure no one said is null, never 0); its GPUs when it
|
|
40
|
+
* has any; its disk when its provider said it. */
|
|
41
|
+
export declare function resourcesOf(figures: ComputeFigures): ResourceOf[];
|
|
42
|
+
/** Whether `provider`'s descriptor says it bills nothing (Local's Docker): its time is $0, never by its id alone. */
|
|
43
|
+
export declare const unmetered: (provider: string) => boolean;
|
|
44
|
+
/** The operator's price of `resource` of `provider`, in USD per its unit: a non-negative decimal, $0 for a provider
|
|
45
|
+
* that bills nothing; null when none is set or the setting can't be read (unpriced, never $0). */
|
|
46
|
+
export declare function computeRate(provider: string, resource: ComputeResource, gpuType: string | null, env: NodeJS.ProcessEnv): number | null;
|
|
47
|
+
/** One priced resource of a computer: what a second of its life costs (its rate times its figure), with its words. */
|
|
48
|
+
type Priced = ResourceOf & {
|
|
49
|
+
readonly rate: number;
|
|
50
|
+
readonly usdPerSecond: number;
|
|
51
|
+
};
|
|
52
|
+
/** A computer's priced resources: those with a known figure and a price. The rest are unpriced and held by nothing. */
|
|
53
|
+
export declare function pricedOf(provider: string, figures: ComputeFigures, env: NodeJS.ProcessEnv): Priced[];
|
|
54
|
+
/** How long a stretch is: what the claim holds ahead, and how often it books what ran. */
|
|
55
|
+
export declare const COMPUTE_STRETCH_S = 300;
|
|
56
|
+
/** The tool a computer's time names on the run's ledger (GET /runs/{run_id}/usage reads its bookings as compute lines). */
|
|
57
|
+
export declare const COMPUTE_TOOL = "compute";
|
|
58
|
+
/** The tag of a booking of one resource: its resource, and a GPU's type. */
|
|
59
|
+
export declare const computeTag: (one: Pick<ResourceOf, "resource" | "gpuType">) => string;
|
|
60
|
+
/** The run's ledger as the meter books on it, the run's pause for a refusal of the next stretch, and whether its cap can
|
|
61
|
+
* judge a step now (`judges`, RunLedger.judges: false while the run's spec, whose cap it is, is still built). */
|
|
62
|
+
export type ComputeLedger = {
|
|
63
|
+
readonly paid?: PaidBooking;
|
|
64
|
+
readonly pause?: (refusal: Refusal) => Promise<void>;
|
|
65
|
+
readonly judges?: () => boolean;
|
|
66
|
+
};
|
|
67
|
+
/** A hold-only step on the ledger, given back by `drop` (answered once the ledger has it back). */
|
|
68
|
+
type Hold = {
|
|
69
|
+
drop(): Promise<void>;
|
|
70
|
+
};
|
|
71
|
+
/** A computer the claim refused to create: the cap had no room for its first stretch. Its words are the cap's. */
|
|
72
|
+
export declare class ComputeRefused extends Error {
|
|
73
|
+
readonly code = "spend_cap_reached";
|
|
74
|
+
}
|
|
75
|
+
export interface ComputeMeter {
|
|
76
|
+
/** Before the claim creates a computer of `provider` asking for `figures`: one stretch of its priced resources held on
|
|
77
|
+
* the run's ledger (none where nothing is priced, or with no ledger). Refused for room or for good: ComputeRefused, in
|
|
78
|
+
* the cap's words, and nothing should be made. The hold answered is the caller's to hand to `start` (or `drop`). */
|
|
79
|
+
before(provider: string, figures: ComputeFigures): Promise<Hold | undefined>;
|
|
80
|
+
/** The claim holds computer `providerId` of `provider` from now, with `figures` (its provider's where it said them):
|
|
81
|
+
* its time is booked each stretch, the next one held; `ahead` (before's hold) is let go once the first is. */
|
|
82
|
+
start(provider: string, providerId: string, figures: ComputeFigures, ahead?: Hold): void;
|
|
83
|
+
/** The claim lets the computer go (its delete answered ok, or its run's park kept it): the time since its last
|
|
84
|
+
* booking booked, its hold let go. Once; one the meter never started is nothing. */
|
|
85
|
+
stop(provider: string, providerId: string): Promise<void>;
|
|
86
|
+
/** Every computer it holds let go as `stop` does (the claim's release). */
|
|
87
|
+
stopAll(): Promise<void>;
|
|
88
|
+
}
|
|
89
|
+
export type ComputeMeterOptions = {
|
|
90
|
+
readonly env: NodeJS.ProcessEnv;
|
|
91
|
+
readonly ledger: ComputeLedger;
|
|
92
|
+
/** Told each booked stretch of a computer's time, in ms (its interval's booked time, computer-intervals.ts). */
|
|
93
|
+
readonly booked?: (provider: string, providerId: string, ms: number) => Promise<void>;
|
|
94
|
+
readonly now?: () => number;
|
|
95
|
+
/** Runs `tick` every `ms` until the answer is called; default setInterval, unref'd. */
|
|
96
|
+
readonly every?: (tick: () => void, ms: number) => () => void;
|
|
97
|
+
readonly log?: (line: string) => void;
|
|
98
|
+
};
|
|
99
|
+
/** One claim's meter of the computers it holds (ComputeMeter). */
|
|
100
|
+
export declare function computeMeter(options: ComputeMeterOptions): ComputeMeter;
|
|
101
|
+
export {};
|