@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,233 @@
|
|
|
1
|
+
import fs from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { randomUUID } from 'node:crypto';
|
|
4
|
+
import { processBirth, processNamespace, sameProcessNamespace } from './process-identity.js';
|
|
5
|
+
const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms));
|
|
6
|
+
const failure = (code, message, details = {}) => Object.assign(new Error(message), { code, ...details });
|
|
7
|
+
export async function coordinationObservation(filename) {
|
|
8
|
+
let stat;
|
|
9
|
+
try {
|
|
10
|
+
stat = await fs.lstat(filename);
|
|
11
|
+
}
|
|
12
|
+
catch (error) {
|
|
13
|
+
if (error.code === 'ENOENT')
|
|
14
|
+
return null;
|
|
15
|
+
throw error;
|
|
16
|
+
}
|
|
17
|
+
if (!stat.isFile() || stat.isSymbolicLink())
|
|
18
|
+
throw failure('COORDINATION_PATH_UNSAFE', 'Coordination path is not an ordinary file.', { path: filename });
|
|
19
|
+
let body;
|
|
20
|
+
if (stat.size <= 4096) {
|
|
21
|
+
try {
|
|
22
|
+
const parsed = JSON.parse(await fs.readFile(filename, 'utf8'));
|
|
23
|
+
if (Number.isSafeInteger(parsed.pid) && parsed.pid > 0 && typeof parsed.token === 'string' && parsed.token) {
|
|
24
|
+
body = { pid: parsed.pid, token: parsed.token, ...(Number.isFinite(parsed.createdAt) ? { createdAt: parsed.createdAt } : {}),
|
|
25
|
+
...(typeof parsed.processBirth === 'string' && parsed.processBirth.length <= 256 ? { processBirth: parsed.processBirth } : {}),
|
|
26
|
+
...(parsed.namespace && typeof parsed.namespace.platform === 'string' && typeof parsed.namespace.hostname === 'string' ? { namespace: parsed.namespace } : {}) };
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
catch { }
|
|
30
|
+
}
|
|
31
|
+
return { body, ageMs: Math.max(0, Date.now() - stat.mtimeMs), mtimeMs: stat.mtimeMs, size: stat.size };
|
|
32
|
+
}
|
|
33
|
+
export function processAppearsDead(pid) {
|
|
34
|
+
try {
|
|
35
|
+
process.kill(pid, 0);
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
return error.code === 'ESRCH';
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
export async function coordinationOwnerAbandoned(body) {
|
|
43
|
+
if (!await sameProcessNamespace(body.namespace))
|
|
44
|
+
return false;
|
|
45
|
+
if (processAppearsDead(body.pid))
|
|
46
|
+
return true;
|
|
47
|
+
if (!body.processBirth)
|
|
48
|
+
return false;
|
|
49
|
+
const actual = await processBirth(body.pid);
|
|
50
|
+
return actual !== null && actual !== body.processBirth;
|
|
51
|
+
}
|
|
52
|
+
export async function createCoordinationLock(filename, token = randomUUID()) {
|
|
53
|
+
await fs.mkdir(path.dirname(filename), { recursive: true });
|
|
54
|
+
const [birth, namespace] = await Promise.all([processBirth(process.pid), processNamespace()]);
|
|
55
|
+
const body = JSON.stringify({ pid: process.pid, token, createdAt: Date.now(), ...(birth ? { processBirth: birth } : {}), ...(namespace ? { namespace } : {}) }) + '\n';
|
|
56
|
+
const claim = filename + '.claim-' + token;
|
|
57
|
+
let handle, linked = false, direct = false;
|
|
58
|
+
try {
|
|
59
|
+
handle = await fs.open(claim, 'wx', 0o600);
|
|
60
|
+
await handle.writeFile(body);
|
|
61
|
+
await handle.sync();
|
|
62
|
+
try {
|
|
63
|
+
await fs.link(claim, filename);
|
|
64
|
+
linked = true;
|
|
65
|
+
await fs.unlink(claim);
|
|
66
|
+
return { handle, token };
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
const code = error.code;
|
|
70
|
+
if (!['EPERM', 'EXDEV', 'ENOTSUP', 'EOPNOTSUPP', 'EINVAL'].includes(String(code)))
|
|
71
|
+
throw error;
|
|
72
|
+
await handle.close();
|
|
73
|
+
handle = undefined;
|
|
74
|
+
await fs.rm(claim, { force: true });
|
|
75
|
+
try {
|
|
76
|
+
handle = await fs.open(filename, 'wx', 0o600);
|
|
77
|
+
direct = true;
|
|
78
|
+
}
|
|
79
|
+
catch (openError) {
|
|
80
|
+
const openCode = String(openError.code);
|
|
81
|
+
// The claim file was created in this directory, so EPERM/EACCES on the
|
|
82
|
+
// target itself is Windows file contention/pending deletion, not a
|
|
83
|
+
// directory permission failure. Surface it as ordinary lock busy so the
|
|
84
|
+
// caller follows the existing bounded retry/recovery path.
|
|
85
|
+
if (process.platform === 'win32' && ['EPERM', 'EACCES'].includes(openCode)) {
|
|
86
|
+
openError.code = 'EEXIST';
|
|
87
|
+
}
|
|
88
|
+
throw openError;
|
|
89
|
+
}
|
|
90
|
+
try {
|
|
91
|
+
await handle.writeFile(body);
|
|
92
|
+
await handle.sync();
|
|
93
|
+
return { handle, token };
|
|
94
|
+
}
|
|
95
|
+
catch (writeError) {
|
|
96
|
+
await handle.close();
|
|
97
|
+
handle = undefined;
|
|
98
|
+
await fs.unlink(filename).catch(() => { });
|
|
99
|
+
throw writeError;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
catch (error) {
|
|
104
|
+
if (handle)
|
|
105
|
+
await handle.close().catch(() => { });
|
|
106
|
+
if (linked) {
|
|
107
|
+
const current = await coordinationObservation(filename).catch(() => null);
|
|
108
|
+
if (current?.body?.token === token)
|
|
109
|
+
await fs.unlink(filename).catch(() => { });
|
|
110
|
+
}
|
|
111
|
+
if (direct)
|
|
112
|
+
await fs.unlink(filename).catch(() => { });
|
|
113
|
+
await fs.rm(claim, { force: true }).catch(() => { });
|
|
114
|
+
throw error;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
export async function releaseCoordinationLock(lock, filename) {
|
|
118
|
+
await lock.handle.close();
|
|
119
|
+
try {
|
|
120
|
+
const current = await coordinationObservation(filename);
|
|
121
|
+
if (current?.body?.token === lock.token)
|
|
122
|
+
await fs.unlink(filename);
|
|
123
|
+
}
|
|
124
|
+
catch (error) {
|
|
125
|
+
if (error.code !== 'ENOENT')
|
|
126
|
+
throw error;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
async function recoverObserved(lockPath, recoveryPath, observed, options, allowIncomplete, depth = 0) {
|
|
130
|
+
const recoveryToken = randomUUID();
|
|
131
|
+
let recovery;
|
|
132
|
+
try {
|
|
133
|
+
recovery = await createCoordinationLock(recoveryPath, recoveryToken);
|
|
134
|
+
}
|
|
135
|
+
catch (error) {
|
|
136
|
+
if (error.code !== 'EEXIST')
|
|
137
|
+
throw error;
|
|
138
|
+
// Recovery is itself crashable. Serialize reclamation of its abandoned
|
|
139
|
+
// generation with another guard, never an unguarded read-then-unlink.
|
|
140
|
+
// Unknown/incomplete guards remain fail-closed, including explicit repair.
|
|
141
|
+
if (depth >= 8)
|
|
142
|
+
return false;
|
|
143
|
+
const guard = await coordinationObservation(recoveryPath);
|
|
144
|
+
if (!guard?.body || !await coordinationOwnerAbandoned(guard.body))
|
|
145
|
+
return false;
|
|
146
|
+
if (!await recoverObserved(recoveryPath, recoveryPath + '.recovery', guard, options, false, depth + 1))
|
|
147
|
+
return false;
|
|
148
|
+
try {
|
|
149
|
+
recovery = await createCoordinationLock(recoveryPath, recoveryToken);
|
|
150
|
+
}
|
|
151
|
+
catch (retry) {
|
|
152
|
+
if (retry.code === 'EEXIST')
|
|
153
|
+
return false;
|
|
154
|
+
throw retry;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
try {
|
|
158
|
+
const current = await coordinationObservation(lockPath);
|
|
159
|
+
if (!current)
|
|
160
|
+
return true;
|
|
161
|
+
const same = current.mtimeMs === observed.mtimeMs && current.size === observed.size
|
|
162
|
+
&& current.body?.token === observed.body?.token && current.body?.pid === observed.body?.pid && current.body?.processBirth === observed.body?.processBirth
|
|
163
|
+
&& JSON.stringify(current.body?.namespace) === JSON.stringify(observed.body?.namespace);
|
|
164
|
+
if (!same)
|
|
165
|
+
return false;
|
|
166
|
+
if (current.body) {
|
|
167
|
+
if (!await coordinationOwnerAbandoned(current.body))
|
|
168
|
+
return false;
|
|
169
|
+
}
|
|
170
|
+
else if (!allowIncomplete || current.ageMs < (options.staleMs ?? 5000))
|
|
171
|
+
return false;
|
|
172
|
+
const abandoned = lockPath + '.abandoned-' + randomUUID();
|
|
173
|
+
if (options.retainAbandoned !== false)
|
|
174
|
+
await fs.rename(lockPath, abandoned);
|
|
175
|
+
else
|
|
176
|
+
await fs.unlink(lockPath);
|
|
177
|
+
return true;
|
|
178
|
+
}
|
|
179
|
+
finally {
|
|
180
|
+
await releaseCoordinationLock(recovery, recoveryPath);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
export async function repairCoordinationLock(lockPath, options) {
|
|
184
|
+
const observed = await coordinationObservation(lockPath);
|
|
185
|
+
if (!observed)
|
|
186
|
+
return { recovered: false, reason: 'absent' };
|
|
187
|
+
if (observed.body && !await coordinationOwnerAbandoned(observed.body))
|
|
188
|
+
throw failure(options.codes.active, (options.messagePrefix ?? 'Coordination') + ' owner is live or cannot be proved abandoned.', { path: lockPath, pid: observed.body.pid });
|
|
189
|
+
if (!observed.body && observed.ageMs < (options.staleMs ?? 5000))
|
|
190
|
+
throw failure(options.codes.active, (options.messagePrefix ?? 'Coordination') + ' lock may still be initializing.', { path: lockPath });
|
|
191
|
+
const ok = await recoverObserved(lockPath, lockPath + '.recovery', observed, options, true);
|
|
192
|
+
if (!ok)
|
|
193
|
+
throw failure(options.codes.recoveryRequired, (options.messagePrefix ?? 'Coordination') + ' ownership changed during recovery.', { path: lockPath });
|
|
194
|
+
return { recovered: true };
|
|
195
|
+
}
|
|
196
|
+
export async function withCoordinationLock(lockPath, work, options) {
|
|
197
|
+
const recoveryPath = lockPath + '.recovery';
|
|
198
|
+
if (options.breakLock)
|
|
199
|
+
await repairCoordinationLock(lockPath, options).catch(error => { if (error.reason === 'absent')
|
|
200
|
+
return; throw error; });
|
|
201
|
+
let lock;
|
|
202
|
+
const attempts = options.nonBlocking ? 1 : (options.attempts ?? 200);
|
|
203
|
+
for (let attempt = 0; attempt < attempts; attempt++) {
|
|
204
|
+
try {
|
|
205
|
+
lock = await createCoordinationLock(lockPath);
|
|
206
|
+
break;
|
|
207
|
+
}
|
|
208
|
+
catch (error) {
|
|
209
|
+
if (error.code !== 'EEXIST')
|
|
210
|
+
throw error;
|
|
211
|
+
const prior = await coordinationObservation(lockPath);
|
|
212
|
+
if (!prior)
|
|
213
|
+
continue;
|
|
214
|
+
if (prior.body && await coordinationOwnerAbandoned(prior.body)) {
|
|
215
|
+
if (await recoverObserved(lockPath, recoveryPath, prior, options, false))
|
|
216
|
+
continue;
|
|
217
|
+
}
|
|
218
|
+
if (!prior.body && prior.ageMs >= (options.staleMs ?? 5000))
|
|
219
|
+
throw failure(options.codes.recoveryRequired, (options.messagePrefix ?? 'Coordination') + ' has an incomplete old lock; explicit recovery is required.', { path: lockPath });
|
|
220
|
+
if (options.nonBlocking)
|
|
221
|
+
throw failure(options.codes.busy, (options.messagePrefix ?? 'Coordination') + ' is busy.', { path: lockPath });
|
|
222
|
+
await sleep(10);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
if (!lock)
|
|
226
|
+
throw failure(options.codes.busy, (options.messagePrefix ?? 'Coordination') + ' is busy or uninspectable.', { path: lockPath });
|
|
227
|
+
try {
|
|
228
|
+
return await work();
|
|
229
|
+
}
|
|
230
|
+
finally {
|
|
231
|
+
await releaseCoordinationLock(lock, lockPath);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type DeviceCore, type DeviceCoreOptions } from '../device/core.js';
|
|
2
|
+
import { PluginHost } from './plugin-host.js';
|
|
3
|
+
import { type Capability } from './plugin-contract.js';
|
|
4
|
+
import type { DevicePluginPolicy } from './plugin-policy.js';
|
|
5
|
+
export interface PlatformDeviceCore extends DeviceCore {
|
|
6
|
+
readonly plugins: PluginHost;
|
|
7
|
+
readonly capabilityContracts: Capability[];
|
|
8
|
+
onCapabilitiesChanged(listener: () => void): () => void;
|
|
9
|
+
}
|
|
10
|
+
export declare function createPlatformDeviceCore(options: DeviceCoreOptions & {
|
|
11
|
+
projectRoots?: string[];
|
|
12
|
+
sourceRoots?: string[];
|
|
13
|
+
bundledPlugins?: boolean;
|
|
14
|
+
pluginPolicy?: DevicePluginPolicy;
|
|
15
|
+
exposeKnowledgeMcp?: boolean;
|
|
16
|
+
}): Promise<PlatformDeviceCore>;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { createDeviceCore } from '../device/core.js';
|
|
3
|
+
import { PluginHost } from './plugin-host.js';
|
|
4
|
+
import { ActivityJournal } from './activity-journal.js';
|
|
5
|
+
import { compatible, CapabilityError } from './plugin-contract.js';
|
|
6
|
+
export async function createPlatformDeviceCore(options) {
|
|
7
|
+
const core = await createDeviceCore(options);
|
|
8
|
+
const activity = new ActivityJournal(core.stateRoot, core.deviceId, core.runtimeInstanceId);
|
|
9
|
+
const plugins = new PluginHost({ stateRoot: core.stateRoot, deviceId: core.deviceId, projectRoots: options.projectRoots ?? options.allowedRoots ?? [], sourceRoots: options.sourceRoots ?? [path.join(core.stateRoot, 'logs')] });
|
|
10
|
+
try {
|
|
11
|
+
// Core never provisions optional plugins. Legacy distribution-enabled Palace
|
|
12
|
+
// needs one explicit enable; manual installs and explicit intent are durable.
|
|
13
|
+
await plugins.start({ skipIds: ['palace'] });
|
|
14
|
+
}
|
|
15
|
+
catch (error) {
|
|
16
|
+
process.stderr.write(`[plugins] Native Device Core remains available: ${error.message}\n`);
|
|
17
|
+
}
|
|
18
|
+
let closed = false;
|
|
19
|
+
let closeRequest;
|
|
20
|
+
const pluginContracts = () => plugins.list().filter(record => record.installed && record.enabled && record.state === 'enabled').flatMap(record => record.manifest.capabilities).filter(capability => plugins.capabilities().includes(capability.name) && ['provider', 'fallback'].includes(capability.role ?? 'provider'));
|
|
21
|
+
const advertised = () => pluginContracts().filter(capability => !capability.name.startsWith('knowledge.') ? true : options.exposeKnowledgeMcp !== false && compatible(capability.version, '^1.0.0'));
|
|
22
|
+
const contracts = () => closed ? [] : [...core.capabilities.map(name => ({ name, version: '1.0.0' })), { name: 'platform.capabilities', version: '1.0.0' }, { name: 'platform.invoke', version: '1.0.0' }, ...pluginContracts()];
|
|
23
|
+
return {
|
|
24
|
+
deviceId: core.deviceId, stateRoot: core.stateRoot, runtimeInstanceId: core.runtimeInstanceId, plugins,
|
|
25
|
+
get capabilities() { return closed ? [] : [...new Set([...core.capabilities, 'platform.capabilities', 'platform.invoke', ...advertised().map(capability => capability.name)])]; },
|
|
26
|
+
get capabilityContracts() { return contracts().filter(capability => options.exposeKnowledgeMcp !== false || !capability.name.startsWith('knowledge.')); },
|
|
27
|
+
onCapabilitiesChanged: listener => plugins.onCapabilitiesChanged(listener),
|
|
28
|
+
async invoke(tool, args = {}) {
|
|
29
|
+
if (closed)
|
|
30
|
+
throw Object.assign(new Error('Device runtime is closed'), { code: 'DEVICE_NOT_READY' });
|
|
31
|
+
if (tool === 'platform.capabilities')
|
|
32
|
+
return { deviceId: core.deviceId, contracts: contracts().filter(capability => options.exposeKnowledgeMcp !== false || !capability.name.startsWith('knowledge.')) };
|
|
33
|
+
if (tool === 'platform.invoke') {
|
|
34
|
+
const request = args;
|
|
35
|
+
if (typeof request.name !== 'string' || request.name.length > 96 || (request.version !== undefined && (typeof request.version !== 'string' || request.version.length > 64)))
|
|
36
|
+
throw new CapabilityError('INVALID_ARGUMENT', 'A capability name and optional compatible contract version are required');
|
|
37
|
+
return plugins.invoke(request.name, request.input ?? {}, { version: request.version });
|
|
38
|
+
}
|
|
39
|
+
if (plugins.capabilities().includes(tool))
|
|
40
|
+
return plugins.invoke(tool, args, { version: tool.startsWith('knowledge.') ? '^1.0.0' : undefined });
|
|
41
|
+
try {
|
|
42
|
+
const result = await core.invoke(tool, args);
|
|
43
|
+
activity.record(tool, args, result);
|
|
44
|
+
return result;
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
activity.record(tool, args, undefined, error);
|
|
48
|
+
throw error;
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
async invokeNative(tool, args = {}) {
|
|
52
|
+
try {
|
|
53
|
+
const result = await core.invokeNative(tool, args);
|
|
54
|
+
activity.record(tool, args, result);
|
|
55
|
+
return result;
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
activity.record(tool, args, undefined, error);
|
|
59
|
+
throw error;
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
close() {
|
|
63
|
+
closed = true;
|
|
64
|
+
if (!closeRequest)
|
|
65
|
+
closeRequest = (async () => {
|
|
66
|
+
const failures = [];
|
|
67
|
+
for (const close of [() => plugins.close(), () => activity.close(), () => core.close()]) {
|
|
68
|
+
try {
|
|
69
|
+
await close();
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
failures.push(error);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
if (failures.length)
|
|
76
|
+
throw failures[0];
|
|
77
|
+
})().catch(error => { closeRequest = undefined; throw error; });
|
|
78
|
+
// A failed cleanup stays observable. Retrying performs real cleanup again;
|
|
79
|
+
// disabling invocation alone is never evidence that resources were freed.
|
|
80
|
+
return closeRequest;
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/** Platform exchange contract. No knowledge provider package is imported here. */
|
|
2
|
+
export interface KnowledgeScope {
|
|
3
|
+
projectId?: string;
|
|
4
|
+
visibility: 'project' | 'account' | 'local';
|
|
5
|
+
}
|
|
6
|
+
export type KnowledgeStatus = 'hypothesis' | 'observed' | 'validated' | 'stale' | 'superseded' | 'withdrawn';
|
|
7
|
+
export interface KnowledgeEvidence {
|
|
8
|
+
id: string;
|
|
9
|
+
originDeviceId: string;
|
|
10
|
+
sourceId: string;
|
|
11
|
+
sourceRef: string;
|
|
12
|
+
recordHash: string;
|
|
13
|
+
kind: 'source_trace' | 'tool_receipt' | 'postcondition';
|
|
14
|
+
sourceAvailable: boolean;
|
|
15
|
+
observedAt: number;
|
|
16
|
+
}
|
|
17
|
+
export interface KnowledgeCard {
|
|
18
|
+
id: string;
|
|
19
|
+
version: number;
|
|
20
|
+
contentHash: string;
|
|
21
|
+
summary: string;
|
|
22
|
+
body: string;
|
|
23
|
+
status: KnowledgeStatus;
|
|
24
|
+
originDeviceId: string;
|
|
25
|
+
servingDeviceId: string;
|
|
26
|
+
scope: KnowledgeScope;
|
|
27
|
+
evidence: KnowledgeEvidence[];
|
|
28
|
+
derivedFrom: string[];
|
|
29
|
+
provenance: string[];
|
|
30
|
+
updatedAt: number;
|
|
31
|
+
lastVerifiedAt: number | null;
|
|
32
|
+
}
|
|
33
|
+
export interface KnowledgePreview {
|
|
34
|
+
id: string;
|
|
35
|
+
version: number;
|
|
36
|
+
contentHash: string;
|
|
37
|
+
summary: string;
|
|
38
|
+
status: KnowledgeStatus;
|
|
39
|
+
originDeviceId: string;
|
|
40
|
+
servingDeviceId: string;
|
|
41
|
+
scope: KnowledgeScope;
|
|
42
|
+
read_ref: string;
|
|
43
|
+
evidenceCount: number;
|
|
44
|
+
lastVerifiedAt: number | null;
|
|
45
|
+
}
|
|
46
|
+
export declare const KNOWLEDGE_CONTRACT_VERSION = "1.0.0";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const KNOWLEDGE_CONTRACT_VERSION = '1.0.0';
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
interface BrokerDevice {
|
|
2
|
+
deviceId: string;
|
|
3
|
+
online: boolean;
|
|
4
|
+
capabilities: string[];
|
|
5
|
+
projects?: string[];
|
|
6
|
+
lastSeenAt?: number;
|
|
7
|
+
latencyMs?: number;
|
|
8
|
+
}
|
|
9
|
+
export interface TrustedToolContext {
|
|
10
|
+
accountId: string;
|
|
11
|
+
sessionId: string;
|
|
12
|
+
listDevices(): BrokerDevice[] | Promise<BrokerDevice[]>;
|
|
13
|
+
callDevice(options: {
|
|
14
|
+
deviceId: string;
|
|
15
|
+
tool: string;
|
|
16
|
+
arguments: Record<string, unknown>;
|
|
17
|
+
timeoutMs?: number;
|
|
18
|
+
}): Promise<unknown>;
|
|
19
|
+
}
|
|
20
|
+
export interface PlatformTool {
|
|
21
|
+
name: string;
|
|
22
|
+
description: string;
|
|
23
|
+
inputSchema: Record<string, unknown>;
|
|
24
|
+
annotations: Record<string, boolean>;
|
|
25
|
+
handler(args: Record<string, any>, context: TrustedToolContext): Promise<unknown>;
|
|
26
|
+
}
|
|
27
|
+
/** All owner and caller policy checks still flow through the authenticated wrapper. */
|
|
28
|
+
export declare function createPlatformTools(stateRoot: string): Promise<PlatformTool[]>;
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
2
|
+
import fs from 'node:fs/promises';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { randomBytes } from 'node:crypto';
|
|
5
|
+
import { KnowledgeRouter, unwrapKnowledgeResult } from './knowledge-router.js';
|
|
6
|
+
import { CapabilityError } from './plugin-contract.js';
|
|
7
|
+
/** The key is runtime state, so references survive restart and verified restore. */
|
|
8
|
+
async function referenceKey(stateRoot) {
|
|
9
|
+
await fs.mkdir(stateRoot, { recursive: true });
|
|
10
|
+
const filename = path.join(stateRoot, 'knowledge-reference.key');
|
|
11
|
+
try {
|
|
12
|
+
await fs.writeFile(filename, randomBytes(32), { flag: 'wx', mode: 0o600 });
|
|
13
|
+
}
|
|
14
|
+
catch (error) {
|
|
15
|
+
if (error.code !== 'EEXIST')
|
|
16
|
+
throw error;
|
|
17
|
+
}
|
|
18
|
+
const key = await fs.readFile(filename);
|
|
19
|
+
if (key.length !== 32)
|
|
20
|
+
throw new CapabilityError('KNOWLEDGE_KEY_INVALID', 'Persisted knowledge reference key is invalid; restore the original key');
|
|
21
|
+
return key;
|
|
22
|
+
}
|
|
23
|
+
/** All owner and caller policy checks still flow through the authenticated wrapper. */
|
|
24
|
+
export async function createPlatformTools(stateRoot) {
|
|
25
|
+
const requests = new AsyncLocalStorage();
|
|
26
|
+
const trusted = (accountId) => {
|
|
27
|
+
const context = requests.getStore();
|
|
28
|
+
if (!context || !context.accountId || context.accountId !== accountId)
|
|
29
|
+
throw new CapabilityError('AUTH_REQUIRED', 'An authenticated account context is required');
|
|
30
|
+
return context;
|
|
31
|
+
};
|
|
32
|
+
const router = new KnowledgeRouter({
|
|
33
|
+
async devices(accountId) {
|
|
34
|
+
return (await trusted(accountId).listDevices()).map(device => ({ ...device, accountId }));
|
|
35
|
+
},
|
|
36
|
+
call: (accountId, deviceId, capability, input) => trusted(accountId).callDevice({ deviceId, tool: capability, arguments: input, timeoutMs: 30000 })
|
|
37
|
+
}, { secret: await referenceKey(stateRoot) });
|
|
38
|
+
const properties = {
|
|
39
|
+
device_id: { type: 'string', minLength: 1, maxLength: 64, description: 'Owned Device requesting the knowledge. It may have no knowledge plugin.' },
|
|
40
|
+
project_id: { type: 'string', minLength: 1, maxLength: 512 },
|
|
41
|
+
max_bytes: { type: 'integer', minimum: 1024, maximum: 65536, default: 16384 }
|
|
42
|
+
};
|
|
43
|
+
const contextFor = (args, context) => {
|
|
44
|
+
if (!context.accountId || !context.sessionId)
|
|
45
|
+
throw new CapabilityError('AUTH_REQUIRED', 'An authenticated account and session are required');
|
|
46
|
+
return { accountId: context.accountId, sessionId: context.sessionId, requesterDeviceId: args.device_id };
|
|
47
|
+
};
|
|
48
|
+
const tools = ['search', 'list'].map(action => ({
|
|
49
|
+
name: 'knowledge.' + action,
|
|
50
|
+
description: action === 'search' ? 'Search compact knowledge previews across an account’s relevant available Devices. Does not import knowledge.' : 'List scoped knowledge previews on relevant available Devices. Does not import knowledge.',
|
|
51
|
+
inputSchema: { type: 'object', additionalProperties: false, required: action === 'search' ? ['device_id', 'query'] : ['device_id'], properties: { ...properties, query: { type: 'string', maxLength: 4096 }, limit: { type: 'integer', minimum: 1, maximum: 50, default: 10 }, provider_device_id: { type: 'string', minLength: 1, maxLength: 64 } } },
|
|
52
|
+
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true },
|
|
53
|
+
handler: (args, context) => requests.run(context, () => router.search(contextFor(args, context), { query: args.query, projectId: args.project_id, limit: args.limit, maxBytes: args.max_bytes, providerDeviceId: args.provider_device_id }, action))
|
|
54
|
+
}));
|
|
55
|
+
tools.push({
|
|
56
|
+
name: 'knowledge.read',
|
|
57
|
+
description: 'Read one selected knowledge reference with provenance and freshness. Lazily import that item only when the requesting Device has a storage provider; otherwise use bounded session cache. Evidence is returned only when requested.',
|
|
58
|
+
inputSchema: { type: 'object', additionalProperties: false, required: ['device_id', 'ref'], properties: { ...properties, ref: { type: 'string', minLength: 1, maxLength: 4096 }, evidence: { type: 'boolean', default: false } } },
|
|
59
|
+
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true },
|
|
60
|
+
handler: (args, context) => requests.run(context, () => router.read(contextFor(args, context), { ref: args.ref, projectId: args.project_id, evidence: args.evidence, maxBytes: args.max_bytes }))
|
|
61
|
+
});
|
|
62
|
+
tools.push({
|
|
63
|
+
name: 'capability.list',
|
|
64
|
+
description: 'Discover current capabilities advertised by an owned Device. Plugin disable, crash and dependency loss remove unavailable capabilities.',
|
|
65
|
+
inputSchema: { type: 'object', additionalProperties: false, required: ['device_id'], properties: { device_id: properties.device_id } },
|
|
66
|
+
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true },
|
|
67
|
+
async handler(args, context) {
|
|
68
|
+
if (!context.accountId)
|
|
69
|
+
throw new CapabilityError('AUTH_REQUIRED', 'An authenticated account is required');
|
|
70
|
+
const device = (await context.listDevices()).find(item => item.deviceId === args.device_id);
|
|
71
|
+
if (!device)
|
|
72
|
+
throw new CapabilityError('ACCESS_DENIED', 'Device is not owned by this account');
|
|
73
|
+
const contracts = device.online && device.capabilities.includes('platform.capabilities') ? unwrapKnowledgeResult(await context.callDevice({ deviceId: device.deviceId, tool: 'platform.capabilities', arguments: {} })).contracts : undefined;
|
|
74
|
+
return { device_id: device.deviceId, online: device.online, capabilities: device.capabilities, ...(contracts ? { contracts } : {}) };
|
|
75
|
+
}
|
|
76
|
+
}, {
|
|
77
|
+
name: 'capability.call',
|
|
78
|
+
description: 'Invoke an advertised plugin capability on an owned Device through normal caller policy. Knowledge exchange uses knowledge.search/list/read; native tools use their existing contracts.',
|
|
79
|
+
inputSchema: { type: 'object', additionalProperties: false, required: ['device_id', 'capability', 'arguments'], properties: { device_id: properties.device_id, capability: { type: 'string', pattern: '^[a-z][a-z0-9_-]*\\.[a-z0-9_.-]+$', maxLength: 96 }, version: { type: 'string', maxLength: 64, description: 'Required compatible capability contract, such as ^1.0.0 or 1.x.' }, arguments: { type: 'object', additionalProperties: true } } },
|
|
80
|
+
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false },
|
|
81
|
+
async handler(args, context) {
|
|
82
|
+
if (!context.accountId)
|
|
83
|
+
throw new CapabilityError('AUTH_REQUIRED', 'An authenticated account is required');
|
|
84
|
+
if (String(args.capability).startsWith('knowledge.'))
|
|
85
|
+
throw new CapabilityError('CAPABILITY_PRIVATE', 'Use the public knowledge exchange contract');
|
|
86
|
+
const device = (await context.listDevices()).find(item => item.deviceId === args.device_id);
|
|
87
|
+
if (!device)
|
|
88
|
+
throw new CapabilityError('ACCESS_DENIED', 'Device is not owned by this account');
|
|
89
|
+
if (!device.online || !device.capabilities.includes('platform.invoke') || !device.capabilities.includes(args.capability))
|
|
90
|
+
throw new CapabilityError('CAPABILITY_UNAVAILABLE', 'The Device does not advertise this plugin capability');
|
|
91
|
+
return context.callDevice({ deviceId: args.device_id, tool: 'platform.invoke', arguments: { name: args.capability, version: args.version, input: args.arguments }, timeoutMs: 30000 });
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
return tools;
|
|
95
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
export interface KnowledgeDevice {
|
|
2
|
+
deviceId: string;
|
|
3
|
+
accountId: string;
|
|
4
|
+
online: boolean;
|
|
5
|
+
capabilities: string[];
|
|
6
|
+
projects?: string[];
|
|
7
|
+
lastSeenAt?: number;
|
|
8
|
+
latencyMs?: number;
|
|
9
|
+
}
|
|
10
|
+
export interface KnowledgeTransport {
|
|
11
|
+
devices(accountId: string): Promise<KnowledgeDevice[]>;
|
|
12
|
+
call(accountId: string, deviceId: string, capability: string, input: unknown): Promise<unknown>;
|
|
13
|
+
}
|
|
14
|
+
export interface KnowledgeRequestContext {
|
|
15
|
+
accountId: string;
|
|
16
|
+
requesterDeviceId: string;
|
|
17
|
+
sessionId: string;
|
|
18
|
+
}
|
|
19
|
+
export declare function unwrapKnowledgeResult(value: any): any;
|
|
20
|
+
/** Account-aware routing and lazy transfer live in the platform, not in a plugin. */
|
|
21
|
+
export declare class KnowledgeRouter {
|
|
22
|
+
private transport;
|
|
23
|
+
private options;
|
|
24
|
+
private cache;
|
|
25
|
+
private cacheBytes;
|
|
26
|
+
private revisions;
|
|
27
|
+
private readonly secret;
|
|
28
|
+
constructor(transport: KnowledgeTransport, options?: {
|
|
29
|
+
secret?: Buffer;
|
|
30
|
+
cacheBytes?: number;
|
|
31
|
+
cacheTtlMs?: number;
|
|
32
|
+
maxProviders?: number;
|
|
33
|
+
now?: () => number;
|
|
34
|
+
});
|
|
35
|
+
private now;
|
|
36
|
+
private accountTag;
|
|
37
|
+
private reference;
|
|
38
|
+
private parseReference;
|
|
39
|
+
private scope;
|
|
40
|
+
private allowed;
|
|
41
|
+
private cacheKey;
|
|
42
|
+
private pruneCache;
|
|
43
|
+
private forgetCached;
|
|
44
|
+
private rememberRevision;
|
|
45
|
+
private cacheCard;
|
|
46
|
+
cacheStats(): {
|
|
47
|
+
entries: number;
|
|
48
|
+
bytes: number;
|
|
49
|
+
};
|
|
50
|
+
private preview;
|
|
51
|
+
search(context: KnowledgeRequestContext, input: {
|
|
52
|
+
query?: string;
|
|
53
|
+
projectId?: string;
|
|
54
|
+
limit?: number;
|
|
55
|
+
maxBytes?: number;
|
|
56
|
+
providerDeviceId?: string;
|
|
57
|
+
}, action?: 'search' | 'list'): Promise<unknown>;
|
|
58
|
+
read(context: KnowledgeRequestContext, input: {
|
|
59
|
+
ref: string;
|
|
60
|
+
projectId?: string;
|
|
61
|
+
evidence?: boolean;
|
|
62
|
+
maxBytes?: number;
|
|
63
|
+
}): Promise<unknown>;
|
|
64
|
+
}
|