@hcu-lab.me/mcp-device 1.0.10 → 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 +57 -2
- 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 -1
- package/dist/device/device.js +87 -39
- 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 +9 -0
- package/dist/device/gateway-tool-adapter.js +20 -1
- 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/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.js +27 -5
- 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/server.js +5 -1
- package/dist/terminal-manager.d.ts +7 -0
- package/dist/terminal-manager.js +10 -0
- package/dist/tool-dispatcher.js +5 -1
- package/dist/tools/improved-process-tools.js +4 -0
- package/dist/types.d.ts +1 -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
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
function samePath(left, right) {
|
|
4
|
+
const normalize = (value) => {
|
|
5
|
+
const resolved = path.resolve(value);
|
|
6
|
+
return process.platform === 'win32' ? resolved.toLowerCase() : resolved;
|
|
7
|
+
};
|
|
8
|
+
return normalize(left) === normalize(right);
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* The transport-neutral execution owner shared by remote Device and server.
|
|
12
|
+
*
|
|
13
|
+
* No account enrollment, socket, self-MCP child, plugin, or Palace is created
|
|
14
|
+
* here. Authorization belongs to the caller's broker; file/process semantics
|
|
15
|
+
* remain owned by the existing Device handlers and GatewayToolAdapter.
|
|
16
|
+
*
|
|
17
|
+
* Existing native managers are process-scoped. A server must configure its
|
|
18
|
+
* isolated state root before importing them; silently changing a global root
|
|
19
|
+
* after import could write to the user's normal Device state.
|
|
20
|
+
*/
|
|
21
|
+
export async function createDeviceCore(options) {
|
|
22
|
+
if (!options.deviceId || typeof options.deviceId !== 'string' || !options.deviceId.trim()) {
|
|
23
|
+
throw Object.assign(new Error('Device Core requires a device identity'), { code: 'DEVICE_ID_REQUIRED' });
|
|
24
|
+
}
|
|
25
|
+
// This module intentionally has no eager imports of existing Device modules.
|
|
26
|
+
const { CONFIG_DIR } = await import('../config.js');
|
|
27
|
+
const stateRoot = path.resolve(options.stateRoot ?? CONFIG_DIR);
|
|
28
|
+
if (!samePath(stateRoot, CONFIG_DIR)) {
|
|
29
|
+
throw Object.assign(new Error('Device Core stateRoot must match MCP_DEVICE_CONFIG_DIR set before importing Device modules'), { code: 'CONFIG_ROOT_MISMATCH' });
|
|
30
|
+
}
|
|
31
|
+
const [{ GatewayToolAdapter, gatewayCapabilities }, { dispatchToolCall }] = await Promise.all([
|
|
32
|
+
import('./gateway-tool-adapter.js'),
|
|
33
|
+
import('../tool-dispatcher.js')
|
|
34
|
+
]);
|
|
35
|
+
const adapter = new GatewayToolAdapter(undefined, {
|
|
36
|
+
allowedRoots: options.allowedRoots,
|
|
37
|
+
context: { deviceId: options.deviceId, stateRoot }
|
|
38
|
+
});
|
|
39
|
+
const runtimeInstanceId = `direct-in-process:${randomUUID()}`;
|
|
40
|
+
let closed = false;
|
|
41
|
+
const assertOpen = () => {
|
|
42
|
+
if (closed)
|
|
43
|
+
throw Object.assign(new Error('Device Core is closed'), { code: 'DEVICE_NOT_READY' });
|
|
44
|
+
};
|
|
45
|
+
return {
|
|
46
|
+
deviceId: options.deviceId,
|
|
47
|
+
stateRoot,
|
|
48
|
+
runtimeInstanceId,
|
|
49
|
+
get capabilities() {
|
|
50
|
+
return closed ? [] : gatewayCapabilities();
|
|
51
|
+
},
|
|
52
|
+
async invoke(tool, args = {}) {
|
|
53
|
+
assertOpen();
|
|
54
|
+
return adapter.call(tool, args);
|
|
55
|
+
},
|
|
56
|
+
async invokeNative(tool, args = {}) {
|
|
57
|
+
assertOpen();
|
|
58
|
+
return dispatchToolCall(tool, args, { isRemote: true });
|
|
59
|
+
},
|
|
60
|
+
async close() {
|
|
61
|
+
// The core owns no second runtime or socket. Its host owns process
|
|
62
|
+
// shutdown; existing native process session retention is unchanged.
|
|
63
|
+
closed = true;
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
}
|
package/dist/device/device.d.ts
CHANGED
|
@@ -2,16 +2,20 @@
|
|
|
2
2
|
import { type RuntimeOwnerStatus } from './runtime-owner.js';
|
|
3
3
|
export declare class MCPDevice {
|
|
4
4
|
private isShuttingDown;
|
|
5
|
-
private
|
|
5
|
+
private shutdownRequest?;
|
|
6
|
+
private core?;
|
|
7
|
+
private unsubscribeCapabilities?;
|
|
6
8
|
private executionEngine;
|
|
7
9
|
private gatewayChannel?;
|
|
8
10
|
private gatewayProxyAgent?;
|
|
9
11
|
private runtimeOwner?;
|
|
12
|
+
private stateLeases;
|
|
10
13
|
constructor();
|
|
11
14
|
private setupShutdownHandlers;
|
|
12
15
|
start(options?: {
|
|
13
16
|
confirmTakeover?: (existing: RuntimeOwnerStatus) => Promise<boolean> | boolean;
|
|
14
17
|
}): Promise<void>;
|
|
15
18
|
shutdown(): Promise<void>;
|
|
19
|
+
private performShutdown;
|
|
16
20
|
}
|
|
17
21
|
export declare function isModuleEntrypoint(moduleUrl: string, argvEntry?: string, pmExecPath?: string): boolean;
|
package/dist/device/device.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { fileURLToPath } from 'url';
|
|
3
|
-
import { randomUUID } from 'crypto';
|
|
4
3
|
import os from 'os';
|
|
5
4
|
import path from 'path';
|
|
6
5
|
import { LocalExecutionEngine } from './execution-engine.js';
|
|
@@ -10,58 +9,60 @@ import { GatewayDeviceIdentity } from './gateway-identity.js';
|
|
|
10
9
|
import { pairGatewayDevice } from './gateway-pairing.js';
|
|
11
10
|
import { bootstrapOfficialGatewayTrust } from './official-trust.js';
|
|
12
11
|
import { GatewayDeviceStatusStore } from './device-status.js';
|
|
13
|
-
import {
|
|
12
|
+
import { createPlatformDeviceCore as createDeviceCore } from '../platform/device-runtime.js';
|
|
13
|
+
import { resolveDevicePluginPolicy } from '../platform/plugin-policy.js';
|
|
14
14
|
import { RuntimeOwner, acquireRuntimeOwner } from './runtime-owner.js';
|
|
15
|
+
import { acquireServerLease } from '../platform/runtime-lease.js';
|
|
15
16
|
import { assertDeviceStartupAllowedDuringUpdate, launchDeviceUpdateHelper, prepareDevicePackageUpdate, reconcileDeviceUpdateAfterStart, retireDeviceUpdateState, signalDeviceUpdateHandoff } from './self-update.js';
|
|
16
17
|
import { captureRemote } from '../utils/capture.js';
|
|
17
18
|
import { VERSION } from '../version.js';
|
|
18
19
|
export class MCPDevice {
|
|
19
20
|
constructor() {
|
|
20
21
|
this.isShuttingDown = false;
|
|
21
|
-
this.bootNonce = '';
|
|
22
22
|
this.executionEngine = new LocalExecutionEngine();
|
|
23
|
+
this.stateLeases = [];
|
|
23
24
|
this.setupShutdownHandlers();
|
|
24
25
|
}
|
|
25
26
|
setupShutdownHandlers() {
|
|
26
27
|
const handleShutdown = async (signal) => {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
const forceExit = setTimeout(() => {
|
|
34
|
-
console.error('\n⚠️ Graceful shutdown timed out, forcing exit...');
|
|
35
|
-
process.exit(1);
|
|
28
|
+
console.log(this.isShuttingDown
|
|
29
|
+
? `\n${signal} received, waiting for owned resources to stop...`
|
|
30
|
+
: `\n${signal} received, initiating graceful shutdown...`);
|
|
31
|
+
const shutdownWarning = setTimeout(() => {
|
|
32
|
+
console.error('\n⚠️ Graceful shutdown is still waiting for owned resources; runtime ownership is retained.');
|
|
33
|
+
process.exitCode = 1;
|
|
36
34
|
}, 5000);
|
|
37
35
|
try {
|
|
38
36
|
await this.shutdown();
|
|
39
|
-
clearTimeout(forceExit);
|
|
40
37
|
process.exit(0);
|
|
41
38
|
}
|
|
42
39
|
catch (error) {
|
|
43
40
|
console.error('Error during shutdown:', error);
|
|
44
|
-
await captureRemote('remote_device_shutdown_handler_error', { error });
|
|
45
|
-
|
|
41
|
+
await captureRemote('remote_device_shutdown_handler_error', { error }).catch(() => { });
|
|
42
|
+
// Exiting here would make the PID lease stale while a plugin
|
|
43
|
+
// may still own its files. Keep the owner available for retry.
|
|
44
|
+
process.exitCode = 1;
|
|
45
|
+
}
|
|
46
|
+
finally {
|
|
47
|
+
clearTimeout(shutdownWarning);
|
|
46
48
|
}
|
|
47
49
|
};
|
|
48
50
|
process.on('SIGINT', () => {
|
|
49
51
|
handleShutdown('SIGINT').catch((error) => {
|
|
50
52
|
console.error('Fatal error during shutdown:', error);
|
|
51
53
|
captureRemote('remote_device_shutdown_handler_error', { error, signal: 'SIGINT' }).catch(() => { });
|
|
52
|
-
process.
|
|
54
|
+
process.exitCode = 1;
|
|
53
55
|
});
|
|
54
56
|
});
|
|
55
57
|
process.on('SIGTERM', () => {
|
|
56
58
|
handleShutdown('SIGTERM').catch((error) => {
|
|
57
59
|
console.error('Fatal error during shutdown:', error);
|
|
58
60
|
captureRemote('remote_device_shutdown_handler_error', { error, signal: 'SIGTERM' }).catch(() => { });
|
|
59
|
-
process.
|
|
61
|
+
process.exitCode = 1;
|
|
60
62
|
});
|
|
61
63
|
});
|
|
62
64
|
}
|
|
63
65
|
async start(options = {}) {
|
|
64
|
-
this.bootNonce = randomUUID();
|
|
65
66
|
try {
|
|
66
67
|
console.log('🚀 Starting MCP Device...');
|
|
67
68
|
if (process.env.DEBUG_MODE === 'true')
|
|
@@ -76,6 +77,17 @@ export class MCPDevice {
|
|
|
76
77
|
: 'foreground';
|
|
77
78
|
this.runtimeOwner = new RuntimeOwner({ mode, onStop: () => this.shutdown() });
|
|
78
79
|
await acquireRuntimeOwner(this.runtimeOwner, { confirmTakeover: options.confirmTakeover });
|
|
80
|
+
const { CONFIG_DIR } = await import('../config.js');
|
|
81
|
+
// Child shell/CLI processes must resolve the same Device-only runtime.
|
|
82
|
+
process.env.MCP_DEVICE_CONFIG_DIR = CONFIG_DIR;
|
|
83
|
+
const stateRoots = new Map();
|
|
84
|
+
for (const root of [this.runtimeOwner.paths.root, CONFIG_DIR]) {
|
|
85
|
+
const absolute = path.resolve(root);
|
|
86
|
+
stateRoots.set(process.platform === 'win32' ? absolute.toLowerCase() : absolute, absolute);
|
|
87
|
+
}
|
|
88
|
+
for (const [, root] of [...stateRoots].sort(([a], [b]) => a.localeCompare(b))) {
|
|
89
|
+
this.stateLeases.push(await acquireServerLease(root, { allowDeviceOwnerPid: process.pid }));
|
|
90
|
+
}
|
|
79
91
|
await this.runtimeOwner.bootstrap();
|
|
80
92
|
await bootstrapOfficialGatewayTrust(new GatewayDeviceConfigStore());
|
|
81
93
|
// Remote mode uses direct in-process dispatch (tool-dispatcher.ts).
|
|
@@ -92,10 +104,16 @@ export class MCPDevice {
|
|
|
92
104
|
const proxy = createGatewayProxyAgent(gatewayConfig);
|
|
93
105
|
this.gatewayProxyAgent = proxy.agent;
|
|
94
106
|
process.env.MCP_DEVICE_REMOTE = 'true';
|
|
95
|
-
console.log(`⏳ Connecting directly to MCP
|
|
107
|
+
console.log(`⏳ Connecting directly to MCP Device server ${gatewayUrl}`);
|
|
96
108
|
const identity = new GatewayDeviceIdentity();
|
|
97
109
|
const identityRecord = await identity.loadOrCreate();
|
|
98
110
|
this.runtimeOwner.setDeviceId(identityRecord.deviceId);
|
|
111
|
+
// Local providers start before pairing; local indexing needs no account session.
|
|
112
|
+
this.core = await createDeviceCore({
|
|
113
|
+
deviceId: identityRecord.deviceId,
|
|
114
|
+
allowedRoots: gatewayConfig.allowedRoots,
|
|
115
|
+
pluginPolicy: resolveDevicePluginPolicy(process.argv)
|
|
116
|
+
});
|
|
99
117
|
const enrollmentCredential = String(process.env.MCP_GATEWAY_ENROLLMENT_TOKEN || process.env.MCP_DEVICE_ENROLLMENT_TOKEN || '').trim() || undefined;
|
|
100
118
|
let pairingGrant;
|
|
101
119
|
if (!identityRecord.enrolled && !enrollmentCredential) {
|
|
@@ -119,14 +137,15 @@ export class MCPDevice {
|
|
|
119
137
|
proxyAgent: proxy.agent,
|
|
120
138
|
securityProtocolFloor: gatewayConfig.securityProtocolFloor,
|
|
121
139
|
appCaPem: gatewayConfig.appCaPem || undefined,
|
|
122
|
-
adapter:
|
|
140
|
+
adapter: { call: (tool, args) => this.core.invoke(tool, args) },
|
|
141
|
+
capabilities: () => this.core?.capabilities ?? [],
|
|
123
142
|
// In remote direct-dispatch mode, the daemon is ready once the gateway channel & dispatch are established.
|
|
124
143
|
runtimeState: () => ({
|
|
125
144
|
runtime_ready: true,
|
|
126
145
|
runtime_reason: null,
|
|
127
|
-
execution_runtime_generation:
|
|
146
|
+
execution_runtime_generation: this.core.runtimeInstanceId
|
|
128
147
|
}),
|
|
129
|
-
agentVersion: VERSION || process.env.npm_package_version || '1.0.
|
|
148
|
+
agentVersion: VERSION || process.env.npm_package_version || '1.0.12',
|
|
130
149
|
onUpdateRequest: async (targetVersion, { requestId }) => {
|
|
131
150
|
const record = await identity.loadOrCreate();
|
|
132
151
|
const prepared = await prepareDevicePackageUpdate({
|
|
@@ -178,6 +197,9 @@ export class MCPDevice {
|
|
|
178
197
|
});
|
|
179
198
|
}
|
|
180
199
|
});
|
|
200
|
+
this.unsubscribeCapabilities = this.core.onCapabilitiesChanged?.(() => {
|
|
201
|
+
this.gatewayChannel?.updateCapabilities();
|
|
202
|
+
});
|
|
181
203
|
await this.gatewayChannel.start();
|
|
182
204
|
const updateReconciliation = await reconcileDeviceUpdateAfterStart(VERSION);
|
|
183
205
|
if (updateReconciliation.action === 'success') {
|
|
@@ -218,32 +240,58 @@ export class MCPDevice {
|
|
|
218
240
|
process.exit(1);
|
|
219
241
|
}
|
|
220
242
|
}
|
|
221
|
-
|
|
222
|
-
if (this.
|
|
223
|
-
return;
|
|
243
|
+
shutdown() {
|
|
244
|
+
if (this.shutdownRequest)
|
|
245
|
+
return this.shutdownRequest;
|
|
224
246
|
this.isShuttingDown = true;
|
|
247
|
+
const request = this.performShutdown();
|
|
248
|
+
this.shutdownRequest = request;
|
|
249
|
+
// Concurrent callers share the same outcome. A rejected cleanup keeps
|
|
250
|
+
// ownership and resources available for a real retry; only success is cached.
|
|
251
|
+
void request.catch(() => {
|
|
252
|
+
if (this.shutdownRequest === request)
|
|
253
|
+
this.shutdownRequest = undefined;
|
|
254
|
+
});
|
|
255
|
+
return request;
|
|
256
|
+
}
|
|
257
|
+
async performShutdown() {
|
|
225
258
|
console.log('\n🛑 Shutting down device...');
|
|
226
259
|
try {
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
this.gatewayChannel
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
260
|
+
try {
|
|
261
|
+
this.unsubscribeCapabilities?.();
|
|
262
|
+
this.unsubscribeCapabilities = undefined;
|
|
263
|
+
if (this.gatewayChannel) {
|
|
264
|
+
console.log(' → Closing direct Gateway channel...');
|
|
265
|
+
await this.gatewayChannel.stop();
|
|
266
|
+
this.gatewayChannel = undefined;
|
|
267
|
+
}
|
|
268
|
+
if (this.gatewayProxyAgent) {
|
|
269
|
+
this.gatewayProxyAgent.destroy();
|
|
270
|
+
this.gatewayProxyAgent = undefined;
|
|
271
|
+
}
|
|
272
|
+
await new GatewayDeviceStatusStore().markOffline().catch(() => { });
|
|
235
273
|
}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
await this.
|
|
240
|
-
this.
|
|
274
|
+
finally {
|
|
275
|
+
// Release shared state only after the same Core and its plugins
|
|
276
|
+
// have stopped, including failures partway through startup.
|
|
277
|
+
await this.core?.close();
|
|
278
|
+
this.core = undefined;
|
|
279
|
+
await this.executionEngine.shutdown();
|
|
280
|
+
while (this.stateLeases.length) {
|
|
281
|
+
await this.stateLeases[this.stateLeases.length - 1]();
|
|
282
|
+
this.stateLeases.pop();
|
|
283
|
+
}
|
|
284
|
+
if (this.runtimeOwner) {
|
|
285
|
+
await this.runtimeOwner.release();
|
|
286
|
+
this.runtimeOwner = undefined;
|
|
287
|
+
}
|
|
241
288
|
}
|
|
242
289
|
console.log('✓ Device shutdown complete');
|
|
243
290
|
}
|
|
244
291
|
catch (error) {
|
|
245
292
|
console.error('Shutdown error:', error.message);
|
|
246
|
-
await captureRemote('remote_device_shutdown_error', { error });
|
|
293
|
+
await captureRemote('remote_device_shutdown_error', { error }).catch(() => { });
|
|
294
|
+
throw error;
|
|
247
295
|
}
|
|
248
296
|
}
|
|
249
297
|
}
|
|
@@ -13,7 +13,9 @@ export interface GatewayChannelOptions {
|
|
|
13
13
|
proxyAgent?: Agent;
|
|
14
14
|
securityProtocolFloor?: number;
|
|
15
15
|
appCaPem?: string;
|
|
16
|
-
adapter: GatewayToolAdapter
|
|
16
|
+
adapter: Pick<GatewayToolAdapter, 'call'>;
|
|
17
|
+
/** Healthy current capabilities, including optional extensions. */
|
|
18
|
+
capabilities?: () => string[];
|
|
17
19
|
runtimeState?: () => {
|
|
18
20
|
runtime_ready: boolean;
|
|
19
21
|
runtime_reason: string | null;
|
|
@@ -44,7 +46,12 @@ export declare class GatewayDeviceChannel {
|
|
|
44
46
|
private secureSocket?;
|
|
45
47
|
private authMode;
|
|
46
48
|
private updateInFlight?;
|
|
49
|
+
private lastAdvertisedCapabilities?;
|
|
47
50
|
constructor(options: GatewayChannelOptions);
|
|
51
|
+
private currentCapabilities;
|
|
52
|
+
private capabilityPayload;
|
|
53
|
+
/** Uses the existing authenticated v11 capability_sync frame. No reconnect. */
|
|
54
|
+
updateCapabilities(): boolean;
|
|
48
55
|
private runtimePayload;
|
|
49
56
|
start(): Promise<void>;
|
|
50
57
|
private startV2Transport;
|
|
@@ -2,7 +2,7 @@ import os from 'os';
|
|
|
2
2
|
import WebSocket from 'ws';
|
|
3
3
|
import { GatewayDeviceIdentity } from './gateway-identity.js';
|
|
4
4
|
import { DEVICE_INNER_TLS_SUBPROTOCOL, createClientInnerTls, createJsonFrameParser, encodeJsonFrame, exportDeviceAuthKeyingMaterial } from './gateway-secure-transport.js';
|
|
5
|
-
import {
|
|
5
|
+
import { gatewayCapabilities } from './gateway-tool-adapter.js';
|
|
6
6
|
import { gatewaySocketUrl } from './gateway-url-policy.js';
|
|
7
7
|
import { VERSION } from '../version.js';
|
|
8
8
|
const PROTOCOL_VERSION = 1;
|
|
@@ -19,6 +19,51 @@ export class GatewayDeviceChannel {
|
|
|
19
19
|
this.authMode = 'reconnect';
|
|
20
20
|
this.identity = options.identity || new GatewayDeviceIdentity();
|
|
21
21
|
}
|
|
22
|
+
currentCapabilities() {
|
|
23
|
+
try {
|
|
24
|
+
const supplied = this.options.capabilities?.() ?? gatewayCapabilities();
|
|
25
|
+
return [...new Set(supplied.filter(value => typeof value === 'string' && value.length > 0 && value.length <= 128))];
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
// Extension metadata must not take ordinary Device execution offline.
|
|
29
|
+
return gatewayCapabilities();
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
capabilityPayload() {
|
|
33
|
+
const capabilities = this.currentCapabilities();
|
|
34
|
+
this.lastAdvertisedCapabilities = JSON.stringify(capabilities);
|
|
35
|
+
return { capabilities, context_version: capabilities.includes('local_status') ? 1 : undefined };
|
|
36
|
+
}
|
|
37
|
+
/** Uses the existing authenticated v11 capability_sync frame. No reconnect. */
|
|
38
|
+
updateCapabilities() {
|
|
39
|
+
if (!this.authenticatedDeviceId || this.connectionEpoch === undefined ||
|
|
40
|
+
!this.socket || this.socket.readyState !== WebSocket.OPEN)
|
|
41
|
+
return false;
|
|
42
|
+
const capabilities = this.currentCapabilities();
|
|
43
|
+
const serialized = JSON.stringify(capabilities);
|
|
44
|
+
if (serialized === this.lastAdvertisedCapabilities)
|
|
45
|
+
return false;
|
|
46
|
+
try {
|
|
47
|
+
this.send({
|
|
48
|
+
protocol_version: this.protocolVersion,
|
|
49
|
+
type: 'capability_sync',
|
|
50
|
+
device_id: this.authenticatedDeviceId,
|
|
51
|
+
connection_epoch: this.connectionEpoch,
|
|
52
|
+
timestamp: Date.now(),
|
|
53
|
+
payload: {
|
|
54
|
+
capabilities,
|
|
55
|
+
agent_version: this.options.agentVersion || 'mcp-device-1',
|
|
56
|
+
package_version: VERSION
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
this.lastAdvertisedCapabilities = serialized;
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
catch {
|
|
63
|
+
// A reconnect will advertise the current getter in its normal hello.
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
22
67
|
runtimePayload() {
|
|
23
68
|
if (!this.options.runtimeState)
|
|
24
69
|
return {};
|
|
@@ -35,6 +80,7 @@ export class GatewayDeviceChannel {
|
|
|
35
80
|
async start() {
|
|
36
81
|
this.authenticatedDeviceId = undefined;
|
|
37
82
|
this.connectionEpoch = undefined;
|
|
83
|
+
this.lastAdvertisedCapabilities = undefined;
|
|
38
84
|
this.messageQueue = Promise.resolve();
|
|
39
85
|
const record = await this.identity.loadOrCreate();
|
|
40
86
|
this.protocolVersion = Number(this.options.securityProtocolFloor || 1) >= 2 ? PROTOCOL_VERSION_V2 : PROTOCOL_VERSION;
|
|
@@ -162,7 +208,7 @@ export class GatewayDeviceChannel {
|
|
|
162
208
|
platform: process.platform,
|
|
163
209
|
arch: process.arch,
|
|
164
210
|
path_style: process.platform === 'win32' ? 'windows' : 'posix',
|
|
165
|
-
|
|
211
|
+
...this.capabilityPayload(),
|
|
166
212
|
...this.runtimePayload(),
|
|
167
213
|
...(enrolling || pairing ? { public_key_pem: record.publicKeyPem } : {})
|
|
168
214
|
}
|
|
@@ -186,7 +232,7 @@ export class GatewayDeviceChannel {
|
|
|
186
232
|
platform: process.platform,
|
|
187
233
|
arch: process.arch,
|
|
188
234
|
path_style: process.platform === 'win32' ? 'windows' : 'posix',
|
|
189
|
-
|
|
235
|
+
...this.capabilityPayload(),
|
|
190
236
|
...this.runtimePayload(),
|
|
191
237
|
...(pairing || enrolling ? { public_key_pem: record.publicKeyPem, enrollment_grant: grant } : {})
|
|
192
238
|
}
|
|
@@ -247,6 +293,7 @@ export class GatewayDeviceChannel {
|
|
|
247
293
|
this.options.pairingGrant = undefined;
|
|
248
294
|
if (this.options.onStatus && message.payload)
|
|
249
295
|
await this.options.onStatus(message.payload);
|
|
296
|
+
this.updateCapabilities();
|
|
250
297
|
this.startHeartbeat();
|
|
251
298
|
this.reconnectAttempt = 0;
|
|
252
299
|
this.readyResolve?.();
|
|
@@ -456,6 +503,7 @@ export class GatewayDeviceChannel {
|
|
|
456
503
|
startHeartbeat() {
|
|
457
504
|
this.stopHeartbeat();
|
|
458
505
|
this.heartbeat = setInterval(async () => {
|
|
506
|
+
this.updateCapabilities();
|
|
459
507
|
const record = await this.identity.loadOrCreate();
|
|
460
508
|
this.send({
|
|
461
509
|
protocol_version: this.protocolVersion,
|
|
@@ -1,5 +1,11 @@
|
|
|
1
|
+
import { type CanonicalObserver } from '../context/capture.js';
|
|
2
|
+
import { type DeviceContextOptions } from '../context/device-adapter.js';
|
|
1
3
|
export declare const GATEWAY_CAPABILITIES: readonly ["read_text_file", "write_file", "edit_file", "shell_execute", "start_process", "read_process_output", "interact_with_process", "terminate_process", "image_preview", "project_inspect"];
|
|
4
|
+
export declare function gatewayCapabilities(): string[];
|
|
2
5
|
export interface GatewayToolAdapterOptions {
|
|
6
|
+
context?: DeviceContextOptions;
|
|
7
|
+
/** Trusted runtime supplies an owner/repository-bound observer, never tool arguments. */
|
|
8
|
+
observer?: CanonicalObserver;
|
|
3
9
|
allowedRoots?: string[];
|
|
4
10
|
pathValidator?: (requestedPath: string) => Promise<string>;
|
|
5
11
|
}
|
|
@@ -7,10 +13,13 @@ export declare class GatewayToolAdapter {
|
|
|
7
13
|
private allowedRoots;
|
|
8
14
|
private pathValidator;
|
|
9
15
|
private canonicalRoots?;
|
|
16
|
+
private readonly observer?;
|
|
17
|
+
private readonly context?;
|
|
10
18
|
constructor(_unusedEngine?: any, options?: GatewayToolAdapterOptions);
|
|
11
19
|
private parseSessionPid;
|
|
12
20
|
private guardPath;
|
|
13
21
|
private imagePreview;
|
|
14
22
|
call(tool: string, args?: any): Promise<any>;
|
|
23
|
+
private executeCall;
|
|
15
24
|
private editFile;
|
|
16
25
|
}
|
|
@@ -6,6 +6,11 @@ import sharp from 'sharp';
|
|
|
6
6
|
import { validatePath } from '../tools/filesystem.js';
|
|
7
7
|
import { inspectProjectOnDevice } from './project-inspection.js';
|
|
8
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';
|
|
9
14
|
const execAsync = promisify(exec);
|
|
10
15
|
const execFileAsync = promisify(execFile);
|
|
11
16
|
const MAX_REMOTE_IMAGE_SOURCE_BYTES = 32 * 1024 * 1024;
|
|
@@ -28,6 +33,9 @@ export const GATEWAY_CAPABILITIES = [
|
|
|
28
33
|
'image_preview',
|
|
29
34
|
'project_inspect'
|
|
30
35
|
];
|
|
36
|
+
export function gatewayCapabilities() {
|
|
37
|
+
return [...GATEWAY_CAPABILITIES, ...(isFeatureAuthorized('FEATURE_PUBLIC_GATEWAY') ? CONTEXT_TOOL_NAMES : [])];
|
|
38
|
+
}
|
|
31
39
|
function configuredGatewayRoots() {
|
|
32
40
|
const raw = process.env.MCP_GATEWAY_ALLOWED_ROOTS || '';
|
|
33
41
|
if (!raw.trim())
|
|
@@ -119,6 +127,8 @@ async function runShell(args) {
|
|
|
119
127
|
}
|
|
120
128
|
export class GatewayToolAdapter {
|
|
121
129
|
constructor(_unusedEngine, options = {}) {
|
|
130
|
+
this.observer = options.observer;
|
|
131
|
+
this.context = options.context;
|
|
122
132
|
this.allowedRoots = options.allowedRoots ?? configuredGatewayRoots();
|
|
123
133
|
this.pathValidator = options.pathValidator ?? validatePath;
|
|
124
134
|
}
|
|
@@ -145,7 +155,7 @@ export class GatewayToolAdapter {
|
|
|
145
155
|
this.canonicalRoots ?? (this.canonicalRoots = Promise.all(this.allowedRoots.map(root => this.pathValidator(root))));
|
|
146
156
|
const roots = await this.canonicalRoots;
|
|
147
157
|
if (!roots.some(root => isWithinRoot(candidate, root))) {
|
|
148
|
-
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' });
|
|
149
159
|
}
|
|
150
160
|
return candidate;
|
|
151
161
|
}
|
|
@@ -216,6 +226,15 @@ export class GatewayToolAdapter {
|
|
|
216
226
|
};
|
|
217
227
|
}
|
|
218
228
|
async call(tool, args = {}) {
|
|
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) {
|
|
219
238
|
const dispatch = async (name, toolArgs) => {
|
|
220
239
|
const res = await dispatchToolCall(name, toolArgs, { isRemote: true });
|
|
221
240
|
return assertSuccess(res, name);
|
|
@@ -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
|
+
}
|