fwdloop 0.15.0 → 0.16.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/bin/fwdloop +106 -31
- package/package.json +2 -2
- package/src/authoring.js +23 -11
- package/src/closers.js +5 -0
- package/src/config.js +66 -4
- package/src/declaration.js +25 -1
- package/src/draft-steps.js +79 -0
- package/src/drafter.js +54 -15
- package/src/flowmodel.js +30 -0
- package/src/input-facts.js +12 -3
- package/src/keysfile.js +51 -16
- package/src/model-step.js +13 -11
- package/src/monthly.js +9 -1
- package/src/panel/author.js +81 -22
- package/src/panel/authorcard.js +25 -17
- package/src/panel/authorflows.js +33 -18
- package/src/panel/authorresume.js +9 -8
- package/src/panel/authorstart.js +11 -9
- package/src/panel/data.js +3 -3
- package/src/panel/index.html +516 -146
- package/src/panel/resume.js +3 -3
- package/src/panel/server.js +4 -3
- package/src/panel/settings.js +138 -80
- package/src/panel/spawn.js +15 -9
- package/src/provider.js +136 -178
- package/src/providershapes.js +7 -7
- package/src/runner.js +38 -22
- package/src/thinking.js +55 -0
- package/types/authoring.d.ts +11 -4
- package/types/closers.d.ts +2 -0
- package/types/config.d.ts +9 -1
- package/types/draft-steps.d.ts +14 -0
- package/types/drafter.d.ts +13 -10
- package/types/flowmodel.d.ts +16 -0
- package/types/input-facts.d.ts +6 -1
- package/types/keysfile.d.ts +23 -6
- package/types/model-step.d.ts +1 -1
- package/types/monthly.d.ts +1 -0
- package/types/panel/author.d.ts +44 -6
- package/types/panel/authorcard.d.ts +21 -8
- package/types/panel/authorflows.d.ts +29 -6
- package/types/panel/authorresume.d.ts +2 -1
- package/types/panel/authorstart.d.ts +16 -6
- package/types/panel/data.d.ts +2 -2
- package/types/panel/resume.d.ts +2 -1
- package/types/panel/server.d.ts +3 -1
- package/types/panel/settings.d.ts +3 -1
- package/types/panel/spawn.d.ts +13 -4
- package/types/provider.d.ts +94 -284
- package/types/providershapes.d.ts +3 -4
- package/types/runner.d.ts +2 -4
- package/types/thinking.d.ts +25 -0
package/types/panel/server.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ export function handleRequest(req: import("node:http").IncomingMessage, res: imp
|
|
|
19
19
|
* header). Resolves once actually listening; rejects on a bind error
|
|
20
20
|
* (including `EADDRINUSE`) with a `.port` field on the error for the
|
|
21
21
|
* caller's message.
|
|
22
|
-
* @param {{ port?: number, root: string, settings?: { home?: string, env?: Record<string,string|undefined>, fetch?: typeof fetch, now?: () => number }, resume?: { env?: Record<string,string|undefined>, bin?: string, logDir?: string, maxTries?: number, windowMs?: number, slotMs?: number }, author?: { env?: Record<string,string|undefined>, loadEnv?: () => any, bin?: string } }} opts
|
|
22
|
+
* @param {{ port?: number, root: string, settings?: { home?: string, env?: Record<string,string|undefined>, fetch?: typeof fetch, now?: () => number, openFolderSpawn?: Function, platform?: string }, resume?: { env?: Record<string,string|undefined>, bin?: string, logDir?: string, maxTries?: number, windowMs?: number, slotMs?: number }, author?: { env?: Record<string,string|undefined>, loadEnv?: () => any, bin?: string } }} opts
|
|
23
23
|
* `resume` and `author` are for tests only (a fake env/bin, a short retry window); the CLI passes none.
|
|
24
24
|
* @returns {Promise<{ server: import('node:http').Server, port: number, close: () => Promise<void> }>}
|
|
25
25
|
*/
|
|
@@ -31,6 +31,8 @@ export function createPanelServer(opts: {
|
|
|
31
31
|
env?: Record<string, string | undefined>;
|
|
32
32
|
fetch?: typeof fetch;
|
|
33
33
|
now?: () => number;
|
|
34
|
+
openFolderSpawn?: Function;
|
|
35
|
+
platform?: string;
|
|
34
36
|
};
|
|
35
37
|
resume?: {
|
|
36
38
|
env?: Record<string, string | undefined>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @param {{ home?: string, skip?: boolean, env?: Record<string,string|undefined>, fetch?: typeof fetch, now?: () => number }} cfg
|
|
2
|
+
* @param {{ home?: string, skip?: boolean, env?: Record<string,string|undefined>, fetch?: typeof fetch, now?: () => number, openFolderSpawn?: Function, platform?: string }} cfg
|
|
3
3
|
* `home` the config home (undefined = the real `~/.config/fwdloop`); `skip` true under a test process
|
|
4
4
|
* with no `FWDLOOP_CONFIG_HOME` (Settings then touches nothing); `env` the shell side (tests only);
|
|
5
5
|
* `fetch` and `now` are test seams.
|
|
@@ -10,6 +10,8 @@ export function createSettings(cfg: {
|
|
|
10
10
|
env?: Record<string, string | undefined>;
|
|
11
11
|
fetch?: typeof fetch;
|
|
12
12
|
now?: () => number;
|
|
13
|
+
openFolderSpawn?: Function;
|
|
14
|
+
platform?: string;
|
|
13
15
|
}): {
|
|
14
16
|
handle: ({ method, pathname, query, body }: {
|
|
15
17
|
method: string;
|
package/types/panel/spawn.d.ts
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The ONE spawn for the Settings "Open keys folder" button (borrowed-from: bareloop src/panel/settingsroutes.js@07c298f): the OS file manager
|
|
3
|
+
* (`xdg-open` / `open`) on a folder the server chose, argv array, no shell, detached. Settings calls it only through its injected seam.
|
|
4
|
+
* @param {string} cmd @param {string[]} args @param {import('node:child_process').SpawnOptions} o
|
|
5
|
+
*/
|
|
6
|
+
export function spawnOpener(cmd: string, args: string[], o: import("node:child_process").SpawnOptions): import("child_process").ChildProcess;
|
|
1
7
|
/**
|
|
2
8
|
* @param {{ bin: string, argv: string[], env: Record<string, string|undefined>, logPath: string }} a
|
|
3
9
|
* @returns {import('node:child_process').ChildProcess} the child (already `unref()`ed; the log fd is closed here)
|
|
@@ -23,8 +29,11 @@ export function readJsonFile(dir: string, rel: string): any;
|
|
|
23
29
|
*/
|
|
24
30
|
export function childRunning(dir: string): boolean;
|
|
25
31
|
/**
|
|
26
|
-
* The provider key VALUES
|
|
27
|
-
* spawn env (POC (a), M4d wiring rule), so the list can never differ from what the child was given.
|
|
28
|
-
* @param {Record<string, string|undefined
|
|
32
|
+
* The provider key VALUES of a keys load (`keysForDoor`) — the scrub list. The env that holds them is the SAME object that is the child's
|
|
33
|
+
* spawn env (POC (a), M4d wiring rule), and the names are the load's own `keyNames`, so the list can never differ from what the child was given.
|
|
34
|
+
* @param {{ env: Record<string, string|undefined>, keyNames?: string[] }} loaded
|
|
29
35
|
*/
|
|
30
|
-
export function providerKeys(
|
|
36
|
+
export function providerKeys(loaded: {
|
|
37
|
+
env: Record<string, string | undefined>;
|
|
38
|
+
keyNames?: string[];
|
|
39
|
+
}): string[];
|
package/types/provider.d.ts
CHANGED
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* THE one lookup of a
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* address while the shape is the slot's code shape, else that shape's vendor address ('' = bare-agent's own).
|
|
7
|
-
* Unknown slot throws. `config` is already-read config (see `readPriceConfig`); no I/O here.
|
|
2
|
+
* THE one lookup of a row's API shape, address and legacy-token tick (M4d amendment 6). A row IS its key's env name, so the slot name and the
|
|
3
|
+
* env var are the same word. What a row holds is only what the person typed in Settings (`config.providers[slot]`): nothing is built
|
|
4
|
+
* in, so a row nobody typed an address for has `baseUrl: ''` and cannot run or list models. Which model a call USES is decided by
|
|
5
|
+
* `resolveUsableModel`. An invalid name throws. `config` is already-read config (see `readPriceConfig`); no I/O here.
|
|
8
6
|
* @param {string} slotName
|
|
9
7
|
* @param {{ config?: Record<string, any> }} [opts]
|
|
10
|
-
* @returns {{ slot: string, envVar: string, legacyMaxTokens: boolean,
|
|
11
|
-
* model: string, shape: string, baseUrl: string,
|
|
12
|
-
* defaults: { model: string, shape: string, baseUrl: string } }}
|
|
8
|
+
* @returns {{ slot: string, envVar: string, legacyMaxTokens: boolean, shape: string, baseUrl: string }}
|
|
13
9
|
*/
|
|
14
10
|
export function resolveSlot(slotName: string, { config }?: {
|
|
15
11
|
config?: Record<string, any>;
|
|
@@ -17,134 +13,95 @@ export function resolveSlot(slotName: string, { config }?: {
|
|
|
17
13
|
slot: string;
|
|
18
14
|
envVar: string;
|
|
19
15
|
legacyMaxTokens: boolean;
|
|
20
|
-
model: string;
|
|
21
16
|
shape: string;
|
|
22
17
|
baseUrl: string;
|
|
23
|
-
defaults: {
|
|
24
|
-
model: string;
|
|
25
|
-
shape: string;
|
|
26
|
-
baseUrl: string;
|
|
27
|
-
};
|
|
28
18
|
};
|
|
29
19
|
/**
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
* @param {string
|
|
34
|
-
* @
|
|
20
|
+
* A row's saved model lines (`config.models[slot]`) as Settings shows them; none saved = no lines. Nothing is built in
|
|
21
|
+
* and nothing is migrated: a line exists only because a person typed or ticked it.
|
|
22
|
+
* @param {string} slot
|
|
23
|
+
* @param {Record<string, any>} [config]
|
|
24
|
+
* @returns {Array<{ model: string, use: boolean, inPerM?: number, outPerM?: number }>}
|
|
35
25
|
*/
|
|
36
|
-
export function
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
source: string;
|
|
62
|
-
};
|
|
63
|
-
'Qwen/Qwen3.8-27B': {
|
|
64
|
-
in: number;
|
|
65
|
-
out: number;
|
|
66
|
-
source: string;
|
|
67
|
-
};
|
|
68
|
-
'openai/gpt-oss-120b': {
|
|
69
|
-
in: number;
|
|
70
|
-
out: number;
|
|
71
|
-
source: string;
|
|
72
|
-
};
|
|
73
|
-
'nvidia/NVIDIA-Nemotron-3-Super-120B-A12B-NVFP4': {
|
|
74
|
-
in: number;
|
|
75
|
-
out: number;
|
|
76
|
-
source: string;
|
|
77
|
-
};
|
|
78
|
-
'syn:large:text': {
|
|
79
|
-
in: number;
|
|
80
|
-
out: number;
|
|
81
|
-
source: string;
|
|
82
|
-
};
|
|
83
|
-
'syn:small:text': {
|
|
84
|
-
in: number;
|
|
85
|
-
out: number;
|
|
86
|
-
source: string;
|
|
87
|
-
};
|
|
88
|
-
'deepseek-v4-flash': {
|
|
89
|
-
in: number;
|
|
90
|
-
out: number;
|
|
91
|
-
source: string;
|
|
92
|
-
};
|
|
93
|
-
'deepseek-flash': {
|
|
94
|
-
in: number;
|
|
95
|
-
out: number;
|
|
96
|
-
source: string;
|
|
97
|
-
};
|
|
98
|
-
'deepseek-v4-pro': {
|
|
99
|
-
in: number;
|
|
100
|
-
out: number;
|
|
101
|
-
source: string;
|
|
102
|
-
};
|
|
26
|
+
export function effectiveModels(slot: string, config?: Record<string, any>): Array<{
|
|
27
|
+
model: string;
|
|
28
|
+
use: boolean;
|
|
29
|
+
inPerM?: number;
|
|
30
|
+
outPerM?: number;
|
|
31
|
+
}>;
|
|
32
|
+
/**
|
|
33
|
+
* Every ticked, priced line of the given rows, in row order: what Chat's model menu offers and what a run may use (M4d amendment 6
|
|
34
|
+
* item 6). `rows` limits it to providers that still have a key (a model whose key is gone cannot run).
|
|
35
|
+
* @param {Record<string, any>} config @param {string[]} rows key names
|
|
36
|
+
* @returns {{ slot: string, model: string, label: string }[]}
|
|
37
|
+
*/
|
|
38
|
+
export function tickedLines(config: Record<string, any>, rows: string[]): {
|
|
39
|
+
slot: string;
|
|
40
|
+
model: string;
|
|
41
|
+
label: string;
|
|
42
|
+
}[];
|
|
43
|
+
/**
|
|
44
|
+
* The ticked, priced line a person names by model id (the command line): `--model <id>`, and `--provider <KEY>` when two keys tick the same id.
|
|
45
|
+
* Reads only the lines Settings holds. @param {Record<string, any>} config @param {{ model?: string, provider?: string }} [named]
|
|
46
|
+
* @returns {{ ok: true, slot: string, model: string } | { ok: false, say: string }}
|
|
47
|
+
*/
|
|
48
|
+
export function pickTicked(config: Record<string, any>, { model, provider }?: {
|
|
49
|
+
model?: string;
|
|
50
|
+
provider?: string;
|
|
103
51
|
}): {
|
|
104
|
-
|
|
105
|
-
|
|
52
|
+
ok: true;
|
|
53
|
+
slot: string;
|
|
54
|
+
model: string;
|
|
55
|
+
} | {
|
|
56
|
+
ok: false;
|
|
57
|
+
say: string;
|
|
106
58
|
};
|
|
107
59
|
/**
|
|
108
|
-
* THE one
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
60
|
+
* THE one decision of "usable model" (M4d amendments 5 and 6): a model is usable only if it is ticked in Settings with both prices,
|
|
61
|
+
* under the named provider. Every model call - the drafter, a run, resume / continue, the command line, the panel - asks this and
|
|
62
|
+
* nothing else; no model name, price or switch lives in code. Returns the model, its provider and its prices (USD per 1M, and per 1K
|
|
63
|
+
* for the Loop; 0 / 0 is a chosen price), or a plain refusal in `say`.
|
|
64
|
+
* No model named: "Tick a model in Settings > Providers with both prices first." Pure: `config` is already-read config, no I/O.
|
|
113
65
|
*
|
|
114
|
-
* @param {string}
|
|
115
|
-
* @param {{
|
|
66
|
+
* @param {string} slotName
|
|
67
|
+
* @param {{ config?: Record<string, any>, model?: string }} [opts]
|
|
116
68
|
* @returns {{
|
|
117
|
-
*
|
|
118
|
-
*
|
|
119
|
-
* source: { in: '
|
|
120
|
-
*
|
|
121
|
-
* }}
|
|
69
|
+
* ok: true, slot: string, model: string,
|
|
70
|
+
* rates: { in: number, out: number, cacheReadMult: number },
|
|
71
|
+
* prices: { perM: { inPerM: number, cachedInPerM: number, outPerM: number }, source: { in: 'model', cachedIn: 'input', out: 'model' } },
|
|
72
|
+
* } | { ok: false, say: string }}
|
|
122
73
|
*/
|
|
123
|
-
export function
|
|
124
|
-
slot?: string;
|
|
74
|
+
export function resolveUsableModel(slotName: string, { config, model }?: {
|
|
125
75
|
config?: Record<string, any>;
|
|
126
|
-
|
|
76
|
+
model?: string;
|
|
127
77
|
}): {
|
|
78
|
+
ok: true;
|
|
79
|
+
slot: string;
|
|
80
|
+
model: string;
|
|
128
81
|
rates: {
|
|
129
82
|
in: number;
|
|
130
83
|
out: number;
|
|
131
|
-
cacheReadMult
|
|
84
|
+
cacheReadMult: number;
|
|
132
85
|
};
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
86
|
+
prices: {
|
|
87
|
+
perM: {
|
|
88
|
+
inPerM: number;
|
|
89
|
+
cachedInPerM: number;
|
|
90
|
+
outPerM: number;
|
|
91
|
+
};
|
|
92
|
+
source: {
|
|
93
|
+
in: "model";
|
|
94
|
+
cachedIn: "input";
|
|
95
|
+
out: "model";
|
|
96
|
+
};
|
|
137
97
|
};
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
out: "settings" | "table" | "ceiling";
|
|
142
|
-
};
|
|
143
|
-
suffix: string | null;
|
|
98
|
+
} | {
|
|
99
|
+
ok: false;
|
|
100
|
+
say: string;
|
|
144
101
|
};
|
|
145
102
|
/**
|
|
146
103
|
* The `price` object a spend row records: the per-1M numbers the call was booked at and where each
|
|
147
|
-
* came from. From a `
|
|
104
|
+
* came from. From a `resolveUsableModel` result's `prices`; or from INJECTED rates (tests) with source "injected".
|
|
148
105
|
* @param {{ perM: any, source: any }|null|undefined} prices
|
|
149
106
|
* @param {{ in: number, out: number, cacheReadMult?: number }|null|undefined} [injectedRates]
|
|
150
107
|
*/
|
|
@@ -164,83 +121,22 @@ export function priceRecord(prices: {
|
|
|
164
121
|
*/
|
|
165
122
|
export function readPriceConfig(home?: string): Record<string, any>;
|
|
166
123
|
/**
|
|
167
|
-
* The
|
|
168
|
-
*
|
|
169
|
-
*
|
|
170
|
-
* `resolvePrices` result, e.g. from `makeProvider`) makes the cap check use the
|
|
171
|
-
* SAME price the round is booked at.
|
|
124
|
+
* The money hold (USD) of one round: the picked model's OWN Settings prices (`rates`, per 1K tokens, from
|
|
125
|
+
* `resolveUsableModel`) times the two token bounds above. Not a table, not a fallback.
|
|
126
|
+
* @param {{ in: number, out: number }} rates
|
|
172
127
|
*/
|
|
173
|
-
export function ceilingCostUsd(
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
source: string;
|
|
178
|
-
};
|
|
179
|
-
'moonshotai/Kimi-K3': {
|
|
180
|
-
in: number;
|
|
181
|
-
out: number;
|
|
182
|
-
source: string;
|
|
183
|
-
};
|
|
184
|
-
'zai-org/GLM-5.3-Flash': {
|
|
185
|
-
in: number;
|
|
186
|
-
out: number;
|
|
187
|
-
source: string;
|
|
188
|
-
};
|
|
189
|
-
'zai-org/GLM-4.7-Flash': {
|
|
190
|
-
in: number;
|
|
191
|
-
out: number;
|
|
192
|
-
source: string;
|
|
193
|
-
};
|
|
194
|
-
'Qwen/Qwen3.8-27B': {
|
|
195
|
-
in: number;
|
|
196
|
-
out: number;
|
|
197
|
-
source: string;
|
|
198
|
-
};
|
|
199
|
-
'openai/gpt-oss-120b': {
|
|
200
|
-
in: number;
|
|
201
|
-
out: number;
|
|
202
|
-
source: string;
|
|
203
|
-
};
|
|
204
|
-
'nvidia/NVIDIA-Nemotron-3-Super-120B-A12B-NVFP4': {
|
|
205
|
-
in: number;
|
|
206
|
-
out: number;
|
|
207
|
-
source: string;
|
|
208
|
-
};
|
|
209
|
-
'syn:large:text': {
|
|
210
|
-
in: number;
|
|
211
|
-
out: number;
|
|
212
|
-
source: string;
|
|
213
|
-
};
|
|
214
|
-
'syn:small:text': {
|
|
215
|
-
in: number;
|
|
216
|
-
out: number;
|
|
217
|
-
source: string;
|
|
218
|
-
};
|
|
219
|
-
'deepseek-v4-flash': {
|
|
220
|
-
in: number;
|
|
221
|
-
out: number;
|
|
222
|
-
source: string;
|
|
223
|
-
};
|
|
224
|
-
'deepseek-flash': {
|
|
225
|
-
in: number;
|
|
226
|
-
out: number;
|
|
227
|
-
source: string;
|
|
228
|
-
};
|
|
229
|
-
'deepseek-v4-pro': {
|
|
230
|
-
in: number;
|
|
231
|
-
out: number;
|
|
232
|
-
source: string;
|
|
233
|
-
};
|
|
234
|
-
}, opts?: {}): number;
|
|
128
|
+
export function ceilingCostUsd(rates: {
|
|
129
|
+
in: number;
|
|
130
|
+
out: number;
|
|
131
|
+
}): number;
|
|
235
132
|
/**
|
|
236
133
|
* Compare the model asked for against the model actually served.
|
|
237
134
|
* `match` identical; `prefix` identical once a routing prefix is stripped;
|
|
238
|
-
* `alias` a declared `syn:` alias resolving to a concrete model (expected);
|
|
239
135
|
* `substituted` a concrete request served by a DIFFERENT concrete model
|
|
240
136
|
* (the one that matters — the signed hash records the request, not what
|
|
241
137
|
* ran); `unreported` the provider told us nothing.
|
|
242
138
|
*/
|
|
243
|
-
export function classifyModelId(requested: any, returned: any): "unreported" | "match" | "prefix" | "
|
|
139
|
+
export function classifyModelId(requested: any, returned: any): "unreported" | "match" | "prefix" | "substituted";
|
|
244
140
|
/**
|
|
245
141
|
* Sum every round of one model attempt into one meter. Money honesty in the
|
|
246
142
|
* strict direction: if ANY round has no priced cost, `costUsd` is `null` —
|
|
@@ -295,7 +191,7 @@ export function readSpendRows(path: string): any[];
|
|
|
295
191
|
export function assertUnderGlobalCap(path: any, capUsd: any): number;
|
|
296
192
|
/**
|
|
297
193
|
* $0 preflight before any draft round and before any ledger write: the key
|
|
298
|
-
* env var
|
|
194
|
+
* env var named `slotName` must be set, non-empty, and free of any
|
|
299
195
|
* whitespace/control character (F26, 2026-09-21: a two-line `pass` entry
|
|
300
196
|
* exported a key with a trailing newline — still truthy, so a bare
|
|
301
197
|
* `if (!apiKey)` never caught it). Never throws — `{ ok:true }` or
|
|
@@ -312,9 +208,9 @@ export function checkKeyPreflight(slotName: string, env?: Record<string, string
|
|
|
312
208
|
message?: undefined;
|
|
313
209
|
};
|
|
314
210
|
/**
|
|
315
|
-
* Build a provider for the given
|
|
316
|
-
* unknown
|
|
317
|
-
*
|
|
211
|
+
* Build a provider for the given row (the name of a key). Throws (never defaults) on an
|
|
212
|
+
* unknown name, a row with no Base URL (typed in Settings), a missing/bad env key, or a model that is not usable (`resolveUsableModel`: ticked in Settings with
|
|
213
|
+
* both prices - the message is its plain sentence). Returns `{ provider, rates, modelId, slot, prices }`.
|
|
318
214
|
*
|
|
319
215
|
* `timeoutMs`/`deadlineMs` bound a silent socket (BA-18 idle) and a
|
|
320
216
|
* zombie-stream total wall clock (BA-19), respectively — see
|
|
@@ -322,17 +218,15 @@ export function checkKeyPreflight(slotName: string, env?: Record<string, string
|
|
|
322
218
|
* values this project uses.
|
|
323
219
|
*
|
|
324
220
|
* @param {string} slotName
|
|
325
|
-
* @param {{ model?: string, timeoutMs?: number, deadlineMs?: number,
|
|
221
|
+
* @param {{ model?: string, timeoutMs?: number, deadlineMs?: number, env?: Record<string,string|undefined>, configHome?: string }} [options]
|
|
326
222
|
* `configHome` (a test) is where `config.json` prices are read; default: the door's home (`readPriceConfig`).
|
|
327
223
|
* `env` (M4d: the merged shell+keys-file env; default process.env) is where the key is read.
|
|
328
|
-
*
|
|
329
|
-
* @returns {{ provider: any, rates: {in:number, out:number, cacheReadMult?:number}, modelId: string, suffix: string|null, slot: string, prices: ReturnType<typeof resolvePrices> }}
|
|
224
|
+
* @returns {{ provider: any, rates: {in:number, out:number, cacheReadMult?:number}, modelId: string, slot: string, prices: { perM: any, source: any } }}
|
|
330
225
|
*/
|
|
331
226
|
export function makeProvider(slotName: string, options?: {
|
|
332
227
|
model?: string;
|
|
333
228
|
timeoutMs?: number;
|
|
334
229
|
deadlineMs?: number;
|
|
335
|
-
thinking?: object | null;
|
|
336
230
|
env?: Record<string, string | undefined>;
|
|
337
231
|
configHome?: string;
|
|
338
232
|
}): {
|
|
@@ -343,99 +237,15 @@ export function makeProvider(slotName: string, options?: {
|
|
|
343
237
|
cacheReadMult?: number;
|
|
344
238
|
};
|
|
345
239
|
modelId: string;
|
|
346
|
-
suffix: string | null;
|
|
347
240
|
slot: string;
|
|
348
|
-
prices:
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
* var elsewhere. `deepseek` is the baseline (F12); `synthetic` is second. */
|
|
352
|
-
export const PROVIDER_SLOTS: Readonly<{
|
|
353
|
-
synthetic: Readonly<{
|
|
354
|
-
baseUrl: "https://api.synthetic.new/openai/v1";
|
|
355
|
-
envVar: "SYNTHETIC_API_KEY";
|
|
356
|
-
defaultModel: "hf:Qwen/Qwen3.8-27B";
|
|
357
|
-
shape: "openai-api";
|
|
358
|
-
legacyMaxTokens: false;
|
|
359
|
-
}>;
|
|
360
|
-
deepseek: Readonly<{
|
|
361
|
-
baseUrl: "https://api.deepseek.com";
|
|
362
|
-
envVar: "DEEPSEEK_API_KEY";
|
|
363
|
-
defaultModel: "deepseek-flash";
|
|
364
|
-
shape: "openai-api";
|
|
365
|
-
legacyMaxTokens: true;
|
|
366
|
-
}>;
|
|
367
|
-
}>;
|
|
368
|
-
/**
|
|
369
|
-
* List-rate ceilings (USD/1K tokens), hand-entered — see
|
|
370
|
-
* poc/m0/spend.mjs@76a3607 for sourcing notes per row. This table is the DEFAULT
|
|
371
|
-
* price: a price set in Settings (`~/.config/fwdloop/config.json` `prices`, per
|
|
372
|
-
* provider slot) wins over a row here, per field, through `resolvePrices` below —
|
|
373
|
-
* the one lookup every model call is booked and cap-checked by (M4d, signed
|
|
374
|
-
* 2026-10-05; that REPLACES the 2026-09-21 "edit a row here, never a runtime
|
|
375
|
-
* flag" ruling). Cached input is priced as input
|
|
376
|
-
* (M4d amendment 2): a row has no cache rate.
|
|
377
|
-
*/
|
|
378
|
-
export const RATES_BY_SUFFIX: {
|
|
379
|
-
'zai-org/GLM-5.2': {
|
|
380
|
-
in: number;
|
|
381
|
-
out: number;
|
|
382
|
-
source: string;
|
|
383
|
-
};
|
|
384
|
-
'moonshotai/Kimi-K3': {
|
|
385
|
-
in: number;
|
|
386
|
-
out: number;
|
|
387
|
-
source: string;
|
|
388
|
-
};
|
|
389
|
-
'zai-org/GLM-5.3-Flash': {
|
|
390
|
-
in: number;
|
|
391
|
-
out: number;
|
|
392
|
-
source: string;
|
|
393
|
-
};
|
|
394
|
-
'zai-org/GLM-4.7-Flash': {
|
|
395
|
-
in: number;
|
|
396
|
-
out: number;
|
|
397
|
-
source: string;
|
|
398
|
-
};
|
|
399
|
-
'Qwen/Qwen3.8-27B': {
|
|
400
|
-
in: number;
|
|
401
|
-
out: number;
|
|
402
|
-
source: string;
|
|
403
|
-
};
|
|
404
|
-
'openai/gpt-oss-120b': {
|
|
405
|
-
in: number;
|
|
406
|
-
out: number;
|
|
407
|
-
source: string;
|
|
408
|
-
};
|
|
409
|
-
'nvidia/NVIDIA-Nemotron-3-Super-120B-A12B-NVFP4': {
|
|
410
|
-
in: number;
|
|
411
|
-
out: number;
|
|
412
|
-
source: string;
|
|
413
|
-
};
|
|
414
|
-
'syn:large:text': {
|
|
415
|
-
in: number;
|
|
416
|
-
out: number;
|
|
417
|
-
source: string;
|
|
418
|
-
};
|
|
419
|
-
'syn:small:text': {
|
|
420
|
-
in: number;
|
|
421
|
-
out: number;
|
|
422
|
-
source: string;
|
|
423
|
-
};
|
|
424
|
-
'deepseek-v4-flash': {
|
|
425
|
-
in: number;
|
|
426
|
-
out: number;
|
|
427
|
-
source: string;
|
|
428
|
-
};
|
|
429
|
-
'deepseek-flash': {
|
|
430
|
-
in: number;
|
|
431
|
-
out: number;
|
|
432
|
-
source: string;
|
|
433
|
-
};
|
|
434
|
-
'deepseek-v4-pro': {
|
|
435
|
-
in: number;
|
|
436
|
-
out: number;
|
|
437
|
-
source: string;
|
|
241
|
+
prices: {
|
|
242
|
+
perM: any;
|
|
243
|
+
source: any;
|
|
438
244
|
};
|
|
439
245
|
};
|
|
246
|
+
export function isKeyName(v: any): boolean;
|
|
440
247
|
export const CEILING_INPUT_TOKENS: 32000;
|
|
441
248
|
export const CEILING_OUTPUT_TOKENS: 16000;
|
|
249
|
+
/** A model that is not usable (`resolveUsableModel`): its message is the plain sentence, shown as it is (no "key:" or "config:" prefix). */
|
|
250
|
+
export class ModelRefusal extends Error {
|
|
251
|
+
}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `id` is the value saved in config.json
|
|
3
|
-
*
|
|
4
|
-
* @type {readonly {id: string, label: string
|
|
2
|
+
* `id` is the value saved in config.json. A shape is a wire protocol, never a place: no web address lives here
|
|
3
|
+
* (M4d amendment 6 item 2) - each row's Base URL is typed in Settings.
|
|
4
|
+
* @type {readonly {id: string, label: string}[]}
|
|
5
5
|
*/
|
|
6
6
|
export const SHAPES: readonly {
|
|
7
7
|
id: string;
|
|
8
8
|
label: string;
|
|
9
|
-
defaultUrl: string;
|
|
10
9
|
}[];
|
|
11
10
|
export const SHAPE_IDS: readonly string[];
|
package/types/runner.d.ts
CHANGED
|
@@ -29,8 +29,6 @@ export function readHaltRecord(runDir: string): {
|
|
|
29
29
|
missing?: undefined;
|
|
30
30
|
red?: undefined;
|
|
31
31
|
};
|
|
32
|
-
/** @param {string|null|undefined} modelId */
|
|
33
|
-
export function resolveCeilingUsd(modelId: string | null | undefined): any;
|
|
34
32
|
/** @param {{goal:string, primitives?:string[], reads?:Record<string,any>, gap?:string|null}} opts */
|
|
35
33
|
export function buildExecutorContext(opts: {
|
|
36
34
|
goal: string;
|
|
@@ -164,7 +162,7 @@ export function readArtifact(runDir: any, id: any): any;
|
|
|
164
162
|
* @param {string[]} [opts.primitiveReds] - `resolvePrimitives`'s own `reds` (e.g. bareguard refusing a symlinked file scope); any entry refuses the run at $0 like an unwired verb, before the run dir exists.
|
|
165
163
|
* @param {() => string} [opts.clock] - returns the current ISO timestamp; defaults to the wall clock.
|
|
166
164
|
* @param {string} opts.businessDate - the run's explicit "as of today", never the wall clock.
|
|
167
|
-
* @param {number} [opts.ceilingUsd] - per-attempt ceiling override;
|
|
165
|
+
* @param {number} [opts.ceilingUsd] - per-attempt ceiling override; the model's hold from Settings prices (`ceilingCostUsd`); absent = no hold.
|
|
168
166
|
* @param {string|null} [opts.initialGap] - M3 scope item 7 (rerun as a fresh
|
|
169
167
|
* run): a human's rerun reason, carried as the FIRST ordinary step's
|
|
170
168
|
* starting gap. Never used by a plain `runFlow` call outside `resumeRun`'s
|
|
@@ -389,7 +387,7 @@ export const MAX_ATTEMPTS: 4;
|
|
|
389
387
|
* (audit.jsonl) stay the source of truth; this tolerance only absorbs
|
|
390
388
|
* summation-order noise, not a real gap. A billionth of a dollar is ~6
|
|
391
389
|
* orders of magnitude below the cheapest real round (audit rows here run
|
|
392
|
-
*
|
|
390
|
+
* a few hundredths of a cent and up), so nothing a real tamper produces can hide inside it. */
|
|
393
391
|
export const SPEND_TOLERANCE_USD: 1e-9;
|
|
394
392
|
export const STOP_FILE: "stop.request";
|
|
395
393
|
export const HALT_FILE: "halt.json";
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {string} shape the row's API shape @param {string} model
|
|
3
|
+
* @param {{ impl?: unknown, baseUrl?: string }} [opts] `impl` is a test seam: the function standing in for bareagent's export (default: the installed export); `baseUrl` is the row's Base URL
|
|
4
|
+
* @returns {true|false|'unverified'}
|
|
5
|
+
*/
|
|
6
|
+
export function thinkingSupport(shape: string, model: string, { impl, baseUrl }?: {
|
|
7
|
+
impl?: unknown;
|
|
8
|
+
baseUrl?: string;
|
|
9
|
+
}): true | false | "unverified";
|
|
10
|
+
/**
|
|
11
|
+
* The worst of a draft's per-round statuses; `null` when no round carried one.
|
|
12
|
+
* @param {Array<string|null|undefined>} statuses @returns {string|null}
|
|
13
|
+
*/
|
|
14
|
+
export function worstThinkingStatus(statuses: Array<string | null | undefined>): string | null;
|
|
15
|
+
/**
|
|
16
|
+
* The ONE place the thinking words live (M4d am11: bareloop's words). The ✗ line shown in the Chat list when thinking did not go as asked.
|
|
17
|
+
* The words are fixed strings, never built from what was asked: they say what the model did (bareloop's code-owned words).
|
|
18
|
+
* 'applied' (and no status) says nothing here (the list's own "thinking on ✓" / "thinking off ✓" covers it).
|
|
19
|
+
* @param {string|null} status @returns {string|null}
|
|
20
|
+
*/
|
|
21
|
+
export function thinkingSay(status: string | null): string | null;
|
|
22
|
+
/** The sentence under a greyed "Thinking on" box (amendment 7 item 2). */
|
|
23
|
+
export const THINKING_FIXED_SAY: "can't change this for this model";
|
|
24
|
+
/** The note beside the Chat "Thinking on" box, before any draft, for a model bareagent has not checked (M4d am11 item 2). */
|
|
25
|
+
export const THINKING_UNVERIFIED_SAY: "thinking off (not verified for this model)";
|