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
@@ -1 +1 @@
1
- {"version":3,"file":"output.js","sourceRoot":"","sources":["../src/output.ts"],"names":[],"mappings":"AAAA,oHAAoH;AACpH,qHAAqH;AACrH,mEAAmE;AAEnE,6GAA6G;AAC7G,MAAM,UAAU,aAAa,CAAC,MAAoC,EAAE,GAAG,GAAsB,OAAO,CAAC,GAAG;IACtG,IAAI,GAAG,CAAC,UAAU,CAAC,KAAK,SAAS,IAAI,GAAG,CAAC,UAAU,CAAC,KAAK,EAA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CAAC;QAChF,GAAG,CAAC,gCAAgC,EAAE,EAAE,CAAC,EAAE,GAAG,CAAC,mEAAmE,EAAE,EAAE,CAAC;QACvH,GAAG,CAAC,mDAAmD,EAAE,EAAE,CAAC,EAAE,EAAE;QAChE,CAAC,CAAC,GAAG,CAAC,kFAAkF,CAAC;KAC1F,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC3C,CAAC","sourcesContent":["// Human-readable rendering for the terminal. The CLI prints this only when stdout is a terminal and `--json` is not\n// given; piped output stays the exact JSON documents scripts rely on. Nothing here prints credentials: results never\n// contain them, and tokens only ever arrive through --token-stdin.\n\n/** Colour only for a real terminal that has not opted out (NO_COLOR, TERM=dumb); FORCE_COLOR turns it on. */\nexport function colourEnabled(stream: { readonly isTTY?: boolean }, env: NodeJS.ProcessEnv = process.env): boolean {\n if (env['NO_COLOR'] !== undefined && env['NO_COLOR'] !== '') return false;\n if (env['FORCE_COLOR'] !== undefined && env['FORCE_COLOR'] !== '0') return true;\n return stream.isTTY === true && env['TERM'] !== 'dumb';\n}\n\nexport interface Paint {\n readonly bold: (text: string) => string; readonly dim: (text: string) => string; readonly red: (text: string) => string;\n readonly green: (text: string) => string; readonly yellow: (text: string) => string; readonly cyan: (text: string) => string;\n}\nexport function paint(enabled: boolean): Paint {\n const code = (open: number, close: number) => (text: string): string => enabled ? `\\u001b[${open}m${text}\\u001b[${close}m` : text;\n return Object.freeze({ bold: code(1, 22), dim: code(2, 22), red: code(31, 39), green: code(32, 39), yellow: code(33, 39), cyan: code(36, 39) });\n}\n\nconst good = new Set(['succeeded', 'ready', 'approved', 'answered', 'migrated', 'stopped', 'released', 'resumed', 'paused']);\nconst bad = new Set(['failed', 'blocked', 'outcome_unknown', 'unknown', 'unavailable', 'degraded', 'cancelled', 'timed_out']);\nconst waiting = new Set(['running', 'waiting', 'pending', 'dispatching', 'planned', 'incomplete']);\n/** A coloured status label, padded to `width` before colouring so columns line up. */\nfunction status(p: Paint, value: string, width = 0): string {\n const colour = good.has(value) ? p.green : bad.has(value) ? p.red : waiting.has(value) ? p.yellow : p.dim;\n const mark = good.has(value) ? '✔' : bad.has(value) ? '✖' : waiting.has(value) ? '●' : '○';\n const label = `${mark} ${value.replaceAll('_', ' ')}`;\n return colour(label) + ' '.repeat(Math.max(0, width - label.length));\n}\nconst time = (ms: number): string => new Date(ms).toISOString().replace('T', ' ').replace(/\\.\\d+Z$/u, ' UTC');\nconst micros = (value: number | string): string => `${value} µ$`;\nconst plural = (count: number, word: string): string => `${count} ${word}${count === 1 ? '' : 's'}`;\n/** Wrap at word boundaries for descriptions under a heading. */\nexport function wrap(text: string, width: number, indent: string): string {\n const lines: string[] = []; let line = '';\n for (const word of text.split(/\\s+/u)) {\n if (line && line.length + word.length + 1 > width) { lines.push(line); line = word; } else line = line ? `${line} ${word}` : word;\n }\n if (line) lines.push(line);\n return lines.map(item => `${indent}${item}`).join('\\n');\n}\nconst columns = (): number => Math.max(60, Math.min(process.stdout.columns ?? 100, 110));\n\ntype Result = Record<string, unknown>;\nconst record = (value: unknown): Result => (value !== null && typeof value === 'object' && !Array.isArray(value) ? value : {}) as Result;\nconst list = (value: unknown): Result[] => Array.isArray(value) ? value.map(record) : [];\nconst text = (value: unknown): string => typeof value === 'string' ? value : typeof value === 'number' ? String(value) : '';\n\n/** The next-steps block after a project is created. */\nexport function nextSteps(kind: 'starter' | 'template', directory: string): string[] {\n const cd = /\\s/u.test(directory) ? `cd \"${directory}\"` : `cd ${directory}`;\n return kind === 'starter' ? [cd, 'npm install', 'npm run dev'] : [cd, 'npm install', 'npm run build', 'npm start'];\n}\n\nfunction plan(p: Paint, result: Result, relative: (path: string) => string): string[] {\n const value = record(result['plan']); const changes = list(value['changes']); const applied = result['status'] === 'succeeded';\n const kind = typeof value['starter'] === 'string' ? 'starter' : 'template';\n const name = text(value['starter']) || text(value['template']); const directory = text(value['directory']);\n const count = (operation: string) => changes.filter(change => change['operation'] === operation).length;\n const created = count('create'); const replaced = count('replace'); const unchanged = count('unchanged');\n const out = [`${p.bold(applied ? 'Created' : 'Plan for')} the ${p.cyan(name)} ${kind} in ${p.bold(relative(directory))}`, ''];\n const shown = changes.filter(change => change['operation'] !== 'unchanged').slice(0, 30);\n for (const change of shown) {\n const marker = change['operation'] === 'replace' ? p.yellow('~ replace') : p.green('+ create ');\n out.push(` ${marker} ${text(change['path'])}`);\n }\n const hidden = created + replaced - shown.length; if (hidden > 0) out.push(p.dim(` … and ${hidden} more`));\n out.push('', ` ${[plural(created, 'file') + ' to create', replaced ? `${replaced} to replace` : '', unchanged ? `${unchanged} unchanged` : ''].filter(Boolean).join(', ')}`);\n if (applied) {\n out.push('', p.bold('Next steps'), ...nextSteps(kind, relative(directory)).map(step => ` ${p.cyan(step)}`));\n } else {\n out.push('', `Nothing is written yet. To create these files, run the same command with ${p.bold('--apply')}${replaced ? ` ${p.bold(`--confirm ${text(value['digest'])}`)}` : ''}.`);\n if (replaced) out.push(p.yellow(`Replacing existing files needs --confirm with this plan's digest, so review the ${plural(replaced, 'replacement')} above first.`));\n }\n return out;\n}\n\nfunction workflow(p: Paint, value: Result): string[] {\n const out = [`${p.bold(`${text(value['definitionId'])}@${text(value['definitionVersion'])}`)} ${status(p, text(value['status']))} ${p.dim(`revision ${text(value['revision'])}`)}`,\n p.dim(` ${text(value['runId'])}`), ''];\n for (const step of list(value['steps'])) {\n const approval = record(step['approval']);\n out.push(` ${status(p, text(step['status']), 26)} ${text(step['id'])} ${p.dim(text(step['kind']))}${step['childRunId'] ? p.dim(` → ${text(step['childRunId'])}`) : ''}`);\n if (approval['digest']) out.push(p.yellow(` needs approval: --node ${text(step['id'])} --digest ${text(approval['digest'])}`));\n }\n return out;\n}\n\n/** Render one command result for a person. Unknown shapes fall back to indented JSON, never to nothing. */\nexport function render(command: string, result: unknown, p: Paint, relative: (path: string) => string = path => path): string {\n const value = record(result); const out: string[] = [];\n if (command === 'templates' || command === 'starters') {\n const items = list(value[command]); const width = columns();\n out.push(p.bold(command === 'starters' ? 'Starters: complete projects with a server, worker, tests and docs' : 'Templates: small single-purpose examples'), '');\n for (const item of items) out.push(` ${p.cyan(text(item['name']))}`, wrap(text(item['description']), width - 6, ' '), '');\n out.push(`Create one with ${p.bold(`mayura init --${command === 'starters' ? 'starter' : 'template'} <name> --directory <dir>`)}, or run ${p.bold('mayura init')} to choose interactively.`);\n } else if (command === 'init') out.push(...plan(p, value, relative));\n else if (command === 'validate') out.push(`${p.green('✔')} ${p.bold(text(value['project']))} is a valid Mayura project ${p.dim(`(${text(value['template'])})`)}`);\n else if (command === 'inspect') {\n const project = record(value['project']);\n out.push(`${p.bold(text(project['name']))} ${p.dim(`(${text(project['template'])})`)}`, '');\n const definitions = list(project['definitions']); const tools = list(project['tools']);\n out.push(p.bold(`Definitions (${definitions.length})`));\n for (const item of definitions) out.push(` ${text(item['kind']).padEnd(9)} ${p.cyan(`${text(item['id'])}@${text(item['version'])}`)} ${p.dim(text(item['source']))}`);\n out.push('', p.bold(`Tools (${tools.length})`));\n for (const item of tools) {\n const capabilities = Array.isArray(item['capabilities']) ? (item['capabilities'] as string[]).join(', ') : '';\n out.push(` ${p.cyan(`${text(item['id'])}@${text(item['version'])}`)} effects: ${text(item['effects'])}${capabilities ? p.dim(` capabilities: ${capabilities}`) : ''}`);\n }\n } else if (command === 'server-health') {\n const health = record(value['health']); out.push(`Server ${status(p, text(health['status']))}`);\n for (const check of list(health['checks'])) out.push(` ${status(p, text(check['status']), 24)} ${text(check['id'])}`);\n } else if (command === 'server-tools') {\n const page = record(value['page']); const tools = list(page['tools']);\n out.push(p.bold(plural(tools.length, 'tool')), '');\n for (const tool of tools) {\n out.push(` ${p.cyan(`${text(tool['id'])}@${text(tool['version'])}`)} ${p.dim(`agent ${text(tool['agentId'])}@${text(tool['agentVersion'])}`)}`,\n ` effects: ${text(tool['effects'])}, cost up to ${micros(text(tool['costMicros']))}, timeout ${text(tool['timeoutMs'])} ms`);\n }\n if (page['next'] !== null && page['next'] !== undefined) out.push('', p.dim(`More: add --after ${text(page['next'])}`));\n } else if (command === 'human-list') {\n const page = record(value['page']); const items = list(page['items']);\n out.push(p.bold(plural(items.length, 'human request')), '');\n for (const item of items) out.push(` ${status(p, text(item['status']), 24)} ${p.cyan(text(item['id']))} ${p.dim(`${text(item['kind']).replaceAll('_', ' ')} · ${text(item['agentId'])}`)}`,\n wrap(text(item['prompt']).slice(0, 300), columns() - 8, ' '));\n if (page['next'] !== null && page['next'] !== undefined) out.push('', p.dim(`More: add --after ${text(page['next'])}`));\n } else if (command === 'human-get' || command === 'human-respond') {\n const item = record(value['request']);\n out.push(`${p.bold(text(item['id']))} ${status(p, text(item['status']))} ${p.dim(`${text(item['kind']).replaceAll('_', ' ')} · agent ${text(item['agentId'])}`)}`, '',\n wrap(text(item['prompt']), columns() - 4, ' '), '', p.dim(` digest ${text(item['digest'])}`), p.dim(` schema ${text(item['schemaId'])}`));\n if (typeof item['deadlineAtMs'] === 'number') out.push(p.dim(` deadline ${time(item['deadlineAtMs'])}`));\n } else if (command === 'run-get' || command === 'run-wait') {\n const run = record(value['run']); const budget = record(run['budget']);\n out.push(`${p.bold('Run')} ${text(run['id'])} ${status(p, text(run['status']))}`,\n ` spent ${micros(text(budget['spentMicros']))}, reserved ${micros(text(budget['reservedMicros']))}, ${plural(Number(budget['calls']), 'call')}`);\n const evidence = list(run['evidence']);\n if (evidence.length) out.push('', p.bold('Tool calls'));\n for (const entry of evidence) {\n const receipt = record(entry['receipt']);\n out.push(` ${status(p, text(receipt['execution']), 24)} ${text(receipt['toolId'])} ${p.dim(`output ${text(receipt['disclosure'])}`)}`);\n }\n } else if (command === 'run-cancel') out.push(`${p.green('✔')} Cancellation requested for run ${text(value['id'])}`);\n else if (command === 'workflow-list') {\n const page = record(value['page']); const items = list(page['items']);\n out.push(p.bold(plural(items.length, 'workflow run')), '');\n for (const item of items) {\n const settled = typeof item['settledAtMs'] === 'number' ? p.dim(` · settled ${time(item['settledAtMs'])}`) : '';\n out.push(` ${status(p, text(item['status']), 26)} ${p.cyan(`${text(item['definitionId'])}@${text(item['definitionVersion'])}`)} ${p.dim(`rev ${text(item['revision'])}`)}${settled}`,\n p.dim(` ${text(item['runId'])}`));\n }\n if (page['next'] !== null && page['next'] !== undefined) out.push('', p.dim(`More: add --after ${text(page['next'])}`));\n } else if (command.startsWith('workflow-')) out.push(...workflow(p, record(value['workflow'])));\n else if (command === 'fleet-get' || command === 'fleet-hold' || command === 'fleet-release') {\n const fleet = record(value['fleet']);\n out.push(fleet['held'] === true ? p.yellow('● The fleet is held: workers start no new work.') : p.green('✔ The fleet is running.'),\n p.dim(` generation ${text(fleet['generation'])}${typeof fleet['changedAtMs'] === 'number' ? `, changed ${time(fleet['changedAtMs'])}` : ''}`));\n } else if (command === 'fleet-sweep') {\n const outcomes = list(value['outcomes']); const counts = new Map<string, number>();\n for (const outcome of outcomes) counts.set(text(outcome['outcome']), (counts.get(text(outcome['outcome'])) ?? 0) + 1);\n out.push(`${p.bold(`Fleet ${text(value['phase'])} sweep`)} ${status(p, text(value['status']))} ${p.dim(plural(Number(value['pages']), 'page'))}`);\n for (const [outcome, count] of counts) out.push(` ${String(count).padStart(5)} ${outcome.replaceAll('_', ' ')}`);\n if (value['nextCursor']) out.push('', p.yellow('Not finished. Run with --json to save nextCursor to a file, then continue with --cursor-file.'));\n } else if (command === 'migrate') out.push(`${p.green('✔')} Storage migrated`);\n else if (command === 'serve' || command === 'worker' || command === 'dev') out.push(`${p.green('✔')} Stopped`);\n else out.push(JSON.stringify(result, null, 2));\n return out.join('\\n');\n}\n\n/** One line per lifecycle event while `serve` or `worker` runs in a terminal. */\nexport function renderLifecycle(event: { readonly event: string } & Record<string, unknown>, p: Paint): string {\n if (event.event === 'serving') return p.green('● Serving. Press Ctrl+C to stop.');\n if (event.event === 'worker-started') {\n const probe = record(event['probe']);\n return p.green(`● Worker started${probe['port'] !== undefined ? `, probes on ${text(probe['hostname'])}:${text(probe['port'])}` : ''}. Press Ctrl+C to stop.`);\n }\n if (event.event === 'stopping') return p.yellow('● Stopping… (press Ctrl+C again to force)');\n if (event.event === 'stopped') return `${p.green('✔ Stopped')}${event['drained'] === false ? p.yellow(` · ${text(event['interrupted'])} interrupted`) : ''}`;\n return JSON.stringify(event);\n}\n\nexport function renderError(error: { readonly code: string; readonly message: string }, p: Paint): string {\n return `${p.red(`✖ ${error.message}`)} ${p.dim(`(${error.code})`)}`;\n}\n\nexport function help(p: Paint): string {\n const row = (name: string, description: string): string => ` ${p.cyan(name.padEnd(30))} ${description}`;\n return [\n `${p.bold('mayura')} <command> [options]`, '',\n p.bold('Create'),\n row('init', 'create a project; with no options in a terminal, choose interactively'),\n row('init --starter <name> --directory <dir>', ''), row('init --template <name> --directory <dir>', 'show the plan; add --apply to write it'),\n row('starters', 'complete starter projects'), row('templates', 'small single-purpose templates'),\n row('validate --file <path>', 'check a mayura.project.json'), row('inspect --file <path>', 'list its agents, workflows and tools'), '',\n p.bold('Run an application'),\n row('dev', 'build, run and restart on changes; loads .env'),\n row('serve --app <module>', 'start its server'), row('worker --app <module>', 'start its worker'), row('migrate --app <module>', 'migrate its storage'), '',\n p.bold('Operate a server') + p.dim(' (pipe the token: … | mayura <command> --url <url> --token-stdin)'),\n row('server-health, server-tools', ''), row('run-get, run-wait, run-cancel', ''), row('human-list, human-get, human-respond', ''),\n row('workflow-list [--settled]', 'active runs, or finished and unresolved ones'),\n row('workflow-get, workflow-approve', ''), row('workflow-cancel, workflow-pause, workflow-resume, workflow-signal', ''),\n row('fleet-get, fleet-hold, fleet-release, fleet-sweep', ''), '',\n p.dim('Output is readable in a terminal and JSON when piped; --json always prints JSON.'),\n ].map(line => line.trimEnd()).join('\\n');\n}\n"]}
1
+ {"version":3,"file":"output.js","sourceRoot":"","sources":["../src/output.ts"],"names":[],"mappings":"AAAA,oHAAoH;AACpH,qHAAqH;AACrH,mEAAmE;AAEnE,6GAA6G;AAC7G,MAAM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6B,EAAE,EAAE,CAAC,EAAE,GAAG,CAAC,+BAA+B,EAAE,EAAE,CAAC,EAAE,GAAG,CAAC,sCAAsC,EAAE,EAAE,CAAC;QACjI,GAAG,CAAC,2BAA2B,EAAE,8CAA8C,CAAC;QAChF,GAAG,CAAC,gCAAgC,EAAE,EAAE,CAAC,EAAE,GAAG,CAAC,mEAAmE,EAAE,EAAE,CAAC;QACvH,GAAG,CAAC,mDAAmD,EAAE,EAAE,CAAC,EAAE,EAAE;QAChE,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC;QACjB,GAAG,CAAC,YAAY,EAAE,yCAAyC,CAAC,EAAE,GAAG,CAAC,eAAe,EAAE,mBAAmB,CAAC;QACvG,GAAG,CAAC,QAAQ,EAAE,uCAAuC,CAAC,EAAE,EAAE;QAC1D,CAAC,CAAC,GAAG,CAAC,kFAAkF,CAAC;KAC1F,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC3C,CAAC","sourcesContent":["// Human-readable rendering for the terminal. The CLI prints this only when stdout is a terminal and `--json` is not\n// given; piped output stays the exact JSON documents scripts rely on. Nothing here prints credentials: results never\n// contain them, and tokens only ever arrive through --token-stdin.\n\n/** Colour only for a real terminal that has not opted out (NO_COLOR, TERM=dumb); FORCE_COLOR turns it on. */\nexport function colourEnabled(stream: { readonly isTTY?: boolean }, env: NodeJS.ProcessEnv = process.env): boolean {\n if (env['NO_COLOR'] !== undefined && env['NO_COLOR'] !== '') return false;\n if (env['FORCE_COLOR'] !== undefined && env['FORCE_COLOR'] !== '0') return true;\n return stream.isTTY === true && env['TERM'] !== 'dumb';\n}\n\nexport interface Paint {\n readonly bold: (text: string) => string; readonly dim: (text: string) => string; readonly red: (text: string) => string;\n readonly green: (text: string) => string; readonly yellow: (text: string) => string; readonly cyan: (text: string) => string;\n}\nexport function paint(enabled: boolean): Paint {\n const code = (open: number, close: number) => (text: string): string => enabled ? `\\u001b[${open}m${text}\\u001b[${close}m` : text;\n return Object.freeze({ bold: code(1, 22), dim: code(2, 22), red: code(31, 39), green: code(32, 39), yellow: code(33, 39), cyan: code(36, 39) });\n}\n\nconst good = new Set(['succeeded', 'ready', 'approved', 'answered', 'migrated', 'stopped', 'released', 'resumed', 'paused']);\nconst bad = new Set(['failed', 'blocked', 'outcome_unknown', 'unknown', 'unavailable', 'degraded', 'cancelled', 'timed_out']);\nconst waiting = new Set(['running', 'waiting', 'pending', 'dispatching', 'planned', 'incomplete']);\n/** A coloured status label, padded to `width` before colouring so columns line up. */\nfunction status(p: Paint, value: string, width = 0): string {\n const colour = good.has(value) ? p.green : bad.has(value) ? p.red : waiting.has(value) ? p.yellow : p.dim;\n const mark = good.has(value) ? '✔' : bad.has(value) ? '✖' : waiting.has(value) ? '●' : '○';\n const label = `${mark} ${value.replaceAll('_', ' ')}`;\n return colour(label) + ' '.repeat(Math.max(0, width - label.length));\n}\nconst time = (ms: number): string => new Date(ms).toISOString().replace('T', ' ').replace(/\\.\\d+Z$/u, ' UTC');\nconst micros = (value: number | string): string => `${value} µ$`;\nconst plural = (count: number, word: string): string => `${count} ${word}${count === 1 ? '' : 's'}`;\n/** Wrap at word boundaries for descriptions under a heading. */\nexport function wrap(text: string, width: number, indent: string): string {\n const lines: string[] = []; let line = '';\n for (const word of text.split(/\\s+/u)) {\n if (line && line.length + word.length + 1 > width) { lines.push(line); line = word; } else line = line ? `${line} ${word}` : word;\n }\n if (line) lines.push(line);\n return lines.map(item => `${indent}${item}`).join('\\n');\n}\nconst columns = (): number => Math.max(60, Math.min(process.stdout.columns ?? 100, 110));\n\ntype Result = Record<string, unknown>;\nconst record = (value: unknown): Result => (value !== null && typeof value === 'object' && !Array.isArray(value) ? value : {}) as Result;\nconst list = (value: unknown): Result[] => Array.isArray(value) ? value.map(record) : [];\nconst text = (value: unknown): string => typeof value === 'string' ? value : typeof value === 'number' ? String(value) : '';\n\n/** The next-steps block after a project is created. */\nexport function nextSteps(kind: 'starter' | 'template', directory: string): string[] {\n const cd = /\\s/u.test(directory) ? `cd \"${directory}\"` : `cd ${directory}`;\n return kind === 'starter' ? [cd, 'npm install', 'npm run dev'] : [cd, 'npm install', 'npm run build', 'npm start'];\n}\n\nfunction plan(p: Paint, result: Result, relative: (path: string) => string): string[] {\n const value = record(result['plan']); const changes = list(value['changes']); const applied = result['status'] === 'succeeded';\n const kind = typeof value['starter'] === 'string' ? 'starter' : 'template';\n const name = text(value['starter']) || text(value['template']); const directory = text(value['directory']);\n const count = (operation: string) => changes.filter(change => change['operation'] === operation).length;\n const created = count('create'); const replaced = count('replace'); const unchanged = count('unchanged');\n const out = [`${p.bold(applied ? 'Created' : 'Plan for')} the ${p.cyan(name)} ${kind} in ${p.bold(relative(directory))}`, ''];\n const shown = changes.filter(change => change['operation'] !== 'unchanged').slice(0, 30);\n for (const change of shown) {\n const marker = change['operation'] === 'replace' ? p.yellow('~ replace') : p.green('+ create ');\n out.push(` ${marker} ${text(change['path'])}`);\n }\n const hidden = created + replaced - shown.length; if (hidden > 0) out.push(p.dim(` … and ${hidden} more`));\n out.push('', ` ${[plural(created, 'file') + ' to create', replaced ? `${replaced} to replace` : '', unchanged ? `${unchanged} unchanged` : ''].filter(Boolean).join(', ')}`);\n if (applied) {\n out.push('', p.bold('Next steps'), ...nextSteps(kind, relative(directory)).map(step => ` ${p.cyan(step)}`));\n } else {\n out.push('', `Nothing is written yet. To create these files, run the same command with ${p.bold('--apply')}${replaced ? ` ${p.bold(`--confirm ${text(value['digest'])}`)}` : ''}.`);\n if (replaced) out.push(p.yellow(`Replacing existing files needs --confirm with this plan's digest, so review the ${plural(replaced, 'replacement')} above first.`));\n }\n return out;\n}\n\nfunction workflow(p: Paint, value: Result): string[] {\n const out = [`${p.bold(`${text(value['definitionId'])}@${text(value['definitionVersion'])}`)} ${status(p, text(value['status']))} ${p.dim(`revision ${text(value['revision'])}`)}`,\n p.dim(` ${text(value['runId'])}`), ''];\n for (const step of list(value['steps'])) {\n const approval = record(step['approval']);\n out.push(` ${status(p, text(step['status']), 26)} ${text(step['id'])} ${p.dim(text(step['kind']))}${step['childRunId'] ? p.dim(` → ${text(step['childRunId'])}`) : ''}`);\n if (approval['digest']) out.push(p.yellow(` needs approval: --node ${text(step['id'])} --digest ${text(approval['digest'])}`));\n }\n return out;\n}\n\n/** Render one command result for a person. Unknown shapes fall back to indented JSON, never to nothing. */\nexport function render(command: string, result: unknown, p: Paint, relative: (path: string) => string = path => path): string {\n const value = record(result); const out: string[] = [];\n if (command === 'templates' || command === 'starters') {\n const items = list(value[command]); const width = columns();\n out.push(p.bold(command === 'starters' ? 'Starters: complete projects with a server, worker, tests and docs' : 'Templates: small single-purpose examples'), '');\n for (const item of items) out.push(` ${p.cyan(text(item['name']))}`, wrap(text(item['description']), width - 6, ' '), '');\n out.push(`Create one with ${p.bold(`mayura init --${command === 'starters' ? 'starter' : 'template'} <name> --directory <dir>`)}, or run ${p.bold('mayura init')} to choose interactively.`);\n } else if (command === 'init') out.push(...plan(p, value, relative));\n else if (command === 'validate') out.push(`${p.green('✔')} ${p.bold(text(value['project']))} is a valid Mayura project ${p.dim(`(${text(value['template'])})`)}`);\n else if (command === 'inspect') {\n const project = record(value['project']);\n out.push(`${p.bold(text(project['name']))} ${p.dim(`(${text(project['template'])})`)}`, '');\n const definitions = list(project['definitions']); const tools = list(project['tools']);\n out.push(p.bold(`Definitions (${definitions.length})`));\n for (const item of definitions) out.push(` ${text(item['kind']).padEnd(9)} ${p.cyan(`${text(item['id'])}@${text(item['version'])}`)} ${p.dim(text(item['source']))}`);\n out.push('', p.bold(`Tools (${tools.length})`));\n for (const item of tools) {\n const capabilities = Array.isArray(item['capabilities']) ? (item['capabilities'] as string[]).join(', ') : '';\n out.push(` ${p.cyan(`${text(item['id'])}@${text(item['version'])}`)} effects: ${text(item['effects'])}${capabilities ? p.dim(` capabilities: ${capabilities}`) : ''}`);\n }\n } else if (command === 'server-health') {\n const health = record(value['health']); out.push(`Server ${status(p, text(health['status']))}`);\n for (const check of list(health['checks'])) out.push(` ${status(p, text(check['status']), 24)} ${text(check['id'])}`);\n } else if (command === 'server-tools') {\n const page = record(value['page']); const tools = list(page['tools']);\n out.push(p.bold(plural(tools.length, 'tool')), '');\n for (const tool of tools) {\n out.push(` ${p.cyan(`${text(tool['id'])}@${text(tool['version'])}`)} ${p.dim(`agent ${text(tool['agentId'])}@${text(tool['agentVersion'])}`)}`,\n ` effects: ${text(tool['effects'])}, cost up to ${micros(text(tool['costMicros']))}, timeout ${text(tool['timeoutMs'])} ms`);\n }\n if (page['next'] !== null && page['next'] !== undefined) out.push('', p.dim(`More: add --after ${text(page['next'])}`));\n } else if (command === 'human-list') {\n const page = record(value['page']); const items = list(page['items']);\n out.push(p.bold(plural(items.length, 'human request')), '');\n for (const item of items) out.push(` ${status(p, text(item['status']), 24)} ${p.cyan(text(item['id']))} ${p.dim(`${text(item['kind']).replaceAll('_', ' ')} · ${text(item['agentId'])}`)}`,\n wrap(text(item['prompt']).slice(0, 300), columns() - 8, ' '));\n if (page['next'] !== null && page['next'] !== undefined) out.push('', p.dim(`More: add --after ${text(page['next'])}`));\n } else if (command === 'human-get' || command === 'human-respond') {\n const item = record(value['request']);\n out.push(`${p.bold(text(item['id']))} ${status(p, text(item['status']))} ${p.dim(`${text(item['kind']).replaceAll('_', ' ')} · agent ${text(item['agentId'])}`)}`, '',\n wrap(text(item['prompt']), columns() - 4, ' '), '', p.dim(` digest ${text(item['digest'])}`), p.dim(` schema ${text(item['schemaId'])}`));\n if (typeof item['deadlineAtMs'] === 'number') out.push(p.dim(` deadline ${time(item['deadlineAtMs'])}`));\n } else if (command === 'run-get' || command === 'run-wait') {\n const run = record(value['run']); const budget = record(run['budget']);\n out.push(`${p.bold('Run')} ${text(run['id'])} ${status(p, text(run['status']))}`,\n ` spent ${micros(text(budget['spentMicros']))}, reserved ${micros(text(budget['reservedMicros']))}, ${plural(Number(budget['calls']), 'call')}`);\n const evidence = list(run['evidence']);\n if (evidence.length) out.push('', p.bold('Tool calls'));\n for (const entry of evidence) {\n const receipt = record(entry['receipt']);\n out.push(` ${status(p, text(receipt['execution']), 24)} ${text(receipt['toolId'])} ${p.dim(`output ${text(receipt['disclosure'])}`)}`);\n }\n } else if (command === 'run-cancel') out.push(`${p.green('✔')} Cancellation requested for run ${text(value['id'])}`);\n else if (command === 'workflow-list') {\n const page = record(value['page']); const items = list(page['items']);\n out.push(p.bold(plural(items.length, 'workflow run')), '');\n for (const item of items) {\n const settled = typeof item['settledAtMs'] === 'number' ? p.dim(` · settled ${time(item['settledAtMs'])}`) : '';\n out.push(` ${status(p, text(item['status']), 26)} ${p.cyan(`${text(item['definitionId'])}@${text(item['definitionVersion'])}`)} ${p.dim(`rev ${text(item['revision'])}`)}${settled}`,\n p.dim(` ${text(item['runId'])}`));\n }\n if (page['next'] !== null && page['next'] !== undefined) out.push('', p.dim(`More: add --after ${text(page['next'])}`));\n } else if (command.startsWith('workflow-')) out.push(...workflow(p, record(value['workflow'])));\n else if (command === 'fleet-get' || command === 'fleet-hold' || command === 'fleet-release') {\n const fleet = record(value['fleet']);\n out.push(fleet['held'] === true ? p.yellow('● The fleet is held: workers start no new work.') : p.green('✔ The fleet is running.'),\n p.dim(` generation ${text(fleet['generation'])}${typeof fleet['changedAtMs'] === 'number' ? `, changed ${time(fleet['changedAtMs'])}` : ''}`));\n } else if (command === 'fleet-sweep') {\n const outcomes = list(value['outcomes']); const counts = new Map<string, number>();\n for (const outcome of outcomes) counts.set(text(outcome['outcome']), (counts.get(text(outcome['outcome'])) ?? 0) + 1);\n out.push(`${p.bold(`Fleet ${text(value['phase'])} sweep`)} ${status(p, text(value['status']))} ${p.dim(plural(Number(value['pages']), 'page'))}`);\n for (const [outcome, count] of counts) out.push(` ${String(count).padStart(5)} ${outcome.replaceAll('_', ' ')}`);\n if (value['nextCursor']) out.push('', p.yellow('Not finished. Run with --json to save nextCursor to a file, then continue with --cursor-file.'));\n } else if (command === 'migrate') out.push(`${p.green('✔')} Storage migrated`);\n else if (command === 'serve' || command === 'worker' || command === 'dev') out.push(`${p.green('✔')} Stopped`);\n else out.push(JSON.stringify(result, null, 2));\n return out.join('\\n');\n}\n\n/** One line per lifecycle event while `serve` or `worker` runs in a terminal. */\nexport function renderLifecycle(event: { readonly event: string } & Record<string, unknown>, p: Paint): string {\n if (event.event === 'serving') return p.green('● Serving. Press Ctrl+C to stop.');\n if (event.event === 'worker-started') {\n const probe = record(event['probe']);\n return p.green(`● Worker started${probe['port'] !== undefined ? `, probes on ${text(probe['hostname'])}:${text(probe['port'])}` : ''}. Press Ctrl+C to stop.`);\n }\n if (event.event === 'stopping') return p.yellow('● Stopping… (press Ctrl+C again to force)');\n if (event.event === 'stopped') return `${p.green('✔ Stopped')}${event['drained'] === false ? p.yellow(` · ${text(event['interrupted'])} interrupted`) : ''}`;\n return JSON.stringify(event);\n}\n\nexport function renderError(error: { readonly code: string; readonly message: string }, p: Paint): string {\n return `${p.red(`✖ ${error.message}`)} ${p.dim(`(${error.code})`)}`;\n}\n\nexport function help(p: Paint): string {\n const row = (name: string, description: string): string => ` ${p.cyan(name.padEnd(30))} ${description}`;\n return [\n `${p.bold('mayura')} <command> [options]`, '',\n p.bold('Create'),\n row('init', 'create a project; with no options in a terminal, choose interactively'),\n row('init --starter <name> --directory <dir>', ''), row('init --template <name> --directory <dir>', 'show the plan; add --apply to write it'),\n row('starters', 'complete starter projects'), row('templates', 'small single-purpose templates'),\n row('validate --file <path>', 'check a mayura.project.json'), row('inspect --file <path>', 'list its agents, workflows and tools'), '',\n p.bold('Run an application'),\n row('dev', 'build, run and restart on changes; loads .env'),\n row('serve --app <module>', 'start its server'), row('worker --app <module>', 'start its worker'), row('migrate --app <module>', 'migrate its storage'), '',\n p.bold('Operate a server') + p.dim(' (pipe the token: … | mayura <command> --url <url> --token-stdin)'),\n row('server-health, server-tools', ''), row('run-get, run-wait, run-cancel', ''), row('human-list, human-get, human-respond', ''),\n row('workflow-list [--settled]', 'active runs, or finished and unresolved ones'),\n row('workflow-get, workflow-approve', ''), row('workflow-cancel, workflow-pause, workflow-resume, workflow-signal', ''),\n row('fleet-get, fleet-hold, fleet-release, fleet-sweep', ''), '',\n p.bold('Options'),\n row('--help, -h', 'show this help (also after any command)'), row('--version, -v', 'print the version'),\n row('--json', 'always print JSON, even in a terminal'), '',\n p.dim('Output is readable in a terminal and JSON when piped; --json always prints JSON.'),\n ].map(line => line.trimEnd()).join('\\n');\n}\n"]}
@@ -8,25 +8,49 @@ export interface ProviderOption {
8
8
  readonly provider?: StarterProvider;
9
9
  readonly keyVariable?: string;
10
10
  readonly defaultModel?: string;
11
- /** OpenAI-compatible presets: a fixed endpoint, or `azure` / `other` to ask for it. */
11
+ /** OpenAI-compatible presets: a fixed endpoint, or `azure` / `cloudflare` / `other` to ask for it. */
12
12
  readonly endpoint?: string;
13
- readonly ask?: 'azure' | 'other';
13
+ readonly ask?: 'azure' | 'cloudflare' | 'other';
14
14
  readonly auth?: ProviderAuth;
15
+ /** The provider's dialect: JSON mode instead of JSON Schema output, and strict tool calls. */
16
+ readonly dialect?: ProviderDialect;
15
17
  }
18
+ /** How an OpenAI-compatible provider differs from OpenAI: see `output`, `strictTools` and `tokenLimitField` of openAICompatibleChat. */
19
+ export interface ProviderDialect {
20
+ readonly output?: 'json_object';
21
+ readonly strictTools?: boolean;
22
+ readonly tokenLimitField?: 'max_completion_tokens';
23
+ }
24
+ /** DeepSeek offers JSON mode but not JSON Schema output, and strict tool calls on its beta endpoint. */
25
+ export declare const DEEPSEEK_DIALECT: ProviderDialect;
26
+ /** OpenAI's models through a gateway: its newer models accept only `max_completion_tokens` for the output limit. */
27
+ export declare const OPENAI_CHAT_DIALECT: ProviderDialect;
16
28
  /**
17
- * Offline, the two native adapters, then OpenAI-compatible endpoints as documented in docs/how-to/model-providers.md.
29
+ * Offline, the two native adapters, then OpenAI-compatible endpoints as documented in docs/guides/model-providers.md.
18
30
  * Mayura has not qualified the compatible ones against live accounts; `pnpm providers:live-check` does that.
19
31
  */
20
32
  export declare const PROVIDERS: readonly ProviderOption[];
21
33
  export interface ProviderChoice {
34
+ /** The provider's key; empty only for a gateway that stores the key itself (then `gatewayToken` authenticates). */
22
35
  readonly provider: StarterProvider;
23
36
  readonly apiKey: string;
24
37
  readonly model: string;
25
- /** For `compatible`: the endpoint, a short id naming its adapter, and how it takes the key. */
38
+ /** For `compatible`: the endpoint, a short id naming its adapter, how it takes the key, and its dialect. */
26
39
  readonly compatible?: {
27
40
  readonly id: string;
28
41
  readonly endpoint: string;
29
42
  readonly auth: ProviderAuth;
43
+ readonly dialect?: ProviderDialect;
44
+ /** Cloudflare AI Gateway's token, for an authenticated gateway (sent as `cf-aig-authorization`). */
45
+ readonly gatewayToken?: string;
46
+ };
47
+ /**
48
+ * For `openai` and `anthropic` through a gateway (Cloudflare AI Gateway's provider endpoints): the full endpoint, and
49
+ * the gateway's token for an authenticated gateway. The key may then be empty when the gateway stores it.
50
+ */
51
+ readonly gateway?: {
52
+ readonly endpoint: string;
53
+ readonly token?: string;
30
54
  };
31
55
  /** Micro-dollars per million tokens. */
32
56
  readonly inputMicrosPerMillionTokens: number;
@@ -45,6 +69,12 @@ export declare const validKey: (value: string | undefined) => boolean;
45
69
  * credentials or fragment and at most an `api-version` query. Returns a reason when it is not.
46
70
  */
47
71
  export declare function endpointProblem(value: string | undefined): string | undefined;
72
+ /** Cloudflare AI Gateway's OpenAI-compatible endpoint for an account and gateway. Models are named `provider/model`. */
73
+ export declare function cloudflareEndpoint(accountId: string, gatewayId: string): string;
74
+ /** Cloudflare AI Gateway's endpoint for a provider's own API: OpenAI's Responses API or Anthropic's Messages API. */
75
+ export declare function cloudflareProviderEndpoint(accountId: string, gatewayId: string, api: 'openai' | 'anthropic'): string;
76
+ /** The dialect of a model reached through a gateway, from its `provider/model` name. */
77
+ export declare const gatewayDialect: (model: string) => ProviderDialect | undefined;
48
78
  /** The Azure OpenAI chat-completions URL for a resource, deployment and API version. */
49
79
  export declare function azureEndpoint(resource: string, deployment: string, apiVersion: string): string;
50
80
  /** The `.env` text for a starter. Only this module handles the key, and only to write it here. */
@@ -1 +1 @@
1
- {"version":3,"file":"providers.d.ts","sourceRoot":"","sources":["../src/providers.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,eAAe,GAAG,QAAQ,GAAG,WAAW,GAAG,YAAY,CAAC;AACpE,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,SAAS,CAAC;AAChD,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACnE,iEAAiE;IACjE,QAAQ,CAAC,QAAQ,CAAC,EAAE,eAAe,CAAC;IAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IACnG,uFAAuF;IACvF,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC;IAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,YAAY,CAAC;CAC5F;AAID;;;GAGG;AACH,eAAO,MAAM,SAAS,EAAE,SAAS,cAAc,EAc7C,CAAC;AAEH,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,QAAQ,EAAE,eAAe,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACpF,+FAA+F;IAC/F,QAAQ,CAAC,UAAU,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAA;KAAE,CAAC;IACtG,wCAAwC;IACxC,QAAQ,CAA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AED,kGAAkG;AAClG,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,cAAc,GAAG,MAAM,CAqBlE;AAED,kHAAkH;AAClH,wBAAsB,wBAAwB,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,SAAS,GAAG,QAAQ,CAAC,CAGvH"}
@@ -2,9 +2,13 @@
2
2
  // The key is written only to that file (owner-only, ignored by git) and is never printed, returned or put in a plan.
3
3
  import { writeFile } from 'node:fs/promises';
4
4
  import { join } from 'node:path';
5
- const compatible = (id, label, endpoint) => ({ id, label, hint: 'OpenAI-compatible', provider: 'compatible', keyVariable: 'MAYURA_MODEL_API_KEY', endpoint, auth: 'bearer' });
5
+ /** DeepSeek offers JSON mode but not JSON Schema output, and strict tool calls on its beta endpoint. */
6
+ export const DEEPSEEK_DIALECT = Object.freeze({ output: 'json_object', strictTools: true });
7
+ /** OpenAI's models through a gateway: its newer models accept only `max_completion_tokens` for the output limit. */
8
+ export const OPENAI_CHAT_DIALECT = Object.freeze({ tokenLimitField: 'max_completion_tokens' });
9
+ const compatible = (id, label, endpoint, extra = {}) => ({ id, label, hint: 'OpenAI-compatible', provider: 'compatible', keyVariable: 'MAYURA_MODEL_API_KEY', endpoint, auth: 'bearer', ...extra });
6
10
  /**
7
- * Offline, the two native adapters, then OpenAI-compatible endpoints as documented in docs/how-to/model-providers.md.
11
+ * Offline, the two native adapters, then OpenAI-compatible endpoints as documented in docs/guides/model-providers.md.
8
12
  * Mayura has not qualified the compatible ones against live accounts; `pnpm providers:live-check` does that.
9
13
  */
10
14
  export const PROVIDERS = Object.freeze([
@@ -14,11 +18,12 @@ export const PROVIDERS = Object.freeze([
14
18
  compatible('groq', 'Groq', 'https://api.groq.com/openai/v1/chat/completions'),
15
19
  compatible('gemini', 'Google Gemini', 'https://generativelanguage.googleapis.com/v1beta/openai/chat/completions'),
16
20
  compatible('mistral', 'Mistral', 'https://api.mistral.ai/v1/chat/completions'),
17
- compatible('deepseek', 'DeepSeek', 'https://api.deepseek.com/chat/completions'),
21
+ compatible('deepseek', 'DeepSeek', 'https://api.deepseek.com/beta/chat/completions', { defaultModel: 'deepseek-flash', dialect: DEEPSEEK_DIALECT }),
18
22
  compatible('xai', 'xAI', 'https://api.x.ai/v1/chat/completions'),
19
23
  compatible('openrouter', 'OpenRouter', 'https://openrouter.ai/api/v1/chat/completions'),
20
24
  compatible('together', 'Together', 'https://api.together.xyz/v1/chat/completions'),
21
25
  compatible('fireworks', 'Fireworks', 'https://api.fireworks.ai/inference/v1/chat/completions'),
26
+ { id: 'cloudflare', label: 'Cloudflare AI Gateway', hint: 'OpenAI, Anthropic or any model through your gateway', provider: 'compatible', keyVariable: 'MAYURA_MODEL_API_KEY', ask: 'cloudflare', auth: 'bearer' },
22
27
  { id: 'azure', label: 'Azure OpenAI', hint: 'your resource and deployment', provider: 'compatible', keyVariable: 'MAYURA_MODEL_API_KEY', ask: 'azure', auth: 'api-key' },
23
28
  { id: 'other', label: 'Another OpenAI-compatible provider', hint: 'any HTTPS /chat/completions endpoint', provider: 'compatible', keyVariable: 'MAYURA_MODEL_API_KEY', ask: 'other', auth: 'bearer' },
24
29
  ]);
@@ -59,6 +64,17 @@ export function endpointProblem(value) {
59
64
  }
60
65
  return undefined;
61
66
  }
67
+ /** Cloudflare AI Gateway's OpenAI-compatible endpoint for an account and gateway. Models are named `provider/model`. */
68
+ export function cloudflareEndpoint(accountId, gatewayId) {
69
+ return `https://gateway.ai.cloudflare.com/v1/${encodeURIComponent(accountId)}/${encodeURIComponent(gatewayId)}/compat/chat/completions`;
70
+ }
71
+ /** Cloudflare AI Gateway's endpoint for a provider's own API: OpenAI's Responses API or Anthropic's Messages API. */
72
+ export function cloudflareProviderEndpoint(accountId, gatewayId, api) {
73
+ const base = `https://gateway.ai.cloudflare.com/v1/${encodeURIComponent(accountId)}/${encodeURIComponent(gatewayId)}`;
74
+ return api === 'openai' ? `${base}/openai/responses` : `${base}/anthropic/v1/messages`;
75
+ }
76
+ /** The dialect of a model reached through a gateway, from its `provider/model` name. */
77
+ export const gatewayDialect = (model) => /^deepseek\//iu.test(model) ? DEEPSEEK_DIALECT : /^openai\//iu.test(model) ? OPENAI_CHAT_DIALECT : undefined;
62
78
  /** The Azure OpenAI chat-completions URL for a resource, deployment and API version. */
63
79
  export function azureEndpoint(resource, deployment, apiVersion) {
64
80
  return `https://${resource}.openai.azure.com/openai/deployments/${encodeURIComponent(deployment)}/chat/completions?api-version=${encodeURIComponent(apiVersion)}`;
@@ -70,9 +86,14 @@ export function providerEnvironment(choice) {
70
86
  '# Written by mayura init for local development. It holds your API key: keep it private and never commit it',
71
87
  '# (.gitignore excludes it). Production reads these settings from its own environment instead.',
72
88
  `MAYURA_MODEL_PROVIDER=${choice.provider}`,
89
+ ...(choice.gateway ? [`MAYURA_MODEL_ENDPOINT=${choice.gateway.endpoint}`, ...(choice.gateway.token ? [`MAYURA_MODEL_GATEWAY_TOKEN=${choice.gateway.token}`] : [])] : []),
73
90
  ...(choice.compatible ? [`MAYURA_MODEL_PROVIDER_ID=${choice.compatible.id}`, `MAYURA_MODEL_ENDPOINT=${choice.compatible.endpoint}`,
74
- `MAYURA_MODEL_AUTH=${choice.compatible.auth}`] : []),
75
- `${keyVariable}=${choice.apiKey}`,
91
+ `MAYURA_MODEL_AUTH=${choice.compatible.auth}`,
92
+ ...(choice.compatible.dialect?.output ? [`MAYURA_MODEL_OUTPUT=${choice.compatible.dialect.output}`] : []),
93
+ ...(choice.compatible.dialect?.strictTools ? ['MAYURA_MODEL_STRICT_TOOLS=true'] : []),
94
+ ...(choice.compatible.dialect?.tokenLimitField ? [`MAYURA_MODEL_TOKEN_LIMIT_FIELD=${choice.compatible.dialect.tokenLimitField}`] : []),
95
+ ...(choice.compatible.gatewayToken ? [`MAYURA_MODEL_GATEWAY_TOKEN=${choice.compatible.gatewayToken}`] : [])] : []),
96
+ ...(choice.apiKey ? [`${keyVariable}=${choice.apiKey}`] : []),
76
97
  `MAYURA_MODEL=${choice.model}`,
77
98
  `MAYURA_MODEL_INPUT_MICROS_PER_MILLION_TOKENS=${choice.inputMicrosPerMillionTokens}`,
78
99
  `MAYURA_MODEL_OUTPUT_MICROS_PER_MILLION_TOKENS=${choice.outputMicrosPerMillionTokens}`,
@@ -1 +1 @@
1
- {"version":3,"file":"providers.js","sourceRoot":"","sources":["../src/providers.ts"],"names":[],"mappings":"AAAA,oHAAoH;AACpH,qHAAqH;AACrH,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAYjC,MAAM,UAAU,GAAG,CAAC,EAAU,EAAE,KAAa,EAAE,QAAgB,EAAkB,EAAE,CACjF,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,mBAAmB,EAAE,QAAQ,EAAE,YAAY,EAAE,WAAW,EAAE,sBAAsB,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC;AACpI;;;GAGG;AACH,MAAM,CAAC,MAAM,SAAS,GAA8B,MAAM,CAAC,MAAM,CAAC;IAChE,EAAE,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,uEAAuE,EAAE;IAClH,EAAE,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,kBAAkB,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,gBAAgB,EAAE;IAC9G,EAAE,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,kBAAkB,EAAE,QAAQ,EAAE,WAAW,EAAE,WAAW,EAAE,mBAAmB,EAAE,YAAY,EAAE,iBAAiB,EAAE;IAC3J,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,iDAAiD,CAAC;IAC7E,UAAU,CAAC,QAAQ,EAAE,eAAe,EAAE,0EAA0E,CAAC;IACjH,UAAU,CAAC,SAAS,EAA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S,CAAC,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC,EAAE,mBAAmB,CAAC,MAAM,CAAC,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;QAAC,OAAO,SAAS,CAAC;IAAC,CAAC;IAC/I,OAAO,KAAK,EAAE,CAAC;QAAC,IAAK,KAA+B,CAAC,IAAI,KAAK,QAAQ;YAAE,OAAO,QAAQ,CAAC;QAAC,MAAM,KAAK,CAAC;IAAC,CAAC;AACzG,CAAC","sourcesContent":["// Model provider settings the starters read, so `mayura init` can ask for them once and write the project's `.env`.\n// The key is written only to that file (owner-only, ignored by git) and is never printed, returned or put in a plan.\nimport { writeFile } from 'node:fs/promises';\nimport { join } from 'node:path';\n\nexport type StarterProvider = 'openai' | 'anthropic' | 'compatible';\nexport type ProviderAuth = 'bearer' | 'api-key';\nexport interface ProviderOption {\n readonly id: string; readonly label: string; readonly hint: string;\n /** What MAYURA_MODEL_PROVIDER becomes; undefined for offline. */\n readonly provider?: StarterProvider; readonly keyVariable?: string; readonly defaultModel?: string;\n /** OpenAI-compatible presets: a fixed endpoint, or `azure` / `other` to ask for it. */\n readonly endpoint?: string; readonly ask?: 'azure' | 'other'; readonly auth?: ProviderAuth;\n}\n\nconst compatible = (id: string, label: string, endpoint: string): ProviderOption =>\n ({ id, label, hint: 'OpenAI-compatible', provider: 'compatible', keyVariable: 'MAYURA_MODEL_API_KEY', endpoint, auth: 'bearer' });\n/**\n * Offline, the two native adapters, then OpenAI-compatible endpoints as documented in docs/how-to/model-providers.md.\n * Mayura has not qualified the compatible ones against live accounts; `pnpm providers:live-check` does that.\n */\nexport const PROVIDERS: readonly ProviderOption[] = Object.freeze([\n { id: 'offline', label: 'Offline', hint: 'rule-based stand-in models, no key, no network: good for a first look' },\n { id: 'openai', label: 'OpenAI', hint: 'needs an API key', provider: 'openai', keyVariable: 'OPENAI_API_KEY' },\n { id: 'anthropic', label: 'Anthropic', hint: 'needs an API key', provider: 'anthropic', keyVariable: 'ANTHROPIC_API_KEY', defaultModel: 'claude-sonnet-5' },\n compatible('groq', 'Groq', 'https://api.groq.com/openai/v1/chat/completions'),\n compatible('gemini', 'Google Gemini', 'https://generativelanguage.googleapis.com/v1beta/openai/chat/completions'),\n compatible('mistral', 'Mistral', 'https://api.mistral.ai/v1/chat/completions'),\n compatible('deepseek', 'DeepSeek', 'https://api.deepseek.com/chat/completions'),\n compatible('xai', 'xAI', 'https://api.x.ai/v1/chat/completions'),\n compatible('openrouter', 'OpenRouter', 'https://openrouter.ai/api/v1/chat/completions'),\n compatible('together', 'Together', 'https://api.together.xyz/v1/chat/completions'),\n compatible('fireworks', 'Fireworks', 'https://api.fireworks.ai/inference/v1/chat/completions'),\n { id: 'azure', label: 'Azure OpenAI', hint: 'your resource and deployment', provider: 'compatible', keyVariable: 'MAYURA_MODEL_API_KEY', ask: 'azure', auth: 'api-key' },\n { id: 'other', label: 'Another OpenAI-compatible provider', hint: 'any HTTPS /chat/completions endpoint', provider: 'compatible', keyVariable: 'MAYURA_MODEL_API_KEY', ask: 'other', auth: 'bearer' },\n]);\n\nexport interface ProviderChoice {\n readonly provider: StarterProvider; readonly apiKey: string; readonly model: string;\n /** For `compatible`: the endpoint, a short id naming its adapter, and how it takes the key. */\n readonly compatible?: { readonly id: string; readonly endpoint: string; readonly auth: ProviderAuth };\n /** Micro-dollars per million tokens. */\n readonly inputMicrosPerMillionTokens: number; readonly outputMicrosPerMillionTokens: number;\n /** The most one model call, and one agent run, may cost, in micro-dollars. */\n readonly maxCallCostMicros: number; readonly maxRunCostMicros: number;\n}\n\nexport const modelPattern = /^[A-Za-z0-9][A-Za-z0-9._:/-]{0,127}$/u;\nexport const providerIdPattern = /^[a-z0-9][a-z0-9-]{0,39}$/u;\n/** Dollars as typed (\"3\", \"0.25\") to micro-dollars; undefined when it is not a plain positive amount. */\nexport function dollarsToMicros(value: string | undefined): number | undefined {\n const text = (value ?? '').trim().replace(/^\\$/u, '');\n if (!/^\\d{1,9}(?:\\.\\d{1,6})?$/u.test(text)) return undefined;\n const micros = Math.round(Number(text) * 1_000_000); return micros > 0 ? micros : undefined;\n}\nexport const validKey = (value: string | undefined): boolean => typeof value === 'string' && /^[\\x21-\\x7e]{8,4096}$/u.test(value);\n\n/**\n * The same rule as the compatible adapter: an HTTPS URL ending in `/chat/completions`, not a loopback address, with no\n * credentials or fragment and at most an `api-version` query. Returns a reason when it is not.\n */\nexport function endpointProblem(value: string | undefined): string | undefined {\n let url: URL; try { url = new URL((value ?? '').trim()); } catch { return 'Enter the full https:// URL.'; }\n const query = [...url.searchParams.keys()];\n if (url.protocol !== 'https:') return 'The endpoint must use https://.';\n if (['localhost', '127.0.0.1', '[::1]'].includes(url.hostname)) return 'For a local server, use openAICompatibleChat without remote in your own code.';\n if (url.username || url.password || url.hash) return 'Leave credentials and #fragments out of the URL; the key goes in the next question.';\n if (!url.pathname.endsWith('/chat/completions')) return 'The endpoint must end in /chat/completions.';\n if (query.length > 1 || query.some(key => key !== 'api-version') || (query.length === 1 && !/^[0-9A-Za-z.-]{1,32}$/u.test(url.searchParams.get('api-version')!))) {\n return 'Only an api-version query is allowed.';\n }\n return undefined;\n}\n/** The Azure OpenAI chat-completions URL for a resource, deployment and API version. */\nexport function azureEndpoint(resource: string, deployment: string, apiVersion: string): string {\n return `https://${resource}.openai.azure.com/openai/deployments/${encodeURIComponent(deployment)}/chat/completions?api-version=${encodeURIComponent(apiVersion)}`;\n}\n\n/** The `.env` text for a starter. Only this module handles the key, and only to write it here. */\nexport function providerEnvironment(choice: ProviderChoice): string {\n const keyVariable = choice.provider === 'openai' ? 'OPENAI_API_KEY' : choice.provider === 'anthropic' ? 'ANTHROPIC_API_KEY' : 'MAYURA_MODEL_API_KEY';\n return [\n '# Written by mayura init for local development. It holds your API key: keep it private and never commit it',\n '# (.gitignore excludes it). Production reads these settings from its own environment instead.',\n `MAYURA_MODEL_PROVIDER=${choice.provider}`,\n ...(choice.compatible ? [`MAYURA_MODEL_PROVIDER_ID=${choice.compatible.id}`, `MAYURA_MODEL_ENDPOINT=${choice.compatible.endpoint}`,\n `MAYURA_MODEL_AUTH=${choice.compatible.auth}`] : []),\n `${keyVariable}=${choice.apiKey}`,\n `MAYURA_MODEL=${choice.model}`,\n `MAYURA_MODEL_INPUT_MICROS_PER_MILLION_TOKENS=${choice.inputMicrosPerMillionTokens}`,\n `MAYURA_MODEL_OUTPUT_MICROS_PER_MILLION_TOKENS=${choice.outputMicrosPerMillionTokens}`,\n `MAYURA_MODEL_MAX_CALL_COST_MICROS=${choice.maxCallCostMicros}`,\n `MAYURA_MAX_RUN_COST_MICROS=${choice.maxRunCostMicros}`,\n '',\n ].join('\\n');\n}\n\n/** Write `.env` once. An existing file is left untouched, since it may hold settings the person wants to keep. */\nexport async function writeProviderEnvironment(directory: string, choice: ProviderChoice): Promise<'written' | 'exists'> {\n try { await writeFile(join(directory, '.env'), providerEnvironment(choice), { encoding: 'utf8', flag: 'wx', mode: 0o600 }); return 'written'; }\n catch (error) { if ((error as NodeJS.ErrnoException).code === 'EEXIST') return 'exists'; throw error; }\n}\n"]}
1
+ {"version":3,"file":"providers.js","sourceRoot":"","sources":["../src/providers.ts"],"names":[],"mappings":"AAAA,oHAAoH;AACpH,qHAAqH;AACrH,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAejC,wGAAwG;AACxG,MAAM,CAAC,MAAM,gBAAgB,GAAoB,MAAM,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,aAAa,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC;AAC7G,oHAAoH;AACpH,MAAM,CAAC,MAAM,mBAAmB,GAAoB,MAAM,CAAC,MAAM,CAAC,EAAE,eAAe,EAAE,uBAAuB,EAAE,CAAC,CAAC;AAEhH,MAAM,UAAU,GAAG,CAAC,EAAU,EAAE,KAAa,EAAE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,CAAC,CAAC,EAAE,CAAC;QAC7D,gBAAgB,MAAM,CAAC,KAAK,EAAE;QAC9B,gDAAgD,MAAM,CAAC,2BAA2B,EAAE;QACpF,iDAAiD,MAAM,CAAC,4BAA4B,EAAE;QACtF,qCAAqC,MAAM,CAAC,iBAAiB,EAAE;QAC/D,8BAA8B,MAAM,CAAC,gBAAgB,EAAE;QACvD,EAAE;KACH,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC;AAED,kHAAkH;AAClH,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAAC,SAAiB,EAAE,MAAsB;IACtF,IAAI,CAAC;QAAC,MAAM,SAAS,CAAC,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC,EAAE,mBAAmB,CAAC,MAAM,CAAC,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;QAAC,OAAO,SAAS,CAAC;IAAC,CAAC;IAC/I,OAAO,KAAK,EAAE,CAAC;QAAC,IAAK,KAA+B,CAAC,IAAI,KAAK,QAAQ;YAAE,OAAO,QAAQ,CAAC;QAAC,MAAM,KAAK,CAAC;IAAC,CAAC;AACzG,CAAC","sourcesContent":["// Model provider settings the starters read, so `mayura init` can ask for them once and write the project's `.env`.\n// The key is written only to that file (owner-only, ignored by git) and is never printed, returned or put in a plan.\nimport { writeFile } from 'node:fs/promises';\nimport { join } from 'node:path';\n\nexport type StarterProvider = 'openai' | 'anthropic' | 'compatible';\nexport type ProviderAuth = 'bearer' | 'api-key';\nexport interface ProviderOption {\n readonly id: string; readonly label: string; readonly hint: string;\n /** What MAYURA_MODEL_PROVIDER becomes; undefined for offline. */\n readonly provider?: StarterProvider; readonly keyVariable?: string; readonly defaultModel?: string;\n /** OpenAI-compatible presets: a fixed endpoint, or `azure` / `cloudflare` / `other` to ask for it. */\n readonly endpoint?: string; readonly ask?: 'azure' | 'cloudflare' | 'other'; readonly auth?: ProviderAuth;\n /** The provider's dialect: JSON mode instead of JSON Schema output, and strict tool calls. */\n readonly dialect?: ProviderDialect;\n}\n/** How an OpenAI-compatible provider differs from OpenAI: see `output`, `strictTools` and `tokenLimitField` of openAICompatibleChat. */\nexport interface ProviderDialect { readonly output?: 'json_object'; readonly strictTools?: boolean; readonly tokenLimitField?: 'max_completion_tokens' }\n/** DeepSeek offers JSON mode but not JSON Schema output, and strict tool calls on its beta endpoint. */\nexport const DEEPSEEK_DIALECT: ProviderDialect = Object.freeze({ output: 'json_object', strictTools: true });\n/** OpenAI's models through a gateway: its newer models accept only `max_completion_tokens` for the output limit. */\nexport const OPENAI_CHAT_DIALECT: ProviderDialect = Object.freeze({ tokenLimitField: 'max_completion_tokens' });\n\nconst compatible = (id: string, label: string, endpoint: string, extra: Partial<ProviderOption> = {}): ProviderOption =>\n ({ id, label, hint: 'OpenAI-compatible', provider: 'compatible', keyVariable: 'MAYURA_MODEL_API_KEY', endpoint, auth: 'bearer', ...extra });\n/**\n * Offline, the two native adapters, then OpenAI-compatible endpoints as documented in docs/guides/model-providers.md.\n * Mayura has not qualified the compatible ones against live accounts; `pnpm providers:live-check` does that.\n */\nexport const PROVIDERS: readonly ProviderOption[] = Object.freeze([\n { id: 'offline', label: 'Offline', hint: 'rule-based stand-in models, no key, no network: good for a first look' },\n { id: 'openai', label: 'OpenAI', hint: 'needs an API key', provider: 'openai', keyVariable: 'OPENAI_API_KEY' },\n { id: 'anthropic', label: 'Anthropic', hint: 'needs an API key', provider: 'anthropic', keyVariable: 'ANTHROPIC_API_KEY', defaultModel: 'claude-sonnet-5' },\n compatible('groq', 'Groq', 'https://api.groq.com/openai/v1/chat/completions'),\n compatible('gemini', 'Google Gemini', 'https://generativelanguage.googleapis.com/v1beta/openai/chat/completions'),\n compatible('mistral', 'Mistral', 'https://api.mistral.ai/v1/chat/completions'),\n compatible('deepseek', 'DeepSeek', 'https://api.deepseek.com/beta/chat/completions', { defaultModel: 'deepseek-flash', dialect: DEEPSEEK_DIALECT }),\n compatible('xai', 'xAI', 'https://api.x.ai/v1/chat/completions'),\n compatible('openrouter', 'OpenRouter', 'https://openrouter.ai/api/v1/chat/completions'),\n compatible('together', 'Together', 'https://api.together.xyz/v1/chat/completions'),\n compatible('fireworks', 'Fireworks', 'https://api.fireworks.ai/inference/v1/chat/completions'),\n { id: 'cloudflare', label: 'Cloudflare AI Gateway', hint: 'OpenAI, Anthropic or any model through your gateway', provider: 'compatible', keyVariable: 'MAYURA_MODEL_API_KEY', ask: 'cloudflare', auth: 'bearer' },\n { id: 'azure', label: 'Azure OpenAI', hint: 'your resource and deployment', provider: 'compatible', keyVariable: 'MAYURA_MODEL_API_KEY', ask: 'azure', auth: 'api-key' },\n { id: 'other', label: 'Another OpenAI-compatible provider', hint: 'any HTTPS /chat/completions endpoint', provider: 'compatible', keyVariable: 'MAYURA_MODEL_API_KEY', ask: 'other', auth: 'bearer' },\n]);\n\nexport interface ProviderChoice {\n /** The provider's key; empty only for a gateway that stores the key itself (then `gatewayToken` authenticates). */\n readonly provider: StarterProvider; readonly apiKey: string; readonly model: string;\n /** For `compatible`: the endpoint, a short id naming its adapter, how it takes the key, and its dialect. */\n readonly compatible?: { readonly id: string; readonly endpoint: string; readonly auth: ProviderAuth; readonly dialect?: ProviderDialect;\n /** Cloudflare AI Gateway's token, for an authenticated gateway (sent as `cf-aig-authorization`). */\n readonly gatewayToken?: string };\n /**\n * For `openai` and `anthropic` through a gateway (Cloudflare AI Gateway's provider endpoints): the full endpoint, and\n * the gateway's token for an authenticated gateway. The key may then be empty when the gateway stores it.\n */\n readonly gateway?: { readonly endpoint: string; readonly token?: string };\n /** Micro-dollars per million tokens. */\n readonly inputMicrosPerMillionTokens: number; readonly outputMicrosPerMillionTokens: number;\n /** The most one model call, and one agent run, may cost, in micro-dollars. */\n readonly maxCallCostMicros: number; readonly maxRunCostMicros: number;\n}\n\nexport const modelPattern = /^[A-Za-z0-9][A-Za-z0-9._:/-]{0,127}$/u;\nexport const providerIdPattern = /^[a-z0-9][a-z0-9-]{0,39}$/u;\n/** Dollars as typed (\"3\", \"0.25\") to micro-dollars; undefined when it is not a plain positive amount. */\nexport function dollarsToMicros(value: string | undefined): number | undefined {\n const text = (value ?? '').trim().replace(/^\\$/u, '');\n if (!/^\\d{1,9}(?:\\.\\d{1,6})?$/u.test(text)) return undefined;\n const micros = Math.round(Number(text) * 1_000_000); return micros > 0 ? micros : undefined;\n}\nexport const validKey = (value: string | undefined): boolean => typeof value === 'string' && /^[\\x21-\\x7e]{8,4096}$/u.test(value);\n\n/**\n * The same rule as the compatible adapter: an HTTPS URL ending in `/chat/completions`, not a loopback address, with no\n * credentials or fragment and at most an `api-version` query. Returns a reason when it is not.\n */\nexport function endpointProblem(value: string | undefined): string | undefined {\n let url: URL; try { url = new URL((value ?? '').trim()); } catch { return 'Enter the full https:// URL.'; }\n const query = [...url.searchParams.keys()];\n if (url.protocol !== 'https:') return 'The endpoint must use https://.';\n if (['localhost', '127.0.0.1', '[::1]'].includes(url.hostname)) return 'For a local server, use openAICompatibleChat without remote in your own code.';\n if (url.username || url.password || url.hash) return 'Leave credentials and #fragments out of the URL; the key goes in the next question.';\n if (!url.pathname.endsWith('/chat/completions')) return 'The endpoint must end in /chat/completions.';\n if (query.length > 1 || query.some(key => key !== 'api-version') || (query.length === 1 && !/^[0-9A-Za-z.-]{1,32}$/u.test(url.searchParams.get('api-version')!))) {\n return 'Only an api-version query is allowed.';\n }\n return undefined;\n}\n/** Cloudflare AI Gateway's OpenAI-compatible endpoint for an account and gateway. Models are named `provider/model`. */\nexport function cloudflareEndpoint(accountId: string, gatewayId: string): string {\n return `https://gateway.ai.cloudflare.com/v1/${encodeURIComponent(accountId)}/${encodeURIComponent(gatewayId)}/compat/chat/completions`;\n}\n/** Cloudflare AI Gateway's endpoint for a provider's own API: OpenAI's Responses API or Anthropic's Messages API. */\nexport function cloudflareProviderEndpoint(accountId: string, gatewayId: string, api: 'openai' | 'anthropic'): string {\n const base = `https://gateway.ai.cloudflare.com/v1/${encodeURIComponent(accountId)}/${encodeURIComponent(gatewayId)}`;\n return api === 'openai' ? `${base}/openai/responses` : `${base}/anthropic/v1/messages`;\n}\n/** The dialect of a model reached through a gateway, from its `provider/model` name. */\nexport const gatewayDialect = (model: string): ProviderDialect | undefined =>\n /^deepseek\\//iu.test(model) ? DEEPSEEK_DIALECT : /^openai\\//iu.test(model) ? OPENAI_CHAT_DIALECT : undefined;\n\n/** The Azure OpenAI chat-completions URL for a resource, deployment and API version. */\nexport function azureEndpoint(resource: string, deployment: string, apiVersion: string): string {\n return `https://${resource}.openai.azure.com/openai/deployments/${encodeURIComponent(deployment)}/chat/completions?api-version=${encodeURIComponent(apiVersion)}`;\n}\n\n/** The `.env` text for a starter. Only this module handles the key, and only to write it here. */\nexport function providerEnvironment(choice: ProviderChoice): string {\n const keyVariable = choice.provider === 'openai' ? 'OPENAI_API_KEY' : choice.provider === 'anthropic' ? 'ANTHROPIC_API_KEY' : 'MAYURA_MODEL_API_KEY';\n return [\n '# Written by mayura init for local development. It holds your API key: keep it private and never commit it',\n '# (.gitignore excludes it). Production reads these settings from its own environment instead.',\n `MAYURA_MODEL_PROVIDER=${choice.provider}`,\n ...(choice.gateway ? [`MAYURA_MODEL_ENDPOINT=${choice.gateway.endpoint}`, ...(choice.gateway.token ? [`MAYURA_MODEL_GATEWAY_TOKEN=${choice.gateway.token}`] : [])] : []),\n ...(choice.compatible ? [`MAYURA_MODEL_PROVIDER_ID=${choice.compatible.id}`, `MAYURA_MODEL_ENDPOINT=${choice.compatible.endpoint}`,\n `MAYURA_MODEL_AUTH=${choice.compatible.auth}`,\n ...(choice.compatible.dialect?.output ? [`MAYURA_MODEL_OUTPUT=${choice.compatible.dialect.output}`] : []),\n ...(choice.compatible.dialect?.strictTools ? ['MAYURA_MODEL_STRICT_TOOLS=true'] : []),\n ...(choice.compatible.dialect?.tokenLimitField ? [`MAYURA_MODEL_TOKEN_LIMIT_FIELD=${choice.compatible.dialect.tokenLimitField}`] : []),\n ...(choice.compatible.gatewayToken ? [`MAYURA_MODEL_GATEWAY_TOKEN=${choice.compatible.gatewayToken}`] : [])] : []),\n ...(choice.apiKey ? [`${keyVariable}=${choice.apiKey}`] : []),\n `MAYURA_MODEL=${choice.model}`,\n `MAYURA_MODEL_INPUT_MICROS_PER_MILLION_TOKENS=${choice.inputMicrosPerMillionTokens}`,\n `MAYURA_MODEL_OUTPUT_MICROS_PER_MILLION_TOKENS=${choice.outputMicrosPerMillionTokens}`,\n `MAYURA_MODEL_MAX_CALL_COST_MICROS=${choice.maxCallCostMicros}`,\n `MAYURA_MAX_RUN_COST_MICROS=${choice.maxRunCostMicros}`,\n '',\n ].join('\\n');\n}\n\n/** Write `.env` once. An existing file is left untouched, since it may hold settings the person wants to keep. */\nexport async function writeProviderEnvironment(directory: string, choice: ProviderChoice): Promise<'written' | 'exists'> {\n try { await writeFile(join(directory, '.env'), providerEnvironment(choice), { encoding: 'utf8', flag: 'wx', mode: 0o600 }); return 'written'; }\n catch (error) { if ((error as NodeJS.ErrnoException).code === 'EEXIST') return 'exists'; throw error; }\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "type": "module",
3
- "version": "0.1.0-dev.0",
3
+ "version": "1.0.0-rc.2",
4
4
  "private": true
5
5
  }
@@ -0,0 +1,47 @@
1
+ /**
2
+ * The AGENTS.md written into every new project: it points an AI coding assistant at the documentation for the exact
3
+ * Mayura version installed (shipped inside the package), and states the rules assistants most often get wrong.
4
+ * CLAUDE.md imports it, for assistants that read that file instead.
5
+ */
6
+ export function agentGuide(options: { readonly kind: 'starter' | 'template'; readonly scripts: Readonly<Record<string, string>> }): string {
7
+ const scripts = Object.entries(options.scripts).map(([name, command]) => `- \`npm run ${name}\`: \`${command}\``);
8
+ return [
9
+ '# AGENTS.md',
10
+ '',
11
+ 'This project is built with [Mayura](https://github.com/KartikeyAI/mayura) (`mayura` on npm), a TypeScript framework',
12
+ 'for AI agents, typed tools and durable workflows.',
13
+ '',
14
+ '## Mayura documentation',
15
+ '',
16
+ 'Read the documentation for the version installed here instead of relying on memory; the API may differ from what',
17
+ 'you have seen before:',
18
+ '',
19
+ '- `node_modules/mayura/docs/README.md`: the index of every page (guides, concepts, CLI, entry points).',
20
+ '- `node_modules/mayura/llms-full.txt`: all of the documentation in one file.',
21
+ '- `node_modules/mayura/lib/<entry point>/dist/*.d.ts`: the exact types, with doc comments.',
22
+ '',
23
+ '## This project',
24
+ '',
25
+ options.kind === 'starter'
26
+ ? '`README.md` explains what this starter does, where everything is, and how to make it yours.'
27
+ : '`README.md` describes this template; the code is in `src/index.ts`.',
28
+ '',
29
+ ...(scripts.length ? ['Scripts:', '', ...scripts, ''] : []),
30
+ '## Rules',
31
+ '',
32
+ '- Import from `mayura` or `mayura/<entry point>` (such as `mayura/provider-openai`), never from `@mayura/...`.',
33
+ "- Schemas use `z` from `mayura` (it is Zod 4): `import { defineTool, z } from 'mayura'`. Do not add `zod`.",
34
+ '- Nothing is allowed by default. Grant what a run needs in `createRuntime({ permissions: { allow: [...] } })`:',
35
+ ' `model:<adapter id>`, `tool:<tool id>`, `effect:<read|write|host>` for tools with effects, and every',
36
+ ' capability a tool declares.',
37
+ '- Costs are in micros (1,000,000 = $1). A run may spend nothing until `limits.maxCostMicros` is set, and each',
38
+ ' model adapter needs its prices and a per-call `maxCostMicros`.',
39
+ '- Mayura generates the JSON Schemas model providers need from Zod schemas. Providers accept only strict schemas:',
40
+ ' use `.nullable()`, not `.optional()` or `.default()`, and no `z.record`; `defineAgent` names any field to fix.',
41
+ '- Check `result.status` before reading `result.output`. `outcome_unknown` means a side effect may have happened:',
42
+ ' reconcile it, never retry it blindly.',
43
+ '- Never write API keys into code or commit `.env`. `mayura dev` loads `.env` for local development.',
44
+ '- Test agents offline with `scriptedModel` from `mayura/testing`; tests must not need a network or an API key.',
45
+ '',
46
+ ].join('\n');
47
+ }
@@ -9,6 +9,12 @@ export interface MayuraServerHandle { isAccepting(): boolean; close(): Promise<v
9
9
  export interface MayuraWorkerHandle {
10
10
  start(): void; isReady(): boolean;
11
11
  drain(options?: { readonly timeoutMs?: number }): Promise<{ readonly drained: boolean; readonly interrupted: number }>;
12
+ /** Advance everything due once and return, for `mayura worker --once`; `createWorkflowWorker` has it. */
13
+ runOnce?(options?: { readonly budgetMs?: number }): Promise<MayuraWorkerOnceReport>;
14
+ }
15
+ /** What one `runOnce` did: see `WorkflowWorker.runOnce` in `mayura/workflows`. */
16
+ export interface MayuraWorkerOnceReport {
17
+ readonly leader: boolean; readonly completedSweep: boolean; readonly held: boolean; readonly passes: number; readonly failures: readonly string[];
12
18
  }
13
19
  /**
14
20
  * The explicit contract a `mayura serve` or `mayura worker` module exports. The module wires its own storage,
@@ -101,6 +107,24 @@ export async function runWorkerApplication(options: { readonly application: Mayu
101
107
  return { status: 'stopped', drained: report.drained, interrupted: report.interrupted };
102
108
  }
103
109
 
110
+ /**
111
+ * Advance the application's workflows once and return, then run its shutdown: `mayura worker --once`, for a scheduled
112
+ * job or function. The status is `succeeded` after a complete sweep, `incomplete` when the budget ran out first,
113
+ * `held` while a fleet hold is set, `standby` when another replica holds the lease, and `failed` when a pass failed.
114
+ */
115
+ export async function runWorkerOnce(options: { readonly application: MayuraApplication; readonly budgetMs?: number }): Promise<{
116
+ readonly status: 'succeeded' | 'incomplete' | 'held' | 'standby' | 'failed'; readonly report: MayuraWorkerOnceReport }> {
117
+ const { application } = options;
118
+ if (!application.worker) throw new MayuraError('INVALID_CONFIG', 'The application does not define a worker.');
119
+ try {
120
+ const worker = await application.worker();
121
+ if (!worker || typeof worker.runOnce !== 'function') throw new MayuraError('INVALID_CONFIG', 'The application worker cannot run once: return a worker from createWorkflowWorker.');
122
+ const report = await worker.runOnce(options.budgetMs === undefined ? {} : { budgetMs: options.budgetMs });
123
+ const status = report.failures.length > 0 ? 'failed' : !report.leader ? 'standby' : report.held ? 'held' : report.completedSweep ? 'succeeded' : 'incomplete';
124
+ return { status, report };
125
+ } finally { await settle(application.shutdown); }
126
+ }
127
+
104
128
  /** Run the application's explicit migration once, then its shutdown. Nothing else is started. */
105
129
  export async function migrateApplication(application: MayuraApplication): Promise<{ readonly status: 'migrated'; readonly report: unknown }> {
106
130
  if (!application.migrate) throw new MayuraError('INVALID_CONFIG', 'The application does not define migrate.');
@@ -4,7 +4,7 @@ import { existsSync, readFileSync } from 'node:fs';
4
4
  import { fileURLToPath, pathToFileURL } from 'node:url';
5
5
  import { lstat, readFile } from 'node:fs/promises';
6
6
  import { jsonValue, MayuraError, publicError, type JsonValue } from '@mayura/core';
7
- import { loadApplication, migrateApplication, runWorkerApplication, serveApplication, type MayuraLifecycleEvent } from './application.js';
7
+ import { loadApplication, migrateApplication, runWorkerApplication, runWorkerOnce, serveApplication, type MayuraLifecycleEvent } from './application.js';
8
8
  import { applyProjectPlan, approveWorkflow, cancelRun, cancelWorkflow, inspectHumanRequest, inspectHumanRequests, inspectRun, inspectServerHealth,
9
9
  inspectServerTools, inspectWorkflow, inspectWorkflows, holdWorkflowFleet, inspectWorkflowFleet, pauseWorkflow, planProject, planStarter, readProject, releaseWorkflowFleet, respondHumanRequest, resumeWorkflow, sweepWorkflowFleet, signalWorkflow, starters, templates, waitForRun, STARTER_NAMES, TEMPLATE_NAMES, type StarterName, type TemplateName } from './index.js';
10
10
  import { colourEnabled, help, paint, render, renderError, renderLifecycle } from './output.js';
@@ -17,6 +17,9 @@ const out = paint(human && colourEnabled(process.stdout));
17
17
  const err = paint(!json && colourEnabled(process.stderr));
18
18
  const shownPath = (path: string): string => { const inner = relative(process.cwd(), path); return !inner ? '.' : inner.startsWith('..') ? path : `./${inner.replaceAll('\\', '/')}`; };
19
19
 
20
+ /** This CLI's version, from its own package.json (the workspace package, or lib/cli inside the published package). */
21
+ const cliVersion = (): string => (JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8')) as { version: string }).version;
22
+
20
23
  /** A usage problem the CLI itself found; its fixed message is safe and useful to show. */
21
24
  const usage = (message: string): MayuraError => new MayuraError('INVALID_INPUT', message);
22
25
 
@@ -82,8 +85,11 @@ async function signalFile(path: string): Promise<JsonValue> {
82
85
 
83
86
  async function main(arguments_: readonly string[]): Promise<unknown> {
84
87
  const command = arguments_[0];
85
- if (command === undefined && human) return { status: 'help' };
86
- if (command === 'help' || command === '--help' || command === '-h') { assertArguments(arguments_, []); return { status: 'help' }; }
88
+ // No command: show what the commands are, in a terminal or not (a script that forgot one learns the same).
89
+ if (command === undefined) return { status: 'help' };
90
+ if (command === '--version' || command === '-v' || command === 'version') { assertArguments(arguments_, []); return { status: 'succeeded', version: cliVersion() }; }
91
+ // Help wins anywhere on the line, so `mayura init --help` shows how to use init instead of an argument error.
92
+ if (command === 'help' || arguments_.includes('--help') || arguments_.includes('-h')) return { status: 'help' };
87
93
  // With no options, a person at a terminal chooses interactively; scripts keep the explicit flags.
88
94
  if (command === 'init' && arguments_.length === 1 && human && process.stdin.isTTY === true) {
89
95
  const { initWizard } = await import('./interactive.js');
@@ -169,8 +175,17 @@ async function main(arguments_: readonly string[]): Promise<unknown> {
169
175
  return migrateApplication(await loadApplication(path));
170
176
  }
171
177
  if (command === 'serve' || command === 'worker') {
172
- assertArguments(arguments_, command === 'serve' ? ['--app'] : ['--app', '--probe-host', '--probe-port', '--drain-timeout-ms']);
178
+ assertArguments(arguments_, command === 'serve' ? ['--app'] : ['--app', '--probe-host', '--probe-port', '--drain-timeout-ms', '--budget-ms'],
179
+ command === 'serve' ? [] : ['--once']);
173
180
  const path = option(arguments_, '--app'); if (!path) throw usage(`${command} requires --app <module.mjs>.`);
181
+ if (command === 'worker' && arguments_.includes('--once')) {
182
+ if (['--probe-host', '--probe-port', '--drain-timeout-ms'].some(flag => arguments_.includes(flag))) throw usage('worker --once takes only --app and --budget-ms.');
183
+ const budget = option(arguments_, '--budget-ms');
184
+ const result = await runWorkerOnce({ application: await loadApplication(path), ...(budget === undefined ? {} : { budgetMs: Number(budget) }) });
185
+ if (result.status === 'failed') process.exitCode = 1;
186
+ return result;
187
+ }
188
+ if (option(arguments_, '--budget-ms') !== undefined) throw usage('--budget-ms is only for worker --once.');
174
189
  const probePort = option(arguments_, '--probe-port'); const drain = option(arguments_, '--drain-timeout-ms');
175
190
  const application = await loadApplication(path);
176
191
  // Probes are an explicit opt-in served by the application's own @mayura/server-node; the CLI stays network-free.
@@ -245,13 +260,15 @@ async function main(arguments_: readonly string[]): Promise<unknown> {
245
260
  ...(childRunId === undefined ? {} : { childRunId }) }) };
246
261
  }
247
262
  // The unknown word is not echoed back: it could be a credential pasted in the wrong place.
248
- throw usage(command === undefined ? 'No command given. Run mayura --help to see the commands.' : 'Unknown command. Run mayura --help to see the commands.');
263
+ throw usage('Unknown command. Run mayura --help to see the commands.');
249
264
  }
250
265
 
251
266
  try {
252
267
  const argumentsWithoutJson = rawArguments.filter(argument => argument !== '--json');
253
268
  const result = await main(argumentsWithoutJson) as { readonly status?: string; readonly rendered?: boolean };
254
269
  if (result?.status === 'help') console.log(help(json ? paint(false) : out));
270
+ // The version is printed plainly, as other CLIs do, so scripts can read it; --json gives the JSON document.
271
+ else if (typeof (result as { version?: unknown })?.version === 'string' && !json) console.log((result as { version: string }).version);
255
272
  else if (result?.rendered) { if (json) console.log(JSON.stringify({ status: result.status }, null, 2)); }
256
273
  else console.log(human ? render(argumentsWithoutJson[0] ?? '', result, out, shownPath) : JSON.stringify(result, null, 2));
257
274
  } catch (error) {
@@ -82,7 +82,11 @@ export async function runDev(options: DevOptions): Promise<{ readonly status: 's
82
82
  const entry = options.entry ?? (existsSync(join(directory, 'dist', 'src', 'dev.js')) ? 'dist/src/dev.js' : undefined);
83
83
  if (entry) { print(p.green(`● running ${entry}`)); children = [launch([entry])]; return; }
84
84
  const app = options.app ?? 'dist/src/app.js';
85
- if (!existsSync(join(directory, app))) { print(p.red(`✖ Nothing to run: add dist/src/dev.js, or pass --app <module> or --entry <file>.`)); return; }
85
+ if (!existsSync(join(directory, app))) {
86
+ // A template is one program: run dist/index.js after each build.
87
+ if (options.app === undefined && existsSync(join(directory, 'dist', 'index.js'))) { print(p.green('● running dist/index.js')); children = [launch(['dist/index.js'])]; return; }
88
+ print(p.red(`✖ Nothing to run: add dist/src/dev.js (or dist/index.js), or pass --app <module> or --entry <file>.`)); return;
89
+ }
86
90
  // An application without a dev entry runs as in production: migrate once, then a server and a worker.
87
91
  const migrate = launch([options.bin, 'migrate', '--app', app]);
88
92
  const migrated = await new Promise<number | null>(resolve => migrate.on('close', resolve));