foldrun 20.1.0 → 20.2.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 +2 -1
- package/docs/api.md +1 -1
- package/docs/claude-code.md +26 -3
- package/docs/cli.md +1 -1
- package/package.json +1 -1
- package/src/commands.mjs +10 -4
package/bin/foldrun.mjs
CHANGED
|
@@ -454,6 +454,7 @@ Options
|
|
|
454
454
|
--a2a keys create: an A2A key for an outside agent — with --to <workspace> and --flows a,b; --max-tasks <n> caps its open tasks (1–100, default 10)
|
|
455
455
|
--gateway keys create: a gateway key for Claude Code — with --cap <usd> (in all) and/or --daily <usd> (per UTC day)
|
|
456
456
|
--cap <usd>, --daily <usd> keys create --gateway: the key's own spending limits, $0.01–$100000
|
|
457
|
+
--login keys create --gateway: on the operator's Claude login instead (the operator's own accounts; not metered, no limits)
|
|
457
458
|
--key-env <NAME> a2a call, a2a status, a2a cancel, a2a card: the environment variable holding the A2A key (default FOLDRUN_A2A_KEY) — a key is never taken on the command line
|
|
458
459
|
--card <url> a2a status, a2a cancel: the agent card of the agent that holds the task
|
|
459
460
|
|
|
@@ -498,7 +499,7 @@ if (!command || command === "--help" || command === "-h") {
|
|
|
498
499
|
// `--value` as the account's argument and stored an empty secret; `--force
|
|
499
500
|
// ./dir` swallowed the directory. A flag followed by another flag is also
|
|
500
501
|
// boolean, so an unlisted switch at least does not eat its neighbour.
|
|
501
|
-
const BOOLEAN_FLAGS = new Set(["read-only", "account", "follow", "force", "oauth2", "wait", "watch", "print", "dry-run", "help", "no-browser", "local", "test", "flat", "yes", "platform", "json", "forever", "all", "check", "new-client", "quiet", "off", "can-ask", "preview", "csv", "failed", "starter", "history", "list", "library", "clear", "security", "changed", "write-baseline", "no-baseline", "rules", "calls", "tree", "tool-error", "stop", "last", "no-pkce", "generate-key", "device", "write", "dpop", "export", "isolated", "no-wait", "dismissed", "unread", "team", "started", "mine", "none", "a2a", "gateway", "public-card", "private-card", "return-immediately", "online", "overwrite", "no-send", "event-wait", "with-client", "use", "clear-name", "clear-description", "clear-examples", "clear-accept-risk", "clear-address", "clear-email", "clear-abn", "no-task", "empty"]);
|
|
502
|
+
const BOOLEAN_FLAGS = new Set(["read-only", "account", "follow", "force", "oauth2", "wait", "watch", "print", "dry-run", "help", "no-browser", "local", "test", "flat", "yes", "platform", "json", "forever", "all", "check", "new-client", "quiet", "off", "can-ask", "preview", "csv", "failed", "starter", "history", "list", "library", "clear", "security", "changed", "write-baseline", "no-baseline", "rules", "calls", "tree", "tool-error", "stop", "last", "no-pkce", "generate-key", "device", "write", "dpop", "export", "isolated", "no-wait", "dismissed", "unread", "team", "started", "mine", "none", "a2a", "gateway", "login", "public-card", "private-card", "return-immediately", "online", "overwrite", "no-send", "event-wait", "with-client", "use", "clear-name", "clear-description", "clear-examples", "clear-accept-risk", "clear-address", "clear-email", "clear-abn", "no-task", "empty"]);
|
|
502
503
|
// Flags said more than once collect into a list: `--tag a --tag b`.
|
|
503
504
|
const REPEATABLE = new Set(["tag", "expect", "header", "site", "add", "remove", "rule", "authorize-param", "example", "accept-risk"]);
|
|
504
505
|
// `--wait` is a switch everywhere but `flow add <flow> wait`, where it takes
|
package/docs/api.md
CHANGED
|
@@ -366,7 +366,7 @@ Reads return which secrets exist, never their values.
|
|
|
366
366
|
|
|
367
367
|
| Route | Methods | |
|
|
368
368
|
|---|---|---|
|
|
369
|
-
| `/api/keys` | GET, POST, DELETE | API keys — an admin's (`keys:manage`) to list, mint and revoke; any key may revoke itself (DELETE with its own `id`, audited as self — what `foldrun logout` does). POST `label`, `role` (viewer \| editor \| admin, never above your own, default editor), `workspaces` (names, or `null` for all — never wider than your own scope); `expires` (`30d`, `90d`, `365d`, any number of days up to 3650, or `never` — the default; anything else is a 400, never a key that lives forever); returns `{ ok, key, id, prefix, role, workspaces, expiresAt }`. POST `{ purpose: "a2a", workspace, flows, maxTasks?, label?, expires? }` mints an A2A key instead: for an outside agent, it opens `/a2a/<account>/<workspace>/…` for the named flows (each must say `a2a: { publish: true }` when the key is minted — a flow not published is refused, 400 — and still say it on every call) and every `/api` route refuses it (403); `maxTasks` (1–100, default 10) caps its tasks open at once; it answers `{ ok, key, id, prefix, purpose, workspace, flows, maxTasks, role, workspaces, expiresAt }`, and rotating one keeps the tasks it made, and the key is shown once. POST `{ purpose: "gateway", capUsd?, dailyUsd?, label?, expires? }` mints a gateway key: for a coding agent such as Claude Code (`ANTHROPIC_BASE_URL` + the key, [Claude Code](claude-code.md)), it spends the account's credits on foldrun's Anthropic models through the gateway and every `/api` route refuses it (403); it needs `capUsd` (USD in all) or `dailyUsd` (USD per UTC day), $0.01–$100,000 after rounding to cents, is minted only by an admin of every workspace (a scoped admin is 403) and only on the hosted platform (400 elsewhere), and answers `{ ok, key, id, prefix, purpose, capUsd, dailyUsd, expiresAt, gatewayUrl }`; rotating one keeps its limits. GET lists each key with `createdAt`, `createdBy`, `expiresAt`, `lastUsedAt`, `lastIp` and `replacedBy` (the id of the key a rotation replaced it with; `null` until then), a gateway key's `gateway: { capUsd, dailyUsd, spentUsd, todayUsd }` (spent in all and today, UTC, calls in flight at their hold), and at the top `gatewayUrl` (the gateway's address; `null` where the install has none) — the last-use pair written at most once a minute per key, the address cut to its /24 (IPv4) or /48 (IPv6). A key past its `expiresAt` is refused with 401 `API key expired on <date>`; the owner is emailed seven days before. Mint, revoke and rotate are written to the audit log. POST with `workspace` or `access` is refused (400): those minted deploy keys for the platform's own git, which went on 17 Oct 2026 — a deploy key minted before is refused everywhere (403). A key for one workspace is `workspaces: ["<ws>"]`. DELETE `id`. `?tenant=` / body `tenant` is read only on an install with no users yet (first-run bootstrap), and there, when the install has a setup token (`FOLDRUN_SETUP_TOKEN`, written by the self-hosting installer), only with that token in `X-Foldrun-Setup-Token` |
|
|
369
|
+
| `/api/keys` | GET, POST, DELETE | API keys — an admin's (`keys:manage`) to list, mint and revoke; any key may revoke itself (DELETE with its own `id`, audited as self — what `foldrun logout` does). POST `label`, `role` (viewer \| editor \| admin, never above your own, default editor), `workspaces` (names, or `null` for all — never wider than your own scope); `expires` (`30d`, `90d`, `365d`, any number of days up to 3650, or `never` — the default; anything else is a 400, never a key that lives forever); returns `{ ok, key, id, prefix, role, workspaces, expiresAt }`. POST `{ purpose: "a2a", workspace, flows, maxTasks?, label?, expires? }` mints an A2A key instead: for an outside agent, it opens `/a2a/<account>/<workspace>/…` for the named flows (each must say `a2a: { publish: true }` when the key is minted — a flow not published is refused, 400 — and still say it on every call) and every `/api` route refuses it (403); `maxTasks` (1–100, default 10) caps its tasks open at once; it answers `{ ok, key, id, prefix, purpose, workspace, flows, maxTasks, role, workspaces, expiresAt }`, and rotating one keeps the tasks it made, and the key is shown once. POST `{ purpose: "gateway", capUsd?, dailyUsd?, label?, expires? }` mints a gateway key: for a coding agent such as Claude Code (`ANTHROPIC_BASE_URL` + the key, [Claude Code](claude-code.md)), it spends the account's credits on foldrun's Anthropic models through the gateway and every `/api` route refuses it (403); it needs `capUsd` (USD in all) or `dailyUsd` (USD per UTC day), $0.01–$100,000 after rounding to cents, is minted only by an admin of every workspace (a scoped admin is 403) and only on the hosted platform (400 elsewhere), and answers `{ ok, key, id, prefix, purpose, capUsd, dailyUsd, expiresAt, gatewayUrl }`; rotating one keeps its limits. With `credential: "login"` it runs on the operator's own Claude login instead — only on an account the operator allows its model credential (403 otherwise), with no `capUsd`/`dailyUsd` (400), not metered or billed; it answers `credential: "login"` and lists with no spend. GET lists each key with `createdAt`, `createdBy`, `expiresAt`, `lastUsedAt`, `lastIp` and `replacedBy` (the id of the key a rotation replaced it with; `null` until then), a gateway key's `gateway: { capUsd, dailyUsd, spentUsd, todayUsd }` (spent in all and today, UTC, calls in flight at their hold), and at the top `gatewayUrl` (the gateway's address; `null` where the install has none) — the last-use pair written at most once a minute per key, the address cut to its /24 (IPv4) or /48 (IPv6). A key past its `expiresAt` is refused with 401 `API key expired on <date>`; the owner is emailed seven days before. Mint, revoke and rotate are written to the audit log. POST with `workspace` or `access` is refused (400): those minted deploy keys for the platform's own git, which went on 17 Oct 2026 — a deploy key minted before is refused everywhere (403). A key for one workspace is `workspaces: ["<ws>"]`. DELETE `id`. `?tenant=` / body `tenant` is read only on an install with no users yet (first-run bootstrap), and there, when the install has a setup token (`FOLDRUN_SETUP_TOKEN`, written by the self-hosting installer), only with that token in `X-Foldrun-Setup-Token` |
|
|
370
370
|
| `/api/keys/<id>/rotate` | POST | a new key with the old one's label, role, workspaces and deploy scope — and, when it had an end, the same lifetime from today — returned once like a mint (`{ ok, key, id, prefix, role, workspaces, expiresAt, replaced: { id, endsAt } }`). `grace`: `0` (default — the old key is revoked at once), or a duration up to `7d` such as `1h` or `24h`, during which the old key still works and after which it is refused as expired. A key is rotated once: rotating a key already replaced is 409 `this key was already rotated to <prefix>…; rotate that one` — and someone who lost the new key's secret rotates the NEW key, which mints another and ends the lost one (rotating the old one again would leave the lost key working). Two rotations of one key at once mint one key. `keys:manage`; a key outside the caller's scope is 404 — except that a key `foldrun login` minted may rotate **itself**, whatever its role: same label, role, workspaces and 90-day lifetime from today, the old key ending 10 minutes later (`grace` is not read). A retry with the old key inside those 10 minutes — the CLI lost the answer, or could not store it — rotates that replacement instead, when nobody has used it and it is at least 30 seconds old (a younger one is a 409: another command may have just stored it). That is how the CLI renews its sign-in; any other key rotating itself still needs `keys:manage`. Audited as `apikey.rotated` (`self: true` for a self-rotation). A `foldrun login` key stays one only when it renews itself or its own person rotates it, signed in; rotated by any other caller the new key is an ordinary one |
|
|
371
371
|
| `/api/team` | GET, POST | members with their roles and workspace scope; mint an invite (a session, or the person's own `foldrun login` key, which invites no admin) — `role` (viewer \| editor \| admin, default editor), `workspaces` (names, or omit for all), `email` (only that address can accept it; sent through the account's `RESEND_API_KEY` unless `send: false`). An invite works **once**, for seven days, and a newer invite to the same address revokes the older ones still pending. Returns `id`, `path` (the invite's relative URL, shown only here), `expires`, `sent` and any `sendError` either way; the full link is in the mail. Links made before 29 Oct 2026 (`inv1`–`inv3`) are refused |
|
|
372
372
|
| `/api/team/invites?all=1` | GET | the account's invites, newest first — pending ones unless `all=1` (then accepted, revoked and expired too): `{ invites: [{ id, email, role, workspaces, invitedBy, createdAt, expiresAt, status }] }`, `email` `null` for a link anyone may use, `workspaces` `null` for all, `status` `pending` \| `accepted` \| `revoked` \| `expired`. Never the link. `team:manage` — an admin key included; a caller scoped to some workspaces sees only the invites inside its scope |
|
package/docs/claude-code.md
CHANGED
|
@@ -28,9 +28,8 @@ foldrun keys create laptop --gateway --cap 20 --daily 5
|
|
|
28
28
|
- **A limit of its own is required:** `--cap` (USD, in all) or `--daily`
|
|
29
29
|
(USD, per UTC day), or both — from $0.01 to $100,000.
|
|
30
30
|
Limits are in dollars charged — what the account pays at foldrun's price
|
|
31
|
-
list — and so is the spend `keys ls` shows.
|
|
32
|
-
|
|
33
|
-
new one.
|
|
31
|
+
list — and so is the spend `keys ls` shows. Each call is kept at the
|
|
32
|
+
margin it was charged at, so a margin changed later re-prices nothing.
|
|
34
33
|
- **Who may mint one:** an admin of every workspace. The key spends the
|
|
35
34
|
whole account's balance, so a workspace-scoped admin cannot.
|
|
36
35
|
- **What it opens:** the gateway only. Every `/api` route refuses it (403),
|
|
@@ -43,6 +42,30 @@ foldrun keys create laptop --gateway --cap 20 --daily 5
|
|
|
43
42
|
The API is `POST /api/keys { purpose: "gateway", capUsd?, dailyUsd?, label?, expires? }`
|
|
44
43
|
([API](api.md)).
|
|
45
44
|
|
|
45
|
+
## On the operator's Claude login
|
|
46
|
+
|
|
47
|
+
An account the operator allows its own model credential — the one its desks
|
|
48
|
+
run on — may mint a gateway key on the operator's Claude login instead:
|
|
49
|
+
|
|
50
|
+
```sh
|
|
51
|
+
foldrun keys create mine --gateway --login
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
or **Runs on → The operator's Claude login** on Settings → API keys (shown
|
|
55
|
+
only on such an account). Such a key:
|
|
56
|
+
|
|
57
|
+
- sends the operator's Claude login to Anthropic, read fresh on every call,
|
|
58
|
+
so the platform's token refresh reaches it with no restart;
|
|
59
|
+
- is **not metered or billed** and takes no `--cap` or `--daily` — the
|
|
60
|
+
login is a flat-rate subscription, so there is no dollar figure to hold;
|
|
61
|
+
- shares that subscription's weekly cap with the account's desks: a long
|
|
62
|
+
coding session can leave the desks out of their window until it resets;
|
|
63
|
+
- opens nothing once the account is no longer allowed the credential: the
|
|
64
|
+
gateway asks on every call.
|
|
65
|
+
|
|
66
|
+
It is for the operator's own use. A subscription's terms are its owner's to
|
|
67
|
+
keep; foldrun's models (the rest of this page) are what to give anyone else.
|
|
68
|
+
|
|
46
69
|
## What the gateway serves
|
|
47
70
|
|
|
48
71
|
| Route | |
|
package/docs/cli.md
CHANGED
|
@@ -314,7 +314,7 @@ claude.ai or Claude Code there, nor any MCP configuration on disk.
|
|
|
314
314
|
| `--expires <span>` | `keys create`: when it stops working — `30d`, `90d` (the default, as in the dashboard; before CLI 15.0.0 the default was never), `365d` or `never`; `--forever` is `never` |
|
|
315
315
|
| `--grace <span>` | `keys rotate`: keep the old key working for `1h` or `24h` (default `0`: revoked now) |
|
|
316
316
|
| `--a2a` | `keys create`: an A2A key for an outside agent, with `--to <workspace>`, `--flows a,b` and optionally `--max-tasks <n>` |
|
|
317
|
-
| `--gateway` | `keys create`: a gateway key for Claude Code, with `--cap <usd>` and/or `--daily <usd>` |
|
|
317
|
+
| `--gateway` | `keys create`: a gateway key for Claude Code, with `--cap <usd>` and/or `--daily <usd>` — or `--login` (the operator's Claude login, on the operator's own accounts; not metered, no limits) |
|
|
318
318
|
| `--key-env <NAME>` | `a2a call`, `a2a status`, `a2a cancel`, `a2a card`: the environment variable that holds the A2A key (default `FOLDRUN_A2A_KEY`) |
|
|
319
319
|
| `--card <url>` | `a2a status`, `a2a cancel`: the agent card of the agent that holds the task |
|
|
320
320
|
| `--force` | `deploy`: deploy while runs are in flight. `pull`, `storage get`: overwrite local files |
|
package/package.json
CHANGED
package/src/commands.mjs
CHANGED
|
@@ -4696,6 +4696,7 @@ async function doctor(flags) {
|
|
|
4696
4696
|
* keys create <label> --expires 90d it stops working in 90 days (30d, 365d, never)
|
|
4697
4697
|
* keys create <label> --a2a --to <ws> --flows a,b [--max-tasks N] a key for an outside agent: /a2a only
|
|
4698
4698
|
* keys create <label> --gateway --cap <usd> [--daily <usd>] a coding agent's key (Claude Code): the gateway only
|
|
4699
|
+
* keys create <label> --gateway --login on the operator's Claude login (its own accounts): not metered
|
|
4699
4700
|
* keys rotate <id> [--grace 1h] a new key, same label/role/scope; the old
|
|
4700
4701
|
* one ends now, or when the grace runs out.
|
|
4701
4702
|
* A key already rotated is refused (409):
|
|
@@ -4828,6 +4829,7 @@ async function keysCreateA2a(url, label, flags) {
|
|
|
4828
4829
|
|
|
4829
4830
|
/** How `keys ls` describes a gateway key: its limits, and what it has spent. */
|
|
4830
4831
|
function gatewayLine(g) {
|
|
4832
|
+
if (g?.credential === "login") return "gateway · Claude Code · the operator's Claude login · not metered";
|
|
4831
4833
|
const usd = (n) => `$${Number(n ?? 0).toFixed(2)}`;
|
|
4832
4834
|
const parts = ["gateway · Claude Code"];
|
|
4833
4835
|
if (g?.capUsd != null) parts.push(`${usd(g.spentUsd)} of ${usd(g.capUsd)}`);
|
|
@@ -4855,10 +4857,14 @@ async function keysCreateGateway(url, label, flags) {
|
|
|
4855
4857
|
if (flags.role !== undefined || flags.workspaces !== undefined || flags.to !== undefined || flags.flows !== undefined) {
|
|
4856
4858
|
throw new Error("a gateway key takes --cap and --daily, not --role, --workspaces, --to or --flows — it opens the gateway only, never the API");
|
|
4857
4859
|
}
|
|
4858
|
-
|
|
4859
|
-
|
|
4860
|
-
if (
|
|
4860
|
+
// --login: the operator's own Claude login, for an account the operator
|
|
4861
|
+
// allows it (its desks' accounts) — not metered, so it takes no limit.
|
|
4862
|
+
if (flags.login === true && (flags.cap !== undefined || flags.daily !== undefined)) throw new Error("--login takes no --cap or --daily — the operator's Claude login is not metered, so a dollar limit could not hold it");
|
|
4863
|
+
const capUsd = flags.login === true ? undefined : usdFlag(flags.cap, "--cap");
|
|
4864
|
+
const dailyUsd = flags.login === true ? undefined : usdFlag(flags.daily, "--daily");
|
|
4865
|
+
if (flags.login !== true && capUsd === undefined && dailyUsd === undefined) throw new Error("a gateway key needs a limit of its own: --cap <usd> in all, or --daily <usd> per UTC day (or both) — or --login, on an account the operator's Claude login is for");
|
|
4861
4866
|
const body = { label, purpose: "gateway" };
|
|
4867
|
+
if (flags.login === true) body.credential = "login";
|
|
4862
4868
|
if (capUsd !== undefined) body.capUsd = capUsd;
|
|
4863
4869
|
if (dailyUsd !== undefined) body.dailyUsd = dailyUsd;
|
|
4864
4870
|
if (flags.forever === true && flags.expires !== undefined) throw new Error("--forever or --expires <span>, not both");
|
|
@@ -4866,7 +4872,7 @@ async function keysCreateGateway(url, label, flags) {
|
|
|
4866
4872
|
if (flags.expires !== undefined && typeof flags.expires !== "string") throw new Error("--expires needs a span: 30d, 90d, 365d or never");
|
|
4867
4873
|
body.expires = flags.forever === true ? "never" : typeof flags.expires === "string" ? flags.expires : "90d";
|
|
4868
4874
|
const made = await remoteCall(url, flags, "/api/keys", { method: "POST", body: JSON.stringify(body) });
|
|
4869
|
-
console.log(`\n ${c.green("✓")} ${c.bold(label)} ${c.dim(made.id)} ${c.dim(gatewayLine({ capUsd: made.capUsd ?? null, dailyUsd: made.dailyUsd ?? null, spentUsd: 0, todayUsd: 0 }))}${made.expiresAt ? c.dim(` expires ${made.expiresAt.slice(0, 10)}`) : ""}\n`);
|
|
4875
|
+
console.log(`\n ${c.green("✓")} ${c.bold(label)} ${c.dim(made.id)} ${c.dim(gatewayLine({ capUsd: made.capUsd ?? null, dailyUsd: made.dailyUsd ?? null, spentUsd: 0, todayUsd: 0, credential: made.credential }))}${made.expiresAt ? c.dim(` expires ${made.expiresAt.slice(0, 10)}`) : ""}\n`);
|
|
4870
4876
|
if (made.key == null) return lostSecret(made.id);
|
|
4871
4877
|
console.log(` ${made.key}\n`);
|
|
4872
4878
|
const base = made.gatewayUrl ?? "<the gateway URL — not set on this platform yet>";
|