fwdloop 0.27.0 → 0.29.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 +1 -1
- package/bin/fwdloop +54 -13
- package/package.json +3 -3
- package/src/ask.js +1 -1
- package/src/audit-fold.js +9 -1
- package/src/authoring.js +22 -5
- package/src/canrun.js +19 -16
- package/src/checked.js +5 -2
- package/src/checkpick.js +257 -0
- package/src/checkwords.js +24 -0
- package/src/closers.js +8 -1
- package/src/config.js +18 -0
- package/src/declaration.js +85 -5
- package/src/drafter.js +143 -47
- package/src/flow.js +2 -1
- package/src/launcher.js +4 -2
- package/src/learn.js +1 -1
- package/src/learnstore.js +8 -7
- package/src/mcp-checks.js +50 -0
- package/src/mcp-pick.js +33 -0
- package/src/mcp-sources.js +84 -0
- package/src/mcp-use.js +54 -0
- package/src/memo.js +120 -0
- package/src/model-step.js +89 -17
- package/src/natural.js +23 -0
- package/src/pageask.js +9 -6
- package/src/pagedropwords.js +9 -0
- package/src/panel/author.js +50 -28
- package/src/panel/authorcard.js +86 -2
- package/src/panel/authorflows.js +18 -14
- package/src/panel/authortrigger.js +241 -84
- package/src/panel/data.js +99 -11
- package/src/panel/index.html +683 -210
- package/src/panel/jobgrid.js +127 -0
- package/src/panel/result.js +28 -7
- package/src/panel/scheduler.js +8 -2
- package/src/panel/server.js +17 -7
- package/src/panel/settings.js +119 -4
- package/src/panel/tickets.js +12 -7
- package/src/pickrecord.js +146 -0
- package/src/plain-checks.js +1 -0
- package/src/primitives.js +34 -5
- package/src/provider.js +4 -1
- package/src/runfile.js +4 -2
- package/src/runner.js +170 -45
- package/src/send.js +71 -4
- package/src/setup.js +13 -1
- package/src/summary-words.js +15 -3
- package/src/ticket-draft.js +40 -42
- package/src/ticket-labels.js +10 -0
- package/src/ticket-mcp.js +33 -10
- package/src/ticket-next.js +33 -0
- package/src/ticket-shape.js +9 -0
- package/src/trigger-clock.js +4 -4
- package/src/trigger-files.js +3 -3
- package/src/trigger-tickets.js +41 -12
- package/types/ask.d.ts +2 -1
- package/types/audit-fold.d.ts +13 -2
- package/types/authoring.d.ts +10 -2
- package/types/canrun.d.ts +5 -12
- package/types/checked.d.ts +7 -2
- package/types/checkpick.d.ts +149 -0
- package/types/checkwords.d.ts +14 -0
- package/types/closers.d.ts +2 -1
- package/types/config.d.ts +6 -0
- package/types/declaration.d.ts +17 -0
- package/types/drafter.d.ts +446 -50
- package/types/learn.d.ts +1 -0
- package/types/learnstore.d.ts +2 -3
- package/types/mcp-checks.d.ts +8 -0
- package/types/mcp-pick.d.ts +23 -0
- package/types/mcp-sources.d.ts +51 -0
- package/types/mcp-use.d.ts +12 -0
- package/types/memo.d.ts +15 -0
- package/types/model-step.d.ts +5 -0
- package/types/natural.d.ts +2 -0
- package/types/pageask.d.ts +9 -2
- package/types/pagedropwords.d.ts +1 -0
- package/types/panel/author.d.ts +37 -1
- package/types/panel/authorcard.d.ts +52 -0
- package/types/panel/authorflows.d.ts +9 -1
- package/types/panel/authortrigger.d.ts +73 -7
- package/types/panel/data.d.ts +56 -2
- package/types/panel/jobgrid.d.ts +109 -0
- package/types/panel/result.d.ts +9 -3
- package/types/panel/server.d.ts +5 -1
- package/types/panel/settings.d.ts +3 -2
- package/types/panel/tickets.d.ts +26 -4
- package/types/pickrecord.d.ts +88 -0
- package/types/primitives.d.ts +15 -2
- package/types/runfile.d.ts +7 -2
- package/types/runner.d.ts +128 -77
- package/types/send.d.ts +10 -2
- package/types/setup.d.ts +1 -56
- package/types/summary-words.d.ts +22 -3
- package/types/ticket-draft.d.ts +40 -32
- package/types/ticket-labels.d.ts +6 -0
- package/types/ticket-mcp.d.ts +18 -1
- package/types/ticket-next.d.ts +23 -0
- package/types/ticket-shape.d.ts +5 -0
- package/types/trigger-clock.d.ts +4 -3
- package/types/trigger-files.d.ts +1 -1
- package/types/trigger-tickets.d.ts +18 -4
- package/src/attemptdiff.js +0 -118
- package/types/attemptdiff.d.ts +0 -38
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/** the added paths in config.json (typed form); none under a test process with no config home, or when config.json is broken (the page says so) @param {string} [home] */
|
|
2
|
+
export function addedMcpPaths(home?: string): {
|
|
3
|
+
paths: string[];
|
|
4
|
+
problem: null;
|
|
5
|
+
} | {
|
|
6
|
+
paths: never[];
|
|
7
|
+
problem: string;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Every place, in order, with the servers found in it.
|
|
11
|
+
* `status`: 'found' (a readable file), 'missing' (no file) or 'not-json' (a file that is not JSON; bare-agent skips it silently).
|
|
12
|
+
* A server: `{name, remote, shadowedBy}`; `shadowedBy` is the shown path of the earlier place that has the same name (the earlier one wins), or null.
|
|
13
|
+
* @param {{ home?: string }} [o] `home` the config home (tests); undefined = the door's
|
|
14
|
+
* @returns {{ places: Array<{ path: string, file: string, added: boolean, status: 'found'|'missing'|'not-json', servers: Array<{name: string, remote: boolean, shadowedBy: string|null}> }>, problem: string|null }}
|
|
15
|
+
*/
|
|
16
|
+
export function mcpSources(o?: {
|
|
17
|
+
home?: string;
|
|
18
|
+
}): {
|
|
19
|
+
places: Array<{
|
|
20
|
+
path: string;
|
|
21
|
+
file: string;
|
|
22
|
+
added: boolean;
|
|
23
|
+
status: "found" | "missing" | "not-json";
|
|
24
|
+
servers: Array<{
|
|
25
|
+
name: string;
|
|
26
|
+
remote: boolean;
|
|
27
|
+
shadowedBy: string | null;
|
|
28
|
+
}>;
|
|
29
|
+
}>;
|
|
30
|
+
problem: string | null;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* The file that holds the WINNING `server` (the first place in the list that has the name), whether it is remote, or null when no place has it.
|
|
34
|
+
* Every place fwdloop starts an MCP from takes its config file from here.
|
|
35
|
+
* @param {string} server @param {{ home?: string }} [o]
|
|
36
|
+
* @returns {{ file: string, remote: boolean } | null}
|
|
37
|
+
*/
|
|
38
|
+
export function mcpConfigFor(server: string, o?: {
|
|
39
|
+
home?: string;
|
|
40
|
+
}): {
|
|
41
|
+
file: string;
|
|
42
|
+
remote: boolean;
|
|
43
|
+
} | null;
|
|
44
|
+
/** the names of the servers that can be started (winners only, remote left out) @param {{ home?: string }} [o] @returns {string[]} */
|
|
45
|
+
export function startableMcpServers(o?: {
|
|
46
|
+
home?: string;
|
|
47
|
+
}): string[];
|
|
48
|
+
export { mcpPathProblem } from "./config.js";
|
|
49
|
+
export function DEFAULT_MCP_PLACES(): string[];
|
|
50
|
+
export function expandMcpPath(p: string): string;
|
|
51
|
+
export function showMcpPath(p: string): string;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {string} root the jobs folder (`<root>/<flow>/runs/run-<n>/`)
|
|
3
|
+
* @param {string[]} servers the server names to count for; a step tool row belongs to the LONGEST name that prefixes it with `_`
|
|
4
|
+
* @returns {Map<string, { calls: number, runs: number, last: string|null, denied: number, tools: Map<string, number> }>}
|
|
5
|
+
*/
|
|
6
|
+
export function countMcpUse(root: string, servers: string[]): Map<string, {
|
|
7
|
+
calls: number;
|
|
8
|
+
runs: number;
|
|
9
|
+
last: string | null;
|
|
10
|
+
denied: number;
|
|
11
|
+
tools: Map<string, number>;
|
|
12
|
+
}>;
|
package/types/memo.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The memo for the try about to run, as text; `''` when nothing has happened yet in this run (no human line, no earlier try).
|
|
3
|
+
* @param {string|null} runDir the run's folder (null = no record = nothing happened)
|
|
4
|
+
* @param {{step: string|null, cap?: number}} o `step` = the step the try belongs to (names its earlier tries and tells a retry from a later step's first try)
|
|
5
|
+
* @returns {string}
|
|
6
|
+
*/
|
|
7
|
+
export function buildMemo(runDir: string | null, { step, cap }: {
|
|
8
|
+
step: string | null;
|
|
9
|
+
cap?: number;
|
|
10
|
+
}): string;
|
|
11
|
+
/** M14 am1 item 2: the memo's fixed words */
|
|
12
|
+
export const MEMO_HEADING: "What happened so far in this run (written by code, from the record)";
|
|
13
|
+
export const MEMO_CUT_NOTE: "(older lines cut to fit)";
|
|
14
|
+
/** M14 item 5 */
|
|
15
|
+
export const MEMO_CAP: 4000;
|
package/types/model-step.d.ts
CHANGED
|
@@ -133,3 +133,8 @@ export const LIVE_PROVIDER_OPTIONS: Readonly<{
|
|
|
133
133
|
timeoutMs: 300000;
|
|
134
134
|
deadlineMs: 240000;
|
|
135
135
|
}>;
|
|
136
|
+
/** M4d am37: the one fixed line a step that answered in text is sent, from code; the model never writes it and it never changes. */
|
|
137
|
+
export const NUDGE: "You answered in text. Call emit_artifact now with that answer; do not reply in text.";
|
|
138
|
+
/** M4d am37: a provider that says it does not send `toolChoice` (`makeProvider` sets the flag from the row's shape) ignores a forced call; round 2 then sends the line unforced and a save there is the fallback. */
|
|
139
|
+
/** Ruling A (hamr 2026-11-03): the fixed say on the audit row of a try whose forced call was refused with no usage returned; it books $0. */
|
|
140
|
+
export const FORCED_REFUSED_SAY: "refused, no bill returned";
|
package/types/pageask.d.ts
CHANGED
|
@@ -44,22 +44,29 @@ export function tooManyAsksText(asks: {
|
|
|
44
44
|
* What a typed answer to a look ask does, the ONE place that decides (the panel's answer route, the setup record and the Result tab all read it).
|
|
45
45
|
* `agree` / `yes` to a reading ask takes the code's reading; `drop it` to a can't-check ask leaves the rule Not checked (no `~` line); anything else is the
|
|
46
46
|
* person's own words, taken word for word with newlines folded to spaces. A question that is not a look ask is never changed: its answer is its rule.
|
|
47
|
-
*
|
|
48
|
-
*
|
|
47
|
+
* M10 am16: a shape guardrail's ask (`ask: 'check'` proposes a check, `'no-check'` found none) takes the same words: `agree` takes the proposal (and the check it
|
|
48
|
+
* carries, `check`), `drop it` leaves the rule Not checked (either kind), anything else is the person's own words (`own`: a `~` rule on the line, no check).
|
|
49
|
+
* @param {{source?: string, ask?: string, proposal?: string|null, check?: Record<string, any>}} q @param {unknown} typed
|
|
50
|
+
* @returns {{rule: string|null, left: boolean, check?: Record<string, any>, own?: boolean}} `rule` = the words written as a new `~` rule (null when the rule is left Not checked)
|
|
49
51
|
*/
|
|
50
52
|
export function ruleOfAnswer(q: {
|
|
51
53
|
source?: string;
|
|
52
54
|
ask?: string;
|
|
53
55
|
proposal?: string | null;
|
|
56
|
+
check?: Record<string, any>;
|
|
54
57
|
}, typed: unknown): {
|
|
55
58
|
rule: string | null;
|
|
56
59
|
left: boolean;
|
|
60
|
+
check?: Record<string, any>;
|
|
61
|
+
own?: boolean;
|
|
57
62
|
};
|
|
58
63
|
/** the most asks before drafting; more than this is a job to rewrite, not a questionnaire (am1) */
|
|
59
64
|
export const MAX_LOOK_ASKS: 3;
|
|
60
65
|
/** the answer that drops a `~` rule the page cannot check: the person types it (any case, a closing full stop allowed) */
|
|
61
66
|
export const DROP_IT: "drop it";
|
|
62
67
|
export function isDropIt(text: unknown): boolean;
|
|
68
|
+
/** the answers that accept the code's reading of a rule; anything else the person types is their own reading */
|
|
69
|
+
export const AGREE_WORDS: string[];
|
|
63
70
|
export function isAgree(text: unknown): boolean;
|
|
64
71
|
export function stripAgreeLead(text: string): string;
|
|
65
72
|
/**
|
package/types/pagedropwords.d.ts
CHANGED
|
@@ -37,4 +37,5 @@ export function splitReadNotes(items: string[] | null | undefined, signed?: stri
|
|
|
37
37
|
/** The names of the facts a signed declaration checks (every cited fact of every step). Pure. @param {any} declaration @returns {string[]} */
|
|
38
38
|
export function signedFactNames(declaration: any): string[];
|
|
39
39
|
export function leftRuleLine(rule: string): string;
|
|
40
|
+
export function pickNoteLine(rule: string, reason: "no-pick" | "own-words"): string;
|
|
40
41
|
export type Dropped = import("./pagerules.js").Dropped;
|
package/types/panel/author.d.ts
CHANGED
|
@@ -126,7 +126,32 @@ export function createAuthor(opts: {
|
|
|
126
126
|
trigger: import("../trigger-line.js").Trigger;
|
|
127
127
|
sig: string;
|
|
128
128
|
}[];
|
|
129
|
+
startAnyway({ flow, number }: {
|
|
130
|
+
flow: string;
|
|
131
|
+
number: number;
|
|
132
|
+
}): {
|
|
133
|
+
ok: boolean;
|
|
134
|
+
say: string;
|
|
135
|
+
} | null;
|
|
129
136
|
retireStale(): void;
|
|
137
|
+
cardSchedule(spec: any, plan: {
|
|
138
|
+
arbiter: any;
|
|
139
|
+
declaration: any;
|
|
140
|
+
}): {
|
|
141
|
+
ok: true;
|
|
142
|
+
trigger: Trigger;
|
|
143
|
+
} | {
|
|
144
|
+
ok: false;
|
|
145
|
+
say: string;
|
|
146
|
+
};
|
|
147
|
+
signSchedule(o: {
|
|
148
|
+
flow: string;
|
|
149
|
+
flowSignatureHash: string;
|
|
150
|
+
trigger: Trigger;
|
|
151
|
+
from: string | null;
|
|
152
|
+
signedBy: string;
|
|
153
|
+
}): void;
|
|
154
|
+
armWaiting(): void;
|
|
130
155
|
busy(job: {
|
|
131
156
|
flow: string;
|
|
132
157
|
}): boolean;
|
|
@@ -180,6 +205,11 @@ export function createAuthor(opts: {
|
|
|
180
205
|
nextSlotMs: number | null;
|
|
181
206
|
lastOutcome: any;
|
|
182
207
|
hasGreenRun: boolean;
|
|
208
|
+
lookProblem: {
|
|
209
|
+
at: number;
|
|
210
|
+
why: string;
|
|
211
|
+
} | null;
|
|
212
|
+
waiting: boolean;
|
|
183
213
|
} | null;
|
|
184
214
|
facts(flow: string): {
|
|
185
215
|
from: string | null;
|
|
@@ -197,8 +227,14 @@ export function createAuthor(opts: {
|
|
|
197
227
|
nextSlotMs: number | null;
|
|
198
228
|
lastOutcome: any;
|
|
199
229
|
hasGreenRun: boolean;
|
|
230
|
+
lookProblem: {
|
|
231
|
+
at: number;
|
|
232
|
+
why: string;
|
|
233
|
+
} | null;
|
|
234
|
+
waiting: boolean;
|
|
200
235
|
} | null;
|
|
201
236
|
card(flow: string): {
|
|
237
|
+
waitingSay?: string | undefined;
|
|
202
238
|
trigger: import("../trigger-line.js").Trigger | null;
|
|
203
239
|
words: string | null;
|
|
204
240
|
armed: boolean;
|
|
@@ -341,7 +377,7 @@ export function createAuthor(opts: {
|
|
|
341
377
|
* `POST /api/author/:id/answer` body `{ k, answer }` (M4e amendments 24, 25): the human's answer to the plan's question `k` of `n`, one at a time.
|
|
342
378
|
* A blank answer is refused and the question stays open; there is no skip. The answer is written ONCE ('wx') as `<plan>/answer-<k>.json`. After
|
|
343
379
|
* the LAST answer the plan is drafted again as a fresh plain `fwdloop draft --no-questions` child (it never asks), from the submitted card with
|
|
344
|
-
* each answer added word for word as a `~` guardrail under its line (the one `
|
|
380
|
+
* each answer added word for word as a `~` guardrail under its line (the one `applyAnswers`, then the one `cardToProse`). It is booked as
|
|
345
381
|
* an answer redraft (`redraft-<n>.json`), not a revise: it uses none of the 2. Synchronous, like `revise`; a refusal at $0 writes nothing.
|
|
346
382
|
* @param {string} id @param {any} body
|
|
347
383
|
*/
|
|
@@ -36,6 +36,47 @@ export function appendAnswersToJob(job: string, answers: {
|
|
|
36
36
|
job: string;
|
|
37
37
|
added: number;
|
|
38
38
|
};
|
|
39
|
+
/**
|
|
40
|
+
* M10 am21: the submitted job box with ONE `~` line of a job line replaced by the words of an answer (the edited added line the ask was about). Pure.
|
|
41
|
+
* @param {string} job @param {number} line the job line (step) number @param {string} oldText the `~` words to replace (case and spacing aside) @param {string} newText
|
|
42
|
+
* @returns {{ job: string, replaced: boolean }}
|
|
43
|
+
*/
|
|
44
|
+
export function replaceRuleOnJob(job: string, line: number, oldText: string, newText: string): {
|
|
45
|
+
job: string;
|
|
46
|
+
replaced: boolean;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* THE one writer of what a set of answers does to the job box and to the picks (M4e am24, M10 am16 (4), M10 am21): an answer is one more `~` line under its job line
|
|
50
|
+
* (`appendAnswersToJob`), EXCEPT the answer to an ask about an edited added line (`pairRule`), which REPLACES that line's words (the old added line never comes back).
|
|
51
|
+
* Picks and left rules are numbered as the asks carried them; an edited-line pick is kept under its source's number (`pairRule`), with the edited words as `added`.
|
|
52
|
+
* @param {string} job @param {{line: number, rule: string|null, left: boolean, check?: Record<string, any>|null, own?: boolean, ruleNo?: number, ruleText?: string, ask?: string, pairRule?: number}[]} all
|
|
53
|
+
* @returns {{job: string, added: number, picks: {line: number, rule: number|undefined, check: Record<string, any>|null, added: string, own?: boolean}[], left: {line: number, rule: number|undefined}[]}}
|
|
54
|
+
*/
|
|
55
|
+
export function applyAnswers(job: string, all: {
|
|
56
|
+
line: number;
|
|
57
|
+
rule: string | null;
|
|
58
|
+
left: boolean;
|
|
59
|
+
check?: Record<string, any> | null;
|
|
60
|
+
own?: boolean;
|
|
61
|
+
ruleNo?: number;
|
|
62
|
+
ruleText?: string;
|
|
63
|
+
ask?: string;
|
|
64
|
+
pairRule?: number;
|
|
65
|
+
}[]): {
|
|
66
|
+
job: string;
|
|
67
|
+
added: number;
|
|
68
|
+
picks: {
|
|
69
|
+
line: number;
|
|
70
|
+
rule: number | undefined;
|
|
71
|
+
check: Record<string, any> | null;
|
|
72
|
+
added: string;
|
|
73
|
+
own?: boolean;
|
|
74
|
+
}[];
|
|
75
|
+
left: {
|
|
76
|
+
line: number;
|
|
77
|
+
rule: number | undefined;
|
|
78
|
+
}[];
|
|
79
|
+
};
|
|
39
80
|
/**
|
|
40
81
|
* THE one place a step's `~` lines become its guardrail: several `~` lines under one step are ONE continuous guardrail (hamr ruling 2026-10-09),
|
|
41
82
|
* each part verbatim (trimmed), in typed order, joined by "; ". An answer (am24) is one more `~` line, so it joins here too. The signed-text parser
|
|
@@ -63,6 +104,17 @@ export function parseInputLines(text: string): {
|
|
|
63
104
|
* @param {any} body
|
|
64
105
|
*/
|
|
65
106
|
export function cardFields(body: any): {
|
|
107
|
+
schedule?: {
|
|
108
|
+
kind: string;
|
|
109
|
+
hour?: undefined;
|
|
110
|
+
minute?: undefined;
|
|
111
|
+
} | {
|
|
112
|
+
kind: any;
|
|
113
|
+
hour: any;
|
|
114
|
+
minute: any;
|
|
115
|
+
} | undefined;
|
|
116
|
+
flowType?: string | undefined;
|
|
117
|
+
mcp?: string | undefined;
|
|
66
118
|
thinking?: boolean | undefined;
|
|
67
119
|
provider?: string | undefined;
|
|
68
120
|
model?: string | undefined;
|
|
@@ -47,7 +47,7 @@ export function createFlowsDoor(opts: {
|
|
|
47
47
|
/** M9 am8 item 1: the sentence that says why the SCHEDULE cannot start a run now (one is starting or still working; a run waiting at its ask does not count), or null. @param {string} name */
|
|
48
48
|
scheduleBusy(name: string): string | null;
|
|
49
49
|
/**
|
|
50
|
-
* M6 am9: is this run red, as the panel's glyph rule reads it (`[✗]` and nothing else; stopped `[■]` and waiting are not)? The server decides this itself,
|
|
50
|
+
* M6 am9: is this run red, as the panel's glyph rule reads it (`[✗]` and nothing else; stopped `[■]` and waiting are not; M13 9b.2: not a run that failed preflight)? The server decides this itself,
|
|
51
51
|
* never from the page's word. False for a run that does not resolve.
|
|
52
52
|
* @param {string} flow @param {unknown} runId
|
|
53
53
|
*/
|
|
@@ -95,6 +95,8 @@ export function createFlowsDoor(opts: {
|
|
|
95
95
|
} | {
|
|
96
96
|
ok: boolean;
|
|
97
97
|
card: {
|
|
98
|
+
flowType?: "mcp" | "plain" | "tickets" | undefined;
|
|
99
|
+
mcp?: any;
|
|
98
100
|
job: string;
|
|
99
101
|
inputs: string;
|
|
100
102
|
destination: string;
|
|
@@ -121,6 +123,8 @@ export function createFlowsDoor(opts: {
|
|
|
121
123
|
roles: any;
|
|
122
124
|
pages: Record<string, string>;
|
|
123
125
|
tickets: string[];
|
|
126
|
+
flowType: "mcp" | "plain" | "tickets";
|
|
127
|
+
mcp: any;
|
|
124
128
|
nextRunId: string;
|
|
125
129
|
lastRunId: string | null;
|
|
126
130
|
lastSources: Record<string, string>;
|
|
@@ -184,6 +188,8 @@ export function createFlowsDoor(opts: {
|
|
|
184
188
|
} | {
|
|
185
189
|
ok: boolean;
|
|
186
190
|
card: {
|
|
191
|
+
flowType?: "mcp" | "plain" | "tickets" | undefined;
|
|
192
|
+
mcp?: any;
|
|
187
193
|
job: string;
|
|
188
194
|
inputs: string;
|
|
189
195
|
destination: string;
|
|
@@ -210,6 +216,8 @@ export function createFlowsDoor(opts: {
|
|
|
210
216
|
roles: any;
|
|
211
217
|
pages: Record<string, string>;
|
|
212
218
|
tickets: string[];
|
|
219
|
+
flowType: "mcp" | "plain" | "tickets";
|
|
220
|
+
mcp: any;
|
|
213
221
|
nextRunId: string;
|
|
214
222
|
lastRunId: string | null;
|
|
215
223
|
lastSources: Record<string, string>;
|
|
@@ -2,22 +2,29 @@
|
|
|
2
2
|
export function readOutcomes(flowDir: string): any[];
|
|
3
3
|
/** The ONE writer of `triggers.jsonl`: append-only, one line per fire outcome. @param {string} flowDir @param {Record<string, any>} row */
|
|
4
4
|
export function appendOutcome(flowDir: string, row: Record<string, any>): void;
|
|
5
|
+
/** M9 item 1 and 2: does this job have "one green run"? @param {string} flowDir */
|
|
6
|
+
export function hasGreenRunForJob(flowDir: string): boolean;
|
|
5
7
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* @param {string} flowDir
|
|
8
|
+
* M13 piece 5: the first green run of this job (the earliest one to end), or null. A resume that ends green counts: the history row is the run's last. The one reader of
|
|
9
|
+
* "which run turned the schedule on".
|
|
10
|
+
* @param {string} flowDir @returns {{runId: string, runDir: string, at: string}|null}
|
|
10
11
|
*/
|
|
11
|
-
export function
|
|
12
|
+
export function firstGreenRunFor(flowDir: string): {
|
|
13
|
+
runId: string;
|
|
14
|
+
runDir: string;
|
|
15
|
+
at: string;
|
|
16
|
+
} | null;
|
|
12
17
|
/**
|
|
13
18
|
* The ONE writer of "this schedule was set": the starting point (am2 item 2). Idempotent per signing. A file kind records what is already there first
|
|
14
19
|
* (never runs; `baseline: false` = the folder is the same as the earlier signing's, whose rows were carried), then the armed row. Throws, naming why,
|
|
15
20
|
* when the target is not usable now.
|
|
16
|
-
*
|
|
21
|
+
* M13 piece 5: `ticketN` (the first green run's ticket number) rides the armed row of a ticket schedule, for its first look's cut.
|
|
22
|
+
* @param {string} flowDir @param {Schedule} schedule @param {number} now epoch ms @param {{baseline?: boolean, ticketN?: number}} [o]
|
|
17
23
|
* @returns {{armed: boolean, already: boolean}}
|
|
18
24
|
*/
|
|
19
25
|
export function armFor(flowDir: string, schedule: Schedule, now: number, o?: {
|
|
20
26
|
baseline?: boolean;
|
|
27
|
+
ticketN?: number;
|
|
21
28
|
}): {
|
|
22
29
|
armed: boolean;
|
|
23
30
|
already: boolean;
|
|
@@ -112,8 +119,56 @@ export function createTriggerDoor(opts: {
|
|
|
112
119
|
trigger: import("../trigger-line.js").Trigger;
|
|
113
120
|
sig: string;
|
|
114
121
|
}[];
|
|
122
|
+
/**
|
|
123
|
+
* M13 am3: `Run it anyway` on a skipped ticket while the job's ticket schedule is OFF (signed, waiting for its first green run): start that ticket's run at once, by hand
|
|
124
|
+
* (kind `run`, the job's normal cap), after the same checks `fire` makes (`startChecks`, the one function). `null` = not this door's case (no ticket schedule, or it is
|
|
125
|
+
* armed: the queue takes it, M12). Else `{ok, say}`; a refusal starts nothing and spends $0. It writes no ledger row: a skipped run never arms, a green one does (the existing path).
|
|
126
|
+
* @param {{flow: string, number: number}} a
|
|
127
|
+
* @returns {{ok: boolean, say: string} | null}
|
|
128
|
+
*/
|
|
129
|
+
startAnyway({ flow, number }: {
|
|
130
|
+
flow: string;
|
|
131
|
+
number: number;
|
|
132
|
+
}): {
|
|
133
|
+
ok: boolean;
|
|
134
|
+
say: string;
|
|
135
|
+
} | null;
|
|
115
136
|
/** A schedule whose job was Edited since (M9 am1: By hand again) is cancelled the way Cancel does it, once. Called at the top of every scheduler tick. */
|
|
116
137
|
retireStale(): void;
|
|
138
|
+
/**
|
|
139
|
+
* M13 piece 5 (signed item 7), the $0 check of the New job card's Schedule row, before anything is signed: the trigger it becomes, built from the plan that is about to be
|
|
140
|
+
* signed (`arbiter` and `declaration` of the draft). Every day at HH:MM is the card's own data; a new ticket is filled from the plan (one ticket-list input, the job's
|
|
141
|
+
* server and signed look tool). `{ok:false, say}` names what is wrong. Writes nothing.
|
|
142
|
+
* @param {any} spec the card's `schedule` @param {{arbiter: any, declaration: any}} plan
|
|
143
|
+
* @returns {{ok: true, trigger: Trigger} | {ok: false, say: string}}
|
|
144
|
+
*/
|
|
145
|
+
cardSchedule(spec: any, plan: {
|
|
146
|
+
arbiter: any;
|
|
147
|
+
declaration: any;
|
|
148
|
+
}): {
|
|
149
|
+
ok: true;
|
|
150
|
+
trigger: Trigger;
|
|
151
|
+
} | {
|
|
152
|
+
ok: false;
|
|
153
|
+
say: string;
|
|
154
|
+
};
|
|
155
|
+
/**
|
|
156
|
+
* M13 piece 5 (signed item 7): the New job card's sign writes `schedule.json` for the job it just signed, in the same sign action. OFF: no `armed` row. The one turn-on is
|
|
157
|
+
* `armWaiting` (a green run); `from` = the run the sign started. The job and its signature are not touched. @param {{flow: string, flowSignatureHash: string, trigger: Trigger, from: string|null, signedBy: string}} o
|
|
158
|
+
*/
|
|
159
|
+
signSchedule(o: {
|
|
160
|
+
flow: string;
|
|
161
|
+
flowSignatureHash: string;
|
|
162
|
+
trigger: Trigger;
|
|
163
|
+
from: string | null;
|
|
164
|
+
signedBy: string;
|
|
165
|
+
}): void;
|
|
166
|
+
/**
|
|
167
|
+
* M13 piece 5 (signed item 7): THE turn-on. A schedule signed with the job is off until the job's first green run (`firstGreenRunFor`: a resume that ends green counts, a red
|
|
168
|
+
* run does not); the panel's next check then writes its one `armed` row through `armFor`. A ticket schedule keeps the ticket number that run read (`ticketN`), so its first
|
|
169
|
+
* look baselines only tickets up to it and a ticket that came in during the wait still runs (F114f). Called at the top of every scheduler tick; idempotent.
|
|
170
|
+
*/
|
|
171
|
+
armWaiting(): void;
|
|
117
172
|
/** M9 am3/am8: is a run of this job starting or still working? A run waiting at its ask is not busy. (the same check `fire` makes first) @param {{flow: string}} job */
|
|
118
173
|
busy(job: {
|
|
119
174
|
flow: string;
|
|
@@ -188,6 +243,11 @@ export function createTriggerDoor(opts: {
|
|
|
188
243
|
nextSlotMs: number | null;
|
|
189
244
|
lastOutcome: any;
|
|
190
245
|
hasGreenRun: boolean;
|
|
246
|
+
lookProblem: {
|
|
247
|
+
at: number;
|
|
248
|
+
why: string;
|
|
249
|
+
} | null;
|
|
250
|
+
waiting: boolean;
|
|
191
251
|
} | null;
|
|
192
252
|
/**
|
|
193
253
|
* M9 am6/am7: every fact the Job tab's Schedule field, a run's Audit schedule rows and the Run tab's SCHEDULE block are built from, for one job: the
|
|
@@ -211,6 +271,11 @@ export function createTriggerDoor(opts: {
|
|
|
211
271
|
nextSlotMs: number | null;
|
|
212
272
|
lastOutcome: any;
|
|
213
273
|
hasGreenRun: boolean;
|
|
274
|
+
lookProblem: {
|
|
275
|
+
at: number;
|
|
276
|
+
why: string;
|
|
277
|
+
} | null;
|
|
278
|
+
waiting: boolean;
|
|
214
279
|
} | null;
|
|
215
280
|
/**
|
|
216
281
|
* What the Run card's dropdown needs of one job (M9 piece 5): the typed trigger, its words, whether it is armed, and, when the job has had
|
|
@@ -218,6 +283,7 @@ export function createTriggerDoor(opts: {
|
|
|
218
283
|
* @param {string} flow
|
|
219
284
|
*/
|
|
220
285
|
card(flow: string): {
|
|
286
|
+
waitingSay?: string | undefined;
|
|
221
287
|
trigger: import("../trigger-line.js").Trigger | null;
|
|
222
288
|
words: string | null;
|
|
223
289
|
armed: boolean;
|
|
@@ -225,7 +291,7 @@ export function createTriggerDoor(opts: {
|
|
|
225
291
|
refusal: string | null;
|
|
226
292
|
} | null;
|
|
227
293
|
};
|
|
228
|
-
/** M12: the
|
|
294
|
+
/** M12: the tool a ticket schedule's look uses. M13 piece 4: it must be in the job's signed `mcp.tools` (item 9b.1), and the schedule's two clicks sign it again. */
|
|
229
295
|
export const TICKET_LOOK_TOOL: "list_issues";
|
|
230
296
|
export const NO_GREEN_SAY: "This job has not had a good run yet. Run it once by hand and get it right first; then you can set when it runs. Nothing was changed.";
|
|
231
297
|
export type Trigger = import("../trigger-line.js").Trigger;
|
package/types/panel/data.d.ts
CHANGED
|
@@ -691,16 +691,19 @@ export function getRunAudit({ root, flow, runId, scheduleRead, home, catalogue,
|
|
|
691
691
|
* name carries its own why, never a blank or a guess. Field order (server
|
|
692
692
|
* order matches the page's own render order): prose, asks, model, cap
|
|
693
693
|
* (+redo cap), sources, sends, guardrails, plan (one row per step, amendment 34), signature.
|
|
694
|
-
*
|
|
694
|
+
* M13 am4 item 2: an MCP or Tickets MCP job also carries `flowType`, `mcp` (the server) and `tools` (`{name, hint}`; the hint is the newest OK check's, else null);
|
|
695
|
+
* a Tickets job adds `ticketFilter` and `ticketWatch`. A plain job's payload has none of these keys. `mcpChecks` reads the newest-check map (unsigned, config home).
|
|
696
|
+
* @param {{root: string, flow: string, runId: string, catalogue: any, scheduleRead?: (flow: string) => any, home?: string, mcpChecks?: () => Map<string, any>}} opts
|
|
695
697
|
* @returns {any|null}
|
|
696
698
|
*/
|
|
697
|
-
export function getRunJob({ root, flow, runId, catalogue, scheduleRead, home, }: {
|
|
699
|
+
export function getRunJob({ root, flow, runId, catalogue, scheduleRead, home, mcpChecks, }: {
|
|
698
700
|
root: string;
|
|
699
701
|
flow: string;
|
|
700
702
|
runId: string;
|
|
701
703
|
catalogue: any;
|
|
702
704
|
scheduleRead?: (flow: string) => any;
|
|
703
705
|
home?: string;
|
|
706
|
+
mcpChecks?: () => Map<string, any>;
|
|
704
707
|
}): any | null;
|
|
705
708
|
/**
|
|
706
709
|
* `GET /api/runs/:flow/:runId/result` — the Result tab (M10 am4). The Not checked list is the Job tab's own (`buildJobPlan`), never a second spelling.
|
|
@@ -734,6 +737,57 @@ export function getTicketList({ root, flow, runId, catalogue, }: {
|
|
|
734
737
|
rows: any[];
|
|
735
738
|
}>;
|
|
736
739
|
} | null;
|
|
740
|
+
/**
|
|
741
|
+
* M13 piece 6 (item 8): the Result tab's ONE grid of a job, all its runs (`buildJobGrid`, src/panel/jobgrid.js). Each run is read once through `loadRunContext`
|
|
742
|
+
* (the glyph is `computeGlyph`'s, the money the history row's), a ticket run is named by the ticket number its `run.json` recorded. `Run it anyway` is offered
|
|
743
|
+
* only for a ticket the ticket list (M12) puts in Skipped. `null` = the flow does not resolve.
|
|
744
|
+
* @param {{root: string, flow: string, catalogue: any, now?: () => number}} a
|
|
745
|
+
*/
|
|
746
|
+
export function getJobGrid({ root, flow, catalogue, now, }: {
|
|
747
|
+
root: string;
|
|
748
|
+
flow: string;
|
|
749
|
+
catalogue: any;
|
|
750
|
+
now?: () => number;
|
|
751
|
+
}): {
|
|
752
|
+
groups: {
|
|
753
|
+
rows: {
|
|
754
|
+
unsure: boolean;
|
|
755
|
+
runId: string;
|
|
756
|
+
name: string;
|
|
757
|
+
title: string | null;
|
|
758
|
+
number: number | null;
|
|
759
|
+
bucket: "done" | "skip" | "stop" | "wait";
|
|
760
|
+
glyph: string;
|
|
761
|
+
at: number;
|
|
762
|
+
ex: "r" | "n" | "g" | "q";
|
|
763
|
+
oj: "r" | "n" | "none" | "g" | "q";
|
|
764
|
+
cost: {
|
|
765
|
+
mark: string;
|
|
766
|
+
value: string;
|
|
767
|
+
};
|
|
768
|
+
time: {
|
|
769
|
+
mark: string;
|
|
770
|
+
value: any;
|
|
771
|
+
};
|
|
772
|
+
reason: string | null;
|
|
773
|
+
anyway: boolean;
|
|
774
|
+
lines: string[];
|
|
775
|
+
}[];
|
|
776
|
+
key: string;
|
|
777
|
+
label: string;
|
|
778
|
+
open: boolean;
|
|
779
|
+
}[];
|
|
780
|
+
anywayRunId: string | null;
|
|
781
|
+
stats: {
|
|
782
|
+
counts: {
|
|
783
|
+
[k: string]: number;
|
|
784
|
+
};
|
|
785
|
+
spent: string | null;
|
|
786
|
+
spentUsd: number | null;
|
|
787
|
+
spentComplete: boolean;
|
|
788
|
+
};
|
|
789
|
+
flowType: "mcp" | "plain" | "tickets" | null;
|
|
790
|
+
} | null;
|
|
737
791
|
/**
|
|
738
792
|
* `GET /api/runs/:flow/:runId/download?i=<n>` (M10 am4): one saved file, or why not.
|
|
739
793
|
* @param {{root: string, flow: string, runId: string, catalogue: any, index: unknown}} a
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/** a figure in dollars: `$0` for an exact zero, `$0.0412`, or `at least $0.0412` when the figure is only a floor (never `$0` for unknown) @param {number} usd @param {boolean} complete */
|
|
2
|
+
export function moneyWords(usd: number, complete: boolean): string;
|
|
3
|
+
/**
|
|
4
|
+
* One run's money: its history row's total when it has one (complete unless the row says the figure is a floor), else the priced spend rows (always a floor), else unknown.
|
|
5
|
+
* @param {{spentUsd?: unknown, spendComplete?: unknown}|null} history @param {any[]} spendRows
|
|
6
|
+
* @returns {{usd: number|null, complete: boolean}}
|
|
7
|
+
*/
|
|
8
|
+
export function runMoney(history: {
|
|
9
|
+
spentUsd?: unknown;
|
|
10
|
+
spendComplete?: unknown;
|
|
11
|
+
} | null, spendRows: any[]): {
|
|
12
|
+
usd: number | null;
|
|
13
|
+
complete: boolean;
|
|
14
|
+
};
|
|
15
|
+
/** the stats line's money: the sum of the runs' money, a floor when any run's is a floor or unknown; `null` usd = nothing is known @param {Array<{usd: number|null, complete: boolean}>} moneys */
|
|
16
|
+
export function sumMoney(moneys: Array<{
|
|
17
|
+
usd: number | null;
|
|
18
|
+
complete: boolean;
|
|
19
|
+
}>): {
|
|
20
|
+
usd: number | null;
|
|
21
|
+
complete: boolean;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* The two check columns of one run, from the run's own check record (the Audit grid's rows, by the same identities: #1 and #2 are `every step`, #3 and up are the
|
|
25
|
+
* close's checks, `try-checks.js`). `g` passed, `r` failed, `n` nothing ran or only a human's yes judged it (a human's yes is not a check), `none` steps ran but the job has no output check at all (only #1 and #2), `q` no verdict (the run ended
|
|
26
|
+
* red and its record holds no check at all). Also the detail lines the row opens to.
|
|
27
|
+
* @param {{diary: any[], steps: any[], ended: boolean, red: boolean, skipped: boolean}} a
|
|
28
|
+
* @returns {{ex: 'g'|'r'|'n'|'q', oj: 'g'|'r'|'n'|'none'|'q', lines: string[]}}
|
|
29
|
+
*/
|
|
30
|
+
export function checkCells({ diary, steps, ended, red, skipped }: {
|
|
31
|
+
diary: any[];
|
|
32
|
+
steps: any[];
|
|
33
|
+
ended: boolean;
|
|
34
|
+
red: boolean;
|
|
35
|
+
skipped: boolean;
|
|
36
|
+
}): {
|
|
37
|
+
ex: "g" | "r" | "n" | "q";
|
|
38
|
+
oj: "g" | "r" | "n" | "none" | "q";
|
|
39
|
+
lines: string[];
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* The grid of one job: every run a row in its bucket, newest first inside each bucket, and the stats line's numbers.
|
|
43
|
+
* @param {{runs: Array<{runId: string, glyph: string, ticket: number|null, title?: string|null, unsure?: boolean, at: number|null, history: any, spendRows: any[], diary: any[], steps: any[], reason: string|null}>, anyway?: {runId: string, numbers: Set<number>}|null, now?: number}} a
|
|
44
|
+
*/
|
|
45
|
+
export function buildJobGrid({ runs, anyway, now }: {
|
|
46
|
+
runs: Array<{
|
|
47
|
+
runId: string;
|
|
48
|
+
glyph: string;
|
|
49
|
+
ticket: number | null;
|
|
50
|
+
title?: string | null;
|
|
51
|
+
unsure?: boolean;
|
|
52
|
+
at: number | null;
|
|
53
|
+
history: any;
|
|
54
|
+
spendRows: any[];
|
|
55
|
+
diary: any[];
|
|
56
|
+
steps: any[];
|
|
57
|
+
reason: string | null;
|
|
58
|
+
}>;
|
|
59
|
+
anyway?: {
|
|
60
|
+
runId: string;
|
|
61
|
+
numbers: Set<number>;
|
|
62
|
+
} | null;
|
|
63
|
+
now?: number;
|
|
64
|
+
}): {
|
|
65
|
+
groups: {
|
|
66
|
+
rows: {
|
|
67
|
+
unsure: boolean;
|
|
68
|
+
runId: string;
|
|
69
|
+
name: string;
|
|
70
|
+
title: string | null;
|
|
71
|
+
number: number | null;
|
|
72
|
+
bucket: "done" | "skip" | "stop" | "wait";
|
|
73
|
+
glyph: string;
|
|
74
|
+
at: number;
|
|
75
|
+
ex: "r" | "n" | "g" | "q";
|
|
76
|
+
oj: "r" | "n" | "none" | "g" | "q";
|
|
77
|
+
cost: {
|
|
78
|
+
mark: string;
|
|
79
|
+
value: string;
|
|
80
|
+
};
|
|
81
|
+
time: {
|
|
82
|
+
mark: string;
|
|
83
|
+
value: any;
|
|
84
|
+
};
|
|
85
|
+
reason: string | null;
|
|
86
|
+
anyway: boolean;
|
|
87
|
+
lines: string[];
|
|
88
|
+
}[];
|
|
89
|
+
key: string;
|
|
90
|
+
label: string;
|
|
91
|
+
open: boolean;
|
|
92
|
+
}[];
|
|
93
|
+
anywayRunId: string | null;
|
|
94
|
+
stats: {
|
|
95
|
+
counts: {
|
|
96
|
+
[k: string]: number;
|
|
97
|
+
};
|
|
98
|
+
spent: string | null;
|
|
99
|
+
spentUsd: number | null;
|
|
100
|
+
spentComplete: boolean;
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
/** the buckets, in the mock's order (the same four as the M12 ticket list: one list of words) */
|
|
104
|
+
export const GRID_BUCKETS: readonly {
|
|
105
|
+
key: string;
|
|
106
|
+
label: string;
|
|
107
|
+
open: boolean;
|
|
108
|
+
}[];
|
|
109
|
+
export function bucketOf(glyph: string): "wait" | "stop" | "done" | "skip";
|