fwdloop 0.21.0 → 0.23.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.
- package/bin/fwdloop +85 -34
- package/package.json +4 -3
- package/src/ask.js +20 -4
- package/src/audit-fold.js +5 -1
- package/src/authoring.js +36 -6
- package/src/canrun.js +5 -0
- package/src/checked.js +32 -4
- package/src/cited-record.js +138 -0
- package/src/cited-source.js +49 -0
- package/src/citedcheck.js +321 -0
- package/src/citedwords.js +197 -0
- package/src/closers.js +37 -198
- package/src/csv.js +69 -12
- package/src/ctx-tools.js +2 -14
- package/src/declaration.js +143 -5
- package/src/diary.js +2 -2
- package/src/docx.js +16 -2
- package/src/draft-steps.js +1 -1
- package/src/drafter.js +322 -33
- package/src/flow.js +33 -7
- package/src/flowmodel.js +21 -0
- package/src/input-facts.js +20 -3
- package/src/model-step.js +38 -21
- package/src/pageask.js +136 -0
- package/src/pagebits.js +107 -0
- package/src/pagedropwords.js +171 -0
- package/src/pagedry.js +120 -0
- package/src/pagefetch.js +164 -0
- package/src/pagelook.js +155 -0
- package/src/pagemap.js +55 -0
- package/src/pageplace.js +103 -0
- package/src/pagerules.js +318 -0
- package/src/panel/author.js +43 -21
- package/src/panel/authorcard.js +20 -3
- package/src/panel/authorflows.js +21 -15
- package/src/panel/authorstart.js +2 -4
- package/src/panel/authortrigger.js +14 -4
- package/src/panel/data.js +102 -6
- package/src/panel/index.html +321 -12
- package/src/panel/result.js +301 -0
- package/src/panel/server.js +27 -3
- package/src/primitives.js +2 -3
- package/src/provider.js +5 -2
- package/src/redact.js +17 -0
- package/src/runner.js +102 -14
- package/src/schedule.js +3 -3
- package/src/setup.js +16 -1
- package/src/sheet-record.js +57 -0
- package/src/sheetblock.js +170 -0
- package/src/sheetchecks.js +206 -0
- package/src/sheetclaims.js +78 -0
- package/src/sheetfind.js +50 -0
- package/src/sheetlook.js +157 -0
- package/src/sheetoffer.js +125 -0
- package/src/sheetrun.js +105 -0
- package/src/signed-text.js +11 -1
- package/src/thinking.js +1 -1
- package/src/try-checks.js +12 -0
- package/src/types.js +4 -11
- package/types/ask.d.ts +2 -1
- package/types/authoring.d.ts +19 -2
- package/types/checked.d.ts +19 -3
- package/types/cited-record.d.ts +21 -0
- package/types/cited-source.d.ts +18 -0
- package/types/citedcheck.d.ts +95 -0
- package/types/citedwords.d.ts +97 -0
- package/types/closers.d.ts +37 -10
- package/types/csv.d.ts +25 -4
- package/types/ctx-tools.d.ts +0 -1
- package/types/declaration.d.ts +20 -1
- package/types/docx.d.ts +14 -0
- package/types/drafter.d.ts +264 -8
- package/types/flow.d.ts +21 -0
- package/types/flowmodel.d.ts +15 -0
- package/types/input-facts.d.ts +12 -2
- package/types/model-step.d.ts +40 -19
- package/types/pageask.d.ts +75 -0
- package/types/pagebits.d.ts +32 -0
- package/types/pagedropwords.d.ts +40 -0
- package/types/pagedry.d.ts +38 -0
- package/types/pagefetch.d.ts +86 -0
- package/types/pagelook.d.ts +75 -0
- package/types/pagemap.d.ts +31 -0
- package/types/pageplace.d.ts +22 -0
- package/types/pagerules.d.ts +86 -0
- package/types/panel/authorcard.d.ts +4 -1
- package/types/panel/authorflows.d.ts +2 -0
- package/types/panel/data.d.ts +26 -0
- package/types/panel/result.d.ts +156 -0
- package/types/provider.d.ts +3 -1
- package/types/redact.d.ts +1 -0
- package/types/runner.d.ts +162 -9
- package/types/schedule.d.ts +0 -11
- package/types/setup.d.ts +13 -0
- package/types/sheet-record.d.ts +24 -0
- package/types/sheetblock.d.ts +116 -0
- package/types/sheetchecks.d.ts +70 -0
- package/types/sheetclaims.d.ts +26 -0
- package/types/sheetfind.d.ts +46 -0
- package/types/sheetlook.d.ts +120 -0
- package/types/sheetoffer.d.ts +25 -0
- package/types/sheetrun.d.ts +35 -0
- package/types/thinking.d.ts +1 -1
- package/types/types.d.ts +27 -14
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One amount of a money fact in the fact's OWN forms, never a hardcoded sign: `symbolFirst` puts the currency sign before the amount when the fact has one.
|
|
3
|
+
* @param {any} f @param {string|number} n @param {boolean} symbolFirst @returns {string}
|
|
4
|
+
*/
|
|
5
|
+
export function moneyAs(f: any, n: string | number, symbolFirst: boolean): string;
|
|
6
|
+
/** @param {any} f a fact with a rule @returns {string} the rule in words, e.g. "under 450 US dollars" */
|
|
7
|
+
export function ruleWords(f: any): string;
|
|
8
|
+
/** @param {unknown} q a recorded question @returns {string|null} the reading a reading ask proposed, or null when it was another kind of question */
|
|
9
|
+
export function readingOfQuestion(q: unknown): string | null;
|
|
10
|
+
/**
|
|
11
|
+
* The early asks CODE forces before any paid drafting, from the look's own result. One ask per rule text on a line; readings first, then can't-check
|
|
12
|
+
* asks, each in line order. The caller applies the cap and the answer gate.
|
|
13
|
+
* @param {{facts?: {line: number, forRule?: number, name?: string, shape?: string, unit?: string[], currency?: string[], reading?: import('./pagerules.js').Reading}[]}|null|undefined} look
|
|
14
|
+
* @param {{n: number, text?: string, rule?: string, rules?: string[]}[]|null|undefined} jobLines
|
|
15
|
+
* @returns {LookAsk[]}
|
|
16
|
+
*/
|
|
17
|
+
export function askableFromLook(look: {
|
|
18
|
+
facts?: {
|
|
19
|
+
line: number;
|
|
20
|
+
forRule?: number;
|
|
21
|
+
name?: string;
|
|
22
|
+
shape?: string;
|
|
23
|
+
unit?: string[];
|
|
24
|
+
currency?: string[];
|
|
25
|
+
reading?: import("./pagerules.js").Reading;
|
|
26
|
+
}[];
|
|
27
|
+
} | null | undefined, jobLines: {
|
|
28
|
+
n: number;
|
|
29
|
+
text?: string;
|
|
30
|
+
rule?: string;
|
|
31
|
+
rules?: string[];
|
|
32
|
+
}[] | null | undefined): LookAsk[];
|
|
33
|
+
/**
|
|
34
|
+
* More asks than the cap means the job needs a rewrite, not a questionnaire. The code-owned stop words list EVERY ask and its reading as the
|
|
35
|
+
* suggestion (no extra paid call). A secret in a rule is masked.
|
|
36
|
+
* @param {{line: number, ruleText: string, reading?: string}[]} asks @returns {string}
|
|
37
|
+
*/
|
|
38
|
+
export function tooManyAsksText(asks: {
|
|
39
|
+
line: number;
|
|
40
|
+
ruleText: string;
|
|
41
|
+
reading?: string;
|
|
42
|
+
}[]): string;
|
|
43
|
+
/**
|
|
44
|
+
* What a typed answer to a look ask does, the ONE place that decides (the panel's answer route, the setup record and the Result tab all read it).
|
|
45
|
+
* `agree` / `yes` to a reading ask takes the code's reading; `drop it` to a can't-check ask leaves the rule Not checked (no `~` line); anything else is the
|
|
46
|
+
* 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.
|
|
47
|
+
* @param {{source?: string, ask?: string, proposal?: string|null}} q @param {unknown} typed
|
|
48
|
+
* @returns {{rule: string|null, left: boolean}} `rule` = the words written as a new `~` rule (null when the rule is left Not checked)
|
|
49
|
+
*/
|
|
50
|
+
export function ruleOfAnswer(q: {
|
|
51
|
+
source?: string;
|
|
52
|
+
ask?: string;
|
|
53
|
+
proposal?: string | null;
|
|
54
|
+
}, typed: unknown): {
|
|
55
|
+
rule: string | null;
|
|
56
|
+
left: boolean;
|
|
57
|
+
};
|
|
58
|
+
/** the most asks before drafting; more than this is a job to rewrite, not a questionnaire (am1) */
|
|
59
|
+
export const MAX_LOOK_ASKS: 3;
|
|
60
|
+
/** the answer that drops a `~` rule the page cannot check: the person types it (any case, a closing full stop allowed) */
|
|
61
|
+
export const DROP_IT: "drop it";
|
|
62
|
+
export function isDropIt(text: unknown): boolean;
|
|
63
|
+
export function isAgree(text: unknown): boolean;
|
|
64
|
+
/**
|
|
65
|
+
* `reading` = the plain words an `agree` writes as a `~` rule (a reading ask only)
|
|
66
|
+
*/
|
|
67
|
+
export type LookAsk = {
|
|
68
|
+
line: number;
|
|
69
|
+
rule: number;
|
|
70
|
+
source: "look";
|
|
71
|
+
question: string;
|
|
72
|
+
ask: "reading" | "cant-check";
|
|
73
|
+
ruleText: string;
|
|
74
|
+
reading?: string;
|
|
75
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How many times exact words occur in a source, white space blind. Zero for empty words.
|
|
3
|
+
* @param {string} source the raw source text @param {string} words
|
|
4
|
+
* @returns {number}
|
|
5
|
+
*/
|
|
6
|
+
export function countExact(source: string, words: string): number;
|
|
7
|
+
/**
|
|
8
|
+
* How many times a phrase or unit occurs as WHOLE words, case and spacing aside ("SFO" is not found inside "sfocus").
|
|
9
|
+
* @param {string} source @param {string} words @returns {number}
|
|
10
|
+
*/
|
|
11
|
+
export function countPhrase(source: string, words: string): number;
|
|
12
|
+
/**
|
|
13
|
+
* The forms a word may be written in (hamr's ruling 2026-10-21, "a simple plural matches"): the word, its plural and its singular, case aside. A simple plural is
|
|
14
|
+
* `s`, `es` after s/x/z/ch/sh, or `ies` for a consonant + `y`; nothing wider ("amounted" is not "amount"). The ONE place a word is allowed a plural: the
|
|
15
|
+
* sheet look's own-word check, the column finder and the .docx heading match all take their forms from here. A number, a phrase a guardrail names or a
|
|
16
|
+
* money value is never widened by it.
|
|
17
|
+
* @param {string} word @returns {string[]}
|
|
18
|
+
*/
|
|
19
|
+
export function wordForms(word: string): string[];
|
|
20
|
+
/** @param {string} t @returns {string} white space made one space, quote marks at the edges dropped, trimmed - how a label is compared */
|
|
21
|
+
export function normLabel(t: string): string;
|
|
22
|
+
/** the ~ rules of one job line, one string each (`rules` when the line has the array, else the joined `rule` split on "; ") @param {any} l @returns {string[]} */
|
|
23
|
+
export function lineRules(l: any): string[];
|
|
24
|
+
export const FACT_OPS: readonly string[];
|
|
25
|
+
export const MAX_CURRENCIES: 3;
|
|
26
|
+
export const MAX_UNITS: 10;
|
|
27
|
+
export const MAX_UNIT_CHARS: 100;
|
|
28
|
+
export function asList(v: unknown): string[];
|
|
29
|
+
export function boundOk(shape: string, v: unknown): boolean;
|
|
30
|
+
export function squash(t: string): string;
|
|
31
|
+
export function boundInWords(b: unknown, said: string): boolean;
|
|
32
|
+
export function wordsSaidOn(jl: any): string;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/** @param {Dropped} d @returns {string} the plain sentence for one drop */
|
|
2
|
+
export function dropSentence(d: Dropped): string;
|
|
3
|
+
/**
|
|
4
|
+
* One row per fact that lost something: the sentences (one per dropped word, then the fact's own), and whether the whole fact went.
|
|
5
|
+
* @param {Dropped[]|undefined|null} dropped
|
|
6
|
+
* @returns {{line: number, rule?: number, fact: string, full: boolean, sentences: string[]}[]}
|
|
7
|
+
*/
|
|
8
|
+
export function dropRows(dropped: Dropped[] | undefined | null): {
|
|
9
|
+
line: number;
|
|
10
|
+
rule?: number;
|
|
11
|
+
fact: string;
|
|
12
|
+
full: boolean;
|
|
13
|
+
sentences: string[];
|
|
14
|
+
}[];
|
|
15
|
+
/**
|
|
16
|
+
* A row as one Not-checked line, in the person's own words: `line N: "<the ~ rule as written, or the fact's name>" — <sentences>`.
|
|
17
|
+
* @param {{line: number, rule?: number, fact: string, sentences: string[]}} row @param {any[]|null|undefined} jobLines @param {(l: any) => string[]} rulesOf
|
|
18
|
+
* @returns {string}
|
|
19
|
+
*/
|
|
20
|
+
export function dropLine(row: {
|
|
21
|
+
line: number;
|
|
22
|
+
rule?: number;
|
|
23
|
+
fact: string;
|
|
24
|
+
sentences: string[];
|
|
25
|
+
}, jobLines: any[] | null | undefined, rulesOf: (l: any) => string[]): string;
|
|
26
|
+
/**
|
|
27
|
+
* @param {string} text one Not-checked line @param {string[]|null|undefined} [signed] the names of the facts the plan signs (none given: an s1 sentence stays Not checked)
|
|
28
|
+
* @returns {boolean} true when the line only says which written forms of a still-checked fact were not used
|
|
29
|
+
*/
|
|
30
|
+
export function isReadNote(text: string, signed?: string[] | null | undefined): boolean;
|
|
31
|
+
/** @param {string[]|null|undefined} items @param {string[]|null|undefined} [signed] names of the signed facts (see isReadNote)
|
|
32
|
+
* @returns {{notChecked: string[], readNotes: string[]}} the lines split: what is left unchecked, and how the page was read */
|
|
33
|
+
export function splitReadNotes(items: string[] | null | undefined, signed?: string[] | null | undefined): {
|
|
34
|
+
notChecked: string[];
|
|
35
|
+
readNotes: string[];
|
|
36
|
+
};
|
|
37
|
+
/** The names of the facts a signed declaration checks (every cited fact of every step). Pure. @param {any} declaration @returns {string[]} */
|
|
38
|
+
export function signedFactNames(declaration: any): string[];
|
|
39
|
+
export function leftRuleLine(rule: string): string;
|
|
40
|
+
export type Dropped = import("./pagerules.js").Dropped;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The result lines of a kept money fact: with a label, every page line where a kept label is followed by a number (one sign between allowed);
|
|
3
|
+
* with no label (U1 moved it to a unit, e.g. "€533 total"), every line where a number is followed by a kept unit.
|
|
4
|
+
* @param {string} text @param {KeptFact} k @returns {{quote: string, value: string}[]}
|
|
5
|
+
*/
|
|
6
|
+
export function moneyResultLines(text: string, k: KeptFact): {
|
|
7
|
+
quote: string;
|
|
8
|
+
value: string;
|
|
9
|
+
}[];
|
|
10
|
+
/**
|
|
11
|
+
* Dry-read every kept money fact; drop (as `reads-no-result`) the ones whose forms read no result line. Other facts pass through untouched.
|
|
12
|
+
* @param {string} text the frozen page text @param {KeptFact[]} facts what the page rules kept
|
|
13
|
+
* @returns {Promise<{facts: KeptFact[], dropped: Dropped[], reads: Record<string, number>, results: Record<string, number>}>}
|
|
14
|
+
* `reads` / `results` = result lines the checker read / lines found, per fact name (for tests and reports; no verdict derives from the numbers)
|
|
15
|
+
*/
|
|
16
|
+
export function dryReadMoney(text: string, facts: KeptFact[]): Promise<{
|
|
17
|
+
facts: KeptFact[];
|
|
18
|
+
dropped: Dropped[];
|
|
19
|
+
reads: Record<string, number>;
|
|
20
|
+
results: Record<string, number>;
|
|
21
|
+
}>;
|
|
22
|
+
/**
|
|
23
|
+
* The same "can it read" for PHRASE facts (bareloop c550dc8; our failure: m10-walk-flights-3, "Rome" was on the page only in "Track prices from Madrid to
|
|
24
|
+
* Rome" switches, in none of the 18 result lines, so no result could ever say it). A kept phrase fact is read against the page's RESULT LINES = the lines
|
|
25
|
+
* the job's kept money facts read (`moneyResultLines`), each checked as an honest claim by the run's own `checkCited` (quote = that line; a phrase has no
|
|
26
|
+
* value to write). A phrase that reads no result line is dropped whole as `phrase-no-result` and shows under Not checked. With no kept money fact the
|
|
27
|
+
* result lines are unknown, so phrase facts pass through untouched (nothing is guessed about what a result is).
|
|
28
|
+
* Throws away: nothing silently (the drop is returned). Third outcomes: a checker that stops counts as "did not read" for that line.
|
|
29
|
+
* @param {string} text the frozen page text @param {KeptFact[]} facts what the money dry read kept
|
|
30
|
+
* @returns {Promise<{facts: KeptFact[], dropped: Dropped[], reads: Record<string, number>}>} `reads` = result lines that said the phrase, per fact name
|
|
31
|
+
*/
|
|
32
|
+
export function dryReadPhrases(text: string, facts: KeptFact[]): Promise<{
|
|
33
|
+
facts: KeptFact[];
|
|
34
|
+
dropped: Dropped[];
|
|
35
|
+
reads: Record<string, number>;
|
|
36
|
+
}>;
|
|
37
|
+
export type KeptFact = import("./pagerules.js").KeptFact;
|
|
38
|
+
export type Dropped = import("./pagerules.js").Dropped;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/** @param {unknown} v @returns {boolean} an http(s) address (the one spelling of "this Inputs value is a web address") */
|
|
2
|
+
export function isWebUrl(v: unknown): boolean;
|
|
3
|
+
/** M10 am3: the web pages a signed job names, role -> address (`source <role> = page:<address>`). The ONE reader of which roles are pages and what their signed address is.
|
|
4
|
+
* @param {{sources?: Array<{role: string, kind?: string, path: string}>}} arbiter @returns {Record<string, string>} */
|
|
5
|
+
export function pageAddressesOf(arbiter: {
|
|
6
|
+
sources?: Array<{
|
|
7
|
+
role: string;
|
|
8
|
+
kind?: string;
|
|
9
|
+
path: string;
|
|
10
|
+
}>;
|
|
11
|
+
}): Record<string, string>;
|
|
12
|
+
/** M10 am3: why a run may not name another address for a page input (the signed address is the job's; a different one is a changed job). @param {string} role @param {string} signed */
|
|
13
|
+
export function pageAddressRefusal(role: string, signed: string): string;
|
|
14
|
+
/**
|
|
15
|
+
* How much of a fetched page is the page's own content: the snapshot's header lines (url, size note, hint) and every part of the tree
|
|
16
|
+
* under a banner / navigation / contentinfo landmark are taken out, the page reader's bracketed tags are removed, and what is left is
|
|
17
|
+
* counted. Generic - no site names, only the ARIA landmark roles. Text that is not a snapshot tree (a plain file) has no landmark, so it
|
|
18
|
+
* counts whole.
|
|
19
|
+
* @param {string} text @returns {number}
|
|
20
|
+
*/
|
|
21
|
+
export function pageContentChars(text: string): number;
|
|
22
|
+
/** @param {string} v @returns {boolean} true when `v` (x.y.z) is at least MIN_BAREBROWSE */
|
|
23
|
+
export function barebrowseNewEnough(v: string): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Fetch one page's text. `connect` is injected (a test never reaches the network); the default is barebrowse's own `connect`.
|
|
26
|
+
* @param {string} url
|
|
27
|
+
* @param {{connect?: (opts: Record<string, any>) => Promise<FetchPage>, timeoutMs?: number, idleMs?: number, idleTimeoutMs?: number, closeWaitMs?: number}} [o]
|
|
28
|
+
* @returns {Promise<{ok: true, text: string, url: string}|{ok: false, error: string}>} `error` is plain words, without a spend line
|
|
29
|
+
*/
|
|
30
|
+
export function fetchPageText(url: string, { connect, timeoutMs, idleMs, idleTimeoutMs, closeWaitMs }?: {
|
|
31
|
+
connect?: (opts: Record<string, any>) => Promise<FetchPage>;
|
|
32
|
+
timeoutMs?: number;
|
|
33
|
+
idleMs?: number;
|
|
34
|
+
idleTimeoutMs?: number;
|
|
35
|
+
closeWaitMs?: number;
|
|
36
|
+
}): Promise<{
|
|
37
|
+
ok: true;
|
|
38
|
+
text: string;
|
|
39
|
+
url: string;
|
|
40
|
+
} | {
|
|
41
|
+
ok: false;
|
|
42
|
+
error: string;
|
|
43
|
+
}>;
|
|
44
|
+
/** the session options (incognito: no auth ever enters; blockPrivateNetwork: SSRF guard); ONE frozen object so a test can pin them */
|
|
45
|
+
export const CONNECT_OPTIONS: Readonly<{
|
|
46
|
+
incognito: true;
|
|
47
|
+
blockPrivateNetwork: true;
|
|
48
|
+
}>;
|
|
49
|
+
/** the snapshot options step 0 proved */
|
|
50
|
+
export const SNAPSHOT_OPTIONS: Readonly<{
|
|
51
|
+
mode: "act";
|
|
52
|
+
}>;
|
|
53
|
+
/** the page's network must be quiet this long (ms) before we read it: long enough to span the gap between a page's first load and the
|
|
54
|
+
* script requests that fill the results, short enough not to stretch a plain page */
|
|
55
|
+
export const NETWORK_IDLE_MS: 1500;
|
|
56
|
+
/** the most we wait for the network to go quiet (ms); a page that never settles (polling, streaming) is read as it stands after this */
|
|
57
|
+
export const NETWORK_IDLE_TIMEOUT_MS: 20000;
|
|
58
|
+
/** the most we wait for the page to load at all (ms) */
|
|
59
|
+
export const GOTO_TIMEOUT_MS: 30000;
|
|
60
|
+
/** a page that comes back with fewer characters than this (after trimming) is treated as "nothing came back" */
|
|
61
|
+
export const MIN_PAGE_CHARS: 200;
|
|
62
|
+
/** the page text left after the site's own header, menus and footer are taken out must hold at least this many characters, or the page is
|
|
63
|
+
* "only site chrome" (L2: a 719-character fetch of a site's header and sign-in passed the 200-character floor) */
|
|
64
|
+
export const MIN_CONTENT_CHARS: 100;
|
|
65
|
+
/** our own deadline around one whole fetch (a hung browser leaves no trace; this is the only thing that fires on the absence of an answer) */
|
|
66
|
+
export const PAGE_FETCH_TIMEOUT_MS: 90000;
|
|
67
|
+
/**
|
|
68
|
+
* @typedef {{goto: (url: string, timeout?: number) => Promise<void>, 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
|
|
70
|
+
*/
|
|
71
|
+
/** the oldest barebrowse that honours CONNECT_OPTIONS (incognito, blockPrivateNetwork); an older one would drop both guards without a word */
|
|
72
|
+
export const MIN_BAREBROWSE: number[];
|
|
73
|
+
/**
|
|
74
|
+
* the part of barebrowse's page handle the fetch uses
|
|
75
|
+
*/
|
|
76
|
+
export type FetchPage = {
|
|
77
|
+
goto: (url: string, timeout?: number) => Promise<void>;
|
|
78
|
+
waitForNetworkIdle: (o?: {
|
|
79
|
+
idle?: number;
|
|
80
|
+
timeout?: number;
|
|
81
|
+
}) => Promise<void>;
|
|
82
|
+
snapshot: (o?: {
|
|
83
|
+
mode?: string;
|
|
84
|
+
}) => Promise<string>;
|
|
85
|
+
close: () => Promise<void>;
|
|
86
|
+
};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A unit, currency or label listed twice in one list is one entry: removed before the rules run, so no rule can compare a word with itself.
|
|
3
|
+
* @param {any} mapping @returns {any}
|
|
4
|
+
*/
|
|
5
|
+
export function dedupeMap(mapping: any): any;
|
|
6
|
+
/**
|
|
7
|
+
* The rules over one saved page: bareloop's (found-on-page, N2, R1, U1/R1L, S1, ...), then ours (no-value).
|
|
8
|
+
* @param {string} text the frozen page text @param {import('./pagerules.js').PageMap} mapping @param {{n: number, text?: string, rule?: string, rules?: string[]}[]} jobLines
|
|
9
|
+
* @returns {{facts: import('./pagerules.js').KeptFact[], dropped: import('./pagerules.js').Dropped[]}}
|
|
10
|
+
*/
|
|
11
|
+
export function applyPageWords(text: string, mapping: import("./pagerules.js").PageMap, jobLines: {
|
|
12
|
+
n: number;
|
|
13
|
+
text?: string;
|
|
14
|
+
rule?: string;
|
|
15
|
+
rules?: string[];
|
|
16
|
+
}[]): {
|
|
17
|
+
facts: import("./pagerules.js").KeptFact[];
|
|
18
|
+
dropped: import("./pagerules.js").Dropped[];
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* A kept fact as the look carries it: the page words under the name the later pieces read (a phrase holds `phrase`, any other `labels`/`label`).
|
|
22
|
+
* @param {import('./pagerules.js').KeptFact} k @param {string} source @returns {any}
|
|
23
|
+
*/
|
|
24
|
+
export function lookFactOf(k: import("./pagerules.js").KeptFact, source: string): any;
|
|
25
|
+
/**
|
|
26
|
+
* Look at ONE page input: the map call (once; once more if the answer is unreadable), then the rules.
|
|
27
|
+
* `callModel(content, attempt)` (attempt 1 or 2) makes and meters ONE model round and returns `{text}`, `{text, cutOff: true}` (the round hit its output cap) or `{error}`.
|
|
28
|
+
* @param {{label: string, text: string, jobLines: {n: number, text: string, rule?: string, rules?: string[]}[], callModel: (content: string, attempt: number) => Promise<{text?: string, cutOff?: boolean, error?: string}>}} o
|
|
29
|
+
* @returns {Promise<{ok: true, look: {facts: any[], dropped: any[]}, notChecked: string[], mapping: any, attempts: number}|{ok: false, reason: string, attempts: number}>}
|
|
30
|
+
*/
|
|
31
|
+
export function lookAtPage({ label, text, jobLines, callModel, }: {
|
|
32
|
+
label: string;
|
|
33
|
+
text: string;
|
|
34
|
+
jobLines: {
|
|
35
|
+
n: number;
|
|
36
|
+
text: string;
|
|
37
|
+
rule?: string;
|
|
38
|
+
rules?: string[];
|
|
39
|
+
}[];
|
|
40
|
+
callModel: (content: string, attempt: number) => Promise<{
|
|
41
|
+
text?: string;
|
|
42
|
+
cutOff?: boolean;
|
|
43
|
+
error?: string;
|
|
44
|
+
}>;
|
|
45
|
+
}): Promise<{
|
|
46
|
+
ok: true;
|
|
47
|
+
look: {
|
|
48
|
+
facts: any[];
|
|
49
|
+
dropped: any[];
|
|
50
|
+
};
|
|
51
|
+
notChecked: string[];
|
|
52
|
+
mapping: any;
|
|
53
|
+
attempts: number;
|
|
54
|
+
} | {
|
|
55
|
+
ok: false;
|
|
56
|
+
reason: string;
|
|
57
|
+
attempts: number;
|
|
58
|
+
}>;
|
|
59
|
+
/**
|
|
60
|
+
* What the drafter is told about a page it cannot read for itself: the words code checked against the saved page (kept), and every drop, so it never
|
|
61
|
+
* claims a check the page cannot give (bareloop's withDropNotes, told to the drafter as plain lines).
|
|
62
|
+
* @param {{label: string, address: string, chars: number, look: {facts: any[]}, notChecked: string[]}} o @returns {string[]}
|
|
63
|
+
*/
|
|
64
|
+
export function pageInfoLines({ label, address, chars, look, notChecked, }: {
|
|
65
|
+
label: string;
|
|
66
|
+
address: string;
|
|
67
|
+
chars: number;
|
|
68
|
+
look: {
|
|
69
|
+
facts: any[];
|
|
70
|
+
};
|
|
71
|
+
notChecked: string[];
|
|
72
|
+
}): string[];
|
|
73
|
+
export function notCheckedLines(dropped: import("./pagerules.js").Dropped[], jobLines: {
|
|
74
|
+
n: number;
|
|
75
|
+
}[]): string[];
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the AI is told, for ONE page input. Ported from the POC prompt: the job, the `~` rules, "a result is one item", the answer form
|
|
3
|
+
* and the shape meanings.
|
|
4
|
+
* @param {{jobLines: {n: number, text: string, rule?: string, rules?: string[]}[], label: string, text: string}} o
|
|
5
|
+
* @returns {string}
|
|
6
|
+
*/
|
|
7
|
+
export function mapPrompt({ jobLines, label, text }: {
|
|
8
|
+
jobLines: {
|
|
9
|
+
n: number;
|
|
10
|
+
text: string;
|
|
11
|
+
rule?: string;
|
|
12
|
+
rules?: string[];
|
|
13
|
+
}[];
|
|
14
|
+
label: string;
|
|
15
|
+
text: string;
|
|
16
|
+
}): string;
|
|
17
|
+
/**
|
|
18
|
+
* Read the AI's answer: ONE JSON object of the answer form, and nothing else. No repair (hamr's ruling): text that is not JSON, JSON of
|
|
19
|
+
* another form, or a fact whose shape or lists are not of the form is a malformed answer.
|
|
20
|
+
* @param {unknown} text @returns {{ok: true, mapping: import('./pagerules.js').PageMap}|{ok: false}}
|
|
21
|
+
*/
|
|
22
|
+
export function parseMapAnswer(text: unknown): {
|
|
23
|
+
ok: true;
|
|
24
|
+
mapping: import("./pagerules.js").PageMap;
|
|
25
|
+
} | {
|
|
26
|
+
ok: false;
|
|
27
|
+
};
|
|
28
|
+
export const MAP_SHAPES: readonly string[];
|
|
29
|
+
export const MAP_SYSTEM: "You map a person's job to the exact words of ONE saved web page. You never grade and never invent words: every string you return must be copied from the page text, character for character.";
|
|
30
|
+
/** the plain-word stop when the answer was not readable twice (no Resume: a draft is not a run) */
|
|
31
|
+
export const MAP_UNREADABLE: "The AI's answer about the page was not readable twice. Nothing was signed.";
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* R2: a phrase extended left by up to 2 words.
|
|
3
|
+
* @param {string[]} lines @param {string} phrase @param {string[]} notes @param {string} tag @returns {{grown: string, steps: string[]}}
|
|
4
|
+
*/
|
|
5
|
+
export function growLeft(lines: string[], phrase: string, notes: string[], tag: string): {
|
|
6
|
+
grown: string;
|
|
7
|
+
steps: string[];
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* The phrases a place fact is signed with: each kept place word grown (R2), a phrase another kept phrase contains dropped (R2a), a phrase that shares
|
|
11
|
+
* under 90% of the longest phrase's page lines dropped (R2b). `grow: false` skips R2 only (the control of F72: the same phrases, no growth).
|
|
12
|
+
* @param {string} text the saved page @param {string[]} words the kept words of ONE place fact, each already on the page
|
|
13
|
+
* @param {{grow?: boolean}} [o]
|
|
14
|
+
* @returns {{phrases: string[], notes: string[], trace: string[]}} `phrases` are all to be in a result's quote (R2c)
|
|
15
|
+
*/
|
|
16
|
+
export function placePhrases(text: string, words: string[], { grow }?: {
|
|
17
|
+
grow?: boolean;
|
|
18
|
+
}): {
|
|
19
|
+
phrases: string[];
|
|
20
|
+
notes: string[];
|
|
21
|
+
trace: string[];
|
|
22
|
+
};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which job line, and which `~` rule under it, a map fact carries out. The map writes `from` as "line N", "line N rule M", "rule M" or
|
|
3
|
+
* "job line"; anything else is the first job line.
|
|
4
|
+
* @param {unknown} from @param {{n: number, text?: string, rule?: string, rules?: string[]}[]} jobLines
|
|
5
|
+
* @returns {{line: number, rule?: number}}
|
|
6
|
+
*/
|
|
7
|
+
export function tieOf(from: unknown, jobLines: {
|
|
8
|
+
n: number;
|
|
9
|
+
text?: string;
|
|
10
|
+
rule?: string;
|
|
11
|
+
rules?: string[];
|
|
12
|
+
}[]): {
|
|
13
|
+
line: number;
|
|
14
|
+
rule?: number;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Is this a legal `reading` for a fact of this shape? Only a time or money fact carries one, with the op set and the bound types of a signed
|
|
18
|
+
* fact rule (src/facts.js): no other key, no missing bound. A malformed one makes the whole map answer malformed (no repair).
|
|
19
|
+
* @param {unknown} shape @param {unknown} r @returns {boolean}
|
|
20
|
+
*/
|
|
21
|
+
export function validReading(shape: unknown, r: unknown): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Apply the rules to the AI's map over one saved page. Returns the kept facts and, for everything a rule removed, one `dropped` entry.
|
|
24
|
+
* The order of the rules is the POC's (apply-v3.mjs): found-on-page, then the rules that read the page. A place is read as a phrase.
|
|
25
|
+
* @param {string} text the frozen page text @param {PageMap} mapping @param {{n: number, text?: string, rule?: string, rules?: string[]}[]} jobLines
|
|
26
|
+
* @returns {{facts: KeptFact[], dropped: Dropped[]}}
|
|
27
|
+
*/
|
|
28
|
+
export function applyPageRules(text: string, mapping: PageMap, jobLines: {
|
|
29
|
+
n: number;
|
|
30
|
+
text?: string;
|
|
31
|
+
rule?: string;
|
|
32
|
+
rules?: string[];
|
|
33
|
+
}[]): {
|
|
34
|
+
facts: KeptFact[];
|
|
35
|
+
dropped: Dropped[];
|
|
36
|
+
};
|
|
37
|
+
export function linesOf(text: string): string[];
|
|
38
|
+
/**
|
|
39
|
+
* what a `~` rule means as a limit (PRD v1.107 Part 5b): the same shape as a signed fact rule
|
|
40
|
+
*/
|
|
41
|
+
export type Reading = {
|
|
42
|
+
op: string;
|
|
43
|
+
value?: string | number;
|
|
44
|
+
lo?: string | number;
|
|
45
|
+
hi?: string | number;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* the AI's map, one fact
|
|
49
|
+
*/
|
|
50
|
+
export type MapFact = {
|
|
51
|
+
name: string;
|
|
52
|
+
from?: string;
|
|
53
|
+
shape: string;
|
|
54
|
+
words?: string[];
|
|
55
|
+
currency?: string[];
|
|
56
|
+
unit?: string[];
|
|
57
|
+
reading?: Reading;
|
|
58
|
+
};
|
|
59
|
+
export type PageMap = {
|
|
60
|
+
facts: MapFact[];
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* `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)
|
|
64
|
+
*/
|
|
65
|
+
export type KeptFact = {
|
|
66
|
+
line: number;
|
|
67
|
+
name: string;
|
|
68
|
+
shape: string;
|
|
69
|
+
from: string;
|
|
70
|
+
words: string[];
|
|
71
|
+
unit?: string[];
|
|
72
|
+
currency?: string[];
|
|
73
|
+
forRule?: number;
|
|
74
|
+
reading?: Reading;
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* `other` = what the drop is compared to: the first label (R1), the primary form (R1L), the fact it would have repeated (S1)
|
|
78
|
+
*/
|
|
79
|
+
export type Dropped = {
|
|
80
|
+
line: number;
|
|
81
|
+
rule?: number;
|
|
82
|
+
fact: string;
|
|
83
|
+
word?: string;
|
|
84
|
+
reason: string;
|
|
85
|
+
other?: string;
|
|
86
|
+
};
|
|
@@ -24,7 +24,8 @@ export function parseJobBox(text: string): {
|
|
|
24
24
|
* M4e amendment 24 item 3: the submitted job box with each answer added WORD FOR WORD as a `~` line under the job line it is about, after
|
|
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
|
-
* the box does not have is NOT added (the caller sees the count).
|
|
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
29
|
* @param {string} job @param {{ line: number, answer: string }[]} answers
|
|
29
30
|
* @returns {{ job: string, added: number }}
|
|
30
31
|
*/
|
|
@@ -72,6 +73,8 @@ export function cardFields(body: any): {
|
|
|
72
73
|
capUsd: any;
|
|
73
74
|
askWait: string;
|
|
74
75
|
};
|
|
76
|
+
/** M10 am3: is this web address whole (a host after the scheme, no spaces)? The ONE reader of a typed page address. @param {string} v */
|
|
77
|
+
export function pageAddressOk(v: string): boolean;
|
|
75
78
|
/** The Run-a-signed-flow door's rows (a role is fixed by the signed flow): what the page sent, as `{role, path}`. @param {any} v */
|
|
76
79
|
export function runInputRows(v: any): {
|
|
77
80
|
role: string;
|
|
@@ -119,6 +119,7 @@ export function createFlowsDoor(opts: {
|
|
|
119
119
|
flow: string;
|
|
120
120
|
capUsd: any;
|
|
121
121
|
roles: any;
|
|
122
|
+
pages: Record<string, string>;
|
|
122
123
|
nextRunId: string;
|
|
123
124
|
lastRunId: string | null;
|
|
124
125
|
lastSources: Record<string, string>;
|
|
@@ -206,6 +207,7 @@ export function createFlowsDoor(opts: {
|
|
|
206
207
|
flow: string;
|
|
207
208
|
capUsd: any;
|
|
208
209
|
roles: any;
|
|
210
|
+
pages: Record<string, string>;
|
|
209
211
|
nextRunId: string;
|
|
210
212
|
lastRunId: string | null;
|
|
211
213
|
lastSources: Record<string, string>;
|
package/types/panel/data.d.ts
CHANGED
|
@@ -701,6 +701,31 @@ export function getRunJob({ root, flow, runId, catalogue, scheduleRead, home, }:
|
|
|
701
701
|
scheduleRead?: (flow: string) => any;
|
|
702
702
|
home?: string;
|
|
703
703
|
}): any | null;
|
|
704
|
+
/**
|
|
705
|
+
* `GET /api/runs/:flow/:runId/result` — the Result tab (M10 am4). The Not checked list is the Job tab's own (`buildJobPlan`), never a second spelling.
|
|
706
|
+
* @param {{root: string, flow: string, runId: string, catalogue: any, resumeAttempt?: (flow: string, runId: string) => any, now?: () => number}} a
|
|
707
|
+
* @returns {any|null}
|
|
708
|
+
*/
|
|
709
|
+
export function getRunResult({ root, flow, runId, catalogue, resumeAttempt, now, }: {
|
|
710
|
+
root: string;
|
|
711
|
+
flow: string;
|
|
712
|
+
runId: string;
|
|
713
|
+
catalogue: any;
|
|
714
|
+
resumeAttempt?: (flow: string, runId: string) => any;
|
|
715
|
+
now?: () => number;
|
|
716
|
+
}): any | null;
|
|
717
|
+
/**
|
|
718
|
+
* `GET /api/runs/:flow/:runId/download?i=<n>` (M10 am4): one saved file, or why not.
|
|
719
|
+
* @param {{root: string, flow: string, runId: string, catalogue: any, index: unknown}} a
|
|
720
|
+
* @returns {ReturnType<typeof downloadOf>}
|
|
721
|
+
*/
|
|
722
|
+
export function getRunDownload({ root, flow, runId, catalogue, index, }: {
|
|
723
|
+
root: string;
|
|
724
|
+
flow: string;
|
|
725
|
+
runId: string;
|
|
726
|
+
catalogue: any;
|
|
727
|
+
index: unknown;
|
|
728
|
+
}): ReturnType<typeof downloadOf>;
|
|
704
729
|
/**
|
|
705
730
|
* hamr's 2026-09-27 exit-check review #3: which declared step (and its
|
|
706
731
|
* signed prose line) each ask in `orderedAsks` belongs to — no book field
|
|
@@ -862,3 +887,4 @@ export const NO_DRAFT_WORDS: "no draft record";
|
|
|
862
887
|
/** M6: what the Job tab says for a run that started before runs kept a copy of their job. */
|
|
863
888
|
export const NO_JOB_COPY_WORDS: "This run started before runs kept a copy of their job, so this shows the job as it is now.";
|
|
864
889
|
import { scheduleAuditWords } from '../summary-words.js';
|
|
890
|
+
import { downloadOf } from './result.js';
|