@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,95 +0,0 @@
|
|
|
1
|
-
import type { ServerWebSocket } from "bun";
|
|
2
|
-
|
|
3
|
-
export interface SessionId {
|
|
4
|
-
userId: string;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export function parseSessionId(sessionId: string): SessionId | null {
|
|
8
|
-
if (!sessionId || sessionId.trim() === "") {
|
|
9
|
-
return null;
|
|
10
|
-
}
|
|
11
|
-
return { userId: sessionId };
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export function formatSessionId(session: SessionId): string {
|
|
15
|
-
return session.userId;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export interface Session {
|
|
19
|
-
id: string;
|
|
20
|
-
parsed: SessionId;
|
|
21
|
-
createdAt: Date;
|
|
22
|
-
lastActivityAt: Date;
|
|
23
|
-
messageCount: number;
|
|
24
|
-
ws?: ServerWebSocket<unknown>;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export class SessionManager {
|
|
28
|
-
private sessions: Map<string, Session> = new Map();
|
|
29
|
-
|
|
30
|
-
create(sessionId: string, ws?: ServerWebSocket<unknown>): Session {
|
|
31
|
-
const parsed = parseSessionId(sessionId);
|
|
32
|
-
if (!parsed) {
|
|
33
|
-
throw new Error(`Invalid session ID: ${sessionId}`);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const existing = this.sessions.get(sessionId);
|
|
37
|
-
if (existing) {
|
|
38
|
-
existing.lastActivityAt = new Date();
|
|
39
|
-
if (ws) {
|
|
40
|
-
existing.ws = ws;
|
|
41
|
-
}
|
|
42
|
-
return existing;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const session: Session = {
|
|
46
|
-
id: sessionId,
|
|
47
|
-
parsed,
|
|
48
|
-
createdAt: new Date(),
|
|
49
|
-
lastActivityAt: new Date(),
|
|
50
|
-
messageCount: 0,
|
|
51
|
-
};
|
|
52
|
-
if (ws !== undefined) {
|
|
53
|
-
session.ws = ws;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
this.sessions.set(sessionId, session);
|
|
57
|
-
return session;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
get(sessionId: string): Session | undefined {
|
|
61
|
-
return this.sessions.get(sessionId);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
touch(sessionId: string): void {
|
|
65
|
-
const session = this.sessions.get(sessionId);
|
|
66
|
-
if (session) {
|
|
67
|
-
session.lastActivityAt = new Date();
|
|
68
|
-
session.messageCount++;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
delete(sessionId: string): boolean {
|
|
73
|
-
return this.sessions.delete(sessionId);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
list(): Session[] {
|
|
77
|
-
return Array.from(this.sessions.values());
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
prune(maxAgeMs: number): number {
|
|
81
|
-
const now = Date.now();
|
|
82
|
-
let pruned = 0;
|
|
83
|
-
|
|
84
|
-
for (const [id, session] of this.sessions) {
|
|
85
|
-
if (now - session.lastActivityAt.getTime() > maxAgeMs) {
|
|
86
|
-
this.sessions.delete(id);
|
|
87
|
-
pruned++;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
return pruned;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
export const sessionManager = new SessionManager();
|
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
import type { ServerWebSocket } from "bun";
|
|
2
|
-
import { sessionManager } from "./session.ts";
|
|
3
|
-
import { laneQueue } from "./lane-queue.ts";
|
|
4
|
-
import { logger } from "../utils/logger.ts";
|
|
5
|
-
|
|
6
|
-
export interface InboundMessage {
|
|
7
|
-
type: "message" | "command" | "ping" | "join" | "canvas_subscribe" | "canvas_unsubscribe" | "logs_subscribe" | "logs_unsubscribe" | "audio";
|
|
8
|
-
sessionId: string;
|
|
9
|
-
content?: string;
|
|
10
|
-
audio?: string;
|
|
11
|
-
command?: string;
|
|
12
|
-
args?: string[];
|
|
13
|
-
metadata?: Record<string, unknown>;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export interface OutboundMessage {
|
|
17
|
-
type: "message" | "stream" | "status" | "error" | "pong" | "command_result" | "joined" | "typing" | "audio" | "welcome";
|
|
18
|
-
sessionId: string;
|
|
19
|
-
id?: string; // Message ID for streaming
|
|
20
|
-
content?: string;
|
|
21
|
-
chunk?: string;
|
|
22
|
-
isChunk?: boolean; // True if this is a streaming chunk
|
|
23
|
-
isLast?: boolean;
|
|
24
|
-
isTyping?: boolean;
|
|
25
|
-
isStep?: boolean;
|
|
26
|
-
stepType?: "plan" | "tool_call" | "tool_result" | "text";
|
|
27
|
-
status?: {
|
|
28
|
-
state: string;
|
|
29
|
-
model?: string;
|
|
30
|
-
tokens?: number;
|
|
31
|
-
};
|
|
32
|
-
error?: string;
|
|
33
|
-
result?: unknown;
|
|
34
|
-
// Welcome message fields
|
|
35
|
-
user?: {
|
|
36
|
-
id: string;
|
|
37
|
-
name: string;
|
|
38
|
-
language: string;
|
|
39
|
-
} | null;
|
|
40
|
-
agent?: {
|
|
41
|
-
id: string;
|
|
42
|
-
name: string;
|
|
43
|
-
provider: string;
|
|
44
|
-
model: string;
|
|
45
|
-
} | null;
|
|
46
|
-
channels?: string[];
|
|
47
|
-
voice?: {
|
|
48
|
-
enabled: boolean;
|
|
49
|
-
sttProvider: string | null;
|
|
50
|
-
ttsProvider: string | null;
|
|
51
|
-
};
|
|
52
|
-
codeBridge?: string[];
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export interface SlashCommand {
|
|
56
|
-
name: string;
|
|
57
|
-
description: string;
|
|
58
|
-
handler: (sessionId: string, args: string[], ws: ServerWebSocket<unknown>) => Promise<unknown>;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const slashCommands = new Map<string, SlashCommand>();
|
|
62
|
-
|
|
63
|
-
export function registerSlashCommand(command: SlashCommand): void {
|
|
64
|
-
slashCommands.set(command.name, command);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
export function isSlashCommand(content: string): boolean {
|
|
68
|
-
return content.startsWith("/") && content.length > 1;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export function parseSlashCommand(content: string): { name: string; args: string[] } | null {
|
|
72
|
-
if (!isSlashCommand(content)) return null;
|
|
73
|
-
|
|
74
|
-
const parts = content.slice(1).split(/\s+/);
|
|
75
|
-
const name = parts[0]?.toLowerCase();
|
|
76
|
-
if (!name) return null;
|
|
77
|
-
|
|
78
|
-
return {
|
|
79
|
-
name,
|
|
80
|
-
args: parts.slice(1),
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export async function executeSlashCommand(
|
|
85
|
-
sessionId: string,
|
|
86
|
-
content: string,
|
|
87
|
-
ws: ServerWebSocket<unknown>
|
|
88
|
-
): Promise<OutboundMessage | null> {
|
|
89
|
-
const parsed = parseSlashCommand(content);
|
|
90
|
-
if (!parsed) {
|
|
91
|
-
return null;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
const command = slashCommands.get(parsed.name);
|
|
95
|
-
if (!command) {
|
|
96
|
-
return null;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
logger.info(`Executing slash command: /${parsed.name}`, { sessionId, args: parsed.args });
|
|
100
|
-
|
|
101
|
-
try {
|
|
102
|
-
const result = await command.handler(sessionId, parsed.args, ws);
|
|
103
|
-
return {
|
|
104
|
-
type: "command_result",
|
|
105
|
-
sessionId,
|
|
106
|
-
result,
|
|
107
|
-
};
|
|
108
|
-
} catch (error) {
|
|
109
|
-
logger.error(`Slash command failed: /${parsed.name}`, { error: (error as Error).message });
|
|
110
|
-
return {
|
|
111
|
-
type: "error",
|
|
112
|
-
sessionId,
|
|
113
|
-
error: (error as Error).message,
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
registerSlashCommand({
|
|
119
|
-
name: "stop",
|
|
120
|
-
description: "Stop the current task",
|
|
121
|
-
handler: async (sessionId) => {
|
|
122
|
-
const cancelled = laneQueue.cancel(sessionId);
|
|
123
|
-
return {
|
|
124
|
-
success: cancelled,
|
|
125
|
-
message: cancelled ? "Task stopped" : "No task running",
|
|
126
|
-
};
|
|
127
|
-
},
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
registerSlashCommand({
|
|
131
|
-
name: "status",
|
|
132
|
-
description: "Show session status",
|
|
133
|
-
handler: async (sessionId) => {
|
|
134
|
-
const session = sessionManager.get(sessionId);
|
|
135
|
-
const queueStatus = laneQueue.getStatus(sessionId);
|
|
136
|
-
|
|
137
|
-
return {
|
|
138
|
-
sessionId,
|
|
139
|
-
createdAt: session?.createdAt,
|
|
140
|
-
messageCount: session?.messageCount,
|
|
141
|
-
queueLength: queueStatus.queueLength,
|
|
142
|
-
isProcessing: queueStatus.running !== undefined,
|
|
143
|
-
};
|
|
144
|
-
},
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
registerSlashCommand({
|
|
148
|
-
name: "new",
|
|
149
|
-
description: "Start a new session",
|
|
150
|
-
handler: async (sessionId) => {
|
|
151
|
-
sessionManager.delete(sessionId);
|
|
152
|
-
return { success: true, message: "Session reset" };
|
|
153
|
-
},
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
registerSlashCommand({
|
|
157
|
-
name: "compact",
|
|
158
|
-
description: "Force context compaction",
|
|
159
|
-
handler: async (sessionId) => {
|
|
160
|
-
logger.info(`Compaction requested for session: ${sessionId}`);
|
|
161
|
-
return { success: true, message: "Compaction triggered" };
|
|
162
|
-
},
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
registerSlashCommand({
|
|
166
|
-
name: "reset",
|
|
167
|
-
description: "Reset the current context",
|
|
168
|
-
handler: async (sessionId) => {
|
|
169
|
-
logger.info(`Context reset requested for session: ${sessionId}`);
|
|
170
|
-
return { success: true, message: "Context reset" };
|
|
171
|
-
},
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
registerSlashCommand({
|
|
175
|
-
name: "model",
|
|
176
|
-
description: "Switch model for this session",
|
|
177
|
-
handler: async (_sessionId, args) => {
|
|
178
|
-
const modelName = args[0];
|
|
179
|
-
if (!modelName) {
|
|
180
|
-
return { success: false, message: "Usage: /model <model-name>" };
|
|
181
|
-
}
|
|
182
|
-
return { success: true, message: `Model switched to: ${modelName}` };
|
|
183
|
-
},
|
|
184
|
-
});
|
|
185
|
-
|
|
186
|
-
registerSlashCommand({
|
|
187
|
-
name: "help",
|
|
188
|
-
description: "Show available commands",
|
|
189
|
-
handler: async () => {
|
|
190
|
-
const commands = Array.from(slashCommands.values()).map((c) => `/${c.name} - ${c.description}`);
|
|
191
|
-
return { commands };
|
|
192
|
-
},
|
|
193
|
-
});
|
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
import type { Config } from "../config/loader.ts";
|
|
2
|
-
import { logger } from "../utils/logger.ts";
|
|
3
|
-
|
|
4
|
-
export interface HealthStatus {
|
|
5
|
-
status: "healthy" | "degraded" | "unhealthy";
|
|
6
|
-
checks: Record<string, {
|
|
7
|
-
status: "ok" | "warning" | "error";
|
|
8
|
-
message?: string;
|
|
9
|
-
latency?: number;
|
|
10
|
-
}>;
|
|
11
|
-
uptime: number;
|
|
12
|
-
lastCheck: Date;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export interface HeartbeatOptions {
|
|
16
|
-
intervalMs?: number;
|
|
17
|
-
onHealthChange?: (status: HealthStatus) => void;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
type HealthCheck = () => Promise<{
|
|
21
|
-
status: "ok" | "warning" | "error";
|
|
22
|
-
message?: string;
|
|
23
|
-
latency?: number;
|
|
24
|
-
}>;
|
|
25
|
-
|
|
26
|
-
export class Heartbeat {
|
|
27
|
-
private intervalMs: number;
|
|
28
|
-
private checks: Map<string, HealthCheck> = new Map();
|
|
29
|
-
private intervalId: Timer | null = null;
|
|
30
|
-
private startTime: Date;
|
|
31
|
-
private lastStatus: HealthStatus | null = null;
|
|
32
|
-
private onHealthChange?: (status: HealthStatus) => void;
|
|
33
|
-
private log = logger.child("heartbeat");
|
|
34
|
-
|
|
35
|
-
constructor(_config: Config, options: HeartbeatOptions = {}) {
|
|
36
|
-
this.intervalMs = options.intervalMs ?? 30000;
|
|
37
|
-
this.onHealthChange = options.onHealthChange;
|
|
38
|
-
this.startTime = new Date();
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
registerCheck(name: string, check: HealthCheck): void {
|
|
42
|
-
this.checks.set(name, check);
|
|
43
|
-
this.log.debug(`Registered health check: ${name}`);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
removeCheck(name: string): boolean {
|
|
47
|
-
return this.checks.delete(name);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
async runChecks(): Promise<HealthStatus> {
|
|
51
|
-
const checks: HealthStatus["checks"] = {};
|
|
52
|
-
let overallStatus: "healthy" | "degraded" | "unhealthy" = "healthy";
|
|
53
|
-
|
|
54
|
-
for (const [name, check] of this.checks) {
|
|
55
|
-
try {
|
|
56
|
-
const start = Date.now();
|
|
57
|
-
const result = await check();
|
|
58
|
-
const latency = Date.now() - start;
|
|
59
|
-
|
|
60
|
-
checks[name] = {
|
|
61
|
-
status: result.status,
|
|
62
|
-
message: result.message,
|
|
63
|
-
latency: result.latency ?? latency,
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
if (result.status === "warning" && overallStatus === "healthy") {
|
|
67
|
-
overallStatus = "degraded";
|
|
68
|
-
} else if (result.status === "error") {
|
|
69
|
-
overallStatus = "unhealthy";
|
|
70
|
-
}
|
|
71
|
-
} catch (error) {
|
|
72
|
-
checks[name] = {
|
|
73
|
-
status: "error",
|
|
74
|
-
message: (error as Error).message,
|
|
75
|
-
};
|
|
76
|
-
overallStatus = "unhealthy";
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
const status: HealthStatus = {
|
|
81
|
-
status: overallStatus,
|
|
82
|
-
checks,
|
|
83
|
-
uptime: Date.now() - this.startTime.getTime(),
|
|
84
|
-
lastCheck: new Date(),
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
const prevStatus = this.lastStatus?.status;
|
|
88
|
-
if (prevStatus && prevStatus !== overallStatus) {
|
|
89
|
-
this.log.info(`Health status changed: ${prevStatus} -> ${overallStatus}`);
|
|
90
|
-
this.onHealthChange?.(status);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
this.lastStatus = status;
|
|
94
|
-
return status;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
start(): void {
|
|
98
|
-
if (this.intervalId) {
|
|
99
|
-
this.log.warn("Heartbeat already running");
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
this.runChecks();
|
|
104
|
-
|
|
105
|
-
this.intervalId = setInterval(async () => {
|
|
106
|
-
await this.runChecks();
|
|
107
|
-
}, this.intervalMs);
|
|
108
|
-
|
|
109
|
-
this.log.info(`Heartbeat started (interval: ${this.intervalMs}ms)`);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
stop(): void {
|
|
113
|
-
if (this.intervalId) {
|
|
114
|
-
clearInterval(this.intervalId);
|
|
115
|
-
this.intervalId = null;
|
|
116
|
-
this.log.info("Heartbeat stopped");
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
getStatus(): HealthStatus | null {
|
|
121
|
-
return this.lastStatus;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
isRunning(): boolean {
|
|
125
|
-
return this.intervalId !== null;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
export function createHeartbeat(config: Config, options?: HeartbeatOptions): Heartbeat {
|
|
130
|
-
const heartbeat = new Heartbeat(config, options);
|
|
131
|
-
|
|
132
|
-
heartbeat.registerCheck("memory", async () => {
|
|
133
|
-
const memUsage = process.memoryUsage();
|
|
134
|
-
const heapUsedMB = Math.round(memUsage.heapUsed / 1024 / 1024);
|
|
135
|
-
const heapTotalMB = Math.round(memUsage.heapTotal / 1024 / 1024);
|
|
136
|
-
const ratio = memUsage.heapUsed / memUsage.heapTotal;
|
|
137
|
-
|
|
138
|
-
if (ratio > 0.9) {
|
|
139
|
-
return {
|
|
140
|
-
status: "error",
|
|
141
|
-
message: `Memory critically high: ${heapUsedMB}/${heapTotalMB}MB`,
|
|
142
|
-
};
|
|
143
|
-
} else if (ratio > 0.75) {
|
|
144
|
-
return {
|
|
145
|
-
status: "warning",
|
|
146
|
-
message: `Memory usage high: ${heapUsedMB}/${heapTotalMB}MB`,
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
return {
|
|
151
|
-
status: "ok",
|
|
152
|
-
message: `${heapUsedMB}/${heapTotalMB}MB used`,
|
|
153
|
-
};
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
return heartbeat;
|
|
157
|
-
}
|
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* MCP Hot Reload
|
|
3
|
-
*
|
|
4
|
-
* Watches for MCP server changes in DB and updates MCP Manager automatically
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import { getDb } from "../storage/sqlite";
|
|
8
|
-
import { logger } from "../utils/logger";
|
|
9
|
-
import type { MCPClientManager } from "@johpaz/hive-mcp";
|
|
10
|
-
import { decryptConfig } from "../storage/crypto";
|
|
11
|
-
import { syncMCPToolsToFTS, removeMCPToolsFromFTS } from "../agent/tool-selector";
|
|
12
|
-
|
|
13
|
-
const log = logger.child("mcp:hot-reload");
|
|
14
|
-
|
|
15
|
-
let _watchInterval: Timer | null = null;
|
|
16
|
-
let _lastKnownServers = new Set<string>();
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Sync MCP tools to database (tools_mcp table + FTS5)
|
|
20
|
-
*/
|
|
21
|
-
async function syncMCPToolsToDB(
|
|
22
|
-
serverId: string,
|
|
23
|
-
serverName: string,
|
|
24
|
-
tools: Array<{ name: string; description: string; inputSchema?: any }>
|
|
25
|
-
): Promise<void> {
|
|
26
|
-
const db = getDb();
|
|
27
|
-
|
|
28
|
-
try {
|
|
29
|
-
const syncTransaction = db.transaction(() => {
|
|
30
|
-
// Remove existing tools from this server
|
|
31
|
-
db.query("DELETE FROM tools_mcp WHERE server_id = ?").run(serverId);
|
|
32
|
-
|
|
33
|
-
// Insert new tools
|
|
34
|
-
const insert = db.prepare(`
|
|
35
|
-
INSERT INTO tools_mcp(id, server_id, server_name, name, description, input_schema, enabled, active, updated_at)
|
|
36
|
-
VALUES (?, ?, ?, ?, ?, ?, 1, 0, unixepoch())
|
|
37
|
-
`);
|
|
38
|
-
|
|
39
|
-
for (const tool of tools) {
|
|
40
|
-
const toolId = `mcp_${serverId}_${tool.name.toLowerCase().replace(/[^a-z0-9]/g, '_')}`;
|
|
41
|
-
const inputSchemaJson = tool.inputSchema ? JSON.stringify(tool.inputSchema) : null;
|
|
42
|
-
|
|
43
|
-
insert.run(toolId, serverId, serverName, tool.name, tool.description, inputSchemaJson);
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
syncTransaction();
|
|
48
|
-
log.info(`[hot-reload] Synced ${tools.length} MCP tools to DB for ${serverName}`);
|
|
49
|
-
} catch (err) {
|
|
50
|
-
log.error(`[hot-reload] Failed to sync MCP tools to DB: ${(err as Error).message}`);
|
|
51
|
-
throw err;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Remove MCP tools from database
|
|
57
|
-
*/
|
|
58
|
-
async function removeMCPToolsFromDB(serverId: string): Promise<void> {
|
|
59
|
-
const db = getDb();
|
|
60
|
-
|
|
61
|
-
try {
|
|
62
|
-
db.query("DELETE FROM tools_mcp WHERE server_id = ?").run(serverId);
|
|
63
|
-
log.info(`[hot-reload] Removed MCP tools for server ${serverId} from DB`);
|
|
64
|
-
} catch (err) {
|
|
65
|
-
log.error(`[hot-reload] Failed to remove MCP tools from DB: ${(err as Error).message}`);
|
|
66
|
-
throw err;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Set MCP tools active/inactive based on server connection status
|
|
72
|
-
*/
|
|
73
|
-
async function setMCPToolsActive(serverId: string, active: boolean): Promise<void> {
|
|
74
|
-
const db = getDb();
|
|
75
|
-
|
|
76
|
-
try {
|
|
77
|
-
db.query("UPDATE tools_mcp SET active = ?, updated_at = unixepoch() WHERE server_id = ?").run(active ? 1 : 0, serverId);
|
|
78
|
-
log.info(`[hot-reload] Set MCP tools ${active ? 'active' : 'inactive'} for server ${serverId}`);
|
|
79
|
-
} catch (err) {
|
|
80
|
-
log.error(`[hot-reload] Failed to set MCP tools active: ${(err as Error).message}`);
|
|
81
|
-
throw err;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Start watching for MCP server changes
|
|
87
|
-
* Checks every 2 seconds for new/removed servers
|
|
88
|
-
*/
|
|
89
|
-
export function startMCPHotReload(mcpManager: MCPClientManager): void {
|
|
90
|
-
if (_watchInterval) {
|
|
91
|
-
log.warn("MCP Hot Reload already running");
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
log.info("Starting MCP Hot Reload watcher (2s interval)");
|
|
96
|
-
|
|
97
|
-
// Initial sync - sync all currently connected servers
|
|
98
|
-
syncMCPServers(mcpManager).then(() => {
|
|
99
|
-
log.info("Initial MCP server sync complete");
|
|
100
|
-
}).catch(err => {
|
|
101
|
-
log.error(`Initial MCP server sync failed: ${err.message}`);
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
// Watch for changes
|
|
105
|
-
_watchInterval = setInterval(() => {
|
|
106
|
-
syncMCPServers(mcpManager);
|
|
107
|
-
}, 2000);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* Stop watching
|
|
112
|
-
*/
|
|
113
|
-
export function stopMCPHotReload(): void {
|
|
114
|
-
if (_watchInterval) {
|
|
115
|
-
clearInterval(_watchInterval);
|
|
116
|
-
_watchInterval = null;
|
|
117
|
-
log.info("MCP Hot Reload stopped");
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* Sync MCP servers from DB to MCP Manager
|
|
123
|
-
*/
|
|
124
|
-
async function syncMCPServers(mcpManager: MCPClientManager): Promise<void> {
|
|
125
|
-
try {
|
|
126
|
-
const db = getDb();
|
|
127
|
-
const dbServers = db.query(`SELECT * FROM mcp_servers WHERE enabled = 1`).all() as Record<string, any>[];
|
|
128
|
-
|
|
129
|
-
const currentServerNames = new Set(dbServers.map(s => s.id || s.name));
|
|
130
|
-
|
|
131
|
-
// Detect new servers
|
|
132
|
-
for (const server of dbServers) {
|
|
133
|
-
const serverName = server.id || server.name;
|
|
134
|
-
|
|
135
|
-
if (!_lastKnownServers.has(serverName)) {
|
|
136
|
-
log.info(`New MCP server detected: ${serverName} - connecting...`);
|
|
137
|
-
|
|
138
|
-
try {
|
|
139
|
-
const mcpServerConfig: any = {
|
|
140
|
-
transport: server.transport,
|
|
141
|
-
command: server.command,
|
|
142
|
-
args: server.args ? JSON.parse(server.args) : [],
|
|
143
|
-
url: server.url,
|
|
144
|
-
enabled: true,
|
|
145
|
-
};
|
|
146
|
-
|
|
147
|
-
if (server.headers_encrypted && server.headers_iv) {
|
|
148
|
-
mcpServerConfig.headers = decryptConfig(server.headers_encrypted, server.headers_iv);
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
// Update MCP Manager config (auto-connects new servers)
|
|
152
|
-
const currentConfig = (mcpManager as any).config || { servers: {} };
|
|
153
|
-
await mcpManager.updateConfig({
|
|
154
|
-
...currentConfig,
|
|
155
|
-
servers: {
|
|
156
|
-
...currentConfig.servers,
|
|
157
|
-
[serverName]: mcpServerConfig,
|
|
158
|
-
},
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
// Wait a bit for connection to establish
|
|
162
|
-
await new Promise(resolve => setTimeout(resolve, 500));
|
|
163
|
-
|
|
164
|
-
// Get tools and update DB status
|
|
165
|
-
const tools = mcpManager.getServerTools(serverName) || [];
|
|
166
|
-
db.query(`UPDATE mcp_servers SET status = ?, tools_count = ? WHERE id = ?`).run("connected", tools.length, serverName);
|
|
167
|
-
|
|
168
|
-
// Sync MCP tools to database (tools_mcp + FTS5 via triggers)
|
|
169
|
-
if (tools.length > 0) {
|
|
170
|
-
await syncMCPToolsToDB(serverName, serverName, tools);
|
|
171
|
-
await setMCPToolsActive(serverName, true);
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
log.info(`✅ MCP server ${serverName} connected with ${tools.length} tools`);
|
|
175
|
-
} catch (error) {
|
|
176
|
-
log.error(`Failed to connect new MCP server ${serverName}: ${(error as Error).message}`);
|
|
177
|
-
db.query(`UPDATE mcp_servers SET status = ? WHERE id = ?`).run("error", serverName);
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
// Detect removed servers
|
|
183
|
-
for (const oldName of _lastKnownServers) {
|
|
184
|
-
if (!currentServerNames.has(oldName)) {
|
|
185
|
-
log.info(`MCP server removed: ${oldName} - disconnecting...`);
|
|
186
|
-
|
|
187
|
-
try {
|
|
188
|
-
await mcpManager.disconnectServer(oldName);
|
|
189
|
-
db.query(`UPDATE mcp_servers SET status = ? WHERE id = ?`).run("disconnected", oldName);
|
|
190
|
-
|
|
191
|
-
// Remove MCP tools from database (triggers will remove from FTS5)
|
|
192
|
-
await removeMCPToolsFromDB(oldName);
|
|
193
|
-
|
|
194
|
-
log.info(`✅ MCP server ${oldName} disconnected`);
|
|
195
|
-
} catch (error) {
|
|
196
|
-
log.error(`Failed to disconnect MCP server ${oldName}: ${(error as Error).message}`);
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
_lastKnownServers = currentServerNames;
|
|
202
|
-
|
|
203
|
-
} catch (error) {
|
|
204
|
-
log.error(`MCP Hot Reload sync failed: ${(error as Error).message}`);
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
/**
|
|
209
|
-
* Get current watched server count
|
|
210
|
-
*/
|
|
211
|
-
export function getWatchedServerCount(): number {
|
|
212
|
-
return _lastKnownServers.size;
|
|
213
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* MCP Manager Singleton
|
|
3
|
-
*
|
|
4
|
-
* Provides global access to the MCP Manager instance
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import type { MCPClientManager } from "@johpaz/hive-mcp";
|
|
8
|
-
|
|
9
|
-
let _mcpManager: MCPClientManager | null = null;
|
|
10
|
-
|
|
11
|
-
export function setMCPManager(m: MCPClientManager): void {
|
|
12
|
-
_mcpManager = m;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export function getMCPManager(): MCPClientManager | null {
|
|
16
|
-
return _mcpManager;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export function hasMCPManager(): boolean {
|
|
20
|
-
return _mcpManager !== null;
|
|
21
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./notes.ts";
|