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,499 @@
1
+ import { freezeJson, jsonValue, MayuraError, validate } from '../../core/dist/index.js';
2
+ import { StorageError, assertWorkflowSagaStateMatchesManifest, initialWorkflowSagaState, workflowSagaState } from '../../storage-contracts/dist/index.js';
3
+ import { digest, resolveBinding } from './definition.js';
4
+ import { createWorkflowLifecycleRuntime } from './lifecycle-runtime.js';
5
+ import { assertWorkflowSaga, sagaManifest } from './saga-definition.js';
6
+ import { assertMigrationAllowed, assertWorkflowMigration, migrationCommand, migrationEvent, nodeFingerprint, planWorkflowMigration } from './migration.js';
7
+ const hashPattern = /^[a-f0-9]{64}$/;
8
+ const terminalSagaStatuses = new Set(['succeeded', 'failed', 'compensated', 'compensation_failed', 'cancelled']);
9
+ const successfulChild = (snapshot) => snapshot.status === 'succeeded';
10
+ const terminalChild = (snapshot) => ['succeeded', 'failed', 'blocked', 'cancelled', 'outcome_unknown'].includes(snapshot.status);
11
+ async function storageCall(operation) {
12
+ try {
13
+ return await operation();
14
+ }
15
+ catch (error) {
16
+ if (error instanceof StorageError && error.code === 'CONFLICT')
17
+ throw error;
18
+ throw new MayuraError('STORAGE_UNAVAILABLE', 'Workflow saga storage is unavailable; inspect current state before retrying.');
19
+ }
20
+ }
21
+ function decoded(record) {
22
+ try {
23
+ return workflowSagaState(record);
24
+ }
25
+ catch {
26
+ throw new MayuraError('CONFLICT', 'Stored workflow saga state failed integrity validation.');
27
+ }
28
+ }
29
+ function snapshot(record) {
30
+ const state = decoded(record);
31
+ return freezeJson(jsonValue({ id: record.id, version: record.version, status: state.status, cursor: state.cursor,
32
+ steps: state.steps, output: state.output, budget: { spentMicros: state.spentMicros,
33
+ maxCostMicros: state.maxCostMicros } }));
34
+ }
35
+ function outputs(state) {
36
+ return Object.fromEntries(Object.entries(state.steps).filter(([, step]) => ['succeeded', 'compensation_waiting', 'compensated', 'compensation_failed'].includes(step.status))
37
+ .map(([id, step]) => [id, step.output]));
38
+ }
39
+ function childKey(sagaRunId, stepId, phase) {
40
+ return digest('mayura:workflow-saga-child:v1', { sagaRunId, stepId, phase });
41
+ }
42
+ /**
43
+ * Durable saga coordinator built from format-5 lifecycle children.
44
+ * The generic aggregate API cannot atomically write a child and its saga link; the
45
+ * stable child key makes replay after that narrow crash window converge safely.
46
+ */
47
+ export function createWorkflowSagaRuntime(options) {
48
+ const store = options.store;
49
+ const scope = Object.freeze({ principalId: options.scope?.principalId, projectId: options.scope?.projectId });
50
+ if ([scope.principalId, scope.projectId, options.policyVersion].some(value => typeof value !== 'string' || value.length < 1 || value.length > 128)) {
51
+ throw new MayuraError('INVALID_CONFIG', 'Workflow saga scope and policy version are required.');
52
+ }
53
+ if (!Array.isArray(options.permissions?.allow) || options.permissions.allow.length > 4_096
54
+ || options.permissions.allow.some(grant => typeof grant !== 'string' || grant.length < 1 || grant.length > 256)) {
55
+ throw new MayuraError('INVALID_CONFIG', 'Workflow saga permissions must be bounded explicit grants.');
56
+ }
57
+ if (!Number.isSafeInteger(options.maxCostMicros) || options.maxCostMicros < 0) {
58
+ throw new MayuraError('INVALID_CONFIG', 'A bounded saga cost is required.');
59
+ }
60
+ const maxOutputBytes = options.maxOutputBytes ?? 1_048_576;
61
+ const callbackTimeoutMs = options.callbackTimeoutMs ?? 30_000;
62
+ const maxPendingCallbacks = options.maxPendingCallbacks ?? 32;
63
+ if (!Number.isSafeInteger(maxOutputBytes) || maxOutputBytes < 1 || !Number.isSafeInteger(callbackTimeoutMs) || callbackTimeoutMs < 1) {
64
+ throw new MayuraError('INVALID_CONFIG', 'Saga callback and output bounds must be positive integers.');
65
+ }
66
+ if (!Number.isSafeInteger(maxPendingCallbacks) || maxPendingCallbacks < 1 || maxPendingCallbacks > 128) {
67
+ throw new MayuraError('INVALID_CONFIG', 'maxPendingCallbacks must be an integer from 1 through 128.');
68
+ }
69
+ const lifecycle = createWorkflowLifecycleRuntime(options);
70
+ const scopeKey = digest('mayura:scope:v1', scope);
71
+ const policy = digest('mayura:workflow-saga-policy:v1', { scope, permissions: [...options.permissions.allow].sort(),
72
+ policyVersion: options.policyVersion, maxCostMicros: options.maxCostMicros, maxOutputBytes,
73
+ approvalTtlMs: options.approvalTtlMs ?? 3_600_000 });
74
+ let closed = false;
75
+ const ensureOpen = () => { if (closed)
76
+ throw new MayuraError('CANCELLED', 'Workflow saga runtime is closed.'); };
77
+ let pendingCallbacks = 0;
78
+ const boundedValidate = async (schema, value, boundary) => {
79
+ if (pendingCallbacks >= maxPendingCallbacks)
80
+ throw new MayuraError('LIMIT_EXCEEDED', 'Saga callback capacity is full.');
81
+ pendingCallbacks += 1;
82
+ let released = false;
83
+ const release = () => { if (!released) {
84
+ released = true;
85
+ pendingCallbacks -= 1;
86
+ } };
87
+ const validation = Promise.resolve().then(() => validate(schema, value, boundary, { maxBytes: maxOutputBytes }));
88
+ void validation.then(release, release);
89
+ let timer;
90
+ try {
91
+ const checked = await Promise.race([validation,
92
+ new Promise((_resolve, reject) => { timer = setTimeout(() => reject(new MayuraError('TIMEOUT', 'Saga schema validation timed out.')), callbackTimeoutMs); })]);
93
+ return jsonValue(checked, { maxBytes: maxOutputBytes });
94
+ }
95
+ finally {
96
+ if (timer !== undefined)
97
+ clearTimeout(timer);
98
+ }
99
+ };
100
+ const load = async (id) => {
101
+ ensureOpen();
102
+ if (typeof id !== 'string' || !hashPattern.test(id))
103
+ throw new MayuraError('INVALID_INPUT', 'A workflow saga run ID is required.');
104
+ const record = await storageCall(() => store.read(scopeKey, id));
105
+ if (!record)
106
+ throw new MayuraError('NOT_FOUND', 'Workflow saga run was not found in this scope.');
107
+ if (record.scope !== scopeKey || record.id !== id)
108
+ throw new MayuraError('CONFLICT', 'Stored saga identity does not match its requested scope.');
109
+ const state = decoded(record);
110
+ if (state.policy !== policy)
111
+ throw new MayuraError('CONFLICT', 'Stored saga policy does not match this runtime.');
112
+ return record;
113
+ };
114
+ const verify = (definition, record, state) => {
115
+ if (record.definitionHash !== definition.digest || state.definition !== definition.digest || state.policy !== policy) {
116
+ throw new MayuraError('CONFLICT', 'Workflow saga definition or policy does not match persisted state.');
117
+ }
118
+ try {
119
+ assertWorkflowSagaStateMatchesManifest(state, sagaManifest(definition));
120
+ }
121
+ catch {
122
+ throw new MayuraError('CONFLICT', 'Workflow saga state does not match its persisted definition.');
123
+ }
124
+ };
125
+ const save = (record, state, type, data = {}) => storageCall(() => store.update({ scope: scopeKey, id: record.id, expectedVersion: record.version,
126
+ state: jsonValue(state), events: [{ type, data }] }));
127
+ const mutate = async (id, transition, type, data = {}) => {
128
+ for (let attempt = 0; attempt < 32; attempt++) {
129
+ const record = await load(id);
130
+ const state = decoded(record);
131
+ const paused = state.status === 'paused';
132
+ if (!transition(state))
133
+ return record;
134
+ // Progress recorded while paused (a child settling) never un-pauses the saga; only a terminal outcome replaces it.
135
+ if (paused && !terminalSagaStatuses.has(state.status) && type !== 'saga.run.resumed')
136
+ state.status = 'paused';
137
+ try {
138
+ return await save(record, state, type, data);
139
+ }
140
+ catch (error) {
141
+ if (!(error instanceof StorageError) || error.code !== 'CONFLICT')
142
+ throw error;
143
+ }
144
+ }
145
+ throw new MayuraError('CONFLICT', 'Workflow saga contention exceeded the bounded retry limit.');
146
+ };
147
+ const recordChild = (state, stepId, phase, child) => {
148
+ const step = state.steps[stepId];
149
+ if (phase === 'forward') {
150
+ step.forwardRunId = child.id;
151
+ step.forwardSpentMicros = child.budget.spentMicros;
152
+ }
153
+ else {
154
+ step.compensationRunId = child.id;
155
+ step.compensationSpentMicros = child.budget.spentMicros;
156
+ }
157
+ state.spentMicros = Object.values(state.steps).reduce((sum, item) => sum + item.forwardSpentMicros + item.compensationSpentMicros, 0);
158
+ if (!Number.isSafeInteger(state.spentMicros) || state.spentMicros > state.maxCostMicros) {
159
+ throw new MayuraError('LIMIT_EXCEEDED', 'Workflow saga exceeded its persisted cost ceiling.');
160
+ }
161
+ };
162
+ const submitChild = async (runId, step, phase, state) => {
163
+ const workflow = phase === 'forward' ? step.forward : step.compensation.workflow;
164
+ const binding = phase === 'forward' ? step.input : step.compensation.input;
165
+ const input = resolveBinding(binding, state.input, outputs(state));
166
+ return lifecycle.submit(workflow, { input, idempotencyKey: childKey(runId, step.id, phase) });
167
+ };
168
+ const run = async (definition, id) => {
169
+ assertWorkflowSaga(definition);
170
+ for (let wave = 0; wave < definition.steps.length * 2 + 4; wave++) {
171
+ let record = await load(id);
172
+ let state = decoded(record);
173
+ verify(definition, record, state);
174
+ if (terminalSagaStatuses.has(state.status) || state.status === 'paused')
175
+ return snapshot(record);
176
+ if (state.status === 'running' || state.status === 'waiting') {
177
+ const index = state.cursor;
178
+ const step = definition.steps[index];
179
+ if (!step) {
180
+ let output;
181
+ try {
182
+ output = await boundedValidate(definition.output, resolveBinding(definition.result, state.input, outputs(state)), 'output');
183
+ }
184
+ catch (error) {
185
+ if (!(error instanceof MayuraError) || !['INVALID_INPUT', 'INVALID_OUTPUT'].includes(error.code))
186
+ throw error;
187
+ state.status = 'compensating';
188
+ state.cursor = definition.steps.length;
189
+ await save(record, state, 'saga.output.rejected');
190
+ continue;
191
+ }
192
+ state.output = output;
193
+ state.status = 'succeeded';
194
+ record = await save(record, state, 'saga.run.succeeded');
195
+ return snapshot(record);
196
+ }
197
+ const persisted = state.steps[step.id];
198
+ let child;
199
+ if (persisted.forwardRunId === null) {
200
+ try {
201
+ child = await submitChild(id, step, 'forward', state);
202
+ }
203
+ catch (error) {
204
+ if (!(error instanceof MayuraError) || !['INVALID_INPUT', 'INVALID_OUTPUT'].includes(error.code))
205
+ throw error;
206
+ await mutate(id, current => {
207
+ const target = current.steps[step.id];
208
+ if (target.status !== 'pending')
209
+ return false;
210
+ target.status = 'failed';
211
+ for (let next = index + 1; next < definition.steps.length; next++)
212
+ current.steps[definition.steps[next].id].status = 'skipped';
213
+ current.status = 'compensating';
214
+ current.cursor = index;
215
+ return true;
216
+ }, 'saga.forward.rejected', { stepId: step.id });
217
+ continue;
218
+ }
219
+ record = await mutate(id, current => {
220
+ const target = current.steps[step.id];
221
+ if (target.forwardRunId !== null)
222
+ return false;
223
+ recordChild(current, step.id, 'forward', child);
224
+ target.status = 'forward_waiting';
225
+ current.status = 'running';
226
+ return true;
227
+ }, 'saga.forward.linked', { stepId: step.id, childRunId: child.id });
228
+ state = decoded(record);
229
+ child = await lifecycle.inspect(state.steps[step.id].forwardRunId);
230
+ }
231
+ else
232
+ child = await lifecycle.inspect(persisted.forwardRunId);
233
+ child = await lifecycle.runUntilSettled(step.forward, child.id);
234
+ if (!terminalChild(child)) {
235
+ record = await mutate(id, current => {
236
+ const target = current.steps[step.id];
237
+ if (target.forwardRunId !== child.id || terminalSagaStatuses.has(current.status))
238
+ return false;
239
+ recordChild(current, step.id, 'forward', child);
240
+ target.status = 'forward_waiting';
241
+ current.status = child.status === 'waiting' ? 'waiting' : 'running';
242
+ return true;
243
+ }, 'saga.forward.waiting', { stepId: step.id, childRunId: child.id });
244
+ return snapshot(record);
245
+ }
246
+ if (successfulChild(child)) {
247
+ record = await mutate(id, current => {
248
+ const target = current.steps[step.id];
249
+ if (target.forwardRunId !== child.id || target.status === 'succeeded')
250
+ return false;
251
+ recordChild(current, step.id, 'forward', child);
252
+ target.output = child.output;
253
+ target.status = 'succeeded';
254
+ current.cursor = index + 1;
255
+ current.status = 'running';
256
+ return true;
257
+ }, 'saga.forward.succeeded', { stepId: step.id, childRunId: child.id });
258
+ continue;
259
+ }
260
+ record = await mutate(id, current => {
261
+ const target = current.steps[step.id];
262
+ if (target.forwardRunId !== child.id || target.status === 'failed')
263
+ return false;
264
+ recordChild(current, step.id, 'forward', child);
265
+ target.status = 'failed';
266
+ for (let next = index + 1; next < definition.steps.length; next++)
267
+ current.steps[definition.steps[next].id].status = 'skipped';
268
+ current.cursor = index;
269
+ current.status = 'compensating';
270
+ return true;
271
+ }, 'saga.forward.failed', { stepId: step.id, childRunId: child.id, childStatus: child.status });
272
+ continue;
273
+ }
274
+ if (state.status === 'compensating') {
275
+ let index = state.cursor - 1;
276
+ while (index >= 0) {
277
+ const candidate = definition.steps[index];
278
+ const persisted = state.steps[candidate.id];
279
+ if (persisted.status === 'succeeded' && candidate.compensation)
280
+ break;
281
+ index -= 1;
282
+ }
283
+ if (index < 0) {
284
+ const compensated = Object.values(state.steps).some(step => step.status === 'compensated');
285
+ state.status = compensated ? 'compensated' : 'failed';
286
+ state.cursor = 0;
287
+ record = await save(record, state, compensated ? 'saga.run.compensated' : 'saga.run.failed');
288
+ return snapshot(record);
289
+ }
290
+ const step = definition.steps[index];
291
+ const persisted = state.steps[step.id];
292
+ let child;
293
+ if (persisted.compensationRunId === null) {
294
+ try {
295
+ child = await submitChild(id, step, 'compensation', state);
296
+ }
297
+ catch (error) {
298
+ if (!(error instanceof MayuraError) || !['INVALID_INPUT', 'INVALID_OUTPUT'].includes(error.code))
299
+ throw error;
300
+ record = await mutate(id, current => {
301
+ const target = current.steps[step.id];
302
+ if (target.status !== 'succeeded')
303
+ return false;
304
+ target.status = 'compensation_failed';
305
+ current.status = 'compensation_failed';
306
+ current.cursor = index;
307
+ return true;
308
+ }, 'saga.compensation.rejected', { stepId: step.id });
309
+ return snapshot(record);
310
+ }
311
+ record = await mutate(id, current => {
312
+ const target = current.steps[step.id];
313
+ if (target.compensationRunId !== null)
314
+ return false;
315
+ recordChild(current, step.id, 'compensation', child);
316
+ target.status = 'compensation_waiting';
317
+ current.status = 'compensating';
318
+ current.cursor = index + 1;
319
+ return true;
320
+ }, 'saga.compensation.linked', { stepId: step.id, childRunId: child.id });
321
+ state = decoded(record);
322
+ child = await lifecycle.inspect(state.steps[step.id].compensationRunId);
323
+ }
324
+ else
325
+ child = await lifecycle.inspect(persisted.compensationRunId);
326
+ child = await lifecycle.runUntilSettled(step.compensation.workflow, child.id);
327
+ if (!terminalChild(child)) {
328
+ record = await mutate(id, current => {
329
+ const target = current.steps[step.id];
330
+ if (target.compensationRunId !== child.id || terminalSagaStatuses.has(current.status))
331
+ return false;
332
+ recordChild(current, step.id, 'compensation', child);
333
+ target.status = 'compensation_waiting';
334
+ current.status = 'compensating';
335
+ current.cursor = index + 1;
336
+ return true;
337
+ }, 'saga.compensation.waiting', { stepId: step.id, childRunId: child.id });
338
+ return snapshot(record);
339
+ }
340
+ if (successfulChild(child)) {
341
+ await mutate(id, current => {
342
+ const target = current.steps[step.id];
343
+ if (target.compensationRunId !== child.id || target.status === 'compensated')
344
+ return false;
345
+ recordChild(current, step.id, 'compensation', child);
346
+ target.status = 'compensated';
347
+ current.status = 'compensating';
348
+ current.cursor = index;
349
+ return true;
350
+ }, 'saga.compensation.succeeded', { stepId: step.id, childRunId: child.id });
351
+ continue;
352
+ }
353
+ record = await mutate(id, current => {
354
+ const target = current.steps[step.id];
355
+ if (target.compensationRunId !== child.id || target.status === 'compensation_failed')
356
+ return false;
357
+ recordChild(current, step.id, 'compensation', child);
358
+ target.status = 'compensation_failed';
359
+ current.status = 'compensation_failed';
360
+ current.cursor = index;
361
+ return true;
362
+ }, 'saga.compensation.failed', { stepId: step.id, childRunId: child.id, childStatus: child.status });
363
+ return snapshot(record);
364
+ }
365
+ }
366
+ return snapshot(await load(id));
367
+ };
368
+ return Object.freeze({
369
+ profile: 'saga-v1', lifecycle,
370
+ submit: async (definition, command) => {
371
+ ensureOpen();
372
+ assertWorkflowSaga(definition);
373
+ if (definition.maxCostMicros > options.maxCostMicros)
374
+ throw new MayuraError('LIMIT_EXCEEDED', 'Saga static cost exceeds its runtime ceiling.');
375
+ if (typeof command.idempotencyKey !== 'string' || command.idempotencyKey.length < 1 || command.idempotencyKey.length > 128) {
376
+ throw new MayuraError('INVALID_INPUT', 'A bounded saga submission key is required.');
377
+ }
378
+ const raw = freezeJson(jsonValue(command.input, { maxBytes: maxOutputBytes }));
379
+ const input = await boundedValidate(definition.input, raw, 'input');
380
+ const state = initialWorkflowSagaState(sagaManifest(definition), input, definition.digest, policy, options.maxCostMicros);
381
+ const id = digest('mayura:workflow-saga-run-id:v1', { scope: scopeKey, submissionKey: command.idempotencyKey });
382
+ const created = await storageCall(() => store.create({ scope: scopeKey, id,
383
+ idempotencyKey: `saga:${command.idempotencyKey}`, definitionHash: definition.digest,
384
+ state: jsonValue(state), events: [{ type: 'saga.run.created', data: {} }] }));
385
+ verify(definition, created.record, decoded(created.record));
386
+ return snapshot(created.record);
387
+ },
388
+ inspect: async (id) => snapshot(await load(id)),
389
+ events: (id, after = 0) => { ensureOpen(); return storageCall(() => store.events(scopeKey, id, after)); },
390
+ runUntilSettled: run,
391
+ pause: async (id) => snapshot(await mutate(id, state => {
392
+ if (state.status === 'paused')
393
+ return false;
394
+ if (terminalSagaStatuses.has(state.status))
395
+ throw new MayuraError('CONFLICT', 'A terminal saga cannot be paused.');
396
+ state.status = 'paused';
397
+ return true;
398
+ }, 'saga.run.paused')),
399
+ resume: async (id) => snapshot(await mutate(id, state => {
400
+ if (state.status !== 'paused')
401
+ throw new MayuraError('CONFLICT', 'Only a paused saga can be resumed.');
402
+ const compensating = Object.values(state.steps).some(step => ['failed', 'compensation_waiting', 'compensated', 'compensation_failed'].includes(step.status));
403
+ state.status = compensating ? 'compensating' : 'running';
404
+ return true;
405
+ }, 'saga.run.resumed')),
406
+ migrate: async (migration, command) => {
407
+ ensureOpen();
408
+ assertWorkflowMigration(migration);
409
+ assertWorkflowSaga(migration.from);
410
+ assertWorkflowSaga(migration.to);
411
+ const { id, actorId, commandId, dryRun = false } = migrationCommand(command);
412
+ const record = await load(id);
413
+ const state = decoded(record);
414
+ verify(migration.from, record, state);
415
+ const preconditions = [];
416
+ if (state.status !== 'paused')
417
+ preconditions.push({ node: '*', reason: `The saga is ${state.status}; pause it before migrating.` });
418
+ if (Object.values(state.steps).some(step => ['failed', 'compensation_waiting', 'compensated', 'compensation_failed'].includes(step.status))) {
419
+ preconditions.push({ node: '*', reason: 'The saga is compensating; only a saga in its forward phase can migrate.' });
420
+ }
421
+ // A running linked child is compared by the definition it is actually pinned to (possibly already migrated).
422
+ const linked = new Map();
423
+ for (const [stepId, step] of Object.entries(state.steps))
424
+ if (step.status === 'forward_waiting' && step.forwardRunId) {
425
+ const child = await storageCall(() => store.read(scopeKey, step.forwardRunId));
426
+ if (!child)
427
+ throw new MayuraError('CONFLICT', 'A linked saga child run is missing.');
428
+ linked.set(stepId, child.definitionHash);
429
+ }
430
+ const nodes = (definition, effective) => sagaManifest(definition).steps.map((step, index, all) => {
431
+ const forward = effective && linked.has(step.id) ? { ...step.forward, definitionHash: linked.get(step.id) } : step.forward;
432
+ return { id: step.id, kind: 'saga-step', dependsOn: index === 0 ? [] : [all[index - 1].id], fingerprint: nodeFingerprint({ ...step, forward }) };
433
+ });
434
+ const statusFor = (status) => status === 'forward_waiting' ? 'running' : status;
435
+ const plan = planWorkflowMigration({ migration, format: 'saga-v1', runId: id, fromDigest: migration.from.digest, toDigest: migration.to.digest,
436
+ from: nodes(migration.from, true), to: nodes(migration.to, false),
437
+ steps: Object.entries(state.steps).map(([step, value]) => ({ id: step, status: statusFor(value.status) })),
438
+ preconditions: [...preconditions, ...Object.entries(state.steps).filter(([stepId, step]) => (step.forwardSpentMicros + step.compensationSpentMicros) > 0
439
+ && !sagaManifest(migration.to).steps.some(target => target.id === stepId || migration.renames[target.id] === stepId))
440
+ .map(([stepId]) => ({ node: stepId, reason: `Step "${stepId}" already spent budget; removing it would drop recorded spend.` }))] });
441
+ if (dryRun)
442
+ return freezeJson(jsonValue({ plan }));
443
+ assertMigrationAllowed(plan);
444
+ const toManifest = sagaManifest(migration.to);
445
+ const fresh = initialWorkflowSagaState(toManifest, state.input, migration.to.digest, policy, options.maxCostMicros);
446
+ const carried = {};
447
+ for (const entry of plan.entries)
448
+ if (entry.target)
449
+ carried[entry.target] = entry.action === 'keep' || entry.action === 'accept' ? state.steps[entry.source] : fresh.steps[entry.target];
450
+ const steps = Object.fromEntries(toManifest.steps.map(step => [step.id, carried[step.id]]));
451
+ const cursor = toManifest.steps.findIndex(step => steps[step.id].status !== 'succeeded');
452
+ const next = { ...state, definition: migration.to.digest, steps, cursor: cursor < 0 ? toManifest.steps.length : cursor,
453
+ spentMicros: Object.values(steps).reduce((sum, step) => sum + step.forwardSpentMicros + step.compensationSpentMicros, 0) };
454
+ try {
455
+ assertWorkflowSagaStateMatchesManifest(workflowSagaState({ id, state: jsonValue(next) }), toManifest);
456
+ }
457
+ catch {
458
+ throw new MayuraError('CONFLICT', 'Migration refused: the migrated saga state does not satisfy the new definition.');
459
+ }
460
+ if (typeof store.migrate !== 'function')
461
+ throw new MayuraError('UNSUPPORTED_PROFILE', 'This store cannot migrate in-flight workflow runs.');
462
+ const migrated = await storageCall(() => store.migrate({ scope: scopeKey, id, expectedVersion: record.version, expectedDefinitionHash: migration.from.digest,
463
+ definitionHash: migration.to.digest, state: jsonValue(next), events: [migrationEvent(plan, actorId, commandId)] }));
464
+ verify(migration.to, migrated, decoded(migrated));
465
+ return freezeJson(jsonValue({ plan, snapshot: snapshot(migrated) }));
466
+ },
467
+ cancel: async (id) => {
468
+ let record = await load(id);
469
+ const state = decoded(record);
470
+ if (terminalSagaStatuses.has(state.status))
471
+ return snapshot(record);
472
+ const activeEntry = Object.entries(state.steps).find(([, step]) => step.status === 'forward_waiting' || step.status === 'compensation_waiting');
473
+ const active = activeEntry?.[1];
474
+ const activeStepId = activeEntry?.[0];
475
+ const childRunId = active?.status === 'forward_waiting' ? active.forwardRunId : active?.compensationRunId;
476
+ const child = childRunId ? await lifecycle.cancel(childRunId) : undefined;
477
+ record = await mutate(id, current => {
478
+ if (terminalSagaStatuses.has(current.status))
479
+ return false;
480
+ if (child && active && activeStepId) {
481
+ const phase = active.status === 'forward_waiting' ? 'forward' : 'compensation';
482
+ const target = current.steps[activeStepId];
483
+ const linked = phase === 'forward' ? target?.forwardRunId : target?.compensationRunId;
484
+ if (linked === child.id)
485
+ recordChild(current, activeStepId, phase, child);
486
+ }
487
+ current.status = 'cancelled';
488
+ return true;
489
+ }, 'saga.run.cancelled');
490
+ return snapshot(record);
491
+ },
492
+ close: () => { if (!closed) {
493
+ closed = true;
494
+ lifecycle.close();
495
+ } },
496
+ drain: async (options) => { const report = await lifecycle.drain(options); closed = true; return report; },
497
+ });
498
+ }
499
+ //# sourceMappingURL=saga-runtime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"saga-runtime.js","sourceRoot":"","sources":["../src/saga-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,QAAQ,EAAoD,MAAM,cAAc,CAAC;AAE9H,OAAO,EAAE,YAAY,EAAE,sCAAsC,EAAE,wBAAwB,EAAE,iBAAiB,EACR,MAAM,2BAA2B,CAAC;AACpI,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAE,8BAA8B,EACiC,MAAM,wBAAwB,CAAC;AACvG,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAA+C,MAAM,sBAAsB,CAAC;AACrH,OAAO,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,gBAAgB,EAAE,cAAc,EAAE,eAAe,EAAE,qBAAqB,EAC5B,MAAM,gBAAgB,CAAC;AAoC7H,MAAM,WAAW,GAAG,gBAAgB,CAAC;AACrC,MAAM,oBAAoB,GAA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AAC,EAAE;wBAAE,WAAW,CAAC,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;gBAC5E,CAAC;gBACD,OAAO,CAAC,MAAM,GAAG,WAAW,CAAC;gBAAC,OAAO,IAAI,CAAC;YAC5C,CAAC,EAAE,oBAAoB,CAAC,CAAC;YACzB,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC;QAC1B,CAAC;QACD,KAAK,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;YAAC,MAAM,GAAG,IAAI,CAAC;YAAC,SAAS,CAAC,KAAK,EAAE,CAAC;QAAC,CAAC,CAAC,CAAC;QACnE,KAAK,EAAE,KAAK,EAAC,OAAO,EAAC,EAAE,GAAG,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC,OAAO,MAAM,CAAC,CAAC,CAAC;KACzG,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { freezeJson, jsonValue, MayuraError, validate, type InferInput, type JsonObject, type JsonValue } from '@mayura/core';\nimport type { WorkflowDrainOptions, WorkflowDrainReport } from './drain.js';\nimport { StorageError, assertWorkflowSagaStateMatchesManifest, initialWorkflowSagaState, workflowSagaState,\n type StoredRecord, type WorkflowSagaState, type WorkflowSagaStatus, type WorkflowSagaStepState } from '@mayura/storage-contracts';\nimport { digest, resolveBinding } from './definition.js';\nimport { createWorkflowLifecycleRuntime, type WorkflowLifecycleRuntime,\n type WorkflowLifecycleRuntimeOptions, type WorkflowLifecycleSnapshot } from './lifecycle-runtime.js';\nimport { assertWorkflowSaga, sagaManifest, type AnyWorkflowSaga, type WorkflowSagaStep } from './saga-definition.js';\nimport { assertMigrationAllowed, assertWorkflowMigration, migrationCommand, migrationEvent, nodeFingerprint, planWorkflowMigration,\n type MigrationBlocker, type MigrationCommand, type WorkflowMigration, type WorkflowMigrationResult } from './migration.js';\n\nexport interface WorkflowSagaRuntimeOptions extends WorkflowLifecycleRuntimeOptions {}\n\nexport interface WorkflowSagaSnapshot {\n readonly id: string;\n readonly version: number;\n readonly status: WorkflowSagaStatus;\n readonly cursor: number;\n readonly steps: Readonly<Record<string, Readonly<WorkflowSagaStepState>>>;\n readonly output: JsonValue;\n readonly budget: { readonly spentMicros: number; readonly maxCostMicros: number };\n}\n\nexport interface WorkflowSagaRuntime {\n readonly profile: 'saga-v1';\n /** Child runtime used to inspect, approve, or answer the currently linked lifecycle run. */\n readonly lifecycle: WorkflowLifecycleRuntime;\n submit<D extends AnyWorkflowSaga>(definition: D, command: { readonly input: InferInput<D['input']>; readonly idempotencyKey: string }): Promise<WorkflowSagaSnapshot>;\n inspect(id: string): Promise<WorkflowSagaSnapshot>;\n events(id: string, after?: number): ReturnType<WorkflowSagaRuntimeOptions['store']['events']>;\n runUntilSettled(definition: AnyWorkflowSaga, id: string): Promise<WorkflowSagaSnapshot>;\n /** Quiescent operator pause: no further child is started or driven; the linked child keeps its own state. */\n pause(id: string): Promise<WorkflowSagaSnapshot>;\n resume(id: string): Promise<WorkflowSagaSnapshot>;\n /**\n * Plan (dryRun) or apply a reviewed migration of a paused saga in its forward phase. A step whose linked child is still\n * running keeps it only if the child already runs the target's child definition: migrate the child first.\n */\n migrate(migration: WorkflowMigration<AnyWorkflowSaga, AnyWorkflowSaga>, command: MigrationCommand): Promise<WorkflowMigrationResult<WorkflowSagaSnapshot>>;\n cancel(id: string): Promise<WorkflowSagaSnapshot>;\n close(): void;\n /** Let admitted child effects settle within the deadline, then close. */\n drain(options?: WorkflowDrainOptions): Promise<WorkflowDrainReport>;\n}\n\nconst hashPattern = /^[a-f0-9]{64}$/;\nconst terminalSagaStatuses = new Set<WorkflowSagaStatus>(['succeeded', 'failed', 'compensated', 'compensation_failed', 'cancelled']);\nconst successfulChild = (snapshot: WorkflowLifecycleSnapshot): boolean => snapshot.status === 'succeeded';\nconst terminalChild = (snapshot: WorkflowLifecycleSnapshot): boolean =>\n ['succeeded', 'failed', 'blocked', 'cancelled', 'outcome_unknown'].includes(snapshot.status);\n\nasync function storageCall<T>(operation: () => Promise<T>): Promise<T> {\n try { return await operation(); }\n catch (error) {\n if (error instanceof StorageError && error.code === 'CONFLICT') throw error;\n throw new MayuraError('STORAGE_UNAVAILABLE', 'Workflow saga storage is unavailable; inspect current state before retrying.');\n }\n}\n\nfunction decoded(record: StoredRecord): WorkflowSagaState {\n try { return workflowSagaState(record); }\n catch { throw new MayuraError('CONFLICT', 'Stored workflow saga state failed integrity validation.'); }\n}\n\nfunction snapshot(record: StoredRecord): WorkflowSagaSnapshot {\n const state = decoded(record);\n return freezeJson(jsonValue({ id: record.id, version: record.version, status: state.status, cursor: state.cursor,\n steps: state.steps, output: state.output, budget: { spentMicros: state.spentMicros,\n maxCostMicros: state.maxCostMicros } })) as unknown as WorkflowSagaSnapshot;\n}\n\nfunction outputs(state: WorkflowSagaState): Record<string, JsonValue> {\n return Object.fromEntries(Object.entries(state.steps).filter(([, step]) =>\n ['succeeded', 'compensation_waiting', 'compensated', 'compensation_failed'].includes(step.status))\n .map(([id, step]) => [id, step.output]));\n}\n\nfunction childKey(sagaRunId: string, stepId: string, phase: 'forward' | 'compensation'): string {\n return digest('mayura:workflow-saga-child:v1', { sagaRunId, stepId, phase });\n}\n\n/**\n * Durable saga coordinator built from format-5 lifecycle children.\n * The generic aggregate API cannot atomically write a child and its saga link; the\n * stable child key makes replay after that narrow crash window converge safely.\n */\nexport function createWorkflowSagaRuntime(options: WorkflowSagaRuntimeOptions): WorkflowSagaRuntime {\n const store = options.store;\n const scope = Object.freeze({ principalId: options.scope?.principalId, projectId: options.scope?.projectId });\n if ([scope.principalId, scope.projectId, options.policyVersion].some(value =>\n typeof value !== 'string' || value.length < 1 || value.length > 128)) {\n throw new MayuraError('INVALID_CONFIG', 'Workflow saga scope and policy version are required.');\n }\n if (!Array.isArray(options.permissions?.allow) || options.permissions.allow.length > 4_096\n || options.permissions.allow.some(grant => typeof grant !== 'string' || grant.length < 1 || grant.length > 256)) {\n throw new MayuraError('INVALID_CONFIG', 'Workflow saga permissions must be bounded explicit grants.');\n }\n if (!Number.isSafeInteger(options.maxCostMicros) || options.maxCostMicros < 0) {\n throw new MayuraError('INVALID_CONFIG', 'A bounded saga cost is required.');\n }\n const maxOutputBytes = options.maxOutputBytes ?? 1_048_576;\n const callbackTimeoutMs = options.callbackTimeoutMs ?? 30_000;\n const maxPendingCallbacks = options.maxPendingCallbacks ?? 32;\n if (!Number.isSafeInteger(maxOutputBytes) || maxOutputBytes < 1 || !Number.isSafeInteger(callbackTimeoutMs) || callbackTimeoutMs < 1) {\n throw new MayuraError('INVALID_CONFIG', 'Saga callback and output bounds must be positive integers.');\n }\n if (!Number.isSafeInteger(maxPendingCallbacks) || maxPendingCallbacks < 1 || maxPendingCallbacks > 128) {\n throw new MayuraError('INVALID_CONFIG', 'maxPendingCallbacks must be an integer from 1 through 128.');\n }\n const lifecycle = createWorkflowLifecycleRuntime(options);\n const scopeKey = digest('mayura:scope:v1', scope);\n const policy = digest('mayura:workflow-saga-policy:v1', { scope, permissions: [...options.permissions.allow].sort(),\n policyVersion: options.policyVersion, maxCostMicros: options.maxCostMicros, maxOutputBytes,\n approvalTtlMs: options.approvalTtlMs ?? 3_600_000 });\n let closed = false;\n const ensureOpen = (): void => { if (closed) throw new MayuraError('CANCELLED', 'Workflow saga runtime is closed.'); };\n let pendingCallbacks = 0;\n const boundedValidate = async (schema: AnyWorkflowSaga['input'] | AnyWorkflowSaga['output'], value: unknown,\n boundary: 'input' | 'output'): Promise<JsonValue> => {\n if (pendingCallbacks >= maxPendingCallbacks) throw new MayuraError('LIMIT_EXCEEDED', 'Saga callback capacity is full.');\n pendingCallbacks += 1; let released = false;\n const release = (): void => { if (!released) { released = true; pendingCallbacks -= 1; } };\n const validation = Promise.resolve().then(() => validate(schema, value, boundary, { maxBytes: maxOutputBytes }));\n void validation.then(release, release);\n let timer: ReturnType<typeof setTimeout> | undefined;\n try {\n const checked = await Promise.race([validation,\n new Promise<never>((_resolve, reject) => { timer = setTimeout(() => reject(new MayuraError('TIMEOUT', 'Saga schema validation timed out.')), callbackTimeoutMs); })]);\n return jsonValue(checked, { maxBytes: maxOutputBytes });\n } finally { if (timer !== undefined) clearTimeout(timer); }\n };\n const load = async (id: string): Promise<StoredRecord> => {\n ensureOpen();\n if (typeof id !== 'string' || !hashPattern.test(id)) throw new MayuraError('INVALID_INPUT', 'A workflow saga run ID is required.');\n const record = await storageCall(() => store.read(scopeKey, id));\n if (!record) throw new MayuraError('NOT_FOUND', 'Workflow saga run was not found in this scope.');\n if (record.scope !== scopeKey || record.id !== id) throw new MayuraError('CONFLICT', 'Stored saga identity does not match its requested scope.');\n const state = decoded(record);\n if (state.policy !== policy) throw new MayuraError('CONFLICT', 'Stored saga policy does not match this runtime.');\n return record;\n };\n const verify = (definition: AnyWorkflowSaga, record: StoredRecord, state: WorkflowSagaState): void => {\n if (record.definitionHash !== definition.digest || state.definition !== definition.digest || state.policy !== policy) {\n throw new MayuraError('CONFLICT', 'Workflow saga definition or policy does not match persisted state.');\n }\n try { assertWorkflowSagaStateMatchesManifest(state, sagaManifest(definition)); }\n catch { throw new MayuraError('CONFLICT', 'Workflow saga state does not match its persisted definition.'); }\n };\n const save = (record: StoredRecord, state: WorkflowSagaState, type: string, data: JsonObject = {}): Promise<StoredRecord> =>\n storageCall(() => store.update({ scope: scopeKey, id: record.id, expectedVersion: record.version,\n state: jsonValue(state) as JsonObject, events: [{ type, data }] }));\n const mutate = async (id: string, transition: (state: WorkflowSagaState) => boolean, type: string,\n data: JsonObject = {}): Promise<StoredRecord> => {\n for (let attempt = 0; attempt < 32; attempt++) {\n const record = await load(id); const state = decoded(record); const paused = state.status === 'paused';\n if (!transition(state)) return record;\n // Progress recorded while paused (a child settling) never un-pauses the saga; only a terminal outcome replaces it.\n if (paused && !terminalSagaStatuses.has(state.status) && type !== 'saga.run.resumed') state.status = 'paused';\n try { return await save(record, state, type, data); }\n catch (error) { if (!(error instanceof StorageError) || error.code !== 'CONFLICT') throw error; }\n }\n throw new MayuraError('CONFLICT', 'Workflow saga contention exceeded the bounded retry limit.');\n };\n const recordChild = (state: WorkflowSagaState, stepId: string, phase: 'forward' | 'compensation',\n child: WorkflowLifecycleSnapshot): void => {\n const step = state.steps[stepId]!;\n if (phase === 'forward') { step.forwardRunId = child.id; step.forwardSpentMicros = child.budget.spentMicros; }\n else { step.compensationRunId = child.id; step.compensationSpentMicros = child.budget.spentMicros; }\n state.spentMicros = Object.values(state.steps).reduce((sum, item) =>\n sum + item.forwardSpentMicros + item.compensationSpentMicros, 0);\n if (!Number.isSafeInteger(state.spentMicros) || state.spentMicros > state.maxCostMicros) {\n throw new MayuraError('LIMIT_EXCEEDED', 'Workflow saga exceeded its persisted cost ceiling.');\n }\n };\n const submitChild = async (runId: string, step: WorkflowSagaStep, phase: 'forward' | 'compensation',\n state: WorkflowSagaState): Promise<WorkflowLifecycleSnapshot> => {\n const workflow = phase === 'forward' ? step.forward : step.compensation!.workflow;\n const binding = phase === 'forward' ? step.input : step.compensation!.input;\n const input = resolveBinding(binding, state.input, outputs(state));\n return lifecycle.submit(workflow, { input, idempotencyKey: childKey(runId, step.id, phase) });\n };\n\n const run = async (definition: AnyWorkflowSaga, id: string): Promise<WorkflowSagaSnapshot> => {\n assertWorkflowSaga(definition);\n for (let wave = 0; wave < definition.steps.length * 2 + 4; wave++) {\n let record = await load(id); let state = decoded(record); verify(definition, record, state);\n if (terminalSagaStatuses.has(state.status) || state.status === 'paused') return snapshot(record);\n if (state.status === 'running' || state.status === 'waiting') {\n const index = state.cursor; const step = definition.steps[index];\n if (!step) {\n let output: JsonValue;\n try { output = await boundedValidate(definition.output,\n resolveBinding(definition.result, state.input, outputs(state)), 'output'); }\n catch (error) {\n if (!(error instanceof MayuraError) || !['INVALID_INPUT', 'INVALID_OUTPUT'].includes(error.code)) throw error;\n state.status = 'compensating'; state.cursor = definition.steps.length;\n await save(record, state, 'saga.output.rejected'); continue;\n }\n state.output = output; state.status = 'succeeded';\n record = await save(record, state, 'saga.run.succeeded'); return snapshot(record);\n }\n const persisted = state.steps[step.id]!;\n let child: WorkflowLifecycleSnapshot;\n if (persisted.forwardRunId === null) {\n try { child = await submitChild(id, step, 'forward', state); }\n catch (error) {\n if (!(error instanceof MayuraError) || !['INVALID_INPUT', 'INVALID_OUTPUT'].includes(error.code)) throw error;\n await mutate(id, current => { const target = current.steps[step.id]!;\n if (target.status !== 'pending') return false;\n target.status = 'failed';\n for (let next = index + 1; next < definition.steps.length; next++) current.steps[definition.steps[next]!.id]!.status = 'skipped';\n current.status = 'compensating'; current.cursor = index; return true;\n }, 'saga.forward.rejected', { stepId: step.id });\n continue;\n }\n record = await mutate(id, current => { const target = current.steps[step.id]!;\n if (target.forwardRunId !== null) return false;\n recordChild(current, step.id, 'forward', child); target.status = 'forward_waiting';\n current.status = 'running'; return true;\n }, 'saga.forward.linked', { stepId: step.id, childRunId: child.id });\n state = decoded(record); child = await lifecycle.inspect(state.steps[step.id]!.forwardRunId!);\n } else child = await lifecycle.inspect(persisted.forwardRunId);\n child = await lifecycle.runUntilSettled(step.forward, child.id);\n if (!terminalChild(child)) {\n record = await mutate(id, current => { const target = current.steps[step.id]!;\n if (target.forwardRunId !== child.id || terminalSagaStatuses.has(current.status)) return false;\n recordChild(current, step.id, 'forward', child); target.status = 'forward_waiting';\n current.status = child.status === 'waiting' ? 'waiting' : 'running'; return true;\n }, 'saga.forward.waiting', { stepId: step.id, childRunId: child.id });\n return snapshot(record);\n }\n if (successfulChild(child)) {\n record = await mutate(id, current => { const target = current.steps[step.id]!;\n if (target.forwardRunId !== child.id || target.status === 'succeeded') return false;\n recordChild(current, step.id, 'forward', child); target.output = child.output; target.status = 'succeeded';\n current.cursor = index + 1; current.status = 'running'; return true;\n }, 'saga.forward.succeeded', { stepId: step.id, childRunId: child.id });\n continue;\n }\n record = await mutate(id, current => { const target = current.steps[step.id]!;\n if (target.forwardRunId !== child.id || target.status === 'failed') return false;\n recordChild(current, step.id, 'forward', child); target.status = 'failed';\n for (let next = index + 1; next < definition.steps.length; next++) current.steps[definition.steps[next]!.id]!.status = 'skipped';\n current.cursor = index; current.status = 'compensating'; return true;\n }, 'saga.forward.failed', { stepId: step.id, childRunId: child.id, childStatus: child.status });\n continue;\n }\n\n if (state.status === 'compensating') {\n let index = state.cursor - 1;\n while (index >= 0) {\n const candidate = definition.steps[index]!; const persisted = state.steps[candidate.id]!;\n if (persisted.status === 'succeeded' && candidate.compensation) break;\n index -= 1;\n }\n if (index < 0) {\n const compensated = Object.values(state.steps).some(step => step.status === 'compensated');\n state.status = compensated ? 'compensated' : 'failed'; state.cursor = 0;\n record = await save(record, state, compensated ? 'saga.run.compensated' : 'saga.run.failed');\n return snapshot(record);\n }\n const step = definition.steps[index]!; const persisted = state.steps[step.id]!;\n let child: WorkflowLifecycleSnapshot;\n if (persisted.compensationRunId === null) {\n try { child = await submitChild(id, step, 'compensation', state); }\n catch (error) {\n if (!(error instanceof MayuraError) || !['INVALID_INPUT', 'INVALID_OUTPUT'].includes(error.code)) throw error;\n record = await mutate(id, current => { const target = current.steps[step.id]!;\n if (target.status !== 'succeeded') return false;\n target.status = 'compensation_failed'; current.status = 'compensation_failed'; current.cursor = index; return true;\n }, 'saga.compensation.rejected', { stepId: step.id });\n return snapshot(record);\n }\n record = await mutate(id, current => { const target = current.steps[step.id]!;\n if (target.compensationRunId !== null) return false;\n recordChild(current, step.id, 'compensation', child); target.status = 'compensation_waiting';\n current.status = 'compensating'; current.cursor = index + 1; return true;\n }, 'saga.compensation.linked', { stepId: step.id, childRunId: child.id });\n state = decoded(record); child = await lifecycle.inspect(state.steps[step.id]!.compensationRunId!);\n } else child = await lifecycle.inspect(persisted.compensationRunId);\n child = await lifecycle.runUntilSettled(step.compensation!.workflow, child.id);\n if (!terminalChild(child)) {\n record = await mutate(id, current => { const target = current.steps[step.id]!;\n if (target.compensationRunId !== child.id || terminalSagaStatuses.has(current.status)) return false;\n recordChild(current, step.id, 'compensation', child); target.status = 'compensation_waiting';\n current.status = 'compensating'; current.cursor = index + 1; return true;\n }, 'saga.compensation.waiting', { stepId: step.id, childRunId: child.id });\n return snapshot(record);\n }\n if (successfulChild(child)) {\n await mutate(id, current => { const target = current.steps[step.id]!;\n if (target.compensationRunId !== child.id || target.status === 'compensated') return false;\n recordChild(current, step.id, 'compensation', child); target.status = 'compensated';\n current.status = 'compensating'; current.cursor = index; return true;\n }, 'saga.compensation.succeeded', { stepId: step.id, childRunId: child.id });\n continue;\n }\n record = await mutate(id, current => { const target = current.steps[step.id]!;\n if (target.compensationRunId !== child.id || target.status === 'compensation_failed') return false;\n recordChild(current, step.id, 'compensation', child); target.status = 'compensation_failed';\n current.status = 'compensation_failed'; current.cursor = index; return true;\n }, 'saga.compensation.failed', { stepId: step.id, childRunId: child.id, childStatus: child.status });\n return snapshot(record);\n }\n }\n return snapshot(await load(id));\n };\n\n return Object.freeze<WorkflowSagaRuntime>({\n profile: 'saga-v1', lifecycle,\n submit: async (definition, command) => {\n ensureOpen(); assertWorkflowSaga(definition);\n if (definition.maxCostMicros > options.maxCostMicros) throw new MayuraError('LIMIT_EXCEEDED', 'Saga static cost exceeds its runtime ceiling.');\n if (typeof command.idempotencyKey !== 'string' || command.idempotencyKey.length < 1 || command.idempotencyKey.length > 128) {\n throw new MayuraError('INVALID_INPUT', 'A bounded saga submission key is required.');\n }\n const raw = freezeJson(jsonValue(command.input, { maxBytes: maxOutputBytes }));\n const input = await boundedValidate(definition.input, raw, 'input');\n const state = initialWorkflowSagaState(sagaManifest(definition), input, definition.digest, policy, options.maxCostMicros);\n const id = digest('mayura:workflow-saga-run-id:v1', { scope: scopeKey, submissionKey: command.idempotencyKey });\n const created = await storageCall(() => store.create({ scope: scopeKey, id,\n idempotencyKey: `saga:${command.idempotencyKey}`, definitionHash: definition.digest,\n state: jsonValue(state) as JsonObject, events: [{ type: 'saga.run.created', data: {} }] }));\n verify(definition, created.record, decoded(created.record)); return snapshot(created.record);\n },\n inspect: async id => snapshot(await load(id)),\n events: (id, after = 0) => { ensureOpen(); return storageCall(() => store.events(scopeKey, id, after)); },\n runUntilSettled: run,\n pause: async id => snapshot(await mutate(id, state => {\n if (state.status === 'paused') return false;\n if (terminalSagaStatuses.has(state.status)) throw new MayuraError('CONFLICT', 'A terminal saga cannot be paused.');\n state.status = 'paused'; return true;\n }, 'saga.run.paused')),\n resume: async id => snapshot(await mutate(id, state => {\n if (state.status !== 'paused') throw new MayuraError('CONFLICT', 'Only a paused saga can be resumed.');\n const compensating = Object.values(state.steps).some(step => ['failed', 'compensation_waiting', 'compensated', 'compensation_failed'].includes(step.status));\n state.status = compensating ? 'compensating' : 'running'; return true;\n }, 'saga.run.resumed')),\n migrate: async (migration, command) => {\n ensureOpen(); assertWorkflowMigration(migration); assertWorkflowSaga(migration.from); assertWorkflowSaga(migration.to);\n const { id, actorId, commandId, dryRun = false } = migrationCommand(command);\n const record = await load(id); const state = decoded(record); verify(migration.from, record, state);\n const preconditions: MigrationBlocker[] = [];\n if (state.status !== 'paused') preconditions.push({ node: '*', reason: `The saga is ${state.status}; pause it before migrating.` });\n if (Object.values(state.steps).some(step => ['failed', 'compensation_waiting', 'compensated', 'compensation_failed'].includes(step.status))) {\n preconditions.push({ node: '*', reason: 'The saga is compensating; only a saga in its forward phase can migrate.' });\n }\n // A running linked child is compared by the definition it is actually pinned to (possibly already migrated).\n const linked = new Map<string, string>();\n for (const [stepId, step] of Object.entries(state.steps)) if (step.status === 'forward_waiting' && step.forwardRunId) {\n const child = await storageCall(() => store.read(scopeKey, step.forwardRunId!));\n if (!child) throw new MayuraError('CONFLICT', 'A linked saga child run is missing.');\n linked.set(stepId, child.definitionHash);\n }\n const nodes = (definition: AnyWorkflowSaga, effective: boolean) => sagaManifest(definition).steps.map((step, index, all) => {\n const forward = effective && linked.has(step.id) ? { ...step.forward, definitionHash: linked.get(step.id)! } : step.forward;\n return { id: step.id, kind: 'saga-step', dependsOn: index === 0 ? [] : [all[index - 1]!.id], fingerprint: nodeFingerprint({ ...step, forward } as unknown as Record<string, unknown>) };\n });\n const statusFor = (status: string): string => status === 'forward_waiting' ? 'running' : status;\n const plan = planWorkflowMigration({ migration, format: 'saga-v1', runId: id, fromDigest: migration.from.digest, toDigest: migration.to.digest,\n from: nodes(migration.from, true), to: nodes(migration.to, false),\n steps: Object.entries(state.steps).map(([step, value]) => ({ id: step, status: statusFor(value.status) })),\n preconditions: [...preconditions, ...Object.entries(state.steps).filter(([stepId, step]) => (step.forwardSpentMicros + step.compensationSpentMicros) > 0\n && !sagaManifest(migration.to).steps.some(target => target.id === stepId || migration.renames[target.id] === stepId))\n .map(([stepId]) => ({ node: stepId, reason: `Step \"${stepId}\" already spent budget; removing it would drop recorded spend.` }))] });\n if (dryRun) return freezeJson(jsonValue({ plan })) as unknown as WorkflowMigrationResult<WorkflowSagaSnapshot>;\n assertMigrationAllowed(plan);\n const toManifest = sagaManifest(migration.to);\n const fresh = initialWorkflowSagaState(toManifest, state.input, migration.to.digest, policy, options.maxCostMicros);\n const carried: Record<string, WorkflowSagaStepState> = {};\n for (const entry of plan.entries) if (entry.target) carried[entry.target] = entry.action === 'keep' || entry.action === 'accept' ? state.steps[entry.source!]! : fresh.steps[entry.target]!;\n const steps = Object.fromEntries(toManifest.steps.map(step => [step.id, carried[step.id]!]));\n const cursor = toManifest.steps.findIndex(step => steps[step.id]!.status !== 'succeeded');\n const next: WorkflowSagaState = { ...state, definition: migration.to.digest, steps, cursor: cursor < 0 ? toManifest.steps.length : cursor,\n spentMicros: Object.values(steps).reduce((sum, step) => sum + step.forwardSpentMicros + step.compensationSpentMicros, 0) };\n try { assertWorkflowSagaStateMatchesManifest(workflowSagaState({ id, state: jsonValue(next) as JsonObject }), toManifest); }\n catch { throw new MayuraError('CONFLICT', 'Migration refused: the migrated saga state does not satisfy the new definition.'); }\n if (typeof store.migrate !== 'function') throw new MayuraError('UNSUPPORTED_PROFILE', 'This store cannot migrate in-flight workflow runs.');\n const migrated = await storageCall(() => store.migrate!({ scope: scopeKey, id, expectedVersion: record.version, expectedDefinitionHash: migration.from.digest,\n definitionHash: migration.to.digest, state: jsonValue(next) as JsonObject, events: [migrationEvent(plan, actorId, commandId) as { type: string; data: JsonObject }] }));\n verify(migration.to, migrated, decoded(migrated));\n return freezeJson(jsonValue({ plan, snapshot: snapshot(migrated) })) as unknown as WorkflowMigrationResult<WorkflowSagaSnapshot>;\n },\n cancel: async id => {\n let record = await load(id); const state = decoded(record);\n if (terminalSagaStatuses.has(state.status)) return snapshot(record);\n const activeEntry = Object.entries(state.steps).find(([, step]) => step.status === 'forward_waiting' || step.status === 'compensation_waiting');\n const active = activeEntry?.[1]; const activeStepId = activeEntry?.[0];\n const childRunId = active?.status === 'forward_waiting' ? active.forwardRunId : active?.compensationRunId;\n const child = childRunId ? await lifecycle.cancel(childRunId) : undefined;\n record = await mutate(id, current => {\n if (terminalSagaStatuses.has(current.status)) return false;\n if (child && active && activeStepId) {\n const phase = active.status === 'forward_waiting' ? 'forward' : 'compensation';\n const target = current.steps[activeStepId];\n const linked = phase === 'forward' ? target?.forwardRunId : target?.compensationRunId;\n if (linked === child.id) recordChild(current, activeStepId, phase, child);\n }\n current.status = 'cancelled'; return true;\n }, 'saga.run.cancelled');\n return snapshot(record);\n },\n close: () => { if (!closed) { closed = true; lifecycle.close(); } },\n drain: async options => { const report = await lifecycle.drain(options); closed = true; return report; },\n });\n}\n"]}
@@ -0,0 +1,6 @@
1
+ export type { WorkflowDrainOptions, WorkflowDrainReport } from './drain.js';
2
+ export { assertWorkflowSaga, defineWorkflowSaga, sagaManifest, type AnyWorkflowSaga, type WorkflowSagaCompensation, type WorkflowSagaDefinition, type WorkflowSagaOptions, type WorkflowSagaOutput, type WorkflowSagaStep, } from './saga-definition.js';
3
+ export { createWorkflowSagaRuntime, type WorkflowSagaRuntime, type WorkflowSagaRuntimeOptions, type WorkflowSagaSnapshot, } from './saga-runtime.js';
4
+ export type { WorkflowSagaManifest, WorkflowSagaStatus, WorkflowSagaStepStatus, } from '../../storage-contracts/dist/index.js';
5
+ export { defineWorkflowMigration, type WorkflowMigration, type WorkflowMigrationResult, type MigrationPlan, type MigrationCommand } from './migration.js';
6
+ //# sourceMappingURL=sagas.d.ts.map