fwdloop 0.14.0 → 0.15.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/package.json +1 -1
- package/src/authoring.js +5 -2
- package/src/checked.js +9 -5
- package/src/declaration.js +2 -0
- package/src/flow.js +220 -5
- package/src/panel/author.js +9 -3
- package/src/panel/authorcard.js +55 -3
- package/src/panel/authorflows.js +39 -3
- package/src/panel/authorresume.js +2 -2
- package/src/panel/authorstart.js +18 -10
- package/src/panel/data.js +59 -18
- package/src/panel/index.html +148 -41
- package/src/panel/server.js +1 -1
- package/src/runner.js +9 -1
- package/src/signed-diff.js +71 -0
- package/types/authoring.d.ts +11 -5
- package/types/checked.d.ts +6 -4
- package/types/flow.d.ts +42 -2
- package/types/panel/author.d.ts +34 -0
- package/types/panel/authorcard.d.ts +32 -0
- package/types/panel/authorflows.d.ts +39 -0
- package/types/panel/authorstart.d.ts +1 -0
- package/types/panel/data.d.ts +8 -4
- package/types/signed-diff.d.ts +10 -0
package/types/flow.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/** The plain "what changed" sentences inside a readFlow refusal (am43), joined for a sentence a human reads; '' when there are none. @param {string[]} reds */
|
|
2
|
+
export function changeSentence(reds: string[]): string;
|
|
1
3
|
/**
|
|
2
4
|
* Check a flow name against the allowed shape: 1..64 characters, lowercase
|
|
3
5
|
* a-z, 0-9, `-`, `_`, starting with a letter or digit. Walked character by
|
|
@@ -174,10 +176,13 @@ export function readdirInside(baseDir: string, relDir: string): string[];
|
|
|
174
176
|
* last (each via a temp file + rename in the same directory), creates an
|
|
175
177
|
* empty `runs/`, and proves the result by reading it back with `readFlow`.
|
|
176
178
|
*
|
|
177
|
-
*
|
|
179
|
+
* M6: with `replaces: {flowHash}` it instead REPLACES the signed job already under that name (see `replaceSigned`), and only if that job is
|
|
180
|
+
* still the one with that signature hash. `onReplaceStep` is a test seam: called after each move of the swap; a throw there is a failure.
|
|
181
|
+
*
|
|
182
|
+
* @param {{root: unknown, name: unknown, proseText: unknown, declaration: unknown, signedBy: unknown, signedAt: unknown, catalogue: unknown, replaces?: {flowHash: string}, onReplaceStep?: (step: string) => void}} input
|
|
178
183
|
* @returns {WriteFlowResult}
|
|
179
184
|
*/
|
|
180
|
-
export function writeFlow({ root, name, proseText, declaration, signedBy, signedAt, catalogue, }: {
|
|
185
|
+
export function writeFlow({ root, name, proseText, declaration, signedBy, signedAt, catalogue, replaces, onReplaceStep, }: {
|
|
181
186
|
root: unknown;
|
|
182
187
|
name: unknown;
|
|
183
188
|
proseText: unknown;
|
|
@@ -185,7 +190,17 @@ export function writeFlow({ root, name, proseText, declaration, signedBy, signed
|
|
|
185
190
|
signedBy: unknown;
|
|
186
191
|
signedAt: unknown;
|
|
187
192
|
catalogue: unknown;
|
|
193
|
+
replaces?: {
|
|
194
|
+
flowHash: string;
|
|
195
|
+
};
|
|
196
|
+
onReplaceStep?: (step: string) => void;
|
|
188
197
|
}): WriteFlowResult;
|
|
198
|
+
/**
|
|
199
|
+
* The signature hash (`signature.json` `flow`) of the signed job in `flowDir`, or null when there is no readable one. It does NOT verify the
|
|
200
|
+
* files (that is `readFlow`): it only says which signing this folder is at, for M6's "was this job signed again since you opened it".
|
|
201
|
+
* @param {string} flowDir @returns {string|null}
|
|
202
|
+
*/
|
|
203
|
+
export function signedHashOf(flowDir: string): string | null;
|
|
189
204
|
/**
|
|
190
205
|
* Read and verify a signed flow from `<root>/<name>/`. Verifies the bytes on
|
|
191
206
|
* disk against the signature FIRST — before anything in the flow is
|
|
@@ -200,6 +215,31 @@ export function readFlow({ root, name, catalogue }: {
|
|
|
200
215
|
name: unknown;
|
|
201
216
|
catalogue: unknown;
|
|
202
217
|
}): ReadFlowResult;
|
|
218
|
+
/**
|
|
219
|
+
* M6 ("Each run saves a copy of the job it ran when it starts"): the ONE writer of `<runDir>/job/`. Reads the flow's three files, proves them against
|
|
220
|
+
* the flow's own signature first (a flow that does not verify is never copied), then writes them write-once (`wx`). `{ok:false, red}` writes nothing
|
|
221
|
+
* it did not finish (a half-written copy is removed). Never throws.
|
|
222
|
+
* @param {string} flowDir @param {string} runDir @param {string} [expectedFlowHash] the `signature.flow` the caller read; a different job on disk is refused
|
|
223
|
+
* @returns {{ok: true} | {ok: false, red: string}}
|
|
224
|
+
*/
|
|
225
|
+
export function writeRunJobCopy(flowDir: string, runDir: string, expectedFlowHash?: string): {
|
|
226
|
+
ok: true;
|
|
227
|
+
} | {
|
|
228
|
+
ok: false;
|
|
229
|
+
red: string;
|
|
230
|
+
};
|
|
231
|
+
/**
|
|
232
|
+
* 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
|
+
* shape as a good `readFlow` (lines, arbiter, declaration, signature, classes), after the copy was verified against the copied signature.
|
|
234
|
+
* `{present:true, ok:false, reds}` = a copy that was edited or is incomplete: refused, never shown as the job.
|
|
235
|
+
* @param {string} runDir @param {unknown} catalogue
|
|
236
|
+
* @returns {{present: false} | ({present: true} & ReadFlowResult)}
|
|
237
|
+
*/
|
|
238
|
+
export function readRunJobCopy(runDir: string, catalogue: unknown): {
|
|
239
|
+
present: false;
|
|
240
|
+
} | ({
|
|
241
|
+
present: true;
|
|
242
|
+
} & ReadFlowResult);
|
|
203
243
|
/** @typedef {import('./types.js').WriteFlowResult} WriteFlowResult */
|
|
204
244
|
/** @typedef {import('./types.js').ReadFlowResult} ReadFlowResult */
|
|
205
245
|
/** @typedef {import('./types.js').CheckFlowNameResult} CheckFlowNameResult */
|
package/types/panel/author.d.ts
CHANGED
|
@@ -27,6 +27,23 @@ export function createAuthor(opts: {
|
|
|
27
27
|
body: {
|
|
28
28
|
ok: boolean;
|
|
29
29
|
flows: {
|
|
30
|
+
edit: {
|
|
31
|
+
ok: boolean;
|
|
32
|
+
say: string;
|
|
33
|
+
card?: undefined;
|
|
34
|
+
flowHash?: undefined;
|
|
35
|
+
} | {
|
|
36
|
+
ok: boolean;
|
|
37
|
+
card: {
|
|
38
|
+
job: string;
|
|
39
|
+
inputs: string;
|
|
40
|
+
destination: string;
|
|
41
|
+
capUsd: string;
|
|
42
|
+
askWait: string;
|
|
43
|
+
};
|
|
44
|
+
flowHash: any;
|
|
45
|
+
say?: undefined;
|
|
46
|
+
};
|
|
30
47
|
values: {
|
|
31
48
|
capUsd: number;
|
|
32
49
|
destination: string | null;
|
|
@@ -86,6 +103,23 @@ export function createAuthor(opts: {
|
|
|
86
103
|
body: {
|
|
87
104
|
ok: boolean;
|
|
88
105
|
flow: {
|
|
106
|
+
edit: {
|
|
107
|
+
ok: boolean;
|
|
108
|
+
say: string;
|
|
109
|
+
card?: undefined;
|
|
110
|
+
flowHash?: undefined;
|
|
111
|
+
} | {
|
|
112
|
+
ok: boolean;
|
|
113
|
+
card: {
|
|
114
|
+
job: string;
|
|
115
|
+
inputs: string;
|
|
116
|
+
destination: string;
|
|
117
|
+
capUsd: string;
|
|
118
|
+
askWait: string;
|
|
119
|
+
};
|
|
120
|
+
flowHash: any;
|
|
121
|
+
say?: undefined;
|
|
122
|
+
};
|
|
89
123
|
values: {
|
|
90
124
|
capUsd: number;
|
|
91
125
|
destination: string | null;
|
|
@@ -62,6 +62,10 @@ 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;
|
|
65
69
|
flowName: string;
|
|
66
70
|
job: string;
|
|
67
71
|
destination: string;
|
|
@@ -81,6 +85,34 @@ export function runInputRows(v: any): {
|
|
|
81
85
|
* @returns {string}
|
|
82
86
|
*/
|
|
83
87
|
export function cardToProse(card: ReturnType<typeof cardFields>): string;
|
|
88
|
+
/**
|
|
89
|
+
* M6: a signed job turned back into the card's fields (the job box, inputs box, destination, cap, ask wait), from `parseSignedText`'s `lines` and
|
|
90
|
+
* `arbiter`. The ONE rule of fidelity is mechanical: the card is offered only if writing it again (`cardToProse` -> `parseSignedText`) gives back the
|
|
91
|
+
* SAME lines and the SAME arbiter (an old unsigned `ask:` wait is the one thing allowed to differ: it comes back signed at its 30m). A setting the
|
|
92
|
+
* card has no box for (a redo cap, a second send, a send off the last line, a wait in seconds) makes the answer `{ok:false, say}`; nothing is dropped.
|
|
93
|
+
* @param {{ lines: {n: number, text: string, guardrail: string}[], arbiter: any }} signed
|
|
94
|
+
* @returns {{ ok: true, card: { job: string, inputs: string, destination: string, capUsd: string, askWait: string } } | { ok: false, say: string }}
|
|
95
|
+
*/
|
|
96
|
+
export function cardFromSigned({ lines, arbiter }: {
|
|
97
|
+
lines: {
|
|
98
|
+
n: number;
|
|
99
|
+
text: string;
|
|
100
|
+
guardrail: string;
|
|
101
|
+
}[];
|
|
102
|
+
arbiter: any;
|
|
103
|
+
}): {
|
|
104
|
+
ok: true;
|
|
105
|
+
card: {
|
|
106
|
+
job: string;
|
|
107
|
+
inputs: string;
|
|
108
|
+
destination: string;
|
|
109
|
+
capUsd: string;
|
|
110
|
+
askWait: string;
|
|
111
|
+
};
|
|
112
|
+
} | {
|
|
113
|
+
ok: false;
|
|
114
|
+
say: string;
|
|
115
|
+
};
|
|
84
116
|
/**
|
|
85
117
|
* The $0 check of the input rows, shared by the card (draft door) and the Run-a-signed-flow door: a role and a path on every row,
|
|
86
118
|
* a role shape the signed-text parser accepts and used once, each path a full path to a readable regular file (realpath at the
|
|
@@ -29,6 +29,8 @@ export function createFlowsDoor(opts: {
|
|
|
29
29
|
starter: ReturnType<typeof import("./authorstart.js").createStarter>;
|
|
30
30
|
monthlyClaim: (usd: number) => any;
|
|
31
31
|
}): {
|
|
32
|
+
/** 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 */
|
|
33
|
+
editBlock(name: string): string | null;
|
|
32
34
|
/** `GET /api/author/flows`. */
|
|
33
35
|
flows(): {
|
|
34
36
|
status: number;
|
|
@@ -42,6 +44,23 @@ export function createFlowsDoor(opts: {
|
|
|
42
44
|
body: {
|
|
43
45
|
ok: boolean;
|
|
44
46
|
flows: {
|
|
47
|
+
edit: {
|
|
48
|
+
ok: boolean;
|
|
49
|
+
say: string;
|
|
50
|
+
card?: undefined;
|
|
51
|
+
flowHash?: undefined;
|
|
52
|
+
} | {
|
|
53
|
+
ok: boolean;
|
|
54
|
+
card: {
|
|
55
|
+
job: string;
|
|
56
|
+
inputs: string;
|
|
57
|
+
destination: string;
|
|
58
|
+
capUsd: string;
|
|
59
|
+
askWait: string;
|
|
60
|
+
};
|
|
61
|
+
flowHash: any;
|
|
62
|
+
say?: undefined;
|
|
63
|
+
};
|
|
45
64
|
values: {
|
|
46
65
|
capUsd: number;
|
|
47
66
|
destination: string | null;
|
|
@@ -107,6 +126,23 @@ export function createFlowsDoor(opts: {
|
|
|
107
126
|
body: {
|
|
108
127
|
ok: boolean;
|
|
109
128
|
flow: {
|
|
129
|
+
edit: {
|
|
130
|
+
ok: boolean;
|
|
131
|
+
say: string;
|
|
132
|
+
card?: undefined;
|
|
133
|
+
flowHash?: undefined;
|
|
134
|
+
} | {
|
|
135
|
+
ok: boolean;
|
|
136
|
+
card: {
|
|
137
|
+
job: string;
|
|
138
|
+
inputs: string;
|
|
139
|
+
destination: string;
|
|
140
|
+
capUsd: string;
|
|
141
|
+
askWait: string;
|
|
142
|
+
};
|
|
143
|
+
flowHash: any;
|
|
144
|
+
say?: undefined;
|
|
145
|
+
};
|
|
110
146
|
values: {
|
|
111
147
|
capUsd: number;
|
|
112
148
|
destination: string | null;
|
|
@@ -173,3 +209,6 @@ export function createFlowsDoor(opts: {
|
|
|
173
209
|
body: any;
|
|
174
210
|
};
|
|
175
211
|
};
|
|
212
|
+
export function editBlockedSay(runId: string): string;
|
|
213
|
+
/** M6 amendment 3: the sentence for a job with a start still alive (its start folder in phase `starting`). */
|
|
214
|
+
export const EDIT_STARTING_SAY: "a run is starting";
|
|
@@ -14,6 +14,7 @@ export function createStarter(opts: {
|
|
|
14
14
|
runDir: string;
|
|
15
15
|
say?: undefined;
|
|
16
16
|
};
|
|
17
|
+
startingFor: (flow: string, keys: string[]) => string | null;
|
|
17
18
|
/**
|
|
18
19
|
* Start `fwdloop run` for a flow whose every $0 check already passed at the calling door. Re-checks the run id here (nothing
|
|
19
20
|
* awaits between this check and the spawn). 202 { startId, runId } or a refusal; a refusal creates nothing.
|
package/types/panel/data.d.ts
CHANGED
|
@@ -175,10 +175,10 @@ export function glyphPulses(g: {
|
|
|
175
175
|
* A saved answer with a live process is `[▶]` working on your answer.
|
|
176
176
|
* - `[?]` crashed after taking your answer (amendment 2 (f)) — the answer was
|
|
177
177
|
* consumed, the process is gone, no end row: cannot be carried on.
|
|
178
|
-
* @param {{historyRow: any, askJson: any, consumedAnswerExists: boolean, hasStateJson: boolean, resume?: any, liveness?: 'running'|'gone'|'unknown', booksFresh?: boolean, lock?: string, resumable?: boolean, stoppedAtAsk?: string|null}} ctx
|
|
178
|
+
* @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}} ctx
|
|
179
179
|
* @returns {{glyph: '[✓]'|'[✗]'|'[·]'|'[!]'|'[▶]'|'[?]'|'[II]'|'[■]', label: string}}
|
|
180
180
|
*/
|
|
181
|
-
export function computeGlyph({ historyRow, askJson, consumedAnswerExists, hasStateJson, resume, liveness, booksFresh, lock, resumable, stoppedAtAsk, }: {
|
|
181
|
+
export function computeGlyph({ historyRow, askJson, consumedAnswerExists, hasStateJson, resume, liveness, booksFresh, lock, resumable, stoppedAtAsk, jobEdited, }: {
|
|
182
182
|
historyRow: any;
|
|
183
183
|
askJson: any;
|
|
184
184
|
consumedAnswerExists: boolean;
|
|
@@ -189,6 +189,7 @@ export function computeGlyph({ historyRow, askJson, consumedAnswerExists, hasSta
|
|
|
189
189
|
lock?: string;
|
|
190
190
|
resumable?: boolean;
|
|
191
191
|
stoppedAtAsk?: string | null;
|
|
192
|
+
jobEdited?: boolean;
|
|
192
193
|
}): {
|
|
193
194
|
glyph: "[\u2713]" | "[\u2717]" | "[\u00B7]" | "[!]" | "[\u25B6]" | "[?]" | "[II]" | "[\u25A0]";
|
|
194
195
|
label: string;
|
|
@@ -655,12 +656,13 @@ export function getRunAsks({ root, flow, runId, catalogue, resumeAttempt, }: {
|
|
|
655
656
|
* force-`false` here as a second, independent check (belt-and-braces on the
|
|
656
657
|
* one thing the brief calls out by name: "the Inbox tab's open count counts
|
|
657
658
|
* only truly open asks — parked run, no history row, unexpired, unanswered").
|
|
658
|
-
* @param {{root: string, resumeAttempt?: (flow: string, runId: string) => any}} opts
|
|
659
|
+
* @param {{root: string, resumeAttempt?: (flow: string, runId: string) => any, catalogue?: any}} opts
|
|
659
660
|
* @returns {any[]}
|
|
660
661
|
*/
|
|
661
|
-
export function listStops({ root, resumeAttempt }: {
|
|
662
|
+
export function listStops({ root, resumeAttempt, catalogue }: {
|
|
662
663
|
root: string;
|
|
663
664
|
resumeAttempt?: (flow: string, runId: string) => any;
|
|
665
|
+
catalogue?: any;
|
|
664
666
|
}): any[];
|
|
665
667
|
/**
|
|
666
668
|
* The ONE ordering of the Inbox (M4c item 4, hamr 2026-09-30); the page renders
|
|
@@ -714,3 +716,5 @@ export const STUCK_REASONS: {
|
|
|
714
716
|
};
|
|
715
717
|
/** The words the Draft says for a flow with no `setup.jsonl` (M4e amendment 6 item 4; renamed Draft by amendment 7 item 2). */
|
|
716
718
|
export const NO_DRAFT_WORDS: "no draft record";
|
|
719
|
+
/** M6: what the Job tab says for a run that started before runs kept a copy of their job. */
|
|
720
|
+
export const NO_JOB_COPY_WORDS: "This run started before runs kept a copy of their job, so this shows the job as it is now.";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {{ oldProse: string, newProse: string, oldDecl: string, newDecl: string }} x the signed copy (old) and the files on disk (new)
|
|
3
|
+
* @returns {string[]} plain sentences; empty when nothing differs
|
|
4
|
+
*/
|
|
5
|
+
export function describeChange({ oldProse, newProse, oldDecl, newDecl }: {
|
|
6
|
+
oldProse: string;
|
|
7
|
+
newProse: string;
|
|
8
|
+
oldDecl: string;
|
|
9
|
+
newDecl: string;
|
|
10
|
+
}): string[];
|