foldrun 26.8.0 → 26.9.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/docs/cli.md CHANGED
@@ -136,7 +136,7 @@ claude.ai or Claude Code there, nor any MCP configuration on disk.
136
136
  | `foldrun export [workspace]` | a deployed project as a `.zip` — agents, flows, tools, skills, scripts, evals, knowledge; never memory, state, storage or a secret's value. `--flow <name>` exports that flow with every flow and agent it runs and the tools, skills and scripts they grant; `--agent <name>` that agent and what it grants. Written under the name the platform gives it (`<ws>.zip`, `<ws>-flow-<name>.zip`); `--file <path>` (`-` for stdout), `--force` to replace (`GET …/export`) |
137
137
  | `foldrun import <file.zip>` | take a package in: first shows what it adds, what is identical, what it would replace and what it still needs (secrets, tools, skills, scripts, agents, flows), then asks. Never deletes; replacing a file needs `--overwrite`. `--to <workspace>` (a name that does not exist makes it, from a project package), `--dry-run` previews only (`--json` for the plan), `--yes` with no terminal (`POST …/import`) |
138
138
  | `foldrun snapshot push [dir]` | send a folder for an agent on foldrun to work on (a snapshot). What goes is what git would commit — tracked files and untracked ones `.gitignore` does not exclude, as they are on disk; links and submodules are left out and named. A secret in any file stops it before anything leaves the machine (remove it, or leave the file out with `.gitignore`); the platform checks again. Answers the snapshot id, kept 7 days from the last send and while a run uses it. `--to <workspace>`, `--dry-run` packs and checks only, `--out <file.tar.gz>` keeps the archive (`--force` over a file that is there), `--json` (`POST …/snapshots`) |
139
- | `foldrun code [dir]` | code with an agent that works in a sandbox on the platform, not on this computer — see [Coding in a sandbox](#coding-in-a-sandbox). Each message sends the folder as a snapshot (as `snapshot push` does), runs the agent on it in its own sandbox as a turn of one conversation, prints what it does as it does it (its tool calls and words, and any refusal or failure; the platform's other notes on the step stay on the run page, `--verbose` shows them too), and offers the patch it hands back: `git apply --check`, git's stat, a yes, then `git apply`. Ctrl-C stops the run; `/new` starts a fresh conversation, `/quit` leaves. `--to <workspace>` (a project that does not exist is made, blank with its `coder` agent, after a yes), `--agent <name>` (default `coder`, added to the project on first use after a yes), `--task "…"` one turn and exit (for scripts), `--yes` applies without asking (required with no terminal), `--test`, `--context <id>`, `--verbose` |
139
+ | `foldrun code [dir]` | code with an agent that works in a sandbox on the platform, not on this computer — see [Coding in a sandbox](#coding-in-a-sandbox). Each message sends the folder as a snapshot (as `snapshot push` does), runs the agent on it in its own sandbox as a turn of one conversation, prints what it does as it does it (its tool calls and words, and any refusal or failure; the platform's other notes on the step stay on the run page, `--verbose` shows them too), and offers the patch it hands back: `git apply --check`, git's stat, a yes, then `git apply`. Ctrl-C stops the run; a dropped connection is followed again, not the end of the turn. After each turn a session line gives the turns so far, the spend, the model, how many tokens the agent read last turn, the time and the conversation id; `/status` prints it, `/new` starts a fresh conversation (and count), `/quit` leaves. `--to <workspace>` (a project that does not exist is made, blank with its `coder` agent, after a yes), `--agent <name>` (default `coder`, added to the project on first use after a yes), `--task "…"` one turn and exit (for scripts), `--yes` applies without asking (required with no terminal), `--test`, `--context <id>`, `--verbose` |
140
140
  | `foldrun status [workspace]` | per workspace: what is added, changed and only-on-the-platform, plus which files moved there since your last deploy from here. Reads only |
141
141
  | `foldrun status --platform` | is the platform up: overall, each component (dashboard and API, run workers, scheduler, model providers, email, storage) and any incident or maintenance the operator posted, with its latest update. Reads the open `/api/status` — no key needed; the signed-in platform, `--url` / `FOLDRUN_URL`, or the default, dash.foldrun.io. `--json` prints the answer as is. Exits 1, saying *status unavailable — the platform may be down*, when it does not answer. Plain `foldrun status` opens with the same one-line verdict |
142
142
  | `foldrun status --platform --history` | what the status page draws as bars: each component's uptime over the window and a mark per day — up, degraded or maintenance, an outage, or no samples — then the incidents and maintenance in it, from the open `GET /api/status/history?days=<n>`. `--days 1-90` (default 90), `--json` |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "foldrun",
3
- "version": "26.8.0",
3
+ "version": "26.9.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",
package/src/commands.mjs CHANGED
@@ -2767,7 +2767,10 @@ export function printNew(run, seen, open = new Map(), { skipResult = false, quie
2767
2767
  const release = (by) => {
2768
2768
  for (const [j, h] of held) {
2769
2769
  if (by?.t && h.t && String(by.t) < String(h.t)) continue;
2770
- console.log(eventLine(h, run.steps[j]?.agent, open));
2770
+ // The result came in this frame and holds it: it is printed with the
2771
+ // result, once (Codex).
2772
+ const result = run.steps[j]?.result;
2773
+ if (!(result && String(result).includes(String(h.text).trim()))) console.log(eventLine(h, run.steps[j]?.agent, open));
2771
2774
  held.delete(j);
2772
2775
  }
2773
2776
  };
@@ -2785,14 +2788,19 @@ export function printNew(run, seen, open = new Map(), { skipResult = false, quie
2785
2788
  const note = e.type === "info";
2786
2789
  if (note && quiet && !REFUSED_NOTE.test(String(e.text ?? ""))) continue;
2787
2790
  if (step === replying && e.type === "text") {
2788
- if (step.result && String(e.text).trim() === String(step.result).trim()) continue;
2791
+ // The result holds all the step's words: text already inside it is
2792
+ // printed with it, once (Codex).
2793
+ if (step.result && String(step.result).includes(String(e.text).trim())) continue;
2789
2794
  release();
2790
2795
  held.set(i, { ...e, __agent: step.agent });
2791
2796
  continue;
2792
2797
  }
2793
2798
  // Anything else that is not a note — a tool call, an error, any other
2794
2799
  // step's words (a sub-agent's) — came after the held text: it shows first.
2795
- if (!note) release(e);
2800
+ // An error in the replying step itself prints without releasing its
2801
+ // held text: a refusal after the agent's last words would otherwise
2802
+ // print the reply as a line, then again in full (seen 19 Nov 2026).
2803
+ if (!note && !(step === replying && e.type === "error")) release(e);
2796
2804
  const line = eventLine(e, step.agent, open);
2797
2805
  if (line !== null) console.log(line);
2798
2806
  }
@@ -2800,7 +2808,11 @@ export function printNew(run, seen, open = new Map(), { skipResult = false, quie
2800
2808
 
2801
2809
  /** An info note that something was refused or went wrong (a `limits:`
2802
2810
  * refusal, "browser pod: reconnect failed …"): shown even in the quiet view. */
2803
- const REFUSED_NOTE = /\b(refused|denied|blocked|failed|failure|error|lost|timed out)\b/i;
2811
+ // "(WebSearch refused)" is how a refused call ends; the setup note
2812
+ // "limits: … a call past one is refused" is not one (seen on 26.8.0).
2813
+ // Core's other refusals: "refused path: …" (copy-back) and "the model
2814
+ // credential was refused mid-step" (Codex).
2815
+ const REFUSED_NOTE = /\(\S+ refused\)|^refused path:|\bwas refused\b|\b(denied|blocked|failed|failure|error|lost|timed out)\b/i;
2804
2816
 
2805
2817
  /** Whatever text is still held is printed: the turn is ending another way
2806
2818
  * (an error, a second Ctrl-C), so no reply follows it (Codex). */
@@ -2827,7 +2839,10 @@ export function dropHeldReply(run, seen, open) {
2827
2839
  const own = (run.steps ?? []).filter((x) => !x.subagentOf);
2828
2840
  const reply = String(own.at(-1)?.result ?? "").trim();
2829
2841
  for (const [i, e] of held) {
2830
- if (String(e.text).trim() !== reply) console.log(eventLine(e, run.steps[i]?.agent, open));
2842
+ // The result holds the step's words, so a held text inside it is
2843
+ // printed with it, not on its own as well.
2844
+ const text = String(e.text).trim();
2845
+ if (!(reply && reply.includes(text))) console.log(eventLine(e, run.steps[i]?.agent, open));
2831
2846
  }
2832
2847
  held.clear();
2833
2848
  }
@@ -2983,8 +2998,22 @@ async function followRemote(url, flags, ws, runId, seen = new Map(), open = new
2983
2998
  if (!(holdOpen && run && isLive(run))) flushCalls(open);
2984
2999
  return run;
2985
3000
  } catch (err) {
2986
- if (!(err instanceof StreamIdle)) throw err;
2987
- const run = await remoteCall(url, flags, `/api/workspaces/${ws}/runs/${runId}`);
3001
+ // A dropped connection (a laptop's network blinking: "terminated:
3002
+ // read ETIMEDOUT", 19 Nov 2026) is not the run ending: read the run
3003
+ // and follow it again, as when the stream goes quiet.
3004
+ if (!(err instanceof StreamIdle) && !droppedConnection(err)) throw err;
3005
+ // The read has its own three tries, apart from the stream's (Codex).
3006
+ let run;
3007
+ for (let read = 1; ; read++) {
3008
+ try {
3009
+ run = await remoteCall(url, flags, `/api/workspaces/${enc(ws)}/runs/${enc(runId)}`);
3010
+ break;
3011
+ } catch (readErr) {
3012
+ if (!droppedConnection(readErr) || read >= 3) throw readErr;
3013
+ console.error(` ${c.dim(`… ${plainText(String(readErr?.message ?? readErr))}; reading the run again (${read}/3)`)}`);
3014
+ await new Promise((r) => setTimeout(r, 1000 * read));
3015
+ }
3016
+ }
2988
3017
  printNew(run, seen, open, { skipResult, quiet });
2989
3018
  if (!isLive(run)) {
2990
3019
  flushCalls(open);
@@ -3000,6 +3029,18 @@ async function followRemote(url, flags, ws, runId, seen = new Map(), open = new
3000
3029
  }
3001
3030
  }
3002
3031
 
3032
+ /**
3033
+ * A network failure the run itself does not share: the socket dropped,
3034
+ * timed out or could not connect. Never an abort (Ctrl-C) or an HTTP answer.
3035
+ * @param {any} err
3036
+ */
3037
+ export function droppedConnection(err) {
3038
+ if (!err || err.name === "AbortError" || err instanceof StreamIdle) return false;
3039
+ if (typeof err.status === "number") return false;
3040
+ const text = [err.message, err.code, err.cause?.code, err.cause?.message].filter(Boolean).join(" ");
3041
+ return /\bterminated\b|ETIMEDOUT|ECONNRESET|ECONNREFUSED|EPIPE|EAI_AGAIN|ENETUNREACH|EHOSTUNREACH|ENETDOWN|UND_ERR_(SOCKET|CONNECT_TIMEOUT|HEADERS_TIMEOUT|BODY_TIMEOUT)|fetch failed|socket hang up|other side closed|could not reach|did not answer .* within/i.test(text);
3042
+ }
3043
+
3003
3044
  /**
3004
3045
  * `foldrun open [page]` — the dashboard, from the terminal: this
3005
3046
  * workspace's overview, or one of its pages (runs, agents, flows, graph,
@@ -13000,6 +13041,8 @@ async function codeTurn(s, task) {
13000
13041
  if (reply) console.log(`\n${plainText(String(reply)).trim().split("\n").map((l) => ` ${l}`).join("\n")}`);
13001
13042
  const cost = (run.steps ?? []).reduce((sum, x) => sum + (x.costUsd ?? 0), 0);
13002
13043
  console.log(`\n ${run.status === "completed" ? c.green("✓") : c.red("✗")} ${plainText(run.status)} ${c.dim(`· $${cost.toFixed(4)} · ${plainText(runId)}`)}`);
13044
+ noteSessionTurn(s, run, cost);
13045
+ console.log(` ${c.dim(sessionLine(s))}`);
13003
13046
  if (cancel.asked) {
13004
13047
  console.log(` ${c.dim(`stopped by you — nothing applied. What it made, if anything: foldrun report ${runId} patch --to ${ws}`)}\n`);
13005
13048
  return "cancelled";
@@ -13082,7 +13125,7 @@ async function codeCmd(positional, flags, layout) {
13082
13125
  const { createInterface } = await import("node:readline/promises");
13083
13126
  console.log(`\n ${c.bold("foldrun code")} ${c.dim(`· ${agent} · ${ws} on ${url}`)}`);
13084
13127
  console.log(` ${c.dim(`${dir} — each message sends it to a sandbox; you apply what comes back`)}`);
13085
- console.log(` ${c.dim("/new a fresh conversation /quit leave")}\n`);
13128
+ console.log(` ${c.dim("/new a fresh conversation /status this session /quit leave")}\n`);
13086
13129
  for (;;) {
13087
13130
  const rl = createInterface({ input: process.stdin, output: process.stdout });
13088
13131
  // Closing the input (Ctrl-D) leaves question() unsettled on Node 26 —
@@ -13098,13 +13141,19 @@ async function codeCmd(positional, flags, layout) {
13098
13141
  console.log();
13099
13142
  return 0;
13100
13143
  }
13144
+ if (line === "/status") {
13145
+ console.log(` ${c.dim(`${sessionLine(s)} · ${agent} · ${ws} on ${url}`)}\n`);
13146
+ continue;
13147
+ }
13101
13148
  if (line === "/new") {
13102
13149
  s.context = newContext();
13150
+ // Nothing of the old conversation stays in the count (Codex).
13151
+ for (const k of ["turns", "costUsd", "model", "contextTokens", "secs"]) delete s[k];
13103
13152
  console.log(` ${c.dim("a fresh conversation — the agent no longer reads the earlier turns")}\n`);
13104
13153
  continue;
13105
13154
  }
13106
13155
  if (line.startsWith("/")) {
13107
- console.log(` ${c.dim("/new a fresh conversation /quit leave")}\n`);
13156
+ console.log(` ${c.dim("/new a fresh conversation /status this session /quit leave")}\n`);
13108
13157
  continue;
13109
13158
  }
13110
13159
  try {
@@ -13115,6 +13164,42 @@ async function codeCmd(positional, flags, layout) {
13115
13164
  }
13116
13165
  }
13117
13166
 
13167
+ /**
13168
+ * What a foldrun code session has done so far, like Claude Code's status
13169
+ * line (owner, 19 Nov 2026): turns, spend, the model, how much the agent
13170
+ * read last turn (its context), how long it took. `/new` starts the count
13171
+ * again; `/status` prints it.
13172
+ * @param {{ turns?: number, costUsd?: number, model?: string, contextTokens?: number, secs?: number }} s
13173
+ * @param {any} run
13174
+ * @param {number} cost
13175
+ */
13176
+ export function noteSessionTurn(s, run, cost) {
13177
+ s.turns = (s.turns ?? 0) + 1;
13178
+ s.costUsd = (s.costUsd ?? 0) + (Number.isFinite(cost) ? cost : 0);
13179
+ const step = (run.steps ?? []).filter((x) => !x.subagentOf).at(-1);
13180
+ const started = (step?.events ?? []).find((e) => e.type === "info" && /^step started \(/.test(String(e.text)));
13181
+ const model = started && /model: ([^\s,)]+)/.exec(String(started.text))?.[1];
13182
+ if (model) s.model = model;
13183
+ const t = step?.tokens;
13184
+ s.contextTokens = t ? Number(t.input ?? 0) : undefined;
13185
+ const a = Date.parse(run.startedAt ?? "");
13186
+ const b = Date.parse(run.finishedAt ?? "");
13187
+ s.secs = Number.isFinite(a) && Number.isFinite(b) ? (b - a) / 1000 : undefined;
13188
+ }
13189
+
13190
+ /** @param {{ turns?: number, costUsd?: number, model?: string, contextTokens?: number, secs?: number, context?: string }} s */
13191
+ export function sessionLine(s) {
13192
+ const k = (/** @type {number} */ n) => (n >= 1000 ? `${Math.round(n / 1000)}k` : String(n));
13193
+ return [
13194
+ `session: ${s.turns ?? 0} turn${s.turns === 1 ? "" : "s"}`,
13195
+ `$${(s.costUsd ?? 0).toFixed(4)} in all`,
13196
+ s.model ? plainText(s.model) : null,
13197
+ s.contextTokens !== undefined ? `last turn read ${k(s.contextTokens)} tokens` : null,
13198
+ s.secs !== undefined ? `${s.secs.toFixed(1)}s` : null,
13199
+ s.context ? `conversation ${plainText(s.context)}` : null,
13200
+ ].filter(Boolean).join(" · ");
13201
+ }
13202
+
13118
13203
  /**
13119
13204
  * `foldrun report <run-id> get <agent>/<path>` — one file a run archived:
13120
13205
  * whatever an agent left in outputs/, copied under the run when it ended.