@firefunc-agent/runner 0.9.0 → 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/README.md +90 -28
- package/dist/activity.d.ts +4 -1
- package/dist/activity.js +94 -8
- package/dist/api.d.ts +24 -0
- package/dist/api.js +74 -5
- package/dist/brief.d.ts +5 -0
- package/dist/brief.js +21 -0
- package/dist/build-info.json +2 -2
- package/dist/cli.js +10 -2
- package/dist/config.d.ts +2 -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 +156 -35
- package/dist/declined.d.ts +11 -0
- package/dist/declined.js +27 -0
- package/dist/engines/claude.js +129 -1
- package/dist/engines/types.d.ts +10 -0
- package/dist/exec.d.ts +3 -0
- package/dist/exec.js +48 -5
- package/dist/firefunc/agents.js +59 -7
- package/dist/firefunc/client.d.ts +1 -0
- package/dist/firefunc/client.js +3 -0
- package/dist/firefunc/configure.d.ts +6 -0
- package/dist/firefunc/configure.js +409 -0
- package/dist/firefunc/main.js +45 -7
- package/dist/firefunc/output.js +4 -1
- package/dist/firefunc/version.js +2 -17
- package/dist/held.d.ts +18 -0
- package/dist/held.js +95 -0
- package/dist/job.d.ts +3 -0
- package/dist/job.js +437 -76
- package/dist/keep-local.d.ts +6 -1
- package/dist/keep-local.js +171 -4
- 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/mcp-proxy.d.ts +21 -0
- package/dist/mcp-proxy.js +180 -0
- package/dist/mcp.d.ts +2 -0
- package/dist/mcp.js +31 -2
- package/dist/orphans.d.ts +40 -0
- package/dist/orphans.js +235 -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/session-stream.d.ts +8 -1
- package/dist/session-stream.js +9 -1
- 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/worktrees.d.ts +15 -0
- package/dist/worktrees.js +96 -0
- package/package.json +1 -1
- package/skill/firefunc/SKILL.md +57 -8
package/dist/firefunc/main.js
CHANGED
|
@@ -3,6 +3,7 @@ import { agentCommands } from './agents.js';
|
|
|
3
3
|
import { authCommands } from './auth.js';
|
|
4
4
|
import { catalogCommands } from './catalog.js';
|
|
5
5
|
import { ApiClient } from './client.js';
|
|
6
|
+
import { configureCommands } from './configure.js';
|
|
6
7
|
import { DEFAULT_API_URL, resolveCredentials } from './config.js';
|
|
7
8
|
import { hideSecrets, looksLikeSecret } from './io.js';
|
|
8
9
|
import { printError } from './output.js';
|
|
@@ -15,6 +16,7 @@ export const COMMANDS = [
|
|
|
15
16
|
...catalogCommands,
|
|
16
17
|
...agentCommands,
|
|
17
18
|
...taskCommands,
|
|
19
|
+
...configureCommands,
|
|
18
20
|
...skillCommands,
|
|
19
21
|
];
|
|
20
22
|
const GROUPS = ['templates', 'projects', 'connections', 'skills', 'agents', 'tasks', 'skill'];
|
|
@@ -37,6 +39,21 @@ const SECTIONS = [
|
|
|
37
39
|
],
|
|
38
40
|
],
|
|
39
41
|
['Tasks', ['run', 'tasks list', 'tasks get', 'tasks watch', 'tasks states']],
|
|
42
|
+
[
|
|
43
|
+
'Configure the workspace (writes need workspace:configure)',
|
|
44
|
+
[
|
|
45
|
+
'skills directory',
|
|
46
|
+
'skills install',
|
|
47
|
+
'skills create',
|
|
48
|
+
'skills update',
|
|
49
|
+
'projects instructions get',
|
|
50
|
+
'projects instructions set',
|
|
51
|
+
'projects sources get',
|
|
52
|
+
'projects sources set',
|
|
53
|
+
'projects repos get',
|
|
54
|
+
'projects repos set',
|
|
55
|
+
],
|
|
56
|
+
],
|
|
40
57
|
['Claude Code', ['skill install', 'skill show']],
|
|
41
58
|
];
|
|
42
59
|
const COMMON_OPTIONS = [
|
|
@@ -62,11 +79,12 @@ function topHelp() {
|
|
|
62
79
|
out.push(` ${p.padEnd(w)}${byPath(p)?.summary ?? ''}`);
|
|
63
80
|
out.push('');
|
|
64
81
|
}
|
|
65
|
-
out.push('Agents are created as DRAFTS: each comes back with a link that opens it in the composer,', 'and a person activates it there. A key granted agents:activate may activate one here.', '', 'Every command takes --json for scripts and agents. Exit codes: 0 done; 1 refused or', 'failed (the reason and the fix on stderr); 2 the command line was wrong.', '', 'Environment:', ' FIREFUNC_API_KEY a workspace key to use instead of the one "login" saved', ` FIREFUNC_API_URL the API address (default ${DEFAULT_API_URL})`, ' FIREFUNC_CONFIG_DIR where "login" keeps the key (default ~/.firefunc)', '', 'Start: make a key in FireFunc → Settings → API keys, then: firefunc login', '');
|
|
82
|
+
out.push('Agents are created as DRAFTS: each comes back with a link that opens it in the composer,', 'and a person activates it there. A key granted agents:activate may activate one here.', 'Skills and a project’s instructions, repositories and claims are changed only with a key', 'granted workspace:configure.', '', 'Every command takes --json for scripts and agents. Exit codes: 0 done; 1 refused or', 'failed (the reason and the fix on stderr); 2 the command line was wrong.', '', 'Environment:', ' FIREFUNC_API_KEY a workspace key to use instead of the one "login" saved', ` FIREFUNC_API_URL the API address (default ${DEFAULT_API_URL})`, ' FIREFUNC_CONFIG_DIR where "login" keeps the key (default ~/.firefunc)', '', 'Start: make a key in FireFunc → Settings → API keys, then: firefunc login', '');
|
|
66
83
|
return out.join('\n');
|
|
67
84
|
}
|
|
85
|
+
const inGroup = (group) => COMMANDS.filter((c) => c.path.join(' ').startsWith(`${group} `));
|
|
68
86
|
function groupHelp(group) {
|
|
69
|
-
const cmds =
|
|
87
|
+
const cmds = inGroup(group);
|
|
70
88
|
const w = Math.max(...cmds.map((c) => c.path.join(' ').length)) + 2;
|
|
71
89
|
return [
|
|
72
90
|
`Usage: firefunc ${group} <command> [options]`,
|
|
@@ -107,7 +125,7 @@ function commandWords(argv) {
|
|
|
107
125
|
continue;
|
|
108
126
|
}
|
|
109
127
|
words.push({ word: a, index: i });
|
|
110
|
-
if (words.length ===
|
|
128
|
+
if (words.length === 3)
|
|
111
129
|
break;
|
|
112
130
|
}
|
|
113
131
|
return words;
|
|
@@ -134,9 +152,14 @@ export async function runFirefunc(argv, io) {
|
|
|
134
152
|
}
|
|
135
153
|
if (words[0].word === 'help') {
|
|
136
154
|
const rest = argv.filter((a) => !a.startsWith('-')).slice(1);
|
|
137
|
-
const c = byPath(rest.slice(0,
|
|
155
|
+
const c = byPath(rest.slice(0, 3).join(' ')) ??
|
|
156
|
+
byPath(rest.slice(0, 2).join(' ')) ??
|
|
157
|
+
byPath(rest[0] ?? '');
|
|
158
|
+
const sub = rest.slice(0, 2).join(' ');
|
|
138
159
|
if (c)
|
|
139
160
|
io.stdout.write(commandHelp(c));
|
|
161
|
+
else if (rest.length >= 2 && inGroup(sub).length)
|
|
162
|
+
io.stdout.write(groupHelp(sub));
|
|
140
163
|
else if (rest[0] && GROUPS.includes(rest[0]))
|
|
141
164
|
io.stdout.write(groupHelp(rest[0]));
|
|
142
165
|
else if (!rest.length)
|
|
@@ -145,13 +168,28 @@ export async function runFirefunc(argv, io) {
|
|
|
145
168
|
throw new UsageError(`No command "${shown(rest)}".`);
|
|
146
169
|
return 0;
|
|
147
170
|
}
|
|
148
|
-
const [first, second] = words;
|
|
149
|
-
let command =
|
|
150
|
-
let used = command ? [first.index, second.index] : [];
|
|
171
|
+
const [first, second, third] = words;
|
|
172
|
+
let command = third ? byPath(`${first.word} ${second.word} ${third.word}`) : undefined;
|
|
173
|
+
let used = command ? [first.index, second.index, third.index] : [];
|
|
174
|
+
if (!command && second) {
|
|
175
|
+
command = byPath(`${first.word} ${second.word}`);
|
|
176
|
+
used = command ? [first.index, second.index] : [];
|
|
177
|
+
}
|
|
151
178
|
if (!command) {
|
|
152
179
|
command = byPath(first.word);
|
|
153
180
|
used = command ? [first.index] : [];
|
|
154
181
|
}
|
|
182
|
+
const sub = second ? `${first.word} ${second.word}` : '';
|
|
183
|
+
if (!command && sub && inGroup(sub).length) {
|
|
184
|
+
if (wantsHelp && (!third || !byPath(`${sub} ${third.word}`))) {
|
|
185
|
+
io.stdout.write(groupHelp(sub));
|
|
186
|
+
return 0;
|
|
187
|
+
}
|
|
188
|
+
const verbs = inGroup(sub).map((c) => c.path[2]);
|
|
189
|
+
throw new UsageError(third
|
|
190
|
+
? `Unknown command "${shown([first.word, second.word, third.word])}": say ${verbs.join(' or ')}.`
|
|
191
|
+
: `Say what to do with "${sub}": ${verbs.join(' or ')}.`, `firefunc ${sub}`);
|
|
192
|
+
}
|
|
155
193
|
if (!command && GROUPS.includes(first.word)) {
|
|
156
194
|
const sub = second?.word;
|
|
157
195
|
const list = byPath(`${first.word} list`);
|
package/dist/firefunc/output.js
CHANGED
|
@@ -2,7 +2,10 @@ import { ApiRefusal, ApiUnreachable } from './client.js';
|
|
|
2
2
|
import { UsageError } from './args.js';
|
|
3
3
|
import { Refusal } from './io.js';
|
|
4
4
|
export function quietWhenReaderLeaves(stdout, stderr, exit) {
|
|
5
|
-
const epipe = (err) =>
|
|
5
|
+
const epipe = (err) => {
|
|
6
|
+
const code = err?.code;
|
|
7
|
+
return code === 'EPIPE' || code === 'ENOTCONN';
|
|
8
|
+
};
|
|
6
9
|
stdout.on('error', (err) => {
|
|
7
10
|
if (!epipe(err))
|
|
8
11
|
throw err;
|
package/dist/firefunc/version.js
CHANGED
|
@@ -1,22 +1,7 @@
|
|
|
1
|
-
import { readFileSync } from 'node:fs';
|
|
2
1
|
import { dirname, join } from 'node:path';
|
|
3
2
|
import { fileURLToPath } from 'node:url';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
for (const file of [
|
|
7
|
-
join(here, '..', 'build-info.json'),
|
|
8
|
-
join(here, '..', '..', 'package.json'),
|
|
9
|
-
]) {
|
|
10
|
-
try {
|
|
11
|
-
const v = JSON.parse(readFileSync(file, 'utf8')).version;
|
|
12
|
-
if (v)
|
|
13
|
-
return v;
|
|
14
|
-
}
|
|
15
|
-
catch {
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
return '0.0.0';
|
|
19
|
-
})();
|
|
3
|
+
import { RUNNER_VERSION } from '../version.js';
|
|
4
|
+
export const CLI_VERSION = RUNNER_VERSION;
|
|
20
5
|
export function packageRoot() {
|
|
21
6
|
return join(dirname(fileURLToPath(import.meta.url)), '..', '..');
|
|
22
7
|
}
|
package/dist/held.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type HeldRun = {
|
|
2
|
+
runId: string;
|
|
3
|
+
pid: number;
|
|
4
|
+
claimedAt: string;
|
|
5
|
+
worktree?: string;
|
|
6
|
+
repoPath?: string;
|
|
7
|
+
scratch?: string[];
|
|
8
|
+
engineGroup?: number;
|
|
9
|
+
engineStartedAt?: number;
|
|
10
|
+
};
|
|
11
|
+
export declare function heldDir(runnerDir: string): string;
|
|
12
|
+
export declare function recordHeld(runnerDir: string, runId: string, pid?: number): void;
|
|
13
|
+
export declare function updateHeld(runnerDir: string, runId: string, patch: Partial<Omit<HeldRun, 'runId' | 'pid' | 'claimedAt'>>): void;
|
|
14
|
+
export declare function releaseHeld(runnerDir: string, runId: string): void;
|
|
15
|
+
export declare function listHeld(runnerDir: string): HeldRun[];
|
|
16
|
+
export declare function heldByGoneProcesses(runnerDir: string, self?: number): HeldRun[];
|
|
17
|
+
export declare function heldByLiveProcesses(runnerDir: string, self?: number): string[];
|
|
18
|
+
export declare function liveWorktrees(runnerDir: string): Set<string>;
|
package/dist/held.js
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, readdirSync, readFileSync, renameSync, unlinkSync, writeFileSync, } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { isAlive } from './orphans.js';
|
|
4
|
+
const RUN_ID = /^[A-Za-z0-9][A-Za-z0-9-]{3,79}$/;
|
|
5
|
+
export function heldDir(runnerDir) {
|
|
6
|
+
return join(runnerDir, 'held');
|
|
7
|
+
}
|
|
8
|
+
function fileFor(runnerDir, runId) {
|
|
9
|
+
return typeof runId === 'string' && RUN_ID.test(runId)
|
|
10
|
+
? join(heldDir(runnerDir), `${runId}.json`)
|
|
11
|
+
: null;
|
|
12
|
+
}
|
|
13
|
+
function write(file, rec) {
|
|
14
|
+
const tmp = `${file}.${process.pid}.tmp`;
|
|
15
|
+
writeFileSync(tmp, `${JSON.stringify(rec, null, 2)}\n`, { mode: 0o600 });
|
|
16
|
+
renameSync(tmp, file);
|
|
17
|
+
}
|
|
18
|
+
export function recordHeld(runnerDir, runId, pid = process.pid) {
|
|
19
|
+
const file = fileFor(runnerDir, runId);
|
|
20
|
+
if (!file)
|
|
21
|
+
return;
|
|
22
|
+
try {
|
|
23
|
+
mkdirSync(heldDir(runnerDir), { recursive: true, mode: 0o700 });
|
|
24
|
+
write(file, { runId, pid, claimedAt: new Date().toISOString() });
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export function updateHeld(runnerDir, runId, patch) {
|
|
30
|
+
const file = fileFor(runnerDir, runId);
|
|
31
|
+
if (!file || !existsSync(file))
|
|
32
|
+
return;
|
|
33
|
+
try {
|
|
34
|
+
const rec = JSON.parse(readFileSync(file, 'utf8'));
|
|
35
|
+
const scratch = patch.scratch
|
|
36
|
+
? [...new Set([...(rec.scratch ?? []), ...patch.scratch])]
|
|
37
|
+
: rec.scratch;
|
|
38
|
+
write(file, { ...rec, ...patch, ...(scratch ? { scratch } : {}) });
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
export function releaseHeld(runnerDir, runId) {
|
|
44
|
+
const file = fileFor(runnerDir, runId);
|
|
45
|
+
if (!file)
|
|
46
|
+
return;
|
|
47
|
+
try {
|
|
48
|
+
unlinkSync(file);
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
export function listHeld(runnerDir) {
|
|
54
|
+
const dir = heldDir(runnerDir);
|
|
55
|
+
if (!existsSync(dir))
|
|
56
|
+
return [];
|
|
57
|
+
const out = [];
|
|
58
|
+
for (const name of readdirSync(dir)) {
|
|
59
|
+
if (!name.endsWith('.json'))
|
|
60
|
+
continue;
|
|
61
|
+
try {
|
|
62
|
+
const rec = JSON.parse(readFileSync(join(dir, name), 'utf8'));
|
|
63
|
+
if (rec &&
|
|
64
|
+
typeof rec.runId === 'string' &&
|
|
65
|
+
RUN_ID.test(rec.runId) &&
|
|
66
|
+
Number.isInteger(rec.pid)) {
|
|
67
|
+
out.push(rec);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return out.sort((a, b) => a.claimedAt.localeCompare(b.claimedAt));
|
|
74
|
+
}
|
|
75
|
+
export function heldByGoneProcesses(runnerDir, self = process.pid) {
|
|
76
|
+
return listHeld(runnerDir).filter((r) => r.pid !== self && !isAlive(r.pid));
|
|
77
|
+
}
|
|
78
|
+
export function heldByLiveProcesses(runnerDir, self = process.pid) {
|
|
79
|
+
return listHeld(runnerDir)
|
|
80
|
+
.filter((r) => r.pid === self || isAlive(r.pid))
|
|
81
|
+
.map((r) => r.runId);
|
|
82
|
+
}
|
|
83
|
+
export function liveWorktrees(runnerDir) {
|
|
84
|
+
const out = new Set();
|
|
85
|
+
for (const r of listHeld(runnerDir)) {
|
|
86
|
+
if (!isAlive(r.pid))
|
|
87
|
+
continue;
|
|
88
|
+
if (r.worktree)
|
|
89
|
+
out.add(r.worktree);
|
|
90
|
+
for (const s of r.scratch ?? [])
|
|
91
|
+
out.add(s);
|
|
92
|
+
}
|
|
93
|
+
return out;
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=held.js.map
|
package/dist/job.d.ts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import type { RunnerApi, ClaimedJob } from './api.js';
|
|
2
2
|
import { type RunnerConfig } from './config.js';
|
|
3
3
|
import type { SessionViewer } from './viewer.js';
|
|
4
|
+
import { type LimitGate } from './limit.js';
|
|
4
5
|
export declare function resolveRepoPath(repo: string | null | undefined, cfg: RunnerConfig): string | null;
|
|
5
6
|
export declare function cloneDestination(repo: string, cfg: RunnerConfig): string | null;
|
|
6
7
|
export declare function rememberRepoPath(repo: string, path: string, cfg: RunnerConfig): void;
|
|
7
8
|
export declare function hasGh(cwd: string): Promise<boolean>;
|
|
8
9
|
export declare function runJob(job: ClaimedJob, cfg: RunnerConfig, api: RunnerApi, viewer?: SessionViewer, opts?: {
|
|
9
10
|
devServerPort?: number;
|
|
11
|
+
limits?: LimitGate;
|
|
12
|
+
now?: () => Date;
|
|
10
13
|
}): Promise<void>;
|