@xemahq/biome-sdk 0.1.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 (383) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +62 -0
  3. package/dist/adapter/index.d.ts +7 -0
  4. package/dist/adapter/index.d.ts.map +1 -0
  5. package/dist/adapter/index.js +23 -0
  6. package/dist/adapter/index.js.map +1 -0
  7. package/dist/adapter/lib/action.d.ts +25 -0
  8. package/dist/adapter/lib/action.d.ts.map +1 -0
  9. package/dist/adapter/lib/action.js +3 -0
  10. package/dist/adapter/lib/action.js.map +1 -0
  11. package/dist/adapter/lib/provider-module.d.ts +41 -0
  12. package/dist/adapter/lib/provider-module.d.ts.map +1 -0
  13. package/dist/adapter/lib/provider-module.js +7 -0
  14. package/dist/adapter/lib/provider-module.js.map +1 -0
  15. package/dist/adapter/lib/resource.d.ts +25 -0
  16. package/dist/adapter/lib/resource.d.ts.map +1 -0
  17. package/dist/adapter/lib/resource.js +3 -0
  18. package/dist/adapter/lib/resource.js.map +1 -0
  19. package/dist/adapter/lib/result.d.ts +18 -0
  20. package/dist/adapter/lib/result.d.ts.map +1 -0
  21. package/dist/adapter/lib/result.js +12 -0
  22. package/dist/adapter/lib/result.js.map +1 -0
  23. package/dist/adapter/lib/sidecar-contract.d.ts +91 -0
  24. package/dist/adapter/lib/sidecar-contract.d.ts.map +1 -0
  25. package/dist/adapter/lib/sidecar-contract.js +19 -0
  26. package/dist/adapter/lib/sidecar-contract.js.map +1 -0
  27. package/dist/adapter/lib/webhook.d.ts +49 -0
  28. package/dist/adapter/lib/webhook.d.ts.map +1 -0
  29. package/dist/adapter/lib/webhook.js +3 -0
  30. package/dist/adapter/lib/webhook.js.map +1 -0
  31. package/dist/agent-workspace/index.d.ts +8 -0
  32. package/dist/agent-workspace/index.d.ts.map +1 -0
  33. package/dist/agent-workspace/index.js +24 -0
  34. package/dist/agent-workspace/index.js.map +1 -0
  35. package/dist/agent-workspace/lib/errors/error-codes.d.ts +16 -0
  36. package/dist/agent-workspace/lib/errors/error-codes.d.ts.map +1 -0
  37. package/dist/agent-workspace/lib/errors/error-codes.js +37 -0
  38. package/dist/agent-workspace/lib/errors/error-codes.js.map +1 -0
  39. package/dist/agent-workspace/lib/errors/index.d.ts +4 -0
  40. package/dist/agent-workspace/lib/errors/index.d.ts.map +1 -0
  41. package/dist/agent-workspace/lib/errors/index.js +20 -0
  42. package/dist/agent-workspace/lib/errors/index.js.map +1 -0
  43. package/dist/agent-workspace/lib/errors/mount-plan-error.d.ts +16 -0
  44. package/dist/agent-workspace/lib/errors/mount-plan-error.d.ts.map +1 -0
  45. package/dist/agent-workspace/lib/errors/mount-plan-error.js +26 -0
  46. package/dist/agent-workspace/lib/errors/mount-plan-error.js.map +1 -0
  47. package/dist/agent-workspace/lib/errors/mount-resolver-error.d.ts +34 -0
  48. package/dist/agent-workspace/lib/errors/mount-resolver-error.d.ts.map +1 -0
  49. package/dist/agent-workspace/lib/errors/mount-resolver-error.js +50 -0
  50. package/dist/agent-workspace/lib/errors/mount-resolver-error.js.map +1 -0
  51. package/dist/agent-workspace/lib/mount-resolver.d.ts +10 -0
  52. package/dist/agent-workspace/lib/mount-resolver.d.ts.map +1 -0
  53. package/dist/agent-workspace/lib/mount-resolver.js +3 -0
  54. package/dist/agent-workspace/lib/mount-resolver.js.map +1 -0
  55. package/dist/agent-workspace/lib/mount-source.d.ts +4 -0
  56. package/dist/agent-workspace/lib/mount-source.d.ts.map +1 -0
  57. package/dist/agent-workspace/lib/mount-source.js +3 -0
  58. package/dist/agent-workspace/lib/mount-source.js.map +1 -0
  59. package/dist/agent-workspace/lib/refid-resolver.d.ts +23 -0
  60. package/dist/agent-workspace/lib/refid-resolver.d.ts.map +1 -0
  61. package/dist/agent-workspace/lib/refid-resolver.js +103 -0
  62. package/dist/agent-workspace/lib/refid-resolver.js.map +1 -0
  63. package/dist/agent-workspace/lib/registries.d.ts +30 -0
  64. package/dist/agent-workspace/lib/registries.d.ts.map +1 -0
  65. package/dist/agent-workspace/lib/registries.js +88 -0
  66. package/dist/agent-workspace/lib/registries.js.map +1 -0
  67. package/dist/agent-workspace/lib/resolvers/agent-definition.resolver.d.ts +13 -0
  68. package/dist/agent-workspace/lib/resolvers/agent-definition.resolver.d.ts.map +1 -0
  69. package/dist/agent-workspace/lib/resolvers/agent-definition.resolver.js +25 -0
  70. package/dist/agent-workspace/lib/resolvers/agent-definition.resolver.js.map +1 -0
  71. package/dist/agent-workspace/lib/resolvers/artifact-store-collection.resolver.d.ts +13 -0
  72. package/dist/agent-workspace/lib/resolvers/artifact-store-collection.resolver.d.ts.map +1 -0
  73. package/dist/agent-workspace/lib/resolvers/artifact-store-collection.resolver.js +28 -0
  74. package/dist/agent-workspace/lib/resolvers/artifact-store-collection.resolver.js.map +1 -0
  75. package/dist/agent-workspace/lib/resolvers/artifact-version.resolver.d.ts +13 -0
  76. package/dist/agent-workspace/lib/resolvers/artifact-version.resolver.d.ts.map +1 -0
  77. package/dist/agent-workspace/lib/resolvers/artifact-version.resolver.js +25 -0
  78. package/dist/agent-workspace/lib/resolvers/artifact-version.resolver.js.map +1 -0
  79. package/dist/agent-workspace/lib/resolvers/clients.d.ts +122 -0
  80. package/dist/agent-workspace/lib/resolvers/clients.d.ts.map +1 -0
  81. package/dist/agent-workspace/lib/resolvers/clients.js +3 -0
  82. package/dist/agent-workspace/lib/resolvers/clients.js.map +1 -0
  83. package/dist/agent-workspace/lib/resolvers/deliverable-specs.resolver.d.ts +13 -0
  84. package/dist/agent-workspace/lib/resolvers/deliverable-specs.resolver.d.ts.map +1 -0
  85. package/dist/agent-workspace/lib/resolvers/deliverable-specs.resolver.js +24 -0
  86. package/dist/agent-workspace/lib/resolvers/deliverable-specs.resolver.js.map +1 -0
  87. package/dist/agent-workspace/lib/resolvers/deliverables.resolver.d.ts +13 -0
  88. package/dist/agent-workspace/lib/resolvers/deliverables.resolver.d.ts.map +1 -0
  89. package/dist/agent-workspace/lib/resolvers/deliverables.resolver.js +28 -0
  90. package/dist/agent-workspace/lib/resolvers/deliverables.resolver.js.map +1 -0
  91. package/dist/agent-workspace/lib/resolvers/index.d.ts +20 -0
  92. package/dist/agent-workspace/lib/resolvers/index.d.ts.map +1 -0
  93. package/dist/agent-workspace/lib/resolvers/index.js +36 -0
  94. package/dist/agent-workspace/lib/resolvers/index.js.map +1 -0
  95. package/dist/agent-workspace/lib/resolvers/instruction-section.resolver.d.ts +13 -0
  96. package/dist/agent-workspace/lib/resolvers/instruction-section.resolver.d.ts.map +1 -0
  97. package/dist/agent-workspace/lib/resolvers/instruction-section.resolver.js +22 -0
  98. package/dist/agent-workspace/lib/resolvers/instruction-section.resolver.js.map +1 -0
  99. package/dist/agent-workspace/lib/resolvers/kb-pages.resolver.d.ts +13 -0
  100. package/dist/agent-workspace/lib/resolvers/kb-pages.resolver.d.ts.map +1 -0
  101. package/dist/agent-workspace/lib/resolvers/kb-pages.resolver.js +36 -0
  102. package/dist/agent-workspace/lib/resolvers/kb-pages.resolver.js.map +1 -0
  103. package/dist/agent-workspace/lib/resolvers/kb-space.resolver.d.ts +13 -0
  104. package/dist/agent-workspace/lib/resolvers/kb-space.resolver.d.ts.map +1 -0
  105. package/dist/agent-workspace/lib/resolvers/kb-space.resolver.js +26 -0
  106. package/dist/agent-workspace/lib/resolvers/kb-space.resolver.js.map +1 -0
  107. package/dist/agent-workspace/lib/resolvers/rendered-agents-md.resolver.d.ts +13 -0
  108. package/dist/agent-workspace/lib/resolvers/rendered-agents-md.resolver.d.ts.map +1 -0
  109. package/dist/agent-workspace/lib/resolvers/rendered-agents-md.resolver.js +23 -0
  110. package/dist/agent-workspace/lib/resolvers/rendered-agents-md.resolver.js.map +1 -0
  111. package/dist/agent-workspace/lib/resolvers/rendered-context-json.resolver.d.ts +13 -0
  112. package/dist/agent-workspace/lib/resolvers/rendered-context-json.resolver.d.ts.map +1 -0
  113. package/dist/agent-workspace/lib/resolvers/rendered-context-json.resolver.js +24 -0
  114. package/dist/agent-workspace/lib/resolvers/rendered-context-json.resolver.js.map +1 -0
  115. package/dist/agent-workspace/lib/resolvers/rendered-system-overlay.resolver.d.ts +13 -0
  116. package/dist/agent-workspace/lib/resolvers/rendered-system-overlay.resolver.d.ts.map +1 -0
  117. package/dist/agent-workspace/lib/resolvers/rendered-system-overlay.resolver.js +23 -0
  118. package/dist/agent-workspace/lib/resolvers/rendered-system-overlay.resolver.js.map +1 -0
  119. package/dist/agent-workspace/lib/resolvers/scm-repo.resolver.d.ts +13 -0
  120. package/dist/agent-workspace/lib/resolvers/scm-repo.resolver.d.ts.map +1 -0
  121. package/dist/agent-workspace/lib/resolvers/scm-repo.resolver.js +28 -0
  122. package/dist/agent-workspace/lib/resolvers/scm-repo.resolver.js.map +1 -0
  123. package/dist/agent-workspace/lib/resolvers/session-attachment.resolver.d.ts +13 -0
  124. package/dist/agent-workspace/lib/resolvers/session-attachment.resolver.d.ts.map +1 -0
  125. package/dist/agent-workspace/lib/resolvers/session-attachment.resolver.js +28 -0
  126. package/dist/agent-workspace/lib/resolvers/session-attachment.resolver.js.map +1 -0
  127. package/dist/agent-workspace/lib/resolvers/skill-bundle.resolver.d.ts +13 -0
  128. package/dist/agent-workspace/lib/resolvers/skill-bundle.resolver.d.ts.map +1 -0
  129. package/dist/agent-workspace/lib/resolvers/skill-bundle.resolver.js +29 -0
  130. package/dist/agent-workspace/lib/resolvers/skill-bundle.resolver.js.map +1 -0
  131. package/dist/agent-workspace/lib/resolvers/static-literal.resolver.d.ts +11 -0
  132. package/dist/agent-workspace/lib/resolvers/static-literal.resolver.d.ts.map +1 -0
  133. package/dist/agent-workspace/lib/resolvers/static-literal.resolver.js +33 -0
  134. package/dist/agent-workspace/lib/resolvers/static-literal.resolver.js.map +1 -0
  135. package/dist/agent-workspace/lib/resolvers/types.d.ts +35 -0
  136. package/dist/agent-workspace/lib/resolvers/types.d.ts.map +1 -0
  137. package/dist/agent-workspace/lib/resolvers/types.js +3 -0
  138. package/dist/agent-workspace/lib/resolvers/types.js.map +1 -0
  139. package/dist/agent-workspace/lib/resolvers/utils/agent-run-context-cache.d.ts +70 -0
  140. package/dist/agent-workspace/lib/resolvers/utils/agent-run-context-cache.d.ts.map +1 -0
  141. package/dist/agent-workspace/lib/resolvers/utils/agent-run-context-cache.js +90 -0
  142. package/dist/agent-workspace/lib/resolvers/utils/agent-run-context-cache.js.map +1 -0
  143. package/dist/agent-workspace/lib/resolvers/utils/auth.d.ts +5 -0
  144. package/dist/agent-workspace/lib/resolvers/utils/auth.d.ts.map +1 -0
  145. package/dist/agent-workspace/lib/resolvers/utils/auth.js +19 -0
  146. package/dist/agent-workspace/lib/resolvers/utils/auth.js.map +1 -0
  147. package/dist/agent-workspace/lib/resolvers/utils/size-cap.d.ts +3 -0
  148. package/dist/agent-workspace/lib/resolvers/utils/size-cap.d.ts.map +1 -0
  149. package/dist/agent-workspace/lib/resolvers/utils/size-cap.js +23 -0
  150. package/dist/agent-workspace/lib/resolvers/utils/size-cap.js.map +1 -0
  151. package/dist/agent-workspace/lib/resolvers/utils/streaming.d.ts +3 -0
  152. package/dist/agent-workspace/lib/resolvers/utils/streaming.d.ts.map +1 -0
  153. package/dist/agent-workspace/lib/resolvers/utils/streaming.js +11 -0
  154. package/dist/agent-workspace/lib/resolvers/utils/streaming.js.map +1 -0
  155. package/dist/agent-workspace/lib/workspace-renderer.d.ts +13 -0
  156. package/dist/agent-workspace/lib/workspace-renderer.d.ts.map +1 -0
  157. package/dist/agent-workspace/lib/workspace-renderer.js +3 -0
  158. package/dist/agent-workspace/lib/workspace-renderer.js.map +1 -0
  159. package/dist/api/index.d.ts +11 -0
  160. package/dist/api/index.d.ts.map +1 -0
  161. package/dist/api/index.js +27 -0
  162. package/dist/api/index.js.map +1 -0
  163. package/dist/api/lib/api-manifest.d.ts +29 -0
  164. package/dist/api/lib/api-manifest.d.ts.map +1 -0
  165. package/dist/api/lib/api-manifest.js +28 -0
  166. package/dist/api/lib/api-manifest.js.map +1 -0
  167. package/dist/api/lib/biome-db.d.ts +2 -0
  168. package/dist/api/lib/biome-db.d.ts.map +1 -0
  169. package/dist/api/lib/biome-db.js +13 -0
  170. package/dist/api/lib/biome-db.js.map +1 -0
  171. package/dist/api/lib/code-tool-context.d.ts +16 -0
  172. package/dist/api/lib/code-tool-context.d.ts.map +1 -0
  173. package/dist/api/lib/code-tool-context.js +12 -0
  174. package/dist/api/lib/code-tool-context.js.map +1 -0
  175. package/dist/api/lib/code-tool-descriptor.d.ts +49 -0
  176. package/dist/api/lib/code-tool-descriptor.d.ts.map +1 -0
  177. package/dist/api/lib/code-tool-descriptor.js +3 -0
  178. package/dist/api/lib/code-tool-descriptor.js.map +1 -0
  179. package/dist/api/lib/code-tool.decorator.d.ts +17 -0
  180. package/dist/api/lib/code-tool.decorator.d.ts.map +1 -0
  181. package/dist/api/lib/code-tool.decorator.js +38 -0
  182. package/dist/api/lib/code-tool.decorator.js.map +1 -0
  183. package/dist/api/lib/mutation-context.d.ts +16 -0
  184. package/dist/api/lib/mutation-context.d.ts.map +1 -0
  185. package/dist/api/lib/mutation-context.js +17 -0
  186. package/dist/api/lib/mutation-context.js.map +1 -0
  187. package/dist/api/lib/pagination.d.ts +8 -0
  188. package/dist/api/lib/pagination.d.ts.map +1 -0
  189. package/dist/api/lib/pagination.js +7 -0
  190. package/dist/api/lib/pagination.js.map +1 -0
  191. package/dist/api/lib/provider-kind-mirror.d.ts +7 -0
  192. package/dist/api/lib/provider-kind-mirror.d.ts.map +1 -0
  193. package/dist/api/lib/provider-kind-mirror.js +11 -0
  194. package/dist/api/lib/provider-kind-mirror.js.map +1 -0
  195. package/dist/api/lib/request-context.d.ts +21 -0
  196. package/dist/api/lib/request-context.d.ts.map +1 -0
  197. package/dist/api/lib/request-context.js +51 -0
  198. package/dist/api/lib/request-context.js.map +1 -0
  199. package/dist/api/lib/route-registry-entry.d.ts +11 -0
  200. package/dist/api/lib/route-registry-entry.d.ts.map +1 -0
  201. package/dist/api/lib/route-registry-entry.js +3 -0
  202. package/dist/api/lib/route-registry-entry.js.map +1 -0
  203. package/dist/api/nest/controller-base.d.ts +6 -0
  204. package/dist/api/nest/controller-base.d.ts.map +1 -0
  205. package/dist/api/nest/controller-base.js +28 -0
  206. package/dist/api/nest/controller-base.js.map +1 -0
  207. package/dist/api/nest/events/events.controller.d.ts +10 -0
  208. package/dist/api/nest/events/events.controller.d.ts.map +1 -0
  209. package/dist/api/nest/events/events.controller.js +56 -0
  210. package/dist/api/nest/events/events.controller.js.map +1 -0
  211. package/dist/api/nest/health/health.controller.d.ts +19 -0
  212. package/dist/api/nest/health/health.controller.d.ts.map +1 -0
  213. package/dist/api/nest/health/health.controller.js +63 -0
  214. package/dist/api/nest/health/health.controller.js.map +1 -0
  215. package/dist/api/nest/health/health.module.d.ts +6 -0
  216. package/dist/api/nest/health/health.module.d.ts.map +1 -0
  217. package/dist/api/nest/health/health.module.js +29 -0
  218. package/dist/api/nest/health/health.module.js.map +1 -0
  219. package/dist/api/nest/index.d.ts +7 -0
  220. package/dist/api/nest/index.d.ts.map +1 -0
  221. package/dist/api/nest/index.js +23 -0
  222. package/dist/api/nest/index.js.map +1 -0
  223. package/dist/api/nest/module.d.ts +6 -0
  224. package/dist/api/nest/module.d.ts.map +1 -0
  225. package/dist/api/nest/module.js +34 -0
  226. package/dist/api/nest/module.js.map +1 -0
  227. package/dist/api/nest/request-context.d.ts +17 -0
  228. package/dist/api/nest/request-context.d.ts.map +1 -0
  229. package/dist/api/nest/request-context.js +75 -0
  230. package/dist/api/nest/request-context.js.map +1 -0
  231. package/dist/builder/index.d.ts +7 -0
  232. package/dist/builder/index.d.ts.map +1 -0
  233. package/dist/builder/index.js +23 -0
  234. package/dist/builder/index.js.map +1 -0
  235. package/dist/builder/lib/content-walker.d.ts +27 -0
  236. package/dist/builder/lib/content-walker.d.ts.map +1 -0
  237. package/dist/builder/lib/content-walker.js +274 -0
  238. package/dist/builder/lib/content-walker.js.map +1 -0
  239. package/dist/builder/lib/contribution-schemas.d.ts +348 -0
  240. package/dist/builder/lib/contribution-schemas.d.ts.map +1 -0
  241. package/dist/builder/lib/contribution-schemas.js +301 -0
  242. package/dist/builder/lib/contribution-schemas.js.map +1 -0
  243. package/dist/builder/lib/define-biome.d.ts +17 -0
  244. package/dist/builder/lib/define-biome.d.ts.map +1 -0
  245. package/dist/builder/lib/define-biome.js +11 -0
  246. package/dist/builder/lib/define-biome.js.map +1 -0
  247. package/dist/builder/lib/define-helpers.d.ts +6 -0
  248. package/dist/builder/lib/define-helpers.d.ts.map +1 -0
  249. package/dist/builder/lib/define-helpers.js +20 -0
  250. package/dist/builder/lib/define-helpers.js.map +1 -0
  251. package/dist/builder/lib/extends-precedence.d.ts +14 -0
  252. package/dist/builder/lib/extends-precedence.d.ts.map +1 -0
  253. package/dist/builder/lib/extends-precedence.js +113 -0
  254. package/dist/builder/lib/extends-precedence.js.map +1 -0
  255. package/dist/builder/lib/workflow-phase-config-loader.d.ts +18 -0
  256. package/dist/builder/lib/workflow-phase-config-loader.d.ts.map +1 -0
  257. package/dist/builder/lib/workflow-phase-config-loader.js +78 -0
  258. package/dist/builder/lib/workflow-phase-config-loader.js.map +1 -0
  259. package/dist/host/index.d.ts +11 -0
  260. package/dist/host/index.d.ts.map +1 -0
  261. package/dist/host/index.js +38 -0
  262. package/dist/host/index.js.map +1 -0
  263. package/dist/host/lib/agents-cross-validate.d.ts +7 -0
  264. package/dist/host/lib/agents-cross-validate.d.ts.map +1 -0
  265. package/dist/host/lib/agents-cross-validate.js +157 -0
  266. package/dist/host/lib/agents-cross-validate.js.map +1 -0
  267. package/dist/host/lib/biome-manifest.d.ts +808 -0
  268. package/dist/host/lib/biome-manifest.d.ts.map +1 -0
  269. package/dist/host/lib/biome-manifest.js +490 -0
  270. package/dist/host/lib/biome-manifest.js.map +1 -0
  271. package/dist/host/lib/bootstrap-contributions-service.d.ts +35 -0
  272. package/dist/host/lib/bootstrap-contributions-service.d.ts.map +1 -0
  273. package/dist/host/lib/bootstrap-contributions-service.js +79 -0
  274. package/dist/host/lib/bootstrap-contributions-service.js.map +1 -0
  275. package/dist/host/lib/default-state.d.ts +3 -0
  276. package/dist/host/lib/default-state.d.ts.map +1 -0
  277. package/dist/host/lib/default-state.js +20 -0
  278. package/dist/host/lib/default-state.js.map +1 -0
  279. package/dist/host/lib/integration-cross-validate.d.ts +12 -0
  280. package/dist/host/lib/integration-cross-validate.d.ts.map +1 -0
  281. package/dist/host/lib/integration-cross-validate.js +66 -0
  282. package/dist/host/lib/integration-cross-validate.js.map +1 -0
  283. package/dist/host/lib/system-overlay-contribution.d.ts +14 -0
  284. package/dist/host/lib/system-overlay-contribution.d.ts.map +1 -0
  285. package/dist/host/lib/system-overlay-contribution.js +3 -0
  286. package/dist/host/lib/system-overlay-contribution.js.map +1 -0
  287. package/dist/host/lib/topology.d.ts +7 -0
  288. package/dist/host/lib/topology.d.ts.map +1 -0
  289. package/dist/host/lib/topology.js +105 -0
  290. package/dist/host/lib/topology.js.map +1 -0
  291. package/dist/index.d.ts +9 -0
  292. package/dist/index.d.ts.map +1 -0
  293. package/dist/index.js +37 -0
  294. package/dist/index.js.map +1 -0
  295. package/dist/orchestrator-adapter/index.d.ts +3 -0
  296. package/dist/orchestrator-adapter/index.d.ts.map +1 -0
  297. package/dist/orchestrator-adapter/index.js +19 -0
  298. package/dist/orchestrator-adapter/index.js.map +1 -0
  299. package/dist/orchestrator-adapter/lib/orchestrator-adapter-registry.d.ts +6 -0
  300. package/dist/orchestrator-adapter/lib/orchestrator-adapter-registry.d.ts.map +1 -0
  301. package/dist/orchestrator-adapter/lib/orchestrator-adapter-registry.js +11 -0
  302. package/dist/orchestrator-adapter/lib/orchestrator-adapter-registry.js.map +1 -0
  303. package/dist/orchestrator-adapter/lib/orchestrator-adapter.d.ts +11 -0
  304. package/dist/orchestrator-adapter/lib/orchestrator-adapter.d.ts.map +1 -0
  305. package/dist/orchestrator-adapter/lib/orchestrator-adapter.js +3 -0
  306. package/dist/orchestrator-adapter/lib/orchestrator-adapter.js.map +1 -0
  307. package/package.json +110 -0
  308. package/src/adapter/index.ts +6 -0
  309. package/src/adapter/lib/action.ts +60 -0
  310. package/src/adapter/lib/provider-module.ts +140 -0
  311. package/src/adapter/lib/resource.ts +52 -0
  312. package/src/adapter/lib/result.ts +53 -0
  313. package/src/adapter/lib/sidecar-contract.ts +169 -0
  314. package/src/adapter/lib/webhook.ts +142 -0
  315. package/src/agent-workspace/index.ts +7 -0
  316. package/src/agent-workspace/lib/errors/error-codes.ts +44 -0
  317. package/src/agent-workspace/lib/errors/index.ts +3 -0
  318. package/src/agent-workspace/lib/errors/mount-plan-error.ts +29 -0
  319. package/src/agent-workspace/lib/errors/mount-resolver-error.ts +56 -0
  320. package/src/agent-workspace/lib/mount-resolver.ts +35 -0
  321. package/src/agent-workspace/lib/mount-source.ts +11 -0
  322. package/src/agent-workspace/lib/refid-resolver.ts +135 -0
  323. package/src/agent-workspace/lib/registries.ts +150 -0
  324. package/src/agent-workspace/lib/resolvers/agent-definition.resolver.ts +45 -0
  325. package/src/agent-workspace/lib/resolvers/artifact-store-collection.resolver.ts +43 -0
  326. package/src/agent-workspace/lib/resolvers/artifact-version.resolver.ts +52 -0
  327. package/src/agent-workspace/lib/resolvers/clients.ts +297 -0
  328. package/src/agent-workspace/lib/resolvers/deliverable-specs.resolver.ts +33 -0
  329. package/src/agent-workspace/lib/resolvers/deliverables.resolver.ts +41 -0
  330. package/src/agent-workspace/lib/resolvers/index.ts +19 -0
  331. package/src/agent-workspace/lib/resolvers/instruction-section.resolver.ts +36 -0
  332. package/src/agent-workspace/lib/resolvers/kb-pages.resolver.ts +62 -0
  333. package/src/agent-workspace/lib/resolvers/kb-space.resolver.ts +34 -0
  334. package/src/agent-workspace/lib/resolvers/rendered-agents-md.resolver.ts +40 -0
  335. package/src/agent-workspace/lib/resolvers/rendered-context-json.resolver.ts +41 -0
  336. package/src/agent-workspace/lib/resolvers/rendered-system-overlay.resolver.ts +39 -0
  337. package/src/agent-workspace/lib/resolvers/scm-repo.resolver.ts +43 -0
  338. package/src/agent-workspace/lib/resolvers/session-attachment.resolver.ts +37 -0
  339. package/src/agent-workspace/lib/resolvers/skill-bundle.resolver.ts +42 -0
  340. package/src/agent-workspace/lib/resolvers/static-literal.resolver.ts +69 -0
  341. package/src/agent-workspace/lib/resolvers/types.ts +94 -0
  342. package/src/agent-workspace/lib/resolvers/utils/agent-run-context-cache.ts +206 -0
  343. package/src/agent-workspace/lib/resolvers/utils/auth.ts +39 -0
  344. package/src/agent-workspace/lib/resolvers/utils/size-cap.ts +38 -0
  345. package/src/agent-workspace/lib/resolvers/utils/streaming.ts +22 -0
  346. package/src/agent-workspace/lib/workspace-renderer.ts +25 -0
  347. package/src/api/index.ts +10 -0
  348. package/src/api/lib/api-manifest.ts +54 -0
  349. package/src/api/lib/biome-db.ts +28 -0
  350. package/src/api/lib/code-tool-context.ts +45 -0
  351. package/src/api/lib/code-tool-descriptor.ts +102 -0
  352. package/src/api/lib/code-tool.decorator.ts +111 -0
  353. package/src/api/lib/mutation-context.ts +49 -0
  354. package/src/api/lib/pagination.ts +17 -0
  355. package/src/api/lib/provider-kind-mirror.ts +16 -0
  356. package/src/api/lib/request-context.ts +90 -0
  357. package/src/api/lib/route-registry-entry.ts +35 -0
  358. package/src/api/nest/controller-base.ts +59 -0
  359. package/src/api/nest/events/events.controller.ts +48 -0
  360. package/src/api/nest/health/health.controller.ts +36 -0
  361. package/src/api/nest/health/health.module.ts +29 -0
  362. package/src/api/nest/index.ts +6 -0
  363. package/src/api/nest/module.ts +51 -0
  364. package/src/api/nest/request-context.ts +166 -0
  365. package/src/builder/index.ts +26 -0
  366. package/src/builder/lib/content-walker.ts +383 -0
  367. package/src/builder/lib/contribution-schemas.ts +572 -0
  368. package/src/builder/lib/define-biome.ts +84 -0
  369. package/src/builder/lib/define-helpers.ts +42 -0
  370. package/src/builder/lib/extends-precedence.ts +195 -0
  371. package/src/builder/lib/workflow-phase-config-loader.ts +163 -0
  372. package/src/host/index.ts +39 -0
  373. package/src/host/lib/agents-cross-validate.ts +283 -0
  374. package/src/host/lib/biome-manifest.ts +1060 -0
  375. package/src/host/lib/bootstrap-contributions-service.ts +233 -0
  376. package/src/host/lib/default-state.ts +40 -0
  377. package/src/host/lib/integration-cross-validate.ts +140 -0
  378. package/src/host/lib/system-overlay-contribution.ts +53 -0
  379. package/src/host/lib/topology.ts +174 -0
  380. package/src/index.ts +58 -0
  381. package/src/orchestrator-adapter/index.ts +2 -0
  382. package/src/orchestrator-adapter/lib/orchestrator-adapter-registry.ts +8 -0
  383. package/src/orchestrator-adapter/lib/orchestrator-adapter.ts +20 -0
@@ -0,0 +1,140 @@
1
+ import type {
2
+ AdapterKindRef,
3
+ CredentialKind,
4
+ ProviderOnboardingManifest,
5
+ } from '@xemahq/kernel-contracts/connector';
6
+
7
+ import type { OutboundActionHandler } from './action';
8
+ import type { ResourceLister } from './resource';
9
+ import type {
10
+ EventMapper,
11
+ IdempotencyKeyExtractor,
12
+ WebhookOrgResolver,
13
+ WebhookVerifier,
14
+ } from './webhook';
15
+
16
+ /**
17
+ * Closed-grammar OAuth + AppInstall config blobs the adapter-sdk
18
+ * surfaces to the registry. Concrete shapes intentionally narrow —
19
+ * biome manifests declare the values; the registry MAY ship them to
20
+ * the install wizard for "Connect <provider>" UX.
21
+ */
22
+ export interface OAuthAppConfig {
23
+ readonly clientIdEnvVar: string;
24
+ readonly clientSecretEnvVar: string;
25
+ readonly authorizationUrl: string;
26
+ readonly tokenUrl: string;
27
+ readonly scopes: readonly string[];
28
+ }
29
+
30
+ export interface AppInstallConfig {
31
+ readonly appIdEnvVar: string;
32
+ readonly privateKeyEnvVar: string;
33
+ /** URL template (e.g. `https://github.com/apps/{slug}/installations/new`). */
34
+ readonly installUrlTemplate: string;
35
+ }
36
+
37
+ /**
38
+ * The single contract a biome-contributed integration adapter must
39
+ * implement. The same shape is used by:
40
+ * - **first-party** biomes loaded in-process inside
41
+ * `integration-adapters-api` (compiled JS, ESLint-quarantined from
42
+ * importing provider SDKs outside the biome's own folder);
43
+ * - **third-party** biomes deployed as `biome-adapter-host`
44
+ * sidecars exposing the same interface over HTTP/gRPC.
45
+ *
46
+ * Registry-side code never branches on hosting topology — the
47
+ * adapter-host service adapts both behind a common `ProviderRegistry`
48
+ * interface.
49
+ *
50
+ * Declared by biomes under `xema.ships.modules.integrationProviders[]`
51
+ * (one module per `(adapterKind, provider)` pair). The biome manifest
52
+ * cross-validator (`packages/biome-host-sdk`) checks that every
53
+ * provider declared here actually has a matching `adapterKinds[]`
54
+ * registration (built-in or biome-contributed) before the host
55
+ * accepts the manifest.
56
+ */
57
+ export interface IntegrationProviderModule {
58
+ // ── Identity ──
59
+ readonly adapterKind: AdapterKindRef;
60
+ /** Unique slug across the platform (e.g. `linear`, `stripe`). */
61
+ readonly provider: string;
62
+ /** Human-readable display name used by install UX + admin pages. */
63
+ readonly displayName: string;
64
+
65
+ // ── Webhook ingress ──
66
+ readonly webhook: {
67
+ readonly verifier: WebhookVerifier;
68
+ readonly eventMapper: EventMapper;
69
+ readonly idempotencyKeyExtractor: IdempotencyKeyExtractor;
70
+ /**
71
+ * Derives `(orgId, orgIntegrationId)` from the raw event. Optional
72
+ * because the legacy controllers do tenant resolution before
73
+ * handing off; new providers MUST declare it for the registry-
74
+ * driven router to dispatch.
75
+ */
76
+ readonly orgResolver?: WebhookOrgResolver;
77
+ };
78
+
79
+ // ── Credential ──
80
+ readonly credentialKind: CredentialKind;
81
+ readonly oauthConfig?: OAuthAppConfig;
82
+ readonly appConfig?: AppInstallConfig;
83
+
84
+ // ── Resource discovery (install UX) ──
85
+ readonly resources: Readonly<Record<string, ResourceLister>>;
86
+
87
+ // ── Outbound actions (activities) ──
88
+ readonly actions: Readonly<Record<string, OutboundActionHandler>>;
89
+
90
+ // ── Install-wizard onboarding metadata ──
91
+ /**
92
+ * Provider-declared install-UX manifest (display name, description,
93
+ * icon, credential field schema OR app-install launch copy). The
94
+ * frontend renders the "Connect <provider>" surface from this object
95
+ * alone — there is no hardcoded PROVIDER_INFO map in the UI.
96
+ *
97
+ * Required: every provider, first-party or biome-contributed, MUST
98
+ * declare an onboarding manifest. The remote-sidecar wrapper carries
99
+ * it through `SidecarManifestResponse.onboarding` so third-party
100
+ * adapters are first-class.
101
+ */
102
+ readonly onboarding: ProviderOnboardingManifest;
103
+ }
104
+
105
+ /**
106
+ * Tiny builder that nudges biome authors toward a stable shape and
107
+ * gives the registry a single import point for hosting-aware
108
+ * registration. Intentionally not a class — staying value-typed means
109
+ * sidecar serialization is trivial.
110
+ */
111
+ export function defineIntegrationProvider<T extends IntegrationProviderModule>(
112
+ module: T,
113
+ ): T {
114
+ return module;
115
+ }
116
+
117
+ /**
118
+ * Biome-contributed AdapterKind declaration. Owned by the manifest
119
+ * `xema.ships.modules.adapterKinds[]` slot; consumed at boot by
120
+ * `integration-adapters-api`'s registry to register a path schema +
121
+ * entityKind enum for the new kind. The kernel enforces semver-versioned
122
+ * envelope schemas: once published, a kind's envelope schema may add
123
+ * fields but not remove/retype existing ones (Phase 7 §7.1).
124
+ */
125
+ export interface AdapterKindDeclaration {
126
+ readonly kind: AdapterKindRef;
127
+ readonly version: string;
128
+ /**
129
+ * Closed list of entity kinds the adapter kind narrows over (e.g.
130
+ * for SCM: `['push', 'change_request', 'issue', ...]`). The
131
+ * `FilterExpr` path checker uses this to scope `$envelope` paths.
132
+ */
133
+ readonly entityKinds: readonly string[];
134
+ /**
135
+ * Per-entityKind allowed `$envelope.*` paths (dot-delimited). Same
136
+ * shape `integration-contracts`' built-in envelope schema uses; the
137
+ * registry merges these into the path-checker map at boot.
138
+ */
139
+ readonly envelopePaths: Readonly<Record<string, readonly string[]>>;
140
+ }
@@ -0,0 +1,52 @@
1
+ import type { MintedToken, ResourceRef } from '@xemahq/kernel-contracts/connector';
2
+
3
+ import type { Result } from './result';
4
+
5
+ /**
6
+ * "List provider-side resources of a given type" contract. Wired
7
+ * through `GET /adapters/:provider/resources/:type` by the registry.
8
+ * The install-wizard's resource-picker widgets bind to a
9
+ * `ResourceTypeRef = { adapterKind, provider, type }` — same code
10
+ * path for every provider in the registry.
11
+ *
12
+ * Streamed via `AsyncIterable` so wide enumerations (GitHub orgs with
13
+ * thousands of repos, Confluence spaces) page server-side without
14
+ * blowing past HTTP response timeouts. Implementations MUST yield
15
+ * pages of bounded size — the registry attaches a `Cursor` header to
16
+ * propagate continuation between calls.
17
+ */
18
+ export interface ResourceLister {
19
+ readonly type: string;
20
+ list(input: ResourceListInput): AsyncIterable<Result<ResourceListItem>>;
21
+ }
22
+
23
+ export interface ResourceListInput {
24
+ readonly credential: MintedToken;
25
+ readonly query?: string;
26
+ readonly parentResource?: ResourceRef;
27
+ readonly cursor?: string;
28
+ /** Soft cap; producers MAY return fewer rows. */
29
+ readonly pageSize?: number;
30
+ }
31
+
32
+ export interface ResourceListItem {
33
+ /** Provider-opaque id stored in `BiomeInstallationResource.selector`. */
34
+ readonly id: string;
35
+ /** Human-readable label rendered by the install wizard. */
36
+ readonly label: string;
37
+ /** Optional secondary description (e.g. repo description, channel topic). */
38
+ readonly description?: string;
39
+ /**
40
+ * Free-form metadata the install wizard MAY display (branch count,
41
+ * member count, last-activity timestamp). Provider-opaque to the
42
+ * platform — never used for routing or authorization.
43
+ */
44
+ readonly metadata?: Readonly<Record<string, string>>;
45
+ }
46
+
47
+ /** Registry-level reference: which provider's resource type. */
48
+ export interface ResourceTypeRef {
49
+ readonly adapterKind: string;
50
+ readonly provider: string;
51
+ readonly type: string;
52
+ }
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Tiny `Result<T, E>` envelope used by adapter-sdk contracts.
3
+ *
4
+ * Rationale: `WebhookVerifier.verify` and `EventMapper.map` run on a
5
+ * per-request hot path inside `integration-adapters-api`. Throwing
6
+ * across the in-process / sidecar boundary loses the typed error
7
+ * shape and bloats the receiving span with a stack trace. Returning
8
+ * `Result` keeps the contract symmetric across both hosting topologies
9
+ * and lets the receiver translate the typed error into a structured
10
+ * 4xx / 5xx without `instanceof` chains.
11
+ *
12
+ * Stays in this package (not platform-common) so the Kernel boundary
13
+ * holds: `@xemahq/adapter-sdk` MUST have zero runtime deps beyond
14
+ * `@xemahq/kernel-contracts/connector`.
15
+ */
16
+ export type Result<T, E = AdapterError> =
17
+ | { readonly ok: true; readonly value: T }
18
+ | { readonly ok: false; readonly error: E };
19
+
20
+ export const ok = <T>(value: T): Result<T, never> => ({ ok: true, value });
21
+ export const err = <E>(error: E): Result<never, E> => ({ ok: false, error });
22
+
23
+ /**
24
+ * Closed-set error reasons producers can surface to the registry.
25
+ * Receiver decides HTTP code; adapters MUST NOT throw raw `Error`s
26
+ * across the registry boundary.
27
+ */
28
+ export type AdapterErrorReason =
29
+ | 'verification-failed'
30
+ | 'malformed-payload'
31
+ | 'unsupported-event'
32
+ | 'rate-limited'
33
+ | 'upstream-unavailable'
34
+ | 'unauthorized'
35
+ | 'not-found'
36
+ | 'internal';
37
+
38
+ export interface AdapterError {
39
+ readonly reason: AdapterErrorReason;
40
+ readonly message: string;
41
+ /** Optional pointer to the offending field path inside the payload. */
42
+ readonly path?: string;
43
+ /** Provider-opaque retry hint, in seconds, when reason='rate-limited'. */
44
+ readonly retryAfterSec?: number;
45
+ }
46
+
47
+ export function adapterError(
48
+ reason: AdapterErrorReason,
49
+ message: string,
50
+ extra?: Pick<AdapterError, 'path' | 'retryAfterSec'>,
51
+ ): AdapterError {
52
+ return { reason, message, ...extra };
53
+ }
@@ -0,0 +1,169 @@
1
+ import type { ProviderOnboardingManifest } from '@xemahq/kernel-contracts/connector';
2
+
3
+ import type { OutboundActionResult } from './action';
4
+ import type { ResourceListItem } from './resource';
5
+ import type { AdapterError, Result } from './result';
6
+ import type { MappedEnvelope } from './webhook';
7
+
8
+ /**
9
+ * HTTP contract spoken between `integration-adapters-api` (host) and a
10
+ * `biome-adapter-host` sidecar pod (one per third-party biome).
11
+ *
12
+ * The sidecar loads a single biome package's `IntegrationProviderModule`
13
+ * in its own Node process and exposes every method over HTTP. The host
14
+ * wraps the remote shape with `RemoteProviderModule` so the
15
+ * `ProviderRegistry` registers it just like any in-process module —
16
+ * topology stays invisible to call sites.
17
+ *
18
+ * Why HTTP and not gRPC: every Xema service already speaks HTTP +
19
+ * service-token auth. Adding a gRPC stack to the host service for one
20
+ * biome protocol would force CI, observability, and security tooling
21
+ * to grow a second protocol. The performance gap doesn't matter at the
22
+ * webhook arrival rates we expect (≤ 100 rps per biome).
23
+ *
24
+ * All endpoints carry `X-Biome-Id` for the receiving sidecar to
25
+ * cross-check its own module's id, plus a service token bound to the
26
+ * `(orgId, biomeInstallationId)` posture pinned at dispatch time.
27
+ *
28
+ * Errors: every method returns `Result<T>`. Sidecar failures
29
+ * (`upstream-unavailable`, `internal`) flow as typed errors instead of
30
+ * HTTP 5xx — the host's `RemoteProviderModule` translates HTTP layer
31
+ * faults into the same shape so the registry doesn't branch on
32
+ * topology.
33
+ */
34
+
35
+ /** Provider metadata the host fetches once at registration time. */
36
+ export interface SidecarManifestResponse {
37
+ readonly adapterKind: string;
38
+ readonly provider: string;
39
+ readonly displayName: string;
40
+ readonly credentialKind: string;
41
+ /** Sorted list of resource types the sidecar exposes via list. */
42
+ readonly resourceTypes: readonly string[];
43
+ /** Sorted list of action names the sidecar exposes via execute. */
44
+ readonly actionNames: readonly string[];
45
+ /** Signature of the verifier the sidecar will run (algorithm + header). */
46
+ readonly verifier: {
47
+ readonly algorithm: string;
48
+ readonly signatureHeader: string;
49
+ readonly secretSource: string;
50
+ };
51
+ /** True iff the loaded module declares `webhook.orgResolver`. */
52
+ readonly hasOrgResolver: boolean;
53
+ /**
54
+ * Install-wizard onboarding metadata the sidecar declares for itself.
55
+ * The host forwards this verbatim through `GET /adapters/providers` so
56
+ * third-party adapters render in the install UI without code changes
57
+ * on the host.
58
+ */
59
+ readonly onboarding: ProviderOnboardingManifest;
60
+ }
61
+
62
+ /** Body for `POST /verify`. Raw body is base64'd for JSON safety. */
63
+ export interface SidecarVerifyRequest {
64
+ readonly rawBodyBase64: string;
65
+ readonly headers: Readonly<Record<string, string>>;
66
+ readonly secret: string;
67
+ }
68
+
69
+ /** Body for `POST /map-event`. */
70
+ export interface SidecarMapEventRequest {
71
+ readonly rawEvent: unknown;
72
+ readonly headers: Readonly<Record<string, string>>;
73
+ }
74
+
75
+ export type SidecarMapEventResponse =
76
+ | { readonly outcome: 'mapped'; readonly envelope: MappedEnvelope }
77
+ | { readonly outcome: 'ignored' };
78
+
79
+ /** Body for `POST /idempotency-key`. */
80
+ export interface SidecarIdempotencyKeyRequest {
81
+ readonly rawBody: unknown;
82
+ readonly headers: Readonly<Record<string, string>>;
83
+ }
84
+
85
+ export interface SidecarIdempotencyKeyResponse {
86
+ readonly key: string;
87
+ }
88
+
89
+ /**
90
+ * Body for `POST /resolve-org`. The host already resolved `(orgId,
91
+ * orgIntegrationId)` candidates via the `OrgIntegrationLookup` —
92
+ * sidecars don't get raw Prisma access, so they return whatever the
93
+ * payload yields and the host calls its lookup on the returned
94
+ * external identifier.
95
+ */
96
+ export interface SidecarResolveOrgRequest {
97
+ readonly rawBody: unknown;
98
+ readonly headers: Readonly<Record<string, string>>;
99
+ }
100
+
101
+ export type SidecarResolveOrgResponse =
102
+ | {
103
+ readonly outcome: 'matched';
104
+ readonly externalInstallationId: string;
105
+ }
106
+ | { readonly outcome: 'unbound' };
107
+
108
+ /** Body for `POST /resources/:type`. */
109
+ export interface SidecarListResourcesRequest {
110
+ readonly credential: SidecarMintedToken;
111
+ readonly query?: string;
112
+ readonly pageSize?: number;
113
+ readonly parentResource?: { readonly type: string; readonly id: string };
114
+ }
115
+
116
+ export interface SidecarListResourcesResponse {
117
+ readonly items: readonly Result<ResourceListItem>[];
118
+ }
119
+
120
+ /** Body for `POST /actions/:action`. Mirrors the in-process signature. */
121
+ export interface SidecarExecuteActionRequest {
122
+ readonly credential: SidecarMintedToken;
123
+ readonly params: unknown;
124
+ }
125
+
126
+ export type SidecarExecuteActionResponse = Result<OutboundActionResult, AdapterError>;
127
+
128
+ /**
129
+ * Token shape the host passes through to sidecars. Stays narrow so a
130
+ * third-party sidecar can't accidentally peek at the raw credential.
131
+ * Matches the host-side `MintedToken` from `@xemahq/kernel-contracts/connector`
132
+ * but redeclared here to keep the SDK independent.
133
+ */
134
+ export interface SidecarMintedToken {
135
+ readonly tokenType: string;
136
+ readonly accessToken: string;
137
+ readonly expiresAt?: string;
138
+ readonly providerHints?: Readonly<Record<string, string>>;
139
+ }
140
+
141
+ /**
142
+ * URL paths the sidecar host MUST serve. Centralized so the host's
143
+ * proxy adapter and the sidecar's NestJS controllers never drift.
144
+ * Keep these stable — operators script against them.
145
+ */
146
+ export const SIDECAR_PATHS = {
147
+ Manifest: '/manifest',
148
+ Verify: '/webhook/verify',
149
+ MapEvent: '/webhook/map-event',
150
+ IdempotencyKey: '/webhook/idempotency-key',
151
+ ResolveOrg: '/webhook/resolve-org',
152
+ ListResources: (type: string): string => `/resources/${encodeURIComponent(type)}`,
153
+ ExecuteAction: (action: string): string => `/actions/${encodeURIComponent(action)}`,
154
+ Health: '/health',
155
+ } as const;
156
+
157
+ /**
158
+ * Headers every sidecar request carries. The host injects them; the
159
+ * sidecar validates them. `X-Biome-Id` is the cross-check that the
160
+ * sidecar's loaded module matches the host's expectation — if a
161
+ * sidecar is rebuilt around the wrong biome, the host's first call
162
+ * fails fast.
163
+ */
164
+ export const SIDECAR_HEADERS = {
165
+ BiomeId: 'x-biome-id',
166
+ WorkflowRunId: 'x-workflow-run-id',
167
+ /** Service-token auth; sidecar verifies issuer + audience. */
168
+ Authorization: 'authorization',
169
+ } as const;
@@ -0,0 +1,142 @@
1
+ import type { Result } from './result';
2
+
3
+ /**
4
+ * Webhook signature verification contract. The registry calls
5
+ * `verify` BEFORE attempting to parse the body — fail-fast on bad
6
+ * signatures so untrusted payloads never reach the event mapper.
7
+ *
8
+ * `secretSource` lets the registry know how to source the verifying
9
+ * material:
10
+ * - `org-integration-secret`: the per-`OrgIntegration` encrypted
11
+ * blob — the registry decrypts and passes the plaintext as
12
+ * `input.secret`.
13
+ * - `provider-shared`: a single platform-wide secret managed in
14
+ * `integration-adapters-api` (used for providers that don't have
15
+ * per-installation secrets, e.g. some SaaS shared webhook tokens).
16
+ */
17
+ export interface WebhookVerifier {
18
+ readonly signatureHeader: string;
19
+ readonly algorithm: WebhookSignatureAlgorithm;
20
+ readonly secretSource: 'org-integration-secret' | 'provider-shared';
21
+ /**
22
+ * Pure verification function. Inputs are the raw body bytes plus the
23
+ * already-collected request headers (lower-cased keys) and the secret
24
+ * resolved from `secretSource`. Implementations MUST be constant-time
25
+ * for HMAC comparisons (use a library helper like `timingSafeEqual`).
26
+ */
27
+ verify(input: WebhookVerifyInput): Result<void>;
28
+ }
29
+
30
+ export type WebhookSignatureAlgorithm =
31
+ | 'hmac-sha256'
32
+ | 'hmac-sha1'
33
+ | 'ed25519'
34
+ | 'none';
35
+
36
+ export interface WebhookVerifyInput {
37
+ readonly rawBody: Uint8Array;
38
+ readonly headers: Readonly<Record<string, string>>;
39
+ readonly secret: string;
40
+ }
41
+
42
+ /**
43
+ * Canonical envelope payload + discriminators the registry persists
44
+ * + forwards to the owning domain service. `entityKind` MUST match
45
+ * one of the entityKinds the adapter declared in its manifest, and
46
+ * `payload` MUST conform to the canonical envelope schema for that
47
+ * `(adapterKind, entityKind)` pair (per `@xemahq/kernel-contracts/connector`).
48
+ *
49
+ * `null` means "ignore this delivery" — used for provider housekeeping
50
+ * events (e.g. GitHub `ping`) that shouldn't trigger any downstream
51
+ * workflow. Returning `null` is NOT a failure mode — the registry
52
+ * still records a `WebhookDelivery` row (for dedup audit) but does
53
+ * not forward to the domain service.
54
+ */
55
+ export interface MappedEnvelope {
56
+ readonly entityKind: string;
57
+ readonly event: string;
58
+ readonly payload: Readonly<Record<string, unknown>>;
59
+ /** Provider-native id surfaced for cross-provider correlation. */
60
+ readonly externalId?: string;
61
+ /** Provider-native parent key (e.g. SCM repo full name). */
62
+ readonly externalSpaceKey?: string;
63
+ /**
64
+ * Optional per-envelope adapterKind override. Used by providers that
65
+ * span multiple adapter kinds on a single webhook URL (e.g. Atlassian
66
+ * mixes Confluence/documentation and Jira/tracker; GitLab mixes SCM
67
+ * and tracker). When unset, the registry uses the provider module's
68
+ * declared `adapterKind` from `IntegrationProviderModule`. When set,
69
+ * MUST be a kind registered with `registerEnvelopeSchema` so the
70
+ * forwarder routes to the right domain service.
71
+ */
72
+ readonly adapterKindOverride?: string;
73
+ }
74
+
75
+ /**
76
+ * Converts a raw provider event into the canonical envelope shape.
77
+ * Pure: no I/O, no network calls. Idempotent — the registry MAY
78
+ * replay deliveries when the outbox worker is catching up.
79
+ *
80
+ * Headers are surfaced because several providers (GitHub, Gitea,
81
+ * GitLab, Atlassian) put the event-type discriminator on a header
82
+ * (`x-github-event`, `x-gitea-event`, `x-gitlab-event`, …) rather
83
+ * than on the payload. Providers whose discriminator is already on
84
+ * the payload can ignore the second argument.
85
+ */
86
+ export interface EventMapper {
87
+ map(input: EventMapperInput): Result<MappedEnvelope | null>;
88
+ }
89
+
90
+ export interface EventMapperInput {
91
+ readonly rawEvent: unknown;
92
+ readonly headers: Readonly<Record<string, string>>;
93
+ }
94
+
95
+ /**
96
+ * Pulls a deterministic dedup key from the raw event. Today this is
97
+ * the provider's delivery id header (e.g. GitHub's `x-github-delivery`)
98
+ * or a synthetic `{provider}:{event-id}` for providers that don't
99
+ * stamp one. MUST be stable across replays: the registry uses the key
100
+ * as the unique constraint on the `WebhookDelivery` table.
101
+ */
102
+ export type IdempotencyKeyExtractor = (input: {
103
+ readonly rawBody: unknown;
104
+ readonly headers: Readonly<Record<string, string>>;
105
+ }) => string;
106
+
107
+ /**
108
+ * Derives `(orgId, orgIntegrationId)` from a raw provider event. This
109
+ * is what the registry-driven webhook router uses to scope incoming
110
+ * traffic to the right tenant — every provider has its own rule (GitHub
111
+ * uses `installation.id`, GitLab a project id, Slack a team id, etc.),
112
+ * so the module owns the mapping.
113
+ *
114
+ * Return `null` when the event lacks tenant context (housekeeping
115
+ * pings, provider-wide health-checks). The router treats `null` the
116
+ * same as a `null` event-mapper result — record the delivery for audit,
117
+ * forward nothing.
118
+ *
119
+ * Implementations call the registry's lookup helpers (passed in as
120
+ * `lookup`) instead of reaching into Prisma directly so the kernel
121
+ * stays free of persistence imports.
122
+ */
123
+ export interface WebhookOrgResolver {
124
+ resolve(input: {
125
+ readonly rawBody: unknown;
126
+ readonly headers: Readonly<Record<string, string>>;
127
+ readonly lookup: OrgIntegrationLookup;
128
+ }): Promise<{ orgId: string; orgIntegrationId: string } | null>;
129
+ }
130
+
131
+ export interface OrgIntegrationLookup {
132
+ /**
133
+ * Find the `OrgIntegration` row whose provider-native id matches the
134
+ * supplied `externalId`. Returns `null` for unbound installations so
135
+ * the router can skip the dispatch (and surface "unbound install"
136
+ * telemetry) instead of throwing.
137
+ */
138
+ byExternalInstallationId(
139
+ provider: string,
140
+ externalInstallationId: string,
141
+ ): Promise<{ orgId: string; orgIntegrationId: string } | null>;
142
+ }
@@ -0,0 +1,7 @@
1
+ export * from './lib/mount-source';
2
+ export * from './lib/mount-resolver';
3
+ export * from './lib/refid-resolver';
4
+ export * from './lib/workspace-renderer';
5
+ export * from './lib/registries';
6
+ export * from './lib/errors';
7
+ export * from './lib/resolvers';
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Closed enum of every error this SDK + workspace-proxy mount endpoint can
3
+ * surface. Every enum value maps deterministically to an HTTP status via
4
+ * `mountResolverErrorHttpStatus()`.
5
+ *
6
+ * Adding a new code requires updating both the enum AND the status map in
7
+ * the same PR. CI is intentionally not enforcing this — readers should
8
+ * treat the map as the closed extension point.
9
+ */
10
+ export enum MountResolverErrorCode {
11
+ // 4xx — caller faults
12
+ PlanInvalid = 'MOUNT_PLAN_INVALID',
13
+ PlanDuplicatePath = 'MOUNT_PLAN_DUPLICATE_PATH',
14
+ PlanSpecMismatch = 'MOUNT_PLAN_SPEC_MISMATCH',
15
+ ActorUnauthorized = 'MOUNT_ACTOR_UNAUTHORIZED',
16
+ ActorForbidden = 'MOUNT_ACTOR_FORBIDDEN',
17
+ SourceNotFound = 'MOUNT_SOURCE_NOT_FOUND',
18
+ PayloadTooLarge = 'MOUNT_PAYLOAD_TOO_LARGE',
19
+ // 5xx — proxy / upstream faults
20
+ UpstreamBadGateway = 'MOUNT_UPSTREAM_BAD_GATEWAY',
21
+ UpstreamUnavailable = 'MOUNT_UPSTREAM_UNAVAILABLE',
22
+ UpstreamTimeout = 'MOUNT_UPSTREAM_TIMEOUT',
23
+ InsufficientStorage = 'MOUNT_INSUFFICIENT_STORAGE',
24
+ Internal = 'MOUNT_INTERNAL',
25
+ }
26
+
27
+ const HTTP_STATUS_MAP: Readonly<Record<MountResolverErrorCode, number>> = {
28
+ [MountResolverErrorCode.PlanInvalid]: 400,
29
+ [MountResolverErrorCode.PlanDuplicatePath]: 409,
30
+ [MountResolverErrorCode.PlanSpecMismatch]: 422,
31
+ [MountResolverErrorCode.ActorUnauthorized]: 401,
32
+ [MountResolverErrorCode.ActorForbidden]: 403,
33
+ [MountResolverErrorCode.SourceNotFound]: 404,
34
+ [MountResolverErrorCode.PayloadTooLarge]: 413,
35
+ [MountResolverErrorCode.UpstreamBadGateway]: 502,
36
+ [MountResolverErrorCode.UpstreamUnavailable]: 503,
37
+ [MountResolverErrorCode.UpstreamTimeout]: 504,
38
+ [MountResolverErrorCode.InsufficientStorage]: 507,
39
+ [MountResolverErrorCode.Internal]: 500,
40
+ };
41
+
42
+ export function mountResolverErrorHttpStatus(code: MountResolverErrorCode): number {
43
+ return HTTP_STATUS_MAP[code];
44
+ }
@@ -0,0 +1,3 @@
1
+ export * from './error-codes';
2
+ export * from './mount-plan-error';
3
+ export * from './mount-resolver-error';
@@ -0,0 +1,29 @@
1
+ import { MountResolverErrorCode } from './error-codes';
2
+
3
+ /**
4
+ * Plan-validation faults — surfaced before any I/O begins. These are
5
+ * caller bugs (malformed plan, duplicate paths, spec mismatch). Workspace
6
+ * state is untouched.
7
+ */
8
+ export abstract class MountPlanError extends Error {
9
+ abstract readonly code: MountResolverErrorCode;
10
+ readonly details: Readonly<Record<string, unknown>>;
11
+
12
+ constructor(message: string, details: Readonly<Record<string, unknown>> = {}) {
13
+ super(message);
14
+ this.name = new.target.name;
15
+ this.details = details;
16
+ }
17
+ }
18
+
19
+ export class MountPlanInvalidError extends MountPlanError {
20
+ readonly code = MountResolverErrorCode.PlanInvalid;
21
+ }
22
+
23
+ export class MountPlanDuplicatePathError extends MountPlanError {
24
+ readonly code = MountResolverErrorCode.PlanDuplicatePath;
25
+ }
26
+
27
+ export class MountPlanWorkspaceSpecMismatchError extends MountPlanError {
28
+ readonly code = MountResolverErrorCode.PlanSpecMismatch;
29
+ }