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.
Files changed (72) hide show
  1. package/README.md +2 -0
  2. package/bin/fwdloop +113 -36
  3. package/package.json +2 -2
  4. package/src/authoring.js +27 -15
  5. package/src/catalogue.json +9 -3
  6. package/src/closers.js +5 -0
  7. package/src/config.js +66 -4
  8. package/src/ctx-tools.js +245 -0
  9. package/src/declaration.js +25 -1
  10. package/src/draft-steps.js +138 -0
  11. package/src/drafter.js +81 -18
  12. package/src/draftspend.js +109 -3
  13. package/src/flowmodel.js +30 -0
  14. package/src/input-facts.js +12 -3
  15. package/src/keysfile.js +51 -16
  16. package/src/liveness.js +34 -10
  17. package/src/model-step.js +13 -11
  18. package/src/monthly.js +9 -1
  19. package/src/panel/author.js +170 -43
  20. package/src/panel/authorcard.js +32 -20
  21. package/src/panel/authorflows.js +34 -19
  22. package/src/panel/authorresume.js +11 -9
  23. package/src/panel/authorstart.js +11 -9
  24. package/src/panel/authorvalues.js +5 -3
  25. package/src/panel/data.js +20 -8
  26. package/src/panel/index.html +584 -182
  27. package/src/panel/resume.js +3 -3
  28. package/src/panel/server.js +12 -6
  29. package/src/panel/settings.js +138 -80
  30. package/src/panel/spawn.js +15 -9
  31. package/src/plain-checks.js +51 -0
  32. package/src/primitives.js +34 -3
  33. package/src/provider.js +148 -181
  34. package/src/providershapes.js +7 -7
  35. package/src/run-store.js +47 -0
  36. package/src/runner.js +40 -22
  37. package/src/setup.js +3 -0
  38. package/src/thinking.js +55 -0
  39. package/src/version.js +13 -0
  40. package/types/authoring.d.ts +11 -6
  41. package/types/closers.d.ts +2 -0
  42. package/types/config.d.ts +9 -1
  43. package/types/ctx-tools.d.ts +18 -0
  44. package/types/draft-steps.d.ts +47 -0
  45. package/types/drafter.d.ts +15 -12
  46. package/types/draftspend.d.ts +56 -0
  47. package/types/flowmodel.d.ts +16 -0
  48. package/types/input-facts.d.ts +6 -1
  49. package/types/keysfile.d.ts +23 -6
  50. package/types/liveness.d.ts +7 -1
  51. package/types/model-step.d.ts +1 -1
  52. package/types/monthly.d.ts +1 -0
  53. package/types/panel/author.d.ts +47 -9
  54. package/types/panel/authorcard.d.ts +33 -10
  55. package/types/panel/authorflows.d.ts +32 -9
  56. package/types/panel/authorresume.d.ts +2 -1
  57. package/types/panel/authorstart.d.ts +16 -6
  58. package/types/panel/authorvalues.d.ts +3 -1
  59. package/types/panel/data.d.ts +2 -2
  60. package/types/panel/resume.d.ts +2 -1
  61. package/types/panel/server.d.ts +6 -2
  62. package/types/panel/settings.d.ts +3 -1
  63. package/types/panel/spawn.d.ts +13 -4
  64. package/types/plain-checks.d.ts +22 -0
  65. package/types/primitives.d.ts +0 -6
  66. package/types/provider.d.ts +100 -284
  67. package/types/providershapes.d.ts +3 -4
  68. package/types/run-store.d.ts +11 -0
  69. package/types/runner.d.ts +2 -4
  70. package/types/setup.d.ts +8 -0
  71. package/types/thinking.d.ts +25 -0
  72. package/types/version.d.ts +2 -0
@@ -1,15 +1,11 @@
1
1
  /**
2
- * THE one lookup of a slot's model, API shape and address (M4d amendment 1). Every model call (run,
3
- * resume, model step, drafter), Test, Balance and the spend rows read the slot through this and nothing
4
- * else: a value saved on the Settings page (`config.providers[slot]`) wins per field, else the code
5
- * default above. A blank saved Base URL means the default FOR THE EFFECTIVE SHAPE: the slot's own code
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
- * Strip an `hf:` routing prefix and look up `suffix` with `Object.hasOwn` —
31
- * never plain truthiness/`in`, which would let a suffix like `"constructor"`
32
- * resolve to an inherited `Object.prototype` member.
33
- * @param {string|null|undefined} modelId
34
- * @param {Record<string, any>} [ratesTable]
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 lookupRate(modelId: string | null | undefined, ratesTable?: Record<string, any>): {
37
- suffix: string;
38
- rates: any;
39
- } | null;
40
- /** Resolve a modelId to its hand-entered rate row, or throw — a caller here
41
- * must never carry forward a 0 rate. */
42
- export function resolveModelRate(modelId: any, ratesTable?: {
43
- 'zai-org/GLM-5.2': {
44
- in: number;
45
- out: number;
46
- source: string;
47
- };
48
- 'moonshotai/Kimi-K3': {
49
- in: number;
50
- out: number;
51
- source: string;
52
- };
53
- 'zai-org/GLM-5.3-Flash': {
54
- in: number;
55
- out: number;
56
- source: string;
57
- };
58
- 'zai-org/GLM-4.7-Flash': {
59
- in: number;
60
- out: number;
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
- suffix: string;
105
- rates: any;
52
+ ok: true;
53
+ slot: string;
54
+ model: string;
55
+ } | {
56
+ ok: false;
57
+ say: string;
106
58
  };
107
59
  /**
108
- * THE one price lookup (M4d scope item 6): every model call — run, resume, model step, drafter —
109
- * is booked and cap-checked from this. Per field: a Settings price (`config.prices[slot]`, USD per
110
- * 1M -> per 1K) wins, else the code table's row, else the table's HIGHEST entry for that field
111
- * (an unknown model; unknown cost is never 0). M4d amendment 2: cached input is priced AS input —
112
- * `cacheReadMult` is always 1; a saved `cachedInPerM` and a row's `cacheIn` are never read here.
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} modelId
115
- * @param {{ slot?: string, config?: Record<string, any>, ratesTable?: Record<string, any> }} [opts]
66
+ * @param {string} slotName
67
+ * @param {{ config?: Record<string, any>, model?: string }} [opts]
116
68
  * @returns {{
117
- * rates: { in: number, out: number, cacheReadMult?: number },
118
- * perM: { inPerM: number, cachedInPerM: number, outPerM: number },
119
- * source: { in: 'settings'|'table'|'ceiling', cachedIn: 'input', out: 'settings'|'table'|'ceiling' },
120
- * suffix: string|null,
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 resolvePrices(modelId: string, { slot, config, ratesTable }?: {
124
- slot?: string;
74
+ export function resolveUsableModel(slotName: string, { config, model }?: {
125
75
  config?: Record<string, any>;
126
- ratesTable?: Record<string, any>;
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?: number;
84
+ cacheReadMult: number;
132
85
  };
133
- perM: {
134
- inPerM: number;
135
- cachedInPerM: number;
136
- outPerM: number;
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
- source: {
139
- in: "settings" | "table" | "ceiling";
140
- cachedIn: "input";
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 `resolvePrices` result; or from INJECTED rates (tests) with source "injected".
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 ceiling cost (USD) of one round of `modelId` — never 0, never null.
168
- * A known model prices at its own rate; an unknown/missing model prices at
169
- * the HIGHEST in/out rate anywhere in `ratesTable`. `opts.prices` (a
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(modelId: any, ratesTable?: {
174
- 'zai-org/GLM-5.2': {
175
- in: number;
176
- out: number;
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" | "alias" | "substituted";
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 for `slotName` must be set, non-empty, and free of any
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 slot. Throws (never defaults) on an
316
- * unknown slot, a missing/bad env key, or a model with no hand-entered
317
- * rate. Returns `{ provider, rates, modelId, suffix, slot }`.
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, thinking?: object|null, env?: Record<string,string|undefined>, configHome?: string }} [options]
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
- * `thinking` (bare-agent >=0.49) is sent verbatim as body.thinking; unset/null leaves the body unchanged.
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: ReturnType<typeof resolvePrices>;
349
- };
350
- /** Provider slots. Frozen — add a new slot here, never inline a baseUrl/env
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; `defaultUrl` is the host a blank Base URL means for a slot
3
- * that has no code default of its own on this shape ('' = bare-agent's own default for that vendor).
4
- * @type {readonly {id: string, label: string, defaultUrl: 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; defaults to `resolveCeilingUsd(null)`.
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
- * $0.0006+), so nothing a real tamper produces can hide inside it. */
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)";
@@ -0,0 +1,2 @@
1
+ /** @param {string|URL} [file] a package.json (a test passes a copy) @returns {string|null} */
2
+ export function readOwnVersion(file?: string | URL): string | null;