@firefunc-agent/runner 0.9.14 → 0.9.35

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 (158) hide show
  1. package/README.md +184 -10
  2. package/dist/alive.d.ts +40 -0
  3. package/dist/alive.js +138 -0
  4. package/dist/api-fallback.d.ts +4 -2
  5. package/dist/api-fallback.js +26 -1
  6. package/dist/api.d.ts +66 -3
  7. package/dist/api.js +164 -3
  8. package/dist/brief-file.d.ts +15 -0
  9. package/dist/brief-file.js +36 -0
  10. package/dist/brief.d.ts +3 -0
  11. package/dist/brief.js +14 -4
  12. package/dist/build-caches.d.ts +7 -0
  13. package/dist/build-caches.js +63 -0
  14. package/dist/build-info.json +2 -2
  15. package/dist/checkpoint.d.ts +40 -0
  16. package/dist/checkpoint.js +98 -0
  17. package/dist/cli.js +184 -18
  18. package/dist/cloud-boot.d.ts +41 -0
  19. package/dist/cloud-boot.js +239 -0
  20. package/dist/command-activity.d.ts +23 -0
  21. package/dist/command-activity.js +89 -0
  22. package/dist/command-step.d.ts +58 -0
  23. package/dist/command-step.js +248 -0
  24. package/dist/config.d.ts +39 -0
  25. package/dist/config.js +23 -0
  26. package/dist/cut.d.ts +1 -1
  27. package/dist/cut.js +13 -3
  28. package/dist/daemon.js +364 -15
  29. package/dist/device-lease.d.ts +15 -0
  30. package/dist/device-lease.js +608 -0
  31. package/dist/editor/fs-server.d.ts +31 -0
  32. package/dist/editor/fs-server.js +159 -0
  33. package/dist/editor/relay-crypto.d.ts +68 -0
  34. package/dist/editor/relay-crypto.js +191 -0
  35. package/dist/editor/sessions.d.ts +50 -0
  36. package/dist/editor/sessions.js +279 -0
  37. package/dist/editor/worktree-of.d.ts +1 -0
  38. package/dist/editor/worktree-of.js +23 -0
  39. package/dist/editor/ws-client.d.ts +26 -0
  40. package/dist/editor/ws-client.js +227 -0
  41. package/dist/engine-account.d.ts +24 -0
  42. package/dist/engine-account.js +118 -0
  43. package/dist/engine-login.d.ts +12 -0
  44. package/dist/engine-login.js +88 -0
  45. package/dist/engine-models.d.ts +13 -0
  46. package/dist/engine-models.js +71 -0
  47. package/dist/engine-watch.d.ts +1 -0
  48. package/dist/engine-watch.js +22 -6
  49. package/dist/engines/antigravity.d.ts +2 -0
  50. package/dist/engines/antigravity.js +74 -4
  51. package/dist/engines/claude.js +22 -9
  52. package/dist/engines/codex.js +16 -2
  53. package/dist/engines/copilot.js +12 -0
  54. package/dist/engines/crush.d.ts +2 -0
  55. package/dist/engines/crush.js +58 -0
  56. package/dist/engines/cursor.js +12 -0
  57. package/dist/engines/gemini.js +14 -9
  58. package/dist/engines/index.d.ts +8 -0
  59. package/dist/engines/index.js +73 -1
  60. package/dist/engines/kilo.d.ts +2 -0
  61. package/dist/engines/kilo.js +63 -0
  62. package/dist/engines/opencode.d.ts +9 -0
  63. package/dist/engines/opencode.js +234 -0
  64. package/dist/engines/openhands.d.ts +10 -0
  65. package/dist/engines/openhands.js +271 -0
  66. package/dist/engines/pi.d.ts +10 -0
  67. package/dist/engines/pi.js +248 -0
  68. package/dist/engines/qwen.d.ts +8 -0
  69. package/dist/engines/qwen.js +153 -0
  70. package/dist/engines/sessions.d.ts +6 -0
  71. package/dist/engines/sessions.js +68 -0
  72. package/dist/engines/types.d.ts +3 -3
  73. package/dist/exec.d.ts +1 -0
  74. package/dist/exec.js +10 -4
  75. package/dist/firefunc/agents.d.ts +8 -1
  76. package/dist/firefunc/agents.js +53 -3
  77. package/dist/firefunc/auth.js +72 -19
  78. package/dist/firefunc/automations.d.ts +2 -0
  79. package/dist/firefunc/automations.js +290 -0
  80. package/dist/firefunc/cli.js +25 -0
  81. package/dist/firefunc/client.d.ts +5 -1
  82. package/dist/firefunc/client.js +12 -2
  83. package/dist/firefunc/config.d.ts +11 -1
  84. package/dist/firefunc/config.js +6 -4
  85. package/dist/firefunc/io.d.ts +1 -0
  86. package/dist/firefunc/main.js +34 -2
  87. package/dist/firefunc/oauth-login.d.ts +23 -0
  88. package/dist/firefunc/oauth-login.js +304 -0
  89. package/dist/firefunc/tasks.d.ts +4 -0
  90. package/dist/firefunc/tasks.js +89 -2
  91. package/dist/fleet-words.d.ts +2 -0
  92. package/dist/fleet-words.js +7 -0
  93. package/dist/git-auth.d.ts +15 -0
  94. package/dist/git-auth.js +39 -1
  95. package/dist/held.d.ts +3 -0
  96. package/dist/job.d.ts +26 -3
  97. package/dist/job.js +763 -152
  98. package/dist/keep-awake.d.ts +17 -0
  99. package/dist/keep-awake.js +90 -0
  100. package/dist/keep-local.d.ts +1 -1
  101. package/dist/keep-local.js +5 -3
  102. package/dist/limit.d.ts +9 -1
  103. package/dist/limit.js +260 -3
  104. package/dist/local-checks.d.ts +19 -0
  105. package/dist/local-checks.js +79 -0
  106. package/dist/locks.d.ts +18 -1
  107. package/dist/locks.js +249 -69
  108. package/dist/machine-commands.d.ts +21 -0
  109. package/dist/machine-commands.js +107 -0
  110. package/dist/machine-profile.d.ts +18 -0
  111. package/dist/machine-profile.js +69 -0
  112. package/dist/mcp-init.d.ts +2 -0
  113. package/dist/mcp-init.js +28 -0
  114. package/dist/mcp.d.ts +13 -1
  115. package/dist/mcp.js +48 -4
  116. package/dist/network.js +3 -2
  117. package/dist/openrouter.d.ts +15 -0
  118. package/dist/openrouter.js +39 -0
  119. package/dist/orphans.d.ts +4 -0
  120. package/dist/orphans.js +96 -4
  121. package/dist/pool.d.ts +1 -0
  122. package/dist/pool.js +25 -2
  123. package/dist/pr-title.d.ts +10 -0
  124. package/dist/pr-title.js +15 -0
  125. package/dist/recover.d.ts +3 -1
  126. package/dist/recover.js +27 -7
  127. package/dist/release-draft.d.ts +79 -0
  128. package/dist/release-draft.js +301 -0
  129. package/dist/resources.d.ts +86 -0
  130. package/dist/resources.js +217 -0
  131. package/dist/restart-idle.d.ts +23 -0
  132. package/dist/restart-idle.js +67 -0
  133. package/dist/run-attachments.d.ts +5 -0
  134. package/dist/run-attachments.js +14 -9
  135. package/dist/run-stops.d.ts +15 -0
  136. package/dist/run-stops.js +90 -0
  137. package/dist/run-temp.d.ts +12 -0
  138. package/dist/run-temp.js +57 -0
  139. package/dist/secret-scan.d.ts +5 -0
  140. package/dist/secret-scan.js +30 -0
  141. package/dist/self-upgrade.d.ts +36 -0
  142. package/dist/self-upgrade.js +78 -0
  143. package/dist/service.d.ts +7 -1
  144. package/dist/service.js +50 -7
  145. package/dist/sign-in.d.ts +42 -0
  146. package/dist/sign-in.js +243 -0
  147. package/dist/tool-call.d.ts +59 -0
  148. package/dist/tool-call.js +375 -0
  149. package/dist/transport.d.ts +26 -0
  150. package/dist/transport.js +118 -0
  151. package/dist/work-dir.d.ts +11 -0
  152. package/dist/work-dir.js +69 -0
  153. package/dist/worktree-report.d.ts +10 -0
  154. package/dist/worktree-report.js +17 -0
  155. package/dist/worktrees.d.ts +16 -1
  156. package/dist/worktrees.js +62 -17
  157. package/package.json +4 -4
  158. package/skill/firefunc/SKILL.md +22 -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).
@@ -60,10 +60,12 @@ That's it. When your QA files a bug (labeled for FireFunc), it appears here with
60
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.
61
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.
62
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".
63
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.
64
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.
65
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.
66
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.
67
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.
68
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.
69
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.
@@ -81,6 +83,7 @@ That's it. When your QA files a bug (labeled for FireFunc), it appears here with
81
83
  | `firefunc-runner logs` | Recent runner output |
82
84
  | `firefunc-runner uninstall` | Remove the background service |
83
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) |
84
87
  | `firefunc-runner --version` | The version this build carries — the one it reports to FireFunc (`-v`) |
85
88
 
86
89
  ### `connect` flags
@@ -166,7 +169,11 @@ holds each (the runner's own or Claude Code's), never a token. From 0.9.3 also:
166
169
  the runs it holds (working on, or keeping a result for), the ids of runs the runner process
167
170
  before it held and lost, and the plan limits it is waiting out (engine and reset time).
168
171
  From 0.9.6 also: the engines installed here that cannot run unattended as the runner's user,
169
- 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).
170
177
  While it is finishing its runs before stopping, waiting out a plan limit on every engine
171
178
  it has, or has no engine that can run unattended, the same request goes every 30 seconds as
172
179
  a heartbeat that asks for no work (`heartbeat`, and `draining` while it stops).
@@ -347,13 +354,14 @@ which machine needs `npm i -g @firefunc-agent/runner@latest`.
347
354
  ## `firefunc`: agents from a terminal, a script or Claude Code
348
355
 
349
356
  The package installs a second command, `firefunc`, for the person who sets agents up
350
- rather than the machine that runs them. It drives FireFunc's public API with a
351
- **workspace API key** (`ffk_…`, made in FireFunc → Settings → API keys), and it is how
352
- 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.
353
361
 
354
362
  ```bash
355
363
  npm install -g @firefunc-agent/runner@latest # firefunc arrived in 0.9.0: check with firefunc --version
356
- 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
357
365
  firefunc templates list # look before you create
358
366
  firefunc projects list
359
367
  firefunc connections list --project "Web app"
@@ -370,7 +378,7 @@ installs the curated skills that template names, as launching it from the galler
370
378
 
371
379
  | Command | Needs | What it does |
372
380
  | ------------------------------------------------------------------------------ | ------------------------------------- | ------------------------------------------------------------------------- |
373
- | `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 |
374
382
  | `firefunc templates list` | `agents:read` | Whole agents to start from |
375
383
  | `firefunc projects list` | `agents:read` | Where an agent can live |
376
384
  | `firefunc connections list [--project …]` | `agents:read` | The tool accounts a project can use |
@@ -404,8 +412,16 @@ Every command has `--help`, and each one takes:
404
412
  checked against: pointed anywhere else, a command is refused (`api_url_mismatch`)
405
413
  until you `firefunc login --api-url` there.
406
414
 
407
- **Where the key lives.** `firefunc login` checks the key against the API before it
408
- 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
409
425
  folder only you can open (0700) when `login` creates it; a folder that already existed
410
426
  keeps its own mode. The CLI never prints the key. That file is
411
427
  separate from the runner's `~/.firefunc-runner`, so `firefunc logout` cannot take a
@@ -426,6 +442,146 @@ you asked for that agent and the key has `agents:activate`. It never asks for a
426
442
  in the chat, and it reports a refusal with the fix. `firefunc skill show` prints the
427
443
  skill. A `SKILL.md` you have edited is kept unless you pass `--force`.
428
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
+
568
+ ## Claude Code through OpenRouter (0.9.35)
569
+
570
+ An agent, a routing job, a task or a workflow step may send Claude Code's requests to OpenRouter
571
+ instead of Anthropic. The runner then starts Claude Code with OpenRouter's documented setup:
572
+
573
+ ```text
574
+ ANTHROPIC_BASE_URL=https://openrouter.ai/api
575
+ ANTHROPIC_AUTH_TOKEN=<this machine's OPENROUTER_API_KEY>
576
+ ANTHROPIC_API_KEY=""
577
+ ```
578
+
579
+ The key is read from this machine only: the runner config's `claudeEnv.OPENROUTER_API_KEY`, else
580
+ the environment the runner was started in. FireFunc never stores it; the runner reports only whether
581
+ it is set. A machine without it ends such a run at once: set `OPENROUTER_API_KEY` there, restart
582
+ the runner, and run the task again. The model is passed as OpenRouter names it
583
+ (`anthropic/claude-sonnet-5.5`). A runner older than 0.9.35 is never handed one of these runs.
584
+
429
585
  ## Licence
430
586
 
431
587
  `@firefunc-agent/runner` is the **client** half of FireFunc, published so the machines
@@ -439,3 +595,21 @@ for, works on **your** checkouts, and reports results back. Your source code
439
595
  does not need to reach FireFunc for any of it to work.
440
596
 
441
597
  FireFunc is a product of SoftHawker LLC, which licenses this package.
598
+
599
+ ## Managed as a fleet (0.9.25)
600
+
601
+ A workspace can manage its machines from Settings → Machines (or the API):
602
+
603
+ - **Minimum runner version.** A runner below the workspace's minimum is refused work, and
604
+ its log says which version is needed and how to upgrade.
605
+ - **Upgrade when idle.** Asked for a version, the runner finishes the runs it holds, takes
606
+ nothing new, runs `npm install -g @firefunc-agent/runner@<version>`, and exits with code 75
607
+ so its service starts the new version. It only does this as the installed service
608
+ (`firefunc-runner install`) and not from npx's cache; otherwise it says why and keeps running.
609
+ A failed install leaves the old version running and reports npm's last lines.
610
+ - **Token lifetime and rotation.** A workspace can give machine tokens a lifetime and a
611
+ pairing window. The runner replaces its token on its own when a third of its life is left,
612
+ or when a person asks; the old token works for one more hour. An expired token stops the
613
+ runner with the reason; pair it again with `firefunc-runner connect <token> --force`.
614
+ - **Labels.** Machines can carry labels (`gpu`, `mac`); an agent can take machines by labels
615
+ instead of naming each one.
@@ -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
@@ -3,7 +3,9 @@ export declare function apiKeyFile(cfg: Pick<RunnerConfig, 'claudeApiKeyFile'>,
3
3
  export declare function fallbackKey(cfg: Pick<RunnerConfig, 'claudeApiKeyFallback' | 'claudeApiKeyFile'>, dir?: string): string | null;
4
4
  export declare function fallbackUntil(dir?: string, now?: Date): Date | null;
5
5
  export declare function startFallback(resetsAt: string | null, dir?: string, now?: Date): Date;
6
- export declare function claudeApiKeyNow(cfg: Pick<RunnerConfig, 'claudeUseApiKey' | 'claudeApiKeyFallback' | 'claudeApiKeyFile'>, dir?: string, now?: 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): {
7
9
  key: string | null;
8
- why: 'opted-in' | 'fallback' | null;
10
+ why: 'opted-in' | 'fallback' | 'key-spent' | null;
9
11
  };
@@ -44,9 +44,34 @@ export function startFallback(resetsAt, dir = runnerDir(), now = new Date()) {
44
44
  writeFileSync(stateFile(dir), JSON.stringify({ until: end.toISOString() }), { mode: 0o600 });
45
45
  return end;
46
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
+ }
47
69
  export function claudeApiKeyNow(cfg, dir = runnerDir(), now = new Date()) {
48
- if (cfg.claudeUseApiKey)
70
+ if (cfg.claudeUseApiKey) {
71
+ if (cfg.claudeKeyToPlan && keySpentUntil(dir, now))
72
+ return { key: null, why: 'key-spent' };
49
73
  return { key: null, why: 'opted-in' };
74
+ }
50
75
  const key = fallbackKey(cfg, dir);
51
76
  if (key && fallbackUntil(dir, now))
52
77
  return { key, why: 'fallback' };
package/dist/api.d.ts CHANGED
@@ -1,5 +1,10 @@
1
+ import { type SignInPrefs, type SignInReport } from './sign-in.js';
2
+ import type { ReleaseOffer, ReleaseReport } from './release-draft.js';
3
+ import type { LocalChecksReport } from './local-checks.js';
1
4
  import type { ChangeSummary } from './ask-first.js';
2
5
  import type { RunUsage } from './usage.js';
6
+ import type { ResourcesReport } from './resources.js';
7
+ import type { RelayTicket } from './editor/sessions.js';
3
8
  export type ClaimedJob = {
4
9
  runId: string;
5
10
  workItemId: string;
@@ -7,6 +12,15 @@ export type ClaimedJob = {
7
12
  repo: string | null;
8
13
  branch: string | null;
9
14
  toolsOnly?: boolean;
15
+ checkpoint?: {
16
+ ref: string;
17
+ sha: string;
18
+ at?: string;
19
+ } | null;
20
+ checks?: Array<{
21
+ key: string;
22
+ command: string;
23
+ }>;
10
24
  continuesBranch?: boolean;
11
25
  review?: boolean;
12
26
  askFirst?: boolean;
@@ -28,6 +42,9 @@ export type ClaimedJob = {
28
42
  type: string;
29
43
  engine?: string | null;
30
44
  model?: string | null;
45
+ planModel?: string | null;
46
+ signIn?: 'plan' | 'key' | null;
47
+ claudeEndpoint?: 'anthropic' | 'openrouter' | null;
31
48
  effort?: string | null;
32
49
  permissionMode?: string | null;
33
50
  attachments?: {
@@ -62,11 +79,17 @@ export type ClaimedJob = {
62
79
  detail?: string;
63
80
  off?: boolean;
64
81
  };
82
+ provenance?: {
83
+ runUrl?: string | null;
84
+ trailers?: string[];
85
+ prFooter?: string | null;
86
+ };
87
+ release?: ReleaseOffer;
65
88
  contextPack?: unknown;
66
89
  mcpConfig?: unknown;
67
90
  maxMinutes?: number | null;
68
91
  };
69
- export type RunnerEvent = 'cloning' | 'fixing' | 'pushing' | 'pr_opened' | 'heartbeat' | 'log';
92
+ export type RunnerEvent = 'cloning' | 'fixing' | 'pushing' | 'pr_opened' | 'heartbeat' | 'log' | 'checkpoint' | 'worktree';
70
93
  export type PlanLimitReport = {
71
94
  kind: 'plan';
72
95
  resetsAt: string | null;
@@ -138,20 +161,27 @@ export type ResultPayload = ({
138
161
  summary?: string;
139
162
  }) & {
140
163
  secretScan?: SecretScanReport;
164
+ localChecks?: LocalChecksReport;
141
165
  usage?: RunUsage;
142
166
  limit?: PlanLimitReport | MachineLimitReport;
143
167
  readHead?: string;
144
168
  openCommandAtEnd?: true;
145
169
  lost?: true;
170
+ release?: ReleaseReport;
146
171
  };
147
172
  export declare const REPORTED_SUMMARY_MAX = 65536;
148
173
  export declare const OLDER_API_SUMMARY_MAX = 4000;
149
174
  export declare function cutText(text: string, max: number): string;
150
- export declare const RESULT_LADDER: readonly ["lost", "openCommandAtEnd", "readHead", "limit", "summary", "usage", "secretScan"];
175
+ export declare const RESULT_LADDER: readonly ["localChecks", "release", "lost", "openCommandAtEnd", "readHead", "limit", "summary", "usage", "secretScan"];
151
176
  export declare class RunnerApi {
152
177
  private readonly apiUrl;
153
- private readonly token;
178
+ private token;
154
179
  constructor(apiUrl: string, token: string);
180
+ setToken(token: string): void;
181
+ rotateToken(): Promise<{
182
+ token: string;
183
+ expiresAt: string | null;
184
+ } | null>;
155
185
  private headers;
156
186
  claim(meta: {
157
187
  version: string;
@@ -186,14 +216,47 @@ export declare class RunnerApi {
186
216
  engine: string;
187
217
  code: string;
188
218
  }>;
219
+ resources?: ResourcesReport;
189
220
  awaitingRuns?: string[];
221
+ toolCallSlots?: number;
222
+ allowsCommands?: boolean;
223
+ commandSlots?: number;
224
+ allowsEditors?: boolean;
225
+ signIn?: SignInReport;
190
226
  }, opts?: {
191
227
  onDiscard?: (runIds: string[]) => void;
228
+ onStop?: (runIds: string[]) => void;
229
+ onUpgrade?: (cmd: {
230
+ version: string;
231
+ requestedAt: string;
232
+ }) => void;
233
+ onToken?: (cmd: {
234
+ rotate: true;
235
+ why: string;
236
+ }) => void;
237
+ onToolCalls?: (calls: unknown[]) => void;
238
+ onCommands?: (commands: unknown[]) => void;
239
+ onStopCommands?: (ids: unknown[]) => void;
240
+ onEditorSessions?: (sessions: unknown[]) => void;
192
241
  }): Promise<ClaimedJob | null>;
242
+ commandResult(id: string, report: unknown): Promise<boolean>;
243
+ private editorPost;
244
+ private static relayOf;
245
+ acceptEditorGrant(grantId: string, body: {
246
+ publicKey: string;
247
+ signature: string;
248
+ machineKey: string;
249
+ }): Promise<RelayTicket | null>;
250
+ editorTicket(grantId: string): Promise<RelayTicket | null>;
251
+ refuseEditorGrant(grantId: string, reason: 'editor_off' | 'no_folder' | 'bad_signature' | 'busy'): Promise<boolean>;
252
+ endEditorGrant(grantId: string, reason: 'runner_ended' | 'task_ended'): Promise<boolean>;
253
+ toolCallResult(id: string, report: unknown): Promise<boolean>;
193
254
  repos(): Promise<string[]>;
194
255
  probe(): Promise<boolean>;
195
256
  config(): Promise<{
196
257
  maxParallel: number;
258
+ requiredCommands: string[] | null;
259
+ signInPrefs: SignInPrefs | null;
197
260
  } | null>;
198
261
  gitCredential(runId: string): Promise<{
199
262
  token: string;