@firefunc-agent/runner 0.9.7 → 0.9.34

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.
Files changed (178) hide show
  1. package/README.md +169 -10
  2. package/dist/activity.d.ts +1 -0
  3. package/dist/activity.js +1 -1
  4. package/dist/alive.d.ts +40 -0
  5. package/dist/alive.js +138 -0
  6. package/dist/api-fallback.d.ts +11 -0
  7. package/dist/api-fallback.js +80 -0
  8. package/dist/api.d.ts +186 -3
  9. package/dist/api.js +311 -6
  10. package/dist/ask/index.d.ts +20 -0
  11. package/dist/ask/index.js +64 -0
  12. package/dist/ask-first.d.ts +8 -0
  13. package/dist/brief-file.d.ts +15 -0
  14. package/dist/brief-file.js +36 -0
  15. package/dist/brief.d.ts +5 -0
  16. package/dist/brief.js +19 -3
  17. package/dist/build-caches.d.ts +7 -0
  18. package/dist/build-caches.js +63 -0
  19. package/dist/build-info.json +2 -2
  20. package/dist/checkpoint.d.ts +40 -0
  21. package/dist/checkpoint.js +98 -0
  22. package/dist/cli.js +184 -18
  23. package/dist/cloud-boot.d.ts +41 -0
  24. package/dist/cloud-boot.js +239 -0
  25. package/dist/command-activity.d.ts +23 -0
  26. package/dist/command-activity.js +89 -0
  27. package/dist/command-step.d.ts +58 -0
  28. package/dist/command-step.js +248 -0
  29. package/dist/config.d.ts +40 -0
  30. package/dist/config.js +23 -0
  31. package/dist/cut.d.ts +2 -1
  32. package/dist/cut.js +19 -5
  33. package/dist/daemon.js +375 -14
  34. package/dist/device-lease.d.ts +15 -0
  35. package/dist/device-lease.js +608 -0
  36. package/dist/editor/fs-server.d.ts +31 -0
  37. package/dist/editor/fs-server.js +159 -0
  38. package/dist/editor/relay-crypto.d.ts +68 -0
  39. package/dist/editor/relay-crypto.js +191 -0
  40. package/dist/editor/sessions.d.ts +50 -0
  41. package/dist/editor/sessions.js +279 -0
  42. package/dist/editor/worktree-of.d.ts +1 -0
  43. package/dist/editor/worktree-of.js +23 -0
  44. package/dist/editor/ws-client.d.ts +26 -0
  45. package/dist/editor/ws-client.js +227 -0
  46. package/dist/engine-account.d.ts +24 -0
  47. package/dist/engine-account.js +118 -0
  48. package/dist/engine-login.d.ts +12 -0
  49. package/dist/engine-login.js +88 -0
  50. package/dist/engine-models.d.ts +13 -0
  51. package/dist/engine-models.js +71 -0
  52. package/dist/engine-watch.d.ts +1 -0
  53. package/dist/engine-watch.js +22 -6
  54. package/dist/engines/antigravity.js +19 -4
  55. package/dist/engines/claude.js +15 -8
  56. package/dist/engines/codex.js +16 -2
  57. package/dist/engines/copilot.js +12 -0
  58. package/dist/engines/crush.d.ts +2 -0
  59. package/dist/engines/crush.js +58 -0
  60. package/dist/engines/cursor.js +12 -0
  61. package/dist/engines/gemini.js +14 -9
  62. package/dist/engines/index.d.ts +8 -0
  63. package/dist/engines/index.js +73 -1
  64. package/dist/engines/kilo.d.ts +2 -0
  65. package/dist/engines/kilo.js +63 -0
  66. package/dist/engines/opencode.d.ts +9 -0
  67. package/dist/engines/opencode.js +234 -0
  68. package/dist/engines/openhands.d.ts +10 -0
  69. package/dist/engines/openhands.js +271 -0
  70. package/dist/engines/pi.d.ts +10 -0
  71. package/dist/engines/pi.js +248 -0
  72. package/dist/engines/qwen.d.ts +8 -0
  73. package/dist/engines/qwen.js +153 -0
  74. package/dist/engines/sessions.d.ts +6 -0
  75. package/dist/engines/sessions.js +68 -0
  76. package/dist/engines/types.d.ts +3 -3
  77. package/dist/exec.d.ts +1 -0
  78. package/dist/exec.js +10 -4
  79. package/dist/firefunc/agents.d.ts +8 -1
  80. package/dist/firefunc/agents.js +53 -3
  81. package/dist/firefunc/auth.js +72 -19
  82. package/dist/firefunc/cli.js +25 -0
  83. package/dist/firefunc/client.d.ts +5 -1
  84. package/dist/firefunc/client.js +12 -2
  85. package/dist/firefunc/config.d.ts +11 -1
  86. package/dist/firefunc/config.js +6 -4
  87. package/dist/firefunc/io.d.ts +1 -0
  88. package/dist/firefunc/main.js +8 -1
  89. package/dist/firefunc/oauth-login.d.ts +23 -0
  90. package/dist/firefunc/oauth-login.js +304 -0
  91. package/dist/firefunc/tasks.d.ts +4 -0
  92. package/dist/firefunc/tasks.js +89 -2
  93. package/dist/fleet-words.d.ts +2 -0
  94. package/dist/fleet-words.js +7 -0
  95. package/dist/git-auth.d.ts +16 -0
  96. package/dist/git-auth.js +48 -2
  97. package/dist/held.d.ts +3 -0
  98. package/dist/job.d.ts +26 -3
  99. package/dist/job.js +1109 -132
  100. package/dist/keep-awake.d.ts +17 -0
  101. package/dist/keep-awake.js +90 -0
  102. package/dist/keep-local.d.ts +2 -1
  103. package/dist/keep-local.js +8 -3
  104. package/dist/limit.d.ts +10 -1
  105. package/dist/limit.js +264 -4
  106. package/dist/local-checks.d.ts +19 -0
  107. package/dist/local-checks.js +79 -0
  108. package/dist/locks.d.ts +21 -1
  109. package/dist/locks.js +279 -66
  110. package/dist/machine-commands.d.ts +21 -0
  111. package/dist/machine-commands.js +107 -0
  112. package/dist/machine-profile.d.ts +18 -0
  113. package/dist/machine-profile.js +69 -0
  114. package/dist/mcp-init.d.ts +2 -0
  115. package/dist/mcp-init.js +28 -0
  116. package/dist/mcp.d.ts +13 -1
  117. package/dist/mcp.js +23 -2
  118. package/dist/network.js +3 -2
  119. package/dist/orphans.d.ts +4 -0
  120. package/dist/orphans.js +96 -4
  121. package/dist/plan-phase/index.d.ts +11 -0
  122. package/dist/plan-phase/index.js +46 -0
  123. package/dist/pool.d.ts +1 -0
  124. package/dist/pool.js +29 -4
  125. package/dist/pr-title.d.ts +15 -0
  126. package/dist/pr-title.js +33 -0
  127. package/dist/recover.d.ts +3 -1
  128. package/dist/recover.js +27 -7
  129. package/dist/reference-files.d.ts +27 -0
  130. package/dist/reference-files.js +202 -0
  131. package/dist/release-draft.d.ts +79 -0
  132. package/dist/release-draft.js +301 -0
  133. package/dist/resources.d.ts +86 -0
  134. package/dist/resources.js +217 -0
  135. package/dist/restart-idle.d.ts +23 -0
  136. package/dist/restart-idle.js +67 -0
  137. package/dist/run-attachments.d.ts +84 -0
  138. package/dist/run-attachments.js +281 -0
  139. package/dist/run-stops.d.ts +15 -0
  140. package/dist/run-stops.js +90 -0
  141. package/dist/run-temp.d.ts +12 -0
  142. package/dist/run-temp.js +57 -0
  143. package/dist/secret-scan.d.ts +6 -1
  144. package/dist/secret-scan.js +33 -0
  145. package/dist/secret-values.d.ts +17 -0
  146. package/dist/secret-values.js +81 -0
  147. package/dist/self-upgrade.d.ts +36 -0
  148. package/dist/self-upgrade.js +78 -0
  149. package/dist/service.d.ts +7 -1
  150. package/dist/service.js +50 -7
  151. package/dist/sign-in.d.ts +41 -0
  152. package/dist/sign-in.js +239 -0
  153. package/dist/tool-call.d.ts +59 -0
  154. package/dist/tool-call.js +375 -0
  155. package/dist/trail/chain.d.ts +12 -0
  156. package/dist/trail/chain.js +89 -0
  157. package/dist/trail/deltas.d.ts +34 -0
  158. package/dist/trail/deltas.js +206 -0
  159. package/dist/trail/index.d.ts +27 -0
  160. package/dist/trail/index.js +128 -0
  161. package/dist/trail/keys.d.ts +14 -0
  162. package/dist/trail/keys.js +61 -0
  163. package/dist/trail/recorder.d.ts +118 -0
  164. package/dist/trail/recorder.js +697 -0
  165. package/dist/trail/rules.d.ts +30 -0
  166. package/dist/trail/rules.js +158 -0
  167. package/dist/trail/stream.d.ts +41 -0
  168. package/dist/trail/stream.js +86 -0
  169. package/dist/transport.d.ts +26 -0
  170. package/dist/transport.js +118 -0
  171. package/dist/work-dir.d.ts +11 -0
  172. package/dist/work-dir.js +69 -0
  173. package/dist/worktree-report.d.ts +10 -0
  174. package/dist/worktree-report.js +17 -0
  175. package/dist/worktrees.d.ts +16 -1
  176. package/dist/worktrees.js +62 -17
  177. package/package.json +4 -4
  178. package/skill/firefunc/SKILL.md +4 -3
package/README.md CHANGED
@@ -1,12 +1,12 @@
1
1
  # firefunc-runner
2
2
 
3
- Run **your own** coding agent — Claude Code, OpenAI Codex, Gemini CLI or Cursor CLI — on work FireFunc routes to you, and open PRs automatically.
3
+ Run **your own** coding agent — Claude Code, OpenAI Codex, Gemini CLI, Cursor CLI, GitHub Copilot CLI or Google Antigravity — on work FireFunc routes to you, and open PRs automatically.
4
4
 
5
5
  This is the **self-hosted runner** for FireFunc's _Claude Code Channel_ engine. It's a tiny always-on daemon on your machine (laptop, dev box, CI host) that:
6
6
 
7
7
  1. **long-polls FireFunc** (outbound only — works behind NAT/VPN, no inbound ports),
8
8
  2. **claims** a bug FireFunc dispatched to your project,
9
- 3. runs **your local coding agent** (`claude -p`, `codex exec`, `gemini`, or `cursor-agent` — whichever the work is routed to) in an isolated git worktree off a clean base branch,
9
+ 3. runs **your local coding agent** (`claude -p`, `codex exec`, `gemini`, `cursor-agent`, `copilot` or `agy` — whichever the work is routed to) in an isolated git worktree off a clean base branch,
10
10
  4. opens a **draft PR** and reports the result back.
11
11
 
12
12
  **Why this and not the cloud Routine?** No ~15/day cap (it uses _your_ Claude subscription's limits), your **code never reaches FireFunc** — it goes from this machine to your own repository, and nowhere else — and it has your full local context — running app, AWS creds, `gh`/`git` auth, MCP servers, `CLAUDE.md`. What the runner does send is listed, field by field, under [What leaves your machine](#what-leaves-your-machine).
@@ -56,12 +56,16 @@ That's it. When your QA files a bug (labeled for FireFunc), it appears here with
56
56
  - **Scans what it is about to push for secrets, on this machine**, and refuses the push on a key, a token or a private key (0.8.3+) — see [The secret scan before a push](#the-secret-scan-before-a-push).
57
57
  - Refuses to push a commit that contains a `.env` file or the run's MCP config, whatever the agent committed.
58
58
  - Writes the agent's skills to `.claude/skills/<slug>/SKILL.md` and keeps them out of every commit **by their real path** (0.9.1+): when the repository keeps `.claude/skills` as a link into a folder it tracks (`.claude/skills -> ../.agents/skills`), the skill lands in that folder and is kept out there — by a `.gitignore` inside each skill folder (that worktree only; your clone's `.git/info/exclude` is not written), in what the runner stages, and at the push, which is refused if the agent committed one anyway. A folder already in the checkout under the same name — in any case, on a disk that ignores case — is never written into (the run sees the repository's, and the log names it), and a link that leads out of the checkout is refused: nothing is written outside the worktree. Runners before 0.9.1 appended `.claude/skills/` to your clone's `.git/info/exclude`; that line can be deleted.
59
+ - **A signed trail of every step, and runs that wait for a person** (0.9.9). The runner records each step the engine takes — its type, timing, outcome and the paths and line counts it touched, never a line of code — as a hash-chained trail signed with this machine's own key, and sends it to FireFunc, which countersigns it. An agent may ask a person a question mid-run, or report its plan for approval before it works: the session is then parked here (worktree and session kept, nothing pushed) and resumed in the same worktree with the answer.
60
+ - **An agent's own environment variables and reference files** (0.9.8). When the agent carries them, the runner asks FireFunc for them for the run it holds (`POST /channel/runs/<id>/agent-env` and `/reference-files` — answered only while that run is live for this machine). The variables are set in the **engine's** environment only — your setup and background commands never see them — and every value FireFunc marks secret is replaced by `[secret NAME]` in everything the runner sends to FireFunc (events, steps, results, a result kept to deliver later) and everything it logs or keeps (the terminal, the session log, the local viewer); a push whose added lines contain one is refused (`agent_secret`). The files are downloaded from addresses signed for minutes, checked against the size and SHA-256 FireFunc recorded, and written to `.firefunc/reference/` in the worktree by the skills' rules: never into a folder the checkout already has, a `.gitignore` of `*` inside, excluded from staging and refused at the push. The brief tells the agent the variables' names (never a value) and where the files are.
59
61
  - Runs Claude with `--permission-mode bypassPermissions` (the default; override with `permissionMode` in the config or per job) **without** `--dangerously-skip-permissions`, which hangs non-interactive daemons. Note what that mode means: the agent is not asked to confirm anything, so the bounds that matter are the ones passed alongside it — `--disallowedTools` for every tool the chain withheld, and `--strict-mcp-config` so the run's servers are the ones FireFunc chose rather than whatever the machine happens to have.
60
62
  - **Claims no work an engine cannot run here** (0.9.6). Claude Code refuses that mode as root or under sudo — the default user of most containers — and exits before doing anything, so a runner started as root used to fail every run it claimed. The runner now asks at start (and whenever it finds a newly installed CLI) whether each engine can run unattended as its user: one that cannot is not offered to FireFunc, which hands this machine none of its work, the log and `firefunc-runner status` say why with the fix, and the Machines page in FireFunc shows it too. A run that reaches it anyway is answered at once, without starting the engine, as the machine not being ready — not as the task's failure. The fix: run the runner as a normal user.
63
+ - **Claims no work for an engine that is not signed in for its user** (0.9.16). A runner installed as a service may not see the sign-in of your desktop session, and every run it claimed failed at once ("could not authenticate"). At start and every two minutes the runner asks Claude Code's own status check, `claude auth status`, which reads the local sign-in and spends nothing; on a clear "not logged in" it offers FireFunc no Claude Code work, says so in the log, `firefunc-runner status` and the Machines page, and a run waiting for it keeps its place until you sign in (`claude auth login`, or `claude setup-token` and `--claude-oauth-token`). An answer it cannot read is never taken for "not signed in".
61
64
  - A per-job timeout (default 20 min) prevents a stuck run from hanging the daemon. An agent's own time budget (FireFunc sends it as `maxMinutes`, 0.9.3) is honoured under the `jobTimeoutMinutes` you set, and in its place when you set none; the engine is told how long it has.
62
65
  - **Nothing a session starts outlives its job** (0.9.3). The engine runs in a process group of its own, and before the worktree is removed — however the job ended — the runner stops that group and every process whose working directory or command line is inside the worktree, its scratch folders or the review skills' `ff-review-*-<checkout>` copies of it, with their descendants; the copies are removed with the worktree. A session's backgrounded test run can no longer go on for hours in a deleted directory.
63
66
  - **Cleans up after a stopped runner, and only after itself** (0.9.3). Each run it claims is written to `held/` in its folder; the next process to start reports the runs a gone process held as lost (so FireFunc can run them again at once), stops what they left running and removes their worktrees. At start, and whenever `git worktree add` finds one of its own leftover worktrees still holding the run's branch, it removes that worktree and tries once more. Only its own — `<temp>/firefunc-XXXXXX` — never yours.
64
67
  - **One heavy command at a time per repository** (0.9.3). Its own setup commands and dependency install take a per-repository lock (`locks/` in its folder), and the engine is offered `$FIREFUNC_HEAVY` — the brief asks it to run a whole-project build, type-check or test suite as `"$FIREFUNC_HEAVY" <command>` — which waits on the same lock. Sessions on different repositories are untouched. `heavyLock: false` in the config turns it off.
68
+ - **The device is lent, one session at a time** (`$FIREFUNC_DEVICE`, `device-lease.ts`). Device work runs as `"$FIREFUNC_DEVICE" <command>`; `--hold` / `--release` keep the device across a sequence (install, set up, test), `--boot <avd>` starts the emulator as the machine's own (never stopped by a run's end; the crash-report dialog off), `--status` says who holds it. A command or a hold keeps it at most 30 minutes (`FIREFUNC_DEVICE_TIMEOUT`), is stopped once no device has answered adb for 5 minutes (`FIREFUNC_DEVICE_GONE`), and the device's airplane mode, wifi, data and proxy are put back when it lets go. A machine running several emulators lists their adb serials as `devices` in the config (`["emulator-5554", "emulator-5556"]`); each is lent to one session, with `ANDROID_SERIAL` set.
65
69
  - **A plan's usage limit is not a failure** (0.9.3). When the engine's own closing report says its plan stopped it (Claude Code's "You've hit your session limit · resets 3:50am"), the attempt is reported as stopped by the plan's usage limit with the reset time, the runner claims no work for that engine until then (`limits.json` in its folder keeps that across a restart), and it keeps the session's worktree: when FireFunc runs the task again after the reset, the same session continues where it stopped (`--resume`) instead of starting over. A kept worktree is removed a day after its reset if the task never comes back.
66
70
  - **A session that ends before its result comes is continued once** (0.9.3). A headless session ends with the agent's turn, and a test it moved to the background is stopped with it. The brief says so; and when the engine's own stream shows a command it started still running at the close — or its closing words only promise a later check ("Waiting on the admission run.") — the runner continues the same session once to get the result. A session that ends that way again is reported as unfinished: its closing words are not sent as its answer and nothing it changed is pushed.
67
71
  - **The GitHub MCP token is renewed as the run goes on** (0.9.3). FireFunc's token for the GitHub MCP server lasts an hour, and runs last longer, so the engine reaches that server through a relay on 127.0.0.1 (a random port and key) which adds the token itself and renews it through FireFunc before it is 55 minutes old or when GitHub answers 401. The token is then never written into the worktree. `mcpRelay: false` in the config writes it into the run's MCP config as before.
@@ -79,6 +83,7 @@ That's it. When your QA files a bug (labeled for FireFunc), it appears here with
79
83
  | `firefunc-runner logs` | Recent runner output |
80
84
  | `firefunc-runner uninstall` | Remove the background service |
81
85
  | `firefunc-runner status` | Saved config, whether each engine can run unattended here, and the service |
86
+ | `firefunc-runner allow-commands` | Let automations run command steps here (`deny-commands` takes it back) |
82
87
  | `firefunc-runner --version` | The version this build carries — the one it reports to FireFunc (`-v`) |
83
88
 
84
89
  ### `connect` flags
@@ -164,7 +169,11 @@ holds each (the runner's own or Claude Code's), never a token. From 0.9.3 also:
164
169
  the runs it holds (working on, or keeping a result for), the ids of runs the runner process
165
170
  before it held and lost, and the plan limits it is waiting out (engine and reset time).
166
171
  From 0.9.6 also: the engines installed here that cannot run unattended as the runner's user,
167
- each with a word for why (`blockedEngines`, e.g. Claude Code and `runs_as_root`).
172
+ each with a word for why (`blockedEngines`, e.g. Claude Code and `runs_as_root`; from 0.9.16
173
+ also `not_signed_in`).
174
+ From 0.9.25 also: each installed engine CLI's own version as `<cli> --version` prints it
175
+ (`engineVersions`, e.g. `{ "claude_code": "2.1.3" }`), and, while an upgrade FireFunc asked
176
+ for is going, how it is going (`upgrade`: started, refused or failed, with the reason).
168
177
  While it is finishing its runs before stopping, waiting out a plan limit on every engine
169
178
  it has, or has no engine that can run unattended, the same request goes every 30 seconds as
170
179
  a heartbeat that asks for no work (`heartbeat`, and `draining` while it stops).
@@ -345,13 +354,14 @@ which machine needs `npm i -g @firefunc-agent/runner@latest`.
345
354
  ## `firefunc`: agents from a terminal, a script or Claude Code
346
355
 
347
356
  The package installs a second command, `firefunc`, for the person who sets agents up
348
- rather than the machine that runs them. It drives FireFunc's public API with a
349
- **workspace API key** (`ffk_…`, made in FireFunc → Settings → API keys), and it is how
350
- Claude Code sets up FireFunc agents for you.
357
+ rather than the machine that runs them. It drives FireFunc's public API as **you**,
358
+ signed in through your browser (0.9.26), or with a **workspace API key** (`ffk_…`, made in
359
+ FireFunc → Settings → API keys) for scripts and CI. It is how Claude Code sets up
360
+ FireFunc agents for you.
351
361
 
352
362
  ```bash
353
363
  npm install -g @firefunc-agent/runner@latest # firefunc arrived in 0.9.0: check with firefunc --version
354
- firefunc login # paste the key at the prompt — nothing you type is shown
364
+ firefunc login # opens FireFunc in your browser: pick the workspace, press Allow
355
365
  firefunc templates list # look before you create
356
366
  firefunc projects list
357
367
  firefunc connections list --project "Web app"
@@ -368,7 +378,7 @@ installs the curated skills that template names, as launching it from the galler
368
378
 
369
379
  | Command | Needs | What it does |
370
380
  | ------------------------------------------------------------------------------ | ------------------------------------- | ------------------------------------------------------------------------- |
371
- | `firefunc login` / `logout` / `whoami` | any key | Save, forget, or show the key this machine uses |
381
+ | `firefunc login` / `logout` / `whoami` | — | Sign in (browser, or `--with-key`), sign out, or show who this machine is |
372
382
  | `firefunc templates list` | `agents:read` | Whole agents to start from |
373
383
  | `firefunc projects list` | `agents:read` | Where an agent can live |
374
384
  | `firefunc connections list [--project …]` | `agents:read` | The tool accounts a project can use |
@@ -402,8 +412,16 @@ Every command has `--help`, and each one takes:
402
412
  checked against: pointed anywhere else, a command is refused (`api_url_mismatch`)
403
413
  until you `firefunc login --api-url` there.
404
414
 
405
- **Where the key lives.** `firefunc login` checks the key against the API before it
406
- saves it to `~/.firefunc/config.json`. The file is readable only by you (0600), in a
415
+ **Signing in through the browser (0.9.26).** `firefunc login` opens FireFunc's consent
416
+ page, the same one Claude, ChatGPT and Codex use. You pick the workspace and what the CLI
417
+ may do (Activate agents and Configure the workspace stay off unless you tick them), and
418
+ the browser hands the sign-in back to a one-off address on `127.0.0.1` (PKCE S256). The
419
+ sign-in is saved to `~/.firefunc/config.json` (0600), refreshes itself every hour, shows
420
+ in FireFunc → Settings → AI tools, and `firefunc logout` ends it there too. On a machine
421
+ with no browser, `--no-browser` prints the address instead; there, or in CI, use a key.
422
+
423
+ **Where the key lives.** `firefunc login --with-key` (or a piped key, or `--key`) checks
424
+ the key against the API before it saves it to `~/.firefunc/config.json`. The file is readable only by you (0600), in a
407
425
  folder only you can open (0700) when `login` creates it; a folder that already existed
408
426
  keeps its own mode. The CLI never prints the key. That file is
409
427
  separate from the runner's `~/.firefunc-runner`, so `firefunc logout` cannot take a
@@ -424,6 +442,129 @@ you asked for that agent and the key has `agents:activate`. It never asks for a
424
442
  in the chat, and it reports a refusal with the fix. `firefunc skill show` prints the
425
443
  skill. A `SKILL.md` you have edited is kept unless you pass `--force`.
426
444
 
445
+ ## Open harnesses (0.9.27)
446
+
447
+ Besides Claude Code, Codex, Gemini CLI, Cursor, Copilot CLI and Antigravity, the runner drives
448
+ the open-source harnesses **OpenCode** (`opencode`), **Pi** (`pi`), **Kilo Code** (`kilo`),
449
+ **Qwen Code** (`qwen`) and **Crush** (`crush`). They use many model providers, such as
450
+ OpenRouter, OpenCode Zen, Anthropic, OpenAI and DeepSeek. The model id names the provider:
451
+ `openrouter/deepseek/deepseek-v4-flash`.
452
+
453
+ Each harness reads a provider's key from the runner's environment (`OPENROUTER_API_KEY`,
454
+ `ANTHROPIC_API_KEY`, …) or from its own login. The runner reads no key. Every hour it asks each
455
+ harness which models it can run (`opencode models`, `pi --list-models`, …) and sends FireFunc the
456
+ model ids, plus the names of the key variables that are set. It never sends their values.
457
+
458
+ ### OpenHands
459
+
460
+ The runner also drives the **OpenHands CLI** (`openhands`, runner id `openhands`). Install the
461
+ official package, pinned to its last release (it needs Python 3.12):
462
+
463
+ ```
464
+ uv tool install openhands==1.16.0 --python 3.12
465
+ ```
466
+
467
+ OpenHands uses your own LLM API key. There is no subscription sign-in. Either set `LLM_API_KEY`
468
+ (your model provider's key) in the runner's environment and pick the model in FireFunc, which
469
+ passes it as `LLM_MODEL` (a LiteLLM id such as `anthropic/claude-sonnet-4-5-20250929`), or run
470
+ `openhands` once as the user the runner runs as and save a model and key. With neither, the
471
+ machine does not offer OpenHands, and says why. The runner runs it as
472
+ `openhands --headless --json --override-with-envs -t <brief>`, on the host, with no Docker.
473
+
474
+ Know these before you pick it:
475
+
476
+ - Its CLI is no longer maintained upstream (since Aug 2026). 1.16.0 is the last release.
477
+ - It reports no usage, so FireFunc shows its runs' usage as not reported.
478
+ - It gets no per-run FireFunc tools (MCP). An agent that plans first, asks a person or works
479
+ only through its tools cannot run on it.
480
+ - It has no effort setting.
481
+
482
+ ## Tool calls for automations (0.9.29)
483
+
484
+ A FireFunc automation can have a step that calls one tool of an MCP server your organization
485
+ lent to the workspace. When only your machine can reach that server (a command it launches, a
486
+ sign-in it holds from `firefunc-runner mcp login`, an address on your own network), the runner
487
+ makes the call. It starts no coding agent and asks no model. It clones nothing and writes no
488
+ file. It starts the one server, calls the one tool once with the step's fields, closes the
489
+ server, and sends back the tool's answer.
490
+
491
+ The server's own output (stderr) stays in the runner's log on your machine. A machine makes at
492
+ most two such calls at once, beside its runs. Windows: a server launched through a `.cmd` shim
493
+ (`npx`, `uvx`) is not started, because the runner launches the command without a shell; register
494
+ the program itself (`node path\to\server.js`).
495
+
496
+ ## Command steps for automations (0.9.30)
497
+
498
+ A FireFunc automation can have a **command step**: one shell command (`go test ./...`,
499
+ `deadcode ./...`) run in a repository. Your machine runs it only after you allow it:
500
+
501
+ ```
502
+ firefunc-runner allow-commands # deny-commands takes it back
503
+ ```
504
+
505
+ It runs in the checkout this machine already has of that repository (mapped with `repo add`, or
506
+ under `--repos-dir`). Nothing is cloned. It starts no coding agent and asks no model. It runs with
507
+ the step's time limit (its whole process group is stopped then, or when the step is stopped in
508
+ FireFunc). What goes to FireFunc: the exit code, how many lines it printed, and its last 2,000
509
+ lines (code-stripped by FireFunc before they are kept). A machine runs at most two at once,
510
+ beside its runs.
511
+
512
+ ## Where a run's folder is (0.9.31)
513
+
514
+ Each run tells FireFunc the absolute path of its worktree on this machine and whether it is still
515
+ there: **live** while the engine works in it, **kept** after the run when the runner keeps it (a cut
516
+ session, a change kept for approval, a parked session), and **gone** once it is removed. Only the
517
+ path is sent, never a file inside it. FireFunc shows the path only to you, the machine's owner, so
518
+ the task page and the editor extension can open the agent's own folder; everyone else sees only the
519
+ machine's name. Worktrees are kept and removed exactly as before.
520
+
521
+ ## Open a run's folder from someone's editor (0.9.32)
522
+
523
+ **Off by default.** Turn it on, as the machine's owner:
524
+
525
+ ```sh
526
+ firefunc-runner config set devMode.editor on # off: firefunc-runner config set devMode.editor off
527
+ firefunc-runner config get devMode.editor
528
+ ```
529
+
530
+ Then a person who can read a task's code, whose editor (the FireFunc extension) is paired with
531
+ FireFunc, may open that run's folder here from their own computer:
532
+
533
+ - **Read-only.** The editor can list folders and read files of that one worktree. It cannot write,
534
+ run anything, or reach any other folder: paths are confined to the worktree (a symlink pointing
535
+ out of it is refused) and the repository's `.git` is never served.
536
+ - **One grant per open.** FireFunc gives a one-time grant for that task, this machine, that folder
537
+ and that editor. It ends when the task ends, when the editor closes, when the pairing is removed,
538
+ when you turn editors off, or after eight hours.
539
+ - **End-to-end encrypted.** The editor and this runner each make a fresh key for the session and
540
+ agree the session key between them (X25519, then ChaCha20-Poly1305). The runner signs its key with
541
+ this machine's trail key; the editor signs its own with its pairing key. FireFunc's relay passes
542
+ the encrypted messages and cannot read them. Both dial out: nothing listens on this machine.
543
+ - The runner's log says who opened which folder, and a six-digit **session check** the editor shows
544
+ too.
545
+
546
+ At most four sessions run at once. A runner older than 0.9.32 never takes one.
547
+
548
+ ## Sign in with: the plan or an API key (0.9.34)
549
+
550
+ On every check-in the runner says, per engine it has, whether the vendor's plan is signed in and
551
+ whether an API key is found, and where (`environment: ANTHROPIC_API_KEY`, `runner folder key file`).
552
+ It never sends a key's value. FireFunc shows this on the machine's Engines.
553
+
554
+ The machine's owner, or a workspace admin, may choose in FireFunc how Claude Code and Codex sign
555
+ in here: the subscription or the API key. The runner reads the choice within a minute and lays it
556
+ over its local config (`claudeUseApiKey`, `codexUseApiKey`); with no choice made, the local config
557
+ decides as before. For Claude Code there are two fallbacks:
558
+
559
+ - **Plan limit hit: use the API key** (`claudeApiKeyFallback`, 0.9.13).
560
+ - **Key out of credit: use the plan** (`claudeKeyToPlan`, new): a session that billed the key and
561
+ closed on "Credit balance is too low" continues at once on the plan in the same worktree, and
562
+ Claude sessions bill the plan for six hours, then the key is tried again.
563
+
564
+ An agent's job may ask for one way. When this machine cannot honour it (no key, or the plan not
565
+ signed in) and no fallback allows the other way, the run ends at once with the reason and the fix,
566
+ for example "No Google key on dan-mbp. Set GEMINI_API_KEY on it, then run the engine check again."
567
+
427
568
  ## Licence
428
569
 
429
570
  `@firefunc-agent/runner` is the **client** half of FireFunc, published so the machines
@@ -437,3 +578,21 @@ for, works on **your** checkouts, and reports results back. Your source code
437
578
  does not need to reach FireFunc for any of it to work.
438
579
 
439
580
  FireFunc is a product of SoftHawker LLC, which licenses this package.
581
+
582
+ ## Managed as a fleet (0.9.25)
583
+
584
+ A workspace can manage its machines from Settings → Machines (or the API):
585
+
586
+ - **Minimum runner version.** A runner below the workspace's minimum is refused work, and
587
+ its log says which version is needed and how to upgrade.
588
+ - **Upgrade when idle.** Asked for a version, the runner finishes the runs it holds, takes
589
+ nothing new, runs `npm install -g @firefunc-agent/runner@<version>`, and exits with code 75
590
+ so its service starts the new version. It only does this as the installed service
591
+ (`firefunc-runner install`) and not from npx's cache; otherwise it says why and keeps running.
592
+ A failed install leaves the old version running and reports npm's last lines.
593
+ - **Token lifetime and rotation.** A workspace can give machine tokens a lifetime and a
594
+ pairing window. The runner replaces its token on its own when a third of its life is left,
595
+ or when a person asks; the old token works for one more hour. An expired token stops the
596
+ runner with the reason; pair it again with `firefunc-runner connect <token> --force`.
597
+ - **Labels.** Machines can carry labels (`gpu`, `mac`); an agent can take machines by labels
598
+ instead of naming each one.
@@ -24,6 +24,7 @@ export declare function createActivityReporter(opts: {
24
24
  now?: () => Date;
25
25
  writeTools?: ReadonlySet<string>;
26
26
  holdMs?: number;
27
+ seqStart?: number;
27
28
  }): {
28
29
  push: (ev: SessionEvent) => void;
29
30
  flush: (final?: boolean) => Promise<void>;
package/dist/activity.js CHANGED
@@ -167,7 +167,7 @@ export function createActivityReporter(opts) {
167
167
  const cap = opts.cap ?? 1500;
168
168
  const holdMs = opts.holdMs ?? 2000;
169
169
  const intervalMs = opts.intervalMs ?? 1500;
170
- let seq = 0;
170
+ let seq = Math.max(0, Math.floor(opts.seqStart ?? 0));
171
171
  let sent = 0;
172
172
  let pending = [];
173
173
  let inflight = null;
@@ -0,0 +1,40 @@
1
+ export type AliveRecord = {
2
+ pid: number;
3
+ user: string;
4
+ service: boolean;
5
+ windowless?: boolean;
6
+ version: string;
7
+ startedAt: string;
8
+ seenAt: string;
9
+ contactAt: string | null;
10
+ transport?: {
11
+ failingSince: string;
12
+ failures: number;
13
+ lastError: string | null;
14
+ rebuilds: number;
15
+ };
16
+ };
17
+ export declare function aliveFile(runnerDir: string): string;
18
+ export declare function writeAlive(runnerDir: string, rec: AliveRecord): void;
19
+ export declare function readAlive(runnerDir: string): AliveRecord | null;
20
+ export declare function clearAlive(runnerDir: string, pid?: number): void;
21
+ export declare function pidAlive(pid: number): boolean;
22
+ export declare const ALIVE_STALE_MS = 90000;
23
+ export type LiveRunner = {
24
+ state: 'running';
25
+ rec: AliveRecord;
26
+ } | {
27
+ state: 'stale';
28
+ rec: AliveRecord;
29
+ } | {
30
+ state: 'gone';
31
+ rec: AliveRecord;
32
+ } | {
33
+ state: 'none';
34
+ };
35
+ export declare function liveRunner(rec: AliveRecord | null, now?: number, alive?: (pid: number) => boolean): LiveRunner;
36
+ export declare function liveRunnerWords(live: LiveRunner, opts: {
37
+ now?: number;
38
+ logPath: string;
39
+ os?: string | null;
40
+ }): string;
package/dist/alive.js ADDED
@@ -0,0 +1,138 @@
1
+ import { readFileSync, renameSync, rmSync, writeFileSync } from 'node:fs';
2
+ import { join } from 'node:path';
3
+ export function aliveFile(runnerDir) {
4
+ return join(runnerDir, 'alive.json');
5
+ }
6
+ export function writeAlive(runnerDir, rec) {
7
+ const file = aliveFile(runnerDir);
8
+ const tmp = `${file}.${rec.pid}.tmp`;
9
+ try {
10
+ writeFileSync(tmp, `${JSON.stringify(rec, null, 2)}\n`, { mode: 0o600 });
11
+ renameSync(tmp, file);
12
+ }
13
+ catch {
14
+ }
15
+ }
16
+ export function readAlive(runnerDir) {
17
+ try {
18
+ const rec = JSON.parse(readFileSync(aliveFile(runnerDir), 'utf8'));
19
+ if (!Number.isInteger(rec.pid) || typeof rec.seenAt !== 'string')
20
+ return null;
21
+ return {
22
+ pid: rec.pid,
23
+ user: typeof rec.user === 'string' ? rec.user : '',
24
+ service: rec.service === true,
25
+ ...(rec.windowless === true ? { windowless: true } : {}),
26
+ version: typeof rec.version === 'string' ? rec.version : '',
27
+ startedAt: typeof rec.startedAt === 'string' ? rec.startedAt : rec.seenAt,
28
+ seenAt: rec.seenAt,
29
+ contactAt: typeof rec.contactAt === 'string' ? rec.contactAt : null,
30
+ ...(rec.transport &&
31
+ typeof rec.transport.failingSince === 'string' &&
32
+ Number.isInteger(rec.transport.failures) &&
33
+ rec.transport.failures > 0
34
+ ? {
35
+ transport: {
36
+ failingSince: rec.transport.failingSince,
37
+ failures: rec.transport.failures,
38
+ lastError: typeof rec.transport.lastError === 'string' ? rec.transport.lastError : null,
39
+ rebuilds: Number.isInteger(rec.transport.rebuilds) ? rec.transport.rebuilds : 0,
40
+ },
41
+ }
42
+ : {}),
43
+ };
44
+ }
45
+ catch {
46
+ return null;
47
+ }
48
+ }
49
+ export function clearAlive(runnerDir, pid = process.pid) {
50
+ const rec = readAlive(runnerDir);
51
+ if (rec && rec.pid !== pid)
52
+ return;
53
+ try {
54
+ rmSync(aliveFile(runnerDir), { force: true });
55
+ }
56
+ catch {
57
+ }
58
+ }
59
+ export function pidAlive(pid) {
60
+ if (!Number.isInteger(pid) || pid <= 0)
61
+ return false;
62
+ try {
63
+ process.kill(pid, 0);
64
+ return true;
65
+ }
66
+ catch (e) {
67
+ return e.code === 'EPERM';
68
+ }
69
+ }
70
+ export const ALIVE_STALE_MS = 90_000;
71
+ export function liveRunner(rec, now = Date.now(), alive = pidAlive) {
72
+ if (!rec)
73
+ return { state: 'none' };
74
+ if (!alive(rec.pid))
75
+ return { state: 'gone', rec };
76
+ const seen = Date.parse(rec.seenAt);
77
+ if (Number.isNaN(seen) || now - seen > ALIVE_STALE_MS)
78
+ return { state: 'stale', rec };
79
+ return { state: 'running', rec };
80
+ }
81
+ function ago(iso, now) {
82
+ if (!iso)
83
+ return 'not yet';
84
+ const t = Date.parse(iso);
85
+ if (Number.isNaN(t))
86
+ return 'at an unknown time';
87
+ const s = Math.max(0, Math.round((now - t) / 1000));
88
+ if (s < 90)
89
+ return `${s}s ago`;
90
+ const m = Math.round(s / 60);
91
+ if (m < 90)
92
+ return `${m} min ago`;
93
+ return `${Math.round(m / 60)} h ago`;
94
+ }
95
+ function transportWords(r, now) {
96
+ const t = r.transport;
97
+ if (!t)
98
+ return '';
99
+ const since = ago(t.failingSince, now).replace(/ ago$/, '');
100
+ const rebuilt = t.rebuilds > 0
101
+ ? `; the connection was rebuilt ${t.rebuilds} time${t.rebuilds === 1 ? '' : 's'}`
102
+ : '';
103
+ return (` failing: cannot reach FireFunc for ${since} — ${t.failures} poll${t.failures === 1 ? '' : 's'} in a row failed${t.lastError ? ` (last: ${t.lastError})` : ''}${rebuilt}\n` +
104
+ ` If FireFunc answers from this machine (open its address in a browser), restart the runner: firefunc-runner stop, then firefunc-runner start-service\n`);
105
+ }
106
+ export function liveRunnerWords(live, opts) {
107
+ const now = opts.now ?? Date.now();
108
+ const logs = ` logs: ${opts.logPath} (firefunc-runner logs)\n`;
109
+ if (live.state === 'none') {
110
+ return (`runner: NOT RUNNING — no runner process has checked in on this machine\n` +
111
+ ` Start it: firefunc-runner start-service (or "firefunc-runner start" in a terminal)\n`);
112
+ }
113
+ const r = live.rec;
114
+ const how = r.service
115
+ ? opts.os === 'win32'
116
+ ? r.windowless
117
+ ? 'started by the background task, with no window'
118
+ : 'started by the background task in a console window (closing it stops the runner — run "firefunc-runner install" again to run it with no window)'
119
+ : 'started by the background service'
120
+ : 'started by hand in a terminal';
121
+ const who = r.user ? ` as ${r.user}` : '';
122
+ if (live.state === 'gone') {
123
+ return (`runner: NOT RUNNING — the last runner (pid ${r.pid}${who}) is gone; it was last seen ${ago(r.seenAt, now)}\n` +
124
+ logs +
125
+ ` The log's last lines say why. Start it: firefunc-runner start-service\n`);
126
+ }
127
+ if (live.state === 'stale') {
128
+ return (`runner: NOT ANSWERING — pid ${r.pid}${who} is alive but has not checked in for ${ago(r.seenAt, now).replace(/ ago$/, '')}\n` +
129
+ logs +
130
+ ` It may be stuck. Restart it: firefunc-runner stop, then firefunc-runner start-service\n`);
131
+ }
132
+ return (`runner: RUNNING — pid ${r.pid}${who}, ${how}${r.version ? `, runner ${r.version}` : ''}\n` +
133
+ ` since: ${r.startedAt}\n` +
134
+ ` FireFunc: last answered ${ago(r.contactAt, now)}\n` +
135
+ transportWords(r, now) +
136
+ logs);
137
+ }
138
+ //# sourceMappingURL=alive.js.map
@@ -0,0 +1,11 @@
1
+ import type { RunnerConfig } from './config.js';
2
+ export declare function apiKeyFile(cfg: Pick<RunnerConfig, 'claudeApiKeyFile'>, dir?: string): string;
3
+ export declare function fallbackKey(cfg: Pick<RunnerConfig, 'claudeApiKeyFallback' | 'claudeApiKeyFile'>, dir?: string): string | null;
4
+ export declare function fallbackUntil(dir?: string, now?: Date): Date | null;
5
+ export declare function startFallback(resetsAt: string | null, dir?: string, now?: Date): Date;
6
+ export declare function keySpentUntil(dir?: string, now?: Date): Date | null;
7
+ export declare function startKeySpent(dir?: string, now?: Date): Date;
8
+ export declare function claudeApiKeyNow(cfg: Pick<RunnerConfig, 'claudeUseApiKey' | 'claudeApiKeyFallback' | 'claudeApiKeyFile' | 'claudeKeyToPlan'>, dir?: string, now?: Date): {
9
+ key: string | null;
10
+ why: 'opted-in' | 'fallback' | 'key-spent' | null;
11
+ };
@@ -0,0 +1,80 @@
1
+ import { existsSync, readFileSync, statSync, writeFileSync } from 'node:fs';
2
+ import { join } from 'node:path';
3
+ import { runnerDir } from './config.js';
4
+ const DEFAULT_WINDOW_MS = 6 * 60 * 60_000;
5
+ export function apiKeyFile(cfg, dir = runnerDir()) {
6
+ return cfg.claudeApiKeyFile ?? join(dir, 'anthropic-api-key');
7
+ }
8
+ export function fallbackKey(cfg, dir = runnerDir()) {
9
+ if (!cfg.claudeApiKeyFallback)
10
+ return null;
11
+ const file = apiKeyFile(cfg, dir);
12
+ try {
13
+ if (!existsSync(file) || statSync(file).size > 4096)
14
+ return null;
15
+ const key = readFileSync(file, 'utf8').trim();
16
+ return key.length >= 20 && !/\s/.test(key) ? key : null;
17
+ }
18
+ catch {
19
+ return null;
20
+ }
21
+ }
22
+ function stateFile(dir) {
23
+ return join(dir, 'api-fallback.json');
24
+ }
25
+ export function fallbackUntil(dir = runnerDir(), now = new Date()) {
26
+ try {
27
+ const raw = JSON.parse(readFileSync(stateFile(dir), 'utf8'));
28
+ const until = raw.until ? new Date(raw.until) : null;
29
+ return until && !Number.isNaN(until.getTime()) && until.getTime() > now.getTime()
30
+ ? until
31
+ : null;
32
+ }
33
+ catch {
34
+ return null;
35
+ }
36
+ }
37
+ export function startFallback(resetsAt, dir = runnerDir(), now = new Date()) {
38
+ const reset = resetsAt ? new Date(resetsAt) : null;
39
+ const until = reset && !Number.isNaN(reset.getTime()) && reset.getTime() > now.getTime()
40
+ ? reset
41
+ : new Date(now.getTime() + DEFAULT_WINDOW_MS);
42
+ const held = fallbackUntil(dir, now);
43
+ const end = held && held.getTime() > until.getTime() ? held : until;
44
+ writeFileSync(stateFile(dir), JSON.stringify({ until: end.toISOString() }), { mode: 0o600 });
45
+ return end;
46
+ }
47
+ function keyStateFile(dir) {
48
+ return join(dir, 'key-fallback.json');
49
+ }
50
+ export function keySpentUntil(dir = runnerDir(), now = new Date()) {
51
+ try {
52
+ const raw = JSON.parse(readFileSync(keyStateFile(dir), 'utf8'));
53
+ const until = raw.until ? new Date(raw.until) : null;
54
+ return until && !Number.isNaN(until.getTime()) && until.getTime() > now.getTime()
55
+ ? until
56
+ : null;
57
+ }
58
+ catch {
59
+ return null;
60
+ }
61
+ }
62
+ export function startKeySpent(dir = runnerDir(), now = new Date()) {
63
+ const until = new Date(now.getTime() + DEFAULT_WINDOW_MS);
64
+ writeFileSync(keyStateFile(dir), JSON.stringify({ until: until.toISOString() }), {
65
+ mode: 0o600,
66
+ });
67
+ return until;
68
+ }
69
+ export function claudeApiKeyNow(cfg, dir = runnerDir(), now = new Date()) {
70
+ if (cfg.claudeUseApiKey) {
71
+ if (cfg.claudeKeyToPlan && keySpentUntil(dir, now))
72
+ return { key: null, why: 'key-spent' };
73
+ return { key: null, why: 'opted-in' };
74
+ }
75
+ const key = fallbackKey(cfg, dir);
76
+ if (key && fallbackUntil(dir, now))
77
+ return { key, why: 'fallback' };
78
+ return { key: null, why: null };
79
+ }
80
+ //# sourceMappingURL=api-fallback.js.map