@firefunc-agent/runner 0.9.35 → 0.9.37
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 +50 -0
- package/dist/api.d.ts +1 -1
- package/dist/brief-file.d.ts +1 -0
- package/dist/brief-file.js +6 -0
- package/dist/build-info.json +2 -2
- package/dist/cli.js +84 -10
- package/dist/daemon.js +35 -5
- package/dist/engine-login.js +4 -2
- package/dist/engine-models.js +4 -2
- package/dist/engines/index.js +4 -2
- package/dist/exec.js +5 -2
- package/dist/firefunc/automations.js +22 -0
- package/dist/firefunc/catalog.js +8 -1
- package/dist/firefunc/machines.d.ts +2 -0
- package/dist/firefunc/machines.js +85 -0
- package/dist/firefunc/main.js +9 -0
- package/dist/firefunc/tasks.js +2 -0
- package/dist/firefunc/webhooks.d.ts +2 -0
- package/dist/firefunc/webhooks.js +78 -0
- package/dist/job.js +17 -4
- package/dist/keep-local.d.ts +1 -0
- package/dist/keep-local.js +6 -1
- package/dist/live-runner.d.ts +47 -0
- package/dist/live-runner.js +109 -0
- package/dist/mcp-login.d.ts +1 -0
- package/dist/mcp-login.js +42 -5
- package/dist/mcp.d.ts +3 -0
- package/dist/mcp.js +35 -3
- package/dist/newer-runner.d.ts +9 -0
- package/dist/newer-runner.js +38 -0
- package/dist/pool.d.ts +2 -0
- package/dist/pool.js +12 -1
- package/dist/update.d.ts +41 -0
- package/dist/update.js +176 -0
- package/dist/win-shell.d.ts +14 -0
- package/dist/win-shell.js +51 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -396,6 +396,16 @@ installs the curated skills that template names, as launching it from the galler
|
|
|
396
396
|
| `firefunc projects instructions get \| set <project> --file f.json` | `agents:read` / `workspace:configure` | A project's standing instructions (set replaces all five fields) |
|
|
397
397
|
| `firefunc projects sources get \| set <project> --file f.json` | `agents:read` / `workspace:configure` | What work a project claims (set merges kind by kind) |
|
|
398
398
|
| `firefunc projects repos get \| set <project> --file f.json` | `agents:read` / `workspace:configure` | A project's repositories (set adds only ones its GitHub account can see) |
|
|
399
|
+
| `firefunc automations list \| get <id> \| templates \| check <id>` | `agents:read` | Workflows and orchestrations, one or all, and whether one would publish |
|
|
400
|
+
| `firefunc automations create --name … --spec f.json` | `agents:write` | A **draft** workflow or orchestration |
|
|
401
|
+
| `firefunc automations publish <id>` | `workspace:configure` | Make the draft the live version |
|
|
402
|
+
| `firefunc automations run <id> [--inputs json] [--watch]` | `tasks:write` | Start a run of a published automation |
|
|
403
|
+
| `firefunc automations runs <id> \| run-get <run>` | `tasks:read` | Its runs, and one run step by step |
|
|
404
|
+
| `firefunc automations retry-from <run> --step <key>` | `tasks:write` | Run a failed run again from that step |
|
|
405
|
+
| `firefunc machines list \| labels <id>` | `agents:read` | Machines, their engines, and one machine's labels |
|
|
406
|
+
| `firefunc machines labels <id> --set a,b` | `workspace:configure` | Replace a machine's labels |
|
|
407
|
+
| `firefunc webhooks list` | `agents:read` | Inbound webhooks and their addresses |
|
|
408
|
+
| `firefunc webhooks create --name … --project … \| rotate <id>` | `workspace:configure` | A new inbound webhook, or a new token for one (printed once) |
|
|
399
409
|
| `firefunc skill install [--dir …]` | — | Write the Claude Code skill (below) |
|
|
400
410
|
|
|
401
411
|
Every command has `--help`, and each one takes:
|
|
@@ -582,6 +592,35 @@ it is set. A machine without it ends such a run at once: set `OPENROUTER_API_KEY
|
|
|
582
592
|
the runner, and run the task again. The model is passed as OpenRouter names it
|
|
583
593
|
(`anthropic/claude-sonnet-5.5`). A runner older than 0.9.35 is never handed one of these runs.
|
|
584
594
|
|
|
595
|
+
## FireFunc's tools during a run (0.9.36)
|
|
596
|
+
|
|
597
|
+
A run's agent reaches FireFunc mid-run (its answer, its verdict, live reads, a Slack post) through
|
|
598
|
+
FireFunc's own MCP server, which the runner sets up just before the engine starts. When it cannot,
|
|
599
|
+
the runner now tells FireFunc why, as a code (`mcp_setup`: the engine has no MCP client, the
|
|
600
|
+
repository already holds the config path, `.git/info/exclude` could not be written, no pass was
|
|
601
|
+
issued, …) — never a path or a vendor's words. The task, the workflow step and Machines then say
|
|
602
|
+
the cause and the fix instead of "reported no answer".
|
|
603
|
+
|
|
604
|
+
On Windows an engine is mostly an npm shim (`claude.cmd`), which starts only through `cmd.exe`.
|
|
605
|
+
Before 0.9.36 the runner handed cmd.exe its arguments unquoted: a path with a space in it
|
|
606
|
+
(`C:\Users\Jane Doe\…`) reached Claude Code as two arguments, so `--mcp-config` (FireFunc's tools),
|
|
607
|
+
`--add-dir` and the tool list could be cut, and Codex's `-c key="value"` overrides lost their
|
|
608
|
+
quotes. Every argument is now quoted for the program and escaped for cmd.exe (twice for a `.cmd`
|
|
609
|
+
shim, which reads its line a second time), so spaces, quotes, `&`, `|`, `<`, `>`, `^` and `%`
|
|
610
|
+
arrive as written. This covers the engines, `npm install -g` for updates, and the version and
|
|
611
|
+
model checks. `mcp login` opens the browser with `rundll32` instead of `cmd /c start`, which cut the
|
|
612
|
+
sign-in address at its first `&`. If an engine that takes its brief on the command line
|
|
613
|
+
(OpenHands) cannot have it moved into the run's `.firefunc/brief` folder, the run stops with the
|
|
614
|
+
fix rather than send the task's words through cmd.exe.
|
|
615
|
+
|
|
616
|
+
A machine picks up new work faster: for two minutes after it claims or finishes a run (and after
|
|
617
|
+
it starts) it asks FireFunc for work every second, then backs off to every 8 seconds while idle.
|
|
618
|
+
A formatted block in an agent's answer (`html, `markdown) is kept on the machine like code
|
|
619
|
+
and now says so: "[formatted text kept on the machine: read it in the run's session log there]".
|
|
620
|
+
|
|
621
|
+
To update: `npm install -g @firefunc-agent/runner@latest; firefunc-runner restart --when-idle`
|
|
622
|
+
(PowerShell), or with `&&` in a POSIX shell.
|
|
623
|
+
|
|
585
624
|
## Licence
|
|
586
625
|
|
|
587
626
|
`@firefunc-agent/runner` is the **client** half of FireFunc, published so the machines
|
|
@@ -607,6 +646,17 @@ A workspace can manage its machines from Settings → Machines (or the API):
|
|
|
607
646
|
so its service starts the new version. It only does this as the installed service
|
|
608
647
|
(`firefunc-runner install`) and not from npx's cache; otherwise it says why and keeps running.
|
|
609
648
|
A failed install leaves the old version running and reports npm's last lines.
|
|
649
|
+
- **Update in one step.** `firefunc-runner update` installs the newest runner the way it was
|
|
650
|
+
installed and restarts into it once no run is held. It is the same in PowerShell, zsh and
|
|
651
|
+
bash. It prints the old and new version and "restarted", or says why it could not and the fix.
|
|
652
|
+
- **Updates install themselves.** A machine running as the installed service updates itself when
|
|
653
|
+
idle, within an hour of a new version on npm, unless the workspace (Admin › Policies ›
|
|
654
|
+
Machines) or the machine's own page turns it off. A failed update shows in the Bell with npm's
|
|
655
|
+
words.
|
|
656
|
+
- **A newer runner is out.** At start and once a day the runner asks npm for the newest version
|
|
657
|
+
(only the package name is sent). When one is newer, its log and `firefunc-runner status` say
|
|
658
|
+
so in one line, with `firefunc-runner update`. `FIREFUNC_RUNNER_NO_UPDATE_CHECK=1` turns the
|
|
659
|
+
check off.
|
|
610
660
|
- **Token lifetime and rotation.** A workspace can give machine tokens a lifetime and a
|
|
611
661
|
pairing window. The runner replaces its token on its own when a third of its life is left,
|
|
612
662
|
or when a person asks; the old token works for one more hour. An expired token stops the
|
package/dist/api.d.ts
CHANGED
|
@@ -89,7 +89,7 @@ export type ClaimedJob = {
|
|
|
89
89
|
mcpConfig?: unknown;
|
|
90
90
|
maxMinutes?: number | null;
|
|
91
91
|
};
|
|
92
|
-
export type RunnerEvent = 'cloning' | 'fixing' | 'pushing' | 'pr_opened' | 'heartbeat' | 'log' | 'checkpoint' | 'worktree';
|
|
92
|
+
export type RunnerEvent = 'cloning' | 'fixing' | 'pushing' | 'pr_opened' | 'heartbeat' | 'log' | 'checkpoint' | 'worktree' | 'mcp_setup';
|
|
93
93
|
export type PlanLimitReport = {
|
|
94
94
|
kind: 'plan';
|
|
95
95
|
resetsAt: string | null;
|
package/dist/brief-file.d.ts
CHANGED
package/dist/brief-file.js
CHANGED
|
@@ -33,4 +33,10 @@ export function fenceBrief(inv, prompt, opts) {
|
|
|
33
33
|
args[at] = briefPointer(file);
|
|
34
34
|
return { invocation: { ...inv, args }, file, exposed: false };
|
|
35
35
|
}
|
|
36
|
+
export function refuseExposedOnWindows(fence, engine, platform = process.platform) {
|
|
37
|
+
if (fence.exposed && fence.invocation.shell && platform === 'win32') {
|
|
38
|
+
throw new Error(`${engine} takes its brief on the command line, and the runner could not write it to the run's .firefunc/brief folder, so the run was not started: on Windows the task's words would go through cmd.exe. Fix: check that the runner's user can write the repository checkout, then re-run the task.`);
|
|
39
|
+
}
|
|
40
|
+
return fence.invocation;
|
|
41
|
+
}
|
|
36
42
|
//# sourceMappingURL=brief-file.js.map
|
package/dist/build-info.json
CHANGED
package/dist/cli.js
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
import { configPath, drainSetting, expandHome, isDraining, loadConfig, runnerDir, saveConfig, editorsAllowed, } from './config.js';
|
|
3
3
|
import { startDaemon } from './daemon.js';
|
|
4
4
|
import { restartWhenIdle } from './restart-idle.js';
|
|
5
|
+
import { installedRunnerVersion, runQuiet, unknownWords, updateRunner } from './update.js';
|
|
6
|
+
import { endLiveRunner, startRunner, stopRunner, versionGapWords, } from './live-runner.js';
|
|
5
7
|
import { heldByLiveProcesses } from './held.js';
|
|
6
8
|
import { runBrief } from './brief.js';
|
|
7
9
|
import { runMcpList, runMcpLogin, runMcpLogout } from './mcp-login.js';
|
|
@@ -9,7 +11,8 @@ import { RUNNER_VERSION } from './version.js';
|
|
|
9
11
|
import { availableEngines, getAdapter } from './engines/index.js';
|
|
10
12
|
import { engineBlocks, unattendedContext } from './unattended.js';
|
|
11
13
|
import { engineLoginBlock } from './engine-login.js';
|
|
12
|
-
import { liveRunner, liveRunnerWords, readAlive } from './alive.js';
|
|
14
|
+
import { liveRunner, liveRunnerWords, pidAlive, readAlive } from './alive.js';
|
|
15
|
+
import { newerRunnerLine, readLatestRunner } from './newer-runner.js';
|
|
13
16
|
import { setWorkDir, workDirFailure, workDirWords } from './work-dir.js';
|
|
14
17
|
import { diskOf } from './resources.js';
|
|
15
18
|
import { currentPlatform, defaultServiceDeps, EPHEMERAL_INSTALL_MESSAGE, installService, isEphemeralInstall, readLogTail, renderLaunchdPlist, renderSystemdUnit, renderWindowsLauncher, renderWindowsTaskXml, serviceStatus, serviceWords, servicePaths, startService, stopService, uninstallService, } from './service.js';
|
|
@@ -37,6 +40,8 @@ Usage:
|
|
|
37
40
|
(the machine stays online); safe to update or
|
|
38
41
|
restart once the log says "drained"
|
|
39
42
|
firefunc-runner resume Take work again after a drain
|
|
43
|
+
firefunc-runner update Install the newest runner and restart into it
|
|
44
|
+
once no run is held (one step, any shell)
|
|
40
45
|
firefunc-runner restart --when-idle Drain, wait until no run is held, restart the
|
|
41
46
|
service, then take work again
|
|
42
47
|
(--max-wait <minutes> gives up after that)
|
|
@@ -388,11 +393,52 @@ async function main() {
|
|
|
388
393
|
: 'Resumed: the runner takes work again within a minute.\n');
|
|
389
394
|
return;
|
|
390
395
|
}
|
|
396
|
+
if (cmd === 'update') {
|
|
397
|
+
const unknown = unknownWords(rest, ['--max-wait']);
|
|
398
|
+
if (unknown) {
|
|
399
|
+
process.stderr.write(`firefunc-runner update did not understand "${unknown}". Run it on its own: firefunc-runner update\n`);
|
|
400
|
+
process.exitCode = 1;
|
|
401
|
+
return;
|
|
402
|
+
}
|
|
403
|
+
const os = currentPlatform();
|
|
404
|
+
const deps = defaultServiceDeps('', os);
|
|
405
|
+
const res = await updateRunner({
|
|
406
|
+
current: RUNNER_VERSION,
|
|
407
|
+
running: () => {
|
|
408
|
+
const rec = readAlive(runnerDir());
|
|
409
|
+
return rec && pidAlive(rec.pid) && rec.version ? rec.version : null;
|
|
410
|
+
},
|
|
411
|
+
latest: () => readLatestRunner(),
|
|
412
|
+
scriptPath: process.argv[1] ?? '',
|
|
413
|
+
service: {
|
|
414
|
+
installed: async () => (await serviceStatus(deps)).installed,
|
|
415
|
+
stop: async () => {
|
|
416
|
+
const r = await stopRunner(liveRunnerDeps(deps));
|
|
417
|
+
return r;
|
|
418
|
+
},
|
|
419
|
+
start: async (want) => startRunner(liveRunnerDeps(deps), want),
|
|
420
|
+
},
|
|
421
|
+
run: runQuiet,
|
|
422
|
+
installedVersion: installedRunnerVersion,
|
|
423
|
+
load: loadConfig,
|
|
424
|
+
save: saveConfig,
|
|
425
|
+
held: () => heldByLiveProcesses(runnerDir()),
|
|
426
|
+
sleep: (ms) => new Promise((r) => setTimeout(r, ms)),
|
|
427
|
+
now: () => Date.now(),
|
|
428
|
+
log: (line) => process.stdout.write(`${line}\n`),
|
|
429
|
+
});
|
|
430
|
+
(res.ok ? process.stdout : process.stderr).write(`${res.message}\n`);
|
|
431
|
+
if (!res.ok)
|
|
432
|
+
process.exitCode = 1;
|
|
433
|
+
return;
|
|
434
|
+
}
|
|
391
435
|
if (cmd === 'restart') {
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
' To
|
|
436
|
+
const unknown = unknownWords(rest, ['--when-idle', '--max-wait']);
|
|
437
|
+
if (unknown) {
|
|
438
|
+
process.stderr.write(`firefunc-runner restart did not understand "${unknown}".\n` +
|
|
439
|
+
' To update and restart in one step: firefunc-runner update\n' +
|
|
440
|
+
' To restart once no run is held: firefunc-runner restart --when-idle\n' +
|
|
441
|
+
' To restart at once, cutting the runs in flight short: firefunc-runner start-service\n');
|
|
396
442
|
process.exitCode = 1;
|
|
397
443
|
return;
|
|
398
444
|
}
|
|
@@ -413,10 +459,11 @@ async function main() {
|
|
|
413
459
|
const installed = (await serviceStatus(deps)).installed;
|
|
414
460
|
if (!installed)
|
|
415
461
|
return { ok: false, installed, message: '' };
|
|
416
|
-
const
|
|
462
|
+
const live = liveRunnerDeps(deps);
|
|
463
|
+
const stopped = await stopRunner(live);
|
|
417
464
|
if (!stopped.ok)
|
|
418
465
|
return { ...stopped, installed };
|
|
419
|
-
return { ...(await
|
|
466
|
+
return { ...(await startRunner(live, RUNNER_VERSION)), installed };
|
|
420
467
|
},
|
|
421
468
|
sleep: (ms) => new Promise((r) => setTimeout(r, ms)),
|
|
422
469
|
now: () => Date.now(),
|
|
@@ -479,7 +526,15 @@ async function main() {
|
|
|
479
526
|
const svc = await serviceStatus(deps);
|
|
480
527
|
const live = liveRunner(readAlive(runnerDir()));
|
|
481
528
|
process.stdout.write(`\n${liveRunnerWords(live, { logPath: svc.log, os })}`);
|
|
529
|
+
const gap = live.state === 'running' ? versionGapWords(RUNNER_VERSION, live.rec) : null;
|
|
530
|
+
if (gap)
|
|
531
|
+
process.stdout.write(gap);
|
|
482
532
|
process.stdout.write(serviceWords(svc, os, live.state === 'running'));
|
|
533
|
+
const newer = newerRunnerLine(RUNNER_VERSION, process.env.FIREFUNC_RUNNER_NO_UPDATE_CHECK === '1'
|
|
534
|
+
? null
|
|
535
|
+
: await readLatestRunner({ timeoutMs: 3_000 }), svc.installed);
|
|
536
|
+
if (newer)
|
|
537
|
+
process.stdout.write(`\n${newer}\n`);
|
|
483
538
|
return;
|
|
484
539
|
}
|
|
485
540
|
if (cmd === 'cloud-boot') {
|
|
@@ -555,13 +610,18 @@ async function main() {
|
|
|
555
610
|
return;
|
|
556
611
|
}
|
|
557
612
|
}
|
|
613
|
+
const live = liveRunnerDeps(deps);
|
|
558
614
|
const res = cmd === 'install'
|
|
559
615
|
? await installService(deps)
|
|
560
616
|
: cmd === 'uninstall'
|
|
561
|
-
? await
|
|
617
|
+
? await (async () => {
|
|
618
|
+
const r = await uninstallService(deps);
|
|
619
|
+
const ended = await endLiveRunner(live);
|
|
620
|
+
return ended.ok ? r : { ok: false, message: `${r.message}\n${ended.message}` };
|
|
621
|
+
})()
|
|
562
622
|
: cmd === 'stop'
|
|
563
|
-
? await
|
|
564
|
-
: await
|
|
623
|
+
? await stopRunner(live)
|
|
624
|
+
: await startRunner(live, RUNNER_VERSION);
|
|
565
625
|
process.stdout.write(`${res.message}\n`);
|
|
566
626
|
if (!res.ok)
|
|
567
627
|
process.exitCode = 1;
|
|
@@ -570,5 +630,19 @@ async function main() {
|
|
|
570
630
|
process.stderr.write(`Unknown command "${cmd}".\n\n${HELP}`);
|
|
571
631
|
process.exitCode = 1;
|
|
572
632
|
}
|
|
633
|
+
function liveRunnerDeps(svc) {
|
|
634
|
+
return {
|
|
635
|
+
os: currentPlatform(),
|
|
636
|
+
readAlive: () => readAlive(runnerDir()),
|
|
637
|
+
pidAlive,
|
|
638
|
+
exec: (cmd, args) => runQuiet(cmd, args).then((r) => ({ code: r.code, out: r.output })),
|
|
639
|
+
signal: (pid, sig) => {
|
|
640
|
+
process.kill(pid, sig);
|
|
641
|
+
},
|
|
642
|
+
service: { stop: () => stopService(svc), start: () => startService(svc) },
|
|
643
|
+
sleep: (ms) => new Promise((r) => setTimeout(r, ms)),
|
|
644
|
+
now: () => Date.now(),
|
|
645
|
+
};
|
|
646
|
+
}
|
|
573
647
|
void main();
|
|
574
648
|
//# sourceMappingURL=cli.js.map
|
package/dist/daemon.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { readEngineModels } from './engine-models.js';
|
|
2
|
+
import { windowsRestartLater } from './live-runner.js';
|
|
3
|
+
import { WINDOWS_TASK_NAME } from './service.js';
|
|
4
|
+
import { NEWER_RUNNER_CHECK_MS, newerRunnerLine, readLatestRunner } from './newer-runner.js';
|
|
2
5
|
import { reportWorktree } from './worktree-report.js';
|
|
3
6
|
import { createEditorSessions } from './editor/sessions.js';
|
|
4
7
|
import { worktreeOfRun } from './editor/worktree-of.js';
|
|
@@ -44,6 +47,7 @@ import { clearAlive, writeAlive } from './alive.js';
|
|
|
44
47
|
import { backoffAfterFailure, describeTransportError, isTransportFailure, rebuildGlobalDispatcher, TRANSPORT_REBUILD_AFTER, TransportWatchdog, } from './transport.js';
|
|
45
48
|
import { setWorkDir, workDirProblem, workRoots } from './work-dir.js';
|
|
46
49
|
import { removeRunTemp, staleRunTemps, tempRoot } from './run-temp.js';
|
|
50
|
+
import { shellSafe } from './win-shell.js';
|
|
47
51
|
function log(msg) {
|
|
48
52
|
console.log(`[firefunc-runner] ${new Date().toISOString()} ${blankSecrets(msg)}`);
|
|
49
53
|
}
|
|
@@ -175,6 +179,7 @@ export async function startDaemon(cfg) {
|
|
|
175
179
|
hostname: hostname(),
|
|
176
180
|
platform: platform(),
|
|
177
181
|
viewerPort,
|
|
182
|
+
service: !!process.env.FIREFUNC_RUNNER_SERVICE,
|
|
178
183
|
};
|
|
179
184
|
let stopping = false;
|
|
180
185
|
const viewer = cfg.viewerEnabled === false
|
|
@@ -383,10 +388,8 @@ export async function startDaemon(cfg) {
|
|
|
383
388
|
return was;
|
|
384
389
|
},
|
|
385
390
|
install: (spec) => new Promise((resolve) => {
|
|
386
|
-
const
|
|
387
|
-
|
|
388
|
-
windowsHide: true,
|
|
389
|
-
});
|
|
391
|
+
const line = shellSafe('npm', ['install', '-g', spec], process.platform === 'win32');
|
|
392
|
+
const child = spawn(line.cmd, line.args, { shell: line.shell, windowsHide: true });
|
|
390
393
|
let output = '';
|
|
391
394
|
const keep = (b) => {
|
|
392
395
|
output = (output + b.toString('utf8')).slice(-4_000);
|
|
@@ -403,7 +406,23 @@ export async function startDaemon(cfg) {
|
|
|
403
406
|
resolve({ code: code ?? -1, output });
|
|
404
407
|
});
|
|
405
408
|
}),
|
|
406
|
-
exit: (code) =>
|
|
409
|
+
exit: (code) => {
|
|
410
|
+
if (process.platform === 'win32' && process.env.FIREFUNC_RUNNER_SERVICE === '1') {
|
|
411
|
+
try {
|
|
412
|
+
const later = windowsRestartLater(WINDOWS_TASK_NAME);
|
|
413
|
+
spawn(later.cmd, later.args, {
|
|
414
|
+
detached: true,
|
|
415
|
+
stdio: 'ignore',
|
|
416
|
+
windowsHide: true,
|
|
417
|
+
}).unref();
|
|
418
|
+
log('asked Task Scheduler to start the new version in a few seconds');
|
|
419
|
+
}
|
|
420
|
+
catch (err) {
|
|
421
|
+
log(`could not ask Task Scheduler to restart it: ${err.message}`);
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
process.exit(code);
|
|
425
|
+
},
|
|
407
426
|
log,
|
|
408
427
|
});
|
|
409
428
|
const onUpgrade = (cmd) => {
|
|
@@ -479,6 +498,17 @@ export async function startDaemon(cfg) {
|
|
|
479
498
|
};
|
|
480
499
|
readModels();
|
|
481
500
|
setInterval(readModels, 60 * 60_000).unref();
|
|
501
|
+
const sayNewer = () => {
|
|
502
|
+
void readLatestRunner().then((latest) => {
|
|
503
|
+
const line = newerRunnerLine(RUNNER_VERSION, latest, alive.service);
|
|
504
|
+
if (line)
|
|
505
|
+
log(line);
|
|
506
|
+
});
|
|
507
|
+
};
|
|
508
|
+
if (process.env.FIREFUNC_RUNNER_NO_UPDATE_CHECK !== '1') {
|
|
509
|
+
sayNewer();
|
|
510
|
+
setInterval(sayNewer, NEWER_RUNNER_CHECK_MS).unref();
|
|
511
|
+
}
|
|
482
512
|
try {
|
|
483
513
|
const checkouts = Object.values(cfg.repos ?? {}).filter((p) => existsSync(p));
|
|
484
514
|
const removed = await sweepLeftoverWorktrees(checkouts, {
|
package/dist/engine-login.js
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
import { spawnSync } from 'node:child_process';
|
|
2
2
|
import { claudeApiKeyNow } from './api-fallback.js';
|
|
3
|
+
import { shellSafe } from './win-shell.js';
|
|
3
4
|
export const spawnLoginProbe = (bin, args, env) => {
|
|
4
5
|
try {
|
|
5
6
|
const clean = {};
|
|
6
7
|
for (const [k, v] of Object.entries(env))
|
|
7
8
|
if (typeof v === 'string')
|
|
8
9
|
clean[k] = v;
|
|
9
|
-
const
|
|
10
|
+
const line = shellSafe(bin, args, process.platform === 'win32', clean);
|
|
11
|
+
const res = spawnSync(line.cmd, line.args, {
|
|
10
12
|
env: clean,
|
|
11
13
|
encoding: 'utf8',
|
|
12
14
|
timeout: 5_000,
|
|
13
15
|
stdio: ['ignore', 'pipe', 'ignore'],
|
|
14
16
|
windowsHide: true,
|
|
15
|
-
shell:
|
|
17
|
+
shell: line.shell,
|
|
16
18
|
});
|
|
17
19
|
if (res.error)
|
|
18
20
|
return null;
|
package/dist/engine-models.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { execFile } from 'node:child_process';
|
|
2
2
|
import { getAdapter, OPEN_PROVIDER_KEY_VARS } from './engines/index.js';
|
|
3
|
+
import { shellSafe } from './win-shell.js';
|
|
3
4
|
const MAX_MODELS = 400;
|
|
4
5
|
const MODEL_ID = /^[A-Za-z0-9~][A-Za-z0-9._:/@[\]~+-]{0,119}$/;
|
|
5
6
|
const ANSI = /\u001b\[[0-9;]*m/g;
|
|
@@ -60,10 +61,11 @@ export async function readEngineModels(cfg, ids, run = runLister, env = process.
|
|
|
60
61
|
}
|
|
61
62
|
function runLister(bin, args) {
|
|
62
63
|
return new Promise((resolve) => {
|
|
63
|
-
|
|
64
|
+
const line = shellSafe(bin, args, process.platform === 'win32');
|
|
65
|
+
execFile(line.cmd, line.args, {
|
|
64
66
|
timeout: 30_000,
|
|
65
67
|
windowsHide: true,
|
|
66
|
-
shell:
|
|
68
|
+
shell: line.shell,
|
|
67
69
|
maxBuffer: 4 * 1024 * 1024,
|
|
68
70
|
}, (_err, stdout) => resolve(String(stdout ?? '')));
|
|
69
71
|
});
|
package/dist/engines/index.js
CHANGED
|
@@ -14,6 +14,7 @@ import { qwenAdapter } from './qwen.js';
|
|
|
14
14
|
import { crushAdapter } from './crush.js';
|
|
15
15
|
import { openhandsAdapter } from './openhands.js';
|
|
16
16
|
import { parseCliVersion } from '../fleet-words.js';
|
|
17
|
+
import { shellSafe } from '../win-shell.js';
|
|
17
18
|
export { claudeAdapter } from './claude.js';
|
|
18
19
|
export { codexAdapter } from './codex.js';
|
|
19
20
|
export { geminiAdapter } from './gemini.js';
|
|
@@ -147,10 +148,11 @@ export async function readEngineVersions(cfg, ids, run = runVersion) {
|
|
|
147
148
|
}
|
|
148
149
|
function runVersion(bin) {
|
|
149
150
|
return new Promise((resolve) => {
|
|
150
|
-
|
|
151
|
+
const line = shellSafe(bin, ['--version'], process.platform === 'win32');
|
|
152
|
+
execFile(line.cmd, line.args, {
|
|
151
153
|
timeout: 8_000,
|
|
152
154
|
windowsHide: true,
|
|
153
|
-
shell:
|
|
155
|
+
shell: line.shell,
|
|
154
156
|
maxBuffer: 64 * 1024,
|
|
155
157
|
}, (_err, stdout, stderr) => resolve(`${stdout ?? ''}\n${stderr ?? ''}`.slice(0, 2_000)));
|
|
156
158
|
});
|
package/dist/exec.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { spawn } from 'node:child_process';
|
|
2
2
|
import { constants } from 'node:os';
|
|
3
|
+
import { shellSafe } from './win-shell.js';
|
|
3
4
|
export function signalExitCode(signal) {
|
|
4
5
|
const n = signal ? constants.signals[signal] : undefined;
|
|
5
6
|
return typeof n === 'number' ? 128 + n : 1;
|
|
@@ -52,9 +53,11 @@ export async function killProcessTree(child) {
|
|
|
52
53
|
export function exec(cmd, args, opts = {}) {
|
|
53
54
|
return new Promise((resolve, reject) => {
|
|
54
55
|
const grouped = opts.ownGroup === true && process.platform !== 'win32';
|
|
55
|
-
const
|
|
56
|
+
const env = mergeEnv(opts.env);
|
|
57
|
+
const line = shellSafe(cmd, args, opts.shell, env);
|
|
58
|
+
const child = spawn(line.cmd, line.args, {
|
|
56
59
|
cwd: opts.cwd,
|
|
57
|
-
env
|
|
60
|
+
env,
|
|
58
61
|
stdio: [opts.input != null ? 'pipe' : 'ignore', 'pipe', 'pipe'],
|
|
59
62
|
shell: opts.shell,
|
|
60
63
|
detached: grouped,
|
|
@@ -273,6 +273,28 @@ export const automationCommands = [
|
|
|
273
273
|
ctx.io.stdout.write(rows.length ? `${rows.map(runLine).join('\n')}\n` : 'No runs yet.\n');
|
|
274
274
|
},
|
|
275
275
|
},
|
|
276
|
+
{
|
|
277
|
+
path: ['automations', 'retry-from'],
|
|
278
|
+
summary: 'Start an ended run again from one of its steps',
|
|
279
|
+
usage: 'automations retry-from <run id> --step <key>',
|
|
280
|
+
details: 'The steps before it keep their results. The run uses the version published now when that version still has the step, so a fix you published is used. Needs a role that may edit the automation.',
|
|
281
|
+
positional: { min: 1, max: 1 },
|
|
282
|
+
flags: { step: 'string' },
|
|
283
|
+
flagHelp: [['--step <key>', "the step's key, as `automations run-get` lists it"]],
|
|
284
|
+
async run(ctx) {
|
|
285
|
+
const id = ctx.args.positional[0];
|
|
286
|
+
const step = str(ctx.args, 'step');
|
|
287
|
+
if (!step)
|
|
288
|
+
throw new UsageError('--step <key> is required: the step to start from.');
|
|
289
|
+
const body = await ctx.api().post(`/api/v1/automation-runs/${enc(id)}/retry-from`, {
|
|
290
|
+
step,
|
|
291
|
+
});
|
|
292
|
+
if (ctx.json)
|
|
293
|
+
return printJson(ctx.io, body);
|
|
294
|
+
const r = body.run ?? body;
|
|
295
|
+
ctx.io.stdout.write(`Run #${text(r.number)} starts again from ${step}. Follow it: firefunc automations run-get ${text(r.id ?? id)}\n`);
|
|
296
|
+
},
|
|
297
|
+
},
|
|
276
298
|
{
|
|
277
299
|
path: ['automations', 'run-get'],
|
|
278
300
|
summary: 'One run: its state and each step',
|
package/dist/firefunc/catalog.js
CHANGED
|
@@ -75,7 +75,7 @@ function printConnections(ctx, body) {
|
|
|
75
75
|
head: 'ACCOUNTS',
|
|
76
76
|
get: (r) => (r.accounts ?? []).map((a) => {
|
|
77
77
|
const where = (a.boundTo ?? []).map((b) => b.projectName).filter(Boolean);
|
|
78
|
-
return `${text(a.label)}${where.length ? ` (${where.join(', ')})` : ''}`;
|
|
78
|
+
return `${text(a.label)}${a.failing ? ' [sign-in failing]' : ''}${where.length ? ` (${where.join(', ')})` : ''}`;
|
|
79
79
|
}),
|
|
80
80
|
max: 45,
|
|
81
81
|
},
|
|
@@ -84,6 +84,13 @@ function printConnections(ctx, body) {
|
|
|
84
84
|
];
|
|
85
85
|
if (tools.length)
|
|
86
86
|
table(io, tools, cols);
|
|
87
|
+
const failing = tools.flatMap((t) => (t.accounts ?? []).filter((a) => a.failing).map((a) => ({ tool: t, a })));
|
|
88
|
+
if (failing.length) {
|
|
89
|
+
io.stdout.write('\nSign-in failing:\n');
|
|
90
|
+
for (const { tool, a } of failing) {
|
|
91
|
+
io.stdout.write(` ${text(tool.label ?? tool.tool)} · ${text(a.label)}${a.failing?.since ? ` (since ${text(a.failing.since).slice(0, 10)})` : ''}: ${text(a.failing?.reason)}\n Fix: ${text(a.failing?.fix)}\n`);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
87
94
|
const servers = listIn(body, 'mcpServers');
|
|
88
95
|
if (servers.length) {
|
|
89
96
|
io.stdout.write('\nMCP servers lent to this workspace (grant one by its slug in tool_grants):\n');
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { str } from './args.js';
|
|
2
|
+
import { listIn } from './catalog.js';
|
|
3
|
+
import { enc } from './command.js';
|
|
4
|
+
import { printJson, table, text } from './output.js';
|
|
5
|
+
export const machineCommands = [
|
|
6
|
+
{
|
|
7
|
+
path: ['machines', 'list'],
|
|
8
|
+
summary: 'The machines paired to this workspace: status, OS, labels, engines',
|
|
9
|
+
usage: 'machines list',
|
|
10
|
+
async run(ctx) {
|
|
11
|
+
const body = await ctx.api().get('/api/v1/machines');
|
|
12
|
+
if (ctx.json)
|
|
13
|
+
return printJson(ctx.io, body);
|
|
14
|
+
const rows = listIn(body, 'machines');
|
|
15
|
+
if (!rows.length) {
|
|
16
|
+
ctx.io.stdout.write('No machine is paired yet. Add one in FireFunc: Machines > Add a machine.\n');
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
table(ctx.io, rows, [
|
|
20
|
+
{ head: 'ID', get: (m) => m.id },
|
|
21
|
+
{ head: 'NAME', get: (m) => m.name },
|
|
22
|
+
{ head: 'STATUS', get: (m) => m.status },
|
|
23
|
+
{ head: 'OS', get: (m) => m.os },
|
|
24
|
+
{ head: 'RUNNING', get: (m) => `${text(m.running)}/${text(m.maxParallel)}` },
|
|
25
|
+
{
|
|
26
|
+
head: 'LABELS',
|
|
27
|
+
get: (m) => (Array.isArray(m.labels) ? m.labels : []).join(',') || '-',
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
head: 'ENGINES',
|
|
31
|
+
get: (m) => (Array.isArray(m.engines) ? m.engines : [])
|
|
32
|
+
.map((e) => text(e.engine).replace(/_channel$/, ''))
|
|
33
|
+
.join(','),
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
head: 'RUNNER',
|
|
37
|
+
get: (m) => {
|
|
38
|
+
const r = (m.runner ?? null);
|
|
39
|
+
if (!r?.version)
|
|
40
|
+
return '-';
|
|
41
|
+
return r.behind ? `${text(r.version)} (${text(r.latest)} is out)` : text(r.version);
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
]);
|
|
45
|
+
const behind = rows.filter((m) => (m.runner ?? null)?.update);
|
|
46
|
+
if (behind.length) {
|
|
47
|
+
ctx.io.stdout.write('\nA newer runner is out:\n');
|
|
48
|
+
for (const m of behind) {
|
|
49
|
+
const u = m.runner.update;
|
|
50
|
+
ctx.io.stdout.write(` ${text(m.name)}: ${text(u.from)} -> ${text(u.to)}\n`);
|
|
51
|
+
if (u.notes)
|
|
52
|
+
ctx.io.stdout.write(` What changed: ${text(u.notes)}\n`);
|
|
53
|
+
ctx.io.stdout.write(` ${text(u.how)}\n`);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
path: ['machines', 'labels'],
|
|
60
|
+
summary: "A machine's labels, or set them",
|
|
61
|
+
usage: 'machines labels <machine id> [--set <label,label,…>]',
|
|
62
|
+
details: 'With --set, the whole list it carries afterwards ("" removes them all); needs workspace:configure and a role that may connect machines. Agents, tasks and steps route to machines by label.',
|
|
63
|
+
positional: { min: 1, max: 1 },
|
|
64
|
+
flags: { set: 'string' },
|
|
65
|
+
flagHelp: [['--set <labels>', 'comma-separated: replaces every label it carries']],
|
|
66
|
+
async run(ctx) {
|
|
67
|
+
const id = ctx.args.positional[0];
|
|
68
|
+
const set = str(ctx.args, 'set');
|
|
69
|
+
const path = `/api/v1/machines/${enc(id)}/labels`;
|
|
70
|
+
const body = set === undefined
|
|
71
|
+
? await ctx.api().get(path)
|
|
72
|
+
: await ctx.api().put(path, {
|
|
73
|
+
labels: set
|
|
74
|
+
.split(',')
|
|
75
|
+
.map((l) => l.trim())
|
|
76
|
+
.filter(Boolean),
|
|
77
|
+
});
|
|
78
|
+
if (ctx.json)
|
|
79
|
+
return printJson(ctx.io, body);
|
|
80
|
+
const labels = Array.isArray(body.labels) ? body.labels : [];
|
|
81
|
+
ctx.io.stdout.write(`${text(body.name)}: ${labels.length ? labels.join(', ') : 'no label'}\n`);
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
];
|
|
85
|
+
//# sourceMappingURL=machines.js.map
|
package/dist/firefunc/main.js
CHANGED
|
@@ -12,6 +12,8 @@ import { printError } from './output.js';
|
|
|
12
12
|
import { PromptCancelled } from './prompt.js';
|
|
13
13
|
import { skillCommands } from './skill.js';
|
|
14
14
|
import { taskCommands } from './tasks.js';
|
|
15
|
+
import { machineCommands } from './machines.js';
|
|
16
|
+
import { webhookCommands } from './webhooks.js';
|
|
15
17
|
import { CLI_VERSION } from './version.js';
|
|
16
18
|
export const COMMANDS = [
|
|
17
19
|
...authCommands,
|
|
@@ -19,6 +21,8 @@ export const COMMANDS = [
|
|
|
19
21
|
...agentCommands,
|
|
20
22
|
...taskCommands,
|
|
21
23
|
...automationCommands,
|
|
24
|
+
...machineCommands,
|
|
25
|
+
...webhookCommands,
|
|
22
26
|
...configureCommands,
|
|
23
27
|
...skillCommands,
|
|
24
28
|
];
|
|
@@ -30,6 +34,8 @@ const GROUPS = [
|
|
|
30
34
|
'agents',
|
|
31
35
|
'tasks',
|
|
32
36
|
'automations',
|
|
37
|
+
'machines',
|
|
38
|
+
'webhooks',
|
|
33
39
|
'skill',
|
|
34
40
|
];
|
|
35
41
|
const SECTIONS = [
|
|
@@ -63,8 +69,11 @@ const SECTIONS = [
|
|
|
63
69
|
'automations run',
|
|
64
70
|
'automations runs',
|
|
65
71
|
'automations run-get',
|
|
72
|
+
'automations retry-from',
|
|
66
73
|
],
|
|
67
74
|
],
|
|
75
|
+
['Machines', ['machines list', 'machines labels']],
|
|
76
|
+
['Inbound webhooks', ['webhooks list', 'webhooks create', 'webhooks rotate']],
|
|
68
77
|
[
|
|
69
78
|
'Configure the workspace (writes need workspace:configure)',
|
|
70
79
|
[
|
package/dist/firefunc/tasks.js
CHANGED
|
@@ -81,6 +81,8 @@ function printTask(ctx, t) {
|
|
|
81
81
|
lines.push(` outputs: ${outputs.length}`);
|
|
82
82
|
for (const o of outputs) {
|
|
83
83
|
lines.push(...wrap(outputWords(o), 76, ' - ', ' '));
|
|
84
|
+
if (o.status === 'succeeded' && typeof o.answer === 'string' && o.answer)
|
|
85
|
+
lines.push(...wrap(o.answer, 74, ' answered: ', ' '));
|
|
84
86
|
if (o.status !== 'succeeded' && typeof o.reason === 'string' && o.reason)
|
|
85
87
|
lines.push(...wrap(o.reason, 74, ' why: ', ' '));
|
|
86
88
|
if (o.status !== 'succeeded' && typeof o.fix === 'string' && o.fix)
|