@johpaz/hive 1.7.2 → 1.7.3
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/README.md +178 -36
- package/dist/hive.js +315124 -0
- package/package.json +11 -3
- package/packages/core/src/index.ts +0 -1
- package/.dockerignore +0 -9
- package/CONTRIBUTING.md +0 -44
- package/Dockerfile +0 -67
- package/docker-compose.yml +0 -19
- package/packages/cli/package.json +0 -28
- package/packages/cli/src/commands/agent-run.ts +0 -168
- package/packages/cli/src/commands/agents.ts +0 -398
- package/packages/cli/src/commands/chat.ts +0 -142
- package/packages/cli/src/commands/config.ts +0 -50
- package/packages/cli/src/commands/cron.ts +0 -161
- package/packages/cli/src/commands/dev.ts +0 -95
- package/packages/cli/src/commands/doctor.ts +0 -133
- package/packages/cli/src/commands/gateway.ts +0 -422
- package/packages/cli/src/commands/logs.ts +0 -57
- package/packages/cli/src/commands/mcp.ts +0 -175
- package/packages/cli/src/commands/message.ts +0 -77
- package/packages/cli/src/commands/onboard.ts +0 -1696
- package/packages/cli/src/commands/security.ts +0 -144
- package/packages/cli/src/commands/service.ts +0 -50
- package/packages/cli/src/commands/sessions.ts +0 -116
- package/packages/cli/src/commands/skills.ts +0 -187
- package/packages/cli/src/commands/update.ts +0 -25
- package/packages/cli/src/index.ts +0 -190
- package/packages/cli/src/utils/token.ts +0 -6
- package/packages/code-bridge/README.md +0 -78
- package/packages/code-bridge/package.json +0 -18
- package/packages/code-bridge/src/index.ts +0 -95
- package/packages/code-bridge/src/process-manager.ts +0 -212
- package/packages/code-bridge/src/schemas.ts +0 -133
- package/packages/core/package.json +0 -55
- package/packages/core/src/agent/agent-loop.ts +0 -520
- package/packages/core/src/agent/compaction.ts +0 -183
- package/packages/core/src/agent/context-compiler.ts +0 -544
- package/packages/core/src/agent/context-guard.ts +0 -91
- package/packages/core/src/agent/conversation-store.ts +0 -193
- package/packages/core/src/agent/curator.ts +0 -158
- package/packages/core/src/agent/hooks.ts +0 -166
- package/packages/core/src/agent/llm-client.ts +0 -503
- package/packages/core/src/agent/native-tools.ts +0 -31
- package/packages/core/src/agent/playbook-selector.ts +0 -143
- package/packages/core/src/agent/prompt-builder.ts +0 -167
- package/packages/core/src/agent/providers/index.ts +0 -186
- package/packages/core/src/agent/providers.ts +0 -1
- package/packages/core/src/agent/reflector.ts +0 -200
- package/packages/core/src/agent/service.ts +0 -266
- package/packages/core/src/agent/skill-selector.ts +0 -413
- package/packages/core/src/agent/stuck-loop.ts +0 -133
- package/packages/core/src/agent/tool-selector.ts +0 -623
- package/packages/core/src/agent/tracer.ts +0 -102
- package/packages/core/src/canvas/canvas-manager.ts +0 -319
- package/packages/core/src/canvas/canvas-tools.ts +0 -420
- package/packages/core/src/canvas/emitter.ts +0 -119
- package/packages/core/src/canvas/index.ts +0 -2
- package/packages/core/src/channels/base.ts +0 -140
- package/packages/core/src/channels/discord.ts +0 -260
- package/packages/core/src/channels/index.ts +0 -7
- package/packages/core/src/channels/manager.ts +0 -383
- package/packages/core/src/channels/slack.ts +0 -287
- package/packages/core/src/channels/telegram.ts +0 -552
- package/packages/core/src/channels/webchat.ts +0 -139
- package/packages/core/src/channels/whatsapp.ts +0 -375
- package/packages/core/src/config/index.ts +0 -12
- package/packages/core/src/config/loader.ts +0 -529
- package/packages/core/src/events/agent-bus.ts +0 -460
- package/packages/core/src/events/event-bus.ts +0 -169
- package/packages/core/src/gateway/helpers/cors.ts +0 -32
- package/packages/core/src/gateway/helpers/index.ts +0 -4
- package/packages/core/src/gateway/helpers/narration.ts +0 -60
- package/packages/core/src/gateway/helpers/path.ts +0 -13
- package/packages/core/src/gateway/helpers/redact.ts +0 -61
- package/packages/core/src/gateway/index.ts +0 -5
- package/packages/core/src/gateway/initializer.ts +0 -332
- package/packages/core/src/gateway/lane-queue.ts +0 -169
- package/packages/core/src/gateway/resolver.ts +0 -108
- package/packages/core/src/gateway/router.ts +0 -124
- package/packages/core/src/gateway/routes/agents.ts +0 -187
- package/packages/core/src/gateway/routes/channels.ts +0 -203
- package/packages/core/src/gateway/routes/chat.ts +0 -241
- package/packages/core/src/gateway/routes/config.ts +0 -12
- package/packages/core/src/gateway/routes/cron.ts +0 -42
- package/packages/core/src/gateway/routes/ethics.ts +0 -46
- package/packages/core/src/gateway/routes/mcp.ts +0 -346
- package/packages/core/src/gateway/routes/models.ts +0 -93
- package/packages/core/src/gateway/routes/projects.ts +0 -179
- package/packages/core/src/gateway/routes/providers.ts +0 -192
- package/packages/core/src/gateway/routes/setup.ts +0 -267
- package/packages/core/src/gateway/routes/skills.ts +0 -70
- package/packages/core/src/gateway/routes/system.ts +0 -165
- package/packages/core/src/gateway/routes/tasks.ts +0 -44
- package/packages/core/src/gateway/routes/tools.ts +0 -35
- package/packages/core/src/gateway/routes/users.ts +0 -118
- package/packages/core/src/gateway/routes/voice.ts +0 -73
- package/packages/core/src/gateway/routes/workspace.ts +0 -281
- package/packages/core/src/gateway/server.ts +0 -1978
- package/packages/core/src/gateway/session.ts +0 -95
- package/packages/core/src/gateway/slash-commands.ts +0 -193
- package/packages/core/src/heartbeat/index.ts +0 -157
- package/packages/core/src/mcp/hot-reload.ts +0 -213
- package/packages/core/src/mcp/singleton.ts +0 -21
- package/packages/core/src/memory/index.ts +0 -1
- package/packages/core/src/memory/notes.ts +0 -68
- package/packages/core/src/plugins/api.ts +0 -128
- package/packages/core/src/plugins/index.ts +0 -2
- package/packages/core/src/plugins/loader.ts +0 -365
- package/packages/core/src/resilience/circuit-breaker.ts +0 -225
- package/packages/core/src/security/google-chat.ts +0 -269
- package/packages/core/src/security/index.ts +0 -192
- package/packages/core/src/security/pairing.ts +0 -250
- package/packages/core/src/security/rate-limit.ts +0 -270
- package/packages/core/src/security/signal.ts +0 -321
- package/packages/core/src/state/store.ts +0 -312
- package/packages/core/src/storage/crypto.ts +0 -101
- package/packages/core/src/storage/onboarding.ts +0 -1609
- package/packages/core/src/storage/schema.ts +0 -567
- package/packages/core/src/storage/seed.ts +0 -608
- package/packages/core/src/storage/sqlite.ts +0 -363
- package/packages/core/src/storage/usage.ts +0 -270
- package/packages/core/src/tools/agents/index.ts +0 -607
- package/packages/core/src/tools/bridge-events.ts +0 -26
- package/packages/core/src/tools/canvas/index.ts +0 -281
- package/packages/core/src/tools/cli/index.ts +0 -142
- package/packages/core/src/tools/codebridge/index.ts +0 -179
- package/packages/core/src/tools/core/index.ts +0 -257
- package/packages/core/src/tools/cron/index.ts +0 -373
- package/packages/core/src/tools/filesystem/fs-delete.ts +0 -78
- package/packages/core/src/tools/filesystem/fs-edit.ts +0 -106
- package/packages/core/src/tools/filesystem/fs-exists.ts +0 -63
- package/packages/core/src/tools/filesystem/fs-glob.ts +0 -108
- package/packages/core/src/tools/filesystem/fs-list.ts +0 -129
- package/packages/core/src/tools/filesystem/fs-read.ts +0 -72
- package/packages/core/src/tools/filesystem/fs-write.ts +0 -67
- package/packages/core/src/tools/filesystem/index.ts +0 -34
- package/packages/core/src/tools/filesystem/workspace-guard.ts +0 -62
- package/packages/core/src/tools/index.ts +0 -197
- package/packages/core/src/tools/projects/index.ts +0 -37
- package/packages/core/src/tools/projects/project-create.ts +0 -94
- package/packages/core/src/tools/projects/project-done.ts +0 -66
- package/packages/core/src/tools/projects/project-fail.ts +0 -66
- package/packages/core/src/tools/projects/project-list.ts +0 -96
- package/packages/core/src/tools/projects/project-update.ts +0 -72
- package/packages/core/src/tools/projects/task-create.ts +0 -68
- package/packages/core/src/tools/projects/task-evaluate.ts +0 -93
- package/packages/core/src/tools/projects/task-update.ts +0 -93
- package/packages/core/src/tools/search-knowledge/search-knowledge.ts +0 -155
- package/packages/core/src/tools/types.ts +0 -39
- package/packages/core/src/tools/voice/index.ts +0 -104
- package/packages/core/src/tools/web/browser-click.ts +0 -54
- package/packages/core/src/tools/web/browser-navigate.ts +0 -84
- package/packages/core/src/tools/web/browser-screenshot.ts +0 -54
- package/packages/core/src/tools/web/browser-type.ts +0 -60
- package/packages/core/src/tools/web/index.ts +0 -31
- package/packages/core/src/tools/web/web-fetch.ts +0 -78
- package/packages/core/src/tools/web/web-search.ts +0 -123
- package/packages/core/src/utils/benchmark.ts +0 -80
- package/packages/core/src/utils/crypto.ts +0 -73
- package/packages/core/src/utils/date.ts +0 -42
- package/packages/core/src/utils/index.ts +0 -5
- package/packages/core/src/utils/logger.ts +0 -389
- package/packages/core/src/utils/retry.ts +0 -70
- package/packages/core/src/utils/toon.ts +0 -356
- package/packages/core/src/voice/index.ts +0 -583
- package/packages/hive-ui/README.md +0 -52
- package/packages/hive-ui/components.json +0 -20
- package/packages/hive-ui/index.html +0 -30
- package/packages/hive-ui/package.json +0 -90
- package/packages/hive-ui/public/favicon.ico +0 -0
- package/packages/hive-ui/public/placeholder.svg +0 -1
- package/packages/hive-ui/src/App.tsx +0 -115
- package/packages/hive-ui/src/components/CronJobsPanel.tsx +0 -200
- package/packages/hive-ui/src/components/NavLink.tsx +0 -34
- package/packages/hive-ui/src/components/NotesPanel.tsx +0 -79
- package/packages/hive-ui/src/components/SystemMonitor.tsx +0 -270
- package/packages/hive-ui/src/components/UsageStatsPanel.tsx +0 -334
- package/packages/hive-ui/src/components/WelcomeDialog.tsx +0 -279
- package/packages/hive-ui/src/components/ui/accordion.tsx +0 -52
- package/packages/hive-ui/src/components/ui/alert-dialog.tsx +0 -104
- package/packages/hive-ui/src/components/ui/alert.tsx +0 -45
- package/packages/hive-ui/src/components/ui/aspect-ratio.tsx +0 -5
- package/packages/hive-ui/src/components/ui/avatar.tsx +0 -38
- package/packages/hive-ui/src/components/ui/badge.tsx +0 -29
- package/packages/hive-ui/src/components/ui/bee-loader.tsx +0 -68
- package/packages/hive-ui/src/components/ui/breadcrumb.tsx +0 -90
- package/packages/hive-ui/src/components/ui/button.tsx +0 -47
- package/packages/hive-ui/src/components/ui/calendar.tsx +0 -54
- package/packages/hive-ui/src/components/ui/card.tsx +0 -45
- package/packages/hive-ui/src/components/ui/carousel.tsx +0 -224
- package/packages/hive-ui/src/components/ui/chart.tsx +0 -303
- package/packages/hive-ui/src/components/ui/checkbox.tsx +0 -26
- package/packages/hive-ui/src/components/ui/collapsible.tsx +0 -9
- package/packages/hive-ui/src/components/ui/command.tsx +0 -133
- package/packages/hive-ui/src/components/ui/context-menu.tsx +0 -178
- package/packages/hive-ui/src/components/ui/dialog.tsx +0 -95
- package/packages/hive-ui/src/components/ui/drawer.tsx +0 -87
- package/packages/hive-ui/src/components/ui/dropdown-menu.tsx +0 -179
- package/packages/hive-ui/src/components/ui/form.tsx +0 -129
- package/packages/hive-ui/src/components/ui/hover-card.tsx +0 -27
- package/packages/hive-ui/src/components/ui/input-otp.tsx +0 -61
- package/packages/hive-ui/src/components/ui/input.tsx +0 -22
- package/packages/hive-ui/src/components/ui/label.tsx +0 -17
- package/packages/hive-ui/src/components/ui/menubar.tsx +0 -207
- package/packages/hive-ui/src/components/ui/navigation-menu.tsx +0 -120
- package/packages/hive-ui/src/components/ui/pagination.tsx +0 -80
- package/packages/hive-ui/src/components/ui/popover.tsx +0 -29
- package/packages/hive-ui/src/components/ui/progress.tsx +0 -23
- package/packages/hive-ui/src/components/ui/radio-group.tsx +0 -36
- package/packages/hive-ui/src/components/ui/resizable.tsx +0 -37
- package/packages/hive-ui/src/components/ui/scroll-area.tsx +0 -38
- package/packages/hive-ui/src/components/ui/select.tsx +0 -143
- package/packages/hive-ui/src/components/ui/separator.tsx +0 -20
- package/packages/hive-ui/src/components/ui/sheet.tsx +0 -107
- package/packages/hive-ui/src/components/ui/sidebar.tsx +0 -636
- package/packages/hive-ui/src/components/ui/skeleton.tsx +0 -7
- package/packages/hive-ui/src/components/ui/slider.tsx +0 -23
- package/packages/hive-ui/src/components/ui/sonner.tsx +0 -27
- package/packages/hive-ui/src/components/ui/switch.tsx +0 -27
- package/packages/hive-ui/src/components/ui/table.tsx +0 -72
- package/packages/hive-ui/src/components/ui/tabs.tsx +0 -53
- package/packages/hive-ui/src/components/ui/textarea.tsx +0 -21
- package/packages/hive-ui/src/components/ui/toast.tsx +0 -111
- package/packages/hive-ui/src/components/ui/toaster.tsx +0 -24
- package/packages/hive-ui/src/components/ui/toggle-group.tsx +0 -49
- package/packages/hive-ui/src/components/ui/toggle.tsx +0 -37
- package/packages/hive-ui/src/components/ui/tooltip.tsx +0 -28
- package/packages/hive-ui/src/components/ui/use-toast.ts +0 -3
- package/packages/hive-ui/src/hooks/use-mobile.tsx +0 -19
- package/packages/hive-ui/src/hooks/use-toast.ts +0 -186
- package/packages/hive-ui/src/hooks/useAgentConfig.ts +0 -25
- package/packages/hive-ui/src/hooks/useAgents.ts +0 -38
- package/packages/hive-ui/src/hooks/useBridge.ts +0 -38
- package/packages/hive-ui/src/hooks/useCanvas.ts +0 -24
- package/packages/hive-ui/src/hooks/useChannels.ts +0 -2
- package/packages/hive-ui/src/hooks/useEthics.ts +0 -51
- package/packages/hive-ui/src/hooks/useProviders.ts +0 -14
- package/packages/hive-ui/src/hooks/useTheme.ts +0 -29
- package/packages/hive-ui/src/hooks/useUserConfig.ts +0 -17
- package/packages/hive-ui/src/hooks/useWebSocket.ts +0 -12
- package/packages/hive-ui/src/index.css +0 -620
- package/packages/hive-ui/src/lib/api.ts +0 -100
- package/packages/hive-ui/src/lib/constants.ts +0 -6
- package/packages/hive-ui/src/lib/models.ts +0 -64
- package/packages/hive-ui/src/lib/swal.ts +0 -30
- package/packages/hive-ui/src/lib/utils.ts +0 -6
- package/packages/hive-ui/src/lib/websocket.ts +0 -7
- package/packages/hive-ui/src/main.tsx +0 -5
- package/packages/hive-ui/src/modules/agent-config/details/AgentDetailsEditor.tsx +0 -524
- package/packages/hive-ui/src/modules/agent-config/ethics/EthicsConflictDetector.tsx +0 -18
- package/packages/hive-ui/src/modules/agent-config/ethics/EthicsEditor.tsx +0 -19
- package/packages/hive-ui/src/modules/agent-config/ethics/EthicsRulesList.tsx +0 -36
- package/packages/hive-ui/src/modules/agent-config/ethics/EthicsTemplateGallery.tsx +0 -361
- package/packages/hive-ui/src/modules/agent-config/ethics/index.ts +0 -4
- package/packages/hive-ui/src/modules/agent-config/index.ts +0 -6
- package/packages/hive-ui/src/modules/agent-config/mcp/MCPServerAdd.tsx +0 -322
- package/packages/hive-ui/src/modules/agent-config/mcp/MCPServerCard.tsx +0 -93
- package/packages/hive-ui/src/modules/agent-config/mcp/MCPServerConfig.tsx +0 -427
- package/packages/hive-ui/src/modules/agent-config/mcp/MCPServerList.tsx +0 -85
- package/packages/hive-ui/src/modules/agent-config/mcp/MCPToolExplorer.tsx +0 -79
- package/packages/hive-ui/src/modules/agent-config/mcp/index.ts +0 -5
- package/packages/hive-ui/src/modules/agent-config/shared/ConfigEditorLayout.tsx +0 -30
- package/packages/hive-ui/src/modules/agent-config/shared/ConfigExporter.tsx +0 -26
- package/packages/hive-ui/src/modules/agent-config/shared/ConfigImporter.tsx +0 -25
- package/packages/hive-ui/src/modules/agent-config/shared/DiffViewer.tsx +0 -31
- package/packages/hive-ui/src/modules/agent-config/shared/MarkdownEditor.tsx +0 -32
- package/packages/hive-ui/src/modules/agent-config/shared/SaveStatusIndicator.tsx +0 -23
- package/packages/hive-ui/src/modules/agent-config/shared/ValidationPanel.tsx +0 -36
- package/packages/hive-ui/src/modules/agent-config/shared/index.ts +0 -7
- package/packages/hive-ui/src/modules/agent-config/skills/SkillCard.tsx +0 -81
- package/packages/hive-ui/src/modules/agent-config/skills/SkillConfigEditor.tsx +0 -22
- package/packages/hive-ui/src/modules/agent-config/skills/SkillCreator.tsx +0 -60
- package/packages/hive-ui/src/modules/agent-config/skills/SkillInstaller.tsx +0 -23
- package/packages/hive-ui/src/modules/agent-config/skills/SkillList.tsx +0 -72
- package/packages/hive-ui/src/modules/agent-config/skills/SkillsTab.tsx +0 -202
- package/packages/hive-ui/src/modules/agent-config/skills/index.ts +0 -5
- package/packages/hive-ui/src/modules/agent-config/tools/ToolCard.tsx +0 -27
- package/packages/hive-ui/src/modules/agent-config/tools/ToolConfigPanel.tsx +0 -22
- package/packages/hive-ui/src/modules/agent-config/tools/ToolManager.tsx +0 -266
- package/packages/hive-ui/src/modules/agent-config/tools/ToolPermissions.tsx +0 -287
- package/packages/hive-ui/src/modules/agent-config/tools/ToolRegistry.tsx +0 -84
- package/packages/hive-ui/src/modules/agent-config/tools/ToolUsageStats.tsx +0 -52
- package/packages/hive-ui/src/modules/agent-config/tools/index.ts +0 -4
- package/packages/hive-ui/src/modules/agent-config/user/ActiveAgentsList.tsx +0 -109
- package/packages/hive-ui/src/modules/agent-config/user/GlobalConfigOverview.tsx +0 -119
- package/packages/hive-ui/src/modules/agent-config/user/UserMemoryManager.tsx +0 -54
- package/packages/hive-ui/src/modules/agent-config/user/UserPreferencesForm.tsx +0 -163
- package/packages/hive-ui/src/modules/agent-config/user/UserProfileEditor.tsx +0 -261
- package/packages/hive-ui/src/modules/agent-config/user/index.ts +0 -3
- package/packages/hive-ui/src/modules/agents/AgentActivityLog.tsx +0 -25
- package/packages/hive-ui/src/modules/agents/AgentCard.tsx +0 -305
- package/packages/hive-ui/src/modules/agents/AgentCreateForm.tsx +0 -446
- package/packages/hive-ui/src/modules/agents/AgentDetail.tsx +0 -28
- package/packages/hive-ui/src/modules/agents/AgentInternalCard.tsx +0 -162
- package/packages/hive-ui/src/modules/agents/AgentList.tsx +0 -29
- package/packages/hive-ui/src/modules/agents/AgentStatusBadge.tsx +0 -34
- package/packages/hive-ui/src/modules/agents/ModelSelector.tsx +0 -151
- package/packages/hive-ui/src/modules/bridge/BridgeLogViewer.tsx +0 -61
- package/packages/hive-ui/src/modules/bridge/BridgeProcessList.tsx +0 -77
- package/packages/hive-ui/src/modules/bridge/BridgeStatus.tsx +0 -23
- package/packages/hive-ui/src/modules/bridge/BridgeTerminal.tsx +0 -7
- package/packages/hive-ui/src/modules/canvas/CanvasButton.tsx +0 -3
- package/packages/hive-ui/src/modules/canvas/CanvasChart.tsx +0 -3
- package/packages/hive-ui/src/modules/canvas/CanvasComponentMap.tsx +0 -605
- package/packages/hive-ui/src/modules/canvas/CanvasContainer.tsx +0 -360
- package/packages/hive-ui/src/modules/canvas/CanvasForm.tsx +0 -3
- package/packages/hive-ui/src/modules/canvas/CanvasMarkdown.tsx +0 -3
- package/packages/hive-ui/src/modules/canvas/CanvasTable.tsx +0 -3
- package/packages/hive-ui/src/modules/canvas/ComponentRenderer.tsx +0 -30
- package/packages/hive-ui/src/modules/canvas/DynamicRenderer.tsx +0 -3
- package/packages/hive-ui/src/modules/channels/available/AvailableChannelsGrid.tsx +0 -89
- package/packages/hive-ui/src/modules/channels/available/ChannelAuthForm.tsx +0 -33
- package/packages/hive-ui/src/modules/channels/available/ChannelSetupWizard.tsx +0 -48
- package/packages/hive-ui/src/modules/channels/available/ChannelTestConnection.tsx +0 -37
- package/packages/hive-ui/src/modules/channels/available/ChannelTypeCard.tsx +0 -30
- package/packages/hive-ui/src/modules/channels/available/ChannelWebhookConfig.tsx +0 -30
- package/packages/hive-ui/src/modules/channels/available/index.ts +0 -6
- package/packages/hive-ui/src/modules/channels/connected/ChannelCard.tsx +0 -95
- package/packages/hive-ui/src/modules/channels/connected/ChannelConfigPanel.tsx +0 -260
- package/packages/hive-ui/src/modules/channels/connected/ChannelDisconnectButton.tsx +0 -21
- package/packages/hive-ui/src/modules/channels/connected/ChannelLogsViewer.tsx +0 -42
- package/packages/hive-ui/src/modules/channels/connected/ChannelQRCode.tsx +0 -32
- package/packages/hive-ui/src/modules/channels/connected/ChannelReconnectButton.tsx +0 -16
- package/packages/hive-ui/src/modules/channels/connected/ChannelStatusBadge.tsx +0 -26
- package/packages/hive-ui/src/modules/channels/connected/ConnectedChannelsList.tsx +0 -40
- package/packages/hive-ui/src/modules/channels/connected/index.ts +0 -8
- package/packages/hive-ui/src/modules/channels/shared/ChannelCard.tsx +0 -84
- package/packages/hive-ui/src/modules/channels/shared/ChannelConfigDialog.tsx +0 -279
- package/packages/hive-ui/src/modules/channels/shared/ChannelIcon.tsx +0 -40
- package/packages/hive-ui/src/modules/channels/shared/ChannelStats.tsx +0 -37
- package/packages/hive-ui/src/modules/channels/shared/ChannelTypeBadge.tsx +0 -23
- package/packages/hive-ui/src/modules/channels/shared/ConnectionHealthIndicator.tsx +0 -20
- package/packages/hive-ui/src/modules/channels/shared/MessagePreview.tsx +0 -19
- package/packages/hive-ui/src/modules/channels/shared/index.ts +0 -5
- package/packages/hive-ui/src/modules/chat/ChatContainer.tsx +0 -268
- package/packages/hive-ui/src/modules/chat/ChatHistory.tsx +0 -101
- package/packages/hive-ui/src/modules/chat/ChatInput.tsx +0 -108
- package/packages/hive-ui/src/modules/chat/ChatMessage.tsx +0 -137
- package/packages/hive-ui/src/modules/chat/ThinkingIndicator.tsx +0 -10
- package/packages/hive-ui/src/modules/layout/AppLayout.tsx +0 -45
- package/packages/hive-ui/src/modules/layout/ConnectionStatus.tsx +0 -19
- package/packages/hive-ui/src/modules/layout/Header.tsx +0 -20
- package/packages/hive-ui/src/modules/layout/HiveSidebar.tsx +0 -173
- package/packages/hive-ui/src/modules/layout/ThemeToggle.tsx +0 -18
- package/packages/hive-ui/src/modules/providers/ProviderCard.tsx +0 -319
- package/packages/hive-ui/src/modules/providers/ProviderConfigForm.tsx +0 -146
- package/packages/hive-ui/src/modules/providers/ProviderFailoverConfig.tsx +0 -110
- package/packages/hive-ui/src/modules/providers/ProviderList.tsx +0 -33
- package/packages/hive-ui/src/modules/providers/ProviderStatusIndicator.tsx +0 -23
- package/packages/hive-ui/src/modules/providers/configs/ProviderAPIKeyManager.tsx +0 -39
- package/packages/hive-ui/src/modules/providers/configs/ProviderEndpointConfig.tsx +0 -27
- package/packages/hive-ui/src/modules/providers/configs/ProviderRateLimits.tsx +0 -37
- package/packages/hive-ui/src/modules/providers/configs/ProviderRetryPolicy.tsx +0 -46
- package/packages/hive-ui/src/modules/providers/configs/index.ts +0 -4
- package/packages/hive-ui/src/modules/providers/index.ts +0 -5
- package/packages/hive-ui/src/modules/providers/models/ModelBenchmarkBadge.tsx +0 -21
- package/packages/hive-ui/src/modules/providers/models/ModelCapabilities.tsx +0 -44
- package/packages/hive-ui/src/modules/providers/models/ModelCard.tsx +0 -36
- package/packages/hive-ui/src/modules/providers/models/ModelComparisonTable.tsx +0 -47
- package/packages/hive-ui/src/modules/providers/models/ModelList.tsx +0 -51
- package/packages/hive-ui/src/modules/providers/models/ModelPricingInfo.tsx +0 -17
- package/packages/hive-ui/src/modules/providers/models/ModelSelector.tsx +0 -32
- package/packages/hive-ui/src/modules/providers/models/index.ts +0 -7
- package/packages/hive-ui/src/pages/AgentDetailPage.tsx +0 -74
- package/packages/hive-ui/src/pages/AgentNewPage.tsx +0 -5
- package/packages/hive-ui/src/pages/AgentsPage.tsx +0 -147
- package/packages/hive-ui/src/pages/BridgePage.tsx +0 -83
- package/packages/hive-ui/src/pages/CanvasPage.tsx +0 -32
- package/packages/hive-ui/src/pages/ChannelsPage.tsx +0 -176
- package/packages/hive-ui/src/pages/DashboardPage.tsx +0 -321
- package/packages/hive-ui/src/pages/Index.tsx +0 -14
- package/packages/hive-ui/src/pages/LogsPage.tsx +0 -252
- package/packages/hive-ui/src/pages/NotFound.tsx +0 -24
- package/packages/hive-ui/src/pages/ProjectsPage.tsx +0 -241
- package/packages/hive-ui/src/pages/ProvidersPage.tsx +0 -111
- package/packages/hive-ui/src/pages/SettingsPage.tsx +0 -147
- package/packages/hive-ui/src/pages/SetupPage.tsx +0 -1177
- package/packages/hive-ui/src/pages/WebChatPage.tsx +0 -15
- package/packages/hive-ui/src/stores/agentConfigStore.ts +0 -32
- package/packages/hive-ui/src/stores/agentStore.ts +0 -5
- package/packages/hive-ui/src/stores/bridgeStore.ts +0 -237
- package/packages/hive-ui/src/stores/canvasStore.ts +0 -250
- package/packages/hive-ui/src/stores/channelStore.ts +0 -5
- package/packages/hive-ui/src/stores/chatStore.ts +0 -42
- package/packages/hive-ui/src/stores/ethicsStore.ts +0 -141
- package/packages/hive-ui/src/stores/mcpStore.ts +0 -5
- package/packages/hive-ui/src/stores/modelStore.ts +0 -2
- package/packages/hive-ui/src/stores/projectsStore.ts +0 -141
- package/packages/hive-ui/src/stores/providerStore.ts +0 -2
- package/packages/hive-ui/src/stores/skillStore.ts +0 -5
- package/packages/hive-ui/src/stores/toolStore.ts +0 -5
- package/packages/hive-ui/src/stores/useGlobalConfigStore.ts +0 -937
- package/packages/hive-ui/src/stores/useLoaderStore.ts +0 -21
- package/packages/hive-ui/src/stores/useNotesAndCronsStore.ts +0 -144
- package/packages/hive-ui/src/stores/useWebSocketStore.ts +0 -152
- package/packages/hive-ui/src/stores/useWelcomeStore.ts +0 -37
- package/packages/hive-ui/src/stores/userConfigStore.ts +0 -23
- package/packages/hive-ui/src/stores/userStore.ts +0 -82
- package/packages/hive-ui/src/test/setup.ts +0 -15
- package/packages/hive-ui/src/types/agent-config.ts +0 -33
- package/packages/hive-ui/src/types/agent.ts +0 -65
- package/packages/hive-ui/src/types/bridge.ts +0 -27
- package/packages/hive-ui/src/types/canvas.ts +0 -76
- package/packages/hive-ui/src/types/channels.ts +0 -109
- package/packages/hive-ui/src/types/chat.ts +0 -25
- package/packages/hive-ui/src/types/connections.ts +0 -17
- package/packages/hive-ui/src/types/ethics.ts +0 -41
- package/packages/hive-ui/src/types/index.ts +0 -15
- package/packages/hive-ui/src/types/mcp.ts +0 -36
- package/packages/hive-ui/src/types/notes-crons.ts +0 -31
- package/packages/hive-ui/src/types/providers.ts +0 -145
- package/packages/hive-ui/src/types/skill.ts +0 -12
- package/packages/hive-ui/src/types/tool.ts +0 -44
- package/packages/hive-ui/src/types/user.ts +0 -26
- package/packages/hive-ui/src/types/websocket.ts +0 -14
- package/packages/hive-ui/src/vite-env.d.ts +0 -1
- package/packages/mcp/package.json +0 -26
- package/packages/mcp/src/config.ts +0 -13
- package/packages/mcp/src/index.ts +0 -1
- package/packages/mcp/src/logger.ts +0 -42
- package/packages/mcp/src/manager.ts +0 -439
- package/packages/mcp/src/transports/index.ts +0 -67
- package/packages/mcp/src/transports/sse.ts +0 -241
- package/packages/mcp/src/transports/websocket.ts +0 -159
- package/packages/skills/package.json +0 -21
- package/packages/skills/src/index.ts +0 -1
- package/packages/skills/src/loader.ts +0 -346
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import { getDb } from "../storage/sqlite"
|
|
2
|
-
|
|
3
|
-
export interface ResolveContextResult {
|
|
4
|
-
userId: string
|
|
5
|
-
agentId: string
|
|
6
|
-
isNewUser: boolean
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export interface ResolveContextOptions {
|
|
10
|
-
channel: string
|
|
11
|
-
channelUserId: string
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export function resolveContext(options: ResolveContextOptions): ResolveContextResult {
|
|
15
|
-
const { channel, channelUserId } = options
|
|
16
|
-
const db = getDb()
|
|
17
|
-
|
|
18
|
-
const identity = db
|
|
19
|
-
.query<any, [string, string]>(
|
|
20
|
-
"SELECT user_id FROM user_identities WHERE channel = ? AND channel_user_id = ?"
|
|
21
|
-
)
|
|
22
|
-
.get(channel, channelUserId)
|
|
23
|
-
|
|
24
|
-
let userId: string
|
|
25
|
-
let isNewUser = false
|
|
26
|
-
|
|
27
|
-
if (identity) {
|
|
28
|
-
userId = identity.user_id
|
|
29
|
-
} else {
|
|
30
|
-
// Sistema mono-usuario: reutilizar el usuario del onboarding
|
|
31
|
-
const existingUser = db
|
|
32
|
-
.query<any, []>("SELECT id FROM users ORDER BY created_at ASC LIMIT 1")
|
|
33
|
-
.get() as { id: string } | undefined
|
|
34
|
-
|
|
35
|
-
if (!existingUser) {
|
|
36
|
-
throw new Error("No user found in database. Please run the onboarding process first.")
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
userId = existingUser.id
|
|
40
|
-
|
|
41
|
-
// Vincular este canal al usuario existente (auto-link en el primer mensaje)
|
|
42
|
-
// INSERT OR REPLACE: si ya existe una fila (user_id, channel), actualiza channel_user_id
|
|
43
|
-
// con el valor real del canal (e.g. chat ID numérico de Telegram).
|
|
44
|
-
db.query(
|
|
45
|
-
"INSERT OR REPLACE INTO user_identities (user_id, channel, channel_user_id, linked_at) VALUES (?, ?, ?, ?)"
|
|
46
|
-
).run(userId, channel, channelUserId, Math.floor(Date.now() / 1000))
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const coordinatorAgent = db
|
|
50
|
-
.query<any, []>("SELECT id FROM agents WHERE role = 'coordinator' LIMIT 1")
|
|
51
|
-
.get()
|
|
52
|
-
|
|
53
|
-
const agentId = coordinatorAgent?.id || "bee"
|
|
54
|
-
|
|
55
|
-
return { userId, agentId, isNewUser }
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export function getDefaultAgentId(): string {
|
|
59
|
-
const db = getDb()
|
|
60
|
-
const coordinatorAgent = db
|
|
61
|
-
.query<any, []>("SELECT id FROM agents WHERE role = 'coordinator' LIMIT 1")
|
|
62
|
-
.get()
|
|
63
|
-
|
|
64
|
-
return coordinatorAgent?.id || "bee"
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
export function getUserById(userId: string): any {
|
|
68
|
-
const db = getDb()
|
|
69
|
-
return db.query<any, [string]>("SELECT * FROM users WHERE id = ?").get(userId)
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export function updateUserProfile(userId: string, updates: {
|
|
73
|
-
name?: string
|
|
74
|
-
language?: string
|
|
75
|
-
timezone?: string
|
|
76
|
-
occupation?: string
|
|
77
|
-
notes?: string
|
|
78
|
-
}): void {
|
|
79
|
-
const db = getDb()
|
|
80
|
-
const setClauses: string[] = []
|
|
81
|
-
const values: any[] = []
|
|
82
|
-
|
|
83
|
-
if (updates.name !== undefined) {
|
|
84
|
-
setClauses.push("name = ?")
|
|
85
|
-
values.push(updates.name)
|
|
86
|
-
}
|
|
87
|
-
if (updates.language !== undefined) {
|
|
88
|
-
setClauses.push("language = ?")
|
|
89
|
-
values.push(updates.language)
|
|
90
|
-
}
|
|
91
|
-
if (updates.timezone !== undefined) {
|
|
92
|
-
setClauses.push("timezone = ?")
|
|
93
|
-
values.push(updates.timezone)
|
|
94
|
-
}
|
|
95
|
-
if (updates.occupation !== undefined) {
|
|
96
|
-
setClauses.push("occupation = ?")
|
|
97
|
-
values.push(updates.occupation)
|
|
98
|
-
}
|
|
99
|
-
if (updates.notes !== undefined) {
|
|
100
|
-
setClauses.push("notes = ?")
|
|
101
|
-
values.push(updates.notes)
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
if (setClauses.length > 0) {
|
|
105
|
-
values.push(userId)
|
|
106
|
-
db.query(`UPDATE users SET ${setClauses.join(", ")} WHERE id = ?`).run(...values)
|
|
107
|
-
}
|
|
108
|
-
}
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import type { Config, Binding } from "../config/loader.ts";
|
|
2
|
-
|
|
3
|
-
export interface RoutingContext {
|
|
4
|
-
channel: string;
|
|
5
|
-
accountId?: string;
|
|
6
|
-
peerKind?: "direct" | "group";
|
|
7
|
-
peerId?: string;
|
|
8
|
-
guildId?: string;
|
|
9
|
-
teamId?: string;
|
|
10
|
-
roles?: string[];
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export function matchBinding(binding: Binding, ctx: RoutingContext): number {
|
|
14
|
-
const match = binding.match;
|
|
15
|
-
let score = 0;
|
|
16
|
-
|
|
17
|
-
if (match.peer?.id && match.peer?.kind) {
|
|
18
|
-
if (ctx.peerId === match.peer.id && ctx.peerKind === match.peer.kind) {
|
|
19
|
-
score += 1000;
|
|
20
|
-
} else {
|
|
21
|
-
return 0;
|
|
22
|
-
}
|
|
23
|
-
} else if (match.peer?.id) {
|
|
24
|
-
if (ctx.peerId === match.peer.id) {
|
|
25
|
-
score += 900;
|
|
26
|
-
} else {
|
|
27
|
-
return 0;
|
|
28
|
-
}
|
|
29
|
-
} else if (match.peer?.kind) {
|
|
30
|
-
if (ctx.peerKind === match.peer.kind) {
|
|
31
|
-
score += 50;
|
|
32
|
-
} else {
|
|
33
|
-
return 0;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
if (match.guildId && match.roles && match.roles.length > 0) {
|
|
38
|
-
if (ctx.guildId === match.guildId && ctx.roles?.some((r) => match.roles?.includes(r))) {
|
|
39
|
-
score += 800;
|
|
40
|
-
} else {
|
|
41
|
-
return 0;
|
|
42
|
-
}
|
|
43
|
-
} else if (match.guildId) {
|
|
44
|
-
if (ctx.guildId === match.guildId) {
|
|
45
|
-
score += 200;
|
|
46
|
-
} else {
|
|
47
|
-
return 0;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
if (match.teamId) {
|
|
52
|
-
if (ctx.teamId === match.teamId) {
|
|
53
|
-
score += 300;
|
|
54
|
-
} else {
|
|
55
|
-
return 0;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
if (match.accountId) {
|
|
60
|
-
if (ctx.accountId === match.accountId) {
|
|
61
|
-
score += 400;
|
|
62
|
-
} else {
|
|
63
|
-
return 0;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
if (match.channel) {
|
|
68
|
-
if (ctx.channel === match.channel) {
|
|
69
|
-
score += 100;
|
|
70
|
-
} else {
|
|
71
|
-
return 0;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
return score || 1;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export function resolveAgent(
|
|
79
|
-
config: Config,
|
|
80
|
-
ctx: RoutingContext
|
|
81
|
-
): string {
|
|
82
|
-
const bindings = config.bindings ?? [];
|
|
83
|
-
|
|
84
|
-
if (bindings.length === 0) {
|
|
85
|
-
return config.agent?.defaultAgentId ?? "main";
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
let bestMatch: { agentId: string; score: number } | null = null;
|
|
89
|
-
|
|
90
|
-
for (const binding of bindings) {
|
|
91
|
-
const score = matchBinding(binding, ctx);
|
|
92
|
-
if (score > 0 && (!bestMatch || score > bestMatch.score)) {
|
|
93
|
-
bestMatch = { agentId: binding.agentId, score };
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
if (bestMatch) {
|
|
98
|
-
return bestMatch.agentId;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
return config.agent?.defaultAgentId ?? "main";
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
export class Router {
|
|
105
|
-
constructor(private config: Config) {}
|
|
106
|
-
|
|
107
|
-
route(ctx: RoutingContext): string {
|
|
108
|
-
return resolveAgent(this.config, ctx);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
getAgentWorkspace(agentId: string): string {
|
|
112
|
-
const agents = this.config.agents?.list ?? [];
|
|
113
|
-
const agent = agents.find((a) => a.id === agentId);
|
|
114
|
-
|
|
115
|
-
if (agent?.workspace) {
|
|
116
|
-
return agent.workspace.replace(/^~/, process.env.HOME ?? "");
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
const baseDir = this.config.agent?.baseDir?.replace(/^~/, process.env.HOME ?? "")
|
|
120
|
-
?? `${process.env.HOME}/.hive/agents`;
|
|
121
|
-
|
|
122
|
-
return `${baseDir}/${agentId}/workspace`;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
import { getDb } from "../../storage/sqlite"
|
|
2
|
-
import { emitCanvas } from "../../canvas/emitter"
|
|
3
|
-
import { encryptConfig } from "../../storage/crypto"
|
|
4
|
-
|
|
5
|
-
export async function handleGetAgents(req: Request, addCorsHeaders: (r: Response, req: Request) => Response): Promise<Response> {
|
|
6
|
-
const rows = getDb().query(`
|
|
7
|
-
SELECT a.*, u.notes as user_preferences,
|
|
8
|
-
CASE WHEN a.headers_encrypted IS NOT NULL THEN 1 ELSE 0 END as has_headers
|
|
9
|
-
FROM agents a
|
|
10
|
-
LEFT JOIN users u ON a.user_id = u.id
|
|
11
|
-
ORDER BY a.created_at DESC
|
|
12
|
-
`).all() as Record<string, unknown>[]
|
|
13
|
-
|
|
14
|
-
const agents = rows.map(row => ({
|
|
15
|
-
// Basic fields
|
|
16
|
-
id: row.id,
|
|
17
|
-
userId: row.user_id,
|
|
18
|
-
name: row.name,
|
|
19
|
-
description: row.description,
|
|
20
|
-
systemPrompt: row.system_prompt,
|
|
21
|
-
tone: row.tone,
|
|
22
|
-
|
|
23
|
-
// Role & status
|
|
24
|
-
role: row.role as 'coordinator' | 'worker',
|
|
25
|
-
status: row.status,
|
|
26
|
-
enabled: Boolean(row.enabled),
|
|
27
|
-
|
|
28
|
-
// Provider & model
|
|
29
|
-
providerId: row.provider_id,
|
|
30
|
-
modelId: row.model_id,
|
|
31
|
-
|
|
32
|
-
// Tools & skills
|
|
33
|
-
toolsJson: row.tools_json,
|
|
34
|
-
skillsJson: row.skills_json,
|
|
35
|
-
|
|
36
|
-
// Hierarchy
|
|
37
|
-
parentId: row.parent_id,
|
|
38
|
-
maxIterations: row.max_iterations,
|
|
39
|
-
|
|
40
|
-
// Workspace
|
|
41
|
-
workspace: row.workspace,
|
|
42
|
-
|
|
43
|
-
// Headers (encrypted)
|
|
44
|
-
hasHeaders: row.has_headers === 1,
|
|
45
|
-
|
|
46
|
-
// Timestamps
|
|
47
|
-
createdAt: new Date((row.created_at as number) * 1000).toISOString(),
|
|
48
|
-
updatedAt: new Date((row.updated_at as number) * 1000).toISOString(),
|
|
49
|
-
|
|
50
|
-
// Virtual fields (not from DB)
|
|
51
|
-
taskCount: 0,
|
|
52
|
-
successRate: 100,
|
|
53
|
-
}))
|
|
54
|
-
|
|
55
|
-
return addCorsHeaders(Response.json({ agents }), req)
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export async function handleCreateAgent(req: Request, addCorsHeaders: (r: Response, req: Request) => Response): Promise<Response> {
|
|
59
|
-
const body = await req.json().catch(() => ({}))
|
|
60
|
-
const { encrypted: headersEnc, iv: headersIv } = body.headers
|
|
61
|
-
? encryptConfig(body.headers)
|
|
62
|
-
: { encrypted: null, iv: null }
|
|
63
|
-
|
|
64
|
-
let agentId: string
|
|
65
|
-
|
|
66
|
-
if (body.id) {
|
|
67
|
-
agentId = body.id
|
|
68
|
-
getDb().query(`
|
|
69
|
-
INSERT INTO agents(id, name, description, provider_id, model_id, tone, enabled, headers_encrypted, headers_iv, workspace)
|
|
70
|
-
VALUES(?, ?, ?, ?, ?, ?, 1, ?, ?, ?)
|
|
71
|
-
`).run(
|
|
72
|
-
agentId,
|
|
73
|
-
body.name,
|
|
74
|
-
body.description || "",
|
|
75
|
-
body.providerId || "openai",
|
|
76
|
-
body.modelId || "gpt-4o",
|
|
77
|
-
body.tone || "friendly",
|
|
78
|
-
headersEnc,
|
|
79
|
-
headersIv,
|
|
80
|
-
body.workspace || null
|
|
81
|
-
)
|
|
82
|
-
} else {
|
|
83
|
-
const result = getDb().query(`
|
|
84
|
-
INSERT INTO agents(name, description, provider_id, model_id, tone, enabled, headers_encrypted, headers_iv, workspace)
|
|
85
|
-
VALUES(?, ?, ?, ?, ?, 1, ?, ?, ?)
|
|
86
|
-
RETURNING id
|
|
87
|
-
`).get(
|
|
88
|
-
body.name,
|
|
89
|
-
body.description || "",
|
|
90
|
-
body.providerId || "openai",
|
|
91
|
-
body.modelId || "gpt-4o",
|
|
92
|
-
body.tone || "friendly",
|
|
93
|
-
headersEnc,
|
|
94
|
-
headersIv,
|
|
95
|
-
body.workspace || null
|
|
96
|
-
) as { id: string } | undefined
|
|
97
|
-
agentId = result?.id || ""
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
emitCanvas("canvas:node_add", {
|
|
101
|
-
node: { id: agentId, name: body.name, status: "idle", type: "agent" }
|
|
102
|
-
})
|
|
103
|
-
|
|
104
|
-
const agent = getDb().query(`
|
|
105
|
-
SELECT id, name, description, provider_id, model_id, tone, status, enabled, active, created_at, workspace
|
|
106
|
-
FROM agents WHERE id = ?
|
|
107
|
-
`).get(agentId) as Record<string, unknown> | undefined
|
|
108
|
-
|
|
109
|
-
if (!agent) {
|
|
110
|
-
return addCorsHeaders(Response.json({ ok: false, error: "Agent not found" }), req)
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
return addCorsHeaders(Response.json({
|
|
114
|
-
ok: true,
|
|
115
|
-
agent: {
|
|
116
|
-
id: agent.id,
|
|
117
|
-
name: agent.name,
|
|
118
|
-
description: agent.description,
|
|
119
|
-
providerId: agent.provider_id,
|
|
120
|
-
modelId: agent.model_id,
|
|
121
|
-
tone: agent.tone,
|
|
122
|
-
status: agent.status,
|
|
123
|
-
enabled: agent.enabled === 1,
|
|
124
|
-
active: agent.active === 1,
|
|
125
|
-
createdAt: new Date((agent.created_at as number) * 1000).toISOString(),
|
|
126
|
-
workspace: agent.workspace,
|
|
127
|
-
}
|
|
128
|
-
}), req)
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
export async function handleUpdateAgent(req: Request, addCorsHeaders: (r: Response, req: Request) => Response): Promise<Response> {
|
|
132
|
-
const url = new URL(req.url)
|
|
133
|
-
const agentId = url.pathname.split("/").pop()
|
|
134
|
-
|
|
135
|
-
if (!agentId) {
|
|
136
|
-
return addCorsHeaders(new Response("Missing ID", { status: 400 }), req)
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
const body = await req.json().catch(() => ({}))
|
|
140
|
-
|
|
141
|
-
const updates: string[] = []
|
|
142
|
-
const params: unknown[] = []
|
|
143
|
-
|
|
144
|
-
const possibleFields = [
|
|
145
|
-
"name", "description", "provider_id", "model_id", "status",
|
|
146
|
-
"enabled", "tone", "workspace"
|
|
147
|
-
]
|
|
148
|
-
|
|
149
|
-
for (const field of possibleFields) {
|
|
150
|
-
const bodyKey = field.replace(/_([a-z])/g, (_g) => field[1]?.toUpperCase() ?? "")
|
|
151
|
-
let val = body[field] !== undefined ? body[field] : body[bodyKey]
|
|
152
|
-
|
|
153
|
-
if (val !== undefined) {
|
|
154
|
-
updates.push(`${field} = ?`)
|
|
155
|
-
params.push(typeof val === 'object' ? JSON.stringify(val) : val)
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
const agentHeaders = body.headers !== undefined ? body.headers : body.config?.headers
|
|
160
|
-
if (agentHeaders !== undefined) {
|
|
161
|
-
const { encrypted, iv } = encryptConfig(agentHeaders)
|
|
162
|
-
updates.push("headers_encrypted = ?")
|
|
163
|
-
params.push(encrypted)
|
|
164
|
-
updates.push("headers_iv = ?")
|
|
165
|
-
params.push(iv)
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
const userPreferences = body.userPreferences !== undefined ? body.userPreferences : body.user_preferences
|
|
169
|
-
if (userPreferences !== undefined) {
|
|
170
|
-
const agentRow = getDb().query("SELECT user_id FROM agents WHERE id = ?").get(agentId) as { user_id: string } | undefined
|
|
171
|
-
if (agentRow?.user_id) {
|
|
172
|
-
getDb().query(`UPDATE users SET notes = ? WHERE id = ?`).run(userPreferences, agentRow.user_id)
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
if (updates.length > 0) {
|
|
177
|
-
params.push(agentId)
|
|
178
|
-
getDb().query(`UPDATE agents SET ${updates.join(", ")} WHERE id = ?`).run(...params as any[])
|
|
179
|
-
|
|
180
|
-
emitCanvas("canvas:node_update", {
|
|
181
|
-
id: agentId,
|
|
182
|
-
updates: body
|
|
183
|
-
})
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
return addCorsHeaders(Response.json({ ok: true }), req)
|
|
187
|
-
}
|
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
import { getDb } from "../../storage/sqlite"
|
|
2
|
-
|
|
3
|
-
export async function handleGetChannels(req: Request, addCorsHeaders: (r: Response, req: Request) => Response): Promise<Response> {
|
|
4
|
-
const channels = getDb().query(`
|
|
5
|
-
SELECT channel, COUNT(*) as count FROM user_channels GROUP BY channel
|
|
6
|
-
`).all() as Record<string, unknown>[]
|
|
7
|
-
|
|
8
|
-
return addCorsHeaders(Response.json({ channels }), req)
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export async function handleGetChannelConfig(req: Request, addCorsHeaders: (r: Response, req: Request) => Response): Promise<Response> {
|
|
12
|
-
const url = new URL(req.url)
|
|
13
|
-
const channelIdMatch = url.pathname.match(/^\/api\/channels\/([^/]+)$/)
|
|
14
|
-
|
|
15
|
-
if (!channelIdMatch) {
|
|
16
|
-
return addCorsHeaders(Response.json({ error: "Invalid path" }), req)
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const channelId = channelIdMatch[1]
|
|
20
|
-
const config = getDb().query(`
|
|
21
|
-
SELECT * FROM user_channels WHERE channel = ?
|
|
22
|
-
`).all(channelId) as Record<string, unknown>[]
|
|
23
|
-
|
|
24
|
-
return addCorsHeaders(Response.json({ config }), req)
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export async function handleActivateChannel(req: Request, addCorsHeaders: (r: Response, req: Request) => Response): Promise<Response> {
|
|
28
|
-
const body = await req.json().catch(() => ({}))
|
|
29
|
-
const { channel, config, accountId } = body
|
|
30
|
-
|
|
31
|
-
if (!channel) {
|
|
32
|
-
return addCorsHeaders(Response.json({ success: false, error: "channel required" }), req)
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const userId = "default"
|
|
36
|
-
getDb().query(`
|
|
37
|
-
INSERT OR REPLACE INTO user_channels(user_id, channel, account_id, config, active)
|
|
38
|
-
VALUES(?, ?, ?, ?, 1)
|
|
39
|
-
`).run(userId, channel, accountId || null, JSON.stringify(config || {}))
|
|
40
|
-
|
|
41
|
-
return addCorsHeaders(Response.json({ success: true, channel }), req)
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export async function handleDeactivateChannel(req: Request, addCorsHeaders: (r: Response, req: Request) => Response): Promise<Response> {
|
|
45
|
-
const url = new URL(req.url)
|
|
46
|
-
const parts = url.pathname.split("/")
|
|
47
|
-
const channel = parts[3]
|
|
48
|
-
const accountId = parts[4]
|
|
49
|
-
|
|
50
|
-
if (!channel) {
|
|
51
|
-
return addCorsHeaders(Response.json({ success: false, error: "channel required" }), req)
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const userId = "default"
|
|
55
|
-
if (accountId) {
|
|
56
|
-
getDb().query(`DELETE FROM user_channels WHERE user_id = ? AND channel = ? AND account_id = ?`).run(userId, channel, accountId)
|
|
57
|
-
} else {
|
|
58
|
-
getDb().query(`DELETE FROM user_channels WHERE user_id = ? AND channel = ?`).run(userId, channel)
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
return addCorsHeaders(Response.json({ success: true }), req)
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export async function handleCreateChannel(
|
|
65
|
-
req: Request,
|
|
66
|
-
addCorsHeaders: (r: Response, req: Request) => Response,
|
|
67
|
-
channelManager?: any
|
|
68
|
-
): Promise<Response> {
|
|
69
|
-
const body = await req.json().catch(() => ({}));
|
|
70
|
-
const { name, accountId, config: channelConfigData } = body;
|
|
71
|
-
|
|
72
|
-
if (!name || !accountId || !channelConfigData) {
|
|
73
|
-
return addCorsHeaders(new Response("Missing name, accountId or config", { status: 400 }), req);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// Note: Channel config persistence should be handled by the caller
|
|
77
|
-
// The channelManager is passed to start the channel after config is saved
|
|
78
|
-
if (channelManager) {
|
|
79
|
-
await channelManager.removeChannel(name, accountId);
|
|
80
|
-
await channelManager.startChannel(name, accountId);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
return addCorsHeaders(Response.json({ success: true }), req);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
export async function handleGetChannelAccount(
|
|
87
|
-
req: Request,
|
|
88
|
-
addCorsHeaders: (r: Response, req: Request) => Response,
|
|
89
|
-
name: string,
|
|
90
|
-
accountId: string
|
|
91
|
-
): Promise<Response> {
|
|
92
|
-
// This should read from the config file or database
|
|
93
|
-
// For now, return a placeholder - the actual implementation depends on config storage
|
|
94
|
-
return addCorsHeaders(Response.json({ name, accountId, config: {} }), req);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
export async function handleUpdateChannelAccount(
|
|
98
|
-
req: Request,
|
|
99
|
-
addCorsHeaders: (r: Response, req: Request) => Response,
|
|
100
|
-
name: string,
|
|
101
|
-
accountId: string,
|
|
102
|
-
channelManager?: any
|
|
103
|
-
): Promise<Response> {
|
|
104
|
-
const body = await req.json().catch(() => ({}));
|
|
105
|
-
if (!body.config) {
|
|
106
|
-
return new Response("Missing config", { status: 400 });
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
// Note: Channel config persistence should be handled by the caller
|
|
110
|
-
if (channelManager) {
|
|
111
|
-
await channelManager.removeChannel(name, accountId);
|
|
112
|
-
await channelManager.startChannel(name, accountId);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
return addCorsHeaders(Response.json({ success: true }), req);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
export async function handleDeleteChannelAccount(
|
|
119
|
-
req: Request,
|
|
120
|
-
addCorsHeaders: (r: Response, req: Request) => Response,
|
|
121
|
-
name: string,
|
|
122
|
-
accountId: string,
|
|
123
|
-
config?: any,
|
|
124
|
-
channelManager?: any
|
|
125
|
-
): Promise<Response> {
|
|
126
|
-
// Note: Config update should be handled by the caller
|
|
127
|
-
if (channelManager) {
|
|
128
|
-
await channelManager.removeChannel(name, accountId);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
return addCorsHeaders(Response.json({ success: true }), req);
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
export async function handleChannelAction(
|
|
135
|
-
req: Request,
|
|
136
|
-
addCorsHeaders: (r: Response, req: Request) => Response,
|
|
137
|
-
name: string,
|
|
138
|
-
accountId: string,
|
|
139
|
-
action: "start" | "stop",
|
|
140
|
-
channelManager?: any
|
|
141
|
-
): Promise<Response> {
|
|
142
|
-
try {
|
|
143
|
-
if (!channelManager) {
|
|
144
|
-
return addCorsHeaders(new Response("Channel manager not available", { status: 500 }), req);
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
if (action === "start") {
|
|
148
|
-
await channelManager.startChannel(name, accountId);
|
|
149
|
-
} else {
|
|
150
|
-
await channelManager.stopChannel(name, accountId);
|
|
151
|
-
}
|
|
152
|
-
return addCorsHeaders(Response.json({ success: true }), req);
|
|
153
|
-
} catch (error) {
|
|
154
|
-
return addCorsHeaders(Response.json(
|
|
155
|
-
{ success: false, error: (error as Error).message },
|
|
156
|
-
{ status: 500 }
|
|
157
|
-
), req);
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
export async function handleUpdateChannelSettings(
|
|
162
|
-
req: Request,
|
|
163
|
-
addCorsHeaders: (r: Response, req: Request) => Response,
|
|
164
|
-
channelId: string
|
|
165
|
-
): Promise<Response> {
|
|
166
|
-
const body = await req.json().catch(() => ({})) as Record<string, unknown>;
|
|
167
|
-
const allowed = ["voice_enabled", "tts_enabled", "stt_provider", "tts_provider", "tts_voice_id", "step_delivery_mode"] as const;
|
|
168
|
-
const updates: string[] = [];
|
|
169
|
-
const params: unknown[] = [];
|
|
170
|
-
|
|
171
|
-
for (const key of allowed) {
|
|
172
|
-
if (key in body) {
|
|
173
|
-
updates.push(`${key} = ?`);
|
|
174
|
-
params.push(typeof body[key] === "boolean" ? (body[key] ? 1 : 0) : body[key]);
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
if (updates.length === 0) {
|
|
179
|
-
return addCorsHeaders(Response.json({ error: "No valid fields to update" }, { status: 400 }), req);
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
params.push(channelId);
|
|
183
|
-
getDb().query(`UPDATE channels SET ${updates.join(", ")} WHERE id = ?`).run(...params as any[]);
|
|
184
|
-
|
|
185
|
-
return addCorsHeaders(Response.json({ success: true }), req);
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
export async function handleToggleChannel(
|
|
189
|
-
req: Request,
|
|
190
|
-
addCorsHeaders: (r: Response, req: Request) => Response,
|
|
191
|
-
channelId: string
|
|
192
|
-
): Promise<Response> {
|
|
193
|
-
const body = await req.json().catch(() => ({}));
|
|
194
|
-
const { active } = body;
|
|
195
|
-
|
|
196
|
-
if (active === undefined) {
|
|
197
|
-
return addCorsHeaders(Response.json({ success: false, error: "Missing active field", message: "Falta el campo 'active'" }, { status: 400 }), req);
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
getDb().query(`UPDATE channels SET active = ?, enabled = ? WHERE id = ?`).run(active ? 1 : 0, active ? 1 : 0, channelId);
|
|
201
|
-
|
|
202
|
-
return addCorsHeaders(Response.json({ success: true, active, message: active ? `Canal "${channelId}" activado` : `Canal "${channelId}" desactivado` }), req);
|
|
203
|
-
}
|