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
@@ -45,6 +45,7 @@ export function spendSummary(opts?: {
45
45
  };
46
46
  };
47
47
  };
48
+ byModel: Record<string, Record<string, number>>;
48
49
  undatedRows: number;
49
50
  preM4dRunsNotCounted: boolean;
50
51
  };
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @param {{ root: string, home?: string, skipMonthly?: boolean, loadEnv: () => { ok: boolean, env: Record<string, string|undefined>, refusal: string|null }, bin?: string, childRunning?: (dir: string) => boolean }} opts
2
+ * @param {{ root: string, home?: string, skipMonthly?: boolean, loadEnv: () => { ok: boolean, env: Record<string, string|undefined>, refusal: string|null, keyNames?: string[] }, bin?: string, childRunning?: (dir: string) => boolean, thinkingSupport?: typeof bareagentThinkingSupport }} opts
3
3
  * `loadEnv` is the keys-file door (`keysForDoor`): called before EVERY spawn and every reply that quotes a log, so editing
4
4
  * the file needs no restart. Its `env` is BOTH the child's spawn env AND the scrub list (POC (a), M4d wiring rule).
5
5
  */
@@ -11,9 +11,11 @@ export function createAuthor(opts: {
11
11
  ok: boolean;
12
12
  env: Record<string, string | undefined>;
13
13
  refusal: string | null;
14
+ keyNames?: string[];
14
15
  };
15
16
  bin?: string;
16
17
  childRunning?: (dir: string) => boolean;
18
+ thinkingSupport?: typeof bareagentThinkingSupport;
17
19
  }): {
18
20
  flows: () => {
19
21
  status: number;
@@ -51,8 +53,13 @@ export function createAuthor(opts: {
51
53
  };
52
54
  jobLines: any;
53
55
  hasSend: boolean;
54
- capFloorUsd: any;
55
- floorText: string;
56
+ capFloorUsd: number;
57
+ floorModel: string | null;
58
+ model: {
59
+ slot: string;
60
+ model: string;
61
+ label: string;
62
+ } | null;
56
63
  flow: string;
57
64
  capUsd: any;
58
65
  roles: any;
@@ -127,8 +134,13 @@ export function createAuthor(opts: {
127
134
  };
128
135
  jobLines: any;
129
136
  hasSend: boolean;
130
- capFloorUsd: any;
131
- floorText: string;
137
+ capFloorUsd: number;
138
+ floorModel: string | null;
139
+ model: {
140
+ slot: string;
141
+ model: string;
142
+ label: string;
143
+ } | null;
132
144
  flow: string;
133
145
  capUsd: any;
134
146
  roles: any;
@@ -182,19 +194,44 @@ export function createAuthor(opts: {
182
194
  /**
183
195
  * `GET /api/author/monthly-check?cap=<usd>`: the note under Cap, one read-only check. `{ text, red }` is what to show (red =
184
196
  * the cap does not fit this month); `floorUsd` is the smallest cap that funds one round of a model step, for the page's
185
- * `needs at least $X per run` line. A cap that is not a number above 0 gets no note. Never spends, never writes.
186
- * @param {unknown} cap @param {string|null} [spent] what a resumed run has already spent (amendment 4 item 4)
197
+ * floor line (am20: `Cap $X is below one drafting|run round's worst case for <model>, $Y. …`, `kind` picks the word). A cap that is not a number above 0 gets no note. Never spends, never writes.
198
+ * @param {unknown} cap @param {string|null} [spent] what a resumed run has already spent (amendment 4 item 4) @param {{ provider?: string, model?: string, flow?: string }|null} [pick] the card's picked model, or (a Run / Resume) the flow whose recorded model it @param {string} [kind] 'run' for Run a signed flow and Resume, else the Chat card's 'drafting' is: its own prices are the floor (M4d am6)
187
199
  */
188
- monthlyCheck(cap: unknown, spent?: string | null): {
200
+ monthlyCheck(cap: unknown, spent?: string | null, pick?: {
201
+ provider?: string;
202
+ model?: string;
203
+ flow?: string;
204
+ } | null, kind?: string, draftId?: string | null): {
189
205
  status: number;
190
206
  body: {
191
207
  ok: boolean;
192
208
  text: string;
193
209
  red: boolean;
194
- floorUsd: any;
210
+ floorUsd: number;
195
211
  floorText: string;
196
212
  };
197
213
  };
214
+ /**
215
+ * `GET /api/author/models` (M4d amendment 6 item 6): what Chat's Model menu offers - every ticked, priced line of a provider whose key is set up, as
216
+ * "provider · model" - and, per line, whether "Thinking on" can change (`canChange`; bareagent's answer through `src/thinking.js`, am7). Read-only.
217
+ */
218
+ models(): {
219
+ status: number;
220
+ body: {
221
+ ok: boolean;
222
+ lines: {
223
+ thinking: {
224
+ support: boolean | "unverified";
225
+ canChange: boolean;
226
+ say: string;
227
+ };
228
+ slot: string;
229
+ model: string;
230
+ label: string;
231
+ }[];
232
+ say: string;
233
+ };
234
+ };
198
235
  /** `GET /api/author/start/:startId`: the start's phase, read from its files. @param {string} id */
199
236
  startGet(id: string): {
200
237
  status: number;
@@ -348,3 +385,4 @@ export function createAuthor(opts: {
348
385
  };
349
386
  /** Up to 2 revises per draft (amendment 14 item 3); a revise is used once its `draft-<n>/` exists (a refusal at $0 makes none). */
350
387
  export const MAX_REVISES: 2;
388
+ import { thinkingSupport as bareagentThinkingSupport } from '../thinking.js';
@@ -66,6 +66,9 @@ export function cardFields(body: any): {
66
66
  flow: any;
67
67
  flowHash: any;
68
68
  } | undefined;
69
+ thinking?: boolean | undefined;
70
+ provider?: string | undefined;
71
+ model?: string | undefined;
69
72
  flowName: string;
70
73
  job: string;
71
74
  destination: string;
@@ -133,15 +136,34 @@ export function checkInputRows(rows: {
133
136
  /**
134
137
  * M4e amendment 4 item 2: the smallest per-run cap that funds ONE round of the first model step. The runner halts a step when
135
138
  * `spent + ceiling > cap` (`runStepRalph`), and every ordinary (non-ask) step is a model step, so the floor is the runner's own
136
- * per-round ceiling (`resolveCeilingUsd`) as soon as the job has one such line; a job of only asks spends nothing before its stop.
139
+ * per-round hold (the picked model's own Settings prices times the token bounds) as soon as the job has one such line; a job of only asks spends nothing before its stop.
137
140
  * ONE function: the card's Draft check, Sign, and the page's note all read it. Returns 0 when no step needs a round.
138
- * @param {string} jobText
141
+ * @param {string} jobText @param {string} [home] the config home the panel reads Settings from (default: the process door)
142
+ * @param {{ slot?: string, provider?: string, model?: string }|null} [pick] the job's picked model (M4d amendment 6): its own Settings prices are the hold (a card names its key as `provider`)
139
143
  */
140
- export function capFloorUsd(jobText: string): any;
141
- /** The floor itself, for a caller that already knows whether the job has a step that is not an ask (a signed flow: any step off an ask line). @param {boolean} hasRoundStep */
142
- export function capFloorFor(hasRoundStep: boolean): any;
143
- /** The one sentence for a cap under the floor (red under Cap, and the Draft / sign refusal). @param {number} floorUsd */
144
- export function capFloorText(floorUsd: number): string;
144
+ export function capFloorUsd(jobText: string, home?: string, pick?: {
145
+ slot?: string;
146
+ provider?: string;
147
+ model?: string;
148
+ } | null): number;
149
+ /** The floor itself, for a caller that already knows whether the job has a step that is not an ask (a signed flow: any step off an ask line). @param {boolean} hasRoundStep @param {string} [home] @param {{ slot?: string, provider?: string, model?: string }|null} [pick] */
150
+ export function capFloorFor(hasRoundStep: boolean, home?: string, pick?: {
151
+ slot?: string;
152
+ provider?: string;
153
+ model?: string;
154
+ } | null): number;
155
+ /** The floor and the model id it was computed for (M4d am20: the refusal sentence names it). `{ usd: 0, model: null }` when there is nothing to hold. @param {boolean} hasRoundStep @param {string} [home] @param {{ slot?: string, provider?: string, model?: string }|null} [pick] */
156
+ export function capFloorOf(hasRoundStep: boolean, home?: string, pick?: {
157
+ slot?: string;
158
+ provider?: string;
159
+ model?: string;
160
+ } | null): {
161
+ usd: number;
162
+ model: null;
163
+ } | {
164
+ usd: number;
165
+ model: string;
166
+ };
145
167
  /**
146
168
  * Amendment 1's destination checks, in ONE place: the New job card and the per-run destination of amendment 5 both ask it. `null` = fine,
147
169
  * else the sentence (a folder that is the run folder, a flow folder, the root, `.drafts`, `.starts`, the config folder, a file, a missing
@@ -153,12 +175,13 @@ export function destinationRefusal(dest: string, root: string): string | null;
153
175
  /**
154
176
  * Every $0 check on the card, before any spawn (scope 6). Collects all refusals so the page can name every box.
155
177
  * @param {ReturnType<typeof cardFields>} card
156
- * @param {{ root: string, env?: Record<string, string|undefined> }} ctx `env` = the merged keys env: a key value typed into any box is refused
178
+ * @param {{ root: string, keys?: string[], home?: string }} ctx `keys` = the provider key values (the keys load's scrub list): a key value typed into any box is refused; `home` = the config home Settings is read from (the cap floor)
157
179
  * @returns {{ ok: true, prose: string }|{ ok: false, refusals: {field: string, say: string}[] }}
158
180
  */
159
- export function checkCard(card: ReturnType<typeof cardFields>, { root, env }: {
181
+ export function checkCard(card: ReturnType<typeof cardFields>, { root, keys, home }: {
160
182
  root: string;
161
- env?: Record<string, string | undefined>;
183
+ keys?: string[];
184
+ home?: string;
162
185
  }): {
163
186
  ok: true;
164
187
  prose: string;
@@ -1,9 +1,13 @@
1
1
  /**
2
2
  * What the Run / Resume forms show of a signed flow (read from its own files, never from a model): the job lines as the signed text has them
3
3
  * (an ask line carries its question and its wait), the values the open boxes start from, and the cap floor. Amendment 5 item 2: all the rest is dimmed.
4
- * @param {any} read `readFlow`'s ok result
4
+ * @param {any} read `readFlow`'s ok result @param {string} [home] the config home Settings is read from @param {string} [flowDir] the signed flow's folder: the model recorded beside it is the one it runs with (M4d amendment 6)
5
+ * @param {{ slot: string, model: string }|null} [picked] a flow with no record runs with the model picked in Chat (M4d amendment 7b): its price is the cap floor
5
6
  */
6
- export function formFacts(read: any): {
7
+ export function formFacts(read: any, home?: string, flowDir?: string, picked?: {
8
+ slot: string;
9
+ model: string;
10
+ } | null): {
7
11
  values: {
8
12
  capUsd: number;
9
13
  destination: string | null;
@@ -11,11 +15,16 @@ export function formFacts(read: any): {
11
15
  };
12
16
  jobLines: any;
13
17
  hasSend: boolean;
14
- capFloorUsd: any;
15
- floorText: string;
18
+ capFloorUsd: number;
19
+ floorModel: string | null;
20
+ model: {
21
+ slot: string;
22
+ model: string;
23
+ label: string;
24
+ } | null;
16
25
  };
17
26
  /**
18
- * @param {{ root: string, home?: string, skipMonthly?: boolean, loadEnv: () => { ok: boolean, env: Record<string, string|undefined>, refusal: string|null }, starter: ReturnType<typeof import('./authorstart.js').createStarter>, monthlyClaim: (usd: number) => any }} opts
27
+ * @param {{ root: string, home?: string, skipMonthly?: boolean, loadEnv: () => { ok: boolean, env: Record<string, string|undefined>, refusal: string|null }, starter: ReturnType<typeof import('./authorstart.js').createStarter>, monthlyClaim: (usd: number) => any, modelRefusal: (card: any, loaded: any) => { field: string, say: string }[] }} opts
19
28
  */
20
29
  export function createFlowsDoor(opts: {
21
30
  root: string;
@@ -28,6 +37,10 @@ export function createFlowsDoor(opts: {
28
37
  };
29
38
  starter: ReturnType<typeof import("./authorstart.js").createStarter>;
30
39
  monthlyClaim: (usd: number) => any;
40
+ modelRefusal: (card: any, loaded: any) => {
41
+ field: string;
42
+ say: string;
43
+ }[];
31
44
  }): {
32
45
  /** M6 amendments 1 and 3: the sentence that says why this flow cannot be edited now, or null (the sign route's check). @param {string} name */
33
46
  editBlock(name: string): string | null;
@@ -68,8 +81,13 @@ export function createFlowsDoor(opts: {
68
81
  };
69
82
  jobLines: any;
70
83
  hasSend: boolean;
71
- capFloorUsd: any;
72
- floorText: string;
84
+ capFloorUsd: number;
85
+ floorModel: string | null;
86
+ model: {
87
+ slot: string;
88
+ model: string;
89
+ label: string;
90
+ } | null;
73
91
  flow: string;
74
92
  capUsd: any;
75
93
  roles: any;
@@ -150,8 +168,13 @@ export function createFlowsDoor(opts: {
150
168
  };
151
169
  jobLines: any;
152
170
  hasSend: boolean;
153
- capFloorUsd: any;
154
- floorText: string;
171
+ capFloorUsd: number;
172
+ floorModel: string | null;
173
+ model: {
174
+ slot: string;
175
+ model: string;
176
+ label: string;
177
+ } | null;
155
178
  flow: string;
156
179
  capUsd: any;
157
180
  roles: any;
@@ -1,8 +1,9 @@
1
1
  /**
2
- * @param {{ root: string, loadEnv: () => { ok: boolean, env: Record<string, string|undefined>, refusal: string|null }, monthlyClaim: (usd: number) => any, starter: ReturnType<typeof import('./authorstart.js').createStarter> }} opts
2
+ * @param {{ root: string, home?: string, loadEnv: () => { ok: boolean, env: Record<string, string|undefined>, refusal: string|null }, monthlyClaim: (usd: number) => any, starter: ReturnType<typeof import('./authorstart.js').createStarter> }} opts
3
3
  */
4
4
  export function createResumeDoor(opts: {
5
5
  root: string;
6
+ home?: string;
6
7
  loadEnv: () => {
7
8
  ok: boolean;
8
9
  env: Record<string, string | undefined>;
@@ -21,11 +21,11 @@ export function createStarter(opts: {
21
21
  * `runId` '' = no typed id: the start CLAIMS the next `run-<n>` itself (claimRunId, folder created exclusively; amendment 3).
22
22
  * `values` (M4e amendment 5 item 3): the human's signed values for THIS run (the page's second click), written once into the run's own
23
23
  * folder as `signed-values.json` BEFORE the spawn; the run then uses them (`pickRunValues`). None = the flow's own.
24
- * @param {{ kind: 'run'|'sign', flow: string, runId: string, sources: {role: string, path: string}[], values?: any }} a
25
- * @param {Record<string, string|undefined>} env the merged keys env: the child's env AND the scrub list
24
+ * @param {{ kind: 'run'|'sign', flow: string, runId: string, sources: {role: string, path: string}[], values?: any, pick?: {slot: string, model: string}|null }} a
25
+ * @param {{ env: Record<string, string|undefined>, keyNames?: string[] }} loaded the keys load: its env is the child's env AND (with its key names) the scrub list
26
26
  * @returns {{ status: number, body: any }}
27
27
  */
28
- start({ kind, flow, runId, sources, values, }: {
28
+ start({ kind, flow, runId, sources, values, pick, }: {
29
29
  kind: "run" | "sign";
30
30
  flow: string;
31
31
  runId: string;
@@ -34,7 +34,14 @@ export function createStarter(opts: {
34
34
  path: string;
35
35
  }[];
36
36
  values?: any;
37
- }, env: Record<string, string | undefined>): {
37
+ pick?: {
38
+ slot: string;
39
+ model: string;
40
+ } | null;
41
+ }, loaded: {
42
+ env: Record<string, string | undefined>;
43
+ keyNames?: string[];
44
+ }): {
38
45
  status: number;
39
46
  body: any;
40
47
  };
@@ -42,14 +49,17 @@ export function createStarter(opts: {
42
49
  * Start `fwdloop continue <runId>` (M4e amendment 4 item 4): Resume of a stopped or cap-halted run, after the door wrote the run's new
43
50
  * signed values version. The same detached-child shape as `start`; the start folder reads as `starting` until the child consumes
44
51
  * `halt.json`, then `started`; a child that died with `halt.json` still there is `refused` with its own sentence. One start at a time per flow.
45
- * @param {{ flow: string, runId: string, version: number }} a @param {Record<string, string|undefined>} env the merged keys env
52
+ * @param {{ flow: string, runId: string, version: number }} a @param {{ env: Record<string, string|undefined>, keyNames?: string[] }} loaded the keys load
46
53
  * @returns {{ status: number, body: any }}
47
54
  */
48
55
  startContinue({ flow, runId, version }: {
49
56
  flow: string;
50
57
  runId: string;
51
58
  version: number;
52
- }, env: Record<string, string | undefined>): {
59
+ }, loaded: {
60
+ env: Record<string, string | undefined>;
61
+ keyNames?: string[];
62
+ }): {
53
63
  status: number;
54
64
  body: any;
55
65
  };
@@ -11,6 +11,7 @@ export function leastResumeCapUsd(spentUsd: number, floorUsd: number): number;
11
11
  * @param {{capUsd: number, destination: string|null, askWaits: Record<string,string>}} a.base the values in force now (the flow's own, or the run's newest signed version)
12
12
  * @param {string} a.realRoot the flows root (real path)
13
13
  * @param {boolean} a.capOnly Resume: destination and waits are never read from the body
14
+ * @param {string|null} [a.floorModel] the model id the floor was computed for (named in the refusal, M4d am20)
14
15
  * @param {number} a.floorUsd the smallest cap that funds one round of a step (amendment 4 item 2); 0 = none
15
16
  * @param {number} [a.spentUsd] what the run has already spent (Resume): the cap must be above it
16
17
  * @param {boolean} [a.always] Resume: the floor and the monthly check always apply. A Run applies them only when its cap differs from the
@@ -18,7 +19,7 @@ export function leastResumeCapUsd(spentUsd: number, floorUsd: number): number;
18
19
  * @param {(remainingUsd: number) => null | { problem: string } | { ok: boolean, room: any }} a.monthlyClaim the one monthly check
19
20
  * @returns {{ ok: true, values: {capUsd: number, destination: string|null, askWaits: Record<string,string>}, differs: boolean, remainingUsd: number } | { ok: false, status: number, refusals: {field: string, say: string}[], refused?: string, say?: string }}
20
21
  */
21
- export function checkValues({ allowedKeys, body, base, realRoot, capOnly, floorUsd, spentUsd, monthlyClaim, always, }: {
22
+ export function checkValues({ allowedKeys, body, base, realRoot, capOnly, floorUsd, floorModel, spentUsd, monthlyClaim, always, }: {
22
23
  allowedKeys: string[];
23
24
  body: any;
24
25
  base: {
@@ -28,6 +29,7 @@ export function checkValues({ allowedKeys, body, base, realRoot, capOnly, floorU
28
29
  };
29
30
  realRoot: string;
30
31
  capOnly: boolean;
32
+ floorModel?: string | null | undefined;
31
33
  floorUsd: number;
32
34
  spentUsd?: number | undefined;
33
35
  always?: boolean | undefined;
@@ -224,8 +224,8 @@ export function costDisplay(spentUsd: number | null | undefined, spendComplete:
224
224
  * never a stale first-attempt value. `null` (never a guess) when no row in
225
225
  * this run ever named one (e.g. every step is `hitl`, no model step ran).
226
226
  * No provider/API-kind field exists in ANY book (`src/provider.js`'s
227
- * `PROVIDER_SLOTS` maps a slot name to a model, but nothing writes which
228
- * slot served a given run back to `audit.jsonl`/`spend.jsonl`) — provider is
227
+ * a provider row maps to a model, but nothing writes which
228
+ * row served a given run back to `audit.jsonl`/`spend.jsonl`) — provider is
229
229
  * never shown alongside it (hamr's own instruction: "if the provider isn't
230
230
  * in any book, show model only").
231
231
  * @param {any[]} auditRows
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @param {{ root: string, env?: Record<string, string|undefined>, loadEnv?: () => { ok: boolean, env: Record<string, string|undefined>, refusal: string|null }, bin?: string, logDir?: string,
2
+ * @param {{ root: string, env?: Record<string, string|undefined>, loadEnv?: () => { ok: boolean, env: Record<string, string|undefined>, refusal: string|null, keyNames?: string[] }, bin?: string, logDir?: string,
3
3
  * maxTries?: number, windowMs?: number, slotMs?: number }} opts
4
4
  * `loadEnv` (M4d: the keys-file door, called before EVERY spawn so editing the file needs no panel restart) returns the merged env
5
5
  * that is BOTH the child's spawn env AND its scrub list, or a refusal sentence that becomes the attempt's refusal (nothing spawns).
@@ -16,6 +16,7 @@ export function createResumer(opts: {
16
16
  ok: boolean;
17
17
  env: Record<string, string | undefined>;
18
18
  refusal: string | null;
19
+ keyNames?: string[];
19
20
  };
20
21
  bin?: string;
21
22
  logDir?: string;
@@ -4,11 +4,12 @@
4
4
  * real listening socket where that is simpler.
5
5
  * @param {import('node:http').IncomingMessage} req
6
6
  * @param {import('node:http').ServerResponse} res
7
- * @param {{ root: string, port: number, resumer: ReturnType<typeof createResumer>, settings: ReturnType<typeof createSettings>, author: ReturnType<typeof createAuthor> }} opts
7
+ * @param {{ root: string, port: number, packagePath?: string, resumer: ReturnType<typeof createResumer>, settings: ReturnType<typeof createSettings>, author: ReturnType<typeof createAuthor> }} opts
8
8
  */
9
9
  export function handleRequest(req: import("node:http").IncomingMessage, res: import("node:http").ServerResponse, opts: {
10
10
  root: string;
11
11
  port: number;
12
+ packagePath?: string;
12
13
  resumer: ReturnType<typeof createResumer>;
13
14
  settings: ReturnType<typeof createSettings>;
14
15
  author: ReturnType<typeof createAuthor>;
@@ -19,18 +20,21 @@ export function handleRequest(req: import("node:http").IncomingMessage, res: imp
19
20
  * header). Resolves once actually listening; rejects on a bind error
20
21
  * (including `EADDRINUSE`) with a `.port` field on the error for the
21
22
  * 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
23
+ * @param {{ port?: number, root: string, packagePath?: 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
24
  * `resume` and `author` are for tests only (a fake env/bin, a short retry window); the CLI passes none.
24
25
  * @returns {Promise<{ server: import('node:http').Server, port: number, close: () => Promise<void> }>}
25
26
  */
26
27
  export function createPanelServer(opts: {
27
28
  port?: number;
28
29
  root: string;
30
+ packagePath?: string;
29
31
  settings?: {
30
32
  home?: string;
31
33
  env?: Record<string, string | undefined>;
32
34
  fetch?: typeof fetch;
33
35
  now?: () => number;
36
+ openFolderSpawn?: Function;
37
+ platform?: string;
34
38
  };
35
39
  resume?: {
36
40
  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;
@@ -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 in the merged env — the scrub list. The env that holds them is the SAME object that is the child's
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>} env
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(env: Record<string, string | undefined>): string[];
36
+ export function providerKeys(loaded: {
37
+ env: Record<string, string | undefined>;
38
+ keyNames?: string[];
39
+ }): string[];
@@ -0,0 +1,22 @@
1
+ /**
2
+ * @param {unknown} raw one raw refusal text
3
+ * @returns {{ say: string, reason: string, fix: string, raw: string }}
4
+ */
5
+ export function plainPlanCheck(raw: unknown): {
6
+ say: string;
7
+ reason: string;
8
+ fix: string;
9
+ raw: string;
10
+ };
11
+ /** @type {ReadonlyArray<{re: RegExp, say: string|null, fix: string}>} `say` null = the checker's own sentence, as it is without its "declaration: " prefix */
12
+ export const PLAN_CHECK_RULES: ReadonlyArray<{
13
+ re: RegExp;
14
+ say: string | null;
15
+ fix: string;
16
+ }>;
17
+ export const GENERIC_SAY: "One of the checks on the plan failed.";
18
+ export const GENERIC_FIX: "Draft again.";
19
+ export function pageRules(): {
20
+ re: string;
21
+ say: string | null;
22
+ }[];
@@ -50,10 +50,4 @@ export class GateRefusal extends Error {
50
50
  path: any;
51
51
  rule: any;
52
52
  }
53
- /** The verbs this piece actually implements (the switch below, as data) —
54
- * one writer for "is this verb wired": `resolvePrimitives`'s own reds use
55
- * it, and `src/runner.js`'s preflight (F46: a step granted a
56
- * catalogue-present-but-unwired verb, e.g. litectx's `compress`, must
57
- * refuse before any model call or spend) imports this SAME set rather than
58
- * keeping a second copy of the list. */
59
53
  export const WIRED_VERBS: Set<string>;