@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
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import * as path from "node:path";
|
|
2
|
+
import { existsSync } from "node:fs";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* De dónde sale la UI que sirve el gateway en producción.
|
|
6
|
+
*
|
|
7
|
+
* `disk` gana siempre que haya un `index.html` real, porque esa copia se
|
|
8
|
+
* construye en el mismo paso que la publica (la etapa `ui-builder` del
|
|
9
|
+
* Dockerfile, o `packages/hive-ui/dist` en el monorepo). `embedded` es el
|
|
10
|
+
* bundle que `generate-ui-bundle.ts` compila dentro del ejecutable standalone,
|
|
11
|
+
* que es la única forma de que un binario suelto tenga UI pero que también
|
|
12
|
+
* puede quedar viejo respecto del disco.
|
|
13
|
+
*/
|
|
14
|
+
export type UISource =
|
|
15
|
+
| { kind: "disk"; dir: string }
|
|
16
|
+
| { kind: "embedded" }
|
|
17
|
+
| { kind: "none"; dir: string };
|
|
18
|
+
|
|
19
|
+
export type UISourceInput = {
|
|
20
|
+
uiDirEnv?: string;
|
|
21
|
+
distDirEnv?: string;
|
|
22
|
+
hiveDir: string;
|
|
23
|
+
cwd: string;
|
|
24
|
+
hasEmbedded: boolean;
|
|
25
|
+
/** Inyectable para poder testear sin tocar el filesystem. */
|
|
26
|
+
exists?: (candidate: string) => boolean;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Orden:
|
|
31
|
+
* HIVE_UI_DIR > bundle embebido > ~/.hive/ui > HIVE_DIST_DIR/ui > cwd/packages/hive-ui/dist
|
|
32
|
+
*
|
|
33
|
+
* La elección es una sola por request y no por path: mezclar dos fuentes
|
|
34
|
+
* serviría un `index.html` de un build con los `assets/index-<hash>.js` de otro.
|
|
35
|
+
*/
|
|
36
|
+
export function resolveUISource(input: UISourceInput): UISource {
|
|
37
|
+
const exists = input.exists ?? existsSync;
|
|
38
|
+
const hasIndex = (dir: string) => exists(path.join(dir, "index.html"));
|
|
39
|
+
|
|
40
|
+
// HIVE_UI_DIR es un override explícito y le gana al embed. Es lo que usa la
|
|
41
|
+
// imagen Docker, cuya etapa ui-builder compila la UI en cada build y la deja
|
|
42
|
+
// en /app/ui. Cuando el embed ganaba, el contenedor servía la copia que
|
|
43
|
+
// viajaba dentro del binario —commiteada y congelada— y /app/ui quedaba
|
|
44
|
+
// inerte.
|
|
45
|
+
if (input.uiDirEnv && hasIndex(input.uiDirEnv)) {
|
|
46
|
+
return { kind: "disk", dir: input.uiDirEnv };
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// El embed va compilado dentro del ejecutable, así que siempre corresponde a
|
|
50
|
+
// su versión. Le gana a los directorios heredados: ~/.hive/ui puede haber
|
|
51
|
+
// quedado de una instalación anterior y taparía la UI del binario nuevo.
|
|
52
|
+
if (input.hasEmbedded) return { kind: "embedded" };
|
|
53
|
+
|
|
54
|
+
const fallbacks = [
|
|
55
|
+
path.join(input.hiveDir, "ui"),
|
|
56
|
+
input.distDirEnv ? path.join(input.distDirEnv, "ui") : undefined,
|
|
57
|
+
path.join(input.cwd, "packages/hive-ui/dist"),
|
|
58
|
+
].filter((dir): dir is string => Boolean(dir));
|
|
59
|
+
|
|
60
|
+
for (const dir of fallbacks) {
|
|
61
|
+
if (hasIndex(dir)) return { kind: "disk", dir };
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Sin UI en ningún lado: se devuelve el candidato preferido para poder
|
|
65
|
+
// nombrarlo en el mensaje de error.
|
|
66
|
+
return { kind: "none", dir: input.uiDirEnv ?? fallbacks[0]! };
|
|
67
|
+
}
|
|
@@ -6,8 +6,9 @@ import type { AgentDoc, ProviderDoc, McpServerDoc } from "../storage/collections
|
|
|
6
6
|
import { buildAgentLoop } from "../agent/agent-loop";
|
|
7
7
|
import { AgentRunner } from "../agent/providers/index";
|
|
8
8
|
import { ChannelManager } from "../channels/manager";
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
9
|
+
import { syncToolsToIndex, syncSkillsToIndex, syncPlaybookToIndex } from "../agent/context-compiler";
|
|
10
|
+
import { syncMCPToolsToIndex } from "../mcp/tool-sync";
|
|
11
|
+
import { syncCatalogAgentsToIndex } from "../agent/catalog-selector";
|
|
11
12
|
import { AgentService, createAgentService } from "../agent/service";
|
|
12
13
|
import { mkdirSync } from "node:fs";
|
|
13
14
|
import * as path from "node:path";
|
|
@@ -24,7 +25,7 @@ const log = logger.child("gateway:init");
|
|
|
24
25
|
/**
|
|
25
26
|
* Verifica que exista al menos un usuario en la base de datos
|
|
26
27
|
*/
|
|
27
|
-
|
|
28
|
+
async function verifyDatabaseUsers(): Promise<void> {
|
|
28
29
|
try {
|
|
29
30
|
await ensureHiveDb();
|
|
30
31
|
|
|
@@ -48,7 +49,7 @@ export async function verifyDatabaseUsers(): Promise<void> {
|
|
|
48
49
|
/**
|
|
49
50
|
* Escribe el archivo PID del proceso
|
|
50
51
|
*/
|
|
51
|
-
|
|
52
|
+
async function writePidFile(pidFile: string): Promise<void> {
|
|
52
53
|
try {
|
|
53
54
|
const dir = path.dirname(pidFile);
|
|
54
55
|
mkdirSync(dir, { recursive: true });
|
|
@@ -64,7 +65,7 @@ export async function writePidFile(pidFile: string): Promise<void> {
|
|
|
64
65
|
* Carga la configuración del agente desde la base de datos
|
|
65
66
|
* @returns Provider y modelo configurados
|
|
66
67
|
*/
|
|
67
|
-
|
|
68
|
+
async function loadAgentConfigFromDB(
|
|
68
69
|
config: Config
|
|
69
70
|
): Promise<{ provider: string; model: string }> {
|
|
70
71
|
// Último recurso cuando la BD aún no tiene providers/modelos activos (setup inicial)
|
|
@@ -143,7 +144,7 @@ export async function loadAgentConfigFromDB(
|
|
|
143
144
|
/**
|
|
144
145
|
* Inicializa el agent loop
|
|
145
146
|
*/
|
|
146
|
-
|
|
147
|
+
async function initializeAgentLoop(mcpManager?: any): Promise<void> {
|
|
147
148
|
try {
|
|
148
149
|
await buildAgentLoop({ mcpManager });
|
|
149
150
|
log.info("Agent loop initialized");
|
|
@@ -156,7 +157,7 @@ export async function initializeAgentLoop(mcpManager?: any): Promise<void> {
|
|
|
156
157
|
/**
|
|
157
158
|
* Inicializa el runner de LLM
|
|
158
159
|
*/
|
|
159
|
-
|
|
160
|
+
async function initializeLLMRunner(
|
|
160
161
|
config: Config,
|
|
161
162
|
provider: string,
|
|
162
163
|
model: string
|
|
@@ -174,7 +175,7 @@ export async function initializeLLMRunner(
|
|
|
174
175
|
/**
|
|
175
176
|
* Inicializa el manager de canales
|
|
176
177
|
*/
|
|
177
|
-
|
|
178
|
+
async function initializeChannelManager(
|
|
178
179
|
config: Config
|
|
179
180
|
): Promise<ChannelManager> {
|
|
180
181
|
try {
|
|
@@ -242,15 +243,16 @@ export async function initializeGateway(
|
|
|
242
243
|
const { getHiveDb } = await import("../storage/hivedb");
|
|
243
244
|
const searchDb = await getHiveDb();
|
|
244
245
|
await Promise.all([
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
246
|
+
syncToolsToIndex(),
|
|
247
|
+
syncSkillsToIndex(),
|
|
248
|
+
syncPlaybookToIndex(),
|
|
249
|
+
syncMCPToolsToIndex(),
|
|
250
|
+
syncCatalogAgentsToIndex()
|
|
249
251
|
]);
|
|
250
252
|
// Warmup query: the first search pays reader initialization; do it here
|
|
251
253
|
// so selector latency stays under budget on the first real message.
|
|
252
254
|
await searchDb.queryHybrid({ text: "warmup", k: 1 });
|
|
253
|
-
log.info("[initialize] ✅ HiveDB capability index synced (tools, skills, playbook, mcp_tools)")
|
|
255
|
+
log.info("[initialize] ✅ HiveDB capability index synced (tools, skills, playbook, mcp_tools, catalog agents)")
|
|
254
256
|
} catch (err) {
|
|
255
257
|
log.error(`[initialize] HiveDB index sync failed during startup: ${(err as Error).message}`);
|
|
256
258
|
// Consider if we should throw or continue. For now, continue but log error.
|
|
@@ -8,24 +8,32 @@
|
|
|
8
8
|
* Executors:
|
|
9
9
|
* - chat_turn: runs the agent loop + streams tokens back to the WS channel
|
|
10
10
|
* - worker_task: runs an isolated worker agent + notifies the bus + channel
|
|
11
|
-
* -
|
|
11
|
+
* - goal_run: multi-turn orchestration until the goal verifies or budget ends
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
14
|
import { registerExecutor, type JobExecutor } from "./durable-queue";
|
|
15
15
|
import { logger } from "../utils/logger";
|
|
16
16
|
import { col, updateDoc } from "../storage/hive";
|
|
17
17
|
import { isRetryableError } from "../resilience/retry";
|
|
18
|
-
import type { JobDoc, TaskDoc, AgentRunDoc } from "../storage/collections";
|
|
19
|
-
import { runAgent, runAgentIsolated } from "../agent/agent-loop";
|
|
18
|
+
import type { JobDoc, TaskDoc, AgentRunDoc, AgentDoc } from "../storage/collections";
|
|
19
|
+
import { runAgent, runAgentIsolated, runAgentIsolatedDetailed } from "../agent/agent-loop";
|
|
20
20
|
import { createRun, completeRun, failRun, interruptRun, getRun, reclaimRun, bumpTurn, startLeaseRenewal, stopLeaseRenewal, deserializeAcceptance, deserializeEpoch } from "../agent/run-store";
|
|
21
21
|
import { getDurableQueue } from "./durable-queue";
|
|
22
22
|
import { sendToUserChannel } from "./channel-notify";
|
|
23
23
|
import { verifyGoal } from "../agent/goal-runner";
|
|
24
24
|
import { buildProofPacket } from "../agent/proof-packet";
|
|
25
|
+
import { runAcceptanceChecks, recordAgentOutcome } from "../agent/acceptance-checks";
|
|
26
|
+
import { prepareDelegation, type PreparedDelegation } from "../agent/delegation-runtime";
|
|
25
27
|
import { runWebchatTurn, type WebchatTurnPayload } from "./webchat-turn";
|
|
26
28
|
import { agentBus } from "../events/agent-bus";
|
|
27
29
|
import { resolveContext } from "./resolver";
|
|
28
30
|
import type { MCPClientManager } from "@johpaz/hive-agents-mcp";
|
|
31
|
+
import { publishNarration } from "../events/narration";
|
|
32
|
+
import {
|
|
33
|
+
emitDelegationStarted,
|
|
34
|
+
emitDelegationFinished,
|
|
35
|
+
emitWorkEvent,
|
|
36
|
+
} from "../canvas/emitter";
|
|
29
37
|
|
|
30
38
|
const log = logger.child("job-executors");
|
|
31
39
|
|
|
@@ -65,17 +73,42 @@ const workerTaskExecutor: JobExecutor = async (job, signal) => {
|
|
|
65
73
|
const taskDescription = payload.taskDescription as string;
|
|
66
74
|
const taskName = payload.taskName as string;
|
|
67
75
|
const taskId = payload.taskId as string | undefined;
|
|
76
|
+
const acceptance = (payload.acceptance ?? null) as import("../agent/run-store").AcceptanceCriterion[] | null;
|
|
68
77
|
const runId = job.run_id;
|
|
78
|
+
const turnId = payload.turnId as string | undefined;
|
|
79
|
+
const parentAgentId = (payload.parentAgentId as string | undefined) ?? "";
|
|
80
|
+
const originThreadId = payload.originThreadId as string | undefined;
|
|
81
|
+
const originChannel = payload.originChannel as string | undefined;
|
|
82
|
+
const originUserId = payload.userId as string | undefined;
|
|
83
|
+
const originSessionId = payload.originSessionId as string | undefined;
|
|
69
84
|
|
|
70
85
|
log.info(`[worker_task] Job ${job.id} → worker=${workerId} task="${taskName}"`);
|
|
71
86
|
|
|
72
|
-
const agentsCol = await col<
|
|
87
|
+
const agentsCol = await col<AgentDoc>("agents");
|
|
73
88
|
const workerEntry = await agentsCol.get(workerId);
|
|
74
89
|
if (!workerEntry) return { ok: false, error: `Worker not found: ${workerId}`, retryable: false };
|
|
75
90
|
if (!workerEntry.doc.enabled) return { ok: false, error: `Worker disabled: ${workerEntry.doc.name}`, retryable: false };
|
|
76
91
|
|
|
77
92
|
const workerName = workerEntry.doc.name;
|
|
93
|
+
const isCatalogAgent = workerEntry.doc.source === "catalog";
|
|
78
94
|
agentBus.notifyTaskStarted(workerId, workerName, 0, taskName, "");
|
|
95
|
+
const delegationRef = taskId ?? job.id;
|
|
96
|
+
emitDelegationStarted({ workerId, parentAgentId, taskRef: delegationRef, taskName });
|
|
97
|
+
if (turnId && originThreadId) {
|
|
98
|
+
await publishNarration({
|
|
99
|
+
turnId,
|
|
100
|
+
threadId: originThreadId,
|
|
101
|
+
channel: originChannel,
|
|
102
|
+
userId: originUserId,
|
|
103
|
+
sessionId: originSessionId,
|
|
104
|
+
agentId: workerId,
|
|
105
|
+
agentName: workerName,
|
|
106
|
+
kind: "worker_started",
|
|
107
|
+
status: "running",
|
|
108
|
+
label: `${workerName} inició “${taskName}”`,
|
|
109
|
+
dedupeKey: `worker_started:${taskId ?? job.id}`,
|
|
110
|
+
});
|
|
111
|
+
}
|
|
79
112
|
|
|
80
113
|
// Update TaskDoc → in_progress if we have a taskId
|
|
81
114
|
if (taskId) {
|
|
@@ -88,13 +121,20 @@ const workerTaskExecutor: JobExecutor = async (job, signal) => {
|
|
|
88
121
|
} as Partial<TaskDoc>).catch(() => {});
|
|
89
122
|
}
|
|
90
123
|
|
|
124
|
+
let prepared: PreparedDelegation | null = null;
|
|
91
125
|
try {
|
|
126
|
+
prepared = await prepareDelegation(workerId, {
|
|
127
|
+
workspace: payload.workspace ?? workerEntry.doc.workspace ?? null,
|
|
128
|
+
parentProviderId: payload.parentProviderId ?? null,
|
|
129
|
+
parentModelId: payload.parentModelId ?? null,
|
|
130
|
+
mcpManager,
|
|
131
|
+
});
|
|
92
132
|
// Resume from the checkpoint on a re-claimed job (payload can't know this)
|
|
93
133
|
const run = runId ? await getRun(runId) : null;
|
|
94
134
|
const resume = !!run?.state_json;
|
|
95
135
|
const threadId = run?.thread_id || `task-${Date.now()}-${workerId}`;
|
|
96
136
|
|
|
97
|
-
const
|
|
137
|
+
const execution = await runAgentIsolatedDetailed({
|
|
98
138
|
agentId: workerId,
|
|
99
139
|
taskDescription,
|
|
100
140
|
threadId,
|
|
@@ -103,10 +143,24 @@ const workerTaskExecutor: JobExecutor = async (job, signal) => {
|
|
|
103
143
|
resume,
|
|
104
144
|
durable: !!runId,
|
|
105
145
|
signal,
|
|
146
|
+
turnId,
|
|
147
|
+
taskId,
|
|
148
|
+
userId: originUserId,
|
|
149
|
+
channel: originChannel,
|
|
150
|
+
sessionId: originSessionId,
|
|
106
151
|
});
|
|
152
|
+
const result = execution.content;
|
|
107
153
|
|
|
108
154
|
if (signal.aborted) {
|
|
109
155
|
agentBus.notifyTaskFailed(workerId, workerName, 0, taskName, "", "Aborted");
|
|
156
|
+
emitWorkEvent({
|
|
157
|
+
phase: "aborted",
|
|
158
|
+
taskRef: delegationRef,
|
|
159
|
+
taskName,
|
|
160
|
+
actorId: workerId,
|
|
161
|
+
targetId: parentAgentId || null,
|
|
162
|
+
detail: "Trabajo interrumpido",
|
|
163
|
+
});
|
|
110
164
|
if (taskId) {
|
|
111
165
|
await updateDoc<TaskDoc>("tasks", taskId, {
|
|
112
166
|
status: "pending",
|
|
@@ -116,6 +170,81 @@ const workerTaskExecutor: JobExecutor = async (job, signal) => {
|
|
|
116
170
|
return { ok: false, error: "Aborted", retryable: false };
|
|
117
171
|
}
|
|
118
172
|
|
|
173
|
+
const finishedRun = runId ? await getRun(runId) : null;
|
|
174
|
+
const resolvedAcceptance = acceptance ?? (finishedRun ? deserializeAcceptance(finishedRun) : null);
|
|
175
|
+
const evidence = [result, ...execution.toolEvidence];
|
|
176
|
+
const checks = await runAcceptanceChecks({
|
|
177
|
+
objective: taskDescription,
|
|
178
|
+
acceptance: resolvedAcceptance,
|
|
179
|
+
delivery: result,
|
|
180
|
+
evidence,
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
if (checks.status === "failed") {
|
|
184
|
+
await recordAgentOutcome(workerId, "harmful");
|
|
185
|
+
emitWorkEvent({
|
|
186
|
+
phase: "review_failed",
|
|
187
|
+
taskRef: delegationRef,
|
|
188
|
+
taskName,
|
|
189
|
+
actorId: parentAgentId || workerId,
|
|
190
|
+
targetId: workerId,
|
|
191
|
+
detail: checks.summary,
|
|
192
|
+
});
|
|
193
|
+
if (turnId && originThreadId) {
|
|
194
|
+
await publishNarration({
|
|
195
|
+
turnId,
|
|
196
|
+
threadId: originThreadId,
|
|
197
|
+
channel: originChannel,
|
|
198
|
+
userId: originUserId,
|
|
199
|
+
sessionId: originSessionId,
|
|
200
|
+
agentId: workerId,
|
|
201
|
+
agentName: workerName,
|
|
202
|
+
kind: "failed",
|
|
203
|
+
status: "error",
|
|
204
|
+
label: `La entrega de ${workerName} no pasó los checks automáticos`,
|
|
205
|
+
detail: checks.summary,
|
|
206
|
+
dedupeKey: `verification_failed:${taskId ?? job.id}`,
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
if (taskId) {
|
|
210
|
+
await updateDoc<TaskDoc>("tasks", taskId, {
|
|
211
|
+
status: "blocked",
|
|
212
|
+
error: checks.summary,
|
|
213
|
+
updated_at: Date.now(),
|
|
214
|
+
} as Partial<TaskDoc>).catch(() => {});
|
|
215
|
+
}
|
|
216
|
+
return {
|
|
217
|
+
ok: false,
|
|
218
|
+
error: checks.summary,
|
|
219
|
+
retryable: false,
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
await recordAgentOutcome(workerId, "helpful");
|
|
224
|
+
emitWorkEvent({
|
|
225
|
+
phase: "review_passed",
|
|
226
|
+
taskRef: delegationRef,
|
|
227
|
+
taskName,
|
|
228
|
+
actorId: parentAgentId || workerId,
|
|
229
|
+
targetId: workerId,
|
|
230
|
+
});
|
|
231
|
+
if (turnId && originThreadId) {
|
|
232
|
+
await publishNarration({
|
|
233
|
+
turnId,
|
|
234
|
+
threadId: originThreadId,
|
|
235
|
+
channel: originChannel,
|
|
236
|
+
userId: originUserId,
|
|
237
|
+
sessionId: originSessionId,
|
|
238
|
+
agentId: workerId,
|
|
239
|
+
agentName: workerName,
|
|
240
|
+
kind: "verified",
|
|
241
|
+
status: "done",
|
|
242
|
+
label: `${workerName} completó “${taskName}”`,
|
|
243
|
+
detail: checks.status === "passed" ? checks.summary : "El coordinador revisa el resultado.",
|
|
244
|
+
dedupeKey: `verified:${taskId ?? job.id}`,
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
|
|
119
248
|
agentBus.notifyTaskCompleted(workerId, workerName, 0, taskName, "", result);
|
|
120
249
|
|
|
121
250
|
// Update TaskDoc → completed
|
|
@@ -129,10 +258,61 @@ const workerTaskExecutor: JobExecutor = async (job, signal) => {
|
|
|
129
258
|
} as Partial<TaskDoc>).catch(() => {});
|
|
130
259
|
}
|
|
131
260
|
|
|
132
|
-
|
|
261
|
+
await buildProofPacket({
|
|
262
|
+
runId,
|
|
263
|
+
agentId: workerId,
|
|
264
|
+
intendedOutcome: taskDescription,
|
|
265
|
+
met: true,
|
|
266
|
+
checksRun: checks.results.length ? checks.results.map((r) => r.check) : ["none"],
|
|
267
|
+
evidence,
|
|
268
|
+
epoch: finishedRun ? deserializeEpoch(finishedRun) : null,
|
|
269
|
+
catalogAgentId: isCatalogAgent ? workerId : null,
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
emitWorkEvent({
|
|
273
|
+
phase: "completed",
|
|
274
|
+
taskRef: delegationRef,
|
|
275
|
+
taskName,
|
|
276
|
+
actorId: workerId,
|
|
277
|
+
targetId: parentAgentId || null,
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
return {
|
|
281
|
+
ok: true,
|
|
282
|
+
result: {
|
|
283
|
+
content: result,
|
|
284
|
+
evidence: execution.toolEvidence,
|
|
285
|
+
acceptance: resolvedAcceptance,
|
|
286
|
+
checks,
|
|
287
|
+
},
|
|
288
|
+
};
|
|
133
289
|
} catch (err) {
|
|
134
290
|
const errorMsg = (err as Error).message;
|
|
135
291
|
agentBus.notifyTaskFailed(workerId, workerName, 0, taskName, "", errorMsg);
|
|
292
|
+
emitWorkEvent({
|
|
293
|
+
phase: signal.aborted ? "aborted" : "failed",
|
|
294
|
+
taskRef: delegationRef,
|
|
295
|
+
taskName,
|
|
296
|
+
actorId: workerId,
|
|
297
|
+
targetId: parentAgentId || null,
|
|
298
|
+
detail: signal.aborted ? "Trabajo interrumpido" : errorMsg,
|
|
299
|
+
});
|
|
300
|
+
if (turnId && originThreadId) {
|
|
301
|
+
await publishNarration({
|
|
302
|
+
turnId,
|
|
303
|
+
threadId: originThreadId,
|
|
304
|
+
channel: originChannel,
|
|
305
|
+
userId: originUserId,
|
|
306
|
+
sessionId: originSessionId,
|
|
307
|
+
agentId: workerId,
|
|
308
|
+
agentName: workerName,
|
|
309
|
+
kind: "failed",
|
|
310
|
+
status: "error",
|
|
311
|
+
label: `${workerName} no pudo completar “${taskName}”`,
|
|
312
|
+
detail: errorMsg,
|
|
313
|
+
dedupeKey: `worker_failed:${taskId ?? job.id}`,
|
|
314
|
+
});
|
|
315
|
+
}
|
|
136
316
|
|
|
137
317
|
// Update TaskDoc → failed
|
|
138
318
|
if (taskId) {
|
|
@@ -144,104 +324,16 @@ const workerTaskExecutor: JobExecutor = async (job, signal) => {
|
|
|
144
324
|
}
|
|
145
325
|
|
|
146
326
|
return { ok: false, error: errorMsg, retryable: isRetryableError(err) };
|
|
147
|
-
}
|
|
148
|
-
};
|
|
149
|
-
|
|
150
|
-
// ─── project_task executor ──────────────────────────────────────────────────
|
|
151
|
-
|
|
152
|
-
const projectTaskExecutor: JobExecutor = async (job, signal) => {
|
|
153
|
-
const payload = JSON.parse(job.payload_json);
|
|
154
|
-
const taskId = payload.taskId as string;
|
|
155
|
-
const workerId = payload.workerId as string;
|
|
156
|
-
const taskDescription = payload.taskDescription as string;
|
|
157
|
-
const runId = job.run_id;
|
|
158
|
-
|
|
159
|
-
log.info(`[project_task] Job ${job.id} → task=${taskId} worker=${workerId}`);
|
|
160
|
-
|
|
161
|
-
// Update TaskDoc → in_progress
|
|
162
|
-
await updateDoc<TaskDoc>("tasks", taskId, {
|
|
163
|
-
status: "in_progress",
|
|
164
|
-
started_at: Date.now(),
|
|
165
|
-
job_id: job.id,
|
|
166
|
-
run_id: runId,
|
|
167
|
-
updated_at: Date.now(),
|
|
168
|
-
} as Partial<TaskDoc>).catch(() => {});
|
|
169
|
-
|
|
170
|
-
try {
|
|
171
|
-
// Resume from the checkpoint on a re-claimed job (payload can't know this)
|
|
172
|
-
const run = runId ? await getRun(runId) : null;
|
|
173
|
-
const resume = !!run?.state_json;
|
|
174
|
-
const threadId = run?.thread_id || `project-${taskId}-${Date.now()}`;
|
|
175
|
-
|
|
176
|
-
const result = await runAgentIsolated({
|
|
177
|
-
agentId: workerId,
|
|
178
|
-
taskDescription,
|
|
179
|
-
threadId,
|
|
180
|
-
mcpManager,
|
|
181
|
-
runId,
|
|
182
|
-
resume,
|
|
183
|
-
durable: !!runId,
|
|
184
|
-
signal,
|
|
185
|
-
});
|
|
186
|
-
|
|
187
|
-
if (signal.aborted) {
|
|
188
|
-
await updateDoc<TaskDoc>("tasks", taskId, {
|
|
189
|
-
status: "pending",
|
|
190
|
-
updated_at: Date.now(),
|
|
191
|
-
} as Partial<TaskDoc>).catch(() => {});
|
|
192
|
-
return { ok: false, error: "Aborted", retryable: false };
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
// Update TaskDoc → completed
|
|
196
|
-
await updateDoc<TaskDoc>("tasks", taskId, {
|
|
197
|
-
status: "completed",
|
|
198
|
-
progress: 100,
|
|
199
|
-
result,
|
|
200
|
-
completed_at: Date.now(),
|
|
201
|
-
updated_at: Date.now(),
|
|
202
|
-
} as Partial<TaskDoc>).catch(() => {});
|
|
203
|
-
|
|
204
|
-
if (runId) {
|
|
205
|
-
const finishedRun = await getRun(runId);
|
|
206
|
-
await buildProofPacket({
|
|
207
|
-
runId,
|
|
208
|
-
agentId: workerId,
|
|
209
|
-
intendedOutcome: taskDescription,
|
|
210
|
-
met: true,
|
|
211
|
-
checksRun: [],
|
|
212
|
-
evidence: [typeof result === "string" ? result : JSON.stringify(result)].filter(Boolean),
|
|
213
|
-
epoch: finishedRun ? deserializeEpoch(finishedRun) : null,
|
|
214
|
-
}).catch(() => {});
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
// Kick the TaskDriver to check for newly-ready tasks
|
|
218
|
-
try {
|
|
219
|
-
const { getTaskDriver } = await import("../scheduler/task-driver");
|
|
220
|
-
await getTaskDriver().kick("project_task:completed");
|
|
221
|
-
} catch { /* non-critical */ }
|
|
222
|
-
|
|
223
|
-
return { ok: true, result };
|
|
224
|
-
} catch (err) {
|
|
225
|
-
const errorMsg = (err as Error).message;
|
|
226
|
-
await updateDoc<TaskDoc>("tasks", taskId, {
|
|
227
|
-
status: "failed",
|
|
228
|
-
error: errorMsg,
|
|
229
|
-
updated_at: Date.now(),
|
|
230
|
-
} as Partial<TaskDoc>).catch(() => {});
|
|
231
|
-
|
|
232
|
-
// Kick the TaskDriver to check for newly-ready tasks (or blocked dependents)
|
|
233
|
-
try {
|
|
234
|
-
const { getTaskDriver } = await import("../scheduler/task-driver");
|
|
235
|
-
await getTaskDriver().kick("project_task:failed");
|
|
236
|
-
} catch { /* non-critical */ }
|
|
237
|
-
|
|
238
|
-
return { ok: false, error: errorMsg, retryable: isRetryableError(err) };
|
|
327
|
+
} finally {
|
|
328
|
+
emitDelegationFinished({ workerId, taskRef: delegationRef });
|
|
329
|
+
await prepared?.release();
|
|
239
330
|
}
|
|
240
331
|
};
|
|
241
332
|
|
|
242
333
|
// ─── goal_run executor ──────────────────────────────────────────────────────
|
|
243
334
|
// Multi-turn orchestration: run a turn → verify the goal → continue with the
|
|
244
|
-
// verifier's feedback until the goal is met or
|
|
335
|
+
// verifier's feedback (verifyGoal, goal-runner.ts) until the goal is met or
|
|
336
|
+
// the budget runs out. The goal
|
|
245
337
|
// AgentRun row (job.run_id) is the orchestrator record: goal_attempts,
|
|
246
338
|
// turns_used and tokens_used accumulate across turns and the budget is HARD.
|
|
247
339
|
// Turns are plain (non-durable) runs on the same thread — a mid-turn crash
|
|
@@ -340,8 +432,9 @@ const goalRunExecutor: JobExecutor = async (job, signal) => {
|
|
|
340
432
|
updated_at: Date.now(),
|
|
341
433
|
} as Partial<AgentRunDoc>).catch(() => {});
|
|
342
434
|
|
|
343
|
-
// Verify: deterministic tool when configured, LLM
|
|
344
|
-
// (
|
|
435
|
+
// Verify: deterministic tool when configured, a single LLM judgment
|
|
436
|
+
// otherwise (one call total, covering every acceptance criterion —
|
|
437
|
+
// see verifyGoal in goal-runner.ts).
|
|
345
438
|
const providerCfg = await resolveGoalProviderCfg(agentId);
|
|
346
439
|
const verdict = await verifyGoal(goal, checkTool, [
|
|
347
440
|
{ role: "user", content: `Meta: ${goal}` },
|
|
@@ -361,7 +454,8 @@ const goalRunExecutor: JobExecutor = async (job, signal) => {
|
|
|
361
454
|
checksRun: acceptance ? acceptance.map((a) => a.checkTool ?? "llm_verifier") : [checkTool ?? "llm_verifier"],
|
|
362
455
|
evidence: [verdict.reason, lastContent].filter(Boolean),
|
|
363
456
|
epoch,
|
|
364
|
-
|
|
457
|
+
catalogAgentId: null,
|
|
458
|
+
});
|
|
365
459
|
return { ok: true, result: { met: true, attempts, reason: verdict.reason, content: lastContent } };
|
|
366
460
|
}
|
|
367
461
|
|
|
@@ -399,8 +493,7 @@ export function initJobExecutors(): void {
|
|
|
399
493
|
if (initialized) return;
|
|
400
494
|
registerExecutor("chat_turn", chatTurnExecutor);
|
|
401
495
|
registerExecutor("worker_task", workerTaskExecutor);
|
|
402
|
-
registerExecutor("project_task", projectTaskExecutor);
|
|
403
496
|
registerExecutor("goal_run", goalRunExecutor);
|
|
404
497
|
initialized = true;
|
|
405
498
|
log.info("[initJobExecutors] All executors registered");
|
|
406
|
-
}
|
|
499
|
+
}
|
|
@@ -19,7 +19,7 @@ export interface LaneQueueOptions {
|
|
|
19
19
|
|
|
20
20
|
type TaskHandler<T> = (task: Task, signal: AbortSignal) => Promise<T>;
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
class LaneQueue {
|
|
23
23
|
private queues: Map<string, Task[]> = new Map();
|
|
24
24
|
private running: Map<string, Task> = new Map();
|
|
25
25
|
private handlers: Map<string, TaskHandler<unknown>> = new Map();
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import type { NotificationDoc } from "../storage/collections";
|
|
3
|
+
import { col, updateDoc } from "../storage/hive";
|
|
4
|
+
|
|
5
|
+
export async function createNotification(input: {
|
|
6
|
+
userId: string;
|
|
7
|
+
channel: string;
|
|
8
|
+
message: string;
|
|
9
|
+
}): Promise<NotificationDoc> {
|
|
10
|
+
const notifications = await col<NotificationDoc>("notifications");
|
|
11
|
+
const id = randomUUID();
|
|
12
|
+
const notification: NotificationDoc = {
|
|
13
|
+
id,
|
|
14
|
+
user_id: input.userId,
|
|
15
|
+
channel: input.channel,
|
|
16
|
+
message: input.message,
|
|
17
|
+
created_at: Date.now(),
|
|
18
|
+
delivered_at: null,
|
|
19
|
+
read_at: null,
|
|
20
|
+
};
|
|
21
|
+
await notifications.put(id, notification, { expectedVersion: 0 });
|
|
22
|
+
return notification;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export async function listPendingNotifications(
|
|
26
|
+
userId: string,
|
|
27
|
+
channel: string,
|
|
28
|
+
): Promise<NotificationDoc[]> {
|
|
29
|
+
const notifications = await col<NotificationDoc>("notifications");
|
|
30
|
+
const rows = await notifications.findBy("user_id", userId);
|
|
31
|
+
return rows
|
|
32
|
+
.map((row) => row.doc)
|
|
33
|
+
.filter((notification) => notification.channel === channel && notification.read_at === null)
|
|
34
|
+
.sort((a, b) => a.created_at - b.created_at);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export async function markNotificationDelivered(id: string, userId: string): Promise<boolean> {
|
|
38
|
+
const notifications = await col<NotificationDoc>("notifications");
|
|
39
|
+
const existing = await notifications.get(id);
|
|
40
|
+
if (!existing || existing.doc.user_id !== userId) return false;
|
|
41
|
+
if (existing.doc.delivered_at !== null) return true;
|
|
42
|
+
await updateDoc<NotificationDoc>("notifications", id, { delivered_at: Date.now() });
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export async function acknowledgeNotification(id: string, userId: string): Promise<boolean> {
|
|
47
|
+
const notifications = await col<NotificationDoc>("notifications");
|
|
48
|
+
const existing = await notifications.get(id);
|
|
49
|
+
if (!existing || existing.doc.user_id !== userId) return false;
|
|
50
|
+
if (existing.doc.read_at !== null) return true;
|
|
51
|
+
const now = Date.now();
|
|
52
|
+
await updateDoc<NotificationDoc>("notifications", id, {
|
|
53
|
+
delivered_at: existing.doc.delivered_at ?? now,
|
|
54
|
+
read_at: now,
|
|
55
|
+
});
|
|
56
|
+
return true;
|
|
57
|
+
}
|