@mastra/client-js 1.35.0-alpha.4 → 1.35.1-alpha.0
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 +42 -0
- package/dist/docs/SKILL.md +2 -2
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/reference-ai-sdk-to-ai-sdk-messages.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 +9 -9
- package/dist/docs/references/reference-client-js-memory.md +2 -2
- package/dist/docs/references/reference-client-js-workflows.md +1 -1
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,47 @@
|
|
|
1
1
|
# @mastra/client-js
|
|
2
2
|
|
|
3
|
+
## 1.35.1-alpha.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`3f472b4`](https://github.com/mastra-ai/mastra/commit/3f472b468892a1ff14ccb43cc0343b86f7d8fd7d), [`35b929b`](https://github.com/mastra-ai/mastra/commit/35b929b7abc3d20d85c7985880960ac2d04a6c86), [`9b3626a`](https://github.com/mastra-ai/mastra/commit/9b3626aeb1d16fcd34b0a8e94c114ddb80a3b240)]:
|
|
8
|
+
- @mastra/core@1.55.0-alpha.0
|
|
9
|
+
|
|
10
|
+
## 1.35.0
|
|
11
|
+
|
|
12
|
+
### Minor Changes
|
|
13
|
+
|
|
14
|
+
- Added exact metadata filtering to message history queries across Memory APIs and supported storage providers. ([#19991](https://github.com/mastra-ai/mastra/pull/19991))
|
|
15
|
+
|
|
16
|
+
```ts
|
|
17
|
+
const messages = await memory.recall({
|
|
18
|
+
threadId: 'thread-1',
|
|
19
|
+
filter: {
|
|
20
|
+
metadata: {
|
|
21
|
+
status: 'done',
|
|
22
|
+
priority: 'high',
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Multiple fields use AND semantics. Supported values are strings, finite numbers, booleans, and `null`.
|
|
29
|
+
|
|
30
|
+
### Patch Changes
|
|
31
|
+
|
|
32
|
+
- Added the `name` and `description` fields to the `DatasetExperiment` type. The server already returned these values, so you can now read an experiment's name and description directly from `listDatasetExperiments`, `listExperiments`, and `getDatasetExperiment` — no cast needed. ([#19256](https://github.com/mastra-ai/mastra/pull/19256))
|
|
33
|
+
|
|
34
|
+
```ts
|
|
35
|
+
const { experiments } = await client.listDatasetExperiments(datasetId);
|
|
36
|
+
|
|
37
|
+
for (const experiment of experiments) {
|
|
38
|
+
console.log(experiment.name, experiment.description);
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
- Updated dependencies [[`ce93a3c`](https://github.com/mastra-ai/mastra/commit/ce93a3c114ea1cbfbd576f3db41d7c26c9844f5b), [`5718a22`](https://github.com/mastra-ai/mastra/commit/5718a229281dcfd36bcd1f42a242e3717e510a33), [`a211d09`](https://github.com/mastra-ai/mastra/commit/a211d09185dc65a746534914cf38b67f21ee9bac), [`0dca9d0`](https://github.com/mastra-ai/mastra/commit/0dca9d0b1356024a53b72ea6f040db528b126caa), [`6218217`](https://github.com/mastra-ai/mastra/commit/62182171b6cfca0b099f1c6a77a2e65e7639ab86), [`5807d3a`](https://github.com/mastra-ai/mastra/commit/5807d3ae1d259b8b7d6df7e5bf2b485c694af9c8), [`57661af`](https://github.com/mastra-ai/mastra/commit/57661afeca52ff9af4e72675ede2134fa503d5a5), [`05db566`](https://github.com/mastra-ai/mastra/commit/05db566fcbdcbf33d0bffca0c72ec30129e2e3ca), [`57661af`](https://github.com/mastra-ai/mastra/commit/57661afeca52ff9af4e72675ede2134fa503d5a5), [`57661af`](https://github.com/mastra-ai/mastra/commit/57661afeca52ff9af4e72675ede2134fa503d5a5), [`5718a22`](https://github.com/mastra-ai/mastra/commit/5718a229281dcfd36bcd1f42a242e3717e510a33), [`57661af`](https://github.com/mastra-ai/mastra/commit/57661afeca52ff9af4e72675ede2134fa503d5a5), [`d1b7e3a`](https://github.com/mastra-ai/mastra/commit/d1b7e3a978a309a5653eeaa490d2d6c7c53bd093), [`29c584a`](https://github.com/mastra-ai/mastra/commit/29c584a13a88831e5ed1fdeb0ff8e82eae180433), [`c093146`](https://github.com/mastra-ai/mastra/commit/c0931466404d3c521308ea119cb165bb7e695155), [`8124754`](https://github.com/mastra-ai/mastra/commit/8124754ae89fbc69f8136d1df4a91904d0f84c4e), [`d12b2e4`](https://github.com/mastra-ai/mastra/commit/d12b2e4023fd9e3d3e93a9169f5088bcee2a849c)]:
|
|
43
|
+
- @mastra/core@1.54.0
|
|
44
|
+
|
|
3
45
|
## 1.35.0-alpha.4
|
|
4
46
|
|
|
5
47
|
### 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.35.
|
|
6
|
+
version: "1.35.1-alpha.0"
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
## When to use
|
|
@@ -34,7 +34,7 @@ Read the individual reference documents for detailed explanations and code examp
|
|
|
34
34
|
- [Reference: toAISdkStream()](references/reference-ai-sdk-to-ai-sdk-stream.md) - API reference for toAISdkStream(), a function to convert Mastra streams to AI SDK-compatible streams.
|
|
35
35
|
- [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.
|
|
36
36
|
- [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.
|
|
37
|
-
- [Reference: Agent Builder API](references/reference-client-js-agent-builder.md) - Learn how to interact with Agent Builder actions, including starting runs
|
|
37
|
+
- [Reference: Agent Builder API](references/reference-client-js-agent-builder.md) - Learn how to interact with Agent Builder actions, including starting runs and streaming progress, plus resuming suspended steps and observing runs using the client-js SDK.
|
|
38
38
|
- [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.
|
|
39
39
|
- [Reference: OpenAI Responses API Conversations](references/reference-client-js-conversations.md) - API reference for the client-js helpers that call Mastra's OpenAI-compatible `/v1/conversations` routes.
|
|
40
40
|
- [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.
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# toAISdkMessages()
|
|
4
4
|
|
|
5
|
-
Converts messages from
|
|
5
|
+
Converts messages from input formats to AI SDK UI message format. `toAISdkMessages()` keeps the existing AI SDK v5/default behavior. If your app is typed against AI SDK v6, pass `version: 'v6'`.
|
|
6
6
|
|
|
7
7
|
`version: 'v6'` uses the MessageList AI SDK v6 UI output path. MessageList input detection and ingestion remain unchanged.
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# toAISdkV4Messages()
|
|
4
4
|
|
|
5
|
-
Converts messages from
|
|
5
|
+
Converts messages from input formats to AI SDK V4 UI message format. This function accepts messages in multiple formats (strings, AI SDK V4/V5 messages, Mastra DB messages, etc.) and normalizes them to the AI SDK V4 `UIMessage` format, which is suitable for use with AI SDK UI components like `useChat()`.
|
|
6
6
|
|
|
7
7
|
## Usage example
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# toAISdkV5Messages()
|
|
4
4
|
|
|
5
|
-
Converts messages from
|
|
5
|
+
Converts messages from input formats to AI SDK V5 (and later) UI message format. This function accepts messages in multiple formats (strings, AI SDK V4/V5 messages, Mastra DB messages, etc.) and normalizes them to the AI SDK V5+ `UIMessage` format, which is suitable for use with AI SDK UI components like `useChat()`.
|
|
6
6
|
|
|
7
7
|
## Usage example
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# Agents API
|
|
4
4
|
|
|
5
|
-
The Agents API provides methods to interact with Mastra AI agents, including generating responses
|
|
5
|
+
The Agents API provides methods to interact with Mastra AI agents, including generating responses and streaming interactions. It also provides methods for managing agent tools.
|
|
6
6
|
|
|
7
7
|
## Getting all agents
|
|
8
8
|
|
|
@@ -155,7 +155,7 @@ for await (const part of uiMessageStream) {
|
|
|
155
155
|
|
|
156
156
|
### `sendMessage()`
|
|
157
157
|
|
|
158
|
-
Send user-authored input to an active agent run or idle memory thread. Use this with `subscribeToThread()` so the client can render the stream that wakes from, or receives
|
|
158
|
+
Send user-authored input to an active agent run or idle memory thread. Use this with `subscribeToThread()` so the client can render the stream that wakes from, or receives the message.
|
|
159
159
|
|
|
160
160
|
```typescript
|
|
161
161
|
const agent = mastraClient.getAgent('support-agent')
|
|
@@ -285,7 +285,7 @@ await subscription.processDataStream({
|
|
|
285
285
|
|
|
286
286
|
### `streamUntilIdle()`
|
|
287
287
|
|
|
288
|
-
Stream a response and keep the stream open until every [background task](https://mastra.ai/docs/long-running-agents/background-tasks) dispatched during the run completes. The server re-enters the agentic loop on each task completion so the LLM can react to results in the same call. Requires background tasks to be [enabled on the Mastra instance](https://mastra.ai/reference/configuration) and a memory thread; otherwise the call
|
|
288
|
+
Stream a response and keep the stream open until every [background task](https://mastra.ai/docs/long-running-agents/background-tasks) dispatched during the run completes. The server re-enters the agentic loop on each task completion so the LLM can react to results in the same call. Requires background tasks to be [enabled on the Mastra instance](https://mastra.ai/reference/configuration) and a memory thread; otherwise the call uses a plain `stream()`.
|
|
289
289
|
|
|
290
290
|
```typescript
|
|
291
291
|
const response = await agent.streamUntilIdle('Research solana for me', {
|
|
@@ -307,7 +307,7 @@ response.processDataStream({
|
|
|
307
307
|
|
|
308
308
|
### `resumeStreamUntilIdle()`
|
|
309
309
|
|
|
310
|
-
Resume a suspended agent stream with custom data and keep the stream open until every [background task](https://mastra.ai/docs/long-running-agents/background-tasks) dispatched during the run completes. Use this to continue execution after a suspension point, such as a workflow suspend within an agent. Requires background tasks to be [enabled on the Mastra instance](https://mastra.ai/reference/configuration) and a memory thread; otherwise the call
|
|
310
|
+
Resume a suspended agent stream with custom data and keep the stream open until every [background task](https://mastra.ai/docs/long-running-agents/background-tasks) dispatched during the run completes. Use this to continue execution after a suspension point, such as a workflow suspend within an agent. Requires background tasks to be [enabled on the Mastra instance](https://mastra.ai/reference/configuration) and a memory thread; otherwise the call uses a plain `resumeStream()`:
|
|
311
311
|
|
|
312
312
|
```typescript
|
|
313
313
|
const response = await agent.resumeStreamUntilIdle(
|
|
@@ -366,7 +366,7 @@ response.processDataStream({
|
|
|
366
366
|
|
|
367
367
|
### `listSuspendedRuns()`
|
|
368
368
|
|
|
369
|
-
List suspended runs for the agent from storage
|
|
369
|
+
List suspended runs for the agent from storage: runs waiting on a tool-call approval or on a tool that suspended. Discovery is backed by storage, so it works after a server restart and across server instances. Pass the returned `runId` to `approveToolCall()`, `declineToolCall()`, or `resumeStream()`.
|
|
370
370
|
|
|
371
371
|
```typescript
|
|
372
372
|
const { runs, total } = await agent.listSuspendedRuns({
|
|
@@ -655,9 +655,9 @@ const screenshotTool = createTool({
|
|
|
655
655
|
|
|
656
656
|
### Tracing client tools
|
|
657
657
|
|
|
658
|
-
When `@mastra/observability` is installed and configured on the server, a client-side tool records a `CLIENT_TOOL_CALL` span as a child of the current `AGENT_RUN` span. The server creates that span when the model emits the client tool call
|
|
658
|
+
When `@mastra/observability` is installed and configured on the server, a client-side tool records a `CLIENT_TOOL_CALL` span as a child of the current `AGENT_RUN` span. The server creates that span when the model emits the client tool call and injects a W3C trace carrier into the outgoing tool-call chunk. It ends the span once the tool arguments are available. Without server-side observability configured, client tool tracing is a no-op.
|
|
659
659
|
|
|
660
|
-
The client SDK also measures the wall-clock duration of each client tool's `execute` function and
|
|
660
|
+
The client SDK also measures the wall-clock duration of each client tool's `execute` function and sends it back to the server, where it's emitted as a `mastra_tool_duration_ms` metric with `toolType: "client"`.
|
|
661
661
|
|
|
662
662
|
For richer telemetry from inside your tool's `execute` function, use the `observe` helper on the execution context to add child spans and structured logs:
|
|
663
663
|
|
|
@@ -680,9 +680,9 @@ const fetchUserTool = createTool({
|
|
|
680
680
|
})
|
|
681
681
|
```
|
|
682
682
|
|
|
683
|
-
`observe` is always available
|
|
683
|
+
`observe` is always available: when no tracing context is active (e.g. running outside a traced agent), `span` runs the function directly and `log` is a no-op. No null-checking needed.
|
|
684
684
|
|
|
685
|
-
The SDK serializes everything the collector buffered as OTLP/JSON and
|
|
685
|
+
The SDK serializes everything the collector buffered as OTLP/JSON and sends it back in the next request body. The server's `@mastra/observability` package validates that the spans belong to the correct trace (preventing cross-trace injection) and forwards each span/log into the same observability bus that server-side telemetry uses. Your existing exporters pick them up automatically after observability is configured.
|
|
686
686
|
|
|
687
687
|
## Stored agents
|
|
688
688
|
|
|
@@ -168,7 +168,7 @@ const result = await thread.listMessages({
|
|
|
168
168
|
})
|
|
169
169
|
```
|
|
170
170
|
|
|
171
|
-
Metadata filters match shallow scalar values only: `string`, finite `number`, `boolean`, and `null`. Every key-value pair must match with AND semantics. `null` matches
|
|
171
|
+
Metadata filters match shallow scalar values only: `string`, finite `number`, `boolean`, and `null`. Every key-value pair must match with AND semantics. `null` matches only keys explicitly set to `null`. Metadata keys must start with a letter or underscore and contain only alphanumeric or underscore characters. The limit is 128 characters. Reserved prototype keys such as `__proto__`, `constructor`, and `prototype` aren't allowed. Performance depends on the server storage backend, and arbitrary metadata filters may scan candidate messages.
|
|
172
172
|
|
|
173
173
|
### Delete Messages
|
|
174
174
|
|
|
@@ -226,7 +226,7 @@ await mastraClient.updateWorkingMemory({
|
|
|
226
226
|
// Returns: { success: true }
|
|
227
227
|
```
|
|
228
228
|
|
|
229
|
-
|
|
229
|
+
For resource-scoped working memory, you must provide the `resourceId` parameter. It allows the memory to persist across all conversation threads for that user.
|
|
230
230
|
|
|
231
231
|
### Get Memory Status
|
|
232
232
|
|
|
@@ -142,7 +142,7 @@ await run.resume({
|
|
|
142
142
|
})
|
|
143
143
|
```
|
|
144
144
|
|
|
145
|
-
When a [`.foreach()`](https://mastra.ai/reference/workflows/workflow-methods/foreach) step suspends across multiple iterations, pass `forEachIndex` (zero-based
|
|
145
|
+
When a [`.foreach()`](https://mastra.ai/reference/workflows/workflow-methods/foreach) step suspends across multiple iterations, pass `forEachIndex` (zero-based. `0` targets the first iteration) to resume one iteration at a time. Iterations you don't target remain suspended.
|
|
146
146
|
|
|
147
147
|
```typescript
|
|
148
148
|
await run.resume({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/client-js",
|
|
3
|
-
"version": "1.35.
|
|
3
|
+
"version": "1.35.1-alpha.0",
|
|
4
4
|
"description": "The official TypeScript library for the Mastra Client API",
|
|
5
5
|
"author": "",
|
|
6
6
|
"type": "module",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"canonicalize": "^1.0.8",
|
|
40
40
|
"jose": "^6.2.1",
|
|
41
41
|
"json-schema": "^0.4.0",
|
|
42
|
-
"@mastra/core": "1.
|
|
42
|
+
"@mastra/core": "1.55.0-alpha.0",
|
|
43
43
|
"@mastra/schema-compat": "1.3.4"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
@@ -56,10 +56,10 @@
|
|
|
56
56
|
"typescript": "^6.0.3",
|
|
57
57
|
"vitest": "4.1.10",
|
|
58
58
|
"zod": "^4.4.3",
|
|
59
|
-
"@internal/ai-sdk-v4": "0.0.
|
|
60
|
-
"@internal/
|
|
61
|
-
"@internal/
|
|
62
|
-
"@internal/
|
|
59
|
+
"@internal/ai-sdk-v4": "0.0.65",
|
|
60
|
+
"@internal/ai-sdk-v5": "0.0.65",
|
|
61
|
+
"@internal/types-builder": "0.0.93",
|
|
62
|
+
"@internal/lint": "0.0.118"
|
|
63
63
|
},
|
|
64
64
|
"engines": {
|
|
65
65
|
"node": ">=22.13.0"
|