fwdloop 0.33.0 → 0.35.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 +14 -0
- package/bin/fwdloop +18 -2
- package/package.json +1 -1
- package/src/action-line.js +100 -0
- package/src/action-stop.js +44 -0
- package/src/ask.js +9 -2
- package/src/auditchecks.js +6 -4
- package/src/authoring.js +28 -14
- package/src/blockasks.js +3 -2
- package/src/blockassemble.js +40 -21
- package/src/blockdraft.js +8 -13
- package/src/blockpick.js +11 -1
- package/src/checkblock.js +102 -58
- package/src/checked.js +7 -2
- package/src/checklist.js +1 -3
- package/src/checklistsign.js +1 -1
- package/src/checkpick.js +7 -73
- package/src/declaration.js +20 -35
- package/src/drafter.js +281 -208
- package/src/jobkey.js +2 -3
- package/src/noteask.js +62 -0
- package/src/pageask.js +24 -69
- package/src/pagedry.js +27 -4
- package/src/pagemap.js +8 -2
- package/src/pagerules.js +19 -3
- package/src/panel/author.js +63 -36
- package/src/panel/authorcard.js +36 -20
- package/src/panel/data.js +5 -1
- package/src/panel/index.html +66 -37
- package/src/pickrecord.js +42 -54
- package/src/planrebuild.js +16 -6
- package/src/rowedit.js +35 -5
- package/src/rubricstep.js +9 -1
- package/src/runner.js +87 -41
- package/src/runvalues.js +9 -1
- package/src/setup.js +3 -1
- package/src/sheetblock.js +17 -7
- package/src/sheetbuild.js +148 -0
- package/src/sheetchecks.js +3 -2
- package/src/sheetfind.js +4 -4
- package/src/sheetlook.js +15 -4
- package/src/sheetoffer.js +50 -5
- package/src/sheetrows.js +18 -2
- package/src/signed-text.js +1 -5
- package/src/ticket-draft.js +4 -21
- package/src/ticketrows.js +100 -0
- package/src/whole-job.js +27 -11
- package/types/action-line.d.ts +71 -0
- package/types/action-stop.d.ts +36 -0
- package/types/ask.d.ts +3 -2
- package/types/auditchecks.d.ts +2 -1
- package/types/authoring.d.ts +8 -3
- package/types/blockasks.d.ts +1 -2
- package/types/blockassemble.d.ts +20 -3
- package/types/blockdraft.d.ts +4 -12
- package/types/blockpick.d.ts +5 -0
- package/types/checkblock.d.ts +33 -17
- package/types/checked.d.ts +2 -0
- package/types/checklist.d.ts +3 -5
- package/types/checkpick.d.ts +4 -34
- package/types/declaration.d.ts +7 -0
- package/types/drafter.d.ts +23 -356
- package/types/noteask.d.ts +52 -0
- package/types/pageask.d.ts +12 -36
- package/types/pagedry.d.ts +13 -0
- package/types/pagerules.d.ts +7 -0
- package/types/panel/author.d.ts +1 -1
- package/types/panel/authorcard.d.ts +13 -8
- package/types/panel/authorflows.d.ts +4 -4
- package/types/panel/data.d.ts +2 -2
- package/types/panel/jobgrid.d.ts +1 -1
- package/types/pickrecord.d.ts +47 -13
- package/types/rowedit.d.ts +16 -1
- package/types/rubricstep.d.ts +3 -0
- package/types/sheetblock.d.ts +11 -4
- package/types/sheetbuild.d.ts +82 -0
- package/types/sheetchecks.d.ts +2 -1
- package/types/sheetfind.d.ts +2 -2
- package/types/sheetoffer.d.ts +26 -1
- package/types/sheetrows.d.ts +8 -0
- package/types/ticket-draft.d.ts +3 -49
- package/types/ticketrows.d.ts +61 -0
- package/types/whole-job.d.ts +3 -3
- package/src/added-end.js +0 -60
- package/src/repairs.js +0 -38
- package/types/added-end.d.ts +0 -62
- package/types/repairs.d.ts +0 -13
package/src/sheetlook.js
CHANGED
|
@@ -83,6 +83,13 @@ export function applySheetWords(text, words, jobLines, label) {
|
|
|
83
83
|
/** @type {import('./pagerules.js').Dropped[]} */
|
|
84
84
|
const dropped = [];
|
|
85
85
|
const seen = new Set();
|
|
86
|
+
// the person's word is a header of the sheet: the word is theirs when the line or its `~` rules say it (a header the model picked in the person's place is not)
|
|
87
|
+
const isYours = (/** @type {any} */ jl, /** @type {string} */ word) => jl !== undefined && wordForms(word).some((f) => countPhrase(wordsSaidOn(jl), f) > 0);
|
|
88
|
+
// F196: a `~` rule whose own words contain a header of the sheet is tied to it by CODE (not by what the model returned): none of its words is asked (M10 am32, F180)
|
|
89
|
+
const headers = parseCsv(text).header;
|
|
90
|
+
const tiedRules = new Set(jobLines.flatMap((l) => lineRules(l).flatMap((r, i) => (headers.some((h) => h.trim() !== '' && countPhrase(r, h) > 0) ? [`${l.n}\u0000${i + 1}`] : []))));
|
|
91
|
+
/** the words (line + word) a `~` rule asked about or settled: the line's own prose never asks that word again (one word, one question; the rule's ask wins) */
|
|
92
|
+
const ruleWords = new Set();
|
|
86
93
|
for (const w of words) {
|
|
87
94
|
const at = tieOf(w.from, jobLines);
|
|
88
95
|
const key = `${at.line}\u0000${at.rule ?? ''}\u0000${w.word.toLowerCase()}`;
|
|
@@ -97,7 +104,7 @@ export function applySheetWords(text, words, jobLines, label) {
|
|
|
97
104
|
if (found.kind === 'header') {
|
|
98
105
|
// a real header is kept only when the word is the PERSON'S: in the line or its ~ rules. A header the model picked in the person's place is not a check the person
|
|
99
106
|
// asked for (live walk 2026-10-21: "Price over 500" kept as "Amount", nothing asked)
|
|
100
|
-
if (jl
|
|
107
|
+
if (!isYours(jl, w.word)) dropped.push({ ...rec, reason: 'word-not-yours' });
|
|
101
108
|
else facts.push(fact(found.column));
|
|
102
109
|
continue;
|
|
103
110
|
}
|
|
@@ -105,12 +112,16 @@ export function applySheetWords(text, words, jobLines, label) {
|
|
|
105
112
|
if (found.kind === 'tie') { dropped.push({ ...rec, reason: 'column-tie', other: found.columns.map((c) => `"${c}"`).join(', ') }); continue; }
|
|
106
113
|
if (found.kind === 'none') { dropped.push({ ...rec, reason: 'no-fit', other: String(found.rows) }); continue; }
|
|
107
114
|
// the person already named this column in a rule of the line (an answer they gave, or their own words): the word is that column, asked no more
|
|
108
|
-
if (rules.some((r
|
|
115
|
+
if (rules.some((r) => countPhrase(r, found.column) > 0)) { facts.push(fact(found.column)); continue; }
|
|
116
|
+
if (at.rule !== undefined) ruleWords.add(`${at.line}\u0000${w.word.toLowerCase()}`);
|
|
117
|
+
if (at.rule !== undefined && tiedRules.has(`${at.line}\u0000${at.rule}`)) continue;
|
|
118
|
+
// F196: the line's prose word that a tied `~` rule of the line also says is settled by that rule (one word, one question, whichever the look tied the ask to)
|
|
119
|
+
if (at.rule === undefined && rules.some((r, i) => tiedRules.has(`${at.line}\u0000${i + 1}`) && wordForms(w.word).some((f) => countPhrase(r, f) > 0))) continue;
|
|
109
120
|
asks.push({
|
|
110
|
-
line: at.line, rule: at.rule ?? null, source: 'look', ask: 'reading', ruleText, question: columnQuestion(w.word, found, at.line), reading: columnRuleWords(w.word, found.column), word: w.word, column: found.column,
|
|
121
|
+
line: at.line, rule: at.rule ?? null, source: 'look', ask: 'reading', ruleText, question: columnQuestion(w.word, found, at.line, at.rule !== undefined), reading: columnRuleWords(w.word, found.column), word: w.word, column: found.column,
|
|
111
122
|
});
|
|
112
123
|
}
|
|
113
|
-
return { facts, asks, dropped };
|
|
124
|
+
return { facts, asks: asks.filter((a) => a.rule !== null || !ruleWords.has(`${a.line}\u0000${a.word.toLowerCase()}`)), dropped };
|
|
114
125
|
}
|
|
115
126
|
|
|
116
127
|
/**
|
package/src/sheetoffer.js
CHANGED
|
@@ -78,20 +78,65 @@ export function sheetOpsBrief() {
|
|
|
78
78
|
* 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).
|
|
79
79
|
* @param {string[]} roles the CSV input roles @returns {string[]}
|
|
80
80
|
*/
|
|
81
|
-
export function sheetOfferRules(roles) {
|
|
81
|
+
export function sheetOfferRules(roles, lineNums = /** @type {number[]} */ ([])) {
|
|
82
82
|
return [
|
|
83
|
-
|
|
84
|
-
|
|
83
|
+
...(lineNums.length ? [`- The job's sheet lines are ${lineNums.join(', ')} (the lines shown with their ~ rules that are not on the list's own rows): "line" in a sheetChecks suggestion is one of those numbers, exactly as shown. The checks of a sheet line are sent only in sheetChecks: an edit that names a sheet line is refused.`] : []),
|
|
84
|
+
`- M17: you write NO sheet check in the declaration (it has no "close.sheet"). A job line whose step reads a CSV input (${roles.join(', ')}) and has a guardrail about values in it lists that input's role in the step's reads and gets its checks from your row-edit reply: "sheetChecks", 1 to ${MAX_SHEET_CHECKS} suggestions, each a bareguard check object from the ops below with "line" = the job line's number and "table" = the CSV input's role. Suggest the checks the line's guardrail needs and nothing else; code builds each one on bareguard or refuses it with its reason, and the person sees every one and can drop it.`,
|
|
85
|
+
'- A column name in a suggestion is picked from the sheet\'s header, spelled exactly; the tool only lets you pick a header name.',
|
|
85
86
|
'- 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.',
|
|
86
|
-
'- A "cells" check names "claim",
|
|
87
|
-
'- "covers" on each
|
|
87
|
+
'- A "cells" check names "claim", any short name (code renames it); the step is told only the shape of the answer, never the check. A "table" check has no claim and judges the input sheet itself, so it must already hold on that sheet; to check what a step gives, use a cells check. If every check of a step is a table check the step has nothing to answer: suggest at least one cells check too.',
|
|
88
|
+
'- "covers" on each suggestion 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.',
|
|
88
89
|
...sheetOpsBrief(),
|
|
89
90
|
];
|
|
90
91
|
}
|
|
91
92
|
|
|
93
|
+
/**
|
|
94
|
+
* M17 am2 item 2: the row-edit reply's `sheetChecks` property: bareguard's `checkSchema` items (src/sheetoffer.js `sheetChecksProp`) plus the job line each suggestion is for. Typed suggestions only; code builds or refuses each.
|
|
95
|
+
* @param {Record<string, {header: string[]}>} tables @param {number[]} [lineNums] the job's sheet lines: `line` can only name one of them @returns {Record<string, any>|null}
|
|
96
|
+
*/
|
|
97
|
+
export function sheetSuggestProp(tables, lineNums = /** @type {number[]} */ ([])) {
|
|
98
|
+
const p = sheetChecksProp(tables);
|
|
99
|
+
if (p === null) return null;
|
|
100
|
+
return { ...p, description: 'suggested sheet checks, only for a job line whose step reads a CSV input: code builds or refuses each one on bareguard; you never write a check into the plan', items: { ...p.items, properties: { line: { type: 'integer', ...(lineNums.length ? { enum: lineNums } : { minimum: 1 }), description: 'the number of the job line this check is for (one of the sheet lines shown)' }, ...p.items.properties }, required: ['line', ...p.items.required] } };
|
|
101
|
+
}
|
|
102
|
+
|
|
92
103
|
/** @param {unknown} rule @returns {boolean} true for the `use the column 'X' for 'Y'` rule an agreed column ask writes ({@link columnRuleWords}) */
|
|
93
104
|
export function isColumnChoiceRule(rule) {
|
|
94
105
|
const r = String(rule);
|
|
95
106
|
const head = columnRuleWords('', '').split("''")[0]; // "use the column '"
|
|
96
107
|
return r.startsWith(head) && r.endsWith("'") && r.includes("' for '");
|
|
97
108
|
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* M17 ruling 1 (hamr 2026-11-14): the parts of an agreed column rule (`use the column 'Amount' for 'Price'`), read from the words code wrote ({@link columnRuleWords}); null for any other text.
|
|
112
|
+
* @param {unknown} rule @returns {{column: string, word: string}|null}
|
|
113
|
+
*/
|
|
114
|
+
export function columnChoiceParts(rule) {
|
|
115
|
+
if (!isColumnChoiceRule(rule)) return null;
|
|
116
|
+
const r = String(rule);
|
|
117
|
+
const head = "use the column '";
|
|
118
|
+
const mid = r.indexOf("' for '", head.length);
|
|
119
|
+
if (mid < 0) return null;
|
|
120
|
+
return { column: r.slice(head.length, mid), word: r.slice(mid + "' for '".length, r.length - 1) };
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* M17 ruling 1: the rule's own words with the job's word (case aside, whole word) swapped for the agreed column: "Price over 500" + Amount -> "Amount over 500". Null when the word is not in the rule.
|
|
125
|
+
* @param {string} text @param {string} word @param {string} column @returns {string|null}
|
|
126
|
+
*/
|
|
127
|
+
export function swapColumnWord(text, word, column) {
|
|
128
|
+
const w = word.trim().toLowerCase();
|
|
129
|
+
if (w === '') return null;
|
|
130
|
+
const low = text.toLowerCase();
|
|
131
|
+
const isWordChar = (/** @type {string|undefined} */ c) => c !== undefined && c.toLowerCase() !== c.toUpperCase() || (c !== undefined && c >= '0' && c <= '9');
|
|
132
|
+
let from = 0;
|
|
133
|
+
for (;;) {
|
|
134
|
+
const at = low.indexOf(w, from);
|
|
135
|
+
if (at < 0) return null;
|
|
136
|
+
if (!isWordChar(text[at - 1]) && !isWordChar(text[at + w.length])) return `${text.slice(0, at)}${column}${text.slice(at + w.length)}`;
|
|
137
|
+
from = at + 1;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/** M17 ruling 2: what the AI is told of a column the person agreed for a word of the job's prose (no `~` rule): the word and the column, typed @param {{line: number, word: string, column: string}} c @returns {string} */
|
|
142
|
+
export const agreedColumnWords = (c) => `- The person agreed that on line ${c.line} the word '${c.word}' means the column '${c.column}'. If a check on that line needs it, suggest it on that column.`;
|
package/src/sheetrows.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
// Words are fwd's existing sheet-check words (src/sheetblock.js `sheetPlainText`); nothing here words a check. What this throws away: the check's fields (id, claim, range ...); a row keeps its line, tag, part and key.
|
|
7
7
|
import { sheetLineBlocks, sheetPlainText } from './sheetblock.js';
|
|
8
8
|
import { closePartsOf } from './checklistsign.js';
|
|
9
|
-
import {
|
|
9
|
+
import { isDeepStrictEqual } from 'node:util';
|
|
10
10
|
|
|
11
11
|
const isRec = (/** @type {unknown} */ v) => v !== null && typeof v === 'object' && !Array.isArray(v);
|
|
12
12
|
|
|
@@ -34,7 +34,7 @@ export function sheetRowsOf({ declaration, lines, csvRoles }) {
|
|
|
34
34
|
const block = sheetLineBlocks({ declaration: { steps: [st] }, lines, csvRoles })[0];
|
|
35
35
|
if (!block) return;
|
|
36
36
|
block.checked.forEach((e, j) => {
|
|
37
|
-
const by =
|
|
37
|
+
const by = /** @type {'you'|'agent'} */ (e.by);
|
|
38
38
|
const key = sheetRowKey(st.fromLine, e.id);
|
|
39
39
|
const nums = Array.isArray(st.close.sheet[j]?.covers) ? st.close.sheet[j].covers.filter((/** @type {unknown} */ x) => Number.isInteger(x) && /** @type {number} */ (x) >= 1 && /** @type {number} */ (x) <= block.guardrails.length) : [];
|
|
40
40
|
signed.push({
|
|
@@ -58,6 +58,22 @@ export function withSheetCard(card, sheet, dropped = []) {
|
|
|
58
58
|
/** the dropped sheet checks the picks record keeps: `{key, line, index, check, text}` @returns {any[]} */
|
|
59
59
|
export const droppedSheetOf = (/** @type {any} */ record) => (isRec(record) && Array.isArray(record.sheetDropped) ? record.sheetDropped.filter((d) => isRec(d) && typeof d.key === 'string' && isRec(d.check) && Number.isInteger(d.line)) : []);
|
|
60
60
|
|
|
61
|
+
/** the fields that say what a check is: all but the names code gives it (id, claim) and the rules it covers */
|
|
62
|
+
const checkBody = (/** @type {any} */ c) => { const { id: _i, claim: _c, covers: _v, ...rest } = c; return rest; };
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* M17 am3: the key of the check of the line that IS a dropped one (same typed fields; code names every check, so an id says nothing across drafts), or null. A Revise keeps a Drop only for the very same check.
|
|
66
|
+
* @param {any} declaration @param {{line: number, check: any}} d a record of `droppedSheetOf` @returns {string|null}
|
|
67
|
+
*/
|
|
68
|
+
export function keyOfSameCheck(declaration, d) {
|
|
69
|
+
for (const st of isRec(declaration) && Array.isArray(declaration.steps) ? declaration.steps : []) {
|
|
70
|
+
if (!isRec(st) || st.fromLine !== d.line || !isRec(st.close) || !Array.isArray(st.close.sheet)) continue;
|
|
71
|
+
const hit = st.close.sheet.find((/** @type {any} */ c) => isRec(c) && isDeepStrictEqual(checkBody(c), checkBody(d.check)));
|
|
72
|
+
if (hit) return sheetRowKey(d.line, String(hit.id));
|
|
73
|
+
}
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
|
|
61
77
|
/**
|
|
62
78
|
* The person's Drop or Add on a sheet row, applied to the declaration (a copy). Same words as the block's own refusals (src/checkblock.js `rowChoice`).
|
|
63
79
|
* @param {{declaration: any, lines: any[], csvRoles: string[], op: 'drop'|'add', key: string, dropped: any[]}} o
|
package/src/signed-text.js
CHANGED
|
@@ -442,11 +442,7 @@ function parseArbiter(arbiterRawLines, lineNumbers, reds, asks) {
|
|
|
442
442
|
reds.push(`arbiter: field "trigger" names the input "${trigger.role}", which is not one of the job's inputs (inputs: [${[...sourceRolesSeen].join(', ')}])`);
|
|
443
443
|
}
|
|
444
444
|
|
|
445
|
-
|
|
446
|
-
if (!asks.some((a) => a.line < s.line)) {
|
|
447
|
-
reds.push(`arbiter: field "sends" send at line ${s.line} has no ask at an earlier line (asks: [${asks.map((a) => a.line).join(', ')}])`);
|
|
448
|
-
}
|
|
449
|
-
}
|
|
445
|
+
// M13 am11: the action (a send) needs no Ask before it; what goes out is checked at run time against the last accept (or stops once)
|
|
450
446
|
|
|
451
447
|
return {
|
|
452
448
|
capUsd,
|
package/src/ticket-draft.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// M12 piece 3 (docs/wiki/the-module-ladder.md, "M12 scope (restart)" item 4): what the DRAFTER is told about a ticket role, and what it may suggest.
|
|
2
2
|
// A ticket role is a signed page input (`source <role> = page:<address>`) whose address is a GitHub issues list: it is never fetched at draft (one ticket is read
|
|
3
|
-
// per run through the job's MCP tools). The drafter may SUGGEST the job's `mcp`/`mcpTools` (issue_read), and
|
|
3
|
+
// per run through the job's MCP tools). The drafter may SUGGEST the job's `mcp`/`mcpTools` (issue_read), and (M17 am6) suggests the `ticketFilter` / `ticketWatch` as an edit of the list's row-edit turn, never as a top-level field; code proves it (src/ticketrows.js), a human
|
|
4
4
|
// signs it and code decides at run. The first facts line is F90c's, the line that made the drafter read a ticket role at all (FINDINGS F90c, F92).
|
|
5
5
|
import { discoverServers } from 'bare-agent/mcp';
|
|
6
6
|
import { startableMcpServers } from './mcp-sources.js';
|
|
@@ -30,8 +30,6 @@ export function ticketFactsLines(role) {
|
|
|
30
30
|
`- ${role}: one ticket's text (a signed input, already frozen at run start; read it by listing "${role}" in a step's reads, do not fetch it)`,
|
|
31
31
|
` A step that reads "${role}" still lists "read" in its primitives: the ticket is frozen, but reading it is a grant.`,
|
|
32
32
|
` Flow type: Tickets. The ticket is already frozen under "${role}" by the job's own tools ("${TICKET_TOOL}" reads it, "${LOOK_TOOL}" looks for new ones); no step needs them. A step lists a tool in "mcpTools" ONLY if that step calls the tool live; leave "mcpTools" out of every other step. The job's server and tool list are set by the program, not by you.`,
|
|
33
|
-
' When a guardrail names a priority or a label (for example "priority P1 only", "only tickets with priority P1 count", "only issues labelled bug"), you MUST add a top-level "ticketFilter": {"priority": [P0 to P3 values], "labels": [label names]} for it; leave it out only when no guardrail names a priority or a label, and such a guardrail stays hitl. A human signs it and code decides at run; never invent a label.',
|
|
34
|
-
' You may SUGGEST a top-level "ticketWatch": ["state", "labels"] (one or both) ONLY for a guardrail that says to run a ticket again when its state or its labels change. Any other thing to watch cannot be put there: leave it out and it stays hitl.',
|
|
35
33
|
];
|
|
36
34
|
}
|
|
37
35
|
|
|
@@ -47,28 +45,13 @@ export function mcpFactsLines(server, tools) {
|
|
|
47
45
|
export const LOOK_TOOL = 'list_issues';
|
|
48
46
|
|
|
49
47
|
/**
|
|
50
|
-
* The schema parts a job with an MCP adds (M13 piece 4): per-step `mcpTools` (an enum of the job's tool names) for MCP (generic) and Tickets, and
|
|
51
|
-
*
|
|
48
|
+
* The schema parts a job with an MCP adds (M13 piece 4): per-step `mcpTools` (an enum of the job's tool names) for MCP (generic) and Tickets, and no top-level `ticketFilter` or `ticketWatch` (M17 am6: they are checks on the list, suggested in the
|
|
49
|
+
* row-edit turn, src/rowedit.js; a draft that carries one is refused). The job's own `mcp` block and `flowType` are NOT offered: code sets them.
|
|
52
50
|
* @param {{flowType: 'mcp'|'tickets', tools: string[]}} o
|
|
53
51
|
*/
|
|
54
52
|
export function ticketSchemaParts({ flowType, tools }) {
|
|
55
53
|
const step = { mcpTools: { type: 'array', items: { type: 'string', enum: tools }, description: 'the MCP tools this step calls LIVE (exact names); omit on every step that calls none' } };
|
|
56
|
-
|
|
57
|
-
return {
|
|
58
|
-
top: {
|
|
59
|
-
ticketFilter: {
|
|
60
|
-
type: 'object',
|
|
61
|
-
properties: {
|
|
62
|
-
priority: { type: 'array', items: { type: 'string', enum: ['P0', 'P1', 'P2', 'P3'] }, description: 'priorities a ticket must have; only when a guardrail names them' },
|
|
63
|
-
labels: { type: 'array', items: { type: 'string' }, description: 'label names, one of which a ticket must carry; only when a guardrail names them' },
|
|
64
|
-
},
|
|
65
|
-
additionalProperties: false,
|
|
66
|
-
description: 'required when a guardrail names a priority or a label: put those values here; leave it out only when no guardrail names one',
|
|
67
|
-
},
|
|
68
|
-
ticketWatch: { type: 'array', items: { type: 'string', enum: ['state', 'labels'] }, description: 'optional: suggest only for a guardrail that says to run a ticket again when its state or its labels change' },
|
|
69
|
-
},
|
|
70
|
-
step,
|
|
71
|
-
};
|
|
54
|
+
return { top: {}, step };
|
|
72
55
|
}
|
|
73
56
|
|
|
74
57
|
/**
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
// M17 am6 (docs/wiki/the-module-ladder.md): a Tickets `~` rule about which tickets to take ("priority P1 only") or what to watch ("run a ticket again when its state changes") is a ROW on the list.
|
|
2
|
+
// Its check is the job's `ticketFilter` or `ticketWatch`. The AI suggests the value as an edit of the row-edit turn (src/rowedit.js); code proves it with the declaration's own readers
|
|
3
|
+
// (src/declaration.js checkTicketFilter / checkTicketWatch) and writes the declaration's field from it, only when a rule of that kind is on the job. This file is the ONE writer of a ticket row,
|
|
4
|
+
// its signed fields, its card words and its proof. A job with no ticket rows (a plan signed before M17) is not examined: its filter and watch run exactly as signed.
|
|
5
|
+
// What this throws away: the filter's and watch's values (they stay in the declaration); a row keeps its line, rule number, tag, state and reason.
|
|
6
|
+
import { checkTicketFilter, checkTicketWatch, isCountGuardrail } from './declaration.js';
|
|
7
|
+
|
|
8
|
+
const isRec = (/** @type {unknown} */ v) => v !== null && typeof v === 'object' && !Array.isArray(v);
|
|
9
|
+
|
|
10
|
+
/** @type {readonly ('ticketFilter'|'ticketWatch')[]} */
|
|
11
|
+
export const TICKET_FIELDS = Object.freeze(['ticketFilter', 'ticketWatch']);
|
|
12
|
+
/** the Not-checked reason of a ticket rule no legal value was suggested for (the block's own noPick sentence is used by the caller's words) */
|
|
13
|
+
export const NO_VALUE_WHY = 'No check was picked for it, so you judge it at the Ask.';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Which signed field a Tickets rule is the check of: `ticketWatch` (a state or labels change), `ticketFilter` (a priority P0 to P3 or a label), or null (a content rule or a count).
|
|
17
|
+
* @param {string} t the rule's words @returns {'ticketFilter'|'ticketWatch'|null}
|
|
18
|
+
*/
|
|
19
|
+
export function ticketRuleField(t) {
|
|
20
|
+
if (isCountGuardrail(t)) return null;
|
|
21
|
+
if (/\b(?:state|labels)\b[^;]*\bchange/i.test(t)) return 'ticketWatch';
|
|
22
|
+
if (/\bp[0-3]\b/i.test(t) || /\blabel(?:l?ed|s)?\b/i.test(t)) return 'ticketFilter';
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The reds of a suggested value, by the declaration's own readers (a stand-in declaration with an `mcp` block so only the value is judged). Empty = legal.
|
|
28
|
+
* @param {'ticketFilter'|'ticketWatch'} field @param {unknown} value @returns {string[]}
|
|
29
|
+
*/
|
|
30
|
+
export function proposalReds(field, value) {
|
|
31
|
+
/** @type {string[]} */
|
|
32
|
+
const reds = [];
|
|
33
|
+
const d = { mcp: {}, [field]: value };
|
|
34
|
+
if (field === 'ticketFilter') checkTicketFilter(d, reds); else checkTicketWatch(d, reds);
|
|
35
|
+
return reds;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** the words a value is drawn with: the readout's own (src/authoring.js) @param {'ticketFilter'|'ticketWatch'} field @param {any} v */
|
|
39
|
+
export function ticketWords(field, v) {
|
|
40
|
+
if (field === 'ticketWatch') return `ticket watch: ${(Array.isArray(v) ? v : []).join(', ')}`;
|
|
41
|
+
const parts = [...(v?.priority?.length ? [`priority ${v.priority.join(', ')}`] : []), ...(v?.labels?.length ? [`labels ${v.labels.join(', ')}`] : [])];
|
|
42
|
+
return `ticket filter: ${parts.join(' · ')}`;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** the key of a ticket row @param {number} line @param {number} rule @param {string} field */
|
|
46
|
+
export const ticketRowKey = (line, rule, field) => `L${line}.ticket.${field}.${rule}`;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* The ticket rows of a Tickets declaration: one per `~` rule of a filter or watch kind. Built when the declaration holds that field; else Not checked (the person judges it at the Ask).
|
|
50
|
+
* @param {{declaration: any, lines: {n: number, guardrail?: string|null}[]}} o `lines` = the signed lines (a line's `guardrail` is its `; `-joined `~` rules)
|
|
51
|
+
* @returns {{signed: Record<string, any>[], card: {key: string, line: number, by: 'you', state: string, text: string, reason: string|null, drop: false}[], notChecked: {line: number, rule: string, reason: string}[]}}
|
|
52
|
+
*/
|
|
53
|
+
export function ticketRowsOf({ declaration, lines }) {
|
|
54
|
+
/** @type {Record<string, any>[]} */ const signed = [];
|
|
55
|
+
/** @type {any[]} */ const card = [];
|
|
56
|
+
/** @type {{line: number, rule: string, reason: string}[]} */ const notChecked = [];
|
|
57
|
+
if (!isRec(declaration) || declaration.flowType !== 'tickets') return { signed, card, notChecked };
|
|
58
|
+
for (const l of lines) {
|
|
59
|
+
const rules = typeof l.guardrail === 'string' ? l.guardrail.split('; ').map((s) => s.trim()).filter(Boolean) : [];
|
|
60
|
+
rules.forEach((t, i) => {
|
|
61
|
+
const field = ticketRuleField(t);
|
|
62
|
+
if (field === null) return;
|
|
63
|
+
const key = ticketRowKey(l.n, i + 1, field);
|
|
64
|
+
const has = Object.hasOwn(declaration, field);
|
|
65
|
+
signed.push({ line: l.n, key, from: 'rule', by: 'you', kind: 'ticket', state: has ? 'built' : 'not-checked', rule: i + 1, field, ...(has ? {} : { reason: NO_VALUE_WHY }) });
|
|
66
|
+
card.push({ key, line: l.n, by: 'you', state: has ? 'built' : 'not-checked', text: has ? `"${t}" -> ${ticketWords(field, declaration[field])}` : `"${t}"`, reason: has ? null : NO_VALUE_WHY, drop: false });
|
|
67
|
+
if (!has) notChecked.push({ line: l.n, rule: t, reason: NO_VALUE_WHY });
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
return { signed, card, notChecked };
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* The list of a declaration with its ticket rows after the block's rows. A declaration with none keeps its list exactly as it was.
|
|
75
|
+
* @param {{declaration: any, lines: any[]}} o @returns {{declaration: any, tickets: ReturnType<typeof ticketRowsOf>}}
|
|
76
|
+
*/
|
|
77
|
+
export function withTicketRows({ declaration, lines }) {
|
|
78
|
+
const base = Array.isArray(declaration.checkList) ? declaration.checkList.filter((/** @type {any} */ r) => !(isRec(r) && r.kind === 'ticket')) : undefined;
|
|
79
|
+
const tickets = ticketRowsOf({ declaration, lines });
|
|
80
|
+
if (tickets.signed.length === 0) return { declaration, tickets };
|
|
81
|
+
return { declaration: { ...declaration, checkList: [...(base ?? []), ...tickets.signed] }, tickets };
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* 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.
|
|
86
|
+
* @param {any} declaration @returns {string[]}
|
|
87
|
+
*/
|
|
88
|
+
export function ticketListReds(declaration) {
|
|
89
|
+
const list = isRec(declaration) && Array.isArray(declaration.checkList) ? declaration.checkList.filter((/** @type {any} */ r) => isRec(r) && r.kind === 'ticket') : [];
|
|
90
|
+
if (list.length === 0) return [];
|
|
91
|
+
/** @type {string[]} */
|
|
92
|
+
const reds = [];
|
|
93
|
+
for (const f of TICKET_FIELDS) {
|
|
94
|
+
const built = list.some((/** @type {any} */ r) => r.field === f && r.state === 'built');
|
|
95
|
+
const has = Object.hasOwn(declaration, f);
|
|
96
|
+
if (built && !has) reds.push(`declaration: checkList: a row says "${f}" is its check, but the plan has no "${f}". Nothing was signed - draft again.`);
|
|
97
|
+
if (has && !built) reds.push(`declaration: "${f}" is not the check of any rule on the list. Nothing was signed - draft again.`);
|
|
98
|
+
}
|
|
99
|
+
return reds;
|
|
100
|
+
}
|
package/src/whole-job.js
CHANGED
|
@@ -4,23 +4,39 @@
|
|
|
4
4
|
// `Line <n>: you accepted this at the Ask.`; the last Ask itself and the send line are not sections. The accepted artifact is `{text}`, so the send ships it unchanged.
|
|
5
5
|
// Throws away: nothing of a step's saved output beyond what `renderSentMd` already drops. Third outcomes: a work step with no readable saved output refuses, naming the step.
|
|
6
6
|
import { renderSentMd } from './send.js';
|
|
7
|
-
import { addedLinesOf } from './added-end.js';
|
|
8
7
|
|
|
9
8
|
/**
|
|
10
|
-
* The
|
|
11
|
-
* (its send line is the person's own words) finds -1 and keeps today's behaviour exactly.
|
|
9
|
+
* The Ask the action reads: the Ask right before the one signed send (M13 am11: the action ships the step before it). -1 = none.
|
|
12
10
|
* @param {{ steps: { fromLine: number, goal: string, emits?: string, reads?: string[] }[], askLines: Map<number, any>, sendLines: Map<number, any> }} p
|
|
13
|
-
* @returns {number}
|
|
11
|
+
* @returns {number}
|
|
14
12
|
*/
|
|
15
|
-
|
|
13
|
+
function askBeforeSend({ steps, askLines, sendLines }) {
|
|
16
14
|
if (sendLines.size !== 1) return -1;
|
|
17
15
|
const send = [...sendLines.values()][0];
|
|
18
|
-
const lines = steps.map((s) => ({ n: s.fromLine, text: s.goal }));
|
|
19
|
-
if (!addedLinesOf(lines, { sends: [...sendLines.values()], asks: [...askLines.values()] }).has(send.line)) return -1;
|
|
20
16
|
const sendStep = steps.find((s) => s.fromLine === send.line);
|
|
21
17
|
const askIds = (sendStep?.reads ?? []).filter((id) => steps.some((s) => s.emits === id && askLines.has(s.fromLine)));
|
|
22
18
|
if (askIds.length !== 1) return -1;
|
|
23
|
-
|
|
19
|
+
const idx = steps.findIndex((s) => s.emits === askIds[0]);
|
|
20
|
+
return steps[idx + 1] === sendStep ? idx : -1;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** The emits of every work step (not an Ask) before step `idx`, in job order. */
|
|
24
|
+
function workBefore(steps, idx, askLines) {
|
|
25
|
+
return steps.slice(0, idx).filter((s) => !askLines.has(s.fromLine) && typeof s.emits === 'string').map((s) => /** @type {string} */ (s.emits));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* The index of the Ask that shows the whole job: the Ask right before the action, when the plan has it read EVERY work step before it (what `readEveryStep` writes into a plan
|
|
30
|
+
* drafted from M13 am9 on). A plan signed with that Ask reading one step (a job signed before am9) finds -1 and keeps today's behaviour exactly: a stored plan is never reinterpreted.
|
|
31
|
+
* @param {{ steps: { fromLine: number, goal: string, emits?: string, reads?: string[] }[], askLines: Map<number, any>, sendLines: Map<number, any> }} p
|
|
32
|
+
* @returns {number} -1 = none
|
|
33
|
+
*/
|
|
34
|
+
export function wholeJobAskIndex({ steps, askLines, sendLines }) {
|
|
35
|
+
const idx = askBeforeSend({ steps, askLines, sendLines });
|
|
36
|
+
if (idx < 1) return idx === 0 ? -1 : idx;
|
|
37
|
+
const work = workBefore(steps, idx, askLines);
|
|
38
|
+
const reads = steps[idx].reads ?? [];
|
|
39
|
+
return work.length > 0 && reads.length === work.length && work.every((e) => reads.includes(e)) ? idx : -1;
|
|
24
40
|
}
|
|
25
41
|
|
|
26
42
|
/**
|
|
@@ -53,7 +69,7 @@ export function wholeJobText({ steps, askLines, lastAskIndex, readResult }) {
|
|
|
53
69
|
|
|
54
70
|
/**
|
|
55
71
|
* M13 am9 item 4: the plan shows the last Ask as reading every step. Code sets the Ask's `reads` to every work step's emits before it (the nearest one first, so a
|
|
56
|
-
* redo still re-runs the step just before the Ask; the rest in job order). Only
|
|
72
|
+
* redo still re-runs the step just before the Ask; the rest in job order). Only for the Ask right before the action; any other plan comes back as it was.
|
|
57
73
|
* @template {{ fromLine: number, goal: string, emits?: string, reads?: string[], primitives?: string[] }} S
|
|
58
74
|
* @param {S[]} steps @param {{ asks?: { line: number }[], sends?: { line: number }[] }} arbiter
|
|
59
75
|
* @returns {S[]}
|
|
@@ -62,9 +78,9 @@ export function readEveryStep(steps, arbiter) {
|
|
|
62
78
|
if (!Array.isArray(steps) || !steps.every((s) => s && typeof s === 'object')) return steps;
|
|
63
79
|
const askLines = new Map((arbiter?.asks ?? []).map((a) => [a.line, a]));
|
|
64
80
|
const sendLines = new Map((arbiter?.sends ?? []).map((x) => [x.line, x]));
|
|
65
|
-
const idx =
|
|
81
|
+
const idx = askBeforeSend({ steps, askLines, sendLines });
|
|
66
82
|
if (idx < 1) return steps;
|
|
67
|
-
const work = steps
|
|
83
|
+
const work = workBefore(steps, idx, askLines);
|
|
68
84
|
if (work.length === 0) return steps;
|
|
69
85
|
const reads = [work[work.length - 1], ...work.slice(0, -1)];
|
|
70
86
|
return steps.map((s, i) => (i === idx ? { ...s, reads } : s));
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The job as the model sees it (F204's listing): `n. text`, ` gN: rule` per `; ` part, then the Destination.
|
|
3
|
+
* @param {{n: number, text: string, guardrail?: string}[]} lines `parseSignedText`'s lines @param {Set<number>} askLines @param {string} destination
|
|
4
|
+
*/
|
|
5
|
+
export function jobListing(lines: {
|
|
6
|
+
n: number;
|
|
7
|
+
text: string;
|
|
8
|
+
guardrail?: string;
|
|
9
|
+
}[], askLines: Set<number>, destination: string): string;
|
|
10
|
+
/**
|
|
11
|
+
* Code's check of the recognise answer: the action is the LAST line (and not an Ask) or there is none.
|
|
12
|
+
* @param {any} args the tool call's arguments @param {number} lastLine @param {boolean} lastIsAsk
|
|
13
|
+
* @returns {boolean} true = the last line is the action
|
|
14
|
+
*/
|
|
15
|
+
export function recognisedIsLast(args: any, lastLine: number, lastIsAsk: boolean): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Code's check of the suggestion: one plain line, not empty, not long, no control characters. Anything else is no suggestion.
|
|
18
|
+
* @param {any} args @returns {string|null}
|
|
19
|
+
*/
|
|
20
|
+
export function cleanSuggestion(args: any): string | null;
|
|
21
|
+
/**
|
|
22
|
+
* The prose file without its (tentative) send line: the one writer of "this job has no write". Only the arbiter's `send at line <n> to ...` line is removed.
|
|
23
|
+
* @param {string} proseText
|
|
24
|
+
*/
|
|
25
|
+
export function withoutSend(proseText: string): string;
|
|
26
|
+
export const RECOGNISE_TOOL: "record_action";
|
|
27
|
+
export const SUGGEST_TOOL: "suggest_action";
|
|
28
|
+
export const MAX_SUGGESTION_CHARS: 300;
|
|
29
|
+
export const RECOGNISE_SYSTEM: "A person wrote a numbered list of steps for a job. The finished result goes to the Destination named below the list.\n\nIs there a last step that writes or sends everything that came before it? Answer with that step's number, or null if there is none.\n\nA step that only reads, makes, lists, checks or asks something is not one. The step does not have to name the Destination: the Destination is only where the result goes.\n\nAnswer by calling the tool record_action exactly once, with the field \"action\" holding one required field: line (the step's number, or null).";
|
|
30
|
+
export const SUGGEST_SYSTEM: "A person wrote a numbered list of steps for a job. The finished result goes to the Destination named below the list. The list has no last step that writes or sends everything that came before it.\n\nYour one task: suggest ONE last step that writes or sends everything that came before it to the Destination.\n\nRules:\n- Write the step as one short plain sentence, in the person's voice, like their other steps. It must say that the result is written or sent to the Destination.\n- Do not repeat or change any existing step. Do not write a step that asks the person a question.\n\nAnswer by calling the tool suggest_action exactly once. The one required field is text (the new step).";
|
|
31
|
+
export namespace RECOGNISE_SCHEMA {
|
|
32
|
+
export let type: string;
|
|
33
|
+
export namespace properties {
|
|
34
|
+
namespace action {
|
|
35
|
+
let type_1: string;
|
|
36
|
+
export { type_1 as type };
|
|
37
|
+
export namespace properties_1 {
|
|
38
|
+
namespace line {
|
|
39
|
+
let type_2: string[];
|
|
40
|
+
export { type_2 as type };
|
|
41
|
+
export let description: string;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
export { properties_1 as properties };
|
|
45
|
+
export let required: string[];
|
|
46
|
+
export let additionalProperties: boolean;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
let required_1: string[];
|
|
50
|
+
export { required_1 as required };
|
|
51
|
+
let additionalProperties_1: boolean;
|
|
52
|
+
export { additionalProperties_1 as additionalProperties };
|
|
53
|
+
}
|
|
54
|
+
export namespace SUGGEST_SCHEMA {
|
|
55
|
+
let type_3: string;
|
|
56
|
+
export { type_3 as type };
|
|
57
|
+
export namespace properties_2 {
|
|
58
|
+
namespace text {
|
|
59
|
+
let type_4: string;
|
|
60
|
+
export { type_4 as type };
|
|
61
|
+
let description_1: string;
|
|
62
|
+
export { description_1 as description };
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
export { properties_2 as properties };
|
|
66
|
+
let required_2: string[];
|
|
67
|
+
export { required_2 as required };
|
|
68
|
+
let additionalProperties_2: boolean;
|
|
69
|
+
export { additionalProperties_2 as additionalProperties };
|
|
70
|
+
}
|
|
71
|
+
export function suggestionQuestion(line: string): string;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {{ acceptedSha: string|null|undefined, outgoing: Record<string, any> }} a `acceptedSha` = the sha256 recorded at the last Ask accepted this run; `outgoing` = the artifact about to go out
|
|
3
|
+
* @returns {{ go: true, outgoingSha: string } | { go: false, question: string, outgoingSha: string }}
|
|
4
|
+
*/
|
|
5
|
+
export function decideAction({ acceptedSha, outgoing }: {
|
|
6
|
+
acceptedSha: string | null | undefined;
|
|
7
|
+
outgoing: Record<string, any>;
|
|
8
|
+
}): {
|
|
9
|
+
go: true;
|
|
10
|
+
outgoingSha: string;
|
|
11
|
+
} | {
|
|
12
|
+
go: false;
|
|
13
|
+
question: string;
|
|
14
|
+
outgoingSha: string;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* The accept to compare against: the sha of the LAST Ask (by step order) before step `i` that was accepted in this run, or null when there is none.
|
|
18
|
+
* @param {{ emits?: string }[]} steps @param {number} i @param {Map<string, string|null>} acceptedAskEmitsThisRun
|
|
19
|
+
*/
|
|
20
|
+
export function lastAcceptedSha(steps: {
|
|
21
|
+
emits?: string;
|
|
22
|
+
}[], i: number, acceptedAskEmitsThisRun: Map<string, string | null>): string | null;
|
|
23
|
+
/**
|
|
24
|
+
* am11a 1/2: the wait of the stop. The LAST Ask's own wait when the job has an Ask before the action; else the card's Ask wait kept in the run's signed values (`arbiter.actionWaitMs`), else 1h.
|
|
25
|
+
* @param {{ fromLine: number }[]} steps @param {number} i @param {Map<number, {ttlMs: number}>} askLines @param {number|undefined} actionWaitMs
|
|
26
|
+
*/
|
|
27
|
+
export function stopWaitMs(steps: {
|
|
28
|
+
fromLine: number;
|
|
29
|
+
}[], i: number, askLines: Map<number, {
|
|
30
|
+
ttlMs: number;
|
|
31
|
+
}>, actionWaitMs: number | undefined): number;
|
|
32
|
+
export const ACTION_STOP_KIND: "action-stop";
|
|
33
|
+
export const STOP_CHANGED: "This changed since you accepted it.";
|
|
34
|
+
export const STOP_UNSEEN: "You have not seen this yet.";
|
|
35
|
+
/** am11a 1: the card's Ask wait is 1h unless the person changes it; this is the default when nothing else is signed. */
|
|
36
|
+
export const DEFAULT_ACTION_WAIT_MS: 3600000;
|
package/types/ask.d.ts
CHANGED
|
@@ -188,10 +188,10 @@ export function answerAsk({ runDir, askId, decision: givenDecision, reason, cloc
|
|
|
188
188
|
* Written once with the rest of the record; an existing archive is never
|
|
189
189
|
* rewritten to add it (the `wx` create refuses).
|
|
190
190
|
*
|
|
191
|
-
* @param {{ runDir: string, askId: string, question: string, askedAt: string, expiresAt: string, evidence: unknown, emits?: string }} opts
|
|
191
|
+
* @param {{ runDir: string, askId: string, question: string, askedAt: string, expiresAt: string, evidence: unknown, emits?: string, kind?: string }} opts
|
|
192
192
|
* @returns {{ ok: true } | { ok: false, red: string }}
|
|
193
193
|
*/
|
|
194
|
-
export function writeAskArchive({ runDir, askId, question, askedAt, expiresAt, evidence, emits, }: {
|
|
194
|
+
export function writeAskArchive({ runDir, askId, question, askedAt, expiresAt, evidence, emits, kind, }: {
|
|
195
195
|
runDir: string;
|
|
196
196
|
askId: string;
|
|
197
197
|
question: string;
|
|
@@ -199,6 +199,7 @@ export function writeAskArchive({ runDir, askId, question, askedAt, expiresAt, e
|
|
|
199
199
|
expiresAt: string;
|
|
200
200
|
evidence: unknown;
|
|
201
201
|
emits?: string;
|
|
202
|
+
kind?: string;
|
|
202
203
|
}): {
|
|
203
204
|
ok: true;
|
|
204
205
|
} | {
|
package/types/auditchecks.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @param {any} declaration the signed plan @param {any[]} diary the run's `checks` rows (src/diary.js readChecks) @param {{items?: string[], by?: Record<string, string>}|null} notChecked the sign row's Not-checked block
|
|
3
3
|
* @param {{lines?: any[], csvRoles?: string[]}} [sheet] the signed job lines and CSV roles: a plan whose list has sheet rows (M16 am4) shows them here, tagged by where each comes from (hamr 2026-11-14)
|
|
4
|
-
* @returns {{checks: AuditCheckRow[], notChecked: AuditCheckRow[], always: AuditCheckRow[]}|null} null for a plan with no list (it keeps its own Audit rows)
|
|
4
|
+
* @returns {{checks: AuditCheckRow[], notChecked: AuditCheckRow[], readNotes: string[], always: AuditCheckRow[]}|null} null for a plan with no list (it keeps its own Audit rows)
|
|
5
5
|
* @typedef {{text: string, by: 'you'|'agent'|'default'|null, result: 'passed'|'failed'|'none'|'not-checked'}} AuditCheckRow
|
|
6
6
|
*/
|
|
7
7
|
export function auditChecksOf(declaration: any, diary: any[], notChecked: {
|
|
@@ -13,6 +13,7 @@ export function auditChecksOf(declaration: any, diary: any[], notChecked: {
|
|
|
13
13
|
}): {
|
|
14
14
|
checks: AuditCheckRow[];
|
|
15
15
|
notChecked: AuditCheckRow[];
|
|
16
|
+
readNotes: string[];
|
|
16
17
|
always: AuditCheckRow[];
|
|
17
18
|
} | null;
|
|
18
19
|
/** the words of a row no result was recorded for: never "passed" */
|
package/types/authoring.d.ts
CHANGED
|
@@ -57,7 +57,7 @@ export function scrub(text: any, secrets: any): any;
|
|
|
57
57
|
export function sweepForSecrets(dir: any, secrets: any): number;
|
|
58
58
|
/** Exact signed TTL with its unit, never rounded: 2h / 30m / 20s / 1500ms (the largest unit that divides it exactly). */
|
|
59
59
|
export function fmtTtl(ms: any): string;
|
|
60
|
-
/** Zero-based indexes of the heading lines in a readout's text (split on "\n"): the panel renders those bold. */
|
|
60
|
+
/** Zero-based indexes of the header and heading lines in a readout's text (split on "\n"): the panel renders those bold. */
|
|
61
61
|
export function readoutHeadIndexes(text: any): any[];
|
|
62
62
|
/** Plain-text readout of what the human is about to sign. Pure. */
|
|
63
63
|
export function buildReadout({ declaration, arbiter, lines, name, modelId, costUsd, rounds, spendComplete, root, }: {
|
|
@@ -113,7 +113,7 @@ export function writePlanFiles(dir: string, files: Record<string, string>, opts?
|
|
|
113
113
|
* Test seam: `provider`/`rates`/`modelId` are injected; without them a live provider is built.
|
|
114
114
|
* `onResult({ ok })` (M4d am32): called once, after the spend is booked and just before the result files are written (the CLI gives its monthly hold back there).
|
|
115
115
|
*/
|
|
116
|
-
export function draftToDir({ proseFile, dir, root, name, slot, model, draftThinking, keyNames, env, provider, rates, modelId, noQuestions, onResult, fetchPage, leftRules, checkPicks, carriedPicks, carriedChoices, carriedSheetDropped, proseRead, flowType, mcpServer, mcpPick, mcpServers, }: {
|
|
116
|
+
export function draftToDir({ proseFile, dir, root, name, slot, model, draftThinking, keyNames, env, provider, rates, modelId, noQuestions, onResult, fetchPage, leftRules, columnAnswers, carriedColumns, checkPicks, carriedPicks, carriedChoices, carriedSheetDropped, proseRead, flowType, mcpServer, mcpPick, mcpServers, actionMode, }: {
|
|
117
117
|
proseFile: any;
|
|
118
118
|
dir: any;
|
|
119
119
|
root: any;
|
|
@@ -130,15 +130,18 @@ export function draftToDir({ proseFile, dir, root, name, slot, model, draftThink
|
|
|
130
130
|
onResult: any;
|
|
131
131
|
fetchPage: any;
|
|
132
132
|
leftRules: any;
|
|
133
|
+
columnAnswers: any;
|
|
134
|
+
carriedColumns: any;
|
|
133
135
|
checkPicks: any;
|
|
134
136
|
carriedPicks: any;
|
|
135
137
|
carriedChoices: any;
|
|
136
138
|
carriedSheetDropped: any;
|
|
137
139
|
proseRead: any;
|
|
138
|
-
flowType?: "
|
|
140
|
+
flowType?: "tickets" | "mcp" | "plain" | undefined;
|
|
139
141
|
mcpServer?: string | undefined;
|
|
140
142
|
mcpPick?: any;
|
|
141
143
|
mcpServers?: string[] | undefined;
|
|
144
|
+
actionMode?: "check" | "known" | null | undefined;
|
|
142
145
|
}): Promise<{
|
|
143
146
|
ok: boolean;
|
|
144
147
|
wrote: boolean;
|
|
@@ -270,3 +273,5 @@ export function SIGN_LINE(dir: any, hash: any): string;
|
|
|
270
273
|
export const OPEN_QUESTION_SAY: "A question the plan raised is still open. Answer it in the panel (fwdloop panel), then sign the plan it drafts after your answers. Nothing was signed.";
|
|
271
274
|
export const ANSWERED_QUESTION_SAY: "This plan raised questions, and your answers went into a newer plan. Sign the newest plan, not this one. Nothing was signed.";
|
|
272
275
|
export function costText(n: any, spendComplete?: boolean): string;
|
|
276
|
+
/** The readout's top line prefix: ONE owner for the text `buildReadout` writes and the bold `readoutHeadIndexes` finds. */
|
|
277
|
+
export const READOUT_HEADER_PREFIX: "DRAFT READOUT \u2014 NOT SIGNED \u2014 flow ";
|
package/types/blockasks.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @typedef {{key: string, rowKey: string, line: number, rule: number, source: 'look', ask: 'reading'|'cant-check'|'no-check'|'check', ruleText: string, question: string, counted: boolean, reading?: string, check?: Record<string, any
|
|
1
|
+
/** @typedef {{key: string, rowKey: string, line: number, rule: number, source: 'look', ask: 'reading'|'cant-check'|'no-check'|'check', ruleText: string, question: string, counted: boolean, reading?: string, check?: Record<string, any>}} BlockAsk */
|
|
2
2
|
/**
|
|
3
3
|
* The questions the block has open, in the order the person meets them: the look's readings, then the look's can't-checks, then the pick path's asks (a proposal or a can't-check about a rule the pick path owns) in rule order (a proposal is not counted toward the 3-ask cap).
|
|
4
4
|
* A can't-check about a rule the PICK path owns (`scoped`: src/checkpick.js scopedRules, every `~` rule of a file job) is the pick path's own ask, `no-check`, in fwd's words (a "Line N, guardrail ...: I can't check this" ask
|
|
@@ -33,5 +33,4 @@ export type BlockAsk = {
|
|
|
33
33
|
counted: boolean;
|
|
34
34
|
reading?: string;
|
|
35
35
|
check?: Record<string, any>;
|
|
36
|
-
pairRule?: number;
|
|
37
36
|
};
|