@braidhq/server 0.0.1 → 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 (376) hide show
  1. package/README.md +164 -0
  2. package/dist/app.d.ts +12 -3
  3. package/dist/app.d.ts.map +1 -1
  4. package/dist/app.js +154 -9
  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/composeFsApp.js +309 -0
  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/_shared/env.js +19 -0
  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/_shared/paths.d.ts +43 -0
  33. package/dist/infrastructure/_shared/paths.d.ts.map +1 -0
  34. package/dist/infrastructure/_shared/paths.js +96 -0
  35. package/dist/infrastructure/_shared/paths.js.map +1 -0
  36. package/dist/infrastructure/auth/AccessPolicy.d.ts +87 -0
  37. package/dist/infrastructure/auth/AccessPolicy.d.ts.map +1 -0
  38. package/dist/infrastructure/auth/AccessPolicy.js +177 -0
  39. package/dist/infrastructure/auth/AccessPolicy.js.map +1 -0
  40. package/dist/infrastructure/auth/SessionStore.d.ts +50 -0
  41. package/dist/infrastructure/auth/SessionStore.d.ts.map +1 -0
  42. package/dist/infrastructure/auth/SessionStore.js +104 -0
  43. package/dist/infrastructure/auth/SessionStore.js.map +1 -0
  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/batch/FsBatchPlanRepository.js +42 -0
  47. package/dist/infrastructure/batch/FsBatchPlanRepository.js.map +1 -0
  48. package/dist/infrastructure/history/GitWorkspaceHistory.d.ts +18 -0
  49. package/dist/infrastructure/history/GitWorkspaceHistory.d.ts.map +1 -0
  50. package/dist/infrastructure/history/GitWorkspaceHistory.js +310 -0
  51. package/dist/infrastructure/history/GitWorkspaceHistory.js.map +1 -0
  52. package/dist/infrastructure/history/commitMessage.d.ts +4 -0
  53. package/dist/infrastructure/history/commitMessage.d.ts.map +1 -0
  54. package/dist/infrastructure/history/commitMessage.js +90 -0
  55. package/dist/infrastructure/history/commitMessage.js.map +1 -0
  56. package/dist/infrastructure/hitl/FsClarificationRepository.d.ts +13 -0
  57. package/dist/infrastructure/hitl/FsClarificationRepository.d.ts.map +1 -0
  58. package/dist/infrastructure/hitl/FsClarificationRepository.js +39 -0
  59. package/dist/infrastructure/hitl/FsClarificationRepository.js.map +1 -0
  60. package/dist/infrastructure/hitl/FsProposalRepository.d.ts.map +1 -0
  61. package/dist/infrastructure/{fs → hitl}/FsProposalRepository.js +10 -3
  62. package/dist/infrastructure/hitl/FsProposalRepository.js.map +1 -0
  63. package/dist/infrastructure/hitl/StatusedJsonStore.d.ts +30 -0
  64. package/dist/infrastructure/hitl/StatusedJsonStore.d.ts.map +1 -0
  65. package/dist/infrastructure/{fs/FsStatusedJsonRepository.js → hitl/StatusedJsonStore.js} +3 -3
  66. package/dist/infrastructure/hitl/StatusedJsonStore.js.map +1 -0
  67. package/dist/infrastructure/model/FsModelSerializer.d.ts +96 -0
  68. package/dist/infrastructure/model/FsModelSerializer.d.ts.map +1 -0
  69. package/dist/infrastructure/model/FsModelSerializer.js +60 -0
  70. package/dist/infrastructure/model/FsModelSerializer.js.map +1 -0
  71. package/dist/infrastructure/oauth/GoogleOAuth.d.ts +43 -14
  72. package/dist/infrastructure/oauth/GoogleOAuth.d.ts.map +1 -1
  73. package/dist/infrastructure/oauth/GoogleOAuth.js +78 -11
  74. package/dist/infrastructure/oauth/GoogleOAuth.js.map +1 -1
  75. package/dist/infrastructure/reactor/FsReactorCycleRepository.d.ts +29 -0
  76. package/dist/infrastructure/reactor/FsReactorCycleRepository.d.ts.map +1 -0
  77. package/dist/infrastructure/reactor/FsReactorCycleRepository.js +94 -0
  78. package/dist/infrastructure/reactor/FsReactorCycleRepository.js.map +1 -0
  79. package/dist/infrastructure/secrets/SecretStore.d.ts +11 -14
  80. package/dist/infrastructure/secrets/SecretStore.d.ts.map +1 -1
  81. package/dist/infrastructure/secrets/SecretStore.js +4 -4
  82. package/dist/infrastructure/secrets/SecretStore.js.map +1 -1
  83. package/dist/infrastructure/{fs → skill}/FsRunRepository.d.ts +9 -4
  84. package/dist/infrastructure/skill/FsRunRepository.d.ts.map +1 -0
  85. package/dist/infrastructure/skill/FsRunRepository.js +162 -0
  86. package/dist/infrastructure/skill/FsRunRepository.js.map +1 -0
  87. package/dist/infrastructure/{fs → skill}/FsSkillRegistry.d.ts +4 -13
  88. package/dist/infrastructure/skill/FsSkillRegistry.d.ts.map +1 -0
  89. package/dist/infrastructure/{fs → skill}/FsSkillRegistry.js +38 -18
  90. package/dist/infrastructure/skill/FsSkillRegistry.js.map +1 -0
  91. package/dist/infrastructure/{agent → skill}/SubprocessSkillRunner.d.ts +13 -15
  92. package/dist/infrastructure/skill/SubprocessSkillRunner.d.ts.map +1 -0
  93. package/dist/infrastructure/{agent → skill}/SubprocessSkillRunner.js +124 -40
  94. package/dist/infrastructure/skill/SubprocessSkillRunner.js.map +1 -0
  95. package/dist/infrastructure/skill/asyncQueue.d.ts +20 -0
  96. package/dist/infrastructure/skill/asyncQueue.d.ts.map +1 -0
  97. package/dist/infrastructure/{agent → skill}/asyncQueue.js +2 -3
  98. package/dist/infrastructure/{agent → skill}/asyncQueue.js.map +1 -1
  99. package/dist/infrastructure/skill/lineBuffer.d.ts +15 -0
  100. package/dist/infrastructure/skill/lineBuffer.d.ts.map +1 -0
  101. package/dist/infrastructure/{agent/streamJsonParser.js → skill/lineBuffer.js} +5 -17
  102. package/dist/infrastructure/skill/lineBuffer.js.map +1 -0
  103. package/dist/infrastructure/skill/orphanReaper.d.ts +20 -0
  104. package/dist/infrastructure/skill/orphanReaper.d.ts.map +1 -0
  105. package/dist/infrastructure/{orphanReaper.js → skill/orphanReaper.js} +7 -5
  106. package/dist/infrastructure/skill/orphanReaper.js.map +1 -0
  107. package/dist/infrastructure/skill/subprocessEventStream.d.ts +16 -0
  108. package/dist/infrastructure/skill/subprocessEventStream.d.ts.map +1 -0
  109. package/dist/infrastructure/skill/subprocessEventStream.js +29 -0
  110. package/dist/infrastructure/skill/subprocessEventStream.js.map +1 -0
  111. package/dist/infrastructure/source/FsSourceUnitDigest.d.ts +19 -0
  112. package/dist/infrastructure/source/FsSourceUnitDigest.d.ts.map +1 -0
  113. package/dist/infrastructure/source/FsSourceUnitDigest.js +58 -0
  114. package/dist/infrastructure/source/FsSourceUnitDigest.js.map +1 -0
  115. package/dist/infrastructure/source/FsSourceUnitObservationRepository.d.ts +31 -0
  116. package/dist/infrastructure/source/FsSourceUnitObservationRepository.d.ts.map +1 -0
  117. package/dist/infrastructure/source/FsSourceUnitObservationRepository.js +88 -0
  118. package/dist/infrastructure/source/FsSourceUnitObservationRepository.js.map +1 -0
  119. package/dist/infrastructure/source/intentScan.d.ts +13 -0
  120. package/dist/infrastructure/source/intentScan.d.ts.map +1 -0
  121. package/dist/infrastructure/source/intentScan.js +137 -0
  122. package/dist/infrastructure/source/intentScan.js.map +1 -0
  123. package/dist/infrastructure/users/UserDirectoryFromRegistry.d.ts +14 -0
  124. package/dist/infrastructure/users/UserDirectoryFromRegistry.d.ts.map +1 -0
  125. package/dist/infrastructure/users/UserDirectoryFromRegistry.js +21 -0
  126. package/dist/infrastructure/users/UserDirectoryFromRegistry.js.map +1 -0
  127. package/dist/infrastructure/users/UserRegistryFile.d.ts +22 -0
  128. package/dist/infrastructure/users/UserRegistryFile.d.ts.map +1 -0
  129. package/dist/infrastructure/users/UserRegistryFile.js +89 -0
  130. package/dist/infrastructure/users/UserRegistryFile.js.map +1 -0
  131. package/dist/infrastructure/users/ensureWorkspaceOwners.d.ts +12 -0
  132. package/dist/infrastructure/users/ensureWorkspaceOwners.d.ts.map +1 -0
  133. package/dist/infrastructure/users/ensureWorkspaceOwners.js +25 -0
  134. package/dist/infrastructure/users/ensureWorkspaceOwners.js.map +1 -0
  135. package/dist/infrastructure/workspace/FsWorkspaceRepository.d.ts.map +1 -0
  136. package/dist/infrastructure/{fs → workspace}/FsWorkspaceRepository.js +15 -5
  137. package/dist/infrastructure/workspace/FsWorkspaceRepository.js.map +1 -0
  138. package/dist/infrastructure/workspace/WorkspaceDiscovery.d.ts +18 -0
  139. package/dist/infrastructure/workspace/WorkspaceDiscovery.d.ts.map +1 -0
  140. package/dist/infrastructure/workspace/WorkspaceDiscovery.js +50 -0
  141. package/dist/infrastructure/workspace/WorkspaceDiscovery.js.map +1 -0
  142. package/dist/infrastructure/workspace/WorkspaceRegistryFile.d.ts +42 -0
  143. package/dist/infrastructure/workspace/WorkspaceRegistryFile.d.ts.map +1 -0
  144. package/dist/infrastructure/workspace/WorkspaceRegistryFile.js +160 -0
  145. package/dist/infrastructure/workspace/WorkspaceRegistryFile.js.map +1 -0
  146. package/dist/infrastructure/workspace/productManifestWriter.d.ts +24 -0
  147. package/dist/infrastructure/workspace/productManifestWriter.d.ts.map +1 -0
  148. package/dist/infrastructure/{fs → workspace}/productManifestWriter.js +14 -28
  149. package/dist/infrastructure/workspace/productManifestWriter.js.map +1 -0
  150. package/dist/middleware/auth.d.ts +39 -0
  151. package/dist/middleware/auth.d.ts.map +1 -0
  152. package/dist/middleware/auth.js +87 -0
  153. package/dist/middleware/auth.js.map +1 -0
  154. package/dist/middleware/cors.d.ts.map +1 -1
  155. package/dist/middleware/cors.js +5 -2
  156. package/dist/middleware/cors.js.map +1 -1
  157. package/dist/middleware/error.d.ts.map +1 -1
  158. package/dist/middleware/error.js +15 -13
  159. package/dist/middleware/error.js.map +1 -1
  160. package/dist/middleware/workspaceAccess.d.ts +51 -0
  161. package/dist/middleware/workspaceAccess.d.ts.map +1 -0
  162. package/dist/middleware/workspaceAccess.js +91 -0
  163. package/dist/middleware/workspaceAccess.js.map +1 -0
  164. package/dist/policy/CapabilityCheck.d.ts +14 -0
  165. package/dist/policy/CapabilityCheck.d.ts.map +1 -0
  166. package/dist/policy/CapabilityCheck.js +2 -0
  167. package/dist/policy/CapabilityCheck.js.map +1 -0
  168. package/dist/policy/PermissionRegistry.d.ts +25 -0
  169. package/dist/policy/PermissionRegistry.d.ts.map +1 -0
  170. package/dist/policy/PermissionRegistry.js +29 -0
  171. package/dist/policy/PermissionRegistry.js.map +1 -0
  172. package/dist/policy/ViewerContext.d.ts +29 -0
  173. package/dist/policy/ViewerContext.d.ts.map +1 -0
  174. package/dist/policy/ViewerContext.js +2 -0
  175. package/dist/policy/ViewerContext.js.map +1 -0
  176. package/dist/policy/checks.d.ts +15 -0
  177. package/dist/policy/checks.d.ts.map +1 -0
  178. package/dist/policy/checks.js +55 -0
  179. package/dist/policy/checks.js.map +1 -0
  180. package/dist/policy/defaultRegistry.d.ts +9 -0
  181. package/dist/policy/defaultRegistry.d.ts.map +1 -0
  182. package/dist/policy/defaultRegistry.js +15 -0
  183. package/dist/policy/defaultRegistry.js.map +1 -0
  184. package/dist/policy/index.d.ts +8 -0
  185. package/dist/policy/index.d.ts.map +1 -0
  186. package/dist/policy/index.js +5 -0
  187. package/dist/policy/index.js.map +1 -0
  188. package/dist/policy/resolveViewer.d.ts +16 -0
  189. package/dist/policy/resolveViewer.d.ts.map +1 -0
  190. package/dist/policy/resolveViewer.js +37 -0
  191. package/dist/policy/resolveViewer.js.map +1 -0
  192. package/dist/routes/_shared.d.ts +138 -0
  193. package/dist/routes/_shared.d.ts.map +1 -0
  194. package/dist/routes/_shared.js +33 -0
  195. package/dist/routes/_shared.js.map +1 -0
  196. package/dist/routes/admin.d.ts +13 -0
  197. package/dist/routes/admin.d.ts.map +1 -0
  198. package/dist/routes/admin.js +228 -0
  199. package/dist/routes/admin.js.map +1 -0
  200. package/dist/routes/auth.d.ts +35 -0
  201. package/dist/routes/auth.d.ts.map +1 -0
  202. package/dist/routes/auth.js +168 -0
  203. package/dist/routes/auth.js.map +1 -0
  204. package/dist/routes/batch.d.ts +7 -0
  205. package/dist/routes/batch.d.ts.map +1 -0
  206. package/dist/routes/batch.js +47 -0
  207. package/dist/routes/batch.js.map +1 -0
  208. package/dist/routes/clarifications.d.ts +8 -0
  209. package/dist/routes/clarifications.d.ts.map +1 -0
  210. package/dist/routes/clarifications.js +243 -0
  211. package/dist/routes/clarifications.js.map +1 -0
  212. package/dist/routes/edges.d.ts +2 -2
  213. package/dist/routes/edges.d.ts.map +1 -1
  214. package/dist/routes/edges.js +34 -16
  215. package/dist/routes/edges.js.map +1 -1
  216. package/dist/routes/health.d.ts +2 -2
  217. package/dist/routes/health.d.ts.map +1 -1
  218. package/dist/routes/health.js +21 -3
  219. package/dist/routes/health.js.map +1 -1
  220. package/dist/routes/history.d.ts +7 -0
  221. package/dist/routes/history.d.ts.map +1 -0
  222. package/dist/routes/history.js +90 -0
  223. package/dist/routes/history.js.map +1 -0
  224. package/dist/routes/model.d.ts +2 -2
  225. package/dist/routes/model.d.ts.map +1 -1
  226. package/dist/routes/model.js +20 -4
  227. package/dist/routes/model.js.map +1 -1
  228. package/dist/routes/nodes.d.ts +2 -2
  229. package/dist/routes/nodes.d.ts.map +1 -1
  230. package/dist/routes/nodes.js +77 -25
  231. package/dist/routes/nodes.js.map +1 -1
  232. package/dist/routes/oauth.d.ts +6 -7
  233. package/dist/routes/oauth.d.ts.map +1 -1
  234. package/dist/routes/oauth.js +6 -7
  235. package/dist/routes/oauth.js.map +1 -1
  236. package/dist/routes/ontology.d.ts +2 -2
  237. package/dist/routes/ontology.d.ts.map +1 -1
  238. package/dist/routes/ontology.js +22 -5
  239. package/dist/routes/ontology.js.map +1 -1
  240. package/dist/routes/proposals.d.ts +5 -4
  241. package/dist/routes/proposals.d.ts.map +1 -1
  242. package/dist/routes/proposals.js +176 -45
  243. package/dist/routes/proposals.js.map +1 -1
  244. package/dist/routes/reactorCycles.d.ts +7 -0
  245. package/dist/routes/reactorCycles.d.ts.map +1 -0
  246. package/dist/routes/reactorCycles.js +60 -0
  247. package/dist/routes/reactorCycles.js.map +1 -0
  248. package/dist/routes/runs.d.ts.map +1 -1
  249. package/dist/routes/runs.js +66 -12
  250. package/dist/routes/runs.js.map +1 -1
  251. package/dist/routes/skillInputOptions.d.ts +10 -0
  252. package/dist/routes/skillInputOptions.d.ts.map +1 -0
  253. package/dist/routes/skillInputOptions.js +159 -0
  254. package/dist/routes/skillInputOptions.js.map +1 -0
  255. package/dist/routes/skills.d.ts +21 -3
  256. package/dist/routes/skills.d.ts.map +1 -1
  257. package/dist/routes/skills.js +223 -21
  258. package/dist/routes/skills.js.map +1 -1
  259. package/dist/routes/sourceLoaders.d.ts +7 -0
  260. package/dist/routes/sourceLoaders.d.ts.map +1 -0
  261. package/dist/routes/sourceLoaders.js +30 -0
  262. package/dist/routes/sourceLoaders.js.map +1 -0
  263. package/dist/routes/sourceUnitObservations.d.ts +20 -0
  264. package/dist/routes/sourceUnitObservations.d.ts.map +1 -0
  265. package/dist/routes/sourceUnitObservations.js +80 -0
  266. package/dist/routes/sourceUnitObservations.js.map +1 -0
  267. package/dist/routes/sourceWebhooks.d.ts +26 -0
  268. package/dist/routes/sourceWebhooks.d.ts.map +1 -0
  269. package/dist/routes/sourceWebhooks.js +301 -0
  270. package/dist/routes/sourceWebhooks.js.map +1 -0
  271. package/dist/routes/users.d.ts +7 -0
  272. package/dist/routes/users.d.ts.map +1 -0
  273. package/dist/routes/users.js +109 -0
  274. package/dist/routes/users.js.map +1 -0
  275. package/dist/routes/workspaceEvents.d.ts +5 -4
  276. package/dist/routes/workspaceEvents.d.ts.map +1 -1
  277. package/dist/routes/workspaceEvents.js +7 -6
  278. package/dist/routes/workspaceEvents.js.map +1 -1
  279. package/dist/routes/workspaceMembers.d.ts +11 -0
  280. package/dist/routes/workspaceMembers.d.ts.map +1 -0
  281. package/dist/routes/workspaceMembers.js +81 -0
  282. package/dist/routes/workspaceMembers.js.map +1 -0
  283. package/dist/routes/workspaces.d.ts +30 -1
  284. package/dist/routes/workspaces.d.ts.map +1 -1
  285. package/dist/routes/workspaces.js +207 -63
  286. package/dist/routes/workspaces.js.map +1 -1
  287. package/dist/server.js +9 -29
  288. package/dist/server.js.map +1 -1
  289. package/dist/startServer.d.ts +17 -0
  290. package/dist/startServer.d.ts.map +1 -0
  291. package/dist/startServer.js +81 -0
  292. package/dist/startServer.js.map +1 -0
  293. package/dist/startup.d.ts +28 -0
  294. package/dist/startup.d.ts.map +1 -0
  295. package/dist/startup.js +94 -0
  296. package/dist/startup.js.map +1 -0
  297. package/package.json +49 -32
  298. package/LICENSE +0 -21
  299. package/dist/composeFs.d.ts +0 -20
  300. package/dist/composeFs.d.ts.map +0 -1
  301. package/dist/composeFs.js +0 -134
  302. package/dist/composeFs.js.map +0 -1
  303. package/dist/composition.d.ts +0 -49
  304. package/dist/composition.d.ts.map +0 -1
  305. package/dist/composition.js +0 -43
  306. package/dist/composition.js.map +0 -1
  307. package/dist/infrastructure/agent/ClaudeCodeAgentBinding.d.ts +0 -8
  308. package/dist/infrastructure/agent/ClaudeCodeAgentBinding.d.ts.map +0 -1
  309. package/dist/infrastructure/agent/ClaudeCodeAgentBinding.js +0 -62
  310. package/dist/infrastructure/agent/ClaudeCodeAgentBinding.js.map +0 -1
  311. package/dist/infrastructure/agent/SubprocessSkillRunner.d.ts.map +0 -1
  312. package/dist/infrastructure/agent/SubprocessSkillRunner.js.map +0 -1
  313. package/dist/infrastructure/agent/asyncQueue.d.ts +0 -22
  314. package/dist/infrastructure/agent/asyncQueue.d.ts.map +0 -1
  315. package/dist/infrastructure/agent/mcpConfig.d.ts +0 -18
  316. package/dist/infrastructure/agent/mcpConfig.d.ts.map +0 -1
  317. package/dist/infrastructure/agent/mcpConfig.js +0 -47
  318. package/dist/infrastructure/agent/mcpConfig.js.map +0 -1
  319. package/dist/infrastructure/agent/streamJsonParser.d.ts +0 -20
  320. package/dist/infrastructure/agent/streamJsonParser.d.ts.map +0 -1
  321. package/dist/infrastructure/agent/streamJsonParser.js.map +0 -1
  322. package/dist/infrastructure/agent/subprocessEventStream.d.ts +0 -26
  323. package/dist/infrastructure/agent/subprocessEventStream.d.ts.map +0 -1
  324. package/dist/infrastructure/agent/subprocessEventStream.js +0 -112
  325. package/dist/infrastructure/agent/subprocessEventStream.js.map +0 -1
  326. package/dist/infrastructure/fs/FsClarifyTicketRepository.d.ts +0 -13
  327. package/dist/infrastructure/fs/FsClarifyTicketRepository.d.ts.map +0 -1
  328. package/dist/infrastructure/fs/FsClarifyTicketRepository.js +0 -33
  329. package/dist/infrastructure/fs/FsClarifyTicketRepository.js.map +0 -1
  330. package/dist/infrastructure/fs/FsDecisionRepository.d.ts +0 -13
  331. package/dist/infrastructure/fs/FsDecisionRepository.d.ts.map +0 -1
  332. package/dist/infrastructure/fs/FsDecisionRepository.js +0 -56
  333. package/dist/infrastructure/fs/FsDecisionRepository.js.map +0 -1
  334. package/dist/infrastructure/fs/FsProposalRepository.d.ts.map +0 -1
  335. package/dist/infrastructure/fs/FsProposalRepository.js.map +0 -1
  336. package/dist/infrastructure/fs/FsRunRepository.d.ts.map +0 -1
  337. package/dist/infrastructure/fs/FsRunRepository.js +0 -88
  338. package/dist/infrastructure/fs/FsRunRepository.js.map +0 -1
  339. package/dist/infrastructure/fs/FsSkillRegistry.d.ts.map +0 -1
  340. package/dist/infrastructure/fs/FsSkillRegistry.js.map +0 -1
  341. package/dist/infrastructure/fs/FsStatusedJsonRepository.d.ts +0 -35
  342. package/dist/infrastructure/fs/FsStatusedJsonRepository.d.ts.map +0 -1
  343. package/dist/infrastructure/fs/FsStatusedJsonRepository.js.map +0 -1
  344. package/dist/infrastructure/fs/FsWorkspaceRepository.d.ts.map +0 -1
  345. package/dist/infrastructure/fs/FsWorkspaceRepository.js.map +0 -1
  346. package/dist/infrastructure/fs/WorkspaceRegistryFile.d.ts +0 -17
  347. package/dist/infrastructure/fs/WorkspaceRegistryFile.d.ts.map +0 -1
  348. package/dist/infrastructure/fs/WorkspaceRegistryFile.js +0 -58
  349. package/dist/infrastructure/fs/WorkspaceRegistryFile.js.map +0 -1
  350. package/dist/infrastructure/fs/frontmatter.d.ts +0 -13
  351. package/dist/infrastructure/fs/frontmatter.d.ts.map +0 -1
  352. package/dist/infrastructure/fs/frontmatter.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 +0 -22
  356. package/dist/infrastructure/fs/paths.d.ts.map +0 -1
  357. package/dist/infrastructure/fs/paths.js +0 -46
  358. package/dist/infrastructure/fs/paths.js.map +0 -1
  359. package/dist/infrastructure/fs/productManifestWriter.d.ts +0 -22
  360. package/dist/infrastructure/fs/productManifestWriter.d.ts.map +0 -1
  361. package/dist/infrastructure/fs/productManifestWriter.js.map +0 -1
  362. package/dist/infrastructure/orphanReaper.d.ts +0 -18
  363. package/dist/infrastructure/orphanReaper.d.ts.map +0 -1
  364. package/dist/infrastructure/orphanReaper.js.map +0 -1
  365. package/dist/routes/clarify.d.ts +0 -8
  366. package/dist/routes/clarify.d.ts.map +0 -1
  367. package/dist/routes/clarify.js +0 -84
  368. package/dist/routes/clarify.js.map +0 -1
  369. package/dist/routes/decisions.d.ts +0 -7
  370. package/dist/routes/decisions.d.ts.map +0 -1
  371. package/dist/routes/decisions.js +0 -30
  372. package/dist/routes/decisions.js.map +0 -1
  373. /package/dist/infrastructure/{fs → _shared}/jsonFileStore.d.ts +0 -0
  374. /package/dist/infrastructure/{fs → _shared}/jsonFileStore.js +0 -0
  375. /package/dist/infrastructure/{fs → hitl}/FsProposalRepository.d.ts +0 -0
  376. /package/dist/infrastructure/{fs → workspace}/FsWorkspaceRepository.d.ts +0 -0
@@ -0,0 +1,243 @@
1
+ import { newClarificationCandidateId } from '@braidhq/core';
2
+ import { Clarification, ClarificationCandidateId, ClarificationCreateBody, ClarificationId, ClarificationStatus, ProposalId, UserId } from '@braidhq/schema';
3
+ import { createRoute, OpenAPIHono, z } from '@hono/zod-openapi';
4
+ import { getUserId } from '../middleware/auth.js';
5
+ import { getViewerContext, requirePermission } from '../middleware/workspaceAccess.js';
6
+ import { getWorkspaceId } from '../middleware/workspaceId.js';
7
+ import { NotFoundResponse, ValidationFailureResponse, WorkspaceIdParam } from './_shared.js';
8
+ import { assertEntityInWorkspace } from './helpers.js';
9
+ const ListQuery = z.object({
10
+ status: z.union([ClarificationStatus, z.array(ClarificationStatus)]).optional().openapi({ description: 'Filter by ticket status. Pass one or many.' }),
11
+ limit: z.coerce.number().int().positive().optional(),
12
+ offset: z.coerce.number().int().nonnegative().optional(),
13
+ showAll: z.coerce.boolean().optional().openapi({ description: 'Owner-only: bypass the personal-pending filter so every member\'s open questions are visible.' }),
14
+ });
15
+ // Reviewer-facing answer body.
16
+ // The selection is either an existing `candidateId`,
17
+ // or a freshly authored `customCandidate` (description only).
18
+ // The server appends it to the ticket and answers in one transaction.
19
+ // `note` is a free-text rationale saved on the answer commit.
20
+ // `userId` is accepted for backwards compat,
21
+ // the authoritative value is the request context set by middleware.
22
+ const AnswerBody = z
23
+ .object({
24
+ candidateId: ClarificationCandidateId.optional(),
25
+ customCandidate: z.object({ description: z.string().min(1) }).optional(),
26
+ userId: UserId.optional(),
27
+ note: z.string().min(1).optional(),
28
+ })
29
+ .refine(body => Boolean(body.candidateId) !== Boolean(body.customCandidate), { message: 'Provide exactly one of candidateId or customCandidate' })
30
+ .openapi('ClarificationAnswerBody');
31
+ const SkipBody = z.object({
32
+ reason: z.string().min(1),
33
+ userId: UserId.optional(),
34
+ }).openapi('ClarificationSkipBody');
35
+ // PATCH body for clarification state transitions.
36
+ // The only legal transition the skill drives is `answered` to `applied`.
37
+ // The proposalId is optional, present when a Proposal was produced,
38
+ // absent when the chosen candidate had no graph impact.
39
+ // The skill then records the ticket as applied without a linking proposal.
40
+ const ApplyBody = z.object({
41
+ status: z.literal('applied'),
42
+ proposalId: ProposalId.optional(),
43
+ userId: UserId.optional(),
44
+ }).openapi('ClarificationApplyBody');
45
+ // Skill-emitted candidates ship their own ids (`cc-1`, `cc-merge`).
46
+ // Human-authored ones via Studio's "New question" form omit them,
47
+ // letting the server mint via `newClarificationCandidateId`.
48
+ // This keeps the ID minting rule intact,
49
+ // no `crypto.randomUUID() as XxxId` in clients.
50
+ const CreateBody = ClarificationCreateBody.openapi('ClarificationCreateBody');
51
+ const ClarificationIdParam = WorkspaceIdParam.extend({
52
+ clarificationId: ClarificationId.openapi({ param: { name: 'clarificationId', in: 'path' } }),
53
+ });
54
+ const ClarificationListResponse = z.object({
55
+ items: z.array(Clarification),
56
+ }).openapi('ClarificationListResponse');
57
+ const createClarificationRoute = createRoute({
58
+ method: 'post',
59
+ path: '/',
60
+ operationId: 'createClarification',
61
+ summary: 'Create a clarification. Skills submit this when they cannot decide between candidate interpretations.',
62
+ tags: ['clarify'],
63
+ request: {
64
+ params: WorkspaceIdParam,
65
+ body: { content: { 'application/json': { schema: CreateBody } } },
66
+ },
67
+ responses: {
68
+ 201: {
69
+ description: 'The saved clarification.',
70
+ content: { 'application/json': { schema: Clarification } },
71
+ },
72
+ 400: ValidationFailureResponse,
73
+ },
74
+ });
75
+ const listClarificationRoute = createRoute({
76
+ method: 'get',
77
+ path: '/',
78
+ operationId: 'listClarifications',
79
+ summary: 'List clarifications for a workspace, optionally filtered by status.',
80
+ tags: ['clarify'],
81
+ request: {
82
+ params: WorkspaceIdParam,
83
+ query: ListQuery,
84
+ },
85
+ responses: {
86
+ 200: {
87
+ description: 'A page of matching clarifications.',
88
+ content: { 'application/json': { schema: ClarificationListResponse } },
89
+ },
90
+ },
91
+ });
92
+ const getClarificationRoute = createRoute({
93
+ method: 'get',
94
+ path: '/{clarificationId}',
95
+ operationId: 'getClarification',
96
+ summary: 'Fetch a single clarification.',
97
+ tags: ['clarify'],
98
+ request: { params: ClarificationIdParam },
99
+ responses: {
100
+ 200: {
101
+ description: 'The requested ticket.',
102
+ content: { 'application/json': { schema: Clarification } },
103
+ },
104
+ 404: NotFoundResponse,
105
+ },
106
+ });
107
+ const answerClarificationRoute = createRoute({
108
+ method: 'post',
109
+ path: '/{clarificationId}/answer',
110
+ operationId: 'answerClarification',
111
+ summary: 'Reviewer answers a clarification. Triggers `pending` to `answered` transition.',
112
+ tags: ['clarify'],
113
+ request: {
114
+ params: ClarificationIdParam,
115
+ body: { content: { 'application/json': { schema: AnswerBody } } },
116
+ },
117
+ responses: {
118
+ 200: {
119
+ description: 'The updated ticket.',
120
+ content: { 'application/json': { schema: Clarification } },
121
+ },
122
+ 404: NotFoundResponse,
123
+ },
124
+ });
125
+ const applyClarificationRoute = createRoute({
126
+ method: 'patch',
127
+ path: '/{clarificationId}',
128
+ operationId: 'markClarificationApplied',
129
+ summary: 'Mark a clarification applied. Optionally link the materialised Proposal.',
130
+ description: 'Called by the ddd:clarify skill once it has wrapped the resolution into a Proposal (or determined there is no graph impact). Transitions `answered` to `applied`.',
131
+ tags: ['clarify'],
132
+ request: {
133
+ params: ClarificationIdParam,
134
+ body: { content: { 'application/json': { schema: ApplyBody } } },
135
+ },
136
+ responses: {
137
+ 200: {
138
+ description: 'The updated ticket.',
139
+ content: { 'application/json': { schema: Clarification } },
140
+ },
141
+ 404: NotFoundResponse,
142
+ },
143
+ });
144
+ const skipClarificationRoute = createRoute({
145
+ method: 'post',
146
+ path: '/{clarificationId}/skip',
147
+ operationId: 'skipClarification',
148
+ summary: 'Skip a clarification with a reason. Triggers `pending` to `skipped` transition.',
149
+ tags: ['clarify'],
150
+ request: {
151
+ params: ClarificationIdParam,
152
+ body: { content: { 'application/json': { schema: SkipBody } } },
153
+ },
154
+ responses: {
155
+ 200: {
156
+ description: 'The updated ticket.',
157
+ content: { 'application/json': { schema: Clarification } },
158
+ },
159
+ 404: NotFoundResponse,
160
+ },
161
+ });
162
+ export function createClarificationRouter(deps) {
163
+ const router = new OpenAPIHono();
164
+ // Answer, skip, and mark-applied are HITL decisions,
165
+ // Owner and Maintainer only.
166
+ // Guests never see the tab, but a direct curl still 403s here.
167
+ router.use('/:clarificationId/answer', requirePermission('clarification.write'));
168
+ router.use('/:clarificationId/skip', requirePermission('clarification.write'));
169
+ router.use('/:clarificationId', requirePermission('clarification.write'));
170
+ router.openapi(createClarificationRoute, async (context) => {
171
+ const workspaceId = getWorkspaceId(context);
172
+ const body = context.req.valid('json');
173
+ const submitterId = getUserId(context);
174
+ const candidates = body.candidates.map(c => ({
175
+ ...c,
176
+ id: c.id ?? newClarificationCandidateId(),
177
+ }));
178
+ const ticket = await deps.hitlService.submitClarification({ ...body, workspaceId, candidates, submitterId });
179
+ return context.json(ticket.toData(), 201);
180
+ });
181
+ router.openapi(listClarificationRoute, async (context) => {
182
+ const workspaceId = getWorkspaceId(context);
183
+ const { status, limit, offset, showAll } = context.req.valid('query');
184
+ const statuses = status === undefined ? undefined : Array.isArray(status) ? status : [status];
185
+ const viewer = getViewerContext(context);
186
+ const viewerId = (showAll && viewer?.effectiveRole === 'owner') ? undefined : getUserId(context);
187
+ const tickets = await deps.clarificationRepository.list({
188
+ workspaceId,
189
+ statuses,
190
+ limit,
191
+ offset,
192
+ ...(viewerId ? { viewerId } : {}),
193
+ });
194
+ return context.json({ items: tickets.map(ticket => ticket.toData()) }, 200);
195
+ });
196
+ router.openapi(getClarificationRoute, async (context) => {
197
+ const workspaceId = getWorkspaceId(context);
198
+ const { clarificationId } = context.req.valid('param');
199
+ const ticket = await deps.clarificationRepository.load(clarificationId);
200
+ assertEntityInWorkspace(workspaceId, ticket.workspaceId, 'Clarification', clarificationId);
201
+ return context.json(ticket.toData(), 200);
202
+ });
203
+ router.openapi(answerClarificationRoute, async (context) => {
204
+ const workspaceId = getWorkspaceId(context);
205
+ const { clarificationId } = context.req.valid('param');
206
+ const body = context.req.valid('json');
207
+ const userId = body.userId ?? getUserId(context);
208
+ const ticket = await deps.clarificationRepository.load(clarificationId);
209
+ assertEntityInWorkspace(workspaceId, ticket.workspaceId, 'Clarification', clarificationId);
210
+ const selection = body.candidateId
211
+ ? { kind: 'existing', candidateId: body.candidateId }
212
+ : { kind: 'custom', description: body.customCandidate.description };
213
+ const answered = await deps.hitlService.answerClarification({
214
+ clarificationId,
215
+ selection,
216
+ userId,
217
+ ...(body.note ? { note: body.note } : {}),
218
+ });
219
+ return context.json(answered.toData(), 200);
220
+ });
221
+ router.openapi(applyClarificationRoute, async (context) => {
222
+ const workspaceId = getWorkspaceId(context);
223
+ const { clarificationId } = context.req.valid('param');
224
+ const { proposalId, userId: bodyUserId } = context.req.valid('json');
225
+ const userId = bodyUserId ?? getUserId(context);
226
+ const ticket = await deps.clarificationRepository.load(clarificationId);
227
+ assertEntityInWorkspace(workspaceId, ticket.workspaceId, 'Clarification', clarificationId);
228
+ const applied = await deps.hitlService.markClarificationApplied(clarificationId, userId, proposalId);
229
+ return context.json(applied.toData(), 200);
230
+ });
231
+ router.openapi(skipClarificationRoute, async (context) => {
232
+ const workspaceId = getWorkspaceId(context);
233
+ const { clarificationId } = context.req.valid('param');
234
+ const { reason, userId: bodyUserId } = context.req.valid('json');
235
+ const userId = bodyUserId ?? getUserId(context);
236
+ const ticket = await deps.clarificationRepository.load(clarificationId);
237
+ assertEntityInWorkspace(workspaceId, ticket.workspaceId, 'Clarification', clarificationId);
238
+ const skipped = await deps.hitlService.skipClarification(clarificationId, reason, userId);
239
+ return context.json(skipped.toData(), 200);
240
+ });
241
+ return router;
242
+ }
243
+ //# sourceMappingURL=clarifications.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clarifications.js","sourceRoot":"","sources":["../../src/routes/clarifications.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,2BAA2B,EAAE,MAAM,eAAe,CAAA;AAC3D,OAAO,EAAE,aAAa,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,eAAe,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAC5J,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAA;AAC/D,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACjD,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAA;AACtF,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAA;AAC7D,OAAO,EAAE,gBAAgB,EAAE,yBAAyB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAC5F,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAA;AAEtD,MAAM,SAAS,GAAG,CAAC,CAAC,MAAM,CAAC;IACzB,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,mBAAmB,EAAE,CAAC,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,EAAE,WAAW,EAAE,4CAA4C,EAAE,CAAC;IACtJ,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;IACpD,MAAM,EAAE,CAAC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AAI,SAAS,CAAC,OAAO,CAAC,CAAA;QAC/C,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,uBAAuB,CAAC,IAAI,CAAC,eAAe,CAAC,CAAA;QACvE,uBAAuB,CAAC,WAAW,EAAE,MAAM,CAAC,WAAW,EAAE,eAAe,EAAE,eAAe,CAAC,CAAA;QAC1F,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,iBAAiB,CAAC,eAAe,EAAE,MAAM,EAAE,MAAM,CAAC,CAAA;QACzF,OAAO,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,GAAG,CAAC,CAAA;IAC5C,CAAC,CAAC,CAAA;IAEF,OAAO,MAAM,CAAA;AACf,CAAC"}
@@ -1,7 +1,7 @@
1
1
  import type { ModelService } from '@braidhq/core';
2
- import { Hono } from 'hono';
2
+ import { OpenAPIHono } from '@hono/zod-openapi';
3
3
  export interface EdgesRouterDeps {
4
4
  modelService: ModelService;
5
5
  }
6
- export declare function createEdgesRouter(deps: EdgesRouterDeps): Hono;
6
+ export declare function createEdgesRouter(deps: EdgesRouterDeps): OpenAPIHono;
7
7
  //# sourceMappingURL=edges.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"edges.d.ts","sourceRoot":"","sources":["../../src/routes/edges.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAGjD,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAY3B,MAAM,WAAW,eAAe;IAC9B,YAAY,EAAE,YAAY,CAAA;CAC3B;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,eAAe,GAAG,IAAI,CAkB7D"}
1
+ {"version":3,"file":"edges.d.ts","sourceRoot":"","sources":["../../src/routes/edges.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAEjD,OAAO,EAAe,WAAW,EAAK,MAAM,mBAAmB,CAAA;AAgB/D,MAAM,WAAW,eAAe;IAC9B,YAAY,EAAE,YAAY,CAAA;CAC3B;AAqBD,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,eAAe,GAAG,WAAW,CAgBpE"}
@@ -1,29 +1,47 @@
1
- import { EdgeTypeId, NodeId } from '@braidhq/schema';
2
- import { zValidator } from '@hono/zod-validator';
3
- import { Hono } from 'hono';
4
- import { z } from 'zod';
1
+ import { EdgeTypeId, GraphEdge, NodeId } from '@braidhq/schema';
2
+ import { createRoute, OpenAPIHono, z } from '@hono/zod-openapi';
5
3
  import { getWorkspaceId } from '../middleware/workspaceId.js';
6
- const ListQuerySchema = z.object({
7
- type: z.union([EdgeTypeId, z.array(EdgeTypeId)]).optional(),
8
- fromNodeId: NodeId.optional(),
9
- toNodeId: NodeId.optional(),
10
- limit: z.coerce.number().int().positive().optional(),
11
- offset: z.coerce.number().int().nonnegative().optional(),
4
+ import { ValidationFailureResponse, WorkspaceIdParam } from './_shared.js';
5
+ const ListQuery = z.object({
6
+ type: z.union([EdgeTypeId, z.array(EdgeTypeId)]).optional().openapi({ description: 'Filter by edge type id. Pass one or many.' }),
7
+ fromNodeId: NodeId.optional()
8
+ .openapi({ description: 'Filter to edges originating from this node.' }),
9
+ toNodeId: NodeId.optional()
10
+ .openapi({ description: 'Filter to edges terminating at this node.' }),
11
+ });
12
+ const EdgeListResponse = z.object({
13
+ items: z.array(GraphEdge),
14
+ }).openapi('EdgeListResponse');
15
+ const listEdgesRoute = createRoute({
16
+ method: 'get',
17
+ path: '/',
18
+ operationId: 'listEdges',
19
+ summary: 'List edges in the graph, optionally filtered by type / endpoint / pagination.',
20
+ tags: ['edges'],
21
+ request: {
22
+ params: WorkspaceIdParam,
23
+ query: ListQuery,
24
+ },
25
+ responses: {
26
+ 200: {
27
+ description: 'A page of matching edges.',
28
+ content: { 'application/json': { schema: EdgeListResponse } },
29
+ },
30
+ 400: ValidationFailureResponse,
31
+ },
12
32
  });
13
33
  export function createEdgesRouter(deps) {
14
- const router = new Hono();
15
- router.get('/', zValidator('query', ListQuerySchema), async (context) => {
34
+ const router = new OpenAPIHono();
35
+ router.openapi(listEdgesRoute, async (context) => {
16
36
  const workspaceId = getWorkspaceId(context);
17
- const { type, fromNodeId, toNodeId, limit, offset } = context.req.valid('query');
37
+ const { type, fromNodeId, toNodeId } = context.req.valid('query');
18
38
  const types = type === undefined ? undefined : Array.isArray(type) ? type : [type];
19
39
  const edges = await deps.modelService.listEdges(workspaceId, {
20
40
  types,
21
41
  fromNodeId,
22
42
  toNodeId,
23
- limit,
24
- offset,
25
43
  });
26
- return context.json({ items: edges });
44
+ return context.json({ items: edges }, 200);
27
45
  });
28
46
  return router;
29
47
  }
@@ -1 +1 @@
1
- {"version":3,"file":"edges.js","sourceRoot":"","sources":["../../src/routes/edges.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAChD,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAC3B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAA;AAE7D,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC;IAC/B,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IAC3D,UAAU,EAAE,MAAM,CAAC,QAAQ,EAAE;IAC7B,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE;IAC3B,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;IACpD,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,E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O,EAAE,EAAE;QAC/C,MAAM,WAAW,GAAG,cAAc,CAAC,OAAO,CAAC,CAAA;QAC3C,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;QACjE,MAAM,KAAK,GAAG,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAA;QAClF,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,WAAW,EAAE;YAC3D,KAAK;YACL,UAAU;YACV,QAAQ;SACT,CAAC,CAAA;QACF,OAAO,OAAO,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,GAAG,CAAC,CAAA;IAC5C,CAAC,CAAC,CAAA;IAEF,OAAO,MAAM,CAAA;AACf,CAAC"}
@@ -1,3 +1,3 @@
1
- import { Hono } from 'hono';
2
- export declare const healthRouter: Hono<import("hono/types").BlankEnv, import("hono/types").BlankSchema, "/">;
1
+ import { OpenAPIHono } from '@hono/zod-openapi';
2
+ export declare const healthRouter: OpenAPIHono<import("hono").Env, {}, "/">;
3
3
  //# sourceMappingURL=health.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"health.d.ts","sourceRoot":"","sources":["../../src/routes/health.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAE3B,eAAO,MAAM,YAAY,4EAAa,CAAA"}
1
+ {"version":3,"file":"health.d.ts","sourceRoot":"","sources":["../../src/routes/health.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,WAAW,EAAK,MAAM,mBAAmB,CAAA;AAsB/D,eAAO,MAAM,YAAY,0CAAoB,CAAA"}
@@ -1,6 +1,24 @@
1
- import { Hono } from 'hono';
2
- export const healthRouter = new Hono();
3
- healthRouter.get('/', (context) => {
1
+ import { createRoute, OpenAPIHono, z } from '@hono/zod-openapi';
2
+ const HealthResponse = z.object({
3
+ status: z.literal('ok'),
4
+ service: z.literal('braid-server'),
5
+ timestamp: z.string(),
6
+ }).openapi('HealthResponse');
7
+ const healthRoute = createRoute({
8
+ method: 'get',
9
+ path: '/',
10
+ operationId: 'health',
11
+ summary: 'Liveness probe',
12
+ tags: ['health'],
13
+ responses: {
14
+ 200: {
15
+ description: 'Server is up.',
16
+ content: { 'application/json': { schema: HealthResponse } },
17
+ },
18
+ },
19
+ });
20
+ export const healthRouter = new OpenAPIHono();
21
+ healthRouter.openapi(healthRoute, (context) => {
4
22
  return context.json({
5
23
  status: 'ok',
6
24
  service: 'braid-server',
@@ -1 +1 @@
1
- {"version":3,"file":"health.js","sourceRoot":"","sources":["../../src/routes/health.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAE3B,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,IAAI,EAAE,CAAA;AAEtC,YAAY,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,OAAO,EAAE,EAAE;IAChC,OAAO,OAAO,CAAC,IAAI,CAAC;QAClB,MAAM,EAAE,IAAI;QACZ,OAAO,EAAE,cAAc;QACvB,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;KACpC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
1
+ {"version":3,"file":"health.js","sourceRoot":"","sources":["../../src/routes/health.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAA;AAE/D,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,CAAC;IAC9B,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC;IACvB,OAAO,EAAE,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC;IAClC,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;CACtB,CAAC,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAA;AAE5B,MAAM,WAAW,GAAG,WAAW,CAAC;IAC9B,MAAM,EAAE,KAAK;IACb,IAAI,EAAE,GAAG;IACT,WAAW,EAAE,QAAQ;IACrB,OAAO,EAAE,gBAAgB;IACzB,IAAI,EAAE,CAAC,QAAQ,CAAC;IAChB,SAAS,EAAE;QACT,GAAG,EAAE;YACH,WAAW,EAAE,eAAe;YAC5B,OAAO,EAAE,EAAE,kBAAkB,EAAE,EAAE,MAAM,EAAE,cAAc,EAAE,EAAE;SAC5D;KACF;CACF,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,WAAW,EAAE,CAAA;AAE7C,YAAY,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,OAAO,EAAE,EAAE;IAC5C,OAAO,OAAO,CAAC,IAAI,CAAC;QAClB,MAAM,EAAE,IAAa;QACrB,OAAO,EAAE,cAAuB;QAChC,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;KACpC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
@@ -0,0 +1,7 @@
1
+ import type { HistoryService } from '@braidhq/core';
2
+ import { Hono } from 'hono';
3
+ export interface HistoryRouterDeps {
4
+ historyService: HistoryService;
5
+ }
6
+ export declare function createHistoryRouter(deps: HistoryRouterDeps): Hono;
7
+ //# sourceMappingURL=history.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"history.d.ts","sourceRoot":"","sources":["../../src/routes/history.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAInD,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AA6B3B,MAAM,WAAW,iBAAiB;IAChC,cAAc,EAAE,cAAc,CAAA;CAC/B;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,iBAAiB,GAAG,IAAI,CAqEjE"}
@@ -0,0 +1,90 @@
1
+ import { NotFoundError } from '@braidhq/core';
2
+ import { CommitSha, UserId } from '@braidhq/schema';
3
+ import { zValidator } from '@hono/zod-validator';
4
+ import { Hono } from 'hono';
5
+ import { z } from 'zod';
6
+ import { getUserId } from '../middleware/auth.js';
7
+ import { requirePermission } from '../middleware/workspaceAccess.js';
8
+ import { getWorkspaceId } from '../middleware/workspaceId.js';
9
+ // `userId` accepted for backwards compat,
10
+ // the authoritative value comes from the request context,
11
+ // set by the auth middleware.
12
+ const RestoreBody = z.object({
13
+ userId: UserId.optional(),
14
+ });
15
+ const TagBody = z.object({
16
+ sha: CommitSha,
17
+ name: z.string().min(1).max(120),
18
+ note: z.string().max(2000).optional(),
19
+ });
20
+ const ListQuery = z.object({
21
+ since: CommitSha.optional(),
22
+ limit: z.coerce.number().int().positive().max(200).optional(),
23
+ });
24
+ const ModelDiffQuery = z.object({
25
+ from: CommitSha,
26
+ to: CommitSha,
27
+ });
28
+ export function createHistoryRouter(deps) {
29
+ const router = new Hono();
30
+ // Restore is destructive, Owner only.
31
+ // Tag CRUD is workspace metadata management,
32
+ // Owner only as well to keep ACL coherent.
33
+ router.use('/:sha/restore', requirePermission('history.write'));
34
+ router.use('/tags', requirePermission('history.write'));
35
+ router.use('/tags/*', requirePermission('history.write'));
36
+ router.get('/', zValidator('query', ListQuery), async (context) => {
37
+ const workspaceId = getWorkspaceId(context);
38
+ const { since, limit } = context.req.valid('query');
39
+ const items = await deps.historyService.listCommits(workspaceId, {
40
+ ...(since ? { since } : {}),
41
+ ...(limit ? { limit } : {}),
42
+ });
43
+ return context.json({ items });
44
+ });
45
+ // Must be registered before `/:sha` so `graph-diff` isn't matched as a sha.
46
+ router.get('/graph-diff', zValidator('query', ModelDiffQuery), async (context) => {
47
+ const workspaceId = getWorkspaceId(context);
48
+ const { from, to } = context.req.valid('query');
49
+ const envelope = await deps.historyService.getModelDiff(workspaceId, from, to);
50
+ return context.json(envelope);
51
+ });
52
+ router.get('/tags', async (context) => {
53
+ const workspaceId = getWorkspaceId(context);
54
+ const items = await deps.historyService.listTags(workspaceId);
55
+ return context.json({ items });
56
+ });
57
+ router.post('/tags', zValidator('json', TagBody), async (context) => {
58
+ const workspaceId = getWorkspaceId(context);
59
+ const { sha, name, note } = context.req.valid('json');
60
+ const tag = await deps.historyService.createTag(workspaceId, sha, name, note);
61
+ return context.json(tag, 201);
62
+ });
63
+ router.delete('/tags/:name', async (context) => {
64
+ const workspaceId = getWorkspaceId(context);
65
+ const name = context.req.param('name');
66
+ if (!name)
67
+ throw new NotFoundError('Tag name is required');
68
+ await deps.historyService.deleteTag(workspaceId, name);
69
+ return context.body(null, 204);
70
+ });
71
+ router.post('/:sha/restore', zValidator('json', RestoreBody), async (context) => {
72
+ const workspaceId = getWorkspaceId(context);
73
+ const sha = CommitSha.parse(context.req.param('sha'));
74
+ const { userId: bodyUserId } = context.req.valid('json');
75
+ const userId = bodyUserId ?? getUserId(context);
76
+ const newSha = await deps.historyService.restore(workspaceId, sha, userId);
77
+ return context.json({ newCommit: newSha, restoredTo: sha });
78
+ });
79
+ router.get('/:sha', async (context) => {
80
+ const workspaceId = getWorkspaceId(context);
81
+ const sha = CommitSha.parse(context.req.param('sha'));
82
+ const commit = await deps.historyService.getCommit(workspaceId, sha);
83
+ if (!commit)
84
+ throw new NotFoundError(`Commit ${sha} not found in workspace ${workspaceId}`);
85
+ const diff = await deps.historyService.getCommitDiff(workspaceId, sha);
86
+ return context.json({ ...commit, diff });
87
+ });
88
+ return router;
89
+ }
90
+ //# sourceMappingURL=history.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"history.js","sourceRoot":"","sources":["../../src/routes/history.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAA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QAChF,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,aAAa,CAAC,WAAW,EAAE,GAAG,CAAC,CAAA;QACtE,OAAO,OAAO,CAAC,IAAI,CAAC,EAAE,GAAG,MAAM,EAAE,IAAI,EAAE,CAAC,CAAA;IAC1C,CAAC,CAAC,CAAA;IAEF,OAAO,MAAM,CAAA;AACf,CAAC"}
@@ -1,7 +1,7 @@
1
1
  import type { ModelService } from '@braidhq/core';
2
- import { Hono } from 'hono';
2
+ import { OpenAPIHono } from '@hono/zod-openapi';
3
3
  export interface ModelRouterDeps {
4
4
  modelService: ModelService;
5
5
  }
6
- export declare function createModelRouter(deps: ModelRouterDeps): Hono;
6
+ export declare function createModelRouter(deps: ModelRouterDeps): OpenAPIHono;
7
7
  //# sourceMappingURL=model.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/routes/model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AACjD,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAG3B,MAAM,WAAW,eAAe;IAC9B,YAAY,EAAE,YAAY,CAAA;CAC3B;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,eAAe,GAAG,IAAI,CAU7D"}
1
+ {"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/routes/model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAEjD,OAAO,EAAe,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAI5D,MAAM,WAAW,eAAe;IAC9B,YAAY,EAAE,YAAY,CAAA;CAC3B;AAiBD,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,eAAe,GAAG,WAAW,CAUpE"}
@@ -1,11 +1,27 @@
1
- import { Hono } from 'hono';
1
+ import { ModelSnapshot } from '@braidhq/schema';
2
+ import { createRoute, OpenAPIHono } from '@hono/zod-openapi';
2
3
  import { getWorkspaceId } from '../middleware/workspaceId.js';
4
+ import { WorkspaceIdParam } from './_shared.js';
5
+ const getSnapshotRoute = createRoute({
6
+ method: 'get',
7
+ path: '/snapshot',
8
+ operationId: 'getModelSnapshot',
9
+ summary: 'Return the full graph snapshot (nodes + edges) for a workspace.',
10
+ tags: ['model'],
11
+ request: { params: WorkspaceIdParam },
12
+ responses: {
13
+ 200: {
14
+ description: 'The full graph snapshot.',
15
+ content: { 'application/json': { schema: ModelSnapshot } },
16
+ },
17
+ },
18
+ });
3
19
  export function createModelRouter(deps) {
4
- const router = new Hono();
5
- router.get('/snapshot', async (context) => {
20
+ const router = new OpenAPIHono();
21
+ router.openapi(getSnapshotRoute, async (context) => {
6
22
  const workspaceId = getWorkspaceId(context);
7
23
  const snapshot = await deps.modelService.getSnapshot(workspaceId);
8
- return context.json(snapshot);
24
+ return context.json(snapshot, 200);
9
25
  });
10
26
  return router;
11
27
  }
@@ -1 +1 @@
1
- {"version":3,"file":"model.js","sourceRoot":"","sources":["../../src/routes/model.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAC3B,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAA;AAM7D,MAAM,UAAU,iBAAiB,CAAC,IAAqB;IACrD,MAAM,MAAM,GAAG,IAAI,IAAI,EAAE,CAAA;IAEzB,MAAM,CAAC,GAAG,CAAC,WAAW,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;QACxC,MAAM,WAAW,GAAG,cAAc,CAAC,OAAO,CAAC,CAAA;QAC3C,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,WAAW,CAAC,CAAA;QACjE,OAAO,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;IAC/B,CAAC,CAAC,CAAA;IAEF,OAAO,MAAM,CAAA;AACf,CAAC"}
1
+ {"version":3,"file":"model.js","sourceRoot":"","sources":["../../src/routes/model.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAA;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAM/C,MAAM,gBAAgB,GAAG,WAAW,CAAC;IACnC,MAAM,EAAE,KAAK;IACb,IAAI,EAAE,WAAW;IACjB,WAAW,EAAE,kBAAkB;IAC/B,OAAO,EAAE,iEAAiE;IAC1E,IAAI,EAAE,CAAC,OAAO,CAAC;IACf,OAAO,EAAE,EAAE,MAAM,EAAE,gBAAgB,EAAE;IACrC,SAAS,EAAE;QACT,GAAG,EAAE;YACH,WAAW,EAAE,0BAA0B;YACvC,OAAO,EAAE,EAAE,kBAAkB,EAAE,EAAE,MAAM,EAAE,aAAa,EAAE,EAAE;SAC3D;KACF;CACF,CAAC,CAAA;AAEF,MAAM,UAAU,iBAAiB,CAAC,IAAqB;IACrD,MAAM,MAAM,GAAG,IAAI,WAAW,EAAE,CAAA;IAEhC,MAAM,CAAC,OAAO,CAAC,gBAAgB,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;QACjD,MAAM,WAAW,GAAG,cAAc,CAAC,OAAO,CAAC,CAAA;QAC3C,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,WAAW,CAAC,CAAA;QACjE,OAAO,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAA;IACpC,CAAC,CAAC,CAAA;IAEF,OAAO,MAAM,CAAA;AACf,CAAC"}
@@ -1,7 +1,7 @@
1
1
  import type { ModelService } from '@braidhq/core';
2
- import { Hono } from 'hono';
2
+ import { OpenAPIHono } from '@hono/zod-openapi';
3
3
  export interface NodesRouterDeps {
4
4
  modelService: ModelService;
5
5
  }
6
- export declare function createNodesRouter(deps: NodesRouterDeps): Hono;
6
+ export declare function createNodesRouter(deps: NodesRouterDeps): OpenAPIHono;
7
7
  //# sourceMappingURL=nodes.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"nodes.d.ts","sourceRoot":"","sources":["../../src/routes/nodes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAGjD,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAgB3B,MAAM,WAAW,eAAe;IAC9B,YAAY,EAAE,YAAY,CAAA;CAC3B;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,eAAe,GAAG,IAAI,CAkC7D"}
1
+ {"version":3,"file":"nodes.d.ts","sourceRoot":"","sources":["../../src/routes/nodes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAEjD,OAAO,EAAe,WAAW,EAAK,MAAM,mBAAmB,CAAA;AAsB/D,MAAM,WAAW,eAAe;IAC9B,YAAY,EAAE,YAAY,CAAA;CAC3B;AAwDD,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,eAAe,GAAG,WAAW,CAgCpE"}