fwdloop 0.20.0 → 0.21.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/README.md +2 -0
- package/package.json +1 -1
- package/src/audit-fold.js +177 -0
- package/src/authoring.js +1 -1
- package/src/books.js +1 -1
- package/src/closers.js +49 -2
- package/src/ctx-tools.js +1 -1
- package/src/diary.js +49 -0
- package/src/flowmodel.js +42 -5
- package/src/model-step.js +103 -5
- package/src/panel/data.js +47 -8
- package/src/panel/index.html +222 -31
- package/src/primitives.js +44 -2
- package/src/runner.js +48 -12
- package/src/thinking.js +39 -0
- package/src/try-checks.js +62 -0
- package/src/types.js +1 -0
- package/types/audit-fold.d.ts +54 -0
- package/types/authoring.d.ts +1 -0
- package/types/books.d.ts +17 -0
- package/types/ctx-tools.d.ts +1 -0
- package/types/diary.d.ts +57 -0
- package/types/flowmodel.d.ts +25 -3
- package/types/model-step.d.ts +4 -1
- package/types/thinking.d.ts +31 -0
- package/types/try-checks.d.ts +55 -0
- package/types/types.d.ts +9 -0
package/src/panel/data.js
CHANGED
|
@@ -43,6 +43,11 @@ import {
|
|
|
43
43
|
NO_COPY_SAY, catchUpWords, endedLineWords, endedWords, needsLeftWords, nextInWords, nextTimeWords, scheduleAuditWords, scheduleBlockWords, scheduleFieldWords, scheduledNextFor, scheduledWords, startedWords,
|
|
44
44
|
} from '../summary-words.js';
|
|
45
45
|
import { MAX_STRUCTURE_RETRIES } from '../drafter.js';
|
|
46
|
+
import { thinkingRuleWords, thinkingTryWords } from '../thinking.js';
|
|
47
|
+
import { readRunThinking } from '../flowmodel.js';
|
|
48
|
+
import {
|
|
49
|
+
isTryRow, loadDiaries, deriveFold, cardLine, summaryLines,
|
|
50
|
+
} from '../audit-fold.js';
|
|
46
51
|
import {
|
|
47
52
|
runLiveness, booksFresh, readResumeLock,
|
|
48
53
|
} from '../liveness.js';
|
|
@@ -712,11 +717,6 @@ export function deriveStepTryMarks(closeClass, rows) {
|
|
|
712
717
|
return rows.map((r) => markForVerdict(r.verdict, closeClass));
|
|
713
718
|
}
|
|
714
719
|
|
|
715
|
-
/** A Stop's notes are not tries: the asked/not-honoured rows, and a `stopped` row that cut no try (no attempt number). */
|
|
716
|
-
function isTryRow(r) {
|
|
717
|
-
return r.verdict !== 'stop-asked' && r.verdict !== 'stop-not-honoured' && !(r.verdict === 'stopped' && !Number.isInteger(r.attempt));
|
|
718
|
-
}
|
|
719
|
-
|
|
720
720
|
/** The name of the one group for audit rows that name no step. */
|
|
721
721
|
const RUN_GROUP = 'run';
|
|
722
722
|
/** The one decider of a row's step name for the Audit tab: its step, else the run's own group name. */
|
|
@@ -1385,6 +1385,7 @@ function enrichAuditRows(rawRows) {
|
|
|
1385
1385
|
action: deriveAuditAction(row),
|
|
1386
1386
|
tokensDisplay: deriveAuditTokensDisplay(row),
|
|
1387
1387
|
toolsPhrase: deriveAuditToolsPhrase(row),
|
|
1388
|
+
thinkingPhrase: thinkingTryWords(row.thinking), // M4d am26: null for a row that kept no thinking record
|
|
1388
1389
|
atWhy: deriveAuditAtWhy(row),
|
|
1389
1390
|
blocked: isBlockedVerdict(row.verdict),
|
|
1390
1391
|
}));
|
|
@@ -1549,7 +1550,12 @@ export function getRunDetail({
|
|
|
1549
1550
|
// summed copy. A step with no audit rows at all (never attempted) has no
|
|
1550
1551
|
// entry here — its card falls back to "not started", same as before.
|
|
1551
1552
|
const auditGroupsByStep = {};
|
|
1552
|
-
|
|
1553
|
+
// M4d am29 items 5-6: the cards' marker and new line, and the summary's two lines, come from the SAME fold the Audit draws (src/audit-fold.js)
|
|
1554
|
+
const diaries = loadDiaries(run.runDir);
|
|
1555
|
+
for (const g of deriveAuditGroups(enrichAuditRows(ctx.auditRows))) {
|
|
1556
|
+
const fold = g.run ? null : deriveFold(g, diaries);
|
|
1557
|
+
auditGroupsByStep[g.step] = fold ? { ...g, fold } : g;
|
|
1558
|
+
}
|
|
1553
1559
|
|
|
1554
1560
|
let steps = null;
|
|
1555
1561
|
let stepsWhy = null;
|
|
@@ -1618,6 +1624,10 @@ export function getRunDetail({
|
|
|
1618
1624
|
// (never attempted) — every field below stays `null`/empty rather
|
|
1619
1625
|
// than a guessed 0, matching `deriveAuditGroups`'s own honesty
|
|
1620
1626
|
// rules exactly (it's the SAME group object).
|
|
1627
|
+
// M4d am29 item 6: `[model]` / `[human · ask]` (null for a step with no record), and the one new line (`—` with no record); a human step's time is the page's
|
|
1628
|
+
who: group?.fold?.who ?? null,
|
|
1629
|
+
newLine: cardLine(group?.fold ?? null),
|
|
1630
|
+
lastAnswerAt: group?.fold?.lastAnswer?.at ?? null,
|
|
1621
1631
|
groupState: group ? group.state : null,
|
|
1622
1632
|
timeMs: group ? group.timeMs : null,
|
|
1623
1633
|
cost: group ? group.cost : null,
|
|
@@ -1769,6 +1779,8 @@ export function getRunDetail({
|
|
|
1769
1779
|
model,
|
|
1770
1780
|
modelWhy,
|
|
1771
1781
|
spendSummary,
|
|
1782
|
+
// M4d am29 item 5: `calls: …` and `checks: …` (`—` for a run with no diaries)
|
|
1783
|
+
runLines: summaryLines(diaries),
|
|
1772
1784
|
wallMs,
|
|
1773
1785
|
wallMsWhy,
|
|
1774
1786
|
steps,
|
|
@@ -1918,6 +1930,27 @@ export function getDraftBlock(flowDir, runDir) {
|
|
|
1918
1930
|
};
|
|
1919
1931
|
}
|
|
1920
1932
|
|
|
1933
|
+
/**
|
|
1934
|
+
* M4d am29 items 4-6: put each step group's `fold` (src/audit-fold.js) on it, in place. An ask step's fold names the file it asks about
|
|
1935
|
+
* (the artifact its first `reads` entry made), read from the run's own saved job when it can be read; otherwise the Path shows `—`.
|
|
1936
|
+
* @param {any[]} groups @param {string} runDir @param {string} flowDir @param {{root: string, flow: string, catalogue?: any}} o
|
|
1937
|
+
*/
|
|
1938
|
+
function attachFolds(groups, runDir, flowDir, { root, flow, catalogue }) {
|
|
1939
|
+
const d = loadDiaries(runDir);
|
|
1940
|
+
let steps = null;
|
|
1941
|
+
if (catalogue) {
|
|
1942
|
+
const job = readRunJob({ root, name: flow, catalogue, runDir }).read;
|
|
1943
|
+
if (job.ok) steps = job.declaration.steps ?? [];
|
|
1944
|
+
}
|
|
1945
|
+
for (const g of groups) {
|
|
1946
|
+
if (g.run) continue;
|
|
1947
|
+
const decl = steps?.find((x) => x.emits === g.step);
|
|
1948
|
+
const read = Array.isArray(decl?.reads) ? decl.reads[0] : null;
|
|
1949
|
+
const fold = deriveFold(g, d, { about: typeof read === 'string' ? `artifacts/${read}.json` : null });
|
|
1950
|
+
if (fold) g.fold = fold;
|
|
1951
|
+
}
|
|
1952
|
+
}
|
|
1953
|
+
|
|
1921
1954
|
/**
|
|
1922
1955
|
* `GET /api/runs/:flow/:runId/audit` — the Audit/logs tab (M4a scope item
|
|
1923
1956
|
* 2): the raw `audit.jsonl` rows, scoped strictly to this run (each run's
|
|
@@ -1941,6 +1974,9 @@ export function getRunAudit({
|
|
|
1941
1974
|
// (`tokensDisplay`) and the new Time column's old-row "why" (`atWhy`) are
|
|
1942
1975
|
// likewise derived here, off this same row, never client-side.
|
|
1943
1976
|
const rows = enrichAuditRows(rawRows);
|
|
1977
|
+
// M4d am29 items 4 and 7: each step's fold is read off the run's files on disk ($0 replay); a step with no record (an older run) has none and draws as before
|
|
1978
|
+
const groups = deriveAuditGroups(rows);
|
|
1979
|
+
attachFolds(groups, run.runDir, run.flowDir, { root, flow, catalogue });
|
|
1944
1980
|
return {
|
|
1945
1981
|
flow,
|
|
1946
1982
|
runId,
|
|
@@ -1948,7 +1984,7 @@ export function getRunAudit({
|
|
|
1948
1984
|
// hamr's 2026-09-27 exit-check review #1: the Audit tab's grouped-by-
|
|
1949
1985
|
// step header pieces, computed here off these SAME enriched rows —
|
|
1950
1986
|
// never a second, client-side re-grouping.
|
|
1951
|
-
groups
|
|
1987
|
+
groups,
|
|
1952
1988
|
draft: getDraftBlock(run.flowDir, run.runDir),
|
|
1953
1989
|
// M11 am11 items 3-4: the one row that says why the card left Needs you (by your Remove, or after 7 days); words: src/summary-words.js
|
|
1954
1990
|
needsLeft: catalogue ? needsLeftWords(getRunNeeds({
|
|
@@ -1960,12 +1996,13 @@ export function getRunAudit({
|
|
|
1960
1996
|
if (!t) return null; // no schedule now: scheduleAuditWords still answers for a cancelled job that has am16 rows (M9 am18), else null
|
|
1961
1997
|
const rec = readTriggerRecord(run.runDir);
|
|
1962
1998
|
const at = firstPidStartedAt(run.runDir) ?? (rec && typeof rec.at === 'string' ? rec.at : null); // the fire's own stamp when the run kept no pid row yet
|
|
1963
|
-
|
|
1999
|
+
const sched = scheduleAuditWords({
|
|
1964
2000
|
trigger: t.trigger, runId, from: t.from ?? null, rec, startMs: at === null || Number.isNaN(Date.parse(at)) ? null : Date.parse(at),
|
|
1965
2001
|
block: scheduleBlockOf({ root, flowDir: run.flowDir, flow, catalogue, t, home, now }),
|
|
1966
2002
|
running: jobHasRunningRun({ root, flow, catalogue, resumeAttempt, startingRun }),
|
|
1967
2003
|
fires: Array.isArray(t.allFires) ? t.allFires : [],
|
|
1968
2004
|
});
|
|
2005
|
+
return sched === null ? null : { ...sched, word: SIGN_WORDS[sched.sign] ?? null }; // M9 am23: the header's word, from the one sign->word table
|
|
1969
2006
|
})(),
|
|
1970
2007
|
empty: rows.length === 0,
|
|
1971
2008
|
why: rows.length === 0 ? 'audit.jsonl is empty or missing — no attempt has been made yet' : null,
|
|
@@ -2068,6 +2105,8 @@ export function getRunJob({
|
|
|
2068
2105
|
trigger: f && f.trigger ? f.trigger : null, from: f?.from ?? null, model: f?.model ?? null, destination: f?.destination ?? null, inputs: f?.inputs ?? null, home,
|
|
2069
2106
|
});
|
|
2070
2107
|
})(),
|
|
2108
|
+
// M4d am28: the run's rule from its own thinking.json; a run with none (before am25) reads `—` (thinkingRuleWords(null)); the row always shows
|
|
2109
|
+
thinkingRule: thinkingRuleWords(readRunThinking(run.runDir)),
|
|
2071
2110
|
jobFrom: copy.present ? 'run' : 'current',
|
|
2072
2111
|
jobFromWhy: copy.present ? null : NO_JOB_COPY_WORDS,
|
|
2073
2112
|
model,
|