bareloop 0.54.1 → 0.56.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 +122 -0
- package/bareloop.context.md +67 -6
- package/package.json +3 -3
- package/src/authorflow.js +217 -238
- package/src/authoring.js +22 -6
- package/src/authorjob.js +138 -30
- package/src/authorreadout.js +15 -4
- package/src/authorrun.js +13 -4
- package/src/authorscout.js +9 -6
- package/src/behaviour.js +14 -0
- package/src/blockasks.js +43 -0
- package/src/cardschedule.js +42 -0
- package/src/checkblock.js +772 -0
- package/src/checklist.js +128 -0
- package/src/checkpick.js +294 -0
- package/src/checksuggest.js +28 -0
- package/src/checkwords.js +27 -0
- package/src/cli.js +1 -1
- package/src/config.js +24 -1
- package/src/declaredclose.js +30 -1
- package/src/destpoint.js +151 -0
- package/src/draftspend.js +85 -0
- package/src/facts.js +8 -1
- package/src/factwords.js +14 -1
- package/src/fitcheck.js +5 -3
- package/src/job.js +81 -1
- package/src/jobblock.js +9 -0
- package/src/labelscan.js +11 -0
- package/src/launcher.js +3 -2
- package/src/mcpchecks.js +52 -0
- package/src/mcppick.js +36 -0
- package/src/mcpsources.js +77 -0
- package/src/mcpuse.js +97 -0
- package/src/natural.js +23 -0
- package/src/pagemap.js +20 -5
- package/src/panel/authorroutes.js +105 -18
- package/src/panel/authorsession.js +293 -44
- package/src/panel/index.html +873 -41
- package/src/panel/jobgrid.js +117 -0
- package/src/panel/jobplan.js +103 -35
- package/src/panel/scheduler.js +80 -13
- package/src/panel/schedules.js +189 -28
- package/src/panel/schedulestart.js +44 -13
- package/src/panel/server.js +471 -39
- package/src/panel/settingsroutes.js +133 -3
- package/src/panel/status.js +19 -1
- package/src/panel/tickets.js +44 -0
- package/src/pickrecord.js +163 -0
- package/src/placerule.js +355 -0
- package/src/plan.js +31 -2
- package/src/planrun.js +71 -15
- package/src/prcheckout.js +259 -0
- package/src/promptregisters.js +11 -0
- package/src/questionbox.js +112 -0
- package/src/readshim.js +3 -2
- package/src/revises.js +56 -0
- package/src/rowedit.js +115 -0
- package/src/rubricstep.js +265 -132
- package/src/run.js +19 -2
- package/src/runexport.js +2 -0
- package/src/runlist.js +3 -2
- package/src/schedulewords.js +46 -4
- package/src/source.js +81 -7
- package/src/stepmcp.js +86 -0
- package/src/ticket.js +113 -0
- package/src/ticketfilter.js +76 -0
- package/src/ticketlabels.js +79 -0
- package/src/ticketmcp.js +111 -0
- package/src/ticketnext.js +35 -0
- package/src/ticketrepo.js +98 -0
- package/src/ticketschedule.js +32 -0
- package/src/ticketshape.js +45 -0
- package/src/tools.js +9 -0
- package/src/trigger.js +14 -2
- package/src/triggerclock.js +7 -3
- package/src/triggerfiles.js +19 -11
- package/src/triggertickets.js +244 -0
- package/src/userrun.js +191 -10
- package/src/validate.js +3 -1
- package/src/worktree.js +43 -1
- package/types/authorflow.d.ts +86 -93
- package/types/authorjob.d.ts +35 -4
- package/types/authorreadout.d.ts +4 -3
- package/types/authorscout.d.ts +4 -2
- package/types/behaviour.d.ts +12 -0
- package/types/blockasks.d.ts +37 -0
- package/types/cardschedule.d.ts +24 -0
- package/types/checkblock.d.ts +361 -0
- package/types/checklist.d.ts +134 -0
- package/types/checkpick.d.ts +160 -0
- package/types/checksuggest.d.ts +30 -0
- package/types/checkwords.d.ts +14 -0
- package/types/config.d.ts +7 -0
- package/types/declaredclose.d.ts +4 -0
- package/types/destpoint.d.ts +89 -0
- package/types/draftspend.d.ts +37 -0
- package/types/factwords.d.ts +7 -0
- package/types/fitcheck.d.ts +7 -1
- package/types/job.d.ts +13 -0
- package/types/jobblock.d.ts +9 -0
- package/types/labelscan.d.ts +7 -0
- package/types/launcher.d.ts +2 -2
- package/types/mcpchecks.d.ts +8 -0
- package/types/mcppick.d.ts +33 -0
- package/types/mcpsources.d.ts +51 -0
- package/types/mcpuse.d.ts +15 -0
- package/types/natural.d.ts +2 -0
- package/types/pagemap.d.ts +6 -1
- package/types/panel/authorroutes.d.ts +11 -2
- package/types/panel/authorsession.d.ts +69 -3
- package/types/panel/jobgrid.d.ts +405 -0
- package/types/panel/jobplan.d.ts +55 -11
- package/types/panel/scheduler.d.ts +7 -2
- package/types/panel/schedules.d.ts +124 -4
- package/types/panel/schedulestart.d.ts +21 -3
- package/types/panel/server.d.ts +432 -10
- package/types/panel/settingsroutes.d.ts +4 -2
- package/types/panel/status.d.ts +16 -2
- package/types/panel/tickets.d.ts +61 -0
- package/types/pickrecord.d.ts +100 -0
- package/types/placerule.d.ts +194 -0
- package/types/plan.d.ts +1 -0
- package/types/prcheckout.d.ts +151 -0
- package/types/questionbox.d.ts +87 -0
- package/types/readshim.d.ts +4 -3
- package/types/revises.d.ts +23 -0
- package/types/rowedit.d.ts +32 -0
- package/types/rubricstep.d.ts +100 -48
- package/types/run.d.ts +27 -1
- package/types/runlist.d.ts +6 -3
- package/types/schedulewords.d.ts +29 -2
- package/types/source.d.ts +40 -4
- package/types/stepmcp.d.ts +40 -0
- package/types/ticket.d.ts +114 -0
- package/types/ticketfilter.d.ts +34 -0
- package/types/ticketlabels.d.ts +44 -0
- package/types/ticketmcp.d.ts +84 -0
- package/types/ticketnext.d.ts +33 -0
- package/types/ticketrepo.d.ts +118 -0
- package/types/ticketschedule.d.ts +21 -0
- package/types/ticketshape.d.ts +37 -0
- package/types/tools.d.ts +1 -0
- package/types/trigger.d.ts +9 -1
- package/types/triggerclock.d.ts +6 -2
- package/types/triggerfiles.d.ts +13 -5
- package/types/triggertickets.d.ts +110 -0
- package/types/userrun.d.ts +50 -0
- package/types/validate.d.ts +1 -0
- package/types/worktree.d.ts +19 -0
package/src/panel/server.js
CHANGED
|
@@ -29,6 +29,7 @@ import {
|
|
|
29
29
|
readFileSync, existsSync, readdirSync, lstatSync, realpathSync,
|
|
30
30
|
} from 'node:fs';
|
|
31
31
|
import { createHash } from 'node:crypto';
|
|
32
|
+
import { execFileSync } from 'node:child_process';
|
|
32
33
|
import {
|
|
33
34
|
dirname, join, basename, relative, isAbsolute, sep,
|
|
34
35
|
} from 'node:path';
|
|
@@ -38,24 +39,27 @@ import { checkExportable } from '../runexport.js';
|
|
|
38
39
|
import { sourceNearSpine, signedSpecForRun } from '../runfiles.js';
|
|
39
40
|
import { webFetchState } from '../source.js';
|
|
40
41
|
import { isWebUrl } from '../pagefetch.js';
|
|
41
|
-
import { draftingPartFor, sessionDirForRow, readDraftSteps } from '../draftspend.js';
|
|
42
|
+
import { draftingPartFor, sessionDirForRow, readDraftSteps, readDraftLedger } from '../draftspend.js';
|
|
42
43
|
import { readingOfQuestion, isAgree } from '../pagemap.js';
|
|
43
44
|
import {
|
|
44
45
|
replayOne, parseJsonl, resolveSiblings, isSidecarByName,
|
|
45
46
|
} from '../replayio.js';
|
|
46
|
-
import { summarizeForAllLine, auditWindowsOf } from '../replay.js';
|
|
47
|
+
import { summarizeForAllLine, auditWindowsOf, replayRun } from '../replay.js';
|
|
47
48
|
import { legsOf, legsWallMs, stopFilePath, capKindOf } from '../legs.js';
|
|
48
49
|
import { chainSpend } from '../ledger.js';
|
|
49
|
-
import { runBehaviour } from '../behaviour.js';
|
|
50
|
+
import { runBehaviour, writesBlocked } from '../behaviour.js';
|
|
50
51
|
import { SPEND_RECORD_TYPES, floorsFromRecords } from '../ledger.js';
|
|
51
|
-
import { jobSpecHash, workflowKey } from '../job.js';
|
|
52
|
+
import { jobSpecHash, workflowKey, flowTypeOf, FLOW_TYPE_LABELS } from '../job.js';
|
|
52
53
|
import { attachMemos, learningsHanded, attachLearnings } from './handed.js';
|
|
54
|
+
import { placeRuleLines } from '../placerule.js';
|
|
53
55
|
import { confirmProtections } from '../authorflow.js';
|
|
54
56
|
import { createScheduleDoor } from './schedules.js';
|
|
57
|
+
import { buildJobGrid } from './jobgrid.js';
|
|
58
|
+
import { TICKET_LOOK_MS } from '../triggertickets.js';
|
|
55
59
|
import { createStarter } from './schedulestart.js';
|
|
56
60
|
import { createScheduler } from './scheduler.js';
|
|
57
61
|
import {
|
|
58
|
-
catchUpWords, dateTimeWords, jobScheduleWords, lowerFirst, scheduleSignFor, scheduledWords, sectionThisRunWords, skippedWords, startedAuditWords, startedWords, triesTailWords, SCHEDULE_WORDS,
|
|
62
|
+
catchUpWords, dateTimeWords, jobScheduleWords, lowerFirst, scheduleCardFill, scheduleSignFor, scheduledWords, sectionThisRunWords, skippedWords, startedAuditWords, startedWords, triesTailWords, SCHEDULE_WORDS,
|
|
59
63
|
} from '../schedulewords.js';
|
|
60
64
|
import { doorWaiting, heldScheduled } from '../reviewdoor.js';
|
|
61
65
|
import { createAuthorRoutes, mintToken, checkHostGuard, panelMoney2 } from './authorroutes.js';
|
|
@@ -70,13 +74,15 @@ import { SHAPES } from '../providershapes.js';
|
|
|
70
74
|
import { resolveProvider } from '../providers.js';
|
|
71
75
|
import { readResume, checkpointAgeGate, CHECKPOINT_OUTCOMES } from '../reuse.js';
|
|
72
76
|
import {
|
|
73
|
-
statusFor, partStatusFor, GOAL_MET_LINE, doorViewOf, ACTOR_MARKER, DOOR_WORDS, isReusableGreen,
|
|
77
|
+
statusFor, partStatusFor, GOAL_MET_LINE, doorViewOf, ACTOR_MARKER, DOOR_WORDS, isReusableGreen, STATUS,
|
|
74
78
|
} from './status.js';
|
|
75
79
|
import { thinkingJobText } from '../thinking.js';
|
|
80
|
+
import { ticketFilterWords } from '../ticketfilter.js';
|
|
81
|
+
import { filterUnsure } from '../ticketlabels.js';
|
|
76
82
|
import { judgedFilesOf, lineRules, stepFileRel, proseNotCheckedItems } from '../rubricstep.js';
|
|
77
83
|
import { factPartOf, factSentence, ruleWords, moneyAs } from '../facts.js';
|
|
78
84
|
import { createSettingsRoutes } from './settingsroutes.js';
|
|
79
|
-
import { planFromSpec } from './jobplan.js';
|
|
85
|
+
import { planFromSpec, auditChecksOf } from './jobplan.js';
|
|
80
86
|
import { stageQuestionsByName } from '../stagewords.js';
|
|
81
87
|
|
|
82
88
|
const HERE = dirname(fileURLToPath(import.meta.url));
|
|
@@ -126,10 +132,10 @@ export const DEFAULT_PORT = 4700;
|
|
|
126
132
|
* running attempt and an archived spine that never reached its own end are
|
|
127
133
|
* the same fact from this read-only side: no verdict has been recorded yet.
|
|
128
134
|
* @param {string|null} outcome
|
|
129
|
-
* @returns {'✓'|'✗'|'■'|'▶'}
|
|
135
|
+
* @returns {'✓'|'✗'|'■'|'▶'|'–'}
|
|
130
136
|
*/
|
|
131
137
|
export function glyphForOutcome(outcome) {
|
|
132
|
-
return /** @type {'✓'|'✗'|'■'|'▶'} */ (statusFor({ outcome }).sign);
|
|
138
|
+
return /** @type {'✓'|'✗'|'■'|'▶'|'–'} */ (statusFor({ outcome }).sign);
|
|
133
139
|
}
|
|
134
140
|
|
|
135
141
|
/**
|
|
@@ -815,14 +821,15 @@ function startingStub(row) {
|
|
|
815
821
|
/**
|
|
816
822
|
* A run that REFUSED before it started (its refetch of a web input was refused, run mvez8s54 shape): listed, settled at $0, no spine.
|
|
817
823
|
* The status word is the table's `failed` (statusFor: "refusals, instrument stops -> failed"); the plain words ride on `endedLine`.
|
|
818
|
-
* @param {{ runid: string, job: string, at: string, via: string }} row @param {string} words
|
|
824
|
+
* @param {{ runid: string, job: string, at: string, via: string }} row @param {string} words @param {'refused-before-start'|'skipped'} [outcome] @param {boolean} [reuseOffered] the Run tab's [Reuse workflow] shows (the run never ran its plan: {@link neverRanPlan}); `skipped` (R5): a ticket the job's filter did not let through, the same no-spine shape with its own status word
|
|
819
825
|
* @returns {any}
|
|
820
826
|
*/
|
|
821
|
-
function refusedStub(row, words) {
|
|
827
|
+
function refusedStub(row, words, outcome = 'refused-before-start', reuseOffered = false) {
|
|
828
|
+
const status = statusFor({ outcome });
|
|
822
829
|
return {
|
|
823
|
-
runid: row.runid, job: row.job, at: row.at, via: row.via, fileMissing: false, refused:
|
|
824
|
-
died: false, glyph:
|
|
825
|
-
outcome
|
|
830
|
+
runid: row.runid, job: row.job, at: row.at, via: row.via, fileMissing: false, refused: outcome !== 'skipped', skipped: outcome === 'skipped', live: false, needs: null, stoppedAt: null,
|
|
831
|
+
died: false, glyph: status.sign, status,
|
|
832
|
+
outcome, endedLine: words, ended: null, reuseOffered, resume: null, checkType: 'unknown', checkTypeTitle: null, model: null,
|
|
826
833
|
spend: '$0', wall: '', date: typeof row.at === 'string' ? row.at.slice(0, 10) : null, spentUsd: 0, spendComplete: true,
|
|
827
834
|
spendFloorUsd: null, wallFloorMs: null, draftSpentUsd: null, draftSpendComplete: null, budgetUsd: null, steps: [], parts: [],
|
|
828
835
|
};
|
|
@@ -834,6 +841,27 @@ function refusalWordsOf(events, row) {
|
|
|
834
841
|
return e && typeof e.words === 'string' && e.words !== '' ? e.words : null;
|
|
835
842
|
}
|
|
836
843
|
|
|
844
|
+
/**
|
|
845
|
+
* R5 (piece 2): the plain words of a run a Tickets job's filter SKIPPED at run start (leg 1), or null. Same home as a refusal: one `settled` event on the run's row, no spine.
|
|
846
|
+
* @param {any[]} events @param {{runid: string}} row
|
|
847
|
+
*/
|
|
848
|
+
function skipWordsOf(events, row) {
|
|
849
|
+
const e = events.find((x) => x && x.type === 'settled' && x.runid === row.runid && x.reason === 'skipped' && !(x.leg > 1));
|
|
850
|
+
return e && typeof e.words === 'string' && e.words !== '' ? e.words : null;
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
/**
|
|
854
|
+
* R9 (9b.2, fwd 7a98141): did this run END BEFORE ITS FIRST STEP, at $0? The rule, from recorded facts only: the run has NO spine on disk, and its row carries a leg-1 `settled` event
|
|
855
|
+
* that is `refused before start` or `skipped` with `spentUsd` exactly 0 and `spendComplete` not false. Such a run never ran its plan (no step, no model call), so Reuse workflow with
|
|
856
|
+
* the job unchanged signs and goes with the signed job; a red run that DID run (it has a spine) still drafts.
|
|
857
|
+
* @param {any[]} events @param {{runid: string, spine: string}} row
|
|
858
|
+
*/
|
|
859
|
+
export function neverRanPlan(events, row) {
|
|
860
|
+
if (existsSync(row.spine)) return false;
|
|
861
|
+
return events.some((x) => x && x.type === 'settled' && x.runid === row.runid && !(x.leg > 1)
|
|
862
|
+
&& (x.reason === 'refused before start' || x.reason === 'skipped') && x.spentUsd === 0 && x.spendComplete !== false);
|
|
863
|
+
}
|
|
864
|
+
|
|
837
865
|
/**
|
|
838
866
|
* RULED 2026-10-15 (Remove from Needs you): the ONE place a run's Needs-you state is decided. `Accept` (a live door) is never removable and never ages out.
|
|
839
867
|
* A `Resume` tag leaves when the person removed it AFTER (or at) the stop it is for — a removal covers only the ending it was made on, so a later stop
|
|
@@ -865,7 +893,9 @@ export function needsStateFor(f) {
|
|
|
865
893
|
function summarizeRow(row, nowMs = Date.now(), removals = undefined, events = []) {
|
|
866
894
|
if (!existsSync(row.spine)) {
|
|
867
895
|
const refusal = refusalWordsOf(events, row);
|
|
868
|
-
if (refusal !== null) return refusedStub(row, refusal);
|
|
896
|
+
if (refusal !== null) return refusedStub(row, refusal, 'refused-before-start', neverRanPlan(events, row));
|
|
897
|
+
const skipped = skipWordsOf(events, row);
|
|
898
|
+
if (skipped !== null) return refusedStub(row, skipped, 'skipped', neverRanPlan(events, row));
|
|
869
899
|
if (runIsAlive(row)) return startingStub(row);
|
|
870
900
|
return {
|
|
871
901
|
runid: row.runid, job: row.job, at: row.at, via: row.via, fileMissing: true, live: false, needs: null, stoppedAt: null,
|
|
@@ -1386,11 +1416,310 @@ function cellText(v) {
|
|
|
1386
1416
|
return '';
|
|
1387
1417
|
}
|
|
1388
1418
|
|
|
1419
|
+
/**
|
|
1420
|
+
* Which Result tab a run wears: `'rubric'` (a soft-green run whose signed close has a rubric-step stage: the page-reading tab, unchanged), `'generic'`
|
|
1421
|
+
* (any other run that ENDED, green or failed: R7b item 4), or `null` (not ended yet, or died with no `job-end`). ONE owner for the tab's gate
|
|
1422
|
+
* ({@link getRunDetailBody}'s `hasResult`) and the route.
|
|
1423
|
+
* @param {{ at?: string }} row @param {any[]} records @param {any} spec
|
|
1424
|
+
* @returns {'rubric'|'generic'|null}
|
|
1425
|
+
*/
|
|
1426
|
+
function resultKindOf(row, records, spec) {
|
|
1427
|
+
const start = records.findLast((r) => r && r.type === 'job-start');
|
|
1428
|
+
if (checkTypeLabel(typeof start?.verdictType === 'string' ? start.verdictType : null, row.at ?? null) === 'rubric' && rubricStagesOf(spec).length > 0) return 'rubric';
|
|
1429
|
+
return records.some((r) => r && r.type === 'job-end') ? 'generic' : null;
|
|
1430
|
+
}
|
|
1431
|
+
|
|
1432
|
+
/** the words of the work box and the diff box, code-owned (one spelling) */
|
|
1433
|
+
const RESULT_WORK_NOTE = 'shown as text; the merge is yours, no button runs it.';
|
|
1434
|
+
|
|
1435
|
+
/**
|
|
1436
|
+
* the allowed folder of a write fence entry in plain words: `src/**` is `src/`; an entry this cannot read as a folder or file is `null`
|
|
1437
|
+
* @param {string} entry
|
|
1438
|
+
*/
|
|
1439
|
+
function scopePrefixOf(entry) {
|
|
1440
|
+
const m = /^(.*?)(?:\/\*\*?)?$/.exec(entry);
|
|
1441
|
+
const base = m ? m[1] : entry;
|
|
1442
|
+
return base !== '' && !/[*?[\]{}]/.test(base) ? base : null;
|
|
1443
|
+
}
|
|
1444
|
+
|
|
1445
|
+
/**
|
|
1446
|
+
* The generic Result tab's "What changed" box, from the spine's own `attempt-diff` records (they survive a deleted branch): the LAST edit's diff, every
|
|
1447
|
+
* edit behind a fold, and the header numbers counted over every diff the records hold. `null` when the run recorded no edit at all.
|
|
1448
|
+
* @param {any[]} records @param {string[]|null} writeScope
|
|
1449
|
+
*/
|
|
1450
|
+
function changedOf(records, writeScope) {
|
|
1451
|
+
const diffs = records.filter((r) => r && r.type === 'attempt-diff' && Array.isArray(r.files));
|
|
1452
|
+
if (diffs.length === 0) return null;
|
|
1453
|
+
const edits = diffs.map((r, i) => ({
|
|
1454
|
+
n: i + 1,
|
|
1455
|
+
step: typeof r.step === 'string' ? r.step : null,
|
|
1456
|
+
files: r.files.filter((/** @type {any} */ f) => f && typeof f.path === 'string').map((/** @type {any} */ f) => ({
|
|
1457
|
+
path: f.path, diff: typeof f.diff === 'string' ? f.diff : '',
|
|
1458
|
+
cut: f.truncated === true ? (Number.isInteger(f.cutLines) ? f.cutLines : 0) : null,
|
|
1459
|
+
})),
|
|
1460
|
+
binary: Array.isArray(r.binary) ? r.binary.filter((/** @type {any} */ b) => typeof b === 'string') : [],
|
|
1461
|
+
}));
|
|
1462
|
+
const paths = [...new Set(edits.flatMap((e) => [...e.files.map((f) => f.path), ...e.binary]))];
|
|
1463
|
+
let plus = 0; let minus = 0; let anyCut = false;
|
|
1464
|
+
for (const e of edits) {
|
|
1465
|
+
for (const f of e.files) {
|
|
1466
|
+
if (f.cut !== null) anyCut = true;
|
|
1467
|
+
for (const line of f.diff.split('\n')) {
|
|
1468
|
+
if (line.startsWith('+') && !line.startsWith('+++')) plus += 1;
|
|
1469
|
+
else if (line.startsWith('-') && !line.startsWith('---')) minus += 1;
|
|
1470
|
+
}
|
|
1471
|
+
}
|
|
1472
|
+
}
|
|
1473
|
+
const shown = paths.length > 4 ? `${paths.slice(0, 4).join(', ')} and ${paths.length - 4} more` : paths.join(', ');
|
|
1474
|
+
const head = `${paths.length} file${paths.length === 1 ? '' : 's'} · ${shown} · +${plus} −${minus} lines over ${edits.length} edit${edits.length === 1 ? '' : 's'}`;
|
|
1475
|
+
const last = edits[edits.length - 1];
|
|
1476
|
+
const cutLines = last.files.reduce((a, f) => a + (f.cut ?? 0), 0);
|
|
1477
|
+
const note = [
|
|
1478
|
+
edits.length > 1 ? 'the last edit only' : null,
|
|
1479
|
+
last.files.some((f) => f.cut !== null) ? `${cutLines} more line${cutLines === 1 ? '' : 's'} cut` : null,
|
|
1480
|
+
].filter(Boolean).join('; ');
|
|
1481
|
+
// the fence line: every path the run wrote inside what was allowed, or what lay outside
|
|
1482
|
+
let scopeLine = null;
|
|
1483
|
+
const prefixes = writeScope ? writeScope.map(scopePrefixOf) : [];
|
|
1484
|
+
if (writeScope && writeScope.length > 0 && prefixes.every((x) => x !== null)) {
|
|
1485
|
+
const inside = (/** @type {string} */ p) => prefixes.some((x) => p === x || p.startsWith(`${x}/`));
|
|
1486
|
+
const outside = paths.filter((p) => !inside(p));
|
|
1487
|
+
const allowed = prefixes.map((x) => (writeScope.includes(`${x}/**`) || writeScope.includes(`${x}/*`) ? `${x}/` : x)).join(', ');
|
|
1488
|
+
scopeLine = outside.length === 0
|
|
1489
|
+
? `only ${allowed} was allowed; the run wrote ${paths.length} file${paths.length === 1 ? '' : 's'}, no other.`
|
|
1490
|
+
: `only ${allowed} was allowed, but the run wrote ${outside.join(', ')}.`;
|
|
1491
|
+
}
|
|
1492
|
+
return {
|
|
1493
|
+
head, files: paths.length, paths, plus, minus, edits: edits.length, anyCut,
|
|
1494
|
+
last: { files: last.files.map((f) => ({ path: f.path, diff: f.diff })), note: note === '' ? null : `...(${note})` },
|
|
1495
|
+
all: edits.map((e) => ({ n: e.n, step: e.step, files: e.files.map((f) => ({ path: f.path, diff: f.diff, cutNote: f.cut === null ? null : `...(${f.cut} more line${f.cut === 1 ? '' : 's'} cut)` })) })),
|
|
1496
|
+
foldWords: `show every edit of the run (${edits.length})`,
|
|
1497
|
+
scopeLine,
|
|
1498
|
+
};
|
|
1499
|
+
}
|
|
1500
|
+
|
|
1501
|
+
/**
|
|
1502
|
+
* The checks a run's STEPS ran in the loop, for a run the outer close never reached (a strike-ladder cap-halt, a stop): read through the Audit tab's own data owner
|
|
1503
|
+
* (`replayRun` parts, worded by {@link enrichPartsWithStageKind} / {@link tryChecksOf}), never a second reader of `check-run` / `exit-eval` records. Each check's standing is its LAST graded
|
|
1504
|
+
* try; a name a later step ran again takes that later standing. The in-loop record carries no structured number, so `value`/`baseline` are null (no figure is parsed out of the gap prose);
|
|
1505
|
+
* `tries` is how many times the step that ran it tried. `null` when no step ran any check.
|
|
1506
|
+
* @param {any[]} records @param {any} spec
|
|
1507
|
+
*/
|
|
1508
|
+
function stepChecksOf(records, spec) {
|
|
1509
|
+
/** @type {any[]|null|undefined} */
|
|
1510
|
+
let parts;
|
|
1511
|
+
try { parts = enrichPartsWithStageKind(replayRun(records).parts, stageKindMetaFromSpec(spec), spec); } catch { return null; }
|
|
1512
|
+
/** @type {Map<string, any>} */
|
|
1513
|
+
const byName = new Map();
|
|
1514
|
+
for (const p of parts ?? []) {
|
|
1515
|
+
if (!p || p.kind !== 'step' || !Array.isArray(p.attempts)) continue;
|
|
1516
|
+
const graded = p.attempts.filter((/** @type {any} */ a) => Array.isArray(a.checks) && a.checks.length > 0);
|
|
1517
|
+
const last = graded.at(-1);
|
|
1518
|
+
if (!last) continue;
|
|
1519
|
+
for (const c of last.checks) {
|
|
1520
|
+
byName.set(c.name, {
|
|
1521
|
+
name: c.name, question: typeof c.question === 'string' && c.question ? c.question : null, passed: c.pass === true,
|
|
1522
|
+
status: c.pass === true ? STATUS.passed : STATUS.failed, value: null, baseline: null, direction: null, baselineKind: null,
|
|
1523
|
+
notes: null, tries: p.attempts.length,
|
|
1524
|
+
});
|
|
1525
|
+
}
|
|
1526
|
+
}
|
|
1527
|
+
const stages = [...byName.values()];
|
|
1528
|
+
if (stages.length === 0) return null;
|
|
1529
|
+
const ok = stages.filter((s) => s.passed).length;
|
|
1530
|
+
return {
|
|
1531
|
+
head: `${ok} of ${stages.length} passed · the steps ran them; the close never ran`,
|
|
1532
|
+
passed: ok, total: stages.length, allPassed: ok === stages.length, stages, notes: [],
|
|
1533
|
+
};
|
|
1534
|
+
}
|
|
1535
|
+
|
|
1536
|
+
/**
|
|
1537
|
+
* The generic Result tab's "The checks" box, from the run's LAST `outer-close` record: each stage's plain question ({@link stageQuestionText}'s one
|
|
1538
|
+
* owner, through the spec's own declaration), its pass/fail word from the status table, and the number the close read. A run the close never reached
|
|
1539
|
+
* falls back to the checks its steps ran ({@link stepChecksOf}); `null` when neither exists.
|
|
1540
|
+
* @param {any[]} records @param {any} spec
|
|
1541
|
+
*/
|
|
1542
|
+
function checksOf(records, spec) {
|
|
1543
|
+
const oc = records.findLast((r) => r && r.type === 'outer-close' && Array.isArray(r.stages));
|
|
1544
|
+
if (!oc) return stepChecksOf(records, spec);
|
|
1545
|
+
const kindMeta = stageKindMetaFromSpec(spec);
|
|
1546
|
+
const stages = oc.stages.filter((/** @type {any} */ s) => s && typeof s.name === 'string').map((/** @type {any} */ raw) => {
|
|
1547
|
+
const s = attachStageKind(raw, kindMeta);
|
|
1548
|
+
const passed = s.verdict === 'satisfied';
|
|
1549
|
+
return {
|
|
1550
|
+
name: s.name, question: typeof s.question === 'string' && s.question ? s.question : null, passed,
|
|
1551
|
+
status: passed ? STATUS.passed : STATUS.failed,
|
|
1552
|
+
value: typeof s.value === 'number' ? s.value : null, baseline: typeof s.baseline === 'number' ? s.baseline : null,
|
|
1553
|
+
direction: s.direction ?? null, baselineKind: s.baselineKind ?? null,
|
|
1554
|
+
notes: typeof s.notes === 'string' && s.notes !== '' ? s.notes : null,
|
|
1555
|
+
};
|
|
1556
|
+
});
|
|
1557
|
+
const ok = stages.filter((/** @type {any} */ s) => s.passed).length;
|
|
1558
|
+
return {
|
|
1559
|
+
head: `${ok} of ${stages.length} passed · the close ran them after the worker stopped`,
|
|
1560
|
+
passed: ok, total: stages.length, allPassed: ok === stages.length, stages,
|
|
1561
|
+
notes: stages.filter((/** @type {any} */ s) => s.notes).map((/** @type {any} */ s) => ({ name: s.name, text: s.notes })),
|
|
1562
|
+
};
|
|
1563
|
+
}
|
|
1564
|
+
|
|
1565
|
+
/**
|
|
1566
|
+
* The generic Result tab's "The work" box: the run's work branch, but ONLY while that branch still exists in the person's repo (asked of git itself).
|
|
1567
|
+
* The merge and delete lines are TEXT; nothing runs them. `null` when the run has no work branch, no repo is known, or the branch is gone.
|
|
1568
|
+
* @param {{ spine: string }} row @param {any[]} records
|
|
1569
|
+
*/
|
|
1570
|
+
function workOf(row, records) {
|
|
1571
|
+
const wb = records.findLast((r) => r && r.type === 'work-branch' && typeof r.branch === 'string') ?? null;
|
|
1572
|
+
const wt = worktreeOfRun(row, records);
|
|
1573
|
+
if (!wb || !wt || !wt.branch) return null;
|
|
1574
|
+
/** @type {string} */
|
|
1575
|
+
let final;
|
|
1576
|
+
try {
|
|
1577
|
+
final = execFileSync('git', ['-C', wt.repo, 'rev-parse', '--verify', '--quiet', `refs/heads/${wt.branch}`], { encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'], timeout: 5000 }).trim();
|
|
1578
|
+
} catch { return null; }
|
|
1579
|
+
if (final === '') return null;
|
|
1580
|
+
return {
|
|
1581
|
+
branch: wt.branch, finalCommit: final.slice(0, 7), madeFrom: typeof wb.base === 'string' ? wb.base.slice(0, 7) : null, repo: wt.repo,
|
|
1582
|
+
merge: `git merge ${wt.branch}`, drop: `git branch -D ${wt.branch}`, note: RESULT_WORK_NOTE,
|
|
1583
|
+
};
|
|
1584
|
+
}
|
|
1585
|
+
|
|
1586
|
+
/**
|
|
1587
|
+
* The ticket a run read, from its `job-start` record (`{number, title, url}`), or null. ONE reader: the generic Result tab's ticket box and the ticket grid's row both ask here.
|
|
1588
|
+
* @param {any} start the run's `job-start` record @returns {{number: number, title: string|null, url: string|null}|null}
|
|
1589
|
+
*/
|
|
1590
|
+
function ticketOfStart(start) {
|
|
1591
|
+
const t = start && start.ticket && typeof start.ticket === 'object' ? start.ticket : null;
|
|
1592
|
+
if (!t || !Number.isInteger(t.number)) return null;
|
|
1593
|
+
return { number: t.number, title: typeof t.title === 'string' ? t.title : null, url: typeof t.url === 'string' && /^https?:\/\//i.test(t.url) ? t.url : null };
|
|
1594
|
+
}
|
|
1595
|
+
|
|
1596
|
+
/**
|
|
1597
|
+
* The generic Result tab (R7b item 4; hamr signed the mockup 2026-11-07) for a run that ENDED and is not a rubric job: five boxes of facts read
|
|
1598
|
+
* from the run's own records, plus the ticket a ticket job read. The page draws it; it decides nothing.
|
|
1599
|
+
* @param {string} runid @param {any} row @param {any[]} records @param {any} spec @param {any} opts
|
|
1600
|
+
*/
|
|
1601
|
+
function genericResultOf(runid, row, records, spec, opts) {
|
|
1602
|
+
const start = records.findLast((r) => r && r.type === 'job-start') ?? null;
|
|
1603
|
+
const writeScope = Array.isArray(spec?.writeScope) && spec.writeScope.every((/** @type {any} */ x) => typeof x === 'string') ? spec.writeScope : null;
|
|
1604
|
+
const t0 = ticketOfStart(start);
|
|
1605
|
+
const ticket = t0 ? { number: t0.number, title: t0.title ?? '', url: t0.url } : null;
|
|
1606
|
+
const detail = getRunDetailBody(runid, opts);
|
|
1607
|
+
const plan = records.findLast((r) => r && r.type === 'plan-executed' && Array.isArray(r.steps)) ?? null;
|
|
1608
|
+
const spentUsd = detail && typeof detail.spentUsd === 'number' ? detail.spentUsd : null;
|
|
1609
|
+
const complete = detail ? detail.spendComplete !== false : true;
|
|
1610
|
+
const ids = plan ? plan.steps.map((/** @type {any} */ x) => String(x?.id)) : [];
|
|
1611
|
+
const replans = plan && Number.isInteger(plan.replans) ? plan.replans : 0;
|
|
1612
|
+
return {
|
|
1613
|
+
runid,
|
|
1614
|
+
kind: 'generic',
|
|
1615
|
+
job: { asked: jobTextFromSpec(spec) || (typeof start?.goal === 'string' ? start.goal : ''), scope: writeScope },
|
|
1616
|
+
ticket,
|
|
1617
|
+
changed: changedOf(records, writeScope),
|
|
1618
|
+
checks: checksOf(records, spec),
|
|
1619
|
+
work: workOf(row, records),
|
|
1620
|
+
run: {
|
|
1621
|
+
spent: spentUsd === null ? 'unknown' : `${complete ? '' : 'at least '}${panelMoney2(spentUsd)}`,
|
|
1622
|
+
spentNote: spentUsd !== null && !complete ? 'a floor: some rounds were unpriced' : null,
|
|
1623
|
+
time: detail && typeof detail.wallMs === 'number' ? formatDurationMs(detail.wallMs) : 'unknown',
|
|
1624
|
+
steps: plan ? `${ids.length} step${ids.length === 1 ? '' : 's'}${ids.length ? ` (${ids.join(', ')})` : ''}, ${replans === 0 ? 'no replan' : `${replans} replan${replans === 1 ? '' : 's'}`}` : null,
|
|
1625
|
+
},
|
|
1626
|
+
// R8: why the run ended, in the Run tab's own words (`detail.ended.reason`): the ticket grid's opened row says it for a run that did not pass
|
|
1627
|
+
endedWords: typeof detail?.ended?.reason === 'string' && detail.ended.reason !== '' ? detail.ended.reason : null,
|
|
1628
|
+
door: { head: DOOR_WORDS.waiting.head, ask: RESULT_DOOR_ASK },
|
|
1629
|
+
};
|
|
1630
|
+
}
|
|
1631
|
+
|
|
1632
|
+
/**
|
|
1633
|
+
* R8 (piece 10): the ticket grid of the job a run belongs to, or `null` when that job is not a Tickets job (no run of it read a ticket) or the run is unknown. ONE row per run of the job, from
|
|
1634
|
+
* the run list's own entry (`summarizeRow`: status, needs, money, wall, ending words), the ticket from `job-start` ({@link ticketOfStart}), the checks from {@link checksOf} and the steps from
|
|
1635
|
+
* the run's `plan-executed` record. The page opens a row through `GET /api/runs/:runid/result` (the generic payload, one owner): this reads no diff and no branch.
|
|
1636
|
+
* @param {string} runid @param {{ home?: string, now?: number, schedules?: ReturnType<typeof createScheduleDoor> }} [opts]
|
|
1637
|
+
*/
|
|
1638
|
+
export function getJobGrid(runid, opts = {}) {
|
|
1639
|
+
const list = readRunList(opts);
|
|
1640
|
+
const anchor = list.rows.find((r) => r && r.runid === runid);
|
|
1641
|
+
if (!anchor || typeof anchor.job !== 'string') return null;
|
|
1642
|
+
const grid = ticketGridOfJob(anchor.job, list, opts);
|
|
1643
|
+
return grid === null ? null : { runid, job: anchor.job, ...grid };
|
|
1644
|
+
}
|
|
1645
|
+
|
|
1646
|
+
/**
|
|
1647
|
+
* Does this run's own record say it read a ticket? (the run list row's `ticket`, else its `job-start` ticket). The cheap gate before a whole job is read.
|
|
1648
|
+
* @param {any} row
|
|
1649
|
+
*/
|
|
1650
|
+
function rowReadTicket(row) {
|
|
1651
|
+
if (Number.isInteger(row.ticket)) return true;
|
|
1652
|
+
if (!existsSync(row.spine)) return false;
|
|
1653
|
+
try { return ticketOfStart(parseJsonl(row.spine).records.findLast((/** @type {any} */ r) => r && r.type === 'job-start')) !== null; } catch { return false; }
|
|
1654
|
+
}
|
|
1655
|
+
|
|
1656
|
+
/**
|
|
1657
|
+
* @param {string} job @param {{rows: any[], events: any[]}} list @param {{ home?: string, now?: number, schedules?: ReturnType<typeof createScheduleDoor> }} opts
|
|
1658
|
+
*/
|
|
1659
|
+
function ticketGridOfJob(job, list, opts) {
|
|
1660
|
+
const mine = list.rows.filter((r) => r && r.job === job);
|
|
1661
|
+
if (!mine.some((r) => rowReadTicket(r))) return null;
|
|
1662
|
+
const nowMs = typeof opts.now === 'number' ? opts.now : Date.now();
|
|
1663
|
+
const removals = readNeedsRemovals(opts);
|
|
1664
|
+
const nos = runNumbers(list.rows);
|
|
1665
|
+
const entries = mine.map((r) => {
|
|
1666
|
+
const e = summarizeRow(r, nowMs, removals, list.events);
|
|
1667
|
+
/** @type {any[]|null} */
|
|
1668
|
+
let records = null;
|
|
1669
|
+
if (existsSync(r.spine)) { try { records = parseJsonl(r.spine).records; } catch { records = null; } }
|
|
1670
|
+
const startRec = records ? records.findLast((/** @type {any} */ x) => x && x.type === 'job-start') : null;
|
|
1671
|
+
const t = records ? ticketOfStart(startRec) : null;
|
|
1672
|
+
const checks = records ? checksOf(records, resolveSpecForRow(r)) : null;
|
|
1673
|
+
const plan = records ? records.findLast((/** @type {any} */ x) => x && x.type === 'plan-executed' && Array.isArray(x.steps)) : null;
|
|
1674
|
+
const status = e.status ?? { key: 'failed', ...STATUS.failed };
|
|
1675
|
+
return {
|
|
1676
|
+
runId: r.runid, runNo: nos.get(r.runid) ?? null, at: Number.isFinite(atMs(r)) ? atMs(r) : null,
|
|
1677
|
+
statusKey: status.key, sign: status.sign, word: status.word, needs: e.needs ?? null,
|
|
1678
|
+
unsure: filterUnsure({ filter: startRec?.ticketFilter }),
|
|
1679
|
+
number: t ? t.number : (Number.isInteger(r.ticket) ? r.ticket : null), title: t ? t.title : null, url: t ? t.url : null,
|
|
1680
|
+
steps: plan ? { done: plan.steps.filter((/** @type {any} */ x) => isReusableGreen(x?.outcome)).length, total: plan.steps.length } : null,
|
|
1681
|
+
checks: checks ? { passed: checks.passed, total: checks.total } : null,
|
|
1682
|
+
spentUsd: typeof e.spentUsd === 'number' ? e.spentUsd : null, spendComplete: e.spendComplete === true, spendFloorUsd: typeof e.spendFloorUsd === 'number' ? e.spendFloorUsd : null,
|
|
1683
|
+
wall: typeof e.wall === 'string' && e.wall !== '' ? e.wall : null,
|
|
1684
|
+
reason: typeof e.endedLine === 'string' && e.endedLine !== '' ? e.endedLine : (e.fileMissing === true ? 'the run\'s log is no longer on disk' : null),
|
|
1685
|
+
};
|
|
1686
|
+
});
|
|
1687
|
+
let scheduleLine = null;
|
|
1688
|
+
try {
|
|
1689
|
+
const v = opts.schedules ? opts.schedules.view(job) : null;
|
|
1690
|
+
if (v && v.scheduled === true && typeof v.text === 'string') scheduleLine = `${v.text} · looks every ${TICKET_LOOK_MS / 60_000} min`;
|
|
1691
|
+
} catch { scheduleLine = null; }
|
|
1692
|
+
return buildJobGrid({ entries, scheduleLine });
|
|
1693
|
+
}
|
|
1694
|
+
|
|
1695
|
+
/**
|
|
1696
|
+
* Is ticket `number` a skipped ticket of `job` that nobody has run since? The ONE check behind `POST /api/author/ticket-anyway`: the grid's own skipped row says so.
|
|
1697
|
+
* @param {string} job @param {number} number @param {{ home?: string, now?: number }} [opts]
|
|
1698
|
+
*/
|
|
1699
|
+
export function isSkippedTicket(job, number, opts = {}) {
|
|
1700
|
+
return skippedRunOf(job, number, opts) !== null;
|
|
1701
|
+
}
|
|
1702
|
+
|
|
1703
|
+
/**
|
|
1704
|
+
* The run id of the skipped row {@link isSkippedTicket} means (the newest one of that ticket, with Run it anyway on it), or null. The no-schedule "Run it anyway" (am3) starts from that
|
|
1705
|
+
* run's own saved signed job.
|
|
1706
|
+
* @param {string} job @param {number} number @param {{ home?: string, now?: number }} [opts]
|
|
1707
|
+
*/
|
|
1708
|
+
export function skippedRunOf(job, number, opts = {}) {
|
|
1709
|
+
const list = readRunList(opts);
|
|
1710
|
+
const grid = ticketGridOfJob(job, list, opts);
|
|
1711
|
+
if (grid === null) return null;
|
|
1712
|
+
const skip = grid.groups.find((g) => g.key === 'skip');
|
|
1713
|
+
return skip?.rows.find((r) => r.number === number && r.anyway === true)?.runId ?? null;
|
|
1714
|
+
}
|
|
1715
|
+
|
|
1389
1716
|
/**
|
|
1390
1717
|
* `GET /api/runs/:runid/result` — the Result tab: for each rubric job line, its words and `~` rules from the signed spec, the facts it requires
|
|
1391
1718
|
* (worded by {@link factSentence}), and — read from the run's own delivered step file, sha256-checked against its `destination-written`
|
|
1392
1719
|
* record — one row per result with each fact's cell. `passed` is read from the run's own `check-run` record; the tab never re-decides. A red run
|
|
1393
1720
|
* delivers nothing, so it has no rows: it carries the check's own first gap instead. `null` = no such run or no result tab for it.
|
|
1721
|
+
* Every OTHER job (R7b item 4) that ENDED gets the generic payload from {@link genericResultOf} (`kind: 'generic'`); the rubric payload below is
|
|
1722
|
+
* untouched and carries no `kind`.
|
|
1394
1723
|
* @param {string} runid @param {{ home?: string }} opts
|
|
1395
1724
|
*/
|
|
1396
1725
|
export function getRunResult(runid, /** @type {{ home?: string, sessionsRoot?: string }} */ opts = {}) {
|
|
@@ -1398,15 +1727,18 @@ export function getRunResult(runid, /** @type {{ home?: string, sessionsRoot?: s
|
|
|
1398
1727
|
if (!row || row.via === 'import' || !existsSync(row.spine)) return null;
|
|
1399
1728
|
const records = parseJsonl(row.spine).records;
|
|
1400
1729
|
const spec = resolveSpecForRow(row);
|
|
1730
|
+
const kind = resultKindOf(row, records, spec);
|
|
1731
|
+
if (kind === 'generic') return genericResultOf(runid, row, records, spec, opts);
|
|
1732
|
+
if (kind === null) return null;
|
|
1401
1733
|
const stages = rubricStagesOf(spec);
|
|
1402
|
-
if (stages.length === 0) return null;
|
|
1403
1734
|
const delivered = deliveredOf(records);
|
|
1404
1735
|
const read = delivered.map((d) => readDelivered(d));
|
|
1405
1736
|
const jobLines = Array.isArray(spec?.jobLines) ? spec.jobLines : [];
|
|
1406
1737
|
// Not checked, split by the line the SIGNED plan ties each item to: a refusal carries its line (closeDecl.refused[].line, planFromSpec's
|
|
1407
1738
|
// `lines[].refused`), a prose step carries its stage's step. What the plan ties to no line stays in `notChecked` (the bottom). Together they are
|
|
1408
1739
|
// exactly the Job tab's items (its per-line "not checked" rows plus its Not checked fold) — never a second spelling.
|
|
1409
|
-
const
|
|
1740
|
+
const ledgerDir = sessionDirForRow(row, opts);
|
|
1741
|
+
const plan = planFromSpec(spec, ledgerDir ? readDraftLedger(ledgerDir) : null);
|
|
1410
1742
|
const proseByLine = proseNotCheckedItems(spec?.closeDecl);
|
|
1411
1743
|
const prosePool = proseByLine.map((i) => i.text);
|
|
1412
1744
|
const tiedToLine = (/** @type {number} */ n) => [...(plan.lines.find((l) => l.n === n)?.refused ?? []), ...proseByLine.filter((i) => i.line === n).map((i) => i.text)];
|
|
@@ -1423,6 +1755,7 @@ export function getRunResult(runid, /** @type {{ home?: string, sessionsRoot?: s
|
|
|
1423
1755
|
/** @type {any} */
|
|
1424
1756
|
const out = {
|
|
1425
1757
|
notChecked: tiedToLine(n),
|
|
1758
|
+
...(plan.notCheckedBy ? { notCheckedBy: plan.notCheckedBy } : {}),
|
|
1426
1759
|
n, text: jl && typeof jl.text === 'string' ? jl.text : '', rules: jl ? lineRules(jl) : [], kind: fp ? 'facts' : 'text', passed,
|
|
1427
1760
|
file: di ? { i: di.i, state: read[di.i].state, words: read[di.i].state === 'gone' ? RESULT_FILE_GONE : (read[di.i].state === 'changed' ? RESULT_FILE_CHANGED : null) } : null,
|
|
1428
1761
|
};
|
|
@@ -1494,6 +1827,7 @@ export function getRunResult(runid, /** @type {{ home?: string, sessionsRoot?: s
|
|
|
1494
1827
|
pages,
|
|
1495
1828
|
pageNote: pages.length ? RESULT_PAGE_MAY_CHANGE : null,
|
|
1496
1829
|
notChecked: bottom,
|
|
1830
|
+
...(plan.notCheckedBy ? { notCheckedBy: plan.notCheckedBy } : {}),
|
|
1497
1831
|
readNotes: plan.readNotes,
|
|
1498
1832
|
// the door's words, from the one table (src/panel/status.js DOOR_WORDS); the page types none of them
|
|
1499
1833
|
door: { head: DOOR_WORDS.waiting.head, ask: RESULT_DOOR_ASK },
|
|
@@ -1584,7 +1918,8 @@ function scheduleExtrasFor(runid, job, rows, events, nos, opts, view) {
|
|
|
1584
1918
|
lastWords = `last ${dateTimeWords(Number(lastRow.at))} · ${skippedWords(lastRow, true)}`;
|
|
1585
1919
|
}
|
|
1586
1920
|
}
|
|
1587
|
-
schedule
|
|
1921
|
+
// R7: a schedule signed with the job says only that it waits (and a run waiting for the Accept, which is what a rubric job waits for)
|
|
1922
|
+
schedule.line2 = (view.waiting === true ? [accept ? SCHEDULE_WORDS.acceptWaiting : null, nextWords] : [lastWords ?? 'no run yet', accept ? SCHEDULE_WORDS.acceptWaiting : null, nextWords]).filter(Boolean).join(' · ');
|
|
1588
1923
|
}
|
|
1589
1924
|
}
|
|
1590
1925
|
const row = rows.find((r) => r && r.runid === runid);
|
|
@@ -1601,7 +1936,7 @@ function scheduleExtrasFor(runid, job, rows, events, nos, opts, view) {
|
|
|
1601
1936
|
const running = rows.some((r) => r && r.job === job && r.via !== 'import' && runIsAlive(r));
|
|
1602
1937
|
const { sign, word } = scheduleSignFor({ running, red: !!(view && view.problem) });
|
|
1603
1938
|
const words = scheduledWords(cur.trigger, door.userHome);
|
|
1604
|
-
const head = [lowerFirst(words ?? ''), originNo === null ? null : `from run-${originNo}`, triesTailWords(tries.length) || null].filter(Boolean).join(' · ');
|
|
1939
|
+
const head = [lowerFirst(words ?? ''), originNo === null ? null : `from run-${originNo}`, door.isWaiting(job) ? lowerFirst(SCHEDULE_WORDS.waiting) : null, triesTailWords(tries.length) || null].filter(Boolean).join(' · ');
|
|
1605
1940
|
const when = row ? dateTimeWords(atMs(row)) : '';
|
|
1606
1941
|
const thisRun = rec ? sectionThisRunWords(rec) : `by hand.${runid === cur.originRunid ? ' The schedule was set from this run.' : ''}`;
|
|
1607
1942
|
const shown = tries.slice(0, 7).map((x, i) => ({ label: i === 0 ? 'tries' : '', text: x.line }));
|
|
@@ -1622,8 +1957,11 @@ function getRunDetailBody(runid, opts) {
|
|
|
1622
1957
|
const row = findRunRow(runid, opts);
|
|
1623
1958
|
if (!row) return null;
|
|
1624
1959
|
if (!existsSync(row.spine)) {
|
|
1625
|
-
const
|
|
1626
|
-
|
|
1960
|
+
const { events: settledEvents } = readRunList(opts);
|
|
1961
|
+
const refusal = refusalWordsOf(settledEvents, row);
|
|
1962
|
+
if (refusal !== null) return refusedStub(row, refusal, 'refused-before-start', neverRanPlan(settledEvents, row));
|
|
1963
|
+
const skipped = skipWordsOf(settledEvents, row);
|
|
1964
|
+
if (skipped !== null) return refusedStub(row, skipped, 'skipped', neverRanPlan(settledEvents, row));
|
|
1627
1965
|
if (runIsAlive(row)) return startingStub(row);
|
|
1628
1966
|
return {
|
|
1629
1967
|
runid, job: row.job, at: row.at, via: row.via, fileMissing: true,
|
|
@@ -1911,12 +2249,15 @@ function getRunDetailBody(runid, opts) {
|
|
|
1911
2249
|
// PRD v1.106 Part 5 F: the two Run summary rows, worded here (the page prints them)
|
|
1912
2250
|
callsLine: callsLineOf(rawSpineRecords, scopedBehaviour(row, rawSpineRecords)),
|
|
1913
2251
|
checksLine: checksLineOf(rawSpineRecords, enrichedParts),
|
|
2252
|
+
auditChecks: auditChecksFor(row, rawSpineRecords, specForParts, opts),
|
|
1914
2253
|
memoryCache: summary.memoryCache,
|
|
2254
|
+
// PLACE RULES: what the run start read for each place-rule check (plain lines from code), or null when the run has none; the Audit page's placement of it is not built yet
|
|
2255
|
+
placeRules: placeRuleLines(rawSpineRecords),
|
|
1915
2256
|
// T Part 8: is this run waiting for the person's Accept? The SAME answer fills the runs list's Needs-you tag (`doorWaiting`, one owner)
|
|
1916
2257
|
accept: !runIsAlive(row) && doorWaiting(rawSpineRecords),
|
|
1917
2258
|
// PRD v1.107 Part 6: the Result tab shows for a rubric run whose signed close has a rubric-step stage, never otherwise; `delivered` is the
|
|
1918
2259
|
// files the run's own `destination-written` records name (the Result tab's downloads index into this list, never a path from a request)
|
|
1919
|
-
hasResult:
|
|
2260
|
+
hasResult: resultKindOf(row, rawSpineRecords, specForParts) !== null,
|
|
1920
2261
|
delivered: deliveredOf(rawSpineRecords).map(({ path, bytes, sha256 }) => ({ path, bytes, sha256 })),
|
|
1921
2262
|
// T Part 7: why a SCHEDULED run started (the words `trigger.json` carried) and the fixed catch-up sentence; null on every hand run
|
|
1922
2263
|
...(() => {
|
|
@@ -2085,11 +2426,22 @@ function resolveAuditPathsForRow(row, spineRecords) {
|
|
|
2085
2426
|
* @returns {ReturnType<typeof runBehaviour>|null}
|
|
2086
2427
|
*/
|
|
2087
2428
|
function scopedBehaviour(row, spineRecords) {
|
|
2429
|
+
const windowed = scopedAuditRows(row, spineRecords);
|
|
2430
|
+
return windowed === null ? null : runBehaviour(windowed);
|
|
2431
|
+
}
|
|
2432
|
+
|
|
2433
|
+
/**
|
|
2434
|
+
* The gate-audit rows inside this run's own ts window(s), the ONE scoping behind the Run tab's tools summary and the Audit's write-fence row; `null` when no
|
|
2435
|
+
* gate-audit sidecar was found for the run (never an empty list posing as a clean record).
|
|
2436
|
+
* @param {{spine: string, patient: string|null}} row
|
|
2437
|
+
* @param {any[]} spineRecords
|
|
2438
|
+
* @returns {any[]|null}
|
|
2439
|
+
*/
|
|
2440
|
+
function scopedAuditRows(row, spineRecords) {
|
|
2088
2441
|
const auditPaths = resolveAuditPathsForRow(row, spineRecords);
|
|
2089
2442
|
if (auditPaths.length === 0) return null;
|
|
2090
2443
|
const windows = runAuditWindows(spineRecords);
|
|
2091
|
-
|
|
2092
|
-
return runBehaviour(windowed);
|
|
2444
|
+
return auditPaths.flatMap((ap) => parseJsonl(ap).records).filter((r) => r && typeof r === 'object' && typeof r.ts === 'string' && inAnyWindow(r.ts, windows));
|
|
2093
2445
|
}
|
|
2094
2446
|
|
|
2095
2447
|
/**
|
|
@@ -3058,6 +3410,31 @@ function successFromSpec(spec) {
|
|
|
3058
3410
|
return names.length > 0 ? names.join(' · ') : null;
|
|
3059
3411
|
}
|
|
3060
3412
|
|
|
3413
|
+
/**
|
|
3414
|
+
* The Audit's check list (hamr ruling A): the card's own sections (planFromSpec for the checks and Not checked, confirmProtections for Always checked) with each row's
|
|
3415
|
+
* result read from the run's recorded stage verdicts ({@link checksOf}), never re-derived. `null` for a run with no signed spec (nothing to list).
|
|
3416
|
+
* @param {{spine: string, patient: string|null}} row @param {any[]} records @param {any} spec @param {{ home?: string, sessionsRoot?: string }} opts
|
|
3417
|
+
*/
|
|
3418
|
+
function auditChecksFor(row, records, spec, opts) {
|
|
3419
|
+
if (!spec || typeof spec !== 'object') return null;
|
|
3420
|
+
const ledgerDir = sessionDirForRow(row, opts);
|
|
3421
|
+
const plan = planFromSpec(spec, ledgerDir ? readDraftLedger(ledgerDir) : null);
|
|
3422
|
+
/** @type {string[]} */
|
|
3423
|
+
let guards = [];
|
|
3424
|
+
if (spec.closeDecl && typeof spec.closeDecl.lang === 'string' && typeof spec.verdictType === 'string') {
|
|
3425
|
+
try {
|
|
3426
|
+
guards = confirmProtections({
|
|
3427
|
+
verdictType: spec.verdictType, lang: spec.closeDecl.lang, jobLines: Array.isArray(spec.jobLines) ? spec.jobLines : null,
|
|
3428
|
+
writeScope: Array.isArray(spec.writeScope) && spec.writeScope.every((/** @type {any} */ x) => typeof x === 'string') ? spec.writeScope : null,
|
|
3429
|
+
});
|
|
3430
|
+
} catch { guards = []; }
|
|
3431
|
+
}
|
|
3432
|
+
const got = checksOf(records, spec);
|
|
3433
|
+
const results = got ? new Map(got.stages.map((/** @type {any} */ x) => [x.name, x.passed === true])) : null;
|
|
3434
|
+
const rows = scopedAuditRows(row, records);
|
|
3435
|
+
return auditChecksOf(plan, guards, results, rows === null ? null : writesBlocked(rows));
|
|
3436
|
+
}
|
|
3437
|
+
|
|
3061
3438
|
/**
|
|
3062
3439
|
* The write fence plus the guard checks a close actually carries — reusing
|
|
3063
3440
|
* {@link confirmProtections} (`src/authorflow.js`), the SAME function the
|
|
@@ -3106,6 +3483,21 @@ function toolsListFromSpec(spec) {
|
|
|
3106
3483
|
return names.length > 0 ? names : null;
|
|
3107
3484
|
}
|
|
3108
3485
|
|
|
3486
|
+
/**
|
|
3487
|
+
* The Job tab's MCP rows (piece 8): the signed flow type (in the card's own words), the server and the tools the job signed, plus a ticket filter / watched fields when the spec
|
|
3488
|
+
* carries them. `null` for a plain job (no MCP rows at all).
|
|
3489
|
+
* @param {any} spec
|
|
3490
|
+
* @returns {{flowType: string, server: string, tools: string[], ticketFilter?: any, ticketFilterWords?: string|null, ticketWatch?: string[]}|null}
|
|
3491
|
+
*/
|
|
3492
|
+
function mcpDetailFromSpec(spec) {
|
|
3493
|
+
const m = spec?.mcp;
|
|
3494
|
+
if (!m || typeof m.server !== 'string' || !Array.isArray(m.tools)) return null;
|
|
3495
|
+
return {
|
|
3496
|
+
flowType: FLOW_TYPE_LABELS[flowTypeOf(spec)], server: m.server, tools: m.tools.filter((/** @type {any} */ t) => typeof t === 'string'),
|
|
3497
|
+
...(spec.ticketFilter ? { ticketFilter: spec.ticketFilter, ticketFilterWords: ticketFilterWords(spec.ticketFilter) } : {}), ...(Array.isArray(spec.ticketWatch) ? { ticketWatch: spec.ticketWatch } : {}),
|
|
3498
|
+
};
|
|
3499
|
+
}
|
|
3500
|
+
|
|
3109
3501
|
/**
|
|
3110
3502
|
* The granted tool list, verbatim, in declared order — `null` when the spec
|
|
3111
3503
|
* carries none (a job may legally declare no `tools` at all).
|
|
@@ -3208,7 +3600,7 @@ export function getRunJob(runid, opts = {}) {
|
|
|
3208
3600
|
trigger: cur ? cur.trigger : null, originNo: cur ? (nos.get(cur.originRunid) ?? null) : null,
|
|
3209
3601
|
model: spec && typeof spec.model === 'string' ? spec.model : null,
|
|
3210
3602
|
destination: cur ? (typeof cur.destination === 'string' && cur.destination !== '' ? cur.destination : (Array.isArray(spec?.writeScope) ? spec.writeScope.join(', ') : null)) : null,
|
|
3211
|
-
home: door.userHome,
|
|
3603
|
+
home: door.userHome, waiting: cur ? door.isWaiting(job) : false,
|
|
3212
3604
|
});
|
|
3213
3605
|
return { ...body, started, schedule };
|
|
3214
3606
|
} catch { return body; }
|
|
@@ -3236,7 +3628,8 @@ function getRunJobBody(runid, opts) {
|
|
|
3236
3628
|
const row = findRunRow(runid, opts);
|
|
3237
3629
|
if (!row) return null;
|
|
3238
3630
|
|
|
3239
|
-
|
|
3631
|
+
// a run that ended BEFORE it started (refused or skipped: a listed row, no spine file) still has its session folder: its path names it (R7b), so the signed job shows from there
|
|
3632
|
+
const near = sourceNearSpine(row.spine);
|
|
3240
3633
|
let manifest = null;
|
|
3241
3634
|
if (near.sourceJsonPath) {
|
|
3242
3635
|
try { manifest = JSON.parse(readFileSync(near.sourceJsonPath, 'utf8')); } catch { manifest = null; }
|
|
@@ -3280,10 +3673,12 @@ function getRunJobBody(runid, opts) {
|
|
|
3280
3673
|
if (existsSync(row.spine)) {
|
|
3281
3674
|
try { firstStart = parseJsonl(row.spine).records.find((r) => r && typeof r === 'object' && r.type === 'job-start') ?? null; } catch { firstStart = null; }
|
|
3282
3675
|
}
|
|
3676
|
+
// the check list's rows as the drafting ended, from the run's own session folder (none for a CLI or imported run: the plan then names a row from its key)
|
|
3677
|
+
const ledgerOf = () => { const dir = sessionDirForRow(row, opts); return dir ? readDraftLedger(dir) : null; };
|
|
3283
3678
|
/** @param {any} spec @param {boolean} resolved @param {string} resolvedFrom @param {string|null} note */
|
|
3284
3679
|
const fromSpec = (spec, resolved, resolvedFrom, note) => ({
|
|
3285
3680
|
// P7: the same plan model the chat's plan bubble is drawn from (src/panel/jobplan.js), read from the SIGNED spec
|
|
3286
|
-
plan: planFromSpec(spec),
|
|
3681
|
+
plan: planFromSpec(spec, ledgerOf()),
|
|
3287
3682
|
jobLines: Array.isArray(spec.jobLines) ? spec.jobLines : null,
|
|
3288
3683
|
inputs: Array.isArray(spec.inputs) && spec.inputs.length ? spec.inputs : [{ n: 1, label: 'repo', value: sourceDisplay() }],
|
|
3289
3684
|
signedAt: typeof firstStart?.ts === 'string' ? firstStart.ts : null,
|
|
@@ -3306,6 +3701,7 @@ function getRunJobBody(runid, opts) {
|
|
|
3306
3701
|
guardrails: notRecorded(guardrailsFromSpec(spec)),
|
|
3307
3702
|
tools: notRecorded(toolsFromSpec(spec)),
|
|
3308
3703
|
toolsList: toolsListFromSpec(spec),
|
|
3704
|
+
mcp: mcpDetailFromSpec(spec),
|
|
3309
3705
|
thinkingTick: spec.thinking === true,
|
|
3310
3706
|
note,
|
|
3311
3707
|
});
|
|
@@ -3524,19 +3920,22 @@ export function reuseLine(record) {
|
|
|
3524
3920
|
* to copy: change the job: Clear the card). `null` when the runid is not listed.
|
|
3525
3921
|
* @param {string} runid
|
|
3526
3922
|
* @param {{ home?: string, model?: string, provider?: string }} [opts] `model` = the Model box's current Name (the estimate counts only runs on that worker); absent = the card's own Model
|
|
3527
|
-
* @returns {{ok: true, origin: {runid: string, job: string}, outcome: string|null, card: Record<string, any>, from: 'signed job',
|
|
3923
|
+
* @returns {{ok: true, origin: {runid: string, job: string}, outcome: string|null, neverRan: boolean, card: Record<string, any>, from: 'signed job',
|
|
3528
3924
|
* note: string|null,
|
|
3529
3925
|
* specHash: string, workflowKey: string, spec: any, specPath: string, specNamesModel: boolean,
|
|
3530
3926
|
* specWorker: {provider: string, endpoint: string, label: string},
|
|
3531
3927
|
* trackRecord: ReturnType<typeof trackRecordFor>, line: string}|{ok: false, error: string}|null}
|
|
3532
3928
|
*/
|
|
3533
3929
|
export function getStartFrom(runid, opts = {}) {
|
|
3534
|
-
const { rows } = readRunList(opts);
|
|
3930
|
+
const { rows, events } = readRunList(opts);
|
|
3535
3931
|
const row = rows.find((r) => r && r.runid === runid);
|
|
3536
3932
|
if (!row) return null;
|
|
3537
|
-
|
|
3538
|
-
|
|
3539
|
-
const
|
|
3933
|
+
// a ticket the job's filter SKIPPED has no log (R5) but its session kept the signed job beside where the log would be: the no-schedule "Run it anyway" (am3) starts from it
|
|
3934
|
+
// R9 (9b.2): so does a run refused before its first step (a refused run-start fetch, a locked-token look): it has no log either, and its session kept the signed job the same way
|
|
3935
|
+
const skipped = neverRanPlan(events, row);
|
|
3936
|
+
if (!existsSync(row.spine) && !skipped) return { ok: false, error: 'this run has no log on disk — nothing to reuse' };
|
|
3937
|
+
const records = skipped ? [] : parseJsonl(row.spine).records;
|
|
3938
|
+
const signed = skipped ? skippedSignedSpec(row) : signedSpecForRun(row, records);
|
|
3540
3939
|
if (!signed) return { ok: false, error: "this run's signed job is not on disk — nothing to reuse (change the job: Clear the card and draft a new one)" };
|
|
3541
3940
|
const near = sourceNearSpine(row.spine);
|
|
3542
3941
|
const spec = signed.spec;
|
|
@@ -3574,6 +3973,8 @@ export function getStartFrom(runid, opts = {}) {
|
|
|
3574
3973
|
const o = legsOf(records).at(-1)?.outcome ?? null;
|
|
3575
3974
|
return isReusableGreen(o) && heldScheduled(records, triggerRecordOf(row)) ? 'green-held' : o;
|
|
3576
3975
|
})(),
|
|
3976
|
+
// R9 (9b.2): the run ended before its first step at $0 (see neverRanPlan): the signed job stands, so an unchanged Reuse is "Sign & run", not a redraft
|
|
3977
|
+
neverRan: skipped,
|
|
3577
3978
|
card,
|
|
3578
3979
|
from: 'signed job',
|
|
3579
3980
|
note: Array.isArray(spec.jobLines) && spec.jobLines.length ? null : 'older job — numbered lines were not saved',
|
|
@@ -3594,16 +3995,30 @@ export function getStartFrom(runid, opts = {}) {
|
|
|
3594
3995
|
};
|
|
3595
3996
|
}
|
|
3596
3997
|
|
|
3998
|
+
/**
|
|
3999
|
+
* The signed job a SKIPPED run's session left (`resolved-spec.json` beside where its log would be), or null. A skipped run has no `job-start` to name the hash, so the file stands as the
|
|
4000
|
+
* session saved it; whatever starts from it is signed afresh by the start's own gates.
|
|
4001
|
+
* @param {{ spine: string }} row @returns {{spec: any, specPath: string, specHash: string}|null}
|
|
4002
|
+
*/
|
|
4003
|
+
function skippedSignedSpec(row) {
|
|
4004
|
+
const { specPath } = sourceNearSpine(row.spine);
|
|
4005
|
+
if (!specPath) return null;
|
|
4006
|
+
try {
|
|
4007
|
+
const spec = JSON.parse(readFileSync(specPath, 'utf8'));
|
|
4008
|
+
return spec && typeof spec === 'object' ? { spec, specPath, specHash: jobSpecHash(spec) } : null;
|
|
4009
|
+
} catch { return null; }
|
|
4010
|
+
}
|
|
4011
|
+
|
|
3597
4012
|
/**
|
|
3598
4013
|
* T Part 3: a job's listed runs, newest first, each with its signed spec (null when not on disk), its terminal outcome and
|
|
3599
4014
|
* its parsed spine. The schedule door's gate (`greenFor`) reads this; nothing here builds a run context.
|
|
3600
4015
|
* @param {string} job
|
|
3601
4016
|
* @param {{ home?: string }} [opts]
|
|
3602
|
-
* @returns {{runid: string, outcome: string|null, spec: any, records: any[]}[]}
|
|
4017
|
+
* @returns {{runid: string, outcome: string|null, spec: any, records: any[], ticket?: number}[]}
|
|
3603
4018
|
*/
|
|
3604
4019
|
export function jobRunsOf(job, opts = {}) {
|
|
3605
4020
|
const { rows } = readRunList(opts);
|
|
3606
|
-
/** @type {{runid: string, outcome: string|null, spec: any, records: any[]}[]} */
|
|
4021
|
+
/** @type {{runid: string, outcome: string|null, spec: any, records: any[], ticket?: number}[]} */
|
|
3607
4022
|
const out = [];
|
|
3608
4023
|
for (let i = rows.length - 1; i >= 0; i -= 1) {
|
|
3609
4024
|
const row = rows[i];
|
|
@@ -3612,7 +4027,11 @@ export function jobRunsOf(job, opts = {}) {
|
|
|
3612
4027
|
try { records = parseJsonl(row.spine).records; } catch { continue; }
|
|
3613
4028
|
const outcome = legsOf(records).at(-1)?.outcome ?? null;
|
|
3614
4029
|
// T D.2: a scheduled run's green is HELD until accepted, so it is not a good run for the schedule gate either
|
|
3615
|
-
out.push({
|
|
4030
|
+
out.push({
|
|
4031
|
+
runid: row.runid, outcome: outcome === 'green' && heldScheduled(records, triggerRecordOf(row)) ? 'green-held' : outcome, spec: signedSpecForRun(row, records)?.spec ?? null, records,
|
|
4032
|
+
// a Tickets run's ticket number (the run list row carries it): the schedule signed with the job starts after this one (R7)
|
|
4033
|
+
...(Number.isInteger(row.ticket) ? { ticket: row.ticket } : {}),
|
|
4034
|
+
});
|
|
3616
4035
|
}
|
|
3617
4036
|
return out;
|
|
3618
4037
|
}
|
|
@@ -3670,6 +4089,8 @@ function reuseCardFromSpec(spec, extra) {
|
|
|
3670
4089
|
destination: extra.destination || writeScope.join(', '),
|
|
3671
4090
|
capUsd: typeof spec.budgetUsd === 'number' ? spec.budgetUsd : null,
|
|
3672
4091
|
maxWallMs: typeof spec.maxWallMs === 'number' ? spec.maxWallMs : undefined,
|
|
4092
|
+
// piece 8: a job with an MCP shows its Flow type and server on the card; a plain job adds nothing (so its card is what it was)
|
|
4093
|
+
...(spec.mcp && typeof spec.mcp.server === 'string' ? { flowType: flowTypeOf(spec), mcp: spec.mcp.server } : {}),
|
|
3673
4094
|
};
|
|
3674
4095
|
}
|
|
3675
4096
|
|
|
@@ -3771,7 +4192,7 @@ function sendText(res, code, text) {
|
|
|
3771
4192
|
* only `createPanelServer` below always supplies one.
|
|
3772
4193
|
* @param {import('node:http').IncomingMessage} req
|
|
3773
4194
|
* @param {import('node:http').ServerResponse} res
|
|
3774
|
-
* @param {{ home?: string, sessionsRoot?: string, version?: string, startedAt?: string, packageJsonPath?: string, port: number, token?: string, authorRoutes?: ReturnType<typeof createAuthorRoutes>, settingsRoutes?: ReturnType<typeof createSettingsRoutes>, runRoutes?: ReturnType<typeof createRunRoutes>, importRoutes?: ReturnType<typeof createImportRoutes>, schedules?: ReturnType<typeof createScheduleDoor> }} opts
|
|
4195
|
+
* @param {{ home?: string, mcpHome?: string, sessionsRoot?: string, version?: string, startedAt?: string, packageJsonPath?: string, port: number, token?: string, authorRoutes?: ReturnType<typeof createAuthorRoutes>, settingsRoutes?: ReturnType<typeof createSettingsRoutes>, runRoutes?: ReturnType<typeof createRunRoutes>, importRoutes?: ReturnType<typeof createImportRoutes>, schedules?: ReturnType<typeof createScheduleDoor> }} opts
|
|
3775
4196
|
*/
|
|
3776
4197
|
export function handleRequest(req, res, opts) {
|
|
3777
4198
|
/** the ONE writable route family for a path, or null — `/api/author/*` (authoring) or
|
|
@@ -3875,6 +4296,8 @@ export function handleRequest(req, res, opts) {
|
|
|
3875
4296
|
// caller (no `opts.token`), which is fine: the page's own JS only reads
|
|
3876
4297
|
// it to send on a POST, and there are none to send without P3's routes.
|
|
3877
4298
|
html = html.replace(/__BARELOOP_PANEL_TOKEN__/g, String(opts.token ?? ''));
|
|
4299
|
+
// the New job card's Schedule row (R7): its words come from the schedule words table, never from the page
|
|
4300
|
+
for (const [token, words] of Object.entries(scheduleCardFill())) html = html.split(token).join(words);
|
|
3878
4301
|
if (method === 'HEAD') {
|
|
3879
4302
|
res.writeHead(200, { 'content-type': 'text/html; charset=utf-8', 'content-length': Buffer.byteLength(html) });
|
|
3880
4303
|
res.end();
|
|
@@ -3894,7 +4317,7 @@ export function handleRequest(req, res, opts) {
|
|
|
3894
4317
|
|
|
3895
4318
|
if (pathname === '/api/runs') { send(200, runsListPayload({ home: opts.home, schedules: opts.schedules })); return; }
|
|
3896
4319
|
|
|
3897
|
-
const runMatch = /^\/api\/runs\/([^/]+)(\/(audit|job|rounds|result|download))?$/.exec(pathname);
|
|
4320
|
+
const runMatch = /^\/api\/runs\/([^/]+)(\/(audit|job|rounds|result|download|grid))?$/.exec(pathname);
|
|
3898
4321
|
if (runMatch) {
|
|
3899
4322
|
const rawRunid = runMatch[1];
|
|
3900
4323
|
const sub = runMatch[3] ?? null;
|
|
@@ -3922,6 +4345,12 @@ export function handleRequest(req, res, opts) {
|
|
|
3922
4345
|
send(200, result);
|
|
3923
4346
|
return;
|
|
3924
4347
|
}
|
|
4348
|
+
if (sub === 'grid') {
|
|
4349
|
+
const result = getJobGrid(runid, { home: opts.home, schedules: opts.schedules });
|
|
4350
|
+
if (!result) { sendText(res, 404, 'no such run, or its job is not a Tickets job'); return; }
|
|
4351
|
+
send(200, result);
|
|
4352
|
+
return;
|
|
4353
|
+
}
|
|
3925
4354
|
if (sub === 'download') {
|
|
3926
4355
|
const got = getRunDownload(runid, url.searchParams.get('i'), { home: opts.home });
|
|
3927
4356
|
if (!got.ok) { sendText(res, got.code, got.error); return; }
|
|
@@ -3988,7 +4417,7 @@ export function panelUrl(boundPort) {
|
|
|
3988
4417
|
* @param {{ port?: number, home?: string, env?: Record<string,string|undefined>,
|
|
3989
4418
|
* sessionsRoot?: string, spawnFn?: (...a: any[]) => any, bareloopBin?: string,
|
|
3990
4419
|
* fetchImpl?: typeof fetch, settleMs?: number, userHome?: string,
|
|
3991
|
-
* openFolderSpawn?: (cmd: string, args: string[], o: object) => any, platform?: string, packageJsonPath?: string,
|
|
4420
|
+
* openFolderSpawn?: (cmd: string, args: string[], o: object) => any, platform?: string, mcpHome?: string, packageJsonPath?: string,
|
|
3992
4421
|
* scheduleNow?: () => number, sessionDeps?: Record<string, any>, schedulerIntervalMs?: number, acceptWaitMs?: number }} [opts] `scheduleNow`, `sessionDeps` and `schedulerIntervalMs` are TEST SEAMS (the schedule clock; createSession's stubs; the scheduler's timer, 0 = none)
|
|
3993
4422
|
* @returns {Promise<{ server: import('node:http').Server, port: number, token: string, schedules: ReturnType<typeof createScheduleDoor>, scheduler: ReturnType<typeof createScheduler>, close: () => Promise<void> }>}
|
|
3994
4423
|
*/
|
|
@@ -4050,6 +4479,8 @@ export function createPanelServer(opts = {}) {
|
|
|
4050
4479
|
schedulesRef = schedules;
|
|
4051
4480
|
authorRoutes = createAuthorRoutes({
|
|
4052
4481
|
schedules,
|
|
4482
|
+
isSkippedTicket: (job, n) => isSkippedTicket(job, n, { home }),
|
|
4483
|
+
skippedRunOf: (job, n) => skippedRunOf(job, n, { home }),
|
|
4053
4484
|
runJobNames: () => readRunList({ home }).rows.flatMap((r) => (r && typeof r.job === 'string' ? [r.job] : [])),
|
|
4054
4485
|
...(opts.sessionDeps ? { sessionDeps: opts.sessionDeps } : {}),
|
|
4055
4486
|
port: boundPort,
|
|
@@ -4060,6 +4491,7 @@ export function createPanelServer(opts = {}) {
|
|
|
4060
4491
|
bareloopBin: opts.bareloopBin,
|
|
4061
4492
|
fetchImpl: opts.fetchImpl,
|
|
4062
4493
|
home,
|
|
4494
|
+
mcpHome: opts.mcpHome,
|
|
4063
4495
|
startFrom: {
|
|
4064
4496
|
get: (runid, o = {}) => getStartFrom(runid, { home, ...o }),
|
|
4065
4497
|
getImport: (id, o = {}) => getStartFromImport(id, { home, ...o }),
|
|
@@ -4080,7 +4512,7 @@ export function createPanelServer(opts = {}) {
|
|
|
4080
4512
|
scheduler.start();
|
|
4081
4513
|
settingsRoutes = createSettingsRoutes({
|
|
4082
4514
|
port: boundPort, token, home, env: opts.env, fetchImpl: opts.fetchImpl,
|
|
4083
|
-
openFolderSpawn: opts.openFolderSpawn, platform: opts.platform,
|
|
4515
|
+
openFolderSpawn: opts.openFolderSpawn, platform: opts.platform, mcpHome: opts.mcpHome,
|
|
4084
4516
|
});
|
|
4085
4517
|
runRoutes = createRunRoutes({
|
|
4086
4518
|
port: boundPort,
|