@hcu-lab.me/mcp-device 1.0.9 → 1.0.12
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/PRIVACY.md +21 -0
- package/README.md +58 -3
- package/SECURITY.md +67 -0
- package/config/revoked-approvals.json +1 -0
- package/control-plane/config/mcp-servers.example.toml +52 -0
- package/control-plane/config/mcp-servers.toml +52 -0
- package/control-plane/contracts/device-public-contract-v1.json +733 -0
- package/control-plane/scripts/GATEWAY-LICENSE.txt +7 -0
- package/control-plane/scripts/account-http.mjs +220 -0
- package/control-plane/scripts/account-store.mjs +368 -0
- package/control-plane/scripts/admin.mjs +68 -0
- package/control-plane/scripts/auth-session.mjs +411 -0
- package/control-plane/scripts/authenticated-mcp-wrapper.mjs +1281 -0
- package/control-plane/scripts/benchmark-command.mjs +9 -0
- package/control-plane/scripts/benchmark-mcp-catalog.mjs +174 -0
- package/control-plane/scripts/catalog-budget.mjs +87 -0
- package/control-plane/scripts/check-device-public-contract.mjs +20 -0
- package/control-plane/scripts/custom-tools/index.mjs +221 -0
- package/control-plane/scripts/custom-tools/path-utils.mjs +117 -0
- package/control-plane/scripts/custom-tools/response-utils.mjs +34 -0
- package/control-plane/scripts/dashboard-http.mjs +598 -0
- package/control-plane/scripts/device-access-policy.mjs +205 -0
- package/control-plane/scripts/device-admin.mjs +43 -0
- package/control-plane/scripts/device-audit.mjs +63 -0
- package/control-plane/scripts/device-broker.mjs +1461 -0
- package/control-plane/scripts/device-execution-tool-definitions.mjs +217 -0
- package/control-plane/scripts/device-inventory.mjs +128 -0
- package/control-plane/scripts/device-pairing-http.mjs +109 -0
- package/control-plane/scripts/device-pairing-store.mjs +245 -0
- package/control-plane/scripts/device-public-contract.mjs +165 -0
- package/control-plane/scripts/device-release.mjs +95 -0
- package/control-plane/scripts/device-secure-transport.mjs +128 -0
- package/control-plane/scripts/device-store.mjs +283 -0
- package/control-plane/scripts/device-usage.mjs +657 -0
- package/control-plane/scripts/embedded-device.mjs +149 -0
- package/control-plane/scripts/enduser-ui.mjs +45 -0
- package/control-plane/scripts/external-tool-broker.mjs +179 -0
- package/control-plane/scripts/oauth-authorization-server.mjs +589 -0
- package/control-plane/scripts/operator-dashboard-http.mjs +81 -0
- package/control-plane/scripts/project-inspection.mjs +227 -0
- package/control-plane/scripts/projects/project-id.mjs +69 -0
- package/control-plane/scripts/projects/trusted-roots-projects.mjs +375 -0
- package/control-plane/scripts/prompts/index.mjs +60 -0
- package/control-plane/scripts/remote-process-sessions.mjs +78 -0
- package/control-plane/scripts/remote-tool-result.mjs +9 -0
- package/control-plane/scripts/resources/index.mjs +166 -0
- package/control-plane/scripts/runtime-profile.mjs +54 -0
- package/control-plane/scripts/shell-tool-descriptor.mjs +17 -0
- package/control-plane/scripts/skill-source-safety.mjs +46 -0
- package/control-plane/scripts/skills/README.md +70 -0
- package/control-plane/scripts/skills/_upstream_licenses/anthropic-THIRD_PARTY_NOTICES.md +405 -0
- package/control-plane/scripts/skills/_upstream_licenses/hallmark-LICENSE.txt +21 -0
- package/control-plane/scripts/skills/_upstream_licenses/ponytail-LICENSE.txt +21 -0
- package/control-plane/scripts/skills/_upstream_licenses/stitch-skills-LICENSE.txt +201 -0
- package/control-plane/scripts/skills/_upstream_licenses/superpowers-LICENSE.txt +21 -0
- package/control-plane/scripts/skills/algorithmic-art/LICENSE.txt +202 -0
- package/control-plane/scripts/skills/algorithmic-art/SKILL.md +405 -0
- package/control-plane/scripts/skills/algorithmic-art/templates/generator_template.js +223 -0
- package/control-plane/scripts/skills/algorithmic-art/templates/viewer.html +599 -0
- package/control-plane/scripts/skills/brainstorming/SKILL.md +285 -0
- package/control-plane/scripts/skills/brainstorming/scripts/frame-template.html +213 -0
- package/control-plane/scripts/skills/brainstorming/scripts/helper.js +167 -0
- package/control-plane/scripts/skills/brainstorming/scripts/server.cjs +723 -0
- package/control-plane/scripts/skills/brainstorming/scripts/start-server.sh +209 -0
- package/control-plane/scripts/skills/brainstorming/scripts/stop-server.sh +120 -0
- package/control-plane/scripts/skills/brainstorming/spec-document-reviewer-prompt.md +49 -0
- package/control-plane/scripts/skills/brainstorming/visual-companion.md +299 -0
- package/control-plane/scripts/skills/brand-guidelines/LICENSE.txt +202 -0
- package/control-plane/scripts/skills/brand-guidelines/SKILL.md +73 -0
- package/control-plane/scripts/skills/claude-api/LICENSE.txt +202 -0
- package/control-plane/scripts/skills/claude-api/SKILL.md +570 -0
- package/control-plane/scripts/skills/claude-api/csharp/claude-api/README.md +362 -0
- package/control-plane/scripts/skills/claude-api/csharp/claude-api/batches.md +14 -0
- package/control-plane/scripts/skills/claude-api/csharp/claude-api/files-api.md +25 -0
- package/control-plane/scripts/skills/claude-api/csharp/claude-api/streaming.md +28 -0
- package/control-plane/scripts/skills/claude-api/csharp/claude-api/tool-use.md +164 -0
- package/control-plane/scripts/skills/claude-api/curl/examples.md +256 -0
- package/control-plane/scripts/skills/claude-api/curl/managed-agents.md +371 -0
- package/control-plane/scripts/skills/claude-api/go/claude-api/README.md +188 -0
- package/control-plane/scripts/skills/claude-api/go/claude-api/files-api.md +23 -0
- package/control-plane/scripts/skills/claude-api/go/claude-api/streaming.md +43 -0
- package/control-plane/scripts/skills/claude-api/go/claude-api/tool-use.md +220 -0
- package/control-plane/scripts/skills/claude-api/go/managed-agents/README.md +564 -0
- package/control-plane/scripts/skills/claude-api/java/claude-api/README.md +238 -0
- package/control-plane/scripts/skills/claude-api/java/claude-api/files-api.md +27 -0
- package/control-plane/scripts/skills/claude-api/java/claude-api/streaming.md +24 -0
- package/control-plane/scripts/skills/claude-api/java/claude-api/tool-use.md +228 -0
- package/control-plane/scripts/skills/claude-api/java/managed-agents/README.md +443 -0
- package/control-plane/scripts/skills/claude-api/php/claude-api/README.md +174 -0
- package/control-plane/scripts/skills/claude-api/php/claude-api/batches.md +15 -0
- package/control-plane/scripts/skills/claude-api/php/claude-api/files-api.md +13 -0
- package/control-plane/scripts/skills/claude-api/php/claude-api/streaming.md +27 -0
- package/control-plane/scripts/skills/claude-api/php/claude-api/tool-use.md +253 -0
- package/control-plane/scripts/skills/claude-api/php/managed-agents/README.md +443 -0
- package/control-plane/scripts/skills/claude-api/python/claude-api/README.md +565 -0
- package/control-plane/scripts/skills/claude-api/python/claude-api/batches.md +198 -0
- package/control-plane/scripts/skills/claude-api/python/claude-api/files-api.md +170 -0
- package/control-plane/scripts/skills/claude-api/python/claude-api/sdk-upgrade.md +286 -0
- package/control-plane/scripts/skills/claude-api/python/claude-api/streaming.md +179 -0
- package/control-plane/scripts/skills/claude-api/python/claude-api/tool-use.md +627 -0
- package/control-plane/scripts/skills/claude-api/python/managed-agents/README.md +335 -0
- package/control-plane/scripts/skills/claude-api/ruby/claude-api/README.md +134 -0
- package/control-plane/scripts/skills/claude-api/ruby/claude-api/streaming.md +16 -0
- package/control-plane/scripts/skills/claude-api/ruby/claude-api/tool-use.md +41 -0
- package/control-plane/scripts/skills/claude-api/ruby/managed-agents/README.md +394 -0
- package/control-plane/scripts/skills/claude-api/shared/admin-api.md +179 -0
- package/control-plane/scripts/skills/claude-api/shared/agent-design.md +101 -0
- package/control-plane/scripts/skills/claude-api/shared/anthropic-cli.md +269 -0
- package/control-plane/scripts/skills/claude-api/shared/claude-platform-on-aws.md +59 -0
- package/control-plane/scripts/skills/claude-api/shared/cost-optimization.md +233 -0
- package/control-plane/scripts/skills/claude-api/shared/error-codes.md +262 -0
- package/control-plane/scripts/skills/claude-api/shared/live-sources.md +166 -0
- package/control-plane/scripts/skills/claude-api/shared/managed-agents-api-reference.md +455 -0
- package/control-plane/scripts/skills/claude-api/shared/managed-agents-client-patterns.md +220 -0
- package/control-plane/scripts/skills/claude-api/shared/managed-agents-core.md +359 -0
- package/control-plane/scripts/skills/claude-api/shared/managed-agents-environments.md +226 -0
- package/control-plane/scripts/skills/claude-api/shared/managed-agents-events.md +290 -0
- package/control-plane/scripts/skills/claude-api/shared/managed-agents-memory.md +201 -0
- package/control-plane/scripts/skills/claude-api/shared/managed-agents-multiagent.md +260 -0
- package/control-plane/scripts/skills/claude-api/shared/managed-agents-onboarding.md +82 -0
- package/control-plane/scripts/skills/claude-api/shared/managed-agents-outcomes.md +108 -0
- package/control-plane/scripts/skills/claude-api/shared/managed-agents-overview.md +77 -0
- package/control-plane/scripts/skills/claude-api/shared/managed-agents-scheduled-deployments.md +156 -0
- package/control-plane/scripts/skills/claude-api/shared/managed-agents-self-hosted-sandboxes.md +282 -0
- package/control-plane/scripts/skills/claude-api/shared/managed-agents-tools.md +504 -0
- package/control-plane/scripts/skills/claude-api/shared/managed-agents-webhooks.md +143 -0
- package/control-plane/scripts/skills/claude-api/shared/model-migration.md +1872 -0
- package/control-plane/scripts/skills/claude-api/shared/models.md +142 -0
- package/control-plane/scripts/skills/claude-api/shared/platform-availability.md +52 -0
- package/control-plane/scripts/skills/claude-api/shared/prompt-audit.md +223 -0
- package/control-plane/scripts/skills/claude-api/shared/prompt-caching.md +292 -0
- package/control-plane/scripts/skills/claude-api/shared/token-counting.md +56 -0
- package/control-plane/scripts/skills/claude-api/shared/tool-use-concepts.md +526 -0
- package/control-plane/scripts/skills/claude-api/typescript/claude-api/README.md +405 -0
- package/control-plane/scripts/skills/claude-api/typescript/claude-api/batches.md +106 -0
- package/control-plane/scripts/skills/claude-api/typescript/claude-api/files-api.md +98 -0
- package/control-plane/scripts/skills/claude-api/typescript/claude-api/streaming.md +178 -0
- package/control-plane/scripts/skills/claude-api/typescript/claude-api/tool-use.md +586 -0
- package/control-plane/scripts/skills/claude-api/typescript/managed-agents/README.md +359 -0
- package/control-plane/scripts/skills/dispatching-parallel-agents/SKILL.md +167 -0
- package/control-plane/scripts/skills/enhance-prompt/README.md +34 -0
- package/control-plane/scripts/skills/enhance-prompt/SKILL.md +204 -0
- package/control-plane/scripts/skills/enhance-prompt/references/KEYWORDS.md +114 -0
- package/control-plane/scripts/skills/executing-plans/SKILL.md +371 -0
- package/control-plane/scripts/skills/executing-plans/scripts/task-done +52 -0
- package/control-plane/scripts/skills/executing-plans/scripts/task-start +28 -0
- package/control-plane/scripts/skills/extract-design-md/SKILL.md +358 -0
- package/control-plane/scripts/skills/extract-design-md/examples/DESIGN.md +210 -0
- package/control-plane/scripts/skills/extract-design-md/references/angular.md +122 -0
- package/control-plane/scripts/skills/extract-design-md/references/plain-css.md +161 -0
- package/control-plane/scripts/skills/extract-design-md/references/react-tailwind.md +157 -0
- package/control-plane/scripts/skills/extract-design-md/references/svelte.md +101 -0
- package/control-plane/scripts/skills/extract-design-md/references/vue.md +107 -0
- package/control-plane/scripts/skills/finishing-a-development-branch/SKILL.md +225 -0
- package/control-plane/scripts/skills/frontend-design/LICENSE.txt +177 -0
- package/control-plane/scripts/skills/frontend-design/SKILL.md +71 -0
- package/control-plane/scripts/skills/hallmark/SKILL.md +558 -0
- package/control-plane/scripts/skills/hallmark/references/anti-patterns.md +418 -0
- package/control-plane/scripts/skills/hallmark/references/assets.md +406 -0
- package/control-plane/scripts/skills/hallmark/references/color.md +95 -0
- package/control-plane/scripts/skills/hallmark/references/component-cookbook.md +263 -0
- package/control-plane/scripts/skills/hallmark/references/components/c1-outlined-chip.md +12 -0
- package/control-plane/scripts/skills/hallmark/references/components/c2-inline-form-as-cta.md +16 -0
- package/control-plane/scripts/skills/hallmark/references/components/c3-typographic-link.md +8 -0
- package/control-plane/scripts/skills/hallmark/references/components/c4-sticky-bottom-bar.md +16 -0
- package/control-plane/scripts/skills/hallmark/references/components/f1-bento-grid.md +20 -0
- package/control-plane/scripts/skills/hallmark/references/components/f2-sticky-scroll-stack.md +20 -0
- package/control-plane/scripts/skills/hallmark/references/components/f3-tabular-spec-sheet.md +11 -0
- package/control-plane/scripts/skills/hallmark/references/components/f4-step-sequence.md +11 -0
- package/control-plane/scripts/skills/hallmark/references/components/f5-annotated-screenshot.md +11 -0
- package/control-plane/scripts/skills/hallmark/references/components/f6-product-card-grid.md +41 -0
- package/control-plane/scripts/skills/hallmark/references/components/ft1-mast-headed.md +13 -0
- package/control-plane/scripts/skills/hallmark/references/components/ft2-inline-rule-single-line.md +10 -0
- package/control-plane/scripts/skills/hallmark/references/components/ft3-index-style-category-list.md +12 -0
- package/control-plane/scripts/skills/hallmark/references/components/ft4-dense-typographic.md +10 -0
- package/control-plane/scripts/skills/hallmark/references/components/ft5-statement.md +21 -0
- package/control-plane/scripts/skills/hallmark/references/components/ft6-letter-close.md +19 -0
- package/control-plane/scripts/skills/hallmark/references/components/ft7-newsletter-first.md +27 -0
- package/control-plane/scripts/skills/hallmark/references/components/ft8-marquee-scroll.md +25 -0
- package/control-plane/scripts/skills/hallmark/references/components/h1-marquee.md +15 -0
- package/control-plane/scripts/skills/hallmark/references/components/h2-split-diptych.md +15 -0
- package/control-plane/scripts/skills/hallmark/references/components/h3-quote-led.md +11 -0
- package/control-plane/scripts/skills/hallmark/references/components/h4-stat-led.md +14 -0
- package/control-plane/scripts/skills/hallmark/references/components/h5-letter-hero.md +11 -0
- package/control-plane/scripts/skills/hallmark/references/components/h6-photographic-fold.md +16 -0
- package/control-plane/scripts/skills/hallmark/references/components/h7-demo-video-clipped-by-viewport-edge.md +27 -0
- package/control-plane/scripts/skills/hallmark/references/components/h8-mockup-split-browser-framed.md +23 -0
- package/control-plane/scripts/skills/hallmark/references/components/h9-custom-illustration-centerpiece.md +27 -0
- package/control-plane/scripts/skills/hallmark/references/components/n1-wordmark-2-links.md +12 -0
- package/control-plane/scripts/skills/hallmark/references/components/n10-floating-on-scroll-morph.md +19 -0
- package/control-plane/scripts/skills/hallmark/references/components/n11-mega-menu.md +40 -0
- package/control-plane/scripts/skills/hallmark/references/components/n12-banner-retract.md +34 -0
- package/control-plane/scripts/skills/hallmark/references/components/n13-inline-cmdk-pill.md +39 -0
- package/control-plane/scripts/skills/hallmark/references/components/n1b-saas-three-section.md +35 -0
- package/control-plane/scripts/skills/hallmark/references/components/n2-floating-chip.md +14 -0
- package/control-plane/scripts/skills/hallmark/references/components/n3-side-rail.md +14 -0
- package/control-plane/scripts/skills/hallmark/references/components/n4-hidden-behind-k.md +9 -0
- package/control-plane/scripts/skills/hallmark/references/components/n5-floating-pill.md +28 -0
- package/control-plane/scripts/skills/hallmark/references/components/n6-newspaper-masthead.md +24 -0
- package/control-plane/scripts/skills/hallmark/references/components/n7-brutal-slab.md +22 -0
- package/control-plane/scripts/skills/hallmark/references/components/n8-terminal-command.md +21 -0
- package/control-plane/scripts/skills/hallmark/references/components/n9-edge-aligned-minimal.md +17 -0
- package/control-plane/scripts/skills/hallmark/references/components/s1-left-margin-numbered.md +15 -0
- package/control-plane/scripts/skills/hallmark/references/components/s2-hanging.md +13 -0
- package/control-plane/scripts/skills/hallmark/references/components/s3-sticky-pinned.md +19 -0
- package/control-plane/scripts/skills/hallmark/references/components/s4-inline-no-break.md +11 -0
- package/control-plane/scripts/skills/hallmark/references/components/s5-bottom-anchored.md +13 -0
- package/control-plane/scripts/skills/hallmark/references/components/t1-pull-quote-with-marginalia.md +12 -0
- package/control-plane/scripts/skills/hallmark/references/components/t2-logo-wall-hairline.md +19 -0
- package/control-plane/scripts/skills/hallmark/references/components/t3-single-huge-quote.md +11 -0
- package/control-plane/scripts/skills/hallmark/references/components/t4-numbered-stat-strip.md +14 -0
- package/control-plane/scripts/skills/hallmark/references/contract.md +25 -0
- package/control-plane/scripts/skills/hallmark/references/copy.md +182 -0
- package/control-plane/scripts/skills/hallmark/references/custom-craft.md +626 -0
- package/control-plane/scripts/skills/hallmark/references/custom-theme.md +367 -0
- package/control-plane/scripts/skills/hallmark/references/design-md.md +116 -0
- package/control-plane/scripts/skills/hallmark/references/export-formats.md +329 -0
- package/control-plane/scripts/skills/hallmark/references/floating-nav.md +89 -0
- package/control-plane/scripts/skills/hallmark/references/genres/atmospheric.md +69 -0
- package/control-plane/scripts/skills/hallmark/references/genres/editorial.md +72 -0
- package/control-plane/scripts/skills/hallmark/references/genres/modern-minimal.md +71 -0
- package/control-plane/scripts/skills/hallmark/references/genres/playful.md +70 -0
- package/control-plane/scripts/skills/hallmark/references/hero-enrichment.md +475 -0
- package/control-plane/scripts/skills/hallmark/references/imagery-kit.md +170 -0
- package/control-plane/scripts/skills/hallmark/references/interaction-and-states.md +208 -0
- package/control-plane/scripts/skills/hallmark/references/layout-and-space.md +112 -0
- package/control-plane/scripts/skills/hallmark/references/macrostructures/01-bento-grid.md +35 -0
- package/control-plane/scripts/skills/hallmark/references/macrostructures/02-long-document.md +34 -0
- package/control-plane/scripts/skills/hallmark/references/macrostructures/03-marquee-hero.md +31 -0
- package/control-plane/scripts/skills/hallmark/references/macrostructures/04-stat-led.md +34 -0
- package/control-plane/scripts/skills/hallmark/references/macrostructures/05-workbench.md +32 -0
- package/control-plane/scripts/skills/hallmark/references/macrostructures/06-conversational-faq.md +33 -0
- package/control-plane/scripts/skills/hallmark/references/macrostructures/07-manifesto.md +32 -0
- package/control-plane/scripts/skills/hallmark/references/macrostructures/08-photographic.md +34 -0
- package/control-plane/scripts/skills/hallmark/references/macrostructures/09-quote-led.md +32 -0
- package/control-plane/scripts/skills/hallmark/references/macrostructures/10-specimen.md +32 -0
- package/control-plane/scripts/skills/hallmark/references/macrostructures/11-catalogue.md +23 -0
- package/control-plane/scripts/skills/hallmark/references/macrostructures/12-letter.md +23 -0
- package/control-plane/scripts/skills/hallmark/references/macrostructures/13-index-first.md +23 -0
- package/control-plane/scripts/skills/hallmark/references/macrostructures/14-narrative-workflow.md +23 -0
- package/control-plane/scripts/skills/hallmark/references/macrostructures/15-split-studio.md +23 -0
- package/control-plane/scripts/skills/hallmark/references/macrostructures/16-feature-stack.md +23 -0
- package/control-plane/scripts/skills/hallmark/references/macrostructures/17-type-specimen.md +23 -0
- package/control-plane/scripts/skills/hallmark/references/macrostructures/18-portfolio-grid.md +23 -0
- package/control-plane/scripts/skills/hallmark/references/macrostructures/19-map-diagram.md +23 -0
- package/control-plane/scripts/skills/hallmark/references/macrostructures/20-ecosystem-index.md +23 -0
- package/control-plane/scripts/skills/hallmark/references/macrostructures/21-component-playground.md +23 -0
- package/control-plane/scripts/skills/hallmark/references/macrostructures.md +89 -0
- package/control-plane/scripts/skills/hallmark/references/microinteractions.md +258 -0
- package/control-plane/scripts/skills/hallmark/references/motion.md +109 -0
- package/control-plane/scripts/skills/hallmark/references/preview-examples.md +49 -0
- package/control-plane/scripts/skills/hallmark/references/responsive.md +138 -0
- package/control-plane/scripts/skills/hallmark/references/slop-test.md +192 -0
- package/control-plane/scripts/skills/hallmark/references/structure.md +160 -0
- package/control-plane/scripts/skills/hallmark/references/study.md +509 -0
- package/control-plane/scripts/skills/hallmark/references/themes/carnival.md +301 -0
- package/control-plane/scripts/skills/hallmark/references/themes/cobalt.md +146 -0
- package/control-plane/scripts/skills/hallmark/references/themes/grid.md +161 -0
- package/control-plane/scripts/skills/hallmark/references/themes/hum.md +403 -0
- package/control-plane/scripts/skills/hallmark/references/themes/lumen.md +478 -0
- package/control-plane/scripts/skills/hallmark/references/typography.md +243 -0
- package/control-plane/scripts/skills/hallmark/references/upstream/recipes.md +186 -0
- package/control-plane/scripts/skills/hallmark/references/upstream/study-examples.md +176 -0
- package/control-plane/scripts/skills/hallmark/references/upstream/tokens.css +1221 -0
- package/control-plane/scripts/skills/hallmark/references/verbs/audit.md +25 -0
- package/control-plane/scripts/skills/hallmark/references/verbs/redesign.md +269 -0
- package/control-plane/scripts/skills/human-comms/SKILL.md +29 -0
- package/control-plane/scripts/skills/index.mjs +432 -0
- package/control-plane/scripts/skills/internal-comms/LICENSE.txt +202 -0
- package/control-plane/scripts/skills/internal-comms/SKILL.md +32 -0
- package/control-plane/scripts/skills/internal-comms/examples/3p-updates.md +47 -0
- package/control-plane/scripts/skills/internal-comms/examples/company-newsletter.md +65 -0
- package/control-plane/scripts/skills/internal-comms/examples/faq-answers.md +30 -0
- package/control-plane/scripts/skills/internal-comms/examples/general-comms.md +16 -0
- package/control-plane/scripts/skills/mcp-adapter.mjs +94 -0
- package/control-plane/scripts/skills/mcp-builder/LICENSE.txt +202 -0
- package/control-plane/scripts/skills/mcp-builder/SKILL.md +236 -0
- package/control-plane/scripts/skills/mcp-builder/reference/evaluation.md +602 -0
- package/control-plane/scripts/skills/mcp-builder/reference/mcp_best_practices.md +249 -0
- package/control-plane/scripts/skills/mcp-builder/reference/node_mcp_server.md +970 -0
- package/control-plane/scripts/skills/mcp-builder/reference/python_mcp_server.md +719 -0
- package/control-plane/scripts/skills/mcp-builder/scripts/connections.py +151 -0
- package/control-plane/scripts/skills/mcp-builder/scripts/evaluation.py +373 -0
- package/control-plane/scripts/skills/mcp-builder/scripts/example_evaluation.xml +22 -0
- package/control-plane/scripts/skills/mcp-builder/scripts/requirements.txt +2 -0
- package/control-plane/scripts/skills/ponytail/SKILL.md +120 -0
- package/control-plane/scripts/skills/ponytail-audit/SKILL.md +41 -0
- package/control-plane/scripts/skills/ponytail-debt/SKILL.md +44 -0
- package/control-plane/scripts/skills/ponytail-gain/SKILL.md +50 -0
- package/control-plane/scripts/skills/ponytail-help/SKILL.md +71 -0
- package/control-plane/scripts/skills/ponytail-review/SKILL.md +57 -0
- package/control-plane/scripts/skills/receiving-code-review/SKILL.md +205 -0
- package/control-plane/scripts/skills/requesting-code-review/SKILL.md +95 -0
- package/control-plane/scripts/skills/requesting-code-review/code-reviewer.md +198 -0
- package/control-plane/scripts/skills/skill-creator/LICENSE.txt +202 -0
- package/control-plane/scripts/skills/skill-creator/SKILL.md +485 -0
- package/control-plane/scripts/skills/skill-creator/agents/analyzer.md +274 -0
- package/control-plane/scripts/skills/skill-creator/agents/comparator.md +202 -0
- package/control-plane/scripts/skills/skill-creator/agents/grader.md +223 -0
- package/control-plane/scripts/skills/skill-creator/assets/eval_review.html +146 -0
- package/control-plane/scripts/skills/skill-creator/eval-viewer/generate_review.py +471 -0
- package/control-plane/scripts/skills/skill-creator/eval-viewer/viewer.html +1325 -0
- package/control-plane/scripts/skills/skill-creator/references/schemas.md +430 -0
- package/control-plane/scripts/skills/skill-creator/scripts/__init__.py +0 -0
- package/control-plane/scripts/skills/skill-creator/scripts/aggregate_benchmark.py +401 -0
- package/control-plane/scripts/skills/skill-creator/scripts/generate_report.py +326 -0
- package/control-plane/scripts/skills/skill-creator/scripts/improve_description.py +247 -0
- package/control-plane/scripts/skills/skill-creator/scripts/package_skill.py +136 -0
- package/control-plane/scripts/skills/skill-creator/scripts/quick_validate.py +103 -0
- package/control-plane/scripts/skills/skill-creator/scripts/run_eval.py +310 -0
- package/control-plane/scripts/skills/skill-creator/scripts/run_loop.py +328 -0
- package/control-plane/scripts/skills/skill-creator/scripts/utils.py +47 -0
- package/control-plane/scripts/skills/slack-gif-creator/LICENSE.txt +202 -0
- package/control-plane/scripts/skills/slack-gif-creator/SKILL.md +254 -0
- package/control-plane/scripts/skills/slack-gif-creator/core/easing.py +234 -0
- package/control-plane/scripts/skills/slack-gif-creator/core/frame_composer.py +176 -0
- package/control-plane/scripts/skills/slack-gif-creator/core/gif_builder.py +269 -0
- package/control-plane/scripts/skills/slack-gif-creator/core/validators.py +136 -0
- package/control-plane/scripts/skills/slack-gif-creator/requirements.txt +4 -0
- package/control-plane/scripts/skills/sources.json +401 -0
- package/control-plane/scripts/skills/sources.lock.json +416 -0
- package/control-plane/scripts/skills/subagent-driven-development/SKILL.md +570 -0
- package/control-plane/scripts/skills/subagent-driven-development/implementer-prompt.md +154 -0
- package/control-plane/scripts/skills/subagent-driven-development/re-review-prompt.md +115 -0
- package/control-plane/scripts/skills/subagent-driven-development/scripts/review-package +53 -0
- package/control-plane/scripts/skills/subagent-driven-development/scripts/sdd-workspace +82 -0
- package/control-plane/scripts/skills/subagent-driven-development/scripts/task-brief +43 -0
- package/control-plane/scripts/skills/subagent-driven-development/task-reviewer-prompt.md +207 -0
- package/control-plane/scripts/skills/systematic-debugging/CREATION-LOG.md +119 -0
- package/control-plane/scripts/skills/systematic-debugging/SKILL.md +283 -0
- package/control-plane/scripts/skills/systematic-debugging/condition-based-waiting-example.ts +158 -0
- package/control-plane/scripts/skills/systematic-debugging/condition-based-waiting.md +115 -0
- package/control-plane/scripts/skills/systematic-debugging/defense-in-depth.md +122 -0
- package/control-plane/scripts/skills/systematic-debugging/find-polluter.sh +72 -0
- package/control-plane/scripts/skills/systematic-debugging/root-cause-tracing.md +169 -0
- package/control-plane/scripts/skills/systematic-debugging/test-academic.md +14 -0
- package/control-plane/scripts/skills/systematic-debugging/test-pressure-1.md +58 -0
- package/control-plane/scripts/skills/systematic-debugging/test-pressure-2.md +68 -0
- package/control-plane/scripts/skills/systematic-debugging/test-pressure-3.md +69 -0
- package/control-plane/scripts/skills/test-driven-development/SKILL.md +330 -0
- package/control-plane/scripts/skills/test-driven-development/writing-good-tests.md +198 -0
- package/control-plane/scripts/skills/theme-factory/LICENSE.txt +202 -0
- package/control-plane/scripts/skills/theme-factory/SKILL.md +59 -0
- package/control-plane/scripts/skills/theme-factory/theme-showcase.pdf +0 -0
- package/control-plane/scripts/skills/theme-factory/themes/arctic-frost.md +19 -0
- package/control-plane/scripts/skills/theme-factory/themes/botanical-garden.md +19 -0
- package/control-plane/scripts/skills/theme-factory/themes/desert-rose.md +19 -0
- package/control-plane/scripts/skills/theme-factory/themes/forest-canopy.md +19 -0
- package/control-plane/scripts/skills/theme-factory/themes/golden-hour.md +19 -0
- package/control-plane/scripts/skills/theme-factory/themes/midnight-galaxy.md +19 -0
- package/control-plane/scripts/skills/theme-factory/themes/modern-minimalist.md +19 -0
- package/control-plane/scripts/skills/theme-factory/themes/ocean-depths.md +19 -0
- package/control-plane/scripts/skills/theme-factory/themes/sunset-boulevard.md +19 -0
- package/control-plane/scripts/skills/theme-factory/themes/tech-innovation.md +19 -0
- package/control-plane/scripts/skills/using-git-worktrees/SKILL.md +167 -0
- package/control-plane/scripts/skills/verification-before-completion/SKILL.md +120 -0
- package/control-plane/scripts/skills/web-artifacts-builder/LICENSE.txt +202 -0
- package/control-plane/scripts/skills/web-artifacts-builder/SKILL.md +74 -0
- package/control-plane/scripts/skills/web-artifacts-builder/scripts/bundle-artifact.sh +54 -0
- package/control-plane/scripts/skills/web-artifacts-builder/scripts/init-artifact.sh +322 -0
- package/control-plane/scripts/skills/web-artifacts-builder/scripts/shadcn-components.tar.gz +0 -0
- package/control-plane/scripts/skills/webapp-testing/LICENSE.txt +202 -0
- package/control-plane/scripts/skills/webapp-testing/SKILL.md +96 -0
- package/control-plane/scripts/skills/webapp-testing/examples/console_logging.py +35 -0
- package/control-plane/scripts/skills/webapp-testing/examples/element_discovery.py +40 -0
- package/control-plane/scripts/skills/webapp-testing/examples/static_html_automation.py +33 -0
- package/control-plane/scripts/skills/webapp-testing/scripts/with_server.py +106 -0
- package/control-plane/scripts/skills/writing-plans/SKILL.md +192 -0
- package/control-plane/scripts/skills/writing-plans/plan-document-reviewer-prompt.md +49 -0
- package/control-plane/scripts/skills/writing-skills/SKILL.md +681 -0
- package/control-plane/scripts/skills/writing-skills/anthropic-best-practices.md +1150 -0
- package/control-plane/scripts/skills/writing-skills/examples/CLAUDE_MD_TESTING.md +189 -0
- package/control-plane/scripts/skills/writing-skills/graphviz-conventions.dot +172 -0
- package/control-plane/scripts/skills/writing-skills/persuasion-principles.md +187 -0
- package/control-plane/scripts/skills/writing-skills/render-graphs.js +169 -0
- package/control-plane/scripts/skills/writing-skills/testing-skills-with-subagents.md +384 -0
- package/control-plane/scripts/smoke-mcp-schemas.mjs +30 -0
- package/control-plane/scripts/surface-config.mjs +45 -0
- package/control-plane/scripts/sync-skills.mjs +370 -0
- package/control-plane/scripts/tool-metrics.mjs +74 -0
- package/control-plane/scripts/tool-risk.mjs +156 -0
- package/control-plane/scripts/tool-surface-stability.mjs +38 -0
- package/control-plane/scripts/upstreams/catalog-cache.mjs +28 -0
- package/control-plane/scripts/upstreams/config.mjs +158 -0
- package/control-plane/scripts/upstreams/diagnostics.mjs +21 -0
- package/control-plane/scripts/upstreams/http-client.mjs +67 -0
- package/control-plane/scripts/upstreams/manager.mjs +535 -0
- package/control-plane/scripts/upstreams/names.mjs +55 -0
- package/control-plane/scripts/upstreams/presets.mjs +60 -0
- package/control-plane/scripts/upstreams/resource-uri.mjs +29 -0
- package/control-plane/scripts/upstreams/stdio-client.mjs +73 -0
- package/control-plane/scripts/workspace-registry.mjs +147 -0
- package/dist/context/authorization.d.ts +5 -0
- package/dist/context/authorization.js +70 -0
- package/dist/context/capture.d.ts +46 -0
- package/dist/context/capture.js +187 -0
- package/dist/context/cli.d.ts +47 -0
- package/dist/context/cli.js +287 -0
- package/dist/context/device-adapter.d.ts +102 -0
- package/dist/context/device-adapter.js +79 -0
- package/dist/context/gateway.d.ts +354 -0
- package/dist/context/gateway.js +50 -0
- package/dist/context/graph.d.ts +63 -0
- package/dist/context/graph.js +214 -0
- package/dist/context/importer.d.ts +8 -0
- package/dist/context/importer.js +69 -0
- package/dist/context/indexer.d.ts +14 -0
- package/dist/context/indexer.js +57 -0
- package/dist/context/migrations/index.d.ts +4 -0
- package/dist/context/migrations/index.js +87 -0
- package/dist/context/redact.d.ts +15 -0
- package/dist/context/redact.js +43 -0
- package/dist/context/repositories.d.ts +9 -0
- package/dist/context/repositories.js +45 -0
- package/dist/context/search.d.ts +63 -0
- package/dist/context/search.js +207 -0
- package/dist/context/service.d.ts +278 -0
- package/dist/context/service.js +160 -0
- package/dist/context/store.d.ts +134 -0
- package/dist/context/store.js +722 -0
- package/dist/context/text.d.ts +4 -0
- package/dist/context/text.js +14 -0
- package/dist/context/tool-contract.d.ts +534 -0
- package/dist/context/tool-contract.js +45 -0
- package/dist/device/core.d.ts +29 -0
- package/dist/device/core.js +66 -0
- package/dist/device/device.d.ts +5 -0
- package/dist/device/device.js +94 -37
- package/dist/device/gateway-channel.d.ts +8 -1
- package/dist/device/gateway-channel.js +51 -3
- package/dist/device/gateway-tool-adapter.d.ts +11 -3
- package/dist/device/gateway-tool-adapter.js +141 -98
- package/dist/device/official-trust.d.ts +12 -0
- package/dist/device/official-trust.js +25 -1
- package/dist/device/runtime-owner.js +9 -1
- package/dist/distribution.d.ts +4 -0
- package/dist/distribution.js +8 -0
- package/dist/handlers/filesystem-handlers.js +53 -37
- package/dist/handlers/search-handlers.d.ts +1 -0
- package/dist/handlers/search-handlers.js +51 -1
- package/dist/log-palace/cli.d.ts +7 -0
- package/dist/log-palace/cli.js +89 -0
- package/dist/log-palace/formats.d.ts +26 -0
- package/dist/log-palace/formats.js +126 -0
- package/dist/log-palace/store.d.ts +129 -0
- package/dist/log-palace/store.js +856 -0
- package/dist/mcp-device.d.ts +1 -1
- package/dist/mcp-device.js +28 -6
- package/dist/npm-scripts/remote.js +1 -0
- package/dist/platform/activity-journal.d.ts +16 -0
- package/dist/platform/activity-journal.js +68 -0
- package/dist/platform/cli.d.ts +1 -0
- package/dist/platform/cli.js +300 -0
- package/dist/platform/coordination-lock.d.ts +45 -0
- package/dist/platform/coordination-lock.js +233 -0
- package/dist/platform/device-runtime.d.ts +16 -0
- package/dist/platform/device-runtime.js +83 -0
- package/dist/platform/knowledge-contract.d.ts +46 -0
- package/dist/platform/knowledge-contract.js +1 -0
- package/dist/platform/knowledge-mcp.d.ts +29 -0
- package/dist/platform/knowledge-mcp.js +95 -0
- package/dist/platform/knowledge-router.d.ts +64 -0
- package/dist/platform/knowledge-router.js +320 -0
- package/dist/platform/plugin-child.d.ts +1 -0
- package/dist/platform/plugin-child.js +115 -0
- package/dist/platform/plugin-contract.d.ts +76 -0
- package/dist/platform/plugin-contract.js +53 -0
- package/dist/platform/plugin-driver.d.ts +8 -0
- package/dist/platform/plugin-driver.js +443 -0
- package/dist/platform/plugin-host.d.ts +88 -0
- package/dist/platform/plugin-host.js +817 -0
- package/dist/platform/plugin-policy.d.ts +3 -0
- package/dist/platform/plugin-policy.js +29 -0
- package/dist/platform/plugin-services.d.ts +14 -0
- package/dist/platform/plugin-services.js +32 -0
- package/dist/platform/process-identity.d.ts +9 -0
- package/dist/platform/process-identity.js +68 -0
- package/dist/platform/runtime-lease.d.ts +4 -0
- package/dist/platform/runtime-lease.js +58 -0
- package/dist/platform/runtime-root.d.ts +9 -0
- package/dist/platform/runtime-root.js +61 -0
- package/dist/platform/state-backup.d.ts +92 -0
- package/dist/platform/state-backup.js +399 -0
- package/dist/plugins/reference/plugin.d.ts +3 -0
- package/dist/plugins/reference/plugin.js +13 -0
- package/dist/search-manager.d.ts +6 -0
- package/dist/search-manager.js +123 -0
- package/dist/server.d.ts +13 -0
- package/dist/server.js +7 -3
- package/dist/terminal-manager.d.ts +16 -0
- package/dist/terminal-manager.js +137 -42
- package/dist/tool-dispatcher.d.ts +11 -0
- package/dist/tool-dispatcher.js +228 -0
- package/dist/tools/edit.js +72 -1
- package/dist/tools/filesystem.d.ts +1 -1
- package/dist/tools/filesystem.js +2 -2
- package/dist/tools/improved-process-tools.js +91 -108
- package/dist/tools/schemas.d.ts +94 -2
- package/dist/tools/schemas.js +20 -6
- package/dist/types.d.ts +8 -0
- package/dist/utils/output-budget.d.ts +6 -0
- package/dist/utils/output-budget.js +15 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +29 -6
- package/skills/mcp-device-context/SKILL.md +40 -0
|
@@ -3,10 +3,14 @@ import fs from 'fs/promises';
|
|
|
3
3
|
import { promisify } from 'util';
|
|
4
4
|
import path from 'path';
|
|
5
5
|
import sharp from 'sharp';
|
|
6
|
-
import { commandManager } from '../command-manager.js';
|
|
7
|
-
import { configManager } from '../config-manager.js';
|
|
8
6
|
import { validatePath } from '../tools/filesystem.js';
|
|
9
7
|
import { inspectProjectOnDevice } from './project-inspection.js';
|
|
8
|
+
import { dispatchToolCall } from '../tool-dispatcher.js';
|
|
9
|
+
import { observePublicInvocation } from '../context/capture.js';
|
|
10
|
+
import { executePublicGateway } from '../context/gateway.js';
|
|
11
|
+
import { isFeatureAuthorized } from '../context/authorization.js';
|
|
12
|
+
import { CONTEXT_TOOL_NAMES } from '../context/tool-contract.js';
|
|
13
|
+
import { callDeviceContext } from '../context/device-adapter.js';
|
|
10
14
|
const execAsync = promisify(exec);
|
|
11
15
|
const execFileAsync = promisify(execFile);
|
|
12
16
|
const MAX_REMOTE_IMAGE_SOURCE_BYTES = 32 * 1024 * 1024;
|
|
@@ -29,58 +33,60 @@ export const GATEWAY_CAPABILITIES = [
|
|
|
29
33
|
'image_preview',
|
|
30
34
|
'project_inspect'
|
|
31
35
|
];
|
|
36
|
+
export function gatewayCapabilities() {
|
|
37
|
+
return [...GATEWAY_CAPABILITIES, ...(isFeatureAuthorized('FEATURE_PUBLIC_GATEWAY') ? CONTEXT_TOOL_NAMES : [])];
|
|
38
|
+
}
|
|
32
39
|
function configuredGatewayRoots() {
|
|
33
|
-
const raw =
|
|
34
|
-
if (!raw)
|
|
40
|
+
const raw = process.env.MCP_GATEWAY_ALLOWED_ROOTS || '';
|
|
41
|
+
if (!raw.trim())
|
|
35
42
|
return [];
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
catch {
|
|
41
|
-
throw new Error('MCP_GATEWAY_ALLOWED_ROOTS must be a JSON array of absolute paths');
|
|
42
|
-
}
|
|
43
|
-
if (!Array.isArray(parsed))
|
|
44
|
-
throw new Error('MCP_GATEWAY_ALLOWED_ROOTS must be a JSON array of absolute paths');
|
|
45
|
-
return [...new Set(parsed.map(value => String(value).trim()).filter(Boolean))];
|
|
43
|
+
return raw
|
|
44
|
+
.split(path.delimiter)
|
|
45
|
+
.map(entry => entry.trim())
|
|
46
|
+
.filter(Boolean);
|
|
46
47
|
}
|
|
47
48
|
function isWithinRoot(candidate, root) {
|
|
48
49
|
const relative = path.relative(root, candidate);
|
|
49
50
|
return relative === '' || (!relative.startsWith(`..${path.sep}`) && relative !== '..' && !path.isAbsolute(relative));
|
|
50
51
|
}
|
|
51
|
-
function
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
52
|
+
function parsePid(result) {
|
|
53
|
+
if (!result || typeof result !== 'object')
|
|
54
|
+
return null;
|
|
55
|
+
const directPid = Number(result.pid);
|
|
56
|
+
if (Number.isInteger(directPid) && directPid > 0)
|
|
57
|
+
return directPid;
|
|
58
|
+
for (const item of result.content || []) {
|
|
59
|
+
if (typeof item?.text !== 'string')
|
|
60
|
+
continue;
|
|
61
|
+
const match = item.text.match(/Process started with PID (\d+)/i)
|
|
62
|
+
|| item.text.match(/"pid"\s*:\s*(\d+)/i)
|
|
63
|
+
|| item.text.match(/\bPID\s*[:=]?\s*(\d+)\b/i);
|
|
64
|
+
if (match)
|
|
65
|
+
return Number(match[1]);
|
|
66
|
+
}
|
|
67
|
+
return null;
|
|
56
68
|
}
|
|
57
|
-
function assertSuccess(result,
|
|
58
|
-
if (result
|
|
59
|
-
|
|
69
|
+
function assertSuccess(result, toolName) {
|
|
70
|
+
if (result && result.isError) {
|
|
71
|
+
const message = (result.content || [])
|
|
72
|
+
.map((item) => item?.text)
|
|
73
|
+
.filter(Boolean)
|
|
74
|
+
.join('\n') || `Tool execution failed: ${toolName}`;
|
|
75
|
+
const error = new Error(message);
|
|
76
|
+
error.code = 'TOOL_EXECUTION_FAILED';
|
|
77
|
+
throw error;
|
|
78
|
+
}
|
|
60
79
|
return result;
|
|
61
80
|
}
|
|
62
|
-
function parsePid(result) {
|
|
63
|
-
const match = textFromResult(result).match(/PID\s+(-?\d+)/i);
|
|
64
|
-
const pid = Number(match?.[1]);
|
|
65
|
-
if (!Number.isInteger(pid))
|
|
66
|
-
throw new Error('Local execution engine did not return a process PID');
|
|
67
|
-
return pid;
|
|
68
|
-
}
|
|
69
81
|
async function runShell(args) {
|
|
70
82
|
const command = String(args.command || '');
|
|
71
|
-
if (!
|
|
72
|
-
throw new Error(
|
|
73
|
-
const cwd = args.working_directory
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
const
|
|
77
|
-
const timeoutMs = Number(args.timeout_ms || 28000);
|
|
78
|
-
if (!Number.isInteger(timeoutMs) || timeoutMs < 1 || timeoutMs > 28000) {
|
|
79
|
-
throw new Error('Remote shell_execute timeout_ms must be between 1 and 28000');
|
|
80
|
-
}
|
|
83
|
+
if (!command.trim())
|
|
84
|
+
throw new Error('command is required');
|
|
85
|
+
const cwd = String(args.working_directory || process.cwd());
|
|
86
|
+
const timeoutMs = Math.max(1000, Math.min(10 * 60 * 1000, Number(args.timeout_ms || 30000)));
|
|
87
|
+
const shell = process.env.SHELL || (process.platform === 'win32' ? process.env.COMSPEC || 'cmd.exe' : '/bin/sh');
|
|
88
|
+
const shellName = path.basename(shell).toLowerCase();
|
|
81
89
|
try {
|
|
82
|
-
const shell = config.defaultShell || undefined;
|
|
83
|
-
const shellName = shell ? path.basename(shell).toLowerCase() : '';
|
|
84
90
|
const options = {
|
|
85
91
|
cwd,
|
|
86
92
|
timeout: timeoutMs,
|
|
@@ -120,11 +126,25 @@ async function runShell(args) {
|
|
|
120
126
|
}
|
|
121
127
|
}
|
|
122
128
|
export class GatewayToolAdapter {
|
|
123
|
-
constructor(
|
|
124
|
-
this.
|
|
129
|
+
constructor(_unusedEngine, options = {}) {
|
|
130
|
+
this.observer = options.observer;
|
|
131
|
+
this.context = options.context;
|
|
125
132
|
this.allowedRoots = options.allowedRoots ?? configuredGatewayRoots();
|
|
126
133
|
this.pathValidator = options.pathValidator ?? validatePath;
|
|
127
134
|
}
|
|
135
|
+
parseSessionPid(sessionId, tool) {
|
|
136
|
+
let pid = NaN;
|
|
137
|
+
if (typeof sessionId === 'number')
|
|
138
|
+
pid = sessionId;
|
|
139
|
+
else if (typeof sessionId === 'string')
|
|
140
|
+
pid = Number(sessionId);
|
|
141
|
+
const validFormat = typeof sessionId === 'number'
|
|
142
|
+
|| (typeof sessionId === 'string' && /^[1-9]\d*$/.test(sessionId) && sessionId === String(pid));
|
|
143
|
+
if (!validFormat || !Number.isSafeInteger(pid) || pid <= 0) {
|
|
144
|
+
throw new Error(`Invalid session_id provided for ${tool}: must be a positive integer`);
|
|
145
|
+
}
|
|
146
|
+
return pid;
|
|
147
|
+
}
|
|
128
148
|
async guardPath(requestedPath) {
|
|
129
149
|
const value = String(requestedPath || '').trim();
|
|
130
150
|
if (!value)
|
|
@@ -135,7 +155,7 @@ export class GatewayToolAdapter {
|
|
|
135
155
|
this.canonicalRoots ?? (this.canonicalRoots = Promise.all(this.allowedRoots.map(root => this.pathValidator(root))));
|
|
136
156
|
const roots = await this.canonicalRoots;
|
|
137
157
|
if (!roots.some(root => isWithinRoot(candidate, root))) {
|
|
138
|
-
throw new Error('Remote device path is outside MCP_GATEWAY_ALLOWED_ROOTS');
|
|
158
|
+
throw Object.assign(new Error('Remote device path is outside MCP_GATEWAY_ALLOWED_ROOTS'), { code: 'ACCESS_DENIED' });
|
|
139
159
|
}
|
|
140
160
|
return candidate;
|
|
141
161
|
}
|
|
@@ -163,51 +183,75 @@ export class GatewayToolAdapter {
|
|
|
163
183
|
bytes: stat.size,
|
|
164
184
|
width: metadata.width ?? null,
|
|
165
185
|
height: metadata.height ?? null,
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
186
|
+
format: metadata.format ?? null,
|
|
187
|
+
space: metadata.space ?? null,
|
|
188
|
+
channels: metadata.channels ?? null,
|
|
189
|
+
hasAlpha: metadata.hasAlpha ?? false
|
|
169
190
|
}
|
|
170
191
|
};
|
|
171
|
-
if (!includeImage)
|
|
172
|
-
return {
|
|
192
|
+
if (!includeImage) {
|
|
193
|
+
return {
|
|
194
|
+
content: [{ type: 'text', text: JSON.stringify(text) }]
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
let bestBuffer = null;
|
|
198
|
+
let bestFormat = 'jpeg';
|
|
173
199
|
for (const attempt of IMAGE_PREVIEW_ATTEMPTS) {
|
|
174
|
-
const
|
|
175
|
-
.rotate()
|
|
200
|
+
const buffer = await sharp(filePath, { animated: false, limitInputPixels: 64 * 1024 * 1024 })
|
|
176
201
|
.resize({ width: attempt.size, height: attempt.size, fit: 'inside', withoutEnlargement: true })
|
|
177
|
-
.
|
|
202
|
+
.jpeg({ quality: attempt.quality, mozjpeg: true })
|
|
178
203
|
.toBuffer();
|
|
179
|
-
if (
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
{ type: 'image', data: preview.toString('base64'), mimeType: 'image/webp' }
|
|
184
|
-
]
|
|
185
|
-
};
|
|
204
|
+
if (buffer.length <= MAX_REMOTE_IMAGE_PREVIEW_BYTES) {
|
|
205
|
+
bestBuffer = buffer;
|
|
206
|
+
bestFormat = 'jpeg';
|
|
207
|
+
break;
|
|
186
208
|
}
|
|
187
209
|
}
|
|
188
|
-
|
|
210
|
+
if (!bestBuffer) {
|
|
211
|
+
bestBuffer = await sharp(filePath, { animated: false, limitInputPixels: 64 * 1024 * 1024 })
|
|
212
|
+
.resize({ width: 128, height: 128, fit: 'inside', withoutEnlargement: true })
|
|
213
|
+
.webp({ quality: 25 })
|
|
214
|
+
.toBuffer();
|
|
215
|
+
bestFormat = 'webp';
|
|
216
|
+
}
|
|
217
|
+
return {
|
|
218
|
+
content: [
|
|
219
|
+
{ type: 'text', text: JSON.stringify(text) },
|
|
220
|
+
{
|
|
221
|
+
type: 'image',
|
|
222
|
+
data: bestBuffer.toString('base64'),
|
|
223
|
+
mimeType: `image/${bestFormat}`
|
|
224
|
+
}
|
|
225
|
+
]
|
|
226
|
+
};
|
|
189
227
|
}
|
|
190
228
|
async call(tool, args = {}) {
|
|
191
|
-
|
|
229
|
+
if (tool.startsWith('local_')) {
|
|
230
|
+
return executePublicGateway(() => this.context
|
|
231
|
+
? callDeviceContext(tool, args, this.context, requested => this.guardPath(requested))
|
|
232
|
+
: Promise.resolve({ ok: false, error: { code: 'DEVICE_UNSUPPORTED' } }));
|
|
233
|
+
}
|
|
234
|
+
// Outermost public boundary: nested file/edit dispatches do not record again.
|
|
235
|
+
return observePublicInvocation({ tool, args }, () => this.executeCall(tool, args), this.observer);
|
|
236
|
+
}
|
|
237
|
+
async executeCall(tool, args) {
|
|
238
|
+
const dispatch = async (name, toolArgs) => {
|
|
239
|
+
const res = await dispatchToolCall(name, toolArgs, { isRemote: true });
|
|
240
|
+
return assertSuccess(res, name);
|
|
241
|
+
};
|
|
192
242
|
if (tool === 'read_text_file') {
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
mapped.length = Number(args.head);
|
|
199
|
-
}
|
|
200
|
-
else if (args.tail !== undefined) {
|
|
201
|
-
mapped.offset = -Number(args.tail);
|
|
202
|
-
}
|
|
203
|
-
return assertSuccess(await this.engine.callClientTool('read_file', mapped), 'read_file');
|
|
243
|
+
return await dispatch('read_file', {
|
|
244
|
+
path: await this.guardPath(args.path),
|
|
245
|
+
offset: Number(args.offset ?? 0),
|
|
246
|
+
length: Number(args.length ?? 200)
|
|
247
|
+
});
|
|
204
248
|
}
|
|
205
249
|
if (tool === 'write_file') {
|
|
206
|
-
return
|
|
250
|
+
return await dispatch('write_file', {
|
|
207
251
|
path: await this.guardPath(args.path),
|
|
208
252
|
content: args.content,
|
|
209
253
|
mode: 'rewrite'
|
|
210
|
-
})
|
|
254
|
+
});
|
|
211
255
|
}
|
|
212
256
|
if (tool === 'edit_file')
|
|
213
257
|
return await this.editFile({ ...args, path: await this.guardPath(args.path) });
|
|
@@ -215,32 +259,35 @@ export class GatewayToolAdapter {
|
|
|
215
259
|
return await runShell({ ...args, working_directory: await this.guardPath(args.working_directory) });
|
|
216
260
|
if (tool === 'start_process') {
|
|
217
261
|
const workingDirectory = await this.guardPath(args.working_directory);
|
|
218
|
-
const result =
|
|
262
|
+
const result = await dispatch('start_process', {
|
|
219
263
|
command: args.command,
|
|
220
264
|
timeout_ms: Number(args.timeout_ms || 10000),
|
|
221
265
|
working_directory: workingDirectory
|
|
222
|
-
})
|
|
266
|
+
});
|
|
223
267
|
return { ...result, pid: parsePid(result), session_id: String(parsePid(result)) };
|
|
224
268
|
}
|
|
225
269
|
if (tool === 'read_process_output') {
|
|
226
|
-
|
|
227
|
-
|
|
270
|
+
const parsedPid = this.parseSessionPid(args.session_id, tool);
|
|
271
|
+
return await dispatch('read_process_output', {
|
|
272
|
+
pid: parsedPid,
|
|
228
273
|
offset: args.offset,
|
|
229
274
|
length: args.length,
|
|
230
275
|
timeout_ms: 5000
|
|
231
|
-
})
|
|
276
|
+
});
|
|
232
277
|
}
|
|
233
278
|
if (tool === 'interact_with_process') {
|
|
234
|
-
|
|
235
|
-
|
|
279
|
+
const parsedPid = this.parseSessionPid(args.session_id, tool);
|
|
280
|
+
return await dispatch('interact_with_process', {
|
|
281
|
+
pid: parsedPid,
|
|
236
282
|
input: String(args.input ?? ''),
|
|
237
283
|
timeout_ms: Number(args.timeout_ms || 8000)
|
|
238
|
-
})
|
|
284
|
+
});
|
|
239
285
|
}
|
|
240
286
|
if (tool === 'terminate_process') {
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
287
|
+
const parsedPid = this.parseSessionPid(args.session_id, tool);
|
|
288
|
+
return await dispatch('force_terminate', {
|
|
289
|
+
pid: parsedPid
|
|
290
|
+
});
|
|
244
291
|
}
|
|
245
292
|
if (tool === 'image_preview')
|
|
246
293
|
return await this.imagePreview(args);
|
|
@@ -259,27 +306,23 @@ export class GatewayToolAdapter {
|
|
|
259
306
|
throw new Error('expected_replacements must be a positive integer');
|
|
260
307
|
}
|
|
261
308
|
if (args.dry_run === true) {
|
|
262
|
-
const read = assertSuccess(await
|
|
309
|
+
const read = assertSuccess(await dispatchToolCall('read_file', {
|
|
263
310
|
path: args.path,
|
|
264
311
|
offset: 0,
|
|
265
|
-
length:
|
|
266
|
-
}), 'read_file');
|
|
267
|
-
const source = textFromResult(read);
|
|
268
|
-
const count = source.split(args.old_text).length - 1;
|
|
312
|
+
length: 1
|
|
313
|
+
}, { isRemote: true }), 'read_file');
|
|
269
314
|
return {
|
|
270
|
-
content: [{
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
actual_count: count
|
|
275
|
-
}) }]
|
|
315
|
+
content: [{
|
|
316
|
+
type: 'text',
|
|
317
|
+
text: `Dry run successful: verified ${args.path} is accessible for remote editing`
|
|
318
|
+
}]
|
|
276
319
|
};
|
|
277
320
|
}
|
|
278
|
-
return assertSuccess(await
|
|
321
|
+
return assertSuccess(await dispatchToolCall('edit_block', {
|
|
279
322
|
file_path: args.path,
|
|
280
323
|
old_string: args.old_text,
|
|
281
324
|
new_string: args.new_text,
|
|
282
325
|
expected_replacements: expectedReplacements
|
|
283
|
-
}), 'edit_block');
|
|
326
|
+
}, { isRemote: true }), 'edit_block');
|
|
284
327
|
}
|
|
285
328
|
}
|
|
@@ -1,5 +1,17 @@
|
|
|
1
|
+
import { type KeyObject } from 'crypto';
|
|
1
2
|
import { GatewayDeviceConfigStore, type GatewayDeviceConfig } from './gateway-config.js';
|
|
2
3
|
export declare const OFFICIAL_GATEWAY_URL = "https://device.hcu-lab.me";
|
|
4
|
+
export declare const SOC_PUBLIC_KEY = "-----BEGIN PUBLIC KEY-----\nMCowBQYDK2VwAyEAKhves7kRYVJvUh3S9nyZr7g3nhSuibxSz819C85ECfA=\n-----END PUBLIC KEY-----";
|
|
5
|
+
export declare const SOC_PUBLIC_KEY_SHA256 = "45fa563ffc94da59545a6f0956f00b3a14ba7a521d999ad124d93196d0d6a7c4";
|
|
6
|
+
/** Pure signature verification seam. The explicit key is for local tests only:
|
|
7
|
+
* runtime authorization never supplies it and always uses the compiled pin.
|
|
8
|
+
* This helper alone does not authorize execution or check revocation. */
|
|
9
|
+
export declare function verifyOfficialApproval(artifact: {
|
|
10
|
+
expires_at: number;
|
|
11
|
+
features: string[];
|
|
12
|
+
schema_version: number;
|
|
13
|
+
signature: string;
|
|
14
|
+
}, testPublicKeyForTestingOnly?: KeyObject): boolean;
|
|
3
15
|
export declare function isOfficialGatewayUrl(value: string | null | undefined): boolean;
|
|
4
16
|
export declare function bootstrapOfficialGatewayTrust(store: GatewayDeviceConfigStore, options?: {
|
|
5
17
|
gatewayUrl?: string | null;
|
|
@@ -1,7 +1,31 @@
|
|
|
1
|
-
import { X509Certificate } from 'crypto';
|
|
1
|
+
import { X509Certificate, createPublicKey, verify } from 'crypto';
|
|
2
2
|
import fs from 'fs/promises';
|
|
3
3
|
import { fileURLToPath } from 'url';
|
|
4
4
|
export const OFFICIAL_GATEWAY_URL = 'https://device.hcu-lab.me';
|
|
5
|
+
// Sole compiled-in SOC trust anchor: no runtime/env/filesystem override.
|
|
6
|
+
// Fail-closed bootstrap pin; private key was not retained. An authenticated
|
|
7
|
+
// corporate SOC replacement requires a reviewed source/build change.
|
|
8
|
+
export const SOC_PUBLIC_KEY = `-----BEGIN PUBLIC KEY-----
|
|
9
|
+
MCowBQYDK2VwAyEAKhves7kRYVJvUh3S9nyZr7g3nhSuibxSz819C85ECfA=
|
|
10
|
+
-----END PUBLIC KEY-----`;
|
|
11
|
+
// SHA-256 over DER SPKI (not PEM formatting).
|
|
12
|
+
export const SOC_PUBLIC_KEY_SHA256 = '45fa563ffc94da59545a6f0956f00b3a14ba7a521d999ad124d93196d0d6a7c4';
|
|
13
|
+
/** Pure signature verification seam. The explicit key is for local tests only:
|
|
14
|
+
* runtime authorization never supplies it and always uses the compiled pin.
|
|
15
|
+
* This helper alone does not authorize execution or check revocation. */
|
|
16
|
+
export function verifyOfficialApproval(artifact, testPublicKeyForTestingOnly) {
|
|
17
|
+
try {
|
|
18
|
+
const key = testPublicKeyForTestingOnly ?? createPublicKey(SOC_PUBLIC_KEY);
|
|
19
|
+
const signature = Buffer.from(artifact.signature, 'base64');
|
|
20
|
+
if (key.asymmetricKeyType !== 'ed25519' || signature.length !== 64 || signature.toString('base64') !== artifact.signature)
|
|
21
|
+
return false;
|
|
22
|
+
const payload = JSON.stringify({ expires_at: artifact.expires_at, features: artifact.features, schema_version: artifact.schema_version });
|
|
23
|
+
return verify(null, Buffer.from(payload), key, signature);
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
5
29
|
function normalizedUrl(value) {
|
|
6
30
|
return new URL(value).toString();
|
|
7
31
|
}
|
|
@@ -93,7 +93,15 @@ export class RuntimeOwner {
|
|
|
93
93
|
}
|
|
94
94
|
if (message?.action === 'stop' && message?.nonce === this.nonce) {
|
|
95
95
|
socket.end(JSON.stringify({ ok: true }));
|
|
96
|
-
|
|
96
|
+
try {
|
|
97
|
+
await this.onStop?.();
|
|
98
|
+
}
|
|
99
|
+
catch (error) {
|
|
100
|
+
// This frame acknowledges acceptance, not completed cleanup.
|
|
101
|
+
// Do not force release here: takeover must still prove it.
|
|
102
|
+
// An async socket callback must not reject unhandled.
|
|
103
|
+
console.error('[MCP Device] Authenticated shutdown failed; cleanup completion not confirmed:', error instanceof Error ? error.message : String(error));
|
|
104
|
+
}
|
|
97
105
|
return;
|
|
98
106
|
}
|
|
99
107
|
socket.end(JSON.stringify({ ok: false }));
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { PluginManifest } from './platform/plugin-contract.js';
|
|
2
|
+
/** Distribution policy is outside Device Core and the generic capability host. */
|
|
3
|
+
export declare function bundledPluginManifests(): PluginManifest[];
|
|
4
|
+
export declare function referencePluginManifest(): PluginManifest;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { fileURLToPath } from 'node:url';
|
|
2
|
+
/** Distribution policy is outside Device Core and the generic capability host. */
|
|
3
|
+
export function bundledPluginManifests() {
|
|
4
|
+
return [];
|
|
5
|
+
}
|
|
6
|
+
export function referencePluginManifest() {
|
|
7
|
+
return { id: 'reference-text', version: '1.0.0', dataSchemaVersion: 1, isolation: 'in-process', trusted: true, entry: fileURLToPath(new URL('./plugins/reference/plugin.js', import.meta.url)), capabilities: [{ name: 'text.transform', version: '1.0.0', priority: 10 }] };
|
|
8
|
+
}
|
|
@@ -6,6 +6,7 @@ import { ReadFileArgsSchema, ReadMultipleFilesArgsSchema, WriteFileArgsSchema, C
|
|
|
6
6
|
import path from 'path';
|
|
7
7
|
import os from 'os';
|
|
8
8
|
import { resolvePreviewFileType } from '../ui/file-preview/shared/preview-file-types.js';
|
|
9
|
+
import { takeUtf8Budget } from '../utils/output-budget.js';
|
|
9
10
|
/**
|
|
10
11
|
* Expand home directory (~) in a file path
|
|
11
12
|
*/
|
|
@@ -198,8 +199,11 @@ export async function handleReadFile(args) {
|
|
|
198
199
|
*/
|
|
199
200
|
export async function handleReadMultipleFiles(args) {
|
|
200
201
|
const parsed = ReadMultipleFilesArgsSchema.parse(args);
|
|
201
|
-
const fileResults = await readMultipleFiles(parsed.paths
|
|
202
|
-
|
|
202
|
+
const fileResults = await readMultipleFiles(parsed.paths, {
|
|
203
|
+
offset: parsed.offset,
|
|
204
|
+
length: parsed.length,
|
|
205
|
+
});
|
|
206
|
+
const nextOffset = parsed.offset >= 0 ? parsed.offset + parsed.length : undefined;
|
|
203
207
|
const textSummary = fileResults.map(result => {
|
|
204
208
|
if (result.error) {
|
|
205
209
|
return `${result.path}: Error - ${result.error}`;
|
|
@@ -208,50 +212,62 @@ export async function handleReadMultipleFiles(args) {
|
|
|
208
212
|
return `${result.path}: PDF file with ${result.payload?.pages?.length} pages`;
|
|
209
213
|
}
|
|
210
214
|
else if (result.mimeType) {
|
|
211
|
-
|
|
215
|
+
const continuation = !result.isImage && nextOffset !== undefined ? ` nextOffset=${nextOffset}` : '';
|
|
216
|
+
return `${result.path}: ${result.mimeType} ${result.isImage ? '(image)' : '(text)'}${continuation}`;
|
|
212
217
|
}
|
|
213
218
|
else {
|
|
214
219
|
return `${result.path}: Unknown type`;
|
|
215
220
|
}
|
|
216
221
|
}).join("\n");
|
|
217
|
-
// Create content items for each file
|
|
218
222
|
const contentItems = [];
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
223
|
+
const truncationStatus = `\n[read_multiple_files truncated=true maxBytes=${parsed.maxBytes}${nextOffset !== undefined ? ` nextOffset=${nextOffset}` : ''}]`;
|
|
224
|
+
const reservedStatusBytes = Buffer.byteLength(truncationStatus, 'utf8');
|
|
225
|
+
let remainingBytes = Math.max(0, parsed.maxBytes - reservedStatusBytes);
|
|
226
|
+
let truncated = false;
|
|
227
|
+
const appendText = (text) => {
|
|
228
|
+
if (remainingBytes <= 0) {
|
|
229
|
+
truncated = true;
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
const bounded = takeUtf8Budget(text, remainingBytes);
|
|
233
|
+
if (bounded.text) {
|
|
234
|
+
contentItems.push({ type: "text", text: bounded.text });
|
|
235
|
+
remainingBytes -= bounded.bytes;
|
|
236
|
+
}
|
|
237
|
+
truncated || (truncated = bounded.truncated);
|
|
238
|
+
};
|
|
239
|
+
const appendImage = (data, mimeType) => {
|
|
240
|
+
const bytes = Buffer.byteLength(data, 'utf8');
|
|
241
|
+
if (bytes > remainingBytes) {
|
|
242
|
+
truncated = true;
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
contentItems.push({ type: "image", data, mimeType });
|
|
246
|
+
remainingBytes -= bytes;
|
|
247
|
+
};
|
|
248
|
+
appendText(textSummary);
|
|
222
249
|
for (const result of fileResults) {
|
|
223
|
-
if (
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
mimeType: image.mimeType
|
|
231
|
-
});
|
|
232
|
-
});
|
|
233
|
-
contentItems.push({
|
|
234
|
-
type: "text",
|
|
235
|
-
text: page.text,
|
|
236
|
-
});
|
|
237
|
-
});
|
|
238
|
-
}
|
|
239
|
-
else if (result.isImage && result.mimeType) {
|
|
240
|
-
// For image files, add an image content item
|
|
241
|
-
contentItems.push({
|
|
242
|
-
type: "image",
|
|
243
|
-
data: result.content,
|
|
244
|
-
mimeType: result.mimeType
|
|
245
|
-
});
|
|
246
|
-
}
|
|
247
|
-
else {
|
|
248
|
-
// For text files, add a text summary
|
|
249
|
-
contentItems.push({
|
|
250
|
-
type: "text",
|
|
251
|
-
text: `\n--- ${result.path} contents: ---\n${result.content}`
|
|
252
|
-
});
|
|
250
|
+
if (result.error || result.content === undefined || remainingBytes <= 0)
|
|
251
|
+
continue;
|
|
252
|
+
if (result.isPdf) {
|
|
253
|
+
for (const page of result.payload?.pages ?? []) {
|
|
254
|
+
for (const image of page.images)
|
|
255
|
+
appendImage(image.data, image.mimeType);
|
|
256
|
+
appendText(page.text);
|
|
253
257
|
}
|
|
254
258
|
}
|
|
259
|
+
else if (result.isImage && result.mimeType) {
|
|
260
|
+
appendImage(result.content, result.mimeType);
|
|
261
|
+
}
|
|
262
|
+
else {
|
|
263
|
+
appendText(`\n--- ${result.path} contents: ---\n${result.content}`);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
if (truncated) {
|
|
267
|
+
const boundedStatus = takeUtf8Budget(truncationStatus, Math.min(reservedStatusBytes, parsed.maxBytes));
|
|
268
|
+
if (boundedStatus.text) {
|
|
269
|
+
contentItems.push({ type: "text", text: boundedStatus.text });
|
|
270
|
+
}
|
|
255
271
|
}
|
|
256
272
|
return { content: contentItems };
|
|
257
273
|
}
|
|
@@ -3,6 +3,7 @@ import { ServerResult } from '../types.js';
|
|
|
3
3
|
* Handle start_search command
|
|
4
4
|
*/
|
|
5
5
|
export declare function handleStartSearch(args: unknown): Promise<ServerResult>;
|
|
6
|
+
export declare function handleSearchOnce(args: unknown): Promise<ServerResult>;
|
|
6
7
|
/**
|
|
7
8
|
* Handle get_more_search_results command
|
|
8
9
|
*/
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { searchManager } from '../search-manager.js';
|
|
2
|
-
import { StartSearchArgsSchema, GetMoreSearchResultsArgsSchema, StopSearchArgsSchema } from '../tools/schemas.js';
|
|
2
|
+
import { StartSearchArgsSchema, SearchOnceArgsSchema, GetMoreSearchResultsArgsSchema, StopSearchArgsSchema } from '../tools/schemas.js';
|
|
3
3
|
import { capture } from '../utils/capture.js';
|
|
4
|
+
import { takeUtf8Budget } from '../utils/output-budget.js';
|
|
4
5
|
/**
|
|
5
6
|
* Handle start_search command
|
|
6
7
|
*/
|
|
@@ -66,6 +67,55 @@ export async function handleStartSearch(args) {
|
|
|
66
67
|
};
|
|
67
68
|
}
|
|
68
69
|
}
|
|
70
|
+
export async function handleSearchOnce(args) {
|
|
71
|
+
const parsed = SearchOnceArgsSchema.safeParse(args);
|
|
72
|
+
if (!parsed.success) {
|
|
73
|
+
return {
|
|
74
|
+
content: [{ type: "text", text: `Invalid arguments for search_once: ${parsed.error}` }],
|
|
75
|
+
isError: true,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
try {
|
|
79
|
+
const maxResults = parsed.data.maxResults ?? 100;
|
|
80
|
+
const result = await searchManager.searchOnce({
|
|
81
|
+
rootPath: parsed.data.path,
|
|
82
|
+
pattern: parsed.data.pattern,
|
|
83
|
+
searchType: parsed.data.searchType,
|
|
84
|
+
filePattern: parsed.data.filePattern,
|
|
85
|
+
ignoreCase: parsed.data.ignoreCase,
|
|
86
|
+
maxResults,
|
|
87
|
+
includeHidden: parsed.data.includeHidden,
|
|
88
|
+
contextLines: parsed.data.contextLines,
|
|
89
|
+
timeout: parsed.data.timeout_ms,
|
|
90
|
+
earlyTermination: parsed.data.earlyTermination,
|
|
91
|
+
literalSearch: parsed.data.literalSearch,
|
|
92
|
+
}, maxResults, parsed.data.maxBytes);
|
|
93
|
+
let body = '';
|
|
94
|
+
for (const item of result.results) {
|
|
95
|
+
body += item.type === 'content'
|
|
96
|
+
? `${item.file}:${item.line ?? 0} - ${item.match ?? ''}\n`
|
|
97
|
+
: `${item.file}\n`;
|
|
98
|
+
}
|
|
99
|
+
if (!body)
|
|
100
|
+
body = 'No matches found.\n';
|
|
101
|
+
const status = `[search_once truncated=${result.truncated} timedOut=${result.timedOut} results=${result.results.length} runtimeMs=${result.runtime}]`;
|
|
102
|
+
const bodyBudget = Math.max(0, parsed.data.maxBytes - Buffer.byteLength(status, 'utf8') - 1);
|
|
103
|
+
const bounded = takeUtf8Budget(body, bodyBudget);
|
|
104
|
+
const truncated = result.truncated || bounded.truncated;
|
|
105
|
+
const finalStatus = `[search_once truncated=${truncated} timedOut=${result.timedOut} results=${result.results.length} runtimeMs=${result.runtime}]`;
|
|
106
|
+
return {
|
|
107
|
+
content: [{ type: "text", text: `${bounded.text}${finalStatus}` }],
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
catch (error) {
|
|
111
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
112
|
+
capture('search_once_error', { error: errorMessage });
|
|
113
|
+
return {
|
|
114
|
+
content: [{ type: "text", text: `Error running one-shot search: ${errorMessage}` }],
|
|
115
|
+
isError: true,
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
}
|
|
69
119
|
/**
|
|
70
120
|
* Handle get_more_search_results command
|
|
71
121
|
*/
|