@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.
Files changed (506) hide show
  1. package/PRIVACY.md +21 -0
  2. package/README.md +58 -3
  3. package/SECURITY.md +67 -0
  4. package/config/revoked-approvals.json +1 -0
  5. package/control-plane/config/mcp-servers.example.toml +52 -0
  6. package/control-plane/config/mcp-servers.toml +52 -0
  7. package/control-plane/contracts/device-public-contract-v1.json +733 -0
  8. package/control-plane/scripts/GATEWAY-LICENSE.txt +7 -0
  9. package/control-plane/scripts/account-http.mjs +220 -0
  10. package/control-plane/scripts/account-store.mjs +368 -0
  11. package/control-plane/scripts/admin.mjs +68 -0
  12. package/control-plane/scripts/auth-session.mjs +411 -0
  13. package/control-plane/scripts/authenticated-mcp-wrapper.mjs +1281 -0
  14. package/control-plane/scripts/benchmark-command.mjs +9 -0
  15. package/control-plane/scripts/benchmark-mcp-catalog.mjs +174 -0
  16. package/control-plane/scripts/catalog-budget.mjs +87 -0
  17. package/control-plane/scripts/check-device-public-contract.mjs +20 -0
  18. package/control-plane/scripts/custom-tools/index.mjs +221 -0
  19. package/control-plane/scripts/custom-tools/path-utils.mjs +117 -0
  20. package/control-plane/scripts/custom-tools/response-utils.mjs +34 -0
  21. package/control-plane/scripts/dashboard-http.mjs +598 -0
  22. package/control-plane/scripts/device-access-policy.mjs +205 -0
  23. package/control-plane/scripts/device-admin.mjs +43 -0
  24. package/control-plane/scripts/device-audit.mjs +63 -0
  25. package/control-plane/scripts/device-broker.mjs +1461 -0
  26. package/control-plane/scripts/device-execution-tool-definitions.mjs +217 -0
  27. package/control-plane/scripts/device-inventory.mjs +128 -0
  28. package/control-plane/scripts/device-pairing-http.mjs +109 -0
  29. package/control-plane/scripts/device-pairing-store.mjs +245 -0
  30. package/control-plane/scripts/device-public-contract.mjs +165 -0
  31. package/control-plane/scripts/device-release.mjs +95 -0
  32. package/control-plane/scripts/device-secure-transport.mjs +128 -0
  33. package/control-plane/scripts/device-store.mjs +283 -0
  34. package/control-plane/scripts/device-usage.mjs +657 -0
  35. package/control-plane/scripts/embedded-device.mjs +149 -0
  36. package/control-plane/scripts/enduser-ui.mjs +45 -0
  37. package/control-plane/scripts/external-tool-broker.mjs +179 -0
  38. package/control-plane/scripts/oauth-authorization-server.mjs +589 -0
  39. package/control-plane/scripts/operator-dashboard-http.mjs +81 -0
  40. package/control-plane/scripts/project-inspection.mjs +227 -0
  41. package/control-plane/scripts/projects/project-id.mjs +69 -0
  42. package/control-plane/scripts/projects/trusted-roots-projects.mjs +375 -0
  43. package/control-plane/scripts/prompts/index.mjs +60 -0
  44. package/control-plane/scripts/remote-process-sessions.mjs +78 -0
  45. package/control-plane/scripts/remote-tool-result.mjs +9 -0
  46. package/control-plane/scripts/resources/index.mjs +166 -0
  47. package/control-plane/scripts/runtime-profile.mjs +54 -0
  48. package/control-plane/scripts/shell-tool-descriptor.mjs +17 -0
  49. package/control-plane/scripts/skill-source-safety.mjs +46 -0
  50. package/control-plane/scripts/skills/README.md +70 -0
  51. package/control-plane/scripts/skills/_upstream_licenses/anthropic-THIRD_PARTY_NOTICES.md +405 -0
  52. package/control-plane/scripts/skills/_upstream_licenses/hallmark-LICENSE.txt +21 -0
  53. package/control-plane/scripts/skills/_upstream_licenses/ponytail-LICENSE.txt +21 -0
  54. package/control-plane/scripts/skills/_upstream_licenses/stitch-skills-LICENSE.txt +201 -0
  55. package/control-plane/scripts/skills/_upstream_licenses/superpowers-LICENSE.txt +21 -0
  56. package/control-plane/scripts/skills/algorithmic-art/LICENSE.txt +202 -0
  57. package/control-plane/scripts/skills/algorithmic-art/SKILL.md +405 -0
  58. package/control-plane/scripts/skills/algorithmic-art/templates/generator_template.js +223 -0
  59. package/control-plane/scripts/skills/algorithmic-art/templates/viewer.html +599 -0
  60. package/control-plane/scripts/skills/brainstorming/SKILL.md +285 -0
  61. package/control-plane/scripts/skills/brainstorming/scripts/frame-template.html +213 -0
  62. package/control-plane/scripts/skills/brainstorming/scripts/helper.js +167 -0
  63. package/control-plane/scripts/skills/brainstorming/scripts/server.cjs +723 -0
  64. package/control-plane/scripts/skills/brainstorming/scripts/start-server.sh +209 -0
  65. package/control-plane/scripts/skills/brainstorming/scripts/stop-server.sh +120 -0
  66. package/control-plane/scripts/skills/brainstorming/spec-document-reviewer-prompt.md +49 -0
  67. package/control-plane/scripts/skills/brainstorming/visual-companion.md +299 -0
  68. package/control-plane/scripts/skills/brand-guidelines/LICENSE.txt +202 -0
  69. package/control-plane/scripts/skills/brand-guidelines/SKILL.md +73 -0
  70. package/control-plane/scripts/skills/claude-api/LICENSE.txt +202 -0
  71. package/control-plane/scripts/skills/claude-api/SKILL.md +570 -0
  72. package/control-plane/scripts/skills/claude-api/csharp/claude-api/README.md +362 -0
  73. package/control-plane/scripts/skills/claude-api/csharp/claude-api/batches.md +14 -0
  74. package/control-plane/scripts/skills/claude-api/csharp/claude-api/files-api.md +25 -0
  75. package/control-plane/scripts/skills/claude-api/csharp/claude-api/streaming.md +28 -0
  76. package/control-plane/scripts/skills/claude-api/csharp/claude-api/tool-use.md +164 -0
  77. package/control-plane/scripts/skills/claude-api/curl/examples.md +256 -0
  78. package/control-plane/scripts/skills/claude-api/curl/managed-agents.md +371 -0
  79. package/control-plane/scripts/skills/claude-api/go/claude-api/README.md +188 -0
  80. package/control-plane/scripts/skills/claude-api/go/claude-api/files-api.md +23 -0
  81. package/control-plane/scripts/skills/claude-api/go/claude-api/streaming.md +43 -0
  82. package/control-plane/scripts/skills/claude-api/go/claude-api/tool-use.md +220 -0
  83. package/control-plane/scripts/skills/claude-api/go/managed-agents/README.md +564 -0
  84. package/control-plane/scripts/skills/claude-api/java/claude-api/README.md +238 -0
  85. package/control-plane/scripts/skills/claude-api/java/claude-api/files-api.md +27 -0
  86. package/control-plane/scripts/skills/claude-api/java/claude-api/streaming.md +24 -0
  87. package/control-plane/scripts/skills/claude-api/java/claude-api/tool-use.md +228 -0
  88. package/control-plane/scripts/skills/claude-api/java/managed-agents/README.md +443 -0
  89. package/control-plane/scripts/skills/claude-api/php/claude-api/README.md +174 -0
  90. package/control-plane/scripts/skills/claude-api/php/claude-api/batches.md +15 -0
  91. package/control-plane/scripts/skills/claude-api/php/claude-api/files-api.md +13 -0
  92. package/control-plane/scripts/skills/claude-api/php/claude-api/streaming.md +27 -0
  93. package/control-plane/scripts/skills/claude-api/php/claude-api/tool-use.md +253 -0
  94. package/control-plane/scripts/skills/claude-api/php/managed-agents/README.md +443 -0
  95. package/control-plane/scripts/skills/claude-api/python/claude-api/README.md +565 -0
  96. package/control-plane/scripts/skills/claude-api/python/claude-api/batches.md +198 -0
  97. package/control-plane/scripts/skills/claude-api/python/claude-api/files-api.md +170 -0
  98. package/control-plane/scripts/skills/claude-api/python/claude-api/sdk-upgrade.md +286 -0
  99. package/control-plane/scripts/skills/claude-api/python/claude-api/streaming.md +179 -0
  100. package/control-plane/scripts/skills/claude-api/python/claude-api/tool-use.md +627 -0
  101. package/control-plane/scripts/skills/claude-api/python/managed-agents/README.md +335 -0
  102. package/control-plane/scripts/skills/claude-api/ruby/claude-api/README.md +134 -0
  103. package/control-plane/scripts/skills/claude-api/ruby/claude-api/streaming.md +16 -0
  104. package/control-plane/scripts/skills/claude-api/ruby/claude-api/tool-use.md +41 -0
  105. package/control-plane/scripts/skills/claude-api/ruby/managed-agents/README.md +394 -0
  106. package/control-plane/scripts/skills/claude-api/shared/admin-api.md +179 -0
  107. package/control-plane/scripts/skills/claude-api/shared/agent-design.md +101 -0
  108. package/control-plane/scripts/skills/claude-api/shared/anthropic-cli.md +269 -0
  109. package/control-plane/scripts/skills/claude-api/shared/claude-platform-on-aws.md +59 -0
  110. package/control-plane/scripts/skills/claude-api/shared/cost-optimization.md +233 -0
  111. package/control-plane/scripts/skills/claude-api/shared/error-codes.md +262 -0
  112. package/control-plane/scripts/skills/claude-api/shared/live-sources.md +166 -0
  113. package/control-plane/scripts/skills/claude-api/shared/managed-agents-api-reference.md +455 -0
  114. package/control-plane/scripts/skills/claude-api/shared/managed-agents-client-patterns.md +220 -0
  115. package/control-plane/scripts/skills/claude-api/shared/managed-agents-core.md +359 -0
  116. package/control-plane/scripts/skills/claude-api/shared/managed-agents-environments.md +226 -0
  117. package/control-plane/scripts/skills/claude-api/shared/managed-agents-events.md +290 -0
  118. package/control-plane/scripts/skills/claude-api/shared/managed-agents-memory.md +201 -0
  119. package/control-plane/scripts/skills/claude-api/shared/managed-agents-multiagent.md +260 -0
  120. package/control-plane/scripts/skills/claude-api/shared/managed-agents-onboarding.md +82 -0
  121. package/control-plane/scripts/skills/claude-api/shared/managed-agents-outcomes.md +108 -0
  122. package/control-plane/scripts/skills/claude-api/shared/managed-agents-overview.md +77 -0
  123. package/control-plane/scripts/skills/claude-api/shared/managed-agents-scheduled-deployments.md +156 -0
  124. package/control-plane/scripts/skills/claude-api/shared/managed-agents-self-hosted-sandboxes.md +282 -0
  125. package/control-plane/scripts/skills/claude-api/shared/managed-agents-tools.md +504 -0
  126. package/control-plane/scripts/skills/claude-api/shared/managed-agents-webhooks.md +143 -0
  127. package/control-plane/scripts/skills/claude-api/shared/model-migration.md +1872 -0
  128. package/control-plane/scripts/skills/claude-api/shared/models.md +142 -0
  129. package/control-plane/scripts/skills/claude-api/shared/platform-availability.md +52 -0
  130. package/control-plane/scripts/skills/claude-api/shared/prompt-audit.md +223 -0
  131. package/control-plane/scripts/skills/claude-api/shared/prompt-caching.md +292 -0
  132. package/control-plane/scripts/skills/claude-api/shared/token-counting.md +56 -0
  133. package/control-plane/scripts/skills/claude-api/shared/tool-use-concepts.md +526 -0
  134. package/control-plane/scripts/skills/claude-api/typescript/claude-api/README.md +405 -0
  135. package/control-plane/scripts/skills/claude-api/typescript/claude-api/batches.md +106 -0
  136. package/control-plane/scripts/skills/claude-api/typescript/claude-api/files-api.md +98 -0
  137. package/control-plane/scripts/skills/claude-api/typescript/claude-api/streaming.md +178 -0
  138. package/control-plane/scripts/skills/claude-api/typescript/claude-api/tool-use.md +586 -0
  139. package/control-plane/scripts/skills/claude-api/typescript/managed-agents/README.md +359 -0
  140. package/control-plane/scripts/skills/dispatching-parallel-agents/SKILL.md +167 -0
  141. package/control-plane/scripts/skills/enhance-prompt/README.md +34 -0
  142. package/control-plane/scripts/skills/enhance-prompt/SKILL.md +204 -0
  143. package/control-plane/scripts/skills/enhance-prompt/references/KEYWORDS.md +114 -0
  144. package/control-plane/scripts/skills/executing-plans/SKILL.md +371 -0
  145. package/control-plane/scripts/skills/executing-plans/scripts/task-done +52 -0
  146. package/control-plane/scripts/skills/executing-plans/scripts/task-start +28 -0
  147. package/control-plane/scripts/skills/extract-design-md/SKILL.md +358 -0
  148. package/control-plane/scripts/skills/extract-design-md/examples/DESIGN.md +210 -0
  149. package/control-plane/scripts/skills/extract-design-md/references/angular.md +122 -0
  150. package/control-plane/scripts/skills/extract-design-md/references/plain-css.md +161 -0
  151. package/control-plane/scripts/skills/extract-design-md/references/react-tailwind.md +157 -0
  152. package/control-plane/scripts/skills/extract-design-md/references/svelte.md +101 -0
  153. package/control-plane/scripts/skills/extract-design-md/references/vue.md +107 -0
  154. package/control-plane/scripts/skills/finishing-a-development-branch/SKILL.md +225 -0
  155. package/control-plane/scripts/skills/frontend-design/LICENSE.txt +177 -0
  156. package/control-plane/scripts/skills/frontend-design/SKILL.md +71 -0
  157. package/control-plane/scripts/skills/hallmark/SKILL.md +558 -0
  158. package/control-plane/scripts/skills/hallmark/references/anti-patterns.md +418 -0
  159. package/control-plane/scripts/skills/hallmark/references/assets.md +406 -0
  160. package/control-plane/scripts/skills/hallmark/references/color.md +95 -0
  161. package/control-plane/scripts/skills/hallmark/references/component-cookbook.md +263 -0
  162. package/control-plane/scripts/skills/hallmark/references/components/c1-outlined-chip.md +12 -0
  163. package/control-plane/scripts/skills/hallmark/references/components/c2-inline-form-as-cta.md +16 -0
  164. package/control-plane/scripts/skills/hallmark/references/components/c3-typographic-link.md +8 -0
  165. package/control-plane/scripts/skills/hallmark/references/components/c4-sticky-bottom-bar.md +16 -0
  166. package/control-plane/scripts/skills/hallmark/references/components/f1-bento-grid.md +20 -0
  167. package/control-plane/scripts/skills/hallmark/references/components/f2-sticky-scroll-stack.md +20 -0
  168. package/control-plane/scripts/skills/hallmark/references/components/f3-tabular-spec-sheet.md +11 -0
  169. package/control-plane/scripts/skills/hallmark/references/components/f4-step-sequence.md +11 -0
  170. package/control-plane/scripts/skills/hallmark/references/components/f5-annotated-screenshot.md +11 -0
  171. package/control-plane/scripts/skills/hallmark/references/components/f6-product-card-grid.md +41 -0
  172. package/control-plane/scripts/skills/hallmark/references/components/ft1-mast-headed.md +13 -0
  173. package/control-plane/scripts/skills/hallmark/references/components/ft2-inline-rule-single-line.md +10 -0
  174. package/control-plane/scripts/skills/hallmark/references/components/ft3-index-style-category-list.md +12 -0
  175. package/control-plane/scripts/skills/hallmark/references/components/ft4-dense-typographic.md +10 -0
  176. package/control-plane/scripts/skills/hallmark/references/components/ft5-statement.md +21 -0
  177. package/control-plane/scripts/skills/hallmark/references/components/ft6-letter-close.md +19 -0
  178. package/control-plane/scripts/skills/hallmark/references/components/ft7-newsletter-first.md +27 -0
  179. package/control-plane/scripts/skills/hallmark/references/components/ft8-marquee-scroll.md +25 -0
  180. package/control-plane/scripts/skills/hallmark/references/components/h1-marquee.md +15 -0
  181. package/control-plane/scripts/skills/hallmark/references/components/h2-split-diptych.md +15 -0
  182. package/control-plane/scripts/skills/hallmark/references/components/h3-quote-led.md +11 -0
  183. package/control-plane/scripts/skills/hallmark/references/components/h4-stat-led.md +14 -0
  184. package/control-plane/scripts/skills/hallmark/references/components/h5-letter-hero.md +11 -0
  185. package/control-plane/scripts/skills/hallmark/references/components/h6-photographic-fold.md +16 -0
  186. package/control-plane/scripts/skills/hallmark/references/components/h7-demo-video-clipped-by-viewport-edge.md +27 -0
  187. package/control-plane/scripts/skills/hallmark/references/components/h8-mockup-split-browser-framed.md +23 -0
  188. package/control-plane/scripts/skills/hallmark/references/components/h9-custom-illustration-centerpiece.md +27 -0
  189. package/control-plane/scripts/skills/hallmark/references/components/n1-wordmark-2-links.md +12 -0
  190. package/control-plane/scripts/skills/hallmark/references/components/n10-floating-on-scroll-morph.md +19 -0
  191. package/control-plane/scripts/skills/hallmark/references/components/n11-mega-menu.md +40 -0
  192. package/control-plane/scripts/skills/hallmark/references/components/n12-banner-retract.md +34 -0
  193. package/control-plane/scripts/skills/hallmark/references/components/n13-inline-cmdk-pill.md +39 -0
  194. package/control-plane/scripts/skills/hallmark/references/components/n1b-saas-three-section.md +35 -0
  195. package/control-plane/scripts/skills/hallmark/references/components/n2-floating-chip.md +14 -0
  196. package/control-plane/scripts/skills/hallmark/references/components/n3-side-rail.md +14 -0
  197. package/control-plane/scripts/skills/hallmark/references/components/n4-hidden-behind-k.md +9 -0
  198. package/control-plane/scripts/skills/hallmark/references/components/n5-floating-pill.md +28 -0
  199. package/control-plane/scripts/skills/hallmark/references/components/n6-newspaper-masthead.md +24 -0
  200. package/control-plane/scripts/skills/hallmark/references/components/n7-brutal-slab.md +22 -0
  201. package/control-plane/scripts/skills/hallmark/references/components/n8-terminal-command.md +21 -0
  202. package/control-plane/scripts/skills/hallmark/references/components/n9-edge-aligned-minimal.md +17 -0
  203. package/control-plane/scripts/skills/hallmark/references/components/s1-left-margin-numbered.md +15 -0
  204. package/control-plane/scripts/skills/hallmark/references/components/s2-hanging.md +13 -0
  205. package/control-plane/scripts/skills/hallmark/references/components/s3-sticky-pinned.md +19 -0
  206. package/control-plane/scripts/skills/hallmark/references/components/s4-inline-no-break.md +11 -0
  207. package/control-plane/scripts/skills/hallmark/references/components/s5-bottom-anchored.md +13 -0
  208. package/control-plane/scripts/skills/hallmark/references/components/t1-pull-quote-with-marginalia.md +12 -0
  209. package/control-plane/scripts/skills/hallmark/references/components/t2-logo-wall-hairline.md +19 -0
  210. package/control-plane/scripts/skills/hallmark/references/components/t3-single-huge-quote.md +11 -0
  211. package/control-plane/scripts/skills/hallmark/references/components/t4-numbered-stat-strip.md +14 -0
  212. package/control-plane/scripts/skills/hallmark/references/contract.md +25 -0
  213. package/control-plane/scripts/skills/hallmark/references/copy.md +182 -0
  214. package/control-plane/scripts/skills/hallmark/references/custom-craft.md +626 -0
  215. package/control-plane/scripts/skills/hallmark/references/custom-theme.md +367 -0
  216. package/control-plane/scripts/skills/hallmark/references/design-md.md +116 -0
  217. package/control-plane/scripts/skills/hallmark/references/export-formats.md +329 -0
  218. package/control-plane/scripts/skills/hallmark/references/floating-nav.md +89 -0
  219. package/control-plane/scripts/skills/hallmark/references/genres/atmospheric.md +69 -0
  220. package/control-plane/scripts/skills/hallmark/references/genres/editorial.md +72 -0
  221. package/control-plane/scripts/skills/hallmark/references/genres/modern-minimal.md +71 -0
  222. package/control-plane/scripts/skills/hallmark/references/genres/playful.md +70 -0
  223. package/control-plane/scripts/skills/hallmark/references/hero-enrichment.md +475 -0
  224. package/control-plane/scripts/skills/hallmark/references/imagery-kit.md +170 -0
  225. package/control-plane/scripts/skills/hallmark/references/interaction-and-states.md +208 -0
  226. package/control-plane/scripts/skills/hallmark/references/layout-and-space.md +112 -0
  227. package/control-plane/scripts/skills/hallmark/references/macrostructures/01-bento-grid.md +35 -0
  228. package/control-plane/scripts/skills/hallmark/references/macrostructures/02-long-document.md +34 -0
  229. package/control-plane/scripts/skills/hallmark/references/macrostructures/03-marquee-hero.md +31 -0
  230. package/control-plane/scripts/skills/hallmark/references/macrostructures/04-stat-led.md +34 -0
  231. package/control-plane/scripts/skills/hallmark/references/macrostructures/05-workbench.md +32 -0
  232. package/control-plane/scripts/skills/hallmark/references/macrostructures/06-conversational-faq.md +33 -0
  233. package/control-plane/scripts/skills/hallmark/references/macrostructures/07-manifesto.md +32 -0
  234. package/control-plane/scripts/skills/hallmark/references/macrostructures/08-photographic.md +34 -0
  235. package/control-plane/scripts/skills/hallmark/references/macrostructures/09-quote-led.md +32 -0
  236. package/control-plane/scripts/skills/hallmark/references/macrostructures/10-specimen.md +32 -0
  237. package/control-plane/scripts/skills/hallmark/references/macrostructures/11-catalogue.md +23 -0
  238. package/control-plane/scripts/skills/hallmark/references/macrostructures/12-letter.md +23 -0
  239. package/control-plane/scripts/skills/hallmark/references/macrostructures/13-index-first.md +23 -0
  240. package/control-plane/scripts/skills/hallmark/references/macrostructures/14-narrative-workflow.md +23 -0
  241. package/control-plane/scripts/skills/hallmark/references/macrostructures/15-split-studio.md +23 -0
  242. package/control-plane/scripts/skills/hallmark/references/macrostructures/16-feature-stack.md +23 -0
  243. package/control-plane/scripts/skills/hallmark/references/macrostructures/17-type-specimen.md +23 -0
  244. package/control-plane/scripts/skills/hallmark/references/macrostructures/18-portfolio-grid.md +23 -0
  245. package/control-plane/scripts/skills/hallmark/references/macrostructures/19-map-diagram.md +23 -0
  246. package/control-plane/scripts/skills/hallmark/references/macrostructures/20-ecosystem-index.md +23 -0
  247. package/control-plane/scripts/skills/hallmark/references/macrostructures/21-component-playground.md +23 -0
  248. package/control-plane/scripts/skills/hallmark/references/macrostructures.md +89 -0
  249. package/control-plane/scripts/skills/hallmark/references/microinteractions.md +258 -0
  250. package/control-plane/scripts/skills/hallmark/references/motion.md +109 -0
  251. package/control-plane/scripts/skills/hallmark/references/preview-examples.md +49 -0
  252. package/control-plane/scripts/skills/hallmark/references/responsive.md +138 -0
  253. package/control-plane/scripts/skills/hallmark/references/slop-test.md +192 -0
  254. package/control-plane/scripts/skills/hallmark/references/structure.md +160 -0
  255. package/control-plane/scripts/skills/hallmark/references/study.md +509 -0
  256. package/control-plane/scripts/skills/hallmark/references/themes/carnival.md +301 -0
  257. package/control-plane/scripts/skills/hallmark/references/themes/cobalt.md +146 -0
  258. package/control-plane/scripts/skills/hallmark/references/themes/grid.md +161 -0
  259. package/control-plane/scripts/skills/hallmark/references/themes/hum.md +403 -0
  260. package/control-plane/scripts/skills/hallmark/references/themes/lumen.md +478 -0
  261. package/control-plane/scripts/skills/hallmark/references/typography.md +243 -0
  262. package/control-plane/scripts/skills/hallmark/references/upstream/recipes.md +186 -0
  263. package/control-plane/scripts/skills/hallmark/references/upstream/study-examples.md +176 -0
  264. package/control-plane/scripts/skills/hallmark/references/upstream/tokens.css +1221 -0
  265. package/control-plane/scripts/skills/hallmark/references/verbs/audit.md +25 -0
  266. package/control-plane/scripts/skills/hallmark/references/verbs/redesign.md +269 -0
  267. package/control-plane/scripts/skills/human-comms/SKILL.md +29 -0
  268. package/control-plane/scripts/skills/index.mjs +432 -0
  269. package/control-plane/scripts/skills/internal-comms/LICENSE.txt +202 -0
  270. package/control-plane/scripts/skills/internal-comms/SKILL.md +32 -0
  271. package/control-plane/scripts/skills/internal-comms/examples/3p-updates.md +47 -0
  272. package/control-plane/scripts/skills/internal-comms/examples/company-newsletter.md +65 -0
  273. package/control-plane/scripts/skills/internal-comms/examples/faq-answers.md +30 -0
  274. package/control-plane/scripts/skills/internal-comms/examples/general-comms.md +16 -0
  275. package/control-plane/scripts/skills/mcp-adapter.mjs +94 -0
  276. package/control-plane/scripts/skills/mcp-builder/LICENSE.txt +202 -0
  277. package/control-plane/scripts/skills/mcp-builder/SKILL.md +236 -0
  278. package/control-plane/scripts/skills/mcp-builder/reference/evaluation.md +602 -0
  279. package/control-plane/scripts/skills/mcp-builder/reference/mcp_best_practices.md +249 -0
  280. package/control-plane/scripts/skills/mcp-builder/reference/node_mcp_server.md +970 -0
  281. package/control-plane/scripts/skills/mcp-builder/reference/python_mcp_server.md +719 -0
  282. package/control-plane/scripts/skills/mcp-builder/scripts/connections.py +151 -0
  283. package/control-plane/scripts/skills/mcp-builder/scripts/evaluation.py +373 -0
  284. package/control-plane/scripts/skills/mcp-builder/scripts/example_evaluation.xml +22 -0
  285. package/control-plane/scripts/skills/mcp-builder/scripts/requirements.txt +2 -0
  286. package/control-plane/scripts/skills/ponytail/SKILL.md +120 -0
  287. package/control-plane/scripts/skills/ponytail-audit/SKILL.md +41 -0
  288. package/control-plane/scripts/skills/ponytail-debt/SKILL.md +44 -0
  289. package/control-plane/scripts/skills/ponytail-gain/SKILL.md +50 -0
  290. package/control-plane/scripts/skills/ponytail-help/SKILL.md +71 -0
  291. package/control-plane/scripts/skills/ponytail-review/SKILL.md +57 -0
  292. package/control-plane/scripts/skills/receiving-code-review/SKILL.md +205 -0
  293. package/control-plane/scripts/skills/requesting-code-review/SKILL.md +95 -0
  294. package/control-plane/scripts/skills/requesting-code-review/code-reviewer.md +198 -0
  295. package/control-plane/scripts/skills/skill-creator/LICENSE.txt +202 -0
  296. package/control-plane/scripts/skills/skill-creator/SKILL.md +485 -0
  297. package/control-plane/scripts/skills/skill-creator/agents/analyzer.md +274 -0
  298. package/control-plane/scripts/skills/skill-creator/agents/comparator.md +202 -0
  299. package/control-plane/scripts/skills/skill-creator/agents/grader.md +223 -0
  300. package/control-plane/scripts/skills/skill-creator/assets/eval_review.html +146 -0
  301. package/control-plane/scripts/skills/skill-creator/eval-viewer/generate_review.py +471 -0
  302. package/control-plane/scripts/skills/skill-creator/eval-viewer/viewer.html +1325 -0
  303. package/control-plane/scripts/skills/skill-creator/references/schemas.md +430 -0
  304. package/control-plane/scripts/skills/skill-creator/scripts/__init__.py +0 -0
  305. package/control-plane/scripts/skills/skill-creator/scripts/aggregate_benchmark.py +401 -0
  306. package/control-plane/scripts/skills/skill-creator/scripts/generate_report.py +326 -0
  307. package/control-plane/scripts/skills/skill-creator/scripts/improve_description.py +247 -0
  308. package/control-plane/scripts/skills/skill-creator/scripts/package_skill.py +136 -0
  309. package/control-plane/scripts/skills/skill-creator/scripts/quick_validate.py +103 -0
  310. package/control-plane/scripts/skills/skill-creator/scripts/run_eval.py +310 -0
  311. package/control-plane/scripts/skills/skill-creator/scripts/run_loop.py +328 -0
  312. package/control-plane/scripts/skills/skill-creator/scripts/utils.py +47 -0
  313. package/control-plane/scripts/skills/slack-gif-creator/LICENSE.txt +202 -0
  314. package/control-plane/scripts/skills/slack-gif-creator/SKILL.md +254 -0
  315. package/control-plane/scripts/skills/slack-gif-creator/core/easing.py +234 -0
  316. package/control-plane/scripts/skills/slack-gif-creator/core/frame_composer.py +176 -0
  317. package/control-plane/scripts/skills/slack-gif-creator/core/gif_builder.py +269 -0
  318. package/control-plane/scripts/skills/slack-gif-creator/core/validators.py +136 -0
  319. package/control-plane/scripts/skills/slack-gif-creator/requirements.txt +4 -0
  320. package/control-plane/scripts/skills/sources.json +401 -0
  321. package/control-plane/scripts/skills/sources.lock.json +416 -0
  322. package/control-plane/scripts/skills/subagent-driven-development/SKILL.md +570 -0
  323. package/control-plane/scripts/skills/subagent-driven-development/implementer-prompt.md +154 -0
  324. package/control-plane/scripts/skills/subagent-driven-development/re-review-prompt.md +115 -0
  325. package/control-plane/scripts/skills/subagent-driven-development/scripts/review-package +53 -0
  326. package/control-plane/scripts/skills/subagent-driven-development/scripts/sdd-workspace +82 -0
  327. package/control-plane/scripts/skills/subagent-driven-development/scripts/task-brief +43 -0
  328. package/control-plane/scripts/skills/subagent-driven-development/task-reviewer-prompt.md +207 -0
  329. package/control-plane/scripts/skills/systematic-debugging/CREATION-LOG.md +119 -0
  330. package/control-plane/scripts/skills/systematic-debugging/SKILL.md +283 -0
  331. package/control-plane/scripts/skills/systematic-debugging/condition-based-waiting-example.ts +158 -0
  332. package/control-plane/scripts/skills/systematic-debugging/condition-based-waiting.md +115 -0
  333. package/control-plane/scripts/skills/systematic-debugging/defense-in-depth.md +122 -0
  334. package/control-plane/scripts/skills/systematic-debugging/find-polluter.sh +72 -0
  335. package/control-plane/scripts/skills/systematic-debugging/root-cause-tracing.md +169 -0
  336. package/control-plane/scripts/skills/systematic-debugging/test-academic.md +14 -0
  337. package/control-plane/scripts/skills/systematic-debugging/test-pressure-1.md +58 -0
  338. package/control-plane/scripts/skills/systematic-debugging/test-pressure-2.md +68 -0
  339. package/control-plane/scripts/skills/systematic-debugging/test-pressure-3.md +69 -0
  340. package/control-plane/scripts/skills/test-driven-development/SKILL.md +330 -0
  341. package/control-plane/scripts/skills/test-driven-development/writing-good-tests.md +198 -0
  342. package/control-plane/scripts/skills/theme-factory/LICENSE.txt +202 -0
  343. package/control-plane/scripts/skills/theme-factory/SKILL.md +59 -0
  344. package/control-plane/scripts/skills/theme-factory/theme-showcase.pdf +0 -0
  345. package/control-plane/scripts/skills/theme-factory/themes/arctic-frost.md +19 -0
  346. package/control-plane/scripts/skills/theme-factory/themes/botanical-garden.md +19 -0
  347. package/control-plane/scripts/skills/theme-factory/themes/desert-rose.md +19 -0
  348. package/control-plane/scripts/skills/theme-factory/themes/forest-canopy.md +19 -0
  349. package/control-plane/scripts/skills/theme-factory/themes/golden-hour.md +19 -0
  350. package/control-plane/scripts/skills/theme-factory/themes/midnight-galaxy.md +19 -0
  351. package/control-plane/scripts/skills/theme-factory/themes/modern-minimalist.md +19 -0
  352. package/control-plane/scripts/skills/theme-factory/themes/ocean-depths.md +19 -0
  353. package/control-plane/scripts/skills/theme-factory/themes/sunset-boulevard.md +19 -0
  354. package/control-plane/scripts/skills/theme-factory/themes/tech-innovation.md +19 -0
  355. package/control-plane/scripts/skills/using-git-worktrees/SKILL.md +167 -0
  356. package/control-plane/scripts/skills/verification-before-completion/SKILL.md +120 -0
  357. package/control-plane/scripts/skills/web-artifacts-builder/LICENSE.txt +202 -0
  358. package/control-plane/scripts/skills/web-artifacts-builder/SKILL.md +74 -0
  359. package/control-plane/scripts/skills/web-artifacts-builder/scripts/bundle-artifact.sh +54 -0
  360. package/control-plane/scripts/skills/web-artifacts-builder/scripts/init-artifact.sh +322 -0
  361. package/control-plane/scripts/skills/web-artifacts-builder/scripts/shadcn-components.tar.gz +0 -0
  362. package/control-plane/scripts/skills/webapp-testing/LICENSE.txt +202 -0
  363. package/control-plane/scripts/skills/webapp-testing/SKILL.md +96 -0
  364. package/control-plane/scripts/skills/webapp-testing/examples/console_logging.py +35 -0
  365. package/control-plane/scripts/skills/webapp-testing/examples/element_discovery.py +40 -0
  366. package/control-plane/scripts/skills/webapp-testing/examples/static_html_automation.py +33 -0
  367. package/control-plane/scripts/skills/webapp-testing/scripts/with_server.py +106 -0
  368. package/control-plane/scripts/skills/writing-plans/SKILL.md +192 -0
  369. package/control-plane/scripts/skills/writing-plans/plan-document-reviewer-prompt.md +49 -0
  370. package/control-plane/scripts/skills/writing-skills/SKILL.md +681 -0
  371. package/control-plane/scripts/skills/writing-skills/anthropic-best-practices.md +1150 -0
  372. package/control-plane/scripts/skills/writing-skills/examples/CLAUDE_MD_TESTING.md +189 -0
  373. package/control-plane/scripts/skills/writing-skills/graphviz-conventions.dot +172 -0
  374. package/control-plane/scripts/skills/writing-skills/persuasion-principles.md +187 -0
  375. package/control-plane/scripts/skills/writing-skills/render-graphs.js +169 -0
  376. package/control-plane/scripts/skills/writing-skills/testing-skills-with-subagents.md +384 -0
  377. package/control-plane/scripts/smoke-mcp-schemas.mjs +30 -0
  378. package/control-plane/scripts/surface-config.mjs +45 -0
  379. package/control-plane/scripts/sync-skills.mjs +370 -0
  380. package/control-plane/scripts/tool-metrics.mjs +74 -0
  381. package/control-plane/scripts/tool-risk.mjs +156 -0
  382. package/control-plane/scripts/tool-surface-stability.mjs +38 -0
  383. package/control-plane/scripts/upstreams/catalog-cache.mjs +28 -0
  384. package/control-plane/scripts/upstreams/config.mjs +158 -0
  385. package/control-plane/scripts/upstreams/diagnostics.mjs +21 -0
  386. package/control-plane/scripts/upstreams/http-client.mjs +67 -0
  387. package/control-plane/scripts/upstreams/manager.mjs +535 -0
  388. package/control-plane/scripts/upstreams/names.mjs +55 -0
  389. package/control-plane/scripts/upstreams/presets.mjs +60 -0
  390. package/control-plane/scripts/upstreams/resource-uri.mjs +29 -0
  391. package/control-plane/scripts/upstreams/stdio-client.mjs +73 -0
  392. package/control-plane/scripts/workspace-registry.mjs +147 -0
  393. package/dist/context/authorization.d.ts +5 -0
  394. package/dist/context/authorization.js +70 -0
  395. package/dist/context/capture.d.ts +46 -0
  396. package/dist/context/capture.js +187 -0
  397. package/dist/context/cli.d.ts +47 -0
  398. package/dist/context/cli.js +287 -0
  399. package/dist/context/device-adapter.d.ts +102 -0
  400. package/dist/context/device-adapter.js +79 -0
  401. package/dist/context/gateway.d.ts +354 -0
  402. package/dist/context/gateway.js +50 -0
  403. package/dist/context/graph.d.ts +63 -0
  404. package/dist/context/graph.js +214 -0
  405. package/dist/context/importer.d.ts +8 -0
  406. package/dist/context/importer.js +69 -0
  407. package/dist/context/indexer.d.ts +14 -0
  408. package/dist/context/indexer.js +57 -0
  409. package/dist/context/migrations/index.d.ts +4 -0
  410. package/dist/context/migrations/index.js +87 -0
  411. package/dist/context/redact.d.ts +15 -0
  412. package/dist/context/redact.js +43 -0
  413. package/dist/context/repositories.d.ts +9 -0
  414. package/dist/context/repositories.js +45 -0
  415. package/dist/context/search.d.ts +63 -0
  416. package/dist/context/search.js +207 -0
  417. package/dist/context/service.d.ts +278 -0
  418. package/dist/context/service.js +160 -0
  419. package/dist/context/store.d.ts +134 -0
  420. package/dist/context/store.js +722 -0
  421. package/dist/context/text.d.ts +4 -0
  422. package/dist/context/text.js +14 -0
  423. package/dist/context/tool-contract.d.ts +534 -0
  424. package/dist/context/tool-contract.js +45 -0
  425. package/dist/device/core.d.ts +29 -0
  426. package/dist/device/core.js +66 -0
  427. package/dist/device/device.d.ts +5 -0
  428. package/dist/device/device.js +94 -37
  429. package/dist/device/gateway-channel.d.ts +8 -1
  430. package/dist/device/gateway-channel.js +51 -3
  431. package/dist/device/gateway-tool-adapter.d.ts +11 -3
  432. package/dist/device/gateway-tool-adapter.js +141 -98
  433. package/dist/device/official-trust.d.ts +12 -0
  434. package/dist/device/official-trust.js +25 -1
  435. package/dist/device/runtime-owner.js +9 -1
  436. package/dist/distribution.d.ts +4 -0
  437. package/dist/distribution.js +8 -0
  438. package/dist/handlers/filesystem-handlers.js +53 -37
  439. package/dist/handlers/search-handlers.d.ts +1 -0
  440. package/dist/handlers/search-handlers.js +51 -1
  441. package/dist/log-palace/cli.d.ts +7 -0
  442. package/dist/log-palace/cli.js +89 -0
  443. package/dist/log-palace/formats.d.ts +26 -0
  444. package/dist/log-palace/formats.js +126 -0
  445. package/dist/log-palace/store.d.ts +129 -0
  446. package/dist/log-palace/store.js +856 -0
  447. package/dist/mcp-device.d.ts +1 -1
  448. package/dist/mcp-device.js +28 -6
  449. package/dist/npm-scripts/remote.js +1 -0
  450. package/dist/platform/activity-journal.d.ts +16 -0
  451. package/dist/platform/activity-journal.js +68 -0
  452. package/dist/platform/cli.d.ts +1 -0
  453. package/dist/platform/cli.js +300 -0
  454. package/dist/platform/coordination-lock.d.ts +45 -0
  455. package/dist/platform/coordination-lock.js +233 -0
  456. package/dist/platform/device-runtime.d.ts +16 -0
  457. package/dist/platform/device-runtime.js +83 -0
  458. package/dist/platform/knowledge-contract.d.ts +46 -0
  459. package/dist/platform/knowledge-contract.js +1 -0
  460. package/dist/platform/knowledge-mcp.d.ts +29 -0
  461. package/dist/platform/knowledge-mcp.js +95 -0
  462. package/dist/platform/knowledge-router.d.ts +64 -0
  463. package/dist/platform/knowledge-router.js +320 -0
  464. package/dist/platform/plugin-child.d.ts +1 -0
  465. package/dist/platform/plugin-child.js +115 -0
  466. package/dist/platform/plugin-contract.d.ts +76 -0
  467. package/dist/platform/plugin-contract.js +53 -0
  468. package/dist/platform/plugin-driver.d.ts +8 -0
  469. package/dist/platform/plugin-driver.js +443 -0
  470. package/dist/platform/plugin-host.d.ts +88 -0
  471. package/dist/platform/plugin-host.js +817 -0
  472. package/dist/platform/plugin-policy.d.ts +3 -0
  473. package/dist/platform/plugin-policy.js +29 -0
  474. package/dist/platform/plugin-services.d.ts +14 -0
  475. package/dist/platform/plugin-services.js +32 -0
  476. package/dist/platform/process-identity.d.ts +9 -0
  477. package/dist/platform/process-identity.js +68 -0
  478. package/dist/platform/runtime-lease.d.ts +4 -0
  479. package/dist/platform/runtime-lease.js +58 -0
  480. package/dist/platform/runtime-root.d.ts +9 -0
  481. package/dist/platform/runtime-root.js +61 -0
  482. package/dist/platform/state-backup.d.ts +92 -0
  483. package/dist/platform/state-backup.js +399 -0
  484. package/dist/plugins/reference/plugin.d.ts +3 -0
  485. package/dist/plugins/reference/plugin.js +13 -0
  486. package/dist/search-manager.d.ts +6 -0
  487. package/dist/search-manager.js +123 -0
  488. package/dist/server.d.ts +13 -0
  489. package/dist/server.js +7 -3
  490. package/dist/terminal-manager.d.ts +16 -0
  491. package/dist/terminal-manager.js +137 -42
  492. package/dist/tool-dispatcher.d.ts +11 -0
  493. package/dist/tool-dispatcher.js +228 -0
  494. package/dist/tools/edit.js +72 -1
  495. package/dist/tools/filesystem.d.ts +1 -1
  496. package/dist/tools/filesystem.js +2 -2
  497. package/dist/tools/improved-process-tools.js +91 -108
  498. package/dist/tools/schemas.d.ts +94 -2
  499. package/dist/tools/schemas.js +20 -6
  500. package/dist/types.d.ts +8 -0
  501. package/dist/utils/output-budget.d.ts +6 -0
  502. package/dist/utils/output-budget.js +15 -0
  503. package/dist/version.d.ts +1 -1
  504. package/dist/version.js +1 -1
  505. package/package.json +29 -6
  506. package/skills/mcp-device-context/SKILL.md +40 -0
@@ -0,0 +1,278 @@
1
+ import { type GatedFeature } from './authorization.js';
2
+ export { isFeatureAuthorized, SOC_PUBLIC_KEY } from './authorization.js';
3
+ import { type GraphOptions } from './graph.js';
4
+ import { ContextStore } from './store.js';
5
+ import { type SearchOptions, type ReadOptions } from './search.js';
6
+ export declare const FEATURE_LIVE_CAPTURE = false;
7
+ export declare const FEATURE_PUBLIC_GATEWAY = false;
8
+ export interface ContextServiceOptions {
9
+ FEATURE_LIVE_CAPTURE?: boolean;
10
+ FEATURE_PUBLIC_GATEWAY?: boolean;
11
+ }
12
+ /** Explicit foreground ownership only; no timers, scheduler, sync or source scans. */
13
+ export declare class ContextService {
14
+ private readonly store;
15
+ private readonly options;
16
+ private readonly jobs;
17
+ private readonly gaps;
18
+ constructor(store: ContextStore, options?: ContextServiceOptions);
19
+ /** All future Phase 7/8 tool initialization must pass this fail-closed boundary.
20
+ * No capture hooks, public routes or MCP tools are enabled by this change. */
21
+ initializeFeature(feature: GatedFeature): void;
22
+ requireFeatureAuthorized(feature: GatedFeature): void;
23
+ /** Revalidate synchronously immediately before the side effect. Revocation
24
+ * takes effect on the next call; this is not cancellation of in-flight work. */
25
+ executeFeature<T>(feature: GatedFeature, action: () => T): T;
26
+ graph(owner: string, repo: string, input: GraphOptions): {
27
+ schema_version: number;
28
+ ok: boolean;
29
+ scope: {
30
+ repository_ref: string;
31
+ };
32
+ index: {
33
+ generation: number;
34
+ indexed_through_event: number;
35
+ manifest_hash: string | number | bigint | Uint8Array<ArrayBufferLike> | null;
36
+ pending_events: number;
37
+ unknown_events: number;
38
+ fts_documents: number;
39
+ };
40
+ coverage: {
41
+ complete: boolean;
42
+ reasons: string[];
43
+ };
44
+ nodes: import("./graph.js").ActivityNode[];
45
+ edges: import("./graph.js").ActivityEdge[];
46
+ partial: boolean;
47
+ next_cursor: null;
48
+ visited_nodes: number;
49
+ examined_edges: number;
50
+ returned_nodes: number;
51
+ truncated_by: string[];
52
+ path: string[];
53
+ };
54
+ search(owner: string, repo: string, input: SearchOptions): {
55
+ schema_version: number;
56
+ ok: boolean;
57
+ scope: {
58
+ repository_ref: string;
59
+ };
60
+ index: {
61
+ generation: number | null;
62
+ indexed_through_event: number;
63
+ pending_events: number;
64
+ freshness: string;
65
+ };
66
+ coverage: {
67
+ complete: boolean;
68
+ reasons: string[];
69
+ };
70
+ items: Record<string, unknown>[];
71
+ partial: boolean;
72
+ next_cursor: string | null;
73
+ warnings: string[];
74
+ };
75
+ read(owner: string, repo: string, input: ReadOptions): {
76
+ schema_version: number;
77
+ ok: boolean;
78
+ scope: {
79
+ repository_ref: string;
80
+ };
81
+ index: {
82
+ generation: number | null;
83
+ indexed_through_event: number;
84
+ pending_events: number;
85
+ freshness: string;
86
+ };
87
+ coverage: {
88
+ complete: boolean;
89
+ reasons: string[];
90
+ };
91
+ items: Record<string, unknown>[];
92
+ partial: boolean;
93
+ next_cursor: string | null;
94
+ warnings: string[];
95
+ };
96
+ sync(owner: string, repo: string): {
97
+ indexed: number;
98
+ schema_version: number;
99
+ ok: boolean;
100
+ scope: {
101
+ repository_ref: string;
102
+ };
103
+ index: {
104
+ generation: number | null;
105
+ indexed_through_event: number;
106
+ pending_events: number;
107
+ fts_documents: number;
108
+ freshness: string;
109
+ };
110
+ coverage: {
111
+ complete: boolean;
112
+ reasons: string[];
113
+ };
114
+ capture_health: {
115
+ capture_healthy: boolean;
116
+ in_memory_gaps: number;
117
+ unknown_after_restart: number;
118
+ quota_gaps: number;
119
+ };
120
+ active_jobs: {
121
+ job_ref: string;
122
+ action: "sync" | "rebuild";
123
+ started_at: number;
124
+ }[];
125
+ storage: {
126
+ available: boolean;
127
+ accounted_bytes: number;
128
+ accounting: string;
129
+ quota_enforced: boolean;
130
+ };
131
+ wiki_enabled: boolean;
132
+ };
133
+ rebuild(owner: string, repo: string): {
134
+ indexed: number;
135
+ schema_version: number;
136
+ ok: boolean;
137
+ scope: {
138
+ repository_ref: string;
139
+ };
140
+ index: {
141
+ generation: number | null;
142
+ indexed_through_event: number;
143
+ pending_events: number;
144
+ fts_documents: number;
145
+ freshness: string;
146
+ };
147
+ coverage: {
148
+ complete: boolean;
149
+ reasons: string[];
150
+ };
151
+ capture_health: {
152
+ capture_healthy: boolean;
153
+ in_memory_gaps: number;
154
+ unknown_after_restart: number;
155
+ quota_gaps: number;
156
+ };
157
+ active_jobs: {
158
+ job_ref: string;
159
+ action: "sync" | "rebuild";
160
+ started_at: number;
161
+ }[];
162
+ storage: {
163
+ available: boolean;
164
+ accounted_bytes: number;
165
+ accounting: string;
166
+ quota_enforced: boolean;
167
+ };
168
+ wiki_enabled: boolean;
169
+ };
170
+ checkpoint(owner: string, repo: string, input: {
171
+ repository_root: string;
172
+ worktree_ref: string;
173
+ summary?: string;
174
+ evidence_refs?: string[];
175
+ }): {
176
+ checkpoint: {
177
+ observed: {
178
+ head: string;
179
+ worktree_ref: string;
180
+ dirty: boolean;
181
+ changed_paths: string[];
182
+ };
183
+ reported: {
184
+ summary: string;
185
+ evidence_refs: string[];
186
+ };
187
+ ref: string;
188
+ };
189
+ schema_version: number;
190
+ ok: boolean;
191
+ scope: {
192
+ repository_ref: string;
193
+ };
194
+ index: {
195
+ generation: number | null;
196
+ indexed_through_event: number;
197
+ pending_events: number;
198
+ fts_documents: number;
199
+ freshness: string;
200
+ };
201
+ coverage: {
202
+ complete: boolean;
203
+ reasons: string[];
204
+ };
205
+ capture_health: {
206
+ capture_healthy: boolean;
207
+ in_memory_gaps: number;
208
+ unknown_after_restart: number;
209
+ quota_gaps: number;
210
+ };
211
+ active_jobs: {
212
+ job_ref: string;
213
+ action: "sync" | "rebuild";
214
+ started_at: number;
215
+ }[];
216
+ storage: {
217
+ available: boolean;
218
+ accounted_bytes: number;
219
+ accounting: string;
220
+ quota_enforced: boolean;
221
+ };
222
+ wiki_enabled: boolean;
223
+ };
224
+ /** Trusted local admin seam, intentionally absent from CLI/MCP agent action dispatch. */
225
+ cleanup(owner: string, repo: string, input: {
226
+ before: number;
227
+ localAdmin: boolean;
228
+ }): {
229
+ purged: number;
230
+ accounted_bytes: number;
231
+ };
232
+ captureGap(owner: string, repo: string, reason: string): void;
233
+ /** Trusted observer scope only; works even when the storage connection is down. */
234
+ recordGap(owner: string, repo: string, reason: string): void;
235
+ status(owner: string, repo: string): {
236
+ schema_version: number;
237
+ ok: boolean;
238
+ scope: {
239
+ repository_ref: string;
240
+ };
241
+ index: {
242
+ generation: number | null;
243
+ indexed_through_event: number;
244
+ pending_events: number;
245
+ fts_documents: number;
246
+ freshness: string;
247
+ };
248
+ coverage: {
249
+ complete: boolean;
250
+ reasons: string[];
251
+ };
252
+ capture_health: {
253
+ capture_healthy: boolean;
254
+ in_memory_gaps: number;
255
+ unknown_after_restart: number;
256
+ quota_gaps: number;
257
+ };
258
+ active_jobs: {
259
+ job_ref: string;
260
+ action: "sync" | "rebuild";
261
+ started_at: number;
262
+ }[];
263
+ storage: {
264
+ available: boolean;
265
+ accounted_bytes: number;
266
+ accounting: string;
267
+ quota_enforced: boolean;
268
+ };
269
+ wiki_enabled: boolean;
270
+ };
271
+ startJob(owner: string, repo: string, action: 'sync' | 'rebuild'): string;
272
+ /** Foreground work completes before another request can run; cancel only releases a scoped pending job. */
273
+ cancel(owner: string, repo: string, id: string): {
274
+ job_ref: string;
275
+ state: "cancelled";
276
+ };
277
+ finishJob(owner: string, repo: string, id: string): void;
278
+ }
@@ -0,0 +1,160 @@
1
+ import { randomBytes, createHash } from 'node:crypto';
2
+ import { requireFeatureAuthorized, GATE_ERROR } from './authorization.js';
3
+ export { isFeatureAuthorized, SOC_PUBLIC_KEY } from './authorization.js';
4
+ import { queryActivityGraph } from './graph.js';
5
+ import { execFileSync } from 'node:child_process';
6
+ import { realpathSync } from 'node:fs';
7
+ import { sync } from './indexer.js';
8
+ import { search, readEvidence } from './search.js';
9
+ export const FEATURE_LIVE_CAPTURE = false;
10
+ export const FEATURE_PUBLIC_GATEWAY = false;
11
+ const GAP_REASONS = new Set(['storage_unavailable', 'busy', 'quota', 'outcome_failed']);
12
+ /** Explicit foreground ownership only; no timers, scheduler, sync or source scans. */
13
+ export class ContextService {
14
+ constructor(store, options = {}) {
15
+ this.store = store;
16
+ this.options = options;
17
+ this.jobs = new Map();
18
+ this.gaps = new Map();
19
+ for (const feature of ['FEATURE_LIVE_CAPTURE', 'FEATURE_PUBLIC_GATEWAY']) {
20
+ if (options[feature] === true)
21
+ this.initializeFeature(feature);
22
+ }
23
+ }
24
+ /** All future Phase 7/8 tool initialization must pass this fail-closed boundary.
25
+ * No capture hooks, public routes or MCP tools are enabled by this change. */
26
+ initializeFeature(feature) {
27
+ this.requireFeatureAuthorized(feature);
28
+ }
29
+ requireFeatureAuthorized(feature) {
30
+ if (this.options[feature] !== true)
31
+ throw new Error(GATE_ERROR);
32
+ requireFeatureAuthorized(feature);
33
+ }
34
+ /** Revalidate synchronously immediately before the side effect. Revocation
35
+ * takes effect on the next call; this is not cancellation of in-flight work. */
36
+ executeFeature(feature, action) {
37
+ this.requireFeatureAuthorized(feature);
38
+ return action();
39
+ }
40
+ graph(owner, repo, input) { return queryActivityGraph(this.store, owner, repo, input); }
41
+ search(owner, repo, input) { return search(this.store, owner, repo, input); }
42
+ read(owner, repo, input) { return readEvidence(this.store, owner, repo, input); }
43
+ sync(owner, repo) {
44
+ this.store.authorize(owner, repo);
45
+ this.store.reconcileQuota();
46
+ const job = this.startJob(owner, repo, 'sync');
47
+ try {
48
+ const result = sync(this.store, owner, repo);
49
+ return { ...this.status(owner, repo), indexed: result.indexed };
50
+ }
51
+ finally {
52
+ this.finishJob(owner, repo, job);
53
+ }
54
+ }
55
+ rebuild(owner, repo) {
56
+ const job = this.startJob(owner, repo, 'rebuild');
57
+ try {
58
+ const result = sync(this.store, owner, repo, { rebuild: true });
59
+ return { ...this.status(owner, repo), indexed: result.indexed };
60
+ }
61
+ finally {
62
+ this.finishJob(owner, repo, job);
63
+ }
64
+ }
65
+ checkpoint(owner, repo, input) {
66
+ this.store.authorize(owner, repo);
67
+ const refs = input.evidence_refs ?? [];
68
+ if (refs.length > 20 || (input.summary !== undefined && (typeof input.summary !== 'string' || Buffer.byteLength(input.summary) > 4096)))
69
+ throw new Error('BUDGET_EXCEEDED');
70
+ for (const ref of refs)
71
+ this.store.read(owner, repo, ref);
72
+ const git = (...args) => execFileSync('git', ['-C', input.repository_root, ...args], {
73
+ encoding: 'utf8', timeout: 5000, maxBuffer: 65536, stdio: ['ignore', 'pipe', 'pipe'],
74
+ env: { ...process.env, GIT_DIR: undefined, GIT_WORK_TREE: undefined, GIT_COMMON_DIR: undefined },
75
+ }).trim();
76
+ const common = git('rev-parse', '--path-format=absolute', '--git-common-dir');
77
+ const identity = createHash('sha256').update(realpathSync(common)).digest('hex');
78
+ const worktree = createHash('sha256').update(realpathSync(git('rev-parse', '--show-toplevel'))).digest('hex');
79
+ if (this.store.findRepository(owner, identity) !== repo || worktree !== input.worktree_ref)
80
+ throw new Error('ACCESS_DENIED');
81
+ const status = git('status', '--porcelain=v1', '-z');
82
+ const checkpoint = {
83
+ observed: { head: git('rev-parse', 'HEAD'), worktree_ref: worktree, dirty: status.length > 0,
84
+ changed_paths: status.split('\0').filter(Boolean).map(line => this.store.redactPayload(line.slice(3)).text).slice(0, 256) },
85
+ reported: { summary: this.store.redactPayload(input.summary ?? '').text, evidence_refs: refs },
86
+ };
87
+ const ref = this.store.append(owner, repo, JSON.stringify(checkpoint), { checkpoint: true });
88
+ const retained = JSON.parse(String(this.store.read(owner, repo, ref).text));
89
+ return { ...this.status(owner, repo), checkpoint: { ref, ...retained } };
90
+ }
91
+ /** Trusted local admin seam, intentionally absent from CLI/MCP agent action dispatch. */
92
+ cleanup(owner, repo, input) {
93
+ if ([...this.jobs.values()].some(job => job.owner === owner && job.repo === repo))
94
+ throw new Error('BUSY');
95
+ return this.store.cleanup(owner, repo, input);
96
+ }
97
+ captureGap(owner, repo, reason) {
98
+ this.store.authorize(owner, repo);
99
+ this.recordGap(owner, repo, reason);
100
+ }
101
+ /** Trusted observer scope only; works even when the storage connection is down. */
102
+ recordGap(owner, repo, reason) {
103
+ for (const key of this.gaps.keys())
104
+ if (!key.startsWith(`${owner}:`))
105
+ this.gaps.delete(key);
106
+ const gap = this.gaps.get(`${owner}:${repo}`) ?? { count: 0, reasons: new Set() };
107
+ gap.count++;
108
+ gap.reasons.add(GAP_REASONS.has(reason) ? reason : 'storage_unavailable');
109
+ this.gaps.set(`${owner}:${repo}`, gap);
110
+ }
111
+ status(owner, repo) {
112
+ this.store.authorize(owner, repo);
113
+ const manifest = this.store.inspectManifest(owner, repo);
114
+ const gap = this.gaps.get(`${owner}:${repo}`);
115
+ const reasons = [...(gap?.reasons ?? [])];
116
+ if (manifest.unknown_events > 0)
117
+ reasons.push('unknown_after_restart');
118
+ const quotaGaps = this.store.quotaGaps(owner);
119
+ if (quotaGaps > 0)
120
+ reasons.push('quota');
121
+ return {
122
+ schema_version: 1, ok: true, scope: { repository_ref: repo },
123
+ index: { generation: manifest.generation, indexed_through_event: manifest.indexed_through_event,
124
+ pending_events: manifest.pending_events, fts_documents: manifest.fts_documents, freshness: manifest.generation === null ? 'missing' : manifest.pending_events ? 'stale' : 'current' },
125
+ coverage: { complete: reasons.length === 0, reasons },
126
+ capture_health: { capture_healthy: reasons.length === 0, in_memory_gaps: gap?.count ?? 0, unknown_after_restart: manifest.unknown_events, quota_gaps: quotaGaps },
127
+ active_jobs: [...this.jobs.values()].filter(job => job.owner === owner && job.repo === repo)
128
+ .map(({ job_ref, action, started_at }) => ({ job_ref, action, started_at })),
129
+ storage: { available: true, accounted_bytes: this.store.accountedBytes(), accounting: 'last_explicit_refresh', quota_enforced: true },
130
+ wiki_enabled: false,
131
+ };
132
+ }
133
+ startJob(owner, repo, action) {
134
+ this.store.authorize(owner, repo);
135
+ if (action !== 'sync' && action !== 'rebuild')
136
+ throw new Error('ACTION_UNSUPPORTED');
137
+ // Re-pair cannot leave sealed-owner jobs consuming the active owner's limits.
138
+ for (const [id, job] of this.jobs)
139
+ if (job.owner !== owner)
140
+ this.jobs.delete(id);
141
+ const jobs = [...this.jobs.values()];
142
+ if (jobs.some(job => job.repo === repo) || jobs.length >= 4)
143
+ throw new Error('BUSY');
144
+ const id = randomBytes(24).toString('hex');
145
+ this.jobs.set(id, { job_ref: id, owner, repo, action, started_at: Date.now() });
146
+ return id;
147
+ }
148
+ /** Foreground work completes before another request can run; cancel only releases a scoped pending job. */
149
+ cancel(owner, repo, id) {
150
+ this.finishJob(owner, repo, id);
151
+ return { job_ref: id, state: 'cancelled' };
152
+ }
153
+ finishJob(owner, repo, id) {
154
+ this.store.authorize(owner, repo);
155
+ const job = this.jobs.get(id);
156
+ if (!job || job.owner !== owner || job.repo !== repo)
157
+ throw new Error('ACCESS_DENIED');
158
+ this.jobs.delete(id);
159
+ }
160
+ }
@@ -0,0 +1,134 @@
1
+ import { DatabaseSync } from 'node:sqlite';
2
+ /** Only context connection constructor, including read-only handles. */
3
+ export declare function createContextDatabase(path: string, options?: {
4
+ readOnly?: boolean;
5
+ }): DatabaseSync;
6
+ interface CursorState {
7
+ generation: number | null;
8
+ position: number;
9
+ expires_at: number;
10
+ query_hash: string;
11
+ }
12
+ /** Device-local storage. State root is supplied by trusted runtime configuration, never tool input. */
13
+ export declare class ContextStore {
14
+ private readonly stateRoot;
15
+ readonly registry: DatabaseSync;
16
+ private readonly root;
17
+ private readonly key;
18
+ private readonly cursorKey;
19
+ private readonly databases;
20
+ private activeReservation;
21
+ private activeEpoch;
22
+ /** Registry provides lease liveness only; repo.sqlite owns epoch authority.
23
+ * Registry and repository are separate SQLite files, not an atomic transaction. */
24
+ assertReservationLive(): void;
25
+ /** Store-owned commit gate: stale caller tokens cannot commit repository work. */
26
+ commitRepository(db: DatabaseSync, token?: string | undefined): void;
27
+ constructor(stateRoot: string, options?: {
28
+ readOnly?: boolean;
29
+ });
30
+ private open;
31
+ activeOwner(): string | null;
32
+ activateOwner(trustedPairingIdentity: string): string;
33
+ authorize(owner: string, repo?: string): void;
34
+ findRepository(owner: string, identity: string): string | null;
35
+ repository(owner: string, identity: string): string;
36
+ private repositoryPath;
37
+ private database;
38
+ /** Internal modules only; adapters must use authorized domain methods. */
39
+ repoDatabase(owner: string, repo: string): DatabaseSync;
40
+ unscopedDatabase(owner: string): DatabaseSync;
41
+ recordUnscoped(owner: string, reason: 'outside_repo' | 'ambiguous_multi_repo' | 'repo_resolution_failed' | 'quota'): void;
42
+ append(owner: string, repo: string, input: string | Buffer, options?: {
43
+ path?: string;
44
+ maxBytes?: number;
45
+ checkpoint?: boolean;
46
+ }): string;
47
+ /** All persistence callers share the protected installation key; raw secrets are never hashed unkeyed. */
48
+ redactPayload(input: string | Buffer, options?: {
49
+ path?: string;
50
+ maxBytes?: number;
51
+ }): import("./redact.js").RedactedPayload;
52
+ read(owner: string, repo: string, ref: string): Record<string, import("node:sqlite").Value>;
53
+ inspectManifest(owner: string, repo: string): {
54
+ generation: number | null;
55
+ indexed_through_event: number;
56
+ manifest_hash: string | number | bigint | Uint8Array<ArrayBufferLike> | null;
57
+ pending_events: number;
58
+ unknown_events: number;
59
+ fts_documents: number;
60
+ };
61
+ /** Query-only access never creates, migrates or opens a writable handle. */
62
+ withReadDatabase<T>(owner: string, repo: string, action: (db: DatabaseSync) => T): T;
63
+ signReadCursor(owner: string, repo: string, state: {
64
+ generation?: unknown;
65
+ key?: unknown;
66
+ expires_at?: unknown;
67
+ [field: string]: unknown;
68
+ }): string;
69
+ /** Authenticate bounded metadata only. search/read continuation() enforces expiry,
70
+ * operation/query identity and generation policy after successful authentication.
71
+ */
72
+ parseReadCursor(owner: string, repo: string, token: string): Record<string, unknown>;
73
+ manifest(owner: string, repo: string): {
74
+ generation: number | null;
75
+ indexed_through_event: number;
76
+ manifest_hash: string | number | bigint | Uint8Array<ArrayBufferLike> | null;
77
+ pending_events: number;
78
+ unknown_events: number;
79
+ fts_documents: number;
80
+ };
81
+ private readManifest;
82
+ beginGeneration(owner: string, repo: string): number;
83
+ publishGeneration(owner: string, repo: string, generation: number, through: number, manifestHash: string): void;
84
+ cursor(owner: string, repo: string, query: string, position: number, ttl?: number): string;
85
+ validateCursor(owner: string, repo: string, token: string, query: string, now?: number): CursorState;
86
+ /** Explicit maintenance accounting includes DB/WAL/blob files in active and sealed namespaces.
87
+ * This is not invoked by status and is not quota enforcement (Phase 5).
88
+ */
89
+ refreshAccounting(): number;
90
+ /** Accounted allocation includes sealed namespaces; actual-file scan is explicit, never status IO. */
91
+ accountedBytes(): number;
92
+ /** Explicit recovery also works in a continuing process (no restart required).
93
+ * Admission and foreground sync invoke this sweep; no hidden timer is added.
94
+ * Registry-first snapshots retain durable living reservations, and reap only
95
+ * expired leases or demonstrably dead same-host PIDs. Committed evidence is
96
+ * always tallied from repo DBs, never inferred from reservation allocations.
97
+ * Logical evidence totals
98
+ * include sealed stores; physical allocation still gates admission. */
99
+ reconcileQuota(): number;
100
+ private reconcileQuotaLocked;
101
+ /** Trusted local configuration only. Caps can be lowered; no tool exposes this method. */
102
+ configureQuota(input: Partial<{
103
+ device_bytes: number;
104
+ owner_bytes: number;
105
+ repo_bytes: number;
106
+ metadata_reserve_bytes: number;
107
+ }>): void;
108
+ /** Two-phase, recoverable protocol across separate Registry and Repo SQLite files:
109
+ * Single-writer invariant: each repository has at most one active writer lease.
110
+ * Admission checks for a living lease under registry BEGIN IMMEDIATE; the same
111
+ * mutex serializes reconciliation and is held through repo COMMIT/finalization.
112
+ * The durable allocation/reacquisition gap cannot admit a second writer lease.
113
+ * 1. Repo durably increments fencing_state; registry reserves allocation and
114
+ * records that epoch as a non-authoritative lease token/cache.
115
+ * 2. Repo checks exact epoch/id in its writer transaction and commits evidence.
116
+ * 3. Registry finalizes quota under the same registry-first writer mutex.
117
+ * This is not distributed atomic commit; reconcileQuota repairs the crash gap.
118
+ * Includes DB/WAL/SHM and sealed allocations; reserve is never payload space.
119
+ */
120
+ quotaWrite<T>(owner: string, repo: string, allocation: number, action: () => T): T;
121
+ quotaGaps(owner: string): number;
122
+ private cursorEpoch;
123
+ /** Destructive domain seam for trusted local owner administration, never MCP dispatch. */
124
+ cleanup(owner: string, repo: string, input: {
125
+ before: number;
126
+ localAdmin: boolean;
127
+ }): {
128
+ purged: number;
129
+ accounted_bytes: number;
130
+ };
131
+ databaseFiles(): string[];
132
+ close(): void;
133
+ }
134
+ export {};