mayura 1.2.1 → 1.2.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 (243) hide show
  1. package/README.md +2 -0
  2. package/docs/README.md +17 -5
  3. package/docs/cli/init.md +15 -3
  4. package/docs/guides/choosing-a-starter.md +80 -0
  5. package/docs/guides/framework-starters.md +5 -1
  6. package/docs/guides/hono.md +94 -0
  7. package/docs/guides/nextjs.md +94 -0
  8. package/docs/guides/nuxt.md +94 -0
  9. package/docs/guides/rag-deployment.md +48 -0
  10. package/docs/guides/rag-modal-pinecone-starter.md +63 -0
  11. package/docs/guides/rag-production.md +34 -15
  12. package/docs/guides/rag-quickstart.md +119 -0
  13. package/docs/guides/rag.md +11 -1
  14. package/docs/guides/react-router.md +94 -0
  15. package/docs/guides/release-readiness.md +76 -39
  16. package/docs/guides/sveltekit.md +94 -0
  17. package/docs/guides/tanstack-start.md +94 -0
  18. package/docs/integrations/reranker-cohere.md +1 -0
  19. package/docs/integrations/reranker-jina.md +1 -0
  20. package/docs/integrations/reranker-voyage.md +1 -0
  21. package/docs/integrations/vector-chroma.md +1 -0
  22. package/docs/integrations/vector-libsql.md +1 -0
  23. package/docs/integrations/vector-pgvector.md +1 -0
  24. package/docs/integrations/vector-pinecone.md +4 -1
  25. package/docs/integrations/vector-qdrant.md +1 -0
  26. package/docs/integrations/vector-weaviate.md +1 -0
  27. package/docs/introduction.md +5 -0
  28. package/docs/project/whats-new.md +70 -2
  29. package/docs/quickstart.md +5 -3
  30. package/lib/adapter-code-docker/image/Dockerfile +1 -1
  31. package/lib/adapter-code-docker/package.json +1 -1
  32. package/lib/adapter-code-quickjs/package.json +1 -1
  33. package/lib/adapter-mcp/package.json +1 -1
  34. package/lib/ag-ui/package.json +1 -1
  35. package/lib/artifacts/package.json +1 -1
  36. package/lib/auth/package.json +1 -1
  37. package/lib/authz/package.json +1 -1
  38. package/lib/browser/package.json +1 -1
  39. package/lib/cli/dist/index.d.ts +1 -1
  40. package/lib/cli/dist/index.d.ts.map +1 -1
  41. package/lib/cli/dist/index.js +63 -20
  42. package/lib/cli/dist/index.js.map +1 -1
  43. package/lib/cli/dist/interactive.js +2 -2
  44. package/lib/cli/dist/interactive.js.map +1 -1
  45. package/lib/cli/package.json +1 -1
  46. package/lib/cli/src/index.ts +51 -12
  47. package/lib/cli/src/interactive.ts +2 -2
  48. package/lib/cli/starter-assets/manifest.json +1 -0
  49. package/lib/cli/starters/hono/package.json +2 -2
  50. package/lib/cli/starters/rag-modal-pinecone/README.md +60 -0
  51. package/lib/cli/starters/rag-modal-pinecone/dot-env.example +23 -0
  52. package/lib/cli/starters/{event-automation → rag-modal-pinecone}/dot-gitignore +2 -4
  53. package/lib/cli/starters/rag-modal-pinecone/fixtures/on-call.md +4 -0
  54. package/lib/cli/starters/rag-modal-pinecone/mayura.project.json +13 -0
  55. package/lib/cli/starters/rag-modal-pinecone/modal-app.py +110 -0
  56. package/lib/cli/starters/rag-modal-pinecone/package.json +28 -0
  57. package/lib/cli/starters/rag-modal-pinecone/src/application.ts +148 -0
  58. package/lib/cli/starters/rag-modal-pinecone/src/cli.ts +78 -0
  59. package/lib/cli/starters/rag-modal-pinecone/src/hosted.ts +137 -0
  60. package/lib/cli/starters/rag-modal-pinecone/test/modal_worker_test.py +53 -0
  61. package/lib/cli/starters/rag-modal-pinecone/test/pipeline.test.ts +137 -0
  62. package/lib/cli/starters/{cli-agent → rag-modal-pinecone}/tsconfig.json +0 -1
  63. package/lib/client/package.json +1 -1
  64. package/lib/client-react/package.json +1 -1
  65. package/lib/code-mode/package.json +1 -1
  66. package/lib/code-mode-workflows/package.json +1 -1
  67. package/lib/context/package.json +1 -1
  68. package/lib/core/package.json +1 -1
  69. package/lib/exporter-otlp/dist/otlp-http-json.js +1 -1
  70. package/lib/exporter-otlp/dist/otlp-http-json.js.map +1 -1
  71. package/lib/exporter-otlp/dist/signals.js +2 -2
  72. package/lib/exporter-otlp/dist/signals.js.map +1 -1
  73. package/lib/exporter-otlp/package.json +1 -1
  74. package/lib/exporter-otlp/src/otlp-http-json.ts +1 -1
  75. package/lib/exporter-otlp/src/signals.ts +2 -2
  76. package/lib/files/package.json +1 -1
  77. package/lib/guardrails/package.json +1 -1
  78. package/lib/helpers/package.json +1 -1
  79. package/lib/keys/package.json +1 -1
  80. package/lib/memory/package.json +1 -1
  81. package/lib/memory-remote/package.json +1 -1
  82. package/lib/observability/package.json +1 -1
  83. package/lib/provider-anthropic/package.json +1 -1
  84. package/lib/provider-openai/package.json +1 -1
  85. package/lib/rag/package.json +1 -1
  86. package/lib/runtime/package.json +1 -1
  87. package/lib/sandbox/package.json +1 -1
  88. package/lib/sdk/package.json +1 -1
  89. package/lib/server/package.json +1 -1
  90. package/lib/server-node/package.json +1 -1
  91. package/lib/skills/package.json +1 -1
  92. package/lib/storage/package.json +1 -1
  93. package/lib/storage-contracts/package.json +1 -1
  94. package/lib/storage-postgres/package.json +1 -1
  95. package/lib/storage-sql/package.json +1 -1
  96. package/lib/storage-sqlite/package.json +1 -1
  97. package/lib/terminal/package.json +1 -1
  98. package/lib/testing/package.json +1 -1
  99. package/lib/threads/package.json +1 -1
  100. package/lib/tools/package.json +1 -1
  101. package/lib/voice/package.json +1 -1
  102. package/lib/workflows/package.json +1 -1
  103. package/lib/workstream/package.json +1 -1
  104. package/llms-full.txt +1362 -289
  105. package/llms.txt +17 -4
  106. package/package.json +4 -4
  107. package/lib/cli/starters/cli-agent/dot-github/workflows/ci.yml +0 -13
  108. package/lib/cli/starters/cli-agent/dot-gitignore +0 -10
  109. package/lib/cli/starters/event-automation/dot-dockerignore +0 -7
  110. package/lib/cli/starters/event-automation/dot-github/workflows/ci.yml +0 -13
  111. package/lib/cli/starters/event-automation/src/model.ts +0 -40
  112. package/lib/cli/starters/event-automation/tsconfig.json +0 -20
  113. package/lib/cli/starters/nextjs/Dockerfile +0 -12
  114. package/lib/cli/starters/nextjs/compose.yaml +0 -19
  115. package/lib/cli/starters/nextjs/dot-dockerignore +0 -11
  116. package/lib/cli/starters/nextjs/dot-env.example +0 -7
  117. package/lib/cli/starters/nextjs/scripts/setup.mjs +0 -9
  118. package/lib/cli/starters/nextjs/server/application.mjs +0 -74
  119. package/lib/cli/starters/nextjs/server/auth.mjs +0 -24
  120. package/lib/cli/starters/nextjs/server/worker.mjs +0 -11
  121. package/lib/cli/starters/nextjs/server/workflows.mjs +0 -23
  122. package/lib/cli/starters/nextjs/src/ChatApp.jsx +0 -57
  123. package/lib/cli/starters/nextjs/src/Notebook.jsx +0 -25
  124. package/lib/cli/starters/nextjs/src/components/mayura/approval.tsx +0 -142
  125. package/lib/cli/starters/nextjs/src/components/mayura/thread-history.tsx +0 -142
  126. package/lib/cli/starters/nextjs/src/components/mayura/thread-list.tsx +0 -9
  127. package/lib/cli/starters/nextjs/src/components/mayura/ui.css +0 -14
  128. package/lib/cli/starters/nextjs/src/connect.js +0 -21
  129. package/lib/cli/starters/nextjs/src/session.js +0 -138
  130. package/lib/cli/starters/nextjs/src/style.css +0 -11
  131. package/lib/cli/starters/nextjs/test/server.test.mjs +0 -95
  132. package/lib/cli/starters/nextjs/test/session.test.mjs +0 -16
  133. package/lib/cli/starters/nuxt/compose.yaml +0 -19
  134. package/lib/cli/starters/nuxt/dot-dockerignore +0 -11
  135. package/lib/cli/starters/nuxt/dot-env.example +0 -7
  136. package/lib/cli/starters/nuxt/dot-gitignore +0 -14
  137. package/lib/cli/starters/nuxt/scripts/setup.mjs +0 -9
  138. package/lib/cli/starters/nuxt/server/application.mjs +0 -74
  139. package/lib/cli/starters/nuxt/server/auth.mjs +0 -24
  140. package/lib/cli/starters/nuxt/server/worker.mjs +0 -11
  141. package/lib/cli/starters/nuxt/server/workflows.mjs +0 -23
  142. package/lib/cli/starters/nuxt/src/connect.js +0 -21
  143. package/lib/cli/starters/nuxt/src/session.js +0 -138
  144. package/lib/cli/starters/nuxt/src/style.css +0 -11
  145. package/lib/cli/starters/nuxt/test/server.test.mjs +0 -95
  146. package/lib/cli/starters/nuxt/test/session.test.mjs +0 -16
  147. package/lib/cli/starters/react-router/Dockerfile +0 -12
  148. package/lib/cli/starters/react-router/compose.yaml +0 -19
  149. package/lib/cli/starters/react-router/dot-dockerignore +0 -11
  150. package/lib/cli/starters/react-router/dot-env.example +0 -7
  151. package/lib/cli/starters/react-router/dot-gitignore +0 -14
  152. package/lib/cli/starters/react-router/scripts/setup.mjs +0 -9
  153. package/lib/cli/starters/react-router/server/application.mjs +0 -74
  154. package/lib/cli/starters/react-router/server/auth.mjs +0 -24
  155. package/lib/cli/starters/react-router/server/worker.mjs +0 -11
  156. package/lib/cli/starters/react-router/server/workflows.mjs +0 -23
  157. package/lib/cli/starters/react-router/src/ChatApp.jsx +0 -57
  158. package/lib/cli/starters/react-router/src/Notebook.jsx +0 -25
  159. package/lib/cli/starters/react-router/src/components/mayura/approval.tsx +0 -142
  160. package/lib/cli/starters/react-router/src/components/mayura/thread-history.tsx +0 -142
  161. package/lib/cli/starters/react-router/src/components/mayura/thread-list.tsx +0 -9
  162. package/lib/cli/starters/react-router/src/components/mayura/ui.css +0 -14
  163. package/lib/cli/starters/react-router/src/connect.js +0 -21
  164. package/lib/cli/starters/react-router/src/session.js +0 -138
  165. package/lib/cli/starters/react-router/src/style.css +0 -11
  166. package/lib/cli/starters/react-router/src/vite-env.d.ts +0 -1
  167. package/lib/cli/starters/react-router/test/server.test.mjs +0 -95
  168. package/lib/cli/starters/react-router/test/session.test.mjs +0 -16
  169. package/lib/cli/starters/research-team/dot-dockerignore +0 -7
  170. package/lib/cli/starters/research-team/dot-github/workflows/ci.yml +0 -13
  171. package/lib/cli/starters/research-team/dot-gitignore +0 -10
  172. package/lib/cli/starters/research-team/src/model.ts +0 -40
  173. package/lib/cli/starters/research-team/tsconfig.json +0 -20
  174. package/lib/cli/starters/support-agent/dot-dockerignore +0 -7
  175. package/lib/cli/starters/support-agent/dot-github/workflows/ci.yml +0 -13
  176. package/lib/cli/starters/support-agent/dot-gitignore +0 -10
  177. package/lib/cli/starters/support-agent/src/model.ts +0 -40
  178. package/lib/cli/starters/support-agent/tsconfig.json +0 -20
  179. package/lib/cli/starters/sveltekit/Dockerfile +0 -12
  180. package/lib/cli/starters/sveltekit/compose.yaml +0 -19
  181. package/lib/cli/starters/sveltekit/dot-dockerignore +0 -11
  182. package/lib/cli/starters/sveltekit/dot-env.example +0 -7
  183. package/lib/cli/starters/sveltekit/dot-gitignore +0 -14
  184. package/lib/cli/starters/sveltekit/scripts/setup.mjs +0 -9
  185. package/lib/cli/starters/sveltekit/server/application.mjs +0 -74
  186. package/lib/cli/starters/sveltekit/server/auth.mjs +0 -24
  187. package/lib/cli/starters/sveltekit/server/worker.mjs +0 -11
  188. package/lib/cli/starters/sveltekit/server/workflows.mjs +0 -23
  189. package/lib/cli/starters/sveltekit/src/connect.js +0 -21
  190. package/lib/cli/starters/sveltekit/src/session.js +0 -138
  191. package/lib/cli/starters/sveltekit/src/style.css +0 -11
  192. package/lib/cli/starters/sveltekit/src/view.js +0 -49
  193. package/lib/cli/starters/sveltekit/test/server.test.mjs +0 -95
  194. package/lib/cli/starters/sveltekit/test/session.test.mjs +0 -16
  195. package/lib/cli/starters/tanstack-start/Dockerfile +0 -12
  196. package/lib/cli/starters/tanstack-start/compose.yaml +0 -19
  197. package/lib/cli/starters/tanstack-start/dot-dockerignore +0 -11
  198. package/lib/cli/starters/tanstack-start/dot-env.example +0 -7
  199. package/lib/cli/starters/tanstack-start/dot-gitignore +0 -14
  200. package/lib/cli/starters/tanstack-start/scripts/setup.mjs +0 -9
  201. package/lib/cli/starters/tanstack-start/server/application.mjs +0 -74
  202. package/lib/cli/starters/tanstack-start/server/auth.mjs +0 -24
  203. package/lib/cli/starters/tanstack-start/server/worker.mjs +0 -11
  204. package/lib/cli/starters/tanstack-start/server/workflows.mjs +0 -23
  205. package/lib/cli/starters/tanstack-start/src/ChatApp.jsx +0 -57
  206. package/lib/cli/starters/tanstack-start/src/Notebook.jsx +0 -25
  207. package/lib/cli/starters/tanstack-start/src/components/mayura/approval.tsx +0 -142
  208. package/lib/cli/starters/tanstack-start/src/components/mayura/thread-history.tsx +0 -142
  209. package/lib/cli/starters/tanstack-start/src/components/mayura/thread-list.tsx +0 -9
  210. package/lib/cli/starters/tanstack-start/src/components/mayura/ui.css +0 -14
  211. package/lib/cli/starters/tanstack-start/src/connect.js +0 -21
  212. package/lib/cli/starters/tanstack-start/src/session.js +0 -138
  213. package/lib/cli/starters/tanstack-start/src/style.css +0 -11
  214. package/lib/cli/starters/tanstack-start/test/server.test.mjs +0 -95
  215. package/lib/cli/starters/tanstack-start/test/session.test.mjs +0 -16
  216. /package/lib/cli/{starters/hono/src/components/mayura/ui.css → starter-assets/011cacc77ada0de5b447674e9fc4374a247b9a46eb169722b12649753f24188f} +0 -0
  217. /package/lib/cli/{starters/hono/test/server.test.mjs → starter-assets/0c825d6a776673ec6274cfc29cd45b1a8c56dcb880c291a91075c77e1ef1e4f3} +0 -0
  218. /package/lib/cli/{starters/hono/server/auth.mjs → starter-assets/0dd570bfacc357d23be3340250090b9a4c6193a49cdd02e9b6789e7bee8433dd} +0 -0
  219. /package/lib/cli/{starters/hono/src/components/mayura/approval.tsx → starter-assets/11292bd14cdaf27a8f8317ba4ab768d706a726b2e26474b599f3db116674b4b3} +0 -0
  220. /package/lib/cli/{starters/nextjs/dot-gitignore → starter-assets/1873b02e070347f9a449e07084242982fa6af412c45aa764985d553975b64589} +0 -0
  221. /package/lib/cli/{starters/hono/src/style.css → starter-assets/2f3869e6d69134e43be713c4590bfe48896a5c54ece6ffc1a4f204cfcfe54218} +0 -0
  222. /package/lib/cli/{starters/hono/server/worker.mjs → starter-assets/350d77757f548369beff29d658cf1620752d4e23b4b732d99a1b403ca043137f} +0 -0
  223. /package/lib/cli/{starters/approval-workflow/src/model.ts → starter-assets/37294d24c04b71eaf6d6f0bd52fd4c1cc7a5d3cb63da9c7920ed1d44276da9cb} +0 -0
  224. /package/lib/cli/{starters/approval-workflow/tsconfig.json → starter-assets/4387d6537dd5924ae62326aa3d7d8cbad1e5abd930aecc9daa6fab1ac2f6ef24} +0 -0
  225. /package/lib/cli/{starters/hono/dot-dockerignore → starter-assets/4434be031b58cc6ee680b2860b2ad1fe4089af7ee866c13223dfb621dd042ff1} +0 -0
  226. /package/lib/cli/{starters/hono/src/ChatApp.jsx → starter-assets/46e199317648a076243d6c8e7ffedc48785a6ffc0f203b88c7c4a9479b34c5b9} +0 -0
  227. /package/lib/cli/{starters/hono/src/components/mayura/thread-history.tsx → starter-assets/4741fccbca2e0d2fc6f61d11af3cf7bcc5f0238b67bb46282287207abdc6c536} +0 -0
  228. /package/lib/cli/{starters/approval-workflow/dot-dockerignore → starter-assets/4be664708b0120da5d2b73c5a27968093da06b8728f88f2bda2a1ccbf40f6891} +0 -0
  229. /package/lib/cli/{starters/hono/server/workflows.mjs → starter-assets/4d11f729672df54969a851494877a3c5aee24bb8f8c68eacaaa22e715bf5ed69} +0 -0
  230. /package/lib/cli/{starters/hono/dot-env.example → starter-assets/4f141323062660c4dc5b563300d57bb4cdbdc7fe9bfba96e43d9c64bb274474e} +0 -0
  231. /package/lib/cli/{starters/hono/Dockerfile → starter-assets/5471b74c46258d1edb00eb8f60f4219c389a252f7e224f2692f8f3e71ae43e3e} +0 -0
  232. /package/lib/cli/{starters/hono/scripts/setup.mjs → starter-assets/56e2d6db9fe4b0449c979acd06947a5b776bcc645184b54b8d3654a48bd12c38} +0 -0
  233. /package/lib/cli/{starters/hono/src/Notebook.jsx → starter-assets/6138d1e2ca4469daf4f5545d140943f6e23b0c37f865051b266ec99695cf181a} +0 -0
  234. /package/lib/cli/{starters/hono/src/vite-env.d.ts → starter-assets/65996936fbb042915f7b74a200fcdde7e410f32a669b1ab9597cfaa4b0faddb5} +0 -0
  235. /package/lib/cli/{starters/hono/server/application.mjs → starter-assets/757f43c27415654049ecf01b67d560c83d788108d1aebcf1f16a86d956bd7fb6} +0 -0
  236. /package/lib/cli/{starters/hono/src/components/mayura/thread-list.tsx → starter-assets/97601d0bf331df7bbde88f7ee269610bc8a1239f8eeb58fded6416e588a5b7dd} +0 -0
  237. /package/lib/cli/{starters/approval-workflow/dot-github/workflows/ci.yml → starter-assets/aa4182c76778ba2194ecbfde9a960c20181534fd1ab484df126278dbc6eb0186} +0 -0
  238. /package/lib/cli/{starters/hono/src/session.js → starter-assets/abcc6ebd29ba47a079befb6568054dec8f43d4c729187e4a3610af39789e77be} +0 -0
  239. /package/lib/cli/{starters/hono/compose.yaml → starter-assets/cc1df6f5ce0eebffc567ecea1d599eba97cd1b94ab01551085c0eb87a28e3a6c} +0 -0
  240. /package/lib/cli/{starters/hono/src/connect.js → starter-assets/cd3ddb959b277e7d495cc020a6f8146acfbcc9d05ececa3809e8aafcf84504d9} +0 -0
  241. /package/lib/cli/{starters/hono/test/session.test.mjs → starter-assets/dfe75fd07538427d80ba76767e037e929664c80ff5a41b7544496a789181bb73} +0 -0
  242. /package/lib/cli/{starters/approval-workflow/dot-gitignore → starter-assets/f3ef7285253ec9668732f535306beee602e91cb6e20f83d4799b3323399ce569} +0 -0
  243. /package/lib/cli/{starters/nuxt/src/view.js → starter-assets/ff840fe960683d377e78f731b5d4318adf6050384791fa20e4948d34192aa35d} +0 -0
package/llms.txt CHANGED
@@ -17,7 +17,8 @@ Rules that matter when writing Mayura code:
17
17
  - [Introduction](docs/introduction.md): What Mayura is, the ideas behind it, and how its parts fit together.
18
18
  - [Quickstart](docs/quickstart.md): Create a Mayura project in one command, or add a first agent to your own project and run it offline or on a real model.
19
19
  - [Installation](docs/installation.md): Requirements, the optional packages each part of Mayura needs, and TypeScript settings.
20
- - [V1.2 release validation status](docs/guides/release-readiness.md): Completed local and CI qualification, experimental surfaces and the checks still required before releasing Mayura V1.2.
20
+ - [V1.2.1 release validation status](docs/guides/release-readiness.md): Verified publication of all 106 packages, the scoped production RAG qualification, and remaining interoperability limits.
21
+ - [Choose a starter](docs/guides/choosing-a-starter.md): Choose among runnable Mayura applications, six framework notebooks and focused templates, then follow the right setup path.
21
22
  - [Using Mayura with AI coding agents](docs/ai-agents.md): Point Claude Code, Cursor, Codex and other coding assistants at documentation that matches your installed Mayura version.
22
23
 
23
24
  ## Concepts
@@ -29,9 +30,21 @@ Rules that matter when writing Mayura code:
29
30
  - [Permissions](docs/concepts/permissions.md): Explicit allow-lists decide which models, tools, effects and capabilities a run may use. Nothing is allowed by default.
30
31
  - [Costs and budgets](docs/concepts/costs-and-budgets.md): Cap what a run can spend: costs in micros, per-call ceilings, the run cost limit, tool costs and shared budgets.
31
32
  - [Workflows](docs/concepts/workflows.md): What a Mayura workflow is, when to use one instead of a single agent run, and which workflow entry point to start with.
32
- - [Framework starters](docs/guides/framework-starters.md): Generate Next.js, Hono, React Router, TanStack Start, SvelteKit or Nuxt notebooks with scoped threads and in-run approvals.
33
+ - [RAG quickstart](docs/guides/rag-quickstart.md): Install Mayura, ingest Markdown, retrieve and verify an exact citation, then delete the source locally.
33
34
  - [Retrieval augmented generation](docs/guides/rag.md): Scoped retrieval tools, durable content-addressed ingestion, vector adapters, citations and bounded reranking.
34
- - [RAG production qualification](docs/guides/rag-production.md): Production qualification evidence and deployment boundaries for the Modal and Pinecone Loki v28 profile.
35
+ - [RAG production qualification](docs/guides/rag-production.md): Compare the qualified Modal and Pinecone Loki v28 profile with experimental RAG configurations, and see measured scale, recall, and latency.
36
+ - [Build and deploy a retrieval agent](docs/guides/rag-deployment.md): Start offline, connect a scoped vector store, and qualify retrieval and citations on your own workload.
37
+ - [Run the Modal + Pinecone RAG starter](docs/guides/rag-modal-pinecone-starter.md): Generate the Mayura RAG starter, run its offline demo, and connect private Modal inference and a scoped Pinecone index.
38
+
39
+ ## Frameworks and starters
40
+
41
+ - [Framework starters](docs/guides/framework-starters.md): Generate Next.js, Hono, React Router, TanStack Start, SvelteKit or Nuxt notebooks with scoped threads and in-run approvals.
42
+ - [Mayura with Next.js](docs/guides/nextjs.md): Run the Next.js notebook starter with persistent threads, exact tool approvals, a scoped server and a separate durable worker.
43
+ - [Mayura with Hono](docs/guides/hono.md): Run the Hono notebook starter with persistent threads, exact tool approvals, a scoped server and a separate durable worker.
44
+ - [Mayura with React Router](docs/guides/react-router.md): Run the React Router notebook starter with persistent threads, exact tool approvals, a scoped server and a separate durable worker.
45
+ - [Mayura with TanStack Start](docs/guides/tanstack-start.md): Run the TanStack Start notebook starter with persistent threads, exact tool approvals, a scoped server and a separate durable worker.
46
+ - [Mayura with SvelteKit](docs/guides/sveltekit.md): Run the SvelteKit notebook starter with persistent threads, exact tool approvals, a scoped server and a separate durable worker.
47
+ - [Mayura with Nuxt](docs/guides/nuxt.md): Run the Nuxt notebook starter with persistent threads, exact tool approvals, a scoped server and a separate durable worker.
35
48
 
36
49
  ## Agents and models
37
50
 
@@ -247,7 +260,7 @@ Rules that matter when writing Mayura code:
247
260
 
248
261
  ## Project
249
262
 
250
- - [What's new in Mayura 1.1](docs/project/whats-new.md): Mayura 1.1: a model registry, voice, files, sandboxes, browsers, authentication and API keys, mayura deploy, edge runtimes and 85 integration packages.
263
+ - [What's new in Mayura 1.2.1](docs/project/whats-new.md): Qualified retrieval for the Modal and Pinecone Loki profile, configurable workflow graphs, and the capabilities shipped in Mayura 1.2.
251
264
  - [Versioning](docs/project/versioning.md): What Mayura keeps stable, how versions follow SemVer, how APIs are deprecated, and how release candidates and npm tags work.
252
265
  - [Support](docs/project/support.md): Supported Node.js versions, platforms and package managers, how to get help with Mayura, and how to report a bug.
253
266
  - [Security](docs/project/security.md): Mayura's security model: what it protects, what your code is trusted with, and how to report a vulnerability.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mayura",
3
- "version": "1.2.1",
3
+ "version": "1.2.2",
4
4
  "description": "A TypeScript framework for agents, typed tools and durable workflows.",
5
5
  "keywords": [
6
6
  "agents",
@@ -390,9 +390,9 @@
390
390
  ],
391
391
  "dependencies": {
392
392
  "@clack/prompts": "1.8.1",
393
- "@hono/node-server": "2.1.1",
394
- "hono": "4.13.9",
395
- "zod": "4.6.5"
393
+ "@hono/node-server": "2.1.11",
394
+ "hono": "4.13.20",
395
+ "zod": "4.6.7"
396
396
  },
397
397
  "peerDependencies": {
398
398
  "@jitl/quickjs-wasmfile-release-sync": "^0.32.0",
@@ -1,13 +0,0 @@
1
- name: ci
2
- on: [push, pull_request]
3
- permissions: { contents: read }
4
- jobs:
5
- test:
6
- runs-on: ubuntu-latest
7
- steps:
8
- - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
9
- with: { persist-credentials: false }
10
- - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
11
- with: { node-version: 24.14.1 }
12
- - run: npm install --no-audit --no-fund
13
- - run: npm test
@@ -1,10 +0,0 @@
1
- node_modules/
2
- dist/
3
- .data/
4
- *.tsbuildinfo
5
- .env
6
- .env.*
7
- !.env.example
8
- *.sqlite
9
- *.sqlite-shm
10
- *.sqlite-wal
@@ -1,7 +0,0 @@
1
- node_modules
2
- dist
3
- .data
4
- .env
5
- .env.*
6
- *.sqlite*
7
- .git
@@ -1,13 +0,0 @@
1
- name: ci
2
- on: [push, pull_request]
3
- permissions: { contents: read }
4
- jobs:
5
- test:
6
- runs-on: ubuntu-latest
7
- steps:
8
- - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
9
- with: { persist-credentials: false }
10
- - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
11
- with: { node-version: 24.14.1 }
12
- - run: npm install --no-audit --no-fund
13
- - run: npm test
@@ -1,40 +0,0 @@
1
- import type { JsonObject, ModelAdapter } from 'mayura/core';
2
- import { anthropicMessages } from 'mayura/provider-anthropic';
3
- import { openAICompatibleChat, openAIResponses } from 'mayura/provider-openai';
4
- import { z } from 'mayura';
5
- import type { ModelSettings } from './config.js';
6
-
7
- /**
8
- * The configured model for one agent. `offline` returns the agent's own rule-based stand-in: it performs no inference,
9
- * needs no key and costs nothing, so the whole starter runs and tests without a network. Set MAYURA_MODEL_PROVIDER to
10
- * `openai`, `anthropic` or `compatible` (any OpenAI-compatible endpoint) to use a real model with the same agent, tools
11
- * and output schema. Each compatible provider gets its own adapter id, `openai-compatible.<MAYURA_MODEL_PROVIDER_ID>`.
12
- */
13
- export function selectModel(settings: ModelSettings, agent: { readonly outputJsonSchema: JsonObject; readonly offline: ModelAdapter }): ModelAdapter {
14
- if (settings.provider === 'offline') return agent.offline;
15
- const options = { model: settings.name, outputJsonSchema: agent.outputJsonSchema,
16
- maxCostMicros: settings.maxCallCostMicros, pricing: settings.pricing, timeoutMs: 30_000 };
17
- if (settings.provider === 'compatible') {
18
- return openAICompatibleChat({ ...options, ...(settings.apiKey ? { apiKey: settings.apiKey } : {}), endpoint: settings.endpoint,
19
- remote: { id: settings.providerId, auth: settings.auth }, output: settings.output, strictTools: settings.strictTools,
20
- ...(settings.tokenLimitField ? { tokenLimitField: settings.tokenLimitField } : {}),
21
- ...(settings.gatewayToken ? { headers: { 'cf-aig-authorization': `Bearer ${settings.gatewayToken}` } } : {}) });
22
- }
23
- // Directly, or through a gateway (MAYURA_MODEL_ENDPOINT, with MAYURA_MODEL_GATEWAY_TOKEN; the key may stay in the gateway).
24
- const headers = settings.gatewayToken ? { 'cf-aig-authorization': `Bearer ${settings.gatewayToken}` } : undefined;
25
- const via = { ...(settings.endpoint ? { endpoint: settings.endpoint } : {}), ...(headers ? { headers } : {}) };
26
- const credentials = settings.apiKey ? { apiKey: settings.apiKey, ...via } : { endpoint: settings.endpoint!, headers: headers! };
27
- return settings.provider === 'openai' ? openAIResponses({ ...options, ...credentials }) : anthropicMessages({ ...options, ...credentials });
28
- }
29
-
30
- /** Runtimes must allow each model explicitly, as `model:<adapter id>`. */
31
- export const modelPermission = (model: ModelAdapter): string => `model:${model.id}`;
32
-
33
- /**
34
- * A zod schema as the plain JSON Schema object a tool or provider takes. Zod attaches non-enumerable metadata and
35
- * Mayura accepts only plain JSON, so the result is round-tripped through JSON; `$schema` is dropped for providers.
36
- */
37
- export function jsonSchema(schema: z.ZodType): JsonObject {
38
- const { $schema: _dialect, ...plain } = JSON.parse(JSON.stringify(z.toJSONSchema(schema))) as JsonObject;
39
- return plain;
40
- }
@@ -1,20 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2023",
4
- "module": "NodeNext",
5
- "moduleResolution": "NodeNext",
6
- "lib": ["ES2023", "DOM", "DOM.Iterable"],
7
- "strict": true,
8
- "noUncheckedIndexedAccess": true,
9
- "exactOptionalPropertyTypes": true,
10
- "noUnusedLocals": true,
11
- "noUnusedParameters": true,
12
- "verbatimModuleSyntax": true,
13
- "skipLibCheck": false,
14
- "sourceMap": true,
15
- "rootDir": ".",
16
- "outDir": "dist",
17
- "types": ["node"]
18
- },
19
- "include": ["src/**/*.ts", "test/**/*.ts"]
20
- }
@@ -1,12 +0,0 @@
1
- FROM node:24.14.1-bookworm-slim
2
- WORKDIR /app
3
- RUN apt-get update && apt-get install -y --no-install-recommends python3 make g++ && rm -rf /var/lib/apt/lists/*
4
- COPY package.json ./
5
- RUN npm install --no-audit --no-fund
6
- COPY . .
7
- ENV NEXT_TELEMETRY_DISABLED=1 NUXT_TELEMETRY_DISABLED=1
8
- RUN npm run build && mkdir -p /app/.data && chown node:node /app/.data
9
- ENV NODE_ENV=production HOST=0.0.0.0 PORT=3000 NITRO_HOST=0.0.0.0 NITRO_PORT=3000
10
- USER node
11
- EXPOSE 3000
12
- CMD ["npm", "start"]
@@ -1,19 +0,0 @@
1
- services:
2
- web:
3
- build: .
4
- ports: ["127.0.0.1:3000:3000"]
5
- env_file: .env
6
- environment:
7
- MAYURA_SQLITE_PATH: /app/.data/notebook.sqlite
8
- volumes: ["notebook:/app/.data"]
9
- restart: unless-stopped
10
- worker:
11
- build: .
12
- command: ["npm", "run", "worker"]
13
- env_file: .env
14
- environment:
15
- MAYURA_SQLITE_PATH: /app/.data/notebook.sqlite
16
- volumes: ["notebook:/app/.data"]
17
- restart: unless-stopped
18
- volumes:
19
- notebook:
@@ -1,11 +0,0 @@
1
- node_modules
2
- .env
3
- .env.*
4
- .data
5
- .git
6
- build
7
- dist
8
- .next
9
- .output
10
- .nuxt
11
- .svelte-kit
@@ -1,7 +0,0 @@
1
- MAYURA_PUBLIC_ORIGIN=http://localhost:3000
2
- MAYURA_PROJECT_ID=notebook
3
- # Explicit token SHA-256, principal and absolute expiry; never a browser-provided project/principal.
4
- MAYURA_SESSIONS_JSON=[]
5
- MAYURA_SQLITE_PATH=.data/notebook.sqlite
6
- # For replicas/serverless, replace SQLite with a shared persistent database:
7
- # DATABASE_URL=postgresql://...
@@ -1,9 +0,0 @@
1
- import { randomBytes, createHash } from 'node:crypto';
2
- import { mkdir, writeFile } from 'node:fs/promises';
3
- // Local single-user setup only. Secrets go to owner-readable ignored files, never logs or browser bundles.
4
- const token = randomBytes(32).toString('hex');
5
- const sessions = [{ tokenSha256: createHash('sha256').update(token).digest('hex'), principalId: 'local-user', expiresAtMs: Date.now() + 8 * 3600000 }];
6
- await mkdir('.data', { recursive: true });
7
- await writeFile('.env', `MAYURA_PUBLIC_ORIGIN=http://localhost:3000\nMAYURA_PROJECT_ID=notebook\nMAYURA_SESSIONS_JSON='${JSON.stringify(sessions)}'\n`, { flag: 'wx', mode: 0o600 });
8
- await writeFile('.data/login-token', token, { flag: 'wx', mode: 0o600 });
9
- console.log('Local session created. Open .data/login-token and enter it in the notebook. Restart the server after changing identities.');
@@ -1,74 +0,0 @@
1
- import { defineAgent, defineTool, z } from 'mayura';
2
- import { createAgentServer } from 'mayura/server';
3
- import { createAggregateRunRecords } from 'mayura/storage-contracts';
4
- import { identityDirectory, agentId } from './auth.mjs';
5
- import { workflowServices } from './workflows.mjs';
6
-
7
- /** All adapters, including edge hosts, receive the same persistent store and host-verified identity directory. */
8
- export async function createApplication({ store, publicOrigin, projectId, sessions, modelOverride }) {
9
- const origin = new URL(publicOrigin);
10
- if (origin.origin !== publicOrigin || !(origin.protocol === 'https:' || origin.protocol === 'http:' && ['127.0.0.1', 'localhost', '[::1]'].includes(origin.hostname))) throw new Error('Invalid public origin.');
11
- const directory = identityDirectory(projectId, sessions);
12
- await store.initialize(); await store.threads.initialize();
13
- const workflows = directory.scopes.map(scope => workflowServices(store, scope));
14
- const save = defineTool({ id: 'notes.save', version: '1', description: 'Save this note and schedule local indexing after your approval.',
15
- input: z.object({ text: z.string().trim().min(1).max(2000) }).strict(), output: z.object({ saved: z.literal(true), noteId: z.string() }).strict(),
16
- effects: 'write', capabilities: ['notes:write'], approval: 'required', costMicros: 0, timeoutMs: 5000,
17
- execute: async ({ text }, context) => {
18
- context.signal.throwIfAborted(); const scope = context.scope;
19
- const index = directory.scopes.findIndex(item => item.principalId === scope.principalId && item.projectId === scope.projectId);
20
- if (index < 0) throw new Error('Scope refused.');
21
- const noteId = `${context.runId}:${context.callId}`;
22
- // Effect-local idempotency is still needed: a checkpoint is not an external-effect transaction.
23
- await store.create({ scope: JSON.stringify([scope.principalId, scope.projectId, 'notes']), id: noteId, idempotencyKey: noteId,
24
- definitionHash: 'notebook-note-v1', state: { text }, events: [{ type: 'note.saved', data: { text } }] });
25
- await workflows[index].host.runtime.submit(workflows[index].definition, { idempotencyKey: noteId, input: { noteId } });
26
- return { saved: true, noteId };
27
- } });
28
- // Deterministic fixture: no provider key or paid model request. One approval-required write per submitted turn.
29
- const model = modelOverride ?? Object.freeze({ id: 'notebook.fixture', maxCostMicros: 0, capabilities: { tools: true, structuredOutput: true, history: true },
30
- async generate(request) {
31
- request.signal.throwIfAborted();
32
- const result = request.messages.findLast(item => item.role === 'tool');
33
- if (result) return { type: 'final', output: { reply: result.result?.saved === true ? 'Saved after your approval. Indexing is queued.' : 'The note was not saved.' }, usage: { costMicros: 0 } };
34
- const input = request.messages.find(item => item.role === 'user')?.content;
35
- return { type: 'tool_calls', calls: [{ id: crypto.randomUUID(), toolId: save.id, input: { text: input.message } }], usage: { costMicros: 0 } };
36
- } });
37
- const agent = defineAgent({ id: agentId, version: '1', instructions: 'Propose one note write, then report its approved result.',
38
- input: z.object({ message: z.string().trim().min(1).max(2000) }).strict(), output: z.object({ reply: z.string() }).strict(), tools: [save], model });
39
- const server = createAgentServer({ publicOrigin, mounted: true, agents: [{ agent,
40
- permissions: { allow: [`model:${model.id}`, 'tool:notes.save', 'notes:write', 'effect:write'] },
41
- limits: { maxCostMicros: 0, maxSteps: 3, maxModelCalls: 2, maxToolCalls: 1, maxDurationMs: 10000 } }],
42
- authenticate: directory.authenticate, threads: { store }, runRecords: createAggregateRunRecords(store), runExecution: 'request',
43
- conversationRecovery: { permissions: { allow: ['conversations:recover'] }, pageSize: 25,
44
- authorize: async ({ scope, agentId: requested, signal }) => !signal.aborted && requested === agentId && directory.scopes.some(item => item.principalId === scope.principalId && item.projectId === scope.projectId) },
45
- limits: { maxRuns: 128, maxRuntimes: 32, maxRequests: 32, maxStreams: 16, maxBodyBytes: 16384, maxResponseBytes: 1048576,
46
- requestTimeoutMs: 15000, streamDurationMs: 5000, runRecordPollMs: 100 } });
47
- let recoveryCursor; let closed = false; let recovering;
48
- return Object.freeze({ server, store, workflows,
49
- async fetch(request) {
50
- const url = new URL(request.url); const prefix = '/api/mayura';
51
- if (!url.pathname.startsWith(`${prefix}/`)) return new Response('Not found', { status: 404 });
52
- url.pathname = url.pathname.slice(prefix.length);
53
- return server.fetch(new Request(url, request));
54
- },
55
- async runOnce() {
56
- if (closed) throw new Error('Application closed.');
57
- if (recovering) return recovering;
58
- recovering = (async () => {
59
- const recovery = await server.recoverConversations({ limit: 25, ...(recoveryCursor ? { after: recoveryCursor } : {}) });
60
- recoveryCursor = recovery.next ?? undefined;
61
- const reports = []; for (const item of workflows) reports.push(await item.worker.runOnce({ budgetMs: 1000 }));
62
- if (recovery.outcomes.some(item => item.status === 'retry') || reports.some(item => item.failures.length)) throw new Error('Background work needs attention.');
63
- return { recovered: recovery.outcomes.length, scopes: reports.length };
64
- })();
65
- try { return await recovering; } finally { recovering = undefined; }
66
- },
67
- async close() {
68
- if (closed) return; closed = true;
69
- await recovering?.catch(() => undefined); await server.close();
70
- for (const item of workflows) { await item.worker.drain(); await item.host.close(); }
71
- await store.close();
72
- },
73
- });
74
- }
@@ -1,24 +0,0 @@
1
- import { sha256Hex } from 'mayura/core/host';
2
-
3
- export const agentId = 'notebook.assistant';
4
- export const capabilities = Object.freeze(['runs:read', 'runs:submit', 'runs:cancel', 'runs:approve', 'threads:read', 'threads:write']);
5
- /** Snapshot a bounded host-owned identity directory. Browser claims never set scope or capabilities. */
6
- export function identityDirectory(projectId, sessions) {
7
- if (!/^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/u.test(projectId) || !Array.isArray(sessions) || !sessions.length || sessions.length > 32) throw new Error('Invalid identity configuration.');
8
- const seen = new Set();
9
- const entries = sessions.map(item => {
10
- if (!item || Object.keys(item).some(key => !['tokenSha256', 'principalId', 'expiresAtMs'].includes(key))
11
- || !/^[a-f0-9]{64}$/u.test(item.tokenSha256) || seen.has(item.tokenSha256)
12
- || typeof item.principalId !== 'string' || !/^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/u.test(item.principalId)
13
- || !Number.isSafeInteger(item.expiresAtMs) || item.expiresAtMs < 1) throw new Error('Invalid identity configuration.');
14
- seen.add(item.tokenSha256);
15
- return Object.freeze({ ...item, scope: Object.freeze({ principalId: item.principalId, projectId }) });
16
- });
17
- const scopes = [...new Map(entries.map(item => [item.principalId, item.scope])).values()];
18
- return Object.freeze({ scopes: Object.freeze(scopes), authenticate: async ({ token, signal }) => {
19
- if (signal.aborted || typeof token !== 'string' || !/^[a-f0-9]{64}$/u.test(token)) return null;
20
- const digest = await sha256Hex(token); if (signal.aborted) return null;
21
- const entry = entries.find(item => item.tokenSha256 === digest);
22
- return entry && entry.expiresAtMs > Date.now() ? { scope: entry.scope, agentIds: [agentId], capabilities, expiresAtMs: entry.expiresAtMs } : null;
23
- } });
24
- }
@@ -1,11 +0,0 @@
1
- import { application } from './node.mjs';
2
- // A separate bounded worker process; runOnce is also available to a trusted scheduler. No public cron endpoint.
3
- const app = await application(); let stopping = false; let timer; let active;
4
- async function cycle() {
5
- try { await app.runOnce(); } catch { console.error('Notebook background work needs attention.'); }
6
- finally { if (!stopping) timer = setTimeout(() => { active = cycle(); }, 1000); }
7
- }
8
- async function stop() { if (stopping) return; stopping = true; clearTimeout(timer); await active; await app.close(); }
9
- process.once('SIGINT', () => void stop()); process.once('SIGTERM', () => void stop());
10
- console.log(JSON.stringify({ event: 'worker-started' }));
11
- active = cycle();
@@ -1,23 +0,0 @@
1
- import { defineTool, z } from 'mayura';
2
- import { createWorkflowLeadership, createWorkflowWorker } from 'mayura/workflows';
3
- import { defineWorkflowLifecycle, createWorkflowLifecycleHost } from 'mayura/workflows/lifecycle';
4
-
5
- /** Durable no-network indexing fixture; replace its effect with an idempotent integration before production use. */
6
- export function workflowServices(store, scope) {
7
- const input = z.object({ noteId: z.string().min(1).max(256) }).strict();
8
- const index = defineTool({ id: 'notes.index', version: '1', description: 'Index an approved local note.', input,
9
- output: z.object({ indexed: z.literal(true) }).strict(), effects: 'write', capabilities: ['notes:index'], costMicros: 0,
10
- execute: async ({ noteId }, context) => {
11
- context.signal.throwIfAborted();
12
- if (context.scope.principalId !== scope.principalId || context.scope.projectId !== scope.projectId) throw new Error('Scope refused.');
13
- await store.create({ scope: JSON.stringify([scope.principalId, scope.projectId, 'note-index']), id: noteId, idempotencyKey: noteId,
14
- definitionHash: 'notebook-index-v1', state: { indexed: true }, events: [{ type: 'note.indexed', data: { noteId } }] });
15
- return { indexed: true };
16
- } });
17
- const definition = defineWorkflowLifecycle({ id: 'notes.follow-up', version: '1', input, output: z.object({ indexed: z.literal(true) }).strict(),
18
- nodes: [{ kind: 'tool', id: 'index', tool: index, input: { kind: 'input', path: [] } }], result: { kind: 'step', stepId: 'index', path: [] } });
19
- const host = createWorkflowLifecycleHost({ store, scope, definitions: [definition], policyVersion: '1', maxCostMicros: 0,
20
- permissions: { allow: ['tool:notes.index', 'notes:index', 'effect:write'] }, intervalMs: 1000, maxPagesPerCycle: 1, pageLimit: 10 });
21
- const worker = createWorkflowWorker({ units: [host], leadership: createWorkflowLeadership({ store, scope, role: 'notebook-worker', holderId: crypto.randomUUID() }) });
22
- return Object.freeze({ definition, host, worker });
23
- }
@@ -1,57 +0,0 @@
1
- import { createElement as h, useEffect, useState, useSyncExternalStore } from 'react';
2
- import { useMayuraRun, useMayuraRunApprovalCommand } from 'mayura/client-react';
3
- import { ThreadHistory as MayuraThreadHistory } from './components/mayura/thread-history';
4
- import { Approval as MayuraRunApprovalControl } from './components/mayura/approval';
5
- import { ThreadList } from './components/mayura/thread-list';
6
-
7
- const ignore = promise => { void promise.catch(() => {}); };
8
- function ApprovalPanel({ controller, session }) {
9
- const state = useMayuraRunApprovalCommand(controller); const [nowMs, setNowMs] = useState(Date.now);
10
- // This is application policy, not a side effect of the reusable approval component.
11
- useEffect(() => { const timer = setInterval(() => setNowMs(Date.now()), 1_000); return () => clearInterval(timer); }, []);
12
- return h('aside', { 'aria-label': 'Review note before saving' },
13
- h('h2', null, 'Review before saving'), h(MayuraRunApprovalControl, { controller, nowMs, subject: 'this note' }),
14
- ['failed', 'conflict'].includes(state.status) ? h('button', { type: 'button', onClick: () => ignore(session.reconnect()) }, 'Refresh approval') : null);
15
- }
16
- function ActiveRun({ store, controller, session, canCancel }) {
17
- const state = useMayuraRun(store);
18
- return h('section', { 'aria-label': 'Current turn' },
19
- h('p', { role: 'status' }, `Run ${state.snapshot?.status ?? state.connection}`),
20
- state.snapshot?.status === 'waiting' && controller ? h(ApprovalPanel, { controller, session }) : null,
21
- canCancel ? h('button', { type: 'button', onClick: () => ignore(session.cancel()) }, 'Cancel current run') : null);
22
- }
23
- /** The app owns transport/session lifecycle; the library's history and approval components remain inert on mount. */
24
- export function ChatApp({ session, threads }) {
25
- const state = useSyncExternalStore(session.subscribe, session.getSnapshot, session.getSnapshot);
26
- const [message, setMessage] = useState(() => session.getSnapshot().runId || session.getSnapshot().hasPending ? '' : 'Remember to send the release notes.');
27
- const canSend = state.phase === 'ready' && !state.busy && !state.hasPending && !state.runId;
28
- const send = async event => {
29
- event.preventDefault(); if (!canSend || !message.trim()) return;
30
- try { await session.send(message); setMessage(''); } catch { /* Session feedback retains the draft and exact retry key. */ }
31
- };
32
- return h('div', { className: 'chat' },
33
- h('header', null, h('p', { className: 'eyebrow' }, 'MAYURA / NOTEBOOK'), h('h1', null, 'A note, with your approval.'),
34
- h('p', null, 'Send a message. Review the proposed note write. Approve it, reject it, or cancel the run.'),
35
- h('p', { className: 'demo-note' }, 'Deterministic demo adapter · no model API key · no external effects')),
36
- h(ThreadList, { store: threads, onSelect: threadId => { if (canSend) ignore(session.selectThread(threadId)); } }),
37
- h('nav', { 'aria-label': 'Conversation actions' },
38
- h('button', { type: 'button', onClick: () => ignore(threads.refresh()) }, 'Refresh conversations'),
39
- h('button', { type: 'button', disabled: !canSend, onClick: () => ignore(session.newThread()) }, 'New chat'),
40
- h('button', { type: 'button', disabled: state.busy || ['opening', 'submitting', 'idle'].includes(state.phase), onClick: () => ignore(session.reconnect()) }, 'Reconnect / refresh')),
41
- state.errorCode ? h('p', { role: 'alert' }, `Chat needs attention (${state.errorCode}). Reconnect to inspect the run; decisions are never retried automatically.`) : null,
42
- ['THREAD_NOT_FOUND', 'RUN_NOT_FOUND'].includes(state.errorCode) ? h('button', { type: 'button', onClick: () => ignore(session.forgetMissing()) }, 'Forget missing chat') : null,
43
- state.hasPending ? h('section', { 'aria-label': 'Unconfirmed submission' },
44
- h('p', null, 'This send has not been confirmed. Retry uses the same message and idempotency key.'),
45
- h('button', { type: 'button', disabled: state.busy || state.phase === 'submitting', onClick: () => ignore(session.retrySubmission()) }, 'Retry last send')) : null,
46
- state.threadStore ? h(MayuraThreadHistory, { store: state.threadStore,
47
- onLoadEarlier: page => ignore(session.refreshHistory(page)), onLoadLater: page => ignore(session.refreshHistory(page)) })
48
- : h('p', { role: 'status' }, 'Opening your conversation…'),
49
- state.message ? h('section', { 'aria-label': 'Current message' }, h('h2', null, 'You'), h('p', { className: 'message' }, state.message)) : null,
50
- state.runStore ? h(ActiveRun, { store: state.runStore, controller: state.approval, session, canCancel: Boolean(state.runId) && !state.busy }) : null,
51
- h('form', { onSubmit: send, 'aria-label': 'Send a message' },
52
- h('label', { htmlFor: 'chat-message' }, 'Message'),
53
- h('textarea', { id: 'chat-message', value: message, maxLength: 2_000, rows: 3, disabled: !canSend,
54
- onChange: event => setMessage(event.target.value), placeholder: 'Write a note to save…' }),
55
- h('button', { type: 'submit', disabled: !canSend || !message.trim() }, 'Send message')),
56
- h('footer', null, 'Reload this page while a run is waiting to recover its approval. Notes and approvals use the configured database. Run the background worker to process indexing and recovery.'));
57
- }
@@ -1,25 +0,0 @@
1
- "use client";
2
- import { createElement as h, useEffect, useRef, useState } from 'react';
3
- import { createHeadlessThreadsStore } from 'mayura/client/headless';
4
- import { connectNotebook } from './connect.js';
5
- import { ChatApp } from './ChatApp.jsx';
6
-
7
- /** Inert on render. Login is explicit; unmount disposes observers, never cancelling remote writes implicitly. */
8
- export default function Notebook() {
9
- const [token, setToken] = useState(''); const [active, setActive] = useState(null); const [error, setError] = useState(''); const [busy, setBusy] = useState(false);
10
- const current = useRef(null); const mounted = useRef(true); const connecting = useRef(false);
11
- useEffect(() => { mounted.current = true; return () => { mounted.current = false; current.current?.session.dispose(); current.current?.threads.dispose(); }; }, []);
12
- async function login(event) {
13
- event.preventDefault(); if (connecting.current) return; connecting.current = true; setBusy(true); setError('');
14
- try {
15
- const next = await connectNotebook(token); if (!mounted.current) { next.session.dispose(); return; }
16
- const threads = createHeadlessThreadsStore({ client: next.client }); current.current = { ...next, threads }; setToken(''); setActive(current.current);
17
- await Promise.all([next.session.open(), threads.refresh()]);
18
- } catch { if (mounted.current) setError('Connection needs attention. Check your session or inspect the conversation before retrying.'); }
19
- finally { connecting.current = false; if (mounted.current) setBusy(false); }
20
- }
21
- function logout() { current.current?.session.dispose(); current.current?.threads.dispose(); current.current = null; setActive(null); }
22
- return h('main', null, active ? h('div', null, h('button', { type: 'button', onClick: logout }, 'Disconnect'), h(ChatApp, { session: active.session, threads: active.threads })) :
23
- h('section', null, h('p', { className: 'eyebrow' }, 'MAYURA / NOTEBOOK'), h('h1', null, 'Your words. Your decision.'), h('p', null, 'Connect with your private session token. Every note waits for your approval.'),
24
- h('form', { onSubmit: login }, h('label', null, 'Session token', h('input', { type: 'password', value: token, autoComplete: 'off', maxLength: 64, required: true, onChange: event => setToken(event.target.value) })), h('button', { disabled: busy, type: 'submit' }, busy ? 'Connecting…' : 'Connect'))), error ? h('p', { role: 'alert' }, error) : null);
25
- }