fwdloop 0.27.0 → 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.
Files changed (67) hide show
  1. package/bin/fwdloop +27 -8
  2. package/package.json +2 -2
  3. package/src/authoring.js +11 -1
  4. package/src/canrun.js +19 -16
  5. package/src/config.js +18 -0
  6. package/src/declaration.js +32 -2
  7. package/src/drafter.js +29 -14
  8. package/src/flow.js +2 -1
  9. package/src/launcher.js +4 -2
  10. package/src/learnstore.js +2 -1
  11. package/src/mcp-checks.js +50 -0
  12. package/src/mcp-pick.js +33 -0
  13. package/src/mcp-sources.js +84 -0
  14. package/src/mcp-use.js +54 -0
  15. package/src/natural.js +23 -0
  16. package/src/panel/author.js +19 -19
  17. package/src/panel/authorcard.js +35 -0
  18. package/src/panel/authorflows.js +18 -14
  19. package/src/panel/authortrigger.js +241 -84
  20. package/src/panel/data.js +89 -6
  21. package/src/panel/index.html +552 -157
  22. package/src/panel/jobgrid.js +127 -0
  23. package/src/panel/scheduler.js +8 -2
  24. package/src/panel/server.js +15 -6
  25. package/src/panel/settings.js +119 -4
  26. package/src/panel/tickets.js +12 -7
  27. package/src/primitives.js +34 -5
  28. package/src/runner.js +88 -15
  29. package/src/summary-words.js +15 -3
  30. package/src/ticket-draft.js +40 -42
  31. package/src/ticket-labels.js +10 -0
  32. package/src/ticket-mcp.js +33 -10
  33. package/src/ticket-next.js +33 -0
  34. package/src/ticket-shape.js +9 -0
  35. package/src/trigger-clock.js +4 -4
  36. package/src/trigger-files.js +3 -3
  37. package/src/trigger-tickets.js +41 -12
  38. package/types/authoring.d.ts +5 -1
  39. package/types/canrun.d.ts +5 -12
  40. package/types/config.d.ts +6 -0
  41. package/types/declaration.d.ts +8 -0
  42. package/types/drafter.d.ts +447 -38
  43. package/types/mcp-checks.d.ts +8 -0
  44. package/types/mcp-pick.d.ts +23 -0
  45. package/types/mcp-sources.d.ts +51 -0
  46. package/types/mcp-use.d.ts +12 -0
  47. package/types/natural.d.ts +2 -0
  48. package/types/panel/author.d.ts +36 -0
  49. package/types/panel/authorcard.d.ts +11 -0
  50. package/types/panel/authorflows.d.ts +9 -1
  51. package/types/panel/authortrigger.d.ts +73 -7
  52. package/types/panel/data.d.ts +56 -2
  53. package/types/panel/jobgrid.d.ts +109 -0
  54. package/types/panel/server.d.ts +5 -1
  55. package/types/panel/settings.d.ts +3 -2
  56. package/types/panel/tickets.d.ts +26 -4
  57. package/types/primitives.d.ts +15 -2
  58. package/types/runner.d.ts +112 -72
  59. package/types/summary-words.d.ts +22 -3
  60. package/types/ticket-draft.d.ts +40 -32
  61. package/types/ticket-labels.d.ts +6 -0
  62. package/types/ticket-mcp.d.ts +18 -1
  63. package/types/ticket-next.d.ts +23 -0
  64. package/types/ticket-shape.d.ts +5 -0
  65. package/types/trigger-clock.d.ts +4 -3
  66. package/types/trigger-files.d.ts +1 -1
  67. package/types/trigger-tickets.d.ts +18 -4
@@ -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;
@@ -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;
@@ -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
- * M9 item 1 and 2: does this job have "one green run"? The ONE function that decides it. A passed run counts when the job it ran (its own
7
- * `job/` copy) is the job as it is now (prose and declaration, byte for byte: a schedule is its own file, so setting one never changes the job).
8
- * A run from before runs kept a job copy has none to compare, so it counts only when its history row's signature is the job's current one.
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 hasGreenRunForJob(flowDir: string): boolean;
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
- * @param {string} flowDir @param {Schedule} schedule @param {number} now epoch ms @param {{baseline?: boolean}} [o]
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 one tool a ticket schedule's look uses, signed with the schedule's two clicks. */
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;
@@ -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
- * @param {{root: string, flow: string, runId: string, catalogue: any, scheduleRead?: (flow: string) => any, home?: string}} opts
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";
@@ -4,11 +4,15 @@
4
4
  * real listening socket where that is simpler.
5
5
  * @param {import('node:http').IncomingMessage} req
6
6
  * @param {import('node:http').ServerResponse} res
7
- * @param {{ root: string, port: number, version?: string|null, startedAt?: string, packagePath?: string, resumer: ReturnType<typeof createResumer>, settings: ReturnType<typeof createSettings>, author: ReturnType<typeof createAuthor>, now?: () => number, ticketQueue: {arriveAnyway: Function} }} opts
7
+ * @param {{ root: string, port: number, checksHome: { skip: boolean, home: string|undefined }, version?: string|null, startedAt?: string, packagePath?: string, resumer: ReturnType<typeof createResumer>, settings: ReturnType<typeof createSettings>, author: ReturnType<typeof createAuthor>, now?: () => number, ticketQueue: {arriveAnyway: Function} }} opts
8
8
  */
9
9
  export function handleRequest(req: import("node:http").IncomingMessage, res: import("node:http").ServerResponse, opts: {
10
10
  root: string;
11
11
  port: number;
12
+ checksHome: {
13
+ skip: boolean;
14
+ home: string | undefined;
15
+ };
12
16
  version?: string | null;
13
17
  startedAt?: string;
14
18
  packagePath?: string;
@@ -1,10 +1,11 @@
1
1
  /**
2
- * @param {{ home?: string, skip?: boolean, env?: Record<string,string|undefined>, fetch?: typeof fetch, now?: () => number, openFolderSpawn?: (cmd: string, args: string[], o: object) => any, platform?: string }} cfg
3
- * `home` the config home (undefined = the real `~/.config/fwdloop`); `skip` true under a test process
2
+ * @param {{ root?: string, home?: string, skip?: boolean, env?: Record<string,string|undefined>, fetch?: typeof fetch, now?: () => number, openFolderSpawn?: (cmd: string, args: string[], o: object) => any, platform?: string }} cfg
3
+ * `root` the jobs folder (the MCP use counts read its runs); `home` the config home (undefined = the real `~/.config/fwdloop`); `skip` true under a test process
4
4
  * with no `FWDLOOP_CONFIG_HOME` (Settings then touches nothing); `env` the shell side (tests only);
5
5
  * `fetch` and `now` are test seams.
6
6
  */
7
7
  export function createSettings(cfg: {
8
+ root?: string;
8
9
  home?: string;
9
10
  skip?: boolean;
10
11
  env?: Record<string, string | undefined>;
@@ -30,7 +30,7 @@ export function ticketListOf({ flowDir, runId, runIdsOf, glyphOf, atOf, readSche
30
30
  /**
31
31
  * `POST /api/author/ticket-anyway`: queue a SKIPPED ticket as a new arrival, after a short reason. Without a reason nothing starts. The queue is the schedule builder's:
32
32
  * `queue.arriveAnyway({flow, number, reason})` is the ONE seam (production: `arriveAnywayOf`).
33
- * @param {{body: any, listOf: (flow: string, runId: string) => ReturnType<typeof ticketListOf>, queue: {arriveAnyway: (a: {flow: string, runId: string, number: number, reason: string}) => {ok: boolean, say?: string}}}} a
33
+ * @param {{body: any, listOf: (flow: string, runId: string) => ReturnType<typeof ticketListOf>, queue: {arriveAnyway: (a: {flow: string, runId: string, number: number, reason: string}) => {ok: boolean, say?: string, started?: boolean}}}} a
34
34
  * @returns {{status: number, body: Record<string, any>}}
35
35
  */
36
36
  export function ticketAnyway({ body, listOf, queue }: {
@@ -45,6 +45,7 @@ export function ticketAnyway({ body, listOf, queue }: {
45
45
  }) => {
46
46
  ok: boolean;
47
47
  say?: string;
48
+ started?: boolean;
48
49
  };
49
50
  };
50
51
  }): {
@@ -54,12 +55,20 @@ export function ticketAnyway({ body, listOf, queue }: {
54
55
  /**
55
56
  * The production queue seam: ONE `arrived` row (`recordAnyway`, the ledger's writer) in the job's schedule ledger, so the scheduler's queue starts the ticket as a new
56
57
  * arrival under the job's normal cap. A job with no live ticket schedule is refused by name, at $0, with nothing written.
57
- * @param {{scan: () => any[], now: () => number}} a
58
- * @returns {{arriveAnyway: (a: {flow: string, runId: string, number: number, reason: string}) => {ok: boolean, say?: string}}}
58
+ * M13 am3: a ticket schedule that is signed but OFF (`startAnyway`, the trigger door's one by-hand start) starts the ticket at once instead; it writes no row.
59
+ * @param {{scan: () => any[], now: () => number, startAnyway?: (a: {flow: string, number: number}) => {ok: boolean, say: string} | null}} a
60
+ * @returns {{arriveAnyway: (a: {flow: string, runId: string, number: number, reason: string}) => {ok: boolean, say?: string, started?: boolean}}}
59
61
  */
60
- export function arriveAnywayOf({ scan, now }: {
62
+ export function arriveAnywayOf({ scan, now, startAnyway }: {
61
63
  scan: () => any[];
62
64
  now: () => number;
65
+ startAnyway?: (a: {
66
+ flow: string;
67
+ number: number;
68
+ }) => {
69
+ ok: boolean;
70
+ say: string;
71
+ } | null;
63
72
  }): {
64
73
  arriveAnyway: (a: {
65
74
  flow: string;
@@ -69,6 +78,7 @@ export function arriveAnywayOf({ scan, now }: {
69
78
  }) => {
70
79
  ok: boolean;
71
80
  say?: string;
81
+ started?: boolean;
72
82
  };
73
83
  };
74
84
  /** the four groups, in the mockup's order: key, label, open at first. The page draws them; it types none of these words. */
@@ -77,5 +87,17 @@ export const TICKET_GROUPS: readonly {
77
87
  label: string;
78
88
  open: boolean;
79
89
  }[];
90
+ /** a run's sign -> its group. Running / stuck / expired / waiting all need a person or are still going: Needs you. */
91
+ export const GROUP_OF: Readonly<{
92
+ '[\u00B7]': "wait";
93
+ '[\u25B6]': "wait";
94
+ '[II]': "wait";
95
+ '[!]': "wait";
96
+ '[\u2713]': "done";
97
+ '[\u2013]': "skip";
98
+ '[\u2717]': "stop";
99
+ '[\u25A0]': "stop";
100
+ '[?]': "stop";
101
+ }>;
80
102
  /** a "Run it anyway" reason: short, never blank. The same bar as a rerun's. */
81
103
  export const ANYWAY_REASON_MAX: 500;
@@ -7,6 +7,11 @@ export function rolePrimitiveFor(frozenPath: any): "read" | "readDocx" | "addres
7
7
  * WIRED_VERBS (and, when `skills` is given, in a signed skill). Absence,
8
8
  * not refusal. Throws only if catalogue.json itself is unreadable. */
9
9
  export function wiredMenu(skills: any): import("./types.js").CatalogueEntry[];
10
+ /** M13 item 5: the job's MCP, as `resolvePrimitives` wants it: the signed server and every tool any step grants; `undefined` when no step has `mcpTools` */
11
+ export function stepMcp(declaration: any): {
12
+ server: any;
13
+ tools: any[];
14
+ } | undefined;
10
15
  /**
11
16
  * Resolve the granted tools for one step's model call. Never throws —
12
17
  * a verb absent from the catalogue, or present but unimplemented here, is
@@ -15,7 +20,7 @@ export function wiredMenu(skills: any): import("./types.js").CatalogueEntry[];
15
20
  *
16
21
  * @param {import('./types.js').CatalogueEntry[]} catalogue - `loadCatalogue().primitives` (or an injected test catalogue).
17
22
  * @param {string[]} grantedVerbs - `step.primitives`.
18
- * @param {{ runDir: string, inputs?: Array<{id:string, frozen:string}> }} ctx
23
+ * @param {{ runDir: string, inputs?: Array<{id:string, frozen:string}>, mcp?: {server: string, tools: string[]} }} ctx - `mcp` (`stepMcp`): the signed `<server>_<tool>` names the gate also allows (M13 item 5)
19
24
  * @returns {{ tools: Record<string, any>, reds: string[] }}
20
25
  */
21
26
  export function resolvePrimitives(catalogue: import("./types.js").CatalogueEntry[], grantedVerbs: string[], ctx: {
@@ -24,6 +29,10 @@ export function resolvePrimitives(catalogue: import("./types.js").CatalogueEntry
24
29
  id: string;
25
30
  frozen: string;
26
31
  }>;
32
+ mcp?: {
33
+ server: string;
34
+ tools: string[];
35
+ };
27
36
  }): {
28
37
  tools: Record<string, any>;
29
38
  reds: string[];
@@ -45,7 +54,10 @@ export function resolvePrimitives(catalogue: import("./types.js").CatalogueEntry
45
54
  * `instanceof` and records `{verb, path, rule}` on the attempt's audit row —
46
55
  * never parsed back out of the message string. */
47
56
  export class GateRefusal extends Error {
48
- constructor(verb: any, resolved: any, rule: any);
57
+ /** `tool: true` (M13 item 5): a refused MCP tool, `verb` is its name; it names no path, so it gets no filesystem wording */
58
+ constructor(verb: any, resolved: any, rule: any, { tool }?: {
59
+ tool?: boolean | undefined;
60
+ });
49
61
  verb: any;
50
62
  path: any;
51
63
  rule: any;
@@ -56,3 +68,4 @@ export class GateRefusal extends Error {
56
68
  * catalogue-present-but-unwired verb must refuse before any model call or
57
69
  * spend) imports this SAME set rather than keeping a second copy of the list. */
58
70
  export const WIRED_VERBS: Set<string>;
71
+ export function mcpToolName(server: any, tool: any): string;