fwdloop 0.26.2 → 0.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/fwdloop +46 -7
- package/package.json +2 -2
- package/src/authoring.js +21 -1
- package/src/canrun.js +23 -0
- package/src/config.js +18 -0
- package/src/declaration.js +129 -3
- package/src/drafter.js +38 -10
- package/src/flow.js +2 -1
- package/src/launcher.js +4 -2
- package/src/learnstore.js +3 -2
- 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/natural.js +23 -0
- package/src/panel/author.js +17 -1
- package/src/panel/authorcard.js +35 -0
- package/src/panel/authorflows.js +15 -6
- package/src/panel/authorstart.js +10 -6
- package/src/panel/authortrigger.js +263 -82
- package/src/panel/data.js +127 -9
- package/src/panel/index.html +945 -94
- package/src/panel/jobgrid.js +127 -0
- package/src/panel/scheduler.js +48 -6
- package/src/panel/server.js +33 -8
- package/src/panel/settings.js +119 -4
- package/src/panel/tickets.js +118 -0
- package/src/primitives.js +34 -5
- package/src/runner.js +129 -15
- package/src/schedule.js +5 -0
- package/src/summary-words.js +27 -7
- package/src/ticket-draft.js +85 -0
- package/src/ticket-labels.js +75 -0
- package/src/ticket-mcp.js +89 -0
- package/src/ticket-next.js +33 -0
- package/src/ticket-shape.js +33 -0
- package/src/trigger-clock.js +4 -4
- package/src/trigger-files.js +4 -4
- package/src/trigger-line.js +2 -1
- package/src/trigger-tickets.js +238 -0
- package/types/authoring.d.ts +5 -1
- package/types/canrun.d.ts +7 -0
- package/types/config.d.ts +6 -0
- package/types/declaration.d.ts +8 -0
- package/types/drafter.d.ts +552 -21
- 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/natural.d.ts +2 -0
- package/types/panel/author.d.ts +44 -0
- package/types/panel/authorcard.d.ts +11 -0
- package/types/panel/authorflows.d.ts +11 -1
- package/types/panel/authorstart.d.ts +3 -1
- package/types/panel/authortrigger.d.ts +83 -7
- package/types/panel/data.d.ts +78 -5
- package/types/panel/jobgrid.d.ts +109 -0
- package/types/panel/scheduler.d.ts +7 -2
- package/types/panel/server.d.ts +13 -2
- package/types/panel/settings.d.ts +3 -2
- package/types/panel/tickets.d.ts +103 -0
- package/types/primitives.d.ts +15 -2
- package/types/runner.d.ts +133 -75
- package/types/summary-words.d.ts +24 -4
- package/types/ticket-draft.d.ts +104 -0
- package/types/ticket-labels.d.ts +42 -0
- package/types/ticket-mcp.d.ts +57 -0
- package/types/ticket-next.d.ts +23 -0
- package/types/ticket-shape.d.ts +30 -0
- package/types/trigger-clock.d.ts +4 -3
- package/types/trigger-files.d.ts +3 -1
- package/types/trigger-line.d.ts +7 -0
- package/types/trigger-tickets.d.ts +105 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {string} server @param {string|undefined|null} home the config home; undefined = the door's decision (`configDoorHome`: a test process with no `FWDLOOP_CONFIG_HOME` has none, so "never checked"; otherwise the default config home); null = none
|
|
3
|
+
* @returns {{ ok: true, server: string, tools: string[] } | { ok: false, say: string }}
|
|
4
|
+
*/
|
|
5
|
+
export function mcpPickFor(server: string, home: string | undefined | null): {
|
|
6
|
+
ok: true;
|
|
7
|
+
server: string;
|
|
8
|
+
tools: string[];
|
|
9
|
+
} | {
|
|
10
|
+
ok: false;
|
|
11
|
+
say: string;
|
|
12
|
+
};
|
|
13
|
+
/** `mcpPickFor` at the config home this process uses (a test process with no `FWDLOOP_CONFIG_HOME` has none) @param {string} server */
|
|
14
|
+
export function mcpPickHere(server: string): {
|
|
15
|
+
ok: true;
|
|
16
|
+
server: string;
|
|
17
|
+
tools: string[];
|
|
18
|
+
} | {
|
|
19
|
+
ok: false;
|
|
20
|
+
say: string;
|
|
21
|
+
};
|
|
22
|
+
/** the one refusal for an MCP nobody has checked (or whose check never succeeded) */
|
|
23
|
+
export const NEVER_CHECKED_SAY: "press check tools in Settings > MCP first";
|
|
@@ -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/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;
|
|
@@ -157,6 +182,14 @@ export function createAuthor(opts: {
|
|
|
157
182
|
kind: "file";
|
|
158
183
|
path: string;
|
|
159
184
|
sha: string;
|
|
185
|
+
} | {
|
|
186
|
+
kind: "ticket";
|
|
187
|
+
number: number;
|
|
188
|
+
sha: string;
|
|
189
|
+
role: string;
|
|
190
|
+
list: string;
|
|
191
|
+
why?: string;
|
|
192
|
+
anyway?: boolean;
|
|
160
193
|
}, hooks?: {
|
|
161
194
|
told?: (row: Record<string, any>) => boolean;
|
|
162
195
|
beforeStart?: () => void;
|
|
@@ -172,6 +205,11 @@ export function createAuthor(opts: {
|
|
|
172
205
|
nextSlotMs: number | null;
|
|
173
206
|
lastOutcome: any;
|
|
174
207
|
hasGreenRun: boolean;
|
|
208
|
+
lookProblem: {
|
|
209
|
+
at: number;
|
|
210
|
+
why: string;
|
|
211
|
+
} | null;
|
|
212
|
+
waiting: boolean;
|
|
175
213
|
} | null;
|
|
176
214
|
facts(flow: string): {
|
|
177
215
|
from: string | null;
|
|
@@ -189,8 +227,14 @@ export function createAuthor(opts: {
|
|
|
189
227
|
nextSlotMs: number | null;
|
|
190
228
|
lastOutcome: any;
|
|
191
229
|
hasGreenRun: boolean;
|
|
230
|
+
lookProblem: {
|
|
231
|
+
at: number;
|
|
232
|
+
why: string;
|
|
233
|
+
} | null;
|
|
234
|
+
waiting: boolean;
|
|
192
235
|
} | null;
|
|
193
236
|
card(flow: string): {
|
|
237
|
+
waitingSay?: string | undefined;
|
|
194
238
|
trigger: import("../trigger-line.js").Trigger | null;
|
|
195
239
|
words: string | null;
|
|
196
240
|
armed: boolean;
|
|
@@ -63,6 +63,17 @@ export function parseInputLines(text: string): {
|
|
|
63
63
|
* @param {any} body
|
|
64
64
|
*/
|
|
65
65
|
export function cardFields(body: any): {
|
|
66
|
+
schedule?: {
|
|
67
|
+
kind: string;
|
|
68
|
+
hour?: undefined;
|
|
69
|
+
minute?: undefined;
|
|
70
|
+
} | {
|
|
71
|
+
kind: any;
|
|
72
|
+
hour: any;
|
|
73
|
+
minute: any;
|
|
74
|
+
} | undefined;
|
|
75
|
+
flowType?: string | undefined;
|
|
76
|
+
mcp?: string | undefined;
|
|
66
77
|
thinking?: boolean | undefined;
|
|
67
78
|
provider?: string | undefined;
|
|
68
79
|
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;
|
|
@@ -120,6 +122,9 @@ export function createFlowsDoor(opts: {
|
|
|
120
122
|
capUsd: any;
|
|
121
123
|
roles: any;
|
|
122
124
|
pages: Record<string, string>;
|
|
125
|
+
tickets: string[];
|
|
126
|
+
flowType: "mcp" | "plain" | "tickets";
|
|
127
|
+
mcp: any;
|
|
123
128
|
nextRunId: string;
|
|
124
129
|
lastRunId: string | null;
|
|
125
130
|
lastSources: Record<string, string>;
|
|
@@ -183,6 +188,8 @@ export function createFlowsDoor(opts: {
|
|
|
183
188
|
} | {
|
|
184
189
|
ok: boolean;
|
|
185
190
|
card: {
|
|
191
|
+
flowType?: "mcp" | "plain" | "tickets" | undefined;
|
|
192
|
+
mcp?: any;
|
|
186
193
|
job: string;
|
|
187
194
|
inputs: string;
|
|
188
195
|
destination: string;
|
|
@@ -208,6 +215,9 @@ export function createFlowsDoor(opts: {
|
|
|
208
215
|
capUsd: any;
|
|
209
216
|
roles: any;
|
|
210
217
|
pages: Record<string, string>;
|
|
218
|
+
tickets: string[];
|
|
219
|
+
flowType: "mcp" | "plain" | "tickets";
|
|
220
|
+
mcp: any;
|
|
211
221
|
nextRunId: string;
|
|
212
222
|
lastRunId: string | null;
|
|
213
223
|
lastSources: Record<string, string>;
|
|
@@ -34,7 +34,7 @@ export function createStarter(opts: {
|
|
|
34
34
|
* folder as `signed-values.json` BEFORE the spawn; the run then uses them (`pickRunValues`). None = the flow's own.
|
|
35
35
|
* `trigger` (M9): `{kind, reason, catchUp, ...}` for a start a trigger fired (kind 'trigger'): written once into the run's own folder as `trigger.json`
|
|
36
36
|
* BEFORE the spawn; `appendHistory` copies it into the run's history row (the catch-up mark, am2 item 1).
|
|
37
|
-
* @param {{ kind: 'run'|'sign'|'trigger', flow: string, runId: string, sources: {role: string, path: string}[], planRun?: boolean, planOf?: string|null, values?: any, pick?: {slot: string, model: string}|null, trigger?: Record<string, any>|null }} a
|
|
37
|
+
* @param {{ kind: 'run'|'sign'|'trigger', flow: string, runId: string, sources: {role: string, path: string, ticket?: number, anyway?: boolean}[], planRun?: boolean, planOf?: string|null, values?: any, pick?: {slot: string, model: string}|null, trigger?: Record<string, any>|null }} a
|
|
38
38
|
* @param {{ env: Record<string, string|undefined>, keyNames?: string[] }} loaded the keys load: its env is the child's env AND (with its key names) the scrub list
|
|
39
39
|
* @returns {{ status: number, body: any }}
|
|
40
40
|
*/
|
|
@@ -45,6 +45,8 @@ export function createStarter(opts: {
|
|
|
45
45
|
sources: {
|
|
46
46
|
role: string;
|
|
47
47
|
path: string;
|
|
48
|
+
ticket?: number;
|
|
49
|
+
anyway?: boolean;
|
|
48
50
|
}[];
|
|
49
51
|
planRun?: boolean;
|
|
50
52
|
planOf?: string | null;
|
|
@@ -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;
|
|
@@ -139,7 +194,7 @@ export function createTriggerDoor(opts: {
|
|
|
139
194
|
* are missing) -> started through the ONE start path (kind `trigger`; the reason and the catch-up mark go into the run's own folder first).
|
|
140
195
|
* The fire / ran ledger row was written by the caller BEFORE this, so a crash loses a run and never doubles one.
|
|
141
196
|
* @param {{flow: string, flowDir: string, read: any, trigger: Trigger, schedule: Schedule}} job
|
|
142
|
-
* @param {{kind: 'clock', slot: number, catchUp: boolean, missed: number} | {kind: 'file', path: string, sha: string}} cause
|
|
197
|
+
* @param {{kind: 'clock', slot: number, catchUp: boolean, missed: number} | {kind: 'file', path: string, sha: string} | {kind: 'ticket', number: number, sha: string, role: string, list: string, why?: string, anyway?: boolean}} cause
|
|
143
198
|
* @param {{ told?: (row: Record<string, any>) => boolean, beforeStart?: () => void, holdIfCannotStart?: boolean }} [hooks] M9 am3 (a queued file): `told(row)` true = this file
|
|
144
199
|
* already has a row for that outcome and reason (`why`), so none is written again (the outcome is still returned); `beforeStart` runs right before the ONE
|
|
145
200
|
* start, once every check has passed: the scheduler writes the file's `ran` row there. `holdIfCannotStart` (a queued file, M9 am17): the starter's `canStart` is asked first, and a no writes nothing
|
|
@@ -160,6 +215,14 @@ export function createTriggerDoor(opts: {
|
|
|
160
215
|
kind: "file";
|
|
161
216
|
path: string;
|
|
162
217
|
sha: string;
|
|
218
|
+
} | {
|
|
219
|
+
kind: "ticket";
|
|
220
|
+
number: number;
|
|
221
|
+
sha: string;
|
|
222
|
+
role: string;
|
|
223
|
+
list: string;
|
|
224
|
+
why?: string;
|
|
225
|
+
anyway?: boolean;
|
|
163
226
|
}, hooks?: {
|
|
164
227
|
told?: (row: Record<string, any>) => boolean;
|
|
165
228
|
beforeStart?: () => void;
|
|
@@ -180,6 +243,11 @@ export function createTriggerDoor(opts: {
|
|
|
180
243
|
nextSlotMs: number | null;
|
|
181
244
|
lastOutcome: any;
|
|
182
245
|
hasGreenRun: boolean;
|
|
246
|
+
lookProblem: {
|
|
247
|
+
at: number;
|
|
248
|
+
why: string;
|
|
249
|
+
} | null;
|
|
250
|
+
waiting: boolean;
|
|
183
251
|
} | null;
|
|
184
252
|
/**
|
|
185
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
|
|
@@ -203,6 +271,11 @@ export function createTriggerDoor(opts: {
|
|
|
203
271
|
nextSlotMs: number | null;
|
|
204
272
|
lastOutcome: any;
|
|
205
273
|
hasGreenRun: boolean;
|
|
274
|
+
lookProblem: {
|
|
275
|
+
at: number;
|
|
276
|
+
why: string;
|
|
277
|
+
} | null;
|
|
278
|
+
waiting: boolean;
|
|
206
279
|
} | null;
|
|
207
280
|
/**
|
|
208
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
|
|
@@ -210,6 +283,7 @@ export function createTriggerDoor(opts: {
|
|
|
210
283
|
* @param {string} flow
|
|
211
284
|
*/
|
|
212
285
|
card(flow: string): {
|
|
286
|
+
waitingSay?: string | undefined;
|
|
213
287
|
trigger: import("../trigger-line.js").Trigger | null;
|
|
214
288
|
words: string | null;
|
|
215
289
|
armed: boolean;
|
|
@@ -217,6 +291,8 @@ export function createTriggerDoor(opts: {
|
|
|
217
291
|
refusal: string | null;
|
|
218
292
|
} | null;
|
|
219
293
|
};
|
|
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. */
|
|
295
|
+
export const TICKET_LOOK_TOOL: "list_issues";
|
|
220
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.";
|
|
221
297
|
export type Trigger = import("../trigger-line.js").Trigger;
|
|
222
298
|
export type Schedule = import("../schedule.js").Schedule;
|
package/types/panel/data.d.ts
CHANGED
|
@@ -177,7 +177,7 @@ export function glyphPulses(g: {
|
|
|
177
177
|
* - `[?]` crashed after taking your answer (amendment 2 (f)) — the answer was
|
|
178
178
|
* consumed, the process is gone, no end row: cannot be carried on.
|
|
179
179
|
* @param {{historyRow: any, askJson: any, consumedAnswerExists: boolean, hasStateJson: boolean, resume?: any, liveness?: 'running'|'gone'|'unknown', booksFresh?: boolean, lock?: string, resumable?: boolean, stoppedAtAsk?: string|null, jobEdited?: boolean, starting?: boolean}} ctx
|
|
180
|
-
* @returns {{glyph: '[✓]'|'[✗]'|'[·]'|'[!]'|'[▶]'|'[?]'|'[II]'|'[■]', label: string}}
|
|
180
|
+
* @returns {{glyph: '[✓]'|'[✗]'|'[·]'|'[!]'|'[▶]'|'[?]'|'[II]'|'[■]'|'[–]', label: string}}
|
|
181
181
|
*/
|
|
182
182
|
export function computeGlyph({ historyRow, askJson, consumedAnswerExists, hasStateJson, resume, liveness, booksFresh, lock, resumable, stoppedAtAsk, jobEdited, starting, }: {
|
|
183
183
|
historyRow: any;
|
|
@@ -193,7 +193,7 @@ export function computeGlyph({ historyRow, askJson, consumedAnswerExists, hasSta
|
|
|
193
193
|
jobEdited?: boolean;
|
|
194
194
|
starting?: boolean;
|
|
195
195
|
}): {
|
|
196
|
-
glyph: "[\u2713]" | "[\u2717]" | "[\u00B7]" | "[!]" | "[\u25B6]" | "[?]" | "[II]" | "[\u25A0]";
|
|
196
|
+
glyph: "[\u2713]" | "[\u2717]" | "[\u00B7]" | "[!]" | "[\u25B6]" | "[?]" | "[II]" | "[\u25A0]" | "[\u2013]";
|
|
197
197
|
label: string;
|
|
198
198
|
};
|
|
199
199
|
/**
|
|
@@ -451,7 +451,7 @@ export function getRunGlyph({ root, flow, runId, catalogue, }: {
|
|
|
451
451
|
runId: string;
|
|
452
452
|
catalogue: any;
|
|
453
453
|
}): {
|
|
454
|
-
glyph: "[\u2713]" | "[\u2717]" | "[\u00B7]" | "[!]" | "[\u25B6]" | "[?]" | "[II]" | "[\u25A0]";
|
|
454
|
+
glyph: "[\u2713]" | "[\u2717]" | "[\u00B7]" | "[!]" | "[\u25B6]" | "[?]" | "[II]" | "[\u25A0]" | "[\u2013]";
|
|
455
455
|
label: string;
|
|
456
456
|
} | null;
|
|
457
457
|
/**
|
|
@@ -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.
|
|
@@ -715,6 +718,76 @@ export function getRunResult({ root, flow, runId, catalogue, resumeAttempt, now,
|
|
|
715
718
|
resumeAttempt?: (flow: string, runId: string) => any;
|
|
716
719
|
now?: () => number;
|
|
717
720
|
}): any | null;
|
|
721
|
+
/**
|
|
722
|
+
* M12 piece 3: the ticket list of the run a ticket schedule was set from (the Result tab's, and `Run it anyway`'s check), or null.
|
|
723
|
+
* @param {{root: string, flow: string, runId: string, catalogue: any}} a
|
|
724
|
+
*/
|
|
725
|
+
export function getTicketList({ root, flow, runId, catalogue, }: {
|
|
726
|
+
root: string;
|
|
727
|
+
flow: string;
|
|
728
|
+
runId: string;
|
|
729
|
+
catalogue: any;
|
|
730
|
+
}): {
|
|
731
|
+
line: string;
|
|
732
|
+
list: string;
|
|
733
|
+
groups: Array<{
|
|
734
|
+
key: string;
|
|
735
|
+
label: string;
|
|
736
|
+
open: boolean;
|
|
737
|
+
rows: any[];
|
|
738
|
+
}>;
|
|
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;
|
|
718
791
|
/**
|
|
719
792
|
* `GET /api/runs/:flow/:runId/download?i=<n>` (M10 am4): one saved file, or why not.
|
|
720
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";
|
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @param {{ door: ReturnType<typeof import('./authortrigger.js').createTriggerDoor>, now?: () => number, intervalMs?: number }} opts
|
|
3
|
-
* `intervalMs` 0 = no timer (a test drives `tick`).
|
|
2
|
+
* @param {{ door: ReturnType<typeof import('./authortrigger.js').createTriggerDoor>, now?: () => number, intervalMs?: number, look?: typeof lookTickets, mcpConfig?: string }} opts
|
|
3
|
+
* `intervalMs` 0 = no timer (a test drives `tick`). `look`/`mcpConfig`: M12 piece 2, the ticket look and the MCP config it reads (default: the person's own ~/.mcp.json).
|
|
4
4
|
*/
|
|
5
5
|
export function createScheduler(opts: {
|
|
6
6
|
door: ReturnType<typeof import("./authortrigger.js").createTriggerDoor>;
|
|
7
7
|
now?: () => number;
|
|
8
8
|
intervalMs?: number;
|
|
9
|
+
look?: typeof lookTickets;
|
|
10
|
+
mcpConfig?: string;
|
|
9
11
|
}): {
|
|
10
12
|
tick: () => void;
|
|
13
|
+
/** M12 piece 2: resolves when every ticket look now out has been written to its ledger (a test awaits it; the timer never does). */
|
|
14
|
+
settled(): Promise<void>;
|
|
11
15
|
/** Start the real timer (idempotent). */
|
|
12
16
|
start(): void;
|
|
13
17
|
/** Stop it (idempotent). The server's close calls this. */
|
|
14
18
|
stop(): void;
|
|
15
19
|
};
|
|
20
|
+
import { lookTickets } from '../trigger-tickets.js';
|