@alneas/eaos-server 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (350) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/LICENSE +21 -0
  3. package/README.ja.md +39 -0
  4. package/README.md +40 -2
  5. package/dist/agentic/agent-jobs.d.ts +329 -0
  6. package/dist/agentic/agent-jobs.js +15 -0
  7. package/dist/agentic/agent-jobs.js.map +1 -0
  8. package/dist/agentic/agent-node.d.ts +40 -0
  9. package/dist/agentic/agent-node.js +7 -0
  10. package/dist/agentic/agent-node.js.map +1 -0
  11. package/dist/agentic/agent-runner.d.ts +33 -0
  12. package/dist/agentic/agent-runner.js +7 -0
  13. package/dist/agentic/agent-runner.js.map +1 -0
  14. package/dist/agentic/ai-broker.d.ts +169 -0
  15. package/dist/agentic/ai-broker.js +8 -0
  16. package/dist/agentic/ai-broker.js.map +1 -0
  17. package/dist/agentic/atomic-checkpointer.d.ts +137 -0
  18. package/dist/agentic/atomic-checkpointer.js +9 -0
  19. package/dist/agentic/atomic-checkpointer.js.map +1 -0
  20. package/dist/agentic/autonomous-worker.d.ts +95 -0
  21. package/dist/agentic/autonomous-worker.js +9 -0
  22. package/dist/agentic/autonomous-worker.js.map +1 -0
  23. package/dist/agentic/event-bridge.d.ts +344 -0
  24. package/dist/agentic/event-bridge.js +9 -0
  25. package/dist/agentic/event-bridge.js.map +1 -0
  26. package/dist/agentic/executor.d.ts +91 -0
  27. package/dist/agentic/executor.js +12 -0
  28. package/dist/agentic/executor.js.map +1 -0
  29. package/dist/agentic/graph-projection.d.ts +119 -0
  30. package/dist/agentic/graph-projection.js +7 -0
  31. package/dist/agentic/graph-projection.js.map +1 -0
  32. package/dist/agentic/graph.d.ts +524 -0
  33. package/dist/agentic/graph.js +7 -0
  34. package/dist/agentic/graph.js.map +1 -0
  35. package/dist/agentic/index.d.ts +24 -0
  36. package/dist/agentic/index.js +86 -0
  37. package/dist/agentic/index.js.map +1 -0
  38. package/dist/agentic/local-runner.d.ts +102 -0
  39. package/dist/agentic/local-runner.js +7 -0
  40. package/dist/agentic/local-runner.js.map +1 -0
  41. package/dist/agentic/remote-executor.d.ts +67 -0
  42. package/dist/agentic/remote-executor.js +8 -0
  43. package/dist/agentic/remote-executor.js.map +1 -0
  44. package/dist/agentic/types.d.ts +157 -0
  45. package/dist/agentic/types.js +7 -0
  46. package/dist/agentic/types.js.map +1 -0
  47. package/dist/agentic/workflow-catalog.d.ts +152 -0
  48. package/dist/agentic/workflow-catalog.js +7 -0
  49. package/dist/agentic/workflow-catalog.js.map +1 -0
  50. package/dist/agentic/workflow-compiler.d.ts +44 -0
  51. package/dist/agentic/workflow-compiler.js +8 -0
  52. package/dist/agentic/workflow-compiler.js.map +1 -0
  53. package/dist/agentic/workflow-coordinator.d.ts +170 -0
  54. package/dist/agentic/workflow-coordinator.js +8 -0
  55. package/dist/agentic/workflow-coordinator.js.map +1 -0
  56. package/dist/agentic/workflow-manager.d.ts +91 -0
  57. package/dist/agentic/workflow-manager.js +7 -0
  58. package/dist/agentic/workflow-manager.js.map +1 -0
  59. package/dist/agentic/workflow-registry.d.ts +334 -0
  60. package/dist/agentic/workflow-registry.js +7 -0
  61. package/dist/agentic/workflow-registry.js.map +1 -0
  62. package/dist/artifacts-CteHmCMI.d.ts +614 -0
  63. package/dist/auth-hooks/api-key.d.ts +75 -0
  64. package/dist/auth-hooks/api-key.js +7 -0
  65. package/dist/auth-hooks/api-key.js.map +1 -0
  66. package/dist/auth-hooks/index.d.ts +80 -0
  67. package/dist/auth-hooks/index.js +28 -0
  68. package/dist/auth-hooks/index.js.map +1 -0
  69. package/dist/browser-auth/account-memberships.d.ts +213 -0
  70. package/dist/browser-auth/account-memberships.js +13 -0
  71. package/dist/browser-auth/account-memberships.js.map +1 -0
  72. package/dist/browser-auth/index.d.ts +8 -0
  73. package/dist/browser-auth/index.js +59 -0
  74. package/dist/browser-auth/index.js.map +1 -0
  75. package/dist/browser-auth/kratos-session.d.ts +37 -0
  76. package/dist/browser-auth/kratos-session.js +7 -0
  77. package/dist/browser-auth/kratos-session.js.map +1 -0
  78. package/dist/browser-auth/platform-session.d.ts +120 -0
  79. package/dist/browser-auth/platform-session.js +7 -0
  80. package/dist/browser-auth/platform-session.js.map +1 -0
  81. package/dist/browser-auth/public-memberships.d.ts +22 -0
  82. package/dist/browser-auth/public-memberships.js +7 -0
  83. package/dist/browser-auth/public-memberships.js.map +1 -0
  84. package/dist/cache/index.d.ts +181 -0
  85. package/dist/cache/index.js +197 -0
  86. package/dist/cache/index.js.map +1 -0
  87. package/dist/chunk-32746UQZ.js +131 -0
  88. package/dist/chunk-32746UQZ.js.map +1 -0
  89. package/dist/chunk-3NLSWP2Y.js +223 -0
  90. package/dist/chunk-3NLSWP2Y.js.map +1 -0
  91. package/dist/chunk-3P4XTTQH.js +346 -0
  92. package/dist/chunk-3P4XTTQH.js.map +1 -0
  93. package/dist/chunk-3VITSHN3.js +15 -0
  94. package/dist/chunk-3VITSHN3.js.map +1 -0
  95. package/dist/chunk-46UWPEW2.js +226 -0
  96. package/dist/chunk-46UWPEW2.js.map +1 -0
  97. package/dist/chunk-4VORUFKR.js +45 -0
  98. package/dist/chunk-4VORUFKR.js.map +1 -0
  99. package/dist/chunk-55D4ERWO.js +1 -0
  100. package/dist/chunk-55D4ERWO.js.map +1 -0
  101. package/dist/chunk-5TBBZIND.js +18 -0
  102. package/dist/chunk-5TBBZIND.js.map +1 -0
  103. package/dist/chunk-5WOZWPZA.js +211 -0
  104. package/dist/chunk-5WOZWPZA.js.map +1 -0
  105. package/dist/chunk-6CBVZ6CT.js +168 -0
  106. package/dist/chunk-6CBVZ6CT.js.map +1 -0
  107. package/dist/chunk-6KV5CJBW.js +221 -0
  108. package/dist/chunk-6KV5CJBW.js.map +1 -0
  109. package/dist/chunk-6XZXYNJR.js +74 -0
  110. package/dist/chunk-6XZXYNJR.js.map +1 -0
  111. package/dist/chunk-753HWDSC.js +222 -0
  112. package/dist/chunk-753HWDSC.js.map +1 -0
  113. package/dist/chunk-7AHSS7SO.js +81 -0
  114. package/dist/chunk-7AHSS7SO.js.map +1 -0
  115. package/dist/chunk-7FTJN4SA.js +1 -0
  116. package/dist/chunk-7FTJN4SA.js.map +1 -0
  117. package/dist/chunk-AVDMLTPF.js +24 -0
  118. package/dist/chunk-AVDMLTPF.js.map +1 -0
  119. package/dist/chunk-BKAHUEIT.js +95 -0
  120. package/dist/chunk-BKAHUEIT.js.map +1 -0
  121. package/dist/chunk-CJ7OFEF7.js +134 -0
  122. package/dist/chunk-CJ7OFEF7.js.map +1 -0
  123. package/dist/chunk-DHQGNP4T.js +770 -0
  124. package/dist/chunk-DHQGNP4T.js.map +1 -0
  125. package/dist/chunk-EJKWDZIU.js +111 -0
  126. package/dist/chunk-EJKWDZIU.js.map +1 -0
  127. package/dist/chunk-F3O7CELI.js +23 -0
  128. package/dist/chunk-F3O7CELI.js.map +1 -0
  129. package/dist/chunk-FD6VC2NA.js +66 -0
  130. package/dist/chunk-FD6VC2NA.js.map +1 -0
  131. package/dist/chunk-FRRRWAHO.js +14 -0
  132. package/dist/chunk-FRRRWAHO.js.map +1 -0
  133. package/dist/chunk-HCKAGLLB.js +17 -0
  134. package/dist/chunk-HCKAGLLB.js.map +1 -0
  135. package/dist/chunk-HVC7FG6B.js +191 -0
  136. package/dist/chunk-HVC7FG6B.js.map +1 -0
  137. package/dist/chunk-HXFVOR7Z.js +496 -0
  138. package/dist/chunk-HXFVOR7Z.js.map +1 -0
  139. package/dist/chunk-IJWYS2PF.js +122 -0
  140. package/dist/chunk-IJWYS2PF.js.map +1 -0
  141. package/dist/chunk-INCHXAFK.js +1395 -0
  142. package/dist/chunk-INCHXAFK.js.map +1 -0
  143. package/dist/chunk-JT6BRGQM.js +1 -0
  144. package/dist/chunk-JT6BRGQM.js.map +1 -0
  145. package/dist/chunk-L6PMAEMB.js +115 -0
  146. package/dist/chunk-L6PMAEMB.js.map +1 -0
  147. package/dist/chunk-LOUGW6MU.js +126 -0
  148. package/dist/chunk-LOUGW6MU.js.map +1 -0
  149. package/dist/chunk-LYPZPE53.js +129 -0
  150. package/dist/chunk-LYPZPE53.js.map +1 -0
  151. package/dist/chunk-NNCCN7JP.js +186 -0
  152. package/dist/chunk-NNCCN7JP.js.map +1 -0
  153. package/dist/chunk-PBC3MZUL.js +212 -0
  154. package/dist/chunk-PBC3MZUL.js.map +1 -0
  155. package/dist/chunk-R4ADP2DC.js +20 -0
  156. package/dist/chunk-R4ADP2DC.js.map +1 -0
  157. package/dist/chunk-RHN4Y6VS.js +44 -0
  158. package/dist/chunk-RHN4Y6VS.js.map +1 -0
  159. package/dist/chunk-THYUY5ZZ.js +204 -0
  160. package/dist/chunk-THYUY5ZZ.js.map +1 -0
  161. package/dist/chunk-UGNTCOVR.js +28 -0
  162. package/dist/chunk-UGNTCOVR.js.map +1 -0
  163. package/dist/chunk-VC2PCK2S.js +31 -0
  164. package/dist/chunk-VC2PCK2S.js.map +1 -0
  165. package/dist/chunk-VF5YDZJC.js +305 -0
  166. package/dist/chunk-VF5YDZJC.js.map +1 -0
  167. package/dist/chunk-VISRDVTK.js +675 -0
  168. package/dist/chunk-VISRDVTK.js.map +1 -0
  169. package/dist/chunk-W6O3LVBY.js +102 -0
  170. package/dist/chunk-W6O3LVBY.js.map +1 -0
  171. package/dist/chunk-WFEAKJLR.js +47 -0
  172. package/dist/chunk-WFEAKJLR.js.map +1 -0
  173. package/dist/chunk-XIEY2OF4.js +67 -0
  174. package/dist/chunk-XIEY2OF4.js.map +1 -0
  175. package/dist/chunk-XITLHDG3.js +37 -0
  176. package/dist/chunk-XITLHDG3.js.map +1 -0
  177. package/dist/chunk-XMWPYZWZ.js +61 -0
  178. package/dist/chunk-XMWPYZWZ.js.map +1 -0
  179. package/dist/chunk-XUP6CNOM.js +34 -0
  180. package/dist/chunk-XUP6CNOM.js.map +1 -0
  181. package/dist/chunk-YABTQZDJ.js +25 -0
  182. package/dist/chunk-YABTQZDJ.js.map +1 -0
  183. package/dist/chunk-YMJ7BRKU.js +510 -0
  184. package/dist/chunk-YMJ7BRKU.js.map +1 -0
  185. package/dist/chunk-ZC3XWU7B.js +28 -0
  186. package/dist/chunk-ZC3XWU7B.js.map +1 -0
  187. package/dist/chunk-ZHMTD5KV.js +90 -0
  188. package/dist/chunk-ZHMTD5KV.js.map +1 -0
  189. package/dist/chunk-ZWZDLOE7.js +160 -0
  190. package/dist/chunk-ZWZDLOE7.js.map +1 -0
  191. package/dist/db-package/db/local-first-sqlite-adapter.d.ts +432 -0
  192. package/dist/db-package/db/local-first-sqlite-adapter.js +7 -0
  193. package/dist/db-package/db/local-first-sqlite-adapter.js.map +1 -0
  194. package/dist/db-package/index.d.ts +7 -0
  195. package/dist/db-package/index.js +16 -0
  196. package/dist/db-package/index.js.map +1 -0
  197. package/dist/db-package/migration/aggregator.d.ts +86 -0
  198. package/dist/db-package/migration/aggregator.js +7 -0
  199. package/dist/db-package/migration/aggregator.js.map +1 -0
  200. package/dist/db-package/migration/index.d.ts +3 -0
  201. package/dist/db-package/migration/index.js +8 -0
  202. package/dist/db-package/migration/index.js.map +1 -0
  203. package/dist/engine.d.ts +205 -0
  204. package/dist/engine.js +20 -0
  205. package/dist/engine.js.map +1 -0
  206. package/dist/entitlements/index.d.ts +313 -0
  207. package/dist/entitlements/index.js +23 -0
  208. package/dist/entitlements/index.js.map +1 -0
  209. package/dist/execution/index.d.ts +50 -0
  210. package/dist/execution/index.js +57 -0
  211. package/dist/execution/index.js.map +1 -0
  212. package/dist/extensions/index.d.ts +172 -0
  213. package/dist/extensions/index.js +95 -0
  214. package/dist/extensions/index.js.map +1 -0
  215. package/dist/health/index.d.ts +35 -0
  216. package/dist/health/index.js +7 -0
  217. package/dist/health/index.js.map +1 -0
  218. package/dist/index.d.ts +39 -0
  219. package/dist/index.js +160 -0
  220. package/dist/index.js.map +1 -0
  221. package/dist/lifecycle/index.d.ts +133 -0
  222. package/dist/lifecycle/index.js +13 -0
  223. package/dist/lifecycle/index.js.map +1 -0
  224. package/dist/lifecycle-engine/backend-migration.d.ts +2 -0
  225. package/dist/lifecycle-engine/backend-migration.js +11 -0
  226. package/dist/lifecycle-engine/backend-migration.js.map +1 -0
  227. package/dist/lifecycle-engine/baseline.d.ts +2 -0
  228. package/dist/lifecycle-engine/baseline.js +9 -0
  229. package/dist/lifecycle-engine/baseline.js.map +1 -0
  230. package/dist/lifecycle-engine/index.d.ts +1497 -0
  231. package/dist/lifecycle-engine/index.js +41 -0
  232. package/dist/lifecycle-engine/index.js.map +1 -0
  233. package/dist/lifecycle-engine/platform/artifacts.d.ts +4 -0
  234. package/dist/lifecycle-engine/platform/artifacts.js +7 -0
  235. package/dist/lifecycle-engine/platform/artifacts.js.map +1 -0
  236. package/dist/lifecycle-engine/platform/control-plane.d.ts +12 -0
  237. package/dist/lifecycle-engine/platform/control-plane.js +2 -0
  238. package/dist/lifecycle-engine/platform/control-plane.js.map +1 -0
  239. package/dist/lifecycle-engine/platform/database-router.d.ts +118 -0
  240. package/dist/lifecycle-engine/platform/database-router.js +7 -0
  241. package/dist/lifecycle-engine/platform/database-router.js.map +1 -0
  242. package/dist/lifecycle-engine/platform/deployment-placements.d.ts +464 -0
  243. package/dist/lifecycle-engine/platform/deployment-placements.js +16 -0
  244. package/dist/lifecycle-engine/platform/deployment-placements.js.map +1 -0
  245. package/dist/lifecycle-engine/platform/deployment.d.ts +4 -0
  246. package/dist/lifecycle-engine/platform/deployment.js +17 -0
  247. package/dist/lifecycle-engine/platform/deployment.js.map +1 -0
  248. package/dist/lifecycle-engine/platform/index.d.ts +737 -0
  249. package/dist/lifecycle-engine/platform/index.js +60 -0
  250. package/dist/lifecycle-engine/platform/index.js.map +1 -0
  251. package/dist/lifecycle-engine/platform/runtime.d.ts +80 -0
  252. package/dist/lifecycle-engine/platform/runtime.js +11 -0
  253. package/dist/lifecycle-engine/platform/runtime.js.map +1 -0
  254. package/dist/lifecycle-engine/platform/site-publication.d.ts +102 -0
  255. package/dist/lifecycle-engine/platform/site-publication.js +7 -0
  256. package/dist/lifecycle-engine/platform/site-publication.js.map +1 -0
  257. package/dist/lifecycle-engine/platform/user-directory.d.ts +139 -0
  258. package/dist/lifecycle-engine/platform/user-directory.js +13 -0
  259. package/dist/lifecycle-engine/platform/user-directory.js.map +1 -0
  260. package/dist/mcp.d.ts +92 -0
  261. package/dist/mcp.js +10 -0
  262. package/dist/mcp.js.map +1 -0
  263. package/dist/middleware/auth.d.ts +118 -0
  264. package/dist/middleware/auth.js +7 -0
  265. package/dist/middleware/auth.js.map +1 -0
  266. package/dist/middleware/error-handler.d.ts +35 -0
  267. package/dist/middleware/error-handler.js +7 -0
  268. package/dist/middleware/error-handler.js.map +1 -0
  269. package/dist/middleware/module-guard.d.ts +33 -0
  270. package/dist/middleware/module-guard.js +7 -0
  271. package/dist/middleware/module-guard.js.map +1 -0
  272. package/dist/platform-admin/index.d.ts +37 -0
  273. package/dist/platform-admin/index.js +11 -0
  274. package/dist/platform-admin/index.js.map +1 -0
  275. package/dist/platform-admin/store.d.ts +346 -0
  276. package/dist/platform-admin/store.js +7 -0
  277. package/dist/platform-admin/store.js.map +1 -0
  278. package/dist/plugin-data/annotations.d.ts +6 -0
  279. package/dist/plugin-data/annotations.js +12 -0
  280. package/dist/plugin-data/annotations.js.map +1 -0
  281. package/dist/plugin-data/atomic-context.d.ts +41 -0
  282. package/dist/plugin-data/atomic-context.js +9 -0
  283. package/dist/plugin-data/atomic-context.js.map +1 -0
  284. package/dist/plugin-data/atomic.d.ts +6 -0
  285. package/dist/plugin-data/atomic.js +26 -0
  286. package/dist/plugin-data/atomic.js.map +1 -0
  287. package/dist/plugin-data/audit.d.ts +6 -0
  288. package/dist/plugin-data/audit.js +12 -0
  289. package/dist/plugin-data/audit.js.map +1 -0
  290. package/dist/plugin-data/commands.d.ts +6 -0
  291. package/dist/plugin-data/commands.js +8 -0
  292. package/dist/plugin-data/commands.js.map +1 -0
  293. package/dist/plugin-data/composite.d.ts +6 -0
  294. package/dist/plugin-data/composite.js +8 -0
  295. package/dist/plugin-data/composite.js.map +1 -0
  296. package/dist/plugin-data/delivery.d.ts +6 -0
  297. package/dist/plugin-data/delivery.js +16 -0
  298. package/dist/plugin-data/delivery.js.map +1 -0
  299. package/dist/plugin-data/index.d.ts +2798 -0
  300. package/dist/plugin-data/index.js +102 -0
  301. package/dist/plugin-data/index.js.map +1 -0
  302. package/dist/plugin-data/json-documents.d.ts +6 -0
  303. package/dist/plugin-data/json-documents.js +16 -0
  304. package/dist/plugin-data/json-documents.js.map +1 -0
  305. package/dist/plugin-data/outbox.d.ts +6 -0
  306. package/dist/plugin-data/outbox.js +16 -0
  307. package/dist/plugin-data/outbox.js.map +1 -0
  308. package/dist/plugin-data/scoped-records.d.ts +6 -0
  309. package/dist/plugin-data/scoped-records.js +10 -0
  310. package/dist/plugin-data/scoped-records.js.map +1 -0
  311. package/dist/plugin-sdk.d.ts +41 -0
  312. package/dist/plugin-sdk.js +10 -0
  313. package/dist/plugin-sdk.js.map +1 -0
  314. package/dist/sql-lifecycle/index.d.ts +138 -0
  315. package/dist/sql-lifecycle/index.js +167 -0
  316. package/dist/sql-lifecycle/index.js.map +1 -0
  317. package/dist/storage/index.d.ts +2 -0
  318. package/dist/storage/index.js +13 -0
  319. package/dist/storage/index.js.map +1 -0
  320. package/dist/storage/s3-compatible.d.ts +139 -0
  321. package/dist/storage/s3-compatible.js +11 -0
  322. package/dist/storage/s3-compatible.js.map +1 -0
  323. package/dist/tenant.d.ts +108 -0
  324. package/dist/tenant.js +9 -0
  325. package/dist/tenant.js.map +1 -0
  326. package/dist/workspace-context.d.ts +119 -0
  327. package/dist/workspace-context.js +9 -0
  328. package/dist/workspace-context.js.map +1 -0
  329. package/docs/api.md +29753 -0
  330. package/docs/db/README.md +49 -0
  331. package/docs/db/docs/api.md +1613 -0
  332. package/docs/db/docs/guide.md +47 -0
  333. package/docs/entitlements.md +60 -0
  334. package/docs/guide.md +48 -0
  335. package/docs/index.md +53 -0
  336. package/docs/ja/db/README.md +46 -0
  337. package/docs/ja/db/docs/guide.md +53 -0
  338. package/docs/ja/guide.md +46 -0
  339. package/docs/ja/lifecycle/README.md +46 -0
  340. package/docs/ja/lifecycle/docs/guide.md +45 -0
  341. package/docs/ja/storage/README.md +46 -0
  342. package/docs/ja/storage/docs/guide.md +43 -0
  343. package/docs/lifecycle/README.md +49 -0
  344. package/docs/lifecycle/docs/api.md +3770 -0
  345. package/docs/lifecycle/docs/baseline.md +50 -0
  346. package/docs/lifecycle/docs/guide.md +47 -0
  347. package/docs/storage/README.md +49 -0
  348. package/docs/storage/docs/api.md +470 -0
  349. package/docs/storage/docs/guide.md +47 -0
  350. package/package.json +345 -4
@@ -0,0 +1,57 @@
1
+ // src/execution/index.ts
2
+ import { Hono } from "hono";
3
+ function createPluginExecutionRouter(options) {
4
+ const router = new Hono(), operations = { ...options.operations }, maxBytes = options.maxBodyBytes ?? 1048576;
5
+ if (!Number.isSafeInteger(maxBytes) || maxBytes < 1) throw new Error("Invalid request limit");
6
+ router.post("/:pluginId/:action", async (c) => {
7
+ c.header("Cache-Control", "no-store");
8
+ try {
9
+ if (c.req.header("Content-Type")?.split(";")[0].trim().toLowerCase() !== "application/json") return c.json({ error: "JSON required" }, 415);
10
+ const origin = c.req.header("Origin");
11
+ if (origin && !options.allowedOrigins?.includes(origin)) return c.json({ error: "Origin denied" }, 403);
12
+ const identity = await options.resolveIdentity(c);
13
+ if (!identity?.tenantId?.trim() || !identity.userId?.trim()) return c.json({ error: "Authentication required" }, 401);
14
+ const { pluginId, action } = c.req.param();
15
+ if (!/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(pluginId) || !/^[a-zA-Z0-9_-]+$/.test(action) || !Object.hasOwn(operations, `${pluginId}:${action}`)) return c.json({ error: "Unknown operation" }, 404);
16
+ const reader = c.req.raw.body?.getReader();
17
+ const chunks = [];
18
+ let size = 0;
19
+ if (reader) try {
20
+ while (true) {
21
+ const { done, value } = await reader.read();
22
+ if (done) break;
23
+ size += value.length;
24
+ if (size > maxBytes) {
25
+ await reader.cancel();
26
+ return c.json({ error: "Request too large" }, 413);
27
+ }
28
+ ;
29
+ chunks.push(value);
30
+ }
31
+ } finally {
32
+ reader.releaseLock();
33
+ }
34
+ const bytes = new Uint8Array(size);
35
+ let offset = 0;
36
+ for (const chunk of chunks) {
37
+ bytes.set(chunk, offset);
38
+ offset += chunk.length;
39
+ }
40
+ let payload;
41
+ try {
42
+ payload = JSON.parse(new TextDecoder().decode(bytes));
43
+ } catch {
44
+ return c.json({ error: "Invalid JSON" }, 400);
45
+ }
46
+ if (!await options.authorize(identity, pluginId, action, payload)) return c.json({ error: "Execution denied" }, 403);
47
+ return c.json(await operations[`${pluginId}:${action}`](identity, payload));
48
+ } catch {
49
+ return c.json({ error: "Execution unavailable" }, 503);
50
+ }
51
+ });
52
+ return router;
53
+ }
54
+ export {
55
+ createPluginExecutionRouter
56
+ };
57
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/execution/index.ts"],"sourcesContent":["import { Hono, type Context } from 'hono'\n/**\n * Authenticated host identity supplied to {@link createPluginExecutionRouter}.\n */\nexport interface ExecutionIdentity {\n /** Nonblank verified tenant ID. */\n tenantId: string\n /** Nonblank verified user ID. */\n userId: string\n}\n/**\n * Routes authenticated, authorized JSON requests to a fixed plugin/action operation map.\n * @param options - resolveIdentity receives Hono context and resolves verified identity/null; authorize receives that identity, pluginId, action, and parsed payload and must check current membership, activation, and resource permissions; operations maps pluginId:action to async handlers receiving identity/payload. maxBodyBytes defaults to 1048576; allowedOrigins permits exact Origin values and defaults to none.\n * @returns A router serving POST /:pluginId/:action with no-store responses. It returns handler output as JSON or explicit 400/401/403/404/413/415 failures; callback/transport/serialization failures become 503.\n * @throws Synchronously for a nonpositive or unsafe-integer body limit.\n * @remarks The operation map is shallow-copied at creation. Plugin IDs must be lowercase kebab-case; actions allow letters/digits/underscore/hyphen. Origin is checked only when present and is not authentication. Body readers are released and oversized streams cancelled. No transaction, idempotency, cancellation, or retry is supplied; operation side effects may precede a 503 response.\n * @example\n * ```typescript\n * import { createPluginExecutionRouter } from \"@alneas/eaos-server/execution\";\n * export function executionRouter(options: Parameters<typeof createPluginExecutionRouter>[0]) {\n * // Host adapters authenticate, authorize, validate payloads, and persist operation results.\n * return createPluginExecutionRouter(options);\n * }\n * ```\n */\nexport function createPluginExecutionRouter(options: {\n /**\n * Authenticates the Hono request and resolves nonblank verified tenant/user IDs or null; callback failure becomes a 503 response.\n */\n resolveIdentity: (context: Context) => Promise<ExecutionIdentity | null>\n /** Must check current tenant membership, plugin activation and resource permissions. */\n authorize: (identity: ExecutionIdentity, pluginId: string, action: string, payload: unknown) => Promise<boolean>\n /**\n * Fixed pluginId:action handlers shallow-copied at creation; each receives admitted identity and parsed JSON and resolves JSON-serializable output.\n */\n operations: Record<string, (identity: ExecutionIdentity, payload: unknown) => Promise<unknown>>\n /**\n * Positive safe-integer request body limit in bytes, enforced while reading; defaults to 1048576.\n */\n maxBodyBytes?: number\n /**\n * Optional exact Origin allowlist; any present Origin is denied unless included, while an absent Origin skips this check.\n */\n allowedOrigins?: string[]\n}) {\n const router = new Hono(), operations = { ...options.operations }, maxBytes = options.maxBodyBytes ?? 1_048_576\n if (!Number.isSafeInteger(maxBytes) || maxBytes < 1) throw new Error('Invalid request limit')\n router.post('/:pluginId/:action', async c => {\n c.header('Cache-Control', 'no-store')\n try {\n if (c.req.header('Content-Type')?.split(';')[0].trim().toLowerCase() !== 'application/json') return c.json({ error: 'JSON required' }, 415)\n const origin = c.req.header('Origin')\n if (origin && !options.allowedOrigins?.includes(origin)) return c.json({ error: 'Origin denied' }, 403)\n const identity = await options.resolveIdentity(c)\n if (!identity?.tenantId?.trim() || !identity.userId?.trim()) return c.json({ error: 'Authentication required' }, 401)\n const { pluginId, action } = c.req.param()\n if (!/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(pluginId) || !/^[a-zA-Z0-9_-]+$/.test(action) || !Object.hasOwn(operations, `${pluginId}:${action}`)) return c.json({ error: 'Unknown operation' }, 404)\n const reader = c.req.raw.body?.getReader(); const chunks: Uint8Array[] = []; let size = 0\n if (reader) try {\n while (true) { const { done, value } = await reader.read(); if (done) break; size += value.length; if (size > maxBytes) { await reader.cancel(); return c.json({ error: 'Request too large' }, 413) }; chunks.push(value) }\n } finally { reader.releaseLock() }\n const bytes = new Uint8Array(size); let offset = 0\n for (const chunk of chunks) { bytes.set(chunk, offset); offset += chunk.length }\n let payload: unknown\n try { payload = JSON.parse(new TextDecoder().decode(bytes)) } catch { return c.json({ error: 'Invalid JSON' }, 400) }\n if (!await options.authorize(identity, pluginId, action, payload)) return c.json({ error: 'Execution denied' }, 403)\n return c.json(await operations[`${pluginId}:${action}`](identity, payload))\n } catch { return c.json({ error: 'Execution unavailable' }, 503) }\n })\n return router\n}\n"],"mappings":";AAAA,SAAS,YAA0B;AAyB5B,SAAS,4BAA4B,SAmBzC;AACD,QAAM,SAAS,IAAI,KAAK,GAAG,aAAa,EAAE,GAAG,QAAQ,WAAW,GAAG,WAAW,QAAQ,gBAAgB;AACtG,MAAI,CAAC,OAAO,cAAc,QAAQ,KAAK,WAAW,EAAG,OAAM,IAAI,MAAM,uBAAuB;AAC5F,SAAO,KAAK,sBAAsB,OAAM,MAAK;AAC3C,MAAE,OAAO,iBAAiB,UAAU;AACpC,QAAI;AACF,UAAI,EAAE,IAAI,OAAO,cAAc,GAAG,MAAM,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,YAAY,MAAM,mBAAoB,QAAO,EAAE,KAAK,EAAE,OAAO,gBAAgB,GAAG,GAAG;AAC1I,YAAM,SAAS,EAAE,IAAI,OAAO,QAAQ;AACpC,UAAI,UAAU,CAAC,QAAQ,gBAAgB,SAAS,MAAM,EAAG,QAAO,EAAE,KAAK,EAAE,OAAO,gBAAgB,GAAG,GAAG;AACtG,YAAM,WAAW,MAAM,QAAQ,gBAAgB,CAAC;AAChD,UAAI,CAAC,UAAU,UAAU,KAAK,KAAK,CAAC,SAAS,QAAQ,KAAK,EAAG,QAAO,EAAE,KAAK,EAAE,OAAO,0BAA0B,GAAG,GAAG;AACpH,YAAM,EAAE,UAAU,OAAO,IAAI,EAAE,IAAI,MAAM;AACzC,UAAI,CAAC,6BAA6B,KAAK,QAAQ,KAAK,CAAC,mBAAmB,KAAK,MAAM,KAAK,CAAC,OAAO,OAAO,YAAY,GAAG,QAAQ,IAAI,MAAM,EAAE,EAAG,QAAO,EAAE,KAAK,EAAE,OAAO,oBAAoB,GAAG,GAAG;AAC9L,YAAM,SAAS,EAAE,IAAI,IAAI,MAAM,UAAU;AAAG,YAAM,SAAuB,CAAC;AAAG,UAAI,OAAO;AACxF,UAAI,OAAQ,KAAI;AACd,eAAO,MAAM;AAAE,gBAAM,EAAE,MAAM,MAAM,IAAI,MAAM,OAAO,KAAK;AAAG,cAAI,KAAM;AAAO,kBAAQ,MAAM;AAAQ,cAAI,OAAO,UAAU;AAAE,kBAAM,OAAO,OAAO;AAAG,mBAAO,EAAE,KAAK,EAAE,OAAO,oBAAoB,GAAG,GAAG;AAAA,UAAE;AAAC;AAAE,iBAAO,KAAK,KAAK;AAAA,QAAE;AAAA,MAC5N,UAAE;AAAU,eAAO,YAAY;AAAA,MAAE;AACjC,YAAM,QAAQ,IAAI,WAAW,IAAI;AAAG,UAAI,SAAS;AACjD,iBAAW,SAAS,QAAQ;AAAE,cAAM,IAAI,OAAO,MAAM;AAAG,kBAAU,MAAM;AAAA,MAAO;AAC/E,UAAI;AACJ,UAAI;AAAE,kBAAU,KAAK,MAAM,IAAI,YAAY,EAAE,OAAO,KAAK,CAAC;AAAA,MAAE,QAAQ;AAAE,eAAO,EAAE,KAAK,EAAE,OAAO,eAAe,GAAG,GAAG;AAAA,MAAE;AACpH,UAAI,CAAC,MAAM,QAAQ,UAAU,UAAU,UAAU,QAAQ,OAAO,EAAG,QAAO,EAAE,KAAK,EAAE,OAAO,mBAAmB,GAAG,GAAG;AACnH,aAAO,EAAE,KAAK,MAAM,WAAW,GAAG,QAAQ,IAAI,MAAM,EAAE,EAAE,UAAU,OAAO,CAAC;AAAA,IAC5E,QAAQ;AAAE,aAAO,EAAE,KAAK,EAAE,OAAO,wBAAwB,GAAG,GAAG;AAAA,IAAE;AAAA,EACnE,CAAC;AACD,SAAO;AACT;","names":[]}
@@ -0,0 +1,172 @@
1
+ import { Hono, Context, MiddlewareHandler } from 'hono';
2
+ import { PluginManifest } from '@alneas/eaos-core';
3
+ import { PlatformContribution } from '@alneas/eaos-server/platform';
4
+
5
+ /**
6
+ * Plugin-manifest route factory supplied by trusted deployment composition.
7
+ * @see PlatformExtension.
8
+ */
9
+ type HostRouteFactory = NonNullable<PluginManifest['createRoutes']>;
10
+ /**
11
+ * Adds host route composition to a trusted platform contribution with explicit tenant scope.
12
+ * @remarks Never populate this object from request input.
13
+ * @see validateExtensions for a complete composition example.
14
+ */
15
+ interface PlatformExtension extends PlatformContribution {
16
+ /** Plugin-ID factories for every contributed manifest; may not override plugins absent from this contribution. */
17
+ routeFactories?: Record<string, HostRouteFactory>;
18
+ /** Optional host API routes with an absolute, wildcard-free prefix, nonblank moduleId, and Hono router. */
19
+ routes?: Array<{
20
+ /** Absolute wildcard-free mount prefix; overlapping tenant contributions may not claim the same prefix. */
21
+ prefix: string;
22
+ /** Nonblank module identity passed to the host requireModule factory after the extension tenant-scope check. */
23
+ moduleId: string;
24
+ /** Trusted Hono child router wrapped with tenant-scope and live host module middleware during extension composition. */
25
+ router: Hono;
26
+ }>;
27
+ /** Optional request context resolver; contributions using it may not overlap tenant scope. Its result/authorization semantics belong to the host. */
28
+ userContext?: (context: Context) => Promise<unknown>;
29
+ }
30
+ /**
31
+ * Checks trusted extension shapes, IDs, route factories, and conflicting tenant/user-context contributions.
32
+ * @param values - Deployment module values to validate; request input must not supply implementations.
33
+ * @returns A new array containing the original validated objects; no deep clone or sandboxing occurs.
34
+ * @throws For invalid version/ID/explicit tenant scopes, duplicate extension/plugin IDs, overlapping userContext tenant scopes, invalid routes, or missing/unauthorized route factories.
35
+ * @remarks Independent plugins can share tenants. This validates composition constraints, not manifest internals or implementation safety.
36
+ * @example
37
+ * ```typescript
38
+ * import { validateExtensions } from "@alneas/eaos-server/extensions";
39
+ * const extensions = validateExtensions([{ apiVersion: 1, id: "example", tenantIds: ["example"] }]);
40
+ * console.log(extensions.length); // 1
41
+ * ```
42
+ */
43
+ declare function validateExtensions(values: unknown[]): PlatformExtension[];
44
+ /**
45
+ * Wraps each contributed plugin route factory with an explicit tenant-scope middleware.
46
+ * @param item - Trusted validated extension; tenantIds is consulted at request time.
47
+ * @returns A shallow copy with fresh route factory wrappers; each wrapper invokes the original factory with unchanged arguments.
48
+ * @throws Calling a wrapped factory propagates the original route-factory errors.
49
+ * @remarks Set trusted tenantId context before handling requests. Out-of-scope or missing tenantId returns 403. This wrapper performs no membership or module authorization.
50
+ * @example
51
+ * ```typescript
52
+ * import { scopeExtensionFactories, validateExtensions } from "@alneas/eaos-server/extensions";
53
+ * const [extension] = validateExtensions([{ apiVersion: 1, id: "example", tenantIds: ["example"] }]);
54
+ * const scoped = scopeExtensionFactories(extension);
55
+ * console.log(scoped.id);
56
+ * ```
57
+ */
58
+ declare function scopeExtensionFactories(item: PlatformExtension): PlatformExtension;
59
+ /**
60
+ * Wraps contributed host routers with tenant-scope checks followed by host module authorization.
61
+ * @param extension - Trusted validated contribution; omitted routes produce an empty array.
62
+ * @param requireModule - Called once per route with moduleId during composition; returns middleware enforcing current module permissions.
63
+ * @returns New prefix/router pairs preserving original route order and mounting original routers beneath their guards.
64
+ * @throws Propagates module middleware factory or route composition errors; request execution propagates downstream failures.
65
+ * @remarks Requires a verified tenantId in Hono context. No authentication is installed here.
66
+ * @example
67
+ * ```typescript
68
+ * import { scopeExtensionRoutes, validateExtensions } from "@alneas/eaos-server/extensions";
69
+ * import { createModuleGuard } from "@alneas/eaos-server/middleware/module-guard";
70
+ * const [extension] = validateExtensions([{ apiVersion: 1, id: "example", tenantIds: ["example"] }]);
71
+ * console.log(scopeExtensionRoutes(extension, id => createModuleGuard(id, { isDev: false }))); // []
72
+ * ```
73
+ */
74
+ declare function scopeExtensionRoutes(extension: PlatformExtension, requireModule: (moduleId: string) => MiddlewareHandler): Array<{
75
+ /**
76
+ * Original host route prefix preserved for subsequent mounting.
77
+ */
78
+ prefix: string;
79
+ /**
80
+ * Fresh Hono wrapper enforcing tenant scope and host module authorization before forwarding to the original router.
81
+ */
82
+ router: Hono;
83
+ }>;
84
+ /**
85
+ * Mounts tenant-dispatched extension routes, allowing a shared prefix across disjoint tenant scopes.
86
+ * @param app - Host Hono app mutated with exact-prefix and descendant dispatch routes.
87
+ * @param extensions - Trusted validated extensions with explicit tenant IDs.
88
+ * @param requireModule - Host factory producing current module authorization middleware for each route moduleId.
89
+ * @returns No value; completes after mounting all route groups.
90
+ * @throws For an overlapping tenant at the same prefix, or propagated route/middleware composition errors.
91
+ * @remarks Install verified identity/tenant middleware before these routes. Dispatch copies parent context variables into the selected child and forwards server environment; missing tenant scope returns 403. There is no automatic route unmount or per-request persistence.
92
+ * @example
93
+ * ```typescript
94
+ * import { Hono } from "hono";
95
+ * import { mountExtensionRoutes, type PlatformExtension } from "@alneas/eaos-server/extensions";
96
+ * import { createModuleGuard } from "@alneas/eaos-server/middleware/module-guard";
97
+ * export function mount(app: Hono, extensions: PlatformExtension[]) {
98
+ * mountExtensionRoutes(app, extensions, id => createModuleGuard(id, { isDev: false }));
99
+ * }
100
+ * ```
101
+ */
102
+ declare function mountExtensionRoutes(app: Hono, extensions: PlatformExtension[], requireModule: (id: string) => MiddlewareHandler): void;
103
+ /** Request-scoped host authorization supplied after verified membership middleware.
104
+ * @see getPlatformPluginAuthorization for binding lookup and a usage example.
105
+ */
106
+ interface PlatformPluginAuthorization {
107
+ /**
108
+ * Resolves the current verified principal after host authentication/membership checks.
109
+ * @returns Tenant/user identity, verified roles, and current enabled plugin IDs, or null to deny.
110
+ * @throws Host authentication or persistence failures propagate to callers.
111
+
112
+ * @example
113
+ * ```typescript
114
+ * import type { PlatformPluginAuthorization } from "@alneas/eaos-server/extensions";
115
+ * export async function readHostPrincipal(authorization: PlatformPluginAuthorization) {
116
+ * const principal = await authorization.resolvePrincipal();
117
+ * return principal; // Null denies access; never replace it with request-supplied claims.
118
+ * }
119
+ * ```
120
+ */
121
+ resolvePrincipal(): Promise<{
122
+ /** Tenant identity established by trusted host authentication/membership resolution; request-supplied headers/body must not define this claim. */
123
+ tenantId: string;
124
+ /** Authenticated user identity within the resolved tenant scope. */
125
+ userId: string;
126
+ /** Verified host role claims used for downstream authorization; tenant roles must not fabricate platform authority. */
127
+ roles: string[];
128
+ /** Current plugin activation identities visible to this verified principal; the host supplies live lifecycle data. */
129
+ enabledPluginIds: string[];
130
+ } | null>;
131
+ /**
132
+ * Checks live plugin activation for a verified tenant.
133
+ * @param tenantId - Verified tenant ID.
134
+ * @param pluginId - Exact installed plugin ID.
135
+ * @returns True only when the plugin is currently enabled for this tenant.
136
+ * @throws Host lifecycle/persistence failures propagate to callers.
137
+
138
+ * @example
139
+ * ```typescript
140
+ * import type { PlatformPluginAuthorization } from "@alneas/eaos-server/extensions";
141
+ * export async function checkCurrentPlugin(
142
+ * authorization: PlatformPluginAuthorization, verifiedTenantId: string, installedPluginId: string,
143
+ * ) {
144
+ * return await authorization.isPluginEnabled(verifiedTenantId, installedPluginId);
145
+ * }
146
+ * ```
147
+ */
148
+ isPluginEnabled(tenantId: string, pluginId: string): Promise<boolean>;
149
+ }
150
+ /**
151
+ * Hono variable/environment key for the host-only {@link PlatformPluginAuthorization} binding.
152
+ * @see getPlatformPluginAuthorization for access behavior.
153
+ */
154
+ declare const PLATFORM_PLUGIN_AUTHORIZATION = "eaosPlatformPluginAuthorization";
155
+ /**
156
+ * Reads a structurally valid host authorization port from Hono context or server environment.
157
+ * @param context - Hono-like context; get(bindingKey) takes precedence over env[bindingKey] when nonnull. Missing contexts return undefined.
158
+ * @returns The original port when both required members are functions, or undefined otherwise.
159
+ * @throws Propagates errors thrown by the context get accessor.
160
+ * @remarks Hono environment forwarding is internal-only; HTTP headers never supply this binding. Structural validation does not establish trust: only host middleware may install it.
161
+ * @example
162
+ * ```typescript
163
+ * import { Hono } from "hono";
164
+ * import { getPlatformPluginAuthorization } from "@alneas/eaos-server/extensions";
165
+ * const app = new Hono();
166
+ * app.get("/authorization-state", c => c.json({ configured: !!getPlatformPluginAuthorization(c) }));
167
+ * ```
168
+ */
169
+ declare function getPlatformPluginAuthorization(context: unknown): PlatformPluginAuthorization | undefined;
170
+
171
+ export { PLATFORM_PLUGIN_AUTHORIZATION, getPlatformPluginAuthorization, mountExtensionRoutes, scopeExtensionFactories, scopeExtensionRoutes, validateExtensions };
172
+ export type { HostRouteFactory, PlatformExtension, PlatformPluginAuthorization };
@@ -0,0 +1,95 @@
1
+ // src/extensions/index.ts
2
+ import { Hono } from "hono";
3
+ function validateExtensions(values) {
4
+ const ids = /* @__PURE__ */ new Set();
5
+ const plugins = /* @__PURE__ */ new Set();
6
+ const tenants = /* @__PURE__ */ new Set();
7
+ return values.map((value) => {
8
+ const item = value;
9
+ if (!item || item.apiVersion !== 1 || typeof item.id !== "string" || !item.id.trim() || !Array.isArray(item.tenantIds) || !item.tenantIds.length || item.tenantIds.some((id) => typeof id !== "string" || !id.trim() || id !== id.trim() || id === "*") || item.manifests !== void 0 && !Array.isArray(item.manifests) || item.lifecycle !== void 0 && !Array.isArray(item.lifecycle) || item.routes !== void 0 && !Array.isArray(item.routes)) {
10
+ throw new Error("Invalid platform extension: version, id and explicit tenantIds are required");
11
+ }
12
+ if (ids.has(item.id)) throw new Error(`Duplicate extension: ${item.id}`);
13
+ ids.add(item.id);
14
+ for (const tenant of item.userContext ? item.tenantIds : []) {
15
+ if (tenants.has(tenant)) throw new Error(`Conflicting extension tenant: ${tenant}`);
16
+ tenants.add(tenant);
17
+ }
18
+ for (const route of item.routes ?? []) {
19
+ if (typeof route.prefix !== "string" || !route.prefix.startsWith("/") || route.prefix.includes("*") || typeof route.moduleId !== "string" || !route.moduleId.trim() || typeof route.router?.fetch !== "function") throw new Error("Invalid extension route");
20
+ }
21
+ for (const manifest of item.manifests ?? []) {
22
+ if (plugins.has(manifest.id)) throw new Error(`Duplicate extension plugin: ${manifest.id}`);
23
+ plugins.add(manifest.id);
24
+ if (typeof item.routeFactories?.[manifest.id] !== "function") throw new Error(`Extension route factory required: ${manifest.id}`);
25
+ }
26
+ for (const id of Object.keys(item.routeFactories ?? {})) {
27
+ if (!(item.manifests ?? []).some((manifest) => manifest.id === id)) throw new Error(`Extension cannot override an official route factory: ${id}`);
28
+ }
29
+ return item;
30
+ });
31
+ }
32
+ function scopeExtensionFactories(item) {
33
+ return { ...item, routeFactories: Object.fromEntries(Object.entries(item.routeFactories ?? {}).map(([id, factory]) => [id, (...args) => {
34
+ const router = new Hono();
35
+ router.use("*", async (context, next) => {
36
+ if (!item.tenantIds.includes(String(context.get("tenantId") ?? ""))) return context.json({ error: "Tenant unavailable" }, 403);
37
+ return next();
38
+ });
39
+ return router.route("/", factory(...args));
40
+ }])) };
41
+ }
42
+ function scopeExtensionRoutes(extension, requireModule) {
43
+ return (extension.routes ?? []).map((route) => {
44
+ const router = new Hono();
45
+ router.use("*", async (context, next) => {
46
+ if (!extension.tenantIds.includes(String(context.get("tenantId") ?? ""))) return context.json({ error: "Tenant unavailable" }, 403);
47
+ return next();
48
+ });
49
+ router.use("*", requireModule(route.moduleId));
50
+ router.route("/", route.router);
51
+ return { prefix: route.prefix, router };
52
+ });
53
+ }
54
+ function mountExtensionRoutes(app, extensions, requireModule) {
55
+ const groups = /* @__PURE__ */ new Map();
56
+ for (const extension of extensions) for (const route of scopeExtensionRoutes(extension, requireModule)) {
57
+ const group = groups.get(route.prefix) ?? [];
58
+ if (group.some((item) => item.tenantIds.some((tenant) => extension.tenantIds.includes(tenant)))) throw new Error("Conflicting extension API prefix for tenant");
59
+ group.push({ tenantIds: extension.tenantIds, router: route.router });
60
+ groups.set(route.prefix, group);
61
+ }
62
+ for (const [prefix, candidates] of groups) {
63
+ const dispatch = async (context) => {
64
+ const tenantId = String(context.get("tenantId") ?? "");
65
+ const selected = candidates.find((item) => item.tenantIds.includes(tenantId));
66
+ if (!selected) return context.json({ error: "Tenant unavailable" }, 403);
67
+ const child = new Hono();
68
+ child.use("*", async (nested, next) => {
69
+ for (const [key, value] of Object.entries(context.var)) nested.set(key, value);
70
+ return next();
71
+ });
72
+ child.route(prefix, selected.router);
73
+ return child.fetch(context.req.raw, context.env);
74
+ };
75
+ app.all(prefix, dispatch);
76
+ app.all(prefix.replace(/\/$/, "") + "/*", dispatch);
77
+ }
78
+ }
79
+ var PLATFORM_PLUGIN_AUTHORIZATION = "eaosPlatformPluginAuthorization";
80
+ function getPlatformPluginAuthorization(context) {
81
+ const c = context;
82
+ const binding = c?.get?.(PLATFORM_PLUGIN_AUTHORIZATION) ?? c?.env?.[PLATFORM_PLUGIN_AUTHORIZATION];
83
+ if (!binding || typeof binding !== "object") return void 0;
84
+ const port = binding;
85
+ return typeof port.resolvePrincipal === "function" && typeof port.isPluginEnabled === "function" ? port : void 0;
86
+ }
87
+ export {
88
+ PLATFORM_PLUGIN_AUTHORIZATION,
89
+ getPlatformPluginAuthorization,
90
+ mountExtensionRoutes,
91
+ scopeExtensionFactories,
92
+ scopeExtensionRoutes,
93
+ validateExtensions
94
+ };
95
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/extensions/index.ts"],"sourcesContent":["import { Hono, type Context, type MiddlewareHandler } from 'hono'\nimport type { PluginManifest } from '@alneas/eaos-core'\nimport type { PlatformContribution } from '@alneas/eaos-server/platform'\n/**\n * Plugin-manifest route factory supplied by trusted deployment composition.\n * @see PlatformExtension.\n */\nexport type HostRouteFactory = NonNullable<PluginManifest['createRoutes']>\n\n/**\n * Adds host route composition to a trusted platform contribution with explicit tenant scope.\n * @remarks Never populate this object from request input.\n * @see validateExtensions for a complete composition example.\n */\nexport interface PlatformExtension extends PlatformContribution {\n /** Plugin-ID factories for every contributed manifest; may not override plugins absent from this contribution. */\n routeFactories?: Record<string, HostRouteFactory>\n /** Optional host API routes with an absolute, wildcard-free prefix, nonblank moduleId, and Hono router. */\n routes?: Array<{\n /** Absolute wildcard-free mount prefix; overlapping tenant contributions may not claim the same prefix. */\n prefix: string\n /** Nonblank module identity passed to the host requireModule factory after the extension tenant-scope check. */\n moduleId: string\n /** Trusted Hono child router wrapped with tenant-scope and live host module middleware during extension composition. */\n router: Hono\n }>\n /** Optional request context resolver; contributions using it may not overlap tenant scope. Its result/authorization semantics belong to the host. */\n userContext?: (context: Context) => Promise<unknown>\n}\n\n/**\n * Checks trusted extension shapes, IDs, route factories, and conflicting tenant/user-context contributions.\n * @param values - Deployment module values to validate; request input must not supply implementations.\n * @returns A new array containing the original validated objects; no deep clone or sandboxing occurs.\n * @throws For invalid version/ID/explicit tenant scopes, duplicate extension/plugin IDs, overlapping userContext tenant scopes, invalid routes, or missing/unauthorized route factories.\n * @remarks Independent plugins can share tenants. This validates composition constraints, not manifest internals or implementation safety.\n * @example\n * ```typescript\n * import { validateExtensions } from \"@alneas/eaos-server/extensions\";\n * const extensions = validateExtensions([{ apiVersion: 1, id: \"example\", tenantIds: [\"example\"] }]);\n * console.log(extensions.length); // 1\n * ```\n */\nexport function validateExtensions(values: unknown[]): PlatformExtension[] {\n const ids = new Set<string>()\n const plugins = new Set<string>()\n const tenants = new Set<string>()\n return values.map(value => {\n const item = value as PlatformExtension\n if (!item || item.apiVersion !== 1 || typeof item.id !== 'string' || !item.id.trim()\n || !Array.isArray(item.tenantIds) || !item.tenantIds.length\n || item.tenantIds.some(id => typeof id !== 'string' || !id.trim() || id !== id.trim() || id === '*')\n || (item.manifests !== undefined && !Array.isArray(item.manifests))\n || (item.lifecycle !== undefined && !Array.isArray(item.lifecycle))\n || (item.routes !== undefined && !Array.isArray(item.routes))) {\n throw new Error('Invalid platform extension: version, id and explicit tenantIds are required')\n }\n if (ids.has(item.id)) throw new Error(`Duplicate extension: ${item.id}`)\n ids.add(item.id)\n // Product identity overrides must remain unambiguous; independent plugins may share tenants.\n for (const tenant of item.userContext ? item.tenantIds : []) {\n if (tenants.has(tenant)) throw new Error(`Conflicting extension tenant: ${tenant}`)\n tenants.add(tenant)\n }\n for (const route of item.routes ?? []) {\n if (typeof route.prefix !== 'string' || !route.prefix.startsWith('/') || route.prefix.includes('*') || typeof route.moduleId !== 'string' || !route.moduleId.trim() || typeof route.router?.fetch !== 'function') throw new Error('Invalid extension route')\n }\n for (const manifest of item.manifests ?? []) {\n if (plugins.has(manifest.id)) throw new Error(`Duplicate extension plugin: ${manifest.id}`)\n plugins.add(manifest.id)\n if (typeof item.routeFactories?.[manifest.id] !== 'function') throw new Error(`Extension route factory required: ${manifest.id}`)\n }\n for (const id of Object.keys(item.routeFactories ?? {})) {\n if (!(item.manifests ?? []).some(manifest => manifest.id === id)) throw new Error(`Extension cannot override an official route factory: ${id}`)\n }\n return item\n })\n}\n\n/**\n * Wraps each contributed plugin route factory with an explicit tenant-scope middleware.\n * @param item - Trusted validated extension; tenantIds is consulted at request time.\n * @returns A shallow copy with fresh route factory wrappers; each wrapper invokes the original factory with unchanged arguments.\n * @throws Calling a wrapped factory propagates the original route-factory errors.\n * @remarks Set trusted tenantId context before handling requests. Out-of-scope or missing tenantId returns 403. This wrapper performs no membership or module authorization.\n * @example\n * ```typescript\n * import { scopeExtensionFactories, validateExtensions } from \"@alneas/eaos-server/extensions\";\n * const [extension] = validateExtensions([{ apiVersion: 1, id: \"example\", tenantIds: [\"example\"] }]);\n * const scoped = scopeExtensionFactories(extension);\n * console.log(scoped.id);\n * ```\n */\nexport function scopeExtensionFactories(item: PlatformExtension): PlatformExtension {\n return { ...item, routeFactories: Object.fromEntries(Object.entries(item.routeFactories ?? {}).map(([id, factory]) => [id, (...args: Parameters<HostRouteFactory>) => {\n const router = new Hono()\n router.use('*', async (context: Context, next) => {\n if (!item.tenantIds.includes(String(context.get('tenantId') ?? ''))) return context.json({ error: 'Tenant unavailable' }, 403)\n return next()\n })\n return router.route('/', factory(...args))\n }])) }\n}\n\n/**\n * Wraps contributed host routers with tenant-scope checks followed by host module authorization.\n * @param extension - Trusted validated contribution; omitted routes produce an empty array.\n * @param requireModule - Called once per route with moduleId during composition; returns middleware enforcing current module permissions.\n * @returns New prefix/router pairs preserving original route order and mounting original routers beneath their guards.\n * @throws Propagates module middleware factory or route composition errors; request execution propagates downstream failures.\n * @remarks Requires a verified tenantId in Hono context. No authentication is installed here.\n * @example\n * ```typescript\n * import { scopeExtensionRoutes, validateExtensions } from \"@alneas/eaos-server/extensions\";\n * import { createModuleGuard } from \"@alneas/eaos-server/middleware/module-guard\";\n * const [extension] = validateExtensions([{ apiVersion: 1, id: \"example\", tenantIds: [\"example\"] }]);\n * console.log(scopeExtensionRoutes(extension, id => createModuleGuard(id, { isDev: false }))); // []\n * ```\n */\nexport function scopeExtensionRoutes(\n extension: PlatformExtension,\n requireModule: (moduleId: string) => MiddlewareHandler,\n): Array<{\n /**\n * Original host route prefix preserved for subsequent mounting.\n */\nprefix: string;\n /**\n * Fresh Hono wrapper enforcing tenant scope and host module authorization before forwarding to the original router.\n */\nrouter: Hono }> {\n return (extension.routes ?? []).map(route => {\n const router = new Hono()\n router.use('*', async (context: Context, next) => {\n if (!extension.tenantIds.includes(String(context.get('tenantId') ?? ''))) return context.json({ error: 'Tenant unavailable' }, 403)\n return next()\n })\n router.use('*', requireModule(route.moduleId))\n router.route('/', route.router)\n return { prefix: route.prefix, router }\n })\n}\n\n\n/**\n * Mounts tenant-dispatched extension routes, allowing a shared prefix across disjoint tenant scopes.\n * @param app - Host Hono app mutated with exact-prefix and descendant dispatch routes.\n * @param extensions - Trusted validated extensions with explicit tenant IDs.\n * @param requireModule - Host factory producing current module authorization middleware for each route moduleId.\n * @returns No value; completes after mounting all route groups.\n * @throws For an overlapping tenant at the same prefix, or propagated route/middleware composition errors.\n * @remarks Install verified identity/tenant middleware before these routes. Dispatch copies parent context variables into the selected child and forwards server environment; missing tenant scope returns 403. There is no automatic route unmount or per-request persistence.\n * @example\n * ```typescript\n * import { Hono } from \"hono\";\n * import { mountExtensionRoutes, type PlatformExtension } from \"@alneas/eaos-server/extensions\";\n * import { createModuleGuard } from \"@alneas/eaos-server/middleware/module-guard\";\n * export function mount(app: Hono, extensions: PlatformExtension[]) {\n * mountExtensionRoutes(app, extensions, id => createModuleGuard(id, { isDev: false }));\n * }\n * ```\n */\nexport function mountExtensionRoutes(app: Hono, extensions: PlatformExtension[], requireModule: (id: string) => MiddlewareHandler): void {\n const groups = new Map<string, Array<{ tenantIds: string[]; router: Hono }>>()\n for (const extension of extensions) for (const route of scopeExtensionRoutes(extension, requireModule)) {\n const group = groups.get(route.prefix) ?? []\n if (group.some(item => item.tenantIds.some(tenant => extension.tenantIds.includes(tenant)))) throw new Error('Conflicting extension API prefix for tenant')\n group.push({ tenantIds: extension.tenantIds, router: route.router })\n groups.set(route.prefix, group)\n }\n for (const [prefix, candidates] of groups) {\n const dispatch: MiddlewareHandler = async context => {\n const tenantId = String(context.get('tenantId') ?? '')\n const selected = candidates.find(item => item.tenantIds.includes(tenantId))\n if (!selected) return context.json({ error: 'Tenant unavailable' }, 403)\n const child = new Hono<{ Variables: Record<string, unknown> }>()\n child.use('*', async (nested, next) => {\n // Preserve verified parent state without putting it in client-controlled headers/body.\n for (const [key, value] of Object.entries(context.var)) nested.set(key, value)\n return next()\n })\n child.route(prefix, selected.router)\n return child.fetch(context.req.raw, context.env)\n }\n app.all(prefix, dispatch)\n app.all(prefix.replace(/\\/$/, '') + '/*', dispatch)\n }\n}\n\n/** Request-scoped host authorization supplied after verified membership middleware.\n * @see getPlatformPluginAuthorization for binding lookup and a usage example.\n */\nexport interface PlatformPluginAuthorization {\n /**\n * Resolves the current verified principal after host authentication/membership checks.\n * @returns Tenant/user identity, verified roles, and current enabled plugin IDs, or null to deny.\n * @throws Host authentication or persistence failures propagate to callers.\n \n * @example\n * ```typescript\n * import type { PlatformPluginAuthorization } from \"@alneas/eaos-server/extensions\";\n * export async function readHostPrincipal(authorization: PlatformPluginAuthorization) {\n * const principal = await authorization.resolvePrincipal();\n * return principal; // Null denies access; never replace it with request-supplied claims.\n * }\n * ```\n */\n resolvePrincipal(): Promise<{ \n /** Tenant identity established by trusted host authentication/membership resolution; request-supplied headers/body must not define this claim. */\n tenantId: string; \n /** Authenticated user identity within the resolved tenant scope. */\n userId: string; \n /** Verified host role claims used for downstream authorization; tenant roles must not fabricate platform authority. */\n roles: string[]; \n /** Current plugin activation identities visible to this verified principal; the host supplies live lifecycle data. */\n enabledPluginIds: string[] } | null>\n /**\n * Checks live plugin activation for a verified tenant.\n * @param tenantId - Verified tenant ID.\n * @param pluginId - Exact installed plugin ID.\n * @returns True only when the plugin is currently enabled for this tenant.\n * @throws Host lifecycle/persistence failures propagate to callers.\n \n * @example\n * ```typescript\n * import type { PlatformPluginAuthorization } from \"@alneas/eaos-server/extensions\";\n * export async function checkCurrentPlugin(\n * authorization: PlatformPluginAuthorization, verifiedTenantId: string, installedPluginId: string,\n * ) {\n * return await authorization.isPluginEnabled(verifiedTenantId, installedPluginId);\n * }\n * ```\n */\n isPluginEnabled(tenantId: string, pluginId: string): Promise<boolean>\n}\n/**\n * Hono variable/environment key for the host-only {@link PlatformPluginAuthorization} binding.\n * @see getPlatformPluginAuthorization for access behavior.\n */\nexport const PLATFORM_PLUGIN_AUTHORIZATION = 'eaosPlatformPluginAuthorization'\n\n/**\n * Reads a structurally valid host authorization port from Hono context or server environment.\n * @param context - Hono-like context; get(bindingKey) takes precedence over env[bindingKey] when nonnull. Missing contexts return undefined.\n * @returns The original port when both required members are functions, or undefined otherwise.\n * @throws Propagates errors thrown by the context get accessor.\n * @remarks Hono environment forwarding is internal-only; HTTP headers never supply this binding. Structural validation does not establish trust: only host middleware may install it.\n * @example\n * ```typescript\n * import { Hono } from \"hono\";\n * import { getPlatformPluginAuthorization } from \"@alneas/eaos-server/extensions\";\n * const app = new Hono();\n * app.get(\"/authorization-state\", c => c.json({ configured: !!getPlatformPluginAuthorization(c) }));\n * ```\n */\nexport function getPlatformPluginAuthorization(context: unknown): PlatformPluginAuthorization | undefined {\n const c = context as { get?: (key: string) => unknown; env?: Record<string, unknown> } | undefined\n const binding = c?.get?.(PLATFORM_PLUGIN_AUTHORIZATION) ?? c?.env?.[PLATFORM_PLUGIN_AUTHORIZATION]\n if (!binding || typeof binding !== 'object') return undefined\n const port = binding as PlatformPluginAuthorization\n return typeof port.resolvePrincipal === 'function' && typeof port.isPluginEnabled === 'function' ? port : undefined\n}\n"],"mappings":"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","names":[]}
@@ -0,0 +1,35 @@
1
+ import { Hono } from 'hono';
2
+ import { HealthCheck } from '@alneas/eaos-core';
3
+
4
+ /**
5
+ * Host inputs for the unauthenticated liveness and readiness routes.
6
+ * @see createHealthRouter for a complete usage example.
7
+ */
8
+ interface HealthRouterOptions {
9
+ /** Nonblank application label included in every response. */
10
+ appName: string;
11
+ /** Readiness checks run on each readiness request; defaults to no checks. */
12
+ checks?: readonly HealthCheck[];
13
+ /** Clock read separately for each request; defaults to the current Date. */
14
+ now?: () => Date;
15
+ }
16
+ /**
17
+ * Creates public /health, /health/live, and /health/ready routes.
18
+ * @param options - Application label, readiness checks, and optional clock.
19
+ * @returns A new Hono router; liveness returns 200 and readiness returns 503 only for a not_ready report.
20
+ * @throws If appName is missing, not a string, or blank. Request handling may reject if the supplied clock throws.
21
+ * @remarks Check implementations and credentials remain host-owned. These routes install no authentication; mount them where public health status is appropriate. Checks run for every readiness request with no caching by this router.
22
+ * @example
23
+ * ```typescript
24
+ * import { Hono } from "hono";
25
+ * import { createHealthRouter } from "@alneas/eaos-server/health";
26
+ * const app = new Hono();
27
+ * app.route("/", createHealthRouter({ appName: "example-service" }));
28
+ * const response = await app.request("/health/live");
29
+ * console.log(response.status); // 200
30
+ * ```
31
+ */
32
+ declare function createHealthRouter(options: HealthRouterOptions): Hono;
33
+
34
+ export { createHealthRouter };
35
+ export type { HealthRouterOptions };
@@ -0,0 +1,7 @@
1
+ import {
2
+ createHealthRouter
3
+ } from "../chunk-R4ADP2DC.js";
4
+ export {
5
+ createHealthRouter
6
+ };
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,39 @@
1
+ export { ModuleGuardOptions, createModuleGuard } from './middleware/module-guard.js';
2
+ export { AuthMiddlewareOptions, AuthSessionVerifier, createAuthMiddleware } from './middleware/auth.js';
3
+ export { ErrorHandlerOptions, createErrorHandler } from './middleware/error-handler.js';
4
+ export { CreateAppOptions, EaosConfig, ErpEngine, createErpEngine, defineConfig } from './engine.js';
5
+ export { EntitlementError, EntitlementPrincipalResolver, EntitlementRuntimeOptions, PluginEntitlementRuntime, ProtectedPluginAsset, createPluginAssetRouter, createPluginEntitlementGuard, createSqlTenantEntitlementLoader, requiresEntitlementRuntime, resolveEngineEntitlementPrincipal, tenantEntitlementContract } from './entitlements/index.js';
6
+ export { PluginSdkHost, createSdkPluginRouter } from './plugin-sdk.js';
7
+ export { McpPrincipal, McpRouterOptions, McpRuntime, createMcpRouter } from './mcp.js';
8
+ export { TenantResolver, TenantResolverOptions, createTenantResolver } from './tenant.js';
9
+ export { HealthRouterOptions, createHealthRouter } from './health/index.js';
10
+ export { PlatformAdminRouterOptions, createPlatformAdminRouter } from './platform-admin/index.js';
11
+ export { ServerAgentDispatchMode, ServerAgentExecutionContext, ServerAgentExecutionError, ServerAgentExecutor, ServerAgentTaskRequest, ServerAgentTaskResult, ServerAgentWorkerType, ServerApprovalCallbackPayload } from './agentic/types.js';
12
+ export { ServerAutonomousWorker, ServerRuntimeRole, ServerWorkerOptions } from './agentic/autonomous-worker.js';
13
+ export { CommandAgentExecutorOptions, CommandAgentSandboxMode, CommandAgentSandboxOptions, buildSystemdRunArgs, createCommandAgentExecutor, validateAgentRuntimePolicy } from './agentic/executor.js';
14
+ export { ServerWorkflowAgentRunnerOptions, createWorkflowAgentRunner } from './agentic/agent-runner.js';
15
+ export { WorkflowAgentNodeOptions, createWorkflowAgentNode } from './agentic/agent-node.js';
16
+ export { ServerWorkflowManager, ServerWorkflowOptions } from './agentic/workflow-manager.js';
17
+ export { AgentGraphEngine, AgentGraphEngineOptions, AgentGraphState, GraphApprovalDecision, GraphConditionalEdgeOptions, GraphEdgeOptions, GraphNodeHandler, GraphNodeOptions, GraphRouter, GraphSubgraph, GraphSubgraphOptions } from './agentic/graph.js';
18
+ export { AgentJobClaimFilter, AgentJobDispatchResult, AgentJobDispatcherOptions, AgentJobStore, AtomicAgentJobStoreOptions, DurableAgentJobDispatcher, cancelAgentJob, createAgentJob, createAtomicAgentJobStore, enqueueAgentJob } from './agentic/agent-jobs.js';
19
+ export { LocalRunnerIdentity, LocalRunnerJobKind, LocalRunnerPullCoordinator, LocalRunnerPullCoordinatorOptions } from './agentic/local-runner.js';
20
+ export { AIJobPlan, AIJobSubmission, AIJobTaskInput, DurableAIExecutionBroker, ServerAIExecutionRoute } from './agentic/ai-broker.js';
21
+ export { GraphProjectionCoordinator, GraphProjectionCoordinatorOptions, ProjectionCursorStore } from './agentic/graph-projection.js';
22
+ export { DurableWorkflowCoordinator, DurableWorkflowCoordinatorOptions, StoredWorkflowInstance, WorkflowInstanceStore } from './agentic/workflow-coordinator.js';
23
+ export { EventAgentBridge, EventAgentBridgeError, EventAgentBridgeOptions, EventAgentPendingApproval, EventAgentRule, EventAgentTaskStore, InMemoryEventAgentTaskStore, QueuedEventTask } from './agentic/event-bridge.js';
24
+ export { HttpAgentExecutorOptions, HttpAgentRuntimeRequest, HttpAgentRuntimeResponse, createHttpAgentExecutor } from './agentic/remote-executor.js';
25
+ export { WorkflowNodeCatalog, WorkflowNodeDescriptor, WorkflowNodeRegistration, WorkflowNodeResolverInput } from './agentic/workflow-catalog.js';
26
+ export { CompiledWorkflow, WorkflowCompilerOptions, compileWorkflowDefinition } from './agentic/workflow-compiler.js';
27
+ export { InMemoryWorkflowDefinitionRegistry, WorkflowDefinitionRecord, WorkflowDefinitionRegistry } from './agentic/workflow-registry.js';
28
+ export { WorkspaceContext, WorkspaceContextError, WorkspaceContextStore, WorkspaceIdentity, createWorkspaceContextResolver } from './workspace-context.js';
29
+ export { AtomicCheckpointSaver } from './agentic/atomic-checkpointer.js';
30
+ import 'hono';
31
+ import '@alneas/eaos-core';
32
+ import './lifecycle/index.js';
33
+ import '@alneas/eaos-server/lifecycle-engine';
34
+ import 'hono/types';
35
+ import './plugin-data/index.js';
36
+ import '@alneas/eaos-core/plugin-sdk';
37
+ import '@alneas/eaos-server/platform';
38
+ import './platform-admin/store.js';
39
+ import '@langchain/langgraph';
package/dist/index.js ADDED
@@ -0,0 +1,160 @@
1
+ import {
2
+ createPlatformAdminRouter
3
+ } from "./chunk-753HWDSC.js";
4
+ import "./chunk-YMJ7BRKU.js";
5
+ import "./chunk-7FTJN4SA.js";
6
+ import {
7
+ InMemoryWorkflowDefinitionRegistry
8
+ } from "./chunk-HVC7FG6B.js";
9
+ import {
10
+ LocalRunnerPullCoordinator
11
+ } from "./chunk-ZHMTD5KV.js";
12
+ import {
13
+ createHttpAgentExecutor
14
+ } from "./chunk-IJWYS2PF.js";
15
+ import {
16
+ WorkflowNodeCatalog
17
+ } from "./chunk-7AHSS7SO.js";
18
+ import {
19
+ compileWorkflowDefinition
20
+ } from "./chunk-CJ7OFEF7.js";
21
+ import {
22
+ DurableWorkflowCoordinator
23
+ } from "./chunk-EJKWDZIU.js";
24
+ import {
25
+ ServerWorkflowManager
26
+ } from "./chunk-FD6VC2NA.js";
27
+ import {
28
+ createWorkflowAgentRunner
29
+ } from "./chunk-6XZXYNJR.js";
30
+ import {
31
+ DurableAIExecutionBroker
32
+ } from "./chunk-LYPZPE53.js";
33
+ import {
34
+ AtomicCheckpointSaver
35
+ } from "./chunk-3NLSWP2Y.js";
36
+ import {
37
+ ServerAutonomousWorker
38
+ } from "./chunk-THYUY5ZZ.js";
39
+ import {
40
+ EventAgentBridge,
41
+ InMemoryEventAgentTaskStore
42
+ } from "./chunk-3P4XTTQH.js";
43
+ import {
44
+ buildSystemdRunArgs,
45
+ createCommandAgentExecutor,
46
+ validateAgentRuntimePolicy
47
+ } from "./chunk-32746UQZ.js";
48
+ import {
49
+ ServerAgentExecutionError
50
+ } from "./chunk-YABTQZDJ.js";
51
+ import {
52
+ GraphProjectionCoordinator
53
+ } from "./chunk-W6O3LVBY.js";
54
+ import {
55
+ AgentGraphEngine
56
+ } from "./chunk-HXFVOR7Z.js";
57
+ import {
58
+ ErpEngine,
59
+ createErpEngine,
60
+ defineConfig
61
+ } from "./chunk-6KV5CJBW.js";
62
+ import {
63
+ createAuthMiddleware
64
+ } from "./chunk-XIEY2OF4.js";
65
+ import {
66
+ createErrorHandler
67
+ } from "./chunk-AVDMLTPF.js";
68
+ import {
69
+ createModuleGuard
70
+ } from "./chunk-VC2PCK2S.js";
71
+ import {
72
+ createHealthRouter
73
+ } from "./chunk-R4ADP2DC.js";
74
+ import "./chunk-L6PMAEMB.js";
75
+ import {
76
+ createMcpRouter
77
+ } from "./chunk-VF5YDZJC.js";
78
+ import {
79
+ createSdkPluginRouter
80
+ } from "./chunk-4VORUFKR.js";
81
+ import {
82
+ EntitlementError,
83
+ PluginEntitlementRuntime,
84
+ createPluginAssetRouter,
85
+ createPluginEntitlementGuard,
86
+ createSqlTenantEntitlementLoader,
87
+ requiresEntitlementRuntime,
88
+ resolveEngineEntitlementPrincipal,
89
+ tenantEntitlementContract
90
+ } from "./chunk-46UWPEW2.js";
91
+ import "./chunk-INCHXAFK.js";
92
+ import "./chunk-3VITSHN3.js";
93
+ import {
94
+ TenantResolver,
95
+ createTenantResolver
96
+ } from "./chunk-BKAHUEIT.js";
97
+ import {
98
+ WorkspaceContextError,
99
+ createWorkspaceContextResolver
100
+ } from "./chunk-WFEAKJLR.js";
101
+ import {
102
+ DurableAgentJobDispatcher,
103
+ cancelAgentJob,
104
+ createAgentJob,
105
+ createAtomicAgentJobStore,
106
+ enqueueAgentJob
107
+ } from "./chunk-PBC3MZUL.js";
108
+ import {
109
+ createWorkflowAgentNode
110
+ } from "./chunk-UGNTCOVR.js";
111
+ export {
112
+ AgentGraphEngine,
113
+ AtomicCheckpointSaver,
114
+ DurableAIExecutionBroker,
115
+ DurableAgentJobDispatcher,
116
+ DurableWorkflowCoordinator,
117
+ EntitlementError,
118
+ ErpEngine,
119
+ EventAgentBridge,
120
+ GraphProjectionCoordinator,
121
+ InMemoryEventAgentTaskStore,
122
+ InMemoryWorkflowDefinitionRegistry,
123
+ LocalRunnerPullCoordinator,
124
+ PluginEntitlementRuntime,
125
+ ServerAgentExecutionError,
126
+ ServerAutonomousWorker,
127
+ ServerWorkflowManager,
128
+ TenantResolver,
129
+ WorkflowNodeCatalog,
130
+ WorkspaceContextError,
131
+ buildSystemdRunArgs,
132
+ cancelAgentJob,
133
+ compileWorkflowDefinition,
134
+ createAgentJob,
135
+ createAtomicAgentJobStore,
136
+ createAuthMiddleware,
137
+ createCommandAgentExecutor,
138
+ createErpEngine,
139
+ createErrorHandler,
140
+ createHealthRouter,
141
+ createHttpAgentExecutor,
142
+ createMcpRouter,
143
+ createModuleGuard,
144
+ createPlatformAdminRouter,
145
+ createPluginAssetRouter,
146
+ createPluginEntitlementGuard,
147
+ createSdkPluginRouter,
148
+ createSqlTenantEntitlementLoader,
149
+ createTenantResolver,
150
+ createWorkflowAgentNode,
151
+ createWorkflowAgentRunner,
152
+ createWorkspaceContextResolver,
153
+ defineConfig,
154
+ enqueueAgentJob,
155
+ requiresEntitlementRuntime,
156
+ resolveEngineEntitlementPrincipal,
157
+ tenantEntitlementContract,
158
+ validateAgentRuntimePolicy
159
+ };
160
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}