fwdloop 0.22.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/package.json +2 -2
- package/src/ask.js +20 -4
- package/src/authoring.js +4 -0
- package/src/canrun.js +5 -0
- package/src/checked.js +14 -3
- package/src/citedcheck.js +16 -1
- package/src/closers.js +13 -223
- package/src/csv.js +69 -12
- package/src/declaration.js +64 -6
- package/src/drafter.js +37 -15
- package/src/model-step.js +13 -21
- package/src/panel/author.js +2 -1
- package/src/panel/authorcard.js +9 -2
- package/src/panel/data.js +20 -5
- package/src/panel/index.html +43 -1
- package/src/panel/result.js +6 -0
- package/src/runner.js +24 -7
- 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/try-checks.js +6 -0
- package/src/types.js +1 -9
- package/types/ask.d.ts +2 -1
- package/types/checked.d.ts +9 -3
- 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 +22 -8
- package/types/model-step.d.ts +19 -30
- package/types/panel/authorcard.d.ts +2 -1
- package/types/runner.d.ts +8 -4
- 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/types.d.ts +16 -11
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
// M10b piece 3 (docs/wiki/the-module-ladder.md "M10b scope" item 4): what the drafter is OFFERED for a sheet. Things, each once:
|
|
2
|
+
// - `sheetChecksProp` the tool schema of `close.sheet`, GENERATED from bareguard's `rubricVocabulary` (fields, ops, date formats), never hand-copied. Every field that
|
|
3
|
+
// names a column is a JSON-schema `enum` of the sheet's exact header strings, so the model can only pick one (code still re-checks, piece 1);
|
|
4
|
+
// - `sheetOpsBrief` the plain list of every op with its summary, what it requires and allows, and bareguard's worked example check, generated the same way;
|
|
5
|
+
// - `isColumnChoiceRule` the agreed-column rule, covered by the column lock.
|
|
6
|
+
// `covers` (which `~` rules of a job line a check verifies, the drafter's typed field) is KEPT on the check and signed (M10b am2: you see it before you sign); it is
|
|
7
|
+
// stripped only on the way into bareguard (src/sheetchecks.js `bareguardChecks`) and read by src/sheetblock.js. A field type the vocabulary gains that this file does not know
|
|
8
|
+
// THROWS at build time (a bareguard upgrade fails loud, it never silently drops a field).
|
|
9
|
+
// Third outcomes, named: a sheet with no header (no enum can be built: no sheet schema is offered).
|
|
10
|
+
import { rubricVocabulary } from 'bareguard';
|
|
11
|
+
import {
|
|
12
|
+
SHEET_RULES, MAX_SHEET_CHECKS, COLUMN_STRING_FIELDS, COLUMN_OPERAND_FIELDS, COLUMN_CELL_FIELDS, COLUMN_LIST_FIELDS,
|
|
13
|
+
} from './sheetchecks.js';
|
|
14
|
+
import { columnRuleWords } from './sheetlook.js';
|
|
15
|
+
|
|
16
|
+
const V = /** @type {any} */ (rubricVocabulary);
|
|
17
|
+
const isRec = (/** @type {unknown} */ v) => v !== null && typeof v === 'object' && !Array.isArray(v);
|
|
18
|
+
|
|
19
|
+
/** The comparisons of a `where` condition. bareguard publishes them only inside the `where` description (no list), so this is the one copy; a test proves each is named there. */
|
|
20
|
+
export const WHERE_CMPS = Object.freeze(['gt', 'gte', 'lt', 'lte', 'eq', 'between', 'before', 'after', 'dateBetween', 'dateOn', 'equals', 'empty', 'notEmpty']);
|
|
21
|
+
|
|
22
|
+
/** @param {Record<string, {header: string[]}>} tables @returns {string[]} the exact header strings of every sheet, once each, in order */
|
|
23
|
+
const headerUnion = (tables) => [...new Set(Object.values(tables).flatMap((t) => t.header))];
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The JSON schema of one vocabulary field. `col` = the schema every column name uses (an enum of the header).
|
|
27
|
+
* @param {string} key @param {any} f @param {Record<string, any>} col @param {string[]} roles @returns {Record<string, any>|null} null = not offered
|
|
28
|
+
*/
|
|
29
|
+
function fieldSchema(key, f, col, roles) {
|
|
30
|
+
const d = f.description ? { description: f.description } : {};
|
|
31
|
+
if (key === 'table') return { type: 'string', enum: roles, description: 'the role of the CSV input this check reads (also in the step\'s reads)' };
|
|
32
|
+
if (key === 'claim') return { type: 'string', minLength: 1, maxLength: 128, description: 'a cells check only: a short name for the field that holds the step\'s answer to this check; the step is told the shape of the answer, never the check', };
|
|
33
|
+
if (COLUMN_STRING_FIELDS.includes(key)) return { ...col, ...d };
|
|
34
|
+
if (COLUMN_OPERAND_FIELDS.includes(key)) return { anyOf: [col, { type: 'object', properties: { const: { type: 'number' } }, required: ['const'], additionalProperties: false }], ...d };
|
|
35
|
+
switch (f.type) {
|
|
36
|
+
case 'name': case 'string': return { type: 'string', ...d };
|
|
37
|
+
case 'explanation': return null; // free text: never offered (a check carries no prose)
|
|
38
|
+
case 'date': return { type: 'string', ...d };
|
|
39
|
+
case 'integer': return { type: 'integer', ...d };
|
|
40
|
+
case 'number': return { type: 'number', ...d };
|
|
41
|
+
case 'boolean': return { type: 'boolean', ...d };
|
|
42
|
+
case 'enum': return { type: 'string', enum: f.enum, ...d };
|
|
43
|
+
case 'range': return { type: 'object', properties: { from: { type: 'integer' }, to: { type: 'integer' } }, required: ['from', 'to'], additionalProperties: false, ...d };
|
|
44
|
+
case 'cell': return { type: 'object', properties: { column: col, row: { type: 'integer' } }, required: ['column', 'row'], additionalProperties: false, ...d };
|
|
45
|
+
case 'condition-list': return { type: 'array', items: { type: 'object', properties: { column: col, cmp: { type: 'string', enum: [...WHERE_CMPS] }, value: {}, lo: {}, hi: {} }, required: ['column', 'cmp'], additionalProperties: false }, ...d };
|
|
46
|
+
case 'date-format-list': return { type: 'array', items: { type: 'object', properties: { column: col, format: { type: 'string', enum: V.cells.dateFormats } }, required: ['column', 'format'], additionalProperties: false }, ...d };
|
|
47
|
+
case 'band-list': return { type: 'array', items: { type: 'object', properties: { name: { type: 'string' }, gt: { type: 'number' }, gte: { type: 'number' }, lt: { type: 'number' }, lte: { type: 'number' } }, required: ['name'], additionalProperties: false }, ...d };
|
|
48
|
+
default: throw new Error(`sheetoffer: bareguard's rubricVocabulary has a field type "${f.type}" (${key}) this file does not know - add it before offering sheet checks`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* The tool schema of `close.sheet`: a list of bareguard cells / table checks. Every field is a field of bareguard's vocabulary; every column-bearing field
|
|
54
|
+
* (`column keyColumn groupColumn result a b from to cell where[].column dateFormats[].column`) is an enum of the sheet's exact header. `covers` is fwdloop's own field
|
|
55
|
+
* (which `~` rules of the job line the check covers), kept and signed.
|
|
56
|
+
* @param {Record<string, {header: string[]}>} tables the drafting copy's table of each CSV input role
|
|
57
|
+
* @returns {Record<string, any>|null} null when there is no sheet with a header to pick from
|
|
58
|
+
*/
|
|
59
|
+
export function sheetChecksProp(tables) {
|
|
60
|
+
const roles = Object.keys(tables);
|
|
61
|
+
const headers = headerUnion(tables);
|
|
62
|
+
if (roles.length === 0 || headers.length === 0) return null;
|
|
63
|
+
const col = { type: 'string', enum: headers };
|
|
64
|
+
/** @type {Record<string, any>} */
|
|
65
|
+
const props = {
|
|
66
|
+
id: { type: 'string', minLength: 1, description: 'a short unique name for this check' },
|
|
67
|
+
rule: { type: 'string', enum: [...SHEET_RULES], description: 'cells: the step gives a value that bareguard recomputes; table: bareguard judges the sheet itself' },
|
|
68
|
+
};
|
|
69
|
+
for (const r of SHEET_RULES) {
|
|
70
|
+
for (const [k, f] of Object.entries(V.rules[r].fields)) {
|
|
71
|
+
if (k === 'op' || props[k] !== undefined) continue;
|
|
72
|
+
const s = fieldSchema(k, f, col, roles);
|
|
73
|
+
if (s !== null) props[k] = s;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
props.op = { type: 'string', enum: [...new Set(SHEET_RULES.flatMap((r) => Object.keys(V.rules[r].ops)))], description: 'a cells op goes with rule "cells", a table op with rule "table" (listed in the system prompt)' };
|
|
77
|
+
props.covers = { type: 'array', items: { type: 'integer', minimum: 1 }, description: 'the numbers of the line\'s ~ guardrail rules this check verifies (1 is its first rule); [] when it verifies none of them' };
|
|
78
|
+
return {
|
|
79
|
+
type: 'array',
|
|
80
|
+
minItems: 1,
|
|
81
|
+
maxItems: MAX_SHEET_CHECKS,
|
|
82
|
+
description: 'only on a green step that reads a CSV input: the checks bareguard runs on the step\'s answer. Omit on any other step',
|
|
83
|
+
items: { type: 'object', properties: props, required: ['id', 'rule', 'table', 'op', 'covers'], additionalProperties: false },
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Every op of the cells and table rules with its summary, what it requires and allows, its claim shape and bareguard's worked example check. Generated from the
|
|
89
|
+
* vocabulary; a new op bareguard adds shows up here by itself.
|
|
90
|
+
* @returns {string[]} lines for the system prompt
|
|
91
|
+
*/
|
|
92
|
+
export function sheetOpsBrief() {
|
|
93
|
+
const out = [];
|
|
94
|
+
for (const rule of SHEET_RULES) {
|
|
95
|
+
out.push(`Rule "${rule}" ops (each line: op, what it does, requires / allows, then bareguard's worked example check; the column names in the examples are only illustrations):`);
|
|
96
|
+
for (const [op, o] of Object.entries(V.rules[rule].ops)) {
|
|
97
|
+
out.push(`- ${op}: ${o.summary}. requires: ${(o.requires ?? []).join(', ') || 'nothing'}; allows: ${(o.allows ?? []).join(', ') || 'nothing'}${o.claim ? `; the step's answer: ${o.claim}` : ''}. Example: ${JSON.stringify(o.example.check)}`);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
out.push(`- The example table those checks run against: ${JSON.stringify(V.cells.exampleTables.t)}`);
|
|
101
|
+
out.push(`- A date column needs a dateFormats entry, its format one of ${V.cells.dateFormats.join(' | ')}. Where conditions: ${V.rules.cells.fields.where.description}`);
|
|
102
|
+
return out;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* The rules the validator enforces on `close.sheet`, as lines for the drafter (every one of them is a refusal at $0 in src/declaration.js / src/sheetchecks.js).
|
|
107
|
+
* @param {string[]} roles the CSV input roles @returns {string[]}
|
|
108
|
+
*/
|
|
109
|
+
export function sheetOfferRules(roles) {
|
|
110
|
+
return [
|
|
111
|
+
`- A green step whose line has a guardrail about values in a CSV input (${roles.join(', ')}) lists that input's role in its reads and carries close.sheet = a list of 1 to ${MAX_SHEET_CHECKS} checks, each a bareguard check object from the ops below, with "table" = the CSV input's role. Write the checks the line's guardrail needs and nothing else; the person signs them. close.sheet is for a green step only.`,
|
|
112
|
+
'- A column name in a check is picked from the sheet\'s header, spelled exactly; the tool only lets you pick a header name. A check that bareguard refuses (a wrong field for the op, overlapping bands, a missing dateFormats entry) is refused at $0 naming the job line.',
|
|
113
|
+
'- A number in a where condition (gt, gte, lt, lte, eq, between) must be a number the person wrote on that job line or its guardrail; a date (asOf, and the values of before, after, dateOn, dateBetween) must be a date they wrote there as YYYY-MM-DD. Never make a number or a date up: if the person gave none, leave that condition out.',
|
|
114
|
+
'- A "cells" check names "claim", a short name for the answer the step gives; the step is told only the shape of the answer, never the check. A "table" check has no claim and judges the sheet itself. If every check of a step is a table check the step has nothing to answer and the line is refused: pair a table check with at least one cells check.',
|
|
115
|
+
'- "covers" on each check lists the numbers of the line\'s guardrail rules (the ~ parts, counted from 1 in the order shown) that this check really verifies; [] if none. A guardrail rule that no check covers is shown to the person as Not checked, so cover every rule you can with a real check, and never claim a rule a check does not verify. A rule shaped like "use the column \'X\' for \'Y\'" is a column choice, not a rule to cover.',
|
|
116
|
+
...sheetOpsBrief(),
|
|
117
|
+
];
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/** @param {unknown} rule @returns {boolean} true for the `use the column 'X' for 'Y'` rule an agreed column ask writes ({@link columnRuleWords}) */
|
|
121
|
+
export function isColumnChoiceRule(rule) {
|
|
122
|
+
const r = String(rule);
|
|
123
|
+
const head = columnRuleWords('', '').split("''")[0]; // "use the column '"
|
|
124
|
+
return r.startsWith(head) && r.endsWith("'") && r.includes("' for '");
|
|
125
|
+
}
|
package/src/sheetrun.js
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
// M10b piece 2 (docs/wiki/the-module-ladder.md "M10b scope" items 5-6 and amendment 1): a sheet check at RUN time.
|
|
2
|
+
// - the lock: at run start each CSV input a step's `close.sheet` names gets its `tableSha` (bareguard's fingerprint of the table made from the run's frozen copy)
|
|
3
|
+
// written down once with that run's inputs (`freezeInputs` is the one writer of inputs.json and calls `tableShaOfFile`); here is how it is read back;
|
|
4
|
+
// - the judge: `closeSheet` hands the signed checks, the step's typed answer and the run's table to bareguard's `checkStep`. No model grades.
|
|
5
|
+
// Third outcomes, each named, never green: a sheet the run recorded no fingerprint for, a frozen copy that is missing, a table that no longer gives the recorded
|
|
6
|
+
// `tableSha` (bareguard stops the check; the red names the input), any other stopped check.
|
|
7
|
+
// Throws away: bareguard's `full` (expected values, evidence) is not kept - the red keeps the gaps, which name rows and counts and never a cell's text.
|
|
8
|
+
import { basename } from 'node:path';
|
|
9
|
+
import { createRubric, checkStep, renderGaps, tableSha } from 'bareguard';
|
|
10
|
+
import { parseCsv, sheetTable } from './csv.js';
|
|
11
|
+
import { readFileInside } from './flow.js';
|
|
12
|
+
import { sheetCheckSentence, bareguardChecks } from './sheetchecks.js';
|
|
13
|
+
import { sheetCheckName, sheetFoundWords } from './sheetblock.js';
|
|
14
|
+
|
|
15
|
+
const isRec = (/** @type {unknown} */ v) => v !== null && typeof v === 'object' && !Array.isArray(v);
|
|
16
|
+
|
|
17
|
+
/** The sheet inputs any step's `close.sheet` reads, once each, in order. @param {any[]} steps @returns {string[]} */
|
|
18
|
+
export function sheetRolesOf(steps) {
|
|
19
|
+
const roles = [];
|
|
20
|
+
for (const s of Array.isArray(steps) ? steps : []) {
|
|
21
|
+
const list = s?.close?.class === 'green' && Array.isArray(s.close.sheet) ? s.close.sheet : [];
|
|
22
|
+
for (const c of list) if (isRec(c) && typeof c.table === 'string' && !roles.includes(c.table)) roles.push(c.table);
|
|
23
|
+
}
|
|
24
|
+
return roles;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* bareguard's `tableSha` of the run's frozen CSV `<runDir>/inputs/<name>` (its table from src/csv.js `sheetTable`), read through the one safe gateway; null when the copy
|
|
29
|
+
* cannot be read or bareguard cannot read it as a table (a ragged row, a repeated header).
|
|
30
|
+
* @param {string} runDir @param {string} name the frozen file's name @returns {string|null}
|
|
31
|
+
*/
|
|
32
|
+
export function tableShaOfFrozen(runDir, name) {
|
|
33
|
+
const file = readFileInside(runDir, `inputs/${name}`);
|
|
34
|
+
return file.ok ? tableSha(sheetTable(parseCsv(file.text))) : null;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const SHA_RE = /^[0-9a-f]{64}$/;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* What a sheet check reads in a run: the run's OWN frozen copy of each sheet its checks name, as bareguard's table, and the `tableSha` recorded in `inputs.json` at
|
|
41
|
+
* the run's start. The table is NOT compared here: bareguard compares it to the recorded sha when it checks (and stops if it differs).
|
|
42
|
+
* @param {string} runDir @param {any[]} checks the step's `close.sheet`
|
|
43
|
+
* @returns {{ok: true, tables: Record<string, {header: string[], rows: any[]}>, inputs: Array<{name: string, sha256: string}>}|{ok: false, red: string}}
|
|
44
|
+
*/
|
|
45
|
+
export function readRunSheets(runDir, checks) {
|
|
46
|
+
const manifest = readFileInside(runDir, 'inputs.json');
|
|
47
|
+
if (!manifest.ok) return { ok: false, red: manifest.missing ? 'this run has no frozen inputs' : `inputs.json: ${manifest.red}` };
|
|
48
|
+
let entries;
|
|
49
|
+
try { entries = JSON.parse(manifest.text); } catch (err) { return { ok: false, red: `inputs.json is not valid JSON - ${/** @type {any} */ (err).message}` }; }
|
|
50
|
+
/** @type {Record<string, any>} */
|
|
51
|
+
const tables = {};
|
|
52
|
+
const inputs = [];
|
|
53
|
+
for (const c of checks) {
|
|
54
|
+
const role = isRec(c) ? c.table : undefined;
|
|
55
|
+
if (typeof role !== 'string' || role in tables) continue;
|
|
56
|
+
const entry = Array.isArray(entries) ? entries.find((e) => e?.id === role) : undefined;
|
|
57
|
+
if (!entry || typeof entry.frozen !== 'string') return { ok: false, red: `input "${role}": this run froze no input with that name` };
|
|
58
|
+
if (typeof entry.tableSha !== 'string' || !SHA_RE.test(entry.tableSha)) return { ok: false, red: `input "${role}": this run recorded no table fingerprint for it at its start` };
|
|
59
|
+
const file = readFileInside(runDir, `inputs/${basename(entry.frozen)}`);
|
|
60
|
+
if (!file.ok) return { ok: false, red: file.missing ? `input "${role}": the frozen copy is missing` : `input "${role}": ${file.red}` };
|
|
61
|
+
tables[role] = sheetTable(parseCsv(file.text));
|
|
62
|
+
inputs.push({ name: role, sha256: entry.tableSha });
|
|
63
|
+
}
|
|
64
|
+
return { ok: true, tables, inputs };
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* The close of a green step that reads a sheet. `sheet` = `readRunSheets`' answer. `artifact` is the step's typed answer (its claim boxes). Gaps come from bareguard
|
|
69
|
+
* (`renderGaps`: row numbers and counts, a data problem first); each signed check is also listed with its own pass or fail for the Checked list.
|
|
70
|
+
* @param {any[]} checks the step's `close.sheet` @param {unknown} artifact @param {ReturnType<typeof readRunSheets>|null|undefined} sheet
|
|
71
|
+
* @returns {Promise<import('./types.js').CloseVerdict>}
|
|
72
|
+
*/
|
|
73
|
+
export async function closeSheet(checks, artifact, sheet) {
|
|
74
|
+
try {
|
|
75
|
+
if (!sheet || sheet.ok !== true) {
|
|
76
|
+
const red = sheet && sheet.ok === false ? sheet.red : 'the run gave the check no saved sheet to read';
|
|
77
|
+
return /** @type {any} */ ({ verdict: 'unparseable', red: `sheet close: ${red}` });
|
|
78
|
+
}
|
|
79
|
+
if (!isRec(artifact)) return /** @type {any} */ ({ verdict: 'unparseable', red: 'a sheet step must answer with an object, one field per check named in its job' });
|
|
80
|
+
const rubric = createRubric({ schema: 1, goal: 'sheet', inputs: sheet.inputs, checkpoints: { sheet: { gating: true, checks: bareguardChecks(checks) } }, maxReds: 3 });
|
|
81
|
+
const res = await checkStep(rubric, 'sheet', artifact, { tables: sheet.tables });
|
|
82
|
+
if (res.verdict === 'stopped') {
|
|
83
|
+
const moved = sheet.inputs.filter((i) => tableSha(sheet.tables[i.name]) !== i.sha256).map((i) => i.name);
|
|
84
|
+
if (moved.length > 0) {
|
|
85
|
+
return /** @type {any} */ ({ verdict: 'crash', red: `sheet close stopped: input ${moved.map((n) => `"${n}"`).join(', ')} - the saved sheet no longer gives the table this run recorded at its start` });
|
|
86
|
+
}
|
|
87
|
+
const fault = res.fault;
|
|
88
|
+
return /** @type {any} */ ({ verdict: 'crash', red: `sheet close stopped: the ${fault?.id ?? 'sheet'} check stopped (${fault?.kind ?? 'no detail'}${fault?.detail ? `: ${fault.detail}` : ''})` });
|
|
89
|
+
}
|
|
90
|
+
const gaps = res.verdict === 'red' ? res.gaps : [];
|
|
91
|
+
const rows = checks.map((c) => {
|
|
92
|
+
const mine = gaps.filter((g) => g.id === c.id);
|
|
93
|
+
// M10b piece 4: the Audit / Checked row is `<short name> — <plain words>`, with what the step claimed (green) or bareguard's gap words (red) as its result
|
|
94
|
+
return { id: c.id, text: `${sheetCheckName(c)} \u2014 ${sheetCheckSentence(c)}`, ok: mine.length === 0, result: mine.length === 0 ? sheetFoundWords(c, artifact) : renderGaps(mine) };
|
|
95
|
+
});
|
|
96
|
+
const sheetRecord = { inputs: sheet.inputs, claims: artifact, checks: rows.map((r) => ({ id: r.id, text: r.text, ok: r.ok, result: r.ok ? null : r.result })) };
|
|
97
|
+
if (res.verdict === 'red') {
|
|
98
|
+
const red = renderGaps(gaps) || 'a sheet check failed';
|
|
99
|
+
return /** @type {any} */ ({ verdict: 'red', red, reds: [red], checks: rows, sheetRecord });
|
|
100
|
+
}
|
|
101
|
+
return /** @type {any} */ ({ verdict: 'green', red: null, reds: [], checks: rows, sheetRecord });
|
|
102
|
+
} catch (err) {
|
|
103
|
+
return /** @type {any} */ ({ verdict: 'crash', red: `sheet close crashed: ${/** @type {any} */ (err).message}` });
|
|
104
|
+
}
|
|
105
|
+
}
|
package/src/try-checks.js
CHANGED
|
@@ -50,6 +50,12 @@ export function closeRecords(step, artifact, closed) {
|
|
|
50
50
|
n: 3, text: 'the close could run', ok: false, result: closed.verdict, source,
|
|
51
51
|
}];
|
|
52
52
|
}
|
|
53
|
+
if (step?.close?.class === 'green' && Array.isArray(step?.close?.sheet) && Array.isArray(closed.checks)) {
|
|
54
|
+
// M10b piece 2: each signed sheet check is its own row, worded by `sheetCheckSentence`, judged by bareguard
|
|
55
|
+
return closed.checks.map((c, i) => ({
|
|
56
|
+
n: 3 + i, text: c.text, ok: c.ok, result: c.result, source,
|
|
57
|
+
}));
|
|
58
|
+
}
|
|
53
59
|
if (step?.close?.class === 'green' && step?.close?.cited) {
|
|
54
60
|
const n = Array.isArray(artifact?.results) ? artifact.results.length : 0;
|
|
55
61
|
return [{
|
package/src/types.js
CHANGED
|
@@ -244,15 +244,6 @@
|
|
|
244
244
|
* @property {string|null} gap
|
|
245
245
|
*/
|
|
246
246
|
|
|
247
|
-
/**
|
|
248
|
-
* A green-class field value: `value` is the number/ISO-date/text claimed;
|
|
249
|
-
* `cite` resolves it (src/closers.js's own grammar).
|
|
250
|
-
* @typedef {object} GreenField
|
|
251
|
-
* @property {string|number} value
|
|
252
|
-
* @property {string} cite
|
|
253
|
-
*/
|
|
254
|
-
|
|
255
|
-
/** @typedef {{ fields: Record<string, GreenField> }} GreenArtifact */
|
|
256
247
|
/** @typedef {{ text: string, lines?: string[] }} SoftgreenArtifact */
|
|
257
248
|
|
|
258
249
|
/**
|
|
@@ -263,6 +254,7 @@
|
|
|
263
254
|
* @property {string[]} [reds]
|
|
264
255
|
* @property {Array<{id:string, text:string, ok:boolean, result:string|null}>} [checks] a softgreen close: every check it ran (M4d am29 item 2)
|
|
265
256
|
* @property {{part: any, check: any, results?: unknown}} [cited] a cited green close (M10 piece 4): the fact part and the check's own answer, for the run's cited-check record
|
|
257
|
+
* @property {{inputs: Array<{name:string, sha256:string}>, claims: unknown, checks: Array<{id:string, text:string, ok:boolean, result:string|null}>}} [sheetRecord] a sheet close (M10b piece 2): what the run's sheet-check record keeps
|
|
266
258
|
*/
|
|
267
259
|
|
|
268
260
|
/**
|
package/types/ask.d.ts
CHANGED
|
@@ -51,7 +51,7 @@ export function makeFileAskStep({ timeoutMs, pollMs, clock, writeLine, }?: {
|
|
|
51
51
|
* @param {any} ask the parsed ask.json object (or its `evidence` field's
|
|
52
52
|
* container — pass the whole ask so a missing `evidence` key is itself a
|
|
53
53
|
* handled case, not the caller's problem).
|
|
54
|
-
* @returns {{ draft: {step?: string, text: string} | null, unjudged: Array<{step: string, emits?: string, text: string}>, why?: string }}
|
|
54
|
+
* @returns {{ draft: {step?: string, text: string} | null, unjudged: Array<{step: string, emits?: string, text: string}>, why?: string, claims?: Record<string, any> }}
|
|
55
55
|
*/
|
|
56
56
|
export function readAskEvidence(ask: any): {
|
|
57
57
|
draft: {
|
|
@@ -64,6 +64,7 @@ export function readAskEvidence(ask: any): {
|
|
|
64
64
|
text: string;
|
|
65
65
|
}>;
|
|
66
66
|
why?: string;
|
|
67
|
+
claims?: Record<string, any>;
|
|
67
68
|
};
|
|
68
69
|
/**
|
|
69
70
|
* M4b piece 3: the ONE serialisation of an artifact's bytes — what
|
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/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: {
|
package/types/model-step.d.ts
CHANGED
|
@@ -15,34 +15,8 @@ export function isTransportFailure(err: any): boolean;
|
|
|
15
15
|
* only (plus, for a green step that quotes a saved page, the form of its answer).
|
|
16
16
|
* `stepClass` is `'green' | 'softgreen' | 'hitl' | null | undefined`; `cited` is true for that green step.
|
|
17
17
|
*/
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
properties: {
|
|
21
|
-
done: {
|
|
22
|
-
type: string;
|
|
23
|
-
description: string;
|
|
24
|
-
};
|
|
25
|
-
blocker: {
|
|
26
|
-
type: string[];
|
|
27
|
-
description: string;
|
|
28
|
-
};
|
|
29
|
-
fields: {
|
|
30
|
-
type: string;
|
|
31
|
-
additionalProperties: {
|
|
32
|
-
type: string;
|
|
33
|
-
properties: {
|
|
34
|
-
value: {};
|
|
35
|
-
cite: {
|
|
36
|
-
type: string;
|
|
37
|
-
description: string;
|
|
38
|
-
};
|
|
39
|
-
};
|
|
40
|
-
required: string[];
|
|
41
|
-
};
|
|
42
|
-
};
|
|
43
|
-
};
|
|
44
|
-
required: string[];
|
|
45
|
-
}> | Readonly<{
|
|
18
|
+
/** @param {string|null|undefined} stepClass @param {boolean} [cited] @param {any[]|null} [sheet] M10b piece 2: the step's `close.sheet` (its claim boxes become the answer) */
|
|
19
|
+
export function buildEmitArtifactSchema(stepClass: string | null | undefined, cited?: boolean, sheet?: any[] | null): Readonly<{
|
|
46
20
|
type: "object";
|
|
47
21
|
properties: {
|
|
48
22
|
done: {
|
|
@@ -108,7 +82,21 @@ export function buildEmitArtifactSchema(stepClass: any, cited?: boolean): Readon
|
|
|
108
82
|
};
|
|
109
83
|
required: string[];
|
|
110
84
|
additionalProperties: false;
|
|
111
|
-
}
|
|
85
|
+
}> | {
|
|
86
|
+
type: string;
|
|
87
|
+
properties: {
|
|
88
|
+
done: {
|
|
89
|
+
type: string;
|
|
90
|
+
description: string;
|
|
91
|
+
};
|
|
92
|
+
blocker: {
|
|
93
|
+
type: string[];
|
|
94
|
+
description: string;
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
required: string[];
|
|
98
|
+
additionalProperties: boolean;
|
|
99
|
+
};
|
|
112
100
|
/**
|
|
113
101
|
* @param {object} opts
|
|
114
102
|
* @param {string} [opts.slot] - a provider row (the name of a key in the keys file); required when `provider` isn't injected.
|
|
@@ -118,7 +106,7 @@ export function buildEmitArtifactSchema(stepClass: any, cited?: boolean): Readon
|
|
|
118
106
|
* @param {{in:number,out:number}} [opts.rates]
|
|
119
107
|
* @param {string} [opts.modelId]
|
|
120
108
|
* @param {Record<string,string|undefined>} [opts.env] - the merged shell+keys-file env the key is read from (default process.env).
|
|
121
|
-
* @returns {(executorContext:object, grantedTools:Record<string,any>, stepMeta?:{class?:string, attempt?:number, step?:string|null, cited?:any, thinkingMode?:'on'|'off'}, seam?:{stopRequested?:() => boolean}) => Promise<any>}
|
|
109
|
+
* @returns {(executorContext:object, grantedTools:Record<string,any>, stepMeta?:{class?:string, attempt?:number, step?:string|null, cited?:any, sheet?:any[]|null, thinkingMode?:'on'|'off'}, seam?:{stopRequested?:() => boolean}) => Promise<any>}
|
|
122
110
|
*/
|
|
123
111
|
export function makeLiveModelStep({ slot, model, spendPath, provider: injectedProvider, rates: injectedRates, modelId: injectedModelId, env, }: {
|
|
124
112
|
slot?: string | undefined;
|
|
@@ -136,6 +124,7 @@ export function makeLiveModelStep({ slot, model, spendPath, provider: injectedPr
|
|
|
136
124
|
attempt?: number;
|
|
137
125
|
step?: string | null;
|
|
138
126
|
cited?: any;
|
|
127
|
+
sheet?: any[] | null;
|
|
139
128
|
thinkingMode?: "on" | "off";
|
|
140
129
|
}, seam?: {
|
|
141
130
|
stopRequested?: () => boolean;
|
|
@@ -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
|
*/
|