@mastra/mcp-docs-server 0.0.0-commonjs-20250414101718
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/.docs/organized/changelogs/%40mastra%2Fastra.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fchroma.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fclickhouse.md +161 -0
- package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare.md +110 -0
- package/.docs/organized/changelogs/%40mastra%2Fcore.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloudflare.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-netlify.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-vercel.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fevals.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Ffirecrawl.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fgithub.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Floggers.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fmcp-registry-registry.md +26 -0
- package/.docs/organized/changelogs/%40mastra%2Fmcp.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fmem0.md +196 -0
- package/.docs/organized/changelogs/%40mastra%2Fmemory.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fpg.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fpinecone.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fqdrant.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Frag.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fragie.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fserver.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fspeech-azure.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fspeech-deepgram.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fspeech-elevenlabs.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fspeech-google.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fspeech-ibm.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fspeech-murf.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fspeech-openai.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fspeech-playai.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fspeech-replicate.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fspeech-speechify.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fturbopuffer.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fupstash.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fvectorize.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-azure.md +250 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-cloudflare.md +250 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-deepgram.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-elevenlabs.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-google.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-murf.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-openai-realtime.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-openai.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-playai.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-sarvam.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-speechify.md +302 -0
- package/.docs/organized/changelogs/create-mastra.md +302 -0
- package/.docs/organized/changelogs/mastra.md +302 -0
- package/.docs/organized/code-examples/agent-network.md +282 -0
- package/.docs/organized/code-examples/agent.md +388 -0
- package/.docs/organized/code-examples/ai-sdk-useChat.md +378 -0
- package/.docs/organized/code-examples/assistant-ui.md +37 -0
- package/.docs/organized/code-examples/bird-checker-with-express.md +235 -0
- package/.docs/organized/code-examples/bird-checker-with-nextjs-and-eval.md +360 -0
- package/.docs/organized/code-examples/bird-checker-with-nextjs.md +250 -0
- package/.docs/organized/code-examples/client-side-tools.md +69 -0
- package/.docs/organized/code-examples/crypto-chatbot.md +96 -0
- package/.docs/organized/code-examples/fireworks-r1.md +159 -0
- package/.docs/organized/code-examples/mcp-registry-registry.md +63 -0
- package/.docs/organized/code-examples/memory-todo-agent.md +164 -0
- package/.docs/organized/code-examples/memory-with-context.md +167 -0
- package/.docs/organized/code-examples/memory-with-libsql.md +204 -0
- package/.docs/organized/code-examples/memory-with-mem0.md +121 -0
- package/.docs/organized/code-examples/memory-with-pg.md +224 -0
- package/.docs/organized/code-examples/memory-with-upstash.md +268 -0
- package/.docs/organized/code-examples/quick-start.md +129 -0
- package/.docs/organized/code-examples/stock-price-tool.md +124 -0
- package/.docs/organized/code-examples/weather-agent.md +353 -0
- package/.docs/organized/code-examples/workflow-ai-recruiter.md +159 -0
- package/.docs/organized/code-examples/workflow-with-inline-steps.md +111 -0
- package/.docs/organized/code-examples/workflow-with-memory.md +393 -0
- package/.docs/organized/code-examples/workflow-with-separate-steps.md +131 -0
- package/.docs/raw/agents/adding-tools.mdx +317 -0
- package/.docs/raw/agents/adding-voice.mdx +175 -0
- package/.docs/raw/agents/agent-memory.mdx +62 -0
- package/.docs/raw/agents/mcp-guide.mdx +215 -0
- package/.docs/raw/agents/overview.mdx +303 -0
- package/.docs/raw/community/discord.mdx +12 -0
- package/.docs/raw/community/licensing.mdx +63 -0
- package/.docs/raw/deployment/client.mdx +120 -0
- package/.docs/raw/deployment/deployment.mdx +127 -0
- package/.docs/raw/deployment/server.mdx +282 -0
- package/.docs/raw/evals/custom-eval.mdx +22 -0
- package/.docs/raw/evals/overview.mdx +95 -0
- package/.docs/raw/evals/running-in-ci.mdx +81 -0
- package/.docs/raw/evals/textual-evals.mdx +54 -0
- package/.docs/raw/faq/index.mdx +63 -0
- package/.docs/raw/frameworks/ai-sdk.mdx +296 -0
- package/.docs/raw/frameworks/next-js.mdx +238 -0
- package/.docs/raw/getting-started/installation.mdx +442 -0
- package/.docs/raw/getting-started/mcp-docs-server.mdx +141 -0
- package/.docs/raw/getting-started/project-structure.mdx +80 -0
- package/.docs/raw/index.mdx +22 -0
- package/.docs/raw/integrations/index.mdx +213 -0
- package/.docs/raw/local-dev/add-to-existing-project.mdx +48 -0
- package/.docs/raw/local-dev/creating-a-new-project.mdx +54 -0
- package/.docs/raw/local-dev/mastra-dev.mdx +108 -0
- package/.docs/raw/memory/memory-processors.mdx +131 -0
- package/.docs/raw/memory/overview.mdx +119 -0
- package/.docs/raw/memory/semantic-recall.mdx +122 -0
- package/.docs/raw/memory/working-memory.mdx +87 -0
- package/.docs/raw/observability/logging.mdx +38 -0
- package/.docs/raw/observability/nextjs-tracing.mdx +108 -0
- package/.docs/raw/observability/tracing.mdx +115 -0
- package/.docs/raw/rag/chunking-and-embedding.mdx +156 -0
- package/.docs/raw/rag/overview.mdx +85 -0
- package/.docs/raw/rag/retrieval.mdx +365 -0
- package/.docs/raw/rag/vector-databases.mdx +340 -0
- package/.docs/raw/reference/agents/createTool.mdx +229 -0
- package/.docs/raw/reference/agents/generate.mdx +334 -0
- package/.docs/raw/reference/agents/getAgent.mdx +54 -0
- package/.docs/raw/reference/agents/stream.mdx +369 -0
- package/.docs/raw/reference/cli/build.mdx +55 -0
- package/.docs/raw/reference/cli/dev.mdx +134 -0
- package/.docs/raw/reference/cli/init.mdx +43 -0
- package/.docs/raw/reference/client-js/agents.mdx +107 -0
- package/.docs/raw/reference/client-js/error-handling.mdx +38 -0
- package/.docs/raw/reference/client-js/logs.mdx +24 -0
- package/.docs/raw/reference/client-js/memory.mdx +97 -0
- package/.docs/raw/reference/client-js/telemetry.mdx +20 -0
- package/.docs/raw/reference/client-js/tools.mdx +44 -0
- package/.docs/raw/reference/client-js/vectors.mdx +79 -0
- package/.docs/raw/reference/client-js/workflows.mdx +136 -0
- package/.docs/raw/reference/core/mastra-class.mdx +232 -0
- package/.docs/raw/reference/deployer/cloudflare.mdx +207 -0
- package/.docs/raw/reference/deployer/deployer.mdx +159 -0
- package/.docs/raw/reference/deployer/netlify.mdx +109 -0
- package/.docs/raw/reference/deployer/vercel.mdx +117 -0
- package/.docs/raw/reference/evals/answer-relevancy.mdx +186 -0
- package/.docs/raw/reference/evals/bias.mdx +186 -0
- package/.docs/raw/reference/evals/completeness.mdx +174 -0
- package/.docs/raw/reference/evals/content-similarity.mdx +183 -0
- package/.docs/raw/reference/evals/context-position.mdx +190 -0
- package/.docs/raw/reference/evals/context-precision.mdx +189 -0
- package/.docs/raw/reference/evals/context-relevancy.mdx +188 -0
- package/.docs/raw/reference/evals/contextual-recall.mdx +191 -0
- package/.docs/raw/reference/evals/faithfulness.mdx +193 -0
- package/.docs/raw/reference/evals/hallucination.mdx +219 -0
- package/.docs/raw/reference/evals/keyword-coverage.mdx +176 -0
- package/.docs/raw/reference/evals/prompt-alignment.mdx +238 -0
- package/.docs/raw/reference/evals/summarization.mdx +205 -0
- package/.docs/raw/reference/evals/textual-difference.mdx +161 -0
- package/.docs/raw/reference/evals/tone-consistency.mdx +181 -0
- package/.docs/raw/reference/evals/toxicity.mdx +165 -0
- package/.docs/raw/reference/index.mdx +12 -0
- package/.docs/raw/reference/memory/Memory.mdx +212 -0
- package/.docs/raw/reference/memory/createThread.mdx +95 -0
- package/.docs/raw/reference/memory/getThreadById.mdx +46 -0
- package/.docs/raw/reference/memory/getThreadsByResourceId.mdx +48 -0
- package/.docs/raw/reference/memory/query.mdx +167 -0
- package/.docs/raw/reference/networks/agent-network.mdx +159 -0
- package/.docs/raw/reference/observability/create-logger.mdx +106 -0
- package/.docs/raw/reference/observability/logger.mdx +55 -0
- package/.docs/raw/reference/observability/otel-config.mdx +120 -0
- package/.docs/raw/reference/observability/providers/braintrust.mdx +40 -0
- package/.docs/raw/reference/observability/providers/dash0.mdx +40 -0
- package/.docs/raw/reference/observability/providers/index.mdx +16 -0
- package/.docs/raw/reference/observability/providers/laminar.mdx +41 -0
- package/.docs/raw/reference/observability/providers/langfuse.mdx +51 -0
- package/.docs/raw/reference/observability/providers/langsmith.mdx +48 -0
- package/.docs/raw/reference/observability/providers/langwatch.mdx +45 -0
- package/.docs/raw/reference/observability/providers/new-relic.mdx +40 -0
- package/.docs/raw/reference/observability/providers/signoz.mdx +40 -0
- package/.docs/raw/reference/observability/providers/traceloop.mdx +40 -0
- package/.docs/raw/reference/rag/astra.mdx +258 -0
- package/.docs/raw/reference/rag/chroma.mdx +281 -0
- package/.docs/raw/reference/rag/chunk.mdx +235 -0
- package/.docs/raw/reference/rag/document.mdx +127 -0
- package/.docs/raw/reference/rag/embeddings.mdx +160 -0
- package/.docs/raw/reference/rag/extract-params.mdx +226 -0
- package/.docs/raw/reference/rag/graph-rag.mdx +182 -0
- package/.docs/raw/reference/rag/libsql.mdx +357 -0
- package/.docs/raw/reference/rag/metadata-filters.mdx +298 -0
- package/.docs/raw/reference/rag/pg.mdx +477 -0
- package/.docs/raw/reference/rag/pinecone.mdx +281 -0
- package/.docs/raw/reference/rag/qdrant.mdx +236 -0
- package/.docs/raw/reference/rag/rerank.mdx +212 -0
- package/.docs/raw/reference/rag/turbopuffer.mdx +249 -0
- package/.docs/raw/reference/rag/upstash.mdx +247 -0
- package/.docs/raw/reference/rag/vectorize.mdx +298 -0
- package/.docs/raw/reference/storage/libsql.mdx +74 -0
- package/.docs/raw/reference/storage/postgresql.mdx +48 -0
- package/.docs/raw/reference/storage/upstash.mdx +86 -0
- package/.docs/raw/reference/tools/client.mdx +207 -0
- package/.docs/raw/reference/tools/document-chunker-tool.mdx +141 -0
- package/.docs/raw/reference/tools/graph-rag-tool.mdx +154 -0
- package/.docs/raw/reference/tools/mcp-configuration.mdx +206 -0
- package/.docs/raw/reference/tools/vector-query-tool.mdx +212 -0
- package/.docs/raw/reference/voice/composite-voice.mdx +140 -0
- package/.docs/raw/reference/voice/deepgram.mdx +164 -0
- package/.docs/raw/reference/voice/elevenlabs.mdx +216 -0
- package/.docs/raw/reference/voice/google.mdx +198 -0
- package/.docs/raw/reference/voice/mastra-voice.mdx +394 -0
- package/.docs/raw/reference/voice/murf.mdx +251 -0
- package/.docs/raw/reference/voice/openai-realtime.mdx +431 -0
- package/.docs/raw/reference/voice/openai.mdx +168 -0
- package/.docs/raw/reference/voice/playai.mdx +159 -0
- package/.docs/raw/reference/voice/sarvam.mdx +260 -0
- package/.docs/raw/reference/voice/speechify.mdx +145 -0
- package/.docs/raw/reference/voice/voice.answer.mdx +122 -0
- package/.docs/raw/reference/voice/voice.connect.mdx +124 -0
- package/.docs/raw/reference/voice/voice.listen.mdx +195 -0
- package/.docs/raw/reference/voice/voice.on.mdx +189 -0
- package/.docs/raw/reference/voice/voice.send.mdx +118 -0
- package/.docs/raw/reference/voice/voice.speak.mdx +203 -0
- package/.docs/raw/reference/workflows/after.mdx +88 -0
- package/.docs/raw/reference/workflows/afterEvent.mdx +76 -0
- package/.docs/raw/reference/workflows/commit.mdx +37 -0
- package/.docs/raw/reference/workflows/createRun.mdx +77 -0
- package/.docs/raw/reference/workflows/else.mdx +72 -0
- package/.docs/raw/reference/workflows/events.mdx +305 -0
- package/.docs/raw/reference/workflows/execute.mdx +110 -0
- package/.docs/raw/reference/workflows/if.mdx +107 -0
- package/.docs/raw/reference/workflows/resume.mdx +155 -0
- package/.docs/raw/reference/workflows/resumeWithEvent.mdx +133 -0
- package/.docs/raw/reference/workflows/snapshots.mdx +207 -0
- package/.docs/raw/reference/workflows/start.mdx +84 -0
- package/.docs/raw/reference/workflows/step-class.mdx +100 -0
- package/.docs/raw/reference/workflows/step-condition.mdx +134 -0
- package/.docs/raw/reference/workflows/step-function.mdx +92 -0
- package/.docs/raw/reference/workflows/step-options.mdx +69 -0
- package/.docs/raw/reference/workflows/step-retries.mdx +203 -0
- package/.docs/raw/reference/workflows/suspend.mdx +70 -0
- package/.docs/raw/reference/workflows/then.mdx +74 -0
- package/.docs/raw/reference/workflows/until.mdx +165 -0
- package/.docs/raw/reference/workflows/watch.mdx +118 -0
- package/.docs/raw/reference/workflows/while.mdx +168 -0
- package/.docs/raw/reference/workflows/workflow.mdx +233 -0
- package/.docs/raw/storage/overview.mdx +378 -0
- package/.docs/raw/voice/overview.mdx +135 -0
- package/.docs/raw/voice/speech-to-text.mdx +45 -0
- package/.docs/raw/voice/text-to-speech.mdx +52 -0
- package/.docs/raw/voice/voice-to-voice.mdx +310 -0
- package/.docs/raw/workflows/control-flow.mdx +778 -0
- package/.docs/raw/workflows/dynamic-workflows.mdx +236 -0
- package/.docs/raw/workflows/error-handling.mdx +183 -0
- package/.docs/raw/workflows/nested-workflows.mdx +352 -0
- package/.docs/raw/workflows/overview.mdx +203 -0
- package/.docs/raw/workflows/steps.mdx +108 -0
- package/.docs/raw/workflows/suspend-and-resume.mdx +404 -0
- package/.docs/raw/workflows/variables.mdx +313 -0
- package/LICENSE.md +46 -0
- package/README.md +129 -0
- package/dist/_tsup-dts-rollup.d.ts +149 -0
- package/dist/chunk-QWYMT5LP.js +194 -0
- package/dist/prepare-docs/prepare.d.ts +1 -0
- package/dist/prepare-docs/prepare.js +1 -0
- package/dist/stdio.d.ts +1 -0
- package/dist/stdio.js +518 -0
- package/package.json +60 -0
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
### package.json
|
|
2
|
+
```json
|
|
3
|
+
{
|
|
4
|
+
"name": "examples-crypto-chatbot",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"private": true,
|
|
7
|
+
"scripts": {
|
|
8
|
+
"dev": "next dev --turbo",
|
|
9
|
+
"build": "tsx db/migrate && next build",
|
|
10
|
+
"start": "next start",
|
|
11
|
+
"lint": "next lint",
|
|
12
|
+
"db:generate": "drizzle-kit generate",
|
|
13
|
+
"db:migrate": "npx tsx ./db/migrate.ts"
|
|
14
|
+
},
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@ai-sdk/openai": "latest",
|
|
17
|
+
"@ai-sdk/react": "^1.1.21",
|
|
18
|
+
"@mastra/core": "link:../../packages/core",
|
|
19
|
+
"@mastra/memory": "link:../../packages/memory",
|
|
20
|
+
"@mastra/pg": "link:../../stores/pg",
|
|
21
|
+
"@next/env": "^15.2.2",
|
|
22
|
+
"@radix-ui/react-alert-dialog": "^1.1.6",
|
|
23
|
+
"@radix-ui/react-dialog": "^1.1.6",
|
|
24
|
+
"@radix-ui/react-dropdown-menu": "^2.1.6",
|
|
25
|
+
"@radix-ui/react-icons": "^1.3.2",
|
|
26
|
+
"@radix-ui/react-label": "^2.1.2",
|
|
27
|
+
"@radix-ui/react-select": "^2.1.6",
|
|
28
|
+
"@radix-ui/react-separator": "^1.1.2",
|
|
29
|
+
"@radix-ui/react-slot": "^1.1.2",
|
|
30
|
+
"@radix-ui/react-tooltip": "^1.1.8",
|
|
31
|
+
"@radix-ui/react-visually-hidden": "^1.1.2",
|
|
32
|
+
"@vercel/analytics": "^1.5.0",
|
|
33
|
+
"@vercel/blob": "^0.24.1",
|
|
34
|
+
"@vercel/postgres": "^0.10.0",
|
|
35
|
+
"ai": "latest",
|
|
36
|
+
"bcrypt-ts": "^5.0.3",
|
|
37
|
+
"class-variance-authority": "^0.7.1",
|
|
38
|
+
"classnames": "^2.5.1",
|
|
39
|
+
"clsx": "^2.1.1",
|
|
40
|
+
"date-fns": "^4.1.0",
|
|
41
|
+
"diff-match-patch": "^1.0.5",
|
|
42
|
+
"dotenv": "^16.4.7",
|
|
43
|
+
"drizzle-orm": "^0.37.0",
|
|
44
|
+
"framer-motion": "^11.18.2",
|
|
45
|
+
"geist": "^1.3.1",
|
|
46
|
+
"lucide-react": "^0.446.0",
|
|
47
|
+
"next": "15.0.3-canary.2",
|
|
48
|
+
"next-auth": "5.0.0-beta.25",
|
|
49
|
+
"next-themes": "^0.3.0",
|
|
50
|
+
"orderedmap": "^2.1.1",
|
|
51
|
+
"pg": "^8.13.3",
|
|
52
|
+
"postgres": "^3.4.5",
|
|
53
|
+
"prosemirror-example-setup": "^1.2.3",
|
|
54
|
+
"prosemirror-inputrules": "^1.4.0",
|
|
55
|
+
"prosemirror-markdown": "^1.13.1",
|
|
56
|
+
"prosemirror-model": "^1.24.1",
|
|
57
|
+
"prosemirror-schema-basic": "^1.2.3",
|
|
58
|
+
"prosemirror-schema-list": "^1.5.1",
|
|
59
|
+
"prosemirror-state": "^1.4.3",
|
|
60
|
+
"prosemirror-view": "^1.38.1",
|
|
61
|
+
"react": "19.0.0-rc-45804af1-20241021",
|
|
62
|
+
"react-dom": "19.0.0-rc-45804af1-20241021",
|
|
63
|
+
"react-markdown": "^9.1.0",
|
|
64
|
+
"remark-gfm": "^4.0.1",
|
|
65
|
+
"server-only": "^0.0.1",
|
|
66
|
+
"sonner": "^1.7.4",
|
|
67
|
+
"swr": "^2.3.3",
|
|
68
|
+
"tailwind-merge": "^2.6.0",
|
|
69
|
+
"tailwindcss-animate": "^1.0.7",
|
|
70
|
+
"usehooks-ts": "^3.1.1",
|
|
71
|
+
"zod": "^3.24.2"
|
|
72
|
+
},
|
|
73
|
+
"devDependencies": {
|
|
74
|
+
"@tailwindcss/typography": "^0.5.16",
|
|
75
|
+
"@types/d3-scale": "^4.0.9",
|
|
76
|
+
"@types/node": "^20.17.24",
|
|
77
|
+
"@types/pdf-parse": "^1.1.4",
|
|
78
|
+
"@types/react": "^19.0.10",
|
|
79
|
+
"@types/react-dom": "^19.0.4",
|
|
80
|
+
"drizzle-kit": "^0.25.0",
|
|
81
|
+
"eslint": "^8.57.1",
|
|
82
|
+
"eslint-config-next": "14.2.5",
|
|
83
|
+
"eslint-config-prettier": "^9.1.0",
|
|
84
|
+
"eslint-import-resolver-typescript": "^3.8.4",
|
|
85
|
+
"eslint-plugin-import": "^2.31.0",
|
|
86
|
+
"eslint-plugin-tailwindcss": "^3.18.0",
|
|
87
|
+
"postcss": "^8.5.3",
|
|
88
|
+
"prettier": "^3.5.3",
|
|
89
|
+
"tailwindcss": "^3.4.17",
|
|
90
|
+
"tsx": "^4.19.3",
|
|
91
|
+
"typescript": "^5.8.2"
|
|
92
|
+
},
|
|
93
|
+
"version": "0.0.1"
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
```
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
### package.json
|
|
2
|
+
```json
|
|
3
|
+
{
|
|
4
|
+
"name": "fireworks-r1",
|
|
5
|
+
"version": "0.0.1",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"private": true,
|
|
8
|
+
"main": "index.js",
|
|
9
|
+
"scripts": {
|
|
10
|
+
"chat": "bun run --watch src/chat.ts"
|
|
11
|
+
},
|
|
12
|
+
"keywords": [],
|
|
13
|
+
"author": "",
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@ai-sdk/anthropic": "^1.1.15",
|
|
17
|
+
"@ai-sdk/fireworks": "^0.1.14",
|
|
18
|
+
"@mastra/core": "workspace:*",
|
|
19
|
+
"@mastra/mcp": "workspace:*",
|
|
20
|
+
"@mastra/memory": "workspace:*",
|
|
21
|
+
"@types/tinycolor2": "^1.4.6",
|
|
22
|
+
"chalk": "^5.4.1",
|
|
23
|
+
"gradient-string": "^3.0.0",
|
|
24
|
+
"ora": "^8.2.0",
|
|
25
|
+
"tinycolor2": "^1.6.0",
|
|
26
|
+
"zod": "^3.24.2"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@types/node": "^20.17.27",
|
|
30
|
+
"dotenv": "^16.4.7",
|
|
31
|
+
"mastra": "workspace:*",
|
|
32
|
+
"tsx": "^4.19.3",
|
|
33
|
+
"typescript": "^5.8.2"
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### chat.ts
|
|
40
|
+
```typescript
|
|
41
|
+
import crypto from 'node:crypto';
|
|
42
|
+
import { maskStreamTags } from '@mastra/core/utils';
|
|
43
|
+
import tinycolor from 'tinycolor2';
|
|
44
|
+
import ora from 'ora';
|
|
45
|
+
import chalk from 'chalk';
|
|
46
|
+
import Readline from 'readline';
|
|
47
|
+
|
|
48
|
+
import 'dotenv/config.js';
|
|
49
|
+
|
|
50
|
+
import gradient from 'gradient-string';
|
|
51
|
+
import { agent } from './mastra/agents';
|
|
52
|
+
|
|
53
|
+
type AsyncIterableStream<T> = AsyncIterable<T> & ReadableStream<T>;
|
|
54
|
+
|
|
55
|
+
function makeThinkStream(textStream: AsyncIterableStream<string>) {
|
|
56
|
+
const thinking = ora({
|
|
57
|
+
text: chalk.bold(`thinking`),
|
|
58
|
+
spinner: {
|
|
59
|
+
interval: 80,
|
|
60
|
+
frames: ['⢎ ', '⠎⠁', '⠊⠑', '⠈⠱', ' ⡱', '⢀⡰', '⢄⡠', '⢆⡀'],
|
|
61
|
+
},
|
|
62
|
+
color: 'green',
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
let thought = ``;
|
|
66
|
+
const start = Date.now();
|
|
67
|
+
const grad = gradient(['darkslategray', 'white', 'midnightblue']);
|
|
68
|
+
|
|
69
|
+
return maskStreamTags(textStream, 'think', {
|
|
70
|
+
onStart: () => {
|
|
71
|
+
thinking.start();
|
|
72
|
+
},
|
|
73
|
+
onMask: chunk => {
|
|
74
|
+
if (chunk.includes(`think`)) return;
|
|
75
|
+
thought += chunk;
|
|
76
|
+
thought = thought
|
|
77
|
+
.substring(Math.max(0, thought.length - 80))
|
|
78
|
+
.split(`\n`)
|
|
79
|
+
.join(` `);
|
|
80
|
+
thinking.suffixText = grad(thought);
|
|
81
|
+
},
|
|
82
|
+
onEnd: () => {
|
|
83
|
+
thinking.suffixText = grad(thought.substring(Math.max(0, thought.length - 90)));
|
|
84
|
+
thinking.succeed(`thought ${chalk.bold(`for ${Math.ceil((Date.now() - start) / 1000)}s`)}`);
|
|
85
|
+
console.log(`\n${chalk.bold.green(`Fireworks R1:`)}`);
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const resourceId = 'SOME_USER_ID';
|
|
91
|
+
const threadId = crypto.randomUUID();
|
|
92
|
+
async function main() {
|
|
93
|
+
console.clear(); // clear all previous output
|
|
94
|
+
|
|
95
|
+
while (true) {
|
|
96
|
+
const rl = Readline.createInterface({
|
|
97
|
+
input: process.stdin,
|
|
98
|
+
output: process.stdout,
|
|
99
|
+
history: ["What's the meaning of life?"],
|
|
100
|
+
});
|
|
101
|
+
process.stdout.write(`\n\n`);
|
|
102
|
+
const answer: string = await new Promise(res => {
|
|
103
|
+
rl.question(chalk.grey('\n> '), answer => {
|
|
104
|
+
setImmediate(() => res(answer));
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
console.log(); // print a line between prompt and response
|
|
108
|
+
|
|
109
|
+
const { textStream } = await agent.stream(answer, {
|
|
110
|
+
threadId,
|
|
111
|
+
resourceId,
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
for await (const chunk of makeThinkStream(textStream)) {
|
|
115
|
+
process.stdout.write(chalk.hex(tinycolor('seagreen').toHex())(chunk));
|
|
116
|
+
}
|
|
117
|
+
rl.close();
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
main();
|
|
122
|
+
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### mastra/agents/index.ts
|
|
126
|
+
```typescript
|
|
127
|
+
import { fireworks } from '@ai-sdk/fireworks';
|
|
128
|
+
import { Agent } from '@mastra/core/agent';
|
|
129
|
+
import { Memory } from '@mastra/memory';
|
|
130
|
+
|
|
131
|
+
if (!process.env.FIREWORKS_API_KEY) {
|
|
132
|
+
throw new Error(`FIREWORKS_API_KEY env var is required for this example to work`);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export const agent = new Agent({
|
|
136
|
+
model: fireworks(`accounts/fireworks/models/deepseek-r1`),
|
|
137
|
+
|
|
138
|
+
name: 'Example agent',
|
|
139
|
+
instructions: `You are a helpful and intelligent AI agent.`,
|
|
140
|
+
memory: new Memory(),
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### mastra/index.ts
|
|
146
|
+
```typescript
|
|
147
|
+
import { Mastra } from '@mastra/core/mastra';
|
|
148
|
+
import { createLogger } from '@mastra/core/logger';
|
|
149
|
+
import { agent } from './agents';
|
|
150
|
+
|
|
151
|
+
export const mastra = new Mastra({
|
|
152
|
+
agents: { agent },
|
|
153
|
+
logger: createLogger({
|
|
154
|
+
name: 'Mastra',
|
|
155
|
+
level: 'info',
|
|
156
|
+
}),
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
```
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
### package.json
|
|
2
|
+
```json
|
|
3
|
+
{
|
|
4
|
+
"name": "examples-mcp-registry-registry",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"private": true,
|
|
7
|
+
"description": "",
|
|
8
|
+
"main": "index.js",
|
|
9
|
+
"version": "0.0.1",
|
|
10
|
+
"scripts": {
|
|
11
|
+
"start-deployed": "npx bun src/with-deployed.ts",
|
|
12
|
+
"start": "npx bun src/index.ts"
|
|
13
|
+
},
|
|
14
|
+
"keywords": [],
|
|
15
|
+
"author": "",
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"@ai-sdk/openai": "latest",
|
|
19
|
+
"@mastra/mcp": "workspace:*",
|
|
20
|
+
"@mastra/mcp-registry-registry": "workspace:*",
|
|
21
|
+
"@mastra/core": "workspace:*",
|
|
22
|
+
"zod": "^3.24.2"
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### mastra/agents/index.ts
|
|
29
|
+
```typescript
|
|
30
|
+
import { openai } from '@ai-sdk/openai';
|
|
31
|
+
import { Agent } from '@mastra/core/agent';
|
|
32
|
+
import { MCPConfiguration } from '@mastra/mcp';
|
|
33
|
+
|
|
34
|
+
const mcp = new MCPConfiguration({
|
|
35
|
+
servers: {
|
|
36
|
+
registry: {
|
|
37
|
+
command: 'node',
|
|
38
|
+
args: ['../../packages/mcp-registry-registry/dist/stdio.js'],
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
export const mcpRegistryAgent = new Agent({
|
|
44
|
+
name: 'MCP Registry Agent',
|
|
45
|
+
instructions: `You are a helpful assistant that provides information about MCP registries. You can search for registries by ID, tag, or name.`,
|
|
46
|
+
model: openai('gpt-4o'),
|
|
47
|
+
tools: await mcp.getTools(),
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### mastra/index.ts
|
|
53
|
+
```typescript
|
|
54
|
+
import { Mastra } from '@mastra/core';
|
|
55
|
+
import { createLogger } from '@mastra/core/logger';
|
|
56
|
+
import { mcpRegistryAgent } from './agents/index';
|
|
57
|
+
|
|
58
|
+
export const mastra = new Mastra({
|
|
59
|
+
agents: { mcpRegistryAgent },
|
|
60
|
+
logger: createLogger({ name: 'MCP Registry', level: 'info' }),
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
```
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
### package.json
|
|
2
|
+
```json
|
|
3
|
+
{
|
|
4
|
+
"name": "memory-todo-agent",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"description": "",
|
|
7
|
+
"private": true,
|
|
8
|
+
"main": "index.js",
|
|
9
|
+
"scripts": {
|
|
10
|
+
"chat": "bun run src/index.ts"
|
|
11
|
+
},
|
|
12
|
+
"keywords": [],
|
|
13
|
+
"author": "",
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@ai-sdk/openai": "latest",
|
|
17
|
+
"@mastra/core": "workspace:*",
|
|
18
|
+
"@mastra/memory": "workspace:*",
|
|
19
|
+
"ai": "latest",
|
|
20
|
+
"chalk": "^5.4.1",
|
|
21
|
+
"ora": "^8.2.0"
|
|
22
|
+
},
|
|
23
|
+
"version": "0.1.6"
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### index.ts
|
|
29
|
+
```typescript
|
|
30
|
+
import { maskStreamTags } from '@mastra/core/utils';
|
|
31
|
+
import chalk from 'chalk';
|
|
32
|
+
import { randomUUID } from 'crypto';
|
|
33
|
+
import ora from 'ora';
|
|
34
|
+
import Readline from 'readline';
|
|
35
|
+
|
|
36
|
+
import 'dotenv/config';
|
|
37
|
+
|
|
38
|
+
import { mastra } from './mastra/index';
|
|
39
|
+
|
|
40
|
+
const agent = mastra.getAgent('todoAgent');
|
|
41
|
+
|
|
42
|
+
let threadId = ``;
|
|
43
|
+
threadId = randomUUID();
|
|
44
|
+
threadId = `d4e58927-ca27-46f9-8559-0c792e76e6f6`; // long thread
|
|
45
|
+
console.log(threadId);
|
|
46
|
+
|
|
47
|
+
const resourceId = 'SOME_USER_ID';
|
|
48
|
+
|
|
49
|
+
async function logRes(res: Awaited<ReturnType<typeof agent.stream>>) {
|
|
50
|
+
console.log(`\n👨🍳 Agent:`);
|
|
51
|
+
let message = '';
|
|
52
|
+
|
|
53
|
+
const memorySpinner = ora('saving memory');
|
|
54
|
+
|
|
55
|
+
const maskedStream = maskStreamTags(res.textStream, 'working_memory', {
|
|
56
|
+
onStart: () => memorySpinner.start(),
|
|
57
|
+
onEnd: () => {
|
|
58
|
+
if (memorySpinner.isSpinning) {
|
|
59
|
+
memorySpinner.succeed();
|
|
60
|
+
process.stdin.resume();
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
for await (const chunk of maskedStream) {
|
|
66
|
+
process.stdout.write(chunk);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return message;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
async function main() {
|
|
73
|
+
const isFirstChat = Boolean(await agent.getMemory()?.getThreadById({ threadId })) === false;
|
|
74
|
+
|
|
75
|
+
await logRes(
|
|
76
|
+
await agent.stream(
|
|
77
|
+
[
|
|
78
|
+
{
|
|
79
|
+
role: 'system',
|
|
80
|
+
content: !isFirstChat
|
|
81
|
+
? `Chat with user started now ${new Date().toISOString()}. Don't mention this message. This means some time has passed between this message and the one before. The user left and came back again. Say something to start the conversation up again.`
|
|
82
|
+
: `Chat with user started now ${new Date().toISOString()}.`,
|
|
83
|
+
},
|
|
84
|
+
],
|
|
85
|
+
{
|
|
86
|
+
threadId,
|
|
87
|
+
resourceId,
|
|
88
|
+
},
|
|
89
|
+
),
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
const rl = Readline.createInterface({
|
|
93
|
+
input: process.stdin,
|
|
94
|
+
output: process.stdout,
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
while (true) {
|
|
98
|
+
const answer: string = await new Promise(res => {
|
|
99
|
+
rl.question(chalk.grey('\n> '), answer => {
|
|
100
|
+
setImmediate(() => res(answer));
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
await logRes(
|
|
105
|
+
await agent.stream(answer, {
|
|
106
|
+
threadId,
|
|
107
|
+
resourceId,
|
|
108
|
+
}),
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
main();
|
|
114
|
+
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### mastra/agents/index.ts
|
|
118
|
+
```typescript
|
|
119
|
+
import { openai } from '@ai-sdk/openai';
|
|
120
|
+
import { Agent } from '@mastra/core/agent';
|
|
121
|
+
import { Memory } from '@mastra/memory';
|
|
122
|
+
|
|
123
|
+
const memory = new Memory({
|
|
124
|
+
options: {
|
|
125
|
+
lastMessages: 1,
|
|
126
|
+
semanticRecall: false,
|
|
127
|
+
workingMemory: {
|
|
128
|
+
enabled: true,
|
|
129
|
+
template: `
|
|
130
|
+
# Todo List
|
|
131
|
+
## Active Items
|
|
132
|
+
- Example (Due: Feb 7 3028, Started: Feb 7 2025)
|
|
133
|
+
- Description: This is an example task - replace with whatever the user needs
|
|
134
|
+
|
|
135
|
+
## Completed Items
|
|
136
|
+
- None yet
|
|
137
|
+
`,
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
export const todoAgent = new Agent({
|
|
143
|
+
name: 'TODO Agent',
|
|
144
|
+
instructions:
|
|
145
|
+
'You are a helpful todolist AI agent. Help the user manage their todolist. If there is no list yet ask them what to add! If there is a list always print it out when the chat starts. For each item add emojis, dates, titles (with an index number starting at 1), descriptions, and statuses. For each piece of info add an emoji to the left of it. Also support subtask lists with bullet points inside a box. Help the user timebox each task by asking them how long it will take. You MUST save the todolist in every response message by printing out <working_memory> blocks. If you do not save it in working_memory you will forget - you only have access to one previous message at any time. The user is expecting you to save your memory in every interaction. If the user expresses any preference on how the list should be displayed, save that info in working_memory so you know how to format it later.',
|
|
146
|
+
|
|
147
|
+
model: openai('gpt-4o-mini'),
|
|
148
|
+
memory,
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### mastra/index.ts
|
|
154
|
+
```typescript
|
|
155
|
+
import { Mastra } from '@mastra/core/mastra';
|
|
156
|
+
|
|
157
|
+
import { todoAgent } from './agents';
|
|
158
|
+
|
|
159
|
+
export const mastra = new Mastra({
|
|
160
|
+
agents: { todoAgent },
|
|
161
|
+
logger: false,
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
```
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
### package.json
|
|
2
|
+
```json
|
|
3
|
+
{
|
|
4
|
+
"name": "memory-with-context",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"description": "",
|
|
7
|
+
"private": true,
|
|
8
|
+
"main": "index.js",
|
|
9
|
+
"scripts": {
|
|
10
|
+
"chat": "bun run src/chat.ts"
|
|
11
|
+
},
|
|
12
|
+
"keywords": [],
|
|
13
|
+
"author": "",
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@ai-sdk/openai": "^1.2.1",
|
|
17
|
+
"@mastra/core": "workspace:*",
|
|
18
|
+
"@mastra/memory": "workspace:*",
|
|
19
|
+
"chalk": "^5.4.1",
|
|
20
|
+
"ora": "^8.2.0"
|
|
21
|
+
},
|
|
22
|
+
"version": "0.0.1"
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### chat.ts
|
|
28
|
+
```typescript
|
|
29
|
+
import { maskStreamTags } from '@mastra/core/utils';
|
|
30
|
+
import chalk from 'chalk';
|
|
31
|
+
import { randomUUID } from 'crypto';
|
|
32
|
+
import ora from 'ora';
|
|
33
|
+
import Readline from 'readline';
|
|
34
|
+
|
|
35
|
+
import 'dotenv/config';
|
|
36
|
+
|
|
37
|
+
import { mastra } from './mastra/index';
|
|
38
|
+
|
|
39
|
+
const agent = mastra.getAgent('memoryAgent');
|
|
40
|
+
|
|
41
|
+
let threadId = ``;
|
|
42
|
+
threadId = randomUUID();
|
|
43
|
+
// threadId = `0b3faadd-7e21-49ec-b613-e519448dab81`; // long thread
|
|
44
|
+
console.log(threadId);
|
|
45
|
+
|
|
46
|
+
const resourceId = 'SOME_USER_ID';
|
|
47
|
+
|
|
48
|
+
async function logRes(res: Awaited<ReturnType<typeof agent.stream>>) {
|
|
49
|
+
console.log(`\n👨🍳 Agent:`);
|
|
50
|
+
let message = '';
|
|
51
|
+
|
|
52
|
+
const thinkSpinner = ora('thinking');
|
|
53
|
+
|
|
54
|
+
const thinkMaskedStream = maskStreamTags(res.textStream, 'think', {
|
|
55
|
+
onStart: () => thinkSpinner.start(),
|
|
56
|
+
onEnd: () => {
|
|
57
|
+
if (thinkSpinner.isSpinning) {
|
|
58
|
+
thinkSpinner.succeed();
|
|
59
|
+
process.stdin.resume();
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
const memorySpinner = ora('saving memory');
|
|
65
|
+
|
|
66
|
+
const maskedStream = maskStreamTags(thinkMaskedStream, 'working_memory', {
|
|
67
|
+
onStart: () => memorySpinner.start(),
|
|
68
|
+
onEnd: () => {
|
|
69
|
+
if (memorySpinner.isSpinning) {
|
|
70
|
+
memorySpinner.succeed();
|
|
71
|
+
process.stdin.resume();
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
for await (const chunk of maskedStream) {
|
|
77
|
+
process.stdout.write(chunk);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return message;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
async function main() {
|
|
84
|
+
const isFirstChat = Boolean(await agent.getMemory()?.getThreadById({ threadId })) === false;
|
|
85
|
+
|
|
86
|
+
await logRes(
|
|
87
|
+
await agent.stream(
|
|
88
|
+
[
|
|
89
|
+
{
|
|
90
|
+
role: 'system',
|
|
91
|
+
content: !isFirstChat
|
|
92
|
+
? `Chat with user started now ${new Date().toISOString()}. Don't mention this message. This means some time has passed between this message and the one before. The user left and came back again. Say something to start the conversation up again.`
|
|
93
|
+
: `Chat with user started now ${new Date().toISOString()}.`,
|
|
94
|
+
},
|
|
95
|
+
],
|
|
96
|
+
{
|
|
97
|
+
threadId,
|
|
98
|
+
resourceId,
|
|
99
|
+
},
|
|
100
|
+
),
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
const rl = Readline.createInterface({
|
|
104
|
+
input: process.stdin,
|
|
105
|
+
output: process.stdout,
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
while (true) {
|
|
109
|
+
process.stdout.write(`\n`);
|
|
110
|
+
const answer: string = await new Promise(res => {
|
|
111
|
+
rl.question(chalk.grey('\n> '), answer => {
|
|
112
|
+
setImmediate(() => res(answer));
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
await logRes(
|
|
117
|
+
await agent.stream(answer, {
|
|
118
|
+
threadId,
|
|
119
|
+
resourceId,
|
|
120
|
+
}),
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
main();
|
|
126
|
+
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### mastra/agents/index.ts
|
|
130
|
+
```typescript
|
|
131
|
+
import { openai } from '@ai-sdk/openai';
|
|
132
|
+
import { Agent } from '@mastra/core/agent';
|
|
133
|
+
import { Memory } from '@mastra/memory';
|
|
134
|
+
|
|
135
|
+
const memory = new Memory({
|
|
136
|
+
options: {
|
|
137
|
+
lastMessages: 4,
|
|
138
|
+
semanticRecall: {
|
|
139
|
+
topK: 1,
|
|
140
|
+
messageRange: 0,
|
|
141
|
+
},
|
|
142
|
+
workingMemory: {
|
|
143
|
+
enabled: true,
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
export const memoryAgent = new Agent({
|
|
149
|
+
name: 'Memory Agent',
|
|
150
|
+
instructions: 'You are a helpful AI agent, looking to assist however you can.',
|
|
151
|
+
model: openai('gpt-4o-mini'),
|
|
152
|
+
memory,
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### mastra/index.ts
|
|
158
|
+
```typescript
|
|
159
|
+
import { Mastra } from '@mastra/core';
|
|
160
|
+
|
|
161
|
+
import { memoryAgent } from './agents';
|
|
162
|
+
|
|
163
|
+
export const mastra = new Mastra({
|
|
164
|
+
agents: { memoryAgent },
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
```
|