@firefunc-agent/runner 0.9.35 → 0.9.36
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 +39 -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/daemon.js +3 -4
- 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 +65 -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/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/pool.d.ts +2 -0
- package/dist/pool.js +12 -1
- 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
|
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/daemon.js
CHANGED
|
@@ -44,6 +44,7 @@ import { clearAlive, writeAlive } from './alive.js';
|
|
|
44
44
|
import { backoffAfterFailure, describeTransportError, isTransportFailure, rebuildGlobalDispatcher, TRANSPORT_REBUILD_AFTER, TransportWatchdog, } from './transport.js';
|
|
45
45
|
import { setWorkDir, workDirProblem, workRoots } from './work-dir.js';
|
|
46
46
|
import { removeRunTemp, staleRunTemps, tempRoot } from './run-temp.js';
|
|
47
|
+
import { shellSafe } from './win-shell.js';
|
|
47
48
|
function log(msg) {
|
|
48
49
|
console.log(`[firefunc-runner] ${new Date().toISOString()} ${blankSecrets(msg)}`);
|
|
49
50
|
}
|
|
@@ -383,10 +384,8 @@ export async function startDaemon(cfg) {
|
|
|
383
384
|
return was;
|
|
384
385
|
},
|
|
385
386
|
install: (spec) => new Promise((resolve) => {
|
|
386
|
-
const
|
|
387
|
-
|
|
388
|
-
windowsHide: true,
|
|
389
|
-
});
|
|
387
|
+
const line = shellSafe('npm', ['install', '-g', spec], process.platform === 'win32');
|
|
388
|
+
const child = spawn(line.cmd, line.args, { shell: line.shell, windowsHide: true });
|
|
390
389
|
let output = '';
|
|
391
390
|
const keep = (b) => {
|
|
392
391
|
output = (output + b.toString('utf8')).slice(-4_000);
|
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,65 @@
|
|
|
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
|
+
},
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
path: ['machines', 'labels'],
|
|
40
|
+
summary: "A machine's labels, or set them",
|
|
41
|
+
usage: 'machines labels <machine id> [--set <label,label,…>]',
|
|
42
|
+
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.',
|
|
43
|
+
positional: { min: 1, max: 1 },
|
|
44
|
+
flags: { set: 'string' },
|
|
45
|
+
flagHelp: [['--set <labels>', 'comma-separated: replaces every label it carries']],
|
|
46
|
+
async run(ctx) {
|
|
47
|
+
const id = ctx.args.positional[0];
|
|
48
|
+
const set = str(ctx.args, 'set');
|
|
49
|
+
const path = `/api/v1/machines/${enc(id)}/labels`;
|
|
50
|
+
const body = set === undefined
|
|
51
|
+
? await ctx.api().get(path)
|
|
52
|
+
: await ctx.api().put(path, {
|
|
53
|
+
labels: set
|
|
54
|
+
.split(',')
|
|
55
|
+
.map((l) => l.trim())
|
|
56
|
+
.filter(Boolean),
|
|
57
|
+
});
|
|
58
|
+
if (ctx.json)
|
|
59
|
+
return printJson(ctx.io, body);
|
|
60
|
+
const labels = Array.isArray(body.labels) ? body.labels : [];
|
|
61
|
+
ctx.io.stdout.write(`${text(body.name)}: ${labels.length ? labels.join(', ') : 'no label'}\n`);
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
];
|
|
65
|
+
//# 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)
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { str, UsageError } from './args.js';
|
|
2
|
+
import { listIn, resolveProjectId } from './catalog.js';
|
|
3
|
+
import { enc } from './command.js';
|
|
4
|
+
import { printJson, table, text } from './output.js';
|
|
5
|
+
function printToken(ctx, body, what) {
|
|
6
|
+
const h = body.webhook ?? {};
|
|
7
|
+
ctx.io.stdout.write([
|
|
8
|
+
`${what} "${text(h.name)}" (${text(h.id)}).`,
|
|
9
|
+
`Send deliveries to: ${ctx.credentials().apiUrl}${text(h.path)}`,
|
|
10
|
+
`Token (shown this once, keep it): ${text(body.token)}`,
|
|
11
|
+
'Send it as "Authorization: Bearer <token>" or ?token=<token>.',
|
|
12
|
+
].join('\n') + '\n');
|
|
13
|
+
}
|
|
14
|
+
export const webhookCommands = [
|
|
15
|
+
{
|
|
16
|
+
path: ['webhooks', 'list'],
|
|
17
|
+
summary: "The workspace's inbound webhooks",
|
|
18
|
+
usage: 'webhooks list',
|
|
19
|
+
async run(ctx) {
|
|
20
|
+
const body = await ctx.api().get('/api/v1/webhooks');
|
|
21
|
+
if (ctx.json)
|
|
22
|
+
return printJson(ctx.io, body);
|
|
23
|
+
const rows = listIn(body, 'webhooks');
|
|
24
|
+
if (!rows.length) {
|
|
25
|
+
ctx.io.stdout.write('No inbound webhook yet. Make one: firefunc webhooks create\n');
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
table(ctx.io, rows, [
|
|
29
|
+
{ head: 'ID', get: (h) => h.id },
|
|
30
|
+
{ head: 'NAME', get: (h) => h.name },
|
|
31
|
+
{ head: 'ON', get: (h) => (h.enabled ? 'yes' : 'no') },
|
|
32
|
+
{ head: 'DELIVERIES', get: (h) => h.receivedCount },
|
|
33
|
+
{ head: 'TOKEN STARTS', get: (h) => `${text(h.tokenPrefix)}…` },
|
|
34
|
+
{ head: 'PATH', get: (h) => h.path, max: 90 },
|
|
35
|
+
]);
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
path: ['webhooks', 'create'],
|
|
40
|
+
summary: 'Make an inbound webhook in a project (prints its token once)',
|
|
41
|
+
usage: 'webhooks create --name <name> --project <id or name> [--vendor <catalogue slug>]',
|
|
42
|
+
flags: { name: 'string', project: 'string', vendor: 'string' },
|
|
43
|
+
flagHelp: [
|
|
44
|
+
['--name <name>', 'what people call it'],
|
|
45
|
+
['--project <id or name>', 'the project its tasks belong to'],
|
|
46
|
+
['--vendor <slug>', "start from a catalogue vendor's mapping (pagerduty, …)"],
|
|
47
|
+
],
|
|
48
|
+
async run(ctx) {
|
|
49
|
+
const name = str(ctx.args, 'name');
|
|
50
|
+
const project = str(ctx.args, 'project');
|
|
51
|
+
if (!name || !project)
|
|
52
|
+
throw new UsageError('--name and --project are both required.');
|
|
53
|
+
const vendor = str(ctx.args, 'vendor');
|
|
54
|
+
const body = await ctx.api().post('/api/v1/webhooks', {
|
|
55
|
+
name,
|
|
56
|
+
projectId: await resolveProjectId(ctx, project),
|
|
57
|
+
...(vendor ? { catalogueSlug: vendor } : {}),
|
|
58
|
+
});
|
|
59
|
+
if (ctx.json)
|
|
60
|
+
return printJson(ctx.io, body);
|
|
61
|
+
printToken(ctx, body, 'Made');
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
path: ['webhooks', 'rotate'],
|
|
66
|
+
summary: 'Give a webhook a new token (the old one stops working)',
|
|
67
|
+
usage: 'webhooks rotate <webhook id>',
|
|
68
|
+
positional: { min: 1, max: 1 },
|
|
69
|
+
async run(ctx) {
|
|
70
|
+
const id = ctx.args.positional[0];
|
|
71
|
+
const body = await ctx.api().post(`/api/v1/webhooks/${enc(id)}/rotate`, {});
|
|
72
|
+
if (ctx.json)
|
|
73
|
+
return printJson(ctx.io, body);
|
|
74
|
+
printToken(ctx, body, 'Rotated');
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
];
|
|
78
|
+
//# sourceMappingURL=webhooks.js.map
|
package/dist/job.js
CHANGED
|
@@ -40,9 +40,9 @@ import { jobClaudeEndpoint } from './openrouter.js';
|
|
|
40
40
|
import { ACCOUNT_RETRY_FIRST_MS, accountBlock, accountProblemOf, cannotWorkSentence, } from './engine-account.js';
|
|
41
41
|
import { createKeyedMutex, deviceLockDir, ensureDeviceScript, ensureHeavyScript, heavyLockDir, heavySlots, heavyTag, withHeavyLock, } from './locks.js';
|
|
42
42
|
import { getAdapter, stripForeignEngineCreds } from './engines/index.js';
|
|
43
|
-
import { mcpFormatForEngine, prepareMcp } from './mcp.js';
|
|
43
|
+
import { mcpFormatForEngine, mcpServerIdsOf, prepareMcp } from './mcp.js';
|
|
44
44
|
import { continueToFinishBrief, engineRules } from './brief.js';
|
|
45
|
-
import { BRIEF_FOLDER, fenceBrief, prepareBriefFolder } from './brief-file.js';
|
|
45
|
+
import { BRIEF_FOLDER, fenceBrief, prepareBriefFolder, refuseExposedOnWindows, } from './brief-file.js';
|
|
46
46
|
import { prepareReleaseFolder, stageDraftRelease } from './release-draft.js';
|
|
47
47
|
import { limitSentence } from './limit.js';
|
|
48
48
|
import { cannotRunUnattendedSentence, unattendedContext } from './unattended.js';
|
|
@@ -1366,7 +1366,7 @@ async function runJobBody(job, cfg, api, viewer, opts) {
|
|
|
1366
1366
|
const heavyHelper = heavyLock ? ensureHeavyScript(rdir) : null;
|
|
1367
1367
|
let briefSeq = 0;
|
|
1368
1368
|
let briefDir;
|
|
1369
|
-
const buildInvocation = (c) => fenceBrief(adapter.buildInvocation(c), c.prompt, {
|
|
1369
|
+
const buildInvocation = (c) => refuseExposedOnWindows(fenceBrief(adapter.buildInvocation(c), c.prompt, {
|
|
1370
1370
|
seq: ++briefSeq,
|
|
1371
1371
|
log,
|
|
1372
1372
|
folder: () => {
|
|
@@ -1378,7 +1378,7 @@ async function runJobBody(job, cfg, api, viewer, opts) {
|
|
|
1378
1378
|
}
|
|
1379
1379
|
return briefDir;
|
|
1380
1380
|
},
|
|
1381
|
-
}).
|
|
1381
|
+
}), adapter.displayName);
|
|
1382
1382
|
const slots = heavySlots(cfg.heavySlots);
|
|
1383
1383
|
const deviceHelper = heavyHelper ? ensureDeviceScript(rdir) : null;
|
|
1384
1384
|
const heavily = (fn) => heavyLock
|
|
@@ -1455,6 +1455,7 @@ async function runJobBody(job, cfg, api, viewer, opts) {
|
|
|
1455
1455
|
const isWin = process.platform === 'win32';
|
|
1456
1456
|
if (job.mcpConfig != null) {
|
|
1457
1457
|
const format = mcpFormatForEngine(adapter.id);
|
|
1458
|
+
const dropped = [];
|
|
1458
1459
|
if (format) {
|
|
1459
1460
|
mcp = await prepareMcp({
|
|
1460
1461
|
raw: job.mcpConfig,
|
|
@@ -1464,9 +1465,21 @@ async function runJobBody(job, cfg, api, viewer, opts) {
|
|
|
1464
1465
|
api,
|
|
1465
1466
|
log,
|
|
1466
1467
|
relay: cfg.mcpRelay !== false,
|
|
1468
|
+
onDrop: (id, code) => dropped.push({ id, code }),
|
|
1467
1469
|
});
|
|
1468
1470
|
}
|
|
1471
|
+
else {
|
|
1472
|
+
for (const id of mcpServerIdsOf(job.mcpConfig))
|
|
1473
|
+
dropped.push({ id, code: 'engine_has_no_mcp' });
|
|
1474
|
+
log(`mcp: ${adapter.displayName} has no MCP client this runner can configure, so FireFunc's tools are off for this run. Fix: run this agent on Claude Code, Codex, Gemini, Copilot, OpenCode, Cursor or Antigravity.`);
|
|
1475
|
+
}
|
|
1469
1476
|
log(mcp ? `mcp: ${mcp.logLine}` : 'mcp: no server was injected for this run');
|
|
1477
|
+
await api.event(job.runId, 'mcp_setup', {
|
|
1478
|
+
engine: adapter.id,
|
|
1479
|
+
platform: process.platform,
|
|
1480
|
+
injected: mcp?.serverIds ?? [],
|
|
1481
|
+
dropped: dropped.slice(0, 20),
|
|
1482
|
+
});
|
|
1470
1483
|
}
|
|
1471
1484
|
const temp = makeRunTemp(job.runId);
|
|
1472
1485
|
if (temp) {
|
package/dist/keep-local.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export declare const CODE_NOTE = "code kept on the machine";
|
|
2
2
|
export declare function codeNote(ref: string | null): string;
|
|
3
|
+
export declare const FORMATTED_NOTE = "[formatted text kept on the machine: read it in the run's session log there]";
|
|
3
4
|
export declare function textCarriesSecret(text: string): boolean;
|
|
4
5
|
export declare function stripCode(text: string): string;
|
|
5
6
|
export declare const UNNAMED_COMMAND = "a command";
|
package/dist/keep-local.js
CHANGED
|
@@ -3,6 +3,8 @@ export const CODE_NOTE = 'code kept on the machine';
|
|
|
3
3
|
export function codeNote(ref) {
|
|
4
4
|
return ref ? `[${CODE_NOTE} — see ${ref}]` : `[${CODE_NOTE}]`;
|
|
5
5
|
}
|
|
6
|
+
export const FORMATTED_NOTE = "[formatted text kept on the machine: read it in the run's session log there]";
|
|
7
|
+
const FORMATTED_LANG = /^(?:html?|xml|markdown|md|text|txt|plain)$/i;
|
|
6
8
|
const EXTENSIONS = 'tsx?|jsx?|mjs|cjs|py|rb|go|rs|java|kts?|swift|c|h|cc|cpp|hpp|cs|php|sql|json|ya?ml|toml|md|css|scss|less|html?|vue|svelte|sh|bash|zsh|tf|hcl|graphql|gql|prisma|ex|exs|scala|dart|lua|pl|proto|xml|gradle|ini|env|lock|conf|cfg';
|
|
7
9
|
const PATH_REF = new RegExp(`((?:[\\w@.-]+/)*[\\w@-][\\w@.-]*\\.(?:${EXTENSIONS}))(?![\\w])(?:(?::|#L)(\\d+))?`, 'i');
|
|
8
10
|
const CODE_REF = /^(\d+):\d+:(\S+)$/;
|
|
@@ -122,7 +124,10 @@ export function stripCode(text) {
|
|
|
122
124
|
let j = i + 1;
|
|
123
125
|
while (j < lines.length && !close.test(lines[j]))
|
|
124
126
|
j++;
|
|
125
|
-
|
|
127
|
+
const lang = (open[3] ?? '').trim().split(/\s+/)[0] ?? '';
|
|
128
|
+
before = FORMATTED_LANG.test(lang)
|
|
129
|
+
? `${indent}${FORMATTED_NOTE}`
|
|
130
|
+
: `${indent}${codeNote(blockRef(open[3], lines.slice(i + 1, j), before))}`;
|
|
126
131
|
fenced.push(before);
|
|
127
132
|
i = j;
|
|
128
133
|
}
|
package/dist/mcp-login.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ export type McpLoginRecord = {
|
|
|
17
17
|
};
|
|
18
18
|
export declare function mcpLoginDir(): string;
|
|
19
19
|
export declare function mcpLoginPath(server: string): string;
|
|
20
|
+
export declare function atlassianDomainHelp(serverUrl: string, redirectUri: string): string[] | null;
|
|
20
21
|
export declare function runMcpLogin(tool: string, opts?: {
|
|
21
22
|
noBrowser?: boolean;
|
|
22
23
|
}): Promise<void>;
|
package/dist/mcp-login.js
CHANGED
|
@@ -371,7 +371,7 @@ function browserOpener() {
|
|
|
371
371
|
if (process.platform === 'darwin')
|
|
372
372
|
return { cmd: 'open', args: [] };
|
|
373
373
|
if (process.platform === 'win32')
|
|
374
|
-
return { cmd: '
|
|
374
|
+
return { cmd: 'rundll32', args: ['url.dll,FileProtocolHandler'] };
|
|
375
375
|
if (!process.env.DISPLAY && !process.env.WAYLAND_DISPLAY)
|
|
376
376
|
return null;
|
|
377
377
|
return { cmd: 'xdg-open', args: [] };
|
|
@@ -488,6 +488,27 @@ async function registerClient(meta, redirectUri, grantTypes) {
|
|
|
488
488
|
}
|
|
489
489
|
return { clientId, clientSecret: str(doc, 'client_secret') ?? undefined };
|
|
490
490
|
}
|
|
491
|
+
export function atlassianDomainHelp(serverUrl, redirectUri) {
|
|
492
|
+
let host = '';
|
|
493
|
+
let back = null;
|
|
494
|
+
try {
|
|
495
|
+
host = new URL(serverUrl).hostname.toLowerCase();
|
|
496
|
+
back = new URL(redirectUri);
|
|
497
|
+
}
|
|
498
|
+
catch {
|
|
499
|
+
return null;
|
|
500
|
+
}
|
|
501
|
+
if (host !== 'mcp.atlassian.com')
|
|
502
|
+
return null;
|
|
503
|
+
const domain = `${back.protocol}//${back.hostname}/**`;
|
|
504
|
+
return [
|
|
505
|
+
'Atlassian lets only approved apps sign in. If Atlassian says the domain is restricted, an admin',
|
|
506
|
+
'of your Atlassian organization adds this domain at admin.atlassian.com › Apps › AI and Rovo ›',
|
|
507
|
+
'Atlassian MCP server › Domains › Add domain:',
|
|
508
|
+
` ${domain}`,
|
|
509
|
+
`(this sign-in returns to ${redirectUri} on this machine). Then run this command again.`,
|
|
510
|
+
];
|
|
511
|
+
}
|
|
491
512
|
function waitForCode(server, state, acceptPaste, timeoutMs) {
|
|
492
513
|
return new Promise((resolve) => {
|
|
493
514
|
let settled = false;
|
|
@@ -508,16 +529,24 @@ function waitForCode(server, state, acceptPaste, timeoutMs) {
|
|
|
508
529
|
const url = new URL(req.url ?? '/', 'http://127.0.0.1');
|
|
509
530
|
const returned = url.searchParams;
|
|
510
531
|
const vendorError = returned.get('error');
|
|
532
|
+
const vendorWords = (returned.get('error_description') ?? '')
|
|
533
|
+
.replace(/[\u0000-\u001f\u007f]+/g, ' ')
|
|
534
|
+
.replace(/\s+/g, ' ')
|
|
535
|
+
.trim()
|
|
536
|
+
.slice(0, 300);
|
|
511
537
|
const code = returned.get('code');
|
|
512
538
|
const body = vendorError
|
|
513
|
-
? `Sign-in was refused: ${vendorError}. You can close this tab.`
|
|
539
|
+
? `Sign-in was refused: ${vendorError}${vendorWords ? ` (${vendorWords})` : ''}. You can close this tab.`
|
|
514
540
|
: code
|
|
515
541
|
? 'Signed in. You can close this tab and return to the terminal.'
|
|
516
542
|
: 'Waiting for the sign-in redirect.';
|
|
517
543
|
res.writeHead(vendorError ? 400 : 200, { 'content-type': 'text/plain; charset=utf-8' });
|
|
518
544
|
res.end(`FireFunc runner — ${body}\n`);
|
|
519
|
-
if (vendorError)
|
|
520
|
-
return finish({
|
|
545
|
+
if (vendorError) {
|
|
546
|
+
return finish({
|
|
547
|
+
failed: `the vendor refused the sign-in (${vendorError}${vendorWords ? `: ${vendorWords}` : ''})`,
|
|
548
|
+
});
|
|
549
|
+
}
|
|
521
550
|
if (!code)
|
|
522
551
|
return;
|
|
523
552
|
if (returned.get('state') !== state) {
|
|
@@ -775,6 +804,12 @@ export async function runMcpLogin(tool, opts = {}) {
|
|
|
775
804
|
authorizeUrl.searchParams.set('scope', meta.scope);
|
|
776
805
|
if (meta.resource)
|
|
777
806
|
authorizeUrl.searchParams.set('resource', meta.resource);
|
|
807
|
+
const domainHelp = atlassianDomainHelp(server.url, loopback.redirectUri);
|
|
808
|
+
if (domainHelp) {
|
|
809
|
+
out('');
|
|
810
|
+
for (const line of domainHelp)
|
|
811
|
+
out(line);
|
|
812
|
+
}
|
|
778
813
|
const opened = opener ? openBrowser(authorizeUrl.href, opener) : false;
|
|
779
814
|
out('');
|
|
780
815
|
if (opened) {
|
|
@@ -802,7 +837,9 @@ export async function runMcpLogin(tool, opts = {}) {
|
|
|
802
837
|
out(`Waiting up to ${Math.round(CALLBACK_TIMEOUT_MS / 60_000)} minutes…`);
|
|
803
838
|
const code = await waitForCode(loopback.server, state, canPaste && !opened, CALLBACK_TIMEOUT_MS);
|
|
804
839
|
if ('failed' in code) {
|
|
805
|
-
err(
|
|
840
|
+
err(domainHelp
|
|
841
|
+
? `\nSign-in did not complete: ${code.failed}.\n\n${domainHelp.join('\n')}`
|
|
842
|
+
: `\nSign-in did not complete: ${code.failed}.\n\nFix: run the command again.`);
|
|
806
843
|
process.exitCode = 1;
|
|
807
844
|
return;
|
|
808
845
|
}
|
package/dist/mcp.d.ts
CHANGED
|
@@ -48,7 +48,10 @@ export type PrepareMcpOptions = {
|
|
|
48
48
|
api: McpCredentialClient;
|
|
49
49
|
log?: (msg: string) => void;
|
|
50
50
|
relay?: boolean;
|
|
51
|
+
onDrop?: (id: string, code: McpDropCode) => void;
|
|
51
52
|
};
|
|
53
|
+
export type McpDropCode = 'engine_has_no_mcp' | 'rejected' | 'unusable_on_engine' | 'config_path_taken' | 'git_exclude_failed' | 'no_credential' | 'not_signed_in' | 'write_failed';
|
|
54
|
+
export declare function mcpServerIdsOf(raw: unknown): string[];
|
|
52
55
|
export declare function mcpFormatForEngine(engine: string | null | undefined): McpFormat | null;
|
|
53
56
|
declare function parseServer(raw: unknown): {
|
|
54
57
|
spec: McpServerSpec;
|
package/dist/mcp.js
CHANGED
|
@@ -4,6 +4,17 @@ import { configPath } from './config.js';
|
|
|
4
4
|
import { CATALOG_ONLY, claudeCodeSignInFix, claudeCodeSignsFor } from './machine-logins.js';
|
|
5
5
|
import { execOut } from './exec.js';
|
|
6
6
|
import { startCredentialRelay } from './mcp-proxy.js';
|
|
7
|
+
export function mcpServerIdsOf(raw) {
|
|
8
|
+
if (!isRecord(raw) || !Array.isArray(raw.servers))
|
|
9
|
+
return [];
|
|
10
|
+
const ids = [];
|
|
11
|
+
for (const s of raw.servers) {
|
|
12
|
+
const id = isRecord(s) ? s.id : null;
|
|
13
|
+
if (typeof id === 'string' && SERVER_ID_PATTERN.test(id) && !ids.includes(id))
|
|
14
|
+
ids.push(id);
|
|
15
|
+
}
|
|
16
|
+
return ids.slice(0, 20);
|
|
17
|
+
}
|
|
7
18
|
const RELAYED_SERVERS = new Set(['github']);
|
|
8
19
|
const SERVER_ID_PATTERN = /^[a-z][a-z0-9_-]*$/;
|
|
9
20
|
const HEADER_NAME_PATTERN = /^[A-Za-z0-9!#$%&'*+.^_`|~-]+$/;
|
|
@@ -199,7 +210,7 @@ function parseServer(raw) {
|
|
|
199
210
|
}
|
|
200
211
|
return { spec };
|
|
201
212
|
}
|
|
202
|
-
function parseRunConfig(raw, log) {
|
|
213
|
+
function parseRunConfig(raw, log, onReject) {
|
|
203
214
|
if (!isRecord(raw))
|
|
204
215
|
return null;
|
|
205
216
|
if (!Array.isArray(raw.servers))
|
|
@@ -209,6 +220,9 @@ function parseRunConfig(raw, log) {
|
|
|
209
220
|
const parsed = parseServer(entry);
|
|
210
221
|
if ('reject' in parsed) {
|
|
211
222
|
log(`mcp: ignoring a server FireFunc sent — ${parsed.reject}.`);
|
|
223
|
+
const id = isRecord(entry) ? entry.id : null;
|
|
224
|
+
if (typeof id === 'string' && SERVER_ID_PATTERN.test(id))
|
|
225
|
+
onReject?.(id);
|
|
212
226
|
continue;
|
|
213
227
|
}
|
|
214
228
|
servers.push(parsed.spec);
|
|
@@ -291,7 +305,7 @@ async function excludeFromGit(worktree, patterns, log) {
|
|
|
291
305
|
mkdirSync(info, { recursive: true });
|
|
292
306
|
const file = join(info, 'exclude');
|
|
293
307
|
const existing = existsSync(file) ? readFileSync(file, 'utf8') : '';
|
|
294
|
-
const lines = existing.split(
|
|
308
|
+
const lines = existing.split(/\r?\n/);
|
|
295
309
|
const missing = patterns.filter((p) => !lines.includes(p));
|
|
296
310
|
if (missing.length) {
|
|
297
311
|
const header = existing.includes(EXCLUDE_HEADER) ? '' : `\n${EXCLUDE_HEADER}\n`;
|
|
@@ -432,7 +446,14 @@ function codexOverrides(resolved) {
|
|
|
432
446
|
const NO_LOG = () => { };
|
|
433
447
|
export async function prepareMcp(opts) {
|
|
434
448
|
const log = opts.log ?? NO_LOG;
|
|
435
|
-
const
|
|
449
|
+
const drop = (id, code) => {
|
|
450
|
+
try {
|
|
451
|
+
opts.onDrop?.(id, code);
|
|
452
|
+
}
|
|
453
|
+
catch {
|
|
454
|
+
}
|
|
455
|
+
};
|
|
456
|
+
const config = parseRunConfig(opts.raw, log, (id) => drop(id, 'rejected'));
|
|
436
457
|
if (!config || config.servers.length === 0)
|
|
437
458
|
return null;
|
|
438
459
|
const usable = [];
|
|
@@ -440,6 +461,7 @@ export async function prepareMcp(opts) {
|
|
|
440
461
|
const reason = whyUnusable(spec, opts.format);
|
|
441
462
|
if (reason) {
|
|
442
463
|
log(`mcp: skipping ${spec.id} on ${opts.format} — ${reason}.`);
|
|
464
|
+
drop(spec.id, 'unusable_on_engine');
|
|
443
465
|
continue;
|
|
444
466
|
}
|
|
445
467
|
usable.push(spec);
|
|
@@ -453,12 +475,16 @@ export async function prepareMcp(opts) {
|
|
|
453
475
|
if (existsSync(target)) {
|
|
454
476
|
log(`mcp: ${relative} already exists in this repo, so MCP is off for this run — FireFunc will not overwrite a file the repo owns, and an exclude cannot protect a tracked one. ` +
|
|
455
477
|
`Fix: remove ${relative} from the repository, or run this project on an engine that reads a different path.`);
|
|
478
|
+
for (const s of usable)
|
|
479
|
+
drop(s.id, 'config_path_taken');
|
|
456
480
|
return null;
|
|
457
481
|
}
|
|
458
482
|
const excluded = await excludeFromGit(opts.worktree, opts.format === 'antigravity' ? [`/${dirname(relative)}/`] : [`/${relative}`], log);
|
|
459
483
|
if (!excluded) {
|
|
460
484
|
log('mcp: MCP is off for this run because the config could not be kept out of the commit. ' +
|
|
461
485
|
'Fix: check that the runner can write .git/info/exclude in the repository checkout.');
|
|
486
|
+
for (const s of usable)
|
|
487
|
+
drop(s.id, 'git_exclude_failed');
|
|
462
488
|
return null;
|
|
463
489
|
}
|
|
464
490
|
}
|
|
@@ -478,6 +504,7 @@ export async function prepareMcp(opts) {
|
|
|
478
504
|
if (spec.auth === 'header') {
|
|
479
505
|
if (!spec.headerName) {
|
|
480
506
|
log(`mcp: skipping ${spec.id} — its credential did not survive validation.`);
|
|
507
|
+
drop(spec.id, 'no_credential');
|
|
481
508
|
continue;
|
|
482
509
|
}
|
|
483
510
|
let value = spec.secret;
|
|
@@ -489,6 +516,7 @@ export async function prepareMcp(opts) {
|
|
|
489
516
|
log(`mcp: skipping ${spec.id} — FireFunc issued no credential for it. ` +
|
|
490
517
|
'Fix: check the server is still granted to this workspace and its secret is set, in Settings → Connections. ' +
|
|
491
518
|
'The run continues without it, on the context pack it already has.');
|
|
519
|
+
drop(spec.id, 'no_credential');
|
|
492
520
|
continue;
|
|
493
521
|
}
|
|
494
522
|
resolved.push({
|
|
@@ -526,6 +554,7 @@ export async function prepareMcp(opts) {
|
|
|
526
554
|
`person's allowance. `
|
|
527
555
|
: '') +
|
|
528
556
|
'The run continues without it, on the context pack it already has.');
|
|
557
|
+
drop(spec.id, 'not_signed_in');
|
|
529
558
|
continue;
|
|
530
559
|
}
|
|
531
560
|
resolved.push({
|
|
@@ -538,6 +567,7 @@ export async function prepareMcp(opts) {
|
|
|
538
567
|
if (!minted?.token) {
|
|
539
568
|
log(`mcp: skipping ${spec.id} — FireFunc issued no read-only credential for it. ` +
|
|
540
569
|
'Fix: the API log names the reason; a 403 usually means GitHub is not connected to this workspace, and a 503 that the GitHub App is not configured. The context pack still carries the repository context.');
|
|
570
|
+
drop(spec.id, 'no_credential');
|
|
541
571
|
continue;
|
|
542
572
|
}
|
|
543
573
|
if (opts.relay && RELAYED_SERVERS.has(spec.id) && spec.transport !== 'stdio' && spec.url) {
|
|
@@ -585,6 +615,8 @@ export async function prepareMcp(opts) {
|
|
|
585
615
|
}
|
|
586
616
|
catch (e) {
|
|
587
617
|
log(`mcp: could not write ${relative} (${e.message}) — MCP is off for this run.`);
|
|
618
|
+
for (const r of resolved)
|
|
619
|
+
drop(r.spec.id, 'write_failed');
|
|
588
620
|
closeRelays();
|
|
589
621
|
return null;
|
|
590
622
|
}
|
package/dist/pool.d.ts
CHANGED
|
@@ -8,6 +8,8 @@ export type JobPoolDeps<J> = {
|
|
|
8
8
|
onStart?: (job: J, inFlight: number) => void;
|
|
9
9
|
idleDelayMs?: number;
|
|
10
10
|
maxIdleDelayMs?: number;
|
|
11
|
+
activePollMs?: number;
|
|
12
|
+
activeWindowMs?: number;
|
|
11
13
|
sleep?: (ms: number) => Promise<void>;
|
|
12
14
|
paused?: () => boolean;
|
|
13
15
|
heartbeat?: (state: {
|
package/dist/pool.js
CHANGED
|
@@ -4,7 +4,16 @@ export async function runJobPool(deps) {
|
|
|
4
4
|
const baseIdleMs = deps.idleDelayMs ?? 800;
|
|
5
5
|
const maxIdleMs = Math.max(baseIdleMs, deps.maxIdleDelayMs ?? 8_000);
|
|
6
6
|
let emptyClaims = 0;
|
|
7
|
-
const
|
|
7
|
+
const activePollMs = deps.activePollMs ?? 1_000;
|
|
8
|
+
const activeWindowMs = deps.activeWindowMs ?? 120_000;
|
|
9
|
+
const clock = deps.now ?? (() => Date.now());
|
|
10
|
+
let lastActivity = clock();
|
|
11
|
+
const idleDelay = () => {
|
|
12
|
+
const backoff = Math.min(maxIdleMs, baseIdleMs * 2 ** Math.min(emptyClaims, 10));
|
|
13
|
+
return clock() - lastActivity < activeWindowMs
|
|
14
|
+
? Math.max(Math.min(baseIdleMs, backoff), Math.min(activePollMs, backoff))
|
|
15
|
+
: backoff;
|
|
16
|
+
};
|
|
8
17
|
const cap = () => {
|
|
9
18
|
const n = Math.floor(typeof deps.maxParallel === 'function' ? deps.maxParallel() : deps.maxParallel);
|
|
10
19
|
return Number.isFinite(n) ? Math.max(0, n) : 1;
|
|
@@ -16,8 +25,10 @@ export async function runJobPool(deps) {
|
|
|
16
25
|
let lastContact = now();
|
|
17
26
|
const spawn = (job) => {
|
|
18
27
|
deps.onStart?.(job, active.size + 1);
|
|
28
|
+
lastActivity = now();
|
|
19
29
|
const p = deps.run(job).finally(() => {
|
|
20
30
|
active.delete(p);
|
|
31
|
+
lastActivity = now();
|
|
21
32
|
});
|
|
22
33
|
active.add(p);
|
|
23
34
|
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare function msvcQuote(arg: string): string;
|
|
2
|
+
export declare function windowsShellArg(arg: string, batch?: boolean): string;
|
|
3
|
+
export declare function windowsShellCommandName(cmd: string): string;
|
|
4
|
+
export type WhichDeps = {
|
|
5
|
+
exists: (p: string) => boolean;
|
|
6
|
+
};
|
|
7
|
+
export declare function resolveWindowsCommand(cmd: string, env?: NodeJS.ProcessEnv, deps?: WhichDeps): string | null;
|
|
8
|
+
export declare function isBatchFile(path: string): boolean;
|
|
9
|
+
export declare function windowsShellLine(cmd: string, args: readonly string[], env?: NodeJS.ProcessEnv, deps?: WhichDeps): string;
|
|
10
|
+
export declare function shellSafe(cmd: string, args: readonly string[], shell: boolean | undefined, env?: NodeJS.ProcessEnv, platform?: NodeJS.Platform): {
|
|
11
|
+
cmd: string;
|
|
12
|
+
args: string[];
|
|
13
|
+
shell: boolean;
|
|
14
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
|
+
import { win32 } from 'node:path';
|
|
3
|
+
const { delimiter, extname, isAbsolute, join, normalize } = win32;
|
|
4
|
+
const META = /([()\][%!^"`<>&|;, *?])/g;
|
|
5
|
+
export function msvcQuote(arg) {
|
|
6
|
+
let out = '"';
|
|
7
|
+
let slashes = 0;
|
|
8
|
+
for (const ch of arg) {
|
|
9
|
+
if (ch === '\\') {
|
|
10
|
+
slashes += 1;
|
|
11
|
+
continue;
|
|
12
|
+
}
|
|
13
|
+
out += ch === '"' ? `${'\\'.repeat(slashes * 2 + 1)}"` : `${'\\'.repeat(slashes)}${ch}`;
|
|
14
|
+
slashes = 0;
|
|
15
|
+
}
|
|
16
|
+
return `${out}${'\\'.repeat(slashes * 2)}"`;
|
|
17
|
+
}
|
|
18
|
+
export function windowsShellArg(arg, batch = false) {
|
|
19
|
+
const once = msvcQuote(arg).replace(META, '^$1');
|
|
20
|
+
return batch ? once.replace(META, '^$1') : once;
|
|
21
|
+
}
|
|
22
|
+
export function windowsShellCommandName(cmd) {
|
|
23
|
+
return normalize(cmd).replace(META, '^$1');
|
|
24
|
+
}
|
|
25
|
+
export function resolveWindowsCommand(cmd, env = process.env, deps = { exists: existsSync }) {
|
|
26
|
+
const exts = (env.PATHEXT ?? '.COM;.EXE;.BAT;.CMD').split(';').filter(Boolean);
|
|
27
|
+
const candidates = (base) => extname(base) && deps.exists(base) ? [base] : exts.map((e) => `${base}${e}`);
|
|
28
|
+
const hasDir = isAbsolute(cmd) || /[\\/]/.test(cmd);
|
|
29
|
+
const dirs = hasDir ? [''] : (env.PATH ?? env.Path ?? '').split(delimiter).filter(Boolean);
|
|
30
|
+
for (const dir of dirs) {
|
|
31
|
+
const base = dir ? join(dir, cmd) : cmd;
|
|
32
|
+
for (const c of candidates(base))
|
|
33
|
+
if (deps.exists(c))
|
|
34
|
+
return c;
|
|
35
|
+
}
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
export function isBatchFile(path) {
|
|
39
|
+
return /\.(cmd|bat)$/i.test(path);
|
|
40
|
+
}
|
|
41
|
+
export function windowsShellLine(cmd, args, env = process.env, deps) {
|
|
42
|
+
const resolved = resolveWindowsCommand(cmd, env, deps) ?? cmd;
|
|
43
|
+
const batch = isBatchFile(resolved);
|
|
44
|
+
return [windowsShellCommandName(resolved), ...args.map((a) => windowsShellArg(a, batch))].join(' ');
|
|
45
|
+
}
|
|
46
|
+
export function shellSafe(cmd, args, shell, env = process.env, platform = process.platform) {
|
|
47
|
+
if (!shell || platform !== 'win32' || args.length === 0)
|
|
48
|
+
return { cmd, args: [...args], shell: !!shell };
|
|
49
|
+
return { cmd: windowsShellLine(cmd, args, env), args: [], shell: true };
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=win-shell.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@firefunc-agent/runner",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.36",
|
|
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, Copilot CLI, Antigravity) on work FireFunc routes to it, opens pull requests, and reports back. Your machine, your subscriptions.",
|