@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
|
@@ -45,6 +45,22 @@ export interface ModelDoc {
|
|
|
45
45
|
capabilities: string | null
|
|
46
46
|
enabled: boolean
|
|
47
47
|
active: boolean
|
|
48
|
+
/**
|
|
49
|
+
* "catalog" for rows that come from SEED_DATA, "discovered" for rows
|
|
50
|
+
* inserted at runtime by querying a provider (Ollama tags, /v1/models).
|
|
51
|
+
* The boot reseed only purges catalog rows — a discovered model has no
|
|
52
|
+
* canonical source to be re-created from, so wiping it would orphan every
|
|
53
|
+
* agent pointing at it. Legacy rows (undefined) are treated as discovered.
|
|
54
|
+
*/
|
|
55
|
+
source?: "catalog" | "discovered"
|
|
56
|
+
/**
|
|
57
|
+
* Precio en USD por millón de tokens. Única fuente de verdad para el costo
|
|
58
|
+
* del dashboard: `calculateCost` (storage/usage.ts) lee de acá, no de una
|
|
59
|
+
* tabla aparte. `null` = precio desconocido (modelo agregado a mano o
|
|
60
|
+
* descubierto en runtime), que se reporta como $0 con un warning.
|
|
61
|
+
*/
|
|
62
|
+
input_per_1m?: number | null
|
|
63
|
+
output_per_1m?: number | null
|
|
48
64
|
}
|
|
49
65
|
|
|
50
66
|
export interface AgentDoc {
|
|
@@ -63,6 +79,8 @@ export interface AgentDoc {
|
|
|
63
79
|
model_id: string
|
|
64
80
|
tools_json: string | null
|
|
65
81
|
skills_json: string | null
|
|
82
|
+
/** MCP server ids currently leased for this execution. */
|
|
83
|
+
active_mcp_json?: string | null
|
|
66
84
|
/** `toIndexable`-encoded — `NO_PARENT` for the coordinator. */
|
|
67
85
|
parent_id: string
|
|
68
86
|
max_iterations: number
|
|
@@ -71,6 +89,24 @@ export interface AgentDoc {
|
|
|
71
89
|
lastTraceAt: number | null
|
|
72
90
|
created_at: number
|
|
73
91
|
updated_at: number
|
|
92
|
+
|
|
93
|
+
// ─── Catalog fields (only populated for source:"catalog" seeded agents) ────
|
|
94
|
+
/** "catalog" = seeded persona from agent-catalog.ts (insert-only, survives reseed). Absent/"user" for everything else (coordinator, agent_create workers). */
|
|
95
|
+
source?: "user" | "catalog"
|
|
96
|
+
/** BM25 routing metadata (capability-search.ts) — `description` itself is already routing-friendly (one line, suitable for small local models) and doubles as the catalog line shown to the coordinator. */
|
|
97
|
+
routing_examples_json?: string | null
|
|
98
|
+
routing_exclusions_json?: string | null
|
|
99
|
+
/** Glob patterns. When present, task_delegate re-expands against the live tool registry at delegation time instead of trusting a possibly-stale tools_json. */
|
|
100
|
+
tool_allowlist_json?: string | null
|
|
101
|
+
/** Persistent MCP server assignments. User specialists normally contain exactly one server id. */
|
|
102
|
+
mcp_server_ids_json?: string | null
|
|
103
|
+
workspace_scope_json?: string | null
|
|
104
|
+
model_override_json?: string | null
|
|
105
|
+
default_acceptance_json?: string | null
|
|
106
|
+
/** ACE learning counters — updated by deterministic acceptance checks and the coordinator's own accept/revise judgment (acceptance-checks.ts), not by loop completion. */
|
|
107
|
+
helpful_count?: number
|
|
108
|
+
harmful_count?: number
|
|
109
|
+
seed_version?: number
|
|
74
110
|
}
|
|
75
111
|
|
|
76
112
|
// ─── Stage 2: catalog ─────────────────────────────────────────────────────────
|
|
@@ -143,6 +179,26 @@ export interface ToolDoc {
|
|
|
143
179
|
updated_at: number
|
|
144
180
|
}
|
|
145
181
|
|
|
182
|
+
// Sub-types for AgentDoc's catalog fields (workspace_scope_json, model_override_json,
|
|
183
|
+
// default_acceptance_json) — kept as named types for readability even though they're
|
|
184
|
+
// stored as JSON strings on the shared agents table, not a separate collection.
|
|
185
|
+
export type AgentWorkspaceScope =
|
|
186
|
+
| { kind: "none" }
|
|
187
|
+
| { kind: "workspace"; read_globs: string[]; write_globs: string[] }
|
|
188
|
+
| { kind: "resource"; resource_types: string[] }
|
|
189
|
+
|
|
190
|
+
export interface AgentModelOverride {
|
|
191
|
+
required_capabilities: string[]
|
|
192
|
+
fallback: "general"
|
|
193
|
+
prefer_different_family?: boolean
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
export interface AgentAcceptanceCriterion {
|
|
197
|
+
id: string
|
|
198
|
+
description: string
|
|
199
|
+
check_tool?: string | null
|
|
200
|
+
}
|
|
201
|
+
|
|
146
202
|
export interface EthicsDoc {
|
|
147
203
|
id: string
|
|
148
204
|
name: string
|
|
@@ -169,9 +225,21 @@ export interface UserIdentityDoc {
|
|
|
169
225
|
user_id: string
|
|
170
226
|
channel: string
|
|
171
227
|
channel_user_id: string
|
|
228
|
+
/** Account that owns this session — replies must go back out through it. Absent on legacy rows. */
|
|
229
|
+
account_id?: string
|
|
172
230
|
linked_at: number
|
|
173
231
|
}
|
|
174
232
|
|
|
233
|
+
export interface NotificationDoc {
|
|
234
|
+
id: string
|
|
235
|
+
user_id: string
|
|
236
|
+
channel: string
|
|
237
|
+
message: string
|
|
238
|
+
created_at: number
|
|
239
|
+
delivered_at: number | null
|
|
240
|
+
read_at: number | null
|
|
241
|
+
}
|
|
242
|
+
|
|
175
243
|
export interface UserChannelDoc {
|
|
176
244
|
id: string
|
|
177
245
|
user_id: string
|
|
@@ -197,16 +265,27 @@ export interface RefreshTokenDoc {
|
|
|
197
265
|
|
|
198
266
|
// ─── Stage 4: chat/ACE ────────────────────────────────────────────────────────
|
|
199
267
|
|
|
268
|
+
/** Where an incoming turn's content came from. */
|
|
269
|
+
export type TurnSource =
|
|
270
|
+
| "message" | "audio" | "a2ui" | "canvas" | "api"
|
|
271
|
+
| "task_complete" | "delegation_summary"
|
|
272
|
+
|
|
273
|
+
/** What gets persisted — adds the synthetic marker for rows written before `source` existed. */
|
|
274
|
+
export type MessageSource = TurnSource | "legacy_internal"
|
|
275
|
+
|
|
200
276
|
export interface ConversationDoc {
|
|
201
277
|
id: string
|
|
202
278
|
thread_id: string
|
|
203
279
|
channel: string
|
|
280
|
+
/** @deprecated "system" only appears in rows written before `source` existed — never written going forward. */
|
|
204
281
|
role: "user" | "assistant" | "tool" | "system"
|
|
205
282
|
content: string
|
|
206
283
|
content_multimodal: string | null
|
|
207
284
|
tool_calls_json: string | null
|
|
208
285
|
tool_call_id: string | null
|
|
209
286
|
reasoning_content: string | null
|
|
287
|
+
/** null on rows written before this field existed (legacy). */
|
|
288
|
+
source: MessageSource | null
|
|
210
289
|
token_count: number
|
|
211
290
|
created_at: number
|
|
212
291
|
updated_at: number
|
|
@@ -234,6 +313,8 @@ export interface TraceDoc {
|
|
|
234
313
|
created_at: number
|
|
235
314
|
/** G9 causal stream id for this run (agent-loop.ts's causalStreamId), when the causal log is enabled. */
|
|
236
315
|
causal_stream_id?: string | null
|
|
316
|
+
/** Catalog agent id when this trace belongs to a source:"catalog" agent. */
|
|
317
|
+
catalog_agent_id?: string
|
|
237
318
|
}
|
|
238
319
|
|
|
239
320
|
export interface ReflectionDoc {
|
|
@@ -300,6 +381,8 @@ export interface AgentRunDoc {
|
|
|
300
381
|
acceptance_json: string | null
|
|
301
382
|
/** Fixed-worker epoch recorded at run creation: {provider, model, app_version, tool_catalog_hash}. */
|
|
302
383
|
epoch_json: string | null
|
|
384
|
+
/** `toIndexable`-encoded catalog agent id, or `NO_PARENT` for ordinary agents. */
|
|
385
|
+
catalog_agent_id?: string
|
|
303
386
|
|
|
304
387
|
error: string | null
|
|
305
388
|
created_at: number
|
|
@@ -310,7 +393,7 @@ export interface AgentRunDoc {
|
|
|
310
393
|
export interface JobDoc {
|
|
311
394
|
id: string
|
|
312
395
|
lane: string
|
|
313
|
-
type: "chat_turn" | "worker_task" | "
|
|
396
|
+
type: "chat_turn" | "worker_task" | "goal_run"
|
|
314
397
|
status: "pending" | "running" | "completed" | "failed" | "cancelled" | "interrupted"
|
|
315
398
|
priority: number
|
|
316
399
|
payload_json: string
|
|
@@ -386,10 +469,43 @@ export interface ProofPacketDoc {
|
|
|
386
469
|
known_limits: string | null
|
|
387
470
|
/** Fixed-worker epoch this run executed under — copied from AgentRunDoc.epoch_json. */
|
|
388
471
|
epoch_json: string | null
|
|
472
|
+
/** `toIndexable`-encoded catalog agent id, or `NO_PARENT`. */
|
|
473
|
+
catalog_agent_id: string
|
|
389
474
|
met: boolean
|
|
390
475
|
created_at: number
|
|
391
476
|
}
|
|
392
477
|
|
|
478
|
+
/** Durable metadata for binary evidence managed under HIVE_HOME/artifacts. */
|
|
479
|
+
export interface ArtifactDoc {
|
|
480
|
+
id: string
|
|
481
|
+
run_id: string | null
|
|
482
|
+
task_id: string | null
|
|
483
|
+
user_id: string
|
|
484
|
+
kind: string
|
|
485
|
+
path: string
|
|
486
|
+
mime_type: string
|
|
487
|
+
size: number
|
|
488
|
+
sha256: string
|
|
489
|
+
width: number | null
|
|
490
|
+
height: number | null
|
|
491
|
+
status: "active" | "expired"
|
|
492
|
+
created_at: number
|
|
493
|
+
expires_at: number
|
|
494
|
+
expired_at: number | null
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
export interface AgentProposalDoc {
|
|
498
|
+
id: string
|
|
499
|
+
type: "move_tool" | "create_agent" | "disable_agent"
|
|
500
|
+
agent_id: string
|
|
501
|
+
proposed_change_json: string
|
|
502
|
+
evidence_trace_ids_json: string
|
|
503
|
+
confidence: number
|
|
504
|
+
status: "proposed" | "approved" | "rejected" | "applied"
|
|
505
|
+
created_at: number
|
|
506
|
+
updated_at: number
|
|
507
|
+
}
|
|
508
|
+
|
|
393
509
|
export interface TaskRunDoc {
|
|
394
510
|
id: string
|
|
395
511
|
task_id: string
|
|
@@ -413,45 +529,23 @@ export interface MemoryDoc {
|
|
|
413
529
|
updated_at: number
|
|
414
530
|
}
|
|
415
531
|
|
|
416
|
-
export interface ProjectDoc {
|
|
417
|
-
id: string
|
|
418
|
-
user_id: string
|
|
419
|
-
/** `toIndexable`-encoded — `NO_PARENT` when unset. */
|
|
420
|
-
agent_id: string
|
|
421
|
-
name: string
|
|
422
|
-
description: string | null
|
|
423
|
-
type: string
|
|
424
|
-
task: string | null
|
|
425
|
-
progress: number
|
|
426
|
-
status: "pending" | "active" | "paused" | "done" | "failed"
|
|
427
|
-
context: string | null
|
|
428
|
-
/** `toIndexable`-encoded — `NO_PARENT` for a top-level project. */
|
|
429
|
-
parent_id: string
|
|
430
|
-
created_at: number
|
|
431
|
-
updated_at: number
|
|
432
|
-
started_at: number | null
|
|
433
|
-
completed_at: number | null
|
|
434
|
-
}
|
|
435
|
-
|
|
436
532
|
export interface TaskDoc {
|
|
437
533
|
id: string
|
|
438
|
-
project_id: string
|
|
439
534
|
/** `toIndexable`-encoded — `NO_PARENT` when unset. */
|
|
440
535
|
agent_id: string
|
|
441
|
-
parent_task_id: string | null
|
|
442
536
|
name: string
|
|
443
537
|
description: string | null
|
|
444
|
-
|
|
445
|
-
status: "pending" | "queued" | "in_progress" | "completed" | "failed" | "blocked"
|
|
538
|
+
status: "pending" | "in_progress" | "completed" | "failed" | "blocked"
|
|
446
539
|
progress: number
|
|
447
|
-
priority: number
|
|
448
|
-
depends_on: string | null
|
|
449
540
|
result: string | null
|
|
450
541
|
error: string | null
|
|
451
542
|
metadata: string | null
|
|
452
543
|
job_id: string | null
|
|
453
544
|
run_id: string | null
|
|
454
545
|
thread_id: string | null
|
|
546
|
+
delegation_group_id?: string | null
|
|
547
|
+
/** `toIndexable`-encoded catalog agent id, or `NO_PARENT`. */
|
|
548
|
+
catalog_agent_id?: string
|
|
455
549
|
started_at: number | null
|
|
456
550
|
attempts: number
|
|
457
551
|
created_at: number
|
|
@@ -459,6 +553,35 @@ export interface TaskDoc {
|
|
|
459
553
|
completed_at: number | null
|
|
460
554
|
}
|
|
461
555
|
|
|
556
|
+
export interface DelegationGroupOutcome {
|
|
557
|
+
task_id: string
|
|
558
|
+
job_id: string
|
|
559
|
+
worker_id: string
|
|
560
|
+
task_name: string
|
|
561
|
+
ok: boolean
|
|
562
|
+
result: unknown | null
|
|
563
|
+
error: string | null
|
|
564
|
+
finished_at: number
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
export interface DelegationGroupDoc {
|
|
568
|
+
id: string
|
|
569
|
+
turn_id: string
|
|
570
|
+
thread_id: string
|
|
571
|
+
channel: string
|
|
572
|
+
user_id: string
|
|
573
|
+
session_id: string
|
|
574
|
+
coordinator_agent_id: string
|
|
575
|
+
status: "open" | "sealed" | "ready" | "notified"
|
|
576
|
+
task_ids_json: string
|
|
577
|
+
outcomes_json: string
|
|
578
|
+
summary_job_id: string | null
|
|
579
|
+
created_at: number
|
|
580
|
+
sealed_at: number | null
|
|
581
|
+
ready_at: number | null
|
|
582
|
+
notified_at: number | null
|
|
583
|
+
}
|
|
584
|
+
|
|
462
585
|
export interface AgentBusMessageDoc {
|
|
463
586
|
id: string
|
|
464
587
|
event_type: string
|
|
@@ -473,6 +596,23 @@ export interface AgentBusMessageDoc {
|
|
|
473
596
|
created_at: number
|
|
474
597
|
}
|
|
475
598
|
|
|
599
|
+
export interface NarrationEventDoc {
|
|
600
|
+
id: string
|
|
601
|
+
turn_id: string
|
|
602
|
+
thread_id: string
|
|
603
|
+
channel: string
|
|
604
|
+
user_id: string
|
|
605
|
+
session_id: string
|
|
606
|
+
agent_id: string
|
|
607
|
+
agent_name: string
|
|
608
|
+
kind: "delegated" | "worker_started" | "tool_call" | "tool_result" | "verified" | "failed" | "group_ready"
|
|
609
|
+
status: "queued" | "running" | "done" | "error"
|
|
610
|
+
label: string
|
|
611
|
+
detail: string | null
|
|
612
|
+
dedupe_key: string
|
|
613
|
+
created_at: number
|
|
614
|
+
}
|
|
615
|
+
|
|
476
616
|
// ─── Stage 7: meeting ─────────────────────────────────────────────────────────
|
|
477
617
|
|
|
478
618
|
export interface MeetingSessionDoc {
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import { createCipheriv, createDecipheriv, randomBytes } from "node:crypto"
|
|
2
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs"
|
|
3
|
+
import * as path from "node:path"
|
|
4
|
+
import { getHiveDir } from "../config/loader.ts"
|
|
1
5
|
import { logger } from "../utils/logger"
|
|
2
6
|
import { col } from "./hive"
|
|
3
7
|
|
|
@@ -9,49 +13,70 @@ interface SecretDoc {
|
|
|
9
13
|
iv: string
|
|
10
14
|
}
|
|
11
15
|
|
|
12
|
-
// ───
|
|
13
|
-
//
|
|
14
|
-
//
|
|
15
|
-
//
|
|
16
|
+
// ─── Durable secret store ────────────────────────────────────────────────────
|
|
17
|
+
// The `secrets` collection is the source of truth: AES-256-GCM ciphertext in
|
|
18
|
+
// the database, keyed by <HIVE_HOME>/.master.key. It lives inside the data
|
|
19
|
+
// directory, so whatever persists the database (a Docker volume, a backup)
|
|
20
|
+
// persists the secrets with it.
|
|
21
|
+
//
|
|
22
|
+
// The OS keychain (Bun.secrets) is only a best-effort mirror. It throws on
|
|
23
|
+
// headless Linux/Docker (no libsecret/D-Bus), and on desktops it can be a
|
|
24
|
+
// session keyring that is discarded when the session ends — so a secret
|
|
25
|
+
// written *only* there does not survive a server restart. That is exactly
|
|
26
|
+
// what was wiping every provider API key, channel token and MCP header on
|
|
27
|
+
// restart in production.
|
|
16
28
|
|
|
17
29
|
const _mem = new Map<string, string>()
|
|
18
30
|
let _keychainOk: boolean | null = null // null = untested
|
|
31
|
+
let _keychainApi: unknown = undefined
|
|
19
32
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
_keychainOk =
|
|
30
|
-
return _mem.get(name) ?? (await _readCollectionSecret(name))
|
|
33
|
+
/**
|
|
34
|
+
* A test double or a recovered runtime may replace Bun.secrets. Reset the
|
|
35
|
+
* cached availability result when that API object changes so a previous
|
|
36
|
+
* headless failure cannot poison the replacement backend forever.
|
|
37
|
+
*/
|
|
38
|
+
function _getKeychainApi(): any {
|
|
39
|
+
const api = (Bun as any).secrets
|
|
40
|
+
if (api !== _keychainApi) {
|
|
41
|
+
_keychainApi = api
|
|
42
|
+
_keychainOk = null
|
|
31
43
|
}
|
|
44
|
+
return api
|
|
32
45
|
}
|
|
33
46
|
|
|
47
|
+
async function _get(name: string): Promise<string | null> {
|
|
48
|
+
const cached = _mem.get(name)
|
|
49
|
+
if (cached !== undefined) return cached
|
|
50
|
+
|
|
51
|
+
// Durable store first — it is the one every write goes to.
|
|
52
|
+
const stored = await _readCollectionSecret(name)
|
|
53
|
+
if (stored) return stored
|
|
54
|
+
|
|
55
|
+
// Legacy/desktop installs may only have the value in the OS keychain.
|
|
56
|
+
const fromKeychain = await _keychainGet(name)
|
|
57
|
+
if (fromKeychain) _mem.set(name, fromKeychain)
|
|
58
|
+
return fromKeychain
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Persist a secret. Always writes the durable store; the keychain is
|
|
63
|
+
* mirrored on top when available. Returns false only when the value ended up
|
|
64
|
+
* nowhere but this process's memory — callers can use that to warn instead of
|
|
65
|
+
* silently accepting a secret that dies with the process.
|
|
66
|
+
*/
|
|
34
67
|
async function _set(name: string, value: string): Promise<boolean> {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
await (Bun as any).secrets.set({ service: SERVICE, name, value })
|
|
41
|
-
_keychainOk = true
|
|
42
|
-
return true
|
|
43
|
-
} catch {
|
|
44
|
-
_keychainOk = false
|
|
45
|
-
_mem.set(name, value)
|
|
46
|
-
return persistSecretToCollection(name, value)
|
|
68
|
+
_mem.set(name, value)
|
|
69
|
+
const durable = await persistSecretToCollection(name, value)
|
|
70
|
+
const mirrored = await _keychainSet(name, value)
|
|
71
|
+
if (!durable && !mirrored) {
|
|
72
|
+
log.error(`[secrets] ${name} could not be persisted — it will be lost on restart`)
|
|
47
73
|
}
|
|
74
|
+
return durable || mirrored
|
|
48
75
|
}
|
|
49
76
|
|
|
50
77
|
/**
|
|
51
|
-
* Read a secret from the `secrets` HiveDB collection
|
|
52
|
-
*
|
|
53
|
-
* survive process restarts when the OS keychain is unavailable (Docker,
|
|
54
|
-
* headless).
|
|
78
|
+
* Read a secret from the `secrets` HiveDB collection — the durable store.
|
|
79
|
+
* Decrypted values are cached in memory for the rest of the process.
|
|
55
80
|
*/
|
|
56
81
|
async function _readCollectionSecret(name: string): Promise<string | null> {
|
|
57
82
|
try {
|
|
@@ -69,6 +94,32 @@ async function _readCollectionSecret(name: string): Promise<string | null> {
|
|
|
69
94
|
}
|
|
70
95
|
}
|
|
71
96
|
|
|
97
|
+
async function _keychainGet(name: string): Promise<string | null> {
|
|
98
|
+
const keychain = _getKeychainApi()
|
|
99
|
+
if (_keychainOk === false) return null
|
|
100
|
+
try {
|
|
101
|
+
const val = await keychain.get({ service: SERVICE, name })
|
|
102
|
+
_keychainOk = true
|
|
103
|
+
return val ?? null
|
|
104
|
+
} catch {
|
|
105
|
+
_keychainOk = false
|
|
106
|
+
return null
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
async function _keychainSet(name: string, value: string): Promise<boolean> {
|
|
111
|
+
const keychain = _getKeychainApi()
|
|
112
|
+
if (_keychainOk === false) return false
|
|
113
|
+
try {
|
|
114
|
+
await keychain.set({ service: SERVICE, name, value })
|
|
115
|
+
_keychainOk = true
|
|
116
|
+
return true
|
|
117
|
+
} catch {
|
|
118
|
+
_keychainOk = false
|
|
119
|
+
return false
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
72
123
|
async function _del(name: string): Promise<void> {
|
|
73
124
|
_mem.delete(name)
|
|
74
125
|
try {
|
|
@@ -84,6 +135,22 @@ async function _del(name: string): Promise<void> {
|
|
|
84
135
|
}
|
|
85
136
|
}
|
|
86
137
|
|
|
138
|
+
/**
|
|
139
|
+
* Mint the master key (if this is a fresh install) and report where secrets
|
|
140
|
+
* will be stored. Called once at boot so an operator sees the answer before
|
|
141
|
+
* typing an API key, not after a restart lost it.
|
|
142
|
+
*/
|
|
143
|
+
export function ensureSecretsBackend(): { durable: boolean } {
|
|
144
|
+
const durable = getMasterKey() !== null
|
|
145
|
+
if (!durable) {
|
|
146
|
+
log.error(
|
|
147
|
+
`[secrets] No master key available — API keys and channel tokens will NOT survive a restart. ` +
|
|
148
|
+
`Set HIVE_MASTER_KEY or make ${getHiveDir()} writable.`
|
|
149
|
+
)
|
|
150
|
+
}
|
|
151
|
+
return { durable }
|
|
152
|
+
}
|
|
153
|
+
|
|
87
154
|
// ─── Primitive API ────────────────────────────────────────────────────────────
|
|
88
155
|
|
|
89
156
|
export async function storeSecret(name: string, value: string): Promise<void> {
|
|
@@ -209,13 +276,12 @@ export function verifyPassword(password: string, hash: string): boolean {
|
|
|
209
276
|
// ─── AES-256-GCM for the collection-backed secret fallback ──────────────────
|
|
210
277
|
|
|
211
278
|
export function decryptSecret(encrypted: string, iv: string): string {
|
|
212
|
-
const nodeCrypto = require("node:crypto")
|
|
213
279
|
const key = getMasterKey()
|
|
214
280
|
if (!key) return ""
|
|
215
281
|
try {
|
|
216
282
|
const ivBuf = Buffer.from(iv, "hex")
|
|
217
283
|
const [encData, authTag] = encrypted.split(":")
|
|
218
|
-
const decipher =
|
|
284
|
+
const decipher = createDecipheriv("aes-256-gcm", key, ivBuf)
|
|
219
285
|
decipher.setAuthTag(Buffer.from(authTag, "hex"))
|
|
220
286
|
return decipher.update(encData, "hex", "utf8") + decipher.final("utf8")
|
|
221
287
|
} catch {
|
|
@@ -223,38 +289,63 @@ export function decryptSecret(encrypted: string, iv: string): string {
|
|
|
223
289
|
}
|
|
224
290
|
}
|
|
225
291
|
|
|
292
|
+
let _masterKey: Buffer | null = null
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* The AES key protecting the `secrets` collection.
|
|
296
|
+
*
|
|
297
|
+
* `HIVE_MASTER_KEY` wins when set (the recommended way to run in production:
|
|
298
|
+
* the key never touches the data volume). Otherwise the key is minted on
|
|
299
|
+
* first use and written 0600 to `<HIVE_HOME>/.master.key`, next to the
|
|
300
|
+
* database — a fresh install becomes durable without the user configuring
|
|
301
|
+
* anything, and restoring the data directory restores the ability to read
|
|
302
|
+
* the secrets inside it.
|
|
303
|
+
*/
|
|
226
304
|
function getMasterKey(): Buffer | null {
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
const
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
if (masterKey) {
|
|
234
|
-
return Buffer.from(masterKey.slice(0, 32).padEnd(32, "0"), "utf8")
|
|
305
|
+
if (_masterKey) return _masterKey
|
|
306
|
+
|
|
307
|
+
const fromEnv = process.env.HIVE_MASTER_KEY
|
|
308
|
+
if (fromEnv) {
|
|
309
|
+
_masterKey = Buffer.from(fromEnv.slice(0, 32).padEnd(32, "0"), "utf8")
|
|
310
|
+
return _masterKey
|
|
235
311
|
}
|
|
236
|
-
|
|
237
|
-
const keyPath =
|
|
238
|
-
if (!nodeFs.existsSync(keyPath)) return null
|
|
312
|
+
|
|
313
|
+
const keyPath = path.join(getHiveDir(), ".master.key")
|
|
239
314
|
try {
|
|
240
|
-
|
|
241
|
-
|
|
315
|
+
if (!existsSync(keyPath)) {
|
|
316
|
+
mkdirSync(path.dirname(keyPath), { recursive: true })
|
|
317
|
+
try {
|
|
318
|
+
// "wx" so two processes starting at once can't overwrite each other's key
|
|
319
|
+
writeFileSync(keyPath, randomBytes(32).toString("hex"), { mode: 0o600, flag: "wx" })
|
|
320
|
+
log.info(`[secrets] Master key generated at ${keyPath}`)
|
|
321
|
+
} catch (err) {
|
|
322
|
+
if ((err as NodeJS.ErrnoException).code !== "EEXIST") throw err
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
const key = Buffer.from(readFileSync(keyPath, "utf8").trim(), "hex")
|
|
326
|
+
if (key.length !== 32) {
|
|
327
|
+
log.error(`[secrets] ${keyPath} is not a 32-byte hex key — secrets cannot be read or written`)
|
|
328
|
+
return null
|
|
329
|
+
}
|
|
330
|
+
_masterKey = key
|
|
331
|
+
return _masterKey
|
|
332
|
+
} catch (err) {
|
|
333
|
+
log.error(`[secrets] Could not read or create ${keyPath}: ${(err as Error).message}`)
|
|
242
334
|
return null
|
|
243
335
|
}
|
|
244
336
|
}
|
|
245
337
|
|
|
246
338
|
/**
|
|
247
339
|
* Encrypt a plaintext string with AES-256-GCM. Format:
|
|
248
|
-
* `<encDataHex>:<authTagHex>`. Used
|
|
249
|
-
*
|
|
340
|
+
* `<encDataHex>:<authTagHex>`. Used for every document in the `secrets`
|
|
341
|
+
* collection.
|
|
250
342
|
*/
|
|
251
343
|
export function encryptSecret(plain: string, ivHex: string): string {
|
|
252
|
-
const nodeCrypto = require("node:crypto")
|
|
253
344
|
const key = getMasterKey()
|
|
254
345
|
if (!key) return ""
|
|
255
346
|
try {
|
|
256
347
|
const iv = Buffer.from(ivHex, "hex")
|
|
257
|
-
const cipher =
|
|
348
|
+
const cipher = createCipheriv("aes-256-gcm", key, iv)
|
|
258
349
|
const encData = cipher.update(plain, "utf8", "hex") + cipher.final("hex")
|
|
259
350
|
const authTag = cipher.getAuthTag().toString("hex")
|
|
260
351
|
return `${encData}:${authTag}`
|
|
@@ -264,20 +355,18 @@ export function encryptSecret(plain: string, ivHex: string): string {
|
|
|
264
355
|
}
|
|
265
356
|
|
|
266
357
|
/**
|
|
267
|
-
* Persist a secret to the `secrets` collection
|
|
268
|
-
*
|
|
269
|
-
*
|
|
358
|
+
* Persist a secret to the `secrets` collection — the durable store — keyed by
|
|
359
|
+
* the canonical secret name (e.g. `provider:openai:api_key`). Returns true if
|
|
360
|
+
* the document was written.
|
|
270
361
|
*/
|
|
271
362
|
async function persistSecretToCollection(name: string, value: string): Promise<boolean> {
|
|
272
|
-
const nodeCrypto = require("node:crypto")
|
|
273
|
-
|
|
274
363
|
const key = getMasterKey()
|
|
275
364
|
if (!key) {
|
|
276
|
-
log.warn(`[secrets] No master key
|
|
365
|
+
log.warn(`[secrets] No master key — cannot persist ${name} durably`)
|
|
277
366
|
return false
|
|
278
367
|
}
|
|
279
368
|
|
|
280
|
-
const iv =
|
|
369
|
+
const iv = randomBytes(12).toString("hex")
|
|
281
370
|
const ciphertext = encryptSecret(value, iv)
|
|
282
371
|
if (!ciphertext) return false
|
|
283
372
|
|
|
@@ -286,7 +375,7 @@ async function persistSecretToCollection(name: string, value: string): Promise<b
|
|
|
286
375
|
await secrets.put(name, { ciphertext, iv })
|
|
287
376
|
return true
|
|
288
377
|
} catch (err) {
|
|
289
|
-
log.warn(`[secrets]
|
|
378
|
+
log.warn(`[secrets] Durable write failed for ${name}: ${(err as Error).message}`)
|
|
290
379
|
return false
|
|
291
380
|
}
|
|
292
381
|
}
|
|
@@ -48,6 +48,15 @@ export async function getHiveDb(): Promise<HiveDB> {
|
|
|
48
48
|
return opening;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
+
/**
|
|
52
|
+
* Return the currently open database without opening one.
|
|
53
|
+
* Used by lifecycle-aware consumers that need to invalidate state after a
|
|
54
|
+
* close/reopen cycle.
|
|
55
|
+
*/
|
|
56
|
+
export function getOpenHiveDb(): HiveDB | null {
|
|
57
|
+
return db;
|
|
58
|
+
}
|
|
59
|
+
|
|
51
60
|
export function closeHiveDb(): void {
|
|
52
61
|
if (db) {
|
|
53
62
|
try {
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Claves de la colección `models`.
|
|
3
|
+
*
|
|
4
|
+
* La colección se indexa sólo por el id del modelo, así que dos providers que
|
|
5
|
+
* sirvan el mismo modelo colisionan y uno pisa al otro (pasó de verdad con
|
|
6
|
+
* `z-ai/glm-5.2`, presente a la vez en NVIDIA NIM y en OpenRouter).
|
|
7
|
+
*
|
|
8
|
+
* Regla: el id conserva el nombre que le da el propietario del modelo, y los
|
|
9
|
+
* servicios revendedores lo prefijan con su propio id de provider.
|
|
10
|
+
*
|
|
11
|
+
* nvidia + z-ai/glm-5.2 → nvidia/z-ai/glm-5.2
|
|
12
|
+
* openrouter + z-ai/glm-5.2 → openrouter/z-ai/glm-5.2
|
|
13
|
+
* anthropic + claude-opus-5 → claude-opus-5
|
|
14
|
+
*
|
|
15
|
+
* El prefijo no llega al cable: `OpenAICompatBase.call()` quita
|
|
16
|
+
* `^<providerName>/` antes de armar el request, así que el provider recibe el
|
|
17
|
+
* nombre del propietario tal cual. Por eso todos los revendedores de esta lista
|
|
18
|
+
* deben ser OpenAI-compatibles.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
const RESELLER_PROVIDERS = new Set(["nvidia", "openrouter", "opencode-go", "groq", "modelscope"])
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Id de fila en `models` para el modelo `wireId` servido por `providerId`.
|
|
25
|
+
*
|
|
26
|
+
* `wireId` es siempre el nombre del cable, nunca una clave ya prefijada. No hay
|
|
27
|
+
* atajo de idempotencia a propósito: "ya lleva el prefijo" es indistinguible de
|
|
28
|
+
* "el namespace del propietario coincide con el id del provider". NVIDIA sirve
|
|
29
|
+
* `nvidia/nemotron-3-super-120b-a12b` y Groq sirve `groq/compound`, así que
|
|
30
|
+
* saltarse el prefijo por un `startsWith` recortaba de más al volver al cable y
|
|
31
|
+
* mandaba `nemotron-…` / `compound`.
|
|
32
|
+
*/
|
|
33
|
+
export function catalogModelKey(providerId: string, wireId: string): string {
|
|
34
|
+
return RESELLER_PROVIDERS.has(providerId) ? `${providerId}/${wireId}` : wireId
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Inversa de `catalogModelKey`: el nombre que el provider espera en el cable.
|
|
39
|
+
*
|
|
40
|
+
* Los adapters OpenAI-compatibles ya hacen este strip solos al armar el request,
|
|
41
|
+
* así que esto es para los caminos que mandan el modelo a mano — por ejemplo la
|
|
42
|
+
* verificación de API key en `gateway/routes/setup.ts`, que arma su propio fetch.
|
|
43
|
+
*/
|
|
44
|
+
export function wireModelId(providerId: string, key: string): string {
|
|
45
|
+
const prefix = `${providerId}/`
|
|
46
|
+
if (!RESELLER_PROVIDERS.has(providerId) || !key.startsWith(prefix)) return key
|
|
47
|
+
return key.slice(prefix.length)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** True cuando el provider revende modelos de terceros y por eso prefija sus ids. */
|
|
51
|
+
export function isResellerProvider(providerId: string): boolean {
|
|
52
|
+
return RESELLER_PROVIDERS.has(providerId)
|
|
53
|
+
}
|