@delurio/cli 0.7.0 → 0.9.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/dist/graph.d.ts CHANGED
@@ -92,10 +92,24 @@ export interface UiNode {
92
92
  unless?: string[];
93
93
  when?: string;
94
94
  disabledIn?: string[];
95
+ disabledWhen?: string;
95
96
  emits?: string;
96
97
  initialFocus?: string;
98
+ repeat?: string;
97
99
  frame?: string;
100
+ value?: Label;
101
+ checked?: boolean | string;
102
+ script?: 'optional' | 'actions';
103
+ source?: string;
104
+ }
105
+ export interface UiEdge {
106
+ labelledBy?: [string, string];
107
+ triggers?: [string, string];
108
+ returnsFocus?: [string, string | string[]];
98
109
  }
110
+ export declare const OPENER = "opener";
111
+ export declare const CHECKABLE: readonly ['checkbox', 'menuitemcheckbox', 'menuitemradio', 'option', 'radio', 'switch'];
112
+ export declare const isDialog: (n: UiNode | undefined) => boolean;
99
113
  export interface Ui {
100
114
  absent?: boolean;
101
115
  id: string;
@@ -106,7 +120,16 @@ export interface Ui {
106
120
  locales?: string[];
107
121
  changes?: {
108
122
  key: string;
123
+ missing?: undefined;
124
+ } | {
125
+ missing: string;
126
+ key?: undefined;
127
+ };
128
+ task?: {
129
+ key: string;
109
130
  };
131
+ focus?: Record<string, string>;
132
+ edges?: UiEdge[];
110
133
  }
111
134
  export interface Graph {
112
135
  dir: string;
@@ -114,9 +137,26 @@ export interface Graph {
114
137
  ui: Ui;
115
138
  catalog: Record<string, string>;
116
139
  }
140
+ export interface ErrorPlace {
141
+ file: string;
142
+ path?: string[];
143
+ line?: number;
144
+ column?: number;
145
+ }
117
146
  export declare class GraphError extends Error {
147
+ readonly place: ErrorPlace | undefined;
148
+ constructor(message: string, place?: ErrorPlace);
118
149
  }
150
+ export declare function placed<E>(err: E, place: ErrorPlace): E;
151
+ export declare function transitionPath(state: string, st: State, event: string | null, i: number): string[];
119
152
  export declare function humanize(id: string): string;
120
153
  export declare function titleOf(flow: Flow, state: string): string;
154
+ export declare function shownIn(n: UiNode, state: string): boolean;
155
+ export interface FocusAfter {
156
+ node: string;
157
+ by: 'returnsFocus' | 'initialFocus' | 'focus';
158
+ from?: string;
159
+ }
160
+ export declare function focusAfter(ui: Ui, from: string | null, to: string, pressed?: string): FocusAfter | null;
121
161
  export declare function alternatives(spec: TransitionSpec): Transition[];
122
162
  export declare function load(dir: string, read?: (file: string) => string, exists?: (file: string) => boolean): Graph;
package/dist/graph.js CHANGED
@@ -1,8 +1,72 @@
1
1
  import { existsSync, readFileSync } from 'node:fs';
2
2
  import { join } from 'node:path';
3
- import { readYaml } from './yaml.js';
3
+ import { lineAndColumn, readYaml } from './yaml.js';
4
4
  import { identifiers, parseExpr } from './expr.js';
5
+ // in a returnsFocus, the node that was pressed to open the dialog, whichever it is (SPEC.md §4); no node is called so
6
+ export const OPENER = 'opener';
7
+ // the roles whose node may say whether it is `checked` (WAI-ARIA 1.2: the roles that support aria-checked)
8
+ export const CHECKABLE = ['checkbox', 'menuitemcheckbox', 'menuitemradio', 'option', 'radio', 'switch'];
9
+ // a page node drawn over another page, whose closing `returnsFocus` may give the focus back (SPEC.md §4)
10
+ export const isDialog = (n) => n?.type === 'page' && (n.role === 'dialog' || n.role === 'alertdialog');
5
11
  export class GraphError extends Error {
12
+ place;
13
+ constructor(message, place) {
14
+ super(message);
15
+ this.place = place;
16
+ }
17
+ }
18
+ // the place of an error that a reader of the graph's files threw, given to it when it has none yet: a YAML error of
19
+ // ui.yaml then says it is in ui.yaml, and the line the parser gave is kept
20
+ export function placed(err, place) {
21
+ if (err instanceof Error && err.place === undefined)
22
+ Object.assign(err, { place });
23
+ return err;
24
+ }
25
+ // the file a graph names, read as YAML, a YAML error carrying the file it is in
26
+ function readGraphFile(read, file) {
27
+ try {
28
+ return readYaml(read(file));
29
+ }
30
+ catch (err) {
31
+ throw placed(err, { file });
32
+ }
33
+ }
34
+ const isMapValue = (v) => v !== null && typeof v === 'object' && !Array.isArray(v);
35
+ // the place of a transition in flow.yaml: `on.<event>`, the item of a list of alternatives, or an item of `always`
36
+ export function transitionPath(state, st, event, i) {
37
+ if (event === null)
38
+ return ['states', state, 'always', String(i)];
39
+ return Array.isArray(st.on?.[event]) ? ['states', state, 'on', event, String(i)] : ['states', state, 'on', event];
40
+ }
41
+ // a catalog: a JSON object, read from the file ui.yaml names; one that is not there, or is not JSON, keeps the graph
42
+ // from loading, at the place that names it or at the place the JSON parser gave
43
+ function readCatalog(read, exists, ui) {
44
+ if (typeof ui.catalog !== 'string' || ui.catalog === '') {
45
+ throw new GraphError('ui.yaml names no catalog: it gives the words of its screens as catalog: catalog/<locale>.json (SPEC.md §4)', { file: 'ui.yaml', path: [] });
46
+ }
47
+ if (!exists(ui.catalog))
48
+ throw new GraphError(`the catalog ${ui.catalog} that ui.yaml names does not exist`, { file: 'ui.yaml', path: ['catalog'] });
49
+ let text;
50
+ try {
51
+ text = read(ui.catalog);
52
+ }
53
+ catch (err) {
54
+ throw new GraphError(`the catalog ${ui.catalog} that ui.yaml names cannot be read: ${err.message}`, { file: 'ui.yaml', path: ['catalog'] });
55
+ }
56
+ try {
57
+ return JSON.parse(text);
58
+ }
59
+ catch (err) {
60
+ const message = err.message;
61
+ const at = /line (\d+) column (\d+)/.exec(message);
62
+ const offset = /position (\d+)/.exec(message);
63
+ const place = { file: ui.catalog };
64
+ if (at !== null)
65
+ Object.assign(place, { line: Number(at[1]), column: Number(at[2]) });
66
+ else if (offset !== null)
67
+ Object.assign(place, lineAndColumn(text, Number(offset[1])));
68
+ throw new GraphError(`the catalog ${ui.catalog} is not JSON: ${message}`, place);
69
+ }
6
70
  }
7
71
  // 'silentRedirect' -> 'silent redirect'; used only when the graph gives no title
8
72
  export function humanize(id) {
@@ -12,56 +76,161 @@ export function humanize(id) {
12
76
  export function titleOf(flow, state) {
13
77
  return flow.states[state].title ?? humanize(state);
14
78
  }
79
+ // a node is shown in a state when the state is in its `in` and not in its `unless`; `when` is read over the context
80
+ export function shownIn(n, state) {
81
+ return (n.in ?? []).includes(state) && !(n.unless ?? []).includes(state);
82
+ }
83
+ // The node that has focus once the flow has moved from the state `from` (null when it starts) into another state `to`,
84
+ // both states the flow stops in (SPEC.md §4, Focus): a dialog that closes gives it back to its `returnsFocus` node when
85
+ // `to` shows that node; else a page that opens gives it to its `initialFocus`, a dialog's before the page it covers;
86
+ // else `focus.<to>`. null when the graph does not say, and on a move from a state to itself. `pressed` is the node that
87
+ // was pressed to open the dialog, which a replay knows and the graph does not: a returnsFocus that lists several
88
+ // nodes, or says OPENER, gives the focus to it. Without it, a list gives the one node of it that `to` shows, and
89
+ // OPENER, or a list of which `to` shows several, gives null.
90
+ export function focusAfter(ui, from, to, pressed) {
91
+ if (from === to)
92
+ return null;
93
+ const nodes = ui.nodes;
94
+ const shown = (id, state) => state !== null && nodes[id] !== undefined && shownIn(nodes[id], state);
95
+ for (const e of ui.edges ?? []) {
96
+ const [dialog, target] = e.returnsFocus ?? [];
97
+ if (dialog === undefined || target === undefined || !isDialog(nodes[dialog]))
98
+ continue;
99
+ if (!shown(dialog, from) || shown(dialog, to))
100
+ continue;
101
+ if (typeof target === 'string' && target !== OPENER) {
102
+ if (shown(target, to))
103
+ return { node: target, by: 'returnsFocus', from: dialog };
104
+ continue;
105
+ }
106
+ // the node that opened the dialog: the one pressed, when the caller knows it, among those a list allows
107
+ const allowed = (id) => target === OPENER || (Array.isArray(target) && target.includes(id));
108
+ if (pressed !== undefined) {
109
+ if (allowed(pressed) && shown(pressed, to))
110
+ return { node: pressed, by: 'returnsFocus', from: dialog };
111
+ continue;
112
+ }
113
+ const candidates = Array.isArray(target) ? target.filter((id) => shown(id, to)) : [];
114
+ if (candidates.length === 1)
115
+ return { node: candidates[0], by: 'returnsFocus', from: dialog };
116
+ return null;
117
+ }
118
+ const opened = Object.entries(nodes).filter(([id, n]) => n.type === 'page' && n.initialFocus !== undefined && shown(id, to) && !shown(id, from));
119
+ const page = opened.find(([, n]) => isDialog(n)) ?? opened[0];
120
+ if (page !== undefined)
121
+ return { node: page[1].initialFocus, by: 'initialFocus', from: page[0] };
122
+ const node = from === null ? undefined : ui.focus?.[to];
123
+ return node === undefined ? null : { node, by: 'focus' };
124
+ }
15
125
  export function alternatives(spec) {
16
126
  const list = Array.isArray(spec) ? spec : [spec];
17
127
  return list.map((a) => (typeof a === 'string' ? { target: a } : a));
18
128
  }
19
129
  // `read` and `exists` take a path relative to `dir`; the revision diff passes ones that read a git revision instead of the disk
20
130
  export function load(dir, read = (file) => readFileSync(join(dir, file), 'utf8'), exists = (file) => existsSync(join(dir, file))) {
21
- const flow = readYaml(read('flow.yaml'));
131
+ const flow = readGraphFile(read, 'flow.yaml');
132
+ if (!isMapValue(flow))
133
+ throw new GraphError('flow.yaml is not a map of keys (SPEC.md §2)', { file: 'flow.yaml', path: [] });
134
+ if (!isMapValue(flow.states))
135
+ throw new GraphError('flow.yaml has no states: a flow gives them as states: { <state>: { .. } } (SPEC.md §2)', { file: 'flow.yaml', path: ['states'] });
22
136
  // a flow with no context, guards or effects leaves the key out; every reader expects an object
23
137
  flow.context ??= {};
24
138
  flow.guards ??= {};
25
139
  flow.effects ??= {};
26
140
  // a flow with no screens (an endpoint, a webhook, a CI job) has no ui.yaml and no catalog
27
- const ui = exists('ui.yaml') ? readYaml(read('ui.yaml')) : { absent: true, id: flow.id, catalog: '', samples: {}, nodes: {} };
28
- const catalog = ui.absent === true ? {} : JSON.parse(read(ui.catalog));
141
+ const ui = exists('ui.yaml') ? readGraphFile(read, 'ui.yaml') : { absent: true, id: flow.id, catalog: '', samples: {}, nodes: {} };
142
+ if (!isMapValue(ui))
143
+ throw new GraphError('ui.yaml is not a map of keys (SPEC.md §4)', { file: 'ui.yaml', path: [] });
144
+ ui.nodes ??= {};
145
+ ui.samples ??= {};
146
+ const catalog = ui.absent === true ? {} : readCatalog(read, exists, ui);
29
147
  if (flow.states[flow.initial] === undefined)
30
- throw new GraphError(`initial state ${flow.initial} does not exist`);
148
+ throw new GraphError(`initial state ${flow.initial} does not exist`, { file: 'flow.yaml', path: ['initial'] });
31
149
  for (const [name, st] of Object.entries(flow.states)) {
150
+ if (!isMapValue(st))
151
+ throw new GraphError(`state ${name} is not a map of keys: write it as ${name}: { .. } (SPEC.md §2)`, { file: 'flow.yaml', path: ['states', name] });
32
152
  if (st.states !== undefined || st.type === 'parallel' || st.type === 'history') {
33
- throw new GraphError(`state ${name}: nested, parallel and history states are not supported by graph-viz yet`);
153
+ throw new GraphError(`state ${name}: nested, parallel and history states are not supported by graph-viz yet`, { file: 'flow.yaml', path: ['states', name, st.states !== undefined ? 'states' : 'type'] });
34
154
  }
35
- const targets = [
36
- ...(st.always ?? []).map((a) => a.target),
37
- ...Object.values(st.on ?? {}).flatMap((spec) => alternatives(spec).map((a) => a.target)),
155
+ const ways = [
156
+ ...(st.always ?? []).map((a, i) => [null, i, a]),
157
+ ...Object.entries(st.on ?? {}).flatMap(([event, spec]) => alternatives(spec).map((a, i) => [event, i, a])),
38
158
  ];
39
- for (const t of targets) {
40
- if (flow.states[t] === undefined)
41
- throw new GraphError(`state ${name} goes to ${t}, which does not exist`);
42
- }
43
- const ways = [...(st.always ?? []), ...Object.values(st.on ?? {}).flatMap((spec) => alternatives(spec))];
44
- for (const w of ways) {
159
+ for (const [event, i, w] of ways) {
160
+ const path = transitionPath(name, st, event, i);
161
+ if (flow.states[w.target] === undefined)
162
+ throw new GraphError(`state ${name} goes to ${w.target}, which does not exist`, { file: 'flow.yaml', path });
45
163
  if (w.starts === undefined)
46
164
  continue;
47
165
  if (typeof w.starts.flow !== 'string')
48
- throw new GraphError(`state ${name}: \`starts\` names no flow`);
166
+ throw new GraphError(`state ${name}: \`starts\` names no flow`, { file: 'flow.yaml', path: [...path, 'starts'] });
49
167
  for (const [k, v] of Object.entries(w.starts.given ?? {})) {
50
168
  if (typeof v !== 'string')
51
169
  continue;
52
- for (const id of identifiers(parseExpr(v))) {
170
+ const at = { file: 'flow.yaml', path: [...path, 'starts', 'given', k] };
171
+ let names;
172
+ try {
173
+ names = identifiers(parseExpr(v));
174
+ }
175
+ catch (err) {
176
+ throw new GraphError(`state ${name} starts ${w.starts.flow} with ${k} = ${v}: ${err.message}`, at);
177
+ }
178
+ for (const id of names) {
53
179
  if (id !== 'state' && flow.context[id] === undefined && flow.guards[id] === undefined) {
54
- throw new GraphError(`state ${name} starts ${w.starts.flow} with ${k} = ${v}: ${id} is not a variable or a guard of this flow (a value is quoted: '${id}')`);
180
+ throw new GraphError(`state ${name} starts ${w.starts.flow} with ${k} = ${v}: ${id} is not a variable or a guard of this flow (a value is quoted: '${id}')`, at);
55
181
  }
56
182
  }
57
183
  }
58
184
  }
59
185
  }
60
186
  for (const [id, node] of Object.entries(ui.nodes)) {
61
- for (const s of [...(node.in ?? []), ...(node.unless ?? []), ...(node.disabledIn ?? [])]) {
62
- if (flow.states[s] === undefined)
63
- throw new GraphError(`ui node ${id} names the unknown state ${s}`);
187
+ for (const key of ['in', 'unless', 'disabledIn']) {
188
+ (node[key] ?? []).forEach((s, i) => {
189
+ if (flow.states[s] === undefined)
190
+ throw new GraphError(`ui node ${id} names the unknown state ${s}`, { file: 'ui.yaml', path: ['nodes', id, key, String(i)] });
191
+ });
192
+ }
193
+ // `checked` is an expression over the context (SPEC.md §3), read when the node is shown
194
+ if (typeof node.checked === 'string') {
195
+ const at = { file: 'ui.yaml', path: ['nodes', id, 'checked'] };
196
+ let names;
197
+ try {
198
+ names = identifiers(parseExpr(node.checked));
199
+ }
200
+ catch (err) {
201
+ throw new GraphError(`ui node ${id}: checked: ${err.message}`, at);
202
+ }
203
+ for (const n of names) {
204
+ if (n !== 'state' && flow.context[n] === undefined && flow.guards[n] === undefined) {
205
+ throw new GraphError(`ui node ${id}: checked: ${node.checked} names ${n}, which is not a variable or a guard of the flow`, at);
206
+ }
207
+ }
64
208
  }
65
209
  }
210
+ for (const s of Object.keys(ui.focus ?? {})) {
211
+ if (flow.states[s] === undefined)
212
+ throw new GraphError(`ui focus names the unknown state ${s}`, { file: 'ui.yaml', path: ['focus', s] });
213
+ }
214
+ disabledWhenReads(flow, ui);
66
215
  return { dir, flow, ui, catalog };
67
216
  }
217
+ // a node's `disabledWhen` is an expression over the context (SPEC.md §3, §4), read where the node is shown: one that
218
+ // does not parse, or names what is not a variable, a guard or `state`, keeps the graph from loading, as `checked` does
219
+ function disabledWhenReads(flow, ui) {
220
+ for (const [id, node] of Object.entries(ui.nodes)) {
221
+ if (typeof node.disabledWhen !== 'string')
222
+ continue;
223
+ let names;
224
+ try {
225
+ names = identifiers(parseExpr(node.disabledWhen));
226
+ }
227
+ catch (err) {
228
+ throw new GraphError(`ui node ${id}: disabledWhen: ${err.message}`);
229
+ }
230
+ for (const n of names) {
231
+ if (n !== 'state' && flow.context[n] === undefined && flow.guards[n] === undefined) {
232
+ throw new GraphError(`ui node ${id}: disabledWhen: ${node.disabledWhen} names ${n}, which is not a variable or a guard of the flow`);
233
+ }
234
+ }
235
+ }
236
+ }
package/dist/html.d.ts CHANGED
@@ -4,7 +4,7 @@ import type { Story } from './story.ts';
4
4
  import type { Kit } from './kit.ts';
5
5
  import type { HandOver } from './starts.ts';
6
6
  import type { Domain, DomainAction } from './changes.ts';
7
- export declare const CSS = "\n:root { --bg:#fafaf9; --surface:#ffffff; --ink:#1c1917; --muted:#6b6560; --line:#d6d3d1; --accent:#1d4ed8; --accent-bg:#eef3ff; --ok:#15803d; --bad:#b91c1c; --server:#eeeeec; --focus:#1d4ed8; --ai:#7e22ce; --ai-bg:#f5edff; --agent:#c2410c; --agent-bg:#fff1e8; --ci:#0f766e; --ci-bg:#e6f6f3; --ok-bg:#eaf7ee; }\n@media (prefers-color-scheme: dark) { :root { --bg:#161513; --surface:#1f1d1b; --ink:#f2efec; --muted:#a8a29e; --line:#44403c; --accent:#8fb0ff; --accent-bg:#1c2438; --ok:#5fcf85; --bad:#f08080; --server:#2a2826; --focus:#8fb0ff; --ai:#c99bff; --ai-bg:#2a2135; --agent:#ff9a66; --agent-bg:#33241b; --ci:#5fd4c4; --ci-bg:#1a2e2b; --ok-bg:#16291d; } }\n* { box-sizing: border-box; }\nbody { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.55 system-ui, -apple-system, \"Segoe UI\", sans-serif; }\nmain { max-width: 1000px; margin: 0 auto; padding: 28px 16px 80px; }\nh1 { font-size: 30px; line-height: 1.2; margin: 6px 0 8px; } h2 { font-size: 21px; margin: 44px 0 12px; } h3 { font-size: 16px; margin: 0; }\ncode, pre, .mono { font-family: ui-monospace, \"SF Mono\", Menlo, Consolas, monospace; font-size: 13px; }\n.muted { color: var(--muted); } .label { margin: 0 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }\n.eyebrow { margin: 0; color: var(--muted); } .lede { font-size: 18px; max-width: 46em; margin: 0; }\n.tag { display: inline-block; padding: 1px 8px; border: 1px solid var(--line); border-radius: 99px; font-size: 12px; color: var(--muted); vertical-align: middle; }\n.scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }\ntable { border-collapse: collapse; width: 100%; } th, td { text-align: left; vertical-align: top; padding: 8px 12px; border-bottom: 1px solid var(--line); } th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); } tr:last-child td { border-bottom: 0; }\ntd ol { margin: 0; padding-left: 20px; }\n.ok { color: var(--ok); font-weight: 600; } .bad { color: var(--bad); font-weight: 600; }\n.story { margin-top: 28px; padding: 18px 22px; border: 1px solid var(--line); border-left: 5px solid var(--accent); border-radius: 10px; background: var(--surface); }\n.story h2 { margin: 0 0 6px; } .story .given { margin: 0 0 8px; } .story ol { margin: 0; padding-left: 26px; } .story li { margin: 5px 0; padding-left: 4px; } .story .result { margin: 10px 0 0; font-weight: 600; }\n.views input { margin-right: 8px; accent-color: var(--accent); } .views label { display: inline-block; margin: 0 0 10px; cursor: pointer; }\n.views .panel-full { display: none; } .views input:checked ~ .panel-main { display: none; } .views input:checked ~ .panel-full { display: block; }\nsvg.spine { display: block; width: 100%; height: auto; padding: 8px; background: var(--surface); margin: 0 auto; }\n.spine .edge { fill: none; stroke-width: 1.5; } .spine .edge-user { stroke: var(--muted); } .spine .edge-system { stroke: var(--muted); } .spine .edge-route { stroke: var(--muted); stroke-dasharray: 2 4; } .spine .edge-fail { stroke: var(--bad); stroke-dasharray: 7 4; } .spine .edge-unused { stroke: var(--line); }\n.spine .edge-main { stroke: var(--accent); stroke-width: 3.5; stroke-dasharray: none; }\n.spine .arrow { fill: var(--muted); } .spine .arrow-fail { fill: var(--bad); } .spine .arrow-main { fill: var(--accent); }\n.spine .elabel rect { fill: var(--surface); stroke: var(--line); } .spine .elabel text { fill: var(--ink); font: 13px system-ui, sans-serif; } .spine .elabel-fail text { fill: var(--bad); } .spine .elabel-main rect { stroke: var(--accent); }\n.spine .node rect { fill: var(--surface); stroke: var(--ink); stroke-width: 1.6; } .spine .node-server rect { fill: var(--server); stroke: var(--muted); stroke-dasharray: 5 3; }\n.spine .node-subflow rect { stroke: var(--accent); } .spine .node-subflow rect.inner { fill: none; stroke-width: 1; }\n.spine .on-main rect { stroke-width: 3; } .spine .node-server.on-main rect { stroke: var(--accent); }\n.spine .exit-never rect { stroke: var(--bad); stroke-width: 3; } .spine .exit-error rect { stroke-dasharray: 6 3; } .spine .exit-left rect { stroke-dasharray: 2 3; stroke: var(--muted); } .spine .exit-success rect { stroke: var(--ok); stroke-width: 3; }\n.spine .node.by-human rect { fill: var(--surface); stroke: var(--ink); stroke-dasharray: none; }\n.spine .node.by-ai rect { fill: var(--ai-bg); stroke: var(--ai); stroke-dasharray: none; }\n.spine .node.by-agent rect { fill: var(--agent-bg); stroke: var(--agent); stroke-dasharray: none; } .spine .node.by-agent rect.inner { fill: none; stroke-width: 1; }\n.spine .node.by-ci rect { fill: var(--ci-bg); stroke: var(--ci); stroke-dasharray: none; }\n.spine .node.goal rect { fill: var(--ok-bg); stroke: var(--ok); stroke-width: 3.5; stroke-dasharray: none; }\n.spine .node.on-main rect { stroke-width: 3.5; }\n.spine .nmore { fill: var(--muted); font: 600 11px system-ui, sans-serif; }\n.legend .sw { display: inline-flex; align-items: center; gap: 6px; } .legend svg { flex: none; }\n.legend .sw-node rect { stroke-width: 1.6; }\n.legend .sw-human rect { fill: var(--surface); stroke: var(--ink); } .legend .sw-ai rect { fill: var(--ai-bg); stroke: var(--ai); } .legend .sw-agent rect { fill: var(--agent-bg); stroke: var(--agent); } .legend .sw-agent rect.inner { fill: none; stroke-width: 1; }\n.legend .sw-ci rect { fill: var(--ci-bg); stroke: var(--ci); } .legend .sw-goal rect { fill: var(--ok-bg); stroke: var(--ok); stroke-width: 3; } .legend .sw-server rect { fill: var(--server); stroke: var(--muted); stroke-dasharray: 4 2; }\n.legend .sw-screen rect { fill: var(--surface); stroke: var(--ink); } .legend .sw-subflow rect { fill: var(--surface); stroke: var(--accent); }\n.legend .sw-node.sw-fail rect { fill: var(--surface); stroke: var(--bad); stroke-width: 3; }\n.legend .sw-line path { fill: none; stroke-width: 3; } .legend .sw-main path { stroke: var(--accent); stroke-width: 3.5; } .legend .sw-fail path { stroke: var(--bad); stroke-dasharray: 6 3; } .legend .sw-route path { stroke: var(--muted); stroke-dasharray: 2 3; }\n.covers { display: grid; gap: 10px; } .covers .cv { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); padding: 10px 14px; } .covers ul { margin: 4px 0 0; padding-left: 20px; }\n.spine .node-unreachable rect { stroke: var(--bad); fill: none; }\n.spine .nname { fill: var(--ink); font: 600 14.5px system-ui, sans-serif; } .spine .nline { fill: var(--muted); font: 11.5px ui-monospace, Menlo, Consolas, monospace; } .spine .start { fill: var(--ink); }\n.spine a:focus-visible .node rect, .spine a:hover .node rect { stroke: var(--focus); stroke-width: 3; }\n.legend { display: flex; flex-wrap: wrap; gap: 4px 18px; margin: 10px 0 0; font-size: 14px; color: var(--muted); }\n.screens { display: grid; gap: 18px; }\n.screen { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); padding: 14px 16px 16px; scroll-margin-top: 16px; }\n.screen:target { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-bg); }\n.screen header { display: flex; align-items: center; gap: 10px; } .screen > p { margin: 4px 0 10px; }\n.wf { border: 1px dashed var(--line); border-radius: 8px; padding: 14px; display: grid; gap: 10px; background: var(--bg); max-width: 560px; }\n.wf-item { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; padding: 2px; border-radius: 4px; }\n.wf-cond { outline: 1.5px dashed var(--muted); outline-offset: 2px; } .wf-focus { outline: 2.5px solid var(--focus); outline-offset: 2px; }\n.wf-h { margin: 0; font-size: 17px; } .wf-t { margin: 0; color: var(--muted); }\n.wf-row { display: flex; flex-wrap: wrap; gap: 10px; }\n.wf-btn, .wf-link { font: inherit; border-radius: 6px; padding: 6px 14px; border: 1px solid var(--ink); background: var(--surface); color: var(--ink); }\n.wf-confirm { background: var(--ink); color: var(--bg); } .wf-link { border: 0; background: none; color: var(--accent); text-decoration: underline; padding: 0; }\n.wf button:disabled { opacity: .45; }\n.wf-list { margin: 0; padding-left: 20px; display: grid; gap: 2px; }\n.wf-status { color: var(--muted); font-style: italic; } .wf-alert { border: 1.5px solid var(--bad); border-radius: 6px; padding: 6px 10px; }\n.wf-field { display: grid; gap: 4px; } .wf-input { font: inherit; border: 1px solid var(--muted); border-radius: 6px; padding: 6px 10px; background: var(--surface); color: var(--ink); }\n.wf-unmapped { border: 1.5px solid var(--bad); padding: 6px 10px; }\n.chip { font: 11px ui-monospace, Menlo, Consolas, monospace; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; white-space: nowrap; }\ndetails { margin-top: 12px; } summary { cursor: pointer; color: var(--muted); }\ndetails.ax-wrap { margin-top: 10px; } pre.ax { margin: 8px 0 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; white-space: pre-wrap; overflow-wrap: anywhere; background: var(--bg); line-height: 1.55; }\ndl.guards { margin: 10px 0 0; display: grid; grid-template-columns: max-content 1fr; gap: 3px 14px; } dl.guards dt { font-weight: 600; } dl.guards dd { margin: 0; }\nul.checks { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; } ul.checks li { padding-left: 26px; position: relative; } ul.checks li::before { content: \"\u2713\"; position: absolute; left: 4px; color: var(--ok); font-weight: 700; } ul.checks li.fail::before { content: \"\u2717\"; color: var(--bad); }\nfooter { margin-top: 56px; color: var(--muted); font-size: 13px; }\n";
7
+ export declare const CSS = "\n:root { --bg:#fafaf9; --surface:#ffffff; --ink:#1c1917; --muted:#6b6560; --line:#d6d3d1; --accent:#1d4ed8; --accent-bg:#eef3ff; --ok:#15803d; --bad:#b91c1c; --server:#eeeeec; --focus:#1d4ed8; --ai:#7e22ce; --ai-bg:#f5edff; --agent:#c2410c; --agent-bg:#fff1e8; --ci:#0f766e; --ci-bg:#e6f6f3; --ok-bg:#eaf7ee; }\n@media (prefers-color-scheme: dark) { :root { --bg:#161513; --surface:#1f1d1b; --ink:#f2efec; --muted:#a8a29e; --line:#44403c; --accent:#8fb0ff; --accent-bg:#1c2438; --ok:#5fcf85; --bad:#f08080; --server:#2a2826; --focus:#8fb0ff; --ai:#c99bff; --ai-bg:#2a2135; --agent:#ff9a66; --agent-bg:#33241b; --ci:#5fd4c4; --ci-bg:#1a2e2b; --ok-bg:#16291d; } }\n* { box-sizing: border-box; }\nbody { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.55 system-ui, -apple-system, \"Segoe UI\", sans-serif; }\nmain { max-width: 1000px; margin: 0 auto; padding: 28px 16px 80px; }\nh1 { font-size: 30px; line-height: 1.2; margin: 6px 0 8px; } h2 { font-size: 21px; margin: 44px 0 12px; } h3 { font-size: 16px; margin: 0; }\ncode, pre, .mono { font-family: ui-monospace, \"SF Mono\", Menlo, Consolas, monospace; font-size: 13px; }\n.muted { color: var(--muted); } .label { margin: 0 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }\n.eyebrow { margin: 0; color: var(--muted); } .lede { font-size: 18px; max-width: 46em; margin: 0; }\n.tag { display: inline-block; padding: 1px 8px; border: 1px solid var(--line); border-radius: 99px; font-size: 12px; color: var(--muted); vertical-align: middle; }\n.scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }\ntable { border-collapse: collapse; width: 100%; } th, td { text-align: left; vertical-align: top; padding: 8px 12px; border-bottom: 1px solid var(--line); } th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); } tr:last-child td { border-bottom: 0; }\ntd ol { margin: 0; padding-left: 20px; }\n.ok { color: var(--ok); font-weight: 600; } .bad { color: var(--bad); font-weight: 600; }\n.story { margin-top: 28px; padding: 18px 22px; border: 1px solid var(--line); border-left: 5px solid var(--accent); border-radius: 10px; background: var(--surface); }\n.story h2 { margin: 0 0 6px; } .story .given { margin: 0 0 8px; } .story ol { margin: 0; padding-left: 26px; } .story li { margin: 5px 0; padding-left: 4px; } .story .result { margin: 10px 0 0; font-weight: 600; }\n.views input { margin-right: 8px; accent-color: var(--accent); } .views label { display: inline-block; margin: 0 0 10px; cursor: pointer; }\n.views .panel-full { display: none; } .views input:checked ~ .panel-main { display: none; } .views input:checked ~ .panel-full { display: block; }\nsvg.spine { display: block; width: 100%; height: auto; padding: 8px; background: var(--surface); margin: 0 auto; }\n.spine .edge { fill: none; stroke-width: 1.5; } .spine .edge-user { stroke: var(--muted); } .spine .edge-system { stroke: var(--muted); } .spine .edge-route { stroke: var(--muted); stroke-dasharray: 2 4; } .spine .edge-fail { stroke: var(--bad); stroke-dasharray: 7 4; } .spine .edge-unused { stroke: var(--line); }\n.spine .edge-main { stroke: var(--accent); stroke-width: 3.5; stroke-dasharray: none; }\n.spine .arrow { fill: var(--muted); } .spine .arrow-fail { fill: var(--bad); } .spine .arrow-main { fill: var(--accent); }\n.spine .elabel rect { fill: var(--surface); stroke: var(--line); } .spine .elabel text { fill: var(--ink); font: 13px system-ui, sans-serif; } .spine .elabel-fail text { fill: var(--bad); } .spine .elabel-main rect { stroke: var(--accent); }\n.spine .node rect { fill: var(--surface); stroke: var(--ink); stroke-width: 1.6; } .spine .node-server rect { fill: var(--server); stroke: var(--muted); stroke-dasharray: 5 3; }\n.spine .node-subflow rect { stroke: var(--accent); } .spine .node-subflow rect.inner { fill: none; stroke-width: 1; }\n.spine .on-main rect { stroke-width: 3; } .spine .node-server.on-main rect { stroke: var(--accent); }\n.spine .exit-never rect { stroke: var(--bad); stroke-width: 3; } .spine .exit-error rect { stroke-dasharray: 6 3; } .spine .exit-left rect { stroke-dasharray: 2 3; stroke: var(--muted); } .spine .exit-success rect { stroke: var(--ok); stroke-width: 3; }\n.spine .node.by-human rect { fill: var(--surface); stroke: var(--ink); stroke-dasharray: none; }\n.spine .node.by-ai rect { fill: var(--ai-bg); stroke: var(--ai); stroke-dasharray: none; }\n.spine .node.by-agent rect { fill: var(--agent-bg); stroke: var(--agent); stroke-dasharray: none; } .spine .node.by-agent rect.inner { fill: none; stroke-width: 1; }\n.spine .node.by-ci rect { fill: var(--ci-bg); stroke: var(--ci); stroke-dasharray: none; }\n.spine .node.goal rect { fill: var(--ok-bg); stroke: var(--ok); stroke-width: 3.5; stroke-dasharray: none; }\n.spine .node.on-main rect { stroke-width: 3.5; }\n.spine .nmore { fill: var(--muted); font: 600 11px system-ui, sans-serif; }\n.legend .sw { display: inline-flex; align-items: center; gap: 6px; } .legend svg { flex: none; }\n.legend .sw-node rect { stroke-width: 1.6; }\n.legend .sw-human rect { fill: var(--surface); stroke: var(--ink); } .legend .sw-ai rect { fill: var(--ai-bg); stroke: var(--ai); } .legend .sw-agent rect { fill: var(--agent-bg); stroke: var(--agent); } .legend .sw-agent rect.inner { fill: none; stroke-width: 1; }\n.legend .sw-ci rect { fill: var(--ci-bg); stroke: var(--ci); } .legend .sw-goal rect { fill: var(--ok-bg); stroke: var(--ok); stroke-width: 3; } .legend .sw-server rect { fill: var(--server); stroke: var(--muted); stroke-dasharray: 4 2; }\n.legend .sw-screen rect { fill: var(--surface); stroke: var(--ink); } .legend .sw-subflow rect { fill: var(--surface); stroke: var(--accent); }\n.legend .sw-node.sw-fail rect { fill: var(--surface); stroke: var(--bad); stroke-width: 3; }\n.legend .sw-line path { fill: none; stroke-width: 3; } .legend .sw-main path { stroke: var(--accent); stroke-width: 3.5; } .legend .sw-fail path { stroke: var(--bad); stroke-dasharray: 6 3; } .legend .sw-route path { stroke: var(--muted); stroke-dasharray: 2 3; }\n.covers { display: grid; gap: 10px; } .covers .cv { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); padding: 10px 14px; } .covers ul { margin: 4px 0 0; padding-left: 20px; }\n.spine .node-unreachable rect { stroke: var(--bad); fill: none; }\n.spine .nname { fill: var(--ink); font: 600 14.5px system-ui, sans-serif; } .spine .nline { fill: var(--muted); font: 11.5px ui-monospace, Menlo, Consolas, monospace; } .spine .start { fill: var(--ink); }\n.spine a:focus-visible .node rect, .spine a:hover .node rect { stroke: var(--focus); stroke-width: 3; }\n.legend { display: flex; flex-wrap: wrap; gap: 4px 18px; margin: 10px 0 0; font-size: 14px; color: var(--muted); }\n.screens { display: grid; gap: 18px; }\n.screen { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); padding: 14px 16px 16px; scroll-margin-top: 16px; }\n.screen:target { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-bg); }\n.screen header { display: flex; align-items: center; gap: 10px; } .screen > p { margin: 4px 0 10px; }\n.wf { border: 1px dashed var(--line); border-radius: 8px; padding: 14px; display: grid; gap: 10px; background: var(--bg); max-width: 560px; }\n.wf-item { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; padding: 2px; border-radius: 4px; }\n.wf-cond { outline: 1.5px dashed var(--muted); outline-offset: 2px; } .wf-focus { outline: 2.5px solid var(--focus); outline-offset: 2px; }\n.wf-h { margin: 0; font-size: 17px; } .wf-t { margin: 0; color: var(--muted); }\n.wf-row { display: flex; flex-wrap: wrap; gap: 10px; }\n.wf-btn, .wf-link { font: inherit; border-radius: 6px; padding: 6px 14px; border: 1px solid var(--ink); background: var(--surface); color: var(--ink); }\n.wf-confirm { background: var(--ink); color: var(--bg); } .wf-link { border: 0; background: none; color: var(--accent); text-decoration: underline; padding: 0; }\n.wf button:disabled { opacity: .45; }\n.wf-list { margin: 0; padding-left: 20px; display: grid; gap: 2px; }\n.wf-status { color: var(--muted); font-style: italic; } .wf-alert { border: 1.5px solid var(--bad); border-radius: 6px; padding: 6px 10px; }\n.wf-check { display: flex; gap: 8px; align-items: center; } .wf-field { display: grid; gap: 4px; } .wf-input { font: inherit; border: 1px solid var(--muted); border-radius: 6px; padding: 6px 10px; background: var(--surface); color: var(--ink); }\n.wf-unmapped { border: 1.5px solid var(--bad); padding: 6px 10px; }\n.chip { font: 11px ui-monospace, Menlo, Consolas, monospace; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; white-space: nowrap; }\ndetails { margin-top: 12px; } summary { cursor: pointer; color: var(--muted); }\ndetails.ax-wrap { margin-top: 10px; } pre.ax { margin: 8px 0 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; white-space: pre-wrap; overflow-wrap: anywhere; background: var(--bg); line-height: 1.55; }\ndl.guards { margin: 10px 0 0; display: grid; grid-template-columns: max-content 1fr; gap: 3px 14px; } dl.guards dt { font-weight: 600; } dl.guards dd { margin: 0; }\nul.checks { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; } ul.checks li { padding-left: 26px; position: relative; } ul.checks li::before { content: \"\u2713\"; position: absolute; left: 4px; color: var(--ok); font-weight: 700; } ul.checks li.fail::before { content: \"\u2717\"; color: var(--bad); }\nfooter { margin-top: 56px; color: var(--muted); font-size: 13px; }\n";
8
8
  export interface PageInput {
9
9
  g: Graph;
10
10
  m: Model;
package/dist/html.js CHANGED
@@ -67,7 +67,7 @@ svg.spine { display: block; width: 100%; height: auto; padding: 8px; background:
67
67
  .wf button:disabled { opacity: .45; }
68
68
  .wf-list { margin: 0; padding-left: 20px; display: grid; gap: 2px; }
69
69
  .wf-status { color: var(--muted); font-style: italic; } .wf-alert { border: 1.5px solid var(--bad); border-radius: 6px; padding: 6px 10px; }
70
- .wf-field { display: grid; gap: 4px; } .wf-input { font: inherit; border: 1px solid var(--muted); border-radius: 6px; padding: 6px 10px; background: var(--surface); color: var(--ink); }
70
+ .wf-check { display: flex; gap: 8px; align-items: center; } .wf-field { display: grid; gap: 4px; } .wf-input { font: inherit; border: 1px solid var(--muted); border-radius: 6px; padding: 6px 10px; background: var(--surface); color: var(--ink); }
71
71
  .wf-unmapped { border: 1.5px solid var(--bad); padding: 6px 10px; }
72
72
  .chip { font: 11px ui-monospace, Menlo, Consolas, monospace; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; white-space: nowrap; }
73
73
  details { margin-top: 12px; } summary { cursor: pointer; color: var(--muted); }
@@ -0,0 +1,10 @@
1
+ import type { Domain } from './changes.ts';
2
+ import type { Graph } from './graph.ts';
3
+ export interface InvokeProblem {
4
+ rule: 'invoke-unknown' | 'refusal-unknown';
5
+ path: string[];
6
+ message: string;
7
+ element: string;
8
+ }
9
+ export declare const TRANSPORT_CODES: readonly string[];
10
+ export declare function checkInvokes(g: Graph, domainOf?: () => Domain | null): InvokeProblem[];
@@ -0,0 +1,67 @@
1
+ // What a flow invokes, held to its domain (SPEC.md §2, §5): `invoke: { action }` names an action of the domain the flow
2
+ // names, and for a state that invokes an action, `failures.<state>.from` does too and each class under it lists
3
+ // refusals of that action. A state that invokes an `external` or a `flow` is not held to the domain. The domain is looked
4
+ // up by id among the graphs beside the flow, all its files read as one, as the `changes` rule finds it. A class may also
5
+ // list a transport code, a failure that is no answer of the action's own (SPEC.md §5). Each finding is an error, which
6
+ // fails --strict (decided on 16 Nov 2026, d-1116-10).
7
+ import { flowDomain } from './changes.js';
8
+ // the key that names a class's action in `failures.<state>`; every other key is a class
9
+ const FROM = 'from';
10
+ // the codes a failure class may list though its action has no such refusal (SPEC.md §5): no answer came back, none came
11
+ // in time, or the server failed with a status the action does not list
12
+ export const TRANSPORT_CODES = ['network', 'timeout', '5xx'];
13
+ // `domainOf` finds the flow's domain, as for checkChanges
14
+ export function checkInvokes(g, domainOf = () => flowDomain(g)) {
15
+ const invoked = Object.entries(g.flow.states).filter(([, st]) => typeof st.invoke?.action === 'string');
16
+ if (g.flow.domain === undefined || invoked.length === 0)
17
+ return [];
18
+ const failures = (g.flow.failures ?? {});
19
+ const domain = domainOf();
20
+ if (domain === null) {
21
+ return [
22
+ {
23
+ rule: 'invoke-unknown',
24
+ path: ['domain'],
25
+ element: 'domain',
26
+ message: `the flow names the domain ${g.flow.domain}, which no domain beside it is (under the nearest folder called graphs), so what its steps invoke is not checked (SPEC.md §5)`,
27
+ },
28
+ ];
29
+ }
30
+ const actions = domain.actions ?? {};
31
+ const has = (name) => Object.hasOwn(actions, name);
32
+ const out = [];
33
+ for (const [state, st] of invoked) {
34
+ const action = st.invoke?.action;
35
+ if (has(action))
36
+ continue;
37
+ out.push({ rule: 'invoke-unknown', path: ['states', state, 'invoke', 'action'], element: `states/${state}/invoke`, message: `state ${state} invokes ${action}, which is not an action of the domain ${g.flow.domain} (SPEC.md §5)` });
38
+ }
39
+ for (const [state, classes] of Object.entries(failures)) {
40
+ const action = g.flow.states[state]?.invoke?.action;
41
+ if (classes === null || typeof classes !== 'object' || typeof action !== 'string')
42
+ continue;
43
+ const named = typeof classes[FROM] === 'string' ? classes[FROM] : action;
44
+ if (!has(named)) {
45
+ // an action the state's own invoke names is reported there
46
+ if (named !== action)
47
+ out.push({ rule: 'invoke-unknown', path: ['failures', state, FROM], element: `failures/${state}/from`, message: `failures.${state} comes from ${named}, which is not an action of the domain ${g.flow.domain} (SPEC.md §2, §5)` });
48
+ continue;
49
+ }
50
+ const refusals = actions[named]?.refusals ?? {};
51
+ for (const [cls, codes] of Object.entries(classes)) {
52
+ if (cls === FROM || !Array.isArray(codes))
53
+ continue;
54
+ codes.forEach((code, i) => {
55
+ if (typeof code !== 'string' || Object.hasOwn(refusals, code) || TRANSPORT_CODES.includes(code))
56
+ return;
57
+ out.push({
58
+ rule: 'refusal-unknown',
59
+ path: ['failures', state, cls, String(i)],
60
+ element: `failures/${state}/${cls}/${code}`,
61
+ message: `FAIL.${cls} of ${state} stands for ${code}, which is not a refusal of ${named} in the domain ${g.flow.domain}, nor network, timeout or 5xx (SPEC.md §2, §5)`,
62
+ });
63
+ });
64
+ }
65
+ }
66
+ return out;
67
+ }
package/dist/kit.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  export declare class KitError extends Error {
2
2
  }
3
3
  declare const SLOTS: readonly ['text', 'name', 'id', 'intent', 'children'];
4
- declare const FLAGS: readonly ['disabled', 'named', 'conditional'];
4
+ declare const FLAGS: readonly ['disabled', 'named', 'conditional', 'checked'];
5
5
  type Slot = (typeof SLOTS)[number];
6
6
  type Flag = (typeof FLAGS)[number];
7
7
  type Part = {
@@ -43,6 +43,7 @@ export interface Fill {
43
43
  disabled: boolean;
44
44
  named: boolean;
45
45
  conditional: boolean;
46
+ checked: boolean;
46
47
  }
47
48
  export declare function drawWith(kit: Kit, component: string, f: Fill, warn: (m: string) => void): string | null;
48
49
  export declare function mark(html: string, id: string, chips: string): string;
package/dist/kit.js CHANGED
@@ -9,7 +9,7 @@ export class KitError extends Error {
9
9
  }
10
10
  const esc = (s) => s.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
11
11
  const SLOTS = ['text', 'name', 'id', 'intent', 'children'];
12
- const FLAGS = ['disabled', 'named', 'conditional'];
12
+ const FLAGS = ['disabled', 'named', 'conditional', 'checked'];
13
13
  // Lists are drawn without a wrapper around each item, so their templates must be one element the renderer can mark.
14
14
  const SINGLE = new Set(['List', 'ListItem']);
15
15
  const VOID = new Set(['area', 'br', 'col', 'hr', 'img', 'input', 'source', 'track', 'wbr']);
package/dist/model.d.ts CHANGED
@@ -1,6 +1,8 @@
1
- import type { Flow, Scalar } from './graph.ts';
1
+ import type { ErrorPlace, Flow, Scalar } from './graph.ts';
2
2
  import type { Value } from './expr.ts';
3
3
  export declare class ModelError extends Error {
4
+ readonly place: ErrorPlace | undefined;
5
+ constructor(message: string, place?: ErrorPlace);
4
6
  }
5
7
  export interface Step {
6
8
  event: string | null;
@@ -44,6 +46,12 @@ export declare class Model {
44
46
  private apply;
45
47
  private waysOf;
46
48
  steps(state: string, ctx: Scalar[]): Step[];
49
+ /**
50
+ * `err`, thrown by `steps(state, ctx)`, given the place in flow.yaml of the transition that threw it when it has
51
+ * none: the ways are tried again as `steps` tries them, and the one whose guard or effect throws is the place; else
52
+ * the state. Read only once a step has thrown, so the exploration itself pays nothing for it.
53
+ */
54
+ placeError<E>(err: E, state: string, ctx: Scalar[]): E;
47
55
  initials(): Scalar[][];
48
56
  scenario(ctx: Scalar[]): Record<string, Scalar>;
49
57
  }
@@ -74,3 +82,25 @@ export interface FinalPath extends PathResult {
74
82
  index: number;
75
83
  }
76
84
  export declare function finalPaths(m: Model, ex: Exploration): FinalPath[];
85
+ export interface CoverPath {
86
+ id: string;
87
+ start: Record<string, Scalar>;
88
+ events: string[];
89
+ states: string[];
90
+ transitions: string[];
91
+ covers: string[];
92
+ }
93
+ export interface Cover {
94
+ by: 'states' | 'transitions';
95
+ paths: CoverPath[];
96
+ unreached: string[];
97
+ }
98
+ export declare function transitionsOf(flow: Flow): string[];
99
+ /**
100
+ * Event paths that together pass every reachable state (`states`) or take every reachable transition (`transitions`)
101
+ * of the flow (#4), from the same starts and through the same steps as `explore(m, from, keep)`. Each is a shortest
102
+ * way to the state or transition it is first kept for, so it repeats a state only on the way to something not yet
103
+ * covered. The longest are kept first and a path that covers nothing new is left out: a small set, never every path.
104
+ * The same flow gives the same paths, in the same order, with the same ids.
105
+ */
106
+ export declare function cover(m: Model, by: 'states' | 'transitions', from?: Scalar[][], keep?: (at: Config, s: Step) => boolean): Cover;