fwdloop 0.22.0 → 0.24.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 +31 -8
- package/package.json +2 -2
- package/src/ask.js +34 -4
- package/src/attemptdiff.js +118 -0
- package/src/audit-fold.js +2 -0
- package/src/authoring.js +36 -2
- package/src/canrun.js +5 -0
- package/src/checked.js +14 -3
- package/src/citedcheck.js +16 -1
- package/src/citedwords.js +36 -2
- package/src/closers.js +13 -223
- package/src/config.js +5 -1
- package/src/csv.js +69 -12
- package/src/declaration.js +64 -6
- package/src/drafter.js +43 -17
- package/src/flowmodel.js +56 -1
- package/src/learn.js +952 -0
- package/src/learnstore.js +346 -0
- package/src/model-step.js +15 -21
- package/src/pagedry.js +3 -4
- package/src/pagefetch.js +9 -2
- package/src/pagerules.js +28 -5
- package/src/panel/author.js +2 -1
- package/src/panel/authorcard.js +9 -2
- package/src/panel/data.js +80 -17
- package/src/panel/index.html +186 -12
- package/src/panel/result.js +6 -0
- package/src/redact.js +6 -6
- package/src/runner.js +151 -24
- 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/sheetoffer.js +125 -0
- package/src/sheetrun.js +105 -0
- package/src/thinking.js +11 -0
- package/src/try-checks.js +6 -0
- package/src/types.js +1 -9
- package/types/ask.d.ts +8 -2
- package/types/attemptdiff.d.ts +38 -0
- package/types/checked.d.ts +9 -3
- package/types/citedwords.d.ts +14 -0
- package/types/closers.d.ts +6 -31
- package/types/csv.d.ts +25 -4
- package/types/declaration.d.ts +6 -1
- package/types/drafter.d.ts +28 -9
- package/types/flowmodel.d.ts +36 -0
- package/types/learn.d.ts +576 -0
- package/types/learnstore.d.ts +168 -0
- package/types/model-step.d.ts +19 -30
- package/types/pagerules.d.ts +7 -0
- package/types/panel/authorcard.d.ts +2 -1
- package/types/panel/data.d.ts +2 -1
- package/types/panel/result.d.ts +1 -1
- package/types/runner.d.ts +19 -6
- 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/sheetoffer.d.ts +25 -0
- package/types/sheetrun.d.ts +35 -0
- package/types/thinking.d.ts +11 -0
- package/types/types.d.ts +16 -11
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cut `text` to at most `max` bytes at a LINE boundary (never mid-line).
|
|
3
|
+
* @param {string} text @param {number} max
|
|
4
|
+
* @returns {{text: string, truncated: boolean, cutLines: number}}
|
|
5
|
+
*/
|
|
6
|
+
export function cutAtLine(text: string, max: number): {
|
|
7
|
+
text: string;
|
|
8
|
+
truncated: boolean;
|
|
9
|
+
cutLines: number;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Begin recording one worker try. Call BEFORE the worker's turn; call `finish()` after
|
|
13
|
+
* (in a `finally`). Never throws.
|
|
14
|
+
* @param {{workdir: string, fence: string[], redact?: (s: string) => string}} o
|
|
15
|
+
* `fence` = the ABSOLUTE write-scope prefixes the gate enforces for this try.
|
|
16
|
+
* @returns {Promise<{finish: () => Promise<null | {files: {path: string, diff: string, truncated: boolean, cutLines: number}[], binary: string[], truncated: boolean, gitError?: string}>}>}
|
|
17
|
+
* `finish()` resolves null when the try changed nothing in scope.
|
|
18
|
+
*/
|
|
19
|
+
export function startAttemptDiff({ workdir, fence, redact }: {
|
|
20
|
+
workdir: string;
|
|
21
|
+
fence: string[];
|
|
22
|
+
redact?: (s: string) => string;
|
|
23
|
+
}): Promise<{
|
|
24
|
+
finish: () => Promise<null | {
|
|
25
|
+
files: {
|
|
26
|
+
path: string;
|
|
27
|
+
diff: string;
|
|
28
|
+
truncated: boolean;
|
|
29
|
+
cutLines: number;
|
|
30
|
+
}[];
|
|
31
|
+
binary: string[];
|
|
32
|
+
truncated: boolean;
|
|
33
|
+
gitError?: string;
|
|
34
|
+
}>;
|
|
35
|
+
}>;
|
|
36
|
+
/** per-file and per-event byte caps for the recorded diff text */
|
|
37
|
+
export const ATTEMPT_DIFF_FILE_MAX: 4096;
|
|
38
|
+
export const ATTEMPT_DIFF_EVENT_MAX: 16384;
|
package/types/checked.d.ts
CHANGED
|
@@ -1,20 +1,25 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* One entry per step, in plan order: the plain sentences for what its typed close checks.
|
|
3
|
-
*
|
|
3
|
+
* M10b piece 4: with `lines` (the signed job lines) a step that reads a sheet also carries `sheet`, its line's block (src/sheetblock.js `sheetLineBlocks`: guardrails,
|
|
4
|
+
* Checked with `covers`, Not checked), and its sentences are only the lead sentence; the surfaces draw the block. Without `lines` the older one-row-per-check sentences.
|
|
5
|
+
* @param {{ steps?: any[] }} declaration @param {{ hasAsk?: boolean, askLines?: number[], lines?: any[], csvRoles?: string[] }} [opts] hasAsk = the job has a signed ask line (so "you check it at the ask" is true);
|
|
4
6
|
* askLines = the job lines of the signed asks, which also lets a step after the LAST ask read "you check it after you accept" (am41 item 2, am42: the ONE place for these words)
|
|
5
|
-
* @returns {{ step: number, line: number|null, goal: string, class: string, sentences: string[] }[]}
|
|
7
|
+
* @returns {{ step: number, line: number|null, goal: string, class: string, sentences: string[], sheet?: ReturnType<typeof sheetLineBlocks>[number] }[]}
|
|
6
8
|
*/
|
|
7
9
|
export function checkedLines(declaration: {
|
|
8
10
|
steps?: any[];
|
|
9
|
-
}, { hasAsk, askLines }?: {
|
|
11
|
+
}, { hasAsk, askLines, lines, csvRoles }?: {
|
|
10
12
|
hasAsk?: boolean;
|
|
11
13
|
askLines?: number[];
|
|
14
|
+
lines?: any[];
|
|
15
|
+
csvRoles?: string[];
|
|
12
16
|
}): {
|
|
13
17
|
step: number;
|
|
14
18
|
line: number | null;
|
|
15
19
|
goal: string;
|
|
16
20
|
class: string;
|
|
17
21
|
sentences: string[];
|
|
22
|
+
sheet?: ReturnType<typeof sheetLineBlocks>[number];
|
|
18
23
|
}[];
|
|
19
24
|
/** The "Not checked" block the page shows: always the label, then the drafter's items (an empty list says the drafter listed nothing). @param {unknown} items */
|
|
20
25
|
export function notCheckedBlock(items: unknown): {
|
|
@@ -33,3 +38,4 @@ export function notCheckedView(items: unknown, declaration: any): {
|
|
|
33
38
|
};
|
|
34
39
|
/** The label that always sits with the "Not checked" list (am41 item 3: the ONE place these words live; the Job tab and the Chat card read it off their payloads). */
|
|
35
40
|
export const NOT_CHECKED_LABEL: "not checked (the AI's own reading)";
|
|
41
|
+
import { sheetLineBlocks } from './sheetblock.js';
|
package/types/citedwords.d.ts
CHANGED
|
@@ -76,6 +76,20 @@ export function placeReds({ part, line, look }: {
|
|
|
76
76
|
facts?: any[];
|
|
77
77
|
} | null | undefined;
|
|
78
78
|
}): WordRed[];
|
|
79
|
+
/**
|
|
80
|
+
* A limit the page look read from a guardrail ("under $40" -> price under 40, `reading` on a kept fact, src/pagerules.js) must be carried by a fact of the part,
|
|
81
|
+
* with the same kind, op and bound. A plan that leaves it out would pass a result the guardrail forbids ($48 under "under $40"). Only a reading code accepts
|
|
82
|
+
* (validReading) whose bounds are in the person's own words on the line is demanded; a bound that is not said gets its ask (src/pageask.js), never a refusal.
|
|
83
|
+
* @param {{part: any, line: number, jobLine: any, look: {facts?: any[]}|null|undefined}} o @returns {WordRed[]}
|
|
84
|
+
*/
|
|
85
|
+
export function boundReds({ part, line, jobLine, look, }: {
|
|
86
|
+
part: any;
|
|
87
|
+
line: number;
|
|
88
|
+
jobLine: any;
|
|
89
|
+
look: {
|
|
90
|
+
facts?: any[];
|
|
91
|
+
} | null | undefined;
|
|
92
|
+
}): WordRed[];
|
|
79
93
|
/**
|
|
80
94
|
* Every word red for one cited part, in the order a person fixes them.
|
|
81
95
|
* @param {{part: any, text: string|undefined, line: number, jobLine: any, look: {facts?: any[], dropped?: any[]}|null|undefined, doc?: boolean}} o @returns {WordRed[]}
|
package/types/closers.d.ts
CHANGED
|
@@ -1,26 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* M10 am10: the one description of the cite forms, told to a step whose check cites cells and named in the red when a cite fits none.
|
|
3
|
-
* Built from the checker's own formula list (FORMULAS keys + daysBetween, which is handled apart), so the text cannot drift from what is accepted.
|
|
4
|
-
*/
|
|
5
|
-
export function citeForms(names?: string[]): string;
|
|
1
|
+
/** @typedef {import('./types.js').CloseVerdict} CloseVerdict */
|
|
6
2
|
/** An input with cells (M4d amendment 8): a file whose name ends `.csv`. The one decider for "this input can be cited". */
|
|
7
3
|
export function isCellsPath(p: any): boolean;
|
|
8
|
-
/**
|
|
9
|
-
* `green` close: every field in `artifact.fields`, in declared order,
|
|
10
|
-
* resolves and matches its cite. First red wins.
|
|
11
|
-
*
|
|
12
|
-
* @param {any} artifact
|
|
13
|
-
* @param {{ reads: Record<string, any>, businessDate: string, lock?: {source: string, column: string}[] }} ctx `lock` (M10 am8): the columns the step's check names
|
|
14
|
-
* @returns {CloseVerdict}
|
|
15
|
-
*/
|
|
16
|
-
export function closeGreen(artifact: any, ctx: {
|
|
17
|
-
reads: Record<string, any>;
|
|
18
|
-
businessDate: string;
|
|
19
|
-
lock?: {
|
|
20
|
-
source: string;
|
|
21
|
-
column: string;
|
|
22
|
-
}[];
|
|
23
|
-
}): CloseVerdict;
|
|
24
4
|
/**
|
|
25
5
|
* M10 piece 4 (item 2, "green grows"): the green close of a step that cites quotes instead of cells. `part` is the step's fact part (`close.cited`, set by
|
|
26
6
|
* code from the page look's kept facts, never by the model); `source` is the run's OWN frozen copy of the page or doc (`readRunSource`); the artifact is
|
|
@@ -103,10 +83,11 @@ export function closeSoftgreen(artifact: any, shape: {
|
|
|
103
83
|
/**
|
|
104
84
|
* The one dispatcher — `close by declared class` (M2 scope item 4).
|
|
105
85
|
*
|
|
106
|
-
* @param {{ close?: { class?: string, shape?: Record<string, any>, cited?: any, columns?: {source: string, column: string}[] } }} step
|
|
86
|
+
* @param {{ close?: { class?: string, shape?: Record<string, any>, cited?: any, columns?: {source: string, column: string}[], sheet?: any[] } }} step
|
|
107
87
|
* @param {unknown} artifact
|
|
108
|
-
* @param {{ reads: Record<string, any>, businessDate: string, source?: {ok: true, text: string, sha256: string}|{ok: false, red: string}|null }} ctx
|
|
88
|
+
* @param {{ reads: Record<string, any>, businessDate: string, source?: {ok: true, text: string, sha256: string}|{ok: false, red: string}|null, sheet?: any }} ctx
|
|
109
89
|
* `source` (M10 piece 4) = the run's own frozen copy a cited step reads, from `readRunSource`; only a step whose close carries `cited` reads it
|
|
90
|
+
* `sheet` (M10b piece 2) = the run's own tables and recorded `tableSha`s a step with `close.sheet` is checked on, from `readRunSheets`
|
|
110
91
|
* @returns {Promise<CloseVerdict>}
|
|
111
92
|
*/
|
|
112
93
|
export function closeByClass(step: {
|
|
@@ -118,6 +99,7 @@ export function closeByClass(step: {
|
|
|
118
99
|
source: string;
|
|
119
100
|
column: string;
|
|
120
101
|
}[];
|
|
102
|
+
sheet?: any[];
|
|
121
103
|
};
|
|
122
104
|
}, artifact: unknown, ctx: {
|
|
123
105
|
reads: Record<string, any>;
|
|
@@ -130,14 +112,7 @@ export function closeByClass(step: {
|
|
|
130
112
|
ok: false;
|
|
131
113
|
red: string;
|
|
132
114
|
} | null;
|
|
115
|
+
sheet?: any;
|
|
133
116
|
}): Promise<CloseVerdict>;
|
|
134
|
-
/** @typedef {import('./types.js').CloseVerdict} CloseVerdict */
|
|
135
|
-
export const FORMULAS: Readonly<{
|
|
136
|
-
sum: (vals: any) => any;
|
|
137
|
-
count: (vals: any) => any;
|
|
138
|
-
min: (vals: any) => number;
|
|
139
|
-
max: (vals: any) => number;
|
|
140
|
-
sub: (vals: any) => number;
|
|
141
|
-
}>;
|
|
142
117
|
export type CloseVerdict = import("./types.js").CloseVerdict;
|
|
143
118
|
import { createRubric } from 'bareguard';
|
package/types/csv.d.ts
CHANGED
|
@@ -8,15 +8,36 @@ export function parseCellRef(cell: any): {
|
|
|
8
8
|
row: number;
|
|
9
9
|
};
|
|
10
10
|
/**
|
|
11
|
-
* Parse CSV text
|
|
12
|
-
* `rows[i]` is `{ rowNumber, cells: { A: '...', B: '...' }, byName: { Customer: '...' } }`
|
|
13
|
-
* where `rowNumber` is the
|
|
11
|
+
* Parse CSV text into { header, rows } (RFC 4180 quoting, see `records`).
|
|
12
|
+
* `rows[i]` is `{ rowNumber, cells: { A: '...', B: '...' }, byName: { Customer: '...' }, raw: ['...', '...'] }` (`raw` is the row's cells exactly as the file has them: no padding, nothing cut)
|
|
13
|
+
* where `rowNumber` is the real sheet line the row starts on (header is row 1; a blank line is skipped but still counted, so it never shifts the rows below).
|
|
14
14
|
*/
|
|
15
15
|
export function parseCsv(text: any): {
|
|
16
|
-
header:
|
|
16
|
+
header: string[];
|
|
17
17
|
rows: {
|
|
18
18
|
rowNumber: number;
|
|
19
19
|
cells: {};
|
|
20
20
|
byName: {};
|
|
21
|
+
raw: string[];
|
|
22
|
+
}[];
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* A parsed sheet as bareguard's table shape: `{ header: string[], rows: [{ rowNumber, cells: string[] }] }`. Each row's cells are the row exactly as the file
|
|
26
|
+
* has it (`raw`): a short or a long row is NOT padded or cut here, so bareguard itself stops it (`tableSha` gives null for a ragged row, and the table is
|
|
27
|
+
* refused). The header strings are exactly as the file has them. The one writer of this shape (M10b item 2).
|
|
28
|
+
* @param {{header: string[], rows: {rowNumber: number, raw: string[]}[]}} sheet from `parseCsv`
|
|
29
|
+
* @returns {{header: string[], rows: {rowNumber: number, cells: string[]}[]}}
|
|
30
|
+
*/
|
|
31
|
+
export function sheetTable(sheet: {
|
|
32
|
+
header: string[];
|
|
33
|
+
rows: {
|
|
34
|
+
rowNumber: number;
|
|
35
|
+
raw: string[];
|
|
36
|
+
}[];
|
|
37
|
+
}): {
|
|
38
|
+
header: string[];
|
|
39
|
+
rows: {
|
|
40
|
+
rowNumber: number;
|
|
41
|
+
cells: string[];
|
|
21
42
|
}[];
|
|
22
43
|
};
|
package/types/declaration.d.ts
CHANGED
|
@@ -55,7 +55,8 @@ export function checkShapeFitsJobLine(step: any, i: any, lines: any, reds: any):
|
|
|
55
55
|
* `pageWords.docs` (M10 piece 5): the roles that are documents (.docx / .md / .txt): their words are proved on their text alone, with no page-word map.
|
|
56
56
|
* `sheetWords` (optional; M10 am8 item 2): `{headers: {role: header names}, facts: the columns the sheet look kept}`. With `fitJobLine`, every column a step's `close.columns` names
|
|
57
57
|
* is proved a real column of its sheet, and a column the code kept for the step's line (an agreed one included) must be in it.
|
|
58
|
-
*
|
|
58
|
+
* `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.
|
|
59
|
+
* @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]
|
|
59
60
|
* @returns {ValidateDeclarationResult}
|
|
60
61
|
*/
|
|
61
62
|
export function validateDeclaration(declaration: unknown, context?: {
|
|
@@ -73,6 +74,10 @@ export function validateDeclaration(declaration: unknown, context?: {
|
|
|
73
74
|
sheetWords?: {
|
|
74
75
|
headers: Record<string, string[]>;
|
|
75
76
|
facts: any[];
|
|
77
|
+
tables?: Record<string, {
|
|
78
|
+
header: string[];
|
|
79
|
+
rows: any[];
|
|
80
|
+
}>;
|
|
76
81
|
};
|
|
77
82
|
}): ValidateDeclarationResult;
|
|
78
83
|
/** @typedef {import('./types.js').Arbiter} Arbiter */
|
package/types/drafter.d.ts
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
1
|
+
/**
|
|
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
|
+
* `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
|
+
* @param {any[]} menu @param {{sheets?: Record<string, {header: string[]}>}} [o]
|
|
5
|
+
*/
|
|
6
|
+
export function buildDeclarationSchema(menu: any[], { sheets }?: {
|
|
7
|
+
sheets?: Record<string, {
|
|
8
|
+
header: string[];
|
|
9
|
+
}>;
|
|
10
|
+
}): {
|
|
3
11
|
type: string;
|
|
4
12
|
properties: {
|
|
5
13
|
steps: {
|
|
@@ -12,7 +20,7 @@ export function buildDeclarationSchema(menu: any): {
|
|
|
12
20
|
type: string;
|
|
13
21
|
items: {
|
|
14
22
|
type: string;
|
|
15
|
-
enum: any;
|
|
23
|
+
enum: any[];
|
|
16
24
|
};
|
|
17
25
|
description: string;
|
|
18
26
|
};
|
|
@@ -45,6 +53,7 @@ export function buildDeclarationSchema(menu: any): {
|
|
|
45
53
|
close: {
|
|
46
54
|
type: string;
|
|
47
55
|
properties: {
|
|
56
|
+
sheet?: Record<string, any> | undefined;
|
|
48
57
|
class: {
|
|
49
58
|
type: string;
|
|
50
59
|
enum: string[];
|
|
@@ -149,7 +158,7 @@ export function buildDeclarationSchema(menu: any): {
|
|
|
149
158
|
type: "array";
|
|
150
159
|
minItems: 1;
|
|
151
160
|
maxItems: 10;
|
|
152
|
-
description: "only on a green step that
|
|
161
|
+
description: "only on a green step that reads a CSV input: the exact column names (the sheet's header) its values come from. Omit on any other step";
|
|
153
162
|
items: {
|
|
154
163
|
type: string;
|
|
155
164
|
properties: {
|
|
@@ -213,8 +222,12 @@ export function buildDeclarationSchema(menu: any): {
|
|
|
213
222
|
additionalProperties: boolean;
|
|
214
223
|
};
|
|
215
224
|
/** The declaration schema plus the optional `notChecked` (every try) and, on try 3 only, `questions`. Neither is in `required`. */
|
|
216
|
-
|
|
217
|
-
|
|
225
|
+
/** @param {any[]} menu @param {{questions?: boolean, sheets?: Record<string, {header: string[]}>|undefined}} [o] */
|
|
226
|
+
export function buildRoundSchema(menu: any[], { questions, sheets }?: {
|
|
227
|
+
questions?: boolean;
|
|
228
|
+
sheets?: Record<string, {
|
|
229
|
+
header: string[];
|
|
230
|
+
}> | undefined;
|
|
218
231
|
}): {
|
|
219
232
|
properties: {
|
|
220
233
|
notChecked: {
|
|
@@ -234,7 +247,7 @@ export function buildRoundSchema(menu: any, { questions }?: {
|
|
|
234
247
|
type: string;
|
|
235
248
|
items: {
|
|
236
249
|
type: string;
|
|
237
|
-
enum: any;
|
|
250
|
+
enum: any[];
|
|
238
251
|
};
|
|
239
252
|
description: string;
|
|
240
253
|
};
|
|
@@ -267,6 +280,7 @@ export function buildRoundSchema(menu: any, { questions }?: {
|
|
|
267
280
|
close: {
|
|
268
281
|
type: string;
|
|
269
282
|
properties: {
|
|
283
|
+
sheet?: Record<string, any> | undefined;
|
|
270
284
|
class: {
|
|
271
285
|
type: string;
|
|
272
286
|
enum: string[];
|
|
@@ -371,7 +385,7 @@ export function buildRoundSchema(menu: any, { questions }?: {
|
|
|
371
385
|
type: "array";
|
|
372
386
|
minItems: 1;
|
|
373
387
|
maxItems: 10;
|
|
374
|
-
description: "only on a green step that
|
|
388
|
+
description: "only on a green step that reads a CSV input: the exact column names (the sheet's header) its values come from. Omit on any other step";
|
|
375
389
|
items: {
|
|
376
390
|
type: string;
|
|
377
391
|
properties: {
|
|
@@ -475,9 +489,10 @@ export function goalForLine(fromLine: any, lines: any): any;
|
|
|
475
489
|
* costUsd:number|null, modelReturned:string|null, modelId?:string, price?:object|null, tokens?:object|null, structureRetries:number, revisions:number, stop:string|null, log:object[],
|
|
476
490
|
* questions?:{line:number, question:string}[], droppedQuestions?:object[], notChecked?:string[], thinking?:{asked:string, status:string|null, say:string|null}, inputs?:{role:string, detail:string}[],
|
|
477
491
|
* look?:{facts:any[], dropped:any[]}, pageLooks?:{role:string, address:string, sha256:string, bytes:number, frozen:string, attempts:number, mapping:any}[], sheetLooks?:any[]}>}
|
|
492
|
+
* `learnHints` (M8 item 5a): the earlier runs' notes block (src/learnstore.js hintsForRun), appended to the drafter's system prompt; null = nothing.
|
|
478
493
|
* `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`.
|
|
479
494
|
*/
|
|
480
|
-
export function draft({ proseText, slot, model, provider: injected, rates: injectedRates, modelId: injectedModelId, env, priorSpend, skills, makeProviderFn, onBook, offerQuestions, draftThinking, draftDir, fetchPage, leftRules, }: {
|
|
495
|
+
export function draft({ proseText, slot, model, provider: injected, rates: injectedRates, modelId: injectedModelId, env, priorSpend, skills, makeProviderFn, onBook, offerQuestions, draftThinking, draftDir, fetchPage, leftRules, learnHints, }: {
|
|
481
496
|
proseText: any;
|
|
482
497
|
slot: any;
|
|
483
498
|
model: any;
|
|
@@ -497,6 +512,10 @@ export function draft({ proseText, slot, model, provider: injected, rates: injec
|
|
|
497
512
|
line: number;
|
|
498
513
|
rule: number;
|
|
499
514
|
}[] | undefined;
|
|
515
|
+
learnHints?: {
|
|
516
|
+
text: string;
|
|
517
|
+
ids: string[];
|
|
518
|
+
} | null | undefined;
|
|
500
519
|
}): Promise<{
|
|
501
520
|
ok: boolean;
|
|
502
521
|
declaration: object | null;
|
package/types/flowmodel.d.ts
CHANGED
|
@@ -46,8 +46,44 @@ export function writeRunModel(runDir: string, { slot, model }: {
|
|
|
46
46
|
slot: string;
|
|
47
47
|
model: string;
|
|
48
48
|
}): void;
|
|
49
|
+
/** @param {string} dir @param {{text: string, ids: string[]}} hints */
|
|
50
|
+
export function writeLearningsRecord(dir: string, { text, ids }: {
|
|
51
|
+
text: string;
|
|
52
|
+
ids: string[];
|
|
53
|
+
}): void;
|
|
54
|
+
/**
|
|
55
|
+
* The drafter's failed ask for the block (or failed record write) rides the same record: nothing handed (`text: ''`, no ids), and `error` (first line, secrets redacted).
|
|
56
|
+
* `readLearningsRecord` reads an empty text as no record, so the Audit box stays hidden and `copyLearningsRecord` copies nothing.
|
|
57
|
+
* @param {string} dir @param {string} error
|
|
58
|
+
*/
|
|
59
|
+
export function writeLearningsError(dir: string, error: string): void;
|
|
60
|
+
/**
|
|
61
|
+
* M8 item 6: the Audit box reads the record in the RUN's folder. It reaches the run the way `model.json` does: a draft's record is copied (write-once) into the folder it is signed
|
|
62
|
+
* into (`copyLearningsRecord`: the flow folder at a new job's sign, the new run's folder at a red run's redraft), and the first run that starts from a flow folder TAKES it
|
|
63
|
+
* (`takeLearningsRecord`: a rename, so it moves once and a second run of the same job never shows it). A run that reused its plan has no draft, so it has none.
|
|
64
|
+
* @param {string} fromDir a draft folder @param {string} toDir a flow folder or a run folder @returns {boolean} true when a record was copied
|
|
65
|
+
*/
|
|
66
|
+
export function copyLearningsRecord(fromDir: string, toDir: string): boolean;
|
|
67
|
+
/** @param {string} flowDir @param {string} runDir @returns {boolean} true when the flow's record moved into the run (it is no longer in the flow folder) */
|
|
68
|
+
export function takeLearningsRecord(flowDir: string, runDir: string): boolean;
|
|
69
|
+
/**
|
|
70
|
+
* The ONE reader of a run's record. null = no record, or one that is not `{phase, text, ids, chars}` (the box is then hidden, never guessed).
|
|
71
|
+
* @param {string} runDir @returns {{phase: string, text: string, ids: string[], chars: number}|null}
|
|
72
|
+
*/
|
|
73
|
+
export function readLearningsRecord(runDir: string): {
|
|
74
|
+
phase: string;
|
|
75
|
+
text: string;
|
|
76
|
+
ids: string[];
|
|
77
|
+
chars: number;
|
|
78
|
+
} | null;
|
|
49
79
|
export const MODEL_FILE: "model.json";
|
|
50
80
|
/** M4d am25: the file in a run's folder that keeps the box as the run started with it (outside `job/`, which holds the three signed files only). */
|
|
51
81
|
export const RUN_THINKING_FILE: "thinking.json";
|
|
52
82
|
/** M4d am33: the file in a run's folder that records the model the run STARTED on (write-once; every continue path keeps it). */
|
|
53
83
|
export const RUN_MODEL_FILE: "run-model.json";
|
|
84
|
+
/**
|
|
85
|
+
* M8 item 5a: the file that keeps EXACTLY what the drafter was handed from earlier runs (the Audit box of item 6 reads it). Bareloop's
|
|
86
|
+
* `learnings` spine record shape, `{phase, text, ids, chars}`. Write-once (never over an existing record); written with something handed, or by `writeLearningsError` with an empty `text`
|
|
87
|
+
* (a failed ask: nothing handed, why in `error`); a reader treats empty text as no record, so no file or empty text = nothing handed = no box. Borrowed-from: bareloop src/planrun.js@v0.46.0:3092 (emit('learnings', ...)).
|
|
88
|
+
*/
|
|
89
|
+
export const LEARNINGS_FILE: "learnings.json";
|