@mastra/client-js 1.22.0-alpha.3 → 1.22.0-alpha.4
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 +97 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/index.cjs +115 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +115 -8
- package/dist/index.js.map +1 -1
- package/dist/resources/tool-provider.d.ts +57 -10
- package/dist/resources/tool-provider.d.ts.map +1 -1
- package/dist/route-types.generated.d.ts +773 -1
- package/dist/route-types.generated.d.ts.map +1 -1
- package/dist/types.d.ts +73 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,102 @@
|
|
|
1
1
|
# @mastra/client-js
|
|
2
2
|
|
|
3
|
+
## 1.22.0-alpha.4
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Added the v1 ToolProvider runtime, server routes, client SDK methods, and editor wiring that power OAuth-backed integrations on stored agents. ([#17248](https://github.com/mastra-ai/mastra/pull/17248))
|
|
8
|
+
|
|
9
|
+
**Stored agents can now pin OAuth connections per toolkit**
|
|
10
|
+
|
|
11
|
+
A stored agent's config accepts a new `toolProviders` shape that tells the runtime which connection to bind for each toolkit at execution time. Connections can be scoped per-author, shared across an org, or supplied by the caller.
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
{
|
|
15
|
+
toolProviders: {
|
|
16
|
+
composio: {
|
|
17
|
+
connections: {
|
|
18
|
+
gmail: [{ kind: 'author', toolkit: 'gmail', connectionId: 'auth_abc', scope: 'per-author' }],
|
|
19
|
+
},
|
|
20
|
+
tools: {
|
|
21
|
+
GMAIL_FETCH_EMAILS: { toolkit: 'gmail' },
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
}
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
**New client SDK surface for managing connections**
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
import { MastraClient } from '@mastra/client-js';
|
|
32
|
+
|
|
33
|
+
const client = new MastraClient({ baseUrl: '…' });
|
|
34
|
+
const composio = client.toolProvider('composio');
|
|
35
|
+
|
|
36
|
+
const { items } = await composio.listConnections({ toolkit: 'gmail' });
|
|
37
|
+
await composio.disconnectConnection('auth_abc');
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
**New `ToolProvider` interface for custom providers**
|
|
41
|
+
|
|
42
|
+
Providers implement a VNext surface (`listToolkitsVNext`, `listToolsVNext`, `resolveToolsVNext`) plus the auth round-trip (`authorize`, `getAuthStatus`, `listConnections`, `disconnectConnection`, `listConnectionFields`, `health`). The Composio provider has been rewritten on this surface; the older catalog methods remain as `@deprecated` shims for back-compat.
|
|
43
|
+
|
|
44
|
+
Connections list responses use `page`/`perPage` pagination, matching the rest of the server surface.
|
|
45
|
+
|
|
46
|
+
Both stored agents (`editor.agent.getById(...)`) and code-defined agents with stored overrides (`editor.agent.applyStoredOverrides(...)`) resolve `toolProviders` at request time, merging provider-resolved tools alongside code/registry/MCP/integration tools.
|
|
47
|
+
|
|
48
|
+
Stored agents that don't set `toolProviders` continue to work unchanged. The Studio/Builder UI ships separately.
|
|
49
|
+
|
|
50
|
+
### Patch Changes
|
|
51
|
+
|
|
52
|
+
- Hardened v1 ToolProvider connection routes and SDK forwarding. ([#17248](https://github.com/mastra-ai/mastra/pull/17248))
|
|
53
|
+
|
|
54
|
+
**Fail closed on unknown `connectionId`**
|
|
55
|
+
|
|
56
|
+
`DELETE /tool-providers/:providerId/connections/:connectionId` and
|
|
57
|
+
`GET …/usage` now return `403` when storage is configured but no persisted
|
|
58
|
+
row matches the supplied `connectionId` and the caller isn't an admin.
|
|
59
|
+
Previously these routes fell through to the caller's own `authorId`, which
|
|
60
|
+
let non-admin callers probe (and trigger provider-side `revokeConnection`
|
|
61
|
+
for) IDs that didn't belong to them.
|
|
62
|
+
|
|
63
|
+
**Aligned authorize label validation with stored label rules**
|
|
64
|
+
|
|
65
|
+
`POST /tool-providers/:providerId/authorize` now enforces the same label
|
|
66
|
+
rules the stored `toolProviders` config uses (`min(1)`, `max(32)`,
|
|
67
|
+
`/^[A-Za-z0-9 _-]+$/`). Labels that pass `authorize` are now guaranteed to
|
|
68
|
+
pass downstream stored-agent validation.
|
|
69
|
+
|
|
70
|
+
**SDK forwards `toolkit` on connection-scoped operations**
|
|
71
|
+
|
|
72
|
+
`@mastra/client-js`:
|
|
73
|
+
|
|
74
|
+
```ts
|
|
75
|
+
await client.toolProviders.get('composio').disconnectConnection('ca_xxx', {
|
|
76
|
+
toolkit: 'gmail',
|
|
77
|
+
force: true,
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
const usage = await client.toolProviders.get('composio').getConnectionUsage('ca_xxx', { toolkit: 'gmail' });
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
`disconnectConnection` now forwards `params.toolkit` (previously dropped)
|
|
84
|
+
and `getConnectionUsage` accepts an optional `{ toolkit }` parameter so
|
|
85
|
+
toolkit-scoped connection lookups disambiguate correctly server-side.
|
|
86
|
+
|
|
87
|
+
- Improved observability and error isolation in the v1 ToolProvider runtime. ([#17248](https://github.com/mastra-ai/mastra/pull/17248))
|
|
88
|
+
|
|
89
|
+
**Better visibility into connection-scope misconfiguration**
|
|
90
|
+
|
|
91
|
+
When an agent runs with a stored ToolProvider connection whose scope cannot be resolved from the request context, the runtime now logs a one-shot warning and falls back to a shared bucket instead of silently routing every caller to the same OAuth account. Multi-tenant deployments get a clear signal when their identity wiring isn't reaching the runtime.
|
|
92
|
+
|
|
93
|
+
**One bad toolkit no longer disables sibling providers**
|
|
94
|
+
|
|
95
|
+
If a provider returns more connections for a toolkit than its declared capabilities allow, the runtime now logs and skips that toolkit instead of throwing. Other providers and other toolkits on the same agent continue to resolve normally.
|
|
96
|
+
|
|
97
|
+
- Updated dependencies [[`50ed00c`](https://github.com/mastra-ai/mastra/commit/50ed00caa914a85969b33de83f26b48e328ef641), [`9283971`](https://github.com/mastra-ai/mastra/commit/928397157009b4aef4d5fdf3a0a273cb371beb55), [`0bf2d93`](https://github.com/mastra-ai/mastra/commit/0bf2d932d20e2936f2d9abb8c0a86e24fbc97ec6), [`94dfef6`](https://github.com/mastra-ai/mastra/commit/94dfef6e2bf19a88467ea3940afcbce88a433f0f), [`a122f79`](https://github.com/mastra-ai/mastra/commit/a122f79427ae225ec79c7b2ed46278da48d04b17), [`4c02027`](https://github.com/mastra-ai/mastra/commit/4c020277235eaa6b1dc957c90ad0639eef213992), [`6855012`](https://github.com/mastra-ai/mastra/commit/685501247cc4717506f3e89beed03509d63a5370), [`7fef31c`](https://github.com/mastra-ai/mastra/commit/7fef31c0d2a6d362a43a647a8a4f6ab893758a23), [`7fef31c`](https://github.com/mastra-ai/mastra/commit/7fef31c0d2a6d362a43a647a8a4f6ab893758a23)]:
|
|
98
|
+
- @mastra/core@1.38.0-alpha.4
|
|
99
|
+
|
|
3
100
|
## 1.22.0-alpha.3
|
|
4
101
|
|
|
5
102
|
### 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.4"
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
## When to use
|
package/dist/index.cjs
CHANGED
|
@@ -5243,16 +5243,13 @@ var ToolProvider = class extends BaseResource {
|
|
|
5243
5243
|
}
|
|
5244
5244
|
providerId;
|
|
5245
5245
|
/**
|
|
5246
|
-
* Lists available toolkits from this provider
|
|
5247
|
-
* @returns Promise containing list of toolkits
|
|
5246
|
+
* Lists available toolkits from this provider.
|
|
5248
5247
|
*/
|
|
5249
5248
|
listToolkits() {
|
|
5250
5249
|
return this.request(`/tool-providers/${encodeURIComponent(this.providerId)}/toolkits`);
|
|
5251
5250
|
}
|
|
5252
5251
|
/**
|
|
5253
|
-
* Lists available tools from this provider, with optional filtering
|
|
5254
|
-
* @param params - Optional filtering and pagination parameters
|
|
5255
|
-
* @returns Promise containing list of tools
|
|
5252
|
+
* Lists available tools from this provider, with optional filtering.
|
|
5256
5253
|
*/
|
|
5257
5254
|
listTools(params) {
|
|
5258
5255
|
const searchParams = new URLSearchParams();
|
|
@@ -5274,15 +5271,125 @@ var ToolProvider = class extends BaseResource {
|
|
|
5274
5271
|
);
|
|
5275
5272
|
}
|
|
5276
5273
|
/**
|
|
5277
|
-
* Gets the input schema for a specific tool
|
|
5278
|
-
* @param toolSlug - The slug of the tool
|
|
5279
|
-
* @returns Promise containing the tool's JSON schema
|
|
5274
|
+
* Gets the input schema for a specific tool.
|
|
5280
5275
|
*/
|
|
5281
5276
|
getToolSchema(toolSlug) {
|
|
5282
5277
|
return this.request(
|
|
5283
5278
|
`/tool-providers/${encodeURIComponent(this.providerId)}/tools/${encodeURIComponent(toolSlug)}/schema`
|
|
5284
5279
|
);
|
|
5285
5280
|
}
|
|
5281
|
+
/**
|
|
5282
|
+
* Starts an OAuth flow for a (toolkit, connectionId) pair. Returns a
|
|
5283
|
+
* redirect URL and an opaque auth handle to poll with `getAuthStatus`.
|
|
5284
|
+
*/
|
|
5285
|
+
authorize(params) {
|
|
5286
|
+
return this.request(`/tool-providers/${encodeURIComponent(this.providerId)}/authorize`, {
|
|
5287
|
+
method: "POST",
|
|
5288
|
+
body: params
|
|
5289
|
+
});
|
|
5290
|
+
}
|
|
5291
|
+
/**
|
|
5292
|
+
* Polls the OAuth flow status for an outstanding authorize call.
|
|
5293
|
+
*/
|
|
5294
|
+
getAuthStatus(authId) {
|
|
5295
|
+
return this.request(
|
|
5296
|
+
`/tool-providers/${encodeURIComponent(this.providerId)}/auth-status/${encodeURIComponent(authId)}`
|
|
5297
|
+
);
|
|
5298
|
+
}
|
|
5299
|
+
/**
|
|
5300
|
+
* Batch-checks whether a set of (connectionId, toolkit) tuples are
|
|
5301
|
+
* currently connected.
|
|
5302
|
+
*/
|
|
5303
|
+
getConnectionStatus(params) {
|
|
5304
|
+
return this.request(`/tool-providers/${encodeURIComponent(this.providerId)}/connection-status`, {
|
|
5305
|
+
method: "POST",
|
|
5306
|
+
body: params
|
|
5307
|
+
});
|
|
5308
|
+
}
|
|
5309
|
+
/**
|
|
5310
|
+
* Lists existing provider connections, scoped to a toolkit.
|
|
5311
|
+
*
|
|
5312
|
+
* Default: the connection owner is resolved server-side from the request's
|
|
5313
|
+
* auth context. Admin callers (with `tool-providers:admin` permission) may
|
|
5314
|
+
* pass `authorId` to target a specific author, or omit it to receive
|
|
5315
|
+
* connections across all authors known to `tool_provider_connections` for
|
|
5316
|
+
* this provider/toolkit. Pagination is page-based via `page` (1-indexed)
|
|
5317
|
+
* and `perPage` (default 50, max 200).
|
|
5318
|
+
*/
|
|
5319
|
+
listConnections(params) {
|
|
5320
|
+
const searchParams = new URLSearchParams();
|
|
5321
|
+
searchParams.set("toolkit", params.toolkit);
|
|
5322
|
+
if (params.authorId) {
|
|
5323
|
+
searchParams.set("authorId", params.authorId);
|
|
5324
|
+
}
|
|
5325
|
+
if (params.page !== void 0 && params.page !== null) {
|
|
5326
|
+
searchParams.set("page", String(params.page));
|
|
5327
|
+
}
|
|
5328
|
+
if (params.perPage !== void 0 && params.perPage !== null) {
|
|
5329
|
+
searchParams.set("perPage", String(params.perPage));
|
|
5330
|
+
}
|
|
5331
|
+
if (params.scope) {
|
|
5332
|
+
searchParams.set("scope", params.scope);
|
|
5333
|
+
}
|
|
5334
|
+
return this.request(
|
|
5335
|
+
`/tool-providers/${encodeURIComponent(this.providerId)}/connections?${searchParams.toString()}`
|
|
5336
|
+
);
|
|
5337
|
+
}
|
|
5338
|
+
/**
|
|
5339
|
+
* Lists provider-specific fields the picker should collect before
|
|
5340
|
+
* initiating a new connection (e.g. Confluence subdomain). Most toolkits
|
|
5341
|
+
* return an empty array.
|
|
5342
|
+
*/
|
|
5343
|
+
listConnectionFields(params) {
|
|
5344
|
+
const searchParams = new URLSearchParams();
|
|
5345
|
+
searchParams.set("toolkit", params.toolkit);
|
|
5346
|
+
return this.request(
|
|
5347
|
+
`/tool-providers/${encodeURIComponent(this.providerId)}/connection-fields?${searchParams.toString()}`
|
|
5348
|
+
);
|
|
5349
|
+
}
|
|
5350
|
+
/**
|
|
5351
|
+
* Disconnects (revokes + deletes) a persisted connection.
|
|
5352
|
+
*
|
|
5353
|
+
* Without `force: true` the server refuses if any agent still pins the
|
|
5354
|
+
* connection. With `force: true` the provider-side revoke is best-effort
|
|
5355
|
+
* (errors are tolerated) and the local row is always removed.
|
|
5356
|
+
*/
|
|
5357
|
+
disconnectConnection(connectionId, params) {
|
|
5358
|
+
const searchParams = new URLSearchParams();
|
|
5359
|
+
if (params?.toolkit) {
|
|
5360
|
+
searchParams.set("toolkit", params.toolkit);
|
|
5361
|
+
}
|
|
5362
|
+
if (params?.force) {
|
|
5363
|
+
searchParams.set("force", "true");
|
|
5364
|
+
}
|
|
5365
|
+
const queryString = searchParams.toString();
|
|
5366
|
+
return this.request(
|
|
5367
|
+
`/tool-providers/${encodeURIComponent(this.providerId)}/connections/${encodeURIComponent(connectionId)}${queryString ? `?${queryString}` : ""}`,
|
|
5368
|
+
{
|
|
5369
|
+
method: "DELETE"
|
|
5370
|
+
}
|
|
5371
|
+
);
|
|
5372
|
+
}
|
|
5373
|
+
/**
|
|
5374
|
+
* Lists the agents that currently pin a given connection. Used by the
|
|
5375
|
+
* picker to warn the user before disconnecting a shared account.
|
|
5376
|
+
*/
|
|
5377
|
+
getConnectionUsage(connectionId, params) {
|
|
5378
|
+
const searchParams = new URLSearchParams();
|
|
5379
|
+
if (params?.toolkit) {
|
|
5380
|
+
searchParams.set("toolkit", params.toolkit);
|
|
5381
|
+
}
|
|
5382
|
+
const queryString = searchParams.toString();
|
|
5383
|
+
return this.request(
|
|
5384
|
+
`/tool-providers/${encodeURIComponent(this.providerId)}/connections/${encodeURIComponent(connectionId)}/usage${queryString ? `?${queryString}` : ""}`
|
|
5385
|
+
);
|
|
5386
|
+
}
|
|
5387
|
+
/**
|
|
5388
|
+
* Returns provider-level health (config, reachability, etc.).
|
|
5389
|
+
*/
|
|
5390
|
+
getHealth() {
|
|
5391
|
+
return this.request(`/tool-providers/${encodeURIComponent(this.providerId)}/health`);
|
|
5392
|
+
}
|
|
5286
5393
|
};
|
|
5287
5394
|
|
|
5288
5395
|
// src/resources/processor-provider.ts
|