feat(ui): build workflows on the canvas: step palette, schema-driven settings forms, references to earlier results, reorder and remove

This commit is contained in:
sam committed 2026-10-05 00:44:22 +11:00
1 parent 3072ba595f
commit e46eeb67dd
9 files changed
+564 -132

No files matched your search

+1 -1
View File
@@ -37,7 +37,7 @@ function duration(ms?: number): string {
<template>
<div
class="w-60 rounded-lg border bg-card px-3 py-2 text-left shadow-sm"
:class="[stateClass, data.run ? '' : data.kind === 'step' && 'opacity-90']"
:class="[stateClass, data.selected && 'ring-2 ring-ring', data.kind === 'step' && 'cursor-pointer']"
>
<Handle v-if="data.kind !== 'start'" type="target" :position="Position.Top" />
<Handle id="data-in" type="target" :position="Position.Right" class="!opacity-0" />
+276
View File
@@ -0,0 +1,276 @@
<script setup lang="ts">
import { computed, ref, watch } from "vue";
import { ArrowDown, ArrowUp, Link2, Plus, Trash2, X } from "@lucide/vue";
import { parse, stringify } from "yaml";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { Textarea } from "@/components/ui/textarea";
import { stepTitle } from "./workflow-graph";
import {
deleteStep,
earlierStepIDs,
insertStep,
moveStep,
replaceStep,
stepAt,
type StepPath,
type StepRecord,
} from "./workflow-edit";
import { settingsProblem, type SettingsSchema, type StepTypeInfo } from "./workflow-yaml";
const props = defineProps<{ yaml: string; path: StepPath | null; vocabulary: StepTypeInfo[] }>();
const emit = defineEmits<{ "update:yaml": [string]; select: [StepPath | null] }>();
const step = computed(() => (props.path ? stepAt(props.yaml, props.path) : undefined));
const type = computed(() => (typeof step.value?.type === "string" ? step.value.type : ""));
const info = computed(() => props.vocabulary.find((candidate) => candidate.name === type.value));
const settings = computed<Record<string, unknown>>(() =>
typeof step.value?.settings === "object" && step.value.settings !== null
? (step.value.settings as Record<string, unknown>)
: {},
);
// The schema's keys arrive sorted; the setting that says what a step does
// comes first.
const LEAD = ["mission", "workflow", "message", "body", "plan", "then", "status", "detail", "run", "rules"];
const fields = computed(() =>
Object.entries(info.value?.settings?.properties ?? {}).sort(([a], [b]) => {
const rank = (key: string) => (LEAD.includes(key) ? LEAD.indexOf(key) : LEAD.length);
return rank(a) - rank(b);
}),
);
const earlier = computed(() => (props.path ? earlierStepIDs(props.yaml, props.path) : []));
const inBranch = computed(() => (props.path?.length ?? 0) > 2);
const problem = computed(() =>
info.value?.settings && step.value?.settings ? settingsProblem(step.value.settings, info.value.settings, "settings") : "",
);
// The palette is open while nothing is selected; selecting a step, including
// the one just added, folds it away so that step's form is what shows.
const paletteOpen = ref(true);
watch(() => JSON.stringify(props.path), () => (paletteOpen.value = !props.path), { immediate: true });
const groups = computed(() => {
const byGroup = new Map<string, StepTypeInfo[]>();
for (const candidate of props.vocabulary) {
const group = candidate.name.split(".")[0];
byGroup.set(group, [...(byGroup.get(group) ?? []), candidate]);
}
return [...byGroup.entries()];
});
function write(next: StepRecord): void {
// id and type lead, the way a step is read.
const { id, type: stepType, ...rest } = next;
if (props.path) emit("update:yaml", replaceStep(props.yaml, props.path, { id, type: stepType, ...rest }));
}
function setField(key: string, value: unknown): void {
write({ ...step.value, [key]: value });
}
function setSetting(key: string, value: unknown): void {
write({ ...step.value, settings: { ...settings.value, [key]: value } });
}
function add(stepType: string): void {
const after = props.path && props.path.length === 2 ? Number(props.path[1]) : Number.MAX_SAFE_INTEGER;
const inserted = insertStep(props.yaml, after, stepType);
emit("update:yaml", inserted.source);
emit("select", inserted.path);
}
function move(delta: -1 | 1): void {
if (!props.path) return;
const moved = moveStep(props.yaml, props.path, delta);
emit("update:yaml", moved.source);
emit("select", moved.path);
}
function remove(): void {
if (!props.path) return;
emit("update:yaml", deleteStep(props.yaml, props.path));
emit("select", null);
}
// A reference is inserted into the text field last focused, which is how a
// later step is connected to an earlier step's result.
const focused = ref<string | null>(null);
function reference(id: string, field: "summary" | "result"): void {
const key = focused.value ?? fields.value.find(([, schema]) => schema.type === "string")?.[0];
if (!key) return;
const current = typeof settings.value[key] === "string" ? (settings.value[key] as string) : "";
const token = field === "summary" ? `{{ steps.${id}.summary }}` : `{{ steps.${id}.result }}`;
setSetting(key, current ? `${current.trimEnd()} ${token}` : token);
}
const longText = /mission|body|detail|plan|rules/;
function kindOf(key: string, schema: SettingsSchema): "select" | "text" | "line" | "boolean" | "number" | "lines" | "yaml" {
if (schema.type === "string") return schema.enum ? "select" : longText.test(key) ? "text" : "line";
if (schema.type === "boolean") return "boolean";
if (schema.type === "integer" || schema.type === "number") return "number";
if (schema.type === "array" && schema.items?.type === "string") return "lines";
return "yaml";
}
const yamlErrors = ref<Record<string, string>>({});
function setYamlSetting(key: string, text: string): void {
try {
setSetting(key, text.trim() ? parse(text) : undefined);
yamlErrors.value = { ...yamlErrors.value, [key]: "" };
} catch (error) {
yamlErrors.value = { ...yamlErrors.value, [key]: String((error as Error).message).split("\n")[0] };
}
}
function asYaml(value: unknown): string {
return value === undefined ? "" : stringify(value).trimEnd();
}
function label(key: string, schema: SettingsSchema): string {
return schema.title ?? key.replaceAll("_", " ").replace(/^./, (c) => c.toUpperCase());
}
</script>
<template>
<aside class="flex h-[560px] flex-col gap-3 overflow-y-auto rounded-lg border border-border bg-card p-3 text-sm">
<template v-if="step && path">
<div class="flex items-start gap-2">
<div class="min-w-0">
<div class="truncate font-medium">{{ stepTitle(type) }}</div>
<div class="font-mono text-[11px] text-fg-subtle">{{ type }}</div>
</div>
<Button type="button" variant="ghost" size="icon" class="ml-auto size-7" aria-label="Close" @click="emit('select', null)"><X /></Button>
</div>
<p v-if="problem" class="rounded bg-danger/10 px-2 py-1 text-xs text-danger" role="alert">{{ problem }}</p>
<label class="flex flex-col gap-1">
<span class="text-xs text-muted-foreground">Step id</span>
<Input
:model-value="(step.id as string) ?? ''"
class="h-8 font-mono"
placeholder="name it so later steps can use its result"
@update:model-value="setField('id', String($event))"
/>
</label>
<template v-for="[key, schema] in fields" :key="key">
<label v-if="kindOf(key, schema) === 'boolean'" class="flex items-start gap-2" :title="schema.description">
<input type="checkbox" class="mt-0.5" :checked="settings[key] === true" @change="setSetting(key, ($event.target as HTMLInputElement).checked || undefined)" />
<span>{{ label(key, schema) }}<span v-if="schema.description" class="block text-xs text-fg-subtle">{{ schema.description }}</span></span>
</label>
<label v-else class="flex flex-col gap-1">
<span class="text-xs text-muted-foreground">{{ label(key, schema) }}</span>
<select
v-if="kindOf(key, schema) === 'select'"
class="h-8 rounded-md border border-input bg-background px-2"
:value="(settings[key] as string) ?? ''"
@change="setSetting(key, ($event.target as HTMLSelectElement).value || undefined)"
>
<option value="">(default)</option>
<option v-for="option in schema.enum" :key="option" :value="option">{{ option }}</option>
</select>
<Textarea
v-else-if="kindOf(key, schema) === 'text'"
:model-value="(settings[key] as string) ?? ''"
class="min-h-28 font-mono text-xs"
@focus="focused = key"
@update:model-value="setSetting(key, String($event))"
/>
<Input
v-else-if="kindOf(key, schema) === 'line'"
:model-value="(settings[key] as string) ?? ''"
class="h-8"
@focus="focused = key"
@update:model-value="setSetting(key, String($event))"
/>
<Input
v-else-if="kindOf(key, schema) === 'number'"
type="number"
:model-value="(settings[key] as number) ?? ''"
class="h-8"
@update:model-value="setSetting(key, $event === '' ? undefined : Number($event))"
/>
<Textarea
v-else-if="kindOf(key, schema) === 'lines'"
:model-value="Array.isArray(settings[key]) ? (settings[key] as string[]).join('\n') : ''"
class="min-h-16 font-mono text-xs"
placeholder="one per line"
@update:model-value="setSetting(key, String($event).split('\n').filter(Boolean))"
/>
<template v-else>
<Textarea
:model-value="asYaml(settings[key])"
class="min-h-24 font-mono text-xs"
placeholder="YAML"
@change="setYamlSetting(key, ($event.target as HTMLTextAreaElement).value)"
/>
<span v-if="yamlErrors[key]" class="text-xs text-danger">{{ yamlErrors[key] }}</span>
</template>
<span v-if="schema.description" class="text-xs text-fg-subtle">{{ schema.description }}</span>
</label>
</template>
<div v-if="earlier.length && fields.some(([, schema]) => schema.type === 'string')" class="space-y-1">
<span class="flex items-center gap-1 text-xs text-muted-foreground"><Link2 class="size-3" aria-hidden="true" />Use an earlier step's result</span>
<div class="flex flex-wrap gap-1">
<template v-for="id in earlier" :key="id">
<button type="button" class="rounded bg-secondary px-1.5 py-0.5 font-mono text-[11px] hover:bg-secondary/70" @click="reference(id, 'summary')">{{ id }}.summary</button>
<button type="button" class="rounded bg-secondary px-1.5 py-0.5 font-mono text-[11px] hover:bg-secondary/70" @click="reference(id, 'result')">{{ id }}.result</button>
</template>
</div>
</div>
<details class="space-y-2">
<summary class="cursor-pointer text-xs text-muted-foreground">When, failure and retry</summary>
<label class="mt-2 flex flex-col gap-1">
<span class="text-xs text-muted-foreground">Run only when</span>
<Input :model-value="(step.when as string) ?? ''" class="h-8 font-mono" placeholder="steps.assess.result.fit" @update:model-value="setField('when', String($event))" />
</label>
<label class="flex flex-col gap-1">
<span class="text-xs text-muted-foreground">If it fails</span>
<select class="h-8 rounded-md border border-input bg-background px-2" :value="(step.on_failure as string) ?? ''" @change="setField('on_failure', ($event.target as HTMLSelectElement).value || undefined)">
<option value="">Park the task</option>
<option value="continue">Continue to the next step</option>
</select>
</label>
<label class="flex flex-col gap-1">
<span class="text-xs text-muted-foreground">Attempts</span>
<Input
type="number"
min="1"
max="10"
:model-value="((step.retry as { attempts?: number } | undefined)?.attempts) ?? ''"
class="h-8"
@update:model-value="setField('retry', $event === '' ? undefined : { ...(step.retry as object), attempts: Number($event) })"
/>
</label>
</details>
<div class="mt-auto flex flex-wrap gap-1.5 border-t border-border pt-3">
<Button type="button" variant="outline" size="sm" @click="move(-1)"><ArrowUp /> Up</Button>
<Button type="button" variant="outline" size="sm" @click="move(1)"><ArrowDown /> Down</Button>
<Button type="button" variant="ghost" size="sm" class="ml-auto text-danger" @click="remove"><Trash2 /> Remove</Button>
</div>
</template>
<div v-else class="text-xs text-fg-subtle">Select a step to edit it.</div>
<details
v-if="!inBranch"
:open="paletteOpen"
class="space-y-2 border-t border-border pt-3"
@toggle="paletteOpen = ($event.target as HTMLDetailsElement).open"
>
<summary class="cursor-pointer text-xs font-medium">{{ step ? "Add a step after this one" : "Add a step" }}</summary>
<div v-for="[group, members] in groups" :key="group" class="space-y-1">
<div class="text-[11px] tracking-wide text-fg-subtle uppercase">{{ group }}</div>
<div class="flex flex-wrap gap-1">
<button
v-for="candidate in members"
:key="candidate.name"
type="button"
class="flex items-center gap-1 rounded border border-border px-1.5 py-0.5 text-xs hover:bg-secondary"
:title="candidate.name"
@click="add(candidate.name)"
>
<Plus class="size-3" aria-hidden="true" />{{ stepTitle(candidate.name) }}
</button>
</div>
</div>
</details>
</aside>
</template>
+12 -3
View File
@@ -9,13 +9,21 @@ import "@vue-flow/controls/dist/style.css";
import StepNode from "./StepNode.vue";
import { withRuns, workflowGraph, type StageRun } from "./workflow-graph";
const props = defineProps<{ yaml: string; stages?: StageRun[] }>();
const props = defineProps<{ yaml: string; stages?: StageRun[]; selected?: (string | number)[] | null }>();
const emit = defineEmits<{ select: [(string | number)[] | null] }>();
const NODE_WIDTH = 240;
const container = ref<HTMLElement | null>(null);
const graph = computed(() => withRuns(workflowGraph(props.yaml), props.stages ?? []));
const nodes = computed(() => graph.value.nodes);
const selectedKey = computed(() => JSON.stringify(props.selected ?? null));
const nodes = computed(() =>
graph.value.nodes.map((node) =>
JSON.stringify(node.data.path ?? null) === selectedKey.value && props.selected
? { ...node, data: { ...node.data, selected: true } }
: node,
),
);
const edges = computed(() =>
graph.value.edges.map(({ label, offset, ...edge }) => ({
...edge,
@@ -50,7 +58,6 @@ watch(() => nodes.value.filter((node) => node.data.run).length, () => place());
<template>
<div ref="container" class="workflow-canvas h-[560px] overflow-hidden rounded-lg border border-border bg-background">
<VueFlow
:key="yaml"
class="h-full"
:nodes="nodes"
:edges="edges"
@@ -61,6 +68,8 @@ watch(() => nodes.value.filter((node) => node.data.run).length, () => place());
:max-zoom="1.5"
pan-on-scroll
@pane-ready="place"
@node-click="({ node }) => emit('select', node.data.path ?? null)"
@pane-click="emit('select', null)"
>
<template #node-step="nodeProps">
<StepNode v-bind="nodeProps" />
+9 -2
View File
@@ -8,7 +8,9 @@ import { Label } from "@/components/ui/label";
import { Spinner } from "@/components/ui/spinner";
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
import { Textarea } from "@/components/ui/textarea";
import StepPanel from "./StepPanel.vue";
import WorkflowCanvas from "./WorkflowCanvas.vue";
import type { StepPath } from "./workflow-edit";
import { useWorkflowRuns } from "./workflow-runs";
import {
cloneControlPlaneValue,
@@ -38,6 +40,7 @@ const shipped = computed<WorkflowDefinitionCollection>(() =>
const selected = defineModel<string>("selected", { required: true });
const id = ref("");
const yaml = ref("");
const selectedStep = ref<StepPath | null>(null);
const localError = ref("");
const { runs, watched, stages, pick } = useWorkflowRuns(selected);
@@ -51,7 +54,8 @@ function load(value: string): void {
(candidate) => candidate.id === value,
);
id.value = entry?.id ?? value;
yaml.value = entry?.yaml ?? `id: ${value}\nsteps:\n - type: `;
yaml.value = entry?.yaml ?? `id: ${value}\nsteps: []\n`;
selectedStep.value = null;
localError.value = "";
}
@@ -157,7 +161,10 @@ function syncScroll(event: Event): void {
</select>
<span v-if="!runs.length" class="text-xs text-fg-subtle">This workflow has not run yet.</span>
</label>
<WorkflowCanvas :yaml="yaml" :stages="stages" />
<div class="grid gap-3 lg:grid-cols-[1fr_20rem]">
<WorkflowCanvas :yaml="yaml" :stages="stages" :selected="selectedStep" @select="selectedStep = $event" />
<StepPanel v-model:yaml="yaml" :path="selectedStep" :vocabulary="vocabulary" @select="selectedStep = $event" />
</div>
</TabsContent>
<TabsContent value="yaml">
<!--
+107
View File
@@ -0,0 +1,107 @@
import { isMap, isSeq, parseDocument } from "yaml";
/**
* Canvas edits as edits to the workflow's YAML document. The text stays the
* one source of truth, so the canvas and the YAML tab cannot disagree, and
* comments and layout the operator wrote survive an edit made on the canvas.
*/
/** Where a step lives in the document: ["steps", 2], or
* ["steps", 1, "parallel", "docs", 0] for a step inside a branch. */
export type StepPath = (string | number)[];
export type StepRecord = Record<string, unknown>;
/** A step as plain data, or undefined when the path names none. */
export function stepAt(source: string, path: StepPath): StepRecord | undefined {
const node = parseDocument(source).getIn(path, true);
if (!isMap(node)) return undefined;
return node.toJSON() as StepRecord;
}
/** Replaces one step with a new value. Unset keys are dropped, so a cleared
* field leaves no empty key behind. */
export function replaceStep(source: string, path: StepPath, step: StepRecord): string {
const document = parseDocument(source);
document.setIn(path, document.createNode(prune(step)));
return document.toString();
}
/** Inserts a new step of the given type after the top-level step at index
* (-1 inserts first; past the end appends). Returns the new source and the
* inserted step's path. */
export function insertStep(source: string, after: number, type: string): { source: string; path: StepPath } {
const document = parseDocument(source);
let steps = document.get("steps", true);
if (!isSeq(steps)) {
document.set("steps", document.createNode([]));
steps = document.get("steps", true);
}
if (!isSeq(steps)) return { source, path: [] };
const index = Math.min(Math.max(after + 1, 0), steps.items.length);
steps.items.splice(index, 0, document.createNode({ type }));
return { source: document.toString(), path: ["steps", index] };
}
/** Removes a step. A branch left empty is removed with it. */
export function deleteStep(source: string, path: StepPath): string {
const document = parseDocument(source);
document.deleteIn(path);
const branch = path.slice(0, -1);
if (branch.length > 2) {
const remaining = document.getIn(branch, true);
if (isSeq(remaining) && remaining.items.length === 0) document.deleteIn(branch);
}
return document.toString();
}
/** Moves a step one place up (-1) or down (+1) within its own list. Returns
* the new source and the step's new path. */
export function moveStep(source: string, path: StepPath, delta: -1 | 1): { source: string; path: StepPath } {
const document = parseDocument(source);
const list = document.getIn(path.slice(0, -1), true);
const index = path.at(-1);
if (!isSeq(list) || typeof index !== "number") return { source, path };
const target = index + delta;
if (target < 0 || target >= list.items.length) return { source, path };
const [item] = list.items.splice(index, 1);
list.items.splice(target, 0, item);
return { source: document.toString(), path: [...path.slice(0, -1), target] };
}
/** The ids every step before the given one declares, which are the steps its
* settings may reference. Inside a branch, sibling branches are not visible. */
export function earlierStepIDs(source: string, path: StepPath): string[] {
const value = parseDocument(source).toJS() as { steps?: unknown[] } | null;
const steps = Array.isArray(value?.steps) ? value.steps : [];
const top = typeof path[1] === "number" ? path[1] : steps.length;
const ids: string[] = [];
const collect = (step: unknown) => {
if (typeof step !== "object" || step === null) return;
const record = step as StepRecord;
if (typeof record.id === "string") ids.push(record.id);
if (typeof record.parallel === "object" && record.parallel !== null)
for (const branch of Object.values(record.parallel as Record<string, unknown[]>))
if (Array.isArray(branch)) branch.forEach(collect);
};
steps.slice(0, top).forEach(collect);
if (path.length === 5) {
const branch = (steps[top] as StepRecord | undefined)?.parallel as Record<string, unknown[]> | undefined;
const own = branch?.[path[3] as string];
if (Array.isArray(own)) own.slice(0, path[4] as number).forEach(collect);
}
return ids;
}
function prune(value: unknown): unknown {
if (Array.isArray(value)) return value.map(prune);
if (typeof value !== "object" || value === null) return value;
const out: Record<string, unknown> = {};
for (const [key, child] of Object.entries(value)) {
if (child === undefined || child === "" || child === null) continue;
const pruned = prune(child);
if (typeof pruned === "object" && pruned !== null && !Array.isArray(pruned) && Object.keys(pruned).length === 0) continue;
out[key] = pruned;
}
return out;
}
+7 -2
View File
@@ -22,6 +22,9 @@ export interface StepNodeData {
stage?: string;
occurrence?: number;
run?: StageRun;
/** Where the step lives in the YAML document, for editing it. */
path?: (string | number)[];
selected?: boolean;
}
/** One recorded run of a step, from the task's attempts view. */
@@ -167,6 +170,7 @@ export function workflowGraph(source: string): WorkflowGraph {
y: number,
branch?: string,
recorded?: { stage: string; occurrence: number },
path?: (string | number)[],
): string => {
const record = isMapping(step) ? step : {};
const type = typeof record.type === "string" ? record.type : "";
@@ -187,6 +191,7 @@ export function workflowGraph(source: string): WorkflowGraph {
retry: isMapping(record.retry) && typeof record.retry.attempts === "number" ? record.retry.attempts : undefined,
continues: record.on_failure === "continue",
branch,
path,
...(recorded ?? { stage: stepID || type, occurrence: occurrenceOf(stepID || type) }),
},
});
@@ -210,7 +215,7 @@ export function workflowGraph(source: string): WorkflowGraph {
const x = (column - (branches.length - 1) / 2) * COLUMN;
let tail = previous;
(Array.isArray(branchSteps) ? branchSteps : []).forEach((branchStep, j) => {
const id = addStep(branchStep, `${i + 1}-${name}-${j + 1}`, x, (row + j) * ROW, name, recorded);
const id = addStep(branchStep, `${i + 1}-${name}-${j + 1}`, x, (row + j) * ROW, name, recorded, ["steps", i, "parallel", name, j]);
link(tail, id);
tail = [id];
depth = Math.max(depth, j + 1);
@@ -221,7 +226,7 @@ export function workflowGraph(source: string): WorkflowGraph {
row += Math.max(depth, 1);
continue;
}
const id = addStep(step, String(i + 1), 0, row * ROW);
const id = addStep(step, String(i + 1), 0, row * ROW, undefined, undefined, ["steps", i]);
link(previous, id);
previous = [id];
row++;
+27 -2
View File
@@ -83,27 +83,52 @@ export function parseWorkflowYaml(
? value.repository.trim()
: "required";
const chips: WorkflowStepChip[] = [];
const declared = new Set<string>();
for (const [i, step] of steps.entries()) {
const where = `workflow ${id} step ${i + 1}`;
if (isMapping(step) && isMapping(step.parallel)) {
for (const [branch, branchSteps] of Object.entries(step.parallel)) {
if (!Array.isArray(branchSteps) || !branchSteps.length)
return { ok: false, message: `${where}: branch ${branch} needs a list of steps` };
const visible = new Set(declared);
for (const [j, branchStep] of branchSteps.entries()) {
const problem = checkStepType(branchStep, `${where} branch ${branch} step ${j + 1}`, known, repository);
const branchWhere = `${where} branch ${branch} step ${j + 1}`;
const problem =
checkStepType(branchStep, branchWhere, known, repository) ||
laterReference(branchStep, branchWhere, visible);
if (problem) return { ok: false, message: problem };
declareID(branchStep, visible);
}
for (const branchStep of branchSteps) declareID(branchStep, declared);
}
declareID(step, declared);
chips.push({ index: i + 1, type: "parallel" });
continue;
}
const problem = checkStepType(step, where, known, repository);
const problem = checkStepType(step, where, known, repository) || laterReference(step, where, declared);
if (problem) return { ok: false, message: problem };
declareID(step, declared);
chips.push({ index: i + 1, type: (step as { type: string }).type.trim() });
}
return { ok: true, id, steps: chips };
}
const STEP_REFERENCE = /steps\.([A-Za-z0-9_-]+)/g;
/** A reference to a step that has not run yet: the server refuses it, so the
* page says so before save. */
function laterReference(step: unknown, where: string, declared: Set<string>): string {
if (!isMapping(step)) return "";
const text = JSON.stringify(step.settings ?? {}) + " " + (typeof step.when === "string" ? step.when : "");
for (const [, ref] of text.matchAll(STEP_REFERENCE))
if (!declared.has(ref)) return `${where}: no earlier step has id "${ref}"`;
return "";
}
function declareID(step: unknown, declared: Set<string>): void {
if (isMapping(step) && typeof step.id === "string") declared.add(step.id);
}
/** What is wrong with one typed step, or "" when nothing the page can see. */
function checkStepType(
step: unknown,