@firefunc-agent/runner 0.9.7 → 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.
- package/README.md +2 -0
- package/dist/activity.d.ts +1 -0
- package/dist/activity.js +1 -1
- package/dist/api-fallback.d.ts +9 -0
- package/dist/api-fallback.js +55 -0
- package/dist/api.d.ts +121 -0
- package/dist/api.js +147 -3
- package/dist/ask/index.d.ts +20 -0
- package/dist/ask/index.js +64 -0
- package/dist/ask-first.d.ts +8 -0
- package/dist/brief.d.ts +2 -0
- package/dist/brief.js +6 -0
- package/dist/build-info.json +2 -2
- package/dist/config.d.ts +2 -0
- package/dist/cut.d.ts +2 -1
- package/dist/cut.js +8 -4
- package/dist/daemon.js +14 -2
- package/dist/engines/claude.js +10 -4
- package/dist/git-auth.d.ts +1 -0
- package/dist/git-auth.js +9 -1
- package/dist/job.js +415 -38
- package/dist/keep-local.d.ts +1 -0
- package/dist/keep-local.js +3 -0
- package/dist/limit.d.ts +1 -0
- package/dist/limit.js +4 -1
- package/dist/locks.d.ts +3 -0
- package/dist/locks.js +46 -13
- package/dist/plan-phase/index.d.ts +11 -0
- package/dist/plan-phase/index.js +46 -0
- package/dist/pool.js +4 -2
- package/dist/pr-title.d.ts +5 -0
- package/dist/pr-title.js +18 -0
- package/dist/reference-files.d.ts +27 -0
- package/dist/reference-files.js +202 -0
- package/dist/run-attachments.d.ts +79 -0
- package/dist/run-attachments.js +276 -0
- package/dist/secret-scan.d.ts +1 -1
- package/dist/secret-scan.js +3 -0
- package/dist/secret-values.d.ts +17 -0
- package/dist/secret-values.js +81 -0
- package/dist/trail/chain.d.ts +12 -0
- package/dist/trail/chain.js +89 -0
- package/dist/trail/deltas.d.ts +34 -0
- package/dist/trail/deltas.js +206 -0
- package/dist/trail/index.d.ts +27 -0
- package/dist/trail/index.js +128 -0
- package/dist/trail/keys.d.ts +14 -0
- package/dist/trail/keys.js +61 -0
- package/dist/trail/recorder.d.ts +118 -0
- package/dist/trail/recorder.js +697 -0
- package/dist/trail/rules.d.ts +30 -0
- package/dist/trail/rules.js +158 -0
- package/dist/trail/stream.d.ts +41 -0
- package/dist/trail/stream.js +86 -0
- package/package.json +1 -1
package/dist/daemon.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { existsSync, rmSync } from 'node:fs';
|
|
2
|
+
import { blankSecrets } from './secret-values.js';
|
|
2
3
|
import { flushPendingResults, listPendingResults } from './pending.js';
|
|
3
|
-
import {
|
|
4
|
+
import { flushPendingTrails } from './trail/index.js';
|
|
5
|
+
import { loadConfig, runnerDir } from './config.js';
|
|
4
6
|
import { hostname, platform } from 'node:os';
|
|
5
7
|
import { RunnerApi } from './api.js';
|
|
6
8
|
import { availableEngines, getAdapter, supportedEngines } from './engines/index.js';
|
|
@@ -10,6 +12,7 @@ import { runJobPool } from './pool.js';
|
|
|
10
12
|
import { machineLogins } from './machine-logins.js';
|
|
11
13
|
import { RUNNER_VERSION } from './version.js';
|
|
12
14
|
import { LimitGate } from './limit.js';
|
|
15
|
+
import { fallbackKey } from './api-fallback.js';
|
|
13
16
|
import { heldByLiveProcesses, liveWorktrees, recordHeld, releaseHeld } from './held.js';
|
|
14
17
|
import { recoverPreviousProcess } from './recover.js';
|
|
15
18
|
import { cutWorktrees, dropCut, expiredCuts, keptWorktrees } from './cut.js';
|
|
@@ -19,7 +22,7 @@ import { signalEngineGroups } from './orphans.js';
|
|
|
19
22
|
import { engineBlocks, unattendedContext } from './unattended.js';
|
|
20
23
|
import { claimPause, engineWatch } from './engine-watch.js';
|
|
21
24
|
function log(msg) {
|
|
22
|
-
console.log(`[firefunc-runner] ${new Date().toISOString()} ${msg}`);
|
|
25
|
+
console.log(`[firefunc-runner] ${new Date().toISOString()} ${blankSecrets(msg)}`);
|
|
23
26
|
}
|
|
24
27
|
export function claimState(s) {
|
|
25
28
|
const held = [...new Set([...s.holding, ...s.pending])].sort();
|
|
@@ -122,6 +125,13 @@ export async function startDaemon(cfg) {
|
|
|
122
125
|
});
|
|
123
126
|
let serverMax = 1;
|
|
124
127
|
const refreshConfig = async () => {
|
|
128
|
+
const saved = loadConfig();
|
|
129
|
+
if (saved) {
|
|
130
|
+
cfg.maxParallel = saved.maxParallel;
|
|
131
|
+
cfg.jobTimeoutMinutes = saved.jobTimeoutMinutes;
|
|
132
|
+
cfg.claudeApiKeyFallback = saved.claudeApiKeyFallback;
|
|
133
|
+
cfg.claudeApiKeyFile = saved.claudeApiKeyFile;
|
|
134
|
+
}
|
|
125
135
|
const c = await api.config();
|
|
126
136
|
if (c)
|
|
127
137
|
serverMax = Math.max(1, Math.floor(c.maxParallel));
|
|
@@ -234,6 +244,7 @@ export async function startDaemon(cfg) {
|
|
|
234
244
|
catch {
|
|
235
245
|
}
|
|
236
246
|
const gate = new LimitGate(LimitGate.fileIn(rdir));
|
|
247
|
+
gate.waive = (engine) => engine === 'claude_code' && fallbackKey(cfg, rdir) !== null;
|
|
237
248
|
const limitReports = () => gate.active().map((l) => ({ engine: l.engine, kind: 'plan', resetsAt: l.resetsAt }));
|
|
238
249
|
const paused = claimPause({ watch: declared, isLimited: (e) => gate.isLimited(e), log });
|
|
239
250
|
const claimBody = (extra = {}) => ({
|
|
@@ -295,6 +306,7 @@ export async function startDaemon(cfg) {
|
|
|
295
306
|
if (flushed && (flushed.delivered || flushed.refused)) {
|
|
296
307
|
log(`pending results: ${flushed.delivered} delivered, ${flushed.refused} refused, ${flushed.kept} kept`);
|
|
297
308
|
}
|
|
309
|
+
await flushPendingTrails(rdir, (runId, batch) => api.trail(runId, batch)).catch(() => null);
|
|
298
310
|
declared.rescan();
|
|
299
311
|
if (Date.now() - lastCutSweep > 10 * 60_000) {
|
|
300
312
|
lastCutSweep = Date.now();
|
package/dist/engines/claude.js
CHANGED
|
@@ -3,6 +3,7 @@ import { readClaudeBudget } from './claude-budget.js';
|
|
|
3
3
|
import { readClaudeUsage } from '../usage.js';
|
|
4
4
|
import { mcpFromContext } from '../mcp.js';
|
|
5
5
|
import { readClaudeLimit } from '../limit.js';
|
|
6
|
+
import { claudeApiKeyNow } from '../api-fallback.js';
|
|
6
7
|
import { commandName } from '../keep-local.js';
|
|
7
8
|
function claudeSummary(streamJson) {
|
|
8
9
|
const lines = streamJson.trim().split('\n');
|
|
@@ -191,14 +192,19 @@ export const claudeAdapter = {
|
|
|
191
192
|
args.push('--mcp-config', mcp.configPath, '--strict-mcp-config');
|
|
192
193
|
}
|
|
193
194
|
args.push(...(cfg.claudeArgs ?? []));
|
|
195
|
+
const billing = claudeApiKeyNow(cfg);
|
|
194
196
|
const env = cfg.claudeUseApiKey
|
|
195
197
|
? ctx.runEnv
|
|
196
|
-
:
|
|
198
|
+
: billing.key
|
|
199
|
+
? { ...ctx.runEnv, ANTHROPIC_API_KEY: billing.key }
|
|
200
|
+
: { ...ctx.runEnv, ANTHROPIC_API_KEY: undefined };
|
|
197
201
|
const authLogLine = cfg.claudeUseApiKey
|
|
198
202
|
? 'ANTHROPIC_API_KEY (API billing — opted in)'
|
|
199
|
-
:
|
|
200
|
-
? '
|
|
201
|
-
:
|
|
203
|
+
: billing.key
|
|
204
|
+
? 'ANTHROPIC_API_KEY (API billing — the plan is spent, until it resets)'
|
|
205
|
+
: cfg.claudeCodeOAuthToken
|
|
206
|
+
? 'subscription token'
|
|
207
|
+
: 'your machine Claude login (API key hidden — subscription billing)';
|
|
202
208
|
return {
|
|
203
209
|
bin: this.bin(cfg),
|
|
204
210
|
args,
|
package/dist/git-auth.d.ts
CHANGED
package/dist/git-auth.js
CHANGED
|
@@ -69,8 +69,16 @@ export async function openDraftPr(args) {
|
|
|
69
69
|
if (list.ok) {
|
|
70
70
|
const rows = (await list.json());
|
|
71
71
|
const hit = rows.find((r) => typeof r.html_url === 'string' && Number.isFinite(r.number));
|
|
72
|
-
if (hit)
|
|
72
|
+
if (hit) {
|
|
73
|
+
if (args.update) {
|
|
74
|
+
await fetch(`https://api.github.com/repos/${repo}/pulls/${Number(hit.number)}`, {
|
|
75
|
+
method: 'PATCH',
|
|
76
|
+
headers,
|
|
77
|
+
body: JSON.stringify({ title, body }),
|
|
78
|
+
}).catch(() => undefined);
|
|
79
|
+
}
|
|
73
80
|
return { url: hit.html_url, number: Number(hit.number) };
|
|
81
|
+
}
|
|
74
82
|
}
|
|
75
83
|
}
|
|
76
84
|
return { error: `github refused to open the pull request (${res.status})` };
|