@mastra/react 0.4.0-alpha.0 → 0.4.0-alpha.10
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/CHANGELOG.md +103 -0
- package/dist/agent/hooks.d.ts +3 -0
- package/dist/agent/hooks.d.ts.map +1 -1
- package/dist/index.cjs +7 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +7 -3
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,108 @@
|
|
|
1
1
|
# @mastra/react
|
|
2
2
|
|
|
3
|
+
## 0.4.0-alpha.10
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`27fd1b7`](https://github.com/mastra-ai/mastra/commit/27fd1b79ac62eb7694f92587eb7d1be05b59be01), [`a702009`](https://github.com/mastra-ai/mastra/commit/a702009d3cfaa745120f501e21c783ed4d6a3072), [`8534d79`](https://github.com/mastra-ai/mastra/commit/8534d791fa1cb70fe1c19e2604c4b63cc10dd051), [`c78f8cd`](https://github.com/mastra-ai/mastra/commit/c78f8cd6222a86e6c60ae5210b6929ad5221b6fb), [`e146aad`](https://github.com/mastra-ai/mastra/commit/e146aadbba66c410ba0e74bac4c50135495cb8dd), [`1a0ec78`](https://github.com/mastra-ai/mastra/commit/1a0ec789a26cae443744e9abbd62ed6ee676af39), [`d52b6fe`](https://github.com/mastra-ai/mastra/commit/d52b6fe1c56853eb38864baae0bbfa75cc739ccb)]:
|
|
8
|
+
- @mastra/core@1.36.0-alpha.10
|
|
9
|
+
- @mastra/client-js@1.20.0-alpha.10
|
|
10
|
+
|
|
11
|
+
## 0.4.0-alpha.9
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies [[`bd92c15`](https://github.com/mastra-ai/mastra/commit/bd92c154238ce5d05e12d5477da07c7b7292c5e3), [`bd92c15`](https://github.com/mastra-ai/mastra/commit/bd92c154238ce5d05e12d5477da07c7b7292c5e3), [`1698f5e`](https://github.com/mastra-ai/mastra/commit/1698f5ec141d34f22a873efdb145ce3cdf848a5e)]:
|
|
16
|
+
- @mastra/client-js@1.20.0-alpha.9
|
|
17
|
+
- @mastra/core@1.36.0-alpha.9
|
|
18
|
+
|
|
19
|
+
## 0.4.0-alpha.8
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- Updated dependencies [[`9aee493`](https://github.com/mastra-ai/mastra/commit/9aee493ed6089b5133472623dcce49934bf2d509)]:
|
|
24
|
+
- @mastra/core@1.36.0-alpha.8
|
|
25
|
+
- @mastra/client-js@1.20.0-alpha.8
|
|
26
|
+
|
|
27
|
+
## 0.4.0-alpha.7
|
|
28
|
+
|
|
29
|
+
### Minor Changes
|
|
30
|
+
|
|
31
|
+
- Added `clientTools` option to `useChat`'s `generate`/`stream` calls for forwarding browser-side tools to the agent on each invocation. ([#16778](https://github.com/mastra-ai/mastra/pull/16778))
|
|
32
|
+
|
|
33
|
+
```tsx
|
|
34
|
+
import { useChat } from '@mastra/react';
|
|
35
|
+
|
|
36
|
+
const { generate } = useChat({ agentId: 'my-agent' });
|
|
37
|
+
|
|
38
|
+
await generate({
|
|
39
|
+
messages: [{ role: 'user', content: 'Show a toast that says hi' }],
|
|
40
|
+
clientTools: {
|
|
41
|
+
showToast: {
|
|
42
|
+
description: 'Show a toast to the user',
|
|
43
|
+
inputSchema: z.object({ message: z.string() }),
|
|
44
|
+
execute: ({ message }) => toast(message),
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Client tools are forwarded as-is to the underlying `agent.generate()` and `agent.stream()` calls.
|
|
51
|
+
|
|
52
|
+
### Patch Changes
|
|
53
|
+
|
|
54
|
+
- Updated dependencies [[`a935b0a`](https://github.com/mastra-ai/mastra/commit/a935b0a0977ae3f196b33ec7621f528069c82db0)]:
|
|
55
|
+
- @mastra/core@1.36.0-alpha.7
|
|
56
|
+
- @mastra/client-js@1.20.0-alpha.7
|
|
57
|
+
|
|
58
|
+
## 0.4.0-alpha.6
|
|
59
|
+
|
|
60
|
+
### Patch Changes
|
|
61
|
+
|
|
62
|
+
- Updated dependencies [[`71a820b`](https://github.com/mastra-ai/mastra/commit/71a820b2353fa1406772c50760a3732058a8b337)]:
|
|
63
|
+
- @mastra/core@1.36.0-alpha.6
|
|
64
|
+
- @mastra/client-js@1.20.0-alpha.6
|
|
65
|
+
|
|
66
|
+
## 0.4.0-alpha.5
|
|
67
|
+
|
|
68
|
+
### Patch Changes
|
|
69
|
+
|
|
70
|
+
- Updated dependencies [[`ac79462`](https://github.com/mastra-ai/mastra/commit/ac79462b98f1062394c45093aa515b0766f27ee2), [`19281c7`](https://github.com/mastra-ai/mastra/commit/19281c70424f757219782de16c2699743c5e04d0)]:
|
|
71
|
+
- @mastra/core@1.36.0-alpha.5
|
|
72
|
+
- @mastra/client-js@1.20.0-alpha.5
|
|
73
|
+
|
|
74
|
+
## 0.4.0-alpha.4
|
|
75
|
+
|
|
76
|
+
### Patch Changes
|
|
77
|
+
|
|
78
|
+
- Updated dependencies [[`c272d50`](https://github.com/mastra-ai/mastra/commit/c272d50610a54496b6b6d92ccd4d37b333a2613a), [`d8692af`](https://github.com/mastra-ai/mastra/commit/d8692afa253028e39cdce2aafa0ac414071a762e), [`841a222`](https://github.com/mastra-ai/mastra/commit/841a222560d8c19238f8213713f30535cdd82284)]:
|
|
79
|
+
- @mastra/core@1.36.0-alpha.4
|
|
80
|
+
- @mastra/client-js@1.20.0-alpha.4
|
|
81
|
+
|
|
82
|
+
## 0.4.0-alpha.3
|
|
83
|
+
|
|
84
|
+
### Patch Changes
|
|
85
|
+
|
|
86
|
+
- Updated dependencies [[`5556cc1`](https://github.com/mastra-ai/mastra/commit/5556cc1befec71518d84f826b3bfe3a079a9daf7), [`5499303`](https://github.com/mastra-ai/mastra/commit/54993032c1ebc09642625b78d2014e0cf84a3cae), [`3498b49`](https://github.com/mastra-ai/mastra/commit/3498b4946be94f4313cd817733589680dcda5278), [`e47bca7`](https://github.com/mastra-ai/mastra/commit/e47bca7b72866d3abd173b9f530ac4318113a8ff), [`0031d0f`](https://github.com/mastra-ai/mastra/commit/0031d0f13831d7843ac5d498734a7d92862e2ce3), [`3498b49`](https://github.com/mastra-ai/mastra/commit/3498b4946be94f4313cd817733589680dcda5278), [`359439b`](https://github.com/mastra-ai/mastra/commit/359439bb8c635e048176306828195f8297f50021)]:
|
|
87
|
+
- @mastra/core@1.36.0-alpha.3
|
|
88
|
+
- @mastra/client-js@1.20.0-alpha.3
|
|
89
|
+
|
|
90
|
+
## 0.4.0-alpha.2
|
|
91
|
+
|
|
92
|
+
### Patch Changes
|
|
93
|
+
|
|
94
|
+
- Updated dependencies [[`5ba7253`](https://github.com/mastra-ai/mastra/commit/5ba7253745c85e8df8012a76d954c640ffa336f7), [`6b25032`](https://github.com/mastra-ai/mastra/commit/6b250329fa4795b4d085cba4077c7998893c1d59), [`f73980d`](https://github.com/mastra-ai/mastra/commit/f73980d651eb5f7f1ab20582de4615a1b6f10fce), [`9c88701`](https://github.com/mastra-ai/mastra/commit/9c8870195b41a38dc40b6ba2aa55eda04df8fa69), [`9c88701`](https://github.com/mastra-ai/mastra/commit/9c8870195b41a38dc40b6ba2aa55eda04df8fa69), [`4e88dc6`](https://github.com/mastra-ai/mastra/commit/4e88dc6b89f154c0eae37221c8126be0c23c569f), [`19018f0`](https://github.com/mastra-ai/mastra/commit/19018f05722af74a5978781a7731a654b26f7f2a)]:
|
|
95
|
+
- @mastra/core@1.36.0-alpha.2
|
|
96
|
+
- @mastra/client-js@1.20.0-alpha.2
|
|
97
|
+
|
|
98
|
+
## 0.4.0-alpha.1
|
|
99
|
+
|
|
100
|
+
### Patch Changes
|
|
101
|
+
|
|
102
|
+
- Updated dependencies [[`8cdb86c`](https://github.com/mastra-ai/mastra/commit/8cdb86ceed1137bc2768e147dce85a0692b9fb26), [`9692d60`](https://github.com/mastra-ai/mastra/commit/9692d60298e8f629d10de54867642a38955fb708), [`eda90c5`](https://github.com/mastra-ai/mastra/commit/eda90c5bfd7de11805ecc9f4552716c895fbaf78), [`afc004f`](https://github.com/mastra-ai/mastra/commit/afc004f5cc7e30697809e7021820b9f5881e6719), [`408be73`](https://github.com/mastra-ai/mastra/commit/408be73449dfab92b51eab8c6623b6c443debc25)]:
|
|
103
|
+
- @mastra/core@1.36.0-alpha.1
|
|
104
|
+
- @mastra/client-js@1.20.0-alpha.1
|
|
105
|
+
|
|
3
106
|
## 0.4.0-alpha.0
|
|
4
107
|
|
|
5
108
|
### Minor Changes
|
package/dist/agent/hooks.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import type { RequestContext } from '@mastra/core/request-context';
|
|
|
5
5
|
import type { ChunkType, NetworkChunkType } from '@mastra/core/stream';
|
|
6
6
|
import type { MastraUIMessage } from '../lib/ai-sdk/index.js';
|
|
7
7
|
import type { ModelSettings } from './types.js';
|
|
8
|
+
type ToolsInput = any;
|
|
8
9
|
export interface MastraChatProps {
|
|
9
10
|
agentId: string;
|
|
10
11
|
resourceId?: string;
|
|
@@ -44,9 +45,11 @@ export type SendMessageArgs = {
|
|
|
44
45
|
} & Omit<StreamArgs, 'coreUserMessages'>));
|
|
45
46
|
export type GenerateArgs = SharedArgs & {
|
|
46
47
|
onFinish?: (messages: UIMessage[]) => Promise<void>;
|
|
48
|
+
clientTools?: ToolsInput;
|
|
47
49
|
};
|
|
48
50
|
export type StreamArgs = SharedArgs & {
|
|
49
51
|
onChunk?: (chunk: ChunkType) => Promise<void>;
|
|
52
|
+
clientTools?: ToolsInput;
|
|
50
53
|
signalId?: string;
|
|
51
54
|
};
|
|
52
55
|
export type NetworkArgs = SharedArgs & {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../src/agent/hooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,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AU,GAAG,UAAU,GAAG;IACpC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9C,WAAW,CAAC,EAAE,UAAU,CAAC;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG,UAAU,GAAG;IACrC,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,gBAAgB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC7D,CAAC;AAYF,eAAO,MAAM,OAAO,GAAI,uKAUrB,eAAe;;qCA2tByC,eAAe;;;kCAnM7B,MAAM;kCAiCN,MAAM;0CAgCE,MAAM;0CAgCN,MAAM;;;;oBAtmBvB,UAAU,GAAG,UAAU;;;uCAsoBT,MAAM,UAAU,MAAM;uCAiCtB,MAAM,UAAU,MAAM;;;oBApqBtC,UAAU,GAAG,UAAU;;;CA8uBxD,CAAC"}
|
package/dist/index.cjs
CHANGED
|
@@ -2149,7 +2149,8 @@ var useChat = ({
|
|
|
2149
2149
|
modelSettings,
|
|
2150
2150
|
signal,
|
|
2151
2151
|
onFinish,
|
|
2152
|
-
tracingOptions
|
|
2152
|
+
tracingOptions,
|
|
2153
|
+
clientTools
|
|
2153
2154
|
}) => {
|
|
2154
2155
|
const {
|
|
2155
2156
|
frequencyPenalty,
|
|
@@ -2191,7 +2192,8 @@ var useChat = ({
|
|
|
2191
2192
|
...threadId2 ? { memory: { thread: threadId2, resource: resourceId || agentId } } : {},
|
|
2192
2193
|
providerOptions,
|
|
2193
2194
|
tracingOptions,
|
|
2194
|
-
requireToolApproval
|
|
2195
|
+
requireToolApproval,
|
|
2196
|
+
clientTools
|
|
2195
2197
|
});
|
|
2196
2198
|
if (response.finishReason === "suspended" && response.suspendPayload) {
|
|
2197
2199
|
const { toolCallId, toolName, args } = response.suspendPayload;
|
|
@@ -2234,6 +2236,7 @@ var useChat = ({
|
|
|
2234
2236
|
modelSettings,
|
|
2235
2237
|
signal,
|
|
2236
2238
|
tracingOptions,
|
|
2239
|
+
clientTools,
|
|
2237
2240
|
signalId
|
|
2238
2241
|
}) => {
|
|
2239
2242
|
const {
|
|
@@ -2283,7 +2286,8 @@ var useChat = ({
|
|
|
2283
2286
|
...threadId2 ? { memory: { thread: threadId2, resource: resourceId || agentId } } : {},
|
|
2284
2287
|
providerOptions,
|
|
2285
2288
|
requireToolApproval,
|
|
2286
|
-
tracingOptions
|
|
2289
|
+
tracingOptions,
|
|
2290
|
+
clientTools
|
|
2287
2291
|
});
|
|
2288
2292
|
_onChunk.current = onChunk;
|
|
2289
2293
|
_currentRunId.current = runId;
|