@marktoflow/gui 2.0.0-alpha.12 → 2.0.0-alpha.13

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 (121) hide show
  1. package/package.json +1 -3
  2. package/.marktoflow/state/workflow-state.db +0 -0
  3. package/.marktoflow/state/workflow-state.db-shm +0 -0
  4. package/.marktoflow/state/workflow-state.db-wal +0 -0
  5. package/.turbo/turbo-build.log +0 -42
  6. package/.turbo/turbo-test.log +0 -38
  7. package/marktoflow-gui-2.0.0-alpha.12.tgz +0 -0
  8. package/playwright.config.ts +0 -27
  9. package/postcss.config.js +0 -6
  10. package/src/client/App.tsx +0 -520
  11. package/src/client/components/Canvas/Canvas.tsx +0 -425
  12. package/src/client/components/Canvas/ExecutionOverlay.tsx +0 -935
  13. package/src/client/components/Canvas/ForEachNode.tsx +0 -152
  14. package/src/client/components/Canvas/IfElseNode.tsx +0 -141
  15. package/src/client/components/Canvas/NodeContextMenu.tsx +0 -192
  16. package/src/client/components/Canvas/OutputNode.tsx +0 -111
  17. package/src/client/components/Canvas/ParallelNode.tsx +0 -157
  18. package/src/client/components/Canvas/StepNode.tsx +0 -106
  19. package/src/client/components/Canvas/SubWorkflowNode.tsx +0 -141
  20. package/src/client/components/Canvas/SwitchNode.tsx +0 -185
  21. package/src/client/components/Canvas/Toolbar.tsx +0 -227
  22. package/src/client/components/Canvas/TransformNode.tsx +0 -194
  23. package/src/client/components/Canvas/TriggerNode.tsx +0 -128
  24. package/src/client/components/Canvas/TryCatchNode.tsx +0 -164
  25. package/src/client/components/Canvas/WhileNode.tsx +0 -161
  26. package/src/client/components/Canvas/index.ts +0 -24
  27. package/src/client/components/Debug/VariableInspector.tsx +0 -148
  28. package/src/client/components/Editor/InputsEditor.tsx +0 -458
  29. package/src/client/components/Editor/NewStepWizard.tsx +0 -344
  30. package/src/client/components/Editor/StepEditor.tsx +0 -532
  31. package/src/client/components/Editor/YamlEditor.tsx +0 -160
  32. package/src/client/components/Panels/PropertiesPanel.tsx +0 -589
  33. package/src/client/components/Prompt/ChangePreview.tsx +0 -281
  34. package/src/client/components/Prompt/PromptHistoryPanel.tsx +0 -209
  35. package/src/client/components/Prompt/PromptInput.tsx +0 -110
  36. package/src/client/components/Settings/ProviderSwitcher.tsx +0 -228
  37. package/src/client/components/Sidebar/ImportDialog.tsx +0 -257
  38. package/src/client/components/Sidebar/Sidebar.tsx +0 -362
  39. package/src/client/components/common/Breadcrumb.tsx +0 -40
  40. package/src/client/components/common/Button.tsx +0 -68
  41. package/src/client/components/common/ContextMenu.tsx +0 -202
  42. package/src/client/components/common/KeyboardShortcuts.tsx +0 -149
  43. package/src/client/components/common/Modal.tsx +0 -93
  44. package/src/client/components/common/Tabs.tsx +0 -57
  45. package/src/client/components/common/ThemeToggle.tsx +0 -63
  46. package/src/client/components/index.ts +0 -32
  47. package/src/client/hooks/index.ts +0 -4
  48. package/src/client/hooks/useAIPrompt.ts +0 -108
  49. package/src/client/hooks/useCanvas.ts +0 -247
  50. package/src/client/hooks/useWebSocket.ts +0 -164
  51. package/src/client/hooks/useWorkflow.ts +0 -138
  52. package/src/client/main.tsx +0 -10
  53. package/src/client/stores/agentStore.ts +0 -109
  54. package/src/client/stores/canvasStore.ts +0 -348
  55. package/src/client/stores/editorStore.ts +0 -133
  56. package/src/client/stores/executionStore.ts +0 -502
  57. package/src/client/stores/index.ts +0 -4
  58. package/src/client/stores/layoutStore.ts +0 -103
  59. package/src/client/stores/navigationStore.ts +0 -49
  60. package/src/client/stores/promptStore.ts +0 -113
  61. package/src/client/stores/themeStore.ts +0 -75
  62. package/src/client/stores/workflowStore.ts +0 -185
  63. package/src/client/styles/globals.css +0 -452
  64. package/src/client/utils/cn.ts +0 -9
  65. package/src/client/utils/index.ts +0 -4
  66. package/src/client/utils/platform.ts +0 -46
  67. package/src/client/utils/serviceIcons.tsx +0 -97
  68. package/src/client/utils/stepValidation.ts +0 -155
  69. package/src/client/utils/workflowToGraph.ts +0 -523
  70. package/src/server/index.ts +0 -137
  71. package/src/server/routes/ai.ts +0 -91
  72. package/src/server/routes/execute.ts +0 -71
  73. package/src/server/routes/executions.ts +0 -136
  74. package/src/server/routes/tools.ts +0 -970
  75. package/src/server/routes/workflows.ts +0 -147
  76. package/src/server/services/AIService.ts +0 -105
  77. package/src/server/services/FileWatcher.ts +0 -69
  78. package/src/server/services/WorkflowService.ts +0 -601
  79. package/src/server/services/agents/claude-code-provider.ts +0 -320
  80. package/src/server/services/agents/claude-provider.ts +0 -248
  81. package/src/server/services/agents/codex-provider.ts +0 -398
  82. package/src/server/services/agents/copilot-provider.ts +0 -311
  83. package/src/server/services/agents/demo-provider.ts +0 -184
  84. package/src/server/services/agents/index.ts +0 -31
  85. package/src/server/services/agents/ollama-provider.ts +0 -267
  86. package/src/server/services/agents/prompts.ts +0 -509
  87. package/src/server/services/agents/registry.ts +0 -310
  88. package/src/server/services/agents/types.ts +0 -146
  89. package/src/server/websocket/index.ts +0 -117
  90. package/src/shared/constants.ts +0 -180
  91. package/src/shared/types.ts +0 -179
  92. package/tailwind.config.ts +0 -73
  93. package/tests/e2e/app.spec.ts +0 -90
  94. package/tests/e2e/canvas.spec.ts +0 -128
  95. package/tests/e2e/workflow.spec.ts +0 -185
  96. package/tests/integration/api.test.ts +0 -452
  97. package/tests/integration/testApp.ts +0 -31
  98. package/tests/setup.ts +0 -72
  99. package/tests/unit/ForEachNode.test.tsx +0 -308
  100. package/tests/unit/IfElseNode.test.tsx +0 -235
  101. package/tests/unit/ParallelNode.test.tsx +0 -344
  102. package/tests/unit/SwitchNode.test.tsx +0 -327
  103. package/tests/unit/TransformNode.test.tsx +0 -386
  104. package/tests/unit/TryCatchNode.test.tsx +0 -243
  105. package/tests/unit/WhileNode.test.tsx +0 -230
  106. package/tests/unit/agentStore.test.ts +0 -218
  107. package/tests/unit/canvasStore.test.ts +0 -502
  108. package/tests/unit/codexProvider.test.ts +0 -399
  109. package/tests/unit/components.test.tsx +0 -151
  110. package/tests/unit/executionStore.test.ts +0 -567
  111. package/tests/unit/layoutStore.test.ts +0 -194
  112. package/tests/unit/navigationStore.test.ts +0 -152
  113. package/tests/unit/platform.test.ts +0 -118
  114. package/tests/unit/serviceIcons.test.ts +0 -197
  115. package/tests/unit/stepValidation.test.ts +0 -226
  116. package/tests/unit/themeStore.test.ts +0 -141
  117. package/tests/unit/workflowToGraph.test.ts +0 -311
  118. package/tsconfig.json +0 -29
  119. package/tsconfig.server.json +0 -28
  120. package/vite.config.ts +0 -31
  121. package/vitest.config.ts +0 -26
@@ -1,532 +0,0 @@
1
- import { useState, useEffect, useMemo } from 'react';
2
- import { Modal, ModalFooter } from '../common/Modal';
3
- import { Button } from '../common/Button';
4
- import { Tabs, TabsList, TabsTrigger, TabsContent } from '../common/Tabs';
5
- import { YamlEditor } from './YamlEditor';
6
- import { InputsEditor } from './InputsEditor';
7
- import {
8
- Settings,
9
- FileInput,
10
- FileOutput,
11
- AlertTriangle,
12
- Filter,
13
- Code,
14
- AlertCircle,
15
- } from 'lucide-react';
16
- import type { WorkflowStep } from '@shared/types';
17
- import { validateStep, getFieldError, type ValidationError } from '../../utils/stepValidation';
18
-
19
- interface StepEditorProps {
20
- open: boolean;
21
- onOpenChange: (open: boolean) => void;
22
- step: WorkflowStep | null;
23
- onSave: (step: WorkflowStep) => void;
24
- availableVariables: string[];
25
- }
26
-
27
- export function StepEditor({
28
- open,
29
- onOpenChange,
30
- step,
31
- onSave,
32
- availableVariables,
33
- }: StepEditorProps) {
34
- const [editedStep, setEditedStep] = useState<WorkflowStep | null>(null);
35
- const [activeTab, setActiveTab] = useState('properties');
36
- const [validationErrors, setValidationErrors] = useState<ValidationError[]>([]);
37
- const [showErrors, setShowErrors] = useState(false);
38
-
39
- useEffect(() => {
40
- if (step) {
41
- setEditedStep({ ...step });
42
- setActiveTab('properties');
43
- setValidationErrors([]);
44
- setShowErrors(false);
45
- }
46
- }, [step]);
47
-
48
- // Validate on every change
49
- const validation = useMemo(() => {
50
- if (!editedStep) return { valid: true, errors: [] };
51
- return validateStep(editedStep);
52
- }, [editedStep]);
53
-
54
- if (!editedStep) return null;
55
-
56
- const handleSave = () => {
57
- if (!editedStep) return;
58
-
59
- const result = validateStep(editedStep);
60
- setValidationErrors(result.errors);
61
- setShowErrors(true);
62
-
63
- if (result.valid) {
64
- onSave(editedStep);
65
- onOpenChange(false);
66
- } else {
67
- // Switch to tab with first error
68
- const firstError = result.errors[0];
69
- if (firstError) {
70
- if (firstError.field === 'id' || firstError.field === 'action' || firstError.field === 'workflow' || firstError.field === 'timeout') {
71
- setActiveTab('properties');
72
- } else if (firstError.field === 'outputVariable') {
73
- setActiveTab('output');
74
- } else if (firstError.field.startsWith('errorHandling')) {
75
- setActiveTab('errors');
76
- } else if (firstError.field.startsWith('conditions')) {
77
- setActiveTab('conditions');
78
- }
79
- }
80
- }
81
- };
82
-
83
- const updateStep = (updates: Partial<WorkflowStep>) => {
84
- setEditedStep((prev) => (prev ? { ...prev, ...updates } : null));
85
- };
86
-
87
- const getError = (field: string): string | undefined => {
88
- if (!showErrors) return undefined;
89
- return getFieldError(validationErrors, field);
90
- };
91
-
92
- return (
93
- <Modal
94
- open={open}
95
- onOpenChange={onOpenChange}
96
- title={`Edit Step: ${editedStep.name || editedStep.id}`}
97
- description={editedStep.action || editedStep.workflow || 'Configure step settings'}
98
- size="xl"
99
- >
100
- <Tabs value={activeTab} onValueChange={setActiveTab}>
101
- <TabsList>
102
- <TabsTrigger value="properties">
103
- <Settings className="w-4 h-4 mr-1.5" />
104
- Properties
105
- </TabsTrigger>
106
- <TabsTrigger value="inputs">
107
- <FileInput className="w-4 h-4 mr-1.5" />
108
- Inputs
109
- </TabsTrigger>
110
- <TabsTrigger value="output">
111
- <FileOutput className="w-4 h-4 mr-1.5" />
112
- Output
113
- </TabsTrigger>
114
- <TabsTrigger value="errors">
115
- <AlertTriangle className="w-4 h-4 mr-1.5" />
116
- Errors
117
- </TabsTrigger>
118
- <TabsTrigger value="conditions">
119
- <Filter className="w-4 h-4 mr-1.5" />
120
- Conditions
121
- </TabsTrigger>
122
- <TabsTrigger value="yaml">
123
- <Code className="w-4 h-4 mr-1.5" />
124
- YAML
125
- </TabsTrigger>
126
- </TabsList>
127
-
128
- <div className="p-4">
129
- <TabsContent value="properties">
130
- <PropertiesTab step={editedStep} onChange={updateStep} getError={getError} />
131
- </TabsContent>
132
-
133
- <TabsContent value="inputs">
134
- <InputsEditor
135
- inputs={editedStep.inputs}
136
- onChange={(inputs) => updateStep({ inputs })}
137
- availableVariables={availableVariables}
138
- />
139
- </TabsContent>
140
-
141
- <TabsContent value="output">
142
- <OutputTab step={editedStep} onChange={updateStep} />
143
- </TabsContent>
144
-
145
- <TabsContent value="errors">
146
- <ErrorHandlingTab step={editedStep} onChange={updateStep} />
147
- </TabsContent>
148
-
149
- <TabsContent value="conditions">
150
- <ConditionsTab
151
- step={editedStep}
152
- onChange={updateStep}
153
- availableVariables={availableVariables}
154
- />
155
- </TabsContent>
156
-
157
- <TabsContent value="yaml">
158
- <YamlEditor
159
- value={editedStep}
160
- onChange={(updated) => setEditedStep(updated)}
161
- />
162
- </TabsContent>
163
- </div>
164
- </Tabs>
165
-
166
- <ModalFooter>
167
- {showErrors && validationErrors.length > 0 && (
168
- <div className="flex-1 flex items-center gap-2 text-error text-sm">
169
- <AlertCircle className="w-4 h-4 flex-shrink-0" />
170
- <span>{validationErrors.length} validation error{validationErrors.length > 1 ? 's' : ''}</span>
171
- </div>
172
- )}
173
- <Button variant="secondary" onClick={() => onOpenChange(false)}>
174
- Cancel
175
- </Button>
176
- <Button onClick={handleSave}>Save Changes</Button>
177
- </ModalFooter>
178
- </Modal>
179
- );
180
- }
181
-
182
- // Properties Tab
183
- function PropertiesTab({
184
- step,
185
- onChange,
186
- getError,
187
- }: {
188
- step: WorkflowStep;
189
- onChange: (updates: Partial<WorkflowStep>) => void;
190
- getError: (field: string) => string | undefined;
191
- }) {
192
- const idError = getError('id');
193
- const actionError = getError('action');
194
- const workflowError = getError('workflow');
195
- const timeoutError = getError('timeout');
196
-
197
- return (
198
- <div className="space-y-4">
199
- <div>
200
- <label className="block text-sm font-medium text-gray-300 mb-1.5">
201
- Step ID <span className="text-error">*</span>
202
- </label>
203
- <input
204
- type="text"
205
- value={step.id}
206
- onChange={(e) => onChange({ id: e.target.value })}
207
- className={`w-full px-3 py-2 bg-node-bg border rounded-lg text-white text-sm focus:outline-none ${
208
- idError ? 'border-error focus:border-error' : 'border-node-border focus:border-primary'
209
- }`}
210
- placeholder="unique-step-id"
211
- />
212
- {idError ? (
213
- <p className="mt-1 text-xs text-error">{idError}</p>
214
- ) : (
215
- <p className="mt-1 text-xs text-gray-500">
216
- Unique identifier for this step
217
- </p>
218
- )}
219
- </div>
220
-
221
- <div>
222
- <label className="block text-sm font-medium text-gray-300 mb-1.5">
223
- Step Name
224
- </label>
225
- <input
226
- type="text"
227
- value={step.name || ''}
228
- onChange={(e) => onChange({ name: e.target.value || undefined })}
229
- className="w-full px-3 py-2 bg-node-bg border border-node-border rounded-lg text-white text-sm focus:outline-none focus:border-primary"
230
- placeholder="Human-readable name"
231
- />
232
- </div>
233
-
234
- <div>
235
- <label className="block text-sm font-medium text-gray-300 mb-1.5">
236
- Action {!step.workflow && <span className="text-error">*</span>}
237
- </label>
238
- <input
239
- type="text"
240
- value={step.action || ''}
241
- onChange={(e) => onChange({ action: e.target.value || undefined })}
242
- className={`w-full px-3 py-2 bg-node-bg border rounded-lg text-white text-sm font-mono focus:outline-none ${
243
- actionError ? 'border-error focus:border-error' : 'border-node-border focus:border-primary'
244
- }`}
245
- placeholder="service.method (e.g., slack.chat.postMessage)"
246
- />
247
- {actionError ? (
248
- <p className="mt-1 text-xs text-error">{actionError}</p>
249
- ) : (
250
- <p className="mt-1 text-xs text-gray-500">
251
- Format: service.method or service.namespace.method
252
- </p>
253
- )}
254
- </div>
255
-
256
- {step.workflow && (
257
- <div>
258
- <label className="block text-sm font-medium text-gray-300 mb-1.5">
259
- Sub-workflow Path
260
- </label>
261
- <input
262
- type="text"
263
- value={step.workflow}
264
- onChange={(e) => onChange({ workflow: e.target.value })}
265
- className={`w-full px-3 py-2 bg-node-bg border rounded-lg text-white text-sm font-mono focus:outline-none ${
266
- workflowError ? 'border-error focus:border-error' : 'border-node-border focus:border-primary'
267
- }`}
268
- placeholder="./path/to/workflow.md"
269
- />
270
- {workflowError && (
271
- <p className="mt-1 text-xs text-error">{workflowError}</p>
272
- )}
273
- </div>
274
- )}
275
-
276
- <div>
277
- <label className="block text-sm font-medium text-gray-300 mb-1.5">
278
- Timeout (seconds)
279
- </label>
280
- <input
281
- type="number"
282
- value={step.timeout || ''}
283
- onChange={(e) =>
284
- onChange({
285
- timeout: e.target.value ? parseInt(e.target.value, 10) : undefined,
286
- })
287
- }
288
- className={`w-full px-3 py-2 bg-node-bg border rounded-lg text-white text-sm focus:outline-none ${
289
- timeoutError ? 'border-error focus:border-error' : 'border-node-border focus:border-primary'
290
- }`}
291
- placeholder="30"
292
- min="1"
293
- />
294
- {timeoutError && (
295
- <p className="mt-1 text-xs text-error">{timeoutError}</p>
296
- )}
297
- </div>
298
- </div>
299
- );
300
- }
301
-
302
- // Output Tab
303
- function OutputTab({
304
- step,
305
- onChange,
306
- }: {
307
- step: WorkflowStep;
308
- onChange: (updates: Partial<WorkflowStep>) => void;
309
- }) {
310
- return (
311
- <div className="space-y-4">
312
- <div>
313
- <label className="block text-sm font-medium text-gray-300 mb-1.5">
314
- Output Variable
315
- </label>
316
- <input
317
- type="text"
318
- value={step.outputVariable || ''}
319
- onChange={(e) =>
320
- onChange({ outputVariable: e.target.value || undefined })
321
- }
322
- className="w-full px-3 py-2 bg-node-bg border border-node-border rounded-lg text-white text-sm font-mono focus:outline-none focus:border-primary"
323
- placeholder="result_variable"
324
- />
325
- <p className="mt-1 text-xs text-gray-500">
326
- Store the step output in this variable for use in subsequent steps
327
- </p>
328
- </div>
329
-
330
- <div className="p-4 bg-node-bg rounded-lg border border-node-border">
331
- <h4 className="text-sm font-medium text-gray-300 mb-2">Usage Example</h4>
332
- <code className="text-xs text-primary font-mono">
333
- {'{{ ' + (step.outputVariable || 'variable_name') + ' }}'}
334
- </code>
335
- <p className="mt-2 text-xs text-gray-500">
336
- Use this syntax in subsequent steps to reference the output
337
- </p>
338
- </div>
339
- </div>
340
- );
341
- }
342
-
343
- // Error Handling Tab
344
- function ErrorHandlingTab({
345
- step,
346
- onChange,
347
- }: {
348
- step: WorkflowStep;
349
- onChange: (updates: Partial<WorkflowStep>) => void;
350
- }) {
351
- const errorHandling = step.errorHandling || { action: 'stop' };
352
-
353
- const updateErrorHandling = (updates: Partial<typeof errorHandling>) => {
354
- onChange({
355
- errorHandling: { ...errorHandling, ...updates },
356
- });
357
- };
358
-
359
- return (
360
- <div className="space-y-4">
361
- <div>
362
- <label className="block text-sm font-medium text-gray-300 mb-1.5">
363
- Error Action
364
- </label>
365
- <select
366
- value={errorHandling.action}
367
- onChange={(e) =>
368
- updateErrorHandling({
369
- action: e.target.value as 'stop' | 'continue' | 'retry',
370
- })
371
- }
372
- className="w-full px-3 py-2 bg-node-bg border border-node-border rounded-lg text-white text-sm focus:outline-none focus:border-primary"
373
- >
374
- <option value="stop">Stop workflow on error</option>
375
- <option value="continue">Continue to next step</option>
376
- <option value="retry">Retry with backoff</option>
377
- </select>
378
- </div>
379
-
380
- {errorHandling.action === 'retry' && (
381
- <>
382
- <div>
383
- <label className="block text-sm font-medium text-gray-300 mb-1.5">
384
- Max Retries
385
- </label>
386
- <input
387
- type="number"
388
- value={errorHandling.maxRetries || 3}
389
- onChange={(e) =>
390
- updateErrorHandling({
391
- maxRetries: parseInt(e.target.value, 10),
392
- })
393
- }
394
- className="w-full px-3 py-2 bg-node-bg border border-node-border rounded-lg text-white text-sm focus:outline-none focus:border-primary"
395
- min="1"
396
- max="10"
397
- />
398
- </div>
399
-
400
- <div>
401
- <label className="block text-sm font-medium text-gray-300 mb-1.5">
402
- Retry Delay (ms)
403
- </label>
404
- <input
405
- type="number"
406
- value={errorHandling.retryDelay || 1000}
407
- onChange={(e) =>
408
- updateErrorHandling({
409
- retryDelay: parseInt(e.target.value, 10),
410
- })
411
- }
412
- className="w-full px-3 py-2 bg-node-bg border border-node-border rounded-lg text-white text-sm focus:outline-none focus:border-primary"
413
- min="100"
414
- step="100"
415
- />
416
- </div>
417
- </>
418
- )}
419
-
420
- <div>
421
- <label className="block text-sm font-medium text-gray-300 mb-1.5">
422
- Fallback Step (optional)
423
- </label>
424
- <input
425
- type="text"
426
- value={errorHandling.fallbackStep || ''}
427
- onChange={(e) =>
428
- updateErrorHandling({
429
- fallbackStep: e.target.value || undefined,
430
- })
431
- }
432
- className="w-full px-3 py-2 bg-node-bg border border-node-border rounded-lg text-white text-sm font-mono focus:outline-none focus:border-primary"
433
- placeholder="fallback-step-id"
434
- />
435
- <p className="mt-1 text-xs text-gray-500">
436
- Jump to this step if the error action fails
437
- </p>
438
- </div>
439
- </div>
440
- );
441
- }
442
-
443
- // Conditions Tab
444
- function ConditionsTab({
445
- step,
446
- onChange,
447
- availableVariables,
448
- }: {
449
- step: WorkflowStep;
450
- onChange: (updates: Partial<WorkflowStep>) => void;
451
- availableVariables: string[];
452
- }) {
453
- const conditions = step.conditions || [];
454
-
455
- const addCondition = () => {
456
- onChange({ conditions: [...conditions, ''] });
457
- };
458
-
459
- const updateCondition = (index: number, value: string) => {
460
- const updated = [...conditions];
461
- updated[index] = value;
462
- onChange({ conditions: updated });
463
- };
464
-
465
- const removeCondition = (index: number) => {
466
- const updated = conditions.filter((_, i) => i !== index);
467
- onChange({ conditions: updated.length > 0 ? updated : undefined });
468
- };
469
-
470
- return (
471
- <div className="space-y-4">
472
- <p className="text-sm text-gray-400">
473
- This step will only execute if all conditions evaluate to true.
474
- </p>
475
-
476
- {conditions.length === 0 ? (
477
- <div className="text-center py-8">
478
- <p className="text-sm text-gray-500 mb-3">No conditions defined</p>
479
- <Button variant="secondary" size="sm" onClick={addCondition}>
480
- Add Condition
481
- </Button>
482
- </div>
483
- ) : (
484
- <div className="space-y-3">
485
- {conditions.map((condition, index) => (
486
- <div key={index} className="flex gap-2">
487
- <input
488
- type="text"
489
- value={condition}
490
- onChange={(e) => updateCondition(index, e.target.value)}
491
- className="flex-1 px-3 py-2 bg-node-bg border border-node-border rounded-lg text-white text-sm font-mono focus:outline-none focus:border-primary"
492
- placeholder="{{ variable }} === 'value'"
493
- />
494
- <Button
495
- variant="ghost"
496
- size="sm"
497
- onClick={() => removeCondition(index)}
498
- >
499
- ×
500
- </Button>
501
- </div>
502
- ))}
503
- <Button variant="secondary" size="sm" onClick={addCondition}>
504
- Add Condition
505
- </Button>
506
- </div>
507
- )}
508
-
509
- {availableVariables.length > 0 && (
510
- <div className="mt-4 p-3 bg-node-bg rounded-lg border border-node-border">
511
- <h4 className="text-xs font-medium text-gray-400 uppercase tracking-wider mb-2">
512
- Available Variables
513
- </h4>
514
- <div className="flex flex-wrap gap-1.5">
515
- {availableVariables.map((variable) => (
516
- <code
517
- key={variable}
518
- className="px-2 py-0.5 bg-primary/10 text-primary text-xs rounded cursor-pointer hover:bg-primary/20"
519
- onClick={() => {
520
- // Copy to clipboard
521
- navigator.clipboard.writeText(`{{ ${variable} }}`);
522
- }}
523
- >
524
- {variable}
525
- </code>
526
- ))}
527
- </div>
528
- </div>
529
- )}
530
- </div>
531
- );
532
- }
@@ -1,160 +0,0 @@
1
- import { useState, useEffect } from 'react';
2
- import Editor from '@monaco-editor/react';
3
- import { stringify, parse } from 'yaml';
4
- import { AlertCircle, Check } from 'lucide-react';
5
- import type { WorkflowStep } from '@shared/types';
6
-
7
- interface YamlEditorProps {
8
- value: WorkflowStep;
9
- onChange: (step: WorkflowStep) => void;
10
- }
11
-
12
- export function YamlEditor({ value, onChange }: YamlEditorProps) {
13
- const [yamlContent, setYamlContent] = useState('');
14
- const [error, setError] = useState<string | null>(null);
15
- const [isValid, setIsValid] = useState(true);
16
-
17
- useEffect(() => {
18
- try {
19
- const yaml = stringify(value, {
20
- indent: 2,
21
- lineWidth: 0,
22
- });
23
- setYamlContent(yaml);
24
- setError(null);
25
- setIsValid(true);
26
- } catch (err) {
27
- setError(err instanceof Error ? err.message : 'Failed to serialize');
28
- setIsValid(false);
29
- }
30
- }, [value]);
31
-
32
- const handleEditorChange = (content: string | undefined) => {
33
- if (!content) return;
34
-
35
- setYamlContent(content);
36
-
37
- try {
38
- const parsed = parse(content) as WorkflowStep;
39
-
40
- // Validate required fields
41
- if (!parsed.id) {
42
- throw new Error('Step ID is required');
43
- }
44
- if (!parsed.action && !parsed.workflow) {
45
- throw new Error('Either action or workflow is required');
46
- }
47
-
48
- setError(null);
49
- setIsValid(true);
50
- onChange(parsed);
51
- } catch (err) {
52
- setError(err instanceof Error ? err.message : 'Invalid YAML');
53
- setIsValid(false);
54
- }
55
- };
56
-
57
- return (
58
- <div className="space-y-2">
59
- {/* Status bar */}
60
- <div className="flex items-center justify-between">
61
- <div className="flex items-center gap-2">
62
- {isValid ? (
63
- <span className="flex items-center gap-1 text-xs text-success">
64
- <Check className="w-3 h-3" />
65
- Valid YAML
66
- </span>
67
- ) : (
68
- <span className="flex items-center gap-1 text-xs text-error">
69
- <AlertCircle className="w-3 h-3" />
70
- {error}
71
- </span>
72
- )}
73
- </div>
74
- <span className="text-xs text-gray-500">
75
- {yamlContent.split('\n').length} lines
76
- </span>
77
- </div>
78
-
79
- {/* Editor */}
80
- <div className="border border-node-border rounded-lg overflow-hidden">
81
- <Editor
82
- height="400px"
83
- language="yaml"
84
- value={yamlContent}
85
- onChange={handleEditorChange}
86
- theme="vs-dark"
87
- options={{
88
- minimap: { enabled: false },
89
- fontSize: 13,
90
- fontFamily: 'JetBrains Mono, Consolas, monospace',
91
- lineNumbers: 'on',
92
- scrollBeyondLastLine: false,
93
- automaticLayout: true,
94
- tabSize: 2,
95
- wordWrap: 'on',
96
- padding: { top: 12, bottom: 12 },
97
- }}
98
- />
99
- </div>
100
-
101
- {/* Help text */}
102
- <div className="text-xs text-gray-500">
103
- <p>
104
- Edit the step configuration directly in YAML format. Changes are
105
- applied automatically when valid.
106
- </p>
107
- </div>
108
- </div>
109
- );
110
- }
111
-
112
- // Read-only YAML viewer
113
- interface YamlViewerProps {
114
- value: unknown;
115
- title?: string;
116
- }
117
-
118
- export function YamlViewer({ value, title }: YamlViewerProps) {
119
- const [yamlContent, setYamlContent] = useState('');
120
-
121
- useEffect(() => {
122
- try {
123
- const yaml = stringify(value, {
124
- indent: 2,
125
- lineWidth: 0,
126
- });
127
- setYamlContent(yaml);
128
- } catch {
129
- setYamlContent('# Failed to serialize value');
130
- }
131
- }, [value]);
132
-
133
- return (
134
- <div className="space-y-2">
135
- {title && (
136
- <h4 className="text-sm font-medium text-gray-300">{title}</h4>
137
- )}
138
- <div className="border border-node-border rounded-lg overflow-hidden">
139
- <Editor
140
- height="300px"
141
- language="yaml"
142
- value={yamlContent}
143
- theme="vs-dark"
144
- options={{
145
- readOnly: true,
146
- minimap: { enabled: false },
147
- fontSize: 13,
148
- fontFamily: 'JetBrains Mono, Consolas, monospace',
149
- lineNumbers: 'on',
150
- scrollBeyondLastLine: false,
151
- automaticLayout: true,
152
- tabSize: 2,
153
- wordWrap: 'on',
154
- padding: { top: 12, bottom: 12 },
155
- }}
156
- />
157
- </div>
158
- </div>
159
- );
160
- }