mayura 1.2.1 → 1.3.0
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.
- package/README.md +4 -4
- package/docs/README.md +22 -5
- package/docs/cli/init.md +15 -3
- package/docs/guides/authentication.md +3 -1
- package/docs/guides/browsers.md +1 -0
- package/docs/guides/choosing-a-starter.md +83 -0
- package/docs/guides/copy-in-ui.md +36 -4
- package/docs/guides/framework-starters.md +7 -2
- package/docs/guides/hono.md +94 -0
- package/docs/guides/nextjs.md +94 -0
- package/docs/guides/nuxt.md +94 -0
- package/docs/guides/rag-deployment.md +49 -0
- package/docs/guides/rag-modal-pinecone-starter.md +65 -0
- package/docs/guides/rag-production.md +34 -15
- package/docs/guides/rag-quickstart.md +119 -0
- package/docs/guides/rag.md +11 -1
- package/docs/guides/react-router.md +94 -0
- package/docs/guides/release-readiness.md +98 -39
- package/docs/guides/sandboxes.md +1 -1
- package/docs/guides/server-and-client.md +8 -3
- package/docs/guides/sveltekit.md +94 -0
- package/docs/guides/tanstack-start.md +94 -0
- package/docs/integrations/browser-stagehand.md +5 -1
- package/docs/integrations/reranker-cohere.md +1 -0
- package/docs/integrations/reranker-jina.md +1 -0
- package/docs/integrations/reranker-voyage.md +1 -0
- package/docs/integrations/sandbox-codesandbox.md +4 -0
- package/docs/integrations/ui.md +82 -0
- package/docs/integrations/vector-chroma.md +1 -0
- package/docs/integrations/vector-libsql.md +1 -0
- package/docs/integrations/vector-pgvector.md +1 -0
- package/docs/integrations/vector-pinecone.md +4 -1
- package/docs/integrations/vector-qdrant.md +1 -0
- package/docs/integrations/vector-weaviate.md +1 -0
- package/docs/introduction.md +5 -0
- package/docs/project/changelog.md +48 -0
- package/docs/project/whats-new.md +79 -2
- package/docs/quickstart.md +5 -3
- package/docs/reference/integrations.md +11 -3
- package/lib/adapter-code-docker/image/Dockerfile +1 -1
- package/lib/adapter-code-docker/package.json +1 -1
- package/lib/adapter-code-quickjs/package.json +1 -1
- package/lib/adapter-mcp/package.json +1 -1
- package/lib/ag-ui/package.json +1 -1
- package/lib/artifacts/package.json +1 -1
- package/lib/auth/dist/identity.d.ts +2 -5
- package/lib/auth/dist/identity.d.ts.map +1 -1
- package/lib/auth/dist/identity.js.map +1 -1
- package/lib/auth/package.json +1 -1
- package/lib/auth/src/identity.ts +3 -3
- package/lib/authz/package.json +1 -1
- package/lib/browser/package.json +1 -1
- package/lib/cli/dist/deploy-targets.js +1 -1
- package/lib/cli/dist/deploy-targets.js.map +1 -1
- package/lib/cli/dist/index.d.ts +1 -1
- package/lib/cli/dist/index.d.ts.map +1 -1
- package/lib/cli/dist/index.js +63 -20
- package/lib/cli/dist/index.js.map +1 -1
- package/lib/cli/dist/interactive.js +2 -2
- package/lib/cli/dist/interactive.js.map +1 -1
- package/lib/cli/package.json +1 -1
- package/lib/cli/src/deploy-targets.ts +1 -1
- package/lib/cli/src/index.ts +51 -12
- package/lib/cli/src/interactive.ts +2 -2
- package/lib/cli/starter-assets/manifest.json +1 -0
- package/lib/cli/starters/hono/package.json +2 -2
- package/lib/cli/starters/rag-modal-pinecone/README.md +60 -0
- package/lib/cli/starters/rag-modal-pinecone/dot-env.example +23 -0
- package/lib/cli/starters/{event-automation → rag-modal-pinecone}/dot-gitignore +2 -4
- package/lib/cli/starters/rag-modal-pinecone/fixtures/on-call.md +4 -0
- package/lib/cli/starters/rag-modal-pinecone/mayura.project.json +13 -0
- package/lib/cli/starters/rag-modal-pinecone/modal-app.py +110 -0
- package/lib/cli/starters/rag-modal-pinecone/package.json +28 -0
- package/lib/cli/starters/rag-modal-pinecone/src/application.ts +148 -0
- package/lib/cli/starters/rag-modal-pinecone/src/cli.ts +78 -0
- package/lib/cli/starters/rag-modal-pinecone/src/hosted.ts +137 -0
- package/lib/cli/starters/rag-modal-pinecone/test/modal_worker_test.py +53 -0
- package/lib/cli/starters/rag-modal-pinecone/test/pipeline.test.ts +137 -0
- package/lib/cli/starters/{cli-agent → rag-modal-pinecone}/tsconfig.json +0 -1
- package/lib/cli/starters/support-agent/src/dev-request.ts +18 -0
- package/lib/cli/starters/support-agent/src/dev.ts +7 -4
- package/lib/cli/starters/support-agent/test/dev-request.test.ts +19 -0
- package/lib/client/dist/index.js +2 -2
- package/lib/client/dist/index.js.map +1 -1
- package/lib/client/package.json +1 -1
- package/lib/client/src/index.ts +2 -2
- package/lib/client-react/package.json +1 -1
- package/lib/code-mode/package.json +1 -1
- package/lib/code-mode-workflows/package.json +1 -1
- package/lib/context/package.json +1 -1
- package/lib/core/package.json +1 -1
- package/lib/exporter-otlp/dist/otlp-http-json.js +1 -1
- package/lib/exporter-otlp/dist/otlp-http-json.js.map +1 -1
- package/lib/exporter-otlp/dist/signals.js +2 -2
- package/lib/exporter-otlp/dist/signals.js.map +1 -1
- package/lib/exporter-otlp/package.json +1 -1
- package/lib/exporter-otlp/src/otlp-http-json.ts +1 -1
- package/lib/exporter-otlp/src/signals.ts +2 -2
- package/lib/files/dist/store.d.ts.map +1 -1
- package/lib/files/dist/store.js +15 -2
- package/lib/files/dist/store.js.map +1 -1
- package/lib/files/package.json +1 -1
- package/lib/files/src/store.ts +15 -2
- package/lib/guardrails/package.json +1 -1
- package/lib/helpers/package.json +1 -1
- package/lib/keys/dist/manager.d.ts +1 -4
- package/lib/keys/dist/manager.d.ts.map +1 -1
- package/lib/keys/dist/manager.js +6 -4
- package/lib/keys/dist/manager.js.map +1 -1
- package/lib/keys/dist/verifier.d.ts +2 -1
- package/lib/keys/dist/verifier.d.ts.map +1 -1
- package/lib/keys/dist/verifier.js +2 -2
- package/lib/keys/dist/verifier.js.map +1 -1
- package/lib/keys/package.json +1 -1
- package/lib/keys/src/manager.ts +8 -6
- package/lib/keys/src/verifier.ts +4 -4
- package/lib/memory/package.json +1 -1
- package/lib/memory-remote/package.json +1 -1
- package/lib/observability/package.json +1 -1
- package/lib/provider-anthropic/package.json +1 -1
- package/lib/provider-openai/package.json +1 -1
- package/lib/rag/package.json +1 -1
- package/lib/runtime/package.json +1 -1
- package/lib/sandbox/package.json +1 -1
- package/lib/sdk/package.json +1 -1
- package/lib/server/dist/index.d.ts +2 -1
- package/lib/server/dist/index.d.ts.map +1 -1
- package/lib/server/dist/index.js +29 -24
- package/lib/server/dist/index.js.map +1 -1
- package/lib/server/dist/inspector-bundle.d.ts +1 -1
- package/lib/server/dist/inspector-bundle.d.ts.map +1 -1
- package/lib/server/dist/inspector-bundle.js +4 -4
- package/lib/server/dist/inspector-bundle.js.map +1 -1
- package/lib/server/package.json +1 -1
- package/lib/server/src/index.ts +26 -20
- package/lib/server/src/inspector-bundle.ts +4 -4
- package/lib/server-node/package.json +1 -1
- package/lib/skills/package.json +1 -1
- package/lib/storage/package.json +1 -1
- package/lib/storage-contracts/package.json +1 -1
- package/lib/storage-postgres/package.json +1 -1
- package/lib/storage-sql/package.json +1 -1
- package/lib/storage-sqlite/package.json +1 -1
- package/lib/terminal/package.json +1 -1
- package/lib/testing/package.json +1 -1
- package/lib/threads/package.json +1 -1
- package/lib/tools/package.json +1 -1
- package/lib/voice/package.json +1 -1
- package/lib/workflows/package.json +1 -1
- package/lib/workstream/package.json +1 -1
- package/llms-full.txt +1595 -292
- package/llms.txt +23 -5
- package/package.json +4 -4
- package/lib/cli/starters/cli-agent/dot-github/workflows/ci.yml +0 -13
- package/lib/cli/starters/cli-agent/dot-gitignore +0 -10
- package/lib/cli/starters/event-automation/dot-dockerignore +0 -7
- package/lib/cli/starters/event-automation/dot-github/workflows/ci.yml +0 -13
- package/lib/cli/starters/event-automation/src/model.ts +0 -40
- package/lib/cli/starters/event-automation/tsconfig.json +0 -20
- package/lib/cli/starters/nextjs/Dockerfile +0 -12
- package/lib/cli/starters/nextjs/compose.yaml +0 -19
- package/lib/cli/starters/nextjs/dot-dockerignore +0 -11
- package/lib/cli/starters/nextjs/dot-env.example +0 -7
- package/lib/cli/starters/nextjs/scripts/setup.mjs +0 -9
- package/lib/cli/starters/nextjs/server/application.mjs +0 -74
- package/lib/cli/starters/nextjs/server/auth.mjs +0 -24
- package/lib/cli/starters/nextjs/server/worker.mjs +0 -11
- package/lib/cli/starters/nextjs/server/workflows.mjs +0 -23
- package/lib/cli/starters/nextjs/src/ChatApp.jsx +0 -57
- package/lib/cli/starters/nextjs/src/Notebook.jsx +0 -25
- package/lib/cli/starters/nextjs/src/components/mayura/approval.tsx +0 -142
- package/lib/cli/starters/nextjs/src/components/mayura/thread-history.tsx +0 -142
- package/lib/cli/starters/nextjs/src/components/mayura/thread-list.tsx +0 -9
- package/lib/cli/starters/nextjs/src/components/mayura/ui.css +0 -14
- package/lib/cli/starters/nextjs/src/connect.js +0 -21
- package/lib/cli/starters/nextjs/src/session.js +0 -138
- package/lib/cli/starters/nextjs/src/style.css +0 -11
- package/lib/cli/starters/nextjs/test/server.test.mjs +0 -95
- package/lib/cli/starters/nextjs/test/session.test.mjs +0 -16
- package/lib/cli/starters/nuxt/compose.yaml +0 -19
- package/lib/cli/starters/nuxt/dot-dockerignore +0 -11
- package/lib/cli/starters/nuxt/dot-env.example +0 -7
- package/lib/cli/starters/nuxt/dot-gitignore +0 -14
- package/lib/cli/starters/nuxt/scripts/setup.mjs +0 -9
- package/lib/cli/starters/nuxt/server/application.mjs +0 -74
- package/lib/cli/starters/nuxt/server/auth.mjs +0 -24
- package/lib/cli/starters/nuxt/server/worker.mjs +0 -11
- package/lib/cli/starters/nuxt/server/workflows.mjs +0 -23
- package/lib/cli/starters/nuxt/src/connect.js +0 -21
- package/lib/cli/starters/nuxt/src/session.js +0 -138
- package/lib/cli/starters/nuxt/src/style.css +0 -11
- package/lib/cli/starters/nuxt/test/server.test.mjs +0 -95
- package/lib/cli/starters/nuxt/test/session.test.mjs +0 -16
- package/lib/cli/starters/react-router/Dockerfile +0 -12
- package/lib/cli/starters/react-router/compose.yaml +0 -19
- package/lib/cli/starters/react-router/dot-dockerignore +0 -11
- package/lib/cli/starters/react-router/dot-env.example +0 -7
- package/lib/cli/starters/react-router/dot-gitignore +0 -14
- package/lib/cli/starters/react-router/scripts/setup.mjs +0 -9
- package/lib/cli/starters/react-router/server/application.mjs +0 -74
- package/lib/cli/starters/react-router/server/auth.mjs +0 -24
- package/lib/cli/starters/react-router/server/worker.mjs +0 -11
- package/lib/cli/starters/react-router/server/workflows.mjs +0 -23
- package/lib/cli/starters/react-router/src/ChatApp.jsx +0 -57
- package/lib/cli/starters/react-router/src/Notebook.jsx +0 -25
- package/lib/cli/starters/react-router/src/components/mayura/approval.tsx +0 -142
- package/lib/cli/starters/react-router/src/components/mayura/thread-history.tsx +0 -142
- package/lib/cli/starters/react-router/src/components/mayura/thread-list.tsx +0 -9
- package/lib/cli/starters/react-router/src/components/mayura/ui.css +0 -14
- package/lib/cli/starters/react-router/src/connect.js +0 -21
- package/lib/cli/starters/react-router/src/session.js +0 -138
- package/lib/cli/starters/react-router/src/style.css +0 -11
- package/lib/cli/starters/react-router/src/vite-env.d.ts +0 -1
- package/lib/cli/starters/react-router/test/server.test.mjs +0 -95
- package/lib/cli/starters/react-router/test/session.test.mjs +0 -16
- package/lib/cli/starters/research-team/dot-dockerignore +0 -7
- package/lib/cli/starters/research-team/dot-github/workflows/ci.yml +0 -13
- package/lib/cli/starters/research-team/dot-gitignore +0 -10
- package/lib/cli/starters/research-team/src/model.ts +0 -40
- package/lib/cli/starters/research-team/tsconfig.json +0 -20
- package/lib/cli/starters/support-agent/dot-dockerignore +0 -7
- package/lib/cli/starters/support-agent/dot-github/workflows/ci.yml +0 -13
- package/lib/cli/starters/support-agent/dot-gitignore +0 -10
- package/lib/cli/starters/support-agent/src/model.ts +0 -40
- package/lib/cli/starters/support-agent/tsconfig.json +0 -20
- package/lib/cli/starters/sveltekit/Dockerfile +0 -12
- package/lib/cli/starters/sveltekit/compose.yaml +0 -19
- package/lib/cli/starters/sveltekit/dot-dockerignore +0 -11
- package/lib/cli/starters/sveltekit/dot-env.example +0 -7
- package/lib/cli/starters/sveltekit/dot-gitignore +0 -14
- package/lib/cli/starters/sveltekit/scripts/setup.mjs +0 -9
- package/lib/cli/starters/sveltekit/server/application.mjs +0 -74
- package/lib/cli/starters/sveltekit/server/auth.mjs +0 -24
- package/lib/cli/starters/sveltekit/server/worker.mjs +0 -11
- package/lib/cli/starters/sveltekit/server/workflows.mjs +0 -23
- package/lib/cli/starters/sveltekit/src/connect.js +0 -21
- package/lib/cli/starters/sveltekit/src/session.js +0 -138
- package/lib/cli/starters/sveltekit/src/style.css +0 -11
- package/lib/cli/starters/sveltekit/src/view.js +0 -49
- package/lib/cli/starters/sveltekit/test/server.test.mjs +0 -95
- package/lib/cli/starters/sveltekit/test/session.test.mjs +0 -16
- package/lib/cli/starters/tanstack-start/Dockerfile +0 -12
- package/lib/cli/starters/tanstack-start/compose.yaml +0 -19
- package/lib/cli/starters/tanstack-start/dot-dockerignore +0 -11
- package/lib/cli/starters/tanstack-start/dot-env.example +0 -7
- package/lib/cli/starters/tanstack-start/dot-gitignore +0 -14
- package/lib/cli/starters/tanstack-start/scripts/setup.mjs +0 -9
- package/lib/cli/starters/tanstack-start/server/application.mjs +0 -74
- package/lib/cli/starters/tanstack-start/server/auth.mjs +0 -24
- package/lib/cli/starters/tanstack-start/server/worker.mjs +0 -11
- package/lib/cli/starters/tanstack-start/server/workflows.mjs +0 -23
- package/lib/cli/starters/tanstack-start/src/ChatApp.jsx +0 -57
- package/lib/cli/starters/tanstack-start/src/Notebook.jsx +0 -25
- package/lib/cli/starters/tanstack-start/src/components/mayura/approval.tsx +0 -142
- package/lib/cli/starters/tanstack-start/src/components/mayura/thread-history.tsx +0 -142
- package/lib/cli/starters/tanstack-start/src/components/mayura/thread-list.tsx +0 -9
- package/lib/cli/starters/tanstack-start/src/components/mayura/ui.css +0 -14
- package/lib/cli/starters/tanstack-start/src/connect.js +0 -21
- package/lib/cli/starters/tanstack-start/src/session.js +0 -138
- package/lib/cli/starters/tanstack-start/src/style.css +0 -11
- package/lib/cli/starters/tanstack-start/test/server.test.mjs +0 -95
- package/lib/cli/starters/tanstack-start/test/session.test.mjs +0 -16
- /package/lib/cli/{starters/hono/src/components/mayura/ui.css → starter-assets/011cacc77ada0de5b447674e9fc4374a247b9a46eb169722b12649753f24188f} +0 -0
- /package/lib/cli/{starters/hono/test/server.test.mjs → starter-assets/0c825d6a776673ec6274cfc29cd45b1a8c56dcb880c291a91075c77e1ef1e4f3} +0 -0
- /package/lib/cli/{starters/hono/server/auth.mjs → starter-assets/0dd570bfacc357d23be3340250090b9a4c6193a49cdd02e9b6789e7bee8433dd} +0 -0
- /package/lib/cli/{starters/hono/src/components/mayura/approval.tsx → starter-assets/11292bd14cdaf27a8f8317ba4ab768d706a726b2e26474b599f3db116674b4b3} +0 -0
- /package/lib/cli/{starters/nextjs/dot-gitignore → starter-assets/1873b02e070347f9a449e07084242982fa6af412c45aa764985d553975b64589} +0 -0
- /package/lib/cli/{starters/hono/src/style.css → starter-assets/2f3869e6d69134e43be713c4590bfe48896a5c54ece6ffc1a4f204cfcfe54218} +0 -0
- /package/lib/cli/{starters/hono/server/worker.mjs → starter-assets/350d77757f548369beff29d658cf1620752d4e23b4b732d99a1b403ca043137f} +0 -0
- /package/lib/cli/{starters/approval-workflow/src/model.ts → starter-assets/37294d24c04b71eaf6d6f0bd52fd4c1cc7a5d3cb63da9c7920ed1d44276da9cb} +0 -0
- /package/lib/cli/{starters/approval-workflow/tsconfig.json → starter-assets/4387d6537dd5924ae62326aa3d7d8cbad1e5abd930aecc9daa6fab1ac2f6ef24} +0 -0
- /package/lib/cli/{starters/hono/dot-dockerignore → starter-assets/4434be031b58cc6ee680b2860b2ad1fe4089af7ee866c13223dfb621dd042ff1} +0 -0
- /package/lib/cli/{starters/hono/src/ChatApp.jsx → starter-assets/46e199317648a076243d6c8e7ffedc48785a6ffc0f203b88c7c4a9479b34c5b9} +0 -0
- /package/lib/cli/{starters/hono/src/components/mayura/thread-history.tsx → starter-assets/4741fccbca2e0d2fc6f61d11af3cf7bcc5f0238b67bb46282287207abdc6c536} +0 -0
- /package/lib/cli/{starters/approval-workflow/dot-dockerignore → starter-assets/4be664708b0120da5d2b73c5a27968093da06b8728f88f2bda2a1ccbf40f6891} +0 -0
- /package/lib/cli/{starters/hono/server/workflows.mjs → starter-assets/4d11f729672df54969a851494877a3c5aee24bb8f8c68eacaaa22e715bf5ed69} +0 -0
- /package/lib/cli/{starters/hono/dot-env.example → starter-assets/4f141323062660c4dc5b563300d57bb4cdbdc7fe9bfba96e43d9c64bb274474e} +0 -0
- /package/lib/cli/{starters/hono/Dockerfile → starter-assets/5471b74c46258d1edb00eb8f60f4219c389a252f7e224f2692f8f3e71ae43e3e} +0 -0
- /package/lib/cli/{starters/hono/scripts/setup.mjs → starter-assets/56e2d6db9fe4b0449c979acd06947a5b776bcc645184b54b8d3654a48bd12c38} +0 -0
- /package/lib/cli/{starters/hono/src/Notebook.jsx → starter-assets/6138d1e2ca4469daf4f5545d140943f6e23b0c37f865051b266ec99695cf181a} +0 -0
- /package/lib/cli/{starters/hono/src/vite-env.d.ts → starter-assets/65996936fbb042915f7b74a200fcdde7e410f32a669b1ab9597cfaa4b0faddb5} +0 -0
- /package/lib/cli/{starters/hono/server/application.mjs → starter-assets/757f43c27415654049ecf01b67d560c83d788108d1aebcf1f16a86d956bd7fb6} +0 -0
- /package/lib/cli/{starters/hono/src/components/mayura/thread-list.tsx → starter-assets/97601d0bf331df7bbde88f7ee269610bc8a1239f8eeb58fded6416e588a5b7dd} +0 -0
- /package/lib/cli/{starters/approval-workflow/dot-github/workflows/ci.yml → starter-assets/aa4182c76778ba2194ecbfde9a960c20181534fd1ab484df126278dbc6eb0186} +0 -0
- /package/lib/cli/{starters/hono/src/session.js → starter-assets/abcc6ebd29ba47a079befb6568054dec8f43d4c729187e4a3610af39789e77be} +0 -0
- /package/lib/cli/{starters/hono/compose.yaml → starter-assets/cc1df6f5ce0eebffc567ecea1d599eba97cd1b94ab01551085c0eb87a28e3a6c} +0 -0
- /package/lib/cli/{starters/hono/src/connect.js → starter-assets/cd3ddb959b277e7d495cc020a6f8146acfbcc9d05ececa3809e8aafcf84504d9} +0 -0
- /package/lib/cli/{starters/hono/test/session.test.mjs → starter-assets/dfe75fd07538427d80ba76767e037e929664c80ff5a41b7544496a789181bb73} +0 -0
- /package/lib/cli/{starters/approval-workflow/dot-gitignore → starter-assets/f3ef7285253ec9668732f535306beee602e91cb6e20f83d4799b3323399ce569} +0 -0
- /package/lib/cli/{starters/nuxt/src/view.js → starter-assets/ff840fe960683d377e78f731b5d4318adf6050384791fa20e4948d34192aa35d} +0 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"""Test the private worker's role and digest contract without Modal or Ollama."""
|
|
2
|
+
import importlib.util
|
|
3
|
+
import pathlib
|
|
4
|
+
import sys
|
|
5
|
+
import unittest
|
|
6
|
+
from unittest.mock import Mock, patch
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def load_worker():
|
|
10
|
+
stub = Mock()
|
|
11
|
+
stub.App.return_value.function.return_value = lambda function: function
|
|
12
|
+
path = pathlib.Path(__file__).resolve().parents[1] / "modal-app.py"
|
|
13
|
+
spec = importlib.util.spec_from_file_location("starter_worker", path)
|
|
14
|
+
module = importlib.util.module_from_spec(spec)
|
|
15
|
+
with patch.dict(sys.modules, {"modal": stub}):
|
|
16
|
+
spec.loader.exec_module(module)
|
|
17
|
+
return module
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class ModelWorkerTest(unittest.TestCase):
|
|
21
|
+
def test_image_clears_the_ollama_entrypoint_for_modal_python(self):
|
|
22
|
+
worker = load_worker()
|
|
23
|
+
worker.modal.Image.from_registry.return_value.entrypoint.assert_called_once_with([])
|
|
24
|
+
|
|
25
|
+
def test_roles_are_distinct_and_model_is_pinned(self):
|
|
26
|
+
worker = load_worker()
|
|
27
|
+
vector = [1.0] + [0.0] * 767
|
|
28
|
+
worker.server = Mock()
|
|
29
|
+
worker.server.poll.return_value = None
|
|
30
|
+
with patch.object(worker, "request", return_value={"embeddings": [vector]}) as request:
|
|
31
|
+
for role, prefix in [("document", "search_document: "), ("query", "search_query: ")]:
|
|
32
|
+
self.assertEqual(worker.embed(role, ["incident"]), {
|
|
33
|
+
"role": role, "digest": worker.DIGEST, "embeddings": [vector],
|
|
34
|
+
})
|
|
35
|
+
request.assert_called_with("/api/embed", {
|
|
36
|
+
"model": worker.MODEL, "input": [prefix + "incident"], "truncate": False, "dimensions": 768,
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
def test_invalid_role_never_calls_ollama(self):
|
|
40
|
+
worker = load_worker()
|
|
41
|
+
with patch.object(worker, "request") as request:
|
|
42
|
+
with self.assertRaises(ValueError):
|
|
43
|
+
worker.embed("untrusted", ["incident"])
|
|
44
|
+
request.assert_not_called()
|
|
45
|
+
|
|
46
|
+
def test_wrong_model_stops_the_starting_worker(self):
|
|
47
|
+
worker = load_worker()
|
|
48
|
+
with patch.object(worker, "start_ollama") as start, patch.object(worker, "stop_ollama") as stop, \
|
|
49
|
+
patch.object(worker, "request", return_value={"models": [{"name": worker.MODEL, "digest": "mismatch"}]}):
|
|
50
|
+
with self.assertRaisesRegex(RuntimeError, "do not match"):
|
|
51
|
+
worker.embed("query", ["incident"])
|
|
52
|
+
stop.assert_called_once_with(start.return_value)
|
|
53
|
+
self.assertIsNone(worker.server)
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import { mkdtemp, rm } from 'node:fs/promises';
|
|
3
|
+
import { tmpdir } from 'node:os';
|
|
4
|
+
import { join } from 'node:path';
|
|
5
|
+
import { test } from 'node:test';
|
|
6
|
+
import { openRag } from '../src/application.js';
|
|
7
|
+
import { hostedBackend, nomicDigest, readHostedSettings } from '../src/hosted.js';
|
|
8
|
+
|
|
9
|
+
const settings = readHostedSettings({
|
|
10
|
+
RAG_MODAL_ENVIRONMENT: 'test', MODAL_TOKEN_ID: 'fixture-id', MODAL_TOKEN_SECRET: 'fixture-secret',
|
|
11
|
+
RAG_MODAL_INFERENCE_TOKEN: 'fixture-inference-key', RAG_MODAL_INFERENCE_MODEL: 'fixture.us-west.modal.direct',
|
|
12
|
+
RAG_PINECONE_HOST: 'https://index.example.pinecone.io', RAG_PINECONE_API_KEY: 'fixture-pinecone-key',
|
|
13
|
+
RAG_INPUT_MICROS_PER_MILLION_TOKENS: '200000', RAG_OUTPUT_MICROS_PER_MILLION_TOKENS: '500000',
|
|
14
|
+
RAG_INFERENCE_MAX_CALL_MICROS: '10000', RAG_MODAL_EMBED_CALL_MICROS: '100', RAG_PINECONE_CALL_MICROS: '100',
|
|
15
|
+
RAG_PRINCIPAL_ID: 'operator', RAG_PROJECT_ID: 'handbook',
|
|
16
|
+
});
|
|
17
|
+
const vector = Array.from({ length: 768 }, (_, i) => Number(i === 0));
|
|
18
|
+
|
|
19
|
+
function services(options: { rejectEmbedding?: boolean; answerSources?: number[] } = {}) {
|
|
20
|
+
const namespaces = new Map<string, Map<string, { id: string; metadata: Record<string, string> }>>();
|
|
21
|
+
const calls: string[] = [];
|
|
22
|
+
const seenEvidence: string[][] = [];
|
|
23
|
+
const transport: typeof fetch = async (input, request) => {
|
|
24
|
+
const url = new URL(String(input));
|
|
25
|
+
const headers = new Headers(request?.headers);
|
|
26
|
+
const body = JSON.parse(String(request?.body));
|
|
27
|
+
if (url.origin === settings.pinecone) {
|
|
28
|
+
assert.equal(headers.get('api-key'), settings.pineconeKey);
|
|
29
|
+
assert.equal(headers.get('x-pinecone-api-version'), '2025-10');
|
|
30
|
+
assert.equal(headers.has('authorization'), false);
|
|
31
|
+
assert.match(body.namespace, /^[a-f0-9]{64}$/u);
|
|
32
|
+
calls.push(url.pathname);
|
|
33
|
+
if (url.pathname === '/vectors/upsert') {
|
|
34
|
+
const indexed = namespaces.get(body.namespace) ?? new Map();
|
|
35
|
+
for (const row of body.vectors) {
|
|
36
|
+
assert.equal(row.metadata.mayuraNamespace, body.namespace);
|
|
37
|
+
assert.deepEqual(row.values, vector);
|
|
38
|
+
indexed.set(row.id, row);
|
|
39
|
+
}
|
|
40
|
+
namespaces.set(body.namespace, indexed);
|
|
41
|
+
return Response.json({ upsertedCount: body.vectors.length });
|
|
42
|
+
}
|
|
43
|
+
assert.equal(url.pathname, '/query');
|
|
44
|
+
assert.deepEqual(body.vector, vector);
|
|
45
|
+
return Response.json({ matches: [...(namespaces.get(body.namespace)?.values() ?? [])].map(row => ({ ...row, score: 1 })) });
|
|
46
|
+
}
|
|
47
|
+
assert.equal(url.href, 'https://inference.us-west.modal.direct/v1/chat/completions');
|
|
48
|
+
assert.equal(headers.get('authorization'), 'Bearer ' + settings.inferenceToken);
|
|
49
|
+
assert.equal(headers.has('api-key'), false);
|
|
50
|
+
assert.equal(body.model, settings.inferenceModel);
|
|
51
|
+
assert.equal(body.reasoning_effort, 'none');
|
|
52
|
+
assert.deepEqual(body.chat_template_kwargs, { thinking: false });
|
|
53
|
+
assert.deepEqual(body.response_format, { type: 'json_object' });
|
|
54
|
+
const user = JSON.parse(body.messages.find((message: { role: string }) => message.role === 'user').content);
|
|
55
|
+
const documents: string[] | undefined = user.documents;
|
|
56
|
+
calls.push(documents ? 'rank' : 'answer');
|
|
57
|
+
seenEvidence.push(documents ?? user.evidence);
|
|
58
|
+
const output = documents ? { results: documents.map((_, index) => ({ index, score: 1 - index })) }
|
|
59
|
+
: { answer: 'Post within 15 minutes.', sources: options.answerSources ?? [1] };
|
|
60
|
+
return Response.json({
|
|
61
|
+
model: 'deepseek-ai/DeepSeek-V4.1-Flash-1017',
|
|
62
|
+
choices: [{ finish_reason: 'stop', message: { role: 'assistant', content: JSON.stringify(output) } }],
|
|
63
|
+
usage: { prompt_tokens: 40, completion_tokens: 20 },
|
|
64
|
+
});
|
|
65
|
+
};
|
|
66
|
+
const backend = hostedBackend(settings, async (role, texts) => {
|
|
67
|
+
calls.push('embed:' + role);
|
|
68
|
+
if (options.rejectEmbedding) throw new Error('Simulated lost acknowledgement');
|
|
69
|
+
return { role, digest: nomicDigest, embeddings: texts.map(() => vector) };
|
|
70
|
+
}, transport);
|
|
71
|
+
return { backend, calls, seenEvidence };
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
test('ingests, restarts, reranks and answers with an exact active citation through hosted protocol fixtures', async () => {
|
|
75
|
+
const directory = await mkdtemp(join(tmpdir(), 'mayura-rag-'));
|
|
76
|
+
const filename = join(directory, 'rag.sqlite');
|
|
77
|
+
const host = services();
|
|
78
|
+
const text = 'Post the incident summary within 15 minutes.';
|
|
79
|
+
let app = await openRag(filename, settings.scope, host.backend);
|
|
80
|
+
try {
|
|
81
|
+
const original = await app.ingest('incident', 'incident.md', 'The old threshold was 30 minutes.');
|
|
82
|
+
const indexed = await app.ingest('incident', 'incident.md', text);
|
|
83
|
+
assert.notEqual(indexed.revision, original.revision);
|
|
84
|
+
await app.close();
|
|
85
|
+
app = await openRag(filename, settings.scope, host.backend);
|
|
86
|
+
const unchanged = await app.ingest('incident', 'incident.md', text);
|
|
87
|
+
assert.equal(unchanged.revision, indexed.revision);
|
|
88
|
+
const same = await app.ask('When should the incident summary be posted?');
|
|
89
|
+
assert.equal(same.answer, 'Post within 15 minutes.');
|
|
90
|
+
assert.equal(same.citations.length, 1);
|
|
91
|
+
const [citation] = same.citations;
|
|
92
|
+
assert.equal(citation?.documentId, 'incident');
|
|
93
|
+
assert.equal(citation.revision, indexed.revision);
|
|
94
|
+
assert.equal(citation.reference, 'incident.md');
|
|
95
|
+
assert.match(citation.chunkId, /^[a-f0-9]{64}$/u);
|
|
96
|
+
assert.equal(text.slice(citation.start, citation.end), text);
|
|
97
|
+
assert.deepEqual(host.seenEvidence, [[text], [text]]);
|
|
98
|
+
assert.deepEqual(host.calls, ['embed:document', '/vectors/upsert', 'embed:document', '/vectors/upsert',
|
|
99
|
+
'embed:query', '/query', 'rank', 'answer']);
|
|
100
|
+
const other = await openRag(filename, { ...settings.scope, principalId: 'another-reader' }, host.backend);
|
|
101
|
+
try { assert.deepEqual(await other.ask('When is the incident summary posted?'), { answer: null, citations: [] }); }
|
|
102
|
+
finally { await other.close(); }
|
|
103
|
+
assert.deepEqual(host.calls.slice(-2), ['embed:query', '/query']);
|
|
104
|
+
} finally {
|
|
105
|
+
await app.close();
|
|
106
|
+
await rm(directory, { recursive: true, force: true });
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
test('does not disclose an answer when the model cites a passage outside the supplied list', async () => {
|
|
111
|
+
const host = services({ answerSources: [2] });
|
|
112
|
+
const app = await openRag(':memory:', settings.scope, host.backend);
|
|
113
|
+
try {
|
|
114
|
+
await app.ingest('incident', 'incident.md', 'Post the incident summary within 15 minutes.');
|
|
115
|
+
await assert.rejects(app.ask('When is the incident summary posted?'), /invalid evidence references/u);
|
|
116
|
+
} finally {
|
|
117
|
+
await app.close();
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
test('keeps an unacknowledged ingestion claim across restart without a second embedding or vector write', async () => {
|
|
122
|
+
const directory = await mkdtemp(join(tmpdir(), 'mayura-rag-'));
|
|
123
|
+
const filename = join(directory, 'rag.sqlite');
|
|
124
|
+
const host = services({ rejectEmbedding: true });
|
|
125
|
+
let app = await openRag(filename, settings.scope, host.backend);
|
|
126
|
+
try {
|
|
127
|
+
const ingest = () => app.ingest('incident', 'incident.md', 'Post the incident summary within 15 minutes.');
|
|
128
|
+
await assert.rejects(ingest(), /did not publish/u);
|
|
129
|
+
await app.close();
|
|
130
|
+
app = await openRag(filename, settings.scope, host.backend);
|
|
131
|
+
await assert.rejects(ingest(), /did not publish/u);
|
|
132
|
+
assert.deepEqual(host.calls, ['embed:document']);
|
|
133
|
+
} finally {
|
|
134
|
+
await app.close();
|
|
135
|
+
await rm(directory, { recursive: true, force: true });
|
|
136
|
+
}
|
|
137
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { RequestOptions } from 'node:http';
|
|
2
|
+
|
|
3
|
+
/** Parse a request target for the local development front server. */
|
|
4
|
+
export function devRequestTarget(value: string | undefined, origin: string): URL | undefined {
|
|
5
|
+
try {
|
|
6
|
+
const target = new URL(value ?? '/', origin);
|
|
7
|
+
if (target.origin === origin && !target.username && !target.password && !target.hash) return target;
|
|
8
|
+
} catch {
|
|
9
|
+
return undefined;
|
|
10
|
+
}
|
|
11
|
+
return undefined;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** Derive the connection from the configured server origin and use only the routed request path and query. */
|
|
15
|
+
export function devUpstreamOptions(origin: string, target: Pick<URL, 'pathname' | 'search'>): RequestOptions {
|
|
16
|
+
const { protocol, hostname, port } = new URL(origin);
|
|
17
|
+
return { protocol, hostname, port, path: target.pathname + target.search };
|
|
18
|
+
}
|
|
@@ -8,6 +8,7 @@ import { MayuraError } from 'mayura/core';
|
|
|
8
8
|
import { createNativeMemory } from 'mayura/memory';
|
|
9
9
|
import { customerPrincipal, devSecrets, tokenDigest } from './auth.js';
|
|
10
10
|
import { loadConfig } from './config.js';
|
|
11
|
+
import { devRequestTarget, devUpstreamOptions } from './dev-request.js';
|
|
11
12
|
import { demoCustomers } from './orders.js';
|
|
12
13
|
import { startServer } from './server.js';
|
|
13
14
|
import { openServices } from './services.js';
|
|
@@ -60,9 +61,9 @@ async function serveFile(pathname: string, response: ServerResponse): Promise<vo
|
|
|
60
61
|
}
|
|
61
62
|
|
|
62
63
|
/** Forward one API request (including the streamed run events) to the Mayura server, unchanged but for the host. */
|
|
63
|
-
function proxy(request: IncomingMessage, response: ServerResponse): void {
|
|
64
|
+
function proxy(request: IncomingMessage, response: ServerResponse, target: URL): void {
|
|
64
65
|
const headers = { ...request.headers }; delete headers.host; delete headers.connection;
|
|
65
|
-
const upstream = forward(
|
|
66
|
+
const upstream = forward({ ...devUpstreamOptions(server.origin, target), method: request.method, headers }, reply => {
|
|
66
67
|
response.writeHead(reply.statusCode ?? 502, reply.headers); reply.pipe(response);
|
|
67
68
|
});
|
|
68
69
|
upstream.on('error', () => { if (!response.headersSent) response.writeHead(502).end(); else response.destroy(); });
|
|
@@ -84,9 +85,11 @@ async function session(request: IncomingMessage, response: ServerResponse): Prom
|
|
|
84
85
|
}
|
|
85
86
|
|
|
86
87
|
const web = createServer((request, response) => {
|
|
87
|
-
const { pathname } = new URL(request.url ?? '/', webOrigin);
|
|
88
88
|
const handle = async (): Promise<void> => {
|
|
89
|
-
|
|
89
|
+
const target = devRequestTarget(request.url, webOrigin);
|
|
90
|
+
if (!target) { response.writeHead(400, security).end(); return; }
|
|
91
|
+
const { pathname } = target;
|
|
92
|
+
if (pathname.startsWith('/v1/')) return proxy(request, response, target);
|
|
90
93
|
if (pathname === '/dev/customers' && request.method === 'GET') {
|
|
91
94
|
response.writeHead(200, { 'Content-Type': 'application/json', 'Cache-Control': 'no-store', ...security }).end(JSON.stringify({ customers: demoCustomers })); return;
|
|
92
95
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import { test } from 'node:test';
|
|
3
|
+
import { devRequestTarget, devUpstreamOptions } from '../src/dev-request.js';
|
|
4
|
+
|
|
5
|
+
const webOrigin = 'http://127.0.0.1:5173';
|
|
6
|
+
|
|
7
|
+
test('keeps the upstream connection on the configured server and preserves the API path and query', () => {
|
|
8
|
+
const target = devRequestTarget('/v1/runs/example/events?after=2', webOrigin);
|
|
9
|
+
assert(target);
|
|
10
|
+
assert.deepEqual(devUpstreamOptions('http://127.0.0.1:4000', target), {
|
|
11
|
+
protocol: 'http:', hostname: '127.0.0.1', port: '4000', path: '/v1/runs/example/events?after=2',
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
test('rejects request targets outside the local development origin and malformed URLs', () => {
|
|
16
|
+
assert.equal(devRequestTarget('https://other.example/v1/runs', webOrigin), undefined);
|
|
17
|
+
assert.equal(devRequestTarget('http://[', webOrigin), undefined);
|
|
18
|
+
assert.equal(devRequestTarget(undefined, webOrigin)?.pathname, '/');
|
|
19
|
+
});
|
package/lib/client/dist/index.js
CHANGED
|
@@ -419,7 +419,7 @@ const featureNames = ['humanRequests', 'workflowIndex', 'workflowViews', 'workfl
|
|
|
419
419
|
* RUN_NOT_FOUND, a missing capability or a protocol violation, is final.
|
|
420
420
|
*/
|
|
421
421
|
function retryableStream(error) {
|
|
422
|
-
return ['TRANSPORT_FAILED', 'TIMEOUT', 'TRUNCATED_STREAM', 'RUN_RECORDS_UNAVAILABLE', 'AUTH_EXPIRED'].includes(error.code)
|
|
422
|
+
return ['TRANSPORT_FAILED', 'TIMEOUT', 'TRUNCATED_STREAM', 'RUN_RECORDS_UNAVAILABLE', 'AUTH_EXPIRED', 'AUTH_UNAVAILABLE', 'AUTH_LIMIT'].includes(error.code)
|
|
423
423
|
|| (error.status !== undefined && [408, 429, 502, 503, 504].includes(error.status));
|
|
424
424
|
}
|
|
425
425
|
/** Why a signal ended: the client's own timers abort with a TIMEOUT error; anything else is the caller's cancellation. */
|
|
@@ -694,7 +694,7 @@ export function createClient(options) {
|
|
|
694
694
|
reported = serverError({ error: JSON.parse(data.join('\n')) }, 0, null);
|
|
695
695
|
}
|
|
696
696
|
catch { /* Not a Mayura error frame. */ }
|
|
697
|
-
throw reported && ['OBSERVATION_FAILED', 'RUN_RECORDS_UNAVAILABLE', 'AUTHORIZATION_DENIED'].includes(reported.code)
|
|
697
|
+
throw reported && ['OBSERVATION_FAILED', 'RUN_RECORDS_UNAVAILABLE', 'AUTHORIZATION_DENIED', 'AUTH_INVALID', 'AUTH_EXPIRED', 'AUTH_UNAVAILABLE', 'AUTH_LIMIT'].includes(reported.code)
|
|
698
698
|
? new ClientError(reported.code, undefined, { message: reported.message, details: reported.details }) : new ClientError('OBSERVATION_FAILED');
|
|
699
699
|
}
|
|
700
700
|
let raw;
|