@braidhq/server 0.1.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (401) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +134 -106
  3. package/dist/app.d.ts +7 -15
  4. package/dist/app.d.ts.map +1 -1
  5. package/dist/app.js +74 -45
  6. package/dist/app.js.map +1 -1
  7. package/dist/authMode.d.ts +39 -0
  8. package/dist/authMode.d.ts.map +1 -0
  9. package/dist/authMode.js +50 -0
  10. package/dist/authMode.js.map +1 -0
  11. package/dist/composeApp.d.ts +80 -0
  12. package/dist/composeApp.d.ts.map +1 -0
  13. package/dist/composeApp.js +137 -0
  14. package/dist/composeApp.js.map +1 -0
  15. package/dist/composeFsApp.d.ts +27 -0
  16. package/dist/composeFsApp.d.ts.map +1 -0
  17. package/dist/{composeFs.js → composeFsApp.js} +127 -126
  18. package/dist/composeFsApp.js.map +1 -0
  19. package/dist/index.d.ts +3 -2
  20. package/dist/index.d.ts.map +1 -1
  21. package/dist/index.js +3 -2
  22. package/dist/index.js.map +1 -1
  23. package/dist/infrastructure/_shared/env.d.ts +10 -0
  24. package/dist/infrastructure/_shared/env.d.ts.map +1 -0
  25. package/dist/infrastructure/{env.js → _shared/env.js} +5 -6
  26. package/dist/infrastructure/_shared/env.js.map +1 -0
  27. package/dist/infrastructure/_shared/frontmatter.d.ts +13 -0
  28. package/dist/infrastructure/_shared/frontmatter.d.ts.map +1 -0
  29. package/dist/infrastructure/{fs → _shared}/frontmatter.js +5 -5
  30. package/dist/infrastructure/_shared/frontmatter.js.map +1 -0
  31. package/dist/infrastructure/_shared/jsonFileStore.d.ts.map +1 -0
  32. package/dist/infrastructure/_shared/jsonFileStore.js.map +1 -0
  33. package/dist/infrastructure/{fs → _shared}/paths.d.ts +17 -10
  34. package/dist/infrastructure/_shared/paths.d.ts.map +1 -0
  35. package/dist/infrastructure/{fs → _shared}/paths.js +27 -20
  36. package/dist/infrastructure/_shared/paths.js.map +1 -0
  37. package/dist/infrastructure/auth/AccessPolicy.d.ts +33 -58
  38. package/dist/infrastructure/auth/AccessPolicy.d.ts.map +1 -1
  39. package/dist/infrastructure/auth/AccessPolicy.js +35 -42
  40. package/dist/infrastructure/auth/AccessPolicy.js.map +1 -1
  41. package/dist/infrastructure/auth/SessionStore.d.ts +22 -12
  42. package/dist/infrastructure/auth/SessionStore.d.ts.map +1 -1
  43. package/dist/infrastructure/auth/SessionStore.js +20 -20
  44. package/dist/infrastructure/auth/SessionStore.js.map +1 -1
  45. package/dist/infrastructure/batch/FsBatchPlanRepository.d.ts +14 -0
  46. package/dist/infrastructure/batch/FsBatchPlanRepository.d.ts.map +1 -0
  47. package/dist/infrastructure/{fs → batch}/FsBatchPlanRepository.js +9 -7
  48. package/dist/infrastructure/batch/FsBatchPlanRepository.js.map +1 -0
  49. package/dist/infrastructure/history/GitWorkspaceHistory.d.ts.map +1 -0
  50. package/dist/infrastructure/{git → history}/GitWorkspaceHistory.js +31 -24
  51. package/dist/infrastructure/history/GitWorkspaceHistory.js.map +1 -0
  52. package/dist/infrastructure/history/commitMessage.d.ts.map +1 -0
  53. package/dist/infrastructure/history/commitMessage.js +90 -0
  54. package/dist/infrastructure/history/commitMessage.js.map +1 -0
  55. package/dist/infrastructure/hitl/FsClarificationRepository.d.ts +13 -0
  56. package/dist/infrastructure/hitl/FsClarificationRepository.d.ts.map +1 -0
  57. package/dist/infrastructure/hitl/FsClarificationRepository.js +40 -0
  58. package/dist/infrastructure/hitl/FsClarificationRepository.js.map +1 -0
  59. package/dist/infrastructure/hitl/FsProposalRepository.d.ts.map +1 -0
  60. package/dist/infrastructure/{fs → hitl}/FsProposalRepository.js +8 -8
  61. package/dist/infrastructure/hitl/FsProposalRepository.js.map +1 -0
  62. package/dist/infrastructure/hitl/StatusedJsonStore.d.ts +30 -0
  63. package/dist/infrastructure/hitl/StatusedJsonStore.d.ts.map +1 -0
  64. package/dist/infrastructure/{fs/FsStatusedJsonRepository.js → hitl/StatusedJsonStore.js} +3 -3
  65. package/dist/infrastructure/hitl/StatusedJsonStore.js.map +1 -0
  66. package/dist/infrastructure/model/FsModelSerializer.d.ts +94 -0
  67. package/dist/infrastructure/model/FsModelSerializer.d.ts.map +1 -0
  68. package/dist/infrastructure/{fs/FsGraphSerializer.js → model/FsModelSerializer.js} +11 -11
  69. package/dist/infrastructure/model/FsModelSerializer.js.map +1 -0
  70. package/dist/infrastructure/oauth/GoogleOAuth.d.ts +20 -38
  71. package/dist/infrastructure/oauth/GoogleOAuth.d.ts.map +1 -1
  72. package/dist/infrastructure/oauth/GoogleOAuth.js +21 -22
  73. package/dist/infrastructure/oauth/GoogleOAuth.js.map +1 -1
  74. package/dist/infrastructure/reactor/FsReactorCycleRepository.d.ts +29 -0
  75. package/dist/infrastructure/reactor/FsReactorCycleRepository.d.ts.map +1 -0
  76. package/dist/infrastructure/reactor/FsReactorCycleRepository.js +94 -0
  77. package/dist/infrastructure/reactor/FsReactorCycleRepository.js.map +1 -0
  78. package/dist/infrastructure/secrets/SecretStore.d.ts +11 -14
  79. package/dist/infrastructure/secrets/SecretStore.d.ts.map +1 -1
  80. package/dist/infrastructure/secrets/SecretStore.js +4 -4
  81. package/dist/infrastructure/secrets/SecretStore.js.map +1 -1
  82. package/dist/infrastructure/{fs → skill}/FsRunRepository.d.ts +5 -3
  83. package/dist/infrastructure/skill/FsRunRepository.d.ts.map +1 -0
  84. package/dist/infrastructure/{fs → skill}/FsRunRepository.js +11 -9
  85. package/dist/infrastructure/skill/FsRunRepository.js.map +1 -0
  86. package/dist/infrastructure/{fs → skill}/FsSkillRegistry.d.ts +4 -13
  87. package/dist/infrastructure/skill/FsSkillRegistry.d.ts.map +1 -0
  88. package/dist/infrastructure/{fs → skill}/FsSkillRegistry.js +28 -20
  89. package/dist/infrastructure/skill/FsSkillRegistry.js.map +1 -0
  90. package/dist/infrastructure/skill/SubprocessSkillRunner.d.ts +52 -0
  91. package/dist/infrastructure/skill/SubprocessSkillRunner.d.ts.map +1 -0
  92. package/dist/infrastructure/{agent → skill}/SubprocessSkillRunner.js +107 -55
  93. package/dist/infrastructure/skill/SubprocessSkillRunner.js.map +1 -0
  94. package/dist/infrastructure/skill/asyncQueue.d.ts +20 -0
  95. package/dist/infrastructure/skill/asyncQueue.d.ts.map +1 -0
  96. package/dist/infrastructure/{agent → skill}/asyncQueue.js +2 -3
  97. package/dist/infrastructure/{agent → skill}/asyncQueue.js.map +1 -1
  98. package/dist/infrastructure/skill/lineBuffer.d.ts +15 -0
  99. package/dist/infrastructure/skill/lineBuffer.d.ts.map +1 -0
  100. package/dist/infrastructure/{agent/streamJsonParser.js → skill/lineBuffer.js} +5 -17
  101. package/dist/infrastructure/skill/lineBuffer.js.map +1 -0
  102. package/dist/infrastructure/skill/orphanReaper.d.ts +20 -0
  103. package/dist/infrastructure/skill/orphanReaper.d.ts.map +1 -0
  104. package/dist/infrastructure/{orphanReaper.js → skill/orphanReaper.js} +7 -5
  105. package/dist/infrastructure/skill/orphanReaper.js.map +1 -0
  106. package/dist/infrastructure/skill/subprocessEventStream.d.ts +16 -0
  107. package/dist/infrastructure/skill/subprocessEventStream.d.ts.map +1 -0
  108. package/dist/infrastructure/skill/subprocessEventStream.js +29 -0
  109. package/dist/infrastructure/skill/subprocessEventStream.js.map +1 -0
  110. package/dist/infrastructure/source/FsSourceUnitDigest.d.ts +19 -0
  111. package/dist/infrastructure/source/FsSourceUnitDigest.d.ts.map +1 -0
  112. package/dist/infrastructure/{fs → source}/FsSourceUnitDigest.js +9 -9
  113. package/dist/infrastructure/source/FsSourceUnitDigest.js.map +1 -0
  114. package/dist/infrastructure/source/FsSourceUnitObservationRepository.d.ts +31 -0
  115. package/dist/infrastructure/source/FsSourceUnitObservationRepository.d.ts.map +1 -0
  116. package/dist/infrastructure/{fs/FsSourceUnitStateRepository.js → source/FsSourceUnitObservationRepository.js} +18 -17
  117. package/dist/infrastructure/source/FsSourceUnitObservationRepository.js.map +1 -0
  118. package/dist/infrastructure/source/unitScan.d.ts +11 -0
  119. package/dist/infrastructure/source/unitScan.d.ts.map +1 -0
  120. package/dist/infrastructure/{fs/intentScan.js → source/unitScan.js} +36 -27
  121. package/dist/infrastructure/source/unitScan.js.map +1 -0
  122. package/dist/infrastructure/users/UserDirectoryFromRegistry.d.ts +2 -2
  123. package/dist/infrastructure/users/UserDirectoryFromRegistry.d.ts.map +1 -1
  124. package/dist/infrastructure/users/UserDirectoryFromRegistry.js +3 -2
  125. package/dist/infrastructure/users/UserDirectoryFromRegistry.js.map +1 -1
  126. package/dist/infrastructure/users/UserRegistryFile.d.ts +4 -5
  127. package/dist/infrastructure/users/UserRegistryFile.d.ts.map +1 -1
  128. package/dist/infrastructure/users/UserRegistryFile.js +6 -8
  129. package/dist/infrastructure/users/UserRegistryFile.js.map +1 -1
  130. package/dist/infrastructure/users/ensureWorkspaceOwners.d.ts +9 -6
  131. package/dist/infrastructure/users/ensureWorkspaceOwners.d.ts.map +1 -1
  132. package/dist/infrastructure/users/ensureWorkspaceOwners.js +10 -7
  133. package/dist/infrastructure/users/ensureWorkspaceOwners.js.map +1 -1
  134. package/dist/infrastructure/workspace/FsWorkspaceRepository.d.ts.map +1 -0
  135. package/dist/infrastructure/{fs → workspace}/FsWorkspaceRepository.js +7 -6
  136. package/dist/infrastructure/workspace/FsWorkspaceRepository.js.map +1 -0
  137. package/dist/infrastructure/workspace/WorkspaceDiscovery.d.ts +18 -0
  138. package/dist/infrastructure/workspace/WorkspaceDiscovery.d.ts.map +1 -0
  139. package/dist/infrastructure/{fs → workspace}/WorkspaceDiscovery.js +15 -11
  140. package/dist/infrastructure/workspace/WorkspaceDiscovery.js.map +1 -0
  141. package/dist/infrastructure/{fs → workspace}/WorkspaceRegistryFile.d.ts +10 -9
  142. package/dist/infrastructure/workspace/WorkspaceRegistryFile.d.ts.map +1 -0
  143. package/dist/infrastructure/{fs → workspace}/WorkspaceRegistryFile.js +15 -17
  144. package/dist/infrastructure/workspace/WorkspaceRegistryFile.js.map +1 -0
  145. package/dist/infrastructure/workspace/productManifestWriter.d.ts +24 -0
  146. package/dist/infrastructure/workspace/productManifestWriter.d.ts.map +1 -0
  147. package/dist/infrastructure/{fs → workspace}/productManifestWriter.js +14 -26
  148. package/dist/infrastructure/workspace/productManifestWriter.js.map +1 -0
  149. package/dist/middleware/auth.d.ts +27 -17
  150. package/dist/middleware/auth.d.ts.map +1 -1
  151. package/dist/middleware/auth.js +69 -53
  152. package/dist/middleware/auth.js.map +1 -1
  153. package/dist/middleware/cors.d.ts.map +1 -1
  154. package/dist/middleware/cors.js +4 -1
  155. package/dist/middleware/cors.js.map +1 -1
  156. package/dist/middleware/error.d.ts.map +1 -1
  157. package/dist/middleware/error.js +15 -13
  158. package/dist/middleware/error.js.map +1 -1
  159. package/dist/middleware/workspaceAccess.d.ts +23 -19
  160. package/dist/middleware/workspaceAccess.d.ts.map +1 -1
  161. package/dist/middleware/workspaceAccess.js +31 -26
  162. package/dist/middleware/workspaceAccess.js.map +1 -1
  163. package/dist/policy/CapabilityCheck.d.ts +5 -5
  164. package/dist/policy/PermissionRegistry.d.ts +11 -9
  165. package/dist/policy/PermissionRegistry.d.ts.map +1 -1
  166. package/dist/policy/PermissionRegistry.js +10 -8
  167. package/dist/policy/PermissionRegistry.js.map +1 -1
  168. package/dist/policy/ViewerContext.d.ts +13 -11
  169. package/dist/policy/ViewerContext.d.ts.map +1 -1
  170. package/dist/policy/checks.d.ts +9 -9
  171. package/dist/policy/checks.d.ts.map +1 -1
  172. package/dist/policy/checks.js +14 -11
  173. package/dist/policy/checks.js.map +1 -1
  174. package/dist/policy/defaultRegistry.d.ts +3 -4
  175. package/dist/policy/defaultRegistry.d.ts.map +1 -1
  176. package/dist/policy/defaultRegistry.js +3 -4
  177. package/dist/policy/defaultRegistry.js.map +1 -1
  178. package/dist/policy/index.d.ts +2 -2
  179. package/dist/policy/index.d.ts.map +1 -1
  180. package/dist/policy/index.js +1 -1
  181. package/dist/policy/index.js.map +1 -1
  182. package/dist/policy/resolveViewer.d.ts +9 -9
  183. package/dist/policy/resolveViewer.js +9 -9
  184. package/dist/routes/_shared.d.ts +93 -153
  185. package/dist/routes/_shared.d.ts.map +1 -1
  186. package/dist/routes/_shared.js +9 -5
  187. package/dist/routes/_shared.js.map +1 -1
  188. package/dist/routes/admin.d.ts +1 -1
  189. package/dist/routes/admin.d.ts.map +1 -1
  190. package/dist/routes/admin.js +13 -12
  191. package/dist/routes/admin.js.map +1 -1
  192. package/dist/routes/auth.d.ts +12 -10
  193. package/dist/routes/auth.d.ts.map +1 -1
  194. package/dist/routes/auth.js +32 -34
  195. package/dist/routes/auth.js.map +1 -1
  196. package/dist/routes/clarifications.d.ts +8 -0
  197. package/dist/routes/clarifications.d.ts.map +1 -0
  198. package/dist/routes/clarifications.js +246 -0
  199. package/dist/routes/clarifications.js.map +1 -0
  200. package/dist/routes/edges.d.ts.map +1 -1
  201. package/dist/routes/edges.js +2 -6
  202. package/dist/routes/edges.js.map +1 -1
  203. package/dist/routes/history.d.ts.map +1 -1
  204. package/dist/routes/history.js +12 -10
  205. package/dist/routes/history.js.map +1 -1
  206. package/dist/routes/nodes.d.ts.map +1 -1
  207. package/dist/routes/nodes.js +4 -8
  208. package/dist/routes/nodes.js.map +1 -1
  209. package/dist/routes/oauth.d.ts +6 -7
  210. package/dist/routes/oauth.d.ts.map +1 -1
  211. package/dist/routes/oauth.js +6 -7
  212. package/dist/routes/oauth.js.map +1 -1
  213. package/dist/routes/ontologies.d.ts +7 -0
  214. package/dist/routes/ontologies.d.ts.map +1 -0
  215. package/dist/routes/ontologies.js +29 -0
  216. package/dist/routes/ontologies.js.map +1 -0
  217. package/dist/routes/ontology.d.ts.map +1 -1
  218. package/dist/routes/ontology.js +2 -1
  219. package/dist/routes/ontology.js.map +1 -1
  220. package/dist/routes/proposals.d.ts +2 -2
  221. package/dist/routes/proposals.d.ts.map +1 -1
  222. package/dist/routes/proposals.js +35 -30
  223. package/dist/routes/proposals.js.map +1 -1
  224. package/dist/routes/reactorCycles.d.ts +7 -0
  225. package/dist/routes/reactorCycles.d.ts.map +1 -0
  226. package/dist/routes/reactorCycles.js +60 -0
  227. package/dist/routes/reactorCycles.js.map +1 -0
  228. package/dist/routes/runs.d.ts.map +1 -1
  229. package/dist/routes/runs.js +22 -19
  230. package/dist/routes/runs.js.map +1 -1
  231. package/dist/routes/skillInputOptions.d.ts +2 -2
  232. package/dist/routes/skillInputOptions.d.ts.map +1 -1
  233. package/dist/routes/skillInputOptions.js +53 -53
  234. package/dist/routes/skillInputOptions.js.map +1 -1
  235. package/dist/routes/skills.d.ts +19 -1
  236. package/dist/routes/skills.d.ts.map +1 -1
  237. package/dist/routes/skills.js +141 -7
  238. package/dist/routes/skills.js.map +1 -1
  239. package/dist/routes/sourceLoaders.d.ts.map +1 -1
  240. package/dist/routes/sourceLoaders.js +1 -0
  241. package/dist/routes/sourceLoaders.js.map +1 -1
  242. package/dist/routes/sourceUnitObservations.d.ts +20 -0
  243. package/dist/routes/sourceUnitObservations.d.ts.map +1 -0
  244. package/dist/routes/sourceUnitObservations.js +80 -0
  245. package/dist/routes/sourceUnitObservations.js.map +1 -0
  246. package/dist/routes/sourceWebhooks.d.ts +26 -0
  247. package/dist/routes/sourceWebhooks.d.ts.map +1 -0
  248. package/dist/routes/sourceWebhooks.js +301 -0
  249. package/dist/routes/sourceWebhooks.js.map +1 -0
  250. package/dist/routes/users.d.ts +0 -2
  251. package/dist/routes/users.d.ts.map +1 -1
  252. package/dist/routes/users.js +15 -33
  253. package/dist/routes/users.js.map +1 -1
  254. package/dist/routes/workspaceEvents.d.ts +5 -4
  255. package/dist/routes/workspaceEvents.d.ts.map +1 -1
  256. package/dist/routes/workspaceEvents.js +7 -6
  257. package/dist/routes/workspaceEvents.js.map +1 -1
  258. package/dist/routes/workspaceMembers.d.ts +1 -1
  259. package/dist/routes/workspaceMembers.d.ts.map +1 -1
  260. package/dist/routes/workspaceMembers.js +2 -2
  261. package/dist/routes/workspaceMembers.js.map +1 -1
  262. package/dist/routes/workspaces.d.ts +21 -10
  263. package/dist/routes/workspaces.d.ts.map +1 -1
  264. package/dist/routes/workspaces.js +95 -69
  265. package/dist/routes/workspaces.js.map +1 -1
  266. package/dist/server.js +6 -70
  267. package/dist/server.js.map +1 -1
  268. package/dist/serviceAccounts.d.ts +13 -0
  269. package/dist/serviceAccounts.d.ts.map +1 -0
  270. package/dist/serviceAccounts.js +26 -0
  271. package/dist/serviceAccounts.js.map +1 -0
  272. package/dist/startServer.d.ts +17 -0
  273. package/dist/startServer.d.ts.map +1 -0
  274. package/dist/startServer.js +81 -0
  275. package/dist/startServer.js.map +1 -0
  276. package/dist/startup.d.ts +28 -0
  277. package/dist/startup.d.ts.map +1 -0
  278. package/dist/startup.js +94 -0
  279. package/dist/startup.js.map +1 -0
  280. package/package.json +35 -40
  281. package/dist/composeFs.d.ts +0 -55
  282. package/dist/composeFs.d.ts.map +0 -1
  283. package/dist/composeFs.js.map +0 -1
  284. package/dist/composition.d.ts +0 -133
  285. package/dist/composition.d.ts.map +0 -1
  286. package/dist/composition.js +0 -113
  287. package/dist/composition.js.map +0 -1
  288. package/dist/infrastructure/agent/SubprocessSkillRunner.d.ts +0 -75
  289. package/dist/infrastructure/agent/SubprocessSkillRunner.d.ts.map +0 -1
  290. package/dist/infrastructure/agent/SubprocessSkillRunner.js.map +0 -1
  291. package/dist/infrastructure/agent/asyncQueue.d.ts +0 -22
  292. package/dist/infrastructure/agent/asyncQueue.d.ts.map +0 -1
  293. package/dist/infrastructure/agent/mcpConfig.d.ts +0 -38
  294. package/dist/infrastructure/agent/mcpConfig.d.ts.map +0 -1
  295. package/dist/infrastructure/agent/mcpConfig.js +0 -55
  296. package/dist/infrastructure/agent/mcpConfig.js.map +0 -1
  297. package/dist/infrastructure/agent/streamJsonParser.d.ts +0 -20
  298. package/dist/infrastructure/agent/streamJsonParser.d.ts.map +0 -1
  299. package/dist/infrastructure/agent/streamJsonParser.js.map +0 -1
  300. package/dist/infrastructure/agent/subprocessEventStream.d.ts +0 -26
  301. package/dist/infrastructure/agent/subprocessEventStream.d.ts.map +0 -1
  302. package/dist/infrastructure/agent/subprocessEventStream.js +0 -112
  303. package/dist/infrastructure/agent/subprocessEventStream.js.map +0 -1
  304. package/dist/infrastructure/auth/ensureApprovedEmails.d.ts +0 -16
  305. package/dist/infrastructure/auth/ensureApprovedEmails.d.ts.map +0 -1
  306. package/dist/infrastructure/auth/ensureApprovedEmails.js +0 -20
  307. package/dist/infrastructure/auth/ensureApprovedEmails.js.map +0 -1
  308. package/dist/infrastructure/env.d.ts +0 -11
  309. package/dist/infrastructure/env.d.ts.map +0 -1
  310. package/dist/infrastructure/env.js.map +0 -1
  311. package/dist/infrastructure/fs/FsBatchPlanRepository.d.ts +0 -300
  312. package/dist/infrastructure/fs/FsBatchPlanRepository.d.ts.map +0 -1
  313. package/dist/infrastructure/fs/FsBatchPlanRepository.js.map +0 -1
  314. package/dist/infrastructure/fs/FsClarifyTicketRepository.d.ts +0 -13
  315. package/dist/infrastructure/fs/FsClarifyTicketRepository.d.ts.map +0 -1
  316. package/dist/infrastructure/fs/FsClarifyTicketRepository.js +0 -39
  317. package/dist/infrastructure/fs/FsClarifyTicketRepository.js.map +0 -1
  318. package/dist/infrastructure/fs/FsDecisionRepository.d.ts +0 -13
  319. package/dist/infrastructure/fs/FsDecisionRepository.d.ts.map +0 -1
  320. package/dist/infrastructure/fs/FsDecisionRepository.js +0 -56
  321. package/dist/infrastructure/fs/FsDecisionRepository.js.map +0 -1
  322. package/dist/infrastructure/fs/FsGraphSerializer.d.ts +0 -629
  323. package/dist/infrastructure/fs/FsGraphSerializer.d.ts.map +0 -1
  324. package/dist/infrastructure/fs/FsGraphSerializer.js.map +0 -1
  325. package/dist/infrastructure/fs/FsProposalRepository.d.ts.map +0 -1
  326. package/dist/infrastructure/fs/FsProposalRepository.js.map +0 -1
  327. package/dist/infrastructure/fs/FsRunRepository.d.ts.map +0 -1
  328. package/dist/infrastructure/fs/FsRunRepository.js.map +0 -1
  329. package/dist/infrastructure/fs/FsSkillRegistry.d.ts.map +0 -1
  330. package/dist/infrastructure/fs/FsSkillRegistry.js.map +0 -1
  331. package/dist/infrastructure/fs/FsSourceUnitDigest.d.ts +0 -19
  332. package/dist/infrastructure/fs/FsSourceUnitDigest.d.ts.map +0 -1
  333. package/dist/infrastructure/fs/FsSourceUnitDigest.js.map +0 -1
  334. package/dist/infrastructure/fs/FsSourceUnitStateRepository.d.ts +0 -30
  335. package/dist/infrastructure/fs/FsSourceUnitStateRepository.d.ts.map +0 -1
  336. package/dist/infrastructure/fs/FsSourceUnitStateRepository.js.map +0 -1
  337. package/dist/infrastructure/fs/FsStatusedJsonRepository.d.ts +0 -35
  338. package/dist/infrastructure/fs/FsStatusedJsonRepository.d.ts.map +0 -1
  339. package/dist/infrastructure/fs/FsStatusedJsonRepository.js.map +0 -1
  340. package/dist/infrastructure/fs/FsWorkspaceRepository.d.ts.map +0 -1
  341. package/dist/infrastructure/fs/FsWorkspaceRepository.js.map +0 -1
  342. package/dist/infrastructure/fs/WorkspaceDiscovery.d.ts +0 -15
  343. package/dist/infrastructure/fs/WorkspaceDiscovery.d.ts.map +0 -1
  344. package/dist/infrastructure/fs/WorkspaceDiscovery.js.map +0 -1
  345. package/dist/infrastructure/fs/WorkspaceRegistryFile.d.ts.map +0 -1
  346. package/dist/infrastructure/fs/WorkspaceRegistryFile.js.map +0 -1
  347. package/dist/infrastructure/fs/frontmatter.d.ts +0 -13
  348. package/dist/infrastructure/fs/frontmatter.d.ts.map +0 -1
  349. package/dist/infrastructure/fs/frontmatter.js.map +0 -1
  350. package/dist/infrastructure/fs/intentScan.d.ts +0 -9
  351. package/dist/infrastructure/fs/intentScan.d.ts.map +0 -1
  352. package/dist/infrastructure/fs/intentScan.js.map +0 -1
  353. package/dist/infrastructure/fs/jsonFileStore.d.ts.map +0 -1
  354. package/dist/infrastructure/fs/jsonFileStore.js.map +0 -1
  355. package/dist/infrastructure/fs/paths.d.ts.map +0 -1
  356. package/dist/infrastructure/fs/paths.js.map +0 -1
  357. package/dist/infrastructure/fs/productManifestWriter.d.ts +0 -22
  358. package/dist/infrastructure/fs/productManifestWriter.d.ts.map +0 -1
  359. package/dist/infrastructure/fs/productManifestWriter.js.map +0 -1
  360. package/dist/infrastructure/git/GitWorkspaceHistory.d.ts.map +0 -1
  361. package/dist/infrastructure/git/GitWorkspaceHistory.js.map +0 -1
  362. package/dist/infrastructure/git/commitMessage.d.ts.map +0 -1
  363. package/dist/infrastructure/git/commitMessage.js +0 -71
  364. package/dist/infrastructure/git/commitMessage.js.map +0 -1
  365. package/dist/infrastructure/orphanReaper.d.ts +0 -18
  366. package/dist/infrastructure/orphanReaper.d.ts.map +0 -1
  367. package/dist/infrastructure/orphanReaper.js.map +0 -1
  368. package/dist/infrastructure/users/ensureLocalUser.d.ts +0 -15
  369. package/dist/infrastructure/users/ensureLocalUser.d.ts.map +0 -1
  370. package/dist/infrastructure/users/ensureLocalUser.js +0 -38
  371. package/dist/infrastructure/users/ensureLocalUser.js.map +0 -1
  372. package/dist/middleware/requireAdmin.d.ts +0 -10
  373. package/dist/middleware/requireAdmin.d.ts.map +0 -1
  374. package/dist/middleware/requireAdmin.js +0 -24
  375. package/dist/middleware/requireAdmin.js.map +0 -1
  376. package/dist/middleware/userId.d.ts +0 -16
  377. package/dist/middleware/userId.d.ts.map +0 -1
  378. package/dist/middleware/userId.js +0 -27
  379. package/dist/middleware/userId.js.map +0 -1
  380. package/dist/policy/Capability.d.ts +0 -12
  381. package/dist/policy/Capability.d.ts.map +0 -1
  382. package/dist/policy/Capability.js +0 -31
  383. package/dist/policy/Capability.js.map +0 -1
  384. package/dist/routes/clarify.d.ts +0 -9
  385. package/dist/routes/clarify.d.ts.map +0 -1
  386. package/dist/routes/clarify.js +0 -274
  387. package/dist/routes/clarify.js.map +0 -1
  388. package/dist/routes/decisions.d.ts +0 -7
  389. package/dist/routes/decisions.d.ts.map +0 -1
  390. package/dist/routes/decisions.js +0 -68
  391. package/dist/routes/decisions.js.map +0 -1
  392. package/dist/routes/sourceUnitStates.d.ts +0 -7
  393. package/dist/routes/sourceUnitStates.d.ts.map +0 -1
  394. package/dist/routes/sourceUnitStates.js +0 -45
  395. package/dist/routes/sourceUnitStates.js.map +0 -1
  396. /package/dist/infrastructure/{fs → _shared}/jsonFileStore.d.ts +0 -0
  397. /package/dist/infrastructure/{fs → _shared}/jsonFileStore.js +0 -0
  398. /package/dist/infrastructure/{git → history}/GitWorkspaceHistory.d.ts +0 -0
  399. /package/dist/infrastructure/{git → history}/commitMessage.d.ts +0 -0
  400. /package/dist/infrastructure/{fs → hitl}/FsProposalRepository.d.ts +0 -0
  401. /package/dist/infrastructure/{fs → workspace}/FsWorkspaceRepository.d.ts +0 -0
@@ -1,20 +1,22 @@
1
- import { BraidError, ConflictError, NotFoundError, ValidationError, } from '@braidhq/core';
1
+ import { BraidError, ValidationError } from '@braidhq/core';
2
2
  import { ZodError } from 'zod';
3
3
  const PROBLEM_BASE_URL = 'https://braid.dev/errors';
4
- function statusFor(error) {
5
- if (error instanceof ValidationError)
6
- return 400;
7
- if (error instanceof NotFoundError)
8
- return 404;
9
- if (error instanceof ConflictError)
10
- return 409;
11
- return 500;
12
- }
4
+ // The HTTP status per error code, keyed by the closed BraidErrorCode enum,
5
+ // so a new code fails to compile until it is mapped here.
6
+ const STATUS_BY_CODE = {
7
+ 'BRAID-VALIDATION': 400,
8
+ 'BRAID-UNAUTHORIZED': 401,
9
+ 'BRAID-NOT-FOUND': 404,
10
+ 'BRAID-CONFLICT': 409,
11
+ 'BRAID-FORBIDDEN': 403,
12
+ 'BRAID-UNAVAILABLE': 503,
13
+ 'BRAID-INTERNAL': 500,
14
+ };
13
15
  function problemFromBraidError(error) {
14
16
  const problem = {
15
17
  type: `${PROBLEM_BASE_URL}/${error.code.toLowerCase()}`,
16
18
  title: error.name,
17
- status: statusFor(error),
19
+ status: STATUS_BY_CODE[error.code],
18
20
  code: error.code,
19
21
  detail: error.message,
20
22
  };
@@ -24,10 +26,10 @@ function problemFromBraidError(error) {
24
26
  }
25
27
  function problemFromZodError(error) {
26
28
  return {
27
- type: `${PROBLEM_BASE_URL}/braid-val`,
29
+ type: `${PROBLEM_BASE_URL}/braid-validation`,
28
30
  title: 'ValidationError',
29
31
  status: 400,
30
- code: 'BRAID-VAL',
32
+ code: 'BRAID-VALIDATION',
31
33
  detail: error.issues.map(issue => `${issue.path.join('.')}: ${issue.message}`).join('; '),
32
34
  };
33
35
  }
@@ -1 +1 @@
1
- {"version":3,"file":"error.js","sourceRoot":"","sources":["../../src/middleware/error.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,UAAU,EACV,aAAa,EACb,aAAa,EACb,eAAe,GAChB,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAA;AAE9B,MAAM,gBAAgB,GAAG,0BAA0B,CAAA;AAEnD,SAAS,SAAS,CAAC,KAAiB;IAClC,IAAI,KAAK,YAAY,eAAe;QAClC,OAAO,GAAG,CAAA;IACZ,IAAI,KAAK,YAAY,aAAa;QAChC,OAAO,GAAG,CAAA;IACZ,IAAI,KAAK,YAAY,aAAa;QAChC,OAAO,GAAG,CAAA;IACZ,OAAO,GAAG,CAAA;AACZ,CAAC;AAED,SAAS,qBAAqB,CAAC,KAAiB;IAC9C,MAAM,OAAO,GAAqB;QAChC,IAAI,EAAE,GAAG,gBAAgB,IAAI,KAAK,CAAC,IAAI,CAAC,WAAW,EAAE,EAA8B;QACnF,KAAK,EAAE,KAAK,CAAC,IAAI;QACjB,MAAM,EAAE,SAAS,CAAC,KAAK,CAAC;QACxB,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,MAAM,EAAE,KAAK,CAAC,OAAO;KACtB,CAAA;IACD,IAAI,KAAK,YAAY,eAAe,IAAI,KAAK,CAAC,MAAM;QAClD,OAAO,CAAC,MAAM,GAAG,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,CAAA;IACpC,OAAO,OAAO,CAAA;AAChB,C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AC,IAAI,CAAC,GAAG,CAAC,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;KAC1F,CAAA;AACH,CAAC;AAED,MAAM,oBAAoB,GAAG,EAAE,cAAc,EAAE,0BAA0B,EAAW,CAAA;AAEpF,MAAM,CAAC,MAAM,YAAY,GAAiB,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;IAC3D,IAAI,KAAK,YAAY,UAAU,EAAE,CAAC;QAChC,MAAM,OAAO,GAAG,qBAAqB,CAAC,KAAK,CAAC,CAAA;QAC5C,OAAO,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,MAA8B,EAAE,oBAAoB,CAAC,CAAA;IAC5F,CAAC;IAED,IAAI,KAAK,YAAY,QAAQ,EAAE,CAAC;QAC9B,MAAM,OAAO,GAAG,mBAAmB,CAAC,KAAK,CAAC,CAAA;QAC1C,OAAO,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,MAA8B,EAAE,oBAAoB,CAAC,CAAA;IAC5F,CAAC;IAED,OAAO,OAAO,CAAC,IAAI,CAAC;QAClB,IAAI,EAAE,GAAG,gBAAgB,WAAW;QACpC,KAAK,EAAE,eAAe;QACtB,MAAM,EAAE,GAAG;QACX,IAAI,EAAE,gBAAgB;QACtB,MAAM,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe;KACjE,EAAE,GAAG,EAAE,oBAAoB,CAAC,CAAA;AAC/B,CAAC,CAAA"}
@@ -1,16 +1,18 @@
1
1
  import type { WorkspaceService } from '@braidhq/core';
2
2
  import type { Context, MiddlewareHandler } from 'hono';
3
- import type { WorkspaceRegistryFile } from '../infrastructure/fs/WorkspaceRegistryFile.js';
4
3
  import type { UserRegistryFile } from '../infrastructure/users/UserRegistryFile.js';
4
+ import type { WorkspaceRegistryFile } from '../infrastructure/workspace/WorkspaceRegistryFile.js';
5
5
  import type { Capability, ViewerContext } from '../policy/index.js';
6
6
  /**
7
- * Server-scope capability guard. Used for actions that happen without
8
- * a workspace context (e.g. workspace creation). Builds a viewer with
9
- * member=undefined; non-admin users resolve to effectiveRole=null and
10
- * fail every check by construction.
7
+ * Server-scope capability guard for actions without a workspace context,
8
+ * such as workspace creation.
9
+ * Builds a viewer with an absent member,
10
+ * so non-admin users resolve to a null effectiveRole,
11
+ * and fail every check by construction.
11
12
  *
12
- * Skips the gate when userRegistry isn't provided so in-memory test
13
- * compositions stay open. Production deployments always pass it.
13
+ * Skips the gate when userRegistry is absent,
14
+ * so in-memory test compositions stay open.
15
+ * Production deployments always pass it.
14
16
  */
15
17
  export declare function requireServerCapability(capability: Capability, userRegistry: UserRegistryFile | undefined): MiddlewareHandler;
16
18
  declare module 'hono' {
@@ -24,24 +26,26 @@ export interface WorkspaceAccessOptions {
24
26
  readonly userRegistry: UserRegistryFile;
25
27
  }
26
28
  /**
27
- * Resolves the caller's ViewerContext for this workspace and stashes
28
- * it on the Hono context for every downstream layer to read. Composes
29
- * after `workspaceIdMiddleware` + `userIdMiddleware`. Outsiders (no
30
- * member row + not a server admin) get 403 here.
29
+ * Resolves the caller's ViewerContext for this workspace,
30
+ * and stashes it on the Hono context for every downstream layer to read.
31
+ * Composes after `workspaceIdMiddleware` and `authMiddleware`.
32
+ * Outsiders get 403 here, meaning no member row and not a server admin.
31
33
  *
32
- * The actual policy decisions live in `policy/`; this middleware just
33
- * builds the viewer and rejects unauthenticated outsiders.
34
+ * The actual policy decisions live in `policy/`.
35
+ * This middleware only builds the viewer,
36
+ * and rejects unauthenticated outsiders.
34
37
  */
35
38
  export declare function workspaceAccessMiddleware(options: WorkspaceAccessOptions): MiddlewareHandler;
36
39
  export declare function getViewerContext(context: Context): ViewerContext | undefined;
37
40
  /**
38
- * Mutation guard. Returns 403 if the viewer can't perform the given
39
- * capability. Optional `buildResource` lets specific capabilities
40
- * (e.g. `skill.run`) attach per-request data the check needs.
41
+ * Mutation guard.
42
+ * Returns 403 when the viewer cannot perform the given capability.
43
+ * Optional `buildResource` lets a capability such as `skill.run`
44
+ * attach per-request data the check needs.
41
45
  *
42
- * Test compositions that don't mount `workspaceAccessMiddleware`
43
- * (in-memory tests, headless server) skip the gate. Production
44
- * deployments always mount the access middleware so the gate is real.
46
+ * Compositions that don't mount `workspaceAccessMiddleware`,
47
+ * such as in-memory tests or the headless server, skip the gate.
48
+ * Production deployments always mount it, so the gate is real.
45
49
  */
46
50
  export declare function requirePermission(capability: Capability, buildResource?: (context: Context) => Promise<ViewerContext['resource']>): MiddlewareHandler;
47
51
  //# sourceMappingURL=workspaceAccess.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"workspaceAccess.d.ts","sourceRoot":"","sources":["../../src/middleware/workspaceAccess.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AACrD,OAAO,KAAK,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAA;AACtD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,+CAA+C,CAAA;AAC1F,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6CAA6C,CAAA;AACnF,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAKnE;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,CACrC,UAAU,EAAE,UAAU,EACtB,YAAY,EAAE,gBAAgB,GAAG,SAAS,GACzC,iBAAiB,CAgBnB;AAED,OAAO,QAAQ,MAAM,CAAC;IACpB,UAAU,kBAAkB;QAC1B,aAAa,EAAE,aAAa,CAAA;KAC7B;CACF;AAED,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,QAAQ,EAAE,qBAAqB,CAAA;IACxC,QAAQ,CAAC,gBAAgB,EAAE,gBAAgB,CAAA;IAC3C,QAAQ,CAAC,YAAY,EAAE,gBAAgB,CAAA;CACxC;AAED;;;;;;;;G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AAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,GAAG,aAAa,GAAG,SAAS,CAE5E;AAED;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,UAAU,EACtB,aAAa,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC,GACvE,iBAAiB,CAcnB"}
@@ -1,14 +1,17 @@
1
+ import { ForbiddenError } from '@braidhq/core';
1
2
  import { defaultPermissionRegistry, resolveViewer } from '../policy/index.js';
2
- import { getUserId } from './userId.js';
3
+ import { getUserId } from './auth.js';
3
4
  import { getWorkspaceId } from './workspaceId.js';
4
5
  /**
5
- * Server-scope capability guard. Used for actions that happen without
6
- * a workspace context (e.g. workspace creation). Builds a viewer with
7
- * member=undefined; non-admin users resolve to effectiveRole=null and
8
- * fail every check by construction.
6
+ * Server-scope capability guard for actions without a workspace context,
7
+ * such as workspace creation.
8
+ * Builds a viewer with an absent member,
9
+ * so non-admin users resolve to a null effectiveRole,
10
+ * and fail every check by construction.
9
11
  *
10
- * Skips the gate when userRegistry isn't provided so in-memory test
11
- * compositions stay open. Production deployments always pass it.
12
+ * Skips the gate when userRegistry is absent,
13
+ * so in-memory test compositions stay open.
14
+ * Production deployments always pass it.
12
15
  */
13
16
  export function requireServerCapability(capability, userRegistry) {
14
17
  return async (context, next) => {
@@ -19,22 +22,23 @@ export function requireServerCapability(capability, userRegistry) {
19
22
  const userId = getUserId(context);
20
23
  const user = await userRegistry.get(userId);
21
24
  if (!user)
22
- return forbid(context, `Unknown user "${userId}".`);
25
+ return forbid(`Unknown user "${userId}".`);
23
26
  const viewer = resolveViewer(user, undefined);
24
27
  if (!defaultPermissionRegistry.can(capability, viewer))
25
- return forbid(context, `Your role cannot perform "${capability}".`);
28
+ return forbid(`Your role cannot perform "${capability}".`);
26
29
  await next();
27
30
  return undefined;
28
31
  };
29
32
  }
30
33
  /**
31
- * Resolves the caller's ViewerContext for this workspace and stashes
32
- * it on the Hono context for every downstream layer to read. Composes
33
- * after `workspaceIdMiddleware` + `userIdMiddleware`. Outsiders (no
34
- * member row + not a server admin) get 403 here.
34
+ * Resolves the caller's ViewerContext for this workspace,
35
+ * and stashes it on the Hono context for every downstream layer to read.
36
+ * Composes after `workspaceIdMiddleware` and `authMiddleware`.
37
+ * Outsiders get 403 here, meaning no member row and not a server admin.
35
38
  *
36
- * The actual policy decisions live in `policy/`; this middleware just
37
- * builds the viewer and rejects unauthenticated outsiders.
39
+ * The actual policy decisions live in `policy/`.
40
+ * This middleware only builds the viewer,
41
+ * and rejects unauthenticated outsiders.
38
42
  */
39
43
  export function workspaceAccessMiddleware(options) {
40
44
  return async (context, next) => {
@@ -42,12 +46,12 @@ export function workspaceAccessMiddleware(options) {
42
46
  const userId = getUserId(context);
43
47
  const user = await options.userRegistry.get(userId);
44
48
  if (!user)
45
- return forbid(context, `Unknown user "${userId}".`);
49
+ return forbid(`Unknown user "${userId}".`);
46
50
  const workspace = await options.workspaceService.findById(workspaceId);
47
51
  const member = await options.registry.getMember(workspace.rootPath, userId);
48
52
  const viewer = resolveViewer(user, member);
49
53
  if (viewer.effectiveRole === null)
50
- return forbid(context, `You are not a member of workspace "${workspaceId}".`);
54
+ return forbid(`You are not a member of workspace "${workspaceId}".`);
51
55
  context.set('viewerContext', viewer);
52
56
  await next();
53
57
  return undefined;
@@ -57,13 +61,14 @@ export function getViewerContext(context) {
57
61
  return context.get('viewerContext');
58
62
  }
59
63
  /**
60
- * Mutation guard. Returns 403 if the viewer can't perform the given
61
- * capability. Optional `buildResource` lets specific capabilities
62
- * (e.g. `skill.run`) attach per-request data the check needs.
64
+ * Mutation guard.
65
+ * Returns 403 when the viewer cannot perform the given capability.
66
+ * Optional `buildResource` lets a capability such as `skill.run`
67
+ * attach per-request data the check needs.
63
68
  *
64
- * Test compositions that don't mount `workspaceAccessMiddleware`
65
- * (in-memory tests, headless server) skip the gate. Production
66
- * deployments always mount the access middleware so the gate is real.
69
+ * Compositions that don't mount `workspaceAccessMiddleware`,
70
+ * such as in-memory tests or the headless server, skip the gate.
71
+ * Production deployments always mount it, so the gate is real.
67
72
  */
68
73
  export function requirePermission(capability, buildResource) {
69
74
  return async (context, next) => {
@@ -75,12 +80,12 @@ export function requirePermission(capability, buildResource) {
75
80
  const resource = buildResource ? await buildResource(context) : undefined;
76
81
  const viewer = resource ? { ...base, resource } : base;
77
82
  if (!defaultPermissionRegistry.can(capability, viewer))
78
- return forbid(context, `Your role cannot perform "${capability}".`);
83
+ return forbid(`Your role cannot perform "${capability}".`);
79
84
  await next();
80
85
  return undefined;
81
86
  };
82
87
  }
83
- function forbid(context, detail) {
84
- return context.json({ type: 'about:blank', title: 'Forbidden', status: 403, detail }, 403, { 'Content-Type': 'application/problem+json' });
88
+ function forbid(detail) {
89
+ throw new ForbiddenError(detail);
85
90
  }
86
91
  //# sourceMappingURL=workspaceAccess.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"workspaceAccess.js","sourceRoot":"","sources":["../../src/middleware/workspaceAccess.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,yBAAyB,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAC7E,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAEjD;;;;;;;;GAQG;AACH,MAAM,UAAU,uBAAuB,CACrC,UAAsB,EACtB,YAA0C;IAE1C,OAAO,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;QAC7B,IAAI,CAAC,YAAY,EAAE,CAAC;YAClB,MAAM,IAAI,EAAE,CAAA;YACZ,OAAO,SAAS,CAAA;QAClB,CAAC;QACD,MAAM,MAAM,GAAG,SAAS,CAAC,OAAO,CAAC,CAAA;QACjC,MAAM,IAAI,GAAG,MAAM,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;QAC3C,IAAI,CAAC,IAAI;YACP,OAAO,MAAM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AE,MAAM,CAAC;YACpD,OAAO,MAAM,CAAC,6BAA6B,UAAU,IAAI,CAAC,CAAA;QAC5D,MAAM,IAAI,EAAE,CAAA;QACZ,OAAO,SAAS,CAAA;IAClB,CAAC,CAAA;AACH,CAAC;AAED,SAAS,MAAM,CAAC,MAAc;IAC5B,MAAM,IAAI,cAAc,CAAC,MAAM,CAAC,CAAA;AAClC,CAAC"}
@@ -1,11 +1,11 @@
1
- import type { Capability } from './Capability.js';
1
+ import type { Capability } from '@braidhq/schema';
2
2
  import type { ViewerContext } from './ViewerContext.js';
3
3
  /**
4
- * Each capability owns its decision logic in a single class. This is
5
- * the Strategy interface; concrete checks live under `./checks/`.
4
+ * The Strategy interface, where each capability owns its decision logic.
5
+ * A stateless check is a const object, the first-party set lives in `checks.ts`.
6
6
  *
7
- * Implementations MUST be pure (no I/O, no time, no rng) so the same
8
- * `(viewer)` always produces the same answer.
7
+ * Implementations MUST be pure, with no I/O, clock, or randomness,
8
+ * so the same viewer always produces the same answer.
9
9
  */
10
10
  export interface CapabilityCheck {
11
11
  readonly id: Capability;
@@ -1,22 +1,24 @@
1
- import type { Capability } from './Capability.js';
1
+ import type { Capability } from '@braidhq/schema';
2
2
  import type { CapabilityCheck } from './CapabilityCheck.js';
3
3
  import type { ViewerContext } from './ViewerContext.js';
4
4
  /**
5
- * Open registry of capability strategies. Adding a new capability =
6
- * `registry.register(new MyCheck())`; existing checks are untouched.
5
+ * Open registry of capability strategies.
6
+ * A new capability arrives via `registry.register(new MyCheck())`,
7
+ * leaving existing checks untouched.
7
8
  *
8
- * Unknown capability ids resolve to `false` (default deny). This makes
9
- * it safe to typo a capability id; the call denies instead of
10
- * accidentally allowing.
9
+ * Unknown capability ids resolve to `false`, a default deny.
10
+ * This makes a typo'd capability id safe,
11
+ * since the call denies rather than accidentally allowing.
11
12
  */
12
13
  export declare class PermissionRegistry {
13
14
  private readonly checks;
14
15
  register(check: CapabilityCheck): this;
15
16
  has(capability: Capability): boolean;
16
17
  /**
17
- * Decide whether a viewer can perform a capability. The viewer
18
- * already carries its own resource (e.g. skill for skill.run); the
19
- * caller is responsible for building the right viewer.
18
+ * Decide whether a viewer can perform a capability.
19
+ * The viewer already carries its own resource,
20
+ * such as the skill for skill.run,
21
+ * so the caller is responsible for building the right viewer.
20
22
  */
21
23
  can(capability: Capability, viewer: ViewerContext): boolean;
22
24
  }
@@ -1 +1 @@
1
- {"version":3,"file":"PermissionRegistry.d.ts","sourceRoot":"","sources":["../../src/policy/PermissionRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAC3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAEvD;;;;;;;GAOG;AACH,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAyC;IAEhE,QAAQ,CAAC,KAAK,EAAE,eAAe,GAAG,IAAI;IAKtC,GAAG,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO;IAIpC;;;;OAIG;IACH,GAAG,CAAC,UAAU,EAAE,UAAU,EAAE,MAAM,EAAE,aAAa,GAAG,OAAO;CAG5D"}
1
+ {"version":3,"file":"PermissionRegistry.d.ts","sourceRoot":"","sources":["../../src/policy/PermissionRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAC3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAEvD;;;;;;;;GAQG;AACH,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAyC;IAEhE,QAAQ,CAAC,KAAK,EAAE,eAAe,GAAG,IAAI;IAKtC,GAAG,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO;IAIpC;;;;;OAKG;IACH,GAAG,CAAC,UAAU,EAAE,UAAU,EAAE,MAAM,EAAE,aAAa,GAAG,OAAO;CAG5D"}
@@ -1,10 +1,11 @@
1
1
  /**
2
- * Open registry of capability strategies. Adding a new capability =
3
- * `registry.register(new MyCheck())`; existing checks are untouched.
2
+ * Open registry of capability strategies.
3
+ * A new capability arrives via `registry.register(new MyCheck())`,
4
+ * leaving existing checks untouched.
4
5
  *
5
- * Unknown capability ids resolve to `false` (default deny). This makes
6
- * it safe to typo a capability id; the call denies instead of
7
- * accidentally allowing.
6
+ * Unknown capability ids resolve to `false`, a default deny.
7
+ * This makes a typo'd capability id safe,
8
+ * since the call denies rather than accidentally allowing.
8
9
  */
9
10
  export class PermissionRegistry {
10
11
  checks = new Map();
@@ -16,9 +17,10 @@ export class PermissionRegistry {
16
17
  return this.checks.has(capability);
17
18
  }
18
19
  /**
19
- * Decide whether a viewer can perform a capability. The viewer
20
- * already carries its own resource (e.g. skill for skill.run); the
21
- * caller is responsible for building the right viewer.
20
+ * Decide whether a viewer can perform a capability.
21
+ * The viewer already carries its own resource,
22
+ * such as the skill for skill.run,
23
+ * so the caller is responsible for building the right viewer.
22
24
  */
23
25
  can(capability, viewer) {
24
26
  return this.checks.get(capability)?.evaluate(viewer) ?? false;
@@ -1 +1 @@
1
- {"version":3,"file":"PermissionRegistry.js","sourceRoot":"","sources":["../../src/policy/PermissionRegistry.ts"],"names":[],"mappings":"AAIA;;;;;;;GAOG;AACH,MAAM,OAAO,kBAAkB;IACZ,MAAM,GAAG,IAAI,GAAG,EAA+B,CAAA;IAEhE,QAAQ,CAAC,KAAsB;QAC7B,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,EAAE,KAAK,CAAC,CAAA;QAChC,OAAO,IAAI,CAAA;IACb,CAAC;IAED,GAAG,CAAC,UAAsB;QACxB,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,CAAA;IACpC,CAAC;IAED;;;;OAIG;IACH,GAAG,CAAC,UAAsB,EAAE,MAAqB;QAC/C,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,IAAI,KAAK,CAAA;IAC/D,CAAC;CACF"}
1
+ {"version":3,"file":"PermissionRegistry.js","sourceRoot":"","sources":["../../src/policy/PermissionRegistry.ts"],"names":[],"mappings":"AAIA;;;;;;;;GAQG;AACH,MAAM,OAAO,kBAAkB;IACZ,MAAM,GAAG,IAAI,GAAG,EAA+B,CAAA;IAEhE,QAAQ,CAAC,KAAsB;QAC7B,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,EAAE,KAAK,CAAC,CAAA;QAChC,OAAO,IAAI,CAAA;IACb,CAAC;IAED,GAAG,CAAC,UAAsB;QACxB,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,CAAA;IACpC,CAAC;IAED;;;;;OAKG;IACH,GAAG,CAAC,UAAsB,EAAE,MAAqB;QAC/C,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,IAAI,KAAK,CAAA;IAC/D,CAAC;CACF"}
@@ -1,18 +1,20 @@
1
1
  import type { SkillFrontmatter, User, WorkspaceMember, WorkspaceRole } from '@braidhq/schema';
2
2
  /**
3
- * The single resolved-identity object that every capability check
4
- * reads. Built once per request by `resolveViewer`; passed unchanged
5
- * into the registry.
3
+ * The single resolved-identity object that every capability check reads.
4
+ * Built once per request by `resolveViewer`,
5
+ * then passed unchanged into the registry.
6
6
  *
7
- * `effectiveRole` is what permission gates use: admins always land as
8
- * `'owner'` here, regardless of whether they have an explicit member
9
- * row. `member` is the stored row when present (used for display +
10
- * skillOverrides lookup) and is independent of effectiveRole. Admin
11
- * who joined as Guest has member.role='guest' but effectiveRole='owner'.
7
+ * Permission gates read `effectiveRole`,
8
+ * where admins always land as owner regardless of any member row.
9
+ * `member` is the stored row when present,
10
+ * used for display and skillOverrides lookup,
11
+ * and stays independent of effectiveRole.
12
+ * An admin who joined as a guest has a guest member.role,
13
+ * yet an owner effectiveRole.
12
14
  *
13
- * `resource` is the per-action context the check needs:
14
- * - skill.run uses `skill` (manifest) + `skillId`
15
- * - future checks can extend this without breaking siblings
15
+ * `resource` is the per-action context the check needs.
16
+ * skill.run reads `skill`, the manifest, along with `skillId`.
17
+ * Future checks can extend it without breaking siblings.
16
18
  */
17
19
  export interface ViewerContext {
18
20
  readonly user: User;
@@ -1 +1 @@
1
- {"version":3,"file":"ViewerContext.d.ts","sourceRoot":"","sources":["../../src/policy/ViewerContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,IAAI,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAE7F;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAA;IACnB,QAAQ,CAAC,MAAM,EAAE,eAAe,GAAG,SAAS,CAAA;IAC5C,QAAQ,CAAC,aAAa,EAAE,aAAa,GAAG,IAAI,CAAA;IAC5C,QAAQ,CAAC,QAAQ,CAAC,EAAE,cAAc,GAAG,SAAS,CAAA;CAC/C;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,KAAK,CAAC,EAAE,gBAAgB,CAAA;IACjC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAC1B"}
1
+ {"version":3,"file":"ViewerContext.d.ts","sourceRoot":"","sources":["../../src/policy/ViewerContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,IAAI,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAE7F;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAA;IACnB,QAAQ,CAAC,MAAM,EAAE,eAAe,GAAG,SAAS,CAAA;IAC5C,QAAQ,CAAC,aAAa,EAAE,aAAa,GAAG,IAAI,CAAA;IAC5C,QAAQ,CAAC,QAAQ,CAAC,EAAE,cAAc,GAAG,SAAS,CAAA;CAC/C;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,KAAK,CAAC,EAAE,gBAAgB,CAAA;IACjC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAC1B"}
@@ -1,15 +1,15 @@
1
1
  import type { CapabilityCheck } from './CapabilityCheck.js';
2
2
  /**
3
- * First-party capability checks, mirrored byte-equivalent in
4
- * `packages/studio/src/policy/checks.ts`. The server is the
5
- * authoritative gate; the client copy lets Studio render Locked-style
6
- * affordances without hitting a 403.
3
+ * First-party capability checks,
4
+ * mirrored byte-equivalent in `packages/studio/src/policy/checks.ts`.
5
+ * The server is the authoritative gate.
6
+ * The client copy lets Studio render locked affordances, without hitting a 403.
7
7
  *
8
- * Workspace-scope verbs collapse to `read` + `write` per resource.
9
- * Workspace.create is server-scope (resolveViewer with no member).
10
- * Skill.run keeps its own verb because its three-step resolution
11
- * (owner short-circuit, per-member override, manifest allowedRoles)
12
- * doesn't fit a read/write pair.
8
+ * Workspace-scope verbs collapse to read and write per resource.
9
+ * `workspace.create` is server-scope, resolved with no member.
10
+ * `skill.run` keeps its own verb for its three-step resolution,
11
+ * covering owner short-circuit, per-member override, allowedRoles,
12
+ * which does not fit a read or write pair.
13
13
  */
14
14
  export declare const checks: readonly CapabilityCheck[];
15
15
  //# sourceMappingURL=checks.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"checks.d.ts","sourceRoot":"","sources":["../../src/policy/checks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAE3D;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,MAAM,EAAE,SAAS,eAAe,EAsC5C,CAAA"}
1
+ {"version":3,"file":"checks.d.ts","sourceRoot":"","sources":["../../src/policy/checks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAE3D;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,MAAM,EAAE,SAAS,eAAe,EAyC5C,CAAA"}
@@ -1,17 +1,20 @@
1
1
  /**
2
- * First-party capability checks, mirrored byte-equivalent in
3
- * `packages/studio/src/policy/checks.ts`. The server is the
4
- * authoritative gate; the client copy lets Studio render Locked-style
5
- * affordances without hitting a 403.
2
+ * First-party capability checks,
3
+ * mirrored byte-equivalent in `packages/studio/src/policy/checks.ts`.
4
+ * The server is the authoritative gate.
5
+ * The client copy lets Studio render locked affordances, without hitting a 403.
6
6
  *
7
- * Workspace-scope verbs collapse to `read` + `write` per resource.
8
- * Workspace.create is server-scope (resolveViewer with no member).
9
- * Skill.run keeps its own verb because its three-step resolution
10
- * (owner short-circuit, per-member override, manifest allowedRoles)
11
- * doesn't fit a read/write pair.
7
+ * Workspace-scope verbs collapse to read and write per resource.
8
+ * `workspace.create` is server-scope, resolved with no member.
9
+ * `skill.run` keeps its own verb for its three-step resolution,
10
+ * covering owner short-circuit, per-member override, allowedRoles,
11
+ * which does not fit a read or write pair.
12
12
  */
13
13
  export const checks = [
14
14
  { id: 'workspace.create', evaluate: v => v.effectiveRole === 'owner' },
15
+ // Server admin reads serverRole directly, not effectiveRole,
16
+ // since a workspace owner also resolves to an owner effectiveRole.
17
+ { id: 'server.admin', evaluate: v => v.user.serverRole === 'admin' },
15
18
  { id: 'workspace.read', evaluate: v => v.effectiveRole !== null },
16
19
  { id: 'workspace.write', evaluate: v => v.effectiveRole === 'owner' },
17
20
  {
@@ -23,11 +26,11 @@ export const checks = [
23
26
  evaluate: v => v.effectiveRole === 'owner' || v.effectiveRole === 'maintainer',
24
27
  },
25
28
  {
26
- id: 'clarify.read',
29
+ id: 'clarification.read',
27
30
  evaluate: v => v.effectiveRole === 'owner' || v.effectiveRole === 'maintainer',
28
31
  },
29
32
  {
30
- id: 'clarify.write',
33
+ id: 'clarification.write',
31
34
  evaluate: v => v.effectiveRole === 'owner' || v.effectiveRole === 'maintainer',
32
35
  },
33
36
  { id: 'history.write', evaluate: v => v.effectiveRole === 'owner' },
@@ -1 +1 @@
1
- {"version":3,"file":"checks.js","sourceRoot":"","sources":["../../src/policy/checks.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,MAAM,GAA+B;IAChD,EAAE,EAAE,EAAE,kBAAkB,EAAE,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,aAAa,KAAK,OAAO,EAAE;IACtE,EAAE,EAAE,EAAE,gBAAgB,EAAE,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,aAAa,KAAK,IAAI,EAAE;IACjE,EAAE,EAAE,EAAE,iBAAiB,EAAE,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,aAAa,KAAK,OAAO,EAAE;IACrE;QACE,EAAE,EAAE,eAAe;QACnB,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,aAAa,KAAK,OAAO,IAAI,CAAC,CAAC,aAAa,KAAK,YAAY;KAC/E;IACD;QACE,EAAE,EAAE,gBAAgB;QACpB,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,aAAa,KAAK,OAAO,IAAI,CAAC,CAAC,aAAa,KAAK,YAAY;KAC/E;IACD;QACE,EAAE,EAAE,cAAc;QAClB,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,aAAa,KAAK,OAAO,IAAI,CAAC,CAAC,aAAa,KAAK,YAAY;KAC/E;IACD;QACE,EAAE,EAAE,eAAe;QACnB,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,aAAa,KAAK,OAAO,IAAI,CAAC,CAAC,aAAa,KAAK,YAAY;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B,OAAO,IAAI,CAAA;YACb,MAAM,QAAQ,GAAG,CAAC,CAAC,MAAM,EAAE,cAAc,EAAE,CAAC,OAA+C,CAAC,CAAA;YAC5F,IAAI,QAAQ;gBACV,OAAO,QAAQ,KAAK,OAAO,CAAA;YAC7B,OAAO,KAAK,CAAC,KAAK,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,aAAa,CAAC,CAAA;QAC3D,CAAC;KACF;CACF,CAAA"}
@@ -1,9 +1,8 @@
1
1
  import { PermissionRegistry } from './PermissionRegistry.js';
2
2
  /**
3
- * Default registry preloaded with the platform's first-party
4
- * capabilities. Plugins that want to register their own checks should
5
- * call `register()` on this instance; tests can build a fresh registry
6
- * via `new PermissionRegistry()` to inject mocks.
3
+ * Default registry preloaded with the first-party capabilities.
4
+ * Plugins register their own checks, calling `register()` on this instance.
5
+ * Tests build a fresh `PermissionRegistry` instead, to inject mocks.
7
6
  */
8
7
  export declare function buildDefaultPermissionRegistry(): PermissionRegistry;
9
8
  export declare const defaultPermissionRegistry: PermissionRegistry;
@@ -1 +1 @@
1
- {"version":3,"file":"defaultRegistry.d.ts","sourceRoot":"","sources":["../../src/policy/defaultRegistry.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAE5D;;;;;GAKG;AACH,wBAAgB,8BAA8B,IAAI,kBAAkB,CAKnE;AAED,eAAO,MAAM,yBAAyB,oBAAmC,CAAA"}
1
+ {"version":3,"file":"defaultRegistry.d.ts","sourceRoot":"","sources":["../../src/policy/defaultRegistry.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAE5D;;;;GAIG;AACH,wBAAgB,8BAA8B,IAAI,kBAAkB,CAKnE;AAED,eAAO,MAAM,yBAAyB,oBAAmC,CAAA"}
@@ -1,10 +1,9 @@
1
1
  import { checks } from './checks.js';
2
2
  import { PermissionRegistry } from './PermissionRegistry.js';
3
3
  /**
4
- * Default registry preloaded with the platform's first-party
5
- * capabilities. Plugins that want to register their own checks should
6
- * call `register()` on this instance; tests can build a fresh registry
7
- * via `new PermissionRegistry()` to inject mocks.
4
+ * Default registry preloaded with the first-party capabilities.
5
+ * Plugins register their own checks, calling `register()` on this instance.
6
+ * Tests build a fresh `PermissionRegistry` instead, to inject mocks.
8
7
  */
9
8
  export function buildDefaultPermissionRegistry() {
10
9
  const registry = new PermissionRegistry();
@@ -1 +1 @@
1
- {"version":3,"file":"defaultRegistry.js","sourceRoot":"","sources":["../../src/policy/defaultRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAE5D;;;;;GAKG;AACH,MAAM,UAAU,8BAA8B;IAC5C,MAAM,QAAQ,GAAG,IAAI,kBAAkB,EAAE,CAAA;IACzC,KAAK,MAAM,KAAK,IAAI,MAAM;QACxB,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;IAC1B,OAAO,QAAQ,CAAA;AACjB,CAAC;AAED,MAAM,CAAC,MAAM,yBAAyB,GAAG,8BAA8B,EAAE,CAAA"}
1
+ {"version":3,"file":"defaultRegistry.js","sourceRoot":"","sources":["../../src/policy/defaultRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAE5D;;;;GAIG;AACH,MAAM,UAAU,8BAA8B;IAC5C,MAAM,QAAQ,GAAG,IAAI,kBAAkB,EAAE,CAAA;IACzC,KAAK,MAAM,KAAK,IAAI,MAAM;QACxB,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;IAC1B,OAAO,QAAQ,CAAA;AACjB,CAAC;AAED,MAAM,CAAC,MAAM,yBAAyB,GAAG,8BAA8B,EAAE,CAAA"}
@@ -1,8 +1,8 @@
1
- export type { Capability } from './Capability.js';
2
- export { CAPABILITY_IDS } from './Capability.js';
3
1
  export type { CapabilityCheck } from './CapabilityCheck.js';
4
2
  export { buildDefaultPermissionRegistry, defaultPermissionRegistry } from './defaultRegistry.js';
5
3
  export { PermissionRegistry } from './PermissionRegistry.js';
6
4
  export { resolveViewer } from './resolveViewer.js';
7
5
  export type { ViewerContext, ViewerResource } from './ViewerContext.js';
6
+ export type { Capability } from '@braidhq/schema';
7
+ export { CAPABILITY_IDS } from '@braidhq/schema';
8
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/policy/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAChD,YAAY,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAC3D,OAAO,EAAE,8BAA8B,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAA;AAChG,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/policy/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAC3D,OAAO,EAAE,8BAA8B,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAA;AAChG,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AACvE,YAAY,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA"}
@@ -1,5 +1,5 @@
1
- export { CAPABILITY_IDS } from './Capability.js';
2
1
  export { buildDefaultPermissionRegistry, defaultPermissionRegistry } from './defaultRegistry.js';
3
2
  export { PermissionRegistry } from './PermissionRegistry.js';
4
3
  export { resolveViewer } from './resolveViewer.js';
4
+ export { CAPABILITY_IDS } from '@braidhq/schema';
5
5
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/policy/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAEhD,OAAO,EAAE,8BAA8B,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAA;AAChG,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/policy/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,8BAA8B,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAA;AAChG,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAGlD,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA"}
@@ -1,16 +1,16 @@
1
1
  import type { User, WorkspaceMember } from '@braidhq/schema';
2
2
  import type { ViewerContext, ViewerResource } from './ViewerContext.js';
3
3
  /**
4
- * The sole place server-admin promotion happens. Every other layer
5
- * (middleware, capability checks, Studio mirror) consumes the resulting
6
- * `effectiveRole` and never re-derives it.
4
+ * The sole place server-admin promotion happens. Every other layer,
5
+ * including middleware, capability checks, and the Studio mirror,
6
+ * consumes the resulting `effectiveRole` and never re-derives it.
7
7
  *
8
- * Resolution:
9
- * 1. user.serverRole === 'admin' → effectiveRole = 'owner'
10
- * (the stored member.role, if any, is kept on `member` for
11
- * display, but ignored by gates)
12
- * 2. member present effectiveRole = member.role
13
- * 3. otherwise → effectiveRole = null (no access)
8
+ * Resolution runs in order:
9
+ * 1. An admin serverRole yields an owner effectiveRole.
10
+ * The stored member.role, if any, stays on `member` for display,
11
+ * yet gates ignore it.
12
+ * 2. A present member yields effectiveRole = member.role.
13
+ * 3. Otherwise effectiveRole is null, meaning no access.
14
14
  */
15
15
  export declare function resolveViewer(user: User, member: WorkspaceMember | undefined, resource?: ViewerResource): ViewerContext;
16
16
  //# sourceMappingURL=resolveViewer.d.ts.map