@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
@@ -1,42 +1,244 @@
1
- import { SkillId as SkillIdSchema } from '@braidhq/schema';
2
- import { zValidator } from '@hono/zod-validator';
3
- import { Hono } from 'hono';
4
- import { z } from 'zod';
1
+ import { createLogger, ValidationError } from '@braidhq/core';
2
+ import { SkillId as SkillIdSchema, SkillManifest, SkillRunId, SourceId } from '@braidhq/schema';
3
+ import { createRoute, OpenAPIHono, z } from '@hono/zod-openapi';
4
+ import { extractBearerToken } from '../middleware/auth.js';
5
+ import { requirePermission } from '../middleware/workspaceAccess.js';
5
6
  import { getWorkspaceId } from '../middleware/workspaceId.js';
7
+ import { NotFoundResponse, WorkspaceIdParam } from './_shared.js';
6
8
  import { loadWorkspaceById } from './helpers.js';
7
- const RunBodySchema = z.object({
9
+ const SourceUnitRef = z.object({
10
+ sourceId: SourceId,
11
+ path: z.string().min(1),
12
+ }).openapi('SourceUnitRef');
13
+ const RunBody = z.object({
8
14
  args: z.string().default(''),
9
- /** Continue an existing claude conversation (from a prior session-started event). */
15
+ // Continue a prior claude conversation from a session-started event.
10
16
  resumeSessionId: z.string().min(1).optional(),
17
+ // Identifies the source unit this run will process,
18
+ // so the server records an observation against it after a clean run.
19
+ // Studio sends this when the user picks a `source-intent` option.
20
+ // Only `ddd:extract` consumes it today, other skills ignore it.
21
+ sourceUnit: SourceUnitRef.optional(),
22
+ }).openapi('SkillRunBody');
23
+ const SkillIdParam = WorkspaceIdParam.extend({
24
+ skillId: SkillIdSchema.openapi({ param: { name: 'skillId', in: 'path' } }),
25
+ });
26
+ const SkillListResponse = z.object({
27
+ items: z.array(SkillManifest),
28
+ }).openapi('SkillListResponse');
29
+ const RunCreatedResponse = z.object({
30
+ runId: SkillRunId,
31
+ }).openapi('RunCreatedResponse');
32
+ const listSkillsRoute = createRoute({
33
+ method: 'get',
34
+ path: '/',
35
+ operationId: 'listSkills',
36
+ summary: 'List skills available in a workspace (builtin + plugin + workspace + extension overlays).',
37
+ tags: ['skills'],
38
+ request: { params: WorkspaceIdParam },
39
+ responses: {
40
+ 200: {
41
+ description: 'The skill list.',
42
+ content: { 'application/json': { schema: SkillListResponse } },
43
+ },
44
+ },
45
+ });
46
+ const getSkillRoute = createRoute({
47
+ method: 'get',
48
+ path: '/{skillId}',
49
+ operationId: 'getSkill',
50
+ summary: 'Fetch a single skill manifest by id.',
51
+ tags: ['skills'],
52
+ request: { params: SkillIdParam },
53
+ responses: {
54
+ 200: {
55
+ description: 'The skill manifest.',
56
+ content: { 'application/json': { schema: SkillManifest } },
57
+ },
58
+ 404: NotFoundResponse,
59
+ },
60
+ });
61
+ const runSkillRoute = createRoute({
62
+ method: 'post',
63
+ path: '/{skillId}/run',
64
+ operationId: 'runSkill',
65
+ summary: 'Fire-and-forget run of a skill. Returns the runId to subscribe to via SSE.',
66
+ description: 'The subprocess + event drain runs in the background. Events are persisted to JSONL and broadcast to subscribers regardless of whether the client stays connected. Tail progress via GET /workspaces/{workspaceId}/runs/{runId}/events.',
67
+ tags: ['skills'],
68
+ request: {
69
+ params: SkillIdParam,
70
+ body: { content: { 'application/json': { schema: RunBody } } },
71
+ },
72
+ responses: {
73
+ 202: {
74
+ description: 'The accepted run id.',
75
+ content: { 'application/json': { schema: RunCreatedResponse } },
76
+ },
77
+ 403: {
78
+ description: 'Caller is not permitted to run this skill in this workspace.',
79
+ content: { 'application/problem+json': { schema: z.object({}).passthrough() } },
80
+ },
81
+ 404: NotFoundResponse,
82
+ },
11
83
  });
12
84
  export function createSkillsRouter(deps) {
13
- const router = new Hono();
14
- router.get('/', async (context) => {
85
+ const router = new OpenAPIHono();
86
+ // skill.run is the only capability needing a per-request resource,
87
+ // the skill manifest.
88
+ // The builder fetches workspace and manifest once,
89
+ // then hands the result to the policy check.
90
+ router.use('/:skillId/run', requirePermission('skill.run', async (context) => {
91
+ const workspace = await loadWorkspaceById(getWorkspaceId(context), deps.workspaceRepository);
92
+ const skillId = SkillIdSchema.parse(context.req.param('skillId'));
93
+ const manifest = await deps.skillRegistry.get(workspace, skillId);
94
+ return { skill: manifest.toData().frontmatter, skillId };
95
+ }));
96
+ router.openapi(listSkillsRoute, async (context) => {
15
97
  const workspace = await loadWorkspaceById(getWorkspaceId(context), deps.workspaceRepository);
16
98
  const manifests = await deps.skillRegistry.list(workspace);
17
99
  return context.json({
18
100
  items: manifests.map(manifest => manifest.toData()),
19
- });
101
+ }, 200);
20
102
  });
21
- router.get('/:skillId', async (context) => {
103
+ router.openapi(getSkillRoute, async (context) => {
22
104
  const workspace = await loadWorkspaceById(getWorkspaceId(context), deps.workspaceRepository);
23
- const skillId = SkillIdSchema.parse(context.req.param('skillId'));
105
+ const { skillId } = context.req.valid('param');
24
106
  const manifest = await deps.skillRegistry.get(workspace, skillId);
25
- return context.json(manifest.toData());
107
+ return context.json(manifest.toData(), 200);
26
108
  });
27
- // Fire-and-forget run. The subprocess + event drain runs in the background;
28
- // events are persisted to JSONL and broadcast to subscribers regardless of
29
- // whether the client stays connected. The client tails progress via
30
- // `GET /workspaces/:ws/runs/:runId/events`, which can be opened and closed
31
- // freely without affecting the run.
32
- router.post('/:skillId/run', zValidator('json', RunBodySchema), async (context) => {
109
+ router.openapi(runSkillRoute, async (context) => {
33
110
  const workspace = await loadWorkspaceById(getWorkspaceId(context), deps.workspaceRepository);
34
- const skillId = SkillIdSchema.parse(context.req.param('skillId'));
35
- const { args, resumeSessionId } = context.req.valid('json');
36
- const options = resumeSessionId ? { resumeSessionId } : undefined;
111
+ const { skillId } = context.req.valid('param');
112
+ const { args, resumeSessionId, sourceUnit } = context.req.valid('json');
113
+ const callerToken = extractBearerToken(context);
114
+ const options = {
115
+ ...(resumeSessionId ? { resumeSessionId } : {}),
116
+ ...(callerToken ? { callerToken } : {}),
117
+ };
118
+ const perUnitSkillId = resolvePerUnitSkillId(deps.pluginRegistry, workspace);
119
+ if (sourceUnit) {
120
+ // The sourceUnit applies only to the ontology's per-unit step,
121
+ // so reject it for any other skill.
122
+ // Otherwise the run-skill route advertises support uniformly,
123
+ // then silently drops it for every skill except extract.
124
+ if (!perUnitSkillId || skillId !== perUnitSkillId) {
125
+ throw new ValidationError(perUnitSkillId
126
+ ? `The \`sourceUnit\` field is only accepted for "${perUnitSkillId}", the active ontology's per-unit skill.`
127
+ : `The \`sourceUnit\` field is not accepted, the active ontology declares no per-unit skill.`);
128
+ }
129
+ // Reject a sourceUnit whose sourceId is not an intent source here.
130
+ // Recording against a ghost sourceId would pollute the ledger,
131
+ // and confuse the Reactor and BatchService diff.
132
+ const known = workspace.sources.find(s => s.id === sourceUnit.sourceId && s.role === 'intent');
133
+ if (!known)
134
+ throw new ValidationError(`Source-unit id "${sourceUnit.sourceId}" does not name an intent source in workspace "${workspace.id}"`);
135
+ }
37
136
  const runId = await deps.skillRunner.start(workspace, skillId, args, options);
137
+ // The observation hook runs in the background,
138
+ // so the route still returns 202 promptly.
139
+ // Any failure (skill error, cancel, repository write) is logged,
140
+ // but does not bubble up to the client.
141
+ if (sourceUnit && perUnitSkillId && skillId === perUnitSkillId) {
142
+ void recordObservationOnSuccess({
143
+ runner: deps.skillRunner,
144
+ runRepository: deps.runRepository,
145
+ sourceUnitObservationService: deps.sourceUnitObservationService,
146
+ workspace,
147
+ runId,
148
+ sourceUnit,
149
+ });
150
+ }
38
151
  return context.json({ runId }, 202);
39
152
  });
40
153
  return router;
41
154
  }
155
+ function resolvePerUnitSkillId(pluginRegistry, workspace) {
156
+ const ontology = pluginRegistry.findOntology(workspace.productManifest.ontologyId);
157
+ return ontology?.batch?.perUnit?.skillId;
158
+ }
159
+ const recordLogger = createLogger('skills.recordObservation');
160
+ // Stop waiting after this many ms, even if no terminal event arrives.
161
+ // Real ddd:extract runs settle in seconds to minutes.
162
+ // This backstops orphan subscriptions on crashed runners,
163
+ // or upstream queues that quietly drop events.
164
+ const OBSERVATION_TIMEOUT_MS = 60 * 60 * 1000;
165
+ // Subscribe to a run and wait for it to terminate.
166
+ // Record a SourceUnitObservation only if it exits cleanly (code 0).
167
+ // On cancellation, non-zero exit, error, or timeout,
168
+ // the previously recorded state is left untouched.
169
+ //
170
+ // Two race-safety measures matter here.
171
+ // First, we subscribe before checking `isActive`.
172
+ // A run finishing between those steps would miss the terminal event,
173
+ // so we backfill from the persisted RunRecord exit code.
174
+ // Second, the Promise has a hard timeout.
175
+ // A run that never emits a terminal event cannot leak the closure.
176
+ async function recordObservationOnSuccess(params) {
177
+ const { runner, runRepository, sourceUnitObservationService, workspace, runId, sourceUnit } = params;
178
+ const workspaceId = workspace.id;
179
+ try {
180
+ const outcome = await waitForTerminalOutcome(runner, runRepository, workspace, runId);
181
+ if (outcome !== 'success')
182
+ return;
183
+ await sourceUnitObservationService.recordObservation(workspaceId, sourceUnit.sourceId, sourceUnit.path, runId);
184
+ }
185
+ catch (err) {
186
+ recordLogger.warn({
187
+ runId,
188
+ workspaceId,
189
+ sourceId: sourceUnit.sourceId,
190
+ path: sourceUnit.path,
191
+ err: err instanceof Error ? err.message : String(err),
192
+ }, 'failed to record observation after ddd:extract run');
193
+ }
194
+ }
195
+ async function waitForTerminalOutcome(runner, runRepository, workspace, runId) {
196
+ return new Promise((resolve) => {
197
+ let settled = false;
198
+ let timeout;
199
+ // Subscribe first, so future events from a still-active run reach us.
200
+ // Checking `isActive` first would race.
201
+ // A run finishing between the two steps would miss the terminal event.
202
+ const sub = runner.subscribe(runId, (event) => {
203
+ if (event.type === 'completed')
204
+ settle(event.exitCode === 0 ? 'success' : 'failure');
205
+ else if (event.type === 'error')
206
+ settle('failure');
207
+ });
208
+ function settle(outcome) {
209
+ if (settled)
210
+ return;
211
+ settled = true;
212
+ sub.unsubscribe();
213
+ if (timeout)
214
+ clearTimeout(timeout);
215
+ resolve(outcome);
216
+ }
217
+ // Backfill for an already-finished run.
218
+ // Its subscription never receives a terminal event,
219
+ // because the runner clears subscribers when drain exits.
220
+ // Read the persisted RunRecord instead.
221
+ if (!runner.isActive(runId)) {
222
+ ;
223
+ (async () => {
224
+ try {
225
+ const records = await runRepository.listRecords(workspace);
226
+ const record = records.find(r => r.runId === runId);
227
+ if (record?.exitCode !== undefined)
228
+ settle(record.exitCode === 0 ? 'success' : 'failure');
229
+ else
230
+ settle('failure');
231
+ }
232
+ catch {
233
+ settle('failure');
234
+ }
235
+ })();
236
+ }
237
+ // Timeout backstop. .unref() lets Node exit while the timer pends.
238
+ // Observation recording is best-effort,
239
+ // not a reason to hold the process open.
240
+ timeout = setTimeout(() => settle('failure'), OBSERVATION_TIMEOUT_MS);
241
+ timeout.unref?.();
242
+ });
243
+ }
42
244
  //# sourceMappingURL=skills.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"skills.js","sourceRoot":"","sources":["../../src/routes/skills.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC1D,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;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAEhD,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,CAAC;IAC7B,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,E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K,IAAI,EAAE;gBACX,IAAI,CAAC;oBACH,MAAM,OAAO,GAAG,MAAM,aAAa,CAAC,WAAW,CAAC,SAAS,CAAC,CAAA;oBAC1D,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,KAAK,CAAC,CAAA;oBACnD,IAAI,MAAM,EAAE,QAAQ,KAAK,SAAS;wBAChC,MAAM,CAAC,MAAM,CAAC,QAAQ,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAA;;wBAErD,MAAM,CAAC,SAAS,CAAC,CAAA;gBACrB,CAAC;gBACD,MAAM,CAAC;oBACL,MAAM,CAAC,SAAS,CAAC,CAAA;gBACnB,CAAC;YACH,CAAC,CAAC,EAAE,CAAA;QACN,CAAC;QAED,mEAAmE;QACnE,wCAAwC;QACxC,yCAAyC;QACzC,OAAO,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,sBAAsB,CAAC,CAAA;QACrE,OAAO,CAAC,KAAK,EAAE,EAAE,CAAA;IACnB,CAAC,CAAC,CAAA;AACJ,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { PluginRegistry } from '@braidhq/core';
2
+ import { OpenAPIHono } from '@hono/zod-openapi';
3
+ export interface SourceLoadersRouterDeps {
4
+ pluginRegistry: PluginRegistry;
5
+ }
6
+ export declare function createSourceLoadersRouter(deps: SourceLoadersRouterDeps): OpenAPIHono;
7
+ //# sourceMappingURL=sourceLoaders.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sourceLoaders.d.ts","sourceRoot":"","sources":["../../src/routes/sourceLoaders.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAEnD,OAAO,EAAe,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAE5D,MAAM,WAAW,uBAAuB;IACtC,cAAc,EAAE,cAAc,CAAA;CAC/B;AAiBD,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,uBAAuB,GAAG,WAAW,CAcpF"}
@@ -0,0 +1,30 @@
1
+ import { ListSourceLoadersResponse } from '@braidhq/schema';
2
+ import { createRoute, OpenAPIHono } from '@hono/zod-openapi';
3
+ const listSourceLoadersRoute = createRoute({
4
+ method: 'get',
5
+ path: '/',
6
+ operationId: 'listSourceLoaders',
7
+ summary: 'List source-loader plugins registered on this server.',
8
+ description: 'Studio uses this to populate its loader dropdown without hardcoding `git / github / gdrive`. The list reflects what `composeFsApp` registered plus any `extraSourceLoaderPlugins` the caller passed in. The `manual` choice in the Studio UI is not a plugin and is not returned here.',
9
+ tags: ['plugins'],
10
+ responses: {
11
+ 200: {
12
+ description: 'Source-loader plugins currently registered.',
13
+ content: { 'application/json': { schema: ListSourceLoadersResponse } },
14
+ },
15
+ },
16
+ });
17
+ export function createSourceLoadersRouter(deps) {
18
+ const router = new OpenAPIHono();
19
+ router.openapi(listSourceLoadersRoute, (context) => {
20
+ const plugins = deps.pluginRegistry.sourceLoaders();
21
+ const loaders = plugins.map(plugin => ({
22
+ kind: plugin.kind,
23
+ pluginId: plugin.id,
24
+ webhook: plugin.webhook !== undefined,
25
+ }));
26
+ return context.json(ListSourceLoadersResponse.parse({ loaders }), 200);
27
+ });
28
+ return router;
29
+ }
30
+ //# sourceMappingURL=sourceLoaders.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sourceLoaders.js","sourceRoot":"","sources":["../../src/routes/sourceLoaders.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAA;AAC3D,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAM5D,MAAM,sBAAsB,GAAG,WAAW,CAAC;IACzC,MAAM,EAAE,KAAK;IACb,IAAI,EAAE,GAAG;IACT,WAAW,EAAE,mBAAmB;IAChC,OAAO,EAAE,uDAAuD;IAChE,WAAW,EAAE,wRAAwR;IACrS,IAAI,EAAE,CAAC,SAAS,CAAC;IACjB,SAAS,EAAE;QACT,GAAG,EAAE;YACH,WAAW,EAAE,6CAA6C;YAC1D,OAAO,EAAE,EAAE,kBAAkB,EAAE,EAAE,MAAM,EAAE,yBAAyB,EAAE,EAAE;SACvE;KACF;CACF,CAAC,CAAA;AAEF,MAAM,UAAU,yBAAyB,CAAC,IAA6B;IACrE,MAAM,MAAM,GAAG,IAAI,WAAW,EAAE,CAAA;IAEhC,MAAM,CAAC,OAAO,CAAC,sBAAsB,EAAE,CAAC,OAAO,EAAE,EAAE;QACjD,MAAM,OAAO,GAAG,IAAI,CAAC,cAAc,CAAC,aAAa,EAAE,CAAA;QACnD,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;YACrC,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,QAAQ,EAAE,MAAM,CAAC,EAAE;YACnB,OAAO,EAAE,MAAM,CAAC,OAAO,KAAK,SAAS;SACtC,CAAC,CAAC,CAAA;QACH,OAAO,OAAO,CAAC,IAAI,CAAC,yBAAyB,CAAC,KAAK,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,GAAG,CAAC,CAAA;IACxE,CAAC,CAAC,CAAA;IAEF,OAAO,MAAM,CAAA;AACf,CAAC"}
@@ -0,0 +1,20 @@
1
+ import type { IntentLister, SourceUnitDigest, SourceUnitObservationService, WorkspaceService } from '@braidhq/core';
2
+ import { OpenAPIHono } from '@hono/zod-openapi';
3
+ export interface SourceUnitObservationsRouterDeps {
4
+ sourceUnitObservationService: SourceUnitObservationService;
5
+ /**
6
+ * Optional `(workspaceService, intentLister, digest)` triple.
7
+ * When all three are present, the router exposes the `:sourceId/diff` route.
8
+ * When any is missing, the route is simply not registered,
9
+ * so callers see a 404 from Hono's router.
10
+ * That matches the unsupported-operation semantics,
11
+ * other partially-wired surfaces follow (Batch, Skills).
12
+ */
13
+ diffSupport?: {
14
+ workspaceService: WorkspaceService;
15
+ intentLister: IntentLister;
16
+ digest: SourceUnitDigest;
17
+ };
18
+ }
19
+ export declare function createSourceUnitObservationsRouter(deps: SourceUnitObservationsRouterDeps): OpenAPIHono;
20
+ //# sourceMappingURL=sourceUnitObservations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sourceUnitObservations.d.ts","sourceRoot":"","sources":["../../src/routes/sourceUnitObservations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,4BAA4B,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAGnH,OAAO,EAAe,WAAW,EAAK,MAAM,mBAAmB,CAAA;AAkB/D,MAAM,WAAW,gCAAgC;IAC/C,4BAA4B,EAAE,4BAA4B,CAAA;IAC1D;;;;;;;OAOG;IACH,WAAW,CAAC,EAAE;QACZ,gBAAgB,EAAE,gBAAgB,CAAA;QAClC,YAAY,EAAE,YAAY,CAAA;QAC1B,MAAM,EAAE,gBAAgB,CAAA;KACzB,CAAA;CACF;AA0CD,wBAAgB,kCAAkC,CAAC,IAAI,EAAE,gCAAgC,GAAG,WAAW,CAgCtG"}
@@ -0,0 +1,80 @@
1
+ import { computeSourceDiff } from '@braidhq/core';
2
+ import { SourceId, SourceUnitDiff, SourceUnitObservation } from '@braidhq/schema';
3
+ import { createRoute, OpenAPIHono, z } from '@hono/zod-openapi';
4
+ import { getWorkspaceId } from '../middleware/workspaceId.js';
5
+ import { NotFoundResponse, ValidationFailureResponse, WorkspaceIdParam } from './_shared.js';
6
+ const ListQuery = z.object({
7
+ sourceId: SourceId.optional().openapi({ description: 'Restrict to one source.' }),
8
+ });
9
+ const ListResponse = z.object({
10
+ items: z.array(SourceUnitObservation),
11
+ }).openapi('SourceUnitObservationListResponse');
12
+ const SourceIdParam = WorkspaceIdParam.extend({
13
+ sourceId: SourceId.openapi({ param: { name: 'sourceId', in: 'path' } }),
14
+ });
15
+ const DiffResponse = SourceUnitDiff.openapi('SourceUnitDiffResponse');
16
+ const listRoute = createRoute({
17
+ method: 'get',
18
+ path: '/',
19
+ operationId: 'listSourceUnitObservations',
20
+ summary: 'List recorded observations per source unit for a workspace.',
21
+ description: 'Returns the framework\'s current view of each source unit '
22
+ + 'last seen by an extract run. One entry per (sourceId, path). Used '
23
+ + 'by Studio to display per-unit freshness and by Reactor to compute '
24
+ + 'what needs re-extraction.',
25
+ tags: ['source-unit-states'],
26
+ request: {
27
+ params: WorkspaceIdParam,
28
+ query: ListQuery,
29
+ },
30
+ responses: {
31
+ 200: {
32
+ description: 'The recorded observations.',
33
+ content: { 'application/json': { schema: ListResponse } },
34
+ },
35
+ 400: ValidationFailureResponse,
36
+ },
37
+ });
38
+ const diffRoute = createRoute({
39
+ method: 'get',
40
+ path: '/{sourceId}/diff',
41
+ operationId: 'getSourceUnitDiff',
42
+ summary: 'Diff a source\'s current units on disk against the recorded ledger.',
43
+ description: 'Returns the partition (`new`, `changed`, `unchanged`, `orphaned`) the Reactor uses internally to decide what to re-extract. Studio\'s Actions form consumes the same shape to render per-option badges on the source-intent picker.',
44
+ tags: ['source-unit-states'],
45
+ request: { params: SourceIdParam },
46
+ responses: {
47
+ 200: {
48
+ description: 'The diff partition.',
49
+ content: { 'application/json': { schema: DiffResponse } },
50
+ },
51
+ 404: NotFoundResponse,
52
+ },
53
+ });
54
+ export function createSourceUnitObservationsRouter(deps) {
55
+ const router = new OpenAPIHono();
56
+ router.openapi(listRoute, async (context) => {
57
+ const workspaceId = getWorkspaceId(context);
58
+ const { sourceId } = context.req.valid('query');
59
+ const items = sourceId
60
+ ? await deps.sourceUnitObservationService.listBySource(workspaceId, sourceId)
61
+ : await deps.sourceUnitObservationService.listByWorkspace(workspaceId);
62
+ return context.json({ items: [...items] }, 200);
63
+ });
64
+ if (deps.diffSupport) {
65
+ const { workspaceService, intentLister, digest } = deps.diffSupport;
66
+ router.openapi(diffRoute, async (context) => {
67
+ const workspaceId = getWorkspaceId(context);
68
+ const { sourceId } = context.req.valid('param');
69
+ const workspace = await workspaceService.findById(workspaceId);
70
+ const diff = await computeSourceDiff({
71
+ intentLister,
72
+ digest,
73
+ sourceUnitObservationService: deps.sourceUnitObservationService,
74
+ }, workspace, sourceId);
75
+ return context.json(diff, 200);
76
+ });
77
+ }
78
+ return router;
79
+ }
80
+ //# sourceMappingURL=sourceUnitObservations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sourceUnitObservations.js","sourceRoot":"","sources":["../../src/routes/sourceUnitObservations.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAA;AACjD,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAA;AACjF,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAA;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAA;AAC7D,OAAO,EAAE,gBAAgB,EAAE,yBAAyB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAE5F,MAAM,SAAS,GAAG,CAAC,CAAC,MAAM,CAAC;IACzB,QAAQ,EAAE,QAAQ,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,EAAE,WAAW,EAAE,yBAAyB,EAAE,CAAC;CAClF,CAAC,CAAA;AAEF,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,CAAC;IAC5B,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,qBAAqB,CAAC;CACtC,CAAC,CAAC,OAAO,CAAC,mCAAmC,CAAC,CAAA;AAE/C,MAAM,aAAa,GAAG,gBAAgB,CAAC,MAAM,CAAC;IAC5C,QAAQ,EAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,CAAC;CACxE,CAAC,CAAA;AAEF,MAAM,YAAY,GAAG,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/SecretStore.js';
3
+ import { OpenAPIHono } from '@hono/zod-openapi';
4
+ import { Hono } from 'hono';
5
+ export interface GithubWebhookReceiverDeps {
6
+ readonly workspaceService: WorkspaceService;
7
+ readonly sourceLoaderRunner: SourceLoaderRunner;
8
+ readonly secretStore: SecretStore;
9
+ readonly pluginRegistry: PluginRegistry;
10
+ }
11
+ export declare function createGithubWebhookReceiver(deps: GithubWebhookReceiverDeps): Hono;
12
+ export interface SourceWebhooksAdminDeps {
13
+ readonly workspaceService: WorkspaceService;
14
+ readonly secretStore: SecretStore;
15
+ readonly pluginRegistry: PluginRegistry;
16
+ /**
17
+ * Base URL under which the public webhook receiver is reachable.
18
+ * Required so the admin response can return an absolute URL,
19
+ * that the user pastes straight into GitHub's webhook settings.
20
+ * When unset (composeApp in tests), the admin endpoints return 503.
21
+ * Better than returning a relative path Studio would render verbatim.
22
+ */
23
+ readonly apiUrl?: string;
24
+ }
25
+ export declare function createSourceWebhooksAdminRouter(deps: SourceWebhooksAdminDeps): OpenAPIHono;
26
+ //# sourceMappingURL=sourceWebhooks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sourceWebhooks.d.ts","sourceRoot":"","sources":["../../src/routes/sourceWebhooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,kBAAkB,EAElB,gBAAgB,EACjB,MAAM,eAAe,CAAA;AACtB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0CAA0C,CAAA;AAK3E,OAAO,EAAe,WAAW,EAAK,MAAM,mBAAmB,CAAA;AAC/D,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AA0C3B,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,gBAAgB,EAAE,gBAAgB,CAAA;IAC3C,QAAQ,CAAC,kBAAkB,EAAE,kBAAkB,CAAA;IAC/C,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAA;IACjC,QAAQ,CAAC,cAAc,EAAE,cAAc,CAAA;CACxC;AA6FD,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,yBAAyB,GAAG,IAAI,CAgFjF;AAYD,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,gBAAgB,EAAE,gBAAgB,CAAA;IAC3C,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAA;IACjC,QAAQ,CAAC,cAAc,EAAE,cAAc,CAAA;IACvC;;;;;;OAMG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CACzB;AA2DD,wBAAgB,+BAA+B,CAAC,IAAI,EAAE,uBAAuB,GAAG,WAAW,CAoC1F"}