yaml-flow 2.0.0 → 2.2.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.
@@ -1,3 +1,5 @@
1
+ import { e as StepFlowConfig } from './types-FZ_eyErS.cjs';
2
+
1
3
  /**
2
4
  * Event Graph — Core Types
3
5
  *
@@ -311,6 +313,131 @@ declare function detectStuckState(params: {
311
313
  completionResult?: CompletionResult;
312
314
  }): StuckDetection;
313
315
 
316
+ /**
317
+ * Event Graph — Execution Plan (Dry Run)
318
+ *
319
+ * Compute the full execution plan from a GraphConfig without running anything.
320
+ * Shows phases (what runs in parallel), dependency edges, and potential issues.
321
+ *
322
+ * Pure function — no I/O, no side effects.
323
+ */
324
+
325
+ interface ExecutionPlan {
326
+ /** Ordered phases — tasks within a phase can run in parallel */
327
+ phases: string[][];
328
+ /** Dependency edges: taskName → tasks it depends on */
329
+ dependencies: Record<string, string[]>;
330
+ /** Tasks that provide conflicts (same output from multiple tasks) */
331
+ conflicts: Record<string, string[]>;
332
+ /** Tasks that have no requires (entry points) */
333
+ entryPoints: string[];
334
+ /** Tasks that nothing depends on (leaf nodes) */
335
+ leafTasks: string[];
336
+ /** Tokens required but not produced by any task */
337
+ unreachableTokens: string[];
338
+ /** Tasks blocked by unreachable tokens */
339
+ blockedTasks: string[];
340
+ /** Total number of phases (depth of the graph) */
341
+ depth: number;
342
+ /** Max parallelism (widest phase) */
343
+ maxParallelism: number;
344
+ }
345
+ /**
346
+ * Compute a full execution plan from a graph config.
347
+ *
348
+ * Shows the order tasks would execute, what can run in parallel,
349
+ * where conflicts exist, and what's unreachable — all without
350
+ * actually running anything.
351
+ *
352
+ * @param graph - The event-graph configuration
353
+ * @returns ExecutionPlan with phases, dependencies, conflicts, and diagnostics
354
+ */
355
+ declare function planExecution(graph: GraphConfig): ExecutionPlan;
356
+
357
+ /**
358
+ * Mermaid Diagram Export
359
+ *
360
+ * Generate Mermaid diagram strings from GraphConfig (event-graph)
361
+ * and StepFlowConfig (step-machine). Useful for documentation,
362
+ * debugging, and CI reports.
363
+ *
364
+ * Pure functions — no I/O, no side effects.
365
+ */
366
+
367
+ interface MermaidOptions {
368
+ /** Diagram direction: TB (top-bottom), LR (left-right), etc. Default: 'TD' */
369
+ direction?: 'TD' | 'TB' | 'LR' | 'RL' | 'BT';
370
+ /** Show token labels on edges. Default: true */
371
+ showTokens?: boolean;
372
+ /** Title comment at top. Default: graph.id or 'Event Graph' */
373
+ title?: string;
374
+ }
375
+ /**
376
+ * Generate a Mermaid dependency graph from an event-graph config.
377
+ *
378
+ * Tasks are nodes. Edges represent token dependencies:
379
+ * if task B requires token X and task A provides X, then A --> B.
380
+ *
381
+ * @param graph - Event graph configuration
382
+ * @param options - Diagram options
383
+ * @returns Mermaid diagram string
384
+ */
385
+ declare function graphToMermaid(graph: GraphConfig, options?: MermaidOptions): string;
386
+ /**
387
+ * Generate a Mermaid flowchart from a step-machine config.
388
+ *
389
+ * Steps are nodes. Transitions are labeled edges.
390
+ * Terminal states are shown as filled/rounded nodes.
391
+ *
392
+ * @param flow - Step machine flow configuration
393
+ * @param options - Diagram options
394
+ * @returns Mermaid diagram string
395
+ */
396
+ declare function flowToMermaid(flow: StepFlowConfig, options?: MermaidOptions): string;
397
+
398
+ /**
399
+ * Event Graph — Loader & Exporter
400
+ *
401
+ * Load GraphConfig from YAML/JSON files or strings, and export back.
402
+ * Mirrors the step-machine's loadStepFlow/validateStepFlowConfig pattern.
403
+ */
404
+
405
+ /**
406
+ * Validate a GraphConfig object. Returns an array of error strings.
407
+ * Empty array = valid config.
408
+ */
409
+ declare function validateGraphConfig(config: unknown): string[];
410
+ /**
411
+ * Load a GraphConfig from a file path, URL, JSON string, or object.
412
+ * Validates the config and throws if invalid.
413
+ *
414
+ * @param source - File path (.yaml/.yml/.json), URL, JSON string, or GraphConfig object
415
+ * @returns Validated GraphConfig
416
+ */
417
+ declare function loadGraphConfig(source: string | GraphConfig): Promise<GraphConfig>;
418
+ interface ExportOptions {
419
+ /** Output format. Default: 'json' */
420
+ format?: 'json' | 'yaml';
421
+ /** Indentation for JSON (default: 2) or YAML */
422
+ indent?: number;
423
+ }
424
+ /**
425
+ * Export a GraphConfig to a JSON or YAML string.
426
+ *
427
+ * @param config - The graph configuration to export
428
+ * @param options - Export format options
429
+ * @returns Serialized config string
430
+ */
431
+ declare function exportGraphConfig(config: GraphConfig, options?: ExportOptions): string;
432
+ /**
433
+ * Export a GraphConfig to a file.
434
+ *
435
+ * @param config - The graph configuration to export
436
+ * @param filePath - Output file path (.json or .yaml/.yml)
437
+ * @param options - Export format options (format auto-detected from extension if not specified)
438
+ */
439
+ declare function exportGraphConfigToFile(config: GraphConfig, filePath: string, options?: ExportOptions): Promise<void>;
440
+
314
441
  /**
315
442
  * Event Graph — Constants
316
443
  */
@@ -327,4 +454,4 @@ declare const DEFAULTS: {
327
454
  readonly MAX_ITERATIONS: 1000;
328
455
  };
329
456
 
330
- export { getRepeatableMax as $, type AgentActionEvent as A, getAllTasks as B, COMPLETION_STRATEGIES as C, DEFAULTS as D, EXECUTION_MODES as E, getCandidateTasks as F, type GraphConfig as G, getProvides as H, type InjectTokensEvent as I, getRequires as J, getTask as K, hasTask as L, isExecutionComplete as M, isNonActiveTask as N, isRepeatableTask as O, isTaskCompleted as P, isTaskRunning as Q, next as R, type SchedulerResult as S, type TaskConfig as T, type RepeatableConfig as U, type TaskCircuitBreakerConfig as V, type TaskMessage as W, type TaskProgressEvent as X, type TaskRetryConfig as Y, addKeyToProvides as Z, addKeyToRequires as _, CONFLICT_STRATEGIES as a, groupTasksByProvides as a0, hasOutputConflict as a1, removeKeyFromProvides as a2, removeKeyFromRequires as a3, type CompletionResult as b, type CompletionStrategy as c, type ConflictStrategy as d, EXECUTION_STATUS as e, type ExecutionConfig as f, type ExecutionMode as g, type ExecutionState as h, type ExecutionStatus as i, type GraphEvent as j, type GraphSettings as k, type StuckDetection as l, TASK_STATUS as m, type TaskCompletedEvent as n, type TaskCreationEvent as o, type TaskFailedEvent as p, type TaskStartedEvent as q, type TaskState as r, type TaskStatus as s, addDynamicTask as t, apply as u, applyAll as v, computeAvailableOutputs as w, createDefaultTaskState as x, createInitialExecutionState as y, detectStuckState as z };
457
+ export { next as $, type AgentActionEvent as A, createInitialExecutionState as B, COMPLETION_STRATEGIES as C, DEFAULTS as D, EXECUTION_MODES as E, detectStuckState as F, type GraphConfig as G, exportGraphConfig as H, type InjectTokensEvent as I, exportGraphConfigToFile as J, flowToMermaid as K, getAllTasks as L, type MermaidOptions as M, getCandidateTasks as N, getProvides as O, getRequires as P, getTask as Q, graphToMermaid as R, type SchedulerResult as S, type TaskConfig as T, hasTask as U, isExecutionComplete as V, isNonActiveTask as W, isRepeatableTask as X, isTaskCompleted as Y, isTaskRunning as Z, loadGraphConfig as _, CONFLICT_STRATEGIES as a, planExecution as a0, validateGraphConfig as a1, type RepeatableConfig as a2, type TaskCircuitBreakerConfig as a3, type TaskMessage as a4, type TaskProgressEvent as a5, type TaskRetryConfig as a6, addKeyToProvides as a7, addKeyToRequires as a8, getRepeatableMax as a9, groupTasksByProvides as aa, hasOutputConflict as ab, removeKeyFromProvides as ac, removeKeyFromRequires as ad, type CompletionResult as b, type CompletionStrategy as c, type ConflictStrategy as d, EXECUTION_STATUS as e, type ExecutionConfig as f, type ExecutionMode as g, type ExecutionPlan as h, type ExecutionState as i, type ExecutionStatus as j, type ExportOptions as k, type GraphEvent as l, type GraphSettings as m, type StuckDetection as n, TASK_STATUS as o, type TaskCompletedEvent as p, type TaskCreationEvent as q, type TaskFailedEvent as r, type TaskStartedEvent as s, type TaskState as t, type TaskStatus as u, addDynamicTask as v, apply as w, applyAll as x, computeAvailableOutputs as y, createDefaultTaskState as z };
@@ -1,3 +1,5 @@
1
+ import { e as StepFlowConfig } from './types-FZ_eyErS.js';
2
+
1
3
  /**
2
4
  * Event Graph — Core Types
3
5
  *
@@ -311,6 +313,131 @@ declare function detectStuckState(params: {
311
313
  completionResult?: CompletionResult;
312
314
  }): StuckDetection;
313
315
 
316
+ /**
317
+ * Event Graph — Execution Plan (Dry Run)
318
+ *
319
+ * Compute the full execution plan from a GraphConfig without running anything.
320
+ * Shows phases (what runs in parallel), dependency edges, and potential issues.
321
+ *
322
+ * Pure function — no I/O, no side effects.
323
+ */
324
+
325
+ interface ExecutionPlan {
326
+ /** Ordered phases — tasks within a phase can run in parallel */
327
+ phases: string[][];
328
+ /** Dependency edges: taskName → tasks it depends on */
329
+ dependencies: Record<string, string[]>;
330
+ /** Tasks that provide conflicts (same output from multiple tasks) */
331
+ conflicts: Record<string, string[]>;
332
+ /** Tasks that have no requires (entry points) */
333
+ entryPoints: string[];
334
+ /** Tasks that nothing depends on (leaf nodes) */
335
+ leafTasks: string[];
336
+ /** Tokens required but not produced by any task */
337
+ unreachableTokens: string[];
338
+ /** Tasks blocked by unreachable tokens */
339
+ blockedTasks: string[];
340
+ /** Total number of phases (depth of the graph) */
341
+ depth: number;
342
+ /** Max parallelism (widest phase) */
343
+ maxParallelism: number;
344
+ }
345
+ /**
346
+ * Compute a full execution plan from a graph config.
347
+ *
348
+ * Shows the order tasks would execute, what can run in parallel,
349
+ * where conflicts exist, and what's unreachable — all without
350
+ * actually running anything.
351
+ *
352
+ * @param graph - The event-graph configuration
353
+ * @returns ExecutionPlan with phases, dependencies, conflicts, and diagnostics
354
+ */
355
+ declare function planExecution(graph: GraphConfig): ExecutionPlan;
356
+
357
+ /**
358
+ * Mermaid Diagram Export
359
+ *
360
+ * Generate Mermaid diagram strings from GraphConfig (event-graph)
361
+ * and StepFlowConfig (step-machine). Useful for documentation,
362
+ * debugging, and CI reports.
363
+ *
364
+ * Pure functions — no I/O, no side effects.
365
+ */
366
+
367
+ interface MermaidOptions {
368
+ /** Diagram direction: TB (top-bottom), LR (left-right), etc. Default: 'TD' */
369
+ direction?: 'TD' | 'TB' | 'LR' | 'RL' | 'BT';
370
+ /** Show token labels on edges. Default: true */
371
+ showTokens?: boolean;
372
+ /** Title comment at top. Default: graph.id or 'Event Graph' */
373
+ title?: string;
374
+ }
375
+ /**
376
+ * Generate a Mermaid dependency graph from an event-graph config.
377
+ *
378
+ * Tasks are nodes. Edges represent token dependencies:
379
+ * if task B requires token X and task A provides X, then A --> B.
380
+ *
381
+ * @param graph - Event graph configuration
382
+ * @param options - Diagram options
383
+ * @returns Mermaid diagram string
384
+ */
385
+ declare function graphToMermaid(graph: GraphConfig, options?: MermaidOptions): string;
386
+ /**
387
+ * Generate a Mermaid flowchart from a step-machine config.
388
+ *
389
+ * Steps are nodes. Transitions are labeled edges.
390
+ * Terminal states are shown as filled/rounded nodes.
391
+ *
392
+ * @param flow - Step machine flow configuration
393
+ * @param options - Diagram options
394
+ * @returns Mermaid diagram string
395
+ */
396
+ declare function flowToMermaid(flow: StepFlowConfig, options?: MermaidOptions): string;
397
+
398
+ /**
399
+ * Event Graph — Loader & Exporter
400
+ *
401
+ * Load GraphConfig from YAML/JSON files or strings, and export back.
402
+ * Mirrors the step-machine's loadStepFlow/validateStepFlowConfig pattern.
403
+ */
404
+
405
+ /**
406
+ * Validate a GraphConfig object. Returns an array of error strings.
407
+ * Empty array = valid config.
408
+ */
409
+ declare function validateGraphConfig(config: unknown): string[];
410
+ /**
411
+ * Load a GraphConfig from a file path, URL, JSON string, or object.
412
+ * Validates the config and throws if invalid.
413
+ *
414
+ * @param source - File path (.yaml/.yml/.json), URL, JSON string, or GraphConfig object
415
+ * @returns Validated GraphConfig
416
+ */
417
+ declare function loadGraphConfig(source: string | GraphConfig): Promise<GraphConfig>;
418
+ interface ExportOptions {
419
+ /** Output format. Default: 'json' */
420
+ format?: 'json' | 'yaml';
421
+ /** Indentation for JSON (default: 2) or YAML */
422
+ indent?: number;
423
+ }
424
+ /**
425
+ * Export a GraphConfig to a JSON or YAML string.
426
+ *
427
+ * @param config - The graph configuration to export
428
+ * @param options - Export format options
429
+ * @returns Serialized config string
430
+ */
431
+ declare function exportGraphConfig(config: GraphConfig, options?: ExportOptions): string;
432
+ /**
433
+ * Export a GraphConfig to a file.
434
+ *
435
+ * @param config - The graph configuration to export
436
+ * @param filePath - Output file path (.json or .yaml/.yml)
437
+ * @param options - Export format options (format auto-detected from extension if not specified)
438
+ */
439
+ declare function exportGraphConfigToFile(config: GraphConfig, filePath: string, options?: ExportOptions): Promise<void>;
440
+
314
441
  /**
315
442
  * Event Graph — Constants
316
443
  */
@@ -327,4 +454,4 @@ declare const DEFAULTS: {
327
454
  readonly MAX_ITERATIONS: 1000;
328
455
  };
329
456
 
330
- export { getRepeatableMax as $, type AgentActionEvent as A, getAllTasks as B, COMPLETION_STRATEGIES as C, DEFAULTS as D, EXECUTION_MODES as E, getCandidateTasks as F, type GraphConfig as G, getProvides as H, type InjectTokensEvent as I, getRequires as J, getTask as K, hasTask as L, isExecutionComplete as M, isNonActiveTask as N, isRepeatableTask as O, isTaskCompleted as P, isTaskRunning as Q, next as R, type SchedulerResult as S, type TaskConfig as T, type RepeatableConfig as U, type TaskCircuitBreakerConfig as V, type TaskMessage as W, type TaskProgressEvent as X, type TaskRetryConfig as Y, addKeyToProvides as Z, addKeyToRequires as _, CONFLICT_STRATEGIES as a, groupTasksByProvides as a0, hasOutputConflict as a1, removeKeyFromProvides as a2, removeKeyFromRequires as a3, type CompletionResult as b, type CompletionStrategy as c, type ConflictStrategy as d, EXECUTION_STATUS as e, type ExecutionConfig as f, type ExecutionMode as g, type ExecutionState as h, type ExecutionStatus as i, type GraphEvent as j, type GraphSettings as k, type StuckDetection as l, TASK_STATUS as m, type TaskCompletedEvent as n, type TaskCreationEvent as o, type TaskFailedEvent as p, type TaskStartedEvent as q, type TaskState as r, type TaskStatus as s, addDynamicTask as t, apply as u, applyAll as v, computeAvailableOutputs as w, createDefaultTaskState as x, createInitialExecutionState as y, detectStuckState as z };
457
+ export { next as $, type AgentActionEvent as A, createInitialExecutionState as B, COMPLETION_STRATEGIES as C, DEFAULTS as D, EXECUTION_MODES as E, detectStuckState as F, type GraphConfig as G, exportGraphConfig as H, type InjectTokensEvent as I, exportGraphConfigToFile as J, flowToMermaid as K, getAllTasks as L, type MermaidOptions as M, getCandidateTasks as N, getProvides as O, getRequires as P, getTask as Q, graphToMermaid as R, type SchedulerResult as S, type TaskConfig as T, hasTask as U, isExecutionComplete as V, isNonActiveTask as W, isRepeatableTask as X, isTaskCompleted as Y, isTaskRunning as Z, loadGraphConfig as _, CONFLICT_STRATEGIES as a, planExecution as a0, validateGraphConfig as a1, type RepeatableConfig as a2, type TaskCircuitBreakerConfig as a3, type TaskMessage as a4, type TaskProgressEvent as a5, type TaskRetryConfig as a6, addKeyToProvides as a7, addKeyToRequires as a8, getRepeatableMax as a9, groupTasksByProvides as aa, hasOutputConflict as ab, removeKeyFromProvides as ac, removeKeyFromRequires as ad, type CompletionResult as b, type CompletionStrategy as c, type ConflictStrategy as d, EXECUTION_STATUS as e, type ExecutionConfig as f, type ExecutionMode as g, type ExecutionPlan as h, type ExecutionState as i, type ExecutionStatus as j, type ExportOptions as k, type GraphEvent as l, type GraphSettings as m, type StuckDetection as n, TASK_STATUS as o, type TaskCompletedEvent as p, type TaskCreationEvent as q, type TaskFailedEvent as r, type TaskStartedEvent as s, type TaskState as t, type TaskStatus as u, addDynamicTask as v, apply as w, applyAll as x, computeAvailableOutputs as y, createDefaultTaskState as z };