fwdloop 0.37.0 → 0.39.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/README.md +5 -19
- package/bin/fwdloop +51 -29
- package/package.json +1 -1
- package/src/ask.js +70 -148
- package/src/audit-fold.js +5 -4
- package/src/auditchecks.js +6 -4
- package/src/authoring.js +36 -64
- package/src/blockasks.js +2 -1
- package/src/blockassemble.js +7 -9
- package/src/blockdraft.js +2 -2
- package/src/blockpick.js +5 -5
- package/src/books.js +217 -12
- package/src/checkblock.js +25 -55
- package/src/checked.js +2 -3
- package/src/checklistsign.js +26 -5
- package/src/checklook.js +3 -1
- package/src/checkpick.js +5 -76
- package/src/cited-source.js +4 -4
- package/src/citedcheck.js +6 -11
- package/src/citedwords.js +9 -8
- package/src/closers.js +9 -6
- package/src/declaration.js +22 -55
- package/src/diary.js +23 -1
- package/src/draft-steps.js +11 -1
- package/src/drafter.js +28 -23
- package/src/draftfiles.js +127 -0
- package/src/draftspend.js +165 -17
- package/src/flow.js +42 -87
- package/src/flowmodel.js +1 -1
- package/src/index.js +3 -2
- package/src/inside.js +86 -0
- package/src/isrec.js +2 -0
- package/src/jsonl-append.js +33 -1
- package/src/learn.js +1 -1
- package/src/learnstore.js +20 -22
- package/src/line-checks.js +2 -3
- package/src/liveness.js +3 -0
- package/src/mcp-use.js +8 -9
- package/src/memo.js +13 -16
- package/src/minrule.js +16 -0
- package/src/model-step.js +3 -3
- package/src/page-words.js +8 -0
- package/src/pageask.js +8 -3
- package/src/pagebits.js +8 -1
- package/src/pagedropwords.js +1 -1
- package/src/pagerules.js +6 -3
- package/src/panel/author.js +121 -78
- package/src/panel/authorcard.js +21 -8
- package/src/panel/authorflows.js +3 -3
- package/src/panel/authorresume.js +3 -3
- package/src/panel/authorstart.js +15 -16
- package/src/panel/authortrigger.js +43 -70
- package/src/panel/data.js +125 -168
- package/src/panel/index.html +154 -63
- package/src/panel/jobgrid.js +3 -7
- package/src/panel/result.js +7 -10
- package/src/panel/resume.js +4 -3
- package/src/panel/scheduler.js +9 -9
- package/src/panel/server.js +8 -4
- package/src/panel/spawn.js +22 -11
- package/src/panel/tickets.js +2 -2
- package/src/pickrecord.js +51 -31
- package/src/placerule.js +3 -4
- package/src/planrebuild.js +19 -19
- package/src/primitives.js +1 -1
- package/src/provider.js +1 -1
- package/src/reasons.js +25 -0
- package/src/report.js +2 -1
- package/src/runfile.js +26 -2
- package/src/runner.js +57 -105
- package/src/runvalues.js +47 -24
- package/src/schedule-choices.js +41 -0
- package/src/schedule-shape.js +39 -0
- package/src/schedule.js +9 -8
- package/src/setup.js +20 -36
- package/src/shaperows.js +2 -2
- package/src/sheet-record.js +1 -2
- package/src/sheetblock.js +3 -4
- package/src/sheetbuild.js +5 -5
- package/src/sheetchecks.js +1 -2
- package/src/sheetclaims.js +1 -2
- package/src/sheetoffer.js +1 -1
- package/src/sheetrun.js +5 -7
- package/src/summary-words.js +2 -1
- package/src/thinking.js +5 -2
- package/src/ticketrows.js +8 -30
- package/src/trigger-clock.js +9 -23
- package/src/trigger-files.js +30 -22
- package/src/trigger-tickets.js +15 -14
- package/src/try-checks.js +2 -1
- package/src/types.js +2 -0
- package/types/ask.d.ts +25 -20
- package/types/authoring.d.ts +8 -42
- package/types/blockassemble.d.ts +0 -1
- package/types/blockpick.d.ts +1 -1
- package/types/books.d.ts +256 -4
- package/types/checkblock.d.ts +2 -25
- package/types/checklist.d.ts +3 -3
- package/types/checklistsign.d.ts +7 -0
- package/types/checkpick.d.ts +0 -21
- package/types/citedwords.d.ts +7 -4
- package/types/closers.d.ts +1 -0
- package/types/declaration.d.ts +4 -14
- package/types/diary.d.ts +14 -1
- package/types/draft-steps.d.ts +7 -0
- package/types/drafter.d.ts +3 -2
- package/types/draftfiles.d.ts +89 -0
- package/types/draftspend.d.ts +74 -0
- package/types/flow.d.ts +32 -54
- package/types/index.d.ts +3 -3
- package/types/inside.d.ts +58 -0
- package/types/isrec.d.ts +1 -0
- package/types/jsonl-append.d.ts +20 -0
- package/types/learnstore.d.ts +0 -2
- package/types/liveness.d.ts +1 -0
- package/types/minrule.d.ts +6 -0
- package/types/page-words.d.ts +6 -0
- package/types/pageask.d.ts +2 -0
- package/types/pagebits.d.ts +3 -0
- package/types/pagerules.d.ts +1 -0
- package/types/panel/author.d.ts +7 -3
- package/types/panel/authorcard.d.ts +0 -6
- package/types/panel/authorflows.d.ts +4 -4
- package/types/panel/authortrigger.d.ts +16 -2
- package/types/panel/data.d.ts +36 -11
- package/types/panel/spawn.d.ts +18 -2
- package/types/pickrecord.d.ts +29 -0
- package/types/reasons.d.ts +23 -0
- package/types/runfile.d.ts +14 -0
- package/types/runner.d.ts +6 -38
- package/types/runvalues.d.ts +17 -2
- package/types/schedule-choices.d.ts +9 -0
- package/types/schedule-shape.d.ts +15 -0
- package/types/sheetbuild.d.ts +1 -1
- package/types/sheetclaims.d.ts +0 -1
- package/types/thinking.d.ts +1 -0
- package/types/ticketrows.d.ts +0 -9
- package/types/trigger-clock.d.ts +3 -2
- package/types/trigger-files.d.ts +15 -4
- package/types/types.d.ts +8 -0
package/types/checkblock.d.ts
CHANGED
|
@@ -31,30 +31,7 @@ export function choiceEntries(lines: {
|
|
|
31
31
|
/** what `setSheet` is given: code's build of a job's sheet checks, per sheet line @typedef {Awaited<ReturnType<typeof import('./sheetbuild.js').buildSheetChecks>>} SheetBuilt */
|
|
32
32
|
/** the four row edits an AI reply may hold */
|
|
33
33
|
export const EDIT_OPS: readonly string[];
|
|
34
|
-
export
|
|
35
|
-
/** the plain reasons code gives, in one place (the card, the Job tab and the Audit read them from the row) */
|
|
36
|
-
export const REASON: Readonly<{
|
|
37
|
-
left: "You chose to leave it Not checked, so you judge it at Accept.";
|
|
38
|
-
nothingOnPage: "Your own words are on the line; the machine has no check for them, so you judge it at Accept.";
|
|
39
|
-
noRule: "No rule can check this, so you judge it at Accept.";
|
|
40
|
-
waitingPick: "waiting for your answer on the proposed check";
|
|
41
|
-
waitingReading: "waiting for your answer on the reading";
|
|
42
|
-
onePerLine: "this line finds facts, so it has no text to quote";
|
|
43
|
-
manyInputs: "the job has more than one input and code cannot pick which one the claims quote";
|
|
44
|
-
oneSidedTime: "a time limit the AI proposes must be a range, so you judge it at Accept.";
|
|
45
|
-
countNeedsFact: "a result count needs a fact to count; this line has none";
|
|
46
|
-
countNeedsSuggested: "a result count needs a fact to count; add the suggested fact on this line to count its results";
|
|
47
|
-
lookNoWords: "the page does not hold the words of the look's fact for this rule";
|
|
48
|
-
afterLast: "no more tries: Start over (rows are never changed by the AI after the last try)";
|
|
49
|
-
noPick: "No check was picked for it, so you judge it at Accept.";
|
|
50
|
-
itemCountByRule: "your rule on this line sets the item count";
|
|
51
|
-
negated: "it says what is not needed, so there is nothing to check";
|
|
52
|
-
dropped: "You dropped it.";
|
|
53
|
-
suggested: "Suggested: not in your job, so it is not checked unless you add it.";
|
|
54
|
-
sheetLine: "this line reads a sheet and its rules are checked by the sheet checks, so a row edit about it is not used";
|
|
55
|
-
sheetFacts: "this line reads a sheet, so it is checked by its sheet checks and not by page facts";
|
|
56
|
-
columnRule: "this rule only names a column; the agent's checks on this line use it";
|
|
57
|
-
}>;
|
|
34
|
+
export function isFactKind(kind: unknown): boolean;
|
|
58
35
|
export class CheckBlock {
|
|
59
36
|
/** @param {{texts: Record<string, string>, labels: string[], maxTries?: number, countScope?: (ruleText: string) => boolean, asks?: boolean, split?: boolean, cited?: boolean, repo?: {files: string[]|null, writeScope: string[]|null}|null}} o the frozen input texts, their labels, how many AI replies (tries) may still change a row, whether code scopes a counting `~` rule in (a pick is asked), and whether a person can be asked at all (`asks`: false = a rule code cannot settle is Not checked, a reading code proposes is built as the AI's proposal) */
|
|
60
37
|
constructor({ texts, labels, maxTries, countScope, asks, split, cited, repo }: {
|
|
@@ -284,7 +261,7 @@ export class CheckBlock {
|
|
|
284
261
|
buildLine(l: {
|
|
285
262
|
n: number;
|
|
286
263
|
text: string;
|
|
287
|
-
}, lineParts: any[], lineRows: string[][], factLines: Set<number
|
|
264
|
+
}, lineParts: any[], lineRows: string[][], factLines: Set<number>): void;
|
|
288
265
|
/**
|
|
289
266
|
* S4: ONE sheet part per sheet line, from the checks code built (the `[you]` rule rows' checks, then the `[agent]` checks the person has not dropped). Every row it carries points at it. A part code cannot legally build leaves its rows Not checked
|
|
290
267
|
* in the stage-shape red's own words; a line whose checks were all dropped has no part and no `[default]` row.
|
package/types/checklist.d.ts
CHANGED
|
@@ -27,11 +27,11 @@ export function isEmptyList(rows: Row[]): boolean;
|
|
|
27
27
|
export function ledgerRecord(rows: Row[]): ({
|
|
28
28
|
key: string;
|
|
29
29
|
line: number;
|
|
30
|
-
rowKind: "
|
|
31
|
-
from: "default" | "agent" | "
|
|
30
|
+
rowKind: "count" | "floor" | "phrase" | "numbers" | "rule" | "fact" | "cited" | "note";
|
|
31
|
+
from: "default" | "agent" | "look" | "rule" | "pick";
|
|
32
32
|
by: "default" | "agent" | "you";
|
|
33
33
|
words: string[];
|
|
34
|
-
state: "
|
|
34
|
+
state: "built" | "dropped" | "not-checked" | "listed";
|
|
35
35
|
reason: string | null;
|
|
36
36
|
} | {
|
|
37
37
|
key: string;
|
package/types/checklistsign.d.ts
CHANGED
|
@@ -25,3 +25,10 @@ export function partByOf(declaration: any, line: number, idx: number): "you" | "
|
|
|
25
25
|
export function factByOf(declaration: any, line: number, name: string): "you" | "agent" | "default" | null;
|
|
26
26
|
/** who made the result count of a list line's quote check, else null @param {any} declaration @param {number} line @returns {'you'|'agent'|'default'|null} */
|
|
27
27
|
export function countByOf(declaration: any, line: number): "you" | "agent" | "default" | null;
|
|
28
|
+
/**
|
|
29
|
+
* The proof of a plan whose list has ticket rows (a plan with none is not examined): a built ticket row needs the declaration's field, and a field the declaration holds needs a built row for it.
|
|
30
|
+
* @param {any} declaration @returns {string[]}
|
|
31
|
+
*/
|
|
32
|
+
export function ticketListReds(declaration: any): string[];
|
|
33
|
+
/** @type {readonly ('ticketFilter'|'ticketWatch')[]} */
|
|
34
|
+
export const TICKET_FIELDS: readonly ("ticketFilter" | "ticketWatch")[];
|
package/types/checkpick.d.ts
CHANGED
|
@@ -20,19 +20,6 @@ export function scopedRules(lines: {
|
|
|
20
20
|
rule: number;
|
|
21
21
|
text: string;
|
|
22
22
|
}[];
|
|
23
|
-
/**
|
|
24
|
-
* Keep a suggestion only if its rule is on bareguard's list, it carries only that rule's own fields, every number in it is a number the guardrail names and
|
|
25
|
-
* every word in it is a word of the guardrail. Anything else is dropped, with the reason. `none` is a drop with the reason `none`.
|
|
26
|
-
* @param {string} guardrail @param {any} sug the model's entry for this guardrail
|
|
27
|
-
* @returns {{kept: true, check: Record<string, any>}|{kept: false, why: string}}
|
|
28
|
-
*/
|
|
29
|
-
export function keepOrDrop(guardrail: string, sug: any): {
|
|
30
|
-
kept: true;
|
|
31
|
-
check: Record<string, any>;
|
|
32
|
-
} | {
|
|
33
|
-
kept: false;
|
|
34
|
-
why: string;
|
|
35
|
-
};
|
|
36
23
|
/**
|
|
37
24
|
* The user message: the job's lines, and under a line only the guardrails this call settles, numbered by their rule number on the line.
|
|
38
25
|
* @param {{n: number, text: string}[]} lines @param {{line: number, rule: number, text: string}[]} scoped @returns {string}
|
|
@@ -62,13 +49,6 @@ export function rowsFromAnswer(scoped: {
|
|
|
62
49
|
check: Record<string, any> | null;
|
|
63
50
|
why: string | null;
|
|
64
51
|
}[];
|
|
65
|
-
/**
|
|
66
|
-
* The check CODE proposes for a count rule when the call yields none: a bullets / list-items / points count -> listItems N, a lines count -> maxLines N, ONE word number ->
|
|
67
|
-
* minWords N when the rule says "at least / minimum / more than", else maxWords N. A section count names no sections, so none is built; a rule naming two different counts is
|
|
68
|
-
* not built either; a rule with several word numbers or a range is not guessed. The result passes `keepOrDrop`, so every number is one the rule names.
|
|
69
|
-
* @param {string} text @returns {Record<string, any>|null}
|
|
70
|
-
*/
|
|
71
|
-
export function countCheck(text: string): Record<string, any> | null;
|
|
72
52
|
/**
|
|
73
53
|
* The asks for the rows: `Line n, guardrail "<…>": I propose <check in plain words>.` for a kept check, `Line n, guardrail "<…>": I can't check this. Your own words, or
|
|
74
54
|
* Not checked?` when nothing was kept. A proposal is not counted toward am1's cap; a can't-check ask is (am16 (5)).
|
|
@@ -139,7 +119,6 @@ export const SUGGEST_SCHEMA: Readonly<{
|
|
|
139
119
|
}>;
|
|
140
120
|
/** the can't-check ask, as the signed words say it */
|
|
141
121
|
export const CANT_CHECK_WORDS: "I can't check this. Your own words, or Not checked?";
|
|
142
|
-
export function HOW_TO_ANSWER(line: number, agree: boolean): string;
|
|
143
122
|
/**
|
|
144
123
|
* `check` = the check the person agreed to (null for their own words); `own` = their own words
|
|
145
124
|
*/
|
package/types/citedwords.d.ts
CHANGED
|
@@ -54,9 +54,10 @@ export function numberRuleReds({ part, jobLine }: {
|
|
|
54
54
|
/**
|
|
55
55
|
* Signed (am7 item 1): "List 3 ..." is the count, 3 results. A count the person never said as a bare number or a word number (not inside a time, a date or an
|
|
56
56
|
* amount) is refused. Same reader as the number rules.
|
|
57
|
-
*
|
|
57
|
+
* M20 am4: a number the person switched on with Add (`added`, src/pickrecord.js `addedCountsOf`: `<line>:min:<n>` / `<line>:max:<n>`) reads as said.
|
|
58
|
+
* @param {{part: any, jobLine: {n: number, text?: string, rule?: string, rules?: string[]}, added?: Set<string>}} o @returns {WordRed[]}
|
|
58
59
|
*/
|
|
59
|
-
export function countReds({ part, jobLine }: {
|
|
60
|
+
export function countReds({ part, jobLine, added }: {
|
|
60
61
|
part: any;
|
|
61
62
|
jobLine: {
|
|
62
63
|
n: number;
|
|
@@ -64,6 +65,7 @@ export function countReds({ part, jobLine }: {
|
|
|
64
65
|
rule?: string;
|
|
65
66
|
rules?: string[];
|
|
66
67
|
};
|
|
68
|
+
added?: Set<string>;
|
|
67
69
|
}): WordRed[];
|
|
68
70
|
/**
|
|
69
71
|
* R2c (am7 item 2): a place the page-read grew to phrases must have EVERY phrase as a phrase fact of the part, or a flipped route passes.
|
|
@@ -92,9 +94,9 @@ export function boundReds({ part, line, jobLine, look, }: {
|
|
|
92
94
|
}): WordRed[];
|
|
93
95
|
/**
|
|
94
96
|
* Every word red for one cited part, in the order a person fixes them.
|
|
95
|
-
* @param {{part: any, text: string|undefined, line: number, jobLine: any, look: {facts?: any[], dropped?: any[]}|null|undefined, doc?: boolean}} o @returns {WordRed[]}
|
|
97
|
+
* @param {{part: any, text: string|undefined, line: number, jobLine: any, look: {facts?: any[], dropped?: any[]}|null|undefined, doc?: boolean, added?: Set<string>}} o @returns {WordRed[]}
|
|
96
98
|
*/
|
|
97
|
-
export function citedWordReds({ part, text, line, jobLine, look, doc, }: {
|
|
99
|
+
export function citedWordReds({ part, text, line, jobLine, look, doc, added, }: {
|
|
98
100
|
part: any;
|
|
99
101
|
text: string | undefined;
|
|
100
102
|
line: number;
|
|
@@ -104,6 +106,7 @@ export function citedWordReds({ part, text, line, jobLine, look, doc, }: {
|
|
|
104
106
|
dropped?: any[];
|
|
105
107
|
} | null | undefined;
|
|
106
108
|
doc?: boolean;
|
|
109
|
+
added?: Set<string>;
|
|
107
110
|
}): WordRed[];
|
|
108
111
|
export type WordRed = {
|
|
109
112
|
code: string;
|
package/types/closers.d.ts
CHANGED
|
@@ -148,5 +148,6 @@ export function closeNumbers(step: any, artifact: unknown, from: number[], numbe
|
|
|
148
148
|
red: string | null;
|
|
149
149
|
text: string;
|
|
150
150
|
};
|
|
151
|
+
export function noJudgment(verdict: unknown): boolean;
|
|
151
152
|
export type CloseVerdict = import("./types.js").CloseVerdict;
|
|
152
153
|
import { createRubric } from 'bareguard';
|
package/types/declaration.d.ts
CHANGED
|
@@ -32,12 +32,6 @@ export function checkShapes(declaration: any): {
|
|
|
32
32
|
reds: any[];
|
|
33
33
|
shapedSteps: number;
|
|
34
34
|
};
|
|
35
|
-
/** Every whole-output word number in a guardrail ("3 sections, under 600 words, each heading at most 3 words" -> [600, 3]), in order; [] when
|
|
36
|
-
* there is none. Code does not decide which one is the limit: the AI picks `maxWords` and the validator checks the pick is one of these
|
|
37
|
-
* (M4e amendments 28 + 29). A "<n> words each" / "<n> words per section" is the per-section size (amendment 15), never listed here. */
|
|
38
|
-
export function guardrailWordNumbers(guardrail: any): number[];
|
|
39
|
-
/** M10 amendment 14 item 2: every standalone number in a guardrail's own text (digits not joined to letters: "P1" and "250ish" are not one; "1,000" and "2.5" are one number each). */
|
|
40
|
-
export function guardrailStandaloneNumbers(guardrail: any): number[];
|
|
41
35
|
/** M10 amendment 14 item 1: the send line (a signed send) is where the accepted result is written out and no AI runs, so a guardrail under it is refused at $0, naming the line.
|
|
42
36
|
* Pure; the card (src/panel/authorcard.js checkCard) and the drafter's pre-flight both call it. @param {any[]} lines `parseSignedText`'s lines @param {{sends?: {line: number}[]}} arbiter */
|
|
43
37
|
export function checkSendLineGuardrail(lines: any[], arbiter: {
|
|
@@ -45,12 +39,6 @@ export function checkSendLineGuardrail(lines: any[], arbiter: {
|
|
|
45
39
|
line: number;
|
|
46
40
|
}[];
|
|
47
41
|
}): string[];
|
|
48
|
-
/** M4e amendment 15 item 1: the "<n> words each" / "<n> words per section" size in a guardrail ("about 250 words each", "250ish each" -> 250), or null. */
|
|
49
|
-
export function guardrailWordsPerSection(guardrail: any): number | null;
|
|
50
|
-
/** M4e amendment 7 item 1: the first "<N> sections" in a guardrail (N digits, or the words one..ten), or null. */
|
|
51
|
-
export function guardrailSectionCount(guardrail: any): any;
|
|
52
|
-
/** M10 amendment 23: the first "<N> bullets / list items / items / lines / points" in a guardrail (N digits, or the words one..ten; not a price like "$5 per item"), or null. */
|
|
53
|
-
export function guardrailItemCount(guardrail: any): any;
|
|
54
42
|
/** M4e amendment 15 item 2: for each line whose guardrail gives a size for each section, a section count AND a word number,
|
|
55
43
|
* size x count more than the LARGEST word number (no possible pick fits) is a red naming the line and the numbers. $0; run before any model
|
|
56
44
|
* call, when there is no AI pick yet (amendment 29). After the draft the AI's `maxWords` is checked in checkShapeFitsJobLine. */
|
|
@@ -80,7 +68,7 @@ export function checkShapeFitsJobLine(step: any, i: any, lines: any, reds: any):
|
|
|
80
68
|
* `sheetWords` (optional; M10 am8 item 2): `{headers: {role: header names}, facts: the columns the sheet look kept}`. With `fitJobLine`, every column a step's `close.columns` names
|
|
81
69
|
* is proved a real column of its sheet, and a column the code kept for the step's line (an agreed one included) must be in it.
|
|
82
70
|
* `sheetWords.tables` (optional; M10b piece 1): `{role: bareguard table}` of the drafting copy. With it, every `close.sheet` check passes bareguard's sign-time test at $0.
|
|
83
|
-
* @param {{ arbiter?: unknown, lines?: unknown, catalogue?: unknown, wired?: Set<string>, verbatimGoals?: boolean, fitJobLine?: boolean, pageWords?: {texts: Record<string, string>, look: any, docs?: string[]}, sheetWords?: {headers: Record<string, string[]>, facts: any[], tables?: Record<string, {header: string[], rows: any[]}>} }} [context]
|
|
71
|
+
* @param {{ arbiter?: unknown, lines?: unknown, catalogue?: unknown, wired?: Set<string>, verbatimGoals?: boolean, fitJobLine?: boolean, addedCounts?: Set<string>, pageWords?: {texts: Record<string, string>, look: any, docs?: string[]}, sheetWords?: {headers: Record<string, string[]>, facts: any[], tables?: Record<string, {header: string[], rows: any[]}>} }} [context]
|
|
84
72
|
* @returns {ValidateDeclarationResult}
|
|
85
73
|
*/
|
|
86
74
|
export function validateDeclaration(declaration: unknown, context?: {
|
|
@@ -90,6 +78,7 @@ export function validateDeclaration(declaration: unknown, context?: {
|
|
|
90
78
|
wired?: Set<string>;
|
|
91
79
|
verbatimGoals?: boolean;
|
|
92
80
|
fitJobLine?: boolean;
|
|
81
|
+
addedCounts?: Set<string>;
|
|
93
82
|
pageWords?: {
|
|
94
83
|
texts: Record<string, string>;
|
|
95
84
|
look: any;
|
|
@@ -114,14 +103,15 @@ export function validateDeclaration(declaration: unknown, context?: {
|
|
|
114
103
|
export const DECLARATION_FIELDS: readonly string[];
|
|
115
104
|
/** M13 piece 4 (signed item 4): the job's flow type, set by code from the job card, signed with the job. */
|
|
116
105
|
export const FLOW_TYPES: readonly string[];
|
|
106
|
+
export function isFlowType(t: unknown): boolean;
|
|
117
107
|
/** The typed `close.shape` vocabulary, signed by hamr 2026-09-23 (v1):
|
|
118
108
|
* exactly these four top-level keys. Anything else inside `shape` reds by
|
|
119
109
|
* name. */
|
|
120
110
|
export const SHAPE_KEYS: readonly string[];
|
|
121
111
|
/** Shape keys only the MACHINE sets (M4e amendment 15): read from the line's guardrail, never offered to the drafter's model. */
|
|
122
112
|
export const MACHINE_SHAPE_KEYS: readonly string[];
|
|
123
|
-
export function isCountGuardrail(guardrail: any): boolean;
|
|
124
113
|
export type Arbiter = import("./types.js").Arbiter;
|
|
125
114
|
export type SignedLine = import("./types.js").SignedLine;
|
|
126
115
|
export type CatalogueEntry = import("./types.js").CatalogueEntry;
|
|
127
116
|
export type ValidateDeclarationResult = import("./types.js").ValidateDeclarationResult;
|
|
117
|
+
export { guardrailWordNumbers, guardrailStandaloneNumbers, guardrailWordsPerSection, guardrailSectionCount, guardrailItemCount } from "./blockpick.js";
|
package/types/diary.d.ts
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* M20 am3g item 23: the ONE rule for a step's newest-try checks, over the run's `checks` rows (`readChecks`): a row of this step with a whole-number `try` and a `checks` list;
|
|
3
|
+
* the highest `try`, a tie going to the later row; the row, or null when the step has none. The Audit, the Result tab and the ticket grid ask it and keep their own words
|
|
4
|
+
* and tags; the Audit card's "checks on the last try" count asks it too (its per-try fold is another question).
|
|
5
|
+
* @param {any[]|null|undefined} diary @param {unknown} stepId @returns {any|null}
|
|
6
|
+
*/
|
|
7
|
+
export function newestChecksOf(diary: any[] | null | undefined, stepId: unknown): any | null;
|
|
1
8
|
export const DIARY_FILE: "diary.jsonl";
|
|
2
9
|
export function diaryPaths(runDir: string): string[];
|
|
3
10
|
export function appendCall(runDir: string, row: {
|
|
@@ -47,8 +54,14 @@ export function appendChecks(runDir: string, row: {
|
|
|
47
54
|
sha256: string;
|
|
48
55
|
} | null;
|
|
49
56
|
}): void;
|
|
57
|
+
export function appendTryStart(runDir: string, row: {
|
|
58
|
+
step: string | null;
|
|
59
|
+
try: number;
|
|
60
|
+
at: string;
|
|
61
|
+
}): void;
|
|
50
62
|
export function readCalls(runDir: string): any[];
|
|
51
63
|
export function readTools(runDir: string): any[];
|
|
52
64
|
export function readChecks(runDir: string): any[];
|
|
65
|
+
export function readTryStarts(runDir: string): any[];
|
|
53
66
|
export function nextRound(runDir: string, step: string | null): any;
|
|
54
|
-
export type DiaryKind = "call" | "tool" | "checks";
|
|
67
|
+
export type DiaryKind = "call" | "tool" | "checks" | "try-start";
|
package/types/draft-steps.d.ts
CHANGED
|
@@ -45,3 +45,10 @@ export function reviseStepList({ log, name }: {
|
|
|
45
45
|
details: string[];
|
|
46
46
|
note?: boolean;
|
|
47
47
|
}> | null;
|
|
48
|
+
/** a plan folder's card file: `card-<n>.json` (n = the redraft or revise number) */
|
|
49
|
+
export const CARD_RE: RegExp;
|
|
50
|
+
/** how much of the end of a child's log a person is shown when it stopped or refused */
|
|
51
|
+
export const LOG_TAIL_CHARS: 1500;
|
|
52
|
+
export function draftLogName(kind: string, n: number): string;
|
|
53
|
+
/** a name that is a revise's or a redraft's log */
|
|
54
|
+
export const DRAFT_LOG_RE: RegExp;
|
package/types/drafter.d.ts
CHANGED
|
@@ -311,7 +311,7 @@ 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 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[]}>}
|
|
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[], box?:string}>}
|
|
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
|
*/
|
|
@@ -364,7 +364,7 @@ export function draft({ proseText, slot, model, provider: injected, rates: injec
|
|
|
364
364
|
ids: string[];
|
|
365
365
|
} | null | undefined;
|
|
366
366
|
mcpServers?: string[] | undefined;
|
|
367
|
-
flowType?: "
|
|
367
|
+
flowType?: "mcp" | "plain" | "tickets" | undefined;
|
|
368
368
|
mcp?: any;
|
|
369
369
|
actionMode?: "check" | "known" | null | undefined;
|
|
370
370
|
}): Promise<{
|
|
@@ -421,6 +421,7 @@ export function draft({ proseText, slot, model, provider: injected, rates: injec
|
|
|
421
421
|
mapping: any;
|
|
422
422
|
}[];
|
|
423
423
|
sheetLooks?: any[];
|
|
424
|
+
box?: string;
|
|
424
425
|
}>;
|
|
425
426
|
export const MAX_STRUCTURE_RETRIES: 2;
|
|
426
427
|
export const MAX_REVISIONS: 2;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* M20 am3 item 12: the ONE reader of one plan folder's verdict, from its files (`spec.hash`, `scrub-leak.red`, `log.json`). Green = a
|
|
3
|
+
* non-empty spec.hash; red = a leak marker or a log that says not ok (`reds` = the log's own reds, then the marker's text); none otherwise.
|
|
4
|
+
* `hashFile` and `leak` are the raw reads, so sign can name a missing or refused file in its own words. Callers scrub `reds` themselves.
|
|
5
|
+
* @param {string} dir the folder that holds the plan folder @param {string} [rel] `draft`, `draft-<n>` or `.` (the plan folder itself)
|
|
6
|
+
* @returns {{verdict: 'green'|'red'|'none', hash: string|null, hashFile: ReturnType<typeof readFileInside>, leak: ReturnType<typeof readFileInside>, log: any, reds: string[]}}
|
|
7
|
+
*/
|
|
8
|
+
export function draftVerdict(dir: string, rel?: string): {
|
|
9
|
+
verdict: "green" | "red" | "none";
|
|
10
|
+
hash: string | null;
|
|
11
|
+
hashFile: ReturnType<typeof readFileInside>;
|
|
12
|
+
leak: ReturnType<typeof readFileInside>;
|
|
13
|
+
log: any;
|
|
14
|
+
reds: string[];
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* The questions a plan folder raised and the answers on disk, READ from its files — the ONE reader (the panel's phase reader, the sign
|
|
18
|
+
* checks and the page all use it). `questions` = [{ k, line, question, answer|null }], `open` = those with no answer. A blank or unreadable
|
|
19
|
+
* answer file counts as no answer. No questions file = `{ questions: [], open: [] }`.
|
|
20
|
+
* @param {string} planDir
|
|
21
|
+
* A question the page look raised (M10 piece 3) also carries `source: 'look'`, `ask` ('reading' | 'cant-check'), `ruleNo`, `ruleText` and `proposal`; an answer file carries `at`.
|
|
22
|
+
* @returns {{ questions: {k:number, line:number, question:string, answer:string|null, at?:string, rule?:string|null, choice?:'agree'|'drop'|'rule'|'column', source?:string, ask?:string, ruleNo?:number, ruleText?:string, proposal?:string|null, check?:Record<string, any>, pairRule?:number, columns?:string[], readings?:Record<string,string>}[], open: {k:number, line:number, question:string, answer:null}[] }}
|
|
23
|
+
*/
|
|
24
|
+
export function readQuestions(planDir: string): {
|
|
25
|
+
questions: {
|
|
26
|
+
k: number;
|
|
27
|
+
line: number;
|
|
28
|
+
question: string;
|
|
29
|
+
answer: string | null;
|
|
30
|
+
at?: string;
|
|
31
|
+
rule?: string | null;
|
|
32
|
+
choice?: "agree" | "drop" | "rule" | "column";
|
|
33
|
+
source?: string;
|
|
34
|
+
ask?: string;
|
|
35
|
+
ruleNo?: number;
|
|
36
|
+
ruleText?: string;
|
|
37
|
+
proposal?: string | null;
|
|
38
|
+
check?: Record<string, any>;
|
|
39
|
+
pairRule?: number;
|
|
40
|
+
columns?: string[];
|
|
41
|
+
readings?: Record<string, string>;
|
|
42
|
+
}[];
|
|
43
|
+
open: {
|
|
44
|
+
k: number;
|
|
45
|
+
line: number;
|
|
46
|
+
question: string;
|
|
47
|
+
answer: null;
|
|
48
|
+
}[];
|
|
49
|
+
};
|
|
50
|
+
/** Literal (never RegExp) key scrub; a secret under 8 chars is skipped so it can't blank ordinary text. */
|
|
51
|
+
export function scrub(text: any, secrets: any): any;
|
|
52
|
+
/**
|
|
53
|
+
* M20 am3 item 10: the ONE reader of a plan folder's `not-checked.json`. `notChecked` is the file's own list as it is (any type; the callers keep what they
|
|
54
|
+
* accept of it: `notCheckedBlock`/`notCheckedView` filter strings, the rebuild keeps strings), `by` the tag of each line when the file holds an object, else null.
|
|
55
|
+
* A missing, refused, unparseable or non-object file reads as `{notChecked: undefined, by: null}` (a plan from before amendment 25 has none).
|
|
56
|
+
* @param {string} dir the folder that holds the plan folder @param {string} [rel] `draft`, `draft-<n>` or `.` (the plan folder itself)
|
|
57
|
+
* @returns {{notChecked: any, by: Record<string, any>|null}}
|
|
58
|
+
*/
|
|
59
|
+
export function readNotCheckedFile(dir: string, rel?: string): {
|
|
60
|
+
notChecked: any;
|
|
61
|
+
by: Record<string, any> | null;
|
|
62
|
+
};
|
|
63
|
+
/** @param {string} dir the session folder @param {number} n @returns {Record<string, any>|null} */
|
|
64
|
+
export function readRedraftMarker(dir: string, n: number): Record<string, any> | null;
|
|
65
|
+
/**
|
|
66
|
+
* M20 am3e item 20: a draft plan folder's job text and steps, the ONE reader. `proseText` is prose.txt as it is (null when missing or refused), `parsed` the signed-text
|
|
67
|
+
* parse of it (`parseSignedText`'s result, ok or not; null when there is no prose), `declaration` declaration.json as an object (null when missing, refused, not JSON or not
|
|
68
|
+
* an object). Each caller keeps its own sentence for what it does when one is null. (A flow folder with a signature is `readFlow`'s; a plan that falls back to
|
|
69
|
+
* declaration.rejected.json is src/panel/author.js `stepListOf`'s own question.)
|
|
70
|
+
* @param {string} dir the folder that holds the plan folder @param {string} [rel] `draft`, `draft-<n>` or `.` (the plan folder itself)
|
|
71
|
+
* @returns {{proseText: string|null, parsed: ReturnType<typeof parseSignedText>|null, declaration: any}}
|
|
72
|
+
*/
|
|
73
|
+
export function readPlanTexts(dir: string, rel?: string): {
|
|
74
|
+
proseText: string | null;
|
|
75
|
+
parsed: ReturnType<typeof parseSignedText> | null;
|
|
76
|
+
declaration: any;
|
|
77
|
+
};
|
|
78
|
+
export const SPEC_HASH_FILE: "spec.hash";
|
|
79
|
+
/** Written when the end sweep finds a key in the draft dir; sign refuses a dir that has it. */
|
|
80
|
+
export const LEAK_MARKER_FILE: "scrub-leak.red";
|
|
81
|
+
export const QUESTIONS_FILE: "questions.json";
|
|
82
|
+
export function ANSWER_FILE(k: any): string;
|
|
83
|
+
/** the drafter's own "Not checked" reading, kept in a plan folder (information only; never in the readout, so never in the hash) */
|
|
84
|
+
export const NOT_CHECKED_FILE: "not-checked.json";
|
|
85
|
+
export function cardFileName(n?: number): string;
|
|
86
|
+
export function readCard(dir: string, n?: number): Record<string, any> | null;
|
|
87
|
+
export function redraftFileName(n: number): string;
|
|
88
|
+
import { readFileInside } from './inside.js';
|
|
89
|
+
import { parseSignedText } from './signed-text.js';
|
package/types/draftspend.d.ts
CHANGED
|
@@ -18,6 +18,12 @@ export function readDraftSpend(dir: string): Record<string, any> | null;
|
|
|
18
18
|
* @returns {Record<string, any>[]}
|
|
19
19
|
*/
|
|
20
20
|
export function readDirSpendRows(dir: string): Record<string, any>[];
|
|
21
|
+
/**
|
|
22
|
+
* M20 am3 item 12: the ONE reader of a session folder's `started-over-from.json`: the `startedOverFrom` value it holds, or null when
|
|
23
|
+
* there is no file, it is unreadable, or it holds none. (A value that is not a session id is the caller's to judge.)
|
|
24
|
+
* @param {string} sessionDir @returns {unknown}
|
|
25
|
+
*/
|
|
26
|
+
export function readStartedOverFrom(sessionDir: string): unknown;
|
|
21
27
|
/**
|
|
22
28
|
* M4d amendment 16 item 1: what ALL of a job's drafting spent — the one writer of that total. A panel draft's session folder holds one plan
|
|
23
29
|
* folder per draft (`draft/`, `draft-<n>/` for each revise and the redraft after answers); each is read by `readDirSpendRows` and priced by
|
|
@@ -69,9 +75,77 @@ export function draftHoldUsd(proseText: string, outDir: string, ceilingUsd: numb
|
|
|
69
75
|
* @param {'drafting'|'run'} kind @param {number} capUsd @param {number} minUsd @param {string} modelId
|
|
70
76
|
*/
|
|
71
77
|
export function capTooSmallText(kind: "drafting" | "run", capUsd: number, minUsd: number, modelId: string): string;
|
|
78
|
+
/**
|
|
79
|
+
* The ONE writer of the step lines. `emit(kind, record)` prints one line (the CLI passes stderr). Each call is given the result so far
|
|
80
|
+
* (`log`, as log.json will hold it) and writes a start for every step not yet started, and an end for every step but the last (the running one);
|
|
81
|
+
* `final` ends them all. A step is keyed by its `id`: written once.
|
|
82
|
+
* @param {(kind: 'step-start'|'step-end', rec: Record<string, any>) => void} emit
|
|
83
|
+
*/
|
|
84
|
+
export function makeStepWriter(emit: (kind: "step-start" | "step-end", rec: Record<string, any>) => void): (/** @type {any} */ log: any, /** @type {any} */ declaration: any, final: any) => void;
|
|
85
|
+
/**
|
|
86
|
+
* Fold the step lines of `<dir>/child.log` into one record per step, oldest first. A line that cannot be parsed is skipped.
|
|
87
|
+
* @param {string} dir the draft folder @param {string} [file] the child's log: `child.log` (the first draft), `revise-<n>.log` or `redraft-<n>.log`
|
|
88
|
+
* @returns {{no: number, id: string, label: string, status: 'running'|'done'|'failed', startedAt: string, endedAt: string|null, wallMs: number|null}[]}
|
|
89
|
+
*/
|
|
90
|
+
export function readDraftSteps(dir: string, file?: string): {
|
|
91
|
+
no: number;
|
|
92
|
+
id: string;
|
|
93
|
+
label: string;
|
|
94
|
+
status: "running" | "done" | "failed";
|
|
95
|
+
startedAt: string;
|
|
96
|
+
endedAt: string | null;
|
|
97
|
+
wallMs: number | null;
|
|
98
|
+
}[];
|
|
99
|
+
/** M:SS, the ONE spelling of a drafting time ("took 0:42", "Drafting so far: 2:00"). @param {number} ms @returns {string} */
|
|
100
|
+
export function mmss(ms: number): string;
|
|
101
|
+
/**
|
|
102
|
+
* The drafting's whole time: the first step's start to the last step's end; `null` when no step has both times.
|
|
103
|
+
* @param {{startedAt: string, endedAt: string|null}[]} steps `readDraftSteps`' records
|
|
104
|
+
* @returns {number|null}
|
|
105
|
+
*/
|
|
106
|
+
export function draftWallMs(steps: {
|
|
107
|
+
startedAt: string;
|
|
108
|
+
endedAt: string | null;
|
|
109
|
+
}[]): number | null;
|
|
110
|
+
/**
|
|
111
|
+
* The ONE owner of the times on the chat's drafting list. While the draft runs the list is the started steps (`no` order, latest label), each `time` "M:SS so far"
|
|
112
|
+
* (a finished one "took M:SS") and `draftSoFar` is "Drafting so far: M:SS". After it ends `list` is `draftStepList`'s list unchanged, each line taking the times of the
|
|
113
|
+
* step line with the same `id` (the first unused, in order); a line no step line matches (thinking, a Fix note) has no time. No lines = no times, `draftSoFar` null.
|
|
114
|
+
* A revise or answer redraft is read from its own log (`file`); its one `plan` line (`reviseStepList`) takes the draft's whole time (`wholeId`).
|
|
115
|
+
* @param {{dir: string, running: boolean, list: any[]|null, nowMs?: number, file?: string, wholeId?: string}} p `dir` = the draft folder, `file` = the child's log in it, `list` = draftStepList's (or reviseStepList's) list or null
|
|
116
|
+
* @returns {{list: any[]|null, draftSoFar: string|null}}
|
|
117
|
+
*/
|
|
118
|
+
export function withDraftTimes({ dir, running, list, nowMs, file, wholeId }: {
|
|
119
|
+
dir: string;
|
|
120
|
+
running: boolean;
|
|
121
|
+
list: any[] | null;
|
|
122
|
+
nowMs?: number;
|
|
123
|
+
file?: string;
|
|
124
|
+
wholeId?: string;
|
|
125
|
+
}): {
|
|
126
|
+
list: any[] | null;
|
|
127
|
+
draftSoFar: string | null;
|
|
128
|
+
};
|
|
129
|
+
/**
|
|
130
|
+
* The plan card's one line: "Drafted in M:SS · $X". The time is the session's first step start to its last step end across ALL its drafts (the first, each revise,
|
|
131
|
+
* each answer redraft); the money is the session's drafting spend (`draftingSpent`, handed in as `spentUsd`; "at least" when `complete` is false). `null` when no
|
|
132
|
+
* step line has a time or the spend is not a number (a Reuse, an old draft, a session that never knew its cost): nothing is made up.
|
|
133
|
+
* @param {{dir: string, spentUsd: number|null, complete: boolean}} p `dir` = the session's draft folder
|
|
134
|
+
* @returns {string|null}
|
|
135
|
+
*/
|
|
136
|
+
export function draftedLine({ dir, spentUsd, complete }: {
|
|
137
|
+
dir: string;
|
|
138
|
+
spentUsd: number | null;
|
|
139
|
+
complete: boolean;
|
|
140
|
+
}): string | null;
|
|
72
141
|
export const DRAFT_SPEND_FILE: "draft-spend.json";
|
|
73
142
|
/** M4d am21 item 2: the one sentence for a Start over (or revise, or sign) whose chain names an earlier draft that is gone. */
|
|
74
143
|
export const EARLIER_MISSING_SAY: "An earlier draft of this job is missing, so its spend can't be counted.";
|
|
75
144
|
/** The file a Start over's session folder carries to name the session it started over from (written once by src/panel/author.js). */
|
|
76
145
|
export const STARTED_OVER_FILE: "started-over-from.json";
|
|
77
146
|
export function usdText(n: number): string;
|
|
147
|
+
export const STEP_LINE_RE: RegExp;
|
|
148
|
+
export const STEP_LINE_PREFIXES: string[];
|
|
149
|
+
/** a running time moves in 30 s steps, never a ticking clock (the page polls often; the words change every 30 s) */
|
|
150
|
+
export const TIME_STEP_MS: 30000;
|
|
151
|
+
export function stepped(ms: number): number;
|
package/types/flow.d.ts
CHANGED
|
@@ -126,63 +126,18 @@ export function claimRunId(flowDir: string): {
|
|
|
126
126
|
red: string;
|
|
127
127
|
};
|
|
128
128
|
/**
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
*
|
|
134
|
-
* to somewhere inside `realpath(baseDir)` — the second check alone also
|
|
135
|
-
* catches a symlinked ANCESTOR directory partway down `relPath` (e.g.
|
|
136
|
-
* `asks/` itself replaced by a symlink to an outside directory), the same
|
|
137
|
-
* shape `readFlow`'s own `runs/` check and `resolveRunDir` already apply one
|
|
138
|
-
* level up. A path that does not exist yet is reported as `missing: true`
|
|
139
|
-
* (never a red) so every existing caller keeps its own "not written yet"
|
|
140
|
-
* behaviour unchanged.
|
|
141
|
-
*
|
|
142
|
-
* @param {string} baseDir
|
|
143
|
-
* @param {string} relPath
|
|
144
|
-
* @returns {{ok:true, full:string}|{ok:false, missing:true}|{ok:false, missing:false, red:string}}
|
|
129
|
+
* M20 am1 item 4: the ONE reader of a DRAFT's `log.json` (`<dir>/<rel>/log.json`, or `<dir>/log.json` with no `rel`): what the drafter kept of its rounds,
|
|
130
|
+
* its `checkCard` and its `action`. The run's `log.json` is another file, read only by `readLog` (src/books.js). `null` when missing, refused by the
|
|
131
|
+
* gateway, unparseable or not an object (a torn write), never a thrown error.
|
|
132
|
+
* @param {string} dir @param {string} [rel] a plan folder under `dir` (`draft`, `draft-<n>`)
|
|
133
|
+
* @returns {any|null}
|
|
145
134
|
*/
|
|
146
|
-
export function
|
|
147
|
-
ok: true;
|
|
148
|
-
full: string;
|
|
149
|
-
} | {
|
|
150
|
-
ok: false;
|
|
151
|
-
missing: true;
|
|
152
|
-
} | {
|
|
153
|
-
ok: false;
|
|
154
|
-
missing: false;
|
|
155
|
-
red: string;
|
|
156
|
-
};
|
|
135
|
+
export function readDraftLog(dir: string, rel?: string): any | null;
|
|
157
136
|
/**
|
|
158
|
-
*
|
|
159
|
-
*
|
|
160
|
-
* @param {string} baseDir
|
|
161
|
-
* @param {string} relPath
|
|
162
|
-
* @returns {{ok:true, text:string}|{ok:false, missing:true}|{ok:false, missing:false, red:string}}
|
|
137
|
+
* M20 am3 item 12: the ONE tolerant JSON read of a file in a folder, through the gateway: the parsed object, or null when the file is missing, refused,
|
|
138
|
+
* unparseable (a torn write) or not an object. Never throws. @param {string} dir @param {string} rel @returns {any|null}
|
|
163
139
|
*/
|
|
164
|
-
export function
|
|
165
|
-
ok: true;
|
|
166
|
-
text: string;
|
|
167
|
-
} | {
|
|
168
|
-
ok: false;
|
|
169
|
-
missing: true;
|
|
170
|
-
} | {
|
|
171
|
-
ok: false;
|
|
172
|
-
missing: false;
|
|
173
|
-
red: string;
|
|
174
|
-
};
|
|
175
|
-
/**
|
|
176
|
-
* `readdirSync` guarded the same way: refuses (returns `[]`) when `relDir`
|
|
177
|
-
* itself is a symlink or resolves outside `baseDir`, and skips (never
|
|
178
|
-
* follows) any individual entry that is itself a symlink — a directory
|
|
179
|
-
* listing must never hand a caller a name that, joined back onto `relDir`,
|
|
180
|
-
* would escape `baseDir`. `[]` when `relDir` doesn't exist.
|
|
181
|
-
* @param {string} baseDir
|
|
182
|
-
* @param {string} relDir
|
|
183
|
-
* @returns {string[]}
|
|
184
|
-
*/
|
|
185
|
-
export function readdirInside(baseDir: string, relDir: string): string[];
|
|
140
|
+
export function readJsonFile(dir: string, rel: string): any | null;
|
|
186
141
|
/**
|
|
187
142
|
* Write a signed flow to `<root>/<name>/`. Refuses (writing nothing) if the
|
|
188
143
|
* flow name is invalid, if `proseText`/`declaration` don't parse/validate,
|
|
@@ -241,6 +196,29 @@ export function planForReuse({ root, name, runDir, catalogue, }: {
|
|
|
241
196
|
ok: false;
|
|
242
197
|
red: string;
|
|
243
198
|
};
|
|
199
|
+
/**
|
|
200
|
+
* M20 am3 item 1 (as am3a): the ONE rule for "this run ran the job the flow holds now": the run's verified job copy (`readRunJobCopy`), the exact
|
|
201
|
+
* declaration, the prose without its trigger line. `{present:false}` = the run kept no copy (before M6); `{present:true, ok:false, reds}` = a copy that
|
|
202
|
+
* fails its signature; `{present:true, ok:true, same, ...copy}` otherwise.
|
|
203
|
+
* @param {{flowDir: string, runDir: string, catalogue: unknown}} a
|
|
204
|
+
* @returns {{present: false} | {present: true, ok: false, reds: string[]} | ({present: true, same: boolean} & ReadFlowResult & {ok: true})}
|
|
205
|
+
*/
|
|
206
|
+
export function sameJob({ flowDir, runDir, catalogue }: {
|
|
207
|
+
flowDir: string;
|
|
208
|
+
runDir: string;
|
|
209
|
+
catalogue: unknown;
|
|
210
|
+
}): {
|
|
211
|
+
present: false;
|
|
212
|
+
} | {
|
|
213
|
+
present: true;
|
|
214
|
+
ok: false;
|
|
215
|
+
reds: string[];
|
|
216
|
+
} | ({
|
|
217
|
+
present: true;
|
|
218
|
+
same: boolean;
|
|
219
|
+
} & ReadFlowResult & {
|
|
220
|
+
ok: true;
|
|
221
|
+
});
|
|
244
222
|
/**
|
|
245
223
|
* M6 am9: give the run folder `runDir` a verified copy of the plan run `fromRunDir` kept (`job/` write-once, then `plan.json {planOf}`), so the run executes
|
|
246
224
|
* it. Nothing is signed: the bytes already carry a signature, proved here. A failure removes what this call wrote.
|
package/types/index.d.ts
CHANGED
|
@@ -5,6 +5,6 @@ export { signFlow, verifyFlow, canonicalBytes, SIGNATURE_FIELDS } from "./signat
|
|
|
5
5
|
export { validateDeclaration, DECLARATION_FIELDS } from "./declaration.js";
|
|
6
6
|
export { parseCatalogue, loadCatalogue, menu, primitiveFor, resolveEntry, CATALOGUE_FIELDS } from "./catalogue.js";
|
|
7
7
|
export { checkFlowName, checkRunId, resolveRunDir, writeFlow, readFlow, listFlowNames, listRunIds, FLOW_FILES } from "./flow.js";
|
|
8
|
-
export { runFlow, resumeRun, makeParkingAskStep, STRIKE_LIMIT, MAX_ATTEMPTS, readAsk
|
|
9
|
-
export {
|
|
10
|
-
export {
|
|
8
|
+
export { runFlow, resumeRun, makeParkingAskStep, STRIKE_LIMIT, MAX_ATTEMPTS, readAsk } from "./runner.js";
|
|
9
|
+
export { readRunState, readLog, appendAudit, appendHistory, readAudit, readHistory, auditRowTokens, auditRowTools } from "./books.js";
|
|
10
|
+
export { answerAsk, readAskEvidence, writeAskArchive, listArchivedAsks } from "./ask.js";
|