fwdloop 0.23.0 → 0.25.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 +62 -32
- package/package.json +1 -1
- package/src/ask.js +15 -1
- package/src/attemptdiff.js +118 -0
- package/src/audit-fold.js +2 -0
- package/src/authoring.js +32 -2
- package/src/cited-record.js +3 -22
- package/src/cited-source.js +5 -6
- package/src/citedwords.js +36 -2
- package/src/config.js +5 -1
- package/src/diary.js +21 -17
- package/src/drafter.js +6 -2
- package/src/flowmodel.js +52 -28
- package/src/keysfile.js +1 -1
- package/src/launcher.js +552 -0
- package/src/learn.js +952 -0
- package/src/learnstore.js +348 -0
- package/src/line-checks.js +55 -0
- package/src/model-step.js +2 -0
- package/src/opener.js +33 -0
- package/src/pagedry.js +3 -4
- package/src/pagefetch.js +9 -2
- package/src/pagerules.js +28 -5
- package/src/panel/author.js +2 -0
- package/src/panel/authorflows.js +9 -9
- package/src/panel/authorresume.js +4 -3
- package/src/panel/data.js +63 -14
- package/src/panel/index.html +162 -16
- package/src/panel/result.js +7 -12
- package/src/panel/server.js +53 -5
- package/src/panel/settings.js +4 -18
- package/src/panel/spawn.js +0 -9
- package/src/prompts.js +33 -0
- package/src/redact.js +6 -6
- package/src/runfile.js +60 -0
- package/src/runner.js +144 -33
- package/src/sheet-record.js +15 -35
- package/src/sheetblock.js +3 -3
- package/src/sheetrun.js +6 -6
- package/src/summary-words.js +13 -5
- package/src/thinking.js +11 -0
- package/src/tty-colour.js +29 -0
- package/types/ask.d.ts +7 -2
- package/types/attemptdiff.d.ts +38 -0
- package/types/cited-record.d.ts +0 -2
- package/types/citedwords.d.ts +14 -0
- package/types/diary.d.ts +2 -5
- package/types/drafter.d.ts +6 -1
- package/types/flowmodel.d.ts +37 -20
- package/types/keysfile.d.ts +7 -0
- package/types/launcher.d.ts +307 -0
- package/types/learn.d.ts +576 -0
- package/types/learnstore.d.ts +168 -0
- package/types/line-checks.d.ts +26 -0
- package/types/opener.d.ts +12 -0
- package/types/pagerules.d.ts +7 -0
- package/types/panel/author.d.ts +2 -0
- package/types/panel/data.d.ts +2 -1
- package/types/panel/result.d.ts +2 -4
- package/types/panel/server.d.ts +24 -3
- package/types/panel/settings.d.ts +2 -2
- package/types/panel/spawn.d.ts +0 -6
- package/types/prompts.d.ts +14 -0
- package/types/runfile.d.ts +48 -0
- package/types/runner.d.ts +14 -5
- package/types/sheet-record.d.ts +0 -2
- package/types/sheetblock.d.ts +2 -2
- package/types/sheetrun.d.ts +1 -1
- package/types/summary-words.d.ts +2 -1
- package/types/thinking.d.ts +11 -0
- package/types/tty-colour.d.ts +33 -0
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* M8 item 5a (loose end): the ONE function that turns a source as written into a place. The run-end notes (`learnAtRunEnd`: a path the panel/CLI gave the run) and
|
|
3
|
+
* the drafter's hints (`hintsForRun`: the step's first input, or at draft time the path as typed in the prose) both pass through it, so the same file cannot be two places. A leading `~` or `~/` is the
|
|
4
|
+
* home folder (`path.resolve` alone would make it `<cwd>/~/...`); then `path.resolve` (lexical, no fs: the F48 guard keeps realpathSync out of this file).
|
|
5
|
+
* A web address stays its host (placeOf). Not copied from bareloop: this is the fwdloop-only part of the place.
|
|
6
|
+
* @param {string} p @returns {string}
|
|
7
|
+
*/
|
|
8
|
+
export function resolvePlace(p: string): string;
|
|
9
|
+
/**
|
|
10
|
+
* M8 am8: the ONE function that gives a run's place spec: `{job, inputs}` for `placeOf`, from the run's first input AS THE RUN READS IT (`inputsManifest[0].source`,
|
|
11
|
+
* a path the panel or CLI gave the run), never the path written in the signed job. The step's hints (`stepHintsReader`), the run-end tally (`learnAtRunEnd`) and the
|
|
12
|
+
* drafter's hints (src/authoring.js) all build their spec here. No source (a job with no file input) is no place.
|
|
13
|
+
* @param {string} job the workflow name
|
|
14
|
+
* @param {string|null|undefined} source the run's first input as it reads it
|
|
15
|
+
* @returns {{job: string, inputs: {value: string}[]}}
|
|
16
|
+
*/
|
|
17
|
+
export function placeSpecOf(job: string, source: string | null | undefined): {
|
|
18
|
+
job: string;
|
|
19
|
+
inputs: {
|
|
20
|
+
value: string;
|
|
21
|
+
}[];
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* `<configHome>/learn/ledger.json`. Under a test process (NODE_ENV=test or node --test) the home is the explicit one or
|
|
25
|
+
* FWDLOOP_CONFIG_HOME; with neither it THROWS rather than fall back to the real ~/.config/fwdloop.
|
|
26
|
+
* @param {string} [home] test seam; production never passes it
|
|
27
|
+
* @returns {string}
|
|
28
|
+
*/
|
|
29
|
+
export function ledgerPath(home?: string): string;
|
|
30
|
+
/**
|
|
31
|
+
* Read the ledger. A missing file is an empty ledger; an unreadable or wrong-shaped one is reported as `problem` (and the
|
|
32
|
+
* writer then refuses to replace it: an append-only record is never silently reset).
|
|
33
|
+
* @param {string} [home]
|
|
34
|
+
* @returns {{ledger: import('./learn.js').Ledger, exists: boolean, problem: string|null}}
|
|
35
|
+
*/
|
|
36
|
+
export function readLedger(home?: string): {
|
|
37
|
+
ledger: import("./learn.js").Ledger;
|
|
38
|
+
exists: boolean;
|
|
39
|
+
problem: string | null;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Write the ledger atomically (temp + rename, mode 600), every string masked through the one secret inventory.
|
|
43
|
+
* @param {import('./learn.js').Ledger} ledger @param {string} [home]
|
|
44
|
+
* @returns {string} the file written
|
|
45
|
+
*/
|
|
46
|
+
export function writeLedger(ledger: import("./learn.js").Ledger, home?: string): string;
|
|
47
|
+
/**
|
|
48
|
+
* Fold ONE finished run into the ledger on disk: every run's cards COUNT now, rubric jobs too (trust kept on new rows;
|
|
49
|
+
* bareloop v0.47.0). `held` is always 0 (kept in the shape for callers). The run's health line is recorded. Never throws on a bad ledger file: it reports `problem` and writes nothing.
|
|
50
|
+
* @param {{home?: string, runid: string, build: import('./learn.js').CardBuild, workflow: string, place: string|null, specHash: string|null, trust: 'deterministic'|'rubric', at: string, now?: Date}} o
|
|
51
|
+
* @returns {{wrote: boolean, counted: number, held: number, problem: string|null}}
|
|
52
|
+
*/
|
|
53
|
+
export function foldRunIntoLedger({ home, runid, build, workflow, place, specHash, trust, at, now }: {
|
|
54
|
+
home?: string;
|
|
55
|
+
runid: string;
|
|
56
|
+
build: import("./learn.js").CardBuild;
|
|
57
|
+
workflow: string;
|
|
58
|
+
place: string | null;
|
|
59
|
+
specHash: string | null;
|
|
60
|
+
trust: "deterministic" | "rubric";
|
|
61
|
+
at: string;
|
|
62
|
+
now?: Date;
|
|
63
|
+
}): {
|
|
64
|
+
wrote: boolean;
|
|
65
|
+
counted: number;
|
|
66
|
+
held: number;
|
|
67
|
+
problem: string | null;
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* The human Accept at the review door: release a hold an older version wrote for the run so it counts (new runs write none; only forward, only here).
|
|
71
|
+
* @param {{home?: string, runid: string, now?: Date}} o
|
|
72
|
+
* @returns {{released: number, problem: string|null}}
|
|
73
|
+
*/
|
|
74
|
+
export function releaseRun({ home, runid, now }: {
|
|
75
|
+
home?: string;
|
|
76
|
+
runid: string;
|
|
77
|
+
now?: Date;
|
|
78
|
+
}): {
|
|
79
|
+
released: number;
|
|
80
|
+
problem: string | null;
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* M8 am1: the ONE setting, `learningHints` in config.json. Ships OFF (absent = off). OFF still writes the tally ($0); the drafter
|
|
84
|
+
* is simply handed nothing. Copied from bareloop learnstore.js@v0.47.0:96 (borrowed-from header above). Difference: bareloop's
|
|
85
|
+
* `readConfig` returns a problem, fwdloop's THROWS ConfigError on an unreadable / non-JSON / invalid file. The safe reading is kept:
|
|
86
|
+
* a bad or unreadable config reads as OFF (never ON). Under a test process with no explicit home and no FWDLOOP_CONFIG_HOME it
|
|
87
|
+
* reads nothing (OFF), so a test can never reach the real ~/.config/fwdloop.
|
|
88
|
+
* @param {string} [home]
|
|
89
|
+
* @returns {boolean}
|
|
90
|
+
*/
|
|
91
|
+
export function learningHintsOn(home?: string): boolean;
|
|
92
|
+
/**
|
|
93
|
+
* One finished run's folder -> the event list buildCards reads, plus the check texts and the model. ONE adapter, map never invent
|
|
94
|
+
* (F79). Check name = `<step> (line <job line>, <close class>)`; a try with verdict red or not-done and a gap = a red moment (the gap
|
|
95
|
+
* verbatim = B1's flagged line); a later try of the same check that is not red = the pass; Fix touched = `artifacts/<step>.json`;
|
|
96
|
+
* What changed = a -U1 line diff of the try's modelOutput (log.json) against the step's previous try. Reads only the run's own books.
|
|
97
|
+
* Refused drafts make no run folder, and a human redo is not a try (isTry), so neither makes a note.
|
|
98
|
+
* @param {string} runDir @param {string} workflow
|
|
99
|
+
* @returns {{events: any[], questions: Map<string, string|null>, model: string|null, source: string|null}|null} null when the run has no try
|
|
100
|
+
*/
|
|
101
|
+
export function eventsOfRun(runDir: string, workflow: string): {
|
|
102
|
+
events: any[];
|
|
103
|
+
questions: Map<string, string | null>;
|
|
104
|
+
model: string | null;
|
|
105
|
+
source: string | null;
|
|
106
|
+
} | null;
|
|
107
|
+
/**
|
|
108
|
+
* THE RUN-END TALLY ($0, code only, no model; M8 item 2): turn a finished run's folder into cards and fold them into the ledger.
|
|
109
|
+
* The place is the first input's source made absolute lexically (`path.resolve`, no fs: the F48 guard keeps realpathSync out of this file, so a symlinked source is not followed). The ledger run id is `<workflow>/<runId>` (fwdloop's run ids repeat across workflows, bareloop's do not). M8 am4: every run's notes COUNT at once (trust 'deterministic'), a run
|
|
110
|
+
* with a signed ask included; there is no hold. It runs whether `learningHints` is on or off. `questions` (bareloop's stageQuestionsByName) is, here, the failing check's own text from
|
|
111
|
+
* the run's diary.jsonl, so a check with no checks row there (a run from before am29) has no `meaning`.
|
|
112
|
+
* Borrowed-from: bareloop src/learnstore.js@v0.47.0:124 (learnAtRunEnd).
|
|
113
|
+
* @param {{home?: string, workflow: string, runId: string, runDir: string, specHash: string|null, now?: Date}} o
|
|
114
|
+
* @returns {{wrote: boolean, counted: number, held: number, problem: string|null, noise: string|null, cards: number}}
|
|
115
|
+
*/
|
|
116
|
+
export function learnAtRunEnd({ home, workflow, runId, runDir, specHash, now }: {
|
|
117
|
+
home?: string;
|
|
118
|
+
workflow: string;
|
|
119
|
+
runId: string;
|
|
120
|
+
runDir: string;
|
|
121
|
+
specHash: string | null;
|
|
122
|
+
now?: Date;
|
|
123
|
+
}): {
|
|
124
|
+
wrote: boolean;
|
|
125
|
+
counted: number;
|
|
126
|
+
held: number;
|
|
127
|
+
problem: string | null;
|
|
128
|
+
noise: string | null;
|
|
129
|
+
cards: number;
|
|
130
|
+
};
|
|
131
|
+
/**
|
|
132
|
+
* M8 am6: seed the ledger from every run already recorded under `root` (every job, every ended run), oldest first by the run's own end time
|
|
133
|
+
* (the last history row that is a run end). Each run goes through `learnAtRunEnd` (the one note builder) with `now` = its own end time, so
|
|
134
|
+
* ages, decay and lastSeen come from the run. A run already in the ledger (its `<workflow>/<runId>` has a health line) is skipped, so a second seed adds nothing.
|
|
135
|
+
* Code only, $0. A run it cannot read is counted and the seed goes on; a bad ledger file stops it at once (nothing is rewritten).
|
|
136
|
+
* Under a test process with no door nothing is read or written (`skippedNoDoor`).
|
|
137
|
+
* @param {{root: string, home?: string}} o `home` is a test seam; production leaves it out
|
|
138
|
+
* @returns {{read: number, added: number, skipped: Record<'already-in'|'still-waiting'|'no-end'|'unreadable'|'noise', number>, problem: string|null, skippedNoDoor: boolean}}
|
|
139
|
+
*/
|
|
140
|
+
export function seedLedger({ root, home }: {
|
|
141
|
+
root: string;
|
|
142
|
+
home?: string;
|
|
143
|
+
}): {
|
|
144
|
+
read: number;
|
|
145
|
+
added: number;
|
|
146
|
+
skipped: Record<"already-in" | "still-waiting" | "no-end" | "unreadable" | "noise", number>;
|
|
147
|
+
problem: string | null;
|
|
148
|
+
skippedNoDoor: boolean;
|
|
149
|
+
};
|
|
150
|
+
/**
|
|
151
|
+
* M8 item 5a: the block the DRAFTER is handed for this job, made from the ledger as it stood: null when `learningHints` is off,
|
|
152
|
+
* when there is no ledger, or when nothing is readable; an unreadable ledger THROWS (the caller hands nothing and records why). The one `renderHints` render (2,000 characters at most),
|
|
153
|
+
* never a second. Age (56 days), job version and level are worked out here, at read time, by renderHints.
|
|
154
|
+
* Borrowed-from: bareloop src/learnstore.js@v0.47.0:140 (hintsForRun). `spec` is `{job, inputs: [{value}]}` (job = the workflow name).
|
|
155
|
+
* @param {{home?: string, spec: any, specHash: string|null, now?: Date}} o
|
|
156
|
+
* @returns {{text: string, ids: string[]}|null}
|
|
157
|
+
*/
|
|
158
|
+
export function hintsForRun({ home, spec, specHash, now }: {
|
|
159
|
+
home?: string;
|
|
160
|
+
spec: any;
|
|
161
|
+
specHash: string | null;
|
|
162
|
+
now?: Date;
|
|
163
|
+
}): {
|
|
164
|
+
text: string;
|
|
165
|
+
ids: string[];
|
|
166
|
+
} | null;
|
|
167
|
+
/** M8 am4 item 2: a run waiting at an ask has not ended ('paused', or a Stop whose set-aside failed). ONE decider: the runner's run-end tally and the seed both read it. */
|
|
168
|
+
export const NOT_A_RUN_END: Set<string>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One section of the record: `{ok: true, lines}`, or `{ok: false, missing: true}` when the file or the section is not there, or `{ok: false, missing: false, red}` when
|
|
3
|
+
* the file (or the section) is not what it should be. Read through the safe gateway.
|
|
4
|
+
* @param {string} runDir @param {LineSection} section
|
|
5
|
+
* @returns {{ok: true, lines: any[]}|{ok: false, missing: true}|{ok: false, missing: false, red: string}}
|
|
6
|
+
*/
|
|
7
|
+
export function readLineSection(runDir: string, section: LineSection): {
|
|
8
|
+
ok: true;
|
|
9
|
+
lines: any[];
|
|
10
|
+
} | {
|
|
11
|
+
ok: false;
|
|
12
|
+
missing: true;
|
|
13
|
+
} | {
|
|
14
|
+
ok: false;
|
|
15
|
+
missing: false;
|
|
16
|
+
red: string;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Change one section's lines and write the file: `change` gets the section's lines now (none when the section or the file is missing or unreadable: the record is started
|
|
20
|
+
* again, this function is its only writer) and returns the lines to keep, or null to write nothing. The other section is carried over as it is. Atomic.
|
|
21
|
+
* @param {string} runDir @param {LineSection} section @param {(lines: any[]) => any[]|null} change @returns {void}
|
|
22
|
+
*/
|
|
23
|
+
export function writeLineSection(runDir: string, section: LineSection, change: (lines: any[]) => any[] | null): void;
|
|
24
|
+
/** the record's name in the run's own folder */
|
|
25
|
+
export const LINE_CHECKS_FILE: "line-checks.json";
|
|
26
|
+
export type LineSection = "cited" | "sheet";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {string} target a folder path or a URL
|
|
3
|
+
* @param {{ platform?: string, spawnFn?: ((cmd: string, args: string[], o: object) => any)|null, underTest?: boolean }} [opts]
|
|
4
|
+
* `spawnFn: null` = no opener at all (resolves false); undefined = the real spawn, unless `underTest`, which spawns nothing
|
|
5
|
+
* unless a test injected one
|
|
6
|
+
* @returns {Promise<boolean>} true once the opener process has started
|
|
7
|
+
*/
|
|
8
|
+
export function openInOs(target: string, opts?: {
|
|
9
|
+
platform?: string;
|
|
10
|
+
spawnFn?: ((cmd: string, args: string[], o: object) => any) | null;
|
|
11
|
+
underTest?: boolean;
|
|
12
|
+
}): Promise<boolean>;
|
package/types/pagerules.d.ts
CHANGED
|
@@ -19,6 +19,13 @@ export function tieOf(from: unknown, jobLines: {
|
|
|
19
19
|
* @param {unknown} shape @param {unknown} r @returns {boolean}
|
|
20
20
|
*/
|
|
21
21
|
export function validReading(shape: unknown, r: unknown): boolean;
|
|
22
|
+
/** a number as the page writes it: digits, thousands commas, optional decimals (a currency sign next to it is not part of it) */
|
|
23
|
+
/**
|
|
24
|
+
* The number written at the very end of `s` (only whitespace after it): the leftmost match of NUM followed by `\s*$`. Shared with src/pagedry.js (one copy). Scans back from the end, so a
|
|
25
|
+
* long run of digits and commas costs O(n) where a backtracking regex is quadratic.
|
|
26
|
+
* @param {string} s @returns {string|undefined}
|
|
27
|
+
*/
|
|
28
|
+
export function numberAtEnd(s: string): string | undefined;
|
|
22
29
|
/**
|
|
23
30
|
* Apply the rules to the AI's map over one saved page. Returns the kept facts and, for everything a rule removed, one `dropped` entry.
|
|
24
31
|
* The order of the rules is the POC's (apply-v3.mjs): found-on-page, then the rules that read the page. A place is read as a phrase.
|
package/types/panel/author.d.ts
CHANGED
|
@@ -43,6 +43,8 @@ export function createAuthor(opts: {
|
|
|
43
43
|
};
|
|
44
44
|
/** `GET /api/author/run-again`, its flow entry carrying the trigger card like the list's entries do. @param {string|null} flow @param {string|null} runId */
|
|
45
45
|
runAgain(flow: string | null, runId: string | null): any;
|
|
46
|
+
/** M4b am4 item 7: how many drafts are open for `whoami` and the launcher's stop warning: the card `live()` returns (the newest draft not abandoned or signed), 0 or 1. */
|
|
47
|
+
openDrafts(): 0 | 1;
|
|
46
48
|
run: (body: any) => {
|
|
47
49
|
status: any;
|
|
48
50
|
body: any;
|
package/types/panel/data.d.ts
CHANGED
|
@@ -658,7 +658,7 @@ export function getDraftBlock(flowDir: string, runDir: string): {
|
|
|
658
658
|
* shared-sidecar contamination risk here the way bareloop's gate-audit
|
|
659
659
|
* sidecar had). `null` when the flow/runId doesn't resolve (404).
|
|
660
660
|
* @param {{root: string, flow: string, runId: string, scheduleRead?: (flow: string) => any, home?: string, catalogue?: any, resumeAttempt?: (flow: string, runId: string) => any, startingRun?: (flow: string, runId: string) => boolean, now?: () => number}} opts
|
|
661
|
-
* @returns {{flow:string, runId:string, rows:any[], groups:any[], draft:ReturnType<typeof getDraftBlock>, needsLeft: string|null, schedule: ReturnType<typeof scheduleAuditWords>, empty:boolean, why:string|null}|null}
|
|
661
|
+
* @returns {{flow:string, runId:string, rows:any[], groups:any[], draft:ReturnType<typeof getDraftBlock>, learnings: any[], needsLeft: string|null, schedule: ReturnType<typeof scheduleAuditWords>, empty:boolean, why:string|null}|null}
|
|
662
662
|
*/
|
|
663
663
|
export function getRunAudit({ root, flow, runId, scheduleRead, home, catalogue, resumeAttempt, startingRun, now, }: {
|
|
664
664
|
root: string;
|
|
@@ -676,6 +676,7 @@ export function getRunAudit({ root, flow, runId, scheduleRead, home, catalogue,
|
|
|
676
676
|
rows: any[];
|
|
677
677
|
groups: any[];
|
|
678
678
|
draft: ReturnType<typeof getDraftBlock>;
|
|
679
|
+
learnings: any[];
|
|
679
680
|
needsLeft: string | null;
|
|
680
681
|
schedule: ReturnType<typeof scheduleAuditWords>;
|
|
681
682
|
empty: boolean;
|
package/types/panel/result.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export function isResultRun(arbiter: any): boolean;
|
|
|
7
7
|
* @param {any} declaration @returns {string} */
|
|
8
8
|
export function checkTypeOf(declaration: any): string;
|
|
9
9
|
/**
|
|
10
|
-
* The ONE reader of the M10 cited-check record (`<run>/
|
|
10
|
+
* The ONE reader of the M10 cited-check record (the `cited` section of `<run>/line-checks.json`, src/line-checks.js; `writeCitedLine`, src/cited-record.js, writes it). Expected shape (typed, nothing parsed out of prose):
|
|
11
11
|
* { lines: [ { n: int, source: string (the role of a signed source), passed: boolean,
|
|
12
12
|
* facts: [ { name: string, kind: 'phrase'|'value', sentence: string, confirmed?: true } ],
|
|
13
13
|
* rows: [ { n: int, quote: string, cells: string[] (one per fact), proof?: { text: string, marks: [[start, end], ...] } } ] | null,
|
|
@@ -109,7 +109,7 @@ export function buildResult({ flow, runId, runDir, root, flowRead, arbiter, hist
|
|
|
109
109
|
path: string;
|
|
110
110
|
name: string;
|
|
111
111
|
bytes: number | null;
|
|
112
|
-
state: "ok" | "
|
|
112
|
+
state: "ok" | "changed" | "gone";
|
|
113
113
|
words: string | null;
|
|
114
114
|
}[];
|
|
115
115
|
gap: {
|
|
@@ -152,5 +152,3 @@ export const RESULT_YOU_CONFIRMED: "(you confirmed)";
|
|
|
152
152
|
/** the Your-call card's words (bareloop server.js@2959217 DOOR_WORDS.waiting.head and RESULT_DOOR_ASK); the page types none of them */
|
|
153
153
|
export const RESULT_DOOR_HEAD: "waiting for you";
|
|
154
154
|
export const RESULT_DOOR_ASK: "the checks passed; is this what you wanted?";
|
|
155
|
-
export { CITED_CHECKS_FILE };
|
|
156
|
-
import { CITED_CHECKS_FILE } from '../cited-record.js';
|
package/types/panel/server.d.ts
CHANGED
|
@@ -4,24 +4,45 @@
|
|
|
4
4
|
* real listening socket where that is simpler.
|
|
5
5
|
* @param {import('node:http').IncomingMessage} req
|
|
6
6
|
* @param {import('node:http').ServerResponse} res
|
|
7
|
-
* @param {{ root: string, port: number, packagePath?: string, resumer: ReturnType<typeof createResumer>, settings: ReturnType<typeof createSettings>, author: ReturnType<typeof createAuthor>, now?: () => number }} opts
|
|
7
|
+
* @param {{ root: string, port: number, version?: string|null, startedAt?: string, packagePath?: string, resumer: ReturnType<typeof createResumer>, settings: ReturnType<typeof createSettings>, author: ReturnType<typeof createAuthor>, now?: () => number }} opts
|
|
8
8
|
*/
|
|
9
9
|
export function handleRequest(req: import("node:http").IncomingMessage, res: import("node:http").ServerResponse, opts: {
|
|
10
10
|
root: string;
|
|
11
11
|
port: number;
|
|
12
|
+
version?: string | null;
|
|
13
|
+
startedAt?: string;
|
|
12
14
|
packagePath?: string;
|
|
13
15
|
resumer: ReturnType<typeof createResumer>;
|
|
14
16
|
settings: ReturnType<typeof createSettings>;
|
|
15
17
|
author: ReturnType<typeof createAuthor>;
|
|
16
18
|
now?: () => number;
|
|
17
19
|
}): void;
|
|
20
|
+
/**
|
|
21
|
+
* The runs list as the panel builds it, for a caller with no panel running (the launcher header): the SAME `listRuns` over the same catalogue,
|
|
22
|
+
* so Needs you (M11's `needsYouOf` tag on each row) has ONE owner. Read-only, $0; the resume-attempt and starting-run lookups are the panel's
|
|
23
|
+
* in-memory ones and a stopped panel has none.
|
|
24
|
+
* borrowed-from: bareloop src/panel/server.js@c772d4e (runsListForCount); adapted: fwdloop's listRuns rows, no schedules-gave-up part (fwdloop has no such concept).
|
|
25
|
+
* @param {{ root: string, now?: () => number }} opts
|
|
26
|
+
* @returns {any[]} the rows of /api/runs
|
|
27
|
+
*/
|
|
28
|
+
export function runsListForCount(opts: {
|
|
29
|
+
root: string;
|
|
30
|
+
now?: () => number;
|
|
31
|
+
}): any[];
|
|
32
|
+
/**
|
|
33
|
+
* The ONE spelling of the panel's own address (the launcher prints and opens it too).
|
|
34
|
+
* borrowed-from: bareloop src/panel/server.js@9104b2b (panelUrl); adaptation: none.
|
|
35
|
+
* @param {number} boundPort
|
|
36
|
+
* @returns {string}
|
|
37
|
+
*/
|
|
38
|
+
export function panelUrl(boundPort: number): string;
|
|
18
39
|
/**
|
|
19
40
|
* Start the panel server. Binds `127.0.0.1` ONLY. A taken port is a LOUD,
|
|
20
41
|
* non-zero-exit failure — this never falls back to another port (see file
|
|
21
42
|
* header). Resolves once actually listening; rejects on a bind error
|
|
22
43
|
* (including `EADDRINUSE`) with a `.port` field on the error for the
|
|
23
44
|
* caller's message.
|
|
24
|
-
* @param {{ port?: number, root: string, packagePath?: string, settings?: { home?: string, env?: Record<string,string|undefined>, fetch?: typeof fetch, now?: () => number, openFolderSpawn?:
|
|
45
|
+
* @param {{ port?: number, root: string, packagePath?: string, settings?: { home?: string, env?: Record<string,string|undefined>, fetch?: typeof fetch, now?: () => number, openFolderSpawn?: (cmd: string, args: string[], o: object) => any, platform?: string }, resume?: { env?: Record<string,string|undefined>, bin?: string, logDir?: string, maxTries?: number, windowMs?: number, slotMs?: number }, author?: { env?: Record<string,string|undefined>, loadEnv?: () => any, bin?: string, now?: () => number }, scheduler?: { intervalMs?: number } }} opts
|
|
25
46
|
* `resume` and `author` are for tests only (a fake env/bin, a short retry window); the CLI passes none.
|
|
26
47
|
* @returns {Promise<{ server: import('node:http').Server, port: number, tick: () => void, close: () => Promise<void> }>}
|
|
27
48
|
*/
|
|
@@ -34,7 +55,7 @@ export function createPanelServer(opts: {
|
|
|
34
55
|
env?: Record<string, string | undefined>;
|
|
35
56
|
fetch?: typeof fetch;
|
|
36
57
|
now?: () => number;
|
|
37
|
-
openFolderSpawn?:
|
|
58
|
+
openFolderSpawn?: (cmd: string, args: string[], o: object) => any;
|
|
38
59
|
platform?: string;
|
|
39
60
|
};
|
|
40
61
|
resume?: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @param {{ home?: string, skip?: boolean, env?: Record<string,string|undefined>, fetch?: typeof fetch, now?: () => number, openFolderSpawn?:
|
|
2
|
+
* @param {{ home?: string, skip?: boolean, env?: Record<string,string|undefined>, fetch?: typeof fetch, now?: () => number, openFolderSpawn?: (cmd: string, args: string[], o: object) => any, platform?: string }} cfg
|
|
3
3
|
* `home` the config home (undefined = the real `~/.config/fwdloop`); `skip` true under a test process
|
|
4
4
|
* with no `FWDLOOP_CONFIG_HOME` (Settings then touches nothing); `env` the shell side (tests only);
|
|
5
5
|
* `fetch` and `now` are test seams.
|
|
@@ -10,7 +10,7 @@ export function createSettings(cfg: {
|
|
|
10
10
|
env?: Record<string, string | undefined>;
|
|
11
11
|
fetch?: typeof fetch;
|
|
12
12
|
now?: () => number;
|
|
13
|
-
openFolderSpawn?:
|
|
13
|
+
openFolderSpawn?: (cmd: string, args: string[], o: object) => any;
|
|
14
14
|
platform?: string;
|
|
15
15
|
}): {
|
|
16
16
|
handle: ({ method, pathname, query, body }: {
|
package/types/panel/spawn.d.ts
CHANGED
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The ONE spawn for the Settings "Open keys folder" button (borrowed-from: bareloop src/panel/settingsroutes.js@07c298f): the OS file manager
|
|
3
|
-
* (`xdg-open` / `open`) on a folder the server chose, argv array, no shell, detached. Settings calls it only through its injected seam.
|
|
4
|
-
* @param {string} cmd @param {string[]} args @param {import('node:child_process').SpawnOptions} o
|
|
5
|
-
*/
|
|
6
|
-
export function spawnOpener(cmd: string, args: string[], o: import("node:child_process").SpawnOptions): import("child_process").ChildProcess;
|
|
7
1
|
/**
|
|
8
2
|
* @param {{ bin: string, argv: string[], env: Record<string, string|undefined>, logPath: string }} a
|
|
9
3
|
* @returns {import('node:child_process').ChildProcess} the child (already `unref()`ed; the log fd is closed here)
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One readline over `stdin`, with a LINE QUEUE: lines that arrive before the next question (piped input, a paste, or input that
|
|
3
|
+
* ends while the header is still waiting on the port probe) wait for it instead of being dropped, and a closed stdin answers ''
|
|
4
|
+
* (the safe default) and never hangs.
|
|
5
|
+
* @param {{ stdin?: any, stdout?: any }} [io]
|
|
6
|
+
* @returns {{ ask: (q: string) => Promise<string>, close: () => void }}
|
|
7
|
+
*/
|
|
8
|
+
export function openAsker(io?: {
|
|
9
|
+
stdin?: any;
|
|
10
|
+
stdout?: any;
|
|
11
|
+
}): {
|
|
12
|
+
ask: (q: string) => Promise<string>;
|
|
13
|
+
close: () => void;
|
|
14
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The record as parsed, or why not. `missing` = no file; `unreadable` = the gateway refused it (a symlink, outside the folder); `invalid` = not a JSON object.
|
|
3
|
+
* @param {string|null} runDir @returns {{ok: true, rec: Record<string, any>}|{ok: false, code: 'missing'|'unreadable'|'invalid', red: string}}
|
|
4
|
+
*/
|
|
5
|
+
export function readRunRecord(runDir: string | null): {
|
|
6
|
+
ok: true;
|
|
7
|
+
rec: Record<string, any>;
|
|
8
|
+
} | {
|
|
9
|
+
ok: false;
|
|
10
|
+
code: "missing" | "unreadable" | "invalid";
|
|
11
|
+
red: string;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* M4d am26: the run's OWN record of the box (`thinking` in `<run>/run.json`) and nothing else: `true`/`false`, or `null` when the run has none (a run from before am25).
|
|
15
|
+
* An unreadable record is box off, as `readJobThinking` has always read it. @param {string|null} runDir @returns {boolean|null}
|
|
16
|
+
*/
|
|
17
|
+
export function readRunThinking(runDir: string | null): boolean | null;
|
|
18
|
+
/**
|
|
19
|
+
* M8b: the ONE reader of what a run froze at its start (`inputs` in `<run>/run.json`: the manifest `freezeInputs` made). `missing` = the run froze none (no record, or no
|
|
20
|
+
* `inputs` section: a refusal at freeze leaves none); `unreadable` = the gateway refused the file; `invalid` = the section is not a list.
|
|
21
|
+
* @param {string|null} runDir
|
|
22
|
+
* @returns {{ok: true, entries: any[]}|{ok: false, code: 'missing'|'unreadable'|'invalid', red: string}}
|
|
23
|
+
*/
|
|
24
|
+
export function readRunInputs(runDir: string | null): {
|
|
25
|
+
ok: true;
|
|
26
|
+
entries: any[];
|
|
27
|
+
} | {
|
|
28
|
+
ok: false;
|
|
29
|
+
code: "missing" | "unreadable" | "invalid";
|
|
30
|
+
red: string;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* M8b item 1: the ONE writer of `run.json`, called once when a fresh run has frozen its inputs (`runFlow`); never over an existing record. `model` is the pick
|
|
34
|
+
* the run started on (M4d am33; null = the section is left out), `thinking` the job's "Thinking on" box as it was at the start (M4d am25: written for every fresh
|
|
35
|
+
* run, ticked or not), `inputs` the manifest `freezeInputs` returned. A section given as null is left out;
|
|
36
|
+
* a fresh run always has `thinking` and `inputs`.
|
|
37
|
+
* @param {string} runDir @param {{ model: { slot: string, model: string }|null, thinking: boolean|null, inputs: any[]|null }} start
|
|
38
|
+
*/
|
|
39
|
+
export function writeRunStart(runDir: string, { model, thinking, inputs }: {
|
|
40
|
+
model: {
|
|
41
|
+
slot: string;
|
|
42
|
+
model: string;
|
|
43
|
+
} | null;
|
|
44
|
+
thinking: boolean | null;
|
|
45
|
+
inputs: any[] | null;
|
|
46
|
+
}): void;
|
|
47
|
+
/** the file's name in the run's folder */
|
|
48
|
+
export const RUN_FILE: "run.json";
|
package/types/runner.d.ts
CHANGED
|
@@ -29,12 +29,13 @@ export function readHaltRecord(runDir: string): {
|
|
|
29
29
|
missing?: undefined;
|
|
30
30
|
red?: undefined;
|
|
31
31
|
};
|
|
32
|
-
/** @param {{goal:string, primitives?:string[], reads?:Record<string,any>, gap?:string|null}} opts */
|
|
32
|
+
/** @param {{goal:string, primitives?:string[], reads?:Record<string,any>, gap?:string|null, hints?:string|null}} opts `hints` (M8 am7): the earlier runs' block, text only, for a retry / redo / rerun try */
|
|
33
33
|
export function buildExecutorContext(opts: {
|
|
34
34
|
goal: string;
|
|
35
35
|
primitives?: string[];
|
|
36
36
|
reads?: Record<string, any>;
|
|
37
37
|
gap?: string | null;
|
|
38
|
+
hints?: string | null;
|
|
38
39
|
}): Readonly<{
|
|
39
40
|
goal: string;
|
|
40
41
|
primitives: readonly string[];
|
|
@@ -42,6 +43,7 @@ export function buildExecutorContext(opts: {
|
|
|
42
43
|
[x: string]: any;
|
|
43
44
|
}>;
|
|
44
45
|
gap: string | null;
|
|
46
|
+
hints: string | null;
|
|
45
47
|
}>;
|
|
46
48
|
/**
|
|
47
49
|
* @param {unknown} value
|
|
@@ -94,7 +96,7 @@ export function freezePage(dir: string, id: string, url: string, { fetchPage }?:
|
|
|
94
96
|
red: string;
|
|
95
97
|
}>;
|
|
96
98
|
/** Copy each named source into `<runDir>/inputs/`, hash the FROZEN copy
|
|
97
|
-
* (never the original again after this),
|
|
99
|
+
* (never the original again after this) and return the manifest, which `runFlow` records as the `inputs` of `run.json` (M8b). An
|
|
98
100
|
* unreadable source refuses by name. A source that is a web address
|
|
99
101
|
* (M10 item 1) is fetched and frozen by `freezePage`, in the same manifest.
|
|
100
102
|
* @param {string} runDir @param {Array<{id: string, path: string}>} sources
|
|
@@ -232,6 +234,7 @@ export function readArtifactsMapChecked(runDir: any, ids: any, { docxRoles }?: {
|
|
|
232
234
|
* @param {(row: any, modelOutput?: any) => void} opts.recordAudit
|
|
233
235
|
* @param {string|null} [opts.initialGap]
|
|
234
236
|
* @param {number} [opts.attemptOffset]
|
|
237
|
+
* @param {(() => {text: string, ids: string[]}|null)|null} [opts.learnHints] - M8 am7: `stepHintsReader`'s closure (the drafter's one block function); asked only on a retry, redo or rerun try
|
|
235
238
|
* @param {boolean} [opts.thinkingBox] - M4d am25: the job's "Thinking on" box as this run's copy keeps it (default off)
|
|
236
239
|
* @param {() => string} [opts.now] - M4a-2: stamps each audit row's `at`;
|
|
237
240
|
* defaults to the real wall clock.
|
|
@@ -242,7 +245,7 @@ export function readArtifactsMapChecked(runDir: any, ids: any, { docxRoles }?: {
|
|
|
242
245
|
* @param {string|null} [opts.runDir] - M4d am29 item 2: the run's folder, where each try saves its checks
|
|
243
246
|
* @returns {Promise<{ok:true, artifact:any, attempts:number, hitl?:boolean} | {ok:false, outcome:string, red:string, stop?:{where:string, book:Record<string, any>, step?:string|null}}>}
|
|
244
247
|
*/
|
|
245
|
-
export function runStepRalph({ step, primitivesMap, readsMap, businessDate, modelStep, spent, capUsd, ceilingUsd, recordAudit, initialGap, attemptOffset, thinkingBox, now, readStop, stepNo, triesDone, runDir, prevStepId, }: {
|
|
248
|
+
export function runStepRalph({ step, primitivesMap, readsMap, businessDate, modelStep, spent, capUsd, ceilingUsd, recordAudit, initialGap, attemptOffset, thinkingBox, learnHints, now, readStop, stepNo, triesDone, runDir, prevStepId, }: {
|
|
246
249
|
step: any;
|
|
247
250
|
primitivesMap?: Record<string, any> | undefined;
|
|
248
251
|
readsMap: Record<string, any>;
|
|
@@ -260,6 +263,10 @@ export function runStepRalph({ step, primitivesMap, readsMap, businessDate, mode
|
|
|
260
263
|
recordAudit: (row: any, modelOutput?: any) => void;
|
|
261
264
|
initialGap?: string | null | undefined;
|
|
262
265
|
attemptOffset?: number | undefined;
|
|
266
|
+
learnHints?: (() => {
|
|
267
|
+
text: string;
|
|
268
|
+
ids: string[];
|
|
269
|
+
} | null) | null | undefined;
|
|
263
270
|
thinkingBox?: boolean | undefined;
|
|
264
271
|
now?: (() => string) | undefined;
|
|
265
272
|
readStop?: (() => boolean) | null | undefined;
|
|
@@ -297,7 +304,7 @@ export function runStepRalph({ step, primitivesMap, readsMap, businessDate, mode
|
|
|
297
304
|
* @param {() => string} [opts.clock] - returns the current ISO timestamp; defaults to the wall clock.
|
|
298
305
|
* @param {string} opts.businessDate - the run's explicit "as of today", never the wall clock.
|
|
299
306
|
* @param {number} [opts.ceilingUsd] - per-attempt ceiling override; the model's hold from Settings prices (`ceilingCostUsd`); absent = no hold.
|
|
300
|
-
* @param {{slot: string, model: string}} [opts.runModel] - M4d am33: the model this run started on; recorded once in the run folder (run
|
|
307
|
+
* @param {{slot: string, model: string}} [opts.runModel] - M4d am33: the model this run started on; recorded once in the run folder (run.json) and kept by every resume/continue.
|
|
301
308
|
* @param {string|null} [opts.initialGap] - M3 scope item 7 (rerun as a fresh
|
|
302
309
|
* run): a human's rerun reason, carried as the FIRST ordinary step's
|
|
303
310
|
* starting gap. Never used by a plain `runFlow` call outside `resumeRun`'s
|
|
@@ -391,7 +398,7 @@ export function makeParkingAskStep(): (opts?: any) => Promise<{
|
|
|
391
398
|
* @param {() => string} [opts.clock]
|
|
392
399
|
* @param {string} opts.businessDate
|
|
393
400
|
* @param {number} [opts.ceilingUsd]
|
|
394
|
-
* @param {{slot: string, model: string}} [opts.runModel] - M4d am33: the model this run started on; recorded once in the run folder (run
|
|
401
|
+
* @param {{slot: string, model: string}} [opts.runModel] - M4d am33: the model this run started on; recorded once in the run folder (run.json) and kept by every resume/continue.
|
|
395
402
|
* @param {() => number} [opts.nowMs] - F45 finding 3; see `runFlow`'s own.
|
|
396
403
|
* @param {(newRunDir:string) => void} [opts.onRerunStart] - amendment 16 C2: called with the new run's folder just before a `rerun` starts it.
|
|
397
404
|
*/
|
|
@@ -544,3 +551,5 @@ export const MAX_ATTEMPTS: 4;
|
|
|
544
551
|
export const SPEND_TOLERANCE_USD: 1e-9;
|
|
545
552
|
export const STOP_FILE: "stop.request";
|
|
546
553
|
export const HALT_FILE: "halt.json";
|
|
554
|
+
/** where a failure of learnings work that must not stop the run is recorded (one appended row, in the run's own folder): the run-end tally (`recordRunNotes`) and the take of the draft's learnings record (`takeLearningsRecord`, in runFlow). The run itself is unaffected */
|
|
555
|
+
export const LEARN_ERROR_FILE: "learn-error.jsonl";
|
package/types/sheet-record.d.ts
CHANGED
|
@@ -20,5 +20,3 @@ export function writeSheetLine(runDir: string, { n, try: attempt, checks, closed
|
|
|
20
20
|
export function readSheetChecks(runDir: string): {
|
|
21
21
|
lines: any[];
|
|
22
22
|
} | null;
|
|
23
|
-
/** the record's name in the run's own folder */
|
|
24
|
-
export const SHEET_CHECKS_FILE: "sheet-checks.json";
|
package/types/sheetblock.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export function sheetFoundWords(check: any, claims: unknown): string | null;
|
|
|
11
11
|
* The block of every job line whose step reads a sheet. A line qualifies when its green step carries `close.sheet`, or (with `csvRoles`) reads a CSV input and carries no
|
|
12
12
|
* older `close.columns` / `close.cited` check (then every guardrail is Not checked).
|
|
13
13
|
* @param {{declaration: any, lines: Array<{n: number, rules?: string[], guardrail?: string, rule?: string}>, csvRoles?: string[], record?: any}} o
|
|
14
|
-
* `record` = the
|
|
14
|
+
* `record` = the `sheet` section of `line-checks.json` (`{lines: [...]}`), only after a run
|
|
15
15
|
* @returns {Array<{line: number, guardrails: string[], checked: Array<{id: string, name: string, words: string, covers: string[], coversWords: string, text: string, ok?: boolean, found?: string}>, notChecked: string[]|'none'}>}
|
|
16
16
|
*/
|
|
17
17
|
export function sheetLineBlocks({ declaration, lines, csvRoles, record }: {
|
|
@@ -60,7 +60,7 @@ export function csvRolesOf(arbiter: any): string[];
|
|
|
60
60
|
*/
|
|
61
61
|
export function claimLines(claims: unknown): string[];
|
|
62
62
|
/**
|
|
63
|
-
* M10b am4: what an ask card shows for the claim boxes it was given. The step is the sheet step whose saved try (`sheet-checks.json`) holds exactly these claims; its block is
|
|
63
|
+
* M10b am4: what an ask card shows for the claim boxes it was given. The step is the sheet step whose saved try (the `sheet` section of `line-checks.json`) holds exactly these claims; its block is
|
|
64
64
|
* the Result tab's own (`sheetLineBlocks`, that try's verdicts), and `answer` is the claims value by value. Null when no saved try matches: the caller then keeps the old line.
|
|
65
65
|
* @param {{claims: unknown, declaration: any, lines: Array<{n: number, rules?: string[], guardrail?: string, rule?: string}>, csvRoles?: string[], record?: any}} o
|
|
66
66
|
* @returns {{block: ReturnType<typeof sheetLineBlocks>[number], answer: string[]}|null}
|
package/types/sheetrun.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export function sheetRolesOf(steps: any[]): string[];
|
|
|
7
7
|
*/
|
|
8
8
|
export function tableShaOfFrozen(runDir: string, name: string): string | null;
|
|
9
9
|
/**
|
|
10
|
-
* What a sheet check reads in a run: the run's OWN frozen copy of each sheet its checks name, as bareguard's table, and the `tableSha` recorded in `
|
|
10
|
+
* What a sheet check reads in a run: the run's OWN frozen copy of each sheet its checks name, as bareguard's table, and the `tableSha` recorded in `run.json` (inputs) at
|
|
11
11
|
* the run's start. The table is NOT compared here: bareguard compares it to the recorded sha when it checks (and stops if it differs).
|
|
12
12
|
* @param {string} runDir @param {any[]} checks the step's `close.sheet`
|
|
13
13
|
* @returns {{ok: true, tables: Record<string, {header: string[], rows: any[]}>, inputs: Array<{name: string, sha256: string}>}|{ok: false, red: string}}
|
package/types/summary-words.d.ts
CHANGED
|
@@ -40,7 +40,7 @@ export function catchUpWords(rec: any): "This run was a catch-up: it started mor
|
|
|
40
40
|
* ENDED / NEXT of a finished run. Every outcome the history row can hold has a fixed sentence; an unknown one gets an honest fixed fallback
|
|
41
41
|
* that names the code and guesses nothing. `null` when there is no ending (still running, waiting, or no history row and not died).
|
|
42
42
|
* @param {{outcome: string|null, died?: boolean, line: number|null, destination: string|null, canResume: boolean, home?: string}} f
|
|
43
|
-
* @returns {{reason: string, next: string}|null}
|
|
43
|
+
* @returns {{reason: string, next: string, rows?: Array<[string, string]>}|null}
|
|
44
44
|
*/
|
|
45
45
|
export function endedWords(f: {
|
|
46
46
|
outcome: string | null;
|
|
@@ -52,6 +52,7 @@ export function endedWords(f: {
|
|
|
52
52
|
}): {
|
|
53
53
|
reason: string;
|
|
54
54
|
next: string;
|
|
55
|
+
rows?: Array<[string, string]>;
|
|
55
56
|
} | null;
|
|
56
57
|
/** "MM/DD HH:MM", local time: the same form as the run cards' `rlShortDate`. @param {number|string} when epoch ms or an ISO string */
|
|
57
58
|
export function shortStamp(when: number | string): string;
|
package/types/thinking.d.ts
CHANGED
|
@@ -50,6 +50,17 @@ export function stepThinkingMode({ boxOn, attempt }: {
|
|
|
50
50
|
boxOn: boolean;
|
|
51
51
|
attempt: number;
|
|
52
52
|
}): "on" | "off";
|
|
53
|
+
/**
|
|
54
|
+
* M8 am7 item 2: the ONE owner of whether a step's try is handed the earlier runs' block. The places thinking switches on, but NOT the Chat "Thinking on" box:
|
|
55
|
+
* a retry (2nd or later try), a redo at an ask (numbered after the step's last try, so 2nd or later), and a rerun (the fresh run's first step, which starts
|
|
56
|
+
* from the human's rerun reason). A step's plain first try never gets it, whatever the box says.
|
|
57
|
+
* @param {{attempt: number, rerunReason: string|null}} a `rerunReason`: the reason this try starts from when it is a fresh run's first try, else null
|
|
58
|
+
* @returns {boolean}
|
|
59
|
+
*/
|
|
60
|
+
export function stepHintsWanted({ attempt, rerunReason }: {
|
|
61
|
+
attempt: number;
|
|
62
|
+
rerunReason: string | null;
|
|
63
|
+
}): boolean;
|
|
53
64
|
/** The sentence under a greyed "Thinking on" box (amendment 7 item 2). */
|
|
54
65
|
export const THINKING_FIXED_SAY: "can't change this for this model";
|
|
55
66
|
/** The note beside the Chat "Thinking on" box, before any draft, for a model bareagent has not checked (M4d am11 item 2). */
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {object} Paint
|
|
3
|
+
* @property {boolean} on
|
|
4
|
+
* @property {(s: string) => string} grey @property {(s: string) => string} green @property {(s: string) => string} yellow
|
|
5
|
+
* @property {(s: string) => string} red @property {(s: string) => string} cyan @property {(s: string) => string} boldCyan
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Colour is on only for a terminal: the stream says it is a TTY, `NO_COLOR` is empty/unset, and `TERM` is not `dumb`.
|
|
9
|
+
* @param {{isTTY?: boolean}|undefined} stream the output stream (process.stdout)
|
|
10
|
+
* @param {Record<string, string|undefined>} [env]
|
|
11
|
+
* @returns {Paint}
|
|
12
|
+
*/
|
|
13
|
+
export function makePaint(stream: {
|
|
14
|
+
isTTY?: boolean;
|
|
15
|
+
} | undefined, env?: Record<string, string | undefined>): Paint;
|
|
16
|
+
export namespace PLAIN {
|
|
17
|
+
let on: boolean;
|
|
18
|
+
let grey: (s: string) => string;
|
|
19
|
+
let green: (s: string) => string;
|
|
20
|
+
let yellow: (s: string) => string;
|
|
21
|
+
let red: (s: string) => string;
|
|
22
|
+
let cyan: (s: string) => string;
|
|
23
|
+
let boldCyan: (s: string) => string;
|
|
24
|
+
}
|
|
25
|
+
export type Paint = {
|
|
26
|
+
on: boolean;
|
|
27
|
+
grey: (s: string) => string;
|
|
28
|
+
green: (s: string) => string;
|
|
29
|
+
yellow: (s: string) => string;
|
|
30
|
+
red: (s: string) => string;
|
|
31
|
+
cyan: (s: string) => string;
|
|
32
|
+
boldCyan: (s: string) => string;
|
|
33
|
+
};
|