bareloop 0.40.0 → 0.42.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/CHANGELOG.md +96 -1
- package/README.md +13 -21
- package/bareloop.context.md +141 -128
- package/package.json +5 -4
- package/src/authorflow.js +346 -38
- package/src/authoring.js +92 -7
- package/src/authorjob.js +82 -20
- package/src/authorreadout.js +89 -5
- package/src/authorrun.js +39 -30
- package/src/authorscout.js +112 -4
- package/src/bundle.js +7 -4
- package/src/bundlerun.js +4 -1
- package/src/cli.js +1 -1
- package/src/config.js +129 -29
- package/src/declaredclose.js +23 -12
- package/src/draftspend.js +4 -4
- package/src/facts.js +317 -0
- package/src/factwords.js +129 -0
- package/src/index.js +2 -4
- package/src/inputlook.js +301 -0
- package/src/interviewrun.js +17 -25
- package/src/job.js +15 -8
- package/src/jobblock.js +7 -2
- package/src/judged.js +11 -43
- package/src/keysfile.js +15 -7
- package/src/kinds.js +86 -5
- package/src/labelscan.js +170 -0
- package/src/modellist.js +84 -0
- package/src/monthly.js +23 -43
- package/src/pagefetch.js +125 -0
- package/src/panel/authorroutes.js +34 -16
- package/src/panel/authorsession.js +161 -80
- package/src/panel/index.html +553 -152
- package/src/panel/jobplan.js +34 -11
- package/src/panel/runroutes.js +3 -0
- package/src/panel/server.js +54 -18
- package/src/panel/settingsroutes.js +232 -173
- package/src/planrun.js +5 -4
- package/src/providerrows.js +226 -141
- package/src/providers.js +58 -332
- package/src/providershapes.js +18 -0
- package/src/replay.js +1 -1
- package/src/rubricstep.js +804 -0
- package/src/source.js +166 -1
- package/src/thinking.js +130 -0
- package/src/u-readout.js +1 -1
- package/src/userrun.js +64 -75
- package/types/authorflow.d.ts +272 -18
- package/types/authoring.d.ts +29 -1
- package/types/authorjob.d.ts +9 -7
- package/types/authorreadout.d.ts +27 -2
- package/types/authorscout.d.ts +72 -2
- package/types/config.d.ts +23 -6
- package/types/declaredclose.d.ts +4 -2
- package/types/draftspend.d.ts +8 -8
- package/types/facts.d.ts +71 -0
- package/types/factwords.d.ts +42 -0
- package/types/index.d.ts +1 -1
- package/types/inputlook.d.ts +238 -0
- package/types/job.d.ts +5 -5
- package/types/jobblock.d.ts +8 -1
- package/types/judged.d.ts +5 -36
- package/types/keysfile.d.ts +15 -4
- package/types/labelscan.d.ts +38 -0
- package/types/modellist.d.ts +50 -0
- package/types/monthly.d.ts +4 -3
- package/types/pagefetch.d.ts +71 -0
- package/types/panel/authorsession.d.ts +20 -11
- package/types/panel/jobplan.d.ts +12 -4
- package/types/panel/server.d.ts +18 -6
- package/types/providerrows.d.ts +192 -99
- package/types/providers.d.ts +34 -159
- package/types/providershapes.d.ts +10 -0
- package/types/rubricstep.d.ts +286 -0
- package/types/source.d.ts +94 -0
- package/types/thinking.d.ts +90 -0
- package/types/userrun.d.ts +17 -1
package/types/authorscout.d.ts
CHANGED
|
@@ -92,7 +92,7 @@ export function defaultSurveyor({ workdir, granted, auditPath, ctx }: {
|
|
|
92
92
|
* @param {{workdir: string, provider?: any,
|
|
93
93
|
* rounds?: number, minBytes?: number, blobMax?: number, maxTokens?: number, ctx?: boolean,
|
|
94
94
|
* attempts?: number, ceilingUsd?: number|null, callTimeoutMs?: number,
|
|
95
|
-
* onCall?: (call: {label: string, costUsd: number|null, unpricedRounds: number,
|
|
95
|
+
* onCall?: (call: {label: string, costUsd: number|null, unpricedRounds: number, thinkingStatus?: string}) => void,
|
|
96
96
|
* createLoop?: (o: {system: string, policy: any, onLlmResult: any, provider: any, rates?: {in: number, out: number}}) => any,
|
|
97
97
|
* rates?: {in: number, out: number}|null, callOptions?: Record<string, any>,
|
|
98
98
|
* createSurveyor?: (o: {workdir: string, granted: readonly string[], ctx: boolean}) => Promise<any>}} o
|
|
@@ -115,7 +115,7 @@ export function runAuthorScout({ workdir, provider, rounds, minBytes, blobMax, m
|
|
|
115
115
|
label: string;
|
|
116
116
|
costUsd: number | null;
|
|
117
117
|
unpricedRounds: number;
|
|
118
|
-
|
|
118
|
+
thinkingStatus?: string;
|
|
119
119
|
}) => void;
|
|
120
120
|
createLoop?: (o: {
|
|
121
121
|
system: string;
|
|
@@ -147,6 +147,72 @@ export function runAuthorScout({ workdir, provider, rounds, minBytes, blobMax, m
|
|
|
147
147
|
}[];
|
|
148
148
|
budgetStop: "cap-halt" | "pricing-red" | null;
|
|
149
149
|
}>;
|
|
150
|
+
/**
|
|
151
|
+
* Run the look. `createLoop` is the same seam the repo scout has; nothing else here needs a live process.
|
|
152
|
+
* @param {{texts: Record<string, string>, inputs: {n: number, label: string}[], jobLines: {n: number, text: string, rule?: string, rules?: string[]}[],
|
|
153
|
+
* provider?: any, rounds?: number, maxTokens?: number, ceilingUsd?: number|null, callTimeoutMs?: number,
|
|
154
|
+
* onCall?: (call: {label: string, costUsd: number|null, unpricedRounds: number, thinkingStatus?: string}) => void,
|
|
155
|
+
* createLoop?: (o: {system: string, policy: any, onLlmResult: any, provider: any, rates?: {in: number, out: number}}) => any,
|
|
156
|
+
* rates?: {in: number, out: number}|null, callOptions?: Record<string, any>,
|
|
157
|
+
* prove?: (source: string, phrase: string) => number}} o
|
|
158
|
+
* @returns {Promise<{state: 'PRESENT'|'ABSENT', facts: any, reason: string|null, cause: string|null, meta: any, raw: string,
|
|
159
|
+
* raws: ReturnType<typeof scrubRaw>[], calls: {label: string, costUsd: number|null, unpricedRounds: number}[],
|
|
160
|
+
* budgetStop: 'cap-halt'|'pricing-red'|null}>}
|
|
161
|
+
*/
|
|
162
|
+
export function runInputLook({ texts, inputs, jobLines, provider, rounds, maxTokens, ceilingUsd, callTimeoutMs, onCall, createLoop, rates, callOptions, prove, }: {
|
|
163
|
+
texts: Record<string, string>;
|
|
164
|
+
inputs: {
|
|
165
|
+
n: number;
|
|
166
|
+
label: string;
|
|
167
|
+
}[];
|
|
168
|
+
jobLines: {
|
|
169
|
+
n: number;
|
|
170
|
+
text: string;
|
|
171
|
+
rule?: string;
|
|
172
|
+
rules?: string[];
|
|
173
|
+
}[];
|
|
174
|
+
provider?: any;
|
|
175
|
+
rounds?: number;
|
|
176
|
+
maxTokens?: number;
|
|
177
|
+
ceilingUsd?: number | null;
|
|
178
|
+
callTimeoutMs?: number;
|
|
179
|
+
onCall?: (call: {
|
|
180
|
+
label: string;
|
|
181
|
+
costUsd: number | null;
|
|
182
|
+
unpricedRounds: number;
|
|
183
|
+
thinkingStatus?: string;
|
|
184
|
+
}) => void;
|
|
185
|
+
createLoop?: (o: {
|
|
186
|
+
system: string;
|
|
187
|
+
policy: any;
|
|
188
|
+
onLlmResult: any;
|
|
189
|
+
provider: any;
|
|
190
|
+
rates?: {
|
|
191
|
+
in: number;
|
|
192
|
+
out: number;
|
|
193
|
+
};
|
|
194
|
+
}) => any;
|
|
195
|
+
rates?: {
|
|
196
|
+
in: number;
|
|
197
|
+
out: number;
|
|
198
|
+
} | null;
|
|
199
|
+
callOptions?: Record<string, any>;
|
|
200
|
+
prove?: (source: string, phrase: string) => number;
|
|
201
|
+
}): Promise<{
|
|
202
|
+
state: "PRESENT" | "ABSENT";
|
|
203
|
+
facts: any;
|
|
204
|
+
reason: string | null;
|
|
205
|
+
cause: string | null;
|
|
206
|
+
meta: any;
|
|
207
|
+
raw: string;
|
|
208
|
+
raws: ReturnType<typeof scrubRaw>[];
|
|
209
|
+
calls: {
|
|
210
|
+
label: string;
|
|
211
|
+
costUsd: number | null;
|
|
212
|
+
unpricedRounds: number;
|
|
213
|
+
}[];
|
|
214
|
+
budgetStop: "cap-halt" | "pricing-red" | null;
|
|
215
|
+
}>;
|
|
150
216
|
/**
|
|
151
217
|
* `git ls-tree -r --name-only <seed>` — the files as of the SEED COMMIT.
|
|
152
218
|
* Deliberately NOT `ls-files`, which reads the index and the working tree: this
|
|
@@ -336,6 +402,10 @@ export const SCOUT_SYSTEM: string;
|
|
|
336
402
|
* produce) — never by asking politely in prose (F19/F37).
|
|
337
403
|
*/
|
|
338
404
|
export const SCOUT_RECOVERY_PROMPT: string;
|
|
405
|
+
/** the look's hard round bound */
|
|
406
|
+
export const LOOK_ROUNDS: 8;
|
|
407
|
+
export const LOOK_SYSTEM: string;
|
|
408
|
+
export const LOOK_RECOVERY_PROMPT: "You are out of looking turns. Report NOW, from what you have already read: call the report tool once with everything you can check and everything you could not find.";
|
|
339
409
|
/** per-path full-listing cap; over it, names give way to counted directories */
|
|
340
410
|
export const LIST_CAP: 40;
|
|
341
411
|
/** whole-block ceiling — the block is a prompt ingredient, like the survey */
|
package/types/config.d.ts
CHANGED
|
@@ -16,15 +16,31 @@ export function configPath(home?: string): string;
|
|
|
16
16
|
export function readConfig(opts?: {
|
|
17
17
|
home?: string;
|
|
18
18
|
}): ConfigRead;
|
|
19
|
+
/**
|
|
20
|
+
* One key-row field's value problem in plain words, or null when fine.
|
|
21
|
+
* @param {string} field `model` | `shape` | `baseUrl` | `legacyMaxTokens`
|
|
22
|
+
* @param {unknown} v
|
|
23
|
+
* @returns {string|null}
|
|
24
|
+
*/
|
|
25
|
+
export function providerFieldProblem(field: string, v: unknown): string | null;
|
|
26
|
+
/**
|
|
27
|
+
* THE one rule for a row's model lines, used by config validation and the Settings routes. A price
|
|
28
|
+
* is a PAIR (`inPerM` and `outPerM`, each a finite number >= 0 — 0 / 0 typed is a chosen price) or
|
|
29
|
+
* neither (null / absent). A ticked line (`use`) needs both. Plain words, or null.
|
|
30
|
+
* @param {unknown} list
|
|
31
|
+
* @returns {string|null}
|
|
32
|
+
*/
|
|
33
|
+
export function modelsProblem(list: unknown): string | null;
|
|
19
34
|
/**
|
|
20
35
|
* Apply a patch and write. `null` deletes a field. Top-level fields shallow-merge;
|
|
21
|
-
* `keys` merges per key variable name, then per field
|
|
22
|
-
* written; nothing is written on a refusal.
|
|
36
|
+
* `keys` merges per key variable name, then per field; `models.<ENV>` is REPLACED WHOLE (`null`
|
|
37
|
+
* clears it). Validated before anything is written; nothing is written on a refusal.
|
|
23
38
|
*
|
|
24
|
-
* Patch fields understood: `monthlyLimitUsd` (finite > 0), `
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
39
|
+
* Patch fields understood: `monthlyLimitUsd` (finite > 0), `keys.<ENV>.{shape,baseUrl,legacyMaxTokens}`,
|
|
40
|
+
* `models.<ENV>` (a list judged by {@link modelsProblem}). The first write of a row's `models` list
|
|
41
|
+
* removes that row's older `name` / `priceInPerM` / `priceOutPerM` in the SAME write (never two
|
|
42
|
+
* sources); a retired top-level `anthropicBalanceNote` is dropped on any write. Any other field is
|
|
43
|
+
* kept, but the whole document is swept for secret-shaped strings first.
|
|
28
44
|
* @param {Record<string, any>} patch
|
|
29
45
|
* @param {{ home?: string }} [opts]
|
|
30
46
|
* @returns {Record<string, any>} the document as written
|
|
@@ -35,6 +51,7 @@ export function updateConfig(patch: Record<string, any>, opts?: {
|
|
|
35
51
|
/** A plain-words config failure (bad value, secret-shaped string, unreadable file). */
|
|
36
52
|
export class ConfigError extends Error {
|
|
37
53
|
}
|
|
54
|
+
export function cleanBaseUrl(v: string): string;
|
|
38
55
|
export type ConfigRead = {
|
|
39
56
|
/**
|
|
40
57
|
* the parsed document ({} when missing/unreadable)
|
package/types/declaredclose.d.ts
CHANGED
|
@@ -53,7 +53,8 @@ export function declaredStages(closeDecl: any): any[] | null;
|
|
|
53
53
|
*
|
|
54
54
|
* @param {any} closeDecl
|
|
55
55
|
* @param {{at?: string, listing?: string[]|null, deferListing?: boolean,
|
|
56
|
-
* catalogue?: Record<string, any>, verdictType?: string|null, writeScope?: string[]|null, jobLines?: {n: number}[]|null
|
|
56
|
+
* catalogue?: Record<string, any>, verdictType?: string|null, writeScope?: string[]|null, jobLines?: {n: number}[]|null,
|
|
57
|
+
* inputLabels?: string[]|null}} [opts]
|
|
57
58
|
* @returns {{ok: boolean, reds: Red[], closeDecl: any, grounded: boolean,
|
|
58
59
|
* scoped: {scoped: boolean, via: string|null},
|
|
59
60
|
* ceiling: {class: string, kind: string, stage: string|null, locked: boolean}|null}}
|
|
@@ -68,6 +69,7 @@ export function validateCloseDecl(closeDecl: any, opts?: {
|
|
|
68
69
|
jobLines?: {
|
|
69
70
|
n: number;
|
|
70
71
|
}[] | null;
|
|
72
|
+
inputLabels?: string[] | null;
|
|
71
73
|
}): {
|
|
72
74
|
ok: boolean;
|
|
73
75
|
reds: Red[];
|
|
@@ -162,7 +164,7 @@ export function closeGrade(v: any): {
|
|
|
162
164
|
/** @typedef {{code: string, path: string, detail: string, [k: string]: any}} Red */
|
|
163
165
|
/** The genres a `closeDecl` may name. v1 admits exactly one (D13) — a genre
|
|
164
166
|
* classifier is designed the day there is a second genre to classify. */
|
|
165
|
-
export const DECLARED_GENRES: readonly
|
|
167
|
+
export const DECLARED_GENRES: readonly string[];
|
|
166
168
|
/**
|
|
167
169
|
* The exact field set of a `closeDecl` — anything else is a smuggle channel, the
|
|
168
170
|
* same rule `STAGE_FIELDS` enforces on a command stage.
|
package/types/draftspend.d.ts
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
* One line of the drafting log. `no` = the step's position in the session's progress list (a step id can repeat).
|
|
3
3
|
* - `step-start` {no, id, label, at}
|
|
4
4
|
* - `step-end` {no, status: 'done'|'failed', label, at} (a re-opened step writes `step-reopen` {no, at} first)
|
|
5
|
-
* - `step-label` {no, label, at} (the step reads `label` from now on, status and times untouched: the thinking row's "the model thought anyway")
|
|
6
|
-
* - `call` {no, step, label, model, thinking,
|
|
7
|
-
* (`thinking` =
|
|
8
|
-
* call's run
|
|
5
|
+
* - `step-label` {no, label, at} (the step reads `label` from now on, status and times untouched: the thinking row's "the model thought anyway" / "can't change it" / "not confirmed")
|
|
6
|
+
* - `call` {no, step, label, model, thinking, thinkingSupport, thinkingStatus?, costUsd (null stays null), unpricedRounds, at}: one METERED model call
|
|
7
|
+
* (`thinking` = the tick's mode: off | on; `thinkingSupport` = bare-agent's lookup for the model: true | false | 'unverified';
|
|
8
|
+
* `thinkingStatus` = bare-agent's own verdict for the call's run: applied | unsupported | ignored | unknown, present only when thinkingMode was sent)
|
|
9
9
|
* (no token counts: the call path does not carry them without reworking the library, so none are recorded)
|
|
10
10
|
* @typedef {{kind: string, no: number, at: string, [k: string]: any}} DraftEvent
|
|
11
11
|
*/
|
|
@@ -108,10 +108,10 @@ export const DRAFT_LOG_FILE: "draft-log.jsonl";
|
|
|
108
108
|
* One line of the drafting log. `no` = the step's position in the session's progress list (a step id can repeat).
|
|
109
109
|
* - `step-start` {no, id, label, at}
|
|
110
110
|
* - `step-end` {no, status: 'done'|'failed', label, at} (a re-opened step writes `step-reopen` {no, at} first)
|
|
111
|
-
* - `step-label` {no, label, at} (the step reads `label` from now on, status and times untouched: the thinking row's "the model thought anyway")
|
|
112
|
-
* - `call` {no, step, label, model, thinking,
|
|
113
|
-
* (`thinking` =
|
|
114
|
-
* call's run
|
|
111
|
+
* - `step-label` {no, label, at} (the step reads `label` from now on, status and times untouched: the thinking row's "the model thought anyway" / "can't change it" / "not confirmed")
|
|
112
|
+
* - `call` {no, step, label, model, thinking, thinkingSupport, thinkingStatus?, costUsd (null stays null), unpricedRounds, at}: one METERED model call
|
|
113
|
+
* (`thinking` = the tick's mode: off | on; `thinkingSupport` = bare-agent's lookup for the model: true | false | 'unverified';
|
|
114
|
+
* `thinkingStatus` = bare-agent's own verdict for the call's run: applied | unsupported | ignored | unknown, present only when thinkingMode was sent)
|
|
115
115
|
* (no token counts: the call path does not carry them without reworking the library, so none are recorded)
|
|
116
116
|
*/
|
|
117
117
|
export type DraftEvent = {
|
package/types/facts.d.ts
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/** the `fact` part of a step's parameters, or null (a step has at most one) @param {any} params @returns {any|null} */
|
|
2
|
+
export function factPartOf(params: any): any | null;
|
|
3
|
+
/**
|
|
4
|
+
* The SHAPE of a `fact` part (what it may carry), pushed as reds in the same form `rubricStepShapeReds` uses. Whether the
|
|
5
|
+
* bareguard rubric it builds is signable is asked of bareguard itself (`checkRubricParts` builds it once at drafting).
|
|
6
|
+
* @param {any} part @param {string} w the path prefix @param {(code: string, path: string, detail: string) => void} red
|
|
7
|
+
*/
|
|
8
|
+
export function factShapeReds(part: any, w: string, red: (code: string, path: string, detail: string) => void): void;
|
|
9
|
+
/**
|
|
10
|
+
* bareguard's `decides` list for a fact part: one decide per fact, in the fact order (so `d<j>` is the fact's own index).
|
|
11
|
+
* @param {any} part @returns {Record<string, any>[]}
|
|
12
|
+
*/
|
|
13
|
+
export function factDecides(part: any): Record<string, any>[];
|
|
14
|
+
/**
|
|
15
|
+
* The claims bareguard reads for a fact step, built from the step file's `results`. The claim TEXT is written here, by code,
|
|
16
|
+
* from the values the worker gave (the worker writes no claim text): `name: value; name: value`. A phrase fact contributes its
|
|
17
|
+
* own signed words. A result that is not an object, or has no string quote, still becomes a claim — an empty one — so
|
|
18
|
+
* bareguard reds it by name rather than the result vanishing.
|
|
19
|
+
* @param {any} part @param {unknown} results @returns {{claim: string, quote: string, values?: Record<string, string>}[]}
|
|
20
|
+
*/
|
|
21
|
+
export function factClaims(part: any, results: unknown): {
|
|
22
|
+
claim: string;
|
|
23
|
+
quote: string;
|
|
24
|
+
values?: Record<string, string>;
|
|
25
|
+
}[];
|
|
26
|
+
/**
|
|
27
|
+
* One fact as a plain row, written by code from the signed fields:
|
|
28
|
+
* `fact · price — money, at most 450 US dollars, after "Price", quoted from "Flights"`.
|
|
29
|
+
* @param {any} f @param {string} source
|
|
30
|
+
* @returns {string}
|
|
31
|
+
*/
|
|
32
|
+
export function factSentence(f: any, source: string): string;
|
|
33
|
+
/**
|
|
34
|
+
* One fact as the WORKER is told it (item 7): what to write for it and where in the quote it sits, in plain words, from the signed
|
|
35
|
+
* fields. A phrase fact has no value to write — the quote has to say it.
|
|
36
|
+
* @param {any} f @returns {string}
|
|
37
|
+
*/
|
|
38
|
+
export function factBrief(f: any): string;
|
|
39
|
+
/** the "N results" row of a fact part, or null @param {any} part @returns {string|null} */
|
|
40
|
+
export function countSentence(part: any): string | null;
|
|
41
|
+
/**
|
|
42
|
+
* Every plan-card row a fact part carries: its facts, then its count.
|
|
43
|
+
* @param {any} part @returns {string[]}
|
|
44
|
+
*/
|
|
45
|
+
export function factRows(part: any): string[];
|
|
46
|
+
/**
|
|
47
|
+
* One bareguard `cited` item (`#<result>:d<j>:<reason>[:<detail>]`, or `#<result>:<reason>`) as a sentence the worker can act
|
|
48
|
+
* on. The names and numbers are bareguard's measurements and the person's signed facts, never inferred here.
|
|
49
|
+
* @param {string} item @param {any} part @returns {string}
|
|
50
|
+
*/
|
|
51
|
+
export function plainFactItem(item: string, part: any): string;
|
|
52
|
+
/**
|
|
53
|
+
* The fields each fact shape takes, in the fact part's own names (`rule` = bareguard's op/value/lo/hi; `unit`/`currency`; `phrase`
|
|
54
|
+
* = the presence decide's phrases), read off bareguard's rubric vocabulary.
|
|
55
|
+
* @returns {Record<string, string[]>} shape -> the fields it takes besides name and shape
|
|
56
|
+
*/
|
|
57
|
+
export function factShapeFields(): Record<string, string[]>;
|
|
58
|
+
/**
|
|
59
|
+
* The lines the drafter is shown about which shape takes which fields, generated from {@link factShapeFields} (shapes with the same
|
|
60
|
+
* fields are listed together). One owner: the composer brief and the confirm note both print this.
|
|
61
|
+
* @returns {string}
|
|
62
|
+
*/
|
|
63
|
+
export function factShapeGuide(): string;
|
|
64
|
+
/** the shapes a fact may have (bareguard's value kinds, plus `phrase` = a presence decide) */
|
|
65
|
+
export const FACT_SHAPES: readonly string[];
|
|
66
|
+
/** the comparison ops a rule may use (bareguard's) */
|
|
67
|
+
export const FACT_OPS: readonly string[];
|
|
68
|
+
/** bareguard signs at most this many decides on one `cited` check */
|
|
69
|
+
export const MAX_FACTS: 10;
|
|
70
|
+
/** every field a part of class `fact` may carry (the shared ones are checked by rubricStepShapeReds) */
|
|
71
|
+
export const FACT_PART_FIELDS: readonly string[];
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How many times exact words occur in a source, white space blind. Zero for empty words.
|
|
3
|
+
* @param {string} source the raw source text @param {string} words
|
|
4
|
+
* @returns {number}
|
|
5
|
+
*/
|
|
6
|
+
export function countExact(source: string, words: string): number;
|
|
7
|
+
/**
|
|
8
|
+
* How many times a phrase or unit occurs as WHOLE words, case and spacing aside ("SFO" is not found inside "sfocus").
|
|
9
|
+
* @param {string} source @param {string} words @returns {number}
|
|
10
|
+
*/
|
|
11
|
+
export function countPhrase(source: string, words: string): number;
|
|
12
|
+
/**
|
|
13
|
+
* The reds for ONE fact part against its frozen source text.
|
|
14
|
+
* @param {{part: any, text: string, line: number|string, scan?: import('./labelscan.js').LabelScan}} o
|
|
15
|
+
* @returns {{code: string, detail: string}[]}
|
|
16
|
+
*/
|
|
17
|
+
export function checkFactWords({ part, text, line, scan }: {
|
|
18
|
+
part: any;
|
|
19
|
+
text: string;
|
|
20
|
+
line: number | string;
|
|
21
|
+
scan?: import("./labelscan.js").LabelScan;
|
|
22
|
+
}): {
|
|
23
|
+
code: string;
|
|
24
|
+
detail: string;
|
|
25
|
+
}[];
|
|
26
|
+
/**
|
|
27
|
+
* The reds for every fact part of a declaration. A fact part whose input text is not at hand is a red: a check whose words were never
|
|
28
|
+
* proved against the source is never signed.
|
|
29
|
+
* @param {any} declaration @param {Record<string, string>|null} texts label -> frozen text
|
|
30
|
+
* @returns {{code: string, path: string, detail: string}[]}
|
|
31
|
+
*/
|
|
32
|
+
export function checkDeclarationWords(declaration: any, texts: Record<string, string> | null): {
|
|
33
|
+
code: string;
|
|
34
|
+
path: string;
|
|
35
|
+
detail: string;
|
|
36
|
+
}[];
|
|
37
|
+
/**
|
|
38
|
+
* The look's own proof hook: how often a phrase the look built is in an input.
|
|
39
|
+
* @param {Record<string, string>} texts @returns {(source: string, phrase: string) => number}
|
|
40
|
+
*/
|
|
41
|
+
export function proverOf(texts: Record<string, string>): (source: string, phrase: string) => number;
|
|
42
|
+
export function squash(t: string): string;
|
package/types/index.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export { validateEnvelope, resolveTrySpec, resolveReuse, reuseSpecHash, selectBr
|
|
|
15
15
|
export { classifyIncidents, foldLedger, ledgerDeltas, updateLedger, LEDGER_CLASSES, VOUCHED_RATE_SOURCES, rateProvenance, spendProvenance } from "./ledger.js";
|
|
16
16
|
export { readShimArm, READ_SHIM_CAP, READ_SHIM_STRATEGY, READ_SHIM_DIFF_STRATEGY } from "./readshim.js";
|
|
17
17
|
export { runDeclaredClose, runStage, seedRead, seedAtHead, LIVE_KINDS, STOP_FAULTS, JUDGED_MARKER, HUMAN_DECISIONS, SEED_EXEMPT_KINDS, normalizeHumanRuling, resolveHumanRuling, JUDGE_ATTEMPTS, MAX_JUDGED_PATHS, DOOR_OPEN_OUTCOMES, REVIEW_DOOR_CLASSES, doorOpens, mechanicalStages } from "./kinds.js";
|
|
18
|
-
export {
|
|
18
|
+
export { resolveJudge, JUDGE_RULES, JUDGE_RULE_IDS, runLocate, decide, CALIBRATION_SIZE, validateCalibrationSet, expectedOf } from "./judged.js";
|
|
19
19
|
export { proposeJudgedArtifacts, signJudgedArtifacts, foldJudgedArtifacts } from "./cardauthor.js";
|
|
20
20
|
export { runCalibration, INJECTION_LOCATE_BATTERY, CASUALTY_AXES } from "./calibrate.js";
|
|
21
21
|
export { validateDeclaration, KIND_CATALOGUE, LOCKED_KINDS, genreEnv, genreInstruments, LOCKED_CLASSES, CLASS_BATTERIES, classGuards, closeCeiling, NEVER_OFFERED_KINDS } from "./authoring.js";
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The input as the AI sees it: lines with any run of white space (U+202F included) made one space and the page reader's bracketed tags
|
|
3
|
+
* (`[ref=549]`) removed - an id that is only the page reader's, never part of a label.
|
|
4
|
+
* @param {string} text @returns {string[]}
|
|
5
|
+
*/
|
|
6
|
+
export function lookLines(text: string): string[];
|
|
7
|
+
/**
|
|
8
|
+
* The two read-only tools: search the input text, read a slice around a hit. They are closures over in-memory text and touch nothing
|
|
9
|
+
* else - read-only BY CONSTRUCTION, not by a fence. Several inputs: the `input` argument names which (its label).
|
|
10
|
+
* @param {Record<string, string>} texts label -> frozen text
|
|
11
|
+
* @returns {{name: string, description: string, parameters: any, execute: (a: any) => Promise<any>}[]}
|
|
12
|
+
*/
|
|
13
|
+
export function lookReadTools(texts: Record<string, string>): {
|
|
14
|
+
name: string;
|
|
15
|
+
description: string;
|
|
16
|
+
parameters: any;
|
|
17
|
+
execute: (a: any) => Promise<any>;
|
|
18
|
+
}[];
|
|
19
|
+
/** the strict answer form (a JSON schema - never free prose with JSON inside) */
|
|
20
|
+
export function lookReportSchema(): {
|
|
21
|
+
type: string;
|
|
22
|
+
additionalProperties: boolean;
|
|
23
|
+
required: string[];
|
|
24
|
+
properties: {
|
|
25
|
+
facts: {
|
|
26
|
+
type: string;
|
|
27
|
+
items: {
|
|
28
|
+
type: string;
|
|
29
|
+
additionalProperties: boolean;
|
|
30
|
+
required: string[];
|
|
31
|
+
properties: {
|
|
32
|
+
line: {
|
|
33
|
+
type: string;
|
|
34
|
+
minimum: number;
|
|
35
|
+
description: string;
|
|
36
|
+
};
|
|
37
|
+
name: {
|
|
38
|
+
type: string;
|
|
39
|
+
minLength: number;
|
|
40
|
+
description: string;
|
|
41
|
+
};
|
|
42
|
+
shape: {
|
|
43
|
+
enum: string[];
|
|
44
|
+
};
|
|
45
|
+
source: {
|
|
46
|
+
type: string;
|
|
47
|
+
minLength: number;
|
|
48
|
+
description: string;
|
|
49
|
+
};
|
|
50
|
+
label: {
|
|
51
|
+
type: string;
|
|
52
|
+
description: string;
|
|
53
|
+
};
|
|
54
|
+
value: {
|
|
55
|
+
type: string;
|
|
56
|
+
description: string;
|
|
57
|
+
};
|
|
58
|
+
example: {
|
|
59
|
+
type: string;
|
|
60
|
+
description: string;
|
|
61
|
+
};
|
|
62
|
+
rule: {
|
|
63
|
+
type: string;
|
|
64
|
+
additionalProperties: boolean;
|
|
65
|
+
required: string[];
|
|
66
|
+
properties: {
|
|
67
|
+
op: {
|
|
68
|
+
enum: string[];
|
|
69
|
+
};
|
|
70
|
+
value: {};
|
|
71
|
+
lo: {};
|
|
72
|
+
hi: {};
|
|
73
|
+
};
|
|
74
|
+
description: string;
|
|
75
|
+
};
|
|
76
|
+
aiProposal: {
|
|
77
|
+
type: string;
|
|
78
|
+
description: string;
|
|
79
|
+
};
|
|
80
|
+
forRule: {
|
|
81
|
+
type: string;
|
|
82
|
+
minimum: number;
|
|
83
|
+
description: string;
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
prose: {
|
|
89
|
+
type: string;
|
|
90
|
+
description: string;
|
|
91
|
+
items: {
|
|
92
|
+
type: string;
|
|
93
|
+
additionalProperties: boolean;
|
|
94
|
+
required: string[];
|
|
95
|
+
properties: {
|
|
96
|
+
line: {
|
|
97
|
+
type: string;
|
|
98
|
+
minimum: number;
|
|
99
|
+
};
|
|
100
|
+
text: {
|
|
101
|
+
type: string;
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
notFound: {
|
|
107
|
+
type: string;
|
|
108
|
+
description: string;
|
|
109
|
+
items: {
|
|
110
|
+
type: string;
|
|
111
|
+
additionalProperties: boolean;
|
|
112
|
+
required: string[];
|
|
113
|
+
properties: {
|
|
114
|
+
line: {
|
|
115
|
+
type: string;
|
|
116
|
+
minimum: number;
|
|
117
|
+
};
|
|
118
|
+
rule: {
|
|
119
|
+
type: string;
|
|
120
|
+
minimum: number;
|
|
121
|
+
description: string;
|
|
122
|
+
};
|
|
123
|
+
words: {
|
|
124
|
+
type: string;
|
|
125
|
+
description: string;
|
|
126
|
+
};
|
|
127
|
+
why: {
|
|
128
|
+
type: string;
|
|
129
|
+
minLength: number;
|
|
130
|
+
};
|
|
131
|
+
};
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
};
|
|
135
|
+
};
|
|
136
|
+
/**
|
|
137
|
+
* What the AI is told: the numbered job, the inputs and their label lists, and what to do.
|
|
138
|
+
* @param {{jobLines: {n: number, text: string, rule?: string, rules?: string[]}[], labels: string[], lists: Record<string, string>}} o
|
|
139
|
+
* @returns {string}
|
|
140
|
+
*/
|
|
141
|
+
export function lookPrompt({ jobLines, labels, lists }: {
|
|
142
|
+
jobLines: {
|
|
143
|
+
n: number;
|
|
144
|
+
text: string;
|
|
145
|
+
rule?: string;
|
|
146
|
+
rules?: string[];
|
|
147
|
+
}[];
|
|
148
|
+
labels: string[];
|
|
149
|
+
lists: Record<string, string>;
|
|
150
|
+
}): string;
|
|
151
|
+
/**
|
|
152
|
+
* Turn the AI's raw report into a VERIFIED one, by code, at $0. A fact is carried only when: its shape is a real shape, its source is
|
|
153
|
+
* a real input, and its label is ON THE LIST for that input and shape (an id is resolved to its exact words). Anything else is moved
|
|
154
|
+
* to `notFound` with a plain reason naming the word - never dropped silently. `prove` is the "found in the source" test of the
|
|
155
|
+
* phrase a phrase fact builds (label + value), supplied by the caller.
|
|
156
|
+
* @param {unknown} raw
|
|
157
|
+
* @param {{scans: Record<string, import('./labelscan.js').LabelScan>, jobLines: {n: number}[], prove?: (source: string, phrase: string) => number}} o
|
|
158
|
+
* @returns {LookReport}
|
|
159
|
+
*/
|
|
160
|
+
export function verifyLookReport(raw: unknown, { scans, jobLines, prove }: {
|
|
161
|
+
scans: Record<string, import("./labelscan.js").LabelScan>;
|
|
162
|
+
jobLines: {
|
|
163
|
+
n: number;
|
|
164
|
+
}[];
|
|
165
|
+
prove?: (source: string, phrase: string) => number;
|
|
166
|
+
}): LookReport;
|
|
167
|
+
/**
|
|
168
|
+
* The look's report as the DRAFTER reads it: one block, per job line, of what can be checked (with the exact words to copy) and what
|
|
169
|
+
* could not be found. Written by code from the verified report.
|
|
170
|
+
* @param {LookReport} report @returns {string}
|
|
171
|
+
*/
|
|
172
|
+
export function renderLookReport(report: LookReport): string;
|
|
173
|
+
/**
|
|
174
|
+
* The label scans and the rendered lists for the inputs the look will read.
|
|
175
|
+
* @param {Record<string, string>} texts
|
|
176
|
+
* @returns {{scans: Record<string, import('./labelscan.js').LabelScan>, lists: Record<string, string>}}
|
|
177
|
+
*/
|
|
178
|
+
export function labelListsOf(texts: Record<string, string>): {
|
|
179
|
+
scans: Record<string, import("./labelscan.js").LabelScan>;
|
|
180
|
+
lists: Record<string, string>;
|
|
181
|
+
};
|
|
182
|
+
/**
|
|
183
|
+
* L3: a reason the AI gave, cut only at a sentence end (never mid-sentence): whole sentences while they fit in `max` characters,
|
|
184
|
+
* and nothing at all if the first one alone does not fit. A trailing full stop is dropped (the caller closes the clause).
|
|
185
|
+
* @param {string} text @param {number} max @returns {string}
|
|
186
|
+
*/
|
|
187
|
+
export function wholeSentences(text: string, max: number): string;
|
|
188
|
+
/**
|
|
189
|
+
* I1 (hamr, 2026-10-13, "Ruled by hamr" 2): when the look shows the person's intent on one `~` rule was NOT captured - its words or
|
|
190
|
+
* meaning are not in the source - the person is asked about THAT rule at once, named by its line and rule. Only a look entry that names
|
|
191
|
+
* a rule number counts; anything else the look could not find is not asked piecemeal (it is Not checked, or the whole job is reviewed).
|
|
192
|
+
* The wording is the code's own, never the model's. The keep-or-drop and the cap are `normalizeQuestions` (src/authorflow.js).
|
|
193
|
+
* @param {LookNotFound[]} notFound @param {{n: number, text?: string, rule?: string, rules?: string[]}[]} jobLines
|
|
194
|
+
* @returns {{line: number, question: string}[]} every candidate question (the caller applies the machine's caps)
|
|
195
|
+
*/
|
|
196
|
+
export function ruleQuestions(notFound: LookNotFound[], jobLines: {
|
|
197
|
+
n: number;
|
|
198
|
+
text?: string;
|
|
199
|
+
rule?: string;
|
|
200
|
+
rules?: string[];
|
|
201
|
+
}[]): {
|
|
202
|
+
line: number;
|
|
203
|
+
question: string;
|
|
204
|
+
}[];
|
|
205
|
+
/** the name of the answer tool - the one place the AI's report enters */
|
|
206
|
+
export const LOOK_REPORT_TOOL: "report_look";
|
|
207
|
+
/** how many hits one search returns at most, and how long a snippet or a read line is */
|
|
208
|
+
export const LOOK_MAX_HITS: 40;
|
|
209
|
+
export { LABEL_SHAPES };
|
|
210
|
+
export type LookFact = {
|
|
211
|
+
line: number;
|
|
212
|
+
name: string;
|
|
213
|
+
shape: string;
|
|
214
|
+
source: string;
|
|
215
|
+
label?: string;
|
|
216
|
+
labelId?: string;
|
|
217
|
+
value?: string;
|
|
218
|
+
phrase?: string;
|
|
219
|
+
example: string;
|
|
220
|
+
rule?: any;
|
|
221
|
+
aiProposal?: boolean;
|
|
222
|
+
forRule?: number;
|
|
223
|
+
};
|
|
224
|
+
export type LookNotFound = {
|
|
225
|
+
line: number;
|
|
226
|
+
rule?: number;
|
|
227
|
+
words?: string;
|
|
228
|
+
why: string;
|
|
229
|
+
};
|
|
230
|
+
export type LookReport = {
|
|
231
|
+
facts: LookFact[];
|
|
232
|
+
prose: {
|
|
233
|
+
line: number;
|
|
234
|
+
text?: string;
|
|
235
|
+
}[];
|
|
236
|
+
notFound: LookNotFound[];
|
|
237
|
+
};
|
|
238
|
+
import { LABEL_SHAPES } from './labelscan.js';
|
package/types/job.d.ts
CHANGED
|
@@ -122,18 +122,18 @@ export function checkApproval(job: object, approvals: unknown): boolean;
|
|
|
122
122
|
* mismatched flag is a mistake worth stopping on, never a silent swap); the
|
|
123
123
|
* same id from both is not a conflict. Extracted from scripts/run-u.mjs so
|
|
124
124
|
* the decision is testable without running the script or touching a provider.
|
|
125
|
-
* @param {{ specModel?: string, flagModel?: string,
|
|
125
|
+
* @param {{ specModel?: string, flagModel?: string, suppliedModel?: string }} args
|
|
126
126
|
* `specModel` — `job.model` if the signed spec carries one, else undefined.
|
|
127
127
|
* `flagModel` — the model id an explicit `--model <tier>` resolved to, else
|
|
128
128
|
* undefined (a flag that was never passed, not merely a default tier name).
|
|
129
|
-
* `
|
|
129
|
+
* `suppliedModel` — a model the CALLER supplies when neither spec nor flag says (bareloop keeps none of its own).
|
|
130
130
|
* @returns {{ model: string, source: 'spec'|'flag'|'default' }}
|
|
131
|
-
* @throws {Error} when the spec names a model and the flag names a different one
|
|
131
|
+
* @throws {Error} when the spec names a model and the flag names a different one, or when no model is named at all
|
|
132
132
|
*/
|
|
133
|
-
export function resolveWorkerModel({ specModel, flagModel,
|
|
133
|
+
export function resolveWorkerModel({ specModel, flagModel, suppliedModel }: {
|
|
134
134
|
specModel?: string;
|
|
135
135
|
flagModel?: string;
|
|
136
|
-
|
|
136
|
+
suppliedModel?: string;
|
|
137
137
|
}): {
|
|
138
138
|
model: string;
|
|
139
139
|
source: "spec" | "flag" | "default";
|
package/types/jobblock.d.ts
CHANGED
|
@@ -52,11 +52,18 @@ export function renderInputs(inputs: JobInput[]): string;
|
|
|
52
52
|
* The two cross-checks between a parsed job block and the Check type: a RUBRIC job needs at least one `PASS:` and one
|
|
53
53
|
* `FAIL:` example (the calibration compile reads them); a DETERMINISTIC job has no judge, so an example line would be
|
|
54
54
|
* silently dropped — a red instead.
|
|
55
|
+
* PART 1a (hamr's ruling P1=B, docs/product/ITEM33-BUILD.md "Addendum 2026-10-12"): the examples are required of a rubric
|
|
56
|
+
* job ONLY when it holds a judged part. A rubric job on the person's own local files holds none in this build (its
|
|
57
|
+
* parts are counted or checked against a quote), so the caller says `judged: false` and a block without examples fits.
|
|
58
|
+
* Examples written anyway are never a red there — they simply have no judge to read them yet.
|
|
55
59
|
* @param {JobLine[]} lines
|
|
56
60
|
* @param {boolean} rubric
|
|
61
|
+
* @param {{judged?: boolean}} [o] `judged` (default true): does this job hold a judged part, so that it needs examples?
|
|
57
62
|
* @returns {string|null} the plain red, or null when the block fits the Check type
|
|
58
63
|
*/
|
|
59
|
-
export function jobBlockFitsCheck(lines: JobLine[], rubric: boolean
|
|
64
|
+
export function jobBlockFitsCheck(lines: JobLine[], rubric: boolean, { judged }?: {
|
|
65
|
+
judged?: boolean;
|
|
66
|
+
}): string | null;
|
|
60
67
|
/**
|
|
61
68
|
* The signed `jobLines` field from parsed lines: the person's own words, `{n, text, rule, rules}` (examples stay inside the
|
|
62
69
|
* rule text, where the person wrote them). `rules` is the same `~` lines as an array, BESIDE the joined `rule` (never
|