fwdloop 0.15.0 → 0.17.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 +2 -0
- package/bin/fwdloop +113 -36
- package/package.json +2 -2
- package/src/authoring.js +27 -15
- package/src/catalogue.json +9 -3
- package/src/closers.js +5 -0
- package/src/config.js +66 -4
- package/src/ctx-tools.js +245 -0
- package/src/declaration.js +25 -1
- package/src/draft-steps.js +138 -0
- package/src/drafter.js +81 -18
- package/src/draftspend.js +109 -3
- package/src/flowmodel.js +30 -0
- package/src/input-facts.js +12 -3
- package/src/keysfile.js +51 -16
- package/src/liveness.js +34 -10
- package/src/model-step.js +13 -11
- package/src/monthly.js +9 -1
- package/src/panel/author.js +170 -43
- package/src/panel/authorcard.js +32 -20
- package/src/panel/authorflows.js +34 -19
- package/src/panel/authorresume.js +11 -9
- package/src/panel/authorstart.js +11 -9
- package/src/panel/authorvalues.js +5 -3
- package/src/panel/data.js +20 -8
- package/src/panel/index.html +584 -182
- package/src/panel/resume.js +3 -3
- package/src/panel/server.js +12 -6
- package/src/panel/settings.js +138 -80
- package/src/panel/spawn.js +15 -9
- package/src/plain-checks.js +51 -0
- package/src/primitives.js +34 -3
- package/src/provider.js +148 -181
- package/src/providershapes.js +7 -7
- package/src/run-store.js +47 -0
- package/src/runner.js +40 -22
- package/src/setup.js +3 -0
- package/src/thinking.js +55 -0
- package/src/version.js +13 -0
- package/types/authoring.d.ts +11 -6
- package/types/closers.d.ts +2 -0
- package/types/config.d.ts +9 -1
- package/types/ctx-tools.d.ts +18 -0
- package/types/draft-steps.d.ts +47 -0
- package/types/drafter.d.ts +15 -12
- package/types/draftspend.d.ts +56 -0
- package/types/flowmodel.d.ts +16 -0
- package/types/input-facts.d.ts +6 -1
- package/types/keysfile.d.ts +23 -6
- package/types/liveness.d.ts +7 -1
- package/types/model-step.d.ts +1 -1
- package/types/monthly.d.ts +1 -0
- package/types/panel/author.d.ts +47 -9
- package/types/panel/authorcard.d.ts +33 -10
- package/types/panel/authorflows.d.ts +32 -9
- package/types/panel/authorresume.d.ts +2 -1
- package/types/panel/authorstart.d.ts +16 -6
- package/types/panel/authorvalues.d.ts +3 -1
- package/types/panel/data.d.ts +2 -2
- package/types/panel/resume.d.ts +2 -1
- package/types/panel/server.d.ts +6 -2
- package/types/panel/settings.d.ts +3 -1
- package/types/panel/spawn.d.ts +13 -4
- package/types/plain-checks.d.ts +22 -0
- package/types/primitives.d.ts +0 -6
- package/types/provider.d.ts +100 -284
- package/types/providershapes.d.ts +3 -4
- package/types/run-store.d.ts +11 -0
- package/types/runner.d.ts +2 -4
- package/types/setup.d.ts +8 -0
- package/types/thinking.d.ts +25 -0
- package/types/version.d.ts +2 -0
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` —
|
|
@@ -268,6 +164,9 @@ export function sumMeterings(events: any): {
|
|
|
268
164
|
/** Append one spend row, stamping `modelMatch` — the one writer for
|
|
269
165
|
* spend.jsonl. Warns (never throws) on a `substituted` model. */
|
|
270
166
|
export function appendSpendRow(path: any, row: any): void;
|
|
167
|
+
export function rowCeilingUsd(row: any): number;
|
|
168
|
+
/** How many calls of an incomplete row were never metered (at least one). @param {any} row */
|
|
169
|
+
export function unmeteredCalls(row: any): number;
|
|
271
170
|
/**
|
|
272
171
|
* The one rule for what a spend row costs: `usd` and whether it is `complete`. An incomplete row (a call
|
|
273
172
|
* died unmetered, or a round was left unpriced) counts its priced floor PLUS one ceiling per unmetered call
|
|
@@ -295,7 +194,7 @@ export function readSpendRows(path: string): any[];
|
|
|
295
194
|
export function assertUnderGlobalCap(path: any, capUsd: any): number;
|
|
296
195
|
/**
|
|
297
196
|
* $0 preflight before any draft round and before any ledger write: the key
|
|
298
|
-
* env var
|
|
197
|
+
* env var named `slotName` must be set, non-empty, and free of any
|
|
299
198
|
* whitespace/control character (F26, 2026-09-21: a two-line `pass` entry
|
|
300
199
|
* exported a key with a trailing newline — still truthy, so a bare
|
|
301
200
|
* `if (!apiKey)` never caught it). Never throws — `{ ok:true }` or
|
|
@@ -312,9 +211,9 @@ export function checkKeyPreflight(slotName: string, env?: Record<string, string
|
|
|
312
211
|
message?: undefined;
|
|
313
212
|
};
|
|
314
213
|
/**
|
|
315
|
-
* Build a provider for the given
|
|
316
|
-
* unknown
|
|
317
|
-
*
|
|
214
|
+
* Build a provider for the given row (the name of a key). Throws (never defaults) on an
|
|
215
|
+
* 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
|
|
216
|
+
* both prices - the message is its plain sentence). Returns `{ provider, rates, modelId, slot, prices }`.
|
|
318
217
|
*
|
|
319
218
|
* `timeoutMs`/`deadlineMs` bound a silent socket (BA-18 idle) and a
|
|
320
219
|
* zombie-stream total wall clock (BA-19), respectively — see
|
|
@@ -322,17 +221,15 @@ export function checkKeyPreflight(slotName: string, env?: Record<string, string
|
|
|
322
221
|
* values this project uses.
|
|
323
222
|
*
|
|
324
223
|
* @param {string} slotName
|
|
325
|
-
* @param {{ model?: string, timeoutMs?: number, deadlineMs?: number,
|
|
224
|
+
* @param {{ model?: string, timeoutMs?: number, deadlineMs?: number, env?: Record<string,string|undefined>, configHome?: string }} [options]
|
|
326
225
|
* `configHome` (a test) is where `config.json` prices are read; default: the door's home (`readPriceConfig`).
|
|
327
226
|
* `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> }}
|
|
227
|
+
* @returns {{ provider: any, rates: {in:number, out:number, cacheReadMult?:number}, modelId: string, slot: string, prices: { perM: any, source: any } }}
|
|
330
228
|
*/
|
|
331
229
|
export function makeProvider(slotName: string, options?: {
|
|
332
230
|
model?: string;
|
|
333
231
|
timeoutMs?: number;
|
|
334
232
|
deadlineMs?: number;
|
|
335
|
-
thinking?: object | null;
|
|
336
233
|
env?: Record<string, string | undefined>;
|
|
337
234
|
configHome?: string;
|
|
338
235
|
}): {
|
|
@@ -343,99 +240,18 @@ export function makeProvider(slotName: string, options?: {
|
|
|
343
240
|
cacheReadMult?: number;
|
|
344
241
|
};
|
|
345
242
|
modelId: string;
|
|
346
|
-
suffix: string | null;
|
|
347
243
|
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;
|
|
244
|
+
prices: {
|
|
245
|
+
perM: any;
|
|
246
|
+
source: any;
|
|
438
247
|
};
|
|
439
248
|
};
|
|
249
|
+
export { isKeyName };
|
|
250
|
+
/** The sentence part every refusal of a non-key name carries, so the rule is named wherever it is refused. */
|
|
251
|
+
export const KEY_NAME_RULE_SAY: "a key name is written in capitals and ends in _KEY";
|
|
440
252
|
export const CEILING_INPUT_TOKENS: 32000;
|
|
441
253
|
export const CEILING_OUTPUT_TOKENS: 16000;
|
|
254
|
+
/** A model that is not usable (`resolveUsableModel`): its message is the plain sentence, shown as it is (no "key:" or "config:" prefix). */
|
|
255
|
+
export class ModelRefusal extends Error {
|
|
256
|
+
}
|
|
257
|
+
import { isKeyName } from './keysfile.js';
|
|
@@ -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[];
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** The folder holding THIS run's store. A different run dir is a different folder.
|
|
2
|
+
* @param {string} runDir */
|
|
3
|
+
export function runStoreDir(runDir: string): string;
|
|
4
|
+
/** Open this run's store, run `fn(lc)`, close it. `root` is the run dir: litectx indexes
|
|
5
|
+
* only its own extensions (.md .js .py ...) there, never the run's json/jsonl records.
|
|
6
|
+
* @template T @param {string} runDir @param {(lc: any) => Promise<T>|T} fn @returns {Promise<T>} */
|
|
7
|
+
export function withRunStore<T>(runDir: string, fn: (lc: any) => Promise<T> | T): Promise<T>;
|
|
8
|
+
/** A run STARTS with an empty store, never an inherited one: a run id can be reused (the next id is max+1, so deleting the last run
|
|
9
|
+
* folder hands its id to the next run) and the store sits beside the run folder, not in it. Called by the one place a fresh run
|
|
10
|
+
* begins (`runFlow`); resume and continue keep the run's own store. @param {string} runDir */
|
|
11
|
+
export function resetRunStore(runDir: string): void;
|
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";
|
package/types/setup.d.ts
CHANGED
|
@@ -11,6 +11,14 @@ export function buildSetupRows({ sessionDir, planDir, hash, signedBy, signedAt,
|
|
|
11
11
|
signedAt: string;
|
|
12
12
|
flowHash?: string;
|
|
13
13
|
}): ({
|
|
14
|
+
tries?: {
|
|
15
|
+
label: string;
|
|
16
|
+
passed: boolean;
|
|
17
|
+
reds: string[];
|
|
18
|
+
outcome: string;
|
|
19
|
+
rawOutcome: string;
|
|
20
|
+
again: boolean;
|
|
21
|
+
}[] | undefined;
|
|
14
22
|
kind: any;
|
|
15
23
|
n: any;
|
|
16
24
|
at: any;
|
|
@@ -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)";
|