@marktoflow/gui 2.0.0-alpha.1
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/.turbo/turbo-build.log +26 -0
- package/.turbo/turbo-test.log +22 -0
- package/README.md +179 -0
- package/dist/client/assets/index-DwTI8opO.js +608 -0
- package/dist/client/assets/index-DwTI8opO.js.map +1 -0
- package/dist/client/assets/index-RoEdL6gO.css +1 -0
- package/dist/client/index.html +20 -0
- package/dist/client/vite.svg +9 -0
- package/dist/server/index.d.ts +3 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +56 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/routes/ai.js +50 -0
- package/dist/server/routes/ai.js.map +1 -0
- package/dist/server/routes/execute.js +62 -0
- package/dist/server/routes/execute.js.map +1 -0
- package/dist/server/routes/workflows.js +99 -0
- package/dist/server/routes/workflows.js.map +1 -0
- package/dist/server/server/index.js +95 -0
- package/dist/server/server/index.js.map +1 -0
- package/dist/server/server/routes/ai.js +87 -0
- package/dist/server/server/routes/ai.js.map +1 -0
- package/dist/server/server/routes/execute.js +63 -0
- package/dist/server/server/routes/execute.js.map +1 -0
- package/dist/server/server/routes/tools.js +518 -0
- package/dist/server/server/routes/tools.js.map +1 -0
- package/dist/server/server/routes/workflows.js +99 -0
- package/dist/server/server/routes/workflows.js.map +1 -0
- package/dist/server/server/services/AIService.js +69 -0
- package/dist/server/server/services/AIService.js.map +1 -0
- package/dist/server/server/services/FileWatcher.js +60 -0
- package/dist/server/server/services/FileWatcher.js.map +1 -0
- package/dist/server/server/services/WorkflowService.js +363 -0
- package/dist/server/server/services/WorkflowService.js.map +1 -0
- package/dist/server/server/services/agents/claude-code-provider.js +250 -0
- package/dist/server/server/services/agents/claude-code-provider.js.map +1 -0
- package/dist/server/server/services/agents/claude-provider.js +204 -0
- package/dist/server/server/services/agents/claude-provider.js.map +1 -0
- package/dist/server/server/services/agents/copilot-provider.js +227 -0
- package/dist/server/server/services/agents/copilot-provider.js.map +1 -0
- package/dist/server/server/services/agents/demo-provider.js +167 -0
- package/dist/server/server/services/agents/demo-provider.js.map +1 -0
- package/dist/server/server/services/agents/index.js +31 -0
- package/dist/server/server/services/agents/index.js.map +1 -0
- package/dist/server/server/services/agents/ollama-provider.js +220 -0
- package/dist/server/server/services/agents/ollama-provider.js.map +1 -0
- package/dist/server/server/services/agents/prompts.js +436 -0
- package/dist/server/server/services/agents/prompts.js.map +1 -0
- package/dist/server/server/services/agents/registry.js +242 -0
- package/dist/server/server/services/agents/registry.js.map +1 -0
- package/dist/server/server/services/agents/types.js +6 -0
- package/dist/server/server/services/agents/types.js.map +1 -0
- package/dist/server/server/websocket/index.js +85 -0
- package/dist/server/server/websocket/index.js.map +1 -0
- package/dist/server/services/AIService.d.ts +30 -0
- package/dist/server/services/AIService.d.ts.map +1 -0
- package/dist/server/services/AIService.js +216 -0
- package/dist/server/services/AIService.js.map +1 -0
- package/dist/server/services/FileWatcher.d.ts +10 -0
- package/dist/server/services/FileWatcher.d.ts.map +1 -0
- package/dist/server/services/FileWatcher.js +62 -0
- package/dist/server/services/FileWatcher.js.map +1 -0
- package/dist/server/services/WorkflowService.d.ts +54 -0
- package/dist/server/services/WorkflowService.d.ts.map +1 -0
- package/dist/server/services/WorkflowService.js +323 -0
- package/dist/server/services/WorkflowService.js.map +1 -0
- package/dist/server/shared/constants.js +175 -0
- package/dist/server/shared/constants.js.map +1 -0
- package/dist/server/shared/types.js +3 -0
- package/dist/server/shared/types.js.map +1 -0
- package/dist/server/websocket/index.d.ts +10 -0
- package/dist/server/websocket/index.d.ts.map +1 -0
- package/dist/server/websocket/index.js +85 -0
- package/dist/server/websocket/index.js.map +1 -0
- package/index.html +19 -0
- package/package.json +96 -0
- package/playwright.config.ts +27 -0
- package/postcss.config.js +6 -0
- package/public/vite.svg +9 -0
- package/src/client/App.tsx +520 -0
- package/src/client/components/Canvas/Canvas.tsx +405 -0
- package/src/client/components/Canvas/ExecutionOverlay.tsx +847 -0
- package/src/client/components/Canvas/NodeContextMenu.tsx +188 -0
- package/src/client/components/Canvas/OutputNode.tsx +111 -0
- package/src/client/components/Canvas/StepNode.tsx +106 -0
- package/src/client/components/Canvas/SubWorkflowNode.tsx +141 -0
- package/src/client/components/Canvas/Toolbar.tsx +189 -0
- package/src/client/components/Canvas/TriggerNode.tsx +128 -0
- package/src/client/components/Editor/InputsEditor.tsx +458 -0
- package/src/client/components/Editor/NewStepWizard.tsx +344 -0
- package/src/client/components/Editor/StepEditor.tsx +532 -0
- package/src/client/components/Editor/YamlEditor.tsx +160 -0
- package/src/client/components/Panels/PropertiesPanel.tsx +589 -0
- package/src/client/components/Prompt/ChangePreview.tsx +281 -0
- package/src/client/components/Prompt/PromptHistoryPanel.tsx +209 -0
- package/src/client/components/Prompt/PromptInput.tsx +108 -0
- package/src/client/components/Sidebar/Sidebar.tsx +343 -0
- package/src/client/components/common/Breadcrumb.tsx +40 -0
- package/src/client/components/common/Button.tsx +68 -0
- package/src/client/components/common/ContextMenu.tsx +202 -0
- package/src/client/components/common/KeyboardShortcuts.tsx +143 -0
- package/src/client/components/common/Modal.tsx +93 -0
- package/src/client/components/common/Tabs.tsx +57 -0
- package/src/client/components/common/ThemeToggle.tsx +63 -0
- package/src/client/components/index.ts +32 -0
- package/src/client/hooks/index.ts +4 -0
- package/src/client/hooks/useAIPrompt.ts +108 -0
- package/src/client/hooks/useCanvas.ts +247 -0
- package/src/client/hooks/useWebSocket.ts +164 -0
- package/src/client/hooks/useWorkflow.ts +138 -0
- package/src/client/main.tsx +10 -0
- package/src/client/stores/canvasStore.ts +348 -0
- package/src/client/stores/editorStore.ts +133 -0
- package/src/client/stores/executionStore.ts +440 -0
- package/src/client/stores/index.ts +4 -0
- package/src/client/stores/layoutStore.ts +103 -0
- package/src/client/stores/navigationStore.ts +49 -0
- package/src/client/stores/promptStore.ts +113 -0
- package/src/client/stores/themeStore.ts +75 -0
- package/src/client/stores/workflowStore.ts +177 -0
- package/src/client/styles/globals.css +346 -0
- package/src/client/utils/cn.ts +9 -0
- package/src/client/utils/index.ts +4 -0
- package/src/client/utils/serviceIcons.tsx +64 -0
- package/src/client/utils/stepValidation.ts +155 -0
- package/src/client/utils/workflowToGraph.ts +299 -0
- package/src/server/index.ts +114 -0
- package/src/server/routes/ai.ts +91 -0
- package/src/server/routes/execute.ts +71 -0
- package/src/server/routes/tools.ts +564 -0
- package/src/server/routes/workflows.ts +106 -0
- package/src/server/services/AIService.ts +105 -0
- package/src/server/services/FileWatcher.ts +69 -0
- package/src/server/services/WorkflowService.ts +441 -0
- package/src/server/services/agents/claude-code-provider.ts +320 -0
- package/src/server/services/agents/claude-provider.ts +248 -0
- package/src/server/services/agents/copilot-provider.ts +311 -0
- package/src/server/services/agents/demo-provider.ts +184 -0
- package/src/server/services/agents/index.ts +31 -0
- package/src/server/services/agents/ollama-provider.ts +267 -0
- package/src/server/services/agents/prompts.ts +482 -0
- package/src/server/services/agents/registry.ts +289 -0
- package/src/server/services/agents/types.ts +146 -0
- package/src/server/websocket/index.ts +104 -0
- package/src/shared/constants.ts +180 -0
- package/src/shared/types.ts +179 -0
- package/tailwind.config.ts +73 -0
- package/tests/e2e/app.spec.ts +90 -0
- package/tests/e2e/canvas.spec.ts +128 -0
- package/tests/e2e/workflow.spec.ts +185 -0
- package/tests/integration/api.test.ts +250 -0
- package/tests/integration/testApp.ts +31 -0
- package/tests/setup.ts +37 -0
- package/tests/unit/canvasStore.test.ts +502 -0
- package/tests/unit/components.test.tsx +151 -0
- package/tests/unit/executionStore.test.ts +527 -0
- package/tests/unit/layoutStore.test.ts +194 -0
- package/tests/unit/navigationStore.test.ts +152 -0
- package/tests/unit/stepValidation.test.ts +226 -0
- package/tests/unit/themeStore.test.ts +141 -0
- package/tests/unit/workflowToGraph.test.ts +289 -0
- package/tsconfig.json +29 -0
- package/tsconfig.server.json +28 -0
- package/vite.config.ts +31 -0
- package/vitest.config.ts +26 -0
|
@@ -0,0 +1,532 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,160 @@
|
|
|
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
|
+
}
|