@firefunc-agent/runner 0.9.5 → 0.9.7

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.
@@ -51,12 +51,50 @@ const DIFF_HEAD = /^(?:diff --git |index [0-9a-f]{7,}\.\.[0-9a-f]{7,}|--- (?:a\/
51
51
  const DIFF_BODY = /^(?:[-+ \\]|@@ |diff --git |index |new file mode|deleted file mode|similarity index|rename (?:from|to) |old mode|new mode|Binary files )/;
52
52
  const INLINE_STATEMENT = /[;{}]|=>|(?<![=!<>])=(?![=>])|^\s*(?:return|throw|raise|const|let|var|def|import|from|export|function|class|if|for|while)\s/;
53
53
  const QUERY_PAIR = /[?&][\w.[\]-]+=[^\s&#]*/g;
54
+ const FLAG_PAIR = /(^|\s)--?[A-Za-z][\w.-]*=(?![=>])[^\s=;{}]*/g;
55
+ const INLINE_COMMANDS = new Set('pnpm pnpx npm npx yarn bun bunx deno node tsx tsc vitest jest mocha playwright cypress eslint prettier biome turbo git gh glab make cargo go python python3 pip pip3 pytest uv poetry ruff mypy ruby bundle rake rails rspec php composer phpunit dotnet mvn gradle gradlew docker kubectl helm terraform curl psql createdb dropdb pg_ctl initdb firefunc firefunc-runner'.split(' '));
56
+ const HANDS_OVER = /(?:^|\s)(?:auth|config|credentials?|login|secrets?|token|variable)(?=\s|$)/i;
57
+ const KEY_SHAPE = /\b(?:AKIA|ASIA)[0-9A-Z]{16}\b|\b(?:gh[pousr]_[A-Za-z0-9]{36}|github_pat_\w{22,}|xox[abprs]-[\w-]{10,}|AIza[\w-]{35}|[rs]k_(?:live|test)_[A-Za-z0-9]{16,})|-----BEGIN [A-Z ]{0,40}PRIVATE KEY|\bey[\w-]{10,}\.ey[\w-]{10,}\.[\w-]{10,}/;
58
+ const ABOUT_IT = 'file|filename|path|dir|ttl|url|uri|name|arn|length|len|size|type|mode|version|prefix|header|expiry|expires|lifetime|timeout|enabled|required|policy|format|algorithm|alg|provider|endpoint|issuer|audience|count|limit|location';
59
+ const REFERENCE = String.raw `(?:[$<*%{…-]|\.\.\.)`;
60
+ const VALUE = String.raw `['"]?(?!${REFERENCE})[^\s'"]`;
61
+ const SECRET_ARG = new RegExp([
62
+ String.raw `:\/\/[^\s/@:]*:(?!${REFERENCE})[^\s/@]+@`,
63
+ String.raw `\bbearer\s+(?!${REFERENCE})[\w.~+/=-]{8,}`,
64
+ String.raw `\bcurl\b[^|;&]*\s(?:-u\s*|--user[=\s]\s*)['"]?[a-z_][^\s:'"]*:(?!${REFERENCE})\S`,
65
+ String.raw `(?:^|\s)(?:-H|--header)[=\s]?\s*['"]?[\w-]*(?:token|key|auth\w*|cookie|secret)[\w-]*\s*:\s*(?!(?:(?:bearer|basic|token)\s+)?${REFERENCE})\S`,
66
+ String.raw `(?:^|\s)--?[\w.-]*(?:pass(?:word|wd|phrase)?|token|secret|api[-_]?key|access[-_]?key|private[-_]?key|auth(?:[-_]?token|orization)?|cred(?:entials?|s)?|cookie|otp)(?:=|\s+)${VALUE}`,
67
+ String.raw `[?&](?:(?:access|refresh|id|auth|api|session)[-_]?)?token=(?!${REFERENCE})[^\s&#]`,
68
+ String.raw `[?&](?:x-amz-security-token|(?:client[-_]?)?secret|passw(?:or)?d|api[-_]?key|key|sig|signature|x-(?:amz|goog)-(?:signature|credential))=(?!${REFERENCE})[^\s&#]`,
69
+ String.raw `(?:^|[\s;&|('"])[\w.-]*(?:password|passwd|passphrase|secret|token|api[_-]?key|access[_-]?key|private[_-]?key)(?![a-z])(?![\w.-]*?[_.-](?:${ABOUT_IT})(?![a-z0-9]))[\w.-]*=${VALUE}`,
70
+ String.raw `hooks\.slack\.com\/(?:services|workflows|triggers)\/|discord(?:app)?\.com\/api\/webhooks\/|\.webhook\.office\.com\/|outlook\.office(?:365)?\.com\/webhook|hooks\.zapier\.com\/hooks\/|api\.telegram\.org\/bot`,
71
+ ].join('|'), 'i');
72
+ const SECRET_CLI = new RegExp([
73
+ String.raw `\b(?:mysql|mariadb)[\w-]*\b[^|;&]*?\s-p${VALUE}`,
74
+ String.raw `\bsshpass\b[^|;&]*?\s-p\s*${VALUE}`,
75
+ String.raw `\b(?:docker|podman|buildah|helm|oras)\b[^|;&]*\slogin\b[^|;&]*\s-p\s*${VALUE}`,
76
+ String.raw `\baws\s+configure\s+set\b[^|;&]*?\s(?:[\w.-]+\.)?aws_(?:secret_access_key|session_token|access_key_id)\s+${VALUE}`,
77
+ String.raw `\bgh\s+secret\s+set\b[^|;&]*?\s(?:--body(?:=|\s+)|-b\s*)${VALUE}`,
78
+ String.raw `\bkubectl\b[^|;&]*?\screate\s+secret\b[^|;&]*?\s--from-literal(?:=|\s+)['"]?[^\s'"=]+=${VALUE}`,
79
+ String.raw `\b(?:heroku\s+config:set|fly(?:ctl)?\s+secrets\s+set|doppler\s+secrets\s+set)\b[^|;&]*?\s['"]?[\w.-]+=${VALUE}`,
80
+ String.raw `\b(?:echo|printf)\b[^|]*?\s['"]?(?!${REFERENCE})[^\s'"|][^|]*\|\s*(?:(?:npx|bunx|sudo)\s+)?(?:vercel\s+env\s+add|gh\s+secret\s+set|wrangler\s+secret\s+put|doppler\s+secrets\s+set|fly(?:ctl)?\s+secrets\s+(?:set|import)|(?:docker|podman)\s+(?:login|secret\s+create)|helm\s+registry\s+login|kubectl\s+create\s+secret)\b`,
81
+ ].join('|'));
82
+ const SECRET_ENV = new RegExp(String.raw `(?:^|[\s;&|('"])(?:(?:[A-Z0-9]+_)*(?:KEY|PASS)|(?:[A-Z0-9]+_)+PWD)(?!(?:_[A-Z0-9]+)*?_(?:${ABOUT_IT.toUpperCase()})(?![A-Z0-9]))(?:_[A-Z0-9]+)*=${VALUE}`);
83
+ const settingsReadOut = (inner) => inner.replace(QUERY_PAIR, '').replace(FLAG_PAIR, '$1');
84
+ const inlineCap = (inner) => INLINE_COMMANDS.has(inner.trim().split(/\s/, 1)[0].split('/').pop()) && !HANDS_OVER.test(inner)
85
+ ? 160
86
+ : 60;
87
+ const carriesSecret = (inner) => inner.length <= 1000 &&
88
+ (KEY_SHAPE.test(inner) ||
89
+ SECRET_ARG.test(inner) ||
90
+ SECRET_CLI.test(inner) ||
91
+ SECRET_ENV.test(inner));
54
92
  function inlineSpan(whole, inner) {
55
93
  const named = /^[\w@./-]+(?::\d+)?$/.test(inner.trim());
56
94
  const code = inner.includes('\n') ||
57
- inner.length > 60 ||
58
- (/\s/.test(inner.trim()) && INLINE_STATEMENT.test(inner.replace(QUERY_PAIR, '')));
59
- return code && !named ? codeNote(null) : whole;
95
+ inner.length > inlineCap(inner) ||
96
+ (/\s/.test(inner.trim()) && INLINE_STATEMENT.test(settingsReadOut(inner)));
97
+ return (code && !named) || carriesSecret(inner) ? codeNote(null) : whole;
60
98
  }
61
99
  export function stripCode(text) {
62
100
  if (!text)
@@ -0,0 +1,14 @@
1
+ import type { EngineId, UnattendedBlock, UnattendedContext } from './engines/types.js';
2
+ import type { RunnerConfig } from './config.js';
3
+ export type EngineBlock = UnattendedBlock & {
4
+ engine: EngineId;
5
+ };
6
+ export declare function unattendedContext(cfg: RunnerConfig, permissionMode?: string | null): UnattendedContext;
7
+ export declare function engineBlocks(engines: readonly EngineId[], ctx: UnattendedContext): EngineBlock[];
8
+ export declare function runnableEngines(installed: readonly EngineId[], blocks: readonly EngineBlock[]): EngineId[];
9
+ export declare function noEngineCanRun(runnable: readonly EngineId[], blocks: readonly EngineBlock[]): boolean;
10
+ export declare function blockedEnginesReport(blocks: readonly EngineBlock[]): Array<{
11
+ engine: EngineId;
12
+ code: UnattendedBlock['code'];
13
+ }>;
14
+ export declare function cannotRunUnattendedSentence(engineName: string, block: UnattendedBlock): string;
@@ -0,0 +1,37 @@
1
+ import { getAdapter } from './engines/index.js';
2
+ export function unattendedContext(cfg, permissionMode) {
3
+ return {
4
+ uid: typeof process.getuid === 'function' ? process.getuid() : null,
5
+ platform: process.platform,
6
+ env: { ...process.env, ...(cfg.claudeEnv ?? {}) },
7
+ permissionMode: permissionMode ?? cfg.permissionMode ?? 'bypassPermissions',
8
+ };
9
+ }
10
+ export function engineBlocks(engines, ctx) {
11
+ const out = [];
12
+ for (const engine of engines) {
13
+ let block = null;
14
+ try {
15
+ block = getAdapter(engine).unattendedBlock?.(ctx) ?? null;
16
+ }
17
+ catch {
18
+ block = null;
19
+ }
20
+ if (block)
21
+ out.push({ ...block, engine });
22
+ }
23
+ return out;
24
+ }
25
+ export function runnableEngines(installed, blocks) {
26
+ return installed.filter((e) => !blocks.some((b) => b.engine === e));
27
+ }
28
+ export function noEngineCanRun(runnable, blocks) {
29
+ return runnable.length === 0 && blocks.length > 0;
30
+ }
31
+ export function blockedEnginesReport(blocks) {
32
+ return blocks.map((b) => ({ engine: b.engine, code: b.code }));
33
+ }
34
+ export function cannotRunUnattendedSentence(engineName, block) {
35
+ return `${engineName} cannot run unattended on this machine: ${block.reason} ${block.fix}`;
36
+ }
37
+ //# sourceMappingURL=unattended.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@firefunc-agent/runner",
3
- "version": "0.9.5",
3
+ "version": "0.9.7",
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