@mastra/client-js 1.7.3 → 1.8.0-alpha.1
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 +48 -0
- package/dist/docs/SKILL.md +10 -10
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/docs-server-auth-auth0.md +2 -2
- package/dist/docs/references/docs-server-auth-clerk.md +1 -1
- package/dist/docs/references/docs-server-auth-firebase.md +3 -3
- package/dist/docs/references/docs-server-auth-jwt.md +1 -1
- package/dist/docs/references/docs-server-auth-supabase.md +1 -1
- package/dist/docs/references/docs-server-auth-workos.md +1 -1
- package/dist/docs/references/docs-server-mastra-client.md +2 -2
- package/dist/docs/references/reference-ai-sdk-to-ai-sdk-stream.md +1 -1
- package/dist/docs/references/reference-ai-sdk-to-ai-sdk-v4-messages.md +1 -1
- package/dist/docs/references/reference-ai-sdk-to-ai-sdk-v5-messages.md +1 -1
- package/dist/docs/references/reference-client-js-agents.md +22 -22
- package/dist/docs/references/reference-client-js-error-handling.md +2 -2
- package/dist/docs/references/reference-client-js-logs.md +2 -2
- package/dist/docs/references/reference-client-js-mastra-client.md +2 -2
- package/dist/docs/references/reference-client-js-memory.md +6 -6
- package/dist/docs/references/reference-client-js-observability.md +4 -4
- package/dist/docs/references/reference-client-js-telemetry.md +1 -1
- package/dist/docs/references/reference-client-js-tools.md +3 -3
- package/dist/docs/references/reference-client-js-vectors.md +2 -2
- package/dist/docs/references/reference-client-js-workflows.md +12 -12
- package/dist/index.cjs +21 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +21 -16
- package/dist/index.js.map +1 -1
- package/dist/resources/agent-builder.d.ts +7 -4
- package/dist/resources/agent-builder.d.ts.map +1 -1
- package/dist/resources/agent.d.ts +14 -8
- package/dist/resources/agent.d.ts.map +1 -1
- package/dist/resources/run.d.ts +4 -4
- package/dist/resources/run.d.ts.map +1 -1
- package/dist/types.d.ts +19 -21
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/process-mastra-stream.d.ts +2 -3
- package/dist/utils/process-mastra-stream.d.ts.map +1 -1
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,53 @@
|
|
|
1
1
|
# @mastra/client-js
|
|
2
2
|
|
|
3
|
+
## 1.8.0-alpha.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`866cc2c`](https://github.com/mastra-ai/mastra/commit/866cc2cb1f0e3b314afab5194f69477fada745d1), [`6bcbf8a`](https://github.com/mastra-ai/mastra/commit/6bcbf8a6774d5a53b21d61db8a45ce2593ca1616), [`18c3a90`](https://github.com/mastra-ai/mastra/commit/18c3a90c9e48cf69500e308affeb8eba5860b2af), [`f35487b`](https://github.com/mastra-ai/mastra/commit/f35487bb2d46c636e22aa71d90025613ae38235a), [`6dc2192`](https://github.com/mastra-ai/mastra/commit/6dc21921aef0f0efab15cd0805fa3d18f277a76f), [`eeb3a3f`](https://github.com/mastra-ai/mastra/commit/eeb3a3f43aca10cf49479eed2a84b7d9ecea02ba), [`05f8d90`](https://github.com/mastra-ai/mastra/commit/05f8d9009290ce6aa03428b3add635268615db85), [`4b8da97`](https://github.com/mastra-ai/mastra/commit/4b8da97a5ce306e97869df6c39535d9069e563db), [`256df35`](https://github.com/mastra-ai/mastra/commit/256df3571d62beb3ad4971faa432927cc140e603)]:
|
|
8
|
+
- @mastra/core@1.11.0-alpha.1
|
|
9
|
+
|
|
10
|
+
## 1.8.0-alpha.0
|
|
11
|
+
|
|
12
|
+
### Minor Changes
|
|
13
|
+
|
|
14
|
+
- Added `requestContext` field to dataset item API endpoints and `requestContextSchema` to dataset CRUD endpoints. Added `requestContext` option to the experiment trigger endpoint, which gets forwarded to agent execution during experiments. ([#13938](https://github.com/mastra-ai/mastra/pull/13938))
|
|
15
|
+
|
|
16
|
+
**Usage with `@mastra/client-js`:**
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
// Create a dataset with a request context schema
|
|
20
|
+
await client.createDataset({
|
|
21
|
+
name: 'my-dataset',
|
|
22
|
+
requestContextSchema: {
|
|
23
|
+
type: 'object',
|
|
24
|
+
properties: { region: { type: 'string' } },
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
// Add an item with request context
|
|
29
|
+
await client.addDatasetItem({
|
|
30
|
+
datasetId: 'my-dataset',
|
|
31
|
+
input: { prompt: 'Hello' },
|
|
32
|
+
requestContext: { region: 'us-east-1' },
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
// Trigger an experiment with request context forwarded to agent
|
|
36
|
+
await client.triggerDatasetExperiment({
|
|
37
|
+
datasetId: 'my-dataset',
|
|
38
|
+
agentId: 'my-agent',
|
|
39
|
+
requestContext: { region: 'eu-west-1' },
|
|
40
|
+
});
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Patch Changes
|
|
44
|
+
|
|
45
|
+
- Fixed @mastra/client-js streaming APIs to expose standard Web Streams types in public declarations for browser consumers. ([#14079](https://github.com/mastra-ai/mastra/pull/14079))
|
|
46
|
+
|
|
47
|
+
- Updated dependencies [[`4f71b43`](https://github.com/mastra-ai/mastra/commit/4f71b436a4a6b8839842d8da47b57b84509af56c), [`a070277`](https://github.com/mastra-ai/mastra/commit/a07027766ce195ba74d0783116d894cbab25d44c), [`b628b91`](https://github.com/mastra-ai/mastra/commit/b628b9128b372c0f54214d902b07279f03443900), [`332c014`](https://github.com/mastra-ai/mastra/commit/332c014e076b81edf7fe45b58205882726415e90), [`6b63153`](https://github.com/mastra-ai/mastra/commit/6b63153878ea841c0f4ce632ba66bb33e57e9c1b), [`4246e34`](https://github.com/mastra-ai/mastra/commit/4246e34cec9c26636d0965942268e6d07c346671), [`b8837ee`](https://github.com/mastra-ai/mastra/commit/b8837ee77e2e84197609762bfabd8b3da326d30c), [`fb58ce1`](https://github.com/mastra-ai/mastra/commit/fb58ce1de85d57f142005c4b3b7559f909167a3f), [`5d950f7`](https://github.com/mastra-ai/mastra/commit/5d950f7bf426a215a1808f0abef7de5c8336ba1c), [`28c85b1`](https://github.com/mastra-ai/mastra/commit/28c85b184fc32b40f7f160483c982da6d388ecbd), [`e9a08fb`](https://github.com/mastra-ai/mastra/commit/e9a08fbef1ada7e50e961e2f54f55e8c10b4a45c), [`631ffd8`](https://github.com/mastra-ai/mastra/commit/631ffd82fed108648b448b28e6a90e38c5f53bf5), [`aae2295`](https://github.com/mastra-ai/mastra/commit/aae2295838a2d329ad6640829e87934790ffe5b8), [`aa61f29`](https://github.com/mastra-ai/mastra/commit/aa61f29ff8095ce46a4ae16e46c4d8c79b2b685b), [`7ff3714`](https://github.com/mastra-ai/mastra/commit/7ff37148515439bb3be009a60e02c3e363299760), [`41d79a1`](https://github.com/mastra-ai/mastra/commit/41d79a14bd8cb6de1e2565fd0a04786bae2f211b), [`e673376`](https://github.com/mastra-ai/mastra/commit/e6733763ad1321aa7e5ae15096b9c2104f93b1f3), [`b2204c9`](https://github.com/mastra-ai/mastra/commit/b2204c98a42848bbfb6f0440f005dc2b6354f1cd), [`a1bf1e3`](https://github.com/mastra-ai/mastra/commit/a1bf1e385ed4c0ef6f11b56c5887442970d127f2), [`b6f647a`](https://github.com/mastra-ai/mastra/commit/b6f647ae2388e091f366581595feb957e37d5b40), [`0c57b8b`](https://github.com/mastra-ai/mastra/commit/0c57b8b0a69a97b5a4ae3f79be6c610f29f3cf7b), [`b081f27`](https://github.com/mastra-ai/mastra/commit/b081f272cf411716e1d6bd72ceac4bcee2657b19), [`0c09eac`](https://github.com/mastra-ai/mastra/commit/0c09eacb1926f64cfdc9ae5c6d63385cf8c9f72c), [`6b9b93d`](https://github.com/mastra-ai/mastra/commit/6b9b93d6f459d1ba6e36f163abf62a085ddb3d64), [`31b6067`](https://github.com/mastra-ai/mastra/commit/31b6067d0cc3ab10e1b29c36147f3b5266bc714a), [`797ac42`](https://github.com/mastra-ai/mastra/commit/797ac4276de231ad2d694d9aeca75980f6cd0419), [`aae2295`](https://github.com/mastra-ai/mastra/commit/aae2295838a2d329ad6640829e87934790ffe5b8), [`0bc289e`](https://github.com/mastra-ai/mastra/commit/0bc289e2d476bf46c5b91c21969e8d0c6864691c), [`9b75a06`](https://github.com/mastra-ai/mastra/commit/9b75a06e53ebb0b950ba7c1e83a0142047185f46), [`4c3a1b1`](https://github.com/mastra-ai/mastra/commit/4c3a1b122ea083e003d71092f30f3b31680b01c0), [`85cc3b3`](https://github.com/mastra-ai/mastra/commit/85cc3b3b6f32ae4b083c26498f50d5b250ba944b), [`97ea28c`](https://github.com/mastra-ai/mastra/commit/97ea28c746e9e4147d56047bbb1c4a92417a3fec), [`d567299`](https://github.com/mastra-ai/mastra/commit/d567299cf81e02bd9d5221d4bc05967d6c224161), [`716ffe6`](https://github.com/mastra-ai/mastra/commit/716ffe68bed81f7c2690bc8581b9e140f7bf1c3d), [`8296332`](https://github.com/mastra-ai/mastra/commit/8296332de21c16e3dfc3d0b2d615720a6dc88f2f), [`4df2116`](https://github.com/mastra-ai/mastra/commit/4df211619dd922c047d396ca41cd7027c8c4c8e7), [`2219c1a`](https://github.com/mastra-ai/mastra/commit/2219c1acbd21da116da877f0036ffb985a9dd5a3), [`17c4145`](https://github.com/mastra-ai/mastra/commit/17c4145166099354545582335b5252bdfdfd908b)]:
|
|
48
|
+
- @mastra/core@1.11.0-alpha.0
|
|
49
|
+
- @mastra/schema-compat@1.2.0-alpha.0
|
|
50
|
+
|
|
3
51
|
## 1.7.3
|
|
4
52
|
|
|
5
53
|
### Patch Changes
|
package/dist/docs/SKILL.md
CHANGED
|
@@ -3,7 +3,7 @@ name: mastra-client-js
|
|
|
3
3
|
description: Documentation for @mastra/client-js. Use when working with @mastra/client-js APIs, configuration, or implementation.
|
|
4
4
|
metadata:
|
|
5
5
|
package: "@mastra/client-js"
|
|
6
|
-
version: "1.
|
|
6
|
+
version: "1.8.0-alpha.1"
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
## When to use
|
|
@@ -16,13 +16,13 @@ Read the individual reference documents for detailed explanations and code examp
|
|
|
16
16
|
|
|
17
17
|
### Docs
|
|
18
18
|
|
|
19
|
-
- [MastraAuthAuth0
|
|
20
|
-
- [MastraAuthClerk
|
|
21
|
-
- [MastraAuthFirebase
|
|
22
|
-
- [MastraJwtAuth
|
|
23
|
-
- [MastraAuthSupabase
|
|
24
|
-
- [MastraAuthWorkos
|
|
25
|
-
- [Mastra
|
|
19
|
+
- [MastraAuthAuth0 class](references/docs-server-auth-auth0.md) - Documentation for the MastraAuthAuth0 class, which authenticates Mastra applications using Auth0 authentication.
|
|
20
|
+
- [MastraAuthClerk class](references/docs-server-auth-clerk.md) - Documentation for the MastraAuthClerk class, which authenticates Mastra applications using Clerk authentication.
|
|
21
|
+
- [MastraAuthFirebase class](references/docs-server-auth-firebase.md) - Documentation for the MastraAuthFirebase class, which authenticates Mastra applications using Firebase Authentication.
|
|
22
|
+
- [MastraJwtAuth class](references/docs-server-auth-jwt.md) - Documentation for the MastraJwtAuth class, which authenticates Mastra applications using JSON Web Tokens.
|
|
23
|
+
- [MastraAuthSupabase class](references/docs-server-auth-supabase.md) - Documentation for the MastraAuthSupabase class, which authenticates Mastra applications using Supabase Auth.
|
|
24
|
+
- [MastraAuthWorkos class](references/docs-server-auth-workos.md) - Documentation for the MastraAuthWorkos class, which authenticates Mastra applications using WorkOS authentication.
|
|
25
|
+
- [Mastra client SDK](references/docs-server-mastra-client.md) - Learn how to set up and use the Mastra Client SDK
|
|
26
26
|
|
|
27
27
|
### Reference
|
|
28
28
|
|
|
@@ -30,9 +30,9 @@ Read the individual reference documents for detailed explanations and code examp
|
|
|
30
30
|
- [Reference: toAISdkV4Messages()](references/reference-ai-sdk-to-ai-sdk-v4-messages.md) - API reference for toAISdkV4Messages(), a function to convert Mastra messages to AI SDK v4 UI messages.
|
|
31
31
|
- [Reference: toAISdkV5Messages()](references/reference-ai-sdk-to-ai-sdk-v5-messages.md) - API reference for toAISdkV5Messages(), a function to convert Mastra messages to AI SDK v5 UI messages.
|
|
32
32
|
- [Reference: Agents API](references/reference-client-js-agents.md) - Learn how to interact with Mastra AI agents, including generating responses, streaming interactions, and managing agent tools using the client-js SDK.
|
|
33
|
-
- [Reference: Error
|
|
33
|
+
- [Reference: Error handling](references/reference-client-js-error-handling.md) - Learn about the built-in retry mechanism and error handling capabilities in the Mastra client-js SDK.
|
|
34
34
|
- [Reference: Logs API](references/reference-client-js-logs.md) - Learn how to access and query system logs and debugging information in Mastra using the client-js SDK.
|
|
35
|
-
- [Reference: Mastra
|
|
35
|
+
- [Reference: Mastra client SDK](references/reference-client-js-mastra-client.md) - Learn how to interact with Mastra using the client-js SDK.
|
|
36
36
|
- [Reference: Memory API](references/reference-client-js-memory.md) - Learn how to manage conversation threads and message history in Mastra using the client-js SDK.
|
|
37
37
|
- [Reference: Observability API](references/reference-client-js-observability.md) - Learn how to retrieve traces, monitor application performance, and score traces using the client-js SDK.
|
|
38
38
|
- [Reference: Telemetry API](references/reference-client-js-telemetry.md) - Learn how to retrieve and analyze traces from your Mastra application for monitoring and debugging using the client-js SDK.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# MastraAuthAuth0
|
|
1
|
+
# MastraAuthAuth0 class
|
|
2
2
|
|
|
3
3
|
The `MastraAuthAuth0` class provides authentication for Mastra using Auth0. It verifies incoming requests using Auth0-issued JWT tokens and integrates with the Mastra server using the `auth` option.
|
|
4
4
|
|
|
@@ -66,7 +66,7 @@ export const mastra = new Mastra({
|
|
|
66
66
|
By default, `MastraAuthAuth0` allows all authenticated users who have valid Auth0 tokens for the specified audience. The token verification ensures that:
|
|
67
67
|
|
|
68
68
|
1. The token is properly signed by Auth0
|
|
69
|
-
2. The token
|
|
69
|
+
2. The token isn't expired
|
|
70
70
|
3. The token audience matches your configured audience
|
|
71
71
|
4. The token issuer matches your Auth0 domain
|
|
72
72
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# MastraAuthFirebase
|
|
1
|
+
# MastraAuthFirebase class
|
|
2
2
|
|
|
3
3
|
The `MastraAuthFirebase` class provides authentication for Mastra using Firebase Authentication. It verifies incoming requests using Firebase ID tokens and integrates with the Mastra server using the `auth` option.
|
|
4
4
|
|
|
@@ -66,12 +66,12 @@ export const mastra = new Mastra({
|
|
|
66
66
|
|
|
67
67
|
The `MastraAuthFirebase` class can be configured through constructor options or environment variables.
|
|
68
68
|
|
|
69
|
-
### Environment
|
|
69
|
+
### Environment variables
|
|
70
70
|
|
|
71
71
|
- `FIREBASE_SERVICE_ACCOUNT`: Path to Firebase service account JSON file
|
|
72
72
|
- `FIRESTORE_DATABASE_ID` or `FIREBASE_DATABASE_ID`: Firestore database ID
|
|
73
73
|
|
|
74
|
-
> **Note:** When constructor options
|
|
74
|
+
> **Note:** When constructor options aren't provided, the class automatically reads these environment variables. This means you can call `new MastraAuthFirebase()` without any arguments if your environment variables are properly configured.
|
|
75
75
|
|
|
76
76
|
### User Authorization
|
|
77
77
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# MastraJwtAuth
|
|
1
|
+
# MastraJwtAuth class
|
|
2
2
|
|
|
3
3
|
The `MastraJwtAuth` class provides a lightweight authentication mechanism for Mastra using JSON Web Tokens (JWTs). It verifies incoming requests based on a shared secret and integrates with the Mastra server using the `auth` option.
|
|
4
4
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# MastraAuthSupabase
|
|
1
|
+
# MastraAuthSupabase class
|
|
2
2
|
|
|
3
3
|
The `MastraAuthSupabase` class provides authentication for Mastra using Supabase Auth. It verifies incoming requests using Supabase's authentication system and integrates with the Mastra server using the `auth` option.
|
|
4
4
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
# Mastra
|
|
1
|
+
# Mastra client SDK
|
|
2
2
|
|
|
3
|
-
The Mastra Client SDK provides a
|
|
3
|
+
The Mastra Client SDK provides a concise and type-safe interface for interacting with your [Mastra Server](https://mastra.ai/docs/server/mastra-server) from your client environment.
|
|
4
4
|
|
|
5
5
|
## Prerequisites
|
|
6
6
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
The Agents API provides methods to interact with Mastra AI agents, including generating responses, streaming interactions, and managing agent tools.
|
|
4
4
|
|
|
5
|
-
## Getting
|
|
5
|
+
## Getting all agents
|
|
6
6
|
|
|
7
7
|
Retrieve a list of all available agents:
|
|
8
8
|
|
|
@@ -12,7 +12,7 @@ const agents = await mastraClient.listAgents()
|
|
|
12
12
|
|
|
13
13
|
Returns a record of agent IDs to their serialized agent configurations.
|
|
14
14
|
|
|
15
|
-
## Working with a
|
|
15
|
+
## Working with a specific agent
|
|
16
16
|
|
|
17
17
|
Get an instance of a specific agent by its ID:
|
|
18
18
|
|
|
@@ -26,9 +26,9 @@ export const myAgent = new Agent({
|
|
|
26
26
|
const agent = mastraClient.getAgent('my-agent')
|
|
27
27
|
```
|
|
28
28
|
|
|
29
|
-
## Agent
|
|
29
|
+
## Agent methods
|
|
30
30
|
|
|
31
|
-
### details()
|
|
31
|
+
### `details()`
|
|
32
32
|
|
|
33
33
|
Retrieve detailed information about an agent:
|
|
34
34
|
|
|
@@ -36,7 +36,7 @@ Retrieve detailed information about an agent:
|
|
|
36
36
|
const details = await agent.details()
|
|
37
37
|
```
|
|
38
38
|
|
|
39
|
-
### generate()
|
|
39
|
+
### `generate()`
|
|
40
40
|
|
|
41
41
|
Generate a response from the agent:
|
|
42
42
|
|
|
@@ -69,7 +69,7 @@ const response = await agent.generate('Hello, how are you?', {
|
|
|
69
69
|
})
|
|
70
70
|
```
|
|
71
71
|
|
|
72
|
-
### stream()
|
|
72
|
+
### `stream()`
|
|
73
73
|
|
|
74
74
|
Stream responses from the agent for real-time interactions:
|
|
75
75
|
|
|
@@ -151,7 +151,7 @@ for await (const part of uiMessageStream) {
|
|
|
151
151
|
}
|
|
152
152
|
```
|
|
153
153
|
|
|
154
|
-
### getTool()
|
|
154
|
+
### `getTool()`
|
|
155
155
|
|
|
156
156
|
Retrieve information about a specific tool available to the agent:
|
|
157
157
|
|
|
@@ -159,7 +159,7 @@ Retrieve information about a specific tool available to the agent:
|
|
|
159
159
|
const tool = await agent.getTool('tool-id')
|
|
160
160
|
```
|
|
161
161
|
|
|
162
|
-
### executeTool()
|
|
162
|
+
### `executeTool()`
|
|
163
163
|
|
|
164
164
|
Execute a specific tool for the agent:
|
|
165
165
|
|
|
@@ -169,7 +169,7 @@ const result = await agent.executeTool('tool-id', {
|
|
|
169
169
|
})
|
|
170
170
|
```
|
|
171
171
|
|
|
172
|
-
### network()
|
|
172
|
+
### `network()`
|
|
173
173
|
|
|
174
174
|
Stream responses from an agent network for multi-agent interactions:
|
|
175
175
|
|
|
@@ -183,7 +183,7 @@ response.processDataStream({
|
|
|
183
183
|
})
|
|
184
184
|
```
|
|
185
185
|
|
|
186
|
-
### approveToolCall()
|
|
186
|
+
### `approveToolCall()`
|
|
187
187
|
|
|
188
188
|
Approve a pending tool call that requires human confirmation:
|
|
189
189
|
|
|
@@ -200,7 +200,7 @@ response.processDataStream({
|
|
|
200
200
|
})
|
|
201
201
|
```
|
|
202
202
|
|
|
203
|
-
### declineToolCall()
|
|
203
|
+
### `declineToolCall()`
|
|
204
204
|
|
|
205
205
|
Decline a pending tool call that requires human confirmation:
|
|
206
206
|
|
|
@@ -217,7 +217,7 @@ response.processDataStream({
|
|
|
217
217
|
})
|
|
218
218
|
```
|
|
219
219
|
|
|
220
|
-
### approveToolCallGenerate()
|
|
220
|
+
### `approveToolCallGenerate()`
|
|
221
221
|
|
|
222
222
|
Approve a pending tool call when using `generate()` (non-streaming). Returns the complete response:
|
|
223
223
|
|
|
@@ -236,7 +236,7 @@ if (output.finishReason === 'suspended') {
|
|
|
236
236
|
}
|
|
237
237
|
```
|
|
238
238
|
|
|
239
|
-
### declineToolCallGenerate()
|
|
239
|
+
### `declineToolCallGenerate()`
|
|
240
240
|
|
|
241
241
|
Decline a pending tool call when using `generate()` (non-streaming). Returns the complete response:
|
|
242
242
|
|
|
@@ -255,7 +255,7 @@ if (output.finishReason === 'suspended') {
|
|
|
255
255
|
}
|
|
256
256
|
```
|
|
257
257
|
|
|
258
|
-
## Client
|
|
258
|
+
## Client tools
|
|
259
259
|
|
|
260
260
|
Client-side tools allow you to execute custom functions on the client side when the agent requests them.
|
|
261
261
|
|
|
@@ -306,11 +306,11 @@ response.processDataStream({
|
|
|
306
306
|
})
|
|
307
307
|
```
|
|
308
308
|
|
|
309
|
-
## Stored
|
|
309
|
+
## Stored agents
|
|
310
310
|
|
|
311
311
|
Stored agents are agent configurations stored in a database that can be created, updated, and deleted at runtime. They reference primitives (tools, workflows, other agents, memory, scorers) by key, which are resolved from the Mastra registry when the agent is instantiated.
|
|
312
312
|
|
|
313
|
-
### listStoredAgents()
|
|
313
|
+
### `listStoredAgents()`
|
|
314
314
|
|
|
315
315
|
Retrieve a paginated list of all stored agents:
|
|
316
316
|
|
|
@@ -333,7 +333,7 @@ const result = await mastraClient.listStoredAgents({
|
|
|
333
333
|
})
|
|
334
334
|
```
|
|
335
335
|
|
|
336
|
-
### createStoredAgent()
|
|
336
|
+
### `createStoredAgent()`
|
|
337
337
|
|
|
338
338
|
Create a new stored agent:
|
|
339
339
|
|
|
@@ -380,7 +380,7 @@ const agent = await mastraClient.createStoredAgent({
|
|
|
380
380
|
})
|
|
381
381
|
```
|
|
382
382
|
|
|
383
|
-
### getStoredAgent()
|
|
383
|
+
### `getStoredAgent()`
|
|
384
384
|
|
|
385
385
|
Get an instance of a specific stored agent:
|
|
386
386
|
|
|
@@ -388,9 +388,9 @@ Get an instance of a specific stored agent:
|
|
|
388
388
|
const storedAgent = mastraClient.getStoredAgent('my-agent')
|
|
389
389
|
```
|
|
390
390
|
|
|
391
|
-
## Stored
|
|
391
|
+
## Stored agent methods
|
|
392
392
|
|
|
393
|
-
### details()
|
|
393
|
+
### `details()`
|
|
394
394
|
|
|
395
395
|
Retrieve the stored agent configuration:
|
|
396
396
|
|
|
@@ -401,7 +401,7 @@ console.log(details.instructions)
|
|
|
401
401
|
console.log(details.model)
|
|
402
402
|
```
|
|
403
403
|
|
|
404
|
-
### update()
|
|
404
|
+
### `update()`
|
|
405
405
|
|
|
406
406
|
Update specific fields of a stored agent. All fields are optional:
|
|
407
407
|
|
|
@@ -427,7 +427,7 @@ await storedAgent.update({
|
|
|
427
427
|
})
|
|
428
428
|
```
|
|
429
429
|
|
|
430
|
-
### delete()
|
|
430
|
+
### `delete()`
|
|
431
431
|
|
|
432
432
|
Delete a stored agent:
|
|
433
433
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
The Logs API provides methods to access and query system logs and debugging information in Mastra.
|
|
4
4
|
|
|
5
|
-
## Getting
|
|
5
|
+
## Getting logs
|
|
6
6
|
|
|
7
7
|
Retrieve system logs with optional filtering:
|
|
8
8
|
|
|
@@ -12,7 +12,7 @@ const logs = await mastraClient.listLogs({
|
|
|
12
12
|
})
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
-
## Getting
|
|
15
|
+
## Getting logs for a specific run
|
|
16
16
|
|
|
17
17
|
Retrieve logs for a specific execution run:
|
|
18
18
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
# Mastra
|
|
1
|
+
# Mastra client SDK
|
|
2
2
|
|
|
3
|
-
The Mastra Client SDK provides a
|
|
3
|
+
The Mastra Client SDK provides a type-safe interface for interacting with your [Mastra Server](https://mastra.ai/docs/deployment/mastra-server) from your client environment.
|
|
4
4
|
|
|
5
5
|
## Usage example
|
|
6
6
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
The Memory API provides methods to manage conversation threads and message history in Mastra.
|
|
4
4
|
|
|
5
|
-
## Get
|
|
5
|
+
## Get all threads
|
|
6
6
|
|
|
7
7
|
Retrieve all memory threads for a specific resource:
|
|
8
8
|
|
|
@@ -15,7 +15,7 @@ const threads = await mastraClient.getMemoryThreads({
|
|
|
15
15
|
|
|
16
16
|
When `agentId` is omitted and storage is configured on the server, threads will be retrieved using storage directly. This is useful when multiple agents share the same threads (e.g., in workflows with multiple agent steps).
|
|
17
17
|
|
|
18
|
-
## Create a
|
|
18
|
+
## Create a new thread
|
|
19
19
|
|
|
20
20
|
Create a new memory thread:
|
|
21
21
|
|
|
@@ -28,7 +28,7 @@ const thread = await mastraClient.createMemoryThread({
|
|
|
28
28
|
})
|
|
29
29
|
```
|
|
30
30
|
|
|
31
|
-
## Working with a
|
|
31
|
+
## Working with a specific thread
|
|
32
32
|
|
|
33
33
|
Get an instance of a specific memory thread:
|
|
34
34
|
|
|
@@ -36,7 +36,7 @@ Get an instance of a specific memory thread:
|
|
|
36
36
|
const thread = mastraClient.getMemoryThread({ threadId: 'thread-id', agentId: 'agent-id' })
|
|
37
37
|
```
|
|
38
38
|
|
|
39
|
-
## Thread
|
|
39
|
+
## Thread methods
|
|
40
40
|
|
|
41
41
|
### Get Thread Details
|
|
42
42
|
|
|
@@ -105,7 +105,7 @@ The clone response includes:
|
|
|
105
105
|
- `thread`: The newly created cloned thread with clone metadata
|
|
106
106
|
- `clonedMessages`: Array of the cloned messages with new IDs
|
|
107
107
|
|
|
108
|
-
## Message
|
|
108
|
+
## Message operations
|
|
109
109
|
|
|
110
110
|
### Save Messages
|
|
111
111
|
|
|
@@ -168,7 +168,7 @@ const result = await thread.deleteMessages(['message-1', 'message-2', 'message-3
|
|
|
168
168
|
// Returns: { success: true, message: "Message deleted successfully" }
|
|
169
169
|
```
|
|
170
170
|
|
|
171
|
-
## Working
|
|
171
|
+
## Working memory
|
|
172
172
|
|
|
173
173
|
Working memory allows agents to maintain persistent information about users across interactions. It can be scoped to either a specific thread or across all threads for a resource (user).
|
|
174
174
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
The Observability API provides methods to retrieve traces, monitor your application's performance, and score traces for evaluation. This helps you understand how your AI agents and workflows are performing.
|
|
4
4
|
|
|
5
|
-
## Getting a
|
|
5
|
+
## Getting a specific trace
|
|
6
6
|
|
|
7
7
|
Retrieve a specific trace by its ID, including all its spans and details:
|
|
8
8
|
|
|
@@ -10,7 +10,7 @@ Retrieve a specific trace by its ID, including all its spans and details:
|
|
|
10
10
|
const trace = await mastraClient.getTrace('trace-id-123')
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
## Getting
|
|
13
|
+
## Getting traces with filtering
|
|
14
14
|
|
|
15
15
|
Retrieve a paginated list of trace root spans with optional filtering:
|
|
16
16
|
|
|
@@ -39,7 +39,7 @@ console.log(`Total pages: ${traces.pagination.totalPages}`)
|
|
|
39
39
|
const completeTrace = await mastraClient.getTrace(traces.spans[0].traceId)
|
|
40
40
|
```
|
|
41
41
|
|
|
42
|
-
## Scoring
|
|
42
|
+
## Scoring traces
|
|
43
43
|
|
|
44
44
|
Score specific traces using registered scorers for evaluation:
|
|
45
45
|
|
|
@@ -53,7 +53,7 @@ const result = await mastraClient.score({
|
|
|
53
53
|
})
|
|
54
54
|
```
|
|
55
55
|
|
|
56
|
-
## Getting
|
|
56
|
+
## Getting scores by span
|
|
57
57
|
|
|
58
58
|
Retrieve scores for a specific span within a trace:
|
|
59
59
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
The Telemetry API provides methods to retrieve and analyze traces from your Mastra application. This helps you monitor and debug your application's behavior and performance.
|
|
4
4
|
|
|
5
|
-
## Getting
|
|
5
|
+
## Getting traces
|
|
6
6
|
|
|
7
7
|
Retrieve traces with optional filtering and pagination:
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
The Tools API provides methods to interact with and execute tools available in the Mastra platform.
|
|
4
4
|
|
|
5
|
-
## Getting
|
|
5
|
+
## Getting all tools
|
|
6
6
|
|
|
7
7
|
Retrieve a list of all available tools:
|
|
8
8
|
|
|
@@ -10,7 +10,7 @@ Retrieve a list of all available tools:
|
|
|
10
10
|
const tools = await mastraClient.listTools()
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
## Working with a
|
|
13
|
+
## Working with a specific tool
|
|
14
14
|
|
|
15
15
|
Get an instance of a specific tool:
|
|
16
16
|
|
|
@@ -18,7 +18,7 @@ Get an instance of a specific tool:
|
|
|
18
18
|
const tool = mastraClient.getTool('tool-id')
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
-
## Tool
|
|
21
|
+
## Tool methods
|
|
22
22
|
|
|
23
23
|
### Get Tool Details
|
|
24
24
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
The Vectors API provides methods to work with vector embeddings for semantic search and similarity matching in Mastra.
|
|
4
4
|
|
|
5
|
-
## Working with
|
|
5
|
+
## Working with vectors
|
|
6
6
|
|
|
7
7
|
Get an instance of a vector store:
|
|
8
8
|
|
|
@@ -10,7 +10,7 @@ Get an instance of a vector store:
|
|
|
10
10
|
const vector = mastraClient.getVector('vector-name')
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
## Vector
|
|
13
|
+
## Vector methods
|
|
14
14
|
|
|
15
15
|
### Get Vector Index Details
|
|
16
16
|
|