@bevel-software/platform-core-backend 0.11.1 → 0.12.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 (443) hide show
  1. package/THIRD-PARTY-NOTICES.md +1163 -425
  2. package/dist/core/create-core-server.js +1 -1
  3. package/dist/core/create-core-server.js.map +1 -1
  4. package/dist/core/create-core-services.d.ts +3 -1
  5. package/dist/core/create-core-services.d.ts.map +1 -1
  6. package/dist/core/create-core-services.js +7 -2
  7. package/dist/core/create-core-services.js.map +1 -1
  8. package/dist/core-config.d.ts +7 -0
  9. package/dist/core-config.d.ts.map +1 -1
  10. package/dist/core-config.js +9 -0
  11. package/dist/core-config.js.map +1 -1
  12. package/dist/modules/access/access-control.service.d.ts +1 -253
  13. package/dist/modules/access/access-control.service.d.ts.map +1 -1
  14. package/dist/modules/access/access-control.service.js +3 -632
  15. package/dist/modules/access/access-control.service.js.map +1 -1
  16. package/dist/modules/access/access-declarations.d.ts +2 -2
  17. package/dist/modules/access/access-declarations.d.ts.map +1 -1
  18. package/dist/modules/access/access-declarations.js +2 -2
  19. package/dist/modules/access/access-declarations.js.map +1 -1
  20. package/dist/modules/access/access-mutation.service.d.ts +3 -3
  21. package/dist/modules/access/access-mutation.service.d.ts.map +1 -1
  22. package/dist/modules/access/access-mutation.service.js +3 -3
  23. package/dist/modules/access/access-mutation.service.js.map +1 -1
  24. package/dist/modules/access/access.routes.js +4 -4
  25. package/dist/modules/access/access.routes.js.map +1 -1
  26. package/dist/modules/access/admin-locked-commit.d.ts +2 -2
  27. package/dist/modules/access/admin-locked-commit.d.ts.map +1 -1
  28. package/dist/modules/access/admin-locked-commit.js +2 -2
  29. package/dist/modules/access/admin-locked-commit.js.map +1 -1
  30. package/dist/modules/access/admin-route-helpers.js +1 -1
  31. package/dist/modules/access/admin-route-helpers.js.map +1 -1
  32. package/dist/modules/access/capability-registry.js +1 -1
  33. package/dist/modules/access/capability-registry.js.map +1 -1
  34. package/dist/modules/access/creator-access.d.ts +1 -45
  35. package/dist/modules/access/creator-access.d.ts.map +1 -1
  36. package/dist/modules/access/creator-access.js +4 -24
  37. package/dist/modules/access/creator-access.js.map +1 -1
  38. package/dist/modules/access/groups-admin.routes.js +1 -1
  39. package/dist/modules/access/groups-admin.routes.js.map +1 -1
  40. package/dist/modules/access/groups-admin.service.d.ts +1 -1
  41. package/dist/modules/access/groups-admin.service.d.ts.map +1 -1
  42. package/dist/modules/access/groups-admin.service.js +6 -5
  43. package/dist/modules/access/groups-admin.service.js.map +1 -1
  44. package/dist/modules/access/groups-edit.js +2 -2
  45. package/dist/modules/access/groups-edit.js.map +1 -1
  46. package/dist/modules/access/reference-scan.js +1 -1
  47. package/dist/modules/access/reference-scan.js.map +1 -1
  48. package/dist/modules/access/roles-admin.service.d.ts +1 -1
  49. package/dist/modules/access/roles-admin.service.d.ts.map +1 -1
  50. package/dist/modules/access/roles-admin.service.js +8 -7
  51. package/dist/modules/access/roles-admin.service.js.map +1 -1
  52. package/dist/modules/access/roles-edit.js +1 -1
  53. package/dist/modules/access/roles-edit.js.map +1 -1
  54. package/dist/modules/access/synced-groups-committer.js +4 -4
  55. package/dist/modules/access/synced-groups-committer.js.map +1 -1
  56. package/dist/modules/access/synced-groups-writer.js +2 -2
  57. package/dist/modules/access/synced-groups-writer.js.map +1 -1
  58. package/dist/modules/access-model/access-errors.d.ts +34 -0
  59. package/dist/modules/access-model/access-errors.d.ts.map +1 -0
  60. package/dist/modules/access-model/access-errors.js +40 -0
  61. package/dist/modules/access-model/access-errors.js.map +1 -0
  62. package/dist/modules/access-model/access-grammar.d.ts +266 -0
  63. package/dist/modules/access-model/access-grammar.d.ts.map +1 -0
  64. package/dist/modules/access-model/access-grammar.js +644 -0
  65. package/dist/modules/access-model/access-grammar.js.map +1 -0
  66. package/dist/modules/access-model/access-splice.d.ts +140 -0
  67. package/dist/modules/access-model/access-splice.d.ts.map +1 -0
  68. package/dist/modules/access-model/access-splice.js +389 -0
  69. package/dist/modules/access-model/access-splice.js.map +1 -0
  70. package/dist/modules/access-model/creator.d.ts +54 -0
  71. package/dist/modules/access-model/creator.d.ts.map +1 -0
  72. package/dist/modules/access-model/creator.js +30 -0
  73. package/dist/modules/access-model/creator.js.map +1 -0
  74. package/dist/modules/access-model/group-files.d.ts +83 -0
  75. package/dist/modules/access-model/group-files.d.ts.map +1 -0
  76. package/dist/modules/access-model/group-files.js +167 -0
  77. package/dist/modules/access-model/group-files.js.map +1 -0
  78. package/dist/modules/access-model/kb-read-filter.d.ts +41 -0
  79. package/dist/modules/access-model/kb-read-filter.d.ts.map +1 -0
  80. package/dist/modules/access-model/kb-read-filter.js +60 -0
  81. package/dist/modules/access-model/kb-read-filter.js.map +1 -0
  82. package/dist/modules/access-model/render-roles-yaml.d.ts +22 -0
  83. package/dist/modules/access-model/render-roles-yaml.d.ts.map +1 -0
  84. package/dist/modules/access-model/render-roles-yaml.js +56 -0
  85. package/dist/modules/access-model/render-roles-yaml.js.map +1 -0
  86. package/dist/modules/access-model/roles-yaml-guard.d.ts +56 -0
  87. package/dist/modules/access-model/roles-yaml-guard.d.ts.map +1 -0
  88. package/dist/modules/access-model/roles-yaml-guard.js +79 -0
  89. package/dist/modules/access-model/roles-yaml-guard.js.map +1 -0
  90. package/dist/modules/admin/admin-access.service.d.ts.map +1 -1
  91. package/dist/modules/admin/admin-access.service.js +1 -1
  92. package/dist/modules/admin/admin-access.service.js.map +1 -1
  93. package/dist/modules/code-mode/code-mode.tool.d.ts.map +1 -1
  94. package/dist/modules/code-mode/code-mode.tool.js +7 -1
  95. package/dist/modules/code-mode/code-mode.tool.js.map +1 -1
  96. package/dist/modules/diff/diff.routes.js +4 -4
  97. package/dist/modules/diff/diff.routes.js.map +1 -1
  98. package/dist/modules/diff/diff.service.d.ts +1 -1
  99. package/dist/modules/diff/diff.service.d.ts.map +1 -1
  100. package/dist/modules/kb-fs/branch-name.d.ts +10 -0
  101. package/dist/modules/kb-fs/branch-name.d.ts.map +1 -0
  102. package/dist/modules/kb-fs/branch-name.js +76 -0
  103. package/dist/modules/kb-fs/branch-name.js.map +1 -0
  104. package/dist/modules/kb-fs/clone-config.d.ts +61 -0
  105. package/dist/modules/kb-fs/clone-config.d.ts.map +1 -0
  106. package/dist/modules/kb-fs/clone-config.js +69 -0
  107. package/dist/modules/kb-fs/clone-config.js.map +1 -0
  108. package/dist/modules/kb-fs/file-change-notifier.d.ts +38 -0
  109. package/dist/modules/kb-fs/file-change-notifier.d.ts.map +1 -0
  110. package/dist/modules/kb-fs/file-change-notifier.js +22 -0
  111. package/dist/modules/kb-fs/file-change-notifier.js.map +1 -0
  112. package/dist/modules/kb-fs/locking-filesystem.d.ts +137 -0
  113. package/dist/modules/kb-fs/locking-filesystem.d.ts.map +1 -0
  114. package/dist/modules/kb-fs/locking-filesystem.js +553 -0
  115. package/dist/modules/kb-fs/locking-filesystem.js.map +1 -0
  116. package/dist/modules/kb-fs/mutex.d.ts +11 -0
  117. package/dist/modules/kb-fs/mutex.d.ts.map +1 -0
  118. package/dist/modules/kb-fs/mutex.js +23 -0
  119. package/dist/modules/kb-fs/mutex.js.map +1 -0
  120. package/dist/modules/kb-fs/read-only-filesystem.d.ts +24 -0
  121. package/dist/modules/kb-fs/read-only-filesystem.d.ts.map +1 -0
  122. package/dist/modules/kb-fs/read-only-filesystem.js +39 -0
  123. package/dist/modules/kb-fs/read-only-filesystem.js.map +1 -0
  124. package/dist/modules/plugins/join-proposals.d.ts +1 -1
  125. package/dist/modules/plugins/join-proposals.d.ts.map +1 -1
  126. package/dist/modules/plugins/join-proposals.js +1 -1
  127. package/dist/modules/plugins/join-proposals.js.map +1 -1
  128. package/dist/modules/plugins/join-requests.service.d.ts.map +1 -1
  129. package/dist/modules/plugins/join-requests.service.js +1 -1
  130. package/dist/modules/plugins/join-requests.service.js.map +1 -1
  131. package/dist/modules/plugins/plugin-provision.service.js +3 -3
  132. package/dist/modules/plugins/plugin-provision.service.js.map +1 -1
  133. package/dist/modules/plugins/plugins.routes.js +2 -2
  134. package/dist/modules/plugins/plugins.routes.js.map +1 -1
  135. package/dist/modules/plugins/plugins.service.js +1 -1
  136. package/dist/modules/plugins/plugins.service.js.map +1 -1
  137. package/dist/modules/secrets-vault/secrets-vault.routes.js +1 -1
  138. package/dist/modules/secrets-vault/secrets-vault.routes.js.map +1 -1
  139. package/dist/modules/skills/pending-skills.service.d.ts.map +1 -1
  140. package/dist/modules/skills/pending-skills.service.js +1 -1
  141. package/dist/modules/skills/pending-skills.service.js.map +1 -1
  142. package/dist/modules/skills/skills.service.js +1 -1
  143. package/dist/modules/skills/skills.service.js.map +1 -1
  144. package/dist/modules/tool-helpers/tool-context.d.ts +2 -2
  145. package/dist/modules/tool-helpers/tool-context.d.ts.map +1 -1
  146. package/dist/modules/tool-helpers/tool-context.js +4 -4
  147. package/dist/modules/tool-helpers/tool-context.js.map +1 -1
  148. package/dist/modules/tool-manuals/mcp-server-edit.service.d.ts +1 -1
  149. package/dist/modules/tool-manuals/mcp-server-edit.service.d.ts.map +1 -1
  150. package/dist/modules/tool-manuals/mcp-server-edit.service.js +1 -1
  151. package/dist/modules/tool-manuals/mcp-server-edit.service.js.map +1 -1
  152. package/dist/modules/tool-manuals/tool-manuals.routes.d.ts +1 -1
  153. package/dist/modules/tool-manuals/tool-manuals.routes.d.ts.map +1 -1
  154. package/dist/modules/tool-manuals/tool-manuals.routes.js +1 -1
  155. package/dist/modules/tool-manuals/tool-manuals.routes.js.map +1 -1
  156. package/dist/modules/tool-manuals/tool-manuals.service.js +1 -1
  157. package/dist/modules/tool-manuals/tool-manuals.service.js.map +1 -1
  158. package/dist/modules/tool-manuals/tool-manuals.tools.js +1 -1
  159. package/dist/modules/tool-manuals/tool-manuals.tools.js.map +1 -1
  160. package/dist/modules/workflow/agent-tools/workflow.tools.js +1 -1
  161. package/dist/modules/workflow/agent-tools/workflow.tools.js.map +1 -1
  162. package/dist/modules/workflow/file-lock.service.js +1 -1
  163. package/dist/modules/workflow/file-lock.service.js.map +1 -1
  164. package/dist/modules/workflow/git/git.service.d.ts +2 -2
  165. package/dist/modules/workflow/git/git.service.d.ts.map +1 -1
  166. package/dist/modules/workflow/git/git.service.js +5 -5
  167. package/dist/modules/workflow/git/git.service.js.map +1 -1
  168. package/dist/modules/workflow/git/pull-request.service.js +1 -1
  169. package/dist/modules/workflow/git/pull-request.service.js.map +1 -1
  170. package/dist/modules/workflow/review-workflow/review-workflow.service.js +2 -2
  171. package/dist/modules/workflow/review-workflow/review-workflow.service.js.map +1 -1
  172. package/dist/modules/workflow/session-ontology.service.js +1 -1
  173. package/dist/modules/workflow/session-ontology.service.js.map +1 -1
  174. package/dist/modules/workflow/workflow.routes.js +2 -2
  175. package/dist/modules/workflow/workflow.routes.js.map +1 -1
  176. package/dist/modules/workflow/workflow.service.d.ts +1 -1
  177. package/dist/modules/workflow/workflow.service.d.ts.map +1 -1
  178. package/dist/modules/workflow/workflow.service.js +4 -4
  179. package/dist/modules/workflow/workflow.service.js.map +1 -1
  180. package/dist/modules/workspace/file-readers/doc-extract.service.d.ts +71 -0
  181. package/dist/modules/workspace/file-readers/doc-extract.service.d.ts.map +1 -0
  182. package/dist/modules/workspace/file-readers/doc-extract.service.js +90 -0
  183. package/dist/modules/workspace/file-readers/doc-extract.service.js.map +1 -0
  184. package/dist/modules/workspace/file-readers/doc-extract.types.d.ts +55 -0
  185. package/dist/modules/workspace/file-readers/doc-extract.types.d.ts.map +1 -0
  186. package/dist/modules/workspace/file-readers/doc-extract.types.js +34 -0
  187. package/dist/modules/workspace/file-readers/doc-extract.types.js.map +1 -0
  188. package/dist/modules/workspace/file-readers/document-reader.d.ts +32 -0
  189. package/dist/modules/workspace/file-readers/document-reader.d.ts.map +1 -0
  190. package/dist/modules/workspace/file-readers/document-reader.js +59 -0
  191. package/dist/modules/workspace/file-readers/document-reader.js.map +1 -0
  192. package/dist/modules/workspace/file-readers/email-reader.d.ts +15 -0
  193. package/dist/modules/workspace/file-readers/email-reader.d.ts.map +1 -0
  194. package/dist/modules/workspace/file-readers/email-reader.js +19 -0
  195. package/dist/modules/workspace/file-readers/email-reader.js.map +1 -0
  196. package/dist/modules/workspace/file-readers/email-text.d.ts +51 -0
  197. package/dist/modules/workspace/file-readers/email-text.d.ts.map +1 -0
  198. package/dist/modules/workspace/file-readers/email-text.js +151 -0
  199. package/dist/modules/workspace/file-readers/email-text.js.map +1 -0
  200. package/dist/modules/workspace/file-readers/extract-docx.d.ts +13 -0
  201. package/dist/modules/workspace/file-readers/extract-docx.d.ts.map +1 -0
  202. package/dist/modules/workspace/file-readers/extract-docx.js +67 -0
  203. package/dist/modules/workspace/file-readers/extract-docx.js.map +1 -0
  204. package/dist/modules/workspace/file-readers/extract-eml.d.ts +18 -0
  205. package/dist/modules/workspace/file-readers/extract-eml.d.ts.map +1 -0
  206. package/dist/modules/workspace/file-readers/extract-eml.js +87 -0
  207. package/dist/modules/workspace/file-readers/extract-eml.js.map +1 -0
  208. package/dist/modules/workspace/file-readers/extract-msg.d.ts +17 -0
  209. package/dist/modules/workspace/file-readers/extract-msg.d.ts.map +1 -0
  210. package/dist/modules/workspace/file-readers/extract-msg.js +121 -0
  211. package/dist/modules/workspace/file-readers/extract-msg.js.map +1 -0
  212. package/dist/modules/workspace/file-readers/extract-odp.d.ts +13 -0
  213. package/dist/modules/workspace/file-readers/extract-odp.d.ts.map +1 -0
  214. package/dist/modules/workspace/file-readers/extract-odp.js +60 -0
  215. package/dist/modules/workspace/file-readers/extract-odp.js.map +1 -0
  216. package/dist/modules/workspace/file-readers/extract-ods.d.ts +10 -0
  217. package/dist/modules/workspace/file-readers/extract-ods.d.ts.map +1 -0
  218. package/dist/modules/workspace/file-readers/extract-ods.js +173 -0
  219. package/dist/modules/workspace/file-readers/extract-ods.js.map +1 -0
  220. package/dist/modules/workspace/file-readers/extract-odt.d.ts +17 -0
  221. package/dist/modules/workspace/file-readers/extract-odt.d.ts.map +1 -0
  222. package/dist/modules/workspace/file-readers/extract-odt.js +45 -0
  223. package/dist/modules/workspace/file-readers/extract-odt.js.map +1 -0
  224. package/dist/modules/workspace/file-readers/extract-pdf.d.ts +3 -0
  225. package/dist/modules/workspace/file-readers/extract-pdf.d.ts.map +1 -0
  226. package/dist/modules/workspace/file-readers/extract-pdf.js +176 -0
  227. package/dist/modules/workspace/file-readers/extract-pdf.js.map +1 -0
  228. package/dist/modules/workspace/file-readers/extract-pptx.d.ts +37 -0
  229. package/dist/modules/workspace/file-readers/extract-pptx.d.ts.map +1 -0
  230. package/dist/modules/workspace/file-readers/extract-pptx.js +288 -0
  231. package/dist/modules/workspace/file-readers/extract-pptx.js.map +1 -0
  232. package/dist/modules/workspace/file-readers/extract-xlsx.d.ts +10 -0
  233. package/dist/modules/workspace/file-readers/extract-xlsx.d.ts.map +1 -0
  234. package/dist/modules/workspace/file-readers/extract-xlsx.js +98 -0
  235. package/dist/modules/workspace/file-readers/extract-xlsx.js.map +1 -0
  236. package/dist/modules/workspace/file-readers/extraction-cache.d.ts +61 -0
  237. package/dist/modules/workspace/file-readers/extraction-cache.d.ts.map +1 -0
  238. package/dist/modules/workspace/file-readers/extraction-cache.js +135 -0
  239. package/dist/modules/workspace/file-readers/extraction-cache.js.map +1 -0
  240. package/dist/modules/workspace/file-readers/file-reader.d.ts +76 -0
  241. package/dist/modules/workspace/file-readers/file-reader.d.ts.map +1 -0
  242. package/dist/modules/workspace/file-readers/file-reader.js +55 -0
  243. package/dist/modules/workspace/file-readers/file-reader.js.map +1 -0
  244. package/dist/modules/workspace/file-readers/file-reader.registry.d.ts +13 -0
  245. package/dist/modules/workspace/file-readers/file-reader.registry.d.ts.map +1 -0
  246. package/dist/modules/workspace/file-readers/file-reader.registry.js +41 -0
  247. package/dist/modules/workspace/file-readers/file-reader.registry.js.map +1 -0
  248. package/dist/modules/workspace/file-readers/image-read.d.ts +35 -0
  249. package/dist/modules/workspace/file-readers/image-read.d.ts.map +1 -0
  250. package/dist/modules/workspace/file-readers/image-read.js +108 -0
  251. package/dist/modules/workspace/file-readers/image-read.js.map +1 -0
  252. package/dist/modules/workspace/file-readers/image-reader.d.ts +19 -0
  253. package/dist/modules/workspace/file-readers/image-reader.d.ts.map +1 -0
  254. package/dist/modules/workspace/file-readers/image-reader.js +30 -0
  255. package/dist/modules/workspace/file-readers/image-reader.js.map +1 -0
  256. package/dist/modules/workspace/file-readers/odf-text.d.ts +26 -0
  257. package/dist/modules/workspace/file-readers/odf-text.d.ts.map +1 -0
  258. package/dist/modules/workspace/file-readers/odf-text.js +116 -0
  259. package/dist/modules/workspace/file-readers/odf-text.js.map +1 -0
  260. package/dist/modules/workspace/file-readers/ooxml-text.d.ts +172 -0
  261. package/dist/modules/workspace/file-readers/ooxml-text.d.ts.map +1 -0
  262. package/dist/modules/workspace/file-readers/ooxml-text.js +439 -0
  263. package/dist/modules/workspace/file-readers/ooxml-text.js.map +1 -0
  264. package/dist/modules/workspace/file-readers/text-reader.d.ts +47 -0
  265. package/dist/modules/workspace/file-readers/text-reader.d.ts.map +1 -0
  266. package/dist/modules/workspace/file-readers/text-reader.js +117 -0
  267. package/dist/modules/workspace/file-readers/text-reader.js.map +1 -0
  268. package/dist/modules/workspace/startup/kb-startup-runner.js +1 -1
  269. package/dist/modules/workspace/startup/kb-startup-runner.js.map +1 -1
  270. package/dist/modules/workspace/startup/steps/groups-to-plugins.step.js +1 -1
  271. package/dist/modules/workspace/startup/steps/groups-to-plugins.step.js.map +1 -1
  272. package/dist/modules/workspace/startup/steps/roles-yaml.step.d.ts +1 -1
  273. package/dist/modules/workspace/startup/steps/roles-yaml.step.js +2 -2
  274. package/dist/modules/workspace/startup/steps/roles-yaml.step.js.map +1 -1
  275. package/dist/modules/workspace/startup/steps/seed-tree.js +1 -1
  276. package/dist/modules/workspace/startup/steps/seed-tree.js.map +1 -1
  277. package/dist/modules/workspace/workspace.routes.d.ts +1 -1
  278. package/dist/modules/workspace/workspace.routes.d.ts.map +1 -1
  279. package/dist/modules/workspace/workspace.routes.js +5 -4
  280. package/dist/modules/workspace/workspace.routes.js.map +1 -1
  281. package/dist/modules/workspace/workspace.service.d.ts +2 -9
  282. package/dist/modules/workspace/workspace.service.d.ts.map +1 -1
  283. package/dist/modules/workspace/workspace.service.js +14 -15
  284. package/dist/modules/workspace/workspace.service.js.map +1 -1
  285. package/dist/modules/workspace/workspace.tools.d.ts +2 -1
  286. package/dist/modules/workspace/workspace.tools.d.ts.map +1 -1
  287. package/dist/modules/workspace/workspace.tools.js +161 -18
  288. package/dist/modules/workspace/workspace.tools.js.map +1 -1
  289. package/dist/shared/domain-errors.d.ts +202 -0
  290. package/dist/shared/domain-errors.d.ts.map +1 -0
  291. package/dist/shared/domain-errors.js +303 -0
  292. package/dist/shared/domain-errors.js.map +1 -0
  293. package/dist/shared/workspace-id.d.ts +27 -0
  294. package/dist/shared/workspace-id.d.ts.map +1 -0
  295. package/dist/shared/workspace-id.js +36 -0
  296. package/dist/shared/workspace-id.js.map +1 -0
  297. package/package.json +9 -4
  298. package/src/core/create-core-server.ts +1 -1
  299. package/src/core/create-core-services.ts +8 -2
  300. package/src/core-config.ts +9 -0
  301. package/src/modules/access/__tests__/access-control.service.test.ts +1 -1
  302. package/src/modules/access/__tests__/access-groups.test.ts +6 -5
  303. package/src/modules/access/__tests__/access-md-format.test.ts +3 -3
  304. package/src/modules/access/__tests__/access-mutation.service.test.ts +1 -1
  305. package/src/modules/access/__tests__/admin-locked-commit.test.ts +1 -1
  306. package/src/modules/access/__tests__/admin-route-helpers.test.ts +1 -1
  307. package/src/modules/access/__tests__/roles-admin.service.test.ts +2 -2
  308. package/src/modules/access/__tests__/roles-edit.test.ts +1 -1
  309. package/src/modules/access/__tests__/synced-groups-committer.test.ts +1 -1
  310. package/src/modules/access/__tests__/synced-groups-writer.test.ts +1 -1
  311. package/src/modules/access/access-control.service.ts +23 -768
  312. package/src/modules/access/access-declarations.ts +2 -2
  313. package/src/modules/access/access-mutation.service.ts +3 -3
  314. package/src/modules/access/access.routes.ts +5 -5
  315. package/src/modules/access/admin-locked-commit.ts +2 -2
  316. package/src/modules/access/admin-route-helpers.ts +1 -1
  317. package/src/modules/access/capability-registry.ts +1 -1
  318. package/src/modules/access/creator-access.ts +9 -72
  319. package/src/modules/access/groups-admin.routes.ts +1 -1
  320. package/src/modules/access/groups-admin.service.ts +6 -7
  321. package/src/modules/access/groups-edit.ts +2 -2
  322. package/src/modules/access/reference-scan.ts +1 -1
  323. package/src/modules/access/roles-admin.service.ts +8 -8
  324. package/src/modules/access/roles-edit.ts +1 -1
  325. package/src/modules/access/synced-groups-committer.ts +4 -4
  326. package/src/modules/access/synced-groups-writer.ts +2 -2
  327. package/src/modules/access-model/__tests__/access-grammar.test.ts +31 -0
  328. package/src/modules/{access → access-model}/__tests__/access-splice.test.ts +268 -268
  329. package/src/modules/{access → access-model}/access-errors.ts +1 -1
  330. package/src/modules/access-model/access-grammar.ts +778 -0
  331. package/src/modules/{access → access-model}/access-splice.ts +1 -1
  332. package/src/modules/access-model/creator.ts +79 -0
  333. package/src/modules/{access → access-model}/group-files.ts +1 -1
  334. package/src/modules/{access → access-model}/render-roles-yaml.ts +1 -1
  335. package/src/modules/{access → access-model}/roles-yaml-guard.ts +2 -2
  336. package/src/modules/admin/admin-access.service.ts +2 -1
  337. package/src/modules/code-mode/__tests__/code-mode.tool.test.ts +30 -0
  338. package/src/modules/code-mode/code-mode.tool.ts +7 -1
  339. package/src/modules/diff/__tests__/diff.routes.rejectPathsLocked.test.ts +2 -2
  340. package/src/modules/diff/__tests__/diff.service.seed-atomicity.test.ts +3 -2
  341. package/src/modules/diff/__tests__/diff.service.test.ts +3 -2
  342. package/src/modules/diff/diff.routes.ts +4 -4
  343. package/src/modules/diff/diff.service.ts +1 -1
  344. package/src/modules/{workflow/git → kb-fs}/__tests__/branch-name.test.ts +1 -1
  345. package/src/modules/{workflow → kb-fs}/__tests__/locking-filesystem.test.ts +1 -1
  346. package/src/modules/{workflow/git → kb-fs}/branch-name.ts +1 -1
  347. package/src/modules/{workflow → kb-fs}/locking-filesystem.ts +2 -2
  348. package/src/modules/plugins/__tests__/join-requests.service.test.ts +2 -4
  349. package/src/modules/plugins/__tests__/plugin-index.service.test.ts +1 -1
  350. package/src/modules/plugins/__tests__/plugins.routes.test.ts +1 -1
  351. package/src/modules/plugins/join-proposals.ts +1 -1
  352. package/src/modules/plugins/join-requests.service.ts +2 -1
  353. package/src/modules/plugins/plugin-provision.service.ts +3 -3
  354. package/src/modules/plugins/plugins.routes.ts +2 -2
  355. package/src/modules/plugins/plugins.service.ts +1 -1
  356. package/src/modules/secrets-vault/secrets-vault.routes.ts +1 -1
  357. package/src/modules/skills/__tests__/skills.service.test.ts +1 -1
  358. package/src/modules/skills/pending-skills.service.ts +2 -1
  359. package/src/modules/skills/skills.service.ts +1 -1
  360. package/src/modules/tool-helpers/__tests__/phase4-tools.test.ts +2 -1
  361. package/src/modules/tool-helpers/tool-context.ts +6 -5
  362. package/src/modules/tool-manuals/__tests__/mcp-server-edit.service.test.ts +1 -1
  363. package/src/modules/tool-manuals/__tests__/tool-manuals.archive.route.test.ts +1 -1
  364. package/src/modules/tool-manuals/__tests__/tool-manuals.detail.route.test.ts +1 -1
  365. package/src/modules/tool-manuals/__tests__/tool-manuals.mcp-oauth.test.ts +1 -1
  366. package/src/modules/tool-manuals/__tests__/tool-manuals.service.test.ts +1 -1
  367. package/src/modules/tool-manuals/mcp-server-edit.service.ts +2 -1
  368. package/src/modules/tool-manuals/tool-manuals.routes.ts +2 -1
  369. package/src/modules/tool-manuals/tool-manuals.service.ts +1 -1
  370. package/src/modules/tool-manuals/tool-manuals.tools.ts +1 -1
  371. package/src/modules/workflow/__tests__/preserve-roles-yaml.test.ts +1 -1
  372. package/src/modules/workflow/__tests__/workflow.service.commitFileWhileLocked.test.ts +1 -1
  373. package/src/modules/workflow/__tests__/workflow.service.facade.test.ts +1 -1
  374. package/src/modules/workflow/__tests__/workflow.service.releaseLock.test.ts +1 -1
  375. package/src/modules/workflow/agent-tools/workflow.tools.ts +1 -1
  376. package/src/modules/workflow/file-lock.service.ts +1 -1
  377. package/src/modules/workflow/git/__tests__/git.service.accessGating.test.ts +1 -1
  378. package/src/modules/workflow/git/__tests__/git.service.deleteBranch.test.ts +1 -1
  379. package/src/modules/workflow/git/__tests__/git.service.diffFileAtCommit.test.ts +1 -1
  380. package/src/modules/workflow/git/__tests__/git.service.diffFileBetweenBranches.test.ts +1 -1
  381. package/src/modules/workflow/git/__tests__/git.service.pull.test.ts +1 -1
  382. package/src/modules/workflow/git/git.service.ts +5 -5
  383. package/src/modules/workflow/git/pull-request.service.ts +1 -1
  384. package/src/modules/workflow/review-workflow/__tests__/cancel-pr.test.ts +1 -1
  385. package/src/modules/workflow/review-workflow/review-workflow.service.ts +2 -2
  386. package/src/modules/workflow/session-ontology.service.ts +1 -1
  387. package/src/modules/workflow/workflow.routes.ts +2 -2
  388. package/src/modules/workflow/workflow.service.ts +5 -5
  389. package/src/modules/workspace/__tests__/workspace.routes.create-grant.test.ts +1 -1
  390. package/src/modules/workspace/__tests__/workspace.routes.delete.test.ts +1 -1
  391. package/src/modules/workspace/__tests__/workspace.routes.download.test.ts +2 -2
  392. package/src/modules/workspace/__tests__/workspace.routes.read-gate.test.ts +1 -1
  393. package/src/modules/workspace/__tests__/workspace.service.read-filter.test.ts +2 -5
  394. package/src/modules/workspace/__tests__/workspace.service.test.ts +13 -1
  395. package/src/modules/workspace/__tests__/workspace.tools.test.ts +501 -3
  396. package/src/modules/workspace/file-readers/__tests__/doc-extract.test.ts +1658 -0
  397. package/src/modules/workspace/file-readers/__tests__/email-extract.test.ts +485 -0
  398. package/src/modules/workspace/file-readers/__tests__/file-reader.registry.test.ts +97 -0
  399. package/src/modules/workspace/file-readers/__tests__/image-read.test.ts +100 -0
  400. package/src/modules/workspace/file-readers/doc-extract.service.ts +104 -0
  401. package/src/modules/workspace/file-readers/doc-extract.types.ts +63 -0
  402. package/src/modules/workspace/file-readers/document-reader.ts +64 -0
  403. package/src/modules/workspace/file-readers/email-reader.ts +21 -0
  404. package/src/modules/workspace/file-readers/email-text.ts +193 -0
  405. package/src/modules/workspace/file-readers/extract-docx.ts +67 -0
  406. package/src/modules/workspace/file-readers/extract-eml.ts +92 -0
  407. package/src/modules/workspace/file-readers/extract-msg.ts +134 -0
  408. package/src/modules/workspace/file-readers/extract-odp.ts +63 -0
  409. package/src/modules/workspace/file-readers/extract-ods.ts +182 -0
  410. package/src/modules/workspace/file-readers/extract-odt.ts +48 -0
  411. package/src/modules/workspace/file-readers/extract-pdf.ts +178 -0
  412. package/src/modules/workspace/file-readers/extract-pptx.ts +302 -0
  413. package/src/modules/workspace/file-readers/extract-xlsx.ts +96 -0
  414. package/src/modules/workspace/file-readers/extraction-cache.ts +142 -0
  415. package/src/modules/workspace/file-readers/file-reader.registry.ts +45 -0
  416. package/src/modules/workspace/file-readers/file-reader.ts +104 -0
  417. package/src/modules/workspace/file-readers/image-read.ts +122 -0
  418. package/src/modules/workspace/file-readers/image-reader.ts +39 -0
  419. package/src/modules/workspace/file-readers/odf-text.ts +123 -0
  420. package/src/modules/workspace/file-readers/ooxml-text.ts +477 -0
  421. package/src/modules/workspace/file-readers/text-reader.ts +131 -0
  422. package/src/modules/workspace/startup/kb-startup-runner.ts +1 -1
  423. package/src/modules/workspace/startup/steps/__tests__/steps.test.ts +1 -1
  424. package/src/modules/workspace/startup/steps/groups-to-plugins.step.ts +1 -1
  425. package/src/modules/workspace/startup/steps/roles-yaml.step.ts +2 -2
  426. package/src/modules/workspace/startup/steps/seed-tree.ts +1 -1
  427. package/src/modules/workspace/workspace.routes.ts +6 -5
  428. package/src/modules/workspace/workspace.service.ts +14 -18
  429. package/src/modules/workspace/workspace.tools.ts +177 -15
  430. package/src/shared/__tests__/join-request.test.ts +1 -1
  431. package/src/shared/__tests__/workspace-id.test.ts +17 -0
  432. package/src/{modules/workflow/workflow.errors.ts → shared/domain-errors.ts} +6 -1
  433. package/src/shared/workspace-id.ts +36 -0
  434. /package/src/modules/{access → access-model}/__tests__/kb-read-filter.test.ts +0 -0
  435. /package/src/modules/{access → access-model}/__tests__/roles-yaml-guard.test.ts +0 -0
  436. /package/src/modules/{access → access-model}/kb-read-filter.ts +0 -0
  437. /package/src/modules/{workflow/git → kb-fs}/__tests__/clone-config.test.ts +0 -0
  438. /package/src/modules/{workflow → kb-fs}/__tests__/file-change-notifier.test.ts +0 -0
  439. /package/src/modules/{workflow/git → kb-fs}/__tests__/mutex.test.ts +0 -0
  440. /package/src/modules/{workflow/git → kb-fs}/clone-config.ts +0 -0
  441. /package/src/modules/{workflow → kb-fs}/file-change-notifier.ts +0 -0
  442. /package/src/modules/{workflow/git → kb-fs}/mutex.ts +0 -0
  443. /package/src/modules/{workflow → kb-fs}/read-only-filesystem.ts +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"access-grammar.js","sourceRoot":"","sources":["../../../src/modules/access-model/access-grammar.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,8EAA8E;AAC9E,yEAAyE;AACzE,8EAA8E;AAE9E,MAAM,CAAC,MAAM,eAAe,GAAG,OAAO,CAAC;AACvC;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,CAAU,CAAC;AAE3E,MAAM,eAAe,GAAwB,IAAI,GAAG,CAAS,WAAW,CAAC,CAAC;AAC1E,MAAM,CAAC,MAAM,kBAAkB,GAAG,UAAU,CAAC;AAC7C,qEAAqE;AACrE,MAAM,CAAC,MAAM,gBAAgB,GAAG,UAAU,CAAC;AAE3C;;;;;;;;;;GAUG;AACH,MAAM,UAAU,cAAc,CAAC,IAAU;IACvC,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,OAAO;YACV,OAAO,CAAC,OAAO,CAAC,CAAC;QACnB,KAAK,MAAM;YACT,OAAO,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;QACpC;YACE,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC3B,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IAC/B,IAAI,OAAO,GAAG,KAAK,CAAC;IACpB,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAiC,CAAC,EAAE,CAAC;QAC7E,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,GAAG,CAAC;YAAE,SAAS,CAAC,wBAAwB;QACjE,yEAAyE;QACzE,wEAAwE;QACxE,oEAAoE;QACpE,mEAAmE;QACnE,IAAI,IAAiB,CAAC;QACtB,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;YAAE,IAAI,GAAG,KAAK,CAAC;aAClC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE;YAAE,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC;;YAC9D,SAAS;QACd,MAAM,IAAI,GAAG,GAAW,CAAC;QACzB,MAAM,IAAI,GAAkB,EAAE,CAAC;QAC/B,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;YACvB,MAAM,MAAM,GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAC;YACrC,IAAI,MAAM,CAAC,EAAE;gBAAE,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACzC,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;QACrB,OAAO,GAAG,IAAI,CAAC;IACjB,CAAC;IACD,OAAO,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC;AAClC,CAAC"}
@@ -0,0 +1,140 @@
1
+ /**
2
+ * Surgical text-splice editor for `access.md` frontmatter and node-frontmatter
3
+ * access verbs.
4
+ *
5
+ * WHY a splice and not parse→model→emit: the resolver's parser
6
+ * (`parseYamlSubset` / `extractFrontmatter` / `stripComment`) deliberately
7
+ * throws away comments, blank lines, key order, AND the markdown body below the
8
+ * closing `---`. Re-serialising from the parsed model would silently DELETE the
9
+ * prose bodies the real `access.md` files carry (the repo-root one is a whole
10
+ * README) — and a `parse(emit(x))` round-trip test would PASS anyway because
11
+ * parse ignores the body. So every mutation here edits the RAW text: we locate
12
+ * the verb's block, splice exactly one list line in or out, and leave every
13
+ * other byte — comments, ordering, blank lines, the body — untouched.
14
+ *
15
+ * ---
16
+ * write: (verb key line, indent 0)
17
+ * - Admin (list item, indent 2) <- splice point
18
+ * - Felix <f@x.eu> (list item)
19
+ * # a comment (preserved verbatim)
20
+ * owner: [] (inline-empty list)
21
+ * ---
22
+ * # Body prose (preserved verbatim)
23
+ *
24
+ * The same engine serves node-frontmatter, which additionally accepts a scalar
25
+ * form (`owner: Felix <f@x.eu>`). Adding a second principal to a scalar verb
26
+ * normalises it to the block-list form.
27
+ */
28
+ import { type Verb } from './access-grammar.js';
29
+ /**
30
+ * Which rule block a mutation edits.
31
+ *
32
+ * - `'node'` (default): the file's YAML frontmatter — node files, and every
33
+ * call that predates the two-format `access.md` story.
34
+ * - `'folder'`: the block that governs the CONTAINING FOLDER of an
35
+ * `access.md` — the body when the file is in the new (body-governed)
36
+ * format, the frontmatter otherwise. Callers mutating folder rules pass
37
+ * this so a grant can never land in a new-format file's frontmatter
38
+ * (which governs the FILE itself, not the folder).
39
+ */
40
+ export type SpliceTarget = 'node' | 'folder';
41
+ /** A principal to grant/revoke, in the resolver's canonical terms. */
42
+ export type Principal = {
43
+ kind: 'user';
44
+ email: string;
45
+ displayName: string;
46
+ } | {
47
+ kind: 'role';
48
+ role: string;
49
+ };
50
+ /** Result of a splice — the new full file text and whether anything changed. */
51
+ export interface SpliceResult {
52
+ text: string;
53
+ changed: boolean;
54
+ }
55
+ /** Thrown when the input can't be spliced safely (malformed frontmatter, etc.). */
56
+ export declare class AccessSpliceError extends Error {
57
+ constructor(message: string);
58
+ }
59
+ /**
60
+ * Render a principal as the canonical access-entry line value the parser reads
61
+ * back (`Name <email>` or a bare role display name). The caller is responsible
62
+ * for having validated the principal first (see `validatePrincipal`).
63
+ *
64
+ * `deny` prefixes the entry with `deny ` so the resolver reads it as a denial
65
+ * (the `deny-here` per-item override) — same line shape, opposite verdict.
66
+ */
67
+ export declare function renderEntry(p: Principal, deny?: boolean): string;
68
+ /**
69
+ * Validate a principal before it is spliced into a file. Rejects anything that
70
+ * could break frontmatter or smuggle in extra YAML — newlines, control chars,
71
+ * and emails / names that don't match the resolver's own regexes. This is the
72
+ * injection guard: a principal that survives this is safe to render verbatim
73
+ * into a ` - ` list line.
74
+ *
75
+ * Returns the canonical principal (lowercased email / canonical role) on
76
+ * success, or throws `AccessSpliceError`.
77
+ */
78
+ export declare function validatePrincipal(p: Principal): Principal;
79
+ /**
80
+ * How a role-shaped principal's TOKEN is compared against a file entry:
81
+ *
82
+ * - `'exact'`: the entry must carry the SAME spelling — a bare token and a
83
+ * `role/<name>` token are DIFFERENT principals (bare = whoever owns the
84
+ * bare key under group-first precedence, `role/` = the role). Grants
85
+ * always use this: granting the group `X` while `role/X` is present (or
86
+ * vice versa) must NOT be treated as already-granted, or the other
87
+ * principal silently never receives the grant.
88
+ * - `'name'`: both spellings of the name match. Revokes use this ONLY when
89
+ * no group shadows the bare name — then both spellings resolve to the
90
+ * role, and revoking the role must also remove legacy bare spellings.
91
+ */
92
+ export type TokenMatch = 'exact' | 'name';
93
+ /**
94
+ * Add `principal` under `verb`. Idempotent: if an entry with the EXACT same
95
+ * token spelling already exists with the SAME deny-ness (a grant when
96
+ * granting, a deny when denying), returns `changed: false`. Idempotency is
97
+ * deliberately exact-token, never name-level: a bare token and a `role/`
98
+ * token are different principals (group-first precedence gives the bare key
99
+ * to a same-named group), so a bare-`X` GROUP grant must go through even when
100
+ * `role/X` is present, and vice versa. Creates the verb key (and the
101
+ * frontmatter fence, for a fresh file) as needed. Preserves everything else
102
+ * byte-for-byte.
103
+ *
104
+ * `allowScalar` controls whether a fresh single-entry verb may be written in
105
+ * the node-frontmatter scalar form (`owner: Name <email>`). access.md always
106
+ * uses the block-list form; node frontmatter prefers scalar for a lone entry.
107
+ *
108
+ * `deny` writes the entry as a `deny <principal>` denial instead of a grant
109
+ * (the `deny-here` per-item override). The block/scalar/empty-list handling is
110
+ * identical — only the rendered line and the idempotency check differ — so the
111
+ * deny path reuses this engine rather than a parallel `spliceDeny`. NOTE: the
112
+ * resolver lets a same-scope grant override a same-scope deny of the same
113
+ * principal, so a caller adding a deny where a grant already exists must strip
114
+ * that grant first (see `AccessMutationService`); this function only writes the
115
+ * one entry it's asked to.
116
+ */
117
+ export declare function spliceGrant(text: string, verb: Verb, rawPrincipal: Principal, opts?: {
118
+ allowScalar?: boolean;
119
+ deny?: boolean;
120
+ target?: SpliceTarget;
121
+ }): SpliceResult;
122
+ /**
123
+ * Remove every entry naming `principal` under `verb` (grant or deny). Idempotent:
124
+ * returns `changed: false` when the principal isn't present. If removing the
125
+ * last item empties the verb, the `verb:` key is collapsed to `verb: []` so the
126
+ * file still parses cleanly (the resolver reads `[]` as an empty list).
127
+ * Preserves everything else.
128
+ *
129
+ * Token matching for role-shaped principals is `tokenMatch` (default `'name'`:
130
+ * BOTH spellings — revoking the role removes legacy bare spellings too).
131
+ * Callers pass `'exact'` when a GROUP shadows the principal's bare name: the
132
+ * bare token then belongs to the group and the `role/` token to the role, so a
133
+ * revoke of one must never strip the other (see AccessMutationService, which
134
+ * derives the flag from the merged principal index).
135
+ */
136
+ export declare function spliceRevoke(text: string, verb: Verb, rawPrincipal: Principal, opts?: {
137
+ target?: SpliceTarget;
138
+ tokenMatch?: TokenMatch;
139
+ }): SpliceResult;
140
+ //# sourceMappingURL=access-splice.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"access-splice.d.ts","sourceRoot":"","sources":["../../../src/modules/access-model/access-splice.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EACL,KAAK,IAAI,EAMV,MAAM,qBAAqB,CAAC;AAE7B;;;;;;;;;;GAUG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,QAAQ,CAAC;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text-splice editor for `access.md` frontmatter and node-frontmatter
3
+ * access verbs.
4
+ *
5
+ * WHY a splice and not parse→model→emit: the resolver's parser
6
+ * (`parseYamlSubset` / `extractFrontmatter` / `stripComment`) deliberately
7
+ * throws away comments, blank lines, key order, AND the markdown body below the
8
+ * closing `---`. Re-serialising from the parsed model would silently DELETE the
9
+ * prose bodies the real `access.md` files carry (the repo-root one is a whole
10
+ * README) — and a `parse(emit(x))` round-trip test would PASS anyway because
11
+ * parse ignores the body. So every mutation here edits the RAW text: we locate
12
+ * the verb's block, splice exactly one list line in or out, and leave every
13
+ * other byte — comments, ordering, blank lines, the body — untouched.
14
+ *
15
+ * ---
16
+ * write: (verb key line, indent 0)
17
+ * - Admin (list item, indent 2) <- splice point
18
+ * - Felix <f@x.eu> (list item)
19
+ * # a comment (preserved verbatim)
20
+ * owner: [] (inline-empty list)
21
+ * ---
22
+ * # Body prose (preserved verbatim)
23
+ *
24
+ * The same engine serves node-frontmatter, which additionally accepts a scalar
25
+ * form (`owner: Felix <f@x.eu>`). Adding a second principal to a scalar verb
26
+ * normalises it to the block-list form.
27
+ */
28
+ import { parseAccessEntry, canonicalEmail, canonicalRoleName, accessMdDeclaresBodyRules, } from './access-grammar.js';
29
+ /** Thrown when the input can't be spliced safely (malformed frontmatter, etc.). */
30
+ export class AccessSpliceError extends Error {
31
+ constructor(message) {
32
+ super(message);
33
+ this.name = 'AccessSpliceError';
34
+ }
35
+ }
36
+ /** Control chars (NUL..US) — newlines, tabs, etc. Never allowed in a principal. */
37
+ // eslint-disable-next-line no-control-regex -- intentional control-char injection guard
38
+ const CONTROL_CHARS = /[\u0000-\u001f\u007f]/;
39
+ /**
40
+ * Render a principal as the canonical access-entry line value the parser reads
41
+ * back (`Name <email>` or a bare role display name). The caller is responsible
42
+ * for having validated the principal first (see `validatePrincipal`).
43
+ *
44
+ * `deny` prefixes the entry with `deny ` so the resolver reads it as a denial
45
+ * (the `deny-here` per-item override) — same line shape, opposite verdict.
46
+ */
47
+ export function renderEntry(p, deny = false) {
48
+ const body = p.kind === 'user' ? `${p.displayName} <${p.email}>` : p.role;
49
+ return deny ? `deny ${body}` : body;
50
+ }
51
+ /**
52
+ * Validate a principal before it is spliced into a file. Rejects anything that
53
+ * could break frontmatter or smuggle in extra YAML — newlines, control chars,
54
+ * and emails / names that don't match the resolver's own regexes. This is the
55
+ * injection guard: a principal that survives this is safe to render verbatim
56
+ * into a ` - ` list line.
57
+ *
58
+ * Returns the canonical principal (lowercased email / canonical role) on
59
+ * success, or throws `AccessSpliceError`.
60
+ */
61
+ export function validatePrincipal(p) {
62
+ if (p.kind === 'user') {
63
+ const displayName = p.displayName.trim();
64
+ const email = canonicalEmail(p.email);
65
+ if (!displayName)
66
+ throw new AccessSpliceError('person grant needs a display name');
67
+ // `#` is rejected because `uncomment()` truncates a whitespace-preceded `#`
68
+ // on read-back, so a name containing it would not round-trip through blockEntries.
69
+ if (CONTROL_CHARS.test(displayName) ||
70
+ displayName.includes('<') ||
71
+ displayName.includes('>') ||
72
+ displayName.includes('#')) {
73
+ throw new AccessSpliceError(`invalid display name: ${JSON.stringify(p.displayName)}`);
74
+ }
75
+ // Reuse the resolver's own email shape so a granted entry always parses back.
76
+ if (!/^[^<>\s@]+@[^<>\s@]+\.[^<>\s@]+$/.test(email)) {
77
+ throw new AccessSpliceError(`invalid email: ${JSON.stringify(p.email)}`);
78
+ }
79
+ // The rendered `Name <email>` line must round-trip through parseAccessEntry.
80
+ const round = parseAccessEntry(`${displayName} <${email}>`);
81
+ if (!round.ok || round.entry.kind !== 'user' || round.entry.deny) {
82
+ throw new AccessSpliceError(`person grant does not round-trip: ${JSON.stringify(p)}`);
83
+ }
84
+ return { kind: 'user', email, displayName };
85
+ }
86
+ const role = p.role.trim();
87
+ const canonical = canonicalRoleName(role);
88
+ if (!canonical)
89
+ throw new AccessSpliceError('role grant needs a name');
90
+ if (CONTROL_CHARS.test(role) ||
91
+ role.includes('<') ||
92
+ role.includes('>') ||
93
+ role.includes(':') ||
94
+ role.includes('#')) {
95
+ throw new AccessSpliceError(`invalid role name: ${JSON.stringify(p.role)}`);
96
+ }
97
+ // `deny` is never a grantee — it's the denial prefix. `everyone` IS grantable
98
+ // (the built-in public role); the access route restricts it to the read verb.
99
+ if (canonical === 'deny') {
100
+ throw new AccessSpliceError(`'${role}' is a reserved name and cannot be granted as a role`);
101
+ }
102
+ const round = parseAccessEntry(role);
103
+ if (!round.ok || round.entry.kind !== 'role' || round.entry.deny) {
104
+ throw new AccessSpliceError(`role grant does not round-trip: ${JSON.stringify(p)}`);
105
+ }
106
+ return { kind: 'role', role };
107
+ }
108
+ /**
109
+ * True when a parsed entry names the given principal (ignoring deny prefix).
110
+ * `tokenMatch` (role-shaped principals only) selects exact-spelling vs
111
+ * name-level matching — see {@link TokenMatch}.
112
+ */
113
+ function entryMatches(entry, p, tokenMatch) {
114
+ if (p.kind === 'user')
115
+ return entry.kind === 'user' && entry.email === canonicalEmail(p.email);
116
+ if (entry.kind !== 'role')
117
+ return false;
118
+ const canonicalPrincipal = canonicalRoleName(p.role);
119
+ if (tokenMatch === 'exact')
120
+ return entry.role === canonicalPrincipal;
121
+ const strip = (token) => token.startsWith('role/') ? canonicalRoleName(token.slice('role/'.length)) : token;
122
+ return strip(entry.role) === strip(canonicalPrincipal);
123
+ }
124
+ /**
125
+ * Split a file into [pre, frontmatter-lines, post] without losing a byte.
126
+ * `hasFrontmatter` is false when the file has no `---` fence yet — callers that
127
+ * grant into a fresh file synthesise one.
128
+ */
129
+ function splitFrontmatter(text) {
130
+ const eol = text.includes('\r\n') ? '\r\n' : '\n';
131
+ const lines = text.split(/\r?\n/);
132
+ // Opening fence must be the very first line.
133
+ if (lines[0]?.trim() !== '---') {
134
+ return { pre: [], fm: [], post: lines, eol, hasFrontmatter: false };
135
+ }
136
+ for (let i = 1; i < lines.length; i++) {
137
+ if (lines[i].trim() === '---') {
138
+ return {
139
+ pre: lines.slice(0, 1), // the opening ---
140
+ fm: lines.slice(1, i),
141
+ post: lines.slice(i), // closing --- onward (body preserved)
142
+ eol,
143
+ hasFrontmatter: true,
144
+ };
145
+ }
146
+ }
147
+ throw new AccessSpliceError('unterminated frontmatter — no closing `---`');
148
+ }
149
+ function joinFrontmatter(f) {
150
+ return [...f.pre, ...f.fm, ...f.post].join(f.eol);
151
+ }
152
+ /**
153
+ * The line region a mutation edits, per {@link SpliceTarget}. `lines` aliases
154
+ * the region's array (edited in place, like `f.fm` always was); `join()`
155
+ * reassembles the whole file around it.
156
+ */
157
+ function pickRegion(text, f, target) {
158
+ if (target === 'folder' && f.hasFrontmatter && accessMdDeclaresBodyRules(text)) {
159
+ // New format: post = [closing '---', ...body]. Edit the body lines.
160
+ const closing = f.post[0];
161
+ const body = f.post.slice(1);
162
+ return {
163
+ lines: body,
164
+ join: () => [...f.pre, ...f.fm, closing, ...body].join(f.eol),
165
+ };
166
+ }
167
+ return { lines: f.fm, join: () => joinFrontmatter(f) };
168
+ }
169
+ /** Leading-space count of a line. */
170
+ function indentOf(line) {
171
+ const m = line.match(/^( *)/);
172
+ return m ? m[1].length : 0;
173
+ }
174
+ /** Strip a trailing `# comment` the way the resolver's tokeniser does. */
175
+ function uncomment(line) {
176
+ let inWs = true;
177
+ for (let i = 0; i < line.length; i++) {
178
+ const ch = line[i];
179
+ if (ch === '#' && (inWs || (i > 0 && /\s/.test(line[i - 1]))))
180
+ return line.slice(0, i);
181
+ if (!/\s/.test(ch))
182
+ inWs = false;
183
+ }
184
+ return line;
185
+ }
186
+ /**
187
+ * Locate a verb's block within the frontmatter lines. Walks the raw lines (not
188
+ * the parsed model) so we can address them for splicing. Recognises the three
189
+ * shapes the resolver accepts: a block list, an inline `verb: []`, and (node
190
+ * frontmatter only) an inline scalar `verb: value`.
191
+ */
192
+ function findVerbBlock(fm, verb) {
193
+ const block = {
194
+ keyLine: -1,
195
+ keyIndent: 0,
196
+ itemLines: [],
197
+ itemIndent: -1,
198
+ inlineEmpty: false,
199
+ inlineScalarValue: null,
200
+ };
201
+ for (let i = 0; i < fm.length; i++) {
202
+ const content = uncomment(fm[i]);
203
+ if (!content.trim())
204
+ continue;
205
+ const indent = indentOf(content);
206
+ const body = content.slice(indent);
207
+ // A list item belonging to the current verb block.
208
+ if ((body.startsWith('- ') || body === '-') &&
209
+ block.keyLine !== -1 &&
210
+ indent > block.keyIndent) {
211
+ block.itemLines.push(i);
212
+ if (block.itemIndent === -1)
213
+ block.itemIndent = indent;
214
+ continue;
215
+ }
216
+ const colon = body.indexOf(':');
217
+ if (colon < 0)
218
+ continue; // not a key line; ignore (the parser would too)
219
+ const key = body.slice(0, colon).trim();
220
+ const value = body.slice(colon + 1).trim();
221
+ if (block.keyLine !== -1) {
222
+ // We already found our verb; a new key at <= our indent ends the block.
223
+ if (indent <= block.keyIndent)
224
+ break;
225
+ continue;
226
+ }
227
+ if (key === verb && indent === 0) {
228
+ block.keyLine = i;
229
+ block.keyIndent = indent;
230
+ if (value === '[]')
231
+ block.inlineEmpty = true;
232
+ else if (value !== '')
233
+ block.inlineScalarValue = value;
234
+ }
235
+ }
236
+ if (block.itemIndent === -1)
237
+ block.itemIndent = block.keyIndent + 2;
238
+ return block;
239
+ }
240
+ /**
241
+ * Parse the items currently under a verb block into ParsedEntry form, for
242
+ * matching. Handles list items and the inline-scalar form.
243
+ */
244
+ function blockEntries(fm, block) {
245
+ const out = [];
246
+ if (block.inlineScalarValue !== null) {
247
+ const r = parseAccessEntry(block.inlineScalarValue);
248
+ if (r.ok)
249
+ out.push({ entry: r.entry, line: block.keyLine });
250
+ return out;
251
+ }
252
+ for (const li of block.itemLines) {
253
+ const content = uncomment(fm[li]).trim();
254
+ const value = content === '-' ? '' : content.slice(2).trim();
255
+ if (!value)
256
+ continue;
257
+ const r = parseAccessEntry(value);
258
+ if (r.ok)
259
+ out.push({ entry: r.entry, line: li });
260
+ }
261
+ return out;
262
+ }
263
+ // ---------------------------------------------------------------------------
264
+ // Public splice operations
265
+ // ---------------------------------------------------------------------------
266
+ /**
267
+ * Add `principal` under `verb`. Idempotent: if an entry with the EXACT same
268
+ * token spelling already exists with the SAME deny-ness (a grant when
269
+ * granting, a deny when denying), returns `changed: false`. Idempotency is
270
+ * deliberately exact-token, never name-level: a bare token and a `role/`
271
+ * token are different principals (group-first precedence gives the bare key
272
+ * to a same-named group), so a bare-`X` GROUP grant must go through even when
273
+ * `role/X` is present, and vice versa. Creates the verb key (and the
274
+ * frontmatter fence, for a fresh file) as needed. Preserves everything else
275
+ * byte-for-byte.
276
+ *
277
+ * `allowScalar` controls whether a fresh single-entry verb may be written in
278
+ * the node-frontmatter scalar form (`owner: Name <email>`). access.md always
279
+ * uses the block-list form; node frontmatter prefers scalar for a lone entry.
280
+ *
281
+ * `deny` writes the entry as a `deny <principal>` denial instead of a grant
282
+ * (the `deny-here` per-item override). The block/scalar/empty-list handling is
283
+ * identical — only the rendered line and the idempotency check differ — so the
284
+ * deny path reuses this engine rather than a parallel `spliceDeny`. NOTE: the
285
+ * resolver lets a same-scope grant override a same-scope deny of the same
286
+ * principal, so a caller adding a deny where a grant already exists must strip
287
+ * that grant first (see `AccessMutationService`); this function only writes the
288
+ * one entry it's asked to.
289
+ */
290
+ export function spliceGrant(text, verb, rawPrincipal, opts = {}) {
291
+ const principal = validatePrincipal(rawPrincipal);
292
+ const deny = opts.deny ?? false;
293
+ const f = splitFrontmatter(text);
294
+ if (!f.hasFrontmatter) {
295
+ // Fresh file — synthesise a minimal frontmatter block, keep any body lines
296
+ // the caller passed (usually none for a new access.md).
297
+ const itemLine = opts.allowScalar
298
+ ? `${verb}: ${renderEntry(principal, deny)}`
299
+ : `${verb}:${f.eol} - ${renderEntry(principal, deny)}`;
300
+ const fenced = ['---', itemLine, '---'].join(f.eol);
301
+ const bodyText = f.post.length ? f.post.join(f.eol) : '';
302
+ const text2 = bodyText ? `${fenced}${f.eol}${bodyText}` : `${fenced}${f.eol}`;
303
+ return { text: text2, changed: true };
304
+ }
305
+ const region = pickRegion(text, f, opts.target ?? 'node');
306
+ const block = findVerbBlock(region.lines, verb);
307
+ const existing = blockEntries(region.lines, block);
308
+ // Idempotency: an entry for this EXACT token with the same deny-ness is
309
+ // already present (a grant when granting, a deny when denying). Exact-token
310
+ // on purpose — see the doc above.
311
+ if (existing.some((e) => entryMatches(e.entry, principal, 'exact') && e.entry.deny === deny)) {
312
+ return { text, changed: false };
313
+ }
314
+ const itemValue = renderEntry(principal, deny);
315
+ if (block.keyLine === -1) {
316
+ // Verb key absent — append a new block at the end of the region.
317
+ const lines = opts.allowScalar ? [`${verb}: ${itemValue}`] : [`${verb}:`, ` - ${itemValue}`];
318
+ region.lines.push(...lines);
319
+ return { text: region.join(), changed: true };
320
+ }
321
+ if (block.inlineScalarValue !== null) {
322
+ // Scalar form — promote to a block list with both the old and new entry.
323
+ const old = block.inlineScalarValue;
324
+ region.lines.splice(block.keyLine, 1, `${verb}:`, ` - ${old}`, ` - ${itemValue}`);
325
+ return { text: region.join(), changed: true };
326
+ }
327
+ // Block-list (possibly inline `[]`). Insert after the last existing item, or
328
+ // right after the key line when the list is currently empty.
329
+ const indent = ' '.repeat(block.itemIndent);
330
+ const newLine = `${indent}- ${itemValue}`;
331
+ if (block.inlineEmpty) {
332
+ // `verb: []` -> `verb:` + one item.
333
+ region.lines[block.keyLine] = `${' '.repeat(block.keyIndent)}${verb}:`;
334
+ region.lines.splice(block.keyLine + 1, 0, newLine);
335
+ return { text: region.join(), changed: true };
336
+ }
337
+ const insertAt = block.itemLines.length > 0 ? block.itemLines[block.itemLines.length - 1] + 1 : block.keyLine + 1;
338
+ region.lines.splice(insertAt, 0, newLine);
339
+ return { text: region.join(), changed: true };
340
+ }
341
+ /**
342
+ * Remove every entry naming `principal` under `verb` (grant or deny). Idempotent:
343
+ * returns `changed: false` when the principal isn't present. If removing the
344
+ * last item empties the verb, the `verb:` key is collapsed to `verb: []` so the
345
+ * file still parses cleanly (the resolver reads `[]` as an empty list).
346
+ * Preserves everything else.
347
+ *
348
+ * Token matching for role-shaped principals is `tokenMatch` (default `'name'`:
349
+ * BOTH spellings — revoking the role removes legacy bare spellings too).
350
+ * Callers pass `'exact'` when a GROUP shadows the principal's bare name: the
351
+ * bare token then belongs to the group and the `role/` token to the role, so a
352
+ * revoke of one must never strip the other (see AccessMutationService, which
353
+ * derives the flag from the merged principal index).
354
+ */
355
+ export function spliceRevoke(text, verb, rawPrincipal, opts = {}) {
356
+ const principal = validatePrincipal(rawPrincipal);
357
+ const tokenMatch = opts.tokenMatch ?? 'name';
358
+ const f = splitFrontmatter(text);
359
+ if (!f.hasFrontmatter)
360
+ return { text, changed: false };
361
+ const region = pickRegion(text, f, opts.target ?? 'node');
362
+ const block = findVerbBlock(region.lines, verb);
363
+ if (block.keyLine === -1)
364
+ return { text, changed: false };
365
+ if (block.inlineScalarValue !== null) {
366
+ const r = parseAccessEntry(block.inlineScalarValue);
367
+ if (r.ok && entryMatches(r.entry, principal, tokenMatch)) {
368
+ // Lone scalar entry removed -> collapse to empty list.
369
+ region.lines[block.keyLine] = `${' '.repeat(block.keyIndent)}${verb}: []`;
370
+ return { text: region.join(), changed: true };
371
+ }
372
+ return { text, changed: false };
373
+ }
374
+ const entries = blockEntries(region.lines, block);
375
+ const victims = entries.filter((e) => entryMatches(e.entry, principal, tokenMatch)).map((e) => e.line);
376
+ if (victims.length === 0)
377
+ return { text, changed: false };
378
+ // Delete from the bottom up so earlier indices stay valid.
379
+ const remaining = block.itemLines.filter((l) => !victims.includes(l));
380
+ for (const line of [...victims].sort((a, b) => b - a))
381
+ region.lines.splice(line, 1);
382
+ if (remaining.length === 0) {
383
+ // Verb block is now empty — collapse `verb:` to `verb: []`. The key line
384
+ // index is unchanged because we only removed lines that came after it.
385
+ region.lines[block.keyLine] = `${' '.repeat(block.keyIndent)}${verb}: []`;
386
+ }
387
+ return { text: region.join(), changed: true };
388
+ }
389
+ //# sourceMappingURL=access-splice.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"access-splice.js","sourceRoot":"","sources":["../../../src/modules/access-model/access-splice.ts"],"names":[],"m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C,CAAC,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;IACtE,KAAK,MAAM,IAAI,IAAI,CAAC,GAAG,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC;QAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;IAEpF,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC3B,yEAAyE;QACzE,uEAAuE;QACvE,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,IAAI,MAAM,CAAC;IAC5E,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAChD,CAAC"}
@@ -0,0 +1,54 @@
1
+ /**
2
+ * The pure half of the creator read-grant story: the creator identity, the
3
+ * grant-plan contract the creation surfaces consume, and the splice-safe
4
+ * principal for a creator. The service that DECIDES when a creation needs a
5
+ * grant (filesystem stats, access checks) is `modules/access/creator-access.ts`;
6
+ * this file carries only the types and pure helpers so downstream modules
7
+ * (kb-fs, plugins, tool-helpers) never need an edge into the access module.
8
+ */
9
+ import type { Principal } from './access-splice.js';
10
+ /**
11
+ * How a pending creation gets its creator read grant.
12
+ * - `seed-access-md`: merge the grant into `wsRelPath` (a new directory's
13
+ * own `access.md`, workspace-relative) — BEFORE or alongside the creation,
14
+ * via the caller's own lock+commit machinery. The caller MUST re-read the
15
+ * file's CURRENT text under its lock and write `apply(current)` ('' when
16
+ * absent), never a precomputed fresh file: two concurrent creators can
17
+ * both plan a seed for the same new directory, and a blind overwrite
18
+ * would silently revoke whichever grant landed first. Skip the write when
19
+ * `apply` returns the input unchanged, and call `noteAccessFileWritten`
20
+ * after a write so the resolver cache drops.
21
+ * - `frontmatter`: run the new file's content through `apply` before
22
+ * writing it, so the grant lands atomically inside the created file.
23
+ */
24
+ export type CreationGrantPlan = {
25
+ kind: 'seed-access-md';
26
+ wsRelPath: string;
27
+ apply: (current: string) => string;
28
+ } | {
29
+ kind: 'frontmatter';
30
+ apply: (content: string) => string;
31
+ };
32
+ /** The creator identity a grant is written for. */
33
+ export interface Creator {
34
+ name: string;
35
+ email: string;
36
+ }
37
+ /**
38
+ * Injection seam for the creation surfaces (routes, lock-aware filesystem,
39
+ * upload apply). Kept as an interface so callers depend on the contract, not
40
+ * the class.
41
+ */
42
+ export interface ICreatorAccess {
43
+ planForCreate(workspaceId: string, creator: Creator, wsRelPath: string, kind: 'file' | 'dir'): Promise<CreationGrantPlan | null>;
44
+ grantInExtractedFile(workspaceId: string, creator: Creator, wsRelPath: string): Promise<string | null>;
45
+ noteAccessFileWritten(workspaceId: string): void;
46
+ }
47
+ /**
48
+ * The splice-safe principal for a creator — exported because plugin
49
+ * provisioning (`PluginProvisionService`) writes the same `Name <email>`
50
+ * entries into the access.md files it seeds, and two spellings of the same
51
+ * person would read as two people.
52
+ */
53
+ export declare function creatorPrincipal(creator: Creator): Principal;
54
+ //# sourceMappingURL=creator.d.ts.map