@braidhq/server 0.1.0 → 0.2.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 (385) hide show
  1. package/README.md +134 -106
  2. package/dist/app.d.ts +7 -15
  3. package/dist/app.d.ts.map +1 -1
  4. package/dist/app.js +72 -45
  5. package/dist/app.js.map +1 -1
  6. package/dist/authMode.d.ts +39 -0
  7. package/dist/authMode.d.ts.map +1 -0
  8. package/dist/authMode.js +50 -0
  9. package/dist/authMode.js.map +1 -0
  10. package/dist/composeApp.d.ts +79 -0
  11. package/dist/composeApp.d.ts.map +1 -0
  12. package/dist/composeApp.js +136 -0
  13. package/dist/composeApp.js.map +1 -0
  14. package/dist/composeFsApp.d.ts +27 -0
  15. package/dist/composeFsApp.d.ts.map +1 -0
  16. package/dist/{composeFs.js → composeFsApp.js} +118 -125
  17. package/dist/composeFsApp.js.map +1 -0
  18. package/dist/index.d.ts +3 -2
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/index.js +3 -2
  21. package/dist/index.js.map +1 -1
  22. package/dist/infrastructure/_shared/env.d.ts +10 -0
  23. package/dist/infrastructure/_shared/env.d.ts.map +1 -0
  24. package/dist/infrastructure/{env.js → _shared/env.js} +5 -6
  25. package/dist/infrastructure/_shared/env.js.map +1 -0
  26. package/dist/infrastructure/_shared/frontmatter.d.ts +13 -0
  27. package/dist/infrastructure/_shared/frontmatter.d.ts.map +1 -0
  28. package/dist/infrastructure/{fs → _shared}/frontmatter.js +5 -5
  29. package/dist/infrastructure/_shared/frontmatter.js.map +1 -0
  30. package/dist/infrastructure/_shared/jsonFileStore.d.ts.map +1 -0
  31. package/dist/infrastructure/_shared/jsonFileStore.js.map +1 -0
  32. package/dist/infrastructure/{fs → _shared}/paths.d.ts +17 -10
  33. package/dist/infrastructure/_shared/paths.d.ts.map +1 -0
  34. package/dist/infrastructure/{fs → _shared}/paths.js +27 -20
  35. package/dist/infrastructure/_shared/paths.js.map +1 -0
  36. package/dist/infrastructure/auth/AccessPolicy.d.ts +33 -58
  37. package/dist/infrastructure/auth/AccessPolicy.d.ts.map +1 -1
  38. package/dist/infrastructure/auth/AccessPolicy.js +35 -42
  39. package/dist/infrastructure/auth/AccessPolicy.js.map +1 -1
  40. package/dist/infrastructure/auth/SessionStore.d.ts +22 -12
  41. package/dist/infrastructure/auth/SessionStore.d.ts.map +1 -1
  42. package/dist/infrastructure/auth/SessionStore.js +15 -18
  43. package/dist/infrastructure/auth/SessionStore.js.map +1 -1
  44. package/dist/infrastructure/batch/FsBatchPlanRepository.d.ts +79 -0
  45. package/dist/infrastructure/batch/FsBatchPlanRepository.d.ts.map +1 -0
  46. package/dist/infrastructure/{fs → batch}/FsBatchPlanRepository.js +1 -1
  47. package/dist/infrastructure/batch/FsBatchPlanRepository.js.map +1 -0
  48. package/dist/infrastructure/history/GitWorkspaceHistory.d.ts.map +1 -0
  49. package/dist/infrastructure/{git → history}/GitWorkspaceHistory.js +31 -24
  50. package/dist/infrastructure/history/GitWorkspaceHistory.js.map +1 -0
  51. package/dist/infrastructure/history/commitMessage.d.ts.map +1 -0
  52. package/dist/infrastructure/history/commitMessage.js +90 -0
  53. package/dist/infrastructure/history/commitMessage.js.map +1 -0
  54. package/dist/infrastructure/hitl/FsClarificationRepository.d.ts +13 -0
  55. package/dist/infrastructure/hitl/FsClarificationRepository.d.ts.map +1 -0
  56. package/dist/infrastructure/{fs/FsClarifyTicketRepository.js → hitl/FsClarificationRepository.js} +15 -15
  57. package/dist/infrastructure/hitl/FsClarificationRepository.js.map +1 -0
  58. package/dist/infrastructure/hitl/FsProposalRepository.d.ts.map +1 -0
  59. package/dist/infrastructure/{fs → hitl}/FsProposalRepository.js +7 -8
  60. package/dist/infrastructure/hitl/FsProposalRepository.js.map +1 -0
  61. package/dist/infrastructure/hitl/StatusedJsonStore.d.ts +30 -0
  62. package/dist/infrastructure/hitl/StatusedJsonStore.d.ts.map +1 -0
  63. package/dist/infrastructure/{fs/FsStatusedJsonRepository.js → hitl/StatusedJsonStore.js} +3 -3
  64. package/dist/infrastructure/hitl/StatusedJsonStore.js.map +1 -0
  65. package/dist/infrastructure/model/FsModelSerializer.d.ts +96 -0
  66. package/dist/infrastructure/model/FsModelSerializer.d.ts.map +1 -0
  67. package/dist/infrastructure/{fs/FsGraphSerializer.js → model/FsModelSerializer.js} +11 -11
  68. package/dist/infrastructure/model/FsModelSerializer.js.map +1 -0
  69. package/dist/infrastructure/oauth/GoogleOAuth.d.ts +20 -38
  70. package/dist/infrastructure/oauth/GoogleOAuth.d.ts.map +1 -1
  71. package/dist/infrastructure/oauth/GoogleOAuth.js +21 -22
  72. package/dist/infrastructure/oauth/GoogleOAuth.js.map +1 -1
  73. package/dist/infrastructure/reactor/FsReactorCycleRepository.d.ts +29 -0
  74. package/dist/infrastructure/reactor/FsReactorCycleRepository.d.ts.map +1 -0
  75. package/dist/infrastructure/reactor/FsReactorCycleRepository.js +94 -0
  76. package/dist/infrastructure/reactor/FsReactorCycleRepository.js.map +1 -0
  77. package/dist/infrastructure/secrets/SecretStore.d.ts +11 -14
  78. package/dist/infrastructure/secrets/SecretStore.d.ts.map +1 -1
  79. package/dist/infrastructure/secrets/SecretStore.js +4 -4
  80. package/dist/infrastructure/secrets/SecretStore.js.map +1 -1
  81. package/dist/infrastructure/{fs → skill}/FsRunRepository.d.ts +5 -3
  82. package/dist/infrastructure/skill/FsRunRepository.d.ts.map +1 -0
  83. package/dist/infrastructure/{fs → skill}/FsRunRepository.js +11 -9
  84. package/dist/infrastructure/skill/FsRunRepository.js.map +1 -0
  85. package/dist/infrastructure/{fs → skill}/FsSkillRegistry.d.ts +4 -13
  86. package/dist/infrastructure/skill/FsSkillRegistry.d.ts.map +1 -0
  87. package/dist/infrastructure/{fs → skill}/FsSkillRegistry.js +28 -20
  88. package/dist/infrastructure/skill/FsSkillRegistry.js.map +1 -0
  89. package/dist/infrastructure/skill/SubprocessSkillRunner.d.ts +52 -0
  90. package/dist/infrastructure/skill/SubprocessSkillRunner.d.ts.map +1 -0
  91. package/dist/infrastructure/{agent → skill}/SubprocessSkillRunner.js +107 -55
  92. package/dist/infrastructure/skill/SubprocessSkillRunner.js.map +1 -0
  93. package/dist/infrastructure/skill/asyncQueue.d.ts +20 -0
  94. package/dist/infrastructure/skill/asyncQueue.d.ts.map +1 -0
  95. package/dist/infrastructure/{agent → skill}/asyncQueue.js +2 -3
  96. package/dist/infrastructure/{agent → skill}/asyncQueue.js.map +1 -1
  97. package/dist/infrastructure/skill/lineBuffer.d.ts +15 -0
  98. package/dist/infrastructure/skill/lineBuffer.d.ts.map +1 -0
  99. package/dist/infrastructure/{agent/streamJsonParser.js → skill/lineBuffer.js} +5 -17
  100. package/dist/infrastructure/skill/lineBuffer.js.map +1 -0
  101. package/dist/infrastructure/skill/orphanReaper.d.ts +20 -0
  102. package/dist/infrastructure/skill/orphanReaper.d.ts.map +1 -0
  103. package/dist/infrastructure/{orphanReaper.js → skill/orphanReaper.js} +7 -5
  104. package/dist/infrastructure/skill/orphanReaper.js.map +1 -0
  105. package/dist/infrastructure/skill/subprocessEventStream.d.ts +16 -0
  106. package/dist/infrastructure/skill/subprocessEventStream.d.ts.map +1 -0
  107. package/dist/infrastructure/skill/subprocessEventStream.js +29 -0
  108. package/dist/infrastructure/skill/subprocessEventStream.js.map +1 -0
  109. package/dist/infrastructure/source/FsSourceUnitDigest.d.ts +19 -0
  110. package/dist/infrastructure/source/FsSourceUnitDigest.d.ts.map +1 -0
  111. package/dist/infrastructure/{fs → source}/FsSourceUnitDigest.js +9 -9
  112. package/dist/infrastructure/source/FsSourceUnitDigest.js.map +1 -0
  113. package/dist/infrastructure/source/FsSourceUnitObservationRepository.d.ts +31 -0
  114. package/dist/infrastructure/source/FsSourceUnitObservationRepository.d.ts.map +1 -0
  115. package/dist/infrastructure/{fs/FsSourceUnitStateRepository.js → source/FsSourceUnitObservationRepository.js} +18 -17
  116. package/dist/infrastructure/source/FsSourceUnitObservationRepository.js.map +1 -0
  117. package/dist/infrastructure/{fs → source}/intentScan.d.ts +4 -0
  118. package/dist/infrastructure/source/intentScan.d.ts.map +1 -0
  119. package/dist/infrastructure/{fs → source}/intentScan.js +18 -16
  120. package/dist/infrastructure/source/intentScan.js.map +1 -0
  121. package/dist/infrastructure/users/UserDirectoryFromRegistry.d.ts +2 -2
  122. package/dist/infrastructure/users/UserDirectoryFromRegistry.js +2 -2
  123. package/dist/infrastructure/users/UserRegistryFile.d.ts +4 -5
  124. package/dist/infrastructure/users/UserRegistryFile.d.ts.map +1 -1
  125. package/dist/infrastructure/users/UserRegistryFile.js +6 -8
  126. package/dist/infrastructure/users/UserRegistryFile.js.map +1 -1
  127. package/dist/infrastructure/users/ensureWorkspaceOwners.d.ts +9 -6
  128. package/dist/infrastructure/users/ensureWorkspaceOwners.d.ts.map +1 -1
  129. package/dist/infrastructure/users/ensureWorkspaceOwners.js +10 -7
  130. package/dist/infrastructure/users/ensureWorkspaceOwners.js.map +1 -1
  131. package/dist/infrastructure/workspace/FsWorkspaceRepository.d.ts.map +1 -0
  132. package/dist/infrastructure/{fs → workspace}/FsWorkspaceRepository.js +7 -6
  133. package/dist/infrastructure/workspace/FsWorkspaceRepository.js.map +1 -0
  134. package/dist/infrastructure/workspace/WorkspaceDiscovery.d.ts +18 -0
  135. package/dist/infrastructure/workspace/WorkspaceDiscovery.d.ts.map +1 -0
  136. package/dist/infrastructure/{fs → workspace}/WorkspaceDiscovery.js +15 -11
  137. package/dist/infrastructure/workspace/WorkspaceDiscovery.js.map +1 -0
  138. package/dist/infrastructure/{fs → workspace}/WorkspaceRegistryFile.d.ts +10 -9
  139. package/dist/infrastructure/workspace/WorkspaceRegistryFile.d.ts.map +1 -0
  140. package/dist/infrastructure/{fs → workspace}/WorkspaceRegistryFile.js +15 -17
  141. package/dist/infrastructure/workspace/WorkspaceRegistryFile.js.map +1 -0
  142. package/dist/infrastructure/workspace/productManifestWriter.d.ts +24 -0
  143. package/dist/infrastructure/workspace/productManifestWriter.d.ts.map +1 -0
  144. package/dist/infrastructure/{fs → workspace}/productManifestWriter.js +14 -26
  145. package/dist/infrastructure/workspace/productManifestWriter.js.map +1 -0
  146. package/dist/middleware/auth.d.ts +27 -17
  147. package/dist/middleware/auth.d.ts.map +1 -1
  148. package/dist/middleware/auth.js +59 -53
  149. package/dist/middleware/auth.js.map +1 -1
  150. package/dist/middleware/cors.d.ts.map +1 -1
  151. package/dist/middleware/cors.js +4 -1
  152. package/dist/middleware/cors.js.map +1 -1
  153. package/dist/middleware/error.d.ts.map +1 -1
  154. package/dist/middleware/error.js +15 -13
  155. package/dist/middleware/error.js.map +1 -1
  156. package/dist/middleware/workspaceAccess.d.ts +23 -19
  157. package/dist/middleware/workspaceAccess.d.ts.map +1 -1
  158. package/dist/middleware/workspaceAccess.js +31 -26
  159. package/dist/middleware/workspaceAccess.js.map +1 -1
  160. package/dist/policy/CapabilityCheck.d.ts +5 -5
  161. package/dist/policy/PermissionRegistry.d.ts +11 -9
  162. package/dist/policy/PermissionRegistry.d.ts.map +1 -1
  163. package/dist/policy/PermissionRegistry.js +10 -8
  164. package/dist/policy/PermissionRegistry.js.map +1 -1
  165. package/dist/policy/ViewerContext.d.ts +13 -11
  166. package/dist/policy/ViewerContext.d.ts.map +1 -1
  167. package/dist/policy/checks.d.ts +9 -9
  168. package/dist/policy/checks.d.ts.map +1 -1
  169. package/dist/policy/checks.js +14 -11
  170. package/dist/policy/checks.js.map +1 -1
  171. package/dist/policy/defaultRegistry.d.ts +3 -4
  172. package/dist/policy/defaultRegistry.d.ts.map +1 -1
  173. package/dist/policy/defaultRegistry.js +3 -4
  174. package/dist/policy/defaultRegistry.js.map +1 -1
  175. package/dist/policy/index.d.ts +2 -2
  176. package/dist/policy/index.d.ts.map +1 -1
  177. package/dist/policy/index.js +1 -1
  178. package/dist/policy/index.js.map +1 -1
  179. package/dist/policy/resolveViewer.d.ts +9 -9
  180. package/dist/policy/resolveViewer.js +9 -9
  181. package/dist/routes/_shared.d.ts +93 -153
  182. package/dist/routes/_shared.d.ts.map +1 -1
  183. package/dist/routes/_shared.js +9 -5
  184. package/dist/routes/_shared.js.map +1 -1
  185. package/dist/routes/admin.d.ts +1 -1
  186. package/dist/routes/admin.d.ts.map +1 -1
  187. package/dist/routes/admin.js +13 -12
  188. package/dist/routes/admin.js.map +1 -1
  189. package/dist/routes/auth.d.ts +12 -10
  190. package/dist/routes/auth.d.ts.map +1 -1
  191. package/dist/routes/auth.js +32 -34
  192. package/dist/routes/auth.js.map +1 -1
  193. package/dist/routes/clarifications.d.ts +8 -0
  194. package/dist/routes/clarifications.d.ts.map +1 -0
  195. package/dist/routes/clarifications.js +243 -0
  196. package/dist/routes/clarifications.js.map +1 -0
  197. package/dist/routes/edges.d.ts.map +1 -1
  198. package/dist/routes/edges.js +2 -6
  199. package/dist/routes/edges.js.map +1 -1
  200. package/dist/routes/history.d.ts.map +1 -1
  201. package/dist/routes/history.js +12 -10
  202. package/dist/routes/history.js.map +1 -1
  203. package/dist/routes/nodes.d.ts.map +1 -1
  204. package/dist/routes/nodes.js +4 -8
  205. package/dist/routes/nodes.js.map +1 -1
  206. package/dist/routes/oauth.d.ts +6 -7
  207. package/dist/routes/oauth.d.ts.map +1 -1
  208. package/dist/routes/oauth.js +6 -7
  209. package/dist/routes/oauth.js.map +1 -1
  210. package/dist/routes/proposals.d.ts +2 -2
  211. package/dist/routes/proposals.d.ts.map +1 -1
  212. package/dist/routes/proposals.js +30 -28
  213. package/dist/routes/proposals.js.map +1 -1
  214. package/dist/routes/reactorCycles.d.ts +7 -0
  215. package/dist/routes/reactorCycles.d.ts.map +1 -0
  216. package/dist/routes/reactorCycles.js +60 -0
  217. package/dist/routes/reactorCycles.js.map +1 -0
  218. package/dist/routes/runs.d.ts.map +1 -1
  219. package/dist/routes/runs.js +22 -19
  220. package/dist/routes/runs.js.map +1 -1
  221. package/dist/routes/skillInputOptions.d.ts +2 -2
  222. package/dist/routes/skillInputOptions.d.ts.map +1 -1
  223. package/dist/routes/skillInputOptions.js +43 -45
  224. package/dist/routes/skillInputOptions.js.map +1 -1
  225. package/dist/routes/skills.d.ts +19 -1
  226. package/dist/routes/skills.d.ts.map +1 -1
  227. package/dist/routes/skills.js +139 -7
  228. package/dist/routes/skills.js.map +1 -1
  229. package/dist/routes/sourceLoaders.d.ts.map +1 -1
  230. package/dist/routes/sourceLoaders.js +1 -0
  231. package/dist/routes/sourceLoaders.js.map +1 -1
  232. package/dist/routes/sourceUnitObservations.d.ts +20 -0
  233. package/dist/routes/sourceUnitObservations.d.ts.map +1 -0
  234. package/dist/routes/sourceUnitObservations.js +80 -0
  235. package/dist/routes/sourceUnitObservations.js.map +1 -0
  236. package/dist/routes/sourceWebhooks.d.ts +26 -0
  237. package/dist/routes/sourceWebhooks.d.ts.map +1 -0
  238. package/dist/routes/sourceWebhooks.js +301 -0
  239. package/dist/routes/sourceWebhooks.js.map +1 -0
  240. package/dist/routes/users.d.ts +0 -2
  241. package/dist/routes/users.d.ts.map +1 -1
  242. package/dist/routes/users.js +15 -33
  243. package/dist/routes/users.js.map +1 -1
  244. package/dist/routes/workspaceEvents.d.ts +5 -4
  245. package/dist/routes/workspaceEvents.d.ts.map +1 -1
  246. package/dist/routes/workspaceEvents.js +7 -6
  247. package/dist/routes/workspaceEvents.js.map +1 -1
  248. package/dist/routes/workspaceMembers.d.ts +1 -1
  249. package/dist/routes/workspaceMembers.d.ts.map +1 -1
  250. package/dist/routes/workspaceMembers.js +2 -2
  251. package/dist/routes/workspaceMembers.js.map +1 -1
  252. package/dist/routes/workspaces.d.ts +21 -10
  253. package/dist/routes/workspaces.d.ts.map +1 -1
  254. package/dist/routes/workspaces.js +97 -69
  255. package/dist/routes/workspaces.js.map +1 -1
  256. package/dist/server.js +6 -70
  257. package/dist/server.js.map +1 -1
  258. package/dist/startServer.d.ts +17 -0
  259. package/dist/startServer.d.ts.map +1 -0
  260. package/dist/startServer.js +81 -0
  261. package/dist/startServer.js.map +1 -0
  262. package/dist/startup.d.ts +28 -0
  263. package/dist/startup.d.ts.map +1 -0
  264. package/dist/startup.js +94 -0
  265. package/dist/startup.js.map +1 -0
  266. package/package.json +9 -9
  267. package/dist/composeFs.d.ts +0 -55
  268. package/dist/composeFs.d.ts.map +0 -1
  269. package/dist/composeFs.js.map +0 -1
  270. package/dist/composition.d.ts +0 -133
  271. package/dist/composition.d.ts.map +0 -1
  272. package/dist/composition.js +0 -113
  273. package/dist/composition.js.map +0 -1
  274. package/dist/infrastructure/agent/SubprocessSkillRunner.d.ts +0 -75
  275. package/dist/infrastructure/agent/SubprocessSkillRunner.d.ts.map +0 -1
  276. package/dist/infrastructure/agent/SubprocessSkillRunner.js.map +0 -1
  277. package/dist/infrastructure/agent/asyncQueue.d.ts +0 -22
  278. package/dist/infrastructure/agent/asyncQueue.d.ts.map +0 -1
  279. package/dist/infrastructure/agent/mcpConfig.d.ts +0 -38
  280. package/dist/infrastructure/agent/mcpConfig.d.ts.map +0 -1
  281. package/dist/infrastructure/agent/mcpConfig.js +0 -55
  282. package/dist/infrastructure/agent/mcpConfig.js.map +0 -1
  283. package/dist/infrastructure/agent/streamJsonParser.d.ts +0 -20
  284. package/dist/infrastructure/agent/streamJsonParser.d.ts.map +0 -1
  285. package/dist/infrastructure/agent/streamJsonParser.js.map +0 -1
  286. package/dist/infrastructure/agent/subprocessEventStream.d.ts +0 -26
  287. package/dist/infrastructure/agent/subprocessEventStream.d.ts.map +0 -1
  288. package/dist/infrastructure/agent/subprocessEventStream.js +0 -112
  289. package/dist/infrastructure/agent/subprocessEventStream.js.map +0 -1
  290. package/dist/infrastructure/auth/ensureApprovedEmails.d.ts +0 -16
  291. package/dist/infrastructure/auth/ensureApprovedEmails.d.ts.map +0 -1
  292. package/dist/infrastructure/auth/ensureApprovedEmails.js +0 -20
  293. package/dist/infrastructure/auth/ensureApprovedEmails.js.map +0 -1
  294. package/dist/infrastructure/env.d.ts +0 -11
  295. package/dist/infrastructure/env.d.ts.map +0 -1
  296. package/dist/infrastructure/env.js.map +0 -1
  297. package/dist/infrastructure/fs/FsBatchPlanRepository.d.ts +0 -300
  298. package/dist/infrastructure/fs/FsBatchPlanRepository.d.ts.map +0 -1
  299. package/dist/infrastructure/fs/FsBatchPlanRepository.js.map +0 -1
  300. package/dist/infrastructure/fs/FsClarifyTicketRepository.d.ts +0 -13
  301. package/dist/infrastructure/fs/FsClarifyTicketRepository.d.ts.map +0 -1
  302. package/dist/infrastructure/fs/FsClarifyTicketRepository.js.map +0 -1
  303. package/dist/infrastructure/fs/FsDecisionRepository.d.ts +0 -13
  304. package/dist/infrastructure/fs/FsDecisionRepository.d.ts.map +0 -1
  305. package/dist/infrastructure/fs/FsDecisionRepository.js +0 -56
  306. package/dist/infrastructure/fs/FsDecisionRepository.js.map +0 -1
  307. package/dist/infrastructure/fs/FsGraphSerializer.d.ts +0 -629
  308. package/dist/infrastructure/fs/FsGraphSerializer.d.ts.map +0 -1
  309. package/dist/infrastructure/fs/FsGraphSerializer.js.map +0 -1
  310. package/dist/infrastructure/fs/FsProposalRepository.d.ts.map +0 -1
  311. package/dist/infrastructure/fs/FsProposalRepository.js.map +0 -1
  312. package/dist/infrastructure/fs/FsRunRepository.d.ts.map +0 -1
  313. package/dist/infrastructure/fs/FsRunRepository.js.map +0 -1
  314. package/dist/infrastructure/fs/FsSkillRegistry.d.ts.map +0 -1
  315. package/dist/infrastructure/fs/FsSkillRegistry.js.map +0 -1
  316. package/dist/infrastructure/fs/FsSourceUnitDigest.d.ts +0 -19
  317. package/dist/infrastructure/fs/FsSourceUnitDigest.d.ts.map +0 -1
  318. package/dist/infrastructure/fs/FsSourceUnitDigest.js.map +0 -1
  319. package/dist/infrastructure/fs/FsSourceUnitStateRepository.d.ts +0 -30
  320. package/dist/infrastructure/fs/FsSourceUnitStateRepository.d.ts.map +0 -1
  321. package/dist/infrastructure/fs/FsSourceUnitStateRepository.js.map +0 -1
  322. package/dist/infrastructure/fs/FsStatusedJsonRepository.d.ts +0 -35
  323. package/dist/infrastructure/fs/FsStatusedJsonRepository.d.ts.map +0 -1
  324. package/dist/infrastructure/fs/FsStatusedJsonRepository.js.map +0 -1
  325. package/dist/infrastructure/fs/FsWorkspaceRepository.d.ts.map +0 -1
  326. package/dist/infrastructure/fs/FsWorkspaceRepository.js.map +0 -1
  327. package/dist/infrastructure/fs/WorkspaceDiscovery.d.ts +0 -15
  328. package/dist/infrastructure/fs/WorkspaceDiscovery.d.ts.map +0 -1
  329. package/dist/infrastructure/fs/WorkspaceDiscovery.js.map +0 -1
  330. package/dist/infrastructure/fs/WorkspaceRegistryFile.d.ts.map +0 -1
  331. package/dist/infrastructure/fs/WorkspaceRegistryFile.js.map +0 -1
  332. package/dist/infrastructure/fs/frontmatter.d.ts +0 -13
  333. package/dist/infrastructure/fs/frontmatter.d.ts.map +0 -1
  334. package/dist/infrastructure/fs/frontmatter.js.map +0 -1
  335. package/dist/infrastructure/fs/intentScan.d.ts.map +0 -1
  336. package/dist/infrastructure/fs/intentScan.js.map +0 -1
  337. package/dist/infrastructure/fs/jsonFileStore.d.ts.map +0 -1
  338. package/dist/infrastructure/fs/jsonFileStore.js.map +0 -1
  339. package/dist/infrastructure/fs/paths.d.ts.map +0 -1
  340. package/dist/infrastructure/fs/paths.js.map +0 -1
  341. package/dist/infrastructure/fs/productManifestWriter.d.ts +0 -22
  342. package/dist/infrastructure/fs/productManifestWriter.d.ts.map +0 -1
  343. package/dist/infrastructure/fs/productManifestWriter.js.map +0 -1
  344. package/dist/infrastructure/git/GitWorkspaceHistory.d.ts.map +0 -1
  345. package/dist/infrastructure/git/GitWorkspaceHistory.js.map +0 -1
  346. package/dist/infrastructure/git/commitMessage.d.ts.map +0 -1
  347. package/dist/infrastructure/git/commitMessage.js +0 -71
  348. package/dist/infrastructure/git/commitMessage.js.map +0 -1
  349. package/dist/infrastructure/orphanReaper.d.ts +0 -18
  350. package/dist/infrastructure/orphanReaper.d.ts.map +0 -1
  351. package/dist/infrastructure/orphanReaper.js.map +0 -1
  352. package/dist/infrastructure/users/ensureLocalUser.d.ts +0 -15
  353. package/dist/infrastructure/users/ensureLocalUser.d.ts.map +0 -1
  354. package/dist/infrastructure/users/ensureLocalUser.js +0 -38
  355. package/dist/infrastructure/users/ensureLocalUser.js.map +0 -1
  356. package/dist/middleware/requireAdmin.d.ts +0 -10
  357. package/dist/middleware/requireAdmin.d.ts.map +0 -1
  358. package/dist/middleware/requireAdmin.js +0 -24
  359. package/dist/middleware/requireAdmin.js.map +0 -1
  360. package/dist/middleware/userId.d.ts +0 -16
  361. package/dist/middleware/userId.d.ts.map +0 -1
  362. package/dist/middleware/userId.js +0 -27
  363. package/dist/middleware/userId.js.map +0 -1
  364. package/dist/policy/Capability.d.ts +0 -12
  365. package/dist/policy/Capability.d.ts.map +0 -1
  366. package/dist/policy/Capability.js +0 -31
  367. package/dist/policy/Capability.js.map +0 -1
  368. package/dist/routes/clarify.d.ts +0 -9
  369. package/dist/routes/clarify.d.ts.map +0 -1
  370. package/dist/routes/clarify.js +0 -274
  371. package/dist/routes/clarify.js.map +0 -1
  372. package/dist/routes/decisions.d.ts +0 -7
  373. package/dist/routes/decisions.d.ts.map +0 -1
  374. package/dist/routes/decisions.js +0 -68
  375. package/dist/routes/decisions.js.map +0 -1
  376. package/dist/routes/sourceUnitStates.d.ts +0 -7
  377. package/dist/routes/sourceUnitStates.d.ts.map +0 -1
  378. package/dist/routes/sourceUnitStates.js +0 -45
  379. package/dist/routes/sourceUnitStates.js.map +0 -1
  380. /package/dist/infrastructure/{fs → _shared}/jsonFileStore.d.ts +0 -0
  381. /package/dist/infrastructure/{fs → _shared}/jsonFileStore.js +0 -0
  382. /package/dist/infrastructure/{git → history}/GitWorkspaceHistory.d.ts +0 -0
  383. /package/dist/infrastructure/{git → history}/commitMessage.d.ts +0 -0
  384. /package/dist/infrastructure/{fs → hitl}/FsProposalRepository.d.ts +0 -0
  385. /package/dist/infrastructure/{fs → workspace}/FsWorkspaceRepository.d.ts +0 -0
@@ -0,0 +1,16 @@
1
+ import type { SkillEvent } from '@braidhq/schema';
2
+ import type { ChildProcess } from 'node:child_process';
3
+ /**
4
+ * Maps one stdout line to zero or more SkillEvents.
5
+ * The agent binding owns this, since the line format is the agent's own.
6
+ */
7
+ export type LineParser = (line: string, now: string) => SkillEvent[];
8
+ /**
9
+ * Wires a child's stdout and stderr to a single SkillEvent callback.
10
+ * `parseLine` comes from the agent binding, so this stays format-agnostic.
11
+ * Returns `flush` so callers can drain the final un-terminated line on `close`.
12
+ */
13
+ export declare function attachOutputBuffers(child: ChildProcess, parseLine: LineParser, onEvent: (event: SkillEvent) => void, now: () => string): {
14
+ flush: () => void;
15
+ };
16
+ //# sourceMappingURL=subprocessEventStream.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subprocessEventStream.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/skill/subprocessEventStream.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAItD;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,KAAK,UAAU,EAAE,CAAA;AAEpE;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,YAAY,EACnB,SAAS,EAAE,UAAU,EACrB,OAAO,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,EACpC,GAAG,EAAE,MAAM,MAAM,GAChB;IAAE,KAAK,EAAE,MAAM,IAAI,CAAA;CAAE,CAsBvB"}
@@ -0,0 +1,29 @@
1
+ import { SkillEvent as SkillEventSchema } from '@braidhq/schema';
2
+ import { LineBuffer } from './lineBuffer.js';
3
+ /**
4
+ * Wires a child's stdout and stderr to a single SkillEvent callback.
5
+ * `parseLine` comes from the agent binding, so this stays format-agnostic.
6
+ * Returns `flush` so callers can drain the final un-terminated line on `close`.
7
+ */
8
+ export function attachOutputBuffers(child, parseLine, onEvent, now) {
9
+ const stdout = new LineBuffer((line) => {
10
+ for (const event of parseLine(line, now()))
11
+ onEvent(event);
12
+ });
13
+ // stderr is wrapped verbatim into a `[stderr]` message event,
14
+ // so it shows up in the transcript alongside model output.
15
+ const stderr = new LineBuffer((line) => {
16
+ onEvent(SkillEventSchema.parse({ type: 'message', text: `[stderr] ${line}` }));
17
+ });
18
+ child.stdout?.setEncoding('utf-8');
19
+ child.stdout?.on('data', (chunk) => stdout.append(chunk));
20
+ child.stderr?.setEncoding('utf-8');
21
+ child.stderr?.on('data', (chunk) => stderr.append(chunk));
22
+ return {
23
+ flush: () => {
24
+ stdout.flush();
25
+ stderr.flush();
26
+ },
27
+ };
28
+ }
29
+ //# sourceMappingURL=subprocessEventStream.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subprocessEventStream.js","sourceRoot":"","sources":["../../../src/infrastructure/skill/subprocessEventStream.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,IAAI,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAQ5C;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CACjC,KAAmB,EACnB,SAAqB,EACrB,OAAoC,EACpC,GAAiB;IAEjB,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,CAAC,IAAI,EAAE,EAAE;QACrC,KAAK,MAAM,KAAK,IAAI,SAAS,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC;YACxC,OAAO,CAAC,KAAK,CAAC,CAAA;IAClB,CAAC,CAAC,CAAA;IACF,8DAA8D;IAC9D,2DAA2D;IAC3D,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,CAAC,IAAI,EAAE,EAAE;QACrC,OAAO,CAAC,gBAAgB,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,YAAY,IAAI,EAAE,EAAE,CAAC,CAAC,CAAA;IAChF,CAAC,CAAC,CAAA;IAEF,KAAK,CAAC,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,CAAA;IAClC,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAA;IACjE,KAAK,CAAC,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,CAAA;IAClC,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAA;IAEjE,OAAO;QACL,KAAK,EAAE,GAAG,EAAE;YACV,MAAM,CAAC,KAAK,EAAE,CAAA;YACd,MAAM,CAAC,KAAK,EAAE,CAAA;QAChB,CAAC;KACF,CAAA;AACH,CAAC"}
@@ -0,0 +1,19 @@
1
+ import type { SourceUnitDigest, Workspace } from '@braidhq/core';
2
+ import type { SourceId, SourceUnitSha } from '@braidhq/schema';
3
+ /**
4
+ * Filesystem-backed `SourceUnitDigest`. Resolves the unit's relative path,
5
+ * under its filesystem source root, then hashes.
6
+ *
7
+ * - regular file: the sha256 of the file bytes.
8
+ * - directory: a recursive walk hashes each file by content,
9
+ * assembles a deterministic `<relpath>:<filehash>\n` manifest,
10
+ * sorted by relpath, then returns the sha256 of that manifest.
11
+ * Dot-prefixed entries are skipped, per the intent scanner's convention.
12
+ *
13
+ * The intent scanner's trailing-slash convention is accepted,
14
+ * so a file reads as `foo.md` and a folder as `foo/`.
15
+ */
16
+ export declare class FsSourceUnitDigest implements SourceUnitDigest {
17
+ computeSha(workspace: Workspace, sourceId: SourceId, path: string): Promise<SourceUnitSha>;
18
+ }
19
+ //# sourceMappingURL=FsSourceUnitDigest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FsSourceUnitDigest.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/source/FsSourceUnitDigest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAChE,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAK9D;;;;;;;;;;;;GAYG;AACH,qBAAa,kBAAmB,YAAW,gBAAgB;IACnD,UAAU,CAAC,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;CAejG"}
@@ -2,17 +2,17 @@ import { createHash } from 'node:crypto';
2
2
  import { readdir, readFile, stat } from 'node:fs/promises';
3
3
  import { isAbsolute, join, relative } from 'node:path';
4
4
  /**
5
- * Filesystem-backed `SourceUnitDigest`. Resolves the unit's relative
6
- * path under its filesystem source root, then either:
5
+ * Filesystem-backed `SourceUnitDigest`. Resolves the unit's relative path,
6
+ * under its filesystem source root, then hashes.
7
7
  *
8
- * - regular file: sha256 of file bytes
9
- * - directory: recursive walk; hash each file by content; build a
10
- * deterministic `<relpath>:<filehash>\n` manifest sorted by relpath;
11
- * sha256 the manifest. Dot-prefixed entries are skipped (mirrors the
12
- * intent scanner's convention).
8
+ * - regular file: the sha256 of the file bytes.
9
+ * - directory: a recursive walk hashes each file by content,
10
+ * assembles a deterministic `<relpath>:<filehash>\n` manifest,
11
+ * sorted by relpath, then returns the sha256 of that manifest.
12
+ * Dot-prefixed entries are skipped, per the intent scanner's convention.
13
13
  *
14
- * Trailing-slash convention from the intent scanner (file = `foo.md`,
15
- * folder = `foo/`) is accepted.
14
+ * The intent scanner's trailing-slash convention is accepted,
15
+ * so a file reads as `foo.md` and a folder as `foo/`.
16
16
  */
17
17
  export class FsSourceUnitDigest {
18
18
  async computeSha(workspace, sourceId, path) {
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FsSourceUnitDigest.js","sourceRoot":"","sources":["../../../src/infrastructure/source/FsSourceUnitDigest.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,E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AC,IAAI,CAAC,CAAA;QACjC,IAAI,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC;YACxB,MAAM,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC,CAAA;YAC1B,SAAQ;QACV,CAAC;QACD,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE;YACjB,SAAQ;QACV,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,QAAQ,CAAC,IAAI,EAAE,GAAG,CAAC,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;IACnE,CAAC;AACH,CAAC"}
@@ -0,0 +1,31 @@
1
+ import type { SourceUnitObservationRepository } from '@braidhq/core';
2
+ import type { AbsolutePath, SourceId, SourceUnitObservation, WorkspaceId } from '@braidhq/schema';
3
+ export interface FsSourceUnitObservationRepositoryOptions {
4
+ /**
5
+ * Lookup of `workspaceId` to `workspaceRoot`, shared by the repos,
6
+ * so this one takes no `WorkspaceService` dependency of its own.
7
+ * `composeFs.ts` builds the closure once, then hands the same one,
8
+ * to every fs repo.
9
+ */
10
+ readonly workspaceRoots: () => Promise<ReadonlyMap<WorkspaceId, AbsolutePath>>;
11
+ }
12
+ /**
13
+ * Filesystem-backed `SourceUnitObservationRepository`. Each entity maps to,
14
+ * `artifacts/source-unit-state/<sourceId>/<encoded-path>.json`, one file each,
15
+ * matching the file-per-entity pattern used by proposals / clarifications.
16
+ *
17
+ * The file body is exactly the `SourceUnitObservation` shape,
18
+ * with no wrapper or envelope.
19
+ * In a future SQLite or Postgres store,
20
+ * each file becomes one row keyed by `(workspaceId, sourceId, path)`.
21
+ */
22
+ export declare class FsSourceUnitObservationRepository implements SourceUnitObservationRepository {
23
+ private readonly options;
24
+ constructor(options: FsSourceUnitObservationRepositoryOptions);
25
+ find(workspaceId: WorkspaceId, sourceId: SourceId, path: string): Promise<SourceUnitObservation | null>;
26
+ save(state: SourceUnitObservation): Promise<void>;
27
+ listByWorkspace(workspaceId: WorkspaceId): Promise<readonly SourceUnitObservation[]>;
28
+ listBySource(workspaceId: WorkspaceId, sourceId: SourceId): Promise<readonly SourceUnitObservation[]>;
29
+ private resolveRoot;
30
+ }
31
+ //# sourceMappingURL=FsSourceUnitObservationRepository.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FsSourceUnitObservationRepository.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/source/FsSourceUnitObservationRepository.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,eAAe,CAAA;AACpE,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,qBAAqB,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AASjG,MAAM,WAAW,wCAAwC;IACvD;;;;;OAKG;IACH,QAAQ,CAAC,cAAc,EAAE,MAAM,OAAO,CAAC,WAAW,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC,CAAA;CAC/E;AAED;;;;;;;;;GASG;AACH,qBAAa,iCAAkC,YAAW,+BAA+B;IAC3E,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE,wCAAwC;IAExE,IAAI,CAAC,WAAW,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,GAAG,IAAI,CAAC;IAcvG,IAAI,CAAC,KAAK,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC;IASjD,eAAe,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,SAAS,qBAAqB,EAAE,CAAC;IAapF,YAAY,CAAC,WAAW,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,SAAS,qBAAqB,EAAE,CAAC;YAK7F,WAAW;CAO1B"}
@@ -2,28 +2,29 @@ import { mkdir, readdir, readFile, rename, writeFile } from 'node:fs/promises';
2
2
  import { join } from 'node:path';
3
3
  import process from 'node:process';
4
4
  import { NotFoundError } from '@braidhq/core';
5
- import { SourceUnitState as SourceUnitStateSchema } from '@braidhq/schema';
6
- import { sourceUnitStateDir, sourceUnitStateFilePath, sourceUnitStateSourceDir } from './paths.js';
5
+ import { SourceUnitObservation as SourceUnitObservationSchema } from '@braidhq/schema';
6
+ import { sourceUnitObservationDir, sourceUnitObservationFilePath, sourceUnitObservationSourceDir } from '../_shared/paths.js';
7
7
  /**
8
- * Filesystem-backed `SourceUnitStateRepository`. One JSON file per
9
- * entity at `artifacts/source-unit-state/<sourceId>/<encoded-path>.json`,
10
- * matching the file-per-entity pattern used by proposals / clarify.
8
+ * Filesystem-backed `SourceUnitObservationRepository`. Each entity maps to,
9
+ * `artifacts/source-unit-state/<sourceId>/<encoded-path>.json`, one file each,
10
+ * matching the file-per-entity pattern used by proposals / clarifications.
11
11
  *
12
- * The file body is exactly the `SourceUnitState` shape; no wrapper or
13
- * envelope. A future SQLite or Postgres impl maps each file to one row
14
- * with composite PK `(workspaceId, sourceId, path)`.
12
+ * The file body is exactly the `SourceUnitObservation` shape,
13
+ * with no wrapper or envelope.
14
+ * In a future SQLite or Postgres store,
15
+ * each file becomes one row keyed by `(workspaceId, sourceId, path)`.
15
16
  */
16
- export class FsSourceUnitStateRepository {
17
+ export class FsSourceUnitObservationRepository {
17
18
  options;
18
19
  constructor(options) {
19
20
  this.options = options;
20
21
  }
21
22
  async find(workspaceId, sourceId, path) {
22
23
  const root = await this.resolveRoot(workspaceId);
23
- const file = sourceUnitStateFilePath(root, sourceId, path);
24
+ const file = sourceUnitObservationFilePath(root, sourceId, path);
24
25
  try {
25
26
  const raw = await readFile(file, 'utf-8');
26
- return SourceUnitStateSchema.parse(JSON.parse(raw));
27
+ return SourceUnitObservationSchema.parse(JSON.parse(raw));
27
28
  }
28
29
  catch (error) {
29
30
  if (error.code === 'ENOENT')
@@ -33,15 +34,15 @@ export class FsSourceUnitStateRepository {
33
34
  }
34
35
  async save(state) {
35
36
  const root = await this.resolveRoot(state.workspaceId);
36
- const file = sourceUnitStateFilePath(root, state.sourceId, state.path);
37
- await mkdir(sourceUnitStateSourceDir(root, state.sourceId), { recursive: true });
37
+ const file = sourceUnitObservationFilePath(root, state.sourceId, state.path);
38
+ await mkdir(sourceUnitObservationSourceDir(root, state.sourceId), { recursive: true });
38
39
  const tmp = `${file}.tmp-${process.pid}-${Date.now()}`;
39
40
  await writeFile(tmp, `${JSON.stringify(state, null, 2)}\n`, 'utf-8');
40
41
  await rename(tmp, file);
41
42
  }
42
43
  async listByWorkspace(workspaceId) {
43
44
  const root = await this.resolveRoot(workspaceId);
44
- const baseDir = sourceUnitStateDir(root);
45
+ const baseDir = sourceUnitObservationDir(root);
45
46
  const sourceDirs = await safeReaddir(baseDir);
46
47
  const all = [];
47
48
  for (const sourceDir of sourceDirs) {
@@ -53,7 +54,7 @@ export class FsSourceUnitStateRepository {
53
54
  }
54
55
  async listBySource(workspaceId, sourceId) {
55
56
  const root = await this.resolveRoot(workspaceId);
56
- return readEntriesIn(sourceUnitStateSourceDir(root, sourceId));
57
+ return readEntriesIn(sourceUnitObservationSourceDir(root, sourceId));
57
58
  }
58
59
  async resolveRoot(workspaceId) {
59
60
  const roots = await this.options.workspaceRoots();
@@ -80,8 +81,8 @@ async function readEntriesIn(dir) {
80
81
  if (!entry.isFile() || !entry.name.endsWith('.json'))
81
82
  continue;
82
83
  const raw = await readFile(join(dir, entry.name), 'utf-8');
83
- results.push(SourceUnitStateSchema.parse(JSON.parse(raw)));
84
+ results.push(SourceUnitObservationSchema.parse(JSON.parse(raw)));
84
85
  }
85
86
  return results;
86
87
  }
87
- //# sourceMappingURL=FsSourceUnitStateRepository.js.map
88
+ //# sourceMappingURL=FsSourceUnitObservationRepository.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FsSourceUnitObservationRepository.js","sourceRoot":"","sources":["../../../src/infrastructure/source/FsSourceUnitObservationRepository.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ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G,MAAM,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE,CAAA;QACjD,MAAM,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,CAAA;QACnC,IAAI,CAAC,IAAI;YACP,MAAM,IAAI,aAAa,CAAC,cAAc,WAAW,+BAA+B,CAAC,CAAA;QACnF,OAAO,IAAI,CAAA;IACb,CAAC;CACF;AAED,KAAK,UAAU,WAAW,CAAC,GAAW;IACpC,IAAI,CAAC;QACH,OAAO,MAAM,OAAO,CAAC,GAAG,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAA;IACpD,CAAC;IACD,OAAO,KAAK,EAAE,CAAC;QACb,IAAK,KAA+B,CAAC,IAAI,KAAK,QAAQ;YACpD,OAAO,EAAE,CAAA;QACX,MAAM,KAAK,CAAA;IACb,CAAC;AACH,CAAC;AAED,KAAK,UAAU,aAAa,CAAC,GAAW;IACtC,MAAM,OAAO,GAAG,MAAM,WAAW,CAAC,GAAG,CAAC,CAAA;IACtC,MAAM,OAAO,GAA4B,EAAE,CAAA;IAC3C,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;QAC5B,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC;YAClD,SAAQ;QACV,MAAM,GAAG,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,CAAA;QAC1D,OAAO,CAAC,IAAI,CAAC,2BAA2B,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;IAClE,CAAC;IACD,OAAO,OAAO,CAAA;AAChB,CAAC"}
@@ -5,5 +5,9 @@ export interface IntentItem {
5
5
  readonly sourceId: string;
6
6
  readonly sourceName: string;
7
7
  }
8
+ /**
9
+ * Shared by the Studio source picker and BatchService,
10
+ * so both see the same per-doc granularity.
11
+ */
8
12
  export declare function listIntentItems(workspace: Workspace): Promise<IntentItem[]>;
9
13
  //# sourceMappingURL=intentScan.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"intentScan.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/source/intentScan.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAM9C,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;CAC5B;AAED;;;GAGG;AACH,wBAAsB,eAAe,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC,CAcjF"}
@@ -1,14 +1,17 @@
1
1
  import { readdir } from 'node:fs/promises';
2
2
  import { isAbsolute, join } from 'node:path';
3
3
  const INTENT_FILE_EXTENSIONS = new Set(['.md', '.mdx', '.markdown', '.txt', '.rst']);
4
- // Shared by the Studio source picker and BatchService so both see the same per-doc granularity.
4
+ /**
5
+ * Shared by the Studio source picker and BatchService,
6
+ * so both see the same per-doc granularity.
7
+ */
5
8
  export async function listIntentItems(workspace) {
6
9
  const items = [];
7
10
  for (const source of workspace.sources) {
8
11
  if (source.role !== 'intent')
9
12
  continue;
10
13
  if (source.kind !== 'filesystem')
11
- // MCP intent sources aren't directory-listable; future enhancement.
14
+ // MCP intent sources aren't directory-listable, future enhancement.
12
15
  continue;
13
16
  const absoluteRoot = isAbsolute(source.path)
14
17
  ? source.path
@@ -31,11 +34,12 @@ async function listIntentEntries(root, sourceId, sourceName) {
31
34
  continue;
32
35
  if (entry.isDirectory()) {
33
36
  const folder = join(root, entry.name);
34
- // Flat directories of loose markdown files (the github source-loader's
35
- // `issues/<num>.md` layout, hand-curated `prd/onboarding.md`, ...) expand
36
- // into one unit per file so downstream skills run per-document, not over
37
- // the whole bag at once. Directories with their own sub-structure stay as
38
- // a single unit because that structure is the unit's own organisation.
37
+ // A flat directory of loose markdown files gives one unit per file,
38
+ // so downstream skills run per-document rather than over the bag all at once.
39
+ // Such layouts include a github loader's issues tree,
40
+ // or a hand-curated prd folder of onboarding docs.
41
+ // A directory with its own sub-structure stays a single unit,
42
+ // since that structure is the unit's own organisation.
39
43
  const flatFiles = await listFlatDocumentFiles(folder);
40
44
  if (flatFiles) {
41
45
  for (const name of flatFiles) {
@@ -69,15 +73,13 @@ async function listIntentEntries(root, sourceId, sourceName) {
69
73
  }
70
74
  return items.sort((a, b) => a.label.localeCompare(b.label));
71
75
  }
72
- /**
73
- * If `dir` is a "flat document directory" (every visible entry is a markdown
74
- * file, no subdirectories), returns the sorted list of those filenames.
75
- * Returns `undefined` otherwise so the caller falls back to treating the
76
- * directory as a single unit.
77
- *
78
- * "Visible" excludes dotfiles, so loader-managed sync state like
79
- * `.braid-github-cursor.json` does not disqualify a directory.
80
- */
76
+ // A flat document directory has every visible entry a markdown file,
77
+ // with no subdirectories.
78
+ // For one, returns the sorted list of filenames.
79
+ // Returns `undefined` otherwise, so the caller falls back to treating,
80
+ // the directory as a single unit.
81
+ // "Visible" here excludes dotfiles,
82
+ // so sync state like `.braid-github-cursor.json` doesn't disqualify it.
81
83
  async function listFlatDocumentFiles(dir) {
82
84
  let entries;
83
85
  try {
@@ -0,0 +1 @@
1
+ {"version":3,"file":"intentScan.js","sourceRoot":"","sources":["../../../src/infrastructure/source/intentScan.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAC1C,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAE5C,MAAM,sBAAsB,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;AASpF;;;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K,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC;YAC5B,SAAQ;QACV,IAAI,KAAK,CAAC,MAAM,EAAE,IAAI,gBAAgB,CAAC,KAAK,CAAC,IAAI,CAAC;YAChD,OAAO,IAAI,CAAA;QACb,IAAI,KAAK,CAAC,WAAW,EAAE,IAAI,MAAM,gBAAgB,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,CAAC,EAAE,QAAQ,GAAG,CAAC,CAAC;YACpF,OAAO,IAAI,CAAA;IACf,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC;AAED,SAAS,gBAAgB,CAAC,QAAgB;IACxC,MAAM,GAAG,GAAG,QAAQ,CAAC,WAAW,CAAC,GAAG,CAAC,CAAA;IACrC,IAAI,GAAG,GAAG,CAAC;QACT,OAAO,KAAK,CAAA;IACd,OAAO,sBAAsB,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC,CAAA;AACtE,CAAC;AAED,SAAS,cAAc,CAAC,QAAgB;IACtC,MAAM,GAAG,GAAG,QAAQ,CAAC,WAAW,CAAC,GAAG,CAAC,CAAA;IACrC,OAAO,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAA;AACpD,CAAC"}
@@ -3,8 +3,8 @@ import type { UserId } from '@braidhq/schema';
3
3
  import type { UserRegistryFile } from './UserRegistryFile.js';
4
4
  /**
5
5
  * Adapt the file-backed user roster to the core `UserDirectory` port.
6
- * Returns `null` for unknown ids (bootstrap / `braid-skill` etc.) so
7
- * the git layer falls back to its synthetic author for those rows.
6
+ * Returns `null` for unknown ids (such as bootstrap or `braid-skill`),
7
+ * so the git layer falls back to its synthetic author for those rows.
8
8
  */
9
9
  export declare class UserDirectoryFromRegistry implements UserDirectory {
10
10
  private readonly registry;
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Adapt the file-backed user roster to the core `UserDirectory` port.
3
- * Returns `null` for unknown ids (bootstrap / `braid-skill` etc.) so
4
- * the git layer falls back to its synthetic author for those rows.
3
+ * Returns `null` for unknown ids (such as bootstrap or `braid-skill`),
4
+ * so the git layer falls back to its synthetic author for those rows.
5
5
  */
6
6
  export class UserDirectoryFromRegistry {
7
7
  registry;
@@ -1,11 +1,10 @@
1
- import type { UserId as UserIdType, UserPatch as UserPatchType, User as UserType } from '@braidhq/schema';
1
+ import type { UserId as UserIdType, UserUpdate as UserPatchType, User as UserType } from '@braidhq/schema';
2
2
  /**
3
3
  * Persists the user registry to a JSON file at `${BRAID_HOME}/users.json`.
4
- * Source of truth across server restarts; in-memory data is a derivation.
4
+ * Source of truth across server restarts, in-memory data is a derivation.
5
5
  *
6
- * Auth and ACL are server-side concerns and never enter a workspace's
7
- * git history — keep this file under `~/.braid/`, not inside any
8
- * workspace directory.
6
+ * Auth and ACL are server-side concerns, never part of a workspace's git history.
7
+ * Keep this file under `~/.braid/`, not inside any workspace dir.
9
8
  */
10
9
  export declare class UserRegistryFile {
11
10
  private readonly filePath;
@@ -1 +1 @@
1
- {"version":3,"file":"UserRegistryFile.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/users/UserRegistryFile.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,UAAU,EAAE,SAAS,IAAI,aAAa,EAAE,IAAI,IAAI,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAazG;;;;;;;GAOG;AACH,qBAAa,gBAAgB;IACf,OAAO,CAAC,QAAQ,CAAC,QAAQ;gBAAR,QAAQ,EAAE,MAAM;IAEvC,IAAI,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;IAK3B,GAAG,CAAC,EAAE,EAAE,UAAU,GAAG,OAAO,CAAC,QAAQ,GAAG,SAAS,CAAC;IAKlD,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ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K;CAIpB"}
@@ -8,11 +8,10 @@ const RegistryContent = z.object({
8
8
  });
9
9
  /**
10
10
  * Persists the user registry to a JSON file at `${BRAID_HOME}/users.json`.
11
- * Source of truth across server restarts; in-memory data is a derivation.
11
+ * Source of truth across server restarts, in-memory data is a derivation.
12
12
  *
13
- * Auth and ACL are server-side concerns and never enter a workspace's
14
- * git history — keep this file under `~/.braid/`, not inside any
15
- * workspace directory.
13
+ * Auth and ACL are server-side concerns, never part of a workspace's git history.
14
+ * Keep this file under `~/.braid/`, not inside any workspace dir.
16
15
  */
17
16
  export class UserRegistryFile {
18
17
  filePath;
@@ -52,10 +51,9 @@ export class UserRegistryFile {
52
51
  if (idx < 0)
53
52
  throw new NotFoundError(`User "${id}" not found`);
54
53
  const current = content.users[idx];
55
- // Drop undefined keys so `{ displayName: undefined }` doesn't blow
56
- // away the existing displayName. Zod's `.partial()` widens every
57
- // field to optional, but the persisted User schema still requires
58
- // the non-optional fields to be present.
54
+ // Drop undefined keys, so `{ displayName: undefined }` doesn't blow away the existing displayName.
55
+ // Zod's `.partial()` widens every field to optional,
56
+ // but the persisted User schema still requires the non-optional fields.
59
57
  const defined = Object.fromEntries(Object.entries(patch).filter(([, v]) => v !== undefined));
60
58
  const merged = { ...current, ...defined };
61
59
  content.users[idx] = merged;
@@ -1 +1 @@
1
- {"version":3,"file":"UserRegistryFile.js","sourceRoot":"","sources":["../../../src/infrastructure/users/UserRegistryFile.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAC7D,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAC9D,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAA;AACtC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,MAAM,eAAe,GAAG,CAAC,CAAC,MAA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,GAAG,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;YAClD,MAAM,MAAM,GAAG,eAAe,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAA;YACzD,IAAI,CAAC,MAAM,CAAC,OAAO;gBACjB,MAAM,IAAI,eAAe,CAAC,6BAA6B,IAAI,CAAC,QAAQ,MAAM,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAA;YACnG,OAAO,MAAM,CAAC,IAAI,CAAA;QACpB,CAAC;QACD,OAAO,KAAK,EAAE,CAAC;YACb,IAAK,KAA+B,CAAC,IAAI,KAAK,QAAQ;gBACpD,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,CAAA;YACtB,MAAM,KAAK,CAAA;QACb,CAAC;IACH,CAAC;IAEO,KAAK,CAAC,KAAK,CAAC,OAAwB;QAC1C,MAAM,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;QACxD,MAAM,SAAS,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;IAClF,CAAC;CACF"}
@@ -1,9 +1,12 @@
1
- import type { WorkspaceRegistryFile } from '../fs/WorkspaceRegistryFile.js';
1
+ import type { UserId } from '@braidhq/schema';
2
+ import type { WorkspaceRegistryFile } from '../workspace/WorkspaceRegistryFile.js';
2
3
  /**
3
- * Phase C migration: workspaces registered before members existed have
4
- * empty `members[]`. Seed each one with `local-user` as owner so the
5
- * single-tenant install keeps working with no manual steps. Idempotent
6
- * workspaces that already have members are left alone.
4
+ * Give every ownerless workspace a default owner.
5
+ * A workspace registered before the member model has an empty `members[]`.
6
+ * Single-tenant seeds `defaultOwner` so the install keeps working untouched.
7
+ * Multi-tenant passes null, where an ownerless workspace is a fault,
8
+ * every workspace there is created with an explicit owner, so this throws.
9
+ * Idempotent, workspaces that already have members are left alone.
7
10
  */
8
- export declare function ensureWorkspaceOwners(registry: WorkspaceRegistryFile): Promise<void>;
11
+ export declare function ensureWorkspaceOwners(registry: WorkspaceRegistryFile, defaultOwner: UserId | null): Promise<void>;
9
12
  //# sourceMappingURL=ensureWorkspaceOwners.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ensureWorkspaceOwners.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/users/ensureWorkspaceOwners.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAA;AAG3E;;;;;GAKG;AACH,wBAAsB,qBAAqB,CAAC,QAAQ,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC,CAa1F"}
1
+ {"version":3,"file":"ensureWorkspaceOwners.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/users/ensureWorkspaceOwners.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAa,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACxD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAA;AAElF;;;;;;;GAOG;AACH,wBAAsB,qBAAqB,CACzC,QAAQ,EAAE,qBAAqB,EAC/B,YAAY,EAAE,MAAM,GAAG,IAAI,GAC1B,OAAO,CAAC,IAAI,CAAC,CAef"}
@@ -1,19 +1,22 @@
1
- import { LOCAL_USER_ID } from './ensureLocalUser.js';
2
1
  /**
3
- * Phase C migration: workspaces registered before members existed have
4
- * empty `members[]`. Seed each one with `local-user` as owner so the
5
- * single-tenant install keeps working with no manual steps. Idempotent
6
- * workspaces that already have members are left alone.
2
+ * Give every ownerless workspace a default owner.
3
+ * A workspace registered before the member model has an empty `members[]`.
4
+ * Single-tenant seeds `defaultOwner` so the install keeps working untouched.
5
+ * Multi-tenant passes null, where an ownerless workspace is a fault,
6
+ * every workspace there is created with an explicit owner, so this throws.
7
+ * Idempotent, workspaces that already have members are left alone.
7
8
  */
8
- export async function ensureWorkspaceOwners(registry) {
9
+ export async function ensureWorkspaceOwners(registry, defaultOwner) {
9
10
  const rootPaths = await registry.list();
10
11
  const now = new Date().toISOString();
11
12
  for (const rootPath of rootPaths) {
12
13
  const members = await registry.listMembers(rootPath);
13
14
  if (members.length > 0)
14
15
  continue;
16
+ if (defaultOwner === null)
17
+ throw new Error(`Workspace at ${rootPath} has no owner, a multi-tenant server requires an explicit owner.`);
15
18
  await registry.addMember(rootPath, {
16
- userId: LOCAL_USER_ID,
19
+ userId: defaultOwner,
17
20
  role: 'owner',
18
21
  joinedAt: now,
19
22
  });
@@ -1 +1 @@
1
- {"version":3,"file":"ensureWorkspaceOwners.js","sourceRoot":"","sources":["../../../src/infrastructure/users/ensureWorkspaceOwners.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAEpD;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAC,QAA+B;IACzE,MAAM,SAAS,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;IACvC,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAe,CAAA;IACjD,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;QACjC,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAA;QACpD,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC;YACpB,SAAQ;QACV,MAAM,QAAQ,CAAC,SAAS,CAAC,QAAQ,EAAE;YACjC,MAAM,EAAE,aAAa;YACrB,IAAI,EAAE,OAAO;YACb,QAAQ,EAAE,GAAG;SACd,CAAC,CAAA;IACJ,CAAC;AACH,CAAC"}
1
+ {"version":3,"file":"ensureWorkspaceOwners.js","sourceRoot":"","sources":["../../../src/infrastructure/users/ensureWorkspaceOwners.ts"],"names":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AE,CAAC;IAc5B,IAAI,CAAC,QAAQ,EAAE,YAAY,GAAG,OAAO,CAAC,SAAS,CAAC;IAShD,IAAI,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;IAKzC,MAAM,CAAC,QAAQ,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAKnD,UAAU,CAAC,QAAQ,EAAE,YAAY,GAAG,IAAI;YAI1B,YAAY;YAcZ,qBAAqB;YAerB,YAAY;IAY1B,OAAO,CAAC,aAAa;CAOtB"}
@@ -2,8 +2,8 @@ import { readFile, stat } from 'node:fs/promises';
2
2
  import { resolve } from 'node:path';
3
3
  import { createLogger, NotFoundError, ValidationError, Workspace } from '@braidhq/core';
4
4
  import { AbsolutePath, ProductManifest, WorkspaceId } from '@braidhq/schema';
5
- import { parseMarkdownFrontmatter } from './frontmatter.js';
6
- import { workspaceProductManifestPath } from './paths.js';
5
+ import { parseMarkdownFrontmatter } from '../_shared/frontmatter.js';
6
+ import { workspaceProductManifestPath } from '../_shared/paths.js';
7
7
  const log = createLogger('server').child({ mod: 'workspace-repo' });
8
8
  export class FsWorkspaceRepository {
9
9
  deps;
@@ -11,10 +11,11 @@ export class FsWorkspaceRepository {
11
11
  constructor(deps) {
12
12
  this.deps = deps;
13
13
  }
14
- // One unreadable rootPath (deleted dir, broken PRODUCT.md, ...)
15
- // must not starve the rest. The asymmetry with `load()` is intentional:
16
- // aggregate views recover, single-entity lookups distinguish present
17
- // from absent.
14
+ // One unreadable rootPath, a deleted dir or a broken PRODUCT.md,
15
+ // must not starve the rest.
16
+ // The asymmetry with `load()` is deliberate.
17
+ // Aggregate views recover,
18
+ // whereas a single-entity lookup must tell present apart from absent.
18
19
  async list() {
19
20
  const rootPaths = await this.deps.registry.list();
20
21
  const workspaces = [];
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FsWorkspaceRepository.js","sourceRoot":"","sources":["../../../src/infrastructure/workspace/FsWorkspaceRepository.ts"],"names":[],"mapp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AM,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAA;QAC/F,CAAC;QACD,OAAO,MAAM,CAAC,IAAI,CAAA;IACpB,CAAC;CACF"}
@@ -0,0 +1,18 @@
1
+ import type { WorkspaceService } from '@braidhq/core';
2
+ import type { AbsolutePath } from '@braidhq/schema';
3
+ /**
4
+ * Walk `<workspacesRoot>/*` and register with the WorkspaceService,
5
+ * every subdirectory that owns a `PRODUCT.md`.
6
+ * It is idempotent,
7
+ * an already-registered workspace is a no-op against the FS registry.
8
+ * We run it on server boot,
9
+ * so CLI-created or hand-copied workspaces surface in Studio,
10
+ * without any explicit `register` step.
11
+ *
12
+ * A per-entry error, a corrupt PRODUCT.md or bad permissions,
13
+ * is logged and skipped.
14
+ * The server must still come up,
15
+ * so the user can fix the outlier and re-boot.
16
+ */
17
+ export declare function discoverCanonicalWorkspaces(workspacesRoot: AbsolutePath, workspaceService: WorkspaceService): Promise<void>;
18
+ //# sourceMappingURL=WorkspaceDiscovery.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WorkspaceDiscovery.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/workspace/WorkspaceDiscovery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AACrD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAKnD;;;;;;;;;;;;;GAaG;AACH,wBAAsB,2BAA2B,CAC/C,cAAc,EAAE,YAAY,EAC5B,gBAAgB,EAAE,gBAAgB,GACjC,OAAO,CAAC,IAAI,CAAC,CAgCf"}