@pipelex/mthds-ui 0.5.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/LICENSE +21 -0
- package/README.md +299 -0
- package/dist/chunk-CCUSQM3E.js +1155 -0
- package/dist/chunk-CCUSQM3E.js.map +1 -0
- package/dist/chunk-DDAAVRWG.js +25 -0
- package/dist/chunk-DDAAVRWG.js.map +1 -0
- package/dist/chunk-IX35IG2I.js +1 -0
- package/dist/chunk-IX35IG2I.js.map +1 -0
- package/dist/graph/index.d.ts +95 -0
- package/dist/graph/index.js +73 -0
- package/dist/graph/index.js.map +1 -0
- package/dist/graph/react/detail/DetailPanel.css +525 -0
- package/dist/graph/react/graph-core.css +394 -0
- package/dist/graph/react/index.css +753 -0
- package/dist/graph/react/index.css.map +1 -0
- package/dist/graph/react/index.d.ts +252 -0
- package/dist/graph/react/index.js +2207 -0
- package/dist/graph/react/index.js.map +1 -0
- package/dist/graph/react/stuff/StuffViewer.css +284 -0
- package/dist/graph/react/viewer/GraphToolbar.css +61 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +73 -0
- package/dist/index.js.map +1 -0
- package/dist/shiki/index.d.ts +13 -0
- package/dist/shiki/index.js +1333 -0
- package/dist/shiki/index.js.map +1 -0
- package/dist/types-bV8F_WoM.d.ts +366 -0
- package/package.json +109 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Pipelex
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
# @pipelex/mthds-ui
|
|
2
|
+
|
|
3
|
+
Interactive graph visualization for [MTHDS](https://mthds.sh) method pipelines. Renders execution graphs from [GraphSpec](https://docs.pipelex.com/latest/under-the-hood/execution-graph-tracing/#graphspec) data — the canonical format produced by [Pipelex](https://pipelex.com) when tracing pipeline execution.
|
|
4
|
+
|
|
5
|
+
Core graph logic (builders, layout, analysis) is pure TypeScript with no React dependency. The React layer provides a drop-in `GraphViewer` component powered by [ReactFlow](https://reactflow.dev).
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @pipelex/mthds-ui
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Released versions are listed on the [npm page](https://www.npmjs.com/package/@pipelex/mthds-ui) and the [GitHub releases page](https://github.com/Pipelex/mthds-ui/releases).
|
|
14
|
+
|
|
15
|
+
### Peer dependencies
|
|
16
|
+
|
|
17
|
+
| Dependency | Required | Used by |
|
|
18
|
+
| -------------------- | -------- | ----------------------------- |
|
|
19
|
+
| `react`, `react-dom` | no | React layer (`graph/react`) |
|
|
20
|
+
| `shiki` | no | Syntax highlighting (`shiki`) |
|
|
21
|
+
|
|
22
|
+
### Bundled dependencies
|
|
23
|
+
|
|
24
|
+
| Dependency | License | Used by |
|
|
25
|
+
| --------------- | ------- | ------------------------------- |
|
|
26
|
+
| `elkjs` | EPL-2.0 | Graph layout engine |
|
|
27
|
+
| `@xyflow/react` | MIT | Graph rendering (`graph/react`) |
|
|
28
|
+
|
|
29
|
+
`elkjs` (Eclipse Layout Kernel) is licensed under the [Eclipse Public License 2.0](https://www.eclipse.org/legal/epl-2.0/). See [NOTICE](./NOTICE) for details.
|
|
30
|
+
|
|
31
|
+
## Quick start (React)
|
|
32
|
+
|
|
33
|
+
```tsx
|
|
34
|
+
import { GraphViewer } from "@pipelex/mthds-ui/graph/react";
|
|
35
|
+
|
|
36
|
+
function MethodGraph({ graphspec }) {
|
|
37
|
+
return <GraphViewer graphspec={graphspec} />;
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
That's it. `GraphViewer` handles layout, styling, CSS variables, and all ReactFlow internals. All props except `graphspec` are optional with sensible defaults.
|
|
42
|
+
|
|
43
|
+
### Next.js (App Router)
|
|
44
|
+
|
|
45
|
+
ReactFlow accesses browser globals at module-evaluation time, so it cannot be server-side rendered. Use `next/dynamic` with `ssr: false`:
|
|
46
|
+
|
|
47
|
+
```tsx
|
|
48
|
+
"use client";
|
|
49
|
+
|
|
50
|
+
import dynamic from "next/dynamic";
|
|
51
|
+
import type { GraphViewerProps } from "@pipelex/mthds-ui/graph/react";
|
|
52
|
+
import React from "react";
|
|
53
|
+
|
|
54
|
+
const GraphViewer = dynamic(
|
|
55
|
+
() =>
|
|
56
|
+
import("@pipelex/mthds-ui/graph/react").then((mod) => ({
|
|
57
|
+
default: mod.GraphViewer,
|
|
58
|
+
})),
|
|
59
|
+
{ ssr: false },
|
|
60
|
+
) as React.ComponentType<GraphViewerProps>;
|
|
61
|
+
|
|
62
|
+
export function MyGraph({ graphspec }) {
|
|
63
|
+
return <GraphViewer graphspec={graphspec} />;
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### GraphViewer props
|
|
68
|
+
|
|
69
|
+
| Prop | Type | Default | Description |
|
|
70
|
+
| ------------------ | ------------------------------------------------- | ---------------------- | ---------------------------------------- |
|
|
71
|
+
| `graphspec` | `GraphSpec \| null` | — | Graph data (nodes + edges) |
|
|
72
|
+
| `config` | `GraphConfig` | `DEFAULT_GRAPH_CONFIG` | Layout and visual configuration |
|
|
73
|
+
| `direction` | `GraphDirection` | `"LR"` | Layout direction: `TB`, `LR`, `RL`, `BT` |
|
|
74
|
+
| `showControllers` | `boolean` | `false` | Show controller group outlines |
|
|
75
|
+
| `onNavigateToPipe` | `(pipeCode: string, status?: PipeStatus) => void` | — | Callback when a pipe node is clicked |
|
|
76
|
+
| `onReactFlowInit` | `(instance: AppRFInstance) => void` | — | Access the underlying ReactFlow instance |
|
|
77
|
+
|
|
78
|
+
### Container sizing
|
|
79
|
+
|
|
80
|
+
The graph container uses `position: absolute; inset: 0` to fill its parent. Make sure the parent element has `position: relative` and a defined height (e.g. `h-full`, `flex-1`, or an explicit height).
|
|
81
|
+
|
|
82
|
+
## GraphSpec
|
|
83
|
+
|
|
84
|
+
GraphSpec is the data format that describes a pipeline execution graph. It's generated by Pipelex when running or validating MTHDS method bundles.
|
|
85
|
+
|
|
86
|
+
### Generating a GraphSpec
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
# From a .mthds bundle file
|
|
90
|
+
pipelex-agent validate bundle my-method.mthds --view
|
|
91
|
+
|
|
92
|
+
# The output JSON contains a graphspec field
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Or programmatically via the Pipelex Python SDK:
|
|
96
|
+
|
|
97
|
+
```python
|
|
98
|
+
from pipelex import Pipelex
|
|
99
|
+
|
|
100
|
+
px = Pipelex()
|
|
101
|
+
result = px.validate_bundle("my-method.mthds", view=True)
|
|
102
|
+
graphspec = result.graphspec # dict ready for JSON serialization
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Structure
|
|
106
|
+
|
|
107
|
+
```typescript
|
|
108
|
+
interface GraphSpec {
|
|
109
|
+
nodes: GraphSpecNode[];
|
|
110
|
+
edges: GraphSpecEdge[];
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
interface GraphSpecNode {
|
|
114
|
+
id: string;
|
|
115
|
+
pipe_code?: string; // e.g. "analyze_match"
|
|
116
|
+
pipe_type?: string; // e.g. "PipeLLM", "PipeSequence", "PipeExtract"
|
|
117
|
+
status?: string; // "succeeded", "failed", "running", "scheduled", "skipped"
|
|
118
|
+
io?: {
|
|
119
|
+
inputs?: IOItem[];
|
|
120
|
+
outputs?: IOItem[];
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
interface GraphSpecEdge {
|
|
125
|
+
id?: string;
|
|
126
|
+
source: string; // Source node ID
|
|
127
|
+
target: string; // Target node ID
|
|
128
|
+
kind: GraphSpecEdgeKind; // "data", "contains", "batch_item", etc.
|
|
129
|
+
label?: string;
|
|
130
|
+
}
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### Node types
|
|
134
|
+
|
|
135
|
+
Nodes represent pipes (operations) and stuffs (data artifacts) in the pipeline:
|
|
136
|
+
|
|
137
|
+
- **Pipe nodes** — operations like `PipeLLM`, `PipeSequence`, `PipeExtract`, `PipeSearch`
|
|
138
|
+
- **Stuff nodes** — data flowing between pipes, typed by concepts (e.g. `CandidateProfile`, `Document`)
|
|
139
|
+
|
|
140
|
+
### Edge kinds
|
|
141
|
+
|
|
142
|
+
| Kind | Description |
|
|
143
|
+
| ------------------ | ----------------------------------------------------------- |
|
|
144
|
+
| `data` | Data flow — stuff produced by one pipe, consumed by another |
|
|
145
|
+
| `contains` | Containment — a controller pipe wraps child pipes |
|
|
146
|
+
| `batch_item` | Batch processing — items fanned out from a collection |
|
|
147
|
+
| `batch_aggregate` | Batch aggregation — items collected back |
|
|
148
|
+
| `parallel_combine` | Parallel results combined |
|
|
149
|
+
|
|
150
|
+
### Example GraphSpec (minimal)
|
|
151
|
+
|
|
152
|
+
```json
|
|
153
|
+
{
|
|
154
|
+
"nodes": [
|
|
155
|
+
{
|
|
156
|
+
"id": "extract_text",
|
|
157
|
+
"pipe_code": "extract_text",
|
|
158
|
+
"pipe_type": "PipeExtract",
|
|
159
|
+
"io": {
|
|
160
|
+
"inputs": [{ "digest": "input_doc", "name": "document", "concept": "Document" }],
|
|
161
|
+
"outputs": [{ "digest": "pages", "name": "pages", "concept": "TextPages" }]
|
|
162
|
+
}
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
"id": "summarize",
|
|
166
|
+
"pipe_code": "summarize",
|
|
167
|
+
"pipe_type": "PipeLLM",
|
|
168
|
+
"io": {
|
|
169
|
+
"inputs": [{ "digest": "pages", "name": "pages", "concept": "TextPages" }],
|
|
170
|
+
"outputs": [{ "digest": "summary", "name": "summary", "concept": "Summary" }]
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
],
|
|
174
|
+
"edges": []
|
|
175
|
+
}
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
Full specification: [docs.pipelex.com — Execution Graph Tracing](https://docs.pipelex.com/latest/under-the-hood/execution-graph-tracing/#graphspec)
|
|
179
|
+
|
|
180
|
+
## Configuration
|
|
181
|
+
|
|
182
|
+
### GraphConfig
|
|
183
|
+
|
|
184
|
+
Controls layout and visual behavior. All fields are optional — `DEFAULT_GRAPH_CONFIG` provides sensible defaults.
|
|
185
|
+
|
|
186
|
+
```typescript
|
|
187
|
+
import { DEFAULT_GRAPH_CONFIG } from "@pipelex/mthds-ui";
|
|
188
|
+
|
|
189
|
+
// Override specific settings
|
|
190
|
+
const myConfig = {
|
|
191
|
+
...DEFAULT_GRAPH_CONFIG,
|
|
192
|
+
direction: "LR",
|
|
193
|
+
nodesep: 80,
|
|
194
|
+
ranksep: 50,
|
|
195
|
+
};
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
| Field | Type | Default | Description |
|
|
199
|
+
| ----------------- | ------------------------ | ------------- | -------------------------------------- |
|
|
200
|
+
| `direction` | `GraphDirection` | `"LR"` | Layout direction |
|
|
201
|
+
| `showControllers` | `boolean` | `false` | Show controller group boxes |
|
|
202
|
+
| `nodesep` | `number` | `50` | Horizontal spacing between nodes |
|
|
203
|
+
| `ranksep` | `number` | `100` | Vertical spacing between ranks |
|
|
204
|
+
| `edgeType` | `EdgeType` | `"bezier"` | Edge curve style |
|
|
205
|
+
| `initialZoom` | `number \| null` | `null` | Override fit-view zoom (`null` = auto) |
|
|
206
|
+
| `panToTop` | `boolean` | `true` | Pan viewport to top after layout |
|
|
207
|
+
| `paletteColors` | `Record<string, string>` | _(see below)_ | CSS variable overrides for theming |
|
|
208
|
+
|
|
209
|
+
### Theming with palette colors
|
|
210
|
+
|
|
211
|
+
`GraphViewer` applies CSS custom properties from `paletteColors` on mount. Override colors by passing a custom config:
|
|
212
|
+
|
|
213
|
+
```tsx
|
|
214
|
+
<GraphViewer
|
|
215
|
+
graphspec={graphspec}
|
|
216
|
+
config={{
|
|
217
|
+
...DEFAULT_GRAPH_CONFIG,
|
|
218
|
+
paletteColors: {
|
|
219
|
+
...DEFAULT_GRAPH_CONFIG.paletteColors,
|
|
220
|
+
"--color-pipe": "#e06c75",
|
|
221
|
+
"--color-stuff": "#61afef",
|
|
222
|
+
"--color-bg": "#282c34",
|
|
223
|
+
},
|
|
224
|
+
}}
|
|
225
|
+
/>
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
Default palette colors include:
|
|
229
|
+
|
|
230
|
+
| Variable | Purpose |
|
|
231
|
+
| ------------------------- | -------------------------- |
|
|
232
|
+
| `--color-pipe` | Pipe node border/accent |
|
|
233
|
+
| `--color-pipe-bg` | Pipe node background |
|
|
234
|
+
| `--color-stuff` | Stuff node border/accent |
|
|
235
|
+
| `--color-stuff-bg` | Stuff node background |
|
|
236
|
+
| `--color-edge` | Edge line color |
|
|
237
|
+
| `--color-batch-item` | Batch item edge color |
|
|
238
|
+
| `--color-batch-aggregate` | Batch aggregate edge color |
|
|
239
|
+
| `--color-bg` | Graph background |
|
|
240
|
+
| `--color-bg-dots` | Background dot pattern |
|
|
241
|
+
| `--font-sans` | Node font family |
|
|
242
|
+
| `--font-mono` | Code/controller font |
|
|
243
|
+
|
|
244
|
+
See `graphConfig.ts` for the full default palette.
|
|
245
|
+
|
|
246
|
+
## Entry points
|
|
247
|
+
|
|
248
|
+
| Import path | Content |
|
|
249
|
+
| ------------------------------- | ------------------------------------------------------------------ |
|
|
250
|
+
| `@pipelex/mthds-ui` | Pure-TS graph logic — types, builders, layout, controllers, config |
|
|
251
|
+
| `@pipelex/mthds-ui/graph/react` | React components — `GraphViewer`, label helpers, type converters |
|
|
252
|
+
| `@pipelex/mthds-ui/shiki` | MTHDS syntax highlighting with shiki |
|
|
253
|
+
|
|
254
|
+
## Pure TypeScript usage
|
|
255
|
+
|
|
256
|
+
Use the graph logic without React — build nodes/edges, run layout, and feed the result to your own renderer:
|
|
257
|
+
|
|
258
|
+
```typescript
|
|
259
|
+
import {
|
|
260
|
+
buildGraph,
|
|
261
|
+
getLayoutedElements,
|
|
262
|
+
applyControllers,
|
|
263
|
+
DEFAULT_GRAPH_CONFIG,
|
|
264
|
+
} from "@pipelex/mthds-ui";
|
|
265
|
+
|
|
266
|
+
// Build graph data from a GraphSpec
|
|
267
|
+
const { graphData, analysis } = buildGraph(graphspec, "bezier");
|
|
268
|
+
|
|
269
|
+
// Apply ELK layout
|
|
270
|
+
const { nodes, edges } = getLayoutedElements(graphData.nodes, graphData.edges, "TB");
|
|
271
|
+
|
|
272
|
+
// Optionally wrap nodes in controller groups
|
|
273
|
+
const final = applyControllers(nodes, edges, graphspec, analysis, true);
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
## Shiki integration
|
|
277
|
+
|
|
278
|
+
Syntax-highlight MTHDS code with the bundled grammar and themes:
|
|
279
|
+
|
|
280
|
+
```typescript
|
|
281
|
+
import { highlightMthds, getAvailableThemes } from "@pipelex/mthds-ui/shiki";
|
|
282
|
+
|
|
283
|
+
const html = await highlightMthds(mthdsSource, "pipelex-dark");
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
## Development
|
|
287
|
+
|
|
288
|
+
```bash
|
|
289
|
+
npm install
|
|
290
|
+
make check # lint + format-check + typecheck
|
|
291
|
+
make test # unit tests (vitest)
|
|
292
|
+
make build # build to dist/
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
## License
|
|
296
|
+
|
|
297
|
+
MIT — see [LICENSE](./LICENSE).
|
|
298
|
+
|
|
299
|
+
This project depends on [elkjs](https://github.com/kieler/elkjs) which is licensed under [EPL-2.0](https://www.eclipse.org/legal/epl-2.0/). See [NOTICE](./NOTICE) for third-party license details.
|