machinaos 0.0.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/.env.template +71 -0
- package/LICENSE +21 -0
- package/README.md +87 -0
- package/bin/cli.js +159 -0
- package/client/.dockerignore +45 -0
- package/client/Dockerfile +68 -0
- package/client/eslint.config.js +29 -0
- package/client/index.html +13 -0
- package/client/nginx.conf +66 -0
- package/client/package.json +48 -0
- package/client/src/App.tsx +27 -0
- package/client/src/Dashboard.tsx +1173 -0
- package/client/src/ParameterPanel.tsx +301 -0
- package/client/src/components/AIAgentNode.tsx +321 -0
- package/client/src/components/APIKeyValidator.tsx +118 -0
- package/client/src/components/ClaudeChatModelNode.tsx +18 -0
- package/client/src/components/ConditionalEdge.tsx +189 -0
- package/client/src/components/CredentialsModal.tsx +306 -0
- package/client/src/components/EdgeConditionEditor.tsx +443 -0
- package/client/src/components/GeminiChatModelNode.tsx +18 -0
- package/client/src/components/GenericNode.tsx +357 -0
- package/client/src/components/LocationParameterPanel.tsx +154 -0
- package/client/src/components/ModelNode.tsx +286 -0
- package/client/src/components/OpenAIChatModelNode.tsx +18 -0
- package/client/src/components/OutputPanel.tsx +471 -0
- package/client/src/components/ParameterRenderer.tsx +1874 -0
- package/client/src/components/SkillEditorModal.tsx +417 -0
- package/client/src/components/SquareNode.tsx +797 -0
- package/client/src/components/StartNode.tsx +250 -0
- package/client/src/components/ToolkitNode.tsx +365 -0
- package/client/src/components/TriggerNode.tsx +463 -0
- package/client/src/components/auth/LoginPage.tsx +247 -0
- package/client/src/components/auth/ProtectedRoute.tsx +59 -0
- package/client/src/components/base/BaseChatModelNode.tsx +271 -0
- package/client/src/components/icons/AIProviderIcons.tsx +50 -0
- package/client/src/components/maps/GoogleMapsPicker.tsx +137 -0
- package/client/src/components/maps/MapsPreviewPanel.tsx +110 -0
- package/client/src/components/maps/index.ts +26 -0
- package/client/src/components/parameterPanel/InputSection.tsx +1094 -0
- package/client/src/components/parameterPanel/LocationPanelLayout.tsx +65 -0
- package/client/src/components/parameterPanel/MapsSection.tsx +92 -0
- package/client/src/components/parameterPanel/MiddleSection.tsx +571 -0
- package/client/src/components/parameterPanel/OutputSection.tsx +81 -0
- package/client/src/components/parameterPanel/ParameterPanelLayout.tsx +82 -0
- package/client/src/components/parameterPanel/ToolSchemaEditor.tsx +436 -0
- package/client/src/components/parameterPanel/index.ts +42 -0
- package/client/src/components/shared/DataPanel.tsx +142 -0
- package/client/src/components/shared/JSONTreeRenderer.tsx +106 -0
- package/client/src/components/ui/AIResultModal.tsx +204 -0
- package/client/src/components/ui/AndroidSettingsPanel.tsx +401 -0
- package/client/src/components/ui/CodeEditor.tsx +81 -0
- package/client/src/components/ui/CollapsibleSection.tsx +88 -0
- package/client/src/components/ui/ComponentItem.tsx +154 -0
- package/client/src/components/ui/ComponentPalette.tsx +321 -0
- package/client/src/components/ui/ConsolePanel.tsx +1074 -0
- package/client/src/components/ui/ErrorBoundary.tsx +196 -0
- package/client/src/components/ui/InputNodesPanel.tsx +204 -0
- package/client/src/components/ui/MapSelector.tsx +314 -0
- package/client/src/components/ui/Modal.tsx +149 -0
- package/client/src/components/ui/NodeContextMenu.tsx +192 -0
- package/client/src/components/ui/NodeOutputPanel.tsx +1150 -0
- package/client/src/components/ui/OutputDisplayPanel.tsx +381 -0
- package/client/src/components/ui/SettingsPanel.tsx +243 -0
- package/client/src/components/ui/TopToolbar.tsx +736 -0
- package/client/src/components/ui/WhatsAppSettingsPanel.tsx +345 -0
- package/client/src/components/ui/WorkflowSidebar.tsx +294 -0
- package/client/src/config/antdTheme.ts +186 -0
- package/client/src/config/api.ts +54 -0
- package/client/src/contexts/AuthContext.tsx +221 -0
- package/client/src/contexts/ThemeContext.tsx +42 -0
- package/client/src/contexts/WebSocketContext.tsx +1971 -0
- package/client/src/factories/baseChatModelFactory.ts +256 -0
- package/client/src/hooks/useAndroidOperations.ts +164 -0
- package/client/src/hooks/useApiKeyValidation.ts +107 -0
- package/client/src/hooks/useApiKeys.ts +238 -0
- package/client/src/hooks/useAppTheme.ts +17 -0
- package/client/src/hooks/useComponentPalette.ts +51 -0
- package/client/src/hooks/useCopyPaste.ts +155 -0
- package/client/src/hooks/useDragAndDrop.ts +124 -0
- package/client/src/hooks/useDragVariable.ts +88 -0
- package/client/src/hooks/useExecution.ts +313 -0
- package/client/src/hooks/useParameterPanel.ts +176 -0
- package/client/src/hooks/useReactFlowNodes.ts +189 -0
- package/client/src/hooks/useToolSchema.ts +209 -0
- package/client/src/hooks/useWhatsApp.ts +196 -0
- package/client/src/hooks/useWorkflowManagement.ts +46 -0
- package/client/src/index.css +315 -0
- package/client/src/main.tsx +19 -0
- package/client/src/nodeDefinitions/aiAgentNodes.ts +336 -0
- package/client/src/nodeDefinitions/aiModelNodes.ts +340 -0
- package/client/src/nodeDefinitions/androidDeviceNodes.ts +140 -0
- package/client/src/nodeDefinitions/androidServiceNodes.ts +383 -0
- package/client/src/nodeDefinitions/chatNodes.ts +135 -0
- package/client/src/nodeDefinitions/codeNodes.ts +54 -0
- package/client/src/nodeDefinitions/documentNodes.ts +379 -0
- package/client/src/nodeDefinitions/index.ts +15 -0
- package/client/src/nodeDefinitions/locationNodes.ts +463 -0
- package/client/src/nodeDefinitions/schedulerNodes.ts +220 -0
- package/client/src/nodeDefinitions/skillNodes.ts +211 -0
- package/client/src/nodeDefinitions/toolNodes.ts +198 -0
- package/client/src/nodeDefinitions/utilityNodes.ts +284 -0
- package/client/src/nodeDefinitions/whatsappNodes.ts +865 -0
- package/client/src/nodeDefinitions/workflowNodes.ts +41 -0
- package/client/src/nodeDefinitions.ts +104 -0
- package/client/src/schemas/workflowSchema.ts +264 -0
- package/client/src/services/dynamicParameterService.ts +96 -0
- package/client/src/services/execution/aiAgentExecutionService.ts +35 -0
- package/client/src/services/executionService.ts +232 -0
- package/client/src/services/workflowApi.ts +91 -0
- package/client/src/store/useAppStore.ts +582 -0
- package/client/src/styles/theme.ts +508 -0
- package/client/src/styles/zIndex.ts +17 -0
- package/client/src/types/ComponentTypes.ts +39 -0
- package/client/src/types/EdgeCondition.ts +231 -0
- package/client/src/types/INodeProperties.ts +288 -0
- package/client/src/types/NodeTypes.ts +28 -0
- package/client/src/utils/formatters.ts +33 -0
- package/client/src/utils/googleMapsLoader.ts +140 -0
- package/client/src/utils/locationUtils.ts +85 -0
- package/client/src/utils/nodeUtils.ts +31 -0
- package/client/src/utils/workflow.ts +30 -0
- package/client/src/utils/workflowExport.ts +120 -0
- package/client/src/vite-env.d.ts +12 -0
- package/client/tailwind.config.js +60 -0
- package/client/tsconfig.json +25 -0
- package/client/tsconfig.node.json +11 -0
- package/client/vite.config.js +35 -0
- package/docker-compose.prod.yml +107 -0
- package/docker-compose.yml +104 -0
- package/docs-MachinaOs/README.md +85 -0
- package/docs-MachinaOs/deployment/docker.mdx +228 -0
- package/docs-MachinaOs/deployment/production.mdx +345 -0
- package/docs-MachinaOs/docs.json +75 -0
- package/docs-MachinaOs/faq.mdx +309 -0
- package/docs-MachinaOs/favicon.svg +5 -0
- package/docs-MachinaOs/installation.mdx +160 -0
- package/docs-MachinaOs/introduction.mdx +114 -0
- package/docs-MachinaOs/logo/dark.svg +6 -0
- package/docs-MachinaOs/logo/light.svg +6 -0
- package/docs-MachinaOs/nodes/ai-agent.mdx +216 -0
- package/docs-MachinaOs/nodes/ai-models.mdx +240 -0
- package/docs-MachinaOs/nodes/android.mdx +411 -0
- package/docs-MachinaOs/nodes/overview.mdx +181 -0
- package/docs-MachinaOs/nodes/schedulers.mdx +316 -0
- package/docs-MachinaOs/nodes/webhooks.mdx +330 -0
- package/docs-MachinaOs/nodes/whatsapp.mdx +305 -0
- package/docs-MachinaOs/quickstart.mdx +119 -0
- package/docs-MachinaOs/tutorials/ai-agent-workflow.mdx +177 -0
- package/docs-MachinaOs/tutorials/android-automation.mdx +242 -0
- package/docs-MachinaOs/tutorials/first-workflow.mdx +134 -0
- package/docs-MachinaOs/tutorials/whatsapp-automation.mdx +185 -0
- package/nul +0 -0
- package/package.json +70 -0
- package/scripts/build.js +158 -0
- package/scripts/check-ports.ps1 +33 -0
- package/scripts/clean.js +40 -0
- package/scripts/docker.js +93 -0
- package/scripts/kill-port.ps1 +154 -0
- package/scripts/start.js +210 -0
- package/scripts/stop.js +325 -0
- package/server/.dockerignore +44 -0
- package/server/Dockerfile +45 -0
- package/server/constants.py +249 -0
- package/server/core/__init__.py +1 -0
- package/server/core/cache.py +461 -0
- package/server/core/config.py +128 -0
- package/server/core/container.py +99 -0
- package/server/core/database.py +1211 -0
- package/server/core/logging.py +314 -0
- package/server/main.py +289 -0
- package/server/middleware/__init__.py +5 -0
- package/server/middleware/auth.py +89 -0
- package/server/models/__init__.py +1 -0
- package/server/models/auth.py +52 -0
- package/server/models/cache.py +24 -0
- package/server/models/database.py +211 -0
- package/server/models/nodes.py +455 -0
- package/server/package.json +9 -0
- package/server/pyproject.toml +72 -0
- package/server/requirements.txt +83 -0
- package/server/routers/__init__.py +1 -0
- package/server/routers/android.py +294 -0
- package/server/routers/auth.py +203 -0
- package/server/routers/database.py +151 -0
- package/server/routers/maps.py +142 -0
- package/server/routers/nodejs_compat.py +289 -0
- package/server/routers/webhook.py +90 -0
- package/server/routers/websocket.py +2127 -0
- package/server/routers/whatsapp.py +761 -0
- package/server/routers/workflow.py +200 -0
- package/server/services/__init__.py +1 -0
- package/server/services/ai.py +2415 -0
- package/server/services/android/__init__.py +27 -0
- package/server/services/android/broadcaster.py +114 -0
- package/server/services/android/client.py +608 -0
- package/server/services/android/manager.py +78 -0
- package/server/services/android/protocol.py +165 -0
- package/server/services/android_service.py +588 -0
- package/server/services/auth.py +131 -0
- package/server/services/chat_client.py +160 -0
- package/server/services/deployment/__init__.py +12 -0
- package/server/services/deployment/manager.py +706 -0
- package/server/services/deployment/state.py +47 -0
- package/server/services/deployment/triggers.py +275 -0
- package/server/services/event_waiter.py +785 -0
- package/server/services/execution/__init__.py +77 -0
- package/server/services/execution/cache.py +769 -0
- package/server/services/execution/conditions.py +373 -0
- package/server/services/execution/dlq.py +132 -0
- package/server/services/execution/executor.py +1351 -0
- package/server/services/execution/models.py +531 -0
- package/server/services/execution/recovery.py +235 -0
- package/server/services/handlers/__init__.py +126 -0
- package/server/services/handlers/ai.py +355 -0
- package/server/services/handlers/android.py +260 -0
- package/server/services/handlers/code.py +278 -0
- package/server/services/handlers/document.py +598 -0
- package/server/services/handlers/http.py +193 -0
- package/server/services/handlers/polyglot.py +105 -0
- package/server/services/handlers/tools.py +845 -0
- package/server/services/handlers/triggers.py +107 -0
- package/server/services/handlers/utility.py +822 -0
- package/server/services/handlers/whatsapp.py +476 -0
- package/server/services/maps.py +289 -0
- package/server/services/memory_store.py +103 -0
- package/server/services/node_executor.py +375 -0
- package/server/services/parameter_resolver.py +218 -0
- package/server/services/polyglot_client.py +169 -0
- package/server/services/scheduler.py +155 -0
- package/server/services/skill_loader.py +417 -0
- package/server/services/status_broadcaster.py +826 -0
- package/server/services/temporal/__init__.py +23 -0
- package/server/services/temporal/activities.py +344 -0
- package/server/services/temporal/client.py +76 -0
- package/server/services/temporal/executor.py +147 -0
- package/server/services/temporal/worker.py +251 -0
- package/server/services/temporal/workflow.py +355 -0
- package/server/services/temporal/ws_client.py +236 -0
- package/server/services/text.py +111 -0
- package/server/services/user_auth.py +172 -0
- package/server/services/websocket_client.py +29 -0
- package/server/services/workflow.py +597 -0
- package/server/skills/android-skill/SKILL.md +82 -0
- package/server/skills/assistant-personality/SKILL.md +45 -0
- package/server/skills/code-skill/SKILL.md +140 -0
- package/server/skills/http-skill/SKILL.md +161 -0
- package/server/skills/maps-skill/SKILL.md +170 -0
- package/server/skills/memory-skill/SKILL.md +154 -0
- package/server/skills/scheduler-skill/SKILL.md +84 -0
- package/server/skills/whatsapp-skill/SKILL.md +283 -0
- package/server/uv.lock +2916 -0
- package/server/whatsapp-rpc/.dockerignore +30 -0
- package/server/whatsapp-rpc/Dockerfile +44 -0
- package/server/whatsapp-rpc/Dockerfile.web +17 -0
- package/server/whatsapp-rpc/README.md +139 -0
- package/server/whatsapp-rpc/cli.js +95 -0
- package/server/whatsapp-rpc/configs/config.yaml +7 -0
- package/server/whatsapp-rpc/docker-compose.yml +35 -0
- package/server/whatsapp-rpc/docs/API.md +410 -0
- package/server/whatsapp-rpc/go.mod +67 -0
- package/server/whatsapp-rpc/go.sum +203 -0
- package/server/whatsapp-rpc/package.json +30 -0
- package/server/whatsapp-rpc/schema.json +1294 -0
- package/server/whatsapp-rpc/scripts/clean.cjs +66 -0
- package/server/whatsapp-rpc/scripts/cli.js +162 -0
- package/server/whatsapp-rpc/src/go/cmd/server/main.go +91 -0
- package/server/whatsapp-rpc/src/go/config/config.go +49 -0
- package/server/whatsapp-rpc/src/go/rpc/rpc.go +446 -0
- package/server/whatsapp-rpc/src/go/rpc/server.go +112 -0
- package/server/whatsapp-rpc/src/go/whatsapp/history.go +166 -0
- package/server/whatsapp-rpc/src/go/whatsapp/messages.go +390 -0
- package/server/whatsapp-rpc/src/go/whatsapp/service.go +2130 -0
- package/server/whatsapp-rpc/src/go/whatsapp/types.go +261 -0
- package/server/whatsapp-rpc/src/python/pyproject.toml +15 -0
- package/server/whatsapp-rpc/src/python/whatsapp_rpc/__init__.py +4 -0
- package/server/whatsapp-rpc/src/python/whatsapp_rpc/client.py +427 -0
- package/server/whatsapp-rpc/web/app.py +609 -0
- package/server/whatsapp-rpc/web/requirements.txt +6 -0
- package/server/whatsapp-rpc/web/rpc_client.py +427 -0
- package/server/whatsapp-rpc/web/static/openapi.yaml +59 -0
- package/server/whatsapp-rpc/web/templates/base.html +150 -0
- package/server/whatsapp-rpc/web/templates/contacts.html +240 -0
- package/server/whatsapp-rpc/web/templates/dashboard.html +320 -0
- package/server/whatsapp-rpc/web/templates/groups.html +328 -0
- package/server/whatsapp-rpc/web/templates/messages.html +465 -0
- package/server/whatsapp-rpc/web/templates/messaging.html +681 -0
- package/server/whatsapp-rpc/web/templates/send.html +259 -0
- package/server/whatsapp-rpc/web/templates/settings.html +459 -0
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { useAppTheme } from '../../hooks/useAppTheme';
|
|
3
|
+
import { INodeTypeDescription } from '../../types/INodeProperties';
|
|
4
|
+
|
|
5
|
+
interface ComponentItemProps {
|
|
6
|
+
definition: INodeTypeDescription;
|
|
7
|
+
onDragStart: (event: React.DragEvent, definition: INodeTypeDescription) => void;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const ComponentItem: React.FC<ComponentItemProps> = ({ definition, onDragStart }) => {
|
|
11
|
+
const theme = useAppTheme();
|
|
12
|
+
const [isDragging, setIsDragging] = useState(false);
|
|
13
|
+
const [isHovered, setIsHovered] = useState(false);
|
|
14
|
+
|
|
15
|
+
// Helper to get colors from new interface format
|
|
16
|
+
const getNodeColor = () => definition.defaults.color || '#9E9E9E';
|
|
17
|
+
const isImageIcon = () => {
|
|
18
|
+
const icon = definition.icon;
|
|
19
|
+
return icon && (icon.startsWith('data:') || icon.startsWith('http') || icon.startsWith('/'));
|
|
20
|
+
};
|
|
21
|
+
const getIconBackground = () => isImageIcon() ? theme.colors.backgroundAlt : getNodeColor();
|
|
22
|
+
const getBorderColor = () => {
|
|
23
|
+
// Create a darker shade for border
|
|
24
|
+
const color = getNodeColor();
|
|
25
|
+
// Simple color darkening - could be enhanced
|
|
26
|
+
if (color.startsWith('#')) {
|
|
27
|
+
const hex = color.substring(1);
|
|
28
|
+
const r = Math.max(0, parseInt(hex.substring(0, 2), 16) - 40);
|
|
29
|
+
const g = Math.max(0, parseInt(hex.substring(2, 4), 16) - 40);
|
|
30
|
+
const b = Math.max(0, parseInt(hex.substring(4, 6), 16) - 40);
|
|
31
|
+
return `#${r.toString(16).padStart(2, '0')}${g.toString(16).padStart(2, '0')}${b.toString(16).padStart(2, '0')}`;
|
|
32
|
+
}
|
|
33
|
+
return color;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<div
|
|
38
|
+
draggable
|
|
39
|
+
onDragStart={(e) => {
|
|
40
|
+
setIsDragging(true);
|
|
41
|
+
onDragStart(e, definition);
|
|
42
|
+
}}
|
|
43
|
+
onDragEnd={() => setIsDragging(false)}
|
|
44
|
+
onMouseEnter={() => setIsHovered(true)}
|
|
45
|
+
onMouseLeave={() => setIsHovered(false)}
|
|
46
|
+
style={{
|
|
47
|
+
padding: '12px',
|
|
48
|
+
backgroundColor: theme.colors.background,
|
|
49
|
+
border: `2px solid ${isHovered ? getBorderColor() : theme.colors.border}`,
|
|
50
|
+
borderRadius: theme.borderRadius.lg,
|
|
51
|
+
cursor: 'grab',
|
|
52
|
+
transition: `all ${theme.transitions.fast}`,
|
|
53
|
+
display: 'flex',
|
|
54
|
+
alignItems: 'center',
|
|
55
|
+
gap: '12px',
|
|
56
|
+
boxShadow: isHovered
|
|
57
|
+
? theme.isDarkMode
|
|
58
|
+
? `0 4px 12px ${getNodeColor()}25, 0 0 0 1px ${getNodeColor()}15`
|
|
59
|
+
: `0 4px 12px ${getNodeColor()}30, 0 0 0 1px ${getNodeColor()}20`
|
|
60
|
+
: theme.isDarkMode
|
|
61
|
+
? `0 1px 3px ${theme.colors.shadowLight}`
|
|
62
|
+
: `0 1px 4px rgba(0,0,0,0.08)`,
|
|
63
|
+
transform: isHovered ? 'translateY(-2px) scale(1.02)' : 'translateY(0)',
|
|
64
|
+
opacity: isDragging ? 0.5 : 1,
|
|
65
|
+
fontFamily: 'system-ui, sans-serif',
|
|
66
|
+
position: 'relative',
|
|
67
|
+
overflow: 'hidden',
|
|
68
|
+
}}
|
|
69
|
+
>
|
|
70
|
+
{/* Gradient Background on Hover */}
|
|
71
|
+
<div style={{
|
|
72
|
+
position: 'absolute',
|
|
73
|
+
top: 0,
|
|
74
|
+
left: 0,
|
|
75
|
+
right: 0,
|
|
76
|
+
bottom: 0,
|
|
77
|
+
background: theme.isDarkMode
|
|
78
|
+
? `linear-gradient(135deg, ${getNodeColor()}08 0%, ${getNodeColor()}12 100%)`
|
|
79
|
+
: `linear-gradient(135deg, ${getNodeColor()}06 0%, ${getNodeColor()}12 100%)`,
|
|
80
|
+
opacity: isHovered ? 1 : 0,
|
|
81
|
+
transition: `opacity ${theme.transitions.fast}`,
|
|
82
|
+
pointerEvents: 'none',
|
|
83
|
+
}} />
|
|
84
|
+
|
|
85
|
+
{/* Icon */}
|
|
86
|
+
<div
|
|
87
|
+
style={{
|
|
88
|
+
fontSize: '18px',
|
|
89
|
+
width: '36px',
|
|
90
|
+
height: '36px',
|
|
91
|
+
display: 'flex',
|
|
92
|
+
alignItems: 'center',
|
|
93
|
+
justifyContent: 'center',
|
|
94
|
+
borderRadius: theme.borderRadius.md,
|
|
95
|
+
backgroundColor: getIconBackground(),
|
|
96
|
+
boxShadow: `0 2px 4px ${getNodeColor()}30`,
|
|
97
|
+
flexShrink: 0,
|
|
98
|
+
position: 'relative',
|
|
99
|
+
zIndex: 1,
|
|
100
|
+
}}
|
|
101
|
+
>
|
|
102
|
+
{definition.icon && (definition.icon.startsWith('data:') || definition.icon.startsWith('http') || definition.icon.startsWith('/')) ? (
|
|
103
|
+
<img src={definition.icon} alt="" style={{ width: '20px', height: '20px', objectFit: 'contain' }} />
|
|
104
|
+
) : (
|
|
105
|
+
definition.icon || '📦'
|
|
106
|
+
)}
|
|
107
|
+
</div>
|
|
108
|
+
|
|
109
|
+
{/* Content */}
|
|
110
|
+
<div style={{
|
|
111
|
+
flex: 1,
|
|
112
|
+
overflow: 'hidden',
|
|
113
|
+
position: 'relative',
|
|
114
|
+
zIndex: 1,
|
|
115
|
+
}}>
|
|
116
|
+
<div style={{
|
|
117
|
+
fontWeight: theme.fontWeight.medium,
|
|
118
|
+
fontSize: theme.fontSize.base,
|
|
119
|
+
color: theme.colors.text,
|
|
120
|
+
marginBottom: '2px',
|
|
121
|
+
overflow: 'hidden',
|
|
122
|
+
textOverflow: 'ellipsis',
|
|
123
|
+
whiteSpace: 'nowrap',
|
|
124
|
+
}}>
|
|
125
|
+
{definition.displayName}
|
|
126
|
+
</div>
|
|
127
|
+
<div style={{
|
|
128
|
+
fontSize: theme.fontSize.xs,
|
|
129
|
+
color: theme.colors.textSecondary,
|
|
130
|
+
overflow: 'hidden',
|
|
131
|
+
textOverflow: 'ellipsis',
|
|
132
|
+
whiteSpace: 'nowrap',
|
|
133
|
+
lineHeight: '1.3',
|
|
134
|
+
}}>
|
|
135
|
+
{definition.description}
|
|
136
|
+
</div>
|
|
137
|
+
</div>
|
|
138
|
+
|
|
139
|
+
{/* Drag Indicator */}
|
|
140
|
+
<div style={{
|
|
141
|
+
fontSize: '14px',
|
|
142
|
+
color: theme.colors.textSecondary,
|
|
143
|
+
opacity: isHovered ? 0.6 : 0.3,
|
|
144
|
+
transition: `opacity ${theme.transitions.fast}`,
|
|
145
|
+
position: 'relative',
|
|
146
|
+
zIndex: 1,
|
|
147
|
+
}}>
|
|
148
|
+
⋮⋮
|
|
149
|
+
</div>
|
|
150
|
+
</div>
|
|
151
|
+
);
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
export default ComponentItem;
|
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useAppTheme } from '../../hooks/useAppTheme';
|
|
3
|
+
import { ComponentPaletteProps } from '../../types/ComponentTypes';
|
|
4
|
+
import { INodeTypeDescription } from '../../types/INodeProperties';
|
|
5
|
+
import ComponentItem from './ComponentItem';
|
|
6
|
+
import CollapsibleSection from './CollapsibleSection';
|
|
7
|
+
|
|
8
|
+
// Category emoji icons
|
|
9
|
+
const CATEGORY_EMOJIS: Record<string, string> = {
|
|
10
|
+
workflow: '⚡',
|
|
11
|
+
trigger: '🕐',
|
|
12
|
+
ai: '🤖',
|
|
13
|
+
agent: '🤖',
|
|
14
|
+
model: '🧬',
|
|
15
|
+
skill: '🎯',
|
|
16
|
+
tool: '🛠️',
|
|
17
|
+
location: '📍',
|
|
18
|
+
whatsapp: '💬',
|
|
19
|
+
android: '📱',
|
|
20
|
+
chat: '💭',
|
|
21
|
+
code: '💻',
|
|
22
|
+
data: '🗄️',
|
|
23
|
+
util: '🔧',
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
// Categories shown in simple (noob) mode - only AI related
|
|
27
|
+
const SIMPLE_MODE_CATEGORIES = ['agent', 'model', 'skill'];
|
|
28
|
+
|
|
29
|
+
const ComponentPalette: React.FC<ComponentPaletteProps> = ({
|
|
30
|
+
nodeDefinitions,
|
|
31
|
+
searchQuery,
|
|
32
|
+
onSearchChange,
|
|
33
|
+
collapsedSections,
|
|
34
|
+
onToggleSection,
|
|
35
|
+
onDragStart,
|
|
36
|
+
proMode = false, // Default to simple mode
|
|
37
|
+
}) => {
|
|
38
|
+
const theme = useAppTheme();
|
|
39
|
+
|
|
40
|
+
const getCategoryConfig = (category: string) => {
|
|
41
|
+
const key = category.toLowerCase();
|
|
42
|
+
// Use theme-specific category colors (darker for light mode, vibrant for dark mode)
|
|
43
|
+
const colors = theme.colors as Record<string, string>;
|
|
44
|
+
const colorMap: Record<string, string> = {
|
|
45
|
+
workflow: colors.categoryWorkflow || theme.dracula.orange,
|
|
46
|
+
trigger: colors.categoryTrigger || theme.dracula.pink,
|
|
47
|
+
ai: colors.categoryAI || theme.dracula.purple,
|
|
48
|
+
agent: colors.categoryAgent || theme.dracula.purple,
|
|
49
|
+
model: colors.categoryModel || theme.dracula.cyan,
|
|
50
|
+
skill: colors.categorySkill || theme.dracula.green,
|
|
51
|
+
tool: colors.categoryTool || theme.dracula.green,
|
|
52
|
+
location: colors.categoryLocation || theme.dracula.red,
|
|
53
|
+
whatsapp: colors.categoryWhatsapp || theme.dracula.green,
|
|
54
|
+
android: colors.categoryAndroid || theme.dracula.cyan,
|
|
55
|
+
chat: colors.categoryChat || theme.dracula.yellow,
|
|
56
|
+
code: colors.categoryCode || theme.dracula.orange,
|
|
57
|
+
data: colors.categoryTrigger || theme.dracula.pink,
|
|
58
|
+
util: colors.categoryUtil || theme.dracula.purple,
|
|
59
|
+
};
|
|
60
|
+
const labelMap: Record<string, string> = {
|
|
61
|
+
workflow: 'Workflow',
|
|
62
|
+
trigger: 'Triggers',
|
|
63
|
+
ai: 'AI',
|
|
64
|
+
agent: 'AI Agents',
|
|
65
|
+
model: 'AI Models',
|
|
66
|
+
skill: 'AI Skills',
|
|
67
|
+
tool: 'AI Tools',
|
|
68
|
+
location: 'Google Maps',
|
|
69
|
+
whatsapp: 'WhatsApp',
|
|
70
|
+
android: 'Android',
|
|
71
|
+
chat: 'Chat',
|
|
72
|
+
code: 'Code Executors',
|
|
73
|
+
data: 'Data',
|
|
74
|
+
util: 'Utilities',
|
|
75
|
+
};
|
|
76
|
+
return {
|
|
77
|
+
icon: CATEGORY_EMOJIS[key] || '📦',
|
|
78
|
+
color: colorMap[key] || theme.colors.textSecondary,
|
|
79
|
+
label: labelMap[key] || category
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
const categorizedComponents = React.useMemo(() => {
|
|
84
|
+
const categories: Record<string, INodeTypeDescription[]> = {};
|
|
85
|
+
|
|
86
|
+
const filteredDefinitions = Object.values(nodeDefinitions).filter((definition) => {
|
|
87
|
+
// Filter by search query
|
|
88
|
+
if (searchQuery.trim()) {
|
|
89
|
+
try {
|
|
90
|
+
const query = searchQuery.toLowerCase();
|
|
91
|
+
const matchesQuery = (
|
|
92
|
+
(definition.displayName || '').toLowerCase().includes(query) ||
|
|
93
|
+
(definition.description || '').toLowerCase().includes(query) ||
|
|
94
|
+
(definition.group?.[0] || '').toLowerCase().includes(query)
|
|
95
|
+
);
|
|
96
|
+
if (!matchesQuery) return false;
|
|
97
|
+
} catch (error) {
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// Filter by proMode - in simple mode, only show AI-related categories
|
|
103
|
+
if (!proMode) {
|
|
104
|
+
const categoryKey = (definition.group?.[0] || '').toLowerCase();
|
|
105
|
+
if (!SIMPLE_MODE_CATEGORIES.includes(categoryKey)) {
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return true;
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
filteredDefinitions.forEach((definition) => {
|
|
114
|
+
try {
|
|
115
|
+
const categoryKey = definition.group?.[0] || 'Uncategorized';
|
|
116
|
+
if (!categories[categoryKey]) {
|
|
117
|
+
categories[categoryKey] = [];
|
|
118
|
+
}
|
|
119
|
+
categories[categoryKey].push(definition);
|
|
120
|
+
} catch (error) {
|
|
121
|
+
// Skip invalid definitions
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
return categories;
|
|
126
|
+
}, [nodeDefinitions, searchQuery, proMode]);
|
|
127
|
+
|
|
128
|
+
const totalComponents = Object.values(categorizedComponents).reduce(
|
|
129
|
+
(acc, components) => acc + components.length,
|
|
130
|
+
0
|
|
131
|
+
);
|
|
132
|
+
|
|
133
|
+
return (
|
|
134
|
+
<div style={{
|
|
135
|
+
width: '100%',
|
|
136
|
+
height: '100%',
|
|
137
|
+
overflowY: 'auto',
|
|
138
|
+
backgroundColor: theme.colors.backgroundPanel,
|
|
139
|
+
display: 'flex',
|
|
140
|
+
flexDirection: 'column',
|
|
141
|
+
}}>
|
|
142
|
+
{/* Header Section */}
|
|
143
|
+
<div style={{
|
|
144
|
+
padding: theme.spacing.lg,
|
|
145
|
+
borderBottom: `1px solid ${theme.colors.border}`,
|
|
146
|
+
background: theme.colors.background,
|
|
147
|
+
}}>
|
|
148
|
+
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', marginBottom: theme.spacing.md }}>
|
|
149
|
+
<h2 style={{
|
|
150
|
+
margin: 0,
|
|
151
|
+
fontSize: theme.fontSize.lg,
|
|
152
|
+
fontWeight: theme.fontWeight.semibold,
|
|
153
|
+
color: theme.colors.text,
|
|
154
|
+
fontFamily: 'system-ui, sans-serif',
|
|
155
|
+
}}>
|
|
156
|
+
Components
|
|
157
|
+
</h2>
|
|
158
|
+
<span style={{
|
|
159
|
+
fontSize: theme.fontSize.xs,
|
|
160
|
+
padding: '4px 10px',
|
|
161
|
+
backgroundColor: theme.colors.backgroundAlt,
|
|
162
|
+
borderRadius: '12px',
|
|
163
|
+
color: theme.colors.textSecondary,
|
|
164
|
+
fontWeight: theme.fontWeight.medium,
|
|
165
|
+
}}>
|
|
166
|
+
{totalComponents}
|
|
167
|
+
</span>
|
|
168
|
+
</div>
|
|
169
|
+
|
|
170
|
+
{/* Search Input */}
|
|
171
|
+
<div style={{ position: 'relative' }}>
|
|
172
|
+
<input
|
|
173
|
+
type="text"
|
|
174
|
+
placeholder="Search..."
|
|
175
|
+
value={searchQuery}
|
|
176
|
+
onChange={(e) => onSearchChange(e.target.value)}
|
|
177
|
+
style={{
|
|
178
|
+
width: '100%',
|
|
179
|
+
padding: '10px 12px',
|
|
180
|
+
paddingLeft: '36px',
|
|
181
|
+
fontSize: theme.fontSize.sm,
|
|
182
|
+
border: `1px solid ${theme.colors.border}`,
|
|
183
|
+
borderRadius: theme.borderRadius.md,
|
|
184
|
+
backgroundColor: theme.colors.backgroundAlt,
|
|
185
|
+
color: theme.colors.text,
|
|
186
|
+
fontFamily: 'system-ui, sans-serif',
|
|
187
|
+
outline: 'none',
|
|
188
|
+
transition: `all ${theme.transitions.fast}`,
|
|
189
|
+
}}
|
|
190
|
+
onFocus={(e) => {
|
|
191
|
+
e.currentTarget.style.borderColor = theme.colors.focus;
|
|
192
|
+
e.currentTarget.style.backgroundColor = theme.colors.background;
|
|
193
|
+
}}
|
|
194
|
+
onBlur={(e) => {
|
|
195
|
+
e.currentTarget.style.borderColor = theme.colors.border;
|
|
196
|
+
e.currentTarget.style.backgroundColor = theme.colors.backgroundAlt;
|
|
197
|
+
}}
|
|
198
|
+
/>
|
|
199
|
+
<svg
|
|
200
|
+
style={{
|
|
201
|
+
position: 'absolute',
|
|
202
|
+
left: '12px',
|
|
203
|
+
top: '50%',
|
|
204
|
+
transform: 'translateY(-50%)',
|
|
205
|
+
width: '16px',
|
|
206
|
+
height: '16px',
|
|
207
|
+
color: theme.colors.textSecondary,
|
|
208
|
+
pointerEvents: 'none',
|
|
209
|
+
}}
|
|
210
|
+
fill="none"
|
|
211
|
+
stroke="currentColor"
|
|
212
|
+
viewBox="0 0 24 24"
|
|
213
|
+
>
|
|
214
|
+
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z" />
|
|
215
|
+
</svg>
|
|
216
|
+
</div>
|
|
217
|
+
</div>
|
|
218
|
+
|
|
219
|
+
{/* Categories */}
|
|
220
|
+
<div style={{
|
|
221
|
+
padding: theme.spacing.md,
|
|
222
|
+
flex: 1,
|
|
223
|
+
overflowY: 'auto',
|
|
224
|
+
}}>
|
|
225
|
+
{Object.keys(categorizedComponents).length === 0 ? (
|
|
226
|
+
<div style={{
|
|
227
|
+
textAlign: 'center',
|
|
228
|
+
padding: theme.spacing.xxl,
|
|
229
|
+
color: theme.colors.textSecondary,
|
|
230
|
+
}}>
|
|
231
|
+
<svg
|
|
232
|
+
style={{ width: '48px', height: '48px', marginBottom: theme.spacing.md, opacity: 0.5 }}
|
|
233
|
+
fill="none"
|
|
234
|
+
stroke="currentColor"
|
|
235
|
+
viewBox="0 0 24 24"
|
|
236
|
+
>
|
|
237
|
+
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={1.5} d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z" />
|
|
238
|
+
</svg>
|
|
239
|
+
<p style={{ margin: 0, fontSize: theme.fontSize.sm }}>
|
|
240
|
+
No components found matching "{searchQuery}"
|
|
241
|
+
</p>
|
|
242
|
+
</div>
|
|
243
|
+
) : (
|
|
244
|
+
Object.entries(categorizedComponents).map(([category, components]) => {
|
|
245
|
+
try {
|
|
246
|
+
const isCollapsed = collapsedSections[category];
|
|
247
|
+
const config = getCategoryConfig(category);
|
|
248
|
+
|
|
249
|
+
return (
|
|
250
|
+
<div key={category || 'unknown'} style={{ marginBottom: theme.spacing.md }}>
|
|
251
|
+
<CollapsibleSection
|
|
252
|
+
title={
|
|
253
|
+
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', width: '100%' }}>
|
|
254
|
+
<div style={{ display: 'flex', alignItems: 'center', gap: '10px' }}>
|
|
255
|
+
<span style={{
|
|
256
|
+
width: '28px',
|
|
257
|
+
height: '28px',
|
|
258
|
+
display: 'flex',
|
|
259
|
+
alignItems: 'center',
|
|
260
|
+
justifyContent: 'center',
|
|
261
|
+
backgroundColor: `${config.color}20`,
|
|
262
|
+
borderRadius: '6px',
|
|
263
|
+
fontSize: '16px',
|
|
264
|
+
}}>
|
|
265
|
+
{config.icon}
|
|
266
|
+
</span>
|
|
267
|
+
<span style={{
|
|
268
|
+
fontWeight: theme.fontWeight.semibold,
|
|
269
|
+
color: theme.colors.text,
|
|
270
|
+
}}>
|
|
271
|
+
{config.label}
|
|
272
|
+
</span>
|
|
273
|
+
</div>
|
|
274
|
+
<span style={{
|
|
275
|
+
fontSize: theme.fontSize.xs,
|
|
276
|
+
padding: '3px 10px',
|
|
277
|
+
backgroundColor: `${config.color}15`,
|
|
278
|
+
borderRadius: '12px',
|
|
279
|
+
color: theme.colors.textSecondary,
|
|
280
|
+
fontWeight: theme.fontWeight.medium,
|
|
281
|
+
}}>
|
|
282
|
+
{components?.length || 0}
|
|
283
|
+
</span>
|
|
284
|
+
</div>
|
|
285
|
+
}
|
|
286
|
+
isCollapsed={isCollapsed}
|
|
287
|
+
onToggle={() => onToggleSection(category)}
|
|
288
|
+
>
|
|
289
|
+
<div style={{
|
|
290
|
+
display: 'grid',
|
|
291
|
+
gap: theme.spacing.sm,
|
|
292
|
+
paddingTop: theme.spacing.sm,
|
|
293
|
+
}}>
|
|
294
|
+
{(components || []).map((definition, idx) => {
|
|
295
|
+
try {
|
|
296
|
+
return (
|
|
297
|
+
<ComponentItem
|
|
298
|
+
key={definition?.name || `item-${idx}`}
|
|
299
|
+
definition={definition}
|
|
300
|
+
onDragStart={onDragStart}
|
|
301
|
+
/>
|
|
302
|
+
);
|
|
303
|
+
} catch (error) {
|
|
304
|
+
return null;
|
|
305
|
+
}
|
|
306
|
+
})}
|
|
307
|
+
</div>
|
|
308
|
+
</CollapsibleSection>
|
|
309
|
+
</div>
|
|
310
|
+
);
|
|
311
|
+
} catch (error) {
|
|
312
|
+
return null;
|
|
313
|
+
}
|
|
314
|
+
})
|
|
315
|
+
)}
|
|
316
|
+
</div>
|
|
317
|
+
</div>
|
|
318
|
+
);
|
|
319
|
+
};
|
|
320
|
+
|
|
321
|
+
export default ComponentPalette;
|