foldrun 13.0.0 → 13.1.0

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/bin/foldrun.mjs CHANGED
@@ -206,7 +206,7 @@ const HELP = `foldrun — agents are just folders
206
206
  foldrun jobs the four jobs — governance, guardrail, observability, evaluation — and what each has set (--to <workspace>, --json)
207
207
  foldrun account the account's defaults — also set <key> <value>, clear <key> (timezone, notify, budget, concurrency, compute vcpu <n> memory <GiB> disk <GiB>, deploy_block none|secrets|security, network_enforce on|off, owner, alerts <threshold> <value>, judge model|effort <value>; or <job>.<field>, e.g. governance.owner), pause [--reason] [--stop] / resume (the kill switch), telemetry [set <url> --header name=\${SECRET} | clear | test] (runs as OpenTelemetry traces), providers (--check) (singular; accounts lists logins)
208
208
  foldrun account export everything the platform holds about the account as one JSON file (owner only; --file <path>, --force)
209
- foldrun account model the account's own model key — set <provider> --key <api key> (--key - reads stdin; custom --base-url --format), remove
209
+ foldrun account model what steps run on — your own key: set <provider> --key <api key> (--key - reads stdin; custom --base-url --format), remove; or foldrun's models (billed in credits): use foldrun --provider <p>, use own, prices
210
210
  foldrun workspace one deployed workspace's settings (--to) — also set <name|description|timezone|budget|compute|notify|network_enforce|owner|alerts|judge> <value> (compute vcpu <n> memory <GiB> disk <GiB>: this workspace's pool) (or <job>.<field>), clear <key>, pause [--reason] [--stop] / resume (the kill switch)
211
211
  foldrun workspace vocabulary the names the dashboard's editor completes in a workspace: agents, flows, skills, tools, secrets, scripts, types, documents (--to, --json)
212
212
  foldrun notify test send one test notification from a workspace and say what happened (--to <workspace>)
package/docs/api.md CHANGED
@@ -360,7 +360,7 @@ Reads return which secrets exist, never their values.
360
360
  | `/api/team/transfer` | POST | hand the account to a member (`to`) — owner only, signed in, and re-proving it is them: `password` (the current one) and, when two-step sign-in is on, `code` (from the app, or a backup code). 400 without them, 401 when wrong, 6 tries in 15 minutes. You become an admin |
361
361
  | `/api/usage/compute` | GET | the account's compute at every level (27 Oct 2026): `compute` is `{ vcpu, memGiB, diskGiB, stepVcpu, stepMemGiB, stepDiskGiB, source }` — the cores, GiB and GiB of disk all its running steps may hold together, the most one step may hold (each `null` for no cap), and where the pool came from (`plan`, `account` — its own `compute:` in AGENTS.md, which can only lower it — `install`, or `null`); `inUse` is `{ vcpu, memGiB, diskGiB, steps }`, what its running steps' sandboxes hold now, from their records (a step still waiting for room holds nothing; a caller scoped to some workspaces sees theirs); `workspaces` is each workspace's own `pool` (its AGENTS.md `compute:`, `null` figures for none) and `inUse`; `runs` is each live run with a pool of its own (its flow's `compute:`) or anything held, `{ workspace, runId, flow, pool, inUse }`; `waiting` lists the steps waiting for room, oldest first — `{ workspace, runId, flow, step, agent, since, why, cpus, memGiB, diskGiB, level?, runPool }`, `since` being when it first found none, its place in line, and `level` the cap that held it when it last looked. A step past any level waits, with no time limit, and starts in turn; one bigger than a level's whole cap or the step maximum fails at once ([four levels](budgets-and-billing#compute-at-four-levels), [waiting for room](budgets-and-billing#waiting-for-room)) |
362
362
  | `/api/usage/history?days=` | GET | charged spend by flow, by agent and by workspace over time, read from the ledger rather than the run records — so it survives runs being pruned and reports what was billed rather than what was consumed. Buckets by week over three weeks, by day under. Each series carries its periods, its total, and the change between the last two COMPLETE periods, so a partial week never reads as a collapse. `unattributedUsd` is charges from before a line recorded its flow. A caller scoped to some workspaces sees only the charges in those; `days` 1–365, default 56 |
363
- | `/api/account/model` | GET, PUT, DELETE | the account's own model key — what every step runs on unless an agent, workspace or the account's AGENTS.md names a `provider:`. GET: `{ set, provider, baseUrl, format, keyHint, runsOn, platformKeyAllowed }` — never the key, only its last four characters; `runsOn` is `account` (its own key), `platform` (the platform's credential, for the operator's accounts) or `none` (runs are refused until a key is set). PUT `{ provider, apiKey, baseUrl?, format? }` (needs `secrets:write`): `provider` is a preset name (anthropic, openrouter, openai, groq, … — see providers) or `custom` with an https `baseUrl` and a `format` (anthropic or openai); a Claude login token (sk-ant-oat…) is refused for any account not allowed the platform's credential. Stored as the account secrets `FOLDRUN_MODEL_PROVIDER`, `FOLDRUN_MODEL_API_KEY`, `FOLDRUN_MODEL_BASE_URL`, `FOLDRUN_MODEL_FORMAT`. DELETE removes them. Honours Idempotency-Key on PUT; audited as model.key_set / model.key_removed |
363
+ | `/api/account/model` | GET, PUT, DELETE | what every step runs on unless an agent, workspace or the account's AGENTS.md names a `provider:` — the account's own model key, or foldrun's models (the platform's keys for one provider, billed in credits at foldrun's price list; hosted only). GET: `{ set, provider, baseUrl, format, keyHint, runsOn, platformKeyAllowed, source, supply, choiceVersion, foldrunModels }` — never a key, only its last four characters; `runsOn` is `account` (its own key), `foldrun` (foldrun's models for `supply`), `platform` (the platform's credential, for the operator's accounts) or `none` (runs are refused until a key is set); `foldrunModels` is `{ offered, refused, providers: [{ name, title, available, reason, tiers }], prices: [{ provider, model, inputPerMTok, outputPerMTok, cacheReadPerMTok, cacheWritePerMTok }], dailyCapUsd, spentTodayUsd }`, the money in what the account pays. PUT `{ source: "foldrun", supply, ifVersion? }` chooses foldrun's models (`supply`: anthropic, openai, gemini or openrouter; a provider the platform cannot serve now, or an account refused them, is a 409; a stale `ifVersion` is a 409); `{ source: "own" }` goes back to the account's own key; a key alone never changes the choice; audited as model.source_set. PUT `{ provider, apiKey, baseUrl?, format? }` (needs `secrets:write`, as does the choice): `provider` is a preset name (anthropic, openrouter, openai, groq, … — see providers) or `custom` with an https `baseUrl` and a `format` (anthropic or openai); a Claude login token (sk-ant-oat…) is refused for any account not allowed the platform's credential. Stored as the account secrets `FOLDRUN_MODEL_PROVIDER`, `FOLDRUN_MODEL_API_KEY`, `FOLDRUN_MODEL_BASE_URL`, `FOLDRUN_MODEL_FORMAT`. DELETE removes them (the choice stays). Honours Idempotency-Key on PUT; audited as model.key_set / model.key_removed |
364
364
  | `/api/account/providers` | GET, POST | GET: the model providers this account's files actually use — each one's preset name, where it is declared, the model a check would send — plus the last daily health check. POST forces one now, which spends one minimal request at each distinct endpoint, and needs the permission that runs and every workspace. A member or key scoped to some workspaces sees the account's provider blocks and its own workspaces' only, in `configured` and in the last check |
365
365
  | `/api/usage` | GET | what has been spent, by meter; each bucket's tokens are `inputTokens` (all input), `outputTokens`, `cacheReadTokens` and `cacheWriteTokens` (the part of the input the prompt cache served and stored), and `cacheHitRate` — reads over `measuredInputTokens`, the input of steps that report the split, `null` when none do. A key or member scoped to some workspaces sees those workspaces, and totals over them; `ledger` is the account's `balanceUsd` and `chargedUsd` (all time), and `waived` the legs the account is not charged for — both `null` to a caller scoped to some workspaces, since they are the whole account's money. Since API version `2026-10-26` nothing else; earlier pins see `providerCostUsd` and `marginUsd` as `null` |
366
366
  | `/api/approvals` | GET | every gate waiting on a person, across workspaces — one entry per waiting **step** (`workspace`, `runId`, `flow`, `step`, `agent`, `question`, `asked`, `waitingSince`), oldest first. By step status, not run status: a decided gate leaves the list at once, before the worker resumes the run. `wait: event` steps are not listed; no button answers them. Beside it, `questions`: every question an agent is asking mid-step in a running run (`kind: "question"`, `id`, `workspace`, `runId`, `flow`, `agent`, `question`, `options?`, `askedAt`) — answered with `…/runs/<id>/answer` |
@@ -191,6 +191,10 @@ Model, or a `provider:` block); the run page says which credential each step
191
191
  used. On a hosted platform every customer account brings one
192
192
  ([providers](providers.md#your-accounts-own-model-key)).
193
193
 
194
+ **On foldrun's models** (hosted; [providers](providers.md#foldruns-models))
195
+ the tokens are bought from the platform instead: see
196
+ [foldrun's models](#foldruns-models) below.
197
+
194
198
  **Going into minus.** Ordinarily an empty balance starts no run. The
195
199
  platform can allow an account to run below zero — to a floor, or with none —
196
200
  for a customer on invoice terms. It shows on that account's Balance page
@@ -220,7 +224,7 @@ provider's own invoice.
220
224
 
221
225
  | meter | what it counts |
222
226
  |---|---|
223
- | **tokens** | model usage at cost, times a margin. **Bring your own key and the margin does not apply** — a BYOK step is billed nothing for tokens |
227
+ | **tokens** | model usage at cost, times a margin. **Bring your own key and the margin does not apply** — a BYOK step is billed nothing for tokens. On foldrun's models, each call at foldrun's price list, times the margin ([below](#foldruns-models)) |
224
228
  | **compute** | sandbox seconds: what a step reserved (cores, memory and disk, while it ran) and what it actually burned. Disk is billed by the GiB a step is allowed to write, per second, like memory (since 27 Oct 2026) |
225
229
  | **storage and network** | GB-months in the file store, accrued daily; GB the sandbox moved, both directions |
226
230
 
@@ -230,6 +234,27 @@ having more, smaller steps. The Usage page shows every table in credits at
230
234
  today's rates beside the meters, so a customer can read what a run will
231
235
  cost from what the last one consumed.
232
236
 
237
+ ### foldrun's models
238
+
239
+ An account on [foldrun's models](providers.md#foldruns-models) pays for each
240
+ model call at **foldrun's price list** — per million input, output,
241
+ cache-read and cache-write tokens, per model — times the margin in force.
242
+ Settings → Model provider shows the list as you pay it, and so does
243
+ `foldrun account model prices`. A model not on it is refused.
244
+
245
+ - **Metered per call**, by the platform's model gateway, from the usage the
246
+ provider reports — not from what a step says it spent. A stream cut off
247
+ before the provider reported usage is charged at the call's estimate.
248
+ A call the provider refused costs nothing.
249
+ - **Charged within minutes**, as its own line on the statement — "foldrun's
250
+ models: N calls (provider model, …)" — one per run, or per eval grade,
251
+ draft or assistant conversation. The run's own charge (sandbox time,
252
+ network, the run fee) is a separate line, as before.
253
+ - **A daily cap** per account (UTC), in what you pay. Before each call the
254
+ gateway reserves its estimate against the cap, so twenty calls at once
255
+ cannot all pass it; one past it is refused until the next day.
256
+ - **The balance must be above zero** for a call to start, like a run.
257
+
233
258
  ## Prompt caching
234
259
 
235
260
  Every step's model calls are cached by prefix, on the provider's side: a
package/docs/cli.md CHANGED
@@ -160,7 +160,7 @@ claude.ai or Claude Code there, nor any MCP configuration on disk.
160
160
  | `foldrun gallery` | the tools the platform ships to every account (`web`), and for each whether this account keeps its own copy and whether that copy still matches. `pull` lays the shelf down under `~/.foldrun/gallery/<host>/` for offline runs (`foldrun run` and `foldrun eval` refresh it themselves before each run); `upgrade <tool>` replaces the account's copy with the current gallery version, the old one a revision back |
161
161
  | `foldrun identity` | keyless cloud identity: the issuer your cloud must trust and the subject each agent's tokens carry (`GET /api/identity`); `--to <workspace>` fills the workspace in, `--json` |
162
162
  | `foldrun jobs` | the four jobs — governance, guardrail, observability, evaluation — and every `AGENTS.md` field of each, with what is set (`GET /api/account/jobs`). `--to <workspace>` shows the workspace's value beside the account's and how the two combine; `--json` the document. `account set <job>.<field>` and `workspace set <job>.<field>` refuse a field that scope cannot set and name the `AGENTS.md` to write it in. See [The four jobs](four-jobs) |
163
- | `foldrun account` | the account's own defaults — the AGENTS.md frontmatter every workspace under it inherits: `timezone`, `notify`, `budget`, `concurrency`, `deploy_block`, `network_enforce`. `foldrun account set timezone Australia/Sydney`, `set notify email you@example.com` (`--events failed,awaiting-approval,completed`), `set notify url https://…`, `set budget 60/month`, `set concurrency 4`, `set compute vcpu 4 memory 8 disk 40` (GiB; any of them, merged over what is set — the account's own pool, lower than the plan's), `set deploy_block secrets` (`none`, `secrets` or `security` — what the scanner's findings do to a deploy), `set network_enforce on` (every workspace refuses a site off an agent's `network:` list; `off` reports only), `set owner <email or name>`, `set alerts <threshold> <value>` (merged into what is set; `off` removes one), `set judge model|effort <value>`. Any setting may be named by its job — `set governance.deploy_block secrets`, `set observability.alerts stale_days 30` — and one named under the wrong job is refused with the right one, `pause` (`--reason "…"`, `--stop` to also stop every run going now — asks, or `--yes`) and `resume`: the kill switch, no new run starts in any workspace while paused, `telemetry` — where each finished run goes as an OpenTelemetry trace: bare shows it, `set <url> --header authorization='${OTEL_TOKEN}'` (repeatable; a value is a vault secret's name), `clear`, `test` (one made-up run, and what the collector answered; exit 1 when not delivered), and `clear <key>` to unset one. `set notify` merges against what is there, because the platform replaces the whole block. `providers` lists the model providers the account's files use and the last daily key check — `--check` asks now, and a dead key is a non-zero exit. `model` is the account's own model key, what every step runs on unless a `provider:` block names another: `foldrun account model` shows it (never the key, only its last four; exit 1 when there is none and runs are refused), `model set <provider> --key <api key>` sets it — a preset name (anthropic, openrouter, openai, groq, …) or `custom --base-url https://… --format anthropic|openai`, `--key -` reads the key from stdin — and `model remove` removes it; a Claude login token is refused for any account not allowed the platform's own credential. `export` downloads everything the platform holds about the account — workspaces, runs, members and the whole ledger — as one JSON file (owner only; `--file <path>`, `--force`). Singular — `accounts` below is the list of logins on this machine |
163
+ | `foldrun account` | the account's own defaults — the AGENTS.md frontmatter every workspace under it inherits: `timezone`, `notify`, `budget`, `concurrency`, `deploy_block`, `network_enforce`. `foldrun account set timezone Australia/Sydney`, `set notify email you@example.com` (`--events failed,awaiting-approval,completed`), `set notify url https://…`, `set budget 60/month`, `set concurrency 4`, `set compute vcpu 4 memory 8 disk 40` (GiB; any of them, merged over what is set — the account's own pool, lower than the plan's), `set deploy_block secrets` (`none`, `secrets` or `security` — what the scanner's findings do to a deploy), `set network_enforce on` (every workspace refuses a site off an agent's `network:` list; `off` reports only), `set owner <email or name>`, `set alerts <threshold> <value>` (merged into what is set; `off` removes one), `set judge model|effort <value>`. Any setting may be named by its job — `set governance.deploy_block secrets`, `set observability.alerts stale_days 30` — and one named under the wrong job is refused with the right one, `pause` (`--reason "…"`, `--stop` to also stop every run going now — asks, or `--yes`) and `resume`: the kill switch, no new run starts in any workspace while paused, `telemetry` — where each finished run goes as an OpenTelemetry trace: bare shows it, `set <url> --header authorization='${OTEL_TOKEN}'` (repeatable; a value is a vault secret's name), `clear`, `test` (one made-up run, and what the collector answered; exit 1 when not delivered), and `clear <key>` to unset one. `set notify` merges against what is there, because the platform replaces the whole block. `providers` lists the model providers the account's files use and the last daily key check — `--check` asks now, and a dead key is a non-zero exit. `model` is what every step runs on unless a `provider:` block names another — the account's own model key, or foldrun's models: `foldrun account model` shows it (never a key, only its last four; on foldrun's models, the provider, its tier map and today's spend against the daily cap; exit 1 when runs are refused — no key, or foldrun's models refused for the account), `model set <provider> --key <api key>` sets the key — a preset name (anthropic, openrouter, openai, groq, …) or `custom --base-url https://… --format anthropic|openai`, `--key -` reads the key from stdin — and `model remove` removes it (the choice stays); a Claude login token is refused for any account not allowed the platform's own credential. `model use foldrun --provider <anthropic|openai|gemini|openrouter>` runs every step on foldrun's models — the platform's keys, billed in credits at foldrun's price list, hosted only; a provider the platform cannot serve now is refused — and `model use own` goes back to the account's own key, which is kept. `model prices` (`--provider <p>`, `--json`) lists foldrun's price list as the account pays it, USD per million tokens. `export` downloads everything the platform holds about the account — workspaces, runs, members and the whole ledger — as one JSON file (owner only; `--file <path>`, `--force`). Singular — `accounts` below is the list of logins on this machine |
164
164
  | `foldrun workspace` | one deployed workspace's own settings (`--to <workspace>`): description, timezone, budget and notify, read from its `AGENTS.md` — unset means the account's. `set timezone <tz>`, `set budget 20/week`, `set compute vcpu 2 memory 4 disk 20` (this workspace's own pool, inside the account's; any of them), `set notify email <address>` / `set notify url <https://…>` (`--events`; merged with what the file says), `set network_enforce on` (refuse a site off an agent's `network:` list here; `off` or `clear` goes back to the account's), `set owner`, `set alerts <threshold> <value>`, `set judge model|effort <value>`, and `<job>.<field>` as on `account`, `pause` (`--reason`, `--stop`) and `resume` — this workspace's kill switch, `set description "…"`, `set name <new>` — a rename changes every webhook URL, so it asks first and names the flows whose URLs changed — and `clear <key>`. Singular — `workspaces` is the list |
165
165
  | `foldrun workspace vocabulary` | what the dashboard's editor completes as you type in a workspace (`--to`): agents, flows, skills, tools, secrets (names only), scripts, document types and linkable documents (`GET …/vocabulary`; `--json`) |
166
166
  | `foldrun notify test` | send one test notification to whatever the workspace's `notify:` resolves to, and print what happened — the provider's own words when it failed ("domain not verified"). Exits 1 when it did not go. `--to <workspace>` |
package/docs/faq.md CHANGED
@@ -16,8 +16,10 @@ model. Bring your own key for any provider that speaks the Anthropic or the
16
16
  Chat Completions API — once for the whole account in Settings → Model
17
17
  (`foldrun account model set`), or per workspace or agent with a `provider:`
18
18
  block — and the platform bills you nothing for those tokens. On a hosted
19
- platform every account brings its own API key; Claude login tokens are not
20
- accepted. See [Providers](providers).
19
+ platform every account brings its own API key — Claude login tokens are not
20
+ accepted — or, on foldrun's own platform, chooses **foldrun's models**:
21
+ Anthropic, OpenAI, Gemini or OpenRouter on foldrun's keys, billed in credits
22
+ at foldrun's price list. See [Providers](providers).
21
23
 
22
24
  **Can agents reach the internet?** Yes — the public internet, as themselves,
23
25
  with the secrets they were granted. Not private networks, not the cloud
@@ -128,7 +128,9 @@ the account as it is (a run on record, a secret in the vault, a key minted
128
128
  for the CLI), so it ticks itself whichever way you did the thing; there is
129
129
  nothing to mark. While an account has no model key every run is refused, so
130
130
  every dashboard page also carries a banner saying so, with a link to
131
- Settings → Model provider (`foldrun account model set anthropic --key …`). **Dismiss** hides it for you alone; the line at the foot of
131
+ Settings → Model provider (`foldrun account model set anthropic --key …`,
132
+ or on foldrun's own platform `foldrun account model use foldrun --provider anthropic`
133
+ to run on foldrun's models, billed in credits). **Dismiss** hides it for you alone; the line at the foot of
132
134
  the page brings it back, and it goes away by itself once every step is done.
133
135
 
134
136
  ```sh
package/docs/providers.md CHANGED
@@ -14,10 +14,10 @@ key, as `FOLDRUN_MODEL_PROVIDER`, `FOLDRUN_MODEL_API_KEY` and, for a custom
14
14
  endpoint, `FOLDRUN_MODEL_BASE_URL` and `FOLDRUN_MODEL_FORMAT`. The dashboard
15
15
  and the API show only its last four characters.
16
16
 
17
- **On a hosted platform every account brings its own key.** The platform's
18
- own model credential is for the operator's accounts
19
- (`FOLDRUN_PLATFORM_KEY_ACCOUNTS`); a step in any other account with no key
20
- of its own is refused before it starts — "no model key: …" on the run — and
17
+ **On a hosted platform every account brings its own key — or chooses
18
+ [foldrun's models](#foldruns-models).** The platform's own model credential
19
+ is for the operator's accounts (`FOLDRUN_PLATFORM_KEY_ACCOUNTS`); a step in
20
+ any other account with neither is refused before it starts — "no model key: …" on the run — and
21
21
  an eval's judge or "draft with AI" says the same. Until it has one, every
22
22
  dashboard page says so in a banner, and **Add your model key** is the first
23
23
  step of [getting started](getting-started.md#the-checklist-on-the-dashboard).
@@ -29,6 +29,48 @@ claude.ai logins. Use an API key from the provider.
29
29
  Tokens on your own key are billed by your provider, not by the platform
30
30
  ([budgets and billing](budgets-and-billing.md)).
31
31
 
32
+ ## foldrun's models
33
+
34
+ On foldrun's own hosted platform an account can run on **foldrun's keys**
35
+ instead of its own: Anthropic, OpenAI, Google Gemini or OpenRouter, one at a
36
+ time for the whole account. No provider account is needed; the tokens are
37
+ billed in credits at **foldrun's price list**
38
+ ([budgets and billing](budgets-and-billing.md#foldruns-models)).
39
+
40
+ - **Choose it:** Settings → Model provider → *foldrun's models*, pick the
41
+ provider, *Use*. Or `foldrun account model use foldrun --provider openai`,
42
+ or `PUT /api/account/model` with `{ "source": "foldrun", "supply": "openai" }`.
43
+ An admin chooses, as for the key. `foldrun account model use own` (or the
44
+ same page) goes back: a key you stored is kept while you are on
45
+ foldrun's models, so switching back is one step.
46
+ - **The order** a step's model is found in is unchanged but for one rung: a
47
+ `provider:` block in the agent, the workspace or the account's AGENTS.md
48
+ first; then foldrun's models, when chosen; then the account's own key.
49
+ - **Which model a tier runs** is the platform's map for that provider
50
+ (`model: fast | default | max`), shown on the page and by
51
+ `foldrun account model prices`. Anthropic's tiers are the usual Claude
52
+ models. A model id written out in full runs only if the price list names
53
+ it; anything not listed is refused before the call is made.
54
+ - **What is refused**, before anything is sent: a model not on the price
55
+ list; the provider's own paid tools (web search, code execution run by
56
+ the provider), priority service tiers, audio, more than one completion per
57
+ call; a document fetched by URL. An image by URL is held at a fixed
58
+ token count. What is allowed is listed per provider; nothing else passes.
59
+ - **A daily cap** (UTC) per account, in what you pay, shown on the page with
60
+ today's spend. A call past it is refused until the next day; ask support
61
+ to raise it. Calls also stop when the credit balance reaches zero.
62
+ - **Never a silent fallback.** If foldrun's models are switched off,
63
+ withdrawn for your account, or the chosen provider is not available, every
64
+ step is refused with the reason — it never runs on your stored key, or on
65
+ anything else, instead.
66
+ - **Where it is metered:** every call on foldrun's keys goes through the
67
+ platform's model gateway, whoever makes it — the agent, a `curl` from its
68
+ sandbox, an eval's judge or grader, *draft with AI*, the dashboard
69
+ assistant. The key never enters the sandbox. The run page shows
70
+ *foldrun models · OpenAI* as the step's credential.
71
+
72
+ Not on self-hosted installs: there the account brings its own key.
73
+
32
74
  What `provider: { name: … }` resolves to. Mirrors `foldrun-core/src/providers.ts`,
33
75
  checked against each provider's own documentation on 2026-09-02 and again on
34
76
  2026-09-06; the table below is what the runtime believes, and
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "foldrun",
3
- "version": "13.0.0",
3
+ "version": "13.1.0",
4
4
  "description": "Agents are just folders. Write them, check them, run them — on your machine.",
5
5
  "license": "FSL-1.1-ALv2",
6
6
  "type": "module",
@@ -11,7 +11,7 @@
11
11
  "node": ">=22"
12
12
  },
13
13
  "dependencies": {
14
- "@foldrun/core": "^13.0.0"
14
+ "@foldrun/core": "^13.1.0"
15
15
  },
16
16
  "files": [
17
17
  "bin",
package/src/commands.mjs CHANGED
@@ -5927,13 +5927,18 @@ async function providersCmd(url, flags) {
5927
5927
  }
5928
5928
 
5929
5929
  /**
5930
- * `foldrun account model` — the account's own model key: what every step
5931
- * runs on unless a provider: block names another (/api/account/model).
5930
+ * `foldrun account model` — what every step runs on unless a provider: block
5931
+ * names another (/api/account/model): the account's own model key, or
5932
+ * foldrun's models (the platform's keys for one provider, billed in credits
5933
+ * at foldrun's price list — hosted only).
5932
5934
  *
5933
5935
  * foldrun account model what is set, what runs
5934
5936
  * foldrun account model set <provider> --key <api key> a preset (anthropic,
5935
5937
  * openrouter, openai, groq, …) or `custom --base-url https://… --format openai`
5936
- * foldrun account model remove
5938
+ * foldrun account model remove the key (the choice stays)
5939
+ * foldrun account model use foldrun --provider <p> run on foldrun's models
5940
+ * foldrun account model use own back to the account's own key
5941
+ * foldrun account model prices [--provider <p>] foldrun's price list
5937
5942
  *
5938
5943
  * `--key -` reads the key from stdin, so it stays out of the shell's history.
5939
5944
  * The platform refuses a Claude login token for any account not allowed its
@@ -5941,29 +5946,108 @@ async function providersCmd(url, flags) {
5941
5946
  */
5942
5947
  async function accountModelCmd(url, positional, flags) {
5943
5948
  const verb = positional[0];
5949
+ const money = (n) => `$${n === 0 || n >= 0.01 ? n.toFixed(2) : n.toFixed(4)}`;
5950
+ const fm = (r) => r.foldrunModels ?? null;
5951
+ /** Whether the account's steps can run now, as the platform says. */
5952
+ const runnable = (r) => {
5953
+ if (r.runsOn === "none") return false;
5954
+ if (r.runsOn !== "foldrun") return true;
5955
+ const f = fm(r);
5956
+ const p = f?.providers?.find((x) => x.name === r.supply);
5957
+ return !f?.refused && p?.available !== false;
5958
+ };
5944
5959
  const show = (r) => {
5945
- const runs =
5946
- r.runsOn === "account"
5947
- ? `${c.green("✓")} your own key — ${c.bold(r.provider ?? "custom")} ${c.dim(`${r.keyHint ?? ""} · ${r.baseUrl ?? ""} · ${r.format ?? ""}`)}`
5948
- : r.runsOn === "platform"
5949
- ? `${c.yellow("·")} the platform's credential ${c.dim("(this account is allowed it)")}`
5950
- : `${c.red("✗")} no key — runs on this account are refused until one is set`;
5960
+ const f = fm(r);
5961
+ let runs;
5962
+ if (r.runsOn === "foldrun") {
5963
+ const p = f?.providers?.find((x) => x.name === r.supply);
5964
+ const why = f?.refused ?? (p && !p.available ? p.reason : null);
5965
+ runs = why
5966
+ ? `${c.red("✗")} foldrun's models — ${c.bold(p?.title ?? r.supply)}, refused: ${why}. Runs are refused until it is resolved, or \`foldrun account model use own\``
5967
+ : `${c.green("✓")} foldrun's models — ${c.bold(p?.title ?? r.supply)} ${c.dim("· billed in credits at foldrun's price list")}`;
5968
+ } else if (r.runsOn === "account") {
5969
+ runs = `${c.green("✓")} your own key — ${c.bold(r.provider ?? "custom")} ${c.dim(`${r.keyHint ?? ""} · ${r.baseUrl ?? ""} · ${r.format ?? ""}`)}`;
5970
+ } else if (r.runsOn === "platform") {
5971
+ runs = `${c.yellow("·")} the platform's credential ${c.dim("(this account is allowed it)")}`;
5972
+ } else {
5973
+ runs = `${c.red("✗")} no key — runs on this account are refused until one is set`;
5974
+ }
5951
5975
  console.log(`\n ${runs}`);
5952
- console.log(`\n ${c.dim("foldrun account model set <provider> --key <api key> · remove · a provider: block in AGENTS.md wins over it")}\n`);
5976
+ if (r.runsOn === "foldrun" && f) {
5977
+ const p = f.providers?.find((x) => x.name === r.supply);
5978
+ const tiers = Object.entries(p?.tiers ?? {});
5979
+ if (tiers.length) console.log(` ${c.dim(`model: ${tiers.map(([t, m]) => `${t} → ${m}`).join(" · ")}`)}`);
5980
+ console.log(` ${c.dim(`spent today ${money(f.spentTodayUsd ?? 0)}${f.dailyCapUsd != null ? ` of a ${money(f.dailyCapUsd)} daily cap (UTC)` : " (no daily cap)"}`)}`);
5981
+ if (r.set) console.log(` ${c.dim(`your own key ${r.provider ?? "custom"} ${r.keyHint ?? ""} is kept — \`foldrun account model use own\` runs on it again`)}`);
5982
+ }
5983
+ const hints = ["foldrun account model set <provider> --key <api key>", "remove"];
5984
+ if (f?.offered && r.runsOn !== "foldrun") hints.push("use foldrun --provider <p> (foldrun's models, billed in credits)");
5985
+ if (r.runsOn === "foldrun") hints.push("use own", "prices");
5986
+ console.log(`\n ${c.dim(`${hints.join(" · ")} · a provider: block in AGENTS.md wins over it`)}\n`);
5953
5987
  };
5988
+ const out = (r) => (flags.json === true ? console.log(JSON.stringify(r, null, 2)) : show(r));
5989
+ const put = (body) =>
5990
+ remoteCall(url, flags, "/api/account/model", {
5991
+ method: "PUT",
5992
+ body: JSON.stringify(body),
5993
+ headers: { "idempotency-key": crypto.randomUUID() },
5994
+ });
5954
5995
  if (!verb) {
5955
5996
  const r = await remoteCall(url, flags, "/api/account/model");
5956
- if (flags.json === true) console.log(JSON.stringify(r, null, 2));
5957
- else show(r);
5958
- return r.runsOn === "none" ? 1 : 0;
5997
+ out(r);
5998
+ return runnable(r) ? 0 : 1;
5959
5999
  }
5960
6000
  if (verb === "remove") {
5961
- const r = await remoteCall(url, flags, "/api/account/model", { method: "DELETE" });
5962
- if (flags.json === true) console.log(JSON.stringify(r, null, 2));
5963
- else show(r);
6001
+ out(await remoteCall(url, flags, "/api/account/model", { method: "DELETE" }));
6002
+ return 0;
6003
+ }
6004
+ if (verb === "use") {
6005
+ const source = positional[1];
6006
+ if (source === "own") {
6007
+ out(await put({ source: "own" }));
6008
+ return 0;
6009
+ }
6010
+ if (source !== "foldrun") throw new Error("`foldrun account model use foldrun --provider <anthropic|openai|gemini|openrouter>` or `foldrun account model use own`");
6011
+ const supply = typeof flags.provider === "string" ? flags.provider : positional[2];
6012
+ if (!supply) throw new Error("which provider? `foldrun account model use foldrun --provider anthropic` (anthropic, openai, gemini or openrouter — `foldrun account model prices` lists what each costs)");
6013
+ const r = await put({ source: "foldrun", supply });
6014
+ out(r);
6015
+ return runnable(r) ? 0 : 1;
6016
+ }
6017
+ if (verb === "prices") {
6018
+ const r = await remoteCall(url, flags, "/api/account/model");
6019
+ const f = fm(r);
6020
+ const only = typeof flags.provider === "string" ? flags.provider : null;
6021
+ const prices = (f?.prices ?? []).filter((p) => !only || p.provider === only);
6022
+ if (flags.json === true) {
6023
+ console.log(JSON.stringify({ offered: f?.offered ?? false, providers: f?.providers ?? [], prices }, null, 2));
6024
+ return 0;
6025
+ }
6026
+ if (!f?.offered) {
6027
+ console.log(`\n ${c.yellow("·")} foldrun's models are not offered here${f?.refused ? ` — ${f.refused}` : ""}\n`);
6028
+ return 1;
6029
+ }
6030
+ for (const p of f.providers ?? []) {
6031
+ if (only && p.name !== only) continue;
6032
+ console.log(`\n ${c.bold(p.title)} ${p.available ? "" : c.dim(`— ${p.reason ?? "not available"}`)}`);
6033
+ const tiers = Object.entries(p.tiers ?? {});
6034
+ if (tiers.length) console.log(` ${c.dim(`model: ${tiers.map(([t, m]) => `${t} → ${m}`).join(" · ")}`)}`);
6035
+ const rows = prices.filter((x) => x.provider === p.name);
6036
+ if (!rows.length) {
6037
+ if (p.available) console.log(` ${c.dim("no model priced yet")}`);
6038
+ continue;
6039
+ }
6040
+ const w = Math.max(...rows.map((x) => x.model.length), 5);
6041
+ console.log(` ${c.dim(`${"model".padEnd(w)} ${"in".padStart(8)} ${"out".padStart(8)} ${"cached in".padStart(9)} ${"cache write".padStart(11)}`)}`);
6042
+ for (const x of rows) {
6043
+ const opt = (n) => (n == null ? "—" : money(n));
6044
+ console.log(` ${x.model.padEnd(w)} ${money(x.inputPerMTok).padStart(8)} ${money(x.outputPerMTok).padStart(8)} ${opt(x.cacheReadPerMTok).padStart(9)} ${opt(x.cacheWritePerMTok).padStart(11)}`);
6045
+ }
6046
+ }
6047
+ console.log(`\n ${c.dim("USD per million tokens. A model not listed is refused.")}\n`);
5964
6048
  return 0;
5965
6049
  }
5966
- if (verb !== "set") throw new Error("`foldrun account model`, `foldrun account model set <provider> --key <api key>`, or `foldrun account model remove`");
6050
+ if (verb !== "set") throw new Error("`foldrun account model`, `set <provider> --key <api key>`, `remove`, `use foldrun --provider <p>`, `use own`, or `prices`");
5967
6051
  const provider = positional[1];
5968
6052
  if (!provider) throw new Error("which provider? `foldrun account model set anthropic --key …` (a preset name, or `custom --base-url https://… --format openai`)");
5969
6053
  let apiKey = typeof flags.key === "string" ? flags.key : "";
@@ -5975,13 +6059,7 @@ async function accountModelCmd(url, positional, flags) {
5975
6059
  ...(typeof flags["base-url"] === "string" ? { baseUrl: flags["base-url"] } : {}),
5976
6060
  ...(typeof flags.format === "string" ? { format: flags.format } : {}),
5977
6061
  };
5978
- const r = await remoteCall(url, flags, "/api/account/model", {
5979
- method: "PUT",
5980
- body: JSON.stringify(body),
5981
- headers: { "idempotency-key": crypto.randomUUID() },
5982
- });
5983
- if (flags.json === true) console.log(JSON.stringify(r, null, 2));
5984
- else show(r);
6062
+ out(await put(body));
5985
6063
  return 0;
5986
6064
  }
5987
6065