@bevel-software/platform-core-backend 0.14.0 → 0.15.1

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 (385) hide show
  1. package/THIRD-PARTY-NOTICES.md +6 -6
  2. package/dist/core/catalog-cache-invalidation.d.ts +29 -0
  3. package/dist/core/catalog-cache-invalidation.d.ts.map +1 -0
  4. package/dist/core/catalog-cache-invalidation.js +71 -0
  5. package/dist/core/catalog-cache-invalidation.js.map +1 -0
  6. package/dist/core/create-core-server.d.ts.map +1 -1
  7. package/dist/core/create-core-server.js +99 -8
  8. package/dist/core/create-core-server.js.map +1 -1
  9. package/dist/core/create-core-services.d.ts +18 -1
  10. package/dist/core/create-core-services.d.ts.map +1 -1
  11. package/dist/core/create-core-services.js +96 -43
  12. package/dist/core/create-core-services.js.map +1 -1
  13. package/dist/modules/access/access-control.interface.d.ts +18 -6
  14. package/dist/modules/access/access-control.interface.d.ts.map +1 -1
  15. package/dist/modules/access/access-control.service.d.ts +26 -1
  16. package/dist/modules/access/access-control.service.d.ts.map +1 -1
  17. package/dist/modules/access/access-control.service.js +213 -71
  18. package/dist/modules/access/access-control.service.js.map +1 -1
  19. package/dist/modules/access/access.routes.d.ts.map +1 -1
  20. package/dist/modules/access/access.routes.js +59 -7
  21. package/dist/modules/access/access.routes.js.map +1 -1
  22. package/dist/modules/access-model/access-grammar.d.ts +51 -1
  23. package/dist/modules/access-model/access-grammar.d.ts.map +1 -1
  24. package/dist/modules/access-model/access-grammar.js +95 -1
  25. package/dist/modules/access-model/access-grammar.js.map +1 -1
  26. package/dist/modules/access-model/group-files.d.ts.map +1 -1
  27. package/dist/modules/access-model/group-files.js +4 -1
  28. package/dist/modules/access-model/group-files.js.map +1 -1
  29. package/dist/modules/access-model/plugin-principals.d.ts +49 -0
  30. package/dist/modules/access-model/plugin-principals.d.ts.map +1 -0
  31. package/dist/modules/access-model/plugin-principals.js +125 -0
  32. package/dist/modules/access-model/plugin-principals.js.map +1 -0
  33. package/dist/modules/database/core-schema.d.ts +326 -0
  34. package/dist/modules/database/core-schema.d.ts.map +1 -1
  35. package/dist/modules/database/core-schema.js +52 -0
  36. package/dist/modules/database/core-schema.js.map +1 -1
  37. package/dist/modules/kb-sync/index.d.ts +6 -0
  38. package/dist/modules/kb-sync/index.d.ts.map +1 -0
  39. package/dist/modules/kb-sync/index.js +5 -0
  40. package/dist/modules/kb-sync/index.js.map +1 -0
  41. package/dist/modules/kb-sync/kb-sync.interface.d.ts +77 -0
  42. package/dist/modules/kb-sync/kb-sync.interface.d.ts.map +1 -0
  43. package/dist/modules/kb-sync/kb-sync.interface.js +2 -0
  44. package/dist/modules/kb-sync/kb-sync.interface.js.map +1 -0
  45. package/dist/modules/kb-sync/kb-sync.routes.d.ts +70 -0
  46. package/dist/modules/kb-sync/kb-sync.routes.d.ts.map +1 -0
  47. package/dist/modules/kb-sync/kb-sync.routes.js +135 -0
  48. package/dist/modules/kb-sync/kb-sync.routes.js.map +1 -0
  49. package/dist/modules/kb-sync/kb-sync.service.d.ts +45 -0
  50. package/dist/modules/kb-sync/kb-sync.service.d.ts.map +1 -0
  51. package/dist/modules/kb-sync/kb-sync.service.js +183 -0
  52. package/dist/modules/kb-sync/kb-sync.service.js.map +1 -0
  53. package/dist/modules/kb-sync/sync-auth.d.ts +59 -0
  54. package/dist/modules/kb-sync/sync-auth.d.ts.map +1 -0
  55. package/dist/modules/kb-sync/sync-auth.js +62 -0
  56. package/dist/modules/kb-sync/sync-auth.js.map +1 -0
  57. package/dist/modules/kb-sync/sync-payload.d.ts +32 -0
  58. package/dist/modules/kb-sync/sync-payload.d.ts.map +1 -0
  59. package/dist/modules/kb-sync/sync-payload.js +105 -0
  60. package/dist/modules/kb-sync/sync-payload.js.map +1 -0
  61. package/dist/modules/marketplace/git-http.routes.d.ts +42 -0
  62. package/dist/modules/marketplace/git-http.routes.d.ts.map +1 -0
  63. package/dist/modules/marketplace/git-http.routes.js +190 -0
  64. package/dist/modules/marketplace/git-http.routes.js.map +1 -0
  65. package/dist/modules/marketplace/github-facade/github-facade-admin.routes.d.ts +23 -0
  66. package/dist/modules/marketplace/github-facade/github-facade-admin.routes.d.ts.map +1 -0
  67. package/dist/modules/marketplace/github-facade/github-facade-admin.routes.js +59 -0
  68. package/dist/modules/marketplace/github-facade/github-facade-admin.routes.js.map +1 -0
  69. package/dist/modules/marketplace/github-facade/github-facade-codes.store.d.ts +59 -0
  70. package/dist/modules/marketplace/github-facade/github-facade-codes.store.d.ts.map +1 -0
  71. package/dist/modules/marketplace/github-facade/github-facade-codes.store.js +96 -0
  72. package/dist/modules/marketplace/github-facade/github-facade-codes.store.js.map +1 -0
  73. package/dist/modules/marketplace/github-facade/github-facade-credentials.service.d.ts +99 -0
  74. package/dist/modules/marketplace/github-facade/github-facade-credentials.service.d.ts.map +1 -0
  75. package/dist/modules/marketplace/github-facade/github-facade-credentials.service.js +147 -0
  76. package/dist/modules/marketplace/github-facade/github-facade-credentials.service.js.map +1 -0
  77. package/dist/modules/marketplace/github-facade/github-facade.routes.d.ts +47 -0
  78. package/dist/modules/marketplace/github-facade/github-facade.routes.d.ts.map +1 -0
  79. package/dist/modules/marketplace/github-facade/github-facade.routes.js +228 -0
  80. package/dist/modules/marketplace/github-facade/github-facade.routes.js.map +1 -0
  81. package/dist/modules/marketplace/github-facade/github-facade.service.d.ts +109 -0
  82. package/dist/modules/marketplace/github-facade/github-facade.service.d.ts.map +1 -0
  83. package/dist/modules/marketplace/github-facade/github-facade.service.js +172 -0
  84. package/dist/modules/marketplace/github-facade/github-facade.service.js.map +1 -0
  85. package/dist/modules/marketplace/github-facade/index.d.ts +6 -0
  86. package/dist/modules/marketplace/github-facade/index.d.ts.map +1 -0
  87. package/dist/modules/marketplace/github-facade/index.js +6 -0
  88. package/dist/modules/marketplace/github-facade/index.js.map +1 -0
  89. package/dist/modules/marketplace/index.d.ts +4 -0
  90. package/dist/modules/marketplace/index.d.ts.map +1 -0
  91. package/dist/modules/marketplace/index.js +4 -0
  92. package/dist/modules/marketplace/index.js.map +1 -0
  93. package/dist/modules/marketplace/marketplace-repo.service.d.ts +122 -0
  94. package/dist/modules/marketplace/marketplace-repo.service.d.ts.map +1 -0
  95. package/dist/modules/marketplace/marketplace-repo.service.js +300 -0
  96. package/dist/modules/marketplace/marketplace-repo.service.js.map +1 -0
  97. package/dist/modules/mcp/oauth/bevel-oauth-provider.d.ts.map +1 -1
  98. package/dist/modules/mcp/oauth/bevel-oauth-provider.js +4 -0
  99. package/dist/modules/mcp/oauth/bevel-oauth-provider.js.map +1 -1
  100. package/dist/modules/mcp/oauth/oauth-consent.routes.d.ts +14 -8
  101. package/dist/modules/mcp/oauth/oauth-consent.routes.d.ts.map +1 -1
  102. package/dist/modules/mcp/oauth/oauth-consent.routes.js +13 -1
  103. package/dist/modules/mcp/oauth/oauth-consent.routes.js.map +1 -1
  104. package/dist/modules/mcp/oauth/oauth-state.d.ts +13 -2
  105. package/dist/modules/mcp/oauth/oauth-state.d.ts.map +1 -1
  106. package/dist/modules/mcp/oauth/oauth-state.js +3 -1
  107. package/dist/modules/mcp/oauth/oauth-state.js.map +1 -1
  108. package/dist/modules/plugins/compile/compile-marketplace.d.ts +97 -0
  109. package/dist/modules/plugins/compile/compile-marketplace.d.ts.map +1 -0
  110. package/dist/modules/plugins/compile/compile-marketplace.js +240 -0
  111. package/dist/modules/plugins/compile/compile-marketplace.js.map +1 -0
  112. package/dist/modules/plugins/compile/marketplace-compiler.service.d.ts +66 -0
  113. package/dist/modules/plugins/compile/marketplace-compiler.service.d.ts.map +1 -0
  114. package/dist/modules/plugins/compile/marketplace-compiler.service.js +132 -0
  115. package/dist/modules/plugins/compile/marketplace-compiler.service.js.map +1 -0
  116. package/dist/modules/plugins/discovery/bundle-dialect/bundle.source.d.ts +37 -0
  117. package/dist/modules/plugins/discovery/bundle-dialect/bundle.source.d.ts.map +1 -0
  118. package/dist/modules/plugins/discovery/bundle-dialect/bundle.source.js +135 -0
  119. package/dist/modules/plugins/discovery/bundle-dialect/bundle.source.js.map +1 -0
  120. package/dist/modules/plugins/discovery/bundle-dialect/registry.d.ts +45 -0
  121. package/dist/modules/plugins/discovery/bundle-dialect/registry.d.ts.map +1 -0
  122. package/dist/modules/plugins/discovery/bundle-dialect/registry.js +147 -0
  123. package/dist/modules/plugins/discovery/bundle-dialect/registry.js.map +1 -0
  124. package/dist/modules/plugins/discovery/kb-plugin-source.d.ts +37 -0
  125. package/dist/modules/plugins/discovery/kb-plugin-source.d.ts.map +1 -0
  126. package/dist/modules/plugins/discovery/kb-plugin-source.js +107 -0
  127. package/dist/modules/plugins/discovery/kb-plugin-source.js.map +1 -0
  128. package/dist/modules/plugins/discovery/native.source.d.ts +15 -0
  129. package/dist/modules/plugins/discovery/native.source.d.ts.map +1 -0
  130. package/dist/modules/plugins/discovery/native.source.js +102 -0
  131. package/dist/modules/plugins/discovery/native.source.js.map +1 -0
  132. package/dist/modules/plugins/discovery/plugin-source.d.ts +96 -0
  133. package/dist/modules/plugins/discovery/plugin-source.d.ts.map +1 -0
  134. package/dist/modules/plugins/discovery/plugin-source.js +2 -0
  135. package/dist/modules/plugins/discovery/plugin-source.js.map +1 -0
  136. package/dist/modules/plugins/index.d.ts +10 -1
  137. package/dist/modules/plugins/index.d.ts.map +1 -1
  138. package/dist/modules/plugins/index.js +8 -0
  139. package/dist/modules/plugins/index.js.map +1 -1
  140. package/dist/modules/plugins/plugin-links.d.ts +66 -0
  141. package/dist/modules/plugins/plugin-links.d.ts.map +1 -0
  142. package/dist/modules/plugins/plugin-links.js +160 -0
  143. package/dist/modules/plugins/plugin-links.js.map +1 -0
  144. package/dist/modules/plugins/plugin-links.service.d.ts +114 -0
  145. package/dist/modules/plugins/plugin-links.service.d.ts.map +1 -0
  146. package/dist/modules/plugins/plugin-links.service.js +304 -0
  147. package/dist/modules/plugins/plugin-links.service.js.map +1 -0
  148. package/dist/modules/plugins/plugin-provision.service.d.ts +39 -3
  149. package/dist/modules/plugins/plugin-provision.service.d.ts.map +1 -1
  150. package/dist/modules/plugins/plugin-provision.service.js +152 -52
  151. package/dist/modules/plugins/plugin-provision.service.js.map +1 -1
  152. package/dist/modules/plugins/plugin-rename.service.d.ts +69 -0
  153. package/dist/modules/plugins/plugin-rename.service.d.ts.map +1 -0
  154. package/dist/modules/plugins/plugin-rename.service.js +245 -0
  155. package/dist/modules/plugins/plugin-rename.service.js.map +1 -0
  156. package/dist/modules/plugins/plugins.contract.d.ts +27 -1
  157. package/dist/modules/plugins/plugins.contract.d.ts.map +1 -1
  158. package/dist/modules/plugins/plugins.routes.d.ts +7 -1
  159. package/dist/modules/plugins/plugins.routes.d.ts.map +1 -1
  160. package/dist/modules/plugins/plugins.routes.js +120 -12
  161. package/dist/modules/plugins/plugins.routes.js.map +1 -1
  162. package/dist/modules/plugins/plugins.service.d.ts +50 -3
  163. package/dist/modules/plugins/plugins.service.d.ts.map +1 -1
  164. package/dist/modules/plugins/plugins.service.js +108 -47
  165. package/dist/modules/plugins/plugins.service.js.map +1 -1
  166. package/dist/modules/settings/deployment-settings.service.d.ts +9 -0
  167. package/dist/modules/settings/deployment-settings.service.d.ts.map +1 -1
  168. package/dist/modules/settings/deployment-settings.service.js +82 -2
  169. package/dist/modules/settings/deployment-settings.service.js.map +1 -1
  170. package/dist/modules/settings/setup.routes.d.ts +26 -0
  171. package/dist/modules/settings/setup.routes.d.ts.map +1 -1
  172. package/dist/modules/settings/setup.routes.js +9 -1
  173. package/dist/modules/settings/setup.routes.js.map +1 -1
  174. package/dist/modules/skills/index.d.ts +1 -0
  175. package/dist/modules/skills/index.d.ts.map +1 -1
  176. package/dist/modules/skills/index.js +1 -0
  177. package/dist/modules/skills/index.js.map +1 -1
  178. package/dist/modules/skills/pending-skills.service.d.ts.map +1 -1
  179. package/dist/modules/skills/pending-skills.service.js +9 -4
  180. package/dist/modules/skills/pending-skills.service.js.map +1 -1
  181. package/dist/modules/skills/skill-access-requests.routes.d.ts +38 -0
  182. package/dist/modules/skills/skill-access-requests.routes.d.ts.map +1 -0
  183. package/dist/modules/skills/skill-access-requests.routes.js +168 -0
  184. package/dist/modules/skills/skill-access-requests.routes.js.map +1 -0
  185. package/dist/modules/skills/skills.contract.d.ts +31 -0
  186. package/dist/modules/skills/skills.contract.d.ts.map +1 -1
  187. package/dist/modules/skills/skills.routes.d.ts +28 -3
  188. package/dist/modules/skills/skills.routes.d.ts.map +1 -1
  189. package/dist/modules/skills/skills.routes.js +42 -3
  190. package/dist/modules/skills/skills.routes.js.map +1 -1
  191. package/dist/modules/skills/skills.service.d.ts +4 -0
  192. package/dist/modules/skills/skills.service.d.ts.map +1 -1
  193. package/dist/modules/skills/skills.service.js +83 -22
  194. package/dist/modules/skills/skills.service.js.map +1 -1
  195. package/dist/modules/tool-auth/external-api-key.interface.d.ts +18 -1
  196. package/dist/modules/tool-auth/external-api-key.interface.d.ts.map +1 -1
  197. package/dist/modules/tool-auth/external-api-key.interface.js +2 -1
  198. package/dist/modules/tool-auth/external-api-key.interface.js.map +1 -1
  199. package/dist/modules/tool-auth/external-api-key.service.d.ts +13 -4
  200. package/dist/modules/tool-auth/external-api-key.service.d.ts.map +1 -1
  201. package/dist/modules/tool-auth/external-api-key.service.js +26 -9
  202. package/dist/modules/tool-auth/external-api-key.service.js.map +1 -1
  203. package/dist/modules/tool-manuals/mcp-json-discovery.d.ts +36 -0
  204. package/dist/modules/tool-manuals/mcp-json-discovery.d.ts.map +1 -1
  205. package/dist/modules/tool-manuals/mcp-json-discovery.js +130 -92
  206. package/dist/modules/tool-manuals/mcp-json-discovery.js.map +1 -1
  207. package/dist/modules/tool-manuals/tool-manuals.service.d.ts +6 -1
  208. package/dist/modules/tool-manuals/tool-manuals.service.d.ts.map +1 -1
  209. package/dist/modules/tool-manuals/tool-manuals.service.js +18 -25
  210. package/dist/modules/tool-manuals/tool-manuals.service.js.map +1 -1
  211. package/dist/modules/workflow/git/git.service.d.ts +40 -2
  212. package/dist/modules/workflow/git/git.service.d.ts.map +1 -1
  213. package/dist/modules/workflow/git/git.service.js +227 -54
  214. package/dist/modules/workflow/git/git.service.js.map +1 -1
  215. package/dist/modules/workflow/git/pull-request.service.d.ts +6 -0
  216. package/dist/modules/workflow/git/pull-request.service.d.ts.map +1 -1
  217. package/dist/modules/workflow/git/pull-request.service.js +8 -0
  218. package/dist/modules/workflow/git/pull-request.service.js.map +1 -1
  219. package/dist/modules/workflow/workflow.service.d.ts +52 -1
  220. package/dist/modules/workflow/workflow.service.d.ts.map +1 -1
  221. package/dist/modules/workflow/workflow.service.js +242 -9
  222. package/dist/modules/workflow/workflow.service.js.map +1 -1
  223. package/dist/modules/workspace/startup/steps/plugin-manifests.step.d.ts +35 -0
  224. package/dist/modules/workspace/startup/steps/plugin-manifests.step.d.ts.map +1 -0
  225. package/dist/modules/workspace/startup/steps/plugin-manifests.step.js +121 -0
  226. package/dist/modules/workspace/startup/steps/plugin-manifests.step.js.map +1 -0
  227. package/dist/modules/workspace/startup/steps/seed-tree.d.ts.map +1 -1
  228. package/dist/modules/workspace/startup/steps/seed-tree.js +46 -2
  229. package/dist/modules/workspace/startup/steps/seed-tree.js.map +1 -1
  230. package/dist/modules/workspace/startup/steps/template-files.step.d.ts.map +1 -1
  231. package/dist/modules/workspace/startup/steps/template-files.step.js +112 -25
  232. package/dist/modules/workspace/startup/steps/template-files.step.js.map +1 -1
  233. package/dist/modules/workspace/workspace.routes.d.ts.map +1 -1
  234. package/dist/modules/workspace/workspace.routes.js +9 -9
  235. package/dist/modules/workspace/workspace.routes.js.map +1 -1
  236. package/dist/modules/workspace/workspace.service.d.ts +33 -0
  237. package/dist/modules/workspace/workspace.service.d.ts.map +1 -1
  238. package/dist/modules/workspace/workspace.service.js +110 -16
  239. package/dist/modules/workspace/workspace.service.js.map +1 -1
  240. package/dist/shared/domain-errors.d.ts +20 -0
  241. package/dist/shared/domain-errors.d.ts.map +1 -1
  242. package/dist/shared/domain-errors.js +29 -0
  243. package/dist/shared/domain-errors.js.map +1 -1
  244. package/dist/shared/fs-errors.d.ts +8 -0
  245. package/dist/shared/fs-errors.d.ts.map +1 -0
  246. package/dist/shared/fs-errors.js +11 -0
  247. package/dist/shared/fs-errors.js.map +1 -0
  248. package/dist/shared/fs-walk.d.ts +20 -6
  249. package/dist/shared/fs-walk.d.ts.map +1 -1
  250. package/dist/shared/fs-walk.js +35 -27
  251. package/dist/shared/fs-walk.js.map +1 -1
  252. package/dist/shared/kb-walk.d.ts +52 -0
  253. package/dist/shared/kb-walk.d.ts.map +1 -0
  254. package/dist/shared/kb-walk.js +76 -0
  255. package/dist/shared/kb-walk.js.map +1 -0
  256. package/dist/shared/path-order.d.ts +18 -0
  257. package/dist/shared/path-order.d.ts.map +1 -0
  258. package/dist/shared/path-order.js +35 -0
  259. package/dist/shared/path-order.js.map +1 -0
  260. package/dist/shared/ttl-cache.d.ts +28 -1
  261. package/dist/shared/ttl-cache.d.ts.map +1 -1
  262. package/dist/shared/ttl-cache.js +33 -1
  263. package/dist/shared/ttl-cache.js.map +1 -1
  264. package/kb-template/.bevelignore +1 -1
  265. package/kb-template/AGENTS.md +95 -30
  266. package/kb-template/Skills/.gitkeep +0 -0
  267. package/migrations/0005_github_facade.sql +25 -0
  268. package/migrations/meta/0005_snapshot.json +1717 -0
  269. package/migrations/meta/_journal.json +7 -0
  270. package/package.json +6 -6
  271. package/src/__tests__/kb-layout-config.test.ts +110 -0
  272. package/src/core/__tests__/catalog-cache-invalidation.test.ts +146 -0
  273. package/src/core/catalog-cache-invalidation.ts +92 -0
  274. package/src/core/create-core-server.ts +123 -7
  275. package/src/core/create-core-services.ts +162 -41
  276. package/src/modules/access/__tests__/access-control.invalidate-race.test.ts +86 -0
  277. package/src/modules/access/__tests__/access-control.service.test.ts +19 -3
  278. package/src/modules/access/__tests__/access-plugin-principals.test.ts +368 -0
  279. package/src/modules/access/__tests__/groups-admin.service.test.ts +8 -0
  280. package/src/modules/access/access-control.interface.ts +20 -9
  281. package/src/modules/access/access-control.service.ts +240 -78
  282. package/src/modules/access/access.routes.ts +96 -14
  283. package/src/modules/access-model/__tests__/access-grammar.test.ts +18 -0
  284. package/src/modules/access-model/__tests__/plugin-token-canonical.test.ts +40 -0
  285. package/src/modules/access-model/access-grammar.ts +114 -2
  286. package/src/modules/access-model/group-files.ts +4 -0
  287. package/src/modules/access-model/plugin-principals.ts +137 -0
  288. package/src/modules/database/core-schema.ts +54 -0
  289. package/src/modules/kb-sync/__tests__/kb-sync.routes.test.ts +297 -0
  290. package/src/modules/kb-sync/__tests__/kb-sync.service.test.ts +295 -0
  291. package/src/modules/kb-sync/__tests__/sync-auth.test.ts +118 -0
  292. package/src/modules/kb-sync/__tests__/sync-payload.test.ts +148 -0
  293. package/src/modules/kb-sync/index.ts +19 -0
  294. package/src/modules/kb-sync/kb-sync.interface.ts +79 -0
  295. package/src/modules/kb-sync/kb-sync.routes.ts +197 -0
  296. package/src/modules/kb-sync/kb-sync.service.ts +201 -0
  297. package/src/modules/kb-sync/sync-auth.ts +118 -0
  298. package/src/modules/kb-sync/sync-payload.ts +143 -0
  299. package/src/modules/marketplace/__tests__/github-facade.test.ts +443 -0
  300. package/src/modules/marketplace/__tests__/marketplace-git.test.ts +179 -0
  301. package/src/modules/marketplace/git-http.routes.ts +193 -0
  302. package/src/modules/marketplace/github-facade/github-facade-admin.routes.ts +78 -0
  303. package/src/modules/marketplace/github-facade/github-facade-codes.store.ts +145 -0
  304. package/src/modules/marketplace/github-facade/github-facade-credentials.service.ts +208 -0
  305. package/src/modules/marketplace/github-facade/github-facade.routes.ts +268 -0
  306. package/src/modules/marketplace/github-facade/github-facade.service.ts +221 -0
  307. package/src/modules/marketplace/github-facade/index.ts +25 -0
  308. package/src/modules/marketplace/index.ts +3 -0
  309. package/src/modules/marketplace/marketplace-repo.service.ts +337 -0
  310. package/src/modules/mcp/oauth/bevel-oauth-provider.ts +3 -0
  311. package/src/modules/mcp/oauth/oauth-consent.routes.ts +24 -2
  312. package/src/modules/mcp/oauth/oauth-state.ts +15 -3
  313. package/src/modules/plugins/__tests__/bundle-dialect.e2e.test.ts +163 -0
  314. package/src/modules/plugins/__tests__/compile-marketplace.test.ts +294 -0
  315. package/src/modules/plugins/__tests__/plugin-index.service.test.ts +56 -12
  316. package/src/modules/plugins/__tests__/plugin-links.service.test.ts +287 -0
  317. package/src/modules/plugins/__tests__/plugin-provision.service.test.ts +205 -5
  318. package/src/modules/plugins/__tests__/plugin-rename.service.test.ts +394 -0
  319. package/src/modules/plugins/__tests__/plugins.routes.test.ts +80 -33
  320. package/src/modules/plugins/compile/compile-marketplace.ts +403 -0
  321. package/src/modules/plugins/compile/marketplace-compiler.service.ts +150 -0
  322. package/src/modules/plugins/discovery/__tests__/kb-plugin-source.test.ts +329 -0
  323. package/src/modules/plugins/discovery/bundle-dialect/bundle.source.ts +140 -0
  324. package/src/modules/plugins/discovery/bundle-dialect/registry.ts +175 -0
  325. package/src/modules/plugins/discovery/kb-plugin-source.ts +114 -0
  326. package/src/modules/plugins/discovery/native.source.ts +122 -0
  327. package/src/modules/plugins/discovery/plugin-source.ts +99 -0
  328. package/src/modules/plugins/index.ts +10 -0
  329. package/src/modules/plugins/plugin-links.service.ts +363 -0
  330. package/src/modules/plugins/plugin-links.ts +184 -0
  331. package/src/modules/plugins/plugin-provision.service.ts +160 -54
  332. package/src/modules/plugins/plugin-rename.service.ts +298 -0
  333. package/src/modules/plugins/plugins.contract.ts +28 -1
  334. package/src/modules/plugins/plugins.routes.ts +128 -11
  335. package/src/modules/plugins/plugins.service.ts +106 -53
  336. package/src/modules/settings/__tests__/deployment-settings.service.test.ts +57 -0
  337. package/src/modules/settings/__tests__/setup.routes.sync-status.test.ts +77 -0
  338. package/src/modules/settings/deployment-settings.service.ts +95 -2
  339. package/src/modules/settings/setup.routes.ts +24 -0
  340. package/src/modules/skills/__tests__/skill-access-requests.routes.test.ts +128 -0
  341. package/src/modules/skills/__tests__/skills.service.test.ts +85 -0
  342. package/src/modules/skills/index.ts +1 -0
  343. package/src/modules/skills/pending-skills.service.ts +7 -5
  344. package/src/modules/skills/skill-access-requests.routes.ts +199 -0
  345. package/src/modules/skills/skills.contract.ts +32 -0
  346. package/src/modules/skills/skills.routes.ts +59 -3
  347. package/src/modules/skills/skills.service.ts +84 -22
  348. package/src/modules/tool-auth/external-api-key.interface.ts +20 -1
  349. package/src/modules/tool-auth/external-api-key.service.ts +31 -13
  350. package/src/modules/tool-manuals/__tests__/mcp-json-discovery.test.ts +24 -1
  351. package/src/modules/tool-manuals/__tests__/tool-manuals.cli.test.ts +2 -0
  352. package/src/modules/tool-manuals/mcp-json-discovery.ts +154 -88
  353. package/src/modules/tool-manuals/tool-manuals.service.ts +14 -23
  354. package/src/modules/workflow/__tests__/preserve-roles-yaml.test.ts +1 -1
  355. package/src/modules/workflow/__tests__/workflow.service.commitFileWhileLocked.test.ts +1 -0
  356. package/src/modules/workflow/__tests__/workflow.service.facade.test.ts +2 -2
  357. package/src/modules/workflow/__tests__/workflow.service.releaseLock.test.ts +119 -2
  358. package/src/modules/workflow/__tests__/workflow.service.sync.test.ts +437 -0
  359. package/src/modules/workflow/git/__tests__/git.service.postMergePull.test.ts +3 -3
  360. package/src/modules/workflow/git/__tests__/git.service.pull.test.ts +47 -4
  361. package/src/modules/workflow/git/__tests__/git.service.syncFromRemote.test.ts +253 -0
  362. package/src/modules/workflow/git/git.service.ts +239 -56
  363. package/src/modules/workflow/git/pull-request.service.ts +9 -0
  364. package/src/modules/workflow/workflow.service.ts +260 -9
  365. package/src/modules/workspace/__tests__/workspace.routes.read-gate.test.ts +6 -7
  366. package/src/modules/workspace/__tests__/workspace.service.list-cloned.test.ts +93 -0
  367. package/src/modules/workspace/__tests__/workspace.service.missing-branch.test.ts +28 -0
  368. package/src/modules/workspace/__tests__/workspace.service.read-filter.test.ts +42 -12
  369. package/src/modules/workspace/startup/steps/__tests__/steps.test.ts +219 -4
  370. package/src/modules/workspace/startup/steps/plugin-manifests.step.ts +129 -0
  371. package/src/modules/workspace/startup/steps/seed-tree.ts +44 -2
  372. package/src/modules/workspace/startup/steps/template-files.step.ts +131 -27
  373. package/src/modules/workspace/workspace.routes.ts +9 -17
  374. package/src/modules/workspace/workspace.service.ts +107 -16
  375. package/src/shared/__tests__/filename.test.ts +0 -0
  376. package/src/shared/__tests__/fs-walk.test.ts +22 -1
  377. package/src/shared/__tests__/kb-walk.test.ts +107 -0
  378. package/src/shared/__tests__/path-order.test.ts +24 -0
  379. package/src/shared/__tests__/ttl-cache.test.ts +55 -0
  380. package/src/shared/domain-errors.ts +29 -0
  381. package/src/shared/fs-errors.ts +10 -0
  382. package/src/shared/fs-walk.ts +38 -23
  383. package/src/shared/kb-walk.ts +95 -0
  384. package/src/shared/path-order.ts +33 -0
  385. package/src/shared/ttl-cache.ts +33 -1
@@ -0,0 +1,99 @@
1
+ import type { Database } from '../../database/connection.js';
2
+ import type { TokenCrypto } from '../../../shared/token-crypto.js';
3
+ /**
4
+ * What Claude's "Add manually" form for a GitHub Enterprise Server asks an
5
+ * Owner to paste, and what the token exchange later checks: the identity
6
+ * this deployment presents to claude.ai as if it were a GitHub App.
7
+ *
8
+ * Every field is generated HERE, once per deployment — nothing is registered
9
+ * anywhere else, because there is no GitHub: hexis is the host Claude talks
10
+ * to. The private key is handed over because the form requires one; the
11
+ * user-added marketplace flow never signs with it (the observed contract is
12
+ * the OAuth pair plus three REST calls), but a future organization
13
+ * marketplace would, and rotating everything together is simpler than
14
+ * explaining which half matters.
15
+ */
16
+ export interface GitHubFacadeCredentials {
17
+ appId: string;
18
+ clientId: string;
19
+ clientSecret: string;
20
+ webhookSecret: string;
21
+ privateKeyPem: string;
22
+ publicKeyPem: string;
23
+ createdAt: Date;
24
+ rotatedAt: Date | null;
25
+ }
26
+ /**
27
+ * Where the one credentials row lives — the database in production, memory
28
+ * in tests. THE row, not a copy of it: every replica reads the store on
29
+ * every use, so a rotation on one replica is what every other replica
30
+ * checks the very next exchange. The reads are rare (a connect, an admin
31
+ * page), and a cache would be a second source of truth with no invalidation.
32
+ *
33
+ * Both writes are conditional, so two replicas writing at once cannot
34
+ * disagree about what is stored: creation happens only when no row exists,
35
+ * and a rotation replaces only the set the caller was looking at. Either way
36
+ * the caller gets back what the store holds afterwards, never what it sent.
37
+ */
38
+ export interface GitHubFacadeCredentialsStore {
39
+ load(): Promise<GitHubFacadeCredentials | null>;
40
+ /**
41
+ * Store `creds` only if no row exists yet, and return whichever row
42
+ * exists afterwards — so two replicas initialising at once agree on one
43
+ * set, and the loser's generated values are simply dropped.
44
+ */
45
+ createIfAbsent(creds: GitHubFacadeCredentials): Promise<GitHubFacadeCredentials>;
46
+ /**
47
+ * Replace the row only while it still carries `expectedClientId`, and
48
+ * return what is stored afterwards. Two admins rotating at once: the first
49
+ * write wins, the second finds a different client id, writes nothing, and
50
+ * is shown the winner's set — the only one Claude will accept.
51
+ */
52
+ replaceIfCurrent(expectedClientId: string, creds: GitHubFacadeCredentials): Promise<GitHubFacadeCredentials>;
53
+ }
54
+ /**
55
+ * The database-backed store. Secrets are sealed with the deployment's secrets
56
+ * key, exactly as stored settings are; without that key there is nowhere safe
57
+ * to keep a client secret, so the store refuses rather than writing plaintext.
58
+ */
59
+ export declare class DbGitHubFacadeCredentialsStore implements GitHubFacadeCredentialsStore {
60
+ private readonly db;
61
+ private readonly crypto;
62
+ constructor(db: Database, crypto: TokenCrypto | null);
63
+ load(): Promise<GitHubFacadeCredentials | null>;
64
+ createIfAbsent(creds: GitHubFacadeCredentials): Promise<GitHubFacadeCredentials>;
65
+ replaceIfCurrent(expectedClientId: string, creds: GitHubFacadeCredentials): Promise<GitHubFacadeCredentials>;
66
+ private stored;
67
+ private seal;
68
+ private requireCrypto;
69
+ }
70
+ export declare class GitHubFacadeUnavailableError extends Error {
71
+ constructor(message: string);
72
+ }
73
+ /**
74
+ * Generates the credentials on first use and reads them from the store on
75
+ * every use after that. No in-process copy: the store is the one place the
76
+ * truth lives, whichever replica asks.
77
+ */
78
+ export declare class GitHubFacadeCredentialsService {
79
+ private readonly store;
80
+ constructor(store: GitHubFacadeCredentialsStore);
81
+ /** The credentials, generated on first use. */
82
+ ensure(): Promise<GitHubFacadeCredentials>;
83
+ /**
84
+ * New credentials, all of them — replacing the set this call read, and
85
+ * returning whatever is stored afterwards. Every registration on the
86
+ * Claude side stops matching at once, which is the point of rotating: the
87
+ * Owner re-enters the new set, and connected users' tokens (connection
88
+ * keys) are untouched, since those are ours.
89
+ */
90
+ rotate(): Promise<GitHubFacadeCredentials>;
91
+ }
92
+ /** For tests: the row kept in memory, with the same conditional writes. */
93
+ export declare class MemoryGitHubFacadeCredentialsStore implements GitHubFacadeCredentialsStore {
94
+ private row;
95
+ load(): Promise<GitHubFacadeCredentials | null>;
96
+ createIfAbsent(creds: GitHubFacadeCredentials): Promise<GitHubFacadeCredentials>;
97
+ replaceIfCurrent(expectedClientId: string, creds: GitHubFacadeCredentials): Promise<GitHubFacadeCredentials>;
98
+ }
99
+ //# sourceMappingURL=github-facade-credentials.service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"github-facade-credentials.service.d.ts","sourceRoot":"","sources":["../../../../src/modules/marketplace/github-facade/github-facade-credentials.service.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAE7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAEnE;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,uBAAuB;IACtC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,IAAI,GAAG,IAAI,CAAC;CACxB;AAED;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,4BAA4B;IAC3C,IAAI,IAAI,OAAO,CAAC,uBAAuB,GAAG,IAAI,CAAC,CAAC;I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gB,CAAC,gBAAgB,EAAE,MAAM,EAAE,KAAK,EAAE,uBAAuB,GAAG,OAAO,CAAC,uBAAuB,CAAC;CAInH"}
@@ -0,0 +1,147 @@
1
+ import { generateKeyPairSync, randomBytes, randomInt } from 'node:crypto';
2
+ import { and, eq } from 'drizzle-orm';
3
+ import { githubFacadeIdentity } from '../../database/schema.js';
4
+ const ROW_ID = 'default';
5
+ /**
6
+ * The database-backed store. Secrets are sealed with the deployment's secrets
7
+ * key, exactly as stored settings are; without that key there is nowhere safe
8
+ * to keep a client secret, so the store refuses rather than writing plaintext.
9
+ */
10
+ export class DbGitHubFacadeCredentialsStore {
11
+ db;
12
+ crypto;
13
+ constructor(db, crypto) {
14
+ this.db = db;
15
+ this.crypto = crypto;
16
+ }
17
+ async load() {
18
+ const [row] = await this.db
19
+ .select()
20
+ .from(githubFacadeIdentity)
21
+ .where(eq(githubFacadeIdentity.id, ROW_ID))
22
+ .limit(1);
23
+ if (!row)
24
+ return null;
25
+ const crypto = this.requireCrypto();
26
+ return {
27
+ appId: row.appId,
28
+ clientId: row.clientId,
29
+ clientSecret: crypto.decrypt(row.clientSecret),
30
+ webhookSecret: crypto.decrypt(row.webhookSecret),
31
+ privateKeyPem: crypto.decrypt(row.privateKeyPem),
32
+ publicKeyPem: row.publicKeyPem,
33
+ createdAt: row.createdAt,
34
+ rotatedAt: row.rotatedAt,
35
+ };
36
+ }
37
+ async createIfAbsent(creds) {
38
+ await this.db
39
+ .insert(githubFacadeIdentity)
40
+ .values({ id: ROW_ID, ...this.seal(creds) })
41
+ .onConflictDoNothing({ target: githubFacadeIdentity.id });
42
+ return this.stored('insert');
43
+ }
44
+ async replaceIfCurrent(expectedClientId, creds) {
45
+ await this.db
46
+ .update(githubFacadeIdentity)
47
+ .set(this.seal(creds))
48
+ .where(and(eq(githubFacadeIdentity.id, ROW_ID), eq(githubFacadeIdentity.clientId, expectedClientId)));
49
+ return this.stored('replace');
50
+ }
51
+ async stored(after) {
52
+ const row = await this.load();
53
+ if (!row)
54
+ throw new Error(`claude bridge credentials vanished between ${after} and read`);
55
+ return row;
56
+ }
57
+ seal(creds) {
58
+ const crypto = this.requireCrypto();
59
+ return {
60
+ appId: creds.appId,
61
+ clientId: creds.clientId,
62
+ clientSecret: crypto.encrypt(creds.clientSecret),
63
+ webhookSecret: crypto.encrypt(creds.webhookSecret),
64
+ privateKeyPem: crypto.encrypt(creds.privateKeyPem),
65
+ publicKeyPem: creds.publicKeyPem,
66
+ createdAt: creds.createdAt,
67
+ rotatedAt: creds.rotatedAt,
68
+ };
69
+ }
70
+ requireCrypto() {
71
+ if (!this.crypto) {
72
+ throw new GitHubFacadeUnavailableError('SECRETS_ENC_KEY is not set, so the Claude connection credentials cannot be stored.');
73
+ }
74
+ return this.crypto;
75
+ }
76
+ }
77
+ export class GitHubFacadeUnavailableError extends Error {
78
+ constructor(message) {
79
+ super(message);
80
+ this.name = 'GitHubFacadeUnavailableError';
81
+ }
82
+ }
83
+ /**
84
+ * Generates the credentials on first use and reads them from the store on
85
+ * every use after that. No in-process copy: the store is the one place the
86
+ * truth lives, whichever replica asks.
87
+ */
88
+ export class GitHubFacadeCredentialsService {
89
+ store;
90
+ constructor(store) {
91
+ this.store = store;
92
+ }
93
+ /** The credentials, generated on first use. */
94
+ async ensure() {
95
+ const existing = await this.store.load();
96
+ if (existing)
97
+ return existing;
98
+ return this.store.createIfAbsent(generateCredentials(null));
99
+ }
100
+ /**
101
+ * New credentials, all of them — replacing the set this call read, and
102
+ * returning whatever is stored afterwards. Every registration on the
103
+ * Claude side stops matching at once, which is the point of rotating: the
104
+ * Owner re-enters the new set, and connected users' tokens (connection
105
+ * keys) are untouched, since those are ours.
106
+ */
107
+ async rotate() {
108
+ const current = await this.ensure();
109
+ return this.store.replaceIfCurrent(current.clientId, generateCredentials(current.createdAt));
110
+ }
111
+ }
112
+ function generateCredentials(createdAt) {
113
+ // The shapes GitHub uses, because the form was built for them: a numeric
114
+ // app id, an `Iv1.`-prefixed client id, hex secrets, a PKCS#1 RSA key.
115
+ const { privateKey, publicKey } = generateKeyPairSync('rsa', {
116
+ modulusLength: 2048,
117
+ privateKeyEncoding: { type: 'pkcs1', format: 'pem' },
118
+ publicKeyEncoding: { type: 'spki', format: 'pem' },
119
+ });
120
+ return {
121
+ appId: String(randomInt(100_000, 999_999)),
122
+ clientId: `Iv1.${randomBytes(8).toString('hex')}`,
123
+ clientSecret: randomBytes(20).toString('hex'),
124
+ webhookSecret: randomBytes(16).toString('hex'),
125
+ privateKeyPem: privateKey,
126
+ publicKeyPem: publicKey,
127
+ createdAt: createdAt ?? new Date(),
128
+ rotatedAt: createdAt ? new Date() : null,
129
+ };
130
+ }
131
+ /** For tests: the row kept in memory, with the same conditional writes. */
132
+ export class MemoryGitHubFacadeCredentialsStore {
133
+ row = null;
134
+ async load() {
135
+ return this.row;
136
+ }
137
+ async createIfAbsent(creds) {
138
+ this.row ??= creds;
139
+ return this.row;
140
+ }
141
+ async replaceIfCurrent(expectedClientId, creds) {
142
+ if (this.row?.clientId === expectedClientId)
143
+ this.row = creds;
144
+ return this.row;
145
+ }
146
+ }
147
+ //# sourceMappingURL=github-facade-credentials.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"github-facade-credentials.service.js","sourceRoot":"","sources":["../../../../src/modules/marketplace/github-facade/github-facade-credentials.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC1E,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAEtC,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAwDhE,MAAM,MAAM,GAAG,SAAS,CAAC;AAEzB;;;;GAIG;AACH,MAAM,OAAO,8BAA8B;IAEtB;IACA;IAFnB,YACmB,EAAY,EACZ,MAA0B;QAD1B,OAAE,GAAF,EAAE,CAAU;QACZ,WAAM,GAAN,MAAM,CAAoB;IAC1C,CAAC;I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WAAW,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC;QAC7C,aAAa,EAAE,WAAW,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC;QAC9C,aAAa,EAAE,UAAU;QACzB,YAAY,EAAE,SAAS;QACvB,SAAS,EAAE,SAAS,IAAI,IAAI,IAAI,EAAE;QAClC,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI;KACzC,CAAC;AACJ,CAAC;AAED,2EAA2E;AAC3E,MAAM,OAAO,kCAAkC;IACrC,GAAG,GAAmC,IAAI,CAAC;IACnD,KAAK,CAAC,IAAI;QACR,OAAO,IAAI,CAAC,GAAG,CAAC;IAClB,CAAC;IACD,KAAK,CAAC,cAAc,CAAC,KAA8B;QACjD,IAAI,CAAC,GAAG,KAAK,KAAK,CAAC;QACnB,OAAO,IAAI,CAAC,GAAG,CAAC;IAClB,CAAC;IACD,KAAK,CAAC,gBAAgB,CAAC,gBAAwB,EAAE,KAA8B;QAC7E,IAAI,IAAI,CAAC,GAAG,EAAE,QAAQ,KAAK,gBAAgB;YAAE,IAAI,CAAC,GAAG,GAAG,KAAK,CAAC;QAC9D,OAAO,IAAI,CAAC,GAAI,CAAC;IACnB,CAAC;CACF"}
@@ -0,0 +1,47 @@
1
+ import express from 'express';
2
+ import '../../auth/auth.middleware.js';
3
+ import '../../tool-auth/external-api-key.interface.js';
4
+ import type { MarketplaceRepoService } from '../marketplace-repo.service.js';
5
+ import type { MarketplaceKeyResolver } from '../git-http.routes.js';
6
+ import { type GitHubFacade } from './github-facade.service.js';
7
+ export interface GitHubFacadeRoutesDeps {
8
+ facade: GitHubFacade;
9
+ keys: MarketplaceKeyResolver;
10
+ repo: MarketplaceRepoService;
11
+ /**
12
+ * The owner and name claude.ai derives from the marketplace URL people
13
+ * paste — the SAME URL Claude Code clones: `https://<host>/git/marketplace.git`
14
+ * reads as owner `git`, repository `marketplace`. One address for every
15
+ * Claude surface.
16
+ */
17
+ owner: string;
18
+ repoName: string;
19
+ /**
20
+ * The deployment's public address. Only its ORIGIN is ever emitted: a
21
+ * configured URL may carry userinfo or a path, and neither belongs in a
22
+ * body handed to a third party.
23
+ */
24
+ publicUrl: string;
25
+ }
26
+ /**
27
+ * The GitHub Enterprise surface a consumer (claude.ai, Cowork) talks to when
28
+ * a person adds this deployment's marketplace from their own settings —
29
+ * observed call for call against a lookalike host, and nothing beyond it:
30
+ *
31
+ * GET /login/oauth/authorize the "connect your account" redirect
32
+ * POST /login/oauth/access_token code → token (our client id + secret)
33
+ * GET /api/v3/repos/:owner/:repo repository metadata
34
+ * GET …/commits?per_page=1 the head commit — of THIS person's tree
35
+ * GET …/zipball/:ref that tree, zipped
36
+ *
37
+ * Mounted at the app root, ahead of the SPA and the `/api` JWT mounts: the
38
+ * first two are hit by a bare browser and by Anthropic's backend, the rest
39
+ * carry the person's token as a Bearer. The token is a connection key, so a
40
+ * revoked link fails here the same way it fails on the git remote.
41
+ *
42
+ * Errors are GitHub-shaped too (`{ message }`, and the OAuth error body on
43
+ * the token endpoint, in whichever encoding the client negotiated): the
44
+ * caller is a GitHub client and reads them as one.
45
+ */
46
+ export declare function createGitHubFacadeRoutes(deps: GitHubFacadeRoutesDeps): express.Router;
47
+ //# sourceMappingURL=github-facade.routes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"github-facade.routes.d.ts","sourceRoot":"","sources":["../../../../src/modules/marketplace/github-facade/github-facade.routes.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAC;AAE9B,OAAO,+BAA+B,CAAC;AACvC,OAAO,+CAA+C,CAAC;AACvD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAC7E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AACpE,OAAO,EAA4B,KAAK,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAEzF,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,YAAY,CAAC;IACrB,IAAI,EAAE,sBAAsB,CAAC;IAC7B,IAAI,EAAE,sBAAsB,CAAC;IAC7B;;;;;OAKG;IACH,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,sBAAsB,GAAG,OAAO,CAAC,MAAM,CAoIrF"}
@@ -0,0 +1,228 @@
1
+ import express from 'express';
2
+ import '../../auth/auth.middleware.js'; // Express Request.userId / userEmail augmentation
3
+ import '../../tool-auth/external-api-key.interface.js'; // Express Request augmentation (req.externalApiKeyId)
4
+ import { GitHubFacadeRequestError } from './github-facade.service.js';
5
+ /**
6
+ * The GitHub Enterprise surface a consumer (claude.ai, Cowork) talks to when
7
+ * a person adds this deployment's marketplace from their own settings —
8
+ * observed call for call against a lookalike host, and nothing beyond it:
9
+ *
10
+ * GET /login/oauth/authorize the "connect your account" redirect
11
+ * POST /login/oauth/access_token code → token (our client id + secret)
12
+ * GET /api/v3/repos/:owner/:repo repository metadata
13
+ * GET …/commits?per_page=1 the head commit — of THIS person's tree
14
+ * GET …/zipball/:ref that tree, zipped
15
+ *
16
+ * Mounted at the app root, ahead of the SPA and the `/api` JWT mounts: the
17
+ * first two are hit by a bare browser and by Anthropic's backend, the rest
18
+ * carry the person's token as a Bearer. The token is a connection key, so a
19
+ * revoked link fails here the same way it fails on the git remote.
20
+ *
21
+ * Errors are GitHub-shaped too (`{ message }`, and the OAuth error body on
22
+ * the token endpoint, in whichever encoding the client negotiated): the
23
+ * caller is a GitHub client and reads them as one.
24
+ */
25
+ export function createGitHubFacadeRoutes(deps) {
26
+ const router = express.Router();
27
+ const { facade, keys, repo, owner, repoName } = deps;
28
+ const origin = new URL(deps.publicUrl).origin;
29
+ const fullName = `${owner}/${repoName}`;
30
+ router.get('/login/oauth/authorize', async (req, res) => {
31
+ try {
32
+ res.redirect(302, await facade.authorizeRedirect(req.query));
33
+ }
34
+ catch (err) {
35
+ answerError(res, err);
36
+ }
37
+ });
38
+ // GitHub's token endpoint takes JSON or a form and answers in the shape
39
+ // `Accept` asks for — success and failure alike; claude.ai sends JSON and
40
+ // asks for JSON.
41
+ router.post('/login/oauth/access_token', express.json({ limit: '16kb' }), express.urlencoded({ extended: false, limit: '16kb' }), async (req, res) => {
42
+ try {
43
+ negotiated(req, res, 200, await facade.exchangeCode((req.body ?? {})));
44
+ }
45
+ catch (err) {
46
+ if (err instanceof GitHubFacadeRequestError) {
47
+ negotiated(req, res, err.status, { error: err.code, error_description: err.message });
48
+ return;
49
+ }
50
+ answerError(res, err);
51
+ }
52
+ });
53
+ // --- the REST API, as far as the observed contract goes ---------------------
54
+ const api = express.Router();
55
+ api.use(async (req, res, next) => {
56
+ const token = bearerOf(req);
57
+ if (!token || !keys.looksLikeExternalApiKey(token)) {
58
+ unauthorized(res);
59
+ return;
60
+ }
61
+ let resolved;
62
+ try {
63
+ resolved = await keys.verifyAndLoadToken(token);
64
+ }
65
+ catch (err) {
66
+ console.error('[github-facade] key verification failed:', err);
67
+ res.status(500).json({ message: 'Authentication backend unavailable' });
68
+ return;
69
+ }
70
+ if (!resolved) {
71
+ unauthorized(res);
72
+ return;
73
+ }
74
+ req.userId = resolved.user.id;
75
+ req.userEmail = resolved.user.email;
76
+ req.externalApiKeyId = resolved.tokenId;
77
+ next();
78
+ });
79
+ const isOurs = (req) => req.params.owner === owner && req.params.repo === repoName;
80
+ const notFound = (res) => res.status(404).json({ message: 'Not Found' });
81
+ api.get('/repos/:owner/:repo', (req, res) => {
82
+ if (!isOurs(req))
83
+ return void notFound(res);
84
+ res.json(repositoryBody(fullName, owner, repoName, origin));
85
+ });
86
+ api.get('/repos/:owner/:repo/commits', async (req, res) => {
87
+ if (!isOurs(req))
88
+ return void notFound(res);
89
+ try {
90
+ const { sha } = await repo.headFor({ id: req.userId, email: req.userEmail });
91
+ const commit = await repo.describeCommit(sha);
92
+ res.json([commitBody(commit, fullName, origin)]);
93
+ }
94
+ catch (err) {
95
+ answerError(res, err);
96
+ }
97
+ });
98
+ api.get('/repos/:owner/:repo/zipball/:ref', async (req, res) => {
99
+ if (!isOurs(req))
100
+ return void notFound(res);
101
+ try {
102
+ const { namespace, sha: head } = await repo.headFor({ id: req.userId, email: req.userEmail });
103
+ const ref = req.params.ref;
104
+ // Only THIS person's tree, at its head or a commit behind it: the object
105
+ // store is shared across everyone, so a sha alone must never be enough
106
+ // to read a tree compiled for someone else.
107
+ const sha = ref === 'HEAD' || ref === 'main' ? head : ref;
108
+ if (!(await repo.contains(namespace, sha)))
109
+ return void notFound(res);
110
+ res.status(200);
111
+ res.setHeader('Content-Type', 'application/zip');
112
+ res.setHeader('Content-Disposition', `attachment; filename=${owner}-${repoName}-${sha.slice(0, 7)}.zip`);
113
+ const archive = repo.archiveZip(sha, `${owner}-${repoName}-${sha.slice(0, 7)}`);
114
+ const stderr = [];
115
+ archive.stderr?.on('data', (chunk) => stderr.push(chunk));
116
+ const fail = (reason) => {
117
+ console.error(`[github-facade] zipball ${sha.slice(0, 7)} failed: ${reason}`);
118
+ // Headers are already out once the stream started; the only honest
119
+ // answer then is a cut connection, which the client sees as a failed
120
+ // download rather than a truncated archive it might unpack.
121
+ if (!res.headersSent)
122
+ res.status(500).json({ message: 'Archive failed' });
123
+ else
124
+ res.destroy();
125
+ };
126
+ archive.on('error', (err) => fail(err.message));
127
+ // A client that goes away mid-download must not leave git running —
128
+ // and that kill is the ONE signal exit that is not a failure: git dying
129
+ // to any other signal left a truncated archive on the wire.
130
+ let stopped = false;
131
+ const stop = () => {
132
+ if (archive.exitCode === null && !archive.killed) {
133
+ stopped = true;
134
+ archive.kill();
135
+ }
136
+ };
137
+ archive.on('close', (code, signal) => {
138
+ if (code === 0 || stopped)
139
+ return;
140
+ fail(`git archive exited ${code ?? `on ${signal}`}: ${Buffer.concat(stderr).toString().trim()}`);
141
+ });
142
+ req.on('aborted', stop);
143
+ res.on('close', stop);
144
+ archive.stdout.pipe(res);
145
+ }
146
+ catch (err) {
147
+ answerError(res, err);
148
+ }
149
+ });
150
+ api.use((_req, res) => notFound(res));
151
+ router.use('/api/v3', api);
152
+ return router;
153
+ }
154
+ function bearerOf(req) {
155
+ const header = req.headers.authorization;
156
+ if (!header)
157
+ return null;
158
+ const [scheme, ...rest] = header.split(' ');
159
+ if (!scheme || !/^(bearer|token)$/i.test(scheme))
160
+ return null;
161
+ return rest.join(' ').trim() || null;
162
+ }
163
+ function unauthorized(res) {
164
+ res.setHeader('WWW-Authenticate', 'Bearer realm="hexis-marketplace"');
165
+ res.status(401).json({ message: 'Bad credentials' });
166
+ }
167
+ /** The token endpoint's reply, in the encoding the client asked for. */
168
+ function negotiated(req, res, status, payload) {
169
+ const accept = req.headers.accept ?? '';
170
+ const wantsForm = accept.includes('application/x-www-form-urlencoded') && !accept.includes('json');
171
+ res.status(status);
172
+ if (wantsForm) {
173
+ res.type('application/x-www-form-urlencoded').send(new URLSearchParams(payload).toString());
174
+ return;
175
+ }
176
+ res.json(payload);
177
+ }
178
+ function answerError(res, err) {
179
+ if (err instanceof GitHubFacadeRequestError) {
180
+ res.status(err.status).json({ message: err.message });
181
+ return;
182
+ }
183
+ console.error('[github-facade]', err);
184
+ res.status(500).json({ message: 'Internal error' });
185
+ }
186
+ /** A repository as GitHub describes one — the fields a marketplace sync reads. */
187
+ function repositoryBody(fullName, owner, name, origin) {
188
+ const html = `${origin}/${fullName}`;
189
+ return {
190
+ id: 1,
191
+ node_id: 'R_hexis_marketplace',
192
+ name,
193
+ full_name: fullName,
194
+ private: true,
195
+ owner: { login: owner, id: 1, type: 'Organization' },
196
+ html_url: html,
197
+ description: 'The skills you may read, compiled as native plugins.',
198
+ fork: false,
199
+ url: `${origin}/api/v3/repos/${fullName}`,
200
+ clone_url: `${html}.git`,
201
+ default_branch: 'main',
202
+ visibility: 'private',
203
+ archived: false,
204
+ disabled: false,
205
+ permissions: { admin: false, maintain: false, push: false, triage: false, pull: true },
206
+ };
207
+ }
208
+ function commitBody(commit, fullName, origin) {
209
+ const base = `${origin}/api/v3/repos/${fullName}`;
210
+ const who = { name: commit.authorName, email: commit.authorEmail, date: commit.date };
211
+ return {
212
+ sha: commit.sha,
213
+ node_id: `C_${commit.sha}`,
214
+ commit: {
215
+ author: who,
216
+ committer: who,
217
+ message: commit.message,
218
+ tree: { sha: commit.tree, url: `${base}/git/trees/${commit.tree}` },
219
+ comment_count: 0,
220
+ },
221
+ url: `${base}/commits/${commit.sha}`,
222
+ html_url: `${origin}/${fullName}/commit/${commit.sha}`,
223
+ author: null,
224
+ committer: null,
225
+ parents: [],
226
+ };
227
+ }
228
+ //# sourceMappingURL=github-facade.routes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"github-facade.routes.js","sourceRoot":"","sources":["../../../../src/modules/marketplace/github-facade/github-facade.routes.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAC;AAE9B,OAAO,+BAA+B,CAAC,CAAC,kDAAkD;AAC1F,OAAO,+CAA+C,CAAC,CAAC,sDAAsD;AAG9G,OAAO,EAAE,wBAAwB,EAAqB,MAAM,4BAA4B,CAAC;AAsBzF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,wBAAwB,CAAC,IAA4B;IACnE,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAChC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC;IACrD,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC;IAC9C,MAAM,QAAQ,GAAG,GAAG,KAAK,IAAI,QAAQ,EAAE,CAAC;IAExC,MAAM,CAAC,GAAG,CAAC,wBAAwB,EAAE,KAAK,EAAE,G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