@firefunc-agent/runner 0.7.1 → 0.9.3
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/LICENSE +7 -3
- package/README.md +296 -4
- package/dist/activity.d.ts +32 -0
- package/dist/activity.js +295 -0
- package/dist/api.d.ts +69 -1
- package/dist/api.js +114 -3
- package/dist/brief.d.ts +11 -0
- package/dist/brief.js +278 -0
- package/dist/build-info.json +4 -0
- package/dist/cli.js +59 -2
- package/dist/config.d.ts +7 -0
- package/dist/config.js +3 -0
- package/dist/cut.d.ts +45 -0
- package/dist/cut.js +105 -0
- package/dist/daemon.d.ts +16 -0
- package/dist/daemon.js +196 -7
- package/dist/declined.d.ts +11 -0
- package/dist/declined.js +27 -0
- package/dist/engines/antigravity.d.ts +2 -0
- package/dist/engines/antigravity.js +102 -0
- package/dist/engines/claude-budget.d.ts +1 -1
- package/dist/engines/claude-budget.js +2 -72
- package/dist/engines/claude.js +139 -2
- package/dist/engines/codex.js +10 -3
- package/dist/engines/copilot.d.ts +2 -0
- package/dist/engines/copilot.js +117 -0
- package/dist/engines/cursor.js +4 -0
- package/dist/engines/gemini.js +6 -1
- package/dist/engines/index.d.ts +2 -0
- package/dist/engines/index.js +22 -4
- package/dist/engines/types.d.ts +12 -1
- package/dist/exec.d.ts +3 -0
- package/dist/exec.js +48 -5
- package/dist/firefunc/agents.d.ts +2 -0
- package/dist/firefunc/agents.js +343 -0
- package/dist/firefunc/args.d.ts +18 -0
- package/dist/firefunc/args.js +82 -0
- package/dist/firefunc/auth.d.ts +21 -0
- package/dist/firefunc/auth.js +129 -0
- package/dist/firefunc/catalog.d.ts +10 -0
- package/dist/firefunc/catalog.js +201 -0
- package/dist/firefunc/cli.d.ts +2 -0
- package/dist/firefunc/cli.js +24 -0
- package/dist/firefunc/client.d.ts +36 -0
- package/dist/firefunc/client.js +177 -0
- package/dist/firefunc/command.d.ts +28 -0
- package/dist/firefunc/command.js +35 -0
- package/dist/firefunc/config.d.ts +29 -0
- package/dist/firefunc/config.js +111 -0
- package/dist/firefunc/configure.d.ts +6 -0
- package/dist/firefunc/configure.js +409 -0
- package/dist/firefunc/io.d.ts +25 -0
- package/dist/firefunc/io.js +14 -0
- package/dist/firefunc/main.d.ts +4 -0
- package/dist/firefunc/main.js +259 -0
- package/dist/firefunc/output.d.ts +29 -0
- package/dist/firefunc/output.js +131 -0
- package/dist/firefunc/prompt.d.ts +14 -0
- package/dist/firefunc/prompt.js +58 -0
- package/dist/firefunc/skill.d.ts +3 -0
- package/dist/firefunc/skill.js +80 -0
- package/dist/firefunc/tasks.d.ts +2 -0
- package/dist/firefunc/tasks.js +279 -0
- package/dist/firefunc/version.d.ts +2 -0
- package/dist/firefunc/version.js +8 -0
- package/dist/git-auth.d.ts +4 -1
- package/dist/git-auth.js +6 -2
- package/dist/held.d.ts +18 -0
- package/dist/held.js +95 -0
- package/dist/job.d.ts +3 -0
- package/dist/job.js +818 -102
- package/dist/keep-local.d.ts +12 -0
- package/dist/keep-local.js +651 -0
- package/dist/limit.d.ts +30 -0
- package/dist/limit.js +258 -0
- package/dist/locks.d.ts +14 -0
- package/dist/locks.js +164 -0
- package/dist/machine-logins.d.ts +19 -0
- package/dist/machine-logins.js +187 -0
- package/dist/mcp-login.d.ts +24 -0
- package/dist/mcp-login.js +993 -0
- package/dist/mcp-proxy.d.ts +21 -0
- package/dist/mcp-proxy.js +180 -0
- package/dist/mcp.d.ts +62 -0
- package/dist/mcp.js +611 -0
- package/dist/network.d.ts +20 -0
- package/dist/network.js +76 -0
- package/dist/orphans.d.ts +40 -0
- package/dist/orphans.js +235 -0
- package/dist/pending.d.ts +14 -0
- package/dist/pending.js +56 -0
- package/dist/pool.d.ts +7 -0
- package/dist/pool.js +57 -9
- package/dist/pr-title.d.ts +11 -0
- package/dist/pr-title.js +63 -0
- package/dist/recover.d.ts +10 -0
- package/dist/recover.js +104 -0
- package/dist/secret-scan.d.ts +19 -0
- package/dist/secret-scan.js +161 -0
- package/dist/session-stream.d.ts +9 -1
- package/dist/session-stream.js +20 -2
- package/dist/skills.d.ts +11 -0
- package/dist/skills.js +164 -0
- package/dist/stopped.d.ts +3 -0
- package/dist/stopped.js +10 -0
- package/dist/usage.d.ts +49 -0
- package/dist/usage.js +389 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.js +17 -0
- package/dist/viewer.js +7 -1
- package/dist/worktrees.d.ts +15 -0
- package/dist/worktrees.js +96 -0
- package/package.json +8 -5
- package/skill/firefunc/SKILL.md +222 -0
package/dist/brief.js
CHANGED
|
@@ -3,9 +3,31 @@ import { tmpdir } from 'node:os';
|
|
|
3
3
|
import { join } from 'node:path';
|
|
4
4
|
import { exec, execOut } from './exec.js';
|
|
5
5
|
import { resolveRepoPath } from './job.js';
|
|
6
|
+
import { changeReads, hardFirst, refusesPush, scanAddedLines, secretRefusal, uniqueHits, } from './secret-scan.js';
|
|
6
7
|
function out(msg) {
|
|
7
8
|
process.stdout.write(`${msg}\n`);
|
|
8
9
|
}
|
|
10
|
+
export function engineRules(opts) {
|
|
11
|
+
const lines = [
|
|
12
|
+
'How this session runs: it is unattended — nobody answers questions — and it ends when your turn ends. Nothing comes back to it afterwards.',
|
|
13
|
+
'- Never start a command in the background (run_in_background, a trailing `&`, nohup) when you need its result to finish the task. Run it in the foreground and wait for it, however long it takes. Do not end your turn while a command you started is still running: whatever is still running when the session ends is stopped, and a promise to check later is never kept.',
|
|
14
|
+
];
|
|
15
|
+
if (opts.heavy) {
|
|
16
|
+
lines.push('- Other sessions on this machine may be working in this same repository. Run a heavy command — a build or type-check of the whole project, the full test suite — as `"$FIREFUNC_HEAVY" <command>`: it waits for any other heavy command in this repository to finish first, so they take turns instead of running at once.');
|
|
17
|
+
}
|
|
18
|
+
lines.push(`- You have at most ${opts.minutes} minutes; the session is stopped when they run out. Leave time to finish and to say what you proved.`);
|
|
19
|
+
return `${lines.join('\n')}\n\n`;
|
|
20
|
+
}
|
|
21
|
+
export function continueToFinishBrief(open) {
|
|
22
|
+
const what = open.length === 0
|
|
23
|
+
? 'on a promise to check a result later'
|
|
24
|
+
: open.length === 1
|
|
25
|
+
? `while a command you started (${open[0]}) was still running`
|
|
26
|
+
: `while commands you started (${open.join(', ')}) were still running`;
|
|
27
|
+
return (`Your session ended ${what}. Nothing comes back to a session once it ends, and whatever it left running was stopped. ` +
|
|
28
|
+
'Run what you need now, in the foreground, and wait for the result however long it takes; then finish the task with what it shows. ' +
|
|
29
|
+
'Do not end your turn before you have the result.');
|
|
30
|
+
}
|
|
9
31
|
const BRIEF_PROMPT = `You are bootstrapping a CLAUDE.md "runner briefing" for THIS repository.
|
|
10
32
|
|
|
11
33
|
Context: a headless, unattended FireFunc runner will load this file on every automated fix — no human to guide it, no prior context, a cold boot each time. Claude Code auto-loads a repo-root CLAUDE.md as project instructions, so this file is the runner's complete, always-loaded operating manual.
|
|
@@ -19,6 +41,33 @@ If a CLAUDE.md already exists at the repo root, only improve it where it is clea
|
|
|
19
41
|
- A "how to make a good autonomous fix" checklist: localize to the smallest correct change, add a test, run the gate locally, keep the diff reviewable (it ships as a draft PR).
|
|
20
42
|
|
|
21
43
|
CRITICAL: state only what you can VERIFY from the code — read package.json scripts, CI workflows, and the source before asserting a command or convention. Do not hallucinate. Do NOT modify any file other than CLAUDE.md.`;
|
|
44
|
+
export async function scanBeforePush(worktree, from, branch) {
|
|
45
|
+
const reads = changeReads(from, branch);
|
|
46
|
+
const read = (args) => exec('git', ['-C', worktree, ...args], { timeoutMs: 120_000, env: reads.env }).catch((e) => ({ code: 1, stdout: '', stderr: e.message }));
|
|
47
|
+
const whole = await read(reads.whole);
|
|
48
|
+
const commits = whole.code === 0 ? await read(reads.commits) : whole;
|
|
49
|
+
if (whole.code !== 0 || commits.code !== 0) {
|
|
50
|
+
const failed = whole.code !== 0 ? whole : commits;
|
|
51
|
+
return {
|
|
52
|
+
refusal: `Not pushing: the change could not be read to scan it for secrets (git exit ${failed.code}: ${failed.stderr.trim().slice(0, 200)}). ` +
|
|
53
|
+
`The commit stays on the local branch ${branch}: look it over with \`git show ${branch}\` and push it yourself, or run brief again.`,
|
|
54
|
+
note: null,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
const hits = hardFirst(uniqueHits([...scanAddedLines(whole.stdout), ...scanAddedLines(commits.stdout)]));
|
|
58
|
+
if (hits.some(refusesPush))
|
|
59
|
+
return { refusal: secretRefusal(hits, branch), note: null };
|
|
60
|
+
if (hits.length === 0)
|
|
61
|
+
return { refusal: null, note: null };
|
|
62
|
+
const named = hits
|
|
63
|
+
.slice(0, 5)
|
|
64
|
+
.map((h) => `${h.kind} at ${h.path}:${h.line}`)
|
|
65
|
+
.join(', ');
|
|
66
|
+
return {
|
|
67
|
+
refusal: null,
|
|
68
|
+
note: `The secret scan found a value set to a secret-looking name (${named}) — pushing; check it is a placeholder before you merge.`,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
22
71
|
export async function runBrief(repo, cfg) {
|
|
23
72
|
const repoPath = resolveRepoPath(repo, cfg);
|
|
24
73
|
if (!repoPath) {
|
|
@@ -95,6 +144,14 @@ export async function runBrief(repo, cfg) {
|
|
|
95
144
|
'docs: add CLAUDE.md runner briefing',
|
|
96
145
|
'--quiet',
|
|
97
146
|
]);
|
|
147
|
+
const scan = await scanBeforePush(worktree, `origin/${base}`, branch);
|
|
148
|
+
if (scan.refusal) {
|
|
149
|
+
out(scan.refusal);
|
|
150
|
+
process.exitCode = 1;
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
if (scan.note)
|
|
154
|
+
out(scan.note);
|
|
98
155
|
const push = await exec('git', ['-C', worktree, 'push', '--force-with-lease', 'origin', `${branch}:${branch}`], { timeoutMs: 120_000 });
|
|
99
156
|
if (push.code !== 0) {
|
|
100
157
|
out(`git push failed: ${push.stderr.slice(0, 300)}`);
|
|
@@ -135,4 +192,225 @@ export async function runBrief(repo, cfg) {
|
|
|
135
192
|
}
|
|
136
193
|
}
|
|
137
194
|
}
|
|
195
|
+
function packRecord(value) {
|
|
196
|
+
return value && typeof value === 'object' && !Array.isArray(value)
|
|
197
|
+
? value
|
|
198
|
+
: null;
|
|
199
|
+
}
|
|
200
|
+
function packString(value) {
|
|
201
|
+
return typeof value === 'string' && value.trim() !== '' ? value : null;
|
|
202
|
+
}
|
|
203
|
+
function packNumber(value) {
|
|
204
|
+
return typeof value === 'number' && Number.isFinite(value) ? value : null;
|
|
205
|
+
}
|
|
206
|
+
function packList(value) {
|
|
207
|
+
return Array.isArray(value) ? value : [];
|
|
208
|
+
}
|
|
209
|
+
function packStrings(value) {
|
|
210
|
+
return packList(value)
|
|
211
|
+
.map(packString)
|
|
212
|
+
.filter((s) => s !== null);
|
|
213
|
+
}
|
|
214
|
+
function cutLine(entry) {
|
|
215
|
+
const t = packRecord(entry);
|
|
216
|
+
const name = packString(t?.section);
|
|
217
|
+
if (!name)
|
|
218
|
+
return null;
|
|
219
|
+
const included = packNumber(t?.included);
|
|
220
|
+
const total = packNumber(t?.total);
|
|
221
|
+
return included !== null && total !== null
|
|
222
|
+
? ` [cut] ${name}: ${included} of ${total} included — the rest exists and was not sent.`
|
|
223
|
+
: ` [cut] ${name}: truncated — part of this section was not sent.`;
|
|
224
|
+
}
|
|
225
|
+
function cutLines(truncations, section) {
|
|
226
|
+
return truncations
|
|
227
|
+
.filter((entry) => {
|
|
228
|
+
const name = packString(packRecord(entry)?.section);
|
|
229
|
+
return name !== null && (name === section || name.startsWith(`${section}.`));
|
|
230
|
+
})
|
|
231
|
+
.map(cutLine)
|
|
232
|
+
.filter((l) => l !== null);
|
|
233
|
+
}
|
|
234
|
+
function spent(perSection, section) {
|
|
235
|
+
const bytes = packNumber(perSection?.[section]);
|
|
236
|
+
return bytes === null ? '' : ` — ${bytes} bytes`;
|
|
237
|
+
}
|
|
238
|
+
export function renderJobBrief(job) {
|
|
239
|
+
const pack = packRecord(job.contextPack);
|
|
240
|
+
if (!pack)
|
|
241
|
+
return job.prompt;
|
|
242
|
+
const budget = packRecord(pack.budget);
|
|
243
|
+
const perSection = packRecord(budget?.perSectionBytes);
|
|
244
|
+
const truncations = packList(budget?.truncations);
|
|
245
|
+
const blocks = [];
|
|
246
|
+
const rendered = new Set();
|
|
247
|
+
const event = packRecord(pack.event);
|
|
248
|
+
if (event) {
|
|
249
|
+
rendered.add('event');
|
|
250
|
+
const lines = [];
|
|
251
|
+
const tool = packString(event.tool);
|
|
252
|
+
const kind = packString(event.kind);
|
|
253
|
+
const account = packString(event.accountLabel);
|
|
254
|
+
const scope = packStrings(event.scopePath);
|
|
255
|
+
const occurred = packString(event.occurredAt);
|
|
256
|
+
const actor = packRecord(event.actor);
|
|
257
|
+
if (tool)
|
|
258
|
+
lines.push(` Tool: ${tool}`);
|
|
259
|
+
if (kind)
|
|
260
|
+
lines.push(` Event: ${kind}`);
|
|
261
|
+
if (account)
|
|
262
|
+
lines.push(` Account: ${account}`);
|
|
263
|
+
if (scope.length > 0)
|
|
264
|
+
lines.push(` Scope: ${scope.join(' / ')}`);
|
|
265
|
+
if (occurred)
|
|
266
|
+
lines.push(` Occurred: ${occurred}`);
|
|
267
|
+
if (actor) {
|
|
268
|
+
const who = packString(actor.displayName) ?? packString(actor.externalId);
|
|
269
|
+
if (who)
|
|
270
|
+
lines.push(` Actor: ${who}${actor.isBot === true ? ' (bot)' : ''}`);
|
|
271
|
+
}
|
|
272
|
+
const changes = packList(event.changes).length;
|
|
273
|
+
if (changes > 0)
|
|
274
|
+
lines.push(` Changed fields: ${changes}`);
|
|
275
|
+
lines.push(...cutLines(truncations, 'event'));
|
|
276
|
+
if (lines.length > 0)
|
|
277
|
+
blocks.push(`## Event${spent(perSection, 'event')}\n${lines.join('\n')}`);
|
|
278
|
+
}
|
|
279
|
+
const subject = packRecord(pack.subject);
|
|
280
|
+
if (subject) {
|
|
281
|
+
rendered.add('subject');
|
|
282
|
+
const lines = [];
|
|
283
|
+
const title = packString(subject.title);
|
|
284
|
+
const externalId = packString(subject.externalId);
|
|
285
|
+
const url = packString(subject.externalUrl);
|
|
286
|
+
const type = packString(subject.type);
|
|
287
|
+
const state = packString(subject.state);
|
|
288
|
+
const stateCategory = packString(subject.stateCategory);
|
|
289
|
+
const severity = packString(subject.severity);
|
|
290
|
+
const labels = packStrings(subject.labels);
|
|
291
|
+
const reporter = packString(subject.reporter);
|
|
292
|
+
const assignee = packString(subject.assignee);
|
|
293
|
+
const body = packString(subject.body);
|
|
294
|
+
if (title)
|
|
295
|
+
lines.push(` Title: ${title}`);
|
|
296
|
+
if (externalId)
|
|
297
|
+
lines.push(` Id: ${externalId}`);
|
|
298
|
+
if (type)
|
|
299
|
+
lines.push(` Type: ${type}`);
|
|
300
|
+
if (url)
|
|
301
|
+
lines.push(` URL: ${url}`);
|
|
302
|
+
if (state)
|
|
303
|
+
lines.push(` State: ${state}${stateCategory ? ` (${stateCategory})` : ''}`);
|
|
304
|
+
if (severity)
|
|
305
|
+
lines.push(` Severity: ${severity}`);
|
|
306
|
+
if (labels.length > 0)
|
|
307
|
+
lines.push(` Labels: ${labels.join(', ')}`);
|
|
308
|
+
if (reporter)
|
|
309
|
+
lines.push(` Reporter: ${reporter}`);
|
|
310
|
+
if (assignee)
|
|
311
|
+
lines.push(` Assignee: ${assignee}`);
|
|
312
|
+
if (body)
|
|
313
|
+
lines.push(` Body: ${body.length} characters`);
|
|
314
|
+
lines.push(...cutLines(truncations, 'subject'));
|
|
315
|
+
if (lines.length > 0)
|
|
316
|
+
blocks.push(`## Item${spent(perSection, 'subject')}\n${lines.join('\n')}`);
|
|
317
|
+
}
|
|
318
|
+
else if ('subject' in pack) {
|
|
319
|
+
rendered.add('subject');
|
|
320
|
+
blocks.push('## Item\n No source item was resolved for this run.');
|
|
321
|
+
}
|
|
322
|
+
const repo = packRecord(pack.repo);
|
|
323
|
+
if (repo) {
|
|
324
|
+
rendered.add('repo');
|
|
325
|
+
const lines = [];
|
|
326
|
+
const name = packString(repo.repo);
|
|
327
|
+
const baseBranch = packString(repo.baseBranch);
|
|
328
|
+
const offLimits = packStrings(repo.offLimitsPaths);
|
|
329
|
+
if (name)
|
|
330
|
+
lines.push(` Repository: ${name}`);
|
|
331
|
+
if (baseBranch)
|
|
332
|
+
lines.push(` Base branch: ${baseBranch}`);
|
|
333
|
+
if (offLimits.length > 0)
|
|
334
|
+
lines.push(` Off-limits paths: ${offLimits.join(', ')}`);
|
|
335
|
+
lines.push(...cutLines(truncations, 'repo'));
|
|
336
|
+
if (lines.length > 0) {
|
|
337
|
+
blocks.push(`## Repository${spent(perSection, 'repo')}\n${lines.join('\n')}`);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
const instruction = packRecord(pack.instruction);
|
|
341
|
+
if (instruction) {
|
|
342
|
+
rendered.add('instruction');
|
|
343
|
+
const lines = [];
|
|
344
|
+
const handle = packString(instruction.handle);
|
|
345
|
+
const triggeredBy = packString(instruction.triggeredBy);
|
|
346
|
+
const text = packString(instruction.text);
|
|
347
|
+
if (handle)
|
|
348
|
+
lines.push(` Addressed to: ${handle}`);
|
|
349
|
+
if (triggeredBy)
|
|
350
|
+
lines.push(` Triggered by: ${triggeredBy}`);
|
|
351
|
+
if (text)
|
|
352
|
+
lines.push(` Instruction text: ${text.length} characters`);
|
|
353
|
+
lines.push(...cutLines(truncations, 'instruction'));
|
|
354
|
+
if (lines.length > 0) {
|
|
355
|
+
blocks.push(`## Instruction${spent(perSection, 'instruction')}\n${lines.join('\n')}`);
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
const related = Object.entries(packRecord(pack.related) ?? {});
|
|
359
|
+
const relatedCuts = cutLines(truncations, 'related');
|
|
360
|
+
if (related.length > 0 || relatedCuts.length > 0) {
|
|
361
|
+
rendered.add('related');
|
|
362
|
+
const lines = related.map(([tool, value]) => {
|
|
363
|
+
const entries = Array.isArray(value) ? ` (${value.length} entries)` : '';
|
|
364
|
+
return ` - ${tool}${entries}`;
|
|
365
|
+
});
|
|
366
|
+
if (lines.length === 0)
|
|
367
|
+
lines.push(' - nothing from another tool fit the budget');
|
|
368
|
+
lines.push(...relatedCuts);
|
|
369
|
+
blocks.push(`## Related context${spent(perSection, 'related')}\n${lines.join('\n')}`);
|
|
370
|
+
}
|
|
371
|
+
const attachments = packList(pack.attachments);
|
|
372
|
+
const attachmentCuts = cutLines(truncations, 'attachments');
|
|
373
|
+
if (attachments.length > 0 || attachmentCuts.length > 0) {
|
|
374
|
+
rendered.add('attachments');
|
|
375
|
+
const lines = attachments.map((entry) => {
|
|
376
|
+
const a = packRecord(entry);
|
|
377
|
+
const name = packString(a?.filename) ?? 'attachment';
|
|
378
|
+
const withheld = packString(a?.withheldReason);
|
|
379
|
+
if (withheld)
|
|
380
|
+
return ` - ${name}: withheld — ${withheld}`;
|
|
381
|
+
const size = packNumber(a?.size);
|
|
382
|
+
return ` - ${name}${size === null ? '' : ` (${size} bytes)`}`;
|
|
383
|
+
});
|
|
384
|
+
lines.push(...attachmentCuts);
|
|
385
|
+
blocks.push(`## Attachments${spent(perSection, 'attachments')}\n${lines.join('\n')}`);
|
|
386
|
+
}
|
|
387
|
+
if (job.skills && job.skills.length > 0) {
|
|
388
|
+
const lines = job.skills.map((s) => ` - ${s.name} (.claude/skills/${s.slug}/SKILL.md)${s.description ? ` — ${s.description}` : ''}`);
|
|
389
|
+
blocks.push(`## Skills\nThese skills are installed in this worktree for this run. Read the ones whose description applies before you start, and follow them:\n${lines.join('\n')}`);
|
|
390
|
+
}
|
|
391
|
+
const orphaned = truncations.filter((entry) => {
|
|
392
|
+
const name = packString(packRecord(entry)?.section);
|
|
393
|
+
return name !== null && !rendered.has(name.split('.')[0] ?? name);
|
|
394
|
+
});
|
|
395
|
+
if (orphaned.length > 0) {
|
|
396
|
+
const lines = orphaned.map(cutLine).filter((l) => l !== null);
|
|
397
|
+
blocks.push(`## Also cut\n${lines.join('\n')}`);
|
|
398
|
+
}
|
|
399
|
+
if (blocks.length === 0) {
|
|
400
|
+
return ('Context pack: this runner recognizes nothing in the pack the server sent, so it ' +
|
|
401
|
+
'cannot describe it. The engine still received the flat rendering as its prompt — ' +
|
|
402
|
+
'nothing was lost. To see the inventory, update the runner: ' +
|
|
403
|
+
'npm install -g @firefunc-agent/runner');
|
|
404
|
+
}
|
|
405
|
+
const total = packNumber(budget?.totalBytes);
|
|
406
|
+
const footer = truncations.length > 0
|
|
407
|
+
? 'Sections marked [cut] did not fit their budget.'
|
|
408
|
+
: 'No cuts are recorded in the pack.';
|
|
409
|
+
blocks.push(total === null ? footer : `Pack total: ${total} bytes. ${footer}`);
|
|
410
|
+
return [
|
|
411
|
+
'Context pack for this run — what FireFunc assembled for the engine ' +
|
|
412
|
+
"(the prompt it receives is the server's flat rendering of these same sections):",
|
|
413
|
+
...blocks,
|
|
414
|
+
].join('\n\n');
|
|
415
|
+
}
|
|
138
416
|
//# sourceMappingURL=brief.js.map
|
package/dist/cli.js
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
import { expandHome, loadConfig, saveConfig, configPath } from './config.js';
|
|
3
3
|
import { startDaemon } from './daemon.js';
|
|
4
4
|
import { runBrief } from './brief.js';
|
|
5
|
+
import { runMcpList, runMcpLogin, runMcpLogout } from './mcp-login.js';
|
|
6
|
+
import { RUNNER_VERSION } from './version.js';
|
|
5
7
|
import { currentPlatform, defaultServiceDeps, EPHEMERAL_INSTALL_MESSAGE, installService, isEphemeralInstall, readLogTail, renderLaunchdPlist, renderSystemdUnit, renderWindowsTaskXml, serviceStatus, servicePaths, startService, stopService, uninstallService, } from './service.js';
|
|
6
8
|
const HELP = `firefunc-runner — run YOUR local coding agent on work FireFunc routes to you.
|
|
7
9
|
(Claude Code, OpenAI Codex, Gemini CLI or Cursor CLI — whichever you have installed.)
|
|
@@ -17,6 +19,10 @@ Usage:
|
|
|
17
19
|
firefunc-runner logs Show recent runner output
|
|
18
20
|
firefunc-runner uninstall Remove the background service
|
|
19
21
|
firefunc-runner status Show the saved config + service state
|
|
22
|
+
firefunc-runner mcp login <tool> Sign THIS machine in to a tool's MCP server
|
|
23
|
+
firefunc-runner mcp list Which MCP servers this machine is signed in to
|
|
24
|
+
firefunc-runner mcp logout <tool> Forget one MCP sign-in
|
|
25
|
+
firefunc-runner --version Print this runner's version (also -v)
|
|
20
26
|
firefunc-runner --help
|
|
21
27
|
|
|
22
28
|
After "connect", run "install" once. The runner then starts at login/boot and
|
|
@@ -62,7 +68,9 @@ fallback + each engine's auth here):
|
|
|
62
68
|
http://127.0.0.1:<n> to watch Claude work; FireFunc's "Watch live"
|
|
63
69
|
button opens it too. Bound to localhost only — never sent to FireFunc.
|
|
64
70
|
--no-viewer Don't serve the local live-session web terminal.
|
|
65
|
-
--max-parallel <n> Run up to N
|
|
71
|
+
--max-parallel <n> Run up to N sessions AT ONCE on this machine, overriding what
|
|
72
|
+
FireFunc offers (the highest "Runs at once" among the projects
|
|
73
|
+
it serves; 1 = serial when none is set).
|
|
66
74
|
Each runs in its own git worktree + dev-server port. Higher N
|
|
67
75
|
= faster throughput, more CPU/RAM, and may hit Claude-Max rate
|
|
68
76
|
limits. It's your machine + subscription — set what you like.
|
|
@@ -76,11 +84,26 @@ dev-environment (so Claude can REPRODUCE bugs live, not just read code):
|
|
|
76
84
|
--setup-timeout <min> Timeout for all setup commands (default: job timeout)
|
|
77
85
|
--no-auto-install Skip auto npm/pnpm/yarn install (default: auto-install deps when no --setup given)
|
|
78
86
|
|
|
87
|
+
mcp (let an agent look things up live in a tool, mid-run — the ticket next to
|
|
88
|
+
this one, the newest event on the issue):
|
|
89
|
+
mcp login <tool> Sign THIS MACHINE in to that tool's MCP server. The sign-in
|
|
90
|
+
happens in your browser, on your machine, and the token is
|
|
91
|
+
cached here, readable only by you — it is never sent to
|
|
92
|
+
FireFunc. Each machine running a runner needs its own.
|
|
93
|
+
mcp list What this machine is signed in to, and when each expires.
|
|
94
|
+
mcp logout <tool> Forget one sign-in (and revoke it where the vendor allows).
|
|
95
|
+
--no-browser Print the sign-in URL instead of opening a browser. Used
|
|
96
|
+
automatically on a headless box, which is also told so
|
|
97
|
+
rather than left waiting for a window that never opens.
|
|
98
|
+
GitHub needs no login: FireFunc mints it a read-only, one-repo, one-hour token
|
|
99
|
+
per run — narrower than any machine-wide sign-in could be.
|
|
100
|
+
|
|
79
101
|
Examples:
|
|
80
102
|
firefunc-runner connect ffr_xxx --repos-dir ~/code
|
|
81
103
|
firefunc-runner connect ffr_xxx --repo acme/api=/Users/me/code/api
|
|
82
104
|
firefunc-runner connect ffr_xxx --env AWS_PROFILE=app-ro --setup "npm ci" --bg "npm run dev"
|
|
83
105
|
firefunc-runner install
|
|
106
|
+
firefunc-runner mcp login jira
|
|
84
107
|
`;
|
|
85
108
|
function parseFlags(args) {
|
|
86
109
|
const out = {};
|
|
@@ -96,6 +119,10 @@ function parseFlags(args) {
|
|
|
96
119
|
}
|
|
97
120
|
async function main() {
|
|
98
121
|
const [cmd, ...rest] = process.argv.slice(2);
|
|
122
|
+
if (cmd === '--version' || cmd === '-v' || cmd === 'version') {
|
|
123
|
+
process.stdout.write(`${RUNNER_VERSION}\n`);
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
99
126
|
if (!cmd || cmd === '--help' || cmd === '-h' || cmd === 'help') {
|
|
100
127
|
process.stdout.write(HELP);
|
|
101
128
|
return;
|
|
@@ -220,6 +247,36 @@ async function main() {
|
|
|
220
247
|
await runBrief(repo, cfg);
|
|
221
248
|
return;
|
|
222
249
|
}
|
|
250
|
+
if (cmd === 'mcp') {
|
|
251
|
+
const f = parseFlags(rest);
|
|
252
|
+
const positional = rest.filter((a) => !a.startsWith('--'));
|
|
253
|
+
const sub = positional[0];
|
|
254
|
+
const tool = positional[1];
|
|
255
|
+
if (sub === 'list') {
|
|
256
|
+
runMcpList();
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
if (sub === 'login' || sub === 'logout') {
|
|
260
|
+
if (!tool) {
|
|
261
|
+
process.stderr.write(`Usage: firefunc-runner mcp ${sub} <tool>\n` +
|
|
262
|
+
`Example: firefunc-runner mcp ${sub} jira\n` +
|
|
263
|
+
`Which tools this machine can sign in to: firefunc-runner mcp list\n`);
|
|
264
|
+
process.exitCode = 1;
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
if (sub === 'login')
|
|
268
|
+
await runMcpLogin(tool, { noBrowser: Boolean(f['no-browser']) });
|
|
269
|
+
else
|
|
270
|
+
await runMcpLogout(tool);
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
273
|
+
process.stderr.write(`Usage: firefunc-runner mcp <login|list|logout> [tool]\n` +
|
|
274
|
+
` firefunc-runner mcp login jira sign THIS machine in to Jira's MCP server\n` +
|
|
275
|
+
` firefunc-runner mcp list what this machine is signed in to\n` +
|
|
276
|
+
` firefunc-runner mcp logout jira forget that sign-in\n`);
|
|
277
|
+
process.exitCode = 1;
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
223
280
|
if (cmd === 'status') {
|
|
224
281
|
const cfg = loadConfig();
|
|
225
282
|
if (!cfg) {
|
|
@@ -236,7 +293,7 @@ async function main() {
|
|
|
236
293
|
` gemini: ${cfg.geminiBin ?? 'gemini'}${cfg.geminiApiKey ? ' (API key set)' : ' (env auth)'}\n` +
|
|
237
294
|
` cursor: ${cfg.cursorAgentBin ?? 'cursor-agent'}${cfg.cursorApiKey ? ' (API key set)' : ' (no key — set --cursor-api-key)'}\n` +
|
|
238
295
|
` liveViewer:${cfg.viewerEnabled === false ? ' off' : ` http://127.0.0.1:${cfg.viewerPort ?? 8787} (local only)`}\n` +
|
|
239
|
-
` maxParallel:${cfg.maxParallel
|
|
296
|
+
` maxParallel:${cfg.maxParallel ? ` ${cfg.maxParallel} at once (set here — overrides FireFunc)` : ' from FireFunc (the highest "Runs at once" among the projects this machine serves)'}\n` +
|
|
240
297
|
` claudeAuth:${cfg.claudeUseApiKey
|
|
241
298
|
? ' ANTHROPIC_API_KEY (API billing — opted in)'
|
|
242
299
|
: cfg.claudeCodeOAuthToken
|
package/dist/config.d.ts
CHANGED
|
@@ -13,6 +13,10 @@ export type RunnerConfig = {
|
|
|
13
13
|
geminiBin?: string;
|
|
14
14
|
geminiApiKey?: string;
|
|
15
15
|
geminiArgs?: string[];
|
|
16
|
+
antigravityBin?: string;
|
|
17
|
+
antigravityArgs?: string[];
|
|
18
|
+
copilotBin?: string;
|
|
19
|
+
copilotArgs?: string[];
|
|
16
20
|
cursorAgentBin?: string;
|
|
17
21
|
cursorApiKey?: string;
|
|
18
22
|
cursorArgs?: string[];
|
|
@@ -30,6 +34,8 @@ export type RunnerConfig = {
|
|
|
30
34
|
claudeUseApiKey?: boolean;
|
|
31
35
|
claudeArgs?: string[];
|
|
32
36
|
jobTimeoutMinutes?: number;
|
|
37
|
+
mcpRelay?: boolean;
|
|
38
|
+
heavyLock?: boolean;
|
|
33
39
|
baseBranch?: string;
|
|
34
40
|
claudeEnv?: Record<string, string>;
|
|
35
41
|
setupCommands?: string[];
|
|
@@ -41,3 +47,4 @@ export type RunnerConfig = {
|
|
|
41
47
|
export declare function configPath(): string;
|
|
42
48
|
export declare function loadConfig(): RunnerConfig | null;
|
|
43
49
|
export declare function saveConfig(cfg: RunnerConfig): void;
|
|
50
|
+
export declare function runnerDir(): string;
|
package/dist/config.js
CHANGED
package/dist/cut.d.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { RunUsage } from './usage.js';
|
|
2
|
+
import type { WrittenSkills } from './skills.js';
|
|
3
|
+
export type CutSession = {
|
|
4
|
+
workItemId: string;
|
|
5
|
+
runId: string;
|
|
6
|
+
engine: string;
|
|
7
|
+
sessionId: string;
|
|
8
|
+
repo: string | null;
|
|
9
|
+
branch: string;
|
|
10
|
+
base: string;
|
|
11
|
+
worktree: string;
|
|
12
|
+
repoPath: string | null;
|
|
13
|
+
readHead?: string;
|
|
14
|
+
resetsAt: string | null;
|
|
15
|
+
cutAt: string;
|
|
16
|
+
keepUntil: string;
|
|
17
|
+
promptHash: string;
|
|
18
|
+
review: boolean;
|
|
19
|
+
toolsOnly: boolean;
|
|
20
|
+
continuesBranch: boolean;
|
|
21
|
+
usage?: RunUsage;
|
|
22
|
+
writtenSkills?: WrittenSkills;
|
|
23
|
+
};
|
|
24
|
+
export declare function cutDir(runnerDir: string): string;
|
|
25
|
+
export declare function promptHash(prompt: string): string;
|
|
26
|
+
export declare function keepUntil(resetsAt: string | null, cutAt: number): string;
|
|
27
|
+
export declare function saveCut(runnerDir: string, cut: CutSession): boolean;
|
|
28
|
+
export declare function listCuts(runnerDir: string): CutSession[];
|
|
29
|
+
export declare function dropCut(runnerDir: string, workItemId: string): void;
|
|
30
|
+
export type CutKey = {
|
|
31
|
+
workItemId: string;
|
|
32
|
+
engine: string;
|
|
33
|
+
repo: string | null;
|
|
34
|
+
branch: string;
|
|
35
|
+
review: boolean;
|
|
36
|
+
toolsOnly: boolean;
|
|
37
|
+
};
|
|
38
|
+
export declare function cutFor(runnerDir: string, key: CutKey, now?: number): {
|
|
39
|
+
resume: CutSession;
|
|
40
|
+
} | {
|
|
41
|
+
discard: CutSession;
|
|
42
|
+
} | null;
|
|
43
|
+
export declare function expiredCuts(runnerDir: string, now?: number): CutSession[];
|
|
44
|
+
export declare function keptWorktrees(runnerDir: string): Set<string>;
|
|
45
|
+
export declare function resumeAfterResetBrief(prompt: string, briefChanged: boolean): string;
|
package/dist/cut.js
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { existsSync, mkdirSync, readdirSync, readFileSync, renameSync, unlinkSync, writeFileSync, } from 'node:fs';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
const DAY = 86_400_000;
|
|
5
|
+
const ITEM_ID = /^[A-Za-z0-9][A-Za-z0-9-]{3,79}$/;
|
|
6
|
+
export function cutDir(runnerDir) {
|
|
7
|
+
return join(runnerDir, 'cut');
|
|
8
|
+
}
|
|
9
|
+
function fileFor(runnerDir, workItemId) {
|
|
10
|
+
return typeof workItemId === 'string' && ITEM_ID.test(workItemId)
|
|
11
|
+
? join(cutDir(runnerDir), `${workItemId}.json`)
|
|
12
|
+
: null;
|
|
13
|
+
}
|
|
14
|
+
export function promptHash(prompt) {
|
|
15
|
+
return createHash('sha256').update(prompt).digest('hex').slice(0, 32);
|
|
16
|
+
}
|
|
17
|
+
export function keepUntil(resetsAt, cutAt) {
|
|
18
|
+
const reset = resetsAt ? Date.parse(resetsAt) : Number.NaN;
|
|
19
|
+
const from = Number.isFinite(reset) ? Math.max(reset, cutAt) : cutAt;
|
|
20
|
+
return new Date(Math.min(from + DAY, cutAt + 8 * DAY)).toISOString();
|
|
21
|
+
}
|
|
22
|
+
export function saveCut(runnerDir, cut) {
|
|
23
|
+
const file = fileFor(runnerDir, cut.workItemId);
|
|
24
|
+
if (!file)
|
|
25
|
+
return false;
|
|
26
|
+
try {
|
|
27
|
+
mkdirSync(cutDir(runnerDir), { recursive: true, mode: 0o700 });
|
|
28
|
+
const tmp = `${file}.${process.pid}.tmp`;
|
|
29
|
+
writeFileSync(tmp, `${JSON.stringify(cut, null, 2)}\n`, { mode: 0o600 });
|
|
30
|
+
renameSync(tmp, file);
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
export function listCuts(runnerDir) {
|
|
38
|
+
const dir = cutDir(runnerDir);
|
|
39
|
+
if (!existsSync(dir))
|
|
40
|
+
return [];
|
|
41
|
+
const out = [];
|
|
42
|
+
for (const name of readdirSync(dir)) {
|
|
43
|
+
if (!name.endsWith('.json'))
|
|
44
|
+
continue;
|
|
45
|
+
try {
|
|
46
|
+
const rec = JSON.parse(readFileSync(join(dir, name), 'utf8'));
|
|
47
|
+
if (rec &&
|
|
48
|
+
typeof rec.workItemId === 'string' &&
|
|
49
|
+
typeof rec.sessionId === 'string' &&
|
|
50
|
+
typeof rec.worktree === 'string' &&
|
|
51
|
+
typeof rec.keepUntil === 'string') {
|
|
52
|
+
out.push(rec);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return out;
|
|
59
|
+
}
|
|
60
|
+
export function dropCut(runnerDir, workItemId) {
|
|
61
|
+
const file = fileFor(runnerDir, workItemId);
|
|
62
|
+
if (!file)
|
|
63
|
+
return;
|
|
64
|
+
try {
|
|
65
|
+
unlinkSync(file);
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
export function cutFor(runnerDir, key, now = Date.now()) {
|
|
71
|
+
const file = fileFor(runnerDir, key.workItemId);
|
|
72
|
+
if (!file || !existsSync(file))
|
|
73
|
+
return null;
|
|
74
|
+
const cut = listCuts(runnerDir).find((c) => c.workItemId === key.workItemId);
|
|
75
|
+
if (!cut)
|
|
76
|
+
return null;
|
|
77
|
+
const matches = cut.engine === key.engine &&
|
|
78
|
+
(cut.repo ?? null) === (key.repo ?? null) &&
|
|
79
|
+
cut.branch === key.branch &&
|
|
80
|
+
cut.review === key.review &&
|
|
81
|
+
cut.toolsOnly === key.toolsOnly;
|
|
82
|
+
if (!matches || Date.parse(cut.keepUntil) <= now || !existsSync(cut.worktree)) {
|
|
83
|
+
return { discard: cut };
|
|
84
|
+
}
|
|
85
|
+
const reset = cut.resetsAt ? Date.parse(cut.resetsAt) : Number.NaN;
|
|
86
|
+
if (Number.isFinite(reset) && reset > now)
|
|
87
|
+
return null;
|
|
88
|
+
return { resume: cut };
|
|
89
|
+
}
|
|
90
|
+
export function expiredCuts(runnerDir, now = Date.now()) {
|
|
91
|
+
return listCuts(runnerDir).filter((c) => Date.parse(c.keepUntil) <= now);
|
|
92
|
+
}
|
|
93
|
+
export function keptWorktrees(runnerDir) {
|
|
94
|
+
return new Set(listCuts(runnerDir).map((c) => c.worktree));
|
|
95
|
+
}
|
|
96
|
+
export function resumeAfterResetBrief(prompt, briefChanged) {
|
|
97
|
+
return ("Your session on this task was stopped by the plan's usage limit, which has now reset. " +
|
|
98
|
+
'The worktree still holds everything you did — check `git status` and `git diff`, then ' +
|
|
99
|
+
'continue from where you stopped and finish the task.' +
|
|
100
|
+
(briefChanged
|
|
101
|
+
? ' FireFunc sent this run a brief that differs from the one you started with; it follows, and where the two differ, follow this one.\n\n' +
|
|
102
|
+
prompt
|
|
103
|
+
: ''));
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=cut.js.map
|
package/dist/daemon.d.ts
CHANGED
|
@@ -1,2 +1,18 @@
|
|
|
1
|
+
import { type EngineLimitReport } from './api.js';
|
|
1
2
|
import type { RunnerConfig } from './config.js';
|
|
3
|
+
export type ClaimState = {
|
|
4
|
+
holding: Iterable<string>;
|
|
5
|
+
pending: Iterable<string>;
|
|
6
|
+
lostRuns?: string[];
|
|
7
|
+
limits?: EngineLimitReport[];
|
|
8
|
+
heartbeat?: boolean;
|
|
9
|
+
draining?: boolean;
|
|
10
|
+
};
|
|
11
|
+
export declare function claimState(s: ClaimState): {
|
|
12
|
+
heldRuns: string[];
|
|
13
|
+
lostRuns?: string[];
|
|
14
|
+
limits?: EngineLimitReport[];
|
|
15
|
+
heartbeat?: true;
|
|
16
|
+
draining?: true;
|
|
17
|
+
};
|
|
2
18
|
export declare function startDaemon(cfg: RunnerConfig): Promise<void>;
|