bareloop 0.56.0 → 0.58.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 +80 -0
- package/README.md +3 -3
- package/bareloop.context.md +75 -214
- package/package.json +2 -2
- package/src/authorflow.js +71 -136
- package/src/authoring.js +5 -124
- package/src/authorjob.js +125 -417
- package/src/authorreadout.js +105 -355
- package/src/authorrun.js +70 -234
- package/src/authorscout.js +9 -1
- package/src/blockasks.js +12 -17
- package/src/bundlerun.js +4 -1
- package/src/checkblock.js +297 -75
- package/src/checklist.js +1 -1
- package/src/checkpick.js +9 -5
- package/src/cli.js +3 -3
- package/src/declaredclose.js +45 -112
- package/src/destpoint.js +1 -1
- package/src/draftspend.js +20 -4
- package/src/fencepointcall.js +76 -0
- package/src/guarddescriptions.js +14 -0
- package/src/index.js +3 -43
- package/src/interviewrun.js +13 -8
- package/src/job.js +20 -1
- package/src/jobblock.js +11 -46
- package/src/judged.js +13 -1229
- package/src/kinds.js +10 -348
- package/src/noteask.js +124 -0
- package/src/pagedry.js +27 -5
- package/src/pagemap.js +7 -29
- package/src/pagerules.js +18 -3
- package/src/panel/authorroutes.js +15 -4
- package/src/panel/authorsession.js +201 -167
- package/src/panel/importrun.js +0 -1
- package/src/panel/index.html +43 -18
- package/src/panel/jobplan.js +54 -19
- package/src/panel/server.js +90 -69
- package/src/panel/status.js +3 -0
- package/src/pickrecord.js +15 -54
- package/src/planrun.js +4 -48
- package/src/promptregisters.js +7 -17
- package/src/providerrows.js +0 -36
- package/src/providers.js +4 -25
- package/src/questionbox.js +34 -30
- package/src/reviewdoor.js +1 -1
- package/src/rowresults.js +69 -0
- package/src/rubricstep.js +136 -28
- package/src/run.js +2 -15
- package/src/stagewords.js +24 -0
- package/src/userrun.js +14 -111
- package/types/authorflow.d.ts +51 -137
- package/types/authoring.d.ts +1 -14
- package/types/authorjob.d.ts +14 -55
- package/types/authorreadout.d.ts +52 -80
- package/types/authorrun.d.ts +20 -0
- package/types/blockasks.d.ts +5 -11
- package/types/checkblock.d.ts +147 -28
- package/types/checklist.d.ts +2 -2
- package/types/checkpick.d.ts +5 -3
- package/types/cli.d.ts +1 -3
- package/types/declaredclose.d.ts +5 -33
- package/types/draftspend.d.ts +16 -2
- package/types/fencepointcall.d.ts +68 -0
- package/types/guarddescriptions.d.ts +7 -0
- package/types/index.d.ts +2 -4
- package/types/job.d.ts +8 -0
- package/types/jobblock.d.ts +8 -38
- package/types/judged.d.ts +7 -357
- package/types/kinds.d.ts +4 -104
- package/types/noteask.d.ts +76 -0
- package/types/pagedry.d.ts +13 -0
- package/types/pagemap.d.ts +2 -5
- package/types/pagerules.d.ts +7 -0
- package/types/panel/authorsession.d.ts +37 -5
- package/types/panel/jobplan.d.ts +15 -3
- package/types/panel/server.d.ts +46 -13
- package/types/panel/status.d.ts +5 -0
- package/types/pickrecord.d.ts +8 -13
- package/types/planrun.d.ts +1 -22
- package/types/providerrows.d.ts +0 -31
- package/types/providers.d.ts +3 -19
- package/types/questionbox.d.ts +20 -6
- package/types/rowresults.d.ts +23 -0
- package/types/rubricstep.d.ts +43 -7
- package/types/run.d.ts +1 -20
- package/types/stagewords.d.ts +11 -0
- package/types/userrun.d.ts +0 -1
- package/src/calibrate.js +0 -702
- package/src/cardauthor.js +0 -502
- package/src/fitcheck.js +0 -168
- package/types/calibrate.d.ts +0 -201
- package/types/cardauthor.d.ts +0 -358
- package/types/fitcheck.d.ts +0 -119
package/types/cardauthor.d.ts
DELETED
|
@@ -1,358 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The proposal's shape, and therefore the whole shape the compiler can express.
|
|
3
|
-
*
|
|
4
|
-
* `rule` is an ENUM off the judge's own rulebook in BOTH places it appears — the
|
|
5
|
-
* card's lines and a case's expected reds — because wherever only a closed set
|
|
6
|
-
* can satisfy a field, the illegal value is made INEXPRESSIBLE rather than
|
|
7
|
-
* rejected after the fact (the `check-passes(name)` model). The SIZE is pinned by
|
|
8
|
-
* `minItems`/`maxItems` from the one constant, so nine and eleven are both
|
|
9
|
-
* unsayable rather than argued about afterwards.
|
|
10
|
-
*
|
|
11
|
-
* `artifact` and `text` are the only free strings, and neither decides anything:
|
|
12
|
-
* one is the code the judge will read, the other is the signer's own words.
|
|
13
|
-
*/
|
|
14
|
-
export function proposalSchema(): {
|
|
15
|
-
type: string;
|
|
16
|
-
properties: {
|
|
17
|
-
card: {
|
|
18
|
-
type: string;
|
|
19
|
-
description: string;
|
|
20
|
-
properties: {
|
|
21
|
-
items: {
|
|
22
|
-
type: string;
|
|
23
|
-
minItems: number;
|
|
24
|
-
items: {
|
|
25
|
-
type: string;
|
|
26
|
-
properties: {
|
|
27
|
-
rule: {
|
|
28
|
-
enum: string[];
|
|
29
|
-
description: string;
|
|
30
|
-
};
|
|
31
|
-
text: {
|
|
32
|
-
type: string;
|
|
33
|
-
minLength: number;
|
|
34
|
-
description: string;
|
|
35
|
-
};
|
|
36
|
-
};
|
|
37
|
-
required: string[];
|
|
38
|
-
additionalProperties: boolean;
|
|
39
|
-
};
|
|
40
|
-
};
|
|
41
|
-
};
|
|
42
|
-
required: string[];
|
|
43
|
-
additionalProperties: boolean;
|
|
44
|
-
};
|
|
45
|
-
cases: {
|
|
46
|
-
type: string;
|
|
47
|
-
minItems: number;
|
|
48
|
-
maxItems: number;
|
|
49
|
-
description: string;
|
|
50
|
-
items: {
|
|
51
|
-
type: string;
|
|
52
|
-
properties: {
|
|
53
|
-
id: {
|
|
54
|
-
type: string;
|
|
55
|
-
minLength: number;
|
|
56
|
-
description: string;
|
|
57
|
-
};
|
|
58
|
-
artifact: {
|
|
59
|
-
type: string;
|
|
60
|
-
minLength: number;
|
|
61
|
-
description: string;
|
|
62
|
-
};
|
|
63
|
-
expect: {
|
|
64
|
-
type: string;
|
|
65
|
-
properties: {
|
|
66
|
-
verdict: {
|
|
67
|
-
enum: string[];
|
|
68
|
-
};
|
|
69
|
-
reds: {
|
|
70
|
-
type: string;
|
|
71
|
-
description: string;
|
|
72
|
-
items: {
|
|
73
|
-
type: string;
|
|
74
|
-
properties: {
|
|
75
|
-
rule: {
|
|
76
|
-
enum: string[];
|
|
77
|
-
description: string;
|
|
78
|
-
};
|
|
79
|
-
fn: {
|
|
80
|
-
type: string;
|
|
81
|
-
minLength: number;
|
|
82
|
-
description: string;
|
|
83
|
-
};
|
|
84
|
-
};
|
|
85
|
-
required: string[];
|
|
86
|
-
additionalProperties: boolean;
|
|
87
|
-
};
|
|
88
|
-
};
|
|
89
|
-
};
|
|
90
|
-
required: string[];
|
|
91
|
-
additionalProperties: boolean;
|
|
92
|
-
};
|
|
93
|
-
};
|
|
94
|
-
required: string[];
|
|
95
|
-
additionalProperties: boolean;
|
|
96
|
-
};
|
|
97
|
-
};
|
|
98
|
-
};
|
|
99
|
-
required: string[];
|
|
100
|
-
additionalProperties: boolean;
|
|
101
|
-
};
|
|
102
|
-
/**
|
|
103
|
-
* The output channel. It records and acknowledges; it takes no action, which is
|
|
104
|
-
* why handing it to a toolless compile call does not reopen D3.
|
|
105
|
-
* @param {{calls: any[]}} box
|
|
106
|
-
*/
|
|
107
|
-
export function proposalTool(box: {
|
|
108
|
-
calls: any[];
|
|
109
|
-
}): {
|
|
110
|
-
name: string;
|
|
111
|
-
description: string;
|
|
112
|
-
parameters: {
|
|
113
|
-
type: string;
|
|
114
|
-
properties: {
|
|
115
|
-
card: {
|
|
116
|
-
type: string;
|
|
117
|
-
description: string;
|
|
118
|
-
properties: {
|
|
119
|
-
items: {
|
|
120
|
-
type: string;
|
|
121
|
-
minItems: number;
|
|
122
|
-
items: {
|
|
123
|
-
type: string;
|
|
124
|
-
properties: {
|
|
125
|
-
rule: {
|
|
126
|
-
enum: string[];
|
|
127
|
-
description: string;
|
|
128
|
-
};
|
|
129
|
-
text: {
|
|
130
|
-
type: string;
|
|
131
|
-
minLength: number;
|
|
132
|
-
description: string;
|
|
133
|
-
};
|
|
134
|
-
};
|
|
135
|
-
required: string[];
|
|
136
|
-
additionalProperties: boolean;
|
|
137
|
-
};
|
|
138
|
-
};
|
|
139
|
-
};
|
|
140
|
-
required: string[];
|
|
141
|
-
additionalProperties: boolean;
|
|
142
|
-
};
|
|
143
|
-
cases: {
|
|
144
|
-
type: string;
|
|
145
|
-
minItems: number;
|
|
146
|
-
maxItems: number;
|
|
147
|
-
description: string;
|
|
148
|
-
items: {
|
|
149
|
-
type: string;
|
|
150
|
-
properties: {
|
|
151
|
-
id: {
|
|
152
|
-
type: string;
|
|
153
|
-
minLength: number;
|
|
154
|
-
description: string;
|
|
155
|
-
};
|
|
156
|
-
artifact: {
|
|
157
|
-
type: string;
|
|
158
|
-
minLength: number;
|
|
159
|
-
description: string;
|
|
160
|
-
};
|
|
161
|
-
expect: {
|
|
162
|
-
type: string;
|
|
163
|
-
properties: {
|
|
164
|
-
verdict: {
|
|
165
|
-
enum: string[];
|
|
166
|
-
};
|
|
167
|
-
reds: {
|
|
168
|
-
type: string;
|
|
169
|
-
description: string;
|
|
170
|
-
items: {
|
|
171
|
-
type: string;
|
|
172
|
-
properties: {
|
|
173
|
-
rule: {
|
|
174
|
-
enum: string[];
|
|
175
|
-
description: string;
|
|
176
|
-
};
|
|
177
|
-
fn: {
|
|
178
|
-
type: string;
|
|
179
|
-
minLength: number;
|
|
180
|
-
description: string;
|
|
181
|
-
};
|
|
182
|
-
};
|
|
183
|
-
required: string[];
|
|
184
|
-
additionalProperties: boolean;
|
|
185
|
-
};
|
|
186
|
-
};
|
|
187
|
-
};
|
|
188
|
-
required: string[];
|
|
189
|
-
additionalProperties: boolean;
|
|
190
|
-
};
|
|
191
|
-
};
|
|
192
|
-
required: string[];
|
|
193
|
-
additionalProperties: boolean;
|
|
194
|
-
};
|
|
195
|
-
};
|
|
196
|
-
};
|
|
197
|
-
required: string[];
|
|
198
|
-
additionalProperties: boolean;
|
|
199
|
-
};
|
|
200
|
-
execute: (args: any) => Promise<string>;
|
|
201
|
-
};
|
|
202
|
-
/**
|
|
203
|
-
* The compile prompt. The Judge Examples answer travels VERBATIM — it is the
|
|
204
|
-
* whole input, and paraphrasing a lay answer is how a rubric stops being the
|
|
205
|
-
* person's. PRD item 33 M3 piece 3: this used to be two answers (Q6+Q7);
|
|
206
|
-
* `SOFTGREEN_JUDGE_EXAMPLES_KEY` is the ONE key both the interview and this
|
|
207
|
-
* compile now read, so a future renumbering of the form moves both readers
|
|
208
|
-
* together rather than drifting.
|
|
209
|
-
*
|
|
210
|
-
* The rulebook is rendered from `JUDGE_RULES` itself rather than restated, for
|
|
211
|
-
* the reason the catalogue block is rendered from the catalogue: the prompt and
|
|
212
|
-
* the gate must describe one set of facts.
|
|
213
|
-
* @param {{answers: Record<string|number, any>, questions?: Record<string|number, string>}} o
|
|
214
|
-
*/
|
|
215
|
-
export function cardCasesPrompt({ answers, questions }: {
|
|
216
|
-
answers: Record<string | number, any>;
|
|
217
|
-
questions?: Record<string | number, string>;
|
|
218
|
-
}): string;
|
|
219
|
-
/**
|
|
220
|
-
* THE D5 MOMENT. The proposal is SHOWN; the signer's `fix` is what is STORED.
|
|
221
|
-
*
|
|
222
|
-
* The fix replaces the proposal WHOLE rather than merging into it. A merge would
|
|
223
|
-
* mean a signer who deleted a card line got it back, and "the signer signs the
|
|
224
|
-
* whole hash" is not a rule that survives a field-wise reconciliation. Handing
|
|
225
|
-
* back no fix is a legal answer — signing the proposal as proposed — and it says
|
|
226
|
-
* so (`source`), because *a person read this and changed nothing* and *nobody has
|
|
227
|
-
* looked* are two different facts.
|
|
228
|
-
*
|
|
229
|
-
* THE GATE RUNS OVER WHAT WILL BE STORED, never over the proposal: a signer can
|
|
230
|
-
* fix a legal proposal into an illegal one, and the artifact that reaches the
|
|
231
|
-
* hash is the one that must be legal.
|
|
232
|
-
*
|
|
233
|
-
* `scrubbed` is the INGEST SCRUB'S OWN ANNOUNCEMENT — the paths whose bytes the
|
|
234
|
-
* secret inventory masked on the way in. Empty on every honest artifact, and
|
|
235
|
-
* never silent when it is not: a signer signs a hash over the STORED bytes, so
|
|
236
|
-
* "what you typed is not what was stored" is a fact they are owed rather than one
|
|
237
|
-
* the redactor keeps.
|
|
238
|
-
* @param {{proposal: any, fix?: any}} o
|
|
239
|
-
* @returns {{ok: boolean, reds: Red[], card: any, cases: any[]|null, source: 'signer'|'proposal',
|
|
240
|
-
* scrubbed: {path: string}[]}}
|
|
241
|
-
*/
|
|
242
|
-
export function signJudgedArtifacts({ proposal, fix }: {
|
|
243
|
-
proposal: any;
|
|
244
|
-
fix?: any;
|
|
245
|
-
}): {
|
|
246
|
-
ok: boolean;
|
|
247
|
-
reds: Red[];
|
|
248
|
-
card: any;
|
|
249
|
-
cases: any[] | null;
|
|
250
|
-
source: "signer" | "proposal";
|
|
251
|
-
scrubbed: {
|
|
252
|
-
path: string;
|
|
253
|
-
}[];
|
|
254
|
-
};
|
|
255
|
-
/**
|
|
256
|
-
* Fold the two signed artifacts into the close declaration, ENUMERATED.
|
|
257
|
-
*
|
|
258
|
-
* WHERE EACH LANDS, and both are inside the spec so `jobSpecHash` covers them by
|
|
259
|
-
* construction (the hash is over the whole resolved spec):
|
|
260
|
-
* - THE CARD replaces the judged stage's own `params.card`. ONE card, and it is
|
|
261
|
-
* the SIGNED one: the composer's draft is a draft, and two cards in one close
|
|
262
|
-
* is the drift a single storage site exists to prevent. The stage is where it
|
|
263
|
-
* already lives, which is what `validateCard`, the M2 runner and the locate
|
|
264
|
-
* prompt all read.
|
|
265
|
-
* - THE CASES land beside the stages as `calibration.cases` — a close-level
|
|
266
|
-
* artifact, because the set calibrates the RULER and not one stage's params,
|
|
267
|
-
* and because module 5's gate reads it before any stage runs.
|
|
268
|
-
* - THE JUDGE MODEL lands beside them as `calibration.judgeModel`. Since PRD item
|
|
269
|
-
* 32.1 that is the RESOLVED judge identity the caller hands in (`resolveJudge`,
|
|
270
|
-
* src/judged.js — the spec's signed `judge` override, else the job's own worker
|
|
271
|
-
* model), not a library pin. A calibration set is only worth the judge that
|
|
272
|
-
* graded it, so the set has to carry which judge certified it or nothing
|
|
273
|
-
* downstream can tell a signed floor from a moved one. Storing it HERE, inside
|
|
274
|
-
* the spec, is what makes a judge change flip `jobSpecHash`: the signature dies,
|
|
275
|
-
* the signer re-signs, and a re-sign is a re-run of the calibration gate. It is
|
|
276
|
-
* REQUIRED, with no default — a set stamped with a model nobody named is exactly
|
|
277
|
-
* the unattributable floor this field exists to prevent (F45).
|
|
278
|
-
*
|
|
279
|
-
* A card with NOWHERE TO LAND THROWS. It is a caller's own broken input — a
|
|
280
|
-
* signed rubric folded into a close with no judged ruler — and there is no safe
|
|
281
|
-
* direction to degrade toward: storing it would sign a rubric nothing reads.
|
|
282
|
-
*
|
|
283
|
-
* The input is never mutated: a closeDecl is a signed artefact and rewriting a
|
|
284
|
-
* caller's copy in place is how two readers come to disagree about what was
|
|
285
|
-
* signed.
|
|
286
|
-
* @param {any} closeDecl @param {{card: any, cases: any[], judgeModel: string}} o
|
|
287
|
-
* @returns {any} a new closeDecl
|
|
288
|
-
*/
|
|
289
|
-
export function foldJudgedArtifacts(closeDecl: any, { card, cases, judgeModel }: {
|
|
290
|
-
card: any;
|
|
291
|
-
cases: any[];
|
|
292
|
-
judgeModel: string;
|
|
293
|
-
}): any;
|
|
294
|
-
/**
|
|
295
|
-
* ONE compile call: the person's Judge Examples answer in, a proposal out.
|
|
296
|
-
*
|
|
297
|
-
* It buys ONE artifact through ONE channel, and the malformed-emission ladder is
|
|
298
|
-
* the SHARED one (`askStructured`) rather than a second copy — a second ladder is
|
|
299
|
-
* a second place for the cap, the reject block and the re-ask to drift.
|
|
300
|
-
*
|
|
301
|
-
* WHAT IS AND IS NOT RETRIED, and the split is the standing one: a reply that
|
|
302
|
-
* carries no proposal is a TRANSPORT fault and is retried under the bound; a
|
|
303
|
-
* proposal that PARSED and then broke the ruling is not — the model answered
|
|
304
|
-
* perfectly clearly and re-asking buys another call to be told the same thing.
|
|
305
|
-
* The proposal is returned as it was said, never repaired: no JSON repair, ever.
|
|
306
|
-
*
|
|
307
|
-
* The book is the CALLER's, so one ceiling governs the survey, the declaration
|
|
308
|
-
* ladder and this compile — the advertised ceiling and the enforced ceiling are
|
|
309
|
-
* the same ceiling.
|
|
310
|
-
* @param {{answers: Record<string|number, any>, questions?: Record<string|number, string>,
|
|
311
|
-
* generate: Function, book?: ReturnType<typeof makeCostBook>,
|
|
312
|
-
* structuredMode?: 'tool'|'text', structureRetries?: number}} o
|
|
313
|
-
* @returns {Promise<{ok: boolean, proposal: any, reds: Red[], stop: string|null,
|
|
314
|
-
* attempts: number, raw: string, cost: any, raws: any[]}>}
|
|
315
|
-
*/
|
|
316
|
-
export function proposeJudgedArtifacts({ answers, questions, generate, book, structuredMode, structureRetries, }: {
|
|
317
|
-
answers: Record<string | number, any>;
|
|
318
|
-
questions?: Record<string | number, string>;
|
|
319
|
-
generate: Function;
|
|
320
|
-
book?: ReturnType<typeof makeCostBook>;
|
|
321
|
-
structuredMode?: "tool" | "text";
|
|
322
|
-
structureRetries?: number;
|
|
323
|
-
}): Promise<{
|
|
324
|
-
ok: boolean;
|
|
325
|
-
proposal: any;
|
|
326
|
-
reds: Red[];
|
|
327
|
-
stop: string | null;
|
|
328
|
-
attempts: number;
|
|
329
|
-
raw: string;
|
|
330
|
-
cost: any;
|
|
331
|
-
raws: any[];
|
|
332
|
-
}>;
|
|
333
|
-
/** @typedef {{code: string, path: string, detail: string, [k: string]: any}} Red */
|
|
334
|
-
/** the output channel for the compile. It takes no action; it carries the answer. */
|
|
335
|
-
export const PROPOSAL_TOOL_NAME: "propose_rubric";
|
|
336
|
-
/** what the tool returns. The loop stops on delivery, so the model never reads it. */
|
|
337
|
-
export const PROPOSAL_ACK: "proposal received";
|
|
338
|
-
/** the label the compile call is metered and persisted under — one spelling */
|
|
339
|
-
export const PROPOSAL_LABEL: "judged-compile";
|
|
340
|
-
/** a malformed EMISSION is a transport fault, bounded on its own axis — the same
|
|
341
|
-
* ceiling `authorClose` declares for the declaration channel */
|
|
342
|
-
export const MAX_PROPOSAL_RETRIES: 2;
|
|
343
|
-
/**
|
|
344
|
-
* The system prompt a caller BINDS ITS SEAM WITH — this module owns no provider
|
|
345
|
-
* and picks none, exactly as `authorClose` does not: the compile call arrives as
|
|
346
|
-
* `generate`, and a caller wires it with `makeLoopGenerate(provider, {system:
|
|
347
|
-
* COMPILE_SYSTEM})`, whose own `maxTokens` default (F30) is what holds ten
|
|
348
|
-
* artifacts. Exported rather than inlined so the one register this call is made
|
|
349
|
-
* in is not re-spelled at every integration.
|
|
350
|
-
*/
|
|
351
|
-
export const COMPILE_SYSTEM: string;
|
|
352
|
-
export type Red = {
|
|
353
|
-
code: string;
|
|
354
|
-
path: string;
|
|
355
|
-
detail: string;
|
|
356
|
-
[k: string]: any;
|
|
357
|
-
};
|
|
358
|
-
import { makeCostBook } from './authorflow.js';
|
package/types/fitcheck.d.ts
DELETED
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* What the AI is told: the job lines (the numbered text only, no `~` rules) and the WHOLE text of every input under its label. Adapted from the POC
|
|
3
|
-
* call (.claude/scratch/fit-poc6/run.mjs): the asks are copied from each job line instead of hand-written.
|
|
4
|
-
* @param {{jobLines: {n: number, text: string}[], texts: Record<string, string>}} o
|
|
5
|
-
* @returns {string}
|
|
6
|
-
*/
|
|
7
|
-
export function fitPrompt({ jobLines, texts }: {
|
|
8
|
-
jobLines: {
|
|
9
|
-
n: number;
|
|
10
|
-
text: string;
|
|
11
|
-
}[];
|
|
12
|
-
texts: Record<string, string>;
|
|
13
|
-
}): string;
|
|
14
|
-
/**
|
|
15
|
-
* Read the AI's reply and decide, all in code. Malformed (no repair): not JSON, another form, a line that is not a job line, an ask not copied from its own
|
|
16
|
-
* line, found not a boolean, a quote neither text nor null, or a job line with no ask. An ask is found only if `found` is true AND its quote is on a page;
|
|
17
|
-
* `found` with a quote that is not on any page (or no quote) is made up and counts as not found.
|
|
18
|
-
* @param {unknown} text the reply
|
|
19
|
-
* @param {{n: number, text: string}[]} jobLines
|
|
20
|
-
* @param {Record<string, string>} texts the frozen input texts by label
|
|
21
|
-
* @returns {{status: 'malformed'}|{status: 'ok', state: 'fits'|'ask', asks: FitAsk[], notFound: {line: number, ask: string}[]}}
|
|
22
|
-
*/
|
|
23
|
-
export function decideFit(text: unknown, jobLines: {
|
|
24
|
-
n: number;
|
|
25
|
-
text: string;
|
|
26
|
-
}[], texts: Record<string, string>): {
|
|
27
|
-
status: "malformed";
|
|
28
|
-
} | {
|
|
29
|
-
status: "ok";
|
|
30
|
-
state: "fits" | "ask";
|
|
31
|
-
asks: FitAsk[];
|
|
32
|
-
notFound: {
|
|
33
|
-
line: number;
|
|
34
|
-
ask: string;
|
|
35
|
-
}[];
|
|
36
|
-
};
|
|
37
|
-
/**
|
|
38
|
-
* Run the fit check: one call (one retry on a malformed reply or a transport failure or a 429). Never throws on a call casualty; every failure is `absent`.
|
|
39
|
-
* @param {{jobLines: {n: number, text: string}[], texts: Record<string, string>, provider?: any, maxTokens?: number, ceilingUsd?: number|null,
|
|
40
|
-
* callTimeoutMs?: number, onCall?: (call: {label: string, costUsd: number|null, unpricedRounds: number, thinkingStatus?: string, raw?: string}) => void,
|
|
41
|
-
* createLoop?: Function, rates?: {in: number, out: number}|null, callOptions?: Record<string, any>, sleep?: (ms: number) => Promise<void>}} o
|
|
42
|
-
* @returns {Promise<{state: 'fits'|'ask'|'absent', asks: FitAsk[], notFound: {line: number, ask: string}[], reason: string|null, cause: string|null,
|
|
43
|
-
* calls: {label: string, costUsd: number|null, unpricedRounds: number}[], budgetStop: 'cap-halt'|'pricing-red'|null}>}
|
|
44
|
-
*/
|
|
45
|
-
export function runFitCheck({ jobLines, texts, provider, maxTokens, ceilingUsd, callTimeoutMs, onCall, createLoop, rates, callOptions, sleep, }: {
|
|
46
|
-
jobLines: {
|
|
47
|
-
n: number;
|
|
48
|
-
text: string;
|
|
49
|
-
}[];
|
|
50
|
-
texts: Record<string, string>;
|
|
51
|
-
provider?: any;
|
|
52
|
-
maxTokens?: number;
|
|
53
|
-
ceilingUsd?: number | null;
|
|
54
|
-
callTimeoutMs?: number;
|
|
55
|
-
onCall?: (call: {
|
|
56
|
-
label: string;
|
|
57
|
-
costUsd: number | null;
|
|
58
|
-
unpricedRounds: number;
|
|
59
|
-
thinkingStatus?: string;
|
|
60
|
-
raw?: string;
|
|
61
|
-
}) => void;
|
|
62
|
-
createLoop?: Function;
|
|
63
|
-
rates?: {
|
|
64
|
-
in: number;
|
|
65
|
-
out: number;
|
|
66
|
-
} | null;
|
|
67
|
-
callOptions?: Record<string, any>;
|
|
68
|
-
sleep?: (ms: number) => Promise<void>;
|
|
69
|
-
}): Promise<{
|
|
70
|
-
state: "fits" | "ask" | "absent";
|
|
71
|
-
asks: FitAsk[];
|
|
72
|
-
notFound: {
|
|
73
|
-
line: number;
|
|
74
|
-
ask: string;
|
|
75
|
-
}[];
|
|
76
|
-
reason: string | null;
|
|
77
|
-
cause: string | null;
|
|
78
|
-
calls: {
|
|
79
|
-
label: string;
|
|
80
|
-
costUsd: number | null;
|
|
81
|
-
unpricedRounds: number;
|
|
82
|
-
}[];
|
|
83
|
-
budgetStop: "cap-halt" | "pricing-red" | null;
|
|
84
|
-
}>;
|
|
85
|
-
/** the label of the one paid call, as the drafting book and the progress line see it */
|
|
86
|
-
export const FIT_CALL_LABEL: "fit-check";
|
|
87
|
-
/** what the chat says when the check did not finish (drafting goes on) */
|
|
88
|
-
export const FIT_ABSENT_NOTE: "The fit check did not finish; drafting goes on.";
|
|
89
|
-
/** the answer that keeps drafting after the fit question (any case, a closing full stop allowed) */
|
|
90
|
-
export const FIT_GO_ON: "go on";
|
|
91
|
-
export function isGoOn(text: unknown): boolean;
|
|
92
|
-
export const FIT_SYSTEM: "You check whether saved web pages show what a job asks for. You never invent words: every ask must be copied from its job line and every quote must be copied from the page, character for character.";
|
|
93
|
-
export function norm(s: unknown): string;
|
|
94
|
-
export function notFoundList(notFound: {
|
|
95
|
-
line: number;
|
|
96
|
-
ask: string;
|
|
97
|
-
}[]): string;
|
|
98
|
-
export function fitQuestionText({ found, total, notFound, foundAsks }: {
|
|
99
|
-
found: number;
|
|
100
|
-
total: number;
|
|
101
|
-
notFound: {
|
|
102
|
-
line: number;
|
|
103
|
-
ask: string;
|
|
104
|
-
}[];
|
|
105
|
-
foundAsks?: {
|
|
106
|
-
line: number;
|
|
107
|
-
ask: string;
|
|
108
|
-
}[];
|
|
109
|
-
}): string;
|
|
110
|
-
/** the answer words the question ends with (said once, here; the panel's question box shows the question without them and has the buttons instead) */
|
|
111
|
-
export const FIT_ANSWER: " Type go on to keep drafting, or anything else to stop and change the job or the page.";
|
|
112
|
-
export type FitAsk = {
|
|
113
|
-
line: number;
|
|
114
|
-
ask: string;
|
|
115
|
-
found: boolean;
|
|
116
|
-
quote: string | null;
|
|
117
|
-
madeUp: boolean;
|
|
118
|
-
ignored?: "number";
|
|
119
|
-
};
|