yaml-flow 2.3.0 → 2.5.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 +368 -0
- package/dist/{constants-DMbnp--H.d.ts → constants-BEbO2_OK.d.ts} +2 -187
- package/dist/{constants-BftTHiuV.d.cts → constants-BNjeIlZ8.d.cts} +2 -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 +179 -0
- package/dist/continuous-event-graph/index.d.ts +179 -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.d.cts +3 -2
- package/dist/event-graph/index.d.ts +3 -2
- package/dist/index.cjs +1008 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +981 -1
- package/dist/index.js.map +1 -1
- package/dist/inference/index.cjs +450 -0
- package/dist/inference/index.cjs.map +1 -0
- package/dist/inference/index.d.cts +229 -0
- package/dist/inference/index.d.ts +229 -0
- package/dist/inference/index.js +443 -0
- package/dist/inference/index.js.map +1 -0
- package/dist/types-C2lOwquM.d.cts +135 -0
- package/dist/types-DAI_a2as.d.cts +198 -0
- package/dist/types-DAI_a2as.d.ts +198 -0
- package/dist/types-mS_pPftm.d.ts +135 -0
- package/package.json +11 -1
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { G as GraphConfig, c as ExecutionState, T as TaskConfig, l as TaskState } from './types-DAI_a2as.cjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Continuous Event Graph — Types
|
|
5
|
+
*
|
|
6
|
+
* A long-lived, evolving event-graph where both config and state
|
|
7
|
+
* mutate over time. The single `LiveGraph` type bundles them.
|
|
8
|
+
*
|
|
9
|
+
* Events are shared with event-graph (task-started, task-completed, etc.).
|
|
10
|
+
* Graph mutations (addNode, removeNode, etc.) are unique to this mode.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* The single evolving object for a continuous-mode graph.
|
|
15
|
+
* Bundles config + state so they can't get out of sync.
|
|
16
|
+
*/
|
|
17
|
+
interface LiveGraph {
|
|
18
|
+
/** The current graph configuration (evolves as nodes are added/removed) */
|
|
19
|
+
config: GraphConfig;
|
|
20
|
+
/** The current execution state (evolves as events arrive) */
|
|
21
|
+
state: ExecutionState;
|
|
22
|
+
}
|
|
23
|
+
interface ScheduleResult {
|
|
24
|
+
/** Tasks ready to dispatch now — all requires satisfied */
|
|
25
|
+
eligible: string[];
|
|
26
|
+
/** Tasks waiting on tokens that some producer will eventually provide (normal) */
|
|
27
|
+
pending: PendingTask[];
|
|
28
|
+
/** Tasks waiting on tokens that NO task can produce (caller's problem) */
|
|
29
|
+
unresolved: UnresolvedDependency[];
|
|
30
|
+
/** Tasks waiting on tokens whose producer FAILED (caller's problem) */
|
|
31
|
+
blocked: BlockedTask[];
|
|
32
|
+
/** Token conflicts: multiple tasks produce the same token */
|
|
33
|
+
conflicts: Record<string, string[]>;
|
|
34
|
+
}
|
|
35
|
+
interface PendingTask {
|
|
36
|
+
taskName: string;
|
|
37
|
+
/** Tokens this task needs that haven't been produced yet but have a viable producer */
|
|
38
|
+
waitingOn: string[];
|
|
39
|
+
}
|
|
40
|
+
interface UnresolvedDependency {
|
|
41
|
+
taskName: string;
|
|
42
|
+
/** Tokens this task needs that no task in the graph can produce */
|
|
43
|
+
missingTokens: string[];
|
|
44
|
+
}
|
|
45
|
+
interface BlockedTask {
|
|
46
|
+
taskName: string;
|
|
47
|
+
/** Tokens this task needs whose only producer has failed */
|
|
48
|
+
failedTokens: string[];
|
|
49
|
+
/** The tasks that failed and would have produced those tokens */
|
|
50
|
+
failedProducers: string[];
|
|
51
|
+
}
|
|
52
|
+
interface LiveGraphHealth {
|
|
53
|
+
/** Total number of tasks in the graph */
|
|
54
|
+
totalNodes: number;
|
|
55
|
+
/** Task counts by status */
|
|
56
|
+
running: number;
|
|
57
|
+
completed: number;
|
|
58
|
+
failed: number;
|
|
59
|
+
waiting: number;
|
|
60
|
+
notStarted: number;
|
|
61
|
+
/** Number of disabled (inactivated) nodes */
|
|
62
|
+
disabled: number;
|
|
63
|
+
/** Number of tasks with unresolvable dependencies */
|
|
64
|
+
unresolvedCount: number;
|
|
65
|
+
/** Number of tasks whose producer has failed */
|
|
66
|
+
blockedCount: number;
|
|
67
|
+
/** Tokens that no task produces (open dependencies) */
|
|
68
|
+
openDependencies: string[];
|
|
69
|
+
/** Cycles detected in the current graph (if any) */
|
|
70
|
+
cycles: string[][];
|
|
71
|
+
/** Tokens produced by multiple tasks */
|
|
72
|
+
conflictTokens: string[];
|
|
73
|
+
}
|
|
74
|
+
interface NodeInfo {
|
|
75
|
+
/** Node name */
|
|
76
|
+
name: string;
|
|
77
|
+
/** The task configuration */
|
|
78
|
+
config: TaskConfig;
|
|
79
|
+
/** The current runtime state */
|
|
80
|
+
state: TaskState;
|
|
81
|
+
}
|
|
82
|
+
interface LiveGraphSnapshot {
|
|
83
|
+
/** Schema version for forward compatibility */
|
|
84
|
+
version: number;
|
|
85
|
+
/** The graph config at snapshot time */
|
|
86
|
+
config: GraphConfig;
|
|
87
|
+
/** The execution state at snapshot time */
|
|
88
|
+
state: ExecutionState;
|
|
89
|
+
/** ISO timestamp of when the snapshot was taken */
|
|
90
|
+
snapshotAt: string;
|
|
91
|
+
}
|
|
92
|
+
interface UnreachableTokensResult {
|
|
93
|
+
tokens: {
|
|
94
|
+
/** The token that cannot be produced */
|
|
95
|
+
token: string;
|
|
96
|
+
/** Why it's unreachable */
|
|
97
|
+
reason: 'no-producer' | 'all-producers-failed' | 'transitive';
|
|
98
|
+
/** Tasks that could produce it (but are themselves unreachable/failed) */
|
|
99
|
+
producers: string[];
|
|
100
|
+
}[];
|
|
101
|
+
}
|
|
102
|
+
interface UnreachableNodesResult {
|
|
103
|
+
nodes: {
|
|
104
|
+
/** The node that can never become eligible */
|
|
105
|
+
nodeName: string;
|
|
106
|
+
/** Unreachable tokens this node requires (empty if the node itself is failed/disabled) */
|
|
107
|
+
missingTokens: string[];
|
|
108
|
+
}[];
|
|
109
|
+
}
|
|
110
|
+
interface UpstreamResult {
|
|
111
|
+
/** The target node being inspected */
|
|
112
|
+
nodeName: string;
|
|
113
|
+
/** All upstream nodes that transitively feed into the target */
|
|
114
|
+
nodes: {
|
|
115
|
+
nodeName: string;
|
|
116
|
+
/** Tokens this node provides that are in the dependency chain */
|
|
117
|
+
providesTokens: string[];
|
|
118
|
+
}[];
|
|
119
|
+
/** All tokens in the upstream dependency chain */
|
|
120
|
+
tokens: string[];
|
|
121
|
+
}
|
|
122
|
+
interface DownstreamResult {
|
|
123
|
+
/** The target node being inspected */
|
|
124
|
+
nodeName: string;
|
|
125
|
+
/** All downstream nodes that transitively depend on the target */
|
|
126
|
+
nodes: {
|
|
127
|
+
nodeName: string;
|
|
128
|
+
/** Tokens this node requires that are in the dependency chain */
|
|
129
|
+
requiresTokens: string[];
|
|
130
|
+
}[];
|
|
131
|
+
/** All tokens in the downstream dependency chain */
|
|
132
|
+
tokens: string[];
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export type { BlockedTask as B, DownstreamResult as D, LiveGraph as L, NodeInfo as N, PendingTask as P, ScheduleResult as S, UnreachableNodesResult as U, LiveGraphHealth as a, LiveGraphSnapshot as b, UnreachableTokensResult as c, UnresolvedDependency as d, UpstreamResult as e };
|
|
@@ -0,0 +1,198 @@
|
|
|
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
|
+
/** LLM inference hints — opt-in metadata for AI-assisted completion detection */
|
|
56
|
+
inference?: {
|
|
57
|
+
/** Human-readable completion criteria */
|
|
58
|
+
criteria?: string;
|
|
59
|
+
/** Keywords to help the LLM understand the domain */
|
|
60
|
+
keywords?: string[];
|
|
61
|
+
/** Suggested checks for verification */
|
|
62
|
+
suggestedChecks?: string[];
|
|
63
|
+
/** Whether the LLM should attempt to auto-detect completion (default: false) */
|
|
64
|
+
autoDetectable?: boolean;
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
interface TaskRetryConfig {
|
|
68
|
+
max_attempts: number;
|
|
69
|
+
delay_ms?: number;
|
|
70
|
+
backoff_multiplier?: number;
|
|
71
|
+
}
|
|
72
|
+
interface RepeatableConfig {
|
|
73
|
+
/** Max times this task can repeat (undefined = unlimited) */
|
|
74
|
+
max?: number;
|
|
75
|
+
}
|
|
76
|
+
interface TaskCircuitBreakerConfig {
|
|
77
|
+
/** Max executions before injecting break tokens */
|
|
78
|
+
max_executions: number;
|
|
79
|
+
/** Tokens to inject when breaker trips */
|
|
80
|
+
on_break: string[];
|
|
81
|
+
}
|
|
82
|
+
interface ExecutionState {
|
|
83
|
+
/** Current status of the execution */
|
|
84
|
+
status: ExecutionStatus;
|
|
85
|
+
/** Task states keyed by task name */
|
|
86
|
+
tasks: Record<string, TaskState>;
|
|
87
|
+
/** Tokens currently available in the system */
|
|
88
|
+
availableOutputs: string[];
|
|
89
|
+
/** Stuck detection result */
|
|
90
|
+
stuckDetection: StuckDetection;
|
|
91
|
+
/** Last update timestamp */
|
|
92
|
+
lastUpdated: string;
|
|
93
|
+
/** Execution ID for this run */
|
|
94
|
+
executionId: string | null;
|
|
95
|
+
/** Execution configuration */
|
|
96
|
+
executionConfig: ExecutionConfig;
|
|
97
|
+
}
|
|
98
|
+
interface ExecutionConfig {
|
|
99
|
+
executionMode: ExecutionMode;
|
|
100
|
+
conflictStrategy: ConflictStrategy;
|
|
101
|
+
completionStrategy: CompletionStrategy;
|
|
102
|
+
}
|
|
103
|
+
interface TaskState {
|
|
104
|
+
status: TaskStatus;
|
|
105
|
+
executionCount: number;
|
|
106
|
+
retryCount: number;
|
|
107
|
+
lastEpoch: number;
|
|
108
|
+
startedAt?: string;
|
|
109
|
+
completedAt?: string;
|
|
110
|
+
failedAt?: string;
|
|
111
|
+
lastUpdated?: string;
|
|
112
|
+
error?: string;
|
|
113
|
+
messages?: TaskMessage[];
|
|
114
|
+
progress?: number | null;
|
|
115
|
+
}
|
|
116
|
+
interface TaskMessage {
|
|
117
|
+
message: string;
|
|
118
|
+
timestamp: string;
|
|
119
|
+
status: string;
|
|
120
|
+
}
|
|
121
|
+
interface StuckDetection {
|
|
122
|
+
is_stuck: boolean;
|
|
123
|
+
stuck_description: string | null;
|
|
124
|
+
outputs_unresolvable: string[];
|
|
125
|
+
tasks_blocked: string[];
|
|
126
|
+
}
|
|
127
|
+
type GraphEvent = TaskStartedEvent | TaskCompletedEvent | TaskFailedEvent | TaskProgressEvent | InjectTokensEvent | AgentActionEvent | TaskCreationEvent;
|
|
128
|
+
interface TaskStartedEvent {
|
|
129
|
+
type: 'task-started';
|
|
130
|
+
taskName: string;
|
|
131
|
+
timestamp: string;
|
|
132
|
+
executionId?: string;
|
|
133
|
+
}
|
|
134
|
+
interface TaskCompletedEvent {
|
|
135
|
+
type: 'task-completed';
|
|
136
|
+
taskName: string;
|
|
137
|
+
/** Handler result key — used for conditional routing via `on` */
|
|
138
|
+
result?: string;
|
|
139
|
+
/** Data payload from task execution */
|
|
140
|
+
data?: Record<string, unknown>;
|
|
141
|
+
timestamp: string;
|
|
142
|
+
executionId?: string;
|
|
143
|
+
}
|
|
144
|
+
interface TaskFailedEvent {
|
|
145
|
+
type: 'task-failed';
|
|
146
|
+
taskName: string;
|
|
147
|
+
error: string;
|
|
148
|
+
timestamp: string;
|
|
149
|
+
executionId?: string;
|
|
150
|
+
}
|
|
151
|
+
interface TaskProgressEvent {
|
|
152
|
+
type: 'task-progress';
|
|
153
|
+
taskName: string;
|
|
154
|
+
message?: string;
|
|
155
|
+
progress?: number;
|
|
156
|
+
timestamp: string;
|
|
157
|
+
executionId?: string;
|
|
158
|
+
}
|
|
159
|
+
interface InjectTokensEvent {
|
|
160
|
+
type: 'inject-tokens';
|
|
161
|
+
tokens: string[];
|
|
162
|
+
timestamp: string;
|
|
163
|
+
}
|
|
164
|
+
interface AgentActionEvent {
|
|
165
|
+
type: 'agent-action';
|
|
166
|
+
action: 'start' | 'stop' | 'pause' | 'resume';
|
|
167
|
+
timestamp: string;
|
|
168
|
+
config?: Partial<ExecutionConfig>;
|
|
169
|
+
}
|
|
170
|
+
interface TaskCreationEvent {
|
|
171
|
+
type: 'task-creation';
|
|
172
|
+
taskName: string;
|
|
173
|
+
taskConfig: TaskConfig;
|
|
174
|
+
timestamp: string;
|
|
175
|
+
}
|
|
176
|
+
interface SchedulerResult {
|
|
177
|
+
/** Tasks eligible for execution */
|
|
178
|
+
eligibleTasks: string[];
|
|
179
|
+
/** Whether the graph execution is complete */
|
|
180
|
+
isComplete: boolean;
|
|
181
|
+
/** Stuck detection result */
|
|
182
|
+
stuckDetection: StuckDetection;
|
|
183
|
+
/** Whether conflicts were detected */
|
|
184
|
+
hasConflicts: boolean;
|
|
185
|
+
/** Conflict groups: output → competing task names */
|
|
186
|
+
conflicts: Record<string, string[]>;
|
|
187
|
+
/** Strategy used for conflict resolution */
|
|
188
|
+
strategy: ConflictStrategy;
|
|
189
|
+
/** Processing log for diagnostics */
|
|
190
|
+
processingLog: string[];
|
|
191
|
+
}
|
|
192
|
+
type TaskStatus = 'not-started' | 'running' | 'completed' | 'failed' | 'inactivated';
|
|
193
|
+
type ExecutionStatus = 'created' | 'running' | 'paused' | 'stopped' | 'completed' | 'failed';
|
|
194
|
+
type CompletionStrategy = 'all-tasks-done' | 'all-outputs-done' | 'only-resolved' | 'goal-reached' | 'manual';
|
|
195
|
+
type ExecutionMode = 'dependency-mode' | 'eligibility-mode';
|
|
196
|
+
type ConflictStrategy = 'alphabetical' | 'priority-first' | 'duration-first' | 'cost-optimized' | 'resource-aware' | 'random-select' | 'user-choice' | 'parallel-all' | 'skip-conflicts' | 'round-robin';
|
|
197
|
+
|
|
198
|
+
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,198 @@
|
|
|
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
|
+
/** LLM inference hints — opt-in metadata for AI-assisted completion detection */
|
|
56
|
+
inference?: {
|
|
57
|
+
/** Human-readable completion criteria */
|
|
58
|
+
criteria?: string;
|
|
59
|
+
/** Keywords to help the LLM understand the domain */
|
|
60
|
+
keywords?: string[];
|
|
61
|
+
/** Suggested checks for verification */
|
|
62
|
+
suggestedChecks?: string[];
|
|
63
|
+
/** Whether the LLM should attempt to auto-detect completion (default: false) */
|
|
64
|
+
autoDetectable?: boolean;
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
interface TaskRetryConfig {
|
|
68
|
+
max_attempts: number;
|
|
69
|
+
delay_ms?: number;
|
|
70
|
+
backoff_multiplier?: number;
|
|
71
|
+
}
|
|
72
|
+
interface RepeatableConfig {
|
|
73
|
+
/** Max times this task can repeat (undefined = unlimited) */
|
|
74
|
+
max?: number;
|
|
75
|
+
}
|
|
76
|
+
interface TaskCircuitBreakerConfig {
|
|
77
|
+
/** Max executions before injecting break tokens */
|
|
78
|
+
max_executions: number;
|
|
79
|
+
/** Tokens to inject when breaker trips */
|
|
80
|
+
on_break: string[];
|
|
81
|
+
}
|
|
82
|
+
interface ExecutionState {
|
|
83
|
+
/** Current status of the execution */
|
|
84
|
+
status: ExecutionStatus;
|
|
85
|
+
/** Task states keyed by task name */
|
|
86
|
+
tasks: Record<string, TaskState>;
|
|
87
|
+
/** Tokens currently available in the system */
|
|
88
|
+
availableOutputs: string[];
|
|
89
|
+
/** Stuck detection result */
|
|
90
|
+
stuckDetection: StuckDetection;
|
|
91
|
+
/** Last update timestamp */
|
|
92
|
+
lastUpdated: string;
|
|
93
|
+
/** Execution ID for this run */
|
|
94
|
+
executionId: string | null;
|
|
95
|
+
/** Execution configuration */
|
|
96
|
+
executionConfig: ExecutionConfig;
|
|
97
|
+
}
|
|
98
|
+
interface ExecutionConfig {
|
|
99
|
+
executionMode: ExecutionMode;
|
|
100
|
+
conflictStrategy: ConflictStrategy;
|
|
101
|
+
completionStrategy: CompletionStrategy;
|
|
102
|
+
}
|
|
103
|
+
interface TaskState {
|
|
104
|
+
status: TaskStatus;
|
|
105
|
+
executionCount: number;
|
|
106
|
+
retryCount: number;
|
|
107
|
+
lastEpoch: number;
|
|
108
|
+
startedAt?: string;
|
|
109
|
+
completedAt?: string;
|
|
110
|
+
failedAt?: string;
|
|
111
|
+
lastUpdated?: string;
|
|
112
|
+
error?: string;
|
|
113
|
+
messages?: TaskMessage[];
|
|
114
|
+
progress?: number | null;
|
|
115
|
+
}
|
|
116
|
+
interface TaskMessage {
|
|
117
|
+
message: string;
|
|
118
|
+
timestamp: string;
|
|
119
|
+
status: string;
|
|
120
|
+
}
|
|
121
|
+
interface StuckDetection {
|
|
122
|
+
is_stuck: boolean;
|
|
123
|
+
stuck_description: string | null;
|
|
124
|
+
outputs_unresolvable: string[];
|
|
125
|
+
tasks_blocked: string[];
|
|
126
|
+
}
|
|
127
|
+
type GraphEvent = TaskStartedEvent | TaskCompletedEvent | TaskFailedEvent | TaskProgressEvent | InjectTokensEvent | AgentActionEvent | TaskCreationEvent;
|
|
128
|
+
interface TaskStartedEvent {
|
|
129
|
+
type: 'task-started';
|
|
130
|
+
taskName: string;
|
|
131
|
+
timestamp: string;
|
|
132
|
+
executionId?: string;
|
|
133
|
+
}
|
|
134
|
+
interface TaskCompletedEvent {
|
|
135
|
+
type: 'task-completed';
|
|
136
|
+
taskName: string;
|
|
137
|
+
/** Handler result key — used for conditional routing via `on` */
|
|
138
|
+
result?: string;
|
|
139
|
+
/** Data payload from task execution */
|
|
140
|
+
data?: Record<string, unknown>;
|
|
141
|
+
timestamp: string;
|
|
142
|
+
executionId?: string;
|
|
143
|
+
}
|
|
144
|
+
interface TaskFailedEvent {
|
|
145
|
+
type: 'task-failed';
|
|
146
|
+
taskName: string;
|
|
147
|
+
error: string;
|
|
148
|
+
timestamp: string;
|
|
149
|
+
executionId?: string;
|
|
150
|
+
}
|
|
151
|
+
interface TaskProgressEvent {
|
|
152
|
+
type: 'task-progress';
|
|
153
|
+
taskName: string;
|
|
154
|
+
message?: string;
|
|
155
|
+
progress?: number;
|
|
156
|
+
timestamp: string;
|
|
157
|
+
executionId?: string;
|
|
158
|
+
}
|
|
159
|
+
interface InjectTokensEvent {
|
|
160
|
+
type: 'inject-tokens';
|
|
161
|
+
tokens: string[];
|
|
162
|
+
timestamp: string;
|
|
163
|
+
}
|
|
164
|
+
interface AgentActionEvent {
|
|
165
|
+
type: 'agent-action';
|
|
166
|
+
action: 'start' | 'stop' | 'pause' | 'resume';
|
|
167
|
+
timestamp: string;
|
|
168
|
+
config?: Partial<ExecutionConfig>;
|
|
169
|
+
}
|
|
170
|
+
interface TaskCreationEvent {
|
|
171
|
+
type: 'task-creation';
|
|
172
|
+
taskName: string;
|
|
173
|
+
taskConfig: TaskConfig;
|
|
174
|
+
timestamp: string;
|
|
175
|
+
}
|
|
176
|
+
interface SchedulerResult {
|
|
177
|
+
/** Tasks eligible for execution */
|
|
178
|
+
eligibleTasks: string[];
|
|
179
|
+
/** Whether the graph execution is complete */
|
|
180
|
+
isComplete: boolean;
|
|
181
|
+
/** Stuck detection result */
|
|
182
|
+
stuckDetection: StuckDetection;
|
|
183
|
+
/** Whether conflicts were detected */
|
|
184
|
+
hasConflicts: boolean;
|
|
185
|
+
/** Conflict groups: output → competing task names */
|
|
186
|
+
conflicts: Record<string, string[]>;
|
|
187
|
+
/** Strategy used for conflict resolution */
|
|
188
|
+
strategy: ConflictStrategy;
|
|
189
|
+
/** Processing log for diagnostics */
|
|
190
|
+
processingLog: string[];
|
|
191
|
+
}
|
|
192
|
+
type TaskStatus = 'not-started' | 'running' | 'completed' | 'failed' | 'inactivated';
|
|
193
|
+
type ExecutionStatus = 'created' | 'running' | 'paused' | 'stopped' | 'completed' | 'failed';
|
|
194
|
+
type CompletionStrategy = 'all-tasks-done' | 'all-outputs-done' | 'only-resolved' | 'goal-reached' | 'manual';
|
|
195
|
+
type ExecutionMode = 'dependency-mode' | 'eligibility-mode';
|
|
196
|
+
type ConflictStrategy = 'alphabetical' | 'priority-first' | 'duration-first' | 'cost-optimized' | 'resource-aware' | 'random-select' | 'user-choice' | 'parallel-all' | 'skip-conflicts' | 'round-robin';
|
|
197
|
+
|
|
198
|
+
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,135 @@
|
|
|
1
|
+
import { G as GraphConfig, c as ExecutionState, T as TaskConfig, l as TaskState } from './types-DAI_a2as.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Continuous Event Graph — Types
|
|
5
|
+
*
|
|
6
|
+
* A long-lived, evolving event-graph where both config and state
|
|
7
|
+
* mutate over time. The single `LiveGraph` type bundles them.
|
|
8
|
+
*
|
|
9
|
+
* Events are shared with event-graph (task-started, task-completed, etc.).
|
|
10
|
+
* Graph mutations (addNode, removeNode, etc.) are unique to this mode.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* The single evolving object for a continuous-mode graph.
|
|
15
|
+
* Bundles config + state so they can't get out of sync.
|
|
16
|
+
*/
|
|
17
|
+
interface LiveGraph {
|
|
18
|
+
/** The current graph configuration (evolves as nodes are added/removed) */
|
|
19
|
+
config: GraphConfig;
|
|
20
|
+
/** The current execution state (evolves as events arrive) */
|
|
21
|
+
state: ExecutionState;
|
|
22
|
+
}
|
|
23
|
+
interface ScheduleResult {
|
|
24
|
+
/** Tasks ready to dispatch now — all requires satisfied */
|
|
25
|
+
eligible: string[];
|
|
26
|
+
/** Tasks waiting on tokens that some producer will eventually provide (normal) */
|
|
27
|
+
pending: PendingTask[];
|
|
28
|
+
/** Tasks waiting on tokens that NO task can produce (caller's problem) */
|
|
29
|
+
unresolved: UnresolvedDependency[];
|
|
30
|
+
/** Tasks waiting on tokens whose producer FAILED (caller's problem) */
|
|
31
|
+
blocked: BlockedTask[];
|
|
32
|
+
/** Token conflicts: multiple tasks produce the same token */
|
|
33
|
+
conflicts: Record<string, string[]>;
|
|
34
|
+
}
|
|
35
|
+
interface PendingTask {
|
|
36
|
+
taskName: string;
|
|
37
|
+
/** Tokens this task needs that haven't been produced yet but have a viable producer */
|
|
38
|
+
waitingOn: string[];
|
|
39
|
+
}
|
|
40
|
+
interface UnresolvedDependency {
|
|
41
|
+
taskName: string;
|
|
42
|
+
/** Tokens this task needs that no task in the graph can produce */
|
|
43
|
+
missingTokens: string[];
|
|
44
|
+
}
|
|
45
|
+
interface BlockedTask {
|
|
46
|
+
taskName: string;
|
|
47
|
+
/** Tokens this task needs whose only producer has failed */
|
|
48
|
+
failedTokens: string[];
|
|
49
|
+
/** The tasks that failed and would have produced those tokens */
|
|
50
|
+
failedProducers: string[];
|
|
51
|
+
}
|
|
52
|
+
interface LiveGraphHealth {
|
|
53
|
+
/** Total number of tasks in the graph */
|
|
54
|
+
totalNodes: number;
|
|
55
|
+
/** Task counts by status */
|
|
56
|
+
running: number;
|
|
57
|
+
completed: number;
|
|
58
|
+
failed: number;
|
|
59
|
+
waiting: number;
|
|
60
|
+
notStarted: number;
|
|
61
|
+
/** Number of disabled (inactivated) nodes */
|
|
62
|
+
disabled: number;
|
|
63
|
+
/** Number of tasks with unresolvable dependencies */
|
|
64
|
+
unresolvedCount: number;
|
|
65
|
+
/** Number of tasks whose producer has failed */
|
|
66
|
+
blockedCount: number;
|
|
67
|
+
/** Tokens that no task produces (open dependencies) */
|
|
68
|
+
openDependencies: string[];
|
|
69
|
+
/** Cycles detected in the current graph (if any) */
|
|
70
|
+
cycles: string[][];
|
|
71
|
+
/** Tokens produced by multiple tasks */
|
|
72
|
+
conflictTokens: string[];
|
|
73
|
+
}
|
|
74
|
+
interface NodeInfo {
|
|
75
|
+
/** Node name */
|
|
76
|
+
name: string;
|
|
77
|
+
/** The task configuration */
|
|
78
|
+
config: TaskConfig;
|
|
79
|
+
/** The current runtime state */
|
|
80
|
+
state: TaskState;
|
|
81
|
+
}
|
|
82
|
+
interface LiveGraphSnapshot {
|
|
83
|
+
/** Schema version for forward compatibility */
|
|
84
|
+
version: number;
|
|
85
|
+
/** The graph config at snapshot time */
|
|
86
|
+
config: GraphConfig;
|
|
87
|
+
/** The execution state at snapshot time */
|
|
88
|
+
state: ExecutionState;
|
|
89
|
+
/** ISO timestamp of when the snapshot was taken */
|
|
90
|
+
snapshotAt: string;
|
|
91
|
+
}
|
|
92
|
+
interface UnreachableTokensResult {
|
|
93
|
+
tokens: {
|
|
94
|
+
/** The token that cannot be produced */
|
|
95
|
+
token: string;
|
|
96
|
+
/** Why it's unreachable */
|
|
97
|
+
reason: 'no-producer' | 'all-producers-failed' | 'transitive';
|
|
98
|
+
/** Tasks that could produce it (but are themselves unreachable/failed) */
|
|
99
|
+
producers: string[];
|
|
100
|
+
}[];
|
|
101
|
+
}
|
|
102
|
+
interface UnreachableNodesResult {
|
|
103
|
+
nodes: {
|
|
104
|
+
/** The node that can never become eligible */
|
|
105
|
+
nodeName: string;
|
|
106
|
+
/** Unreachable tokens this node requires (empty if the node itself is failed/disabled) */
|
|
107
|
+
missingTokens: string[];
|
|
108
|
+
}[];
|
|
109
|
+
}
|
|
110
|
+
interface UpstreamResult {
|
|
111
|
+
/** The target node being inspected */
|
|
112
|
+
nodeName: string;
|
|
113
|
+
/** All upstream nodes that transitively feed into the target */
|
|
114
|
+
nodes: {
|
|
115
|
+
nodeName: string;
|
|
116
|
+
/** Tokens this node provides that are in the dependency chain */
|
|
117
|
+
providesTokens: string[];
|
|
118
|
+
}[];
|
|
119
|
+
/** All tokens in the upstream dependency chain */
|
|
120
|
+
tokens: string[];
|
|
121
|
+
}
|
|
122
|
+
interface DownstreamResult {
|
|
123
|
+
/** The target node being inspected */
|
|
124
|
+
nodeName: string;
|
|
125
|
+
/** All downstream nodes that transitively depend on the target */
|
|
126
|
+
nodes: {
|
|
127
|
+
nodeName: string;
|
|
128
|
+
/** Tokens this node requires that are in the dependency chain */
|
|
129
|
+
requiresTokens: string[];
|
|
130
|
+
}[];
|
|
131
|
+
/** All tokens in the downstream dependency chain */
|
|
132
|
+
tokens: string[];
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export type { BlockedTask as B, DownstreamResult as D, LiveGraph as L, NodeInfo as N, PendingTask as P, ScheduleResult as S, UnreachableNodesResult as U, LiveGraphHealth as a, LiveGraphSnapshot as b, UnreachableTokensResult as c, UnresolvedDependency as d, UpstreamResult as e };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yaml-flow",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.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,16 @@
|
|
|
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"
|
|
61
|
+
},
|
|
62
|
+
"./inference": {
|
|
63
|
+
"types": "./dist/inference/index.d.ts",
|
|
64
|
+
"import": "./dist/inference/index.js",
|
|
65
|
+
"require": "./dist/inference/index.cjs"
|
|
56
66
|
}
|
|
57
67
|
},
|
|
58
68
|
"browser": {
|