@mastra/client-js 1.22.0-alpha.4 → 1.22.0-alpha.5
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 +35 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/docs-editor-overview.md +70 -8
- package/dist/index.cjs +23 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -1
- package/dist/resources/stored-agent.d.ts +5 -1
- package/dist/resources/stored-agent.d.ts.map +1 -1
- package/dist/resources/tool-provider.d.ts +7 -1
- package/dist/resources/tool-provider.d.ts.map +1 -1
- package/dist/route-types.generated.d.ts +2415 -258
- package/dist/route-types.generated.d.ts.map +1 -1
- package/dist/types.d.ts +11 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,40 @@
|
|
|
1
1
|
# @mastra/client-js
|
|
2
2
|
|
|
3
|
+
## 1.22.0-alpha.5
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Added an agent override export API and server-side ownership enforcement. ([#17228](https://github.com/mastra-ai/mastra/pull/17228))
|
|
8
|
+
|
|
9
|
+
The server and client now expose an agent override export endpoint so Studio can download an agent's overrides as JSON for review or commit workflows. Saves are enforced server-side against each agent's `editor` config, so only owned fields (instructions, tools, or tool descriptions) are persisted and fields locked by the `editor` config are stripped.
|
|
10
|
+
|
|
11
|
+
The system packages response also reports the active editor `source` so clients can render the correct editing experience.
|
|
12
|
+
|
|
13
|
+
- Added a `PATCH /tool-providers/:providerId/connections/:connectionId` endpoint and matching client SDK method so authors can rename a connection's display label after creation. ([#17249](https://github.com/mastra-ai/mastra/pull/17249))
|
|
14
|
+
|
|
15
|
+
**Rename a connection from the client SDK**
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import { MastraClient } from '@mastra/client-js';
|
|
19
|
+
|
|
20
|
+
const client = new MastraClient({ baseUrl: '…' });
|
|
21
|
+
|
|
22
|
+
await client.getToolProvider('composio').updateConnection('auth_abc', {
|
|
23
|
+
label: 'Work inbox',
|
|
24
|
+
});
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Pass `label: null` (or an empty string) to clear the existing label. Labels are 1–32 characters and accept letters, digits, spaces, underscores, and hyphens (`[A-Za-z0-9 _-]+`).
|
|
28
|
+
|
|
29
|
+
**Ownership enforced server-side**
|
|
30
|
+
|
|
31
|
+
Non-owners get a 403 unless they hold `tool-providers:admin`. Shared connections are reachable by every author. The label is stored on the connection row itself, so the rename flows to every agent that pins the connection — no per-agent edit needed.
|
|
32
|
+
|
|
33
|
+
### Patch Changes
|
|
34
|
+
|
|
35
|
+
- Updated dependencies [[`a18775a`](https://github.com/mastra-ai/mastra/commit/a18775a693172546ee2378d39b67d4e32895b251), [`1baf2d1`](https://github.com/mastra-ai/mastra/commit/1baf2d152c6881338ff8f114633d5316fe13dd15)]:
|
|
36
|
+
- @mastra/core@1.38.0-alpha.5
|
|
37
|
+
|
|
3
38
|
## 1.22.0-alpha.4
|
|
4
39
|
|
|
5
40
|
### Minor 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.22.0-alpha.
|
|
6
|
+
version: "1.22.0-alpha.5"
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
## When to use
|
|
@@ -66,6 +66,41 @@ Once registered, you can manage agents through [Studio](https://mastra.ai/docs/s
|
|
|
66
66
|
|
|
67
67
|
> **Note:** See the [MastraEditor reference](https://mastra.ai/reference/editor/mastra-editor) for all configuration options.
|
|
68
68
|
|
|
69
|
+
## Code and database sources
|
|
70
|
+
|
|
71
|
+
The editor stores agent overrides in one of two sources, set with the `source` option on `MastraEditor`:
|
|
72
|
+
|
|
73
|
+
| Source | Where overrides live | Studio actions |
|
|
74
|
+
| -------------- | --------------------------------------------------------- | -------------------------------------------------------- |
|
|
75
|
+
| `db` (default) | The configured storage backend. | Save and publish drafts. |
|
|
76
|
+
| `code` | Per-agent JSON files on disk, tracked in your repository. | Download the override file or save it to the filesystem. |
|
|
77
|
+
|
|
78
|
+
The default `db` source is best when non-developers iterate through Studio and you want versioning, drafts, and runtime version targeting. The `code` source is best when overrides should live in your repository alongside the rest of your code, reviewed through pull requests and deployed with your application.
|
|
79
|
+
|
|
80
|
+
To use the code source, set `source: 'code'`:
|
|
81
|
+
|
|
82
|
+
```typescript
|
|
83
|
+
import { Mastra } from '@mastra/core'
|
|
84
|
+
import { MastraEditor } from '@mastra/editor'
|
|
85
|
+
|
|
86
|
+
export const mastra = new Mastra({
|
|
87
|
+
agents: {
|
|
88
|
+
/* your existing agents */
|
|
89
|
+
},
|
|
90
|
+
editor: new MastraEditor({
|
|
91
|
+
source: 'code',
|
|
92
|
+
}),
|
|
93
|
+
})
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
When `source` is `'code'`, the editor writes each override to a deterministic JSON file under `./mastra/editor/agents/<agentId>.json`. Set `codePath` to change the directory. Because the files are deterministic, every save produces a clean diff you can commit and review.
|
|
97
|
+
|
|
98
|
+
### Versioning with the code source
|
|
99
|
+
|
|
100
|
+
The code source uses the Git history of each per-agent JSON file as its version history. Each commit that changes a file appears as a read-only version in Studio, labeled with the commit message. Saving in Studio updates the working file in place rather than creating a database draft, so the version dropdown reflects your actual commit history.
|
|
101
|
+
|
|
102
|
+
This means versions and rollbacks are managed through Git rather than through draft and publish actions.
|
|
103
|
+
|
|
69
104
|
## Studio
|
|
70
105
|
|
|
71
106
|
Go to the **Agents** tab in Studio and select an agent to edit. Select the **Editor** tab. You'll be taken to the editor interface, where you can modify the agent's instructions, tools, and variables.
|
|
@@ -114,15 +149,16 @@ The `editor.agent` namespace also exposes `getById`, `list`, `listResolved`, and
|
|
|
114
149
|
|
|
115
150
|
The same operations are available over HTTP through the Mastra server. Use these when you want to manage stored agents from a separate service or from a non-TypeScript client:
|
|
116
151
|
|
|
117
|
-
| Method | Path
|
|
118
|
-
| -------- |
|
|
119
|
-
| `GET` | `/stored/agents`
|
|
120
|
-
| `POST` | `/stored/agents`
|
|
121
|
-
| `GET` | `/stored/agents/:storedAgentId`
|
|
122
|
-
| `PATCH` | `/stored/agents/:storedAgentId`
|
|
123
|
-
| `DELETE` | `/stored/agents/:storedAgentId`
|
|
152
|
+
| Method | Path | Description |
|
|
153
|
+
| -------- | -------------------------------------- | ---------------------------------------------------------------- |
|
|
154
|
+
| `GET` | `/stored/agents` | List all stored agents. |
|
|
155
|
+
| `POST` | `/stored/agents` | Create a stored agent. |
|
|
156
|
+
| `GET` | `/stored/agents/:storedAgentId` | Get a stored agent by ID. |
|
|
157
|
+
| `PATCH` | `/stored/agents/:storedAgentId` | Update a stored agent. |
|
|
158
|
+
| `DELETE` | `/stored/agents/:storedAgentId` | Delete a stored agent. |
|
|
159
|
+
| `POST` | `/stored/agents/:storedAgentId/export` | Export a stored agent's override as a deterministic JSON config. |
|
|
124
160
|
|
|
125
|
-
The Client SDK wraps these endpoints with `client.listStoredAgents()`, `client.createStoredAgent()`, and `client.getStoredAgent()`. Version management endpoints live under `/stored/agents/:storedAgentId/versions`, see [version management](https://mastra.ai/reference/client-js/agents) for the full list.
|
|
161
|
+
The export endpoint returns only the fields the agent's [`editor` config](https://mastra.ai/reference/agents/agent) allows, so the output matches the per-agent file the code source writes to disk. The Client SDK wraps these endpoints with `client.listStoredAgents()`, `client.createStoredAgent()`, `client.getStoredAgent()`, and `client.getStoredAgent(id).export()`. Version management endpoints live under `/stored/agents/:storedAgentId/versions`, see [version management](https://mastra.ai/reference/client-js/agents) for the full list.
|
|
126
162
|
|
|
127
163
|
### Automated experimentation
|
|
128
164
|
|
|
@@ -149,6 +185,32 @@ When you edit a code-defined agent through the editor, only specific fields can
|
|
|
149
185
|
|
|
150
186
|
Fields like the agent's `id`, `name`, and `model` come from your code and can't be changed through the editor for code-defined agents. The variables are also read-only.
|
|
151
187
|
|
|
188
|
+
### Controlling what is editable
|
|
189
|
+
|
|
190
|
+
Use the `editor` field on a code-defined agent to control which fields the editor can override. This lets you keep some fields code-owned while allowing edits to others:
|
|
191
|
+
|
|
192
|
+
```typescript
|
|
193
|
+
import { Agent } from '@mastra/core/agent'
|
|
194
|
+
|
|
195
|
+
export const supportAgent = new Agent({
|
|
196
|
+
name: 'support-agent',
|
|
197
|
+
model: 'openai/gpt-5.4',
|
|
198
|
+
editor: { instructions: true, tools: { description: true } },
|
|
199
|
+
})
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
The `editor` field accepts these shapes:
|
|
203
|
+
|
|
204
|
+
| Value | Result |
|
|
205
|
+
| ---------------------------------- | ---------------------------------------------------------- |
|
|
206
|
+
| Omitted | Instructions and tools are editable. |
|
|
207
|
+
| `false` | Nothing is editable. The agent is locked. |
|
|
208
|
+
| `{ instructions: true }` | Instructions are editable. |
|
|
209
|
+
| `{ tools: true }` | Tool membership and descriptions are editable. |
|
|
210
|
+
| `{ tools: { description: true } }` | Only tool descriptions are editable. Membership is locked. |
|
|
211
|
+
|
|
212
|
+
When a field is owned by code, Studio shows it as read-only and the server strips it from saved overrides, so the stored config only contains the fields you allow. See the [`editor` overrides reference](https://mastra.ai/reference/agents/agent) for the full type.
|
|
213
|
+
|
|
152
214
|
## Versioning
|
|
153
215
|
|
|
154
216
|
Every time you save changes to an agent or prompt block, a new version snapshot is created. Versions give you a full history of your agent's configuration. You can roll back to any previous state, compare what changed between two snapshots, and target specific versions per request for A/B testing or gradual rollouts.
|
package/dist/index.cjs
CHANGED
|
@@ -4710,6 +4710,15 @@ var StoredAgent = class extends BaseResource {
|
|
|
4710
4710
|
}
|
|
4711
4711
|
);
|
|
4712
4712
|
}
|
|
4713
|
+
/**
|
|
4714
|
+
* Exports deterministic JSON for this agent without mutating storage.
|
|
4715
|
+
*/
|
|
4716
|
+
export(params) {
|
|
4717
|
+
return this.request(`/stored/agents/${encodeURIComponent(this.storedAgentId)}/export`, {
|
|
4718
|
+
method: "POST",
|
|
4719
|
+
body: params
|
|
4720
|
+
});
|
|
4721
|
+
}
|
|
4713
4722
|
/**
|
|
4714
4723
|
* Deletes the stored agent
|
|
4715
4724
|
* @param requestContext - Optional request context to pass as query parameter
|
|
@@ -5370,6 +5379,20 @@ var ToolProvider = class extends BaseResource {
|
|
|
5370
5379
|
}
|
|
5371
5380
|
);
|
|
5372
5381
|
}
|
|
5382
|
+
/**
|
|
5383
|
+
* Updates the persisted display label on a connection row. Pass `label: null`
|
|
5384
|
+
* (or an empty string) to clear the existing label. Only the connection owner
|
|
5385
|
+
* or an admin may rename, unless the row is `scope: 'shared'`.
|
|
5386
|
+
*/
|
|
5387
|
+
updateConnection(connectionId, params) {
|
|
5388
|
+
return this.request(
|
|
5389
|
+
`/tool-providers/${encodeURIComponent(this.providerId)}/connections/${encodeURIComponent(connectionId)}`,
|
|
5390
|
+
{
|
|
5391
|
+
method: "PATCH",
|
|
5392
|
+
body: params
|
|
5393
|
+
}
|
|
5394
|
+
);
|
|
5395
|
+
}
|
|
5373
5396
|
/**
|
|
5374
5397
|
* Lists the agents that currently pin a given connection. Used by the
|
|
5375
5398
|
* picker to warn the user before disconnecting a shared account.
|