fwdloop 0.21.0 → 0.22.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 (87) hide show
  1. package/bin/fwdloop +85 -34
  2. package/package.json +4 -3
  3. package/src/audit-fold.js +5 -1
  4. package/src/authoring.js +32 -6
  5. package/src/checked.js +18 -1
  6. package/src/cited-record.js +138 -0
  7. package/src/cited-source.js +49 -0
  8. package/src/citedcheck.js +306 -0
  9. package/src/citedwords.js +197 -0
  10. package/src/closers.js +56 -7
  11. package/src/ctx-tools.js +2 -14
  12. package/src/declaration.js +85 -5
  13. package/src/diary.js +2 -2
  14. package/src/docx.js +16 -2
  15. package/src/draft-steps.js +1 -1
  16. package/src/drafter.js +292 -25
  17. package/src/flow.js +33 -7
  18. package/src/flowmodel.js +21 -0
  19. package/src/input-facts.js +20 -3
  20. package/src/model-step.js +30 -5
  21. package/src/pageask.js +136 -0
  22. package/src/pagebits.js +107 -0
  23. package/src/pagedropwords.js +171 -0
  24. package/src/pagedry.js +120 -0
  25. package/src/pagefetch.js +164 -0
  26. package/src/pagelook.js +155 -0
  27. package/src/pagemap.js +55 -0
  28. package/src/pageplace.js +103 -0
  29. package/src/pagerules.js +318 -0
  30. package/src/panel/author.js +41 -20
  31. package/src/panel/authorcard.js +11 -1
  32. package/src/panel/authorflows.js +21 -15
  33. package/src/panel/authorstart.js +2 -4
  34. package/src/panel/authortrigger.js +14 -4
  35. package/src/panel/data.js +83 -2
  36. package/src/panel/index.html +279 -12
  37. package/src/panel/result.js +295 -0
  38. package/src/panel/server.js +27 -3
  39. package/src/primitives.js +2 -3
  40. package/src/provider.js +5 -2
  41. package/src/redact.js +17 -0
  42. package/src/runner.js +83 -12
  43. package/src/schedule.js +3 -3
  44. package/src/setup.js +16 -1
  45. package/src/sheetfind.js +50 -0
  46. package/src/sheetlook.js +157 -0
  47. package/src/signed-text.js +11 -1
  48. package/src/thinking.js +1 -1
  49. package/src/try-checks.js +6 -0
  50. package/src/types.js +3 -2
  51. package/types/authoring.d.ts +19 -2
  52. package/types/checked.d.ts +10 -0
  53. package/types/cited-record.d.ts +21 -0
  54. package/types/cited-source.d.ts +18 -0
  55. package/types/citedcheck.d.ts +95 -0
  56. package/types/citedwords.d.ts +97 -0
  57. package/types/closers.d.ts +55 -3
  58. package/types/ctx-tools.d.ts +0 -1
  59. package/types/declaration.d.ts +15 -1
  60. package/types/docx.d.ts +14 -0
  61. package/types/drafter.d.ts +244 -2
  62. package/types/flow.d.ts +21 -0
  63. package/types/flowmodel.d.ts +15 -0
  64. package/types/input-facts.d.ts +12 -2
  65. package/types/model-step.d.ts +35 -3
  66. package/types/pageask.d.ts +75 -0
  67. package/types/pagebits.d.ts +32 -0
  68. package/types/pagedropwords.d.ts +40 -0
  69. package/types/pagedry.d.ts +38 -0
  70. package/types/pagefetch.d.ts +86 -0
  71. package/types/pagelook.d.ts +75 -0
  72. package/types/pagemap.d.ts +31 -0
  73. package/types/pageplace.d.ts +22 -0
  74. package/types/pagerules.d.ts +86 -0
  75. package/types/panel/authorcard.d.ts +2 -0
  76. package/types/panel/authorflows.d.ts +2 -0
  77. package/types/panel/data.d.ts +26 -0
  78. package/types/panel/result.d.ts +156 -0
  79. package/types/provider.d.ts +3 -1
  80. package/types/redact.d.ts +1 -0
  81. package/types/runner.d.ts +156 -7
  82. package/types/schedule.d.ts +0 -11
  83. package/types/setup.d.ts +13 -0
  84. package/types/sheetfind.d.ts +46 -0
  85. package/types/sheetlook.d.ts +120 -0
  86. package/types/thinking.d.ts +1 -1
  87. package/types/types.d.ts +11 -3
@@ -0,0 +1,97 @@
1
+ /** @typedef {{code: string, detail: string}} WordRed */
2
+ /**
3
+ * What the page-word map KEPT and DROPPED for one input: the sets the proof reads.
4
+ * @param {{facts?: any[], dropped?: any[]}|null|undefined} look @param {string} source
5
+ * @returns {{labels: Set<string>|null, words: Set<string>, dropped: Map<string, any>}|null} null = the page was not read by the map; `labels: null` = a document (no map, any label in the text)
6
+ */
7
+ export function keptSetOf(look: {
8
+ facts?: any[];
9
+ dropped?: any[];
10
+ } | null | undefined, source: string): {
11
+ labels: Set<string> | null;
12
+ words: Set<string>;
13
+ dropped: Map<string, any>;
14
+ } | null;
15
+ /**
16
+ * The reds for ONE fact part against its frozen source text and what the page-word map kept.
17
+ * @param {{part: any, text: string, line: number, kept: NonNullable<ReturnType<typeof keptSetOf>>}} o
18
+ * @returns {WordRed[]}
19
+ */
20
+ export function factWordReds({ part, text, line, kept, }: {
21
+ part: any;
22
+ text: string;
23
+ line: number;
24
+ kept: NonNullable<ReturnType<typeof keptSetOf>>;
25
+ }): WordRed[];
26
+ /**
27
+ * The numbers a person said in their words, by KIND. A number inside a time (05:00), a date (2026-11-18) or an amount ($150) is part of that token, not
28
+ * a bare number: "5" is not said by "05:00", "15" and "50" are not said by "$150". (bareloop's `boundInWords` is a substring test and accepts all of those; this
29
+ * reader is ours - FINDINGS-worthy, see the commit.) Times compare without a leading zero on the hour ("05:00" = "5:00"), spaces dropped, case folded.
30
+ * @param {string} text
31
+ * @returns {{bare: Set<number>, amount: Set<number>, time: Set<string>, date: Set<string>}}
32
+ */
33
+ export function numbersSaid(text: string): {
34
+ bare: Set<number>;
35
+ amount: Set<number>;
36
+ time: Set<string>;
37
+ date: Set<string>;
38
+ };
39
+ /**
40
+ * Tighter than bareloop (signed, am7 item 1): every number in a fact's rule must be in the person's own words on this job line (the line and its `~` rules;
41
+ * an agreed reading is a `~` line too), as the right KIND of token: a money or number bound is a bare number or an amount, a time bound is a time, a date bound
42
+ * is a date. A bound the AI made up, or one that only sits inside another token, is refused.
43
+ * @param {{part: any, jobLine: {n: number, text?: string, rule?: string, rules?: string[]}}} o @returns {WordRed[]}
44
+ */
45
+ export function numberRuleReds({ part, jobLine }: {
46
+ part: any;
47
+ jobLine: {
48
+ n: number;
49
+ text?: string;
50
+ rule?: string;
51
+ rules?: string[];
52
+ };
53
+ }): WordRed[];
54
+ /**
55
+ * Signed (am7 item 1): "List 3 ..." is the count, 3 results. A count the person never said as a bare number or a word number (not inside a time, a date or an
56
+ * amount) is refused. Same reader as the number rules.
57
+ * @param {{part: any, jobLine: {n: number, text?: string, rule?: string, rules?: string[]}}} o @returns {WordRed[]}
58
+ */
59
+ export function countReds({ part, jobLine }: {
60
+ part: any;
61
+ jobLine: {
62
+ n: number;
63
+ text?: string;
64
+ rule?: string;
65
+ rules?: string[];
66
+ };
67
+ }): WordRed[];
68
+ /**
69
+ * R2c (am7 item 2): a place the page-read grew to phrases must have EVERY phrase as a phrase fact of the part, or a flipped route passes.
70
+ * @param {{part: any, line: number, look: {facts?: any[]}|null|undefined}} o @returns {WordRed[]}
71
+ */
72
+ export function placeReds({ part, line, look }: {
73
+ part: any;
74
+ line: number;
75
+ look: {
76
+ facts?: any[];
77
+ } | null | undefined;
78
+ }): WordRed[];
79
+ /**
80
+ * Every word red for one cited part, in the order a person fixes them.
81
+ * @param {{part: any, text: string|undefined, line: number, jobLine: any, look: {facts?: any[], dropped?: any[]}|null|undefined, doc?: boolean}} o @returns {WordRed[]}
82
+ */
83
+ export function citedWordReds({ part, text, line, jobLine, look, doc, }: {
84
+ part: any;
85
+ text: string | undefined;
86
+ line: number;
87
+ jobLine: any;
88
+ look: {
89
+ facts?: any[];
90
+ dropped?: any[];
91
+ } | null | undefined;
92
+ doc?: boolean;
93
+ }): WordRed[];
94
+ export type WordRed = {
95
+ code: string;
96
+ detail: string;
97
+ };
@@ -1,3 +1,8 @@
1
+ /**
2
+ * M10 am10: the one description of the cite forms, told to a step whose check cites cells and named in the red when a cite fits none.
3
+ * Built from the checker's own formula list (FORMULAS keys + daysBetween, which is handled apart), so the text cannot drift from what is accepted.
4
+ */
5
+ export function citeForms(names?: string[]): string;
1
6
  /** An input with cells (M4d amendment 8): a file whose name ends `.csv`. The one decider for "this input can be cited". */
2
7
  export function isCellsPath(p: any): boolean;
3
8
  /**
@@ -5,13 +10,38 @@ export function isCellsPath(p: any): boolean;
5
10
  * resolves and matches its cite. First red wins.
6
11
  *
7
12
  * @param {any} artifact
8
- * @param {{ reads: Record<string, any>, businessDate: string }} ctx
13
+ * @param {{ reads: Record<string, any>, businessDate: string, lock?: {source: string, column: string}[] }} ctx `lock` (M10 am8): the columns the step's check names
9
14
  * @returns {CloseVerdict}
10
15
  */
11
16
  export function closeGreen(artifact: any, ctx: {
12
17
  reads: Record<string, any>;
13
18
  businessDate: string;
19
+ lock?: {
20
+ source: string;
21
+ column: string;
22
+ }[];
14
23
  }): CloseVerdict;
24
+ /**
25
+ * M10 piece 4 (item 2, "green grows"): the green close of a step that cites quotes instead of cells. `part` is the step's fact part (`close.cited`, set by
26
+ * code from the page look's kept facts, never by the model); `source` is the run's OWN frozen copy of the page or doc (`readRunSource`); the artifact is
27
+ * `{ results: [{ quote, values: { <fact name>: "<value as the quote writes it>" } }] }`. bareguard's `cited` check proves each quote is word for word in
28
+ * the frozen text, each value is in its quote and passes its rule, and the number of results is as signed. No model grades.
29
+ * Third outcomes, each named, never green: no readable source or an artifact that is not an object (`unparseable`, a casualty), a part bareguard cannot sign
30
+ * (`crash`). `cited` carries what the runner writes to the run's cited-check record: the part and the check's own answer.
31
+ *
32
+ * @param {any} part
33
+ * @param {any} artifact
34
+ * @param {{ok: true, text: string, sha256: string}|{ok: false, red: string}|null|undefined} source
35
+ * @returns {Promise<CloseVerdict>}
36
+ */
37
+ export function closeCited(part: any, artifact: any, source: {
38
+ ok: true;
39
+ text: string;
40
+ sha256: string;
41
+ } | {
42
+ ok: false;
43
+ red: string;
44
+ } | null | undefined): Promise<CloseVerdict>;
15
45
  /**
16
46
  * M4e amendment 18: the soft checks run on bareguard 0.21.0. `softgreenSpec(shape)` is the ONE place a declared shape
17
47
  * becomes a rubric spec (signing and the run both build through `buildSoftgreenRubric`, so a shape that signs is a shape
@@ -73,19 +103,41 @@ export function closeSoftgreen(artifact: any, shape: {
73
103
  /**
74
104
  * The one dispatcher — `close by declared class` (M2 scope item 4).
75
105
  *
76
- * @param {{ close?: { class?: string, shape?: Record<string, any> } }} step
106
+ * @param {{ close?: { class?: string, shape?: Record<string, any>, cited?: any, columns?: {source: string, column: string}[] } }} step
77
107
  * @param {unknown} artifact
78
- * @param {{ reads: Record<string, any>, businessDate: string }} ctx
108
+ * @param {{ reads: Record<string, any>, businessDate: string, source?: {ok: true, text: string, sha256: string}|{ok: false, red: string}|null }} ctx
109
+ * `source` (M10 piece 4) = the run's own frozen copy a cited step reads, from `readRunSource`; only a step whose close carries `cited` reads it
79
110
  * @returns {Promise<CloseVerdict>}
80
111
  */
81
112
  export function closeByClass(step: {
82
113
  close?: {
83
114
  class?: string;
84
115
  shape?: Record<string, any>;
116
+ cited?: any;
117
+ columns?: {
118
+ source: string;
119
+ column: string;
120
+ }[];
85
121
  };
86
122
  }, artifact: unknown, ctx: {
87
123
  reads: Record<string, any>;
88
124
  businessDate: string;
125
+ source?: {
126
+ ok: true;
127
+ text: string;
128
+ sha256: string;
129
+ } | {
130
+ ok: false;
131
+ red: string;
132
+ } | null;
89
133
  }): Promise<CloseVerdict>;
134
+ /** @typedef {import('./types.js').CloseVerdict} CloseVerdict */
135
+ export const FORMULAS: Readonly<{
136
+ sum: (vals: any) => any;
137
+ count: (vals: any) => any;
138
+ min: (vals: any) => number;
139
+ max: (vals: any) => number;
140
+ sub: (vals: any) => number;
141
+ }>;
90
142
  export type CloseVerdict = import("./types.js").CloseVerdict;
91
143
  import { createRubric } from 'bareguard';
@@ -16,4 +16,3 @@ export function makeCtxTools({ runDir, gatePath }: {
16
16
  /** One stashed item holds at most this many bytes (measured after secrets are masked,
17
17
  * because that is what enters the store). Bareloop's number, signed in M7 item 3. */
18
18
  export const ISOLATE_MAX_BYTES: 65536;
19
- export function redactSecrets(raw: unknown): string;
@@ -50,7 +50,12 @@ export function checkShapeFitsJobLine(step: any, i: any, lines: any, reds: any):
50
50
  * text as its goal, exactly. Off by default so already-signed flows keep running; draft and sign turn it on.
51
51
  * `fitJobLine` (optional boolean; M4e amendment 6): when true, a `close.shape` whose sections/maxWords fight the step's job
52
52
  * line or its guardrail is a red. Draft, change and sign turn it on; readFlow does not (signed flows keep running).
53
- * @param {{ arbiter?: unknown, lines?: unknown, catalogue?: unknown, wired?: Set<string>, verbatimGoals?: boolean, fitJobLine?: boolean }} [context]
53
+ * `pageWords` (optional; M10 am7 item 1): `{texts: {role: drafting copy}, look: {facts, dropped}}`. With `fitJobLine`, the words of every `close.cited` fact are
54
+ * proved on the page at $0; the drafter passes it, sign does not (the draft was already proved, and its files are hash-bound).
55
+ * `pageWords.docs` (M10 piece 5): the roles that are documents (.docx / .md / .txt): their words are proved on their text alone, with no page-word map.
56
+ * `sheetWords` (optional; M10 am8 item 2): `{headers: {role: header names}, facts: the columns the sheet look kept}`. With `fitJobLine`, every column a step's `close.columns` names
57
+ * is proved a real column of its sheet, and a column the code kept for the step's line (an agreed one included) must be in it.
58
+ * @param {{ arbiter?: unknown, lines?: unknown, catalogue?: unknown, wired?: Set<string>, verbatimGoals?: boolean, fitJobLine?: boolean, pageWords?: {texts: Record<string, string>, look: any, docs?: string[]}, sheetWords?: {headers: Record<string, string[]>, facts: any[]} }} [context]
54
59
  * @returns {ValidateDeclarationResult}
55
60
  */
56
61
  export function validateDeclaration(declaration: unknown, context?: {
@@ -60,6 +65,15 @@ export function validateDeclaration(declaration: unknown, context?: {
60
65
  wired?: Set<string>;
61
66
  verbatimGoals?: boolean;
62
67
  fitJobLine?: boolean;
68
+ pageWords?: {
69
+ texts: Record<string, string>;
70
+ look: any;
71
+ docs?: string[];
72
+ };
73
+ sheetWords?: {
74
+ headers: Record<string, string[]>;
75
+ facts: any[];
76
+ };
63
77
  }): ValidateDeclarationResult;
64
78
  /** @typedef {import('./types.js').Arbiter} Arbiter */
65
79
  /** @typedef {import('./types.js').SignedLine} SignedLine */
package/types/docx.d.ts CHANGED
@@ -7,6 +7,20 @@ export function readDocxText(path: string): {
7
7
  ok: false;
8
8
  red: string;
9
9
  };
10
+ /**
11
+ * M10 piece 5 (item 2, "a quote in a doc"): the text of a .docx AND the sha256 of its bytes from one read, so a cited check can prove the run's own frozen copy is
12
+ * the file that was frozen. Same text as {@link readDocxText} (what it throws away is declared at the top of this file).
13
+ * @param {string} path @returns {{ok:true,text:string,paragraphs:number,sha256:string}|{ok:false,red:string}}
14
+ */
15
+ export function readDocxSource(path: string): {
16
+ ok: true;
17
+ text: string;
18
+ paragraphs: number;
19
+ sha256: string;
20
+ } | {
21
+ ok: false;
22
+ red: string;
23
+ };
10
24
  /** @param {string} path @returns {{ok:true,headings:string[]}|{ok:false,red:string}} */
11
25
  export function readDocxHeadings(path: string): {
12
26
  ok: true;
@@ -56,6 +56,116 @@ export function buildDeclarationSchema(menu: any): {
56
56
  additionalProperties: boolean;
57
57
  description: string;
58
58
  };
59
+ cited: Readonly<{
60
+ type: "object";
61
+ description: "only on a green step that checks quotes from a web page or a document input: the facts every result must hold. Omit on any other step";
62
+ properties: {
63
+ source: {
64
+ type: string;
65
+ description: string;
66
+ };
67
+ facts: {
68
+ type: string;
69
+ minItems: number;
70
+ maxItems: number;
71
+ description: string;
72
+ items: {
73
+ type: string;
74
+ properties: {
75
+ name: {
76
+ type: string;
77
+ description: string;
78
+ };
79
+ shape: {
80
+ type: string;
81
+ enum: string[];
82
+ };
83
+ unit: {
84
+ type: string[];
85
+ items: {
86
+ type: string;
87
+ };
88
+ description: string;
89
+ };
90
+ currency: {
91
+ type: string[];
92
+ items: {
93
+ type: string;
94
+ };
95
+ description: string;
96
+ };
97
+ phrase: {
98
+ type: string;
99
+ description: string;
100
+ };
101
+ anchor: {
102
+ type: string;
103
+ description: string;
104
+ };
105
+ until: {
106
+ type: string;
107
+ description: string;
108
+ };
109
+ rule: {
110
+ type: string;
111
+ description: string;
112
+ properties: {
113
+ op: {
114
+ type: string;
115
+ enum: string[];
116
+ };
117
+ value: {};
118
+ lo: {};
119
+ hi: {};
120
+ };
121
+ required: string[];
122
+ additionalProperties: boolean;
123
+ };
124
+ };
125
+ required: string[];
126
+ additionalProperties: boolean;
127
+ };
128
+ };
129
+ count: {
130
+ type: string;
131
+ description: string;
132
+ properties: {
133
+ min: {
134
+ type: string;
135
+ minimum: number;
136
+ };
137
+ max: {
138
+ type: string;
139
+ minimum: number;
140
+ };
141
+ };
142
+ additionalProperties: boolean;
143
+ };
144
+ };
145
+ required: string[];
146
+ additionalProperties: false;
147
+ }>;
148
+ columns: Readonly<{
149
+ type: "array";
150
+ minItems: 1;
151
+ maxItems: 10;
152
+ description: "only on a green step that cites cells of a CSV input: the exact column names (the sheet's header) every cited cell comes from. Omit on any other step";
153
+ items: {
154
+ type: string;
155
+ properties: {
156
+ source: {
157
+ type: string;
158
+ description: string;
159
+ };
160
+ column: {
161
+ type: string;
162
+ description: string;
163
+ };
164
+ };
165
+ required: string[];
166
+ additionalProperties: boolean;
167
+ };
168
+ }>;
59
169
  };
60
170
  required: string[];
61
171
  additionalProperties: boolean;
@@ -168,6 +278,116 @@ export function buildRoundSchema(menu: any, { questions }?: {
168
278
  additionalProperties: boolean;
169
279
  description: string;
170
280
  };
281
+ cited: Readonly<{
282
+ type: "object";
283
+ description: "only on a green step that checks quotes from a web page or a document input: the facts every result must hold. Omit on any other step";
284
+ properties: {
285
+ source: {
286
+ type: string;
287
+ description: string;
288
+ };
289
+ facts: {
290
+ type: string;
291
+ minItems: number;
292
+ maxItems: number;
293
+ description: string;
294
+ items: {
295
+ type: string;
296
+ properties: {
297
+ name: {
298
+ type: string;
299
+ description: string;
300
+ };
301
+ shape: {
302
+ type: string;
303
+ enum: string[];
304
+ };
305
+ unit: {
306
+ type: string[];
307
+ items: {
308
+ type: string;
309
+ };
310
+ description: string;
311
+ };
312
+ currency: {
313
+ type: string[];
314
+ items: {
315
+ type: string;
316
+ };
317
+ description: string;
318
+ };
319
+ phrase: {
320
+ type: string;
321
+ description: string;
322
+ };
323
+ anchor: {
324
+ type: string;
325
+ description: string;
326
+ };
327
+ until: {
328
+ type: string;
329
+ description: string;
330
+ };
331
+ rule: {
332
+ type: string;
333
+ description: string;
334
+ properties: {
335
+ op: {
336
+ type: string;
337
+ enum: string[];
338
+ };
339
+ value: {};
340
+ lo: {};
341
+ hi: {};
342
+ };
343
+ required: string[];
344
+ additionalProperties: boolean;
345
+ };
346
+ };
347
+ required: string[];
348
+ additionalProperties: boolean;
349
+ };
350
+ };
351
+ count: {
352
+ type: string;
353
+ description: string;
354
+ properties: {
355
+ min: {
356
+ type: string;
357
+ minimum: number;
358
+ };
359
+ max: {
360
+ type: string;
361
+ minimum: number;
362
+ };
363
+ };
364
+ additionalProperties: boolean;
365
+ };
366
+ };
367
+ required: string[];
368
+ additionalProperties: false;
369
+ }>;
370
+ columns: Readonly<{
371
+ type: "array";
372
+ minItems: 1;
373
+ maxItems: 10;
374
+ description: "only on a green step that cites cells of a CSV input: the exact column names (the sheet's header) every cited cell comes from. Omit on any other step";
375
+ items: {
376
+ type: string;
377
+ properties: {
378
+ source: {
379
+ type: string;
380
+ description: string;
381
+ };
382
+ column: {
383
+ type: string;
384
+ description: string;
385
+ };
386
+ };
387
+ required: string[];
388
+ additionalProperties: boolean;
389
+ };
390
+ }>;
171
391
  };
172
392
  required: string[];
173
393
  additionalProperties: boolean;
@@ -253,9 +473,11 @@ export function goalForLine(fromLine: any, lines: any): any;
253
473
  *
254
474
  * @returns {Promise<{ok:boolean, declaration:object|null, reds:string[], rounds:number, calls:number, spendComplete:boolean,
255
475
  * costUsd:number|null, modelReturned:string|null, modelId?:string, price?:object|null, tokens?:object|null, structureRetries:number, revisions:number, stop:string|null, log:object[],
256
- * questions?:{line:number, question:string}[], droppedQuestions?:object[], notChecked?:string[], thinking?:{asked:string, status:string|null, say:string|null}, inputs?:{role:string, detail:string}[]}>}
476
+ * questions?:{line:number, question:string}[], droppedQuestions?:object[], notChecked?:string[], thinking?:{asked:string, status:string|null, say:string|null}, inputs?:{role:string, detail:string}[],
477
+ * look?:{facts:any[], dropped:any[]}, pageLooks?:{role:string, address:string, sha256:string, bytes:number, frozen:string, attempts:number, mapping:any}[], sheetLooks?:any[]}>}
478
+ * `look` / `pageLooks` (M10 item 3) are there when the job signs a web page: the kept facts (with their `reading`, the input a later ask reads), every drop, and per page its address, sha256 and the AI's map. Each drop is also a line in `notChecked`.
257
479
  */
258
- export function draft({ proseText, slot, model, provider: injected, rates: injectedRates, modelId: injectedModelId, env, priorSpend, skills, makeProviderFn, onBook, offerQuestions, draftThinking, }: {
480
+ export function draft({ proseText, slot, model, provider: injected, rates: injectedRates, modelId: injectedModelId, env, priorSpend, skills, makeProviderFn, onBook, offerQuestions, draftThinking, draftDir, fetchPage, leftRules, }: {
259
481
  proseText: any;
260
482
  slot: any;
261
483
  model: any;
@@ -269,6 +491,12 @@ export function draft({ proseText, slot, model, provider: injected, rates: injec
269
491
  onBook: any;
270
492
  offerQuestions?: boolean | undefined;
271
493
  draftThinking?: "on" | "off" | undefined;
494
+ draftDir?: string | null | undefined;
495
+ fetchPage?: undefined;
496
+ leftRules?: {
497
+ line: number;
498
+ rule: number;
499
+ }[] | undefined;
272
500
  }): Promise<{
273
501
  ok: boolean;
274
502
  declaration: object | null;
@@ -300,6 +528,20 @@ export function draft({ proseText, slot, model, provider: injected, rates: injec
300
528
  role: string;
301
529
  detail: string;
302
530
  }[];
531
+ look?: {
532
+ facts: any[];
533
+ dropped: any[];
534
+ };
535
+ pageLooks?: {
536
+ role: string;
537
+ address: string;
538
+ sha256: string;
539
+ bytes: number;
540
+ frozen: string;
541
+ attempts: number;
542
+ mapping: any;
543
+ }[];
544
+ sheetLooks?: any[];
303
545
  }>;
304
546
  export const MAX_STRUCTURE_RETRIES: 2;
305
547
  export const MAX_REVISIONS: 2;
package/types/flow.d.ts CHANGED
@@ -98,6 +98,21 @@ export function listRunIds(flowDir: string): string[];
98
98
  * @returns {string}
99
99
  */
100
100
  export function nextRunId(flowDir: string): string;
101
+ /**
102
+ * The ONE decider of an unnamed run's id: the first `run-<n>` from `from` (default: nextRunId) with nothing by that name (a stray file counts as taken, as
103
+ * `mkdir` EEXIST does). Only LOOKS; `claimRunId` claims it and `canStart` (src/panel/authorstart.js) asks it.
104
+ * @param {string} flowDir @param {number} [from]
105
+ * @returns {{ok:true, runId:string, runDir:string, n:number}|{ok:false, red:string}}
106
+ */
107
+ export function freeRunId(flowDir: string, from?: number): {
108
+ ok: true;
109
+ runId: string;
110
+ runDir: string;
111
+ n: number;
112
+ } | {
113
+ ok: false;
114
+ red: string;
115
+ };
101
116
  /**
102
117
  * @param {string} flowDir
103
118
  * @returns {{ok:true, runId:string, runDir:string}|{ok:false, red:string}}
@@ -344,6 +359,12 @@ export function readRunJobCopy(runDir: string, catalogue: unknown): {
344
359
  * @param {string} root @param {string} name
345
360
  */
346
361
  export function suggestFlowName(root: string, name: string): string;
362
+ /**
363
+ * M10: take back the drafting copies of web pages (`files`) a draft froze into `dir` when the draft is then refused at $0, and the folder itself once it is
364
+ * empty. Only the files named are removed; a folder holding anything else is left.
365
+ * @param {string} dir @param {string[]} files
366
+ */
367
+ export function removeFrozenPages(dir: string, files: string[]): void;
347
368
  /** @typedef {import('./types.js').WriteFlowResult} WriteFlowResult */
348
369
  /** @typedef {import('./types.js').ReadFlowResult} ReadFlowResult */
349
370
  /** @typedef {import('./types.js').CheckFlowNameResult} CheckFlowNameResult */
@@ -33,6 +33,21 @@ export function readRunThinking(runDir: string | null): boolean | null;
33
33
  * Written for every fresh run, ticked or not. @param {string} flowDir @param {string} runDir
34
34
  */
35
35
  export function writeRunThinking(flowDir: string, runDir: string): void;
36
+ /**
37
+ * M4d am33: the ONE reader of the model a run started on, or null (a run from before the record, or an unusable one: the caller then keeps today's pick).
38
+ * @param {string|null} runDir @returns {{ slot: string, model: string }|null}
39
+ */
40
+ export function readRunModel(runDir: string | null): {
41
+ slot: string;
42
+ model: string;
43
+ } | null;
44
+ /** M4d am33: the ONE writer, called once when a fresh run starts (`runFlow`); never over an existing record. @param {string} runDir @param {{ slot: string, model: string }} pick */
45
+ export function writeRunModel(runDir: string, { slot, model }: {
46
+ slot: string;
47
+ model: string;
48
+ }): void;
36
49
  export const MODEL_FILE: "model.json";
37
50
  /** M4d am25: the file in a run's folder that keeps the box as the run started with it (outside `job/`, which holds the three signed files only). */
38
51
  export const RUN_THINKING_FILE: "thinking.json";
52
+ /** M4d am33: the file in a run's folder that records the model the run STARTED on (write-once; every continue path keeps it). */
53
+ export const RUN_MODEL_FILE: "run-model.json";
@@ -1,13 +1,21 @@
1
1
  /**
2
2
  * @param {Array<{kind?:string, role:string, path:string}>} sources arbiter.sources
3
+ * @param {{pages?: Record<string, {text: string}>}} [o] `pages` (M10 item 1): the drafting copy of each web page input, role -> its frozen text, fetched by the caller. A page
4
+ * source with no copy here is a named red (never skipped); it adds no heading facts (a page has none), only its line for the drafter and the Chat card.
3
5
  * `list` (M4d am10) is one `{role, detail}` per readable input for the Chat card's list (a CSV: its columns; text: its headings); never hashed.
4
- * @returns {{ok:boolean, inputFacts:Record<string,string[]>, info:string[], list:Array<{role:string, detail:string}>, reds:string[]}}
6
+ * `sheets` (M10 piece 5): role -> the text of each CSV input, for the sheet-word look (the same read, not a second one).
7
+ * `docs` (M10 piece 5, item 2): role -> the text of each document input (.docx paragraphs, .md / .txt as is), the drafting copy a cited fact part's words are proved on.
8
+ * @returns {{ok:boolean, inputFacts:Record<string,string[]>, info:string[], list:Array<{role:string, detail:string}>, reds:string[], sheets:Record<string,string>, docs:Record<string,string>}}
5
9
  */
6
10
  export function readInputFacts(sources: Array<{
7
11
  kind?: string;
8
12
  role: string;
9
13
  path: string;
10
- }>): {
14
+ }>, { pages }?: {
15
+ pages?: Record<string, {
16
+ text: string;
17
+ }>;
18
+ }): {
11
19
  ok: boolean;
12
20
  inputFacts: Record<string, string[]>;
13
21
  info: string[];
@@ -16,4 +24,6 @@ export function readInputFacts(sources: Array<{
16
24
  detail: string;
17
25
  }>;
18
26
  reds: string[];
27
+ sheets: Record<string, string>;
28
+ docs: Record<string, string>;
19
29
  };