foldrun 20.2.0 → 20.3.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/cli.md +1 -1
- package/package.json +1 -1
- package/src/commands.mjs +80 -8
package/bin/foldrun.mjs
CHANGED
|
@@ -300,6 +300,7 @@ Signing in
|
|
|
300
300
|
foldrun preferences your own settings on the platform — the theme; set theme system|light|dark (a key acts for whoever minted it)
|
|
301
301
|
foldrun doctor check the path to the platform: node, CLI, model credential, account, DNS, a timed /api/healthz
|
|
302
302
|
foldrun accounts every account signed in on this machine, and which one is active
|
|
303
|
+
foldrun accounts prune forget the saved sign-ins that no longer work (--unreachable: also those whose platform did not answer)
|
|
303
304
|
foldrun use <name> act as one of them from here on
|
|
304
305
|
foldrun keys ls the account's API keys: created, last used, expires, scope, and which are a machine's CLI sign-in (they renew themselves) — also create <label> [--expires 90d], rotate <id> [--grace 1h], revoke <id>
|
|
305
306
|
foldrun keys create <label> --a2a --to <ws> --flows a,b a key for an OUTSIDE agent: it opens /a2a for those published flows and no /api route (--max-tasks N open at once, default 10; --expires); shown once
|
|
@@ -499,7 +500,7 @@ if (!command || command === "--help" || command === "-h") {
|
|
|
499
500
|
// `--value` as the account's argument and stored an empty secret; `--force
|
|
500
501
|
// ./dir` swallowed the directory. A flag followed by another flag is also
|
|
501
502
|
// boolean, so an unlisted switch at least does not eat its neighbour.
|
|
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"]);
|
|
503
|
+
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", "unreachable", "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"]);
|
|
503
504
|
// Flags said more than once collect into a list: `--tag a --tag b`.
|
|
504
505
|
const REPEATABLE = new Set(["tag", "expect", "header", "site", "add", "remove", "rule", "authorize-param", "example", "accept-risk"]);
|
|
505
506
|
// `--wait` is a switch everywhere but `flow add <flow> wait`, where it takes
|
package/docs/cli.md
CHANGED
|
@@ -203,7 +203,7 @@ claude.ai or Claude Code there, nor any MCP configuration on disk.
|
|
|
203
203
|
| `foldrun history restore <path> --id <revision>` | the History drawer's **Restore this version**: the file is rewritten with that revision's text as a new revision, `restored <rev> from history`, so the restore is itself undone the same way. Shows the diff against the file now and asks (`--yes`, `--dry-run`); sent with `ifMatch`, so a file that changed since is refused. A version that does not pass today's checks is still restored, and the errors are printed (`--to`) |
|
|
204
204
|
| `foldrun restore <workspace> --to <revision\|time\|age>` | put a workspace's source back as it was then — `--to` is a revision id (`r-…`, from `foldrun history`), the commit a deploy named, a date/time (the last revision at or before it) or an age (`90m`, `12h`, `3d`, `2w`). Always shows the change first (`--dry-run`: the full diff and nothing else); the restore asks for the workspace's name typed back (`--yes` with no terminal) and sends the removals it showed, so a file added in between refuses it. A new revision, so it prints the `foldrun restore … --to <from>` that undoes it. Runs, `state/`, storage and secrets are not touched. See [Backups and restore](backups-and-restore.md) |
|
|
205
205
|
| `foldrun backups` | how the account is backed up: the schedule, how many are kept, the last snapshot (verified? copied off the server? encrypted?), the snapshots that hold the account, each marked encrypted or not, each workspace's last change, and earlier restore requests (`--limit`, `--json`). `backups request --what runs\|state\|storage\|everything --at "<when>" [--to <workspace>] [--backup <id>] [--note "…"]` asks the platform team for a restore from a snapshot — recorded and emailed; nothing is restored until they do it. `backups requests` lists every request this account has made, and where each stands (`GET /api/account/backups/requests`, `--json`) |
|
|
206
|
-
| `foldrun accounts` | every account signed in on this machine, and which one a bare command acts as. `foldrun profiles` is the same command |
|
|
206
|
+
| `foldrun accounts` | every account signed in on this machine whose sign-in still works, and which one a bare command acts as. Each is asked once (`GET /api/me`, in parallel); one whose key is refused (revoked, expired, an account that is gone) or whose platform does not answer is left out and counted in one line — the active one is always shown, marked when it fails. `--all` lists every one with what it answered; `accounts prune` forgets the refused ones on this machine (asks first; `--yes` on a pipe; `--unreachable` also those that did not answer). `foldrun profiles` is the same command |
|
|
207
207
|
| `foldrun use <name>` | act as one of them from here on. `foldrun switch <name>` is the same command |
|
|
208
208
|
| `foldrun keys ls` | the account's API keys, each with its role and scope, when it was created, when it was last used and from where (a /24 or /48), and when it expires; a key `foldrun login` minted is tagged `CLI sign-in · renews itself` (revoke it to sign that machine out) — also `create <label>` (`--expires 30d\|90d\|365d\|never`), `rotate <id>` and `revoke <id>` |
|
|
209
209
|
| `foldrun keys rotate <id>` | a new key with the old one's label, role, workspaces and deploy scope, printed once; the old key is revoked at once (asks first; `--yes` on a pipe), or keeps working for `--grace 1h` / `24h` while you swap the new one in. A key already rotated is refused (409) and the command names the key that replaced it — rotate that one, also if its secret was lost; `keys ls` shows `rotated → <id>`. The owner is emailed a week before any key expires |
|
package/package.json
CHANGED
package/src/commands.mjs
CHANGED
|
@@ -5876,6 +5876,35 @@ async function workspacesCmd(positional, flags, layout) {
|
|
|
5876
5876
|
return 0;
|
|
5877
5877
|
}
|
|
5878
5878
|
|
|
5879
|
+
/**
|
|
5880
|
+
* Whether a stored sign-in still works: one GET /api/me with its key, all
|
|
5881
|
+
* at once, a few seconds each. `refused`: the platform answered and said no
|
|
5882
|
+
* (a revoked, expired or unknown key, an account that is gone). `unreachable`:
|
|
5883
|
+
* nothing answered (an install that is down, a laptop offline, a 5xx).
|
|
5884
|
+
* @typedef {{ ok: boolean, why: "refused" | "unreachable" | null, detail: string }} SignInStatus
|
|
5885
|
+
* @returns {Promise<SignInStatus>}
|
|
5886
|
+
*/
|
|
5887
|
+
async function signInWorks(p, seconds = 6) {
|
|
5888
|
+
if (!p.token || !p.url) return { ok: false, why: "refused", detail: "no key stored" };
|
|
5889
|
+
/** @type {(why: "refused" | "unreachable", detail: string) => SignInStatus} */
|
|
5890
|
+
const fail = (why, detail) => ({ ok: false, why, detail });
|
|
5891
|
+
try {
|
|
5892
|
+
// Resolved as remoteFetch resolves every call (against the origin), so
|
|
5893
|
+
// the check asks the endpoint real commands use (Codex review).
|
|
5894
|
+
const res = await fetch(new URL("/api/me", p.url), {
|
|
5895
|
+
headers: { authorization: `Bearer ${p.token}`, "user-agent": `foldrun-cli/${CLI_VERSION}` },
|
|
5896
|
+
signal: AbortSignal.timeout(seconds * 1000),
|
|
5897
|
+
});
|
|
5898
|
+
await res.body?.cancel().catch(() => {});
|
|
5899
|
+
if (res.ok) return { ok: true, why: null, detail: "" };
|
|
5900
|
+
if (res.status === 401 || res.status === 403) return fail("refused", `${res.status} — the key no longer works`);
|
|
5901
|
+
return fail("unreachable", `the platform answered ${res.status}`);
|
|
5902
|
+
} catch (err) {
|
|
5903
|
+
const timedOut = err && typeof err === "object" && "name" in err && err.name === "TimeoutError";
|
|
5904
|
+
return fail("unreachable", timedOut ? `no answer in ${seconds}s` : "could not reach it");
|
|
5905
|
+
}
|
|
5906
|
+
}
|
|
5907
|
+
|
|
5879
5908
|
/**
|
|
5880
5909
|
* `foldrun accounts` — every account this machine is signed in to, and
|
|
5881
5910
|
* which one a bare command talks as. `foldrun use <name>` switches.
|
|
@@ -5883,21 +5912,64 @@ async function workspacesCmd(positional, flags, layout) {
|
|
|
5883
5912
|
* The list is the point: someone looking after four customers on one
|
|
5884
5913
|
* platform could see only the last one they signed in as, and had to paste
|
|
5885
5914
|
* --token to reach the others.
|
|
5886
|
-
|
|
5887
|
-
|
|
5915
|
+
*
|
|
5916
|
+
* Only sign-ins that still work are listed (owner, 10 Nov 2026): each is
|
|
5917
|
+
* asked once (GET /api/me), and one whose key is refused or whose platform
|
|
5918
|
+
* does not answer is left out — counted in one line, so the stale keys in
|
|
5919
|
+
* the file are never silently forgotten. The active one is always shown,
|
|
5920
|
+
* marked when it fails, since every bare command uses it. `--all` lists
|
|
5921
|
+
* every one with what it answered; `prune` removes the refused ones
|
|
5922
|
+
* (`--unreachable` too: those that did not answer).
|
|
5923
|
+
*/
|
|
5924
|
+
async function accountsCmd(positional, flags = {}) {
|
|
5888
5925
|
const profiles = listProfiles();
|
|
5889
5926
|
if (!profiles.length) {
|
|
5890
5927
|
console.log(`\n ${c.dim("not signed in anywhere — `foldrun login`")}\n`);
|
|
5891
5928
|
return 0;
|
|
5892
5929
|
}
|
|
5893
5930
|
const verb = positional[0];
|
|
5894
|
-
if (verb && verb !== "ls" && verb !== "list") throw new Error(`accounts: unknown verb "${verb}" —
|
|
5895
|
-
const
|
|
5931
|
+
if (verb && verb !== "ls" && verb !== "list" && verb !== "prune") throw new Error(`accounts: unknown verb "${verb}" — ls (the default) or prune; \`foldrun use <name>\` switches`);
|
|
5932
|
+
const checks = await Promise.all(profiles.map((p) => signInWorks(p)));
|
|
5933
|
+
/** @type {(p: { name: string }) => SignInStatus} */
|
|
5934
|
+
const statusOf = (p) => checks[profiles.findIndex((x) => x.name === p.name)] ?? { ok: false, why: "unreachable", detail: "not asked" };
|
|
5935
|
+
|
|
5936
|
+
if (verb === "prune") {
|
|
5937
|
+
const gone = profiles.filter((p) => {
|
|
5938
|
+
const s = statusOf(p);
|
|
5939
|
+
return !s.ok && (s.why === "refused" || (flags.unreachable === true && s.why === "unreachable"));
|
|
5940
|
+
});
|
|
5941
|
+
if (!gone.length) {
|
|
5942
|
+
console.log(`\n ${c.dim(`nothing to remove — every saved sign-in works${flags.unreachable === true ? " or was not asked to go" : " (or only did not answer: --unreachable removes those)"}`)}\n`);
|
|
5943
|
+
return 0;
|
|
5944
|
+
}
|
|
5945
|
+
const what = `${gone.length} saved sign-in${gone.length === 1 ? "" : "s"} on this machine (${gone.map((p) => p.name).join(", ")}) — their keys stay wherever else they are; only this machine forgets them`;
|
|
5946
|
+
if (!(await sureToDelete(flags, "accounts prune", what))) return 1;
|
|
5947
|
+
for (const p of gone) removeCredential(p.name);
|
|
5948
|
+
console.log(`\n ${c.green("✓")} removed ${gone.map((p) => c.bold(p.name)).join(", ")}\n`);
|
|
5949
|
+
return 0;
|
|
5950
|
+
}
|
|
5951
|
+
|
|
5952
|
+
const all = flags.all === true;
|
|
5953
|
+
const shown = profiles.filter((p) => all || p.current || statusOf(p).ok);
|
|
5954
|
+
const hidden = profiles.filter((p) => !shown.includes(p));
|
|
5955
|
+
const width = Math.max(...shown.map((p) => p.name.length));
|
|
5896
5956
|
console.log("");
|
|
5897
|
-
for (const p of
|
|
5898
|
-
const
|
|
5957
|
+
for (const p of shown) {
|
|
5958
|
+
const s = statusOf(p);
|
|
5959
|
+
const mark = p.current ? (s.ok ? c.green("●") : c.red("●")) : " ";
|
|
5899
5960
|
const who = p.email ?? c.dim("api key");
|
|
5900
|
-
|
|
5961
|
+
const state = s.ok ? "" : ` ${c.red(s.why === "refused" ? "sign-in no longer works" : "platform not answering")} ${c.dim(`(${s.detail})`)}`;
|
|
5962
|
+
console.log(` ${mark} ${c.bold(p.name.padEnd(width))} ${p.account} ${c.dim(`${p.role ?? "?"} · ${who} · ${p.url}`)}${state}`);
|
|
5963
|
+
}
|
|
5964
|
+
const current = profiles.find((p) => p.current);
|
|
5965
|
+
if (current && !statusOf(current).ok) {
|
|
5966
|
+
console.log(`\n ${c.amber("!")} ${c.dim(`the active one, ${current.name}, does not work: \`foldrun login\` again, or \`foldrun use <name>\` another`)}`);
|
|
5967
|
+
}
|
|
5968
|
+
if (hidden.length) {
|
|
5969
|
+
const refused = hidden.filter((p) => statusOf(p).why === "refused").length;
|
|
5970
|
+
const away = hidden.length - refused;
|
|
5971
|
+
const parts = [refused ? `${refused} no longer work${refused === 1 ? "s" : ""}` : "", away ? `${away} did not answer` : ""].filter(Boolean).join(", ");
|
|
5972
|
+
console.log(`\n ${c.dim(`${hidden.length} more saved sign-in${hidden.length === 1 ? "" : "s"} not shown (${parts}) — \`foldrun accounts --all\` lists them, \`foldrun accounts prune\` removes the ones that no longer work.`)}`);
|
|
5901
5973
|
}
|
|
5902
5974
|
console.log(`\n ${c.dim("● is the one a bare command talks as. `foldrun use <name>` switches; --profile <name> is one command.")}\n`);
|
|
5903
5975
|
return 0;
|
|
@@ -14713,7 +14785,7 @@ export async function run(command, positional, flags, workspace, layout) {
|
|
|
14713
14785
|
return auditCmd(positional, flags);
|
|
14714
14786
|
case "accounts":
|
|
14715
14787
|
case "profiles":
|
|
14716
|
-
return accountsCmd(positional);
|
|
14788
|
+
return accountsCmd(positional, flags);
|
|
14717
14789
|
case "use":
|
|
14718
14790
|
case "switch":
|
|
14719
14791
|
return useCmd(positional);
|