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
@@ -0,0 +1,202 @@
1
+ ---
2
+ title: "Tools"
3
+ description: "Define typed tools with defineTool: schemas, effects, capabilities, cost, timeouts, refusals and batches."
4
+ ---
5
+
6
+ A tool is a typed function an agent can ask to run: look up an order, search documents, open a ticket. You define it
7
+ once with `defineTool`, give it input and output schemas, and say what kind of effect it has. Every call goes through
8
+ the same checks, whether a model asked for it, a workflow step runs it or your own code calls it: the caller must be
9
+ allowed to use it, its input is validated before your code runs, and its output is validated before anyone sees it.
10
+
11
+ ## A read-only tool
12
+
13
+ ```ts
14
+ import { defineTool, z } from 'mayura';
15
+
16
+ export const lookupOrder = defineTool({
17
+ id: 'orders.lookup',
18
+ version: '1',
19
+ description: 'Look up one order by id. Returns found=false when there is no such order.',
20
+ input: z.object({ orderId: z.string().min(1).max(64) }),
21
+ output: z.object({
22
+ found: z.boolean(),
23
+ orderId: z.string(),
24
+ status: z.string().nullable(),
25
+ }),
26
+ effects: 'read',
27
+ capabilities: [],
28
+ timeoutMs: 5_000,
29
+ execute: async ({ orderId }, context) => {
30
+ const order = await db.findOrder(orderId, { signal: context.signal });
31
+ if (!order) return { found: false, orderId, status: null };
32
+ return { found: true, orderId, status: order.status };
33
+ },
34
+ });
35
+ ```
36
+
37
+ To call this tool, a runtime must allow `tool:orders.lookup` and `effect:read`. Add the tool to an agent's `tools`
38
+ list to let the model use it.
39
+
40
+ ## Options
41
+
42
+ | Option | Default | What it is |
43
+ | --- | --- | --- |
44
+ | `id` | required | Stable name, used in permissions as `tool:<id>`. Starts with a letter; letters, digits, `.`, `_`, `/`, `-`; up to 128 characters. |
45
+ | `version` | required | Version of the tool's behavior and schemas, for example `1`. Change it when either changes. |
46
+ | `description` | required | What the tool does and returns, written for the model. Up to 4096 characters. |
47
+ | `input` | required | Standard Schema validator for the input. `execute` receives the validated value. |
48
+ | `output` | required | Standard Schema validator for the result. The result is checked before anyone sees it. |
49
+ | `inputJsonSchema` | generated | The input as JSON Schema, which the model reads. Generated from `input` when the validator can describe itself (Zod 4.2 and later); give it otherwise. |
50
+ | `effects` | required | `'none'`, `'read'`, `'write'` or `'host'`. |
51
+ | `capabilities` | required | Extra permission names a caller must hold, for example `['payments:refund']`. Pass `[]` for none. |
52
+ | `costMicros` | `0` | The most one call can cost, in micros (millionths of a dollar). |
53
+ | `timeoutMs` | `30000` | How long one call may take before it is stopped. |
54
+ | `guards` | none | `{ input, output }` lists of guards that allow or block this tool's input and output. |
55
+ | `execute` | required | `(input, context)` returning the output or a promise of it. |
56
+
57
+ ## Input schemas for real models
58
+
59
+ `input` is what Mayura enforces. The model also needs to know how to call the tool, as JSON Schema: Mayura generates
60
+ it from `input` (validators that implement Standard JSON Schema can describe themselves, as Zod 4.2 and later do), and
61
+ you can see it as `tool.inputJsonSchema`. Pass `inputJsonSchema` yourself only when your validator cannot describe
62
+ itself, or to tell the model something narrower.
63
+
64
+ Model providers accept only strict schemas: every field present, no extra keys. So for a field the model may leave
65
+ empty, use `.nullable()` rather than `.optional()` or `.default()`, and avoid open records (`z.record`). You don't have
66
+ to remember this: when you pass the tool to `defineAgent` with a real model, it checks every tool and throws an error
67
+ that names the field and the fix, for example:
68
+
69
+ ```text
70
+ Agent support: Tool "orders.find" input schema: property "query" is optional, but model providers require every
71
+ property. Make it nullable instead (with Zod, .nullable() rather than .optional() or .default()).
72
+ ```
73
+
74
+ The scripted test model accepts any schema.
75
+
76
+ ## Effects and capabilities
77
+
78
+ `effects` says what a call can change, and decides which permission a caller needs:
79
+
80
+ | Effect | Use it for | Extra permission required |
81
+ | --- | --- | --- |
82
+ | `none` | Pure computation, no outside state. | none |
83
+ | `read` | Reads outside state: databases, APIs, files. | `effect:read` |
84
+ | `write` | Changes outside state: sends, updates, payments. | `effect:write` |
85
+ | `host` | Runs work on your own infrastructure, such as a nested agent run inside a durable workflow. | `effect:host` |
86
+
87
+ `capabilities` are names you invent for finer control, such as `payments:refund` or `email:send`. A caller needs
88
+ every one of them. See [Permissions](./permissions.md).
89
+
90
+ The effect also changes what Mayura reports when something goes wrong. If a `none` or `read` tool throws, the call
91
+ simply failed: it changed nothing outside, so there is nothing to check (its declared `costMicros` is still charged,
92
+ since a paid lookup may have been billed). If a `write` or `host` tool throws or times out after it started, Mayura
93
+ cannot know whether the change happened, so the call ends as `outcome_unknown`. See [Outcomes and errors](./outcomes.md).
94
+
95
+ ## The execute context
96
+
97
+ `execute` receives the validated input and a context:
98
+
99
+ | Field | What it is |
100
+ | --- | --- |
101
+ | `runId` | The run this call belongs to. |
102
+ | `callId` | The call's id, unique within the run. `runId` plus `callId` makes a good idempotency key. |
103
+ | `scope` | `{ principalId, projectId }`: who the run acts for. Use it to scope data access. |
104
+ | `signal` | An `AbortSignal` that fires on cancellation or timeout. Pass it to `fetch` and database calls. |
105
+ | `reportUsage` | Report the real cost of this call, once: `{ knownCostMicros, unknownCostMicros }`. |
106
+
107
+ If you never call `reportUsage`, a successful call is charged its full `costMicros`. Reported cost cannot exceed
108
+ `costMicros`. Reporting any `unknownCostMicros` makes the call `outcome_unknown`, because the cost is not settled.
109
+
110
+ ## Return "not found", don't throw it
111
+
112
+ Inside a run, a tool call that does not succeed ends the whole run. And a thrown error from a `write` or `host` tool
113
+ is reported as `outcome_unknown`, which asks a person to check what happened. So for ordinary answers the
114
+ model should act on, such as "no such order", "not eligible" or "already done", return a structured result and
115
+ describe it in the tool's description. The model reads it and continues.
116
+
117
+ Throw only when something is really broken, and the run should stop.
118
+
119
+ ## Refusing a call: ToolRefusal and withPreflight
120
+
121
+ Sometimes a tool decides not to act, before it has changed anything: the request is not allowed, or a person
122
+ declined it. Throw `ToolRefusal` for that. Mayura records the call as not started, releases its reserved cost, and
123
+ reports `failed` with code `TOOL_FAILED` and your reason as the message, never `outcome_unknown`. Only throw it when
124
+ nothing happened yet; a refusal after the tool reported usage is not believed.
125
+
126
+ `withPreflight` wraps an existing tool with a check that runs on the validated input before `execute`. It returns a
127
+ tool with the same id; `extraTimeoutMs` lengthens its timeout for checks that wait, and `description` replaces the
128
+ description.
129
+
130
+ ```ts
131
+ import { ToolRefusal, defineTool, withPreflight, z } from 'mayura';
132
+
133
+ const refundOrder = defineTool({
134
+ id: 'orders.refund',
135
+ version: '1',
136
+ description: 'Refund a delivered order in full. Safe to repeat: an order is never refunded twice.',
137
+ input: z.object({ orderId: z.string().min(1).max(64) }),
138
+ output: z.object({ status: z.enum(['refunded', 'already_refunded', 'not_found', 'not_eligible']) }),
139
+ effects: 'write',
140
+ capabilities: ['payments:refund'],
141
+ costMicros: 1_000,
142
+ execute: async ({ orderId }, context) => {
143
+ const order = await db.findOrder(orderId, { signal: context.signal });
144
+ if (!order) return { status: 'not_found' as const };
145
+ if (order.status !== 'delivered') return { status: 'not_eligible' as const };
146
+ const result = await payments.refund(orderId, { idempotencyKey: `${context.runId}/${context.callId}` });
147
+ return { status: result.created ? 'refunded' as const : 'already_refunded' as const };
148
+ },
149
+ });
150
+
151
+ export const guardedRefund = withPreflight(refundOrder, async ({ orderId }) => {
152
+ if (await fraud.isFlagged(orderId)) throw new ToolRefusal('Refunds for this order need a manual review.');
153
+ });
154
+ ```
155
+
156
+ For a person approving each call, see [Approvals and human input](../guides/approvals-and-human-input.md).
157
+
158
+ ## Calling tools without an agent
159
+
160
+ `invokeTool(tool, input, options)` runs one tool through the same checks, outside any agent. You pass the permissions,
161
+ scope, a `Budget` and an `AbortSignal` yourself, and get an outcome back instead of an exception.
162
+
163
+ `invokeBatch(calls, options)` runs 1 to 128 calls together. Each call has an `id`, a `tool` and an `input`. An input can
164
+ refer to an earlier call's result with `batchOutput(callId, path)`, which also makes the call wait for that one.
165
+ Mayura checks every permission and every literal input before the first call starts, then runs ready calls in
166
+ parallel (4 at a time by default, `concurrency` up to 32).
167
+
168
+ ```ts
169
+ import { Budget, batchOutput, invokeBatch } from 'mayura';
170
+
171
+ const results = await invokeBatch([
172
+ { id: 'customer', tool: findCustomer, input: { email: 'ada@example.com' } },
173
+ { id: 'orders', tool: listOrders, input: { customerId: batchOutput('customer', ['customerId']) } },
174
+ ], {
175
+ runId: 'nightly-sync',
176
+ scope: { principalId: 'ops', projectId: 'shop' },
177
+ signal: AbortSignal.timeout(30_000),
178
+ permissions: { allow: ['tool:customers.find', 'tool:orders.list', 'effect:read'] },
179
+ budget: new Budget(0, 2),
180
+ });
181
+ for (const { id, outcome } of results) console.log(id, outcome.status);
182
+ ```
183
+
184
+ Results come back in input order. Besides the usual outcomes, a call can be `skipped` (for example because a call it
185
+ depends on failed, or `failurePolicy: 'fail-fast'` stopped the batch) or `waiting`. Batches are process-local: they do
186
+ not survive a restart and never retry on their own.
187
+
188
+ ## Good to know
189
+
190
+ - `execute` is ordinary JavaScript in your process. Effects and capabilities control who may call a tool; they do not
191
+ sandbox what it does.
192
+ - Tool guards can allow or block, not rewrite. An agent's output guards also see every tool result, and can rewrite it.
193
+ - A timeout aborts `context.signal`, but code that ignores the signal keeps running. Always pass the signal on.
194
+ - Output is limited to 1 MiB by default (the runtime's `maxOutputBytes`).
195
+
196
+ ## Related
197
+
198
+ - [Agents](./agent.md)
199
+ - [Permissions](./permissions.md)
200
+ - [Costs and budgets](./costs-and-budgets.md)
201
+ - [Outcomes and errors](./outcomes.md)
202
+ - [MCP](../guides/mcp.md)
@@ -0,0 +1,134 @@
1
+ ---
2
+ title: "Workflows"
3
+ description: "What a Mayura workflow is, when to use one instead of a single agent run, and which workflow entry point to start with."
4
+ ---
5
+
6
+ A workflow is a fixed graph of steps that you declare as data: run this tool, then these three in parallel, wait for a
7
+ person, wait until Tuesday, then finish. Each step is a [tool](tools.md), so every step has typed input and output,
8
+ declared effects and its own permission. The graph, not a model, decides what runs next.
9
+
10
+ An agent run is the opposite: the model decides which tools to call, in what order, and when it is done. Use a workflow
11
+ when you already know the steps and want them to run the same way every time, with an audit trail. Use an agent when
12
+ the path depends on judgement. The two combine well: a workflow step can run an agent, and an agent can call a workflow
13
+ as a tool.
14
+
15
+ | You need | Use |
16
+ |---|---|
17
+ | A model to plan, call tools and answer | A single [agent run](agent.md) |
18
+ | The same steps every time, in a fixed order | An in-process workflow |
19
+ | Steps that survive restarts, wait hours for a person or a date, and never repeat a payment | A durable workflow |
20
+ | Undo earlier steps when a later one fails | A saga |
21
+ | Repeat a durable workflow until a condition holds | A loop |
22
+
23
+ ## A workflow at a glance
24
+
25
+ ```ts
26
+ import { defineTool, z } from 'mayura';
27
+ import { defineWorkflowLifecycle } from 'mayura/workflows/lifecycle';
28
+
29
+ const invoice = z.object({ invoiceId: z.string(), amountCents: z.number().int() });
30
+
31
+ const check = defineTool({
32
+ id: 'invoices.check', version: '1', description: 'Check an invoice against policy.',
33
+ input: invoice, output: z.object({ ok: z.boolean() }), effects: 'none', capabilities: [],
34
+ execute: request => ({ ok: request.amountCents < 100_000 }),
35
+ });
36
+ const pay = defineTool({
37
+ id: 'invoices.pay', version: '1', description: 'Pay an invoice.',
38
+ input: invoice, output: z.object({ paymentId: z.string() }), effects: 'write', capabilities: ['payments:send'],
39
+ execute: async request => ({ paymentId: `pay_${request.invoiceId}` }),
40
+ });
41
+
42
+ export const payInvoice = defineWorkflowLifecycle({
43
+ id: 'invoices.pay-flow',
44
+ version: '1',
45
+ input: invoice,
46
+ output: z.object({ paymentId: z.string() }),
47
+ nodes: [
48
+ { kind: 'tool', id: 'check', tool: check, input: { kind: 'input', path: [] } },
49
+ // Stops until a person approves this exact payment.
50
+ { kind: 'tool', id: 'pay', tool: pay, input: { kind: 'input', path: [] }, dependsOn: ['check'], approval: true },
51
+ ],
52
+ result: { kind: 'step', stepId: 'pay', path: [] },
53
+ });
54
+ ```
55
+
56
+ The pieces:
57
+
58
+ - **Nodes** are the steps. A `tool` node runs a tool, a `join` node collects the outputs of its dependencies into an
59
+ array, and durable workflows add `human` nodes (wait for a typed answer from a person), `timer` nodes (wait until
60
+ an absolute time) and `signal` nodes (wait for an event from another system). A tool node can run an agent through
61
+ `agentStep`.
62
+ - **Bindings** say where a step's input comes from: `{ kind: 'input', path }` reads the workflow input,
63
+ `{ kind: 'step', stepId, path }` reads an earlier step's output, and `{ kind: 'literal', value }` is a fixed JSON
64
+ value. A path is a list of property names; `[]` means the whole value.
65
+ - **`dependsOn`** orders the steps. A step that reads another step's output must depend on it. Steps whose dependencies
66
+ are done run together.
67
+ - **`result`** is a binding that picks the workflow's output, checked against the `output` schema.
68
+
69
+ The graph is fixed when you define it: at most 128 nodes, no cycles, and no code runs between steps. Logic lives in the
70
+ tools. For work whose width depends on data, a durable workflow can declare up to a fixed number of parallel slots
71
+ (`fanOut`) and skip steps with a condition (`when`). See [Durable workflows](../guides/durable-workflows.md).
72
+
73
+ ## In-process or durable
74
+
75
+ Mayura runs workflows in two ways.
76
+
77
+ **In-process (ephemeral).** `mayura/workflows/ephemeral` turns a workflow into an agent, or into a tool another agent
78
+ can call, and runs it inside an ordinary [runtime](runtime.md) with that runtime's permissions, limits and budget.
79
+ Nothing is stored. If the process stops, the run is gone. There are no approvals or waits. Use it to package a fixed
80
+ sequence of tool calls as one reusable unit. See [Workflow composition](../guides/workflow-composition.md).
81
+
82
+ **Durable.** A durable workflow records every step in [storage](../guides/storage.md) (SQLite or PostgreSQL) before
83
+ and after it runs. A run can wait for days for an approval, a person or a date without holding any memory or process.
84
+ When a process restarts, another worker picks the run up where it stopped. A step that was running when the process
85
+ died is never run again automatically: its outcome is marked unknown, and a person decides what happened. This is what
86
+ makes durable workflows safe for payments, emails and other effects that must not happen twice.
87
+
88
+ ## Workflow entry points
89
+
90
+ | Entry point | What it gives you |
91
+ |---|---|
92
+ | `mayura/workflows/lifecycle` | **Start here.** Durable workflows with tool steps, approvals, human requests, timers, optional steps and parallel slots, plus the worker host that advances them. |
93
+ | `mayura/workflows` | Shared pieces for running workflows in production: workers and leadership, the fleet hold, the operator API for the HTTP server, version inventory and migrations, trace export. It also re-exports the lifecycle API, and contains `defineWorkflow` and two earlier durable runtimes for plain tool graphs. |
94
+ | `mayura/workflows/ephemeral` | `workflowAsAgent` and `workflowAsTool`: run a `defineWorkflow` graph in-process. |
95
+ | `mayura/workflows/sagas` | Sequences of durable workflows that compensate (undo) earlier steps in reverse order when a later one fails. |
96
+ | `mayura/workflows/loops` | Repeat one durable workflow, up to a fixed number of times, until a condition in its output is false. |
97
+ | `mayura/workflows/composites` | The worker host and index that advance sagas and loops after a restart. |
98
+ | `mayura/workflows/graphs` | Durable graphs that wait for other, already submitted runs to finish before continuing. |
99
+ | `mayura/workflows/children` | Durable workflow trees: a root workflow that starts required child workflows, one level deep. |
100
+ | `mayura/workflows/agents` | `agentAsDurableWorkflow`: wrap an agent as a one-step durable workflow for the earlier `defineWorkflow` runtimes. |
101
+
102
+ The related `mayura/workstream/*` entry points are standalone durable building blocks that work next to workflows:
103
+ [webhook triggers](../guides/webhooks.md), typed [human requests](../guides/approvals-and-human-input.md) outside a
104
+ workflow, durable timers and completion waits.
105
+
106
+ **Which one to start with.** For anything that must survive a restart, use `mayura/workflows/lifecycle`. It is what
107
+ every `mayura init` starter uses, and sagas and loops are built from lifecycle workflows. Reach for graphs or children
108
+ only when you need a run to wait on other runs or own child runs. Use `mayura/workflows/ephemeral` when you only want
109
+ to compose tools in-process.
110
+
111
+ ## Definition versions
112
+
113
+ Every durable run is pinned to the exact definition it started with: its `id`, its `version` and a digest of its
114
+ steps. Mayura never continues a run under a different definition. When you change a workflow, give it a new
115
+ `version`, keep the old version registered with your workers until its runs finish, and optionally move in-flight runs
116
+ to the new version with a reviewed migration. See [Operating workflows](../guides/workflow-operations.md).
117
+
118
+ ## Good to know
119
+
120
+ - Steps are tools. To run a model inside a step, wrap an agent in a tool; see
121
+ [Durable workflows](../guides/durable-workflows.md).
122
+ - There are no automatic retries. A failed step fails the run; a step with an unknown outcome makes the run end
123
+ `outcome_unknown` and waits for a person.
124
+ - A durable run has one cost budget, in micros, shared by all its steps. See [Costs and budgets](costs-and-budgets.md).
125
+ - Durable runtimes grant permissions with the same explicit strings as agents: `tool:<id>`, each capability the tool
126
+ declares, and `effect:<kind>` for tools with effects. See [Permissions](permissions.md).
127
+
128
+ ## Related
129
+
130
+ - [Durable workflows](../guides/durable-workflows.md)
131
+ - [Workflow composition](../guides/workflow-composition.md)
132
+ - [Approvals and human input](../guides/approvals-and-human-input.md)
133
+ - [Sagas and loops](../guides/sagas-and-loops.md)
134
+ - [Operating workflows](../guides/workflow-operations.md)
@@ -0,0 +1,278 @@
1
+ ---
2
+ title: "Approvals and human input"
3
+ description: "Stop a durable workflow until a person approves an exact tool call or answers a typed question, and respond from code, CLI or UI."
4
+ ---
5
+
6
+ Some steps should not happen until a person says so: paying a refund, deleting an account, publishing a post. Others
7
+ need information only a person has: a corrected address, a choice between two plans. Mayura handles both inside
8
+ [durable workflows](durable-workflows.md), and the run waits in storage, not in memory, for as long as it takes.
9
+
10
+ - **Approvals.** Mark a tool step with `approval: true`. The run stops before the tool runs, and a person approves the
11
+ exact call: the tool, its version and its validated input.
12
+ - **Human requests.** A `human` step asks a typed question and continues with the validated answer as its output.
13
+ - **Standalone requests.** `mayura/workstream/humans` stores the same kind of typed question outside any workflow.
14
+
15
+ ## A complete example
16
+
17
+ This workflow checks a refund and waits for approval before paying it. The approver is verified by `verifyHuman`.
18
+
19
+ ```ts
20
+ import { defineTool, z } from 'mayura';
21
+ import { createSqliteStore } from 'mayura/storage-sqlite';
22
+ import { createWorkflowLifecycleRuntime, defineWorkflowLifecycle } from 'mayura/workflows/lifecycle';
23
+
24
+ const refund = z.object({ refundId: z.string(), amountCents: z.number().int().positive() });
25
+
26
+ const policy = defineTool({
27
+ id: 'refunds.policy', version: '1', description: 'Check a refund against the refund policy.',
28
+ input: refund, output: z.object({ ok: z.boolean() }), effects: 'none', capabilities: [],
29
+ execute: request => ({ ok: request.amountCents <= 50_000 }),
30
+ });
31
+ const issue = defineTool({
32
+ id: 'refunds.issue', version: '1', description: 'Issue the refund.',
33
+ input: refund, output: z.object({ receiptId: z.string() }), effects: 'write', capabilities: ['payments:refund'],
34
+ execute: async request => ({ receiptId: `re_${request.refundId}` }),
35
+ });
36
+
37
+ const refunds = defineWorkflowLifecycle({
38
+ id: 'refunds.approval', version: '1', input: refund, output: z.object({ receiptId: z.string() }),
39
+ nodes: [
40
+ { kind: 'tool', id: 'policy', tool: policy, input: { kind: 'input', path: [] } },
41
+ { kind: 'tool', id: 'issue', tool: issue, input: { kind: 'input', path: [] }, dependsOn: ['policy'], approval: true },
42
+ ],
43
+ result: { kind: 'step', stepId: 'issue', path: [] },
44
+ });
45
+
46
+ // Credentials are objects your authenticated code creates; request data can never forge one.
47
+ const approvers = new WeakMap<object, string>();
48
+ const credentialFor = (personId: string): object => { const credential = {}; approvers.set(credential, personId); return credential; };
49
+
50
+ const store = createSqliteStore({ filename: ':memory:' });
51
+ await store.initialize();
52
+ const runtime = createWorkflowLifecycleRuntime({
53
+ store,
54
+ scope: { principalId: 'refunds-service', projectId: 'shop' },
55
+ permissions: { allow: ['tool:refunds.policy', 'tool:refunds.issue', 'payments:refund', 'effect:write'] },
56
+ policyVersion: '1',
57
+ maxCostMicros: 0,
58
+ verifyHuman: async credential => {
59
+ const id = typeof credential === 'object' && credential !== null ? approvers.get(credential) : undefined;
60
+ if (!id) throw new Error('Unknown approver.');
61
+ return { id, projectId: 'shop', canApprove: true };
62
+ },
63
+ });
64
+
65
+ const run = await runtime.submit(refunds, { input: { refundId: 'rf-1', amountCents: 4_999 }, idempotencyKey: 'rf-1' });
66
+ const waiting = await runtime.runUntilSettled(refunds, run.id); // status: 'waiting'
67
+
68
+ // Show the approver exactly what will run.
69
+ const request = await runtime.approvalRequest(refunds, run.id, 'issue');
70
+ console.log(request?.toolId, request?.input); // refunds.issue { refundId: 'rf-1', amountCents: 4999 }
71
+
72
+ if (request) await runtime.approve({ id: run.id, nodeId: 'issue', digest: request.digest, credential: credentialFor('alice') });
73
+ const done = await runtime.runUntilSettled(refunds, run.id);
74
+ console.log(done.status, done.output); // succeeded { receiptId: 're_rf-1' }
75
+
76
+ runtime.close();
77
+ await store.close();
78
+ ```
79
+
80
+ ## Approvals
81
+
82
+ When the run reaches an approval step, it validates the tool input, stores an approval request and ends the wave with
83
+ status `waiting`. The request has a `digest` that binds the run, the step, the tool id and version, the exact input and
84
+ an expiry time. Nothing runs until someone approves that digest.
85
+
86
+ - `runtime.approvalRequest(definition, runId, nodeId)` returns what an approver should see: `toolId`, `toolVersion`,
87
+ `input`, `digest` and `expiresAtMs`. The runtime rebuilds it and checks it still matches the digest.
88
+ - `runtime.approve({ id, nodeId, digest, credential })` records the approval. `verifyHuman` must return a person in the
89
+ runtime's project with `canApprove: true`; otherwise it fails with `PERMISSION_DENIED`. Approving the same digest
90
+ again is harmless.
91
+ - An approval request lapses after `approvalTtlMs` (1 hour by default). On the next pass the run issues a fresh request
92
+ with a new digest, so always approve the digest you just read. An old digest is refused with `CONFLICT`.
93
+ - After approval, call `runUntilSettled` again (a worker does this in production) and the tool runs once.
94
+
95
+ An approval does not grant permissions. The workflow runtime must still allow the tool, its capabilities and its
96
+ effect. See [Permissions](../concepts/permissions.md).
97
+
98
+ ## Verifying who responds
99
+
100
+ `verifyHuman` is the boundary between your authentication and the workflow. It receives an opaque credential and
101
+ returns `{ id, projectId, canApprove }`, or throws. Mayura stores only the returned `id`, never the credential. Build
102
+ the credential in trusted code after you have authenticated the person, as the example does, and never accept one
103
+ that came from request JSON. The `mayura init` approval starter uses the same pattern.
104
+
105
+ ## Human requests
106
+
107
+ A `human` step asks a person for a typed answer. The answer is validated with the step's `response` schema and becomes
108
+ the step's output, which later steps can bind to.
109
+
110
+ ```ts
111
+ import type { WorkflowLifecycleNode } from 'mayura/workflows/lifecycle';
112
+ import { z } from 'mayura';
113
+
114
+ const pickPlan: WorkflowLifecycleNode = {
115
+ kind: 'human', id: 'pick-plan', dependsOn: ['propose'],
116
+ request: {
117
+ kind: 'plan_selection',
118
+ schemaId: 'migrations.plan-choice', // schemaDigest is derived from the Zod response below
119
+ prompt: 'Choose how to run the database migration.',
120
+ response: z.object({ plan: z.enum(['online', 'maintenance-window']) }),
121
+ context: { kind: 'step', stepId: 'propose', path: ['options'] },
122
+ deadlineAtMs: { kind: 'input', path: ['decideBy'] },
123
+ },
124
+ };
125
+ ```
126
+
127
+ | Field | Meaning |
128
+ |---|---|
129
+ | `kind` | `information` (a fact or note), `correction` (a fix to a specific thing) or `plan_selection` (a choice). |
130
+ | `schemaId`, `schemaDigest` | A stable name and a 64-hex SHA-256 of your response contract. Forms and clients use them to show the right fields. Leave `schemaDigest` out to derive it from `response` (see [Schema digests](#schema-digests)). |
131
+ | `prompt` | What the person sees, up to 1 KiB. |
132
+ | `response` | The schema the answer must pass. |
133
+ | `context` | Optional binding to JSON shown with the request. It is stored, so include only what the responder may see. |
134
+ | `subjectDigest` | Required for `correction`, not allowed otherwise: a binding to the 64-hex digest of the exact thing being corrected. |
135
+ | `deadlineAtMs` | Optional binding to an absolute time. If no answer arrives by then, the step is `timed_out` and the run fails. |
136
+
137
+ To answer from code, read the request, then respond with its digest:
138
+
139
+ ```ts
140
+ const request = await runtime.humanRequest(definition, runId, 'pick-plan');
141
+ if (request?.status === 'waiting') {
142
+ await runtime.respond(definition, {
143
+ id: runId, nodeId: 'pick-plan', requestDigest: request.digest,
144
+ commandId: 'pick-plan-1', credential, value: { plan: 'online' },
145
+ });
146
+ }
147
+ ```
148
+
149
+ ### Schema digests
150
+
151
+ A schema digest pins the response contract into the request, so a form built for another version of it cannot answer.
152
+ When the `response` validator can describe itself as JSON Schema (Zod 4.2 and later can), leave `schemaDigest` out and
153
+ the definition derives it. For a validator that cannot, pass the digest yourself; `schemaDigest` computes it from a
154
+ JSON Schema object, and gives your UI the same value:
155
+
156
+ ```ts
157
+ import { schemaDigest } from 'mayura/workflows/lifecycle';
158
+
159
+ const planChoiceDigest = schemaDigest(planChoiceJsonSchema); // 64 hex characters
160
+ ```
161
+
162
+ A derived digest follows the JSON Schema the validator produces. If a library upgrade changes that JSON Schema, the
163
+ digest changes too, and with it the definition's digest: register the new definition as a new `version`, as for any
164
+ other change, or pass the digest explicitly to keep it fixed.
165
+
166
+ `respond` checks the credential with `verifyHuman` (it does not need `canApprove`). If you have already authenticated
167
+ the person yourself, `respondVerified` takes `actor: { id, projectId }` instead of a credential. Repeating the same
168
+ command id, person and value is harmless; a different answer to an answered request is refused with `CONFLICT`, and so
169
+ is an answer after the deadline. An answer is only data: it never grants a tool permission or approves a step.
170
+
171
+ ## Responding over HTTP, CLI and UI
172
+
173
+ The [HTTP server](server-and-client.md) exposes both kinds of wait to authenticated callers.
174
+
175
+ **Approvals** come with the workflow operator API. Pass `approvalCredential` to `lifecycleOperatorTarget`, a function
176
+ that turns the authenticated operator's id into a credential your `verifyHuman` accepts (see
177
+ [Operating workflows](workflow-operations.md)). A waiting step in the run view then carries `approval.digest`,
178
+ `approval.expiresAtMs` and `approval.subject`, the exact tool call. Approving needs the `workflows:control` capability:
179
+
180
+ ```ts
181
+ const view = await client.workflow(runId);
182
+ const step = view.steps.find(item => item.id === 'issue');
183
+ if (step?.approval) {
184
+ await client.approveWorkflow(runId, { revision: view.revision, nodeId: 'issue', approvalDigest: step.approval.digest },
185
+ { commandId: crypto.randomUUID() });
186
+ }
187
+ ```
188
+
189
+ **Human requests** are served by `createWorkflowLifecycleHumanTransport`. Give it the fleet runtime and the
190
+ definitions whose requests it serves, and pass `controller.transport` to the server as `humanRequests`. It finds
191
+ pending requests in storage through the fleet index, so nothing is registered and a restart loses nothing. Listing
192
+ needs `humans:read`, answering needs `humans:respond`, and the verified caller becomes the responder.
193
+
194
+ ```ts
195
+ import { createWorkflowLifecycleFleetRuntime, createWorkflowLifecycleHumanTransport } from 'mayura/workflows/lifecycle';
196
+
197
+ const runtime = createWorkflowLifecycleFleetRuntime(options);
198
+ const humans = createWorkflowLifecycleHumanTransport({
199
+ scope: options.scope, runtime,
200
+ // Every version with runs in flight, and the agent whose callers may see and answer its requests.
201
+ definitions: [{ agentId: 'planner', definition }],
202
+ });
203
+ // Pass humans.transport to the server as `humanRequests`.
204
+
205
+ const page = await client.humanRequests();
206
+ const pending = page.items.find(item => item.status === 'waiting');
207
+ if (pending) await client.respondHumanRequest(pending.id, pending.digest, { plan: 'online' }, { commandId: crypto.randomUUID() });
208
+ ```
209
+
210
+ - A caller sees a request only in the transport's scope, and only if its identity lists the request's `agentId`.
211
+ - The transport lists the requests of active runs (running, waiting or paused), including answered and timed-out ones.
212
+ A run that has finished leaves the index, and its requests with it.
213
+ - The runtime must serve the same scope as the transport; a mismatch is refused with `INVALID_CONFIG`.
214
+ - Request ids are opaque 64-hex strings, stable for a run and step.
215
+ - Without a fleet runtime, create the transport with only `scope` and call `register({ agentId, definition, runtime,
216
+ runId })` for each run instead. Those registrations live in memory: register again after a restart, and call
217
+ `unregister(runId)` when a run finishes.
218
+
219
+ - **CLI.** `mayura workflow-approve`, `mayura human-list`, `mayura human-get` and `mayura human-respond`. See
220
+ [Operations commands](../cli/operations.md).
221
+ - **Operator console.** Shows pending approvals with the exact tool call, and open human requests. See
222
+ [Operator console](operator-console.md).
223
+ - **React.** Ready-made typed response forms that bind to `schemaId` and `schemaDigest`. See [React](react.md).
224
+
225
+ Keep one command id per logical attempt. If a request times out, retry with the same command id; the server returns
226
+ the recorded outcome instead of acting twice.
227
+
228
+ ## Human requests outside a workflow
229
+
230
+ `mayura/workstream/humans` stores a typed request and its answer durably without a workflow run, for example when an
231
+ agent tool needs a person's input that your own code will act on later.
232
+
233
+ ```ts
234
+ import { createHumanWorkStream } from 'mayura/workstream/humans';
235
+ import { z } from 'mayura';
236
+
237
+ const humans = createHumanWorkStream({
238
+ store, scope, streamId: 'address-checks',
239
+ // Decide whether an already authenticated person may answer this request.
240
+ authorize: async ({ actor, request }) => actor.id.startsWith('support-') && request.kind === 'correction',
241
+ });
242
+ await humans.initialize();
243
+
244
+ const fixAddress = {
245
+ id: 'order-1001-address', kind: 'correction' as const,
246
+ schemaId: 'orders.address', // schemaDigest is derived from the Zod response below
247
+ prompt: 'The courier rejected this address. Please correct it.',
248
+ response: z.object({ line1: z.string(), postcode: z.string() }),
249
+ subjectDigest: rejectedAddressDigest,
250
+ };
251
+
252
+ await humans.request(fixAddress); // idempotent: the same definition returns the same request
253
+ const answered = await humans.respond(fixAddress, {
254
+ commandId: 'fix-1', actor: { id: 'support-7' }, value: { line1: '1 High St', postcode: 'AB1 2CD' },
255
+ });
256
+ console.log(answered.status, answered.response?.value);
257
+ ```
258
+
259
+ `inspect(definition)` returns the current state (`waiting`, `answered`, `cancelled` or `timed_out`), `cancel(id)` closes
260
+ a request, and `sweepDeadlines()` expires overdue ones; call it on a schedule. A stream holds at most 128 requests,
261
+ and each request or answer is at most 3.5 KiB.
262
+
263
+ ## Good to know
264
+
265
+ - Approvals are attributed to whatever `id` your verifier returns. If every operator token maps to one service
266
+ identity, every approval is attributed to that identity; put your identity provider in front for per-person records.
267
+ - A waiting approval or human request keeps the run `waiting`. The worker wakes it when an approval lapses or a deadline
268
+ passes, and `nextWakeAtMs` tells you when that is.
269
+ - In production, approve and respond through the fleet runtime (or the operator API), so the worker's index sees the
270
+ change at once.
271
+
272
+ ## Related
273
+
274
+ - [Durable workflows](durable-workflows.md)
275
+ - [Operating workflows](workflow-operations.md)
276
+ - [Operations commands](../cli/operations.md)
277
+ - [React](react.md)
278
+ - [Operator console](operator-console.md)