mayura 0.1.0-dev.0 → 1.0.0-rc.2

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 (578) hide show
  1. package/README.md +152 -35
  2. package/docs/README.md +82 -0
  3. package/docs/ai-agents.md +73 -0
  4. package/docs/cli/dev.md +111 -0
  5. package/docs/cli/init.md +192 -0
  6. package/docs/cli/operations.md +235 -0
  7. package/docs/cli/overview.md +129 -0
  8. package/docs/cli/run.md +182 -0
  9. package/docs/concepts/agent.md +197 -0
  10. package/docs/concepts/costs-and-budgets.md +177 -0
  11. package/docs/concepts/outcomes.md +154 -0
  12. package/docs/concepts/permissions.md +155 -0
  13. package/docs/concepts/runtime.md +172 -0
  14. package/docs/concepts/tools.md +202 -0
  15. package/docs/concepts/workflows.md +134 -0
  16. package/docs/guides/approvals-and-human-input.md +278 -0
  17. package/docs/guides/artifacts.md +123 -0
  18. package/docs/guides/child-agents.md +158 -0
  19. package/docs/guides/code-mode.md +233 -0
  20. package/docs/guides/deployment.md +644 -0
  21. package/docs/guides/durable-workflows.md +463 -0
  22. package/docs/guides/guardrails.md +205 -0
  23. package/docs/guides/helpers.md +176 -0
  24. package/docs/guides/lifecycle-hooks.md +187 -0
  25. package/docs/guides/mcp.md +123 -0
  26. package/docs/guides/memory-and-context.md +293 -0
  27. package/docs/guides/model-providers.md +371 -0
  28. package/docs/guides/model-routing.md +138 -0
  29. package/docs/guides/observability.md +238 -0
  30. package/docs/guides/operator-console.md +140 -0
  31. package/docs/guides/react.md +276 -0
  32. package/docs/guides/sagas-and-loops.md +212 -0
  33. package/docs/guides/server-and-client.md +559 -0
  34. package/docs/guides/skills.md +152 -0
  35. package/docs/guides/storage.md +251 -0
  36. package/docs/guides/streaming.md +146 -0
  37. package/docs/guides/terminal.md +166 -0
  38. package/docs/guides/testing.md +220 -0
  39. package/docs/guides/vision.md +155 -0
  40. package/docs/guides/webhooks.md +172 -0
  41. package/docs/guides/workflow-composition.md +141 -0
  42. package/docs/guides/workflow-operations.md +269 -0
  43. package/docs/installation.md +90 -0
  44. package/docs/introduction.md +74 -0
  45. package/docs/project/credits.md +78 -0
  46. package/docs/project/security.md +178 -0
  47. package/docs/project/support.md +91 -0
  48. package/docs/project/versioning.md +122 -0
  49. package/docs/quickstart.md +190 -0
  50. package/docs/reference/entry-points.md +146 -0
  51. package/lib/adapter-code-docker/dist/index.d.ts +8 -1
  52. package/lib/adapter-code-docker/dist/index.d.ts.map +1 -1
  53. package/lib/adapter-code-docker/dist/index.js +64 -67
  54. package/lib/adapter-code-docker/dist/index.js.map +1 -1
  55. package/lib/adapter-code-docker/dist/options.d.ts +15 -0
  56. package/lib/adapter-code-docker/dist/options.d.ts.map +1 -0
  57. package/lib/adapter-code-docker/dist/options.js +56 -0
  58. package/lib/adapter-code-docker/dist/options.js.map +1 -0
  59. package/lib/adapter-code-docker/image/Dockerfile +4 -2
  60. package/lib/adapter-code-docker/package.json +1 -1
  61. package/lib/adapter-code-docker/src/index.ts +63 -65
  62. package/lib/adapter-code-docker/src/options.ts +51 -0
  63. package/lib/adapter-code-quickjs/dist/index.d.ts +16 -4
  64. package/lib/adapter-code-quickjs/dist/index.d.ts.map +1 -1
  65. package/lib/adapter-code-quickjs/dist/index.js +94 -50
  66. package/lib/adapter-code-quickjs/dist/index.js.map +1 -1
  67. package/lib/adapter-code-quickjs/dist/worker-command.d.ts +27 -0
  68. package/lib/adapter-code-quickjs/dist/worker-command.d.ts.map +1 -0
  69. package/lib/adapter-code-quickjs/dist/worker-command.js +66 -0
  70. package/lib/adapter-code-quickjs/dist/worker-command.js.map +1 -0
  71. package/lib/adapter-code-quickjs/dist/worker.js +421 -104
  72. package/lib/adapter-code-quickjs/dist/worker.js.map +1 -1
  73. package/lib/adapter-code-quickjs/package.json +1 -1
  74. package/lib/adapter-code-quickjs/src/index.ts +88 -44
  75. package/lib/adapter-code-quickjs/src/worker-command.ts +68 -0
  76. package/lib/adapter-code-quickjs/src/worker.ts +315 -89
  77. package/lib/adapter-mcp/package.json +1 -1
  78. package/lib/artifacts/dist/contracts.d.ts +6 -2
  79. package/lib/artifacts/dist/contracts.d.ts.map +1 -1
  80. package/lib/artifacts/dist/contracts.js.map +1 -1
  81. package/lib/artifacts/dist/index.d.ts +1 -0
  82. package/lib/artifacts/dist/index.d.ts.map +1 -1
  83. package/lib/artifacts/dist/index.js +1 -0
  84. package/lib/artifacts/dist/index.js.map +1 -1
  85. package/lib/artifacts/dist/local-store.d.ts.map +1 -1
  86. package/lib/artifacts/dist/local-store.js +4 -7
  87. package/lib/artifacts/dist/local-store.js.map +1 -1
  88. package/lib/artifacts/dist/media.d.ts +11 -0
  89. package/lib/artifacts/dist/media.d.ts.map +1 -0
  90. package/lib/artifacts/dist/media.js +18 -0
  91. package/lib/artifacts/dist/media.js.map +1 -0
  92. package/lib/artifacts/package.json +1 -1
  93. package/lib/artifacts/src/contracts.ts +6 -2
  94. package/lib/artifacts/src/index.ts +1 -0
  95. package/lib/artifacts/src/local-store.ts +5 -7
  96. package/lib/artifacts/src/media.ts +20 -0
  97. package/lib/cli/dist/agent-guide.d.ts +10 -0
  98. package/lib/cli/dist/agent-guide.d.ts.map +1 -0
  99. package/lib/cli/dist/agent-guide.js +48 -0
  100. package/lib/cli/dist/agent-guide.js.map +1 -0
  101. package/lib/cli/dist/application.d.ts +24 -0
  102. package/lib/cli/dist/application.d.ts.map +1 -1
  103. package/lib/cli/dist/application.js +21 -0
  104. package/lib/cli/dist/application.js.map +1 -1
  105. package/lib/cli/dist/bin.js +26 -6
  106. package/lib/cli/dist/bin.js.map +1 -1
  107. package/lib/cli/dist/dev.d.ts.map +1 -1
  108. package/lib/cli/dist/dev.js +7 -1
  109. package/lib/cli/dist/dev.js.map +1 -1
  110. package/lib/cli/dist/index.d.ts +3 -3
  111. package/lib/cli/dist/index.d.ts.map +1 -1
  112. package/lib/cli/dist/index.js +19 -9
  113. package/lib/cli/dist/index.js.map +1 -1
  114. package/lib/cli/dist/interactive.d.ts.map +1 -1
  115. package/lib/cli/dist/interactive.js +52 -11
  116. package/lib/cli/dist/interactive.js.map +1 -1
  117. package/lib/cli/dist/operations.d.ts +25 -2
  118. package/lib/cli/dist/operations.d.ts.map +1 -1
  119. package/lib/cli/dist/operations.js +125 -12
  120. package/lib/cli/dist/operations.js.map +1 -1
  121. package/lib/cli/dist/output.d.ts.map +1 -1
  122. package/lib/cli/dist/output.js +3 -0
  123. package/lib/cli/dist/output.js.map +1 -1
  124. package/lib/cli/dist/providers.d.ts +34 -4
  125. package/lib/cli/dist/providers.d.ts.map +1 -1
  126. package/lib/cli/dist/providers.js +26 -5
  127. package/lib/cli/dist/providers.js.map +1 -1
  128. package/lib/cli/package.json +1 -1
  129. package/lib/cli/src/agent-guide.ts +47 -0
  130. package/lib/cli/src/application.ts +24 -0
  131. package/lib/cli/src/bin.ts +22 -5
  132. package/lib/cli/src/dev.ts +5 -1
  133. package/lib/cli/src/index.ts +18 -10
  134. package/lib/cli/src/interactive.ts +44 -12
  135. package/lib/cli/src/operations.ts +82 -12
  136. package/lib/cli/src/output.ts +3 -0
  137. package/lib/cli/src/providers.ts +45 -10
  138. package/lib/cli/starters/approval-workflow/dot-env.example +11 -0
  139. package/lib/cli/starters/approval-workflow/package.json +1 -2
  140. package/lib/cli/starters/approval-workflow/src/config.ts +25 -7
  141. package/lib/cli/starters/approval-workflow/src/intake.ts +1 -2
  142. package/lib/cli/starters/approval-workflow/src/model.ts +11 -4
  143. package/lib/cli/starters/approval-workflow/src/workflow.ts +1 -2
  144. package/lib/cli/starters/cli-agent/README.md +121 -0
  145. package/lib/cli/starters/cli-agent/dot-env.example +37 -0
  146. package/lib/cli/starters/cli-agent/dot-github/workflows/ci.yml +13 -0
  147. package/lib/cli/starters/cli-agent/dot-gitignore +10 -0
  148. package/lib/cli/starters/cli-agent/mayura.project.json +15 -0
  149. package/lib/cli/starters/cli-agent/package.json +28 -0
  150. package/lib/cli/starters/cli-agent/skills/release-notes/SKILL.md +18 -0
  151. package/lib/cli/starters/cli-agent/skills/release-notes/references/example.md +12 -0
  152. package/lib/cli/starters/cli-agent/src/assistant.ts +124 -0
  153. package/lib/cli/starters/cli-agent/src/cli.ts +72 -0
  154. package/lib/cli/starters/cli-agent/src/config.ts +117 -0
  155. package/lib/cli/starters/cli-agent/src/model.ts +34 -0
  156. package/lib/cli/starters/cli-agent/src/workspace.ts +170 -0
  157. package/lib/cli/starters/cli-agent/test/assistant.test.ts +205 -0
  158. package/lib/cli/starters/cli-agent/tsconfig.json +20 -0
  159. package/lib/cli/starters/event-automation/README.md +4 -3
  160. package/lib/cli/starters/event-automation/dot-env.example +11 -0
  161. package/lib/cli/starters/event-automation/package.json +1 -2
  162. package/lib/cli/starters/event-automation/src/config.ts +25 -7
  163. package/lib/cli/starters/event-automation/src/ingress.ts +3 -5
  164. package/lib/cli/starters/event-automation/src/model.ts +11 -4
  165. package/lib/cli/starters/event-automation/src/send-sample.ts +1 -1
  166. package/lib/cli/starters/event-automation/src/tracker/main.ts +1 -1
  167. package/lib/cli/starters/event-automation/src/tracker/mcp-server.ts +1 -1
  168. package/lib/cli/starters/event-automation/src/tracker/tickets.ts +1 -1
  169. package/lib/cli/starters/event-automation/src/tracker-tools.ts +1 -1
  170. package/lib/cli/starters/event-automation/src/triage.ts +15 -22
  171. package/lib/cli/starters/event-automation/src/workflows.ts +1 -1
  172. package/lib/cli/starters/event-automation/test/automation.test.ts +3 -3
  173. package/lib/cli/starters/research-team/README.md +2 -2
  174. package/lib/cli/starters/research-team/dot-env.example +11 -0
  175. package/lib/cli/starters/research-team/package.json +1 -2
  176. package/lib/cli/starters/research-team/src/config.ts +25 -7
  177. package/lib/cli/starters/research-team/src/desk.ts +1 -2
  178. package/lib/cli/starters/research-team/src/library/index.ts +1 -2
  179. package/lib/cli/starters/research-team/src/model.ts +11 -4
  180. package/lib/cli/starters/research-team/src/services.ts +1 -1
  181. package/lib/cli/starters/research-team/src/team.ts +1 -2
  182. package/lib/cli/starters/research-team/src/workflow.ts +45 -59
  183. package/lib/cli/starters/support-agent/dot-env.example +11 -0
  184. package/lib/cli/starters/support-agent/package.json +1 -2
  185. package/lib/cli/starters/support-agent/src/assistant.ts +5 -5
  186. package/lib/cli/starters/support-agent/src/config.ts +25 -7
  187. package/lib/cli/starters/support-agent/src/guardrails.ts +3 -1
  188. package/lib/cli/starters/support-agent/src/model.ts +11 -4
  189. package/lib/cli/starters/support-agent/src/returns.ts +1 -2
  190. package/lib/cli/starters/support-agent/test/support.test.ts +25 -1
  191. package/lib/cli/templates/basic-agent.ts +1 -2
  192. package/lib/cli/templates/capability-policy.ts +1 -2
  193. package/lib/cli/templates/code-mode-workflow.ts +1 -1
  194. package/lib/cli/templates/durable-approval.ts +1 -1
  195. package/lib/cli/templates/parallel-research.ts +1 -2
  196. package/lib/cli/templates/typed-tool-runner.ts +1 -2
  197. package/lib/client/dist/forms.d.ts.map +1 -1
  198. package/lib/client/dist/forms.js +3 -4
  199. package/lib/client/dist/forms.js.map +1 -1
  200. package/lib/client/dist/headless.d.ts +3 -1
  201. package/lib/client/dist/headless.d.ts.map +1 -1
  202. package/lib/client/dist/headless.js +10 -6
  203. package/lib/client/dist/headless.js.map +1 -1
  204. package/lib/client/dist/index.d.ts +95 -6
  205. package/lib/client/dist/index.d.ts.map +1 -1
  206. package/lib/client/dist/index.js +397 -124
  207. package/lib/client/dist/index.js.map +1 -1
  208. package/lib/client/dist/workflows.d.ts +1 -1
  209. package/lib/client/dist/workflows.d.ts.map +1 -1
  210. package/lib/client/dist/workflows.js +7 -6
  211. package/lib/client/dist/workflows.js.map +1 -1
  212. package/lib/client/package.json +1 -1
  213. package/lib/client/src/forms.ts +3 -4
  214. package/lib/client/src/headless.ts +13 -7
  215. package/lib/client/src/index.ts +344 -74
  216. package/lib/client/src/workflows.ts +8 -7
  217. package/lib/client-react/package.json +1 -1
  218. package/lib/code-mode/dist/index.d.ts +32 -1
  219. package/lib/code-mode/dist/index.d.ts.map +1 -1
  220. package/lib/code-mode/dist/index.js +289 -221
  221. package/lib/code-mode/dist/index.js.map +1 -1
  222. package/lib/code-mode/package.json +1 -1
  223. package/lib/code-mode/src/index.ts +288 -184
  224. package/lib/code-mode-workflows/package.json +1 -1
  225. package/lib/context/package.json +1 -1
  226. package/lib/core/dist/budget.d.ts.map +1 -1
  227. package/lib/core/dist/budget.js +17 -2
  228. package/lib/core/dist/budget.js.map +1 -1
  229. package/lib/core/dist/contracts.d.ts +57 -0
  230. package/lib/core/dist/contracts.d.ts.map +1 -1
  231. package/lib/core/dist/contracts.js +36 -0
  232. package/lib/core/dist/contracts.js.map +1 -1
  233. package/lib/core/dist/destination.d.ts +12 -0
  234. package/lib/core/dist/destination.d.ts.map +1 -0
  235. package/lib/core/dist/destination.js +37 -0
  236. package/lib/core/dist/destination.js.map +1 -0
  237. package/lib/core/dist/event-stream.d.ts +1 -1
  238. package/lib/core/dist/event-stream.d.ts.map +1 -1
  239. package/lib/core/dist/event-stream.js +7 -0
  240. package/lib/core/dist/event-stream.js.map +1 -1
  241. package/lib/core/dist/host.d.ts +3 -0
  242. package/lib/core/dist/host.d.ts.map +1 -1
  243. package/lib/core/dist/host.js +3 -0
  244. package/lib/core/dist/host.js.map +1 -1
  245. package/lib/core/dist/index.d.ts +2 -0
  246. package/lib/core/dist/index.d.ts.map +1 -1
  247. package/lib/core/dist/index.js +2 -0
  248. package/lib/core/dist/index.js.map +1 -1
  249. package/lib/core/dist/media.d.ts +98 -0
  250. package/lib/core/dist/media.d.ts.map +1 -0
  251. package/lib/core/dist/media.js +227 -0
  252. package/lib/core/dist/media.js.map +1 -0
  253. package/lib/core/dist/model-schema.d.ts +37 -0
  254. package/lib/core/dist/model-schema.d.ts.map +1 -0
  255. package/lib/core/dist/model-schema.js +154 -0
  256. package/lib/core/dist/model-schema.js.map +1 -0
  257. package/lib/core/package.json +1 -1
  258. package/lib/core/src/budget.ts +17 -2
  259. package/lib/core/src/contracts.ts +71 -3
  260. package/lib/core/src/destination.ts +33 -0
  261. package/lib/core/src/event-stream.ts +5 -1
  262. package/lib/core/src/host.ts +3 -0
  263. package/lib/core/src/index.ts +2 -0
  264. package/lib/core/src/media.ts +228 -0
  265. package/lib/core/src/model-schema.ts +129 -0
  266. package/lib/exporter-otlp/dist/otlp-http-json.js +1 -1
  267. package/lib/exporter-otlp/dist/otlp-http-json.js.map +1 -1
  268. package/lib/exporter-otlp/dist/signals.js +2 -2
  269. package/lib/exporter-otlp/dist/signals.js.map +1 -1
  270. package/lib/exporter-otlp/package.json +1 -1
  271. package/lib/exporter-otlp/src/otlp-http-json.ts +1 -1
  272. package/lib/exporter-otlp/src/signals.ts +2 -2
  273. package/lib/guardrails/package.json +1 -1
  274. package/lib/helpers/package.json +1 -1
  275. package/lib/memory/dist/index.js +1 -1
  276. package/lib/memory/dist/index.js.map +1 -1
  277. package/lib/memory/dist/native.d.ts.map +1 -1
  278. package/lib/memory/dist/native.js +4 -3
  279. package/lib/memory/dist/native.js.map +1 -1
  280. package/lib/memory/package.json +1 -1
  281. package/lib/memory/src/index.ts +1 -1
  282. package/lib/memory/src/native.ts +4 -3
  283. package/lib/memory-remote/package.json +1 -1
  284. package/lib/observability/package.json +1 -1
  285. package/lib/provider-anthropic/dist/index.d.ts +36 -3
  286. package/lib/provider-anthropic/dist/index.d.ts.map +1 -1
  287. package/lib/provider-anthropic/dist/index.js +128 -78
  288. package/lib/provider-anthropic/dist/index.js.map +1 -1
  289. package/lib/provider-anthropic/package.json +1 -1
  290. package/lib/provider-anthropic/src/index.ts +152 -76
  291. package/lib/provider-openai/dist/index.d.ts +71 -4
  292. package/lib/provider-openai/dist/index.d.ts.map +1 -1
  293. package/lib/provider-openai/dist/index.js +259 -96
  294. package/lib/provider-openai/dist/index.js.map +1 -1
  295. package/lib/provider-openai/package.json +1 -1
  296. package/lib/provider-openai/src/index.ts +282 -84
  297. package/lib/runtime/dist/agent.d.ts +18 -1
  298. package/lib/runtime/dist/agent.d.ts.map +1 -1
  299. package/lib/runtime/dist/agent.js +59 -3
  300. package/lib/runtime/dist/agent.js.map +1 -1
  301. package/lib/runtime/dist/composition.d.ts.map +1 -1
  302. package/lib/runtime/dist/composition.js +2 -1
  303. package/lib/runtime/dist/composition.js.map +1 -1
  304. package/lib/runtime/dist/hooks.d.ts +15 -3
  305. package/lib/runtime/dist/hooks.d.ts.map +1 -1
  306. package/lib/runtime/dist/hooks.js.map +1 -1
  307. package/lib/runtime/dist/index.d.ts +1 -1
  308. package/lib/runtime/dist/index.d.ts.map +1 -1
  309. package/lib/runtime/dist/index.js.map +1 -1
  310. package/lib/runtime/dist/response.d.ts +7 -1
  311. package/lib/runtime/dist/response.d.ts.map +1 -1
  312. package/lib/runtime/dist/response.js +23 -2
  313. package/lib/runtime/dist/response.js.map +1 -1
  314. package/lib/runtime/dist/router.d.ts +10 -3
  315. package/lib/runtime/dist/router.d.ts.map +1 -1
  316. package/lib/runtime/dist/router.js +45 -8
  317. package/lib/runtime/dist/router.js.map +1 -1
  318. package/lib/runtime/dist/runtime.d.ts +9 -1
  319. package/lib/runtime/dist/runtime.d.ts.map +1 -1
  320. package/lib/runtime/dist/runtime.js +50 -22
  321. package/lib/runtime/dist/runtime.js.map +1 -1
  322. package/lib/runtime/package.json +1 -1
  323. package/lib/runtime/src/agent.ts +69 -3
  324. package/lib/runtime/src/composition.ts +2 -1
  325. package/lib/runtime/src/hooks.ts +10 -4
  326. package/lib/runtime/src/index.ts +1 -1
  327. package/lib/runtime/src/response.ts +20 -2
  328. package/lib/runtime/src/router.ts +43 -10
  329. package/lib/runtime/src/runtime.ts +58 -27
  330. package/lib/sdk/dist/index.d.ts +9 -1
  331. package/lib/sdk/dist/index.d.ts.map +1 -1
  332. package/lib/sdk/dist/index.js +9 -1
  333. package/lib/sdk/dist/index.js.map +1 -1
  334. package/lib/sdk/package.json +1 -1
  335. package/lib/sdk/src/index.ts +9 -1
  336. package/lib/server/dist/index.d.ts +201 -3
  337. package/lib/server/dist/index.d.ts.map +1 -1
  338. package/lib/server/dist/index.js +701 -149
  339. package/lib/server/dist/index.js.map +1 -1
  340. package/lib/server/dist/inspector-bundle.d.ts +1 -1
  341. package/lib/server/dist/inspector-bundle.d.ts.map +1 -1
  342. package/lib/server/dist/inspector-bundle.js +4 -4
  343. package/lib/server/dist/inspector-bundle.js.map +1 -1
  344. package/lib/server/package.json +1 -1
  345. package/lib/server/src/index.ts +611 -135
  346. package/lib/server/src/inspector-bundle.ts +4 -4
  347. package/lib/server-node/dist/hardening.d.ts +1 -1
  348. package/lib/server-node/dist/hardening.d.ts.map +1 -1
  349. package/lib/server-node/dist/hardening.js +4 -2
  350. package/lib/server-node/dist/hardening.js.map +1 -1
  351. package/lib/server-node/dist/index.d.ts +2 -1
  352. package/lib/server-node/dist/index.d.ts.map +1 -1
  353. package/lib/server-node/dist/index.js.map +1 -1
  354. package/lib/server-node/dist/probe.js +2 -2
  355. package/lib/server-node/dist/probe.js.map +1 -1
  356. package/lib/server-node/dist/production.d.ts +8 -1
  357. package/lib/server-node/dist/production.d.ts.map +1 -1
  358. package/lib/server-node/dist/production.js +15 -2
  359. package/lib/server-node/dist/production.js.map +1 -1
  360. package/lib/server-node/package.json +1 -1
  361. package/lib/server-node/src/hardening.ts +5 -3
  362. package/lib/server-node/src/index.ts +2 -1
  363. package/lib/server-node/src/probe.ts +2 -2
  364. package/lib/server-node/src/production.ts +23 -3
  365. package/lib/skills/dist/index.d.ts +81 -0
  366. package/lib/skills/dist/index.d.ts.map +1 -0
  367. package/lib/skills/dist/index.js +311 -0
  368. package/lib/skills/dist/index.js.map +1 -0
  369. package/lib/skills/package.json +5 -0
  370. package/lib/skills/src/index.ts +260 -0
  371. package/lib/storage/dist/index.d.ts +1 -1
  372. package/lib/storage/dist/index.d.ts.map +1 -1
  373. package/lib/storage/dist/index.js.map +1 -1
  374. package/lib/storage/package.json +1 -1
  375. package/lib/storage/src/index.ts +1 -1
  376. package/lib/storage-contracts/dist/contracts.d.ts +12 -5
  377. package/lib/storage-contracts/dist/contracts.d.ts.map +1 -1
  378. package/lib/storage-contracts/dist/contracts.js +24 -6
  379. package/lib/storage-contracts/dist/contracts.js.map +1 -1
  380. package/lib/storage-contracts/dist/index.d.ts +2 -0
  381. package/lib/storage-contracts/dist/index.d.ts.map +1 -1
  382. package/lib/storage-contracts/dist/index.js +2 -0
  383. package/lib/storage-contracts/dist/index.js.map +1 -1
  384. package/lib/storage-contracts/dist/memory-contracts.js +1 -1
  385. package/lib/storage-contracts/dist/memory-contracts.js.map +1 -1
  386. package/lib/storage-contracts/dist/run-records.d.ts +100 -0
  387. package/lib/storage-contracts/dist/run-records.d.ts.map +1 -0
  388. package/lib/storage-contracts/dist/run-records.js +464 -0
  389. package/lib/storage-contracts/dist/run-records.js.map +1 -0
  390. package/lib/storage-contracts/dist/schema-digest.d.ts +17 -0
  391. package/lib/storage-contracts/dist/schema-digest.d.ts.map +1 -0
  392. package/lib/storage-contracts/dist/schema-digest.js +94 -0
  393. package/lib/storage-contracts/dist/schema-digest.js.map +1 -0
  394. package/lib/storage-contracts/dist/submission-journal.js +1 -1
  395. package/lib/storage-contracts/dist/submission-journal.js.map +1 -1
  396. package/lib/storage-contracts/dist/workflow-format5.d.ts +30 -2
  397. package/lib/storage-contracts/dist/workflow-format5.d.ts.map +1 -1
  398. package/lib/storage-contracts/dist/workflow-format5.js +57 -5
  399. package/lib/storage-contracts/dist/workflow-format5.js.map +1 -1
  400. package/lib/storage-contracts/package.json +1 -1
  401. package/lib/storage-contracts/src/contracts.ts +29 -5
  402. package/lib/storage-contracts/src/index.ts +2 -0
  403. package/lib/storage-contracts/src/memory-contracts.ts +1 -1
  404. package/lib/storage-contracts/src/run-records.ts +365 -0
  405. package/lib/storage-contracts/src/schema-digest.ts +71 -0
  406. package/lib/storage-contracts/src/submission-journal.ts +1 -1
  407. package/lib/storage-contracts/src/workflow-format5.ts +70 -6
  408. package/lib/storage-postgres/dist/index.d.ts +1 -1
  409. package/lib/storage-postgres/dist/index.d.ts.map +1 -1
  410. package/lib/storage-postgres/dist/index.js.map +1 -1
  411. package/lib/storage-postgres/dist/postgres.d.ts +15 -0
  412. package/lib/storage-postgres/dist/postgres.d.ts.map +1 -1
  413. package/lib/storage-postgres/dist/postgres.js +18 -7
  414. package/lib/storage-postgres/dist/postgres.js.map +1 -1
  415. package/lib/storage-postgres/package.json +1 -1
  416. package/lib/storage-postgres/src/index.ts +1 -1
  417. package/lib/storage-postgres/src/postgres.ts +34 -8
  418. package/lib/storage-sql/dist/aggregate-session.js +1 -1
  419. package/lib/storage-sql/dist/aggregate-session.js.map +1 -1
  420. package/lib/storage-sql/dist/scheduled-database.js +1 -1
  421. package/lib/storage-sql/dist/scheduled-database.js.map +1 -1
  422. package/lib/storage-sql/dist/workflow-tree-validation.js +1 -1
  423. package/lib/storage-sql/dist/workflow-tree-validation.js.map +1 -1
  424. package/lib/storage-sql/package.json +1 -1
  425. package/lib/storage-sql/src/aggregate-session.ts +1 -1
  426. package/lib/storage-sql/src/scheduled-database.ts +1 -1
  427. package/lib/storage-sql/src/workflow-tree-validation.ts +1 -1
  428. package/lib/storage-sqlite/dist/sqlite-database.js +4 -4
  429. package/lib/storage-sqlite/dist/sqlite-database.js.map +1 -1
  430. package/lib/storage-sqlite/dist/sqlite-worker.js +2 -2
  431. package/lib/storage-sqlite/dist/sqlite-worker.js.map +1 -1
  432. package/lib/storage-sqlite/dist/sqlite.js +1 -1
  433. package/lib/storage-sqlite/dist/sqlite.js.map +1 -1
  434. package/lib/storage-sqlite/package.json +1 -1
  435. package/lib/storage-sqlite/src/sqlite-database.ts +4 -4
  436. package/lib/storage-sqlite/src/sqlite-worker.ts +2 -2
  437. package/lib/storage-sqlite/src/sqlite.ts +1 -1
  438. package/lib/terminal/dist/index.d.ts +92 -0
  439. package/lib/terminal/dist/index.d.ts.map +1 -0
  440. package/lib/terminal/dist/index.js +397 -0
  441. package/lib/terminal/dist/index.js.map +1 -0
  442. package/lib/terminal/package.json +5 -0
  443. package/lib/terminal/src/index.ts +273 -0
  444. package/lib/testing/dist/index.d.ts +44 -1
  445. package/lib/testing/dist/index.d.ts.map +1 -1
  446. package/lib/testing/dist/index.js +63 -10
  447. package/lib/testing/dist/index.js.map +1 -1
  448. package/lib/testing/package.json +1 -1
  449. package/lib/testing/src/index.ts +83 -10
  450. package/lib/tools/dist/index.d.ts +32 -4
  451. package/lib/tools/dist/index.d.ts.map +1 -1
  452. package/lib/tools/dist/index.js +64 -11
  453. package/lib/tools/dist/index.js.map +1 -1
  454. package/lib/tools/package.json +1 -1
  455. package/lib/tools/src/index.ts +74 -13
  456. package/lib/workflows/dist/abandoned.d.ts +15 -0
  457. package/lib/workflows/dist/abandoned.d.ts.map +1 -0
  458. package/lib/workflows/dist/abandoned.js +33 -0
  459. package/lib/workflows/dist/abandoned.js.map +1 -0
  460. package/lib/workflows/dist/agent-step.d.ts +83 -0
  461. package/lib/workflows/dist/agent-step.d.ts.map +1 -0
  462. package/lib/workflows/dist/agent-step.js +161 -0
  463. package/lib/workflows/dist/agent-step.js.map +1 -0
  464. package/lib/workflows/dist/children-runtime.js +8 -8
  465. package/lib/workflows/dist/children-runtime.js.map +1 -1
  466. package/lib/workflows/dist/composite-fleet.js +2 -2
  467. package/lib/workflows/dist/composite-fleet.js.map +1 -1
  468. package/lib/workflows/dist/composite-host.d.ts.map +1 -1
  469. package/lib/workflows/dist/composite-host.js +26 -2
  470. package/lib/workflows/dist/composite-host.js.map +1 -1
  471. package/lib/workflows/dist/hook-relay.js +2 -2
  472. package/lib/workflows/dist/hook-relay.js.map +1 -1
  473. package/lib/workflows/dist/index.d.ts +1 -1
  474. package/lib/workflows/dist/index.d.ts.map +1 -1
  475. package/lib/workflows/dist/index.js.map +1 -1
  476. package/lib/workflows/dist/leadership.js +3 -3
  477. package/lib/workflows/dist/leadership.js.map +1 -1
  478. package/lib/workflows/dist/lifecycle-definition.d.ts +26 -4
  479. package/lib/workflows/dist/lifecycle-definition.d.ts.map +1 -1
  480. package/lib/workflows/dist/lifecycle-definition.js +31 -6
  481. package/lib/workflows/dist/lifecycle-definition.js.map +1 -1
  482. package/lib/workflows/dist/lifecycle-fleet.d.ts.map +1 -1
  483. package/lib/workflows/dist/lifecycle-fleet.js +9 -11
  484. package/lib/workflows/dist/lifecycle-fleet.js.map +1 -1
  485. package/lib/workflows/dist/lifecycle-host.d.ts.map +1 -1
  486. package/lib/workflows/dist/lifecycle-host.js +26 -2
  487. package/lib/workflows/dist/lifecycle-host.js.map +1 -1
  488. package/lib/workflows/dist/lifecycle-human-transport.d.ts +22 -2
  489. package/lib/workflows/dist/lifecycle-human-transport.d.ts.map +1 -1
  490. package/lib/workflows/dist/lifecycle-human-transport.js +115 -33
  491. package/lib/workflows/dist/lifecycle-human-transport.js.map +1 -1
  492. package/lib/workflows/dist/lifecycle-runtime.d.ts +62 -1
  493. package/lib/workflows/dist/lifecycle-runtime.d.ts.map +1 -1
  494. package/lib/workflows/dist/lifecycle-runtime.js +268 -64
  495. package/lib/workflows/dist/lifecycle-runtime.js.map +1 -1
  496. package/lib/workflows/dist/lifecycle.d.ts +6 -4
  497. package/lib/workflows/dist/lifecycle.d.ts.map +1 -1
  498. package/lib/workflows/dist/lifecycle.js +2 -0
  499. package/lib/workflows/dist/lifecycle.js.map +1 -1
  500. package/lib/workflows/dist/loop-runtime.d.ts.map +1 -1
  501. package/lib/workflows/dist/loop-runtime.js +38 -26
  502. package/lib/workflows/dist/loop-runtime.js.map +1 -1
  503. package/lib/workflows/dist/migration.d.ts +1 -1
  504. package/lib/workflows/dist/migration.d.ts.map +1 -1
  505. package/lib/workflows/dist/migration.js +3 -3
  506. package/lib/workflows/dist/migration.js.map +1 -1
  507. package/lib/workflows/dist/operator-transports.d.ts +24 -2
  508. package/lib/workflows/dist/operator-transports.d.ts.map +1 -1
  509. package/lib/workflows/dist/operator-transports.js +49 -3
  510. package/lib/workflows/dist/operator-transports.js.map +1 -1
  511. package/lib/workflows/dist/runtime.d.ts.map +1 -1
  512. package/lib/workflows/dist/runtime.js +34 -22
  513. package/lib/workflows/dist/runtime.js.map +1 -1
  514. package/lib/workflows/dist/saga-runtime.d.ts.map +1 -1
  515. package/lib/workflows/dist/saga-runtime.js +44 -30
  516. package/lib/workflows/dist/saga-runtime.js.map +1 -1
  517. package/lib/workflows/dist/scheduled-helpers.d.ts.map +1 -1
  518. package/lib/workflows/dist/scheduled-helpers.js +3 -3
  519. package/lib/workflows/dist/scheduled-helpers.js.map +1 -1
  520. package/lib/workflows/dist/storage-failure.d.ts +16 -0
  521. package/lib/workflows/dist/storage-failure.d.ts.map +1 -0
  522. package/lib/workflows/dist/storage-failure.js +38 -0
  523. package/lib/workflows/dist/storage-failure.js.map +1 -0
  524. package/lib/workflows/dist/sweep-position.d.ts +22 -0
  525. package/lib/workflows/dist/sweep-position.d.ts.map +1 -0
  526. package/lib/workflows/dist/sweep-position.js +45 -0
  527. package/lib/workflows/dist/sweep-position.js.map +1 -0
  528. package/lib/workflows/dist/traces.js +2 -2
  529. package/lib/workflows/dist/traces.js.map +1 -1
  530. package/lib/workflows/dist/worker.d.ts +31 -0
  531. package/lib/workflows/dist/worker.d.ts.map +1 -1
  532. package/lib/workflows/dist/worker.js +94 -0
  533. package/lib/workflows/dist/worker.js.map +1 -1
  534. package/lib/workflows/package.json +1 -1
  535. package/lib/workflows/src/abandoned.ts +32 -0
  536. package/lib/workflows/src/agent-step.ts +199 -0
  537. package/lib/workflows/src/children-runtime.ts +8 -8
  538. package/lib/workflows/src/composite-fleet.ts +2 -2
  539. package/lib/workflows/src/composite-host.ts +21 -3
  540. package/lib/workflows/src/hook-relay.ts +2 -2
  541. package/lib/workflows/src/index.ts +2 -1
  542. package/lib/workflows/src/leadership.ts +3 -3
  543. package/lib/workflows/src/lifecycle-definition.ts +50 -9
  544. package/lib/workflows/src/lifecycle-fleet.ts +7 -8
  545. package/lib/workflows/src/lifecycle-host.ts +21 -5
  546. package/lib/workflows/src/lifecycle-human-transport.ts +110 -26
  547. package/lib/workflows/src/lifecycle-runtime.ts +270 -60
  548. package/lib/workflows/src/lifecycle.ts +7 -0
  549. package/lib/workflows/src/loop-runtime.ts +34 -25
  550. package/lib/workflows/src/migration.ts +2 -2
  551. package/lib/workflows/src/operator-transports.ts +48 -4
  552. package/lib/workflows/src/runtime.ts +28 -22
  553. package/lib/workflows/src/saga-runtime.ts +38 -28
  554. package/lib/workflows/src/scheduled-helpers.ts +3 -3
  555. package/lib/workflows/src/storage-failure.ts +37 -0
  556. package/lib/workflows/src/sweep-position.ts +52 -0
  557. package/lib/workflows/src/traces.ts +2 -2
  558. package/lib/workflows/src/worker.ts +79 -1
  559. package/lib/workstream/dist/humans.d.ts +7 -3
  560. package/lib/workstream/dist/humans.d.ts.map +1 -1
  561. package/lib/workstream/dist/humans.js +13 -2
  562. package/lib/workstream/dist/humans.js.map +1 -1
  563. package/lib/workstream/dist/index.js +2 -2
  564. package/lib/workstream/dist/index.js.map +1 -1
  565. package/lib/workstream/dist/timers.js +2 -2
  566. package/lib/workstream/dist/timers.js.map +1 -1
  567. package/lib/workstream/dist/webhooks.d.ts +6 -2
  568. package/lib/workstream/dist/webhooks.d.ts.map +1 -1
  569. package/lib/workstream/dist/webhooks.js +17 -7
  570. package/lib/workstream/dist/webhooks.js.map +1 -1
  571. package/lib/workstream/package.json +1 -1
  572. package/lib/workstream/src/humans.ts +15 -5
  573. package/lib/workstream/src/index.ts +2 -2
  574. package/lib/workstream/src/timers.ts +2 -2
  575. package/lib/workstream/src/webhooks.ts +21 -8
  576. package/llms-full.txt +9766 -0
  577. package/llms.txt +92 -0
  578. package/package.json +18 -6
@@ -8,8 +8,19 @@ function active(signal) {
8
8
  throw new MayuraError('CANCELLED', 'Human transport request was cancelled.');
9
9
  }
10
10
  /**
11
- * Bridges registered format-5 runs to the authenticated server transport shape.
12
- * Registration is intentionally explicit until durable lifecycle fleet discovery exists.
11
+ * A request's opaque route id. It starts with its run's two-hex index shard, so a durable transport finds a request
12
+ * by reading one shard, and pages in id order shard by shard.
13
+ */
14
+ function routeId(agentId, definitionHash, runId, nodeId) {
15
+ return runId.slice(0, 2) + digest('mayura:workflow-lifecycle-human-route:v2', { agentId, definitionHash, runId, nodeId }).slice(2);
16
+ }
17
+ /**
18
+ * Serves format-5 human requests to the agent server's `humanRequests` transport (list, inspect, respond).
19
+ *
20
+ * With `runtime` and `definitions` it is durable: requests are discovered from the lifecycle fleet index, so they are
21
+ * listed, read and answered after a restart without registering anything. Without them, each run is registered with
22
+ * `register` and forgotten on restart. Either way, a caller sees a request only in the transport's exact scope and
23
+ * only when its identity lists the request's agent, and an answer is recorded as the verified caller's.
13
24
  */
14
25
  export function createWorkflowLifecycleHumanTransport(options) {
15
26
  const scope = Object.freeze({ principalId: options.scope?.principalId, projectId: options.scope?.projectId });
@@ -21,7 +32,25 @@ export function createWorkflowLifecycleHumanTransport(options) {
21
32
  || !Number.isSafeInteger(maxExaminedPerPage) || maxExaminedPerPage < 1 || maxExaminedPerPage > 1_024) {
22
33
  throw new MayuraError('INVALID_CONFIG', 'Lifecycle human transport limits are invalid.');
23
34
  }
24
- const entries = new Map();
35
+ const durable = options.runtime !== undefined || options.definitions !== undefined;
36
+ const routes = new Map();
37
+ if (durable) {
38
+ const runtime = options.runtime;
39
+ if (!runtime || runtime.profile !== 'lifecycle-v1' || typeof runtime.scan !== 'function' || !Array.isArray(options.definitions)
40
+ || options.definitions.length < 1 || options.definitions.length > 128) {
41
+ throw new MayuraError('INVALID_CONFIG', 'A durable human transport needs the lifecycle fleet runtime and 1–128 definitions, each with its agentId.');
42
+ }
43
+ for (const route of options.definitions) {
44
+ assertWorkflowLifecycle(route?.definition);
45
+ if (typeof route.agentId !== 'string' || !identifier.test(route.agentId))
46
+ throw new MayuraError('INVALID_CONFIG', 'Each human transport definition needs a valid agentId.');
47
+ if (routes.has(route.definition.digest))
48
+ throw new MayuraError('INVALID_CONFIG', 'Human transport definitions must be unique.');
49
+ routes.set(route.definition.digest, Object.freeze({ agentId: route.agentId, definition: route.definition }));
50
+ }
51
+ }
52
+ const scopeKey = digest('mayura:scope:v1', scope);
53
+ const registered = new Map();
25
54
  const exactScope = (candidate) => {
26
55
  if (candidate?.principalId !== scope.principalId || candidate?.projectId !== scope.projectId) {
27
56
  throw new MayuraError('PERMISSION_DENIED', 'Lifecycle human transport scope does not match.');
@@ -32,7 +61,6 @@ export function createWorkflowLifecycleHumanTransport(options) {
32
61
  || new Set(agentIds).size !== agentIds.length)
33
62
  throw new MayuraError('INVALID_INPUT', 'Lifecycle human transport agent visibility is invalid.');
34
63
  };
35
- const visible = (entry, agentIds) => agentIds.includes(entry.agentId);
36
64
  const record = (entry, request) => freezeJson(jsonValue({ id: entry.id, agentId: entry.agentId, kind: request.kind, schemaId: request.schemaId,
37
65
  schemaDigest: request.schemaDigest, prompt: request.prompt, digest: request.digest,
38
66
  status: request.status === 'succeeded' ? 'answered' : request.status,
@@ -51,32 +79,86 @@ export function createWorkflowLifecycleHumanTransport(options) {
51
79
  throw error;
52
80
  }
53
81
  };
54
- const transport = Object.freeze({
55
- list: async (input) => {
56
- exactScope(input.scope);
57
- active(input.signal);
58
- checkedAgents(input.agentIds);
59
- if ((input.after !== null && !hashPattern.test(input.after)) || !Number.isSafeInteger(input.limit) || input.limit < 1 || input.limit > 100) {
60
- throw new MayuraError('INVALID_INPUT', 'Lifecycle human request page is invalid.');
82
+ /** The human requests of the active runs in one index shard, in route id order. */
83
+ const shardEntries = async (shard) => {
84
+ const runtime = options.runtime;
85
+ const candidates = [];
86
+ let afterId = '';
87
+ for (let reads = 0; reads < 8; reads++) {
88
+ let page;
89
+ try {
90
+ page = await runtime.scan({ cursor: { format: 1, scope: scopeKey, shard, afterId }, limit: 128, maxShardReads: 1 });
91
+ }
92
+ catch (error) {
93
+ // The fleet runtime refuses a cursor for another scope: the transport and runtime serve different scopes.
94
+ if (error instanceof MayuraError && error.code === 'INVALID_INPUT')
95
+ throw new MayuraError('INVALID_CONFIG', 'The human transport and its lifecycle runtime serve different scopes.');
96
+ throw error;
61
97
  }
62
- const ordered = [...entries.values()].filter(entry => visible(entry, input.agentIds) && (input.after === null || entry.id > input.after))
63
- .sort((left, right) => left.id.localeCompare(right.id));
64
- const items = [];
65
- let examined = 0;
66
- let cursor = null;
98
+ candidates.push(...page.candidates);
99
+ if (!page.nextCursor || page.nextCursor.shard !== shard)
100
+ break;
101
+ afterId = page.nextCursor.afterId;
102
+ }
103
+ return candidates.flatMap(candidate => {
104
+ const route = routes.get(candidate.definitionHash);
105
+ if (!route)
106
+ return [];
107
+ return route.definition.nodes.filter(node => node.kind === 'human').map(node => Object.freeze({
108
+ id: routeId(route.agentId, candidate.definitionHash, candidate.runId, node.id), agentId: route.agentId, definition: route.definition,
109
+ runtime, runId: candidate.runId, nodeId: node.id
110
+ }));
111
+ }).sort((left, right) => left.id.localeCompare(right.id));
112
+ };
113
+ const find = async (id) => durable
114
+ ? (await shardEntries(Number.parseInt(id.slice(0, 2), 16))).find(entry => entry.id === id)
115
+ : registered.get(id);
116
+ const page = async (agentIds, after, limit, signal) => {
117
+ const items = [];
118
+ let examined = 0;
119
+ let cursor = null;
120
+ const visible = (entry) => agentIds.includes(entry.agentId) && (after === null || entry.id > after);
121
+ if (!durable) {
122
+ const ordered = [...registered.values()].filter(visible).sort((left, right) => left.id.localeCompare(right.id));
67
123
  for (const entry of ordered) {
68
- if (items.length >= input.limit || examined >= maxExaminedPerPage)
124
+ if (items.length >= limit || examined >= maxExaminedPerPage)
69
125
  break;
70
- active(input.signal);
126
+ active(signal);
71
127
  examined += 1;
72
128
  cursor = entry.id;
73
129
  const item = await requestFor(entry);
74
130
  if (item)
75
131
  items.push(item);
76
132
  }
77
- const hasMore = cursor !== null && ordered.some(entry => entry.id > cursor);
133
+ return { items, next: cursor !== null && ordered.some(entry => entry.id > cursor) ? cursor : null };
134
+ }
135
+ // Route ids start with their shard, so walking shards in order walks ids in order.
136
+ for (let shard = after === null ? 0 : Number.parseInt(after.slice(0, 2), 16); shard < 256; shard++) {
137
+ active(signal);
138
+ for (const entry of (await shardEntries(shard)).filter(visible)) {
139
+ if (items.length >= limit || examined >= maxExaminedPerPage)
140
+ return { items, next: cursor };
141
+ active(signal);
142
+ examined += 1;
143
+ cursor = entry.id;
144
+ const item = await requestFor(entry);
145
+ if (item)
146
+ items.push(item);
147
+ }
148
+ }
149
+ return { items, next: null };
150
+ };
151
+ const transport = Object.freeze({
152
+ list: async (input) => {
153
+ exactScope(input.scope);
154
+ active(input.signal);
155
+ checkedAgents(input.agentIds);
156
+ if ((input.after !== null && !hashPattern.test(input.after)) || !Number.isSafeInteger(input.limit) || input.limit < 1 || input.limit > 100) {
157
+ throw new MayuraError('INVALID_INPUT', 'Lifecycle human request page is invalid.');
158
+ }
159
+ const result = await page(input.agentIds, input.after, input.limit, input.signal);
78
160
  active(input.signal);
79
- return freezeJson(jsonValue({ items, next: hasMore ? cursor : null }));
161
+ return freezeJson(jsonValue(result));
80
162
  },
81
163
  inspect: async (input) => {
82
164
  exactScope(input.scope);
@@ -84,8 +166,8 @@ export function createWorkflowLifecycleHumanTransport(options) {
84
166
  checkedAgents(input.agentIds);
85
167
  if (!hashPattern.test(input.id))
86
168
  throw new MayuraError('INVALID_INPUT', 'Lifecycle human request identity is invalid.');
87
- const entry = entries.get(input.id);
88
- if (!entry || !visible(entry, input.agentIds))
169
+ const entry = await find(input.id);
170
+ if (!entry || !input.agentIds.includes(entry.agentId))
89
171
  return null;
90
172
  const item = await requestFor(entry);
91
173
  active(input.signal);
@@ -99,8 +181,8 @@ export function createWorkflowLifecycleHumanTransport(options) {
99
181
  || !identifier.test(input.actorId)) {
100
182
  throw new MayuraError('INVALID_INPUT', 'Lifecycle human response identity is invalid.');
101
183
  }
102
- const entry = entries.get(input.id);
103
- if (!entry || !visible(entry, input.agentIds))
184
+ const entry = await find(input.id);
185
+ if (!entry || !input.agentIds.includes(entry.agentId))
104
186
  throw new MayuraError('NOT_FOUND', 'Lifecycle human request was not found.');
105
187
  await entry.runtime.respondVerified(entry.definition, { id: entry.runId, nodeId: entry.nodeId,
106
188
  requestDigest: input.requestDigest, commandId: input.commandId,
@@ -115,34 +197,34 @@ export function createWorkflowLifecycleHumanTransport(options) {
115
197
  return Object.freeze({
116
198
  transport,
117
199
  register: input => {
200
+ if (durable)
201
+ throw new MayuraError('INVALID_CONFIG', 'This human transport finds requests in storage; runs need no registration.');
118
202
  assertWorkflowLifecycle(input.definition);
119
203
  if (!identifier.test(input.agentId) || !hashPattern.test(input.runId) || input.runtime?.profile !== 'lifecycle-v1') {
120
204
  throw new MayuraError('INVALID_INPUT', 'Lifecycle human registration is invalid.');
121
205
  }
122
206
  const nodes = input.definition.nodes.filter(node => node.kind === 'human');
123
- const ids = nodes.map(node => digest('mayura:workflow-lifecycle-human-route:v1', {
124
- agentId: input.agentId, definitionHash: input.definition.digest, runId: input.runId, nodeId: node.id,
125
- }));
126
- const additions = ids.filter(id => !entries.has(id)).length;
127
- if (entries.size + additions > maxEntries)
207
+ const ids = nodes.map(node => routeId(input.agentId, input.definition.digest, input.runId, node.id));
208
+ const additions = ids.filter(id => !registered.has(id)).length;
209
+ if (registered.size + additions > maxEntries)
128
210
  throw new MayuraError('LIMIT_EXCEEDED', 'Lifecycle human transport registry is full.');
129
211
  for (const [index, node] of nodes.entries()) {
130
212
  const id = ids[index];
131
- const previous = entries.get(id);
213
+ const previous = registered.get(id);
132
214
  if (previous && (previous.agentId !== input.agentId || previous.definition !== input.definition
133
215
  || previous.runtime !== input.runtime || previous.runId !== input.runId || previous.nodeId !== node.id)) {
134
216
  throw new MayuraError('CONFLICT', 'Lifecycle human route ID collision.');
135
217
  }
136
- entries.set(id, Object.freeze({ ...input, id, nodeId: node.id }));
218
+ registered.set(id, Object.freeze({ ...input, id, nodeId: node.id }));
137
219
  }
138
220
  return Object.freeze(ids);
139
221
  },
140
222
  unregister: runId => {
141
223
  if (!hashPattern.test(runId))
142
224
  throw new MayuraError('INVALID_INPUT', 'Lifecycle run ID is invalid.');
143
- for (const [id, entry] of entries)
225
+ for (const [id, entry] of registered)
144
226
  if (entry.runId === runId)
145
- entries.delete(id);
227
+ registered.delete(id);
146
228
  },
147
229
  });
148
230
  }
@@ -1 +1 @@
1
- {"version":3,"file":"lifecycle-human-transport.js","sourceRoot":"","sources":["../src/lifecycle-human-transport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAA8B,MAAM,cAAc,CAAC;AAC9F,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,uBAAuB,EAA6B,MAAM,2BAA2B,CAAC;AAgD/F,MAAM,UAAU,GAAG,qCAAqC,CAAC;AACzD,MAAM,WAAW,GAAG,gBAAgB,CAAC;AAErC,SAAS,MAAM,CAAC,MAAmB;IACjC,IAAI,MAAM,CAAC,OAAO;QAAE,MAAM,IAAI,WAAW,CAAC,WAAW,EAAE,wCAAwC,CAAC,CAAC;AACnG,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,qCAAqC,CACnD,OAA+C;IAE/C,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,OAAO,CAAC,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,CAAC,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;IAC9G,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC;QAAE,MAAM,IAAI,WAAW,CAAC,gBAAgB,EAAE,6CAA6C,CAAC,CAAC;IACrK,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,IAAI,GAAG,CAAC;IAAC,MAAM,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,IAAI,GAAG,CAAC;IAC3G,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,UAAU,CAAC,IAAI,UAAU,GAAG,CAAC,IAAI,UAAU,GAAG,KAAK;WACxE,CAAC,MAAM,CAAC,aAAa,CAAC,kBAAkB,CAAC,IAAI,kBAAkB,GAAG,CAA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AAO,EAAE,EAAE,CAAC;gBAC5C,MAAM,EAAE,GAAG,GAAG,CAAC,KAAK,CAAE,CAAC;gBAAC,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;gBACzD,IAAI,QAAQ,IAAI,CAAC,QAAQ,CAAC,OAAO,KAAK,KAAK,CAAC,OAAO,IAAI,QAAQ,CAAC,UAAU,KAAK,KAAK,CAAC,UAAU;uBAC1F,QAAQ,CAAC,OAAO,KAAK,KAAK,CAAC,OAAO,IAAI,QAAQ,CAAC,KAAK,KAAK,KAAK,CAAC,KAAK,IAAI,QAAQ,CAAC,MAAM,KAAK,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;oBAC1G,MAAM,IAAI,WAAW,CAAC,UAAU,EAAE,qCAAqC,CAAC,CAAC;gBAC3E,CAAC;gBACD,OAAO,CAAC,GAAG,CAAC,EAAE,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;YACpE,CAAC;YACD,OAAO,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAC5B,CAAC;QACD,UAAU,EAAE,KAAK,CAAC,EAAE;YAClB,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC;gBAAE,MAAM,IAAI,WAAW,CAAC,eAAe,EAAE,8BAA8B,CAAC,CAAC;YACrG,KAAK,MAAM,CAAC,EAAE,EAAE,KAAK,CAAC,IAAI,OAAO;gBAAE,IAAI,KAAK,CAAC,KAAK,KAAK,KAAK;oBAAE,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QACnF,CAAC;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { freezeJson, jsonValue, MayuraError, type JsonValue, type Scope } from '@mayura/core';\nimport { digest } from './definition.js';\nimport { assertWorkflowLifecycle, type AnyWorkflowLifecycle } from './lifecycle-definition.js';\nimport type { WorkflowLifecycleHumanRequest, WorkflowLifecycleRuntime } from './lifecycle-runtime.js';\n\nexport interface WorkflowLifecycleHumanTransportRecord {\n readonly id: string;\n readonly agentId: string;\n readonly kind: 'information' | 'correction' | 'plan_selection';\n readonly schemaId: string;\n readonly schemaDigest: string;\n readonly prompt: string;\n readonly digest: string;\n readonly status: 'waiting' | 'answered' | 'timed_out';\n readonly context?: JsonValue;\n readonly subjectDigest?: string;\n readonly deadlineAtMs?: number;\n}\n\nexport interface WorkflowLifecycleHumanTransport {\n readonly list: (input: { readonly scope: Scope; readonly agentIds: readonly string[]; readonly after: string | null;\n readonly limit: number; readonly signal: AbortSignal }) => Promise<{ readonly items: readonly WorkflowLifecycleHumanTransportRecord[]; readonly next: string | null }>;\n readonly inspect: (input: { readonly scope: Scope; readonly agentIds: readonly string[]; readonly id: string;\n readonly signal: AbortSignal }) => Promise<WorkflowLifecycleHumanTransportRecord | null>;\n readonly respond: (input: { readonly scope: Scope; readonly agentIds: readonly string[]; readonly actorId: string;\n readonly id: string; readonly requestDigest: string; readonly commandId: string; readonly value: JsonValue;\n readonly signal: AbortSignal }) => Promise<WorkflowLifecycleHumanTransportRecord>;\n}\n\nexport interface WorkflowLifecycleHumanRegistration {\n readonly agentId: string;\n readonly definition: AnyWorkflowLifecycle;\n readonly runtime: WorkflowLifecycleRuntime;\n readonly runId: string;\n}\n\nexport interface WorkflowLifecycleHumanTransportController {\n /** Exact three-callback object accepted by @mayura/server. */\n readonly transport: WorkflowLifecycleHumanTransport;\n register(input: WorkflowLifecycleHumanRegistration): readonly string[];\n unregister(runId: string): void;\n}\n\nexport interface WorkflowLifecycleHumanTransportOptions {\n readonly scope: Scope;\n readonly maxEntries?: number;\n readonly maxExaminedPerPage?: number;\n}\n\ninterface Entry extends WorkflowLifecycleHumanRegistration { readonly id: string; readonly nodeId: string }\nconst identifier = /^[A-Za-z0-9][A-Za-z0-9._/-]{0,127}$/;\nconst hashPattern = /^[a-f0-9]{64}$/;\n\nfunction active(signal: AbortSignal): void {\n if (signal.aborted) throw new MayuraError('CANCELLED', 'Human transport request was cancelled.');\n}\n\n/**\n * Bridges registered format-5 runs to the authenticated server transport shape.\n * Registration is intentionally explicit until durable lifecycle fleet discovery exists.\n */\nexport function createWorkflowLifecycleHumanTransport(\n options: WorkflowLifecycleHumanTransportOptions,\n): WorkflowLifecycleHumanTransportController {\n const scope = Object.freeze({ principalId: options.scope?.principalId, projectId: options.scope?.projectId });\n if (!identifier.test(scope.principalId) || !identifier.test(scope.projectId)) throw new MayuraError('INVALID_CONFIG', 'Lifecycle human transport scope is invalid.');\n const maxEntries = options.maxEntries ?? 512; const maxExaminedPerPage = options.maxExaminedPerPage ?? 256;\n if (!Number.isSafeInteger(maxEntries) || maxEntries < 1 || maxEntries > 8_192\n || !Number.isSafeInteger(maxExaminedPerPage) || maxExaminedPerPage < 1 || maxExaminedPerPage > 1_024) {\n throw new MayuraError('INVALID_CONFIG', 'Lifecycle human transport limits are invalid.');\n }\n const entries = new Map<string, Entry>();\n const exactScope = (candidate: Scope): void => {\n if (candidate?.principalId !== scope.principalId || candidate?.projectId !== scope.projectId) {\n throw new MayuraError('PERMISSION_DENIED', 'Lifecycle human transport scope does not match.');\n }\n };\n const checkedAgents = (agentIds: readonly string[]): void => {\n if (!Array.isArray(agentIds) || agentIds.length > 256 || agentIds.some(id => !identifier.test(id))\n || new Set(agentIds).size !== agentIds.length) throw new MayuraError('INVALID_INPUT', 'Lifecycle human transport agent visibility is invalid.');\n };\n const visible = (entry: Entry, agentIds: readonly string[]): boolean => agentIds.includes(entry.agentId);\n const record = (entry: Entry, request: WorkflowLifecycleHumanRequest): WorkflowLifecycleHumanTransportRecord =>\n freezeJson(jsonValue({ id: entry.id, agentId: entry.agentId, kind: request.kind, schemaId: request.schemaId,\n schemaDigest: request.schemaDigest, prompt: request.prompt, digest: request.digest,\n status: request.status === 'succeeded' ? 'answered' : request.status,\n ...(request.context === null ? {} : { context: request.context }),\n ...(request.subjectDigest === null ? {} : { subjectDigest: request.subjectDigest }),\n ...(request.deadlineAtMs === null ? {} : { deadlineAtMs: request.deadlineAtMs }),\n })) as unknown as WorkflowLifecycleHumanTransportRecord;\n const requestFor = async (entry: Entry): Promise<WorkflowLifecycleHumanTransportRecord | null> => {\n try {\n const request = await entry.runtime.humanRequest(entry.definition, entry.runId, entry.nodeId);\n return request ? record(entry, request) : null;\n } catch (error) {\n if (error instanceof MayuraError && error.code === 'NOT_FOUND') return null;\n throw error;\n }\n };\n const transport = Object.freeze<WorkflowLifecycleHumanTransport>({\n list: async input => {\n exactScope(input.scope); active(input.signal);\n checkedAgents(input.agentIds);\n if ((input.after !== null && !hashPattern.test(input.after)) || !Number.isSafeInteger(input.limit) || input.limit < 1 || input.limit > 100) {\n throw new MayuraError('INVALID_INPUT', 'Lifecycle human request page is invalid.');\n }\n const ordered = [...entries.values()].filter(entry => visible(entry, input.agentIds) && (input.after === null || entry.id > input.after))\n .sort((left, right) => left.id.localeCompare(right.id));\n const items: WorkflowLifecycleHumanTransportRecord[] = []; let examined = 0; let cursor: string | null = null;\n for (const entry of ordered) {\n if (items.length >= input.limit || examined >= maxExaminedPerPage) break;\n active(input.signal); examined += 1; cursor = entry.id;\n const item = await requestFor(entry); if (item) items.push(item);\n }\n const hasMore = cursor !== null && ordered.some(entry => entry.id > cursor!);\n active(input.signal); return freezeJson(jsonValue({ items, next: hasMore ? cursor : null })) as unknown as { readonly items: readonly WorkflowLifecycleHumanTransportRecord[]; readonly next: string | null };\n },\n inspect: async input => {\n exactScope(input.scope); active(input.signal);\n checkedAgents(input.agentIds);\n if (!hashPattern.test(input.id)) throw new MayuraError('INVALID_INPUT', 'Lifecycle human request identity is invalid.');\n const entry = entries.get(input.id); if (!entry || !visible(entry, input.agentIds)) return null;\n const item = await requestFor(entry); active(input.signal); return item;\n },\n respond: async input => {\n exactScope(input.scope); active(input.signal);\n checkedAgents(input.agentIds);\n if (!hashPattern.test(input.id) || !hashPattern.test(input.requestDigest) || !identifier.test(input.commandId)\n || !identifier.test(input.actorId)) {\n throw new MayuraError('INVALID_INPUT', 'Lifecycle human response identity is invalid.');\n }\n const entry = entries.get(input.id);\n if (!entry || !visible(entry, input.agentIds)) throw new MayuraError('NOT_FOUND', 'Lifecycle human request was not found.');\n await entry.runtime.respondVerified(entry.definition, { id: entry.runId, nodeId: entry.nodeId,\n requestDigest: input.requestDigest, commandId: input.commandId,\n actor: { id: input.actorId, projectId: scope.projectId }, value: input.value });\n active(input.signal); const updated = await requestFor(entry);\n if (!updated) throw new MayuraError('CONFLICT', 'Lifecycle human request disappeared after response.');\n return updated;\n },\n });\n return Object.freeze<WorkflowLifecycleHumanTransportController>({\n transport,\n register: input => {\n assertWorkflowLifecycle(input.definition);\n if (!identifier.test(input.agentId) || !hashPattern.test(input.runId) || input.runtime?.profile !== 'lifecycle-v1') {\n throw new MayuraError('INVALID_INPUT', 'Lifecycle human registration is invalid.');\n }\n const nodes = input.definition.nodes.filter(node => node.kind === 'human');\n const ids = nodes.map(node => digest('mayura:workflow-lifecycle-human-route:v1', {\n agentId: input.agentId, definitionHash: input.definition.digest, runId: input.runId, nodeId: node.id,\n }));\n const additions = ids.filter(id => !entries.has(id)).length;\n if (entries.size + additions > maxEntries) throw new MayuraError('LIMIT_EXCEEDED', 'Lifecycle human transport registry is full.');\n for (const [index, node] of nodes.entries()) {\n const id = ids[index]!; const previous = entries.get(id);\n if (previous && (previous.agentId !== input.agentId || previous.definition !== input.definition\n || previous.runtime !== input.runtime || previous.runId !== input.runId || previous.nodeId !== node.id)) {\n throw new MayuraError('CONFLICT', 'Lifecycle human route ID collision.');\n }\n entries.set(id, Object.freeze({ ...input, id, nodeId: node.id }));\n }\n return Object.freeze(ids);\n },\n unregister: runId => {\n if (!hashPattern.test(runId)) throw new MayuraError('INVALID_INPUT', 'Lifecycle run ID is invalid.');\n for (const [id, entry] of entries) if (entry.runId === runId) entries.delete(id);\n },\n });\n}\n"]}
1
+ {"version":3,"file":"lifecycle-human-transport.js","source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AK,KAAK,CAAC,OAAO,IAAI,QAAQ,CAAC,UAAU,KAAK,KAAK,CAAC,UAAU;uBAC1F,QAAQ,CAAC,OAAO,KAAK,KAAK,CAAC,OAAO,IAAI,QAAQ,CAAC,KAAK,KAAK,KAAK,CAAC,KAAK,IAAI,QAAQ,CAAC,MAAM,KAAK,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;oBAC1G,MAAM,IAAI,WAAW,CAAC,UAAU,EAAE,qCAAqC,CAAC,CAAC;gBAC3E,CAAC;gBACD,UAAU,CAAC,GAAG,CAAC,EAAE,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;YACvE,CAAC;YACD,OAAO,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAC5B,CAAC;QACD,UAAU,EAAE,KAAK,CAAC,EAAE;YAClB,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC;gBAAE,MAAM,IAAI,WAAW,CAAC,eAAe,EAAE,8BAA8B,CAAC,CAAC;YACrG,KAAK,MAAM,CAAC,EAAE,EAAE,KAAK,CAAC,IAAI,UAAU;gBAAE,IAAI,KAAK,CAAC,KAAK,KAAK,KAAK;oBAAE,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QACzF,CAAC;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { freezeJson, jsonValue, MayuraError, type JsonValue, type Scope } from '@mayura/core';\nimport { digest } from './definition.js';\nimport { assertWorkflowLifecycle, type AnyWorkflowLifecycle } from './lifecycle-definition.js';\nimport type { WorkflowLifecycleFleetCandidate, WorkflowLifecycleFleetRuntime } from './lifecycle-fleet.js';\nimport type { WorkflowLifecycleHumanRequest, WorkflowLifecycleRuntime } from './lifecycle-runtime.js';\n\nexport interface WorkflowLifecycleHumanTransportRecord {\n readonly id: string;\n readonly agentId: string;\n readonly kind: 'information' | 'correction' | 'plan_selection';\n readonly schemaId: string;\n readonly schemaDigest: string;\n readonly prompt: string;\n readonly digest: string;\n readonly status: 'waiting' | 'answered' | 'timed_out';\n readonly context?: JsonValue;\n readonly subjectDigest?: string;\n readonly deadlineAtMs?: number;\n}\n\nexport interface WorkflowLifecycleHumanTransport {\n readonly list: (input: { readonly scope: Scope; readonly agentIds: readonly string[]; readonly after: string | null;\n readonly limit: number; readonly signal: AbortSignal }) => Promise<{ readonly items: readonly WorkflowLifecycleHumanTransportRecord[]; readonly next: string | null }>;\n readonly inspect: (input: { readonly scope: Scope; readonly agentIds: readonly string[]; readonly id: string;\n readonly signal: AbortSignal }) => Promise<WorkflowLifecycleHumanTransportRecord | null>;\n readonly respond: (input: { readonly scope: Scope; readonly agentIds: readonly string[]; readonly actorId: string;\n readonly id: string; readonly requestDigest: string; readonly commandId: string; readonly value: JsonValue;\n readonly signal: AbortSignal }) => Promise<WorkflowLifecycleHumanTransportRecord>;\n}\n\nexport interface WorkflowLifecycleHumanRegistration {\n readonly agentId: string;\n readonly definition: AnyWorkflowLifecycle;\n readonly runtime: WorkflowLifecycleRuntime;\n readonly runId: string;\n}\n\n/** A definition whose human requests a durable transport serves, and the agent whose callers may see and answer them. */\nexport interface WorkflowLifecycleHumanRoute {\n readonly agentId: string;\n readonly definition: AnyWorkflowLifecycle;\n}\n\nexport interface WorkflowLifecycleHumanTransportController {\n /** Exact three-callback object accepted by @mayura/server. */\n readonly transport: WorkflowLifecycleHumanTransport;\n /** Registration mode only: serve one run's human requests. A durable transport finds them itself and refuses this. */\n register(input: WorkflowLifecycleHumanRegistration): readonly string[];\n unregister(runId: string): void;\n}\n\nexport interface WorkflowLifecycleHumanTransportOptions {\n readonly scope: Scope;\n /**\n * Durable discovery: the fleet runtime (or host runtime) whose index lists the active runs of `scope`. Pending\n * requests are then found in storage: nothing is registered, and a restart loses nothing. Requires `definitions`.\n */\n readonly runtime?: WorkflowLifecycleFleetRuntime;\n /** With `runtime`: every definition version whose requests this transport serves (at most 128), each with its agent. */\n readonly definitions?: readonly WorkflowLifecycleHumanRoute[];\n /** Registration mode: the most registered requests (default 512). */\n readonly maxEntries?: number;\n /** The most requests one page reads (default 256). */\n readonly maxExaminedPerPage?: number;\n}\n\ninterface Entry { readonly id: string; readonly agentId: string; readonly definition: AnyWorkflowLifecycle; readonly runtime: WorkflowLifecycleRuntime;\n readonly runId: string; readonly nodeId: string }\nconst identifier = /^[A-Za-z0-9][A-Za-z0-9._/-]{0,127}$/;\nconst hashPattern = /^[a-f0-9]{64}$/;\n\nfunction active(signal: AbortSignal): void {\n if (signal.aborted) throw new MayuraError('CANCELLED', 'Human transport request was cancelled.');\n}\n\n/**\n * A request's opaque route id. It starts with its run's two-hex index shard, so a durable transport finds a request\n * by reading one shard, and pages in id order shard by shard.\n */\nfunction routeId(agentId: string, definitionHash: string, runId: string, nodeId: string): string {\n return runId.slice(0, 2) + digest('mayura:workflow-lifecycle-human-route:v2', { agentId, definitionHash, runId, nodeId }).slice(2);\n}\n\n/**\n * Serves format-5 human requests to the agent server's `humanRequests` transport (list, inspect, respond).\n *\n * With `runtime` and `definitions` it is durable: requests are discovered from the lifecycle fleet index, so they are\n * listed, read and answered after a restart without registering anything. Without them, each run is registered with\n * `register` and forgotten on restart. Either way, a caller sees a request only in the transport's exact scope and\n * only when its identity lists the request's agent, and an answer is recorded as the verified caller's.\n */\nexport function createWorkflowLifecycleHumanTransport(\n options: WorkflowLifecycleHumanTransportOptions,\n): WorkflowLifecycleHumanTransportController {\n const scope = Object.freeze({ principalId: options.scope?.principalId, projectId: options.scope?.projectId });\n if (!identifier.test(scope.principalId) || !identifier.test(scope.projectId)) throw new MayuraError('INVALID_CONFIG', 'Lifecycle human transport scope is invalid.');\n const maxEntries = options.maxEntries ?? 512; const maxExaminedPerPage = options.maxExaminedPerPage ?? 256;\n if (!Number.isSafeInteger(maxEntries) || maxEntries < 1 || maxEntries > 8_192\n || !Number.isSafeInteger(maxExaminedPerPage) || maxExaminedPerPage < 1 || maxExaminedPerPage > 1_024) {\n throw new MayuraError('INVALID_CONFIG', 'Lifecycle human transport limits are invalid.');\n }\n const durable = options.runtime !== undefined || options.definitions !== undefined;\n const routes = new Map<string, WorkflowLifecycleHumanRoute>();\n if (durable) {\n const runtime = options.runtime;\n if (!runtime || runtime.profile !== 'lifecycle-v1' || typeof runtime.scan !== 'function' || !Array.isArray(options.definitions)\n || options.definitions.length < 1 || options.definitions.length > 128) {\n throw new MayuraError('INVALID_CONFIG', 'A durable human transport needs the lifecycle fleet runtime and 1–128 definitions, each with its agentId.');\n }\n for (const route of options.definitions) {\n assertWorkflowLifecycle(route?.definition);\n if (typeof route.agentId !== 'string' || !identifier.test(route.agentId)) throw new MayuraError('INVALID_CONFIG', 'Each human transport definition needs a valid agentId.');\n if (routes.has(route.definition.digest)) throw new MayuraError('INVALID_CONFIG', 'Human transport definitions must be unique.');\n routes.set(route.definition.digest, Object.freeze({ agentId: route.agentId, definition: route.definition }));\n }\n }\n const scopeKey = digest('mayura:scope:v1', scope);\n const registered = new Map<string, Entry>();\n const exactScope = (candidate: Scope): void => {\n if (candidate?.principalId !== scope.principalId || candidate?.projectId !== scope.projectId) {\n throw new MayuraError('PERMISSION_DENIED', 'Lifecycle human transport scope does not match.');\n }\n };\n const checkedAgents = (agentIds: readonly string[]): void => {\n if (!Array.isArray(agentIds) || agentIds.length > 256 || agentIds.some(id => !identifier.test(id))\n || new Set(agentIds).size !== agentIds.length) throw new MayuraError('INVALID_INPUT', 'Lifecycle human transport agent visibility is invalid.');\n };\n const record = (entry: Entry, request: WorkflowLifecycleHumanRequest): WorkflowLifecycleHumanTransportRecord =>\n freezeJson(jsonValue({ id: entry.id, agentId: entry.agentId, kind: request.kind, schemaId: request.schemaId,\n schemaDigest: request.schemaDigest, prompt: request.prompt, digest: request.digest,\n status: request.status === 'succeeded' ? 'answered' : request.status,\n ...(request.context === null ? {} : { context: request.context }),\n ...(request.subjectDigest === null ? {} : { subjectDigest: request.subjectDigest }),\n ...(request.deadlineAtMs === null ? {} : { deadlineAtMs: request.deadlineAtMs }),\n })) as unknown as WorkflowLifecycleHumanTransportRecord;\n const requestFor = async (entry: Entry): Promise<WorkflowLifecycleHumanTransportRecord | null> => {\n try {\n const request = await entry.runtime.humanRequest(entry.definition, entry.runId, entry.nodeId);\n return request ? record(entry, request) : null;\n } catch (error) {\n if (error instanceof MayuraError && error.code === 'NOT_FOUND') return null;\n throw error;\n }\n };\n /** The human requests of the active runs in one index shard, in route id order. */\n const shardEntries = async (shard: number): Promise<Entry[]> => {\n const runtime = options.runtime!; const candidates: WorkflowLifecycleFleetCandidate[] = []; let afterId = '';\n for (let reads = 0; reads < 8; reads++) {\n let page;\n try { page = await runtime.scan({ cursor: { format: 1, scope: scopeKey, shard, afterId }, limit: 128, maxShardReads: 1 }); }\n catch (error) {\n // The fleet runtime refuses a cursor for another scope: the transport and runtime serve different scopes.\n if (error instanceof MayuraError && error.code === 'INVALID_INPUT') throw new MayuraError('INVALID_CONFIG', 'The human transport and its lifecycle runtime serve different scopes.');\n throw error;\n }\n candidates.push(...page.candidates);\n if (!page.nextCursor || page.nextCursor.shard !== shard) break;\n afterId = page.nextCursor.afterId;\n }\n return candidates.flatMap(candidate => {\n const route = routes.get(candidate.definitionHash); if (!route) return [];\n return route.definition.nodes.filter(node => node.kind === 'human').map(node => Object.freeze({\n id: routeId(route.agentId, candidate.definitionHash, candidate.runId, node.id), agentId: route.agentId, definition: route.definition,\n runtime, runId: candidate.runId, nodeId: node.id }));\n }).sort((left, right) => left.id.localeCompare(right.id));\n };\n const find = async (id: string): Promise<Entry | undefined> => durable\n ? (await shardEntries(Number.parseInt(id.slice(0, 2), 16))).find(entry => entry.id === id)\n : registered.get(id);\n const page = async (agentIds: readonly string[], after: string | null, limit: number, signal: AbortSignal): Promise<{ items: WorkflowLifecycleHumanTransportRecord[]; next: string | null }> => {\n const items: WorkflowLifecycleHumanTransportRecord[] = []; let examined = 0; let cursor: string | null = null;\n const visible = (entry: Entry): boolean => agentIds.includes(entry.agentId) && (after === null || entry.id > after);\n if (!durable) {\n const ordered = [...registered.values()].filter(visible).sort((left, right) => left.id.localeCompare(right.id));\n for (const entry of ordered) {\n if (items.length >= limit || examined >= maxExaminedPerPage) break;\n active(signal); examined += 1; cursor = entry.id;\n const item = await requestFor(entry); if (item) items.push(item);\n }\n return { items, next: cursor !== null && ordered.some(entry => entry.id > cursor!) ? cursor : null };\n }\n // Route ids start with their shard, so walking shards in order walks ids in order.\n for (let shard = after === null ? 0 : Number.parseInt(after.slice(0, 2), 16); shard < 256; shard++) {\n active(signal);\n for (const entry of (await shardEntries(shard)).filter(visible)) {\n if (items.length >= limit || examined >= maxExaminedPerPage) return { items, next: cursor };\n active(signal); examined += 1; cursor = entry.id;\n const item = await requestFor(entry); if (item) items.push(item);\n }\n }\n return { items, next: null };\n };\n const transport = Object.freeze<WorkflowLifecycleHumanTransport>({\n list: async input => {\n exactScope(input.scope); active(input.signal);\n checkedAgents(input.agentIds);\n if ((input.after !== null && !hashPattern.test(input.after)) || !Number.isSafeInteger(input.limit) || input.limit < 1 || input.limit > 100) {\n throw new MayuraError('INVALID_INPUT', 'Lifecycle human request page is invalid.');\n }\n const result = await page(input.agentIds, input.after, input.limit, input.signal);\n active(input.signal); return freezeJson(jsonValue(result)) as unknown as { readonly items: readonly WorkflowLifecycleHumanTransportRecord[]; readonly next: string | null };\n },\n inspect: async input => {\n exactScope(input.scope); active(input.signal);\n checkedAgents(input.agentIds);\n if (!hashPattern.test(input.id)) throw new MayuraError('INVALID_INPUT', 'Lifecycle human request identity is invalid.');\n const entry = await find(input.id); if (!entry || !input.agentIds.includes(entry.agentId)) return null;\n const item = await requestFor(entry); active(input.signal); return item;\n },\n respond: async input => {\n exactScope(input.scope); active(input.signal);\n checkedAgents(input.agentIds);\n if (!hashPattern.test(input.id) || !hashPattern.test(input.requestDigest) || !identifier.test(input.commandId)\n || !identifier.test(input.actorId)) {\n throw new MayuraError('INVALID_INPUT', 'Lifecycle human response identity is invalid.');\n }\n const entry = await find(input.id);\n if (!entry || !input.agentIds.includes(entry.agentId)) throw new MayuraError('NOT_FOUND', 'Lifecycle human request was not found.');\n await entry.runtime.respondVerified(entry.definition, { id: entry.runId, nodeId: entry.nodeId,\n requestDigest: input.requestDigest, commandId: input.commandId,\n actor: { id: input.actorId, projectId: scope.projectId }, value: input.value });\n active(input.signal); const updated = await requestFor(entry);\n if (!updated) throw new MayuraError('CONFLICT', 'Lifecycle human request disappeared after response.');\n return updated;\n },\n });\n return Object.freeze<WorkflowLifecycleHumanTransportController>({\n transport,\n register: input => {\n if (durable) throw new MayuraError('INVALID_CONFIG', 'This human transport finds requests in storage; runs need no registration.');\n assertWorkflowLifecycle(input.definition);\n if (!identifier.test(input.agentId) || !hashPattern.test(input.runId) || input.runtime?.profile !== 'lifecycle-v1') {\n throw new MayuraError('INVALID_INPUT', 'Lifecycle human registration is invalid.');\n }\n const nodes = input.definition.nodes.filter(node => node.kind === 'human');\n const ids = nodes.map(node => routeId(input.agentId, input.definition.digest, input.runId, node.id));\n const additions = ids.filter(id => !registered.has(id)).length;\n if (registered.size + additions > maxEntries) throw new MayuraError('LIMIT_EXCEEDED', 'Lifecycle human transport registry is full.');\n for (const [index, node] of nodes.entries()) {\n const id = ids[index]!; const previous = registered.get(id);\n if (previous && (previous.agentId !== input.agentId || previous.definition !== input.definition\n || previous.runtime !== input.runtime || previous.runId !== input.runId || previous.nodeId !== node.id)) {\n throw new MayuraError('CONFLICT', 'Lifecycle human route ID collision.');\n }\n registered.set(id, Object.freeze({ ...input, id, nodeId: node.id }));\n }\n return Object.freeze(ids);\n },\n unregister: runId => {\n if (!hashPattern.test(runId)) throw new MayuraError('INVALID_INPUT', 'Lifecycle run ID is invalid.');\n for (const [id, entry] of registered) if (entry.runId === runId) registered.delete(id);\n },\n });\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { type JsonValue, type Permissions, type Scope } from '../../core/dist/index.js';
1
+ import { MayuraError, type JsonValue, type Permissions, type Scope } from '../../core/dist/index.js';
2
2
  import { type WorkflowDrainOptions, type WorkflowDrainReport } from './drain.js';
3
3
  import { type AggregateStore, type WorkflowLifecycleStatus, type WorkflowLifecycleStep } from '../../storage-contracts/dist/index.js';
4
4
  import { type AnyWorkflowLifecycle } from './lifecycle-definition.js';
@@ -31,6 +31,21 @@ export interface WorkflowLifecycleHumanRequest {
31
31
  readonly subjectDigest: string | null;
32
32
  readonly deadlineAtMs: number | null;
33
33
  }
34
+ /**
35
+ * A signal for a waiting (or not yet started) `signal` step. `signalId` makes delivery idempotent: the same id with the
36
+ * same payload is accepted once and every repeat returns the run unchanged; the same id with another payload, or a
37
+ * second signal for a step that already has one, is refused with CONFLICT.
38
+ */
39
+ export interface WorkflowLifecycleSignalCommand {
40
+ readonly id: string;
41
+ /** The signal node's `name` (its id unless it names one). */
42
+ readonly name: string;
43
+ /** 1–128 letters, digits, `.`, `_`, `/` or `-`, starting with a letter or digit. */
44
+ readonly signalId: string;
45
+ readonly payload: unknown;
46
+ /** Who sent it, recorded in the run's event log. */
47
+ readonly actorId?: string;
48
+ }
34
49
  /** What an operator approves: the exact tool call the approval digest binds, reconstructed and digest-verified. */
35
50
  export interface WorkflowLifecycleApprovalRequest {
36
51
  readonly runId: string;
@@ -43,6 +58,17 @@ export interface WorkflowLifecycleApprovalRequest {
43
58
  readonly digest: string;
44
59
  readonly expiresAtMs: number;
45
60
  }
61
+ /**
62
+ * Runtime settings a run may have been started with (same scope as the runtime). Defaults match the runtime's own.
63
+ * A run started under a listed policy continues under exactly those settings; it never gains the current ones.
64
+ */
65
+ export interface WorkflowLifecyclePolicy {
66
+ readonly permissions: Permissions;
67
+ readonly policyVersion: string;
68
+ readonly maxCostMicros: number;
69
+ readonly maxOutputBytes?: number;
70
+ readonly approvalTtlMs?: number;
71
+ }
46
72
  export interface WorkflowLifecycleRuntimeOptions {
47
73
  readonly store: AggregateStore;
48
74
  readonly scope: Scope;
@@ -51,6 +77,11 @@ export interface WorkflowLifecycleRuntimeOptions {
51
77
  readonly maxCostMicros: number;
52
78
  readonly approvalTtlMs?: number;
53
79
  readonly maxOutputBytes?: number;
80
+ /**
81
+ * Settings of earlier deployments (at most 16). Runs started under one of them continue under it instead of
82
+ * failing with CONFLICT; new runs always use the current settings, and `migrate` moves a run onto them.
83
+ */
84
+ readonly previousPolicies?: readonly WorkflowLifecyclePolicy[];
54
85
  readonly callbackTimeoutMs?: number;
55
86
  readonly maxPendingCallbacks?: number;
56
87
  /** Trusted synchronized clock; never accepted from workflow input. */
@@ -97,6 +128,11 @@ export interface WorkflowLifecycleRuntime {
97
128
  readonly actor: WorkflowLifecycleVerifiedActor;
98
129
  readonly value: unknown;
99
130
  }): Promise<WorkflowLifecycleSnapshot>;
131
+ /**
132
+ * Deliver a signal to the run's `signal` step named `command.name`. The payload is validated with the step's
133
+ * `payload` schema (INVALID_INPUT otherwise). The run continues on its next `runUntilSettled`, as after a response.
134
+ */
135
+ signal(definition: AnyWorkflowLifecycle, command: WorkflowLifecycleSignalCommand): Promise<WorkflowLifecycleSnapshot>;
100
136
  pause(id: string): Promise<WorkflowLifecycleSnapshot>;
101
137
  resume(id: string): Promise<WorkflowLifecycleSnapshot>;
102
138
  /**
@@ -110,6 +146,31 @@ export interface WorkflowLifecycleRuntime {
110
146
  /** Admit no new wave, let admitted effects and receipts settle within the deadline, then close. */
111
147
  drain(options?: WorkflowDrainOptions): Promise<WorkflowDrainReport>;
112
148
  }
149
+ /** @internal A validated policy with its defaults applied. */
150
+ export interface WorkflowPolicySettings {
151
+ readonly permissions: Permissions;
152
+ readonly policyVersion: string;
153
+ readonly maxCostMicros: number;
154
+ readonly maxOutputBytes: number;
155
+ readonly approvalTtlMs: number;
156
+ }
157
+ /**
158
+ * @internal The runtime's own settings first, then each previous policy, validated and defaulted alike, so index `n`
159
+ * means the same settings to every runtime built from one options object.
160
+ */
161
+ export declare function workflowPolicySettings(options: WorkflowLifecyclePolicy & {
162
+ readonly previousPolicies?: readonly WorkflowLifecyclePolicy[];
163
+ }): readonly WorkflowPolicySettings[];
164
+ /** @internal The digest a run records for its settings; each runtime kind has its own domain tag. */
165
+ export declare function workflowPolicyDigest(tag: string, scope: Scope, settings: WorkflowPolicySettings): string;
166
+ /** @internal */
167
+ export declare function unknownWorkflowPolicy(): MayuraError;
168
+ type LifecycleSubmission = Parameters<WorkflowLifecycleRuntime['submit']>;
169
+ /**
170
+ * @internal Submit under the runtime's policy at `policy` (0: current, n: `previousPolicies[n - 1]`), so the later
171
+ * children of a pinned saga or loop keep the parent's settings instead of gaining the current ones.
172
+ */
173
+ export declare function submitWorkflowLifecycleUnder(runtime: WorkflowLifecycleRuntime, policy: number, ...submission: LifecycleSubmission): Promise<WorkflowLifecycleSnapshot>;
113
174
  /** Conservative durable lifecycle driver. Waiting nodes never retain a callback, worker, or timer handle. */
114
175
  export declare function createWorkflowLifecycleRuntime(options: WorkflowLifecycleRuntimeOptions): WorkflowLifecycleRuntime;
115
176
  //# sourceMappingURL=lifecycle-runtime.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"lifecycle-runtime.d.ts","sourceRoot":"","sources":["../src/lifecycle-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EACmC,KAAK,SAAS,EAAE,KAAK,WAAW,EAAE,KAAK,KAAK,EAAE,MAAM,cAAc,CAAC;AAE7G,OAAO,EAA2B,KAAK,oBAAoB,EAAE,KAAK,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAC1G,OAAO,EAEL,KAAK,cAAc,EACnB,KAAK,uBAAuB,EAAE,KAAK,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAE9F,OAAO,EAA8C,KAAK,oBAAoB,EAChD,MAAM,2BAA2B,CAAC;AAChE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EACkB,KAAK,gBAAgB,EAAE,KAAK,iBAAiB,EAAE,KAAK,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAC7H,YAAY,EAAE,uBAAuB,EA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