mayura 0.1.0-dev.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 (1116) hide show
  1. package/LICENSE +201 -0
  2. package/NOTICE +8 -0
  3. package/README.md +55 -0
  4. package/lib/adapter-code-docker/dist/index.d.ts +65 -0
  5. package/lib/adapter-code-docker/dist/index.d.ts.map +1 -0
  6. package/lib/adapter-code-docker/dist/index.js +228 -0
  7. package/lib/adapter-code-docker/dist/index.js.map +1 -0
  8. package/lib/adapter-code-docker/image/Dockerfile +12 -0
  9. package/lib/adapter-code-docker/package.json +5 -0
  10. package/lib/adapter-code-docker/src/index.ts +244 -0
  11. package/lib/adapter-code-quickjs/dist/index.d.ts +40 -0
  12. package/lib/adapter-code-quickjs/dist/index.d.ts.map +1 -0
  13. package/lib/adapter-code-quickjs/dist/index.js +169 -0
  14. package/lib/adapter-code-quickjs/dist/index.js.map +1 -0
  15. package/lib/adapter-code-quickjs/dist/worker.d.ts +2 -0
  16. package/lib/adapter-code-quickjs/dist/worker.d.ts.map +1 -0
  17. package/lib/adapter-code-quickjs/dist/worker.js +164 -0
  18. package/lib/adapter-code-quickjs/dist/worker.js.map +1 -0
  19. package/lib/adapter-code-quickjs/package.json +5 -0
  20. package/lib/adapter-code-quickjs/src/index.ts +174 -0
  21. package/lib/adapter-code-quickjs/src/worker.ts +142 -0
  22. package/lib/adapter-mcp/dist/index.d.ts +29 -0
  23. package/lib/adapter-mcp/dist/index.d.ts.map +1 -0
  24. package/lib/adapter-mcp/dist/index.js +54 -0
  25. package/lib/adapter-mcp/dist/index.js.map +1 -0
  26. package/lib/adapter-mcp/package.json +5 -0
  27. package/lib/adapter-mcp/src/index.ts +82 -0
  28. package/lib/artifacts/dist/contracts.d.ts +139 -0
  29. package/lib/artifacts/dist/contracts.d.ts.map +1 -0
  30. package/lib/artifacts/dist/contracts.js +2 -0
  31. package/lib/artifacts/dist/contracts.js.map +1 -0
  32. package/lib/artifacts/dist/index.d.ts +3 -0
  33. package/lib/artifacts/dist/index.d.ts.map +1 -0
  34. package/lib/artifacts/dist/index.js +2 -0
  35. package/lib/artifacts/dist/index.js.map +1 -0
  36. package/lib/artifacts/dist/local-store.d.ts +3 -0
  37. package/lib/artifacts/dist/local-store.d.ts.map +1 -0
  38. package/lib/artifacts/dist/local-store.js +922 -0
  39. package/lib/artifacts/dist/local-store.js.map +1 -0
  40. package/lib/artifacts/package.json +5 -0
  41. package/lib/artifacts/src/contracts.ts +159 -0
  42. package/lib/artifacts/src/index.ts +26 -0
  43. package/lib/artifacts/src/local-store.ts +816 -0
  44. package/lib/cli/dist/application.d.ts +85 -0
  45. package/lib/cli/dist/application.d.ts.map +1 -0
  46. package/lib/cli/dist/application.js +116 -0
  47. package/lib/cli/dist/application.js.map +1 -0
  48. package/lib/cli/dist/bin.d.ts +3 -0
  49. package/lib/cli/dist/bin.d.ts.map +1 -0
  50. package/lib/cli/dist/bin.js +394 -0
  51. package/lib/cli/dist/bin.js.map +1 -0
  52. package/lib/cli/dist/dev.d.ts +21 -0
  53. package/lib/cli/dist/dev.d.ts.map +1 -0
  54. package/lib/cli/dist/dev.js +205 -0
  55. package/lib/cli/dist/dev.js.map +1 -0
  56. package/lib/cli/dist/index.d.ts +72 -0
  57. package/lib/cli/dist/index.d.ts.map +1 -0
  58. package/lib/cli/dist/index.js +423 -0
  59. package/lib/cli/dist/index.js.map +1 -0
  60. package/lib/cli/dist/interactive.d.ts +19 -0
  61. package/lib/cli/dist/interactive.d.ts.map +1 -0
  62. package/lib/cli/dist/interactive.js +163 -0
  63. package/lib/cli/dist/interactive.js.map +1 -0
  64. package/lib/cli/dist/operations.d.ts +215 -0
  65. package/lib/cli/dist/operations.d.ts.map +1 -0
  66. package/lib/cli/dist/operations.js +580 -0
  67. package/lib/cli/dist/operations.js.map +1 -0
  68. package/lib/cli/dist/output.d.ts +29 -0
  69. package/lib/cli/dist/output.d.ts.map +1 -0
  70. package/lib/cli/dist/output.js +244 -0
  71. package/lib/cli/dist/output.js.map +1 -0
  72. package/lib/cli/dist/providers.d.ts +54 -0
  73. package/lib/cli/dist/providers.d.ts.map +1 -0
  74. package/lib/cli/dist/providers.js +96 -0
  75. package/lib/cli/dist/providers.js.map +1 -0
  76. package/lib/cli/package.json +5 -0
  77. package/lib/cli/src/application.ts +109 -0
  78. package/lib/cli/src/bin.ts +261 -0
  79. package/lib/cli/src/dev.ts +139 -0
  80. package/lib/cli/src/index.ts +386 -0
  81. package/lib/cli/src/interactive.ts +132 -0
  82. package/lib/cli/src/operations.ts +458 -0
  83. package/lib/cli/src/output.ts +205 -0
  84. package/lib/cli/src/providers.ts +102 -0
  85. package/lib/cli/starters/approval-workflow/Dockerfile +20 -0
  86. package/lib/cli/starters/approval-workflow/README.md +102 -0
  87. package/lib/cli/starters/approval-workflow/compose.yaml +33 -0
  88. package/lib/cli/starters/approval-workflow/dot-dockerignore +7 -0
  89. package/lib/cli/starters/approval-workflow/dot-env.example +41 -0
  90. package/lib/cli/starters/approval-workflow/dot-github/workflows/ci.yml +13 -0
  91. package/lib/cli/starters/approval-workflow/dot-gitignore +10 -0
  92. package/lib/cli/starters/approval-workflow/mayura.project.json +16 -0
  93. package/lib/cli/starters/approval-workflow/package.json +30 -0
  94. package/lib/cli/starters/approval-workflow/src/app.ts +19 -0
  95. package/lib/cli/starters/approval-workflow/src/auth.ts +68 -0
  96. package/lib/cli/starters/approval-workflow/src/config.ts +107 -0
  97. package/lib/cli/starters/approval-workflow/src/dev.ts +59 -0
  98. package/lib/cli/starters/approval-workflow/src/intake.ts +104 -0
  99. package/lib/cli/starters/approval-workflow/src/model.ts +33 -0
  100. package/lib/cli/starters/approval-workflow/src/server.ts +56 -0
  101. package/lib/cli/starters/approval-workflow/src/services.ts +26 -0
  102. package/lib/cli/starters/approval-workflow/src/token.ts +6 -0
  103. package/lib/cli/starters/approval-workflow/src/worker.ts +18 -0
  104. package/lib/cli/starters/approval-workflow/src/workflow.ts +100 -0
  105. package/lib/cli/starters/approval-workflow/test/refunds.test.ts +140 -0
  106. package/lib/cli/starters/approval-workflow/tsconfig.json +20 -0
  107. package/lib/cli/starters/event-automation/Dockerfile +21 -0
  108. package/lib/cli/starters/event-automation/README.md +150 -0
  109. package/lib/cli/starters/event-automation/compose.yaml +41 -0
  110. package/lib/cli/starters/event-automation/dot-dockerignore +7 -0
  111. package/lib/cli/starters/event-automation/dot-env.example +51 -0
  112. package/lib/cli/starters/event-automation/dot-github/workflows/ci.yml +13 -0
  113. package/lib/cli/starters/event-automation/dot-gitignore +10 -0
  114. package/lib/cli/starters/event-automation/mayura.project.json +17 -0
  115. package/lib/cli/starters/event-automation/package.json +32 -0
  116. package/lib/cli/starters/event-automation/src/app.ts +19 -0
  117. package/lib/cli/starters/event-automation/src/auth.ts +61 -0
  118. package/lib/cli/starters/event-automation/src/config.ts +138 -0
  119. package/lib/cli/starters/event-automation/src/dev.ts +54 -0
  120. package/lib/cli/starters/event-automation/src/ingress.ts +129 -0
  121. package/lib/cli/starters/event-automation/src/mcp.ts +139 -0
  122. package/lib/cli/starters/event-automation/src/model.ts +33 -0
  123. package/lib/cli/starters/event-automation/src/send-sample.ts +29 -0
  124. package/lib/cli/starters/event-automation/src/server.ts +58 -0
  125. package/lib/cli/starters/event-automation/src/services.ts +54 -0
  126. package/lib/cli/starters/event-automation/src/signing.ts +30 -0
  127. package/lib/cli/starters/event-automation/src/token.ts +7 -0
  128. package/lib/cli/starters/event-automation/src/tracker/main.ts +18 -0
  129. package/lib/cli/starters/event-automation/src/tracker/mcp-server.ts +145 -0
  130. package/lib/cli/starters/event-automation/src/tracker/samples.ts +19 -0
  131. package/lib/cli/starters/event-automation/src/tracker/tickets.ts +54 -0
  132. package/lib/cli/starters/event-automation/src/tracker-tools.ts +38 -0
  133. package/lib/cli/starters/event-automation/src/triage.ts +151 -0
  134. package/lib/cli/starters/event-automation/src/worker.ts +19 -0
  135. package/lib/cli/starters/event-automation/src/workflows.ts +57 -0
  136. package/lib/cli/starters/event-automation/test/automation.test.ts +200 -0
  137. package/lib/cli/starters/event-automation/tsconfig.json +20 -0
  138. package/lib/cli/starters/research-team/Dockerfile +22 -0
  139. package/lib/cli/starters/research-team/README.md +189 -0
  140. package/lib/cli/starters/research-team/compose.yaml +38 -0
  141. package/lib/cli/starters/research-team/dot-dockerignore +7 -0
  142. package/lib/cli/starters/research-team/dot-env.example +49 -0
  143. package/lib/cli/starters/research-team/dot-github/workflows/ci.yml +13 -0
  144. package/lib/cli/starters/research-team/dot-gitignore +10 -0
  145. package/lib/cli/starters/research-team/mayura.project.json +22 -0
  146. package/lib/cli/starters/research-team/package.json +30 -0
  147. package/lib/cli/starters/research-team/src/app.ts +19 -0
  148. package/lib/cli/starters/research-team/src/auth.ts +56 -0
  149. package/lib/cli/starters/research-team/src/config.ts +170 -0
  150. package/lib/cli/starters/research-team/src/desk.ts +124 -0
  151. package/lib/cli/starters/research-team/src/dev.ts +58 -0
  152. package/lib/cli/starters/research-team/src/library/corpus.ts +76 -0
  153. package/lib/cli/starters/research-team/src/library/index.ts +109 -0
  154. package/lib/cli/starters/research-team/src/model.ts +33 -0
  155. package/lib/cli/starters/research-team/src/server.ts +69 -0
  156. package/lib/cli/starters/research-team/src/services.ts +48 -0
  157. package/lib/cli/starters/research-team/src/team.ts +173 -0
  158. package/lib/cli/starters/research-team/src/telemetry.ts +95 -0
  159. package/lib/cli/starters/research-team/src/token.ts +6 -0
  160. package/lib/cli/starters/research-team/src/worker.ts +21 -0
  161. package/lib/cli/starters/research-team/src/workflow.ts +197 -0
  162. package/lib/cli/starters/research-team/test/research.test.ts +271 -0
  163. package/lib/cli/starters/research-team/tsconfig.json +20 -0
  164. package/lib/cli/starters/support-agent/Dockerfile +21 -0
  165. package/lib/cli/starters/support-agent/README.md +128 -0
  166. package/lib/cli/starters/support-agent/compose.yaml +33 -0
  167. package/lib/cli/starters/support-agent/dot-dockerignore +7 -0
  168. package/lib/cli/starters/support-agent/dot-env.example +44 -0
  169. package/lib/cli/starters/support-agent/dot-github/workflows/ci.yml +13 -0
  170. package/lib/cli/starters/support-agent/dot-gitignore +10 -0
  171. package/lib/cli/starters/support-agent/mayura.project.json +18 -0
  172. package/lib/cli/starters/support-agent/package.json +43 -0
  173. package/lib/cli/starters/support-agent/src/app.ts +19 -0
  174. package/lib/cli/starters/support-agent/src/assistant.ts +313 -0
  175. package/lib/cli/starters/support-agent/src/auth.ts +69 -0
  176. package/lib/cli/starters/support-agent/src/config.ts +120 -0
  177. package/lib/cli/starters/support-agent/src/dev.ts +115 -0
  178. package/lib/cli/starters/support-agent/src/guardrails.ts +71 -0
  179. package/lib/cli/starters/support-agent/src/model.ts +33 -0
  180. package/lib/cli/starters/support-agent/src/orders.ts +62 -0
  181. package/lib/cli/starters/support-agent/src/returns.ts +86 -0
  182. package/lib/cli/starters/support-agent/src/server.ts +72 -0
  183. package/lib/cli/starters/support-agent/src/services.ts +32 -0
  184. package/lib/cli/starters/support-agent/src/session.ts +55 -0
  185. package/lib/cli/starters/support-agent/src/token.ts +9 -0
  186. package/lib/cli/starters/support-agent/src/worker.ts +19 -0
  187. package/lib/cli/starters/support-agent/test/support.test.ts +263 -0
  188. package/lib/cli/starters/support-agent/tsconfig.json +20 -0
  189. package/lib/cli/starters/support-agent/web/index.html +12 -0
  190. package/lib/cli/starters/support-agent/web/src/App.tsx +43 -0
  191. package/lib/cli/starters/support-agent/web/src/components/chat.tsx +161 -0
  192. package/lib/cli/starters/support-agent/web/src/components/ui/button.tsx +33 -0
  193. package/lib/cli/starters/support-agent/web/src/components/ui/primitives.tsx +48 -0
  194. package/lib/cli/starters/support-agent/web/src/env.d.ts +1 -0
  195. package/lib/cli/starters/support-agent/web/src/lib/api.ts +56 -0
  196. package/lib/cli/starters/support-agent/web/src/lib/utils.ts +4 -0
  197. package/lib/cli/starters/support-agent/web/src/main.tsx +6 -0
  198. package/lib/cli/starters/support-agent/web/src/styles.css +86 -0
  199. package/lib/cli/starters/support-agent/web/tsconfig.json +9 -0
  200. package/lib/cli/starters/support-agent/web/vite.config.ts +13 -0
  201. package/lib/cli/templates/basic-agent.ts +10 -0
  202. package/lib/cli/templates/capability-policy.ts +18 -0
  203. package/lib/cli/templates/code-mode-workflow.ts +34 -0
  204. package/lib/cli/templates/durable-approval.ts +25 -0
  205. package/lib/cli/templates/guarded-streaming-app.ts +23 -0
  206. package/lib/cli/templates/native-memory.ts +15 -0
  207. package/lib/cli/templates/parallel-research.ts +21 -0
  208. package/lib/cli/templates/typed-tool-runner.ts +15 -0
  209. package/lib/client/dist/forms.d.ts +77 -0
  210. package/lib/client/dist/forms.d.ts.map +1 -0
  211. package/lib/client/dist/forms.js +282 -0
  212. package/lib/client/dist/forms.js.map +1 -0
  213. package/lib/client/dist/headless.d.ts +84 -0
  214. package/lib/client/dist/headless.d.ts.map +1 -0
  215. package/lib/client/dist/headless.js +376 -0
  216. package/lib/client/dist/headless.js.map +1 -0
  217. package/lib/client/dist/index.d.ts +266 -0
  218. package/lib/client/dist/index.d.ts.map +1 -0
  219. package/lib/client/dist/index.js +814 -0
  220. package/lib/client/dist/index.js.map +1 -0
  221. package/lib/client/dist/workflows.d.ts +128 -0
  222. package/lib/client/dist/workflows.d.ts.map +1 -0
  223. package/lib/client/dist/workflows.js +379 -0
  224. package/lib/client/dist/workflows.js.map +1 -0
  225. package/lib/client/package.json +5 -0
  226. package/lib/client/src/forms.ts +215 -0
  227. package/lib/client/src/headless.ts +265 -0
  228. package/lib/client/src/index.ts +646 -0
  229. package/lib/client/src/workflows.ts +307 -0
  230. package/lib/client-react/dist/components.d.ts +70 -0
  231. package/lib/client-react/dist/components.d.ts.map +1 -0
  232. package/lib/client-react/dist/components.js +173 -0
  233. package/lib/client-react/dist/components.js.map +1 -0
  234. package/lib/client-react/dist/index.d.ts +29 -0
  235. package/lib/client-react/dist/index.d.ts.map +1 -0
  236. package/lib/client-react/dist/index.js +57 -0
  237. package/lib/client-react/dist/index.js.map +1 -0
  238. package/lib/client-react/package.json +5 -0
  239. package/lib/client-react/src/components.ts +183 -0
  240. package/lib/client-react/src/index.ts +70 -0
  241. package/lib/code-mode/dist/index.d.ts +142 -0
  242. package/lib/code-mode/dist/index.d.ts.map +1 -0
  243. package/lib/code-mode/dist/index.js +498 -0
  244. package/lib/code-mode/dist/index.js.map +1 -0
  245. package/lib/code-mode/package.json +5 -0
  246. package/lib/code-mode/src/index.ts +605 -0
  247. package/lib/code-mode-workflows/dist/index.d.ts +51 -0
  248. package/lib/code-mode-workflows/dist/index.d.ts.map +1 -0
  249. package/lib/code-mode-workflows/dist/index.js +231 -0
  250. package/lib/code-mode-workflows/dist/index.js.map +1 -0
  251. package/lib/code-mode-workflows/package.json +5 -0
  252. package/lib/code-mode-workflows/src/index.ts +259 -0
  253. package/lib/context/dist/assemble.d.ts +11 -0
  254. package/lib/context/dist/assemble.d.ts.map +1 -0
  255. package/lib/context/dist/assemble.js +265 -0
  256. package/lib/context/dist/assemble.js.map +1 -0
  257. package/lib/context/dist/cache.d.ts +53 -0
  258. package/lib/context/dist/cache.d.ts.map +1 -0
  259. package/lib/context/dist/cache.js +147 -0
  260. package/lib/context/dist/cache.js.map +1 -0
  261. package/lib/context/dist/contracts.d.ts +145 -0
  262. package/lib/context/dist/contracts.d.ts.map +1 -0
  263. package/lib/context/dist/contracts.js +2 -0
  264. package/lib/context/dist/contracts.js.map +1 -0
  265. package/lib/context/dist/index.d.ts +4 -0
  266. package/lib/context/dist/index.d.ts.map +1 -0
  267. package/lib/context/dist/index.js +3 -0
  268. package/lib/context/dist/index.js.map +1 -0
  269. package/lib/context/package.json +5 -0
  270. package/lib/context/src/assemble.ts +205 -0
  271. package/lib/context/src/cache.ts +143 -0
  272. package/lib/context/src/contracts.ts +124 -0
  273. package/lib/context/src/index.ts +3 -0
  274. package/lib/core/dist/budget.d.ts +85 -0
  275. package/lib/core/dist/budget.d.ts.map +1 -0
  276. package/lib/core/dist/budget.js +328 -0
  277. package/lib/core/dist/budget.js.map +1 -0
  278. package/lib/core/dist/contracts.d.ts +156 -0
  279. package/lib/core/dist/contracts.d.ts.map +1 -0
  280. package/lib/core/dist/contracts.js +13 -0
  281. package/lib/core/dist/contracts.js.map +1 -0
  282. package/lib/core/dist/errors.d.ts +17 -0
  283. package/lib/core/dist/errors.d.ts.map +1 -0
  284. package/lib/core/dist/errors.js +22 -0
  285. package/lib/core/dist/errors.js.map +1 -0
  286. package/lib/core/dist/event-stream.d.ts +26 -0
  287. package/lib/core/dist/event-stream.d.ts.map +1 -0
  288. package/lib/core/dist/event-stream.js +116 -0
  289. package/lib/core/dist/event-stream.js.map +1 -0
  290. package/lib/core/dist/host.d.ts +7 -0
  291. package/lib/core/dist/host.d.ts.map +1 -0
  292. package/lib/core/dist/host.js +7 -0
  293. package/lib/core/dist/host.js.map +1 -0
  294. package/lib/core/dist/index.d.ts +8 -0
  295. package/lib/core/dist/index.d.ts.map +1 -0
  296. package/lib/core/dist/index.js +7 -0
  297. package/lib/core/dist/index.js.map +1 -0
  298. package/lib/core/dist/json.d.ts +18 -0
  299. package/lib/core/dist/json.d.ts.map +1 -0
  300. package/lib/core/dist/json.js +100 -0
  301. package/lib/core/dist/json.js.map +1 -0
  302. package/lib/core/dist/lifecycle.d.ts +45 -0
  303. package/lib/core/dist/lifecycle.d.ts.map +1 -0
  304. package/lib/core/dist/lifecycle.js +114 -0
  305. package/lib/core/dist/lifecycle.js.map +1 -0
  306. package/lib/core/dist/local-guards.d.ts +4 -0
  307. package/lib/core/dist/local-guards.d.ts.map +1 -0
  308. package/lib/core/dist/local-guards.js +47 -0
  309. package/lib/core/dist/local-guards.js.map +1 -0
  310. package/lib/core/dist/managed-guards.d.ts +44 -0
  311. package/lib/core/dist/managed-guards.d.ts.map +1 -0
  312. package/lib/core/dist/managed-guards.js +146 -0
  313. package/lib/core/dist/managed-guards.js.map +1 -0
  314. package/lib/core/dist/schema.d.ts +36 -0
  315. package/lib/core/dist/schema.d.ts.map +1 -0
  316. package/lib/core/dist/schema.js +24 -0
  317. package/lib/core/dist/schema.js.map +1 -0
  318. package/lib/core/package.json +5 -0
  319. package/lib/core/src/budget.ts +366 -0
  320. package/lib/core/src/contracts.ts +107 -0
  321. package/lib/core/src/errors.ts +33 -0
  322. package/lib/core/src/event-stream.ts +87 -0
  323. package/lib/core/src/host.ts +6 -0
  324. package/lib/core/src/index.ts +7 -0
  325. package/lib/core/src/json.ts +81 -0
  326. package/lib/core/src/lifecycle.ts +133 -0
  327. package/lib/core/src/local-guards.ts +37 -0
  328. package/lib/core/src/managed-guards.ts +154 -0
  329. package/lib/core/src/schema.ts +43 -0
  330. package/lib/exporter-otlp/dist/contracts.d.ts +112 -0
  331. package/lib/exporter-otlp/dist/contracts.d.ts.map +1 -0
  332. package/lib/exporter-otlp/dist/contracts.js +2 -0
  333. package/lib/exporter-otlp/dist/contracts.js.map +1 -0
  334. package/lib/exporter-otlp/dist/index.d.ts +5 -0
  335. package/lib/exporter-otlp/dist/index.d.ts.map +1 -0
  336. package/lib/exporter-otlp/dist/index.js +4 -0
  337. package/lib/exporter-otlp/dist/index.js.map +1 -0
  338. package/lib/exporter-otlp/dist/otlp-http-json.d.ts +4 -0
  339. package/lib/exporter-otlp/dist/otlp-http-json.d.ts.map +1 -0
  340. package/lib/exporter-otlp/dist/otlp-http-json.js +286 -0
  341. package/lib/exporter-otlp/dist/otlp-http-json.js.map +1 -0
  342. package/lib/exporter-otlp/dist/run-traces.d.ts +15 -0
  343. package/lib/exporter-otlp/dist/run-traces.d.ts.map +1 -0
  344. package/lib/exporter-otlp/dist/run-traces.js +114 -0
  345. package/lib/exporter-otlp/dist/run-traces.js.map +1 -0
  346. package/lib/exporter-otlp/dist/signals.d.ts +4 -0
  347. package/lib/exporter-otlp/dist/signals.d.ts.map +1 -0
  348. package/lib/exporter-otlp/dist/signals.js +330 -0
  349. package/lib/exporter-otlp/dist/signals.js.map +1 -0
  350. package/lib/exporter-otlp/package.json +5 -0
  351. package/lib/exporter-otlp/src/contracts.ts +119 -0
  352. package/lib/exporter-otlp/src/index.ts +23 -0
  353. package/lib/exporter-otlp/src/otlp-http-json.ts +189 -0
  354. package/lib/exporter-otlp/src/run-traces.ts +86 -0
  355. package/lib/exporter-otlp/src/signals.ts +185 -0
  356. package/lib/guardrails/dist/agent-guard.d.ts +9 -0
  357. package/lib/guardrails/dist/agent-guard.d.ts.map +1 -0
  358. package/lib/guardrails/dist/agent-guard.js +23 -0
  359. package/lib/guardrails/dist/agent-guard.js.map +1 -0
  360. package/lib/guardrails/dist/auxiliary-helpers.d.ts +63 -0
  361. package/lib/guardrails/dist/auxiliary-helpers.d.ts.map +1 -0
  362. package/lib/guardrails/dist/auxiliary-helpers.js +147 -0
  363. package/lib/guardrails/dist/auxiliary-helpers.js.map +1 -0
  364. package/lib/guardrails/dist/auxiliary.d.ts +51 -0
  365. package/lib/guardrails/dist/auxiliary.d.ts.map +1 -0
  366. package/lib/guardrails/dist/auxiliary.js +230 -0
  367. package/lib/guardrails/dist/auxiliary.js.map +1 -0
  368. package/lib/guardrails/dist/batches.d.ts +18 -0
  369. package/lib/guardrails/dist/batches.d.ts.map +1 -0
  370. package/lib/guardrails/dist/batches.js +160 -0
  371. package/lib/guardrails/dist/batches.js.map +1 -0
  372. package/lib/guardrails/dist/disclosure.d.ts +30 -0
  373. package/lib/guardrails/dist/disclosure.d.ts.map +1 -0
  374. package/lib/guardrails/dist/disclosure.js +109 -0
  375. package/lib/guardrails/dist/disclosure.js.map +1 -0
  376. package/lib/guardrails/dist/helpers.d.ts +20 -0
  377. package/lib/guardrails/dist/helpers.d.ts.map +1 -0
  378. package/lib/guardrails/dist/helpers.js +72 -0
  379. package/lib/guardrails/dist/helpers.js.map +1 -0
  380. package/lib/guardrails/dist/index.d.ts +9 -0
  381. package/lib/guardrails/dist/index.d.ts.map +1 -0
  382. package/lib/guardrails/dist/index.js +9 -0
  383. package/lib/guardrails/dist/index.js.map +1 -0
  384. package/lib/guardrails/dist/managed.d.ts +18 -0
  385. package/lib/guardrails/dist/managed.d.ts.map +1 -0
  386. package/lib/guardrails/dist/managed.js +67 -0
  387. package/lib/guardrails/dist/managed.js.map +1 -0
  388. package/lib/guardrails/dist/pipeline.d.ts +55 -0
  389. package/lib/guardrails/dist/pipeline.d.ts.map +1 -0
  390. package/lib/guardrails/dist/pipeline.js +201 -0
  391. package/lib/guardrails/dist/pipeline.js.map +1 -0
  392. package/lib/guardrails/package.json +5 -0
  393. package/lib/guardrails/src/agent-guard.ts +22 -0
  394. package/lib/guardrails/src/auxiliary-helpers.ts +146 -0
  395. package/lib/guardrails/src/auxiliary.ts +202 -0
  396. package/lib/guardrails/src/batches.ts +130 -0
  397. package/lib/guardrails/src/disclosure.ts +92 -0
  398. package/lib/guardrails/src/helpers.ts +67 -0
  399. package/lib/guardrails/src/index.ts +8 -0
  400. package/lib/guardrails/src/managed.ts +64 -0
  401. package/lib/guardrails/src/pipeline.ts +185 -0
  402. package/lib/helpers/dist/concurrency.d.ts +25 -0
  403. package/lib/helpers/dist/concurrency.d.ts.map +1 -0
  404. package/lib/helpers/dist/concurrency.js +106 -0
  405. package/lib/helpers/dist/concurrency.js.map +1 -0
  406. package/lib/helpers/dist/configuration.d.ts +42 -0
  407. package/lib/helpers/dist/configuration.d.ts.map +1 -0
  408. package/lib/helpers/dist/configuration.js +119 -0
  409. package/lib/helpers/dist/configuration.js.map +1 -0
  410. package/lib/helpers/dist/control.d.ts +61 -0
  411. package/lib/helpers/dist/control.d.ts.map +1 -0
  412. package/lib/helpers/dist/control.js +220 -0
  413. package/lib/helpers/dist/control.js.map +1 -0
  414. package/lib/helpers/dist/credentials.d.ts +42 -0
  415. package/lib/helpers/dist/credentials.d.ts.map +1 -0
  416. package/lib/helpers/dist/credentials.js +126 -0
  417. package/lib/helpers/dist/credentials.js.map +1 -0
  418. package/lib/helpers/dist/data.d.ts +30 -0
  419. package/lib/helpers/dist/data.d.ts.map +1 -0
  420. package/lib/helpers/dist/data.js +90 -0
  421. package/lib/helpers/dist/data.js.map +1 -0
  422. package/lib/helpers/dist/index.d.ts +6 -0
  423. package/lib/helpers/dist/index.d.ts.map +1 -0
  424. package/lib/helpers/dist/index.js +6 -0
  425. package/lib/helpers/dist/index.js.map +1 -0
  426. package/lib/helpers/package.json +5 -0
  427. package/lib/helpers/src/concurrency.ts +92 -0
  428. package/lib/helpers/src/configuration.ts +131 -0
  429. package/lib/helpers/src/control.ts +231 -0
  430. package/lib/helpers/src/credentials.ts +113 -0
  431. package/lib/helpers/src/data.ts +105 -0
  432. package/lib/helpers/src/index.ts +5 -0
  433. package/lib/memory/dist/contracts.d.ts +146 -0
  434. package/lib/memory/dist/contracts.d.ts.map +1 -0
  435. package/lib/memory/dist/contracts.js +2 -0
  436. package/lib/memory/dist/contracts.js.map +1 -0
  437. package/lib/memory/dist/index.d.ts +10 -0
  438. package/lib/memory/dist/index.d.ts.map +1 -0
  439. package/lib/memory/dist/index.js +316 -0
  440. package/lib/memory/dist/index.js.map +1 -0
  441. package/lib/memory/dist/native.d.ts +157 -0
  442. package/lib/memory/dist/native.d.ts.map +1 -0
  443. package/lib/memory/dist/native.js +664 -0
  444. package/lib/memory/dist/native.js.map +1 -0
  445. package/lib/memory/dist/validation.d.ts +21 -0
  446. package/lib/memory/dist/validation.d.ts.map +1 -0
  447. package/lib/memory/dist/validation.js +123 -0
  448. package/lib/memory/dist/validation.js.map +1 -0
  449. package/lib/memory/dist/vectors.d.ts +40 -0
  450. package/lib/memory/dist/vectors.d.ts.map +1 -0
  451. package/lib/memory/dist/vectors.js +134 -0
  452. package/lib/memory/dist/vectors.js.map +1 -0
  453. package/lib/memory/package.json +5 -0
  454. package/lib/memory/src/contracts.ts +113 -0
  455. package/lib/memory/src/index.ts +241 -0
  456. package/lib/memory/src/native.ts +568 -0
  457. package/lib/memory/src/validation.ts +103 -0
  458. package/lib/memory/src/vectors.ts +121 -0
  459. package/lib/memory-remote/dist/index.d.ts +91 -0
  460. package/lib/memory-remote/dist/index.d.ts.map +1 -0
  461. package/lib/memory-remote/dist/index.js +434 -0
  462. package/lib/memory-remote/dist/index.js.map +1 -0
  463. package/lib/memory-remote/package.json +5 -0
  464. package/lib/memory-remote/src/index.ts +367 -0
  465. package/lib/observability/dist/contracts.d.ts +102 -0
  466. package/lib/observability/dist/contracts.d.ts.map +1 -0
  467. package/lib/observability/dist/contracts.js +2 -0
  468. package/lib/observability/dist/contracts.js.map +1 -0
  469. package/lib/observability/dist/index.d.ts +5 -0
  470. package/lib/observability/dist/index.d.ts.map +1 -0
  471. package/lib/observability/dist/index.js +4 -0
  472. package/lib/observability/dist/index.js.map +1 -0
  473. package/lib/observability/dist/observer.d.ts +4 -0
  474. package/lib/observability/dist/observer.d.ts.map +1 -0
  475. package/lib/observability/dist/observer.js +354 -0
  476. package/lib/observability/dist/observer.js.map +1 -0
  477. package/lib/observability/dist/validation.d.ts +6 -0
  478. package/lib/observability/dist/validation.d.ts.map +1 -0
  479. package/lib/observability/dist/validation.js +203 -0
  480. package/lib/observability/dist/validation.js.map +1 -0
  481. package/lib/observability/package.json +5 -0
  482. package/lib/observability/src/contracts.ts +85 -0
  483. package/lib/observability/src/index.ts +4 -0
  484. package/lib/observability/src/observer.ts +246 -0
  485. package/lib/observability/src/validation.ts +132 -0
  486. package/lib/provider-anthropic/dist/index.d.ts +19 -0
  487. package/lib/provider-anthropic/dist/index.d.ts.map +1 -0
  488. package/lib/provider-anthropic/dist/index.js +342 -0
  489. package/lib/provider-anthropic/dist/index.js.map +1 -0
  490. package/lib/provider-anthropic/package.json +5 -0
  491. package/lib/provider-anthropic/src/index.ts +317 -0
  492. package/lib/provider-openai/dist/index.d.ts +77 -0
  493. package/lib/provider-openai/dist/index.d.ts.map +1 -0
  494. package/lib/provider-openai/dist/index.js +577 -0
  495. package/lib/provider-openai/dist/index.js.map +1 -0
  496. package/lib/provider-openai/package.json +5 -0
  497. package/lib/provider-openai/src/index.ts +459 -0
  498. package/lib/runtime/dist/agent.d.ts +63 -0
  499. package/lib/runtime/dist/agent.d.ts.map +1 -0
  500. package/lib/runtime/dist/agent.js +134 -0
  501. package/lib/runtime/dist/agent.js.map +1 -0
  502. package/lib/runtime/dist/composition.d.ts +21 -0
  503. package/lib/runtime/dist/composition.d.ts.map +1 -0
  504. package/lib/runtime/dist/composition.js +54 -0
  505. package/lib/runtime/dist/composition.js.map +1 -0
  506. package/lib/runtime/dist/event-buffer.d.ts +18 -0
  507. package/lib/runtime/dist/event-buffer.d.ts.map +1 -0
  508. package/lib/runtime/dist/event-buffer.js +66 -0
  509. package/lib/runtime/dist/event-buffer.js.map +1 -0
  510. package/lib/runtime/dist/hook-execution.d.ts +40 -0
  511. package/lib/runtime/dist/hook-execution.d.ts.map +1 -0
  512. package/lib/runtime/dist/hook-execution.js +186 -0
  513. package/lib/runtime/dist/hook-execution.js.map +1 -0
  514. package/lib/runtime/dist/hooks.d.ts +178 -0
  515. package/lib/runtime/dist/hooks.d.ts.map +1 -0
  516. package/lib/runtime/dist/hooks.js +120 -0
  517. package/lib/runtime/dist/hooks.js.map +1 -0
  518. package/lib/runtime/dist/index.d.ts +6 -0
  519. package/lib/runtime/dist/index.d.ts.map +1 -0
  520. package/lib/runtime/dist/index.js +6 -0
  521. package/lib/runtime/dist/index.js.map +1 -0
  522. package/lib/runtime/dist/managed-guards.d.ts +27 -0
  523. package/lib/runtime/dist/managed-guards.d.ts.map +1 -0
  524. package/lib/runtime/dist/managed-guards.js +183 -0
  525. package/lib/runtime/dist/managed-guards.js.map +1 -0
  526. package/lib/runtime/dist/permits.d.ts +9 -0
  527. package/lib/runtime/dist/permits.d.ts.map +1 -0
  528. package/lib/runtime/dist/permits.js +77 -0
  529. package/lib/runtime/dist/permits.js.map +1 -0
  530. package/lib/runtime/dist/response.d.ts +8 -0
  531. package/lib/runtime/dist/response.d.ts.map +1 -0
  532. package/lib/runtime/dist/response.js +83 -0
  533. package/lib/runtime/dist/response.js.map +1 -0
  534. package/lib/runtime/dist/router.d.ts +51 -0
  535. package/lib/runtime/dist/router.d.ts.map +1 -0
  536. package/lib/runtime/dist/router.js +181 -0
  537. package/lib/runtime/dist/router.js.map +1 -0
  538. package/lib/runtime/dist/runtime.d.ts +98 -0
  539. package/lib/runtime/dist/runtime.d.ts.map +1 -0
  540. package/lib/runtime/dist/runtime.js +945 -0
  541. package/lib/runtime/dist/runtime.js.map +1 -0
  542. package/lib/runtime/dist/stream.d.ts +25 -0
  543. package/lib/runtime/dist/stream.d.ts.map +1 -0
  544. package/lib/runtime/dist/stream.js +226 -0
  545. package/lib/runtime/dist/stream.js.map +1 -0
  546. package/lib/runtime/package.json +5 -0
  547. package/lib/runtime/src/agent.ts +167 -0
  548. package/lib/runtime/src/composition.ts +63 -0
  549. package/lib/runtime/src/event-buffer.ts +55 -0
  550. package/lib/runtime/src/hook-execution.ts +188 -0
  551. package/lib/runtime/src/hooks.ts +227 -0
  552. package/lib/runtime/src/index.ts +5 -0
  553. package/lib/runtime/src/managed-guards.ts +176 -0
  554. package/lib/runtime/src/permits.ts +65 -0
  555. package/lib/runtime/src/response.ts +68 -0
  556. package/lib/runtime/src/router.ts +178 -0
  557. package/lib/runtime/src/runtime.ts +909 -0
  558. package/lib/runtime/src/stream.ts +130 -0
  559. package/lib/sdk/dist/index.d.ts +5 -0
  560. package/lib/sdk/dist/index.d.ts.map +1 -0
  561. package/lib/sdk/dist/index.js +5 -0
  562. package/lib/sdk/dist/index.js.map +1 -0
  563. package/lib/sdk/package.json +5 -0
  564. package/lib/sdk/src/index.ts +4 -0
  565. package/lib/server/dist/index.d.ts +343 -0
  566. package/lib/server/dist/index.d.ts.map +1 -0
  567. package/lib/server/dist/index.js +1356 -0
  568. package/lib/server/dist/index.js.map +1 -0
  569. package/lib/server/dist/inspector-bundle.d.ts +6 -0
  570. package/lib/server/dist/inspector-bundle.d.ts.map +1 -0
  571. package/lib/server/dist/inspector-bundle.js +6 -0
  572. package/lib/server/dist/inspector-bundle.js.map +1 -0
  573. package/lib/server/dist/inspector.d.ts +3 -0
  574. package/lib/server/dist/inspector.d.ts.map +1 -0
  575. package/lib/server/dist/inspector.js +27 -0
  576. package/lib/server/dist/inspector.js.map +1 -0
  577. package/lib/server/package.json +5 -0
  578. package/lib/server/src/index.ts +1033 -0
  579. package/lib/server/src/inspector-bundle.ts +5 -0
  580. package/lib/server/src/inspector.ts +27 -0
  581. package/lib/server-node/dist/hardening.d.ts +19 -0
  582. package/lib/server-node/dist/hardening.d.ts.map +1 -0
  583. package/lib/server-node/dist/hardening.js +79 -0
  584. package/lib/server-node/dist/hardening.js.map +1 -0
  585. package/lib/server-node/dist/index.d.ts +18 -0
  586. package/lib/server-node/dist/index.d.ts.map +1 -0
  587. package/lib/server-node/dist/index.js +53 -0
  588. package/lib/server-node/dist/index.js.map +1 -0
  589. package/lib/server-node/dist/probe.d.ts +13 -0
  590. package/lib/server-node/dist/probe.d.ts.map +1 -0
  591. package/lib/server-node/dist/probe.js +44 -0
  592. package/lib/server-node/dist/probe.js.map +1 -0
  593. package/lib/server-node/dist/production.d.ts +32 -0
  594. package/lib/server-node/dist/production.d.ts.map +1 -0
  595. package/lib/server-node/dist/production.js +125 -0
  596. package/lib/server-node/dist/production.js.map +1 -0
  597. package/lib/server-node/package.json +5 -0
  598. package/lib/server-node/src/hardening.ts +79 -0
  599. package/lib/server-node/src/index.ts +58 -0
  600. package/lib/server-node/src/probe.ts +36 -0
  601. package/lib/server-node/src/production.ts +116 -0
  602. package/lib/storage/dist/index.d.ts +4 -0
  603. package/lib/storage/dist/index.d.ts.map +1 -0
  604. package/lib/storage/dist/index.js +5 -0
  605. package/lib/storage/dist/index.js.map +1 -0
  606. package/lib/storage/package.json +5 -0
  607. package/lib/storage/src/index.ts +5 -0
  608. package/lib/storage-contracts/dist/contracts.d.ts +69 -0
  609. package/lib/storage-contracts/dist/contracts.d.ts.map +1 -0
  610. package/lib/storage-contracts/dist/contracts.js +15 -0
  611. package/lib/storage-contracts/dist/contracts.js.map +1 -0
  612. package/lib/storage-contracts/dist/durable-budget-contracts.d.ts +110 -0
  613. package/lib/storage-contracts/dist/durable-budget-contracts.d.ts.map +1 -0
  614. package/lib/storage-contracts/dist/durable-budget-contracts.js +430 -0
  615. package/lib/storage-contracts/dist/durable-budget-contracts.js.map +1 -0
  616. package/lib/storage-contracts/dist/execution-wait-contracts.d.ts +74 -0
  617. package/lib/storage-contracts/dist/execution-wait-contracts.d.ts.map +1 -0
  618. package/lib/storage-contracts/dist/execution-wait-contracts.js +159 -0
  619. package/lib/storage-contracts/dist/execution-wait-contracts.js.map +1 -0
  620. package/lib/storage-contracts/dist/index.d.ts +18 -0
  621. package/lib/storage-contracts/dist/index.d.ts.map +1 -0
  622. package/lib/storage-contracts/dist/index.js +18 -0
  623. package/lib/storage-contracts/dist/index.js.map +1 -0
  624. package/lib/storage-contracts/dist/memory-contracts.d.ts +208 -0
  625. package/lib/storage-contracts/dist/memory-contracts.d.ts.map +1 -0
  626. package/lib/storage-contracts/dist/memory-contracts.js +350 -0
  627. package/lib/storage-contracts/dist/memory-contracts.js.map +1 -0
  628. package/lib/storage-contracts/dist/scheduled-workflow-contracts.d.ts +171 -0
  629. package/lib/storage-contracts/dist/scheduled-workflow-contracts.d.ts.map +1 -0
  630. package/lib/storage-contracts/dist/scheduled-workflow-contracts.js +2 -0
  631. package/lib/storage-contracts/dist/scheduled-workflow-contracts.js.map +1 -0
  632. package/lib/storage-contracts/dist/scheduler-contracts.d.ts +133 -0
  633. package/lib/storage-contracts/dist/scheduler-contracts.d.ts.map +1 -0
  634. package/lib/storage-contracts/dist/scheduler-contracts.js +2 -0
  635. package/lib/storage-contracts/dist/scheduler-contracts.js.map +1 -0
  636. package/lib/storage-contracts/dist/submission-journal.d.ts +21 -0
  637. package/lib/storage-contracts/dist/submission-journal.d.ts.map +1 -0
  638. package/lib/storage-contracts/dist/submission-journal.js +51 -0
  639. package/lib/storage-contracts/dist/submission-journal.js.map +1 -0
  640. package/lib/storage-contracts/dist/workflow-format2.d.ts +54 -0
  641. package/lib/storage-contracts/dist/workflow-format2.d.ts.map +1 -0
  642. package/lib/storage-contracts/dist/workflow-format2.js +398 -0
  643. package/lib/storage-contracts/dist/workflow-format2.js.map +1 -0
  644. package/lib/storage-contracts/dist/workflow-format3.d.ts +20 -0
  645. package/lib/storage-contracts/dist/workflow-format3.d.ts.map +1 -0
  646. package/lib/storage-contracts/dist/workflow-format3.js +309 -0
  647. package/lib/storage-contracts/dist/workflow-format3.js.map +1 -0
  648. package/lib/storage-contracts/dist/workflow-format4.d.ts +48 -0
  649. package/lib/storage-contracts/dist/workflow-format4.d.ts.map +1 -0
  650. package/lib/storage-contracts/dist/workflow-format4.js +132 -0
  651. package/lib/storage-contracts/dist/workflow-format4.js.map +1 -0
  652. package/lib/storage-contracts/dist/workflow-format5.d.ts +94 -0
  653. package/lib/storage-contracts/dist/workflow-format5.d.ts.map +1 -0
  654. package/lib/storage-contracts/dist/workflow-format5.js +365 -0
  655. package/lib/storage-contracts/dist/workflow-format5.js.map +1 -0
  656. package/lib/storage-contracts/dist/workflow-graph-contracts.d.ts +69 -0
  657. package/lib/storage-contracts/dist/workflow-graph-contracts.d.ts.map +1 -0
  658. package/lib/storage-contracts/dist/workflow-graph-contracts.js +2 -0
  659. package/lib/storage-contracts/dist/workflow-graph-contracts.js.map +1 -0
  660. package/lib/storage-contracts/dist/workflow-graph-discovery.d.ts +45 -0
  661. package/lib/storage-contracts/dist/workflow-graph-discovery.d.ts.map +1 -0
  662. package/lib/storage-contracts/dist/workflow-graph-discovery.js +101 -0
  663. package/lib/storage-contracts/dist/workflow-graph-discovery.js.map +1 -0
  664. package/lib/storage-contracts/dist/workflow-loop-format1.d.ts +52 -0
  665. package/lib/storage-contracts/dist/workflow-loop-format1.d.ts.map +1 -0
  666. package/lib/storage-contracts/dist/workflow-loop-format1.js +134 -0
  667. package/lib/storage-contracts/dist/workflow-loop-format1.js.map +1 -0
  668. package/lib/storage-contracts/dist/workflow-saga-format1.d.ts +52 -0
  669. package/lib/storage-contracts/dist/workflow-saga-format1.d.ts.map +1 -0
  670. package/lib/storage-contracts/dist/workflow-saga-format1.js +235 -0
  671. package/lib/storage-contracts/dist/workflow-saga-format1.js.map +1 -0
  672. package/lib/storage-contracts/dist/workflow-tree-contracts.d.ts +428 -0
  673. package/lib/storage-contracts/dist/workflow-tree-contracts.d.ts.map +1 -0
  674. package/lib/storage-contracts/dist/workflow-tree-contracts.js +151 -0
  675. package/lib/storage-contracts/dist/workflow-tree-contracts.js.map +1 -0
  676. package/lib/storage-contracts/dist/workflow-tree-discovery.d.ts +38 -0
  677. package/lib/storage-contracts/dist/workflow-tree-discovery.d.ts.map +1 -0
  678. package/lib/storage-contracts/dist/workflow-tree-discovery.js +57 -0
  679. package/lib/storage-contracts/dist/workflow-tree-discovery.js.map +1 -0
  680. package/lib/storage-contracts/package.json +5 -0
  681. package/lib/storage-contracts/src/contracts.ts +73 -0
  682. package/lib/storage-contracts/src/durable-budget-contracts.ts +266 -0
  683. package/lib/storage-contracts/src/execution-wait-contracts.ts +169 -0
  684. package/lib/storage-contracts/src/index.ts +17 -0
  685. package/lib/storage-contracts/src/memory-contracts.ts +322 -0
  686. package/lib/storage-contracts/src/scheduled-workflow-contracts.ts +88 -0
  687. package/lib/storage-contracts/src/scheduler-contracts.ts +68 -0
  688. package/lib/storage-contracts/src/submission-journal.ts +50 -0
  689. package/lib/storage-contracts/src/workflow-format2.ts +288 -0
  690. package/lib/storage-contracts/src/workflow-format3.ts +201 -0
  691. package/lib/storage-contracts/src/workflow-format4.ts +96 -0
  692. package/lib/storage-contracts/src/workflow-format5.ts +375 -0
  693. package/lib/storage-contracts/src/workflow-graph-contracts.ts +44 -0
  694. package/lib/storage-contracts/src/workflow-graph-discovery.ts +107 -0
  695. package/lib/storage-contracts/src/workflow-loop-format1.ts +102 -0
  696. package/lib/storage-contracts/src/workflow-saga-format1.ts +165 -0
  697. package/lib/storage-contracts/src/workflow-tree-contracts.ts +191 -0
  698. package/lib/storage-contracts/src/workflow-tree-discovery.ts +39 -0
  699. package/lib/storage-postgres/dist/index.d.ts +2 -0
  700. package/lib/storage-postgres/dist/index.d.ts.map +1 -0
  701. package/lib/storage-postgres/dist/index.js +2 -0
  702. package/lib/storage-postgres/dist/index.js.map +1 -0
  703. package/lib/storage-postgres/dist/postgres.d.ts +8 -0
  704. package/lib/storage-postgres/dist/postgres.d.ts.map +1 -0
  705. package/lib/storage-postgres/dist/postgres.js +233 -0
  706. package/lib/storage-postgres/dist/postgres.js.map +1 -0
  707. package/lib/storage-postgres/package.json +5 -0
  708. package/lib/storage-postgres/src/index.ts +1 -0
  709. package/lib/storage-postgres/src/postgres.ts +222 -0
  710. package/lib/storage-sql/dist/aggregate-session.d.ts +31 -0
  711. package/lib/storage-sql/dist/aggregate-session.d.ts.map +1 -0
  712. package/lib/storage-sql/dist/aggregate-session.js +78 -0
  713. package/lib/storage-sql/dist/aggregate-session.js.map +1 -0
  714. package/lib/storage-sql/dist/contracts.d.ts +2 -0
  715. package/lib/storage-sql/dist/contracts.d.ts.map +1 -0
  716. package/lib/storage-sql/dist/contracts.js +3 -0
  717. package/lib/storage-sql/dist/contracts.js.map +1 -0
  718. package/lib/storage-sql/dist/durable-budget-database.d.ts +33 -0
  719. package/lib/storage-sql/dist/durable-budget-database.d.ts.map +1 -0
  720. package/lib/storage-sql/dist/durable-budget-database.js +191 -0
  721. package/lib/storage-sql/dist/durable-budget-database.js.map +1 -0
  722. package/lib/storage-sql/dist/durable-budget-state.d.ts +24 -0
  723. package/lib/storage-sql/dist/durable-budget-state.d.ts.map +1 -0
  724. package/lib/storage-sql/dist/durable-budget-state.js +211 -0
  725. package/lib/storage-sql/dist/durable-budget-state.js.map +1 -0
  726. package/lib/storage-sql/dist/durable-budget-validation.d.ts +5 -0
  727. package/lib/storage-sql/dist/durable-budget-validation.d.ts.map +1 -0
  728. package/lib/storage-sql/dist/durable-budget-validation.js +22 -0
  729. package/lib/storage-sql/dist/durable-budget-validation.js.map +1 -0
  730. package/lib/storage-sql/dist/execution-completions.d.ts +12 -0
  731. package/lib/storage-sql/dist/execution-completions.d.ts.map +1 -0
  732. package/lib/storage-sql/dist/execution-completions.js +60 -0
  733. package/lib/storage-sql/dist/execution-completions.js.map +1 -0
  734. package/lib/storage-sql/dist/execution-wait-database.d.ts +22 -0
  735. package/lib/storage-sql/dist/execution-wait-database.d.ts.map +1 -0
  736. package/lib/storage-sql/dist/execution-wait-database.js +288 -0
  737. package/lib/storage-sql/dist/execution-wait-database.js.map +1 -0
  738. package/lib/storage-sql/dist/execution-wait-validation.d.ts +8 -0
  739. package/lib/storage-sql/dist/execution-wait-validation.d.ts.map +1 -0
  740. package/lib/storage-sql/dist/execution-wait-validation.js +125 -0
  741. package/lib/storage-sql/dist/execution-wait-validation.js.map +1 -0
  742. package/lib/storage-sql/dist/host.d.ts +22 -0
  743. package/lib/storage-sql/dist/host.d.ts.map +1 -0
  744. package/lib/storage-sql/dist/host.js +21 -0
  745. package/lib/storage-sql/dist/host.js.map +1 -0
  746. package/lib/storage-sql/dist/memory-database.d.ts +24 -0
  747. package/lib/storage-sql/dist/memory-database.d.ts.map +1 -0
  748. package/lib/storage-sql/dist/memory-database.js +359 -0
  749. package/lib/storage-sql/dist/memory-database.js.map +1 -0
  750. package/lib/storage-sql/dist/scheduled-database.d.ts +74 -0
  751. package/lib/storage-sql/dist/scheduled-database.d.ts.map +1 -0
  752. package/lib/storage-sql/dist/scheduled-database.js +1152 -0
  753. package/lib/storage-sql/dist/scheduled-database.js.map +1 -0
  754. package/lib/storage-sql/dist/scheduled-validation.d.ts +9 -0
  755. package/lib/storage-sql/dist/scheduled-validation.d.ts.map +1 -0
  756. package/lib/storage-sql/dist/scheduled-validation.js +200 -0
  757. package/lib/storage-sql/dist/scheduled-validation.js.map +1 -0
  758. package/lib/storage-sql/dist/scheduler-contracts.d.ts +2 -0
  759. package/lib/storage-sql/dist/scheduler-contracts.d.ts.map +1 -0
  760. package/lib/storage-sql/dist/scheduler-contracts.js +3 -0
  761. package/lib/storage-sql/dist/scheduler-contracts.js.map +1 -0
  762. package/lib/storage-sql/dist/scheduler-database.d.ts +55 -0
  763. package/lib/storage-sql/dist/scheduler-database.d.ts.map +1 -0
  764. package/lib/storage-sql/dist/scheduler-database.js +655 -0
  765. package/lib/storage-sql/dist/scheduler-database.js.map +1 -0
  766. package/lib/storage-sql/dist/scheduler-validation.d.ts +22 -0
  767. package/lib/storage-sql/dist/scheduler-validation.d.ts.map +1 -0
  768. package/lib/storage-sql/dist/scheduler-validation.js +201 -0
  769. package/lib/storage-sql/dist/scheduler-validation.js.map +1 -0
  770. package/lib/storage-sql/dist/validation.d.ts +14 -0
  771. package/lib/storage-sql/dist/validation.d.ts.map +1 -0
  772. package/lib/storage-sql/dist/validation.js +106 -0
  773. package/lib/storage-sql/dist/validation.js.map +1 -0
  774. package/lib/storage-sql/dist/workflow-graph-discovery-index.d.ts +7 -0
  775. package/lib/storage-sql/dist/workflow-graph-discovery-index.d.ts.map +1 -0
  776. package/lib/storage-sql/dist/workflow-graph-discovery-index.js +55 -0
  777. package/lib/storage-sql/dist/workflow-graph-discovery-index.js.map +1 -0
  778. package/lib/storage-sql/dist/workflow-graph-discovery-validation.d.ts +5 -0
  779. package/lib/storage-sql/dist/workflow-graph-discovery-validation.d.ts.map +1 -0
  780. package/lib/storage-sql/dist/workflow-graph-discovery-validation.js +22 -0
  781. package/lib/storage-sql/dist/workflow-graph-discovery-validation.js.map +1 -0
  782. package/lib/storage-sql/dist/workflow-tree-database.d.ts +270 -0
  783. package/lib/storage-sql/dist/workflow-tree-database.d.ts.map +1 -0
  784. package/lib/storage-sql/dist/workflow-tree-database.js +1692 -0
  785. package/lib/storage-sql/dist/workflow-tree-database.js.map +1 -0
  786. package/lib/storage-sql/dist/workflow-tree-discovery-validation.d.ts +5 -0
  787. package/lib/storage-sql/dist/workflow-tree-discovery-validation.d.ts.map +1 -0
  788. package/lib/storage-sql/dist/workflow-tree-discovery-validation.js +15 -0
  789. package/lib/storage-sql/dist/workflow-tree-discovery-validation.js.map +1 -0
  790. package/lib/storage-sql/dist/workflow-tree-validation.d.ts +9 -0
  791. package/lib/storage-sql/dist/workflow-tree-validation.d.ts.map +1 -0
  792. package/lib/storage-sql/dist/workflow-tree-validation.js +576 -0
  793. package/lib/storage-sql/dist/workflow-tree-validation.js.map +1 -0
  794. package/lib/storage-sql/package.json +5 -0
  795. package/lib/storage-sql/src/aggregate-session.ts +72 -0
  796. package/lib/storage-sql/src/contracts.ts +2 -0
  797. package/lib/storage-sql/src/durable-budget-database.ts +180 -0
  798. package/lib/storage-sql/src/durable-budget-state.ts +155 -0
  799. package/lib/storage-sql/src/durable-budget-validation.ts +23 -0
  800. package/lib/storage-sql/src/execution-completions.ts +58 -0
  801. package/lib/storage-sql/src/execution-wait-database.ts +219 -0
  802. package/lib/storage-sql/src/execution-wait-validation.ts +108 -0
  803. package/lib/storage-sql/src/host.ts +21 -0
  804. package/lib/storage-sql/src/memory-database.ts +320 -0
  805. package/lib/storage-sql/src/scheduled-database.ts +811 -0
  806. package/lib/storage-sql/src/scheduled-validation.ts +89 -0
  807. package/lib/storage-sql/src/scheduler-contracts.ts +2 -0
  808. package/lib/storage-sql/src/scheduler-database.ts +475 -0
  809. package/lib/storage-sql/src/scheduler-validation.ts +112 -0
  810. package/lib/storage-sql/src/validation.ts +104 -0
  811. package/lib/storage-sql/src/workflow-graph-discovery-index.ts +60 -0
  812. package/lib/storage-sql/src/workflow-graph-discovery-validation.ts +21 -0
  813. package/lib/storage-sql/src/workflow-tree-database.ts +450 -0
  814. package/lib/storage-sql/src/workflow-tree-discovery-validation.ts +13 -0
  815. package/lib/storage-sql/src/workflow-tree-validation.ts +166 -0
  816. package/lib/storage-sqlite/dist/backup.d.ts +24 -0
  817. package/lib/storage-sqlite/dist/backup.d.ts.map +1 -0
  818. package/lib/storage-sqlite/dist/backup.js +84 -0
  819. package/lib/storage-sqlite/dist/backup.js.map +1 -0
  820. package/lib/storage-sqlite/dist/index.d.ts +4 -0
  821. package/lib/storage-sqlite/dist/index.d.ts.map +1 -0
  822. package/lib/storage-sqlite/dist/index.js +4 -0
  823. package/lib/storage-sqlite/dist/index.js.map +1 -0
  824. package/lib/storage-sqlite/dist/migrations.d.ts +6 -0
  825. package/lib/storage-sqlite/dist/migrations.d.ts.map +1 -0
  826. package/lib/storage-sqlite/dist/migrations.js +50 -0
  827. package/lib/storage-sqlite/dist/migrations.js.map +1 -0
  828. package/lib/storage-sqlite/dist/sqlite-database.d.ts +36 -0
  829. package/lib/storage-sqlite/dist/sqlite-database.d.ts.map +1 -0
  830. package/lib/storage-sqlite/dist/sqlite-database.js +179 -0
  831. package/lib/storage-sqlite/dist/sqlite-database.js.map +1 -0
  832. package/lib/storage-sqlite/dist/sqlite-worker.d.ts +2 -0
  833. package/lib/storage-sqlite/dist/sqlite-worker.d.ts.map +1 -0
  834. package/lib/storage-sqlite/dist/sqlite-worker.js +95 -0
  835. package/lib/storage-sqlite/dist/sqlite-worker.js.map +1 -0
  836. package/lib/storage-sqlite/dist/sqlite.d.ts +7 -0
  837. package/lib/storage-sqlite/dist/sqlite.d.ts.map +1 -0
  838. package/lib/storage-sqlite/dist/sqlite.js +78 -0
  839. package/lib/storage-sqlite/dist/sqlite.js.map +1 -0
  840. package/lib/storage-sqlite/package.json +5 -0
  841. package/lib/storage-sqlite/src/backup.ts +58 -0
  842. package/lib/storage-sqlite/src/index.ts +3 -0
  843. package/lib/storage-sqlite/src/migrations.ts +46 -0
  844. package/lib/storage-sqlite/src/sqlite-database.ts +172 -0
  845. package/lib/storage-sqlite/src/sqlite-worker.ts +52 -0
  846. package/lib/storage-sqlite/src/sqlite.ts +72 -0
  847. package/lib/testing/dist/index.d.ts +10 -0
  848. package/lib/testing/dist/index.d.ts.map +1 -0
  849. package/lib/testing/dist/index.js +24 -0
  850. package/lib/testing/dist/index.js.map +1 -0
  851. package/lib/testing/package.json +5 -0
  852. package/lib/testing/src/index.ts +26 -0
  853. package/lib/tools/dist/batch.d.ts +71 -0
  854. package/lib/tools/dist/batch.d.ts.map +1 -0
  855. package/lib/tools/dist/batch.js +542 -0
  856. package/lib/tools/dist/batch.js.map +1 -0
  857. package/lib/tools/dist/budget-binding.d.ts +18 -0
  858. package/lib/tools/dist/budget-binding.d.ts.map +1 -0
  859. package/lib/tools/dist/budget-binding.js +65 -0
  860. package/lib/tools/dist/budget-binding.js.map +1 -0
  861. package/lib/tools/dist/context.d.ts +17 -0
  862. package/lib/tools/dist/context.d.ts.map +1 -0
  863. package/lib/tools/dist/context.js +52 -0
  864. package/lib/tools/dist/context.js.map +1 -0
  865. package/lib/tools/dist/host.d.ts +3 -0
  866. package/lib/tools/dist/host.d.ts.map +1 -0
  867. package/lib/tools/dist/host.js +3 -0
  868. package/lib/tools/dist/host.js.map +1 -0
  869. package/lib/tools/dist/index.d.ts +79 -0
  870. package/lib/tools/dist/index.d.ts.map +1 -0
  871. package/lib/tools/dist/index.js +462 -0
  872. package/lib/tools/dist/index.js.map +1 -0
  873. package/lib/tools/package.json +5 -0
  874. package/lib/tools/src/batch.ts +496 -0
  875. package/lib/tools/src/budget-binding.ts +63 -0
  876. package/lib/tools/src/context.ts +56 -0
  877. package/lib/tools/src/host.ts +2 -0
  878. package/lib/tools/src/index.ts +479 -0
  879. package/lib/workflows/dist/agents.d.ts +24 -0
  880. package/lib/workflows/dist/agents.d.ts.map +1 -0
  881. package/lib/workflows/dist/agents.js +55 -0
  882. package/lib/workflows/dist/agents.js.map +1 -0
  883. package/lib/workflows/dist/children-coordinator.d.ts +58 -0
  884. package/lib/workflows/dist/children-coordinator.d.ts.map +1 -0
  885. package/lib/workflows/dist/children-coordinator.js +148 -0
  886. package/lib/workflows/dist/children-coordinator.js.map +1 -0
  887. package/lib/workflows/dist/children-definition.d.ts +43 -0
  888. package/lib/workflows/dist/children-definition.d.ts.map +1 -0
  889. package/lib/workflows/dist/children-definition.js +74 -0
  890. package/lib/workflows/dist/children-definition.js.map +1 -0
  891. package/lib/workflows/dist/children-discovery.d.ts +20 -0
  892. package/lib/workflows/dist/children-discovery.d.ts.map +1 -0
  893. package/lib/workflows/dist/children-discovery.js +103 -0
  894. package/lib/workflows/dist/children-discovery.js.map +1 -0
  895. package/lib/workflows/dist/children-runtime.d.ts +72 -0
  896. package/lib/workflows/dist/children-runtime.d.ts.map +1 -0
  897. package/lib/workflows/dist/children-runtime.js +600 -0
  898. package/lib/workflows/dist/children-runtime.js.map +1 -0
  899. package/lib/workflows/dist/children.d.ts +9 -0
  900. package/lib/workflows/dist/children.d.ts.map +1 -0
  901. package/lib/workflows/dist/children.js +6 -0
  902. package/lib/workflows/dist/children.js.map +1 -0
  903. package/lib/workflows/dist/composite-fleet.d.ts +87 -0
  904. package/lib/workflows/dist/composite-fleet.d.ts.map +1 -0
  905. package/lib/workflows/dist/composite-fleet.js +259 -0
  906. package/lib/workflows/dist/composite-fleet.js.map +1 -0
  907. package/lib/workflows/dist/composite-host.d.ts +45 -0
  908. package/lib/workflows/dist/composite-host.d.ts.map +1 -0
  909. package/lib/workflows/dist/composite-host.js +132 -0
  910. package/lib/workflows/dist/composite-host.js.map +1 -0
  911. package/lib/workflows/dist/composites.d.ts +4 -0
  912. package/lib/workflows/dist/composites.d.ts.map +1 -0
  913. package/lib/workflows/dist/composites.js +3 -0
  914. package/lib/workflows/dist/composites.js.map +1 -0
  915. package/lib/workflows/dist/definition.d.ts +61 -0
  916. package/lib/workflows/dist/definition.d.ts.map +1 -0
  917. package/lib/workflows/dist/definition.js +112 -0
  918. package/lib/workflows/dist/definition.js.map +1 -0
  919. package/lib/workflows/dist/drain.d.ts +21 -0
  920. package/lib/workflows/dist/drain.d.ts.map +1 -0
  921. package/lib/workflows/dist/drain.js +53 -0
  922. package/lib/workflows/dist/drain.js.map +1 -0
  923. package/lib/workflows/dist/ephemeral.d.ts +24 -0
  924. package/lib/workflows/dist/ephemeral.d.ts.map +1 -0
  925. package/lib/workflows/dist/ephemeral.js +122 -0
  926. package/lib/workflows/dist/ephemeral.js.map +1 -0
  927. package/lib/workflows/dist/fleet-control.d.ts +129 -0
  928. package/lib/workflows/dist/fleet-control.d.ts.map +1 -0
  929. package/lib/workflows/dist/fleet-control.js +356 -0
  930. package/lib/workflows/dist/fleet-control.js.map +1 -0
  931. package/lib/workflows/dist/graph-coordinator.d.ts +60 -0
  932. package/lib/workflows/dist/graph-coordinator.d.ts.map +1 -0
  933. package/lib/workflows/dist/graph-coordinator.js +266 -0
  934. package/lib/workflows/dist/graph-coordinator.js.map +1 -0
  935. package/lib/workflows/dist/graph-definition.d.ts +40 -0
  936. package/lib/workflows/dist/graph-definition.d.ts.map +1 -0
  937. package/lib/workflows/dist/graph-definition.js +58 -0
  938. package/lib/workflows/dist/graph-definition.js.map +1 -0
  939. package/lib/workflows/dist/graph-discovery.d.ts +27 -0
  940. package/lib/workflows/dist/graph-discovery.d.ts.map +1 -0
  941. package/lib/workflows/dist/graph-discovery.js +165 -0
  942. package/lib/workflows/dist/graph-discovery.js.map +1 -0
  943. package/lib/workflows/dist/graphs.d.ts +55 -0
  944. package/lib/workflows/dist/graphs.d.ts.map +1 -0
  945. package/lib/workflows/dist/graphs.js +10 -0
  946. package/lib/workflows/dist/graphs.js.map +1 -0
  947. package/lib/workflows/dist/hook-relay.d.ts +67 -0
  948. package/lib/workflows/dist/hook-relay.d.ts.map +1 -0
  949. package/lib/workflows/dist/hook-relay.js +157 -0
  950. package/lib/workflows/dist/hook-relay.js.map +1 -0
  951. package/lib/workflows/dist/index.d.ts +16 -0
  952. package/lib/workflows/dist/index.d.ts.map +1 -0
  953. package/lib/workflows/dist/index.js +15 -0
  954. package/lib/workflows/dist/index.js.map +1 -0
  955. package/lib/workflows/dist/leadership.d.ts +33 -0
  956. package/lib/workflows/dist/leadership.d.ts.map +1 -0
  957. package/lib/workflows/dist/leadership.js +109 -0
  958. package/lib/workflows/dist/leadership.js.map +1 -0
  959. package/lib/workflows/dist/lifecycle-definition.d.ts +89 -0
  960. package/lib/workflows/dist/lifecycle-definition.d.ts.map +1 -0
  961. package/lib/workflows/dist/lifecycle-definition.js +137 -0
  962. package/lib/workflows/dist/lifecycle-definition.js.map +1 -0
  963. package/lib/workflows/dist/lifecycle-fleet.d.ts +90 -0
  964. package/lib/workflows/dist/lifecycle-fleet.d.ts.map +1 -0
  965. package/lib/workflows/dist/lifecycle-fleet.js +406 -0
  966. package/lib/workflows/dist/lifecycle-fleet.js.map +1 -0
  967. package/lib/workflows/dist/lifecycle-host.d.ts +44 -0
  968. package/lib/workflows/dist/lifecycle-host.d.ts.map +1 -0
  969. package/lib/workflows/dist/lifecycle-host.js +133 -0
  970. package/lib/workflows/dist/lifecycle-host.js.map +1 -0
  971. package/lib/workflows/dist/lifecycle-human-transport.d.ts +67 -0
  972. package/lib/workflows/dist/lifecycle-human-transport.d.ts.map +1 -0
  973. package/lib/workflows/dist/lifecycle-human-transport.js +149 -0
  974. package/lib/workflows/dist/lifecycle-human-transport.js.map +1 -0
  975. package/lib/workflows/dist/lifecycle-runtime.d.ts +115 -0
  976. package/lib/workflows/dist/lifecycle-runtime.d.ts.map +1 -0
  977. package/lib/workflows/dist/lifecycle-runtime.js +831 -0
  978. package/lib/workflows/dist/lifecycle-runtime.js.map +1 -0
  979. package/lib/workflows/dist/lifecycle.d.ts +10 -0
  980. package/lib/workflows/dist/lifecycle.d.ts.map +1 -0
  981. package/lib/workflows/dist/lifecycle.js +7 -0
  982. package/lib/workflows/dist/lifecycle.js.map +1 -0
  983. package/lib/workflows/dist/loop-definition.d.ts +46 -0
  984. package/lib/workflows/dist/loop-definition.d.ts.map +1 -0
  985. package/lib/workflows/dist/loop-definition.js +55 -0
  986. package/lib/workflows/dist/loop-definition.js.map +1 -0
  987. package/lib/workflows/dist/loop-runtime.d.ts +47 -0
  988. package/lib/workflows/dist/loop-runtime.d.ts.map +1 -0
  989. package/lib/workflows/dist/loop-runtime.js +358 -0
  990. package/lib/workflows/dist/loop-runtime.js.map +1 -0
  991. package/lib/workflows/dist/loops.d.ts +6 -0
  992. package/lib/workflows/dist/loops.d.ts.map +1 -0
  993. package/lib/workflows/dist/loops.js +4 -0
  994. package/lib/workflows/dist/loops.js.map +1 -0
  995. package/lib/workflows/dist/migration-service.d.ts +55 -0
  996. package/lib/workflows/dist/migration-service.d.ts.map +1 -0
  997. package/lib/workflows/dist/migration-service.js +73 -0
  998. package/lib/workflows/dist/migration-service.js.map +1 -0
  999. package/lib/workflows/dist/migration.d.ts +123 -0
  1000. package/lib/workflows/dist/migration.d.ts.map +1 -0
  1001. package/lib/workflows/dist/migration.js +217 -0
  1002. package/lib/workflows/dist/migration.js.map +1 -0
  1003. package/lib/workflows/dist/operator-transports.d.ts +265 -0
  1004. package/lib/workflows/dist/operator-transports.d.ts.map +1 -0
  1005. package/lib/workflows/dist/operator-transports.js +404 -0
  1006. package/lib/workflows/dist/operator-transports.js.map +1 -0
  1007. package/lib/workflows/dist/reconciliation.d.ts +25 -0
  1008. package/lib/workflows/dist/reconciliation.d.ts.map +1 -0
  1009. package/lib/workflows/dist/reconciliation.js +109 -0
  1010. package/lib/workflows/dist/reconciliation.js.map +1 -0
  1011. package/lib/workflows/dist/runtime.d.ts +65 -0
  1012. package/lib/workflows/dist/runtime.d.ts.map +1 -0
  1013. package/lib/workflows/dist/runtime.js +492 -0
  1014. package/lib/workflows/dist/runtime.js.map +1 -0
  1015. package/lib/workflows/dist/saga-definition.d.ts +46 -0
  1016. package/lib/workflows/dist/saga-definition.d.ts.map +1 -0
  1017. package/lib/workflows/dist/saga-definition.js +71 -0
  1018. package/lib/workflows/dist/saga-definition.js.map +1 -0
  1019. package/lib/workflows/dist/saga-runtime.d.ts +51 -0
  1020. package/lib/workflows/dist/saga-runtime.d.ts.map +1 -0
  1021. package/lib/workflows/dist/saga-runtime.js +499 -0
  1022. package/lib/workflows/dist/saga-runtime.js.map +1 -0
  1023. package/lib/workflows/dist/sagas.d.ts +6 -0
  1024. package/lib/workflows/dist/sagas.d.ts.map +1 -0
  1025. package/lib/workflows/dist/sagas.js +4 -0
  1026. package/lib/workflows/dist/sagas.js.map +1 -0
  1027. package/lib/workflows/dist/scheduled-helpers.d.ts +53 -0
  1028. package/lib/workflows/dist/scheduled-helpers.d.ts.map +1 -0
  1029. package/lib/workflows/dist/scheduled-helpers.js +230 -0
  1030. package/lib/workflows/dist/scheduled-helpers.js.map +1 -0
  1031. package/lib/workflows/dist/scheduled.d.ts +116 -0
  1032. package/lib/workflows/dist/scheduled.d.ts.map +1 -0
  1033. package/lib/workflows/dist/scheduled.js +781 -0
  1034. package/lib/workflows/dist/scheduled.js.map +1 -0
  1035. package/lib/workflows/dist/traces.d.ts +158 -0
  1036. package/lib/workflows/dist/traces.d.ts.map +1 -0
  1037. package/lib/workflows/dist/traces.js +366 -0
  1038. package/lib/workflows/dist/traces.js.map +1 -0
  1039. package/lib/workflows/dist/versions.d.ts +57 -0
  1040. package/lib/workflows/dist/versions.d.ts.map +1 -0
  1041. package/lib/workflows/dist/versions.js +87 -0
  1042. package/lib/workflows/dist/versions.js.map +1 -0
  1043. package/lib/workflows/dist/worker.d.ts +51 -0
  1044. package/lib/workflows/dist/worker.d.ts.map +1 -0
  1045. package/lib/workflows/dist/worker.js +143 -0
  1046. package/lib/workflows/dist/worker.js.map +1 -0
  1047. package/lib/workflows/package.json +5 -0
  1048. package/lib/workflows/src/agents.ts +65 -0
  1049. package/lib/workflows/src/children-coordinator.ts +50 -0
  1050. package/lib/workflows/src/children-definition.ts +88 -0
  1051. package/lib/workflows/src/children-discovery.ts +32 -0
  1052. package/lib/workflows/src/children-runtime.ts +169 -0
  1053. package/lib/workflows/src/children.ts +12 -0
  1054. package/lib/workflows/src/composite-fleet.ts +155 -0
  1055. package/lib/workflows/src/composite-host.ts +67 -0
  1056. package/lib/workflows/src/composites.ts +6 -0
  1057. package/lib/workflows/src/definition.ts +113 -0
  1058. package/lib/workflows/src/drain.ts +56 -0
  1059. package/lib/workflows/src/ephemeral.ts +124 -0
  1060. package/lib/workflows/src/fleet-control.ts +326 -0
  1061. package/lib/workflows/src/graph-coordinator.ts +223 -0
  1062. package/lib/workflows/src/graph-definition.ts +70 -0
  1063. package/lib/workflows/src/graph-discovery.ts +145 -0
  1064. package/lib/workflows/src/graphs.ts +56 -0
  1065. package/lib/workflows/src/hook-relay.ts +177 -0
  1066. package/lib/workflows/src/index.ts +27 -0
  1067. package/lib/workflows/src/leadership.ts +102 -0
  1068. package/lib/workflows/src/lifecycle-definition.ts +194 -0
  1069. package/lib/workflows/src/lifecycle-fleet.ts +346 -0
  1070. package/lib/workflows/src/lifecycle-host.ts +109 -0
  1071. package/lib/workflows/src/lifecycle-human-transport.ts +170 -0
  1072. package/lib/workflows/src/lifecycle-runtime.ts +673 -0
  1073. package/lib/workflows/src/lifecycle.ts +59 -0
  1074. package/lib/workflows/src/loop-definition.ts +62 -0
  1075. package/lib/workflows/src/loop-runtime.ts +260 -0
  1076. package/lib/workflows/src/loops.ts +7 -0
  1077. package/lib/workflows/src/migration-service.ts +83 -0
  1078. package/lib/workflows/src/migration.ts +242 -0
  1079. package/lib/workflows/src/operator-transports.ts +439 -0
  1080. package/lib/workflows/src/reconciliation.ts +121 -0
  1081. package/lib/workflows/src/runtime.ts +348 -0
  1082. package/lib/workflows/src/saga-definition.ts +104 -0
  1083. package/lib/workflows/src/saga-runtime.ts +406 -0
  1084. package/lib/workflows/src/sagas.ts +24 -0
  1085. package/lib/workflows/src/scheduled-helpers.ts +214 -0
  1086. package/lib/workflows/src/scheduled.ts +707 -0
  1087. package/lib/workflows/src/traces.ts +381 -0
  1088. package/lib/workflows/src/versions.ts +114 -0
  1089. package/lib/workflows/src/worker.ts +115 -0
  1090. package/lib/workstream/dist/executions.d.ts +34 -0
  1091. package/lib/workstream/dist/executions.d.ts.map +1 -0
  1092. package/lib/workstream/dist/executions.js +344 -0
  1093. package/lib/workstream/dist/executions.js.map +1 -0
  1094. package/lib/workstream/dist/humans.d.ts +76 -0
  1095. package/lib/workstream/dist/humans.d.ts.map +1 -0
  1096. package/lib/workstream/dist/humans.js +273 -0
  1097. package/lib/workstream/dist/humans.js.map +1 -0
  1098. package/lib/workstream/dist/index.d.ts +61 -0
  1099. package/lib/workstream/dist/index.d.ts.map +1 -0
  1100. package/lib/workstream/dist/index.js +310 -0
  1101. package/lib/workstream/dist/index.js.map +1 -0
  1102. package/lib/workstream/dist/timers.d.ts +41 -0
  1103. package/lib/workstream/dist/timers.d.ts.map +1 -0
  1104. package/lib/workstream/dist/timers.js +240 -0
  1105. package/lib/workstream/dist/timers.js.map +1 -0
  1106. package/lib/workstream/dist/webhooks.d.ts +69 -0
  1107. package/lib/workstream/dist/webhooks.d.ts.map +1 -0
  1108. package/lib/workstream/dist/webhooks.js +313 -0
  1109. package/lib/workstream/dist/webhooks.js.map +1 -0
  1110. package/lib/workstream/package.json +5 -0
  1111. package/lib/workstream/src/executions.ts +253 -0
  1112. package/lib/workstream/src/humans.ts +323 -0
  1113. package/lib/workstream/src/index.ts +279 -0
  1114. package/lib/workstream/src/timers.ts +212 -0
  1115. package/lib/workstream/src/webhooks.ts +180 -0
  1116. package/package.json +281 -0
@@ -0,0 +1,165 @@
1
+ import { jsonValue, MayuraError } from '../../core/dist/index.js';
2
+ import { StorageError, workflowGraphDiscoveryCommand, workflowGraphDiscoveryPage, workflowPolicy } from '../../storage-contracts/dist/index.js';
3
+ import { digest } from './definition.js';
4
+ import { scheduledCallback } from './scheduled-helpers.js';
5
+ const invalid = () => new MayuraError('INVALID_INPUT', 'Graph discovery requires exact bounded scan fields and a cursor matching its configured scope and policy.');
6
+ const unavailable = () => new MayuraError('STORAGE_UNAVAILABLE', 'Graph discovery could not confirm a valid observation page. Retry explicitly when storage is available.');
7
+ function object(value) {
8
+ if (!value || typeof value !== 'object' || Array.isArray(value))
9
+ throw invalid();
10
+ return value;
11
+ }
12
+ function positive(value, fallback, maximum) {
13
+ const result = value === undefined ? fallback : value;
14
+ if (typeof result !== 'number' || !Number.isSafeInteger(result) || result < 1 || result > maximum)
15
+ throw invalid();
16
+ return result;
17
+ }
18
+ /** Read only data descriptors; ordinary class methods retain their original receiver. */
19
+ function member(value, name) {
20
+ let current = value;
21
+ for (let depth = 0; current && depth < 16; depth++, current = Object.getPrototypeOf(current)) {
22
+ const field = Object.getOwnPropertyDescriptor(current, name);
23
+ if (field) {
24
+ if (!('value' in field))
25
+ throw invalid();
26
+ return field.value;
27
+ }
28
+ }
29
+ throw invalid();
30
+ }
31
+ function adapter(store) {
32
+ try {
33
+ if (!store || typeof store !== 'object')
34
+ throw invalid();
35
+ const source = member(store, 'workflowGraphDiscovery');
36
+ if (!source || typeof source !== 'object')
37
+ throw invalid();
38
+ const captured = {};
39
+ for (const name of ['initialize', 'scan']) {
40
+ const method = member(source, name);
41
+ if (typeof method !== 'function')
42
+ throw invalid();
43
+ captured[name] = (...args) => Reflect.apply(method, source, args);
44
+ }
45
+ return Object.freeze(captured);
46
+ }
47
+ catch {
48
+ throw new MayuraError('UNSUPPORTED_PROFILE', 'This adapter does not provide the optional graph discovery capability.');
49
+ }
50
+ }
51
+ function storageFailure(error) {
52
+ let code = 'STORAGE_UNAVAILABLE';
53
+ try {
54
+ const descriptor = error instanceof StorageError ? Object.getOwnPropertyDescriptor(error, 'code') : undefined;
55
+ const value = descriptor && 'value' in descriptor ? descriptor.value : undefined;
56
+ if (value === 'QUEUE_FULL')
57
+ code = 'LIMIT_EXCEEDED';
58
+ else if (value === 'INVALID_INPUT' || value === 'CONFLICT' || value === 'NOT_FOUND' || value === 'LIMIT_EXCEEDED')
59
+ code = value;
60
+ }
61
+ catch { /* Provider exceptions, getters and diagnostics never cross the public boundary. */ }
62
+ return new MayuraError(code, 'Graph discovery persistence could not confirm this scan. Retry explicitly after checking storage availability.');
63
+ }
64
+ /**
65
+ * Discover finite scoped graph continuation candidates without advancing their state.
66
+ * Cursors are plain metadata, not a stable database snapshot or authorization grant.
67
+ */
68
+ export function createWorkflowGraphDiscovery(options) {
69
+ let fields;
70
+ let policy;
71
+ let storageTimeoutMs;
72
+ let maxPending;
73
+ try {
74
+ if (!options || typeof options !== 'object' || ![Object.prototype, null].includes(Object.getPrototypeOf(options)))
75
+ throw invalid();
76
+ fields = Object.getOwnPropertyDescriptors(options);
77
+ const allowed = ['store', 'scope', 'permissions', 'policyVersion', 'maxCostMicros', 'maxOutputBytes', 'approvalTtlMs', 'storageTimeoutMs', 'maxPendingStorageOperations'];
78
+ if (Reflect.ownKeys(fields).some(name => typeof name !== 'string' || !allowed.includes(name))
79
+ || Object.values(fields).some(field => !field.enumerable || !('value' in field)))
80
+ throw invalid();
81
+ const raw = object(jsonValue({ scope: fields['scope']?.value, permissions: fields['permissions']?.value,
82
+ policyVersion: fields['policyVersion']?.value, maxCostMicros: fields['maxCostMicros']?.value,
83
+ maxOutputBytes: fields['maxOutputBytes']?.value === undefined ? 65_536 : fields['maxOutputBytes'].value,
84
+ approvalTtlMs: fields['approvalTtlMs']?.value === undefined ? 3_600_000 : fields['approvalTtlMs'].value }));
85
+ const permissions = object(raw['permissions']);
86
+ if (Object.keys(permissions).length !== 1 || !Object.hasOwn(permissions, 'allow'))
87
+ throw invalid();
88
+ policy = workflowPolicy({ ...raw, permissions: permissions['allow'] });
89
+ storageTimeoutMs = positive(fields['storageTimeoutMs']?.value, 10_000, 30_000);
90
+ maxPending = positive(fields['maxPendingStorageOperations']?.value, 64, 1_024);
91
+ }
92
+ catch {
93
+ throw new MayuraError('INVALID_CONFIG', 'Graph discovery requires explicit graph-compatible scope, permissions, policy and finite callback limits.');
94
+ }
95
+ const api = adapter(fields['store']?.value);
96
+ const scope = digest('mayura:scope:v1', policy.scope);
97
+ const policyHash = digest('mayura:policy:v1', { ...policy, permissions: [...policy.permissions].sort() });
98
+ const shutdown = new AbortController();
99
+ let pending = 0;
100
+ let initialized;
101
+ const open = () => { if (shutdown.signal.aborted)
102
+ throw new MayuraError('CANCELLED', 'The graph discovery facade is closed.'); };
103
+ /** Only actual settlement returns capacity, including after local timeout or close. */
104
+ const call = async (operation) => {
105
+ open();
106
+ if (pending >= maxPending)
107
+ throw new MayuraError('LIMIT_EXCEEDED', 'The bounded graph discovery callback capacity is occupied.');
108
+ pending++;
109
+ const actual = Promise.resolve().then(() => { open(); return operation(); }).finally(() => { pending--; });
110
+ // A synchronous close can abort scheduledCallback before its microtask adopts
111
+ // actual. Observe rejection eagerly; only actual settlement releases capacity.
112
+ void actual.catch(() => { });
113
+ try {
114
+ return await scheduledCallback(() => actual, storageTimeoutMs, shutdown.signal);
115
+ }
116
+ catch (error) {
117
+ open();
118
+ throw storageFailure(error);
119
+ }
120
+ };
121
+ const initialize = async () => {
122
+ open();
123
+ initialized ??= (async () => {
124
+ if (await call(() => api.initialize()) !== undefined)
125
+ throw unavailable();
126
+ open();
127
+ })().catch((error) => { initialized = undefined; throw error; });
128
+ await initialized;
129
+ open();
130
+ };
131
+ return Object.freeze({
132
+ cursorAfter(runId) {
133
+ if (typeof runId !== 'string' || !/^[a-f0-9]{64}$/.test(runId))
134
+ throw invalid();
135
+ return Object.freeze({ format: 1, scope, policyHash, afterId: runId });
136
+ },
137
+ async scan(command = {}) {
138
+ open();
139
+ let admitted;
140
+ try {
141
+ // Own caller data before initialization or any other asynchronous callback.
142
+ const raw = object(jsonValue(command, { maxBytes: 1_024 }));
143
+ if (Object.keys(raw).some(name => name !== 'cursor' && name !== 'limit'))
144
+ throw invalid();
145
+ admitted = workflowGraphDiscoveryCommand('scan', { scope, policyHash,
146
+ cursor: Object.hasOwn(raw, 'cursor') ? raw['cursor'] : null,
147
+ limit: Object.hasOwn(raw, 'limit') ? raw['limit'] : 16 });
148
+ }
149
+ catch {
150
+ throw invalid();
151
+ }
152
+ await initialize();
153
+ const raw = await call(() => api.scan(admitted));
154
+ open();
155
+ try {
156
+ return workflowGraphDiscoveryPage(raw, admitted);
157
+ }
158
+ catch {
159
+ throw unavailable();
160
+ }
161
+ },
162
+ async close() { shutdown.abort(); },
163
+ });
164
+ }
165
+ //# sourceMappingURL=graph-discovery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"graph-discovery.js","sourceRoot":"","sources":["../src/graph-discovery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,WAAW,EAAmD,MAAM,cAAc,CAAC;AACvG,OA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,KAAK,EAAE,CAAC,CAAC,CAAC;KACnD,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { jsonValue, MayuraError, type ErrorCode, type JsonObject, type JsonValue } from '@mayura/core';\nimport { StorageError, workflowGraphDiscoveryCommand, workflowGraphDiscoveryPage, workflowPolicy,\n type WorkflowGraphDiscoveryAggregateStore, type WorkflowGraphDiscoveryCursor, type WorkflowGraphDiscoveryPage,\n type WorkflowGraphDiscoveryScan, type WorkflowGraphDiscoveryStore } from '@mayura/storage-contracts';\nimport { digest } from './definition.js';\nimport { scheduledCallback } from './scheduled-helpers.js';\nimport type { WorkflowRuntimeOptions } from './runtime.js';\n\nexport type { WorkflowGraphDiscoveryCandidate, WorkflowGraphDiscoveryCursor, WorkflowGraphDiscoveryPage } from '@mayura/storage-contracts';\n\nexport interface WorkflowGraphDiscoveryOptions extends Pick<WorkflowRuntimeOptions,\n 'scope' | 'permissions' | 'policyVersion' | 'maxCostMicros' | 'maxOutputBytes' | 'approvalTtlMs'> {\n readonly store: WorkflowGraphDiscoveryAggregateStore;\n /** Bounds the acknowledgement wait, not the adapter's actual callback lifetime. */\n readonly storageTimeoutMs?: number;\n /** Timed-out callbacks keep these slots until their underlying promises settle. */\n readonly maxPendingStorageOperations?: number;\n}\nexport interface WorkflowGraphDiscovery {\n /** One finite page of examined owners; candidates are hints, never dispatch authority. */\n scan(command?: { readonly cursor?: WorkflowGraphDiscoveryCursor | null; readonly limit?: number }): Promise<WorkflowGraphDiscoveryPage>;\n /** The cursor that continues a scan after `runId`, for callers that persist only the last run id. */\n cursorAfter(runId: string): WorkflowGraphDiscoveryCursor;\n /** Stops this facade without closing caller-owned storage or changing durable executions. */\n close(): Promise<void>;\n}\n\nconst invalid = (): MayuraError => new MayuraError('INVALID_INPUT', 'Graph discovery requires exact bounded scan fields and a cursor matching its configured scope and policy.');\nconst unavailable = (): MayuraError => new MayuraError('STORAGE_UNAVAILABLE', 'Graph discovery could not confirm a valid observation page. Retry explicitly when storage is available.');\nfunction object(value: JsonValue): JsonObject {\n if (!value || typeof value !== 'object' || Array.isArray(value)) throw invalid();\n return value;\n}\nfunction positive(value: unknown, fallback: number, maximum: number): number {\n const result = value === undefined ? fallback : value;\n if (typeof result !== 'number' || !Number.isSafeInteger(result) || result < 1 || result > maximum) throw invalid();\n return result;\n}\n\n/** Read only data descriptors; ordinary class methods retain their original receiver. */\nfunction member(value: object, name: string): unknown {\n let current: object | null = value;\n for (let depth = 0; current && depth < 16; depth++, current = Object.getPrototypeOf(current) as object | null) {\n const field = Object.getOwnPropertyDescriptor(current, name);\n if (field) { if (!('value' in field)) throw invalid(); return field.value; }\n }\n throw invalid();\n}\nfunction adapter(store: unknown): WorkflowGraphDiscoveryStore {\n try {\n if (!store || typeof store !== 'object') throw invalid();\n const source = member(store, 'workflowGraphDiscovery');\n if (!source || typeof source !== 'object') throw invalid();\n const captured: Record<string, (...args: unknown[]) => unknown> = {};\n for (const name of ['initialize', 'scan'] as const) {\n const method = member(source, name); if (typeof method !== 'function') throw invalid();\n captured[name] = (...args: unknown[]) => Reflect.apply(method, source, args);\n }\n return Object.freeze(captured) as unknown as WorkflowGraphDiscoveryStore;\n } catch { throw new MayuraError('UNSUPPORTED_PROFILE', 'This adapter does not provide the optional graph discovery capability.'); }\n}\nfunction storageFailure(error: unknown): MayuraError {\n let code: ErrorCode = 'STORAGE_UNAVAILABLE';\n try {\n const descriptor = error instanceof StorageError ? Object.getOwnPropertyDescriptor(error, 'code') : undefined;\n const value: unknown = descriptor && 'value' in descriptor ? descriptor.value : undefined;\n if (value === 'QUEUE_FULL') code = 'LIMIT_EXCEEDED';\n else if (value === 'INVALID_INPUT' || value === 'CONFLICT' || value === 'NOT_FOUND' || value === 'LIMIT_EXCEEDED') code = value;\n } catch { /* Provider exceptions, getters and diagnostics never cross the public boundary. */ }\n return new MayuraError(code, 'Graph discovery persistence could not confirm this scan. Retry explicitly after checking storage availability.');\n}\n\n/**\n * Discover finite scoped graph continuation candidates without advancing their state.\n * Cursors are plain metadata, not a stable database snapshot or authorization grant.\n */\nexport function createWorkflowGraphDiscovery(options: WorkflowGraphDiscoveryOptions): WorkflowGraphDiscovery {\n let fields: PropertyDescriptorMap; let policy: ReturnType<typeof workflowPolicy>;\n let storageTimeoutMs: number; let maxPending: number;\n try {\n if (!options || typeof options !== 'object' || ![Object.prototype, null].includes(Object.getPrototypeOf(options))) throw invalid();\n fields = Object.getOwnPropertyDescriptors(options);\n const allowed = ['store', 'scope', 'permissions', 'policyVersion', 'maxCostMicros', 'maxOutputBytes', 'approvalTtlMs', 'storageTimeoutMs', 'maxPendingStorageOperations'];\n if (Reflect.ownKeys(fields).some(name => typeof name !== 'string' || !allowed.includes(name))\n || Object.values(fields).some(field => !field.enumerable || !('value' in field))) throw invalid();\n const raw = object(jsonValue({ scope: fields['scope']?.value, permissions: fields['permissions']?.value,\n policyVersion: fields['policyVersion']?.value, maxCostMicros: fields['maxCostMicros']?.value,\n maxOutputBytes: fields['maxOutputBytes']?.value === undefined ? 65_536 : fields['maxOutputBytes'].value,\n approvalTtlMs: fields['approvalTtlMs']?.value === undefined ? 3_600_000 : fields['approvalTtlMs'].value }));\n const permissions = object(raw['permissions']!);\n if (Object.keys(permissions).length !== 1 || !Object.hasOwn(permissions, 'allow')) throw invalid();\n policy = workflowPolicy({ ...raw, permissions: permissions['allow'] });\n storageTimeoutMs = positive(fields['storageTimeoutMs']?.value, 10_000, 30_000);\n maxPending = positive(fields['maxPendingStorageOperations']?.value, 64, 1_024);\n } catch { throw new MayuraError('INVALID_CONFIG', 'Graph discovery requires explicit graph-compatible scope, permissions, policy and finite callback limits.'); }\n const api = adapter(fields['store']?.value);\n const scope = digest('mayura:scope:v1', policy.scope);\n const policyHash = digest('mayura:policy:v1', { ...policy, permissions: [...policy.permissions].sort() });\n const shutdown = new AbortController(); let pending = 0; let initialized: Promise<void> | undefined;\n const open = (): void => { if (shutdown.signal.aborted) throw new MayuraError('CANCELLED', 'The graph discovery facade is closed.'); };\n\n /** Only actual settlement returns capacity, including after local timeout or close. */\n const call = async <T>(operation: () => Promise<T>): Promise<T> => {\n open();\n if (pending >= maxPending) throw new MayuraError('LIMIT_EXCEEDED', 'The bounded graph discovery callback capacity is occupied.');\n pending++;\n const actual = Promise.resolve().then(() => { open(); return operation(); }).finally(() => { pending--; });\n // A synchronous close can abort scheduledCallback before its microtask adopts\n // actual. Observe rejection eagerly; only actual settlement releases capacity.\n void actual.catch(() => {});\n try { return await scheduledCallback(() => actual, storageTimeoutMs, shutdown.signal); }\n catch (error) { open(); throw storageFailure(error); }\n };\n const initialize = async (): Promise<void> => {\n open();\n initialized ??= (async () => {\n if (await call(() => api.initialize()) !== undefined) throw unavailable();\n open();\n })().catch((error: unknown) => { initialized = undefined; throw error; });\n await initialized; open();\n };\n\n return Object.freeze<WorkflowGraphDiscovery>({\n cursorAfter(runId: string): WorkflowGraphDiscoveryCursor {\n if (typeof runId !== 'string' || !/^[a-f0-9]{64}$/.test(runId)) throw invalid();\n return Object.freeze({ format: 1, scope, policyHash, afterId: runId }) as WorkflowGraphDiscoveryCursor;\n },\n async scan(command = {}): Promise<WorkflowGraphDiscoveryPage> {\n open(); let admitted: WorkflowGraphDiscoveryScan;\n try {\n // Own caller data before initialization or any other asynchronous callback.\n const raw = object(jsonValue(command, { maxBytes: 1_024 }));\n if (Object.keys(raw).some(name => name !== 'cursor' && name !== 'limit')) throw invalid();\n admitted = workflowGraphDiscoveryCommand('scan', { scope, policyHash,\n cursor: Object.hasOwn(raw, 'cursor') ? raw['cursor'] : null,\n limit: Object.hasOwn(raw, 'limit') ? raw['limit'] : 16 }) as unknown as WorkflowGraphDiscoveryScan;\n } catch { throw invalid(); }\n await initialize();\n const raw = await call(() => api.scan(admitted)); open();\n try { return workflowGraphDiscoveryPage(raw, admitted); }\n catch { throw unavailable(); }\n },\n async close(): Promise<void> { shutdown.abort(); },\n });\n}\n"]}
@@ -0,0 +1,55 @@
1
+ import type { InferInput, Schema } from '../../core/dist/index.js';
2
+ import type { ExecutionRef, WorkflowGraphAggregateStore, WorkflowGraphFormat3Step } from '../../storage-contracts/dist/index.js';
3
+ import { type ReconcileExternalEffectCommand, type ScheduledWorkflowRuntimeOptions } from './scheduled.js';
4
+ import type { WorkflowSnapshot } from './runtime.js';
5
+ import type { WorkflowDrainOptions, WorkflowDrainReport } from './drain.js';
6
+ export type { WorkflowDrainOptions, WorkflowDrainReport } from './drain.js';
7
+ import type { AnyWorkflowGraph, WorkflowGraphDefinition } from './graph-definition.js';
8
+ import type { MigrationCommand, WorkflowMigration, WorkflowMigrationResult } from './migration.js';
9
+ export { defineWorkflowGraph, type WorkflowGraphDefinition, type WorkflowGraphOptions, type WorkflowGraphNode, type WorkflowGraphTargetBinding, type WorkflowGraphOutput } from './graph-definition.js';
10
+ export { createWorkflowGraphDiscovery, type WorkflowGraphDiscovery, type WorkflowGraphDiscoveryOptions, type WorkflowGraphDiscoveryCandidate, type WorkflowGraphDiscoveryCursor, type WorkflowGraphDiscoveryPage } from './graph-discovery.js';
11
+ export { createWorkflowGraphCoordinator, type WorkflowGraphCoordinator, type WorkflowGraphCoordinatorOptions, type WorkflowGraphCatalogEntry, type WorkflowGraphPageReport, type WorkflowGraphCandidateOutcome } from './graph-coordinator.js';
12
+ export interface WorkflowGraphSnapshot extends Omit<WorkflowSnapshot, 'steps'> {
13
+ readonly steps: Readonly<Record<string, Readonly<WorkflowGraphFormat3Step>>>;
14
+ }
15
+ export interface WorkflowGraphRuntimeOptions extends Omit<ScheduledWorkflowRuntimeOptions, 'store'> {
16
+ readonly store: WorkflowGraphAggregateStore;
17
+ }
18
+ export interface WorkflowGraphRuntime {
19
+ readonly profile: 'scheduled-v2';
20
+ submit<I extends Schema, O extends Schema>(definition: WorkflowGraphDefinition<I, O>, command: {
21
+ readonly input: InferInput<I>;
22
+ readonly idempotencyKey: string;
23
+ }): Promise<WorkflowGraphSnapshot>;
24
+ inspect(id: string): Promise<WorkflowGraphSnapshot>;
25
+ /** Exact scoped metadata, not an authorization capability or backend identity proof. */
26
+ reference(id: string): Promise<ExecutionRef>;
27
+ events(id: string, after?: number): ReturnType<WorkflowGraphAggregateStore['events']>;
28
+ runUntilSettled(definition: AnyWorkflowGraph, id: string): Promise<WorkflowGraphSnapshot>;
29
+ reconcile(definition: AnyWorkflowGraph, command: ReconcileExternalEffectCommand): Promise<WorkflowGraphSnapshot>;
30
+ approve(command: {
31
+ readonly id: string;
32
+ readonly nodeId: string;
33
+ readonly digest: string;
34
+ readonly credential: unknown;
35
+ }): Promise<WorkflowGraphSnapshot>;
36
+ cancel(id: string): Promise<WorkflowGraphSnapshot>;
37
+ /** Persist a quiescent operator pause; claimed or in-flight effects must settle or be recovered first. */
38
+ pause(id: string): Promise<WorkflowGraphSnapshot>;
39
+ /** Resume scheduling only; unresolved waits and approvals remain unresolved. */
40
+ resume(id: string): Promise<WorkflowGraphSnapshot>;
41
+ /**
42
+ * Plan (dryRun) or apply a reviewed migration of a paused graph run. Both definitions must be registered with this
43
+ * worker; storage re-verifies wait targets and scheduler history inside its transaction. The run stays paused.
44
+ */
45
+ migrate(migration: WorkflowMigration<AnyWorkflowGraph, AnyWorkflowGraph>, command: MigrationCommand): Promise<WorkflowMigrationResult<WorkflowGraphSnapshot>>;
46
+ recoverExpired(id: string): Promise<WorkflowGraphSnapshot>;
47
+ /** Stop this finite driver without cancelling durable waits or closing caller-owned storage. */
48
+ close(): Promise<void>;
49
+ /** Claim no new work, let admitted effects and receipts settle within the deadline, then close. */
50
+ drain(options?: WorkflowDrainOptions): Promise<WorkflowDrainReport>;
51
+ }
52
+ /** Opt in explicitly to format-3 graph waits; no fallback to legacy or unfenced execution. */
53
+ export declare function createWorkflowGraphRuntime(options: WorkflowGraphRuntimeOptions): WorkflowGraphRuntime;
54
+ export { defineWorkflowMigration, type WorkflowMigration, type WorkflowMigrationResult, type MigrationPlan, type MigrationCommand } from './migration.js';
55
+ //# sourceMappingURL=graphs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"graphs.d.ts","sourceRo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AE,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAC;IAC1J,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAC;IACnD,0GAA0G;IAC1G,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAC;IAClD,gFAAgF;IAChF,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAC;IACnD;;;OAGG;IACH,OAAO,CAAC,SAAS,EAAE,iBAAiB,CAAC,gBAAgB,EAAE,gBAAgB,CAAC,EAAE,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,uBAAuB,CAAC,qBAAqB,CAAC,CAAC,CAAC;IAC9J,cAAc,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAC;IAC3D,gGAAgG;IAChG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,mGAAmG;IACnG,KAAK,CAAC,OAAO,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;CACrE;AAED,8FAA8F;AAC9F,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,2BAA2B,GAAG,oBAAoB,CAErG;AACD,OAAO,EAAE,uBAAuB,EAAE,KAAK,iBAAiB,EAAE,KAAK,uBAAuB,EAAE,KAAK,aAAa,EAAE,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { createScheduledDriver } from './scheduled.js';
2
+ export { defineWorkflowGraph } from './graph-definition.js';
3
+ export { createWorkflowGraphDiscovery } from './graph-discovery.js';
4
+ export { createWorkflowGraphCoordinator } from './graph-coordinator.js';
5
+ /** Opt in explicitly to format-3 graph waits; no fallback to legacy or unfenced execution. */
6
+ export function createWorkflowGraphRuntime(options) {
7
+ return createScheduledDriver(options, 'scheduled-v2');
8
+ }
9
+ export { defineWorkflowMigration } from './migration.js';
10
+ //# sourceMappingURL=graphs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"graphs.js","sourceRoot":"","sources":["../src/graphs.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAA6E,MAAM,gBAAgB,CAAC;AAOlI,OAAO,EAAE,mBAAmB,EACyD,MAAM,uBAAuB,CAAC;AACnH,OAAO,EAAE,4BAA4B,EACuE,MAAM,sBAAsB,CAAC;AACzI,OAAO,EAAE,8BAA8B,EAC6D,MAAM,wBAAwB,CAAC;AAqCnI,8FAA8F;AAC9F,MAAM,UAAU,0BAA0B,CAAC,OAAoC;IAC7E,OAAO,qBAAqB,CAAC,OAAO,EAAE,cAAc,CAAyB,CAAC;AAChF,CAAC;AACD,OAAO,EAAE,uBAAuB,EAAmG,MAAM,gBAAgB,CAAC","sourcesContent":["import type { InferInput, Schema } from '@mayura/core';\nimport type { ExecutionRef, WorkflowGraphAggregateStore, WorkflowGraphFormat3Step } from '@mayura/storage-contracts';\nimport { createScheduledDriver, type ReconcileExternalEffectCommand, type ScheduledWorkflowRuntimeOptions } from './scheduled.js';\nimport type { WorkflowSnapshot } from './runtime.js';\nimport type { WorkflowDrainOptions, WorkflowDrainReport } from './drain.js';\nexport type { WorkflowDrainOptions, WorkflowDrainReport } from './drain.js';\nimport type { AnyWorkflowGraph, WorkflowGraphDefinition } from './graph-definition.js';\nimport type { MigrationCommand, WorkflowMigration, WorkflowMigrationResult } from './migration.js';\n\nexport { defineWorkflowGraph, type WorkflowGraphDefinition, type WorkflowGraphOptions,\n type WorkflowGraphNode, type WorkflowGraphTargetBinding, type WorkflowGraphOutput } from './graph-definition.js';\nexport { createWorkflowGraphDiscovery, type WorkflowGraphDiscovery, type WorkflowGraphDiscoveryOptions,\n type WorkflowGraphDiscoveryCandidate, type WorkflowGraphDiscoveryCursor, type WorkflowGraphDiscoveryPage } from './graph-discovery.js';\nexport { createWorkflowGraphCoordinator, type WorkflowGraphCoordinator, type WorkflowGraphCoordinatorOptions,\n type WorkflowGraphCatalogEntry, type WorkflowGraphPageReport, type WorkflowGraphCandidateOutcome } from './graph-coordinator.js';\n\nexport interface WorkflowGraphSnapshot extends Omit<WorkflowSnapshot, 'steps'> {\n readonly steps: Readonly<Record<string, Readonly<WorkflowGraphFormat3Step>>>;\n}\nexport interface WorkflowGraphRuntimeOptions extends Omit<ScheduledWorkflowRuntimeOptions, 'store'> {\n readonly store: WorkflowGraphAggregateStore;\n}\nexport interface WorkflowGraphRuntime {\n readonly profile: 'scheduled-v2';\n submit<I extends Schema, O extends Schema>(definition: WorkflowGraphDefinition<I, O>, command: {\n readonly input: InferInput<I>; readonly idempotencyKey: string;\n }): Promise<WorkflowGraphSnapshot>;\n inspect(id: string): Promise<WorkflowGraphSnapshot>;\n /** Exact scoped metadata, not an authorization capability or backend identity proof. */\n reference(id: string): Promise<ExecutionRef>;\n events(id: string, after?: number): ReturnType<WorkflowGraphAggregateStore['events']>;\n runUntilSettled(definition: AnyWorkflowGraph, id: string): Promise<WorkflowGraphSnapshot>;\n reconcile(definition: AnyWorkflowGraph, command: ReconcileExternalEffectCommand): Promise<WorkflowGraphSnapshot>;\n approve(command: { readonly id: string; readonly nodeId: string; readonly digest: string; readonly credential: unknown }): Promise<WorkflowGraphSnapshot>;\n cancel(id: string): Promise<WorkflowGraphSnapshot>;\n /** Persist a quiescent operator pause; claimed or in-flight effects must settle or be recovered first. */\n pause(id: string): Promise<WorkflowGraphSnapshot>;\n /** Resume scheduling only; unresolved waits and approvals remain unresolved. */\n resume(id: string): Promise<WorkflowGraphSnapshot>;\n /**\n * Plan (dryRun) or apply a reviewed migration of a paused graph run. Both definitions must be registered with this\n * worker; storage re-verifies wait targets and scheduler history inside its transaction. The run stays paused.\n */\n migrate(migration: WorkflowMigration<AnyWorkflowGraph, AnyWorkflowGraph>, command: MigrationCommand): Promise<WorkflowMigrationResult<WorkflowGraphSnapshot>>;\n recoverExpired(id: string): Promise<WorkflowGraphSnapshot>;\n /** Stop this finite driver without cancelling durable waits or closing caller-owned storage. */\n close(): Promise<void>;\n /** Claim no new work, let admitted effects and receipts settle within the deadline, then close. */\n drain(options?: WorkflowDrainOptions): Promise<WorkflowDrainReport>;\n}\n\n/** Opt in explicitly to format-3 graph waits; no fallback to legacy or unfenced execution. */\nexport function createWorkflowGraphRuntime(options: WorkflowGraphRuntimeOptions): WorkflowGraphRuntime {\n return createScheduledDriver(options, 'scheduled-v2') as WorkflowGraphRuntime;\n}\nexport { defineWorkflowMigration, type WorkflowMigration, type WorkflowMigrationResult, type MigrationPlan, type MigrationCommand } from './migration.js';\n"]}
@@ -0,0 +1,67 @@
1
+ import { type JsonObject, type LifecycleObserver, type Scope } from '../../core/dist/index.js';
2
+ import { type AggregateStore, type StoredEvent } from '../../storage-contracts/dist/index.js';
3
+ /** Durable lifecycle points delivered from a workflow run's stored event log. */
4
+ export type WorkflowHookStage = 'onWait' | 'onResume' | 'onApprovalRequested' | 'onApprovalResolved' | 'afterExecution' | 'onError' | 'onCancel' | 'onBlocked' | 'onFinally';
5
+ /** Metadata-only view of one stored event. `eventId` is the deduplication identity for at-least-once delivery. */
6
+ export interface WorkflowHookEvent {
7
+ readonly stage: WorkflowHookStage;
8
+ readonly runId: string;
9
+ readonly sequence: number;
10
+ /** `<relayId>:<runId>:<sequence>:<stage>`; stable across redelivery. */
11
+ readonly eventId: string;
12
+ /** The stored event type, for example `approval.requested` or `lifecycle.timer.fired`. */
13
+ readonly type: string;
14
+ readonly nodeId?: string;
15
+ /** Terminal status, present for terminal stages. */
16
+ readonly status?: string;
17
+ }
18
+ export type WorkflowHooks = {
19
+ readonly [S in WorkflowHookStage]?: LifecycleObserver<WorkflowHookEvent, S>;
20
+ } & {
21
+ readonly timeoutMs?: number;
22
+ };
23
+ /** Any workflow runtime: every format exposes its ordered durable log as `events(id, after)`. */
24
+ export interface WorkflowEventSource {
25
+ events(id: string, after?: number): Promise<readonly StoredEvent[]>;
26
+ }
27
+ export interface WorkflowHookRelayOptions {
28
+ readonly source: WorkflowEventSource;
29
+ /** Holds one delivery cursor per (relay, run). May be the same store the workflows use. */
30
+ readonly store: AggregateStore;
31
+ readonly scope: Scope;
32
+ /** Separates independent consumers of the same runs, for example `audit` and `notifications`. */
33
+ readonly relayId: string;
34
+ readonly hooks: WorkflowHooks;
35
+ }
36
+ export interface WorkflowHookDelivery {
37
+ /** Callbacks that completed during this call. */
38
+ readonly delivered: number;
39
+ /** Last stored event whose callbacks all completed; delivery resumes after it. */
40
+ readonly sequence: number;
41
+ /** Present when a callback failed; the next `deliver` retries this event. */
42
+ readonly failure?: {
43
+ readonly sequence: number;
44
+ readonly stage: WorkflowHookStage;
45
+ readonly code: string;
46
+ };
47
+ }
48
+ export interface WorkflowHookRelay {
49
+ /** Deliver callbacks for stored events after the durable cursor, in order, for at most `limit` events (default 1000). */
50
+ deliver(runId: string, options?: {
51
+ readonly signal?: AbortSignal;
52
+ readonly limit?: number;
53
+ }): Promise<WorkflowHookDelivery>;
54
+ /** The durable cursor for a run (0 before any delivery). */
55
+ cursor(runId: string): Promise<number>;
56
+ }
57
+ /** The callbacks one stored event produces, in order. Unrelated events produce none. */
58
+ export declare function workflowHookStages(type: string, data: JsonObject): readonly {
59
+ readonly stage: WorkflowHookStage;
60
+ readonly status?: string;
61
+ }[];
62
+ /**
63
+ * Durable, recoverable delivery of workflow lifecycle callbacks. Delivery is at-least-once: the cursor advances
64
+ * only after an event's callbacks complete, so a crash or failure redelivers from that event with the same `eventId`.
65
+ */
66
+ export declare function createWorkflowHookRelay(options: WorkflowHookRelayOptions): WorkflowHookRelay;
67
+ //# sourceMappingURL=hook-relay.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hook-relay.d.ts","sourceRoot":"","sources":["../src/hook-relay.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,UAAU,EAAE,KAAK,iBAAiB,EAAE,KAAK,KAAK,EAAE,MAAM,cAAc,CAAC;AAEhG,OAAO,EAAgB,KAAK,cAAc,EAAE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AAC,KAAK,EAAE,aAAa,CAAC;CAC/B;AACD,MAAM,WAAW,oBAAoB;IACnC,iDAAiD;IACjD,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,kFAAkF;IAClF,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,6EAA6E;IAC7E,QAAQ,CAAC,OAAO,CAAC,EAAE;QAAE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,KAAK,EAAE,iBAAiB,CAAC;QAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;CAC5G;AACD,MAAM,WAAW,iBAAiB;IAChC,yHAAyH;IACzH,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;QAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;IAC5H,4DAA4D;IAC5D,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CACxC;AAwBD,wFAAwF;AACxF,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,GAAG,SAAS;IAAE,QAAQ,CAAC,KAAK,EAAE,iBAAiB,CAAC;IAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,EAAE,CAQ7I;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,wBAAwB,GAAG,iBAAiB,CAwF5F"}
@@ -0,0 +1,157 @@
1
+ import { MayuraError } from '../../core/dist/index.js';
2
+ import { evaluateLifecycleObserver, snapshotHookOptions } from '../../core/dist/host.js';
3
+ import { StorageError } from '../../storage-contracts/dist/index.js';
4
+ import { digest } from './definition.js';
5
+ const stages = ['onWait', 'onResume', 'onApprovalRequested', 'onApprovalResolved', 'afterExecution', 'onError', 'onCancel', 'onBlocked', 'onFinally'];
6
+ const identifier = /^[A-Za-z0-9][A-Za-z0-9._:/-]{0,127}$/;
7
+ const eventStages = Object.freeze({
8
+ 'approval.requested': 'onApprovalRequested', 'lifecycle.approval.requested': 'onApprovalRequested',
9
+ 'approval.resolved': 'onApprovalResolved', 'lifecycle.approval.resolved': 'onApprovalResolved',
10
+ 'approval.expired': 'onApprovalResolved', 'lifecycle.approval.expired': 'onApprovalResolved',
11
+ 'wait.registered': 'onWait', 'run.waiting': 'onWait', 'lifecycle.run.waiting': 'onWait', 'workflow.waiting': 'onWait',
12
+ 'run.paused': 'onWait', 'lifecycle.run.paused': 'onWait', 'lifecycle.human.requested': 'onWait', 'lifecycle.timer.scheduled': 'onWait',
13
+ 'saga.forward.waiting': 'onWait', 'saga.compensation.waiting': 'onWait', 'loop.child.waiting': 'onWait',
14
+ 'wait.resolved': 'onResume', 'run.resumed': 'onResume', 'lifecycle.run.resumed': 'onResume',
15
+ 'lifecycle.human.responded': 'onResume', 'lifecycle.timer.fired': 'onResume',
16
+ });
17
+ /** Terminal events of every format; the value is the status used when the event data carries none. */
18
+ const terminalEvents = Object.freeze({
19
+ 'run.completed': 'unknown', 'lifecycle.run.completed': 'unknown', 'workflow.terminated': 'unknown',
20
+ 'run.cancelled': 'cancelled', 'lifecycle.run.cancelled': 'cancelled', 'saga.run.cancelled': 'cancelled', 'loop.run.cancelled': 'cancelled',
21
+ 'saga.run.succeeded': 'succeeded', 'loop.run.succeeded': 'succeeded',
22
+ 'saga.run.failed': 'failed', 'saga.run.compensated': 'compensated',
23
+ 'loop.output.rejected': 'failed', 'loop.condition.rejected': 'failed', 'loop.input.rejected': 'failed', 'loop.child.rejected': 'failed',
24
+ 'loop.child.failed': 'failed', 'loop.limit.exceeded': 'limit_exceeded',
25
+ });
26
+ /** The callbacks one stored event produces, in order. Unrelated events produce none. */
27
+ export function workflowHookStages(type, data) {
28
+ const stage = eventStages[type];
29
+ if (stage)
30
+ return [{ stage }];
31
+ const fallback = terminalEvents[type];
32
+ if (fallback === undefined)
33
+ return [];
34
+ const status = typeof data['status'] === 'string' && identifier.test(data['status']) ? data['status'] : fallback;
35
+ const terminal = status === 'succeeded' ? 'afterExecution' : status === 'cancelled' ? 'onCancel' : status === 'blocked' ? 'onBlocked' : 'onError';
36
+ return [{ stage: terminal, status }, { stage: 'onFinally', status }];
37
+ }
38
+ /**
39
+ * Durable, recoverable delivery of workflow lifecycle callbacks. Delivery is at-least-once: the cursor advances
40
+ * only after an event's callbacks complete, so a crash or failure redelivers from that event with the same `eventId`.
41
+ */
42
+ export function createWorkflowHookRelay(options) {
43
+ const { store, source } = options;
44
+ if (!store || typeof store.read !== 'function' || typeof store.create !== 'function' || typeof store.update !== 'function'
45
+ || !source || typeof source.events !== 'function' || typeof options.relayId !== 'string' || !identifier.test(options.relayId)
46
+ || typeof options.scope?.principalId !== 'string' || typeof options.scope?.projectId !== 'string') {
47
+ throw new MayuraError('INVALID_CONFIG', 'A workflow hook relay requires a store, an event source, a scope and a bounded relay identity.');
48
+ }
49
+ const { handlers, timeoutMs } = snapshotHookOptions(options.hooks, stages, 'Workflow hooks require callable handlers for known stages and a bounded timeout.');
50
+ const relayId = options.relayId;
51
+ const scope = digest('mayura:scope:v1', { principalId: options.scope.principalId, projectId: options.scope.projectId });
52
+ const cursorId = (runId) => digest('mayura:workflow-hook-relay:v1', { relayId, runId });
53
+ const guarded = async (operation) => {
54
+ try {
55
+ return await operation();
56
+ }
57
+ catch (error) {
58
+ if (error instanceof MayuraError || (error instanceof StorageError && error.code === 'CONFLICT'))
59
+ throw error;
60
+ throw new MayuraError('STORAGE_UNAVAILABLE', 'Workflow hook relay storage is unavailable.');
61
+ }
62
+ };
63
+ const read = async (runId) => {
64
+ const id = cursorId(runId);
65
+ const record = await guarded(() => store.read(scope, id));
66
+ if (!record)
67
+ return { sequence: 0 };
68
+ const state = record.state;
69
+ if (record.scope !== scope || record.id !== id || state['format'] !== 1 || state['relayId'] !== relayId || state['runId'] !== runId
70
+ || !Number.isSafeInteger(state['sequence']) || state['sequence'] < 0) {
71
+ throw new MayuraError('STORAGE_UNAVAILABLE', 'Stored hook relay cursor failed integrity validation.');
72
+ }
73
+ return { record, sequence: state['sequence'] };
74
+ };
75
+ /** Compare-and-set advance; a concurrent relay that got further wins and this one resumes from its cursor. */
76
+ const advance = async (runId, current, sequence) => {
77
+ const state = { format: 1, relayId, runId, sequence };
78
+ const event = { type: 'hook-relay.advanced', data: { sequence } };
79
+ try {
80
+ const record = current.record
81
+ ? await guarded(() => store.update({ scope, id: current.record.id, expectedVersion: current.record.version, state, events: [event] }))
82
+ : (await guarded(() => store.create({ scope, id: cursorId(runId), idempotencyKey: cursorId(runId),
83
+ definitionHash: digest('mayura:workflow-hook-relay-format:v1', {}), state, events: [event] }))).record;
84
+ return { record, sequence };
85
+ }
86
+ catch (error) {
87
+ if (!(error instanceof StorageError && error.code === 'CONFLICT'))
88
+ throw error;
89
+ const latest = await read(runId);
90
+ return latest.sequence >= sequence ? latest : advance(runId, latest, sequence);
91
+ }
92
+ };
93
+ const validRun = (runId) => {
94
+ if (typeof runId !== 'string' || !identifier.test(runId))
95
+ throw new MayuraError('INVALID_INPUT', 'A bounded workflow run identity is required.');
96
+ return runId;
97
+ };
98
+ return Object.freeze({
99
+ async cursor(runId) { return (await read(validRun(runId))).sequence; },
100
+ async deliver(runId, deliveryOptions = {}) {
101
+ validRun(runId);
102
+ const limit = deliveryOptions.limit ?? 1_000;
103
+ const signal = deliveryOptions.signal;
104
+ if (!Number.isSafeInteger(limit) || limit < 1 || limit > 10_000)
105
+ throw new MayuraError('INVALID_INPUT', 'Delivery limit must be 1–10000 events.');
106
+ let current = await read(runId);
107
+ let scanned = 0;
108
+ let delivered = 0;
109
+ while (scanned < limit) {
110
+ if (signal?.aborted)
111
+ throw new MayuraError('CANCELLED', 'Workflow hook delivery was cancelled.');
112
+ const page = await guarded(() => source.events(runId, current.sequence));
113
+ if (!Array.isArray(page))
114
+ throw new MayuraError('STORAGE_UNAVAILABLE', 'The workflow event source returned an invalid page.');
115
+ let expected = current.sequence;
116
+ let unsaved = current.sequence;
117
+ for (const stored of page) {
118
+ if (scanned >= limit)
119
+ break;
120
+ if (!stored || stored.sequence !== expected + 1 || typeof stored.type !== 'string' || !stored.data || typeof stored.data !== 'object') {
121
+ throw new MayuraError('STORAGE_UNAVAILABLE', 'The workflow event source returned events out of order.');
122
+ }
123
+ expected = stored.sequence;
124
+ scanned++;
125
+ const callbacks = workflowHookStages(stored.type, stored.data).filter(entry => handlers[entry.stage] !== undefined);
126
+ for (const { stage, status } of callbacks) {
127
+ const nodeId = stored.data['nodeId'];
128
+ const event = { stage, runId, sequence: stored.sequence, eventId: `${relayId}:${runId}:${stored.sequence}:${stage}`, type: stored.type,
129
+ ...(typeof nodeId === 'string' && identifier.test(nodeId) ? { nodeId } : {}), ...(status === undefined ? {} : { status }) };
130
+ try {
131
+ await evaluateLifecycleObserver({ stage, handler: handlers[stage], event, timeoutMs, ...(signal ? { signal } : {}) });
132
+ }
133
+ catch (error) {
134
+ if (unsaved > current.sequence)
135
+ current = await advance(runId, current, unsaved);
136
+ if (error instanceof MayuraError && error.code === 'CANCELLED')
137
+ throw error;
138
+ const code = error instanceof MayuraError ? error.code : 'GUARD_UNAVAILABLE';
139
+ return Object.freeze({ delivered, sequence: current.sequence, failure: Object.freeze({ sequence: stored.sequence, stage, code }) });
140
+ }
141
+ delivered++;
142
+ }
143
+ unsaved = stored.sequence;
144
+ // Persist after every callback-bearing event so a crash never repeats completed callbacks of earlier events.
145
+ if (callbacks.length > 0)
146
+ current = await advance(runId, current, unsaved);
147
+ }
148
+ if (unsaved > current.sequence)
149
+ current = await advance(runId, current, unsaved);
150
+ if (page.length < 1_000)
151
+ break;
152
+ }
153
+ return Object.freeze({ delivered, sequence: current.sequence });
154
+ },
155
+ });
156
+ }
157
+ //# sourceMappingURL=hook-relay.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hook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7G,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC;wBAAE,OAAO,GAAG,MAAM,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;gBAC7E,CAAC;gBACD,IAAI,OAAO,GAAG,OAAO,CAAC,QAAQ;oBAAE,OAAO,GAAG,MAAM,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;gBACjF,IAAI,IAAI,CAAC,MAAM,GAAG,KAAK;oBAAE,MAAM;YACjC,CAAC;YACD,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;QAClE,CAAC;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { MayuraError, type JsonObject, type LifecycleObserver, type Scope } from '@mayura/core';\nimport { evaluateLifecycleObserver, snapshotHookOptions } from '@mayura/core/host';\nimport { StorageError, type AggregateStore, type StoredEvent, type StoredRecord } from '@mayura/storage-contracts';\nimport { digest } from './definition.js';\n\n/** Durable lifecycle points delivered from a workflow run's stored event log. */\nexport type WorkflowHookStage = 'onWait' | 'onResume' | 'onApprovalRequested' | 'onApprovalResolved'\n | 'afterExecution' | 'onError' | 'onCancel' | 'onBlocked' | 'onFinally';\n\n/** Metadata-only view of one stored event. `eventId` is the deduplication identity for at-least-once delivery. */\nexport interface WorkflowHookEvent {\n readonly stage: WorkflowHookStage;\n readonly runId: string;\n readonly sequence: number;\n /** `<relayId>:<runId>:<sequence>:<stage>`; stable across redelivery. */\n readonly eventId: string;\n /** The stored event type, for example `approval.requested` or `lifecycle.timer.fired`. */\n readonly type: string;\n readonly nodeId?: string;\n /** Terminal status, present for terminal stages. */\n readonly status?: string;\n}\nexport type WorkflowHooks = { readonly [S in WorkflowHookStage]?: LifecycleObserver<WorkflowHookEvent, S> } & { readonly timeoutMs?: number };\n\n/** Any workflow runtime: every format exposes its ordered durable log as `events(id, after)`. */\nexport interface WorkflowEventSource { events(id: string, after?: number): Promise<readonly StoredEvent[]> }\n\nexport interface WorkflowHookRelayOptions {\n readonly source: WorkflowEventSource;\n /** Holds one delivery cursor per (relay, run). May be the same store the workflows use. */\n readonly store: AggregateStore;\n readonly scope: Scope;\n /** Separates independent consumers of the same runs, for example `audit` and `notifications`. */\n readonly relayId: string;\n readonly hooks: WorkflowHooks;\n}\nexport interface WorkflowHookDelivery {\n /** Callbacks that completed during this call. */\n readonly delivered: number;\n /** Last stored event whose callbacks all completed; delivery resumes after it. */\n readonly sequence: number;\n /** Present when a callback failed; the next `deliver` retries this event. */\n readonly failure?: { readonly sequence: number; readonly stage: WorkflowHookStage; readonly code: string };\n}\nexport interface WorkflowHookRelay {\n /** Deliver callbacks for stored events after the durable cursor, in order, for at most `limit` events (default 1000). */\n deliver(runId: string, options?: { readonly signal?: AbortSignal; readonly limit?: number }): Promise<WorkflowHookDelivery>;\n /** The durable cursor for a run (0 before any delivery). */\n cursor(runId: string): Promise<number>;\n}\n\nconst stages: readonly WorkflowHookStage[] = ['onWait', 'onResume', 'onApprovalRequested', 'onApprovalResolved', 'afterExecution', 'onError', 'onCancel', 'onBlocked', 'onFinally'];\nconst identifier = /^[A-Za-z0-9][A-Za-z0-9._:/-]{0,127}$/;\nconst eventStages: Readonly<Record<string, WorkflowHookStage>> = Object.freeze({\n 'approval.requested': 'onApprovalRequested', 'lifecycle.approval.requested': 'onApprovalRequested',\n 'approval.resolved': 'onApprovalResolved', 'lifecycle.approval.resolved': 'onApprovalResolved',\n 'approval.expired': 'onApprovalResolved', 'lifecycle.approval.expired': 'onApprovalResolved',\n 'wait.registered': 'onWait', 'run.waiting': 'onWait', 'lifecycle.run.waiting': 'onWait', 'workflow.waiting': 'onWait',\n 'run.paused': 'onWait', 'lifecycle.run.paused': 'onWait', 'lifecycle.human.requested': 'onWait', 'lifecycle.timer.scheduled': 'onWait',\n 'saga.forward.waiting': 'onWait', 'saga.compensation.waiting': 'onWait', 'loop.child.waiting': 'onWait',\n 'wait.resolved': 'onResume', 'run.resumed': 'onResume', 'lifecycle.run.resumed': 'onResume',\n 'lifecycle.human.responded': 'onResume', 'lifecycle.timer.fired': 'onResume',\n});\n/** Terminal events of every format; the value is the status used when the event data carries none. */\nconst terminalEvents: Readonly<Record<string, string>> = Object.freeze({\n 'run.completed': 'unknown', 'lifecycle.run.completed': 'unknown', 'workflow.terminated': 'unknown',\n 'run.cancelled': 'cancelled', 'lifecycle.run.cancelled': 'cancelled', 'saga.run.cancelled': 'cancelled', 'loop.run.cancelled': 'cancelled',\n 'saga.run.succeeded': 'succeeded', 'loop.run.succeeded': 'succeeded',\n 'saga.run.failed': 'failed', 'saga.run.compensated': 'compensated',\n 'loop.output.rejected': 'failed', 'loop.condition.rejected': 'failed', 'loop.input.rejected': 'failed', 'loop.child.rejected': 'failed',\n 'loop.child.failed': 'failed', 'loop.limit.exceeded': 'limit_exceeded',\n});\n\n/** The callbacks one stored event produces, in order. Unrelated events produce none. */\nexport function workflowHookStages(type: string, data: JsonObject): readonly { readonly stage: WorkflowHookStage; readonly status?: string }[] {\n const stage = eventStages[type];\n if (stage) return [{ stage }];\n const fallback = terminalEvents[type];\n if (fallback === undefined) return [];\n const status = typeof data['status'] === 'string' && identifier.test(data['status']) ? data['status'] : fallback;\n const terminal: WorkflowHookStage = status === 'succeeded' ? 'afterExecution' : status === 'cancelled' ? 'onCancel' : status === 'blocked' ? 'onBlocked' : 'onError';\n return [{ stage: terminal, status }, { stage: 'onFinally', status }];\n}\n\n/**\n * Durable, recoverable delivery of workflow lifecycle callbacks. Delivery is at-least-once: the cursor advances\n * only after an event's callbacks complete, so a crash or failure redelivers from that event with the same `eventId`.\n */\nexport function createWorkflowHookRelay(options: WorkflowHookRelayOptions): WorkflowHookRelay {\n const { store, source } = options;\n if (!store || typeof store.read !== 'function' || typeof store.create !== 'function' || typeof store.update !== 'function'\n || !source || typeof source.events !== 'function' || typeof options.relayId !== 'string' || !identifier.test(options.relayId)\n || typeof options.scope?.principalId !== 'string' || typeof options.scope?.projectId !== 'string') {\n throw new MayuraError('INVALID_CONFIG', 'A workflow hook relay requires a store, an event source, a scope and a bounded relay identity.');\n }\n const { handlers, timeoutMs } = snapshotHookOptions(options.hooks, stages, 'Workflow hooks require callable handlers for known stages and a bounded timeout.');\n const relayId = options.relayId;\n const scope = digest('mayura:scope:v1', { principalId: options.scope.principalId, projectId: options.scope.projectId });\n const cursorId = (runId: string): string => digest('mayura:workflow-hook-relay:v1', { relayId, runId });\n const guarded = async <T>(operation: () => Promise<T>): Promise<T> => {\n try { return await operation(); }\n catch (error) { if (error instanceof MayuraError || (error instanceof StorageError && error.code === 'CONFLICT')) throw error;\n throw new MayuraError('STORAGE_UNAVAILABLE', 'Workflow hook relay storage is unavailable.'); }\n };\n const read = async (runId: string): Promise<{ record?: StoredRecord; sequence: number }> => {\n const id = cursorId(runId); const record = await guarded(() => store.read(scope, id));\n if (!record) return { sequence: 0 };\n const state = record.state;\n if (record.scope !== scope || record.id !== id || state['format'] !== 1 || state['relayId'] !== relayId || state['runId'] !== runId\n || !Number.isSafeInteger(state['sequence']) || (state['sequence'] as number) < 0) {\n throw new MayuraError('STORAGE_UNAVAILABLE', 'Stored hook relay cursor failed integrity validation.');\n }\n return { record, sequence: state['sequence'] as number };\n };\n /** Compare-and-set advance; a concurrent relay that got further wins and this one resumes from its cursor. */\n const advance = async (runId: string, current: { record?: StoredRecord; sequence: number }, sequence: number): Promise<{ record?: StoredRecord; sequence: number }> => {\n const state = { format: 1, relayId, runId, sequence }; const event = { type: 'hook-relay.advanced', data: { sequence } };\n try {\n const record = current.record\n ? await guarded(() => store.update({ scope, id: current.record!.id, expectedVersion: current.record!.version, state, events: [event] }))\n : (await guarded(() => store.create({ scope, id: cursorId(runId), idempotencyKey: cursorId(runId),\n definitionHash: digest('mayura:workflow-hook-relay-format:v1', {}), state, events: [event] }))).record;\n return { record, sequence };\n } catch (error) {\n if (!(error instanceof StorageError && error.code === 'CONFLICT')) throw error;\n const latest = await read(runId);\n return latest.sequence >= sequence ? latest : advance(runId, latest, sequence);\n }\n };\n const validRun = (runId: unknown): string => {\n if (typeof runId !== 'string' || !identifier.test(runId)) throw new MayuraError('INVALID_INPUT', 'A bounded workflow run identity is required.');\n return runId;\n };\n return Object.freeze<WorkflowHookRelay>({\n async cursor(runId) { return (await read(validRun(runId))).sequence; },\n async deliver(runId, deliveryOptions = {}) {\n validRun(runId);\n const limit = deliveryOptions.limit ?? 1_000; const signal = deliveryOptions.signal;\n if (!Number.isSafeInteger(limit) || limit < 1 || limit > 10_000) throw new MayuraError('INVALID_INPUT', 'Delivery limit must be 1–10000 events.');\n let current = await read(runId); let scanned = 0; let delivered = 0;\n while (scanned < limit) {\n if (signal?.aborted) throw new MayuraError('CANCELLED', 'Workflow hook delivery was cancelled.');\n const page = await guarded(() => source.events(runId, current.sequence));\n if (!Array.isArray(page)) throw new MayuraError('STORAGE_UNAVAILABLE', 'The workflow event source returned an invalid page.');\n let expected = current.sequence; let unsaved = current.sequence;\n for (const stored of page) {\n if (scanned >= limit) break;\n if (!stored || stored.sequence !== expected + 1 || typeof stored.type !== 'string' || !stored.data || typeof stored.data !== 'object') {\n throw new MayuraError('STORAGE_UNAVAILABLE', 'The workflow event source returned events out of order.');\n }\n expected = stored.sequence; scanned++;\n const callbacks = workflowHookStages(stored.type, stored.data).filter(entry => handlers[entry.stage] !== undefined);\n for (const { stage, status } of callbacks) {\n const nodeId = stored.data['nodeId'];\n const event: WorkflowHookEvent = { stage, runId, sequence: stored.sequence, eventId: `${relayId}:${runId}:${stored.sequence}:${stage}`, type: stored.type,\n ...(typeof nodeId === 'string' && identifier.test(nodeId) ? { nodeId } : {}), ...(status === undefined ? {} : { status }) };\n try {\n await evaluateLifecycleObserver({ stage, handler: handlers[stage] as LifecycleObserver<WorkflowHookEvent>, event, timeoutMs, ...(signal ? { signal } : {}) });\n } catch (error) {\n if (unsaved > current.sequence) current = await advance(runId, current, unsaved);\n if (error instanceof MayuraError && error.code === 'CANCELLED') throw error;\n const code = error instanceof MayuraError ? error.code : 'GUARD_UNAVAILABLE';\n return Object.freeze({ delivered, sequence: current.sequence, failure: Object.freeze({ sequence: stored.sequence, stage, code }) });\n }\n delivered++;\n }\n unsaved = stored.sequence;\n // Persist after every callback-bearing event so a crash never repeats completed callbacks of earlier events.\n if (callbacks.length > 0) current = await advance(runId, current, unsaved);\n }\n if (unsaved > current.sequence) current = await advance(runId, current, unsaved);\n if (page.length < 1_000) break;\n }\n return Object.freeze({ delivered, sequence: current.sequence });\n },\n });\n}\n"]}
@@ -0,0 +1,16 @@
1
+ export { defineWorkflow, type Binding, type WorkflowNode, type WorkflowDefinition, type WorkflowOptions, type WorkflowOutput } from './definition.js';
2
+ export { createWorkflowRuntime, type WorkflowRuntimeOptions, type WorkflowSnapshot, type VerifiedHuman } from './runtime.js';
3
+ export type { WorkflowDrainOptions, WorkflowDrainReport } from './drain.js';
4
+ export { createScheduledWorkflowRuntime, type ScheduledWorkflowRuntime, type ScheduledWorkflowRuntimeOptions, type ExternalEffectReconciliationRequest, type VerifiedExternalEffect, type ReconcileExternalEffectCommand } from './scheduled.js';
5
+ export { composeExternalEffectVerifiers, defineExternalEffectVerifier, type ExternalEffectProviderAttestation, type ExternalEffectVerificationRouter, type ExternalEffectVerifier, type ExternalEffectVerifierOptions } from './reconciliation.js';
6
+ export { agentAsDurableWorkflow, type DurableAgentWorkflowOptions } from './agents.js';
7
+ export { createWorkflowFleetControl, compositeFleetTarget, graphFleetTarget, lifecycleFleetTarget, treeFleetTarget, type WorkflowFleetControl, type WorkflowFleetControlOptions, type WorkflowFleetHoldReader, type WorkflowFleetHoldState, type WorkflowFleetSweepCursor, type WorkflowFleetSweepOutcome, type WorkflowFleetSweepReport, type WorkflowFleetTarget } from './fleet-control.js';
8
+ export { createWorkflowLeadership, type WorkflowLeadership, type WorkflowLeadershipOptions, type WorkflowLeadershipState } from './leadership.js';
9
+ export { coordinatorUnit, createWorkflowWorker, type WorkflowWorker, type WorkflowWorkerOptions, type WorkflowWorkerStatus, type WorkflowWorkerUnit } from './worker.js';
10
+ export { createWorkflowHookRelay, workflowHookStages, type WorkflowHookRelay, type WorkflowHookRelayOptions, type WorkflowHookDelivery, type WorkflowHookEvent, type WorkflowHookStage, type WorkflowHooks, type WorkflowEventSource } from './hook-relay.js';
11
+ export { inventoryWorkflowVersions, assertWorkflowVersionsRetained, compositeVersionTarget, type WorkflowVersionInventory, type WorkflowVersionInventoryOptions, type WorkflowVersionEntry, type WorkflowVersionTarget } from './versions.js';
12
+ export { defineWorkflowMigration, createWorkflowMigrationCatalog, type WorkflowMigrationCatalog, planWorkflowMigration, nodeFingerprint, nodeEvidence, type WorkflowMigration, type WorkflowMigrationOptions, type MigrationPlan, type MigrationPlanEntry, type MigrationBlocker, type MigrationAction, type MigrationCommand, type MigrationNode, type MigrationStep, type WorkflowMigrationResult } from './migration.js';
13
+ export { createWorkflowMigrationService, pinnedDefinitionHash, type WorkflowMigrationService, type WorkflowMigrationServiceOptions, type WorkflowMigrationOfferRecord, type WorkflowMigrationApplyResult } from './migration-service.js';
14
+ export { createWorkflowCommandJournal, createWorkflowOperatorTransports, lifecycleOperatorTarget, graphOperatorTarget, treeOperatorTarget, type WorkflowCommandJournal, type WorkflowCommandJournalOptions, type WorkflowCommandOutcome, type WorkflowCommandResult, type WorkflowOperatorTarget, type WorkflowOperatorView, type WorkflowOperatorIndexRecord, type WorkflowOperatorSettledRecord, type WorkflowOperatorTransports, type WorkflowOperatorResult, type WorkflowOperatorControlInput, type WorkflowOperatorStatus, type WorkflowOperatorNodeKind, type WorkflowOperatorStepStatus, type WorkflowOperatorFleetSweepOutcome, type WorkflowOperatorApproval, type WorkflowOperatorTransportOptions, type WorkflowApprovalCredential } from './operator-transports.js';
15
+ export { createWorkflowTraceExport, workflowStepTraceContext, workflowTraceContext, workflowTraceSpans, type WorkflowTraceAttributeName, type WorkflowTraceAttributes, type WorkflowTraceContext, type WorkflowTraceDefinition, type WorkflowTraceExport, type WorkflowTraceExportOptions, type WorkflowTraceExportResult, type WorkflowTraceFlushReport, type WorkflowTraceInput, type WorkflowTraceSink, type WorkflowTraceSnapshot, type WorkflowTraceSource, type WorkflowTraceSpan, type WorkflowTraceUnitOptions } from './traces.js';
16
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,KAAK,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,kBAAkB,EAAE,KAAK,eAAe,EAAE,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtJ,OAAO,EAAE,qBAAqB,EAAE,KAAK,sBAAsB,EAAE,KAAK,gBAAgB,EAAE,KAAK,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7H,YAAY,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAC5E,OAAO,EAAE,8BAA8B,EAAE,KAAK,wBAAwB,EAAE,KAAK,+BAA+B,EAC1G,KAAK,mCAAmC,EAAE,KAAK,sBAAsB,EAAE,KAAK,8BAA8B,EAAE,MAAM,gBAAgB,CAAC;AACrI,OAAO,EAAE,8BAA8B,EAAE,4BAA4B,EAAE,KAAK,iCAAiC,EAC3G,KAAK,gCAAgC,EAAE,KAAK,sBAAsB,EAAE,KAAK,6BAA6B,EAAE,MAAM,qBAAqB,CAAC;AACtI,OAAO,EAAE,sBAAsB,EAAE,KAAK,2BAA2B,EAAE,MAAM,aAAa,CAAC;AACvF,OAAO,EAAE,0BAA0B,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,eAAe,EAAE,KAAK,oBAAoB,EAC3I,KAAK,2BAA2B,EAAE,KAAK,uBAAuB,EAAE,KAAK,sBAAsB,EAAE,KAAK,wBAAwB,EAC1H,KAAK,yBAAyB,EAAE,KAAK,wBAAwB,EAAE,KAAK,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACtH,OAAO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