fwdloop 0.29.0 → 0.30.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/added-end.js +60 -0
- package/src/authoring.js +9 -5
- package/src/checked.js +11 -9
- package/src/checkpick.js +66 -5
- package/src/checkwords.js +5 -0
- package/src/citedcheck.js +14 -0
- package/src/closers.js +32 -2
- package/src/declaration.js +49 -2
- package/src/draft-steps.js +3 -3
- package/src/drafter.js +41 -9
- package/src/jobkey.js +3 -1
- package/src/model-step.js +14 -8
- package/src/pageask.js +3 -0
- package/src/panel/author.js +2 -1
- package/src/panel/authorcard.js +12 -8
- package/src/panel/data.js +4 -3
- package/src/panel/index.html +15 -1
- package/src/plain-checks.js +15 -3
- package/src/provider.js +1 -1
- package/src/repairs.js +38 -0
- package/src/runner.js +47 -10
- package/src/sheetblock.js +2 -1
- package/src/ticket-draft.js +2 -2
- package/src/ticket-labels.js +2 -2
- package/src/try-checks.js +13 -3
- package/src/whole-job.js +71 -0
- package/types/added-end.d.ts +62 -0
- package/types/checkpick.d.ts +34 -0
- package/types/checkwords.d.ts +4 -0
- package/types/citedcheck.d.ts +6 -0
- package/types/closers.d.ts +4 -2
- package/types/declaration.d.ts +3 -0
- package/types/drafter.d.ts +16 -0
- package/types/model-step.d.ts +18 -3
- package/types/panel/data.d.ts +1 -1
- package/types/panel/jobgrid.d.ts +1 -1
- package/types/plain-checks.d.ts +9 -1
- package/types/repairs.d.ts +13 -0
- package/types/try-checks.d.ts +1 -7
- package/types/whole-job.d.ts +70 -0
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 a `ticketFilter` (priority / label names); a human
|
|
3
|
+
// per run through the job's MCP tools). The drafter may SUGGEST the job's `mcp`/`mcpTools` (issue_read), and MUST add a `ticketFilter` (priority / label names) when a guardrail names a priority or a label; 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';
|
|
@@ -63,7 +63,7 @@ export function ticketSchemaParts({ flowType, tools }) {
|
|
|
63
63
|
labels: { type: 'array', items: { type: 'string' }, description: 'label names, one of which a ticket must carry; only when a guardrail names them' },
|
|
64
64
|
},
|
|
65
65
|
additionalProperties: false,
|
|
66
|
-
description: '
|
|
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
67
|
},
|
|
68
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
69
|
},
|
package/src/ticket-labels.js
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
// Three outcomes are kept apart: skip (a definite miss, or closed), run (a match), run-with-`unsure` (an off-scale or unreadable label goes to a human at the
|
|
5
5
|
// ask, NEVER skipped). Normaliser borrowed in shape from fwdloop poc/mcp/f96/f96.mjs (the F96 rules, 12 of 12 on real tickets), re-shaped to a pure function.
|
|
6
6
|
|
|
7
|
-
/** `P0`..`P3`, optionally after `priority`, `priority:`, `priority /` or `priority -`;
|
|
8
|
-
const PRIORITY_LABEL = /^(?:priority\s*[:/-]?\s*)?p([0-3])(?![
|
|
7
|
+
/** `P0`..`P3`, optionally after `priority`, `priority:`, `priority /` or `priority -`; no letter or digit may follow the digit (`P12`, `p2p` are no priority; `P1-urgent` is P1) */
|
|
8
|
+
const PRIORITY_LABEL = /^(?:priority\s*[:/-]?\s*)?p([0-3])(?![a-z0-9])/;
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* One priority value from a ticket's labels: `P0`..`P3`; `unsure` when two different ones are present, or when a label names a priority on another scale
|
package/src/try-checks.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// checks. A check that did not run (the done check halts before the others) is not listed. A hitl close has no mechanical check, so it adds none.
|
|
4
4
|
import { createHash } from 'node:crypto';
|
|
5
5
|
import { serializeArtifact } from './ask.js';
|
|
6
|
+
import { labelled } from './checkwords.js';
|
|
6
7
|
|
|
7
8
|
export const EVERY_STEP = 'every step';
|
|
8
9
|
|
|
@@ -44,6 +45,14 @@ export function outputRecord(step, artifact) {
|
|
|
44
45
|
* @param {any} step @param {any} artifact @param {{verdict: string, red?: string|null, checks?: Array<{text:string, ok:boolean, result:string|null}>}} closed
|
|
45
46
|
*/
|
|
46
47
|
export function closeRecords(step, artifact, closed) {
|
|
48
|
+
const rows = factRecords(step, artifact, closed);
|
|
49
|
+
// M10 am22 (1): the picks on a fact line are rows after the fact rows, each judged on the answer's text
|
|
50
|
+
const picks = Array.isArray(/** @type {any} */ (closed).pickChecks) ? /** @type {any} */ (closed).pickChecks : [];
|
|
51
|
+
return [...rows, ...picks.map((/** @type {any} */ c, i) => ({ n: rows.length + 3 + i, text: labelled(c.text, 'picked'), ok: c.ok, result: c.result, source: lineSource(step) }))];
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** @param {any} step @param {any} artifact @param {any} closed */
|
|
55
|
+
function factRecords(step, artifact, closed) {
|
|
47
56
|
const source = lineSource(step);
|
|
48
57
|
if (closed.verdict === 'unparseable' || closed.verdict === 'crash') {
|
|
49
58
|
return [{
|
|
@@ -53,13 +62,13 @@ export function closeRecords(step, artifact, closed) {
|
|
|
53
62
|
if (step?.close?.class === 'green' && Array.isArray(step?.close?.sheet) && Array.isArray(closed.checks)) {
|
|
54
63
|
// M10b piece 2: each signed sheet check is its own row, worded by `sheetCheckSentence`, judged by bareguard
|
|
55
64
|
return closed.checks.map((c, i) => ({
|
|
56
|
-
n: 3 + i, text: c.text, ok: c.ok, result: c.result, source,
|
|
65
|
+
n: 3 + i, text: labelled(c.text, 'agent'), ok: c.ok, result: c.result, source,
|
|
57
66
|
}));
|
|
58
67
|
}
|
|
59
68
|
if (step?.close?.class === 'green' && step?.close?.cited) {
|
|
60
69
|
const n = Array.isArray(artifact?.results) ? artifact.results.length : 0;
|
|
61
70
|
return [{
|
|
62
|
-
n: 3, text: 'every result is quoted from the saved copy and passes its rules', ok: closed.verdict === 'green', result: `${n} result${n === 1 ? '' : 's'}`, source,
|
|
71
|
+
n: 3, text: labelled('every result is quoted from the saved copy and passes its rules', 'agent'), ok: Array.isArray(/** @type {any} */ (closed).pickChecks) && closed.cited?.check ? closed.cited.check.verdict === 'green' : closed.verdict === 'green', result: `${n} result${n === 1 ? '' : 's'}`, source,
|
|
63
72
|
}];
|
|
64
73
|
}
|
|
65
74
|
if (step?.close?.class === 'green') {
|
|
@@ -68,7 +77,8 @@ export function closeRecords(step, artifact, closed) {
|
|
|
68
77
|
n: 3, text: 'every cited field matches its source', ok: closed.verdict === 'green', result: `${n} field${n === 1 ? '' : 's'}`, source,
|
|
69
78
|
}];
|
|
70
79
|
}
|
|
80
|
+
// M10 am22 (4): a softgreen check is the person's when it is one of their picks, the drafter's otherwise; the one-key row is code's own and carries no label
|
|
71
81
|
return (closed.checks ?? []).map((c, i) => ({
|
|
72
|
-
n: 3 + i, text: c.text, ok: c.ok, result: c.result, source,
|
|
82
|
+
n: 3 + i, text: /** @type {any} */ (c).id === 'keys' ? c.text : labelled(c.text, /^pick\d+$/.test(String(/** @type {any} */ (c).id)) ? 'picked' : 'agent'), ok: c.ok, result: c.result, source,
|
|
73
83
|
}));
|
|
74
84
|
}
|
package/src/whole-job.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// M13 am9: the file holds the whole job. ONE writer of the whole-job text (`wholeJobText`), ONE finder of the Ask that shows it (`wholeJobAskIndex`).
|
|
2
|
+
// The last Ask before the added `write it out` shows every step's result in job order, built by code from each step's saved output (never picked by the AI):
|
|
3
|
+
// a work step is one section `## Line <n>: <line words>` + `renderSentMd(<its saved output>)` (the M15 form, unchanged); an Ask before it is one line
|
|
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
|
+
// 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
|
+
import { renderSentMd } from './send.js';
|
|
7
|
+
import { addedLinesOf } from './added-end.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* The index of the Ask that shows the whole job: the Ask the added send reads, only when the plan has the am8 added `write it out`. A job signed before am8
|
|
11
|
+
* (its send line is the person's own words) finds -1 and keeps today's behaviour exactly.
|
|
12
|
+
* @param {{ steps: { fromLine: number, goal: string, emits?: string, reads?: string[] }[], askLines: Map<number, any>, sendLines: Map<number, any> }} p
|
|
13
|
+
* @returns {number} -1 = none
|
|
14
|
+
*/
|
|
15
|
+
export function wholeJobAskIndex({ steps, askLines, sendLines }) {
|
|
16
|
+
if (sendLines.size !== 1) return -1;
|
|
17
|
+
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
|
+
const sendStep = steps.find((s) => s.fromLine === send.line);
|
|
21
|
+
const askIds = (sendStep?.reads ?? []).filter((id) => steps.some((s) => s.emits === id && askLines.has(s.fromLine)));
|
|
22
|
+
if (askIds.length !== 1) return -1;
|
|
23
|
+
return steps.findIndex((s) => s.emits === askIds[0]);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* @param {{ steps: { fromLine: number, goal: string, emits?: string }[], askLines: Map<number, any>, lastAskIndex: number,
|
|
28
|
+
* readResult: (id: string) => ({ ok: true, value: any } | { ok: false, missing: true } | { ok: false, missing: false, red: string }) }} p
|
|
29
|
+
* @returns {{ ok: true, value: { text: string } } | { ok: false, red: string }}
|
|
30
|
+
*/
|
|
31
|
+
export function wholeJobText({ steps, askLines, lastAskIndex, readResult }) {
|
|
32
|
+
/** @type {string[]} */
|
|
33
|
+
const parts = [];
|
|
34
|
+
for (let i = 0; i < lastAskIndex; i += 1) {
|
|
35
|
+
const s = steps[i];
|
|
36
|
+
if (askLines.has(s.fromLine)) {
|
|
37
|
+
parts.push(`Line ${s.fromLine}: you accepted this at the Ask.`);
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
const r = readResult(/** @type {string} */ (s.emits));
|
|
41
|
+
if (!r.ok) {
|
|
42
|
+
return {
|
|
43
|
+
ok: false,
|
|
44
|
+
red: r.missing
|
|
45
|
+
? `ask: the saved output "${s.emits}" of step "${s.goal}" is missing — refusing to show the whole job`
|
|
46
|
+
: `ask: the saved output "${s.emits}" of step "${s.goal}" — ${r.red}`,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
parts.push(`## Line ${s.fromLine}: ${s.goal}\n${renderSentMd(r.value)}`);
|
|
50
|
+
}
|
|
51
|
+
return { ok: true, value: { text: parts.join('\n\n') } };
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* 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 a plan with the am8 added end; any other plan comes back as it was.
|
|
57
|
+
* @template {{ fromLine: number, goal: string, emits?: string, reads?: string[], primitives?: string[] }} S
|
|
58
|
+
* @param {S[]} steps @param {{ asks?: { line: number }[], sends?: { line: number }[] }} arbiter
|
|
59
|
+
* @returns {S[]}
|
|
60
|
+
*/
|
|
61
|
+
export function readEveryStep(steps, arbiter) {
|
|
62
|
+
if (!Array.isArray(steps) || !steps.every((s) => s && typeof s === 'object')) return steps;
|
|
63
|
+
const askLines = new Map((arbiter?.asks ?? []).map((a) => [a.line, a]));
|
|
64
|
+
const sendLines = new Map((arbiter?.sends ?? []).map((x) => [x.line, x]));
|
|
65
|
+
const idx = wholeJobAskIndex({ steps, askLines, sendLines });
|
|
66
|
+
if (idx < 1) return steps;
|
|
67
|
+
const work = steps.slice(0, idx).filter((s) => !askLines.has(s.fromLine) && typeof s.emits === 'string').map((s) => /** @type {string} */ (s.emits));
|
|
68
|
+
if (work.length === 0) return steps;
|
|
69
|
+
const reads = [work[work.length - 1], ...work.slice(0, -1)];
|
|
70
|
+
return steps.map((s, i) => (i === idx ? { ...s, reads } : s));
|
|
71
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {{ n: number, text: string, ask: null | { wait: string|null, question: string }, guardrails: string[] }[]} steps `parseJobBox` steps
|
|
3
|
+
* @param {string} destination the card's Destination ('' = none)
|
|
4
|
+
* @returns {{ steps: { n: number, text: string, ask: null | { wait: string|null, question: string }, guardrails: string[] }[], added: number[] }} the steps with the end added, and the numbers of the added lines
|
|
5
|
+
*/
|
|
6
|
+
export function addEnd(steps: {
|
|
7
|
+
n: number;
|
|
8
|
+
text: string;
|
|
9
|
+
ask: null | {
|
|
10
|
+
wait: string | null;
|
|
11
|
+
question: string;
|
|
12
|
+
};
|
|
13
|
+
guardrails: string[];
|
|
14
|
+
}[], destination: string): {
|
|
15
|
+
steps: {
|
|
16
|
+
n: number;
|
|
17
|
+
text: string;
|
|
18
|
+
ask: null | {
|
|
19
|
+
wait: string | null;
|
|
20
|
+
question: string;
|
|
21
|
+
};
|
|
22
|
+
guardrails: string[];
|
|
23
|
+
}[];
|
|
24
|
+
added: number[];
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* The added lines of a plan, found again from its signed lines and arbiter: the send line when it reads `write it out`, and the Ask just before it
|
|
28
|
+
* when that reads `check the result with me`. A job signed before M13 am8 (its send line is the person's own words) finds none.
|
|
29
|
+
* @param {{ n: number, text: string }[]} lines @param {{ sends?: { line: number }[], asks?: { line: number }[] }} arbiter
|
|
30
|
+
* @returns {Set<number>}
|
|
31
|
+
*/
|
|
32
|
+
export function addedLinesOf(lines: {
|
|
33
|
+
n: number;
|
|
34
|
+
text: string;
|
|
35
|
+
}[], arbiter: {
|
|
36
|
+
sends?: {
|
|
37
|
+
line: number;
|
|
38
|
+
}[];
|
|
39
|
+
asks?: {
|
|
40
|
+
line: number;
|
|
41
|
+
}[];
|
|
42
|
+
}): Set<number>;
|
|
43
|
+
/**
|
|
44
|
+
* The lines a person typed, found again from a signed job: the signed lines without the send line (the last line when it is the send; today's `write it out`, or
|
|
45
|
+
* the person's own words in a job signed before am8) and without an added Ask before it. ONE reader for the Edit card (`cardFromSigned`) and the job identity (`jobKeyOfSigned`).
|
|
46
|
+
* @template {{ n: number, text: string }} L
|
|
47
|
+
* @param {L[]} lines @param {{ sends?: { line: number }[], asks?: { line: number }[] }} arbiter
|
|
48
|
+
* @returns {L[]}
|
|
49
|
+
*/
|
|
50
|
+
export function typedLinesOf<L extends {
|
|
51
|
+
n: number;
|
|
52
|
+
text: string;
|
|
53
|
+
}>(lines: L[], arbiter: {
|
|
54
|
+
sends?: {
|
|
55
|
+
line: number;
|
|
56
|
+
}[];
|
|
57
|
+
asks?: {
|
|
58
|
+
line: number;
|
|
59
|
+
}[];
|
|
60
|
+
}): L[];
|
|
61
|
+
export const ADDED_ASK_QUESTION: "check the result with me";
|
|
62
|
+
export const ADDED_WRITE: "write it out";
|
package/types/checkpick.d.ts
CHANGED
|
@@ -62,6 +62,13 @@ export function rowsFromAnswer(scoped: {
|
|
|
62
62
|
check: Record<string, any> | null;
|
|
63
63
|
why: string | null;
|
|
64
64
|
}[];
|
|
65
|
+
/**
|
|
66
|
+
* The check CODE proposes for a count rule when the call yields none: a bullets / list-items / points count -> listItems N, a lines count -> maxLines N, ONE word number ->
|
|
67
|
+
* minWords N when the rule says "at least / minimum / more than", else maxWords N. A section count names no sections, so none is built; a rule naming two different counts is
|
|
68
|
+
* not built either; a rule with several word numbers or a range is not guessed. The result passes `keepOrDrop`, so every number is one the rule names.
|
|
69
|
+
* @param {string} text @returns {Record<string, any>|null}
|
|
70
|
+
*/
|
|
71
|
+
export function countCheck(text: string): Record<string, any> | null;
|
|
65
72
|
/**
|
|
66
73
|
* The asks for the rows: `Line n, guardrail "<…>": I propose <check in plain words>.` for a kept check, `Line n, guardrail "<…>": I can't check this. Your own words, or
|
|
67
74
|
* Not checked?` when nothing was kept. A proposal is not counted toward am1's cap; a can't-check ask is (am16 (5)).
|
|
@@ -112,10 +119,37 @@ export function applyPicks(declaration: any, rules: ReturnType<typeof scopedRule
|
|
|
112
119
|
line: number;
|
|
113
120
|
reason: "person-left" | "own-words" | "no-pick";
|
|
114
121
|
}) => string): any;
|
|
122
|
+
/**
|
|
123
|
+
* M10 am27 (4) RETENTION record of one draft (record only, counts, no words). Per job line: `aiParts` = the cited facts the drafter wrote on that line (a `cited` close counts once per
|
|
124
|
+
* fact, at least 1), `kept` = how many are still in the final declaration, `dropped` = what code removed, `picks` = the line has the person's picks; `classAsked` / `classFinal`
|
|
125
|
+
* = the line's close class as the drafter sent it and as it ended. Pure.
|
|
126
|
+
* @param {any} drafted the declaration as the drafter sent it @param {any} final the declaration the draft ended with @param {any[]|null|undefined} jobLines @param {Iterable<number>} [pickLines]
|
|
127
|
+
* @returns {{line: number, aiParts: number, kept: number, dropped: number, picks: boolean, classAsked: string|null, classFinal: string|null}[]}
|
|
128
|
+
*/
|
|
129
|
+
export function retentionOf(drafted: any, final: any, jobLines: any[] | null | undefined, pickLines?: Iterable<number>): {
|
|
130
|
+
line: number;
|
|
131
|
+
aiParts: number;
|
|
132
|
+
kept: number;
|
|
133
|
+
dropped: number;
|
|
134
|
+
picks: boolean;
|
|
135
|
+
classAsked: string | null;
|
|
136
|
+
classFinal: string | null;
|
|
137
|
+
}[];
|
|
115
138
|
/** the one tool the suggestion call is forced to use */
|
|
116
139
|
export const SUGGEST_TOOL: "suggest_checks";
|
|
117
140
|
export function hasRoutingInput(sources: any[] | undefined): boolean;
|
|
118
141
|
export function codeScope(sources: any[] | undefined, g: string): "in" | "out";
|
|
142
|
+
export function offerRules(lines: {
|
|
143
|
+
n: number;
|
|
144
|
+
guardrail?: string;
|
|
145
|
+
}[], arbiter: any, facts: {
|
|
146
|
+
line: number;
|
|
147
|
+
forRule?: number;
|
|
148
|
+
}[]): {
|
|
149
|
+
line: number;
|
|
150
|
+
rule: number;
|
|
151
|
+
text: string;
|
|
152
|
+
}[];
|
|
119
153
|
export const SUGGEST_SYSTEM: string;
|
|
120
154
|
/** the forced tool's parameter schema: one `anyOf` variant per offered rule, plus `none` */
|
|
121
155
|
export const SUGGEST_SCHEMA: Readonly<{
|
package/types/checkwords.d.ts
CHANGED
|
@@ -12,3 +12,7 @@ export function plainWords(c: {
|
|
|
12
12
|
}): string;
|
|
13
13
|
/** the rules of bareguard's list a person may pick here (text rules only: the ones a plain answer can be judged by) */
|
|
14
14
|
export const OFFERED: readonly string[];
|
|
15
|
+
/** M10 am22 (4): who added a check, the ONE place these two words live. The plan card, the Job tab and the Audit trail write them after the check's words. */
|
|
16
|
+
export const LABEL_AGENT: "[agent]";
|
|
17
|
+
export const LABEL_PICKED: "[you picked]";
|
|
18
|
+
export function labelled(text: string, by: "agent" | "picked"): string;
|
package/types/citedcheck.d.ts
CHANGED
|
@@ -57,6 +57,12 @@ export function citedBrief(part: any): {
|
|
|
57
57
|
eachResultHolds: string[];
|
|
58
58
|
howMany: string | null;
|
|
59
59
|
};
|
|
60
|
+
/**
|
|
61
|
+
* M10 am28: what a page-quoting step is told about the picks (am22) on its line, one plain line per pick, the values and what counts, never a verdict and never
|
|
62
|
+
* another guardrail. A list item is what bareguard's listItems counts: its own line starting with "1." or "- " followed by a space and its text.
|
|
63
|
+
* @param {any[]} picked @returns {string[]}
|
|
64
|
+
*/
|
|
65
|
+
export function toldPicks(picked: any[]): string[];
|
|
60
66
|
/**
|
|
61
67
|
* Every plan-card row a fact part carries: its facts, then its count (bareloop's factRows).
|
|
62
68
|
* @param {any} part @returns {string[]}
|
package/types/closers.d.ts
CHANGED
|
@@ -71,7 +71,7 @@ export function renderSoftgreenGaps(gaps: any[], shape: {
|
|
|
71
71
|
* Async because bareguard's `checkStep` is.
|
|
72
72
|
*
|
|
73
73
|
* @param {any} artifact
|
|
74
|
-
* @param {{ maxWords?: number, sections?: string[], wordsPerSection?: number, linesPerInvoice?: number, mustCarry?: string[] }} shape
|
|
74
|
+
* @param {{ maxWords?: number, sections?: string[], wordsPerSection?: number, linesPerInvoice?: number, mustCarry?: string[], picked?: any[] }} shape
|
|
75
75
|
* @returns {Promise<CloseVerdict>}
|
|
76
76
|
*/
|
|
77
77
|
export function closeSoftgreen(artifact: any, shape: {
|
|
@@ -80,11 +80,12 @@ export function closeSoftgreen(artifact: any, shape: {
|
|
|
80
80
|
wordsPerSection?: number;
|
|
81
81
|
linesPerInvoice?: number;
|
|
82
82
|
mustCarry?: string[];
|
|
83
|
+
picked?: any[];
|
|
83
84
|
}): Promise<CloseVerdict>;
|
|
84
85
|
/**
|
|
85
86
|
* The one dispatcher — `close by declared class` (M2 scope item 4).
|
|
86
87
|
*
|
|
87
|
-
* @param {{ close?: { class?: string, shape?: Record<string, any>, cited?: any, columns?: {source: string, column: string}[], sheet?: any[] } }} step
|
|
88
|
+
* @param {{ close?: { class?: string, shape?: Record<string, any>, picked?: any[], cited?: any, columns?: {source: string, column: string}[], sheet?: any[] } }} step
|
|
88
89
|
* @param {unknown} artifact
|
|
89
90
|
* @param {{ reads: Record<string, any>, businessDate: string, source?: {ok: true, text: string, sha256: string}|{ok: false, red: string}|null, sheet?: any }} ctx
|
|
90
91
|
* `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
|
|
@@ -95,6 +96,7 @@ export function closeByClass(step: {
|
|
|
95
96
|
close?: {
|
|
96
97
|
class?: string;
|
|
97
98
|
shape?: Record<string, any>;
|
|
99
|
+
picked?: any[];
|
|
98
100
|
cited?: any;
|
|
99
101
|
columns?: {
|
|
100
102
|
source: string;
|
package/types/declaration.d.ts
CHANGED
|
@@ -42,6 +42,8 @@ export function checkSendLineGuardrail(lines: any[], arbiter: {
|
|
|
42
42
|
export function guardrailWordsPerSection(guardrail: any): number | null;
|
|
43
43
|
/** M4e amendment 7 item 1: the first "<N> sections" in a guardrail (N digits, or the words one..ten), or null. */
|
|
44
44
|
export function guardrailSectionCount(guardrail: any): any;
|
|
45
|
+
/** M10 amendment 23: the first "<N> bullets / list items / items / lines / points" in a guardrail (N digits, or the words one..ten; not a price like "$5 per item"), or null. */
|
|
46
|
+
export function guardrailItemCount(guardrail: any): any;
|
|
45
47
|
/** M4e amendment 15 item 2: for each line whose guardrail gives a size for each section, a section count AND a word number,
|
|
46
48
|
* size x count more than the LARGEST word number (no possible pick fits) is a red naming the line and the numbers. $0; run before any model
|
|
47
49
|
* call, when there is no AI pick yet (amendment 29). After the draft the AI's `maxWords` is checked in checkShapeFitsJobLine. */
|
|
@@ -111,6 +113,7 @@ export const FLOW_TYPES: readonly string[];
|
|
|
111
113
|
export const SHAPE_KEYS: readonly string[];
|
|
112
114
|
/** Shape keys only the MACHINE sets (M4e amendment 15): read from the line's guardrail, never offered to the drafter's model. */
|
|
113
115
|
export const MACHINE_SHAPE_KEYS: readonly string[];
|
|
116
|
+
export function isCountGuardrail(guardrail: any): boolean;
|
|
114
117
|
export type Arbiter = import("./types.js").Arbiter;
|
|
115
118
|
export type SignedLine = import("./types.js").SignedLine;
|
|
116
119
|
export type CatalogueEntry = import("./types.js").CatalogueEntry;
|
package/types/drafter.d.ts
CHANGED
|
@@ -967,6 +967,22 @@ export function normalizeQuestions(raw: any, failedLines: any): {
|
|
|
967
967
|
kept: any[];
|
|
968
968
|
dropped: any[];
|
|
969
969
|
};
|
|
970
|
+
/**
|
|
971
|
+
* The job lines as the page look may see them (no count rule), and `toOriginal`, which takes a look fact's / dropped entry's visible rule number back to the guardrail's own number.
|
|
972
|
+
* @param {{n: number, text: string, rule?: string}[]} jobLines
|
|
973
|
+
*/
|
|
974
|
+
export function hideCounts(jobLines: {
|
|
975
|
+
n: number;
|
|
976
|
+
text: string;
|
|
977
|
+
rule?: string;
|
|
978
|
+
}[]): {
|
|
979
|
+
seenLines: {
|
|
980
|
+
rule?: string | undefined;
|
|
981
|
+
n: number;
|
|
982
|
+
text: string;
|
|
983
|
+
}[];
|
|
984
|
+
toOriginal: (f: any) => any;
|
|
985
|
+
};
|
|
970
986
|
export function buildSystemPrompt({ menu, lines, arbiter, factsInfo }: {
|
|
971
987
|
menu: any;
|
|
972
988
|
lines: any;
|
package/types/model-step.d.ts
CHANGED
|
@@ -15,8 +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
|
-
/** @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<{
|
|
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) @param {boolean} [withText] M10 am22: a fact step with the person's picks also answers in `text` (the picks read it) */
|
|
19
|
+
export function buildEmitArtifactSchema(stepClass: string | null | undefined, cited?: boolean, sheet?: any[] | null, withText?: boolean): Readonly<{
|
|
20
20
|
type: "object";
|
|
21
21
|
properties: {
|
|
22
22
|
done: {
|
|
@@ -93,6 +93,19 @@ export function buildEmitArtifactSchema(stepClass: string | null | undefined, ci
|
|
|
93
93
|
type: string[];
|
|
94
94
|
description: string;
|
|
95
95
|
};
|
|
96
|
+
text: {
|
|
97
|
+
type: string;
|
|
98
|
+
};
|
|
99
|
+
} | {
|
|
100
|
+
done: {
|
|
101
|
+
type: string;
|
|
102
|
+
description: string;
|
|
103
|
+
};
|
|
104
|
+
blocker: {
|
|
105
|
+
type: string[];
|
|
106
|
+
description: string;
|
|
107
|
+
};
|
|
108
|
+
text?: undefined;
|
|
96
109
|
};
|
|
97
110
|
required: string[];
|
|
98
111
|
additionalProperties: boolean;
|
|
@@ -106,7 +119,7 @@ export function buildEmitArtifactSchema(stepClass: string | null | undefined, ci
|
|
|
106
119
|
* @param {{in:number,out:number}} [opts.rates]
|
|
107
120
|
* @param {string} [opts.modelId]
|
|
108
121
|
* @param {Record<string,string|undefined>} [opts.env] - the merged shell+keys-file env the key is read from (default process.env).
|
|
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
|
+
* @returns {(executorContext:object, grantedTools:Record<string,any>, stepMeta?:{class?:string, attempt?:number, step?:string|null, cited?:any, sheet?:any[]|null, withText?:boolean, picked?:any[]|null, thinkingMode?:'on'|'off'}, seam?:{stopRequested?:() => boolean}) => Promise<any>}
|
|
110
123
|
*/
|
|
111
124
|
export function makeLiveModelStep({ slot, model, spendPath, provider: injectedProvider, rates: injectedRates, modelId: injectedModelId, env, }: {
|
|
112
125
|
slot?: string | undefined;
|
|
@@ -125,6 +138,8 @@ export function makeLiveModelStep({ slot, model, spendPath, provider: injectedPr
|
|
|
125
138
|
step?: string | null;
|
|
126
139
|
cited?: any;
|
|
127
140
|
sheet?: any[] | null;
|
|
141
|
+
withText?: boolean;
|
|
142
|
+
picked?: any[] | null;
|
|
128
143
|
thinkingMode?: "on" | "off";
|
|
129
144
|
}, seam?: {
|
|
130
145
|
stopRequested?: () => boolean;
|
package/types/panel/data.d.ts
CHANGED
|
@@ -756,7 +756,7 @@ export function getJobGrid({ root, flow, catalogue, now, }: {
|
|
|
756
756
|
name: string;
|
|
757
757
|
title: string | null;
|
|
758
758
|
number: number | null;
|
|
759
|
-
bucket: "
|
|
759
|
+
bucket: "wait" | "done" | "skip" | "stop";
|
|
760
760
|
glyph: string;
|
|
761
761
|
at: number;
|
|
762
762
|
ex: "r" | "n" | "g" | "q";
|
package/types/panel/jobgrid.d.ts
CHANGED
|
@@ -69,7 +69,7 @@ export function buildJobGrid({ runs, anyway, now }: {
|
|
|
69
69
|
name: string;
|
|
70
70
|
title: string | null;
|
|
71
71
|
number: number | null;
|
|
72
|
-
bucket: "
|
|
72
|
+
bucket: "wait" | "done" | "skip" | "stop";
|
|
73
73
|
glyph: string;
|
|
74
74
|
at: number;
|
|
75
75
|
ex: "r" | "n" | "g" | "q";
|
package/types/plain-checks.d.ts
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* M4d amendment 38 item 1: the ONE decision of which red is explained: the first red a `first` rule matches, else the first red (am15 item 3).
|
|
3
|
+
* @param {ReadonlyArray<string>} reds
|
|
4
|
+
* @returns {string|undefined}
|
|
5
|
+
*/
|
|
6
|
+
export function pickPlanRed(reds: ReadonlyArray<string>): string | undefined;
|
|
1
7
|
/**
|
|
2
8
|
* @param {unknown} raw one raw refusal text
|
|
3
9
|
* @returns {{ say: string, reason: string, fix: string, raw: string }}
|
|
@@ -8,15 +14,17 @@ export function plainPlanCheck(raw: unknown): {
|
|
|
8
14
|
fix: string;
|
|
9
15
|
raw: string;
|
|
10
16
|
};
|
|
11
|
-
/** @type {ReadonlyArray<{re: RegExp, say: string|null, fix: string}>} `say` null = the checker's own sentence, as it is without its "declaration: " prefix */
|
|
17
|
+
/** @type {ReadonlyArray<{re: RegExp, say: string|null, fix: string, first?: boolean}>} `say` null = the checker's own sentence, as it is without its "declaration: " prefix */
|
|
12
18
|
export const PLAN_CHECK_RULES: ReadonlyArray<{
|
|
13
19
|
re: RegExp;
|
|
14
20
|
say: string | null;
|
|
15
21
|
fix: string;
|
|
22
|
+
first?: boolean;
|
|
16
23
|
}>;
|
|
17
24
|
export const GENERIC_SAY: "One of the checks on the plan failed.";
|
|
18
25
|
export const GENERIC_FIX: "Draft again.";
|
|
19
26
|
export function pageRules(): {
|
|
27
|
+
first?: boolean | undefined;
|
|
20
28
|
re: string;
|
|
21
29
|
say: string | null;
|
|
22
30
|
}[];
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {any} declaration the drafter's declaration (not changed) @param {{sources?: {role?: string, kind?: string}[]}} arbiter
|
|
3
|
+
* @returns {{declaration: any, repaired: string[]}}
|
|
4
|
+
*/
|
|
5
|
+
export function repairDeclaration(declaration: any, arbiter: {
|
|
6
|
+
sources?: {
|
|
7
|
+
role?: string;
|
|
8
|
+
kind?: string;
|
|
9
|
+
}[];
|
|
10
|
+
}): {
|
|
11
|
+
declaration: any;
|
|
12
|
+
repaired: string[];
|
|
13
|
+
};
|
package/types/try-checks.d.ts
CHANGED
|
@@ -42,13 +42,7 @@ export function closeRecords(step: any, artifact: any, closed: {
|
|
|
42
42
|
ok: boolean;
|
|
43
43
|
result: string | null;
|
|
44
44
|
}>;
|
|
45
|
-
}):
|
|
46
|
-
n: number;
|
|
47
|
-
text: string;
|
|
48
|
-
ok: boolean;
|
|
49
|
-
result: string | null;
|
|
50
|
-
source: string;
|
|
51
|
-
}[];
|
|
45
|
+
}): any[];
|
|
52
46
|
export const EVERY_STEP: "every step";
|
|
53
47
|
export function lineSource(step: {
|
|
54
48
|
fromLine?: unknown;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The index of the Ask that shows the whole job: the Ask the added send reads, only when the plan has the am8 added `write it out`. A job signed before am8
|
|
3
|
+
* (its send line is the person's own words) finds -1 and keeps today's behaviour exactly.
|
|
4
|
+
* @param {{ steps: { fromLine: number, goal: string, emits?: string, reads?: string[] }[], askLines: Map<number, any>, sendLines: Map<number, any> }} p
|
|
5
|
+
* @returns {number} -1 = none
|
|
6
|
+
*/
|
|
7
|
+
export function wholeJobAskIndex({ steps, askLines, sendLines }: {
|
|
8
|
+
steps: {
|
|
9
|
+
fromLine: number;
|
|
10
|
+
goal: string;
|
|
11
|
+
emits?: string;
|
|
12
|
+
reads?: string[];
|
|
13
|
+
}[];
|
|
14
|
+
askLines: Map<number, any>;
|
|
15
|
+
sendLines: Map<number, any>;
|
|
16
|
+
}): number;
|
|
17
|
+
/**
|
|
18
|
+
* @param {{ steps: { fromLine: number, goal: string, emits?: string }[], askLines: Map<number, any>, lastAskIndex: number,
|
|
19
|
+
* readResult: (id: string) => ({ ok: true, value: any } | { ok: false, missing: true } | { ok: false, missing: false, red: string }) }} p
|
|
20
|
+
* @returns {{ ok: true, value: { text: string } } | { ok: false, red: string }}
|
|
21
|
+
*/
|
|
22
|
+
export function wholeJobText({ steps, askLines, lastAskIndex, readResult }: {
|
|
23
|
+
steps: {
|
|
24
|
+
fromLine: number;
|
|
25
|
+
goal: string;
|
|
26
|
+
emits?: string;
|
|
27
|
+
}[];
|
|
28
|
+
askLines: Map<number, any>;
|
|
29
|
+
lastAskIndex: number;
|
|
30
|
+
readResult: (id: string) => ({
|
|
31
|
+
ok: true;
|
|
32
|
+
value: any;
|
|
33
|
+
} | {
|
|
34
|
+
ok: false;
|
|
35
|
+
missing: true;
|
|
36
|
+
} | {
|
|
37
|
+
ok: false;
|
|
38
|
+
missing: false;
|
|
39
|
+
red: string;
|
|
40
|
+
});
|
|
41
|
+
}): {
|
|
42
|
+
ok: true;
|
|
43
|
+
value: {
|
|
44
|
+
text: string;
|
|
45
|
+
};
|
|
46
|
+
} | {
|
|
47
|
+
ok: false;
|
|
48
|
+
red: string;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* 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
|
|
52
|
+
* redo still re-runs the step just before the Ask; the rest in job order). Only a plan with the am8 added end; any other plan comes back as it was.
|
|
53
|
+
* @template {{ fromLine: number, goal: string, emits?: string, reads?: string[], primitives?: string[] }} S
|
|
54
|
+
* @param {S[]} steps @param {{ asks?: { line: number }[], sends?: { line: number }[] }} arbiter
|
|
55
|
+
* @returns {S[]}
|
|
56
|
+
*/
|
|
57
|
+
export function readEveryStep<S extends {
|
|
58
|
+
fromLine: number;
|
|
59
|
+
goal: string;
|
|
60
|
+
emits?: string;
|
|
61
|
+
reads?: string[];
|
|
62
|
+
primitives?: string[];
|
|
63
|
+
}>(steps: S[], arbiter: {
|
|
64
|
+
asks?: {
|
|
65
|
+
line: number;
|
|
66
|
+
}[];
|
|
67
|
+
sends?: {
|
|
68
|
+
line: number;
|
|
69
|
+
}[];
|
|
70
|
+
}): S[];
|