@johpaz/hive-agents 0.0.47 → 1.0.0
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 +119 -902
- package/dist/hive.js +68840 -68355
- package/dist/tool-worker.js +220 -925
- package/dist/ui/assets/A2UIPage-D4nUFe5q.js +8 -0
- package/dist/ui/assets/AgentCreateForm-g1mQnIoJ.js +1 -0
- package/dist/ui/assets/AgentDetailPage-C3XkU4Ll.js +1 -0
- package/dist/ui/assets/AgentNewPage-CEkLeA79.js +1 -0
- package/dist/ui/assets/AgentsPage-CNA778Eo.js +10 -0
- package/dist/ui/assets/ApiClientPage-t5DpKhmA.js +3 -0
- package/dist/ui/assets/ChannelsPage-yY6t0YTU.js +8 -0
- package/dist/ui/assets/DashboardPage-BSeNSYg5.js +6 -0
- package/dist/ui/assets/{LoginPage-BTxJdFVG.js → LoginPage-eT5zDRDa.js} +1 -1
- package/dist/ui/assets/{LogsPage-DVV2eHbh.js → LogsPage-Gczzzsdh.js} +1 -1
- package/dist/ui/assets/MeetingPage-Bu4aMMNR.js +1 -0
- package/dist/ui/assets/ModelSelector-nNOrW3te.js +1 -0
- package/dist/ui/assets/{NotFound-BIUDlIXU.js → NotFound-Bpr12V51.js} +1 -1
- package/dist/ui/assets/Office3DPage-B_iXEbyv.js +4614 -0
- package/dist/ui/assets/Office3DPage-C3SIzd2H.css +1 -0
- package/dist/ui/assets/ProvidersPage-BupHs5yO.js +1 -0
- package/dist/ui/assets/{RecoverPage-7YDQysBL.js → RecoverPage-DMqSasKk.js} +1 -1
- package/dist/ui/assets/SettingsPage-B6FTSkOn.js +9 -0
- package/dist/ui/assets/SetupPage-DhcRbGgg.js +1 -0
- package/dist/ui/assets/WebChatPage-CWXjW4Hn.js +29 -0
- package/dist/ui/assets/{activity-c3pNngT_.js → activity-CQuPevhB.js} +1 -1
- package/dist/ui/assets/agentCapabilities-CDC6y91E.js +1 -0
- package/dist/ui/assets/alert-CQlRq6sv.js +1 -0
- package/dist/ui/assets/arrow-left-0EBE7nsF.js +1 -0
- package/dist/ui/assets/arrow-right-5QIaph-z.js +1 -0
- package/dist/ui/assets/arrow-up-right-DQQCY007.js +1 -0
- package/dist/ui/assets/badge-DKGZbVZJ.js +1 -0
- package/dist/ui/assets/{calendar-B-KZ9RQO.js → calendar-Be23hQGc.js} +1 -1
- package/dist/ui/assets/{card-CNf6BS2e.js → card-D3Nw3kh3.js} +1 -1
- package/dist/ui/assets/check-Dp6tzwax.js +1 -0
- package/dist/ui/assets/chevron-down-33N886NY.js +1 -0
- package/dist/ui/assets/chevron-left-C6itJXh3.js +1 -0
- package/dist/ui/assets/chevron-right-CFodBS-b.js +1 -0
- package/dist/ui/assets/chevron-up-BvSmyBEs.js +1 -0
- package/dist/ui/assets/{circle-alert-KuAm2FWh.js → circle-alert-BDVHxmAz.js} +1 -1
- package/dist/ui/assets/circle-check-BJWNbLuF.js +1 -0
- package/dist/ui/assets/{circle-x-DjLkFDO8.js → circle-x-Cb2Yer4s.js} +1 -1
- package/dist/ui/assets/{copy-Bu5d7C-0.js → copy-33tZrzc9.js} +1 -1
- package/dist/ui/assets/{dialog-Jk4bieO4.js → dialog-KOZKWbib.js} +1 -1
- package/dist/ui/assets/dist-CD_qfA30.js +1 -0
- package/dist/ui/assets/{download-Cjbk4Rek.js → download-CiQqqXyz.js} +1 -1
- package/dist/ui/assets/earth-DCvN7ynm.js +1 -0
- package/dist/ui/assets/ellipsis-vertical-BybFZDk2.js +1 -0
- package/dist/ui/assets/{external-link-6sTlRDUR.js → external-link-0iNNBvZm.js} +1 -1
- package/dist/ui/assets/{eye-Df8o0tkC.js → eye-C8sKSSkg.js} +1 -1
- package/dist/ui/assets/{file-text-lnxnjBp0.js → file-text-DO8jqiJK.js} +1 -1
- package/dist/ui/assets/{gateway-url-DwzPmoc8.js → gateway-url-BlnabM5e.js} +1 -1
- package/dist/ui/assets/gauge-BRGwuN8G.js +1 -0
- package/dist/ui/assets/{history-CAF_R34_.js → history-BtTD1kDo.js} +1 -1
- package/dist/ui/assets/index-Bejlp-R1.js +116 -0
- package/dist/ui/assets/index-XoTT41Hr.css +2 -0
- package/dist/ui/assets/{info-WjromB4Y.js → info-mpk1tsNC.js} +1 -1
- package/dist/ui/assets/key-CoQ0qtXt.js +1 -0
- package/dist/ui/assets/label-k0jYxoWW.js +1 -0
- package/dist/ui/assets/loader-circle-BhqRN2nO.js +1 -0
- package/dist/ui/assets/lock-open-Cd2aqwOd.js +1 -0
- package/dist/ui/assets/mail-BG0RYSkL.js +1 -0
- package/dist/ui/assets/{pause-VqeUmp2Z.js → pause-Cme88_9s.js} +1 -1
- package/dist/ui/assets/pencil-f1nJ1xhs.js +1 -0
- package/dist/ui/assets/play-CfYDHD6h.js +1 -0
- package/dist/ui/assets/plus-C5BxJeOX.js +1 -0
- package/dist/ui/assets/progress-DrI2UDu-.js +1 -0
- package/dist/ui/assets/radio-B5SpKJ-J.js +1 -0
- package/dist/ui/assets/{refresh-cw-CCzDCAuz.js → refresh-cw-CroGQY62.js} +1 -1
- package/dist/ui/assets/scroll-area-CfHn94Vb.js +1 -0
- package/dist/ui/assets/search-rfBcmohK.js +1 -0
- package/dist/ui/assets/select-BhbW0stK.js +1 -0
- package/dist/ui/assets/{send-BPk9XbIq.js → send-D6whYpw-.js} +1 -1
- package/dist/ui/assets/{settings-BGfrZ_zM.js → settings-BX6q3MGB.js} +1 -1
- package/dist/ui/assets/{shield-CxhcUT39.js → shield-BnGyu1xf.js} +1 -1
- package/dist/ui/assets/slider-CmE_z1Ii.js +1 -0
- package/dist/ui/assets/{sparkles-BhwlS1pc.js → sparkles-BcaOs_Jk.js} +1 -1
- package/dist/ui/assets/{square-DMNWw4Hi.js → square-ju5H8nrT.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-Bjfu-TkS.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-DjQXac_0.js} +1 -1
- package/dist/ui/assets/{triangle-alert-pVIJGjga.js → triangle-alert-B04mgMcg.js} +1 -1
- package/dist/ui/assets/{useHiveAgentsModelLoad-BnC4jLE-.js → useHiveAgentsModelLoad-DT5-4CCj.js} +1 -1
- package/dist/ui/assets/useOfficeModel-Cy7cAyEn.js +1 -0
- package/dist/ui/assets/useProviders-DSX7eVsz.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-qnVxkRSM.js +1 -0
- package/dist/ui/assets/wifi-BA1m2dGO.js +1 -0
- package/dist/ui/assets/{zap-B4RaNNO5.js → zap-DT7cM7YS.js} +1 -1
- package/dist/ui/index.html +10 -9
- package/package.json +8 -9
- 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 +45 -1
- package/packages/cli/src/commands/gateway.ts +2 -9
- package/packages/cli/src/index.ts +9 -11
- package/packages/core/src/agent/acceptance-verifier.ts +300 -0
- package/packages/core/src/agent/agent-catalog.ts +384 -0
- package/packages/core/src/agent/agent-loop.ts +185 -28
- package/packages/core/src/agent/capability-search.ts +5 -5
- package/packages/core/src/agent/catalog-selector.ts +104 -0
- package/packages/core/src/agent/compaction.ts +36 -41
- package/packages/core/src/agent/context-compiler.ts +182 -62
- 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 +248 -0
- package/packages/core/src/agent/index.ts +17 -0
- package/packages/core/src/agent/llm-providers/hiveagents.ts +1 -1
- package/packages/core/src/agent/llm-providers/interface.ts +3 -3
- package/packages/core/src/agent/llm-providers/openai-compat-base.ts +1 -1
- package/packages/core/src/agent/minimal-loadout.ts +46 -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 +15 -1
- package/packages/core/src/agent/providers/index.ts +8 -3
- 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 +36 -35
- 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 +165 -69
- package/packages/core/src/canvas/index.ts +0 -2
- package/packages/core/src/channels/base.ts +3 -1
- package/packages/core/src/channels/webchat.ts +4 -8
- package/packages/core/src/config/loader.ts +0 -22
- package/packages/core/src/events/agent-bus.ts +0 -31
- package/packages/core/src/events/narration.ts +82 -0
- package/packages/core/src/gateway/channel-notify.ts +34 -5
- package/packages/core/src/gateway/delegation-groups.ts +245 -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 +12 -7
- package/packages/core/src/gateway/helpers/redact.ts +1 -1
- package/packages/core/src/gateway/initializer.ts +15 -13
- package/packages/core/src/gateway/job-executors.ts +232 -101
- 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 +1 -23
- 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/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/providers.ts +1 -0
- package/packages/core/src/gateway/routes/setup.ts +29 -24
- package/packages/core/src/gateway/routes/skills.ts +2 -2
- package/packages/core/src/gateway/routes/system.ts +23 -5
- package/packages/core/src/gateway/routes/users.ts +24 -1
- package/packages/core/src/gateway/server.ts +153 -117
- 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 +34 -8
- 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 +25 -5
- package/packages/core/src/storage/collections.ts +201 -27
- package/packages/core/src/storage/onboarding.ts +147 -32
- package/packages/core/src/storage/reconcile.ts +2 -5
- package/packages/core/src/storage/seed.ts +196 -34
- package/packages/core/src/storage/usage.ts +0 -9
- 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 +392 -83
- 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 +17 -45
- 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-screenshot.ts +26 -5
- package/packages/core/src/tools/web/index.ts +3 -0
- package/packages/core/src/utils/logger.ts +58 -30
- package/packages/core/src/utils/toon.ts +0 -20
- 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/acceptance_verification/SKILL.md +26 -0
- package/packages/skills/src/bundled/agents/agent_spawner/SKILL.md +24 -18
- package/packages/skills/src/bundled/agents/task_orchestrator/SKILL.md +47 -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 +690 -1255
- 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
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
import type { Tool } from "../types.ts";
|
|
8
8
|
import { col } from "../../storage/hive.ts";
|
|
9
|
-
import type { ToolDoc, SkillDoc, PlaybookDoc, McpToolDoc, TaskDoc } from "../../storage/collections.ts";
|
|
9
|
+
import type { ToolDoc, SkillDoc, PlaybookDoc, McpToolDoc, TaskDoc, AgentDoc } from "../../storage/collections.ts";
|
|
10
10
|
import { logger } from "../../utils/logger.ts";
|
|
11
11
|
import {
|
|
12
12
|
searchCapabilities,
|
|
@@ -138,7 +138,7 @@ function translateQueryToEnglish(query: string): string {
|
|
|
138
138
|
|
|
139
139
|
export const searchKnowledgeTool: Tool = {
|
|
140
140
|
name: "search_knowledge",
|
|
141
|
-
description: "Busca en TODO el conocimiento de Hive
|
|
141
|
+
description: "Busca en TODO el conocimiento de Hive: tools nativas, MCP, skills, agentes de catálogo y playbook.",
|
|
142
142
|
parameters: {
|
|
143
143
|
type: "object",
|
|
144
144
|
properties: {
|
|
@@ -148,7 +148,7 @@ export const searchKnowledgeTool: Tool = {
|
|
|
148
148
|
},
|
|
149
149
|
type: {
|
|
150
150
|
type: "string",
|
|
151
|
-
enum: ["all", "tools", "skills", "playbook", "mcp"],
|
|
151
|
+
enum: ["all", "tools", "skills", "playbook", "mcp", "agents"],
|
|
152
152
|
description: "Opcional. Por defecto 'all' (busca en todo). Usa 'mcp' para filtrar solo herramientas externas, 'tools' para solo nativas.",
|
|
153
153
|
},
|
|
154
154
|
limit: {
|
|
@@ -171,20 +171,21 @@ export const searchKnowledgeTool: Tool = {
|
|
|
171
171
|
skills: ["skill"],
|
|
172
172
|
playbook: ["playbook"],
|
|
173
173
|
mcp: ["mcp"],
|
|
174
|
+
agents: ["agent"],
|
|
174
175
|
};
|
|
175
176
|
const types = typeMap[type] ?? undefined;
|
|
176
177
|
|
|
177
178
|
try {
|
|
178
179
|
if (!query) {
|
|
179
180
|
log.info(`[search_knowledge] Empty query — returning empty results`)
|
|
180
|
-
return { query, type, tools: [], skills: [], playbook: [], toolsmcp: [] }
|
|
181
|
+
return { query, type, tools: [], skills: [], playbook: [], toolsmcp: [], agents: [] }
|
|
181
182
|
}
|
|
182
183
|
// HiveDB parses raw text leniently (accents, quotes, operators are all
|
|
183
184
|
// safe), so the query goes in as-is — only underscores become spaces so
|
|
184
185
|
// tool ids like "send_email" match their tokens.
|
|
185
186
|
const normalizedQuery = query.replace(/_/g, " ").trim();
|
|
186
187
|
|
|
187
|
-
const result: any = { query, type, tools: [], skills: [], playbook: [], toolsmcp: [] };
|
|
188
|
+
const result: any = { query, type, tools: [], skills: [], playbook: [], toolsmcp: [], agents: [] };
|
|
188
189
|
|
|
189
190
|
// ─── Hydration from HiveDB collections (index stores only ids + search text) ──
|
|
190
191
|
|
|
@@ -194,6 +195,7 @@ export const searchKnowledgeTool: Tool = {
|
|
|
194
195
|
const skillsCol = await col<SkillDoc>("skills");
|
|
195
196
|
const playbookCol = await col<PlaybookDoc>("playbook");
|
|
196
197
|
const mcpToolsCol = await col<McpToolDoc>("mcpTools");
|
|
198
|
+
const agentsCol = await col<AgentDoc>("agents");
|
|
197
199
|
|
|
198
200
|
async function hydrateTool(hit: CapabilityHit): Promise<any | null> {
|
|
199
201
|
const entry = await toolsCol.get(hit.rawId);
|
|
@@ -243,12 +245,26 @@ export const searchKnowledgeTool: Tool = {
|
|
|
243
245
|
const t = entry?.doc;
|
|
244
246
|
if (!t || !t.active) return null;
|
|
245
247
|
return {
|
|
246
|
-
id: t.id, full_name: t.id, server_name: t.server_name, tool_name: t.tool_name,
|
|
248
|
+
id: t.id, full_name: t.id, server_id: t.server_id, server_name: t.server_name, tool_name: t.tool_name,
|
|
247
249
|
description: t.description, category: t.category,
|
|
248
250
|
active: t.active, rank: hit.score,
|
|
249
251
|
};
|
|
250
252
|
}
|
|
251
253
|
|
|
254
|
+
async function hydrateAgent(hit: CapabilityHit): Promise<any | null> {
|
|
255
|
+
const entry = await agentsCol.get(hit.rawId);
|
|
256
|
+
const agent = entry?.doc;
|
|
257
|
+
if (!agent || agent.source !== "catalog" || !agent.enabled) return null;
|
|
258
|
+
return {
|
|
259
|
+
id: agent.id,
|
|
260
|
+
name: agent.name,
|
|
261
|
+
description: agent.description,
|
|
262
|
+
default_acceptance: agent.default_acceptance_json ? JSON.parse(agent.default_acceptance_json) : [],
|
|
263
|
+
active: agent.enabled,
|
|
264
|
+
rank: hit.score,
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
|
|
252
268
|
const seenIds = new Set<string>();
|
|
253
269
|
|
|
254
270
|
async function mergeHits(hits: CapabilityHit[]): Promise<number> {
|
|
@@ -270,6 +286,9 @@ export const searchKnowledgeTool: Tool = {
|
|
|
270
286
|
case "mcp":
|
|
271
287
|
if (result.toolsmcp.length < limit) { entry = await hydrateMcp(hit); bucket = result.toolsmcp; }
|
|
272
288
|
break;
|
|
289
|
+
case "agent":
|
|
290
|
+
if (result.agents.length < limit) { entry = await hydrateAgent(hit); bucket = result.agents; }
|
|
291
|
+
break;
|
|
273
292
|
}
|
|
274
293
|
if (entry && bucket) {
|
|
275
294
|
bucket.push(entry);
|
|
@@ -281,8 +300,7 @@ export const searchKnowledgeTool: Tool = {
|
|
|
281
300
|
}
|
|
282
301
|
|
|
283
302
|
// ─── Pass 1: Search with original query ─────────────────────────
|
|
284
|
-
// `rank` is the raw BM25 score: positive, higher = more relevant
|
|
285
|
-
// (the old FTS5 rank was negative, lower = better).
|
|
303
|
+
// `rank` is the raw BM25 score: positive, higher = more relevant.
|
|
286
304
|
|
|
287
305
|
const hits1 = await searchCapabilities(normalizedQuery, { types, k: limit * 4 });
|
|
288
306
|
const totalFirst = await mergeHits(hits1);
|
|
@@ -300,7 +318,7 @@ export const searchKnowledgeTool: Tool = {
|
|
|
300
318
|
}
|
|
301
319
|
}
|
|
302
320
|
|
|
303
|
-
result.totalResults = result.tools.length + result.skills.length + result.playbook.length + result.toolsmcp.length;
|
|
321
|
+
result.totalResults = result.tools.length + result.skills.length + result.playbook.length + result.toolsmcp.length + result.agents.length;
|
|
304
322
|
|
|
305
323
|
return { ok: true, ...result };
|
|
306
324
|
} catch (error) {
|
|
@@ -439,4 +457,4 @@ export const reportProgressTool: Tool = {
|
|
|
439
457
|
|
|
440
458
|
export function createTools(): Tool[] {
|
|
441
459
|
return [searchKnowledgeTool, notifyTool, saveNoteTool, reportProgressTool];
|
|
442
|
-
}
|
|
460
|
+
}
|
|
@@ -100,7 +100,7 @@ export async function resolveBestChannel(userId: string, explicitChannel?: strin
|
|
|
100
100
|
|
|
101
101
|
export const cronCreateTool: Tool = {
|
|
102
102
|
name: "cron.create",
|
|
103
|
-
description: "Create a
|
|
103
|
+
description: "Create a Hive scheduled automation: a recurring cron job or one-shot future execution. Spanish: crear automatización programada, programar tarea recurrente, ejecutar después, programar reporte",
|
|
104
104
|
parameters: {
|
|
105
105
|
type: "object",
|
|
106
106
|
properties: {
|
|
@@ -621,8 +621,3 @@ export function createTools(): Tool[] {
|
|
|
621
621
|
cronHistoryTool,
|
|
622
622
|
];
|
|
623
623
|
}
|
|
624
|
-
|
|
625
|
-
/**
|
|
626
|
-
* Alias for backward compatibility
|
|
627
|
-
*/
|
|
628
|
-
export const createCronTools = createTools;
|
|
@@ -11,10 +11,10 @@ import type { Config } from "../config/loader.ts";
|
|
|
11
11
|
// Filesystem (7)
|
|
12
12
|
import * as filesystem from "./filesystem/index.ts";
|
|
13
13
|
|
|
14
|
-
// Web (
|
|
14
|
+
// Web (10)
|
|
15
15
|
import * as web from "./web/index.ts";
|
|
16
16
|
|
|
17
|
-
// Cron (
|
|
17
|
+
// Cron (8) - Croner-based scheduler tools
|
|
18
18
|
import * as cron from "./cron/index.ts";
|
|
19
19
|
|
|
20
20
|
// CLI (1)
|
|
@@ -23,11 +23,8 @@ import * as cli from "./cli/index.ts";
|
|
|
23
23
|
// Agents (14)
|
|
24
24
|
import * as agents from "./agents/index.ts";
|
|
25
25
|
|
|
26
|
-
//
|
|
27
|
-
import * as
|
|
28
|
-
|
|
29
|
-
// Voice (2)
|
|
30
|
-
import * as voice from "./voice/index.ts";
|
|
26
|
+
// A2UI (4)
|
|
27
|
+
import * as a2ui from "./a2ui/index.ts";
|
|
31
28
|
|
|
32
29
|
// Core (4)
|
|
33
30
|
import * as core from "./core/index.ts";
|
|
@@ -35,15 +32,9 @@ import * as core from "./core/index.ts";
|
|
|
35
32
|
// Office (8)
|
|
36
33
|
import * as office from "./office/index.ts";
|
|
37
34
|
|
|
38
|
-
// Meeting (4)
|
|
39
|
-
import * as meeting from "./meeting/index.ts";
|
|
40
|
-
|
|
41
35
|
// API (1) - HTTP client for REST APIs
|
|
42
36
|
import * as api from "./api/index.ts";
|
|
43
37
|
|
|
44
|
-
// Projects (3) - project/task management
|
|
45
|
-
import * as projects from "./projects/index.ts";
|
|
46
|
-
|
|
47
38
|
/**
|
|
48
39
|
* Creates all tools with proper configuration
|
|
49
40
|
*/
|
|
@@ -52,10 +43,10 @@ export function createAllTools(config: Config): Tool[] {
|
|
|
52
43
|
// FILESYSTEM (7)
|
|
53
44
|
...filesystem.createTools(),
|
|
54
45
|
|
|
55
|
-
// WEB (
|
|
46
|
+
// WEB (10)
|
|
56
47
|
...web.createTools(),
|
|
57
48
|
|
|
58
|
-
// CRON (
|
|
49
|
+
// CRON (8)
|
|
59
50
|
...cron.createTools(),
|
|
60
51
|
|
|
61
52
|
// CLI (1)
|
|
@@ -64,11 +55,8 @@ export function createAllTools(config: Config): Tool[] {
|
|
|
64
55
|
// AGENTS (14)
|
|
65
56
|
...agents.createTools(),
|
|
66
57
|
|
|
67
|
-
//
|
|
68
|
-
...
|
|
69
|
-
|
|
70
|
-
// VOICE (2)
|
|
71
|
-
...voice.createTools(),
|
|
58
|
+
// A2UI (4)
|
|
59
|
+
...a2ui.createTools(config),
|
|
72
60
|
|
|
73
61
|
// CORE (4)
|
|
74
62
|
...core.createTools(),
|
|
@@ -76,14 +64,9 @@ export function createAllTools(config: Config): Tool[] {
|
|
|
76
64
|
// OFFICE (8)
|
|
77
65
|
...office.createTools(),
|
|
78
66
|
|
|
79
|
-
// MEETING (4)
|
|
80
|
-
...meeting.createTools(),
|
|
81
|
-
|
|
82
67
|
// API (1)
|
|
83
68
|
...api.createTools(),
|
|
84
69
|
|
|
85
|
-
// PROJECTS (3)
|
|
86
|
-
...projects.createProjectTools(),
|
|
87
70
|
];
|
|
88
71
|
}
|
|
89
72
|
|
|
@@ -102,16 +85,12 @@ export function createToolsByCategory(category: string, config: Config): Tool[]
|
|
|
102
85
|
return cli.createTools();
|
|
103
86
|
case "agents":
|
|
104
87
|
return agents.createTools();
|
|
105
|
-
case "
|
|
106
|
-
return
|
|
107
|
-
case "voice":
|
|
108
|
-
return voice.createTools();
|
|
88
|
+
case "a2ui":
|
|
89
|
+
return a2ui.createTools(config);
|
|
109
90
|
case "core":
|
|
110
91
|
return core.createTools();
|
|
111
92
|
case "office":
|
|
112
93
|
return office.createTools();
|
|
113
|
-
case "meeting":
|
|
114
|
-
return meeting.createTools();
|
|
115
94
|
case "api":
|
|
116
95
|
return api.createTools();
|
|
117
96
|
default:
|
|
@@ -144,6 +123,7 @@ export {
|
|
|
144
123
|
browserExtractTool,
|
|
145
124
|
browserScriptTool,
|
|
146
125
|
browserWaitTool,
|
|
126
|
+
artifactInspectTool,
|
|
147
127
|
} from "./web/index.ts";
|
|
148
128
|
|
|
149
129
|
export {
|
|
@@ -171,26 +151,18 @@ export {
|
|
|
171
151
|
agentFindTool,
|
|
172
152
|
agentArchiveTool,
|
|
173
153
|
taskDelegateTool,
|
|
174
|
-
|
|
154
|
+
taskListTool,
|
|
175
155
|
taskStatusTool,
|
|
176
156
|
busPublishTool,
|
|
177
157
|
busReadTool,
|
|
178
158
|
} from "./agents/index.ts";
|
|
179
159
|
|
|
180
160
|
export {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
canvasShowListTool,
|
|
187
|
-
canvasClearTool,
|
|
188
|
-
} from "./canvas/index.ts";
|
|
189
|
-
|
|
190
|
-
export {
|
|
191
|
-
voiceTranscribeTool,
|
|
192
|
-
voiceSpeakTool,
|
|
193
|
-
} from "./voice/index.ts";
|
|
161
|
+
createA2UISurfaceTool,
|
|
162
|
+
createA2UIUpdateComponentsTool,
|
|
163
|
+
createA2UIUpdateDataModelTool,
|
|
164
|
+
createA2UIDeleteSurfaceTool,
|
|
165
|
+
} from "./a2ui/index.ts";
|
|
194
166
|
|
|
195
167
|
export {
|
|
196
168
|
searchKnowledgeTool,
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Tool } from "../types";
|
|
2
|
+
import { inspectArtifact } from "../../artifacts/store";
|
|
3
|
+
|
|
4
|
+
export const artifactInspectTool: Tool = {
|
|
5
|
+
name: "artifact_inspect",
|
|
6
|
+
description: "Inspect managed artifact metadata, integrity, MIME type and dimensions without returning or modifying its binary content.",
|
|
7
|
+
parameters: {
|
|
8
|
+
type: "object",
|
|
9
|
+
properties: {
|
|
10
|
+
artifactId: {
|
|
11
|
+
type: "string",
|
|
12
|
+
description: "Managed artifact identifier returned by a Hive tool.",
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
required: ["artifactId"],
|
|
16
|
+
},
|
|
17
|
+
execute: async (params, config) => {
|
|
18
|
+
const artifactId = String(params.artifactId ?? "").trim();
|
|
19
|
+
if (!artifactId) return { ok: false, error: "artifactId is required" };
|
|
20
|
+
const userId = config?.configurable?.user_id as string | undefined;
|
|
21
|
+
return inspectArtifact(artifactId, { userId });
|
|
22
|
+
},
|
|
23
|
+
};
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
import type { Tool } from "../types.ts";
|
|
10
10
|
import { logger } from "../../utils/logger.ts";
|
|
11
11
|
import { getBrowserService, screenshotElement } from "./browser-service.ts";
|
|
12
|
+
import { createArtifact } from "../../artifacts/store.ts";
|
|
12
13
|
|
|
13
14
|
const log = logger.child("browser-screenshot");
|
|
14
15
|
|
|
@@ -53,7 +54,7 @@ export const browserScreenshotTool: Tool = {
|
|
|
53
54
|
},
|
|
54
55
|
required: [],
|
|
55
56
|
},
|
|
56
|
-
execute: async (params: Record<string, unknown
|
|
57
|
+
execute: async (params: Record<string, unknown>, config?: any) => {
|
|
57
58
|
const url = params.url as string | undefined;
|
|
58
59
|
const fullPage = (params.fullPage as boolean) ?? false;
|
|
59
60
|
const selector = params.selector as string | undefined;
|
|
@@ -99,14 +100,34 @@ export const browserScreenshotTool: Tool = {
|
|
|
99
100
|
}
|
|
100
101
|
|
|
101
102
|
const currentUrl = view.url;
|
|
102
|
-
|
|
103
|
+
const bytes = Buffer.from(screenshot, "base64");
|
|
104
|
+
const effectiveFormat = selector ? "png" : format;
|
|
105
|
+
const mimeType = effectiveFormat === "png" ? "image/png" : "image/jpeg";
|
|
106
|
+
const configurable = config?.configurable ?? {};
|
|
107
|
+
const artifact = await createArtifact({
|
|
108
|
+
bytes,
|
|
109
|
+
mimeType,
|
|
110
|
+
kind: "browser_screenshot",
|
|
111
|
+
userId: String(configurable.user_id ?? ""),
|
|
112
|
+
runId: configurable.run_id ? String(configurable.run_id) : null,
|
|
113
|
+
taskId: configurable.task_id ? String(configurable.task_id) : null,
|
|
114
|
+
rootDir: configurable.artifact_dir ? String(configurable.artifact_dir) : undefined,
|
|
115
|
+
width,
|
|
116
|
+
height,
|
|
117
|
+
});
|
|
118
|
+
log.info(`Screenshot stored as artifact ${artifact.id} (${artifact.size} bytes, ${mimeType})`);
|
|
103
119
|
|
|
104
120
|
return {
|
|
105
121
|
ok: true,
|
|
106
122
|
url: currentUrl,
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
123
|
+
artifact_id: artifact.id,
|
|
124
|
+
kind: artifact.kind,
|
|
125
|
+
mime_type: artifact.mime_type,
|
|
126
|
+
size: artifact.size,
|
|
127
|
+
sha256: artifact.sha256,
|
|
128
|
+
status: artifact.status,
|
|
129
|
+
expires_at: artifact.expires_at,
|
|
130
|
+
format: effectiveFormat,
|
|
110
131
|
fullPage,
|
|
111
132
|
selector,
|
|
112
133
|
viewport: { width, height },
|
|
@@ -14,6 +14,7 @@ import { browserTypeTool } from "./browser-type.ts";
|
|
|
14
14
|
import { browserExtractTool } from "./browser-extract.ts";
|
|
15
15
|
import { browserScriptTool } from "./browser-script.ts";
|
|
16
16
|
import { browserWaitTool } from "./browser-wait.ts";
|
|
17
|
+
import { artifactInspectTool } from "./artifact-inspect.ts";
|
|
17
18
|
|
|
18
19
|
export function createTools(): Tool[] {
|
|
19
20
|
return [
|
|
@@ -26,6 +27,7 @@ export function createTools(): Tool[] {
|
|
|
26
27
|
browserExtractTool,
|
|
27
28
|
browserScriptTool,
|
|
28
29
|
browserWaitTool,
|
|
30
|
+
artifactInspectTool,
|
|
29
31
|
];
|
|
30
32
|
}
|
|
31
33
|
|
|
@@ -39,3 +41,4 @@ export * from "./browser-extract.ts";
|
|
|
39
41
|
export * from "./browser-script.ts";
|
|
40
42
|
export * from "./browser-wait.ts";
|
|
41
43
|
export * from "./browser-service.ts";
|
|
44
|
+
export * from "./artifact-inspect.ts";
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
appendFileSync,
|
|
3
|
+
mkdirSync,
|
|
4
|
+
unlinkSync,
|
|
5
|
+
renameSync,
|
|
6
|
+
existsSync,
|
|
7
|
+
statSync,
|
|
8
|
+
} from "node:fs";
|
|
2
9
|
import * as path from "node:path";
|
|
3
10
|
import { homedir } from "node:os";
|
|
4
11
|
import { getHiveDir, loadConfig } from "../config/loader.ts";
|
|
@@ -70,6 +77,18 @@ const SENSITIVE_PATTERNS = [
|
|
|
70
77
|
/auth/i,
|
|
71
78
|
];
|
|
72
79
|
|
|
80
|
+
const BINARY_FIELD_PATTERNS = [
|
|
81
|
+
/base64/i,
|
|
82
|
+
/screenshot/i,
|
|
83
|
+
/image[_-]?data/i,
|
|
84
|
+
/audio[_-]?data/i,
|
|
85
|
+
/binary/i,
|
|
86
|
+
/bytes/i,
|
|
87
|
+
];
|
|
88
|
+
|
|
89
|
+
const DATA_URI_PATTERN = /data:[a-z0-9.+-]+\/[a-z0-9.+-]+;base64,[a-z0-9+/=\s]+/gi;
|
|
90
|
+
const LONG_BASE64_PATTERN = /(?:[A-Za-z0-9+/]{80,}={0,2})/g;
|
|
91
|
+
|
|
73
92
|
const COLORS = {
|
|
74
93
|
debug: "\x1b[36m",
|
|
75
94
|
info: "\x1b[32m",
|
|
@@ -87,7 +106,14 @@ function expandPath(p: string): string {
|
|
|
87
106
|
return p;
|
|
88
107
|
}
|
|
89
108
|
|
|
109
|
+
function sanitizeString(value: string): string {
|
|
110
|
+
return value
|
|
111
|
+
.replace(DATA_URI_PATTERN, "[REDACTED_BINARY]")
|
|
112
|
+
.replace(LONG_BASE64_PATTERN, "[REDACTED_BINARY]");
|
|
113
|
+
}
|
|
114
|
+
|
|
90
115
|
function redact(obj: unknown, seen: WeakSet<object> = new WeakSet()): unknown {
|
|
116
|
+
if (typeof obj === "string") return sanitizeString(obj);
|
|
91
117
|
if (obj === null || typeof obj !== "object") {
|
|
92
118
|
return obj;
|
|
93
119
|
}
|
|
@@ -104,13 +130,13 @@ function redact(obj: unknown, seen: WeakSet<object> = new WeakSet()): unknown {
|
|
|
104
130
|
|
|
105
131
|
const result: Record<string, unknown> = {};
|
|
106
132
|
for (const [key, value] of Object.entries(obj as Record<string, unknown>)) {
|
|
107
|
-
const isSensitive = SENSITIVE_PATTERNS.some((p) => p.test(key));
|
|
133
|
+
const isSensitive = [...SENSITIVE_PATTERNS, ...BINARY_FIELD_PATTERNS].some((p) => p.test(key));
|
|
108
134
|
if (isSensitive) {
|
|
109
135
|
result[key] = "[REDACTED]";
|
|
110
136
|
} else if (typeof value === "object" && value !== null) {
|
|
111
137
|
result[key] = redact(value, seen);
|
|
112
138
|
} else {
|
|
113
|
-
result[key] = value;
|
|
139
|
+
result[key] = typeof value === "string" ? sanitizeString(value) : value;
|
|
114
140
|
}
|
|
115
141
|
}
|
|
116
142
|
return result;
|
|
@@ -171,8 +197,7 @@ export class Logger {
|
|
|
171
197
|
|
|
172
198
|
this.logFile = path.join(logDir, `hive-${new Date().toISOString().split("T")[0]}.log`);
|
|
173
199
|
|
|
174
|
-
|
|
175
|
-
this.currentSize = file.size ?? 0;
|
|
200
|
+
this.currentSize = existsSync(this.logFile) ? statSync(this.logFile).size : 0;
|
|
176
201
|
} catch {
|
|
177
202
|
this.logFile = null;
|
|
178
203
|
}
|
|
@@ -182,14 +207,12 @@ export class Logger {
|
|
|
182
207
|
return LOG_LEVELS[level] >= LOG_LEVELS[this.config.level];
|
|
183
208
|
}
|
|
184
209
|
|
|
185
|
-
private writeToConsole(level: LogLevel, message: string,
|
|
210
|
+
private writeToConsole(level: LogLevel, message: string, mergedMeta?: unknown): void {
|
|
186
211
|
if (!this.config.console) return;
|
|
187
212
|
|
|
188
213
|
const color = COLORS[level];
|
|
189
|
-
const
|
|
190
|
-
|
|
191
|
-
const metaStr = displayMeta && Object.keys(displayMeta as object).length > 0
|
|
192
|
-
? ` ${JSON.stringify(displayMeta)}`
|
|
214
|
+
const metaStr = mergedMeta && Object.keys(mergedMeta as object).length > 0
|
|
215
|
+
? ` ${JSON.stringify(mergedMeta)}`
|
|
193
216
|
: "";
|
|
194
217
|
|
|
195
218
|
const prefix = `${COLORS.dim}${formatTimestamp()}${COLORS.reset}`;
|
|
@@ -227,10 +250,7 @@ export class Logger {
|
|
|
227
250
|
this.rotateLogs();
|
|
228
251
|
}
|
|
229
252
|
|
|
230
|
-
|
|
231
|
-
const encoder = new TextEncoder();
|
|
232
|
-
const data = encoder.encode(line);
|
|
233
|
-
Bun.write(this.logFile, data).catch(() => { });
|
|
253
|
+
appendFileSync(this.logFile, line, "utf8");
|
|
234
254
|
this.currentSize += bytes;
|
|
235
255
|
} catch {
|
|
236
256
|
// Silently fail if we can't write to log file
|
|
@@ -270,38 +290,46 @@ export class Logger {
|
|
|
270
290
|
|
|
271
291
|
debug(message: string, meta?: unknown): void {
|
|
272
292
|
if (!this.shouldLog("debug")) return;
|
|
273
|
-
const
|
|
274
|
-
const
|
|
275
|
-
this.
|
|
293
|
+
const safeMessage = this.config.redactSensitive ? sanitizeString(message) : message;
|
|
294
|
+
const rawMeta = this.mergeMeta(meta);
|
|
295
|
+
const mergedMeta = this.config.redactSensitive && rawMeta ? redact(rawMeta) : rawMeta;
|
|
296
|
+
const formatted = formatMessage("debug", safeMessage, mergedMeta, this.correlationContext.correlationId);
|
|
297
|
+
this.writeToConsole("debug", safeMessage, mergedMeta);
|
|
276
298
|
this.writeToFile(formatted);
|
|
277
|
-
emitLogEntry({ timestamp: formatTimestamp(), level: "debug", source: "core", message, meta: mergedMeta as Record<string, unknown> | undefined });
|
|
299
|
+
emitLogEntry({ timestamp: formatTimestamp(), level: "debug", source: "core", message: safeMessage, meta: mergedMeta as Record<string, unknown> | undefined });
|
|
278
300
|
}
|
|
279
301
|
|
|
280
302
|
info(message: string, meta?: unknown): void {
|
|
281
303
|
if (!this.shouldLog("info")) return;
|
|
282
|
-
const
|
|
283
|
-
const
|
|
284
|
-
this.
|
|
304
|
+
const safeMessage = this.config.redactSensitive ? sanitizeString(message) : message;
|
|
305
|
+
const rawMeta = this.mergeMeta(meta);
|
|
306
|
+
const mergedMeta = this.config.redactSensitive && rawMeta ? redact(rawMeta) : rawMeta;
|
|
307
|
+
const formatted = formatMessage("info", safeMessage, mergedMeta, this.correlationContext.correlationId);
|
|
308
|
+
this.writeToConsole("info", safeMessage, mergedMeta);
|
|
285
309
|
this.writeToFile(formatted);
|
|
286
|
-
emitLogEntry({ timestamp: formatTimestamp(), level: "info", source: "core", message, meta: mergedMeta as Record<string, unknown> | undefined });
|
|
310
|
+
emitLogEntry({ timestamp: formatTimestamp(), level: "info", source: "core", message: safeMessage, meta: mergedMeta as Record<string, unknown> | undefined });
|
|
287
311
|
}
|
|
288
312
|
|
|
289
313
|
warn(message: string, meta?: unknown): void {
|
|
290
314
|
if (!this.shouldLog("warn")) return;
|
|
291
|
-
const
|
|
292
|
-
const
|
|
293
|
-
this.
|
|
315
|
+
const safeMessage = this.config.redactSensitive ? sanitizeString(message) : message;
|
|
316
|
+
const rawMeta = this.mergeMeta(meta);
|
|
317
|
+
const mergedMeta = this.config.redactSensitive && rawMeta ? redact(rawMeta) : rawMeta;
|
|
318
|
+
const formatted = formatMessage("warn", safeMessage, mergedMeta, this.correlationContext.correlationId);
|
|
319
|
+
this.writeToConsole("warn", safeMessage, mergedMeta);
|
|
294
320
|
this.writeToFile(formatted);
|
|
295
|
-
emitLogEntry({ timestamp: formatTimestamp(), level: "warn", source: "core", message, meta: mergedMeta as Record<string, unknown> | undefined });
|
|
321
|
+
emitLogEntry({ timestamp: formatTimestamp(), level: "warn", source: "core", message: safeMessage, meta: mergedMeta as Record<string, unknown> | undefined });
|
|
296
322
|
}
|
|
297
323
|
|
|
298
324
|
error(message: string, meta?: unknown): void {
|
|
299
325
|
if (!this.shouldLog("error")) return;
|
|
300
|
-
const
|
|
301
|
-
const
|
|
302
|
-
this.
|
|
326
|
+
const safeMessage = this.config.redactSensitive ? sanitizeString(message) : message;
|
|
327
|
+
const rawMeta = this.mergeMeta(meta);
|
|
328
|
+
const mergedMeta = this.config.redactSensitive && rawMeta ? redact(rawMeta) : rawMeta;
|
|
329
|
+
const formatted = formatMessage("error", safeMessage, mergedMeta, this.correlationContext.correlationId);
|
|
330
|
+
this.writeToConsole("error", safeMessage, mergedMeta);
|
|
303
331
|
this.writeToFile(formatted);
|
|
304
|
-
emitLogEntry({ timestamp: formatTimestamp(), level: "error", source: "core", message, meta: mergedMeta as Record<string, unknown> | undefined });
|
|
332
|
+
emitLogEntry({ timestamp: formatTimestamp(), level: "error", source: "core", message: safeMessage, meta: mergedMeta as Record<string, unknown> | undefined });
|
|
305
333
|
}
|
|
306
334
|
|
|
307
335
|
child(context: string): ChildLogger {
|
|
@@ -225,26 +225,6 @@ export async function withToonFormat<T>(
|
|
|
225
225
|
}
|
|
226
226
|
}
|
|
227
227
|
|
|
228
|
-
/**
|
|
229
|
-
* Print compression report to console for debugging/analysis
|
|
230
|
-
* Note: This prints directly to console, does not return a string
|
|
231
|
-
*/
|
|
232
|
-
export function reportCompression(data: any): void {
|
|
233
|
-
// Import dynamically to avoid issues if function doesn't exist
|
|
234
|
-
import('toon-format-parser')
|
|
235
|
-
.then(({ printCompressionReport }) => {
|
|
236
|
-
printCompressionReport(data)
|
|
237
|
-
})
|
|
238
|
-
.catch(() => {
|
|
239
|
-
// Fallback: manual report
|
|
240
|
-
const analysis = analyzeCompression(data)
|
|
241
|
-
console.log(`\nTOON Compression Report:`)
|
|
242
|
-
console.log(` JSON: ${analysis.jsonBytes} bytes, ~${analysis.jsonTokens} tokens`)
|
|
243
|
-
console.log(` TOON: ${analysis.toonBytes} bytes, ~${analysis.toonTokens} tokens`)
|
|
244
|
-
console.log(` Saved: ${analysis.savedBytes} bytes, ${analysis.savedTokens} tokens (${analysis.savedPercent.toFixed(1)}%)`)
|
|
245
|
-
})
|
|
246
|
-
}
|
|
247
|
-
|
|
248
228
|
/**
|
|
249
229
|
* Get compression analysis as an object (for programmatic use)
|
|
250
230
|
*/
|
|
@@ -58,7 +58,7 @@ export class MCPClientManager {
|
|
|
58
58
|
logger.setHandler(handler);
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
async initialize(): Promise<void> {
|
|
61
|
+
async initialize(options: { connect?: boolean } = {}): Promise<void> {
|
|
62
62
|
const servers = this.config.servers ?? {};
|
|
63
63
|
|
|
64
64
|
for (const [name, serverConfig] of Object.entries(servers)) {
|
|
@@ -79,10 +79,9 @@ export class MCPClientManager {
|
|
|
79
79
|
|
|
80
80
|
this.log.info(`MCP Client initialized with ${this.servers.size} servers`);
|
|
81
81
|
|
|
82
|
-
//
|
|
83
|
-
//
|
|
84
|
-
|
|
85
|
-
await this.connectAll();
|
|
82
|
+
// Local-first lazy default: registering a server must not spawn a process
|
|
83
|
+
// or open a network session. Admin/manual callers may explicitly opt in.
|
|
84
|
+
if (options.connect === true) await this.connectAll();
|
|
86
85
|
}
|
|
87
86
|
|
|
88
87
|
async updateConfig(config: MCPConfig): Promise<void> {
|
|
@@ -129,7 +128,9 @@ export class MCPClientManager {
|
|
|
129
128
|
prompts: [],
|
|
130
129
|
reconnectAttempts: 0,
|
|
131
130
|
});
|
|
132
|
-
//
|
|
131
|
+
// A server the user just added should be usable right away — only
|
|
132
|
+
// servers that were already dormant (e.g. from a previous boot)
|
|
133
|
+
// wait for an explicit connect or an agent's task-scoped lease.
|
|
133
134
|
await this.connectServer(name).catch((err) => {
|
|
134
135
|
this.log.error(`Failed to connect new server ${name}: ${err.message}`);
|
|
135
136
|
});
|
|
@@ -460,4 +461,4 @@ export class MCPClientManager {
|
|
|
460
461
|
|
|
461
462
|
export function createMCPManager(config: MCPConfig): MCPClientManager {
|
|
462
463
|
return new MCPClientManager(config);
|
|
463
|
-
}
|
|
464
|
+
}
|
|
@@ -151,9 +151,3 @@ export class WebSocketTransport implements Transport {
|
|
|
151
151
|
return this.ws !== null && this.ws.readyState === WebSocket.OPEN;
|
|
152
152
|
}
|
|
153
153
|
}
|
|
154
|
-
|
|
155
|
-
export function createWebSocketTransport(
|
|
156
|
-
config: WebSocketTransportConfig
|
|
157
|
-
): Transport {
|
|
158
|
-
return new WebSocketTransport(config) as unknown as Transport;
|
|
159
|
-
}
|