@marktoflow/gui 2.0.0-alpha.1 → 2.0.0-alpha.3

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.
Files changed (74) hide show
  1. package/.turbo/turbo-build.log +7 -7
  2. package/README.md +38 -2
  3. package/dist/client/assets/index-C90Y_aBX.js +678 -0
  4. package/dist/client/assets/index-C90Y_aBX.js.map +1 -0
  5. package/dist/client/assets/index-CRWeQ3NN.css +1 -0
  6. package/dist/client/index.html +2 -2
  7. package/dist/server/server/index.js +1 -1
  8. package/dist/server/server/routes/tools.js +406 -0
  9. package/dist/server/server/routes/tools.js.map +1 -1
  10. package/dist/server/server/services/agents/codex-provider.js +270 -0
  11. package/dist/server/server/services/agents/codex-provider.js.map +1 -0
  12. package/dist/server/server/services/agents/prompts.js +27 -0
  13. package/dist/server/server/services/agents/prompts.js.map +1 -1
  14. package/dist/server/server/services/agents/registry.js +20 -0
  15. package/dist/server/server/services/agents/registry.js.map +1 -1
  16. package/package.json +6 -6
  17. package/src/client/components/Canvas/Canvas.tsx +24 -6
  18. package/src/client/components/Canvas/ForEachNode.tsx +128 -0
  19. package/src/client/components/Canvas/IfElseNode.tsx +126 -0
  20. package/src/client/components/Canvas/ParallelNode.tsx +140 -0
  21. package/src/client/components/Canvas/SwitchNode.tsx +164 -0
  22. package/src/client/components/Canvas/TransformNode.tsx +185 -0
  23. package/src/client/components/Canvas/TryCatchNode.tsx +164 -0
  24. package/src/client/components/Canvas/WhileNode.tsx +129 -0
  25. package/src/client/components/Canvas/index.ts +24 -0
  26. package/src/client/utils/serviceIcons.tsx +33 -0
  27. package/src/server/index.ts +1 -1
  28. package/src/server/routes/tools.ts +406 -0
  29. package/src/server/services/agents/codex-provider.ts +398 -0
  30. package/src/server/services/agents/prompts.ts +27 -0
  31. package/src/server/services/agents/registry.ts +21 -0
  32. package/tailwind.config.ts +1 -1
  33. package/tests/integration/api.test.ts +203 -1
  34. package/tests/integration/testApp.ts +1 -1
  35. package/tests/setup.ts +35 -0
  36. package/tests/unit/ForEachNode.test.tsx +218 -0
  37. package/tests/unit/IfElseNode.test.tsx +188 -0
  38. package/tests/unit/ParallelNode.test.tsx +264 -0
  39. package/tests/unit/SwitchNode.test.tsx +252 -0
  40. package/tests/unit/TransformNode.test.tsx +386 -0
  41. package/tests/unit/TryCatchNode.test.tsx +243 -0
  42. package/tests/unit/WhileNode.test.tsx +226 -0
  43. package/tests/unit/codexProvider.test.ts +399 -0
  44. package/tests/unit/serviceIcons.test.ts +197 -0
  45. package/.turbo/turbo-test.log +0 -22
  46. package/dist/client/assets/index-DwTI8opO.js +0 -608
  47. package/dist/client/assets/index-DwTI8opO.js.map +0 -1
  48. package/dist/client/assets/index-RoEdL6gO.css +0 -1
  49. package/dist/server/index.d.ts +0 -3
  50. package/dist/server/index.d.ts.map +0 -1
  51. package/dist/server/index.js +0 -56
  52. package/dist/server/index.js.map +0 -1
  53. package/dist/server/routes/ai.js +0 -50
  54. package/dist/server/routes/ai.js.map +0 -1
  55. package/dist/server/routes/execute.js +0 -62
  56. package/dist/server/routes/execute.js.map +0 -1
  57. package/dist/server/routes/workflows.js +0 -99
  58. package/dist/server/routes/workflows.js.map +0 -1
  59. package/dist/server/services/AIService.d.ts +0 -30
  60. package/dist/server/services/AIService.d.ts.map +0 -1
  61. package/dist/server/services/AIService.js +0 -216
  62. package/dist/server/services/AIService.js.map +0 -1
  63. package/dist/server/services/FileWatcher.d.ts +0 -10
  64. package/dist/server/services/FileWatcher.d.ts.map +0 -1
  65. package/dist/server/services/FileWatcher.js +0 -62
  66. package/dist/server/services/FileWatcher.js.map +0 -1
  67. package/dist/server/services/WorkflowService.d.ts +0 -54
  68. package/dist/server/services/WorkflowService.d.ts.map +0 -1
  69. package/dist/server/services/WorkflowService.js +0 -323
  70. package/dist/server/services/WorkflowService.js.map +0 -1
  71. package/dist/server/websocket/index.d.ts +0 -10
  72. package/dist/server/websocket/index.d.ts.map +0 -1
  73. package/dist/server/websocket/index.js +0 -85
  74. package/dist/server/websocket/index.js.map +0 -1
@@ -24,7 +24,7 @@ export function createTestApp(): Express {
24
24
 
25
25
  // Health check
26
26
  app.get('/api/health', (_req, res) => {
27
- res.json({ status: 'ok', version: '2.0.0-alpha.1' });
27
+ res.json({ status: 'ok', version: '2.0.0-alpha.2' });
28
28
  });
29
29
 
30
30
  return app;
package/tests/setup.ts CHANGED
@@ -35,3 +35,38 @@ global.IntersectionObserver = vi.fn().mockImplementation(() => ({
35
35
 
36
36
  // Suppress console errors during tests (optional)
37
37
  vi.spyOn(console, 'error').mockImplementation(() => {});
38
+
39
+ // Mock localStorage
40
+ const localStorageMock = (() => {
41
+ let store: Record<string, string> = {};
42
+
43
+ return {
44
+ getItem: (key: string) => store[key] || null,
45
+ setItem: (key: string, value: string) => {
46
+ store[key] = value.toString();
47
+ },
48
+ removeItem: (key: string) => {
49
+ delete store[key];
50
+ },
51
+ clear: () => {
52
+ store = {};
53
+ },
54
+ get length() {
55
+ return Object.keys(store).length;
56
+ },
57
+ key: (index: number) => {
58
+ const keys = Object.keys(store);
59
+ return keys[index] || null;
60
+ },
61
+ };
62
+ })();
63
+
64
+ Object.defineProperty(window, 'localStorage', {
65
+ value: localStorageMock,
66
+ writable: true,
67
+ });
68
+
69
+ Object.defineProperty(window, 'sessionStorage', {
70
+ value: localStorageMock,
71
+ writable: true,
72
+ });
@@ -0,0 +1,218 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import { render, screen } from '@testing-library/react';
3
+ import { ReactFlowProvider } from '@xyflow/react';
4
+ import { ForEachNode, type ForEachNodeData } from '../../src/client/components/Canvas/ForEachNode';
5
+
6
+ const createMockNode = (data: Partial<ForEachNodeData> = {}) => ({
7
+ id: 'foreach-1',
8
+ type: 'for_each' as const,
9
+ position: { x: 0, y: 0 },
10
+ data: {
11
+ id: 'foreach-1',
12
+ name: 'Process Orders',
13
+ items: '{{ orders }}',
14
+ itemVariable: 'order',
15
+ status: 'pending' as const,
16
+ ...data,
17
+ },
18
+ });
19
+
20
+ const renderNode = (data: Partial<ForEachNodeData> = {}) => {
21
+ const node = createMockNode(data);
22
+ return render(
23
+ <ReactFlowProvider>
24
+ <ForEachNode
25
+ id={node.id}
26
+ type={node.type}
27
+ data={node.data}
28
+ selected={false}
29
+ isConnectable={true}
30
+ zIndex={0}
31
+ positionAbsoluteX={0}
32
+ positionAbsoluteY={0}
33
+ dragging={false}
34
+ />
35
+ </ReactFlowProvider>
36
+ );
37
+ };
38
+
39
+ describe('ForEachNode', () => {
40
+ it('should render node with name, items, and variable', () => {
41
+ renderNode();
42
+
43
+ expect(screen.getByText('Process Orders')).toBeInTheDocument();
44
+ expect(screen.getByText('{{ orders }}')).toBeInTheDocument();
45
+ expect(screen.getByText('order')).toBeInTheDocument();
46
+ expect(screen.getByText('Loop')).toBeInTheDocument();
47
+ });
48
+
49
+ it('should render default name when name is not provided', () => {
50
+ renderNode({ name: undefined });
51
+
52
+ expect(screen.getByText('For Each')).toBeInTheDocument();
53
+ });
54
+
55
+ it('should render default item variable when not provided', () => {
56
+ renderNode({ itemVariable: undefined });
57
+
58
+ expect(screen.getByText('item')).toBeInTheDocument();
59
+ });
60
+
61
+ it('should display items and variable labels', () => {
62
+ renderNode();
63
+
64
+ expect(screen.getByText('Items:')).toBeInTheDocument();
65
+ expect(screen.getByText('Variable:')).toBeInTheDocument();
66
+ });
67
+
68
+ describe('status states', () => {
69
+ it('should render pending status', () => {
70
+ renderNode({ status: 'pending' });
71
+
72
+ const node = screen.getByText('Process Orders').closest('.control-flow-node');
73
+ expect(node).toBeInTheDocument();
74
+ });
75
+
76
+ it('should render running status with animation', () => {
77
+ renderNode({ status: 'running' });
78
+
79
+ const node = screen.getByText('Process Orders').closest('.control-flow-node');
80
+ expect(node).toHaveClass('running');
81
+ });
82
+
83
+ it('should render completed status', () => {
84
+ renderNode({ status: 'completed' });
85
+
86
+ const node = screen.getByText('Process Orders').closest('.control-flow-node');
87
+ expect(node).toBeInTheDocument();
88
+ });
89
+
90
+ it('should render failed status', () => {
91
+ renderNode({ status: 'failed' });
92
+
93
+ const node = screen.getByText('Process Orders').closest('.control-flow-node');
94
+ expect(node).toBeInTheDocument();
95
+ });
96
+ });
97
+
98
+ describe('iteration progress', () => {
99
+ it('should display progress when totalIterations is provided', () => {
100
+ renderNode({
101
+ currentIteration: 5,
102
+ totalIterations: 10,
103
+ });
104
+
105
+ expect(screen.getByText('Progress')).toBeInTheDocument();
106
+ expect(screen.getByText('5 / 10')).toBeInTheDocument();
107
+ });
108
+
109
+ it('should display progress bar with correct width', () => {
110
+ const { container } = renderNode({
111
+ currentIteration: 5,
112
+ totalIterations: 10,
113
+ });
114
+
115
+ const progressBar = container.querySelector('.bg-orange-400');
116
+ expect(progressBar).toHaveStyle({ width: '50%' });
117
+ });
118
+
119
+ it('should display 0% progress when currentIteration is 0', () => {
120
+ const { container } = renderNode({
121
+ currentIteration: 0,
122
+ totalIterations: 10,
123
+ });
124
+
125
+ const progressBar = container.querySelector('.bg-orange-400');
126
+ expect(progressBar).toHaveStyle({ width: '0%' });
127
+ });
128
+
129
+ it('should display 100% progress when completed', () => {
130
+ const { container } = renderNode({
131
+ currentIteration: 10,
132
+ totalIterations: 10,
133
+ });
134
+
135
+ const progressBar = container.querySelector('.bg-orange-400');
136
+ expect(progressBar).toHaveStyle({ width: '100%' });
137
+ });
138
+
139
+ it('should not display progress when totalIterations is undefined', () => {
140
+ renderNode({ currentIteration: 5, totalIterations: undefined });
141
+
142
+ expect(screen.queryByText('Progress')).not.toBeInTheDocument();
143
+ });
144
+ });
145
+
146
+ describe('loop metadata', () => {
147
+ it('should display loop metadata information', () => {
148
+ renderNode();
149
+
150
+ expect(screen.getByText('ℹ️')).toBeInTheDocument();
151
+ expect(screen.getByText('Access: loop.index, loop.first, loop.last')).toBeInTheDocument();
152
+ });
153
+ });
154
+
155
+ describe('visual styling', () => {
156
+ it('should have pink/red gradient background', () => {
157
+ renderNode();
158
+
159
+ const node = screen.getByText('Process Orders').closest('.control-flow-node');
160
+ expect(node).toHaveStyle({
161
+ background: 'linear-gradient(135deg, #f093fb 0%, #f5576c 100%)',
162
+ });
163
+ });
164
+
165
+ it('should display items with monospace font', () => {
166
+ renderNode();
167
+
168
+ const itemsElement = screen.getByText('{{ orders }}');
169
+ expect(itemsElement).toHaveClass('font-mono');
170
+ });
171
+
172
+ it('should display variable with monospace font', () => {
173
+ renderNode();
174
+
175
+ const variableElement = screen.getByText('order');
176
+ expect(variableElement).toHaveClass('font-mono');
177
+ });
178
+ });
179
+
180
+ describe('selection state', () => {
181
+ it('should apply selected class when selected', () => {
182
+ const node = createMockNode();
183
+ const { container } = render(
184
+ <ReactFlowProvider>
185
+ <ForEachNode
186
+ id={node.id}
187
+ type={node.type}
188
+ data={node.data}
189
+ selected={true}
190
+ isConnectable={true}
191
+ zIndex={0}
192
+ positionAbsoluteX={0}
193
+ positionAbsoluteY={0}
194
+ dragging={false}
195
+ />
196
+ </ReactFlowProvider>
197
+ );
198
+
199
+ const nodeElement = container.querySelector('.control-flow-node');
200
+ expect(nodeElement).toHaveClass('selected');
201
+ });
202
+ });
203
+
204
+ describe('items display', () => {
205
+ it('should display "Not set" when items is empty', () => {
206
+ renderNode({ items: '' });
207
+
208
+ expect(screen.getByText('Not set')).toBeInTheDocument();
209
+ });
210
+
211
+ it('should display complex template expressions', () => {
212
+ const complexItems = '{{ data.orders.filter(o => o.active) }}';
213
+ renderNode({ items: complexItems });
214
+
215
+ expect(screen.getByText(complexItems)).toBeInTheDocument();
216
+ });
217
+ });
218
+ });
@@ -0,0 +1,188 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import { render, screen } from '@testing-library/react';
3
+ import { ReactFlowProvider } from '@xyflow/react';
4
+ import { IfElseNode, type IfElseNodeData } from '../../src/client/components/Canvas/IfElseNode';
5
+
6
+ const createMockNode = (data: Partial<IfElseNodeData> = {}) => ({
7
+ id: 'if-1',
8
+ type: 'if' as const,
9
+ position: { x: 0, y: 0 },
10
+ data: {
11
+ id: 'if-1',
12
+ name: 'Check Count',
13
+ condition: '{{ count > 0 }}',
14
+ status: 'pending' as const,
15
+ ...data,
16
+ },
17
+ });
18
+
19
+ const renderNode = (data: Partial<IfElseNodeData> = {}) => {
20
+ const node = createMockNode(data);
21
+ return render(
22
+ <ReactFlowProvider>
23
+ <IfElseNode
24
+ id={node.id}
25
+ type={node.type}
26
+ data={node.data}
27
+ selected={false}
28
+ isConnectable={true}
29
+ zIndex={0}
30
+ positionAbsoluteX={0}
31
+ positionAbsoluteY={0}
32
+ dragging={false}
33
+ />
34
+ </ReactFlowProvider>
35
+ );
36
+ };
37
+
38
+ describe('IfElseNode', () => {
39
+ it('should render node with name and condition', () => {
40
+ renderNode();
41
+
42
+ expect(screen.getByText('Check Count')).toBeInTheDocument();
43
+ expect(screen.getByText('{{ count > 0 }}')).toBeInTheDocument();
44
+ expect(screen.getByText('Conditional')).toBeInTheDocument();
45
+ });
46
+
47
+ it('should render default name when name is not provided', () => {
48
+ renderNode({ name: undefined });
49
+
50
+ expect(screen.getByText('If/Else')).toBeInTheDocument();
51
+ });
52
+
53
+ it('should display condition with monospace font', () => {
54
+ renderNode();
55
+
56
+ const conditionElement = screen.getByText('{{ count > 0 }}');
57
+ expect(conditionElement).toHaveClass('font-mono');
58
+ });
59
+
60
+ describe('status states', () => {
61
+ it('should render pending status', () => {
62
+ renderNode({ status: 'pending' });
63
+
64
+ // Should have Clock icon for pending status
65
+ const node = screen.getByText('Check Count').closest('.control-flow-node');
66
+ expect(node).toBeInTheDocument();
67
+ });
68
+
69
+ it('should render running status with animation', () => {
70
+ renderNode({ status: 'running' });
71
+
72
+ const node = screen.getByText('Check Count').closest('.control-flow-node');
73
+ expect(node).toHaveClass('running');
74
+ });
75
+
76
+ it('should render completed status', () => {
77
+ renderNode({ status: 'completed' });
78
+
79
+ // Status should be completed
80
+ const node = screen.getByText('Check Count').closest('.control-flow-node');
81
+ expect(node).toBeInTheDocument();
82
+ });
83
+
84
+ it('should render failed status', () => {
85
+ renderNode({ status: 'failed' });
86
+
87
+ const node = screen.getByText('Check Count').closest('.control-flow-node');
88
+ expect(node).toBeInTheDocument();
89
+ });
90
+
91
+ it('should render skipped status', () => {
92
+ renderNode({ status: 'skipped' });
93
+
94
+ const node = screen.getByText('Check Count').closest('.control-flow-node');
95
+ expect(node).toBeInTheDocument();
96
+ });
97
+ });
98
+
99
+ describe('active branch highlighting', () => {
100
+ it('should highlight then branch when active', () => {
101
+ renderNode({ activeBranch: 'then' });
102
+
103
+ const thenBranch = screen.getByText('✓ Then');
104
+ expect(thenBranch).toHaveClass('bg-green-500/30', 'text-green-200');
105
+ });
106
+
107
+ it('should highlight else branch when active', () => {
108
+ renderNode({ activeBranch: 'else' });
109
+
110
+ const elseBranch = screen.getByText('✗ Else');
111
+ expect(elseBranch).toHaveClass('bg-red-500/30', 'text-red-200');
112
+ });
113
+
114
+ it('should not highlight branches when no active branch', () => {
115
+ renderNode({ activeBranch: null });
116
+
117
+ const thenBranch = screen.getByText('✓ Then');
118
+ const elseBranch = screen.getByText('✗ Else');
119
+
120
+ expect(thenBranch).toHaveClass('bg-white/5', 'text-white/60');
121
+ expect(elseBranch).toHaveClass('bg-white/5', 'text-white/60');
122
+ });
123
+ });
124
+
125
+ describe('branch outputs', () => {
126
+ it('should display both then and else branches', () => {
127
+ renderNode();
128
+
129
+ expect(screen.getByText('✓ Then')).toBeInTheDocument();
130
+ expect(screen.getByText('✗ Else')).toBeInTheDocument();
131
+ });
132
+
133
+ it('should have gradient background', () => {
134
+ renderNode();
135
+
136
+ const node = screen.getByText('Check Count').closest('.control-flow-node');
137
+ expect(node).toHaveStyle({
138
+ background: 'linear-gradient(135deg, #667eea 0%, #764ba2 100%)',
139
+ });
140
+ });
141
+ });
142
+
143
+ describe('selection state', () => {
144
+ it('should apply selected class when selected', () => {
145
+ const node = createMockNode();
146
+ const { container } = render(
147
+ <ReactFlowProvider>
148
+ <IfElseNode
149
+ id={node.id}
150
+ type={node.type}
151
+ data={node.data}
152
+ selected={true}
153
+ isConnectable={true}
154
+ zIndex={0}
155
+ positionAbsoluteX={0}
156
+ positionAbsoluteY={0}
157
+ dragging={false}
158
+ />
159
+ </ReactFlowProvider>
160
+ );
161
+
162
+ const nodeElement = container.querySelector('.control-flow-node');
163
+ expect(nodeElement).toHaveClass('selected');
164
+ });
165
+
166
+ it('should not apply selected class when not selected', () => {
167
+ const { container } = renderNode();
168
+
169
+ const nodeElement = container.querySelector('.control-flow-node');
170
+ expect(nodeElement).not.toHaveClass('selected');
171
+ });
172
+ });
173
+
174
+ describe('condition display', () => {
175
+ it('should display "No condition set" when condition is empty', () => {
176
+ renderNode({ condition: '' });
177
+
178
+ expect(screen.getByText('No condition set')).toBeInTheDocument();
179
+ });
180
+
181
+ it('should display complex conditions correctly', () => {
182
+ const complexCondition = '{{ priority === "critical" && assignee !== null }}';
183
+ renderNode({ condition: complexCondition });
184
+
185
+ expect(screen.getByText(complexCondition)).toBeInTheDocument();
186
+ });
187
+ });
188
+ });