fwdloop 0.25.1 → 0.26.0
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 +8 -1
- package/bin/fwdloop +18 -19
- package/package.json +2 -2
- package/src/config.js +23 -2
- package/src/launcher.js +4 -4
- package/src/pagefetch.js +3 -3
- package/src/panel/authortrigger.js +4 -0
- package/src/panel/index.html +20 -8
- package/src/prompts.js +1 -1
- package/src/provider.js +2 -2
- package/src/runner.js +4 -2
- package/types/config.d.ts +9 -0
- package/types/launcher.d.ts +2 -2
- package/types/pagefetch.d.ts +1 -1
package/README.md
CHANGED
|
@@ -28,6 +28,13 @@ change.
|
|
|
28
28
|
It is built mainly for that shape of work: gather, decide, pause, hand off, continue. Not a
|
|
29
29
|
general agent. Not a chat bot. A workflow that a person can read, approve, rerun, and edit.
|
|
30
30
|
|
|
31
|
+
## See it
|
|
32
|
+
|
|
33
|
+
A real past run: a job that reads a public flights page, lists 3 Madrid→Rome flights, asks a
|
|
34
|
+
human to check them, then writes the result out. Shown across the panel's Job, Run, Ask, Audit and Result tabs.
|
|
35
|
+
|
|
36
|
+
<img src="https://raw.githubusercontent.com/hamr0/fwdloop/main/docs/media/walkthrough.gif" alt="fwdloop panel walkthrough: Job, Run, Ask, Audit, Result" width="100%">
|
|
37
|
+
|
|
31
38
|
## Where it comes from
|
|
32
39
|
|
|
33
40
|
fwdloop carries forward what the bare suite learned about agentic automation: how to author
|
|
@@ -60,7 +67,7 @@ standalone.
|
|
|
60
67
|
|
|
61
68
|
## Status
|
|
62
69
|
|
|
63
|
-
Work in progress.
|
|
70
|
+
Work in progress, on npm as `fwdloop` (`npm install -g fwdloop`); expect changes between versions. `fwdloop` with no arguments opens a menu to start the panel. All jobs live in `~/.config/fwdloop/flows`, next to the settings; `--root <folder>` points a command somewhere else.
|
|
64
71
|
|
|
65
72
|
The in-run `impact` tool needs ripgrep (`rg`) on PATH; without it the tool is refused with a message, never a wrong answer.
|
|
66
73
|
|
package/bin/fwdloop
CHANGED
|
@@ -40,7 +40,7 @@ import {
|
|
|
40
40
|
} from '../src/provider.js';
|
|
41
41
|
import { readModelRecord, readRunModel, LEARNINGS_FILE } from '../src/flowmodel.js';
|
|
42
42
|
import { readRunInputs } from '../src/runfile.js';
|
|
43
|
-
import { configDoorHome } from '../src/config.js';
|
|
43
|
+
import { configDoorHome, defaultFlowsRoot } from '../src/config.js';
|
|
44
44
|
import {
|
|
45
45
|
claimHold, settleHold, nameRunDir, monthlyRefusalText, ConfigError,
|
|
46
46
|
} from '../src/monthly.js';
|
|
@@ -145,10 +145,13 @@ function fail(message) {
|
|
|
145
145
|
*/
|
|
146
146
|
function resolveRoot(cmd, given) {
|
|
147
147
|
try {
|
|
148
|
-
|
|
148
|
+
// M4b am7: no `--root` = the ONE default (`defaultFlowsRoot`: <config home>/flows), never the current folder
|
|
149
|
+
return realpathSync(given === undefined ? defaultFlowsRoot() : resolve(given));
|
|
149
150
|
} catch (err) {
|
|
150
|
-
|
|
151
|
-
|
|
151
|
+
// No --root given: name the default jobs folder (the failing path from the error), never the word "undefined".
|
|
152
|
+
const what = given === undefined ? `the jobs folder "${err.path ?? '~/.config/fwdloop/flows'}"` : `--root "${given}"`;
|
|
153
|
+
if (err.code === 'ENOENT') fail(`${cmd}: ${what} does not exist`);
|
|
154
|
+
fail(`${cmd}: ${what} cannot be resolved: ${err.code ?? err.message}`);
|
|
152
155
|
}
|
|
153
156
|
}
|
|
154
157
|
|
|
@@ -326,7 +329,6 @@ async function cmdRun(rest) {
|
|
|
326
329
|
|
|
327
330
|
const flowName = positionals[0];
|
|
328
331
|
if (!flowName) fail('run: a flow name is required — fwdloop run <flow> --root <dir> --source <role>=<path> ...');
|
|
329
|
-
if (!values.root) fail('run: --root <dir> is required');
|
|
330
332
|
|
|
331
333
|
const root = resolveRoot('run', values.root);
|
|
332
334
|
const nameCheck = checkFlowName(flowName);
|
|
@@ -444,7 +446,7 @@ async function cmdRun(rest) {
|
|
|
444
446
|
});
|
|
445
447
|
|
|
446
448
|
for (const d of rerunDirs(result, join(root, flowName))) hold.addRunDir(d);
|
|
447
|
-
reportRunResult(result, { rootArg: values.root });
|
|
449
|
+
reportRunResult(result, { rootArg: values.root ?? root });
|
|
448
450
|
}
|
|
449
451
|
|
|
450
452
|
// ---------------------------------------------------------------------------
|
|
@@ -456,7 +458,7 @@ function cmdInbox(rest) {
|
|
|
456
458
|
args: rest,
|
|
457
459
|
options: { root: { type: 'string' } },
|
|
458
460
|
});
|
|
459
|
-
const root = resolveRoot('inbox', values.root
|
|
461
|
+
const root = resolveRoot('inbox', values.root);
|
|
460
462
|
|
|
461
463
|
const rows = [];
|
|
462
464
|
// F48 round 3: flow/run identity is walked via `listFlowNames`/
|
|
@@ -552,7 +554,7 @@ function cmdShow(rest) {
|
|
|
552
554
|
const [askId] = positionals;
|
|
553
555
|
if (!askId) fail('show: an askId is required — fwdloop show <askId> --root <dir>');
|
|
554
556
|
|
|
555
|
-
const root = resolveRoot('show', values.root
|
|
557
|
+
const root = resolveRoot('show', values.root);
|
|
556
558
|
const runDir = findRunDirByAskId(root, askId);
|
|
557
559
|
if (!runDir) fail(`show: no open ask found for askId "${askId}" under ${root}`);
|
|
558
560
|
|
|
@@ -609,7 +611,7 @@ function cmdAnswer(rest) {
|
|
|
609
611
|
if (!askId) fail('answer: an askId is required — fwdloop answer <askId> accept|redo "<reason>"|rerun "<reason>"');
|
|
610
612
|
if (!decision) fail(`answer: a decision (accept|redo|rerun) is required for askId "${askId}"`);
|
|
611
613
|
|
|
612
|
-
const root = resolveRoot('answer', values.root
|
|
614
|
+
const root = resolveRoot('answer', values.root);
|
|
613
615
|
const runDir = findRunDirByAskId(root, askId);
|
|
614
616
|
if (!runDir) fail(`answer: no open ask found for askId "${askId}" under ${root}`);
|
|
615
617
|
|
|
@@ -639,7 +641,6 @@ async function cmdResume(rest) {
|
|
|
639
641
|
const runId = positionals[0];
|
|
640
642
|
if (!runId) fail('resume: a runId is required — fwdloop resume <runId> --flow <name> --root <dir>');
|
|
641
643
|
if (!values.flow) fail('resume: --flow <name> is required');
|
|
642
|
-
if (!values.root) fail('resume: --root <dir> is required');
|
|
643
644
|
|
|
644
645
|
const root = resolveRoot('resume', values.root);
|
|
645
646
|
const flowName = values.flow;
|
|
@@ -716,7 +717,7 @@ async function cmdResume(rest) {
|
|
|
716
717
|
});
|
|
717
718
|
|
|
718
719
|
for (const d of rerunDirs(result, join(root, flowName))) hold.addRunDir(d);
|
|
719
|
-
reportRunResult(result, { rootArg: values.root });
|
|
720
|
+
reportRunResult(result, { rootArg: values.root ?? root });
|
|
720
721
|
}
|
|
721
722
|
|
|
722
723
|
// ---------------------------------------------------------------------------
|
|
@@ -739,7 +740,6 @@ async function cmdContinue(rest) {
|
|
|
739
740
|
const runId = positionals[0];
|
|
740
741
|
if (!runId) fail('continue: a runId is required — fwdloop continue <runId> --flow <name> --root <dir>');
|
|
741
742
|
if (!values.flow) fail('continue: --flow <name> is required');
|
|
742
|
-
if (!values.root) fail('continue: --root <dir> is required');
|
|
743
743
|
|
|
744
744
|
const root = resolveRoot('continue', values.root);
|
|
745
745
|
const flowName = values.flow;
|
|
@@ -802,7 +802,7 @@ async function cmdContinue(rest) {
|
|
|
802
802
|
});
|
|
803
803
|
|
|
804
804
|
for (const d of rerunDirs(result, join(root, flowName))) hold.addRunDir(d);
|
|
805
|
-
reportRunResult(result, { rootArg: values.root });
|
|
805
|
+
reportRunResult(result, { rootArg: values.root ?? root });
|
|
806
806
|
}
|
|
807
807
|
|
|
808
808
|
// ---------------------------------------------------------------------------
|
|
@@ -823,7 +823,7 @@ async function cmdPanel(rest) {
|
|
|
823
823
|
root: { type: 'string' },
|
|
824
824
|
},
|
|
825
825
|
});
|
|
826
|
-
const root = resolveRoot('panel', values.root
|
|
826
|
+
const root = resolveRoot('panel', values.root);
|
|
827
827
|
|
|
828
828
|
const argv = ['--root', root];
|
|
829
829
|
if (values.port) argv.push('--port', values.port);
|
|
@@ -863,7 +863,7 @@ async function cmdDraft(rest) {
|
|
|
863
863
|
const { env } = keysLoad;
|
|
864
864
|
const proseFile = positionals[0];
|
|
865
865
|
if (!proseFile) fail('draft: a prose file is required — fwdloop draft <prose.txt> --out <draftDir> --root <flowsDir> --name <flow>');
|
|
866
|
-
for (const req of ['out', '
|
|
866
|
+
for (const req of ['out', 'name']) if (!values[req]) fail(`draft: --${req} is required`);
|
|
867
867
|
|
|
868
868
|
const leftRules = [];
|
|
869
869
|
for (const pair of values.left === undefined ? [] : values.left.split(',')) {
|
|
@@ -926,7 +926,7 @@ async function cmdDraft(rest) {
|
|
|
926
926
|
proseFile: resolve(proseFile),
|
|
927
927
|
proseRead,
|
|
928
928
|
dir: resolve(values.out),
|
|
929
|
-
root: resolve(values.root),
|
|
929
|
+
root: values.root === undefined ? defaultFlowsRoot() : resolve(values.root),
|
|
930
930
|
name: values.name,
|
|
931
931
|
noQuestions: values['no-questions'] === true,
|
|
932
932
|
...(leftRules.length ? { leftRules } : {}),
|
|
@@ -996,7 +996,6 @@ function cmdLearn(rest) {
|
|
|
996
996
|
const [sub, ...args] = rest;
|
|
997
997
|
if (sub !== 'seed') fail('learn: expected "seed" — fwdloop learn seed --root <flows folder>');
|
|
998
998
|
const { values } = parseArgs({ args, options: { root: { type: 'string' } } });
|
|
999
|
-
if (!values.root) fail('learn seed: --root <flows folder> is required');
|
|
1000
999
|
const root = resolveRoot('learn seed', values.root);
|
|
1001
1000
|
const r = seedLedger({ root });
|
|
1002
1001
|
if (r.skippedNoDoor) fail('learn seed: a test process has no config home (set FWDLOOP_CONFIG_HOME)');
|
|
@@ -1010,11 +1009,11 @@ function cmdLearn(rest) {
|
|
|
1010
1009
|
|
|
1011
1010
|
/**
|
|
1012
1011
|
* M4b am4/am5 (the launcher): a bare `fwdloop` shows the menu; `start | stop | restart | status | install` are its five choices as verbs. All logic is src/launcher.js.
|
|
1013
|
-
* `--root <flows folder>` (default
|
|
1012
|
+
* `--root <flows folder>` (default <config home>/flows, M4b am7) is the folder the runs line reads and `start` hands the panel; the config home is the real ~/.config/fwdloop.
|
|
1014
1013
|
*/
|
|
1015
1014
|
async function cmdLauncher(cmd, rest) {
|
|
1016
1015
|
const at = rest.indexOf('--root');
|
|
1017
|
-
const given = at === -1 ?
|
|
1016
|
+
const given = at === -1 ? undefined : rest[at + 1];
|
|
1018
1017
|
if (at !== -1 && (given === undefined || given.startsWith('--'))) fail(`${cmd}: --root needs a folder`);
|
|
1019
1018
|
const args = at === -1 ? rest : rest.filter((_, i) => i !== at && i !== at + 1);
|
|
1020
1019
|
process.exitCode = await launcherMain(cmd, args, { root: resolveRoot(cmd, given) });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fwdloop",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.26.0",
|
|
4
4
|
"description": "Describe a job as steps and guardrails; an agent builds the workflow, pauses for humans where you said, checks every step happened, and reruns it under budgets it cannot touch.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
],
|
|
51
51
|
"dependencies": {
|
|
52
52
|
"bare-agent": "^0.52.0",
|
|
53
|
-
"barebrowse": "^0.
|
|
53
|
+
"barebrowse": "^0.24.1",
|
|
54
54
|
"bareguard": "^0.26.0",
|
|
55
55
|
"litectx": "^0.32.0"
|
|
56
56
|
},
|
package/src/config.js
CHANGED
|
@@ -37,6 +37,26 @@ export function configHome(home) {
|
|
|
37
37
|
return home ?? join(homedir(), '.config', 'fwdloop');
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
+
/**
|
|
41
|
+
* M4b am7: the ONE decider of the default jobs folder, `<config home>/flows`, used by every verb given no `--root` (the current
|
|
42
|
+
* folder is never the default). Made 0700 if missing (chmod only when this call made it, so umask cannot loosen it and an
|
|
43
|
+
* existing folder is never touched). Under a test process with no explicit home and no `FWDLOOP_CONFIG_HOME` it THROWS rather
|
|
44
|
+
* than make a folder under the real ~/.config/fwdloop (the same door as `configDoorHome`).
|
|
45
|
+
* @param {string} [home] test seam; production never passes it
|
|
46
|
+
* @returns {string}
|
|
47
|
+
*/
|
|
48
|
+
export function defaultFlowsRoot(home) {
|
|
49
|
+
let base = home;
|
|
50
|
+
if (base === undefined) {
|
|
51
|
+
const door = configDoorHome();
|
|
52
|
+
if (door.skip) throw new Error('a test process has no config home for the default jobs folder (set FWDLOOP_CONFIG_HOME or pass --root)');
|
|
53
|
+
base = door.home;
|
|
54
|
+
}
|
|
55
|
+
const root = join(configHome(base), 'flows');
|
|
56
|
+
if (mkdirSync(root, { recursive: true, mode: 0o700 }) !== undefined) chmodSync(root, 0o700);
|
|
57
|
+
return root;
|
|
58
|
+
}
|
|
59
|
+
|
|
40
60
|
/**
|
|
41
61
|
* @param {string} [home]
|
|
42
62
|
* @returns {string} `<home>/config.json`
|
|
@@ -105,8 +125,9 @@ export function providerFieldProblem(field, v) {
|
|
|
105
125
|
return null;
|
|
106
126
|
}
|
|
107
127
|
|
|
108
|
-
/** A Base URL as stored: trailing slashes dropped.
|
|
109
|
-
|
|
128
|
+
/** A Base URL as stored: trailing slashes dropped. The lookbehind starts the match only at the start of a run of slashes, so a long run is linear.
|
|
129
|
+
* // borrowed-from: bareloop src/config.js@v0.48.0 (ed3a110) */
|
|
130
|
+
export const cleanBaseUrl = (v) => v.replace(/(?<!\/)\/+$/, '');
|
|
110
131
|
|
|
111
132
|
const isPrice = (v) => typeof v === 'number' && Number.isFinite(v) && v > 0;
|
|
112
133
|
|
package/src/launcher.js
CHANGED
|
@@ -20,7 +20,7 @@ import { createServer } from 'node:net';
|
|
|
20
20
|
import { openAsker } from './prompts.js';
|
|
21
21
|
import { dirname, join } from 'node:path';
|
|
22
22
|
import { fileURLToPath } from 'node:url';
|
|
23
|
-
import { readConfig, updateConfig, configPath, ConfigError } from './config.js';
|
|
23
|
+
import { readConfig, updateConfig, configPath, defaultFlowsRoot, ConfigError } from './config.js';
|
|
24
24
|
import { keysHome, keysFilePath, createKeysFile } from './keysfile.js';
|
|
25
25
|
import { openInOs } from './opener.js';
|
|
26
26
|
import { PLAIN, makePaint } from './tty-colour.js';
|
|
@@ -49,7 +49,7 @@ const RULE_WIDTH = 56;
|
|
|
49
49
|
/**
|
|
50
50
|
* @typedef {object} LauncherDeps every OS touch, injectable (a test passes all of them)
|
|
51
51
|
* @property {string} [home] the fwdloop config home (`~/.config/fwdloop`, src/config.js `configHome`); undefined = the real one
|
|
52
|
-
* @property {string} [root] the flows folder the runs line reads and `start` hands the panel (`--root`); default
|
|
52
|
+
* @property {string} [root] the flows folder the runs line reads and `start` hands the panel (`--root`); default `<config home>/flows` (`defaultFlowsRoot`)
|
|
53
53
|
* @property {number} [portStart] @property {number} [portCount]
|
|
54
54
|
* @property {number[]} [ports] an explicit port list (tests); wins over portStart/portCount
|
|
55
55
|
* @property {number} [timeoutMs] probe timeout per port
|
|
@@ -195,7 +195,7 @@ export async function buildHeader(d) {
|
|
|
195
195
|
const first = `${P.boldCyan('fwdloop')} ${P.grey(version)}${sep}${state}${sep}${where}`;
|
|
196
196
|
let second;
|
|
197
197
|
try {
|
|
198
|
-
const c = countRuns(runsListForCount({ root: d.root ??
|
|
198
|
+
const c = countRuns(runsListForCount({ root: d.root ?? defaultFlowsRoot(d.home), ...(typeof d.now === 'number' ? { now: () => /** @type {number} */ (d.now) } : {}) }));
|
|
199
199
|
second = `${P.grey('runs:')} ${c.running > 0 ? P.green(`${c.running} running`) : P.grey(`${c.running} running`)}${sep}`
|
|
200
200
|
+ `${c.needYou > 0 ? P.yellow(`${c.needYou} need you`) : P.grey(`${c.needYou} need you`)}${sep}${c.total} in all`;
|
|
201
201
|
} catch {
|
|
@@ -387,7 +387,7 @@ export async function startCmd(io, d, shown) {
|
|
|
387
387
|
try { mkdirSync(dir, { recursive: true, mode: 0o700 }); } catch { /* the log open below reports it */ }
|
|
388
388
|
const logFile = join(dir, 'panel.log');
|
|
389
389
|
const bin = d.fwdloopBin ?? join(HERE, '..', 'bin', 'fwdloop');
|
|
390
|
-
const argv = ['panel', '--port', String(chosen), '--root', d.root ??
|
|
390
|
+
const argv = ['panel', '--port', String(chosen), '--root', d.root ?? defaultFlowsRoot(d.home)];
|
|
391
391
|
const spawnFn = d.spawnFn ?? spawnDetached;
|
|
392
392
|
try {
|
|
393
393
|
const child = spawnFn({ bin, argv, env: d.env ?? process.env, logPath: logFile });
|
package/src/pagefetch.js
CHANGED
|
@@ -90,8 +90,8 @@ export function pageContentChars(text) {
|
|
|
90
90
|
* snapshot: (o?: {mode?: string}) => Promise<string>, close: () => Promise<void>}} FetchPage the part of barebrowse's page handle the fetch uses
|
|
91
91
|
*/
|
|
92
92
|
|
|
93
|
-
/** the oldest barebrowse
|
|
94
|
-
export const MIN_BAREBROWSE = [0,
|
|
93
|
+
/** the oldest barebrowse we accept: 0.21.0 honours CONNECT_OPTIONS (incognito, blockPrivateNetwork; an older one would drop both guards without a word); 0.24.1 tethers Chromium to its launcher, so a killed run or an Abandoned draft leaves no browser behind */
|
|
94
|
+
export const MIN_BAREBROWSE = [0, 24, 1];
|
|
95
95
|
|
|
96
96
|
/** @param {string} v @returns {boolean} true when `v` (x.y.z) is at least MIN_BAREBROWSE */
|
|
97
97
|
export function barebrowseNewEnough(v) {
|
|
@@ -108,7 +108,7 @@ async function loadConnect() {
|
|
|
108
108
|
try {
|
|
109
109
|
const mod = /** @type {any} */ (await import('barebrowse'));
|
|
110
110
|
const pkg = JSON.parse(readFileSync(join(dirname(fileURLToPath(import.meta.resolve('barebrowse'))), '..', 'package.json'), 'utf8'));
|
|
111
|
-
if (!barebrowseNewEnough(pkg.version)) return { ok: /** @type {const} */ (false), error: `the page reader (barebrowse ${pkg.version}) is too old: a web page needs 0.
|
|
111
|
+
if (!barebrowseNewEnough(pkg.version)) return { ok: /** @type {const} */ (false), error: `the page reader (barebrowse ${pkg.version}) is too old: a web page needs 0.24.1 or newer, which keeps the browser private, off the local network, and closed when the run ends` };
|
|
112
112
|
return { ok: /** @type {const} */ (true), connect: /** @type {(opts: Record<string, any>) => Promise<FetchPage>} */ (mod.connect) };
|
|
113
113
|
} catch (e) { return { ok: /** @type {const} */ (false), error: `the page reader (barebrowse) could not be loaded: ${/** @type {Error} */ (e).message}` }; }
|
|
114
114
|
}
|
|
@@ -25,6 +25,7 @@ import { destinationRefusal, checkInputRows, runInputRows } from './authorcard.j
|
|
|
25
25
|
import { endRow, readHistory } from '../books.js';
|
|
26
26
|
import { appendRow } from '../jsonl-append.js';
|
|
27
27
|
import { loadCatalogue } from '../catalogue.js';
|
|
28
|
+
import { canFlowRun, willNotRunSay } from '../canrun.js';
|
|
28
29
|
import {
|
|
29
30
|
FLOW_FILES, checkFlowName, listFlowNames, listRunIds, planForReuse, readFileInside, readFlow, readRunJobCopy, resolveRunDir,
|
|
30
31
|
} from '../flow.js';
|
|
@@ -398,6 +399,9 @@ export function createTriggerDoor(opts) {
|
|
|
398
399
|
read = /** @type {any} */ (kept);
|
|
399
400
|
planRun = planRec.run;
|
|
400
401
|
}
|
|
402
|
+
// the Run door's own `canFlowRun` (a retired check form, an unwired verb), on the plan this fire runs, in the Run door's own sentence: refused at $0, nothing started
|
|
403
|
+
const can = canFlowRun(read);
|
|
404
|
+
if (!can.ok) return done({ outcome: 'refused', why: willNotRunSay(flow, String(can.red)) });
|
|
401
405
|
const claim = monthlyClaim(read.arbiter.capUsd); // the same check the Run door decides on
|
|
402
406
|
if (claim && 'problem' in claim) return done({ outcome: 'refused', why: `${claim.problem}. Nothing spent.` });
|
|
403
407
|
if (claim && !claim.ok) return done({ outcome: 'monthly-exhausted', leftUsd: claim.room.leftUsd, needUsd: claim.room.needUsd, atLeast: claim.room.atLeast === true });
|
package/src/panel/index.html
CHANGED
|
@@ -5224,7 +5224,7 @@
|
|
|
5224
5224
|
askWait: askWaitEl.value.trim(),
|
|
5225
5225
|
provider: modelPick().provider,
|
|
5226
5226
|
model: modelPick().model,
|
|
5227
|
-
thinking: thinkingEl.checked && !
|
|
5227
|
+
thinking: thinkingEl.checked && !thinkingNone,
|
|
5228
5228
|
...(reuseOf !== null ? {reuseOf: reuseOf} : {})
|
|
5229
5229
|
};
|
|
5230
5230
|
}
|
|
@@ -5377,6 +5377,7 @@
|
|
|
5377
5377
|
runFlowSel.classList.toggle("locked", on);
|
|
5378
5378
|
rwPickedEl.classList.toggle("locked", on);
|
|
5379
5379
|
card.querySelectorAll('input[name="jf-mode"]').forEach(function(r){ r.disabled = on || sessionLive; });
|
|
5380
|
+
paintModelLock();
|
|
5380
5381
|
}
|
|
5381
5382
|
// top-right: Abandon while a draft is live and unsigned, else Clear
|
|
5382
5383
|
function clearButtonFor(live, hasId){
|
|
@@ -5683,6 +5684,16 @@
|
|
|
5683
5684
|
var modelEl = byId("jf-model");
|
|
5684
5685
|
var thinkingEl = byId("jf-thinking");
|
|
5685
5686
|
var modelLines = [];
|
|
5687
|
+
var modelNone = true; // no model to pick (none ticked, or the list could not be read): the menu stays shut
|
|
5688
|
+
var thinkingNone = true; // Thinking cannot change for the picked line (thinkingBoxState): the box stays shut
|
|
5689
|
+
// M6 item 7: the card is locked as a whole, so the Model menu and the Thinking box lock with it. THE one writer of both `disabled`s:
|
|
5690
|
+
// shut when the card is locked OR for their own reason above; the other sites only set the reason and call this.
|
|
5691
|
+
function paintModelLock(){
|
|
5692
|
+
if(!modelEl || !thinkingEl) return; // syncCardLock can run before these two are looked up
|
|
5693
|
+
var on = cardLocked();
|
|
5694
|
+
modelEl.disabled = on || modelNone; modelEl.classList.toggle("locked", on);
|
|
5695
|
+
thinkingEl.disabled = on || thinkingNone; thinkingEl.classList.toggle("locked", on);
|
|
5696
|
+
}
|
|
5686
5697
|
function modelPick(){
|
|
5687
5698
|
var l = modelLines[Number(modelEl.value)];
|
|
5688
5699
|
return l ? {provider: l.slot, model: l.model} : {provider: "", model: ""};
|
|
@@ -5696,7 +5707,8 @@
|
|
|
5696
5707
|
}
|
|
5697
5708
|
function paintThinking(){
|
|
5698
5709
|
var st = thinkingBoxState(modelLines[Number(modelEl.value)], thinkingEl.checked);
|
|
5699
|
-
|
|
5710
|
+
thinkingNone = st.disabled; thinkingEl.checked = st.checked;
|
|
5711
|
+
paintModelLock();
|
|
5700
5712
|
byId("jf-thinking-note").textContent = st.note;
|
|
5701
5713
|
drafterModel = modelPick().model;
|
|
5702
5714
|
}
|
|
@@ -5716,7 +5728,7 @@
|
|
|
5716
5728
|
}
|
|
5717
5729
|
runPickEl.addEventListener("change", function(){ runPicked = runPickChoice(); });
|
|
5718
5730
|
function syncRunPick(){
|
|
5719
|
-
runPickEl.innerHTML = modelEl.innerHTML; runPickEl.disabled =
|
|
5731
|
+
runPickEl.innerHTML = modelEl.innerHTML; runPickEl.disabled = modelNone;
|
|
5720
5732
|
for(var i = 0; i < modelLines.length; i += 1){ if(modelLines[i].slot === runPicked.provider && modelLines[i].model === runPicked.model){ runPickEl.value = String(i); break; } }
|
|
5721
5733
|
}
|
|
5722
5734
|
// `tries` counts the reads that failed in a row (a click passes an Event, which is not a number: that is a fresh read).
|
|
@@ -5725,7 +5737,7 @@
|
|
|
5725
5737
|
var failed = typeof tries === "number" ? tries : 0;
|
|
5726
5738
|
function unread(){
|
|
5727
5739
|
if(modelLines.length > 0) return; // a menu that was filled keeps what it had
|
|
5728
|
-
modelEl.innerHTML = "";
|
|
5740
|
+
modelEl.innerHTML = ""; modelNone = true; paintModelLock();
|
|
5729
5741
|
var o = document.createElement("option"); o.value = "";
|
|
5730
5742
|
o.textContent = failed < 5 ? "Could not read your models. Trying again\u2026" : "Could not read your models. Reload the page.";
|
|
5731
5743
|
modelEl.appendChild(o);
|
|
@@ -5739,12 +5751,12 @@
|
|
|
5739
5751
|
modelEl.innerHTML = "";
|
|
5740
5752
|
if(modelLines.length === 0){
|
|
5741
5753
|
var none = document.createElement("option"); none.value = ""; none.textContent = j.say || "Tick a model in Settings > Providers."; modelEl.appendChild(none);
|
|
5742
|
-
|
|
5754
|
+
modelNone = true;
|
|
5743
5755
|
} else {
|
|
5744
|
-
|
|
5756
|
+
modelNone = false;
|
|
5745
5757
|
modelLines.forEach(function(l, i){ var o = document.createElement("option"); o.value = String(i); o.textContent = l.label; modelEl.appendChild(o); });
|
|
5746
5758
|
}
|
|
5747
|
-
setModelPick(was.provider, was.model);
|
|
5759
|
+
setModelPick(was.provider, was.model); // (paints the lock through paintThinking)
|
|
5748
5760
|
syncRunPick();
|
|
5749
5761
|
}).catch(function(){ failed += 1; unread(); });
|
|
5750
5762
|
}
|
|
@@ -6235,7 +6247,7 @@
|
|
|
6235
6247
|
openNewCard();
|
|
6236
6248
|
setMode("new");
|
|
6237
6249
|
setVal("jf-name", c.flowName); setVal("jf-job", c.job); setVal("jf-cap-money", c.capUsd);
|
|
6238
|
-
setModelPick(c.provider || "", c.model || ""); thinkingEl.checked = c.thinking === true && !
|
|
6250
|
+
setModelPick(c.provider || "", c.model || ""); thinkingEl.checked = c.thinking === true && !thinkingNone;
|
|
6239
6251
|
refreshCapNote();
|
|
6240
6252
|
setVal("jf-dest-folder", typeof c.destination === "string" ? c.destination : ""); setVal("jf-inputs", typeof c.inputs === "string" ? c.inputs : ""); setVal("jf-ask-wait", c.askWait || "1h");
|
|
6241
6253
|
sessionId = d.draftId;
|
package/src/prompts.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// borrowed-from: bareloop src/prompts.js@
|
|
1
|
+
// borrowed-from: bareloop src/prompts.js@v0.48.0 (openAsker only; askRequired and the menu changes are not copied)
|
|
2
2
|
// The CLI's one line-asker. Every prompt in the launcher reads through this, so a closed stdin behaves the same everywhere.
|
|
3
3
|
|
|
4
4
|
import { createInterface } from 'node:readline';
|
package/src/provider.js
CHANGED
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
import { dirname, basename } from 'node:path';
|
|
22
22
|
import { readFileInside } from './flow.js';
|
|
23
23
|
import { appendRow } from './jsonl-append.js';
|
|
24
|
-
import { readConfig, configDoorHome } from './config.js';
|
|
24
|
+
import { readConfig, configDoorHome, cleanBaseUrl } from './config.js';
|
|
25
25
|
import { isKeyName } from './keysfile.js';
|
|
26
26
|
import { OpenAI, Anthropic, Gemini } from 'bare-agent/providers';
|
|
27
27
|
|
|
@@ -81,7 +81,7 @@ export function resolveSlot(slotName, { config = {} } = {}) {
|
|
|
81
81
|
// F11: some providers ignore `max_completion_tokens`; only the legacy `max_tokens` key bounds their output. A per-row tick in Settings.
|
|
82
82
|
legacyMaxTokens: saved.legacyMaxTokens === true && shape === 'openai-api',
|
|
83
83
|
shape,
|
|
84
|
-
baseUrl: typeof saved.baseUrl === 'string' ? saved.baseUrl
|
|
84
|
+
baseUrl: typeof saved.baseUrl === 'string' ? cleanBaseUrl(saved.baseUrl) : '',
|
|
85
85
|
};
|
|
86
86
|
}
|
|
87
87
|
|
package/src/runner.js
CHANGED
|
@@ -979,7 +979,7 @@ export async function runStepRalph({
|
|
|
979
979
|
const usd = sumKnownUsd(attemptFloorUsd, result.costUsd);
|
|
980
980
|
const ranCalls = (turns ?? 0) > 0 || attemptFloorUsd !== null;
|
|
981
981
|
return stopped(stopWords(ranCalls ? attempt : attempt - 1, turns ?? 0), rowOf({
|
|
982
|
-
step, attempt: ranCalls ? attempt : null, verdict: 'stopped', gap: null, usd, spendComplete:
|
|
982
|
+
step, attempt: ranCalls ? attempt : null, verdict: 'stopped', gap: null, usd, spendComplete: typeof result.costUsd === 'number', wallMs, model: result.model, modelMatch: result.modelMatch, strike: false, at: now(), tokens: result.tokens ?? null, tools: result.tools ?? null, ungranted: result.ungranted, refused: result.refused, thinking: result.thinking,
|
|
983
983
|
}));
|
|
984
984
|
}
|
|
985
985
|
|
|
@@ -1008,9 +1008,11 @@ export async function runStepRalph({
|
|
|
1008
1008
|
const strike = seenGaps.has(normalised);
|
|
1009
1009
|
seenGaps.add(normalised);
|
|
1010
1010
|
if (strike) strikes += 1;
|
|
1011
|
+
// A floor from a faulted first call plus a retry whose own cost is unknown is "at least" the floor, never complete: complete needs THIS call's cost known
|
|
1012
|
+
// (no floor and an unknown cost is usd null, also incomplete - the "no provider ever built" case).
|
|
1011
1013
|
const usd = sumKnownUsd(attemptFloorUsd, result?.costUsd);
|
|
1012
1014
|
recordAudit(rowOf({
|
|
1013
|
-
step, attempt, verdict: 'red', gap: red, usd, spendComplete:
|
|
1015
|
+
step, attempt, verdict: 'red', gap: red, usd, spendComplete: typeof result?.costUsd === 'number', wallMs, model: result?.model, modelMatch: result?.modelMatch, strike, at: now(), tokens: result?.tokens ?? null, tools: result?.tools ?? null, ungranted: result?.ungranted, refused: result?.refused, thinking: result?.thinking,
|
|
1014
1016
|
}), red);
|
|
1015
1017
|
if (n === maxN) return { ok: false, outcome: 'attempt-fallback', red: `attempt-fallback: step "${step.goal}" — ${red}` };
|
|
1016
1018
|
if (strikes >= STRIKE_LIMIT) return { ok: false, outcome: 'struck-out', red: `struck-out: step "${step.goal}" — ${red}` };
|
package/types/config.d.ts
CHANGED
|
@@ -5,6 +5,15 @@
|
|
|
5
5
|
* @returns {string}
|
|
6
6
|
*/
|
|
7
7
|
export function configHome(home?: string): string;
|
|
8
|
+
/**
|
|
9
|
+
* M4b am7: the ONE decider of the default jobs folder, `<config home>/flows`, used by every verb given no `--root` (the current
|
|
10
|
+
* folder is never the default). Made 0700 if missing (chmod only when this call made it, so umask cannot loosen it and an
|
|
11
|
+
* existing folder is never touched). Under a test process with no explicit home and no `FWDLOOP_CONFIG_HOME` it THROWS rather
|
|
12
|
+
* than make a folder under the real ~/.config/fwdloop (the same door as `configDoorHome`).
|
|
13
|
+
* @param {string} [home] test seam; production never passes it
|
|
14
|
+
* @returns {string}
|
|
15
|
+
*/
|
|
16
|
+
export function defaultFlowsRoot(home?: string): string;
|
|
8
17
|
/**
|
|
9
18
|
* @param {string} [home]
|
|
10
19
|
* @returns {string} `<home>/config.json`
|
package/types/launcher.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
/**
|
|
7
7
|
* @typedef {object} LauncherDeps every OS touch, injectable (a test passes all of them)
|
|
8
8
|
* @property {string} [home] the fwdloop config home (`~/.config/fwdloop`, src/config.js `configHome`); undefined = the real one
|
|
9
|
-
* @property {string} [root] the flows folder the runs line reads and `start` hands the panel (`--root`); default
|
|
9
|
+
* @property {string} [root] the flows folder the runs line reads and `start` hands the panel (`--root`); default `<config home>/flows` (`defaultFlowsRoot`)
|
|
10
10
|
* @property {number} [portStart] @property {number} [portCount]
|
|
11
11
|
* @property {number[]} [ports] an explicit port list (tests); wins over portStart/portCount
|
|
12
12
|
* @property {number} [timeoutMs] probe timeout per port
|
|
@@ -232,7 +232,7 @@ export type LauncherDeps = {
|
|
|
232
232
|
*/
|
|
233
233
|
home?: string | undefined;
|
|
234
234
|
/**
|
|
235
|
-
* the flows folder the runs line reads and `start` hands the panel (`--root`); default
|
|
235
|
+
* the flows folder the runs line reads and `start` hands the panel (`--root`); default `<config home>/flows` (`defaultFlowsRoot`)
|
|
236
236
|
*/
|
|
237
237
|
root?: string | undefined;
|
|
238
238
|
portStart?: number | undefined;
|
package/types/pagefetch.d.ts
CHANGED
|
@@ -68,7 +68,7 @@ export const PAGE_FETCH_TIMEOUT_MS: 90000;
|
|
|
68
68
|
* @typedef {{goto: (url: string, timeout?: number) => Promise<void>, waitForNetworkIdle: (o?: {idle?: number, timeout?: number}) => Promise<void>,
|
|
69
69
|
* snapshot: (o?: {mode?: string}) => Promise<string>, close: () => Promise<void>}} FetchPage the part of barebrowse's page handle the fetch uses
|
|
70
70
|
*/
|
|
71
|
-
/** the oldest barebrowse
|
|
71
|
+
/** the oldest barebrowse we accept: 0.21.0 honours CONNECT_OPTIONS (incognito, blockPrivateNetwork; an older one would drop both guards without a word); 0.24.1 tethers Chromium to its launcher, so a killed run or an Abandoned draft leaves no browser behind */
|
|
72
72
|
export const MIN_BAREBROWSE: number[];
|
|
73
73
|
/**
|
|
74
74
|
* the part of barebrowse's page handle the fetch uses
|