@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.
Files changed (427) hide show
  1. package/README.md +178 -36
  2. package/dist/hive.js +315124 -0
  3. package/package.json +11 -3
  4. package/packages/core/src/index.ts +0 -1
  5. package/.dockerignore +0 -9
  6. package/CONTRIBUTING.md +0 -44
  7. package/Dockerfile +0 -67
  8. package/docker-compose.yml +0 -19
  9. package/packages/cli/package.json +0 -28
  10. package/packages/cli/src/commands/agent-run.ts +0 -168
  11. package/packages/cli/src/commands/agents.ts +0 -398
  12. package/packages/cli/src/commands/chat.ts +0 -142
  13. package/packages/cli/src/commands/config.ts +0 -50
  14. package/packages/cli/src/commands/cron.ts +0 -161
  15. package/packages/cli/src/commands/dev.ts +0 -95
  16. package/packages/cli/src/commands/doctor.ts +0 -133
  17. package/packages/cli/src/commands/gateway.ts +0 -422
  18. package/packages/cli/src/commands/logs.ts +0 -57
  19. package/packages/cli/src/commands/mcp.ts +0 -175
  20. package/packages/cli/src/commands/message.ts +0 -77
  21. package/packages/cli/src/commands/onboard.ts +0 -1696
  22. package/packages/cli/src/commands/security.ts +0 -144
  23. package/packages/cli/src/commands/service.ts +0 -50
  24. package/packages/cli/src/commands/sessions.ts +0 -116
  25. package/packages/cli/src/commands/skills.ts +0 -187
  26. package/packages/cli/src/commands/update.ts +0 -25
  27. package/packages/cli/src/index.ts +0 -190
  28. package/packages/cli/src/utils/token.ts +0 -6
  29. package/packages/code-bridge/README.md +0 -78
  30. package/packages/code-bridge/package.json +0 -18
  31. package/packages/code-bridge/src/index.ts +0 -95
  32. package/packages/code-bridge/src/process-manager.ts +0 -212
  33. package/packages/code-bridge/src/schemas.ts +0 -133
  34. package/packages/core/package.json +0 -55
  35. package/packages/core/src/agent/agent-loop.ts +0 -520
  36. package/packages/core/src/agent/compaction.ts +0 -183
  37. package/packages/core/src/agent/context-compiler.ts +0 -544
  38. package/packages/core/src/agent/context-guard.ts +0 -91
  39. package/packages/core/src/agent/conversation-store.ts +0 -193
  40. package/packages/core/src/agent/curator.ts +0 -158
  41. package/packages/core/src/agent/hooks.ts +0 -166
  42. package/packages/core/src/agent/llm-client.ts +0 -503
  43. package/packages/core/src/agent/native-tools.ts +0 -31
  44. package/packages/core/src/agent/playbook-selector.ts +0 -143
  45. package/packages/core/src/agent/prompt-builder.ts +0 -167
  46. package/packages/core/src/agent/providers/index.ts +0 -186
  47. package/packages/core/src/agent/providers.ts +0 -1
  48. package/packages/core/src/agent/reflector.ts +0 -200
  49. package/packages/core/src/agent/service.ts +0 -266
  50. package/packages/core/src/agent/skill-selector.ts +0 -413
  51. package/packages/core/src/agent/stuck-loop.ts +0 -133
  52. package/packages/core/src/agent/tool-selector.ts +0 -623
  53. package/packages/core/src/agent/tracer.ts +0 -102
  54. package/packages/core/src/canvas/canvas-manager.ts +0 -319
  55. package/packages/core/src/canvas/canvas-tools.ts +0 -420
  56. package/packages/core/src/canvas/emitter.ts +0 -119
  57. package/packages/core/src/canvas/index.ts +0 -2
  58. package/packages/core/src/channels/base.ts +0 -140
  59. package/packages/core/src/channels/discord.ts +0 -260
  60. package/packages/core/src/channels/index.ts +0 -7
  61. package/packages/core/src/channels/manager.ts +0 -383
  62. package/packages/core/src/channels/slack.ts +0 -287
  63. package/packages/core/src/channels/telegram.ts +0 -552
  64. package/packages/core/src/channels/webchat.ts +0 -139
  65. package/packages/core/src/channels/whatsapp.ts +0 -375
  66. package/packages/core/src/config/index.ts +0 -12
  67. package/packages/core/src/config/loader.ts +0 -529
  68. package/packages/core/src/events/agent-bus.ts +0 -460
  69. package/packages/core/src/events/event-bus.ts +0 -169
  70. package/packages/core/src/gateway/helpers/cors.ts +0 -32
  71. package/packages/core/src/gateway/helpers/index.ts +0 -4
  72. package/packages/core/src/gateway/helpers/narration.ts +0 -60
  73. package/packages/core/src/gateway/helpers/path.ts +0 -13
  74. package/packages/core/src/gateway/helpers/redact.ts +0 -61
  75. package/packages/core/src/gateway/index.ts +0 -5
  76. package/packages/core/src/gateway/initializer.ts +0 -332
  77. package/packages/core/src/gateway/lane-queue.ts +0 -169
  78. package/packages/core/src/gateway/resolver.ts +0 -108
  79. package/packages/core/src/gateway/router.ts +0 -124
  80. package/packages/core/src/gateway/routes/agents.ts +0 -187
  81. package/packages/core/src/gateway/routes/channels.ts +0 -203
  82. package/packages/core/src/gateway/routes/chat.ts +0 -241
  83. package/packages/core/src/gateway/routes/config.ts +0 -12
  84. package/packages/core/src/gateway/routes/cron.ts +0 -42
  85. package/packages/core/src/gateway/routes/ethics.ts +0 -46
  86. package/packages/core/src/gateway/routes/mcp.ts +0 -346
  87. package/packages/core/src/gateway/routes/models.ts +0 -93
  88. package/packages/core/src/gateway/routes/projects.ts +0 -179
  89. package/packages/core/src/gateway/routes/providers.ts +0 -192
  90. package/packages/core/src/gateway/routes/setup.ts +0 -267
  91. package/packages/core/src/gateway/routes/skills.ts +0 -70
  92. package/packages/core/src/gateway/routes/system.ts +0 -165
  93. package/packages/core/src/gateway/routes/tasks.ts +0 -44
  94. package/packages/core/src/gateway/routes/tools.ts +0 -35
  95. package/packages/core/src/gateway/routes/users.ts +0 -118
  96. package/packages/core/src/gateway/routes/voice.ts +0 -73
  97. package/packages/core/src/gateway/routes/workspace.ts +0 -281
  98. package/packages/core/src/gateway/server.ts +0 -1978
  99. package/packages/core/src/gateway/session.ts +0 -95
  100. package/packages/core/src/gateway/slash-commands.ts +0 -193
  101. package/packages/core/src/heartbeat/index.ts +0 -157
  102. package/packages/core/src/mcp/hot-reload.ts +0 -213
  103. package/packages/core/src/mcp/singleton.ts +0 -21
  104. package/packages/core/src/memory/index.ts +0 -1
  105. package/packages/core/src/memory/notes.ts +0 -68
  106. package/packages/core/src/plugins/api.ts +0 -128
  107. package/packages/core/src/plugins/index.ts +0 -2
  108. package/packages/core/src/plugins/loader.ts +0 -365
  109. package/packages/core/src/resilience/circuit-breaker.ts +0 -225
  110. package/packages/core/src/security/google-chat.ts +0 -269
  111. package/packages/core/src/security/index.ts +0 -192
  112. package/packages/core/src/security/pairing.ts +0 -250
  113. package/packages/core/src/security/rate-limit.ts +0 -270
  114. package/packages/core/src/security/signal.ts +0 -321
  115. package/packages/core/src/state/store.ts +0 -312
  116. package/packages/core/src/storage/crypto.ts +0 -101
  117. package/packages/core/src/storage/onboarding.ts +0 -1609
  118. package/packages/core/src/storage/schema.ts +0 -567
  119. package/packages/core/src/storage/seed.ts +0 -608
  120. package/packages/core/src/storage/sqlite.ts +0 -363
  121. package/packages/core/src/storage/usage.ts +0 -270
  122. package/packages/core/src/tools/agents/index.ts +0 -607
  123. package/packages/core/src/tools/bridge-events.ts +0 -26
  124. package/packages/core/src/tools/canvas/index.ts +0 -281
  125. package/packages/core/src/tools/cli/index.ts +0 -142
  126. package/packages/core/src/tools/codebridge/index.ts +0 -179
  127. package/packages/core/src/tools/core/index.ts +0 -257
  128. package/packages/core/src/tools/cron/index.ts +0 -373
  129. package/packages/core/src/tools/filesystem/fs-delete.ts +0 -78
  130. package/packages/core/src/tools/filesystem/fs-edit.ts +0 -106
  131. package/packages/core/src/tools/filesystem/fs-exists.ts +0 -63
  132. package/packages/core/src/tools/filesystem/fs-glob.ts +0 -108
  133. package/packages/core/src/tools/filesystem/fs-list.ts +0 -129
  134. package/packages/core/src/tools/filesystem/fs-read.ts +0 -72
  135. package/packages/core/src/tools/filesystem/fs-write.ts +0 -67
  136. package/packages/core/src/tools/filesystem/index.ts +0 -34
  137. package/packages/core/src/tools/filesystem/workspace-guard.ts +0 -62
  138. package/packages/core/src/tools/index.ts +0 -197
  139. package/packages/core/src/tools/projects/index.ts +0 -37
  140. package/packages/core/src/tools/projects/project-create.ts +0 -94
  141. package/packages/core/src/tools/projects/project-done.ts +0 -66
  142. package/packages/core/src/tools/projects/project-fail.ts +0 -66
  143. package/packages/core/src/tools/projects/project-list.ts +0 -96
  144. package/packages/core/src/tools/projects/project-update.ts +0 -72
  145. package/packages/core/src/tools/projects/task-create.ts +0 -68
  146. package/packages/core/src/tools/projects/task-evaluate.ts +0 -93
  147. package/packages/core/src/tools/projects/task-update.ts +0 -93
  148. package/packages/core/src/tools/search-knowledge/search-knowledge.ts +0 -155
  149. package/packages/core/src/tools/types.ts +0 -39
  150. package/packages/core/src/tools/voice/index.ts +0 -104
  151. package/packages/core/src/tools/web/browser-click.ts +0 -54
  152. package/packages/core/src/tools/web/browser-navigate.ts +0 -84
  153. package/packages/core/src/tools/web/browser-screenshot.ts +0 -54
  154. package/packages/core/src/tools/web/browser-type.ts +0 -60
  155. package/packages/core/src/tools/web/index.ts +0 -31
  156. package/packages/core/src/tools/web/web-fetch.ts +0 -78
  157. package/packages/core/src/tools/web/web-search.ts +0 -123
  158. package/packages/core/src/utils/benchmark.ts +0 -80
  159. package/packages/core/src/utils/crypto.ts +0 -73
  160. package/packages/core/src/utils/date.ts +0 -42
  161. package/packages/core/src/utils/index.ts +0 -5
  162. package/packages/core/src/utils/logger.ts +0 -389
  163. package/packages/core/src/utils/retry.ts +0 -70
  164. package/packages/core/src/utils/toon.ts +0 -356
  165. package/packages/core/src/voice/index.ts +0 -583
  166. package/packages/hive-ui/README.md +0 -52
  167. package/packages/hive-ui/components.json +0 -20
  168. package/packages/hive-ui/index.html +0 -30
  169. package/packages/hive-ui/package.json +0 -90
  170. package/packages/hive-ui/public/favicon.ico +0 -0
  171. package/packages/hive-ui/public/placeholder.svg +0 -1
  172. package/packages/hive-ui/src/App.tsx +0 -115
  173. package/packages/hive-ui/src/components/CronJobsPanel.tsx +0 -200
  174. package/packages/hive-ui/src/components/NavLink.tsx +0 -34
  175. package/packages/hive-ui/src/components/NotesPanel.tsx +0 -79
  176. package/packages/hive-ui/src/components/SystemMonitor.tsx +0 -270
  177. package/packages/hive-ui/src/components/UsageStatsPanel.tsx +0 -334
  178. package/packages/hive-ui/src/components/WelcomeDialog.tsx +0 -279
  179. package/packages/hive-ui/src/components/ui/accordion.tsx +0 -52
  180. package/packages/hive-ui/src/components/ui/alert-dialog.tsx +0 -104
  181. package/packages/hive-ui/src/components/ui/alert.tsx +0 -45
  182. package/packages/hive-ui/src/components/ui/aspect-ratio.tsx +0 -5
  183. package/packages/hive-ui/src/components/ui/avatar.tsx +0 -38
  184. package/packages/hive-ui/src/components/ui/badge.tsx +0 -29
  185. package/packages/hive-ui/src/components/ui/bee-loader.tsx +0 -68
  186. package/packages/hive-ui/src/components/ui/breadcrumb.tsx +0 -90
  187. package/packages/hive-ui/src/components/ui/button.tsx +0 -47
  188. package/packages/hive-ui/src/components/ui/calendar.tsx +0 -54
  189. package/packages/hive-ui/src/components/ui/card.tsx +0 -45
  190. package/packages/hive-ui/src/components/ui/carousel.tsx +0 -224
  191. package/packages/hive-ui/src/components/ui/chart.tsx +0 -303
  192. package/packages/hive-ui/src/components/ui/checkbox.tsx +0 -26
  193. package/packages/hive-ui/src/components/ui/collapsible.tsx +0 -9
  194. package/packages/hive-ui/src/components/ui/command.tsx +0 -133
  195. package/packages/hive-ui/src/components/ui/context-menu.tsx +0 -178
  196. package/packages/hive-ui/src/components/ui/dialog.tsx +0 -95
  197. package/packages/hive-ui/src/components/ui/drawer.tsx +0 -87
  198. package/packages/hive-ui/src/components/ui/dropdown-menu.tsx +0 -179
  199. package/packages/hive-ui/src/components/ui/form.tsx +0 -129
  200. package/packages/hive-ui/src/components/ui/hover-card.tsx +0 -27
  201. package/packages/hive-ui/src/components/ui/input-otp.tsx +0 -61
  202. package/packages/hive-ui/src/components/ui/input.tsx +0 -22
  203. package/packages/hive-ui/src/components/ui/label.tsx +0 -17
  204. package/packages/hive-ui/src/components/ui/menubar.tsx +0 -207
  205. package/packages/hive-ui/src/components/ui/navigation-menu.tsx +0 -120
  206. package/packages/hive-ui/src/components/ui/pagination.tsx +0 -80
  207. package/packages/hive-ui/src/components/ui/popover.tsx +0 -29
  208. package/packages/hive-ui/src/components/ui/progress.tsx +0 -23
  209. package/packages/hive-ui/src/components/ui/radio-group.tsx +0 -36
  210. package/packages/hive-ui/src/components/ui/resizable.tsx +0 -37
  211. package/packages/hive-ui/src/components/ui/scroll-area.tsx +0 -38
  212. package/packages/hive-ui/src/components/ui/select.tsx +0 -143
  213. package/packages/hive-ui/src/components/ui/separator.tsx +0 -20
  214. package/packages/hive-ui/src/components/ui/sheet.tsx +0 -107
  215. package/packages/hive-ui/src/components/ui/sidebar.tsx +0 -636
  216. package/packages/hive-ui/src/components/ui/skeleton.tsx +0 -7
  217. package/packages/hive-ui/src/components/ui/slider.tsx +0 -23
  218. package/packages/hive-ui/src/components/ui/sonner.tsx +0 -27
  219. package/packages/hive-ui/src/components/ui/switch.tsx +0 -27
  220. package/packages/hive-ui/src/components/ui/table.tsx +0 -72
  221. package/packages/hive-ui/src/components/ui/tabs.tsx +0 -53
  222. package/packages/hive-ui/src/components/ui/textarea.tsx +0 -21
  223. package/packages/hive-ui/src/components/ui/toast.tsx +0 -111
  224. package/packages/hive-ui/src/components/ui/toaster.tsx +0 -24
  225. package/packages/hive-ui/src/components/ui/toggle-group.tsx +0 -49
  226. package/packages/hive-ui/src/components/ui/toggle.tsx +0 -37
  227. package/packages/hive-ui/src/components/ui/tooltip.tsx +0 -28
  228. package/packages/hive-ui/src/components/ui/use-toast.ts +0 -3
  229. package/packages/hive-ui/src/hooks/use-mobile.tsx +0 -19
  230. package/packages/hive-ui/src/hooks/use-toast.ts +0 -186
  231. package/packages/hive-ui/src/hooks/useAgentConfig.ts +0 -25
  232. package/packages/hive-ui/src/hooks/useAgents.ts +0 -38
  233. package/packages/hive-ui/src/hooks/useBridge.ts +0 -38
  234. package/packages/hive-ui/src/hooks/useCanvas.ts +0 -24
  235. package/packages/hive-ui/src/hooks/useChannels.ts +0 -2
  236. package/packages/hive-ui/src/hooks/useEthics.ts +0 -51
  237. package/packages/hive-ui/src/hooks/useProviders.ts +0 -14
  238. package/packages/hive-ui/src/hooks/useTheme.ts +0 -29
  239. package/packages/hive-ui/src/hooks/useUserConfig.ts +0 -17
  240. package/packages/hive-ui/src/hooks/useWebSocket.ts +0 -12
  241. package/packages/hive-ui/src/index.css +0 -620
  242. package/packages/hive-ui/src/lib/api.ts +0 -100
  243. package/packages/hive-ui/src/lib/constants.ts +0 -6
  244. package/packages/hive-ui/src/lib/models.ts +0 -64
  245. package/packages/hive-ui/src/lib/swal.ts +0 -30
  246. package/packages/hive-ui/src/lib/utils.ts +0 -6
  247. package/packages/hive-ui/src/lib/websocket.ts +0 -7
  248. package/packages/hive-ui/src/main.tsx +0 -5
  249. package/packages/hive-ui/src/modules/agent-config/details/AgentDetailsEditor.tsx +0 -524
  250. package/packages/hive-ui/src/modules/agent-config/ethics/EthicsConflictDetector.tsx +0 -18
  251. package/packages/hive-ui/src/modules/agent-config/ethics/EthicsEditor.tsx +0 -19
  252. package/packages/hive-ui/src/modules/agent-config/ethics/EthicsRulesList.tsx +0 -36
  253. package/packages/hive-ui/src/modules/agent-config/ethics/EthicsTemplateGallery.tsx +0 -361
  254. package/packages/hive-ui/src/modules/agent-config/ethics/index.ts +0 -4
  255. package/packages/hive-ui/src/modules/agent-config/index.ts +0 -6
  256. package/packages/hive-ui/src/modules/agent-config/mcp/MCPServerAdd.tsx +0 -322
  257. package/packages/hive-ui/src/modules/agent-config/mcp/MCPServerCard.tsx +0 -93
  258. package/packages/hive-ui/src/modules/agent-config/mcp/MCPServerConfig.tsx +0 -427
  259. package/packages/hive-ui/src/modules/agent-config/mcp/MCPServerList.tsx +0 -85
  260. package/packages/hive-ui/src/modules/agent-config/mcp/MCPToolExplorer.tsx +0 -79
  261. package/packages/hive-ui/src/modules/agent-config/mcp/index.ts +0 -5
  262. package/packages/hive-ui/src/modules/agent-config/shared/ConfigEditorLayout.tsx +0 -30
  263. package/packages/hive-ui/src/modules/agent-config/shared/ConfigExporter.tsx +0 -26
  264. package/packages/hive-ui/src/modules/agent-config/shared/ConfigImporter.tsx +0 -25
  265. package/packages/hive-ui/src/modules/agent-config/shared/DiffViewer.tsx +0 -31
  266. package/packages/hive-ui/src/modules/agent-config/shared/MarkdownEditor.tsx +0 -32
  267. package/packages/hive-ui/src/modules/agent-config/shared/SaveStatusIndicator.tsx +0 -23
  268. package/packages/hive-ui/src/modules/agent-config/shared/ValidationPanel.tsx +0 -36
  269. package/packages/hive-ui/src/modules/agent-config/shared/index.ts +0 -7
  270. package/packages/hive-ui/src/modules/agent-config/skills/SkillCard.tsx +0 -81
  271. package/packages/hive-ui/src/modules/agent-config/skills/SkillConfigEditor.tsx +0 -22
  272. package/packages/hive-ui/src/modules/agent-config/skills/SkillCreator.tsx +0 -60
  273. package/packages/hive-ui/src/modules/agent-config/skills/SkillInstaller.tsx +0 -23
  274. package/packages/hive-ui/src/modules/agent-config/skills/SkillList.tsx +0 -72
  275. package/packages/hive-ui/src/modules/agent-config/skills/SkillsTab.tsx +0 -202
  276. package/packages/hive-ui/src/modules/agent-config/skills/index.ts +0 -5
  277. package/packages/hive-ui/src/modules/agent-config/tools/ToolCard.tsx +0 -27
  278. package/packages/hive-ui/src/modules/agent-config/tools/ToolConfigPanel.tsx +0 -22
  279. package/packages/hive-ui/src/modules/agent-config/tools/ToolManager.tsx +0 -266
  280. package/packages/hive-ui/src/modules/agent-config/tools/ToolPermissions.tsx +0 -287
  281. package/packages/hive-ui/src/modules/agent-config/tools/ToolRegistry.tsx +0 -84
  282. package/packages/hive-ui/src/modules/agent-config/tools/ToolUsageStats.tsx +0 -52
  283. package/packages/hive-ui/src/modules/agent-config/tools/index.ts +0 -4
  284. package/packages/hive-ui/src/modules/agent-config/user/ActiveAgentsList.tsx +0 -109
  285. package/packages/hive-ui/src/modules/agent-config/user/GlobalConfigOverview.tsx +0 -119
  286. package/packages/hive-ui/src/modules/agent-config/user/UserMemoryManager.tsx +0 -54
  287. package/packages/hive-ui/src/modules/agent-config/user/UserPreferencesForm.tsx +0 -163
  288. package/packages/hive-ui/src/modules/agent-config/user/UserProfileEditor.tsx +0 -261
  289. package/packages/hive-ui/src/modules/agent-config/user/index.ts +0 -3
  290. package/packages/hive-ui/src/modules/agents/AgentActivityLog.tsx +0 -25
  291. package/packages/hive-ui/src/modules/agents/AgentCard.tsx +0 -305
  292. package/packages/hive-ui/src/modules/agents/AgentCreateForm.tsx +0 -446
  293. package/packages/hive-ui/src/modules/agents/AgentDetail.tsx +0 -28
  294. package/packages/hive-ui/src/modules/agents/AgentInternalCard.tsx +0 -162
  295. package/packages/hive-ui/src/modules/agents/AgentList.tsx +0 -29
  296. package/packages/hive-ui/src/modules/agents/AgentStatusBadge.tsx +0 -34
  297. package/packages/hive-ui/src/modules/agents/ModelSelector.tsx +0 -151
  298. package/packages/hive-ui/src/modules/bridge/BridgeLogViewer.tsx +0 -61
  299. package/packages/hive-ui/src/modules/bridge/BridgeProcessList.tsx +0 -77
  300. package/packages/hive-ui/src/modules/bridge/BridgeStatus.tsx +0 -23
  301. package/packages/hive-ui/src/modules/bridge/BridgeTerminal.tsx +0 -7
  302. package/packages/hive-ui/src/modules/canvas/CanvasButton.tsx +0 -3
  303. package/packages/hive-ui/src/modules/canvas/CanvasChart.tsx +0 -3
  304. package/packages/hive-ui/src/modules/canvas/CanvasComponentMap.tsx +0 -605
  305. package/packages/hive-ui/src/modules/canvas/CanvasContainer.tsx +0 -360
  306. package/packages/hive-ui/src/modules/canvas/CanvasForm.tsx +0 -3
  307. package/packages/hive-ui/src/modules/canvas/CanvasMarkdown.tsx +0 -3
  308. package/packages/hive-ui/src/modules/canvas/CanvasTable.tsx +0 -3
  309. package/packages/hive-ui/src/modules/canvas/ComponentRenderer.tsx +0 -30
  310. package/packages/hive-ui/src/modules/canvas/DynamicRenderer.tsx +0 -3
  311. package/packages/hive-ui/src/modules/channels/available/AvailableChannelsGrid.tsx +0 -89
  312. package/packages/hive-ui/src/modules/channels/available/ChannelAuthForm.tsx +0 -33
  313. package/packages/hive-ui/src/modules/channels/available/ChannelSetupWizard.tsx +0 -48
  314. package/packages/hive-ui/src/modules/channels/available/ChannelTestConnection.tsx +0 -37
  315. package/packages/hive-ui/src/modules/channels/available/ChannelTypeCard.tsx +0 -30
  316. package/packages/hive-ui/src/modules/channels/available/ChannelWebhookConfig.tsx +0 -30
  317. package/packages/hive-ui/src/modules/channels/available/index.ts +0 -6
  318. package/packages/hive-ui/src/modules/channels/connected/ChannelCard.tsx +0 -95
  319. package/packages/hive-ui/src/modules/channels/connected/ChannelConfigPanel.tsx +0 -260
  320. package/packages/hive-ui/src/modules/channels/connected/ChannelDisconnectButton.tsx +0 -21
  321. package/packages/hive-ui/src/modules/channels/connected/ChannelLogsViewer.tsx +0 -42
  322. package/packages/hive-ui/src/modules/channels/connected/ChannelQRCode.tsx +0 -32
  323. package/packages/hive-ui/src/modules/channels/connected/ChannelReconnectButton.tsx +0 -16
  324. package/packages/hive-ui/src/modules/channels/connected/ChannelStatusBadge.tsx +0 -26
  325. package/packages/hive-ui/src/modules/channels/connected/ConnectedChannelsList.tsx +0 -40
  326. package/packages/hive-ui/src/modules/channels/connected/index.ts +0 -8
  327. package/packages/hive-ui/src/modules/channels/shared/ChannelCard.tsx +0 -84
  328. package/packages/hive-ui/src/modules/channels/shared/ChannelConfigDialog.tsx +0 -279
  329. package/packages/hive-ui/src/modules/channels/shared/ChannelIcon.tsx +0 -40
  330. package/packages/hive-ui/src/modules/channels/shared/ChannelStats.tsx +0 -37
  331. package/packages/hive-ui/src/modules/channels/shared/ChannelTypeBadge.tsx +0 -23
  332. package/packages/hive-ui/src/modules/channels/shared/ConnectionHealthIndicator.tsx +0 -20
  333. package/packages/hive-ui/src/modules/channels/shared/MessagePreview.tsx +0 -19
  334. package/packages/hive-ui/src/modules/channels/shared/index.ts +0 -5
  335. package/packages/hive-ui/src/modules/chat/ChatContainer.tsx +0 -268
  336. package/packages/hive-ui/src/modules/chat/ChatHistory.tsx +0 -101
  337. package/packages/hive-ui/src/modules/chat/ChatInput.tsx +0 -108
  338. package/packages/hive-ui/src/modules/chat/ChatMessage.tsx +0 -137
  339. package/packages/hive-ui/src/modules/chat/ThinkingIndicator.tsx +0 -10
  340. package/packages/hive-ui/src/modules/layout/AppLayout.tsx +0 -45
  341. package/packages/hive-ui/src/modules/layout/ConnectionStatus.tsx +0 -19
  342. package/packages/hive-ui/src/modules/layout/Header.tsx +0 -20
  343. package/packages/hive-ui/src/modules/layout/HiveSidebar.tsx +0 -173
  344. package/packages/hive-ui/src/modules/layout/ThemeToggle.tsx +0 -18
  345. package/packages/hive-ui/src/modules/providers/ProviderCard.tsx +0 -319
  346. package/packages/hive-ui/src/modules/providers/ProviderConfigForm.tsx +0 -146
  347. package/packages/hive-ui/src/modules/providers/ProviderFailoverConfig.tsx +0 -110
  348. package/packages/hive-ui/src/modules/providers/ProviderList.tsx +0 -33
  349. package/packages/hive-ui/src/modules/providers/ProviderStatusIndicator.tsx +0 -23
  350. package/packages/hive-ui/src/modules/providers/configs/ProviderAPIKeyManager.tsx +0 -39
  351. package/packages/hive-ui/src/modules/providers/configs/ProviderEndpointConfig.tsx +0 -27
  352. package/packages/hive-ui/src/modules/providers/configs/ProviderRateLimits.tsx +0 -37
  353. package/packages/hive-ui/src/modules/providers/configs/ProviderRetryPolicy.tsx +0 -46
  354. package/packages/hive-ui/src/modules/providers/configs/index.ts +0 -4
  355. package/packages/hive-ui/src/modules/providers/index.ts +0 -5
  356. package/packages/hive-ui/src/modules/providers/models/ModelBenchmarkBadge.tsx +0 -21
  357. package/packages/hive-ui/src/modules/providers/models/ModelCapabilities.tsx +0 -44
  358. package/packages/hive-ui/src/modules/providers/models/ModelCard.tsx +0 -36
  359. package/packages/hive-ui/src/modules/providers/models/ModelComparisonTable.tsx +0 -47
  360. package/packages/hive-ui/src/modules/providers/models/ModelList.tsx +0 -51
  361. package/packages/hive-ui/src/modules/providers/models/ModelPricingInfo.tsx +0 -17
  362. package/packages/hive-ui/src/modules/providers/models/ModelSelector.tsx +0 -32
  363. package/packages/hive-ui/src/modules/providers/models/index.ts +0 -7
  364. package/packages/hive-ui/src/pages/AgentDetailPage.tsx +0 -74
  365. package/packages/hive-ui/src/pages/AgentNewPage.tsx +0 -5
  366. package/packages/hive-ui/src/pages/AgentsPage.tsx +0 -147
  367. package/packages/hive-ui/src/pages/BridgePage.tsx +0 -83
  368. package/packages/hive-ui/src/pages/CanvasPage.tsx +0 -32
  369. package/packages/hive-ui/src/pages/ChannelsPage.tsx +0 -176
  370. package/packages/hive-ui/src/pages/DashboardPage.tsx +0 -321
  371. package/packages/hive-ui/src/pages/Index.tsx +0 -14
  372. package/packages/hive-ui/src/pages/LogsPage.tsx +0 -252
  373. package/packages/hive-ui/src/pages/NotFound.tsx +0 -24
  374. package/packages/hive-ui/src/pages/ProjectsPage.tsx +0 -241
  375. package/packages/hive-ui/src/pages/ProvidersPage.tsx +0 -111
  376. package/packages/hive-ui/src/pages/SettingsPage.tsx +0 -147
  377. package/packages/hive-ui/src/pages/SetupPage.tsx +0 -1177
  378. package/packages/hive-ui/src/pages/WebChatPage.tsx +0 -15
  379. package/packages/hive-ui/src/stores/agentConfigStore.ts +0 -32
  380. package/packages/hive-ui/src/stores/agentStore.ts +0 -5
  381. package/packages/hive-ui/src/stores/bridgeStore.ts +0 -237
  382. package/packages/hive-ui/src/stores/canvasStore.ts +0 -250
  383. package/packages/hive-ui/src/stores/channelStore.ts +0 -5
  384. package/packages/hive-ui/src/stores/chatStore.ts +0 -42
  385. package/packages/hive-ui/src/stores/ethicsStore.ts +0 -141
  386. package/packages/hive-ui/src/stores/mcpStore.ts +0 -5
  387. package/packages/hive-ui/src/stores/modelStore.ts +0 -2
  388. package/packages/hive-ui/src/stores/projectsStore.ts +0 -141
  389. package/packages/hive-ui/src/stores/providerStore.ts +0 -2
  390. package/packages/hive-ui/src/stores/skillStore.ts +0 -5
  391. package/packages/hive-ui/src/stores/toolStore.ts +0 -5
  392. package/packages/hive-ui/src/stores/useGlobalConfigStore.ts +0 -937
  393. package/packages/hive-ui/src/stores/useLoaderStore.ts +0 -21
  394. package/packages/hive-ui/src/stores/useNotesAndCronsStore.ts +0 -144
  395. package/packages/hive-ui/src/stores/useWebSocketStore.ts +0 -152
  396. package/packages/hive-ui/src/stores/useWelcomeStore.ts +0 -37
  397. package/packages/hive-ui/src/stores/userConfigStore.ts +0 -23
  398. package/packages/hive-ui/src/stores/userStore.ts +0 -82
  399. package/packages/hive-ui/src/test/setup.ts +0 -15
  400. package/packages/hive-ui/src/types/agent-config.ts +0 -33
  401. package/packages/hive-ui/src/types/agent.ts +0 -65
  402. package/packages/hive-ui/src/types/bridge.ts +0 -27
  403. package/packages/hive-ui/src/types/canvas.ts +0 -76
  404. package/packages/hive-ui/src/types/channels.ts +0 -109
  405. package/packages/hive-ui/src/types/chat.ts +0 -25
  406. package/packages/hive-ui/src/types/connections.ts +0 -17
  407. package/packages/hive-ui/src/types/ethics.ts +0 -41
  408. package/packages/hive-ui/src/types/index.ts +0 -15
  409. package/packages/hive-ui/src/types/mcp.ts +0 -36
  410. package/packages/hive-ui/src/types/notes-crons.ts +0 -31
  411. package/packages/hive-ui/src/types/providers.ts +0 -145
  412. package/packages/hive-ui/src/types/skill.ts +0 -12
  413. package/packages/hive-ui/src/types/tool.ts +0 -44
  414. package/packages/hive-ui/src/types/user.ts +0 -26
  415. package/packages/hive-ui/src/types/websocket.ts +0 -14
  416. package/packages/hive-ui/src/vite-env.d.ts +0 -1
  417. package/packages/mcp/package.json +0 -26
  418. package/packages/mcp/src/config.ts +0 -13
  419. package/packages/mcp/src/index.ts +0 -1
  420. package/packages/mcp/src/logger.ts +0 -42
  421. package/packages/mcp/src/manager.ts +0 -439
  422. package/packages/mcp/src/transports/index.ts +0 -67
  423. package/packages/mcp/src/transports/sse.ts +0 -241
  424. package/packages/mcp/src/transports/websocket.ts +0 -159
  425. package/packages/skills/package.json +0 -21
  426. package/packages/skills/src/index.ts +0 -1
  427. package/packages/skills/src/loader.ts +0 -346
@@ -1,267 +0,0 @@
1
- import { existsSync } from "node:fs"
2
- import { randomUUID } from "node:crypto"
3
- import { getDbPathLazy } from "../../storage/sqlite"
4
- import {
5
- initOnboardingDb,
6
- saveUserProfile,
7
- saveProviderConfig,
8
- activateChannel,
9
- saveVoiceConfig,
10
- activateEthics,
11
- } from "../../storage/onboarding"
12
- import type { Config } from "../../config/loader"
13
-
14
- export function isSetupMode(): boolean {
15
- return !existsSync(getDbPathLazy())
16
- }
17
-
18
- export async function handleSetupStatus(): Promise<Response> {
19
- const setupMode = isSetupMode()
20
- return Response.json({
21
- configured: !setupMode,
22
- setupMode,
23
- })
24
- }
25
-
26
- export async function handleVerifyProvider(req: Request): Promise<Response> {
27
- const body = await req.json().catch(() => ({}))
28
- const { provider, apiKey, model } = body
29
-
30
- if (!provider || !apiKey) {
31
- return Response.json({
32
- success: false,
33
- error: "Provider and API key are required",
34
- }, { status: 400 })
35
- }
36
-
37
- try {
38
- let testUrl: string | null = null
39
- let testBody: unknown = null
40
- let headers: Record<string, string> = {}
41
-
42
- const testMessages = [{ role: "user" as const, content: "Say 'ok' if you can read this." }]
43
-
44
- if (provider === "ollama") {
45
- try {
46
- const response = await fetch("http://localhost:11434/api/tags", {
47
- signal: AbortSignal.timeout(5000),
48
- })
49
- return Response.json({
50
- success: response.ok,
51
- error: response.ok ? null : "Could not connect to Ollama",
52
- })
53
- } catch {
54
- return Response.json({
55
- success: false,
56
- error: "Could not connect to Ollama at http://localhost:11434",
57
- })
58
- }
59
- }
60
-
61
- if (provider === "anthropic") {
62
- testUrl = "https://api.anthropic.com/v1/messages"
63
- testBody = {
64
- model: model || "claude-sonnet-4-6",
65
- max_tokens: 10,
66
- messages: testMessages,
67
- }
68
- headers = {
69
- "Content-Type": "application/json",
70
- "x-api-key": apiKey,
71
- "anthropic-version": "2023-06-01",
72
- "anthropic-dangerous-direct-browser-access": "true",
73
- }
74
- } else if (provider === "openai") {
75
- testUrl = "https://api.openai.com/v1/chat/completions"
76
- testBody = {
77
- model: model || "gpt-4o-mini",
78
- max_tokens: 10,
79
- messages: testMessages,
80
- }
81
- headers = {
82
- "Content-Type": "application/json",
83
- "Authorization": `Bearer ${apiKey}`,
84
- }
85
- } else if (provider === "gemini") {
86
- testUrl = `https://generativelanguage.googleapis.com/v1beta/models/${model || "gemini-2.5-flash"}:generateContent?key=${apiKey}`
87
- testBody = {
88
- contents: [{ parts: [{ text: "Say ok" }] }],
89
- }
90
- headers = { "Content-Type": "application/json" }
91
- } else if (provider === "groq") {
92
- testUrl = "https://api.groq.com/openai/v1/chat/completions"
93
- testBody = {
94
- model: model || "llama-3.3-70b-versatile",
95
- max_tokens: 10,
96
- messages: testMessages,
97
- }
98
- headers = {
99
- "Content-Type": "application/json",
100
- "Authorization": `Bearer ${apiKey}`,
101
- }
102
- } else if (provider === "openrouter") {
103
- testUrl = "https://openrouter.ai/api/v1/chat/completions"
104
- testBody = {
105
- model: model || "meta-llama/llama-3.3-70b-instruct",
106
- max_tokens: 10,
107
- messages: testMessages,
108
- }
109
- headers = {
110
- "Content-Type": "application/json",
111
- "Authorization": `Bearer ${apiKey}`,
112
- }
113
- } else if (provider === "mistral") {
114
- testUrl = "https://api.mistral.ai/v1/chat/completions"
115
- testBody = {
116
- model: model || "mistral-small-latest",
117
- max_tokens: 10,
118
- messages: testMessages,
119
- }
120
- headers = {
121
- "Content-Type": "application/json",
122
- "Authorization": `Bearer ${apiKey}`,
123
- }
124
- } else if (provider === "deepseek") {
125
- testUrl = "https://api.deepseek.com/v1/chat/completions"
126
- testBody = {
127
- model: model || "deepseek-chat",
128
- max_tokens: 10,
129
- messages: testMessages,
130
- }
131
- headers = {
132
- "Content-Type": "application/json",
133
- "Authorization": `Bearer ${apiKey}`,
134
- }
135
- } else if (provider === "kimi") {
136
- testUrl = "https://api.moonshot.cn/v1/chat/completions"
137
- testBody = {
138
- model: model || "moonshot-v1-8k",
139
- max_tokens: 10,
140
- messages: testMessages,
141
- }
142
- headers = {
143
- "Content-Type": "application/json",
144
- "Authorization": `Bearer ${apiKey}`,
145
- }
146
- }
147
-
148
- if (!testUrl) {
149
- return Response.json({
150
- success: false,
151
- error: "Unsupported provider",
152
- }, { status: 400 })
153
- }
154
-
155
- const response = await fetch(testUrl, {
156
- method: "POST",
157
- headers,
158
- body: JSON.stringify(testBody),
159
- signal: AbortSignal.timeout(10000),
160
- })
161
-
162
- return Response.json({
163
- success: response.ok,
164
- error: response.ok ? null : `API error: ${response.status}`,
165
- })
166
- } catch (error) {
167
- return Response.json({
168
- success: false,
169
- error: `Connection error: ${(error as Error).message}`,
170
- })
171
- }
172
- }
173
-
174
- export async function handleCompleteSetup(
175
- req: Request,
176
- config: Config,
177
- addCorsHeaders: (response: Response, request: Request) => Response
178
- ): Promise<Response> {
179
- if (!isSetupMode()) {
180
- return addCorsHeaders(Response.json({
181
- success: false,
182
- error: "Setup already completed. Use config endpoints to modify settings.",
183
- }, { status: 400 }), req)
184
- }
185
-
186
- const body = await req.json().catch(() => ({}))
187
-
188
- try {
189
- initOnboardingDb()
190
-
191
- const userId = `user_${randomUUID().split("-")[0]}`
192
- const agentId = `agent_${randomUUID().split("-")[0]}`
193
- const channelUserId = randomUUID()
194
-
195
- saveUserProfile({
196
- userId,
197
- userName: body.userName || "User",
198
- userLanguage: body.userLanguage || "es",
199
- userTimezone: body.userTimezone || "UTC",
200
- userOccupation: body.userOccupation || "",
201
- userNotes: body.userNotes || "",
202
- agentName: body.agentName || "Bee",
203
- agentId,
204
- agentDescription: body.agentDescription || "",
205
- agentTone: "friendly",
206
- channelUserId,
207
- })
208
-
209
- if (body.provider && body.apiKey) {
210
- await saveProviderConfig({
211
- userId,
212
- provider: body.provider,
213
- model: body.model,
214
- apiKey: body.apiKey,
215
- })
216
- }
217
-
218
- await activateChannel(userId, {
219
- channelId: "webchat",
220
- channelUserId,
221
- config: {},
222
- })
223
-
224
- if (body.channels) {
225
- for (const [channelId, channelData] of Object.entries(body.channels as Record<string, unknown>)) {
226
- if (channelId !== "webchat" && channelData && typeof channelData === "object" && (channelData as { enabled?: boolean }).enabled) {
227
- await activateChannel(userId, {
228
- channelId,
229
- config: (channelData as { config?: Record<string, unknown> }).config || {},
230
- })
231
- }
232
- }
233
- }
234
-
235
- if (body.voiceEnabled) {
236
- await saveVoiceConfig({
237
- userId,
238
- channelId: "webchat",
239
- voiceEnabled: true,
240
- sttProvider: body.sttProvider || "groq-whisper",
241
- ttsProvider: body.ttsProvider || "elevenlabs",
242
- })
243
- }
244
-
245
- // Activar ethics por defecto
246
- activateEthics(userId, "default")
247
-
248
- const authToken = randomUUID().replace(/-/g, "")
249
-
250
- process.env.HIVE_AUTH_TOKEN = authToken
251
- // Note: userId and agentId are now resolved from database, not environment variables
252
- // These assignments are kept for backward compatibility but are no longer used
253
-
254
- return addCorsHeaders(Response.json({
255
- success: true,
256
- userId,
257
- agentId,
258
- authToken,
259
- message: "Setup completed successfully",
260
- }), req)
261
- } catch (error) {
262
- return addCorsHeaders(Response.json({
263
- success: false,
264
- error: (error as Error).message,
265
- }, { status: 500 }), req)
266
- }
267
- }
@@ -1,70 +0,0 @@
1
- import { getDb } from "../../storage/sqlite"
2
- import { emitCanvas } from "../../canvas/emitter"
3
-
4
- export async function handleGetSkills(req: Request, addCorsHeaders: (r: Response, req: Request) => Response): Promise<Response> {
5
- const skills = getDb().query(`
6
- SELECT id, name, category, tools, triggers, body, version, active
7
- FROM skills
8
- ORDER BY name
9
- `).all() as Record<string, unknown>[]
10
-
11
- return addCorsHeaders(Response.json({
12
- skills: skills.map(s => ({
13
- id: s.id,
14
- name: s.name,
15
- category: s.category,
16
- tools: s.tools,
17
- triggers: s.triggers,
18
- body: s.body,
19
- version: s.version,
20
- active: s.active === 1,
21
- }))
22
- }), req)
23
- }
24
-
25
- export async function handleActivateSkill(req: Request, addCorsHeaders: (r: Response, req: Request) => Response): Promise<Response> {
26
- const body = await req.json().catch(() => ({}))
27
- const { skillId, active } = body
28
-
29
- if (!skillId) {
30
- return addCorsHeaders(Response.json({ success: false, error: "skillId required" }), req)
31
- }
32
-
33
- getDb().query(`UPDATE skills SET active = ? WHERE id = ?`).run(active ? 1 : 0, skillId)
34
-
35
- return addCorsHeaders(Response.json({ success: true, skillId, active }), req)
36
- }
37
-
38
- export async function handleDeleteSkill(req: Request, addCorsHeaders: (r: Response, req: Request) => Response): Promise<Response> {
39
- const url = new URL(req.url)
40
- const skillId = url.pathname.split("/").pop()
41
-
42
- if (!skillId) {
43
- return addCorsHeaders(Response.json({ success: false, error: "skillId required" }), req)
44
- }
45
-
46
- getDb().query(`DELETE FROM skills WHERE id = ?`).run(skillId)
47
-
48
- return addCorsHeaders(Response.json({ success: true }), req)
49
- }
50
-
51
- export async function handleCreateSkill(
52
- req: Request,
53
- addCorsHeaders: (r: Response, req: Request) => Response
54
- ): Promise<Response> {
55
- const body = await req.json().catch(() => ({}));
56
- const { name, category, tools, triggers, body: bodyContent } = body;
57
-
58
- if (!name) {
59
- return addCorsHeaders(new Response("Missing name", { status: 400 }), req);
60
- }
61
-
62
- const { randomUUID } = await import("crypto");
63
- const id = randomUUID();
64
-
65
- getDb().query(
66
- `INSERT INTO skills(id, name, category, tools, triggers, body, version, active) VALUES(?, ?, ?, ?, ?, ?, 1, 1)`
67
- ).run(id, name, category || "", tools || "", triggers || "", bodyContent || "", 1);
68
-
69
- return addCorsHeaders(Response.json({ success: true, id }), req);
70
- }
@@ -1,165 +0,0 @@
1
- import { getDb } from "../../storage/sqlite.ts"
2
- import { loadConfig } from "../../config/loader.ts"
3
- import { cpus } from "node:os"
4
-
5
- export function getSystemStats(startTime: number) {
6
- const mem = process.memoryUsage()
7
- const uptimeSeconds = Math.floor((Date.now() - startTime) / 1000)
8
- const uptimeStr = new Date(uptimeSeconds * 1000).toISOString().substr(11, 8)
9
-
10
- return {
11
- cpu: 0, // Placeholder - Node.js doesn't provide per-process CPU
12
- memory: {
13
- rss: Math.round(mem.rss / 1024 / 1024), // MB
14
- heapUsed: Math.round(mem.heapUsed / 1024 / 1024), // MB
15
- heapTotal: Math.round(mem.heapTotal / 1024 / 1024), // MB
16
- heapPercent: Math.round((mem.heapUsed / mem.heapTotal) * 100 * 100) / 100,
17
- external: Math.round((mem.external || 0) / 1024 / 1024), // MB
18
- },
19
- uptime: uptimeStr,
20
- connections: 0, // Placeholder
21
- cores: cpus().length,
22
- recentMessages: 0, // Placeholder
23
- }
24
- }
25
-
26
- export async function handleGetActivityStats(req: Request, addCorsHeaders: (r: Response, req: Request) => Response): Promise<Response> {
27
- const db = getDb()
28
- const url = new URL(req.url)
29
- const hours = parseInt(url.searchParams.get("hours") || "12", 10)
30
-
31
- // Get message counts per hour from conversations table
32
- const now = Date.now()
33
- const startTime = now - (hours * 60 * 60 * 1000)
34
-
35
- const rows = db.query(`
36
- SELECT
37
- strftime('%Y-%m-%d %H:00', datetime(created_at, 'unixepoch')) as hour,
38
- COUNT(*) as count
39
- FROM conversations
40
- WHERE created_at >= ?
41
- GROUP BY hour
42
- ORDER BY hour
43
- `).all(startTime / 1000) as { hour: string; count: number }[]
44
-
45
- // Format as array expected by frontend
46
- const activityData = rows.map(r => ({
47
- time: r.hour,
48
- count: r.count,
49
- }))
50
-
51
- return addCorsHeaders(Response.json(activityData), req)
52
- }
53
-
54
- export async function handleGetSystemStats(req: Request, addCorsHeaders: (r: Response, req: Request) => Response, startTime: number): Promise<Response> {
55
- return addCorsHeaders(Response.json(getSystemStats(startTime)), req)
56
- }
57
-
58
- export async function handleGetUsageStats(req: Request, addCorsHeaders: (r: Response, req: Request) => Response): Promise<Response> {
59
- const db = getDb()
60
-
61
- // Get totals from usage_records table
62
- const totals = db.query(`
63
- SELECT
64
- COALESCE(SUM(input_tokens), 0) as inputTokens,
65
- COALESCE(SUM(output_tokens), 0) as outputTokens,
66
- COALESCE(SUM(cost_usd), 0) as costUsd
67
- FROM usage_records
68
- `).get() as { inputTokens: number; outputTokens: number; costUsd: number }
69
-
70
- // Get by provider
71
- const byProviderRows = db.query(`
72
- SELECT
73
- provider,
74
- COALESCE(SUM(input_tokens), 0) as inputTokens,
75
- COALESCE(SUM(output_tokens), 0) as outputTokens,
76
- COALESCE(SUM(cost_usd), 0) as costUsd
77
- FROM usage_records
78
- GROUP BY provider
79
- `).all() as { provider: string; inputTokens: number; outputTokens: number; costUsd: number }[]
80
-
81
- // Get by model
82
- const byModelRows = db.query(`
83
- SELECT
84
- model,
85
- COALESCE(SUM(input_tokens), 0) as inputTokens,
86
- COALESCE(SUM(output_tokens), 0) as outputTokens,
87
- COALESCE(SUM(cost_usd), 0) as costUsd
88
- FROM usage_records
89
- GROUP BY model
90
- `).all() as { model: string; inputTokens: number; outputTokens: number; costUsd: number }[]
91
-
92
- const totalTokens = (totals.inputTokens || 0) + (totals.outputTokens || 0)
93
- const totalCostUsd = totals.costUsd || 0
94
-
95
- // TOON savings (placeholder - actual calculation depends on implementation)
96
- const toonSavedTokens = 0
97
- const toonSavedCost = 0
98
- const toonSavingsPercent = 0
99
-
100
- const stats: UsageStats = {
101
- totalTokens,
102
- totalInputTokens: totals.inputTokens || 0,
103
- totalOutputTokens: totals.outputTokens || 0,
104
- totalCostUsd,
105
- toonSavedTokens,
106
- toonSavedCost,
107
- toonSavingsPercent,
108
- byProvider: Object.fromEntries(
109
- byProviderRows.map(r => [r.provider, {
110
- tokens: (r.inputTokens || 0) + (r.outputTokens || 0),
111
- costUsd: r.costUsd || 0,
112
- inputTokens: r.inputTokens || 0,
113
- outputTokens: r.outputTokens || 0,
114
- }])
115
- ),
116
- byModel: Object.fromEntries(
117
- byModelRows.map(r => [r.model, {
118
- tokens: (r.inputTokens || 0) + (r.outputTokens || 0),
119
- costUsd: r.costUsd || 0,
120
- provider: "unknown",
121
- inputTokens: r.inputTokens || 0,
122
- outputTokens: r.outputTokens || 0,
123
- }])
124
- ),
125
- }
126
-
127
- return addCorsHeaders(Response.json(stats), req)
128
- }
129
-
130
- // Add UsageStats interface for backend
131
- interface UsageStats {
132
- totalTokens: number;
133
- totalInputTokens: number;
134
- totalOutputTokens: number;
135
- totalCostUsd: number;
136
- toonSavedTokens: number;
137
- toonSavedCost: number;
138
- toonSavingsPercent: number;
139
- byProvider: Record<string, { tokens: number; costUsd: number; inputTokens: number; outputTokens: number }>;
140
- byModel: Record<string, { tokens: number; costUsd: number; provider: string; inputTokens: number; outputTokens: number }>;
141
- }
142
-
143
- export async function handleSystemReload(req: Request, addCorsHeaders: (r: Response, req: Request) => Response): Promise<Response> {
144
- return addCorsHeaders(Response.json({ success: true, message: "Reload triggered" }), req)
145
- }
146
-
147
- export async function handleApiReload(
148
- req: Request,
149
- addCorsHeaders: (r: Response, req: Request) => Response,
150
- agent?: any
151
- ): Promise<Response> {
152
- try {
153
- const newConfig = await loadConfig()
154
- if (agent) {
155
- await agent.updateConfig(newConfig)
156
- await agent.reload()
157
- }
158
- return addCorsHeaders(Response.json({ success: true, message: "Configuration reloaded" }), req)
159
- } catch (error) {
160
- return addCorsHeaders(Response.json(
161
- { success: false, error: (error as Error).message },
162
- { status: 500 }
163
- ), req)
164
- }
165
- }
@@ -1,44 +0,0 @@
1
- import { getDb } from "../../storage/sqlite"
2
-
3
- export async function handleGetTasks(req: Request, addCorsHeaders: (r: Response, req: Request) => Response): Promise<Response> {
4
- const url = new URL(req.url)
5
- const agentId = url.searchParams.get("agentId")
6
-
7
- let tasks
8
- if (agentId) {
9
- tasks = getDb().query("SELECT * FROM tasks WHERE agent_id = ? ORDER BY id ASC").all(agentId)
10
- } else {
11
- tasks = getDb().query("SELECT * FROM tasks ORDER BY id ASC").all()
12
- }
13
-
14
- return addCorsHeaders(Response.json({ tasks }), req)
15
- }
16
-
17
- export async function handleUpdateTask(req: Request, addCorsHeaders: (r: Response, req: Request) => Response): Promise<Response> {
18
- const url = new URL(req.url)
19
- const taskId = url.pathname.split("/").pop()
20
- const body = await req.json().catch(() => ({}))
21
-
22
- if (!taskId) {
23
- return addCorsHeaders(new Response("Missing ID", { status: 400 }), req)
24
- }
25
-
26
- const updates: string[] = []
27
- const params: unknown[] = []
28
-
29
- if (body.status !== undefined) {
30
- updates.push("status = ?")
31
- params.push(body.status)
32
- }
33
- if (body.result !== undefined) {
34
- updates.push("result = ?")
35
- params.push(body.result)
36
- }
37
-
38
- if (updates.length > 0) {
39
- params.push(taskId)
40
- getDb().query(`UPDATE tasks SET ${updates.join(", ")} WHERE id = ?`).run(...params as any[])
41
- }
42
-
43
- return addCorsHeaders(Response.json({ ok: true }), req)
44
- }
@@ -1,35 +0,0 @@
1
- import { getDb } from "../../storage/sqlite"
2
-
3
- export async function handleGetTools(req: Request, addCorsHeaders: (r: Response, req: Request) => Response): Promise<Response> {
4
- const tools = getDb().query(`
5
- SELECT id, name, description, category, active, enabled
6
- FROM tools
7
- ORDER BY name
8
- `).all() as Record<string, unknown>[]
9
-
10
- return addCorsHeaders(Response.json({
11
- tools: tools.map(t => ({
12
- id: t.id,
13
- name: t.name,
14
- description: t.description,
15
- category: t.category,
16
- active: t.active === 1,
17
- enabled: t.enabled === 1,
18
- }))
19
- }), req)
20
- }
21
-
22
- export async function handleActivateTool(req: Request, addCorsHeaders: (r: Response, req: Request) => Response): Promise<Response> {
23
- const url = new URL(req.url)
24
- const toolId = url.pathname.split("/")[3]
25
- const body = await req.json().catch(() => ({}))
26
- const { active } = body
27
-
28
- if (!toolId) {
29
- return addCorsHeaders(Response.json({ success: false, error: "toolId required" }), req)
30
- }
31
-
32
- getDb().query(`UPDATE tools SET active = ?, enabled = ? WHERE id = ?`).run(active ? 1 : 0, active ? 1 : 0, toolId)
33
-
34
- return addCorsHeaders(Response.json({ success: true, toolId, active }), req)
35
- }
@@ -1,118 +0,0 @@
1
- import { getDb } from "../../storage/sqlite"
2
-
3
- export async function handleGetUsers(req: Request, addCorsHeaders: (r: Response, req: Request) => Response): Promise<Response> {
4
- const users = getDb().query(`
5
- SELECT u.*, COUNT(DISTINCT a.id) as agent_count
6
- FROM users u
7
- LEFT JOIN agents a ON u.id = a.user_id
8
- GROUP BY u.id
9
- ORDER BY u.created_at DESC
10
- `).all() as Record<string, unknown>[]
11
-
12
- return addCorsHeaders(Response.json({
13
- users: users.map(u => ({
14
- id: u.id,
15
- name: u.name,
16
- language: u.language,
17
- timezone: u.timezone,
18
- occupation: u.occupation,
19
- notes: u.notes,
20
- createdAt: new Date((u.created_at as number) * 1000).toISOString(),
21
- agentCount: u.agent_count,
22
- }))
23
- }), req)
24
- }
25
-
26
- export async function handleCreateUser(req: Request, addCorsHeaders: (r: Response, req: Request) => Response): Promise<Response> {
27
- const body = await req.json().catch(() => ({}))
28
-
29
- const result = getDb().query(`
30
- INSERT INTO users(name, language, timezone, occupation, notes)
31
- VALUES(?, ?, ?, ?, ?)
32
- RETURNING id
33
- `).get(
34
- body.name || "User",
35
- body.language || "es",
36
- body.timezone || "UTC",
37
- body.occupation || "",
38
- body.notes || ""
39
- ) as { id: string } | undefined
40
-
41
- return addCorsHeaders(Response.json({
42
- ok: true,
43
- userId: result?.id
44
- }), req)
45
- }
46
-
47
- export async function handleUpdateUserSettings(req: Request, addCorsHeaders: (r: Response, req: Request) => Response): Promise<Response> {
48
- const url = new URL(req.url)
49
- const userId = url.searchParams.get("userId") || "default"
50
- const body = await req.json().catch(() => ({}))
51
-
52
- const updates: string[] = []
53
- const params: unknown[] = []
54
-
55
- if (body.name !== undefined) {
56
- updates.push("name = ?")
57
- params.push(body.name)
58
- }
59
- if (body.language !== undefined) {
60
- updates.push("language = ?")
61
- params.push(body.language)
62
- }
63
- if (body.timezone !== undefined) {
64
- updates.push("timezone = ?")
65
- params.push(body.timezone)
66
- }
67
- if (body.occupation !== undefined) {
68
- updates.push("occupation = ?")
69
- params.push(body.occupation)
70
- }
71
- if (body.notes !== undefined) {
72
- updates.push("notes = ?")
73
- params.push(body.notes)
74
- }
75
-
76
- if (updates.length > 0) {
77
- params.push(userId)
78
- getDb().query(`UPDATE users SET ${updates.join(", ")} WHERE id = ?`).run(...params as any[])
79
- }
80
-
81
- return addCorsHeaders(Response.json({ ok: true }), req)
82
- }
83
-
84
- export async function handleGetUserChannels(
85
- req: Request,
86
- addCorsHeaders: (r: Response, req: Request) => Response,
87
- config?: any
88
- ): Promise<Response> {
89
- return addCorsHeaders(Response.json({
90
- user: config?.user || { id: "", name: "User", channels: {} },
91
- }), req);
92
- }
93
-
94
- export async function handleLinkUserChannel(
95
- req: Request,
96
- addCorsHeaders: (r: Response, req: Request) => Response,
97
- config?: any,
98
- logger?: any
99
- ): Promise<Response> {
100
- const body = await req.json().catch(() => ({}));
101
- const { channel, channelUserId } = body;
102
-
103
- if (!channel || !channelUserId) {
104
- return addCorsHeaders(Response.json({ success: false, error: "Missing channel or channelUserId" }, { status: 400 }), req);
105
- }
106
-
107
- if (config) {
108
- config.user = config.user || { id: "", name: "User" };
109
- config.user.channels = config.user.channels || {};
110
- config.user.channels[channel] = channelUserId;
111
-
112
- if (logger) {
113
- logger.info(`Linked channel ${channel} to user ID ${channelUserId}`);
114
- }
115
- }
116
-
117
- return addCorsHeaders(Response.json({ success: true, channels: config?.user?.channels }), req);
118
- }