fwdloop 0.19.1 → 0.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/README.md +2 -0
  2. package/bin/fwdloop +22 -13
  3. package/package.json +1 -1
  4. package/src/audit-fold.js +177 -0
  5. package/src/authoring.js +24 -4
  6. package/src/books.js +4 -3
  7. package/src/closers.js +49 -2
  8. package/src/ctx-tools.js +1 -1
  9. package/src/diary.js +49 -0
  10. package/src/flow.js +218 -2
  11. package/src/flowmodel.js +42 -5
  12. package/src/jobkey.js +25 -0
  13. package/src/jsonl-append.js +29 -0
  14. package/src/model-step.js +103 -5
  15. package/src/monthly.js +3 -2
  16. package/src/panel/author.js +44 -18
  17. package/src/panel/authorcard.js +7 -13
  18. package/src/panel/authorflows.js +118 -24
  19. package/src/panel/authorresume.js +8 -4
  20. package/src/panel/authorstart.js +63 -18
  21. package/src/panel/authortrigger.js +250 -125
  22. package/src/panel/authorvalues.js +13 -2
  23. package/src/panel/data.js +279 -43
  24. package/src/panel/index.html +547 -150
  25. package/src/panel/needsyou.js +29 -0
  26. package/src/panel/scheduler.js +21 -22
  27. package/src/panel/server.js +30 -6
  28. package/src/primitives.js +44 -2
  29. package/src/provider.js +3 -2
  30. package/src/runner.js +58 -22
  31. package/src/runvalues.js +10 -2
  32. package/src/schedule.js +135 -0
  33. package/src/setup.js +0 -21
  34. package/src/summary-words.js +180 -7
  35. package/src/thinking.js +39 -0
  36. package/src/trigger-clock.js +18 -16
  37. package/src/trigger-files.js +37 -24
  38. package/src/trigger-line.js +6 -15
  39. package/src/try-checks.js +62 -0
  40. package/src/types.js +2 -1
  41. package/types/audit-fold.d.ts +54 -0
  42. package/types/authoring.d.ts +33 -2
  43. package/types/books.d.ts +17 -0
  44. package/types/ctx-tools.d.ts +1 -0
  45. package/types/diary.d.ts +57 -0
  46. package/types/flow.d.ts +106 -0
  47. package/types/flowmodel.d.ts +25 -3
  48. package/types/jobkey.d.ts +11 -0
  49. package/types/jsonl-append.d.ts +6 -0
  50. package/types/model-step.d.ts +4 -1
  51. package/types/panel/author.d.ts +47 -17
  52. package/types/panel/authorcard.d.ts +3 -6
  53. package/types/panel/authorflows.d.ts +38 -10
  54. package/types/panel/authorstart.d.ts +15 -2
  55. package/types/panel/authortrigger.d.ts +73 -41
  56. package/types/panel/authorvalues.d.ts +6 -0
  57. package/types/panel/data.d.ts +101 -19
  58. package/types/panel/needsyou.d.ts +20 -0
  59. package/types/runvalues.d.ts +5 -0
  60. package/types/schedule.d.ts +69 -0
  61. package/types/setup.d.ts +0 -19
  62. package/types/summary-words.d.ts +105 -2
  63. package/types/thinking.d.ts +31 -0
  64. package/types/trigger-clock.d.ts +8 -7
  65. package/types/trigger-files.d.ts +17 -10
  66. package/types/trigger-line.d.ts +16 -8
  67. package/types/try-checks.d.ts +55 -0
  68. package/types/types.d.ts +10 -1
@@ -149,9 +149,11 @@ export function draftToDir({ proseFile, dir, root, name, slot, model, draftThink
149
149
  * `sessionDir` (the panel's draft folder: card, notes, every change) widens the setup record; the CLI has none, so its record is the one plan folder.
150
150
  * M6: `replaces: {flowHash}` (a draft opened from an existing signed job, carrying that job's signature hash) makes this sign REPLACE that job
151
151
  * (`writeFlow` checks the hash is still the job's); without it a taken name is refused as ever.
152
- * @param {{dir: any, approve?: any, signedBy: any, signedAt?: string, env?: Record<string, string|undefined>, keyNames?: string[], sessionDir?: string, replaces?: {flowHash: string}}} a
152
+ * M6 am9: `asRunOf: {flow}` (a red run's redraft of an UNCHANGED job) signs the plan as the plan of a NEW run of that existing workflow: the workflow's own files are
153
+ * never written (`writeRunPlan`), and a plan whose job key is not the workflow's is refused here, at sign time.
154
+ * @param {{dir: any, approve?: any, signedBy: any, signedAt?: string, env?: Record<string, string|undefined>, keyNames?: string[], sessionDir?: string, replaces?: {flowHash: string}, asRunOf?: {flow: string}}} a
153
155
  */
154
- export function signDraft({ dir, approve, signedBy, signedAt, env, keyNames, sessionDir, replaces, }: {
156
+ export function signDraft({ dir, approve, signedBy, signedAt, env, keyNames, sessionDir, replaces, asRunOf, }: {
155
157
  dir: any;
156
158
  approve?: any;
157
159
  signedBy: any;
@@ -162,9 +164,35 @@ export function signDraft({ dir, approve, signedBy, signedAt, env, keyNames, ses
162
164
  replaces?: {
163
165
  flowHash: string;
164
166
  };
167
+ asRunOf?: {
168
+ flow: string;
169
+ };
165
170
  }): {
166
171
  ok: boolean;
167
172
  reds: any[];
173
+ } | {
174
+ ok: boolean;
175
+ flowDir: string;
176
+ runId: string;
177
+ runDir: string;
178
+ signature: any;
179
+ setup: {
180
+ ok: true;
181
+ file: string;
182
+ rows: number;
183
+ } | {
184
+ ok: false;
185
+ red: string;
186
+ };
187
+ modelRecord: {
188
+ ok: boolean;
189
+ recorded: boolean;
190
+ };
191
+ modelPick: {
192
+ slot: string;
193
+ model: string;
194
+ thinking?: true;
195
+ } | null;
168
196
  } | {
169
197
  ok: boolean;
170
198
  flowDir: string;
@@ -181,6 +209,9 @@ export function signDraft({ dir, approve, signedBy, signedAt, env, keyNames, ses
181
209
  ok: boolean;
182
210
  recorded: boolean;
183
211
  };
212
+ runId?: undefined;
213
+ runDir?: undefined;
214
+ modelPick?: undefined;
184
215
  };
185
216
  export const SPEC_HASH_FILE: "spec.hash";
186
217
  /** The one folder under the flows root where the panel keeps its draft folders (M4e). Starts with a dot, so it is never a flow name. */
package/types/books.d.ts CHANGED
@@ -17,6 +17,23 @@ export function appendPidRow(runDir: string, row: {
17
17
  * @returns {any[]}
18
18
  */
19
19
  export function readPidRows(runDir: string): any[];
20
+ /**
21
+ * Raw read-back of one JSONL book, one writer's own sibling reader (M4a
22
+ * piece 2, docs/wiki/the-module-ladder.md M4a scope item 2: "one reader per
23
+ * book"). Never throws on a missing file (`[]`) or a malformed line (that
24
+ * one line is skipped, never crashes the whole read) — the panel and any
25
+ * other reader need an honest best-effort array, not a hard failure over one
26
+ * bad byte someone else wrote.
27
+ *
28
+ * F48 round 3: goes through `readFileInside` (`src/flow.js`) — a book file
29
+ * that is itself a symlink, or that sits behind a symlinked ancestor
30
+ * directory, resolving outside `baseDir` reads as `[]`, same as a missing
31
+ * file, never as the outside target's content.
32
+ * @param {string} baseDir - the run dir (audit.jsonl) or flow dir (history.jsonl)
33
+ * @param {string} relPath - the book's own file name, relative to baseDir
34
+ * @returns {any[]}
35
+ */
36
+ export function readLines(baseDir: string, relPath: string): any[];
20
37
  /**
21
38
  * One row per attempt (also used for one row per ask and one row per send —
22
39
  * M2 scope item 9). `row` shape: `{ step, attempt, class, verdict, gap, usd,
@@ -16,3 +16,4 @@ export function makeCtxTools({ runDir, gatePath }: {
16
16
  /** One stashed item holds at most this many bytes (measured after secrets are masked,
17
17
  * because that is what enters the store). Bareloop's number, signed in M7 item 3. */
18
18
  export const ISOLATE_MAX_BYTES: 65536;
19
+ export function redactSecrets(raw: unknown): string;
@@ -0,0 +1,57 @@
1
+ export const DIARY_FILES: Readonly<{
2
+ calls: "calls.jsonl";
3
+ tools: "tools.jsonl";
4
+ checks: "checks.jsonl";
5
+ }>;
6
+ export function diaryPaths(runDir: string): string[];
7
+ export function appendCall(runDir: string, row: {
8
+ step: string | null;
9
+ try: number | null;
10
+ round: number;
11
+ at: string;
12
+ model: string | null;
13
+ costUsd: number | null;
14
+ tokens: {
15
+ in: number;
16
+ out: number;
17
+ cache: number;
18
+ } | null;
19
+ ms: number | null;
20
+ stopReason: string | null;
21
+ thinking: {
22
+ asked: string | null;
23
+ status: string | null;
24
+ };
25
+ }): void;
26
+ export function appendTool(runDir: string, row: {
27
+ step: string | null;
28
+ try: number | null;
29
+ round: number;
30
+ at: string;
31
+ tool: string;
32
+ path: string | null;
33
+ decision: "allow" | "deny" | "no check";
34
+ rule: string | null;
35
+ }): void;
36
+ export function appendChecks(runDir: string, row: {
37
+ step: string | null;
38
+ try: number;
39
+ at: string;
40
+ lastRound: number;
41
+ checks: Array<{
42
+ n: number;
43
+ text: string;
44
+ ok: boolean;
45
+ result: string | null;
46
+ source: string;
47
+ }>;
48
+ output: {
49
+ file: string;
50
+ bytes: number;
51
+ sha256: string;
52
+ } | null;
53
+ }): void;
54
+ export function readCalls(runDir: string): any[];
55
+ export function readTools(runDir: string): any[];
56
+ export function readChecks(runDir: string): any[];
57
+ export function nextRound(runDir: string, step: string | null): any;
package/types/flow.d.ts CHANGED
@@ -201,6 +201,71 @@ export function writeFlow({ root, name, proseText, declaration, signedBy, signed
201
201
  * @param {string} flowDir @returns {string|null}
202
202
  */
203
203
  export function signedHashOf(flowDir: string): string | null;
204
+ /**
205
+ * M6 am9 ("Each run keeps the plan it ran"): which plan does a reuse of run `runDir` run? `{same:true}` = the workflow's own plan (the run kept no copy, as a run made
206
+ * before M6, or its kept plan is byte-equal to the workflow's declaration and prose, a trigger line aside). `{same:false, read}` = a different kept plan, already verified.
207
+ * `{ok:false, red}` = a kept plan that does not verify: refused by name, never swapped for the workflow's.
208
+ * @param {{root: string, name: string, runDir: string, catalogue: unknown}} a
209
+ * @returns {{ok: true, same: true} | {ok: true, same: false, read: ReadFlowResult & {ok: true}} | {ok: false, red: string}}
210
+ */
211
+ export function planForReuse({ root, name, runDir, catalogue, }: {
212
+ root: string;
213
+ name: string;
214
+ runDir: string;
215
+ catalogue: unknown;
216
+ }): {
217
+ ok: true;
218
+ same: true;
219
+ } | {
220
+ ok: true;
221
+ same: false;
222
+ read: ReadFlowResult & {
223
+ ok: true;
224
+ };
225
+ } | {
226
+ ok: false;
227
+ red: string;
228
+ };
229
+ /**
230
+ * M6 am9: give the run folder `runDir` a verified copy of the plan run `fromRunDir` kept (`job/` write-once, then `plan.json {planOf}`), so the run executes
231
+ * it. Nothing is signed: the bytes already carry a signature, proved here. A failure removes what this call wrote.
232
+ * @param {{fromRunDir: string, runDir: string, catalogue: unknown}} a
233
+ * @returns {{ok: true} | {ok: false, red: string}}
234
+ */
235
+ export function copyRunPlan({ fromRunDir, runDir, catalogue }: {
236
+ fromRunDir: string;
237
+ runDir: string;
238
+ catalogue: unknown;
239
+ }): {
240
+ ok: true;
241
+ } | {
242
+ ok: false;
243
+ red: string;
244
+ };
245
+ /**
246
+ * M6 am9 ("a red run always drafts"): sign a plan as the plan of a NEW run of an existing workflow. Same checks and the same `signFlow` as `writeFlow`,
247
+ * but nothing of the workflow is written: the run folder is claimed (`claimRunId`) and receives `job/{prose.txt,declaration.json,signature.json}` write-once,
248
+ * then `plan.json` last (the file that makes the run execute it). A failure removes the run folder this call claimed. The caller proves the job is unchanged.
249
+ * @param {{root: unknown, name: unknown, proseText: unknown, declaration: unknown, signedBy: unknown, signedAt: unknown, catalogue: unknown}} a
250
+ * @returns {{ok: true, runId: string, runDir: string, signature: any} | {ok: false, reds: string[]}}
251
+ */
252
+ export function writeRunPlan({ root, name, proseText, declaration, signedBy, signedAt, catalogue, }: {
253
+ root: unknown;
254
+ name: unknown;
255
+ proseText: unknown;
256
+ declaration: unknown;
257
+ signedBy: unknown;
258
+ signedAt: unknown;
259
+ catalogue: unknown;
260
+ }): {
261
+ ok: true;
262
+ runId: string;
263
+ runDir: string;
264
+ signature: any;
265
+ } | {
266
+ ok: false;
267
+ reds: string[];
268
+ };
204
269
  /**
205
270
  * Read and verify a signed flow from `<root>/<name>/`. Verifies the bytes on
206
271
  * disk against the signature FIRST — before anything in the flow is
@@ -228,6 +293,38 @@ export function writeRunJobCopy(flowDir: string, runDir: string, expectedFlowHas
228
293
  ok: false;
229
294
  red: string;
230
295
  };
296
+ /** M6 am9: does this run execute its own kept plan? The ONE test (no marker = the flow folder's plan, as every run before am9). @param {string} runDir */
297
+ export function runOwnsPlan(runDir: string): boolean;
298
+ /**
299
+ * M6 am9: the ONE reader of the plan a run executes. A run whose folder holds `plan.json` reads its own verified copy (`<run>/job/`); every other
300
+ * run (and a read with no run) reads the flow folder exactly as `readFlow` does. Never throws; a kept plan that does not verify is a red, never swapped for the flow's.
301
+ * @param {{root: unknown, name: unknown, catalogue: unknown, runDir?: string|null}} a
302
+ * @returns {ReadFlowResult}
303
+ */
304
+ export function readPlan({ root, name, catalogue, runDir }: {
305
+ root: unknown;
306
+ name: unknown;
307
+ catalogue: unknown;
308
+ runDir?: string | null;
309
+ }): ReadFlowResult;
310
+ /**
311
+ * M9 am12: the ONE reader of "the job this run resumes against" (an answer, Resume, Reopen, continue-after-cap, the panel's resume controls).
312
+ * Always the run's OWN kept copy, verified against that copy's own signature (a run with `plan.json` reads it through `readPlan`, the same
313
+ * `<run>/job/`); never the workflow's current job, so a Cancel or an Edit of the workflow does not strand a waiting run. A copy that fails its
314
+ * signature is a red naming it; a run with no copy (it started before M6) is a red with `noCopy: true`, never the flow's job. Never throws.
315
+ * @param {{root: unknown, name: unknown, catalogue: unknown, runDir: string}} a
316
+ * @returns {ReadFlowResult | {ok: false, reds: string[], noCopy: true}}
317
+ */
318
+ export function readRunPlan({ root, name, catalogue, runDir }: {
319
+ root: unknown;
320
+ name: unknown;
321
+ catalogue: unknown;
322
+ runDir: string;
323
+ }): ReadFlowResult | {
324
+ ok: false;
325
+ reds: string[];
326
+ noCopy: true;
327
+ };
231
328
  /**
232
329
  * M6: the job a run ran, from its own copy. `{present:false}` = the run has none (it started before M6). `{present:true, ok:true, ...}` = the same
233
330
  * shape as a good `readFlow` (lines, arbiter, declaration, signature, classes), after the copy was verified against the copied signature.
@@ -240,6 +337,13 @@ export function readRunJobCopy(runDir: string, catalogue: unknown): {
240
337
  } | ({
241
338
  present: true;
242
339
  } & ReadFlowResult);
340
+ /**
341
+ * M6 am5 item 2: the name suggested for the new workflow a changed job becomes: `<base>-N`, N the first free number from 2. A trailing `-N` of
342
+ * `name` is stripped first when what is left is itself a workflow here (aging-live-4-2 -> base aging-live-4; aging-live-4 keeps its 4). "Free" = nothing at all by that name under root (a folder or a file), the same
343
+ * test the card's name check makes. Pure read; the sign still refuses a name taken meanwhile (writeFlow never overwrites).
344
+ * @param {string} root @param {string} name
345
+ */
346
+ export function suggestFlowName(root: string, name: string): string;
243
347
  /** @typedef {import('./types.js').WriteFlowResult} WriteFlowResult */
244
348
  /** @typedef {import('./types.js').ReadFlowResult} ReadFlowResult */
245
349
  /** @typedef {import('./types.js').CheckFlowNameResult} CheckFlowNameResult */
@@ -248,6 +352,8 @@ export function readRunJobCopy(runDir: string, catalogue: unknown): {
248
352
  export const FLOW_FILES: readonly string[];
249
353
  /** The one folder under the flows root where the panel keeps each run start's own files (M4e piece 2b). A dot-name, so never a flow. */
250
354
  export const PANEL_STARTS_DIR: ".starts";
355
+ /** M6 am9: a run's folder holds this file when the run executes the plan it keeps (`<run>/job/`), not the flow folder's. Written once, by the run's plan writer. */
356
+ export const RUN_PLAN_MARKER: "plan.json";
251
357
  export type WriteFlowResult = import("./types.js").WriteFlowResult;
252
358
  export type ReadFlowResult = import("./types.js").ReadFlowResult;
253
359
  export type CheckFlowNameResult = import("./types.js").CheckFlowNameResult;
@@ -1,16 +1,38 @@
1
1
  /**
2
2
  * @param {string} dir a draft folder or a flow folder
3
- * @returns {{ slot: string, model: string }|null} null when there is no usable record (missing, unreadable, or not a name and a model id)
3
+ * M4d am25: `thinking: true` is the Chat "Thinking on" box as it was when the job was signed; the key is absent when the box was off.
4
+ * @returns {{ slot: string, model: string, thinking?: true }|null} null when there is no usable record (missing, unreadable, or not a name and a model id)
4
5
  */
5
6
  export function readModelRecord(dir: string): {
6
7
  slot: string;
7
8
  model: string;
9
+ thinking?: true;
8
10
  } | null;
9
11
  /**
10
- * Write the record once (never over an existing one). @param {string} dir @param {{ slot: string, model: string }} pick
12
+ * Write the record once (never over an existing one). @param {string} dir @param {{ slot: string, model: string, thinking?: boolean }} pick
11
13
  */
12
- export function writeModelRecord(dir: string, { slot, model }: {
14
+ export function writeModelRecord(dir: string, { slot, model, thinking }: {
13
15
  slot: string;
14
16
  model: string;
17
+ thinking?: boolean;
15
18
  }): void;
19
+ /**
20
+ * M4d am25: the ONE reader of the job's "Thinking on" box for a run. A run reads its OWN record (`<run>/thinking.json`, written once when the run
21
+ * started) when it has one; otherwise the flow folder's `model.json`. No record, an unreadable one, or one without `thinking` is box OFF: a job
22
+ * signed before am25 stored nothing, and it must not start thinking on every try.
23
+ * @param {string} flowDir @param {string|null} runDir @returns {boolean}
24
+ */
25
+ export function readJobThinking(flowDir: string, runDir: string | null): boolean;
26
+ /**
27
+ * M4d am26: the run's OWN record of the box (`<run>/thinking.json`) and nothing else: `true`/`false`, or `null` when the run has none (a run from before am25).
28
+ * An unreadable record is box off, as `readJobThinking` has always read it. @param {string|null} runDir @returns {boolean|null}
29
+ */
30
+ export function readRunThinking(runDir: string | null): boolean | null;
31
+ /**
32
+ * M4d am25: a run keeps the box as the job had it when the run started (write-once, so an Edit of the job never changes a run already going).
33
+ * Written for every fresh run, ticked or not. @param {string} flowDir @param {string} runDir
34
+ */
35
+ export function writeRunThinking(flowDir: string, runDir: string): void;
16
36
  export const MODEL_FILE: "model.json";
37
+ /** M4d am25: the file in a run's folder that keeps the box as the run started with it (outside `job/`, which holds the three signed files only). */
38
+ export const RUN_THINKING_FILE: "thinking.json";
@@ -0,0 +1,11 @@
1
+ /** The key of the job as the card's job box types it. @param {string} job */
2
+ export function jobKeyOfCard(job: string): string;
3
+ /** The key of a signed job. @param {{ lines: {n: number, text: string, guardrail: string}[], arbiter: any }} signed `parseSignedText`'s ok result */
4
+ export function jobKeyOfSigned({ lines, arbiter }: {
5
+ lines: {
6
+ n: number;
7
+ text: string;
8
+ guardrail: string;
9
+ }[];
10
+ arbiter: any;
11
+ }): string;
@@ -0,0 +1,6 @@
1
+ /** The ledger's text, '' when there is no file yet. @param {string} file */
2
+ export function ledgerText(file: string): string;
3
+ /** Append one JSON row as its own line; a torn last line gets its newline first. The parent folder must exist. @param {string} file @param {unknown} row @param {{mode?: number}} [options] e.g. `{ mode: 0o600 }` */
4
+ export function appendRow(file: string, row: unknown, options?: {
5
+ mode?: number;
6
+ }): void;
@@ -87,7 +87,7 @@ export function buildEmitArtifactSchema(stepClass: any): Readonly<{
87
87
  * @param {{in:number,out:number}} [opts.rates]
88
88
  * @param {string} [opts.modelId]
89
89
  * @param {Record<string,string|undefined>} [opts.env] - the merged shell+keys-file env the key is read from (default process.env).
90
- * @returns {(executorContext:object, grantedTools:Record<string,any>, stepMeta?:{class?:string}, seam?:{stopRequested?:() => boolean}) => Promise<any>}
90
+ * @returns {(executorContext:object, grantedTools:Record<string,any>, stepMeta?:{class?:string, attempt?:number, step?:string|null, thinkingMode?:'on'|'off'}, seam?:{stopRequested?:() => boolean}) => Promise<any>}
91
91
  */
92
92
  export function makeLiveModelStep({ slot, model, spendPath, provider: injectedProvider, rates: injectedRates, modelId: injectedModelId, env, }: {
93
93
  slot?: string | undefined;
@@ -102,6 +102,9 @@ export function makeLiveModelStep({ slot, model, spendPath, provider: injectedPr
102
102
  env?: Record<string, string | undefined> | undefined;
103
103
  }): (executorContext: object, grantedTools: Record<string, any>, stepMeta?: {
104
104
  class?: string;
105
+ attempt?: number;
106
+ step?: string | null;
107
+ thinkingMode?: "on" | "off";
105
108
  }, seam?: {
106
109
  stopRequested?: () => boolean;
107
110
  }) => Promise<any>;
@@ -47,6 +47,10 @@ export function createAuthor(opts: {
47
47
  status: any;
48
48
  body: any;
49
49
  };
50
+ reuseCheck: (b: any) => {
51
+ status: any;
52
+ body: any;
53
+ };
50
54
  runPrepare: (body: any) => {
51
55
  status: any;
52
56
  body: any;
@@ -78,44 +82,49 @@ export function createAuthor(opts: {
78
82
  ok: boolean;
79
83
  refused: string;
80
84
  say: string;
81
- reds?: undefined;
85
+ flow?: undefined;
86
+ trigger?: undefined;
87
+ words?: undefined;
88
+ armed?: undefined;
89
+ flowHash?: undefined;
90
+ sig?: undefined;
82
91
  };
83
92
  } | {
84
93
  status: number;
85
94
  body: {
86
95
  ok: boolean;
87
- refused: string;
88
- say: string;
89
- reds: any[];
96
+ flow: any;
97
+ trigger: null;
98
+ words: string | null;
99
+ armed: boolean;
100
+ refused?: undefined;
101
+ say?: undefined;
102
+ flowHash?: undefined;
103
+ sig?: undefined;
90
104
  };
91
105
  } | {
92
106
  status: number;
93
107
  body: {
94
- say?: string | undefined;
95
108
  ok: boolean;
96
109
  flow: any;
97
- trigger: import("../trigger-line.js").Trigger | null;
110
+ trigger: import("../trigger-line.js").Trigger;
98
111
  words: string | null;
99
112
  flowHash: string;
113
+ sig: string;
100
114
  armed: boolean;
101
115
  refused?: undefined;
102
- reds?: undefined;
116
+ say?: undefined;
103
117
  };
104
118
  };
105
119
  scan(): {
106
120
  flow: string;
107
121
  flowDir: string;
108
122
  read: import("../types.js").ReadFlowOk;
109
- trigger: import("./authortrigger.js").Trigger;
123
+ schedule: import("../schedule.js").Schedule;
124
+ trigger: import("../trigger-line.js").Trigger;
125
+ sig: string;
110
126
  }[];
111
- ensureArmed(job: {
112
- flowDir: string;
113
- read: any;
114
- trigger: Trigger;
115
- }): {
116
- armed: boolean;
117
- already: boolean;
118
- };
127
+ retireStale(): void;
119
128
  busy(job: {
120
129
  flow: string;
121
130
  }): boolean;
@@ -123,17 +132,20 @@ export function createAuthor(opts: {
123
132
  flow: string;
124
133
  flowDir: string;
125
134
  trigger: Trigger;
135
+ sig: string;
126
136
  }, row: Record<string, any>): void;
127
137
  refuse(job: {
128
138
  flow: string;
129
139
  flowDir: string;
130
140
  trigger: Trigger;
141
+ sig: string;
131
142
  }, why: string): void;
132
143
  fire(job: {
133
144
  flow: string;
134
145
  flowDir: string;
135
146
  read: any;
136
147
  trigger: Trigger;
148
+ schedule: Schedule;
137
149
  }, cause: {
138
150
  kind: "clock";
139
151
  slot: number;
@@ -146,11 +158,30 @@ export function createAuthor(opts: {
146
158
  }, hooks?: {
147
159
  told?: (row: Record<string, any>) => boolean;
148
160
  beforeStart?: () => void;
161
+ holdIfCannotStart?: boolean;
149
162
  }): Record<string, any>;
150
163
  read(flow: string): {
151
164
  flow: string;
152
165
  trigger: import("../trigger-line.js").Trigger | null;
153
166
  flowHash: string;
167
+ sig: string | null;
168
+ armed: boolean;
169
+ armedAt: number | null;
170
+ nextSlotMs: number | null;
171
+ lastOutcome: any;
172
+ hasGreenRun: boolean;
173
+ } | null;
174
+ facts(flow: string): {
175
+ from: string | null;
176
+ model: string | null;
177
+ destination: string | null;
178
+ inputs: string[];
179
+ fires: any[];
180
+ allFires: any[];
181
+ flow: string;
182
+ trigger: import("../trigger-line.js").Trigger | null;
183
+ flowHash: string;
184
+ sig: string | null;
154
185
  armed: boolean;
155
186
  armedAt: number | null;
156
187
  nextSlotMs: number | null;
@@ -163,7 +194,6 @@ export function createAuthor(opts: {
163
194
  armed: boolean;
164
195
  hasGreenRun: boolean;
165
196
  refusal: string | null;
166
- editNote: string | null;
167
197
  } | null;
168
198
  };
169
199
  resumePrepare: (body: any) => any;
@@ -62,10 +62,6 @@ export function parseInputLines(text: string): {
62
62
  * @param {any} body
63
63
  */
64
64
  export function cardFields(body: any): {
65
- editOf?: {
66
- flow: any;
67
- flowHash: any;
68
- } | undefined;
69
65
  thinking?: boolean | undefined;
70
66
  provider?: string | undefined;
71
67
  model?: string | undefined;
@@ -175,13 +171,14 @@ export function destinationRefusal(dest: string, root: string): string | null;
175
171
  /**
176
172
  * Every $0 check on the card, before any spawn (scope 6). Collects all refusals so the page can name every box.
177
173
  * @param {ReturnType<typeof cardFields>} card
178
- * @param {{ root: string, keys?: string[], home?: string }} ctx `keys` = the provider key values (the keys load's scrub list): a key value typed into any box is refused; `home` = the config home Settings is read from (the cap floor)
174
+ * @param {{ root: string, keys?: string[], home?: string, runOf?: string }} ctx `keys` = the provider key values (the keys load's scrub list): a key value typed into any box is refused; `home` = the config home Settings is read from (the cap floor)
179
175
  * @returns {{ ok: true, prose: string }|{ ok: false, refusals: {field: string, say: string}[] }}
180
176
  */
181
- export function checkCard(card: ReturnType<typeof cardFields>, { root, keys, home }: {
177
+ export function checkCard(card: ReturnType<typeof cardFields>, { root, keys, home, runOf }: {
182
178
  root: string;
183
179
  keys?: string[];
184
180
  home?: string;
181
+ runOf?: string;
185
182
  }): {
186
183
  ok: true;
187
184
  prose: string;
@@ -44,6 +44,30 @@ export function createFlowsDoor(opts: {
44
44
  }): {
45
45
  /** M6 amendments 1 and 3: the sentence that says why this flow cannot be edited now, or null (the sign route's check). @param {string} name */
46
46
  editBlock(name: string): string | null;
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
+ scheduleBusy(name: string): string | null;
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,
51
+ * never from the page's word. False for a run that does not resolve.
52
+ * @param {string} flow @param {unknown} runId
53
+ */
54
+ runIsRed(flow: string, runId: unknown): boolean;
55
+ /**
56
+ * M6 am5/am6: the job key of the signed flow `name` (see src/jobkey.js), or null when it is not a signed flow that reads. The draft door compares a Reuse card with it.
57
+ * @param {string} name
58
+ */
59
+ signedJobKey(name: string): string | null;
60
+ /**
61
+ * `POST /api/author/reuse-check` (M6 am6 item 2): what the ONE Reuse card's button is for the fields as typed, decided here, at $0, writes nothing.
62
+ * Any job field changed (lines, guardrails, asks, steps) = `draft` (with the next free name); else a RED source run (`[✗]`, M6 am9) = `draft` with `runOf: true`; else a destination, cap or ask wait different from the
63
+ * signed value = `sign-run` (with the hash the second click carries); else `run`. Only a red run's colour enters, and the server reads it. `fromRun` (the run the card was
64
+ * opened from) is dropped before the run checks; `job` is read here and never reaches the run door.
65
+ * @param {any} body
66
+ */
67
+ reuseCheck(body: any): {
68
+ status: any;
69
+ body: any;
70
+ };
47
71
  /** M9: the source paths the newest run of this job used, role -> path (blank = none), for a start a trigger fires. @param {string} name @param {string[]} roles */
48
72
  lastSourcesOf(name: string, roles: string[]): {
49
73
  runId: null;
@@ -66,10 +90,8 @@ export function createFlowsDoor(opts: {
66
90
  ok: boolean;
67
91
  flows: {
68
92
  edit: {
69
- ok: boolean;
93
+ ok: false;
70
94
  say: string;
71
- card?: undefined;
72
- flowHash?: undefined;
73
95
  } | {
74
96
  ok: boolean;
75
97
  card: {
@@ -79,8 +101,6 @@ export function createFlowsDoor(opts: {
79
101
  capUsd: string;
80
102
  askWait: string;
81
103
  };
82
- flowHash: any;
83
- say?: undefined;
84
104
  };
85
105
  values: {
86
106
  capUsd: number;
@@ -110,6 +130,10 @@ export function createFlowsDoor(opts: {
110
130
  destination: string | null;
111
131
  askWaits: Record<string, string>;
112
132
  };
133
+ model: {
134
+ slot: any;
135
+ model: any;
136
+ } | null;
113
137
  runId: string;
114
138
  }[];
115
139
  stats: {
@@ -153,10 +177,8 @@ export function createFlowsDoor(opts: {
153
177
  ok: boolean;
154
178
  flow: {
155
179
  edit: {
156
- ok: boolean;
180
+ ok: false;
157
181
  say: string;
158
- card?: undefined;
159
- flowHash?: undefined;
160
182
  } | {
161
183
  ok: boolean;
162
184
  card: {
@@ -166,8 +188,6 @@ export function createFlowsDoor(opts: {
166
188
  capUsd: string;
167
189
  askWait: string;
168
190
  };
169
- flowHash: any;
170
- say?: undefined;
171
191
  };
172
192
  values: {
173
193
  capUsd: number;
@@ -197,6 +217,10 @@ export function createFlowsDoor(opts: {
197
217
  destination: string | null;
198
218
  askWaits: Record<string, string>;
199
219
  };
220
+ model: {
221
+ slot: any;
222
+ model: any;
223
+ } | null;
200
224
  runId: string;
201
225
  }[];
202
226
  stats: {
@@ -215,6 +239,10 @@ export function createFlowsDoor(opts: {
215
239
  destination: string | null;
216
240
  askWaits: Record<string, string>;
217
241
  };
242
+ model: {
243
+ slot: any;
244
+ model: any;
245
+ } | null;
218
246
  runId: string;
219
247
  };
220
248
  };