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,256 @@
|
|
|
1
|
+
// Base Chat Model Factory - Standardized node definition generator
|
|
2
|
+
import {
|
|
3
|
+
INodeTypeDescription,
|
|
4
|
+
NodeConnectionType,
|
|
5
|
+
INodeProperties
|
|
6
|
+
} from '../types/INodeProperties';
|
|
7
|
+
|
|
8
|
+
// ============================================================================
|
|
9
|
+
// BASE CHAT MODEL CONFIGURATION INTERFACE
|
|
10
|
+
// ============================================================================
|
|
11
|
+
|
|
12
|
+
export interface ChatModelConfig {
|
|
13
|
+
providerId: string;
|
|
14
|
+
displayName: string;
|
|
15
|
+
icon: string;
|
|
16
|
+
color: string;
|
|
17
|
+
description: string;
|
|
18
|
+
nodeName?: string;
|
|
19
|
+
models: Array<{
|
|
20
|
+
name: string;
|
|
21
|
+
value: string;
|
|
22
|
+
maxTokens?: number;
|
|
23
|
+
}>;
|
|
24
|
+
parameters: INodeProperties[];
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// ============================================================================
|
|
28
|
+
// BASE CHAT MODEL FACTORY FUNCTION
|
|
29
|
+
// ============================================================================
|
|
30
|
+
|
|
31
|
+
export function createBaseChatModel(config: ChatModelConfig): INodeTypeDescription {
|
|
32
|
+
return {
|
|
33
|
+
displayName: `${config.displayName} Chat Model`,
|
|
34
|
+
name: config.nodeName || `${config.providerId}ChatModel`,
|
|
35
|
+
icon: config.icon,
|
|
36
|
+
group: ['model'],
|
|
37
|
+
version: 1,
|
|
38
|
+
subtitle: '={{$parameter["model"]}}',
|
|
39
|
+
description: config.description,
|
|
40
|
+
defaults: {
|
|
41
|
+
name: `${config.displayName} Chat Model`,
|
|
42
|
+
color: config.color
|
|
43
|
+
},
|
|
44
|
+
inputs: [{
|
|
45
|
+
name: 'prompt',
|
|
46
|
+
displayName: 'Prompt',
|
|
47
|
+
type: 'string' as NodeConnectionType,
|
|
48
|
+
description: 'Input prompt or message for the AI model',
|
|
49
|
+
required: false
|
|
50
|
+
}],
|
|
51
|
+
outputs: [{
|
|
52
|
+
name: 'model',
|
|
53
|
+
displayName: 'Model',
|
|
54
|
+
type: 'ai' as NodeConnectionType,
|
|
55
|
+
description: `${config.displayName} configuration for AI agents`,
|
|
56
|
+
dataStructure: {
|
|
57
|
+
properties: {
|
|
58
|
+
provider: {
|
|
59
|
+
type: 'string',
|
|
60
|
+
description: `Model provider (${config.providerId})`,
|
|
61
|
+
required: true
|
|
62
|
+
},
|
|
63
|
+
model: {
|
|
64
|
+
type: 'string',
|
|
65
|
+
description: 'Model name',
|
|
66
|
+
required: true
|
|
67
|
+
},
|
|
68
|
+
apiKey: {
|
|
69
|
+
type: 'string',
|
|
70
|
+
description: `${config.displayName} API key`,
|
|
71
|
+
required: true
|
|
72
|
+
},
|
|
73
|
+
temperature: {
|
|
74
|
+
type: 'number',
|
|
75
|
+
description: 'Sampling temperature'
|
|
76
|
+
},
|
|
77
|
+
maxTokens: {
|
|
78
|
+
type: 'number',
|
|
79
|
+
description: 'Maximum response tokens'
|
|
80
|
+
},
|
|
81
|
+
topP: {
|
|
82
|
+
type: 'number',
|
|
83
|
+
description: 'Top-p sampling parameter'
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}],
|
|
88
|
+
properties: [
|
|
89
|
+
{
|
|
90
|
+
displayName: 'Model',
|
|
91
|
+
name: 'model',
|
|
92
|
+
type: 'string',
|
|
93
|
+
default: '',
|
|
94
|
+
required: true,
|
|
95
|
+
placeholder: `Select a ${config.displayName} model...`,
|
|
96
|
+
description: `${config.displayName} model to use (configure API key in Credentials)`,
|
|
97
|
+
typeOptions: {
|
|
98
|
+
dynamicOptions: true
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
displayName: 'Prompt',
|
|
103
|
+
name: 'prompt',
|
|
104
|
+
type: 'string',
|
|
105
|
+
default: '{{ $json.message }}',
|
|
106
|
+
required: true,
|
|
107
|
+
typeOptions: {
|
|
108
|
+
rows: 4
|
|
109
|
+
},
|
|
110
|
+
description: 'The message to send to the AI model',
|
|
111
|
+
placeholder: 'Enter your prompt or use template variables...'
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
displayName: 'Options',
|
|
115
|
+
name: 'options',
|
|
116
|
+
type: 'collection',
|
|
117
|
+
placeholder: 'Add Option',
|
|
118
|
+
default: {},
|
|
119
|
+
options: [
|
|
120
|
+
{
|
|
121
|
+
displayName: 'System Message',
|
|
122
|
+
name: 'systemMessage',
|
|
123
|
+
type: 'string',
|
|
124
|
+
default: '',
|
|
125
|
+
typeOptions: {
|
|
126
|
+
rows: 3
|
|
127
|
+
},
|
|
128
|
+
description: 'System message to define AI behavior and personality'
|
|
129
|
+
},
|
|
130
|
+
...config.parameters
|
|
131
|
+
] as any
|
|
132
|
+
}
|
|
133
|
+
]
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// ============================================================================
|
|
138
|
+
// STANDARD PARAMETER SETS
|
|
139
|
+
// ============================================================================
|
|
140
|
+
|
|
141
|
+
export const STANDARD_PARAMETERS = {
|
|
142
|
+
temperature: {
|
|
143
|
+
displayName: 'Temperature',
|
|
144
|
+
name: 'temperature',
|
|
145
|
+
type: 'number' as const,
|
|
146
|
+
default: 0.7,
|
|
147
|
+
typeOptions: { minValue: 0, maxValue: 2, numberStepSize: 0.1 },
|
|
148
|
+
description: 'Controls randomness in responses'
|
|
149
|
+
},
|
|
150
|
+
|
|
151
|
+
maxTokens: {
|
|
152
|
+
displayName: 'Maximum Tokens',
|
|
153
|
+
name: 'maxTokens',
|
|
154
|
+
type: 'number' as const,
|
|
155
|
+
default: 1000,
|
|
156
|
+
typeOptions: { minValue: 1, maxValue: 8192 },
|
|
157
|
+
description: 'Maximum number of tokens to generate'
|
|
158
|
+
},
|
|
159
|
+
|
|
160
|
+
topP: {
|
|
161
|
+
displayName: 'Top P',
|
|
162
|
+
name: 'topP',
|
|
163
|
+
type: 'number' as const,
|
|
164
|
+
default: 1,
|
|
165
|
+
typeOptions: { minValue: 0, maxValue: 1, numberStepSize: 0.1 },
|
|
166
|
+
description: 'Controls diversity via nucleus sampling'
|
|
167
|
+
},
|
|
168
|
+
|
|
169
|
+
topK: {
|
|
170
|
+
displayName: 'Top K',
|
|
171
|
+
name: 'topK',
|
|
172
|
+
type: 'number' as const,
|
|
173
|
+
default: 40,
|
|
174
|
+
typeOptions: { minValue: 1, maxValue: 100 },
|
|
175
|
+
description: 'Limits token selection to top K candidates'
|
|
176
|
+
},
|
|
177
|
+
|
|
178
|
+
frequencyPenalty: {
|
|
179
|
+
displayName: 'Frequency Penalty',
|
|
180
|
+
name: 'frequencyPenalty',
|
|
181
|
+
type: 'number' as const,
|
|
182
|
+
default: 0,
|
|
183
|
+
typeOptions: { minValue: -2, maxValue: 2, numberStepSize: 0.1 },
|
|
184
|
+
description: 'Penalty for frequency of token usage'
|
|
185
|
+
},
|
|
186
|
+
|
|
187
|
+
presencePenalty: {
|
|
188
|
+
displayName: 'Presence Penalty',
|
|
189
|
+
name: 'presencePenalty',
|
|
190
|
+
type: 'number' as const,
|
|
191
|
+
default: 0,
|
|
192
|
+
typeOptions: { minValue: -2, maxValue: 2, numberStepSize: 0.1 },
|
|
193
|
+
description: 'Penalty for presence of tokens'
|
|
194
|
+
},
|
|
195
|
+
|
|
196
|
+
// Thinking/Reasoning parameters
|
|
197
|
+
thinkingEnabled: {
|
|
198
|
+
displayName: 'Thinking/Reasoning Mode',
|
|
199
|
+
name: 'thinkingEnabled',
|
|
200
|
+
type: 'boolean' as const,
|
|
201
|
+
default: false,
|
|
202
|
+
description: 'Enable extended thinking for supported models'
|
|
203
|
+
},
|
|
204
|
+
|
|
205
|
+
thinkingBudget: {
|
|
206
|
+
displayName: 'Thinking Budget (Tokens)',
|
|
207
|
+
name: 'thinkingBudget',
|
|
208
|
+
type: 'number' as const,
|
|
209
|
+
default: 2048,
|
|
210
|
+
typeOptions: { minValue: 1024, maxValue: 16000 },
|
|
211
|
+
description: 'Maximum tokens for thinking (Claude, Gemini 2.5)',
|
|
212
|
+
displayOptions: { show: { thinkingEnabled: [true] } }
|
|
213
|
+
},
|
|
214
|
+
|
|
215
|
+
reasoningEffort: {
|
|
216
|
+
displayName: 'Reasoning Effort',
|
|
217
|
+
name: 'reasoningEffort',
|
|
218
|
+
type: 'options' as const,
|
|
219
|
+
options: [
|
|
220
|
+
{ name: 'Minimal', value: 'minimal' },
|
|
221
|
+
{ name: 'Low', value: 'low' },
|
|
222
|
+
{ name: 'Medium', value: 'medium' },
|
|
223
|
+
{ name: 'High', value: 'high' }
|
|
224
|
+
],
|
|
225
|
+
default: 'medium',
|
|
226
|
+
description: 'Reasoning effort level (OpenAI o-series)',
|
|
227
|
+
displayOptions: { show: { thinkingEnabled: [true] } }
|
|
228
|
+
},
|
|
229
|
+
|
|
230
|
+
thinkingLevel: {
|
|
231
|
+
displayName: 'Thinking Level',
|
|
232
|
+
name: 'thinkingLevel',
|
|
233
|
+
type: 'options' as const,
|
|
234
|
+
options: [
|
|
235
|
+
{ name: 'Low', value: 'low' },
|
|
236
|
+
{ name: 'Medium', value: 'medium' },
|
|
237
|
+
{ name: 'High', value: 'high' }
|
|
238
|
+
],
|
|
239
|
+
default: 'medium',
|
|
240
|
+
description: 'Thinking depth (Gemini 3+)',
|
|
241
|
+
displayOptions: { show: { thinkingEnabled: [true] } }
|
|
242
|
+
},
|
|
243
|
+
|
|
244
|
+
reasoningFormat: {
|
|
245
|
+
displayName: 'Reasoning Format',
|
|
246
|
+
name: 'reasoningFormat',
|
|
247
|
+
type: 'options' as const,
|
|
248
|
+
options: [
|
|
249
|
+
{ name: 'Parsed (show reasoning)', value: 'parsed' },
|
|
250
|
+
{ name: 'Hidden (final answer only)', value: 'hidden' }
|
|
251
|
+
],
|
|
252
|
+
default: 'parsed',
|
|
253
|
+
description: 'How to return reasoning content (Groq)',
|
|
254
|
+
displayOptions: { show: { thinkingEnabled: [true] } }
|
|
255
|
+
}
|
|
256
|
+
};
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useAndroidOperations Hook - WebSocket-based Android device operations
|
|
3
|
+
*
|
|
4
|
+
* Provides Android device management and service execution via WebSocket.
|
|
5
|
+
* This replaces REST-based Android API calls for real-time operations.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { useCallback, useState } from 'react';
|
|
9
|
+
import { useWebSocket } from '../contexts/WebSocketContext';
|
|
10
|
+
|
|
11
|
+
export interface AndroidDevice {
|
|
12
|
+
id: string;
|
|
13
|
+
model?: string;
|
|
14
|
+
state?: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface AndroidActionResult {
|
|
18
|
+
success: boolean;
|
|
19
|
+
result?: any;
|
|
20
|
+
error?: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface UseAndroidOperationsResult {
|
|
24
|
+
// Get list of connected devices
|
|
25
|
+
getDevices: () => Promise<AndroidDevice[]>;
|
|
26
|
+
|
|
27
|
+
// Setup Android device connection
|
|
28
|
+
setupDevice: (
|
|
29
|
+
connectionType: 'local' | 'remote',
|
|
30
|
+
deviceId?: string,
|
|
31
|
+
websocketUrl?: string,
|
|
32
|
+
port?: number
|
|
33
|
+
) => Promise<AndroidActionResult>;
|
|
34
|
+
|
|
35
|
+
// Execute Android service action
|
|
36
|
+
executeAction: (
|
|
37
|
+
serviceId: string,
|
|
38
|
+
action: string,
|
|
39
|
+
parameters: Record<string, any>,
|
|
40
|
+
deviceId?: string
|
|
41
|
+
) => Promise<AndroidActionResult>;
|
|
42
|
+
|
|
43
|
+
// State
|
|
44
|
+
isExecuting: boolean;
|
|
45
|
+
lastError: string | null;
|
|
46
|
+
isConnected: boolean;
|
|
47
|
+
|
|
48
|
+
// Android status from WebSocket
|
|
49
|
+
androidStatus: {
|
|
50
|
+
connected: boolean;
|
|
51
|
+
device_id: string | null;
|
|
52
|
+
connected_devices: string[];
|
|
53
|
+
connection_type: string | null;
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export const useAndroidOperations = (): UseAndroidOperationsResult => {
|
|
58
|
+
const {
|
|
59
|
+
getAndroidDevices: wsGetDevices,
|
|
60
|
+
setupAndroidDevice: wsSetupDevice,
|
|
61
|
+
executeAndroidAction: wsExecuteAction,
|
|
62
|
+
androidStatus,
|
|
63
|
+
isConnected
|
|
64
|
+
} = useWebSocket();
|
|
65
|
+
|
|
66
|
+
const [isExecuting, setIsExecuting] = useState(false);
|
|
67
|
+
const [lastError, setLastError] = useState<string | null>(null);
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Get list of connected Android devices
|
|
71
|
+
*/
|
|
72
|
+
const getDevices = useCallback(async (): Promise<AndroidDevice[]> => {
|
|
73
|
+
try {
|
|
74
|
+
const devices = await wsGetDevices();
|
|
75
|
+
return devices.map((id: string) => ({ id }));
|
|
76
|
+
} catch (error: any) {
|
|
77
|
+
console.warn('Failed to get Android devices:', error);
|
|
78
|
+
setLastError(error.message);
|
|
79
|
+
return [];
|
|
80
|
+
}
|
|
81
|
+
}, [wsGetDevices]);
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Setup Android device connection
|
|
85
|
+
*/
|
|
86
|
+
const setupDevice = useCallback(async (
|
|
87
|
+
connectionType: 'local' | 'remote',
|
|
88
|
+
deviceId?: string,
|
|
89
|
+
websocketUrl?: string,
|
|
90
|
+
_port: number = 8888 // Port passed to backend via wsSetupDevice
|
|
91
|
+
): Promise<AndroidActionResult> => {
|
|
92
|
+
setIsExecuting(true);
|
|
93
|
+
setLastError(null);
|
|
94
|
+
|
|
95
|
+
try {
|
|
96
|
+
const result = await wsSetupDevice(connectionType, deviceId, websocketUrl);
|
|
97
|
+
|
|
98
|
+
if (!result.success) {
|
|
99
|
+
setLastError(result.error || 'Setup failed');
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return {
|
|
103
|
+
success: result.success,
|
|
104
|
+
result: result.result,
|
|
105
|
+
error: result.error
|
|
106
|
+
};
|
|
107
|
+
} catch (error: any) {
|
|
108
|
+
const errorMsg = error.message || 'Device setup failed';
|
|
109
|
+
setLastError(errorMsg);
|
|
110
|
+
return {
|
|
111
|
+
success: false,
|
|
112
|
+
error: errorMsg
|
|
113
|
+
};
|
|
114
|
+
} finally {
|
|
115
|
+
setIsExecuting(false);
|
|
116
|
+
}
|
|
117
|
+
}, [wsSetupDevice]);
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Execute Android service action
|
|
121
|
+
*/
|
|
122
|
+
const executeAction = useCallback(async (
|
|
123
|
+
serviceId: string,
|
|
124
|
+
action: string,
|
|
125
|
+
parameters: Record<string, any>,
|
|
126
|
+
deviceId?: string
|
|
127
|
+
): Promise<AndroidActionResult> => {
|
|
128
|
+
setIsExecuting(true);
|
|
129
|
+
setLastError(null);
|
|
130
|
+
|
|
131
|
+
try {
|
|
132
|
+
const result = await wsExecuteAction(serviceId, action, parameters, deviceId);
|
|
133
|
+
|
|
134
|
+
if (!result.success) {
|
|
135
|
+
setLastError(result.error || 'Action failed');
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
return {
|
|
139
|
+
success: result.success,
|
|
140
|
+
result: result.result,
|
|
141
|
+
error: result.error
|
|
142
|
+
};
|
|
143
|
+
} catch (error: any) {
|
|
144
|
+
const errorMsg = error.message || 'Action execution failed';
|
|
145
|
+
setLastError(errorMsg);
|
|
146
|
+
return {
|
|
147
|
+
success: false,
|
|
148
|
+
error: errorMsg
|
|
149
|
+
};
|
|
150
|
+
} finally {
|
|
151
|
+
setIsExecuting(false);
|
|
152
|
+
}
|
|
153
|
+
}, [wsExecuteAction]);
|
|
154
|
+
|
|
155
|
+
return {
|
|
156
|
+
getDevices,
|
|
157
|
+
setupDevice,
|
|
158
|
+
executeAction,
|
|
159
|
+
isExecuting,
|
|
160
|
+
lastError,
|
|
161
|
+
isConnected,
|
|
162
|
+
androidStatus
|
|
163
|
+
};
|
|
164
|
+
};
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { useState, useEffect, useCallback } from 'react';
|
|
2
|
+
import { notification } from 'antd';
|
|
3
|
+
import { useApiKeys } from './useApiKeys';
|
|
4
|
+
|
|
5
|
+
export type ValidationStatus = 'idle' | 'validating' | 'valid' | 'invalid';
|
|
6
|
+
|
|
7
|
+
interface UseApiKeyValidationProps {
|
|
8
|
+
provider?: string;
|
|
9
|
+
onSuccess?: (models: string[]) => void;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const useApiKeyValidation = ({ provider, onSuccess }: UseApiKeyValidationProps) => {
|
|
13
|
+
const [status, setStatus] = useState<ValidationStatus>('idle');
|
|
14
|
+
const [hasStoredKeyState, setHasStoredKeyState] = useState(false);
|
|
15
|
+
|
|
16
|
+
// Use WebSocket-based API key management
|
|
17
|
+
const {
|
|
18
|
+
validateApiKey: wsValidateApiKey,
|
|
19
|
+
getStoredApiKey: wsGetStoredApiKey,
|
|
20
|
+
hasStoredKey: wsHasStoredKey,
|
|
21
|
+
removeApiKey: wsRemoveApiKey,
|
|
22
|
+
getStoredModels: wsGetStoredModels
|
|
23
|
+
} = useApiKeys();
|
|
24
|
+
|
|
25
|
+
// Check for existing key on mount
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
if (!provider) return;
|
|
28
|
+
|
|
29
|
+
const checkStoredKey = async () => {
|
|
30
|
+
try {
|
|
31
|
+
const hasKey = await wsHasStoredKey(provider);
|
|
32
|
+
if (hasKey) {
|
|
33
|
+
setHasStoredKeyState(true);
|
|
34
|
+
setStatus('valid');
|
|
35
|
+
|
|
36
|
+
// Try to get models if there's a stored key
|
|
37
|
+
const models = await wsGetStoredModels(provider);
|
|
38
|
+
if (models?.length && onSuccess) {
|
|
39
|
+
onSuccess(models);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
} catch (error) {
|
|
43
|
+
console.warn('Error checking stored key:', error);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
checkStoredKey();
|
|
48
|
+
}, [provider, onSuccess, wsHasStoredKey, wsGetStoredModels]);
|
|
49
|
+
|
|
50
|
+
const validate = useCallback(async (apiKey: string) => {
|
|
51
|
+
if (!provider || !apiKey.trim()) {
|
|
52
|
+
notification.error({ message: 'Please enter an API key' });
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
setStatus('validating');
|
|
57
|
+
|
|
58
|
+
try {
|
|
59
|
+
const result = await wsValidateApiKey(provider, apiKey.trim());
|
|
60
|
+
|
|
61
|
+
if (result.isValid) {
|
|
62
|
+
setStatus('valid');
|
|
63
|
+
setHasStoredKeyState(true);
|
|
64
|
+
notification.success({ message: 'API key validated successfully!' });
|
|
65
|
+
|
|
66
|
+
if (result.models?.length && onSuccess) {
|
|
67
|
+
onSuccess(result.models);
|
|
68
|
+
}
|
|
69
|
+
} else {
|
|
70
|
+
setStatus('invalid');
|
|
71
|
+
notification.error({ message: result.error || 'Invalid API key' });
|
|
72
|
+
}
|
|
73
|
+
} catch (error: any) {
|
|
74
|
+
setStatus('invalid');
|
|
75
|
+
notification.error({ message: error.message || 'Validation failed' });
|
|
76
|
+
}
|
|
77
|
+
}, [provider, onSuccess, wsValidateApiKey]);
|
|
78
|
+
|
|
79
|
+
const clear = useCallback(async () => {
|
|
80
|
+
if (!provider) return;
|
|
81
|
+
|
|
82
|
+
try {
|
|
83
|
+
await wsRemoveApiKey(provider);
|
|
84
|
+
setHasStoredKeyState(false);
|
|
85
|
+
setStatus('idle');
|
|
86
|
+
notification.success({ message: 'API key cleared' });
|
|
87
|
+
} catch (error) {
|
|
88
|
+
notification.error({ message: 'Failed to clear API key' });
|
|
89
|
+
}
|
|
90
|
+
}, [provider, wsRemoveApiKey]);
|
|
91
|
+
|
|
92
|
+
const getStoredKey = useCallback(async () => {
|
|
93
|
+
if (!provider) return null;
|
|
94
|
+
return await wsGetStoredApiKey(provider);
|
|
95
|
+
}, [provider, wsGetStoredApiKey]);
|
|
96
|
+
|
|
97
|
+
return {
|
|
98
|
+
status,
|
|
99
|
+
hasStoredKey: hasStoredKeyState,
|
|
100
|
+
validate,
|
|
101
|
+
clear,
|
|
102
|
+
getStoredKey,
|
|
103
|
+
isValidating: status === 'validating',
|
|
104
|
+
isValid: status === 'valid',
|
|
105
|
+
isInvalid: status === 'invalid'
|
|
106
|
+
};
|
|
107
|
+
};
|