@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,15 +0,0 @@
|
|
|
1
|
-
import { ChatContainer } from "@/modules/chat/ChatContainer";
|
|
2
|
-
import { useUserStore } from "@/stores/userStore";
|
|
3
|
-
|
|
4
|
-
export function WebChatPage() {
|
|
5
|
-
const { currentUser } = useUserStore();
|
|
6
|
-
const activeSession = currentUser?.id || "default";
|
|
7
|
-
|
|
8
|
-
return (
|
|
9
|
-
<div className="h-full bg-zinc-950 overflow-hidden mt-10">
|
|
10
|
-
<div className="max-w-4xl mx-auto h-full flex flex-col border-x border-white/5">
|
|
11
|
-
<ChatContainer agentId="main" sessionId={activeSession} />
|
|
12
|
-
</div>
|
|
13
|
-
</div>
|
|
14
|
-
);
|
|
15
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { create } from "zustand";
|
|
2
|
-
import type { ConfigSnapshot, SaveStatus, ConfigSection, ConfigValidationError } from "@/types";
|
|
3
|
-
|
|
4
|
-
interface AgentConfigState {
|
|
5
|
-
activeAgentId: string | null;
|
|
6
|
-
activeSection: ConfigSection;
|
|
7
|
-
saveStatus: SaveStatus;
|
|
8
|
-
snapshots: ConfigSnapshot[];
|
|
9
|
-
validationErrors: ConfigValidationError[];
|
|
10
|
-
unsavedChanges: boolean;
|
|
11
|
-
setActiveAgent: (id: string | null) => void;
|
|
12
|
-
setActiveSection: (section: ConfigSection) => void;
|
|
13
|
-
setSaveStatus: (status: SaveStatus) => void;
|
|
14
|
-
addSnapshot: (snapshot: ConfigSnapshot) => void;
|
|
15
|
-
setValidationErrors: (errors: ConfigValidationError[]) => void;
|
|
16
|
-
setUnsavedChanges: (val: boolean) => void;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export const useAgentConfigStore = create<AgentConfigState>((set) => ({
|
|
20
|
-
activeAgentId: null,
|
|
21
|
-
activeSection: "ethics",
|
|
22
|
-
saveStatus: "saved",
|
|
23
|
-
snapshots: [],
|
|
24
|
-
validationErrors: [],
|
|
25
|
-
unsavedChanges: false,
|
|
26
|
-
setActiveAgent: (id) => set({ activeAgentId: id }),
|
|
27
|
-
setActiveSection: (section) => set({ activeSection: section }),
|
|
28
|
-
setSaveStatus: (status) => set({ saveStatus: status }),
|
|
29
|
-
addSnapshot: (snapshot) => set((s) => ({ snapshots: [...s.snapshots, snapshot] })),
|
|
30
|
-
setValidationErrors: (errors) => set({ validationErrors: errors }),
|
|
31
|
-
setUnsavedChanges: (val) => set({ unsavedChanges: val }),
|
|
32
|
-
}));
|
|
@@ -1,237 +0,0 @@
|
|
|
1
|
-
import { create } from "zustand";
|
|
2
|
-
import type { BridgeProcess, BridgeLog } from "@/types";
|
|
3
|
-
|
|
4
|
-
const CODE_BRIDGE_URL = "ws://localhost:18791/ws";
|
|
5
|
-
const API_URL = import.meta.env.VITE_API_URL || "http://localhost:18790";
|
|
6
|
-
const GATEWAY_WS_URL = API_URL.replace(/^http/, "ws");
|
|
7
|
-
const GATEWAY_BRIDGE_URL = `${GATEWAY_WS_URL}/bridge-events`;
|
|
8
|
-
|
|
9
|
-
function generateId(): string {
|
|
10
|
-
return Math.random().toString(36).substring(2, 15);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
function createLog(level: BridgeLog["level"], message: string, processId: string = "system"): BridgeLog {
|
|
14
|
-
return {
|
|
15
|
-
id: generateId(),
|
|
16
|
-
processId,
|
|
17
|
-
level,
|
|
18
|
-
message,
|
|
19
|
-
timestamp: new Date().toISOString(),
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
interface BridgeState {
|
|
24
|
-
processes: BridgeProcess[];
|
|
25
|
-
logs: BridgeLog[];
|
|
26
|
-
isConnected: boolean;
|
|
27
|
-
socket: WebSocket | null;
|
|
28
|
-
gatewaySocket: WebSocket | null;
|
|
29
|
-
addProcess: (process: BridgeProcess) => void;
|
|
30
|
-
removeProcess: (id: string) => void;
|
|
31
|
-
updateProcess: (id: string, updates: Partial<BridgeProcess>) => void;
|
|
32
|
-
addLog: (log: BridgeLog) => void;
|
|
33
|
-
clearLogs: () => void;
|
|
34
|
-
connect: () => void;
|
|
35
|
-
disconnect: () => void;
|
|
36
|
-
sendCommand: (cmd: { cmd: string; [key: string]: unknown }) => void;
|
|
37
|
-
connectGateway: () => void;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export const useBridgeStore = create<BridgeState>((set, get) => ({
|
|
41
|
-
processes: [],
|
|
42
|
-
logs: [],
|
|
43
|
-
isConnected: false,
|
|
44
|
-
socket: null,
|
|
45
|
-
gatewaySocket: null,
|
|
46
|
-
|
|
47
|
-
addProcess: (process) => set((s) => ({ processes: [...s.processes, process] })),
|
|
48
|
-
removeProcess: (id) => set((s) => ({ processes: s.processes.filter((p) => p.id !== id) })),
|
|
49
|
-
updateProcess: (id, updates) =>
|
|
50
|
-
set((s) => ({
|
|
51
|
-
processes: s.processes.map((p) => (p.id === id ? { ...p, ...updates } : p)),
|
|
52
|
-
})),
|
|
53
|
-
addLog: (log) => set((s) => ({ logs: [log, ...s.logs].slice(0, 500) })),
|
|
54
|
-
clearLogs: () => set({ logs: [] }),
|
|
55
|
-
|
|
56
|
-
sendCommand: (cmd) => {
|
|
57
|
-
const { socket, isConnected } = get();
|
|
58
|
-
if (socket && isConnected) {
|
|
59
|
-
socket.send(JSON.stringify(cmd));
|
|
60
|
-
}
|
|
61
|
-
},
|
|
62
|
-
|
|
63
|
-
// Connect to the Code Bridge service (port 18791)
|
|
64
|
-
connect: () => {
|
|
65
|
-
const { socket: existingSocket, isConnected } = get();
|
|
66
|
-
if (existingSocket || isConnected) return;
|
|
67
|
-
|
|
68
|
-
try {
|
|
69
|
-
const ws = new WebSocket(CODE_BRIDGE_URL);
|
|
70
|
-
|
|
71
|
-
ws.onopen = () => {
|
|
72
|
-
set({ isConnected: true, socket: ws });
|
|
73
|
-
get().addLog(createLog("info", "Connected to Code Bridge"));
|
|
74
|
-
get().sendCommand({ cmd: "status" });
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
ws.onmessage = (event) => {
|
|
78
|
-
try {
|
|
79
|
-
const data = JSON.parse(event.data);
|
|
80
|
-
|
|
81
|
-
if (data.type === "code-bridge:status" && Array.isArray(data.agents)) {
|
|
82
|
-
const processes: BridgeProcess[] = data.agents.map((agent: { taskId: string; role: string; cli: string; pid: number; state: string }) => ({
|
|
83
|
-
id: agent.taskId,
|
|
84
|
-
name: agent.role,
|
|
85
|
-
command: agent.cli,
|
|
86
|
-
status: agent.state as BridgeProcess["status"],
|
|
87
|
-
pid: agent.pid,
|
|
88
|
-
startedAt: new Date().toISOString(),
|
|
89
|
-
output: [],
|
|
90
|
-
}));
|
|
91
|
-
set({ processes });
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
if (data.type === "agent:started") {
|
|
95
|
-
const newProcess: BridgeProcess = {
|
|
96
|
-
id: data.taskId,
|
|
97
|
-
name: data.role,
|
|
98
|
-
command: data.cli,
|
|
99
|
-
status: "running",
|
|
100
|
-
pid: data.pid,
|
|
101
|
-
startedAt: new Date().toISOString(),
|
|
102
|
-
output: [],
|
|
103
|
-
};
|
|
104
|
-
get().addProcess(newProcess);
|
|
105
|
-
get().addLog(createLog("info", `Agent started: ${data.role} (PID: ${data.pid})`, data.taskId));
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
if (data.type === "agent:output") {
|
|
109
|
-
const process = get().processes.find((p) => p.id === data.taskId);
|
|
110
|
-
if (process) {
|
|
111
|
-
get().updateProcess(data.taskId, { output: [...process.output, data.chunk] });
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
if (data.type === "agent:finished") {
|
|
116
|
-
get().updateProcess(data.taskId, { status: "completed" });
|
|
117
|
-
get().addLog(createLog("info", `Agent finished: ${data.role}`, data.taskId));
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
if (data.type === "agent:error") {
|
|
121
|
-
get().updateProcess(data.taskId, { status: "error" });
|
|
122
|
-
get().addLog(createLog("error", data.message, data.taskId));
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
if (data.type === "agent:cancelled") {
|
|
126
|
-
get().updateProcess(data.taskId, { status: "stopped" });
|
|
127
|
-
get().addLog(createLog("warn", `Agent cancelled: ${data.role}`, data.taskId));
|
|
128
|
-
}
|
|
129
|
-
} catch {
|
|
130
|
-
// Ignore non-JSON messages
|
|
131
|
-
}
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
ws.onerror = () => {
|
|
135
|
-
get().addLog(createLog("error", "Code Bridge WebSocket error"));
|
|
136
|
-
};
|
|
137
|
-
|
|
138
|
-
ws.onclose = () => {
|
|
139
|
-
set({ isConnected: false, socket: null });
|
|
140
|
-
get().addLog(createLog("info", "Disconnected from Code Bridge"));
|
|
141
|
-
setTimeout(() => {
|
|
142
|
-
if (!get().isConnected) get().connect();
|
|
143
|
-
}, 5000);
|
|
144
|
-
};
|
|
145
|
-
|
|
146
|
-
set({ socket: ws });
|
|
147
|
-
} catch {
|
|
148
|
-
set({ isConnected: false, socket: null });
|
|
149
|
-
}
|
|
150
|
-
},
|
|
151
|
-
|
|
152
|
-
// Connect to the gateway's /bridge-events endpoint to receive terminal events
|
|
153
|
-
connectGateway: () => {
|
|
154
|
-
const { gatewaySocket } = get();
|
|
155
|
-
if (gatewaySocket) return;
|
|
156
|
-
|
|
157
|
-
try {
|
|
158
|
-
const ws = new WebSocket(GATEWAY_BRIDGE_URL);
|
|
159
|
-
|
|
160
|
-
ws.onopen = () => {
|
|
161
|
-
get().addLog(createLog("info", "Connected to gateway bridge events"));
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
ws.onmessage = (event) => {
|
|
165
|
-
try {
|
|
166
|
-
const evt = JSON.parse(event.data);
|
|
167
|
-
|
|
168
|
-
if (evt.type === "bridge:cmd_start") {
|
|
169
|
-
const d = evt.data as { processId: string; command: string; cwd?: string; name?: string };
|
|
170
|
-
const newProcess: BridgeProcess = {
|
|
171
|
-
id: d.processId,
|
|
172
|
-
name: d.name ?? "terminal",
|
|
173
|
-
command: d.command,
|
|
174
|
-
status: "running",
|
|
175
|
-
pid: 0,
|
|
176
|
-
startedAt: new Date().toISOString(),
|
|
177
|
-
output: [],
|
|
178
|
-
};
|
|
179
|
-
get().addProcess(newProcess);
|
|
180
|
-
get().addLog(createLog("info", `$ ${d.command}${d.cwd ? ` (in ${d.cwd})` : ""}`, d.processId));
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
if (evt.type === "bridge:cmd_output") {
|
|
184
|
-
const d = evt.data as { processId: string; chunk: string; stream: string };
|
|
185
|
-
const process = get().processes.find((p) => p.id === d.processId);
|
|
186
|
-
if (process) {
|
|
187
|
-
get().updateProcess(d.processId, { output: [...process.output, d.chunk] });
|
|
188
|
-
}
|
|
189
|
-
get().addLog(createLog(d.stream === "stderr" ? "warn" : "info", d.chunk, d.processId));
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
if (evt.type === "bridge:cmd_done") {
|
|
193
|
-
const d = evt.data as { processId: string; exitCode: number; success: boolean };
|
|
194
|
-
get().updateProcess(d.processId, { status: d.success ? "completed" : "error" });
|
|
195
|
-
get().addLog(createLog(d.success ? "info" : "error", `Exit code: ${d.exitCode}`, d.processId));
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
if (evt.type === "bridge:cmd_error") {
|
|
199
|
-
const d = evt.data as { processId: string; message: string };
|
|
200
|
-
get().updateProcess(d.processId, { status: "error" });
|
|
201
|
-
get().addLog(createLog("error", d.message, d.processId));
|
|
202
|
-
}
|
|
203
|
-
} catch {
|
|
204
|
-
// Ignore non-JSON
|
|
205
|
-
}
|
|
206
|
-
};
|
|
207
|
-
|
|
208
|
-
ws.onerror = () => {
|
|
209
|
-
// Gateway may not be available immediately
|
|
210
|
-
};
|
|
211
|
-
|
|
212
|
-
ws.onclose = () => {
|
|
213
|
-
set({ gatewaySocket: null });
|
|
214
|
-
// Reconnect after 5 seconds
|
|
215
|
-
setTimeout(() => {
|
|
216
|
-
if (!get().gatewaySocket) get().connectGateway();
|
|
217
|
-
}, 5000);
|
|
218
|
-
};
|
|
219
|
-
|
|
220
|
-
set({ gatewaySocket: ws });
|
|
221
|
-
} catch {
|
|
222
|
-
set({ gatewaySocket: null });
|
|
223
|
-
}
|
|
224
|
-
},
|
|
225
|
-
|
|
226
|
-
disconnect: () => {
|
|
227
|
-
const { socket, gatewaySocket } = get();
|
|
228
|
-
if (socket) {
|
|
229
|
-
socket.close();
|
|
230
|
-
set({ socket: null, isConnected: false });
|
|
231
|
-
}
|
|
232
|
-
if (gatewaySocket) {
|
|
233
|
-
gatewaySocket.close();
|
|
234
|
-
set({ gatewaySocket: null });
|
|
235
|
-
}
|
|
236
|
-
},
|
|
237
|
-
}));
|
|
@@ -1,250 +0,0 @@
|
|
|
1
|
-
import { create } from "zustand";
|
|
2
|
-
import type { CanvasComponent } from "@/types/canvas";
|
|
3
|
-
|
|
4
|
-
export interface GraphNode {
|
|
5
|
-
id: string;
|
|
6
|
-
name: string;
|
|
7
|
-
type: "agent" | "mcp" | "project" | "task";
|
|
8
|
-
status: string;
|
|
9
|
-
data?: Record<string, unknown>;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export interface GraphEdge {
|
|
13
|
-
id: string;
|
|
14
|
-
source: string;
|
|
15
|
-
target: string;
|
|
16
|
-
edgeType: string;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
interface GatewayMessage {
|
|
20
|
-
type: string;
|
|
21
|
-
sessionId?: string;
|
|
22
|
-
component?: CanvasComponent;
|
|
23
|
-
componentId?: string;
|
|
24
|
-
data?: {
|
|
25
|
-
nodes?: GraphNode[];
|
|
26
|
-
edges?: GraphEdge[];
|
|
27
|
-
id?: string;
|
|
28
|
-
[key: string]: unknown;
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
interface CanvasState {
|
|
33
|
-
ws: WebSocket | null;
|
|
34
|
-
components: CanvasComponent[];
|
|
35
|
-
selectedComponentId: string | null;
|
|
36
|
-
sessionId: string | null;
|
|
37
|
-
isConnected: boolean;
|
|
38
|
-
graphNodes: GraphNode[];
|
|
39
|
-
graphEdges: GraphEdge[];
|
|
40
|
-
|
|
41
|
-
// Actions
|
|
42
|
-
setComponents: (components: CanvasComponent[]) => void;
|
|
43
|
-
addComponent: (component: CanvasComponent) => void;
|
|
44
|
-
removeComponent: (id: string) => void;
|
|
45
|
-
selectComponent: (id: string | null) => void;
|
|
46
|
-
setSessionId: (id: string | null) => void;
|
|
47
|
-
setIsConnected: (connected: boolean) => void;
|
|
48
|
-
setGraphSnapshot: (nodes: GraphNode[], edges: GraphEdge[]) => void;
|
|
49
|
-
addGraphNode: (node: GraphNode) => void;
|
|
50
|
-
updateGraphNode: (id: string, updates: Partial<GraphNode>) => void;
|
|
51
|
-
removeGraphNode: (id: string) => void;
|
|
52
|
-
addGraphEdge: (edge: GraphEdge) => void;
|
|
53
|
-
|
|
54
|
-
// Connection management
|
|
55
|
-
connect: (sessionId: string, userId?: string | null) => void;
|
|
56
|
-
disconnect: () => void;
|
|
57
|
-
sendMessage: (message: any) => void;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
let heartbeatInterval: ReturnType<typeof setInterval> | null = null;
|
|
61
|
-
|
|
62
|
-
export const useCanvasStore = create<CanvasState>((set, get) => ({
|
|
63
|
-
ws: null,
|
|
64
|
-
components: [],
|
|
65
|
-
selectedComponentId: null,
|
|
66
|
-
sessionId: null,
|
|
67
|
-
isConnected: false,
|
|
68
|
-
graphNodes: [],
|
|
69
|
-
graphEdges: [],
|
|
70
|
-
|
|
71
|
-
setComponents: (components) => set({ components }),
|
|
72
|
-
addComponent: (component) => set((s) => ({ components: [...s.components, component] })),
|
|
73
|
-
removeComponent: (id) => set((s) => ({ components: s.components.filter((c) => c.id !== id) })),
|
|
74
|
-
selectComponent: (id) => set({ selectedComponentId: id }),
|
|
75
|
-
setSessionId: (id) => set({ sessionId: id }),
|
|
76
|
-
setIsConnected: (connected) => set({ isConnected: connected }),
|
|
77
|
-
setGraphSnapshot: (nodes, edges) => set({ graphNodes: nodes, graphEdges: edges }),
|
|
78
|
-
|
|
79
|
-
addGraphNode: (node) =>
|
|
80
|
-
set((s) => {
|
|
81
|
-
const existing = s.graphNodes.find((n) => n.id === node.id);
|
|
82
|
-
if (existing) {
|
|
83
|
-
return { graphNodes: s.graphNodes.map((n) => (n.id === node.id ? node : n)) };
|
|
84
|
-
}
|
|
85
|
-
return { graphNodes: [...s.graphNodes, node] };
|
|
86
|
-
}),
|
|
87
|
-
|
|
88
|
-
updateGraphNode: (id, updates) =>
|
|
89
|
-
set((s) => ({
|
|
90
|
-
graphNodes: s.graphNodes.map((n) => (n.id === id ? { ...n, ...updates } : n)),
|
|
91
|
-
})),
|
|
92
|
-
|
|
93
|
-
removeGraphNode: (id) =>
|
|
94
|
-
set((s) => ({
|
|
95
|
-
graphNodes: s.graphNodes.filter((n) => n.id !== id),
|
|
96
|
-
graphEdges: s.graphEdges.filter((e) => e.source !== id && e.target !== id),
|
|
97
|
-
})),
|
|
98
|
-
|
|
99
|
-
addGraphEdge: (edge) =>
|
|
100
|
-
set((s) => {
|
|
101
|
-
const existing = s.graphEdges.find((e) => e.id === edge.id);
|
|
102
|
-
if (existing) return s;
|
|
103
|
-
return { graphEdges: [...s.graphEdges, edge] };
|
|
104
|
-
}),
|
|
105
|
-
|
|
106
|
-
connect: (sessionId, userId) => {
|
|
107
|
-
const currentState = get();
|
|
108
|
-
|
|
109
|
-
// Si ya está conectado a la misma sesión, no hacer nada
|
|
110
|
-
if (currentState.ws && currentState.sessionId === sessionId && currentState.ws.readyState === WebSocket.OPEN) {
|
|
111
|
-
console.log(`[CanvasStore] Already connected to session: ${sessionId}`);
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
// Si hay una conexión previa diferente, cerrarla
|
|
116
|
-
if (currentState.ws) {
|
|
117
|
-
console.log(`[CanvasStore] Closing previous connection for session: ${currentState.sessionId}`);
|
|
118
|
-
currentState.disconnect();
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
const API_URL = import.meta.env.VITE_API_URL || "http://localhost:18790";
|
|
122
|
-
const GATEWAY_WS_URL = API_URL.replace(/^http/, "ws");
|
|
123
|
-
const wsUrl = `${GATEWAY_WS_URL}/canvas?sessionId=${encodeURIComponent(sessionId)}`;
|
|
124
|
-
|
|
125
|
-
console.log(`[CanvasStore] Connecting to ${wsUrl}`);
|
|
126
|
-
const socket = new WebSocket(wsUrl);
|
|
127
|
-
|
|
128
|
-
socket.onopen = () => {
|
|
129
|
-
console.log(`[CanvasStore] Connected with sessionId: ${sessionId}`);
|
|
130
|
-
set({ isConnected: true, sessionId, ws: socket });
|
|
131
|
-
|
|
132
|
-
// Handshake
|
|
133
|
-
socket.send(JSON.stringify({
|
|
134
|
-
type: "canvas:handshake",
|
|
135
|
-
sessionId,
|
|
136
|
-
userId: userId || null,
|
|
137
|
-
client: "hive-ui",
|
|
138
|
-
version: "1.0"
|
|
139
|
-
}));
|
|
140
|
-
|
|
141
|
-
// Heartbeat every 30s
|
|
142
|
-
if (heartbeatInterval) clearInterval(heartbeatInterval);
|
|
143
|
-
heartbeatInterval = setInterval(() => {
|
|
144
|
-
if (socket.readyState === WebSocket.OPEN) {
|
|
145
|
-
socket.send(JSON.stringify({ type: "canvas:ping", sessionId }));
|
|
146
|
-
}
|
|
147
|
-
}, 30000);
|
|
148
|
-
};
|
|
149
|
-
|
|
150
|
-
socket.onmessage = (event) => {
|
|
151
|
-
try {
|
|
152
|
-
const message = JSON.parse(event.data) as GatewayMessage;
|
|
153
|
-
|
|
154
|
-
if (message.type === "canvas:pong") return;
|
|
155
|
-
|
|
156
|
-
if (message.type === "canvas:render" || message.type === "canvas:update") {
|
|
157
|
-
// emitCanvas wraps payload in { type, data, timestamp } — component lives in data
|
|
158
|
-
const component = (message.data?.component ?? message.component) as CanvasComponent | undefined;
|
|
159
|
-
if (component) {
|
|
160
|
-
set((s) => {
|
|
161
|
-
const existing = s.components.find((c) => c.id === component.id);
|
|
162
|
-
if (existing) {
|
|
163
|
-
return { components: s.components.map(c => c.id === component.id ? component : c) };
|
|
164
|
-
}
|
|
165
|
-
return { components: [...s.components, component] };
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
} else if (message.type === "canvas:clear") {
|
|
169
|
-
set({ components: [] });
|
|
170
|
-
} else if (message.type === "canvas:snapshot") {
|
|
171
|
-
const d = message.data;
|
|
172
|
-
if (d && Array.isArray(d.nodes) && Array.isArray(d.edges)) {
|
|
173
|
-
set({ graphNodes: d.nodes as GraphNode[], graphEdges: d.edges as GraphEdge[] });
|
|
174
|
-
}
|
|
175
|
-
} else if (message.type === "canvas:node_add") {
|
|
176
|
-
const raw = message.data as Record<string, unknown>;
|
|
177
|
-
if (raw?.id) {
|
|
178
|
-
const subData = (raw.data as Record<string, unknown>) ?? {};
|
|
179
|
-
const node: GraphNode = {
|
|
180
|
-
id: raw.id as string,
|
|
181
|
-
type: raw.type as GraphNode["type"],
|
|
182
|
-
name: (raw.label ?? raw.name ?? raw.id) as string,
|
|
183
|
-
status: (subData.status ?? raw.status ?? "pending") as string,
|
|
184
|
-
data: subData,
|
|
185
|
-
};
|
|
186
|
-
get().addGraphNode(node);
|
|
187
|
-
}
|
|
188
|
-
} else if (message.type === "canvas:node_update") {
|
|
189
|
-
const d = message.data as Record<string, unknown>;
|
|
190
|
-
const nodeId = (d?.id ?? d?.nodeId) as string;
|
|
191
|
-
if (nodeId) {
|
|
192
|
-
const subData = (d.data ?? d.changes) as Record<string, unknown> ?? {};
|
|
193
|
-
const updates: Partial<GraphNode> = {};
|
|
194
|
-
if (subData.status) updates.status = subData.status as string;
|
|
195
|
-
// Merge existing data with new data/changes
|
|
196
|
-
updates.data = subData;
|
|
197
|
-
get().updateGraphNode(nodeId, updates);
|
|
198
|
-
}
|
|
199
|
-
} else if (message.type === "canvas:node_remove") {
|
|
200
|
-
const d = message.data;
|
|
201
|
-
if (d?.id) get().removeGraphNode(d.id as string);
|
|
202
|
-
} else if (message.type === "canvas:edge_add") {
|
|
203
|
-
const edge = message.data as unknown as GraphEdge;
|
|
204
|
-
if (edge?.id) get().addGraphEdge(edge);
|
|
205
|
-
}
|
|
206
|
-
} catch (e) {
|
|
207
|
-
console.error("[CanvasStore] Parse error:", e);
|
|
208
|
-
}
|
|
209
|
-
};
|
|
210
|
-
|
|
211
|
-
socket.onerror = (error) => {
|
|
212
|
-
console.error("[CanvasStore] WebSocket error:", error);
|
|
213
|
-
set({ isConnected: false });
|
|
214
|
-
};
|
|
215
|
-
|
|
216
|
-
socket.onclose = (event) => {
|
|
217
|
-
console.log("[CanvasStore] Disconnected:", event.code, event.reason);
|
|
218
|
-
set({ isConnected: false, ws: null });
|
|
219
|
-
|
|
220
|
-
if (heartbeatInterval) {
|
|
221
|
-
clearInterval(heartbeatInterval);
|
|
222
|
-
heartbeatInterval = null;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
// Auto-reconnect after 3 seconds if not intentionally closed
|
|
226
|
-
if (event.code !== 1000 && event.code !== 1001) {
|
|
227
|
-
setTimeout(() => get().connect(sessionId, userId), 3000);
|
|
228
|
-
}
|
|
229
|
-
};
|
|
230
|
-
},
|
|
231
|
-
|
|
232
|
-
disconnect: () => {
|
|
233
|
-
const { ws } = get();
|
|
234
|
-
if (ws) {
|
|
235
|
-
ws.close(1000, "Intentional disconnect");
|
|
236
|
-
set({ ws: null, isConnected: false });
|
|
237
|
-
}
|
|
238
|
-
if (heartbeatInterval) {
|
|
239
|
-
clearInterval(heartbeatInterval);
|
|
240
|
-
heartbeatInterval = null;
|
|
241
|
-
}
|
|
242
|
-
},
|
|
243
|
-
|
|
244
|
-
sendMessage: (message) => {
|
|
245
|
-
const { ws, isConnected } = get();
|
|
246
|
-
if (ws && isConnected && ws.readyState === WebSocket.OPEN) {
|
|
247
|
-
ws.send(JSON.stringify(message));
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
}));
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { create } from "zustand";
|
|
2
|
-
import type { Message } from "@/types";
|
|
3
|
-
|
|
4
|
-
interface ChatState {
|
|
5
|
-
messages: Message[];
|
|
6
|
-
isLoading: boolean;
|
|
7
|
-
currentSteps: string[];
|
|
8
|
-
addMessage: (message: Message) => void;
|
|
9
|
-
addMessages: (messages: Message[]) => void;
|
|
10
|
-
updateMessage: (id: string, updates: Partial<Message>) => void;
|
|
11
|
-
setMessages: (messages: Message[]) => void;
|
|
12
|
-
clearMessages: () => void;
|
|
13
|
-
setLoading: (loading: boolean) => void;
|
|
14
|
-
addStep: (step: string) => void;
|
|
15
|
-
clearSteps: () => void;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export const useChatStore = create<ChatState>((set) => ({
|
|
19
|
-
messages: [],
|
|
20
|
-
isLoading: false,
|
|
21
|
-
currentSteps: [],
|
|
22
|
-
addMessage: (message) =>
|
|
23
|
-
set((state) => ({
|
|
24
|
-
messages: [...state.messages, message],
|
|
25
|
-
})),
|
|
26
|
-
addMessages: (messages) =>
|
|
27
|
-
set((state) => ({
|
|
28
|
-
messages: [...state.messages, ...messages],
|
|
29
|
-
})),
|
|
30
|
-
updateMessage: (id, updates) =>
|
|
31
|
-
set((state) => ({
|
|
32
|
-
messages: state.messages.map((m) => (m.id === id ? { ...m, ...updates } : m)),
|
|
33
|
-
})),
|
|
34
|
-
setMessages: (messages) => set({ messages }),
|
|
35
|
-
clearMessages: () => set({ messages: [] }),
|
|
36
|
-
setLoading: (loading) => set({ isLoading: loading }),
|
|
37
|
-
addStep: (step) =>
|
|
38
|
-
set((state) => ({
|
|
39
|
-
currentSteps: [...state.currentSteps.slice(-4), step], // keep last 5
|
|
40
|
-
})),
|
|
41
|
-
clearSteps: () => set({ currentSteps: [] }),
|
|
42
|
-
}));
|