@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,18 +1,17 @@
1
- import { mkdir, rm, symlink } from 'node:fs/promises';
1
+ import { mkdir, rm, symlink, writeFile } from 'node:fs/promises';
2
2
  import { dirname, join } from 'node:path';
3
3
  import { newSkillRunId, NotFoundError } from '@braidhq/core';
4
- import { AbsolutePath as AbsolutePathSchema, SkillEvent as SkillEventSchema, SkillRunId as SkillRunIdSchema, } from '@braidhq/schema';
5
- import { sessionDirPath } from '../fs/paths.js';
4
+ import { AbsolutePath as AbsolutePathSchema, McpServerId, SkillEvent as SkillEventSchema, SkillRunId as SkillRunIdSchema, splitSkillId } from '@braidhq/schema';
5
+ import { sessionDirPath } from '../_shared/paths.js';
6
6
  import { createAsyncQueue } from './asyncQueue.js';
7
- import { writeMcpConfigFile } from './mcpConfig.js';
8
7
  import { attachOutputBuffers } from './subprocessEventStream.js';
9
8
  export class SubprocessSkillRunner {
10
9
  deps;
11
10
  running = new Map();
12
- /** sessionId cwd for resuming. claude needs the same cwd between turns. */
11
+ // Maps sessionId to cwd for resuming. claude needs the same cwd per turn.
13
12
  sessionDirs = new Map();
14
13
  subscribers = new Map();
15
- /** How many events have been emitted (and persisted) per run so far. */
14
+ // How many events have been emitted (and persisted) per run so far.
16
15
  positions = new Map();
17
16
  constructor(deps) {
18
17
  this.deps = deps;
@@ -21,28 +20,63 @@ export class SubprocessSkillRunner {
21
20
  const manifest = await this.deps.skillRegistry.get(workspace, skillId);
22
21
  const runId = newSkillRunId();
23
22
  const sessionDir = await this.resolveSessionDir(workspace, runId, options?.resumeSessionId);
24
- const mcpConfigFile = await writeMcpConfigFile(workspace, sessionDir);
25
- const invocation = this.deps.agentBinding.resolveSpawn({
23
+ const skillBundleDirs = await this.skillBundleDirsFor(workspace, sessionDir);
24
+ const gatewayArgs = [
25
+ 'openapi-mcp-gateway',
26
+ '--spec',
27
+ this.deps.coreGateway?.specUrl ?? '',
28
+ '--transport',
29
+ 'stdio',
30
+ '--name',
31
+ 'braid-core',
32
+ // Forward the caller's Bearer token so the gateway authenticates its outgoing API calls.
33
+ // The gateway resolves `${BRAID_TOKEN}` against its process env at startup.
34
+ // Without this the server's auth middleware rejects every callback with 401.
35
+ // eslint-disable-next-line no-template-curly-in-string
36
+ ...(options?.callerToken ? ['--auth-type', 'bearer', '--auth-token', '${BRAID_TOKEN}'] : []),
37
+ ];
38
+ // Compose the MCP server list, the built-in gateway plus any the workspace
39
+ // declares. The binding writes whatever config its CLI needs from this.
40
+ const gatewayServers = this.deps.coreGateway
41
+ ? [{
42
+ id: McpServerId.parse('braid-core'),
43
+ transport: 'stdio',
44
+ command: this.deps.coreGateway.uvxBin ?? 'uvx',
45
+ args: gatewayArgs,
46
+ }]
47
+ : [];
48
+ const binding = this.bindingFor(manifest.frontmatter.braid.agent);
49
+ const invocation = await binding.resolveSpawn({
26
50
  skillId,
27
51
  args,
28
52
  workspace,
29
53
  manifest,
30
54
  apiUrl: this.deps.apiUrl,
31
- mcpConfigFile: AbsolutePathSchema.parse(mcpConfigFile),
55
+ mcpServers: [...gatewayServers, ...workspace.mcpServers],
56
+ sessionDir: AbsolutePathSchema.parse(sessionDir),
57
+ skillBundleDirs,
32
58
  ...(options?.resumeSessionId ? { resumeSessionId: options.resumeSessionId } : {}),
33
59
  });
34
60
  const spawnFn = this.deps.spawn ?? (await defaultSpawn());
35
- // BRAID_SESSION_DIR resolves ambiguity in SKILL.md paths: claude sees
36
- // both `BRAID_WORKSPACE` and a cwd that lives inside it, and would
37
- // otherwise guess wrong about which one `.claude/skills/...` is rooted in.
61
+ // BRAID_SESSION_DIR resolves ambiguity in SKILL.md paths.
62
+ // claude sees both `BRAID_WORKSPACE` and a cwd inside it,
63
+ // and would otherwise guess which one `.claude/skills/...` is rooted in.
38
64
  const child = spawnFn(invocation.bin, [...invocation.args], {
39
65
  cwd: sessionDir,
40
- env: { ...invocation.env, BRAID_SESSION_DIR: sessionDir },
66
+ env: {
67
+ ...invocation.env,
68
+ BRAID_SESSION_DIR: sessionDir,
69
+ // BRAID_TOKEN is read by the braid-core MCP gateway,
70
+ // and by any shell-level callback (curl in a SKILL.md),
71
+ // so the subprocess can authenticate against the running server.
72
+ ...(options?.callerToken ? { BRAID_TOKEN: options.callerToken } : {}),
73
+ ...(options?.extraEnv ?? {}),
74
+ },
41
75
  stdio: ['ignore', 'pipe', 'pipe'],
42
76
  });
43
77
  this.running.set(runId, { workspace, child });
44
- // Persist the started record up front so listing endpoints see the run
45
- // immediately, even before any subprocess output.
78
+ // Persist the started record up front,
79
+ // so listing endpoints see the run immediately, before any output.
46
80
  const startedAt = this.now();
47
81
  const initialRecord = {
48
82
  runId,
@@ -61,12 +95,13 @@ export class SubprocessSkillRunner {
61
95
  skillId,
62
96
  at: startedAt,
63
97
  });
64
- // Fire-and-forget the drain so the HTTP request that called start()
65
- // can return immediately.
98
+ // Fire-and-forget the drain,
99
+ // so the HTTP request that called start() can return immediately.
66
100
  void this.drain({
67
101
  workspace,
68
102
  runId,
69
103
  child,
104
+ parseLine: binding.parseLine,
70
105
  skillId,
71
106
  args,
72
107
  sessionDir,
@@ -122,13 +157,18 @@ export class SubprocessSkillRunner {
122
157
  at: input.startedAt,
123
158
  }));
124
159
  const queue = createAsyncQueue();
125
- const buffers = attachOutputBuffers(input.child, queue.push, () => this.now());
126
- input.child.on('close', (code) => {
160
+ const buffers = attachOutputBuffers(input.child, input.parseLine, queue.push, () => this.now());
161
+ input.child.on('close', (code, signal) => {
127
162
  buffers.flush();
128
163
  queue.push(SkillEventSchema.parse({
129
164
  type: 'completed',
130
165
  runId: input.runId,
131
- exitCode: code ?? 0,
166
+ // A signal-killed run must be reported as non-zero,
167
+ // e.g. cancel via SIGTERM, or OS-level SIGKILL.
168
+ // Downstream consumers then distinguish it from a clean exit.
169
+ // Without this, `code ?? 0` collapses every signal kill to 0,
170
+ // and cancellation looks identical to a clean run.
171
+ exitCode: code ?? (signal ? 128 : 0),
132
172
  at: this.now(),
133
173
  }));
134
174
  queue.end();
@@ -161,17 +201,16 @@ export class SubprocessSkillRunner {
161
201
  at: this.now(),
162
202
  });
163
203
  this.subscribers.delete(input.runId);
164
- // Keep the session dir on disk if a session id was captured: claude
165
- // stores conversation state per-cwd, so the dir must survive between
166
- // turns. GC happens via forgetSession(sessionId).
204
+ // Keep the session dir on disk if a session id was captured.
205
+ // claude stores conversation state per-cwd, so the dir must survive between turns.
206
+ // GC happens via forgetSession(sessionId).
167
207
  const keepForResume = capturedSessionId !== null;
168
208
  if (this.deps.cleanupSession !== false && !keepForResume)
169
209
  await rm(input.sessionDir, { recursive: true, force: true }).catch(() => { });
170
210
  }
171
211
  }
172
- // Persist first, then broadcast. A subscriber that arrived just before
173
- // this emit is guaranteed to receive events strictly past its
174
- // positionAtSubscribe.
212
+ // Persist first, then broadcast.
213
+ // This guarantees a just-subscribed listener receives every event strictly past its positionAtSubscribe.
175
214
  async emit(workspace, runId, event) {
176
215
  await this.deps.runRepository.appendEvent(workspace, runId, event);
177
216
  const next = (this.positions.get(runId) ?? 0) + 1;
@@ -210,25 +249,70 @@ export class SubprocessSkillRunner {
210
249
  }
211
250
  async buildSessionDir(workspace, runId) {
212
251
  const sessionDir = sessionDirPath(workspace.rootPath, runId);
213
- const skillsDir = join(sessionDir, '.claude', 'skills');
214
- await mkdir(skillsDir, { recursive: true });
215
- const manifests = await this.deps.skillRegistry.list(workspace);
216
- const linked = new Set();
217
- for (const manifest of manifests) {
218
- const slashName = manifest.frontmatter.name;
219
- if (linked.has(slashName))
220
- continue;
221
- linked.add(slashName);
222
- await symlink(dirname(manifest.path), join(skillsDir, slashName), 'dir');
223
- }
252
+ // Companion reference docs stay under `.claude/skills/<name>/`,
253
+ // so SKILL.md bodies keep reading `<cwd>/.claude/skills/shared/...`.
254
+ const docsDir = join(sessionDir, '.claude', 'skills');
255
+ await mkdir(docsDir, { recursive: true });
256
+ const linkedRefs = new Set();
224
257
  for (const reference of this.deps.referenceDirs ?? []) {
225
- if (linked.has(reference.name))
258
+ if (linkedRefs.has(reference.name))
226
259
  continue;
227
- linked.add(reference.name);
228
- await symlink(reference.path, join(skillsDir, reference.name), 'dir');
260
+ linkedRefs.add(reference.name);
261
+ await symlink(reference.path, join(docsDir, reference.name), 'dir');
262
+ }
263
+ // Invokable skills stage as one claude plugin per namespace, so a skill
264
+ // invokes as `/namespace:verb`. The colon lives only in the invocation
265
+ // token claude synthesises, never in a path, so the layout is portable.
266
+ const byNamespace = new Map();
267
+ for (const manifest of await this.deps.skillRegistry.list(workspace)) {
268
+ const { namespace } = splitSkillId(manifest.id);
269
+ const bucket = byNamespace.get(namespace) ?? [];
270
+ bucket.push(manifest);
271
+ byNamespace.set(namespace, bucket);
272
+ }
273
+ for (const [namespace, skills] of byNamespace) {
274
+ const pluginDir = this.skillBundleDir(sessionDir, namespace);
275
+ await mkdir(join(pluginDir, '.claude-plugin'), { recursive: true });
276
+ const manifest = { name: namespace, version: '0.0.0', description: `Braid ${namespace} skills` };
277
+ await writeFile(join(pluginDir, '.claude-plugin', 'plugin.json'), `${JSON.stringify(manifest, null, 2)}\n`, 'utf-8');
278
+ const skillsDir = join(pluginDir, 'skills');
279
+ await mkdir(skillsDir, { recursive: true });
280
+ const linked = new Set();
281
+ for (const skill of skills) {
282
+ const { verb } = splitSkillId(skill.id);
283
+ if (linked.has(verb))
284
+ continue;
285
+ linked.add(verb);
286
+ await symlink(dirname(skill.path), join(skillsDir, verb), 'dir');
287
+ }
229
288
  }
230
289
  return sessionDir;
231
290
  }
291
+ skillBundleDir(sessionDir, namespace) {
292
+ return join(sessionDir, '.braid-plugins', namespace);
293
+ }
294
+ // The plugin bundle dir for every namespace present in the workspace.
295
+ // Deterministic from the session dir, so it works on a resumed session,
296
+ // whose bundles were staged on the first run, without restaging.
297
+ async skillBundleDirsFor(workspace, sessionDir) {
298
+ const manifests = await this.deps.skillRegistry.list(workspace);
299
+ const namespaces = [...new Set(manifests.map(manifest => splitSkillId(manifest.id).namespace))];
300
+ return namespaces.map(namespace => this.skillBundleDir(sessionDir, namespace));
301
+ }
302
+ // Merge a skill's agent override onto the server default, then build the binding.
303
+ // Unset override fields inherit the default.
304
+ bindingFor(override) {
305
+ const base = this.deps.defaultAgent;
306
+ const effort = override?.effort ?? base.effort;
307
+ return this.deps.buildAgentBinding({
308
+ id: base.id,
309
+ kind: override?.kind ?? base.kind,
310
+ model: override?.model ?? base.model,
311
+ ...(effort ? { effort } : {}),
312
+ extraArgs: base.extraArgs,
313
+ env: base.env,
314
+ });
315
+ }
232
316
  now() {
233
317
  return (this.deps.clock ?? (() => new Date().toISOString()))();
234
318
  }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SubprocessSkillRunner.js","sourceRoot":"","sources":["../../../src/infrastructure/skill/SubprocessSkillRunner.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAChE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AACzC,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAC5D,OAAO,EAAE,YAAY,IAAI,kBAAkB,EAAE,WAAW,EAAE,UAAU,IAAI,gBAAgB,EAAE,UAAU,IAAI,gBAAgB,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAC/J,OAAO,EAAE,cAAc,EAAE,MAAM,q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;YACX,IAAI,EAAE,QAAQ,EAAE,IAAI,IAAI,IAAI,CAAC,IAAI;YACjC,KAAK,EAAE,QAAQ,EAAE,KAAK,IAAI,IAAI,CAAC,KAAK;YACpC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAC7B,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,GAAG,EAAE,IAAI,CAAC,GAAG;SACd,CAAC,CAAA;IACJ,CAAC;IAEO,GAAG;QACT,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC,EAAE,CAAA;IAChE,CAAC;CACF;AAED,KAAK,UAAU,YAAY;IACzB,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,oBAAoB,CAAC,CAAA;IAC9C,OAAO,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,GAAG,IAAI,CAAC,EAAE,OAAO,CAAC,CAAA;AAC3E,CAAC"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Single-producer, single-consumer async queue backing an `AsyncIterable`.
3
+ * Bridges node `EventEmitter`-style callbacks,
4
+ * which fire whenever subprocess stdout, stderr, or close events arrive,
5
+ * into `for await of` consumers (Hono's SSE writer, vitest assertions),
6
+ * without buffering every event until the producer is done.
7
+ *
8
+ * `push(item)` enqueues an item and wakes a pending consumer.
9
+ * `end()` signals that no more items are coming,
10
+ * the iterator finishes once it has drained the queue.
11
+ * `iterate()` returns a single-use async generator,
12
+ * calling it more than once is undefined.
13
+ */
14
+ export interface AsyncQueue<T> {
15
+ push: (item: T) => void;
16
+ end: () => void;
17
+ iterate: () => AsyncGenerator<T>;
18
+ }
19
+ export declare function createAsyncQueue<T>(): AsyncQueue<T>;
20
+ //# sourceMappingURL=asyncQueue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asyncQueue.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/skill/asyncQueue.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,UAAU,CAAC,CAAC;IAC3B,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI,CAAA;IACvB,GAAG,EAAE,MAAM,IAAI,CAAA;IACf,OAAO,EAAE,MAAM,cAAc,CAAC,CAAC,CAAC,CAAA;CACjC;AAED,wBAAgB,gBAAgB,CAAC,CAAC,KAAK,UAAU,CAAC,CAAC,CAAC,CA0CnD"}
@@ -26,9 +26,8 @@ export function createAsyncQueue() {
26
26
  }
27
27
  if (finished)
28
28
  return;
29
- // The double check inside the Promise constructor avoids a race
30
- // where `push` or `end` is called between the queue-length check
31
- // and the resolver assignment.
29
+ // Re-check inside the Promise constructor to avoid a race,
30
+ // where `push` or `end` fires between the queue-length check and the resolver assignment.
32
31
  await new Promise((r) => {
33
32
  if (buffer.length > 0 || finished) {
34
33
  r();
@@ -1 +1 @@
1
- {"version":3,"file":"asyncQueue.js","sourceRoot":"","sources":["../../../src/infrastructure/agent/asyncQueue.ts"],"names":[],"mappings":"AAqBA,MAAM,UAAU,gBAAgB;IAC9B,MAAM,MAAM,GAAQ,EAAE,CAAA;IACtB,IAAI,QAAQ,GAAwB,IAAI,CAAA;IACxC,IAAI,QAAQ,GAAG,KAAK,CAAA;IAEpB,MAAM,IAAI,GAAG,GAAS,EAAE;QACtB,IAAI,QAAQ,EAAE,CAAC;YACb,MAAM,CAAC,GAAG,QAAQ,CAAA;YAClB,QAAQ,GAAG,IAAI,CAAA;YACf,CAAC,EAAE,CAAA;QACL,CAAC;IACH,CAAC,CAAA;IAED,OAAO;QACL,IAAI,EAAE,CAAC,IAAI,EAAE,EAAE;YACb,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;YACjB,IAAI,EAAE,CAAA;QACR,CAAC;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,QAAQ,GAAG,IAAI,CAAA;YACf,IAAI,EAAE,CAAA;QACR,CAAC;QACD,OAAO,EAAE,KAAK,SAAS,CAAC,CAAC,OAAO;YAC9B,OAAO,IAAI,EAAE,CAAC;gBACZ,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;oBACtB,MAAM,MAAM,CAAC,KAAK,EAAG,CAAA;oBACrB,SAAQ;gBACV,CAAC;gBACD,IAAI,QAAQ;oBACV,OAAM;gBACR,2DAA2D;gBAC3D,0FAA0F;gBAC1F,MAAM,IAAI,OAAO,CAAO,CAAC,CAAC,EAAE,EAAE;oBAC5B,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,IAAI,QAAQ,EAAE,CAAC;wBAClC,CAAC,EAAE,CAAA;wBACH,OAAM;oBACR,CAAC;oBACD,QAAQ,GAAG,CAAC,CAAA;gBACd,CAAC,CAAC,CAAA;YACJ,CAAC;QACH,CAAC;KACF,CAAA;AACH,CAAC"}
@@ -0,0 +1,15 @@
1
+ export type LineHandler = (line: string) => void;
2
+ /**
3
+ * Splits a chunked text stream into newline-delimited lines,
4
+ * invoking the handler once per complete line.
5
+ * Partial lines are buffered until the next chunk completes them.
6
+ * Call `flush()` after the source closes to release any trailing line without a terminator.
7
+ */
8
+ export declare class LineBuffer {
9
+ private readonly onLine;
10
+ private buffer;
11
+ constructor(onLine: LineHandler);
12
+ append(chunk: string): void;
13
+ flush(): void;
14
+ }
15
+ //# sourceMappingURL=lineBuffer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lineBuffer.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/skill/lineBuffer.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;AAEhD;;;;;GAKG;AACH,qBAAa,UAAU;IAGT,OAAO,CAAC,QAAQ,CAAC,MAAM;IAFnC,OAAO,CAAC,MAAM,CAAK;gBAEU,MAAM,EAAE,WAAW;IAEhD,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAY3B,KAAK,IAAI,IAAI;CAOd"}
@@ -1,8 +1,8 @@
1
1
  /**
2
- * Splits a chunked text stream into newline-delimited lines, invoking the
3
- * handler exactly once per complete line. Partial lines are buffered until
4
- * the next chunk completes them. Call `flush()` after the source closes to
5
- * release any trailing line without a terminator.
2
+ * Splits a chunked text stream into newline-delimited lines,
3
+ * invoking the handler once per complete line.
4
+ * Partial lines are buffered until the next chunk completes them.
5
+ * Call `flush()` after the source closes to release any trailing line without a terminator.
6
6
  */
7
7
  export class LineBuffer {
8
8
  onLine;
@@ -29,16 +29,4 @@ export class LineBuffer {
29
29
  this.onLine(remainder);
30
30
  }
31
31
  }
32
- export function parseJsonLine(line) {
33
- const trimmed = line.trim();
34
- if (trimmed.length === 0)
35
- return undefined;
36
- try {
37
- const parsed = JSON.parse(trimmed);
38
- return parsed;
39
- }
40
- catch {
41
- return undefined;
42
- }
43
- }
44
- //# sourceMappingURL=streamJsonParser.js.map
32
+ //# sourceMappingURL=lineBuffer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lineBuffer.js","sourceRoot":"","sources":["../../../src/infrastructure/skill/lineBuffer.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,OAAO,UAAU;IAGQ;IAFrB,MAAM,GAAG,EAAE,CAAA;IAEnB,YAA6B,MAAmB;QAAnB,WAAM,GAAN,MAAM,CAAa;IAAG,CAAC;IAEpD,MAAM,CAAC,KAAa;QAClB,IAAI,CAAC,MAAM,IAAI,KAAK,CAAA;QACpB,IAAI,YAAY,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;QAC5C,OAAO,YAAY,IAAI,CAAC,EAAE,CAAC;YACzB,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,YAAY,CAAC,CAAA;YAC/C,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,YAAY,GAAG,CAAC,CAAC,CAAA;YACjD,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC;gBACjB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;YACnB,YAAY,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;QAC1C,CAAC;IACH,CAAC;IAED,KAAK;QACH,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC;YAC1B,OAAM;QACR,MAAM,SAAS,GAAG,IAAI,CAAC,MAAM,CAAA;QAC7B,IAAI,CAAC,MAAM,GAAG,EAAE,CAAA;QAChB,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAA;IACxB,CAAC;CACF"}
@@ -0,0 +1,20 @@
1
+ import type { Clock, RunRepository, WorkspaceRepository } from '@braidhq/core';
2
+ /**
3
+ * Run records survive across server restarts,
4
+ * but the subprocess that was driving each run does not.
5
+ * On startup any run without a `completedAt` timestamp is an orphan,
6
+ * nobody is going to drain its events.
7
+ * We tag those with a synthetic `error` event,
8
+ * so the UI can show why the transcript is truncated.
9
+ * A `completed` event then makes the run leave the active list.
10
+ *
11
+ * Idempotent: runs that are already marked completed are skipped.
12
+ */
13
+ export declare function reapOrphanRuns(deps: {
14
+ workspaceRepository: WorkspaceRepository;
15
+ runRepository: RunRepository;
16
+ clock: Clock;
17
+ }): Promise<{
18
+ reaped: number;
19
+ }>;
20
+ //# sourceMappingURL=orphanReaper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"orphanReaper.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/skill/orphanReaper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AAG9E;;;;;;;;;;GAUG;AACH,wBAAsB,cAAc,CAAC,IAAI,EAAE;IACzC,mBAAmB,EAAE,mBAAmB,CAAA;IACxC,aAAa,EAAE,aAAa,CAAA;IAC5B,KAAK,EAAE,KAAK,CAAA;CACb,GAAG,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CA+B9B"}
@@ -1,9 +1,11 @@
1
1
  /**
2
- * Run records survive across server restarts, but the subprocess that was
3
- * driving each run does not. On startup any run without a `completedAt`
4
- * timestamp is an orphan: nobody is going to drain its events. We tag those
5
- * with a synthetic `error` event so the UI can show why the transcript is
6
- * truncated, and a `completed` event so the run leaves the active list.
2
+ * Run records survive across server restarts,
3
+ * but the subprocess that was driving each run does not.
4
+ * On startup any run without a `completedAt` timestamp is an orphan,
5
+ * nobody is going to drain its events.
6
+ * We tag those with a synthetic `error` event,
7
+ * so the UI can show why the transcript is truncated.
8
+ * A `completed` event then makes the run leave the active list.
7
9
  *
8
10
  * Idempotent: runs that are already marked completed are skipped.
9
11
  */
@@ -0,0 +1 @@
1
+ {"version":3,"file":"orphanReaper.js","sourceRoot":"","sources":["../../../src/infrastructure/skill/orphanReaper.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,IAIpC;IACC,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,mBAAmB,CAAC,IAAI,EAAE,CAAA;IACxD,IAAI,MAAM,GAAG,CAAC,CAAA;IACd,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACnC,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC,SAAS,CAAC,CAAA;QAC/D,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;YAC7B,IAAI,MAAM,CAAC,WAAW,KAAK,SAAS;gBAClC,SAAQ;YACV,MAAM,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAA;YAC3B,MAAM,KAAK,GAAe;gBACxB,IAAI,EAAE,OAAO;gBACb,OAAO,EAAE,+DAA+D;gBACxE,EAAE;aACH,CAAA;YACD,MAAM,SAAS,GAAe;gBAC5B,IAAI,EAAE,WAAW;gBACjB,KAAK,EAAE,MAAM,CAAC,KAAK;gBACnB,QAAQ,EAAE,CAAC,CAAC;gBACZ,EAAE;aACH,CAAA;YACD,MAAM,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC,SAAS,EAAE,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;YACpE,MAAM,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC,SAAS,EAAE,MAAM,CAAC,KAAK,EAAE,SAAS,CAAC,CAAA;YACxE,MAAM,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,SAAS,EAAE;gBAC7C,GAAG,MAAM;gBACT,WAAW,EAAE,EAAE;gBACf,QAAQ,EAAE,CAAC,CAAC;aACb,CAAC,CAAA;YACF,MAAM,EAAE,CAAA;QACV,CAAC;IACH,CAAC;IACD,OAAO,EAAE,MAAM,EAAE,CAAA;AACnB,CAAC"}
@@ -0,0 +1,16 @@
1
+ import type { SkillEvent } from '@braidhq/schema';
2
+ import type { ChildProcess } from 'node:child_process';
3
+ /**
4
+ * Maps one stdout line to zero or more SkillEvents.
5
+ * The agent binding owns this, since the line format is the agent's own.
6
+ */
7
+ export type LineParser = (line: string, now: string) => SkillEvent[];
8
+ /**
9
+ * Wires a child's stdout and stderr to a single SkillEvent callback.
10
+ * `parseLine` comes from the agent binding, so this stays format-agnostic.
11
+ * Returns `flush` so callers can drain the final un-terminated line on `close`.
12
+ */
13
+ export declare function attachOutputBuffers(child: ChildProcess, parseLine: LineParser, onEvent: (event: SkillEvent) => void, now: () => string): {
14
+ flush: () => void;
15
+ };
16
+ //# sourceMappingURL=subprocessEventStream.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subprocessEventStream.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/skill/subprocessEventStream.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAItD;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,KAAK,UAAU,EAAE,CAAA;AAEpE;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,YAAY,EACnB,SAAS,EAAE,UAAU,EACrB,OAAO,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,EACpC,GAAG,EAAE,MAAM,MAAM,GAChB;IAAE,KAAK,EAAE,MAAM,IAAI,CAAA;CAAE,CAsBvB"}
@@ -0,0 +1,29 @@
1
+ import { SkillEvent as SkillEventSchema } from '@braidhq/schema';
2
+ import { LineBuffer } from './lineBuffer.js';
3
+ /**
4
+ * Wires a child's stdout and stderr to a single SkillEvent callback.
5
+ * `parseLine` comes from the agent binding, so this stays format-agnostic.
6
+ * Returns `flush` so callers can drain the final un-terminated line on `close`.
7
+ */
8
+ export function attachOutputBuffers(child, parseLine, onEvent, now) {
9
+ const stdout = new LineBuffer((line) => {
10
+ for (const event of parseLine(line, now()))
11
+ onEvent(event);
12
+ });
13
+ // stderr is wrapped verbatim into a `[stderr]` message event,
14
+ // so it shows up in the transcript alongside model output.
15
+ const stderr = new LineBuffer((line) => {
16
+ onEvent(SkillEventSchema.parse({ type: 'message', text: `[stderr] ${line}` }));
17
+ });
18
+ child.stdout?.setEncoding('utf-8');
19
+ child.stdout?.on('data', (chunk) => stdout.append(chunk));
20
+ child.stderr?.setEncoding('utf-8');
21
+ child.stderr?.on('data', (chunk) => stderr.append(chunk));
22
+ return {
23
+ flush: () => {
24
+ stdout.flush();
25
+ stderr.flush();
26
+ },
27
+ };
28
+ }
29
+ //# sourceMappingURL=subprocessEventStream.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subprocessEventStream.js","sourceRoot":"","sources":["../../../src/infrastructure/skill/subprocessEventStream.ts"],"names":[],"mappings":"AAEA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ace } from '@braidhq/core';
2
+ import type { SourceId, SourceUnitSha } from '@braidhq/schema';
3
+ /**
4
+ * Filesystem-backed `SourceUnitDigest`. Resolves the unit's relative path,
5
+ * under its filesystem source root, then hashes.
6
+ *
7
+ * - regular file: the sha256 of the file bytes.
8
+ * - directory: a recursive walk hashes each file by content,
9
+ * assembles a deterministic `<relpath>:<filehash>\n` manifest,
10
+ * sorted by relpath, then returns the sha256 of that manifest.
11
+ * Dot-prefixed entries are skipped, per the intent scanner's convention.
12
+ *
13
+ * The intent scanner's trailing-slash convention is accepted,
14
+ * so a file reads as `foo.md` and a folder as `foo/`.
15
+ */
16
+ export declare class FsSourceUnitDigest implements SourceUnitDigest {
17
+ computeSha(workspace: Workspace, sourceId: SourceId, path: string): Promise<SourceUnitSha>;
18
+ }
19
+ //# sourceMappingURL=FsSourceUnitDigest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FsSourceUnitDigest.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/source/FsSourceUnitDigest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAChE,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAK9D;;;;;;;;;;;;GAYG;AACH,qBAAa,kBAAmB,YAAW,gBAAgB;IACnD,UAAU,CAAC,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;CAejG"}
@@ -0,0 +1,58 @@
1
+ import { createHash } from 'node:crypto';
2
+ import { readdir, readFile, stat } from 'node:fs/promises';
3
+ import { isAbsolute, join, relative } from 'node:path';
4
+ /**
5
+ * Filesystem-backed `SourceUnitDigest`. Resolves the unit's relative path,
6
+ * under its filesystem source root, then hashes.
7
+ *
8
+ * - regular file: the sha256 of the file bytes.
9
+ * - directory: a recursive walk hashes each file by content,
10
+ * assembles a deterministic `<relpath>:<filehash>\n` manifest,
11
+ * sorted by relpath, then returns the sha256 of that manifest.
12
+ * Dot-prefixed entries are skipped, per the intent scanner's convention.
13
+ *
14
+ * The intent scanner's trailing-slash convention is accepted,
15
+ * so a file reads as `foo.md` and a folder as `foo/`.
16
+ */
17
+ export class FsSourceUnitDigest {
18
+ async computeSha(workspace, sourceId, path) {
19
+ const source = workspace.sources.find(s => s.id === sourceId);
20
+ if (!source || source.kind !== 'filesystem') {
21
+ throw new Error(`Cannot compute digest for non-filesystem source "${sourceId}" on workspace "${workspace.id}"`);
22
+ }
23
+ const sourceRoot = isAbsolute(source.path) ? source.path : join(workspace.rootPath, source.path);
24
+ const stripped = path.endsWith('/') ? path.slice(0, -1) : path;
25
+ const target = join(sourceRoot, stripped);
26
+ const info = await stat(target);
27
+ if (info.isDirectory())
28
+ return hashDirectory(target);
29
+ return hashFile(target);
30
+ }
31
+ }
32
+ async function hashFile(filePath) {
33
+ const buf = await readFile(filePath);
34
+ return createHash('sha256').update(buf).digest('hex');
35
+ }
36
+ async function hashDirectory(dirPath) {
37
+ const files = [];
38
+ await walk(dirPath, dirPath, files);
39
+ files.sort((a, b) => (a.rel < b.rel ? -1 : a.rel > b.rel ? 1 : 0));
40
+ const manifest = files.map(f => `${f.rel}:${f.hash}`).join('\n');
41
+ return createHash('sha256').update(manifest).digest('hex');
42
+ }
43
+ async function walk(root, dir, out) {
44
+ const entries = await readdir(dir, { withFileTypes: true });
45
+ for (const entry of entries) {
46
+ if (entry.name.startsWith('.'))
47
+ continue;
48
+ const abs = join(dir, entry.name);
49
+ if (entry.isDirectory()) {
50
+ await walk(root, abs, out);
51
+ continue;
52
+ }
53
+ if (!entry.isFile())
54
+ continue;
55
+ out.push({ rel: relative(root, abs), hash: await hashFile(abs) });
56
+ }
57
+ }
58
+ //# sourceMappingURL=FsSourceUnitDigest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FsSourceUnitDigest.js","sourceRoot":"","sources":["../../../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YAC5B,SAAQ;QACV,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,CAAC,CAAA;QACjC,IAAI,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC;YACxB,MAAM,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC,CAAA;YAC1B,SAAQ;QACV,CAAC;QACD,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE;YACjB,SAAQ;QACV,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,QAAQ,CAAC,IAAI,EAAE,GAAG,CAAC,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;IACnE,CAAC;AACH,CAAC"}
@@ -0,0 +1,31 @@
1
+ import type { SourceUnitObservationRepository } from '@braidhq/core';
2
+ import type { AbsolutePath, SourceId, SourceUnitObservation, WorkspaceId } from '@braidhq/schema';
3
+ export interface FsSourceUnitObservationRepositoryOptions {
4
+ /**
5
+ * Lookup of `workspaceId` to `workspaceRoot`, shared by the repos,
6
+ * so this one takes no `WorkspaceService` dependency of its own.
7
+ * `composeFs.ts` builds the closure once, then hands the same one,
8
+ * to every fs repo.
9
+ */
10
+ readonly workspaceRoots: () => Promise<ReadonlyMap<WorkspaceId, AbsolutePath>>;
11
+ }
12
+ /**
13
+ * Filesystem-backed `SourceUnitObservationRepository`. Each entity maps to,
14
+ * `artifacts/source-unit-state/<sourceId>/<encoded-path>.json`, one file each,
15
+ * matching the file-per-entity pattern used by proposals / clarifications.
16
+ *
17
+ * The file body is exactly the `SourceUnitObservation` shape,
18
+ * with no wrapper or envelope.
19
+ * In a future SQLite or Postgres store,
20
+ * each file becomes one row keyed by `(workspaceId, sourceId, path)`.
21
+ */
22
+ export declare class FsSourceUnitObservationRepository implements SourceUnitObservationRepository {
23
+ private readonly options;
24
+ constructor(options: FsSourceUnitObservationRepositoryOptions);
25
+ find(workspaceId: WorkspaceId, sourceId: SourceId, path: string): Promise<SourceUnitObservation | null>;
26
+ save(state: SourceUnitObservation): Promise<void>;
27
+ listByWorkspace(workspaceId: WorkspaceId): Promise<readonly SourceUnitObservation[]>;
28
+ listBySource(workspaceId: WorkspaceId, sourceId: SourceId): Promise<readonly SourceUnitObservation[]>;
29
+ private resolveRoot;
30
+ }
31
+ //# sourceMappingURL=FsSourceUnitObservationRepository.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FsSourceUnitObservationRepository.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/source/FsSourceUnitObservationRepository.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,eAAe,CAAA;AACpE,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,qBAAqB,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AASjG,MAAM,WAAW,wCAAwC;IACvD;;;;;OAKG;IACH,QAAQ,CAAC,cAAc,EAAE,MAAM,OAAO,CAAC,WAAW,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC,CAAA;CAC/E;AAED;;;;;;;;;GASG;AACH,qBAAa,iCAAkC,YAAW,+BAA+B;IAC3E,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE,wCAAwC;IAExE,IAAI,CAAC,WAAW,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,GAAG,IAAI,CAAC;IAcvG,IAAI,CAAC,KAAK,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC;IASjD,eAAe,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,SAAS,qBAAqB,EAAE,CAAC;IAapF,YAAY,CAAC,WAAW,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,SAAS,qBAAqB,EAAE,CAAC;YAK7F,WAAW;CAO1B"}