@mastra/client-js 1.40.1-alpha.6 → 1.41.0-alpha.8
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 +29 -0
- package/dist/docs/SKILL.md +6 -6
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/{docs-agents-a2a.md → docs-connections-a2a.md} +2 -2
- package/dist/docs/references/{docs-long-running-agents-schedules.md → docs-harness-schedules.md} +5 -5
- package/dist/docs/references/docs-server-mastra-client.md +2 -2
- package/dist/docs/references/integrations-auth-workos.md +1 -1
- package/dist/docs/references/reference-client-js-agents.md +4 -4
- package/dist/docs/references/reference-editor-versioning.md +3 -3
- package/dist/index.cjs +12 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +12 -2
- package/dist/index.js.map +1 -1
- package/dist/resources/agent-controller.d.ts +3 -1
- package/dist/resources/agent-controller.d.ts.map +1 -1
- package/dist/resources/agent.d.ts +7 -1
- package/dist/resources/agent.d.ts.map +1 -1
- package/dist/route-types.generated.d.ts +81 -36
- package/dist/route-types.generated.d.ts.map +1 -1
- package/dist/types.d.ts +1 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -2
- /package/dist/docs/references/{docs-server-auth-jwt.md → docs-auth-jwt.md} +0 -0
- /package/dist/docs/references/{docs-long-running-agents-signals.md → docs-harness-signals.md} +0 -0
- /package/dist/docs/references/{docs-editor-overview.md → docs-studio-editor.md} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
1
|
# @mastra/client-js
|
|
2
2
|
|
|
3
|
+
## 1.41.0-alpha.8
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Added `Agent.readPlan()` for loading submitted plan Markdown. ([#21658](https://github.com/mastra-ai/mastra/pull/21658))
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
const agent = client.getAgent('agent-id');
|
|
11
|
+
const plan = await agent.readPlan('.mastracode/plans/add-dark-mode.md');
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- `session.state()` now accepts a `threadId`, so reopening a chat can load the durable task list for that specific thread. ([#21545](https://github.com/mastra-ai/mastra/pull/21545))
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
const state = await session.state({ threadId: 'thread-123' });
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
- Updated dependencies [[`4e7a421`](https://github.com/mastra-ai/mastra/commit/4e7a421dce8a48742f785d1e93ad2f43a572b282), [`242e324`](https://github.com/mastra-ai/mastra/commit/242e3241e73cbd5c9bb86a31ebb49ca0256488d4), [`217e967`](https://github.com/mastra-ai/mastra/commit/217e9672d8b3160eb729d8e9f0044949e88da239), [`d774e89`](https://github.com/mastra-ai/mastra/commit/d774e8930c781df8c9effe3763e6b501c099b6cc), [`9c27a53`](https://github.com/mastra-ai/mastra/commit/9c27a53cd9d3de4f3f025bc387d94ce371c33f95), [`dff25a1`](https://github.com/mastra-ai/mastra/commit/dff25a1103fa72ee082a9b6f805ebeb5ce400753), [`217e967`](https://github.com/mastra-ai/mastra/commit/217e9672d8b3160eb729d8e9f0044949e88da239), [`7f78585`](https://github.com/mastra-ai/mastra/commit/7f785857e401570e2ffb316911f126ed363aa537), [`f2a4afd`](https://github.com/mastra-ai/mastra/commit/f2a4afd7e37e809669001ed17724b341a5c1f45e), [`d438148`](https://github.com/mastra-ai/mastra/commit/d438148e222c1e2fb3c652725ce75680962ebec4), [`ba05fe0`](https://github.com/mastra-ai/mastra/commit/ba05fe0738f70cb686777546e968237d09269142), [`d26a8d4`](https://github.com/mastra-ai/mastra/commit/d26a8d4281f28414715b333c85bedaf70d0b2890), [`677cdc6`](https://github.com/mastra-ai/mastra/commit/677cdc6af564dec29a13464d12b7ab2a4efc22e9), [`a318490`](https://github.com/mastra-ai/mastra/commit/a318490e17da32f338d50929c770d901a9b3dd72), [`763e0c6`](https://github.com/mastra-ai/mastra/commit/763e0c61e04d76ad9a9efd301aa57525ca0cbea9), [`23e0be2`](https://github.com/mastra-ai/mastra/commit/23e0be261381e49534b4ff3101c60ee64a946cbf), [`7fc8806`](https://github.com/mastra-ai/mastra/commit/7fc880627d3cbf995d31ea0e8b807bf15417e651), [`0e02eac`](https://github.com/mastra-ai/mastra/commit/0e02eacdb2e30e1697a41910b41163742a181dc1), [`4df174c`](https://github.com/mastra-ai/mastra/commit/4df174c32bddf093a82f273070b8380aef7c9e90), [`f7c25b5`](https://github.com/mastra-ai/mastra/commit/f7c25b5106ddfb48e591f98df7a51e0f2dd01dba), [`dc09cc1`](https://github.com/mastra-ai/mastra/commit/dc09cc1083d861cde192c1cd235324dc75b8c731), [`36b4649`](https://github.com/mastra-ai/mastra/commit/36b4649045a3a380cbab8ceca866db4086223aff), [`377eb81`](https://github.com/mastra-ai/mastra/commit/377eb81ce43b964e3a6b541df172da74a8ff3716)]:
|
|
23
|
+
- @mastra/core@1.60.0-alpha.8
|
|
24
|
+
|
|
25
|
+
## 1.40.1-alpha.7
|
|
26
|
+
|
|
27
|
+
### Patch Changes
|
|
28
|
+
|
|
29
|
+
- Updated dependencies [[`940bf5c`](https://github.com/mastra-ai/mastra/commit/940bf5ccf04f2c9ebd8a1390431733222a03b1cd)]:
|
|
30
|
+
- @mastra/core@1.60.0-alpha.7
|
|
31
|
+
|
|
3
32
|
## 1.40.1-alpha.6
|
|
4
33
|
|
|
5
34
|
### 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.41.0-alpha.8"
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
## When to use
|
|
@@ -16,12 +16,12 @@ Read the individual reference documents for detailed explanations and code examp
|
|
|
16
16
|
|
|
17
17
|
### Docs
|
|
18
18
|
|
|
19
|
-
- [
|
|
20
|
-
- [
|
|
21
|
-
- [Schedules](references/docs-
|
|
22
|
-
- [Signals](references/docs-
|
|
23
|
-
- [JSON Web Token](references/docs-server-auth-jwt.md) - Documentation for JSON Web Token usage inside Mastra.
|
|
19
|
+
- [JSON Web Token](references/docs-auth-jwt.md) - Documentation for JSON Web Token usage inside Mastra.
|
|
20
|
+
- [A2A (Agent-to-Agent)](references/docs-connections-a2a.md) - Expose and call remote Mastra agents over the Agent-to-Agent protocol.
|
|
21
|
+
- [Schedules](references/docs-harness-schedules.md) - Run an agent on a cron schedule to deliver a recurring prompt, with optional thread delivery and lifecycle hooks.
|
|
22
|
+
- [Signals](references/docs-harness-signals.md) - Learn how to send real-time messages and context into a Mastra agent thread.
|
|
24
23
|
- [Mastra client](references/docs-server-mastra-client.md) - Learn how to set up and use the Mastra Client SDK
|
|
24
|
+
- [Editor](references/docs-studio-editor.md) - Let collaborators update an agent in Studio, test their changes, and publish without editing code.
|
|
25
25
|
|
|
26
26
|
### Integrations
|
|
27
27
|
|
|
@@ -80,7 +80,7 @@ Use `A2AAgent` when another Mastra agent should delegate work to a remote agent.
|
|
|
80
80
|
|
|
81
81
|
## Consume A2A agents as subagents
|
|
82
82
|
|
|
83
|
-
Use `A2AAgent` to wrap a remote A2A agent, then add it to a parent agent with the [supervisor agents](https://mastra.ai/docs/
|
|
83
|
+
Use `A2AAgent` to wrap a remote A2A agent, then add it to a parent agent with the [supervisor agents](https://mastra.ai/docs/subagents) pattern. Pass an explicit agent card URL when the remote server hosts multiple agents or uses a custom well-known path.
|
|
84
84
|
|
|
85
85
|
```typescript
|
|
86
86
|
import { Agent } from '@mastra/core/agent'
|
|
@@ -221,7 +221,7 @@ A2A models human-in-the-loop (HITL) work with the `input-required` task state. W
|
|
|
221
221
|
|
|
222
222
|
Mastra maps its agent suspension model to this state in both directions:
|
|
223
223
|
|
|
224
|
-
- **As a server**: when an exposed agent suspends, the task transitions to `input-required`. This includes suspensions caused by [tool approval](https://mastra.ai/docs/agents/
|
|
224
|
+
- **As a server**: when an exposed agent suspends, the task transitions to `input-required`. This includes suspensions caused by [tool approval](https://mastra.ai/docs/agents/human-in-the-loop) or a tool that calls `suspend()`. The task status message includes a text prompt and a data part with the structured `suspendPayload` and `resumeSchema`. A follow-up `message/send` or `message/stream` request with the same `taskId` resumes the suspended run with the provided input.
|
|
225
225
|
- **As a client**: when a remote task reaches `input-required` or `auth-required`, `A2AAgent` returns a suspended result with `finishReason: 'suspended'` and a `suspendPayload`. Calling `resumeGenerate()` or `resumeStream()` sends the input or credentials back to the remote task with the original `taskId`.
|
|
226
226
|
|
|
227
227
|
```typescript
|
package/dist/docs/references/{docs-long-running-agents-schedules.md → docs-harness-schedules.md}
RENAMED
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
|
|
7
7
|
> **Beta:** Breaking changes may occur without a major version bump until the API is stable.
|
|
8
8
|
|
|
9
|
-
A schedule runs an agent on a cron cadence. On each fire, Mastra sends a prompt to the agent, either as a [signal](https://mastra.ai/docs/
|
|
9
|
+
A schedule runs an agent on a cron cadence. On each fire, Mastra sends a prompt to the agent, either as a [signal](https://mastra.ai/docs/harness/signals) into a thread or as a threadless [`agent.generate()`](https://mastra.ai/reference/agents/generate) run. Use schedules for recurring agent work such as daily summaries, periodic checks, or scheduled nudges into a conversation.
|
|
10
10
|
|
|
11
11
|
Schedules are persisted, so they survive restarts and redeploys. Manage them at runtime through [`mastra.schedules`](https://mastra.ai/reference/schedules/overview), the canonical create, read, update, and delete (CRUD) surface. The same surface also manages [workflow schedules](https://mastra.ai/docs/workflows/scheduled-workflows) (pass `workflowId` instead of `agentId` to schedule a workflow).
|
|
12
12
|
|
|
13
|
-
> **Note:** Schedules require a [storage](https://mastra.ai/docs/storage
|
|
13
|
+
> **Note:** Schedules require a [storage](https://mastra.ai/docs/storage) adapter that implements the schedules domain. See the [`mastra.schedules` reference](https://mastra.ai/reference/schedules/overview) for supported adapters and API behavior.
|
|
14
14
|
|
|
15
15
|
## Quickstart
|
|
16
16
|
|
|
@@ -71,7 +71,7 @@ Without a `threadId`, each fire is an isolated `agent.generate()` run. Nothing i
|
|
|
71
71
|
|
|
72
72
|
### Threaded
|
|
73
73
|
|
|
74
|
-
With a `threadId`, the schedule sends a [signal](https://mastra.ai/docs/
|
|
74
|
+
With a `threadId`, the schedule sends a [signal](https://mastra.ai/docs/harness/signals) into that thread, so the prompt joins the agent's conversation. Threaded schedules require a `resourceId` alongside the `threadId`.
|
|
75
75
|
|
|
76
76
|
```typescript
|
|
77
77
|
await mastra.schedules.create({
|
|
@@ -83,7 +83,7 @@ await mastra.schedules.create({
|
|
|
83
83
|
})
|
|
84
84
|
```
|
|
85
85
|
|
|
86
|
-
Threaded schedules accept extra fields that control how the signal behaves, including the signal type, XML tag, tag attributes, and active-or-idle delivery behavior. They mirror the options [`agent.sendSignal()`](https://mastra.ai/docs/
|
|
86
|
+
Threaded schedules accept extra fields that control how the signal behaves, including the signal type, XML tag, tag attributes, and active-or-idle delivery behavior. They mirror the options [`agent.sendSignal()`](https://mastra.ai/docs/harness/signals) accepts and stay JSON-serializable so they persist with the schedule.
|
|
87
87
|
|
|
88
88
|
These fields require a `threadId`. For the full threaded input shape, see the [agent schedule input reference](https://mastra.ai/reference/schedules/overview).
|
|
89
89
|
|
|
@@ -197,5 +197,5 @@ Hook exceptions are caught and logged. They never re-route the worker or trigger
|
|
|
197
197
|
## Related
|
|
198
198
|
|
|
199
199
|
- [`mastra.schedules`](https://mastra.ai/reference/schedules/overview): API reference for creating and managing schedules.
|
|
200
|
-
- [Signals](https://mastra.ai/docs/
|
|
200
|
+
- [Signals](https://mastra.ai/docs/harness/signals): the delivery mechanism behind threaded schedules.
|
|
201
201
|
- [Scheduled workflows](https://mastra.ai/docs/workflows/scheduled-workflows): declare a cron schedule on a workflow definition.
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# Mastra client
|
|
4
4
|
|
|
5
|
-
The Mastra Client SDK provides a concise and type-safe interface for interacting with your [Mastra Server](https://mastra.ai/docs/server/
|
|
5
|
+
The Mastra Client SDK provides a concise and type-safe interface for interacting with your [Mastra Server](https://mastra.ai/docs/server/overview) from your client environment.
|
|
6
6
|
|
|
7
7
|
## Prerequisites
|
|
8
8
|
|
|
@@ -59,7 +59,7 @@ export const mastraClient = new MastraClient({
|
|
|
59
59
|
The Mastra Client SDK exposes all resources served by the Mastra Server.
|
|
60
60
|
|
|
61
61
|
- **[Agents](https://mastra.ai/reference/client-js/agents)**: Generate responses and stream conversations.
|
|
62
|
-
- **[A2A](https://mastra.ai/docs/
|
|
62
|
+
- **[A2A](https://mastra.ai/docs/connections/a2a)**: Discover agents through agent cards and work with task-based A2A streams.
|
|
63
63
|
- **[Memory](https://mastra.ai/reference/client-js/memory)**: Manage conversation threads and message history.
|
|
64
64
|
- **[Tools](https://mastra.ai/reference/client-js/tools)**: Executed and managed tools.
|
|
65
65
|
- **[Workflows](https://mastra.ai/reference/client-js/workflows)**: Trigger workflows and track their execution.
|
|
@@ -89,7 +89,7 @@ By default, `MastraAuthWorkos` grants access to any authenticated WorkOS user. T
|
|
|
89
89
|
|
|
90
90
|
### FGA membership loading
|
|
91
91
|
|
|
92
|
-
Set `fetchMemberships: true` when you use [`MastraFGAWorkos`](https://mastra.ai/docs/
|
|
92
|
+
Set `fetchMemberships: true` when you use [`MastraFGAWorkos`](https://mastra.ai/docs/auth/fga). This tells the auth provider to load the user's WorkOS organization memberships during authentication so FGA checks can resolve the correct organization membership ID.
|
|
93
93
|
|
|
94
94
|
```typescript
|
|
95
95
|
import { MastraAuthWorkos, MastraFGAWorkos } from '@mastra/auth-workos'
|
|
@@ -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/
|
|
288
|
+
Stream a response and keep the stream open until every [background task](https://mastra.ai/docs/harness/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/
|
|
310
|
+
Resume a suspended agent stream with custom data and keep the stream open until every [background task](https://mastra.ai/docs/harness/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(
|
|
@@ -497,7 +497,7 @@ if (output.finishReason === 'suspended') {
|
|
|
497
497
|
|
|
498
498
|
## Agent schedules
|
|
499
499
|
|
|
500
|
-
Use the client SDK schedule methods to manage persisted agent schedules over the `/api/schedules` routes. For concepts and server-side examples, see [Schedules](https://mastra.ai/docs/
|
|
500
|
+
Use the client SDK schedule methods to manage persisted agent schedules over the `/api/schedules` routes. For concepts and server-side examples, see [Schedules](https://mastra.ai/docs/harness/schedules) and the [`mastra.schedules` reference](https://mastra.ai/reference/schedules/overview).
|
|
501
501
|
|
|
502
502
|
### `createSchedule()`
|
|
503
503
|
|
|
@@ -839,7 +839,7 @@ console.log(result.success) // true
|
|
|
839
839
|
|
|
840
840
|
## Version management
|
|
841
841
|
|
|
842
|
-
Both `Agent` (code-defined) and `StoredAgent` instances have methods for managing configuration versions. See [Editor versioning](https://mastra.ai/docs/editor
|
|
842
|
+
Both `Agent` (code-defined) and `StoredAgent` instances have methods for managing configuration versions. See [Editor versioning](https://mastra.ai/docs/studio/editor) for lifecycle and selection behavior.
|
|
843
843
|
|
|
844
844
|
### Getting an agent with a specific version
|
|
845
845
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
Editor versions stored agents and prompt blocks. Database-backed resources use draft and publish operations. Code-backed agent overrides use deterministic files and Git history.
|
|
6
6
|
|
|
7
|
-
See [Editor versioning](https://mastra.ai/docs/editor
|
|
7
|
+
See [Editor versioning](https://mastra.ai/docs/studio/editor) for release and experimentation patterns.
|
|
8
8
|
|
|
9
9
|
## Database lifecycle
|
|
10
10
|
|
|
@@ -35,7 +35,7 @@ See [`MastraEditor`](https://mastra.ai/reference/editor/mastra-editor) for sourc
|
|
|
35
35
|
|
|
36
36
|
## Select an agent version
|
|
37
37
|
|
|
38
|
-
Calling [`mastra.getAgentById()`](https://mastra.ai/reference/core/getAgentById) without a selector returns the registered code-defined agent. Pass `status` or `versionId` to apply a stored override. See [Select a version](https://mastra.ai/docs/editor
|
|
38
|
+
Calling [`mastra.getAgentById()`](https://mastra.ai/reference/core/getAgentById) without a selector returns the registered code-defined agent. Pass `status` or `versionId` to apply a stored override. See [Select a version](https://mastra.ai/docs/studio/editor) for a TypeScript example.
|
|
39
39
|
|
|
40
40
|
With the default server prefix, pass selectors as query parameters under `/api`:
|
|
41
41
|
|
|
@@ -54,7 +54,7 @@ See the [Client SDK agents reference](https://mastra.ai/reference/client-js/agen
|
|
|
54
54
|
|
|
55
55
|
## Sub-agent versioning
|
|
56
56
|
|
|
57
|
-
Version overrides propagate through [supervisor-agent delegation](https://mastra.ai/docs/
|
|
57
|
+
Version overrides propagate through [supervisor-agent delegation](https://mastra.ai/docs/subagents) in request context. Define selectors at three levels:
|
|
58
58
|
|
|
59
59
|
1. `Mastra` instance `versions`: Defaults for every invocation
|
|
60
60
|
2. Server request-body `versions`: Per-request values added to request context
|
package/dist/index.cjs
CHANGED
|
@@ -884,6 +884,15 @@ var Agent = class extends BaseResource {
|
|
|
884
884
|
return this.request(`/agents/${this.agentId}${this.getQueryString(requestContext)}`);
|
|
885
885
|
}
|
|
886
886
|
/**
|
|
887
|
+
* Reads a markdown plan submitted by this agent through the core submit_plan tool.
|
|
888
|
+
* The server only serves paths under `.mastracode/plans/` and only when the
|
|
889
|
+
* agent exposes that capability.
|
|
890
|
+
*/
|
|
891
|
+
readPlan(path, requestContext) {
|
|
892
|
+
const contextQuery = this.getQueryString(requestContext, "&");
|
|
893
|
+
return this.request(`/agents/${this.agentId}/plans/file?path=${encodeURIComponent(path)}${contextQuery}`);
|
|
894
|
+
}
|
|
895
|
+
/**
|
|
887
896
|
* Probe the agent's browser session state before opening a screencast WebSocket.
|
|
888
897
|
*
|
|
889
898
|
* Returns `{ hasSession, screencastAvailable }`. Use this to avoid opening a WS
|
|
@@ -5989,8 +5998,9 @@ var AgentControllerSession = class extends BaseResource {
|
|
|
5989
5998
|
});
|
|
5990
5999
|
}
|
|
5991
6000
|
/** Get the current mode, model, and thread (for initial UI hydration). */
|
|
5992
|
-
state() {
|
|
5993
|
-
|
|
6001
|
+
state(options) {
|
|
6002
|
+
const path = options?.threadId ? `${this.base()}?threadId=${encodeURIComponent(options.threadId)}` : this.base();
|
|
6003
|
+
return this.request(this.url(path));
|
|
5994
6004
|
}
|
|
5995
6005
|
/** Merge key-value pairs into the session state. Existing keys not in the payload are preserved. */
|
|
5996
6006
|
async setState(updates) {
|