@firefunc-agent/runner 0.9.4 → 0.9.6

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/README.md CHANGED
@@ -57,6 +57,7 @@ That's it. When your QA files a bug (labeled for FireFunc), it appears here with
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
59
  - 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
+ - **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.
60
61
  - 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.
61
62
  - **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.
62
63
  - **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.
@@ -68,17 +69,17 @@ That's it. When your QA files a bug (labeled for FireFunc), it appears here with
68
69
 
69
70
  ## Commands
70
71
 
71
- | Command | What it does |
72
- | ----------------------------------------- | ------------------------------------------------------------------------- |
73
- | `firefunc-runner connect <token> [flags]` | Save your token + settings (`~/.firefunc-runner/config.json`, mode 0600) |
74
- | `firefunc-runner install` | Install as a background service — starts at login/boot, restarts on crash |
75
- | `firefunc-runner start` | Run in THIS terminal (stops when you close it) — for watching it work |
76
- | `firefunc-runner stop` | Stop the background service (stays stopped) |
77
- | `firefunc-runner start-service` | Start the background service again |
78
- | `firefunc-runner logs` | Recent runner output |
79
- | `firefunc-runner uninstall` | Remove the background service |
80
- | `firefunc-runner status` | Saved config **and** whether the service is installed + running |
81
- | `firefunc-runner --version` | The version this build carries — the one it reports to FireFunc (`-v`) |
72
+ | Command | What it does |
73
+ | ----------------------------------------- | -------------------------------------------------------------------------- |
74
+ | `firefunc-runner connect <token> [flags]` | Save your token + settings (`~/.firefunc-runner/config.json`, mode 0600) |
75
+ | `firefunc-runner install` | Install as a background service — starts at login/boot, restarts on crash |
76
+ | `firefunc-runner start` | Run in THIS terminal (stops when you close it) — for watching it work |
77
+ | `firefunc-runner stop` | Stop the background service (stays stopped) |
78
+ | `firefunc-runner start-service` | Start the background service again |
79
+ | `firefunc-runner logs` | Recent runner output |
80
+ | `firefunc-runner uninstall` | Remove the background service |
81
+ | `firefunc-runner status` | Saved config, whether each engine can run unattended here, and the service |
82
+ | `firefunc-runner --version` | The version this build carries — the one it reports to FireFunc (`-v`) |
82
83
 
83
84
  ### `connect` flags
84
85
 
@@ -150,7 +151,7 @@ find their own logins). If you install a new agent CLI somewhere new, re-run
150
151
 
151
152
  FireFunc never clones, fetches or stores your repository. The change goes from this
152
153
  machine to **your** repository on GitHub — the push and the draft pull request — and
153
- nowhere else. This is everything runner **0.9.3** sends to the FireFunc API you connected
154
+ nowhere else. This is everything runner **0.9.6** sends to the FireFunc API you connected
154
155
  it to:
155
156
 
156
157
  **While it waits for work** (`POST /channel/claim`, every few seconds): its version,
@@ -162,9 +163,11 @@ the MCP servers this machine is signed in to — names, states, expiries and whi
162
163
  holds each (the runner's own or Claude Code's), never a token. From 0.9.3 also: the ids of
163
164
  the runs it holds (working on, or keeping a result for), the ids of runs the runner process
164
165
  before it held and lost, and the plan limits it is waiting out (engine and reset time).
165
- While it is finishing its runs before stopping, or waiting out a plan limit on every engine
166
- it has, the same request goes every 30 seconds as a heartbeat that asks for no work
167
- (`heartbeat`, and `draining` while it stops).
166
+ 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`).
168
+ While it is finishing its runs before stopping, waiting out a plan limit on every engine
169
+ it has, or has no engine that can run unattended, the same request goes every 30 seconds as
170
+ a heartbeat that asks for no work (`heartbeat`, and `draining` while it stops).
168
171
 
169
172
  **While a run works** (`/channel/runs/<id>/events` and `/activity`): the stage it is at
170
173
  (`cloning`, `fixing`, `pushing`, `pr_opened`, a heartbeat every five minutes) with the
package/dist/api.d.ts CHANGED
@@ -39,6 +39,10 @@ export type PlanLimitReport = {
39
39
  export type EngineLimitReport = PlanLimitReport & {
40
40
  engine: string;
41
41
  };
42
+ export type MachineLimitReport = {
43
+ kind: 'machine';
44
+ detail: string;
45
+ };
42
46
  export type SecretScanReport = {
43
47
  scanned: true;
44
48
  hits: Array<{
@@ -67,7 +71,7 @@ export type ResultPayload = ({
67
71
  }) & {
68
72
  secretScan?: SecretScanReport;
69
73
  usage?: RunUsage;
70
- limit?: PlanLimitReport;
74
+ limit?: PlanLimitReport | MachineLimitReport;
71
75
  readHead?: string;
72
76
  openCommandAtEnd?: true;
73
77
  lost?: true;
@@ -110,6 +114,10 @@ export declare class RunnerApi {
110
114
  heartbeat?: true;
111
115
  draining?: true;
112
116
  limits?: EngineLimitReport[];
117
+ blockedEngines?: Array<{
118
+ engine: string;
119
+ code: string;
120
+ }>;
113
121
  }): Promise<ClaimedJob | null>;
114
122
  repos(): Promise<string[]>;
115
123
  probe(): Promise<boolean>;
@@ -1,4 +1,4 @@
1
1
  {
2
- "version": "0.9.4",
3
- "builtAt": "2026-09-30T12:22:09.568Z"
2
+ "version": "0.9.6",
3
+ "builtAt": "2026-10-02T17:48:54.080Z"
4
4
  }
package/dist/cli.js CHANGED
@@ -4,6 +4,8 @@ import { startDaemon } from './daemon.js';
4
4
  import { runBrief } from './brief.js';
5
5
  import { runMcpList, runMcpLogin, runMcpLogout } from './mcp-login.js';
6
6
  import { RUNNER_VERSION } from './version.js';
7
+ import { availableEngines, getAdapter } from './engines/index.js';
8
+ import { engineBlocks, unattendedContext } from './unattended.js';
7
9
  import { currentPlatform, defaultServiceDeps, EPHEMERAL_INSTALL_MESSAGE, installService, isEphemeralInstall, readLogTail, renderLaunchdPlist, renderSystemdUnit, renderWindowsTaskXml, serviceStatus, servicePaths, startService, stopService, uninstallService, } from './service.js';
8
10
  const HELP = `firefunc-runner — run YOUR local coding agent on work FireFunc routes to you.
9
11
  (Claude Code, OpenAI Codex, Gemini CLI or Cursor CLI — whichever you have installed.)
@@ -18,7 +20,8 @@ Usage:
18
20
  firefunc-runner start-service Start the background service again
19
21
  firefunc-runner logs Show recent runner output
20
22
  firefunc-runner uninstall Remove the background service
21
- firefunc-runner status Show the saved config + service state
23
+ firefunc-runner status Show the saved config, whether each engine can
24
+ run unattended here, and the service state
22
25
  firefunc-runner mcp login <tool> Sign THIS machine in to a tool's MCP server
23
26
  firefunc-runner mcp list Which MCP servers this machine is signed in to
24
27
  firefunc-runner mcp logout <tool> Forget one MCP sign-in
@@ -304,6 +307,18 @@ async function main() {
304
307
  ` autoInstall:${cfg.autoInstall === false ? ' off' : ' on (when no setup)'}\n` +
305
308
  ` background:${cfg.backgroundCommands?.length ? ' ' + cfg.backgroundCommands.join(' ; ') : ' (none)'}\n` +
306
309
  ` envFile: ${cfg.envFile ?? '(none)'}\n`);
310
+ const installed = availableEngines(cfg);
311
+ const blocks = engineBlocks(installed, unattendedContext(cfg));
312
+ process.stdout.write(`\nengines: ${installed.length ? '' : 'none found on PATH — install one (e.g. claude), or set --claude-bin'}\n` +
313
+ installed
314
+ .map((e) => {
315
+ const b = blocks.find((x) => x.engine === e);
316
+ const name = getAdapter(e).displayName;
317
+ return b
318
+ ? ` ${e}: CANNOT RUN UNATTENDED as this user — ${b.reason}\n Fix: ${b.fix}\n The runner claims no ${name} work until then.\n`
319
+ : ` ${e}: ready (${name})\n`;
320
+ })
321
+ .join(''));
307
322
  const os = currentPlatform();
308
323
  const deps = defaultServiceDeps('', os);
309
324
  const svc = await serviceStatus(deps);
package/dist/daemon.js CHANGED
@@ -15,6 +15,8 @@ import { recoverPreviousProcess } from './recover.js';
15
15
  import { dropCut, expiredCuts, keptWorktrees } from './cut.js';
16
16
  import { removeRunnerWorktree, sweepLeftoverWorktrees } from './worktrees.js';
17
17
  import { signalEngineGroups } from './orphans.js';
18
+ import { engineBlocks, unattendedContext } from './unattended.js';
19
+ import { claimPause, engineWatch } from './engine-watch.js';
18
20
  function log(msg) {
19
21
  console.log(`[firefunc-runner] ${new Date().toISOString()} ${msg}`);
20
22
  }
@@ -34,10 +36,10 @@ export async function startDaemon(cfg) {
34
36
  const rdir = runnerDir();
35
37
  const machine = cfg.name ?? hostname();
36
38
  const viewerPort = cfg.viewerEnabled === false ? null : (cfg.viewerPort ?? 8787);
37
- const declaredEngines = availableEngines(cfg);
38
- const skipped = supportedEngines().filter((e) => !declaredEngines.includes(e));
39
- if (declaredEngines.length > 0) {
40
- log(`engines available on this machine: ${declaredEngines.join(', ')}`);
39
+ const installedEngines = availableEngines(cfg);
40
+ const skipped = supportedEngines().filter((e) => !installedEngines.includes(e));
41
+ if (installedEngines.length > 0) {
42
+ log(`engines available on this machine: ${installedEngines.join(', ')}`);
41
43
  }
42
44
  else {
43
45
  log('WARNING: no engine CLI found on PATH — this runner cannot run jobs. Install "claude" (or set --claude-bin).');
@@ -45,35 +47,26 @@ export async function startDaemon(cfg) {
45
47
  if (skipped.length > 0) {
46
48
  log(`engines not installed (skipped): ${skipped.join(', ')} — install the CLI to enable them`);
47
49
  }
50
+ const blocksOf = (installed) => engineBlocks(installed, unattendedContext(cfg));
51
+ const sayBlocked = (blocks) => {
52
+ for (const b of blocks) {
53
+ const name = getAdapter(b.engine).displayName;
54
+ log(`WARNING: ${name} cannot run unattended on this machine: ${b.reason} ${b.fix} Claiming no ${name} work until then.`);
55
+ }
56
+ };
57
+ const declared = engineWatch({
58
+ installed: installedEngines,
59
+ scan: () => availableEngines(cfg),
60
+ blocksOf,
61
+ log,
62
+ onNewlyBlocked: sayBlocked,
63
+ });
64
+ sayBlocked(declared.blocked);
48
65
  const meta = {
49
66
  version: RUNNER_VERSION,
50
67
  hostname: hostname(),
51
68
  platform: platform(),
52
69
  viewerPort,
53
- engines: declaredEngines,
54
- };
55
- const ENGINE_RESCAN_MS = 120_000;
56
- let lastEngineScan = Date.now();
57
- const rescanEngines = () => {
58
- if (Date.now() - lastEngineScan < ENGINE_RESCAN_MS)
59
- return;
60
- lastEngineScan = Date.now();
61
- let found;
62
- try {
63
- found = availableEngines(cfg);
64
- }
65
- catch {
66
- return;
67
- }
68
- if (found.join(',') === meta.engines.join(','))
69
- return;
70
- const added = found.filter((e) => !meta.engines.includes(e));
71
- const gone = meta.engines.filter((e) => !found.includes(e));
72
- meta.engines = found;
73
- if (added.length)
74
- log(`engines now available: ${added.join(', ')}`);
75
- if (gone.length)
76
- log(`engines no longer on PATH: ${gone.join(', ')}`);
77
70
  };
78
71
  let stopping = false;
79
72
  const viewer = cfg.viewerEnabled === false
@@ -214,26 +207,11 @@ export async function startDaemon(cfg) {
214
207
  }
215
208
  const gate = new LimitGate(LimitGate.fileIn(rdir));
216
209
  const limitReports = () => gate.active().map((l) => ({ engine: l.engine, kind: 'plan', resetsAt: l.resetsAt }));
217
- let wasPaused = false;
218
- const paused = () => {
219
- const engines = meta.engines.length > 0 ? meta.engines : ['claude_code'];
220
- const spent = engines.map((e) => gate.isLimited(e));
221
- const now = spent.every((l) => l !== null);
222
- if (now && !wasPaused) {
223
- const until = spent
224
- .map((l) => l.until)
225
- .sort()
226
- .at(-1);
227
- log(`the plan's usage limit is spent on every engine here — claiming no work until ${until}`);
228
- }
229
- else if (!now && wasPaused) {
230
- log("the plan's usage limit has reset — claiming work again");
231
- }
232
- wasPaused = now;
233
- return now;
234
- };
210
+ const paused = claimPause({ watch: declared, isLimited: (e) => gate.isLimited(e), log });
235
211
  const claimBody = (extra = {}) => ({
236
212
  ...meta,
213
+ engines: declared.engines,
214
+ blockedEngines: declared.blockedReport(),
237
215
  maxParallel: effectiveMax(),
238
216
  budget: budgets,
239
217
  mcpLogins: logins.map((l) => ({
@@ -286,7 +264,7 @@ export async function startDaemon(cfg) {
286
264
  if (flushed && (flushed.delivered || flushed.refused)) {
287
265
  log(`pending results: ${flushed.delivered} delivered, ${flushed.refused} refused, ${flushed.kept} kept`);
288
266
  }
289
- rescanEngines();
267
+ declared.rescan();
290
268
  if (Date.now() - lastCutSweep > 10 * 60_000) {
291
269
  lastCutSweep = Date.now();
292
270
  await dropExpiredCuts().catch(() => { });
@@ -0,0 +1,26 @@
1
+ import type { EngineId } from './engines/types.js';
2
+ import { blockedEnginesReport, type EngineBlock } from './unattended.js';
3
+ export declare const ENGINE_RESCAN_MS = 120000;
4
+ export type EngineWatch = {
5
+ readonly installed: EngineId[];
6
+ readonly blocked: EngineBlock[];
7
+ readonly engines: EngineId[];
8
+ blockedReport(): ReturnType<typeof blockedEnginesReport>;
9
+ rescan(): void;
10
+ };
11
+ export declare function engineWatch(deps: {
12
+ installed: EngineId[];
13
+ scan: () => EngineId[];
14
+ blocksOf: (installed: EngineId[]) => EngineBlock[];
15
+ now?: () => number;
16
+ everyMs?: number;
17
+ log?: (msg: string) => void;
18
+ onNewlyBlocked?: (blocks: EngineBlock[]) => void;
19
+ }): EngineWatch;
20
+ export declare function claimPause(deps: {
21
+ watch: Pick<EngineWatch, 'rescan' | 'engines' | 'blocked'>;
22
+ isLimited: (engine: string) => {
23
+ until: string;
24
+ } | null;
25
+ log: (msg: string) => void;
26
+ }): () => boolean;
@@ -0,0 +1,85 @@
1
+ import { blockedEnginesReport, noEngineCanRun, runnableEngines, } from './unattended.js';
2
+ export const ENGINE_RESCAN_MS = 120_000;
3
+ export function engineWatch(deps) {
4
+ const now = deps.now ?? (() => Date.now());
5
+ const everyMs = deps.everyMs ?? ENGINE_RESCAN_MS;
6
+ let installed = deps.installed;
7
+ let blocked = deps.blocksOf(installed);
8
+ let lastScan = now();
9
+ return {
10
+ get installed() {
11
+ return installed;
12
+ },
13
+ get blocked() {
14
+ return blocked;
15
+ },
16
+ get engines() {
17
+ return runnableEngines(installed, blocked);
18
+ },
19
+ blockedReport: () => blockedEnginesReport(blocked),
20
+ rescan() {
21
+ if (now() - lastScan < everyMs)
22
+ return;
23
+ lastScan = now();
24
+ let found;
25
+ try {
26
+ found = deps.scan();
27
+ }
28
+ catch {
29
+ return;
30
+ }
31
+ if (found.join(',') === installed.join(','))
32
+ return;
33
+ const added = found.filter((e) => !installed.includes(e));
34
+ const gone = installed.filter((e) => !found.includes(e));
35
+ installed = found;
36
+ const nowBlocked = deps.blocksOf(found);
37
+ const newly = nowBlocked.filter((b) => !blocked.some((x) => x.engine === b.engine));
38
+ if (newly.length)
39
+ deps.onNewlyBlocked?.(newly);
40
+ blocked = nowBlocked;
41
+ if (added.length)
42
+ deps.log?.(`engines now available: ${added.join(', ')}`);
43
+ if (gone.length)
44
+ deps.log?.(`engines no longer on PATH: ${gone.join(', ')}`);
45
+ },
46
+ };
47
+ }
48
+ export function claimPause(deps) {
49
+ let wasBlocked = false;
50
+ let pausedOn = null;
51
+ return () => {
52
+ deps.watch.rescan();
53
+ const runnable = deps.watch.engines;
54
+ if (noEngineCanRun(runnable, deps.watch.blocked)) {
55
+ if (!wasBlocked) {
56
+ deps.log('no engine on this machine can run unattended as this user — claiming no work; the Machines page in FireFunc shows why and the fix');
57
+ }
58
+ wasBlocked = true;
59
+ return true;
60
+ }
61
+ if (wasBlocked)
62
+ deps.log(`${runnable.join(', ')} can run unattended here — claiming work`);
63
+ wasBlocked = false;
64
+ const engines = runnable.length > 0 ? runnable : ['claude_code'];
65
+ const spent = engines.map((e) => deps.isLimited(e));
66
+ const all = spent.every((l) => l !== null);
67
+ if (all && !pausedOn) {
68
+ const until = spent
69
+ .map((l) => l.until)
70
+ .sort()
71
+ .at(-1);
72
+ deps.log(`the plan's usage limit is spent on every engine here — claiming no work until ${until}`);
73
+ }
74
+ else if (!all && pausedOn) {
75
+ const free = engines.filter((_, i) => spent[i] === null);
76
+ const wasSpent = pausedOn;
77
+ deps.log(free.some((e) => wasSpent.includes(e))
78
+ ? "the plan's usage limit has reset — claiming work again"
79
+ : `${free.join(', ')} ${free.length === 1 ? 'is' : 'are'} not waiting out a plan limit — claiming work again`);
80
+ }
81
+ pausedOn = all ? engines : null;
82
+ return all;
83
+ };
84
+ }
85
+ //# sourceMappingURL=engine-watch.js.map
@@ -46,6 +46,24 @@ function claudeEnding(streamJson) {
46
46
  }
47
47
  return undefined;
48
48
  }
49
+ const TRUTHY = new Set(['1', 'true', 'yes', 'on']);
50
+ function claudeUnattendedBlock(ctx) {
51
+ if (ctx.permissionMode !== 'bypassPermissions')
52
+ return null;
53
+ if (ctx.platform === 'win32' || ctx.uid !== 0)
54
+ return null;
55
+ if (ctx.env.IS_SANDBOX === '1')
56
+ return null;
57
+ const bubblewrap = (ctx.env.CLAUDE_CODE_BUBBLEWRAP ?? '').trim().toLowerCase();
58
+ if (TRUTHY.has(bubblewrap))
59
+ return null;
60
+ return {
61
+ code: 'runs_as_root',
62
+ reason: 'the runner runs as root, and Claude Code refuses --permission-mode bypassPermissions as root or under sudo.',
63
+ fix: 'Run the runner as a normal user: stop it, then start it (or install its service) from an account that is not root.',
64
+ detail: 'Claude Code will not run as root — run the runner as a normal user',
65
+ };
66
+ }
49
67
  const SESSION_ID = /^[A-Za-z0-9][A-Za-z0-9-]{7,79}$/;
50
68
  function claudeSessionId(streamJson) {
51
69
  let id = null;
@@ -234,6 +252,14 @@ export const claudeAdapter = {
234
252
  }
235
253
  return null;
236
254
  },
255
+ unattendedBlock(ctx) {
256
+ try {
257
+ return claudeUnattendedBlock(ctx);
258
+ }
259
+ catch {
260
+ return null;
261
+ }
262
+ },
237
263
  readBudget(cfg) {
238
264
  return readClaudeBudget(cfg);
239
265
  },
@@ -1,6 +1,6 @@
1
1
  import type { AgentAdapter, EngineId } from './types.js';
2
2
  import type { RunnerConfig } from '../config.js';
3
- export type { AgentAdapter, EngineId, Invocation, InvocationContext } from './types.js';
3
+ export type { AgentAdapter, EngineId, Invocation, InvocationContext, UnattendedBlock, UnattendedContext, } from './types.js';
4
4
  export { claudeAdapter } from './claude.js';
5
5
  export { codexAdapter } from './codex.js';
6
6
  export { geminiAdapter } from './gemini.js';
@@ -19,6 +19,18 @@ export type InvocationContext = {
19
19
  cfg: RunnerConfig;
20
20
  resumeSessionId?: string;
21
21
  };
22
+ export type UnattendedContext = {
23
+ uid: number | null;
24
+ platform: NodeJS.Platform;
25
+ env: NodeJS.ProcessEnv;
26
+ permissionMode: string;
27
+ };
28
+ export type UnattendedBlock = {
29
+ code: 'runs_as_root';
30
+ reason: string;
31
+ fix: string;
32
+ detail: string;
33
+ };
22
34
  export type Invocation = {
23
35
  bin: string;
24
36
  args: string[];
@@ -48,6 +60,7 @@ export interface AgentAdapter {
48
60
  summarize(stdout: string): string;
49
61
  authFailureHint(text: string): string | null;
50
62
  rateLimitHint(text: string): string | null;
63
+ unattendedBlock?(ctx: UnattendedContext): UnattendedBlock | null;
51
64
  ending?(stdout: string): EngineEnding | undefined;
52
65
  meter?(stdout: string): RunUsage | null;
53
66
  planLimit?(stdout: string, now: Date): PlanLimit | null;
@@ -139,7 +139,13 @@ function activationLines(body, opts) {
139
139
  else if (r.ready === true)
140
140
  lines.push('', 'Nothing is missing for it to be activated.');
141
141
  }
142
- if (typeof r.machinesOnline === 'number') {
142
+ if (typeof r.machinesServing === 'number') {
143
+ const all = typeof r.machinesOnline === 'number' && r.machinesOnline !== r.machinesServing
144
+ ? ` (${r.machinesOnline} online in the workspace)`
145
+ : '';
146
+ lines.push(`Machines online that serve its project now: ${r.machinesServing}${all}`);
147
+ }
148
+ else if (typeof r.machinesOnline === 'number') {
143
149
  lines.push(`Machines online for this workspace now: ${r.machinesOnline}`);
144
150
  }
145
151
  if (notes.length)
@@ -27,7 +27,13 @@ function printTask(ctx, t) {
27
27
  ` agent: ${agent ? `${text(agent.name)}${agent.handle ? ` (@${String(agent.handle)})` : ''}` : text(t.workflowId)}`,
28
28
  ` project: ${project ? text(project.name) : text(t.projectId)}`,
29
29
  ];
30
- if (t.error)
30
+ const hold = heldBy(t.hold);
31
+ if (hold) {
32
+ lines.push(...wrap(hold.said, 78, ' held: ', ' '));
33
+ if (hold.fix)
34
+ lines.push(...wrap(hold.fix, 78, ' fix: ', ' '));
35
+ }
36
+ else if (t.error)
31
37
  lines.push(` error: ${text(t.error)}`);
32
38
  const prs = Array.isArray(t.pullRequests) ? t.pullRequests : [];
33
39
  for (const pr of prs)
@@ -64,6 +70,19 @@ function printTask(ctx, t) {
64
70
  }
65
71
  ctx.io.stdout.write(`${lines.join('\n')}\n`);
66
72
  }
73
+ function heldBy(v) {
74
+ if (!v || typeof v !== 'object')
75
+ return null;
76
+ const h = v;
77
+ const said = typeof h.detail === 'string' && h.detail.trim()
78
+ ? h.detail
79
+ : typeof h.reason === 'string' && h.reason
80
+ ? h.reason
81
+ : null;
82
+ if (!said)
83
+ return null;
84
+ return { said, fix: typeof h.fix === 'string' && h.fix.trim() ? h.fix : null };
85
+ }
67
86
  function verdictWord(v) {
68
87
  const word = v?.word;
69
88
  if (typeof word !== 'string' || !word)
package/dist/job.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import type { RunnerApi, ClaimedJob } from './api.js';
2
2
  import { type RunnerConfig } from './config.js';
3
3
  import type { SessionViewer } from './viewer.js';
4
+ import type { UnattendedContext } from './engines/types.js';
4
5
  import { type LimitGate } from './limit.js';
5
6
  export declare function resolveRepoPath(repo: string | null | undefined, cfg: RunnerConfig): string | null;
6
7
  export declare function cloneDestination(repo: string, cfg: RunnerConfig): string | null;
@@ -10,4 +11,5 @@ export declare function runJob(job: ClaimedJob, cfg: RunnerConfig, api: RunnerAp
10
11
  devServerPort?: number;
11
12
  limits?: LimitGate;
12
13
  now?: () => Date;
14
+ unattended?: Partial<UnattendedContext>;
13
15
  }): Promise<void>;
package/dist/job.js CHANGED
@@ -23,6 +23,7 @@ import { getAdapter, stripForeignEngineCreds } from './engines/index.js';
23
23
  import { mcpFormatForEngine, prepareMcp } from './mcp.js';
24
24
  import { continueToFinishBrief, engineRules } from './brief.js';
25
25
  import { limitSentence } from './limit.js';
26
+ import { cannotRunUnattendedSentence, unattendedContext } from './unattended.js';
26
27
  import { cutFor, dropCut, keepUntil, promptHash, resumeAfterResetBrief, saveCut, } from './cut.js';
27
28
  import { liveWorktrees, updateHeld } from './held.js';
28
29
  import { killOrphans, reviewCopiesOf, trackEngineGroup, untrackEngineGroup } from './orphans.js';
@@ -241,6 +242,19 @@ export async function runJob(job, cfg, api, viewer, opts) {
241
242
  limit: { kind: 'plan', resetsAt: limit.resetsAt },
242
243
  });
243
244
  }
245
+ const unattended = adapter.unattendedBlock?.({
246
+ ...unattendedContext(cfg, job.permissionMode),
247
+ ...opts?.unattended,
248
+ });
249
+ if (unattended) {
250
+ const sentence = cannotRunUnattendedSentence(adapter.displayName, unattended);
251
+ log(`${job.runId}: ${sentence}`);
252
+ return report({
253
+ status: 'failed',
254
+ error: sentence,
255
+ limit: { kind: 'machine', detail: unattended.detail },
256
+ });
257
+ }
244
258
  let repoPath = toolsOnly ? null : resolveRepoPath(job.repo, cfg);
245
259
  if (!repoPath && job.repo) {
246
260
  const cred = await api.gitCredential(job.runId);
@@ -50,12 +50,51 @@ function isCodeLine(line) {
50
50
  const DIFF_HEAD = /^(?:diff --git |index [0-9a-f]{7,}\.\.[0-9a-f]{7,}|--- (?:a\/|\/dev\/null)|\+\+\+ (?:b\/|\/dev\/null)|@@ -\d+(?:,\d+)? \+\d+(?:,\d+)? @@)/;
51
51
  const DIFF_BODY = /^(?:[-+ \\]|@@ |diff --git |index |new file mode|deleted file mode|similarity index|rename (?:from|to) |old mode|new mode|Binary files )/;
52
52
  const INLINE_STATEMENT = /[;{}]|=>|(?<![=!<>])=(?![=>])|^\s*(?:return|throw|raise|const|let|var|def|import|from|export|function|class|if|for|while)\s/;
53
+ const QUERY_PAIR = /[?&][\w.[\]-]+=[^\s&#]*/g;
54
+ const FLAG_PAIR = /(^|\s)--?[A-Za-z][\w.-]*=(?![=>])[^\s=;{}]*/g;
55
+ const INLINE_COMMANDS = new Set('pnpm pnpx npm npx yarn bun bunx deno node tsx tsc vitest jest mocha playwright cypress eslint prettier biome turbo git gh glab make cargo go python python3 pip pip3 pytest uv poetry ruff mypy ruby bundle rake rails rspec php composer phpunit dotnet mvn gradle gradlew docker kubectl helm terraform curl psql createdb dropdb pg_ctl initdb firefunc firefunc-runner'.split(' '));
56
+ const HANDS_OVER = /(?:^|\s)(?:auth|config|credentials?|login|secrets?|token|variable)(?=\s|$)/i;
57
+ const KEY_SHAPE = /\b(?:AKIA|ASIA)[0-9A-Z]{16}\b|\b(?:gh[pousr]_[A-Za-z0-9]{36}|github_pat_\w{22,}|xox[abprs]-[\w-]{10,}|AIza[\w-]{35}|[rs]k_(?:live|test)_[A-Za-z0-9]{16,})|-----BEGIN [A-Z ]{0,40}PRIVATE KEY|\bey[\w-]{10,}\.ey[\w-]{10,}\.[\w-]{10,}/;
58
+ const ABOUT_IT = 'file|filename|path|dir|ttl|url|uri|name|arn|length|len|size|type|mode|version|prefix|header|expiry|expires|lifetime|timeout|enabled|required|policy|format|algorithm|alg|provider|endpoint|issuer|audience|count|limit|location';
59
+ const REFERENCE = String.raw `(?:[$<*%{…-]|\.\.\.)`;
60
+ const VALUE = String.raw `['"]?(?!${REFERENCE})[^\s'"]`;
61
+ const SECRET_ARG = new RegExp([
62
+ String.raw `:\/\/[^\s/@:]*:(?!${REFERENCE})[^\s/@]+@`,
63
+ String.raw `\bbearer\s+(?!${REFERENCE})[\w.~+/=-]{8,}`,
64
+ String.raw `\bcurl\b[^|;&]*\s(?:-u\s*|--user[=\s]\s*)['"]?[a-z_][^\s:'"]*:(?!${REFERENCE})\S`,
65
+ String.raw `(?:^|\s)(?:-H|--header)[=\s]?\s*['"]?[\w-]*(?:token|key|auth\w*|cookie|secret)[\w-]*\s*:\s*(?!(?:(?:bearer|basic|token)\s+)?${REFERENCE})\S`,
66
+ String.raw `(?:^|\s)--?[\w.-]*(?:pass(?:word|wd|phrase)?|token|secret|api[-_]?key|access[-_]?key|private[-_]?key|auth(?:[-_]?token|orization)?|cred(?:entials?|s)?|cookie|otp)(?:=|\s+)${VALUE}`,
67
+ String.raw `[?&](?:(?:access|refresh|id|auth|api|session)[-_]?)?token=(?!${REFERENCE})[^\s&#]`,
68
+ String.raw `[?&](?:x-amz-security-token|(?:client[-_]?)?secret|passw(?:or)?d|api[-_]?key|key|sig|signature|x-(?:amz|goog)-(?:signature|credential))=(?!${REFERENCE})[^\s&#]`,
69
+ String.raw `(?:^|[\s;&|('"])[\w.-]*(?:password|passwd|passphrase|secret|token|api[_-]?key|access[_-]?key|private[_-]?key)(?![a-z])(?![\w.-]*?[_.-](?:${ABOUT_IT})(?![a-z0-9]))[\w.-]*=${VALUE}`,
70
+ String.raw `hooks\.slack\.com\/(?:services|workflows|triggers)\/|discord(?:app)?\.com\/api\/webhooks\/|\.webhook\.office\.com\/|outlook\.office(?:365)?\.com\/webhook|hooks\.zapier\.com\/hooks\/|api\.telegram\.org\/bot`,
71
+ ].join('|'), 'i');
72
+ const SECRET_CLI = new RegExp([
73
+ String.raw `\b(?:mysql|mariadb)[\w-]*\b[^|;&]*?\s-p${VALUE}`,
74
+ String.raw `\bsshpass\b[^|;&]*?\s-p\s*${VALUE}`,
75
+ String.raw `\b(?:docker|podman|buildah|helm|oras)\b[^|;&]*\slogin\b[^|;&]*\s-p\s*${VALUE}`,
76
+ String.raw `\baws\s+configure\s+set\b[^|;&]*?\s(?:[\w.-]+\.)?aws_(?:secret_access_key|session_token|access_key_id)\s+${VALUE}`,
77
+ String.raw `\bgh\s+secret\s+set\b[^|;&]*?\s(?:--body(?:=|\s+)|-b\s*)${VALUE}`,
78
+ String.raw `\bkubectl\b[^|;&]*?\screate\s+secret\b[^|;&]*?\s--from-literal(?:=|\s+)['"]?[^\s'"=]+=${VALUE}`,
79
+ String.raw `\b(?:heroku\s+config:set|fly(?:ctl)?\s+secrets\s+set|doppler\s+secrets\s+set)\b[^|;&]*?\s['"]?[\w.-]+=${VALUE}`,
80
+ String.raw `\b(?:echo|printf)\b[^|]*?\s['"]?(?!${REFERENCE})[^\s'"|][^|]*\|\s*(?:(?:npx|bunx|sudo)\s+)?(?:vercel\s+env\s+add|gh\s+secret\s+set|wrangler\s+secret\s+put|doppler\s+secrets\s+set|fly(?:ctl)?\s+secrets\s+(?:set|import)|(?:docker|podman)\s+(?:login|secret\s+create)|helm\s+registry\s+login|kubectl\s+create\s+secret)\b`,
81
+ ].join('|'));
82
+ const SECRET_ENV = new RegExp(String.raw `(?:^|[\s;&|('"])(?:(?:[A-Z0-9]+_)*(?:KEY|PASS)|(?:[A-Z0-9]+_)+PWD)(?!(?:_[A-Z0-9]+)*?_(?:${ABOUT_IT.toUpperCase()})(?![A-Z0-9]))(?:_[A-Z0-9]+)*=${VALUE}`);
83
+ const settingsReadOut = (inner) => inner.replace(QUERY_PAIR, '').replace(FLAG_PAIR, '$1');
84
+ const inlineCap = (inner) => INLINE_COMMANDS.has(inner.trim().split(/\s/, 1)[0].split('/').pop()) && !HANDS_OVER.test(inner)
85
+ ? 160
86
+ : 60;
87
+ const carriesSecret = (inner) => inner.length <= 1000 &&
88
+ (KEY_SHAPE.test(inner) ||
89
+ SECRET_ARG.test(inner) ||
90
+ SECRET_CLI.test(inner) ||
91
+ SECRET_ENV.test(inner));
53
92
  function inlineSpan(whole, inner) {
54
93
  const named = /^[\w@./-]+(?::\d+)?$/.test(inner.trim());
55
94
  const code = inner.includes('\n') ||
56
- inner.length > 60 ||
57
- (/\s/.test(inner.trim()) && INLINE_STATEMENT.test(inner));
58
- return code && !named ? codeNote(null) : whole;
95
+ inner.length > inlineCap(inner) ||
96
+ (/\s/.test(inner.trim()) && INLINE_STATEMENT.test(settingsReadOut(inner)));
97
+ return (code && !named) || carriesSecret(inner) ? codeNote(null) : whole;
59
98
  }
60
99
  export function stripCode(text) {
61
100
  if (!text)
@@ -0,0 +1,14 @@
1
+ import type { EngineId, UnattendedBlock, UnattendedContext } from './engines/types.js';
2
+ import type { RunnerConfig } from './config.js';
3
+ export type EngineBlock = UnattendedBlock & {
4
+ engine: EngineId;
5
+ };
6
+ export declare function unattendedContext(cfg: RunnerConfig, permissionMode?: string | null): UnattendedContext;
7
+ export declare function engineBlocks(engines: readonly EngineId[], ctx: UnattendedContext): EngineBlock[];
8
+ export declare function runnableEngines(installed: readonly EngineId[], blocks: readonly EngineBlock[]): EngineId[];
9
+ export declare function noEngineCanRun(runnable: readonly EngineId[], blocks: readonly EngineBlock[]): boolean;
10
+ export declare function blockedEnginesReport(blocks: readonly EngineBlock[]): Array<{
11
+ engine: EngineId;
12
+ code: UnattendedBlock['code'];
13
+ }>;
14
+ export declare function cannotRunUnattendedSentence(engineName: string, block: UnattendedBlock): string;
@@ -0,0 +1,37 @@
1
+ import { getAdapter } from './engines/index.js';
2
+ export function unattendedContext(cfg, permissionMode) {
3
+ return {
4
+ uid: typeof process.getuid === 'function' ? process.getuid() : null,
5
+ platform: process.platform,
6
+ env: { ...process.env, ...(cfg.claudeEnv ?? {}) },
7
+ permissionMode: permissionMode ?? cfg.permissionMode ?? 'bypassPermissions',
8
+ };
9
+ }
10
+ export function engineBlocks(engines, ctx) {
11
+ const out = [];
12
+ for (const engine of engines) {
13
+ let block = null;
14
+ try {
15
+ block = getAdapter(engine).unattendedBlock?.(ctx) ?? null;
16
+ }
17
+ catch {
18
+ block = null;
19
+ }
20
+ if (block)
21
+ out.push({ ...block, engine });
22
+ }
23
+ return out;
24
+ }
25
+ export function runnableEngines(installed, blocks) {
26
+ return installed.filter((e) => !blocks.some((b) => b.engine === e));
27
+ }
28
+ export function noEngineCanRun(runnable, blocks) {
29
+ return runnable.length === 0 && blocks.length > 0;
30
+ }
31
+ export function blockedEnginesReport(blocks) {
32
+ return blocks.map((b) => ({ engine: b.engine, code: b.code }));
33
+ }
34
+ export function cannotRunUnattendedSentence(engineName, block) {
35
+ return `${engineName} cannot run unattended on this machine: ${block.reason} ${block.fix}`;
36
+ }
37
+ //# sourceMappingURL=unattended.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@firefunc-agent/runner",
3
- "version": "0.9.4",
3
+ "version": "0.9.6",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "FireFunc self-hosted runner — an always-on daemon that runs YOUR local coding agent (Claude Code, Codex, Gemini CLI, Cursor CLI) on work FireFunc routes to it, opens pull requests, and reports back. Your machine, your subscriptions.",