@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,149 +0,0 @@
1
- import { useState, useEffect } from 'react';
2
- import { Modal, ModalFooter } from './Modal';
3
- import { Button } from './Button';
4
- import { Keyboard } from 'lucide-react';
5
- import { getModKey } from '../../utils/platform';
6
-
7
- interface Shortcut {
8
- keys: string[];
9
- description: string;
10
- category: string;
11
- }
12
-
13
- const shortcuts: Shortcut[] = [
14
- // General
15
- { keys: ['⌘', 'S'], description: 'Save workflow', category: 'General' },
16
- { keys: ['⌘', 'Z'], description: 'Undo', category: 'General' },
17
- { keys: ['⌘', '⇧', 'Z'], description: 'Redo', category: 'General' },
18
- { keys: ['⌘', '?'], description: 'Show keyboard shortcuts', category: 'General' },
19
-
20
- // Canvas
21
- { keys: ['N'], description: 'Add new step', category: 'Canvas' },
22
- { keys: ['⌘', 'L'], description: 'Auto-layout canvas', category: 'Canvas' },
23
- { keys: ['⌘', '0'], description: 'Fit view', category: 'Canvas' },
24
- { keys: ['⌘', '+'], description: 'Zoom in', category: 'Canvas' },
25
- { keys: ['⌘', '-'], description: 'Zoom out', category: 'Canvas' },
26
- { keys: ['⌫'], description: 'Delete selected', category: 'Canvas' },
27
- { keys: ['⌘', 'D'], description: 'Duplicate selected', category: 'Canvas' },
28
-
29
- // Editing
30
- { keys: ['Double-click'], description: 'Edit step', category: 'Editing' },
31
- { keys: ['E'], description: 'Edit selected step', category: 'Editing' },
32
- { keys: ['Y'], description: 'View YAML', category: 'Editing' },
33
- { keys: ['Escape'], description: 'Close modal / deselect', category: 'Editing' },
34
-
35
- // Navigation
36
- { keys: ['⌘', '←'], description: 'Back to parent workflow', category: 'Navigation' },
37
- { keys: ['⌘', '↑'], description: 'Go to root workflow', category: 'Navigation' },
38
-
39
- // Execution
40
- { keys: ['⌘', '↵'], description: 'Execute workflow', category: 'Execution' },
41
-
42
- // Debugging
43
- { keys: ['F9'], description: 'Toggle debug mode', category: 'Debugging' },
44
- { keys: ['F5'], description: 'Continue execution', category: 'Debugging' },
45
- { keys: ['F10'], description: 'Step over', category: 'Debugging' },
46
- { keys: ['F11'], description: 'Step into', category: 'Debugging' },
47
- { keys: ['⇧', 'F11'], description: 'Step out', category: 'Debugging' },
48
- ];
49
-
50
- interface KeyboardShortcutsProps {
51
- open: boolean;
52
- onOpenChange: (open: boolean) => void;
53
- }
54
-
55
- export function KeyboardShortcuts({ open, onOpenChange }: KeyboardShortcutsProps) {
56
- // Group shortcuts by category
57
- const categories = [...new Set(shortcuts.map((s) => s.category))];
58
-
59
- // Get platform-specific modifier key
60
- const modKey = getModKey();
61
-
62
- return (
63
- <Modal
64
- open={open}
65
- onOpenChange={onOpenChange}
66
- title="Keyboard Shortcuts"
67
- description="Quick reference for all keyboard shortcuts"
68
- size="md"
69
- >
70
- <div className="p-4 space-y-6 max-h-[60vh] overflow-y-auto">
71
- {categories.map((category) => (
72
- <div key={category}>
73
- <h3 className="text-sm font-medium text-gray-400 uppercase tracking-wider mb-3">
74
- {category}
75
- </h3>
76
- <div className="space-y-2">
77
- {shortcuts
78
- .filter((s) => s.category === category)
79
- .map((shortcut, index) => (
80
- <div
81
- key={index}
82
- className="flex items-center justify-between py-1.5 border-b border-node-border last:border-0"
83
- >
84
- <span className="text-sm text-gray-300">{shortcut.description}</span>
85
- <div className="flex items-center gap-1">
86
- {shortcut.keys.map((key, i) => (
87
- <kbd
88
- key={i}
89
- className="px-2 py-1 bg-node-bg border border-node-border rounded text-xs font-mono text-gray-300"
90
- >
91
- {key === '⌘' ? modKey : key}
92
- </kbd>
93
- ))}
94
- </div>
95
- </div>
96
- ))}
97
- </div>
98
- </div>
99
- ))}
100
- </div>
101
-
102
- <ModalFooter>
103
- <Button variant="secondary" onClick={() => onOpenChange(false)}>
104
- Close
105
- </Button>
106
- </ModalFooter>
107
- </Modal>
108
- );
109
- }
110
-
111
- // Hook to manage keyboard shortcuts modal
112
- export function useKeyboardShortcuts() {
113
- const [isOpen, setIsOpen] = useState(false);
114
-
115
- useEffect(() => {
116
- const handleKeyDown = (e: KeyboardEvent) => {
117
- // ⌘+? or Ctrl+? to open shortcuts
118
- if ((e.metaKey || e.ctrlKey) && e.key === '/') {
119
- e.preventDefault();
120
- setIsOpen(true);
121
- }
122
- };
123
-
124
- window.addEventListener('keydown', handleKeyDown);
125
- return () => window.removeEventListener('keydown', handleKeyDown);
126
- }, []);
127
-
128
- return {
129
- isOpen,
130
- setIsOpen,
131
- openShortcuts: () => setIsOpen(true),
132
- };
133
- }
134
-
135
- // Small button to show keyboard shortcuts
136
- export function KeyboardShortcutsButton({ onClick }: { onClick: () => void }) {
137
- const modKey = getModKey();
138
-
139
- return (
140
- <button
141
- onClick={onClick}
142
- className="flex items-center gap-1.5 px-2 py-1 text-xs text-gray-500 hover:text-gray-300 transition-colors"
143
- title={`Keyboard shortcuts (${modKey}/)`}
144
- >
145
- <Keyboard className="w-3.5 h-3.5" />
146
- <span className="hidden sm:inline">Shortcuts</span>
147
- </button>
148
- );
149
- }
@@ -1,93 +0,0 @@
1
- import * as Dialog from '@radix-ui/react-dialog';
2
- import { X } from 'lucide-react';
3
- import { cn } from '../../utils/cn';
4
-
5
- interface ModalProps {
6
- open: boolean;
7
- onOpenChange: (open: boolean) => void;
8
- title?: string;
9
- description?: string;
10
- children: React.ReactNode;
11
- className?: string;
12
- size?: 'sm' | 'md' | 'lg' | 'xl' | 'full';
13
- }
14
-
15
- const sizeClasses = {
16
- sm: 'max-w-md',
17
- md: 'max-w-lg',
18
- lg: 'max-w-2xl',
19
- xl: 'max-w-4xl',
20
- full: 'max-w-[90vw]',
21
- };
22
-
23
- export function Modal({
24
- open,
25
- onOpenChange,
26
- title,
27
- description,
28
- children,
29
- className,
30
- size = 'md',
31
- }: ModalProps) {
32
- return (
33
- <Dialog.Root open={open} onOpenChange={onOpenChange}>
34
- <Dialog.Portal>
35
- <Dialog.Overlay className="fixed inset-0 z-50 bg-black/50 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0" />
36
- <Dialog.Content
37
- className={cn(
38
- 'fixed left-[50%] top-[50%] z-50 translate-x-[-50%] translate-y-[-50%]',
39
- 'w-full rounded-lg border border-node-border bg-panel-bg shadow-lg',
40
- 'data-[state=open]:animate-in data-[state=closed]:animate-out',
41
- 'data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0',
42
- 'data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95',
43
- 'data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%]',
44
- 'data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%]',
45
- 'duration-200',
46
- sizeClasses[size],
47
- className
48
- )}
49
- >
50
- {(title || description) && (
51
- <div className="flex items-start justify-between p-4 border-b border-node-border">
52
- <div>
53
- {title && (
54
- <Dialog.Title className="text-lg font-semibold text-white">
55
- {title}
56
- </Dialog.Title>
57
- )}
58
- {description && (
59
- <Dialog.Description className="mt-1 text-sm text-gray-400">
60
- {description}
61
- </Dialog.Description>
62
- )}
63
- </div>
64
- <Dialog.Close className="rounded-full p-1 hover:bg-white/10 transition-colors">
65
- <X className="w-5 h-5 text-gray-400" />
66
- </Dialog.Close>
67
- </div>
68
- )}
69
- <div className="max-h-[calc(85vh-8rem)] overflow-y-auto">{children}</div>
70
- </Dialog.Content>
71
- </Dialog.Portal>
72
- </Dialog.Root>
73
- );
74
- }
75
-
76
- export function ModalFooter({
77
- children,
78
- className,
79
- }: {
80
- children: React.ReactNode;
81
- className?: string;
82
- }) {
83
- return (
84
- <div
85
- className={cn(
86
- 'flex items-center justify-end gap-3 p-4 border-t border-node-border',
87
- className
88
- )}
89
- >
90
- {children}
91
- </div>
92
- );
93
- }
@@ -1,57 +0,0 @@
1
- import * as TabsPrimitive from '@radix-ui/react-tabs';
2
- import { forwardRef } from 'react';
3
- import { cn } from '../../utils/cn';
4
-
5
- const Tabs = TabsPrimitive.Root;
6
-
7
- const TabsList = forwardRef<
8
- React.ElementRef<typeof TabsPrimitive.List>,
9
- React.ComponentPropsWithoutRef<typeof TabsPrimitive.List>
10
- >(({ className, ...props }, ref) => (
11
- <TabsPrimitive.List
12
- ref={ref}
13
- className={cn(
14
- 'inline-flex items-center gap-1 border-b border-node-border w-full px-2',
15
- className
16
- )}
17
- {...props}
18
- />
19
- ));
20
- TabsList.displayName = TabsPrimitive.List.displayName;
21
-
22
- const TabsTrigger = forwardRef<
23
- React.ElementRef<typeof TabsPrimitive.Trigger>,
24
- React.ComponentPropsWithoutRef<typeof TabsPrimitive.Trigger>
25
- >(({ className, ...props }, ref) => (
26
- <TabsPrimitive.Trigger
27
- ref={ref}
28
- className={cn(
29
- 'inline-flex items-center justify-center whitespace-nowrap px-3 py-2 text-sm font-medium',
30
- 'text-gray-400 transition-all',
31
- 'hover:text-gray-200',
32
- 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50',
33
- 'disabled:pointer-events-none disabled:opacity-50',
34
- 'data-[state=active]:text-primary data-[state=active]:border-b-2 data-[state=active]:border-primary data-[state=active]:-mb-px',
35
- className
36
- )}
37
- {...props}
38
- />
39
- ));
40
- TabsTrigger.displayName = TabsPrimitive.Trigger.displayName;
41
-
42
- const TabsContent = forwardRef<
43
- React.ElementRef<typeof TabsPrimitive.Content>,
44
- React.ComponentPropsWithoutRef<typeof TabsPrimitive.Content>
45
- >(({ className, ...props }, ref) => (
46
- <TabsPrimitive.Content
47
- ref={ref}
48
- className={cn(
49
- 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50',
50
- className
51
- )}
52
- {...props}
53
- />
54
- ));
55
- TabsContent.displayName = TabsPrimitive.Content.displayName;
56
-
57
- export { Tabs, TabsList, TabsTrigger, TabsContent };
@@ -1,63 +0,0 @@
1
- import { Sun, Moon, Monitor } from 'lucide-react';
2
- import { useThemeStore, type Theme } from '../../stores/themeStore';
3
-
4
- interface ThemeToggleProps {
5
- showLabel?: boolean;
6
- }
7
-
8
- export function ThemeToggle({ showLabel = false }: ThemeToggleProps) {
9
- const { theme, toggleTheme } = useThemeStore();
10
-
11
- return (
12
- <button
13
- onClick={toggleTheme}
14
- className="flex items-center gap-2 px-2 py-1.5 rounded-lg hover:bg-white/10 dark:hover:bg-white/10 light:hover:bg-black/5 transition-colors"
15
- title={`Switch to ${theme === 'dark' ? 'light' : 'dark'} mode`}
16
- >
17
- {theme === 'dark' ? (
18
- <Moon className="w-4 h-4 text-gray-400" />
19
- ) : (
20
- <Sun className="w-4 h-4 text-yellow-500" />
21
- )}
22
- {showLabel && (
23
- <span className="text-xs text-gray-400">
24
- {theme === 'dark' ? 'Dark' : 'Light'}
25
- </span>
26
- )}
27
- </button>
28
- );
29
- }
30
-
31
- interface ThemePickerProps {
32
- className?: string;
33
- }
34
-
35
- export function ThemePicker({ className }: ThemePickerProps) {
36
- const { theme, setTheme } = useThemeStore();
37
-
38
- const themes: { value: Theme; icon: typeof Sun; label: string }[] = [
39
- { value: 'light', icon: Sun, label: 'Light' },
40
- { value: 'dark', icon: Moon, label: 'Dark' },
41
- { value: 'system', icon: Monitor, label: 'System' },
42
- ];
43
-
44
- return (
45
- <div className={`flex items-center gap-1 ${className}`}>
46
- {themes.map(({ value, icon: Icon, label }) => (
47
- <button
48
- key={value}
49
- onClick={() => setTheme(value)}
50
- className={`flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs transition-colors ${
51
- theme === value
52
- ? 'bg-primary/20 text-primary'
53
- : 'text-gray-400 hover:text-white hover:bg-white/10'
54
- }`}
55
- title={`${label} mode`}
56
- >
57
- <Icon className="w-4 h-4" />
58
- <span className="hidden sm:inline">{label}</span>
59
- </button>
60
- ))}
61
- </div>
62
- );
63
- }
@@ -1,32 +0,0 @@
1
- // Canvas components
2
- export { Canvas } from './Canvas/Canvas';
3
- export { StepNode } from './Canvas/StepNode';
4
- export { SubWorkflowNode } from './Canvas/SubWorkflowNode';
5
- export { TriggerNode } from './Canvas/TriggerNode';
6
- export { OutputNode } from './Canvas/OutputNode';
7
- export { Toolbar } from './Canvas/Toolbar';
8
- export { ExecutionOverlay } from './Canvas/ExecutionOverlay';
9
- export { NodeContextMenu, CanvasContextMenu } from './Canvas/NodeContextMenu';
10
-
11
- // Editor components
12
- export { StepEditor } from './Editor/StepEditor';
13
- export { YamlEditor, YamlViewer } from './Editor/YamlEditor';
14
- export { InputsEditor } from './Editor/InputsEditor';
15
- export { NewStepWizard } from './Editor/NewStepWizard';
16
-
17
- // Common components
18
- export { Button } from './common/Button';
19
- export { Modal, ModalFooter } from './common/Modal';
20
- export { Tabs, TabsList, TabsTrigger, TabsContent } from './common/Tabs';
21
- export { ThemeToggle, ThemePicker } from './common/ThemeToggle';
22
- export * from './common/ContextMenu';
23
-
24
- // Prompt components
25
- export { PromptInput } from './Prompt/PromptInput';
26
- export { ChangePreview } from './Prompt/ChangePreview';
27
-
28
- // Panel components
29
- export { PropertiesPanel } from './Panels/PropertiesPanel';
30
-
31
- // Sidebar components
32
- export { Sidebar } from './Sidebar/Sidebar';
@@ -1,4 +0,0 @@
1
- export { useWebSocket } from './useWebSocket';
2
- export { useWorkflow } from './useWorkflow';
3
- export { useCanvas } from './useCanvas';
4
- export { useAIPrompt } from './useAIPrompt';
@@ -1,108 +0,0 @@
1
- import { useCallback } from 'react';
2
- import { usePromptStore } from '../stores/promptStore';
3
- import { useWorkflowStore } from '../stores/workflowStore';
4
-
5
- export function useAIPrompt() {
6
- const {
7
- isProcessing,
8
- history,
9
- lastError,
10
- pendingChanges,
11
- sendPrompt,
12
- acceptChanges,
13
- rejectChanges,
14
- clearHistory,
15
- } = usePromptStore();
16
-
17
- const currentWorkflow = useWorkflowStore((s) => s.currentWorkflow);
18
-
19
- // Send a prompt with the current workflow context
20
- const submitPrompt = useCallback(
21
- async (prompt: string) => {
22
- if (!prompt.trim()) return;
23
- await sendPrompt(prompt);
24
- },
25
- [sendPrompt]
26
- );
27
-
28
- // Quick action helpers
29
- const addStep = useCallback(
30
- async (service: string, description?: string) => {
31
- const prompt = description
32
- ? `Add a ${service} step: ${description}`
33
- : `Add a ${service} step at the end of the workflow`;
34
- await submitPrompt(prompt);
35
- },
36
- [submitPrompt]
37
- );
38
-
39
- const modifyStep = useCallback(
40
- async (stepId: string, modification: string) => {
41
- const prompt = `Modify step "${stepId}": ${modification}`;
42
- await submitPrompt(prompt);
43
- },
44
- [submitPrompt]
45
- );
46
-
47
- const addErrorHandling = useCallback(
48
- async (stepId?: string, retries = 3) => {
49
- const prompt = stepId
50
- ? `Add error handling with ${retries} retries to step "${stepId}"`
51
- : `Add error handling with ${retries} retries to all steps`;
52
- await submitPrompt(prompt);
53
- },
54
- [submitPrompt]
55
- );
56
-
57
- const addCondition = useCallback(
58
- async (stepId: string, condition: string) => {
59
- const prompt = `Add a condition to step "${stepId}": only run if ${condition}`;
60
- await submitPrompt(prompt);
61
- },
62
- [submitPrompt]
63
- );
64
-
65
- const convertToSubworkflow = useCallback(
66
- async (stepIds: string[], name: string) => {
67
- const prompt = `Convert steps ${stepIds.join(', ')} into a sub-workflow called "${name}"`;
68
- await submitPrompt(prompt);
69
- },
70
- [submitPrompt]
71
- );
72
-
73
- const explainWorkflow = useCallback(async () => {
74
- const prompt =
75
- 'Explain what this workflow does, step by step, in simple terms';
76
- await submitPrompt(prompt);
77
- }, [submitPrompt]);
78
-
79
- const suggestImprovements = useCallback(async () => {
80
- const prompt =
81
- 'Analyze this workflow and suggest improvements for error handling, efficiency, or reliability';
82
- await submitPrompt(prompt);
83
- }, [submitPrompt]);
84
-
85
- return {
86
- // State
87
- isProcessing,
88
- history,
89
- lastError,
90
- pendingChanges,
91
- currentWorkflow,
92
-
93
- // Core actions
94
- submitPrompt,
95
- acceptChanges,
96
- rejectChanges,
97
- clearHistory,
98
-
99
- // Quick actions
100
- addStep,
101
- modifyStep,
102
- addErrorHandling,
103
- addCondition,
104
- convertToSubworkflow,
105
- explainWorkflow,
106
- suggestImprovements,
107
- };
108
- }