@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,190 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bun
|
|
2
|
-
import { onboard } from "./commands/onboard";
|
|
3
|
-
import { start, stop, status, reload } from "./commands/gateway";
|
|
4
|
-
import { dev } from "./commands/dev";
|
|
5
|
-
import { agents } from "./commands/agents";
|
|
6
|
-
import { mcp } from "./commands/mcp";
|
|
7
|
-
import { skills } from "./commands/skills";
|
|
8
|
-
import { config } from "./commands/config";
|
|
9
|
-
import { logs } from "./commands/logs";
|
|
10
|
-
import { chat } from "./commands/chat";
|
|
11
|
-
import { sessions } from "./commands/sessions";
|
|
12
|
-
import { cron } from "./commands/cron";
|
|
13
|
-
import { doctor } from "./commands/doctor";
|
|
14
|
-
import { securityAudit } from "./commands/security";
|
|
15
|
-
import { installService } from "./commands/service";
|
|
16
|
-
import { update } from "./commands/update";
|
|
17
|
-
import { message } from "./commands/message";
|
|
18
|
-
import { agent } from "./commands/agent-run";
|
|
19
|
-
|
|
20
|
-
const VERSION = "1.7.2";
|
|
21
|
-
|
|
22
|
-
const HELP = `
|
|
23
|
-
🐝 Hive — Personal Swarm AI Gateway v${VERSION}
|
|
24
|
-
|
|
25
|
-
Usage: hive <command> [subcommand] [options]
|
|
26
|
-
|
|
27
|
-
Commands:
|
|
28
|
-
onboard Wizard de configuración inicial
|
|
29
|
-
dev Modo desarrollo (onboard + start)
|
|
30
|
-
start [--daemon] Arrancar el Gateway
|
|
31
|
-
stop Detener el Gateway
|
|
32
|
-
reload Recargar config sin reiniciar
|
|
33
|
-
status Estado del Gateway y agentes
|
|
34
|
-
chat [--agent <id>] Chat directo en terminal
|
|
35
|
-
logs [--follow] [--level] Ver logs del Gateway
|
|
36
|
-
|
|
37
|
-
message send --to <id> --content <text>
|
|
38
|
-
Enviar mensaje por canal
|
|
39
|
-
agent run --message <text> Ejecutar agente con mensaje
|
|
40
|
-
|
|
41
|
-
agents add <id> Crear nuevo agente
|
|
42
|
-
agents list [--bindings] Listar agentes
|
|
43
|
-
agents remove <id> Eliminar agente
|
|
44
|
-
|
|
45
|
-
mcp list Listar servidores MCP
|
|
46
|
-
mcp add Añadir servidor MCP
|
|
47
|
-
mcp test <nombre> Verificar servidor MCP
|
|
48
|
-
mcp tools <nombre> Listar tools de un servidor
|
|
49
|
-
mcp remove <nombre> Eliminar servidor MCP
|
|
50
|
-
|
|
51
|
-
skills list Listar skills instaladas
|
|
52
|
-
skills search <query> Buscar skills
|
|
53
|
-
skills install <slug> Instalar skill
|
|
54
|
-
skills remove <nombre> Eliminar skill
|
|
55
|
-
skills update Actualizar skills
|
|
56
|
-
|
|
57
|
-
config get <key> Leer valor de config
|
|
58
|
-
config set <key> <value> Escribir valor de config
|
|
59
|
-
config show Mostrar config completa
|
|
60
|
-
|
|
61
|
-
sessions list Listar sesiones
|
|
62
|
-
sessions view <id> Ver transcripción
|
|
63
|
-
sessions prune Eliminar sesiones inactivas
|
|
64
|
-
|
|
65
|
-
cron list Listar cron jobs
|
|
66
|
-
cron add Añadir cron job
|
|
67
|
-
cron remove <id> Eliminar cron job
|
|
68
|
-
cron logs Ver logs de cron
|
|
69
|
-
|
|
70
|
-
doctor Diagnóstico y auto-reparación
|
|
71
|
-
security audit Auditoría de seguridad
|
|
72
|
-
install-service Instalar servicio systemd
|
|
73
|
-
update Actualizar Hive
|
|
74
|
-
|
|
75
|
-
Options:
|
|
76
|
-
--help, -h Mostrar ayuda
|
|
77
|
-
--version, -v Mostrar versión
|
|
78
|
-
|
|
79
|
-
Examples:
|
|
80
|
-
hive onboard Configurar Hive por primera vez
|
|
81
|
-
hive start Arrancar el Gateway
|
|
82
|
-
hive chat Chatear con el agente en terminal
|
|
83
|
-
hive message send --to 123 --content "Hola"
|
|
84
|
-
hive agent run --message "Analiza README.md" --wait
|
|
85
|
-
hive agents add work Crear agente "work"
|
|
86
|
-
hive mcp add Añadir servidor MCP
|
|
87
|
-
hive doctor Diagnosticar problemas
|
|
88
|
-
|
|
89
|
-
Documentation:
|
|
90
|
-
English: https://github.com/johpaz/hive/docs
|
|
91
|
-
Español: https://github.com/johpaz/hive/docs/es
|
|
92
|
-
`;
|
|
93
|
-
|
|
94
|
-
async function main(): Promise<void> {
|
|
95
|
-
// In compiled Bun binaries, process.argv is [binaryPath, arg0, arg1, ...]
|
|
96
|
-
// In dev mode (bun run script.ts), it is [bun, scriptPath, arg0, arg1, ...]
|
|
97
|
-
// We detect compiled mode by checking if argv[1] looks like a command (no path separator)
|
|
98
|
-
const isCompiled = !process.argv[1]?.includes("/") && !process.argv[1]?.endsWith(".ts");
|
|
99
|
-
const args = process.argv.slice(isCompiled ? 1 : 2);
|
|
100
|
-
const command = args[0];
|
|
101
|
-
const subcommand = args[1];
|
|
102
|
-
const flags = args.filter((a) => a.startsWith("--"));
|
|
103
|
-
|
|
104
|
-
switch (command) {
|
|
105
|
-
case "onboard":
|
|
106
|
-
await onboard();
|
|
107
|
-
break;
|
|
108
|
-
case "dev":
|
|
109
|
-
await dev();
|
|
110
|
-
break;
|
|
111
|
-
case "start":
|
|
112
|
-
await start(flags);
|
|
113
|
-
break;
|
|
114
|
-
case "stop":
|
|
115
|
-
await stop();
|
|
116
|
-
break;
|
|
117
|
-
case "reload":
|
|
118
|
-
await reload();
|
|
119
|
-
break;
|
|
120
|
-
case "status":
|
|
121
|
-
await status(flags);
|
|
122
|
-
break;
|
|
123
|
-
case "chat":
|
|
124
|
-
await chat(flags);
|
|
125
|
-
break;
|
|
126
|
-
case "logs":
|
|
127
|
-
await logs(flags);
|
|
128
|
-
break;
|
|
129
|
-
case "message":
|
|
130
|
-
await message(subcommand, args.slice(2));
|
|
131
|
-
break;
|
|
132
|
-
case "agent":
|
|
133
|
-
await agent(subcommand, args.slice(2));
|
|
134
|
-
break;
|
|
135
|
-
case "agents":
|
|
136
|
-
await agents(subcommand, args.slice(2));
|
|
137
|
-
break;
|
|
138
|
-
case "mcp":
|
|
139
|
-
await mcp(subcommand, args.slice(2));
|
|
140
|
-
break;
|
|
141
|
-
case "skills":
|
|
142
|
-
await skills(subcommand, args.slice(2));
|
|
143
|
-
break;
|
|
144
|
-
case "config":
|
|
145
|
-
await config(subcommand, args.slice(2));
|
|
146
|
-
break;
|
|
147
|
-
case "sessions":
|
|
148
|
-
await sessions(subcommand, args.slice(2));
|
|
149
|
-
break;
|
|
150
|
-
case "cron":
|
|
151
|
-
await cron(subcommand, args.slice(2));
|
|
152
|
-
break;
|
|
153
|
-
case "doctor":
|
|
154
|
-
await doctor();
|
|
155
|
-
break;
|
|
156
|
-
case "security":
|
|
157
|
-
if (subcommand === "audit") {
|
|
158
|
-
await securityAudit();
|
|
159
|
-
} else {
|
|
160
|
-
console.log("Usage: hive security audit");
|
|
161
|
-
}
|
|
162
|
-
break;
|
|
163
|
-
case "install-service":
|
|
164
|
-
await installService();
|
|
165
|
-
break;
|
|
166
|
-
case "update":
|
|
167
|
-
await update();
|
|
168
|
-
break;
|
|
169
|
-
case "--version":
|
|
170
|
-
case "-v":
|
|
171
|
-
case "version":
|
|
172
|
-
console.log(`Hive v${VERSION}`);
|
|
173
|
-
break;
|
|
174
|
-
case "--help":
|
|
175
|
-
case "-h":
|
|
176
|
-
case "help":
|
|
177
|
-
case undefined:
|
|
178
|
-
console.log(HELP);
|
|
179
|
-
break;
|
|
180
|
-
default:
|
|
181
|
-
console.error(`❌ Comando desconocido: "${command}"\n`);
|
|
182
|
-
console.log(HELP);
|
|
183
|
-
process.exit(1);
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
main().catch((error) => {
|
|
188
|
-
console.error("Fatal error:", error.message);
|
|
189
|
-
process.exit(1);
|
|
190
|
-
});
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
# @johpaz/hive-code-bridge
|
|
2
|
-
|
|
3
|
-
Code Bridge for the Hive ecosystem. Exposes a **local WebSocket mesh** (via `Bun.serve`) that spawns and supervises CLI AI tools (e.g. `opencode`, `gemini`, `qwen`) as child processes, streaming their output and telemetry to any connected dashboard client.
|
|
4
|
-
|
|
5
|
-
## Architecture
|
|
6
|
-
|
|
7
|
-
```
|
|
8
|
-
Dashboard (Angular) ──WS──► @johpaz/hive-code-bridge ──Bun.spawn──► CLI tool (opencode / gemini / qwen…)
|
|
9
|
-
◄──WS──── telemetry events (stdout chunks, progress, tokens)
|
|
10
|
-
```
|
|
11
|
-
|
|
12
|
-
## Files
|
|
13
|
-
|
|
14
|
-
| File | Purpose |
|
|
15
|
-
|---|---|
|
|
16
|
-
| `src/index.ts` | Bun.serve entry point — HTTP health + WebSocket handler |
|
|
17
|
-
| `src/schemas.ts` | Zod schemas: `AgentRole`, `SubagentConfig`, `TelemetryEvent`, `DashboardCommand` |
|
|
18
|
-
| `src/process-manager.ts` | Spawns/kills processes, streams stdout/stderr, parses `HIVE_PROGRESS` and `HIVE_TOKENS` hints |
|
|
19
|
-
|
|
20
|
-
## Running
|
|
21
|
-
|
|
22
|
-
```bash
|
|
23
|
-
# From the monorepo root:
|
|
24
|
-
bun run packages/code-bridge/src/index.ts
|
|
25
|
-
|
|
26
|
-
# Or from this package:
|
|
27
|
-
bun run src/index.ts
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
Server starts on `ws://localhost:18791` by default (`CODE_BRIDGE_PORT` env override).
|
|
31
|
-
|
|
32
|
-
## WebSocket Protocol
|
|
33
|
-
|
|
34
|
-
### Dashboard → Code Bridge
|
|
35
|
-
|
|
36
|
-
```jsonc
|
|
37
|
-
// Launch a CLI subagent
|
|
38
|
-
{ "cmd": "launch", "taskId": "uuid", "prompt": "Refactor auth module", "config": { "role": "development", "cli": "opencode" } }
|
|
39
|
-
|
|
40
|
-
// Cancel a running agent
|
|
41
|
-
{ "cmd": "cancel", "taskId": "uuid" }
|
|
42
|
-
|
|
43
|
-
// Request current status snapshot
|
|
44
|
-
{ "cmd": "status" }
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
### Code Bridge → Dashboard (broadcast)
|
|
48
|
-
|
|
49
|
-
| Event type | Description |
|
|
50
|
-
|---|---|
|
|
51
|
-
| `code-bridge:status` | Full snapshot of all agents (sent on connect and on `status` command) |
|
|
52
|
-
| `agent:started` | Process PID and CLI tool |
|
|
53
|
-
| `agent:output` | stdout/stderr chunk |
|
|
54
|
-
| `agent:progress` | 0–100 percent (from `HIVE_PROGRESS:<n>` in stdout) |
|
|
55
|
-
| `agent:token_usage` | Token counters + model (from `HIVE_TOKENS:input=<n>,output=<n>,model=<name>`) |
|
|
56
|
-
| `agent:finished` | Exit code |
|
|
57
|
-
| `agent:cancelled` | Cancelled by dashboard |
|
|
58
|
-
| `agent:error` | Non-zero exit or spawn error |
|
|
59
|
-
|
|
60
|
-
## HIVE Protocol Hints
|
|
61
|
-
|
|
62
|
-
CLI tools can emit structured hints in their stdout to feed the dashboard:
|
|
63
|
-
|
|
64
|
-
```
|
|
65
|
-
HIVE_PROGRESS:42
|
|
66
|
-
HIVE_TOKENS:input=1200,output=350,model=gemini-2.0-flash
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
## Tests
|
|
70
|
-
|
|
71
|
-
```bash
|
|
72
|
-
bun test src/schemas.test.ts
|
|
73
|
-
bun test src/process-manager.test.ts
|
|
74
|
-
# or all at once:
|
|
75
|
-
bun test
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
Tests cover: schema validation, launch/cancel lifecycle, stdout streaming, progress/token hint parsing.
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@johpaz/hive-code-bridge",
|
|
3
|
-
"version": "1.7.2",
|
|
4
|
-
"private": true,
|
|
5
|
-
"description": "Code Bridge - Bridge between CLI tools and Dashboard via WebSocket",
|
|
6
|
-
"type": "module",
|
|
7
|
-
"main": "src/index.ts",
|
|
8
|
-
"scripts": {
|
|
9
|
-
"dev": "bun run src/index.ts"
|
|
10
|
-
},
|
|
11
|
-
"dependencies": {
|
|
12
|
-
"@johpaz/hive-mcp": "^1.7.2",
|
|
13
|
-
"zod": "^4.3.6"
|
|
14
|
-
},
|
|
15
|
-
"peerDependencies": {
|
|
16
|
-
"@johpaz/hive-core": "^1.7.2"
|
|
17
|
-
}
|
|
18
|
-
}
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import { ProcessManager } from "./process-manager.ts";
|
|
2
|
-
import { DashboardCommand } from "./schemas.ts";
|
|
3
|
-
|
|
4
|
-
const CODE_BRIDGE_PORT = parseInt(process.env.CODE_BRIDGE_PORT ?? "18791", 10);
|
|
5
|
-
|
|
6
|
-
const manager = new ProcessManager();
|
|
7
|
-
|
|
8
|
-
const server = Bun.serve<{ id: string }>({
|
|
9
|
-
port: CODE_BRIDGE_PORT,
|
|
10
|
-
|
|
11
|
-
// ── HTTP routes ──────────────────────────────────────────────────────────
|
|
12
|
-
fetch(req, server) {
|
|
13
|
-
const url = new URL(req.url);
|
|
14
|
-
|
|
15
|
-
// Upgrade WebSocket connections
|
|
16
|
-
if (url.pathname === "/ws") {
|
|
17
|
-
const id = crypto.randomUUID();
|
|
18
|
-
const upgraded = server.upgrade(req, { data: { id } });
|
|
19
|
-
if (upgraded) return undefined;
|
|
20
|
-
return new Response("WebSocket upgrade failed", { status: 400 });
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
// Simple REST ping
|
|
24
|
-
if (url.pathname === "/health") {
|
|
25
|
-
return new Response(JSON.stringify({ ok: true, port: CODE_BRIDGE_PORT }), {
|
|
26
|
-
headers: { "Content-Type": "application/json" },
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// Status snapshot (REST fallback for the dashboard initial load)
|
|
31
|
-
if (url.pathname === "/status") {
|
|
32
|
-
return new Response(JSON.stringify(manager.status()), {
|
|
33
|
-
headers: { "Content-Type": "application/json" },
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
return new Response("Not found", { status: 404 });
|
|
38
|
-
},
|
|
39
|
-
|
|
40
|
-
// ── WebSocket handlers ───────────────────────────────────────────────────
|
|
41
|
-
websocket: {
|
|
42
|
-
open(ws) {
|
|
43
|
-
manager.subscribe(ws);
|
|
44
|
-
// Immediately send the current snapshot to the newly connected client
|
|
45
|
-
ws.send(JSON.stringify(manager.status()));
|
|
46
|
-
},
|
|
47
|
-
|
|
48
|
-
async message(ws, raw) {
|
|
49
|
-
let parsed: unknown;
|
|
50
|
-
try {
|
|
51
|
-
parsed = JSON.parse(typeof raw === "string" ? raw : new TextDecoder().decode(raw));
|
|
52
|
-
} catch {
|
|
53
|
-
ws.send(JSON.stringify({ type: "error", message: "Invalid JSON" }));
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
const cmd = DashboardCommand.safeParse(parsed);
|
|
58
|
-
if (!cmd.success) {
|
|
59
|
-
ws.send(JSON.stringify({ type: "error", message: cmd.error.message }));
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
const command = cmd.data;
|
|
64
|
-
|
|
65
|
-
switch (command.cmd) {
|
|
66
|
-
case "launch": {
|
|
67
|
-
try {
|
|
68
|
-
const pid = await manager.launch(command.taskId, command.config, command.prompt);
|
|
69
|
-
ws.send(JSON.stringify({ type: "ack", cmd: "launch", taskId: command.taskId, pid }));
|
|
70
|
-
} catch (err: any) {
|
|
71
|
-
ws.send(JSON.stringify({ type: "error", message: err.message }));
|
|
72
|
-
}
|
|
73
|
-
break;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
case "cancel": {
|
|
77
|
-
const ok = manager.cancel(command.taskId);
|
|
78
|
-
ws.send(JSON.stringify({ type: "ack", cmd: "cancel", taskId: command.taskId, ok }));
|
|
79
|
-
break;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
case "status": {
|
|
83
|
-
ws.send(JSON.stringify(manager.status()));
|
|
84
|
-
break;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
},
|
|
88
|
-
|
|
89
|
-
close(ws) {
|
|
90
|
-
manager.unsubscribe(ws);
|
|
91
|
-
},
|
|
92
|
-
},
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
console.log(`🌉 Hive Code Bridge running on ws://localhost:${server.port}`);
|
|
@@ -1,212 +0,0 @@
|
|
|
1
|
-
import type { ServerWebSocket } from "bun";
|
|
2
|
-
import type { SubagentConfig, TelemetryEvent } from "./schemas.ts";
|
|
3
|
-
import { AgentRole } from "./schemas.ts";
|
|
4
|
-
|
|
5
|
-
/** Live record of a running subagent process */
|
|
6
|
-
interface AgentRecord {
|
|
7
|
-
taskId: string;
|
|
8
|
-
config: SubagentConfig;
|
|
9
|
-
pid: number;
|
|
10
|
-
proc: ReturnType<typeof Bun.spawn>;
|
|
11
|
-
state: "running" | "finished" | "cancelled" | "error";
|
|
12
|
-
progress: number;
|
|
13
|
-
tokens: { input: number; output: number };
|
|
14
|
-
model?: string;
|
|
15
|
-
startedAt: number;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
type WsData = { id: string };
|
|
19
|
-
|
|
20
|
-
export class ProcessManager {
|
|
21
|
-
private agents = new Map<string, AgentRecord>();
|
|
22
|
-
private sockets = new Set<ServerWebSocket<WsData>>();
|
|
23
|
-
|
|
24
|
-
// ── Socket subscription ──────────────────────────────────────────────────
|
|
25
|
-
|
|
26
|
-
subscribe(ws: ServerWebSocket<WsData>) {
|
|
27
|
-
this.sockets.add(ws);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
unsubscribe(ws: ServerWebSocket<WsData>) {
|
|
31
|
-
this.sockets.delete(ws);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
private broadcast(event: TelemetryEvent) {
|
|
35
|
-
const payload = JSON.stringify(event);
|
|
36
|
-
for (const ws of this.sockets) {
|
|
37
|
-
try {
|
|
38
|
-
ws.send(payload);
|
|
39
|
-
} catch {
|
|
40
|
-
this.sockets.delete(ws);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// ── Launch ───────────────────────────────────────────────────────────────
|
|
46
|
-
|
|
47
|
-
async launch(taskId: string, config: SubagentConfig, prompt: string) {
|
|
48
|
-
if (this.agents.has(taskId)) {
|
|
49
|
-
throw new Error(`Task ${taskId} is already running`);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const args = [config.cli, ...config.args];
|
|
53
|
-
const proc = Bun.spawn(args, {
|
|
54
|
-
cwd: config.cwd ?? process.cwd(),
|
|
55
|
-
stdin: "pipe",
|
|
56
|
-
stdout: "pipe",
|
|
57
|
-
stderr: "pipe",
|
|
58
|
-
env: { ...process.env, HIVE_ROLE: config.role },
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
const record: AgentRecord = {
|
|
62
|
-
taskId,
|
|
63
|
-
config,
|
|
64
|
-
pid: proc.pid,
|
|
65
|
-
proc,
|
|
66
|
-
state: "running",
|
|
67
|
-
progress: 0,
|
|
68
|
-
tokens: { input: 0, output: 0 },
|
|
69
|
-
startedAt: Date.now(),
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
this.agents.set(taskId, record);
|
|
73
|
-
|
|
74
|
-
this.broadcast({
|
|
75
|
-
type: "agent:started",
|
|
76
|
-
ts: Date.now(),
|
|
77
|
-
role: config.role,
|
|
78
|
-
pid: proc.pid,
|
|
79
|
-
cli: config.cli,
|
|
80
|
-
taskId,
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
// Write the prompt to stdin then close it
|
|
84
|
-
proc.stdin.write(prompt);
|
|
85
|
-
proc.stdin.end();
|
|
86
|
-
|
|
87
|
-
// Stream stdout
|
|
88
|
-
this.pipeStream(record, proc.stdout, "stdout");
|
|
89
|
-
// Stream stderr
|
|
90
|
-
this.pipeStream(record, proc.stderr, "stderr");
|
|
91
|
-
|
|
92
|
-
// Wait for process exit
|
|
93
|
-
proc.exited.then((exitCode) => {
|
|
94
|
-
const r = this.agents.get(taskId);
|
|
95
|
-
if (!r || r.state === "cancelled") return;
|
|
96
|
-
r.state = exitCode === 0 ? "finished" : "error";
|
|
97
|
-
if (exitCode === 0) {
|
|
98
|
-
this.broadcast({
|
|
99
|
-
type: "agent:finished",
|
|
100
|
-
ts: Date.now(),
|
|
101
|
-
role: config.role,
|
|
102
|
-
taskId,
|
|
103
|
-
exitCode,
|
|
104
|
-
});
|
|
105
|
-
} else {
|
|
106
|
-
this.broadcast({
|
|
107
|
-
type: "agent:error",
|
|
108
|
-
ts: Date.now(),
|
|
109
|
-
role: config.role,
|
|
110
|
-
taskId,
|
|
111
|
-
message: `Process exited with code ${exitCode}`,
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
return record.pid;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
// ── Cancel ───────────────────────────────────────────────────────────────
|
|
120
|
-
|
|
121
|
-
cancel(taskId: string) {
|
|
122
|
-
const record = this.agents.get(taskId);
|
|
123
|
-
if (!record) return false;
|
|
124
|
-
record.state = "cancelled";
|
|
125
|
-
record.proc.kill();
|
|
126
|
-
this.broadcast({
|
|
127
|
-
type: "agent:cancelled",
|
|
128
|
-
ts: Date.now(),
|
|
129
|
-
role: record.config.role,
|
|
130
|
-
taskId,
|
|
131
|
-
});
|
|
132
|
-
return true;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
// ── Status snapshot ──────────────────────────────────────────────────────
|
|
136
|
-
|
|
137
|
-
status(): TelemetryEvent {
|
|
138
|
-
return {
|
|
139
|
-
type: "code-bridge:status",
|
|
140
|
-
ts: Date.now(),
|
|
141
|
-
agents: [...this.agents.values()].map((r) => ({
|
|
142
|
-
taskId: r.taskId,
|
|
143
|
-
role: r.config.role,
|
|
144
|
-
cli: r.config.cli,
|
|
145
|
-
pid: r.pid,
|
|
146
|
-
state: r.state,
|
|
147
|
-
progress: r.progress,
|
|
148
|
-
tokens: r.tokens,
|
|
149
|
-
model: r.model,
|
|
150
|
-
})),
|
|
151
|
-
};
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
// ── Helpers ──────────────────────────────────────────────────────────────
|
|
155
|
-
|
|
156
|
-
private async pipeStream(
|
|
157
|
-
record: AgentRecord,
|
|
158
|
-
stream: ReadableStream<Uint8Array>,
|
|
159
|
-
kind: "stdout" | "stderr"
|
|
160
|
-
) {
|
|
161
|
-
const reader = stream.getReader();
|
|
162
|
-
const decoder = new TextDecoder();
|
|
163
|
-
try {
|
|
164
|
-
while (true) {
|
|
165
|
-
const { done, value } = await reader.read();
|
|
166
|
-
if (done) break;
|
|
167
|
-
const chunk = decoder.decode(value);
|
|
168
|
-
|
|
169
|
-
// Parse progress hints: lines containing "HIVE_PROGRESS:<n>"
|
|
170
|
-
for (const line of chunk.split("\n")) {
|
|
171
|
-
const m = line.match(/HIVE_PROGRESS:(\d+)/);
|
|
172
|
-
if (m) {
|
|
173
|
-
record.progress = Math.min(100, parseInt(m[1], 10));
|
|
174
|
-
this.broadcast({
|
|
175
|
-
type: "agent:progress",
|
|
176
|
-
ts: Date.now(),
|
|
177
|
-
role: record.config.role,
|
|
178
|
-
taskId: record.taskId,
|
|
179
|
-
percent: record.progress,
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
|
-
// Parse token hints: "HIVE_TOKENS:input=<n>,output=<n>,model=<name>"
|
|
183
|
-
const t = line.match(/HIVE_TOKENS:input=(\d+),output=(\d+)(?:,model=(.+))?/);
|
|
184
|
-
if (t) {
|
|
185
|
-
record.tokens = { input: parseInt(t[1], 10), output: parseInt(t[2], 10) };
|
|
186
|
-
if (t[3]) record.model = t[3].trim();
|
|
187
|
-
this.broadcast({
|
|
188
|
-
type: "agent:token_usage",
|
|
189
|
-
ts: Date.now(),
|
|
190
|
-
role: record.config.role,
|
|
191
|
-
taskId: record.taskId,
|
|
192
|
-
inputTokens: record.tokens.input,
|
|
193
|
-
outputTokens: record.tokens.output,
|
|
194
|
-
model: record.model ?? "unknown",
|
|
195
|
-
});
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
this.broadcast({
|
|
200
|
-
type: "agent:output",
|
|
201
|
-
ts: Date.now(),
|
|
202
|
-
role: record.config.role,
|
|
203
|
-
taskId: record.taskId,
|
|
204
|
-
stream: kind,
|
|
205
|
-
chunk,
|
|
206
|
-
});
|
|
207
|
-
}
|
|
208
|
-
} catch {
|
|
209
|
-
// stream closed
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
}
|