@theowlops/boombot 0.0.0-stage → 1.1.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/README.md +69 -3
- package/dist/LICENSE +21 -0
- package/dist/bin/boombot.js +16 -0
- package/dist/cli/api-key.js +123 -0
- package/dist/cli/bin-bun.js +17 -0
- package/dist/cli/bin.js +34 -0
- package/dist/cli/cli/cli-error.js +61 -0
- package/dist/cli/cli/dispatch.js +138 -0
- package/dist/cli/cli/help.js +83 -0
- package/dist/cli/cli/parser.js +89 -0
- package/dist/cli/cli/registry.js +185 -0
- package/dist/cli/cli/spec.js +41 -0
- package/dist/cli/cli/suggest.js +125 -0
- package/dist/cli/cli/version.js +30 -0
- package/dist/cli/cli/vocabulary.js +87 -0
- package/dist/cli/commands/doctor.js +365 -0
- package/dist/cli/commands/gateway.js +290 -0
- package/dist/cli/commands/migrate.js +270 -0
- package/dist/cli/commands/plugin.js +97 -0
- package/dist/cli/commands/setup.js +244 -0
- package/dist/cli/config-file.js +133 -0
- package/dist/cli/master-key.js +78 -0
- package/dist/cli/open-browser.js +59 -0
- package/dist/cli/web-assets.js +58 -0
- package/dist/gateway/auth.js +46 -0
- package/dist/gateway/config-format.js +202 -0
- package/dist/gateway/config.js +427 -0
- package/dist/gateway/context.js +1 -0
- package/dist/gateway/env-file.js +129 -0
- package/dist/gateway/events.js +172 -0
- package/dist/gateway/guard/tagging.js +505 -0
- package/dist/gateway/handlers/index.js +66 -0
- package/dist/gateway/handlers/memory.js +54 -0
- package/dist/gateway/handlers/providers.js +73 -0
- package/dist/gateway/handlers/registry.js +39 -0
- package/dist/gateway/handlers/sessions.js +188 -0
- package/dist/gateway/handlers/system.js +12 -0
- package/dist/gateway/handlers/tasks.js +191 -0
- package/dist/gateway/handlers/turn.js +100 -0
- package/dist/gateway/index.js +126 -0
- package/dist/gateway/main.js +23 -0
- package/dist/gateway/server.js +354 -0
- package/dist/gateway/services/context-limits.js +75 -0
- package/dist/gateway/services/history-normalizer.js +42 -0
- package/dist/gateway/services/image-pipeline.js +56 -0
- package/dist/gateway/services/key-roulette-client.js +43 -0
- package/dist/gateway/services/llm-client.js +593 -0
- package/dist/gateway/services/llm-decoder.js +200 -0
- package/dist/gateway/services/local-fallback.js +135 -0
- package/dist/gateway/services/memory.js +511 -0
- package/dist/gateway/services/persistent-memory.js +196 -0
- package/dist/gateway/services/providers.js +44 -0
- package/dist/gateway/services/tasks.js +237 -0
- package/dist/gateway/services/verification.js +124 -0
- package/dist/gateway/services/vision-payload.js +48 -0
- package/dist/gateway/services.js +257 -0
- package/dist/gateway/session-snapshot.js +19 -0
- package/dist/gateway/sessions.js +701 -0
- package/dist/gateway/static.js +239 -0
- package/dist/gateway/turns/clarify-tool.js +57 -0
- package/dist/gateway/turns/cronjob-tool.js +96 -0
- package/dist/gateway/turns/deferred-tools.js +154 -0
- package/dist/gateway/turns/execute-code-tool.js +84 -0
- package/dist/gateway/turns/file-tool-defs.js +178 -0
- package/dist/gateway/turns/file-tool-ops.js +178 -0
- package/dist/gateway/turns/file-tool-scan.js +182 -0
- package/dist/gateway/turns/file-tool.js +302 -0
- package/dist/gateway/turns/index.js +416 -0
- package/dist/gateway/turns/jev-middleware.js +91 -0
- package/dist/gateway/turns/local-reply.js +156 -0
- package/dist/gateway/turns/mcp-client.js +643 -0
- package/dist/gateway/turns/memory-tool.js +171 -0
- package/dist/gateway/turns/middleware.js +96 -0
- package/dist/gateway/turns/python-core.js +397 -0
- package/dist/gateway/turns/routing/index.js +3 -0
- package/dist/gateway/turns/routing/intent-classifier.js +60 -0
- package/dist/gateway/turns/routing/planner-adapter.js +91 -0
- package/dist/gateway/turns/routing/types.js +1 -0
- package/dist/gateway/turns/runtime-deps.js +228 -0
- package/dist/gateway/turns/self-config-tool.js +277 -0
- package/dist/gateway/turns/service-types.js +11 -0
- package/dist/gateway/turns/service.js +820 -0
- package/dist/gateway/turns/session-adapter.js +158 -0
- package/dist/gateway/turns/session-tool.js +49 -0
- package/dist/gateway/turns/shell-tool.js +190 -0
- package/dist/gateway/turns/skill-tool.js +239 -0
- package/dist/gateway/turns/spillover.js +201 -0
- package/dist/gateway/turns/subagent-tool.js +140 -0
- package/dist/gateway/turns/system-prompt.js +121 -0
- package/dist/gateway/turns/tool-schema.js +90 -0
- package/dist/gateway/turns/turn-utils.js +58 -0
- package/dist/gateway/turns/vision-tool.js +120 -0
- package/dist/gateway/types.js +1 -0
- package/dist/native/win32-x64/boombot-native-host.exe +0 -0
- package/dist/node_modules/@boombot/channels/handlers.d.ts +9 -0
- package/dist/node_modules/@boombot/channels/handlers.js +109 -0
- package/dist/node_modules/@boombot/channels/index.d.ts +12 -0
- package/dist/node_modules/@boombot/channels/index.js +12 -0
- package/dist/node_modules/@boombot/channels/package.json +9 -0
- package/dist/node_modules/@boombot/channels/service.d.ts +62 -0
- package/dist/node_modules/@boombot/channels/service.js +608 -0
- package/dist/node_modules/@boombot/channels/tool.d.ts +10 -0
- package/dist/node_modules/@boombot/channels/tool.js +46 -0
- package/dist/node_modules/@boombot/channels/transports/common/dedup.d.ts +17 -0
- package/dist/node_modules/@boombot/channels/transports/common/dedup.js +42 -0
- package/dist/node_modules/@boombot/channels/transports/common/handoff.d.ts +19 -0
- package/dist/node_modules/@boombot/channels/transports/common/handoff.js +32 -0
- package/dist/node_modules/@boombot/channels/transports/common/index.d.ts +3 -0
- package/dist/node_modules/@boombot/channels/transports/common/index.js +3 -0
- package/dist/node_modules/@boombot/channels/transports/common/types.d.ts +99 -0
- package/dist/node_modules/@boombot/channels/transports/common/types.js +54 -0
- package/dist/node_modules/@boombot/channels/transports/common.d.ts +2 -0
- package/dist/node_modules/@boombot/channels/transports/common.js +2 -0
- package/dist/node_modules/@boombot/channels/transports/dedup/index.d.ts +1 -0
- package/dist/node_modules/@boombot/channels/transports/dedup/index.js +1 -0
- package/dist/node_modules/@boombot/channels/transports/dedup.d.ts +2 -0
- package/dist/node_modules/@boombot/channels/transports/dedup.js +2 -0
- package/dist/node_modules/@boombot/channels/transports/discord/index.d.ts +1 -0
- package/dist/node_modules/@boombot/channels/transports/discord/index.js +1 -0
- package/dist/node_modules/@boombot/channels/transports/discord/transport.d.ts +36 -0
- package/dist/node_modules/@boombot/channels/transports/discord/transport.js +199 -0
- package/dist/node_modules/@boombot/channels/transports/discord.d.ts +2 -0
- package/dist/node_modules/@boombot/channels/transports/discord.js +2 -0
- package/dist/node_modules/@boombot/channels/transports/handoff.d.ts +2 -0
- package/dist/node_modules/@boombot/channels/transports/handoff.js +2 -0
- package/dist/node_modules/@boombot/channels/transports/messenger/index.d.ts +1 -0
- package/dist/node_modules/@boombot/channels/transports/messenger/index.js +1 -0
- package/dist/node_modules/@boombot/channels/transports/messenger/transport.d.ts +34 -0
- package/dist/node_modules/@boombot/channels/transports/messenger/transport.js +180 -0
- package/dist/node_modules/@boombot/channels/transports/messenger.d.ts +2 -0
- package/dist/node_modules/@boombot/channels/transports/messenger.js +2 -0
- package/dist/node_modules/@boombot/channels/transports/slack/index.d.ts +1 -0
- package/dist/node_modules/@boombot/channels/transports/slack/index.js +1 -0
- package/dist/node_modules/@boombot/channels/transports/slack/transport.d.ts +35 -0
- package/dist/node_modules/@boombot/channels/transports/slack/transport.js +183 -0
- package/dist/node_modules/@boombot/channels/transports/slack.d.ts +2 -0
- package/dist/node_modules/@boombot/channels/transports/slack.js +2 -0
- package/dist/node_modules/@boombot/channels/transports/streamer/index.d.ts +1 -0
- package/dist/node_modules/@boombot/channels/transports/streamer/index.js +1 -0
- package/dist/node_modules/@boombot/channels/transports/streamer/streamer.d.ts +31 -0
- package/dist/node_modules/@boombot/channels/transports/streamer/streamer.js +141 -0
- package/dist/node_modules/@boombot/channels/transports/streamer.d.ts +2 -0
- package/dist/node_modules/@boombot/channels/transports/streamer.js +2 -0
- package/dist/node_modules/@boombot/channels/transports/telegram/index.d.ts +1 -0
- package/dist/node_modules/@boombot/channels/transports/telegram/index.js +1 -0
- package/dist/node_modules/@boombot/channels/transports/telegram/transport.d.ts +75 -0
- package/dist/node_modules/@boombot/channels/transports/telegram/transport.js +395 -0
- package/dist/node_modules/@boombot/channels/transports/telegram.d.ts +2 -0
- package/dist/node_modules/@boombot/channels/transports/telegram.js +2 -0
- package/dist/node_modules/@boombot/channels/transports/tiktok/index.d.ts +1 -0
- package/dist/node_modules/@boombot/channels/transports/tiktok/index.js +1 -0
- package/dist/node_modules/@boombot/channels/transports/tiktok/transport.d.ts +27 -0
- package/dist/node_modules/@boombot/channels/transports/tiktok/transport.js +97 -0
- package/dist/node_modules/@boombot/channels/transports/tiktok.d.ts +2 -0
- package/dist/node_modules/@boombot/channels/transports/tiktok.js +2 -0
- package/dist/node_modules/@boombot/channels/transports/whatsapp/index.d.ts +1 -0
- package/dist/node_modules/@boombot/channels/transports/whatsapp/index.js +1 -0
- package/dist/node_modules/@boombot/channels/transports/whatsapp/transport.d.ts +38 -0
- package/dist/node_modules/@boombot/channels/transports/whatsapp/transport.js +189 -0
- package/dist/node_modules/@boombot/channels/transports/whatsapp.d.ts +2 -0
- package/dist/node_modules/@boombot/channels/transports/whatsapp.js +2 -0
- package/dist/node_modules/@boombot/channels/transports/zalo/index.d.ts +2 -0
- package/dist/node_modules/@boombot/channels/transports/zalo/index.js +2 -0
- package/dist/node_modules/@boombot/channels/transports/zalo/oa.d.ts +28 -0
- package/dist/node_modules/@boombot/channels/transports/zalo/oa.js +94 -0
- package/dist/node_modules/@boombot/channels/transports/zalo/personal.d.ts +106 -0
- package/dist/node_modules/@boombot/channels/transports/zalo/personal.js +171 -0
- package/dist/node_modules/@boombot/channels/transports/zalo-personal.d.ts +2 -0
- package/dist/node_modules/@boombot/channels/transports/zalo-personal.js +2 -0
- package/dist/node_modules/@boombot/channels/transports/zalo.d.ts +2 -0
- package/dist/node_modules/@boombot/channels/transports/zalo.js +2 -0
- package/dist/node_modules/@boombot/core/agent-core/index.d.ts +12 -0
- package/dist/node_modules/@boombot/core/agent-core/index.js +12 -0
- package/dist/node_modules/@boombot/core/agent-core/middleware.d.ts +60 -0
- package/dist/node_modules/@boombot/core/agent-core/middleware.js +152 -0
- package/dist/node_modules/@boombot/core/agent-core/routing.d.ts +128 -0
- package/dist/node_modules/@boombot/core/agent-core/routing.js +437 -0
- package/dist/node_modules/@boombot/core/agent-core/runtime-deps.d.ts +88 -0
- package/dist/node_modules/@boombot/core/agent-core/runtime-deps.js +8 -0
- package/dist/node_modules/@boombot/core/agent-core/tool-errors.d.ts +44 -0
- package/dist/node_modules/@boombot/core/agent-core/tool-errors.js +60 -0
- package/dist/node_modules/@boombot/core/agent-core/turn-loop.d.ts +21 -0
- package/dist/node_modules/@boombot/core/agent-core/turn-loop.js +561 -0
- package/dist/node_modules/@boombot/core/agent-core/types.d.ts +189 -0
- package/dist/node_modules/@boombot/core/agent-core/types.js +7 -0
- package/dist/node_modules/@boombot/core/compaction/compactor.d.ts +19 -0
- package/dist/node_modules/@boombot/core/compaction/compactor.js +127 -0
- package/dist/node_modules/@boombot/core/compaction/estimator.d.ts +10 -0
- package/dist/node_modules/@boombot/core/compaction/estimator.js +48 -0
- package/dist/node_modules/@boombot/core/compaction/index.d.ts +3 -0
- package/dist/node_modules/@boombot/core/compaction/index.js +3 -0
- package/dist/node_modules/@boombot/core/compaction/types.d.ts +31 -0
- package/dist/node_modules/@boombot/core/compaction/types.js +7 -0
- package/dist/node_modules/@boombot/core/index.d.ts +9 -0
- package/dist/node_modules/@boombot/core/index.js +9 -0
- package/dist/node_modules/@boombot/core/jev/index.d.ts +2 -0
- package/dist/node_modules/@boombot/core/jev/index.js +2 -0
- package/dist/node_modules/@boombot/core/jev/jev.d.ts +30 -0
- package/dist/node_modules/@boombot/core/jev/jev.js +164 -0
- package/dist/node_modules/@boombot/core/jev/types.d.ts +22 -0
- package/dist/node_modules/@boombot/core/jev/types.js +1 -0
- package/dist/node_modules/@boombot/core/memory/consolidation/budget.d.ts +63 -0
- package/dist/node_modules/@boombot/core/memory/consolidation/budget.js +94 -0
- package/dist/node_modules/@boombot/core/memory/consolidation/consolidator.d.ts +152 -0
- package/dist/node_modules/@boombot/core/memory/consolidation/consolidator.js +318 -0
- package/dist/node_modules/@boombot/core/memory/consolidation/index.d.ts +12 -0
- package/dist/node_modules/@boombot/core/memory/consolidation/index.js +12 -0
- package/dist/node_modules/@boombot/core/memory/curation.d.ts +86 -0
- package/dist/node_modules/@boombot/core/memory/curation.js +120 -0
- package/dist/node_modules/@boombot/core/memory/errors.d.ts +12 -0
- package/dist/node_modules/@boombot/core/memory/errors.js +20 -0
- package/dist/node_modules/@boombot/core/memory/hybrid-search.d.ts +29 -0
- package/dist/node_modules/@boombot/core/memory/hybrid-search.js +52 -0
- package/dist/node_modules/@boombot/core/memory/index.d.ts +23 -0
- package/dist/node_modules/@boombot/core/memory/index.js +23 -0
- package/dist/node_modules/@boombot/core/memory/indexer.d.ts +47 -0
- package/dist/node_modules/@boombot/core/memory/indexer.js +138 -0
- package/dist/node_modules/@boombot/core/memory/lifecycle.d.ts +12 -0
- package/dist/node_modules/@boombot/core/memory/lifecycle.js +66 -0
- package/dist/node_modules/@boombot/core/memory/provider.d.ts +84 -0
- package/dist/node_modules/@boombot/core/memory/provider.js +117 -0
- package/dist/node_modules/@boombot/core/memory/recall.d.ts +7 -0
- package/dist/node_modules/@boombot/core/memory/recall.js +111 -0
- package/dist/node_modules/@boombot/core/memory/scope-resolver.d.ts +27 -0
- package/dist/node_modules/@boombot/core/memory/scope-resolver.js +60 -0
- package/dist/node_modules/@boombot/core/memory/search.d.ts +37 -0
- package/dist/node_modules/@boombot/core/memory/search.js +158 -0
- package/dist/node_modules/@boombot/core/memory/store.d.ts +60 -0
- package/dist/node_modules/@boombot/core/memory/store.js +289 -0
- package/dist/node_modules/@boombot/core/memory/types.d.ts +121 -0
- package/dist/node_modules/@boombot/core/memory/types.js +21 -0
- package/dist/node_modules/@boombot/core/memory/vector-index.d.ts +34 -0
- package/dist/node_modules/@boombot/core/memory/vector-index.js +65 -0
- package/dist/node_modules/@boombot/core/package.json +9 -0
- package/dist/node_modules/@boombot/core/reflection/classifier.d.ts +13 -0
- package/dist/node_modules/@boombot/core/reflection/classifier.js +77 -0
- package/dist/node_modules/@boombot/core/reflection/index.d.ts +2 -0
- package/dist/node_modules/@boombot/core/reflection/index.js +2 -0
- package/dist/node_modules/@boombot/core/reflection/types.d.ts +13 -0
- package/dist/node_modules/@boombot/core/reflection/types.js +4 -0
- package/dist/node_modules/@boombot/core/research/config.d.ts +89 -0
- package/dist/node_modules/@boombot/core/research/config.js +206 -0
- package/dist/node_modules/@boombot/core/research/crawl.d.ts +36 -0
- package/dist/node_modules/@boombot/core/research/crawl.js +179 -0
- package/dist/node_modules/@boombot/core/research/factory.d.ts +26 -0
- package/dist/node_modules/@boombot/core/research/factory.js +46 -0
- package/dist/node_modules/@boombot/core/research/http.d.ts +87 -0
- package/dist/node_modules/@boombot/core/research/http.js +250 -0
- package/dist/node_modules/@boombot/core/research/index.d.ts +17 -0
- package/dist/node_modules/@boombot/core/research/index.js +10 -0
- package/dist/node_modules/@boombot/core/research/orchestrator.d.ts +113 -0
- package/dist/node_modules/@boombot/core/research/orchestrator.js +252 -0
- package/dist/node_modules/@boombot/core/research/parse/docx.d.ts +24 -0
- package/dist/node_modules/@boombot/core/research/parse/docx.js +183 -0
- package/dist/node_modules/@boombot/core/research/parse/guards.d.ts +89 -0
- package/dist/node_modules/@boombot/core/research/parse/guards.js +171 -0
- package/dist/node_modules/@boombot/core/research/parse/index.d.ts +68 -0
- package/dist/node_modules/@boombot/core/research/parse/index.js +219 -0
- package/dist/node_modules/@boombot/core/research/parse/pdf.d.ts +38 -0
- package/dist/node_modules/@boombot/core/research/parse/pdf.js +567 -0
- package/dist/node_modules/@boombot/core/research/providers/arxiv.d.ts +9 -0
- package/dist/node_modules/@boombot/core/research/providers/arxiv.js +72 -0
- package/dist/node_modules/@boombot/core/research/providers/brave.d.ts +11 -0
- package/dist/node_modules/@boombot/core/research/providers/brave.js +36 -0
- package/dist/node_modules/@boombot/core/research/providers/duckduckgo.d.ts +9 -0
- package/dist/node_modules/@boombot/core/research/providers/duckduckgo.js +78 -0
- package/dist/node_modules/@boombot/core/research/providers/exa.d.ts +11 -0
- package/dist/node_modules/@boombot/core/research/providers/exa.js +34 -0
- package/dist/node_modules/@boombot/core/research/providers/firecrawl.d.ts +16 -0
- package/dist/node_modules/@boombot/core/research/providers/firecrawl.js +47 -0
- package/dist/node_modules/@boombot/core/research/providers/index.d.ts +17 -0
- package/dist/node_modules/@boombot/core/research/providers/index.js +11 -0
- package/dist/node_modules/@boombot/core/research/providers/jina.d.ts +13 -0
- package/dist/node_modules/@boombot/core/research/providers/jina.js +114 -0
- package/dist/node_modules/@boombot/core/research/providers/openalex.d.ts +14 -0
- package/dist/node_modules/@boombot/core/research/providers/openalex.js +66 -0
- package/dist/node_modules/@boombot/core/research/providers/semantic-scholar.d.ts +9 -0
- package/dist/node_modules/@boombot/core/research/providers/semantic-scholar.js +56 -0
- package/dist/node_modules/@boombot/core/research/providers/tavily.d.ts +11 -0
- package/dist/node_modules/@boombot/core/research/providers/tavily.js +35 -0
- package/dist/node_modules/@boombot/core/research/providers/wikipedia.d.ts +12 -0
- package/dist/node_modules/@boombot/core/research/providers/wikipedia.js +47 -0
- package/dist/node_modules/@boombot/core/research/tools.d.ts +27 -0
- package/dist/node_modules/@boombot/core/research/tools.js +251 -0
- package/dist/node_modules/@boombot/core/research/types.d.ts +133 -0
- package/dist/node_modules/@boombot/core/research/types.js +8 -0
- package/dist/node_modules/@boombot/core/research/wiring.d.ts +25 -0
- package/dist/node_modules/@boombot/core/research/wiring.js +51 -0
- package/dist/node_modules/@boombot/core/scheduler/cron.d.ts +34 -0
- package/dist/node_modules/@boombot/core/scheduler/cron.js +147 -0
- package/dist/node_modules/@boombot/core/scheduler/evaluator.d.ts +42 -0
- package/dist/node_modules/@boombot/core/scheduler/evaluator.js +148 -0
- package/dist/node_modules/@boombot/core/scheduler/index.d.ts +15 -0
- package/dist/node_modules/@boombot/core/scheduler/index.js +15 -0
- package/dist/node_modules/@boombot/core/scheduler/registry.d.ts +81 -0
- package/dist/node_modules/@boombot/core/scheduler/registry.js +263 -0
- package/dist/node_modules/@boombot/core/scheduler/runner.d.ts +59 -0
- package/dist/node_modules/@boombot/core/scheduler/runner.js +257 -0
- package/dist/node_modules/@boombot/core/scheduler/store.d.ts +150 -0
- package/dist/node_modules/@boombot/core/scheduler/store.js +526 -0
- package/dist/node_modules/@boombot/core/scheduler/timezone.d.ts +35 -0
- package/dist/node_modules/@boombot/core/scheduler/timezone.js +96 -0
- package/dist/node_modules/@boombot/core/scheduler/types.d.ts +157 -0
- package/dist/node_modules/@boombot/core/scheduler/types.js +89 -0
- package/dist/node_modules/@boombot/core/task-runner/index.d.ts +7 -0
- package/dist/node_modules/@boombot/core/task-runner/index.js +5 -0
- package/dist/node_modules/@boombot/core/task-runner/planner.d.ts +37 -0
- package/dist/node_modules/@boombot/core/task-runner/planner.js +154 -0
- package/dist/node_modules/@boombot/core/task-runner/runner.d.ts +8 -0
- package/dist/node_modules/@boombot/core/task-runner/runner.js +564 -0
- package/dist/node_modules/@boombot/core/task-runner/store.d.ts +28 -0
- package/dist/node_modules/@boombot/core/task-runner/store.js +126 -0
- package/dist/node_modules/@boombot/core/task-runner/types.d.ts +138 -0
- package/dist/node_modules/@boombot/core/task-runner/types.js +11 -0
- package/dist/node_modules/@boombot/core/workflow/dag.d.ts +16 -0
- package/dist/node_modules/@boombot/core/workflow/dag.js +109 -0
- package/dist/node_modules/@boombot/core/workflow/engine.d.ts +34 -0
- package/dist/node_modules/@boombot/core/workflow/engine.js +304 -0
- package/dist/node_modules/@boombot/core/workflow/index.d.ts +3 -0
- package/dist/node_modules/@boombot/core/workflow/index.js +3 -0
- package/dist/node_modules/@boombot/core/workflow/types.d.ts +98 -0
- package/dist/node_modules/@boombot/core/workflow/types.js +21 -0
- package/dist/node_modules/@boombot/cronjobs/handlers.d.ts +11 -0
- package/dist/node_modules/@boombot/cronjobs/handlers.js +174 -0
- package/dist/node_modules/@boombot/cronjobs/index.d.ts +2 -0
- package/dist/node_modules/@boombot/cronjobs/index.js +2 -0
- package/dist/node_modules/@boombot/cronjobs/package.json +9 -0
- package/dist/node_modules/@boombot/cronjobs/service.d.ts +53 -0
- package/dist/node_modules/@boombot/cronjobs/service.js +200 -0
- package/dist/node_modules/@boombot/plugins/index.d.ts +2 -0
- package/dist/node_modules/@boombot/plugins/index.js +2 -0
- package/dist/node_modules/@boombot/plugins/installer.d.ts +45 -0
- package/dist/node_modules/@boombot/plugins/installer.js +487 -0
- package/dist/node_modules/@boombot/plugins/manager.d.ts +23 -0
- package/dist/node_modules/@boombot/plugins/manager.js +243 -0
- package/dist/node_modules/@boombot/plugins/package.json +9 -0
- package/dist/node_modules/@boombot/protocol/gateway-protocol/commands-channels.d.ts +125 -0
- package/dist/node_modules/@boombot/protocol/gateway-protocol/commands-channels.js +76 -0
- package/dist/node_modules/@boombot/protocol/gateway-protocol/commands-plugins.d.ts +220 -0
- package/dist/node_modules/@boombot/protocol/gateway-protocol/commands-plugins.js +60 -0
- package/dist/node_modules/@boombot/protocol/gateway-protocol/commands-scheduler.d.ts +33 -0
- package/dist/node_modules/@boombot/protocol/gateway-protocol/commands-scheduler.js +25 -0
- package/dist/node_modules/@boombot/protocol/gateway-protocol/commands.d.ts +4349 -0
- package/dist/node_modules/@boombot/protocol/gateway-protocol/commands.js +563 -0
- package/dist/node_modules/@boombot/protocol/gateway-protocol/envelope.d.ts +32 -0
- package/dist/node_modules/@boombot/protocol/gateway-protocol/envelope.js +61 -0
- package/dist/node_modules/@boombot/protocol/gateway-protocol/errors.d.ts +13 -0
- package/dist/node_modules/@boombot/protocol/gateway-protocol/errors.js +16 -0
- package/dist/node_modules/@boombot/protocol/gateway-protocol/events.d.ts +567 -0
- package/dist/node_modules/@boombot/protocol/gateway-protocol/events.js +395 -0
- package/dist/node_modules/@boombot/protocol/gateway-protocol/index.d.ts +20 -0
- package/dist/node_modules/@boombot/protocol/gateway-protocol/index.js +13 -0
- package/dist/node_modules/@boombot/protocol/gateway-protocol/types.d.ts +91 -0
- package/dist/node_modules/@boombot/protocol/gateway-protocol/types.js +7 -0
- package/dist/node_modules/@boombot/protocol/index.d.ts +4 -0
- package/dist/node_modules/@boombot/protocol/index.js +3 -0
- package/dist/node_modules/@boombot/protocol/package.json +9 -0
- package/dist/node_modules/@boombot/protocol/plugin-sdk/channel.d.ts +41 -0
- package/dist/node_modules/@boombot/protocol/plugin-sdk/channel.js +17 -0
- package/dist/node_modules/@boombot/protocol/plugin-sdk/index.d.ts +10 -0
- package/dist/node_modules/@boombot/protocol/plugin-sdk/index.js +10 -0
- package/dist/node_modules/@boombot/protocol/plugin-sdk/manifest.d.ts +58 -0
- package/dist/node_modules/@boombot/protocol/plugin-sdk/manifest.js +116 -0
- package/dist/node_modules/@boombot/protocol/plugin-sdk/plugin.d.ts +25 -0
- package/dist/node_modules/@boombot/protocol/plugin-sdk/plugin.js +1 -0
- package/dist/node_modules/@boombot/protocol/providers/cipher.d.ts +7 -0
- package/dist/node_modules/@boombot/protocol/providers/cipher.js +52 -0
- package/dist/node_modules/@boombot/protocol/providers/index.d.ts +19 -0
- package/dist/node_modules/@boombot/protocol/providers/index.js +19 -0
- package/dist/node_modules/@boombot/protocol/providers/key-roulette.d.ts +79 -0
- package/dist/node_modules/@boombot/protocol/providers/key-roulette.js +81 -0
- package/dist/node_modules/@boombot/protocol/providers/probe.d.ts +29 -0
- package/dist/node_modules/@boombot/protocol/providers/probe.js +96 -0
- package/dist/node_modules/@boombot/protocol/providers/profiles/anthropic.d.ts +11 -0
- package/dist/node_modules/@boombot/protocol/providers/profiles/anthropic.js +11 -0
- package/dist/node_modules/@boombot/protocol/providers/profiles/custom.d.ts +22 -0
- package/dist/node_modules/@boombot/protocol/providers/profiles/custom.js +222 -0
- package/dist/node_modules/@boombot/protocol/providers/profiles/deepseek.d.ts +7 -0
- package/dist/node_modules/@boombot/protocol/providers/profiles/deepseek.js +9 -0
- package/dist/node_modules/@boombot/protocol/providers/profiles/google.d.ts +10 -0
- package/dist/node_modules/@boombot/protocol/providers/profiles/google.js +10 -0
- package/dist/node_modules/@boombot/protocol/providers/profiles/index.d.ts +31 -0
- package/dist/node_modules/@boombot/protocol/providers/profiles/index.js +56 -0
- package/dist/node_modules/@boombot/protocol/providers/profiles/local.d.ts +10 -0
- package/dist/node_modules/@boombot/protocol/providers/profiles/local.js +11 -0
- package/dist/node_modules/@boombot/protocol/providers/profiles/mistral.d.ts +7 -0
- package/dist/node_modules/@boombot/protocol/providers/profiles/mistral.js +9 -0
- package/dist/node_modules/@boombot/protocol/providers/profiles/openai-compatible.d.ts +10 -0
- package/dist/node_modules/@boombot/protocol/providers/profiles/openai-compatible.js +10 -0
- package/dist/node_modules/@boombot/protocol/providers/profiles/openai.d.ts +7 -0
- package/dist/node_modules/@boombot/protocol/providers/profiles/openai.js +11 -0
- package/dist/node_modules/@boombot/protocol/providers/profiles/types.d.ts +58 -0
- package/dist/node_modules/@boombot/protocol/providers/profiles/types.js +1 -0
- package/dist/node_modules/@boombot/protocol/providers/profiles/xai.d.ts +7 -0
- package/dist/node_modules/@boombot/protocol/providers/profiles/xai.js +10 -0
- package/dist/node_modules/@boombot/protocol/providers/request-profile.d.ts +102 -0
- package/dist/node_modules/@boombot/protocol/providers/request-profile.js +118 -0
- package/dist/node_modules/@boombot/protocol/providers/service.d.ts +2 -0
- package/dist/node_modules/@boombot/protocol/providers/service.js +418 -0
- package/dist/node_modules/@boombot/protocol/providers/types.d.ts +141 -0
- package/dist/node_modules/@boombot/protocol/providers/types.js +16 -0
- package/dist/node_modules/@boombot/sandbox/fs-path.d.ts +13 -0
- package/dist/node_modules/@boombot/sandbox/fs-path.js +79 -0
- package/dist/node_modules/@boombot/sandbox/index.d.ts +13 -0
- package/dist/node_modules/@boombot/sandbox/index.js +13 -0
- package/dist/node_modules/@boombot/sandbox/native.d.ts +39 -0
- package/dist/node_modules/@boombot/sandbox/native.js +224 -0
- package/dist/node_modules/@boombot/sandbox/package.json +9 -0
- package/dist/node_modules/@boombot/sandbox/sandbox.d.ts +92 -0
- package/dist/node_modules/@boombot/sandbox/sandbox.js +229 -0
- package/dist/node_modules/@boombot/security/harness-guard/boundary.d.ts +22 -0
- package/dist/node_modules/@boombot/security/harness-guard/boundary.js +105 -0
- package/dist/node_modules/@boombot/security/harness-guard/gates.d.ts +90 -0
- package/dist/node_modules/@boombot/security/harness-guard/gates.js +791 -0
- package/dist/node_modules/@boombot/security/harness-guard/index.d.ts +23 -0
- package/dist/node_modules/@boombot/security/harness-guard/index.js +23 -0
- package/dist/node_modules/@boombot/security/harness-guard/policy.d.ts +20 -0
- package/dist/node_modules/@boombot/security/harness-guard/policy.js +70 -0
- package/dist/node_modules/@boombot/security/harness-guard/sanitizer.d.ts +53 -0
- package/dist/node_modules/@boombot/security/harness-guard/sanitizer.js +145 -0
- package/dist/node_modules/@boombot/security/harness-guard/types.d.ts +71 -0
- package/dist/node_modules/@boombot/security/harness-guard/types.js +10 -0
- package/dist/node_modules/@boombot/security/harness-guard/verifier.d.ts +59 -0
- package/dist/node_modules/@boombot/security/harness-guard/verifier.js +169 -0
- package/dist/node_modules/@boombot/security/index.d.ts +5 -0
- package/dist/node_modules/@boombot/security/index.js +9 -0
- package/dist/node_modules/@boombot/security/package.json +9 -0
- package/dist/node_modules/@boombot/security/policy/approval.d.ts +117 -0
- package/dist/node_modules/@boombot/security/policy/approval.js +223 -0
- package/dist/node_modules/@boombot/security/reasoning-guard/claim-extractor.d.ts +10 -0
- package/dist/node_modules/@boombot/security/reasoning-guard/claim-extractor.js +124 -0
- package/dist/node_modules/@boombot/security/reasoning-guard/evidence-ledger.d.ts +25 -0
- package/dist/node_modules/@boombot/security/reasoning-guard/evidence-ledger.js +70 -0
- package/dist/node_modules/@boombot/security/reasoning-guard/gate.d.ts +38 -0
- package/dist/node_modules/@boombot/security/reasoning-guard/gate.js +61 -0
- package/dist/node_modules/@boombot/security/reasoning-guard/grounding-check.d.ts +12 -0
- package/dist/node_modules/@boombot/security/reasoning-guard/grounding-check.js +234 -0
- package/dist/node_modules/@boombot/security/reasoning-guard/index.d.ts +17 -0
- package/dist/node_modules/@boombot/security/reasoning-guard/index.js +13 -0
- package/dist/node_modules/@boombot/security/reasoning-guard/policy.d.ts +15 -0
- package/dist/node_modules/@boombot/security/reasoning-guard/policy.js +39 -0
- package/dist/node_modules/@boombot/security/reasoning-guard/types.d.ts +46 -0
- package/dist/node_modules/@boombot/security/reasoning-guard/types.js +7 -0
- package/dist/node_modules/@boombot/security/security/approval.d.ts +63 -0
- package/dist/node_modules/@boombot/security/security/approval.js +140 -0
- package/dist/node_modules/@boombot/security/security/audit.d.ts +39 -0
- package/dist/node_modules/@boombot/security/security/audit.js +70 -0
- package/dist/node_modules/@boombot/security/security/index.d.ts +12 -0
- package/dist/node_modules/@boombot/security/security/index.js +12 -0
- package/dist/node_modules/@boombot/security/security/trust.d.ts +79 -0
- package/dist/node_modules/@boombot/security/security/trust.js +87 -0
- package/dist/package.json +5 -0
- package/dist/proto/agent_core.proto +56 -0
- package/dist/python/agent-core-python/pyproject.toml +40 -0
- package/dist/python/agent-core-python/src/boombot_agent/__init__.py +5 -0
- package/dist/python/agent-core-python/src/boombot_agent/generated/__init__.py +0 -0
- package/dist/python/agent-core-python/src/boombot_agent/generated/agent_core_pb2.py +54 -0
- package/dist/python/agent-core-python/src/boombot_agent/generated/agent_core_pb2_grpc.py +140 -0
- package/dist/python/agent-core-python/src/boombot_agent/rpc.py +265 -0
- package/dist/python/agent-core-python/src/boombot_agent/turn.py +577 -0
- package/dist/python/agent-core-python/src/boombot_ml/__init__.py +12 -0
- package/dist/python/agent-core-python/src/boombot_ml/embeddings.py +58 -0
- package/dist/python/agent-core-python/src/boombot_ml/training.py +156 -0
- package/dist/python/agent-core-python/uv.lock +2856 -0
- package/dist/web/assets/ChatView-BZrSD-64.js +262 -0
- package/dist/web/assets/ChatView-Cahbjez6.css +1 -0
- package/dist/web/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
- package/dist/web/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
- package/dist/web/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
- package/dist/web/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
- package/dist/web/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
- package/dist/web/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
- package/dist/web/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
- package/dist/web/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
- package/dist/web/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
- package/dist/web/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
- package/dist/web/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
- package/dist/web/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
- package/dist/web/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
- package/dist/web/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
- package/dist/web/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
- package/dist/web/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
- package/dist/web/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
- package/dist/web/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
- package/dist/web/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
- package/dist/web/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
- package/dist/web/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
- package/dist/web/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
- package/dist/web/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
- package/dist/web/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
- package/dist/web/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
- package/dist/web/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
- package/dist/web/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
- package/dist/web/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
- package/dist/web/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
- package/dist/web/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
- package/dist/web/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
- package/dist/web/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
- package/dist/web/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
- package/dist/web/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
- package/dist/web/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
- package/dist/web/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
- package/dist/web/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
- package/dist/web/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
- package/dist/web/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
- package/dist/web/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
- package/dist/web/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
- package/dist/web/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
- package/dist/web/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
- package/dist/web/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
- package/dist/web/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
- package/dist/web/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
- package/dist/web/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
- package/dist/web/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
- package/dist/web/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
- package/dist/web/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
- package/dist/web/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
- package/dist/web/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
- package/dist/web/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
- package/dist/web/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
- package/dist/web/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
- package/dist/web/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
- package/dist/web/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
- package/dist/web/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
- package/dist/web/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
- package/dist/web/assets/MemoryView-BJbXqqs7.css +1 -0
- package/dist/web/assets/MemoryView-BfMq_6CD.js +1 -0
- package/dist/web/assets/SchedulesView-B22QmPR-.js +1 -0
- package/dist/web/assets/SchedulesView-C6XK7A8a.css +1 -0
- package/dist/web/assets/SessionsView-C1dqdhxI.css +1 -0
- package/dist/web/assets/SessionsView-DS0-aH2a.js +1 -0
- package/dist/web/assets/TasksView-Dtasg4hd.css +1 -0
- package/dist/web/assets/TasksView-ey0FLsW8.js +2 -0
- package/dist/web/assets/Textarea-DN3Zybl1.js +1 -0
- package/dist/web/assets/Tooltip-Bn2cqFPz.css +1 -0
- package/dist/web/assets/Tooltip-MzV2Gqnc.js +1 -0
- package/dist/web/assets/browser-Bnt73-Ub.js +8 -0
- package/dist/web/assets/index-BL8bi7Yt.css +1 -0
- package/dist/web/assets/index-CuPR73Tn.js +73 -0
- package/dist/web/favicon.svg +4 -0
- package/dist/web/index.html +26 -0
- package/dist/web/logo.jpg +0 -0
- package/dist/web/logo.png +0 -0
- package/package.json +51 -4
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
export const FILE_READ_TOOL_NAME = 'file.read';
|
|
2
|
+
export const FILE_WRITE_TOOL_NAME = 'file.write';
|
|
3
|
+
export const FILE_EDIT_TOOL_NAME = 'file.edit';
|
|
4
|
+
export const FILE_GLOB_TOOL_NAME = 'file.glob';
|
|
5
|
+
export const FILE_GREP_TOOL_NAME = 'file.grep';
|
|
6
|
+
/** All tool names in this group — used for policy allow grants. */
|
|
7
|
+
export const FILE_TOOL_NAMES = [
|
|
8
|
+
FILE_READ_TOOL_NAME,
|
|
9
|
+
FILE_WRITE_TOOL_NAME,
|
|
10
|
+
FILE_EDIT_TOOL_NAME,
|
|
11
|
+
FILE_GLOB_TOOL_NAME,
|
|
12
|
+
FILE_GREP_TOOL_NAME,
|
|
13
|
+
];
|
|
14
|
+
/** Byte cap per read for `file.read`. */
|
|
15
|
+
export const MAX_READ_BYTES = 256 * 1024;
|
|
16
|
+
/** Result line cap for `file.glob`. */
|
|
17
|
+
export const MAX_GLOB_RESULTS = 200;
|
|
18
|
+
/** Match line cap for `file.grep`. */
|
|
19
|
+
export const MAX_GREP_MATCHES = 200;
|
|
20
|
+
/** Files larger than this are skipped by `file.grep` (not read). */
|
|
21
|
+
export const MAX_GREP_FILE_BYTES = 1024 * 1024;
|
|
22
|
+
/** Character cap for `file.grep`'s `pattern`. */
|
|
23
|
+
export const MAX_PATTERN_LENGTH = 512;
|
|
24
|
+
/** Cap on entries visited during glob/grep, guards against unbounded scans. */
|
|
25
|
+
export const MAX_WALK_ENTRIES = 20_000;
|
|
26
|
+
/**
|
|
27
|
+
* Directory (and file) names skipped during traversal.
|
|
28
|
+
*
|
|
29
|
+
* `file.*`'s root is the project directory, so without this list a single
|
|
30
|
+
* `file.glob` would swallow `node_modules` whole, hit `MAX_WALK_ENTRIES` before
|
|
31
|
+
* reaching `src/`, and return results that are both slow and WRONG — just the
|
|
32
|
+
* head of the tree presented as if it were the whole tree. This is the search
|
|
33
|
+
* tool's default, not a security limit: to inspect `node_modules`, change
|
|
34
|
+
* `files.root` or read directly with `file.read`.
|
|
35
|
+
*/
|
|
36
|
+
export const WALK_IGNORES = new Set([
|
|
37
|
+
'node_modules',
|
|
38
|
+
'.git',
|
|
39
|
+
'dist',
|
|
40
|
+
'build',
|
|
41
|
+
'coverage',
|
|
42
|
+
'.next',
|
|
43
|
+
'.turbo',
|
|
44
|
+
'target',
|
|
45
|
+
'__pycache__',
|
|
46
|
+
'.venv',
|
|
47
|
+
'vendor',
|
|
48
|
+
'win-unpacked',
|
|
49
|
+
]);
|
|
50
|
+
/** Minified files: content is unreadable by eye, so always skipped. */
|
|
51
|
+
export const MINIFIED_FILE_RE = /\.min\.[^./\\]+$/i;
|
|
52
|
+
/** Leading bytes used for binary detection, instead of loading the whole file. */
|
|
53
|
+
export const BINARY_SNIFF_BYTES = 8 * 1024;
|
|
54
|
+
/** Files `file.grep` reads in parallel per batch. */
|
|
55
|
+
export const GREP_READ_CONCURRENCY = 8;
|
|
56
|
+
export const fileReadDefinition = {
|
|
57
|
+
name: FILE_READ_TOOL_NAME,
|
|
58
|
+
description: 'Reads a text file in the project directory and returns its content. ' +
|
|
59
|
+
'Paths escaping the root are refused, including via symlink. ' +
|
|
60
|
+
`Content is truncated at ${MAX_READ_BYTES} bytes. Use nextOffset as the offset to continue reading.`,
|
|
61
|
+
parameters: {
|
|
62
|
+
type: 'object',
|
|
63
|
+
properties: {
|
|
64
|
+
path: {
|
|
65
|
+
type: 'string',
|
|
66
|
+
description: 'File path, relative to the project directory.',
|
|
67
|
+
},
|
|
68
|
+
maxBytes: {
|
|
69
|
+
type: 'number',
|
|
70
|
+
description: `Byte cap for this read. Defaults to ${MAX_READ_BYTES}.`,
|
|
71
|
+
},
|
|
72
|
+
offset: {
|
|
73
|
+
type: 'integer',
|
|
74
|
+
description: 'Starting byte position (default 0). Use nextOffset from the previous read.',
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
required: ['path'],
|
|
78
|
+
additionalProperties: false,
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
export const fileWriteDefinition = {
|
|
82
|
+
name: FILE_WRITE_TOOL_NAME,
|
|
83
|
+
description: 'Overwrites a file in the project directory (creates it if missing, auto-creates ' +
|
|
84
|
+
'parent directories). Paths escaping the root are refused. Replaces all old content.',
|
|
85
|
+
parameters: {
|
|
86
|
+
type: 'object',
|
|
87
|
+
properties: {
|
|
88
|
+
path: {
|
|
89
|
+
type: 'string',
|
|
90
|
+
description: 'File path, relative to the project directory.',
|
|
91
|
+
},
|
|
92
|
+
content: {
|
|
93
|
+
type: 'string',
|
|
94
|
+
description: 'New content. An empty string makes an empty file.',
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
required: ['path', 'content'],
|
|
98
|
+
additionalProperties: false,
|
|
99
|
+
},
|
|
100
|
+
};
|
|
101
|
+
export const fileEditDefinition = {
|
|
102
|
+
name: FILE_EDIT_TOOL_NAME,
|
|
103
|
+
description: 'Replaces a text span in a file. `oldText` must appear EXACTLY ONCE — ' +
|
|
104
|
+
'zero or multiple matches are refused to avoid editing the wrong spot.',
|
|
105
|
+
parameters: {
|
|
106
|
+
type: 'object',
|
|
107
|
+
properties: {
|
|
108
|
+
path: {
|
|
109
|
+
type: 'string',
|
|
110
|
+
description: 'File path, relative to the project directory.',
|
|
111
|
+
},
|
|
112
|
+
oldText: {
|
|
113
|
+
type: 'string',
|
|
114
|
+
description: 'Text span to replace. Must match exactly once.',
|
|
115
|
+
},
|
|
116
|
+
newText: {
|
|
117
|
+
type: 'string',
|
|
118
|
+
description: 'Replacement text.',
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
required: ['path', 'oldText', 'newText'],
|
|
122
|
+
additionalProperties: false,
|
|
123
|
+
},
|
|
124
|
+
};
|
|
125
|
+
export const fileGlobDefinition = {
|
|
126
|
+
name: FILE_GLOB_TOOL_NAME,
|
|
127
|
+
description: 'Lists files matching a glob pattern in THIS machine\'s PROJECT DIRECTORY — this is ' +
|
|
128
|
+
'how to find local files; do NOT use research.search for questions about files in the project. ' +
|
|
129
|
+
'Example "**/*.ts" or "src/*.json". ' +
|
|
130
|
+
'Supports `*` (one level), `**` (any depth), `?` (one character). ' +
|
|
131
|
+
`Returns at most ${MAX_GLOB_RESULTS} results. Skips node_modules, .git, dist, build, ` +
|
|
132
|
+
'coverage and minified files. Symlinks are not followed.',
|
|
133
|
+
parameters: {
|
|
134
|
+
type: 'object',
|
|
135
|
+
properties: {
|
|
136
|
+
pattern: {
|
|
137
|
+
type: 'string',
|
|
138
|
+
description: 'Glob pattern, e.g. "**/*.test.ts". Use "/" as the level separator.',
|
|
139
|
+
},
|
|
140
|
+
path: {
|
|
141
|
+
type: 'string',
|
|
142
|
+
description: 'Base directory to search, relative to the project directory. Defaults to the whole project.',
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
required: ['pattern'],
|
|
146
|
+
additionalProperties: false,
|
|
147
|
+
},
|
|
148
|
+
};
|
|
149
|
+
export const fileGrepDefinition = {
|
|
150
|
+
name: FILE_GREP_TOOL_NAME,
|
|
151
|
+
description: 'Finds lines matching a regular expression (JavaScript regex) in text ' +
|
|
152
|
+
'files under THIS machine\'s PROJECT DIRECTORY — this is how to search content in ' +
|
|
153
|
+
'local files; do NOT use research.search for questions about files in the project. ' +
|
|
154
|
+
'Returns "path:line: content". ' +
|
|
155
|
+
`Returns at most ${MAX_GREP_MATCHES} matching lines. Skips node_modules, .git, dist, ` +
|
|
156
|
+
`build, coverage, minified files and files larger than ${MAX_GREP_FILE_BYTES} bytes.`,
|
|
157
|
+
parameters: {
|
|
158
|
+
type: 'object',
|
|
159
|
+
properties: {
|
|
160
|
+
pattern: {
|
|
161
|
+
type: 'string',
|
|
162
|
+
description: 'JavaScript regular expression, e.g. "resolveWithin\\\\(".',
|
|
163
|
+
},
|
|
164
|
+
path: {
|
|
165
|
+
type: 'string',
|
|
166
|
+
description: 'Base directory to search, relative to the project directory. Defaults to the whole project.',
|
|
167
|
+
},
|
|
168
|
+
glob: {
|
|
169
|
+
type: 'string',
|
|
170
|
+
description: 'Additional glob filter, e.g. "**/*.ts".',
|
|
171
|
+
},
|
|
172
|
+
},
|
|
173
|
+
required: ['pattern'],
|
|
174
|
+
additionalProperties: false,
|
|
175
|
+
},
|
|
176
|
+
};
|
|
177
|
+
// ---------------------------------------------------------------------------
|
|
178
|
+
// Argument parsing — throws plain `Error`, the caller wraps it into a ToolResult.
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File tool operations — `file.read`, `file.write`, `file.edit` handlers.
|
|
3
|
+
*
|
|
4
|
+
* Single responsibility: the three single-file operations. Glob/grep live in
|
|
5
|
+
* `file-tool.ts`; shared parsing/traversal in `file-tool-scan.ts`.
|
|
6
|
+
*/
|
|
7
|
+
import { mkdir, open, readFile, stat, writeFile } from 'node:fs/promises';
|
|
8
|
+
import { dirname } from 'node:path';
|
|
9
|
+
import { resolveWithin } from '@boombot/sandbox';
|
|
10
|
+
import { MAX_READ_BYTES } from './file-tool-defs.js';
|
|
11
|
+
import { messageOf, optPosIntArg, strArg, textArg } from './file-tool-scan.js';
|
|
12
|
+
export function makeFail(call) {
|
|
13
|
+
return (message) => ({
|
|
14
|
+
callId: call.id,
|
|
15
|
+
name: call.name,
|
|
16
|
+
output: message,
|
|
17
|
+
error: true,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
export function makeOk(call) {
|
|
21
|
+
return (output) => ({
|
|
22
|
+
callId: call.id,
|
|
23
|
+
name: call.name,
|
|
24
|
+
output,
|
|
25
|
+
error: false,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
export async function executeRead(call, options) {
|
|
29
|
+
const fail = makeFail(call);
|
|
30
|
+
const ok = makeOk(call);
|
|
31
|
+
let target;
|
|
32
|
+
let maxBytes;
|
|
33
|
+
let offset;
|
|
34
|
+
try {
|
|
35
|
+
target = strArg(call.arguments, 'path');
|
|
36
|
+
maxBytes = Math.min(optPosIntArg(call.arguments, 'maxBytes') ?? MAX_READ_BYTES, options.maxReadBytes ?? MAX_READ_BYTES, MAX_READ_BYTES);
|
|
37
|
+
const rawOffset = call.arguments['offset'] ?? 0;
|
|
38
|
+
if (typeof rawOffset !== 'number' || !Number.isSafeInteger(rawOffset) || rawOffset < 0) {
|
|
39
|
+
throw new Error("'offset' must be a non-negative safe integer");
|
|
40
|
+
}
|
|
41
|
+
offset = rawOffset;
|
|
42
|
+
}
|
|
43
|
+
catch (err) {
|
|
44
|
+
return fail(`file.read: invalid arguments: ${messageOf(err)}`);
|
|
45
|
+
}
|
|
46
|
+
let abs;
|
|
47
|
+
try {
|
|
48
|
+
abs = await resolveWithin(options.workspaceRoot, target);
|
|
49
|
+
}
|
|
50
|
+
catch (err) {
|
|
51
|
+
return fail(`file.read refused: ${messageOf(err)}`);
|
|
52
|
+
}
|
|
53
|
+
try {
|
|
54
|
+
const info = await stat(abs);
|
|
55
|
+
if (!info.isFile()) {
|
|
56
|
+
return fail(`file.read refused: '${target}' is not a regular file`);
|
|
57
|
+
}
|
|
58
|
+
if (offset > info.size)
|
|
59
|
+
return fail(`file.read: offset is beyond the end (${info.size} bytes)`);
|
|
60
|
+
const want = Math.min(info.size - offset, maxBytes);
|
|
61
|
+
const handle = await open(abs, 'r');
|
|
62
|
+
let buf;
|
|
63
|
+
try {
|
|
64
|
+
buf = Buffer.alloc(want);
|
|
65
|
+
let total = 0;
|
|
66
|
+
while (total < want) {
|
|
67
|
+
const { bytesRead } = await handle.read(buf, total, want - total, offset + total);
|
|
68
|
+
if (bytesRead === 0)
|
|
69
|
+
break;
|
|
70
|
+
total += bytesRead;
|
|
71
|
+
}
|
|
72
|
+
buf = buf.subarray(0, total);
|
|
73
|
+
}
|
|
74
|
+
finally {
|
|
75
|
+
await handle.close();
|
|
76
|
+
}
|
|
77
|
+
if (buf.includes(0)) {
|
|
78
|
+
return ok(`file.read: '${target}' looks binary (${info.size} bytes) — not shown.`);
|
|
79
|
+
}
|
|
80
|
+
// Keep incomplete UTF-8 characters for the next page, including Vietnamese text.
|
|
81
|
+
const body = new TextDecoder('utf-8', { fatal: true, ignoreBOM: true }).decode(buf, {
|
|
82
|
+
stream: offset + buf.length < info.size,
|
|
83
|
+
});
|
|
84
|
+
if (buf.length > 0 && body.length === 0) {
|
|
85
|
+
return fail('file.read: maxBytes is too small for a UTF-8 character; use at least 4');
|
|
86
|
+
}
|
|
87
|
+
const nextOffset = offset + Buffer.byteLength(body, 'utf8');
|
|
88
|
+
const truncated = nextOffset < info.size;
|
|
89
|
+
const header = truncated
|
|
90
|
+
? `file.read: '${target}' — bytes ${offset}–${nextOffset} of ${info.size} (truncated; nextOffset=${nextOffset})`
|
|
91
|
+
: `file.read: '${target}' (${info.size} bytes)`;
|
|
92
|
+
return ok(`${header}\n---\n${body}`);
|
|
93
|
+
}
|
|
94
|
+
catch (err) {
|
|
95
|
+
return fail(`file.read failed: ${messageOf(err)}`);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
export async function executeWrite(call, options) {
|
|
99
|
+
const fail = makeFail(call);
|
|
100
|
+
const ok = makeOk(call);
|
|
101
|
+
let target;
|
|
102
|
+
let content;
|
|
103
|
+
try {
|
|
104
|
+
target = strArg(call.arguments, 'path');
|
|
105
|
+
content = textArg(call.arguments, 'content');
|
|
106
|
+
}
|
|
107
|
+
catch (err) {
|
|
108
|
+
return fail(`file.write: invalid arguments: ${messageOf(err)}`);
|
|
109
|
+
}
|
|
110
|
+
let abs;
|
|
111
|
+
try {
|
|
112
|
+
abs = await resolveWithin(options.workspaceRoot, target);
|
|
113
|
+
}
|
|
114
|
+
catch (err) {
|
|
115
|
+
return fail(`file.write refused: ${messageOf(err)}`);
|
|
116
|
+
}
|
|
117
|
+
try {
|
|
118
|
+
// Overwriting a directory would throw a cryptic EISDIR; say so upfront.
|
|
119
|
+
const existing = await stat(abs).catch(() => null);
|
|
120
|
+
if (existing?.isDirectory() === true) {
|
|
121
|
+
return fail(`file.write refused: '${target}' is a directory`);
|
|
122
|
+
}
|
|
123
|
+
await mkdir(dirname(abs), { recursive: true });
|
|
124
|
+
await writeFile(abs, content, 'utf8');
|
|
125
|
+
const bytes = Buffer.byteLength(content, 'utf8');
|
|
126
|
+
return ok(`file.write: '${target}' written (${bytes} bytes).`);
|
|
127
|
+
}
|
|
128
|
+
catch (err) {
|
|
129
|
+
return fail(`file.write failed: ${messageOf(err)}`);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
export async function executeEdit(call, options) {
|
|
133
|
+
const fail = makeFail(call);
|
|
134
|
+
const ok = makeOk(call);
|
|
135
|
+
let target;
|
|
136
|
+
let oldText;
|
|
137
|
+
let newText;
|
|
138
|
+
try {
|
|
139
|
+
target = strArg(call.arguments, 'path');
|
|
140
|
+
oldText = strArg(call.arguments, 'oldText');
|
|
141
|
+
newText = textArg(call.arguments, 'newText');
|
|
142
|
+
}
|
|
143
|
+
catch (err) {
|
|
144
|
+
return fail(`file.edit: invalid arguments: ${messageOf(err)}`);
|
|
145
|
+
}
|
|
146
|
+
let abs;
|
|
147
|
+
try {
|
|
148
|
+
abs = await resolveWithin(options.workspaceRoot, target);
|
|
149
|
+
}
|
|
150
|
+
catch (err) {
|
|
151
|
+
return fail(`file.edit refused: ${messageOf(err)}`);
|
|
152
|
+
}
|
|
153
|
+
try {
|
|
154
|
+
const info = await stat(abs);
|
|
155
|
+
if (!info.isFile()) {
|
|
156
|
+
return fail(`file.edit refused: '${target}' is not a regular file`);
|
|
157
|
+
}
|
|
158
|
+
const before = await readFile(abs, 'utf8');
|
|
159
|
+
// The match must be UNIQUE: 0 hits means wrong location, many means ambiguous.
|
|
160
|
+
// Both are refused rather than guessed — editing the wrong spot in a user's
|
|
161
|
+
// file is worse than an error.
|
|
162
|
+
const first = before.indexOf(oldText);
|
|
163
|
+
if (first === -1) {
|
|
164
|
+
return fail(`file.edit refused: oldText not found in '${target}'`);
|
|
165
|
+
}
|
|
166
|
+
if (before.indexOf(oldText, first + oldText.length) !== -1) {
|
|
167
|
+
return fail(`file.edit refused: oldText appears more than once in '${target}' — ` +
|
|
168
|
+
`include more surrounding context to make it unique.`);
|
|
169
|
+
}
|
|
170
|
+
const after = before.slice(0, first) + newText + before.slice(first + oldText.length);
|
|
171
|
+
await writeFile(abs, after, 'utf8');
|
|
172
|
+
const lineNo = before.slice(0, first).split('\n').length;
|
|
173
|
+
return ok(`file.edit: '${target}' updated at line ${lineNo}.`);
|
|
174
|
+
}
|
|
175
|
+
catch (err) {
|
|
176
|
+
return fail(`file.edit failed: ${messageOf(err)}`);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File tool scanning utilities — argument parsing, glob matching, and filesystem traversal.
|
|
3
|
+
*
|
|
4
|
+
* Single responsibility: pure helpers for finding files. No tool definitions
|
|
5
|
+
* (`file-tool-defs.ts`) and no tool execution (`file-tool.ts`) here.
|
|
6
|
+
* `walkFiles` is the shared traversal used by `file.glob` and `file.grep`.
|
|
7
|
+
*/
|
|
8
|
+
import { readdir, stat } from 'node:fs/promises';
|
|
9
|
+
import { join, relative, sep } from 'node:path';
|
|
10
|
+
import { resolveWithin } from '@boombot/sandbox';
|
|
11
|
+
import { MAX_WALK_ENTRIES, MINIFIED_FILE_RE, WALK_IGNORES, } from './file-tool-defs.js';
|
|
12
|
+
// ---------------------------------------------------------------------------
|
|
13
|
+
export function strArg(args, key) {
|
|
14
|
+
const v = args[key];
|
|
15
|
+
if (typeof v !== 'string' || v.length === 0) {
|
|
16
|
+
throw new Error(`'${key}' must be a non-empty string`);
|
|
17
|
+
}
|
|
18
|
+
return v;
|
|
19
|
+
}
|
|
20
|
+
/** Like `strArg` but allows empty strings (empty `content` is valid). */
|
|
21
|
+
export function textArg(args, key) {
|
|
22
|
+
const v = args[key];
|
|
23
|
+
if (typeof v !== 'string') {
|
|
24
|
+
throw new Error(`'${key}' must be a string`);
|
|
25
|
+
}
|
|
26
|
+
return v;
|
|
27
|
+
}
|
|
28
|
+
export function optStrArg(args, key) {
|
|
29
|
+
const v = args[key];
|
|
30
|
+
if (v === undefined)
|
|
31
|
+
return undefined;
|
|
32
|
+
if (typeof v !== 'string' || v.length === 0) {
|
|
33
|
+
throw new Error(`'${key}' must be a non-empty string when provided`);
|
|
34
|
+
}
|
|
35
|
+
return v;
|
|
36
|
+
}
|
|
37
|
+
export function optPosIntArg(args, key) {
|
|
38
|
+
const v = args[key];
|
|
39
|
+
if (v === undefined)
|
|
40
|
+
return undefined;
|
|
41
|
+
if (typeof v !== 'number' || !Number.isInteger(v) || v <= 0) {
|
|
42
|
+
throw new Error(`'${key}' must be a positive integer when provided`);
|
|
43
|
+
}
|
|
44
|
+
return v;
|
|
45
|
+
}
|
|
46
|
+
export function messageOf(err) {
|
|
47
|
+
return err instanceof Error ? err.message : 'unknown error';
|
|
48
|
+
}
|
|
49
|
+
// ---------------------------------------------------------------------------
|
|
50
|
+
// Glob
|
|
51
|
+
// ---------------------------------------------------------------------------
|
|
52
|
+
/**
|
|
53
|
+
* Translates a glob pattern to a doubly-anchored RegExp. `**` crosses levels,
|
|
54
|
+
* `*` stays within one level, `?` matches one character. Everything else is escaped.
|
|
55
|
+
*
|
|
56
|
+
* Note: a double star immediately before a separator becomes
|
|
57
|
+
* `(?:.*[/\\])?` — e.g. the pattern `**` + `/*.ts` matches both root-level `a.ts`
|
|
58
|
+
* and `src/a.ts`. That's the behavior users expect, not a bug.
|
|
59
|
+
*/
|
|
60
|
+
export function globToRegExp(pattern) {
|
|
61
|
+
let out = '';
|
|
62
|
+
for (let i = 0; i < pattern.length; i++) {
|
|
63
|
+
const ch = pattern[i];
|
|
64
|
+
if (ch === '*') {
|
|
65
|
+
if (pattern[i + 1] === '*') {
|
|
66
|
+
i++;
|
|
67
|
+
const after = pattern[i + 1];
|
|
68
|
+
if (after === '/' || after === '\\') {
|
|
69
|
+
i++;
|
|
70
|
+
out += '(?:.*[/\\\\])?';
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
out += '.*';
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
out += '[^/\\\\]*';
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
else if (ch === '?') {
|
|
81
|
+
out += '[^/\\\\]';
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
out += ch.replace(/[.+^${}()|[\]\\]/g, '\\$&');
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return new RegExp(`^${out}$`);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* The STATIC directory prefix of a glob pattern: the pattern's head up to the
|
|
91
|
+
* first wildcard, cut back to the last separator within it. This lets `walkFiles`
|
|
92
|
+
* skip subtrees that can't match — `src/**` only walks `src`.
|
|
93
|
+
*
|
|
94
|
+
* Returns `'.'` when nothing can be pruned (pattern starts with `*`, or is just
|
|
95
|
+
* a filename at the root). Being conservative is deliberate: a wrong prune
|
|
96
|
+
* would drop correct results.
|
|
97
|
+
*/
|
|
98
|
+
export function globStaticPrefix(pattern) {
|
|
99
|
+
// A pattern starting with a separator is never a valid prefix relative to root,
|
|
100
|
+
// and resolving it is meaningless (it might even escape root), so reject it outright.
|
|
101
|
+
if (pattern.startsWith('/') || pattern.startsWith('\\'))
|
|
102
|
+
return '.';
|
|
103
|
+
const wildcardAt = pattern.search(/[*?]/);
|
|
104
|
+
const literal = wildcardAt === -1 ? pattern : pattern.slice(0, wildcardAt);
|
|
105
|
+
const cut = Math.max(literal.lastIndexOf('/'), literal.lastIndexOf('\\'));
|
|
106
|
+
if (cut <= 0)
|
|
107
|
+
return '.';
|
|
108
|
+
return literal.slice(0, cut);
|
|
109
|
+
}
|
|
110
|
+
/** Normalizes relative paths to "/" so glob patterns use one separator style. */
|
|
111
|
+
function toPosix(p) {
|
|
112
|
+
return sep === '/' ? p : p.split(sep).join('/');
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Walks files under `base` (already inside root). Return `false` from `visit` to stop.
|
|
116
|
+
*
|
|
117
|
+
* Symlinks are skipped ENTIRELY, even ones pointing inside the root: following
|
|
118
|
+
* them would require per-step containment checks and opens infinite loops. This
|
|
119
|
+
* is a deliberate limitation, documented in the tool description.
|
|
120
|
+
*
|
|
121
|
+
* `ignore` prunes whole subtrees by entry name (see `WALK_IGNORES`): an ignored
|
|
122
|
+
* directory is never pushed onto the stack, so no extra `readdir` is spent. Minified
|
|
123
|
+
* files are also skipped because they have no readable content.
|
|
124
|
+
*/
|
|
125
|
+
export async function walkFiles(root, base, visit, ignore = WALK_IGNORES) {
|
|
126
|
+
const stack = [base];
|
|
127
|
+
let seen = 0;
|
|
128
|
+
while (stack.length > 0) {
|
|
129
|
+
const dir = stack.pop();
|
|
130
|
+
let entries;
|
|
131
|
+
try {
|
|
132
|
+
entries = await readdir(dir, { withFileTypes: true });
|
|
133
|
+
}
|
|
134
|
+
catch {
|
|
135
|
+
continue; // unreadable directory: skip it, don't fail the whole walk
|
|
136
|
+
}
|
|
137
|
+
for (const entry of entries) {
|
|
138
|
+
if (++seen > MAX_WALK_ENTRIES)
|
|
139
|
+
return;
|
|
140
|
+
if (ignore.has(entry.name))
|
|
141
|
+
continue;
|
|
142
|
+
const abs = join(dir, entry.name);
|
|
143
|
+
if (entry.isSymbolicLink())
|
|
144
|
+
continue;
|
|
145
|
+
if (entry.isDirectory()) {
|
|
146
|
+
stack.push(abs);
|
|
147
|
+
continue;
|
|
148
|
+
}
|
|
149
|
+
if (!entry.isFile())
|
|
150
|
+
continue;
|
|
151
|
+
if (MINIFIED_FILE_RE.test(entry.name))
|
|
152
|
+
continue;
|
|
153
|
+
const keepGoing = await visit({ abs, rel: toPosix(relative(root, abs)) });
|
|
154
|
+
if (!keepGoing)
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Start directory for a glob pattern: `relBase` joined with the pattern's static
|
|
161
|
+
* prefix (`globStaticPrefix`). Falls back to `absBase` — the resolved ABSOLUTE path —
|
|
162
|
+
* when nothing can be pruned, when the prefix isn't a directory, or when it points
|
|
163
|
+
* outside root. Pruning is only an optimization: it must never corrupt results, and
|
|
164
|
+
* must never widen the walk scope.
|
|
165
|
+
*/
|
|
166
|
+
export async function prunedBase(root, relBase, absBase, pattern) {
|
|
167
|
+
const prefix = globStaticPrefix(pattern);
|
|
168
|
+
if (prefix === '.')
|
|
169
|
+
return absBase;
|
|
170
|
+
const joined = relBase === '.' ? prefix : join(relBase, prefix);
|
|
171
|
+
try {
|
|
172
|
+
const candidate = await resolveWithin(root, joined);
|
|
173
|
+
const info = await stat(candidate);
|
|
174
|
+
return info.isDirectory() ? candidate : absBase;
|
|
175
|
+
}
|
|
176
|
+
catch {
|
|
177
|
+
return absBase;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
// ---------------------------------------------------------------------------
|
|
181
|
+
// Handler
|
|
182
|
+
// ---------------------------------------------------------------------------
|