foldrun 8.0.0 → 8.1.1
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/docs/api.md +4 -4
- package/docs/cli.md +10 -0
- package/docs/security.md +10 -0
- package/package.json +3 -3
- package/src/commands.mjs +148 -25
package/docs/api.md
CHANGED
|
@@ -203,7 +203,7 @@ paying for the steps around it.
|
|
|
203
203
|
| `/api/workspaces/<ws>/runs/<id>/calls/<call>` | GET | one tool call's recorded content (see [Runs](runs#what-a-run-records)): `{ call: { id, tool, input, output, inputChars, outputChars, truncated, inputCut, outputCut } }` — what it was given and what it gave back, secrets masked, each at most 65,536 characters; `inputChars`/`outputChars` are the whole length, `inputCut`/`outputCut` say which part was cut (`truncated`: either). `<call>` is the tool event's `call`; an event with `captured: true` has content here. 404 when nothing was recorded: the workspace says `capture: metadata`, or the run is from before 19 Oct 2026. A run's steps also carry `calls`, each model call (`n`, `at`, `ms`, `model`, `stop`, `tokens`, `tools`, and `subagent` / `attempt` when a sub-agent or a later attempt made it); a step that handed jobs to `sandbox: own` sub-agents carries `delegations` (`id`, `agent`, `status`, `costUsd`, `ms`), and each job is a step of its own with `subagentOf` (the delegating agent), `delegation` (that `id`) and `wrote` (the workspace paths it changed — copied into the delegating step's sandbox too, up to 4 MiB a job); and the run its `revision` (the workspace's latest revision when a worker picked it up — a deploy's commit, or the id an edit through `/source` was saved as) and `drivenAt` (when that was) |
|
|
204
204
|
| `/api/workspaces/<ws>/runs/<id>/trace` | GET | the run as one tree (see [Runs](runs#the-trace-tree)): `{ tree, failure }`. Each span is `{ id, kind, label, start, end, status, children, … }`, where `kind` is `run`, `step`, `model` (one model call: `model`, `stop`, `tokens`), `tool` (`call`, `captured` when its input and output were recorded) or `error` (`text`); `start`/`end` are epoch milliseconds and `status` is `ok`, `error`, `running`, `waiting`, `skipped` or `pending`. A tool call sits under the model call that asked for it. `failure` is the ids from the root to the first thing that went wrong, which the run page opens on; `[]` when nothing did |
|
|
205
205
|
| `/api/workspaces/<ws>/runs/<id>/compare?with=` | GET | this run beside another of the same flow (see [Runs](runs#compare-with-the-last-good-run)): `{ comparison: { base, run, revisionChanged, changedFiles, steps }, chosen }`. Each step is `{ step, agent, base, run, changes }`: both sides' status, instruction, model, seconds, tokens, model calls, tool counts, tool errors, first errors and first line said, and `changes` in words (`status: completed → failed`, `new error: …`, `instruction changed`, `tools: +web ×3`, `took 12s → 48s`, …). `changedFiles` lists the files changed between the revisions the two ran (null when one is unknown). `with` names the other run; unasked it is the newest earlier run of the flow that finished well, else the run this one re-ran (`chosen` says which) |
|
|
206
|
-
| `/api/workspaces/<ws>/runs/<id>` | GET, DELETE | the whole run: every step, its output, cost, timing, the runner `image` it ran on and — for a step that browsed through the account's pod from slim — its `browserPod` reconnects and fallback ([runs](runs#the-record)). `?wait=true&timeout=<s>` instead blocks until the run stops (or `timeout`, default 300, max 900) and answers the verdict the run routes give — `200` completed, `
|
|
206
|
+
| `/api/workspaces/<ws>/runs/<id>` | GET, DELETE | the whole run: every step, its output, cost, timing, the runner `image` it ran on and — for a step that browsed through the account's pod from slim — its `browserPod` reconnects and fallback ([runs](runs#the-record)). `?wait=true&timeout=<s>` instead blocks until the run stops (or `timeout`, default 300, max 900) and answers the verdict the run routes give — `200` once the run has ended, however it ended: `ok: true` when it completed, `ok: false` with its `status` and `failure: { agent, reason }` when it failed or was stopped (a run that fails is the answer, not a fault in the call — it was a `500` before 29 Oct 2026); `202` still going (`timedOut`) or parked on a person (`awaitingApproval`). A start refused before any run exists — a paused account or workspace (`423`), an agent or flow that is not there (`404`), `overlap: skip` (`409`) — is answered as such and waits for nothing. Ask in short pieces: whatever sits in front of the platform cuts a request that stays silent too long (Cloudflare at 100 s, an AWS ALB at 60 s), and a flow can run for many minutes — the CLI's `--wait` asks 25 s at a time and comes back here on every `202` |
|
|
207
207
|
| `/api/workspaces/<ws>/runs/<id>/stream` | GET | server-sent events, live |
|
|
208
208
|
| `/api/workspaces/<ws>/runs/<id>/stop` | POST | destroys the sandbox, not just the record |
|
|
209
209
|
| `/api/workspaces/<ws>/runs/<id>/rerun` | POST | again — `step` to start partway, or `agent` to start at the first step that agent runs (one of the two is required). `instruction` tells that step something else this once, in place of the flow's (the flow file is not changed); the new run's `rerunOf` says `{ run, step, instruction }`. Takes `?wait=true&timeout=` like a flow start |
|
|
@@ -337,7 +337,7 @@ Reads return which secrets exist, never their values.
|
|
|
337
337
|
| Route | Methods | |
|
|
338
338
|
|---|---|---|
|
|
339
339
|
| `/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 }`, and the key is shown once. 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) — 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` |
|
|
340
|
-
| `/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. Audited as `apikey.rotated` |
|
|
340
|
+
| `/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) |
|
|
341
341
|
| `/api/team` | GET, POST | members with their roles and workspace scope; mint an invite — `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 |
|
|
342
342
|
| `/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 |
|
|
343
343
|
| `/api/team/invites/<id>` | DELETE | revoke an invite: its link stops working at once. `{ ok, revoked, invite }` — `revoked: false` when it was already revoked or expired; `404` for an id that is not this account's; `409` for one already accepted (remove the member instead). `team:manage`, a key included; a scoped caller only inside its scope, and an admin invite only by the owner. Audited as `member.invite_revoked` |
|
|
@@ -463,8 +463,8 @@ signed-in person, never by a key — mints an ordinary API key at their role.
|
|
|
463
463
|
|---|---|---|
|
|
464
464
|
| `/api/cli/login` | POST | `hostname` → `{ id, code, verifyUrl, expiresAt, interval }`. Open: there is no credential yet. Ten-minute lifetime |
|
|
465
465
|
| `/api/cli/login/<id>` | GET | `{ status }` — `pending`, `denied`, `expired`, or `approved` with `token`, `account`, `email`, `role`. The key is returned once; the request is gone after |
|
|
466
|
-
| `/api/cli/authorize` | GET, POST | `?code=` describes the request (machine, expiry). POST `{ code, decision }` from a session approves (mints the key, labelled `cli · <hostname
|
|
467
|
-
| `/api/me` | GET | who is calling: `account`, `owner`, `role`, `workspaces` (null: all), and the `actor` — a person's email, or a key's id, label, prefix
|
|
466
|
+
| `/api/cli/authorize` | GET, POST | `?code=` describes the request (machine, expiry). POST `{ code, decision }` from a session approves (mints the key, labelled `cli · <hostname>`, ending in 90 days — the CLI renews it itself before then, see `/api/keys/<id>/rotate`) or denies — `decision` is `approve` or `deny`, and absent approves; any other word is a `400`. Every role may sign its own CLI in; an owner's key is an admin's |
|
|
467
|
+
| `/api/me` | GET | who is calling: `account`, `owner`, `role`, `workspaces` (null: all), and the `actor` — a person's email, or a key's id, label, prefix, who minted it, `expiresAt` (null: never) and `origin` (`cli-login` for a key `foldrun login` minted, else null) |
|
|
468
468
|
| `/api/me/onboarding` | GET, PATCH | the account's getting-started steps, each derived from what is really there — `{ steps: [{ id, title, why, href, cli?, done }], done, total, complete, next, dismissed, dismissedAt }`. Steps: `model` (first; only for an account that must bring its own key — done once it has one, or a `provider:` block in the account's AGENTS.md), `workspace`, `agent` (an agent written or deployed after the workspace was made), `run`, `success` (a completed run), `secret`, `trigger` (a schedule or webhook), `teammate` (a second member), `billing` (hosted, not fully waived: a saved card or a plan), `cli` (any API key or CLI login). PATCH `{ dismissed: true or false }` hides or brings back the dashboard card for the signed-in person (kept in their prefs); a key reads `dismissed: false` and cannot PATCH |
|
|
469
469
|
| `/api/me/inbox` | GET, POST | your inbox — what waits on you across the workspaces you may see. GET `{ person, items: [{ id, kind (approval, question, issue, proposal, run), bucket (mine, started, team), why, workspace, title, detail, at, href, read, dismissed }], counts: { mine, started, team, unread } }`, newest first. `mine` is assigned to you (named in `approvers:`, owner of the flow or agent, or you asked for the proposal); `started` is runs you started — failed or BLOCKED/BAD this week, a gate on one (someone else decides it), a question it asked; `team` is the rest that waits in your workspaces. By default `mine` and `started`; `?bucket=mine\|started\|team\|all`, `?kind=`, `?workspace=`, `?dismissed=1` for what you set aside. `counts.unread` is unread `mine` + `started`. POST `{ ids \| id, action: read\|unread\|dismiss\|restore }` changes your view only — dismissing never decides a gate or resolves an issue; ids name an occurrence, so a thing that happens again is new. A key acts for the person who minted it, inside the key's own scope; one no person minted is a `400` |
|
|
470
470
|
| `/api/me/notifications` | GET, PATCH | what mail you get. GET `{ email, categories: [{ category, label, description, required, why?, perWorkspace, enabled, workspaces: { <ws>: bool } }] }` for `security`, `invites`, `billing`, `account` (required — always sent) and `run-alerts`, `approvals` (per workspace), `low-balance`, `product-updates`. PATCH `{ category, enabled, workspace? }` or `{ preferences: [ … ] }`; answers the same as GET. Turning a required category off is a `409` with the reason; `workspace` on an account-wide category is a `400`; `enabled: true` account-wide clears that category's per-workspace offs. A key acts for the person who minted it |
|
package/docs/cli.md
CHANGED
|
@@ -314,6 +314,16 @@ revoked like any other — and the CLI stored it in `~/.foldrun/credentials.json
|
|
|
314
314
|
(mode 0600; `FOLDRUN_HOME` moves the directory). An owner's terminal is an
|
|
315
315
|
admin's: a key is never an owner.
|
|
316
316
|
|
|
317
|
+
That key lasts 90 days, and renews itself: when a command finds fewer than
|
|
318
|
+
14 days left, the CLI rotates the key from itself (same label, role and
|
|
319
|
+
workspaces) and stores the new one, saying so on one dim line. A machine in
|
|
320
|
+
use never sees its sign-in end; one left unused for 90 days is signed out,
|
|
321
|
+
and the next command says to run `foldrun login` again. A key handed in with
|
|
322
|
+
`--token` or `FOLDRUN_TOKEN` is never renewed — its end is its owner's.
|
|
323
|
+
A credentials file the CLI cannot write is not renewed either (the new key
|
|
324
|
+
would be lost); if storing a renewed key fails, the CLI says so, and the next
|
|
325
|
+
command within ten minutes tries again.
|
|
326
|
+
|
|
317
327
|
`foldrun login --url https://foldrun.example.com` signs in to your own
|
|
318
328
|
installation; the last one signed in to is the default afterwards, and
|
|
319
329
|
`--url` on any command picks another. `foldrun login --token <key>` stores a
|
package/docs/security.md
CHANGED
|
@@ -92,6 +92,16 @@ At rest, each account has its own encryption key; the account keys are
|
|
|
92
92
|
wrapped by one root key the platform holds. A stolen copy of an account's
|
|
93
93
|
secrets opens nothing without it.
|
|
94
94
|
|
|
95
|
+
The egress proxy can run without that root key
|
|
96
|
+
([`FOLDRUN_EGRESS_MINIMAL_BOOT`](environment)). It is then given only what it
|
|
97
|
+
uses, each derived from the root key for that one purpose: the public half
|
|
98
|
+
of the key the worker signs every step's lease with, the key of the
|
|
99
|
+
certificate authority it signs bound sites with, and the key that seals the
|
|
100
|
+
identity signing keys. A lease is sealed under the step's own token, which
|
|
101
|
+
the lease store never holds, so the proxy opens a step's credentials only
|
|
102
|
+
when that step presents its token — and a lease nobody but the worker could
|
|
103
|
+
have signed is refused.
|
|
104
|
+
|
|
95
105
|
Backups are encrypted before they leave the server. The nightly archive —
|
|
96
106
|
every workspace, run record and the database — and the server's key file
|
|
97
107
|
are encrypted with age to a public key whose private half is not on the
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "foldrun",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.1.1",
|
|
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": "^7.0.
|
|
14
|
+
"@foldrun/core": "^7.0.1"
|
|
15
15
|
},
|
|
16
16
|
"files": [
|
|
17
17
|
"bin",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
],
|
|
23
23
|
"scripts": {
|
|
24
24
|
"e2e": "FOLDRUN_E2E=1 FOLDRUN_DATA=$(mktemp -d /tmp/foldrun-e2e-XXXXXX) node --test --test-timeout=300000 tests/e2e.test.ts",
|
|
25
|
-
"test": "FOLDRUN_DATA=$(mktemp -d /tmp/foldrun-test-XXXXXX) node --test tests/cli-account.test.ts tests/model-credential.test.ts tests/cli-approvals.test.ts tests/cli-issues.test.ts tests/cli-capture.test.ts tests/cli-stop.test.ts tests/cli-account-settings.test.ts tests/cli-schedule.test.ts tests/cli-billing.test.ts tests/cli-storage.test.ts tests/cli-scaffold.test.ts tests/cli-secrets.test.ts tests/cli-site-login.test.ts tests/cli-check-library.test.ts tests/cli-check-timezone.test.ts tests/cli-check-frontmatter.test.ts tests/cli-agent-import.test.ts tests/cli-check-subagents.test.ts tests/cli-connect.test.ts tests/cli-accounts.test.ts tests/cli-remote.test.ts tests/cli-stream.test.ts tests/cli-doctor.test.ts tests/cli-tool-test.test.ts tests/cli-agent-run.test.ts tests/cli-check-remote.test.ts tests/cli-shares.test.ts tests/cli-triggers.test.ts tests/cli-providers.test.ts tests/cli-rerun-put.test.ts tests/cli-guide.test.ts tests/cli-runtimes.test.ts tests/cli-deploy-safety.test.ts tests/cli-operator.test.ts tests/cli-flow-patterns.test.ts tests/cli-flow-rm-step.test.ts tests/cli-flow-dup-step.test.ts tests/cli-flow-write-stale.test.ts tests/cli-agent-link-stale.test.ts tests/cli-agent-link-isolated.test.ts tests/cli-parity.test.ts tests/cli-invoke-inputs.test.ts tests/cli-audit-keys.test.ts tests/cli-version.test.ts tests/cli-check-web-warnings.test.ts tests/cli-report-image.test.ts tests/cli-report-cache.test.ts tests/cli-check-workspace-paths.test.ts tests/cli-parity-dashboard.test.ts tests/cli-api-standards.test.ts tests/cli-backups-onboarding.test.ts tests/cli-check-limits.test.ts tests/cli-gallery.test.ts tests/cli-status-platform.test.ts tests/cli-webhooks-notifications.test.ts tests/cli-flags.test.ts tests/cli-api-coverage.test.ts tests/cli-hooks.test.ts tests/cli-release.test.ts tests/cli-terminal.test.ts tests/cli-network.test.ts tests/cli-assistant.test.ts tests/cli-check-scan.test.ts tests/cli-published.test.ts tests/cli-init-target.test.ts tests/cli-flow-filter.test.ts tests/cli-eval-grades.test.ts tests/cli-eval-compare.test.ts tests/cli-proposals.test.ts tests/cli-inbox.test.ts tests/cli-usage-compute.test.ts",
|
|
25
|
+
"test": "FOLDRUN_DATA=$(mktemp -d /tmp/foldrun-test-XXXXXX) node --test tests/cli-account.test.ts tests/model-credential.test.ts tests/cli-approvals.test.ts tests/cli-issues.test.ts tests/cli-capture.test.ts tests/cli-stop.test.ts tests/cli-account-settings.test.ts tests/cli-schedule.test.ts tests/cli-billing.test.ts tests/cli-storage.test.ts tests/cli-scaffold.test.ts tests/cli-secrets.test.ts tests/cli-site-login.test.ts tests/cli-check-library.test.ts tests/cli-check-timezone.test.ts tests/cli-check-frontmatter.test.ts tests/cli-agent-import.test.ts tests/cli-check-subagents.test.ts tests/cli-connect.test.ts tests/cli-accounts.test.ts tests/cli-remote.test.ts tests/cli-stream.test.ts tests/cli-doctor.test.ts tests/cli-tool-test.test.ts tests/cli-agent-run.test.ts tests/cli-check-remote.test.ts tests/cli-shares.test.ts tests/cli-triggers.test.ts tests/cli-providers.test.ts tests/cli-rerun-put.test.ts tests/cli-guide.test.ts tests/cli-runtimes.test.ts tests/cli-deploy-safety.test.ts tests/cli-operator.test.ts tests/cli-flow-patterns.test.ts tests/cli-flow-rm-step.test.ts tests/cli-flow-dup-step.test.ts tests/cli-flow-write-stale.test.ts tests/cli-agent-link-stale.test.ts tests/cli-agent-link-isolated.test.ts tests/cli-parity.test.ts tests/cli-invoke-inputs.test.ts tests/cli-audit-keys.test.ts tests/cli-version.test.ts tests/cli-check-web-warnings.test.ts tests/cli-report-image.test.ts tests/cli-report-cache.test.ts tests/cli-check-workspace-paths.test.ts tests/cli-parity-dashboard.test.ts tests/cli-api-standards.test.ts tests/cli-backups-onboarding.test.ts tests/cli-check-limits.test.ts tests/cli-gallery.test.ts tests/cli-status-platform.test.ts tests/cli-webhooks-notifications.test.ts tests/cli-flags.test.ts tests/cli-api-coverage.test.ts tests/cli-hooks.test.ts tests/cli-release.test.ts tests/cli-terminal.test.ts tests/cli-network.test.ts tests/cli-assistant.test.ts tests/cli-check-scan.test.ts tests/cli-published.test.ts tests/cli-init-target.test.ts tests/cli-flow-filter.test.ts tests/cli-eval-grades.test.ts tests/cli-eval-compare.test.ts tests/cli-proposals.test.ts tests/cli-inbox.test.ts tests/cli-usage-compute.test.ts tests/cli-fol105.test.ts tests/cli-key-renew.test.ts tests/cli-wait-failed.test.ts",
|
|
26
26
|
"release": "node scripts/release.mjs",
|
|
27
27
|
"typecheck": "tsc -p tsconfig.json",
|
|
28
28
|
"docs:sync": "node scripts/sync-docs.mjs",
|
package/src/commands.mjs
CHANGED
|
@@ -711,7 +711,7 @@ async function platformLibrary(flags) {
|
|
|
711
711
|
if (!url) return { url: undefined, tools: new Set(), skills: new Set(), warning: null };
|
|
712
712
|
let token;
|
|
713
713
|
try {
|
|
714
|
-
token =
|
|
714
|
+
token = await renewedToken(url, { ...flags, quiet: true });
|
|
715
715
|
} catch {
|
|
716
716
|
return { url, tools: new Set(), skills: new Set(), warning: `${url} is the platform but this machine is not signed in — library tools there cannot be seen` };
|
|
717
717
|
}
|
|
@@ -1948,7 +1948,7 @@ async function runEvals(name, flags = {}) {
|
|
|
1948
1948
|
* read exactly like one refused on disk.
|
|
1949
1949
|
*/
|
|
1950
1950
|
async function deployOverHttp(url, workspace, files, flags, expectRemoved) {
|
|
1951
|
-
const token =
|
|
1951
|
+
const token = await renewedToken(url, flags);
|
|
1952
1952
|
const endpoint = `${url.replace(/\/+$/, "")}/api/workspaces/${encodeURIComponent(workspace)}/deploy`;
|
|
1953
1953
|
|
|
1954
1954
|
let res;
|
|
@@ -2511,6 +2511,81 @@ async function versionCmd(flags) {
|
|
|
2511
2511
|
return 0;
|
|
2512
2512
|
}
|
|
2513
2513
|
|
|
2514
|
+
/**
|
|
2515
|
+
* Renew this machine's `foldrun login` key before it ends (FOL-71). Such a
|
|
2516
|
+
* key lives 90 days; with under RENEW_DAYS left the CLI rotates it itself
|
|
2517
|
+
* (POST /api/keys/<own id>/rotate — a cli-login key may, whatever its role)
|
|
2518
|
+
* and stores the new one, so a machine in use never sees it end. Once per
|
|
2519
|
+
* command, only for a key `login` minted and stored here — never --token or
|
|
2520
|
+
* FOLDRUN_TOKEN, whose holder chose them — and it never fails the command
|
|
2521
|
+
* it rides on: any problem leaves the old key in place to try next time.
|
|
2522
|
+
* Costs a request only when the end is near or not yet known (/api/me, at
|
|
2523
|
+
* most daily for a key that does not renew, e.g. on an older platform).
|
|
2524
|
+
*/
|
|
2525
|
+
const RENEW_DAYS = 14;
|
|
2526
|
+
const DAY_MS = 86_400_000;
|
|
2527
|
+
let renewChecked = false;
|
|
2528
|
+
async function renewIfDue(url, flags) {
|
|
2529
|
+
if (renewChecked || flags.token || env("FOLDRUN_TOKEN")) return;
|
|
2530
|
+
renewChecked = true;
|
|
2531
|
+
try {
|
|
2532
|
+
const p = chosenProfile(flags);
|
|
2533
|
+
if (!p?.minted || !p.token) return;
|
|
2534
|
+
const now = Date.now();
|
|
2535
|
+
const ends = p.expiresAt ? Date.parse(p.expiresAt) : NaN;
|
|
2536
|
+
if (p.renews === true && ends - now > RENEW_DAYS * DAY_MS) return;
|
|
2537
|
+
if (p.renews === false && p.checkedAt && now - Date.parse(p.checkedAt) < DAY_MS) return;
|
|
2538
|
+
const { name, current: _c, url: at, loggedInAt: _l, ...entry } = p;
|
|
2539
|
+
const save = (fields) => saveCredential(at, { ...entry, ...fields }, { name, makeDefault: false });
|
|
2540
|
+
const meRes = await remoteFetch(at, "/api/me", {}, { token: p.token });
|
|
2541
|
+
if (!meRes.ok) return;
|
|
2542
|
+
const a = /** @type {any} */ (await meRes.json())?.actor ?? {};
|
|
2543
|
+
if (a.kind !== "key" || a.origin !== "cli-login") return void save({ renews: false, checkedAt: new Date(now).toISOString() });
|
|
2544
|
+
if (!a.expiresAt || Date.parse(a.expiresAt) - now > RENEW_DAYS * DAY_MS) return void save({ renews: true, expiresAt: a.expiresAt ?? null, checkedAt: undefined });
|
|
2545
|
+
// Rotate only what can be kept: the old key ends minutes after the
|
|
2546
|
+
// rotation lands, so a credentials file this CLI cannot write would lose
|
|
2547
|
+
// the new key and sign the machine out. Then the old one runs to its end.
|
|
2548
|
+
if (!credentialsWritable()) return;
|
|
2549
|
+
const res = await remoteFetch(at, `/api/keys/${enc(a.id)}/rotate`, { method: "POST", headers: { "content-type": "application/json" }, body: "{}" }, { token: p.token });
|
|
2550
|
+
if (!res.ok) return;
|
|
2551
|
+
const r = /** @type {any} */ (await res.json());
|
|
2552
|
+
if (typeof r.key !== "string") return;
|
|
2553
|
+
try {
|
|
2554
|
+
save({ token: r.key, renews: true, expiresAt: r.expiresAt ?? null, checkedAt: undefined });
|
|
2555
|
+
} catch (err) {
|
|
2556
|
+
// Not silent: the old key now ends within minutes. The next command
|
|
2557
|
+
// retries with it (the platform rotates the unused new one), and
|
|
2558
|
+
// `foldrun login` is the way back if that cannot be stored either.
|
|
2559
|
+
console.error(` ${c.amber("!")} renewed this machine's sign-in but could not store it (${err instanceof Error ? err.message : err}) — the next command tries again within 10 minutes; after that, \`foldrun login\``);
|
|
2560
|
+
return;
|
|
2561
|
+
}
|
|
2562
|
+
if (flags.quiet !== true) console.error(` ${c.dim(`renewed this machine's sign-in as "${name}"${r.expiresAt ? ` — it now lasts until ${String(r.expiresAt).slice(0, 10)}` : ""}`)}`);
|
|
2563
|
+
} catch {
|
|
2564
|
+
// Offline, an old platform, a read-only home: the old key still works.
|
|
2565
|
+
}
|
|
2566
|
+
}
|
|
2567
|
+
|
|
2568
|
+
/** Whether the credentials file can be written in place (or, not there yet,
|
|
2569
|
+
* made) — checked before a renewal, which cannot be undone. */
|
|
2570
|
+
function credentialsWritable() {
|
|
2571
|
+
const dir = credentialsDir();
|
|
2572
|
+
const file = path.join(dir, "credentials.json");
|
|
2573
|
+
try {
|
|
2574
|
+
fs.accessSync(fs.existsSync(file) ? file : dir, fs.constants.W_OK);
|
|
2575
|
+
return true;
|
|
2576
|
+
} catch {
|
|
2577
|
+
return false;
|
|
2578
|
+
}
|
|
2579
|
+
}
|
|
2580
|
+
|
|
2581
|
+
/** tokenFor, after the once-per-command renewal remoteCall does — for the
|
|
2582
|
+
* calls that fetch bytes, uploads or streams themselves (FOL-71). Without
|
|
2583
|
+
* it a machine that only ran those would never renew its sign-in. */
|
|
2584
|
+
async function renewedToken(url, flags) {
|
|
2585
|
+
await renewIfDue(url, flags);
|
|
2586
|
+
return tokenFor(url, flags);
|
|
2587
|
+
}
|
|
2588
|
+
|
|
2514
2589
|
/**
|
|
2515
2590
|
* A call to the platform's API, as JSON. A body that is not JSON is not the
|
|
2516
2591
|
* platform talking — a Cloudflare challenge, a proxy's error page, a tunnel
|
|
@@ -2521,7 +2596,7 @@ async function versionCmd(flags) {
|
|
|
2521
2596
|
* @returns {Promise<any>}
|
|
2522
2597
|
*/
|
|
2523
2598
|
async function remoteCall(url, flags, apiPath, init = {}, { seconds } = {}) {
|
|
2524
|
-
const token =
|
|
2599
|
+
const token = await renewedToken(url, flags);
|
|
2525
2600
|
const res = await remoteFetch(
|
|
2526
2601
|
url,
|
|
2527
2602
|
apiPath,
|
|
@@ -2643,7 +2718,7 @@ class StreamIdle extends Error {
|
|
|
2643
2718
|
* first, and throws StreamIdle when nothing arrives for streamIdleSeconds.
|
|
2644
2719
|
*/
|
|
2645
2720
|
async function streamOnce(url, flags, ws, runId, seen, open = new Map()) {
|
|
2646
|
-
const token =
|
|
2721
|
+
const token = await renewedToken(url, flags);
|
|
2647
2722
|
const idle = streamIdleSeconds();
|
|
2648
2723
|
const target = new URL(`/api/workspaces/${ws}/runs/${runId}/stream`, url);
|
|
2649
2724
|
const ctrl = new AbortController();
|
|
@@ -3516,13 +3591,14 @@ async function invoke(target, flags) {
|
|
|
3516
3591
|
// used to land here after 100 s while the run carried on was the trigger.
|
|
3517
3592
|
const WAIT_PIECE_S = 25;
|
|
3518
3593
|
const wait = flags.wait === true ? `?wait=true&timeout=${WAIT_PIECE_S}` : "";
|
|
3519
|
-
// A waited run that FAILS is
|
|
3520
|
-
//
|
|
3521
|
-
//
|
|
3522
|
-
//
|
|
3523
|
-
//
|
|
3594
|
+
// A waited run that FAILS is the answer to the call, not an error in it:
|
|
3595
|
+
// reported as a failed run, with why, never thrown as a transport fault —
|
|
3596
|
+
// the difference between "your flow failed" and "the platform is down".
|
|
3597
|
+
// A platform since FOL-106 answers it 200 with `status` and `failure`;
|
|
3598
|
+
// one before answered 500 with the same record, which is still read.
|
|
3524
3599
|
const reportFailedRun = (body, ws) => {
|
|
3525
3600
|
if (body?.result) console.log(`\n${body.result}\n`);
|
|
3601
|
+
if (body?.failure?.reason) console.log(` ${c.red("why")} ${c.dim(body.failure.agent ?? "?")} ${firstLine(body.failure.reason, 200)}`);
|
|
3526
3602
|
for (const st of body?.steps ?? []) {
|
|
3527
3603
|
const mark = st.status === "completed" ? c.green("✓") : st.status === "skipped" ? c.dim("–") : c.red("✗");
|
|
3528
3604
|
console.log(` ${mark} ${c.dim(st.agent ?? "?")} ${st.status}${st.skipReason ? c.dim(` (${st.skipReason})`) : ""}`);
|
|
@@ -3595,6 +3671,7 @@ async function invoke(target, flags) {
|
|
|
3595
3671
|
const run = body.run ?? body;
|
|
3596
3672
|
const status = run.status ?? body.status ?? "finished";
|
|
3597
3673
|
const ok = status === "completed";
|
|
3674
|
+
if (!ok && status !== "awaiting-approval" && body.runId && body.status) return reportFailedRun(body, ws);
|
|
3598
3675
|
if (body.result) console.log(`\n${body.result}\n`);
|
|
3599
3676
|
const mark = ok ? c.green("✓") : status === "awaiting-approval" ? c.amber("⏸") : c.red("✗");
|
|
3600
3677
|
console.log(` ${mark} ${status}${body.costUsd != null ? ` · $${Number(body.costUsd).toFixed(4)}` : ""}${status === "awaiting-approval" ? c.dim(` — ${url}/dashboard/${ws}/runs/${body.runId}`) : ""}\n`);
|
|
@@ -3668,7 +3745,7 @@ async function connect(positional, flags) {
|
|
|
3668
3745
|
// this machine's vault otherwise. Decided before the browser opens, so a
|
|
3669
3746
|
// consent is never spent on a store that then refuses it.
|
|
3670
3747
|
const url = flags.local === true ? undefined : remoteUrl(flags);
|
|
3671
|
-
const token = url ?
|
|
3748
|
+
const token = url ? await renewedToken(url, flags) : null;
|
|
3672
3749
|
const workspaceName = flags.to ?? (flags.workspace ? path.basename(path.resolve(flags.workspace)) : undefined);
|
|
3673
3750
|
|
|
3674
3751
|
// Reconnecting: the platform already holds the client this secret (or this
|
|
@@ -3919,7 +3996,7 @@ async function login(flags) {
|
|
|
3919
3996
|
// elsewhere; logout only forgets it.
|
|
3920
3997
|
const name = saveCredential(url, { token: poll.token, email: poll.email, account: poll.account, role: poll.role, minted: true }, { name: typeof flags.profile === "string" ? flags.profile : undefined });
|
|
3921
3998
|
console.log(`\n ${c.green("✓")} signed in to ${c.bold(url)} as ${poll.email} ${c.dim(`(${poll.account}, ${poll.role})`)}\n`);
|
|
3922
|
-
console.log(` ${c.dim(`Stored as the account "${name}" in
|
|
3999
|
+
console.log(` ${c.dim(`Stored as the account "${name}" in ${credentialsShown()}. \`foldrun accounts\` lists every account signed in here; \`foldrun use ${name}\` switches.`)}\n`);
|
|
3923
4000
|
return 0;
|
|
3924
4001
|
}
|
|
3925
4002
|
}
|
|
@@ -3975,7 +4052,7 @@ async function whoami(flags) {
|
|
|
3975
4052
|
console.log(` role ${me.role}`);
|
|
3976
4053
|
console.log(` workspaces ${me.workspaces === null ? "all" : me.workspaces.join(", ") || "none"}`);
|
|
3977
4054
|
const profile = flags.token || env("FOLDRUN_TOKEN") ? null : chosenProfile(flags);
|
|
3978
|
-
const source = flags.token ? "--token" : env("FOLDRUN_TOKEN") ? "FOLDRUN_TOKEN" :
|
|
4055
|
+
const source = flags.token ? "--token" : env("FOLDRUN_TOKEN") ? "FOLDRUN_TOKEN" : `${credentialsShown()} as "${profile?.name ?? "?"}"`;
|
|
3979
4056
|
console.log(` ${c.dim(`credential from ${source}`)}`);
|
|
3980
4057
|
const others = listProfiles().filter((p) => p.name !== profile?.name);
|
|
3981
4058
|
console.log(others.length ? ` ${c.dim(`also signed in as: ${others.map((p) => p.name).join(", ")} — \`foldrun accounts\``)}\n` : "\n");
|
|
@@ -4870,7 +4947,10 @@ async function pullCmd(layout, flags, only) {
|
|
|
4870
4947
|
const { isSourcePath, LIBRARY_KINDS } = await core();
|
|
4871
4948
|
const url = remoteUrl(flags);
|
|
4872
4949
|
if (!url) throw new Error("pull brings a platform's account down — pass --url, or `foldrun login` first");
|
|
4873
|
-
|
|
4950
|
+
// A bare folder (nothing of foldrun's yet) is the account root itself, as
|
|
4951
|
+
// in guideCmd — core reads it as a flat workspace whose account is the
|
|
4952
|
+
// PARENT, and pull would write workspaces/, AGENTS.md and CLAUDE.md there.
|
|
4953
|
+
const root = layout.kind === "empty" ? (layout.workspaceDir ?? process.cwd()) : layout.accountRoot;
|
|
4874
4954
|
const wsRoot = layout.workspacesDir ?? path.join(root, "workspaces");
|
|
4875
4955
|
|
|
4876
4956
|
const names = (await remoteWorkspaceNames(url, flags)).filter((n) => (only ? n === only : true));
|
|
@@ -4921,6 +5001,7 @@ async function pullCmd(layout, flags, only) {
|
|
|
4921
5001
|
`\n ${c.green("✓")} pulled ${names.length} workspace${names.length === 1 ? "" : "s"} from ${url} ` +
|
|
4922
5002
|
c.dim(`${written} file${written === 1 ? "" : "s"} written, ${incoming.length - written} already current`),
|
|
4923
5003
|
);
|
|
5004
|
+
console.log(` ${c.dim(`into ${root}`)}`);
|
|
4924
5005
|
const rules = writeAgentFiles(root);
|
|
4925
5006
|
for (const [file, what] of [["AGENTS.md", rules.agentsMd], ["CLAUDE.md", rules.claudeMd]]) {
|
|
4926
5007
|
if (what === "created" || what === "updated") console.log(` ${c.green("✓")} ${file} ${c.dim(`${what} — the coding-agent rules, pointing at \`foldrun docs\``)}`);
|
|
@@ -5212,7 +5293,7 @@ async function storageCmd(positional, flags, layout) {
|
|
|
5212
5293
|
if (jobs.length !== 1) throw new Error("--as names one file; for several use --into <folder/>");
|
|
5213
5294
|
jobs[0].rel = flags.as;
|
|
5214
5295
|
}
|
|
5215
|
-
const token =
|
|
5296
|
+
const token = await renewedToken(url, flags);
|
|
5216
5297
|
const base = `/api/workspaces/${encodeURIComponent(ws)}/storage`;
|
|
5217
5298
|
const said = async (res) => {
|
|
5218
5299
|
const text = await res.text();
|
|
@@ -5284,7 +5365,7 @@ async function storageCmd(positional, flags, layout) {
|
|
|
5284
5365
|
// streams the bytes on the fs driver, so this is a plain fetch that
|
|
5285
5366
|
// follows redirects — not remoteCall, which parses JSON and would make a
|
|
5286
5367
|
// markdown file look like a broken platform.
|
|
5287
|
-
const token =
|
|
5368
|
+
const token = await renewedToken(url, flags);
|
|
5288
5369
|
const res = await remoteFetch(url, `/api/workspaces/${ws}/storage/download?path=${encodeURIComponent(rel)}`, {}, { token });
|
|
5289
5370
|
if (!res.ok) {
|
|
5290
5371
|
const said = await res.text();
|
|
@@ -5667,8 +5748,32 @@ function printDefaults(d) {
|
|
|
5667
5748
|
/** network_enforce: as a person reads it. Off is never "allowed" outright:
|
|
5668
5749
|
* the level above (the account, or the install's own switch) may refuse
|
|
5669
5750
|
* anyway, and this file cannot see either, so off says what it leaves to. */
|
|
5670
|
-
function networkEnforceText(on, above) {
|
|
5671
|
-
|
|
5751
|
+
function networkEnforceText(on, above, aboveOn = false) {
|
|
5752
|
+
if (on) return `refused ${c.dim("— a site off an agent's network: list gets a 403")}`;
|
|
5753
|
+
// Either level's true is enough (core networkEnforceWanted), so the level
|
|
5754
|
+
// below cannot turn it off: say what a run here actually gets.
|
|
5755
|
+
if (aboveOn) return `refused ${c.dim(`— ${above} enforces it; this file does not ask, and cannot turn it off`)}`;
|
|
5756
|
+
return c.dim(`${above}'s — this file does not ask to refuse`);
|
|
5757
|
+
}
|
|
5758
|
+
|
|
5759
|
+
/** Whether the account's own AGENTS.md has network_enforce on — null when
|
|
5760
|
+
* this credential may not read the account (a workspace-scoped key). */
|
|
5761
|
+
async function accountEnforces(url, flags) {
|
|
5762
|
+
try {
|
|
5763
|
+
const { defaults } = await remoteCall(url, flags, "/api/account");
|
|
5764
|
+
return defaults?.networkEnforce === true;
|
|
5765
|
+
} catch (err) {
|
|
5766
|
+
if (err instanceof HttpError && (err.status === 403 || err.status === 404)) return null;
|
|
5767
|
+
throw err;
|
|
5768
|
+
}
|
|
5769
|
+
}
|
|
5770
|
+
|
|
5771
|
+
/** Where this machine keeps its keys, written the way a person would type it.
|
|
5772
|
+
* FOLDRUN_HOME moves the folder, so the path is read, never assumed. */
|
|
5773
|
+
function credentialsShown() {
|
|
5774
|
+
const file = path.join(credentialsDir(), "credentials.json");
|
|
5775
|
+
const home = os.homedir();
|
|
5776
|
+
return file.startsWith(home + path.sep) ? `~${file.slice(home.length)}` : file;
|
|
5672
5777
|
}
|
|
5673
5778
|
|
|
5674
5779
|
/** `on`/`off` (or true/false, yes/no) for network_enforce, or an error. */
|
|
@@ -6926,7 +7031,15 @@ export function podTries(step) {
|
|
|
6926
7031
|
}
|
|
6927
7032
|
|
|
6928
7033
|
/** Whichever error this step recorded — on the step, or on its last try. */
|
|
6929
|
-
|
|
7034
|
+
// A step refused before its agent started (no model key, a login token)
|
|
7035
|
+
// records only an error event — no `error`, no tries — so a failed step
|
|
7036
|
+
// falls back to its last error event: the reason was in the record all
|
|
7037
|
+
// along, and `report` and `agent run --wait` printed nothing about it (FOL-106).
|
|
7038
|
+
const stepError = (step) =>
|
|
7039
|
+
step.error ??
|
|
7040
|
+
[...(step.tries ?? [])].reverse().find((t) => t.error)?.error ??
|
|
7041
|
+
(step.status === "failed" ? [...(step.events ?? [])].reverse().find((e) => e.type === "error")?.text : null) ??
|
|
7042
|
+
null;
|
|
6930
7043
|
|
|
6931
7044
|
/**
|
|
6932
7045
|
* `foldrun report <run-id>` — one run, whole, readable without a browser.
|
|
@@ -7165,6 +7278,7 @@ async function reportCmd(runId, flags, layout) {
|
|
|
7165
7278
|
if (err) {
|
|
7166
7279
|
console.log(` ${c.red(firstLine(err, 96))}`);
|
|
7167
7280
|
for (const e of (step.events ?? []).slice(-4)) {
|
|
7281
|
+
if (e.text === err) continue; // already the red line above
|
|
7168
7282
|
console.log(` ${EVENT_MARK(e)} ${c.dim(firstLine(e.text, 92))}`);
|
|
7169
7283
|
}
|
|
7170
7284
|
}
|
|
@@ -7320,9 +7434,10 @@ async function agentRunCmd(positional, flags, layout) {
|
|
|
7320
7434
|
const wait = flags.wait === true ? `?wait=true&timeout=${WAIT_PIECE_S}` : "";
|
|
7321
7435
|
const base = `/api/workspaces/${encodeURIComponent(ws)}/agents/${encodeURIComponent(name)}`;
|
|
7322
7436
|
|
|
7323
|
-
// A waited run that FAILS is
|
|
7324
|
-
//
|
|
7325
|
-
//
|
|
7437
|
+
// A waited run that FAILS is the answer to the question, not a fault in
|
|
7438
|
+
// the call: 200 with its status since FOL-106, 500 with the same record
|
|
7439
|
+
// from a platform before. Either way the run id is taken off it and the
|
|
7440
|
+
// report is printed like any other.
|
|
7326
7441
|
const waited = async (fn) => {
|
|
7327
7442
|
try {
|
|
7328
7443
|
return await fn();
|
|
@@ -9374,7 +9489,7 @@ async function apiCmd(positional, flags) {
|
|
|
9374
9489
|
|
|
9375
9490
|
/** A GET whose answer is a file, not JSON — the error body still is. */
|
|
9376
9491
|
async function remoteBytes(url, flags, apiPath, what) {
|
|
9377
|
-
const token =
|
|
9492
|
+
const token = await renewedToken(url, flags);
|
|
9378
9493
|
const res = await remoteFetch(url, apiPath, {}, { token, seconds: timeoutSeconds(flags) });
|
|
9379
9494
|
if (!res.ok) {
|
|
9380
9495
|
const said = await res.text();
|
|
@@ -9426,7 +9541,7 @@ async function importCmd(positional, flags, layout) {
|
|
|
9426
9541
|
const url = platformFor(flags, "import");
|
|
9427
9542
|
const ws = platformWorkspace(flags, layout, "import");
|
|
9428
9543
|
const bytes = fs.readFileSync(file);
|
|
9429
|
-
const token =
|
|
9544
|
+
const token = await renewedToken(url, flags);
|
|
9430
9545
|
const send = async (query) => {
|
|
9431
9546
|
const res = await remoteFetch(
|
|
9432
9547
|
url,
|
|
@@ -9914,11 +10029,14 @@ async function workspaceCmd(positional, flags, layout) {
|
|
|
9914
10029
|
console.log(` notify ${notify}`);
|
|
9915
10030
|
console.log(` budget ${budget}`);
|
|
9916
10031
|
console.log(` compute ${computeText(d.compute, c.dim("no cap of its own — the account's"))}`);
|
|
9917
|
-
if (d.networkEnforce !== undefined) console.log(` network ${networkEnforceText(d.networkEnforce, "the account")}`);
|
|
10032
|
+
if (d.networkEnforce !== undefined) console.log(` network ${networkEnforceText(d.networkEnforce, "the account", aboveOn === true)}`);
|
|
9918
10033
|
};
|
|
10034
|
+
/** @type {boolean | null} */
|
|
10035
|
+
let aboveOn = null;
|
|
9919
10036
|
|
|
9920
10037
|
if (!verb) {
|
|
9921
10038
|
const d = await workspaceDefaults(url, flags, ws);
|
|
10039
|
+
aboveOn = await accountEnforces(url, flags);
|
|
9922
10040
|
show({ description: typeof d.description === "string" ? d.description : "", timezone: d.timezone ?? null, budget: d.budget ?? null, notify: d.notify ?? null, networkEnforce: d.network_enforce === true, compute: computeOfFile(d.compute) }, ws);
|
|
9923
10041
|
const halt = await pauseState(remoteCall(url, flags, `/api/workspaces/${enc(ws)}/pause`));
|
|
9924
10042
|
if (halt) console.log(` paused ${halt.paused ? c.red(`${halt.paused.scope === "account" ? "by the account: " : ""}${pauseLine(halt.paused)}`) : c.dim("no")}`);
|
|
@@ -9968,8 +10086,13 @@ async function workspaceCmd(positional, flags, layout) {
|
|
|
9968
10086
|
}
|
|
9969
10087
|
}
|
|
9970
10088
|
const r = await remoteCall(url, flags, `/api/workspaces/${enc(ws)}`, { method: "PATCH", body: JSON.stringify(patch) });
|
|
10089
|
+
const turnedOff = key === "network_enforce" && patch.network_enforce !== true;
|
|
10090
|
+
if (turnedOff) aboveOn = await accountEnforces(url, flags);
|
|
9971
10091
|
if (r.defaults) show(r.defaults, r.name ?? ws);
|
|
9972
10092
|
console.log(`\n ${c.green("✓")} ${r.renamed ? `renamed to ${r.name}` : verb === "clear" ? `${key} cleared` : `${key} set`} ${c.dim(`on ${r.name ?? ws}`)}`);
|
|
10093
|
+
// FOL-105: "off" here only drops this file's own true — the account's on
|
|
10094
|
+
// still refuses, and a ✓ alone read as if runs here were now allowed.
|
|
10095
|
+
if (turnedOff && aboveOn) console.log(` ${c.amber("!")} still refused here: the account enforces network_enforce — \`foldrun account set network_enforce off\` turns it off for every workspace`);
|
|
9973
10096
|
if (r.brokeWebhooks?.length) console.log(` ${c.amber("!")} webhook URLs changed for ${r.brokeWebhooks.join(", ")} — copy the new ones from each flow`);
|
|
9974
10097
|
console.log();
|
|
9975
10098
|
return 0;
|
|
@@ -11774,7 +11897,7 @@ async function reportLiveCmd(runId, flags, layout) {
|
|
|
11774
11897
|
console.log(`\n ${c.dim(`foldrun report ${runId} live --agent <name> saves its newest frame`)}\n`);
|
|
11775
11898
|
return 0;
|
|
11776
11899
|
}
|
|
11777
|
-
const res = await remoteFetch(url, `${base}?agent=${enc(agent)}`, {}, { token:
|
|
11900
|
+
const res = await remoteFetch(url, `${base}?agent=${enc(agent)}`, {}, { token: await renewedToken(url, flags), seconds: timeoutSeconds(flags) });
|
|
11778
11901
|
if (res.status === 204) {
|
|
11779
11902
|
console.log(`\n ${c.dim(`${agent} has no frame — its browser has not shown anything yet`)}\n`);
|
|
11780
11903
|
return 0;
|