@braidhq/server 0.1.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (401) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +134 -106
  3. package/dist/app.d.ts +7 -15
  4. package/dist/app.d.ts.map +1 -1
  5. package/dist/app.js +74 -45
  6. package/dist/app.js.map +1 -1
  7. package/dist/authMode.d.ts +39 -0
  8. package/dist/authMode.d.ts.map +1 -0
  9. package/dist/authMode.js +50 -0
  10. package/dist/authMode.js.map +1 -0
  11. package/dist/composeApp.d.ts +80 -0
  12. package/dist/composeApp.d.ts.map +1 -0
  13. package/dist/composeApp.js +137 -0
  14. package/dist/composeApp.js.map +1 -0
  15. package/dist/composeFsApp.d.ts +27 -0
  16. package/dist/composeFsApp.d.ts.map +1 -0
  17. package/dist/{composeFs.js → composeFsApp.js} +127 -126
  18. package/dist/composeFsApp.js.map +1 -0
  19. package/dist/index.d.ts +3 -2
  20. package/dist/index.d.ts.map +1 -1
  21. package/dist/index.js +3 -2
  22. package/dist/index.js.map +1 -1
  23. package/dist/infrastructure/_shared/env.d.ts +10 -0
  24. package/dist/infrastructure/_shared/env.d.ts.map +1 -0
  25. package/dist/infrastructure/{env.js → _shared/env.js} +5 -6
  26. package/dist/infrastructure/_shared/env.js.map +1 -0
  27. package/dist/infrastructure/_shared/frontmatter.d.ts +13 -0
  28. package/dist/infrastructure/_shared/frontmatter.d.ts.map +1 -0
  29. package/dist/infrastructure/{fs → _shared}/frontmatter.js +5 -5
  30. package/dist/infrastructure/_shared/frontmatter.js.map +1 -0
  31. package/dist/infrastructure/_shared/jsonFileStore.d.ts.map +1 -0
  32. package/dist/infrastructure/_shared/jsonFileStore.js.map +1 -0
  33. package/dist/infrastructure/{fs → _shared}/paths.d.ts +17 -10
  34. package/dist/infrastructure/_shared/paths.d.ts.map +1 -0
  35. package/dist/infrastructure/{fs → _shared}/paths.js +27 -20
  36. package/dist/infrastructure/_shared/paths.js.map +1 -0
  37. package/dist/infrastructure/auth/AccessPolicy.d.ts +33 -58
  38. package/dist/infrastructure/auth/AccessPolicy.d.ts.map +1 -1
  39. package/dist/infrastructure/auth/AccessPolicy.js +35 -42
  40. package/dist/infrastructure/auth/AccessPolicy.js.map +1 -1
  41. package/dist/infrastructure/auth/SessionStore.d.ts +22 -12
  42. package/dist/infrastructure/auth/SessionStore.d.ts.map +1 -1
  43. package/dist/infrastructure/auth/SessionStore.js +20 -20
  44. package/dist/infrastructure/auth/SessionStore.js.map +1 -1
  45. package/dist/infrastructure/batch/FsBatchPlanRepository.d.ts +14 -0
  46. package/dist/infrastructure/batch/FsBatchPlanRepository.d.ts.map +1 -0
  47. package/dist/infrastructure/{fs → batch}/FsBatchPlanRepository.js +9 -7
  48. package/dist/infrastructure/batch/FsBatchPlanRepository.js.map +1 -0
  49. package/dist/infrastructure/history/GitWorkspaceHistory.d.ts.map +1 -0
  50. package/dist/infrastructure/{git → history}/GitWorkspaceHistory.js +31 -24
  51. package/dist/infrastructure/history/GitWorkspaceHistory.js.map +1 -0
  52. package/dist/infrastructure/history/commitMessage.d.ts.map +1 -0
  53. package/dist/infrastructure/history/commitMessage.js +90 -0
  54. package/dist/infrastructure/history/commitMessage.js.map +1 -0
  55. package/dist/infrastructure/hitl/FsClarificationRepository.d.ts +13 -0
  56. package/dist/infrastructure/hitl/FsClarificationRepository.d.ts.map +1 -0
  57. package/dist/infrastructure/hitl/FsClarificationRepository.js +40 -0
  58. package/dist/infrastructure/hitl/FsClarificationRepository.js.map +1 -0
  59. package/dist/infrastructure/hitl/FsProposalRepository.d.ts.map +1 -0
  60. package/dist/infrastructure/{fs → hitl}/FsProposalRepository.js +8 -8
  61. package/dist/infrastructure/hitl/FsProposalRepository.js.map +1 -0
  62. package/dist/infrastructure/hitl/StatusedJsonStore.d.ts +30 -0
  63. package/dist/infrastructure/hitl/StatusedJsonStore.d.ts.map +1 -0
  64. package/dist/infrastructure/{fs/FsStatusedJsonRepository.js → hitl/StatusedJsonStore.js} +3 -3
  65. package/dist/infrastructure/hitl/StatusedJsonStore.js.map +1 -0
  66. package/dist/infrastructure/model/FsModelSerializer.d.ts +94 -0
  67. package/dist/infrastructure/model/FsModelSerializer.d.ts.map +1 -0
  68. package/dist/infrastructure/{fs/FsGraphSerializer.js → model/FsModelSerializer.js} +11 -11
  69. package/dist/infrastructure/model/FsModelSerializer.js.map +1 -0
  70. package/dist/infrastructure/oauth/GoogleOAuth.d.ts +20 -38
  71. package/dist/infrastructure/oauth/GoogleOAuth.d.ts.map +1 -1
  72. package/dist/infrastructure/oauth/GoogleOAuth.js +21 -22
  73. package/dist/infrastructure/oauth/GoogleOAuth.js.map +1 -1
  74. package/dist/infrastructure/reactor/FsReactorCycleRepository.d.ts +29 -0
  75. package/dist/infrastructure/reactor/FsReactorCycleRepository.d.ts.map +1 -0
  76. package/dist/infrastructure/reactor/FsReactorCycleRepository.js +94 -0
  77. package/dist/infrastructure/reactor/FsReactorCycleRepository.js.map +1 -0
  78. package/dist/infrastructure/secrets/SecretStore.d.ts +11 -14
  79. package/dist/infrastructure/secrets/SecretStore.d.ts.map +1 -1
  80. package/dist/infrastructure/secrets/SecretStore.js +4 -4
  81. package/dist/infrastructure/secrets/SecretStore.js.map +1 -1
  82. package/dist/infrastructure/{fs → skill}/FsRunRepository.d.ts +5 -3
  83. package/dist/infrastructure/skill/FsRunRepository.d.ts.map +1 -0
  84. package/dist/infrastructure/{fs → skill}/FsRunRepository.js +11 -9
  85. package/dist/infrastructure/skill/FsRunRepository.js.map +1 -0
  86. package/dist/infrastructure/{fs → skill}/FsSkillRegistry.d.ts +4 -13
  87. package/dist/infrastructure/skill/FsSkillRegistry.d.ts.map +1 -0
  88. package/dist/infrastructure/{fs → skill}/FsSkillRegistry.js +28 -20
  89. package/dist/infrastructure/skill/FsSkillRegistry.js.map +1 -0
  90. package/dist/infrastructure/skill/SubprocessSkillRunner.d.ts +52 -0
  91. package/dist/infrastructure/skill/SubprocessSkillRunner.d.ts.map +1 -0
  92. package/dist/infrastructure/{agent → skill}/SubprocessSkillRunner.js +107 -55
  93. package/dist/infrastructure/skill/SubprocessSkillRunner.js.map +1 -0
  94. package/dist/infrastructure/skill/asyncQueue.d.ts +20 -0
  95. package/dist/infrastructure/skill/asyncQueue.d.ts.map +1 -0
  96. package/dist/infrastructure/{agent → skill}/asyncQueue.js +2 -3
  97. package/dist/infrastructure/{agent → skill}/asyncQueue.js.map +1 -1
  98. package/dist/infrastructure/skill/lineBuffer.d.ts +15 -0
  99. package/dist/infrastructure/skill/lineBuffer.d.ts.map +1 -0
  100. package/dist/infrastructure/{agent/streamJsonParser.js → skill/lineBuffer.js} +5 -17
  101. package/dist/infrastructure/skill/lineBuffer.js.map +1 -0
  102. package/dist/infrastructure/skill/orphanReaper.d.ts +20 -0
  103. package/dist/infrastructure/skill/orphanReaper.d.ts.map +1 -0
  104. package/dist/infrastructure/{orphanReaper.js → skill/orphanReaper.js} +7 -5
  105. package/dist/infrastructure/skill/orphanReaper.js.map +1 -0
  106. package/dist/infrastructure/skill/subprocessEventStream.d.ts +16 -0
  107. package/dist/infrastructure/skill/subprocessEventStream.d.ts.map +1 -0
  108. package/dist/infrastructure/skill/subprocessEventStream.js +29 -0
  109. package/dist/infrastructure/skill/subprocessEventStream.js.map +1 -0
  110. package/dist/infrastructure/source/FsSourceUnitDigest.d.ts +19 -0
  111. package/dist/infrastructure/source/FsSourceUnitDigest.d.ts.map +1 -0
  112. package/dist/infrastructure/{fs → source}/FsSourceUnitDigest.js +9 -9
  113. package/dist/infrastructure/source/FsSourceUnitDigest.js.map +1 -0
  114. package/dist/infrastructure/source/FsSourceUnitObservationRepository.d.ts +31 -0
  115. package/dist/infrastructure/source/FsSourceUnitObservationRepository.d.ts.map +1 -0
  116. package/dist/infrastructure/{fs/FsSourceUnitStateRepository.js → source/FsSourceUnitObservationRepository.js} +18 -17
  117. package/dist/infrastructure/source/FsSourceUnitObservationRepository.js.map +1 -0
  118. package/dist/infrastructure/source/unitScan.d.ts +11 -0
  119. package/dist/infrastructure/source/unitScan.d.ts.map +1 -0
  120. package/dist/infrastructure/{fs/intentScan.js → source/unitScan.js} +36 -27
  121. package/dist/infrastructure/source/unitScan.js.map +1 -0
  122. package/dist/infrastructure/users/UserDirectoryFromRegistry.d.ts +2 -2
  123. package/dist/infrastructure/users/UserDirectoryFromRegistry.d.ts.map +1 -1
  124. package/dist/infrastructure/users/UserDirectoryFromRegistry.js +3 -2
  125. package/dist/infrastructure/users/UserDirectoryFromRegistry.js.map +1 -1
  126. package/dist/infrastructure/users/UserRegistryFile.d.ts +4 -5
  127. package/dist/infrastructure/users/UserRegistryFile.d.ts.map +1 -1
  128. package/dist/infrastructure/users/UserRegistryFile.js +6 -8
  129. package/dist/infrastructure/users/UserRegistryFile.js.map +1 -1
  130. package/dist/infrastructure/users/ensureWorkspaceOwners.d.ts +9 -6
  131. package/dist/infrastructure/users/ensureWorkspaceOwners.d.ts.map +1 -1
  132. package/dist/infrastructure/users/ensureWorkspaceOwners.js +10 -7
  133. package/dist/infrastructure/users/ensureWorkspaceOwners.js.map +1 -1
  134. package/dist/infrastructure/workspace/FsWorkspaceRepository.d.ts.map +1 -0
  135. package/dist/infrastructure/{fs → workspace}/FsWorkspaceRepository.js +7 -6
  136. package/dist/infrastructure/workspace/FsWorkspaceRepository.js.map +1 -0
  137. package/dist/infrastructure/workspace/WorkspaceDiscovery.d.ts +18 -0
  138. package/dist/infrastructure/workspace/WorkspaceDiscovery.d.ts.map +1 -0
  139. package/dist/infrastructure/{fs → workspace}/WorkspaceDiscovery.js +15 -11
  140. package/dist/infrastructure/workspace/WorkspaceDiscovery.js.map +1 -0
  141. package/dist/infrastructure/{fs → workspace}/WorkspaceRegistryFile.d.ts +10 -9
  142. package/dist/infrastructure/workspace/WorkspaceRegistryFile.d.ts.map +1 -0
  143. package/dist/infrastructure/{fs → workspace}/WorkspaceRegistryFile.js +15 -17
  144. package/dist/infrastructure/workspace/WorkspaceRegistryFile.js.map +1 -0
  145. package/dist/infrastructure/workspace/productManifestWriter.d.ts +24 -0
  146. package/dist/infrastructure/workspace/productManifestWriter.d.ts.map +1 -0
  147. package/dist/infrastructure/{fs → workspace}/productManifestWriter.js +14 -26
  148. package/dist/infrastructure/workspace/productManifestWriter.js.map +1 -0
  149. package/dist/middleware/auth.d.ts +27 -17
  150. package/dist/middleware/auth.d.ts.map +1 -1
  151. package/dist/middleware/auth.js +69 -53
  152. package/dist/middleware/auth.js.map +1 -1
  153. package/dist/middleware/cors.d.ts.map +1 -1
  154. package/dist/middleware/cors.js +4 -1
  155. package/dist/middleware/cors.js.map +1 -1
  156. package/dist/middleware/error.d.ts.map +1 -1
  157. package/dist/middleware/error.js +15 -13
  158. package/dist/middleware/error.js.map +1 -1
  159. package/dist/middleware/workspaceAccess.d.ts +23 -19
  160. package/dist/middleware/workspaceAccess.d.ts.map +1 -1
  161. package/dist/middleware/workspaceAccess.js +31 -26
  162. package/dist/middleware/workspaceAccess.js.map +1 -1
  163. package/dist/policy/CapabilityCheck.d.ts +5 -5
  164. package/dist/policy/PermissionRegistry.d.ts +11 -9
  165. package/dist/policy/PermissionRegistry.d.ts.map +1 -1
  166. package/dist/policy/PermissionRegistry.js +10 -8
  167. package/dist/policy/PermissionRegistry.js.map +1 -1
  168. package/dist/policy/ViewerContext.d.ts +13 -11
  169. package/dist/policy/ViewerContext.d.ts.map +1 -1
  170. package/dist/policy/checks.d.ts +9 -9
  171. package/dist/policy/checks.d.ts.map +1 -1
  172. package/dist/policy/checks.js +14 -11
  173. package/dist/policy/checks.js.map +1 -1
  174. package/dist/policy/defaultRegistry.d.ts +3 -4
  175. package/dist/policy/defaultRegistry.d.ts.map +1 -1
  176. package/dist/policy/defaultRegistry.js +3 -4
  177. package/dist/policy/defaultRegistry.js.map +1 -1
  178. package/dist/policy/index.d.ts +2 -2
  179. package/dist/policy/index.d.ts.map +1 -1
  180. package/dist/policy/index.js +1 -1
  181. package/dist/policy/index.js.map +1 -1
  182. package/dist/policy/resolveViewer.d.ts +9 -9
  183. package/dist/policy/resolveViewer.js +9 -9
  184. package/dist/routes/_shared.d.ts +93 -153
  185. package/dist/routes/_shared.d.ts.map +1 -1
  186. package/dist/routes/_shared.js +9 -5
  187. package/dist/routes/_shared.js.map +1 -1
  188. package/dist/routes/admin.d.ts +1 -1
  189. package/dist/routes/admin.d.ts.map +1 -1
  190. package/dist/routes/admin.js +13 -12
  191. package/dist/routes/admin.js.map +1 -1
  192. package/dist/routes/auth.d.ts +12 -10
  193. package/dist/routes/auth.d.ts.map +1 -1
  194. package/dist/routes/auth.js +32 -34
  195. package/dist/routes/auth.js.map +1 -1
  196. package/dist/routes/clarifications.d.ts +8 -0
  197. package/dist/routes/clarifications.d.ts.map +1 -0
  198. package/dist/routes/clarifications.js +246 -0
  199. package/dist/routes/clarifications.js.map +1 -0
  200. package/dist/routes/edges.d.ts.map +1 -1
  201. package/dist/routes/edges.js +2 -6
  202. package/dist/routes/edges.js.map +1 -1
  203. package/dist/routes/history.d.ts.map +1 -1
  204. package/dist/routes/history.js +12 -10
  205. package/dist/routes/history.js.map +1 -1
  206. package/dist/routes/nodes.d.ts.map +1 -1
  207. package/dist/routes/nodes.js +4 -8
  208. package/dist/routes/nodes.js.map +1 -1
  209. package/dist/routes/oauth.d.ts +6 -7
  210. package/dist/routes/oauth.d.ts.map +1 -1
  211. package/dist/routes/oauth.js +6 -7
  212. package/dist/routes/oauth.js.map +1 -1
  213. package/dist/routes/ontologies.d.ts +7 -0
  214. package/dist/routes/ontologies.d.ts.map +1 -0
  215. package/dist/routes/ontologies.js +29 -0
  216. package/dist/routes/ontologies.js.map +1 -0
  217. package/dist/routes/ontology.d.ts.map +1 -1
  218. package/dist/routes/ontology.js +2 -1
  219. package/dist/routes/ontology.js.map +1 -1
  220. package/dist/routes/proposals.d.ts +2 -2
  221. package/dist/routes/proposals.d.ts.map +1 -1
  222. package/dist/routes/proposals.js +35 -30
  223. package/dist/routes/proposals.js.map +1 -1
  224. package/dist/routes/reactorCycles.d.ts +7 -0
  225. package/dist/routes/reactorCycles.d.ts.map +1 -0
  226. package/dist/routes/reactorCycles.js +60 -0
  227. package/dist/routes/reactorCycles.js.map +1 -0
  228. package/dist/routes/runs.d.ts.map +1 -1
  229. package/dist/routes/runs.js +22 -19
  230. package/dist/routes/runs.js.map +1 -1
  231. package/dist/routes/skillInputOptions.d.ts +2 -2
  232. package/dist/routes/skillInputOptions.d.ts.map +1 -1
  233. package/dist/routes/skillInputOptions.js +53 -53
  234. package/dist/routes/skillInputOptions.js.map +1 -1
  235. package/dist/routes/skills.d.ts +19 -1
  236. package/dist/routes/skills.d.ts.map +1 -1
  237. package/dist/routes/skills.js +141 -7
  238. package/dist/routes/skills.js.map +1 -1
  239. package/dist/routes/sourceLoaders.d.ts.map +1 -1
  240. package/dist/routes/sourceLoaders.js +1 -0
  241. package/dist/routes/sourceLoaders.js.map +1 -1
  242. package/dist/routes/sourceUnitObservations.d.ts +20 -0
  243. package/dist/routes/sourceUnitObservations.d.ts.map +1 -0
  244. package/dist/routes/sourceUnitObservations.js +80 -0
  245. package/dist/routes/sourceUnitObservations.js.map +1 -0
  246. package/dist/routes/sourceWebhooks.d.ts +26 -0
  247. package/dist/routes/sourceWebhooks.d.ts.map +1 -0
  248. package/dist/routes/sourceWebhooks.js +301 -0
  249. package/dist/routes/sourceWebhooks.js.map +1 -0
  250. package/dist/routes/users.d.ts +0 -2
  251. package/dist/routes/users.d.ts.map +1 -1
  252. package/dist/routes/users.js +15 -33
  253. package/dist/routes/users.js.map +1 -1
  254. package/dist/routes/workspaceEvents.d.ts +5 -4
  255. package/dist/routes/workspaceEvents.d.ts.map +1 -1
  256. package/dist/routes/workspaceEvents.js +7 -6
  257. package/dist/routes/workspaceEvents.js.map +1 -1
  258. package/dist/routes/workspaceMembers.d.ts +1 -1
  259. package/dist/routes/workspaceMembers.d.ts.map +1 -1
  260. package/dist/routes/workspaceMembers.js +2 -2
  261. package/dist/routes/workspaceMembers.js.map +1 -1
  262. package/dist/routes/workspaces.d.ts +21 -10
  263. package/dist/routes/workspaces.d.ts.map +1 -1
  264. package/dist/routes/workspaces.js +95 -69
  265. package/dist/routes/workspaces.js.map +1 -1
  266. package/dist/server.js +6 -70
  267. package/dist/server.js.map +1 -1
  268. package/dist/serviceAccounts.d.ts +13 -0
  269. package/dist/serviceAccounts.d.ts.map +1 -0
  270. package/dist/serviceAccounts.js +26 -0
  271. package/dist/serviceAccounts.js.map +1 -0
  272. package/dist/startServer.d.ts +17 -0
  273. package/dist/startServer.d.ts.map +1 -0
  274. package/dist/startServer.js +81 -0
  275. package/dist/startServer.js.map +1 -0
  276. package/dist/startup.d.ts +28 -0
  277. package/dist/startup.d.ts.map +1 -0
  278. package/dist/startup.js +94 -0
  279. package/dist/startup.js.map +1 -0
  280. package/package.json +35 -40
  281. package/dist/composeFs.d.ts +0 -55
  282. package/dist/composeFs.d.ts.map +0 -1
  283. package/dist/composeFs.js.map +0 -1
  284. package/dist/composition.d.ts +0 -133
  285. package/dist/composition.d.ts.map +0 -1
  286. package/dist/composition.js +0 -113
  287. package/dist/composition.js.map +0 -1
  288. package/dist/infrastructure/agent/SubprocessSkillRunner.d.ts +0 -75
  289. package/dist/infrastructure/agent/SubprocessSkillRunner.d.ts.map +0 -1
  290. package/dist/infrastructure/agent/SubprocessSkillRunner.js.map +0 -1
  291. package/dist/infrastructure/agent/asyncQueue.d.ts +0 -22
  292. package/dist/infrastructure/agent/asyncQueue.d.ts.map +0 -1
  293. package/dist/infrastructure/agent/mcpConfig.d.ts +0 -38
  294. package/dist/infrastructure/agent/mcpConfig.d.ts.map +0 -1
  295. package/dist/infrastructure/agent/mcpConfig.js +0 -55
  296. package/dist/infrastructure/agent/mcpConfig.js.map +0 -1
  297. package/dist/infrastructure/agent/streamJsonParser.d.ts +0 -20
  298. package/dist/infrastructure/agent/streamJsonParser.d.ts.map +0 -1
  299. package/dist/infrastructure/agent/streamJsonParser.js.map +0 -1
  300. package/dist/infrastructure/agent/subprocessEventStream.d.ts +0 -26
  301. package/dist/infrastructure/agent/subprocessEventStream.d.ts.map +0 -1
  302. package/dist/infrastructure/agent/subprocessEventStream.js +0 -112
  303. package/dist/infrastructure/agent/subprocessEventStream.js.map +0 -1
  304. package/dist/infrastructure/auth/ensureApprovedEmails.d.ts +0 -16
  305. package/dist/infrastructure/auth/ensureApprovedEmails.d.ts.map +0 -1
  306. package/dist/infrastructure/auth/ensureApprovedEmails.js +0 -20
  307. package/dist/infrastructure/auth/ensureApprovedEmails.js.map +0 -1
  308. package/dist/infrastructure/env.d.ts +0 -11
  309. package/dist/infrastructure/env.d.ts.map +0 -1
  310. package/dist/infrastructure/env.js.map +0 -1
  311. package/dist/infrastructure/fs/FsBatchPlanRepository.d.ts +0 -300
  312. package/dist/infrastructure/fs/FsBatchPlanRepository.d.ts.map +0 -1
  313. package/dist/infrastructure/fs/FsBatchPlanRepository.js.map +0 -1
  314. package/dist/infrastructure/fs/FsClarifyTicketRepository.d.ts +0 -13
  315. package/dist/infrastructure/fs/FsClarifyTicketRepository.d.ts.map +0 -1
  316. package/dist/infrastructure/fs/FsClarifyTicketRepository.js +0 -39
  317. package/dist/infrastructure/fs/FsClarifyTicketRepository.js.map +0 -1
  318. package/dist/infrastructure/fs/FsDecisionRepository.d.ts +0 -13
  319. package/dist/infrastructure/fs/FsDecisionRepository.d.ts.map +0 -1
  320. package/dist/infrastructure/fs/FsDecisionRepository.js +0 -56
  321. package/dist/infrastructure/fs/FsDecisionRepository.js.map +0 -1
  322. package/dist/infrastructure/fs/FsGraphSerializer.d.ts +0 -629
  323. package/dist/infrastructure/fs/FsGraphSerializer.d.ts.map +0 -1
  324. package/dist/infrastructure/fs/FsGraphSerializer.js.map +0 -1
  325. package/dist/infrastructure/fs/FsProposalRepository.d.ts.map +0 -1
  326. package/dist/infrastructure/fs/FsProposalRepository.js.map +0 -1
  327. package/dist/infrastructure/fs/FsRunRepository.d.ts.map +0 -1
  328. package/dist/infrastructure/fs/FsRunRepository.js.map +0 -1
  329. package/dist/infrastructure/fs/FsSkillRegistry.d.ts.map +0 -1
  330. package/dist/infrastructure/fs/FsSkillRegistry.js.map +0 -1
  331. package/dist/infrastructure/fs/FsSourceUnitDigest.d.ts +0 -19
  332. package/dist/infrastructure/fs/FsSourceUnitDigest.d.ts.map +0 -1
  333. package/dist/infrastructure/fs/FsSourceUnitDigest.js.map +0 -1
  334. package/dist/infrastructure/fs/FsSourceUnitStateRepository.d.ts +0 -30
  335. package/dist/infrastructure/fs/FsSourceUnitStateRepository.d.ts.map +0 -1
  336. package/dist/infrastructure/fs/FsSourceUnitStateRepository.js.map +0 -1
  337. package/dist/infrastructure/fs/FsStatusedJsonRepository.d.ts +0 -35
  338. package/dist/infrastructure/fs/FsStatusedJsonRepository.d.ts.map +0 -1
  339. package/dist/infrastructure/fs/FsStatusedJsonRepository.js.map +0 -1
  340. package/dist/infrastructure/fs/FsWorkspaceRepository.d.ts.map +0 -1
  341. package/dist/infrastructure/fs/FsWorkspaceRepository.js.map +0 -1
  342. package/dist/infrastructure/fs/WorkspaceDiscovery.d.ts +0 -15
  343. package/dist/infrastructure/fs/WorkspaceDiscovery.d.ts.map +0 -1
  344. package/dist/infrastructure/fs/WorkspaceDiscovery.js.map +0 -1
  345. package/dist/infrastructure/fs/WorkspaceRegistryFile.d.ts.map +0 -1
  346. package/dist/infrastructure/fs/WorkspaceRegistryFile.js.map +0 -1
  347. package/dist/infrastructure/fs/frontmatter.d.ts +0 -13
  348. package/dist/infrastructure/fs/frontmatter.d.ts.map +0 -1
  349. package/dist/infrastructure/fs/frontmatter.js.map +0 -1
  350. package/dist/infrastructure/fs/intentScan.d.ts +0 -9
  351. package/dist/infrastructure/fs/intentScan.d.ts.map +0 -1
  352. package/dist/infrastructure/fs/intentScan.js.map +0 -1
  353. package/dist/infrastructure/fs/jsonFileStore.d.ts.map +0 -1
  354. package/dist/infrastructure/fs/jsonFileStore.js.map +0 -1
  355. package/dist/infrastructure/fs/paths.d.ts.map +0 -1
  356. package/dist/infrastructure/fs/paths.js.map +0 -1
  357. package/dist/infrastructure/fs/productManifestWriter.d.ts +0 -22
  358. package/dist/infrastructure/fs/productManifestWriter.d.ts.map +0 -1
  359. package/dist/infrastructure/fs/productManifestWriter.js.map +0 -1
  360. package/dist/infrastructure/git/GitWorkspaceHistory.d.ts.map +0 -1
  361. package/dist/infrastructure/git/GitWorkspaceHistory.js.map +0 -1
  362. package/dist/infrastructure/git/commitMessage.d.ts.map +0 -1
  363. package/dist/infrastructure/git/commitMessage.js +0 -71
  364. package/dist/infrastructure/git/commitMessage.js.map +0 -1
  365. package/dist/infrastructure/orphanReaper.d.ts +0 -18
  366. package/dist/infrastructure/orphanReaper.d.ts.map +0 -1
  367. package/dist/infrastructure/orphanReaper.js.map +0 -1
  368. package/dist/infrastructure/users/ensureLocalUser.d.ts +0 -15
  369. package/dist/infrastructure/users/ensureLocalUser.d.ts.map +0 -1
  370. package/dist/infrastructure/users/ensureLocalUser.js +0 -38
  371. package/dist/infrastructure/users/ensureLocalUser.js.map +0 -1
  372. package/dist/middleware/requireAdmin.d.ts +0 -10
  373. package/dist/middleware/requireAdmin.d.ts.map +0 -1
  374. package/dist/middleware/requireAdmin.js +0 -24
  375. package/dist/middleware/requireAdmin.js.map +0 -1
  376. package/dist/middleware/userId.d.ts +0 -16
  377. package/dist/middleware/userId.d.ts.map +0 -1
  378. package/dist/middleware/userId.js +0 -27
  379. package/dist/middleware/userId.js.map +0 -1
  380. package/dist/policy/Capability.d.ts +0 -12
  381. package/dist/policy/Capability.d.ts.map +0 -1
  382. package/dist/policy/Capability.js +0 -31
  383. package/dist/policy/Capability.js.map +0 -1
  384. package/dist/routes/clarify.d.ts +0 -9
  385. package/dist/routes/clarify.d.ts.map +0 -1
  386. package/dist/routes/clarify.js +0 -274
  387. package/dist/routes/clarify.js.map +0 -1
  388. package/dist/routes/decisions.d.ts +0 -7
  389. package/dist/routes/decisions.d.ts.map +0 -1
  390. package/dist/routes/decisions.js +0 -68
  391. package/dist/routes/decisions.js.map +0 -1
  392. package/dist/routes/sourceUnitStates.d.ts +0 -7
  393. package/dist/routes/sourceUnitStates.d.ts.map +0 -1
  394. package/dist/routes/sourceUnitStates.js +0 -45
  395. package/dist/routes/sourceUnitStates.js.map +0 -1
  396. /package/dist/infrastructure/{fs → _shared}/jsonFileStore.d.ts +0 -0
  397. /package/dist/infrastructure/{fs → _shared}/jsonFileStore.js +0 -0
  398. /package/dist/infrastructure/{git → history}/GitWorkspaceHistory.d.ts +0 -0
  399. /package/dist/infrastructure/{git → history}/commitMessage.d.ts +0 -0
  400. /package/dist/infrastructure/{fs → hitl}/FsProposalRepository.d.ts +0 -0
  401. /package/dist/infrastructure/{fs → workspace}/FsWorkspaceRepository.d.ts +0 -0
@@ -4,8 +4,8 @@ import { join } from 'node:path';
4
4
  import { fileURLToPath } from 'node:url';
5
5
  import { NotFoundError, SkillManifest, validateSkillStructure } from '@braidhq/core';
6
6
  import { AbsolutePath as AbsolutePathSchema, SkillFrontmatter as SkillFrontmatterSchema, SkillId as SkillIdSchema } from '@braidhq/schema';
7
- import { parseMarkdownFrontmatter } from './frontmatter.js';
8
- import { workspaceSkillExtensionsDir, workspaceSkillsDir } from './paths.js';
7
+ import { parseMarkdownFrontmatter } from '../_shared/frontmatter.js';
8
+ import { workspaceSkillExtensionsDir, workspaceSkillsDir } from '../_shared/paths.js';
9
9
  export class FsSkillRegistry {
10
10
  options;
11
11
  constructor(options) {
@@ -16,9 +16,9 @@ export class FsSkillRegistry {
16
16
  const pluginSkills = await this.scanPluginSkills();
17
17
  const workspaceSkills = await this.scanSkillsRoot(AbsolutePathSchema.parse(workspaceSkillsDir(workspace.rootPath)), 'workspace');
18
18
  const extensions = await this.scanExtensionRoot(AbsolutePathSchema.parse(workspaceSkillExtensionsDir(workspace.rootPath)));
19
- // Precedence (later wins): builtin < plugin < workspace.
20
- // Extensions don't override; they attach an EXTEND.md path to the
21
- // resolved skill so SubprocessSkillRunner appends it at run time.
19
+ // Precedence, later wins: builtin < plugin < workspace.
20
+ // Extensions don't override. They attach an EXTEND.md path,
21
+ // and the agent binding points claude at that file at run time.
22
22
  const manifests = new Map();
23
23
  for (const manifest of builtins)
24
24
  manifests.set(manifest.id, manifest);
@@ -55,8 +55,12 @@ export class FsSkillRegistry {
55
55
  const frontmatter = await this.readSkillFrontmatter(skillFile);
56
56
  if (!frontmatter)
57
57
  continue;
58
+ // The directory is the bare verb. Namespace it by origin,
59
+ // builtins under `braid`, workspace skills under `workspace`,
60
+ // so the id matches the plugin the agent binding stages it as.
61
+ const namespace = origin === 'builtin' ? 'braid' : 'workspace';
58
62
  manifests.push(new SkillManifest({
59
- id: SkillIdSchema.parse(entry.name),
63
+ id: SkillIdSchema.parse(`${namespace}:${entry.name}`),
60
64
  origin,
61
65
  path: skillFile,
62
66
  frontmatter,
@@ -64,14 +68,13 @@ export class FsSkillRegistry {
64
68
  }
65
69
  return manifests;
66
70
  }
67
- /**
68
- * Resolve every PluginSkillRef in the registry to a parsed
69
- * SkillManifest. Each ref's `directory` is converted to an absolute
70
- * fs path (URL via fileURLToPath), then `SKILL.md` is read and
71
- * parsed. Missing files at a plugin-declared path are an error,
72
- * not a silent skip: a plugin that ships a broken ref deserves a
73
- * loud startup failure, not a mysteriously-absent skill.
74
- */
71
+ // Resolve every PluginSkillRef in the registry to a parsed SkillManifest.
72
+ // Each ref's `directory` is resolved to an absolute path via fileURLToPath,
73
+ // then its `SKILL.md` is read and parsed.
74
+ // A file missing at such a path,
75
+ // counts as an error, never a silent skip.
76
+ // A plugin shipping a broken ref,
77
+ // earns a loud startup failure, not a mysteriously absent skill.
75
78
  async scanPluginSkills() {
76
79
  const registry = this.options.pluginRegistry;
77
80
  if (!registry)
@@ -103,7 +106,11 @@ export class FsSkillRegistry {
103
106
  const extendPath = AbsolutePathSchema.parse(join(root, entry.name, 'EXTEND.md'));
104
107
  try {
105
108
  await stat(extendPath);
106
- const skillId = SkillIdSchema.parse(entry.name.replace(/^braid-/, ''));
109
+ // The extension dir is `<namespace>-<verb>`, filesystem-safe.
110
+ // The first hyphen maps back to the id's `:` separator,
111
+ // so `ddd-extract` targets `ddd:extract` and `braid:generate-doc`
112
+ // targets `braid:generate-doc`.
113
+ const skillId = SkillIdSchema.parse(entry.name.replace('-', ':'));
107
114
  results.push({ id: skillId, path: extendPath });
108
115
  }
109
116
  catch (error) {
@@ -125,11 +132,12 @@ export class FsSkillRegistry {
125
132
  }
126
133
  const { frontmatter: raw, body } = parseMarkdownFrontmatter(content);
127
134
  const frontmatter = SkillFrontmatterSchema.parse(raw);
128
- // Structural contract: SKILL.md must declare the required H2 sections
129
- // per its `braid.category`. The validator is hard-fail so a broken
130
- // skill never silently appears in the workspace's skill list — a
131
- // skill missing `## Procedure` would burn an entire run before the
132
- // agent notices the gap.
135
+ // Structural contract: SKILL.md must declare the required H2 sections,
136
+ // per its `braid.category`.
137
+ // The validator is hard-fail.
138
+ // A broken skill never lands silently in the workspace list.
139
+ // Were `## Procedure` absent, the skill would burn an entire run,
140
+ // before the agent ever noticed the missing section.
133
141
  const validation = validateSkillStructure({ body, frontmatter });
134
142
  if (!validation.ok) {
135
143
  const issues = validation.issues.map(issue => `- ${issue.message}`).join('\n');
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FsSkillRegistry.js","sourceRoot":"","sources":["../../../src/infrastructure/skill/FsSkillRegistry.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AAC1D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AACxC,OAAO,EAAE,aAAa,EAAuB,aAAa,EAAsB,sBAAsB,EAAkB,MAAM,eAAe,CAAA;AAC7I,OAAO,EAAE,YAAY,IAAI,kBAAkB,EAAE,gBAAgB,IAAI,sBAAsB,EAAE,OAAO,IAAI,aA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,CAAC,CAAA;YACjE,OAAO,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;gBAC3B,IAAI,EAAE,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC;gBAC5F,WAAW,EAAE,GAAY,EAAE,CAAC,KAAK,CAAC,WAAW,EAAE;aAChD,CAAC,CAAC,CAAA;QACL,CAAC;QACD,OAAO,KAAK,EAAE,CAAC;YACb,IAAK,KAA+B,CAAC,IAAI,KAAK,QAAQ;gBACpD,OAAO,EAAE,CAAA;YACX,MAAM,KAAK,CAAA;QACb,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,52 @@
1
+ import type { AgentBinding, RunRepository, SkillEventListener, SkillRegistry, SkillRunner, SkillRunOptions, SkillRunSubscription, Workspace, WorkspaceEventBus } from '@braidhq/core';
2
+ import type { AbsolutePath, AgentBindingDescriptor, SkillId, SkillRunId } from '@braidhq/schema';
3
+ import type { ChildProcess, SpawnOptions } from 'node:child_process';
4
+ export type SpawnFn = (command: string, args: readonly string[], options: SpawnOptions) => ChildProcess;
5
+ /**
6
+ * Additional directories to expose under the session's `.claude/skills/` tree.
7
+ * Typically non-skill reference content,
8
+ * e.g. a `shared/` dir that builtin SKILL.md files reference.
9
+ */
10
+ export interface SkillReferenceDir {
11
+ readonly name: string;
12
+ readonly path: AbsolutePath;
13
+ }
14
+ export interface SubprocessSkillRunnerDeps {
15
+ readonly skillRegistry: SkillRegistry;
16
+ readonly buildAgentBinding: (descriptor: AgentBindingDescriptor) => AgentBinding;
17
+ readonly defaultAgent: AgentBindingDescriptor;
18
+ readonly apiUrl: string;
19
+ readonly runRepository: RunRepository;
20
+ readonly spawn?: SpawnFn;
21
+ readonly clock?: () => string;
22
+ readonly referenceDirs?: readonly SkillReferenceDir[];
23
+ readonly cleanupSession?: boolean;
24
+ readonly coreGateway?: {
25
+ readonly specUrl: string;
26
+ readonly uvxBin?: string;
27
+ };
28
+ readonly eventBus?: WorkspaceEventBus;
29
+ }
30
+ export declare class SubprocessSkillRunner implements SkillRunner {
31
+ private readonly deps;
32
+ private readonly running;
33
+ private readonly sessionDirs;
34
+ private readonly subscribers;
35
+ private readonly positions;
36
+ constructor(deps: SubprocessSkillRunnerDeps);
37
+ start(workspace: Workspace, skillId: SkillId, args: string, options?: SkillRunOptions): Promise<SkillRunId>;
38
+ subscribe(runId: SkillRunId, listener: SkillEventListener): SkillRunSubscription;
39
+ isActive(runId: SkillRunId): boolean;
40
+ cancel(runId: SkillRunId): Promise<void>;
41
+ forgetSession(sessionId: string): Promise<void>;
42
+ private drain;
43
+ private emit;
44
+ private resolveSessionDir;
45
+ private recoverSessionDir;
46
+ private buildSessionDir;
47
+ private skillBundleDir;
48
+ private skillBundleDirsFor;
49
+ private bindingFor;
50
+ private now;
51
+ }
52
+ //# sourceMappingURL=SubprocessSkillRunner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SubprocessSkillRunner.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/skill/SubprocessSkillRunner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,aAAa,EACb,kBAAkB,EAElB,aAAa,EACb,WAAW,EACX,eAAe,EACf,oBAAoB,EACpB,SAAS,EACT,iBAAiB,EAClB,MAAM,eAAe,CAAA;AACtB,OAAO,KAAK,EAAE,YAAY,EAAE,sBAAsB,EAA8D,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5J,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AASpE,MAAM,MAAM,OAAO,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,MAAM,EAAE,EAAE,OAAO,EAAE,YAAY,KAAK,YAAY,CAAA;A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Ae,GACxB,OAAO,CAAC,UAAU,CAAC;IAoGtB,SAAS,CAAC,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,kBAAkB,GAAG,oBAAoB;IAchF,QAAQ,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO;IAI9B,MAAM,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IAQxC,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;YASvC,KAAK;YAqFL,IAAI;YAiBJ,iBAAiB;YAkBjB,iBAAiB;YAQjB,eAAe;IA6C7B,OAAO,CAAC,cAAc;YAOR,kBAAkB;IAQhC,OAAO,CAAC,UAAU;IAalB,OAAO,CAAC,GAAG;CAGZ"}
@@ -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, McpServerId, 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,6 +20,7 @@ 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);
23
+ const skillBundleDirs = await this.skillBundleDirsFor(workspace, sessionDir);
24
24
  const gatewayArgs = [
25
25
  'openapi-mcp-gateway',
26
26
  '--spec',
@@ -29,52 +29,54 @@ export class SubprocessSkillRunner {
29
29
  'stdio',
30
30
  '--name',
31
31
  'braid-core',
32
- // Forward the caller's Bearer token so the gateway authenticates
33
- // its outgoing API calls. The gateway resolves `${BRAID_TOKEN}`
34
- // against its inherited process env at startup; without this the
35
- // server's auth middleware rejects every callback with 401.
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.
36
35
  // eslint-disable-next-line no-template-curly-in-string
37
36
  ...(options?.callerToken ? ['--auth-type', 'bearer', '--auth-token', '${BRAID_TOKEN}'] : []),
38
37
  ];
39
- const mcpConfigFile = await writeMcpConfigFile(workspace, sessionDir, {
40
- extraServers: 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
- });
49
- const invocation = this.deps.agentBinding.resolveSpawn({
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({
50
50
  skillId,
51
51
  args,
52
52
  workspace,
53
53
  manifest,
54
54
  apiUrl: this.deps.apiUrl,
55
- mcpConfigFile: AbsolutePathSchema.parse(mcpConfigFile),
55
+ mcpServers: [...gatewayServers, ...workspace.mcpServers],
56
+ sessionDir: AbsolutePathSchema.parse(sessionDir),
57
+ skillBundleDirs,
56
58
  ...(options?.resumeSessionId ? { resumeSessionId: options.resumeSessionId } : {}),
57
59
  });
58
60
  const spawnFn = this.deps.spawn ?? (await defaultSpawn());
59
- // BRAID_SESSION_DIR resolves ambiguity in SKILL.md paths: claude sees
60
- // both `BRAID_WORKSPACE` and a cwd that lives inside it, and would
61
- // 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.
62
64
  const child = spawnFn(invocation.bin, [...invocation.args], {
63
65
  cwd: sessionDir,
64
66
  env: {
65
67
  ...invocation.env,
66
68
  BRAID_SESSION_DIR: sessionDir,
67
- // BRAID_TOKEN is read by the braid-core MCP gateway and by any
68
- // shell-level callback (curl in a SKILL.md) so the subprocess
69
- // can authenticate against the running server.
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.
70
72
  ...(options?.callerToken ? { BRAID_TOKEN: options.callerToken } : {}),
71
73
  ...(options?.extraEnv ?? {}),
72
74
  },
73
75
  stdio: ['ignore', 'pipe', 'pipe'],
74
76
  });
75
77
  this.running.set(runId, { workspace, child });
76
- // Persist the started record up front so listing endpoints see the run
77
- // immediately, even before any subprocess output.
78
+ // Persist the started record up front,
79
+ // so listing endpoints see the run immediately, before any output.
78
80
  const startedAt = this.now();
79
81
  const initialRecord = {
80
82
  runId,
@@ -93,12 +95,13 @@ export class SubprocessSkillRunner {
93
95
  skillId,
94
96
  at: startedAt,
95
97
  });
96
- // Fire-and-forget the drain so the HTTP request that called start()
97
- // can return immediately.
98
+ // Fire-and-forget the drain,
99
+ // so the HTTP request that called start() can return immediately.
98
100
  void this.drain({
99
101
  workspace,
100
102
  runId,
101
103
  child,
104
+ parseLine: binding.parseLine,
102
105
  skillId,
103
106
  args,
104
107
  sessionDir,
@@ -154,13 +157,18 @@ export class SubprocessSkillRunner {
154
157
  at: input.startedAt,
155
158
  }));
156
159
  const queue = createAsyncQueue();
157
- const buffers = attachOutputBuffers(input.child, queue.push, () => this.now());
158
- input.child.on('close', (code) => {
160
+ const buffers = attachOutputBuffers(input.child, input.parseLine, queue.push, () => this.now());
161
+ input.child.on('close', (code, signal) => {
159
162
  buffers.flush();
160
163
  queue.push(SkillEventSchema.parse({
161
164
  type: 'completed',
162
165
  runId: input.runId,
163
- 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),
164
172
  at: this.now(),
165
173
  }));
166
174
  queue.end();
@@ -193,17 +201,16 @@ export class SubprocessSkillRunner {
193
201
  at: this.now(),
194
202
  });
195
203
  this.subscribers.delete(input.runId);
196
- // Keep the session dir on disk if a session id was captured: claude
197
- // stores conversation state per-cwd, so the dir must survive between
198
- // 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).
199
207
  const keepForResume = capturedSessionId !== null;
200
208
  if (this.deps.cleanupSession !== false && !keepForResume)
201
209
  await rm(input.sessionDir, { recursive: true, force: true }).catch(() => { });
202
210
  }
203
211
  }
204
- // Persist first, then broadcast. A subscriber that arrived just before
205
- // this emit is guaranteed to receive events strictly past its
206
- // positionAtSubscribe.
212
+ // Persist first, then broadcast.
213
+ // This guarantees a just-subscribed listener receives every event strictly past its positionAtSubscribe.
207
214
  async emit(workspace, runId, event) {
208
215
  await this.deps.runRepository.appendEvent(workspace, runId, event);
209
216
  const next = (this.positions.get(runId) ?? 0) + 1;
@@ -242,25 +249,70 @@ export class SubprocessSkillRunner {
242
249
  }
243
250
  async buildSessionDir(workspace, runId) {
244
251
  const sessionDir = sessionDirPath(workspace.rootPath, runId);
245
- const skillsDir = join(sessionDir, '.claude', 'skills');
246
- await mkdir(skillsDir, { recursive: true });
247
- const manifests = await this.deps.skillRegistry.list(workspace);
248
- const linked = new Set();
249
- for (const manifest of manifests) {
250
- const slashName = manifest.frontmatter.name;
251
- if (linked.has(slashName))
252
- continue;
253
- linked.add(slashName);
254
- await symlink(dirname(manifest.path), join(skillsDir, slashName), 'dir');
255
- }
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();
256
257
  for (const reference of this.deps.referenceDirs ?? []) {
257
- if (linked.has(reference.name))
258
+ if (linkedRefs.has(reference.name))
258
259
  continue;
259
- linked.add(reference.name);
260
- 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
+ }
261
288
  }
262
289
  return sessionDir;
263
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
+ }
264
316
  now() {
265
317
  return (this.deps.clock ?? (() => new Date().toISOString()))();
266
318
  }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SubprocessSkillRunner.js","sourceRoot":"","sources":["../../../src/infrastructure/skill/SubprocessSkillRunner.ts"],"names":[],"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* 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;I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AAA;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;QACD,GAAG,EAAE,GAAG,EAAE;YACR,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