yaml-flow 2.2.0 → 2.3.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/dist/index.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { StepMachine as FlowEngine, StepMachine, applyStepResult, checkCircuitBreaker, computeStepInput, createStepMachine as createEngine, createInitialState, createStepMachine, extractReturnData, loadStepFlow, validateStepFlowConfig } from './step-machine/index.cjs';
2
2
  export { C as CircuitBreakerConfig, R as RetryConfig, S as StepConfig, a as StepContext, b as StepEvent, c as StepEventListener, d as StepEventType, e as StepFlowConfig, f as StepFlowSettings, g as StepHandler, h as StepInput, i as StepMachineOptions, j as StepMachineResult, k as StepMachineState, l as StepMachineStore, m as StepReducerResult, n as StepResult, T as TerminalStateConfig } from './types-FZ_eyErS.cjs';
3
- export { A as AgentActionEvent, C as COMPLETION_STRATEGIES, a as CONFLICT_STRATEGIES, b as CompletionResult, c as CompletionStrategy, d as ConflictStrategy, D as DEFAULTS, E as EXECUTION_MODES, e as EXECUTION_STATUS, f as ExecutionConfig, g as ExecutionMode, h as ExecutionPlan, i as ExecutionState, j as ExecutionStatus, k as ExportOptions, G as GraphConfig, l as GraphEvent, m as GraphSettings, T as GraphTaskConfig, I as InjectTokensEvent, M as MermaidOptions, S as SchedulerResult, n as StuckDetection, o as TASK_STATUS, p as TaskCompletedEvent, q as TaskCreationEvent, r as TaskFailedEvent, s as TaskStartedEvent, t as TaskState, u as TaskStatus, v as addDynamicTask, w as apply, x as applyAll, y as computeAvailableOutputs, z as createDefaultTaskState, B as createInitialExecutionState, F as detectStuckState, H as exportGraphConfig, J as exportGraphConfigToFile, K as flowToMermaid, L as getAllTasks, N as getCandidateTasks, O as getProvides, P as getRequires, Q as getTask, R as graphToMermaid, U as hasTask, V as isExecutionComplete, W as isNonActiveTask, X as isRepeatableTask, Y as isTaskCompleted, Z as isTaskRunning, _ as loadGraphConfig, $ as next, a0 as planExecution, a1 as validateGraphConfig } from './constants-Bwvkbr5s.cjs';
3
+ export { A as AgentActionEvent, C as COMPLETION_STRATEGIES, a as CONFLICT_STRATEGIES, b as CompletionResult, c as CompletionStrategy, d as ConflictStrategy, D as DEFAULTS, E as EXECUTION_MODES, e as EXECUTION_STATUS, f as ExecutionConfig, g as ExecutionMode, h as ExecutionPlan, i as ExecutionState, j as ExecutionStatus, k as ExportOptions, G as GraphConfig, l as GraphEvent, m as GraphIssue, n as GraphSettings, T as GraphTaskConfig, o as GraphValidationResult, I as InjectTokensEvent, p as IssueSeverity, M as MermaidOptions, S as SchedulerResult, q as StuckDetection, r as TASK_STATUS, s as TaskCompletedEvent, t as TaskCreationEvent, u as TaskFailedEvent, v as TaskStartedEvent, w as TaskState, x as TaskStatus, y as addDynamicTask, z as apply, B as applyAll, F as computeAvailableOutputs, H as createDefaultTaskState, J as createInitialExecutionState, K as detectStuckState, L as exportGraphConfig, N as exportGraphConfigToFile, O as flowToMermaid, P as getAllTasks, Q as getCandidateTasks, R as getProvides, U as getRequires, V as getTask, W as graphToMermaid, X as hasTask, Y as isExecutionComplete, Z as isNonActiveTask, _ as isRepeatableTask, $ as isTaskCompleted, a0 as isTaskRunning, a1 as loadGraphConfig, a2 as next, a3 as planExecution, a4 as validateGraph, a5 as validateGraphConfig } from './constants-BftTHiuV.cjs';
4
4
  export { MemoryStore } from './stores/memory.cjs';
5
5
  export { LocalStorageStore } from './stores/localStorage.cjs';
6
6
  export { FileStore } from './stores/file.cjs';
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { StepMachine as FlowEngine, StepMachine, applyStepResult, checkCircuitBreaker, computeStepInput, createStepMachine as createEngine, createInitialState, createStepMachine, extractReturnData, loadStepFlow, validateStepFlowConfig } from './step-machine/index.js';
2
2
  export { C as CircuitBreakerConfig, R as RetryConfig, S as StepConfig, a as StepContext, b as StepEvent, c as StepEventListener, d as StepEventType, e as StepFlowConfig, f as StepFlowSettings, g as StepHandler, h as StepInput, i as StepMachineOptions, j as StepMachineResult, k as StepMachineState, l as StepMachineStore, m as StepReducerResult, n as StepResult, T as TerminalStateConfig } from './types-FZ_eyErS.js';
3
- export { A as AgentActionEvent, C as COMPLETION_STRATEGIES, a as CONFLICT_STRATEGIES, b as CompletionResult, c as CompletionStrategy, d as ConflictStrategy, D as DEFAULTS, E as EXECUTION_MODES, e as EXECUTION_STATUS, f as ExecutionConfig, g as ExecutionMode, h as ExecutionPlan, i as ExecutionState, j as ExecutionStatus, k as ExportOptions, G as GraphConfig, l as GraphEvent, m as GraphSettings, T as GraphTaskConfig, I as InjectTokensEvent, M as MermaidOptions, S as SchedulerResult, n as StuckDetection, o as TASK_STATUS, p as TaskCompletedEvent, q as TaskCreationEvent, r as TaskFailedEvent, s as TaskStartedEvent, t as TaskState, u as TaskStatus, v as addDynamicTask, w as apply, x as applyAll, y as computeAvailableOutputs, z as createDefaultTaskState, B as createInitialExecutionState, F as detectStuckState, H as exportGraphConfig, J as exportGraphConfigToFile, K as flowToMermaid, L as getAllTasks, N as getCandidateTasks, O as getProvides, P as getRequires, Q as getTask, R as graphToMermaid, U as hasTask, V as isExecutionComplete, W as isNonActiveTask, X as isRepeatableTask, Y as isTaskCompleted, Z as isTaskRunning, _ as loadGraphConfig, $ as next, a0 as planExecution, a1 as validateGraphConfig } from './constants-Ewufm5cK.js';
3
+ export { A as AgentActionEvent, C as COMPLETION_STRATEGIES, a as CONFLICT_STRATEGIES, b as CompletionResult, c as CompletionStrategy, d as ConflictStrategy, D as DEFAULTS, E as EXECUTION_MODES, e as EXECUTION_STATUS, f as ExecutionConfig, g as ExecutionMode, h as ExecutionPlan, i as ExecutionState, j as ExecutionStatus, k as ExportOptions, G as GraphConfig, l as GraphEvent, m as GraphIssue, n as GraphSettings, T as GraphTaskConfig, o as GraphValidationResult, I as InjectTokensEvent, p as IssueSeverity, M as MermaidOptions, S as SchedulerResult, q as StuckDetection, r as TASK_STATUS, s as TaskCompletedEvent, t as TaskCreationEvent, u as TaskFailedEvent, v as TaskStartedEvent, w as TaskState, x as TaskStatus, y as addDynamicTask, z as apply, B as applyAll, F as computeAvailableOutputs, H as createDefaultTaskState, J as createInitialExecutionState, K as detectStuckState, L as exportGraphConfig, N as exportGraphConfigToFile, O as flowToMermaid, P as getAllTasks, Q as getCandidateTasks, R as getProvides, U as getRequires, V as getTask, W as graphToMermaid, X as hasTask, Y as isExecutionComplete, Z as isNonActiveTask, _ as isRepeatableTask, $ as isTaskCompleted, a0 as isTaskRunning, a1 as loadGraphConfig, a2 as next, a3 as planExecution, a4 as validateGraph, a5 as validateGraphConfig } from './constants-DMbnp--H.js';
4
4
  export { MemoryStore } from './stores/memory.js';
5
5
  export { LocalStorageStore } from './stores/localStorage.js';
6
6
  export { FileStore } from './stores/file.js';
package/dist/index.js CHANGED
@@ -1733,6 +1733,213 @@ ${serialized}`;
1733
1733
  return String(obj);
1734
1734
  }
1735
1735
 
1736
+ // src/event-graph/validate.ts
1737
+ function buildProducerMap2(tasks) {
1738
+ const map = {};
1739
+ for (const [name, config] of Object.entries(tasks)) {
1740
+ for (const token of getProvides(config)) {
1741
+ if (!map[token]) map[token] = [];
1742
+ map[token].push(name);
1743
+ }
1744
+ if (config.on) {
1745
+ for (const tokens of Object.values(config.on)) {
1746
+ for (const token of tokens) {
1747
+ if (!map[token]) map[token] = [];
1748
+ if (!map[token].includes(name)) map[token].push(name);
1749
+ }
1750
+ }
1751
+ }
1752
+ if (config.on_failure) {
1753
+ for (const token of config.on_failure) {
1754
+ if (!map[token]) map[token] = [];
1755
+ if (!map[token].includes(name)) map[token].push(name);
1756
+ }
1757
+ }
1758
+ }
1759
+ return map;
1760
+ }
1761
+ function buildTaskDeps(tasks, producerMap) {
1762
+ const deps = {};
1763
+ for (const [name, config] of Object.entries(tasks)) {
1764
+ deps[name] = /* @__PURE__ */ new Set();
1765
+ for (const token of getRequires(config)) {
1766
+ for (const producer of producerMap[token] || []) {
1767
+ if (producer !== name) deps[name].add(producer);
1768
+ }
1769
+ }
1770
+ }
1771
+ return deps;
1772
+ }
1773
+ function detectCycles(taskNames, deps) {
1774
+ const WHITE = 0, GRAY = 1, BLACK = 2;
1775
+ const color = {};
1776
+ const parent = {};
1777
+ const cycles = [];
1778
+ for (const name of taskNames) {
1779
+ color[name] = WHITE;
1780
+ parent[name] = null;
1781
+ }
1782
+ function dfs(node) {
1783
+ color[node] = GRAY;
1784
+ for (const dep of deps[node] || []) {
1785
+ if (color[dep] === GRAY) {
1786
+ const cycle = [dep];
1787
+ let cur = node;
1788
+ while (cur !== dep) {
1789
+ cycle.push(cur);
1790
+ cur = parent[cur];
1791
+ }
1792
+ cycle.push(dep);
1793
+ cycle.reverse();
1794
+ cycles.push(cycle);
1795
+ } else if (color[dep] === WHITE) {
1796
+ parent[dep] = node;
1797
+ dfs(dep);
1798
+ }
1799
+ }
1800
+ color[node] = BLACK;
1801
+ }
1802
+ for (const name of taskNames) {
1803
+ if (color[name] === WHITE) {
1804
+ dfs(name);
1805
+ }
1806
+ }
1807
+ return cycles;
1808
+ }
1809
+ function validateGraph(graph) {
1810
+ const issues = [];
1811
+ const tasks = getAllTasks(graph);
1812
+ const taskNames = Object.keys(tasks);
1813
+ if (taskNames.length === 0) {
1814
+ issues.push({
1815
+ severity: "error",
1816
+ code: "EMPTY_GRAPH",
1817
+ message: "Graph has no tasks"
1818
+ });
1819
+ return buildResult(issues);
1820
+ }
1821
+ const producerMap = buildProducerMap2(tasks);
1822
+ const deps = buildTaskDeps(tasks, producerMap);
1823
+ for (const [name, config] of Object.entries(tasks)) {
1824
+ for (const token of getRequires(config)) {
1825
+ if (!producerMap[token]) {
1826
+ issues.push({
1827
+ severity: "error",
1828
+ code: "DANGLING_REQUIRES",
1829
+ message: `Task "${name}" requires token "${token}" but no task produces it`,
1830
+ tasks: [name],
1831
+ tokens: [token]
1832
+ });
1833
+ }
1834
+ }
1835
+ }
1836
+ const cycles = detectCycles(taskNames, deps);
1837
+ for (const cycle of cycles) {
1838
+ issues.push({
1839
+ severity: "error",
1840
+ code: "CIRCULAR_DEPENDENCY",
1841
+ message: `Circular dependency: ${cycle.join(" \u2192 ")}`,
1842
+ tasks: cycle.filter((_t, i) => i < cycle.length - 1)
1843
+ // dedupe last = first
1844
+ });
1845
+ }
1846
+ for (const [name, config] of Object.entries(tasks)) {
1847
+ const req = getRequires(config);
1848
+ const prov = getProvides(config);
1849
+ const self = req.filter((token) => prov.includes(token));
1850
+ if (self.length > 0) {
1851
+ issues.push({
1852
+ severity: "error",
1853
+ code: "SELF_DEPENDENCY",
1854
+ message: `Task "${name}" requires tokens it provides itself: [${self.join(", ")}]`,
1855
+ tasks: [name],
1856
+ tokens: self
1857
+ });
1858
+ }
1859
+ }
1860
+ for (const [token, producers] of Object.entries(producerMap)) {
1861
+ if (producers.length > 1) {
1862
+ issues.push({
1863
+ severity: "warning",
1864
+ code: "PROVIDE_CONFLICT",
1865
+ message: `Token "${token}" is produced by multiple tasks: [${producers.join(", ")}]. This requires a conflict strategy.`,
1866
+ tasks: producers,
1867
+ tokens: [token]
1868
+ });
1869
+ }
1870
+ }
1871
+ if (graph.settings.completion === "goal-reached" && graph.settings.goal) {
1872
+ for (const goalToken of graph.settings.goal) {
1873
+ if (!producerMap[goalToken]) {
1874
+ issues.push({
1875
+ severity: "error",
1876
+ code: "UNREACHABLE_GOAL",
1877
+ message: `Goal token "${goalToken}" cannot be produced by any task`,
1878
+ tokens: [goalToken]
1879
+ });
1880
+ }
1881
+ }
1882
+ }
1883
+ if (taskNames.length > 1) {
1884
+ for (const [name, config] of Object.entries(tasks)) {
1885
+ const prov = getProvides(config);
1886
+ const onProv = config.on ? Object.values(config.on).flat() : [];
1887
+ const failProv = config.on_failure || [];
1888
+ if (prov.length === 0 && onProv.length === 0 && failProv.length === 0) {
1889
+ issues.push({
1890
+ severity: "warning",
1891
+ code: "DEAD_END_TASK",
1892
+ message: `Task "${name}" has no provides \u2014 it cannot unblock any downstream task`,
1893
+ tasks: [name]
1894
+ });
1895
+ }
1896
+ }
1897
+ }
1898
+ const allRequired = /* @__PURE__ */ new Set();
1899
+ for (const config of Object.values(tasks)) {
1900
+ for (const token of getRequires(config)) {
1901
+ allRequired.add(token);
1902
+ }
1903
+ }
1904
+ for (const [name, config] of Object.entries(tasks)) {
1905
+ const req = getRequires(config);
1906
+ const prov = getProvides(config);
1907
+ const onProv = config.on ? Object.values(config.on).flat() : [];
1908
+ const allProv = [...prov, ...onProv];
1909
+ const isEntryPoint = req.length === 0;
1910
+ const hasDownstream = allProv.some((token) => allRequired.has(token));
1911
+ if (isEntryPoint && !hasDownstream && taskNames.length > 1) {
1912
+ const isGoalRelevant = graph.settings.completion === "goal-reached" && graph.settings.goal?.some((g) => allProv.includes(g));
1913
+ if (!isGoalRelevant) {
1914
+ issues.push({
1915
+ severity: "info",
1916
+ code: "ISOLATED_TASK",
1917
+ message: `Task "${name}" is disconnected \u2014 it has no requires and nothing depends on its provides`,
1918
+ tasks: [name]
1919
+ });
1920
+ }
1921
+ }
1922
+ }
1923
+ if (graph.settings.completion === "goal-reached" && !graph.settings.goal) {
1924
+ issues.push({
1925
+ severity: "error",
1926
+ code: "MISSING_GOAL",
1927
+ message: 'Completion strategy is "goal-reached" but no goal tokens are defined'
1928
+ });
1929
+ }
1930
+ return buildResult(issues);
1931
+ }
1932
+ function buildResult(issues) {
1933
+ const errors = issues.filter((i) => i.severity === "error");
1934
+ const warnings = issues.filter((i) => i.severity === "warning");
1935
+ return {
1936
+ valid: errors.length === 0,
1937
+ issues,
1938
+ errors,
1939
+ warnings
1940
+ };
1941
+ }
1942
+
1736
1943
  // src/stores/localStorage.ts
1737
1944
  var LocalStorageStore = class {
1738
1945
  prefix;
@@ -2093,6 +2300,6 @@ function resolveConfigTemplates(config) {
2093
2300
  return result;
2094
2301
  }
2095
2302
 
2096
- export { COMPLETION_STRATEGIES, CONFLICT_STRATEGIES, DEFAULTS, EXECUTION_MODES, EXECUTION_STATUS, FileStore, StepMachine as FlowEngine, LocalStorageStore, MemoryStore, StepMachine, TASK_STATUS, addDynamicTask, apply, applyAll, applyStepResult, batch, checkCircuitBreaker, computeAvailableOutputs, computeStepInput, createDefaultTaskState, createStepMachine as createEngine, createInitialExecutionState, createInitialState, createStepMachine, detectStuckState, exportGraphConfig, exportGraphConfigToFile, extractReturnData, flowToMermaid, getAllTasks, getCandidateTasks, getProvides, getRequires, getTask, graphToMermaid, hasTask, isExecutionComplete, isNonActiveTask, isRepeatableTask, isTaskCompleted, isTaskRunning, loadGraphConfig, loadStepFlow, next, planExecution, resolveConfigTemplates, resolveVariables, validateGraphConfig, validateStepFlowConfig };
2303
+ export { COMPLETION_STRATEGIES, CONFLICT_STRATEGIES, DEFAULTS, EXECUTION_MODES, EXECUTION_STATUS, FileStore, StepMachine as FlowEngine, LocalStorageStore, MemoryStore, StepMachine, TASK_STATUS, addDynamicTask, apply, applyAll, applyStepResult, batch, checkCircuitBreaker, computeAvailableOutputs, computeStepInput, createDefaultTaskState, createStepMachine as createEngine, createInitialExecutionState, createInitialState, createStepMachine, detectStuckState, exportGraphConfig, exportGraphConfigToFile, extractReturnData, flowToMermaid, getAllTasks, getCandidateTasks, getProvides, getRequires, getTask, graphToMermaid, hasTask, isExecutionComplete, isNonActiveTask, isRepeatableTask, isTaskCompleted, isTaskRunning, loadGraphConfig, loadStepFlow, next, planExecution, resolveConfigTemplates, resolveVariables, validateGraph, validateGraphConfig, validateStepFlowConfig };
2097
2304
  //# sourceMappingURL=index.js.map
2098
2305
  //# sourceMappingURL=index.js.map