@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,257 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Core Tools - 4 tools
|
|
3
|
-
*
|
|
4
|
-
* @category core
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import type { Tool } from "../types.ts";
|
|
8
|
-
import { getDb } from "../../storage/sqlite.ts";
|
|
9
|
-
import { logger } from "../../utils/logger.ts";
|
|
10
|
-
|
|
11
|
-
const log = logger.child("core");
|
|
12
|
-
|
|
13
|
-
// ─── search_knowledge ────────────────────────────────────────────────────────
|
|
14
|
-
|
|
15
|
-
export const searchKnowledgeTool: Tool = {
|
|
16
|
-
name: "search_knowledge",
|
|
17
|
-
description: "Busca herramientas (tools), habilidades (skills) o reglas del playbook en la base de conocimientos. Usa búsqueda full-text (FTS5).",
|
|
18
|
-
parameters: {
|
|
19
|
-
type: "object",
|
|
20
|
-
properties: {
|
|
21
|
-
query: {
|
|
22
|
-
type: "string",
|
|
23
|
-
description: "Término de búsqueda (nombre, descripción, categoría)",
|
|
24
|
-
},
|
|
25
|
-
type: {
|
|
26
|
-
type: "string",
|
|
27
|
-
enum: ["all", "tools", "skills", "playbook"],
|
|
28
|
-
description: "Tipo de conocimiento a buscar",
|
|
29
|
-
},
|
|
30
|
-
limit: {
|
|
31
|
-
type: "number",
|
|
32
|
-
description: "Máximo de resultados (default: 10)",
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
required: ["query"],
|
|
36
|
-
},
|
|
37
|
-
execute: async (params: Record<string, unknown>) => {
|
|
38
|
-
const db = getDb();
|
|
39
|
-
const query = params.query as string;
|
|
40
|
-
const type = (params.type as string) ?? "all";
|
|
41
|
-
const limit = (params.limit as number) ?? 10;
|
|
42
|
-
|
|
43
|
-
try {
|
|
44
|
-
const escapedQuery = query.replace(/'/g, "''");
|
|
45
|
-
const normalizedQuery = escapedQuery.replace(/_/g, " ").trim();
|
|
46
|
-
const ftsMatch = normalizedQuery.includes(" ")
|
|
47
|
-
? `"${normalizedQuery}"`
|
|
48
|
-
: `"${normalizedQuery}" OR ${normalizedQuery}*`;
|
|
49
|
-
|
|
50
|
-
const result: any = { query, type, tools: [], skills: [], playbook: [] };
|
|
51
|
-
|
|
52
|
-
// Search tools
|
|
53
|
-
if (type === "all" || type === "tools") {
|
|
54
|
-
const tools = db.query(`
|
|
55
|
-
SELECT t.id, t.name, t.description, t.category, t.enabled, t.active, bm25(tools_fts) as rank
|
|
56
|
-
FROM tools_fts
|
|
57
|
-
LEFT JOIN tools t ON t.name = tools_fts.name
|
|
58
|
-
WHERE tools_fts MATCH ?
|
|
59
|
-
ORDER BY rank
|
|
60
|
-
LIMIT ?
|
|
61
|
-
`).all(ftsMatch, limit) as any[];
|
|
62
|
-
|
|
63
|
-
result.tools = tools.map((t) => ({
|
|
64
|
-
id: t.id,
|
|
65
|
-
name: t.name,
|
|
66
|
-
description: t.description,
|
|
67
|
-
category: t.category,
|
|
68
|
-
enabled: t.enabled === 1,
|
|
69
|
-
active: t.active === 1,
|
|
70
|
-
rank: t.rank,
|
|
71
|
-
}));
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
// Search skills
|
|
75
|
-
if (type === "all" || type === "skills") {
|
|
76
|
-
const skills = db.query(`
|
|
77
|
-
SELECT s.id, s.name, s.category, s.tools, s.triggers, s.active, bm25(skills_fts) as rank
|
|
78
|
-
FROM skills_fts
|
|
79
|
-
JOIN skills s ON s.id = skills_fts.id
|
|
80
|
-
WHERE skills_fts MATCH ?
|
|
81
|
-
ORDER BY rank
|
|
82
|
-
LIMIT ?
|
|
83
|
-
`).all(ftsMatch, limit) as any[];
|
|
84
|
-
|
|
85
|
-
result.skills = skills.map((s) => ({
|
|
86
|
-
id: s.id,
|
|
87
|
-
name: s.name,
|
|
88
|
-
category: s.category,
|
|
89
|
-
tools: s.tools,
|
|
90
|
-
triggers: s.triggers,
|
|
91
|
-
active: s.active === 1,
|
|
92
|
-
rank: s.rank,
|
|
93
|
-
}));
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
// Search playbook
|
|
97
|
-
if (type === "all" || type === "playbook") {
|
|
98
|
-
const playbook = db.query(`
|
|
99
|
-
SELECT p.id, p.rule, p.category, p.applicable_to, p.helpful_count, p.harmful_count, p.active, bm25(playbook_fts) as rank
|
|
100
|
-
FROM playbook_fts
|
|
101
|
-
JOIN playbook p ON p.id = playbook_fts.rowid
|
|
102
|
-
WHERE playbook_fts MATCH ?
|
|
103
|
-
ORDER BY rank
|
|
104
|
-
LIMIT ?
|
|
105
|
-
`).all(ftsMatch, limit) as any[];
|
|
106
|
-
|
|
107
|
-
result.playbook = playbook.map((p) => ({
|
|
108
|
-
id: p.id,
|
|
109
|
-
rule: p.rule,
|
|
110
|
-
category: p.category,
|
|
111
|
-
applicable_to: p.applicable_to ? JSON.parse(p.applicable_to) : null,
|
|
112
|
-
helpful_count: p.helpful_count,
|
|
113
|
-
harmful_count: p.harmful_count,
|
|
114
|
-
active: p.active === 1,
|
|
115
|
-
rank: p.rank,
|
|
116
|
-
}));
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
result.totalResults = result.tools.length + result.skills.length + result.playbook.length;
|
|
120
|
-
|
|
121
|
-
return { ok: true, ...result };
|
|
122
|
-
} catch (error) {
|
|
123
|
-
return {
|
|
124
|
-
ok: false,
|
|
125
|
-
error: `Search failed: ${(error as Error).message}`,
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
},
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
// ─── notify ──────────────────────────────────────────────────────────────────
|
|
132
|
-
|
|
133
|
-
export const notifyTool: Tool = {
|
|
134
|
-
name: "notify",
|
|
135
|
-
description: "Send a notification to the user's active channel.",
|
|
136
|
-
parameters: {
|
|
137
|
-
type: "object",
|
|
138
|
-
properties: {
|
|
139
|
-
message: {
|
|
140
|
-
type: "string",
|
|
141
|
-
description: "Notification message",
|
|
142
|
-
},
|
|
143
|
-
channel: {
|
|
144
|
-
type: "string",
|
|
145
|
-
description: "Channel ID (optional, uses active channel if not specified)",
|
|
146
|
-
},
|
|
147
|
-
},
|
|
148
|
-
required: ["message"],
|
|
149
|
-
},
|
|
150
|
-
execute: async (params: Record<string, unknown>) => {
|
|
151
|
-
const message = params.message as string;
|
|
152
|
-
const channel = (params.channel as string) ?? "webchat";
|
|
153
|
-
|
|
154
|
-
log.info(`Sending notification to ${channel}: ${message}`);
|
|
155
|
-
|
|
156
|
-
// Placeholder - real notification would use channel gateway
|
|
157
|
-
return {
|
|
158
|
-
ok: true,
|
|
159
|
-
message: "Notification sent.",
|
|
160
|
-
channel,
|
|
161
|
-
};
|
|
162
|
-
},
|
|
163
|
-
};
|
|
164
|
-
|
|
165
|
-
// ─── save_note (scratchpad) ──────────────────────────────────────────────────
|
|
166
|
-
|
|
167
|
-
export const saveNoteTool: Tool = {
|
|
168
|
-
name: "save_note",
|
|
169
|
-
description: "Save a note to the scratchpad (survives context compression).",
|
|
170
|
-
parameters: {
|
|
171
|
-
type: "object",
|
|
172
|
-
properties: {
|
|
173
|
-
key: {
|
|
174
|
-
type: "string",
|
|
175
|
-
description: "Unique key for the note",
|
|
176
|
-
},
|
|
177
|
-
value: {
|
|
178
|
-
type: "string",
|
|
179
|
-
description: "Note content",
|
|
180
|
-
},
|
|
181
|
-
thread_id: {
|
|
182
|
-
type: "string",
|
|
183
|
-
description: "Thread ID (optional, uses current thread if not specified)",
|
|
184
|
-
},
|
|
185
|
-
},
|
|
186
|
-
required: ["key", "value"],
|
|
187
|
-
},
|
|
188
|
-
execute: async (params: Record<string, unknown>, config?: any) => {
|
|
189
|
-
const db = getDb();
|
|
190
|
-
const key = params.key as string;
|
|
191
|
-
const value = params.value as string;
|
|
192
|
-
const threadId = (params.thread_id as string) ?? config?.configurable?.thread_id ?? "default";
|
|
193
|
-
|
|
194
|
-
try {
|
|
195
|
-
db.query(`
|
|
196
|
-
INSERT OR REPLACE INTO scratchpad (thread_id, key, value, source, updated_at)
|
|
197
|
-
VALUES (?, ?, ?, 'agent', unixepoch())
|
|
198
|
-
`).run(threadId, key, value);
|
|
199
|
-
|
|
200
|
-
return { ok: true, key, message: "Note saved." };
|
|
201
|
-
} catch (error) {
|
|
202
|
-
return {
|
|
203
|
-
ok: false,
|
|
204
|
-
error: `Failed to save note: ${(error as Error).message}`,
|
|
205
|
-
};
|
|
206
|
-
}
|
|
207
|
-
},
|
|
208
|
-
};
|
|
209
|
-
|
|
210
|
-
// ─── report_progress ─────────────────────────────────────────────────────────
|
|
211
|
-
|
|
212
|
-
export const reportProgressTool: Tool = {
|
|
213
|
-
name: "report_progress",
|
|
214
|
-
description: "Report progress of a task in progress.",
|
|
215
|
-
parameters: {
|
|
216
|
-
type: "object",
|
|
217
|
-
properties: {
|
|
218
|
-
progress: {
|
|
219
|
-
type: "number",
|
|
220
|
-
description: "Progress percentage (0-100)",
|
|
221
|
-
},
|
|
222
|
-
message: {
|
|
223
|
-
type: "string",
|
|
224
|
-
description: "Progress message",
|
|
225
|
-
},
|
|
226
|
-
task_id: {
|
|
227
|
-
type: "string",
|
|
228
|
-
description: "Task or project ID",
|
|
229
|
-
},
|
|
230
|
-
},
|
|
231
|
-
required: ["progress", "message"],
|
|
232
|
-
},
|
|
233
|
-
execute: async (params: Record<string, unknown>) => {
|
|
234
|
-
const progress = params.progress as number;
|
|
235
|
-
const message = params.message as string;
|
|
236
|
-
const taskId = (params.task_id as string) ?? null;
|
|
237
|
-
|
|
238
|
-
log.info(`Progress: ${progress}% - ${message}`);
|
|
239
|
-
|
|
240
|
-
// Update task progress if task_id provided
|
|
241
|
-
if (taskId) {
|
|
242
|
-
const db = getDb();
|
|
243
|
-
db.query(`UPDATE tasks SET progress = ?, updated_at = unixepoch() WHERE id = ?`).run(progress, taskId);
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
return {
|
|
247
|
-
ok: true,
|
|
248
|
-
progress,
|
|
249
|
-
message,
|
|
250
|
-
task_id: taskId,
|
|
251
|
-
};
|
|
252
|
-
},
|
|
253
|
-
};
|
|
254
|
-
|
|
255
|
-
export function createTools(): Tool[] {
|
|
256
|
-
return [searchKnowledgeTool, notifyTool, saveNoteTool, reportProgressTool];
|
|
257
|
-
}
|
|
@@ -1,373 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Cron Tools - 4 tools
|
|
3
|
-
*
|
|
4
|
-
* @category cron
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import type { Tool } from "../types.ts";
|
|
8
|
-
import { getDb } from "../../storage/sqlite.ts";
|
|
9
|
-
import { logger } from "../../utils/logger.ts";
|
|
10
|
-
import { Cron } from "croner";
|
|
11
|
-
|
|
12
|
-
const log = logger.child("cron");
|
|
13
|
-
|
|
14
|
-
// ─── cron_add ────────────────────────────────────────────────────────────────
|
|
15
|
-
|
|
16
|
-
export const cronAddTool: Tool = {
|
|
17
|
-
name: "cron_add",
|
|
18
|
-
description: "Schedule a recurring or one-time job using a cron expression. Spanish: programar tarea, recordatorio, alarma, automatizar horario",
|
|
19
|
-
parameters: {
|
|
20
|
-
type: "object",
|
|
21
|
-
properties: {
|
|
22
|
-
name: { type: "string", description: "Nombre de la tarea programada" },
|
|
23
|
-
cronExpression: { type: "string", description: "Expresión cron (5 campos: minuto hora día mes weekday)" },
|
|
24
|
-
taskType: { type: "string", description: "Tipo de tarea (message, project, etc.)" },
|
|
25
|
-
taskConfig: { type: "object", description: "Configuración de la tarea" },
|
|
26
|
-
maxRuns: { type: "number", description: "Máximo de ejecuciones. Usa 1 para tareas de una sola vez (one-shot). Omitir para recurrentes." },
|
|
27
|
-
},
|
|
28
|
-
required: ["name", "cronExpression"],
|
|
29
|
-
},
|
|
30
|
-
execute: async (params: Record<string, unknown>, config?: any) => {
|
|
31
|
-
const db = getDb();
|
|
32
|
-
const userId = config?.configurable?.user_id;
|
|
33
|
-
const name = (params.name || params.taskName || params.title || params.task) as string | undefined;
|
|
34
|
-
const cronExpression = (params.cronExpression || params.cron_expression || params.expression) as string | undefined;
|
|
35
|
-
const taskType = (params.taskType as string) ?? "message";
|
|
36
|
-
const taskConfig = params.taskConfig as Record<string, unknown> | undefined;
|
|
37
|
-
const maxRuns = params.maxRuns as number | undefined;
|
|
38
|
-
|
|
39
|
-
if (!name) {
|
|
40
|
-
return { ok: false, error: "Missing required field: name (job name)" };
|
|
41
|
-
}
|
|
42
|
-
if (!cronExpression) {
|
|
43
|
-
return { ok: false, error: "Missing required field: cronExpression (e.g. '0 9 * * *')" };
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
try {
|
|
47
|
-
// Validate and calculate next run
|
|
48
|
-
const cronInstance = new Cron(cronExpression);
|
|
49
|
-
const nextDate = cronInstance.nextRun();
|
|
50
|
-
cronInstance.stop(); // Solo era para calcular, el scheduler real lo relanzará
|
|
51
|
-
const nextRun = nextDate ? Math.floor(nextDate.getTime() / 1000) : null;
|
|
52
|
-
|
|
53
|
-
const jobId = crypto.randomUUID().replace(/-/g, "").slice(0, 16);
|
|
54
|
-
|
|
55
|
-
db.query(`
|
|
56
|
-
INSERT INTO cron_jobs (id, user_id, name, cron_expression, task_type, task_config, max_runs, enabled, next_run, created_at)
|
|
57
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, 1, ?, unixepoch())
|
|
58
|
-
`).run(jobId, userId, name, cronExpression, taskType, JSON.stringify(taskConfig ?? {}), maxRuns ?? null, nextRun);
|
|
59
|
-
|
|
60
|
-
return {
|
|
61
|
-
ok: true,
|
|
62
|
-
jobId,
|
|
63
|
-
nextRun: nextDate?.toISOString() ?? null,
|
|
64
|
-
message: `Cron job "${name}" scheduled. Next run: ${nextDate?.toLocaleString() ?? "unknown"}`,
|
|
65
|
-
};
|
|
66
|
-
} catch (error) {
|
|
67
|
-
log.error(`Failed to add cron: ${(error as Error).message}`);
|
|
68
|
-
return {
|
|
69
|
-
ok: false,
|
|
70
|
-
error: `Invalid cron expression or database error: ${(error as Error).message}`,
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
},
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
// ─── cron_list ───────────────────────────────────────────────────────────────
|
|
77
|
-
|
|
78
|
-
export const cronListTool: Tool = {
|
|
79
|
-
name: "cron_list",
|
|
80
|
-
description: "List all scheduled cron jobs and next execution times. Spanish: ver tareas programadas, cronograma, próximos eventos",
|
|
81
|
-
parameters: {
|
|
82
|
-
type: "object",
|
|
83
|
-
properties: {
|
|
84
|
-
enabled: { type: "boolean", description: "Filter by enabled status" },
|
|
85
|
-
},
|
|
86
|
-
},
|
|
87
|
-
execute: async (params: Record<string, unknown>, config?: any) => {
|
|
88
|
-
const db = getDb();
|
|
89
|
-
const userId = config?.configurable?.user_id;
|
|
90
|
-
const enabledFilter = params.enabled as boolean | undefined;
|
|
91
|
-
|
|
92
|
-
try {
|
|
93
|
-
let query = "SELECT * FROM cron_jobs WHERE user_id = ?";
|
|
94
|
-
const args: any[] = [userId];
|
|
95
|
-
|
|
96
|
-
if (enabledFilter !== undefined) {
|
|
97
|
-
query += " AND enabled = ?";
|
|
98
|
-
args.push(enabledFilter ? 1 : 0);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
query += " ORDER BY next_run ASC";
|
|
102
|
-
|
|
103
|
-
const jobs = db.query(query).all(...args) as any[];
|
|
104
|
-
|
|
105
|
-
return {
|
|
106
|
-
ok: true,
|
|
107
|
-
jobs: jobs.map((j) => ({
|
|
108
|
-
id: j.id,
|
|
109
|
-
name: j.name,
|
|
110
|
-
cronExpression: j.cron_expression,
|
|
111
|
-
taskType: j.task_type,
|
|
112
|
-
enabled: j.enabled === 1,
|
|
113
|
-
runCount: j.run_count,
|
|
114
|
-
nextRun: j.next_run ? new Date(j.next_run * 1000).toISOString() : null,
|
|
115
|
-
})),
|
|
116
|
-
count: jobs.length,
|
|
117
|
-
};
|
|
118
|
-
} catch (error) {
|
|
119
|
-
log.error(`Failed to list crons: ${(error as Error).message}`);
|
|
120
|
-
return {
|
|
121
|
-
ok: false,
|
|
122
|
-
error: `Failed to list cron jobs: ${(error as Error).message}`,
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
},
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
// ─── cron_edit ───────────────────────────────────────────────────────────────
|
|
129
|
-
|
|
130
|
-
export const cronEditTool: Tool = {
|
|
131
|
-
name: "cron_edit",
|
|
132
|
-
description: "Edit an existing cron job expression or config. Spanish: modificar horario, cambiar programación, editar cron",
|
|
133
|
-
parameters: {
|
|
134
|
-
type: "object",
|
|
135
|
-
properties: {
|
|
136
|
-
jobId: { type: "string", description: "ID del cron job" },
|
|
137
|
-
cronExpression: { type: "string", description: "Nueva expresión cron" },
|
|
138
|
-
taskConfig: { type: "object", description: "Nueva configuración" },
|
|
139
|
-
},
|
|
140
|
-
required: ["jobId"],
|
|
141
|
-
},
|
|
142
|
-
execute: async (params: Record<string, unknown>) => {
|
|
143
|
-
const db = getDb();
|
|
144
|
-
const jobId = params.jobId as string;
|
|
145
|
-
const cronExpression = params.cronExpression as string | undefined;
|
|
146
|
-
const taskConfig = params.taskConfig as Record<string, unknown> | undefined;
|
|
147
|
-
|
|
148
|
-
try {
|
|
149
|
-
const updates: string[] = [];
|
|
150
|
-
const values: any[] = [];
|
|
151
|
-
|
|
152
|
-
if (cronExpression) {
|
|
153
|
-
new Cron(cronExpression); // Validate
|
|
154
|
-
updates.push("cron_expression = ?");
|
|
155
|
-
values.push(cronExpression);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
if (taskConfig !== undefined) {
|
|
159
|
-
updates.push("task_config = ?");
|
|
160
|
-
values.push(JSON.stringify(taskConfig));
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
if (updates.length === 0) {
|
|
164
|
-
return { ok: false, error: "No changes provided" };
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
values.push(jobId);
|
|
168
|
-
|
|
169
|
-
const result = db.query(`UPDATE cron_jobs SET ${updates.join(", ")} WHERE id = ?`).run(...values);
|
|
170
|
-
|
|
171
|
-
if (result.changes === 0) {
|
|
172
|
-
return { ok: false, error: `Cron job not found: ${jobId}` };
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
return { ok: true, jobId, message: "Cron job updated." };
|
|
176
|
-
} catch (error) {
|
|
177
|
-
log.error(`Failed to edit cron: ${(error as Error).message}`);
|
|
178
|
-
return {
|
|
179
|
-
ok: false,
|
|
180
|
-
error: `Failed to edit cron job: ${(error as Error).message}`,
|
|
181
|
-
};
|
|
182
|
-
}
|
|
183
|
-
},
|
|
184
|
-
};
|
|
185
|
-
|
|
186
|
-
// ─── cron_remove ─────────────────────────────────────────────────────────────
|
|
187
|
-
|
|
188
|
-
export const cronRemoveTool: Tool = {
|
|
189
|
-
name: "cron_remove",
|
|
190
|
-
description: "Remove a scheduled cron job. Spanish: eliminar cron, cancelar recordatorio, borrar programación",
|
|
191
|
-
parameters: {
|
|
192
|
-
type: "object",
|
|
193
|
-
properties: {
|
|
194
|
-
jobId: { type: "string", description: "ID del cron job a eliminar" },
|
|
195
|
-
},
|
|
196
|
-
required: ["jobId"],
|
|
197
|
-
},
|
|
198
|
-
execute: async (params: Record<string, unknown>) => {
|
|
199
|
-
const db = getDb();
|
|
200
|
-
const jobId = params.jobId as string;
|
|
201
|
-
|
|
202
|
-
try {
|
|
203
|
-
const result = db.query("DELETE FROM cron_jobs WHERE id = ?").run(jobId);
|
|
204
|
-
|
|
205
|
-
if (result.changes === 0) {
|
|
206
|
-
return { ok: false, error: `Cron job not found: ${jobId}` };
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
return { ok: true, jobId, message: "Cron job removed." };
|
|
210
|
-
} catch (error) {
|
|
211
|
-
log.error(`Failed to remove cron: ${(error as Error).message}`);
|
|
212
|
-
return {
|
|
213
|
-
ok: false,
|
|
214
|
-
error: `Failed to remove cron job: ${(error as Error).message}`,
|
|
215
|
-
};
|
|
216
|
-
}
|
|
217
|
-
},
|
|
218
|
-
};
|
|
219
|
-
|
|
220
|
-
import crypto from "crypto";
|
|
221
|
-
|
|
222
|
-
export function createTools(): Tool[] {
|
|
223
|
-
return [cronAddTool, cronListTool, cronEditTool, cronRemoveTool];
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
// Mapa de instancias Cron activas: jobId → Cron instance
|
|
227
|
-
const activeJobs = new Map<string, InstanceType<typeof Cron>>();
|
|
228
|
-
|
|
229
|
-
type CronCallback = (sessionId: string, task: string, jobId: string, context: { fecha_usuario: string; hora_usuario: string }) => void;
|
|
230
|
-
|
|
231
|
-
function scheduleJob(
|
|
232
|
-
job: { id: string; user_id: string; name: string; cron_expression: string; max_runs: number | null; run_count: number; expires_at: number | null },
|
|
233
|
-
callback: CronCallback
|
|
234
|
-
): void {
|
|
235
|
-
// Si ya hay una instancia activa para este job, la saltamos
|
|
236
|
-
if (activeJobs.has(job.id)) return;
|
|
237
|
-
|
|
238
|
-
try {
|
|
239
|
-
const instance = new Cron(job.cron_expression, { protect: true }, () => {
|
|
240
|
-
const db = getDb();
|
|
241
|
-
const now = Math.floor(Date.now() / 1000);
|
|
242
|
-
|
|
243
|
-
// Verificar expiración
|
|
244
|
-
if (job.expires_at && now > job.expires_at) {
|
|
245
|
-
log.info(`[cron] Job "${job.name}" (${job.id}) expired, stopping`);
|
|
246
|
-
instance.stop();
|
|
247
|
-
activeJobs.delete(job.id);
|
|
248
|
-
db.query("UPDATE cron_jobs SET enabled = 0 WHERE id = ?").run(job.id);
|
|
249
|
-
return;
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
// Actualizar run_count, last_run, next_run
|
|
253
|
-
const newRunCount = (job.run_count ?? 0) + 1;
|
|
254
|
-
const nextDate = instance.nextRun();
|
|
255
|
-
const nextRunTs = nextDate ? Math.floor(nextDate.getTime() / 1000) : null;
|
|
256
|
-
|
|
257
|
-
db.query(
|
|
258
|
-
"UPDATE cron_jobs SET run_count = ?, last_run = ?, next_run = ? WHERE id = ?"
|
|
259
|
-
).run(newRunCount, now, nextRunTs, job.id);
|
|
260
|
-
job.run_count = newRunCount;
|
|
261
|
-
|
|
262
|
-
// Verificar max_runs
|
|
263
|
-
if (job.max_runs !== null && newRunCount >= job.max_runs) {
|
|
264
|
-
log.info(`[cron] Job "${job.name}" (${job.id}) reached max_runs=${job.max_runs}, stopping`);
|
|
265
|
-
instance.stop();
|
|
266
|
-
activeJobs.delete(job.id);
|
|
267
|
-
db.query("UPDATE cron_jobs SET enabled = 0 WHERE id = ?").run(job.id);
|
|
268
|
-
return;
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
// Auto-desactivar si no hay próxima ejecución en los próximos 366 días
|
|
272
|
-
// (detecta expresiones one-shot como "0 19 9 3 *" que croner reprograma al año siguiente)
|
|
273
|
-
if (!nextDate || nextDate.getTime() - Date.now() > 366 * 24 * 60 * 60 * 1000) {
|
|
274
|
-
log.info(`[cron] Job "${job.name}" (${job.id}) has no near future run (next=${nextDate?.toISOString() ?? "null"}), disabling`);
|
|
275
|
-
instance.stop();
|
|
276
|
-
activeJobs.delete(job.id);
|
|
277
|
-
db.query("UPDATE cron_jobs SET enabled = 0 WHERE id = ?").run(job.id);
|
|
278
|
-
return;
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
// Contexto de fecha/hora local
|
|
282
|
-
const now_date = new Date();
|
|
283
|
-
const context = {
|
|
284
|
-
fecha_usuario: now_date.toLocaleDateString("es-ES"),
|
|
285
|
-
hora_usuario: now_date.toLocaleTimeString("es-ES"),
|
|
286
|
-
};
|
|
287
|
-
|
|
288
|
-
log.info(`[cron] Firing job "${job.name}" (${job.id}) run #${newRunCount}`);
|
|
289
|
-
callback(job.user_id, job.name, job.id, context);
|
|
290
|
-
});
|
|
291
|
-
|
|
292
|
-
activeJobs.set(job.id, instance);
|
|
293
|
-
|
|
294
|
-
// Actualizar next_run inicial en BD
|
|
295
|
-
const nextDate = instance.nextRun();
|
|
296
|
-
if (nextDate) {
|
|
297
|
-
getDb()
|
|
298
|
-
.query("UPDATE cron_jobs SET next_run = ? WHERE id = ?")
|
|
299
|
-
.run(Math.floor(nextDate.getTime() / 1000), job.id);
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
log.info(`[cron] Scheduled job "${job.name}" (${job.id}) — next: ${instance.nextRun()?.toISOString() ?? "unknown"}`);
|
|
303
|
-
} catch (err) {
|
|
304
|
-
log.error(`[cron] Failed to schedule job "${job.name}" (${job.id}): ${(err as Error).message}`);
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
/**
|
|
309
|
-
* Initialize the cron scheduler.
|
|
310
|
-
* Loads all enabled jobs from the DB and schedules them.
|
|
311
|
-
* Polls every 30s for new jobs added after startup.
|
|
312
|
-
*/
|
|
313
|
-
export function initCronScheduler(callback: CronCallback): void {
|
|
314
|
-
const db = getDb();
|
|
315
|
-
|
|
316
|
-
const loadAndSchedule = () => {
|
|
317
|
-
const jobs = db.query(`
|
|
318
|
-
SELECT id, user_id, name, cron_expression, max_runs, run_count, expires_at
|
|
319
|
-
FROM cron_jobs
|
|
320
|
-
WHERE enabled = 1
|
|
321
|
-
`).all() as { id: string; user_id: string; name: string; cron_expression: string; max_runs: number | null; run_count: number; expires_at: number | null }[];
|
|
322
|
-
|
|
323
|
-
for (const job of jobs) {
|
|
324
|
-
scheduleJob(job, callback);
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
// Detener jobs que ya no están en BD o están deshabilitados
|
|
328
|
-
const activeIds = new Set(jobs.map((j) => j.id));
|
|
329
|
-
for (const [jobId, instance] of activeJobs) {
|
|
330
|
-
if (!activeIds.has(jobId)) {
|
|
331
|
-
log.info(`[cron] Stopping removed/disabled job ${jobId}`);
|
|
332
|
-
instance.stop();
|
|
333
|
-
activeJobs.delete(jobId);
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
};
|
|
337
|
-
|
|
338
|
-
// Carga inicial
|
|
339
|
-
loadAndSchedule();
|
|
340
|
-
|
|
341
|
-
// Poll cada 30s para detectar nuevos jobs o jobs eliminados
|
|
342
|
-
setInterval(loadAndSchedule, 30_000);
|
|
343
|
-
|
|
344
|
-
log.info(`[cron] Scheduler initialized with ${activeJobs.size} active jobs`);
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
/**
|
|
348
|
-
* Resolve the best channel TYPE ("webchat", "telegram", etc.) for cron notifications.
|
|
349
|
-
* Priority: explicit notify_channel_id → user_identities (first registered) → "webchat"
|
|
350
|
-
*/
|
|
351
|
-
export function resolveBestChannel(userId: string, notifyChannelId?: string | null): string {
|
|
352
|
-
// 1. Explicit channel set on the job
|
|
353
|
-
if (notifyChannelId) return notifyChannelId;
|
|
354
|
-
|
|
355
|
-
// 2. Look up which channels the user has registered identities for
|
|
356
|
-
try {
|
|
357
|
-
const db = getDb();
|
|
358
|
-
const identities = db.query<{ channel: string }, [string]>(
|
|
359
|
-
"SELECT channel FROM user_identities WHERE user_id = ? ORDER BY channel ASC LIMIT 5"
|
|
360
|
-
).all(userId);
|
|
361
|
-
|
|
362
|
-
// Prefer telegram if available (most reliable for async notifications)
|
|
363
|
-
const preferred = ["telegram", "discord", "slack", "whatsapp"];
|
|
364
|
-
for (const p of preferred) {
|
|
365
|
-
if (identities.some((i) => i.channel === p)) return p;
|
|
366
|
-
}
|
|
367
|
-
} catch {
|
|
368
|
-
// DB not ready or no identities — fall through
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
// 3. Default to webchat
|
|
372
|
-
return "webchat";
|
|
373
|
-
}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* fs_delete - Delete file or directory from workspace
|
|
3
|
-
*
|
|
4
|
-
* @category filesystem
|
|
5
|
-
* @seedId fs_delete
|
|
6
|
-
* @spanish eliminar archivo, borrar archivo, borrar carpeta
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import type { Tool } from "../types.ts";
|
|
10
|
-
import { logger } from "../../utils/logger.ts";
|
|
11
|
-
import { resolveInWorkspace, getWorkspace } from "./workspace-guard.ts";
|
|
12
|
-
import * as fs from "node:fs";
|
|
13
|
-
|
|
14
|
-
const log = logger.child("fs-delete");
|
|
15
|
-
|
|
16
|
-
export const fsDeleteTool: Tool = {
|
|
17
|
-
name: "fs_delete",
|
|
18
|
-
description: "Delete file or directory from workspace. Spanish: eliminar archivo, borrar archivo, borrar carpeta",
|
|
19
|
-
parameters: {
|
|
20
|
-
type: "object",
|
|
21
|
-
properties: {
|
|
22
|
-
path: {
|
|
23
|
-
type: "string",
|
|
24
|
-
description: "Path to the file or directory to delete",
|
|
25
|
-
},
|
|
26
|
-
recursive: {
|
|
27
|
-
type: "boolean",
|
|
28
|
-
description: "Delete recursively for directories (default: false)",
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
required: ["path"],
|
|
32
|
-
},
|
|
33
|
-
execute: async (params: Record<string, unknown>, config?: any) => {
|
|
34
|
-
const workspace = getWorkspace(config);
|
|
35
|
-
let targetPath: string;
|
|
36
|
-
try {
|
|
37
|
-
targetPath = resolveInWorkspace(params.path as string, workspace);
|
|
38
|
-
} catch (e) {
|
|
39
|
-
return { ok: false, error: (e as Error).message };
|
|
40
|
-
}
|
|
41
|
-
const recursive = (params.recursive as boolean) ?? false;
|
|
42
|
-
|
|
43
|
-
log.debug(`Deleting: ${targetPath}`);
|
|
44
|
-
|
|
45
|
-
try {
|
|
46
|
-
if (!fs.existsSync(targetPath)) {
|
|
47
|
-
return {
|
|
48
|
-
ok: false,
|
|
49
|
-
error: `Path not found: ${targetPath}`,
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
const stats = fs.statSync(targetPath);
|
|
54
|
-
|
|
55
|
-
if (stats.isDirectory()) {
|
|
56
|
-
if (recursive) {
|
|
57
|
-
fs.rmSync(targetPath, { recursive: true });
|
|
58
|
-
} else {
|
|
59
|
-
fs.rmdirSync(targetPath);
|
|
60
|
-
}
|
|
61
|
-
} else {
|
|
62
|
-
fs.unlinkSync(targetPath);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
return {
|
|
66
|
-
ok: true,
|
|
67
|
-
path: targetPath,
|
|
68
|
-
deleted: true,
|
|
69
|
-
};
|
|
70
|
-
} catch (error) {
|
|
71
|
-
log.error(`Error deleting: ${(error as Error).message}`);
|
|
72
|
-
return {
|
|
73
|
-
ok: false,
|
|
74
|
-
error: `Failed to delete: ${(error as Error).message}`,
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
},
|
|
78
|
-
};
|