@hcu-lab.me/mcp-device 1.0.9 → 1.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/PRIVACY.md +21 -0
- package/README.md +58 -3
- package/SECURITY.md +67 -0
- package/config/revoked-approvals.json +1 -0
- package/control-plane/config/mcp-servers.example.toml +52 -0
- package/control-plane/config/mcp-servers.toml +52 -0
- package/control-plane/contracts/device-public-contract-v1.json +733 -0
- package/control-plane/scripts/GATEWAY-LICENSE.txt +7 -0
- package/control-plane/scripts/account-http.mjs +220 -0
- package/control-plane/scripts/account-store.mjs +368 -0
- package/control-plane/scripts/admin.mjs +68 -0
- package/control-plane/scripts/auth-session.mjs +411 -0
- package/control-plane/scripts/authenticated-mcp-wrapper.mjs +1281 -0
- package/control-plane/scripts/benchmark-command.mjs +9 -0
- package/control-plane/scripts/benchmark-mcp-catalog.mjs +174 -0
- package/control-plane/scripts/catalog-budget.mjs +87 -0
- package/control-plane/scripts/check-device-public-contract.mjs +20 -0
- package/control-plane/scripts/custom-tools/index.mjs +221 -0
- package/control-plane/scripts/custom-tools/path-utils.mjs +117 -0
- package/control-plane/scripts/custom-tools/response-utils.mjs +34 -0
- package/control-plane/scripts/dashboard-http.mjs +598 -0
- package/control-plane/scripts/device-access-policy.mjs +205 -0
- package/control-plane/scripts/device-admin.mjs +43 -0
- package/control-plane/scripts/device-audit.mjs +63 -0
- package/control-plane/scripts/device-broker.mjs +1461 -0
- package/control-plane/scripts/device-execution-tool-definitions.mjs +217 -0
- package/control-plane/scripts/device-inventory.mjs +128 -0
- package/control-plane/scripts/device-pairing-http.mjs +109 -0
- package/control-plane/scripts/device-pairing-store.mjs +245 -0
- package/control-plane/scripts/device-public-contract.mjs +165 -0
- package/control-plane/scripts/device-release.mjs +95 -0
- package/control-plane/scripts/device-secure-transport.mjs +128 -0
- package/control-plane/scripts/device-store.mjs +283 -0
- package/control-plane/scripts/device-usage.mjs +657 -0
- package/control-plane/scripts/embedded-device.mjs +149 -0
- package/control-plane/scripts/enduser-ui.mjs +45 -0
- package/control-plane/scripts/external-tool-broker.mjs +179 -0
- package/control-plane/scripts/oauth-authorization-server.mjs +589 -0
- package/control-plane/scripts/operator-dashboard-http.mjs +81 -0
- package/control-plane/scripts/project-inspection.mjs +227 -0
- package/control-plane/scripts/projects/project-id.mjs +69 -0
- package/control-plane/scripts/projects/trusted-roots-projects.mjs +375 -0
- package/control-plane/scripts/prompts/index.mjs +60 -0
- package/control-plane/scripts/remote-process-sessions.mjs +78 -0
- package/control-plane/scripts/remote-tool-result.mjs +9 -0
- package/control-plane/scripts/resources/index.mjs +166 -0
- package/control-plane/scripts/runtime-profile.mjs +54 -0
- package/control-plane/scripts/shell-tool-descriptor.mjs +17 -0
- package/control-plane/scripts/skill-source-safety.mjs +46 -0
- package/control-plane/scripts/skills/README.md +70 -0
- package/control-plane/scripts/skills/_upstream_licenses/anthropic-THIRD_PARTY_NOTICES.md +405 -0
- package/control-plane/scripts/skills/_upstream_licenses/hallmark-LICENSE.txt +21 -0
- package/control-plane/scripts/skills/_upstream_licenses/ponytail-LICENSE.txt +21 -0
- package/control-plane/scripts/skills/_upstream_licenses/stitch-skills-LICENSE.txt +201 -0
- package/control-plane/scripts/skills/_upstream_licenses/superpowers-LICENSE.txt +21 -0
- package/control-plane/scripts/skills/algorithmic-art/LICENSE.txt +202 -0
- package/control-plane/scripts/skills/algorithmic-art/SKILL.md +405 -0
- package/control-plane/scripts/skills/algorithmic-art/templates/generator_template.js +223 -0
- package/control-plane/scripts/skills/algorithmic-art/templates/viewer.html +599 -0
- package/control-plane/scripts/skills/brainstorming/SKILL.md +285 -0
- package/control-plane/scripts/skills/brainstorming/scripts/frame-template.html +213 -0
- package/control-plane/scripts/skills/brainstorming/scripts/helper.js +167 -0
- package/control-plane/scripts/skills/brainstorming/scripts/server.cjs +723 -0
- package/control-plane/scripts/skills/brainstorming/scripts/start-server.sh +209 -0
- package/control-plane/scripts/skills/brainstorming/scripts/stop-server.sh +120 -0
- package/control-plane/scripts/skills/brainstorming/spec-document-reviewer-prompt.md +49 -0
- package/control-plane/scripts/skills/brainstorming/visual-companion.md +299 -0
- package/control-plane/scripts/skills/brand-guidelines/LICENSE.txt +202 -0
- package/control-plane/scripts/skills/brand-guidelines/SKILL.md +73 -0
- package/control-plane/scripts/skills/claude-api/LICENSE.txt +202 -0
- package/control-plane/scripts/skills/claude-api/SKILL.md +570 -0
- package/control-plane/scripts/skills/claude-api/csharp/claude-api/README.md +362 -0
- package/control-plane/scripts/skills/claude-api/csharp/claude-api/batches.md +14 -0
- package/control-plane/scripts/skills/claude-api/csharp/claude-api/files-api.md +25 -0
- package/control-plane/scripts/skills/claude-api/csharp/claude-api/streaming.md +28 -0
- package/control-plane/scripts/skills/claude-api/csharp/claude-api/tool-use.md +164 -0
- package/control-plane/scripts/skills/claude-api/curl/examples.md +256 -0
- package/control-plane/scripts/skills/claude-api/curl/managed-agents.md +371 -0
- package/control-plane/scripts/skills/claude-api/go/claude-api/README.md +188 -0
- package/control-plane/scripts/skills/claude-api/go/claude-api/files-api.md +23 -0
- package/control-plane/scripts/skills/claude-api/go/claude-api/streaming.md +43 -0
- package/control-plane/scripts/skills/claude-api/go/claude-api/tool-use.md +220 -0
- package/control-plane/scripts/skills/claude-api/go/managed-agents/README.md +564 -0
- package/control-plane/scripts/skills/claude-api/java/claude-api/README.md +238 -0
- package/control-plane/scripts/skills/claude-api/java/claude-api/files-api.md +27 -0
- package/control-plane/scripts/skills/claude-api/java/claude-api/streaming.md +24 -0
- package/control-plane/scripts/skills/claude-api/java/claude-api/tool-use.md +228 -0
- package/control-plane/scripts/skills/claude-api/java/managed-agents/README.md +443 -0
- package/control-plane/scripts/skills/claude-api/php/claude-api/README.md +174 -0
- package/control-plane/scripts/skills/claude-api/php/claude-api/batches.md +15 -0
- package/control-plane/scripts/skills/claude-api/php/claude-api/files-api.md +13 -0
- package/control-plane/scripts/skills/claude-api/php/claude-api/streaming.md +27 -0
- package/control-plane/scripts/skills/claude-api/php/claude-api/tool-use.md +253 -0
- package/control-plane/scripts/skills/claude-api/php/managed-agents/README.md +443 -0
- package/control-plane/scripts/skills/claude-api/python/claude-api/README.md +565 -0
- package/control-plane/scripts/skills/claude-api/python/claude-api/batches.md +198 -0
- package/control-plane/scripts/skills/claude-api/python/claude-api/files-api.md +170 -0
- package/control-plane/scripts/skills/claude-api/python/claude-api/sdk-upgrade.md +286 -0
- package/control-plane/scripts/skills/claude-api/python/claude-api/streaming.md +179 -0
- package/control-plane/scripts/skills/claude-api/python/claude-api/tool-use.md +627 -0
- package/control-plane/scripts/skills/claude-api/python/managed-agents/README.md +335 -0
- package/control-plane/scripts/skills/claude-api/ruby/claude-api/README.md +134 -0
- package/control-plane/scripts/skills/claude-api/ruby/claude-api/streaming.md +16 -0
- package/control-plane/scripts/skills/claude-api/ruby/claude-api/tool-use.md +41 -0
- package/control-plane/scripts/skills/claude-api/ruby/managed-agents/README.md +394 -0
- package/control-plane/scripts/skills/claude-api/shared/admin-api.md +179 -0
- package/control-plane/scripts/skills/claude-api/shared/agent-design.md +101 -0
- package/control-plane/scripts/skills/claude-api/shared/anthropic-cli.md +269 -0
- package/control-plane/scripts/skills/claude-api/shared/claude-platform-on-aws.md +59 -0
- package/control-plane/scripts/skills/claude-api/shared/cost-optimization.md +233 -0
- package/control-plane/scripts/skills/claude-api/shared/error-codes.md +262 -0
- package/control-plane/scripts/skills/claude-api/shared/live-sources.md +166 -0
- package/control-plane/scripts/skills/claude-api/shared/managed-agents-api-reference.md +455 -0
- package/control-plane/scripts/skills/claude-api/shared/managed-agents-client-patterns.md +220 -0
- package/control-plane/scripts/skills/claude-api/shared/managed-agents-core.md +359 -0
- package/control-plane/scripts/skills/claude-api/shared/managed-agents-environments.md +226 -0
- package/control-plane/scripts/skills/claude-api/shared/managed-agents-events.md +290 -0
- package/control-plane/scripts/skills/claude-api/shared/managed-agents-memory.md +201 -0
- package/control-plane/scripts/skills/claude-api/shared/managed-agents-multiagent.md +260 -0
- package/control-plane/scripts/skills/claude-api/shared/managed-agents-onboarding.md +82 -0
- package/control-plane/scripts/skills/claude-api/shared/managed-agents-outcomes.md +108 -0
- package/control-plane/scripts/skills/claude-api/shared/managed-agents-overview.md +77 -0
- package/control-plane/scripts/skills/claude-api/shared/managed-agents-scheduled-deployments.md +156 -0
- package/control-plane/scripts/skills/claude-api/shared/managed-agents-self-hosted-sandboxes.md +282 -0
- package/control-plane/scripts/skills/claude-api/shared/managed-agents-tools.md +504 -0
- package/control-plane/scripts/skills/claude-api/shared/managed-agents-webhooks.md +143 -0
- package/control-plane/scripts/skills/claude-api/shared/model-migration.md +1872 -0
- package/control-plane/scripts/skills/claude-api/shared/models.md +142 -0
- package/control-plane/scripts/skills/claude-api/shared/platform-availability.md +52 -0
- package/control-plane/scripts/skills/claude-api/shared/prompt-audit.md +223 -0
- package/control-plane/scripts/skills/claude-api/shared/prompt-caching.md +292 -0
- package/control-plane/scripts/skills/claude-api/shared/token-counting.md +56 -0
- package/control-plane/scripts/skills/claude-api/shared/tool-use-concepts.md +526 -0
- package/control-plane/scripts/skills/claude-api/typescript/claude-api/README.md +405 -0
- package/control-plane/scripts/skills/claude-api/typescript/claude-api/batches.md +106 -0
- package/control-plane/scripts/skills/claude-api/typescript/claude-api/files-api.md +98 -0
- package/control-plane/scripts/skills/claude-api/typescript/claude-api/streaming.md +178 -0
- package/control-plane/scripts/skills/claude-api/typescript/claude-api/tool-use.md +586 -0
- package/control-plane/scripts/skills/claude-api/typescript/managed-agents/README.md +359 -0
- package/control-plane/scripts/skills/dispatching-parallel-agents/SKILL.md +167 -0
- package/control-plane/scripts/skills/enhance-prompt/README.md +34 -0
- package/control-plane/scripts/skills/enhance-prompt/SKILL.md +204 -0
- package/control-plane/scripts/skills/enhance-prompt/references/KEYWORDS.md +114 -0
- package/control-plane/scripts/skills/executing-plans/SKILL.md +371 -0
- package/control-plane/scripts/skills/executing-plans/scripts/task-done +52 -0
- package/control-plane/scripts/skills/executing-plans/scripts/task-start +28 -0
- package/control-plane/scripts/skills/extract-design-md/SKILL.md +358 -0
- package/control-plane/scripts/skills/extract-design-md/examples/DESIGN.md +210 -0
- package/control-plane/scripts/skills/extract-design-md/references/angular.md +122 -0
- package/control-plane/scripts/skills/extract-design-md/references/plain-css.md +161 -0
- package/control-plane/scripts/skills/extract-design-md/references/react-tailwind.md +157 -0
- package/control-plane/scripts/skills/extract-design-md/references/svelte.md +101 -0
- package/control-plane/scripts/skills/extract-design-md/references/vue.md +107 -0
- package/control-plane/scripts/skills/finishing-a-development-branch/SKILL.md +225 -0
- package/control-plane/scripts/skills/frontend-design/LICENSE.txt +177 -0
- package/control-plane/scripts/skills/frontend-design/SKILL.md +71 -0
- package/control-plane/scripts/skills/hallmark/SKILL.md +558 -0
- package/control-plane/scripts/skills/hallmark/references/anti-patterns.md +418 -0
- package/control-plane/scripts/skills/hallmark/references/assets.md +406 -0
- package/control-plane/scripts/skills/hallmark/references/color.md +95 -0
- package/control-plane/scripts/skills/hallmark/references/component-cookbook.md +263 -0
- package/control-plane/scripts/skills/hallmark/references/components/c1-outlined-chip.md +12 -0
- package/control-plane/scripts/skills/hallmark/references/components/c2-inline-form-as-cta.md +16 -0
- package/control-plane/scripts/skills/hallmark/references/components/c3-typographic-link.md +8 -0
- package/control-plane/scripts/skills/hallmark/references/components/c4-sticky-bottom-bar.md +16 -0
- package/control-plane/scripts/skills/hallmark/references/components/f1-bento-grid.md +20 -0
- package/control-plane/scripts/skills/hallmark/references/components/f2-sticky-scroll-stack.md +20 -0
- package/control-plane/scripts/skills/hallmark/references/components/f3-tabular-spec-sheet.md +11 -0
- package/control-plane/scripts/skills/hallmark/references/components/f4-step-sequence.md +11 -0
- package/control-plane/scripts/skills/hallmark/references/components/f5-annotated-screenshot.md +11 -0
- package/control-plane/scripts/skills/hallmark/references/components/f6-product-card-grid.md +41 -0
- package/control-plane/scripts/skills/hallmark/references/components/ft1-mast-headed.md +13 -0
- package/control-plane/scripts/skills/hallmark/references/components/ft2-inline-rule-single-line.md +10 -0
- package/control-plane/scripts/skills/hallmark/references/components/ft3-index-style-category-list.md +12 -0
- package/control-plane/scripts/skills/hallmark/references/components/ft4-dense-typographic.md +10 -0
- package/control-plane/scripts/skills/hallmark/references/components/ft5-statement.md +21 -0
- package/control-plane/scripts/skills/hallmark/references/components/ft6-letter-close.md +19 -0
- package/control-plane/scripts/skills/hallmark/references/components/ft7-newsletter-first.md +27 -0
- package/control-plane/scripts/skills/hallmark/references/components/ft8-marquee-scroll.md +25 -0
- package/control-plane/scripts/skills/hallmark/references/components/h1-marquee.md +15 -0
- package/control-plane/scripts/skills/hallmark/references/components/h2-split-diptych.md +15 -0
- package/control-plane/scripts/skills/hallmark/references/components/h3-quote-led.md +11 -0
- package/control-plane/scripts/skills/hallmark/references/components/h4-stat-led.md +14 -0
- package/control-plane/scripts/skills/hallmark/references/components/h5-letter-hero.md +11 -0
- package/control-plane/scripts/skills/hallmark/references/components/h6-photographic-fold.md +16 -0
- package/control-plane/scripts/skills/hallmark/references/components/h7-demo-video-clipped-by-viewport-edge.md +27 -0
- package/control-plane/scripts/skills/hallmark/references/components/h8-mockup-split-browser-framed.md +23 -0
- package/control-plane/scripts/skills/hallmark/references/components/h9-custom-illustration-centerpiece.md +27 -0
- package/control-plane/scripts/skills/hallmark/references/components/n1-wordmark-2-links.md +12 -0
- package/control-plane/scripts/skills/hallmark/references/components/n10-floating-on-scroll-morph.md +19 -0
- package/control-plane/scripts/skills/hallmark/references/components/n11-mega-menu.md +40 -0
- package/control-plane/scripts/skills/hallmark/references/components/n12-banner-retract.md +34 -0
- package/control-plane/scripts/skills/hallmark/references/components/n13-inline-cmdk-pill.md +39 -0
- package/control-plane/scripts/skills/hallmark/references/components/n1b-saas-three-section.md +35 -0
- package/control-plane/scripts/skills/hallmark/references/components/n2-floating-chip.md +14 -0
- package/control-plane/scripts/skills/hallmark/references/components/n3-side-rail.md +14 -0
- package/control-plane/scripts/skills/hallmark/references/components/n4-hidden-behind-k.md +9 -0
- package/control-plane/scripts/skills/hallmark/references/components/n5-floating-pill.md +28 -0
- package/control-plane/scripts/skills/hallmark/references/components/n6-newspaper-masthead.md +24 -0
- package/control-plane/scripts/skills/hallmark/references/components/n7-brutal-slab.md +22 -0
- package/control-plane/scripts/skills/hallmark/references/components/n8-terminal-command.md +21 -0
- package/control-plane/scripts/skills/hallmark/references/components/n9-edge-aligned-minimal.md +17 -0
- package/control-plane/scripts/skills/hallmark/references/components/s1-left-margin-numbered.md +15 -0
- package/control-plane/scripts/skills/hallmark/references/components/s2-hanging.md +13 -0
- package/control-plane/scripts/skills/hallmark/references/components/s3-sticky-pinned.md +19 -0
- package/control-plane/scripts/skills/hallmark/references/components/s4-inline-no-break.md +11 -0
- package/control-plane/scripts/skills/hallmark/references/components/s5-bottom-anchored.md +13 -0
- package/control-plane/scripts/skills/hallmark/references/components/t1-pull-quote-with-marginalia.md +12 -0
- package/control-plane/scripts/skills/hallmark/references/components/t2-logo-wall-hairline.md +19 -0
- package/control-plane/scripts/skills/hallmark/references/components/t3-single-huge-quote.md +11 -0
- package/control-plane/scripts/skills/hallmark/references/components/t4-numbered-stat-strip.md +14 -0
- package/control-plane/scripts/skills/hallmark/references/contract.md +25 -0
- package/control-plane/scripts/skills/hallmark/references/copy.md +182 -0
- package/control-plane/scripts/skills/hallmark/references/custom-craft.md +626 -0
- package/control-plane/scripts/skills/hallmark/references/custom-theme.md +367 -0
- package/control-plane/scripts/skills/hallmark/references/design-md.md +116 -0
- package/control-plane/scripts/skills/hallmark/references/export-formats.md +329 -0
- package/control-plane/scripts/skills/hallmark/references/floating-nav.md +89 -0
- package/control-plane/scripts/skills/hallmark/references/genres/atmospheric.md +69 -0
- package/control-plane/scripts/skills/hallmark/references/genres/editorial.md +72 -0
- package/control-plane/scripts/skills/hallmark/references/genres/modern-minimal.md +71 -0
- package/control-plane/scripts/skills/hallmark/references/genres/playful.md +70 -0
- package/control-plane/scripts/skills/hallmark/references/hero-enrichment.md +475 -0
- package/control-plane/scripts/skills/hallmark/references/imagery-kit.md +170 -0
- package/control-plane/scripts/skills/hallmark/references/interaction-and-states.md +208 -0
- package/control-plane/scripts/skills/hallmark/references/layout-and-space.md +112 -0
- package/control-plane/scripts/skills/hallmark/references/macrostructures/01-bento-grid.md +35 -0
- package/control-plane/scripts/skills/hallmark/references/macrostructures/02-long-document.md +34 -0
- package/control-plane/scripts/skills/hallmark/references/macrostructures/03-marquee-hero.md +31 -0
- package/control-plane/scripts/skills/hallmark/references/macrostructures/04-stat-led.md +34 -0
- package/control-plane/scripts/skills/hallmark/references/macrostructures/05-workbench.md +32 -0
- package/control-plane/scripts/skills/hallmark/references/macrostructures/06-conversational-faq.md +33 -0
- package/control-plane/scripts/skills/hallmark/references/macrostructures/07-manifesto.md +32 -0
- package/control-plane/scripts/skills/hallmark/references/macrostructures/08-photographic.md +34 -0
- package/control-plane/scripts/skills/hallmark/references/macrostructures/09-quote-led.md +32 -0
- package/control-plane/scripts/skills/hallmark/references/macrostructures/10-specimen.md +32 -0
- package/control-plane/scripts/skills/hallmark/references/macrostructures/11-catalogue.md +23 -0
- package/control-plane/scripts/skills/hallmark/references/macrostructures/12-letter.md +23 -0
- package/control-plane/scripts/skills/hallmark/references/macrostructures/13-index-first.md +23 -0
- package/control-plane/scripts/skills/hallmark/references/macrostructures/14-narrative-workflow.md +23 -0
- package/control-plane/scripts/skills/hallmark/references/macrostructures/15-split-studio.md +23 -0
- package/control-plane/scripts/skills/hallmark/references/macrostructures/16-feature-stack.md +23 -0
- package/control-plane/scripts/skills/hallmark/references/macrostructures/17-type-specimen.md +23 -0
- package/control-plane/scripts/skills/hallmark/references/macrostructures/18-portfolio-grid.md +23 -0
- package/control-plane/scripts/skills/hallmark/references/macrostructures/19-map-diagram.md +23 -0
- package/control-plane/scripts/skills/hallmark/references/macrostructures/20-ecosystem-index.md +23 -0
- package/control-plane/scripts/skills/hallmark/references/macrostructures/21-component-playground.md +23 -0
- package/control-plane/scripts/skills/hallmark/references/macrostructures.md +89 -0
- package/control-plane/scripts/skills/hallmark/references/microinteractions.md +258 -0
- package/control-plane/scripts/skills/hallmark/references/motion.md +109 -0
- package/control-plane/scripts/skills/hallmark/references/preview-examples.md +49 -0
- package/control-plane/scripts/skills/hallmark/references/responsive.md +138 -0
- package/control-plane/scripts/skills/hallmark/references/slop-test.md +192 -0
- package/control-plane/scripts/skills/hallmark/references/structure.md +160 -0
- package/control-plane/scripts/skills/hallmark/references/study.md +509 -0
- package/control-plane/scripts/skills/hallmark/references/themes/carnival.md +301 -0
- package/control-plane/scripts/skills/hallmark/references/themes/cobalt.md +146 -0
- package/control-plane/scripts/skills/hallmark/references/themes/grid.md +161 -0
- package/control-plane/scripts/skills/hallmark/references/themes/hum.md +403 -0
- package/control-plane/scripts/skills/hallmark/references/themes/lumen.md +478 -0
- package/control-plane/scripts/skills/hallmark/references/typography.md +243 -0
- package/control-plane/scripts/skills/hallmark/references/upstream/recipes.md +186 -0
- package/control-plane/scripts/skills/hallmark/references/upstream/study-examples.md +176 -0
- package/control-plane/scripts/skills/hallmark/references/upstream/tokens.css +1221 -0
- package/control-plane/scripts/skills/hallmark/references/verbs/audit.md +25 -0
- package/control-plane/scripts/skills/hallmark/references/verbs/redesign.md +269 -0
- package/control-plane/scripts/skills/human-comms/SKILL.md +29 -0
- package/control-plane/scripts/skills/index.mjs +432 -0
- package/control-plane/scripts/skills/internal-comms/LICENSE.txt +202 -0
- package/control-plane/scripts/skills/internal-comms/SKILL.md +32 -0
- package/control-plane/scripts/skills/internal-comms/examples/3p-updates.md +47 -0
- package/control-plane/scripts/skills/internal-comms/examples/company-newsletter.md +65 -0
- package/control-plane/scripts/skills/internal-comms/examples/faq-answers.md +30 -0
- package/control-plane/scripts/skills/internal-comms/examples/general-comms.md +16 -0
- package/control-plane/scripts/skills/mcp-adapter.mjs +94 -0
- package/control-plane/scripts/skills/mcp-builder/LICENSE.txt +202 -0
- package/control-plane/scripts/skills/mcp-builder/SKILL.md +236 -0
- package/control-plane/scripts/skills/mcp-builder/reference/evaluation.md +602 -0
- package/control-plane/scripts/skills/mcp-builder/reference/mcp_best_practices.md +249 -0
- package/control-plane/scripts/skills/mcp-builder/reference/node_mcp_server.md +970 -0
- package/control-plane/scripts/skills/mcp-builder/reference/python_mcp_server.md +719 -0
- package/control-plane/scripts/skills/mcp-builder/scripts/connections.py +151 -0
- package/control-plane/scripts/skills/mcp-builder/scripts/evaluation.py +373 -0
- package/control-plane/scripts/skills/mcp-builder/scripts/example_evaluation.xml +22 -0
- package/control-plane/scripts/skills/mcp-builder/scripts/requirements.txt +2 -0
- package/control-plane/scripts/skills/ponytail/SKILL.md +120 -0
- package/control-plane/scripts/skills/ponytail-audit/SKILL.md +41 -0
- package/control-plane/scripts/skills/ponytail-debt/SKILL.md +44 -0
- package/control-plane/scripts/skills/ponytail-gain/SKILL.md +50 -0
- package/control-plane/scripts/skills/ponytail-help/SKILL.md +71 -0
- package/control-plane/scripts/skills/ponytail-review/SKILL.md +57 -0
- package/control-plane/scripts/skills/receiving-code-review/SKILL.md +205 -0
- package/control-plane/scripts/skills/requesting-code-review/SKILL.md +95 -0
- package/control-plane/scripts/skills/requesting-code-review/code-reviewer.md +198 -0
- package/control-plane/scripts/skills/skill-creator/LICENSE.txt +202 -0
- package/control-plane/scripts/skills/skill-creator/SKILL.md +485 -0
- package/control-plane/scripts/skills/skill-creator/agents/analyzer.md +274 -0
- package/control-plane/scripts/skills/skill-creator/agents/comparator.md +202 -0
- package/control-plane/scripts/skills/skill-creator/agents/grader.md +223 -0
- package/control-plane/scripts/skills/skill-creator/assets/eval_review.html +146 -0
- package/control-plane/scripts/skills/skill-creator/eval-viewer/generate_review.py +471 -0
- package/control-plane/scripts/skills/skill-creator/eval-viewer/viewer.html +1325 -0
- package/control-plane/scripts/skills/skill-creator/references/schemas.md +430 -0
- package/control-plane/scripts/skills/skill-creator/scripts/__init__.py +0 -0
- package/control-plane/scripts/skills/skill-creator/scripts/aggregate_benchmark.py +401 -0
- package/control-plane/scripts/skills/skill-creator/scripts/generate_report.py +326 -0
- package/control-plane/scripts/skills/skill-creator/scripts/improve_description.py +247 -0
- package/control-plane/scripts/skills/skill-creator/scripts/package_skill.py +136 -0
- package/control-plane/scripts/skills/skill-creator/scripts/quick_validate.py +103 -0
- package/control-plane/scripts/skills/skill-creator/scripts/run_eval.py +310 -0
- package/control-plane/scripts/skills/skill-creator/scripts/run_loop.py +328 -0
- package/control-plane/scripts/skills/skill-creator/scripts/utils.py +47 -0
- package/control-plane/scripts/skills/slack-gif-creator/LICENSE.txt +202 -0
- package/control-plane/scripts/skills/slack-gif-creator/SKILL.md +254 -0
- package/control-plane/scripts/skills/slack-gif-creator/core/easing.py +234 -0
- package/control-plane/scripts/skills/slack-gif-creator/core/frame_composer.py +176 -0
- package/control-plane/scripts/skills/slack-gif-creator/core/gif_builder.py +269 -0
- package/control-plane/scripts/skills/slack-gif-creator/core/validators.py +136 -0
- package/control-plane/scripts/skills/slack-gif-creator/requirements.txt +4 -0
- package/control-plane/scripts/skills/sources.json +401 -0
- package/control-plane/scripts/skills/sources.lock.json +416 -0
- package/control-plane/scripts/skills/subagent-driven-development/SKILL.md +570 -0
- package/control-plane/scripts/skills/subagent-driven-development/implementer-prompt.md +154 -0
- package/control-plane/scripts/skills/subagent-driven-development/re-review-prompt.md +115 -0
- package/control-plane/scripts/skills/subagent-driven-development/scripts/review-package +53 -0
- package/control-plane/scripts/skills/subagent-driven-development/scripts/sdd-workspace +82 -0
- package/control-plane/scripts/skills/subagent-driven-development/scripts/task-brief +43 -0
- package/control-plane/scripts/skills/subagent-driven-development/task-reviewer-prompt.md +207 -0
- package/control-plane/scripts/skills/systematic-debugging/CREATION-LOG.md +119 -0
- package/control-plane/scripts/skills/systematic-debugging/SKILL.md +283 -0
- package/control-plane/scripts/skills/systematic-debugging/condition-based-waiting-example.ts +158 -0
- package/control-plane/scripts/skills/systematic-debugging/condition-based-waiting.md +115 -0
- package/control-plane/scripts/skills/systematic-debugging/defense-in-depth.md +122 -0
- package/control-plane/scripts/skills/systematic-debugging/find-polluter.sh +72 -0
- package/control-plane/scripts/skills/systematic-debugging/root-cause-tracing.md +169 -0
- package/control-plane/scripts/skills/systematic-debugging/test-academic.md +14 -0
- package/control-plane/scripts/skills/systematic-debugging/test-pressure-1.md +58 -0
- package/control-plane/scripts/skills/systematic-debugging/test-pressure-2.md +68 -0
- package/control-plane/scripts/skills/systematic-debugging/test-pressure-3.md +69 -0
- package/control-plane/scripts/skills/test-driven-development/SKILL.md +330 -0
- package/control-plane/scripts/skills/test-driven-development/writing-good-tests.md +198 -0
- package/control-plane/scripts/skills/theme-factory/LICENSE.txt +202 -0
- package/control-plane/scripts/skills/theme-factory/SKILL.md +59 -0
- package/control-plane/scripts/skills/theme-factory/theme-showcase.pdf +0 -0
- package/control-plane/scripts/skills/theme-factory/themes/arctic-frost.md +19 -0
- package/control-plane/scripts/skills/theme-factory/themes/botanical-garden.md +19 -0
- package/control-plane/scripts/skills/theme-factory/themes/desert-rose.md +19 -0
- package/control-plane/scripts/skills/theme-factory/themes/forest-canopy.md +19 -0
- package/control-plane/scripts/skills/theme-factory/themes/golden-hour.md +19 -0
- package/control-plane/scripts/skills/theme-factory/themes/midnight-galaxy.md +19 -0
- package/control-plane/scripts/skills/theme-factory/themes/modern-minimalist.md +19 -0
- package/control-plane/scripts/skills/theme-factory/themes/ocean-depths.md +19 -0
- package/control-plane/scripts/skills/theme-factory/themes/sunset-boulevard.md +19 -0
- package/control-plane/scripts/skills/theme-factory/themes/tech-innovation.md +19 -0
- package/control-plane/scripts/skills/using-git-worktrees/SKILL.md +167 -0
- package/control-plane/scripts/skills/verification-before-completion/SKILL.md +120 -0
- package/control-plane/scripts/skills/web-artifacts-builder/LICENSE.txt +202 -0
- package/control-plane/scripts/skills/web-artifacts-builder/SKILL.md +74 -0
- package/control-plane/scripts/skills/web-artifacts-builder/scripts/bundle-artifact.sh +54 -0
- package/control-plane/scripts/skills/web-artifacts-builder/scripts/init-artifact.sh +322 -0
- package/control-plane/scripts/skills/web-artifacts-builder/scripts/shadcn-components.tar.gz +0 -0
- package/control-plane/scripts/skills/webapp-testing/LICENSE.txt +202 -0
- package/control-plane/scripts/skills/webapp-testing/SKILL.md +96 -0
- package/control-plane/scripts/skills/webapp-testing/examples/console_logging.py +35 -0
- package/control-plane/scripts/skills/webapp-testing/examples/element_discovery.py +40 -0
- package/control-plane/scripts/skills/webapp-testing/examples/static_html_automation.py +33 -0
- package/control-plane/scripts/skills/webapp-testing/scripts/with_server.py +106 -0
- package/control-plane/scripts/skills/writing-plans/SKILL.md +192 -0
- package/control-plane/scripts/skills/writing-plans/plan-document-reviewer-prompt.md +49 -0
- package/control-plane/scripts/skills/writing-skills/SKILL.md +681 -0
- package/control-plane/scripts/skills/writing-skills/anthropic-best-practices.md +1150 -0
- package/control-plane/scripts/skills/writing-skills/examples/CLAUDE_MD_TESTING.md +189 -0
- package/control-plane/scripts/skills/writing-skills/graphviz-conventions.dot +172 -0
- package/control-plane/scripts/skills/writing-skills/persuasion-principles.md +187 -0
- package/control-plane/scripts/skills/writing-skills/render-graphs.js +169 -0
- package/control-plane/scripts/skills/writing-skills/testing-skills-with-subagents.md +384 -0
- package/control-plane/scripts/smoke-mcp-schemas.mjs +30 -0
- package/control-plane/scripts/surface-config.mjs +45 -0
- package/control-plane/scripts/sync-skills.mjs +370 -0
- package/control-plane/scripts/tool-metrics.mjs +74 -0
- package/control-plane/scripts/tool-risk.mjs +156 -0
- package/control-plane/scripts/tool-surface-stability.mjs +38 -0
- package/control-plane/scripts/upstreams/catalog-cache.mjs +28 -0
- package/control-plane/scripts/upstreams/config.mjs +158 -0
- package/control-plane/scripts/upstreams/diagnostics.mjs +21 -0
- package/control-plane/scripts/upstreams/http-client.mjs +67 -0
- package/control-plane/scripts/upstreams/manager.mjs +535 -0
- package/control-plane/scripts/upstreams/names.mjs +55 -0
- package/control-plane/scripts/upstreams/presets.mjs +60 -0
- package/control-plane/scripts/upstreams/resource-uri.mjs +29 -0
- package/control-plane/scripts/upstreams/stdio-client.mjs +73 -0
- package/control-plane/scripts/workspace-registry.mjs +147 -0
- package/dist/context/authorization.d.ts +5 -0
- package/dist/context/authorization.js +70 -0
- package/dist/context/capture.d.ts +46 -0
- package/dist/context/capture.js +187 -0
- package/dist/context/cli.d.ts +47 -0
- package/dist/context/cli.js +287 -0
- package/dist/context/device-adapter.d.ts +102 -0
- package/dist/context/device-adapter.js +79 -0
- package/dist/context/gateway.d.ts +354 -0
- package/dist/context/gateway.js +50 -0
- package/dist/context/graph.d.ts +63 -0
- package/dist/context/graph.js +214 -0
- package/dist/context/importer.d.ts +8 -0
- package/dist/context/importer.js +69 -0
- package/dist/context/indexer.d.ts +14 -0
- package/dist/context/indexer.js +57 -0
- package/dist/context/migrations/index.d.ts +4 -0
- package/dist/context/migrations/index.js +87 -0
- package/dist/context/redact.d.ts +15 -0
- package/dist/context/redact.js +43 -0
- package/dist/context/repositories.d.ts +9 -0
- package/dist/context/repositories.js +45 -0
- package/dist/context/search.d.ts +63 -0
- package/dist/context/search.js +207 -0
- package/dist/context/service.d.ts +278 -0
- package/dist/context/service.js +160 -0
- package/dist/context/store.d.ts +134 -0
- package/dist/context/store.js +722 -0
- package/dist/context/text.d.ts +4 -0
- package/dist/context/text.js +14 -0
- package/dist/context/tool-contract.d.ts +534 -0
- package/dist/context/tool-contract.js +45 -0
- package/dist/device/core.d.ts +29 -0
- package/dist/device/core.js +66 -0
- package/dist/device/device.d.ts +5 -0
- package/dist/device/device.js +94 -37
- package/dist/device/gateway-channel.d.ts +8 -1
- package/dist/device/gateway-channel.js +51 -3
- package/dist/device/gateway-tool-adapter.d.ts +11 -3
- package/dist/device/gateway-tool-adapter.js +141 -98
- package/dist/device/official-trust.d.ts +12 -0
- package/dist/device/official-trust.js +25 -1
- package/dist/device/runtime-owner.js +9 -1
- package/dist/distribution.d.ts +4 -0
- package/dist/distribution.js +8 -0
- package/dist/handlers/filesystem-handlers.js +53 -37
- package/dist/handlers/search-handlers.d.ts +1 -0
- package/dist/handlers/search-handlers.js +51 -1
- package/dist/log-palace/cli.d.ts +7 -0
- package/dist/log-palace/cli.js +89 -0
- package/dist/log-palace/formats.d.ts +26 -0
- package/dist/log-palace/formats.js +126 -0
- package/dist/log-palace/store.d.ts +129 -0
- package/dist/log-palace/store.js +856 -0
- package/dist/mcp-device.d.ts +1 -1
- package/dist/mcp-device.js +28 -6
- package/dist/npm-scripts/remote.js +1 -0
- package/dist/platform/activity-journal.d.ts +16 -0
- package/dist/platform/activity-journal.js +68 -0
- package/dist/platform/cli.d.ts +1 -0
- package/dist/platform/cli.js +300 -0
- package/dist/platform/coordination-lock.d.ts +45 -0
- package/dist/platform/coordination-lock.js +233 -0
- package/dist/platform/device-runtime.d.ts +16 -0
- package/dist/platform/device-runtime.js +83 -0
- package/dist/platform/knowledge-contract.d.ts +46 -0
- package/dist/platform/knowledge-contract.js +1 -0
- package/dist/platform/knowledge-mcp.d.ts +29 -0
- package/dist/platform/knowledge-mcp.js +95 -0
- package/dist/platform/knowledge-router.d.ts +64 -0
- package/dist/platform/knowledge-router.js +320 -0
- package/dist/platform/plugin-child.d.ts +1 -0
- package/dist/platform/plugin-child.js +115 -0
- package/dist/platform/plugin-contract.d.ts +76 -0
- package/dist/platform/plugin-contract.js +53 -0
- package/dist/platform/plugin-driver.d.ts +8 -0
- package/dist/platform/plugin-driver.js +443 -0
- package/dist/platform/plugin-host.d.ts +88 -0
- package/dist/platform/plugin-host.js +817 -0
- package/dist/platform/plugin-policy.d.ts +3 -0
- package/dist/platform/plugin-policy.js +29 -0
- package/dist/platform/plugin-services.d.ts +14 -0
- package/dist/platform/plugin-services.js +32 -0
- package/dist/platform/process-identity.d.ts +9 -0
- package/dist/platform/process-identity.js +68 -0
- package/dist/platform/runtime-lease.d.ts +4 -0
- package/dist/platform/runtime-lease.js +58 -0
- package/dist/platform/runtime-root.d.ts +9 -0
- package/dist/platform/runtime-root.js +61 -0
- package/dist/platform/state-backup.d.ts +92 -0
- package/dist/platform/state-backup.js +399 -0
- package/dist/plugins/reference/plugin.d.ts +3 -0
- package/dist/plugins/reference/plugin.js +13 -0
- package/dist/search-manager.d.ts +6 -0
- package/dist/search-manager.js +123 -0
- package/dist/server.d.ts +13 -0
- package/dist/server.js +7 -3
- package/dist/terminal-manager.d.ts +16 -0
- package/dist/terminal-manager.js +137 -42
- package/dist/tool-dispatcher.d.ts +11 -0
- package/dist/tool-dispatcher.js +228 -0
- package/dist/tools/edit.js +72 -1
- package/dist/tools/filesystem.d.ts +1 -1
- package/dist/tools/filesystem.js +2 -2
- package/dist/tools/improved-process-tools.js +91 -108
- package/dist/tools/schemas.d.ts +94 -2
- package/dist/tools/schemas.js +20 -6
- package/dist/types.d.ts +8 -0
- package/dist/utils/output-budget.d.ts +6 -0
- package/dist/utils/output-budget.js +15 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +29 -6
- package/skills/mcp-device-context/SKILL.md +40 -0
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
export { validateContextInput } from './tool-contract.js';
|
|
2
|
+
/** Trusted Phase 8 entry boundary; revalidate before every privileged action.
|
|
3
|
+
* No public routes or tools are registered by importing this module. */
|
|
4
|
+
export declare function executePublicGateway<T>(action: () => T): T;
|
|
5
|
+
/** Registration is explicit and always protected by the pinned approval gate. */
|
|
6
|
+
export declare function contextToolCatalog(): {
|
|
7
|
+
name: "local_status" | "local_search" | "local_read" | "local_graph" | "local_index" | "local_wiki";
|
|
8
|
+
description: string;
|
|
9
|
+
inputSchema: {
|
|
10
|
+
type: "string";
|
|
11
|
+
minLength?: number;
|
|
12
|
+
maxLength?: number;
|
|
13
|
+
format?: "email" | "idn-email" | "uri" | "uuid" | "date-time" | "ipv4" | "ipv6" | "date" | "time" | "duration";
|
|
14
|
+
pattern?: string;
|
|
15
|
+
allOf?: {
|
|
16
|
+
pattern: string;
|
|
17
|
+
errorMessage?: import("zod-to-json-schema").ErrorMessages<{
|
|
18
|
+
pattern: string;
|
|
19
|
+
}>;
|
|
20
|
+
}[];
|
|
21
|
+
anyOf?: {
|
|
22
|
+
format: string;
|
|
23
|
+
errorMessage?: import("zod-to-json-schema").ErrorMessages<{
|
|
24
|
+
format: string;
|
|
25
|
+
}>;
|
|
26
|
+
}[];
|
|
27
|
+
errorMessage?: import("zod-to-json-schema").ErrorMessages<import("zod-to-json-schema").JsonSchema7StringType>;
|
|
28
|
+
contentEncoding?: string;
|
|
29
|
+
title?: string;
|
|
30
|
+
default?: any;
|
|
31
|
+
description?: string;
|
|
32
|
+
markdownDescription?: string;
|
|
33
|
+
definitions?: {
|
|
34
|
+
[key: string]: import("zod-to-json-schema").JsonSchema7Type;
|
|
35
|
+
} | undefined;
|
|
36
|
+
} | {
|
|
37
|
+
type: "array";
|
|
38
|
+
items?: import("zod-to-json-schema").JsonSchema7Type;
|
|
39
|
+
minItems?: number;
|
|
40
|
+
maxItems?: number;
|
|
41
|
+
errorMessages?: import("zod-to-json-schema").ErrorMessages<import("zod-to-json-schema").JsonSchema7ArrayType, "items">;
|
|
42
|
+
title?: string;
|
|
43
|
+
default?: any;
|
|
44
|
+
description?: string;
|
|
45
|
+
markdownDescription?: string;
|
|
46
|
+
definitions?: {
|
|
47
|
+
[key: string]: import("zod-to-json-schema").JsonSchema7Type;
|
|
48
|
+
} | undefined;
|
|
49
|
+
} | {
|
|
50
|
+
type: "number" | "integer";
|
|
51
|
+
minimum?: number;
|
|
52
|
+
exclusiveMinimum?: number;
|
|
53
|
+
maximum?: number;
|
|
54
|
+
exclusiveMaximum?: number;
|
|
55
|
+
multipleOf?: number;
|
|
56
|
+
errorMessage?: import("zod-to-json-schema").ErrorMessages<import("zod-to-json-schema").JsonSchema7NumberType>;
|
|
57
|
+
title?: string;
|
|
58
|
+
default?: any;
|
|
59
|
+
description?: string;
|
|
60
|
+
markdownDescription?: string;
|
|
61
|
+
definitions?: {
|
|
62
|
+
[key: string]: import("zod-to-json-schema").JsonSchema7Type;
|
|
63
|
+
} | undefined;
|
|
64
|
+
} | {
|
|
65
|
+
type: "integer";
|
|
66
|
+
format: "int64";
|
|
67
|
+
minimum?: BigInt;
|
|
68
|
+
exclusiveMinimum?: BigInt;
|
|
69
|
+
maximum?: BigInt;
|
|
70
|
+
exclusiveMaximum?: BigInt;
|
|
71
|
+
multipleOf?: BigInt;
|
|
72
|
+
errorMessage?: import("zod-to-json-schema").ErrorMessages<import("zod-to-json-schema").JsonSchema7BigintType>;
|
|
73
|
+
title?: string;
|
|
74
|
+
default?: any;
|
|
75
|
+
description?: string;
|
|
76
|
+
markdownDescription?: string;
|
|
77
|
+
definitions?: {
|
|
78
|
+
[key: string]: import("zod-to-json-schema").JsonSchema7Type;
|
|
79
|
+
} | undefined;
|
|
80
|
+
} | {
|
|
81
|
+
type: "boolean";
|
|
82
|
+
title?: string;
|
|
83
|
+
default?: any;
|
|
84
|
+
description?: string;
|
|
85
|
+
markdownDescription?: string;
|
|
86
|
+
definitions?: {
|
|
87
|
+
[key: string]: import("zod-to-json-schema").JsonSchema7Type;
|
|
88
|
+
} | undefined;
|
|
89
|
+
} | {
|
|
90
|
+
type: "integer" | "string";
|
|
91
|
+
format: "unix-time" | "date-time" | "date";
|
|
92
|
+
minimum?: number;
|
|
93
|
+
maximum?: number;
|
|
94
|
+
errorMessage?: import("zod-to-json-schema").ErrorMessages<import("zod-to-json-schema").JsonSchema7NumberType>;
|
|
95
|
+
title?: string;
|
|
96
|
+
default?: any;
|
|
97
|
+
description?: string;
|
|
98
|
+
markdownDescription?: string;
|
|
99
|
+
definitions?: {
|
|
100
|
+
[key: string]: import("zod-to-json-schema").JsonSchema7Type;
|
|
101
|
+
} | undefined;
|
|
102
|
+
} | {
|
|
103
|
+
anyOf: import("zod-to-json-schema").JsonSchema7DateType[];
|
|
104
|
+
title?: string;
|
|
105
|
+
default?: any;
|
|
106
|
+
description?: string;
|
|
107
|
+
markdownDescription?: string;
|
|
108
|
+
definitions?: {
|
|
109
|
+
[key: string]: import("zod-to-json-schema").JsonSchema7Type;
|
|
110
|
+
} | undefined;
|
|
111
|
+
} | {
|
|
112
|
+
type: "string";
|
|
113
|
+
enum: string[];
|
|
114
|
+
title?: string;
|
|
115
|
+
default?: any;
|
|
116
|
+
description?: string;
|
|
117
|
+
markdownDescription?: string;
|
|
118
|
+
definitions?: {
|
|
119
|
+
[key: string]: import("zod-to-json-schema").JsonSchema7Type;
|
|
120
|
+
} | undefined;
|
|
121
|
+
} | {
|
|
122
|
+
type: "string" | "number" | "integer" | "boolean";
|
|
123
|
+
const: string | number | boolean;
|
|
124
|
+
title?: string;
|
|
125
|
+
default?: any;
|
|
126
|
+
description?: string;
|
|
127
|
+
markdownDescription?: string;
|
|
128
|
+
definitions?: {
|
|
129
|
+
[key: string]: import("zod-to-json-schema").JsonSchema7Type;
|
|
130
|
+
} | undefined;
|
|
131
|
+
} | {
|
|
132
|
+
type: "object" | "array";
|
|
133
|
+
title?: string;
|
|
134
|
+
default?: any;
|
|
135
|
+
description?: string;
|
|
136
|
+
markdownDescription?: string;
|
|
137
|
+
definitions?: {
|
|
138
|
+
[key: string]: import("zod-to-json-schema").JsonSchema7Type;
|
|
139
|
+
} | undefined;
|
|
140
|
+
} | {
|
|
141
|
+
type: "string" | "number" | ["string", "number"];
|
|
142
|
+
enum: (string | number)[];
|
|
143
|
+
title?: string;
|
|
144
|
+
default?: any;
|
|
145
|
+
description?: string;
|
|
146
|
+
markdownDescription?: string;
|
|
147
|
+
definitions?: {
|
|
148
|
+
[key: string]: import("zod-to-json-schema").JsonSchema7Type;
|
|
149
|
+
} | undefined;
|
|
150
|
+
} | {
|
|
151
|
+
type: "null";
|
|
152
|
+
title?: string;
|
|
153
|
+
default?: any;
|
|
154
|
+
description?: string;
|
|
155
|
+
markdownDescription?: string;
|
|
156
|
+
definitions?: {
|
|
157
|
+
[key: string]: import("zod-to-json-schema").JsonSchema7Type;
|
|
158
|
+
} | undefined;
|
|
159
|
+
} | {
|
|
160
|
+
type: "object";
|
|
161
|
+
properties: Record<string, import("zod-to-json-schema").JsonSchema7Type>;
|
|
162
|
+
additionalProperties?: boolean | import("zod-to-json-schema").JsonSchema7Type;
|
|
163
|
+
required?: string[];
|
|
164
|
+
title?: string;
|
|
165
|
+
default?: any;
|
|
166
|
+
description?: string;
|
|
167
|
+
markdownDescription?: string;
|
|
168
|
+
definitions?: {
|
|
169
|
+
[key: string]: import("zod-to-json-schema").JsonSchema7Type;
|
|
170
|
+
} | undefined;
|
|
171
|
+
} | {
|
|
172
|
+
type: "object";
|
|
173
|
+
additionalProperties?: import("zod-to-json-schema").JsonSchema7Type | true;
|
|
174
|
+
propertyNames?: Omit<import("zod-to-json-schema").JsonSchema7StringType, "type"> | Omit<import("zod-to-json-schema").JsonSchema7EnumType, "type">;
|
|
175
|
+
title?: string;
|
|
176
|
+
default?: any;
|
|
177
|
+
description?: string;
|
|
178
|
+
markdownDescription?: string;
|
|
179
|
+
definitions?: {
|
|
180
|
+
[key: string]: import("zod-to-json-schema").JsonSchema7Type;
|
|
181
|
+
} | undefined;
|
|
182
|
+
} | {
|
|
183
|
+
type: "array";
|
|
184
|
+
minItems: number;
|
|
185
|
+
items: import("zod-to-json-schema").JsonSchema7Type[];
|
|
186
|
+
maxItems: number;
|
|
187
|
+
title?: string;
|
|
188
|
+
default?: any;
|
|
189
|
+
description?: string;
|
|
190
|
+
markdownDescription?: string;
|
|
191
|
+
definitions?: {
|
|
192
|
+
[key: string]: import("zod-to-json-schema").JsonSchema7Type;
|
|
193
|
+
} | undefined;
|
|
194
|
+
} | {
|
|
195
|
+
type: "array";
|
|
196
|
+
minItems: number;
|
|
197
|
+
items: import("zod-to-json-schema").JsonSchema7Type[];
|
|
198
|
+
additionalItems?: import("zod-to-json-schema").JsonSchema7Type;
|
|
199
|
+
title?: string;
|
|
200
|
+
default?: any;
|
|
201
|
+
description?: string;
|
|
202
|
+
markdownDescription?: string;
|
|
203
|
+
definitions?: {
|
|
204
|
+
[key: string]: import("zod-to-json-schema").JsonSchema7Type;
|
|
205
|
+
} | undefined;
|
|
206
|
+
} | {
|
|
207
|
+
type: ("string" | "number" | "boolean" | "null" | "integer") | ("string" | "number" | "boolean" | "null" | "integer")[];
|
|
208
|
+
title?: string;
|
|
209
|
+
default?: any;
|
|
210
|
+
description?: string;
|
|
211
|
+
markdownDescription?: string;
|
|
212
|
+
definitions?: {
|
|
213
|
+
[key: string]: import("zod-to-json-schema").JsonSchema7Type;
|
|
214
|
+
} | undefined;
|
|
215
|
+
} | {
|
|
216
|
+
type: ("string" | "number" | "boolean" | "null" | "integer") | ("string" | "number" | "boolean" | "null" | "integer")[];
|
|
217
|
+
enum: (string | number | bigint | boolean | null)[];
|
|
218
|
+
title?: string;
|
|
219
|
+
default?: any;
|
|
220
|
+
description?: string;
|
|
221
|
+
markdownDescription?: string;
|
|
222
|
+
definitions?: {
|
|
223
|
+
[key: string]: import("zod-to-json-schema").JsonSchema7Type;
|
|
224
|
+
} | undefined;
|
|
225
|
+
} | {
|
|
226
|
+
anyOf: import("zod-to-json-schema").JsonSchema7Type[];
|
|
227
|
+
title?: string;
|
|
228
|
+
default?: any;
|
|
229
|
+
description?: string;
|
|
230
|
+
markdownDescription?: string;
|
|
231
|
+
definitions?: {
|
|
232
|
+
[key: string]: import("zod-to-json-schema").JsonSchema7Type;
|
|
233
|
+
} | undefined;
|
|
234
|
+
} | {
|
|
235
|
+
not: import("zod-to-json-schema").JsonSchema7AnyType;
|
|
236
|
+
title?: string;
|
|
237
|
+
default?: any;
|
|
238
|
+
description?: string;
|
|
239
|
+
markdownDescription?: string;
|
|
240
|
+
definitions?: {
|
|
241
|
+
[key: string]: import("zod-to-json-schema").JsonSchema7Type;
|
|
242
|
+
} | undefined;
|
|
243
|
+
} | {
|
|
244
|
+
$ref: string;
|
|
245
|
+
title?: string;
|
|
246
|
+
default?: any;
|
|
247
|
+
description?: string;
|
|
248
|
+
markdownDescription?: string;
|
|
249
|
+
definitions?: {
|
|
250
|
+
[key: string]: import("zod-to-json-schema").JsonSchema7Type;
|
|
251
|
+
} | undefined;
|
|
252
|
+
} | {
|
|
253
|
+
not: import("zod-to-json-schema").JsonSchema7AnyType;
|
|
254
|
+
title?: string;
|
|
255
|
+
default?: any;
|
|
256
|
+
description?: string;
|
|
257
|
+
markdownDescription?: string;
|
|
258
|
+
definitions?: {
|
|
259
|
+
[key: string]: import("zod-to-json-schema").JsonSchema7Type;
|
|
260
|
+
} | undefined;
|
|
261
|
+
} | {
|
|
262
|
+
type: "array";
|
|
263
|
+
maxItems: 125;
|
|
264
|
+
items: {
|
|
265
|
+
type: "array";
|
|
266
|
+
items: [import("zod-to-json-schema").JsonSchema7Type, import("zod-to-json-schema").JsonSchema7Type];
|
|
267
|
+
minItems: 2;
|
|
268
|
+
maxItems: 2;
|
|
269
|
+
};
|
|
270
|
+
title?: string;
|
|
271
|
+
default?: any;
|
|
272
|
+
description?: string;
|
|
273
|
+
markdownDescription?: string;
|
|
274
|
+
definitions?: {
|
|
275
|
+
[key: string]: import("zod-to-json-schema").JsonSchema7Type;
|
|
276
|
+
} | undefined;
|
|
277
|
+
} | {
|
|
278
|
+
$ref?: string;
|
|
279
|
+
title?: string;
|
|
280
|
+
default?: any;
|
|
281
|
+
description?: string;
|
|
282
|
+
markdownDescription?: string;
|
|
283
|
+
definitions?: {
|
|
284
|
+
[key: string]: import("zod-to-json-schema").JsonSchema7Type;
|
|
285
|
+
} | undefined;
|
|
286
|
+
} | {
|
|
287
|
+
anyOf: [import("zod-to-json-schema").JsonSchema7Type, import("zod-to-json-schema").JsonSchema7NullType];
|
|
288
|
+
title?: string;
|
|
289
|
+
default?: any;
|
|
290
|
+
description?: string;
|
|
291
|
+
markdownDescription?: string;
|
|
292
|
+
definitions?: {
|
|
293
|
+
[key: string]: import("zod-to-json-schema").JsonSchema7Type;
|
|
294
|
+
} | undefined;
|
|
295
|
+
} | {
|
|
296
|
+
type: [string, "null"];
|
|
297
|
+
title?: string;
|
|
298
|
+
default?: any;
|
|
299
|
+
description?: string;
|
|
300
|
+
markdownDescription?: string;
|
|
301
|
+
definitions?: {
|
|
302
|
+
[key: string]: import("zod-to-json-schema").JsonSchema7Type;
|
|
303
|
+
} | undefined;
|
|
304
|
+
} | {
|
|
305
|
+
allOf: import("zod-to-json-schema").JsonSchema7Type[];
|
|
306
|
+
unevaluatedProperties?: boolean;
|
|
307
|
+
title?: string;
|
|
308
|
+
default?: any;
|
|
309
|
+
description?: string;
|
|
310
|
+
markdownDescription?: string;
|
|
311
|
+
definitions?: {
|
|
312
|
+
[key: string]: import("zod-to-json-schema").JsonSchema7Type;
|
|
313
|
+
} | undefined;
|
|
314
|
+
} | {
|
|
315
|
+
type: "array";
|
|
316
|
+
uniqueItems: true;
|
|
317
|
+
items?: import("zod-to-json-schema").JsonSchema7Type;
|
|
318
|
+
minItems?: number;
|
|
319
|
+
maxItems?: number;
|
|
320
|
+
errorMessage?: import("zod-to-json-schema").ErrorMessages<import("zod-to-json-schema").JsonSchema7SetType>;
|
|
321
|
+
title?: string;
|
|
322
|
+
default?: any;
|
|
323
|
+
description?: string;
|
|
324
|
+
markdownDescription?: string;
|
|
325
|
+
definitions?: {
|
|
326
|
+
[key: string]: import("zod-to-json-schema").JsonSchema7Type;
|
|
327
|
+
} | undefined;
|
|
328
|
+
};
|
|
329
|
+
annotations: {
|
|
330
|
+
readOnlyHint: boolean;
|
|
331
|
+
idempotentHint: boolean;
|
|
332
|
+
destructiveHint: boolean;
|
|
333
|
+
openWorldHint: boolean;
|
|
334
|
+
};
|
|
335
|
+
risk_lane: "read" | "write";
|
|
336
|
+
}[];
|
|
337
|
+
export interface ContextGatewayRoute {
|
|
338
|
+
resolveDevice(deviceId: string): Promise<{
|
|
339
|
+
owned: boolean;
|
|
340
|
+
online: boolean;
|
|
341
|
+
capabilities: readonly string[];
|
|
342
|
+
context_version?: number;
|
|
343
|
+
} | undefined>;
|
|
344
|
+
forward(deviceId: string, tool: string, input: Record<string, unknown>): Promise<unknown>;
|
|
345
|
+
/** Payload-free operational counters only; never arguments/results/errors. */
|
|
346
|
+
telemetry?: (event: {
|
|
347
|
+
tool: string;
|
|
348
|
+
lane: 'read' | 'write';
|
|
349
|
+
outcome: 'success' | 'error';
|
|
350
|
+
}) => void;
|
|
351
|
+
}
|
|
352
|
+
/** Stateless broker: ownership and capability checks precede device forwarding.
|
|
353
|
+
* No Store, search engine, content cache, logging or fallback exists here. */
|
|
354
|
+
export declare function callContextTool(tool: string, input: unknown, route: ContextGatewayRoute, lane: 'read' | 'write'): Promise<unknown>;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { requireFeatureAuthorized } from './authorization.js';
|
|
2
|
+
import { buildContextCatalog, validateContextInput, contextError, WIKI_DISABLED } from './tool-contract.js';
|
|
3
|
+
export { validateContextInput } from './tool-contract.js';
|
|
4
|
+
/** Trusted Phase 8 entry boundary; revalidate before every privileged action.
|
|
5
|
+
* No public routes or tools are registered by importing this module. */
|
|
6
|
+
export function executePublicGateway(action) {
|
|
7
|
+
requireFeatureAuthorized('FEATURE_PUBLIC_GATEWAY');
|
|
8
|
+
return action();
|
|
9
|
+
}
|
|
10
|
+
/** Registration is explicit and always protected by the pinned approval gate. */
|
|
11
|
+
export function contextToolCatalog() { return executePublicGateway(buildContextCatalog); }
|
|
12
|
+
/** Stateless broker: ownership and capability checks precede device forwarding.
|
|
13
|
+
* No Store, search engine, content cache, logging or fallback exists here. */
|
|
14
|
+
export function callContextTool(tool, input, route, lane) {
|
|
15
|
+
return executePublicGateway(async () => {
|
|
16
|
+
let outcome = 'error';
|
|
17
|
+
try {
|
|
18
|
+
const args = validateContextInput(tool, input);
|
|
19
|
+
const expectedLane = tool === 'local_index' ? 'write' : 'read';
|
|
20
|
+
if (lane !== expectedLane)
|
|
21
|
+
throw new Error('ACCESS_DENIED');
|
|
22
|
+
if (tool === 'local_wiki')
|
|
23
|
+
return WIKI_DISABLED;
|
|
24
|
+
if (!args.cwd && !args.project_id)
|
|
25
|
+
throw new Error('SCOPE_REQUIRED');
|
|
26
|
+
if (args.cwd && args.project_id)
|
|
27
|
+
throw new Error('SCOPE_AMBIGUOUS');
|
|
28
|
+
const device = await route.resolveDevice(args.device_id);
|
|
29
|
+
if (!device?.owned)
|
|
30
|
+
throw new Error('ACCESS_DENIED');
|
|
31
|
+
if (!device.online)
|
|
32
|
+
throw new Error('DEVICE_OFFLINE');
|
|
33
|
+
if (device.context_version !== 1 || !device.capabilities.includes(tool))
|
|
34
|
+
throw new Error('DEVICE_UNSUPPORTED');
|
|
35
|
+
const result = await route.forward(args.device_id, tool, args);
|
|
36
|
+
outcome = result?.ok === false ? 'error' : 'success';
|
|
37
|
+
return result;
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
return contextError(error);
|
|
41
|
+
}
|
|
42
|
+
finally {
|
|
43
|
+
// Observability failures must never affect domain results.
|
|
44
|
+
try {
|
|
45
|
+
route.telemetry?.({ tool: buildContextCatalog().some(entry => entry.name === tool) ? tool : 'unknown', lane, outcome });
|
|
46
|
+
}
|
|
47
|
+
catch { /* best effort */ }
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { DatabaseSync } from 'node:sqlite';
|
|
2
|
+
import { ContextStore } from './store.js';
|
|
3
|
+
export type ActivityKind = 'event' | 'file' | 'session' | 'process' | 'command' | 'test_run' | 'error_signature' | 'checkpoint' | 'revision';
|
|
4
|
+
export type ActivityRelation = 'read_from' | 'edit_succeeded' | 'write_succeeded' | 'attempted' | 'started_process' | 'observed_output' | 'mentions' | 'recorded_in' | 'checkpoint_of';
|
|
5
|
+
export interface ActivityNode {
|
|
6
|
+
node_id: string;
|
|
7
|
+
kind: ActivityKind;
|
|
8
|
+
evidence_ref: string;
|
|
9
|
+
depth: number;
|
|
10
|
+
evidence_class: 'parsed' | 'reported';
|
|
11
|
+
}
|
|
12
|
+
export interface ActivityEdge {
|
|
13
|
+
edge_id: string;
|
|
14
|
+
source: string;
|
|
15
|
+
target: string;
|
|
16
|
+
relation: ActivityRelation;
|
|
17
|
+
evidence_ref: string;
|
|
18
|
+
}
|
|
19
|
+
export interface GraphOptions {
|
|
20
|
+
refs: string[];
|
|
21
|
+
action?: 'neighbors' | 'path' | 'timeline' | 'related';
|
|
22
|
+
target?: string;
|
|
23
|
+
direction?: 'out' | 'in' | 'both';
|
|
24
|
+
relations?: ActivityRelation[];
|
|
25
|
+
max_hops?: number;
|
|
26
|
+
max_nodes?: number;
|
|
27
|
+
max_edges?: number;
|
|
28
|
+
max_visited?: number;
|
|
29
|
+
max_bytes?: number;
|
|
30
|
+
wall_ms?: number;
|
|
31
|
+
generation?: number;
|
|
32
|
+
}
|
|
33
|
+
/** Only retained redacted evidence is parsed. No temporal or exit-code causal inference. */
|
|
34
|
+
export declare function materializeActivity(db: DatabaseSync, ref: string, text: string): void;
|
|
35
|
+
/** Deterministic BFS, with limits enforced before each adjacency fetch, not after recursion. */
|
|
36
|
+
export declare function queryActivityGraph(store: ContextStore, owner: string, repo: string, input: GraphOptions): {
|
|
37
|
+
schema_version: number;
|
|
38
|
+
ok: boolean;
|
|
39
|
+
scope: {
|
|
40
|
+
repository_ref: string;
|
|
41
|
+
};
|
|
42
|
+
index: {
|
|
43
|
+
generation: number;
|
|
44
|
+
indexed_through_event: number;
|
|
45
|
+
manifest_hash: string | number | bigint | Uint8Array<ArrayBufferLike> | null;
|
|
46
|
+
pending_events: number;
|
|
47
|
+
unknown_events: number;
|
|
48
|
+
fts_documents: number;
|
|
49
|
+
};
|
|
50
|
+
coverage: {
|
|
51
|
+
complete: boolean;
|
|
52
|
+
reasons: string[];
|
|
53
|
+
};
|
|
54
|
+
nodes: ActivityNode[];
|
|
55
|
+
edges: ActivityEdge[];
|
|
56
|
+
partial: boolean;
|
|
57
|
+
next_cursor: null;
|
|
58
|
+
visited_nodes: number;
|
|
59
|
+
examined_edges: number;
|
|
60
|
+
returned_nodes: number;
|
|
61
|
+
truncated_by: string[];
|
|
62
|
+
path: string[];
|
|
63
|
+
};
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { performance } from 'node:perf_hooks';
|
|
3
|
+
const relations = ['read_from', 'edit_succeeded', 'write_succeeded', 'attempted', 'started_process', 'observed_output', 'mentions', 'recorded_in', 'checkpoint_of'];
|
|
4
|
+
const id = (...values) => createHash('sha256').update(JSON.stringify(values)).digest('hex').slice(0, 48);
|
|
5
|
+
const scalar = (value) => typeof value === 'string' && value.length > 0 && Buffer.byteLength(value) <= 4096;
|
|
6
|
+
/** Only retained redacted evidence is parsed. No temporal or exit-code causal inference. */
|
|
7
|
+
export function materializeActivity(db, ref, text) {
|
|
8
|
+
const node = (kind, key) => {
|
|
9
|
+
const nodeId = id(kind, key);
|
|
10
|
+
db.prepare('INSERT OR IGNORE INTO activity_nodes(node_id,kind,evidence_ref) VALUES(?,?,?)').run(nodeId, kind, ref);
|
|
11
|
+
return nodeId;
|
|
12
|
+
};
|
|
13
|
+
const source = node('event', ref);
|
|
14
|
+
const link = (kind, key, relation) => {
|
|
15
|
+
if (!scalar(key))
|
|
16
|
+
return;
|
|
17
|
+
const target = node(kind, key);
|
|
18
|
+
db.prepare('INSERT OR IGNORE INTO activity_edges(edge_id,source,target,relation,evidence_ref) VALUES(?,?,?,?,?)')
|
|
19
|
+
.run(id(source, target, relation, ref), source, target, relation, ref);
|
|
20
|
+
};
|
|
21
|
+
let data;
|
|
22
|
+
try {
|
|
23
|
+
const parsed = JSON.parse(text);
|
|
24
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed))
|
|
25
|
+
return;
|
|
26
|
+
data = parsed;
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const args = data.arguments && typeof data.arguments === 'object' && !Array.isArray(data.arguments) ? data.arguments : {};
|
|
32
|
+
const tool = typeof data.toolName === 'string' ? data.toolName : '';
|
|
33
|
+
// Success must be explicit. Unknown outcomes and dry-runs never become successful edits.
|
|
34
|
+
const success = data.status === 'succeeded' && data.dry_run !== true && args.dry_run !== true;
|
|
35
|
+
let fileRelation = 'mentions';
|
|
36
|
+
if (tool === 'read_file')
|
|
37
|
+
fileRelation = 'read_from';
|
|
38
|
+
if (tool === 'edit_file')
|
|
39
|
+
fileRelation = success ? 'edit_succeeded' : 'attempted';
|
|
40
|
+
if (tool === 'write_file')
|
|
41
|
+
fileRelation = success ? 'write_succeeded' : 'attempted';
|
|
42
|
+
link('file', args.path, fileRelation);
|
|
43
|
+
link('session', data.session_ref, 'recorded_in');
|
|
44
|
+
link('command', args.command, tool === 'test_run' ? 'mentions' : 'attempted');
|
|
45
|
+
// Durable execution refs only: a PID alone is never process identity.
|
|
46
|
+
let processRelation = 'mentions';
|
|
47
|
+
if (tool === 'start_process' && success)
|
|
48
|
+
processRelation = 'started_process';
|
|
49
|
+
if (tool === 'read_process_output')
|
|
50
|
+
processRelation = 'observed_output';
|
|
51
|
+
link('process', data.process_ref, processRelation);
|
|
52
|
+
link('revision', data.revision, 'recorded_in');
|
|
53
|
+
link('error_signature', data.error_signature, 'mentions');
|
|
54
|
+
if (tool === 'test_run')
|
|
55
|
+
link('test_run', ref, 'mentions');
|
|
56
|
+
if (data.observed && data.reported && typeof data.reported === 'object') {
|
|
57
|
+
link('checkpoint', ref, 'checkpoint_of');
|
|
58
|
+
const reported = data.reported;
|
|
59
|
+
if (Array.isArray(reported.evidence_refs))
|
|
60
|
+
for (const other of reported.evidence_refs.slice(0, 20)) {
|
|
61
|
+
if (scalar(other) && db.prepare("SELECT 1 FROM evidence WHERE ref=? AND retention_state='available'").get(other))
|
|
62
|
+
link('event', other, 'mentions');
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
function bound(value, fallback, maximum, minimum = 1) {
|
|
67
|
+
const n = value ?? fallback;
|
|
68
|
+
if (!Number.isSafeInteger(n) || n < minimum || n > maximum)
|
|
69
|
+
throw new Error('BUDGET_EXCEEDED');
|
|
70
|
+
return n;
|
|
71
|
+
}
|
|
72
|
+
/** Deterministic BFS, with limits enforced before each adjacency fetch, not after recursion. */
|
|
73
|
+
export function queryActivityGraph(store, owner, repo, input) {
|
|
74
|
+
store.authorize(owner, repo);
|
|
75
|
+
if (!Array.isArray(input.refs) || !input.refs.length || input.refs.length > 20 || input.refs.some(ref => !/^[a-f0-9]{48}$/.test(ref)))
|
|
76
|
+
throw new Error('BUDGET_EXCEEDED');
|
|
77
|
+
const action = input.action ?? 'neighbors', direction = input.direction ?? 'both';
|
|
78
|
+
if (!['neighbors', 'path', 'timeline', 'related'].includes(action) || !['out', 'in', 'both'].includes(direction) || input.relations?.some(r => !relations.includes(r)))
|
|
79
|
+
throw new Error('ACTION_UNSUPPORTED');
|
|
80
|
+
if (action === 'path' && (!input.target || !/^[a-f0-9]{48}$/.test(input.target)))
|
|
81
|
+
throw new Error('BUDGET_EXCEEDED');
|
|
82
|
+
const hops = bound(input.max_hops, 2, 3, 0), nodes = bound(input.max_nodes, 50, 100), edges = bound(input.max_edges, 500, 2000);
|
|
83
|
+
const visitedCap = bound(input.max_visited, 200, 1000), cap = bound(input.max_bytes, 65536, 131072), wall = bound(input.wall_ms, 25, 100);
|
|
84
|
+
const manifest = store.inspectManifest(owner, repo);
|
|
85
|
+
if (manifest.generation === null)
|
|
86
|
+
throw new Error('INDEX_MISSING');
|
|
87
|
+
const generation = input.generation ?? manifest.generation;
|
|
88
|
+
if (!Number.isSafeInteger(generation) || generation < 1 || generation > manifest.generation)
|
|
89
|
+
throw new Error('INDEX_INCOMPATIBLE');
|
|
90
|
+
return store.withReadDatabase(owner, repo, db => {
|
|
91
|
+
if (!db.prepare("SELECT 1 FROM generations WHERE generation_id=? AND status='published'").get(generation))
|
|
92
|
+
throw new Error('INDEX_INCOMPATIBLE');
|
|
93
|
+
const start = performance.now();
|
|
94
|
+
const result = { schema_version: 1, ok: true, scope: { repository_ref: repo },
|
|
95
|
+
index: { ...manifest, generation }, coverage: { complete: manifest.unknown_events === 0, reasons: manifest.unknown_events ? ['unknown_after_restart'] : [] },
|
|
96
|
+
nodes: [], edges: [], partial: false, next_cursor: null,
|
|
97
|
+
visited_nodes: 0, examined_edges: 0, returned_nodes: 0, truncated_by: [], path: [] };
|
|
98
|
+
const stop = (reason) => { result.partial = true; if (!result.truncated_by.includes(reason))
|
|
99
|
+
result.truncated_by.push(reason); };
|
|
100
|
+
const visible = db.prepare(`SELECT 1 FROM evidence p JOIN search_documents d ON d.ref=p.ref WHERE p.ref=? AND p.retention_state='available'
|
|
101
|
+
AND d.first_indexed_generation<=? AND (d.deleted_generation IS NULL OR d.deleted_generation>?)`);
|
|
102
|
+
const get = db.prepare('SELECT node_id,kind,evidence_ref FROM activity_nodes WHERE node_id=?');
|
|
103
|
+
const resolve = (ref) => {
|
|
104
|
+
const row = get.get(ref) ?? get.get(id('event', ref));
|
|
105
|
+
if (!row || !visible.get(row.evidence_ref, generation, generation))
|
|
106
|
+
return undefined;
|
|
107
|
+
return { node_id: String(row.node_id), kind: row.kind, evidence_ref: String(row.evidence_ref), depth: 0,
|
|
108
|
+
evidence_class: row.kind === 'checkpoint' ? 'reported' : 'parsed' };
|
|
109
|
+
};
|
|
110
|
+
const target = input.target ? resolve(input.target)?.node_id : undefined;
|
|
111
|
+
if (input.target && !target)
|
|
112
|
+
throw new Error('REF_NOT_FOUND');
|
|
113
|
+
const seen = new Set(), seenEdges = new Set(), parents = new Map();
|
|
114
|
+
const queue = [];
|
|
115
|
+
const add = (node) => {
|
|
116
|
+
if (seen.has(node.node_id))
|
|
117
|
+
return true;
|
|
118
|
+
if (seen.size >= visitedCap) {
|
|
119
|
+
stop('visited_nodes');
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
if (result.nodes.length >= nodes) {
|
|
123
|
+
stop('returned_nodes');
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
result.nodes.push(node);
|
|
127
|
+
result.returned_nodes = result.nodes.length;
|
|
128
|
+
result.visited_nodes = seen.size + 1;
|
|
129
|
+
if (Buffer.byteLength(JSON.stringify(result)) + 256 > cap) {
|
|
130
|
+
result.nodes.pop();
|
|
131
|
+
result.returned_nodes--;
|
|
132
|
+
result.visited_nodes--;
|
|
133
|
+
stop('response_bytes');
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
seen.add(node.node_id);
|
|
137
|
+
queue.push(node);
|
|
138
|
+
return true;
|
|
139
|
+
};
|
|
140
|
+
for (const ref of input.refs) {
|
|
141
|
+
const seed = resolve(ref);
|
|
142
|
+
if (!seed)
|
|
143
|
+
throw new Error('REF_NOT_FOUND');
|
|
144
|
+
if (!add(seed))
|
|
145
|
+
break;
|
|
146
|
+
}
|
|
147
|
+
const columns = direction === 'out' ? ['source'] : direction === 'in' ? ['target'] : ['source', 'target'];
|
|
148
|
+
const statements = columns.map(column => db.prepare(`SELECT * FROM activity_edges WHERE ${column}=? AND edge_id>? ORDER BY edge_id LIMIT ?`));
|
|
149
|
+
let found = false;
|
|
150
|
+
traversal: for (let index = 0; index < queue.length && !result.partial; index++) {
|
|
151
|
+
const current = queue[index];
|
|
152
|
+
if (current.node_id === target) {
|
|
153
|
+
found = true;
|
|
154
|
+
break;
|
|
155
|
+
}
|
|
156
|
+
if (current.depth >= hops)
|
|
157
|
+
continue;
|
|
158
|
+
for (const statement of statements) {
|
|
159
|
+
if (performance.now() - start >= wall) {
|
|
160
|
+
stop('wall_time');
|
|
161
|
+
break traversal;
|
|
162
|
+
}
|
|
163
|
+
// SQL bounds the fetch to the remaining examination budget plus one
|
|
164
|
+
// sentinel; the sentinel is never examined or returned.
|
|
165
|
+
const rows = statement.all(current.node_id, '', edges - result.examined_edges + 1);
|
|
166
|
+
for (const row of rows) {
|
|
167
|
+
if (performance.now() - start >= wall) {
|
|
168
|
+
stop('wall_time');
|
|
169
|
+
break traversal;
|
|
170
|
+
}
|
|
171
|
+
if (result.examined_edges >= edges) {
|
|
172
|
+
stop('examined_edges');
|
|
173
|
+
break traversal;
|
|
174
|
+
}
|
|
175
|
+
const after = String(row.edge_id);
|
|
176
|
+
result.examined_edges++;
|
|
177
|
+
if (seenEdges.has(after) || (input.relations && !input.relations.includes(row.relation)) || !visible.get(row.evidence_ref, generation, generation))
|
|
178
|
+
continue;
|
|
179
|
+
const nextId = String(row.source === current.node_id ? row.target : row.source);
|
|
180
|
+
const next = resolve(nextId);
|
|
181
|
+
if (!next)
|
|
182
|
+
continue;
|
|
183
|
+
next.depth = current.depth + 1;
|
|
184
|
+
if (!seen.has(nextId))
|
|
185
|
+
parents.set(nextId, current.node_id);
|
|
186
|
+
if (!add(next))
|
|
187
|
+
break traversal;
|
|
188
|
+
const edge = { edge_id: after, source: String(row.source), target: String(row.target), relation: row.relation, evidence_ref: String(row.evidence_ref) };
|
|
189
|
+
result.edges.push(edge);
|
|
190
|
+
if (Buffer.byteLength(JSON.stringify(result)) + 256 > cap) {
|
|
191
|
+
result.edges.pop();
|
|
192
|
+
stop('response_bytes');
|
|
193
|
+
break traversal;
|
|
194
|
+
}
|
|
195
|
+
seenEdges.add(after);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
if (action === 'path' && found && target) {
|
|
200
|
+
let node = target;
|
|
201
|
+
while (node) {
|
|
202
|
+
result.path.unshift(node);
|
|
203
|
+
node = parents.get(node);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
if (action === 'timeline') {
|
|
207
|
+
const timestamp = db.prepare('SELECT timestamp FROM search_documents WHERE ref=?');
|
|
208
|
+
result.nodes.sort((a, b) => Number(timestamp.get(a.evidence_ref)?.timestamp) - Number(timestamp.get(b.evidence_ref)?.timestamp) || a.node_id.localeCompare(b.node_id));
|
|
209
|
+
}
|
|
210
|
+
if (Buffer.byteLength(JSON.stringify(result)) > cap)
|
|
211
|
+
throw new Error('BUDGET_EXCEEDED');
|
|
212
|
+
return result;
|
|
213
|
+
});
|
|
214
|
+
}
|