yaml-flow 2.3.0 → 2.4.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.
@@ -0,0 +1,309 @@
1
+ import { G as GraphConfig, c as ExecutionState, T as TaskConfig, l as TaskState, e as GraphEvent } from '../types-CTu8RqY0.js';
2
+ export { f as GraphSettings } from '../types-CTu8RqY0.js';
3
+
4
+ /**
5
+ * Continuous Event Graph — Types
6
+ *
7
+ * A long-lived, evolving event-graph where both config and state
8
+ * mutate over time. The single `LiveGraph` type bundles them.
9
+ *
10
+ * Events are shared with event-graph (task-started, task-completed, etc.).
11
+ * Graph mutations (addNode, removeNode, etc.) are unique to this mode.
12
+ */
13
+
14
+ /**
15
+ * The single evolving object for a continuous-mode graph.
16
+ * Bundles config + state so they can't get out of sync.
17
+ */
18
+ interface LiveGraph {
19
+ /** The current graph configuration (evolves as nodes are added/removed) */
20
+ config: GraphConfig;
21
+ /** The current execution state (evolves as events arrive) */
22
+ state: ExecutionState;
23
+ }
24
+ interface ScheduleResult {
25
+ /** Tasks ready to dispatch now — all requires satisfied */
26
+ eligible: string[];
27
+ /** Tasks waiting on tokens that some producer will eventually provide (normal) */
28
+ pending: PendingTask[];
29
+ /** Tasks waiting on tokens that NO task can produce (caller's problem) */
30
+ unresolved: UnresolvedDependency[];
31
+ /** Tasks waiting on tokens whose producer FAILED (caller's problem) */
32
+ blocked: BlockedTask[];
33
+ /** Token conflicts: multiple tasks produce the same token */
34
+ conflicts: Record<string, string[]>;
35
+ }
36
+ interface PendingTask {
37
+ taskName: string;
38
+ /** Tokens this task needs that haven't been produced yet but have a viable producer */
39
+ waitingOn: string[];
40
+ }
41
+ interface UnresolvedDependency {
42
+ taskName: string;
43
+ /** Tokens this task needs that no task in the graph can produce */
44
+ missingTokens: string[];
45
+ }
46
+ interface BlockedTask {
47
+ taskName: string;
48
+ /** Tokens this task needs whose only producer has failed */
49
+ failedTokens: string[];
50
+ /** The tasks that failed and would have produced those tokens */
51
+ failedProducers: string[];
52
+ }
53
+ interface LiveGraphHealth {
54
+ /** Total number of tasks in the graph */
55
+ totalNodes: number;
56
+ /** Task counts by status */
57
+ running: number;
58
+ completed: number;
59
+ failed: number;
60
+ waiting: number;
61
+ notStarted: number;
62
+ /** Number of disabled (inactivated) nodes */
63
+ disabled: number;
64
+ /** Number of tasks with unresolvable dependencies */
65
+ unresolvedCount: number;
66
+ /** Number of tasks whose producer has failed */
67
+ blockedCount: number;
68
+ /** Tokens that no task produces (open dependencies) */
69
+ openDependencies: string[];
70
+ /** Cycles detected in the current graph (if any) */
71
+ cycles: string[][];
72
+ /** Tokens produced by multiple tasks */
73
+ conflictTokens: string[];
74
+ }
75
+ interface NodeInfo {
76
+ /** Node name */
77
+ name: string;
78
+ /** The task configuration */
79
+ config: TaskConfig;
80
+ /** The current runtime state */
81
+ state: TaskState;
82
+ }
83
+ interface LiveGraphSnapshot {
84
+ /** Schema version for forward compatibility */
85
+ version: number;
86
+ /** The graph config at snapshot time */
87
+ config: GraphConfig;
88
+ /** The execution state at snapshot time */
89
+ state: ExecutionState;
90
+ /** ISO timestamp of when the snapshot was taken */
91
+ snapshotAt: string;
92
+ }
93
+ interface UnreachableTokensResult {
94
+ tokens: {
95
+ /** The token that cannot be produced */
96
+ token: string;
97
+ /** Why it's unreachable */
98
+ reason: 'no-producer' | 'all-producers-failed' | 'transitive';
99
+ /** Tasks that could produce it (but are themselves unreachable/failed) */
100
+ producers: string[];
101
+ }[];
102
+ }
103
+ interface UnreachableNodesResult {
104
+ nodes: {
105
+ /** The node that can never become eligible */
106
+ nodeName: string;
107
+ /** Unreachable tokens this node requires (empty if the node itself is failed/disabled) */
108
+ missingTokens: string[];
109
+ }[];
110
+ }
111
+ interface UpstreamResult {
112
+ /** The target node being inspected */
113
+ nodeName: string;
114
+ /** All upstream nodes that transitively feed into the target */
115
+ nodes: {
116
+ nodeName: string;
117
+ /** Tokens this node provides that are in the dependency chain */
118
+ providesTokens: string[];
119
+ }[];
120
+ /** All tokens in the upstream dependency chain */
121
+ tokens: string[];
122
+ }
123
+ interface DownstreamResult {
124
+ /** The target node being inspected */
125
+ nodeName: string;
126
+ /** All downstream nodes that transitively depend on the target */
127
+ nodes: {
128
+ nodeName: string;
129
+ /** Tokens this node requires that are in the dependency chain */
130
+ requiresTokens: string[];
131
+ }[];
132
+ /** All tokens in the downstream dependency chain */
133
+ tokens: string[];
134
+ }
135
+
136
+ /**
137
+ * Continuous Event Graph — Core
138
+ *
139
+ * All functions are pure: f(LiveGraph, input) → LiveGraph
140
+ *
141
+ * - createLiveGraph: bootstrap from a GraphConfig
142
+ * - applyEvent: reduce an event (task-started, task-completed, etc.)
143
+ * - addNode / removeNode: structural graph mutations
144
+ * - addRequires / removeRequires / addProvides / removeProvides: wiring mutations
145
+ */
146
+
147
+ /**
148
+ * Create a LiveGraph from a GraphConfig.
149
+ * Initialises execution state for all tasks in the config.
150
+ */
151
+ declare function createLiveGraph(config: GraphConfig, executionId?: string): LiveGraph;
152
+ /**
153
+ * Apply an execution event to the LiveGraph, producing a new LiveGraph.
154
+ * Events are the shared vocabulary: task-started, task-completed, task-failed,
155
+ * task-progress, inject-tokens, agent-action.
156
+ *
157
+ * Config is NOT mutated by events — only state changes.
158
+ */
159
+ declare function applyEvent(live: LiveGraph, event: GraphEvent): LiveGraph;
160
+ /**
161
+ * Add a node (task) to the live graph. Updates both config and state atomically.
162
+ * If the node already exists, returns the graph unchanged.
163
+ */
164
+ declare function addNode(live: LiveGraph, name: string, taskConfig: TaskConfig): LiveGraph;
165
+ /**
166
+ * Remove a node (task) from the live graph. Updates both config and state atomically.
167
+ * If the node doesn't exist, returns the graph unchanged.
168
+ * NOTE: Does not clean up references — other nodes' requires/provides are left intact.
169
+ * The caller can use removeRequires() to clean up if needed.
170
+ */
171
+ declare function removeNode(live: LiveGraph, name: string): LiveGraph;
172
+ /**
173
+ * Add requires tokens to a node. If the node doesn't exist, returns unchanged.
174
+ * Deduplicates — won't add tokens already in requires.
175
+ */
176
+ declare function addRequires(live: LiveGraph, nodeName: string, tokens: string[]): LiveGraph;
177
+ /**
178
+ * Remove requires tokens from a node. If the node doesn't exist, returns unchanged.
179
+ */
180
+ declare function removeRequires(live: LiveGraph, nodeName: string, tokens: string[]): LiveGraph;
181
+ /**
182
+ * Add provides tokens to a node. If the node doesn't exist, returns unchanged.
183
+ * Deduplicates — won't add tokens already in provides.
184
+ */
185
+ declare function addProvides(live: LiveGraph, nodeName: string, tokens: string[]): LiveGraph;
186
+ /**
187
+ * Remove provides tokens from a node. If the node doesn't exist, returns unchanged.
188
+ */
189
+ declare function removeProvides(live: LiveGraph, nodeName: string, tokens: string[]): LiveGraph;
190
+ /**
191
+ * Inject tokens into the live graph's available outputs.
192
+ * Equivalent to applyEvent(live, { type: 'inject-tokens', tokens, timestamp }).
193
+ */
194
+ declare function injectTokens(live: LiveGraph, tokens: string[]): LiveGraph;
195
+ /**
196
+ * Drain (remove) tokens from the live graph's available outputs.
197
+ * Inverse of injectTokens — useful for expiring stale data or revoking signals.
198
+ * Tokens that aren't currently available are silently ignored.
199
+ * Pure function.
200
+ */
201
+ declare function drainTokens(live: LiveGraph, tokens: string[]): LiveGraph;
202
+ /**
203
+ * Reset a node's state back to not-started, clearing error, retry count, progress.
204
+ * Config is untouched. Useful when a failed task should be retried later.
205
+ * If the node doesn't exist, returns unchanged.
206
+ */
207
+ declare function resetNode(live: LiveGraph, name: string): LiveGraph;
208
+ /**
209
+ * Disable a node — sets its status to 'inactivated'.
210
+ * The scheduler will skip inactivated tasks. Config is untouched.
211
+ * If the node doesn't exist or is already inactivated, returns unchanged.
212
+ */
213
+ declare function disableNode(live: LiveGraph, name: string): LiveGraph;
214
+ /**
215
+ * Enable a previously-disabled node — sets its status back to 'not-started'.
216
+ * Only acts on 'inactivated' nodes. If the node isn't inactivated, returns unchanged.
217
+ */
218
+ declare function enableNode(live: LiveGraph, name: string): LiveGraph;
219
+ /**
220
+ * Get the config and state for a single node.
221
+ * Returns undefined if the node doesn't exist.
222
+ */
223
+ declare function getNode(live: LiveGraph, name: string): NodeInfo | undefined;
224
+ /**
225
+ * Serialize a LiveGraph to a plain JSON-safe object.
226
+ * Can be persisted to disk, database, etc.
227
+ */
228
+ declare function snapshot(live: LiveGraph): LiveGraphSnapshot;
229
+ /**
230
+ * Restore a LiveGraph from a snapshot. Validates the shape.
231
+ * Throws if the snapshot is invalid.
232
+ */
233
+ declare function restore(data: unknown): LiveGraph;
234
+
235
+ /**
236
+ * Continuous Event Graph — Schedule
237
+ *
238
+ * Pure read-only projection: LiveGraph → ScheduleResult
239
+ *
240
+ * Classifies every non-terminal task into one of:
241
+ * - eligible: all requires satisfied, ready to dispatch
242
+ * - pending: requires not yet met, but a viable producer exists (normal waiting)
243
+ * - unresolved: requires not met, NO task in the graph can produce them (caller's problem)
244
+ * - blocked: requires not met because the producing task FAILED (caller's problem)
245
+ */
246
+
247
+ /**
248
+ * Compute the scheduling status of every task in the live graph.
249
+ * Pure function — no side effects.
250
+ */
251
+ declare function schedule(live: LiveGraph): ScheduleResult;
252
+
253
+ /**
254
+ * Continuous Event Graph — Inspect
255
+ *
256
+ * Pure read-only projection: LiveGraph → LiveGraphHealth
257
+ *
258
+ * Live health report combining config structure + runtime state.
259
+ */
260
+
261
+ /**
262
+ * Compute a live health report for the graph.
263
+ * Combines structural analysis (cycles, conflicts, open deps) with runtime state (task statuses).
264
+ * Pure function — no side effects.
265
+ */
266
+ declare function inspect(live: LiveGraph): LiveGraphHealth;
267
+ /**
268
+ * Get all tokens that are required but cannot be produced given the current
269
+ * graph state. This is **transitive**: if token X is unreachable, and node A
270
+ * is the only producer of token Y but A requires X, then Y is also unreachable.
271
+ *
272
+ * Takes into account:
273
+ * - Tokens already in availableOutputs (reachable)
274
+ * - Tokens from completed tasks (reachable)
275
+ * - Failed/disabled producers (non-viable)
276
+ *
277
+ * Pure function.
278
+ */
279
+ declare function getUnreachableTokens(live: LiveGraph): UnreachableTokensResult;
280
+ /**
281
+ * Get all nodes that can never become eligible given the current graph state.
282
+ * A node is unreachable if any of its required tokens is unreachable.
283
+ *
284
+ * This is the node-level companion to getUnreachableTokens — uses the same
285
+ * transitive analysis.
286
+ *
287
+ * Pure function.
288
+ */
289
+ declare function getUnreachableNodes(live: LiveGraph): UnreachableNodesResult;
290
+ /**
291
+ * Get all nodes that transitively feed into the given node.
292
+ * "What's upstream of X?" — traces backwards through requires → provides chains.
293
+ *
294
+ * Returns the set of upstream nodes and the tokens connecting them.
295
+ * Does NOT include the target node itself.
296
+ * Pure function.
297
+ */
298
+ declare function getUpstream(live: LiveGraph, nodeName: string): UpstreamResult;
299
+ /**
300
+ * Get all nodes that transitively depend on the given node.
301
+ * "What breaks if I disable X?" — traces forwards through provides → requires chains.
302
+ *
303
+ * Returns the set of downstream nodes and the tokens connecting them.
304
+ * Does NOT include the target node itself.
305
+ * Pure function.
306
+ */
307
+ declare function getDownstream(live: LiveGraph, nodeName: string): DownstreamResult;
308
+
309
+ export { type BlockedTask, type DownstreamResult, ExecutionState, GraphConfig, GraphEvent, type LiveGraph, type LiveGraphHealth, type LiveGraphSnapshot, type NodeInfo, type PendingTask, type ScheduleResult, TaskConfig, TaskState, type UnreachableNodesResult, type UnreachableTokensResult, type UnresolvedDependency, type UpstreamResult, addNode, addProvides, addRequires, applyEvent, createLiveGraph, disableNode, drainTokens, enableNode, getDownstream, getNode, getUnreachableNodes, getUnreachableTokens, getUpstream, injectTokens, inspect, removeNode, removeProvides, removeRequires, resetNode, restore, schedule, snapshot };