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,192 @@
1
+ ---
2
+ title: "Create a project"
3
+ description: "Create a Mayura project from a starter or a template with mayura init, interactively or with flags, then validate and inspect it."
4
+ ---
5
+
6
+ `mayura init` creates a new project. You choose between two kinds of starting point:
7
+
8
+ - A **starter** is a complete application you can run, test and ship: configuration read from the environment,
9
+ tests and CI. Four are servers, with a worker, a Dockerfile and a compose file; `cli-agent` is a command-line
10
+ assistant. Start here for a real project.
11
+ - A **template** is one small file that shows one feature, with a `package.json` and `tsconfig.json` around it. Start
12
+ here to learn a single idea.
13
+
14
+ Both run offline out of the box: no API key and no network.
15
+
16
+ ```bash
17
+ npx mayura init
18
+ ```
19
+
20
+ ## The interactive wizard
21
+
22
+ Run `mayura init` with no options in a terminal and it asks, in order:
23
+
24
+ 1. **Start from**: a starter or a template.
25
+ 2. **Which one**, with a one-line summary of each.
26
+ 3. **Which model provider** (starters only). Templates use scripted test models and need no provider.
27
+ 4. **Where should it go?** The default is `./<name>`.
28
+
29
+ It then shows the plan: how many files it will create, and any existing files it would replace. Replacing files
30
+ needs an explicit yes, and the answer defaults to no. After it writes the files it prints the next steps:
31
+
32
+ ```text
33
+ cd refunds
34
+ npm install
35
+ npm run dev
36
+ ```
37
+
38
+ For a template the next steps are `npm install`, `npm run build` and `npm start`. Press Ctrl+C at any question to
39
+ cancel; nothing is written, and the command exits with code 1.
40
+
41
+ The wizard needs a terminal on both input and output. With `--json`, or when input or output is piped, use the flags
42
+ below instead.
43
+
44
+ ### Choosing a model provider
45
+
46
+ For a starter, the wizard offers:
47
+
48
+ | Choice | What it asks for |
49
+ |---|---|
50
+ | Offline (the default) | Nothing. The starter uses rule-based stand-in models. |
51
+ | OpenAI, Anthropic | Model (Anthropic defaults to `claude-sonnet-5`) and API key |
52
+ | Groq, Google Gemini, Mistral, DeepSeek, xAI, OpenRouter, Together, Fireworks | Model and API key. These use the provider's OpenAI-compatible chat-completions endpoint. DeepSeek is set up with its beta endpoint, JSON mode and strict tool calls (`MAYURA_MODEL_OUTPUT=json_object`, `MAYURA_MODEL_STRICT_TOOLS=true`), and its model defaults to `deepseek-flash`. |
53
+ | Cloudflare AI Gateway | Account ID, gateway name, the gateway token (for an authenticated gateway, saved as `MAYURA_MODEL_GATEWAY_TOKEN`), then which API to use through it. **Unified (OpenAI-compatible)**: any provider, with a `provider/model` name such as `deepseek/deepseek-flash`; a `deepseek/` model gets DeepSeek's settings, and an `openai/` model sends its output limit as `max_completion_tokens` (`MAYURA_MODEL_TOKEN_LIMIT_FIELD`). **OpenAI Responses API** or **Anthropic Messages API**: that provider's own API and Mayura's adapter for it, with the gateway's endpoint saved as `MAYURA_MODEL_ENDPOINT` and `MAYURA_MODEL_PROVIDER` set to `openai` or `anthropic`. In every case the provider's key is optional when the gateway stores it. |
54
+ | Azure OpenAI | Resource name, deployment name, API version, model and API key |
55
+ | Another OpenAI-compatible provider | An HTTPS URL ending in `/chat/completions`, a short id for the provider, model and API key |
56
+
57
+ For every real provider it also asks for your prices (dollars per million input and output tokens, from the
58
+ provider's pricing page) and two spending caps: the most one model call may cost (default $0.05) and the most one
59
+ agent run may cost (default $0.50). Mayura needs these because it accounts for every call's cost before making it;
60
+ see [Costs and budgets](../concepts/costs-and-budgets.md).
61
+
62
+ The API key is typed masked. The wizard writes these settings to a `.env` file in the new project, readable only by
63
+ you, and never prints the key or puts it in the plan:
64
+
65
+ ```text
66
+ MAYURA_MODEL_PROVIDER=anthropic
67
+ ANTHROPIC_API_KEY=<your key>
68
+ MAYURA_MODEL=claude-sonnet-5
69
+ MAYURA_MODEL_INPUT_MICROS_PER_MILLION_TOKENS=3000000
70
+ MAYURA_MODEL_OUTPUT_MICROS_PER_MILLION_TOKENS=15000000
71
+ MAYURA_MODEL_MAX_CALL_COST_MICROS=50000
72
+ MAYURA_MAX_RUN_COST_MICROS=500000
73
+ ```
74
+
75
+ OpenAI uses `OPENAI_API_KEY`. Compatible providers use `MAYURA_MODEL_API_KEY` plus `MAYURA_MODEL_PROVIDER_ID`,
76
+ `MAYURA_MODEL_ENDPOINT` and `MAYURA_MODEL_AUTH`. The starters' `.gitignore` excludes `.env`, and `mayura dev` loads it.
77
+ If the directory already has a `.env`, the wizard leaves it untouched and tells you to add the settings yourself (each
78
+ starter's `.env.example` lists them). You can switch providers later by editing `.env`.
79
+
80
+ ## Non-interactive: plan, then apply
81
+
82
+ With flags, `init` is plan-first. Without `--apply` it writes nothing and prints what it would do:
83
+
84
+ ```bash
85
+ mayura init --starter approval-workflow --directory ./refunds
86
+ mayura init --starter approval-workflow --directory ./refunds --apply
87
+ ```
88
+
89
+ | Option | Meaning |
90
+ |---|---|
91
+ | `--starter <name>` or `--template <name>` | What to create. Give exactly one. |
92
+ | `--directory <dir>` | Where to create it. Required. A relative path is resolved from the current directory. |
93
+ | `--apply` | Write the files. |
94
+ | `--confirm <digest>` | Allow replacing existing files. Only with `--apply`. |
95
+
96
+ The plan lists every file with its operation (`create`, `replace` or `unchanged`) and a SHA-256 digest of its
97
+ content. For a file it would replace, the JSON plan also includes a short text diff. The whole plan has one `digest`.
98
+
99
+ If the plan replaces any existing file, `--apply` alone is refused. Review the replacements, then run the command again
100
+ with the digest the plan printed:
101
+
102
+ ```bash
103
+ mayura init --template basic-agent --directory ./my-agent --apply --confirm <plan digest>
104
+ ```
105
+
106
+ The digest covers the target directory and the exact before and after content of every file, so it only works for the
107
+ plan you reviewed. If any target file changes between planning and writing, nothing is written. The target directory
108
+ must not be, or pass through, a symbolic link.
109
+
110
+ The project name comes from the directory's last segment, lower-cased (for example `./Refunds` becomes `refunds`).
111
+ The generated `package.json` pins `mayura` to the CLI's exact version.
112
+
113
+ Every new project also gets an `AGENTS.md`, with a `CLAUDE.md` that points to it. It tells AI coding assistants to
114
+ read the documentation shipped inside the installed `mayura` package, so they follow the API of the version you
115
+ actually have.
116
+
117
+ ## Starters
118
+
119
+ `mayura starters` lists them. Each one runs offline with `npm run dev` and `npm test`, and ends its README with what
120
+ it does not do. The server starters use SQLite locally and PostgreSQL when `DATABASE_URL` is set.
121
+
122
+ | Starter | What it is |
123
+ |---|---|
124
+ | `approval-workflow` | Refund approvals. An intake agent opens a durable workflow that checks policy, waits for an operator to approve the exact payment in the operator console, issues it and notifies the customer. Includes a reviewed migration of in-flight runs from workflow v1 to v2. |
125
+ | `support-agent` | Customer support chat with a React UI and streamed replies. Order tools act only for the signed-in customer, memory is kept per customer, card numbers, emails and phone numbers are redacted, and opening a return starts a durable follow-up workflow. |
126
+ | `research-team` | Multi-agent research as one durable workflow: a planner, up to four parallel researchers over a source library and a writer whose citations are checked, under one shared budget. The report is stored as a content-addressed artifact, with optional OpenTelemetry traces. |
127
+ | `event-automation` | Signed webhooks start durable workflow runs in which a triage agent acts on a ticket tracker through MCP tools under explicit permissions. Forged, stale and replayed deliveries start nothing, and assigning an urgent ticket waits for operator approval. |
128
+ | `cli-agent` | A command-line assistant: `assistant chat`, or one request such as `assistant list files in src`, about the folder you run it in. File tools stay inside that folder and never open `.env` files, you confirm every write, skills load from `skills/`, and replies stream. `npm run dev` starts the chat. |
129
+
130
+ Browse the source at
131
+ [packages/cli/starters](https://github.com/KartikeyAI/mayura/blob/main/packages/cli/starters).
132
+
133
+ ## Templates
134
+
135
+ `mayura templates` lists them. Each creates `src/index.ts`, `package.json`, `tsconfig.json`, `README.md` and
136
+ `mayura.project.json`. They use scripted test models, so they run without a key.
137
+
138
+ | Template | What it shows | Extra packages |
139
+ |---|---|---|
140
+ | `typed-tool-runner` | An agent calling a typed tool | none |
141
+ | `basic-agent` | The smallest agent with a structured answer | none |
142
+ | `durable-approval` | A durable workflow step that waits for human approval, on SQLite | `better-sqlite3` |
143
+ | `parallel-research` | Two child agents run in parallel and joined | none |
144
+ | `native-memory` | Scoped memory with provenance, correction and deletion | `better-sqlite3` |
145
+ | `guarded-streaming-app` | An authenticated local server, guarded output and the browser client | none |
146
+ | `code-mode-workflow` | An approval-gated durable Code Mode workflow in the QuickJS sandbox | `better-sqlite3`, `quickjs-emscripten-core`, `@jitl/quickjs-wasmfile-release-sync` |
147
+ | `capability-policy` | A tool that needs an explicit permission, granted and denied | none |
148
+
149
+ Browse the source at
150
+ [packages/cli/templates](https://github.com/KartikeyAI/mayura/blob/main/packages/cli/templates).
151
+
152
+ ## mayura.project.json, validate and inspect
153
+
154
+ Every project has a `mayura.project.json`: a plain JSON catalog of its agents, workflows and tools. The CLI reads it
155
+ without importing any of your code.
156
+
157
+ ```json
158
+ {
159
+ "format": "mayura.project.v1",
160
+ "name": "approval-workflow",
161
+ "template": "approval-workflow",
162
+ "definitions": [
163
+ { "kind": "agent", "id": "refunds.intake", "version": "1", "source": "src/intake.ts" },
164
+ { "kind": "workflow", "id": "refunds.approval", "version": "2", "source": "src/workflow.ts" }
165
+ ],
166
+ "tools": [
167
+ { "id": "refunds.issue", "version": "1", "effects": "write", "capabilities": ["payments:refund"] }
168
+ ]
169
+ }
170
+ ```
171
+
172
+ ```bash
173
+ mayura validate --file ./refunds/mayura.project.json
174
+ mayura inspect --file ./refunds/mayura.project.json
175
+ ```
176
+
177
+ `validate` checks the file's shape and prints the project name. `inspect` lists its definitions and tools with their
178
+ effects and capabilities. The rules are strict: exactly these keys, a lower-case `name`, `template` set to a known
179
+ starter or template name, `source` paths under `src/` ending in `.ts`, and no duplicate definition.
180
+
181
+ ## Good to know
182
+
183
+ - The catalog is descriptive. Nothing checks it against your code, so update it when you add an agent, workflow or
184
+ tool.
185
+ - `init` never runs `npm install` for you.
186
+
187
+ ## Related
188
+
189
+ - [CLI overview](overview.md)
190
+ - [Develop with mayura dev](dev.md)
191
+ - [Model providers](../guides/model-providers.md)
192
+ - [Quickstart](../quickstart.md)
@@ -0,0 +1,235 @@
1
+ ---
2
+ title: "Operate a server"
3
+ description: "Inspect and control a running Mayura server from the CLI: health, tools, runs, human requests, workflows and the fleet."
4
+ ---
5
+
6
+ The operational commands talk to a running Mayura server over its authenticated HTTP API. Use them to check health,
7
+ follow and cancel runs, answer human requests, approve, pause, resume, signal or cancel durable workflows, and hold
8
+ the whole workflow fleet during an incident. They are the command-line counterpart of the
9
+ [operator console](../guides/operator-console.md), and they work well in scripts because they print JSON when piped.
10
+
11
+ ```bash
12
+ printf '%s' "$OPERATOR_TOKEN" | mayura server-health --url https://agents.example.com --token-stdin
13
+ ```
14
+
15
+ ## The token and the URL
16
+
17
+ Every operational command needs two options:
18
+
19
+ - `--url <origin>`: the server's origin, such as `https://agents.example.com`. It must be HTTPS. Plain HTTP is
20
+ allowed only for `localhost`, `127.0.0.1` and `[::1]`. Give the origin only: no path, query or credentials.
21
+ - `--token-stdin`: read the bearer token from standard input.
22
+
23
+ The token is accepted **only** through a pipe. There is no token option, no environment variable and no prompt, so
24
+ the token never appears in your shell history, the process list or logs. If stdin is a terminal the command refuses to
25
+ run. A trailing newline is removed; the token must be printable ASCII without spaces, at most 8192 characters.
26
+
27
+ Pipe it from wherever you keep it, for example a secret manager:
28
+
29
+ ```bash
30
+ my-secret-tool read mayura/operator-token | mayura workflow-list --url https://agents.example.com --token-stdin
31
+ ```
32
+
33
+ The server decides what the token may do. Your application's `authenticate` callback turns it into an identity with a
34
+ set of capabilities, and each command needs one:
35
+
36
+ | Commands | Capability |
37
+ |---|---|
38
+ | `server-health`, `server-tools` | `operations:read` |
39
+ | `run-get`, `run-wait` | `runs:read` |
40
+ | `run-cancel` | `runs:cancel` |
41
+ | `human-list`, `human-get` | `humans:read` |
42
+ | `human-respond` | `humans:respond` |
43
+ | `workflow-list`, `workflow-get`, `fleet-get` | `workflows:read` |
44
+ | `workflow-approve`, `workflow-cancel`, `workflow-pause`, `workflow-resume`, `workflow-signal` | `workflows:control` |
45
+ | `fleet-hold`, `fleet-release`, `fleet-sweep` | `workflows:fleet` |
46
+
47
+ See [Server and client](../guides/server-and-client.md) for setting up authentication.
48
+
49
+ ## How requests behave
50
+
51
+ - Each command sends its request **once**. Nothing is retried automatically, and redirects are refused.
52
+ - A request times out after 10 seconds.
53
+ - Responses are checked strictly. Output never includes a run's output or error payload, approval data or a signal
54
+ value.
55
+ - A refused request reports a stable `code`, the HTTP `status` and the server's own `serverCode` with its message, for
56
+ example:
57
+
58
+ ```json
59
+ { "status": "failed", "error": { "code": "PERMISSION_DENIED", "message": "The operational server refused the request (HTTP 403 CAPABILITY_REQUIRED): The access token lacks the capability this request needs (see capability).", "status": 403, "serverCode": "CAPABILITY_REQUIRED", "capability": "workflows:read" } }
60
+ ```
61
+
62
+ `serverCode` is one of the codes in [Server and client](../guides/server-and-client.md#errors), such as
63
+ `RUN_NOT_FOUND`, `AUTH_EXPIRED`, `WORKFLOW_CONFLICT` (with `currentRevision` when the token may read the run) or
64
+ `RUN_LIMIT` (with `retryAfterMs`). It is `null` when the answer did not come from Mayura, for example a proxy's error
65
+ page. Only a well-formed code and a short printable message are shown; nothing else from the answer is printed.
66
+ - The stable `code` is `PERMISSION_DENIED` (401, 403, or a redirect), `NOT_FOUND` (404, 410), `CONFLICT` (409, 412),
67
+ `OUTCOME_UNKNOWN` (`SUBMISSION_OUTCOME_UNKNOWN`), `LIMIT_EXCEEDED` (413, 429), `INVALID_INPUT` (400, 415), `TIMEOUT`
68
+ (408, or no answer within 10 seconds), and `TOOL_FAILED` when the server could not be reached or failed otherwise.
69
+ `INVALID_OUTPUT` means the server's reply was not what the CLI expected.
70
+
71
+ ## Server health and tools
72
+
73
+ ```bash
74
+ printf '%s' "$TOKEN" | mayura server-health --url https://agents.example.com --token-stdin
75
+ printf '%s' "$TOKEN" | mayura server-tools --url https://agents.example.com --token-stdin --limit 50
76
+ ```
77
+
78
+ `server-health` reports `ready` or `degraded` and the status of each health check the server defines. A degraded
79
+ server is a normal result, not an error.
80
+
81
+ `server-tools` lists the tools of the agents your token can see: id, version, owning agent, effects, maximum cost
82
+ and timeout. It never shows descriptions, schemas or handlers.
83
+
84
+ ## Runs
85
+
86
+ These commands control the server's ephemeral agent runs. Run ids are UUIDs.
87
+
88
+ ```bash
89
+ printf '%s' "$TOKEN" | mayura run-get --url https://agents.example.com --token-stdin --id <run id>
90
+ printf '%s' "$TOKEN" | mayura run-wait --url https://agents.example.com --token-stdin --id <run id> --wait-ms 120000
91
+ printf '%s' "$TOKEN" | mayura run-cancel --url https://agents.example.com --token-stdin --id <run id>
92
+ ```
93
+
94
+ `run-get` shows the run's status, its spend (`spentMicros`, `reservedMicros`) and number of model calls, and a
95
+ receipt for each tool call: whether it executed (`not_started`, `succeeded`, `failed` or `unknown`) and whether its
96
+ output was released.
97
+
98
+ `run-wait` polls until the run finishes. `--poll-ms` sets the interval (250 to 10000, default 1000) and `--wait-ms`
99
+ the total wait (up to 300000, default 60000). Any failed read ends the wait.
100
+
101
+ `run-cancel` asks the server to cancel the run. If the acknowledgement is lost, the command fails rather than
102
+ retrying; check with `run-get`.
103
+
104
+ ## Human requests
105
+
106
+ When an agent asks a person for information, the server lists the request until someone answers.
107
+
108
+ ```bash
109
+ printf '%s' "$TOKEN" | mayura human-list --url https://agents.example.com --token-stdin --limit 20
110
+ printf '%s' "$TOKEN" | mayura human-get --url https://agents.example.com --token-stdin --id <request id>
111
+ printf '%s' "$TOKEN" | mayura human-respond --url https://agents.example.com --token-stdin --id <request id> --digest <request digest> --command-id answer-1 --response-file answer.json
112
+ ```
113
+
114
+ `human-get` prints the prompt, the request `digest` and its schema. `human-respond` sends the JSON in
115
+ `--response-file` (a regular file of at most 1 MiB) as the answer. The `--digest` binds your answer to exactly the
116
+ request you read, so a request that changed in the meantime is refused. `--command-id` is an id you choose for this
117
+ answer. The command prints the updated request, never your answer. See
118
+ [Approvals and human input](../guides/approvals-and-human-input.md).
119
+
120
+ ## Workflows
121
+
122
+ Durable workflow runs are identified by a 64-character hex id.
123
+
124
+ ```bash
125
+ printf '%s' "$TOKEN" | mayura workflow-list --url https://agents.example.com --token-stdin
126
+ printf '%s' "$TOKEN" | mayura workflow-list --url https://agents.example.com --token-stdin --settled
127
+ printf '%s' "$TOKEN" | mayura workflow-get --url https://agents.example.com --token-stdin --id <workflow run id>
128
+ ```
129
+
130
+ `workflow-list` shows active runs (running, waiting or paused). With `--settled` it shows finished runs instead, with
131
+ the time each one settled. `workflow-get` shows one run: its definition and version, status, `revision` and the
132
+ status of every step.
133
+
134
+ ### Revision-bound commands
135
+
136
+ Every command that changes a workflow run takes two extra options:
137
+
138
+ - `--revision <n>`: the run's revision from `workflow-get` or `workflow-list`. If the run has changed since you read
139
+ it, the server refuses the command with `CONFLICT` (`serverCode` `WORKFLOW_CONFLICT`). Read the run again and decide
140
+ again.
141
+ - `--command-id <id>`: an id you choose for this action, such as `pause-incident-42`. Servers built with Mayura's
142
+ workflow operator transports record command ids, so sending the same command again with the same id does not
143
+ apply it twice. Reuse the id when you retry after an unclear failure; use a new id for a new action.
144
+
145
+ ```bash
146
+ printf '%s' "$TOKEN" | mayura workflow-pause --url https://agents.example.com --token-stdin --id <workflow run id> --revision 7 --command-id pause-1
147
+ printf '%s' "$TOKEN" | mayura workflow-resume --url https://agents.example.com --token-stdin --id <workflow run id> --revision 8 --command-id resume-1
148
+ printf '%s' "$TOKEN" | mayura workflow-cancel --url https://agents.example.com --token-stdin --id <workflow run id> --revision 8 --command-id cancel-1
149
+ ```
150
+
151
+ - `workflow-pause` stops the run at the next safe point. It does not interrupt a tool call already in progress.
152
+ - `workflow-resume` continues a paused or stalled run from its stored state. It cannot skip a step that is waiting for
153
+ approval, a signal, a person or a timer.
154
+ - `workflow-cancel` cancels the run.
155
+
156
+ ### Approving a step
157
+
158
+ A tool step marked for approval waits until someone approves its exact call:
159
+
160
+ ```bash
161
+ printf '%s' "$TOKEN" | mayura workflow-approve --url https://agents.example.com --token-stdin --id <workflow run id> --revision 3 --command-id approve-1 --node issue --digest <approval digest>
162
+ ```
163
+
164
+ `--node` is the waiting step's id and `--digest` is its approval digest. For a step inside a child workflow, add
165
+ `--child-id <child run id>`. The CLI does not display approval digests: read the digest, and the exact tool call it
166
+ approves, in the operator console or with `client.workflow(id)` from `mayura/client`.
167
+
168
+ ### Sending a signal
169
+
170
+ ```bash
171
+ printf '%s' "$TOKEN" | mayura workflow-signal --url https://agents.example.com --token-stdin --id <workflow run id> --revision 4 --command-id signal-1 --signal-id payment-7 --signal-name payment.received --value-file signal.json
172
+ ```
173
+
174
+ `--signal-name` is the name the workflow waits for, `--signal-id` a stable id for this signal, and `--value-file` a
175
+ JSON file of at most 4096 bytes, checked against the signal step's payload schema. See
176
+ [Durable workflows](../guides/durable-workflows.md#signals).
177
+
178
+ ## The workflow fleet
179
+
180
+ A fleet hold stops workers from starting new workflow work across your scope, for example during an incident or a
181
+ risky deploy. Holding and releasing are idempotent.
182
+
183
+ ```bash
184
+ printf '%s' "$TOKEN" | mayura fleet-get --url https://agents.example.com --token-stdin
185
+ printf '%s' "$TOKEN" | mayura fleet-hold --url https://agents.example.com --token-stdin
186
+ printf '%s' "$TOKEN" | mayura fleet-release --url https://agents.example.com --token-stdin
187
+ ```
188
+
189
+ `fleet-sweep` pauses (or later resumes) every run in the fleet, one page at a time:
190
+
191
+ ```bash
192
+ printf '%s' "$TOKEN" | mayura fleet-sweep --url https://agents.example.com --token-stdin --phase pause --json > sweep.json
193
+ ```
194
+
195
+ | Option | Meaning |
196
+ |---|---|
197
+ | `--phase pause` or `--phase resume` | What to do to each run. Required. |
198
+ | `--limit <n>` | Runs per page, 1 to 128. Default 32. |
199
+ | `--max-pages <n>` | Pages to process in this invocation, 1 to 256. Default 32. |
200
+ | `--cursor-file <file>` | Continue a previous sweep from its saved `nextCursor`. |
201
+
202
+ The result counts each run's outcome, such as `paused`, `already_paused`, `terminal`, `busy` or `failed`. If the
203
+ sweep reached `--max-pages` before finishing, its status is `incomplete` and the JSON includes `nextCursor`. Save that
204
+ object to a file and continue with `--cursor-file`. See [Workflow operations](../guides/workflow-operations.md).
205
+
206
+ ## From TypeScript
207
+
208
+ Every operational command is also a function in `mayura/cli`, taking the same options and an explicit token callback:
209
+
210
+ ```ts
211
+ import { inspectWorkflows, pauseWorkflow } from 'mayura/cli';
212
+
213
+ const server = { baseUrl: 'https://agents.example.com', token: () => getOperatorToken() };
214
+ const page = await inspectWorkflows(server, { limit: 20 });
215
+ for (const run of page.items) {
216
+ if (run.status === 'running') {
217
+ await pauseWorkflow(server, { id: run.runId, revision: run.revision, commandId: `pause-${run.runId}` });
218
+ }
219
+ }
220
+ ```
221
+
222
+ ## Good to know
223
+
224
+ - Pagination is explicit. List commands return one page and a `next` value; pass it back with `--after` for the next
225
+ page.
226
+ - The CLI cannot submit runs, change which scope or agents a token sees, or migrate in-flight workflows. Use the
227
+ client or the operator console for those.
228
+
229
+ ## Related
230
+
231
+ - [Operator console](../guides/operator-console.md)
232
+ - [Workflow operations](../guides/workflow-operations.md)
233
+ - [Server and client](../guides/server-and-client.md)
234
+ - [Approvals and human input](../guides/approvals-and-human-input.md)
235
+ - [CLI overview](overview.md)
@@ -0,0 +1,129 @@
1
+ ---
2
+ title: "CLI overview"
3
+ description: "Install and run the mayura command: its commands, readable and JSON output, help, version, exit codes and errors."
4
+ ---
5
+
6
+ The `mayura` command ships inside the `mayura` npm package. You use it to create projects from starters and
7
+ templates, to run your application during development and in production, and to operate a running Mayura server
8
+ from a terminal or a script.
9
+
10
+ ```bash
11
+ npx mayura init
12
+ ```
13
+
14
+ In a terminal, `mayura init` with no options opens a short wizard. Everything else is driven by flags, so the same
15
+ commands work in scripts and CI.
16
+
17
+ ## Installing and running
18
+
19
+ You do not need to install anything globally. There are two common ways to run the CLI:
20
+
21
+ - **Before you have a project**, run it with `npx`, which fetches the `mayura` package on demand:
22
+
23
+ ```bash
24
+ npx mayura starters
25
+ ```
26
+
27
+ - **Inside a project**, add `mayura` as a dependency. Every project created by `mayura init` already has it, pinned
28
+ to the exact version of the CLI that created it. Run the command through `npx` or from your `package.json` scripts:
29
+
30
+ ```bash
31
+ npm install mayura
32
+ npx mayura --version
33
+ ```
34
+
35
+ The starters' scripts call it this way, for example `"dev": "mayura dev"` and
36
+ `"serve": "mayura serve --app dist/src/app.js"`.
37
+
38
+ The CLI needs Node.js 22 (22.12 or later) or 24 (24.14.1 or later). See [Support](../project/support.md).
39
+
40
+ ## Commands
41
+
42
+ `mayura --help` groups the commands like this:
43
+
44
+ | Group | Commands | Page |
45
+ |---|---|---|
46
+ | Create | `init`, `starters`, `templates`, `validate`, `inspect` | [Create a project](init.md) |
47
+ | Run an application | `dev` | [Develop with mayura dev](dev.md) |
48
+ | Run an application | `serve`, `worker`, `migrate` | [Serve, worker and migrate](run.md) |
49
+ | Operate a server | `server-health`, `server-tools`, `run-get`, `run-wait`, `run-cancel`, `human-list`, `human-get`, `human-respond`, `workflow-list`, `workflow-get`, `workflow-approve`, `workflow-cancel`, `workflow-pause`, `workflow-resume`, `workflow-signal`, `fleet-get`, `fleet-hold`, `fleet-release`, `fleet-sweep` | [Operate a server](operations.md) |
50
+
51
+ Options take the form `--name value`, or just `--name` for switches such as `--apply`. An unknown option, or the
52
+ same option given twice, is an error.
53
+
54
+ ## Help and version
55
+
56
+ ```bash
57
+ mayura --help
58
+ mayura init --help
59
+ mayura --version
60
+ ```
61
+
62
+ `--help` (or `-h`) shows the command list and wins anywhere on the line, so `mayura init --help` prints help instead
63
+ of an argument error. `mayura help` does the same. Running `mayura` with no command in a terminal also prints help.
64
+
65
+ `--version` (or `-v`, or `mayura version`) prints the version as plain text, so scripts can read it. Add `--json` to
66
+ get it as a JSON document instead.
67
+
68
+ ## Readable and JSON output
69
+
70
+ The CLI picks its output format from where the output goes:
71
+
72
+ - **In a terminal**, results are readable: coloured statuses (`✔ succeeded`, `● waiting`, `✖ failed`), wrapped
73
+ descriptions, and the next command or flag to use.
74
+ - **When output is piped or redirected**, every command prints one JSON document instead. Scripts and CI can parse it
75
+ directly.
76
+ - **With `--json`**, the CLI always prints JSON, even in a terminal.
77
+
78
+ ```bash
79
+ mayura templates --json
80
+ mayura starters | jq -r '.starters[].name'
81
+ ```
82
+
83
+ Every JSON document has a `status` field. Most commands report `succeeded`; `init` without `--apply` reports
84
+ `planned`, `migrate` reports `migrated`, `serve`, `worker` and `dev` report `stopped` when they exit, and a
85
+ `fleet-sweep` that did not finish reports `incomplete`.
86
+
87
+ Colour follows the usual conventions: it is off when `NO_COLOR` is set to any non-empty value or `TERM=dumb`, and on
88
+ when `FORCE_COLOR` is set to anything other than `0`. Colour is never written into JSON output.
89
+
90
+ ## Exit codes and errors
91
+
92
+ | Exit code | Meaning |
93
+ |---|---|
94
+ | `0` | The command succeeded. This includes `init` printing a plan, and `fleet-sweep` stopping with `incomplete`. |
95
+ | `1` | The command failed, or you cancelled the `init` wizard. |
96
+
97
+ Errors go to stderr. In a terminal they read like this:
98
+
99
+ ```text
100
+ ✖ Unknown template; run mayura templates. (INVALID_INPUT)
101
+ ```
102
+
103
+ When stderr is not a terminal, or with `--json`, the error is a JSON document:
104
+
105
+ ```text
106
+ {"status":"failed","error":{"code":"INVALID_INPUT","message":"Unknown command. Run mayura --help to see the commands."}}
107
+ ```
108
+
109
+ The `code` is one of Mayura's error codes (see [Outcomes](../concepts/outcomes.md)): `INVALID_INPUT` for a usage
110
+ problem the CLI found, `INVALID_CONFIG` for a bad file or setting, `PERMISSION_DENIED`, `NOT_FOUND`, `CONFLICT`,
111
+ `TIMEOUT` and so on for server commands. Messages are fixed, safe text. The CLI never echoes an unknown command or
112
+ argument back, because it might be a credential pasted in the wrong place.
113
+
114
+ ## Good to know
115
+
116
+ - The CLI never prompts for a server token. Authenticated commands read it only from stdin (`--token-stdin`); see
117
+ [Operate a server](operations.md).
118
+ - `serve`, `worker` and `migrate` import only the one module you name with `--app`. Listing and inspecting a project
119
+ never runs your code.
120
+ - Everything the commands do is also available as functions from `mayura/cli`, for example `planProject`,
121
+ `inspectWorkflows` and `defineMayuraApplication`. See [Entry points](../reference/entry-points.md).
122
+
123
+ ## Related
124
+
125
+ - [Create a project](init.md)
126
+ - [Develop with mayura dev](dev.md)
127
+ - [Serve, worker and migrate](run.md)
128
+ - [Operate a server](operations.md)
129
+ - [Quickstart](../quickstart.md)