@mastra/mcp-docs-server 1.0.0-beta.8 → 1.0.0-beta.9
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/%40internal%2Fchangeset-cli.md +1 -15
- package/.docs/organized/changelogs/%40internal%2Fexternal-types.md +1 -7
- package/.docs/organized/changelogs/%40internal%2Ftypes-builder.md +1 -55
- package/.docs/organized/changelogs/%40mastra%2Fai-sdk.md +39 -39
- package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +10 -10
- package/.docs/organized/changelogs/%40mastra%2Fcodemod.md +6 -0
- package/.docs/organized/changelogs/%40mastra%2Fcore.md +58 -58
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloud.md +9 -9
- package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +11 -11
- package/.docs/organized/changelogs/%40mastra%2Flibsql.md +49 -49
- package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +9 -9
- package/.docs/organized/changelogs/%40mastra%2Fmcp.md +12 -12
- package/.docs/organized/changelogs/%40mastra%2Fpg.md +49 -49
- package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +21 -21
- package/.docs/organized/changelogs/%40mastra%2Freact.md +7 -0
- package/.docs/organized/changelogs/%40mastra%2Fserver.md +49 -49
- package/.docs/organized/changelogs/create-mastra.md +13 -13
- package/.docs/organized/changelogs/mastra.md +21 -21
- package/.docs/organized/code-examples/mcp-server-adapters.md +1 -2
- package/.docs/organized/code-examples/processors-with-ai-sdk.md +14 -0
- package/.docs/organized/code-examples/server-app-access.md +1 -1
- package/.docs/organized/code-examples/server-hono-adapter.md +1 -1
- package/.docs/raw/getting-started/studio.mdx +4 -2
- package/.docs/raw/guides/agent-frameworks/ai-sdk.mdx +161 -0
- package/.docs/raw/guides/build-your-ui/ai-sdk-ui.mdx +4 -4
- package/.docs/raw/guides/migrations/upgrade-to-v1/tools.mdx +3 -3
- package/.docs/raw/reference/client-js/agents.mdx +251 -67
- package/.docs/raw/reference/client-js/mastra-client.mdx +2 -2
- package/.docs/raw/reference/client-js/memory.mdx +4 -1
- package/.docs/raw/reference/core/getMemory.mdx +73 -0
- package/.docs/raw/reference/core/getStoredAgentById.mdx +183 -0
- package/.docs/raw/reference/core/listMemory.mdx +70 -0
- package/.docs/raw/reference/core/listStoredAgents.mdx +151 -0
- package/.docs/raw/reference/core/mastra-class.mdx +8 -0
- package/.docs/raw/reference/server/express-adapter.mdx +52 -0
- package/.docs/raw/reference/server/hono-adapter.mdx +54 -0
- package/.docs/raw/server-db/server-adapters.mdx +94 -91
- package/.docs/raw/streaming/tool-streaming.mdx +10 -14
- package/CHANGELOG.md +8 -0
- package/package.json +4 -4
|
@@ -1,5 +1,53 @@
|
|
|
1
1
|
# @mastra/pg
|
|
2
2
|
|
|
3
|
+
## 1.0.0-beta.6
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Add stored agents support ([#10953](https://github.com/mastra-ai/mastra/pull/10953))
|
|
8
|
+
|
|
9
|
+
Agents can now be stored in the database and loaded at runtime. This lets you persist agent configurations and dynamically create executable Agent instances from storage.
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
import { Mastra } from '@mastra/core';
|
|
13
|
+
import { LibSQLStore } from '@mastra/libsql';
|
|
14
|
+
|
|
15
|
+
const mastra = new Mastra({
|
|
16
|
+
storage: new LibSQLStore({ url: ':memory:' }),
|
|
17
|
+
tools: { myTool },
|
|
18
|
+
scorers: { myScorer },
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
// Create agent in storage via API or directly
|
|
22
|
+
await mastra.getStorage().createAgent({
|
|
23
|
+
agent: {
|
|
24
|
+
id: 'my-agent',
|
|
25
|
+
name: 'My Agent',
|
|
26
|
+
instructions: 'You are helpful',
|
|
27
|
+
model: { provider: 'openai', name: 'gpt-4' },
|
|
28
|
+
tools: { myTool: {} },
|
|
29
|
+
scorers: { myScorer: { sampling: { type: 'ratio', rate: 0.5 } } },
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
// Load and use the agent
|
|
34
|
+
const agent = await mastra.getStoredAgentById('my-agent');
|
|
35
|
+
const response = await agent.generate({ messages: 'Hello!' });
|
|
36
|
+
|
|
37
|
+
// List all stored agents with pagination
|
|
38
|
+
const { agents, total, hasMore } = await mastra.listStoredAgents({
|
|
39
|
+
page: 0,
|
|
40
|
+
perPage: 10,
|
|
41
|
+
});
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Also adds a memory registry to Mastra so stored agents can reference memory instances by key.
|
|
45
|
+
|
|
46
|
+
### Patch Changes
|
|
47
|
+
|
|
48
|
+
- Updated dependencies [[`72df8ae`](https://github.com/mastra-ai/mastra/commit/72df8ae595584cdd7747d5c39ffaca45e4507227), [`9198899`](https://github.com/mastra-ai/mastra/commit/91988995c427b185c33714b7f3be955367911324), [`653e65a`](https://github.com/mastra-ai/mastra/commit/653e65ae1f9502c2958a32f47a5a2df11e612a92), [`c6fd6fe`](https://github.com/mastra-ai/mastra/commit/c6fd6fedd09e9cf8004b03a80925f5e94826ad7e), [`0bed332`](https://github.com/mastra-ai/mastra/commit/0bed332843f627202c6520eaf671771313cd20f3)]:
|
|
49
|
+
- @mastra/core@1.0.0-beta.9
|
|
50
|
+
|
|
3
51
|
## 1.0.0-beta.5
|
|
4
52
|
|
|
5
53
|
### Patch Changes
|
|
@@ -451,52 +499,4 @@
|
|
|
451
499
|
- Updated dependencies [[`c621613`](https://github.com/mastra-ai/mastra/commit/c621613069173c69eb2c3ef19a5308894c6549f0), [`12b1189`](https://github.com/mastra-ai/mastra/commit/12b118942445e4de0dd916c593e33ec78dc3bc73), [`4783b30`](https://github.com/mastra-ai/mastra/commit/4783b3063efea887825514b783ba27f67912c26d), [`076b092`](https://github.com/mastra-ai/mastra/commit/076b0924902ff0f49d5712d2df24c4cca683713f), [`2aee9e7`](https://github.com/mastra-ai/mastra/commit/2aee9e7d188b8b256a4ddc203ccefb366b4867fa), [`c582906`](https://github.com/mastra-ai/mastra/commit/c5829065a346260f96c4beb8af131b94804ae3ad), [`fa2eb96`](https://github.com/mastra-ai/mastra/commit/fa2eb96af16c7d433891a73932764960d3235c1d), [`ee9108f`](https://github.com/mastra-ai/mastra/commit/ee9108fa29bb8368fc23df158c9f0645b2d7b65c), [`4783b30`](https://github.com/mastra-ai/mastra/commit/4783b3063efea887825514b783ba27f67912c26d), [`a739d0c`](https://github.com/mastra-ai/mastra/commit/a739d0c8b37cd89569e04a6ca0827083c6167e19), [`603e927`](https://github.com/mastra-ai/mastra/commit/603e9279db8bf8a46caf83881c6b7389ccffff7e), [`cd45982`](https://github.com/mastra-ai/mastra/commit/cd4598291cda128a88738734ae6cbef076ebdebd), [`874f74d`](https://github.com/mastra-ai/mastra/commit/874f74da4b1acf6517f18132d035612c3ecc394a), [`b728a45`](https://github.com/mastra-ai/mastra/commit/b728a45ab3dba59da0f5ee36b81fe246659f305d), [`0baf2ba`](https://github.com/mastra-ai/mastra/commit/0baf2bab8420277072ef1f95df5ea7b0a2f61fe7), [`10e633a`](https://github.com/mastra-ai/mastra/commit/10e633a07d333466d9734c97acfc3dbf757ad2d0), [`a6d69c5`](https://github.com/mastra-ai/mastra/commit/a6d69c5fb50c0875b46275811fece5862f03c6a0), [`84199af`](https://github.com/mastra-ai/mastra/commit/84199af8673f6f9cb59286ffb5477a41932775de), [`7f431af`](https://github.com/mastra-ai/mastra/commit/7f431afd586b7d3265075e73106eb73167edbb86), [`26e968d`](https://github.com/mastra-ai/mastra/commit/26e968db2171ded9e4d47aa1b4f19e1e771158d0), [`cbd3fb6`](https://github.com/mastra-ai/mastra/commit/cbd3fb65adb03a7c0df193cb998aed5ac56675ee)]:
|
|
452
500
|
- @mastra/core@0.20.1
|
|
453
501
|
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
### Patch Changes
|
|
457
|
-
|
|
458
|
-
- Add validation for index creation ([#8552](https://github.com/mastra-ai/mastra/pull/8552))
|
|
459
|
-
|
|
460
|
-
- Updated dependencies [[`c621613`](https://github.com/mastra-ai/mastra/commit/c621613069173c69eb2c3ef19a5308894c6549f0), [`12b1189`](https://github.com/mastra-ai/mastra/commit/12b118942445e4de0dd916c593e33ec78dc3bc73), [`4783b30`](https://github.com/mastra-ai/mastra/commit/4783b3063efea887825514b783ba27f67912c26d), [`076b092`](https://github.com/mastra-ai/mastra/commit/076b0924902ff0f49d5712d2df24c4cca683713f), [`2aee9e7`](https://github.com/mastra-ai/mastra/commit/2aee9e7d188b8b256a4ddc203ccefb366b4867fa), [`c582906`](https://github.com/mastra-ai/mastra/commit/c5829065a346260f96c4beb8af131b94804ae3ad), [`fa2eb96`](https://github.com/mastra-ai/mastra/commit/fa2eb96af16c7d433891a73932764960d3235c1d), [`4783b30`](https://github.com/mastra-ai/mastra/commit/4783b3063efea887825514b783ba27f67912c26d), [`a739d0c`](https://github.com/mastra-ai/mastra/commit/a739d0c8b37cd89569e04a6ca0827083c6167e19), [`603e927`](https://github.com/mastra-ai/mastra/commit/603e9279db8bf8a46caf83881c6b7389ccffff7e), [`cd45982`](https://github.com/mastra-ai/mastra/commit/cd4598291cda128a88738734ae6cbef076ebdebd), [`874f74d`](https://github.com/mastra-ai/mastra/commit/874f74da4b1acf6517f18132d035612c3ecc394a), [`0baf2ba`](https://github.com/mastra-ai/mastra/commit/0baf2bab8420277072ef1f95df5ea7b0a2f61fe7), [`26e968d`](https://github.com/mastra-ai/mastra/commit/26e968db2171ded9e4d47aa1b4f19e1e771158d0), [`cbd3fb6`](https://github.com/mastra-ai/mastra/commit/cbd3fb65adb03a7c0df193cb998aed5ac56675ee)]:
|
|
461
|
-
- @mastra/core@0.20.1-alpha.1
|
|
462
|
-
|
|
463
|
-
## 0.17.1
|
|
464
|
-
|
|
465
|
-
### Patch Changes
|
|
466
|
-
|
|
467
|
-
- Breaking change to move the agent.streamVNext/generateVNext implementation to the default stream/generate. The old stream/generate have now been moved to streamLegacy and generateLegacy ([#8097](https://github.com/mastra-ai/mastra/pull/8097))
|
|
468
|
-
|
|
469
|
-
- Updated dependencies [[`00cb6bd`](https://github.com/mastra-ai/mastra/commit/00cb6bdf78737c0fac14a5a0c7b532a11e38558a), [`869ba22`](https://github.com/mastra-ai/mastra/commit/869ba222e1d6b58fc1b65e7c9fd55ca4e01b8c2f), [`1b73665`](https://github.com/mastra-ai/mastra/commit/1b73665e8e23f5c09d49fcf3e7d709c75259259e), [`f7d7475`](https://github.com/mastra-ai/mastra/commit/f7d747507341aef60ed39e4b49318db1f86034a6), [`084b77b`](https://github.com/mastra-ai/mastra/commit/084b77b2955960e0190af8db3f77138aa83ed65c), [`a93ff84`](https://github.com/mastra-ai/mastra/commit/a93ff84b5e1af07ee236ac8873dac9b49aa5d501), [`bc5aacb`](https://github.com/mastra-ai/mastra/commit/bc5aacb646d468d325327e36117129f28cd13bf6), [`6b5af12`](https://github.com/mastra-ai/mastra/commit/6b5af12ce9e09066e0c32e821c203a6954498bea), [`bf60e4a`](https://github.com/mastra-ai/mastra/commit/bf60e4a89c515afd9570b7b79f33b95e7d07c397), [`d41aee5`](https://github.com/mastra-ai/mastra/commit/d41aee526d124e35f42720a08e64043229193679), [`e8fe13c`](https://github.com/mastra-ai/mastra/commit/e8fe13c4b4c255a42520127797ec394310f7c919), [`3ca833d`](https://github.com/mastra-ai/mastra/commit/3ca833dc994c38e3c9b4f9b4478a61cd8e07b32a), [`1edb8d1`](https://github.com/mastra-ai/mastra/commit/1edb8d1cfb963e72a12412990fb9170936c9904c), [`fbf6e32`](https://github.com/mastra-ai/mastra/commit/fbf6e324946332d0f5ed8930bf9d4d4479cefd7a), [`4753027`](https://github.com/mastra-ai/mastra/commit/4753027ee889288775c6958bdfeda03ff909af67)]:
|
|
470
|
-
- @mastra/core@0.20.0
|
|
471
|
-
|
|
472
|
-
## 0.17.1-alpha.0
|
|
473
|
-
|
|
474
|
-
### Patch Changes
|
|
475
|
-
|
|
476
|
-
- Breaking change to move the agent.streamVNext/generateVNext implementation to the default stream/generate. The old stream/generate have now been moved to streamLegacy and generateLegacy ([#8097](https://github.com/mastra-ai/mastra/pull/8097))
|
|
477
|
-
|
|
478
|
-
- Updated dependencies [[`00cb6bd`](https://github.com/mastra-ai/mastra/commit/00cb6bdf78737c0fac14a5a0c7b532a11e38558a), [`869ba22`](https://github.com/mastra-ai/mastra/commit/869ba222e1d6b58fc1b65e7c9fd55ca4e01b8c2f), [`1b73665`](https://github.com/mastra-ai/mastra/commit/1b73665e8e23f5c09d49fcf3e7d709c75259259e), [`f7d7475`](https://github.com/mastra-ai/mastra/commit/f7d747507341aef60ed39e4b49318db1f86034a6), [`084b77b`](https://github.com/mastra-ai/mastra/commit/084b77b2955960e0190af8db3f77138aa83ed65c), [`a93ff84`](https://github.com/mastra-ai/mastra/commit/a93ff84b5e1af07ee236ac8873dac9b49aa5d501), [`bc5aacb`](https://github.com/mastra-ai/mastra/commit/bc5aacb646d468d325327e36117129f28cd13bf6), [`6b5af12`](https://github.com/mastra-ai/mastra/commit/6b5af12ce9e09066e0c32e821c203a6954498bea), [`bf60e4a`](https://github.com/mastra-ai/mastra/commit/bf60e4a89c515afd9570b7b79f33b95e7d07c397), [`d41aee5`](https://github.com/mastra-ai/mastra/commit/d41aee526d124e35f42720a08e64043229193679), [`e8fe13c`](https://github.com/mastra-ai/mastra/commit/e8fe13c4b4c255a42520127797ec394310f7c919), [`3ca833d`](https://github.com/mastra-ai/mastra/commit/3ca833dc994c38e3c9b4f9b4478a61cd8e07b32a), [`1edb8d1`](https://github.com/mastra-ai/mastra/commit/1edb8d1cfb963e72a12412990fb9170936c9904c), [`fbf6e32`](https://github.com/mastra-ai/mastra/commit/fbf6e324946332d0f5ed8930bf9d4d4479cefd7a), [`4753027`](https://github.com/mastra-ai/mastra/commit/4753027ee889288775c6958bdfeda03ff909af67)]:
|
|
479
|
-
- @mastra/core@0.20.0-alpha.0
|
|
480
|
-
|
|
481
|
-
## 0.17.0
|
|
482
|
-
|
|
483
|
-
### Minor Changes
|
|
484
|
-
|
|
485
|
-
- Added Postgres and updated libsql storage adapters for ai-traces ([#8027](https://github.com/mastra-ai/mastra/pull/8027))
|
|
486
|
-
|
|
487
|
-
### Patch Changes
|
|
488
|
-
|
|
489
|
-
- Update peer deps ([#8154](https://github.com/mastra-ai/mastra/pull/8154))
|
|
490
|
-
|
|
491
|
-
- Add PG Store api to fetch scores by traceId and spanId ([#8154](https://github.com/mastra-ai/mastra/pull/8154))
|
|
492
|
-
|
|
493
|
-
- add SSL support to connection string configuration ([#8178](https://github.com/mastra-ai/mastra/pull/8178))
|
|
494
|
-
|
|
495
|
-
- Updated dependencies [[`dc099b4`](https://github.com/mastra-ai/mastra/commit/dc099b40fb31147ba3f362f98d991892033c4c67), [`504438b`](https://github.com/mastra-ai/mastra/commit/504438b961bde211071186bba63a842c4e3db879), [`b342a68`](https://github.com/mastra-ai/mastra/commit/b342a68e1399cf1ece9ba11bda112db89d21118c), [`a7243e2`](https://github.com/mastra-ai/mastra/commit/a7243e2e58762667a6e3921e755e89d6bb0a3282), [`7fceb0a`](https://github.com/mastra-ai/mastra/commit/7fceb0a327d678e812f90f5387c5bc4f38bd039e), [`303a9c0`](https://github.com/mastra-ai/mastra/commit/303a9c0d7dd58795915979f06a0512359e4532fb), [`df64f9e`](https://github.com/mastra-ai/mastra/commit/df64f9ef814916fff9baedd861c988084e7c41de), [`370f8a6`](https://github.com/mastra-ai/mastra/commit/370f8a6480faec70fef18d72e5f7538f27004301), [`809eea0`](https://github.com/mastra-ai/mastra/commit/809eea092fa80c3f69b9eaf078d843b57fd2a88e), [`683e5a1`](https://github.com/mastra-ai/mastra/commit/683e5a1466e48b686825b2c11f84680f296138e4), [`3679378`](https://github.com/mastra-ai/mastra/commit/3679378673350aa314741dc826f837b1984149bc), [`7775bc2`](https://github.com/mastra-ai/mastra/commit/7775bc20bb1ad1ab24797fb420e4f96c65b0d8ec), [`623ffaf`](https://github.com/mastra-ai/mastra/commit/623ffaf2d969e11e99a0224633cf7b5a0815c857), [`9fc1613`](https://github.com/mastra-ai/mastra/commit/9fc16136400186648880fd990119ac15f7c02ee4), [`61f62aa`](https://github.com/mastra-ai/mastra/commit/61f62aa31bc88fe4ddf8da6240dbcfbeb07358bd), [`db1891a`](https://github.com/mastra-ai/mastra/commit/db1891a4707443720b7cd8a260dc7e1d49b3609c), [`e8f379d`](https://github.com/mastra-ai/mastra/commit/e8f379d390efa264c4e0874f9ac0cf8839b07777), [`652066b`](https://github.com/mastra-ai/mastra/commit/652066bd1efc6bb6813ba950ed1d7573e8b7d9d4), [`3e292ba`](https://github.com/mastra-ai/mastra/commit/3e292ba00837886d5d68a34cbc0d9b703c991883), [`418c136`](https://github.com/mastra-ai/mastra/commit/418c1366843d88e491bca3f87763899ce855ca29), [`ea8d386`](https://github.com/mastra-ai/mastra/commit/ea8d386cd8c5593664515fd5770c06bf2aa980ef), [`67b0f00`](https://github.com/mastra-ai/mastra/commit/67b0f005b520335c71fb85cbaa25df4ce8484a81), [`c2a4919`](https://github.com/mastra-ai/mastra/commit/c2a4919ba6797d8bdb1509e02287496eef69303e), [`c84b7d0`](https://github.com/mastra-ai/mastra/commit/c84b7d093c4657772140cbfd2b15ef72f3315ed5), [`0130986`](https://github.com/mastra-ai/mastra/commit/0130986fc62d0edcc626dd593282661dbb9af141)]:
|
|
496
|
-
- @mastra/core@0.19.0
|
|
497
|
-
|
|
498
|
-
## 0.17.0-alpha.0
|
|
499
|
-
|
|
500
|
-
### Minor Changes
|
|
501
|
-
|
|
502
|
-
... 2707 more lines hidden. See full changelog in package directory.
|
|
502
|
+
... 2755 more lines hidden. See full changelog in package directory.
|
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @mastra/playground-ui
|
|
2
2
|
|
|
3
|
+
## 7.0.0-beta.9
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Fix default value showing on workflow form after user submits ([#10983](https://github.com/mastra-ai/mastra/pull/10983))
|
|
8
|
+
|
|
9
|
+
- Move useScorers down to trace page to trigger it once for all trace spans ([#10985](https://github.com/mastra-ai/mastra/pull/10985))
|
|
10
|
+
|
|
11
|
+
- Update Observability Trace Spans list UI, so a user can expand/collapse span children/descendants and can filter the list by span type or name ([#10378](https://github.com/mastra-ai/mastra/pull/10378))
|
|
12
|
+
|
|
13
|
+
- Add UI to match with the mastra studio command ([#10283](https://github.com/mastra-ai/mastra/pull/10283))
|
|
14
|
+
|
|
15
|
+
- Fix workflow trigger form overflow ([#10986](https://github.com/mastra-ai/mastra/pull/10986))
|
|
16
|
+
|
|
17
|
+
- Updated dependencies [[`72df8ae`](https://github.com/mastra-ai/mastra/commit/72df8ae595584cdd7747d5c39ffaca45e4507227), [`9198899`](https://github.com/mastra-ai/mastra/commit/91988995c427b185c33714b7f3be955367911324), [`a54793a`](https://github.com/mastra-ai/mastra/commit/a54793a6377edb87d43a795711deedf487152d5c), [`653e65a`](https://github.com/mastra-ai/mastra/commit/653e65ae1f9502c2958a32f47a5a2df11e612a92), [`c6fd6fe`](https://github.com/mastra-ai/mastra/commit/c6fd6fedd09e9cf8004b03a80925f5e94826ad7e), [`5a1ede1`](https://github.com/mastra-ai/mastra/commit/5a1ede1f7ab527b9ead11f7eee2f73e67aeca9e4), [`92a2ab4`](https://github.com/mastra-ai/mastra/commit/92a2ab408a21d7f88f8db111838bc247069c2ee9), [`0bed332`](https://github.com/mastra-ai/mastra/commit/0bed332843f627202c6520eaf671771313cd20f3), [`0bed332`](https://github.com/mastra-ai/mastra/commit/0bed332843f627202c6520eaf671771313cd20f3)]:
|
|
18
|
+
- @mastra/core@1.0.0-beta.9
|
|
19
|
+
- @mastra/ai-sdk@1.0.0-beta.7
|
|
20
|
+
- @mastra/client-js@1.0.0-beta.9
|
|
21
|
+
- @mastra/react@0.1.0-beta.9
|
|
22
|
+
|
|
3
23
|
## 7.0.0-beta.8
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
|
@@ -478,25 +498,5 @@
|
|
|
478
498
|
|
|
479
499
|
do
|
|
480
500
|
|
|
481
|
-
```
|
|
482
|
-
z.discriminatedUnion('type', [
|
|
483
|
-
z.object({ type: z.literal('byCity'), city: z.string() }).extend({ order: z.number() }),
|
|
484
|
-
z.object({ type: z.literal('byCoords'), lat: z.number(), lon: z.number() }).extend({ order: z.number() }),
|
|
485
|
-
]);
|
|
486
|
-
```
|
|
487
|
-
|
|
488
|
-
- Extract more components to playground-ui for sharing with cloud ([#9241](https://github.com/mastra-ai/mastra/pull/9241))
|
|
489
|
-
|
|
490
|
-
- Fix undefined window issue when Sidebar used in Next app ([#9448](https://github.com/mastra-ai/mastra/pull/9448))
|
|
491
|
-
|
|
492
|
-
- Move WorkflowInformation to playground-ui ([#9297](https://github.com/mastra-ai/mastra/pull/9297))
|
|
493
|
-
|
|
494
|
-
- Remove `waitForEvent` from workflows. `waitForEvent` is now removed, please use suspend & resume flow instead. See https://mastra.ai/en/docs/workflows/suspend-and-resume for more details on suspend & resume flow. ([#9214](https://github.com/mastra-ai/mastra/pull/9214))
|
|
495
|
-
|
|
496
|
-
- Add combobox in playground for entities and update routes and error handling ([#9743](https://github.com/mastra-ai/mastra/pull/9743))
|
|
497
|
-
|
|
498
|
-
- **Breaking Changes:** ([#9045](https://github.com/mastra-ai/mastra/pull/9045))
|
|
499
|
-
- Moved `generateTitle` from `threads.generateTitle` to top-level memory option
|
|
500
|
-
- Changed default value from `true` to `false`
|
|
501
501
|
|
|
502
|
-
...
|
|
502
|
+
... 4154 more lines hidden. See full changelog in package directory.
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# @mastra/react-hooks
|
|
2
2
|
|
|
3
|
+
## 0.1.0-beta.9
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`5a1ede1`](https://github.com/mastra-ai/mastra/commit/5a1ede1f7ab527b9ead11f7eee2f73e67aeca9e4)]:
|
|
8
|
+
- @mastra/client-js@1.0.0-beta.9
|
|
9
|
+
|
|
3
10
|
## 0.1.0-beta.8
|
|
4
11
|
|
|
5
12
|
### Patch Changes
|
|
@@ -1,5 +1,53 @@
|
|
|
1
1
|
# @mastra/server
|
|
2
2
|
|
|
3
|
+
## 1.0.0-beta.9
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Add stored agents support ([#10953](https://github.com/mastra-ai/mastra/pull/10953))
|
|
8
|
+
|
|
9
|
+
Agents can now be stored in the database and loaded at runtime. This lets you persist agent configurations and dynamically create executable Agent instances from storage.
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
import { Mastra } from '@mastra/core';
|
|
13
|
+
import { LibSQLStore } from '@mastra/libsql';
|
|
14
|
+
|
|
15
|
+
const mastra = new Mastra({
|
|
16
|
+
storage: new LibSQLStore({ url: ':memory:' }),
|
|
17
|
+
tools: { myTool },
|
|
18
|
+
scorers: { myScorer },
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
// Create agent in storage via API or directly
|
|
22
|
+
await mastra.getStorage().createAgent({
|
|
23
|
+
agent: {
|
|
24
|
+
id: 'my-agent',
|
|
25
|
+
name: 'My Agent',
|
|
26
|
+
instructions: 'You are helpful',
|
|
27
|
+
model: { provider: 'openai', name: 'gpt-4' },
|
|
28
|
+
tools: { myTool: {} },
|
|
29
|
+
scorers: { myScorer: { sampling: { type: 'ratio', rate: 0.5 } } },
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
// Load and use the agent
|
|
34
|
+
const agent = await mastra.getStoredAgentById('my-agent');
|
|
35
|
+
const response = await agent.generate({ messages: 'Hello!' });
|
|
36
|
+
|
|
37
|
+
// List all stored agents with pagination
|
|
38
|
+
const { agents, total, hasMore } = await mastra.listStoredAgents({
|
|
39
|
+
page: 0,
|
|
40
|
+
perPage: 10,
|
|
41
|
+
});
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Also adds a memory registry to Mastra so stored agents can reference memory instances by key.
|
|
45
|
+
|
|
46
|
+
### Patch Changes
|
|
47
|
+
|
|
48
|
+
- Updated dependencies [[`72df8ae`](https://github.com/mastra-ai/mastra/commit/72df8ae595584cdd7747d5c39ffaca45e4507227), [`9198899`](https://github.com/mastra-ai/mastra/commit/91988995c427b185c33714b7f3be955367911324), [`653e65a`](https://github.com/mastra-ai/mastra/commit/653e65ae1f9502c2958a32f47a5a2df11e612a92), [`c6fd6fe`](https://github.com/mastra-ai/mastra/commit/c6fd6fedd09e9cf8004b03a80925f5e94826ad7e), [`0bed332`](https://github.com/mastra-ai/mastra/commit/0bed332843f627202c6520eaf671771313cd20f3)]:
|
|
49
|
+
- @mastra/core@1.0.0-beta.9
|
|
50
|
+
|
|
3
51
|
## 1.0.0-beta.8
|
|
4
52
|
|
|
5
53
|
### Patch Changes
|
|
@@ -451,52 +499,4 @@
|
|
|
451
499
|
|
|
452
500
|
### Patch Changes
|
|
453
501
|
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
- Add agent id to the list agent ([#9770](https://github.com/mastra-ai/mastra/pull/9770))
|
|
457
|
-
|
|
458
|
-
- Update tool execution signature ([#9587](https://github.com/mastra-ai/mastra/pull/9587))
|
|
459
|
-
|
|
460
|
-
Consolidated the 3 different execution contexts to one
|
|
461
|
-
|
|
462
|
-
```typescript
|
|
463
|
-
// before depending on the context the tool was executed in
|
|
464
|
-
tool.execute({ context: data });
|
|
465
|
-
tool.execute({ context: { inputData: data } });
|
|
466
|
-
tool.execute(data);
|
|
467
|
-
|
|
468
|
-
// now, for all contexts
|
|
469
|
-
tool.execute(data, context);
|
|
470
|
-
```
|
|
471
|
-
|
|
472
|
-
**Before:**
|
|
473
|
-
|
|
474
|
-
```typescript
|
|
475
|
-
inputSchema: z.object({ something: z.string() }),
|
|
476
|
-
execute: async ({ context, tracingContext, runId, ... }) => {
|
|
477
|
-
return doSomething(context.string);
|
|
478
|
-
}
|
|
479
|
-
```
|
|
480
|
-
|
|
481
|
-
**After:**
|
|
482
|
-
|
|
483
|
-
```typescript
|
|
484
|
-
inputSchema: z.object({ something: z.string() }),
|
|
485
|
-
execute: async (inputData, context) => {
|
|
486
|
-
const { agent, mcp, workflow, ...sharedContext } = context
|
|
487
|
-
|
|
488
|
-
// context that only an agent would get like toolCallId, messages, suspend, resume, etc
|
|
489
|
-
if (agent) {
|
|
490
|
-
doSomething(inputData.something, agent)
|
|
491
|
-
// context that only a workflow would get like runId, state, suspend, resume, etc
|
|
492
|
-
} else if (workflow) {
|
|
493
|
-
doSomething(inputData.something, workflow)
|
|
494
|
-
// context that only a workflow would get like "extra", "elicitation"
|
|
495
|
-
} else if (mcp) {
|
|
496
|
-
doSomething(inputData.something, mcp)
|
|
497
|
-
} else {
|
|
498
|
-
// Running a tool in no execution context
|
|
499
|
-
return doSomething(inputData.something);
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
... 4179 more lines hidden. See full changelog in package directory.
|
|
502
|
+
... 4227 more lines hidden. See full changelog in package directory.
|
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# create-mastra
|
|
2
2
|
|
|
3
|
+
## 1.0.0-beta.7
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Fix default value showing on workflow form after user submits ([#10983](https://github.com/mastra-ai/mastra/pull/10983))
|
|
8
|
+
|
|
9
|
+
- Move useScorers down to trace page to trigger it once for all trace spans ([#10985](https://github.com/mastra-ai/mastra/pull/10985))
|
|
10
|
+
|
|
11
|
+
- Update Observability Trace Spans list UI, so a user can expand/collapse span children/descendants and can filter the list by span type or name ([#10378](https://github.com/mastra-ai/mastra/pull/10378))
|
|
12
|
+
|
|
13
|
+
- Fix workflow trigger form overflow ([#10986](https://github.com/mastra-ai/mastra/pull/10986))
|
|
14
|
+
|
|
3
15
|
## 1.0.0-beta.6
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -487,16 +499,4 @@
|
|
|
487
499
|
|
|
488
500
|
- Fix template slug when getting template environment variables ([#7650](https://github.com/mastra-ai/mastra/pull/7650))
|
|
489
501
|
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
### Patch Changes
|
|
493
|
-
|
|
494
|
-
- add workflow streaming in agent thread ([#7506](https://github.com/mastra-ai/mastra/pull/7506))
|
|
495
|
-
|
|
496
|
-
## 0.12.1-alpha.0
|
|
497
|
-
|
|
498
|
-
### Patch Changes
|
|
499
|
-
|
|
500
|
-
- dependencies updates: ([#7544](https://github.com/mastra-ai/mastra/pull/7544))
|
|
501
|
-
|
|
502
|
-
... 1636 more lines hidden. See full changelog in package directory.
|
|
502
|
+
... 1648 more lines hidden. See full changelog in package directory.
|
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# mastra
|
|
2
2
|
|
|
3
|
+
## 1.0.0-beta.7
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Add `mastra studio` CLI command to serve the built playground as a static server ([#10283](https://github.com/mastra-ai/mastra/pull/10283))
|
|
8
|
+
|
|
9
|
+
- Fix default value showing on workflow form after user submits ([#10983](https://github.com/mastra-ai/mastra/pull/10983))
|
|
10
|
+
|
|
11
|
+
- Move to @posthog/react which is the actual way to use posthog in React. It also fixes ([#10967](https://github.com/mastra-ai/mastra/pull/10967))
|
|
12
|
+
|
|
13
|
+
- Move useScorers down to trace page to trigger it once for all trace spans ([#10985](https://github.com/mastra-ai/mastra/pull/10985))
|
|
14
|
+
|
|
15
|
+
- Update Observability Trace Spans list UI, so a user can expand/collapse span children/descendants and can filter the list by span type or name ([#10378](https://github.com/mastra-ai/mastra/pull/10378))
|
|
16
|
+
|
|
17
|
+
- Fix workflow trigger form overflow ([#10986](https://github.com/mastra-ai/mastra/pull/10986))
|
|
18
|
+
|
|
19
|
+
- Updated dependencies [[`72df8ae`](https://github.com/mastra-ai/mastra/commit/72df8ae595584cdd7747d5c39ffaca45e4507227), [`9198899`](https://github.com/mastra-ai/mastra/commit/91988995c427b185c33714b7f3be955367911324), [`7761c77`](https://github.com/mastra-ai/mastra/commit/7761c778b7b083cb01f7587cfa66010307204d00), [`653e65a`](https://github.com/mastra-ai/mastra/commit/653e65ae1f9502c2958a32f47a5a2df11e612a92), [`c6fd6fe`](https://github.com/mastra-ai/mastra/commit/c6fd6fedd09e9cf8004b03a80925f5e94826ad7e), [`0bed332`](https://github.com/mastra-ai/mastra/commit/0bed332843f627202c6520eaf671771313cd20f3)]:
|
|
20
|
+
- @mastra/core@1.0.0-beta.9
|
|
21
|
+
- @mastra/deployer@1.0.0-beta.9
|
|
22
|
+
|
|
3
23
|
## 1.0.0-beta.6
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
|
@@ -478,25 +498,5 @@
|
|
|
478
498
|
|
|
479
499
|
- remove icons in entity lists ([#8520](https://github.com/mastra-ai/mastra/pull/8520))
|
|
480
500
|
|
|
481
|
-
- add client search to all entities ([#8523](https://github.com/mastra-ai/mastra/pull/8523))
|
|
482
|
-
|
|
483
|
-
- Fixed an issue where model router was adding /chat/completions to API urls when it shouldn't. ([#8589](https://github.com/mastra-ai/mastra/pull/8589))
|
|
484
|
-
fixed an issue with provider ID rendering in playground UI
|
|
485
|
-
|
|
486
|
-
- Fix useStreamWorkflow unmounting breaking stream call ([#8449](https://github.com/mastra-ai/mastra/pull/8449))
|
|
487
|
-
|
|
488
|
-
- Remove shell from dev ([#8466](https://github.com/mastra-ai/mastra/pull/8466))
|
|
489
|
-
|
|
490
|
-
- UX for the agents page ([#8517](https://github.com/mastra-ai/mastra/pull/8517))
|
|
491
|
-
|
|
492
|
-
- add icons into playground titles + a link to the entity doc ([#8518](https://github.com/mastra-ai/mastra/pull/8518))
|
|
493
|
-
|
|
494
|
-
- Updated dependencies [[`c621613`](https://github.com/mastra-ai/mastra/commit/c621613069173c69eb2c3ef19a5308894c6549f0), [`ee17cec`](https://github.com/mastra-ai/mastra/commit/ee17cec065f4454740c9cc8f8a841027a5990f57), [`12b1189`](https://github.com/mastra-ai/mastra/commit/12b118942445e4de0dd916c593e33ec78dc3bc73), [`42ffed3`](https://github.com/mastra-ai/mastra/commit/42ffed311b9d8750652bbc55c773be62c989fcc6), [`4783b30`](https://github.com/mastra-ai/mastra/commit/4783b3063efea887825514b783ba27f67912c26d), [`076b092`](https://github.com/mastra-ai/mastra/commit/076b0924902ff0f49d5712d2df24c4cca683713f), [`2aee9e7`](https://github.com/mastra-ai/mastra/commit/2aee9e7d188b8b256a4ddc203ccefb366b4867fa), [`c582906`](https://github.com/mastra-ai/mastra/commit/c5829065a346260f96c4beb8af131b94804ae3ad), [`fa2eb96`](https://github.com/mastra-ai/mastra/commit/fa2eb96af16c7d433891a73932764960d3235c1d), [`ee9108f`](https://github.com/mastra-ai/mastra/commit/ee9108fa29bb8368fc23df158c9f0645b2d7b65c), [`4783b30`](https://github.com/mastra-ai/mastra/commit/4783b3063efea887825514b783ba27f67912c26d), [`a739d0c`](https://github.com/mastra-ai/mastra/commit/a739d0c8b37cd89569e04a6ca0827083c6167e19), [`a9c4cb7`](https://github.com/mastra-ai/mastra/commit/a9c4cb7d6a35de23ca51066f166a66e0e4cca418), [`603e927`](https://github.com/mastra-ai/mastra/commit/603e9279db8bf8a46caf83881c6b7389ccffff7e), [`cd45982`](https://github.com/mastra-ai/mastra/commit/cd4598291cda128a88738734ae6cbef076ebdebd), [`874f74d`](https://github.com/mastra-ai/mastra/commit/874f74da4b1acf6517f18132d035612c3ecc394a), [`b728a45`](https://github.com/mastra-ai/mastra/commit/b728a45ab3dba59da0f5ee36b81fe246659f305d), [`0baf2ba`](https://github.com/mastra-ai/mastra/commit/0baf2bab8420277072ef1f95df5ea7b0a2f61fe7), [`10e633a`](https://github.com/mastra-ai/mastra/commit/10e633a07d333466d9734c97acfc3dbf757ad2d0), [`a6d69c5`](https://github.com/mastra-ai/mastra/commit/a6d69c5fb50c0875b46275811fece5862f03c6a0), [`84199af`](https://github.com/mastra-ai/mastra/commit/84199af8673f6f9cb59286ffb5477a41932775de), [`7f431af`](https://github.com/mastra-ai/mastra/commit/7f431afd586b7d3265075e73106eb73167edbb86), [`26e968d`](https://github.com/mastra-ai/mastra/commit/26e968db2171ded9e4d47aa1b4f19e1e771158d0), [`cbd3fb6`](https://github.com/mastra-ai/mastra/commit/cbd3fb65adb03a7c0df193cb998aed5ac56675ee)]:
|
|
495
|
-
- @mastra/core@0.20.1
|
|
496
|
-
- @mastra/deployer@0.20.1
|
|
497
|
-
- @mastra/mcp@0.13.4
|
|
498
|
-
|
|
499
|
-
## 0.15.0-alpha.3
|
|
500
|
-
|
|
501
501
|
|
|
502
|
-
...
|
|
502
|
+
... 6338 more lines hidden. See full changelog in package directory.
|
|
@@ -82,9 +82,8 @@ const app = new Hono<{ Bindings: HonoBindings; Variables: HonoVariables }>();
|
|
|
82
82
|
app.get('/', c => c.json({ status: 'ok', server: 'hono', message: 'Hono MCP Server is running' }));
|
|
83
83
|
|
|
84
84
|
// Create Mastra server adapter
|
|
85
|
-
// Note: Type assertion needed due to Hono version differences between example and @mastra/hono
|
|
86
85
|
const adapter = new MastraServer({
|
|
87
|
-
app
|
|
86
|
+
app,
|
|
88
87
|
mastra,
|
|
89
88
|
});
|
|
90
89
|
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
### package.json
|
|
2
|
+
```json
|
|
3
|
+
{
|
|
4
|
+
"name": "examples-processors-with-ai-sdk",
|
|
5
|
+
"dependencies": {
|
|
6
|
+
"@ai-sdk/openai": "latest",
|
|
7
|
+
"@mastra/ai-sdk": "latest",
|
|
8
|
+
"@mastra/core": "latest",
|
|
9
|
+
"@mastra/libsql": "latest",
|
|
10
|
+
"ai": "latest",
|
|
11
|
+
"zod": "^3.25.76"
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
```
|
|
@@ -42,7 +42,7 @@ const BASE_URL = 'http://internal';
|
|
|
42
42
|
async function main() {
|
|
43
43
|
// Create and initialize server (no port binding)
|
|
44
44
|
const app = new Hono<{ Bindings: HonoBindings; Variables: HonoVariables }>();
|
|
45
|
-
const adapter = new MastraServer({ app
|
|
45
|
+
const adapter = new MastraServer({ app, mastra });
|
|
46
46
|
await adapter.init();
|
|
47
47
|
|
|
48
48
|
// Get the server app - works because MastraServer auto-registers with mastra
|
|
@@ -64,7 +64,7 @@ import { HonoBindings, HonoVariables, MastraServer } from '@mastra/hono';
|
|
|
64
64
|
import { mastra } from './mastra';
|
|
65
65
|
|
|
66
66
|
const app = new Hono<{ Bindings: HonoBindings; Variables: HonoVariables }>();
|
|
67
|
-
const server = new MastraServer({ app
|
|
67
|
+
const server = new MastraServer({ app, mastra });
|
|
68
68
|
|
|
69
69
|
await server.init();
|
|
70
70
|
|
|
@@ -80,8 +80,10 @@ When running a workflow, you can also view detailed traces showing tool calls, r
|
|
|
80
80
|
Run tools in isolation to observe their behavior. Test them before assigning them to your agent, or isolate them to debug issues should something go wrong.
|
|
81
81
|
|
|
82
82
|
<VideoPlayer src="https://res.cloudinary.com/mastra-assets/video/upload/v1751406316/local-dev-agents-tools_100_fe1jdt.mp4" />
|
|
83
|
-
|
|
84
|
-
|
|
83
|
+
|
|
84
|
+
### MCP
|
|
85
|
+
|
|
86
|
+
List the MCP servers attached to your Mastra instance and explore their available tools.
|
|
85
87
|
|
|
86
88
|

|
|
87
89
|
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "AI SDK | Agent Frameworks"
|
|
3
|
+
description: "Use Mastra processors and memory with the Vercel AI SDK"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
import Tabs from "@theme/Tabs";
|
|
7
|
+
import TabItem from "@theme/TabItem";
|
|
8
|
+
|
|
9
|
+
# AI SDK
|
|
10
|
+
|
|
11
|
+
If you're already using the [Vercel AI SDK](https://sdk.vercel.ai) directly and want to add Mastra capabilities like [processors](/docs/v1/agents/processors) or [memory](/docs/v1/memory/memory-processors) without switching to the full Mastra agent API, `withMastra()` lets you wrap any AI SDK model with these features. This is useful when you want to keep your existing AI SDK code but add input/output processing, conversation persistence, or content filtering.
|
|
12
|
+
|
|
13
|
+
Learn more about the features you can add:
|
|
14
|
+
- [Processors](/docs/v1/agents/processors) - Learn about input and output processors
|
|
15
|
+
- [Memory](/docs/v1/memory/overview) - Overview of Mastra's memory system
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
<Tabs>
|
|
20
|
+
<TabItem value="npm" label="npm">
|
|
21
|
+
```bash copy
|
|
22
|
+
npm install @mastra/ai-sdk@beta
|
|
23
|
+
```
|
|
24
|
+
</TabItem>
|
|
25
|
+
<TabItem value="pnpm" label="pnpm">
|
|
26
|
+
```bash copy
|
|
27
|
+
pnpm add @mastra/ai-sdk@beta
|
|
28
|
+
```
|
|
29
|
+
</TabItem>
|
|
30
|
+
<TabItem value="yarn" label="yarn">
|
|
31
|
+
```bash copy
|
|
32
|
+
yarn add @mastra/ai-sdk@beta
|
|
33
|
+
```
|
|
34
|
+
</TabItem>
|
|
35
|
+
<TabItem value="bun" label="bun">
|
|
36
|
+
```bash copy
|
|
37
|
+
bun add @mastra/ai-sdk@beta
|
|
38
|
+
```
|
|
39
|
+
</TabItem>
|
|
40
|
+
</Tabs>
|
|
41
|
+
|
|
42
|
+
## With Processors
|
|
43
|
+
|
|
44
|
+
Processors let you transform messages before they're sent to the model (`processInput`) and after responses are received (`processOutputResult`). This example creates a logging processor that logs message counts at each stage, then wraps an OpenAI model with it.
|
|
45
|
+
|
|
46
|
+
```typescript title="src/example.ts" copy
|
|
47
|
+
import { openai } from '@ai-sdk/openai';
|
|
48
|
+
import { generateText } from 'ai';
|
|
49
|
+
import { withMastra } from '@mastra/ai-sdk';
|
|
50
|
+
import type { Processor } from '@mastra/core/processors';
|
|
51
|
+
|
|
52
|
+
const loggingProcessor: Processor<'logger'> = {
|
|
53
|
+
id: 'logger',
|
|
54
|
+
async processInput({ messages }) {
|
|
55
|
+
console.log('Input:', messages.length, 'messages');
|
|
56
|
+
return messages;
|
|
57
|
+
},
|
|
58
|
+
async processOutputResult({ messages }) {
|
|
59
|
+
console.log('Output:', messages.length, 'messages');
|
|
60
|
+
return messages;
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const model = withMastra(openai('gpt-4o'), {
|
|
65
|
+
inputProcessors: [loggingProcessor],
|
|
66
|
+
outputProcessors: [loggingProcessor],
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
const { text } = await generateText({
|
|
70
|
+
model,
|
|
71
|
+
prompt: 'What is 2 + 2?',
|
|
72
|
+
});
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## With Memory
|
|
76
|
+
|
|
77
|
+
Memory automatically loads previous messages from storage before the LLM call and saves new messages after. This example configures a LibSQL storage backend to persist conversation history, loading the last 10 messages for context.
|
|
78
|
+
|
|
79
|
+
```typescript title="src/memory-example.ts" copy
|
|
80
|
+
import { openai } from '@ai-sdk/openai';
|
|
81
|
+
import { generateText } from 'ai';
|
|
82
|
+
import { withMastra } from '@mastra/ai-sdk';
|
|
83
|
+
import { LibSQLStore } from '@mastra/libsql';
|
|
84
|
+
|
|
85
|
+
const storage = new LibSQLStore({
|
|
86
|
+
id: 'my-app',
|
|
87
|
+
url: 'file:./data.db',
|
|
88
|
+
});
|
|
89
|
+
await storage.init();
|
|
90
|
+
|
|
91
|
+
const model = withMastra(openai('gpt-4o'), {
|
|
92
|
+
memory: {
|
|
93
|
+
storage,
|
|
94
|
+
threadId: 'user-thread-123',
|
|
95
|
+
resourceId: 'user-123',
|
|
96
|
+
lastMessages: 10,
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
const { text } = await generateText({
|
|
101
|
+
model,
|
|
102
|
+
prompt: 'What did we talk about earlier?',
|
|
103
|
+
});
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## With Both
|
|
107
|
+
|
|
108
|
+
You can combine processors and memory together. Input processors run after memory loads historical messages, and output processors run before memory saves the response.
|
|
109
|
+
|
|
110
|
+
```typescript title="src/combined-example.ts" copy
|
|
111
|
+
import { openai } from '@ai-sdk/openai';
|
|
112
|
+
import { generateText } from 'ai';
|
|
113
|
+
import { withMastra } from '@mastra/ai-sdk';
|
|
114
|
+
import { LibSQLStore } from '@mastra/libsql';
|
|
115
|
+
|
|
116
|
+
const storage = new LibSQLStore({ id: 'my-app', url: 'file:./data.db' });
|
|
117
|
+
await storage.init();
|
|
118
|
+
|
|
119
|
+
const model = withMastra(openai('gpt-4o'), {
|
|
120
|
+
inputProcessors: [myGuardProcessor],
|
|
121
|
+
outputProcessors: [myLoggingProcessor],
|
|
122
|
+
memory: {
|
|
123
|
+
storage,
|
|
124
|
+
threadId: 'thread-123',
|
|
125
|
+
resourceId: 'user-123',
|
|
126
|
+
lastMessages: 10,
|
|
127
|
+
},
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
const { text } = await generateText({
|
|
131
|
+
model,
|
|
132
|
+
prompt: 'Hello!',
|
|
133
|
+
});
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## API Reference
|
|
137
|
+
|
|
138
|
+
### `withMastra(model, options)`
|
|
139
|
+
|
|
140
|
+
Wraps an AI SDK model with Mastra processors and/or memory.
|
|
141
|
+
|
|
142
|
+
**Parameters:**
|
|
143
|
+
|
|
144
|
+
- `model` - Any AI SDK language model (e.g., `openai('gpt-4o')`, `anthropic('claude-3-opus')`)
|
|
145
|
+
- `options` - Configuration object:
|
|
146
|
+
- `inputProcessors` - Array of processors to run on input messages
|
|
147
|
+
- `outputProcessors` - Array of processors to run on output messages
|
|
148
|
+
- `memory` - Memory configuration object:
|
|
149
|
+
- `storage` - A Mastra storage instance (LibSQLStore, PostgresStore, etc.)
|
|
150
|
+
- `threadId` - Unique identifier for the conversation thread
|
|
151
|
+
- `resourceId` - Unique identifier for the user/resource
|
|
152
|
+
- `lastMessages` - Number of previous messages to load (default: 10)
|
|
153
|
+
- `semanticRecall` - Optional semantic search configuration
|
|
154
|
+
|
|
155
|
+
**Returns:** A wrapped model compatible with `generateText`, `streamText`, `generateObject`, and `streamObject`.
|
|
156
|
+
|
|
157
|
+
## Related
|
|
158
|
+
|
|
159
|
+
- [Processors](/docs/v1/agents/processors) - Learn about input and output processors
|
|
160
|
+
- [Memory](/docs/v1/memory/overview) - Overview of Mastra's memory system
|
|
161
|
+
- [AI SDK UI](/guides/v1/build-your-ui/ai-sdk-ui) - Using AI SDK hooks with Mastra agents
|
|
@@ -602,17 +602,17 @@ It is important that you `await` the `writer.custom()` call.
|
|
|
602
602
|
import { createTool } from "@mastra/core/tools";
|
|
603
603
|
|
|
604
604
|
export const testTool = createTool({
|
|
605
|
-
execute: async (
|
|
606
|
-
const { value } =
|
|
605
|
+
execute: async (inputData, context) => {
|
|
606
|
+
const { value } = inputData;
|
|
607
607
|
|
|
608
|
-
await writer?.custom({
|
|
608
|
+
await context?.writer?.custom({
|
|
609
609
|
type: "data-tool-progress",
|
|
610
610
|
status: "pending"
|
|
611
611
|
});
|
|
612
612
|
|
|
613
613
|
const response = await fetch(...);
|
|
614
614
|
|
|
615
|
-
await writer?.custom({
|
|
615
|
+
await context?.writer?.custom({
|
|
616
616
|
type: "data-tool-progress",
|
|
617
617
|
status: "success"
|
|
618
618
|
});
|