@johpaz/hive-agents 0.0.47 → 1.0.1
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/LICENSE +21 -0
- package/README.md +128 -897
- package/dist/hive.js +222237 -206295
- package/dist/tool-worker.js +226 -927
- package/dist/ui/assets/A2UIPage-D4nzp5NV.js +8 -0
- package/dist/ui/assets/AgentCreateForm-M2RhjeA1.js +1 -0
- package/dist/ui/assets/AgentDetailPage-DkFRtj8g.js +1 -0
- package/dist/ui/assets/AgentNewPage-CfBU7puz.js +1 -0
- package/dist/ui/assets/AgentsPage-Ctzq2LWx.js +10 -0
- package/dist/ui/assets/ApiClientPage-DKbGO1QW.js +3 -0
- package/dist/ui/assets/ChannelsPage-H6rgr8DQ.js +8 -0
- package/dist/ui/assets/DashboardPage-BIjYGf4m.js +6 -0
- package/dist/ui/assets/{LoginPage-BTxJdFVG.js → LoginPage-DazoxtBJ.js} +1 -1
- package/dist/ui/assets/{LogsPage-DVV2eHbh.js → LogsPage-DMZ6KtQ3.js} +1 -1
- package/dist/ui/assets/MeetingPage-CSLFvHL7.js +1 -0
- package/dist/ui/assets/ModelSelector-BCfvugHB.js +1 -0
- package/dist/ui/assets/{NotFound-BIUDlIXU.js → NotFound-Bpr12V51.js} +1 -1
- package/dist/ui/assets/Office3DPage-BE6Epe0d.js +4614 -0
- package/dist/ui/assets/Office3DPage-C3SIzd2H.css +1 -0
- package/dist/ui/assets/ProvidersPage-D0cApfM1.js +1 -0
- package/dist/ui/assets/{RecoverPage-7YDQysBL.js → RecoverPage-BVUPHG9z.js} +1 -1
- package/dist/ui/assets/SettingsPage-DCZ4nql4.js +9 -0
- package/dist/ui/assets/SetupPage-In19p30M.js +1 -0
- package/dist/ui/assets/WebChatPage-ByVBSzxL.js +29 -0
- package/dist/ui/assets/{activity-c3pNngT_.js → activity-BIIli7ET.js} +1 -1
- package/dist/ui/assets/agentCapabilities-D1PD9yFH.js +1 -0
- package/dist/ui/assets/alert-CQlRq6sv.js +1 -0
- package/dist/ui/assets/arrow-left-BfcnX8Er.js +1 -0
- package/dist/ui/assets/arrow-right-Q-dzAn8k.js +1 -0
- package/dist/ui/assets/arrow-up-right-Bf-8wrUQ.js +1 -0
- package/dist/ui/assets/badge-DKGZbVZJ.js +1 -0
- package/dist/ui/assets/{calendar-B-KZ9RQO.js → calendar-S9-_Q6QR.js} +1 -1
- package/dist/ui/assets/{card-CNf6BS2e.js → card-D3Nw3kh3.js} +1 -1
- package/dist/ui/assets/check-CryV78SQ.js +1 -0
- package/dist/ui/assets/chevron-down-QCtMs-Af.js +1 -0
- package/dist/ui/assets/chevron-left-dTGbyl5G.js +1 -0
- package/dist/ui/assets/chevron-right-D0GjXbnO.js +1 -0
- package/dist/ui/assets/chevron-up-Cg0jO8uT.js +1 -0
- package/dist/ui/assets/{circle-alert-KuAm2FWh.js → circle-alert-DTVW4R94.js} +1 -1
- package/dist/ui/assets/circle-check-BAolxswA.js +1 -0
- package/dist/ui/assets/{circle-x-DjLkFDO8.js → circle-x-CJXbXzRh.js} +1 -1
- package/dist/ui/assets/{copy-Bu5d7C-0.js → copy-X_TPpA-A.js} +1 -1
- package/dist/ui/assets/{dialog-Jk4bieO4.js → dialog-uUBz_NIB.js} +1 -1
- package/dist/ui/assets/dist-CD_qfA30.js +1 -0
- package/dist/ui/assets/{download-Cjbk4Rek.js → download-C-fXu08w.js} +1 -1
- package/dist/ui/assets/earth-CTsVjCmp.js +1 -0
- package/dist/ui/assets/ellipsis-vertical-5zBh5yzc.js +1 -0
- package/dist/ui/assets/{external-link-6sTlRDUR.js → external-link-CvpRhwC_.js} +1 -1
- package/dist/ui/assets/{eye-Df8o0tkC.js → eye-CM-HQEWU.js} +1 -1
- package/dist/ui/assets/{file-text-lnxnjBp0.js → file-text-lwkvYGtA.js} +1 -1
- package/dist/ui/assets/{gateway-url-DwzPmoc8.js → gateway-url-BlnabM5e.js} +1 -1
- package/dist/ui/assets/gauge-CB-cas-h.js +1 -0
- package/dist/ui/assets/{history-CAF_R34_.js → history-eSHspWRr.js} +1 -1
- package/dist/ui/assets/index-D489S18g.css +2 -0
- package/dist/ui/assets/index-ZjAc-KQS.js +116 -0
- package/dist/ui/assets/{info-WjromB4Y.js → info-DTgFQ_jA.js} +1 -1
- package/dist/ui/assets/key-CeM9JJkq.js +1 -0
- package/dist/ui/assets/label-k0jYxoWW.js +1 -0
- package/dist/ui/assets/loader-circle-Dtfz4FWw.js +1 -0
- package/dist/ui/assets/lock-open-B089GUAJ.js +1 -0
- package/dist/ui/assets/mail--gNFIe4M.js +1 -0
- package/dist/ui/assets/{pause-VqeUmp2Z.js → pause-DjT1nwQM.js} +1 -1
- package/dist/ui/assets/pencil-6PRgdjiU.js +1 -0
- package/dist/ui/assets/play-tOrP0xUJ.js +1 -0
- package/dist/ui/assets/plus-Cnom3j47.js +1 -0
- package/dist/ui/assets/progress-DrI2UDu-.js +1 -0
- package/dist/ui/assets/radio-D-joO9J0.js +1 -0
- package/dist/ui/assets/{refresh-cw-CCzDCAuz.js → refresh-cw-BRrzoHQW.js} +1 -1
- package/dist/ui/assets/scroll-area-CfHn94Vb.js +1 -0
- package/dist/ui/assets/search-D277MUP0.js +1 -0
- package/dist/ui/assets/select-BOR8MsSL.js +1 -0
- package/dist/ui/assets/{send-BPk9XbIq.js → send-DIlj81PT.js} +1 -1
- package/dist/ui/assets/{settings-BGfrZ_zM.js → settings-CkBjgAEm.js} +1 -1
- package/dist/ui/assets/{shield-CxhcUT39.js → shield-U0hIjGzm.js} +1 -1
- package/dist/ui/assets/slider-CmE_z1Ii.js +1 -0
- package/dist/ui/assets/{sparkles-BhwlS1pc.js → sparkles-VXHGDbNh.js} +1 -1
- package/dist/ui/assets/{square-DMNWw4Hi.js → square-OHeetvN3.js} +1 -1
- package/dist/ui/assets/switch-DXcELPsM.js +1 -0
- package/dist/ui/assets/tabs-CxiybXcw.js +1 -0
- package/dist/ui/assets/terminal-C6YPcJl_.js +1 -0
- package/dist/ui/assets/{textarea-B6Z1Zc6W.js → textarea-rp6vsOZl.js} +1 -1
- package/dist/ui/assets/{trash-2-xD2o4SgX.js → trash-2-DQxm7DUM.js} +1 -1
- package/dist/ui/assets/{triangle-alert-pVIJGjga.js → triangle-alert-Dj8ZhmWj.js} +1 -1
- package/dist/ui/assets/{useHiveAgentsModelLoad-BnC4jLE-.js → useHiveAgentsModelLoad-COLvs-Ho.js} +1 -1
- package/dist/ui/assets/useOfficeModel-Cy7cAyEn.js +1 -0
- package/dist/ui/assets/useProviders-q6iROeWE.js +1 -0
- package/dist/ui/assets/utils-Dyb7SC2_.js +1 -0
- package/dist/ui/assets/vendor-charts-K3xcRl0X.js +60 -0
- package/dist/ui/assets/{vendor-query-DsWPbQdG.js → vendor-query-Dj8xYhQD.js} +1 -1
- package/dist/ui/assets/vendor-radix-D0s_k6Gp.js +63 -0
- package/dist/ui/assets/vendor-react-CPJEWbIG.js +1 -0
- package/dist/ui/assets/{vendor-router-gqiZ7xhx.js → vendor-router-zpB-76nT.js} +1 -1
- package/dist/ui/assets/volume-x-Bm735CXN.js +1 -0
- package/dist/ui/assets/wifi-DklBfOZ6.js +1 -0
- package/dist/ui/assets/{zap-B4RaNNO5.js → zap-BEZNJ0i0.js} +1 -1
- package/dist/ui/index.html +16 -13
- package/dist/ui/logoblack.png +0 -0
- package/dist/ui/logocolor-dark.png +0 -0
- package/dist/ui/logocolorbg.png +0 -0
- package/dist/ui/logodoradobg.png +0 -0
- package/package.json +18 -15
- package/packages/cli/src/adapters/config.ts +1 -80
- package/packages/cli/src/adapters/factory.ts +0 -45
- package/packages/cli/src/adapters/index.ts +0 -8
- package/packages/cli/src/commands/doctor.ts +156 -1
- package/packages/cli/src/commands/gateway.ts +2 -9
- package/packages/cli/src/commands/onboard.ts +126 -59
- package/packages/cli/src/index.ts +9 -11
- package/packages/cli/src/ui-bundle.generated.ts +9 -92
- package/packages/core/src/agent/acceptance-checks.ts +172 -0
- package/packages/core/src/agent/agent-catalog.ts +348 -0
- package/packages/core/src/agent/agent-loop.ts +204 -28
- package/packages/core/src/agent/capability-search.ts +5 -5
- package/packages/core/src/agent/catalog-selector.ts +103 -0
- package/packages/core/src/agent/compaction.ts +52 -42
- package/packages/core/src/agent/context-compiler.ts +185 -63
- package/packages/core/src/agent/conversation-store.ts +56 -3
- package/packages/core/src/agent/curator.ts +129 -34
- package/packages/core/src/agent/delegation-runtime.ts +241 -0
- package/packages/core/src/agent/goal-runner.ts +111 -32
- package/packages/core/src/agent/index.ts +17 -0
- package/packages/core/src/agent/llm-client.ts +34 -2
- package/packages/core/src/agent/llm-providers/anthropic.ts +10 -7
- package/packages/core/src/agent/llm-providers/hiveagents.ts +1 -1
- package/packages/core/src/agent/llm-providers/interface.ts +16 -5
- package/packages/core/src/agent/llm-providers/modelscope.ts +5 -0
- package/packages/core/src/agent/llm-providers/openai-compat-base.ts +1 -1
- package/packages/core/src/agent/llm-providers/z-ai.ts +5 -0
- package/packages/core/src/agent/minimal-loadout.ts +47 -0
- package/packages/core/src/agent/playbook-selector.ts +1 -1
- package/packages/core/src/agent/prompt-builder.ts +4 -0
- package/packages/core/src/agent/proof-packet.ts +6 -1
- package/packages/core/src/agent/providers/index.ts +9 -4
- package/packages/core/src/agent/routing-intent.ts +22 -0
- package/packages/core/src/agent/run-store.ts +24 -3
- package/packages/core/src/agent/service.ts +2 -2
- package/packages/core/src/agent/skill-selector.ts +12 -31
- package/packages/core/src/agent/tool-selector.ts +61 -36
- package/packages/core/src/agent/tracer.ts +5 -1
- package/packages/core/src/artifacts/store.ts +162 -0
- package/packages/core/src/canvas/canvas-manager.ts +5 -234
- package/packages/core/src/canvas/emitter.ts +121 -69
- package/packages/core/src/canvas/index.ts +0 -2
- package/packages/core/src/channels/base.ts +3 -1
- package/packages/core/src/channels/manager.ts +117 -25
- package/packages/core/src/channels/webchat.ts +4 -8
- package/packages/core/src/channels/whatsapp.ts +6 -1
- package/packages/core/src/config/loader.ts +13 -23
- package/packages/core/src/events/agent-bus.ts +0 -31
- package/packages/core/src/events/channel-narration.ts +150 -0
- package/packages/core/src/events/narration.ts +82 -0
- package/packages/core/src/events/tool-narration.ts +62 -0
- package/packages/core/src/gateway/channel-notify.ts +43 -10
- package/packages/core/src/gateway/delegation-groups.ts +258 -0
- package/packages/core/src/gateway/delegation-notify.ts +103 -0
- package/packages/core/src/gateway/durable-queue.ts +33 -2
- package/packages/core/src/gateway/helpers/index.ts +2 -2
- package/packages/core/src/gateway/helpers/narration.ts +4 -57
- package/packages/core/src/gateway/helpers/redact.ts +1 -1
- package/packages/core/src/gateway/helpers/ui-source.ts +67 -0
- package/packages/core/src/gateway/initializer.ts +15 -13
- package/packages/core/src/gateway/job-executors.ts +197 -104
- package/packages/core/src/gateway/lane-queue.ts +1 -1
- package/packages/core/src/gateway/notification-inbox.ts +57 -0
- package/packages/core/src/gateway/resolver.ts +11 -25
- package/packages/core/src/gateway/routes/agents.ts +91 -1
- package/packages/core/src/gateway/routes/auth.ts +21 -42
- package/packages/core/src/gateway/routes/channels.ts +15 -1
- package/packages/core/src/gateway/routes/chat.ts +6 -6
- package/packages/core/src/gateway/routes/cron-api.ts +0 -4
- package/packages/core/src/gateway/routes/mcp.ts +0 -63
- package/packages/core/src/gateway/routes/meeting.ts +245 -0
- package/packages/core/src/gateway/routes/models.ts +69 -12
- package/packages/core/src/gateway/routes/providers.ts +111 -28
- package/packages/core/src/gateway/routes/setup.ts +92 -35
- package/packages/core/src/gateway/routes/skills.ts +2 -2
- package/packages/core/src/gateway/routes/system.ts +31 -10
- package/packages/core/src/gateway/routes/users.ts +24 -1
- package/packages/core/src/gateway/routes/voice.ts +3 -0
- package/packages/core/src/gateway/server.ts +207 -141
- package/packages/core/src/gateway/session.ts +6 -4
- package/packages/core/src/gateway/slash-commands.ts +7 -6
- package/packages/core/src/gateway/webchat-turn.ts +63 -13
- package/packages/core/src/index.ts +3 -0
- package/packages/core/src/mcp/hot-reload.ts +14 -7
- package/packages/core/src/mcp/singleton.ts +0 -3
- package/packages/core/src/mcp/tool-sync.ts +2 -2
- package/packages/core/src/resilience/retry.ts +1 -1
- package/packages/core/src/scheduler/CronScheduler.ts +3 -1
- package/packages/core/src/scheduler/integration.ts +1 -1
- package/packages/core/src/storage/bootstrap.ts +34 -10
- package/packages/core/src/storage/collections.ts +167 -27
- package/packages/core/src/storage/crypto.ts +147 -58
- package/packages/core/src/storage/hivedb.ts +9 -0
- package/packages/core/src/storage/model-id.ts +53 -0
- package/packages/core/src/storage/onboarding.ts +160 -34
- package/packages/core/src/storage/reconcile.ts +2 -5
- package/packages/core/src/storage/seed.ts +436 -158
- package/packages/core/src/storage/usage.ts +61 -132
- package/packages/core/src/storage/user-email.ts +11 -0
- package/packages/core/src/tool-runtime/index.ts +69 -23
- package/packages/core/src/tool-runtime/worker-tools.ts +4 -2
- package/packages/core/src/{canvas/a2ui-tools.ts → tools/a2ui/index.ts} +17 -8
- package/packages/core/src/tools/agents/index.ts +566 -85
- package/packages/core/src/tools/core/index.ts +28 -10
- package/packages/core/src/tools/cron/index.ts +1 -6
- package/packages/core/src/tools/index.ts +19 -46
- package/packages/core/src/tools/types.ts +1 -1
- package/packages/core/src/tools/web/artifact-inspect.ts +23 -0
- package/packages/core/src/tools/web/browser-backend.ts +129 -0
- package/packages/core/src/tools/web/browser-screenshot.ts +26 -5
- package/packages/core/src/tools/web/browser-service.ts +75 -35
- package/packages/core/src/tools/web/index.ts +3 -0
- package/packages/core/src/tools/web/webview-backend.ts +412 -0
- package/packages/core/src/utils/logger.ts +58 -30
- package/packages/core/src/utils/toon.ts +0 -20
- package/packages/core/src/voice/index.ts +108 -17
- package/packages/mcp/src/manager.ts +8 -7
- package/packages/mcp/src/transports/sse.ts +0 -4
- package/packages/mcp/src/transports/websocket.ts +0 -6
- package/packages/skills/src/bundled/{canvas → a2ui}/a2ui_dashboard/SKILL.md +4 -4
- package/packages/skills/src/bundled/{canvas → a2ui}/a2ui_form/SKILL.md +4 -4
- package/packages/skills/src/bundled/{canvas → a2ui}/a2ui_interactive/SKILL.md +5 -5
- package/packages/skills/src/bundled/agents/agent_spawner/SKILL.md +24 -18
- package/packages/skills/src/bundled/agents/task_orchestrator/SKILL.md +48 -148
- package/packages/skills/src/bundled/cli/cli_pipeline/SKILL.md +9 -10
- package/packages/skills/src/bundled/cli/cli_safe_exec/SKILL.md +1 -1
- package/packages/skills/src/bundled/cli/software_engineering/SKILL.md +23 -0
- package/packages/skills/src/bundled/cron_manager/SKILL.md +2 -2
- package/packages/skills/src/bundled/cron_reminder/SKILL.md +7 -7
- package/packages/skills/src/bundled/filesystem/file_read_and_summarize/SKILL.md +11 -10
- package/packages/skills/src/bundled/filesystem/file_writer/SKILL.md +29 -35
- package/packages/skills/src/bundled/filesystem/workspace_file_operator/SKILL.md +22 -0
- package/packages/skills/src/bundled/search_knowledge/capability_discovery/SKILL.md +5 -4
- package/packages/skills/src/bundled-data.generated.ts +640 -1226
- package/dist/ui/assets/AgentCreateForm-DzaIT-dA.js +0 -1
- package/dist/ui/assets/AgentDetailPage-DgqcJceY.js +0 -1
- package/dist/ui/assets/AgentNewPage-CNSpoOSA.js +0 -1
- package/dist/ui/assets/AgentsPage-BMUJzTD6.js +0 -10
- package/dist/ui/assets/ApiClientPage-Cum_a_3j.js +0 -3
- package/dist/ui/assets/CanvasPage-o6oCP6uq.js +0 -33
- package/dist/ui/assets/ChannelsPage-WrB0zwLq.js +0 -8
- package/dist/ui/assets/DashboardPage-BCd6kNw0.js +0 -6
- package/dist/ui/assets/MeetingPage-BULIAWzq.js +0 -1
- package/dist/ui/assets/ModelSelector-BMYOChYb.js +0 -1
- package/dist/ui/assets/ProvidersPage-BVN5UZrI.js +0 -1
- package/dist/ui/assets/SettingsPage-CYmpFfDn.js +0 -9
- package/dist/ui/assets/SetupPage-Dnmb1Lbv.js +0 -1
- package/dist/ui/assets/WebChatPage-DmmdFhIC.js +0 -16
- package/dist/ui/assets/accordion-CnLzKNHK.js +0 -1
- package/dist/ui/assets/alert-B9J6KHmt.js +0 -1
- package/dist/ui/assets/alert-dialog-KcYQWcJ6.js +0 -1
- package/dist/ui/assets/arrow-left-CBcbX5EZ.js +0 -1
- package/dist/ui/assets/badge-88dRb4M8.js +0 -1
- package/dist/ui/assets/bell-8BqRYmzf.js +0 -1
- package/dist/ui/assets/chevron-down-DIosfU_U.js +0 -1
- package/dist/ui/assets/chevron-left-D4U-5A27.js +0 -1
- package/dist/ui/assets/chevron-right-CR4Skrf3.js +0 -1
- package/dist/ui/assets/chevron-up-CI-W21Fy.js +0 -1
- package/dist/ui/assets/circle-check-6Ard1-2z.js +0 -1
- package/dist/ui/assets/dropdown-menu-DDiaHg5y.js +0 -1
- package/dist/ui/assets/es-4I-joeZz.js +0 -1
- package/dist/ui/assets/folder-open-DJBLDFjv.js +0 -1
- package/dist/ui/assets/format-DsLPBxvt.js +0 -1
- package/dist/ui/assets/gauge-B8Tj43rC.js +0 -1
- package/dist/ui/assets/hexagon-6L79pgVK.js +0 -1
- package/dist/ui/assets/index-BmwTAwOF.css +0 -2
- package/dist/ui/assets/index-Cyw7L0Li.js +0 -116
- package/dist/ui/assets/key-DyKOoQh5.js +0 -1
- package/dist/ui/assets/label-B_15zZlR.js +0 -1
- package/dist/ui/assets/loader-circle-BmBOgYze.js +0 -1
- package/dist/ui/assets/lock-BS6OLXPv.js +0 -1
- package/dist/ui/assets/play-zJpWuhrr.js +0 -1
- package/dist/ui/assets/plus-BZQX26Dr.js +0 -1
- package/dist/ui/assets/progress-D5c-Eilm.js +0 -1
- package/dist/ui/assets/scroll-area-CihOx0cb.js +0 -1
- package/dist/ui/assets/search-DzDptO9s.js +0 -1
- package/dist/ui/assets/select-BQCOjM2j.js +0 -1
- package/dist/ui/assets/slider-bcUiUfx0.js +0 -14
- package/dist/ui/assets/switch-BR30E4ej.js +0 -1
- package/dist/ui/assets/table-B3aGEaVp.js +0 -1
- package/dist/ui/assets/tabs-LQidMKRS.js +0 -1
- package/dist/ui/assets/terminal--7G943As.js +0 -1
- package/dist/ui/assets/useProviders-C1xVKLxB.js +0 -1
- package/dist/ui/assets/utils-3pnRFmFe.js +0 -1
- package/dist/ui/assets/vendor-charts-Bu2lyBKP.js +0 -65
- package/dist/ui/assets/vendor-radix-D6rA7xKY.js +0 -63
- package/dist/ui/assets/vendor-react-BU5iQU4f.js +0 -1
- package/dist/ui/assets/volume-2-BekVQl6P.js +0 -1
- package/packages/core/src/agent/context-guard.ts +0 -91
- package/packages/core/src/agent/hooks.ts +0 -166
- package/packages/core/src/agent/providers.ts +0 -1
- package/packages/core/src/auth/auth.ts +0 -111
- package/packages/core/src/auth/index.ts +0 -1
- package/packages/core/src/canvas/canvas-tools.ts +0 -448
- package/packages/core/src/gateway/router.ts +0 -126
- package/packages/core/src/scheduler/dag/AgentExecutor.ts +0 -53
- package/packages/core/src/scheduler/dag/DAGScheduler.ts +0 -250
- package/packages/core/src/scheduler/dag/EventBridge.ts +0 -122
- package/packages/core/src/scheduler/dag/TaskGraph.ts +0 -192
- package/packages/core/src/scheduler/dag/TaskNode.ts +0 -97
- package/packages/core/src/scheduler/dag/TaskResult.ts +0 -22
- package/packages/core/src/scheduler/dag/errors.ts +0 -37
- package/packages/core/src/scheduler/dag/index.ts +0 -26
- package/packages/core/src/scheduler/dag/presets/ResearchPreset.ts +0 -97
- package/packages/core/src/scheduler/dag/strategies/ParallelStrategy.ts +0 -21
- package/packages/core/src/scheduler/dag/strategies/PriorityStrategy.ts +0 -46
- package/packages/core/src/scheduler/index.ts +0 -22
- package/packages/core/src/scheduler/task-driver.ts +0 -216
- package/packages/core/src/tools/canvas/index.ts +0 -420
- package/packages/core/src/tools/meeting/index.ts +0 -336
- package/packages/core/src/tools/projects/index.ts +0 -348
- package/packages/core/src/tools/voice/index.ts +0 -104
- package/packages/core/src/utils/index.ts +0 -5
- package/packages/skills/src/bundled/agents/code_delegator/SKILL.md +0 -156
- package/packages/skills/src/bundled/canvas/canvas_dashboard/SKILL.md +0 -146
- package/packages/skills/src/bundled/canvas/canvas_interact/SKILL.md +0 -148
- package/packages/skills/src/bundled/canvas/canvas_report/SKILL.md +0 -146
- package/packages/skills/src/bundled/meeting/meeting_transcription/SKILL.md +0 -213
- package/packages/skills/src/bundled/voice/voice_assistant/SKILL.md +0 -174
- package/packages/skills/src/bundled/voice/voice_input/SKILL.md +0 -146
- package/packages/skills/src/bundled/voice/voice_output/SKILL.md +0 -151
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Config } from "../config/loader";
|
|
2
2
|
import { loadConfig, getHiveDir } from "../config/loader";
|
|
3
3
|
import { logger, onLogEntry } from "../utils/logger";
|
|
4
|
+
import { resolveUISource } from "./helpers/ui-source";
|
|
4
5
|
import { sessionManager, parseSessionId } from "./session";
|
|
5
6
|
import { enqueueChatTurn, initWebchatTurnRunner } from "./webchat-turn";
|
|
6
7
|
import {
|
|
@@ -20,7 +21,6 @@ import rootPackage from "../../../../package.json";
|
|
|
20
21
|
// Static JSON import lets Bun inline the release version into npm bundles and
|
|
21
22
|
// standalone executables instead of depending on a package.json at runtime.
|
|
22
23
|
const _pkgVersion = rootPackage.version;
|
|
23
|
-
import { cpus as osCpus } from "node:os";
|
|
24
24
|
import { ensureHiveDb } from "../storage/bootstrap";
|
|
25
25
|
import { col, fromIndexable, nextId } from "../storage/hive";
|
|
26
26
|
import { reconcileOnBoot } from "../storage/reconcile";
|
|
@@ -29,12 +29,11 @@ import { stopAllLeaseRenewals, interruptRun, findRunsByStatus } from "../agent/r
|
|
|
29
29
|
import { shutdownToolRuntime } from "../tool-runtime";
|
|
30
30
|
import { initDurableQueue, getDurableQueue } from "./durable-queue";
|
|
31
31
|
import { initJobExecutors, setJobExecutorMCPManager } from "./job-executors";
|
|
32
|
+
import { initDelegationNotify } from "./delegation-notify";
|
|
32
33
|
import { findAllPendingJobs, findExpiredLeases, loadJobRetryPolicy } from "./job-store";
|
|
33
|
-
import { initTaskDriver } from "../scheduler/task-driver";
|
|
34
34
|
import type { UserDoc, AgentDoc } from "../storage/collections";
|
|
35
35
|
import { canvasManager } from "../canvas/canvas-manager.ts";
|
|
36
|
-
import { subscribeCanvas, unsubscribeCanvas, emitCanvas, getCanvasSnapshot
|
|
37
|
-
import { resolveCanvasInteraction } from "../tools/canvas/index";
|
|
36
|
+
import { subscribeCanvas, unsubscribeCanvas, emitCanvas, getCanvasSnapshot } from "../canvas/emitter";
|
|
38
37
|
import { randomUUID } from "crypto";
|
|
39
38
|
import { circuitBreakerRegistry } from "../resilience/circuit-breaker.ts";
|
|
40
39
|
import { loadMcpHeaders } from "../storage/crypto.ts";
|
|
@@ -45,16 +44,28 @@ import { initializeGateway, type GatewayInitializationResult } from "./initializ
|
|
|
45
44
|
import { handleSetupStatus, handleVerifyProvider, handleCompleteSetup, handleSetupProviders, handleSetupEthics, handleSetupOllamaModels } from "./routes/setup";
|
|
46
45
|
import { handleAuthStatus, handleLogin, handleSetupCredentials, handleChangePassword, handleRecover, handleDisableAuth, handleRecoveryKey } from "./routes/auth";
|
|
47
46
|
import { resolveUserId } from "../storage/onboarding";
|
|
48
|
-
import { handleGetAgents, handleCreateAgent, handleUpdateAgent, handleDeleteAgent } from "./routes/agents";
|
|
49
|
-
import { handleGetProviders, handleCreateProvider, handleToggleProvider, handleUpdateProvider, handleSyncProviderModels, handleLoadHiveAgentsModel, handleGetHiveAgentsModelStatus } from "./routes/providers";
|
|
47
|
+
import { handleGetAgents, handleCreateAgent, handleUpdateAgent, handleDeleteAgent, handleGetAgentProposals } from "./routes/agents";
|
|
48
|
+
import { handleGetProviders, handleCreateProvider, handleToggleProvider, handleUpdateProvider, handleSyncProviderModels, handleGetProviderAvailableModels, handleLoadHiveAgentsModel, handleGetHiveAgentsModelStatus } from "./routes/providers";
|
|
50
49
|
import { handleGetUsers, handleCreateUser, handleUpdateUserSettings, handleGetUserChannels, handleLinkUserChannel } from "./routes/users";
|
|
51
50
|
import { handleGetSkills, handleActivateSkill, handleUpdateSkill, handleDeleteSkill, handleCreateSkill } from "./routes/skills";
|
|
52
51
|
import { handleGetEthics, handleActivateEthics, handleDeleteEthics } from "./routes/ethics";
|
|
53
52
|
import { handleGetTools, handleActivateTool, handleUpdateTool } from "./routes/tools";
|
|
54
53
|
import { handleGetTasks, handleUpdateTask } from "./routes/tasks";
|
|
55
54
|
import { setChannelSendFn } from "./channel-notify";
|
|
55
|
+
import {
|
|
56
|
+
acknowledgeNotification,
|
|
57
|
+
listPendingNotifications,
|
|
58
|
+
markNotificationDelivered,
|
|
59
|
+
} from "./notification-inbox";
|
|
60
|
+
import { setNarrationDelivery } from "../events/narration";
|
|
61
|
+
import {
|
|
62
|
+
resolveNarrationMode,
|
|
63
|
+
shouldDeliverToChannel,
|
|
64
|
+
formatNarrationForChannel,
|
|
65
|
+
enqueueChannelNarration,
|
|
66
|
+
awaitChannelNarration,
|
|
67
|
+
} from "../events/channel-narration";
|
|
56
68
|
import { CronScheduler } from "../scheduler/CronScheduler";
|
|
57
|
-
import { DAGScheduler, ParallelStrategy } from "../scheduler/dag/index";
|
|
58
69
|
import { createTaskHandler, setSchedulerForCleanup } from "../scheduler/integration";
|
|
59
70
|
|
|
60
71
|
import { setSchedulerInstance as setScheduleToolsInstance } from "../tools/cron/index.ts";
|
|
@@ -78,9 +89,9 @@ import { handleGetModels, handleCreateModel, handleToggleModel, handleGetModelsC
|
|
|
78
89
|
import { handleGetVoiceProviders, handleGetConfiguredVoiceProviders, handleSaveVoiceProviderKey, handleTestVoice, handleGetChannelVoice, handleUpdateChannelVoice, handleGetVoiceProviderVoices } from "./routes/voice";
|
|
79
90
|
import { handleGetVisionProviders, handleGetChannelVision, handleUpdateChannelVision, handleOcrImage } from "./routes/multimodal";
|
|
80
91
|
import { handleGetLocalTTSStatus, handleGetLocalTTSLogs, handleInstallLocalTTS, handleStartLocalTTS, handleStopLocalTTS, handleSpeakLocalTTS, handleGetAvailableModels, handleGetInstalledVoices, handleDownloadModel, handleGetDownloadLogs, initializeLocalTTS } from "./routes/tts-local";
|
|
81
|
-
import { handleCreateMeeting, handleListMeetings, handleGetMeeting, handleAddMeetingSegment, handleStopMeeting } from "./routes/meeting";
|
|
92
|
+
import { handleCreateMeeting, handleListMeetings, handleGetMeeting, handleAddMeetingSegment, handleStopMeeting, handleGenerateMeetingReport, handleDownloadMeetingReport } from "./routes/meeting";
|
|
82
93
|
import { handleGetActivityStats, handleGetSystemStats, handleGetUsageStats, handleSystemReload, handleApiReload, handleGetVersion, handleTriggerUpdate } from "./routes/system";
|
|
83
|
-
import { handleGetChatHistory,
|
|
94
|
+
import { handleGetChatHistory, handleGetNotes, handleUpdateNote } from "./routes/chat";
|
|
84
95
|
import { handleChat as handlePostChat } from "./routes/chat";
|
|
85
96
|
import { handleGetConfig } from "./routes/config";
|
|
86
97
|
import { handleHttpRequest } from "./routes/http-client";
|
|
@@ -120,10 +131,6 @@ export async function startGateway(
|
|
|
120
131
|
// FIX 2 — startTime para calcular uptime en /status y /api/agents
|
|
121
132
|
const startTime = Date.now();
|
|
122
133
|
|
|
123
|
-
// CPU delta sampling — process.cpuUsage() is cumulative; we diff between calls
|
|
124
|
-
const numCores = osCpus().length || 1;
|
|
125
|
-
let lastCpuSample = process.cpuUsage();
|
|
126
|
-
let lastCpuSampleTime = Date.now();
|
|
127
134
|
const log = logger.child("gateway");
|
|
128
135
|
|
|
129
136
|
log.info(`Starting gateway on ${host}:${port}`);
|
|
@@ -209,8 +216,46 @@ export async function startGateway(
|
|
|
209
216
|
await initializeLocalTTS();
|
|
210
217
|
|
|
211
218
|
// Conectar channel-notify singleton para que las tools (notify, report_progress) puedan enviar mensajes
|
|
212
|
-
setChannelSendFn(async (channel, sessionId, content) => {
|
|
213
|
-
await channelManager.send(channel, sessionId, {
|
|
219
|
+
setChannelSendFn(async (channel, sessionId, content, metadata) => {
|
|
220
|
+
await channelManager.send(channel, sessionId, {
|
|
221
|
+
content,
|
|
222
|
+
type: metadata?.notificationId ? "notification" : "progress",
|
|
223
|
+
sessionId,
|
|
224
|
+
notificationId: metadata?.notificationId,
|
|
225
|
+
}, metadata?.accountId);
|
|
226
|
+
});
|
|
227
|
+
setNarrationDelivery(async (event) => {
|
|
228
|
+
if (event.channel === "webchat" && event.session_id) {
|
|
229
|
+
const session = sessionManager.get(event.session_id);
|
|
230
|
+
if (session?.ws && session.ws.readyState === 1) {
|
|
231
|
+
session.ws.send(JSON.stringify({
|
|
232
|
+
type: "process",
|
|
233
|
+
sessionId: event.session_id,
|
|
234
|
+
id: event.id,
|
|
235
|
+
messageId: event.turn_id,
|
|
236
|
+
processKind: event.kind === "tool_call" ? "tool" : "observation",
|
|
237
|
+
processStatus: event.status === "error" ? "error" : event.status === "done" ? "done" : "thinking",
|
|
238
|
+
label: event.label,
|
|
239
|
+
detail: event.detail,
|
|
240
|
+
timestamp: new Date(event.created_at).toISOString(),
|
|
241
|
+
}));
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
if (!event.channel || !event.session_id) return;
|
|
246
|
+
|
|
247
|
+
// Messaging channels turn every event into a permanent chat message, so
|
|
248
|
+
// they get a filtered feed (see events/channel-narration.ts) delivered
|
|
249
|
+
// off the agent loop's critical path.
|
|
250
|
+
const mode = await resolveNarrationMode(event.channel);
|
|
251
|
+
if (!shouldDeliverToChannel(event, mode)) return;
|
|
252
|
+
|
|
253
|
+
enqueueChannelNarration(`${event.channel}:${event.session_id}`, async () => {
|
|
254
|
+
await channelManager.send(event.channel, event.session_id, {
|
|
255
|
+
content: formatNarrationForChannel(event),
|
|
256
|
+
type: "progress",
|
|
257
|
+
});
|
|
258
|
+
});
|
|
214
259
|
});
|
|
215
260
|
|
|
216
261
|
if (gatewaySetupMode) {
|
|
@@ -241,12 +286,11 @@ export async function startGateway(
|
|
|
241
286
|
getProvider: () => dbProvider,
|
|
242
287
|
getModel: () => dbModel,
|
|
243
288
|
});
|
|
289
|
+
// Closes the async task_delegate loop: relays worker_task outcomes
|
|
290
|
+
// back into the delegating conversation (see delegation-notify.ts).
|
|
291
|
+
initDelegationNotify();
|
|
244
292
|
log.info(`🔀 DurableQueue initialized (maxConcurrency=${durableQueue.getMaxGlobalConcurrency()})`);
|
|
245
293
|
|
|
246
|
-
// Initialize TaskDriver (project/task engine)
|
|
247
|
-
initTaskDriver();
|
|
248
|
-
log.info("📋 TaskDriver initialized");
|
|
249
|
-
|
|
250
294
|
// Create and boot scheduler
|
|
251
295
|
const handler = createTaskHandler();
|
|
252
296
|
const scheduler = new CronScheduler(handler);
|
|
@@ -258,11 +302,6 @@ export async function startGateway(
|
|
|
258
302
|
setSchedulerForCleanup(scheduler);
|
|
259
303
|
|
|
260
304
|
log.info(`📅 CronScheduler initialized with ${(await scheduler.getStatus()).length} task(s)`);
|
|
261
|
-
|
|
262
|
-
// Register DAGScheduler as a global service (opt-in by swarms)
|
|
263
|
-
const dagScheduler = new DAGScheduler({ strategy: new ParallelStrategy(), maxConcurrentWorkers: 2 });
|
|
264
|
-
(globalThis as any).__dagScheduler = dagScheduler;
|
|
265
|
-
log.info("🔀 DAGScheduler ready");
|
|
266
305
|
} catch (err) {
|
|
267
306
|
log.error(`❌ CronScheduler initialization failed: ${(err as Error).message}`);
|
|
268
307
|
}
|
|
@@ -481,6 +520,7 @@ export async function startGateway(
|
|
|
481
520
|
const { userId, threadId: conversationThreadId } = await resolveContext({
|
|
482
521
|
channel: message.channel,
|
|
483
522
|
channelUserId: message.sessionId,
|
|
523
|
+
accountId: message.accountId,
|
|
484
524
|
});
|
|
485
525
|
|
|
486
526
|
const telegramMeta = message.metadata?.telegram as { messageId?: number } | undefined;
|
|
@@ -525,6 +565,7 @@ export async function startGateway(
|
|
|
525
565
|
try {
|
|
526
566
|
log.info(`🤖 Routing to agent loop...`);
|
|
527
567
|
|
|
568
|
+
const turnId = randomUUID();
|
|
528
569
|
const response = await runner.generate({
|
|
529
570
|
provider: dbProvider as any,
|
|
530
571
|
messages,
|
|
@@ -535,41 +576,11 @@ export async function startGateway(
|
|
|
535
576
|
threadId: unifiedSessionId,
|
|
536
577
|
userId,
|
|
537
578
|
channel: message.channel,
|
|
579
|
+
turnId,
|
|
580
|
+
sessionId: routingSessionId,
|
|
538
581
|
onStep: async (step) => {
|
|
539
|
-
//
|
|
540
|
-
|
|
541
|
-
const trimmedMessage = (typeof step.message === "string" ? step.message : "").trim();
|
|
542
|
-
if (trimmedMessage) {
|
|
543
|
-
log.debug(`[NARRATION] ${trimmedMessage.substring(0, 100)}`);
|
|
544
|
-
try {
|
|
545
|
-
await channelManager.send(message.channel, routingSessionId, {
|
|
546
|
-
content: trimmedMessage,
|
|
547
|
-
type: "progress",
|
|
548
|
-
});
|
|
549
|
-
} catch (err) {
|
|
550
|
-
log.warn(`[onStep] Narration send failed: ${(err as Error).message}`);
|
|
551
|
-
}
|
|
552
|
-
}
|
|
553
|
-
return;
|
|
554
|
-
}
|
|
555
|
-
|
|
556
|
-
// "tool_call" = el agente va a ejecutar una herramienta → narrar al usuario
|
|
557
|
-
if (step.type === "tool_call" && step.toolName) {
|
|
558
|
-
const narration = getNarration(step.toolName);
|
|
559
|
-
log.debug(`[TOOL] ${step.toolName} → "${narration}"`);
|
|
560
|
-
try {
|
|
561
|
-
await channelManager.send(message.channel, routingSessionId, {
|
|
562
|
-
content: narration,
|
|
563
|
-
type: "progress",
|
|
564
|
-
});
|
|
565
|
-
} catch (err) {
|
|
566
|
-
log.warn(`[onStep] Tool narration send failed: ${(err as Error).message}`);
|
|
567
|
-
}
|
|
568
|
-
return;
|
|
569
|
-
}
|
|
570
|
-
|
|
571
|
-
// "tool_result" = resultado de la herramienta
|
|
572
|
-
// Solo enviamos al usuario si el resultado lo pide explícitamente
|
|
582
|
+
// Explicit tool-authored progress remains supported. Ordinary agent
|
|
583
|
+
// and tool lifecycle narration is emitted by the domain service.
|
|
573
584
|
if (step.type === "tool_result" && step.message) {
|
|
574
585
|
try {
|
|
575
586
|
const result = JSON.parse(step.message);
|
|
@@ -592,13 +603,19 @@ export async function startGateway(
|
|
|
592
603
|
},
|
|
593
604
|
});
|
|
594
605
|
|
|
595
|
-
const
|
|
606
|
+
const { sealDelegationGroup } = await import("./delegation-groups");
|
|
607
|
+
const delegationGroup = await sealDelegationGroup(turnId);
|
|
608
|
+
const responseContent = delegationGroup ? "" : response.content?.trim() || "";
|
|
596
609
|
if (!responseContent) {
|
|
597
610
|
log.warn(`📤 LLM response: empty — skipping send`);
|
|
598
611
|
return;
|
|
599
612
|
}
|
|
600
613
|
log.info(`📤 LLM response: ${responseContent.substring(0, 100)}${responseContent.length > 100 ? "..." : ""}`);
|
|
601
614
|
|
|
615
|
+
// Narration is delivered off the critical path — let it drain first so the
|
|
616
|
+
// final answer lands after the progress messages, not before them.
|
|
617
|
+
await awaitChannelNarration(`${message.channel}:${routingSessionId}`);
|
|
618
|
+
|
|
602
619
|
const shouldSpeak = preferAudioResponse;
|
|
603
620
|
let responseType: "text" | "audio" = "text";
|
|
604
621
|
let ttsProviderUsed: string | null = null;
|
|
@@ -620,7 +637,7 @@ export async function startGateway(
|
|
|
620
637
|
responseType = "audio";
|
|
621
638
|
|
|
622
639
|
try {
|
|
623
|
-
const channel = channelManager.getChannel(message.channel);
|
|
640
|
+
const channel = channelManager.getChannel(message.channel, message.accountId);
|
|
624
641
|
if (channel?.sendAudio) {
|
|
625
642
|
await channel.sendAudio(routingSessionId, audioOutput.data as Buffer, audioOutput.mimeType);
|
|
626
643
|
log.info(`✅ Audio sent to ${routingSessionId}`);
|
|
@@ -891,16 +908,16 @@ export async function startGateway(
|
|
|
891
908
|
return new Response("Not found", { status: 404 });
|
|
892
909
|
}
|
|
893
910
|
|
|
894
|
-
// In production: serve from dist folder
|
|
895
|
-
//
|
|
896
|
-
|
|
897
|
-
const
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
911
|
+
// In production: serve from dist folder, o del bundle embebido si no
|
|
912
|
+
// hay nada en disco. Ver helpers/ui-source.ts para el orden y por qué
|
|
913
|
+
// el disco le gana al embed.
|
|
914
|
+
const uiSource = resolveUISource({
|
|
915
|
+
uiDirEnv: process.env.HIVE_UI_DIR,
|
|
916
|
+
distDirEnv: process.env.HIVE_DIST_DIR,
|
|
917
|
+
hiveDir: getHiveDir(),
|
|
918
|
+
cwd: process.cwd(),
|
|
919
|
+
hasEmbedded: Boolean(embeddedUI?.size),
|
|
920
|
+
});
|
|
904
921
|
let subPath = url.pathname;
|
|
905
922
|
|
|
906
923
|
// En setup mode: / y /ui redirigen a /setup
|
|
@@ -931,7 +948,7 @@ export async function startGateway(
|
|
|
931
948
|
// Standalone executables carry the UI inside the Bun binary. The CLI
|
|
932
949
|
// passes that bundle into the child gateway process so both API and
|
|
933
950
|
// UI continue to share a single port without extracting files.
|
|
934
|
-
if (embeddedUI
|
|
951
|
+
if (uiSource.kind === "embedded" && embeddedUI) {
|
|
935
952
|
const entry = embeddedUI.get(subPath)
|
|
936
953
|
?? (!path.extname(subPath) ? embeddedUI.get("/index.html") : undefined);
|
|
937
954
|
if (entry) {
|
|
@@ -946,17 +963,18 @@ export async function startGateway(
|
|
|
946
963
|
}
|
|
947
964
|
}
|
|
948
965
|
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
966
|
+
if (uiSource.kind === "disk") {
|
|
967
|
+
const uiFile = Bun.file(path.join(uiSource.dir, subPath));
|
|
968
|
+
if (await uiFile.exists()) {
|
|
969
|
+
return new Response(uiFile);
|
|
970
|
+
}
|
|
954
971
|
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
972
|
+
// SPA fallback: paths without a file extension are React Router routes — serve index.html
|
|
973
|
+
if (!path.extname(subPath)) {
|
|
974
|
+
const indexFile = Bun.file(path.join(uiSource.dir, "index.html"));
|
|
975
|
+
if (await indexFile.exists()) {
|
|
976
|
+
return new Response(indexFile);
|
|
977
|
+
}
|
|
960
978
|
}
|
|
961
979
|
}
|
|
962
980
|
|
|
@@ -1049,7 +1067,9 @@ export async function startGateway(
|
|
|
1049
1067
|
return addCorsHeaders(new Response(
|
|
1050
1068
|
JSON.stringify({
|
|
1051
1069
|
status: "ok",
|
|
1052
|
-
|
|
1070
|
+
// Estaba hardcodeada en "0.1.7" mientras package.json iba por 1.0.1:
|
|
1071
|
+
// /status mentía sobre qué versión estaba corriendo.
|
|
1072
|
+
version: _pkgVersion,
|
|
1053
1073
|
uptime: Math.floor((Date.now() - startTime) / 1000),
|
|
1054
1074
|
gateway: { host, port },
|
|
1055
1075
|
sessions: sessionManager.list().map((s) => ({
|
|
@@ -1272,6 +1292,10 @@ export async function startGateway(
|
|
|
1272
1292
|
return await handleGetAgents(req, addCorsHeaders)
|
|
1273
1293
|
}
|
|
1274
1294
|
|
|
1295
|
+
if (url.pathname === "/api/agents/proposals" && req.method === "GET") {
|
|
1296
|
+
return await handleGetAgentProposals(req, addCorsHeaders)
|
|
1297
|
+
}
|
|
1298
|
+
|
|
1275
1299
|
if (url.pathname === "/api/agents" && req.method === "POST") {
|
|
1276
1300
|
return await handleCreateAgent(req, addCorsHeaders)
|
|
1277
1301
|
}
|
|
@@ -1323,6 +1347,12 @@ export async function startGateway(
|
|
|
1323
1347
|
return await handleSyncProviderModels(req, addCorsHeaders, providerId)
|
|
1324
1348
|
}
|
|
1325
1349
|
|
|
1350
|
+
// GET /api/providers/:id/available-models — lista lo que sirve el provider, sin persistir
|
|
1351
|
+
const availableModelsMatch = url.pathname.match(/^\/api\/providers\/([^/]+)\/available-models$/)
|
|
1352
|
+
if (availableModelsMatch && req.method === "GET") {
|
|
1353
|
+
return await handleGetProviderAvailableModels(req, addCorsHeaders, availableModelsMatch[1])
|
|
1354
|
+
}
|
|
1355
|
+
|
|
1326
1356
|
// POST /api/models - Create a new model
|
|
1327
1357
|
if (url.pathname === "/api/models" && req.method === "POST") {
|
|
1328
1358
|
return await handleCreateModel(req, addCorsHeaders)
|
|
@@ -1506,7 +1536,10 @@ export async function startGateway(
|
|
|
1506
1536
|
const newServersConfig = { ...currentConfig.servers }
|
|
1507
1537
|
newServersConfig[mcpName] = mcpServerConfig
|
|
1508
1538
|
|
|
1509
|
-
//
|
|
1539
|
+
// Register the server (or refresh its config) — this alone does not
|
|
1540
|
+
// connect: updateConfig() only (re)connects a server whose config
|
|
1541
|
+
// actually changed, so an already-registered dormant server needs an
|
|
1542
|
+
// explicit connect below.
|
|
1510
1543
|
await mcp.updateConfig({
|
|
1511
1544
|
...currentConfig,
|
|
1512
1545
|
servers: newServersConfig,
|
|
@@ -1514,6 +1547,12 @@ export async function startGateway(
|
|
|
1514
1547
|
|
|
1515
1548
|
log.info(`[MCP] Server registered in MCP Manager`)
|
|
1516
1549
|
|
|
1550
|
+
// Explicitly wake the server — connectServer() is a no-op if it's
|
|
1551
|
+
// already connected, so this is safe to call unconditionally.
|
|
1552
|
+
await mcp.connectServer(mcpName).catch((err: Error) => {
|
|
1553
|
+
log.error(`[MCP] Connect attempt failed for ${mcpName}: ${err.message}`);
|
|
1554
|
+
});
|
|
1555
|
+
|
|
1517
1556
|
// Get tools after connection
|
|
1518
1557
|
const tools = mcp.getServerTools(mcpName) || [];
|
|
1519
1558
|
const serverDetails = mcp.getServerDetails?.(mcpName);
|
|
@@ -1608,7 +1647,10 @@ export async function startGateway(
|
|
|
1608
1647
|
const newServersConfig = { ...currentConfig.servers }
|
|
1609
1648
|
newServersConfig[mcpName] = mcpServerConfig
|
|
1610
1649
|
|
|
1611
|
-
//
|
|
1650
|
+
// Register the server (or refresh its config) — this alone does not
|
|
1651
|
+
// connect: updateConfig() only (re)connects a server whose config
|
|
1652
|
+
// actually changed, so an already-registered dormant server needs an
|
|
1653
|
+
// explicit connect below.
|
|
1612
1654
|
await mcp.updateConfig({
|
|
1613
1655
|
...currentConfig,
|
|
1614
1656
|
servers: newServersConfig,
|
|
@@ -1616,6 +1658,12 @@ export async function startGateway(
|
|
|
1616
1658
|
|
|
1617
1659
|
log.info(`[MCP] Server registered in MCP Manager`)
|
|
1618
1660
|
|
|
1661
|
+
// Explicitly wake the server — connectServer() is a no-op if it's
|
|
1662
|
+
// already connected, so this is safe to call unconditionally.
|
|
1663
|
+
await mcp.connectServer(mcpName).catch((err: Error) => {
|
|
1664
|
+
log.error(`[MCP] Connect attempt failed for ${mcpName}: ${err.message}`);
|
|
1665
|
+
});
|
|
1666
|
+
|
|
1619
1667
|
// Get tools after connection
|
|
1620
1668
|
const tools = mcp.getServerTools(mcpName) || [];
|
|
1621
1669
|
const serverDetails2 = mcp.getServerDetails?.(mcpName);
|
|
@@ -1814,7 +1862,17 @@ export async function startGateway(
|
|
|
1814
1862
|
return await handleStopMeeting(req, addCorsHeaders, meetingStopMatch[1]);
|
|
1815
1863
|
}
|
|
1816
1864
|
|
|
1817
|
-
|
|
1865
|
+
const meetingReportMatch = url.pathname.match(/^\/api\/meetings\/([^/]+)\/report$/);
|
|
1866
|
+
if (meetingReportMatch && req.method === "POST") {
|
|
1867
|
+
return await handleGenerateMeetingReport(req, addCorsHeaders, meetingReportMatch[1]);
|
|
1868
|
+
}
|
|
1869
|
+
|
|
1870
|
+
const meetingReportDownloadMatch = url.pathname.match(/^\/api\/meetings\/([^/]+)\/report\/download$/);
|
|
1871
|
+
if (meetingReportDownloadMatch && req.method === "GET") {
|
|
1872
|
+
return await handleDownloadMeetingReport(req, addCorsHeaders, meetingReportDownloadMatch[1]);
|
|
1873
|
+
}
|
|
1874
|
+
|
|
1875
|
+
// ── Chat / Notes API ────────────────────────────────────────────────
|
|
1818
1876
|
if (url.pathname === "/api/chat/history" && req.method === "GET") {
|
|
1819
1877
|
return await handleGetChatHistory(req, addCorsHeaders)
|
|
1820
1878
|
}
|
|
@@ -1823,10 +1881,6 @@ export async function startGateway(
|
|
|
1823
1881
|
return await handlePostChat(req, addCorsHeaders)
|
|
1824
1882
|
}
|
|
1825
1883
|
|
|
1826
|
-
if (url.pathname === "/api/canvas" && req.method === "GET") {
|
|
1827
|
-
return await handleGetCanvas(req, addCorsHeaders)
|
|
1828
|
-
}
|
|
1829
|
-
|
|
1830
1884
|
if (url.pathname === "/api/notes" && req.method === "GET") {
|
|
1831
1885
|
return await handleGetNotes(req, addCorsHeaders)
|
|
1832
1886
|
}
|
|
@@ -1904,6 +1958,26 @@ export async function startGateway(
|
|
|
1904
1958
|
websocket: {
|
|
1905
1959
|
async open(ws) {
|
|
1906
1960
|
const data = ws.data;
|
|
1961
|
+
|
|
1962
|
+
// ── Heartbeat a nivel de protocolo (todos los sockets) ──────────────
|
|
1963
|
+
// ws.ping() usa frames ping/pong WebSocket: el navegador responde pong
|
|
1964
|
+
// automáticamente incluso con la pestaña en segundo plano (los timers
|
|
1965
|
+
// JS se throttle-an, los frames de protocolo no). Si no hay señal de
|
|
1966
|
+
// vida en 90s (pong, mensaje o ping), cerramos para que el cliente
|
|
1967
|
+
// reconecte en lugar de quedar zombi.
|
|
1968
|
+
(data as any)._lastSeen = Date.now();
|
|
1969
|
+
const hbInterval = setInterval(() => {
|
|
1970
|
+
try {
|
|
1971
|
+
if (ws.readyState !== 1) return;
|
|
1972
|
+
ws.ping();
|
|
1973
|
+
const lastSeen = (data as any)._lastSeen ?? 0;
|
|
1974
|
+
if (Date.now() - lastSeen > 90_000) {
|
|
1975
|
+
try { ws.close(4000, "heartbeat timeout"); } catch { /* ignore */ }
|
|
1976
|
+
}
|
|
1977
|
+
} catch { /* ignore */ }
|
|
1978
|
+
}, 25_000);
|
|
1979
|
+
(data as any)._hbInterval = hbInterval;
|
|
1980
|
+
|
|
1907
1981
|
// ── Meeting Stream ─────────────────────────────────────────────────────
|
|
1908
1982
|
if (data.sessionId.startsWith("meeting:")) {
|
|
1909
1983
|
log.info(`Meeting stream client connected: ${data.sessionId}`);
|
|
@@ -1964,6 +2038,7 @@ export async function startGateway(
|
|
|
1964
2038
|
|
|
1965
2039
|
async message(ws, message) {
|
|
1966
2040
|
const data = ws.data;
|
|
2041
|
+
(data as any)._lastSeen = Date.now();
|
|
1967
2042
|
|
|
1968
2043
|
// Bridge events clients are read-only; only respond to ping keepalive
|
|
1969
2044
|
if (data.sessionId.startsWith("bridge:")) {
|
|
@@ -2064,6 +2139,28 @@ export async function startGateway(
|
|
|
2064
2139
|
return;
|
|
2065
2140
|
}
|
|
2066
2141
|
|
|
2142
|
+
if (msg.type === "notification_sync") {
|
|
2143
|
+
const pending = await listPendingNotifications(data.sessionId, "webchat");
|
|
2144
|
+
for (const notification of pending) {
|
|
2145
|
+
ws.send(JSON.stringify({
|
|
2146
|
+
type: "notification",
|
|
2147
|
+
sessionId: data.sessionId,
|
|
2148
|
+
notificationId: notification.id,
|
|
2149
|
+
content: notification.message,
|
|
2150
|
+
createdAt: notification.created_at,
|
|
2151
|
+
} as OutboundMessage));
|
|
2152
|
+
await markNotificationDelivered(notification.id, data.sessionId);
|
|
2153
|
+
}
|
|
2154
|
+
return;
|
|
2155
|
+
}
|
|
2156
|
+
|
|
2157
|
+
if (msg.type === "notification_ack") {
|
|
2158
|
+
if (msg.notificationId) {
|
|
2159
|
+
await acknowledgeNotification(msg.notificationId, data.sessionId);
|
|
2160
|
+
}
|
|
2161
|
+
return;
|
|
2162
|
+
}
|
|
2163
|
+
|
|
2067
2164
|
// Canvas subscribe
|
|
2068
2165
|
if (msg.type === "canvas_subscribe") {
|
|
2069
2166
|
subscribeCanvas(ws);
|
|
@@ -2078,7 +2175,7 @@ export async function startGateway(
|
|
|
2078
2175
|
// Canvas unsubscribe
|
|
2079
2176
|
if (msg.type === "canvas_unsubscribe") {
|
|
2080
2177
|
unsubscribeCanvas(ws);
|
|
2081
|
-
canvasManager.unregisterSession(`canvas:${data.sessionId}
|
|
2178
|
+
canvasManager.unregisterSession(`canvas:${data.sessionId}`, ws);
|
|
2082
2179
|
return;
|
|
2083
2180
|
}
|
|
2084
2181
|
|
|
@@ -2109,50 +2206,6 @@ export async function startGateway(
|
|
|
2109
2206
|
return;
|
|
2110
2207
|
}
|
|
2111
2208
|
|
|
2112
|
-
// Canvas interactions from the main session — route to canvasManager and local resolver
|
|
2113
|
-
if (msg.type === "canvas:interact") {
|
|
2114
|
-
const { componentId } = msg;
|
|
2115
|
-
let resolvedByPending = false;
|
|
2116
|
-
if (componentId) {
|
|
2117
|
-
removeCanvasComponent(componentId);
|
|
2118
|
-
// Resolve local pending interactions (canvas_confirm tool)
|
|
2119
|
-
resolvedByPending = resolveCanvasInteraction(componentId, msg.data);
|
|
2120
|
-
}
|
|
2121
|
-
const canvasSessionId = `canvas:${data.sessionId}`;
|
|
2122
|
-
canvasManager.handleMessage(canvasSessionId, JSON.stringify(msg));
|
|
2123
|
-
|
|
2124
|
-
// If no tool was waiting for this interaction, forward it to the agent as a new turn
|
|
2125
|
-
if (!resolvedByPending) {
|
|
2126
|
-
const interactionData = msg.data as Record<string, unknown> | undefined;
|
|
2127
|
-
const action = (msg as any).action as string | undefined;
|
|
2128
|
-
|
|
2129
|
-
// Build a human-readable message describing what the user clicked
|
|
2130
|
-
let interactionMsg = `[canvas:interact] componentId=${componentId ?? "unknown"}, action=${action ?? "click"}`;
|
|
2131
|
-
if (interactionData && Object.keys(interactionData).length > 0) {
|
|
2132
|
-
interactionMsg += `, data=${JSON.stringify(interactionData)}`;
|
|
2133
|
-
}
|
|
2134
|
-
|
|
2135
|
-
log.info(`Canvas interaction forwarded to agent: ${interactionMsg}`);
|
|
2136
|
-
|
|
2137
|
-
const sessionId = data.sessionId;
|
|
2138
|
-
|
|
2139
|
-
ws.send(JSON.stringify({ type: "typing", isTyping: true, sessionId } as OutboundMessage));
|
|
2140
|
-
|
|
2141
|
-
enqueueChatTurn({
|
|
2142
|
-
lane: sessionId,
|
|
2143
|
-
payload: { source: "canvas", sessionId, content: interactionMsg },
|
|
2144
|
-
live: { sendRaw: (payload) => ws.send(payload) },
|
|
2145
|
-
}).catch((error) => {
|
|
2146
|
-
ws.send(JSON.stringify({ type: "typing", isTyping: false, sessionId } as OutboundMessage));
|
|
2147
|
-
ws.send(JSON.stringify({ type: "error", sessionId, error: (error as Error).message } as OutboundMessage));
|
|
2148
|
-
log.error(`Canvas interact enqueue error: ${(error as Error).message}`);
|
|
2149
|
-
});
|
|
2150
|
-
}
|
|
2151
|
-
|
|
2152
|
-
return;
|
|
2153
|
-
}
|
|
2154
|
-
|
|
2155
|
-
// Canvas session - handle interactions
|
|
2156
2209
|
if (msg.type === "command" || (msg.content && isSlashCommand(msg.content))) {
|
|
2157
2210
|
const result = await executeSlashCommand(msg.sessionId, msg.content ?? `/${msg.command}`, ws);
|
|
2158
2211
|
if (result) {
|
|
@@ -2316,8 +2369,22 @@ export async function startGateway(
|
|
|
2316
2369
|
} as OutboundMessage));
|
|
2317
2370
|
},
|
|
2318
2371
|
|
|
2372
|
+
// Frames de protocolo: cualquier señal de vida resetea el watchdog
|
|
2373
|
+
ping(ws) {
|
|
2374
|
+
(ws.data as any)._lastSeen = Date.now();
|
|
2375
|
+
try { ws.pong(); } catch { /* ignore */ }
|
|
2376
|
+
},
|
|
2377
|
+
|
|
2378
|
+
pong(ws) {
|
|
2379
|
+
(ws.data as any)._lastSeen = Date.now();
|
|
2380
|
+
},
|
|
2381
|
+
|
|
2319
2382
|
close(ws) {
|
|
2320
2383
|
const data = ws.data;
|
|
2384
|
+
if ((data as any)._hbInterval) {
|
|
2385
|
+
clearInterval((data as any)._hbInterval);
|
|
2386
|
+
(data as any)._hbInterval = null;
|
|
2387
|
+
}
|
|
2321
2388
|
if (data.sessionId.startsWith("meeting:")) {
|
|
2322
2389
|
log.info(`Meeting stream client disconnected: ${data.sessionId}`);
|
|
2323
2390
|
return;
|
|
@@ -2330,14 +2397,13 @@ export async function startGateway(
|
|
|
2330
2397
|
}
|
|
2331
2398
|
|
|
2332
2399
|
log.debug(`WebSocket disconnected: ${data.sessionId}`);
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
getDurableQueue().cancelLane(data.sessionId).catch(() => {});
|
|
2400
|
+
const wasCurrentSession = sessionManager.deleteIfOwner(data.sessionId, ws);
|
|
2401
|
+
if (wasCurrentSession) logSubscribers.delete(data.sessionId);
|
|
2336
2402
|
unsubscribeCanvas(ws);
|
|
2337
|
-
canvasManager.unregisterSession(`canvas:${data.sessionId}
|
|
2403
|
+
canvasManager.unregisterSession(`canvas:${data.sessionId}`, ws);
|
|
2338
2404
|
|
|
2339
2405
|
const channel = channelManager?.getChannel("webchat") as any;
|
|
2340
|
-
if (channel?.unregisterConnection) channel.unregisterConnection(data.sessionId);
|
|
2406
|
+
if (channel?.unregisterConnection) channel.unregisterConnection(data.sessionId, ws);
|
|
2341
2407
|
},
|
|
2342
2408
|
},
|
|
2343
2409
|
});
|
|
@@ -2377,7 +2443,7 @@ export async function startGateway(
|
|
|
2377
2443
|
log.info(`[gateway] UI: ${devUrl}`);
|
|
2378
2444
|
log.info(`[gateway] API: http://${host}:${port}`);
|
|
2379
2445
|
log.info(`[gateway] WebSocket: ws://${host}:${port}/ws`);
|
|
2380
|
-
log.info(`[gateway]
|
|
2446
|
+
log.info(`[gateway] Actividad: ws://${host}:${port}/canvas`);
|
|
2381
2447
|
log.info(`[gateway] Modo: desarrollo`);
|
|
2382
2448
|
if (!isGatewayChild) {
|
|
2383
2449
|
log.info(gatewaySetupMode ? `🎉 Primer arranque — abriendo setup...` : `🐝 Administra tu Hive aquí: ${devUrl}`);
|
|
@@ -2391,7 +2457,7 @@ export async function startGateway(
|
|
|
2391
2457
|
log.info(`[gateway] UI: ${uiUrl}`);
|
|
2392
2458
|
log.info(`[gateway] API: http://${host}:${port}`);
|
|
2393
2459
|
log.info(`[gateway] WebSocket: ws://${host}:${port}/ws`);
|
|
2394
|
-
log.info(`[gateway]
|
|
2460
|
+
log.info(`[gateway] Actividad: ws://${host}:${port}/canvas`);
|
|
2395
2461
|
|
|
2396
2462
|
// Always open browser on startup (setup and normal mode).
|
|
2397
2463
|
// Set NO_BROWSER=1 to skip in headless/server environments (e.g. CLI parent manages the browser).
|
|
@@ -11,10 +11,6 @@ export function parseSessionId(sessionId: string): SessionId | null {
|
|
|
11
11
|
return { userId: sessionId };
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
export function formatSessionId(session: SessionId): string {
|
|
15
|
-
return session.userId;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
14
|
export interface Session {
|
|
19
15
|
id: string;
|
|
20
16
|
parsed: SessionId;
|
|
@@ -73,6 +69,12 @@ export class SessionManager {
|
|
|
73
69
|
return this.sessions.delete(sessionId);
|
|
74
70
|
}
|
|
75
71
|
|
|
72
|
+
deleteIfOwner(sessionId: string, ws: ServerWebSocket<unknown>): boolean {
|
|
73
|
+
const session = this.sessions.get(sessionId);
|
|
74
|
+
if (!session || session.ws !== ws) return false;
|
|
75
|
+
return this.sessions.delete(sessionId);
|
|
76
|
+
}
|
|
77
|
+
|
|
76
78
|
list(): Session[] {
|
|
77
79
|
return Array.from(this.sessions.values());
|
|
78
80
|
}
|