yaml-flow 2.2.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.
- package/README.md +196 -0
- package/dist/{constants-Bwvkbr5s.d.cts → constants-Dbk6ArN5.d.cts} +52 -187
- package/dist/{constants-Ewufm5cK.d.ts → constants-DcCDDQON.d.ts} +52 -187
- package/dist/continuous-event-graph/index.cjs +939 -0
- package/dist/continuous-event-graph/index.cjs.map +1 -0
- package/dist/continuous-event-graph/index.d.cts +309 -0
- package/dist/continuous-event-graph/index.d.ts +309 -0
- package/dist/continuous-event-graph/index.js +916 -0
- package/dist/continuous-event-graph/index.js.map +1 -0
- package/dist/event-graph/index.cjs +208 -0
- package/dist/event-graph/index.cjs.map +1 -1
- package/dist/event-graph/index.d.cts +3 -2
- package/dist/event-graph/index.d.ts +3 -2
- package/dist/event-graph/index.js +208 -1
- package/dist/event-graph/index.js.map +1 -1
- package/dist/index.cjs +957 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +935 -1
- package/dist/index.js.map +1 -1
- package/dist/types-CTu8RqY0.d.cts +187 -0
- package/dist/types-CTu8RqY0.d.ts +187 -0
- package/package.json +6 -1
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Event Graph — Core Types
|
|
3
|
+
*
|
|
4
|
+
* Type definitions for the stateless event-graph engine.
|
|
5
|
+
* Pure: f(state, event) → newState
|
|
6
|
+
*/
|
|
7
|
+
interface GraphConfig {
|
|
8
|
+
id?: string;
|
|
9
|
+
settings: GraphSettings;
|
|
10
|
+
tasks: Record<string, TaskConfig>;
|
|
11
|
+
}
|
|
12
|
+
interface GraphSettings {
|
|
13
|
+
/** Completion strategy */
|
|
14
|
+
completion: CompletionStrategy;
|
|
15
|
+
/** Conflict resolution strategy */
|
|
16
|
+
conflict_strategy?: ConflictStrategy;
|
|
17
|
+
/** Execution mode */
|
|
18
|
+
execution_mode?: ExecutionMode;
|
|
19
|
+
/** Goal outputs — used with 'goal-reached' completion */
|
|
20
|
+
goal?: string[];
|
|
21
|
+
/** Max total scheduler iterations (safety limit, default: 1000) */
|
|
22
|
+
max_iterations?: number;
|
|
23
|
+
/** Timeout in ms (declared for drivers, not enforced by pure engine) */
|
|
24
|
+
timeout_ms?: number;
|
|
25
|
+
}
|
|
26
|
+
interface TaskConfig {
|
|
27
|
+
/** What this task needs to become eligible */
|
|
28
|
+
requires?: string[];
|
|
29
|
+
/** What this task produces on successful completion */
|
|
30
|
+
provides: string[];
|
|
31
|
+
/** Conditional provides based on handler result */
|
|
32
|
+
on?: Record<string, string[]>;
|
|
33
|
+
/** Tokens to inject into available outputs on failure */
|
|
34
|
+
on_failure?: string[];
|
|
35
|
+
/** Task execution method (informational — driver concern) */
|
|
36
|
+
method?: string;
|
|
37
|
+
/** Arbitrary task configuration (driver concern) */
|
|
38
|
+
config?: Record<string, unknown>;
|
|
39
|
+
/** Task priority (higher = preferred in conflict resolution) */
|
|
40
|
+
priority?: number;
|
|
41
|
+
/** Estimated duration in ms (used by duration-first strategy) */
|
|
42
|
+
estimatedDuration?: number;
|
|
43
|
+
/** Estimated cost (used by cost-optimized strategy) */
|
|
44
|
+
estimatedCost?: number;
|
|
45
|
+
/** Resource requirements (used by resource-aware strategy) */
|
|
46
|
+
estimatedResources?: Record<string, number>;
|
|
47
|
+
/** Retry configuration */
|
|
48
|
+
retry?: TaskRetryConfig;
|
|
49
|
+
/** Repeatable task configuration */
|
|
50
|
+
repeatable?: boolean | RepeatableConfig;
|
|
51
|
+
/** Circuit breaker: max executions before breaking */
|
|
52
|
+
circuit_breaker?: TaskCircuitBreakerConfig;
|
|
53
|
+
/** Description */
|
|
54
|
+
description?: string;
|
|
55
|
+
}
|
|
56
|
+
interface TaskRetryConfig {
|
|
57
|
+
max_attempts: number;
|
|
58
|
+
delay_ms?: number;
|
|
59
|
+
backoff_multiplier?: number;
|
|
60
|
+
}
|
|
61
|
+
interface RepeatableConfig {
|
|
62
|
+
/** Max times this task can repeat (undefined = unlimited) */
|
|
63
|
+
max?: number;
|
|
64
|
+
}
|
|
65
|
+
interface TaskCircuitBreakerConfig {
|
|
66
|
+
/** Max executions before injecting break tokens */
|
|
67
|
+
max_executions: number;
|
|
68
|
+
/** Tokens to inject when breaker trips */
|
|
69
|
+
on_break: string[];
|
|
70
|
+
}
|
|
71
|
+
interface ExecutionState {
|
|
72
|
+
/** Current status of the execution */
|
|
73
|
+
status: ExecutionStatus;
|
|
74
|
+
/** Task states keyed by task name */
|
|
75
|
+
tasks: Record<string, TaskState>;
|
|
76
|
+
/** Tokens currently available in the system */
|
|
77
|
+
availableOutputs: string[];
|
|
78
|
+
/** Stuck detection result */
|
|
79
|
+
stuckDetection: StuckDetection;
|
|
80
|
+
/** Last update timestamp */
|
|
81
|
+
lastUpdated: string;
|
|
82
|
+
/** Execution ID for this run */
|
|
83
|
+
executionId: string | null;
|
|
84
|
+
/** Execution configuration */
|
|
85
|
+
executionConfig: ExecutionConfig;
|
|
86
|
+
}
|
|
87
|
+
interface ExecutionConfig {
|
|
88
|
+
executionMode: ExecutionMode;
|
|
89
|
+
conflictStrategy: ConflictStrategy;
|
|
90
|
+
completionStrategy: CompletionStrategy;
|
|
91
|
+
}
|
|
92
|
+
interface TaskState {
|
|
93
|
+
status: TaskStatus;
|
|
94
|
+
executionCount: number;
|
|
95
|
+
retryCount: number;
|
|
96
|
+
lastEpoch: number;
|
|
97
|
+
startedAt?: string;
|
|
98
|
+
completedAt?: string;
|
|
99
|
+
failedAt?: string;
|
|
100
|
+
lastUpdated?: string;
|
|
101
|
+
error?: string;
|
|
102
|
+
messages?: TaskMessage[];
|
|
103
|
+
progress?: number | null;
|
|
104
|
+
}
|
|
105
|
+
interface TaskMessage {
|
|
106
|
+
message: string;
|
|
107
|
+
timestamp: string;
|
|
108
|
+
status: string;
|
|
109
|
+
}
|
|
110
|
+
interface StuckDetection {
|
|
111
|
+
is_stuck: boolean;
|
|
112
|
+
stuck_description: string | null;
|
|
113
|
+
outputs_unresolvable: string[];
|
|
114
|
+
tasks_blocked: string[];
|
|
115
|
+
}
|
|
116
|
+
type GraphEvent = TaskStartedEvent | TaskCompletedEvent | TaskFailedEvent | TaskProgressEvent | InjectTokensEvent | AgentActionEvent | TaskCreationEvent;
|
|
117
|
+
interface TaskStartedEvent {
|
|
118
|
+
type: 'task-started';
|
|
119
|
+
taskName: string;
|
|
120
|
+
timestamp: string;
|
|
121
|
+
executionId?: string;
|
|
122
|
+
}
|
|
123
|
+
interface TaskCompletedEvent {
|
|
124
|
+
type: 'task-completed';
|
|
125
|
+
taskName: string;
|
|
126
|
+
/** Handler result key — used for conditional routing via `on` */
|
|
127
|
+
result?: string;
|
|
128
|
+
/** Data payload from task execution */
|
|
129
|
+
data?: Record<string, unknown>;
|
|
130
|
+
timestamp: string;
|
|
131
|
+
executionId?: string;
|
|
132
|
+
}
|
|
133
|
+
interface TaskFailedEvent {
|
|
134
|
+
type: 'task-failed';
|
|
135
|
+
taskName: string;
|
|
136
|
+
error: string;
|
|
137
|
+
timestamp: string;
|
|
138
|
+
executionId?: string;
|
|
139
|
+
}
|
|
140
|
+
interface TaskProgressEvent {
|
|
141
|
+
type: 'task-progress';
|
|
142
|
+
taskName: string;
|
|
143
|
+
message?: string;
|
|
144
|
+
progress?: number;
|
|
145
|
+
timestamp: string;
|
|
146
|
+
executionId?: string;
|
|
147
|
+
}
|
|
148
|
+
interface InjectTokensEvent {
|
|
149
|
+
type: 'inject-tokens';
|
|
150
|
+
tokens: string[];
|
|
151
|
+
timestamp: string;
|
|
152
|
+
}
|
|
153
|
+
interface AgentActionEvent {
|
|
154
|
+
type: 'agent-action';
|
|
155
|
+
action: 'start' | 'stop' | 'pause' | 'resume';
|
|
156
|
+
timestamp: string;
|
|
157
|
+
config?: Partial<ExecutionConfig>;
|
|
158
|
+
}
|
|
159
|
+
interface TaskCreationEvent {
|
|
160
|
+
type: 'task-creation';
|
|
161
|
+
taskName: string;
|
|
162
|
+
taskConfig: TaskConfig;
|
|
163
|
+
timestamp: string;
|
|
164
|
+
}
|
|
165
|
+
interface SchedulerResult {
|
|
166
|
+
/** Tasks eligible for execution */
|
|
167
|
+
eligibleTasks: string[];
|
|
168
|
+
/** Whether the graph execution is complete */
|
|
169
|
+
isComplete: boolean;
|
|
170
|
+
/** Stuck detection result */
|
|
171
|
+
stuckDetection: StuckDetection;
|
|
172
|
+
/** Whether conflicts were detected */
|
|
173
|
+
hasConflicts: boolean;
|
|
174
|
+
/** Conflict groups: output → competing task names */
|
|
175
|
+
conflicts: Record<string, string[]>;
|
|
176
|
+
/** Strategy used for conflict resolution */
|
|
177
|
+
strategy: ConflictStrategy;
|
|
178
|
+
/** Processing log for diagnostics */
|
|
179
|
+
processingLog: string[];
|
|
180
|
+
}
|
|
181
|
+
type TaskStatus = 'not-started' | 'running' | 'completed' | 'failed' | 'inactivated';
|
|
182
|
+
type ExecutionStatus = 'created' | 'running' | 'paused' | 'stopped' | 'completed' | 'failed';
|
|
183
|
+
type CompletionStrategy = 'all-tasks-done' | 'all-outputs-done' | 'only-resolved' | 'goal-reached' | 'manual';
|
|
184
|
+
type ExecutionMode = 'dependency-mode' | 'eligibility-mode';
|
|
185
|
+
type ConflictStrategy = 'alphabetical' | 'priority-first' | 'duration-first' | 'cost-optimized' | 'resource-aware' | 'random-select' | 'user-choice' | 'parallel-all' | 'skip-conflicts' | 'round-robin';
|
|
186
|
+
|
|
187
|
+
export type { AgentActionEvent as A, CompletionStrategy as C, ExecutionConfig as E, GraphConfig as G, InjectTokensEvent as I, RepeatableConfig as R, SchedulerResult as S, TaskConfig as T, ConflictStrategy as a, ExecutionMode as b, ExecutionState as c, ExecutionStatus as d, GraphEvent as e, GraphSettings as f, StuckDetection as g, TaskCompletedEvent as h, TaskCreationEvent as i, TaskFailedEvent as j, TaskStartedEvent as k, TaskState as l, TaskStatus as m, TaskCircuitBreakerConfig as n, TaskMessage as o, TaskProgressEvent as p, TaskRetryConfig as q };
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Event Graph — Core Types
|
|
3
|
+
*
|
|
4
|
+
* Type definitions for the stateless event-graph engine.
|
|
5
|
+
* Pure: f(state, event) → newState
|
|
6
|
+
*/
|
|
7
|
+
interface GraphConfig {
|
|
8
|
+
id?: string;
|
|
9
|
+
settings: GraphSettings;
|
|
10
|
+
tasks: Record<string, TaskConfig>;
|
|
11
|
+
}
|
|
12
|
+
interface GraphSettings {
|
|
13
|
+
/** Completion strategy */
|
|
14
|
+
completion: CompletionStrategy;
|
|
15
|
+
/** Conflict resolution strategy */
|
|
16
|
+
conflict_strategy?: ConflictStrategy;
|
|
17
|
+
/** Execution mode */
|
|
18
|
+
execution_mode?: ExecutionMode;
|
|
19
|
+
/** Goal outputs — used with 'goal-reached' completion */
|
|
20
|
+
goal?: string[];
|
|
21
|
+
/** Max total scheduler iterations (safety limit, default: 1000) */
|
|
22
|
+
max_iterations?: number;
|
|
23
|
+
/** Timeout in ms (declared for drivers, not enforced by pure engine) */
|
|
24
|
+
timeout_ms?: number;
|
|
25
|
+
}
|
|
26
|
+
interface TaskConfig {
|
|
27
|
+
/** What this task needs to become eligible */
|
|
28
|
+
requires?: string[];
|
|
29
|
+
/** What this task produces on successful completion */
|
|
30
|
+
provides: string[];
|
|
31
|
+
/** Conditional provides based on handler result */
|
|
32
|
+
on?: Record<string, string[]>;
|
|
33
|
+
/** Tokens to inject into available outputs on failure */
|
|
34
|
+
on_failure?: string[];
|
|
35
|
+
/** Task execution method (informational — driver concern) */
|
|
36
|
+
method?: string;
|
|
37
|
+
/** Arbitrary task configuration (driver concern) */
|
|
38
|
+
config?: Record<string, unknown>;
|
|
39
|
+
/** Task priority (higher = preferred in conflict resolution) */
|
|
40
|
+
priority?: number;
|
|
41
|
+
/** Estimated duration in ms (used by duration-first strategy) */
|
|
42
|
+
estimatedDuration?: number;
|
|
43
|
+
/** Estimated cost (used by cost-optimized strategy) */
|
|
44
|
+
estimatedCost?: number;
|
|
45
|
+
/** Resource requirements (used by resource-aware strategy) */
|
|
46
|
+
estimatedResources?: Record<string, number>;
|
|
47
|
+
/** Retry configuration */
|
|
48
|
+
retry?: TaskRetryConfig;
|
|
49
|
+
/** Repeatable task configuration */
|
|
50
|
+
repeatable?: boolean | RepeatableConfig;
|
|
51
|
+
/** Circuit breaker: max executions before breaking */
|
|
52
|
+
circuit_breaker?: TaskCircuitBreakerConfig;
|
|
53
|
+
/** Description */
|
|
54
|
+
description?: string;
|
|
55
|
+
}
|
|
56
|
+
interface TaskRetryConfig {
|
|
57
|
+
max_attempts: number;
|
|
58
|
+
delay_ms?: number;
|
|
59
|
+
backoff_multiplier?: number;
|
|
60
|
+
}
|
|
61
|
+
interface RepeatableConfig {
|
|
62
|
+
/** Max times this task can repeat (undefined = unlimited) */
|
|
63
|
+
max?: number;
|
|
64
|
+
}
|
|
65
|
+
interface TaskCircuitBreakerConfig {
|
|
66
|
+
/** Max executions before injecting break tokens */
|
|
67
|
+
max_executions: number;
|
|
68
|
+
/** Tokens to inject when breaker trips */
|
|
69
|
+
on_break: string[];
|
|
70
|
+
}
|
|
71
|
+
interface ExecutionState {
|
|
72
|
+
/** Current status of the execution */
|
|
73
|
+
status: ExecutionStatus;
|
|
74
|
+
/** Task states keyed by task name */
|
|
75
|
+
tasks: Record<string, TaskState>;
|
|
76
|
+
/** Tokens currently available in the system */
|
|
77
|
+
availableOutputs: string[];
|
|
78
|
+
/** Stuck detection result */
|
|
79
|
+
stuckDetection: StuckDetection;
|
|
80
|
+
/** Last update timestamp */
|
|
81
|
+
lastUpdated: string;
|
|
82
|
+
/** Execution ID for this run */
|
|
83
|
+
executionId: string | null;
|
|
84
|
+
/** Execution configuration */
|
|
85
|
+
executionConfig: ExecutionConfig;
|
|
86
|
+
}
|
|
87
|
+
interface ExecutionConfig {
|
|
88
|
+
executionMode: ExecutionMode;
|
|
89
|
+
conflictStrategy: ConflictStrategy;
|
|
90
|
+
completionStrategy: CompletionStrategy;
|
|
91
|
+
}
|
|
92
|
+
interface TaskState {
|
|
93
|
+
status: TaskStatus;
|
|
94
|
+
executionCount: number;
|
|
95
|
+
retryCount: number;
|
|
96
|
+
lastEpoch: number;
|
|
97
|
+
startedAt?: string;
|
|
98
|
+
completedAt?: string;
|
|
99
|
+
failedAt?: string;
|
|
100
|
+
lastUpdated?: string;
|
|
101
|
+
error?: string;
|
|
102
|
+
messages?: TaskMessage[];
|
|
103
|
+
progress?: number | null;
|
|
104
|
+
}
|
|
105
|
+
interface TaskMessage {
|
|
106
|
+
message: string;
|
|
107
|
+
timestamp: string;
|
|
108
|
+
status: string;
|
|
109
|
+
}
|
|
110
|
+
interface StuckDetection {
|
|
111
|
+
is_stuck: boolean;
|
|
112
|
+
stuck_description: string | null;
|
|
113
|
+
outputs_unresolvable: string[];
|
|
114
|
+
tasks_blocked: string[];
|
|
115
|
+
}
|
|
116
|
+
type GraphEvent = TaskStartedEvent | TaskCompletedEvent | TaskFailedEvent | TaskProgressEvent | InjectTokensEvent | AgentActionEvent | TaskCreationEvent;
|
|
117
|
+
interface TaskStartedEvent {
|
|
118
|
+
type: 'task-started';
|
|
119
|
+
taskName: string;
|
|
120
|
+
timestamp: string;
|
|
121
|
+
executionId?: string;
|
|
122
|
+
}
|
|
123
|
+
interface TaskCompletedEvent {
|
|
124
|
+
type: 'task-completed';
|
|
125
|
+
taskName: string;
|
|
126
|
+
/** Handler result key — used for conditional routing via `on` */
|
|
127
|
+
result?: string;
|
|
128
|
+
/** Data payload from task execution */
|
|
129
|
+
data?: Record<string, unknown>;
|
|
130
|
+
timestamp: string;
|
|
131
|
+
executionId?: string;
|
|
132
|
+
}
|
|
133
|
+
interface TaskFailedEvent {
|
|
134
|
+
type: 'task-failed';
|
|
135
|
+
taskName: string;
|
|
136
|
+
error: string;
|
|
137
|
+
timestamp: string;
|
|
138
|
+
executionId?: string;
|
|
139
|
+
}
|
|
140
|
+
interface TaskProgressEvent {
|
|
141
|
+
type: 'task-progress';
|
|
142
|
+
taskName: string;
|
|
143
|
+
message?: string;
|
|
144
|
+
progress?: number;
|
|
145
|
+
timestamp: string;
|
|
146
|
+
executionId?: string;
|
|
147
|
+
}
|
|
148
|
+
interface InjectTokensEvent {
|
|
149
|
+
type: 'inject-tokens';
|
|
150
|
+
tokens: string[];
|
|
151
|
+
timestamp: string;
|
|
152
|
+
}
|
|
153
|
+
interface AgentActionEvent {
|
|
154
|
+
type: 'agent-action';
|
|
155
|
+
action: 'start' | 'stop' | 'pause' | 'resume';
|
|
156
|
+
timestamp: string;
|
|
157
|
+
config?: Partial<ExecutionConfig>;
|
|
158
|
+
}
|
|
159
|
+
interface TaskCreationEvent {
|
|
160
|
+
type: 'task-creation';
|
|
161
|
+
taskName: string;
|
|
162
|
+
taskConfig: TaskConfig;
|
|
163
|
+
timestamp: string;
|
|
164
|
+
}
|
|
165
|
+
interface SchedulerResult {
|
|
166
|
+
/** Tasks eligible for execution */
|
|
167
|
+
eligibleTasks: string[];
|
|
168
|
+
/** Whether the graph execution is complete */
|
|
169
|
+
isComplete: boolean;
|
|
170
|
+
/** Stuck detection result */
|
|
171
|
+
stuckDetection: StuckDetection;
|
|
172
|
+
/** Whether conflicts were detected */
|
|
173
|
+
hasConflicts: boolean;
|
|
174
|
+
/** Conflict groups: output → competing task names */
|
|
175
|
+
conflicts: Record<string, string[]>;
|
|
176
|
+
/** Strategy used for conflict resolution */
|
|
177
|
+
strategy: ConflictStrategy;
|
|
178
|
+
/** Processing log for diagnostics */
|
|
179
|
+
processingLog: string[];
|
|
180
|
+
}
|
|
181
|
+
type TaskStatus = 'not-started' | 'running' | 'completed' | 'failed' | 'inactivated';
|
|
182
|
+
type ExecutionStatus = 'created' | 'running' | 'paused' | 'stopped' | 'completed' | 'failed';
|
|
183
|
+
type CompletionStrategy = 'all-tasks-done' | 'all-outputs-done' | 'only-resolved' | 'goal-reached' | 'manual';
|
|
184
|
+
type ExecutionMode = 'dependency-mode' | 'eligibility-mode';
|
|
185
|
+
type ConflictStrategy = 'alphabetical' | 'priority-first' | 'duration-first' | 'cost-optimized' | 'resource-aware' | 'random-select' | 'user-choice' | 'parallel-all' | 'skip-conflicts' | 'round-robin';
|
|
186
|
+
|
|
187
|
+
export type { AgentActionEvent as A, CompletionStrategy as C, ExecutionConfig as E, GraphConfig as G, InjectTokensEvent as I, RepeatableConfig as R, SchedulerResult as S, TaskConfig as T, ConflictStrategy as a, ExecutionMode as b, ExecutionState as c, ExecutionStatus as d, GraphEvent as e, GraphSettings as f, StuckDetection as g, TaskCompletedEvent as h, TaskCreationEvent as i, TaskFailedEvent as j, TaskStartedEvent as k, TaskState as l, TaskStatus as m, TaskCircuitBreakerConfig as n, TaskMessage as o, TaskProgressEvent as p, TaskRetryConfig as q };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yaml-flow",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0",
|
|
4
4
|
"description": "Unified workflow engine: step-machine (sequential) + event-graph (stateless DAG) with pluggable storage",
|
|
5
5
|
"author": "",
|
|
6
6
|
"license": "MIT",
|
|
@@ -53,6 +53,11 @@
|
|
|
53
53
|
"types": "./dist/config/index.d.ts",
|
|
54
54
|
"import": "./dist/config/index.js",
|
|
55
55
|
"require": "./dist/config/index.cjs"
|
|
56
|
+
},
|
|
57
|
+
"./continuous-event-graph": {
|
|
58
|
+
"types": "./dist/continuous-event-graph/index.d.ts",
|
|
59
|
+
"import": "./dist/continuous-event-graph/index.js",
|
|
60
|
+
"require": "./dist/continuous-event-graph/index.cjs"
|
|
56
61
|
}
|
|
57
62
|
},
|
|
58
63
|
"browser": {
|