@firefunc-agent/runner 0.9.34 → 0.9.36

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.
@@ -3,6 +3,8 @@ export const CODE_NOTE = 'code kept on the machine';
3
3
  export function codeNote(ref) {
4
4
  return ref ? `[${CODE_NOTE} — see ${ref}]` : `[${CODE_NOTE}]`;
5
5
  }
6
+ export const FORMATTED_NOTE = "[formatted text kept on the machine: read it in the run's session log there]";
7
+ const FORMATTED_LANG = /^(?:html?|xml|markdown|md|text|txt|plain)$/i;
6
8
  const EXTENSIONS = 'tsx?|jsx?|mjs|cjs|py|rb|go|rs|java|kts?|swift|c|h|cc|cpp|hpp|cs|php|sql|json|ya?ml|toml|md|css|scss|less|html?|vue|svelte|sh|bash|zsh|tf|hcl|graphql|gql|prisma|ex|exs|scala|dart|lua|pl|proto|xml|gradle|ini|env|lock|conf|cfg';
7
9
  const PATH_REF = new RegExp(`((?:[\\w@.-]+/)*[\\w@-][\\w@.-]*\\.(?:${EXTENSIONS}))(?![\\w])(?:(?::|#L)(\\d+))?`, 'i');
8
10
  const CODE_REF = /^(\d+):\d+:(\S+)$/;
@@ -122,7 +124,10 @@ export function stripCode(text) {
122
124
  let j = i + 1;
123
125
  while (j < lines.length && !close.test(lines[j]))
124
126
  j++;
125
- before = `${indent}${codeNote(blockRef(open[3], lines.slice(i + 1, j), before))}`;
127
+ const lang = (open[3] ?? '').trim().split(/\s+/)[0] ?? '';
128
+ before = FORMATTED_LANG.test(lang)
129
+ ? `${indent}${FORMATTED_NOTE}`
130
+ : `${indent}${codeNote(blockRef(open[3], lines.slice(i + 1, j), before))}`;
126
131
  fenced.push(before);
127
132
  i = j;
128
133
  }
@@ -17,6 +17,7 @@ export type McpLoginRecord = {
17
17
  };
18
18
  export declare function mcpLoginDir(): string;
19
19
  export declare function mcpLoginPath(server: string): string;
20
+ export declare function atlassianDomainHelp(serverUrl: string, redirectUri: string): string[] | null;
20
21
  export declare function runMcpLogin(tool: string, opts?: {
21
22
  noBrowser?: boolean;
22
23
  }): Promise<void>;
package/dist/mcp-login.js CHANGED
@@ -371,7 +371,7 @@ function browserOpener() {
371
371
  if (process.platform === 'darwin')
372
372
  return { cmd: 'open', args: [] };
373
373
  if (process.platform === 'win32')
374
- return { cmd: 'cmd', args: ['/c', 'start', ''] };
374
+ return { cmd: 'rundll32', args: ['url.dll,FileProtocolHandler'] };
375
375
  if (!process.env.DISPLAY && !process.env.WAYLAND_DISPLAY)
376
376
  return null;
377
377
  return { cmd: 'xdg-open', args: [] };
@@ -488,6 +488,27 @@ async function registerClient(meta, redirectUri, grantTypes) {
488
488
  }
489
489
  return { clientId, clientSecret: str(doc, 'client_secret') ?? undefined };
490
490
  }
491
+ export function atlassianDomainHelp(serverUrl, redirectUri) {
492
+ let host = '';
493
+ let back = null;
494
+ try {
495
+ host = new URL(serverUrl).hostname.toLowerCase();
496
+ back = new URL(redirectUri);
497
+ }
498
+ catch {
499
+ return null;
500
+ }
501
+ if (host !== 'mcp.atlassian.com')
502
+ return null;
503
+ const domain = `${back.protocol}//${back.hostname}/**`;
504
+ return [
505
+ 'Atlassian lets only approved apps sign in. If Atlassian says the domain is restricted, an admin',
506
+ 'of your Atlassian organization adds this domain at admin.atlassian.com › Apps › AI and Rovo ›',
507
+ 'Atlassian MCP server › Domains › Add domain:',
508
+ ` ${domain}`,
509
+ `(this sign-in returns to ${redirectUri} on this machine). Then run this command again.`,
510
+ ];
511
+ }
491
512
  function waitForCode(server, state, acceptPaste, timeoutMs) {
492
513
  return new Promise((resolve) => {
493
514
  let settled = false;
@@ -508,16 +529,24 @@ function waitForCode(server, state, acceptPaste, timeoutMs) {
508
529
  const url = new URL(req.url ?? '/', 'http://127.0.0.1');
509
530
  const returned = url.searchParams;
510
531
  const vendorError = returned.get('error');
532
+ const vendorWords = (returned.get('error_description') ?? '')
533
+ .replace(/[\u0000-\u001f\u007f]+/g, ' ')
534
+ .replace(/\s+/g, ' ')
535
+ .trim()
536
+ .slice(0, 300);
511
537
  const code = returned.get('code');
512
538
  const body = vendorError
513
- ? `Sign-in was refused: ${vendorError}. You can close this tab.`
539
+ ? `Sign-in was refused: ${vendorError}${vendorWords ? ` (${vendorWords})` : ''}. You can close this tab.`
514
540
  : code
515
541
  ? 'Signed in. You can close this tab and return to the terminal.'
516
542
  : 'Waiting for the sign-in redirect.';
517
543
  res.writeHead(vendorError ? 400 : 200, { 'content-type': 'text/plain; charset=utf-8' });
518
544
  res.end(`FireFunc runner — ${body}\n`);
519
- if (vendorError)
520
- return finish({ failed: `the vendor refused the sign-in (${vendorError})` });
545
+ if (vendorError) {
546
+ return finish({
547
+ failed: `the vendor refused the sign-in (${vendorError}${vendorWords ? `: ${vendorWords}` : ''})`,
548
+ });
549
+ }
521
550
  if (!code)
522
551
  return;
523
552
  if (returned.get('state') !== state) {
@@ -775,6 +804,12 @@ export async function runMcpLogin(tool, opts = {}) {
775
804
  authorizeUrl.searchParams.set('scope', meta.scope);
776
805
  if (meta.resource)
777
806
  authorizeUrl.searchParams.set('resource', meta.resource);
807
+ const domainHelp = atlassianDomainHelp(server.url, loopback.redirectUri);
808
+ if (domainHelp) {
809
+ out('');
810
+ for (const line of domainHelp)
811
+ out(line);
812
+ }
778
813
  const opened = opener ? openBrowser(authorizeUrl.href, opener) : false;
779
814
  out('');
780
815
  if (opened) {
@@ -802,7 +837,9 @@ export async function runMcpLogin(tool, opts = {}) {
802
837
  out(`Waiting up to ${Math.round(CALLBACK_TIMEOUT_MS / 60_000)} minutes…`);
803
838
  const code = await waitForCode(loopback.server, state, canPaste && !opened, CALLBACK_TIMEOUT_MS);
804
839
  if ('failed' in code) {
805
- err(`\nSign-in did not complete: ${code.failed}.\n\nFix: run the command again.`);
840
+ err(domainHelp
841
+ ? `\nSign-in did not complete: ${code.failed}.\n\n${domainHelp.join('\n')}`
842
+ : `\nSign-in did not complete: ${code.failed}.\n\nFix: run the command again.`);
806
843
  process.exitCode = 1;
807
844
  return;
808
845
  }
package/dist/mcp.d.ts CHANGED
@@ -20,7 +20,7 @@ export type McpRunConfig = {
20
20
  servers: McpServerSpec[];
21
21
  callBudget: number | null;
22
22
  };
23
- export type McpFormat = 'claude' | 'cursor' | 'gemini' | 'codex' | 'copilot' | 'opencode';
23
+ export type McpFormat = 'claude' | 'cursor' | 'gemini' | 'codex' | 'copilot' | 'opencode' | 'antigravity';
24
24
  export type McpCredentialClient = {
25
25
  mcpCredential(runId: string, server: string): Promise<{
26
26
  token: string;
@@ -48,7 +48,10 @@ export type PrepareMcpOptions = {
48
48
  api: McpCredentialClient;
49
49
  log?: (msg: string) => void;
50
50
  relay?: boolean;
51
+ onDrop?: (id: string, code: McpDropCode) => void;
51
52
  };
53
+ export type McpDropCode = 'engine_has_no_mcp' | 'rejected' | 'unusable_on_engine' | 'config_path_taken' | 'git_exclude_failed' | 'no_credential' | 'not_signed_in' | 'write_failed';
54
+ export declare function mcpServerIdsOf(raw: unknown): string[];
52
55
  export declare function mcpFormatForEngine(engine: string | null | undefined): McpFormat | null;
53
56
  declare function parseServer(raw: unknown): {
54
57
  spec: McpServerSpec;
package/dist/mcp.js CHANGED
@@ -4,6 +4,17 @@ import { configPath } from './config.js';
4
4
  import { CATALOG_ONLY, claudeCodeSignInFix, claudeCodeSignsFor } from './machine-logins.js';
5
5
  import { execOut } from './exec.js';
6
6
  import { startCredentialRelay } from './mcp-proxy.js';
7
+ export function mcpServerIdsOf(raw) {
8
+ if (!isRecord(raw) || !Array.isArray(raw.servers))
9
+ return [];
10
+ const ids = [];
11
+ for (const s of raw.servers) {
12
+ const id = isRecord(s) ? s.id : null;
13
+ if (typeof id === 'string' && SERVER_ID_PATTERN.test(id) && !ids.includes(id))
14
+ ids.push(id);
15
+ }
16
+ return ids.slice(0, 20);
17
+ }
7
18
  const RELAYED_SERVERS = new Set(['github']);
8
19
  const SERVER_ID_PATTERN = /^[a-z][a-z0-9_-]*$/;
9
20
  const HEADER_NAME_PATTERN = /^[A-Za-z0-9!#$%&'*+.^_`|~-]+$/;
@@ -16,6 +27,7 @@ const CONFIG_PATHS = {
16
27
  codex: null,
17
28
  copilot: '.firefunc-copilot-mcp.json',
18
29
  opencode: '.firefunc-opencode.json',
30
+ antigravity: '.agents/plugins/firefunc-run/mcp_config.json',
19
31
  };
20
32
  export function mcpFormatForEngine(engine) {
21
33
  switch (engine) {
@@ -31,6 +43,8 @@ export function mcpFormatForEngine(engine) {
31
43
  return 'copilot';
32
44
  case 'opencode':
33
45
  return 'opencode';
46
+ case 'antigravity':
47
+ return 'antigravity';
34
48
  default:
35
49
  return null;
36
50
  }
@@ -196,7 +210,7 @@ function parseServer(raw) {
196
210
  }
197
211
  return { spec };
198
212
  }
199
- function parseRunConfig(raw, log) {
213
+ function parseRunConfig(raw, log, onReject) {
200
214
  if (!isRecord(raw))
201
215
  return null;
202
216
  if (!Array.isArray(raw.servers))
@@ -206,6 +220,9 @@ function parseRunConfig(raw, log) {
206
220
  const parsed = parseServer(entry);
207
221
  if ('reject' in parsed) {
208
222
  log(`mcp: ignoring a server FireFunc sent — ${parsed.reject}.`);
223
+ const id = isRecord(entry) ? entry.id : null;
224
+ if (typeof id === 'string' && SERVER_ID_PATTERN.test(id))
225
+ onReject?.(id);
209
226
  continue;
210
227
  }
211
228
  servers.push(parsed.spec);
@@ -288,7 +305,7 @@ async function excludeFromGit(worktree, patterns, log) {
288
305
  mkdirSync(info, { recursive: true });
289
306
  const file = join(info, 'exclude');
290
307
  const existing = existsSync(file) ? readFileSync(file, 'utf8') : '';
291
- const lines = existing.split('\n');
308
+ const lines = existing.split(/\r?\n/);
292
309
  const missing = patterns.filter((p) => !lines.includes(p));
293
310
  if (missing.length) {
294
311
  const header = existing.includes(EXCLUDE_HEADER) ? '' : `\n${EXCLUDE_HEADER}\n`;
@@ -360,6 +377,17 @@ function opencodeBody(resolved) {
360
377
  }
361
378
  return `${JSON.stringify({ $schema: 'https://opencode.ai/config.json', mcp: servers }, null, 2)}\n`;
362
379
  }
380
+ function antigravityBody(resolved) {
381
+ const servers = {};
382
+ for (const { spec, cred } of resolved) {
383
+ const headers = { ...spec.headers, ...credentialHeaders(cred) };
384
+ servers[spec.id] =
385
+ spec.transport === 'stdio'
386
+ ? { command: spec.command, ...(spec.args ? { args: spec.args } : {}) }
387
+ : { serverUrl: spec.url, headers };
388
+ }
389
+ return `${JSON.stringify({ mcpServers: servers }, null, 2)}\n`;
390
+ }
363
391
  function geminiBody(resolved) {
364
392
  const servers = {};
365
393
  for (const { spec, cred } of resolved) {
@@ -418,7 +446,14 @@ function codexOverrides(resolved) {
418
446
  const NO_LOG = () => { };
419
447
  export async function prepareMcp(opts) {
420
448
  const log = opts.log ?? NO_LOG;
421
- const config = parseRunConfig(opts.raw, log);
449
+ const drop = (id, code) => {
450
+ try {
451
+ opts.onDrop?.(id, code);
452
+ }
453
+ catch {
454
+ }
455
+ };
456
+ const config = parseRunConfig(opts.raw, log, (id) => drop(id, 'rejected'));
422
457
  if (!config || config.servers.length === 0)
423
458
  return null;
424
459
  const usable = [];
@@ -426,6 +461,7 @@ export async function prepareMcp(opts) {
426
461
  const reason = whyUnusable(spec, opts.format);
427
462
  if (reason) {
428
463
  log(`mcp: skipping ${spec.id} on ${opts.format} — ${reason}.`);
464
+ drop(spec.id, 'unusable_on_engine');
429
465
  continue;
430
466
  }
431
467
  usable.push(spec);
@@ -439,12 +475,16 @@ export async function prepareMcp(opts) {
439
475
  if (existsSync(target)) {
440
476
  log(`mcp: ${relative} already exists in this repo, so MCP is off for this run — FireFunc will not overwrite a file the repo owns, and an exclude cannot protect a tracked one. ` +
441
477
  `Fix: remove ${relative} from the repository, or run this project on an engine that reads a different path.`);
478
+ for (const s of usable)
479
+ drop(s.id, 'config_path_taken');
442
480
  return null;
443
481
  }
444
- const excluded = await excludeFromGit(opts.worktree, [`/${relative}`], log);
482
+ const excluded = await excludeFromGit(opts.worktree, opts.format === 'antigravity' ? [`/${dirname(relative)}/`] : [`/${relative}`], log);
445
483
  if (!excluded) {
446
484
  log('mcp: MCP is off for this run because the config could not be kept out of the commit. ' +
447
485
  'Fix: check that the runner can write .git/info/exclude in the repository checkout.');
486
+ for (const s of usable)
487
+ drop(s.id, 'git_exclude_failed');
448
488
  return null;
449
489
  }
450
490
  }
@@ -464,6 +504,7 @@ export async function prepareMcp(opts) {
464
504
  if (spec.auth === 'header') {
465
505
  if (!spec.headerName) {
466
506
  log(`mcp: skipping ${spec.id} — its credential did not survive validation.`);
507
+ drop(spec.id, 'no_credential');
467
508
  continue;
468
509
  }
469
510
  let value = spec.secret;
@@ -475,6 +516,7 @@ export async function prepareMcp(opts) {
475
516
  log(`mcp: skipping ${spec.id} — FireFunc issued no credential for it. ` +
476
517
  'Fix: check the server is still granted to this workspace and its secret is set, in Settings → Connections. ' +
477
518
  'The run continues without it, on the context pack it already has.');
519
+ drop(spec.id, 'no_credential');
478
520
  continue;
479
521
  }
480
522
  resolved.push({
@@ -512,6 +554,7 @@ export async function prepareMcp(opts) {
512
554
  `person's allowance. `
513
555
  : '') +
514
556
  'The run continues without it, on the context pack it already has.');
557
+ drop(spec.id, 'not_signed_in');
515
558
  continue;
516
559
  }
517
560
  resolved.push({
@@ -524,6 +567,7 @@ export async function prepareMcp(opts) {
524
567
  if (!minted?.token) {
525
568
  log(`mcp: skipping ${spec.id} — FireFunc issued no read-only credential for it. ` +
526
569
  'Fix: the API log names the reason; a 403 usually means GitHub is not connected to this workspace, and a 503 that the GitHub App is not configured. The context pack still carries the repository context.');
570
+ drop(spec.id, 'no_credential');
527
571
  continue;
528
572
  }
529
573
  if (opts.relay && RELAYED_SERVERS.has(spec.id) && spec.transport !== 'stdio' && spec.url) {
@@ -560,11 +604,19 @@ export async function prepareMcp(opts) {
560
604
  ? cursorBody(resolved)
561
605
  : opts.format === 'opencode'
562
606
  ? opencodeBody(resolved)
563
- : geminiBody(resolved);
607
+ : opts.format === 'antigravity'
608
+ ? antigravityBody(resolved)
609
+ : geminiBody(resolved);
564
610
  writeFileSync(target, body, { mode: 0o600 });
611
+ if (opts.format === 'antigravity')
612
+ writeFileSync(join(dirname(target), 'plugin.json'), '{ "name": "firefunc-run" }\n', {
613
+ mode: 0o600,
614
+ });
565
615
  }
566
616
  catch (e) {
567
617
  log(`mcp: could not write ${relative} (${e.message}) — MCP is off for this run.`);
618
+ for (const r of resolved)
619
+ drop(r.spec.id, 'write_failed');
568
620
  closeRelays();
569
621
  return null;
570
622
  }
@@ -584,7 +636,10 @@ export async function prepareMcp(opts) {
584
636
  if (!writtenPath)
585
637
  return;
586
638
  try {
587
- rmSync(writtenPath, { force: true });
639
+ if (opts.format === 'antigravity')
640
+ rmSync(dirname(writtenPath), { recursive: true, force: true });
641
+ else
642
+ rmSync(writtenPath, { force: true });
588
643
  }
589
644
  catch {
590
645
  }
@@ -0,0 +1,15 @@
1
+ import type { RunnerConfig } from './config.js';
2
+ export declare const OPENROUTER_BASE_URL = "https://openrouter.ai/api";
3
+ export declare const OPENROUTER_KEY_VAR = "OPENROUTER_API_KEY";
4
+ export declare function openRouterKeyOf(cfg: Pick<RunnerConfig, 'claudeEnv'>, env?: NodeJS.ProcessEnv): string | null;
5
+ export declare function openRouterClaudeEnv(runEnv: NodeJS.ProcessEnv, key: string): NodeJS.ProcessEnv;
6
+ export type JobEndpoint = {
7
+ ok: true;
8
+ cfg: RunnerConfig;
9
+ note: string | null;
10
+ } | {
11
+ ok: false;
12
+ reason: string;
13
+ fix: string;
14
+ };
15
+ export declare function jobClaudeEndpoint(engine: string, want: unknown, cfg: RunnerConfig, machine: string, env?: NodeJS.ProcessEnv): JobEndpoint;
@@ -0,0 +1,39 @@
1
+ export const OPENROUTER_BASE_URL = 'https://openrouter.ai/api';
2
+ export const OPENROUTER_KEY_VAR = 'OPENROUTER_API_KEY';
3
+ export function openRouterKeyOf(cfg, env = process.env) {
4
+ const v = (cfg.claudeEnv?.[OPENROUTER_KEY_VAR] ?? env[OPENROUTER_KEY_VAR] ?? '').trim();
5
+ return v ? v : null;
6
+ }
7
+ export function openRouterClaudeEnv(runEnv, key) {
8
+ return {
9
+ ...runEnv,
10
+ ANTHROPIC_BASE_URL: OPENROUTER_BASE_URL,
11
+ ANTHROPIC_AUTH_TOKEN: key,
12
+ ANTHROPIC_API_KEY: '',
13
+ CLAUDE_CODE_OAUTH_TOKEN: undefined,
14
+ };
15
+ }
16
+ export function jobClaudeEndpoint(engine, want, cfg, machine, env = process.env) {
17
+ if (want !== 'openrouter')
18
+ return { ok: true, cfg, note: null };
19
+ if (engine !== 'claude_code') {
20
+ return {
21
+ ok: false,
22
+ reason: `This job asks for the OpenRouter endpoint, a setting of Claude Code only, and it runs on ${engine}.`,
23
+ fix: 'Set the Claude Code endpoint back to Anthropic for this work in FireFunc, or run it on Claude Code.',
24
+ };
25
+ }
26
+ if (!openRouterKeyOf(cfg, env)) {
27
+ return {
28
+ ok: false,
29
+ reason: `This job's Claude Code sends its requests to OpenRouter, and ${OPENROUTER_KEY_VAR} is not set on ${machine}.`,
30
+ fix: `Set ${OPENROUTER_KEY_VAR} on this machine (in the environment the runner starts in, or in the runner config's claudeEnv), restart the runner, and run the task again — or set the Claude Code endpoint back to Anthropic. FireFunc never stores the key.`,
31
+ };
32
+ }
33
+ return {
34
+ ok: true,
35
+ cfg: { ...cfg, claudeEndpoint: 'openrouter' },
36
+ note: `OpenRouter (${OPENROUTER_KEY_VAR} from this machine)`,
37
+ };
38
+ }
39
+ //# sourceMappingURL=openrouter.js.map
package/dist/pool.d.ts CHANGED
@@ -8,6 +8,8 @@ export type JobPoolDeps<J> = {
8
8
  onStart?: (job: J, inFlight: number) => void;
9
9
  idleDelayMs?: number;
10
10
  maxIdleDelayMs?: number;
11
+ activePollMs?: number;
12
+ activeWindowMs?: number;
11
13
  sleep?: (ms: number) => Promise<void>;
12
14
  paused?: () => boolean;
13
15
  heartbeat?: (state: {
package/dist/pool.js CHANGED
@@ -4,7 +4,16 @@ export async function runJobPool(deps) {
4
4
  const baseIdleMs = deps.idleDelayMs ?? 800;
5
5
  const maxIdleMs = Math.max(baseIdleMs, deps.maxIdleDelayMs ?? 8_000);
6
6
  let emptyClaims = 0;
7
- const idleDelay = () => Math.min(maxIdleMs, baseIdleMs * 2 ** Math.min(emptyClaims, 10));
7
+ const activePollMs = deps.activePollMs ?? 1_000;
8
+ const activeWindowMs = deps.activeWindowMs ?? 120_000;
9
+ const clock = deps.now ?? (() => Date.now());
10
+ let lastActivity = clock();
11
+ const idleDelay = () => {
12
+ const backoff = Math.min(maxIdleMs, baseIdleMs * 2 ** Math.min(emptyClaims, 10));
13
+ return clock() - lastActivity < activeWindowMs
14
+ ? Math.max(Math.min(baseIdleMs, backoff), Math.min(activePollMs, backoff))
15
+ : backoff;
16
+ };
8
17
  const cap = () => {
9
18
  const n = Math.floor(typeof deps.maxParallel === 'function' ? deps.maxParallel() : deps.maxParallel);
10
19
  return Number.isFinite(n) ? Math.max(0, n) : 1;
@@ -16,8 +25,10 @@ export async function runJobPool(deps) {
16
25
  let lastContact = now();
17
26
  const spawn = (job) => {
18
27
  deps.onStart?.(job, active.size + 1);
28
+ lastActivity = now();
19
29
  const p = deps.run(job).finally(() => {
20
30
  active.delete(p);
31
+ lastActivity = now();
21
32
  });
22
33
  active.add(p);
23
34
  };
package/dist/sign-in.d.ts CHANGED
@@ -8,6 +8,7 @@ export type EngineSignIn = {
8
8
  key: KeyState;
9
9
  keySource?: string;
10
10
  uses?: 'plan' | 'key';
11
+ openrouter?: 'found' | 'missing';
11
12
  };
12
13
  export type SignInReport = Partial<Record<EngineId, EngineSignIn>>;
13
14
  export type SignInPref = {
package/dist/sign-in.js CHANGED
@@ -3,6 +3,7 @@ import { homedir } from 'node:os';
3
3
  import { join } from 'node:path';
4
4
  import { apiKeyFile, claudeApiKeyNow } from './api-fallback.js';
5
5
  import { spawnLoginProbe } from './engine-login.js';
6
+ import { openRouterKeyOf } from './openrouter.js';
6
7
  export const ENGINE_KEY_VARS = {
7
8
  claude_code: ['ANTHROPIC_API_KEY'],
8
9
  codex_cli: ['OPENAI_API_KEY', 'CODEX_API_KEY'],
@@ -103,9 +104,12 @@ export function signInReport(engines, cfg, opts = {}) {
103
104
  continue;
104
105
  }
105
106
  const source = keySourceOf(engine, cfg, opts.env, opts.dir);
107
+ const openrouter = engine === 'claude_code'
108
+ ? { openrouter: openRouterKeyOf(cfg, opts.env) ? 'found' : 'missing' }
109
+ : {};
106
110
  out[engine] = source
107
- ? { plan, key: 'found', keySource: source, ...used }
108
- : { plan, key: 'missing', ...used };
111
+ ? { plan, key: 'found', keySource: source, ...used, ...openrouter }
112
+ : { plan, key: 'missing', ...used, ...openrouter };
109
113
  }
110
114
  return out;
111
115
  }
@@ -0,0 +1,14 @@
1
+ export declare function msvcQuote(arg: string): string;
2
+ export declare function windowsShellArg(arg: string, batch?: boolean): string;
3
+ export declare function windowsShellCommandName(cmd: string): string;
4
+ export type WhichDeps = {
5
+ exists: (p: string) => boolean;
6
+ };
7
+ export declare function resolveWindowsCommand(cmd: string, env?: NodeJS.ProcessEnv, deps?: WhichDeps): string | null;
8
+ export declare function isBatchFile(path: string): boolean;
9
+ export declare function windowsShellLine(cmd: string, args: readonly string[], env?: NodeJS.ProcessEnv, deps?: WhichDeps): string;
10
+ export declare function shellSafe(cmd: string, args: readonly string[], shell: boolean | undefined, env?: NodeJS.ProcessEnv, platform?: NodeJS.Platform): {
11
+ cmd: string;
12
+ args: string[];
13
+ shell: boolean;
14
+ };
@@ -0,0 +1,51 @@
1
+ import { existsSync } from 'node:fs';
2
+ import { win32 } from 'node:path';
3
+ const { delimiter, extname, isAbsolute, join, normalize } = win32;
4
+ const META = /([()\][%!^"`<>&|;, *?])/g;
5
+ export function msvcQuote(arg) {
6
+ let out = '"';
7
+ let slashes = 0;
8
+ for (const ch of arg) {
9
+ if (ch === '\\') {
10
+ slashes += 1;
11
+ continue;
12
+ }
13
+ out += ch === '"' ? `${'\\'.repeat(slashes * 2 + 1)}"` : `${'\\'.repeat(slashes)}${ch}`;
14
+ slashes = 0;
15
+ }
16
+ return `${out}${'\\'.repeat(slashes * 2)}"`;
17
+ }
18
+ export function windowsShellArg(arg, batch = false) {
19
+ const once = msvcQuote(arg).replace(META, '^$1');
20
+ return batch ? once.replace(META, '^$1') : once;
21
+ }
22
+ export function windowsShellCommandName(cmd) {
23
+ return normalize(cmd).replace(META, '^$1');
24
+ }
25
+ export function resolveWindowsCommand(cmd, env = process.env, deps = { exists: existsSync }) {
26
+ const exts = (env.PATHEXT ?? '.COM;.EXE;.BAT;.CMD').split(';').filter(Boolean);
27
+ const candidates = (base) => extname(base) && deps.exists(base) ? [base] : exts.map((e) => `${base}${e}`);
28
+ const hasDir = isAbsolute(cmd) || /[\\/]/.test(cmd);
29
+ const dirs = hasDir ? [''] : (env.PATH ?? env.Path ?? '').split(delimiter).filter(Boolean);
30
+ for (const dir of dirs) {
31
+ const base = dir ? join(dir, cmd) : cmd;
32
+ for (const c of candidates(base))
33
+ if (deps.exists(c))
34
+ return c;
35
+ }
36
+ return null;
37
+ }
38
+ export function isBatchFile(path) {
39
+ return /\.(cmd|bat)$/i.test(path);
40
+ }
41
+ export function windowsShellLine(cmd, args, env = process.env, deps) {
42
+ const resolved = resolveWindowsCommand(cmd, env, deps) ?? cmd;
43
+ const batch = isBatchFile(resolved);
44
+ return [windowsShellCommandName(resolved), ...args.map((a) => windowsShellArg(a, batch))].join(' ');
45
+ }
46
+ export function shellSafe(cmd, args, shell, env = process.env, platform = process.platform) {
47
+ if (!shell || platform !== 'win32' || args.length === 0)
48
+ return { cmd, args: [...args], shell: !!shell };
49
+ return { cmd: windowsShellLine(cmd, args, env), args: [], shell: true };
50
+ }
51
+ //# sourceMappingURL=win-shell.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@firefunc-agent/runner",
3
- "version": "0.9.34",
3
+ "version": "0.9.36",
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, Copilot CLI, Antigravity) on work FireFunc routes to it, opens pull requests, and reports back. Your machine, your subscriptions.",
@@ -227,3 +227,21 @@ for an agent that reads and reports, that is the work), `verdict` (`{id, word}`,
227
227
  only for an agent that declares verdicts) and `findings` (one line each, with a
228
228
  severity). Each is null or empty when nothing was recorded; say so rather than
229
229
  guessing. Quote the answer as it came.
230
+
231
+ ## Workflows and orchestrations
232
+
233
+ An automation chains steps (a workflow) or roles (an orchestration). It is made as a DRAFT and
234
+ does nothing until it is published:
235
+
236
+ ```bash
237
+ firefunc automations templates --json # what to start from, and the agents each brings
238
+ firefunc automations create --name "Error to fix" --from-template tpl-incident-fix --project "Payments" --json
239
+ firefunc automations check <id> --json # the checks behind Publish, each with its fix
240
+ firefunc automations run <id> --mode dry --watch --json # a dry run starts nothing and writes nothing
241
+ ```
242
+
243
+ Publishing makes it live at once: a tool trigger takes the next real event. Ask the person first,
244
+ naming what starts it and its project, then `firefunc automations publish <id> --yes --json`. The
245
+ answer says where it went live (`goesLive`) and the agents a run would wait at (`heldAgents`: a
246
+ template's agents arrive paused). Start one by hand with `firefunc automations run <id> --watch`;
247
+ read a run with `firefunc automations run-get <run id>`.