@crewx/workflow 0.1.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 @@
1
+ {"version":3,"file":"run-manager.js","sourceRoot":"","sources":["../../src/run-manager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgBA,oCAeC;AAKD,8BAMC;AAnCD,uCAAyB;AACzB,2CAA6B;AAC7B,8CAAgC;AAOhC,SAAgB,YAAY,CAAC,IAAc;IACzC,MAAM,IAAI,GAA2B,EAAE,CAAC;IACxC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACrC,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;YAC/C,MAAM,IAAI,GAAG,IAAI,CAAC,CAAC,GAAG,CAAC,CAAE,CAAC;YAC1B,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;YAChC,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE,CAAC;gBACjB,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;gBACrC,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;gBACxC,IAAI,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;YACpB,CAAC;YACD,CAAC,EAAE,CAAC;QACN,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAKM,KAAK,UAAU,SAAS;IAC7B,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;QACxC,MAAM,CAAC,IAAI,CAAC,KA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;QACzB,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAClB,OAAO,GAAG,CAAC;IACb,CAAC;IAED,QAAQ;QACN,IAAI,CAAC,aAAa,EAAE,CAAC;QAErB,MAAM,KAAK,GAAG,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;QAChF,MAAM,IAAI,GAAmB,EAAE,CAAC;QAEhC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,IAAI,CAAC;gBACH,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CACpB,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,EAAE,OAAO,CAAC,CAC5C,CAAC;gBAClB,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YACjB,CAAC;YAAC,MAAM,CAAC;YAET,CAAC;QACH,CAAC;QAGD,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,OAAO,EAAE,GAAG,IAAI,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;QACzF,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAtJD,gCAsJC"}
@@ -0,0 +1,76 @@
1
+ export interface WorkflowMeta {
2
+ name: string;
3
+ description?: string;
4
+ version?: string;
5
+ }
6
+ export interface RetryConfig {
7
+ max: number;
8
+ delay: 'exponential' | 'fixed';
9
+ max_delay?: number;
10
+ on?: string[];
11
+ }
12
+ export interface OnError {
13
+ handler?: string;
14
+ fallback_node?: string;
15
+ }
16
+ export type NodeType = 'agent_task' | 'parallel' | 'join' | 'branch' | 'approval' | 'end';
17
+ export interface WorkflowNode {
18
+ type: NodeType;
19
+ agent?: string;
20
+ mode?: 'query' | 'execute';
21
+ input?: string;
22
+ output?: string;
23
+ next?: string;
24
+ hooks?: string[];
25
+ retry?: RetryConfig;
26
+ condition?: string;
27
+ branches?: string[] | Record<string, string>;
28
+ default?: string;
29
+ join?: string;
30
+ on_failure?: 'fail_fast' | 'continue' | 'ignore';
31
+ description?: string;
32
+ assignee?: string;
33
+ timeout?: number;
34
+ channels?: string[];
35
+ comment?: string;
36
+ on_approve?: string;
37
+ on_reject?: string;
38
+ on_error?: OnError;
39
+ }
40
+ export interface WorkflowSpec {
41
+ metadata?: WorkflowMeta;
42
+ timeout?: number;
43
+ max_iterations?: number;
44
+ state?: Record<string, unknown>;
45
+ nodes: Record<string, WorkflowNode>;
46
+ }
47
+ export interface WorkflowDocument {
48
+ workflows?: Record<string, WorkflowSpec>;
49
+ agents?: Record<string, unknown>;
50
+ }
51
+ export interface LoadedWorkflow {
52
+ id: string;
53
+ filePath: string;
54
+ spec: WorkflowSpec;
55
+ }
56
+ export interface ValidationError {
57
+ path: string;
58
+ message: string;
59
+ }
60
+ export interface ValidationResult {
61
+ name: string;
62
+ valid: boolean;
63
+ errors: ValidationError[];
64
+ }
65
+ export interface RunExecution {
66
+ id: string;
67
+ workflow_id: string;
68
+ workflow_file: string;
69
+ created_at: string;
70
+ updated_at: string;
71
+ current_node: string;
72
+ completed_nodes: string[];
73
+ state: Record<string, unknown>;
74
+ initial_state: Record<string, unknown>;
75
+ }
76
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE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Q,CAAC,EAAE,YAAY,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;CACrC;AAED,MAAM,WAAW,gBAAgB;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IACzC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC;AAED,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,YAAY,CAAC;CACpB;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,eAAe,EAAE,CAAC;CAC3B;AAED,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACxC"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,173 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "title": "CrewX Workflow Schema",
4
+ "description": "JSON Schema for crewx.yaml workflows section",
5
+ "type": "object",
6
+ "additionalProperties": {
7
+ "$ref": "#/definitions/WorkflowSpec"
8
+ },
9
+ "definitions": {
10
+ "WorkflowSpec": {
11
+ "type": "object",
12
+ "required": ["nodes"],
13
+ "properties": {
14
+ "metadata": {
15
+ "$ref": "#/definitions/Metadata"
16
+ },
17
+ "timeout": {
18
+ "type": "number"
19
+ },
20
+ "max_iterations": {
21
+ "type": "number"
22
+ },
23
+ "state": {
24
+ "type": "object"
25
+ },
26
+ "nodes": {
27
+ "type": "object",
28
+ "additionalProperties": {
29
+ "$ref": "#/definitions/WorkflowNode"
30
+ }
31
+ }
32
+ }
33
+ },
34
+ "Metadata": {
35
+ "type": "object",
36
+ "required": ["name"],
37
+ "properties": {
38
+ "name": {
39
+ "type": "string"
40
+ },
41
+ "description": {
42
+ "type": "string"
43
+ },
44
+ "version": {
45
+ "type": "string"
46
+ }
47
+ }
48
+ },
49
+ "WorkflowNode": {
50
+ "type": "object",
51
+ "required": ["type"],
52
+ "properties": {
53
+ "type": {
54
+ "type": "string",
55
+ "enum": ["agent_task", "parallel", "join", "branch", "approval", "end"]
56
+ },
57
+ "agent": {
58
+ "type": "string"
59
+ },
60
+ "mode": {
61
+ "type": "string",
62
+ "enum": ["query", "execute"]
63
+ },
64
+ "input": {
65
+ "type": "string"
66
+ },
67
+ "output": {
68
+ "type": "string"
69
+ },
70
+ "hooks": {
71
+ "type": "array",
72
+ "items": {
73
+ "type": "string"
74
+ }
75
+ },
76
+ "retry": {
77
+ "$ref": "#/definitions/RetryConfig"
78
+ },
79
+ "condition": {
80
+ "type": "string"
81
+ },
82
+ "branches": {
83
+ "oneOf": [
84
+ {
85
+ "type": "array",
86
+ "items": {
87
+ "type": "string"
88
+ },
89
+ "description": "For parallel nodes: array of node IDs to execute concurrently"
90
+ },
91
+ {
92
+ "type": "object",
93
+ "additionalProperties": {
94
+ "type": "string"
95
+ },
96
+ "description": "For branch nodes: condition value -> target node ID mapping"
97
+ }
98
+ ]
99
+ },
100
+ "default": {
101
+ "type": "string"
102
+ },
103
+ "join": {
104
+ "type": "string"
105
+ },
106
+ "on_failure": {
107
+ "type": "string",
108
+ "enum": ["fail_fast", "continue", "ignore"]
109
+ },
110
+ "description": {
111
+ "type": "string"
112
+ },
113
+ "assignee": {
114
+ "type": "string"
115
+ },
116
+ "timeout": {
117
+ "type": "number"
118
+ },
119
+ "channels": {
120
+ "type": "array",
121
+ "items": {
122
+ "type": "string"
123
+ }
124
+ },
125
+ "comment": {
126
+ "type": "string"
127
+ },
128
+ "on_approve": {
129
+ "type": "string"
130
+ },
131
+ "on_reject": {
132
+ "type": "string"
133
+ },
134
+ "next": {
135
+ "type": "string"
136
+ },
137
+ "on_error": {
138
+ "type": "object",
139
+ "properties": {
140
+ "handler": {
141
+ "type": "string"
142
+ },
143
+ "fallback_node": {
144
+ "type": "string"
145
+ }
146
+ }
147
+ }
148
+ }
149
+ },
150
+ "RetryConfig": {
151
+ "type": "object",
152
+ "required": ["max", "delay"],
153
+ "properties": {
154
+ "max": {
155
+ "type": "number"
156
+ },
157
+ "delay": {
158
+ "type": "string",
159
+ "enum": ["exponential", "fixed"]
160
+ },
161
+ "max_delay": {
162
+ "type": "number"
163
+ },
164
+ "on": {
165
+ "type": "array",
166
+ "items": {
167
+ "type": "string"
168
+ }
169
+ }
170
+ }
171
+ }
172
+ }
173
+ }
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "@crewx/workflow",
3
+ "version": "0.1.0",
4
+ "description": "Workflow engine for CrewX - list, show, validate workflows with Mermaid visualization",
5
+ "type": "commonjs",
6
+ "main": "dist/src/engine.js",
7
+ "types": "dist/src/engine.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/src/engine.d.ts",
11
+ "import": "./dist/src/engine.js",
12
+ "require": "./dist/src/engine.js",
13
+ "default": "./dist/src/engine.js"
14
+ },
15
+ "./cli": {
16
+ "import": "./dist/cli.js",
17
+ "require": "./dist/cli.js",
18
+ "default": "./dist/cli.js"
19
+ }
20
+ },
21
+ "bin": {
22
+ "workflow": "./dist/cli.js"
23
+ },
24
+ "files": ["dist", "SKILL.md", "workflow-schema.json"],
25
+ "scripts": {
26
+ "build": "tsc && cp workflow-schema.json dist/",
27
+ "dev": "ts-node cli.ts",
28
+ "clean": "rm -rf dist",
29
+ "test": "vitest run"
30
+ },
31
+ "keywords": ["crewx", "workflow", "mermaid", "yaml"],
32
+ "license": "MIT",
33
+ "dependencies": {
34
+ "@crewx/shared": "0.0.3",
35
+ "js-yaml": "^4.1.0"
36
+ },
37
+ "devDependencies": {
38
+ "@types/js-yaml": "^4.0.9",
39
+ "@types/node": "^20.0.0",
40
+ "ts-node": "^10.9.0",
41
+ "typescript": "^5.0.0",
42
+ "vitest": "^1.0.0"
43
+ }
44
+ }
@@ -0,0 +1,173 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "title": "CrewX Workflow Schema",
4
+ "description": "JSON Schema for crewx.yaml workflows section",
5
+ "type": "object",
6
+ "additionalProperties": {
7
+ "$ref": "#/definitions/WorkflowSpec"
8
+ },
9
+ "definitions": {
10
+ "WorkflowSpec": {
11
+ "type": "object",
12
+ "required": ["nodes"],
13
+ "properties": {
14
+ "metadata": {
15
+ "$ref": "#/definitions/Metadata"
16
+ },
17
+ "timeout": {
18
+ "type": "number"
19
+ },
20
+ "max_iterations": {
21
+ "type": "number"
22
+ },
23
+ "state": {
24
+ "type": "object"
25
+ },
26
+ "nodes": {
27
+ "type": "object",
28
+ "additionalProperties": {
29
+ "$ref": "#/definitions/WorkflowNode"
30
+ }
31
+ }
32
+ }
33
+ },
34
+ "Metadata": {
35
+ "type": "object",
36
+ "required": ["name"],
37
+ "properties": {
38
+ "name": {
39
+ "type": "string"
40
+ },
41
+ "description": {
42
+ "type": "string"
43
+ },
44
+ "version": {
45
+ "type": "string"
46
+ }
47
+ }
48
+ },
49
+ "WorkflowNode": {
50
+ "type": "object",
51
+ "required": ["type"],
52
+ "properties": {
53
+ "type": {
54
+ "type": "string",
55
+ "enum": ["agent_task", "parallel", "join", "branch", "approval", "end"]
56
+ },
57
+ "agent": {
58
+ "type": "string"
59
+ },
60
+ "mode": {
61
+ "type": "string",
62
+ "enum": ["query", "execute"]
63
+ },
64
+ "input": {
65
+ "type": "string"
66
+ },
67
+ "output": {
68
+ "type": "string"
69
+ },
70
+ "hooks": {
71
+ "type": "array",
72
+ "items": {
73
+ "type": "string"
74
+ }
75
+ },
76
+ "retry": {
77
+ "$ref": "#/definitions/RetryConfig"
78
+ },
79
+ "condition": {
80
+ "type": "string"
81
+ },
82
+ "branches": {
83
+ "oneOf": [
84
+ {
85
+ "type": "array",
86
+ "items": {
87
+ "type": "string"
88
+ },
89
+ "description": "For parallel nodes: array of node IDs to execute concurrently"
90
+ },
91
+ {
92
+ "type": "object",
93
+ "additionalProperties": {
94
+ "type": "string"
95
+ },
96
+ "description": "For branch nodes: condition value -> target node ID mapping"
97
+ }
98
+ ]
99
+ },
100
+ "default": {
101
+ "type": "string"
102
+ },
103
+ "join": {
104
+ "type": "string"
105
+ },
106
+ "on_failure": {
107
+ "type": "string",
108
+ "enum": ["fail_fast", "continue", "ignore"]
109
+ },
110
+ "description": {
111
+ "type": "string"
112
+ },
113
+ "assignee": {
114
+ "type": "string"
115
+ },
116
+ "timeout": {
117
+ "type": "number"
118
+ },
119
+ "channels": {
120
+ "type": "array",
121
+ "items": {
122
+ "type": "string"
123
+ }
124
+ },
125
+ "comment": {
126
+ "type": "string"
127
+ },
128
+ "on_approve": {
129
+ "type": "string"
130
+ },
131
+ "on_reject": {
132
+ "type": "string"
133
+ },
134
+ "next": {
135
+ "type": "string"
136
+ },
137
+ "on_error": {
138
+ "type": "object",
139
+ "properties": {
140
+ "handler": {
141
+ "type": "string"
142
+ },
143
+ "fallback_node": {
144
+ "type": "string"
145
+ }
146
+ }
147
+ }
148
+ }
149
+ },
150
+ "RetryConfig": {
151
+ "type": "object",
152
+ "required": ["max", "delay"],
153
+ "properties": {
154
+ "max": {
155
+ "type": "number"
156
+ },
157
+ "delay": {
158
+ "type": "string",
159
+ "enum": ["exponential", "fixed"]
160
+ },
161
+ "max_delay": {
162
+ "type": "number"
163
+ },
164
+ "on": {
165
+ "type": "array",
166
+ "items": {
167
+ "type": "string"
168
+ }
169
+ }
170
+ }
171
+ }
172
+ }
173
+ }