@mastra/client-js 1.0.0-beta.24 → 1.0.0-beta.26
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 +122 -0
- package/README.md +1 -3
- package/dist/client.d.ts +17 -5
- package/dist/client.d.ts.map +1 -1
- package/dist/docs/README.md +1 -1
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/SOURCE_MAP.json +1 -1
- package/dist/docs/client-js/01-reference.md +41 -12
- package/dist/docs/server/01-mastra-client.md +8 -25
- package/dist/docs/server/02-jwt.md +2 -3
- package/dist/docs/server/03-clerk.md +11 -8
- package/dist/docs/server/04-supabase.md +21 -19
- package/dist/docs/server/05-firebase.md +13 -11
- package/dist/docs/server/06-workos.md +10 -8
- package/dist/docs/server/07-auth0.md +10 -8
- package/dist/index.cjs +92 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +92 -13
- package/dist/index.js.map +1 -1
- package/dist/resources/agent.d.ts +22 -9
- package/dist/resources/agent.d.ts.map +1 -1
- package/dist/resources/index.d.ts +1 -0
- package/dist/resources/index.d.ts.map +1 -1
- package/dist/resources/processor.d.ts +20 -0
- package/dist/resources/processor.d.ts.map +1 -0
- package/dist/types.d.ts +87 -7
- package/dist/types.d.ts.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,127 @@
|
|
|
1
1
|
# @mastra/client-js
|
|
2
2
|
|
|
3
|
+
## 1.0.0-beta.26
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Improve type handling with Zod ([#12091](https://github.com/mastra-ai/mastra/pull/12091))
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`026b848`](https://github.com/mastra-ai/mastra/commit/026b8483fbf5b6d977be8f7e6aac8d15c75558ac), [`ffa553a`](https://github.com/mastra-ai/mastra/commit/ffa553a3edc1bd17d73669fba66d6b6f4ac10897)]:
|
|
10
|
+
- @mastra/core@1.0.0-beta.26
|
|
11
|
+
|
|
12
|
+
## 1.0.0-beta.25
|
|
13
|
+
|
|
14
|
+
### Minor Changes
|
|
15
|
+
|
|
16
|
+
- Added human-in-the-loop (HITL) tool approval support for `generate()` method. ([#12056](https://github.com/mastra-ai/mastra/pull/12056))
|
|
17
|
+
|
|
18
|
+
**Why:** This provides parity between `stream()` and `generate()` for tool approval flows, allowing non-streaming use cases to leverage `requireToolApproval` without needing to switch to streaming.
|
|
19
|
+
|
|
20
|
+
Previously, tool approval with `requireToolApproval` only worked with `stream()`. Now you can use the same approval flow with `generate()` for non-streaming use cases.
|
|
21
|
+
|
|
22
|
+
**Using tool approval with generate()**
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
const output = await agent.generate('Find user John', {
|
|
26
|
+
requireToolApproval: true,
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
// Check if a tool is waiting for approval
|
|
30
|
+
if (output.finishReason === 'suspended') {
|
|
31
|
+
console.log('Tool requires approval:', output.suspendPayload.toolName);
|
|
32
|
+
|
|
33
|
+
// Approve the tool call
|
|
34
|
+
const result = await agent.approveToolCallGenerate({
|
|
35
|
+
runId: output.runId,
|
|
36
|
+
toolCallId: output.suspendPayload.toolCallId,
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
console.log(result.text);
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
**Declining a tool call**
|
|
44
|
+
|
|
45
|
+
```typescript
|
|
46
|
+
if (output.finishReason === 'suspended') {
|
|
47
|
+
const result = await agent.declineToolCallGenerate({
|
|
48
|
+
runId: output.runId,
|
|
49
|
+
toolCallId: output.suspendPayload.toolCallId,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
**New methods added:**
|
|
55
|
+
- `agent.approveToolCallGenerate({ runId, toolCallId })` - Approves a pending tool call and returns the complete result
|
|
56
|
+
- `agent.declineToolCallGenerate({ runId, toolCallId })` - Declines a pending tool call and returns the complete result
|
|
57
|
+
|
|
58
|
+
**Server routes added:**
|
|
59
|
+
- `POST /api/agents/:agentId/approve-tool-call-generate`
|
|
60
|
+
- `POST /api/agents/:agentId/decline-tool-call-generate`
|
|
61
|
+
|
|
62
|
+
The playground UI now also supports tool approval when using generate mode.
|
|
63
|
+
|
|
64
|
+
- Added processor resource to the JavaScript client SDK. You can now list processors, get processor details, and execute processors via the client: ([#12059](https://github.com/mastra-ai/mastra/pull/12059))
|
|
65
|
+
|
|
66
|
+
```typescript
|
|
67
|
+
// List all processors
|
|
68
|
+
const processors = await client.listProcessors();
|
|
69
|
+
|
|
70
|
+
// Get processor details
|
|
71
|
+
const details = await client.getProcessor('my-processor').details();
|
|
72
|
+
|
|
73
|
+
// Execute a processor
|
|
74
|
+
const result = await client.getProcessor('my-processor').execute({
|
|
75
|
+
phase: 'input',
|
|
76
|
+
messages: [{ role: 'user', content: { format: 2, parts: [{ type: 'text', text: 'Hello' }] } }],
|
|
77
|
+
});
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
- Added new `listThreads` method for flexible thread filtering across all storage adapters. ([#11832](https://github.com/mastra-ai/mastra/pull/11832))
|
|
81
|
+
|
|
82
|
+
**New Features**
|
|
83
|
+
- Filter threads by `resourceId`, `metadata`, or both (with AND logic for metadata key-value pairs)
|
|
84
|
+
- All filter parameters are optional, allowing you to list all threads or filter as needed
|
|
85
|
+
- Full pagination and sorting support
|
|
86
|
+
|
|
87
|
+
**Example Usage**
|
|
88
|
+
|
|
89
|
+
```typescript
|
|
90
|
+
// List all threads
|
|
91
|
+
const allThreads = await memory.listThreads({});
|
|
92
|
+
|
|
93
|
+
// Filter by resourceId only
|
|
94
|
+
const userThreads = await memory.listThreads({
|
|
95
|
+
filter: { resourceId: 'user-123' },
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
// Filter by metadata only
|
|
99
|
+
const supportThreads = await memory.listThreads({
|
|
100
|
+
filter: { metadata: { category: 'support' } },
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
// Filter by both with pagination
|
|
104
|
+
const filteredThreads = await memory.listThreads({
|
|
105
|
+
filter: {
|
|
106
|
+
resourceId: 'user-123',
|
|
107
|
+
metadata: { priority: 'high', status: 'open' },
|
|
108
|
+
},
|
|
109
|
+
orderBy: { field: 'updatedAt', direction: 'DESC' },
|
|
110
|
+
page: 0,
|
|
111
|
+
perPage: 20,
|
|
112
|
+
});
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
**Security Improvements**
|
|
116
|
+
- Added validation to prevent SQL injection via malicious metadata keys
|
|
117
|
+
- Added pagination parameter validation to prevent integer overflow attacks
|
|
118
|
+
|
|
119
|
+
### Patch Changes
|
|
120
|
+
|
|
121
|
+
- Updated dependencies [[`ed3e3dd`](https://github.com/mastra-ai/mastra/commit/ed3e3ddec69d564fe2b125e083437f76331f1283), [`6833c69`](https://github.com/mastra-ai/mastra/commit/6833c69607418d257750bbcdd84638993d343539), [`47b1c16`](https://github.com/mastra-ai/mastra/commit/47b1c16a01c7ffb6765fe1e499b49092f8b7eba3), [`3a76a80`](https://github.com/mastra-ai/mastra/commit/3a76a80284cb71a0faa975abb3d4b2a9631e60cd), [`8538a0d`](https://github.com/mastra-ai/mastra/commit/8538a0d232619bf55dad7ddc2a8b0ca77c679a87), [`9312dcd`](https://github.com/mastra-ai/mastra/commit/9312dcd1c6f5b321929e7d382e763d95fdc030f5)]:
|
|
122
|
+
- @mastra/core@1.0.0-beta.25
|
|
123
|
+
- @mastra/schema-compat@1.0.0-beta.8
|
|
124
|
+
|
|
3
125
|
## 1.0.0-beta.24
|
|
4
126
|
|
|
5
127
|
### Major Changes
|
package/README.md
CHANGED
|
@@ -24,9 +24,7 @@ async function main() {
|
|
|
24
24
|
const agent = client.getAgent('your-agent-id');
|
|
25
25
|
|
|
26
26
|
// Generate a response
|
|
27
|
-
const response = await agent.generate({
|
|
28
|
-
messages: [{ role: 'user', content: "What's the weather like today?" }],
|
|
29
|
-
});
|
|
27
|
+
const response = await agent.generate([{ role: 'user', content: "What's the weather like today?" }]);
|
|
30
28
|
|
|
31
29
|
console.log(response);
|
|
32
30
|
}
|
package/dist/client.d.ts
CHANGED
|
@@ -3,9 +3,9 @@ import type { ServerDetailInfo } from '@mastra/core/mcp';
|
|
|
3
3
|
import type { RequestContext } from '@mastra/core/request-context';
|
|
4
4
|
import type { TraceRecord, ListTracesArgs, ListTracesResponse } from '@mastra/core/storage';
|
|
5
5
|
import type { WorkflowInfo } from '@mastra/core/workflows';
|
|
6
|
-
import { Agent, MemoryThread, Tool, Workflow, Vector, BaseResource, A2A, MCPTool, AgentBuilder, StoredAgent } from './resources/index.js';
|
|
6
|
+
import { Agent, MemoryThread, Tool, Processor, Workflow, Vector, BaseResource, A2A, MCPTool, AgentBuilder, StoredAgent } from './resources/index.js';
|
|
7
7
|
import type { ListScoresBySpanParams, LegacyTracesPaginatedArg, LegacyGetTracesResponse } from './resources/observability.js';
|
|
8
|
-
import type { ClientOptions, CreateMemoryThreadParams, CreateMemoryThreadResponse, GetAgentResponse, GetLogParams, GetLogsParams, GetLogsResponse, GetToolResponse, GetWorkflowResponse, SaveMessageToMemoryParams, SaveMessageToMemoryResponse, McpServerListResponse, McpServerToolListResponse, GetScorerResponse, ListScoresByScorerIdParams, ListScoresByRunIdParams, ListScoresByEntityIdParams, SaveScoreParams, SaveScoreResponse, GetMemoryConfigParams, GetMemoryConfigResponse, ListMemoryThreadMessagesResponse, MemorySearchResponse, ListAgentsModelProvidersResponse, ListMemoryThreadsParams, ListMemoryThreadsResponse, ListStoredAgentsParams, ListStoredAgentsResponse, CreateStoredAgentParams, StoredAgentResponse, GetSystemPackagesResponse, ListScoresResponse as ListScoresResponseOld } from './types.js';
|
|
8
|
+
import type { ClientOptions, CreateMemoryThreadParams, CreateMemoryThreadResponse, GetAgentResponse, GetLogParams, GetLogsParams, GetLogsResponse, GetToolResponse, GetProcessorResponse, GetWorkflowResponse, SaveMessageToMemoryParams, SaveMessageToMemoryResponse, McpServerListResponse, McpServerToolListResponse, GetScorerResponse, ListScoresByScorerIdParams, ListScoresByRunIdParams, ListScoresByEntityIdParams, SaveScoreParams, SaveScoreResponse, GetMemoryConfigParams, GetMemoryConfigResponse, ListMemoryThreadMessagesResponse, MemorySearchResponse, ListAgentsModelProvidersResponse, ListMemoryThreadsParams, ListMemoryThreadsResponse, ListStoredAgentsParams, ListStoredAgentsResponse, CreateStoredAgentParams, StoredAgentResponse, GetSystemPackagesResponse, ListScoresResponse as ListScoresResponseOld } from './types.js';
|
|
9
9
|
export declare class MastraClient extends BaseResource {
|
|
10
10
|
private observability;
|
|
11
11
|
constructor(options: ClientOptions);
|
|
@@ -23,11 +23,11 @@ export declare class MastraClient extends BaseResource {
|
|
|
23
23
|
*/
|
|
24
24
|
getAgent(agentId: string): Agent;
|
|
25
25
|
/**
|
|
26
|
-
* Lists memory threads
|
|
27
|
-
* @param params - Parameters containing
|
|
26
|
+
* Lists memory threads with optional filtering by resourceId and/or metadata
|
|
27
|
+
* @param params - Parameters containing optional filters, pagination options, and request context
|
|
28
28
|
* @returns Promise containing paginated array of memory threads with metadata
|
|
29
29
|
*/
|
|
30
|
-
listMemoryThreads(params
|
|
30
|
+
listMemoryThreads(params?: ListMemoryThreadsParams): Promise<ListMemoryThreadsResponse>;
|
|
31
31
|
/**
|
|
32
32
|
* Retrieves memory config for a resource
|
|
33
33
|
* @param params - Parameters containing the resource ID and optional request context
|
|
@@ -99,6 +99,18 @@ export declare class MastraClient extends BaseResource {
|
|
|
99
99
|
* @returns Tool instance
|
|
100
100
|
*/
|
|
101
101
|
getTool(toolId: string): Tool;
|
|
102
|
+
/**
|
|
103
|
+
* Retrieves all available processors
|
|
104
|
+
* @param requestContext - Optional request context to pass as query parameter
|
|
105
|
+
* @returns Promise containing map of processor IDs to processor details
|
|
106
|
+
*/
|
|
107
|
+
listProcessors(requestContext?: RequestContext | Record<string, any>): Promise<Record<string, GetProcessorResponse>>;
|
|
108
|
+
/**
|
|
109
|
+
* Gets a processor instance by ID
|
|
110
|
+
* @param processorId - ID of the processor to retrieve
|
|
111
|
+
* @returns Processor instance
|
|
112
|
+
*/
|
|
113
|
+
getProcessor(processorId: string): Processor;
|
|
102
114
|
/**
|
|
103
115
|
* Retrieves all available workflows
|
|
104
116
|
* @param requestContext - Optional request context to pass as query parameter
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC5F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EACL,KAAK,EACL,YAAY,EACZ,IAAI,EACJ,QAAQ,EACR,MAAM,EACN,YAAY,EACZ,GAAG,EACH,OAAO,EACP,YAAY,EAEZ,WAAW,EACZ,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EACV,sBAAsB,EACtB,wBAAwB,EACxB,uBAAuB,EACxB,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EACV,aAAa,EACb,wBAAwB,EACxB,0BAA0B,EAC1B,gBAAgB,EAChB,YAAY,EACZ,aAAa,EACb,eAAe,EACf,eAAe,EACf,mBAAmB,EACnB,yBAAyB,EACzB,2BAA2B,EAC3B,qBAAqB,EACrB,yBAAyB,EACzB,iBAAiB,EACjB,0BAA0B,EAC1B,uBAAuB,EACvB,0BAA0B,EAC1B,eAAe,EACf,iBAAiB,EACjB,qBAAqB,EACrB,uBAAuB,EACvB,gCAAgC,EAChC,oBAAoB,EACpB,gCAAgC,E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CAAC,mBAAmB,CAAC;IAOvF;;;;OAIG;IACI,cAAc,CAAC,aAAa,EAAE,MAAM,GAAG,WAAW;IAQzD;;;OAGG;IACI,iBAAiB,IAAI,OAAO,CAAC,yBAAyB,CAAC;CAG/D"}
|
package/dist/docs/README.md
CHANGED
package/dist/docs/SKILL.md
CHANGED
|
@@ -133,7 +133,7 @@ import { createUIMessageStream } from "ai";
|
|
|
133
133
|
import { toAISdkStream } from "@mastra/ai-sdk";
|
|
134
134
|
import type { ChunkType, MastraModelOutput } from "@mastra/core/stream";
|
|
135
135
|
|
|
136
|
-
const response = await agent.stream(
|
|
136
|
+
const response = await agent.stream("Tell me a story");
|
|
137
137
|
|
|
138
138
|
const chunkStream: ReadableStream<ChunkType> = new ReadableStream<ChunkType>({
|
|
139
139
|
start(controller) {
|
|
@@ -184,14 +184,7 @@ const result = await agent.executeTool("tool-id", {
|
|
|
184
184
|
Stream responses from an agent network for multi-agent interactions:
|
|
185
185
|
|
|
186
186
|
```typescript
|
|
187
|
-
const response = await agent.network(
|
|
188
|
-
messages: [
|
|
189
|
-
{
|
|
190
|
-
role: "user",
|
|
191
|
-
content: "Research this topic and write a summary",
|
|
192
|
-
},
|
|
193
|
-
],
|
|
194
|
-
});
|
|
187
|
+
const response = await agent.network("Research this topic and write a summary");
|
|
195
188
|
|
|
196
189
|
response.processDataStream({
|
|
197
190
|
onChunk: async (chunk) => {
|
|
@@ -234,6 +227,44 @@ response.processDataStream({
|
|
|
234
227
|
});
|
|
235
228
|
```
|
|
236
229
|
|
|
230
|
+
### approveToolCallGenerate()
|
|
231
|
+
|
|
232
|
+
Approve a pending tool call when using `generate()` (non-streaming). Returns the complete response:
|
|
233
|
+
|
|
234
|
+
```typescript
|
|
235
|
+
const output = await agent.generate("Find user John", {
|
|
236
|
+
requireToolApproval: true,
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
if (output.finishReason === "suspended") {
|
|
240
|
+
const result = await agent.approveToolCallGenerate({
|
|
241
|
+
runId: output.runId,
|
|
242
|
+
toolCallId: output.suspendPayload.toolCallId,
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
console.log(result.text);
|
|
246
|
+
}
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
### declineToolCallGenerate()
|
|
250
|
+
|
|
251
|
+
Decline a pending tool call when using `generate()` (non-streaming). Returns the complete response:
|
|
252
|
+
|
|
253
|
+
```typescript
|
|
254
|
+
const output = await agent.generate("Find user John", {
|
|
255
|
+
requireToolApproval: true,
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
if (output.finishReason === "suspended") {
|
|
259
|
+
const result = await agent.declineToolCallGenerate({
|
|
260
|
+
runId: output.runId,
|
|
261
|
+
toolCallId: output.suspendPayload.toolCallId,
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
console.log(result.text);
|
|
265
|
+
}
|
|
266
|
+
```
|
|
267
|
+
|
|
237
268
|
## Client Tools
|
|
238
269
|
|
|
239
270
|
Client-side tools allow you to execute custom functions on the client side when the agent requests them.
|
|
@@ -430,9 +461,7 @@ All API methods can throw errors that you can catch and handle:
|
|
|
430
461
|
```typescript
|
|
431
462
|
try {
|
|
432
463
|
const agent = mastraClient.getAgent("agent-id");
|
|
433
|
-
const response = await agent.generate(
|
|
434
|
-
messages: [{ role: "user", content: "Hello" }],
|
|
435
|
-
});
|
|
464
|
+
const response = await agent.generate("Hello");
|
|
436
465
|
} catch (error) {
|
|
437
466
|
console.error("An error occurred:", error.message);
|
|
438
467
|
}
|
|
@@ -75,7 +75,7 @@ The Mastra Client SDK exposes all resources served by the Mastra Server
|
|
|
75
75
|
|
|
76
76
|
## Generating responses
|
|
77
77
|
|
|
78
|
-
Call `.generate()` with
|
|
78
|
+
Call `.generate()` with a string prompt:
|
|
79
79
|
|
|
80
80
|
```typescript
|
|
81
81
|
import { mastraClient } from "lib/mastra-client";
|
|
@@ -84,14 +84,7 @@ const testAgent = async () => {
|
|
|
84
84
|
try {
|
|
85
85
|
const agent = mastraClient.getAgent("testAgent");
|
|
86
86
|
|
|
87
|
-
const response = await agent.generate(
|
|
88
|
-
messages: [
|
|
89
|
-
{
|
|
90
|
-
role: "user",
|
|
91
|
-
content: "Hello",
|
|
92
|
-
},
|
|
93
|
-
],
|
|
94
|
-
});
|
|
87
|
+
const response = await agent.generate("Hello");
|
|
95
88
|
|
|
96
89
|
console.log(response.text);
|
|
97
90
|
} catch (error) {
|
|
@@ -102,11 +95,11 @@ const testAgent = async () => {
|
|
|
102
95
|
|
|
103
96
|
> **Note:**
|
|
104
97
|
|
|
105
|
-
Visit [.generate()](https://mastra.ai/reference/v1/client-js/agents#generate) for more information.
|
|
98
|
+
You can also call `.generate()` with an array of message objects that include `role` and `content`. Visit the [.generate() reference](https://mastra.ai/reference/v1/client-js/agents#generate) for more information.
|
|
106
99
|
|
|
107
100
|
## Streaming responses
|
|
108
101
|
|
|
109
|
-
Use `.stream()` for real-time responses with
|
|
102
|
+
Use `.stream()` for real-time responses with a string prompt:
|
|
110
103
|
|
|
111
104
|
```typescript
|
|
112
105
|
import { mastraClient } from "lib/mastra-client";
|
|
@@ -115,14 +108,7 @@ const testAgent = async () => {
|
|
|
115
108
|
try {
|
|
116
109
|
const agent = mastraClient.getAgent("testAgent");
|
|
117
110
|
|
|
118
|
-
const stream = await agent.stream(
|
|
119
|
-
messages: [
|
|
120
|
-
{
|
|
121
|
-
role: "user",
|
|
122
|
-
content: "Hello",
|
|
123
|
-
},
|
|
124
|
-
],
|
|
125
|
-
});
|
|
111
|
+
const stream = await agent.stream("Hello");
|
|
126
112
|
|
|
127
113
|
stream.processDataStream({
|
|
128
114
|
onTextPart: (text) => {
|
|
@@ -137,7 +123,7 @@ const testAgent = async () => {
|
|
|
137
123
|
|
|
138
124
|
> **Note:**
|
|
139
125
|
|
|
140
|
-
Visit [.stream()](https://mastra.ai/reference/v1/client-js/agents#stream) for more information.
|
|
126
|
+
You can also call `.stream()` with an array of message objects that include `role` and `content`. Visit the [.stream() reference](https://mastra.ai/reference/v1/client-js/agents#stream) for more information.
|
|
141
127
|
|
|
142
128
|
## Configuration options
|
|
143
129
|
|
|
@@ -220,8 +206,7 @@ const handleClientTool = async () => {
|
|
|
220
206
|
},
|
|
221
207
|
});
|
|
222
208
|
|
|
223
|
-
const response = await agent.generate({
|
|
224
|
-
messages: "Change the background to blue",
|
|
209
|
+
const response = await agent.generate("Change the background to blue", {
|
|
225
210
|
clientTools: { colorChangeTool },
|
|
226
211
|
});
|
|
227
212
|
|
|
@@ -257,9 +242,7 @@ You can also use `MastraClient` in server-side environments such as API routes,
|
|
|
257
242
|
export async function action() {
|
|
258
243
|
const agent = mastraClient.getAgent("testAgent");
|
|
259
244
|
|
|
260
|
-
const stream = await agent.stream(
|
|
261
|
-
messages: [{ role: "user", content: "Hello" }],
|
|
262
|
-
});
|
|
245
|
+
const stream = await agent.stream("Hello");
|
|
263
246
|
|
|
264
247
|
return new Response(stream.body);
|
|
265
248
|
}
|
|
@@ -63,9 +63,7 @@ Once `MastraClient` is configured, you can send authenticated requests from your
|
|
|
63
63
|
async function handleClick() {
|
|
64
64
|
const agent = mastraClient.getAgent("weatherAgent");
|
|
65
65
|
|
|
66
|
-
const response = await agent.generate(
|
|
67
|
-
messages: "Weather in London"
|
|
68
|
-
});
|
|
66
|
+
const response = await agent.generate("Weather in London");
|
|
69
67
|
|
|
70
68
|
console.log(response);
|
|
71
69
|
}
|
|
@@ -85,6 +83,7 @@ Once `MastraClient` is configured, you can send authenticated requests from your
|
|
|
85
83
|
"messages": "Weather in London"
|
|
86
84
|
}'
|
|
87
85
|
```
|
|
86
|
+
|
|
88
87
|
|
|
89
88
|
|
|
90
89
|
## Creating a JWT
|
|
@@ -14,7 +14,9 @@ CLERK_SECRET_KEY=sk_test_...
|
|
|
14
14
|
CLERK_JWKS_URI=https://your-clerk-domain.clerk.accounts.dev/.well-known/jwks.json
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
-
> **Note:**
|
|
17
|
+
> **Note:**
|
|
18
|
+
|
|
19
|
+
You can find these keys in your Clerk Dashboard under "API Keys".
|
|
18
20
|
|
|
19
21
|
## Installation
|
|
20
22
|
|
|
@@ -41,10 +43,10 @@ export const mastra = new Mastra({
|
|
|
41
43
|
});
|
|
42
44
|
```
|
|
43
45
|
|
|
44
|
-
> **Note:** The default `authorizeUser` method allows all authenticated users. To customize user authorization, provide a custom `authorizeUser` function when constructing the provider.
|
|
45
|
-
|
|
46
46
|
> **Note:**
|
|
47
47
|
|
|
48
|
+
The default `authorizeUser` method allows all authenticated users. To customize user authorization, provide a custom `authorizeUser` function when constructing the provider.
|
|
49
|
+
|
|
48
50
|
Visit [MastraAuthClerk](https://mastra.ai/reference/v1/auth/clerk) for all available configuration options.
|
|
49
51
|
|
|
50
52
|
## Client-side setup
|
|
@@ -70,7 +72,9 @@ export const useClerkAuth = () => {
|
|
|
70
72
|
};
|
|
71
73
|
```
|
|
72
74
|
|
|
73
|
-
>
|
|
75
|
+
> **Note:**
|
|
76
|
+
|
|
77
|
+
Refer to the [Clerk documentation](https://clerk.com/docs) for more information.
|
|
74
78
|
|
|
75
79
|
## Configuring `MastraClient`
|
|
76
80
|
|
|
@@ -87,9 +91,10 @@ export const mastraClient = new MastraClient({
|
|
|
87
91
|
});
|
|
88
92
|
```
|
|
89
93
|
|
|
90
|
-
> **Note:** The access token must be prefixed with `Bearer` in the Authorization header.
|
|
91
94
|
> **Note:**
|
|
92
95
|
|
|
96
|
+
The access token must be prefixed with `Bearer` in the Authorization header.
|
|
97
|
+
|
|
93
98
|
Visit [Mastra Client SDK](https://mastra.ai/docs/v1/server/mastra-client) for more configuration options.
|
|
94
99
|
|
|
95
100
|
### Making authenticated requests
|
|
@@ -116,9 +121,7 @@ Once `MastraClient` is configured with the Clerk access token, you can send auth
|
|
|
116
121
|
});
|
|
117
122
|
|
|
118
123
|
const weatherAgent = client.getAgent("weatherAgent");
|
|
119
|
-
const response = await weatherAgent.generate(
|
|
120
|
-
messages: "What's the weather like in New York",
|
|
121
|
-
});
|
|
124
|
+
const response = await weatherAgent.generate("What's the weather like in New York");
|
|
122
125
|
|
|
123
126
|
console.log({ response });
|
|
124
127
|
}
|
|
@@ -13,7 +13,9 @@ SUPABASE_URL=https://your-project.supabase.co
|
|
|
13
13
|
SUPABASE_ANON_KEY=your-anon-key
|
|
14
14
|
```
|
|
15
15
|
|
|
16
|
-
> **Note:**
|
|
16
|
+
> **Note:**
|
|
17
|
+
|
|
18
|
+
Review your Supabase Row Level Security (RLS) settings to ensure proper data access controls.
|
|
17
19
|
|
|
18
20
|
## Installation
|
|
19
21
|
|
|
@@ -39,10 +41,10 @@ export const mastra = new Mastra({
|
|
|
39
41
|
});
|
|
40
42
|
```
|
|
41
43
|
|
|
42
|
-
> **Note:** The default `authorizeUser` method checks the `isAdmin` column in the `users` table in the `public` schema. To customize user authorization, provide a custom `authorizeUser` function when constructing the provider.
|
|
43
|
-
|
|
44
44
|
> **Note:**
|
|
45
45
|
|
|
46
|
+
The default `authorizeUser` method checks the `isAdmin` column in the `users` table in the `public` schema. To customize user authorization, provide a custom `authorizeUser` function when constructing the provider.
|
|
47
|
+
|
|
46
48
|
Visit [MastraAuthSupabase](https://mastra.ai/reference/v1/auth/supabase) for all available configuration options.
|
|
47
49
|
|
|
48
50
|
## Client-side setup
|
|
@@ -66,7 +68,9 @@ const authTokenResponse = await supabase.auth.signInWithPassword({
|
|
|
66
68
|
const accessToken = authTokenResponse.data?.session?.access_token;
|
|
67
69
|
```
|
|
68
70
|
|
|
69
|
-
>
|
|
71
|
+
> **Note:**
|
|
72
|
+
|
|
73
|
+
Refer to the [Supabase documentation](https://supabase.com/docs/guides/auth) for other authentication methods like OAuth, magic links, and more.
|
|
70
74
|
|
|
71
75
|
## Configuring `MastraClient`
|
|
72
76
|
|
|
@@ -83,10 +87,10 @@ export const mastraClient = new MastraClient({
|
|
|
83
87
|
});
|
|
84
88
|
```
|
|
85
89
|
|
|
86
|
-
> **Note:** The access token must be prefixed with `Bearer` in the Authorization header.
|
|
87
|
-
|
|
88
90
|
> **Note:**
|
|
89
91
|
|
|
92
|
+
The access token must be prefixed with `Bearer` in the Authorization header.
|
|
93
|
+
|
|
90
94
|
Visit [Mastra Client SDK](https://mastra.ai/docs/v1/server/mastra-client) for more configuration options.
|
|
91
95
|
|
|
92
96
|
### Making authenticated requests
|
|
@@ -95,23 +99,21 @@ Once `MastraClient` is configured with the Supabase access token, you can send a
|
|
|
95
99
|
|
|
96
100
|
**react:**
|
|
97
101
|
|
|
98
|
-
|
|
99
|
-
|
|
102
|
+
```tsx title="src/components/test-agent.tsx" copy
|
|
103
|
+
import { mastraClient } from "../../lib/mastra-client";
|
|
100
104
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
105
|
+
export const TestAgent = () => {
|
|
106
|
+
async function handleClick() {
|
|
107
|
+
const agent = mastraClient.getAgent("weatherAgent");
|
|
104
108
|
|
|
105
|
-
|
|
106
|
-
messages: "What's the weather like in New York"
|
|
107
|
-
});
|
|
109
|
+
const response = await agent.generate("What's the weather like in New York");
|
|
108
110
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
+
console.log(response);
|
|
112
|
+
}
|
|
111
113
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
114
|
+
return <button onClick={handleClick}>Test Agent</button>;
|
|
115
|
+
};
|
|
116
|
+
```
|
|
115
117
|
|
|
116
118
|
|
|
117
119
|
**curl:**
|
|
@@ -20,7 +20,9 @@ FIRESTORE_DATABASE_ID=(default)
|
|
|
20
20
|
# FIREBASE_DATABASE_ID=(default)
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
-
> **Note:**
|
|
23
|
+
> **Note:**
|
|
24
|
+
|
|
25
|
+
Store your service account JSON file securely and never commit it to version control.
|
|
24
26
|
|
|
25
27
|
## Installation
|
|
26
28
|
|
|
@@ -73,7 +75,9 @@ The `MastraAuthFirebase` class can be configured through constructor options or
|
|
|
73
75
|
- `FIREBASE_SERVICE_ACCOUNT`: Path to Firebase service account JSON file
|
|
74
76
|
- `FIRESTORE_DATABASE_ID` or `FIREBASE_DATABASE_ID`: Firestore database ID
|
|
75
77
|
|
|
76
|
-
> **Note:**
|
|
78
|
+
> **Note:**
|
|
79
|
+
|
|
80
|
+
When constructor options are not provided, the class automatically reads these environment variables. This means you can simply call `new MastraAuthFirebase()` without any arguments if your environment variables are properly configured.
|
|
77
81
|
|
|
78
82
|
### User Authorization
|
|
79
83
|
|
|
@@ -163,7 +167,9 @@ export const signOutUser = async () => {
|
|
|
163
167
|
};
|
|
164
168
|
```
|
|
165
169
|
|
|
166
|
-
>
|
|
170
|
+
> **Note:**
|
|
171
|
+
|
|
172
|
+
Refer to the [Firebase documentation](https://firebase.google.com/docs/auth) for other authentication methods like email/password, phone authentication, and more.
|
|
167
173
|
|
|
168
174
|
## Configuring `MastraClient`
|
|
169
175
|
|
|
@@ -182,10 +188,10 @@ export const createMastraClient = (idToken: string) => {
|
|
|
182
188
|
};
|
|
183
189
|
```
|
|
184
190
|
|
|
185
|
-
> **Note:** The ID token must be prefixed with `Bearer` in the Authorization header.
|
|
186
|
-
|
|
187
191
|
> **Note:**
|
|
188
192
|
|
|
193
|
+
The ID token must be prefixed with `Bearer` in the Authorization header.
|
|
194
|
+
|
|
189
195
|
Visit [Mastra Client SDK](https://mastra.ai/docs/v1/server/mastra-client) for more configuration options.
|
|
190
196
|
|
|
191
197
|
### Making authenticated requests
|
|
@@ -212,9 +218,7 @@ Once `MastraClient` is configured with the Firebase ID token, you can send authe
|
|
|
212
218
|
const client = createMastraClient(token);
|
|
213
219
|
|
|
214
220
|
const weatherAgent = client.getAgent("weatherAgent");
|
|
215
|
-
const response = await weatherAgent.generate(
|
|
216
|
-
messages: "What's the weather like in New York",
|
|
217
|
-
});
|
|
221
|
+
const response = await weatherAgent.generate("What's the weather like in New York");
|
|
218
222
|
|
|
219
223
|
console.log({ response });
|
|
220
224
|
}
|
|
@@ -260,9 +264,7 @@ Once `MastraClient` is configured with the Firebase ID token, you can send authe
|
|
|
260
264
|
});
|
|
261
265
|
|
|
262
266
|
const weatherAgent = mastra.getAgent("weatherAgent");
|
|
263
|
-
const response = await weatherAgent.generate(
|
|
264
|
-
messages: "What's the weather like in Nairobi"
|
|
265
|
-
});
|
|
267
|
+
const response = await weatherAgent.generate("What's the weather like in Nairobi");
|
|
266
268
|
|
|
267
269
|
res.json({ response: response.text });
|
|
268
270
|
} catch (error) {
|