@bevel-software/platform-core-backend 0.20.0 → 0.22.0

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 (666) hide show
  1. package/dist/core/catalog-cache-invalidation.d.ts +7 -2
  2. package/dist/core/catalog-cache-invalidation.d.ts.map +1 -1
  3. package/dist/core/catalog-cache-invalidation.js +8 -9
  4. package/dist/core/catalog-cache-invalidation.js.map +1 -1
  5. package/dist/core/core-ports.d.ts +19 -0
  6. package/dist/core/core-ports.d.ts.map +1 -1
  7. package/dist/core/core-ports.js.map +1 -1
  8. package/dist/core/create-core-server.d.ts +2 -0
  9. package/dist/core/create-core-server.d.ts.map +1 -1
  10. package/dist/core/create-core-server.js +55 -107
  11. package/dist/core/create-core-server.js.map +1 -1
  12. package/dist/core/create-core-services.d.ts +41 -4
  13. package/dist/core/create-core-services.d.ts.map +1 -1
  14. package/dist/core/create-core-services.js +183 -82
  15. package/dist/core/create-core-services.js.map +1 -1
  16. package/dist/core/lifecycle.d.ts +74 -28
  17. package/dist/core/lifecycle.d.ts.map +1 -1
  18. package/dist/core/lifecycle.js +157 -20
  19. package/dist/core/lifecycle.js.map +1 -1
  20. package/dist/core/public-config.d.ts +5 -1
  21. package/dist/core/public-config.d.ts.map +1 -1
  22. package/dist/core/public-config.js +7 -5
  23. package/dist/core/public-config.js.map +1 -1
  24. package/dist/core-config.d.ts +95 -1
  25. package/dist/core-config.d.ts.map +1 -1
  26. package/dist/core-config.js +24 -8
  27. package/dist/core-config.js.map +1 -1
  28. package/dist/index.d.ts +5 -3
  29. package/dist/index.d.ts.map +1 -1
  30. package/dist/index.js +6 -3
  31. package/dist/index.js.map +1 -1
  32. package/dist/modules/access/access-control.service.d.ts +18 -1
  33. package/dist/modules/access/access-control.service.d.ts.map +1 -1
  34. package/dist/modules/access/access-control.service.js +19 -8
  35. package/dist/modules/access/access-control.service.js.map +1 -1
  36. package/dist/modules/access/access-requests.contract.d.ts +75 -0
  37. package/dist/modules/access/access-requests.contract.d.ts.map +1 -0
  38. package/dist/modules/access/access-requests.contract.js +20 -0
  39. package/dist/modules/access/access-requests.contract.js.map +1 -0
  40. package/dist/modules/access/access-requests.routes.d.ts +35 -0
  41. package/dist/modules/access/access-requests.routes.d.ts.map +1 -0
  42. package/dist/modules/access/access-requests.routes.js +237 -0
  43. package/dist/modules/access/access-requests.routes.js.map +1 -0
  44. package/dist/modules/access/access-requests.service.d.ts +123 -0
  45. package/dist/modules/access/access-requests.service.d.ts.map +1 -0
  46. package/dist/modules/access/access-requests.service.js +337 -0
  47. package/dist/modules/access/access-requests.service.js.map +1 -0
  48. package/dist/modules/access/access.routes.d.ts +2 -1
  49. package/dist/modules/access/access.routes.d.ts.map +1 -1
  50. package/dist/modules/access/access.routes.js +10 -10
  51. package/dist/modules/access/access.routes.js.map +1 -1
  52. package/dist/modules/access/change-read-gate.d.ts +6 -3
  53. package/dist/modules/access/change-read-gate.d.ts.map +1 -1
  54. package/dist/modules/access/change-read-gate.js +9 -6
  55. package/dist/modules/access/change-read-gate.js.map +1 -1
  56. package/dist/modules/access/creator-access.d.ts +4 -2
  57. package/dist/modules/access/creator-access.d.ts.map +1 -1
  58. package/dist/modules/access/creator-access.js +7 -4
  59. package/dist/modules/access/creator-access.js.map +1 -1
  60. package/dist/modules/access-model/access-grammar.d.ts +12 -0
  61. package/dist/modules/access-model/access-grammar.d.ts.map +1 -1
  62. package/dist/modules/access-model/access-grammar.js +24 -0
  63. package/dist/modules/access-model/access-grammar.js.map +1 -1
  64. package/dist/modules/agent-instructions/read-preamble.d.ts +2 -1
  65. package/dist/modules/agent-instructions/read-preamble.d.ts.map +1 -1
  66. package/dist/modules/agent-instructions/read-preamble.js +6 -9
  67. package/dist/modules/agent-instructions/read-preamble.js.map +1 -1
  68. package/dist/modules/auth/account-admission.d.ts +40 -0
  69. package/dist/modules/auth/account-admission.d.ts.map +1 -0
  70. package/dist/modules/auth/account-admission.js +17 -0
  71. package/dist/modules/auth/account-admission.js.map +1 -0
  72. package/dist/modules/auth/account.routes.d.ts.map +1 -1
  73. package/dist/modules/auth/account.routes.js +4 -1
  74. package/dist/modules/auth/account.routes.js.map +1 -1
  75. package/dist/modules/auth/auth.service.d.ts +45 -2
  76. package/dist/modules/auth/auth.service.d.ts.map +1 -1
  77. package/dist/modules/auth/auth.service.js +44 -3
  78. package/dist/modules/auth/auth.service.js.map +1 -1
  79. package/dist/modules/auth/oidc-auth-provider.d.ts.map +1 -1
  80. package/dist/modules/auth/oidc-auth-provider.js +9 -0
  81. package/dist/modules/auth/oidc-auth-provider.js.map +1 -1
  82. package/dist/modules/connection-probe/connection-probe.service.d.ts +13 -1
  83. package/dist/modules/connection-probe/connection-probe.service.d.ts.map +1 -1
  84. package/dist/modules/connection-probe/connection-probe.service.js +10 -2
  85. package/dist/modules/connection-probe/connection-probe.service.js.map +1 -1
  86. package/dist/modules/database/advisory-lock.d.ts +17 -0
  87. package/dist/modules/database/advisory-lock.d.ts.map +1 -1
  88. package/dist/modules/database/advisory-lock.js +24 -3
  89. package/dist/modules/database/advisory-lock.js.map +1 -1
  90. package/dist/modules/database/connection.d.ts +67 -2
  91. package/dist/modules/database/connection.d.ts.map +1 -1
  92. package/dist/modules/database/connection.js +118 -12
  93. package/dist/modules/database/connection.js.map +1 -1
  94. package/dist/modules/database/migrate.d.ts +1 -1
  95. package/dist/modules/database/migrate.d.ts.map +1 -1
  96. package/dist/modules/database/migrate.js +27 -3
  97. package/dist/modules/database/migrate.js.map +1 -1
  98. package/dist/modules/github-app/github-app.client.d.ts +101 -0
  99. package/dist/modules/github-app/github-app.client.d.ts.map +1 -0
  100. package/dist/modules/github-app/github-app.client.js +222 -0
  101. package/dist/modules/github-app/github-app.client.js.map +1 -0
  102. package/dist/modules/github-app/github-app.connection.d.ts +102 -0
  103. package/dist/modules/github-app/github-app.connection.d.ts.map +1 -0
  104. package/dist/modules/github-app/github-app.connection.js +185 -0
  105. package/dist/modules/github-app/github-app.connection.js.map +1 -0
  106. package/dist/modules/github-app/github-app.routes.d.ts +59 -0
  107. package/dist/modules/github-app/github-app.routes.d.ts.map +1 -0
  108. package/dist/modules/github-app/github-app.routes.js +323 -0
  109. package/dist/modules/github-app/github-app.routes.js.map +1 -0
  110. package/dist/modules/github-app/index.d.ts +4 -0
  111. package/dist/modules/github-app/index.d.ts.map +1 -0
  112. package/dist/modules/github-app/index.js +4 -0
  113. package/dist/modules/github-app/index.js.map +1 -0
  114. package/dist/modules/kb-fs/branch-name.d.ts +0 -1
  115. package/dist/modules/kb-fs/branch-name.d.ts.map +1 -1
  116. package/dist/modules/kb-fs/branch-name.js +3 -3
  117. package/dist/modules/kb-fs/branch-name.js.map +1 -1
  118. package/dist/modules/kb-fs/clone-config.d.ts +9 -8
  119. package/dist/modules/kb-fs/clone-config.d.ts.map +1 -1
  120. package/dist/modules/kb-fs/clone-config.js +14 -12
  121. package/dist/modules/kb-fs/clone-config.js.map +1 -1
  122. package/dist/modules/kb-fs/remote-url.d.ts +22 -0
  123. package/dist/modules/kb-fs/remote-url.d.ts.map +1 -0
  124. package/dist/modules/kb-fs/remote-url.js +35 -0
  125. package/dist/modules/kb-fs/remote-url.js.map +1 -0
  126. package/dist/modules/mcp/mcp.service.d.ts +7 -0
  127. package/dist/modules/mcp/mcp.service.d.ts.map +1 -1
  128. package/dist/modules/mcp/mcp.service.js +4 -4
  129. package/dist/modules/mcp/mcp.service.js.map +1 -1
  130. package/dist/modules/plugins/compile/marketplace-compiler.service.d.ts +4 -4
  131. package/dist/modules/plugins/compile/marketplace-compiler.service.d.ts.map +1 -1
  132. package/dist/modules/plugins/compile/marketplace-compiler.service.js +7 -10
  133. package/dist/modules/plugins/compile/marketplace-compiler.service.js.map +1 -1
  134. package/dist/modules/plugins/discovery/bundle-dialect/bundle.source.d.ts +4 -1
  135. package/dist/modules/plugins/discovery/bundle-dialect/bundle.source.d.ts.map +1 -1
  136. package/dist/modules/plugins/discovery/bundle-dialect/bundle.source.js +5 -3
  137. package/dist/modules/plugins/discovery/bundle-dialect/bundle.source.js.map +1 -1
  138. package/dist/modules/plugins/discovery/kb-plugin-source.d.ts +6 -1
  139. package/dist/modules/plugins/discovery/kb-plugin-source.d.ts.map +1 -1
  140. package/dist/modules/plugins/discovery/kb-plugin-source.js +14 -9
  141. package/dist/modules/plugins/discovery/kb-plugin-source.js.map +1 -1
  142. package/dist/modules/plugins/discovery/native.source.d.ts +4 -1
  143. package/dist/modules/plugins/discovery/native.source.d.ts.map +1 -1
  144. package/dist/modules/plugins/discovery/native.source.js +4 -2
  145. package/dist/modules/plugins/discovery/native.source.js.map +1 -1
  146. package/dist/modules/plugins/index.d.ts +1 -1
  147. package/dist/modules/plugins/index.d.ts.map +1 -1
  148. package/dist/modules/plugins/index.js +1 -1
  149. package/dist/modules/plugins/index.js.map +1 -1
  150. package/dist/modules/plugins/join-proposals.d.ts +17 -5
  151. package/dist/modules/plugins/join-proposals.d.ts.map +1 -1
  152. package/dist/modules/plugins/join-proposals.js +76 -22
  153. package/dist/modules/plugins/join-proposals.js.map +1 -1
  154. package/dist/modules/plugins/join-request-jobs.service.d.ts +3 -1
  155. package/dist/modules/plugins/join-request-jobs.service.d.ts.map +1 -1
  156. package/dist/modules/plugins/join-request-jobs.service.js +6 -6
  157. package/dist/modules/plugins/join-request-jobs.service.js.map +1 -1
  158. package/dist/modules/plugins/join-requests.service.d.ts +113 -18
  159. package/dist/modules/plugins/join-requests.service.d.ts.map +1 -1
  160. package/dist/modules/plugins/join-requests.service.js +178 -33
  161. package/dist/modules/plugins/join-requests.service.js.map +1 -1
  162. package/dist/modules/plugins/plugin-links.d.ts +65 -10
  163. package/dist/modules/plugins/plugin-links.d.ts.map +1 -1
  164. package/dist/modules/plugins/plugin-links.js +136 -31
  165. package/dist/modules/plugins/plugin-links.js.map +1 -1
  166. package/dist/modules/plugins/plugin-links.service.d.ts +107 -5
  167. package/dist/modules/plugins/plugin-links.service.d.ts.map +1 -1
  168. package/dist/modules/plugins/plugin-links.service.js +151 -21
  169. package/dist/modules/plugins/plugin-links.service.js.map +1 -1
  170. package/dist/modules/plugins/plugin-provision.service.d.ts +10 -3
  171. package/dist/modules/plugins/plugin-provision.service.d.ts.map +1 -1
  172. package/dist/modules/plugins/plugin-provision.service.js +33 -26
  173. package/dist/modules/plugins/plugin-provision.service.js.map +1 -1
  174. package/dist/modules/plugins/plugin-rename.service.d.ts +4 -2
  175. package/dist/modules/plugins/plugin-rename.service.d.ts.map +1 -1
  176. package/dist/modules/plugins/plugin-rename.service.js +10 -12
  177. package/dist/modules/plugins/plugin-rename.service.js.map +1 -1
  178. package/dist/modules/plugins/plugins.routes.d.ts +3 -0
  179. package/dist/modules/plugins/plugins.routes.d.ts.map +1 -1
  180. package/dist/modules/plugins/plugins.routes.js +48 -17
  181. package/dist/modules/plugins/plugins.routes.js.map +1 -1
  182. package/dist/modules/plugins/plugins.service.d.ts +4 -4
  183. package/dist/modules/plugins/plugins.service.d.ts.map +1 -1
  184. package/dist/modules/plugins/plugins.service.js +7 -10
  185. package/dist/modules/plugins/plugins.service.js.map +1 -1
  186. package/dist/modules/plugins/teams.routes.d.ts +4 -1
  187. package/dist/modules/plugins/teams.routes.d.ts.map +1 -1
  188. package/dist/modules/plugins/teams.routes.js +11 -9
  189. package/dist/modules/plugins/teams.routes.js.map +1 -1
  190. package/dist/modules/secrets-vault/index.d.ts +1 -1
  191. package/dist/modules/secrets-vault/index.d.ts.map +1 -1
  192. package/dist/modules/secrets-vault/index.js +1 -1
  193. package/dist/modules/secrets-vault/index.js.map +1 -1
  194. package/dist/modules/secrets-vault/secrets-variable-loader.d.ts +29 -11
  195. package/dist/modules/secrets-vault/secrets-variable-loader.d.ts.map +1 -1
  196. package/dist/modules/secrets-vault/secrets-variable-loader.js +46 -21
  197. package/dist/modules/secrets-vault/secrets-variable-loader.js.map +1 -1
  198. package/dist/modules/secrets-vault/secrets-vault.routes.d.ts +3 -0
  199. package/dist/modules/secrets-vault/secrets-vault.routes.d.ts.map +1 -1
  200. package/dist/modules/secrets-vault/secrets-vault.routes.js +4 -6
  201. package/dist/modules/secrets-vault/secrets-vault.routes.js.map +1 -1
  202. package/dist/modules/settings/deployment-settings.service.d.ts +34 -9
  203. package/dist/modules/settings/deployment-settings.service.d.ts.map +1 -1
  204. package/dist/modules/settings/deployment-settings.service.js +113 -26
  205. package/dist/modules/settings/deployment-settings.service.js.map +1 -1
  206. package/dist/modules/settings/managed-repository.d.ts +43 -0
  207. package/dist/modules/settings/managed-repository.d.ts.map +1 -0
  208. package/dist/modules/settings/managed-repository.js +60 -0
  209. package/dist/modules/settings/managed-repository.js.map +1 -0
  210. package/dist/modules/settings/repository-source.d.ts +128 -0
  211. package/dist/modules/settings/repository-source.d.ts.map +1 -0
  212. package/dist/modules/settings/repository-source.js +150 -0
  213. package/dist/modules/settings/repository-source.js.map +1 -0
  214. package/dist/modules/settings/setup.routes.d.ts +34 -4
  215. package/dist/modules/settings/setup.routes.d.ts.map +1 -1
  216. package/dist/modules/settings/setup.routes.js +198 -18
  217. package/dist/modules/settings/setup.routes.js.map +1 -1
  218. package/dist/modules/skills/allowed-tools-check.d.ts +4 -3
  219. package/dist/modules/skills/allowed-tools-check.d.ts.map +1 -1
  220. package/dist/modules/skills/allowed-tools-check.js +8 -8
  221. package/dist/modules/skills/allowed-tools-check.js.map +1 -1
  222. package/dist/modules/skills/pending-skills.service.d.ts +3 -1
  223. package/dist/modules/skills/pending-skills.service.d.ts.map +1 -1
  224. package/dist/modules/skills/pending-skills.service.js +9 -6
  225. package/dist/modules/skills/pending-skills.service.js.map +1 -1
  226. package/dist/modules/skills/skill-access-requests.routes.d.ts +8 -9
  227. package/dist/modules/skills/skill-access-requests.routes.d.ts.map +1 -1
  228. package/dist/modules/skills/skill-access-requests.routes.js +26 -65
  229. package/dist/modules/skills/skill-access-requests.routes.js.map +1 -1
  230. package/dist/modules/skills/skills.routes.d.ts +4 -1
  231. package/dist/modules/skills/skills.routes.d.ts.map +1 -1
  232. package/dist/modules/skills/skills.routes.js +4 -4
  233. package/dist/modules/skills/skills.routes.js.map +1 -1
  234. package/dist/modules/skills/skills.service.d.ts +4 -2
  235. package/dist/modules/skills/skills.service.d.ts.map +1 -1
  236. package/dist/modules/skills/skills.service.js +13 -11
  237. package/dist/modules/skills/skills.service.js.map +1 -1
  238. package/dist/modules/tool-helpers/tool-context.d.ts.map +1 -1
  239. package/dist/modules/tool-helpers/tool-context.js +15 -0
  240. package/dist/modules/tool-helpers/tool-context.js.map +1 -1
  241. package/dist/modules/tool-manuals/mcp-json-discovery.d.ts +2 -1
  242. package/dist/modules/tool-manuals/mcp-json-discovery.d.ts.map +1 -1
  243. package/dist/modules/tool-manuals/mcp-json-discovery.js +6 -5
  244. package/dist/modules/tool-manuals/mcp-json-discovery.js.map +1 -1
  245. package/dist/modules/tool-manuals/mcp-server-edit.service.d.ts +4 -2
  246. package/dist/modules/tool-manuals/mcp-server-edit.service.d.ts.map +1 -1
  247. package/dist/modules/tool-manuals/mcp-server-edit.service.js +12 -10
  248. package/dist/modules/tool-manuals/mcp-server-edit.service.js.map +1 -1
  249. package/dist/modules/tool-manuals/pending-tools.service.d.ts +3 -1
  250. package/dist/modules/tool-manuals/pending-tools.service.d.ts.map +1 -1
  251. package/dist/modules/tool-manuals/pending-tools.service.js +19 -16
  252. package/dist/modules/tool-manuals/pending-tools.service.js.map +1 -1
  253. package/dist/modules/tool-manuals/tool-delete.service.d.ts +4 -2
  254. package/dist/modules/tool-manuals/tool-delete.service.d.ts.map +1 -1
  255. package/dist/modules/tool-manuals/tool-delete.service.js +14 -12
  256. package/dist/modules/tool-manuals/tool-delete.service.js.map +1 -1
  257. package/dist/modules/tool-manuals/tool-manuals.routes.d.ts +3 -1
  258. package/dist/modules/tool-manuals/tool-manuals.routes.d.ts.map +1 -1
  259. package/dist/modules/tool-manuals/tool-manuals.routes.js +7 -7
  260. package/dist/modules/tool-manuals/tool-manuals.routes.js.map +1 -1
  261. package/dist/modules/tool-manuals/tool-manuals.service.d.ts +4 -2
  262. package/dist/modules/tool-manuals/tool-manuals.service.d.ts.map +1 -1
  263. package/dist/modules/tool-manuals/tool-manuals.service.js +15 -12
  264. package/dist/modules/tool-manuals/tool-manuals.service.js.map +1 -1
  265. package/dist/modules/tool-manuals/tool-manuals.tools.d.ts +3 -0
  266. package/dist/modules/tool-manuals/tool-manuals.tools.d.ts.map +1 -1
  267. package/dist/modules/tool-manuals/tool-manuals.tools.js +4 -6
  268. package/dist/modules/tool-manuals/tool-manuals.tools.js.map +1 -1
  269. package/dist/modules/workflow/agent-tools/workflow.tools.d.ts +3 -2
  270. package/dist/modules/workflow/agent-tools/workflow.tools.d.ts.map +1 -1
  271. package/dist/modules/workflow/agent-tools/workflow.tools.js +47 -11
  272. package/dist/modules/workflow/agent-tools/workflow.tools.js.map +1 -1
  273. package/dist/modules/workflow/git/git.service.d.ts +14 -6
  274. package/dist/modules/workflow/git/git.service.d.ts.map +1 -1
  275. package/dist/modules/workflow/git/git.service.js +40 -18
  276. package/dist/modules/workflow/git/git.service.js.map +1 -1
  277. package/dist/modules/workflow/git/node-git-runner.d.ts +26 -2
  278. package/dist/modules/workflow/git/node-git-runner.d.ts.map +1 -1
  279. package/dist/modules/workflow/git/node-git-runner.js +40 -5
  280. package/dist/modules/workflow/git/node-git-runner.js.map +1 -1
  281. package/dist/modules/workflow/git/pull-request.service.d.ts +45 -0
  282. package/dist/modules/workflow/git/pull-request.service.d.ts.map +1 -1
  283. package/dist/modules/workflow/git/pull-request.service.js +99 -0
  284. package/dist/modules/workflow/git/pull-request.service.js.map +1 -1
  285. package/dist/modules/workflow/review-workflow/review-workflow.service.d.ts.map +1 -1
  286. package/dist/modules/workflow/review-workflow/review-workflow.service.js +9 -4
  287. package/dist/modules/workflow/review-workflow/review-workflow.service.js.map +1 -1
  288. package/dist/modules/workflow/session-ontology.service.d.ts +6 -1
  289. package/dist/modules/workflow/session-ontology.service.d.ts.map +1 -1
  290. package/dist/modules/workflow/session-ontology.service.js +6 -2
  291. package/dist/modules/workflow/session-ontology.service.js.map +1 -1
  292. package/dist/modules/workflow/workflow.routes.d.ts.map +1 -1
  293. package/dist/modules/workflow/workflow.routes.js +3 -1
  294. package/dist/modules/workflow/workflow.routes.js.map +1 -1
  295. package/dist/modules/workflow/workflow.service.d.ts +42 -10
  296. package/dist/modules/workflow/workflow.service.d.ts.map +1 -1
  297. package/dist/modules/workflow/workflow.service.js +181 -71
  298. package/dist/modules/workflow/workflow.service.js.map +1 -1
  299. package/dist/modules/workspace/session-ontology.gate.d.ts +3 -1
  300. package/dist/modules/workspace/session-ontology.gate.d.ts.map +1 -1
  301. package/dist/modules/workspace/session-ontology.gate.js +3 -3
  302. package/dist/modules/workspace/session-ontology.gate.js.map +1 -1
  303. package/dist/modules/workspace/startup/kb-git.d.ts +4 -3
  304. package/dist/modules/workspace/startup/kb-git.d.ts.map +1 -1
  305. package/dist/modules/workspace/startup/kb-git.js +15 -13
  306. package/dist/modules/workspace/startup/kb-git.js.map +1 -1
  307. package/dist/modules/workspace/startup/kb-startup-runner.d.ts +70 -7
  308. package/dist/modules/workspace/startup/kb-startup-runner.d.ts.map +1 -1
  309. package/dist/modules/workspace/startup/kb-startup-runner.js +183 -38
  310. package/dist/modules/workspace/startup/kb-startup-runner.js.map +1 -1
  311. package/dist/modules/workspace/startup/steps/groups-to-plugins.step.d.ts +7 -1
  312. package/dist/modules/workspace/startup/steps/groups-to-plugins.step.d.ts.map +1 -1
  313. package/dist/modules/workspace/startup/steps/groups-to-plugins.step.js +23 -16
  314. package/dist/modules/workspace/startup/steps/groups-to-plugins.step.js.map +1 -1
  315. package/dist/modules/workspace/startup/steps/personal-spaces.step.d.ts +7 -1
  316. package/dist/modules/workspace/startup/steps/personal-spaces.step.d.ts.map +1 -1
  317. package/dist/modules/workspace/startup/steps/personal-spaces.step.js +12 -5
  318. package/dist/modules/workspace/startup/steps/personal-spaces.step.js.map +1 -1
  319. package/dist/modules/workspace/startup/steps/plugin-display-names.step.d.ts +7 -1
  320. package/dist/modules/workspace/startup/steps/plugin-display-names.step.d.ts.map +1 -1
  321. package/dist/modules/workspace/startup/steps/plugin-display-names.step.js +12 -5
  322. package/dist/modules/workspace/startup/steps/plugin-display-names.step.js.map +1 -1
  323. package/dist/modules/workspace/startup/steps/plugin-manifests.step.d.ts +7 -1
  324. package/dist/modules/workspace/startup/steps/plugin-manifests.step.d.ts.map +1 -1
  325. package/dist/modules/workspace/startup/steps/plugin-manifests.step.js +12 -5
  326. package/dist/modules/workspace/startup/steps/plugin-manifests.step.js.map +1 -1
  327. package/dist/modules/workspace/startup/steps/seed-tree.d.ts +4 -1
  328. package/dist/modules/workspace/startup/steps/seed-tree.d.ts.map +1 -1
  329. package/dist/modules/workspace/startup/steps/seed-tree.js +14 -11
  330. package/dist/modules/workspace/startup/steps/seed-tree.js.map +1 -1
  331. package/dist/modules/workspace/startup/steps/template-files.step.d.ts +17 -3
  332. package/dist/modules/workspace/startup/steps/template-files.step.d.ts.map +1 -1
  333. package/dist/modules/workspace/startup/steps/template-files.step.js +36 -30
  334. package/dist/modules/workspace/startup/steps/template-files.step.js.map +1 -1
  335. package/dist/modules/workspace/startup/steps/template-source.d.ts +6 -1
  336. package/dist/modules/workspace/startup/steps/template-source.d.ts.map +1 -1
  337. package/dist/modules/workspace/startup/steps/template-source.js +10 -6
  338. package/dist/modules/workspace/startup/steps/template-source.js.map +1 -1
  339. package/dist/modules/workspace/workspace.routes.d.ts +2 -1
  340. package/dist/modules/workspace/workspace.routes.d.ts.map +1 -1
  341. package/dist/modules/workspace/workspace.routes.js +8 -7
  342. package/dist/modules/workspace/workspace.routes.js.map +1 -1
  343. package/dist/modules/workspace/workspace.service.d.ts +18 -12
  344. package/dist/modules/workspace/workspace.service.d.ts.map +1 -1
  345. package/dist/modules/workspace/workspace.service.js +49 -29
  346. package/dist/modules/workspace/workspace.service.js.map +1 -1
  347. package/dist/modules/workspace/workspace.tools.d.ts +2 -1
  348. package/dist/modules/workspace/workspace.tools.d.ts.map +1 -1
  349. package/dist/modules/workspace/workspace.tools.js +48 -20
  350. package/dist/modules/workspace/workspace.tools.js.map +1 -1
  351. package/dist/modules/workspace/write-denial.d.ts +3 -2
  352. package/dist/modules/workspace/write-denial.d.ts.map +1 -1
  353. package/dist/modules/workspace/write-denial.js +6 -5
  354. package/dist/modules/workspace/write-denial.js.map +1 -1
  355. package/dist/shared/domain-errors.d.ts +39 -0
  356. package/dist/shared/domain-errors.d.ts.map +1 -1
  357. package/dist/shared/domain-errors.js +55 -0
  358. package/dist/shared/domain-errors.js.map +1 -1
  359. package/dist/shared/git.contract.d.ts +62 -7
  360. package/dist/shared/git.contract.d.ts.map +1 -1
  361. package/dist/shared/git.contract.js +30 -8
  362. package/dist/shared/git.contract.js.map +1 -1
  363. package/dist/shared/kb-context.d.ts +76 -0
  364. package/dist/shared/kb-context.d.ts.map +1 -0
  365. package/dist/shared/kb-context.js +108 -0
  366. package/dist/shared/kb-context.js.map +1 -0
  367. package/dist/shared/kb-layout.d.ts +3 -2
  368. package/dist/shared/kb-layout.d.ts.map +1 -1
  369. package/dist/shared/kb-layout.js +4 -3
  370. package/dist/shared/kb-layout.js.map +1 -1
  371. package/dist/shared/kb-layout.test.js +35 -27
  372. package/dist/shared/kb-layout.test.js.map +1 -1
  373. package/dist/shared/pending-proposals.d.ts +4 -1
  374. package/dist/shared/pending-proposals.d.ts.map +1 -1
  375. package/dist/shared/pending-proposals.js +3 -4
  376. package/dist/shared/pending-proposals.js.map +1 -1
  377. package/dist/shared/redact-secret.d.ts +5 -5
  378. package/dist/shared/redact-secret.js +5 -5
  379. package/dist/tenancy/index.d.ts +13 -0
  380. package/dist/tenancy/index.d.ts.map +1 -0
  381. package/dist/tenancy/index.js +13 -0
  382. package/dist/tenancy/index.js.map +1 -0
  383. package/dist/tenancy/static-tenant-source.d.ts +98 -0
  384. package/dist/tenancy/static-tenant-source.d.ts.map +1 -0
  385. package/dist/tenancy/static-tenant-source.js +220 -0
  386. package/dist/tenancy/static-tenant-source.js.map +1 -0
  387. package/dist/tenancy/tenant-host.d.ts +80 -0
  388. package/dist/tenancy/tenant-host.d.ts.map +1 -0
  389. package/dist/tenancy/tenant-host.js +217 -0
  390. package/dist/tenancy/tenant-host.js.map +1 -0
  391. package/dist/tenancy/tenant-runtime.d.ts +91 -0
  392. package/dist/tenancy/tenant-runtime.d.ts.map +1 -0
  393. package/dist/tenancy/tenant-runtime.js +174 -0
  394. package/dist/tenancy/tenant-runtime.js.map +1 -0
  395. package/dist/tenancy/tenant-secrets.d.ts +24 -0
  396. package/dist/tenancy/tenant-secrets.d.ts.map +1 -0
  397. package/dist/tenancy/tenant-secrets.js +30 -0
  398. package/dist/tenancy/tenant-secrets.js.map +1 -0
  399. package/dist/tenancy/tenant-source.contract.d.ts +45 -0
  400. package/dist/tenancy/tenant-source.contract.d.ts.map +1 -0
  401. package/dist/tenancy/tenant-source.contract.js +21 -0
  402. package/dist/tenancy/tenant-source.contract.js.map +1 -0
  403. package/migrations/0000_core_init.sql +14 -14
  404. package/migrations/0003_deployment_settings.sql +1 -1
  405. package/migrations/0005_github_facade.sql +1 -1
  406. package/migrations/0012_agent_audit.sql +6 -6
  407. package/package.json +3 -3
  408. package/src/__tests__/branch-model.test.ts +7 -6
  409. package/src/__tests__/kb-context.ts +30 -0
  410. package/src/__tests__/kb-layout-config.test.ts +35 -30
  411. package/src/core/__tests__/catalog-cache-invalidation.test.ts +2 -1
  412. package/src/core/__tests__/lifecycle.test.ts +78 -1
  413. package/src/core/__tests__/public-config.test.ts +5 -1
  414. package/src/core/catalog-cache-invalidation.ts +16 -11
  415. package/src/core/core-ports.ts +19 -0
  416. package/src/core/create-core-server.ts +64 -107
  417. package/src/core/create-core-services.ts +238 -96
  418. package/src/core/lifecycle.ts +214 -29
  419. package/src/core/public-config.ts +8 -5
  420. package/src/core-config.ts +107 -8
  421. package/src/index.ts +25 -2
  422. package/src/modules/access/__tests__/access-control.admin-root-floor.test.ts +2 -1
  423. package/src/modules/access/__tests__/access-requests.recut.test.ts +134 -0
  424. package/src/modules/access/__tests__/access-requests.routes.test.ts +610 -0
  425. package/src/modules/access/__tests__/access.routes.batch.test.ts +2 -1
  426. package/src/modules/access/__tests__/access.routes.folder-governs.test.ts +2 -1
  427. package/src/modules/access/__tests__/access.routes.group-grant.test.ts +2 -1
  428. package/src/modules/access/__tests__/access.routes.overrides.test.ts +2 -1
  429. package/src/modules/access/__tests__/access.routes.proposal-branch.test.ts +2 -1
  430. package/src/modules/access/__tests__/access.routes.prospective.test.ts +2 -1
  431. package/src/modules/access/__tests__/access.routes.revoke.test.ts +2 -1
  432. package/src/modules/access/__tests__/access.routes.unknown-email.test.ts +2 -1
  433. package/src/modules/access/__tests__/change-read-gate.test.ts +13 -11
  434. package/src/modules/access/__tests__/creator-access.test.ts +3 -2
  435. package/src/modules/access/__tests__/roles.routes.test.ts +2 -1
  436. package/src/modules/access/access-control.service.ts +20 -6
  437. package/src/modules/access/access-requests.contract.ts +93 -0
  438. package/src/modules/access/access-requests.routes.ts +286 -0
  439. package/src/modules/access/access-requests.service.ts +420 -0
  440. package/src/modules/access/access.routes.ts +10 -13
  441. package/src/modules/access/change-read-gate.ts +10 -4
  442. package/src/modules/access/creator-access.ts +7 -2
  443. package/src/modules/access-model/access-grammar.ts +22 -0
  444. package/src/modules/agent-instructions/__tests__/read-preamble.test.ts +13 -12
  445. package/src/modules/agent-instructions/read-preamble.ts +10 -12
  446. package/src/modules/auth/__tests__/account.routes.test.ts +15 -0
  447. package/src/modules/auth/__tests__/auth.service.test.ts +98 -0
  448. package/src/modules/auth/account-admission.ts +44 -0
  449. package/src/modules/auth/account.routes.ts +4 -1
  450. package/src/modules/auth/auth.service.ts +61 -2
  451. package/src/modules/auth/oidc-auth-provider.ts +9 -0
  452. package/src/modules/connection-probe/connection-probe.service.ts +7 -1
  453. package/src/modules/database/__tests__/advisory-lock.test.ts +23 -1
  454. package/src/modules/database/__tests__/connection.test.ts +98 -0
  455. package/src/modules/database/__tests__/migrations-unqualified.test.ts +32 -0
  456. package/src/modules/database/advisory-lock.ts +28 -4
  457. package/src/modules/database/connection.ts +143 -13
  458. package/src/modules/database/migrate.ts +48 -14
  459. package/src/modules/diff/__tests__/diff.service.seed-atomicity.test.ts +2 -1
  460. package/src/modules/diff/__tests__/diff.service.test.ts +2 -1
  461. package/src/modules/github-app/__tests__/github-app.test.ts +848 -0
  462. package/src/modules/github-app/github-app.client.ts +268 -0
  463. package/src/modules/github-app/github-app.connection.ts +204 -0
  464. package/src/modules/github-app/github-app.routes.ts +359 -0
  465. package/src/modules/github-app/index.ts +19 -0
  466. package/src/modules/kb-fs/__tests__/branch-name.test.ts +6 -6
  467. package/src/modules/kb-fs/__tests__/clone-config.test.ts +24 -20
  468. package/src/modules/kb-fs/__tests__/remote-url.test.ts +38 -0
  469. package/src/modules/kb-fs/branch-name.ts +3 -3
  470. package/src/modules/kb-fs/clone-config.ts +15 -12
  471. package/src/modules/kb-fs/remote-url.ts +35 -0
  472. package/src/modules/marketplace/__tests__/marketplace-repo.head.test.ts +2 -1
  473. package/src/modules/mcp/mcp.service.ts +11 -4
  474. package/src/modules/plugins/__tests__/bundle-dialect.e2e.test.ts +12 -11
  475. package/src/modules/plugins/__tests__/bundle-dialect.test.ts +2 -1
  476. package/src/modules/plugins/__tests__/compile-marketplace.test.ts +6 -4
  477. package/src/modules/plugins/__tests__/join-proposals.test.ts +100 -19
  478. package/src/modules/plugins/__tests__/join-request-jobs.service.test.ts +2 -1
  479. package/src/modules/plugins/__tests__/join-requests.service.test.ts +28 -11
  480. package/src/modules/plugins/__tests__/join-requests.settlement.test.ts +371 -0
  481. package/src/modules/plugins/__tests__/plugin-creation-display-name.test.ts +4 -3
  482. package/src/modules/plugins/__tests__/plugin-index.service.test.ts +6 -4
  483. package/src/modules/plugins/__tests__/plugin-links.service.test.ts +220 -5
  484. package/src/modules/plugins/__tests__/plugin-provision.service.test.ts +3 -1
  485. package/src/modules/plugins/__tests__/plugin-rename.service.test.ts +7 -6
  486. package/src/modules/plugins/__tests__/plugins.routes.test.ts +12 -3
  487. package/src/modules/plugins/__tests__/teams.routes.test.ts +2 -1
  488. package/src/modules/plugins/compile/marketplace-compiler.service.ts +7 -9
  489. package/src/modules/plugins/discovery/__tests__/kb-plugin-source.test.ts +20 -16
  490. package/src/modules/plugins/discovery/bundle-dialect/bundle.source.ts +9 -2
  491. package/src/modules/plugins/discovery/kb-plugin-source.ts +15 -8
  492. package/src/modules/plugins/discovery/native.source.ts +4 -1
  493. package/src/modules/plugins/index.ts +1 -1
  494. package/src/modules/plugins/join-proposals.ts +87 -19
  495. package/src/modules/plugins/join-request-jobs.service.ts +8 -7
  496. package/src/modules/plugins/join-requests.service.ts +203 -43
  497. package/src/modules/plugins/plugin-links.service.ts +192 -19
  498. package/src/modules/plugins/plugin-links.ts +147 -27
  499. package/src/modules/plugins/plugin-provision.service.ts +54 -27
  500. package/src/modules/plugins/plugin-rename.service.ts +10 -10
  501. package/src/modules/plugins/plugins.routes.ts +48 -17
  502. package/src/modules/plugins/plugins.service.ts +7 -11
  503. package/src/modules/plugins/teams.routes.ts +16 -8
  504. package/src/modules/secrets-vault/__tests__/connect-pending.route.test.ts +7 -0
  505. package/src/modules/secrets-vault/__tests__/secrets-variable-loader.test.ts +40 -0
  506. package/src/modules/secrets-vault/__tests__/tool-owner-gate.route.test.ts +2 -0
  507. package/src/modules/secrets-vault/index.ts +2 -0
  508. package/src/modules/secrets-vault/secrets-variable-loader.ts +51 -21
  509. package/src/modules/secrets-vault/secrets-vault.routes.ts +7 -6
  510. package/src/modules/settings/__tests__/deployment-settings.service.test.ts +24 -11
  511. package/src/modules/settings/__tests__/git-root-folders.test.ts +2 -1
  512. package/src/modules/settings/__tests__/repository-source.test.ts +191 -0
  513. package/src/modules/settings/__tests__/setup.routes.boot-failure.test.ts +2 -1
  514. package/src/modules/settings/__tests__/setup.routes.git-mode.test.ts +353 -0
  515. package/src/modules/settings/__tests__/setup.routes.github-app.test.ts +282 -0
  516. package/src/modules/settings/__tests__/setup.routes.layout-phase.test.ts +7 -4
  517. package/src/modules/settings/__tests__/setup.routes.managed-phase.test.ts +233 -0
  518. package/src/modules/settings/__tests__/setup.routes.oidc.test.ts +2 -0
  519. package/src/modules/settings/__tests__/setup.routes.sync-status.test.ts +2 -0
  520. package/src/modules/settings/__tests__/setup.routes.test.ts +33 -52
  521. package/src/modules/settings/deployment-settings.service.ts +130 -23
  522. package/src/modules/settings/managed-repository.ts +68 -0
  523. package/src/modules/settings/repository-source.ts +197 -0
  524. package/src/modules/settings/setup.routes.ts +233 -19
  525. package/src/modules/skills/__tests__/allowed-tools-check.test.ts +11 -10
  526. package/src/modules/skills/__tests__/allowed-tools-warn.tools.test.ts +4 -3
  527. package/src/modules/skills/__tests__/pending-skills.service.test.ts +3 -1
  528. package/src/modules/skills/__tests__/skill-access-requests.routes.test.ts +7 -2
  529. package/src/modules/skills/__tests__/skills.routes.warnings.test.ts +2 -1
  530. package/src/modules/skills/__tests__/skills.service.test.ts +3 -2
  531. package/src/modules/skills/allowed-tools-check.ts +7 -6
  532. package/src/modules/skills/pending-skills.service.ts +9 -8
  533. package/src/modules/skills/skill-access-requests.routes.ts +29 -79
  534. package/src/modules/skills/skills.routes.ts +4 -3
  535. package/src/modules/skills/skills.service.ts +13 -9
  536. package/src/modules/tool-helpers/__tests__/agent-roles-write.test.ts +3 -2
  537. package/src/modules/tool-helpers/__tests__/phase4-tools.test.ts +3 -2
  538. package/src/modules/tool-helpers/tool-context.ts +15 -0
  539. package/src/modules/tool-manuals/__tests__/mcp-json-discovery.test.ts +17 -12
  540. package/src/modules/tool-manuals/__tests__/mcp-server-edit.service.test.ts +2 -1
  541. package/src/modules/tool-manuals/__tests__/pending-tools.service.test.ts +4 -1
  542. package/src/modules/tool-manuals/__tests__/tool-delete.service.test.ts +2 -1
  543. package/src/modules/tool-manuals/__tests__/tool-manuals.archive.route.test.ts +2 -1
  544. package/src/modules/tool-manuals/__tests__/tool-manuals.cli.test.ts +5 -4
  545. package/src/modules/tool-manuals/__tests__/tool-manuals.detail.route.test.ts +2 -1
  546. package/src/modules/tool-manuals/__tests__/tool-manuals.invalid.routes.test.ts +4 -2
  547. package/src/modules/tool-manuals/__tests__/tool-manuals.invalid.test.ts +13 -5
  548. package/src/modules/tool-manuals/__tests__/tool-manuals.mcp-oauth.test.ts +2 -1
  549. package/src/modules/tool-manuals/__tests__/tool-manuals.restart.test.ts +9 -1
  550. package/src/modules/tool-manuals/__tests__/tool-manuals.service.test.ts +3 -2
  551. package/src/modules/tool-manuals/__tests__/tool-manuals.tools.test.ts +2 -0
  552. package/src/modules/tool-manuals/mcp-json-discovery.ts +6 -4
  553. package/src/modules/tool-manuals/mcp-server-edit.service.ts +13 -11
  554. package/src/modules/tool-manuals/pending-tools.service.ts +19 -16
  555. package/src/modules/tool-manuals/tool-delete.service.ts +13 -10
  556. package/src/modules/tool-manuals/tool-manuals.routes.ts +10 -8
  557. package/src/modules/tool-manuals/tool-manuals.service.ts +15 -13
  558. package/src/modules/tool-manuals/tool-manuals.tools.ts +7 -6
  559. package/src/modules/workflow/__tests__/apply-failure.test.ts +11 -2
  560. package/src/modules/workflow/__tests__/merge-announces-tree.test.ts +14 -26
  561. package/src/modules/workflow/__tests__/preserve-roles-yaml.test.ts +2 -1
  562. package/src/modules/workflow/__tests__/session-ontology.service.test.ts +3 -2
  563. package/src/modules/workflow/__tests__/workflow.routes.lock-path.test.ts +2 -1
  564. package/src/modules/workflow/__tests__/workflow.service.branch-in-use.test.ts +3 -10
  565. package/src/modules/workflow/__tests__/workflow.service.commitFileWhileLocked.test.ts +2 -1
  566. package/src/modules/workflow/__tests__/workflow.service.deleted-branch-sweep.test.ts +3 -10
  567. package/src/modules/workflow/__tests__/workflow.service.facade.test.ts +187 -35
  568. package/src/modules/workflow/__tests__/workflow.service.folder-proposals.test.ts +2 -1
  569. package/src/modules/workflow/__tests__/workflow.service.platform-restore.test.ts +2 -1
  570. package/src/modules/workflow/__tests__/workflow.service.read-gate.test.ts +3 -2
  571. package/src/modules/workflow/__tests__/workflow.service.releaseLock.test.ts +2 -1
  572. package/src/modules/workflow/__tests__/workflow.service.sync.test.ts +5 -4
  573. package/src/modules/workflow/__tests__/workflow.service.update-from-target.test.ts +148 -41
  574. package/src/modules/workflow/agent-tools/__tests__/workflow.tools.test.ts +143 -2
  575. package/src/modules/workflow/agent-tools/workflow.tools.ts +60 -12
  576. package/src/modules/workflow/git/__tests__/git.service.accessGating.test.ts +5 -4
  577. package/src/modules/workflow/git/__tests__/git.service.changedFilesForPr.test.ts +12 -11
  578. package/src/modules/workflow/git/__tests__/git.service.commitChanges.test.ts +9 -8
  579. package/src/modules/workflow/git/__tests__/git.service.commitFile.strayPath.test.ts +8 -7
  580. package/src/modules/workflow/git/__tests__/git.service.commitFile.test.ts +6 -5
  581. package/src/modules/workflow/git/__tests__/git.service.createBranch.test.ts +3 -2
  582. package/src/modules/workflow/git/__tests__/git.service.deleteBranch.test.ts +3 -2
  583. package/src/modules/workflow/git/__tests__/git.service.diffFileAtCommit.test.ts +7 -6
  584. package/src/modules/workflow/git/__tests__/git.service.diffFileBetweenBranches.test.ts +16 -15
  585. package/src/modules/workflow/git/__tests__/git.service.fileContentsAtCommit.test.ts +3 -2
  586. package/src/modules/workflow/git/__tests__/git.service.forkPoint.test.ts +2 -1
  587. package/src/modules/workflow/git/__tests__/git.service.history-guards.test.ts +2 -1
  588. package/src/modules/workflow/git/__tests__/git.service.list-branches.test.ts +10 -9
  589. package/src/modules/workflow/git/__tests__/git.service.listTrackedFiles.test.ts +2 -1
  590. package/src/modules/workflow/git/__tests__/git.service.logForFile.test.ts +6 -5
  591. package/src/modules/workflow/git/__tests__/git.service.mergeChangeRequest.test.ts +9 -8
  592. package/src/modules/workflow/git/__tests__/git.service.pendingChanges.test.ts +2 -1
  593. package/src/modules/workflow/git/__tests__/git.service.postMergePull.test.ts +4 -3
  594. package/src/modules/workflow/git/__tests__/git.service.pull.test.ts +130 -8
  595. package/src/modules/workflow/git/__tests__/git.service.readFileAtRef.test.ts +2 -1
  596. package/src/modules/workflow/git/__tests__/git.service.revertPathsAndPush.test.ts +2 -1
  597. package/src/modules/workflow/git/__tests__/git.service.status.test.ts +4 -3
  598. package/src/modules/workflow/git/__tests__/git.service.syncFromRemote.test.ts +8 -7
  599. package/src/modules/workflow/git/__tests__/node-git-runner.test.ts +41 -3
  600. package/src/modules/workflow/git/__tests__/pull-request.service.getPrDetail.test.ts +145 -2
  601. package/src/modules/workflow/git/__tests__/pull-request.service.viewer-can-delete.test.ts +166 -0
  602. package/src/modules/workflow/git/git.service.ts +49 -17
  603. package/src/modules/workflow/git/node-git-runner.ts +43 -4
  604. package/src/modules/workflow/git/pull-request.service.ts +119 -0
  605. package/src/modules/workflow/review-workflow/review-workflow.service.ts +9 -6
  606. package/src/modules/workflow/session-ontology.service.ts +7 -2
  607. package/src/modules/workflow/workflow.routes.ts +3 -1
  608. package/src/modules/workflow/workflow.service.ts +201 -76
  609. package/src/modules/workspace/__tests__/file-stat-access.test.ts +3 -2
  610. package/src/modules/workspace/__tests__/git-internals.security.test.ts +10 -9
  611. package/src/modules/workspace/__tests__/session-ontology.gate.test.ts +4 -2
  612. package/src/modules/workspace/__tests__/workspace-paths-inside-the-repo.test.ts +3 -2
  613. package/src/modules/workspace/__tests__/workspace.routes.branch-errors.test.ts +2 -1
  614. package/src/modules/workspace/__tests__/workspace.routes.create-grant.test.ts +2 -1
  615. package/src/modules/workspace/__tests__/workspace.routes.delete.test.ts +2 -1
  616. package/src/modules/workspace/__tests__/workspace.routes.download-implies-read.test.ts +2 -1
  617. package/src/modules/workspace/__tests__/workspace.routes.download.test.ts +2 -1
  618. package/src/modules/workspace/__tests__/workspace.routes.file-writes.test.ts +2 -1
  619. package/src/modules/workspace/__tests__/workspace.routes.folders.test.ts +5 -4
  620. package/src/modules/workspace/__tests__/workspace.routes.move-platform-files.test.ts +2 -1
  621. package/src/modules/workspace/__tests__/workspace.routes.read-gate.test.ts +2 -1
  622. package/src/modules/workspace/__tests__/workspace.service.ensure-remotes-fetched.test.ts +2 -2
  623. package/src/modules/workspace/__tests__/workspace.service.list-cloned.test.ts +6 -5
  624. package/src/modules/workspace/__tests__/workspace.service.move-never-overwrites.test.ts +2 -1
  625. package/src/modules/workspace/__tests__/workspace.service.read-filter.test.ts +2 -1
  626. package/src/modules/workspace/__tests__/workspace.service.test.ts +84 -50
  627. package/src/modules/workspace/__tests__/workspace.service.unknown-branch.test.ts +45 -1
  628. package/src/modules/workspace/__tests__/workspace.tools.agents-file.test.ts +10 -7
  629. package/src/modules/workspace/__tests__/workspace.tools.branch-errors.test.ts +237 -10
  630. package/src/modules/workspace/__tests__/workspace.tools.test.ts +44 -11
  631. package/src/modules/workspace/__tests__/write-denial.test.ts +5 -4
  632. package/src/modules/workspace/session-ontology.gate.ts +6 -4
  633. package/src/modules/workspace/startup/__tests__/kb-startup-runner.degraded.test.ts +6 -2
  634. package/src/modules/workspace/startup/__tests__/kb-startup-runner.test.ts +240 -21
  635. package/src/modules/workspace/startup/kb-git.ts +15 -22
  636. package/src/modules/workspace/startup/kb-startup-runner.ts +198 -45
  637. package/src/modules/workspace/startup/steps/__tests__/steps.test.ts +104 -98
  638. package/src/modules/workspace/startup/steps/groups-to-plugins.step.ts +24 -16
  639. package/src/modules/workspace/startup/steps/personal-spaces.step.ts +14 -5
  640. package/src/modules/workspace/startup/steps/plugin-display-names.step.ts +13 -5
  641. package/src/modules/workspace/startup/steps/plugin-manifests.step.ts +14 -5
  642. package/src/modules/workspace/startup/steps/seed-tree.ts +11 -9
  643. package/src/modules/workspace/startup/steps/template-files.step.ts +43 -34
  644. package/src/modules/workspace/startup/steps/template-source.ts +8 -5
  645. package/src/modules/workspace/workspace.routes.ts +8 -7
  646. package/src/modules/workspace/workspace.service.ts +47 -28
  647. package/src/modules/workspace/workspace.tools.ts +56 -20
  648. package/src/modules/workspace/write-denial.ts +7 -5
  649. package/src/shared/__tests__/kb-layout.plugin.test.ts +19 -16
  650. package/src/shared/domain-errors.ts +58 -0
  651. package/src/shared/git.contract.ts +80 -8
  652. package/src/shared/kb-context.ts +130 -0
  653. package/src/shared/kb-layout.test.ts +37 -27
  654. package/src/shared/kb-layout.ts +4 -3
  655. package/src/shared/pending-proposals.ts +7 -4
  656. package/src/shared/redact-secret.ts +5 -5
  657. package/src/tenancy/__tests__/static-tenant-source.test.ts +177 -0
  658. package/src/tenancy/__tests__/tenant-host.test.ts +372 -0
  659. package/src/tenancy/__tests__/tenant-runtime.test.ts +221 -0
  660. package/src/tenancy/__tests__/tenant-secrets.test.ts +35 -0
  661. package/src/tenancy/index.ts +35 -0
  662. package/src/tenancy/static-tenant-source.ts +296 -0
  663. package/src/tenancy/tenant-host.ts +261 -0
  664. package/src/tenancy/tenant-runtime.ts +208 -0
  665. package/src/tenancy/tenant-secrets.ts +41 -0
  666. package/src/tenancy/tenant-source.contract.ts +59 -0
@@ -2,14 +2,16 @@ import path from 'node:path';
2
2
  import { logger } from '../shared/logging.js';
3
3
  import type { AuthProviderPlugin } from '../modules/auth/auth.routes.js';
4
4
  import type { AuthUser } from '@bevel-software/platform-shared';
5
- import {
6
- DEFAULT_BRANCH,
7
- configureBranchModel,
8
- validateBranchModel,
9
- PROTECTED_BRANCHES,
10
- configureKbLayout,
11
- } from '@bevel-software/platform-shared';
12
- import { CoreConfig } from '../core-config.js';
5
+ // The browser-side live bindings, imported here and nowhere else in this
6
+ // package: `mirrorSharedBindings` below keeps them in step with `kb` for an
7
+ // overlay that still reads them. Core's own modules read only `KbContext`.
8
+ // eslint-disable-next-line no-restricted-imports
9
+ import { configureBranchModel, configureKbLayout } from '@bevel-software/platform-shared';
10
+ import type { TenantConfig } from '../core-config.js';
11
+ import { sql } from 'drizzle-orm';
12
+ import { DEFAULT_DB_SCHEMA, assertSearchPath } from '../modules/database/connection.js';
13
+ import { DEFAULT_SECRETS_SCOPE } from '../modules/secrets-vault/secrets-variable-loader.js';
14
+ import { KbContext } from '../shared/kb-context.js';
13
15
  import { getDb, type Database } from '../modules/database/connection.js';
14
16
  import { runCoreMigrations } from '../modules/database/migrate.js';
15
17
  import { coreMigrationsDir } from '../assets.js';
@@ -29,6 +31,9 @@ import { NodeFs } from '../modules/kb-fs/node-fs.js';
29
31
  import { assertKbDirNameFree } from '../modules/kb-fs/repo-path.js';
30
32
  import type { IFsProbe, ITreeWalker } from '../shared/fs.contract.js';
31
33
  import type { IGitRunner } from '../shared/git.contract.js';
34
+ import { ManagedRepository, MANAGED_DEFAULT_BRANCH } from '../modules/settings/managed-repository.js';
35
+ import { RepositorySource } from '../modules/settings/repository-source.js';
36
+ import { GitHubAppConnection } from '../modules/github-app/index.js';
32
37
  import { AdvisoryLease, AdvisoryLock } from '../modules/database/advisory-lock.js';
33
38
  import { holdCommitWorkerLease, withStartupTask, type LeaseLoopHandle } from './lifecycle.js';
34
39
 
@@ -155,7 +160,7 @@ import { registerCatalogCacheInvalidation } from './catalog-cache-invalidation.j
155
160
  * core services to construct). See {@link CorePorts} for the pattern.
156
161
  */
157
162
  export interface CoreServices {
158
- config: CoreConfig;
163
+ config: TenantConfig;
159
164
  db: Database;
160
165
  /**
161
166
  * Reading the disk without locks — the one tree walk and the one path
@@ -184,6 +189,29 @@ export interface CoreServices {
184
189
  * first-time setup completion — and never again while the process serves.
185
190
  */
186
191
  kbStartupRunner: KbStartupRunner;
192
+ /**
193
+ * Where the knowledge base's repository is and what git presents to it,
194
+ * whichever way the deployment was given one (see `RepositorySource`).
195
+ */
196
+ repositorySource: RepositorySource;
197
+ /** The repository the deployment keeps for itself, when that is the way it chose. */
198
+ managedRepository: ManagedRepository;
199
+ /** The connection to GitHub through a GitHub App, when that is the way it chose. */
200
+ githubApp: GitHubAppConnection;
201
+ /**
202
+ * The startup phase's retry when the boot survived an unreachable remote
203
+ * — set by `startCore`, stopped by `stopCore` (see `core/lifecycle.ts`);
204
+ * null while nothing is asking.
205
+ */
206
+ startupRetry: { stop(): void } | null;
207
+ /**
208
+ * What tells this graph's locks, migration ledger and secrets scope apart
209
+ * from another graph's in the same process and database: the schema name,
210
+ * or `''` for the default schema (the single-tenant ids).
211
+ */
212
+ tenantKey: string;
213
+ /** The scope this graph's vault is registered under with the UTCP variable loader. */
214
+ secretsScope: string;
187
215
  spillStore: SpillStore;
188
216
  docExtractService: DocExtractService;
189
217
  accessControl: AccessControlService;
@@ -264,12 +292,20 @@ export interface CoreServices {
264
292
  updateCheckService: UpdateCheckService;
265
293
  /** Deployment settings, env-first — the KB remote resolves through these. */
266
294
  settings: DeploymentSettingsService;
295
+ /**
296
+ * The knowledge base as this composition names it: the checkout folder,
297
+ * the branch model and the layout — the one object every core service reads
298
+ * those from (see `shared/kb-context.ts`). The setup-completing save applies
299
+ * the branch model and the layout to it, so an overlay reads the answer in
300
+ * effect here rather than from the shared package's live bindings.
301
+ */
302
+ kb: KbContext;
267
303
  /**
268
304
  * The knowledge-base directory name IN EFFECT — environment first, then the
269
305
  * stored setting, then the default. Published here because `config.kbDirName`
270
306
  * is only the environment's half of that answer: reading it directly gives
271
307
  * the empty string on any deployment configured through the setup screen, and
272
- * every path built from it would be wrong.
308
+ * every path built from it would be wrong. The same value as `kb.kbDirName`.
273
309
  */
274
310
  kbDirName: string;
275
311
  secretsVaultService: DbSecretsVaultService;
@@ -301,14 +337,28 @@ export interface CoreServices {
301
337
  }
302
338
 
303
339
  export async function createCoreServices(
304
- config: CoreConfig,
340
+ config: TenantConfig,
305
341
  ports: CorePorts = {},
306
342
  ): Promise<CoreServices> {
307
343
  // Fail fast on a runtime whose git is too old for `--no-write-fetch-head`
308
344
  // (see `git-version.ts`): every clone, fetch and refresh below depends on it,
309
345
  // so an unsupported binary is better surfaced here than at the first merge.
310
346
  await assertGitVersion();
311
- const db = getDb(config.databaseUrl);
347
+ // What tells this knowledge base's locks, migration ledger and secrets
348
+ // loader apart from another's in the same process and database. Empty for
349
+ // the default schema, so a single-tenant deployment keeps the lock ids and
350
+ // the ledger it always had.
351
+ const tenantKey = config.dbSchema === DEFAULT_DB_SCHEMA ? '' : config.dbSchema;
352
+ const db = getDb(config.databaseUrl, { schema: config.dbSchema });
353
+ // A schema of its own is created on first use, so a tenant's first
354
+ // activation needs nothing done by hand; `public` always exists. Then the
355
+ // server is asked whether the connections really search that schema: a
356
+ // pooler that dropped the startup parameter would otherwise land every
357
+ // tenant's tables in `public`, silently — see `assertSearchPath`.
358
+ if (tenantKey) {
359
+ await db.execute(sql.raw(`create schema if not exists "${config.dbSchema}"`));
360
+ await assertSearchPath(db, config.dbSchema);
361
+ }
312
362
  // Migrations must run BEFORE any service that reads or writes a managed
313
363
  // table. `PendingCommitsService.startupReconcile` (called later in this
314
364
  // function) hits `pending_commits` — on a fresh DB, deferring migrations to
@@ -325,40 +375,13 @@ export async function createCoreServices(
325
375
  // is resolved through them, and a fresh install has none of it in the
326
376
  // environment. `load()` is env-first, so an existing deployment sees exactly
327
377
  // what it saw before — a stored row only answers where a variable is silent.
328
- const settings = new DeploymentSettingsService(db, config.secretsEncKey);
378
+ const settings = new DeploymentSettingsService(db, config.secretsEncKey, undefined, { env: config.settingsEnv });
329
379
  await settings.load();
330
380
 
331
- /**
332
- * The branch model, before anything reads it. It used to be applied at import
333
- * time from the environment, which is what forced the frontend to bake it
334
- * into its bundle; it now comes through the settings store like the rest of
335
- * the deployment's configuration (environment first, as always).
336
- *
337
- * UNCONFIGURED IS ALLOWED, and that is the point: a fresh deployment has no
338
- * branch model, and refusing to boot would take away the setup screen where
339
- * one gets entered. What reads it before then is the setup path itself, which
340
- * does not need it — the bootstrap admin is recognised without a workspace.
341
- * `isComplete` keeps the rest of the app behind the gate until it is set, and
342
- * the setting is restart-to-apply because services take the value at
343
- * construction.
344
- */
345
- const branchModel = {
346
- defaultBranch: settings.resolve('defaultBranch'),
347
- protectedBranches: settings.resolve('protectedBranches'),
348
- };
349
- if (!validateBranchModel(branchModel)) configureBranchModel(branchModel);
350
381
  // The layout variables that were retired this release, folded into their
351
382
  // saved settings before anything reads the layout — so the boot that imports
352
383
  // them also RUNS on the imported names rather than on the defaults.
353
384
  await settings.importLegacyLayoutEnv();
354
- // The KB layout — the three renameable roots and the agent guide's file name
355
- // — applied the same way and at the same moment, before any service captures
356
- // one of them. Unlike the branch model it always resolves (every name has a
357
- // default), so an invalid value is a real misconfiguration and stops the boot.
358
- configureKbLayout(settings.resolveKbLayout());
359
- // A token supplied through the setup screen has to reach the credential
360
- // helper, which reads `$GITHUB_TOKEN` at call time.
361
- settings.syncGitTokenEnv();
362
385
 
363
386
  // `kbDirName` is read ONCE and threaded into a dozen services as a plain
364
387
  // string, which is why changing it needs a restart (the setting says so).
@@ -370,19 +393,104 @@ export async function createCoreServices(
370
393
  // unnameable. Both are operator settings, so the collision is refused here,
371
394
  // by name, before any service captures either.
372
395
  assertKbDirNameFree(kbDirName, settings.resolveKbLayout());
396
+ /**
397
+ * The knowledge base's context — the checkout folder, the branch model and
398
+ * the layout — built before any service, and handed to each one that reads
399
+ * a name from it (see `shared/kb-context.ts`). The values come through the
400
+ * settings store like the rest of the deployment's configuration
401
+ * (environment first, as always).
402
+ *
403
+ * The branch model: UNCONFIGURED IS ALLOWED, and that is the point. A fresh
404
+ * deployment has no branch model, and refusing to boot would take away the
405
+ * setup screen where one gets entered. What reads it before then is the
406
+ * setup path itself, which does not need it — the bootstrap admin is
407
+ * recognised without a workspace. `isComplete` keeps the rest of the app
408
+ * behind the gate until it is set, and the save that completes setup applies
409
+ * it to this very object, which every service reads at use rather than
410
+ * capturing at construction.
411
+ *
412
+ * The layout — the three renameable roots and the agent guide's file name —
413
+ * always resolves (every name has a default), so an invalid value is a real
414
+ * misconfiguration and stops the boot.
415
+ */
416
+ const kb = new KbContext(
417
+ kbDirName,
418
+ KbContext.branchModelOrUnconfigured({
419
+ defaultBranch: settings.resolve('defaultBranch'),
420
+ protectedBranches: settings.resolve('protectedBranches'),
421
+ }),
422
+ settings.resolveKbLayout(),
423
+ );
424
+ // The shared package's process-wide live bindings, kept in step with `kb`
425
+ // for an overlay that still reads them — now, and again when the setup-
426
+ // completing save applies a model or a layout. Nothing in this package
427
+ // reads them; a host serving several knowledge bases turns this off.
428
+ if (ports.mirrorSharedBindings !== false) {
429
+ const mirrorBranchModel = () => {
430
+ if (kb.isBranchModelConfigured()) {
431
+ configureBranchModel({ defaultBranch: kb.defaultBranch, protectedBranches: [...kb.protectedBranches] });
432
+ }
433
+ };
434
+ const mirrorLayout = () => configureKbLayout(kb.layout);
435
+ mirrorBranchModel();
436
+ mirrorLayout();
437
+ kb.onBranchModelApplied(mirrorBranchModel);
438
+ kb.onLayoutApplied(mirrorLayout);
439
+ }
373
440
  // The disk: one walk, one probe, for every reader below.
374
441
  const disk = new NodeFs();
442
+ // What git authenticates with, read on every call: the username and token
443
+ // the setup screen stored, or the environment's. Environment first for the
444
+ // token, as for every setting (`resolve` is env-first); the legacy
445
+ // `GITHUB_TOKEN` / `GH_TOKEN` spellings only through `config`, since the
446
+ // settings catalogue knows `GIT_TOKEN` alone. Handed to the runner, which
447
+ // puts the token into each child's environment — never into this
448
+ // process's, which several knowledge bases may share.
449
+ //
450
+ // Both come from the repository source, which is the one place that knows
451
+ // a deployment can be given its repository in more than one way; what
452
+ // comes back is the address and the credential, as it always was.
453
+ const managedRepository = new ManagedRepository(path.join(config.backupsRoot, 'managed-repository'));
454
+ const githubApp = new GitHubAppConnection({
455
+ read: (key) => settings.resolve(key),
456
+ sourceOf: (key) => settings.sourceOf(key),
457
+ });
458
+ const repositorySource = new RepositorySource({
459
+ read: (key) => settings.resolve(key),
460
+ fallback: { username: config.gitUsername, token: config.gitToken },
461
+ managed: managedRepository,
462
+ githubApp,
463
+ });
464
+ const gitCredentialsInEffect = repositorySource.credentials;
375
465
  // How git is run, for every module that runs it: one environment, one buffer
376
466
  // ceiling, one error shape, and — the reason it exists — one deadline, so a
377
467
  // git that never returns cannot hold a workspace (and with it the commit
378
468
  // queue) open indefinitely. See `shared/git.contract.ts`.
379
- const gitRunner = new NodeGitRunner(config.gitTimeoutMs);
469
+ const gitRunner = new NodeGitRunner(config.gitTimeoutMs, gitCredentialsInEffect);
470
+ // A deployment that keeps its own repository has it before anything asks
471
+ // for it: one that chose the mode through the environment never passes
472
+ // through the save that would have created it, and the startup phase's
473
+ // first question would be asked of a folder that is not there. Left to
474
+ // that phase to report if it cannot be made: its failures are classified
475
+ // and shown on the setup screen, where a throw here would take the screen
476
+ // down with the boot.
477
+ if (repositorySource.mode() === 'managed') {
478
+ await managedRepository
479
+ .ensure(gitRunner, settings.resolve('defaultBranch') || MANAGED_DEFAULT_BRANCH)
480
+ .catch((err: unknown) => logger('setup').error('the managed repository could not be created:', { err }));
481
+ }
482
+ // One reached through a GitHub App has a token in hand before anything
483
+ // reads it: a working copy's credential helper is stamped according to
484
+ // whether there is a token, by code that cannot wait for one. A failure is
485
+ // the startup phase's to report, for the same reason as above.
486
+ if (repositorySource.mode() === 'github-app') {
487
+ await githubApp.prepare().catch(() => undefined);
488
+ }
380
489
  const workspaceService = new WorkspaceService(
381
490
  config.workspacesRoot,
382
- () => settings.resolve('kbRepoUrl'),
383
- kbDirName,
491
+ () => repositorySource.url(),
492
+ kb,
384
493
  disk,
385
- () => settings.resolve('gitUsername') || 'x-access-token',
386
494
  gitRunner,
387
495
  );
388
496
  // The KB startup phase: every seeding, scaffolding and migration concern,
@@ -400,18 +508,18 @@ export async function createCoreServices(
400
508
  // read-only, needs no remote, and must be said even on a deployment whose
401
509
  // setup never finished — so `noteBesideCheckout` runs once from the server
402
510
  // builder, ahead of this gated phase.)
403
- new GroupsToPluginsStep(disk),
404
- new PluginManifestsStep(disk),
511
+ new GroupsToPluginsStep(disk, kb),
512
+ new PluginManifestsStep(disk, kb),
405
513
  // After the manifests step: a folder that only just got its manifest got
406
514
  // one the renderer wrote, which already carries the display name — the
407
515
  // backfill then has nothing to do for it. Ordered the other way, the
408
516
  // backfill would walk a tree still missing those manifests.
409
- new PluginDisplayNamesStep(disk),
410
- new PersonalSpacesStep(disk),
517
+ new PluginDisplayNamesStep(disk, kb),
518
+ new PersonalSpacesStep(disk, kb),
411
519
  // A getter, not a value: the step is built here, while the process may
412
520
  // still hold the defaults, and the save that completes first-run setup
413
521
  // applies the admin's answer afterwards.
414
- new TemplateFilesStep(disk, extraDirs, () => settings.resolveAgentsFileLink()),
522
+ new TemplateFilesStep(disk, kb, extraDirs, () => settings.resolveAgentsFileLink()),
415
523
  new RolesYamlStep(disk, [config.adminEmail]),
416
524
  ...(ports.kbStartupSteps ?? []),
417
525
  ];
@@ -419,19 +527,21 @@ export async function createCoreServices(
419
527
  // Getters, not values: the remote and the branch model can arrive from the
420
528
  // setup screen after this object exists, and the setup-completion run is
421
529
  // the first thing that needs them.
422
- kbRepoUrl: () => settings.resolve('kbRepoUrl'),
423
- gitUsername: () => settings.resolve('gitUsername') || 'x-access-token',
424
- gitToken: () => settings.resolve('gitToken'),
530
+ kbRepoUrl: () => repositorySource.url(),
425
531
  workspacesRoot: config.workspacesRoot,
532
+ // Under the backups root, a persistent volume of its own and one nothing
533
+ // sweeps: a working copy of a repository that was replaced is kept there,
534
+ // never deleted (see the runner's `reconcileClonesWithConfiguredRepository`).
535
+ setAsideRoot: path.join(config.backupsRoot, 'replaced-working-copies'),
426
536
  kbDirName,
427
537
  templateDir: config.kbTemplateDir,
428
- defaultBranch: () => DEFAULT_BRANCH,
429
- protectedBranches: () => [...PROTECTED_BRANCHES],
538
+ defaultBranch: () => kb.defaultBranch,
539
+ protectedBranches: () => [...kb.protectedBranches],
430
540
  // The deployment owner is the initial Admin of a freshly seeded KB — the
431
541
  // same answer `SEED_ADMIN_EMAILS` used to ask for a second time.
432
542
  seedAdminEmails: [config.adminEmail],
433
543
  steps: kbStartupSteps,
434
- buildSeedTree: buildSeedTree(disk, config.kbTemplateDir, extraDirs, [config.adminEmail]),
544
+ buildSeedTree: buildSeedTree(disk, config.kbTemplateDir, extraDirs, [config.adminEmail], kb),
435
545
  gitRunner,
436
546
  });
437
547
  // Shared, workspace-independent store for oversized `call_tool_chain` results,
@@ -452,49 +562,50 @@ export async function createCoreServices(
452
562
  disk,
453
563
  [config.adminEmail],
454
564
  gitRunner,
565
+ kb,
455
566
  );
456
567
  // Creator read-grant on creation: read is default-deny and the roots grant
457
568
  // it to nobody, so every surface that starts a new folder at a root (human
458
569
  // routes, agent tools, upload apply) consults this planner to keep the new
459
570
  // folder visible to its creator.
460
- const creatorAccess = new CreatorAccessService(workspaceService, accessControl, kbDirName, disk);
571
+ const creatorAccess = new CreatorAccessService(workspaceService, accessControl, kb, disk);
461
572
  // Read-before-write: the gate every lock acquire asks, on every branch —
462
573
  // nothing is created, changed or removed where its author cannot read,
463
574
  // except that new folder at a root (see `access-model/change-gate.ts`).
464
- const changeGate = new ChangeReadGate(workspaceService, accessControl, kbDirName, disk);
575
+ const changeGate = new ChangeReadGate(workspaceService, accessControl, kb, disk);
465
576
 
466
577
  // Ontology-session boundary: records each agent run's touched ontologies and
467
578
  // blocks writes once a run has crossed ontologies. Postgres-backed so the
468
579
  // boundary survives a restart.
469
- const sessionOntologyService = new SessionOntologyService(db);
580
+ const sessionOntologyService = new SessionOntologyService(db, kb);
470
581
  // Per-run write restriction (by file extension). Shared by the workspace tool
471
582
  // surface (which enforces it) and the routine runner (which sets it for
472
583
  // dashboard-only `watchlist_check` runs). In-memory: a restriction lives only for
473
584
  // one run, unlike the Postgres-backed ontology touched-set above.
474
585
  const routineWritePolicy = new RoutineWritePolicyService();
475
586
  // Skills: discovered from the default-branch workspace only (global catalog).
476
- const skillService = new SkillService(workspaceService, accessControl, kbDirName, disk);
587
+ const skillService = new SkillService(workspaceService, accessControl, kb, disk);
477
588
  // Tool manuals: user-authored `*.tool` files under `Plugins/` in the default
478
589
  // branch — access-controlled like Skills, served to external agents via
479
590
  // `GET /api/agent/all-tools` and registered on the MCP proxy's UTCP client.
480
591
  // Where plugins come from: one walk of the plugins root that reads every
481
592
  // plugin folder in whichever file shape it carries (see
482
593
  // modules/plugins/discovery). Nothing to configure, nothing to document.
483
- const pluginSource = new KbPluginSource(disk);
484
- const toolManualService = new ToolManualService(workspaceService, accessControl, kbDirName, disk, pluginSource);
594
+ const pluginSource = new KbPluginSource(disk, kb);
595
+ const toolManualService = new ToolManualService(workspaceService, accessControl, kb, disk, pluginSource);
485
596
  // Plugins: the folders under `Plugins/` that carry a
486
597
  // team's skills AND the tools they need. Enumerated for EVERY authenticated
487
598
  // caller — a plugin they cannot read still exists for them, as a locked one —
488
599
  // with the counts read off the two catalogs above rather than a second scan.
489
600
  // The link index resolves manifests against the released catalog, and the
490
601
  // plugin index counts through it (inline + linked), so it comes first.
491
- const pluginLinkIndex = new PluginLinkIndex(workspaceService, skillService, accessControl, kbDirName, pluginSource);
602
+ const pluginLinkIndex = new PluginLinkIndex(workspaceService, skillService, accessControl, kb, pluginSource);
492
603
  const pluginIndexService = new PluginIndexService(
493
604
  workspaceService,
494
605
  accessControl,
495
606
  skillService,
496
607
  toolManualService,
497
- kbDirName,
608
+ kb,
498
609
  pluginSource,
499
610
  Date.now,
500
611
  pluginLinkIndex,
@@ -504,13 +615,17 @@ export async function createCoreServices(
504
615
  // PullRequestService no longer depends on it for attribution.)
505
616
  // The allow-list is resolved, not read off the environment: it is settable
506
617
  // from the setup screen alongside the SSO configuration it guards.
507
- const authService = new AuthService(db, {
508
- jwtSecret: config.jwtSecret,
509
- adminEmail: config.adminEmail,
510
- adminPassword: config.adminPassword,
511
- allowedEmailDomains: parseDomainList(settings.resolve('allowedEmailDomains')),
512
- loginPasswordEnabled: config.loginPasswordEnabled,
513
- });
618
+ const authService = new AuthService(
619
+ db,
620
+ {
621
+ jwtSecret: config.jwtSecret,
622
+ adminEmail: config.adminEmail,
623
+ adminPassword: config.adminPassword,
624
+ allowedEmailDomains: parseDomainList(settings.resolve('allowedEmailDomains')),
625
+ loginPasswordEnabled: config.loginPasswordEnabled,
626
+ },
627
+ ports.accountAdmission,
628
+ );
514
629
  const authMiddleware = createAuthMiddleware(authService);
515
630
 
516
631
  // Shared mutex so git and diff operations on the same workspace serialize
@@ -526,7 +641,7 @@ export async function createCoreServices(
526
641
  const gitService = new GitService(
527
642
  workspaceService,
528
643
  workflowHooks,
529
- kbDirName,
644
+ kb,
530
645
  workspaceMutex,
531
646
  accessControl,
532
647
  gitRunner,
@@ -611,7 +726,7 @@ export async function createCoreServices(
611
726
  accessControl,
612
727
  fileLockService,
613
728
  pendingCommitsService,
614
- kbDirName,
729
+ kb,
615
730
  changeGate,
616
731
  eventBus,
617
732
  fileChangeNotifier,
@@ -625,7 +740,14 @@ export async function createCoreServices(
625
740
  // (the request's branch vs the default branch), so it holds no state — it
626
741
  // only needs to read files at refs and to close a request whose proposals
627
742
  // have all landed.
628
- const joinRequestsService = new JoinRequestsService(workspaceService, workflowService);
743
+ const joinRequestsService = new JoinRequestsService(
744
+ workspaceService,
745
+ workflowService,
746
+ kb,
747
+ // Read-only: the one question a request asks of the resolver is whether
748
+ // the person it names already holds what it proposes.
749
+ accessControl,
750
+ );
629
751
  // The OTHER half of a join request: the row the subscribe endpoint writes
630
752
  // before it answers, and the branch/clone/commit/push/change-request work
631
753
  // that runs against it afterwards. The row is what lets the click be
@@ -634,7 +756,7 @@ export async function createCoreServices(
634
756
  const pluginJoinRequestJobs = new PluginJoinRequestJobs(new DbJoinRequestStore(db), {
635
757
  workflow: workflowService,
636
758
  workspaceService,
637
- kbDirName,
759
+ kb,
638
760
  // A record keys on the plugin's primary FOLDER below the root, which the
639
761
  // catalog is the only thing that can turn back into a path and a name
640
762
  // people read. Null once nothing answers to the key — a deleted plugin,
@@ -666,7 +788,7 @@ export async function createCoreServices(
666
788
  accessControl,
667
789
  skillService,
668
790
  pluginLinkIndex,
669
- kbDirName,
791
+ kb,
670
792
  eventBus,
671
793
  () => pluginIndexService.invalidate(),
672
794
  );
@@ -678,7 +800,7 @@ export async function createCoreServices(
678
800
  accessControl,
679
801
  pluginSource,
680
802
  disk,
681
- kbDirName,
803
+ kb,
682
804
  eventBus,
683
805
  () => {
684
806
  pluginIndexService.invalidate();
@@ -692,7 +814,7 @@ export async function createCoreServices(
692
814
  accessControl,
693
815
  skillService,
694
816
  pluginLinkIndex,
695
- kbDirName,
817
+ kb,
696
818
  {
697
819
  name: 'hexis',
698
820
  owner: 'Hexis',
@@ -727,7 +849,7 @@ export async function createCoreServices(
727
849
  workflowService,
728
850
  accessControl,
729
851
  toolManualService,
730
- kbDirName,
852
+ kb,
731
853
  disk,
732
854
  );
733
855
 
@@ -739,7 +861,7 @@ export async function createCoreServices(
739
861
  workspaceService,
740
862
  workflowService,
741
863
  accessControl,
742
- kbDirName,
864
+ kb,
743
865
  eventBus,
744
866
  pluginSource,
745
867
  disk,
@@ -755,6 +877,7 @@ export async function createCoreServices(
755
877
  accessControl,
756
878
  skillService,
757
879
  workflowService,
880
+ kb,
758
881
  );
759
882
 
760
883
  // The same missing half, for tools: a `.tool` manual or an `mcp.json` server
@@ -766,6 +889,7 @@ export async function createCoreServices(
766
889
  accessControl,
767
890
  toolManualService,
768
891
  workflowService,
892
+ kb,
769
893
  );
770
894
 
771
895
  // Catalog freshness: the skill / tool-manual / plugin-index caches all scan
@@ -777,7 +901,7 @@ export async function createCoreServices(
777
901
  registerCatalogCacheInvalidation({
778
902
  eventBus,
779
903
  fileChangeNotifier,
780
- kbDirName,
904
+ kb,
781
905
  catalogs: [toolManualService, skillService, pluginIndexService, pluginLinkIndex],
782
906
  accessControl,
783
907
  });
@@ -787,7 +911,7 @@ export async function createCoreServices(
787
911
  const adminAccess = new AdminAccessService(
788
912
  accessControl,
789
913
  workspaceService,
790
- () => DEFAULT_BRANCH,
914
+ () => kb.defaultBranch,
791
915
  // The deployment owner administers accounts/roles even before the KB's
792
916
  // roles.yaml lists them, and whatever the sign-in method — this list is
793
917
  // consulted before any roles.yaml lookup, so it holds for SSO too.
@@ -818,8 +942,11 @@ export async function createCoreServices(
818
942
  (key) => toolManualService.scopeOfVariable(key),
819
943
  );
820
944
  // Register the `bevel-secrets` UTCP variable loader against this vault so any
821
- // UTCP client can resolve `${VAR}` from the caller's secrets at tool-call time.
822
- registerBevelSecretsVariableLoader(secretsVaultService);
945
+ // UTCP client can resolve `${VAR}` from the caller's secrets at tool-call
946
+ // time — under this knowledge base's scope, since the loader registry is
947
+ // UTCP's and process-wide while the vault is this graph's.
948
+ const secretsScope = tenantKey ? `${config.tenantId}/${config.dbSchema}` : DEFAULT_SECRETS_SCOPE;
949
+ registerBevelSecretsVariableLoader(secretsVaultService, secretsScope);
823
950
 
824
951
  // Deleting ONE tool from its page — the owner's verb, the other end of the
825
952
  // promise that made them the owner. Built here because it is the one service
@@ -835,7 +962,7 @@ export async function createCoreServices(
835
962
  pluginIndexService,
836
963
  pluginSource,
837
964
  secretsVaultService,
838
- kbDirName,
965
+ kb,
839
966
  disk,
840
967
  );
841
968
 
@@ -845,7 +972,7 @@ export async function createCoreServices(
845
972
  // call, the vault to resolve the credential to call it with. Holds no state
846
973
  // and takes no `db`: a verdict is returned to the caller that asked for it and
847
974
  // never outlives their page (see `ProbeVerdict`).
848
- const connectionProbeService = new ConnectionProbeService(toolManualService, secretsVaultService);
975
+ const connectionProbeService = new ConnectionProbeService(toolManualService, secretsVaultService, secretsScope);
849
976
 
850
977
  // Zero-config OAuth for bare `type: mcp` `.tool`s: when the remote server
851
978
  // demands OAuth (MCP authorization spec), discover its authorization server,
@@ -917,7 +1044,7 @@ export async function createCoreServices(
917
1044
  // for readers, and the preamble is a broadcast). One reader, two consumers:
918
1045
  // the proxy below composes in-process per request; the agent-facing route
919
1046
  // serves the same composition to the local bridge and the frontend card.
920
- const readPreamble: AgentPreambleReader = () => readAgentPreamble(workspaceService, kbDirName, disk);
1047
+ const readPreamble: AgentPreambleReader = () => readAgentPreamble(workspaceService, kb, disk);
921
1048
  // The Audit log. Records through the proxy below (every call an external
922
1049
  // agent makes), reads keys through the key service so their shape is
923
1050
  // defined once, and prunes past the retention setting — read per sweep, so
@@ -930,7 +1057,7 @@ export async function createCoreServices(
930
1057
  // Loopback to our own REST tool surface — 127.0.0.1 (not localhost) to pin
931
1058
  // IPv4 and dodge resolver ambiguity. The proxy authenticates each call with
932
1059
  // the caller's own connection key.
933
- loopbackBaseUrl: `http://127.0.0.1:${config.port}`,
1060
+ loopbackBaseUrl: config.loopbackBaseUrl ?? `http://127.0.0.1:${config.port}`,
934
1061
  // Manual namespace + UTCP variable prefix (KNOWLEDGE_BASE_API_URL / …).
935
1062
  manualName: 'KNOWLEDGE_BASE',
936
1063
  // Oversized chain results spill here too — an external MCP caller has no
@@ -939,6 +1066,7 @@ export async function createCoreServices(
939
1066
  // For the needs-authorization setup link surfaced to external agents.
940
1067
  publicFrontendUrl: config.publicFrontendUrl,
941
1068
  readAgentPreamble: readPreamble,
1069
+ secretsScope,
942
1070
  },
943
1071
  // Pre-dispatch per-user credential check: the vault answers "has this caller
944
1072
  // set it?" and the manual catalog answers "which user-scoped vars does this
@@ -1060,12 +1188,6 @@ export async function createCoreServices(
1060
1188
  },
1061
1189
  });
1062
1190
  const leased = withStartupTask(pendingCommitsWorker, reconcileQueue);
1063
- // Not `start()`: the worker runs only while this process holds the
1064
- // commit-worker lease. On a redeploy the outgoing container still holds it,
1065
- // so this one serves requests and declines to drain until that one exits;
1066
- // then it takes the lease and starts. Two processes draining one shared
1067
- // clone volume is the failure this prevents — see `core/lifecycle.ts`.
1068
- const commitWorker = holdCommitWorkerLease(new AdvisoryLease(db, AdvisoryLock.CommitWorker), leased);
1069
1191
 
1070
1192
  // SSO providers. The array REFERENCE is shared with the caller's port — an
1071
1193
  // overlay pushes its own plugins into it after construction (they mount when
@@ -1112,7 +1234,7 @@ export async function createCoreServices(
1112
1234
  eventBus,
1113
1235
  kbDirName,
1114
1236
  bot,
1115
- defaultBranchOf: () => DEFAULT_BRANCH,
1237
+ defaultBranchOf: () => kb.defaultBranch,
1116
1238
  }),
1117
1239
  debounceMs: opts?.debounceMs,
1118
1240
  log: opts?.log ?? ((message) => logger('directory-sync').warn(message)),
@@ -1126,7 +1248,7 @@ export async function createCoreServices(
1126
1248
  workflowService,
1127
1249
  accessControl,
1128
1250
  kbDirName,
1129
- () => DEFAULT_BRANCH,
1251
+ () => kb.defaultBranch,
1130
1252
  eventBus,
1131
1253
  );
1132
1254
  // Account deletion's optional half: the erased address out of roles.yaml,
@@ -1138,22 +1260,42 @@ export async function createCoreServices(
1138
1260
  accessControl,
1139
1261
  disk,
1140
1262
  kbDirName,
1141
- () => DEFAULT_BRANCH,
1263
+ () => kb.defaultBranch,
1142
1264
  eventBus,
1143
1265
  [config.adminEmail],
1144
1266
  );
1145
1267
 
1268
+ // THE LAST THING STARTED, once everything above is built: the lease loop
1269
+ // is the one piece of this function that keeps running on its own, and a
1270
+ // throw anywhere after it would leave a loop holding — or forever asking
1271
+ // for — this knowledge base's lock with no graph to stop it. Single-tenant
1272
+ // never noticed (the process exited with the throw); a host that retries
1273
+ // an activation would. Not `start()`: the worker runs only while this
1274
+ // process holds the commit-worker lease. On a redeploy the outgoing
1275
+ // container still holds it, so this one serves requests and declines to
1276
+ // drain until that one exits; then it takes the lease and starts. Two
1277
+ // processes draining one shared clone volume is the failure this prevents
1278
+ // — see `core/lifecycle.ts`.
1279
+ const commitWorker = holdCommitWorkerLease(new AdvisoryLease(db, AdvisoryLock.CommitWorker, { tenantKey }), leased);
1280
+
1146
1281
  return {
1147
1282
  config,
1148
1283
  db,
1149
1284
  gitRunner,
1150
1285
  commitWorker,
1286
+ startupRetry: null,
1287
+ tenantKey,
1288
+ secretsScope,
1151
1289
  disk,
1152
1290
  mcpServerEditService,
1153
1291
  toolDeleteService,
1154
1292
  workspaceService,
1155
1293
  kbStartupRunner,
1294
+ repositorySource,
1295
+ managedRepository,
1296
+ githubApp,
1156
1297
  settings,
1298
+ kb,
1157
1299
  kbDirName,
1158
1300
  spillStore,
1159
1301
  docExtractService,