@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,62 @@
|
|
|
1
|
+
// ─── Tool narration map ───────────────────────────────────────────────────────
|
|
2
|
+
// Maps tool name prefixes/exact names to human-readable Spanish narrations.
|
|
3
|
+
// Shown to the user while the agent executes a tool.
|
|
4
|
+
const TOOL_NARRATIONS: Record<string, string> = {
|
|
5
|
+
// Web
|
|
6
|
+
web_search: "Buscando en la web...",
|
|
7
|
+
web_fetch: "Leyendo página web...",
|
|
8
|
+
// Files
|
|
9
|
+
read: "Leyendo archivo...",
|
|
10
|
+
write: "Escribiendo archivo...",
|
|
11
|
+
edit: "Editando archivo...",
|
|
12
|
+
exec: "Ejecutando comando...",
|
|
13
|
+
// Cron
|
|
14
|
+
"cron.create": "Programando tarea...",
|
|
15
|
+
"cron.list": "Consultando tareas programadas...",
|
|
16
|
+
"cron.update": "Actualizando tarea programada...",
|
|
17
|
+
"cron.delete": "Eliminando tarea programada...",
|
|
18
|
+
"cron.pause": "Pausando tarea programada...",
|
|
19
|
+
"cron.resume": "Reanudando tarea programada...",
|
|
20
|
+
"cron.trigger": "Ejecutando tarea ahora...",
|
|
21
|
+
"cron.history": "Consultando historial...",
|
|
22
|
+
// Agents
|
|
23
|
+
agent_create: "Creando agente worker...",
|
|
24
|
+
agent_find: "Buscando agente disponible...",
|
|
25
|
+
agent_archive: "Archivando agente...",
|
|
26
|
+
get_available_models: "Consultando modelos disponibles...",
|
|
27
|
+
task_delegate: "Delegando tarea a un agente...",
|
|
28
|
+
task_list: "Listando tareas en ejecución...",
|
|
29
|
+
task_status: "Consultando estado de la tarea...",
|
|
30
|
+
bus_publish: "Coordinando con otro agente...",
|
|
31
|
+
bus_read: "Leyendo mensajes de los agentes...",
|
|
32
|
+
// Discovery
|
|
33
|
+
search_knowledge: "Buscando capacidades disponibles...",
|
|
34
|
+
// Memory
|
|
35
|
+
save_note: "Guardando nota...",
|
|
36
|
+
memory_write: "Guardando en memoria...",
|
|
37
|
+
memory_read: "Leyendo memoria...",
|
|
38
|
+
memory_search: "Buscando en memoria...",
|
|
39
|
+
memory_delete: "Eliminando de memoria...",
|
|
40
|
+
memory_list: "Listando notas...",
|
|
41
|
+
// Browser
|
|
42
|
+
browser_navigate: "Navegando a la página...",
|
|
43
|
+
browser_click: "Haciendo clic...",
|
|
44
|
+
browser_type: "Escribiendo en la página...",
|
|
45
|
+
browser_screenshot: "Tomando captura de pantalla...",
|
|
46
|
+
browser_extract: "Extrayendo información de la página...",
|
|
47
|
+
// Canvas
|
|
48
|
+
canvas_add_node: "Actualizando canvas...",
|
|
49
|
+
canvas_update: "Actualizando canvas...",
|
|
50
|
+
// Notify
|
|
51
|
+
notify: "Enviando notificación...",
|
|
52
|
+
report_progress: "Reportando progreso...",
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function getNarration(toolName: string): string {
|
|
56
|
+
if (TOOL_NARRATIONS[toolName]) return TOOL_NARRATIONS[toolName]
|
|
57
|
+
// Prefix matching for MCP tools like "github__create_pr" → "Ejecutando github..."
|
|
58
|
+
const prefix = toolName.split("__")[0]
|
|
59
|
+
if (prefix && prefix !== toolName) return `Ejecutando ${prefix}...`
|
|
60
|
+
// Fallback
|
|
61
|
+
return `Ejecutando ${toolName.replace(/_/g, " ")}...`
|
|
62
|
+
}
|
|
@@ -8,10 +8,19 @@
|
|
|
8
8
|
import { logger } from "../utils/logger"
|
|
9
9
|
import { col } from "../storage/hive"
|
|
10
10
|
import type { UserIdentityDoc } from "../storage/collections"
|
|
11
|
+
import {
|
|
12
|
+
createNotification,
|
|
13
|
+
markNotificationDelivered,
|
|
14
|
+
} from "./notification-inbox"
|
|
11
15
|
|
|
12
16
|
const log = logger.child("channel-notify")
|
|
13
17
|
|
|
14
|
-
type SendFn = (
|
|
18
|
+
type SendFn = (
|
|
19
|
+
channel: string,
|
|
20
|
+
sessionId: string,
|
|
21
|
+
message: string,
|
|
22
|
+
metadata?: { notificationId?: string; accountId?: string },
|
|
23
|
+
) => Promise<void>
|
|
15
24
|
|
|
16
25
|
let _sendFn: SendFn | null = null
|
|
17
26
|
|
|
@@ -22,18 +31,22 @@ export function setChannelSendFn(fn: SendFn): void {
|
|
|
22
31
|
}
|
|
23
32
|
|
|
24
33
|
/**
|
|
25
|
-
* Resuelve el sessionId real (chat ID de Telegram, etc.) desde user_identities
|
|
34
|
+
* Resuelve el sessionId real (chat ID de Telegram, etc.) desde user_identities,
|
|
35
|
+
* junto con la cuenta del canal por la que llegó — con varias cuentas del mismo
|
|
36
|
+
* tipo conectadas, la respuesta debe salir por la misma.
|
|
26
37
|
* Necesario porque config.thread_id es el userId interno, no el chat ID externo.
|
|
27
38
|
*/
|
|
28
|
-
async function
|
|
39
|
+
async function resolveSession(userId: string, channel: string): Promise<{ sessionId: string; accountId?: string }> {
|
|
29
40
|
try {
|
|
30
41
|
const identitiesCol = await col<UserIdentityDoc>("userIdentities")
|
|
31
42
|
const identity = await identitiesCol.get(`${userId}:${channel}`)
|
|
32
|
-
if (identity?.doc.channel_user_id)
|
|
43
|
+
if (identity?.doc.channel_user_id) {
|
|
44
|
+
return { sessionId: identity.doc.channel_user_id, accountId: identity.doc.account_id }
|
|
45
|
+
}
|
|
33
46
|
} catch {
|
|
34
47
|
// DB no lista — fallback al userId
|
|
35
48
|
}
|
|
36
|
-
return userId
|
|
49
|
+
return { sessionId: userId }
|
|
37
50
|
}
|
|
38
51
|
|
|
39
52
|
/**
|
|
@@ -44,20 +57,40 @@ export async function sendToUserChannel(
|
|
|
44
57
|
channel: string,
|
|
45
58
|
userId: string,
|
|
46
59
|
message: string
|
|
47
|
-
): Promise<{ ok: boolean; error?: string }> {
|
|
60
|
+
): Promise<{ ok: boolean; queued?: boolean; notificationId?: string; error?: string }> {
|
|
61
|
+
let notificationId: string | undefined
|
|
62
|
+
if (channel === "webchat") {
|
|
63
|
+
try {
|
|
64
|
+
const notification = await createNotification({ userId, channel, message })
|
|
65
|
+
notificationId = notification.id
|
|
66
|
+
} catch (err) {
|
|
67
|
+
const error = `Could not persist WebChat notification: ${(err as Error).message}`
|
|
68
|
+
log.warn(`[channel-notify] ${error}`)
|
|
69
|
+
return { ok: false, error }
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
48
73
|
if (!_sendFn) {
|
|
49
|
-
|
|
74
|
+
if (notificationId) {
|
|
75
|
+
log.info(`[channel-notify] WebChat offline — notification ${notificationId} queued`)
|
|
76
|
+
return { ok: true, queued: true, notificationId }
|
|
77
|
+
}
|
|
78
|
+
log.warn("[channel-notify] No send function registered")
|
|
50
79
|
return { ok: false, error: "Channel send not initialized" }
|
|
51
80
|
}
|
|
52
81
|
|
|
53
|
-
const sessionId = await
|
|
82
|
+
const { sessionId, accountId } = await resolveSession(userId, channel)
|
|
54
83
|
log.info(`[channel-notify] Sending to ${channel}/${sessionId}: ${message.substring(0, 80)}`)
|
|
55
84
|
|
|
56
85
|
try {
|
|
57
|
-
await _sendFn(channel, sessionId, message)
|
|
58
|
-
|
|
86
|
+
await _sendFn(channel, sessionId, message, { notificationId, accountId })
|
|
87
|
+
if (notificationId) await markNotificationDelivered(notificationId, userId)
|
|
88
|
+
return { ok: true, queued: false, notificationId }
|
|
59
89
|
} catch (err) {
|
|
60
90
|
log.warn(`[channel-notify] Failed to send: ${(err as Error).message}`)
|
|
91
|
+
if (notificationId) {
|
|
92
|
+
return { ok: true, queued: true, notificationId }
|
|
93
|
+
}
|
|
61
94
|
return { ok: false, error: (err as Error).message }
|
|
62
95
|
}
|
|
63
96
|
}
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
import { col } from "../storage/hive";
|
|
2
|
+
import type {
|
|
3
|
+
DelegationGroupDoc,
|
|
4
|
+
DelegationGroupOutcome,
|
|
5
|
+
} from "../storage/collections";
|
|
6
|
+
import { logger } from "../utils/logger";
|
|
7
|
+
import { publishNarration } from "../events/narration";
|
|
8
|
+
|
|
9
|
+
const log = logger.child("delegation-groups");
|
|
10
|
+
const MAX_RETRIES = 8;
|
|
11
|
+
|
|
12
|
+
export type DelegationSummaryEnqueuer = (
|
|
13
|
+
group: DelegationGroupDoc,
|
|
14
|
+
content: string,
|
|
15
|
+
idempotencyKey: string,
|
|
16
|
+
) => Promise<{ id: string }>;
|
|
17
|
+
|
|
18
|
+
let summaryEnqueuer: DelegationSummaryEnqueuer | null = null;
|
|
19
|
+
|
|
20
|
+
export function setDelegationSummaryEnqueuer(enqueuer: DelegationSummaryEnqueuer | null): void {
|
|
21
|
+
summaryEnqueuer = enqueuer;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function taskIds(group: DelegationGroupDoc): string[] {
|
|
25
|
+
return JSON.parse(group.task_ids_json || "[]");
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function outcomes(group: DelegationGroupDoc): DelegationGroupOutcome[] {
|
|
29
|
+
return JSON.parse(group.outcomes_json || "[]");
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
async function mutate(
|
|
33
|
+
groupId: string,
|
|
34
|
+
fn: (doc: DelegationGroupDoc) => DelegationGroupDoc,
|
|
35
|
+
): Promise<DelegationGroupDoc> {
|
|
36
|
+
const groups = await col<DelegationGroupDoc>("delegationGroups");
|
|
37
|
+
for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
|
|
38
|
+
const current = await groups.get(groupId);
|
|
39
|
+
if (!current) throw new Error(`Delegation group not found: ${groupId}`);
|
|
40
|
+
const next = fn(current.doc);
|
|
41
|
+
try {
|
|
42
|
+
await groups.put(groupId, next, { expectedVersion: current.version });
|
|
43
|
+
return next;
|
|
44
|
+
} catch {
|
|
45
|
+
// optimistic concurrency conflict
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
throw new Error(`Delegation group contention: ${groupId}`);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export async function registerDelegatedTask(input: {
|
|
52
|
+
turnId: string;
|
|
53
|
+
taskId: string;
|
|
54
|
+
threadId: string;
|
|
55
|
+
channel?: string | null;
|
|
56
|
+
userId?: string | null;
|
|
57
|
+
sessionId?: string | null;
|
|
58
|
+
coordinatorAgentId?: string | null;
|
|
59
|
+
}): Promise<DelegationGroupDoc> {
|
|
60
|
+
const groups = await col<DelegationGroupDoc>("delegationGroups");
|
|
61
|
+
const existing = await groups.get(input.turnId);
|
|
62
|
+
if (!existing) {
|
|
63
|
+
const now = Date.now();
|
|
64
|
+
const created: DelegationGroupDoc = {
|
|
65
|
+
id: input.turnId,
|
|
66
|
+
turn_id: input.turnId,
|
|
67
|
+
thread_id: input.threadId,
|
|
68
|
+
channel: input.channel ?? "",
|
|
69
|
+
user_id: input.userId ?? "",
|
|
70
|
+
session_id: input.sessionId ?? "",
|
|
71
|
+
coordinator_agent_id: input.coordinatorAgentId ?? "",
|
|
72
|
+
status: "open",
|
|
73
|
+
task_ids_json: JSON.stringify([input.taskId]),
|
|
74
|
+
outcomes_json: "[]",
|
|
75
|
+
summary_job_id: null,
|
|
76
|
+
created_at: now,
|
|
77
|
+
sealed_at: null,
|
|
78
|
+
ready_at: null,
|
|
79
|
+
notified_at: null,
|
|
80
|
+
};
|
|
81
|
+
try {
|
|
82
|
+
await groups.put(input.turnId, created, { expectedVersion: 0 });
|
|
83
|
+
return created;
|
|
84
|
+
} catch {
|
|
85
|
+
// Another parallel task created the group; append below.
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return mutate(input.turnId, (group) => {
|
|
90
|
+
if (group.status !== "open") {
|
|
91
|
+
throw new Error(`Delegation group ${input.turnId} is already sealed`);
|
|
92
|
+
}
|
|
93
|
+
const ids = taskIds(group);
|
|
94
|
+
if (!ids.includes(input.taskId)) ids.push(input.taskId);
|
|
95
|
+
return { ...group, task_ids_json: JSON.stringify(ids) };
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export async function getDelegationGroup(turnId: string): Promise<DelegationGroupDoc | null> {
|
|
100
|
+
return (await (await col<DelegationGroupDoc>("delegationGroups")).get(turnId))?.doc ?? null;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function isComplete(group: DelegationGroupDoc): boolean {
|
|
104
|
+
const expected = new Set(taskIds(group));
|
|
105
|
+
const completed = new Set(outcomes(group).map((outcome) => outcome.task_id));
|
|
106
|
+
return expected.size > 0 && [...expected].every((id) => completed.has(id));
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function summarize(value: unknown, maxLen = 800): unknown {
|
|
110
|
+
if (typeof value !== "string") return value;
|
|
111
|
+
return value.length > maxLen ? `${value.slice(0, maxLen)}…` : value;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function summaryPrompt(group: DelegationGroupDoc): string {
|
|
115
|
+
const factual = outcomes(group).map((outcome) => {
|
|
116
|
+
const result = outcome.result as { content?: unknown; acceptance?: unknown; checks?: { status?: string; summary?: string } } | null;
|
|
117
|
+
return {
|
|
118
|
+
task_id: outcome.task_id,
|
|
119
|
+
worker_id: outcome.worker_id,
|
|
120
|
+
task: outcome.task_name,
|
|
121
|
+
ok: outcome.ok,
|
|
122
|
+
content: summarize(result?.content ?? outcome.result),
|
|
123
|
+
acceptance: result?.acceptance ?? null,
|
|
124
|
+
checks: result?.checks ? { status: result.checks.status, summary: summarize(result.checks.summary) } : null,
|
|
125
|
+
error: outcome.error,
|
|
126
|
+
};
|
|
127
|
+
});
|
|
128
|
+
// No manual framing here — persisted with source:"delegation_summary" and
|
|
129
|
+
// framed at serialization time by formatInternalEvent (conversation-store.ts).
|
|
130
|
+
return [
|
|
131
|
+
"Todas las tareas delegadas de este turno alcanzaron estado terminal.",
|
|
132
|
+
"Para cada una, comprobá la entrega contra sus criterios de aceptación (`acceptance`):",
|
|
133
|
+
'- checks.status="passed" → verificado determinísticamente, aceptá.',
|
|
134
|
+
'- checks.status="failed" → NO cumplió (ok=false). No lo reportes como éxito.',
|
|
135
|
+
'- checks.status="unchecked" o ausente → juzgalo vos con el contenido y la evidencia adjunta.',
|
|
136
|
+
"Si una entrega no cumple sus criterios: usá `task_revise` con el task_id y un feedback concreto, o arreglala vos si es trivial y tenés las tools. No inventes trabajo ni evidencia, y no declares éxito para ok=false.",
|
|
137
|
+
"Si todas cumplen, escribí UNA sola respuesta final para el usuario, en lenguaje natural: nunca expongas task_id, worker_id, nombres de tools ni JSON crudo.",
|
|
138
|
+
JSON.stringify(factual),
|
|
139
|
+
].join("\n\n");
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
async function finalizeIfReady(groupId: string): Promise<DelegationGroupDoc> {
|
|
143
|
+
let group = await getDelegationGroup(groupId);
|
|
144
|
+
if (!group || group.status === "open" || group.status === "notified" || !isComplete(group)) {
|
|
145
|
+
return group!;
|
|
146
|
+
}
|
|
147
|
+
if (group.status === "sealed") {
|
|
148
|
+
group = await mutate(groupId, (current) => {
|
|
149
|
+
if (current.status !== "sealed" || !isComplete(current)) return current;
|
|
150
|
+
return { ...current, status: "ready", ready_at: Date.now() };
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
if (group.status !== "ready") return group;
|
|
154
|
+
if (!summaryEnqueuer) {
|
|
155
|
+
log.warn(`Group ${groupId} is ready but no summary enqueuer is registered`);
|
|
156
|
+
return group;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const groups = await col<DelegationGroupDoc>("delegationGroups");
|
|
160
|
+
let claimed = false;
|
|
161
|
+
for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
|
|
162
|
+
const current = await groups.get(groupId);
|
|
163
|
+
if (!current) return group;
|
|
164
|
+
if (current.doc.status !== "ready" || current.doc.summary_job_id !== null) {
|
|
165
|
+
return current.doc;
|
|
166
|
+
}
|
|
167
|
+
try {
|
|
168
|
+
await groups.put(groupId, {
|
|
169
|
+
...current.doc,
|
|
170
|
+
summary_job_id: "__claim__",
|
|
171
|
+
}, { expectedVersion: current.version });
|
|
172
|
+
group = { ...current.doc, summary_job_id: "__claim__" };
|
|
173
|
+
claimed = true;
|
|
174
|
+
break;
|
|
175
|
+
} catch {
|
|
176
|
+
// another terminal hook is racing us
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
if (!claimed) return (await getDelegationGroup(groupId))!;
|
|
180
|
+
|
|
181
|
+
let job: { id: string };
|
|
182
|
+
try {
|
|
183
|
+
job = await summaryEnqueuer(
|
|
184
|
+
group,
|
|
185
|
+
summaryPrompt(group),
|
|
186
|
+
`delegation-summary:${group.id}`,
|
|
187
|
+
);
|
|
188
|
+
} catch (error) {
|
|
189
|
+
await mutate(groupId, (current) => current.summary_job_id === "__claim__"
|
|
190
|
+
? { ...current, summary_job_id: null }
|
|
191
|
+
: current);
|
|
192
|
+
throw error;
|
|
193
|
+
}
|
|
194
|
+
group = await mutate(groupId, (current) => {
|
|
195
|
+
if (current.status === "notified") return current;
|
|
196
|
+
return {
|
|
197
|
+
...current,
|
|
198
|
+
status: "notified",
|
|
199
|
+
summary_job_id: job.id,
|
|
200
|
+
notified_at: Date.now(),
|
|
201
|
+
};
|
|
202
|
+
});
|
|
203
|
+
await publishNarration({
|
|
204
|
+
turnId: group.turn_id,
|
|
205
|
+
threadId: group.thread_id,
|
|
206
|
+
channel: group.channel,
|
|
207
|
+
userId: group.user_id,
|
|
208
|
+
sessionId: group.session_id,
|
|
209
|
+
agentId: group.coordinator_agent_id,
|
|
210
|
+
agentName: "Coordinador",
|
|
211
|
+
kind: "group_ready",
|
|
212
|
+
status: "done",
|
|
213
|
+
label: "Todas las entregas fueron revisadas; el coordinador prepara una única respuesta final",
|
|
214
|
+
dedupeKey: "delegation_group_ready",
|
|
215
|
+
});
|
|
216
|
+
return group;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
export async function sealDelegationGroup(turnId: string): Promise<DelegationGroupDoc | null> {
|
|
220
|
+
const existing = await getDelegationGroup(turnId);
|
|
221
|
+
if (!existing) return null;
|
|
222
|
+
if (existing.status === "open") {
|
|
223
|
+
await mutate(turnId, (group) => group.status === "open"
|
|
224
|
+
? { ...group, status: "sealed", sealed_at: Date.now() }
|
|
225
|
+
: group);
|
|
226
|
+
}
|
|
227
|
+
return finalizeIfReady(turnId);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
export async function recordDelegationOutcome(input: {
|
|
231
|
+
turnId: string;
|
|
232
|
+
taskId: string;
|
|
233
|
+
jobId: string;
|
|
234
|
+
workerId: string;
|
|
235
|
+
taskName: string;
|
|
236
|
+
ok: boolean;
|
|
237
|
+
result?: unknown;
|
|
238
|
+
error?: string | null;
|
|
239
|
+
}): Promise<DelegationGroupDoc | null> {
|
|
240
|
+
const existing = await getDelegationGroup(input.turnId);
|
|
241
|
+
if (!existing) return null;
|
|
242
|
+
await mutate(input.turnId, (group) => {
|
|
243
|
+
const current = outcomes(group);
|
|
244
|
+
if (current.some((outcome) => outcome.task_id === input.taskId)) return group;
|
|
245
|
+
current.push({
|
|
246
|
+
task_id: input.taskId,
|
|
247
|
+
job_id: input.jobId,
|
|
248
|
+
worker_id: input.workerId,
|
|
249
|
+
task_name: input.taskName,
|
|
250
|
+
ok: input.ok,
|
|
251
|
+
result: input.result ?? null,
|
|
252
|
+
error: input.error ?? null,
|
|
253
|
+
finished_at: Date.now(),
|
|
254
|
+
});
|
|
255
|
+
return { ...group, outcomes_json: JSON.stringify(current) };
|
|
256
|
+
});
|
|
257
|
+
return finalizeIfReady(input.turnId);
|
|
258
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* delegation-notify — closes the loop on `task_delegate(mode:"async")`.
|
|
3
|
+
*
|
|
4
|
+
* Before this, an async-delegated worker_task was fire-and-forget: nothing
|
|
5
|
+
* told the user (or the coordinator) when the delegated agent finished. This
|
|
6
|
+
* registers a terminal hook (durable-queue.ts) that, on completion or final
|
|
7
|
+
* failure, enqueues a synthetic chat turn in the ORIGINATING conversation's
|
|
8
|
+
* lane so the coordinator can relay the outcome — reusing the exact delivery
|
|
9
|
+
* path already used for crash-recovered turns (webchat-turn.ts's
|
|
10
|
+
* `sendToUserChannel` fallback when no live socket is attached).
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { logger } from "../utils/logger";
|
|
14
|
+
import { registerTerminalHook, type JobTerminalOutcome } from "./durable-queue";
|
|
15
|
+
import { enqueueChatTurn } from "./webchat-turn";
|
|
16
|
+
import type { JobDoc } from "../storage/collections";
|
|
17
|
+
import {
|
|
18
|
+
recordDelegationOutcome,
|
|
19
|
+
setDelegationSummaryEnqueuer,
|
|
20
|
+
} from "./delegation-groups";
|
|
21
|
+
|
|
22
|
+
const log = logger.child("delegation-notify");
|
|
23
|
+
|
|
24
|
+
interface WorkerTaskPayload {
|
|
25
|
+
originThreadId?: string | null;
|
|
26
|
+
taskName?: string;
|
|
27
|
+
workerId?: string;
|
|
28
|
+
taskId?: string;
|
|
29
|
+
turnId?: string | null;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** Inverts enqueueChatTurn's `thread_id = webchat:${sessionId}` (or raw sessionId for "api") mapping (webchat-turn.ts:438). */
|
|
33
|
+
function deriveSessionId(originThreadId: string): string {
|
|
34
|
+
const prefix = "webchat:";
|
|
35
|
+
return originThreadId.startsWith(prefix) ? originThreadId.slice(prefix.length) : originThreadId;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function summarize(value: unknown, maxLen = 500): string {
|
|
39
|
+
const text = typeof value === "string" ? value : JSON.stringify(value);
|
|
40
|
+
return text.length > maxLen ? `${text.slice(0, maxLen)}…` : text;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
async function notifyWorkerTaskOutcome(job: JobDoc, outcome: JobTerminalOutcome): Promise<void> {
|
|
44
|
+
const payload = JSON.parse(job.payload_json) as WorkerTaskPayload;
|
|
45
|
+
if (payload.turnId && payload.taskId) {
|
|
46
|
+
await recordDelegationOutcome({
|
|
47
|
+
turnId: payload.turnId,
|
|
48
|
+
taskId: payload.taskId,
|
|
49
|
+
jobId: job.id,
|
|
50
|
+
workerId: payload.workerId ?? "",
|
|
51
|
+
taskName: payload.taskName ?? "tarea delegada",
|
|
52
|
+
ok: outcome.ok,
|
|
53
|
+
result: outcome.result,
|
|
54
|
+
error: outcome.error ?? null,
|
|
55
|
+
});
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
if (!payload.originThreadId) return; // sync delegation or no coordinator conversation to report back to
|
|
59
|
+
|
|
60
|
+
const sessionId = deriveSessionId(payload.originThreadId);
|
|
61
|
+
const taskName = payload.taskName || "la tarea delegada";
|
|
62
|
+
|
|
63
|
+
// No manual framing here — persisted with source:"task_complete" and framed
|
|
64
|
+
// at serialization time by formatInternalEvent (conversation-store.ts).
|
|
65
|
+
const content = outcome.ok
|
|
66
|
+
? `El agente completó la tarea "${taskName}". Resultado: ${summarize(outcome.result)}`
|
|
67
|
+
: `El agente NO pudo completar la tarea "${taskName}". Motivo: ${summarize(outcome.error ?? "error desconocido")}`;
|
|
68
|
+
|
|
69
|
+
try {
|
|
70
|
+
await enqueueChatTurn({
|
|
71
|
+
lane: sessionId,
|
|
72
|
+
payload: { source: "task_complete", sessionId, content },
|
|
73
|
+
});
|
|
74
|
+
log.info(`[notifyWorkerTaskOutcome] Enqueued task_complete notice for session ${sessionId} (job ${job.id}, ok=${outcome.ok})`);
|
|
75
|
+
} catch (err) {
|
|
76
|
+
log.warn(`[notifyWorkerTaskOutcome] Failed to enqueue completion notice: ${(err as Error).message}`);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
let initialized = false;
|
|
81
|
+
|
|
82
|
+
export function initDelegationNotify(): void {
|
|
83
|
+
if (initialized) return;
|
|
84
|
+
registerTerminalHook("worker_task", notifyWorkerTaskOutcome);
|
|
85
|
+
setDelegationSummaryEnqueuer(async (group, content, idempotencyKey) => {
|
|
86
|
+
const sessionId = group.session_id || deriveSessionId(group.thread_id);
|
|
87
|
+
return enqueueChatTurn({
|
|
88
|
+
lane: sessionId,
|
|
89
|
+
payload: {
|
|
90
|
+
source: "delegation_summary",
|
|
91
|
+
sessionId,
|
|
92
|
+
content,
|
|
93
|
+
rawContent: content,
|
|
94
|
+
userId: group.user_id,
|
|
95
|
+
agentId: group.coordinator_agent_id,
|
|
96
|
+
channel: group.channel,
|
|
97
|
+
},
|
|
98
|
+
idempotencyKey,
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
initialized = true;
|
|
102
|
+
log.info("[initDelegationNotify] Registered worker_task terminal hook");
|
|
103
|
+
}
|
|
@@ -76,6 +76,32 @@ export function registerExecutor(type: JobType, executor: JobExecutor): void {
|
|
|
76
76
|
log.info(`[registerExecutor] Registered executor for type=${type}`);
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
+
export interface JobTerminalOutcome {
|
|
80
|
+
ok: boolean;
|
|
81
|
+
result?: unknown;
|
|
82
|
+
error?: string;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** Fires exactly once when a job of `type` reaches a terminal state (completed, or failed with no retries left) — never on a retryable failure that gets requeued. */
|
|
86
|
+
export type JobTerminalHook = (job: JobDoc, outcome: JobTerminalOutcome) => void | Promise<void>;
|
|
87
|
+
|
|
88
|
+
const terminalHooks = new Map<JobType, JobTerminalHook>();
|
|
89
|
+
|
|
90
|
+
/** Register a side-effect to run once a job type finishes for good. Kept decoupled from executors so this module doesn't need to import webchat-turn.ts (circular: webchat-turn.ts already imports durable-queue.ts for enqueueChatTurn). */
|
|
91
|
+
export function registerTerminalHook(type: JobType, hook: JobTerminalHook): void {
|
|
92
|
+
terminalHooks.set(type, hook);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
async function runTerminalHook(job: JobDoc, outcome: JobTerminalOutcome): Promise<void> {
|
|
96
|
+
const hook = terminalHooks.get(job.type);
|
|
97
|
+
if (!hook) return;
|
|
98
|
+
try {
|
|
99
|
+
await hook(job, outcome);
|
|
100
|
+
} catch (err) {
|
|
101
|
+
log.warn(`[runTerminalHook] Hook for type=${job.type} failed: ${(err as Error).message}`);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
79
105
|
export class DurableLaneQueue {
|
|
80
106
|
private maxGlobalConcurrency: number;
|
|
81
107
|
private taskTimeoutMs: number;
|
|
@@ -280,14 +306,17 @@ export class DurableLaneQueue {
|
|
|
280
306
|
|
|
281
307
|
if (result.ok) {
|
|
282
308
|
await completeJob(job.id, result.result ?? null, this.bootId);
|
|
309
|
+
await runTerminalHook(job, { ok: true, result: result.result });
|
|
283
310
|
} else {
|
|
284
311
|
const error = result.error ?? "Unknown error";
|
|
285
312
|
// chat_turn is user-facing — never auto-retry a logical failure, the
|
|
286
313
|
// user just sees the error and can re-ask.
|
|
287
314
|
if (job.type !== "chat_turn" && result.retryable !== false) {
|
|
288
|
-
await failJobOrRetry(job.id, error, this.bootId, this.jobRetryPolicy);
|
|
315
|
+
const updated = await failJobOrRetry(job.id, error, this.bootId, this.jobRetryPolicy);
|
|
316
|
+
if (updated?.status === "failed") await runTerminalHook(job, { ok: false, error });
|
|
289
317
|
} else {
|
|
290
318
|
await failJob(job.id, error, this.bootId);
|
|
319
|
+
await runTerminalHook(job, { ok: false, error });
|
|
291
320
|
}
|
|
292
321
|
}
|
|
293
322
|
} catch (err) {
|
|
@@ -296,9 +325,11 @@ export class DurableLaneQueue {
|
|
|
296
325
|
} else {
|
|
297
326
|
const error = (err as Error).message;
|
|
298
327
|
if (job.type !== "chat_turn") {
|
|
299
|
-
await failJobOrRetry(job.id, error, this.bootId, this.jobRetryPolicy);
|
|
328
|
+
const updated = await failJobOrRetry(job.id, error, this.bootId, this.jobRetryPolicy);
|
|
329
|
+
if (updated?.status === "failed") await runTerminalHook(job, { ok: false, error });
|
|
300
330
|
} else {
|
|
301
331
|
await failJob(job.id, error, this.bootId);
|
|
332
|
+
await runTerminalHook(job, { ok: false, error });
|
|
302
333
|
}
|
|
303
334
|
}
|
|
304
335
|
} finally {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { getNarration } from "./narration.ts";
|
|
2
2
|
export { expandPath } from "./path.ts";
|
|
3
3
|
export { CORS_ORIGINS, addCorsHeaders } from "./cors.ts";
|
|
4
|
-
export {
|
|
4
|
+
export { redactConfig } from "./redact.ts";
|
|
@@ -1,57 +1,4 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
export
|
|
5
|
-
// Web
|
|
6
|
-
web_search: "Buscando en la web...",
|
|
7
|
-
web_fetch: "Leyendo página web...",
|
|
8
|
-
// Files
|
|
9
|
-
read: "Leyendo archivo...",
|
|
10
|
-
write: "Escribiendo archivo...",
|
|
11
|
-
edit: "Editando archivo...",
|
|
12
|
-
exec: "Ejecutando comando...",
|
|
13
|
-
// Cron
|
|
14
|
-
"cron.create": "Programando tarea...",
|
|
15
|
-
"cron.list": "Consultando tareas programadas...",
|
|
16
|
-
"cron.update": "Actualizando tarea programada...",
|
|
17
|
-
"cron.delete": "Eliminando tarea programada...",
|
|
18
|
-
"cron.pause": "Pausando tarea programada...",
|
|
19
|
-
"cron.resume": "Reanudando tarea programada...",
|
|
20
|
-
"cron.trigger": "Ejecutando tarea ahora...",
|
|
21
|
-
"cron.history": "Consultando historial...",
|
|
22
|
-
// Agents
|
|
23
|
-
create_agent: "Creando agente worker...",
|
|
24
|
-
find_agent: "Buscando agente disponible...",
|
|
25
|
-
archive_agent: "Archivando agente...",
|
|
26
|
-
// Memory
|
|
27
|
-
save_note: "Guardando nota...",
|
|
28
|
-
memory_write: "Guardando en memoria...",
|
|
29
|
-
memory_read: "Leyendo memoria...",
|
|
30
|
-
memory_search: "Buscando en memoria...",
|
|
31
|
-
memory_delete: "Eliminando de memoria...",
|
|
32
|
-
memory_list: "Listando notas...",
|
|
33
|
-
// Browser
|
|
34
|
-
browser_navigate: "Navegando a la página...",
|
|
35
|
-
browser_click: "Haciendo clic...",
|
|
36
|
-
browser_type: "Escribiendo en la página...",
|
|
37
|
-
browser_screenshot: "Tomando captura de pantalla...",
|
|
38
|
-
browser_extract: "Extrayendo información de la página...",
|
|
39
|
-
// Canvas
|
|
40
|
-
canvas_add_node: "Actualizando canvas...",
|
|
41
|
-
canvas_update: "Actualizando canvas...",
|
|
42
|
-
// Code Bridge
|
|
43
|
-
bridge_send: "Enviando tarea al CLI...",
|
|
44
|
-
bridge_exec: "Ejecutando en el Code Bridge...",
|
|
45
|
-
// Notify
|
|
46
|
-
notify: "Enviando notificación...",
|
|
47
|
-
report_progress: "Reportando progreso...",
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export function getNarration(toolName: string): string {
|
|
51
|
-
if (TOOL_NARRATIONS[toolName]) return TOOL_NARRATIONS[toolName]
|
|
52
|
-
// Prefix matching for MCP tools like "github__create_pr" → "Ejecutando github..."
|
|
53
|
-
const prefix = toolName.split("__")[0]
|
|
54
|
-
if (prefix && prefix !== toolName) return `Ejecutando ${prefix}...`
|
|
55
|
-
// Fallback
|
|
56
|
-
return `Ejecutando ${toolName.replace(/_/g, " ")}...`
|
|
57
|
-
}
|
|
1
|
+
// The tool narration map lives in the narration domain (`events/`) so the agent
|
|
2
|
+
// loop can label its own events without depending on the gateway. Re-exported
|
|
3
|
+
// here to keep the existing `gateway/helpers` import path working.
|
|
4
|
+
export { getNarration } from "../../events/tool-narration.ts";
|
|
@@ -5,7 +5,7 @@ import type { Config } from "../../config/loader.ts";
|
|
|
5
5
|
* @param value - The value to redact
|
|
6
6
|
* @returns The redacted value or a string of bullets if too short
|
|
7
7
|
*/
|
|
8
|
-
|
|
8
|
+
function redactValue(value: string): string {
|
|
9
9
|
if (!value || value.length < 8) return "••••••••";
|
|
10
10
|
return `${value.slice(0, 4)}••••••••`;
|
|
11
11
|
}
|