@firefunc-agent/runner 0.9.6 → 0.9.14

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.
Files changed (59) hide show
  1. package/README.md +2 -0
  2. package/dist/activity.d.ts +1 -0
  3. package/dist/activity.js +1 -1
  4. package/dist/api-fallback.d.ts +9 -0
  5. package/dist/api-fallback.js +55 -0
  6. package/dist/api.d.ts +138 -0
  7. package/dist/api.js +153 -4
  8. package/dist/ask/index.d.ts +20 -0
  9. package/dist/ask/index.js +64 -0
  10. package/dist/ask-first.d.ts +59 -0
  11. package/dist/ask-first.js +126 -0
  12. package/dist/brief.d.ts +2 -0
  13. package/dist/brief.js +6 -0
  14. package/dist/build-info.json +2 -2
  15. package/dist/config.d.ts +2 -0
  16. package/dist/cut.d.ts +3 -1
  17. package/dist/cut.js +15 -4
  18. package/dist/daemon.js +51 -5
  19. package/dist/engines/claude.js +10 -4
  20. package/dist/engines/copilot.js +3 -2
  21. package/dist/firefunc/agents.js +1 -1
  22. package/dist/git-auth.d.ts +1 -0
  23. package/dist/git-auth.js +9 -1
  24. package/dist/job.js +1324 -804
  25. package/dist/keep-local.d.ts +1 -0
  26. package/dist/keep-local.js +3 -0
  27. package/dist/limit.d.ts +1 -0
  28. package/dist/limit.js +4 -1
  29. package/dist/locks.d.ts +3 -0
  30. package/dist/locks.js +46 -13
  31. package/dist/plan-phase/index.d.ts +11 -0
  32. package/dist/plan-phase/index.js +46 -0
  33. package/dist/pool.js +4 -2
  34. package/dist/pr-title.d.ts +5 -0
  35. package/dist/pr-title.js +18 -0
  36. package/dist/reference-files.d.ts +27 -0
  37. package/dist/reference-files.js +202 -0
  38. package/dist/run-attachments.d.ts +79 -0
  39. package/dist/run-attachments.js +276 -0
  40. package/dist/secret-scan.d.ts +1 -1
  41. package/dist/secret-scan.js +3 -0
  42. package/dist/secret-values.d.ts +17 -0
  43. package/dist/secret-values.js +81 -0
  44. package/dist/trail/chain.d.ts +12 -0
  45. package/dist/trail/chain.js +89 -0
  46. package/dist/trail/deltas.d.ts +34 -0
  47. package/dist/trail/deltas.js +206 -0
  48. package/dist/trail/index.d.ts +27 -0
  49. package/dist/trail/index.js +128 -0
  50. package/dist/trail/keys.d.ts +14 -0
  51. package/dist/trail/keys.js +61 -0
  52. package/dist/trail/recorder.d.ts +118 -0
  53. package/dist/trail/recorder.js +697 -0
  54. package/dist/trail/rules.d.ts +30 -0
  55. package/dist/trail/rules.js +158 -0
  56. package/dist/trail/stream.d.ts +41 -0
  57. package/dist/trail/stream.js +86 -0
  58. package/package.json +1 -1
  59. package/skill/firefunc/SKILL.md +3 -3
@@ -0,0 +1,30 @@
1
+ export declare const LIMITS: {
2
+ readonly path: 300;
3
+ readonly label: 120;
4
+ readonly words: 300;
5
+ readonly files: 200;
6
+ readonly hunks: 200;
7
+ readonly plan: 50;
8
+ readonly argv: 30;
9
+ };
10
+ export declare const WITHHELD_PATH = "[path withheld]";
11
+ export declare const WITHHELD_WORDS = "[words withheld]";
12
+ export type Category = 'lifecycle' | 'data' | 'control' | 'network' | 'policy' | 'approval';
13
+ export declare const TYPE_CATEGORY: Record<string, Category>;
14
+ export declare function isStorablePath(p: string): boolean;
15
+ export declare function storablePath(p: string): string;
16
+ export declare function argvShapeOf(words: readonly string[]): string[];
17
+ export declare function flagsOfCommand(command: string): string[];
18
+ export declare function storableWords(text: string, max?: number): string | null;
19
+ export type SensitiveClass = 'secret_file' | 'ci_config' | 'migration' | 'lockfile' | 'dependency_manifest' | 'infra';
20
+ export declare function sensitiveClassOf(path: string): SensitiveClass | undefined;
21
+ export declare function isTestPath(path: string): boolean;
22
+ export type Risk = 'low' | 'med' | 'high';
23
+ export declare function riskOf(type: string, opts?: {
24
+ sensitive?: boolean;
25
+ write?: boolean;
26
+ }): Risk;
27
+ export declare function hostOf(url: string): {
28
+ host: string;
29
+ port?: number;
30
+ } | null;
@@ -0,0 +1,158 @@
1
+ import { stripCode, textCarriesSecret } from '../keep-local.js';
2
+ export const LIMITS = {
3
+ path: 300,
4
+ label: 120,
5
+ words: 300,
6
+ files: 200,
7
+ hunks: 200,
8
+ plan: 50,
9
+ argv: 30,
10
+ };
11
+ export const WITHHELD_PATH = '[path withheld]';
12
+ export const WITHHELD_WORDS = '[words withheld]';
13
+ export const TYPE_CATEGORY = {
14
+ 'run.started': 'lifecycle',
15
+ 'setup.ran': 'lifecycle',
16
+ 'engine.started': 'lifecycle',
17
+ 'engine.ended': 'lifecycle',
18
+ 'run.ended': 'lifecycle',
19
+ gap: 'lifecycle',
20
+ 'file.read': 'data',
21
+ 'file.edited': 'data',
22
+ 'file.changed': 'data',
23
+ search: 'data',
24
+ 'skill.read': 'data',
25
+ exec: 'control',
26
+ 'tool.call': 'control',
27
+ 'subagent.started': 'control',
28
+ 'plan.updated': 'control',
29
+ 'git.commit': 'control',
30
+ 'git.push': 'control',
31
+ 'pr.opened': 'control',
32
+ 'web.fetch': 'network',
33
+ 'web.search': 'network',
34
+ 'policy.decision': 'policy',
35
+ 'approval.requested': 'approval',
36
+ 'approval.answered': 'approval',
37
+ 'question.asked': 'approval',
38
+ 'question.answered': 'approval',
39
+ 'plan.approved': 'approval',
40
+ 'criterion.reported': 'approval',
41
+ 'rollback.action': 'control',
42
+ };
43
+ export function isStorablePath(p) {
44
+ if (!p || p.length > LIMITS.path)
45
+ return false;
46
+ if (/[\n\r\t\0]/.test(p))
47
+ return false;
48
+ if (/^(?:\/|[A-Za-z]:[\\/]|~)/.test(p))
49
+ return false;
50
+ if (p.startsWith('…/'))
51
+ return true;
52
+ return !textCarriesSecret(p);
53
+ }
54
+ export function storablePath(p) {
55
+ return isStorablePath(p) ? p : WITHHELD_PATH;
56
+ }
57
+ export function argvShapeOf(words) {
58
+ const out = [];
59
+ for (const w of words) {
60
+ const m = /^(--?[A-Za-z][\w-]{0,40})(?:=.*)?$/.exec(w);
61
+ if (m)
62
+ out.push(m[1]);
63
+ if (out.length >= LIMITS.argv)
64
+ break;
65
+ }
66
+ return out;
67
+ }
68
+ export function flagsOfCommand(command) {
69
+ const words = command.replace(/'[^']*'|"(?:\\.|[^"\\])*"/g, ' ').split(/\s+/);
70
+ return [...new Set(argvShapeOf(words))];
71
+ }
72
+ export function storableWords(text, max = LIMITS.label) {
73
+ const one = stripCode(text).replace(/\s+/g, ' ').trim();
74
+ if (!one)
75
+ return null;
76
+ if (textCarriesSecret(one))
77
+ return WITHHELD_WORDS;
78
+ return one.length > max ? `${one.slice(0, max - 1)}…` : one;
79
+ }
80
+ export function sensitiveClassOf(path) {
81
+ const p = path.replace(/\\/g, '/').toLowerCase();
82
+ const base = p.split('/').pop() ?? p;
83
+ if (/^\.env(?:\..+)?$/.test(base) ||
84
+ /\.(?:pem|key|p12|pfx|jks|keystore)$/.test(base) ||
85
+ /^id_(?:rsa|dsa|ecdsa|ed25519)$/.test(base) ||
86
+ /(?:^|\/)(?:secrets?|credentials?)(?:\/|$)/.test(p) ||
87
+ base === '.npmrc' ||
88
+ base === '.netrc')
89
+ return 'secret_file';
90
+ if (p.startsWith('.github/workflows/') ||
91
+ base === '.gitlab-ci.yml' ||
92
+ p.startsWith('.circleci/') ||
93
+ p.startsWith('.buildkite/') ||
94
+ base === 'jenkinsfile' ||
95
+ base === 'azure-pipelines.yml')
96
+ return 'ci_config';
97
+ if (/(?:^|\/)(?:migrations?|migrate|db\/migrate|alembic\/versions)\//.test(p))
98
+ return 'migration';
99
+ if ([
100
+ 'package-lock.json',
101
+ 'pnpm-lock.yaml',
102
+ 'yarn.lock',
103
+ 'bun.lockb',
104
+ 'cargo.lock',
105
+ 'go.sum',
106
+ 'poetry.lock',
107
+ 'pipfile.lock',
108
+ 'gemfile.lock',
109
+ 'composer.lock',
110
+ 'uv.lock',
111
+ ].includes(base))
112
+ return 'lockfile';
113
+ if ([
114
+ 'package.json',
115
+ 'cargo.toml',
116
+ 'go.mod',
117
+ 'pyproject.toml',
118
+ 'requirements.txt',
119
+ 'gemfile',
120
+ 'composer.json',
121
+ 'pom.xml',
122
+ 'build.gradle',
123
+ ].includes(base))
124
+ return 'dependency_manifest';
125
+ if (/\.(?:tf|tfvars|hcl)$/.test(base) ||
126
+ base === 'dockerfile' ||
127
+ /^docker-compose.*\.ya?ml$/.test(base) ||
128
+ /(?:^|\/)(?:k8s|kubernetes|helm|charts|infrastructure|infra)\//.test(p))
129
+ return 'infra';
130
+ return undefined;
131
+ }
132
+ export function isTestPath(path) {
133
+ return /(?:^|\/)(?:__tests__|tests?|spec|e2e)\/|\.(?:test|spec)\.[a-z0-9]+$|_test\.(?:go|py)$|(?:^|\/)test_[^/]+\.py$/i.test(path);
134
+ }
135
+ export function riskOf(type, opts = {}) {
136
+ if (type === 'git.push' || type === 'pr.opened' || type === 'rollback.action')
137
+ return 'high';
138
+ if (type === 'tool.call')
139
+ return opts.write ? 'high' : 'low';
140
+ if (type === 'file.edited' || type === 'file.changed' || type === 'exec')
141
+ return opts.sensitive ? 'high' : 'med';
142
+ if (type === 'web.fetch')
143
+ return 'med';
144
+ return 'low';
145
+ }
146
+ const HOST = /^(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)*[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/i;
147
+ export function hostOf(url) {
148
+ try {
149
+ const u = new URL(url);
150
+ if (!HOST.test(u.hostname))
151
+ return null;
152
+ return { host: u.hostname, ...(u.port ? { port: Number(u.port) } : {}) };
153
+ }
154
+ catch {
155
+ return null;
156
+ }
157
+ }
158
+ //# sourceMappingURL=rules.js.map
@@ -0,0 +1,41 @@
1
+ export type ToolInput = {
2
+ file_path?: string;
3
+ notebook_path?: string;
4
+ path?: string;
5
+ command?: string;
6
+ run_in_background?: boolean;
7
+ url?: string;
8
+ query?: boolean;
9
+ subagent_type?: string;
10
+ skill?: string;
11
+ todos?: Array<{
12
+ content: string;
13
+ status: string;
14
+ }>;
15
+ pattern_is_glob?: boolean;
16
+ };
17
+ export type TrailStreamEvent = {
18
+ kind: 'init';
19
+ model?: string;
20
+ version?: string;
21
+ } | {
22
+ kind: 'tool_use';
23
+ id: string;
24
+ name: string;
25
+ input: ToolInput;
26
+ parentId?: string;
27
+ } | {
28
+ kind: 'tool_result';
29
+ id: string;
30
+ isError: boolean;
31
+ parentId?: string;
32
+ } | {
33
+ kind: 'result';
34
+ durationMs?: number;
35
+ turns?: number;
36
+ isError?: boolean;
37
+ tokensIn?: number;
38
+ tokensOut?: number;
39
+ tokensCache?: number;
40
+ };
41
+ export declare function makeTrailStreamParser(onEvent: (ev: TrailStreamEvent) => void): (chunk: string) => void;
@@ -0,0 +1,86 @@
1
+ const str = (v) => (typeof v === 'string' && v ? v : undefined);
2
+ const num = (v) => typeof v === 'number' && Number.isFinite(v) && v >= 0 ? Math.round(v) : undefined;
3
+ function inputOf(raw) {
4
+ const todos = Array.isArray(raw.todos)
5
+ ? raw.todos.flatMap((t) => {
6
+ const o = t;
7
+ return o && typeof o.content === 'string' && typeof o.status === 'string'
8
+ ? [{ content: o.content, status: o.status }]
9
+ : [];
10
+ })
11
+ : undefined;
12
+ return {
13
+ ...(str(raw.file_path) ? { file_path: str(raw.file_path) } : {}),
14
+ ...(str(raw.notebook_path) ? { notebook_path: str(raw.notebook_path) } : {}),
15
+ ...(str(raw.path) ? { path: str(raw.path) } : {}),
16
+ ...(str(raw.command) ? { command: str(raw.command) } : {}),
17
+ ...(raw.run_in_background === true ? { run_in_background: true } : {}),
18
+ ...(str(raw.url) ? { url: str(raw.url) } : {}),
19
+ ...(str(raw.query) ? { query: true } : {}),
20
+ ...(str(raw.subagent_type) ? { subagent_type: str(raw.subagent_type) } : {}),
21
+ ...(str(raw.skill) ? { skill: str(raw.skill) } : {}),
22
+ ...(todos ? { todos } : {}),
23
+ };
24
+ }
25
+ export function makeTrailStreamParser(onEvent) {
26
+ let buf = '';
27
+ return (chunk) => {
28
+ buf += chunk;
29
+ let nl = buf.indexOf('\n');
30
+ while (nl >= 0) {
31
+ const raw = buf.slice(0, nl).trim();
32
+ buf = buf.slice(nl + 1);
33
+ nl = buf.indexOf('\n');
34
+ if (!raw || raw[0] !== '{')
35
+ continue;
36
+ let line;
37
+ try {
38
+ line = JSON.parse(raw);
39
+ }
40
+ catch {
41
+ continue;
42
+ }
43
+ const parentId = str(line.parent_tool_use_id);
44
+ if (line.type === 'system' && line.subtype === 'init') {
45
+ onEvent({ kind: 'init', model: str(line.model), version: str(line.claude_code_version) });
46
+ }
47
+ else if (line.type === 'assistant' && Array.isArray(line.message?.content)) {
48
+ for (const c of line.message.content) {
49
+ if (c?.type === 'tool_use' && typeof c.name === 'string' && typeof c.id === 'string') {
50
+ onEvent({
51
+ kind: 'tool_use',
52
+ id: c.id,
53
+ name: c.name,
54
+ input: inputOf((c.input ?? {})),
55
+ ...(parentId ? { parentId } : {}),
56
+ });
57
+ }
58
+ }
59
+ }
60
+ else if (line.type === 'user' && Array.isArray(line.message?.content)) {
61
+ for (const c of line.message.content) {
62
+ if (c?.type === 'tool_result' && typeof c.tool_use_id === 'string') {
63
+ onEvent({
64
+ kind: 'tool_result',
65
+ id: c.tool_use_id,
66
+ isError: c.is_error === true,
67
+ ...(parentId ? { parentId } : {}),
68
+ });
69
+ }
70
+ }
71
+ }
72
+ else if (line.type === 'result') {
73
+ onEvent({
74
+ kind: 'result',
75
+ durationMs: num(line.duration_ms),
76
+ turns: num(line.num_turns),
77
+ isError: line.is_error === true,
78
+ tokensIn: num(line.usage?.input_tokens),
79
+ tokensOut: num(line.usage?.output_tokens),
80
+ tokensCache: num(line.usage?.cache_read_input_tokens),
81
+ });
82
+ }
83
+ }
84
+ };
85
+ }
86
+ //# sourceMappingURL=stream.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@firefunc-agent/runner",
3
- "version": "0.9.6",
3
+ "version": "0.9.14",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "FireFunc self-hosted runner — an always-on daemon that runs YOUR local coding agent (Claude Code, Codex, Gemini CLI, Cursor CLI) on work FireFunc routes to it, opens pull requests, and reports back. Your machine, your subscriptions.",
@@ -120,9 +120,9 @@ EOF
120
120
  - Leave `status` out. The CLI refuses a spec that sets it.
121
121
 
122
122
  The answer has `agent`, `composerUrl` and `warnings`. The API gives a new
123
- draft the composer's cautious defaults for anything the spec leaves out:
124
- Preview autonomy (`guardrails.dry_run_mode: true`, `auto_merge: false`), at most
125
- 5 runs a day, and the template's grants and deliverables, or GitHub read and
123
+ draft the agent page's defaults for anything the spec leaves out: Autonomous
124
+ (`guardrails.dry_run_mode: false`, `auto_merge: false` unless the template merges
125
+ — it opens pull requests once a person activates it), at most 5 runs a day, and the template's grants and deliverables, or GitHub read and
126
126
  write without a template. It names in `warnings` each default part it had to
127
127
  leave out, with the fix.
128
128
  `agent.activation.missing` lists what activation still waits on. **Give the