@dudko.dev/agent-web-react 0.0.25 → 0.0.27
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 +123 -28
- package/dist/chunk-LCJZEGB5.js +147 -0
- package/dist/chunk-LCJZEGB5.js.map +1 -0
- package/dist/index.js +324 -413
- package/dist/index.js.map +1 -1
- package/dist/mcp.cjs +65 -35
- package/dist/mcp.cjs.map +1 -1
- package/dist/mcp.d.cts +43 -13
- package/dist/mcp.d.ts +43 -13
- package/dist/mcp.js +64 -35
- package/dist/mcp.js.map +1 -1
- package/dist/pipeline.cjs +3485 -0
- package/dist/pipeline.cjs.map +1 -0
- package/dist/pipeline.css +1407 -0
- package/dist/pipeline.d.cts +830 -0
- package/dist/pipeline.d.ts +830 -0
- package/dist/pipeline.js +3390 -0
- package/dist/pipeline.js.map +1 -0
- package/package.json +33 -20
|
@@ -0,0 +1,830 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ReactNode, CSSProperties } from 'react';
|
|
3
|
+
import { PipelineDefinition, PipelineCondition, PipelineNode, PipelineIssue, AgentEvent, PipelineResult, IUsage, PipelineStop, PipelineValidation, PipelineOptions, NodeResolverOptions, PipelineNodeRunner, AgentEventHandler } from '@dudko.dev/agent-web';
|
|
4
|
+
export { NodeResolverOptions, PIPELINE_LIMITS, Pipeline, PipelineCondition, PipelineDefinition, PipelineEdge, PipelineEvent, PipelineIssue, PipelineNode, PipelineNodeError, PipelineOptions, PipelineResult, PipelineRoute, PipelineRunOptions, PipelineStop, PipelineValidation, PipelineValidationError, createPipeline, nodeResolver, normalizePipeline, validatePipeline } from '@dudko.dev/agent-web';
|
|
5
|
+
|
|
6
|
+
interface Point {
|
|
7
|
+
x: number;
|
|
8
|
+
y: number;
|
|
9
|
+
}
|
|
10
|
+
interface Size {
|
|
11
|
+
width: number;
|
|
12
|
+
height: number;
|
|
13
|
+
}
|
|
14
|
+
interface Rect extends Point, Size {
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Where the world sits on the screen: a world point `p` is drawn at
|
|
18
|
+
* `p * zoom + (x, y)`, in pixels from the canvas's top-left corner.
|
|
19
|
+
*/
|
|
20
|
+
interface Viewport {
|
|
21
|
+
x: number;
|
|
22
|
+
y: number;
|
|
23
|
+
zoom: number;
|
|
24
|
+
}
|
|
25
|
+
/** The four control points of a cubic Bezier curve. */
|
|
26
|
+
interface Curve {
|
|
27
|
+
p0: Point;
|
|
28
|
+
p1: Point;
|
|
29
|
+
p2: Point;
|
|
30
|
+
p3: Point;
|
|
31
|
+
}
|
|
32
|
+
declare const DEFAULT_MIN_ZOOM = 0.25;
|
|
33
|
+
declare const DEFAULT_MAX_ZOOM = 2;
|
|
34
|
+
declare const IDENTITY_VIEWPORT: Viewport;
|
|
35
|
+
declare const clamp: (value: number, min: number, max: number) => number;
|
|
36
|
+
declare const screenToWorld: (point: Point, viewport: Viewport) => Point;
|
|
37
|
+
declare const worldToScreen: (point: Point, viewport: Viewport) => Point;
|
|
38
|
+
declare const panBy: (viewport: Viewport, dx: number, dy: number) => Viewport;
|
|
39
|
+
/** Set the zoom, keeping the world point under `anchor` (a screen point) where it is. */
|
|
40
|
+
declare const zoomAt: (viewport: Viewport, zoom: number, anchor: Point, minZoom?: number, maxZoom?: number) => Viewport;
|
|
41
|
+
/**
|
|
42
|
+
* Two fingers moved from `before` to `after` (screen points): zoom by how far apart they went,
|
|
43
|
+
* and keep the world point that was between them under the point that is between them now.
|
|
44
|
+
*/
|
|
45
|
+
declare const pinchViewport: (viewport: Viewport, before: [Point, Point], after: [Point, Point], minZoom?: number, maxZoom?: number) => Viewport;
|
|
46
|
+
/** The smallest rectangle around all of `rects`; undefined when there are none. */
|
|
47
|
+
declare const boundsOf: (rects: Rect[]) => Rect | undefined;
|
|
48
|
+
interface FitOptions {
|
|
49
|
+
/** Free space kept around the content, in screen pixels (default 48). */
|
|
50
|
+
padding?: number;
|
|
51
|
+
minZoom?: number;
|
|
52
|
+
/** Fitting never zooms in past this (default 1: a small graph is not blown up). */
|
|
53
|
+
maxZoom?: number;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* The viewport that shows all of `rects` centred in a canvas of `size`. When they do not fit at
|
|
57
|
+
* `minZoom`, it shows them from their top-left corner at that zoom instead.
|
|
58
|
+
*/
|
|
59
|
+
declare const fitViewport: (rects: Rect[], size: Size, options?: FitOptions) => Viewport;
|
|
60
|
+
/** The viewport with `rect` in the middle of a canvas of `size`, at the zoom given. */
|
|
61
|
+
declare const centerOn: (rect: Rect, size: Size, zoom: number) => Viewport;
|
|
62
|
+
/** Is any part of `rect` (world) inside a canvas of `size` under `viewport`? */
|
|
63
|
+
declare const isRectVisible: (rect: Rect, size: Size, viewport: Viewport) => boolean;
|
|
64
|
+
declare const snapTo: (value: number, grid: number) => number;
|
|
65
|
+
declare const snapPoint: (point: Point, grid: number) => Point;
|
|
66
|
+
declare const rectContains: (rect: Rect, point: Point) => boolean;
|
|
67
|
+
/** The id of the node under `point` (world). Later nodes are drawn on top, so they win. */
|
|
68
|
+
declare const hitNode: <T extends Rect & {
|
|
69
|
+
id: string;
|
|
70
|
+
}>(nodes: T[], point: Point) => string | undefined;
|
|
71
|
+
/** Where an edge enters a node: the middle of its left side. */
|
|
72
|
+
declare const inputAnchor: (rect: Rect) => Point;
|
|
73
|
+
/** Where an edge leaves a node that has `count` output ports: spread down its right side. */
|
|
74
|
+
declare const outputAnchor: (rect: Rect, index?: number, count?: number) => Point;
|
|
75
|
+
interface EdgeCurveOptions {
|
|
76
|
+
/**
|
|
77
|
+
* How far an edge that runs backwards (its target is to the left of its source) swings below
|
|
78
|
+
* the two nodes so that it does not cross them (default 90).
|
|
79
|
+
*/
|
|
80
|
+
clearance?: number;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* The curve of an edge that leaves `from` to the right and enters `to` from the left. A forward
|
|
84
|
+
* edge is a plain S; a backward one (a loop) swings out and around.
|
|
85
|
+
*/
|
|
86
|
+
declare const edgeCurve: (from: Point, to: Point, options?: EdgeCurveOptions) => Curve;
|
|
87
|
+
/** The SVG path data of a curve. */
|
|
88
|
+
declare const curvePath: ({ p0, p1, p2, p3 }: Curve) => string;
|
|
89
|
+
/** The point of a curve at `t` in 0..1. */
|
|
90
|
+
declare const curvePoint: ({ p0, p1, p2, p3 }: Curve, t: number) => Point;
|
|
91
|
+
/** How far `point` is from a curve (the curve is walked in `samples` straight pieces). */
|
|
92
|
+
declare const distanceToCurve: (curve: Curve, point: Point, samples?: number) => number;
|
|
93
|
+
/** The id of the edge within `tolerance` of `point`, the nearest one when several are. */
|
|
94
|
+
declare const hitEdge: (edges: {
|
|
95
|
+
id: string;
|
|
96
|
+
curve: Curve;
|
|
97
|
+
}[], point: Point, tolerance?: number) => string | undefined;
|
|
98
|
+
/**
|
|
99
|
+
* The order a keyboard walks the nodes in: left to right, then top to bottom - the direction a
|
|
100
|
+
* graph that flows from its entry to its end is read in. Nodes in the same column (within
|
|
101
|
+
* `column` pixels) count as level.
|
|
102
|
+
*/
|
|
103
|
+
declare const readingOrder: <T extends Point & {
|
|
104
|
+
id: string;
|
|
105
|
+
}>(nodes: T[], column?: number) => string[];
|
|
106
|
+
|
|
107
|
+
interface CanvasPortSpec {
|
|
108
|
+
id: string;
|
|
109
|
+
/** What a screen reader calls it ("approved"). */
|
|
110
|
+
label?: string;
|
|
111
|
+
}
|
|
112
|
+
interface CanvasNode {
|
|
113
|
+
id: string;
|
|
114
|
+
x: number;
|
|
115
|
+
y: number;
|
|
116
|
+
/** Used until the node is measured (and where nothing can be: a server render). */
|
|
117
|
+
width?: number;
|
|
118
|
+
height?: number;
|
|
119
|
+
/** The node's name for a screen reader. */
|
|
120
|
+
label: string;
|
|
121
|
+
/** More for a screen reader: its state ("running, visit 2"). */
|
|
122
|
+
description?: string;
|
|
123
|
+
/**
|
|
124
|
+
* Its output ports. Without this the canvas draws one port on the node's right side. With it,
|
|
125
|
+
* `renderNode` places a `<CanvasPort id>` for each wherever it likes.
|
|
126
|
+
*/
|
|
127
|
+
ports?: CanvasPortSpec[];
|
|
128
|
+
}
|
|
129
|
+
type CanvasEdgeTone = 'default' | 'active' | 'done' | 'muted' | 'danger';
|
|
130
|
+
interface CanvasEdge {
|
|
131
|
+
id: string;
|
|
132
|
+
from: string;
|
|
133
|
+
to: string;
|
|
134
|
+
/** The port of `from` it leaves by (default: the node's first port). */
|
|
135
|
+
fromPort?: string;
|
|
136
|
+
/** Shown on the edge, at its middle. */
|
|
137
|
+
label?: string;
|
|
138
|
+
/** What a screen reader hears after "from A to B". Defaults to `label`. */
|
|
139
|
+
description?: string;
|
|
140
|
+
tone?: CanvasEdgeTone;
|
|
141
|
+
}
|
|
142
|
+
type CanvasSelection = {
|
|
143
|
+
kind: 'node' | 'edge';
|
|
144
|
+
id: string;
|
|
145
|
+
} | null;
|
|
146
|
+
interface CanvasConnection {
|
|
147
|
+
from: string;
|
|
148
|
+
fromPort?: string;
|
|
149
|
+
to: string;
|
|
150
|
+
}
|
|
151
|
+
/** Every string the canvas shows or says. */
|
|
152
|
+
interface CanvasLabels {
|
|
153
|
+
/** The canvas's own name for a screen reader. */
|
|
154
|
+
canvas: string;
|
|
155
|
+
/** How to use it with a keyboard; read once, when the canvas is focused. */
|
|
156
|
+
help: string;
|
|
157
|
+
/** `aria-roledescription` of a node. */
|
|
158
|
+
node: string;
|
|
159
|
+
edge: (from: string, to: string, description?: string) => string;
|
|
160
|
+
port: (node: string, port?: string) => string;
|
|
161
|
+
connectsTo: (names: string) => string;
|
|
162
|
+
receivesFrom: (names: string) => string;
|
|
163
|
+
zoomIn: string;
|
|
164
|
+
zoomOut: string;
|
|
165
|
+
fit: string;
|
|
166
|
+
zoomLevel: (percent: number) => string;
|
|
167
|
+
/** Shown (and announced) while a connection is being made without dragging. */
|
|
168
|
+
connectHint: (from: string) => string;
|
|
169
|
+
cancel: string;
|
|
170
|
+
connected: (from: string, to: string) => string;
|
|
171
|
+
}
|
|
172
|
+
declare const defaultCanvasLabels: CanvasLabels;
|
|
173
|
+
interface CanvasNodeState {
|
|
174
|
+
selected: boolean;
|
|
175
|
+
dragging: boolean;
|
|
176
|
+
/** A connection is being made and this node can take it. */
|
|
177
|
+
connectable: boolean;
|
|
178
|
+
}
|
|
179
|
+
interface CanvasHandle {
|
|
180
|
+
/** Show everything. */
|
|
181
|
+
fit: () => void;
|
|
182
|
+
zoomIn: () => void;
|
|
183
|
+
zoomOut: () => void;
|
|
184
|
+
/** Put a node or an edge in view and move the keyboard focus to it. */
|
|
185
|
+
focus: (target: NonNullable<CanvasSelection>) => void;
|
|
186
|
+
/** Scroll a node into the middle of the view. */
|
|
187
|
+
center: (nodeId: string) => void;
|
|
188
|
+
/** The same, but only when no part of the node is in view. */
|
|
189
|
+
reveal: (nodeId: string) => void;
|
|
190
|
+
getViewport: () => Viewport;
|
|
191
|
+
/** The canvas's size on the screen, in pixels. */
|
|
192
|
+
getSize: () => Size;
|
|
193
|
+
}
|
|
194
|
+
interface CanvasProps {
|
|
195
|
+
nodes: CanvasNode[];
|
|
196
|
+
edges: CanvasEdge[];
|
|
197
|
+
renderNode: (node: CanvasNode, state: CanvasNodeState) => ReactNode;
|
|
198
|
+
selection?: CanvasSelection;
|
|
199
|
+
onSelectionChange?: (selection: CanvasSelection) => void;
|
|
200
|
+
/** Controlled viewport. Leave both out and the canvas keeps its own. */
|
|
201
|
+
viewport?: Viewport;
|
|
202
|
+
onViewportChange?: (viewport: Viewport) => void;
|
|
203
|
+
/** A node is being dragged, or was moved with the arrow keys. */
|
|
204
|
+
onNodeMove?: (id: string, position: Point) => void;
|
|
205
|
+
/** The drag ended (or the key was pressed): the place to save. */
|
|
206
|
+
onNodeMoveEnd?: (id: string, position: Point) => void;
|
|
207
|
+
/** A port was dragged (or keyboard-connected) to another node. */
|
|
208
|
+
onConnect?: (connection: CanvasConnection) => void;
|
|
209
|
+
/** Delete / Backspace on a node or an edge. */
|
|
210
|
+
onDelete?: (target: NonNullable<CanvasSelection>) => void;
|
|
211
|
+
/** Enter or a double click on a node or an edge. */
|
|
212
|
+
onOpen?: (target: NonNullable<CanvasSelection>) => void;
|
|
213
|
+
/** Grid step nodes snap to, in world pixels (default 20; 0 = no snapping). */
|
|
214
|
+
snap?: number;
|
|
215
|
+
/** The dot grid behind the graph (default true). */
|
|
216
|
+
showGrid?: boolean;
|
|
217
|
+
/** The zoom buttons in the corner (default true). */
|
|
218
|
+
showControls?: boolean;
|
|
219
|
+
minZoom?: number;
|
|
220
|
+
maxZoom?: number;
|
|
221
|
+
/** Fit the graph when the canvas first has a size (default true; ignored when controlled). */
|
|
222
|
+
fitOnMount?: boolean;
|
|
223
|
+
/** Change it to fit again - a new document was loaded. */
|
|
224
|
+
fitKey?: string | number;
|
|
225
|
+
/**
|
|
226
|
+
* The smallest zoom the canvas fits to BY ITSELF (on mount, on `fitKey`, when its box changes).
|
|
227
|
+
* A wide graph on a phone is then readable from its start rather than whole and tiny; the Fit
|
|
228
|
+
* button still shows everything. Default: `minZoom`.
|
|
229
|
+
*/
|
|
230
|
+
autoFitMinZoom?: number;
|
|
231
|
+
/** Look, pan and zoom only: nothing can be moved, connected or deleted. */
|
|
232
|
+
readOnly?: boolean;
|
|
233
|
+
labels?: Partial<CanvasLabels>;
|
|
234
|
+
className?: string;
|
|
235
|
+
style?: CSSProperties;
|
|
236
|
+
/** Drawn over the canvas, outside the zoomed layer (a legend, an empty state). */
|
|
237
|
+
children?: ReactNode;
|
|
238
|
+
}
|
|
239
|
+
interface CanvasPortProps {
|
|
240
|
+
/** The port's id (default: the node's only port). */
|
|
241
|
+
id?: string;
|
|
242
|
+
/** Its name for a screen reader, when the node's `ports` does not give one. */
|
|
243
|
+
label?: string;
|
|
244
|
+
className?: string;
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* An output port: drag from it to another node to connect them, or press it and then the node.
|
|
248
|
+
* Place it inside what `renderNode` returns; an edge with this `fromPort` starts at its centre.
|
|
249
|
+
*/
|
|
250
|
+
declare const CanvasPort: ({ id, label, className }: CanvasPortProps) => react.JSX.Element;
|
|
251
|
+
/**
|
|
252
|
+
* The canvas. Nodes are HTML, edges are SVG; drag the background to pan, pinch or ctrl+wheel to
|
|
253
|
+
* zoom, drag a node to move it, drag a port to another node to connect them.
|
|
254
|
+
*/
|
|
255
|
+
declare const Canvas: react.ForwardRefExoticComponent<CanvasProps & react.RefAttributes<CanvasHandle>>;
|
|
256
|
+
|
|
257
|
+
type PipelineSelection = {
|
|
258
|
+
kind: 'node' | 'edge';
|
|
259
|
+
id: string;
|
|
260
|
+
} | null;
|
|
261
|
+
/** A definition to start from: one node, which is the entry. */
|
|
262
|
+
declare const emptyPipeline: () => PipelineDefinition;
|
|
263
|
+
/**
|
|
264
|
+
* The definition with an id on every edge. The runner hands ids out by position (`e0`, `e1`, …),
|
|
265
|
+
* which shift when an edge is removed - an editor needs them fixed, so it writes them down.
|
|
266
|
+
*/
|
|
267
|
+
declare const ensureEdgeIds: (definition: PipelineDefinition) => PipelineDefinition;
|
|
268
|
+
/** "Fact checker!" → "fact-checker". */
|
|
269
|
+
declare const slugifyId: (text: string) => string;
|
|
270
|
+
/** An id no node has: `base`, or `base-2`, `base-3`, … */
|
|
271
|
+
declare const uniqueNodeId: (definition: PipelineDefinition, base?: string) => string;
|
|
272
|
+
/** An id no edge has (`e0`, `e1`, …; the positional ids of unnamed edges count as taken). */
|
|
273
|
+
declare const uniqueEdgeId: (definition: PipelineDefinition) => string;
|
|
274
|
+
/**
|
|
275
|
+
* Add a node. Without an id it gets a free one (from its name, or `node`); an id that is taken
|
|
276
|
+
* is made unique. The first node of a pipeline becomes its entry.
|
|
277
|
+
*/
|
|
278
|
+
declare const addNode: (definition: PipelineDefinition, node?: Partial<PipelineNode>) => PipelineDefinition;
|
|
279
|
+
/** Change a node's fields (not its id: `renameNode`). An emptied field is removed. */
|
|
280
|
+
declare const updateNode: (definition: PipelineDefinition, id: string, patch: Partial<Omit<PipelineNode, "id">>) => PipelineDefinition;
|
|
281
|
+
declare const moveNode: (definition: PipelineDefinition, id: string, position: {
|
|
282
|
+
x: number;
|
|
283
|
+
y: number;
|
|
284
|
+
}) => PipelineDefinition;
|
|
285
|
+
/** Remove a node and every edge that touches it. The entry moves to the first node left. */
|
|
286
|
+
declare const removeNode: (definition: PipelineDefinition, id: string) => PipelineDefinition;
|
|
287
|
+
/** Give a node another id; its edges and the entry follow. Refused when the id is empty or taken. */
|
|
288
|
+
declare const renameNode: (definition: PipelineDefinition, id: string, nextId: string) => PipelineDefinition;
|
|
289
|
+
declare const setEntry: (definition: PipelineDefinition, id: string) => PipelineDefinition;
|
|
290
|
+
/**
|
|
291
|
+
* Connect two nodes. Refused when either does not exist, or when the same edge (the same ends
|
|
292
|
+
* and the same condition) is already there. The edge gets a free id unless it brings one.
|
|
293
|
+
*/
|
|
294
|
+
declare const addEdge: (definition: PipelineDefinition, edge: {
|
|
295
|
+
from: string;
|
|
296
|
+
to: string;
|
|
297
|
+
when?: PipelineCondition;
|
|
298
|
+
id?: string;
|
|
299
|
+
}) => PipelineDefinition;
|
|
300
|
+
/** Change an edge's condition or ends. An end that names no node is refused. */
|
|
301
|
+
declare const updateEdge: (definition: PipelineDefinition, id: string, patch: {
|
|
302
|
+
from?: string;
|
|
303
|
+
to?: string;
|
|
304
|
+
when?: PipelineCondition;
|
|
305
|
+
}) => PipelineDefinition;
|
|
306
|
+
declare const removeEdge: (definition: PipelineDefinition, id: string) => PipelineDefinition;
|
|
307
|
+
/** Rename one of a node's routes; the edges that take that route follow. */
|
|
308
|
+
declare const renameRoute: (definition: PipelineDefinition, nodeId: string, label: string, nextLabel: string) => PipelineDefinition;
|
|
309
|
+
/** Set (a number) or clear (undefined) the limits; a definition with none has no `limits`. */
|
|
310
|
+
declare const setLimits: (definition: PipelineDefinition, patch: {
|
|
311
|
+
maxNodeVisits?: number;
|
|
312
|
+
maxRuns?: number;
|
|
313
|
+
}) => PipelineDefinition;
|
|
314
|
+
declare const setPipelineName: (definition: PipelineDefinition, name: string) => PipelineDefinition;
|
|
315
|
+
interface AutoLayoutOptions {
|
|
316
|
+
/** Distance between the left sides of two columns (default 320). */
|
|
317
|
+
columnGap?: number;
|
|
318
|
+
/** Distance between the tops of two nodes of a column (default 170). */
|
|
319
|
+
rowGap?: number;
|
|
320
|
+
/** Place every node, not only the ones without a position. */
|
|
321
|
+
all?: boolean;
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* Give a position to the nodes that have none (a definition written by hand, or by a model):
|
|
325
|
+
* columns by distance from the entry, left to right. Nodes the entry does not reach go last.
|
|
326
|
+
*/
|
|
327
|
+
declare const autoLayout: (definition: PipelineDefinition, options?: AutoLayoutOptions) => PipelineDefinition;
|
|
328
|
+
/** A free spot for a new node: to the right of the lowest node of the last column. */
|
|
329
|
+
declare const nextNodePosition: (definition: PipelineDefinition) => {
|
|
330
|
+
x: number;
|
|
331
|
+
y: number;
|
|
332
|
+
};
|
|
333
|
+
/** What a validation issue is about, as something to select. */
|
|
334
|
+
declare const issueTarget: (issue: PipelineIssue, definition: PipelineDefinition) => PipelineSelection;
|
|
335
|
+
/**
|
|
336
|
+
* Read a definition from text (an imported file, a paste). Throws with a plain message when the
|
|
337
|
+
* text is not JSON or not the shape of a pipeline; a definition that parses but does not
|
|
338
|
+
* validate is returned as it is, for the editor to show what is wrong with it.
|
|
339
|
+
*/
|
|
340
|
+
declare const parsePipelineJson: (text: string) => PipelineDefinition;
|
|
341
|
+
|
|
342
|
+
type PipelineRunStatus = 'idle' | 'running' | 'done' | 'failed' | 'stopped';
|
|
343
|
+
/**
|
|
344
|
+
* `waiting`: an edge fired towards the node and it has not started yet (it waits for its wave,
|
|
345
|
+
* or for the other branch of a fan-in). `skipped`: a cap refused the visit.
|
|
346
|
+
*/
|
|
347
|
+
type PipelineNodeStatus = 'idle' | 'waiting' | 'running' | 'done' | 'failed' | 'skipped';
|
|
348
|
+
/** What the node's own agent is doing right now, in one line's worth. */
|
|
349
|
+
interface PipelineNodeActivity {
|
|
350
|
+
phase?: 'plan' | 'execute' | 'replan' | 'synthesize';
|
|
351
|
+
/** The plan step in progress, with its place in the plan (1-based, as the core counts). */
|
|
352
|
+
step?: string;
|
|
353
|
+
stepIndex?: number;
|
|
354
|
+
stepTotal?: number;
|
|
355
|
+
/** The tool being called, while it runs. */
|
|
356
|
+
tool?: string;
|
|
357
|
+
/** Tool calls made in this visit so far. */
|
|
358
|
+
toolCalls: number;
|
|
359
|
+
}
|
|
360
|
+
interface PipelineOutputView {
|
|
361
|
+
visit: number;
|
|
362
|
+
text: string;
|
|
363
|
+
route?: string;
|
|
364
|
+
}
|
|
365
|
+
interface PipelineNodeView {
|
|
366
|
+
status: PipelineNodeStatus;
|
|
367
|
+
/** Visits started. */
|
|
368
|
+
visits: number;
|
|
369
|
+
/** The nodes whose outputs the current (or last) visit received. */
|
|
370
|
+
from: string[];
|
|
371
|
+
/** One entry per finished visit, in order. */
|
|
372
|
+
outputs: PipelineOutputView[];
|
|
373
|
+
activity?: PipelineNodeActivity;
|
|
374
|
+
error?: string;
|
|
375
|
+
/** Why the last activation was refused. */
|
|
376
|
+
skipped?: 'maxRuns' | 'maxNodeVisits';
|
|
377
|
+
/** Tokens of all its finished visits. */
|
|
378
|
+
usage?: IUsage;
|
|
379
|
+
}
|
|
380
|
+
interface PipelineEdgeView {
|
|
381
|
+
from: string;
|
|
382
|
+
to: string;
|
|
383
|
+
/** The last decision. */
|
|
384
|
+
fired: boolean;
|
|
385
|
+
/** The visit of the source node that decided it. */
|
|
386
|
+
visit: number;
|
|
387
|
+
/** How many times it fired in this run. */
|
|
388
|
+
count: number;
|
|
389
|
+
/** It fired and what it carries has not been consumed yet: the target waits or runs. */
|
|
390
|
+
live: boolean;
|
|
391
|
+
}
|
|
392
|
+
/** One node visit, in the order visits started: the run as a timeline. */
|
|
393
|
+
interface PipelineVisitView {
|
|
394
|
+
nodeId: string;
|
|
395
|
+
visit: number;
|
|
396
|
+
from: string[];
|
|
397
|
+
status: 'running' | 'done' | 'failed' | 'stopped';
|
|
398
|
+
text?: string;
|
|
399
|
+
route?: string;
|
|
400
|
+
error?: string;
|
|
401
|
+
usage?: IUsage;
|
|
402
|
+
}
|
|
403
|
+
interface PipelineUiState {
|
|
404
|
+
status: PipelineRunStatus;
|
|
405
|
+
/** The request of the current (or last) run. */
|
|
406
|
+
input?: string;
|
|
407
|
+
/** The definition's name, as the run reported it. */
|
|
408
|
+
name?: string;
|
|
409
|
+
/** By node id. A node the run has not touched is absent: read it with `pipelineNodeView`. */
|
|
410
|
+
nodes: Record<string, PipelineNodeView>;
|
|
411
|
+
/** By edge id: the last decision on each edge that was decided. */
|
|
412
|
+
edges: Record<string, PipelineEdgeView>;
|
|
413
|
+
/** The edges the node that finished last fired. */
|
|
414
|
+
lastFired: string[];
|
|
415
|
+
visits: PipelineVisitView[];
|
|
416
|
+
/** The final text (set when the run ends). */
|
|
417
|
+
text: string;
|
|
418
|
+
usage: IUsage;
|
|
419
|
+
/** Node visits started. */
|
|
420
|
+
runs: number;
|
|
421
|
+
stoppedBy?: PipelineStop;
|
|
422
|
+
error?: string;
|
|
423
|
+
/** The node whose failure ended the run. */
|
|
424
|
+
failedNode?: string;
|
|
425
|
+
}
|
|
426
|
+
type PipelineAction = {
|
|
427
|
+
type: 'run.start';
|
|
428
|
+
input: string;
|
|
429
|
+
} | {
|
|
430
|
+
type: 'event';
|
|
431
|
+
event: AgentEvent;
|
|
432
|
+
}
|
|
433
|
+
/** `run` resolved. */
|
|
434
|
+
| {
|
|
435
|
+
type: 'run.result';
|
|
436
|
+
result: PipelineResult;
|
|
437
|
+
}
|
|
438
|
+
/** `run` rejected, or could not start. */
|
|
439
|
+
| {
|
|
440
|
+
type: 'run.error';
|
|
441
|
+
error: string;
|
|
442
|
+
nodeId?: string;
|
|
443
|
+
} | {
|
|
444
|
+
type: 'reset';
|
|
445
|
+
};
|
|
446
|
+
declare const createInitialPipelineState: () => PipelineUiState;
|
|
447
|
+
/** A node's view; an idle one for a node the run has not touched. */
|
|
448
|
+
declare const pipelineNodeView: (state: PipelineUiState, nodeId: string) => PipelineNodeView;
|
|
449
|
+
/** Fold one action into the state. Returns the same object when nothing changed. */
|
|
450
|
+
declare const pipelineStateReducer: (state: PipelineUiState, action: PipelineAction) => PipelineUiState;
|
|
451
|
+
|
|
452
|
+
type ConditionKind = PipelineCondition['kind'];
|
|
453
|
+
/**
|
|
454
|
+
* Every string the pipeline editor renders or says - override any of them for another language
|
|
455
|
+
* or wording, per component (`labels` prop) or for a whole tree (`<PipelineLabelsProvider>`).
|
|
456
|
+
* Counted phrases are functions. The reference with the defaults is in docs/pipeline.md.
|
|
457
|
+
*/
|
|
458
|
+
interface PipelineLabels {
|
|
459
|
+
toolbar: string;
|
|
460
|
+
addNode: string;
|
|
461
|
+
deleteSelected: string;
|
|
462
|
+
fit: string;
|
|
463
|
+
zoomIn: string;
|
|
464
|
+
zoomOut: string;
|
|
465
|
+
importJson: string;
|
|
466
|
+
exportJson: string;
|
|
467
|
+
copyCode: string;
|
|
468
|
+
/** The name a new node gets ("Agent 3"). */
|
|
469
|
+
newNodeName: (n: number) => string;
|
|
470
|
+
importFailed: (reason: string) => string;
|
|
471
|
+
issues: string;
|
|
472
|
+
noIssues: string;
|
|
473
|
+
errors: (n: number) => string;
|
|
474
|
+
warnings: (n: number) => string;
|
|
475
|
+
issueError: string;
|
|
476
|
+
issueWarning: string;
|
|
477
|
+
/** The canvas's own strings (its name, its keyboard help, what a port and an edge are called). */
|
|
478
|
+
canvas: CanvasLabels;
|
|
479
|
+
emptyCanvas: string;
|
|
480
|
+
/** The node's state for a screen reader: "running, visit 2". */
|
|
481
|
+
nodeDescription: (status: string, visits: number) => string;
|
|
482
|
+
nodeStatus: Record<PipelineNodeStatus, string>;
|
|
483
|
+
entry: string;
|
|
484
|
+
defaultModel: string;
|
|
485
|
+
skillsBadge: (n: number) => string;
|
|
486
|
+
toolsBadge: (n: number) => string;
|
|
487
|
+
mcpBadge: (n: number) => string;
|
|
488
|
+
visits: (n: number) => string;
|
|
489
|
+
/** The output port of a node with routes that takes no route: every other kind of edge. */
|
|
490
|
+
anyOutput: string;
|
|
491
|
+
activityPlanning: string;
|
|
492
|
+
activityReplanning: string;
|
|
493
|
+
activityAnswering: string;
|
|
494
|
+
activityStep: (index: number, total: number, step: string) => string;
|
|
495
|
+
activityTool: (name: string) => string;
|
|
496
|
+
skippedBy: Record<'maxRuns' | 'maxNodeVisits', string>;
|
|
497
|
+
inspector: string;
|
|
498
|
+
inspectorNode: string;
|
|
499
|
+
inspectorEdge: string;
|
|
500
|
+
inspectorPipeline: string;
|
|
501
|
+
close: string;
|
|
502
|
+
expand: string;
|
|
503
|
+
collapse: string;
|
|
504
|
+
fieldId: string;
|
|
505
|
+
fieldIdHint: string;
|
|
506
|
+
idTaken: string;
|
|
507
|
+
idEmpty: string;
|
|
508
|
+
fieldName: string;
|
|
509
|
+
fieldInstructions: string;
|
|
510
|
+
instructionsPlaceholder: string;
|
|
511
|
+
fieldModel: string;
|
|
512
|
+
/** An option that is in the definition but not in the host's list. */
|
|
513
|
+
unknownOption: (name: string) => string;
|
|
514
|
+
fieldSkills: string;
|
|
515
|
+
fieldTools: string;
|
|
516
|
+
fieldMcp: string;
|
|
517
|
+
noOptions: string;
|
|
518
|
+
fieldRoutes: string;
|
|
519
|
+
routesHint: string;
|
|
520
|
+
routeLabel: string;
|
|
521
|
+
routeDescription: string;
|
|
522
|
+
addRoute: string;
|
|
523
|
+
removeRoute: (label: string) => string;
|
|
524
|
+
fieldJoin: string;
|
|
525
|
+
joinAll: string;
|
|
526
|
+
joinAny: string;
|
|
527
|
+
isEntry: string;
|
|
528
|
+
makeEntry: string;
|
|
529
|
+
deleteNode: string;
|
|
530
|
+
edgeEnds: (from: string, to: string) => string;
|
|
531
|
+
fieldCondition: string;
|
|
532
|
+
conditionKinds: Record<ConditionKind, string>;
|
|
533
|
+
conditionHints: Record<ConditionKind, string>;
|
|
534
|
+
fieldText: string;
|
|
535
|
+
caseSensitive: string;
|
|
536
|
+
fieldPattern: string;
|
|
537
|
+
fieldFlags: string;
|
|
538
|
+
fieldRoute: string;
|
|
539
|
+
noRoutes: string;
|
|
540
|
+
deleteEdge: string;
|
|
541
|
+
pipelineName: string;
|
|
542
|
+
pipelineNamePlaceholder: string;
|
|
543
|
+
fieldEntry: string;
|
|
544
|
+
fieldMaxNodeVisits: string;
|
|
545
|
+
fieldMaxRuns: string;
|
|
546
|
+
limitDefault: (n: number) => string;
|
|
547
|
+
counts: (nodes: number, edges: number) => string;
|
|
548
|
+
runPlaceholder: string;
|
|
549
|
+
runInput: string;
|
|
550
|
+
run: string;
|
|
551
|
+
stop: string;
|
|
552
|
+
fixErrorsFirst: string;
|
|
553
|
+
runStatus: Record<PipelineRunStatus, string>;
|
|
554
|
+
stoppedBy: Record<PipelineStop, string>;
|
|
555
|
+
/** Announced to a screen reader as nodes start, finish, fail. */
|
|
556
|
+
announceNode: (name: string, status: string) => string;
|
|
557
|
+
results: string;
|
|
558
|
+
showResults: string;
|
|
559
|
+
hideResults: string;
|
|
560
|
+
finalAnswer: string;
|
|
561
|
+
nodeOutputs: string;
|
|
562
|
+
noOutputYet: string;
|
|
563
|
+
visitTitle: (name: string, visit: number) => string;
|
|
564
|
+
routeTaken: (label: string) => string;
|
|
565
|
+
receivedFrom: (names: string) => string;
|
|
566
|
+
usage: (input: string, output: string) => string;
|
|
567
|
+
runsCount: (n: number) => string;
|
|
568
|
+
codeTitle: string;
|
|
569
|
+
codeBrowser: string;
|
|
570
|
+
codeNode: string;
|
|
571
|
+
copy: string;
|
|
572
|
+
copied: string;
|
|
573
|
+
}
|
|
574
|
+
declare const defaultPipelineLabels: PipelineLabels;
|
|
575
|
+
declare const NESTED: readonly ["canvas", "nodeStatus", "skippedBy", "conditionKinds", "conditionHints", "runStatus", "stoppedBy"];
|
|
576
|
+
type Nested = (typeof NESTED)[number];
|
|
577
|
+
/** Overrides: any label, with the nested groups merged key by key. */
|
|
578
|
+
type PipelineLabelsOverride = Partial<Omit<PipelineLabels, Nested>> & {
|
|
579
|
+
[K in Nested]?: Partial<PipelineLabels[K]>;
|
|
580
|
+
};
|
|
581
|
+
/** `base` with `over` applied (nested groups merged, not replaced). */
|
|
582
|
+
declare const mergePipelineLabels: (base: PipelineLabels, over?: PipelineLabelsOverride) => PipelineLabels;
|
|
583
|
+
interface PipelineLabelsProviderProps {
|
|
584
|
+
labels: PipelineLabelsOverride;
|
|
585
|
+
children?: ReactNode;
|
|
586
|
+
}
|
|
587
|
+
/** Override labels for every pipeline component below (nests: inner providers win). */
|
|
588
|
+
declare const PipelineLabelsProvider: ({ labels, children }: PipelineLabelsProviderProps) => react.JSX.Element;
|
|
589
|
+
/** The labels in effect: the provider's, with a component's own `labels` prop on top. */
|
|
590
|
+
declare const usePipelineLabels: (over?: PipelineLabelsOverride) => PipelineLabels;
|
|
591
|
+
|
|
592
|
+
/** Something a node may name: a model, a skill, a group of tools, an MCP server. */
|
|
593
|
+
interface PipelineOption {
|
|
594
|
+
/** The name written into the definition. */
|
|
595
|
+
id: string;
|
|
596
|
+
/** What the person sees (default: the id). */
|
|
597
|
+
label?: string;
|
|
598
|
+
description?: string;
|
|
599
|
+
}
|
|
600
|
+
interface PipelineInspectorProps {
|
|
601
|
+
value: PipelineDefinition;
|
|
602
|
+
onChange: (next: PipelineDefinition) => void;
|
|
603
|
+
selection: PipelineSelection;
|
|
604
|
+
onSelectionChange?: (selection: PipelineSelection) => void;
|
|
605
|
+
/** What the host can resolve; a node picks from these. */
|
|
606
|
+
models?: PipelineOption[];
|
|
607
|
+
skills?: PipelineOption[];
|
|
608
|
+
tools?: PipelineOption[];
|
|
609
|
+
mcpServers?: PipelineOption[];
|
|
610
|
+
readOnly?: boolean;
|
|
611
|
+
/** Under the fields of whatever is selected. */
|
|
612
|
+
footer?: ReactNode;
|
|
613
|
+
labels?: PipelineLabelsOverride;
|
|
614
|
+
}
|
|
615
|
+
/** What the inspector is showing, for a heading: the kind and the name. */
|
|
616
|
+
declare const inspectorTitle: (value: PipelineDefinition, selection: PipelineSelection, labels: PipelineLabels) => {
|
|
617
|
+
kind: string;
|
|
618
|
+
name: string;
|
|
619
|
+
};
|
|
620
|
+
/**
|
|
621
|
+
* The fields of whatever is selected: a node, a connection, or - with nothing selected - the
|
|
622
|
+
* pipeline itself. Controlled: every edit goes out through `onChange` as a new definition.
|
|
623
|
+
*/
|
|
624
|
+
declare const PipelineInspector: (props: PipelineInspectorProps) => react.JSX.Element;
|
|
625
|
+
|
|
626
|
+
/** What the editor needs to run a pipeline and show the run: what `usePipeline` returns. */
|
|
627
|
+
interface PipelineController extends PipelineUiState {
|
|
628
|
+
run: (input: string) => Promise<unknown>;
|
|
629
|
+
stop: () => void;
|
|
630
|
+
isRunning: boolean;
|
|
631
|
+
}
|
|
632
|
+
interface PipelineEditorSlots {
|
|
633
|
+
/** Before / after the toolbar's own buttons. */
|
|
634
|
+
toolbarStart?: ReactNode;
|
|
635
|
+
toolbarEnd?: ReactNode;
|
|
636
|
+
/** Over the canvas (a legend, a watermark of your own). */
|
|
637
|
+
canvas?: ReactNode;
|
|
638
|
+
/** Under the inspector's fields. */
|
|
639
|
+
inspectorFooter?: ReactNode;
|
|
640
|
+
/** After the Run button. */
|
|
641
|
+
runBarEnd?: ReactNode;
|
|
642
|
+
/** Under the results. */
|
|
643
|
+
resultsFooter?: ReactNode;
|
|
644
|
+
}
|
|
645
|
+
interface PipelineNodeRenderContext {
|
|
646
|
+
node: PipelineNode;
|
|
647
|
+
view: PipelineNodeView;
|
|
648
|
+
entry: boolean;
|
|
649
|
+
selected: boolean;
|
|
650
|
+
invalid: boolean;
|
|
651
|
+
/** The card the editor would draw. */
|
|
652
|
+
card: ReactNode;
|
|
653
|
+
}
|
|
654
|
+
interface PipelineEditorProps {
|
|
655
|
+
/** The definition. The editor never keeps its own copy: every edit goes out through `onChange`. */
|
|
656
|
+
value: PipelineDefinition;
|
|
657
|
+
onChange: (next: PipelineDefinition) => void;
|
|
658
|
+
/** `usePipeline(...)`: adds Run / Stop, live statuses and the results. Without it: an editor only. */
|
|
659
|
+
controller?: PipelineController;
|
|
660
|
+
/** What a node may name - the keys of the registries the host resolves. */
|
|
661
|
+
models?: PipelineOption[];
|
|
662
|
+
skills?: PipelineOption[];
|
|
663
|
+
tools?: PipelineOption[];
|
|
664
|
+
mcpServers?: PipelineOption[];
|
|
665
|
+
/** Controlled selection (optional). */
|
|
666
|
+
selection?: PipelineSelection;
|
|
667
|
+
onSelectionChange?: (selection: PipelineSelection) => void;
|
|
668
|
+
/** The request in the run bar (optional control). */
|
|
669
|
+
input?: string;
|
|
670
|
+
onInputChange?: (input: string) => void;
|
|
671
|
+
/** Checks the definition (default: the core's `validatePipeline`). */
|
|
672
|
+
validate?: (definition: PipelineDefinition) => PipelineValidation;
|
|
673
|
+
showToolbar?: boolean;
|
|
674
|
+
showInspector?: boolean;
|
|
675
|
+
showRunBar?: boolean;
|
|
676
|
+
showResults?: boolean;
|
|
677
|
+
showIssues?: boolean;
|
|
678
|
+
showImport?: boolean;
|
|
679
|
+
showExport?: boolean;
|
|
680
|
+
showCode?: boolean;
|
|
681
|
+
showZoom?: boolean;
|
|
682
|
+
showGrid?: boolean;
|
|
683
|
+
/** Grid step nodes snap to (default 20; 0 = no snapping). */
|
|
684
|
+
snap?: number;
|
|
685
|
+
/** Look and run, but do not edit. */
|
|
686
|
+
readOnly?: boolean;
|
|
687
|
+
/** Change it when another document is loaded: the canvas fits it. */
|
|
688
|
+
fitKey?: string | number;
|
|
689
|
+
/** Under this width the inspector is a bottom sheet and the toolbar is icons (default 760). */
|
|
690
|
+
narrowWidth?: number;
|
|
691
|
+
/** Replace the node card. */
|
|
692
|
+
renderNode?: (ctx: PipelineNodeRenderContext) => ReactNode;
|
|
693
|
+
/** Render a node's output or the final answer (Markdown, say). Default: plain text. */
|
|
694
|
+
renderContent?: (text: string) => ReactNode;
|
|
695
|
+
slots?: PipelineEditorSlots;
|
|
696
|
+
labels?: PipelineLabelsOverride;
|
|
697
|
+
/** Force a colour scheme (default: the system's). */
|
|
698
|
+
theme?: 'light' | 'dark';
|
|
699
|
+
className?: string;
|
|
700
|
+
}
|
|
701
|
+
/** What an edge's condition reads as on the canvas ("" for an edge that always fires). */
|
|
702
|
+
declare const conditionSummary: (when: PipelineCondition | undefined, labels: PipelineLabels) => string;
|
|
703
|
+
interface PipelineCodeDialogProps {
|
|
704
|
+
definition: PipelineDefinition;
|
|
705
|
+
open: boolean;
|
|
706
|
+
onClose: () => void;
|
|
707
|
+
/** The request in the snippet's example call. */
|
|
708
|
+
input?: string;
|
|
709
|
+
labels?: PipelineLabelsOverride;
|
|
710
|
+
}
|
|
711
|
+
/** "Copy as code": the definition as a snippet for the browser package or for the Node one. */
|
|
712
|
+
declare const PipelineCodeDialog: ({ definition, open, onClose, input, labels: over, }: PipelineCodeDialogProps) => react.JSX.Element;
|
|
713
|
+
interface PipelineResultsProps {
|
|
714
|
+
/** The run: `usePipeline(...)`, or any `PipelineUiState`. */
|
|
715
|
+
state: PipelineUiState;
|
|
716
|
+
/** For the names of the nodes. */
|
|
717
|
+
definition: PipelineDefinition;
|
|
718
|
+
renderContent?: (text: string) => ReactNode;
|
|
719
|
+
footer?: ReactNode;
|
|
720
|
+
labels?: PipelineLabelsOverride;
|
|
721
|
+
}
|
|
722
|
+
/** What a run produced: the final answer, and every node's output, visit by visit. */
|
|
723
|
+
declare const PipelineResults: ({ state, definition, renderContent, footer, labels: over, }: PipelineResultsProps) => react.JSX.Element;
|
|
724
|
+
interface PipelineIssuesProps {
|
|
725
|
+
validation: PipelineValidation;
|
|
726
|
+
/** An issue was picked: select what it is about. */
|
|
727
|
+
onPick?: (issue: PipelineIssue) => void;
|
|
728
|
+
labels?: PipelineLabelsOverride;
|
|
729
|
+
}
|
|
730
|
+
/** The definition's errors and warnings as a list; each one leads to its node or edge. */
|
|
731
|
+
declare const PipelineIssues: ({ validation, onPick, labels: over }: PipelineIssuesProps) => react.JSX.Element;
|
|
732
|
+
/**
|
|
733
|
+
* The pipeline editor: a canvas of nodes and connections, an inspector for what is selected, a
|
|
734
|
+
* toolbar, and - with a `controller` - a run bar, live statuses and the results. Controlled:
|
|
735
|
+
* `value` in, `onChange` out. Import `@dudko.dev/agent-web-react/pipeline.css` for its styles.
|
|
736
|
+
*/
|
|
737
|
+
declare const PipelineEditor: (props: PipelineEditorProps) => react.JSX.Element;
|
|
738
|
+
|
|
739
|
+
/** The id of the canvas port a route leaves by. */
|
|
740
|
+
declare const routePortId: (label: string) => string;
|
|
741
|
+
/** The id of the port every other kind of edge leaves by. */
|
|
742
|
+
declare const OUTPUT_PORT = "out";
|
|
743
|
+
interface PipelineNodeCardProps {
|
|
744
|
+
node: PipelineNode;
|
|
745
|
+
/** Its run state (an idle one when the pipeline has not run). */
|
|
746
|
+
view: PipelineNodeView;
|
|
747
|
+
/** It is the pipeline's entry node. */
|
|
748
|
+
entry?: boolean;
|
|
749
|
+
/** What to show for its model instead of the name in the definition. */
|
|
750
|
+
modelLabel?: string;
|
|
751
|
+
/** A validation error is about this node. */
|
|
752
|
+
invalid?: boolean;
|
|
753
|
+
labels?: PipelineLabelsOverride;
|
|
754
|
+
}
|
|
755
|
+
/** One line of what a running node's agent is doing. */
|
|
756
|
+
declare const activityText: (activity: PipelineNodeActivity | undefined, labels: PipelineLabels) => string;
|
|
757
|
+
/**
|
|
758
|
+
* A node on the canvas: its name, model, what it may use, its routes as output ports and its
|
|
759
|
+
* run status. Rendered inside a canvas node (it places `<CanvasPort>`s for a node with routes).
|
|
760
|
+
*/
|
|
761
|
+
declare const PipelineNodeCard: ({ node, view, entry, modelLabel, invalid, labels: over, }: PipelineNodeCardProps) => react.JSX.Element;
|
|
762
|
+
|
|
763
|
+
interface UsePipelineOptions {
|
|
764
|
+
/**
|
|
765
|
+
* The agent config of a node - the core's seam. Give this, or the registries below (they are
|
|
766
|
+
* passed to the core's `nodeResolver`), or `runNode`.
|
|
767
|
+
*/
|
|
768
|
+
resolveNode?: PipelineOptions['resolveNode'];
|
|
769
|
+
/** With registries: the config every node starts from. */
|
|
770
|
+
base?: NodeResolverOptions['base'];
|
|
771
|
+
/** What the names in the definition stand for. A name that is not here fails its node. */
|
|
772
|
+
models?: NodeResolverOptions['models'];
|
|
773
|
+
skills?: NodeResolverOptions['skills'];
|
|
774
|
+
tools?: NodeResolverOptions['tools'];
|
|
775
|
+
mcpServers?: NodeResolverOptions['mcpServers'];
|
|
776
|
+
configure?: NodeResolverOptions['configure'];
|
|
777
|
+
/** Run a node yourself: the pipeline then only schedules (a test, a mock, a custom runner). */
|
|
778
|
+
runNode?: PipelineNodeRunner<AgentEvent>;
|
|
779
|
+
/** Every raw event, after the reducer folded it. */
|
|
780
|
+
onEvent?: AgentEventHandler;
|
|
781
|
+
}
|
|
782
|
+
interface UsePipelineReturn extends PipelineUiState {
|
|
783
|
+
/**
|
|
784
|
+
* Run the pipeline on a request. Resolves with the result, or `undefined` when it could not
|
|
785
|
+
* start (a run in flight, an invalid definition) or a node failed - then see `error`.
|
|
786
|
+
*/
|
|
787
|
+
run: (input: string) => Promise<PipelineResult | undefined>;
|
|
788
|
+
/** Abort the run in flight; it ends with `stoppedBy: 'aborted'`. */
|
|
789
|
+
stop: () => void;
|
|
790
|
+
/** Forget the last run (statuses, outputs, the result). */
|
|
791
|
+
reset: () => void;
|
|
792
|
+
isRunning: boolean;
|
|
793
|
+
/** The definition, checked by the core: `ok`, `errors`, `warnings`. */
|
|
794
|
+
validation: PipelineValidation;
|
|
795
|
+
/** What the last finished run returned. */
|
|
796
|
+
result: PipelineResult | undefined;
|
|
797
|
+
}
|
|
798
|
+
/**
|
|
799
|
+
* The React binding of the core's `createPipeline`: builds the pipeline from a definition,
|
|
800
|
+
* runs it, and folds its events into a renderable {@link PipelineUiState} (per-node status and
|
|
801
|
+
* visits, which edges fired, what each node's agent is doing, outputs, usage).
|
|
802
|
+
*
|
|
803
|
+
* ```tsx
|
|
804
|
+
* const pipeline = usePipeline(definition, { base: { model, credentials }, tools: { files } })
|
|
805
|
+
* // <PipelineEditor value={definition} onChange={setDefinition} controller={pipeline} />
|
|
806
|
+
* ```
|
|
807
|
+
*
|
|
808
|
+
* The node agents live as long as the definition and the options stay the same objects, so
|
|
809
|
+
* keep them referentially stable (`useMemo`) for a node to remember across runs.
|
|
810
|
+
*/
|
|
811
|
+
declare const usePipeline: (definition: PipelineDefinition, options?: UsePipelineOptions) => UsePipelineReturn;
|
|
812
|
+
|
|
813
|
+
type PipelineCodeTarget = 'browser' | 'node';
|
|
814
|
+
interface PipelineCodeOptions {
|
|
815
|
+
/** `browser`: @dudko.dev/agent-web. `node`: @dudko.dev/agent. */
|
|
816
|
+
target?: PipelineCodeTarget;
|
|
817
|
+
/** Keep the nodes' `position` (an editor's business; the runner ignores it). Default false. */
|
|
818
|
+
positions?: boolean;
|
|
819
|
+
/** The request in the example call. */
|
|
820
|
+
input?: string;
|
|
821
|
+
}
|
|
822
|
+
/**
|
|
823
|
+
* A snippet that runs the definition with the browser package or with the Node one. The names
|
|
824
|
+
* the definition uses (models, skills, tool groups, MCP servers) appear as variables for the
|
|
825
|
+
* host to supply: a definition never carries a model or a key.
|
|
826
|
+
*/
|
|
827
|
+
declare const pipelineToCode: (definition: PipelineDefinition, options?: PipelineCodeOptions) => string;
|
|
828
|
+
|
|
829
|
+
export { Canvas, CanvasPort, DEFAULT_MAX_ZOOM, DEFAULT_MIN_ZOOM, IDENTITY_VIEWPORT, OUTPUT_PORT, PipelineCodeDialog, PipelineEditor, PipelineInspector, PipelineIssues, PipelineLabelsProvider, PipelineNodeCard, PipelineResults, activityText, addEdge, addNode, autoLayout, boundsOf, centerOn, clamp, conditionSummary, createInitialPipelineState, curvePath, curvePoint, defaultCanvasLabels, defaultPipelineLabels, distanceToCurve, edgeCurve, emptyPipeline, ensureEdgeIds, fitViewport, hitEdge, hitNode, inputAnchor, inspectorTitle, isRectVisible, issueTarget, mergePipelineLabels, moveNode, nextNodePosition, outputAnchor, panBy, parsePipelineJson, pinchViewport, pipelineNodeView, pipelineStateReducer, pipelineToCode, readingOrder, rectContains, removeEdge, removeNode, renameNode, renameRoute, routePortId, screenToWorld, setEntry, setLimits, setPipelineName, slugifyId, snapPoint, snapTo, uniqueEdgeId, uniqueNodeId, updateEdge, updateNode, usePipeline, usePipelineLabels, worldToScreen, zoomAt };
|
|
830
|
+
export type { AutoLayoutOptions, CanvasConnection, CanvasEdge, CanvasEdgeTone, CanvasHandle, CanvasLabels, CanvasNode, CanvasNodeState, CanvasPortProps, CanvasPortSpec, CanvasProps, CanvasSelection, Curve, EdgeCurveOptions, FitOptions, PipelineAction, PipelineCodeDialogProps, PipelineCodeOptions, PipelineCodeTarget, PipelineController, PipelineEdgeView, PipelineEditorProps, PipelineEditorSlots, PipelineInspectorProps, PipelineIssuesProps, PipelineLabels, PipelineLabelsOverride, PipelineLabelsProviderProps, PipelineNodeActivity, PipelineNodeCardProps, PipelineNodeRenderContext, PipelineNodeStatus, PipelineNodeView, PipelineOption, PipelineOutputView, PipelineResultsProps, PipelineRunStatus, PipelineSelection, PipelineUiState, PipelineVisitView, Point, Rect, Size, UsePipelineOptions, UsePipelineReturn, Viewport };
|