@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
@@ -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 function textCarriesSecret(text: string): boolean;
3
4
  export declare function stripCode(text: string): string;
4
5
  export declare const UNNAMED_COMMAND = "a command";
5
6
  export declare function commandName(command: string): string;
@@ -89,6 +89,9 @@ const carriesSecret = (inner) => inner.length <= 1000 &&
89
89
  SECRET_ARG.test(inner) ||
90
90
  SECRET_CLI.test(inner) ||
91
91
  SECRET_ENV.test(inner));
92
+ export function textCarriesSecret(text) {
93
+ return carriesSecret(text);
94
+ }
92
95
  function inlineSpan(whole, inner) {
93
96
  const named = /^[\w@./-]+(?::\d+)?$/.test(inner.trim());
94
97
  const code = inner.includes('\n') ||
package/dist/limit.d.ts CHANGED
@@ -20,6 +20,7 @@ export declare class LimitGate {
20
20
  private readonly file;
21
21
  private readonly now;
22
22
  private limits;
23
+ waive: (engine: string) => boolean;
23
24
  constructor(file: string | null, now?: () => number);
24
25
  static fileIn(runnerDir: string): string;
25
26
  set(engine: string, limit: PlanLimit): ActiveLimit;
package/dist/limit.js CHANGED
@@ -173,6 +173,7 @@ export class LimitGate {
173
173
  file;
174
174
  now;
175
175
  limits = new Map();
176
+ waive = () => false;
176
177
  constructor(file, now = () => Date.now()) {
177
178
  this.file = file;
178
179
  this.now = now;
@@ -222,11 +223,13 @@ export class LimitGate {
222
223
  }
223
224
  isLimited(engine) {
224
225
  this.prune();
226
+ if (this.waive(engine))
227
+ return null;
225
228
  return this.limits.get(engine) ?? null;
226
229
  }
227
230
  active() {
228
231
  this.prune();
229
- return [...this.limits.values()];
232
+ return [...this.limits.values()].filter((l) => !this.waive(l.engine));
230
233
  }
231
234
  prune() {
232
235
  const nowMs = this.now();
package/dist/locks.d.ts CHANGED
@@ -15,4 +15,7 @@ export type HeavyLockOptions = {
15
15
  export declare function acquireHeavyLock(lockDir: string, opts?: HeavyLockOptions): Promise<() => void>;
16
16
  export declare function withHeavyLock<T>(lockDir: string, fn: () => Promise<T>, opts?: HeavyLockOptions): Promise<T>;
17
17
  export declare function heavyScript(): string;
18
+ export declare function deviceLockDir(runnerDir: string): string;
19
+ export declare function deviceScript(): string;
20
+ export declare function ensureDeviceScript(runnerDir: string): string | null;
18
21
  export declare function ensureHeavyScript(runnerDir: string): string | null;
package/dist/locks.js CHANGED
@@ -117,14 +117,15 @@ export async function withHeavyLock(lockDir, fn, opts = {}) {
117
117
  });
118
118
  }
119
119
  const HEAVY_SCRIPT_VERSION = 1;
120
- export function heavyScript() {
120
+ const DEVICE_SCRIPT_VERSION = 1;
121
+ function helperScript(h) {
121
122
  return `#!/bin/sh
122
- # firefunc-heavy v${HEAVY_SCRIPT_VERSION} — written by the FireFunc runner (locks.ts).
123
- # Runs ONE heavy command at a time per repository on this machine:
124
- # "$FIREFUNC_HEAVY" pnpm test
125
- # It waits for any other heavy command in the same repository, then runs yours.
126
- lock="\${FIREFUNC_HEAVY_LOCK:-}"
127
- if [ -z "$lock" ] || [ "\${FIREFUNC_HEAVY_HELD:-}" = "$lock" ]; then
123
+ # ${h.name} v${h.version} — written by the FireFunc runner (locks.ts).
124
+ # ${h.header}
125
+ # ${h.usage}
126
+ # It waits for ${h.waitsFor}, then runs yours.
127
+ lock="\${${h.lockVar}:-}"
128
+ if [ -z "$lock" ] || [ "\${${h.heldVar}:-}" = "$lock" ]; then
128
129
  exec "$@"
129
130
  fi
130
131
  mkdir -p "$(dirname "$lock")" 2>/dev/null
@@ -142,7 +143,7 @@ while ! mkdir "$lock" 2>/dev/null; do
142
143
  continue
143
144
  fi
144
145
  if [ "$told" = 0 ]; then
145
- echo "firefunc-heavy: another heavy command is running in this repository (pid \${holder:-?}) — waiting for it to finish first" >&2
146
+ echo "${h.name}: ${h.waiting} (pid \${holder:-?}) — waiting for it to finish first" >&2
146
147
  told=1
147
148
  fi
148
149
  sleep 2
@@ -151,17 +152,43 @@ printf '%s\\n%s\\n%s\\n%s\\n' "$$" "$(hostname)" "$(date -u +%Y-%m-%dT%H:%M:%SZ)
151
152
  trap 'rm -rf "$lock"' EXIT
152
153
  trap 'rm -rf "$lock"; exit 130' INT
153
154
  trap 'rm -rf "$lock"; exit 143' TERM
154
- FIREFUNC_HEAVY_HELD="$lock"
155
- export FIREFUNC_HEAVY_HELD
155
+ ${h.heldVar}="$lock"
156
+ export ${h.heldVar}
156
157
  "$@"
157
158
  `;
158
159
  }
159
- export function ensureHeavyScript(runnerDir) {
160
+ export function heavyScript() {
161
+ return helperScript({
162
+ name: 'firefunc-heavy',
163
+ version: HEAVY_SCRIPT_VERSION,
164
+ header: 'Runs ONE heavy command at a time per repository on this machine:',
165
+ usage: '"$FIREFUNC_HEAVY" pnpm test',
166
+ lockVar: 'FIREFUNC_HEAVY_LOCK',
167
+ heldVar: 'FIREFUNC_HEAVY_HELD',
168
+ waitsFor: 'any other heavy command in the same repository',
169
+ waiting: 'another heavy command is running in this repository',
170
+ });
171
+ }
172
+ export function deviceLockDir(runnerDir) {
173
+ return join(runnerDir, 'locks', 'device.lock');
174
+ }
175
+ export function deviceScript() {
176
+ return helperScript({
177
+ name: 'firefunc-device',
178
+ version: DEVICE_SCRIPT_VERSION,
179
+ header: 'Gives ONE session at a time the device (the emulator) on this machine:',
180
+ usage: '"$FIREFUNC_DEVICE" maestro test e2e/',
181
+ lockVar: 'FIREFUNC_DEVICE_LOCK',
182
+ heldVar: 'FIREFUNC_DEVICE_HELD',
183
+ waitsFor: 'any other session using the device',
184
+ waiting: 'another session is using the device',
185
+ });
186
+ }
187
+ function ensureScript(runnerDir, name, text) {
160
188
  if (process.platform === 'win32')
161
189
  return null;
162
190
  const dir = join(runnerDir, 'bin');
163
- const file = join(dir, 'firefunc-heavy');
164
- const text = heavyScript();
191
+ const file = join(dir, name);
165
192
  try {
166
193
  if (!existsSync(file) || readFileSync(file, 'utf8') !== text) {
167
194
  mkdirSync(dir, { recursive: true, mode: 0o700 });
@@ -174,4 +201,10 @@ export function ensureHeavyScript(runnerDir) {
174
201
  return null;
175
202
  }
176
203
  }
204
+ export function ensureDeviceScript(runnerDir) {
205
+ return ensureScript(runnerDir, 'firefunc-device', deviceScript());
206
+ }
207
+ export function ensureHeavyScript(runnerDir) {
208
+ return ensureScript(runnerDir, 'firefunc-heavy', heavyScript());
209
+ }
177
210
  //# sourceMappingURL=locks.js.map
@@ -0,0 +1,11 @@
1
+ export type Phase = 'plan' | 'work';
2
+ export declare function phaseOf(job: {
3
+ planFirst?: boolean;
4
+ planApproved?: boolean;
5
+ parkStep?: {
6
+ kind: string;
7
+ } | null;
8
+ }): Phase;
9
+ export declare function planPhaseBrief(round: number, note?: string | null): string;
10
+ export declare function planGoBrief(steps: readonly string[], by: string | null): string;
11
+ export declare function changedWhilePlanning(worktree: string): Promise<number | null>;
@@ -0,0 +1,46 @@
1
+ import { exec } from '../exec.js';
2
+ export function phaseOf(job) {
3
+ if (job.planFirst !== true)
4
+ return 'work';
5
+ if (job.planApproved === true)
6
+ return 'work';
7
+ if (job.parkStep?.kind === 'plan_go')
8
+ return 'work';
9
+ return 'plan';
10
+ }
11
+ export function planPhaseBrief(round, note) {
12
+ return [
13
+ `## Plan first — you are PLANNING (round ${round})`,
14
+ 'A person approves this plan before any work is done. In this session:',
15
+ '- Read what you need to understand the task. Change NOTHING: no file edits, no commits, no installs that write into the checkout.',
16
+ '- Then call report_plan on the "firefunc" MCP server with the plan\'s steps — short titles in plain words, in order, no code — and an optional one-paragraph summary.',
17
+ '- Then end your session with one line saying the plan is waiting for approval.',
18
+ ...(note
19
+ ? [
20
+ '',
21
+ 'A person looked at your earlier plan and asked for changes. Their note:',
22
+ '',
23
+ note.trim(),
24
+ '',
25
+ 'Plan again with that in mind, and report the new plan.',
26
+ ]
27
+ : []),
28
+ ].join('\n');
29
+ }
30
+ export function planGoBrief(steps, by) {
31
+ return [
32
+ `${by ?? 'A person'} approved your plan. Now do the work, in this same checkout, following it:`,
33
+ ...steps.map((s, i) => `${i + 1}. ${s}`),
34
+ '',
35
+ 'Do not call report_plan again. When you finish, end as the task asks.',
36
+ ].join('\n');
37
+ }
38
+ export async function changedWhilePlanning(worktree) {
39
+ const r = await exec('git', ['-C', worktree, 'status', '--porcelain'], {
40
+ timeoutMs: 60_000,
41
+ }).catch(() => null);
42
+ if (!r || r.code !== 0)
43
+ return null;
44
+ return r.stdout.split('\n').filter((l) => l.trim()).length;
45
+ }
46
+ //# sourceMappingURL=index.js.map
package/dist/pool.js CHANGED
@@ -59,8 +59,10 @@ export async function runJobPool(deps) {
59
59
  continue;
60
60
  }
61
61
  if (active.size >= cap()) {
62
- if (deps.heartbeat)
63
- await Promise.race([...active, sleep(heartbeatMs)]);
62
+ if (deps.heartbeat) {
63
+ await beat({ draining: false, paused: false });
64
+ await napUntilBeat();
65
+ }
64
66
  else
65
67
  await Promise.race(active);
66
68
  continue;
@@ -9,3 +9,8 @@ export declare function pullRequestTitle(job: {
9
9
  export declare function pullRequestBody(kind: ChangeKind, engineName: string, externalId: string | null, opts?: {
10
10
  continuesBranch?: boolean;
11
11
  }): string;
12
+ export declare const AGENT_PR_FILE = ".firefunc/pull-request.md";
13
+ export declare function parseAgentPullRequest(text: string): {
14
+ title: string;
15
+ body: string;
16
+ } | null;
package/dist/pr-title.js CHANGED
@@ -60,4 +60,22 @@ export function pullRequestBody(kind, engineName, externalId, opts = {}) {
60
60
  : `Automated fix by FireFunc (self-hosted ${engineName} runner) for ${externalId ?? 'a reported bug'}.`;
61
61
  return `${what}\n\nReview before merging.`;
62
62
  }
63
+ export const AGENT_PR_FILE = '.firefunc/pull-request.md';
64
+ export function parseAgentPullRequest(text) {
65
+ const lines = text.replace(/\r\n?/g, '\n').split('\n');
66
+ const i = lines.findIndex((l) => l.trim() !== '');
67
+ if (i < 0)
68
+ return null;
69
+ const title = lines[i].replace(/^#+\s*/, '')
70
+ .trim()
71
+ .slice(0, 256);
72
+ if (!title)
73
+ return null;
74
+ const body = lines
75
+ .slice(i + 1)
76
+ .join('\n')
77
+ .trim()
78
+ .slice(0, 60_000);
79
+ return { title, body };
80
+ }
63
81
  //# sourceMappingURL=pr-title.js.map
@@ -0,0 +1,27 @@
1
+ import type { WrittenSkills } from './skills.js';
2
+ export declare const REFERENCE_FOLDER = ".firefunc/reference";
3
+ export type ReferenceToWrite = {
4
+ name: string;
5
+ size: number;
6
+ sha256: string;
7
+ url: string;
8
+ };
9
+ export type WrittenReferences = WrittenSkills & {
10
+ names: string[];
11
+ skipped: Array<{
12
+ name: string;
13
+ why: string;
14
+ }>;
15
+ };
16
+ export declare function safeReferenceName(name: string): boolean;
17
+ export declare function downloadReference(f: ReferenceToWrite, fetcher?: typeof fetch): Promise<{
18
+ bytes: Buffer;
19
+ } | {
20
+ why: string;
21
+ }>;
22
+ export declare function writeReferenceFiles(worktree: string, files: readonly ReferenceToWrite[] | null | undefined, log: (m: string) => void, download?: (f: ReferenceToWrite) => Promise<{
23
+ bytes: Buffer;
24
+ } | {
25
+ why: string;
26
+ }>): Promise<WrittenReferences>;
27
+ export declare function mergeWritten(a: WrittenSkills, b: WrittenSkills): WrittenSkills;
@@ -0,0 +1,202 @@
1
+ import { execFileSync } from 'node:child_process';
2
+ import { createHash } from 'node:crypto';
3
+ import { existsSync, lstatSync, mkdirSync, realpathSync, statSync, writeFileSync } from 'node:fs';
4
+ import { isAbsolute, join, relative, sep } from 'node:path';
5
+ export const REFERENCE_FOLDER = '.firefunc/reference';
6
+ const MAX_BYTES = 20 * 1024 * 1024;
7
+ const GITIGNORE = '# FireFunc: reference files for one run, never committed\n*\n';
8
+ const NONE = (skipped = []) => ({
9
+ written: [],
10
+ pathspecs: [],
11
+ names: [],
12
+ skipped,
13
+ });
14
+ function git(cwd, args) {
15
+ try {
16
+ return execFileSync('git', ['-C', cwd, ...args], {
17
+ encoding: 'utf8',
18
+ stdio: ['ignore', 'pipe', 'ignore'],
19
+ }).trim();
20
+ }
21
+ catch {
22
+ return null;
23
+ }
24
+ }
25
+ function insideTop(top, real) {
26
+ const rel = relative(top, real);
27
+ if (!rel || rel === '..' || rel.startsWith(`..${sep}`) || isAbsolute(rel))
28
+ return null;
29
+ return rel.split(sep).join('/');
30
+ }
31
+ function lstatExists(p) {
32
+ try {
33
+ lstatSync(p);
34
+ return true;
35
+ }
36
+ catch {
37
+ return false;
38
+ }
39
+ }
40
+ export function safeReferenceName(name) {
41
+ return (typeof name === 'string' &&
42
+ name.length > 0 &&
43
+ name.length <= 120 &&
44
+ name.trim() === name &&
45
+ name !== '.' &&
46
+ name !== '..' &&
47
+ !/[\u0000-\u001f\u007f/\\]/.test(name));
48
+ }
49
+ export async function downloadReference(f, fetcher = fetch) {
50
+ if (f.size > MAX_BYTES)
51
+ return { why: `it is larger than ${MAX_BYTES} bytes` };
52
+ const ctrl = new AbortController();
53
+ const timer = setTimeout(() => ctrl.abort(), 120_000);
54
+ try {
55
+ const res = await fetcher(f.url, { signal: ctrl.signal });
56
+ if (!res.ok)
57
+ return { why: `the download answered ${res.status}` };
58
+ const bytes = Buffer.from(await res.arrayBuffer());
59
+ if (bytes.byteLength !== f.size) {
60
+ return { why: `${bytes.byteLength} bytes arrived where ${f.size} were recorded` };
61
+ }
62
+ const sha = createHash('sha256').update(bytes).digest('hex');
63
+ if (sha !== f.sha256.toLowerCase()) {
64
+ return { why: 'the bytes that arrived are not the file that was uploaded (SHA-256 differs)' };
65
+ }
66
+ return { bytes };
67
+ }
68
+ catch (e) {
69
+ return { why: `the download failed (${e.name})` };
70
+ }
71
+ finally {
72
+ clearTimeout(timer);
73
+ }
74
+ }
75
+ export async function writeReferenceFiles(worktree, files, log, download = (f) => downloadReference(f)) {
76
+ const wanted = [];
77
+ const skipped = [];
78
+ const seen = new Set();
79
+ for (const f of files ?? []) {
80
+ if (!f || !safeReferenceName(f.name)) {
81
+ skipped.push({ name: String(f?.name ?? ''), why: 'its name is not one file name' });
82
+ continue;
83
+ }
84
+ if (seen.has(f.name.toLowerCase()))
85
+ continue;
86
+ seen.add(f.name.toLowerCase());
87
+ wanted.push(f);
88
+ }
89
+ if (wanted.length === 0)
90
+ return NONE(skipped);
91
+ let top;
92
+ try {
93
+ top = realpathSync(worktree);
94
+ }
95
+ catch (e) {
96
+ log(`could not write reference files: ${e.message}`);
97
+ return NONE([...skipped, ...wanted.map((f) => ({ name: f.name, why: 'no worktree' }))]);
98
+ }
99
+ const allSkipped = (why) => NONE([...skipped, ...wanted.map((f) => ({ name: f.name, why }))]);
100
+ const outer = join(top, '.firefunc');
101
+ if (!lstatExists(outer)) {
102
+ try {
103
+ mkdirSync(outer);
104
+ }
105
+ catch (e) {
106
+ log(`could not write reference files: ${e.message}`);
107
+ return allSkipped('the folder could not be made');
108
+ }
109
+ }
110
+ else if (!existsSync(outer)) {
111
+ log('reference files not written: .firefunc is a link to a place that does not exist in this checkout. ' +
112
+ 'Fix: point it at a folder inside the repository, or remove the link.');
113
+ return allSkipped('.firefunc is a dangling link');
114
+ }
115
+ let outerReal;
116
+ try {
117
+ outerReal = realpathSync(outer);
118
+ }
119
+ catch (e) {
120
+ log(`could not write reference files: ${e.message}`);
121
+ return allSkipped('the folder could not be read');
122
+ }
123
+ if (insideTop(top, outerReal) === null || !statSync(outerReal).isDirectory()) {
124
+ log(`reference files not written: .firefunc leads to ${outerReal}, which is not a folder inside this checkout; ` +
125
+ 'FireFunc writes only inside the worktree. Fix: make .firefunc a folder inside the repository.');
126
+ return allSkipped('.firefunc is not a folder inside the checkout');
127
+ }
128
+ const dir = join(outerReal, 'reference');
129
+ const rel = insideTop(top, dir);
130
+ if (lstatExists(dir)) {
131
+ log(`reference files not written: ${rel} is already in the checkout, and FireFunc never writes into ` +
132
+ `the repository's own files. Fix: rename or remove ${rel} in the repository.`);
133
+ return allSkipped(`${rel} is the repository's own`);
134
+ }
135
+ const gitTop = git(top, ['rev-parse', '--show-toplevel']);
136
+ let isRepo = false;
137
+ if (gitTop) {
138
+ try {
139
+ isRepo = realpathSync(gitTop) === top;
140
+ }
141
+ catch {
142
+ isRepo = false;
143
+ }
144
+ }
145
+ const ignoreCase = isRepo && git(top, ['config', '--bool', 'core.ignorecase']) === 'true';
146
+ if (isRepo) {
147
+ const tracked = git(top, [
148
+ 'ls-files',
149
+ '-z',
150
+ '--',
151
+ `:(literal${ignoreCase ? ',icase' : ''})${rel}`,
152
+ ]);
153
+ if (tracked) {
154
+ log(`reference files not written: the repository tracks files under ${rel}, and FireFunc never ` +
155
+ `overwrites a repository's files. Fix: move them out of ${rel}.`);
156
+ return allSkipped(`${rel} is tracked by the repository`);
157
+ }
158
+ }
159
+ try {
160
+ mkdirSync(dir);
161
+ writeFileSync(join(dir, '.gitignore'), GITIGNORE);
162
+ }
163
+ catch (e) {
164
+ log(`could not write reference files: ${e.message}`);
165
+ return allSkipped('the folder could not be made');
166
+ }
167
+ const names = [];
168
+ for (const f of wanted) {
169
+ const got = await download(f);
170
+ if ('why' in got) {
171
+ skipped.push({ name: f.name, why: got.why });
172
+ log(`reference file ${f.name} not written: ${got.why}. Fix: add it again on the agent page.`);
173
+ continue;
174
+ }
175
+ try {
176
+ writeFileSync(join(dir, f.name), got.bytes, { mode: 0o600 });
177
+ names.push(f.name);
178
+ }
179
+ catch (e) {
180
+ skipped.push({ name: f.name, why: 'it could not be written' });
181
+ log(`could not write reference file ${f.name}: ${e.message}`);
182
+ }
183
+ }
184
+ if (names.length)
185
+ log(`wrote ${names.length} reference file(s) into ${rel}: ${names.join(', ')}`);
186
+ return {
187
+ written: [rel],
188
+ pathspecs: [`:(exclude,literal${ignoreCase ? ',icase' : ''})${rel}`],
189
+ ...(ignoreCase ? { ignoreCase } : {}),
190
+ names,
191
+ skipped,
192
+ };
193
+ }
194
+ export function mergeWritten(a, b) {
195
+ const ignoreCase = !!(a.ignoreCase || b.ignoreCase);
196
+ return {
197
+ written: [...a.written, ...b.written],
198
+ pathspecs: [...a.pathspecs, ...b.pathspecs],
199
+ ...(ignoreCase ? { ignoreCase } : {}),
200
+ };
201
+ }
202
+ //# sourceMappingURL=reference-files.js.map
@@ -0,0 +1,79 @@
1
+ import type { WrittenSkills } from './skills.js';
2
+ export declare const ATTACH_FOLDER = ".firefunc/attach";
3
+ export declare const MAX_ATTACHMENTS = 12;
4
+ export declare const MAX_ATTACHMENT_BYTES: number;
5
+ export declare const MAX_ATTACHMENTS_TOTAL_BYTES: number;
6
+ export declare const ATTACHMENT_TYPES: Readonly<Record<string, string>>;
7
+ export declare const ATTACH_RULE = "- To show the founder what you built, save screenshots (png/jpg/webp) or one short screen recording (mp4) in `.firefunc/attach/`; FireFunc attaches them to the ticket. Never capture a screen that shows a key, a token or a password.";
8
+ export type AttachLimits = {
9
+ maxFiles: number;
10
+ maxFileBytes: number;
11
+ maxTotalBytes: number;
12
+ };
13
+ export declare function attachLimitsOf(offer: {
14
+ maxFiles?: number;
15
+ maxFileBytes?: number;
16
+ maxTotalBytes?: number;
17
+ }): AttachLimits;
18
+ export type PreparedAttach = WrittenSkills & {
19
+ dir: string | null;
20
+ };
21
+ export declare function prepareAttachFolder(worktree: string, log: (m: string) => void): PreparedAttach;
22
+ export type AttachCandidate = {
23
+ name: string;
24
+ path: string;
25
+ size: number;
26
+ contentType: string;
27
+ };
28
+ export declare function scanAttachFolder(dir: string, limits?: AttachLimits): {
29
+ files: AttachCandidate[];
30
+ skipped: Array<{
31
+ name: string;
32
+ why: string;
33
+ }>;
34
+ };
35
+ export type AttachApi = {
36
+ offerAttachment(runId: string, file: {
37
+ name: string;
38
+ size: number;
39
+ sha256: string;
40
+ contentType: string;
41
+ }): Promise<{
42
+ id: string;
43
+ upload: {
44
+ url: string;
45
+ headers: Record<string, string>;
46
+ };
47
+ } | {
48
+ refused: {
49
+ reason: string;
50
+ fix: string;
51
+ status: number;
52
+ };
53
+ }>;
54
+ completeAttachment(runId: string, attachmentId: string): Promise<{
55
+ ok: true;
56
+ } | {
57
+ refused: {
58
+ reason: string;
59
+ fix: string;
60
+ status: number;
61
+ };
62
+ }>;
63
+ probe(): Promise<boolean>;
64
+ };
65
+ export declare function uploadRunAttachments(opts: {
66
+ runId: string;
67
+ dir: string;
68
+ api: AttachApi;
69
+ log: (m: string) => void;
70
+ limits?: AttachLimits;
71
+ maxWaitMs?: number;
72
+ fetcher?: typeof fetch;
73
+ }): Promise<{
74
+ attached: string[];
75
+ skipped: Array<{
76
+ name: string;
77
+ why: string;
78
+ }>;
79
+ }>;