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,471 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { useAppTheme } from '../hooks/useAppTheme';
|
|
3
|
+
import { useAppStore } from '../store/useAppStore';
|
|
4
|
+
import { nodeDefinitions } from '../nodeDefinitions';
|
|
5
|
+
import { INodeOutputDefinition, NodeConnectionType } from '../types/INodeProperties';
|
|
6
|
+
import { useDragVariable } from '../hooks/useDragVariable';
|
|
7
|
+
|
|
8
|
+
interface OutputPanelProps {
|
|
9
|
+
nodeId: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
interface ConnectedNodeData {
|
|
13
|
+
nodeId: string;
|
|
14
|
+
nodeName: string;
|
|
15
|
+
outputs: INodeOutputDefinition[];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Android node output schemas - matches the flattened output structure from backend
|
|
19
|
+
// These are shown as draggable outputs for template variable creation
|
|
20
|
+
const ANDROID_OUTPUT_SCHEMAS: Record<string, Record<string, string>> = {
|
|
21
|
+
batteryMonitor: {
|
|
22
|
+
battery_level: 'number',
|
|
23
|
+
is_charging: 'boolean',
|
|
24
|
+
temperature_celsius: 'number',
|
|
25
|
+
health: 'string',
|
|
26
|
+
voltage: 'number'
|
|
27
|
+
},
|
|
28
|
+
systemInfo: {
|
|
29
|
+
device_model: 'string',
|
|
30
|
+
android_version: 'string',
|
|
31
|
+
api_level: 'number',
|
|
32
|
+
manufacturer: 'string',
|
|
33
|
+
total_memory: 'number',
|
|
34
|
+
available_memory: 'number'
|
|
35
|
+
},
|
|
36
|
+
networkMonitor: {
|
|
37
|
+
connected: 'boolean',
|
|
38
|
+
type: 'string',
|
|
39
|
+
ssid: 'string',
|
|
40
|
+
ip_address: 'string',
|
|
41
|
+
signal_strength: 'number'
|
|
42
|
+
},
|
|
43
|
+
wifiAutomation: {
|
|
44
|
+
enabled: 'boolean',
|
|
45
|
+
connected: 'boolean',
|
|
46
|
+
ssid: 'string',
|
|
47
|
+
networks: 'array'
|
|
48
|
+
},
|
|
49
|
+
bluetoothAutomation: {
|
|
50
|
+
enabled: 'boolean',
|
|
51
|
+
connected: 'boolean',
|
|
52
|
+
paired_devices: 'array'
|
|
53
|
+
},
|
|
54
|
+
audioAutomation: {
|
|
55
|
+
media_volume: 'number',
|
|
56
|
+
ring_volume: 'number',
|
|
57
|
+
muted: 'boolean'
|
|
58
|
+
},
|
|
59
|
+
location: {
|
|
60
|
+
latitude: 'number',
|
|
61
|
+
longitude: 'number',
|
|
62
|
+
accuracy: 'number',
|
|
63
|
+
provider: 'string',
|
|
64
|
+
altitude: 'number',
|
|
65
|
+
speed: 'number',
|
|
66
|
+
bearing: 'number'
|
|
67
|
+
},
|
|
68
|
+
appLauncher: {
|
|
69
|
+
package_name: 'string',
|
|
70
|
+
launched: 'boolean',
|
|
71
|
+
app_name: 'string'
|
|
72
|
+
},
|
|
73
|
+
appList: {
|
|
74
|
+
apps: 'array',
|
|
75
|
+
count: 'number'
|
|
76
|
+
},
|
|
77
|
+
deviceStateAutomation: {
|
|
78
|
+
airplane_mode: 'boolean',
|
|
79
|
+
screen_on: 'boolean',
|
|
80
|
+
brightness: 'number'
|
|
81
|
+
},
|
|
82
|
+
screenControlAutomation: {
|
|
83
|
+
brightness: 'number',
|
|
84
|
+
auto_brightness: 'boolean',
|
|
85
|
+
screen_timeout: 'number'
|
|
86
|
+
},
|
|
87
|
+
motionDetection: {
|
|
88
|
+
acceleration_x: 'number',
|
|
89
|
+
acceleration_y: 'number',
|
|
90
|
+
acceleration_z: 'number',
|
|
91
|
+
is_moving: 'boolean'
|
|
92
|
+
},
|
|
93
|
+
environmentalSensors: {
|
|
94
|
+
temperature: 'number',
|
|
95
|
+
humidity: 'number',
|
|
96
|
+
pressure: 'number',
|
|
97
|
+
light: 'number'
|
|
98
|
+
},
|
|
99
|
+
cameraControl: {
|
|
100
|
+
cameras: 'array',
|
|
101
|
+
photo_path: 'string'
|
|
102
|
+
},
|
|
103
|
+
mediaControl: {
|
|
104
|
+
playing: 'boolean',
|
|
105
|
+
volume: 'number',
|
|
106
|
+
track: 'string'
|
|
107
|
+
},
|
|
108
|
+
airplaneModeControl: {
|
|
109
|
+
enabled: 'boolean'
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
// List of Android service node types
|
|
114
|
+
const ANDROID_NODE_TYPES = [
|
|
115
|
+
'batteryMonitor', 'systemInfo', 'networkMonitor', 'location',
|
|
116
|
+
'wifiAutomation', 'bluetoothAutomation', 'audioAutomation',
|
|
117
|
+
'deviceStateAutomation', 'screenControlAutomation', 'airplaneModeControl',
|
|
118
|
+
'motionDetection', 'environmentalSensors', 'cameraControl', 'mediaControl',
|
|
119
|
+
'appLauncher', 'appList'
|
|
120
|
+
];
|
|
121
|
+
|
|
122
|
+
const OutputPanel: React.FC<OutputPanelProps> = ({ nodeId }) => {
|
|
123
|
+
const theme = useAppTheme();
|
|
124
|
+
const { currentWorkflow } = useAppStore();
|
|
125
|
+
const [expandedNode, setExpandedNode] = useState<string | null>(null);
|
|
126
|
+
const [isDragging, setIsDragging] = useState(false);
|
|
127
|
+
const [draggedParam, setDraggedParam] = useState<{ nodeId: string; output: string } | null>(null);
|
|
128
|
+
|
|
129
|
+
// Use the same template variable naming as InputSection for consistency
|
|
130
|
+
const { getTemplateVariableName } = useDragVariable(nodeId);
|
|
131
|
+
|
|
132
|
+
// Helper to get outputs from a node definition
|
|
133
|
+
const getNodeOutputs = (nodeType: string): INodeOutputDefinition[] => {
|
|
134
|
+
// For Android nodes, use the detailed schema to show individual draggable properties
|
|
135
|
+
if (ANDROID_NODE_TYPES.includes(nodeType)) {
|
|
136
|
+
const schema = ANDROID_OUTPUT_SCHEMAS[nodeType];
|
|
137
|
+
if (schema) {
|
|
138
|
+
return Object.entries(schema).map(([name, type]) => ({
|
|
139
|
+
name,
|
|
140
|
+
displayName: name.split('_').map(w => w.charAt(0).toUpperCase() + w.slice(1)).join(' '),
|
|
141
|
+
type: type as NodeConnectionType,
|
|
142
|
+
description: `${type} value`
|
|
143
|
+
}));
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
const definition = nodeDefinitions[nodeType];
|
|
148
|
+
if (!definition) return [];
|
|
149
|
+
|
|
150
|
+
if (!definition.outputs) {
|
|
151
|
+
return [{
|
|
152
|
+
name: 'output',
|
|
153
|
+
displayName: 'Output',
|
|
154
|
+
type: 'main' as NodeConnectionType,
|
|
155
|
+
description: 'Node output'
|
|
156
|
+
}];
|
|
157
|
+
} else if (Array.isArray(definition.outputs)) {
|
|
158
|
+
if (typeof definition.outputs[0] === 'string') {
|
|
159
|
+
return (definition.outputs as string[]).map(outputName => ({
|
|
160
|
+
name: outputName,
|
|
161
|
+
displayName: outputName.charAt(0).toUpperCase() + outputName.slice(1),
|
|
162
|
+
type: 'main' as NodeConnectionType,
|
|
163
|
+
description: `${outputName} output`
|
|
164
|
+
}));
|
|
165
|
+
} else {
|
|
166
|
+
return definition.outputs as INodeOutputDefinition[];
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return [{
|
|
170
|
+
name: 'output',
|
|
171
|
+
displayName: 'Output',
|
|
172
|
+
type: 'main' as NodeConnectionType,
|
|
173
|
+
description: 'Node output'
|
|
174
|
+
}];
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
// Helper to check if a handle is a config/auxiliary handle (not main data flow)
|
|
178
|
+
const isConfigHandle = (handle: string | null | undefined): boolean => {
|
|
179
|
+
if (!handle) return false;
|
|
180
|
+
// Config handles follow pattern: input-<type> where type is not 'main'
|
|
181
|
+
// Examples: input-memory, input-tools, input-model
|
|
182
|
+
if (handle.startsWith('input-') && handle !== 'input-main') {
|
|
183
|
+
return true;
|
|
184
|
+
}
|
|
185
|
+
return false;
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
// Helper to check if a node is a config/auxiliary node (connects to config handles)
|
|
189
|
+
const isConfigNode = (nodeType: string | undefined): boolean => {
|
|
190
|
+
if (!nodeType) return false;
|
|
191
|
+
const definition = nodeDefinitions[nodeType];
|
|
192
|
+
if (!definition) return false;
|
|
193
|
+
// Config nodes typically have 'memory' or 'tool' in their group, or have no main input
|
|
194
|
+
const groups = definition.group || [];
|
|
195
|
+
return groups.includes('memory') || groups.includes('tool');
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
// Get connected nodes with their outputs
|
|
199
|
+
const getConnectedNodes = (): ConnectedNodeData[] => {
|
|
200
|
+
if (!currentWorkflow || !nodeId) return [];
|
|
201
|
+
|
|
202
|
+
const connectedNodes: ConnectedNodeData[] = [];
|
|
203
|
+
const addedNodeIds = new Set<string>();
|
|
204
|
+
|
|
205
|
+
// Helper to add a node to connected list
|
|
206
|
+
const addConnectedNode = (sourceNodeId: string, label?: string) => {
|
|
207
|
+
if (addedNodeIds.has(sourceNodeId)) return;
|
|
208
|
+
|
|
209
|
+
const sourceNode = currentWorkflow.nodes.find(n => n.id === sourceNodeId);
|
|
210
|
+
if (!sourceNode?.type) return;
|
|
211
|
+
|
|
212
|
+
const sourceDefinition = nodeDefinitions[sourceNode.type];
|
|
213
|
+
if (!sourceDefinition) return;
|
|
214
|
+
|
|
215
|
+
addedNodeIds.add(sourceNodeId);
|
|
216
|
+
connectedNodes.push({
|
|
217
|
+
nodeId: sourceNode.id,
|
|
218
|
+
nodeName: label ? `${sourceDefinition.displayName} (${label})` : sourceDefinition.displayName,
|
|
219
|
+
outputs: getNodeOutputs(sourceNode.type)
|
|
220
|
+
});
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
// Find all edges that connect TO the current node
|
|
224
|
+
const incomingEdges = currentWorkflow.edges.filter(edge => edge.target === nodeId);
|
|
225
|
+
|
|
226
|
+
// Get current node info
|
|
227
|
+
const currentNode = currentWorkflow.nodes.find(n => n.id === nodeId);
|
|
228
|
+
const currentNodeType = currentNode?.type;
|
|
229
|
+
|
|
230
|
+
for (const edge of incomingEdges) {
|
|
231
|
+
// Skip config handle connections - they're for auxiliary nodes, not main data flow
|
|
232
|
+
if (isConfigHandle(edge.targetHandle)) {
|
|
233
|
+
continue;
|
|
234
|
+
}
|
|
235
|
+
addConnectedNode(edge.source);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
// If current node is a config node (memory, tool), inherit parent node's main inputs
|
|
239
|
+
if (isConfigNode(currentNodeType)) {
|
|
240
|
+
// Find which parent node this config node is connected to
|
|
241
|
+
const outgoingEdges = currentWorkflow.edges.filter(edge => edge.source === nodeId);
|
|
242
|
+
|
|
243
|
+
for (const edge of outgoingEdges) {
|
|
244
|
+
// Check if connected to a config handle on the target
|
|
245
|
+
if (isConfigHandle(edge.targetHandle)) {
|
|
246
|
+
const targetNode = currentWorkflow.nodes.find(n => n.id === edge.target);
|
|
247
|
+
if (!targetNode) continue;
|
|
248
|
+
|
|
249
|
+
const targetDef = nodeDefinitions[targetNode.type || ''];
|
|
250
|
+
const targetName = targetDef?.displayName || targetNode.type;
|
|
251
|
+
|
|
252
|
+
// Find nodes connected to the parent's main input (non-config handles)
|
|
253
|
+
const parentInputEdges = currentWorkflow.edges.filter(
|
|
254
|
+
e => e.target === targetNode.id && !isConfigHandle(e.targetHandle)
|
|
255
|
+
);
|
|
256
|
+
|
|
257
|
+
for (const parentEdge of parentInputEdges) {
|
|
258
|
+
addConnectedNode(parentEdge.source, `via ${targetName}`);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
return connectedNodes;
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
const connectedNodes = getConnectedNodes();
|
|
268
|
+
|
|
269
|
+
const handleDragStart = (e: React.DragEvent, sourceNodeId: string, outputName: string) => {
|
|
270
|
+
setIsDragging(true);
|
|
271
|
+
setDraggedParam({ nodeId: sourceNodeId, output: outputName });
|
|
272
|
+
e.dataTransfer.effectAllowed = 'copy';
|
|
273
|
+
|
|
274
|
+
// Use the same template naming as InputSection for consistency
|
|
275
|
+
// This ensures Android nodes and all other nodes work properly with template variables
|
|
276
|
+
const templateName = getTemplateVariableName(sourceNodeId);
|
|
277
|
+
|
|
278
|
+
e.dataTransfer.setData('text/plain', `{{${templateName}.${outputName}}}`);
|
|
279
|
+
};
|
|
280
|
+
|
|
281
|
+
const handleDragEnd = () => {
|
|
282
|
+
setIsDragging(false);
|
|
283
|
+
setDraggedParam(null);
|
|
284
|
+
};
|
|
285
|
+
|
|
286
|
+
if (connectedNodes.length === 0) {
|
|
287
|
+
return (
|
|
288
|
+
<div style={{
|
|
289
|
+
width: '300px',
|
|
290
|
+
height: '100%',
|
|
291
|
+
padding: theme.spacing.md,
|
|
292
|
+
backgroundColor: theme.colors.backgroundAlt,
|
|
293
|
+
borderRight: `1px solid ${theme.colors.border}`,
|
|
294
|
+
display: 'flex',
|
|
295
|
+
flexDirection: 'column',
|
|
296
|
+
alignItems: 'center',
|
|
297
|
+
justifyContent: 'center'
|
|
298
|
+
}}>
|
|
299
|
+
<p style={{
|
|
300
|
+
margin: 0,
|
|
301
|
+
fontSize: theme.fontSize.sm,
|
|
302
|
+
color: theme.colors.textSecondary,
|
|
303
|
+
fontStyle: 'italic',
|
|
304
|
+
textAlign: 'center'
|
|
305
|
+
}}>
|
|
306
|
+
No connected nodes.
|
|
307
|
+
<br />
|
|
308
|
+
Connect nodes to see their outputs here.
|
|
309
|
+
</p>
|
|
310
|
+
</div>
|
|
311
|
+
);
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
return (
|
|
315
|
+
<div style={{
|
|
316
|
+
width: '300px',
|
|
317
|
+
height: '100%',
|
|
318
|
+
backgroundColor: theme.colors.backgroundAlt,
|
|
319
|
+
borderRight: `1px solid ${theme.colors.border}`,
|
|
320
|
+
display: 'flex',
|
|
321
|
+
flexDirection: 'column'
|
|
322
|
+
}}>
|
|
323
|
+
{/* Header */}
|
|
324
|
+
<div style={{
|
|
325
|
+
padding: theme.spacing.md,
|
|
326
|
+
backgroundColor: theme.colors.backgroundPanel,
|
|
327
|
+
borderBottom: `1px solid ${theme.colors.border}`,
|
|
328
|
+
fontSize: theme.fontSize.sm,
|
|
329
|
+
fontWeight: theme.fontWeight.semibold,
|
|
330
|
+
color: theme.colors.textSecondary,
|
|
331
|
+
textTransform: 'uppercase',
|
|
332
|
+
letterSpacing: '0.1em'
|
|
333
|
+
}}>
|
|
334
|
+
🔗 Connected Outputs
|
|
335
|
+
</div>
|
|
336
|
+
|
|
337
|
+
{/* Scrollable content */}
|
|
338
|
+
<div style={{
|
|
339
|
+
flex: 1,
|
|
340
|
+
overflowY: 'auto',
|
|
341
|
+
padding: theme.spacing.sm
|
|
342
|
+
}}>
|
|
343
|
+
{connectedNodes.map((node) => (
|
|
344
|
+
<div key={node.nodeId} style={{
|
|
345
|
+
marginBottom: theme.spacing.xs,
|
|
346
|
+
border: `1px solid ${theme.colors.border}`,
|
|
347
|
+
borderRadius: theme.borderRadius.sm,
|
|
348
|
+
backgroundColor: theme.colors.background,
|
|
349
|
+
overflow: 'hidden'
|
|
350
|
+
}}>
|
|
351
|
+
<div
|
|
352
|
+
onClick={() => setExpandedNode(expandedNode === node.nodeId ? null : node.nodeId)}
|
|
353
|
+
style={{
|
|
354
|
+
padding: theme.spacing.sm,
|
|
355
|
+
cursor: 'pointer',
|
|
356
|
+
display: 'flex',
|
|
357
|
+
alignItems: 'center',
|
|
358
|
+
justifyContent: 'space-between',
|
|
359
|
+
backgroundColor: theme.colors.backgroundAlt,
|
|
360
|
+
transition: theme.transitions.fast
|
|
361
|
+
}}
|
|
362
|
+
>
|
|
363
|
+
<span style={{
|
|
364
|
+
fontSize: theme.fontSize.sm,
|
|
365
|
+
fontWeight: theme.fontWeight.medium,
|
|
366
|
+
color: theme.colors.text
|
|
367
|
+
}}>
|
|
368
|
+
📦 {node.nodeName}
|
|
369
|
+
</span>
|
|
370
|
+
<span style={{
|
|
371
|
+
fontSize: theme.fontSize.xs,
|
|
372
|
+
color: theme.colors.textSecondary,
|
|
373
|
+
transform: expandedNode === node.nodeId ? 'rotate(180deg)' : 'rotate(0deg)',
|
|
374
|
+
transition: 'transform 0.2s ease'
|
|
375
|
+
}}>
|
|
376
|
+
â–¼
|
|
377
|
+
</span>
|
|
378
|
+
</div>
|
|
379
|
+
|
|
380
|
+
{expandedNode === node.nodeId && (
|
|
381
|
+
<div style={{
|
|
382
|
+
padding: theme.spacing.sm,
|
|
383
|
+
borderTop: `1px solid ${theme.colors.border}`
|
|
384
|
+
}}>
|
|
385
|
+
{node.outputs.length === 0 ? (
|
|
386
|
+
<p style={{
|
|
387
|
+
margin: 0,
|
|
388
|
+
fontSize: theme.fontSize.xs,
|
|
389
|
+
color: theme.colors.textSecondary,
|
|
390
|
+
fontStyle: 'italic',
|
|
391
|
+
padding: theme.spacing.xs
|
|
392
|
+
}}>
|
|
393
|
+
No output parameters available
|
|
394
|
+
</p>
|
|
395
|
+
) : (
|
|
396
|
+
node.outputs.map((output) => (
|
|
397
|
+
<div
|
|
398
|
+
key={output.name}
|
|
399
|
+
draggable
|
|
400
|
+
onDragStart={(e) => handleDragStart(e, node.nodeId, output.name)}
|
|
401
|
+
onDragEnd={handleDragEnd}
|
|
402
|
+
style={{
|
|
403
|
+
padding: theme.spacing.xs,
|
|
404
|
+
marginBottom: theme.spacing.xs,
|
|
405
|
+
backgroundColor: isDragging && draggedParam?.nodeId === node.nodeId && draggedParam?.output === output.name
|
|
406
|
+
? theme.colors.focusRing
|
|
407
|
+
: theme.colors.backgroundAlt,
|
|
408
|
+
border: `1px solid ${theme.colors.border}`,
|
|
409
|
+
borderRadius: theme.borderRadius.sm,
|
|
410
|
+
cursor: 'grab',
|
|
411
|
+
transition: theme.transitions.fast
|
|
412
|
+
}}
|
|
413
|
+
>
|
|
414
|
+
<div style={{
|
|
415
|
+
display: 'flex',
|
|
416
|
+
alignItems: 'center',
|
|
417
|
+
justifyContent: 'space-between'
|
|
418
|
+
}}>
|
|
419
|
+
<div>
|
|
420
|
+
<div style={{
|
|
421
|
+
fontSize: theme.fontSize.sm,
|
|
422
|
+
fontWeight: theme.fontWeight.medium,
|
|
423
|
+
color: theme.colors.text,
|
|
424
|
+
marginBottom: '2px'
|
|
425
|
+
}}>
|
|
426
|
+
{output.displayName}
|
|
427
|
+
</div>
|
|
428
|
+
<div style={{
|
|
429
|
+
fontSize: theme.fontSize.xs,
|
|
430
|
+
color: theme.colors.textSecondary
|
|
431
|
+
}}>
|
|
432
|
+
{output.type} • {output.description}
|
|
433
|
+
</div>
|
|
434
|
+
</div>
|
|
435
|
+
<div style={{
|
|
436
|
+
fontSize: theme.fontSize.xs,
|
|
437
|
+
color: theme.colors.textSecondary,
|
|
438
|
+
fontFamily: 'monospace',
|
|
439
|
+
padding: `2px ${theme.spacing.xs}`,
|
|
440
|
+
backgroundColor: theme.colors.background,
|
|
441
|
+
borderRadius: theme.borderRadius.sm,
|
|
442
|
+
border: `1px solid ${theme.colors.border}`
|
|
443
|
+
}}>
|
|
444
|
+
{output.name}
|
|
445
|
+
</div>
|
|
446
|
+
</div>
|
|
447
|
+
</div>
|
|
448
|
+
))
|
|
449
|
+
)}
|
|
450
|
+
</div>
|
|
451
|
+
)}
|
|
452
|
+
</div>
|
|
453
|
+
))}
|
|
454
|
+
</div>
|
|
455
|
+
|
|
456
|
+
{/* Footer */}
|
|
457
|
+
<div style={{
|
|
458
|
+
padding: theme.spacing.sm,
|
|
459
|
+
backgroundColor: theme.colors.backgroundPanel,
|
|
460
|
+
borderTop: `1px solid ${theme.colors.border}`,
|
|
461
|
+
fontSize: theme.fontSize.xs,
|
|
462
|
+
color: theme.colors.textSecondary,
|
|
463
|
+
textAlign: 'center'
|
|
464
|
+
}}>
|
|
465
|
+
💡 Drag outputs to parameter fields
|
|
466
|
+
</div>
|
|
467
|
+
</div>
|
|
468
|
+
);
|
|
469
|
+
};
|
|
470
|
+
|
|
471
|
+
export default OutputPanel;
|