fwdloop 0.32.0 → 0.33.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 (93) hide show
  1. package/bin/fwdloop +8 -2
  2. package/package.json +2 -2
  3. package/src/auditchecks.js +53 -0
  4. package/src/authoring.js +52 -12
  5. package/src/blockasks.js +44 -0
  6. package/src/blockassemble.js +140 -0
  7. package/src/blockdraft.js +91 -0
  8. package/src/blocklines.js +30 -0
  9. package/src/blockpick.js +165 -0
  10. package/src/cardlist.js +19 -0
  11. package/src/checkblock.js +804 -0
  12. package/src/checked.js +48 -9
  13. package/src/checklist.js +99 -0
  14. package/src/checklistsign.js +93 -0
  15. package/src/checkwords.js +20 -1
  16. package/src/cited-record.js +21 -1
  17. package/src/citedcheck.js +162 -7
  18. package/src/closers.js +41 -3
  19. package/src/declaration.js +25 -2
  20. package/src/declaredclose.js +4 -0
  21. package/src/draft-steps.js +3 -1
  22. package/src/drafter.js +205 -122
  23. package/src/factwords.js +112 -0
  24. package/src/inputlook.js +53 -0
  25. package/src/labelscan.js +162 -0
  26. package/src/pageask.js +4 -1
  27. package/src/pagedropwords.js +11 -1
  28. package/src/panel/author.js +73 -4
  29. package/src/panel/authorcard.js +9 -6
  30. package/src/panel/data.js +41 -9
  31. package/src/panel/index.html +202 -13
  32. package/src/panel/result.js +4 -3
  33. package/src/panel/server.js +3 -1
  34. package/src/pickrecord.js +28 -0
  35. package/src/placerule.js +398 -0
  36. package/src/planrebuild.js +206 -0
  37. package/src/rowedit.js +118 -0
  38. package/src/rubricstep.js +264 -0
  39. package/src/runfile.js +4 -2
  40. package/src/runner.js +67 -10
  41. package/src/setup.js +10 -4
  42. package/src/sheetblock.js +6 -2
  43. package/src/sheetchecks.js +49 -64
  44. package/src/sheetclaims.js +12 -32
  45. package/src/sheetoffer.js +24 -52
  46. package/src/sheetrows.js +107 -0
  47. package/src/sheetrun.js +13 -10
  48. package/src/summary-words.js +3 -3
  49. package/src/try-checks.js +31 -12
  50. package/src/types.js +1 -0
  51. package/types/auditchecks.d.ts +24 -0
  52. package/types/authoring.d.ts +18 -1
  53. package/types/blockasks.d.ts +37 -0
  54. package/types/blockassemble.d.ts +33 -0
  55. package/types/blockdraft.d.ts +83 -0
  56. package/types/blocklines.d.ts +31 -0
  57. package/types/blockpick.d.ts +41 -0
  58. package/types/cardlist.d.ts +21 -0
  59. package/types/checkblock.d.ts +363 -0
  60. package/types/checked.d.ts +16 -2
  61. package/types/checklist.d.ts +115 -0
  62. package/types/checklistsign.d.ts +27 -0
  63. package/types/checkwords.d.ts +5 -0
  64. package/types/cited-record.d.ts +9 -0
  65. package/types/citedcheck.d.ts +33 -2
  66. package/types/closers.d.ts +24 -2
  67. package/types/declaredclose.d.ts +2 -0
  68. package/types/drafter.d.ts +15 -361
  69. package/types/factwords.d.ts +38 -0
  70. package/types/inputlook.d.ts +49 -0
  71. package/types/labelscan.d.ts +35 -0
  72. package/types/pageask.d.ts +2 -0
  73. package/types/panel/author.d.ts +41 -0
  74. package/types/panel/authorcard.d.ts +1 -1
  75. package/types/panel/data.d.ts +4 -2
  76. package/types/panel/jobgrid.d.ts +1 -1
  77. package/types/pickrecord.d.ts +22 -0
  78. package/types/placerule.d.ts +208 -0
  79. package/types/planrebuild.d.ts +52 -0
  80. package/types/provider.d.ts +1 -1
  81. package/types/rowedit.d.ts +33 -0
  82. package/types/rubricstep.d.ts +60 -0
  83. package/types/runfile.d.ts +5 -2
  84. package/types/runner.d.ts +45 -1
  85. package/types/sheetblock.d.ts +1 -0
  86. package/types/sheetchecks.d.ts +10 -17
  87. package/types/sheetclaims.d.ts +2 -1
  88. package/types/sheetoffer.d.ts +5 -5
  89. package/types/sheetrows.d.ts +73 -0
  90. package/types/sheetrun.d.ts +4 -4
  91. package/types/summary-words.d.ts +2 -1
  92. package/types/try-checks.d.ts +4 -2
  93. package/types/types.d.ts +8 -0
@@ -0,0 +1,2 @@
1
+ /** the fields of a row of the one check list that the signed close carries (`closeDecl.list`); the row's own words are never signed */
2
+ export const SIGNED_ROW_FIELDS: readonly string[];
@@ -2,6 +2,7 @@
2
2
  * The forced tool's parameter schema. `menu` = wiredMenu(). `sheets` (M10b piece 3, optional) = the drafting copy's table of each CSV input role: with it a step may carry
3
3
  * `close.sheet`, and every column a check names is an enum of that sheet's exact header (src/sheetoffer.js); without it (no CSV input) no sheet property exists.
4
4
  * M13 piece 4: `ticket` = `{flowType, tools}` for MCP (generic) and Tickets; then a step may carry `mcpTools` (an enum of the job's tools) and, for Tickets, the tool carries `ticketFilter` and `ticketWatch` (src/ticket-draft.js). The job's `mcp` block and `flowType` are set by code, never offered.
5
+ * M16 item 5: the AI is offered no `close.cited` (the list owns the facts; code builds them from its rows).
5
6
  * @param {any[]} menu @param {{sheets?: Record<string, {header: string[]}>, ticket?: {flowType: 'mcp'|'tickets', tools: string[]}}} [o]
6
7
  */
7
8
  export function buildDeclarationSchema(menu: any[], { sheets, ticket }?: {
@@ -91,95 +92,6 @@ export function buildDeclarationSchema(menu: any[], { sheets, ticket }?: {
91
92
  enum: string[];
92
93
  description: string;
93
94
  };
94
- cited: Readonly<{
95
- type: "object";
96
- 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";
97
- properties: {
98
- source: {
99
- type: string;
100
- description: string;
101
- };
102
- facts: {
103
- type: string;
104
- minItems: number;
105
- maxItems: number;
106
- description: string;
107
- items: {
108
- type: string;
109
- properties: {
110
- name: {
111
- type: string;
112
- description: string;
113
- };
114
- shape: {
115
- type: string;
116
- enum: string[];
117
- };
118
- unit: {
119
- type: string[];
120
- items: {
121
- type: string;
122
- };
123
- description: string;
124
- };
125
- currency: {
126
- type: string[];
127
- items: {
128
- type: string;
129
- };
130
- description: string;
131
- };
132
- phrase: {
133
- type: string;
134
- description: string;
135
- };
136
- anchor: {
137
- type: string;
138
- description: string;
139
- };
140
- until: {
141
- type: string;
142
- description: string;
143
- };
144
- rule: {
145
- type: string;
146
- description: string;
147
- properties: {
148
- op: {
149
- type: string;
150
- enum: string[];
151
- };
152
- value: {};
153
- lo: {};
154
- hi: {};
155
- };
156
- required: string[];
157
- additionalProperties: boolean;
158
- };
159
- };
160
- required: string[];
161
- additionalProperties: boolean;
162
- };
163
- };
164
- count: {
165
- type: string;
166
- description: string;
167
- properties: {
168
- min: {
169
- type: string;
170
- minimum: number;
171
- };
172
- max: {
173
- type: string;
174
- minimum: number;
175
- };
176
- };
177
- additionalProperties: boolean;
178
- };
179
- };
180
- required: string[];
181
- additionalProperties: false;
182
- }>;
183
95
  columns: Readonly<{
184
96
  type: "array";
185
97
  minItems: 1;
@@ -331,95 +243,6 @@ export function buildDeclarationSchema(menu: any[], { sheets, ticket }?: {
331
243
  enum: string[];
332
244
  description: string;
333
245
  };
334
- cited: Readonly<{
335
- type: "object";
336
- 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";
337
- properties: {
338
- source: {
339
- type: string;
340
- description: string;
341
- };
342
- facts: {
343
- type: string;
344
- minItems: number;
345
- maxItems: number;
346
- description: string;
347
- items: {
348
- type: string;
349
- properties: {
350
- name: {
351
- type: string;
352
- description: string;
353
- };
354
- shape: {
355
- type: string;
356
- enum: string[];
357
- };
358
- unit: {
359
- type: string[];
360
- items: {
361
- type: string;
362
- };
363
- description: string;
364
- };
365
- currency: {
366
- type: string[];
367
- items: {
368
- type: string;
369
- };
370
- description: string;
371
- };
372
- phrase: {
373
- type: string;
374
- description: string;
375
- };
376
- anchor: {
377
- type: string;
378
- description: string;
379
- };
380
- until: {
381
- type: string;
382
- description: string;
383
- };
384
- rule: {
385
- type: string;
386
- description: string;
387
- properties: {
388
- op: {
389
- type: string;
390
- enum: string[];
391
- };
392
- value: {};
393
- lo: {};
394
- hi: {};
395
- };
396
- required: string[];
397
- additionalProperties: boolean;
398
- };
399
- };
400
- required: string[];
401
- additionalProperties: boolean;
402
- };
403
- };
404
- count: {
405
- type: string;
406
- description: string;
407
- properties: {
408
- min: {
409
- type: string;
410
- minimum: number;
411
- };
412
- max: {
413
- type: string;
414
- minimum: number;
415
- };
416
- };
417
- additionalProperties: boolean;
418
- };
419
- };
420
- required: string[];
421
- additionalProperties: false;
422
- }>;
423
246
  columns: Readonly<{
424
247
  type: "array";
425
248
  minItems: 1;
@@ -566,95 +389,6 @@ export function buildRoundSchema(menu: any[], { questions, sheets, ticket }?: {
566
389
  enum: string[];
567
390
  description: string;
568
391
  };
569
- cited: Readonly<{
570
- type: "object";
571
- 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";
572
- properties: {
573
- source: {
574
- type: string;
575
- description: string;
576
- };
577
- facts: {
578
- type: string;
579
- minItems: number;
580
- maxItems: number;
581
- description: string;
582
- items: {
583
- type: string;
584
- properties: {
585
- name: {
586
- type: string;
587
- description: string;
588
- };
589
- shape: {
590
- type: string;
591
- enum: string[];
592
- };
593
- unit: {
594
- type: string[];
595
- items: {
596
- type: string;
597
- };
598
- description: string;
599
- };
600
- currency: {
601
- type: string[];
602
- items: {
603
- type: string;
604
- };
605
- description: string;
606
- };
607
- phrase: {
608
- type: string;
609
- description: string;
610
- };
611
- anchor: {
612
- type: string;
613
- description: string;
614
- };
615
- until: {
616
- type: string;
617
- description: string;
618
- };
619
- rule: {
620
- type: string;
621
- description: string;
622
- properties: {
623
- op: {
624
- type: string;
625
- enum: string[];
626
- };
627
- value: {};
628
- lo: {};
629
- hi: {};
630
- };
631
- required: string[];
632
- additionalProperties: boolean;
633
- };
634
- };
635
- required: string[];
636
- additionalProperties: boolean;
637
- };
638
- };
639
- count: {
640
- type: string;
641
- description: string;
642
- properties: {
643
- min: {
644
- type: string;
645
- minimum: number;
646
- };
647
- max: {
648
- type: string;
649
- minimum: number;
650
- };
651
- };
652
- additionalProperties: boolean;
653
- };
654
- };
655
- required: string[];
656
- additionalProperties: false;
657
- }>;
658
392
  columns: Readonly<{
659
393
  type: "array";
660
394
  minItems: 1;
@@ -813,95 +547,6 @@ export function buildRoundSchema(menu: any[], { questions, sheets, ticket }?: {
813
547
  enum: string[];
814
548
  description: string;
815
549
  };
816
- cited: Readonly<{
817
- type: "object";
818
- 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";
819
- properties: {
820
- source: {
821
- type: string;
822
- description: string;
823
- };
824
- facts: {
825
- type: string;
826
- minItems: number;
827
- maxItems: number;
828
- description: string;
829
- items: {
830
- type: string;
831
- properties: {
832
- name: {
833
- type: string;
834
- description: string;
835
- };
836
- shape: {
837
- type: string;
838
- enum: string[];
839
- };
840
- unit: {
841
- type: string[];
842
- items: {
843
- type: string;
844
- };
845
- description: string;
846
- };
847
- currency: {
848
- type: string[];
849
- items: {
850
- type: string;
851
- };
852
- description: string;
853
- };
854
- phrase: {
855
- type: string;
856
- description: string;
857
- };
858
- anchor: {
859
- type: string;
860
- description: string;
861
- };
862
- until: {
863
- type: string;
864
- description: string;
865
- };
866
- rule: {
867
- type: string;
868
- description: string;
869
- properties: {
870
- op: {
871
- type: string;
872
- enum: string[];
873
- };
874
- value: {};
875
- lo: {};
876
- hi: {};
877
- };
878
- required: string[];
879
- additionalProperties: boolean;
880
- };
881
- };
882
- required: string[];
883
- additionalProperties: boolean;
884
- };
885
- };
886
- count: {
887
- type: string;
888
- description: string;
889
- properties: {
890
- min: {
891
- type: string;
892
- minimum: number;
893
- };
894
- max: {
895
- type: string;
896
- minimum: number;
897
- };
898
- };
899
- additionalProperties: boolean;
900
- };
901
- };
902
- required: string[];
903
- additionalProperties: false;
904
- }>;
905
550
  columns: Readonly<{
906
551
  type: "array";
907
552
  minItems: 1;
@@ -969,13 +614,13 @@ export function normalizeQuestions(raw: any, failedLines: any): {
969
614
  };
970
615
  /**
971
616
  * The job lines as the page look may see them (no count rule), and `toOriginal`, which takes a look fact's / dropped entry's visible rule number back to the guardrail's own number.
972
- * @param {{n: number, text: string, rule?: string}[]} jobLines
617
+ * @param {{n: number, text: string, rule?: string}[]} jobLines @param {Set<number>} [shown] lines whose count rules the look may see (M16: the block's lines)
973
618
  */
974
619
  export function hideCounts(jobLines: {
975
620
  n: number;
976
621
  text: string;
977
622
  rule?: string;
978
- }[]): {
623
+ }[], shown?: Set<number>): {
979
624
  seenLines: {
980
625
  rule?: string | undefined;
981
626
  n: number;
@@ -983,11 +628,12 @@ export function hideCounts(jobLines: {
983
628
  }[];
984
629
  toOriginal: (f: any) => any;
985
630
  };
986
- export function buildSystemPrompt({ menu, lines, arbiter, factsInfo }: {
631
+ export function buildSystemPrompt({ menu, lines, arbiter, factsInfo, blockLines }: {
987
632
  menu: any;
988
633
  lines: any;
989
634
  arbiter: any;
990
635
  factsInfo: any;
636
+ blockLines?: Set<number> | undefined;
991
637
  }): string;
992
638
  /**
993
639
  * A step's goal = its signed line's text, exactly as parseSignedText's `lines` gives it: the words after
@@ -1008,11 +654,11 @@ export function goalForLine(fromLine: any, lines: any): any;
1008
654
  * @returns {Promise<{ok:boolean, declaration:object|null, reds:string[], rounds:number, calls:number, spendComplete:boolean,
1009
655
  * costUsd:number|null, modelReturned:string|null, modelId?:string, price?:object|null, tokens?:object|null, structureRetries:number, revisions:number, stop:string|null, log:object[],
1010
656
  * questions?:{line:number, question:string}[], droppedQuestions?:object[], notChecked?:string[], thinking?:{asked:string, status:string|null, say:string|null}, inputs?:{role:string, detail:string}[],
1011
- * look?:{facts:any[], dropped:any[]}, pageLooks?:{role:string, address:string, sha256:string, bytes:number, frozen:string, attempts:number, mapping:any}[], sheetLooks?:any[]}>}
657
+ * 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[]}>}
1012
658
  * `learnHints` (M8 item 5a): the earlier runs' notes block (src/learnstore.js hintsForRun), appended to the drafter's system prompt; null = nothing.
1013
659
  * `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`.
1014
660
  */
1015
- export function draft({ proseText, slot, model, provider: injected, rates: injectedRates, modelId: injectedModelId, env, priorSpend, skills, makeProviderFn, onBook, offerQuestions, draftThinking, draftDir, fetchPage, leftRules, checkPicks, carriedPicks, onPickRecord, learnHints, mcpServers, flowType, mcp, }: {
661
+ export function draft({ proseText, slot, model, provider: injected, rates: injectedRates, modelId: injectedModelId, env, priorSpend, skills, makeProviderFn, onBook, offerQuestions, draftThinking, draftDir, fetchPage, leftRules, checkPicks, carriedPicks, carriedChoices, carriedSheetDropped, onSheetDropped, onChoices, onPickRecord, learnHints, mcpServers, flowType, mcp, }: {
1016
662
  proseText: any;
1017
663
  slot: any;
1018
664
  model: any;
@@ -1034,6 +680,10 @@ export function draft({ proseText, slot, model, provider: injected, rates: injec
1034
680
  }[] | undefined;
1035
681
  checkPicks?: import("./checkpick.js").Pick[] | undefined;
1036
682
  carriedPicks?: import("./pickrecord.js").Entry[] | undefined;
683
+ carriedChoices?: any[] | null | undefined;
684
+ carriedSheetDropped?: any[] | undefined;
685
+ onSheetDropped?: ((rec: any[]) => void) | undefined;
686
+ onChoices?: ((rec: any[]) => void) | undefined;
1037
687
  onPickRecord?: ((r: {
1038
688
  picks: import("./pickrecord.js").Entry[];
1039
689
  kept: {
@@ -1081,6 +731,8 @@ export function draft({ proseText, slot, model, provider: injected, rates: injec
1081
731
  role: string;
1082
732
  detail: string;
1083
733
  }[];
734
+ checkCard?: ReturnType<typeof cardOfBlock>;
735
+ notCheckedBy?: Record<string, "you" | "agent" | "default">;
1084
736
  look?: {
1085
737
  facts: any[];
1086
738
  dropped: any[];
@@ -1103,6 +755,7 @@ export const DRAFT_SKILLS: readonly string[];
1103
755
  export const CLASSES: readonly string[];
1104
756
  /** The whole-output-ceiling rule, told once to the drafter (schema and prompt use this string). Amendment 29; no number words (am25). */
1105
757
  export const WHOLE_OUTPUT_CEILING_RULE: "use the guardrail's ceiling for the whole output";
758
+ export function docRolesOf(sources: any[] | undefined): string[];
1106
759
  export const MAX_QUESTIONS: 2;
1107
760
  /** What fwdloop's typed checks can really check (bareloop F174: give the model the real list, or "Not checked" is invented). */
1108
761
  export const CHECKABLE: readonly string[];
@@ -1111,3 +764,4 @@ export const NOTCHECKED_PROMPT: string;
1111
764
  /** 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. */
1112
765
  export const QUESTIONS_PROMPT: string;
1113
766
  import { makeProvider } from './provider.js';
767
+ import { cardOfBlock } from './cardlist.js';
@@ -0,0 +1,38 @@
1
+ /**
2
+ * What the page-word map (src/pagemap.js) KEPT and DROPPED for one input: the sets the second proof reads. A look from the old search-and-read
3
+ * path has no `dropped` list, so it gives null and the label is proved against the code-made list as before.
4
+ * @param {{facts?: any[], dropped?: (import('./pagerules.js').Dropped & {source?: string})[]}|null|undefined} look @param {string} source
5
+ * @returns {{labels: Set<string>, units: Set<string>, currencies: Set<string>, words: Set<string>, dropped: Map<string, import('./pagerules.js').Dropped>, forms: {labels: Set<string>, lang?: string, decimal?: string}[]}|null}
6
+ */
7
+ export function keptSetOf(look: {
8
+ facts?: any[];
9
+ dropped?: (import("./pagerules.js").Dropped & {
10
+ source?: string;
11
+ })[];
12
+ } | null | undefined, source: string): {
13
+ labels: Set<string>;
14
+ units: Set<string>;
15
+ currencies: Set<string>;
16
+ words: Set<string>;
17
+ dropped: Map<string, import("./pagerules.js").Dropped>;
18
+ forms: {
19
+ labels: Set<string>;
20
+ lang?: string;
21
+ decimal?: string;
22
+ }[];
23
+ } | null;
24
+ /**
25
+ * The reds for ONE fact part against its frozen source text.
26
+ * @param {{part: any, text: string, line: number|string, scan?: import('./labelscan.js').LabelScan, kept?: ReturnType<typeof keptSetOf>}} o
27
+ * @returns {{code: string, detail: string}[]}
28
+ */
29
+ export function checkFactWords({ part, text, line, scan, kept }: {
30
+ part: any;
31
+ text: string;
32
+ line: number | string;
33
+ scan?: import("./labelscan.js").LabelScan;
34
+ kept?: ReturnType<typeof keptSetOf>;
35
+ }): {
36
+ code: string;
37
+ detail: string;
38
+ }[];
@@ -0,0 +1,49 @@
1
+ /** @typedef {{line: number, name: string, shape: string, source: string, label?: string, labelId?: string, value?: string, phrase?: string, example: string, rule?: any, aiProposal?: boolean, forRule?: number, reading?: import('./pagerules.js').Reading,
2
+ * words?: string[], labels?: string[], unit?: string[], currency?: string[], lang?: string, decimal?: string}} LookFact `words` / `labels` / `unit` / `currency`: what the page-word map kept (idea A core) */
3
+ /** @typedef {{line: number, rule?: number, words?: string, why: string}} LookNotFound */
4
+ /** @typedef {{facts: LookFact[], prose: {line: number, text?: string}[], notFound: LookNotFound[], dropped?: import('./pagerules.js').Dropped[]}} LookReport */
5
+ /**
6
+ * The look's report as the DRAFTER reads it: one block, per job line, of what can be checked (with the exact words to copy) and what
7
+ * could not be found. Written by code from the verified report.
8
+ * @param {LookReport} report @returns {string}
9
+ */
10
+ export function renderLookReport(report: LookReport): string;
11
+ /**
12
+ * `words` / `labels` / `unit` / `currency`: what the page-word map kept (idea A core)
13
+ */
14
+ export type LookFact = {
15
+ line: number;
16
+ name: string;
17
+ shape: string;
18
+ source: string;
19
+ label?: string;
20
+ labelId?: string;
21
+ value?: string;
22
+ phrase?: string;
23
+ example: string;
24
+ rule?: any;
25
+ aiProposal?: boolean;
26
+ forRule?: number;
27
+ reading?: import("./pagerules.js").Reading;
28
+ words?: string[];
29
+ labels?: string[];
30
+ unit?: string[];
31
+ currency?: string[];
32
+ lang?: string;
33
+ decimal?: string;
34
+ };
35
+ export type LookNotFound = {
36
+ line: number;
37
+ rule?: number;
38
+ words?: string;
39
+ why: string;
40
+ };
41
+ export type LookReport = {
42
+ facts: LookFact[];
43
+ prose: {
44
+ line: number;
45
+ text?: string;
46
+ }[];
47
+ notFound: LookNotFound[];
48
+ dropped?: import("./pagerules.js").Dropped[];
49
+ };
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Scan one source text for the labels that sit before values, per shape.
3
+ * @param {string} text
4
+ * @returns {LabelScan}
5
+ */
6
+ export function scanLabels(text: string): LabelScan;
7
+ /**
8
+ * Is this label on the list for this shape? Compared the way a label is read: white space of any kind is one space, quote marks at the
9
+ * edges are dropped. `idOrText` may be a list id (`t1`) or the exact words.
10
+ * @param {LabelScan} scan @param {string} shape @param {unknown} idOrText
11
+ * @returns {LabelEntry|null}
12
+ */
13
+ export function labelOnList(scan: LabelScan, shape: string, idOrText: unknown): LabelEntry | null;
14
+ /** @typedef {{id: string, label: string, count: number, example: string}} LabelEntry */
15
+ /** @typedef {Record<'money'|'number'|'date'|'time'|'text', LabelEntry[]>} LabelScan */
16
+ export const LABEL_SHAPES: readonly string[];
17
+ /** a label must occur at least this often to be listed (1: a one-page document with one total still has its label; the list is cut to the highest counts) */
18
+ export const MIN_COUNT: 1;
19
+ /** how many labels one shape's list holds at most (the highest counts first) */
20
+ export const MAX_PER_SHAPE: 40;
21
+ /** only this much of a source is scanned (a source over it is scanned up to a line end) */
22
+ export const SCAN_MAX_CHARS: 2000000;
23
+ /**
24
+ * The page reader's bracketed tag (`[ref=549]`), shared by the three places that strip it. The lookahead and lookbehind add no match and drop no
25
+ * match: a `[` that sits inside the run of an earlier `[letters=` (no `]` or white space between) is skipped, because that earlier start reads the same
26
+ * run to the same end - it matches (and consumes this one) or fails (and so does this one). Without them "[a=[a=[a=..." with no `]` is quadratic.
27
+ */
28
+ export const TAG: RegExp;
29
+ export type LabelEntry = {
30
+ id: string;
31
+ label: string;
32
+ count: number;
33
+ example: string;
34
+ };
35
+ export type LabelScan = Record<"money" | "number" | "date" | "time" | "text", LabelEntry[]>;
@@ -79,6 +79,8 @@ export function isDropIt(text: unknown): boolean;
79
79
  export const AGREE_WORDS: string[];
80
80
  export function isAgree(text: unknown): boolean;
81
81
  export function stripAgreeLead(text: string): string;
82
+ export function readingQuestion(n: number, rule: string, reading: string): string;
83
+ export function cantCheckQuestion(n: number, rule: string): string;
82
84
  /**
83
85
  * `reading` = the plain words an `agree` writes as a `~` rule (a reading ask only)
84
86
  */
@@ -385,6 +385,47 @@ export function createAuthor(opts: {
385
385
  status: number;
386
386
  body: any;
387
387
  };
388
+ /**
389
+ * `POST /api/author/:id/row-edit` body `{ op: 'drop'|'add', key }` (M16 item 5, am3 (4); hamr 2026-11-13 N-2): the plan card's Drop and Add. $0 and instant: the panel REBUILDS the list from the
390
+ * newest green plan's saved files (src/planrebuild.js), applies the choice through the block's own `rowChoice`, and writes a NEW plan folder `draft-<n>` (records are write-once, the old plan is
391
+ * never touched) booked as a plan of its own with a $0 spend row. It spawns no `fwdloop draft`, builds no provider, makes no call. Signing then reads the new plan (its hash). A refusal is plain
392
+ * words and writes nothing.
393
+ * @param {string} id @param {any} body
394
+ */
395
+ rowEdit(id: string, body: any): {
396
+ status: number;
397
+ body: {
398
+ ok: boolean;
399
+ refused: string;
400
+ say?: undefined;
401
+ draftId?: undefined;
402
+ n?: undefined;
403
+ plan?: undefined;
404
+ hash?: undefined;
405
+ };
406
+ } | {
407
+ status: number;
408
+ body: {
409
+ ok: boolean;
410
+ refused: string;
411
+ say: string;
412
+ draftId?: undefined;
413
+ n?: undefined;
414
+ plan?: undefined;
415
+ hash?: undefined;
416
+ };
417
+ } | {
418
+ status: number;
419
+ body: {
420
+ ok: boolean;
421
+ draftId: string;
422
+ n: number;
423
+ plan: string;
424
+ hash: string;
425
+ refused?: undefined;
426
+ say?: undefined;
427
+ };
428
+ };
388
429
  /**
389
430
  * `GET /api/author/live`: the newest draft that is not abandoned or signed, and the newest panel start the human has not cleared
390
431
  * (`starting` or `refused`; a `started` one is in Runs) — read from files, never memory.
@@ -25,7 +25,7 @@ export function parseJobBox(text: string): {
25
25
  * that line's own `~` lines (several answers for one line keep their order). The job box's own lines are untouched; the card -> prose path
26
26
  * (`cardToProse`) then writes the answer as that line's guardrail, so it reaches the signed text and the hash. Pure. An answer for a line
27
27
  * the box does not have is NOT added (the caller sees the count). An answer equal (exact string, after trim) to a `~` rule already on that line is not added
28
- * again, and still counts: it is taken, the line already says it.
28
+ * again (case, spacing and trailing punctuation aside; also not when it is one `; ` part of a `~` line), and still counts: it is taken, the line already says it.
29
29
  * @param {string} job @param {{ line: number, answer: string }[]} answers
30
30
  * @returns {{ job: string, added: number }}
31
31
  */