fwdloop 0.13.0 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/fwdloop +25 -12
- package/package.json +2 -2
- package/src/authoring.js +73 -39
- package/src/canrun.js +71 -1
- package/src/catalogue.json +2 -2
- package/src/checked.js +54 -0
- package/src/closers.js +112 -91
- package/src/declaration.js +115 -11
- package/src/drafter.js +139 -39
- package/src/flow.js +220 -5
- package/src/keysfile.js +4 -2
- package/src/model-step.js +1 -1
- package/src/monthly.js +139 -17
- package/src/panel/author.js +226 -64
- package/src/panel/authorcard.js +99 -4
- package/src/panel/authorflows.js +51 -10
- package/src/panel/authorresume.js +2 -2
- package/src/panel/authorstart.js +18 -10
- package/src/panel/data.js +147 -81
- package/src/panel/index.html +497 -338
- package/src/panel/server.js +5 -2
- package/src/panel/settings.js +1 -1
- package/src/runner.js +105 -48
- package/src/setup.js +21 -14
- package/src/signed-diff.js +71 -0
- package/types/authoring.d.ts +52 -14
- package/types/canrun.d.ts +33 -1
- package/types/checked.d.ts +25 -0
- package/types/closers.d.ts +47 -28
- package/types/declaration.d.ts +16 -2
- package/types/drafter.d.ts +146 -11
- package/types/flow.d.ts +42 -2
- package/types/model-step.d.ts +1 -6
- package/types/monthly.d.ts +25 -1
- package/types/panel/author.d.ts +55 -40
- package/types/panel/authorcard.d.ts +54 -0
- package/types/panel/authorflows.d.ts +39 -0
- package/types/panel/authorstart.d.ts +1 -0
- package/types/panel/data.d.ts +11 -56
- package/types/runner.d.ts +11 -3
- package/types/setup.d.ts +6 -12
- package/types/signed-diff.d.ts +10 -0
package/types/canrun.d.ts
CHANGED
|
@@ -19,14 +19,46 @@ export function unwiredRed(found: {
|
|
|
19
19
|
};
|
|
20
20
|
verb: string;
|
|
21
21
|
}): string;
|
|
22
|
+
/**
|
|
23
|
+
* M4e amendment 23: the ONE function that turns "this step's check cannot be built" into a plain sentence. It reads the shape, never
|
|
24
|
+
* bareguard's wording, so no `spec.` path or `checks[` index can reach a human. The steps are numbered by the job line they came from
|
|
25
|
+
* ("line 3" elsewhere), so "step 3" is job line 3. What it throws away: the raw reason (kept apart as `detail`) and any second problem
|
|
26
|
+
* in the same shape (the first one found is the one said). A shape it cannot classify gets the generic sentence.
|
|
27
|
+
* @param {number|undefined} n the step's job line
|
|
28
|
+
* @param {Record<string, any>} shape
|
|
29
|
+
* @returns {string}
|
|
30
|
+
*/
|
|
31
|
+
export function unbuildableSay(n: number | undefined, shape: Record<string, any>): string;
|
|
32
|
+
/**
|
|
33
|
+
* M4e amendment 19 4: the first softgreen step whose check bareguard cannot build (a flow signed before amendment 18 may hold one), or null.
|
|
34
|
+
* Built with the same `buildSoftgreenRubric` the close uses, so a step that passes here never crashes at its close for want of a check.
|
|
35
|
+
* `why` is bareguard's raw reason, for the record only (amendment 23); `say` is the plain sentence.
|
|
36
|
+
* @param {Record<string, any>} declaration `readFlow`'s declaration
|
|
37
|
+
* @returns {{step: {emits: string, fromLine: number}, why: string, say: string}|null}
|
|
38
|
+
*/
|
|
39
|
+
export function findUnbuildableCheckStep(declaration: Record<string, any>): {
|
|
40
|
+
step: {
|
|
41
|
+
emits: string;
|
|
42
|
+
fromLine: number;
|
|
43
|
+
};
|
|
44
|
+
why: string;
|
|
45
|
+
say: string;
|
|
46
|
+
} | null;
|
|
47
|
+
/** The preflight refusal sentence for a check that cannot be built: plain words, never bareguard's (that is `found.why`). @param {{say: string}} found */
|
|
48
|
+
export function unbuildableRed(found: {
|
|
49
|
+
say: string;
|
|
50
|
+
}): string;
|
|
22
51
|
/**
|
|
23
52
|
* Can this flow run? `read` is `readFlow`'s result (a failed read — signature, tampering, missing files — is a refusal with its own reds).
|
|
24
53
|
* @param {any} read
|
|
25
|
-
* @returns {{ok: true} | {ok: false, red: string}}
|
|
54
|
+
* @returns {{ok: true} | {ok: false, red: string, detail?: string}} `detail` is the raw reason, for the record, never the sentence
|
|
26
55
|
*/
|
|
27
56
|
export function canFlowRun(read: any): {
|
|
28
57
|
ok: true;
|
|
29
58
|
} | {
|
|
30
59
|
ok: false;
|
|
31
60
|
red: string;
|
|
61
|
+
detail?: string;
|
|
32
62
|
};
|
|
63
|
+
/** The one sentence for a signed flow that will not run: the panel's run door (the POST /api/author/run 409) and Run again say the same words. The Signed list no longer shows a refused flow. @param {string} flow @param {string} red */
|
|
64
|
+
export function willNotRunSay(flow: string, red: string): string;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One entry per step, in plan order: the plain sentences for what its typed close checks.
|
|
3
|
+
* @param {{ steps?: any[] }} declaration @param {{ hasAsk?: boolean, askLines?: number[] }} [opts] hasAsk = the job has a signed ask line (so "you check it at the ask" is true);
|
|
4
|
+
* 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[] }[]}
|
|
6
|
+
*/
|
|
7
|
+
export function checkedLines(declaration: {
|
|
8
|
+
steps?: any[];
|
|
9
|
+
}, { hasAsk, askLines }?: {
|
|
10
|
+
hasAsk?: boolean;
|
|
11
|
+
askLines?: number[];
|
|
12
|
+
}): {
|
|
13
|
+
step: number;
|
|
14
|
+
line: number | null;
|
|
15
|
+
goal: string;
|
|
16
|
+
class: string;
|
|
17
|
+
sentences: string[];
|
|
18
|
+
}[];
|
|
19
|
+
/** 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
|
+
export function notCheckedBlock(items: unknown): {
|
|
21
|
+
label: string;
|
|
22
|
+
items: any[];
|
|
23
|
+
};
|
|
24
|
+
/** 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). */
|
|
25
|
+
export const NOT_CHECKED_LABEL: "not checked (the AI's own reading)";
|
package/types/closers.d.ts
CHANGED
|
@@ -11,52 +11,70 @@ export function closeGreen(artifact: any, ctx: {
|
|
|
11
11
|
businessDate: string;
|
|
12
12
|
}): CloseVerdict;
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
14
|
+
* M4e amendment 18: the soft checks run on bareguard 0.21.0. `softgreenSpec(shape)` is the ONE place a declared shape
|
|
15
|
+
* becomes a rubric spec (signing and the run both build through `buildSoftgreenRubric`, so a shape that signs is a shape
|
|
16
|
+
* that builds). The checks are in this fixed order, which is the order their sentences read in:
|
|
17
|
+
* allowedKeys, maxWords, sectionOrder, sectionWords, blockLines.
|
|
18
|
+
* A key that is declared at all gets its check built, so a half-declared shape (wordsPerSection with no sections, one of
|
|
19
|
+
* linesPerInvoice/mustCarry) cannot build and is a crash at run time, never silently skipped.
|
|
17
20
|
*
|
|
18
|
-
* @param {
|
|
19
|
-
* @param {{ maxWords: number, sections: string[] }} declared
|
|
20
|
-
* @returns {CloseVerdict}
|
|
21
|
+
* @param {Record<string, any>} shape
|
|
21
22
|
*/
|
|
22
|
-
export function
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
export function softgreenSpec(shape: Record<string, any>): {
|
|
24
|
+
schema: number;
|
|
25
|
+
goal: string;
|
|
26
|
+
checkpoints: {
|
|
27
|
+
close: {
|
|
28
|
+
gating: boolean;
|
|
29
|
+
checks: Record<string, any>[];
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
/** Throws bareguard's `invalid rubric: ...` for a shape it cannot build. @param {Record<string, any>} shape @returns {ReturnType<typeof createRubric>} */
|
|
34
|
+
export function buildSoftgreenRubric(shape: Record<string, any>): ReturnType<typeof createRubric>;
|
|
26
35
|
/**
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
36
|
+
* The ONE render function (amendment 18 item 4A): bareguard's typed gaps in, fwdloop's plain-English sentences out, byte for byte
|
|
37
|
+
* what the hand-written checks said before the switch (test/m4e-am18-parity.test.js proves it on 142 inputs); past bareguard's own
|
|
38
|
+
* offender-list bound the "N more" tail is ours (amendment 19 2), derived from each gap's `itemsTotal` and list length, never a number.
|
|
39
|
+
* What it throws away: bareguard bounds every offender list; past that the sentence says how many more there were.
|
|
40
|
+
* A gap it has no sentence for is still a red, worded generically, never dropped.
|
|
41
|
+
*
|
|
42
|
+
* @param {any[]} gaps
|
|
43
|
+
* @param {{ linesPerInvoice?: number, mustCarry?: string[] }} shape
|
|
44
|
+
* @returns {{ red: string, reds: string[] }}
|
|
32
45
|
*/
|
|
33
|
-
export function
|
|
34
|
-
linesPerInvoice
|
|
35
|
-
mustCarry
|
|
36
|
-
}):
|
|
46
|
+
export function renderSoftgreenGaps(gaps: any[], shape: {
|
|
47
|
+
linesPerInvoice?: number;
|
|
48
|
+
mustCarry?: string[];
|
|
49
|
+
}): {
|
|
50
|
+
red: string;
|
|
51
|
+
reds: string[];
|
|
52
|
+
};
|
|
37
53
|
/**
|
|
38
|
-
* `softgreen` close:
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
54
|
+
* `softgreen` close: the declared shape (`maxWords`, `sections`, `wordsPerSection`, `linesPerInvoice` + `mustCarry`, and the
|
|
55
|
+
* one-key rule) is checked by bareguard's rubric (amendment 18 item 1) and every failing check is reported, one sentence each
|
|
56
|
+
* (F38's rule, never widened to first-red-only). Our front door stays: an answer that is not `{text: string}` is `unparseable`
|
|
57
|
+
* before bareguard sees it. A shape that cannot be built, or a check that stopped, is `crash`: never green.
|
|
58
|
+
* Async because bareguard's `checkStep` is.
|
|
42
59
|
*
|
|
43
60
|
* @param {any} artifact
|
|
44
|
-
* @param {{ maxWords?: number, sections?: string[], linesPerInvoice?: number, mustCarry?: string[] }} shape
|
|
45
|
-
* @returns {CloseVerdict}
|
|
61
|
+
* @param {{ maxWords?: number, sections?: string[], wordsPerSection?: number, linesPerInvoice?: number, mustCarry?: string[] }} shape
|
|
62
|
+
* @returns {Promise<CloseVerdict>}
|
|
46
63
|
*/
|
|
47
64
|
export function closeSoftgreen(artifact: any, shape: {
|
|
48
65
|
maxWords?: number;
|
|
49
66
|
sections?: string[];
|
|
67
|
+
wordsPerSection?: number;
|
|
50
68
|
linesPerInvoice?: number;
|
|
51
69
|
mustCarry?: string[];
|
|
52
|
-
}): CloseVerdict
|
|
70
|
+
}): Promise<CloseVerdict>;
|
|
53
71
|
/**
|
|
54
72
|
* The one dispatcher — `close by declared class` (M2 scope item 4).
|
|
55
73
|
*
|
|
56
74
|
* @param {{ close?: { class?: string, shape?: Record<string, any> } }} step
|
|
57
75
|
* @param {unknown} artifact
|
|
58
76
|
* @param {{ reads: Record<string, any>, businessDate: string }} ctx
|
|
59
|
-
* @returns {CloseVerdict}
|
|
77
|
+
* @returns {Promise<CloseVerdict>}
|
|
60
78
|
*/
|
|
61
79
|
export function closeByClass(step: {
|
|
62
80
|
close?: {
|
|
@@ -66,5 +84,6 @@ export function closeByClass(step: {
|
|
|
66
84
|
}, artifact: unknown, ctx: {
|
|
67
85
|
reads: Record<string, any>;
|
|
68
86
|
businessDate: string;
|
|
69
|
-
}): CloseVerdict
|
|
87
|
+
}): Promise<CloseVerdict>;
|
|
70
88
|
export type CloseVerdict = import("./types.js").CloseVerdict;
|
|
89
|
+
import { createRubric } from 'bareguard';
|
package/types/declaration.d.ts
CHANGED
|
@@ -19,9 +19,21 @@ export function checkShapes(declaration: any): {
|
|
|
19
19
|
reds: any[];
|
|
20
20
|
shapedSteps: number;
|
|
21
21
|
};
|
|
22
|
+
/** Every whole-output word number in a guardrail ("3 sections, under 600 words, each heading at most 3 words" -> [600, 3]), in order; [] when
|
|
23
|
+
* there is none. Code does not decide which one is the limit: the AI picks `maxWords` and the validator checks the pick is one of these
|
|
24
|
+
* (M4e amendments 28 + 29). A "<n> words each" / "<n> words per section" is the per-section size (amendment 15), never listed here. */
|
|
25
|
+
export function guardrailWordNumbers(guardrail: any): number[];
|
|
26
|
+
/** M4e amendment 15 item 1: the "<n> words each" / "<n> words per section" size in a guardrail ("about 250 words each", "250ish each" -> 250), or null. */
|
|
27
|
+
export function guardrailWordsPerSection(guardrail: any): number | null;
|
|
28
|
+
/** M4e amendment 7 item 1: the first "<N> sections" in a guardrail (N digits, or the words one..ten), or null. */
|
|
29
|
+
export function guardrailSectionCount(guardrail: any): any;
|
|
30
|
+
/** M4e amendment 15 item 2: for each line whose guardrail gives a size for each section, a section count AND a word number,
|
|
31
|
+
* 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
|
|
32
|
+
* call, when there is no AI pick yet (amendment 29). After the draft the AI's `maxWords` is checked in checkShapeFitsJobLine. */
|
|
33
|
+
export function checkGuardrailSums(lines: any): string[];
|
|
22
34
|
/** M4e amendment 6 item 1 (+ amendment 7 item 1): a step's check cannot fight its own job line. Sections must be found in the line's words
|
|
23
|
-
* (case-insensitive substring of the goal, first occurrence) and in the line's order; `maxWords`
|
|
24
|
-
*
|
|
35
|
+
* (case-insensitive substring of the goal, first occurrence) and in the line's order; `maxWords` (the AI's pick, amendment 29) must be one
|
|
36
|
+
* of the line's guardrail word numbers when that guardrail has any. A shape key a note may still change (mustCarry, linesPerInvoice)
|
|
25
37
|
* is untouched. Pushes reds naming the step and both orders/values. */
|
|
26
38
|
export function checkShapeFitsJobLine(step: any, i: any, lines: any, reds: any): void;
|
|
27
39
|
/**
|
|
@@ -61,6 +73,8 @@ export const DECLARATION_FIELDS: readonly string[];
|
|
|
61
73
|
* exactly these four top-level keys. Anything else inside `shape` reds by
|
|
62
74
|
* name. */
|
|
63
75
|
export const SHAPE_KEYS: readonly string[];
|
|
76
|
+
/** Shape keys only the MACHINE sets (M4e amendment 15): read from the line's guardrail, never offered to the drafter's model. */
|
|
77
|
+
export const MACHINE_SHAPE_KEYS: readonly string[];
|
|
64
78
|
export type Arbiter = import("./types.js").Arbiter;
|
|
65
79
|
export type SignedLine = import("./types.js").SignedLine;
|
|
66
80
|
export type CatalogueEntry = import("./types.js").CatalogueEntry;
|
package/types/drafter.d.ts
CHANGED
|
@@ -102,6 +102,133 @@ export function buildDeclarationSchema(menu: any): {
|
|
|
102
102
|
required: string[];
|
|
103
103
|
additionalProperties: boolean;
|
|
104
104
|
};
|
|
105
|
+
/** The declaration schema plus the optional `notChecked` (every try) and, on try 3 only, `questions`. Neither is in `required`. */
|
|
106
|
+
export function buildRoundSchema(menu: any, { questions }?: {
|
|
107
|
+
questions?: boolean | undefined;
|
|
108
|
+
}): {
|
|
109
|
+
properties: {
|
|
110
|
+
notChecked: {
|
|
111
|
+
type: string;
|
|
112
|
+
items: {
|
|
113
|
+
type: string;
|
|
114
|
+
};
|
|
115
|
+
description: string;
|
|
116
|
+
};
|
|
117
|
+
steps: {
|
|
118
|
+
type: string;
|
|
119
|
+
minItems: number;
|
|
120
|
+
items: {
|
|
121
|
+
type: string;
|
|
122
|
+
properties: {
|
|
123
|
+
primitives: {
|
|
124
|
+
type: string;
|
|
125
|
+
items: {
|
|
126
|
+
type: string;
|
|
127
|
+
enum: any;
|
|
128
|
+
};
|
|
129
|
+
description: string;
|
|
130
|
+
};
|
|
131
|
+
reads: {
|
|
132
|
+
type: string;
|
|
133
|
+
items: {
|
|
134
|
+
type: string;
|
|
135
|
+
};
|
|
136
|
+
description: string;
|
|
137
|
+
};
|
|
138
|
+
emits: {
|
|
139
|
+
type: string;
|
|
140
|
+
minLength: number;
|
|
141
|
+
description: string;
|
|
142
|
+
};
|
|
143
|
+
fromLine: {
|
|
144
|
+
type: string[];
|
|
145
|
+
description: string;
|
|
146
|
+
};
|
|
147
|
+
picks: {
|
|
148
|
+
type: string;
|
|
149
|
+
additionalProperties: {
|
|
150
|
+
type: string;
|
|
151
|
+
items: {
|
|
152
|
+
type: string;
|
|
153
|
+
};
|
|
154
|
+
};
|
|
155
|
+
description: string;
|
|
156
|
+
};
|
|
157
|
+
close: {
|
|
158
|
+
type: string;
|
|
159
|
+
properties: {
|
|
160
|
+
class: {
|
|
161
|
+
type: string;
|
|
162
|
+
enum: string[];
|
|
163
|
+
description: string;
|
|
164
|
+
};
|
|
165
|
+
shape: {
|
|
166
|
+
type: string;
|
|
167
|
+
properties: {};
|
|
168
|
+
additionalProperties: boolean;
|
|
169
|
+
description: string;
|
|
170
|
+
};
|
|
171
|
+
};
|
|
172
|
+
required: string[];
|
|
173
|
+
additionalProperties: boolean;
|
|
174
|
+
};
|
|
175
|
+
};
|
|
176
|
+
required: string[];
|
|
177
|
+
additionalProperties: boolean;
|
|
178
|
+
};
|
|
179
|
+
};
|
|
180
|
+
guardrailClasses: {
|
|
181
|
+
type: string;
|
|
182
|
+
additionalProperties: {
|
|
183
|
+
type: string;
|
|
184
|
+
enum: string[];
|
|
185
|
+
};
|
|
186
|
+
description: string;
|
|
187
|
+
};
|
|
188
|
+
unjudgeable: {
|
|
189
|
+
type: string;
|
|
190
|
+
additionalProperties: {
|
|
191
|
+
type: string;
|
|
192
|
+
};
|
|
193
|
+
description: string;
|
|
194
|
+
};
|
|
195
|
+
refused: {
|
|
196
|
+
type: string;
|
|
197
|
+
items: {
|
|
198
|
+
type: string;
|
|
199
|
+
properties: {
|
|
200
|
+
line: {
|
|
201
|
+
type: string;
|
|
202
|
+
};
|
|
203
|
+
reason: {
|
|
204
|
+
type: string;
|
|
205
|
+
minLength: number;
|
|
206
|
+
};
|
|
207
|
+
};
|
|
208
|
+
required: string[];
|
|
209
|
+
additionalProperties: boolean;
|
|
210
|
+
};
|
|
211
|
+
description: string;
|
|
212
|
+
};
|
|
213
|
+
};
|
|
214
|
+
type: string;
|
|
215
|
+
required: string[];
|
|
216
|
+
additionalProperties: boolean;
|
|
217
|
+
};
|
|
218
|
+
/**
|
|
219
|
+
* Which job lines did these reds name? Reds name a line three ways: "line N" (also "ask at line N", "(line N)",
|
|
220
|
+
* "guardrailClasses key \"N\""), "steps[i]" (mapped through that declaration's steps[i].fromLine), and "step N's check"
|
|
221
|
+
* (1-based). A red naming none (a missing top-level key, an unknown key) names no line. Returns sorted real line numbers.
|
|
222
|
+
*/
|
|
223
|
+
export function linesNamedByReds(reds: any, declaration: any, lineNums: any): any[];
|
|
224
|
+
/**
|
|
225
|
+
* Amendment 25: a question is kept only if its line is one try 2's reds named; no line, a blank question or a third question is
|
|
226
|
+
* dropped. Every drop comes back with its reason, for the draft's log. Returns {kept, dropped}.
|
|
227
|
+
*/
|
|
228
|
+
export function normalizeQuestions(raw: any, failedLines: any): {
|
|
229
|
+
kept: any[];
|
|
230
|
+
dropped: any[];
|
|
231
|
+
};
|
|
105
232
|
export function buildSystemPrompt({ menu, lines, arbiter, factsInfo }: {
|
|
106
233
|
menu: any;
|
|
107
234
|
lines: any;
|
|
@@ -114,12 +241,6 @@ export function buildSystemPrompt({ menu, lines, arbiter, factsInfo }: {
|
|
|
114
241
|
* lines do not exist in the grammar. A step naming no signed line gets a fixed placeholder, never model prose.
|
|
115
242
|
*/
|
|
116
243
|
export function goalForLine(fromLine: any, lines: any): any;
|
|
117
|
-
/**
|
|
118
|
-
* M4e amendment 3 item 3 (revise the plan): the first round's user text when the human asked for a change. The model sees the
|
|
119
|
-
* current plan (its own fields only: no machine-set `goal`, no `inputFacts`) and the note; the rules above still hold, and the
|
|
120
|
-
* validator below is the ONE check that refuses a plan that touches what only the card may set.
|
|
121
|
-
*/
|
|
122
|
-
export function reviseOpening(plan: any, note: any): string;
|
|
123
244
|
/**
|
|
124
245
|
* Draft one declaration. `provider`/`rates`/`modelId` may be injected (tests,
|
|
125
246
|
* the batch); otherwise a live provider is built from `slot` (throws on a bad
|
|
@@ -129,13 +250,12 @@ export function reviseOpening(plan: any, note: any): string;
|
|
|
129
250
|
* `calls`) and right AFTER it (`inFlight: false`), with what is known so far, so the caller can book spend per call
|
|
130
251
|
* and a draft killed between rounds still has its paid rounds on disk. It may throw before a call (nothing is
|
|
131
252
|
* spent then and the draft stops); after a call it is the caller's to keep from throwing.
|
|
132
|
-
* `revise` (M4e amendment 3 item 3): `{ plan, note }` — the current green plan and the human's note; the first round then asks for the
|
|
133
|
-
* revised plan. Everything else (the $0 gates, the validator, the budget, the metering) is the same code path as a first draft.
|
|
134
253
|
*
|
|
135
254
|
* @returns {Promise<{ok:boolean, declaration:object|null, reds:string[], rounds:number, calls:number, spendComplete:boolean,
|
|
136
|
-
* costUsd:number|null, modelReturned:string|null, modelId?:string, price?:object|null, tokens?:object|null, structureRetries:number, revisions:number, stop:string|null, log:object[]
|
|
255
|
+
* costUsd:number|null, modelReturned:string|null, modelId?:string, price?:object|null, tokens?:object|null, structureRetries:number, revisions:number, stop:string|null, log:object[],
|
|
256
|
+
* questions?:{line:number, question:string}[], droppedQuestions?:object[], notChecked?:string[]}>}
|
|
137
257
|
*/
|
|
138
|
-
export function draft({ proseText, slot, model, provider: injected, rates: injectedRates, modelId: injectedModelId, env, budgetUsd, skills, makeProviderFn, onBook,
|
|
258
|
+
export function draft({ proseText, slot, model, provider: injected, rates: injectedRates, modelId: injectedModelId, env, budgetUsd, skills, makeProviderFn, onBook, offerQuestions, }: {
|
|
139
259
|
proseText: any;
|
|
140
260
|
slot?: string | undefined;
|
|
141
261
|
model: any;
|
|
@@ -147,7 +267,7 @@ export function draft({ proseText, slot, model, provider: injected, rates: injec
|
|
|
147
267
|
skills?: readonly string[] | undefined;
|
|
148
268
|
makeProviderFn?: typeof makeProvider | undefined;
|
|
149
269
|
onBook: any;
|
|
150
|
-
|
|
270
|
+
offerQuestions?: boolean | undefined;
|
|
151
271
|
}): Promise<{
|
|
152
272
|
ok: boolean;
|
|
153
273
|
declaration: object | null;
|
|
@@ -164,12 +284,27 @@ export function draft({ proseText, slot, model, provider: injected, rates: injec
|
|
|
164
284
|
revisions: number;
|
|
165
285
|
stop: string | null;
|
|
166
286
|
log: object[];
|
|
287
|
+
questions?: {
|
|
288
|
+
line: number;
|
|
289
|
+
question: string;
|
|
290
|
+
}[];
|
|
291
|
+
droppedQuestions?: object[];
|
|
292
|
+
notChecked?: string[];
|
|
167
293
|
}>;
|
|
168
294
|
export const MAX_STRUCTURE_RETRIES: 2;
|
|
169
295
|
export const MAX_REVISIONS: 2;
|
|
170
296
|
export const DRAFT_MAX_TOKENS: 16000;
|
|
171
297
|
export const DRAFT_SKILLS: readonly string[];
|
|
172
298
|
export const CLASSES: readonly string[];
|
|
299
|
+
/** The whole-output-ceiling rule, told once to the drafter (schema and prompt use this string). Amendment 29; no number words (am25). */
|
|
300
|
+
export const WHOLE_OUTPUT_CEILING_RULE: "use the guardrail's ceiling for the whole output";
|
|
301
|
+
export const MAX_QUESTIONS: 2;
|
|
302
|
+
/** What fwdloop's typed checks can really check (bareloop F174: give the model the real list, or "Not checked" is invented). */
|
|
303
|
+
export const CHECKABLE: readonly string[];
|
|
304
|
+
/** Offered on EVERY try (it is information, not asking). */
|
|
305
|
+
export const NOTCHECKED_PROMPT: string;
|
|
306
|
+
/** Try 3 only, and only after tries 1 and 2 both failed validation. No digit and no number word anywhere (a test greps this): the machine, not the prompt, bounds the count. */
|
|
307
|
+
export const QUESTIONS_PROMPT: string;
|
|
173
308
|
export const DRAFT_PROVIDER_OPTIONS: Readonly<{
|
|
174
309
|
thinking: Readonly<{
|
|
175
310
|
type: "disabled";
|
package/types/flow.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/** The plain "what changed" sentences inside a readFlow refusal (am43), joined for a sentence a human reads; '' when there are none. @param {string[]} reds */
|
|
2
|
+
export function changeSentence(reds: string[]): string;
|
|
1
3
|
/**
|
|
2
4
|
* Check a flow name against the allowed shape: 1..64 characters, lowercase
|
|
3
5
|
* a-z, 0-9, `-`, `_`, starting with a letter or digit. Walked character by
|
|
@@ -174,10 +176,13 @@ export function readdirInside(baseDir: string, relDir: string): string[];
|
|
|
174
176
|
* last (each via a temp file + rename in the same directory), creates an
|
|
175
177
|
* empty `runs/`, and proves the result by reading it back with `readFlow`.
|
|
176
178
|
*
|
|
177
|
-
*
|
|
179
|
+
* M6: with `replaces: {flowHash}` it instead REPLACES the signed job already under that name (see `replaceSigned`), and only if that job is
|
|
180
|
+
* still the one with that signature hash. `onReplaceStep` is a test seam: called after each move of the swap; a throw there is a failure.
|
|
181
|
+
*
|
|
182
|
+
* @param {{root: unknown, name: unknown, proseText: unknown, declaration: unknown, signedBy: unknown, signedAt: unknown, catalogue: unknown, replaces?: {flowHash: string}, onReplaceStep?: (step: string) => void}} input
|
|
178
183
|
* @returns {WriteFlowResult}
|
|
179
184
|
*/
|
|
180
|
-
export function writeFlow({ root, name, proseText, declaration, signedBy, signedAt, catalogue, }: {
|
|
185
|
+
export function writeFlow({ root, name, proseText, declaration, signedBy, signedAt, catalogue, replaces, onReplaceStep, }: {
|
|
181
186
|
root: unknown;
|
|
182
187
|
name: unknown;
|
|
183
188
|
proseText: unknown;
|
|
@@ -185,7 +190,17 @@ export function writeFlow({ root, name, proseText, declaration, signedBy, signed
|
|
|
185
190
|
signedBy: unknown;
|
|
186
191
|
signedAt: unknown;
|
|
187
192
|
catalogue: unknown;
|
|
193
|
+
replaces?: {
|
|
194
|
+
flowHash: string;
|
|
195
|
+
};
|
|
196
|
+
onReplaceStep?: (step: string) => void;
|
|
188
197
|
}): WriteFlowResult;
|
|
198
|
+
/**
|
|
199
|
+
* The signature hash (`signature.json` `flow`) of the signed job in `flowDir`, or null when there is no readable one. It does NOT verify the
|
|
200
|
+
* files (that is `readFlow`): it only says which signing this folder is at, for M6's "was this job signed again since you opened it".
|
|
201
|
+
* @param {string} flowDir @returns {string|null}
|
|
202
|
+
*/
|
|
203
|
+
export function signedHashOf(flowDir: string): string | null;
|
|
189
204
|
/**
|
|
190
205
|
* Read and verify a signed flow from `<root>/<name>/`. Verifies the bytes on
|
|
191
206
|
* disk against the signature FIRST — before anything in the flow is
|
|
@@ -200,6 +215,31 @@ export function readFlow({ root, name, catalogue }: {
|
|
|
200
215
|
name: unknown;
|
|
201
216
|
catalogue: unknown;
|
|
202
217
|
}): ReadFlowResult;
|
|
218
|
+
/**
|
|
219
|
+
* M6 ("Each run saves a copy of the job it ran when it starts"): the ONE writer of `<runDir>/job/`. Reads the flow's three files, proves them against
|
|
220
|
+
* the flow's own signature first (a flow that does not verify is never copied), then writes them write-once (`wx`). `{ok:false, red}` writes nothing
|
|
221
|
+
* it did not finish (a half-written copy is removed). Never throws.
|
|
222
|
+
* @param {string} flowDir @param {string} runDir @param {string} [expectedFlowHash] the `signature.flow` the caller read; a different job on disk is refused
|
|
223
|
+
* @returns {{ok: true} | {ok: false, red: string}}
|
|
224
|
+
*/
|
|
225
|
+
export function writeRunJobCopy(flowDir: string, runDir: string, expectedFlowHash?: string): {
|
|
226
|
+
ok: true;
|
|
227
|
+
} | {
|
|
228
|
+
ok: false;
|
|
229
|
+
red: string;
|
|
230
|
+
};
|
|
231
|
+
/**
|
|
232
|
+
* M6: the job a run ran, from its own copy. `{present:false}` = the run has none (it started before M6). `{present:true, ok:true, ...}` = the same
|
|
233
|
+
* shape as a good `readFlow` (lines, arbiter, declaration, signature, classes), after the copy was verified against the copied signature.
|
|
234
|
+
* `{present:true, ok:false, reds}` = a copy that was edited or is incomplete: refused, never shown as the job.
|
|
235
|
+
* @param {string} runDir @param {unknown} catalogue
|
|
236
|
+
* @returns {{present: false} | ({present: true} & ReadFlowResult)}
|
|
237
|
+
*/
|
|
238
|
+
export function readRunJobCopy(runDir: string, catalogue: unknown): {
|
|
239
|
+
present: false;
|
|
240
|
+
} | ({
|
|
241
|
+
present: true;
|
|
242
|
+
} & ReadFlowResult);
|
|
203
243
|
/** @typedef {import('./types.js').WriteFlowResult} WriteFlowResult */
|
|
204
244
|
/** @typedef {import('./types.js').ReadFlowResult} ReadFlowResult */
|
|
205
245
|
/** @typedef {import('./types.js').CheckFlowNameResult} CheckFlowNameResult */
|
package/types/model-step.d.ts
CHANGED
|
@@ -54,14 +54,9 @@ export function buildEmitArtifactSchema(stepClass: any): Readonly<{
|
|
|
54
54
|
text: {
|
|
55
55
|
type: string;
|
|
56
56
|
};
|
|
57
|
-
lines: {
|
|
58
|
-
type: string;
|
|
59
|
-
items: {
|
|
60
|
-
type: string;
|
|
61
|
-
};
|
|
62
|
-
};
|
|
63
57
|
};
|
|
64
58
|
required: string[];
|
|
59
|
+
additionalProperties: false;
|
|
65
60
|
}> | Readonly<{
|
|
66
61
|
type: "object";
|
|
67
62
|
properties: {
|
package/types/monthly.d.ts
CHANGED
|
@@ -4,11 +4,13 @@ export function realpathLoose(p: string): string;
|
|
|
4
4
|
export function readRuns(home?: string): any[];
|
|
5
5
|
/**
|
|
6
6
|
* The Money tab's figures (piece 4 reads this) and the check's month total.
|
|
7
|
-
*
|
|
7
|
+
* `rows` (a caller that has just read the record, like the claim) saves a second parse of the same file.
|
|
8
|
+
* @param {{ home?: string, now?: () => number, rows?: any[] }} [opts]
|
|
8
9
|
*/
|
|
9
10
|
export function spendSummary(opts?: {
|
|
10
11
|
home?: string;
|
|
11
12
|
now?: () => number;
|
|
13
|
+
rows?: any[];
|
|
12
14
|
}): {
|
|
13
15
|
month: {
|
|
14
16
|
modelMinutes: number | null;
|
|
@@ -89,6 +91,28 @@ export function claimHold({ what, flow, runId, runDir, holdUsd, spentAtHold, hom
|
|
|
89
91
|
home?: string;
|
|
90
92
|
now?: () => number;
|
|
91
93
|
}): Claim;
|
|
94
|
+
/**
|
|
95
|
+
* Amendment 16 C2: a hold's process starts spending into one more run dir (a rerun's new run): name it NOW, so a process killed hard
|
|
96
|
+
* still has that dir's spend counted. Append-only; `namedDirs` dedupes, so the settle note naming it again never counts it twice.
|
|
97
|
+
* Never throws (a failed note is closed by the settle note's `alsoRunDirs` on a normal exit).
|
|
98
|
+
* @param {{ holdId: string|null, runDir: string, home?: string, now?: () => number }} a
|
|
99
|
+
*/
|
|
100
|
+
export function nameRunDir({ holdId, runDir, home, now, }: {
|
|
101
|
+
holdId: string | null;
|
|
102
|
+
runDir: string;
|
|
103
|
+
home?: string;
|
|
104
|
+
now?: () => number;
|
|
105
|
+
}): void;
|
|
106
|
+
/**
|
|
107
|
+
* I1 (amendment 16): fold the spend of every run/draft dir whose holds have ALL ended (settled, released or refused) into `rolled`
|
|
108
|
+
* rows, so the next month figure or Money load reads one record instead of one file per run. Append-only; a dir already rolled and not
|
|
109
|
+
* named since is left alone. Reads the dirs it folds exactly as `spendSummary` would, so no total changes. Never throws.
|
|
110
|
+
* @param {{ home?: string, now?: () => number }} [a]
|
|
111
|
+
*/
|
|
112
|
+
export function rollSettled({ home, now }?: {
|
|
113
|
+
home?: string;
|
|
114
|
+
now?: () => number;
|
|
115
|
+
}): void;
|
|
92
116
|
/**
|
|
93
117
|
* The run's own process ends or parks: give the hold back. Never throws (a failed settle is closed by the
|
|
94
118
|
* next check as "process gone"). `alsoRunDirs` names dirs this process also spent into (a rerun's new run).
|