@leitwerk-dev/workflow-graph 0.0.0-stage → 0.4.1
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/README.md +33 -2
- package/dist/LICENSE +13 -0
- package/dist/WorkflowGraph.svelte +366 -0
- package/dist/WorkflowIcon.svelte +30 -0
- package/dist/WorkflowRoute.svelte +89 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +374 -0
- package/dist/index.js.map +1 -0
- package/dist/layout.d.ts +67 -0
- package/dist/layout.d.ts.map +1 -0
- package/package.json +52 -5
- package/src/WorkflowGraph.svelte +366 -0
- package/src/WorkflowIcon.svelte +30 -0
- package/src/WorkflowRoute.svelte +89 -0
- package/src/index.ts +9 -0
- package/src/layout.ts +531 -0
package/README.md
CHANGED
|
@@ -1,3 +1,34 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Workflow graph
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
`@leitwerk-dev/workflow-graph` owns the workflow definition renderer and its pure
|
|
4
|
+
layout. The application UI and synthetic preview use this same package.
|
|
5
|
+
|
|
6
|
+
```svelte
|
|
7
|
+
<script lang="ts">
|
|
8
|
+
import WorkflowGraph from "@leitwerk-dev/workflow-graph/WorkflowGraph.svelte";
|
|
9
|
+
import type { ProcessFlowView } from "@leitwerk-dev/domain";
|
|
10
|
+
|
|
11
|
+
let { flow }: { flow: ProcessFlowView } = $props();
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<WorkflowGraph {flow} />
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
`flow` is a static definition projected by the SDK. The component performs no
|
|
18
|
+
network requests or process execution. Optional `onInspectTurn(turnId)` adds an
|
|
19
|
+
**Open turn details** action; selecting a node opens local graph details first.
|
|
20
|
+
Chronicle CSS tokens supply the theme, with standalone fallbacks.
|
|
21
|
+
`internal/WorkflowIcon.svelte` is shared implementation, not a supported extension API.
|
|
22
|
+
|
|
23
|
+
See the [Workflow interaction contract](../../docs/ui.md#process-inspector) for
|
|
24
|
+
layout, repeat notation, tools, and inspection behavior. The graph describes the
|
|
25
|
+
current definition, not the tools or items of a particular execution.
|
|
26
|
+
|
|
27
|
+
From the repository root, run `npm run dev:workflow-graph` and open
|
|
28
|
+
<http://127.0.0.1:4320>. This preview uses live package source, four synthetic
|
|
29
|
+
definitions, and a local guided form. It requires no server or credentials.
|
|
30
|
+
See [the preview](../../tools/workflow-graph-prototype/README.md) for controls.
|
|
31
|
+
|
|
32
|
+
Build with `npm run build -w @leitwerk-dev/workflow-graph`. Changes to this package
|
|
33
|
+
require `npm run test:full`; preview-only changes also need the standalone check:
|
|
34
|
+
`npm run check --prefix tools/workflow-graph-prototype`.
|
package/dist/LICENSE
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Copyright 2026 Leitwerk contributors.
|
|
2
|
+
|
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License.
|
|
5
|
+
You may obtain a copy of the License at
|
|
6
|
+
|
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
|
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
See the License for the specific language governing permissions and
|
|
13
|
+
limitations under the License.
|
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { ProcessFlowTool, ProcessFlowView } from "@leitwerk-dev/domain";
|
|
3
|
+
import { onMount, tick, untrack } from "svelte";
|
|
4
|
+
import { on } from "svelte/events";
|
|
5
|
+
import {
|
|
6
|
+
edgePath,
|
|
7
|
+
layoutWorkflow,
|
|
8
|
+
type Point,
|
|
9
|
+
turnKindLabel,
|
|
10
|
+
type WorkflowEdge,
|
|
11
|
+
type WorkflowNode,
|
|
12
|
+
} from "./index.js";
|
|
13
|
+
import Icon from "./WorkflowIcon.svelte";
|
|
14
|
+
import Route from "./WorkflowRoute.svelte";
|
|
15
|
+
|
|
16
|
+
interface Target {
|
|
17
|
+
id: string;
|
|
18
|
+
part: "turn" | "repeat" | "collect";
|
|
19
|
+
}
|
|
20
|
+
type HighlightTarget = { id: string; part: Target["part"] | "edge" | "results" | "loop" };
|
|
21
|
+
type Preview = HighlightTarget & { element: HTMLElement | SVGGElement };
|
|
22
|
+
let {
|
|
23
|
+
flow,
|
|
24
|
+
onInspectTurn,
|
|
25
|
+
inspectorPlacement = "auto",
|
|
26
|
+
}: {
|
|
27
|
+
flow: ProcessFlowView;
|
|
28
|
+
onInspectTurn?: (turnId: string) => void;
|
|
29
|
+
inspectorPlacement?: "auto" | "below";
|
|
30
|
+
} = $props();
|
|
31
|
+
const uid = $props.id();
|
|
32
|
+
const graph = $derived(layoutWorkflow(flow));
|
|
33
|
+
let selected = $state<Target | null>(null);
|
|
34
|
+
let preview = $state<Preview | null>(null);
|
|
35
|
+
let viewport = $state<HTMLDivElement>();
|
|
36
|
+
let inspector = $state<HTMLElement>();
|
|
37
|
+
let tooltip = $state<HTMLDivElement>();
|
|
38
|
+
let opener: HTMLElement | null = null;
|
|
39
|
+
let scale = $state(1);
|
|
40
|
+
let automaticFit = true;
|
|
41
|
+
let authorDetails = $state(false);
|
|
42
|
+
let tooltipPosition = $state({ left: 0, top: 0 });
|
|
43
|
+
const active = $derived(preview ?? selected);
|
|
44
|
+
const chosen = $derived(graph.nodes.find((node) => node.id === selected?.id));
|
|
45
|
+
const tooltipNode = $derived.by(() => {
|
|
46
|
+
const value = preview;
|
|
47
|
+
return value && value.part !== "edge" && !sameTarget(value, selected)
|
|
48
|
+
? graph.nodes.find((node) => node.id === value.id)
|
|
49
|
+
: undefined;
|
|
50
|
+
});
|
|
51
|
+
const tooltipEdge = $derived.by(() => {
|
|
52
|
+
const value = preview;
|
|
53
|
+
return value?.part === "edge" ? graph.edges.find((edge) => edge.id === value.id) : undefined;
|
|
54
|
+
});
|
|
55
|
+
const routes = $derived(graph.edges.filter((edge) => edge.from === chosen?.id));
|
|
56
|
+
const presentKinds = $derived([
|
|
57
|
+
...new Set(graph.nodes.filter((node) => node.turnId !== null).map((node) => node.kind)),
|
|
58
|
+
]);
|
|
59
|
+
let processId: string | undefined;
|
|
60
|
+
$effect(() => {
|
|
61
|
+
if (preview && tooltip) positionTooltip();
|
|
62
|
+
});
|
|
63
|
+
$effect(() => {
|
|
64
|
+
if (flow.processId !== processId) {
|
|
65
|
+
processId = flow.processId;
|
|
66
|
+
untrack(() => {
|
|
67
|
+
selected = null;
|
|
68
|
+
preview = null;
|
|
69
|
+
authorDetails = false;
|
|
70
|
+
automaticFit = true;
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
graph.width;
|
|
74
|
+
untrack(() => {
|
|
75
|
+
if (automaticFit) void tick().then(fit);
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
onMount(() => {
|
|
80
|
+
fit();
|
|
81
|
+
if (typeof ResizeObserver === "undefined" || !viewport) return;
|
|
82
|
+
let previousWidth = viewport.clientWidth;
|
|
83
|
+
const observer = new ResizeObserver(() => {
|
|
84
|
+
if (viewport && previousWidth !== viewport.clientWidth) {
|
|
85
|
+
previousWidth = viewport.clientWidth;
|
|
86
|
+
if (automaticFit) fit();
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
observer.observe(viewport);
|
|
90
|
+
return () => observer.disconnect();
|
|
91
|
+
});
|
|
92
|
+
function fit() {
|
|
93
|
+
automaticFit = true;
|
|
94
|
+
if (viewport?.clientWidth)
|
|
95
|
+
scale = Math.max(0.35, Math.min(1, (viewport.clientWidth - 36) / Math.max(1, graph.width)));
|
|
96
|
+
}
|
|
97
|
+
function zoom(delta: number) {
|
|
98
|
+
automaticFit = false;
|
|
99
|
+
scale = Math.max(0.35, Math.min(1.5, scale + delta));
|
|
100
|
+
}
|
|
101
|
+
function sameTarget(a: HighlightTarget | null, b: HighlightTarget | null) {
|
|
102
|
+
return !!a && !!b && a.part === b.part && a.id === b.id;
|
|
103
|
+
}
|
|
104
|
+
function target(node: WorkflowNode, part: Target["part"] = "turn"): Target {
|
|
105
|
+
return { id: node.id, part };
|
|
106
|
+
}
|
|
107
|
+
function isPreview(node: WorkflowNode, part: Target["part"] = "turn") {
|
|
108
|
+
return sameTarget(preview, target(node, part));
|
|
109
|
+
}
|
|
110
|
+
function isSelected(node: WorkflowNode, part: Target["part"] = "turn") {
|
|
111
|
+
return sameTarget(selected, target(node, part));
|
|
112
|
+
}
|
|
113
|
+
function showPreview(event: MouseEvent | FocusEvent | KeyboardEvent, value: HighlightTarget) {
|
|
114
|
+
const element = event.currentTarget as HTMLElement | SVGGElement;
|
|
115
|
+
// The latest interaction owns the preview; leaving it must not revive an older one.
|
|
116
|
+
preview = { ...value, element };
|
|
117
|
+
positionTooltip();
|
|
118
|
+
}
|
|
119
|
+
function hidePreview(event: MouseEvent | FocusEvent) {
|
|
120
|
+
if (preview?.element === event.currentTarget) preview = null;
|
|
121
|
+
}
|
|
122
|
+
function positionTooltip() {
|
|
123
|
+
const value = preview;
|
|
124
|
+
if (!value) return;
|
|
125
|
+
const routeBounds = value.element.getBoundingClientRect();
|
|
126
|
+
const rect = (
|
|
127
|
+
value.part === "edge" ? (value.element.querySelector("text") ?? value.element) : value.element
|
|
128
|
+
).getBoundingClientRect();
|
|
129
|
+
let boundary: Pick<DOMRect, "top" | "bottom"> =
|
|
130
|
+
value.element.closest(".repeat-group")?.getBoundingClientRect() ?? routeBounds;
|
|
131
|
+
if (value.part === "edge") {
|
|
132
|
+
const edge = graph.edges.find((edge) => edge.id === value.id);
|
|
133
|
+
const canvas = value.element.closest(".canvas")?.getBoundingClientRect();
|
|
134
|
+
if (edge && canvas) {
|
|
135
|
+
// Keep the complete route and its endpoint boxes clear of its tooltip.
|
|
136
|
+
const endpoints = graph.nodes.filter((node) => node.id === edge.from || node.id === edge.to);
|
|
137
|
+
boundary = {
|
|
138
|
+
top: Math.min(boundary.top, ...endpoints.map((node) => canvas.top + node.y * scale)),
|
|
139
|
+
bottom: Math.max(
|
|
140
|
+
boundary.bottom,
|
|
141
|
+
...endpoints.map((node) => canvas.top + (node.y + node.height) * scale),
|
|
142
|
+
),
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
tooltipPosition = {
|
|
147
|
+
left: Math.max(12, Math.min(innerWidth - 292, rect.left + rect.width / 2 - 140)),
|
|
148
|
+
top:
|
|
149
|
+
boundary.bottom + (tooltip?.offsetHeight ?? 155) + 10 > innerHeight
|
|
150
|
+
? Math.max(12, boundary.top - (tooltip?.offsetHeight ?? 145) - 10)
|
|
151
|
+
: boundary.bottom + 10,
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
async function select(value: Target, element?: HTMLElement) {
|
|
155
|
+
if (element && !element.closest(".step-inspector")) opener = element;
|
|
156
|
+
if (sameTarget(selected, value)) {
|
|
157
|
+
await closeInspector();
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
selected = value;
|
|
161
|
+
await tick();
|
|
162
|
+
if (
|
|
163
|
+
inspector &&
|
|
164
|
+
viewport &&
|
|
165
|
+
inspector.getBoundingClientRect().top >= viewport.getBoundingClientRect().bottom
|
|
166
|
+
) {
|
|
167
|
+
inspector.scrollIntoView?.({ block: "nearest" });
|
|
168
|
+
inspector.focus({ preventScroll: true });
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
async function closeInspector() {
|
|
172
|
+
selected = null;
|
|
173
|
+
preview = null;
|
|
174
|
+
await tick();
|
|
175
|
+
if (opener?.isConnected) opener.focus({ preventScroll: true });
|
|
176
|
+
// Restore keyboard position without reopening the tooltip the user just dismissed.
|
|
177
|
+
preview = null;
|
|
178
|
+
}
|
|
179
|
+
function onKey(event: KeyboardEvent) {
|
|
180
|
+
if (event.key !== "Escape" || (!selected && !preview)) return;
|
|
181
|
+
event.stopPropagation();
|
|
182
|
+
if (selected) void closeInspector();
|
|
183
|
+
else preview = null;
|
|
184
|
+
}
|
|
185
|
+
function connected(edge: WorkflowEdge) {
|
|
186
|
+
if (!active) return false;
|
|
187
|
+
if (active.part === "edge") return active.id === edge.id;
|
|
188
|
+
if (active.part === "loop" || active.part === "results") return false;
|
|
189
|
+
const node = graph.nodes.find((node) => node.id === active.id);
|
|
190
|
+
if (node?.repeat && active.part === "collect") return edge.from === node.id;
|
|
191
|
+
if (node?.repeat && active.part === "turn") return edge.to === node.id;
|
|
192
|
+
return edge.from === active.id || edge.to === active.id;
|
|
193
|
+
}
|
|
194
|
+
function internalActive(node: WorkflowNode, part: "results" | "loop") {
|
|
195
|
+
if (!active || active.part === "edge" || active.id !== node.id) return false;
|
|
196
|
+
if (active.part === "loop" || active.part === "results") return active.part === part;
|
|
197
|
+
return active.part !== "collect" || part === "results";
|
|
198
|
+
}
|
|
199
|
+
function edgeSummary(edge: WorkflowEdge) {
|
|
200
|
+
return `${graph.nodes.find((node) => node.id === edge.from)?.title} → ${graph.nodes.find((node) => node.id === edge.to)?.title}`;
|
|
201
|
+
}
|
|
202
|
+
function routeTitle(edge: WorkflowEdge) {
|
|
203
|
+
return edge.condition?.label ?? edge.label;
|
|
204
|
+
}
|
|
205
|
+
function edgeLabel(edge: WorkflowEdge) {
|
|
206
|
+
const label = routeTitle(edge);
|
|
207
|
+
return `Highlight route: ${label ? `${label}. ` : ""}${edgeSummary(edge)}`;
|
|
208
|
+
}
|
|
209
|
+
function described(value: HighlightTarget) {
|
|
210
|
+
return sameTarget(preview, value) && (tooltipNode || tooltipEdge) ? `${uid}-tooltip` : undefined;
|
|
211
|
+
}
|
|
212
|
+
function localPoints(node: WorkflowNode, edge: WorkflowEdge, source: boolean): Point[] {
|
|
213
|
+
if (!node.repeat) return [];
|
|
214
|
+
const point = source ? edge.points[0] : edge.points.at(-1);
|
|
215
|
+
if (!point) return [];
|
|
216
|
+
const boundary = { x: point.x - node.x, y: point.y - node.y };
|
|
217
|
+
const side = source ? edge.sourceSide : edge.targetSide;
|
|
218
|
+
const { activity, collector, axis } = node.repeat;
|
|
219
|
+
if (source) {
|
|
220
|
+
if (side === "right")
|
|
221
|
+
return [
|
|
222
|
+
{ x: collector.x + 12, y: axis },
|
|
223
|
+
{ x: collector.x + 28, y: axis },
|
|
224
|
+
{ x: collector.x + 28, y: boundary.y },
|
|
225
|
+
boundary,
|
|
226
|
+
];
|
|
227
|
+
return [
|
|
228
|
+
{ x: collector.x, y: axis + (side === "top" ? -14 : 14) },
|
|
229
|
+
{ x: boundary.x, y: axis + (side === "top" ? -14 : 14) },
|
|
230
|
+
boundary,
|
|
231
|
+
];
|
|
232
|
+
}
|
|
233
|
+
if (side === "left") return [boundary, { x: activity.x, y: boundary.y }];
|
|
234
|
+
return [
|
|
235
|
+
boundary,
|
|
236
|
+
{ x: boundary.x, y: side === "top" ? activity.y : activity.y + activity.height },
|
|
237
|
+
];
|
|
238
|
+
}
|
|
239
|
+
function title(node: WorkflowNode, part: Target["part"] | "loop" | "results" = "turn") {
|
|
240
|
+
if (part === "loop") return "Next item";
|
|
241
|
+
if (part === "results") return "All items done";
|
|
242
|
+
return part === "collect" ? "Collect results" : part === "repeat" ? "For each item" : node.title;
|
|
243
|
+
}
|
|
244
|
+
function summary(node: WorkflowNode, part: Target["part"] | "loop" | "results" = "turn") {
|
|
245
|
+
if (part === "loop") return "Repeat the activity for the next item in the collection.";
|
|
246
|
+
if (part === "results") return "Once every item has yielded a result, continue to collection.";
|
|
247
|
+
if (part === "collect")
|
|
248
|
+
return "Combine ordered item results, update state, and choose one route. Runs once, even for an empty collection; this is part of the mapped turn.";
|
|
249
|
+
if (part === "repeat")
|
|
250
|
+
return "Repeat this LLM activity for each frozen item, one at a time. Collect all results before choosing the next route.";
|
|
251
|
+
if (node.repeat)
|
|
252
|
+
return "One LLM activity per item. Its outcome yields an item result; collection chooses the route after all items.";
|
|
253
|
+
if (node.kind === "llm") return "An LLM turn with the tools declared for this step.";
|
|
254
|
+
if (node.kind === "automatic") return "Runs deterministic process code without invoking a model.";
|
|
255
|
+
if (node.kind === "human") return "Waits for an operator decision or a declared external action.";
|
|
256
|
+
if (node.kind === "external") return "Waits for a declared external event.";
|
|
257
|
+
return node.synthetic
|
|
258
|
+
? "The process can be aborted from any active turn. No explicit workflow route is declared."
|
|
259
|
+
: `The process ends as ${node.kind}.`;
|
|
260
|
+
}
|
|
261
|
+
function iconName(node: WorkflowNode) {
|
|
262
|
+
return node.kind === "completed" ? "complete" : node.kind === "aborted" ? "abort" : node.kind;
|
|
263
|
+
}
|
|
264
|
+
function box(node: WorkflowNode) {
|
|
265
|
+
return `left:${node.x}px;top:${node.y}px;width:${node.width}px;height:${node.height}px`;
|
|
266
|
+
}
|
|
267
|
+
function categoryLabel(tool: ProcessFlowTool, node: WorkflowNode) {
|
|
268
|
+
return {
|
|
269
|
+
workspace: "Workspace",
|
|
270
|
+
integration: "Integration",
|
|
271
|
+
question: "Ask operator",
|
|
272
|
+
outcome: node.repeat ? "Finish item" : "Outcome",
|
|
273
|
+
}[tool.category];
|
|
274
|
+
}
|
|
275
|
+
</script>
|
|
276
|
+
|
|
277
|
+
<div class="workflow-graph" role="region" aria-label="Workflow definition" {@attach (element) => on(element, "keydown", onKey)} tabindex="-1" data-section="process-flow-diagram" data-flow-mode="full">
|
|
278
|
+
{#if !graph.nodes.length}<p class="empty">No workflow definition is available.</p>
|
|
279
|
+
{:else}
|
|
280
|
+
<div class="workbench" class:with-inspector={!!chosen && inspectorPlacement === 'auto'}>
|
|
281
|
+
<section class="graph-panel" aria-label="Process flow chart">
|
|
282
|
+
<div class="toolbar"><strong>Process flow</strong><span class="toolbar-hint">Select a step to explore</span><div class="zoom-controls"><button aria-label="Zoom out" disabled={scale <= .35} onclick={() => zoom(-.1)}><Icon name="minus" size={17}/></button><span>{Math.round(scale*100)}%</span><button aria-label="Zoom in" disabled={scale >= 1.5} onclick={() => zoom(.1)}><Icon name="plus" size={17}/></button><button aria-label="Fit graph to viewport" onclick={fit}><Icon name="fit" size={17}/></button></div></div>
|
|
283
|
+
<!-- svelte-ignore a11y_no_noninteractive_tabindex (Keyboard users need to focus and scroll the canvas.) -->
|
|
284
|
+
<div class="graph-viewport" bind:this={viewport} role="region" aria-label="Workflow canvas. Scroll to explore." tabindex="0">
|
|
285
|
+
<div class="graph-size" style={`width:${graph.width*scale}px;height:${graph.height*scale}px`}>
|
|
286
|
+
<div class="canvas" style={`width:${graph.width}px;height:${graph.height}px;transform:scale(${scale});--graph-route-hit-width:${14/scale}px`}>
|
|
287
|
+
<svg class="edges" width={graph.width} height={graph.height} role="group" aria-label="Workflow transitions">
|
|
288
|
+
<defs>{#each ['normal','active','loop'] as kind}<marker id={`${uid}-arrow-${kind}`} viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6" markerHeight="6" orient="auto-start-reverse"><path d="M1 1L9 5L1 9" fill="none" stroke={kind === 'loop' ? 'var(--graph-amber)' : kind === 'active' ? 'var(--graph-accent)' : 'var(--graph-route)'} stroke-width="1.7"/></marker>{/each}</defs>
|
|
289
|
+
{#each graph.edges as edge (edge.id)}
|
|
290
|
+
{@const routeTarget = { part: 'edge', id: edge.id } as const}
|
|
291
|
+
{@const label = routeTitle(edge)}
|
|
292
|
+
<Route id={edge.id} section="outer" path={edgePath(edge.points)} active={connected(edge)} muted={!!active && !connected(edge)} rework={edge.kind === 'loopback'} markerPrefix={uid} arrowEnd={!graph.nodes.find(node => node.id === edge.to)?.repeat}
|
|
293
|
+
label={label ? [label] : []} labelPosition={edge.labelPosition} accessibleLabel={edgeLabel(edge)} describedBy={described(routeTarget)}
|
|
294
|
+
from={graph.nodes.find(node => node.id === edge.from)?.turnId ?? undefined} to={graph.nodes.find(node => node.id === edge.to)?.turnId ?? undefined} kind={edge.kind}
|
|
295
|
+
onPreview={event => showPreview(event, routeTarget)} onExit={hidePreview}/>
|
|
296
|
+
{/each}
|
|
297
|
+
</svg>
|
|
298
|
+
{#each graph.nodes as node (node.id)}
|
|
299
|
+
{@const geometry=node.repeat}
|
|
300
|
+
<div class="node-group" class:repeat-group={!!geometry} style={box(node)} role={geometry?'group':undefined} aria-label={geometry?`${node.title}: one repeated LLM turn`:undefined}>
|
|
301
|
+
{#if geometry}
|
|
302
|
+
<button class="repeat-node" class:highlighted={isPreview(node,'repeat')} class:chosen={isSelected(node,'repeat')} data-flow-turn-id={node.turnId} data-part="repeat" aria-label={`Repeat ${node.title}, one item at a time`} aria-expanded={isSelected(node,'repeat')} aria-describedby={described(target(node,'repeat'))} onclick={event => select(target(node,'repeat'),event.currentTarget)} onmouseenter={event=>showPreview(event,target(node,'repeat'))} onmouseleave={hidePreview} onfocus={event=>showPreview(event,target(node,'repeat'))} onblur={hidePreview}><span class="repeat-title"><Icon name="map" size={18}/>For each item</span>{#if isSelected(node,'repeat')}<span class="selected-dot"></span>{/if}</button>
|
|
303
|
+
<svg class="internal-paths" width={node.width} height={node.height} role="group" aria-label={`Routes within ${node.title}`}>
|
|
304
|
+
{#each graph.edges.filter(edge=>edge.from === node.id || edge.to === node.id) as edge (edge.id)}
|
|
305
|
+
{#each [true,false].filter(source => source ? edge.from === node.id : edge.to === node.id) as source}
|
|
306
|
+
{@const routeTarget = { part: 'edge', id: edge.id } as const}
|
|
307
|
+
<Route id={edge.id} section={source?'exit':'entry'} path={edgePath(localPoints(node,edge,source))} active={connected(edge)} muted={!!active && !connected(edge)} rework={edge.kind === 'loopback'} markerPrefix={uid} arrowEnd={!source} tabbable={false}
|
|
308
|
+
accessibleLabel={edgeLabel(edge)} describedBy={described(routeTarget)} onPreview={event => showPreview(event, routeTarget)} onExit={hidePreview}/>
|
|
309
|
+
{/each}
|
|
310
|
+
{/each}
|
|
311
|
+
<Route id={`${node.id}:results`} section="results" path={`M253 ${geometry.axis}H312`} active={internalActive(node,'results')} muted={!!active && !internalActive(node,'results')} markerPrefix={uid}
|
|
312
|
+
label={['All items','done']} labelPosition={{x:282,y:geometry.axis-22}} repeatLabel accessibleLabel={`Highlight all items done: ${node.title} to Collect results`} describedBy={described({id:node.id,part:'results'})}
|
|
313
|
+
onPreview={event => showPreview(event,{id:node.id,part:'results'})} onExit={hidePreview}/>
|
|
314
|
+
<Route id={`${node.id}:loop`} section="loop" path={`M253 ${geometry.axis}H268V${geometry.loopY}H65V${geometry.activity.y+geometry.activity.height}`} active={internalActive(node,'loop')} muted={!!active && !internalActive(node,'loop')} markerPrefix={uid}
|
|
315
|
+
label={['Next item']} labelPosition={{x:167,y:geometry.loopY}} repeatLabel accessibleLabel={`Highlight next item: ${node.title}`} describedBy={described({id:node.id,part:'loop'})}
|
|
316
|
+
onPreview={event => showPreview(event,{id:node.id,part:'loop'})} onExit={hidePreview}/>
|
|
317
|
+
</svg>
|
|
318
|
+
{/if}
|
|
319
|
+
<button class={geometry?'activity':`flow-node ${node.kind}`} class:highlighted={isPreview(node)} class:chosen={isSelected(node)} style={geometry?`left:${geometry.activity.x}px;top:${geometry.activity.y}px;width:${geometry.activity.width}px;height:${geometry.activity.height}px`:'left:0;top:0;width:100%;height:100%'} data-flow-turn-id={node.turnId ?? undefined} data-flow-end-state={!node.turnId?node.kind:undefined} data-part="turn" aria-label={`${node.title}. ${geometry?'LLM activity for one item.':turnKindLabel(node.kind)}`} aria-expanded={isSelected(node)} aria-describedby={described(target(node))} onclick={event=>select(target(node),event.currentTarget)} onmouseenter={event=>showPreview(event,target(node))} onmouseleave={hidePreview} onfocus={event=>showPreview(event,target(node))} onblur={hidePreview}>
|
|
320
|
+
<span class="kind-icon {geometry?'llm':node.kind}"><Icon name={geometry?'llm':iconName(node)} size={20}/></span><span class="node-content">{#if geometry || node.turnId}<span class="node-kind">{geometry?'LLM turn':turnKindLabel(node.kind)}</span>{/if}<strong>{node.title}</strong>{#if (geometry || node.kind === 'llm') && node.definition?.tools}<span class="tool-count"><Icon name="wrench" size={11}/>{node.definition.tools.length}{node.definition.hasDynamicTools?'+':''} {node.definition.tools.length===1&&!node.definition.hasDynamicTools?'tool':'tools'}</span>{/if}{#if node.synthetic}<span class="synthetic-caption">From any active turn</span>{/if}</span>{#if isSelected(node)}<span class="selected-dot"></span>{/if}
|
|
321
|
+
</button>
|
|
322
|
+
{#if geometry}
|
|
323
|
+
<button class="collector" style={`left:${geometry.collector.x-22}px;top:${geometry.axis-30}px`} class:highlighted={isPreview(node,'collect')} class:chosen={isSelected(node,'collect')} data-flow-turn-id={node.turnId} data-part="collect" aria-label={`Collect results for ${node.title}`} aria-expanded={isSelected(node,'collect')} aria-describedby={described(target(node,'collect'))} onclick={event=>select(target(node,'collect'),event.currentTarget)} onmouseenter={event=>showPreview(event,target(node,'collect'))} onmouseleave={hidePreview} onfocus={event=>showPreview(event,target(node,'collect'))} onblur={hidePreview}><Icon name="collect" size={28}/><span>Collect results</span></button>
|
|
324
|
+
{/if}
|
|
325
|
+
</div>
|
|
326
|
+
{/each}
|
|
327
|
+
</div>
|
|
328
|
+
</div>
|
|
329
|
+
</div>
|
|
330
|
+
<div class="graph-footer"><div class="legend">{#each presentKinds as kind}<span><Icon name={kind} size={14}/>{turnKindLabel(kind)}</span>{/each}{#if graph.nodes.some(node=>node.repeat)}<span><Icon name="collect" size={14}/>Collection</span>{/if}<span><i></i>Transition</span>{#if graph.edges.some(edge=>edge.kind==='loopback')}<span><i class="loop"></i>Rework route</span>{/if}</div></div>
|
|
331
|
+
</section>
|
|
332
|
+
{#if chosen && selected}
|
|
333
|
+
<section class="step-inspector" bind:this={inspector} tabindex="-1" aria-label={`Details for ${title(chosen,selected.part)}`}>
|
|
334
|
+
<div class="inspector-heading"><span class="kind-icon {chosen.kind}"><Icon name={selected.part==='collect'?'collect':selected.part==='repeat'?'map':iconName(chosen)} size={22}/></span><h3>{title(chosen,selected.part)}</h3><button aria-label="Close step details" onclick={closeInspector}><Icon name="close" size={20}/></button></div>
|
|
335
|
+
<p>{summary(chosen,selected.part)}</p>
|
|
336
|
+
{#if chosen.turnId}<button class="author-toggle" aria-pressed={authorDetails} onclick={()=>authorDetails=!authorDetails}><Icon name="edit" size={14}/>Author details</button>{/if}
|
|
337
|
+
{#if authorDetails && chosen.definition}<dl class="author-details"><dt>Turn</dt><dd><code>{chosen.turnId}</code></dd><dt>Declared inputs</dt><dd>{chosen.definition.inputProducts?.join(', ') || 'No named products declared'}</dd><dt>Published products</dt><dd>{chosen.definition.outputProducts?.join(', ') || 'No named products declared'}</dd></dl>{/if}
|
|
338
|
+
{#if chosen.kind==='llm' && selected.part!=='collect'}<section class="available-tools"><h4><Icon name="wrench" size={15}/>Available tools</h4>{#key chosen.id}<ul>{#each chosen.definition?.tools ?? [] as tool (tool.name)}<li><details class="tool-disclosure"><summary><code>{tool.name}</code><Icon name="right" size={14}/></summary><div class="tool-body"><span>{categoryLabel(tool,chosen)}</span>{#if tool.description}<p>{tool.description}</p>{/if}</div></details></li>{:else}<li class="muted">{chosen.definition?.tools ? 'No static tools declared.' : 'Tool declarations are unavailable.'}</li>{/each}</ul>{/key}{#if chosen.definition?.hasDynamicTools}<p class="muted dynamic-tools">Additional integration tools are determined when this turn starts.</p>{/if}</section>{/if}
|
|
339
|
+
<section class="outgoing"><h4>{chosen.repeat?'After collection':chosen.turnId?'Possible transitions':'End of this workflow'}</h4>{#each routes as route (route.id)}{@const destination=graph.nodes.find(node=>node.id===route.to)}{#if destination}<button class="route-option" class:rework={route.kind==='loopback'} onclick={()=>select(target(destination))}><Icon name={route.kind==='loopback'?'loop':'arrow'} size={18}/><span>{#if routeTitle(route)}<strong>{routeTitle(route)}</strong>{/if}<span>{destination.title}</span>{#if route.condition?.description}<span>{route.condition.description}</span>{/if}</span><Icon name="right" size={14}/></button>{/if}{:else}<p class="muted">{chosen.turnId?'No static transitions declared.':'No outgoing transitions.'}</p>{/each}</section>
|
|
340
|
+
{#if onInspectTurn && chosen.turnId}<button class="inspect-turn" onclick={()=>onInspectTurn?.(chosen.turnId as string)}>Open turn details<Icon name="right" size={15}/></button>{/if}
|
|
341
|
+
</section>
|
|
342
|
+
{/if}
|
|
343
|
+
</div>
|
|
344
|
+
{/if}
|
|
345
|
+
{#if tooltipNode && preview && preview.part !== 'edge'}<div bind:this={tooltip} id={`${uid}-tooltip`} class="node-tooltip" role="tooltip" style={`left:${tooltipPosition.left}px;top:${tooltipPosition.top}px`}><strong>{title(tooltipNode,preview.part)}</strong><p>{summary(tooltipNode,preview.part)}</p>{#if preview.part !== 'loop' && preview.part !== 'results'}<span>Click to explore</span>{/if}</div>
|
|
346
|
+
{:else if tooltipEdge}<div bind:this={tooltip} id={`${uid}-tooltip`} class="node-tooltip" role="tooltip" style={`left:${tooltipPosition.left}px;top:${tooltipPosition.top}px`}><strong>{routeTitle(tooltipEdge) || 'Transition'}</strong><p>{edgeSummary(tooltipEdge)}</p>{#if tooltipEdge.condition}{#if tooltipEdge.label && tooltipEdge.label !== tooltipEdge.condition.label}<p>After {tooltipEdge.label}</p>{/if}{#if tooltipEdge.condition.description}<p>{tooltipEdge.condition.description}</p>{/if}{/if}</div>{/if}
|
|
347
|
+
</div>
|
|
348
|
+
|
|
349
|
+
<style>
|
|
350
|
+
.workflow-graph {--graph-accent:var(--chronicle-accent,#2f61b7);--graph-paper:var(--chronicle-panel,#fff);--graph-ink:var(--chronicle-text,#18212b);--graph-muted:var(--chronicle-text-muted,#5c6a7b);--graph-line:var(--chronicle-border,#d8e0ea);--graph-route:#9eacbd;--graph-amber:var(--chronicle-warning,#a76b17);--graph-tint:color-mix(in srgb,var(--graph-accent) 4%,var(--graph-paper));color:var(--graph-ink);font-family:inherit;container-type:inline-size;min-width:0;width:100%;}
|
|
351
|
+
.workflow-graph * {box-sizing:border-box;}
|
|
352
|
+
button {font:inherit;color:inherit;background:none;border:0;cursor:pointer;} button:disabled{opacity:.4;cursor:default;} button:focus-visible,summary:focus-visible,[tabindex]:focus-visible{outline:3px solid color-mix(in srgb,var(--graph-accent) 65%,white);outline-offset:3px;} svg{flex:none;vertical-align:middle;} p,h3,h4,dl,dd{margin:0;} .workbench{display:grid;gap:18px;align-items:start;min-width:0;}
|
|
353
|
+
.graph-panel{min-width:0;background:var(--graph-paper);border:1px solid var(--graph-line);border-radius:14px;overflow:hidden;}
|
|
354
|
+
.toolbar{display:flex;align-items:center;gap:18px;min-height:55px;padding:10px 16px;border-bottom:1px solid var(--graph-line);font-size:12px;} .toolbar strong{font-weight:600;} .toolbar-hint{font-size:11px;color:var(--graph-muted);} .zoom-controls{display:flex;align-items:center;gap:5px;margin-left:auto;} .zoom-controls button{display:grid;place-items:center;width:30px;height:30px;border-radius:5px;} .zoom-controls button:hover{background:var(--graph-tint);} .zoom-controls>span{min-width:36px;text-align:center;font-size:11px;font-variant-numeric:tabular-nums;color:var(--graph-muted);}
|
|
355
|
+
.graph-viewport{overflow:auto;padding:16px;min-height:350px;max-height:700px;background-color:var(--graph-paper);background-image:radial-gradient(color-mix(in srgb,var(--graph-line) 90%,transparent) .8px,transparent .8px);background-size:20px 20px;display:flex;align-items:center;justify-content:safe center;}
|
|
356
|
+
.graph-size{flex:none;position:relative;}.canvas{position:absolute;inset:0;transform-origin:top left;}.edges{position:absolute;inset:0;pointer-events:none;overflow:visible;}
|
|
357
|
+
.flow-node,.activity{position:absolute;display:flex;align-items:center;gap:11px;padding:17px;background:var(--graph-paper);border:1px solid var(--graph-line);border-radius:12px;text-align:left;}.flow-node.highlighted,.activity.highlighted{background:color-mix(in srgb,var(--graph-accent) 8%,var(--graph-paper));border-color:color-mix(in srgb,var(--graph-accent) 65%,var(--graph-line));}.flow-node.chosen,.activity.chosen{border-color:var(--graph-accent);background:var(--graph-tint);}.node-content{display:flex;flex-direction:column;gap:4px;min-width:0;}.node-content strong{font-size:15px;font-weight:600;line-height:1.4;overflow-wrap:anywhere;display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical;overflow:hidden;}.node-kind{font-size:9px;line-height:1.5;font-weight:650;letter-spacing:.65px;text-transform:uppercase;color:var(--graph-muted);}.kind-icon{width:33px;height:33px;display:grid;place-items:center;flex:none;border-radius:50%;background:color-mix(in srgb,var(--graph-muted) 7%,var(--graph-paper));color:var(--graph-muted);}.kind-icon.llm{color:var(--graph-accent);background:color-mix(in srgb,var(--graph-accent) 8%,var(--graph-paper));}.tool-count{display:flex;gap:5px;align-items:center;color:var(--graph-muted);font-size:9px;line-height:1.4;}.completed{color:#257651;background:color-mix(in srgb,#257651 5%,var(--graph-paper));}.aborted{color:var(--graph-muted);background:color-mix(in srgb,var(--graph-muted) 5%,var(--graph-paper));}.synthetic-caption{font-size:10px;}.selected-dot{position:absolute;width:6px;height:6px;border-radius:50%;background:var(--graph-accent);right:10px;top:11px;}
|
|
358
|
+
.node-group{position:absolute;}.repeat-node{position:absolute;inset:0;width:100%;height:100%;padding:0;border:0;border-radius:12px;background:var(--graph-tint);text-align:left;}.repeat-node::before{content:"";position:absolute;inset:0;border:1px dashed color-mix(in srgb,var(--graph-accent) 30%,var(--graph-line));border-radius:inherit;pointer-events:none;}.repeat-node.highlighted::before{border-color:var(--graph-accent);}.repeat-node.chosen::before{border:2px dashed var(--graph-accent);}.repeat-title{position:absolute;left:20px;top:20px;display:flex;gap:8px;align-items:center;font-size:12px;font-weight:600;color:var(--graph-accent);}.activity{padding:13px;border-radius:9px;}.internal-paths{position:absolute;inset:0;pointer-events:none;}
|
|
359
|
+
.collector{position:absolute;width:44px;height:100px;display:flex;flex-direction:column;align-items:center;gap:8px;padding:16px 4px;color:var(--graph-muted);}.collector>span{font-size:10px;line-height:1.4;text-align:center;}.collector.highlighted,.collector.chosen{--collection-fill:color-mix(in srgb,var(--graph-accent) 15%,var(--graph-paper));color:var(--graph-accent);}.collector.highlighted :global(svg),.collector.chosen :global(svg){stroke-width:2.2px;}.collector.chosen>span{font-weight:650;}.collector:focus-visible{outline:none;}.collector:focus-visible>span{outline:2px solid var(--graph-accent);outline-offset:4px;border-radius:2px;}
|
|
360
|
+
.graph-footer{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:12px;padding:14px 18px;border-top:1px solid var(--graph-line);font-size:10px;color:var(--graph-muted);}.legend{display:flex;flex-wrap:wrap;gap:12px 18px;}.legend>span{display:flex;gap:6px;align-items:center;}.legend i{width:18px;border-top:1.6px solid var(--graph-route);}.legend i.loop{border-color:var(--graph-amber);}
|
|
361
|
+
.step-inspector{min-width:0;border:1px solid var(--graph-line);border-radius:12px;background:var(--graph-paper);padding:18px;font-size:12px;line-height:1.7;display:grid;gap:18px;overflow-wrap:anywhere;}.inspector-heading{display:flex;align-items:center;gap:10px;}.inspector-heading h3{font-size:15px;line-height:1.4;flex:1;}.inspector-heading button{display:grid;place-items:center;width:30px;height:30px;border-radius:5px;}.inspector-heading button:hover{background:var(--graph-tint);}.step-inspector>p{color:var(--graph-muted);max-width:65ch;}.author-toggle{justify-self:start;display:flex;align-items:center;gap:6px;font-size:11px;color:var(--graph-muted);padding:5px 0;}.author-toggle[aria-pressed="true"]{color:var(--graph-accent);}.author-details{display:grid;grid-template-columns:100px minmax(0,1fr);gap:10px;font-size:11px;}.author-details dt{color:var(--graph-muted);}.available-tools,.outgoing{padding-top:16px;border-top:1px solid var(--graph-line);}.available-tools h4,.outgoing h4{display:flex;align-items:center;gap:7px;font-size:12px;font-weight:600;}.available-tools ul{list-style:none;padding:0;margin:10px 0 0;}.available-tools li+li{border-top:1px solid var(--graph-line);}.tool-disclosure summary{display:flex;gap:12px;align-items:center;justify-content:space-between;cursor:pointer;padding:12px 0;list-style:none;}.tool-disclosure summary::-webkit-details-marker{display:none;}.tool-disclosure code{font-size:11px;overflow-wrap:anywhere;}.tool-disclosure summary :global(svg){flex:none;transition:transform .15s;}.tool-disclosure[open] summary :global(svg){transform:rotate(90deg);}.tool-disclosure summary:hover{color:var(--graph-accent);}.tool-body{padding:0 0 13px;color:var(--graph-muted);font-size:11px;}.tool-body>span{display:block;font-weight:600;margin-bottom:4px;}.dynamic-tools{font-size:11px;margin-top:12px;}.muted{color:var(--graph-muted);}.route-option{width:100%;display:flex;gap:10px;align-items:center;padding:12px 0;text-align:left;border-bottom:1px solid var(--graph-line);color:var(--graph-accent);font-size:11px;}.route-option>span{display:grid;gap:3px;flex:1;}.route-option strong{font-weight:600;color:var(--graph-ink);}.route-option.rework{color:var(--graph-amber);}.route-option:hover{background:var(--graph-tint);}.inspect-turn{display:flex;align-items:center;justify-content:space-between;padding:8px 0;color:var(--graph-accent);font-size:12px;}.empty{padding:16px;color:var(--graph-muted);font-size:13px;}
|
|
362
|
+
.node-tooltip{position:fixed;width:280px;max-width:calc(100vw - 24px);z-index:1000;pointer-events:none;background:#21364f;color:white;padding:15px 17px;border-radius:10px;box-shadow:0 6px 25px #182b452e;font-size:11px;line-height:1.7;}.node-tooltip strong{font-size:12px;}.node-tooltip p{margin-top:7px;color:#e4edfa;}.node-tooltip>span{display:block;margin-top:9px;color:#cbdaf1;font-size:10px;}
|
|
363
|
+
@container(min-width:1100px){.workbench.with-inspector{grid-template-columns:minmax(0,1fr) 330px;}}
|
|
364
|
+
@container(max-width:650px){.toolbar-hint{display:none;}.toolbar{gap:8px;padding:10px;}.graph-viewport{justify-content:flex-start;max-height:550px;}.graph-footer{padding:12px;}.legend{gap:10px;}.author-details{grid-template-columns:1fr;gap:4px;}.author-details dd{margin-bottom:8px;}}
|
|
365
|
+
@media(prefers-reduced-motion:reduce){.tool-disclosure summary :global(svg){transition:none;}}
|
|
366
|
+
</style>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
<!-- @internal -->
|
|
2
|
+
<script>
|
|
3
|
+
let { name = "agent", size = 20 } = $props();
|
|
4
|
+
const paths = {
|
|
5
|
+
document: "M6 3h8l4 4v14H6zM14 3v5h4M9 12h6M9 16h6",
|
|
6
|
+
external: "M5 5h14v14H5zM2 12h11m-3-3 3 3-3 3",
|
|
7
|
+
agent: "M8 4h8v4H8z M4 10h16v10H4z M8 14h.01 M16 14h.01 M9 17h6 M12 2v2 M2 13h2 M20 13h2",
|
|
8
|
+
map: "m16 3 4 4-4 4M4 11V9a2 2 0 0 1 2-2h14M8 21l-4-4 4-4m12 0v2a2 2 0 0 1-2 2H4",
|
|
9
|
+
automatic: "m10 3-1 3-3 1-3 3v4l3 1 1 3 3 3h4l1-3 3-1 3-3v-4l-3-1-1-3-3-3h-4Z",
|
|
10
|
+
human: "M5 21v-3a7 7 0 0 1 14 0v3M9 17l2 2 4-4",
|
|
11
|
+
complete: "M5 12l4 4L19 6",
|
|
12
|
+
abort: "M7 7l10 10 M17 7L7 17",
|
|
13
|
+
arrow: "M4 12h16 M14 6l6 6-6 6",
|
|
14
|
+
left: "M15 6l-6 6 6 6",
|
|
15
|
+
right: "M9 6l6 6-6 6",
|
|
16
|
+
close: "M6 6l12 12 M18 6L6 18",
|
|
17
|
+
fit: "M9 3H3v6 M15 3h6v6 M3 15v6h6 M21 15v6h-6",
|
|
18
|
+
plus: "M5 12h14 M12 5v14",
|
|
19
|
+
minus: "M5 12h14",
|
|
20
|
+
loop: "M5 8a8 8 0 1 1-1 8 M5 3v5h5",
|
|
21
|
+
branch: "M6 3v14a4 4 0 0 0 4 4h8 M6 7h8a4 4 0 0 0 4-4 M14 17l4 4-4 3 M14 3l4-3",
|
|
22
|
+
info: "M12 11v6 M12 7h.01 M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0",
|
|
23
|
+
layers: "M12 3L3 8l9 5 9-5-9-5 M3 12l9 5 9-5 M3 16l9 5 9-5",
|
|
24
|
+
play: "M8 4l12 8-12 8z",
|
|
25
|
+
edit: "M4 20h4L20 8l-4-4L4 16z M13 7l4 4",
|
|
26
|
+
wrench: "M14 6a5 5 0 0 0-6 6L3 17a2.8 2.8 0 0 0 4 4l5-5a5 5 0 0 0 6-6l-3 3-4-4 3-3Z",
|
|
27
|
+
};
|
|
28
|
+
</script>
|
|
29
|
+
|
|
30
|
+
<svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">{#if name === 'llm'}<path d="m10 3 2.2 6.8L19 12l-6.8 2.2L10 21l-2.2-6.8L1 12l6.8-2.2L10 3Z" fill="currentColor" stroke="none" /><path d="m19 1 1 3 3 1-3 1-1 3-1-3-3-1 3-1 1-3Zm1 14 .8 2.2L23 18l-2.2.8L20 21l-.8-2.2L17 18l2.2-.8L20 15Z" fill="currentColor" stroke="none" />{:else if name === 'collect'}<path d="M12 3L21 12L12 21L3 12Z" fill="var(--collection-fill, none)" /><path d="M7 9L12 12L7 15 M12 12H17" />{:else if name === 'automatic'}<path d={paths.automatic} transform="translate(0 -1) scale(1 .95)" /><circle cx="12" cy="11" r="3" />{:else if name === 'human'}<circle cx="12" cy="7" r="3" /><path d={paths.human} />{:else}<path d={paths[name] || paths.agent} />{/if}</svg>
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
<svelte:options namespace="svg" />
|
|
2
|
+
|
|
3
|
+
<script lang="ts">
|
|
4
|
+
import type { Point, WorkflowEdge } from "./index.js";
|
|
5
|
+
|
|
6
|
+
let {
|
|
7
|
+
id,
|
|
8
|
+
section,
|
|
9
|
+
path,
|
|
10
|
+
active,
|
|
11
|
+
muted,
|
|
12
|
+
markerPrefix,
|
|
13
|
+
arrowEnd = true,
|
|
14
|
+
rework = false,
|
|
15
|
+
label = [],
|
|
16
|
+
labelPosition,
|
|
17
|
+
repeatLabel = false,
|
|
18
|
+
tabbable = true,
|
|
19
|
+
accessibleLabel,
|
|
20
|
+
describedBy,
|
|
21
|
+
from,
|
|
22
|
+
to,
|
|
23
|
+
kind,
|
|
24
|
+
onPreview,
|
|
25
|
+
onExit,
|
|
26
|
+
}: {
|
|
27
|
+
id: string;
|
|
28
|
+
section: "outer" | "entry" | "exit" | "results" | "loop";
|
|
29
|
+
path: string;
|
|
30
|
+
active: boolean;
|
|
31
|
+
muted: boolean;
|
|
32
|
+
markerPrefix: string;
|
|
33
|
+
arrowEnd?: boolean;
|
|
34
|
+
rework?: boolean;
|
|
35
|
+
label?: string[];
|
|
36
|
+
labelPosition?: Point;
|
|
37
|
+
repeatLabel?: boolean;
|
|
38
|
+
tabbable?: boolean;
|
|
39
|
+
accessibleLabel: string;
|
|
40
|
+
describedBy?: string;
|
|
41
|
+
from?: string;
|
|
42
|
+
to?: string;
|
|
43
|
+
kind?: WorkflowEdge["kind"];
|
|
44
|
+
onPreview: (event: MouseEvent | FocusEvent | KeyboardEvent) => void;
|
|
45
|
+
onExit: (event: MouseEvent | FocusEvent) => void;
|
|
46
|
+
} = $props();
|
|
47
|
+
let element: SVGGElement;
|
|
48
|
+
function activate(event: MouseEvent | KeyboardEvent) {
|
|
49
|
+
if (event.type === "keydown") {
|
|
50
|
+
const key = (event as KeyboardEvent).key;
|
|
51
|
+
if (key !== "Enter" && key !== " ") return;
|
|
52
|
+
event.preventDefault();
|
|
53
|
+
}
|
|
54
|
+
element.focus();
|
|
55
|
+
onPreview(event);
|
|
56
|
+
}
|
|
57
|
+
</script>
|
|
58
|
+
|
|
59
|
+
<g bind:this={element} class="workflow-route" class:route-active={active} class:route-muted={muted} class:rework
|
|
60
|
+
data-route-id={id} data-route-section={section} data-flow-edge-from={from} data-flow-edge-to={to} data-flow-edge-kind={kind}
|
|
61
|
+
role="button" tabindex={tabbable ? 0 : -1} aria-label={accessibleLabel} aria-describedby={describedBy}
|
|
62
|
+
onmouseenter={onPreview} onmouseleave={onExit} onfocus={onPreview} onblur={onExit} onclick={activate} onkeydown={activate}>
|
|
63
|
+
<path class="route-hit" d={path} fill="none" stroke="transparent" />
|
|
64
|
+
<path class="route-line" d={path} fill="none" stroke={active ? 'var(--graph-accent)' : rework ? 'var(--graph-amber)' : 'var(--graph-route)'} stroke-width={active ? 2.2 : 1.6}
|
|
65
|
+
marker-end={arrowEnd ? `url(#${markerPrefix}-arrow-${active ? 'active' : rework ? 'loop' : 'normal'})` : undefined} />
|
|
66
|
+
{#if label.length && labelPosition}
|
|
67
|
+
<text class="route-label" class:repeat-label={repeatLabel} x={labelPosition.x} y={labelPosition.y} text-anchor="middle">
|
|
68
|
+
{#each label as line, index}<tspan x={labelPosition.x} dy={index ? 11 : 0}>{line}</tspan>{/each}
|
|
69
|
+
</text>
|
|
70
|
+
{/if}
|
|
71
|
+
</g>
|
|
72
|
+
|
|
73
|
+
<style>
|
|
74
|
+
.workflow-route {cursor:pointer;}
|
|
75
|
+
.route-hit {pointer-events:stroke;stroke-width:var(--graph-route-hit-width,14px);}
|
|
76
|
+
/* The two internal paths share a fork; keep their hit areas within that gap. */
|
|
77
|
+
[data-route-section="loop"] .route-hit,[data-route-section="results"] .route-hit {stroke-width:min(var(--graph-route-hit-width,14px),20px);}
|
|
78
|
+
.route-line {pointer-events:none;}
|
|
79
|
+
.route-label {pointer-events:all;font-family:inherit;font-size:10px;font-weight:500;fill:var(--graph-muted);stroke:var(--graph-paper);stroke-width:8px;paint-order:stroke;stroke-linejoin:round;}
|
|
80
|
+
.repeat-label {stroke:var(--graph-tint);}
|
|
81
|
+
[data-route-section="results"] .route-label {font-size:9px;}
|
|
82
|
+
.rework .route-label {fill:var(--graph-amber);}
|
|
83
|
+
.route-active .route-label {fill:var(--graph-accent);font-weight:650;}
|
|
84
|
+
.route-muted {opacity:.4;}
|
|
85
|
+
.route-muted.rework {opacity:.7;}
|
|
86
|
+
.workflow-route:focus-visible {outline:none;}
|
|
87
|
+
.workflow-route:focus-visible .route-label {text-decoration:underline;text-underline-offset:3px;}
|
|
88
|
+
.workflow-route:focus-visible .route-line {stroke-width:2.8px;}
|
|
89
|
+
</style>
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,gBAAgB;AAChB,YAAY,EACX,KAAK,EACL,cAAc,EACd,YAAY,EACZ,cAAc,EACd,YAAY,GACZ,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,sBAAsB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC"}
|