fwdloop 0.35.2 → 0.37.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 (104) hide show
  1. package/README.md +1 -1
  2. package/bin/fwdloop +5 -2
  3. package/package.json +3 -3
  4. package/src/action-stop.js +1 -1
  5. package/src/auditchecks.js +41 -9
  6. package/src/authoring.js +78 -20
  7. package/src/blockasks.js +10 -12
  8. package/src/blockassemble.js +49 -43
  9. package/src/blockdraft.js +4 -2
  10. package/src/blockpick.js +10 -0
  11. package/src/canrun.js +2 -1
  12. package/src/cardlist.js +28 -5
  13. package/src/checkblock.js +610 -64
  14. package/src/checked.js +28 -33
  15. package/src/checklistsign.js +2 -1
  16. package/src/checklook.js +45 -0
  17. package/src/checkrows.js +202 -0
  18. package/src/cited-record.js +2 -2
  19. package/src/citedcheck.js +53 -12
  20. package/src/citedwords.js +7 -4
  21. package/src/closers.js +49 -2
  22. package/src/declaration.js +26 -4
  23. package/src/drafter.js +86 -62
  24. package/src/factwords.js +7 -4
  25. package/src/globprefix.js +26 -0
  26. package/src/model-step.js +22 -4
  27. package/src/pageask.js +6 -4
  28. package/src/pagedropwords.js +3 -11
  29. package/src/pagedry.js +75 -1
  30. package/src/pagefetch.js +11 -6
  31. package/src/pagelook.js +2 -1
  32. package/src/pagerules.js +8 -2
  33. package/src/panel/author.js +20 -8
  34. package/src/panel/authorcard.js +3 -3
  35. package/src/panel/data.js +3 -2
  36. package/src/panel/index.html +176 -41
  37. package/src/panel/result.js +40 -3
  38. package/src/pickrecord.js +14 -0
  39. package/src/planrebuild.js +55 -19
  40. package/src/ratelimit.js +117 -0
  41. package/src/report.js +216 -0
  42. package/src/rowresults.js +111 -0
  43. package/src/rubricstep.js +65 -2
  44. package/src/runner.js +61 -9
  45. package/src/send.js +19 -82
  46. package/src/shapebuild.js +281 -0
  47. package/src/shapelook.js +91 -0
  48. package/src/shapemenu.js +64 -0
  49. package/src/shaperesult.js +104 -0
  50. package/src/shaperows.js +263 -0
  51. package/src/shapewords.js +140 -0
  52. package/src/sheetbuild.js +41 -29
  53. package/src/sheetclaims.js +49 -1
  54. package/src/sheetfind.js +8 -0
  55. package/src/sheetlook.js +11 -1
  56. package/src/sheetrows.js +10 -64
  57. package/src/ticketrows.js +1 -1
  58. package/src/try-checks.js +39 -6
  59. package/src/types.js +1 -0
  60. package/src/whole-job.js +108 -16
  61. package/types/action-stop.d.ts +1 -1
  62. package/types/auditchecks.d.ts +13 -2
  63. package/types/authoring.d.ts +24 -4
  64. package/types/blockasks.d.ts +6 -10
  65. package/types/blockassemble.d.ts +13 -13
  66. package/types/blockdraft.d.ts +3 -2
  67. package/types/blockpick.d.ts +4 -0
  68. package/types/cardlist.d.ts +18 -2
  69. package/types/checkblock.d.ts +278 -28
  70. package/types/checked.d.ts +15 -6
  71. package/types/checklook.d.ts +36 -0
  72. package/types/checkrows.d.ts +119 -0
  73. package/types/citedcheck.d.ts +4 -2
  74. package/types/closers.d.ts +10 -1
  75. package/types/drafter.d.ts +8 -4
  76. package/types/globprefix.d.ts +5 -0
  77. package/types/model-step.d.ts +43 -2
  78. package/types/pageask.d.ts +5 -3
  79. package/types/pagedropwords.d.ts +0 -1
  80. package/types/pagedry.d.ts +27 -0
  81. package/types/pagefetch.d.ts +3 -2
  82. package/types/pagerules.d.ts +4 -0
  83. package/types/panel/result.d.ts +19 -2
  84. package/types/pickrecord.d.ts +10 -0
  85. package/types/ratelimit.d.ts +59 -0
  86. package/types/report.d.ts +46 -0
  87. package/types/rowresults.d.ts +28 -0
  88. package/types/rubricstep.d.ts +21 -0
  89. package/types/runner.d.ts +3 -1
  90. package/types/send.d.ts +13 -12
  91. package/types/shapebuild.d.ts +97 -0
  92. package/types/shapelook.d.ts +76 -0
  93. package/types/shapemenu.d.ts +40 -0
  94. package/types/shaperesult.d.ts +40 -0
  95. package/types/shaperows.d.ts +102 -0
  96. package/types/shapewords.d.ts +43 -0
  97. package/types/sheetbuild.d.ts +31 -13
  98. package/types/sheetclaims.d.ts +16 -0
  99. package/types/sheetfind.d.ts +1 -0
  100. package/types/sheetrows.d.ts +5 -36
  101. package/types/ticketrows.d.ts +1 -1
  102. package/types/try-checks.d.ts +2 -1
  103. package/types/types.d.ts +4 -0
  104. package/types/whole-job.d.ts +69 -3
@@ -0,0 +1,119 @@
1
+ /**
2
+ * am8 item 1 and am9 item 5: the draft's ledger rows, one per Not checked list row, for the draft's own `log.json` `log` list (no new file). A `~` rule's words are its own text.
3
+ * @param {any} declaration @param {any[]} lines @param {Record<string, string[]>} [wordsByKey] the words the build gave a row (its name)
4
+ * @returns {{kind: 'ledger', phase: 'final', key: string, rowKind: string, words: string[], state: 'not-checked'}[]}
5
+ */
6
+ export function ledgerRowsOf(declaration: any, lines: any[], wordsByKey?: Record<string, string[]>): {
7
+ kind: "ledger";
8
+ phase: "final";
9
+ key: string;
10
+ rowKind: string;
11
+ words: string[];
12
+ state: "not-checked";
13
+ }[];
14
+ /** am8 item 1: the last ledger row per key wins (bareloop `readDraftLedger`). @param {unknown} log @returns {Map<string, any>} */
15
+ export function readLedger(log: unknown): Map<string, any>;
16
+ /**
17
+ * The name of a Not checked row: am9 item 1 (a `~` rule: `line <n>: "<rule text>" - <reason>`, else `line <n>: rule <n> - <reason>`), item 2 (prose or stage: `line <n>: <reason>`), item 3 (cited, numbers, note: fixed words),
18
+ * item 4 and am8 item 2 (any other: `<kind> "<ledger words>"`, else its key's tail). The dash is an em dash with a space each side.
19
+ * @param {any} r the signed row @param {string|undefined} ruleText @param {string[]|undefined} words
20
+ */
21
+ export function notCheckedName(r: any, ruleText: string | undefined, words: string[] | undefined): string;
22
+ /**
23
+ * The Not checked ITEM a plan saves for a list row (the string the readout, the Job tab, the Audit and the card's Not checked group read, src/checklook.js `ncRowsOf`): the row's name, with the code-written prefix `line <n>: ` for a row whose name
24
+ * does not name its line (the prefix is how the surfaces place a row under its job line; `ncRowsOf` strips it), and M10 am17 (6)'s words when a Revise carried the row. ONE writer: src/blockassemble.js and the reader both call it.
25
+ * @param {any} r the signed row @param {string|undefined} ruleText @param {string[]|undefined} words @param {boolean} [keptFromLast]
26
+ */
27
+ export function notCheckedItem(r: any, ruleText: string | undefined, words: string[] | undefined, keptFromLast?: boolean): string;
28
+ /**
29
+ * The rows of ONE step's close, in the close's part order (facts, the result count, the field rows of a list of items, each picked check, the numbers tie), each with `idx`, the index of the part the signed list's rows point at (src/checklistsign.js).
30
+ * The ONE place the words of these rows are written: the card, the readout, the Job tab and the Audit's Checks fold all read them from here.
31
+ * @param {{declaration: any, st: any, lines: any[], kept?: {line: number, check?: any, rule?: number}[], idx?: number}} o `idx` = the first part's index (the parts the earlier steps of the line have)
32
+ * @returns {{rows: any[], next: number}}
33
+ */
34
+ export function stepRowsOf({ declaration, st, lines, kept, idx }: {
35
+ declaration: any;
36
+ st: any;
37
+ lines: any[];
38
+ kept?: {
39
+ line: number;
40
+ check?: any;
41
+ rule?: number;
42
+ }[];
43
+ idx?: number;
44
+ }): {
45
+ rows: any[];
46
+ next: number;
47
+ };
48
+ /**
49
+ * The card's rows and its Not checked list, read from the signed plan.
50
+ * @param {{declaration: any, lines: {n: number, text?: string, guardrail?: string}[], csvRoles?: string[], kept?: {line: number, check?: any, rule?: number}[], log?: unknown}} o `log` = the draft's own `log.json` `log` list (the ledger rows are read from it)
51
+ * @returns {{rows: {line: number, key: string, by: string, state: string, kind: string, text: string, reason: string|null, drop?: boolean, part: string}[], notChecked: {line: number, key: string, by: string, state: 'not-checked', kind: string, text: string, reason: string|null, part: string}[]}}
52
+ */
53
+ export function cardOfPlan({ declaration, lines, csvRoles, kept, log }: {
54
+ declaration: any;
55
+ lines: {
56
+ n: number;
57
+ text?: string;
58
+ guardrail?: string;
59
+ }[];
60
+ csvRoles?: string[];
61
+ kept?: {
62
+ line: number;
63
+ check?: any;
64
+ rule?: number;
65
+ }[];
66
+ log?: unknown;
67
+ }): {
68
+ rows: {
69
+ line: number;
70
+ key: string;
71
+ by: string;
72
+ state: string;
73
+ kind: string;
74
+ text: string;
75
+ reason: string | null;
76
+ drop?: boolean;
77
+ part: string;
78
+ }[];
79
+ notChecked: {
80
+ line: number;
81
+ key: string;
82
+ by: string;
83
+ state: "not-checked";
84
+ kind: string;
85
+ text: string;
86
+ reason: string | null;
87
+ part: string;
88
+ }[];
89
+ };
90
+ /**
91
+ * M19 am6 item 3 (bareloop `planMatchesClose`): the checks a card shows must equal the checks the signed plan runs, line by line. Returns the reds, each naming the line; empty = they match. Pure.
92
+ * @param {{declaration: any, lines: any[], csvRoles?: string[], kept?: any[], log?: unknown}} plan @param {any} card the card as shown
93
+ * @returns {string[]}
94
+ */
95
+ export function planMatchesCard(plan: {
96
+ declaration: any;
97
+ lines: any[];
98
+ csvRoles?: string[];
99
+ kept?: any[];
100
+ log?: unknown;
101
+ }, card: any): string[];
102
+ /**
103
+ * The card as the draft saves and the panel draws it: the block's own card (suggestions, restorable, the Drop flags) with its rows read from the signed plan and its Not checked list beside them.
104
+ * A Drop flag is joined by key from the block's card; a row the block's card has no flag for keeps the flag its own reader gave it (a sheet row), else false.
105
+ * @param {any} card the block's card (src/cardlist.js, with the sheet and Tickets rows) @param {Parameters<typeof cardOfPlan>[0]} plan
106
+ */
107
+ export function planCard(card: any, plan: Parameters<typeof cardOfPlan>[0]): any;
108
+ /** the words of a line's floor row (src/cardlist.js drew them first; the reader is their one owner now) */
109
+ export const FLOOR_WORDS: "the file exists and its text is not empty (code's own floor)";
110
+ export const FLOOR_LIST_WORDS: "the file exists (code's own floor); this line lists items, so it has no text check";
111
+ export function numbersWords(from: number[]): string;
112
+ /** am9 item 3 (bareloop `DEFAULT_ROW_WORDS`) */
113
+ export const DEFAULT_ROW_WORDS: Readonly<{
114
+ cited: "every claim quotes its input";
115
+ numbers: "every number matches a quote";
116
+ note: "the note";
117
+ }>;
118
+ export function isListedNotChecked(list: any[], r: any): boolean;
119
+ export function ruleTextOf(lines: any[], r: any): string | undefined;
@@ -22,9 +22,9 @@ export function factDecides(part: any): Record<string, any>[];
22
22
  * a phrase fact contributes its own signed words. A result that is not an object, or has no string quote, still becomes a claim (an empty one) so
23
23
  * bareguard reds it by name rather than the result vanishing.
24
24
  * `asWritten` (bareloop v0.56.0): per result, per fact index, the value as the page writes it, for the claim's words of a date or amount a page form signs.
25
- * @param {any} part @param {unknown} results @param {Record<number, string>[]} [asWritten] @returns {{claim: string, quote: string, values?: Record<string, string>}[]}
25
+ * @param {any} part @param {unknown} results @param {(Record<number, string>|undefined)[]} [asWritten] @returns {{claim: string, quote: string, values?: Record<string, string>}[]}
26
26
  */
27
- export function factClaims(part: any, results: unknown, asWritten?: Record<number, string>[]): {
27
+ export function factClaims(part: any, results: unknown, asWritten?: (Record<number, string> | undefined)[]): {
28
28
  claim: string;
29
29
  quote: string;
30
30
  values?: Record<string, string>;
@@ -114,6 +114,8 @@ export const FACT_SHAPES: readonly string[];
114
114
  /** bareguard signs at most this many decides on one `cited` check */
115
115
  export const MAX_FACTS: 10;
116
116
  export const CITED_ID: "facts";
117
+ export function phraseWordsOf(f: any): string[];
118
+ export function quotedWords(words: string[]): string;
117
119
  export function sha256Text(t: string): string;
118
120
  /** the languages whose month names bareguard 0.27 reads on a `date` fact (its `lang`), each with the name a person reads; absent `lang` = ISO YYYY-MM-DD only */
119
121
  export const FACT_LANGS: Readonly<{
@@ -22,6 +22,14 @@ export function closeCited(part: any, artifact: any, source: {
22
22
  ok: false;
23
23
  red: string;
24
24
  } | null | undefined): Promise<CloseVerdict>;
25
+ /**
26
+ * M19 S5: the list-of-items check of a line's close (`close.itemShape`, the signed shape part {fields, minItems?, maxItems?}; never `close.shape`, which stays the text shape of M10): ONE bareguard `itemShape` check over the
27
+ * answer's `results`. On a facts+shape line (`close.cited` beside it) the check is closed and also lists `quote` and `values`, and the item count stays with the fact part (src/shaperows.js `shapeItemCheck`), so a count fault is
28
+ * told once. A red names the item and the field in the tag's words (src/shapewords.js). Third outcomes, never green: an answer that is not an object (`unparseable`), a shape bareguard cannot build or a check that stopped (`crash`).
29
+ * `shapeGaps` carries bareguard's own gaps (names, counts and bounds, never a value) for the views that mark an item or a field.
30
+ * @param {any} step @param {unknown} artifact @returns {Promise<CloseVerdict>}
31
+ */
32
+ export function closeItemShape(step: any, artifact: unknown): Promise<CloseVerdict>;
25
33
  /**
26
34
  * M4e amendment 18: the soft checks run on bareguard 0.21.0. `softgreenSpec(shape)` is the ONE place a declared shape
27
35
  * becomes a rubric spec (signing and the run both build through `buildSoftgreenRubric`, so a shape that signs is a shape
@@ -85,7 +93,7 @@ export function closeSoftgreen(artifact: any, shape: {
85
93
  /**
86
94
  * The one dispatcher — `close by declared class` (M2 scope item 4).
87
95
  *
88
- * @param {{ close?: { class?: string, shape?: Record<string, any>, picked?: any[], cited?: any, columns?: {source: string, column: string}[], sheet?: any[], numbersFrom?: number[] } }} step
96
+ * @param {{ close?: { class?: string, shape?: Record<string, any>, picked?: any[], cited?: any, itemShape?: any, columns?: {source: string, column: string}[], sheet?: any[], numbersFrom?: number[] } }} step
89
97
  * @param {unknown} artifact
90
98
  * @param {{ reads: Record<string, any>, businessDate: string, source?: {ok: true, text: string, sha256: string}|{ok: false, red: string}|null, sheet?: any, numbers?: {quotes: Record<string, string[]>, missing: number[]} }} ctx
91
99
  * `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
@@ -98,6 +106,7 @@ export function closeByClass(step: {
98
106
  shape?: Record<string, any>;
99
107
  picked?: any[];
100
108
  cited?: any;
109
+ itemShape?: any;
101
110
  columns?: {
102
111
  source: string;
103
112
  column: string;
@@ -311,11 +311,11 @@ export function goalForLine(fromLine: any, lines: any): any;
311
311
  * @returns {Promise<{ok:boolean, declaration:object|null, reds:string[], rounds:number, calls:number, spendComplete:boolean,
312
312
  * costUsd:number|null, modelReturned:string|null, modelId?:string, price?:object|null, tokens?:object|null, structureRetries:number, revisions:number, stop:string|null, log:object[],
313
313
  * questions?:{line:number, question:string}[], proseText?:string, action?:{line:number, by?:'agent'|'you', dropped?:true}|null, droppedQuestions?:object[], notChecked?:string[], thinking?:{asked:string, status:string|null, say:string|null}, inputs?:{role:string, detail:string}[],
314
- * checkCard?:ReturnType<typeof cardOfBlock>, notCheckedBy?:Record<string,'you'|'agent'|'default'>, look?:{facts:any[], dropped:any[]}, pageLooks?:{role:string, address:string, sha256:string, bytes:number, frozen:string, attempts:number, mapping:any}[], sheetLooks?:any[]}>}
314
+ * checkCard?:ReturnType<typeof cardOfPlanBlock>, sheetBuilt?:Awaited<ReturnType<typeof buildSheetChecks>>, notCheckedBy?:Record<string,'you'|'agent'|'default'>, look?:{facts:any[], dropped:any[]}, pageLooks?:{role:string, address:string, sha256:string, bytes:number, frozen:string, attempts:number, mapping:any}[], sheetLooks?:any[]}>}
315
315
  * `learnHints` (M8 item 5a): the earlier runs' notes block (src/learnstore.js hintsForRun), appended to the drafter's system prompt; null = nothing.
316
316
  * `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`.
317
317
  */
318
- export function draft({ proseText, slot, model, provider: injected, rates: injectedRates, modelId: injectedModelId, env, priorSpend, skills, makeProviderFn, onBook, offerQuestions, draftThinking, draftDir, fetchPage, leftRules, columnAnswers, carriedColumns, onColumns, checkPicks, carriedPicks, carriedChoices, carriedSheetDropped, onSheetDropped, onChoices, onPickRecord, learnHints, mcpServers, flowType, mcp, actionMode, }: {
318
+ export function draft({ proseText, slot, model, provider: injected, rates: injectedRates, modelId: injectedModelId, env, priorSpend, skills, makeProviderFn, onBook, offerQuestions, draftThinking, draftDir, fetchPage, leftRules, columnAnswers, carriedColumns, onColumns, checkPicks, carriedPicks, carriedChoices, carriedSheetDropped, onSheetDropped, carriedShapeDropped, onShapeDropped, onChoices, onPickRecord, learnHints, mcpServers, flowType, mcp, actionMode, }: {
319
319
  proseText: any;
320
320
  slot: any;
321
321
  model: any;
@@ -347,6 +347,8 @@ export function draft({ proseText, slot, model, provider: injected, rates: injec
347
347
  carriedChoices?: any[] | null | undefined;
348
348
  carriedSheetDropped?: any[] | undefined;
349
349
  onSheetDropped?: ((rec: any[]) => void) | undefined;
350
+ carriedShapeDropped?: any[] | undefined;
351
+ onShapeDropped?: ((rec: any[]) => void) | undefined;
350
352
  onChoices?: ((rec: any[]) => void) | undefined;
351
353
  onPickRecord?: ((r: {
352
354
  picks: import("./pickrecord.js").Entry[];
@@ -402,7 +404,8 @@ export function draft({ proseText, slot, model, provider: injected, rates: injec
402
404
  role: string;
403
405
  detail: string;
404
406
  }[];
405
- checkCard?: ReturnType<typeof cardOfBlock>;
407
+ checkCard?: ReturnType<typeof cardOfPlanBlock>;
408
+ sheetBuilt?: Awaited<ReturnType<typeof buildSheetChecks>>;
406
409
  notCheckedBy?: Record<string, "you" | "agent" | "default">;
407
410
  look?: {
408
411
  facts: any[];
@@ -431,4 +434,5 @@ export const MAX_QUESTIONS: 2;
431
434
  /** Try 3 only, and only after tries 1 and 2 both failed validation. No digit and no number word anywhere (a test greps this): the machine, not the prompt, bounds the count. */
432
435
  export const QUESTIONS_PROMPT: string;
433
436
  import { makeProvider } from './provider.js';
434
- import { cardOfBlock } from './cardlist.js';
437
+ import { cardOfPlanBlock } from './cardlist.js';
438
+ import { buildSheetChecks } from './sheetbuild.js';
@@ -0,0 +1,5 @@
1
+ /**
2
+ * @param {string} scope
3
+ * @returns {string}
4
+ */
5
+ export function globToPrefix(scope: string): string;
@@ -16,7 +16,7 @@ export function isTransportFailure(err: any): boolean;
16
16
  * `stepClass` is `'green' | 'softgreen' | 'hitl' | null | undefined`; `cited` is true for that green step.
17
17
  */
18
18
  /** @param {string|null|undefined} stepClass @param {boolean} [cited] @param {any[]|null} [sheet] M10b piece 2: the step's `close.sheet` (its claim boxes become the answer) @param {boolean} [withText] M10 am22: a fact step with the person's picks also answers in `text` (the picks read it) */
19
- export function buildEmitArtifactSchema(stepClass: string | null | undefined, cited?: boolean, sheet?: any[] | null, withText?: boolean): Readonly<{
19
+ export function buildEmitArtifactSchema(stepClass: string | null | undefined, cited?: boolean, sheet?: any[] | null, withText?: boolean, items?: boolean): Readonly<{
20
20
  type: "object";
21
21
  properties: {
22
22
  done: {
@@ -83,6 +83,45 @@ export function buildEmitArtifactSchema(stepClass: string | null | undefined, ci
83
83
  required: string[];
84
84
  additionalProperties: false;
85
85
  }> | {
86
+ properties: {
87
+ text: {
88
+ type: string;
89
+ };
90
+ done: {
91
+ type: string;
92
+ description: string;
93
+ };
94
+ blocker: {
95
+ type: string[];
96
+ description: string;
97
+ };
98
+ results: {
99
+ type: string;
100
+ items: {
101
+ type: string;
102
+ };
103
+ };
104
+ } | {
105
+ text?: undefined;
106
+ done: {
107
+ type: string;
108
+ description: string;
109
+ };
110
+ blocker: {
111
+ type: string[];
112
+ description: string;
113
+ };
114
+ results: {
115
+ type: string;
116
+ items: {
117
+ type: string;
118
+ };
119
+ };
120
+ };
121
+ required: string[];
122
+ type: "object";
123
+ additionalProperties: false;
124
+ } | {
86
125
  type: string;
87
126
  properties: {
88
127
  done: {
@@ -119,7 +158,7 @@ export function buildEmitArtifactSchema(stepClass: string | null | undefined, ci
119
158
  * @param {{in:number,out:number}} [opts.rates]
120
159
  * @param {string} [opts.modelId]
121
160
  * @param {Record<string,string|undefined>} [opts.env] - the merged shell+keys-file env the key is read from (default process.env).
122
- * @returns {(executorContext:object, grantedTools:Record<string,any>, stepMeta?:{class?:string, attempt?:number, step?:string|null, cited?:any, sheet?:any[]|null, withText?:boolean, picked?:any[]|null, thinkingMode?:'on'|'off'}, seam?:{stopRequested?:() => boolean}) => Promise<any>}
161
+ * @returns {(executorContext:object, grantedTools:Record<string,any>, stepMeta?:{class?:string, attempt?:number, step?:string|null, cited?:any, sheet?:any[]|null, withText?:boolean, itemShape?:any, line?:number|null, picked?:any[]|null, thinkingMode?:'on'|'off'}, seam?:{stopRequested?:() => boolean}) => Promise<any>}
123
162
  */
124
163
  export function makeLiveModelStep({ slot, model, spendPath, provider: injectedProvider, rates: injectedRates, modelId: injectedModelId, env, }: {
125
164
  slot?: string | undefined;
@@ -139,6 +178,8 @@ export function makeLiveModelStep({ slot, model, spendPath, provider: injectedPr
139
178
  cited?: any;
140
179
  sheet?: any[] | null;
141
180
  withText?: boolean;
181
+ itemShape?: any;
182
+ line?: number | null;
142
183
  picked?: any[] | null;
143
184
  thinkingMode?: "on" | "off";
144
185
  }, seam?: {
@@ -42,7 +42,7 @@ export function decidedWords(h: {
42
42
  * person's own words, taken word for word with newlines folded to spaces. A question that is not a look ask is never changed: its answer is its rule.
43
43
  * M10 am16: a shape guardrail's ask (`ask: 'check'` proposes a check, `'no-check'` found none) takes the same words: `agree` takes the proposal (and the check it
44
44
  * carries, `check`), `drop it` leaves the rule Not checked (either kind), anything else is the person's own words (`own`: a `~` rule on the line, no check).
45
- * @param {{source?: string, ask?: string, proposal?: string|null, check?: Record<string, any>}} q @param {unknown} typed @param {'agree'|'drop'|'rule'} [choice] M10 am29: the button used; absent = today's words reading (CLI, old files)
45
+ * @param {{source?: string, ask?: string, proposal?: string|null, check?: Record<string, any>, readings?: Record<string, string>}} q @param {unknown} typed @param {'agree'|'drop'|'rule'|'column'} [choice] M10 am29: the button used; absent = today's words reading (CLI, old files)
46
46
  * @returns {{rule: string|null, left: boolean, check?: Record<string, any>, own?: boolean, action?: 'known', actionLine?: string}} `rule` = the words written as a new `~` rule (null when the rule is left Not checked)
47
47
  */
48
48
  export function ruleOfAnswer(q: {
@@ -50,7 +50,8 @@ export function ruleOfAnswer(q: {
50
50
  ask?: string;
51
51
  proposal?: string | null;
52
52
  check?: Record<string, any>;
53
- }, typed: unknown, choice?: "agree" | "drop" | "rule"): {
53
+ readings?: Record<string, string>;
54
+ }, typed: unknown, choice?: "agree" | "drop" | "rule" | "column"): {
54
55
  rule: string | null;
55
56
  left: boolean;
56
57
  check?: Record<string, any>;
@@ -62,10 +63,11 @@ export function ruleOfAnswer(q: {
62
63
  export const MAX_LOOK_ASKS: 3;
63
64
  /** the answer that drops a `~` rule the page cannot check: the person types it (any case, a closing full stop allowed) */
64
65
  export const DROP_IT: "drop it";
66
+ /** M17 am9 item 3: the door's refusal of a wrong answer to a column tie (signed words) */
67
+ export const TIE_PICK_SAY: "This question has a list to choose from: pick one of the columns, or Drop it. Nothing was saved.";
65
68
  export function isDropIt(text: unknown): boolean;
66
69
  /** the answers that accept the code's reading of a rule; anything else the person types is their own reading */
67
70
  export const AGREE_WORDS: string[];
68
71
  export function isAgree(text: unknown): boolean;
69
72
  export function stripAgreeLead(text: string): string;
70
73
  export function readingQuestion(n: number, rule: string, reading: string): string;
71
- export function cantCheckQuestion(n: number, rule: string): string;
@@ -37,5 +37,4 @@ export function splitReadNotes(items: string[] | null | undefined, signed?: stri
37
37
  /** The names of the facts a signed declaration checks (every cited fact of every step). Pure. @param {any} declaration @returns {string[]} */
38
38
  export function signedFactNames(declaration: any): string[];
39
39
  export function leftRuleLine(rule: string): string;
40
- export function pickNoteLine(rule: string, reason: "no-pick" | "own-words"): string;
41
40
  export type Dropped = import("./pagerules.js").Dropped;
@@ -47,5 +47,32 @@ export function dryReadPhrases(text: string, facts: KeptFact[]): Promise<{
47
47
  dropped: Dropped[];
48
48
  reads: Record<string, number>;
49
49
  }>;
50
+ /**
51
+ * The candidate lines of a kept time fact: a LOOSE finder (it only collects). Every page line where a kept label word has a clock time anywhere
52
+ * after it; the value is that line's first time after the label. Whether the run's checker can read it is not decided here.
53
+ * @param {string} text @param {KeptFact} k @returns {{quote: string, value: string}[]}
54
+ */
55
+ export function timeCandidateLines(text: string, k: KeptFact): {
56
+ quote: string;
57
+ value: string;
58
+ }[];
59
+ /**
60
+ * AS SEEN (F337): the planner's example of one result's shape. When a signed fact's label sits on a different line than the result's first line
61
+ * (a hosted flights site: the price line, then `Departure time:` on the next), the worker must copy those lines whole; the planner is the one who can
62
+ * tell it, so the signed record keeps the exact input lines from the drafting copy. Result and label lines are found by the SAME finders the dry
63
+ * reads use (`moneyResultLines`, `timeCandidateLines`), one line at a time, so there is no second reader of "what holds this label". The first
64
+ * result is the first line holding the first labelled fact (money or time); its block runs to the next such line. Every other labelled fact must
65
+ * have its label on the first line or inside the block, else nothing is stored (never a half-example). Lines are the input's own bytes (secret-masked).
66
+ * @param {string} text the drafting copy of the input @param {any[]} facts the signed facts of one part @param {string} input the input's label
67
+ * @returns {{input: string, lines: string[], labels: string[]} | null} null when every label is on the first line, or nothing fits
68
+ */
69
+ export function asSeenOf(text: string, facts: any[], input: string): {
70
+ input: string;
71
+ lines: string[];
72
+ labels: string[];
73
+ } | null;
74
+ /** the longest "as seen" example kept: more lines or characters than this is not a result's few label lines, so nothing is stored */
75
+ export const AS_SEEN_MAX_LINES: 12;
76
+ export const AS_SEEN_MAX_CHARS: 3000;
50
77
  export type KeptFact = import("./pagerules.js").KeptFact;
51
78
  export type Dropped = import("./pagerules.js").Dropped;
@@ -66,9 +66,9 @@ export const MIN_CONTENT_CHARS: 100;
66
66
  export const PAGE_FETCH_TIMEOUT_MS: 90000;
67
67
  /**
68
68
  * @typedef {{goto: (url: string, timeout?: number) => Promise<{url: string, status: number}>, waitForNetworkIdle: (o?: {idle?: number, timeout?: number}) => Promise<void>,
69
- * snapshot: (o?: {mode?: string}) => Promise<string>, close: () => Promise<void>}} FetchPage the part of barebrowse's page handle the fetch uses
69
+ * snapshot: (o?: {mode?: string}) => Promise<string>, close: () => Promise<void>, botBlocked?: boolean}} FetchPage the part of barebrowse's page handle the fetch uses
70
70
  */
71
- /** the oldest barebrowse we accept: 0.21.0 honours CONNECT_OPTIONS (incognito, blockPrivateNetwork; an older one would drop both guards without a word); 0.24.1 tethers Chromium to its launcher, so a killed run or an Abandoned draft leaves no browser behind; 0.26.0 makes goto() resolve to {url, status}, the HTTP status an error page is refused on (M10 am13) */
71
+ /** the oldest barebrowse we accept: 0.21.0 honours CONNECT_OPTIONS (incognito, blockPrivateNetwork; an older one would drop both guards without a word); 0.24.1 tethers Chromium to its launcher, so a killed run or an Abandoned draft leaves no browser behind; 0.26.0 makes goto() resolve to {url, status}, the HTTP status an error page is refused on (M10 am13); 0.30.0 sets page.botBlocked, the flag a bot challenge is refused on (F222) */
72
72
  export const MIN_BAREBROWSE: number[];
73
73
  /**
74
74
  * the part of barebrowse's page handle the fetch uses
@@ -86,4 +86,5 @@ export type FetchPage = {
86
86
  mode?: string;
87
87
  }) => Promise<string>;
88
88
  close: () => Promise<void>;
89
+ botBlocked?: boolean;
89
90
  };
@@ -72,6 +72,10 @@ export type MapFact = {
72
72
  };
73
73
  export type PageMap = {
74
74
  facts: MapFact[];
75
+ cannot?: {
76
+ from?: string;
77
+ why?: string;
78
+ }[];
75
79
  };
76
80
  /**
77
81
  * `words` = what the page proves: the labels of a money/number/time fact, or the alternative phrases of a phrase fact (a place is a phrase)
@@ -61,10 +61,10 @@ export function readDelivered(rec: {
61
61
  buf: null;
62
62
  };
63
63
  /**
64
- * The files this run's signed sends wrote: for each signed send whose send step ended green in the audit, the file `<flow>-<runId>-<emits>.md`
64
+ * The files this run's signed sends wrote: for each signed send whose send step ended green in the audit, the file `<job>-YYYY-MM-DD[-n].md` (`sentName`, M15 am3; older runs: `<flow>-<runId>-<emits>.md`)
65
65
  * in the signed folder with the sha256 the send recorded for it (M15), or, for a send older than M15, `.json` with the sha256 the human's accept recorded for the ask that
66
66
  * send reads (`readAcceptedHashesByEmits`, the same record the send itself checked). No accepted hash = recorded as null, which reads as "changed", never as ok.
67
- * @returns {{path: string, dir: string|null, name: string, sha256: string|null}[]}
67
+ * @returns {{path: string, dir: string|null, name: string, note: string|null, sha256: string|null}[]}
68
68
  */
69
69
  export function deliveredOf({ arbiter, declaration, runDir, root, flow, runId, auditRows, }: {
70
70
  arbiter: any;
@@ -78,8 +78,24 @@ export function deliveredOf({ arbiter, declaration, runDir, root, flow, runId, a
78
78
  path: string;
79
79
  dir: string | null;
80
80
  name: string;
81
+ note: string | null;
81
82
  sha256: string | null;
82
83
  }[];
84
+ /**
85
+ * borrowed-from: bareloop src/panel/server.js@v0.61.0 (`shapeRedsFromRecords`, the gap-line half), adjusted to fwdloop's books: a run records the close's plain gap lines on its audit and log.json attempt rows (never bareguard's per-row record),
86
+ * and a red run's judged answer is the model output of that attempt in log.json. A shape line's answer for the Result tab: the delivered artifact (the step closed green: no item is red) or, for a red run, the step's last red attempt
87
+ * with the item reds read back from its plain gap lines through `shapeItemOfPlain`. Third outcome: nothing readable is `null` (the page says "no saved result to show").
88
+ * @param {{runDir: string, step: any, line: number, logJson: any}} a @returns {{results: any[], reds: string[]}|null}
89
+ */
90
+ export function shapeAnswerOf({ runDir, step, line, logJson }: {
91
+ runDir: string;
92
+ step: any;
93
+ line: number;
94
+ logJson: any;
95
+ }): {
96
+ results: any[];
97
+ reds: string[];
98
+ } | null;
83
99
  /**
84
100
  * The Result tab's JSON for one run (`GET /api/runs/:flow/:runId/result`).
85
101
  * @param {{flow: string, runId: string, runDir: string, root: string, flowRead: any, arbiter: any, historyRow: any, auditRows: any[], logJson: any, notChecked: string[], readNotes?: string[], setupRows?: any[], door?: {askId: string, draftNo: number}|null}} a
@@ -117,6 +133,7 @@ export function buildResult({ flow, runId, runDir, root, flowRead, arbiter, hist
117
133
  bytes: number | null;
118
134
  state: "ok" | "changed" | "gone";
119
135
  words: string | null;
136
+ note: string | null;
120
137
  }[];
121
138
  gap: {
122
139
  line: string;
@@ -71,6 +71,16 @@ export function readRowChoices(file: string): {
71
71
  tail: string;
72
72
  choice: string;
73
73
  }[] | null;
74
+ /**
75
+ * Shape jobs (clause 4): the shape fields a person dropped from a plan, carried like the sheet's (the block's `shapeDroppedRecord`: `{lineWords, occurrence, name}` or `{lineWords, occurrence, rule}`), so a Revise keeps a Drop of the very same field. A missing or unreadable record is no record.
76
+ * @param {string} file @returns {{lineWords: string, occurrence: number, name?: string, rule?: number}[]|null}
77
+ */
78
+ export function readShapeDropped(file: string): {
79
+ lineWords: string;
80
+ occurrence: number;
81
+ name?: string;
82
+ rule?: number;
83
+ }[] | null;
74
84
  /**
75
85
  * The sheet checks the person dropped from a plan (hamr 2026-11-14: a Revise keeps a sheet Drop), carried like the page-row choices: the record's `sheetDropped` entries, each `{key, line, index, check, text}`;
76
86
  * the next draft drops a new check with the same id again. Read through readFileInside; a missing or unreadable record is no record.
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Is `err` an HTTP 429 (rate-limited) response? True ONLY for an explicit
3
+ * status of 429 on the error itself. Nothing else qualifies — not message
4
+ * text (a message merely containing "429" is not this), not `retryable`,
5
+ * not any other status. Symmetric with `isTransportFailure`'s own status
6
+ * check (src/transport.js), just reading the opposite branch of it.
7
+ * @param {any} err
8
+ * @returns {boolean}
9
+ */
10
+ export function isRateLimited(err: any): boolean;
11
+ /**
12
+ * The vendor's RAW stated wait, in milliseconds, parsed straight from the
13
+ * error message — no default, no margin, no cap. `null` when nothing in the
14
+ * message matches a known shape. Exported separately from `rateLimitWaitMs`
15
+ * so a caller that wants to report the vendor's own number on the spine
16
+ * (`statedMs`) never has to re-derive it from the margin-adjusted figure.
17
+ *
18
+ * bare-agent does not expose the vendor's `retry-after` /
19
+ * `x-ratelimit-reset-*` response headers on the thrown error (BA-26) — the
20
+ * delay exists only in the vendor's English message text, so this parses
21
+ * that text. Verified real shape (a hosted provider, run `8ev2sdkn`, 2026-09-08):
22
+ * "Please try again in 11.996s." This also supports "try again in 1.5
23
+ * seconds", "try again in 20ms", "retry after 30s", and "retry after 30
24
+ * seconds" — case-insensitive.
25
+ * @param {any} err
26
+ * @returns {number|null}
27
+ */
28
+ export function statedWaitMs(err: any): number | null;
29
+ /**
30
+ * How long to wait before retrying a 429, in milliseconds — or `null`
31
+ * meaning "do not retry at all" (either the parsed wait exceeds
32
+ * `RATE_LIMIT_MAX_WAIT_MS`, in which case waiting that long is the
33
+ * operator's decision, not ours).
34
+ *
35
+ * A parsed value gets `PARSED_DELAY_MARGIN_MS` added (the vendor's stated
36
+ * number is the earliest moment its window resets, not a safe one to fire
37
+ * on), capped so the margin itself can never push a parsed value over
38
+ * `RATE_LIMIT_MAX_WAIT_MS`. When nothing parses, `RATE_LIMIT_DEFAULT_WAIT_MS`
39
+ * is returned as-is, with no margin added (there is nothing to add margin
40
+ * to — it is already a conservative guess, not an earliest-moment reading).
41
+ * @param {any} err
42
+ * @returns {number|null}
43
+ */
44
+ export function rateLimitWaitMs(err: any): number | null;
45
+ /** The fixed retry budget: ONE extra attempt after a 429. Never read from a
46
+ * job spec or CLI flag — raising it is arbiter territory, mirroring
47
+ * transport.js's TRANSPORT_RETRIES exactly (tighten-only doctrine). */
48
+ export const RATE_LIMIT_RETRIES: 1;
49
+ /** bare-agent's `Retry.call` (if ever used) counts ATTEMPTS, not retries;
50
+ * this module's own hand-rolled ladder (src/planrun.js) does the same for
51
+ * symmetry with TRANSPORT_MAX_ATTEMPTS. */
52
+ export const RATE_LIMIT_MAX_ATTEMPTS: number;
53
+ /** The hard cap on how long we will ever wait for a vendor-stated 429 delay.
54
+ * A vendor asking for longer than this is not honoured — we do not retry at
55
+ * all in that case. Waiting that long is the operator's decision, not ours
56
+ * (arbiter territory: nothing here escalates the wait past what hamr set). */
57
+ export const RATE_LIMIT_MAX_WAIT_MS: 60000;
58
+ /** Used only when the vendor's message carries no parseable delay at all. */
59
+ export const RATE_LIMIT_DEFAULT_WAIT_MS: 5000;
@@ -0,0 +1,46 @@
1
+ /**
2
+ * claim id -> the sentence of the first passed non-sumIf/countIf check carrying it; a claim only sumIf/countIf carry is null. `okIds` = the ids of the checks that passed, or null = no record (all count).
3
+ * @param {any[]} checks @param {Set<string>|null} okIds @returns {Record<string, string|null>}
4
+ */
5
+ export function claimWordsOf(checks: any[], okIds: Set<string> | null): Record<string, string | null>;
6
+ /** the date as plain words, `18 Nov 2026`, in the machine's local day (the day the dated file names use) @param {Date} d */
7
+ export function plainDate(d: Date): string;
8
+ /** the run number when the run id reads `run-N`, else null (a rerun id `run-1-rerun-1` has none) @param {string} runId @returns {number|null} */
9
+ export function runNumberOf(runId: string): number | null;
10
+ /**
11
+ * The body: every line before the send, in job order. A work line is `## <n>. <text>`, a `Rule:` per ~ rule, `### Checked by code` (bullets) and the AI's text under its heading; an Ask line is one line
12
+ * in its place; a work line with nothing to write has no section. Pure.
13
+ * @param {{n: number, kind: 'ask'|'work', text?: string, rules?: string[], artifact?: unknown, checks?: any[], okIds?: Set<string>|null, proseChecked?: boolean, shape?: any}[]} lines
14
+ * @param {Record<string, any>} tables the frozen sheets by input name
15
+ * @returns {string}
16
+ */
17
+ export function renderReportBody(lines: {
18
+ n: number;
19
+ kind: "ask" | "work";
20
+ text?: string;
21
+ rules?: string[];
22
+ artifact?: unknown;
23
+ checks?: any[];
24
+ okIds?: Set<string> | null;
25
+ proseChecked?: boolean;
26
+ shape?: any;
27
+ }[], tables: Record<string, any>): string;
28
+ /**
29
+ * The file name for a report: `<job>-YYYY-MM-DD.md`, then `<job>-YYYY-MM-DD-2.md`, `-3`, ... the first one that is free in `dir` (the machine's local day). Never a taken name. `taken` = the first choice
30
+ * when it was not free (the Result tab's note names it), else null. `name` = null when every name up to -99 is taken.
31
+ * @param {string} dir the Destination folder @param {string} job @param {Date} now
32
+ * @returns {{name: string|null, taken: string|null}}
33
+ */
34
+ export function nextFreeName(dir: string, job: string, now: Date): {
35
+ name: string | null;
36
+ taken: string | null;
37
+ };
38
+ /** the words under a not-checked answer and a checked one (M15 am3 item 2) */
39
+ export const NOT_CHECKED_HEADING: "### The AI's answer (not checked \u2014 you judge it at Accept)";
40
+ export const CHECKED_HEADING: "### The answer";
41
+ export function askLineWords(n: number): string;
42
+ export function REPORT_RENAMED(taken: string): string;
43
+ export function reportHead(job: string, runNo: number | null, now: Date): string;
44
+ export function reportFileText(job: string, runNo: number | null, now: Date, body: string): string;
45
+ /** the most same-day names tried before the send stops (bareloop's MAX_SAME_DAY) */
46
+ export const MAX_SAME_DAY: 99;
@@ -0,0 +1,28 @@
1
+ /**
2
+ * @typedef {{key: string, result: 'passed'|'failed'|'unread', why?: string}} RowResult
3
+ * @param {any[]|null|undefined} list the signed list (`closeDecl.list`) @param {{step: number, parts: any[]}} params the rubric-step stage's params
4
+ * @param {{verdict?: string, rawGaps?: any[], extraGaps?: string[], detail?: Record<string, any>, ruleCounts?: Record<number, {min?: number, max?: number}>}} graded `gradeStep`'s answer (`ruleCounts`: fwd's, the bounds of the rules that count items)
5
+ * @returns {{rows: RowResult[], unclaimed: string[], items?: string[]}}
6
+ */
7
+ export function rowResultsOf(list: any[] | null | undefined, params: {
8
+ step: number;
9
+ parts: any[];
10
+ }, graded: {
11
+ verdict?: string;
12
+ rawGaps?: any[];
13
+ extraGaps?: string[];
14
+ detail?: Record<string, any>;
15
+ ruleCounts?: Record<number, {
16
+ min?: number;
17
+ max?: number;
18
+ }>;
19
+ }): {
20
+ rows: RowResult[];
21
+ unclaimed: string[];
22
+ items?: string[];
23
+ };
24
+ export type RowResult = {
25
+ key: string;
26
+ result: "passed" | "failed" | "unread";
27
+ why?: string;
28
+ };
@@ -41,6 +41,27 @@ export function listMatchesClose(closeDecl: any): {
41
41
  ok: false;
42
42
  error: string;
43
43
  };
44
+ /**
45
+ * FACTS + SHAPE: the extra lines of a fact line's brief when its close also carries an itemShape part (code-written, never model-written): each result also carries the shape fields, in plain words, with ONE example result
46
+ * built by code (the quote and values placeholders, then a legal value for each shape field). Nothing is added for a line with no shape part.
47
+ * @param {any} shape the line's shape part ({fields, minItems?, maxItems?}) @param {any} fp the fact part @returns {string[]}
48
+ */
49
+ export function shapeBriefOf(shape: any, fp: any): string[];
50
+ /**
51
+ * A SHAPE line's brief (no fact part): the answer is a list of items, each field in plain words (the signed bounds, in the person's own form) and ONE worked example item, all written by code from the signed shape.
52
+ * `alsoText` = the line also carries the person's picks (its answer has `text` too).
53
+ * @param {number} n the job line @param {any} shape the line's shape part @param {boolean} [alsoText] @returns {string}
54
+ */
55
+ export function shapeLineBrief(n: number, shape: any, alsoText?: boolean): string;
56
+ /**
57
+ * The plain sentence of a bareguard gap of one line's answer, as the tag's `plainStepGap` takes it (step, why, gap, params). fwd's step has no file, so an itemShape gap's file is `the answer` (src/closers.js); only an itemShape gap
58
+ * is worded here (fwd's other gaps keep their own words in src/closers.js and src/citedcheck.js).
59
+ * @param {number} step the job line @param {string} _why @param {any} g a bareguard gap @param {any} [_params] @returns {string}
60
+ */
61
+ export function plainStepGap(step: number, _why: string, g: any, _params?: any): string;
62
+ export function stageKeyOf(name: string): string;
63
+ export function guardKeyOf(name: string): string;
64
+ export const FENCE_KEY: "J.$fence";
44
65
  /** the closed set of classes a part is sorted into; `none` = "I could not sort this one" (a red, in plain words, never a guess) */
45
66
  export const PART_CLASSES: readonly string[];
46
67
  /**