@mastra/editor 0.3.0 → 0.4.0-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 +105 -0
- package/dist/arcade.cjs +293 -0
- package/dist/arcade.d.cts +66 -0
- package/dist/arcade.d.ts +66 -0
- package/dist/arcade.js +266 -0
- package/dist/composio.cjs +143 -0
- package/dist/composio.d.cts +59 -0
- package/dist/composio.d.ts +59 -0
- package/dist/composio.js +116 -0
- package/dist/index.cjs +238 -12
- package/dist/index.d.cts +57 -7
- package/dist/index.d.ts +57 -7
- package/dist/index.js +226 -11
- package/package.json +49 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,110 @@
|
|
|
1
1
|
# @mastra/editor
|
|
2
2
|
|
|
3
|
+
## 0.4.0-alpha.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Added observational memory configuration support for stored agents. When creating or editing a stored agent in the playground, you can now enable observational memory and configure its settings including model provider/name, scope (thread or resource), share token budget, and detailed observer/reflector parameters like token limits, buffer settings, and blocking thresholds. The configuration is serialized as part of the agent's memory config and round-trips through storage. ([#12962](https://github.com/mastra-ai/mastra/pull/12962))
|
|
8
|
+
|
|
9
|
+
**Example usage in the playground:**
|
|
10
|
+
|
|
11
|
+
Enable the Observational Memory toggle in the Memory section, then configure:
|
|
12
|
+
- Top-level model (provider + model) used by both observer and reflector
|
|
13
|
+
- Scope: `thread` (per-conversation) or `resource` (shared across threads)
|
|
14
|
+
- Expand **Observer** or **Reflector** sections to override models and tune token budgets
|
|
15
|
+
|
|
16
|
+
**Programmatic usage via client SDK:**
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
await client.createStoredAgent({
|
|
20
|
+
name: 'My Agent',
|
|
21
|
+
// ...other config
|
|
22
|
+
memory: {
|
|
23
|
+
observationalMemory: true, // enable with defaults
|
|
24
|
+
options: { lastMessages: 40 },
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
// Or with custom configuration:
|
|
29
|
+
await client.createStoredAgent({
|
|
30
|
+
name: 'My Agent',
|
|
31
|
+
memory: {
|
|
32
|
+
observationalMemory: {
|
|
33
|
+
model: 'google/gemini-2.5-flash',
|
|
34
|
+
scope: 'resource',
|
|
35
|
+
shareTokenBudget: true,
|
|
36
|
+
observation: { messageTokens: 50000 },
|
|
37
|
+
reflection: { observationTokens: 60000 },
|
|
38
|
+
},
|
|
39
|
+
options: { lastMessages: 40 },
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
**Programmatic usage via editor:**
|
|
45
|
+
|
|
46
|
+
```ts
|
|
47
|
+
await editor.agent.create({
|
|
48
|
+
name: 'My Agent',
|
|
49
|
+
// ...other config
|
|
50
|
+
memory: {
|
|
51
|
+
observationalMemory: true, // enable with defaults
|
|
52
|
+
options: { lastMessages: 40 },
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
// Or with custom configuration:
|
|
57
|
+
await editor.agent.create({
|
|
58
|
+
name: 'My Agent',
|
|
59
|
+
memory: {
|
|
60
|
+
observationalMemory: {
|
|
61
|
+
model: 'google/gemini-2.5-flash',
|
|
62
|
+
scope: 'resource',
|
|
63
|
+
shareTokenBudget: true,
|
|
64
|
+
observation: { messageTokens: 50000 },
|
|
65
|
+
reflection: { observationTokens: 60000 },
|
|
66
|
+
},
|
|
67
|
+
options: { lastMessages: 40 },
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
- Added MCP client management, integration tools resolution, and built-in Composio and Arcade AI tool providers. ([#12974](https://github.com/mastra-ai/mastra/pull/12974))
|
|
73
|
+
|
|
74
|
+
**MCP Client Namespace**
|
|
75
|
+
|
|
76
|
+
New `editor.mcpClient` namespace for managing stored MCP client configurations with full CRUD operations. Stored agents can reference MCP clients with per-server tool filtering.
|
|
77
|
+
|
|
78
|
+
**Integration Tools**
|
|
79
|
+
|
|
80
|
+
Stored agents now support an `integrationTools` conditional field that resolves tools from registered `ToolProvider` instances at hydration time:
|
|
81
|
+
|
|
82
|
+
```ts
|
|
83
|
+
import { MastraEditor } from '@mastra/editor';
|
|
84
|
+
import { ComposioToolProvider } from '@mastra/editor/composio';
|
|
85
|
+
import { ArcadeToolProvider } from '@mastra/editor/arcade';
|
|
86
|
+
|
|
87
|
+
const editor = new MastraEditor({
|
|
88
|
+
// ...
|
|
89
|
+
toolProviders: {
|
|
90
|
+
composio: new ComposioToolProvider({ apiKey: '...' }),
|
|
91
|
+
arcade: new ArcadeToolProvider({ apiKey: '...' }),
|
|
92
|
+
},
|
|
93
|
+
});
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
**Built-in Tool Providers**
|
|
97
|
+
- `@mastra/editor/composio` — Composio tool provider with toolkit/tool discovery and execution via `@composio/core` and `@composio/mastra` SDKs
|
|
98
|
+
- `@mastra/editor/arcade` — Arcade AI tool provider with a pre-seeded catalog of 93 toolkits, tool discovery, and execution via `@arcadeai/arcadejs` SDK
|
|
99
|
+
|
|
100
|
+
Each provider is a separate entry point — importing `@mastra/editor` alone does not load any provider SDK code.
|
|
101
|
+
|
|
102
|
+
### Patch Changes
|
|
103
|
+
|
|
104
|
+
- Updated dependencies [[`7ef618f`](https://github.com/mastra-ai/mastra/commit/7ef618f3c49c27e2f6b27d7f564c557c0734325b), [`b373564`](https://github.com/mastra-ai/mastra/commit/b37356491d43b4d53067f10cb669abaf2502f218), [`927c2af`](https://github.com/mastra-ai/mastra/commit/927c2af9792286c122e04409efce0f3c804f777f), [`b896b41`](https://github.com/mastra-ai/mastra/commit/b896b41343de7fcc14442fb40fe82d189e65bbe2), [`6415277`](https://github.com/mastra-ai/mastra/commit/6415277a438faa00db2af850ead5dee25f40c428), [`191bc3a`](https://github.com/mastra-ai/mastra/commit/191bc3adfdbe4b262dbc93b7d9c3d6c6a3c8ef92), [`0831bbb`](https://github.com/mastra-ai/mastra/commit/0831bbb5bc750c18e9b22b45f18687c964b70828), [`74fb394`](https://github.com/mastra-ai/mastra/commit/74fb3944f51f55e1fc1ca65eede4254d8fe72aa3), [`63f7eda`](https://github.com/mastra-ai/mastra/commit/63f7eda605eb3e0c8c35ee3912ffe7c999c69f69), [`a5b67a3`](https://github.com/mastra-ai/mastra/commit/a5b67a3589a74415feb663a55d1858324a2afde9), [`877b02c`](https://github.com/mastra-ai/mastra/commit/877b02cdbb15e199184c7f2b8f217be8d3ebada7), [`cb8c38e`](https://github.com/mastra-ai/mastra/commit/cb8c38e6f855ad190383a7112ba95abef072d490), [`7567222`](https://github.com/mastra-ai/mastra/commit/7567222b1366f0d39980594792dd9d5060bfe2ab), [`af71458`](https://github.com/mastra-ai/mastra/commit/af71458e3b566f09c11d0e5a0a836dc818e7a24a), [`eb36bd8`](https://github.com/mastra-ai/mastra/commit/eb36bd8c52fcd6ec9674ac3b7a6412405b5983e1), [`3cbf121`](https://github.com/mastra-ai/mastra/commit/3cbf121f55418141924754a83102aade89835947)]:
|
|
105
|
+
- @mastra/core@1.4.0-alpha.0
|
|
106
|
+
- @mastra/memory@1.3.0-alpha.0
|
|
107
|
+
|
|
3
108
|
## 0.3.0
|
|
4
109
|
|
|
5
110
|
### Minor Changes
|
package/dist/arcade.cjs
ADDED
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/arcade.ts
|
|
21
|
+
var arcade_exports = {};
|
|
22
|
+
__export(arcade_exports, {
|
|
23
|
+
ArcadeToolProvider: () => ArcadeToolProvider
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(arcade_exports);
|
|
26
|
+
|
|
27
|
+
// src/providers/arcade.ts
|
|
28
|
+
var import_arcadejs = require("@arcadeai/arcadejs");
|
|
29
|
+
var import_lib = require("@arcadeai/arcadejs/lib/index");
|
|
30
|
+
var KNOWN_TOOLKITS = [
|
|
31
|
+
{ slug: "AirtableApi", name: "Airtable API", category: "productivity" },
|
|
32
|
+
{ slug: "ArcadeEngineApi", name: "Arcade Engine API", category: "development" },
|
|
33
|
+
{ slug: "Asana", name: "Asana", category: "productivity" },
|
|
34
|
+
{ slug: "AsanaApi", name: "Asana API", category: "productivity" },
|
|
35
|
+
{ slug: "AshbyApi", name: "Ashby API", category: "productivity" },
|
|
36
|
+
{ slug: "Attio", name: "Attio", category: "sales" },
|
|
37
|
+
{ slug: "BoxApi", name: "Box API", category: "productivity" },
|
|
38
|
+
{ slug: "Brightdata", name: "Bright Data", category: "development" },
|
|
39
|
+
{ slug: "CalendlyApi", name: "Calendly API", category: "productivity" },
|
|
40
|
+
{ slug: "Clickup", name: "ClickUp", category: "productivity" },
|
|
41
|
+
{ slug: "ClickupApi", name: "ClickUp API", category: "productivity" },
|
|
42
|
+
{ slug: "Confluence", name: "Confluence", category: "productivity" },
|
|
43
|
+
{ slug: "CursorAgentsApi", name: "Cursor Agents API", category: "development" },
|
|
44
|
+
{ slug: "CustomerioApi", name: "Customer.io API", category: "customer-support" },
|
|
45
|
+
{ slug: "CustomerioPipelinesApi", name: "Customer.io Pipelines API", category: "customer-support" },
|
|
46
|
+
{ slug: "CustomerioTrackApi", name: "Customer.io Track API", category: "customer-support" },
|
|
47
|
+
{ slug: "DatadogApi", name: "Datadog API", category: "development" },
|
|
48
|
+
{ slug: "Dropbox", name: "Dropbox", category: "productivity" },
|
|
49
|
+
{ slug: "E2b", name: "E2B", category: "development" },
|
|
50
|
+
{ slug: "ExaApi", name: "Exa API", category: "search" },
|
|
51
|
+
{ slug: "Figma", name: "Figma", category: "productivity" },
|
|
52
|
+
{ slug: "FigmaApi", name: "Figma API", category: "productivity" },
|
|
53
|
+
{ slug: "Firecrawl", name: "Firecrawl", category: "development" },
|
|
54
|
+
{ slug: "FreshserviceApi", name: "Freshservice API", category: "customer-support" },
|
|
55
|
+
{ slug: "Github", name: "GitHub", category: "development" },
|
|
56
|
+
{ slug: "GithubApi", name: "GitHub API", category: "development" },
|
|
57
|
+
{ slug: "Gmail", name: "Gmail", category: "productivity" },
|
|
58
|
+
{ slug: "Google", name: "Google", category: "search" },
|
|
59
|
+
{ slug: "GoogleCalendar", name: "Google Calendar", category: "productivity" },
|
|
60
|
+
{ slug: "GoogleContacts", name: "Google Contacts", category: "productivity" },
|
|
61
|
+
{ slug: "GoogleDocs", name: "Google Docs", category: "productivity" },
|
|
62
|
+
{ slug: "GoogleDrive", name: "Google Drive", category: "productivity" },
|
|
63
|
+
{ slug: "GoogleFinance", name: "Google Finance", category: "search" },
|
|
64
|
+
{ slug: "GoogleFlights", name: "Google Flights", category: "search" },
|
|
65
|
+
{ slug: "GoogleHotels", name: "Google Hotels", category: "search" },
|
|
66
|
+
{ slug: "GoogleJobs", name: "Google Jobs", category: "search" },
|
|
67
|
+
{ slug: "GoogleMaps", name: "Google Maps", category: "search" },
|
|
68
|
+
{ slug: "GoogleNews", name: "Google News", category: "search" },
|
|
69
|
+
{ slug: "GoogleSearch", name: "Google Search", category: "search" },
|
|
70
|
+
{ slug: "GoogleSheets", name: "Google Sheets", category: "productivity" },
|
|
71
|
+
{ slug: "GoogleShopping", name: "Google Shopping", category: "search" },
|
|
72
|
+
{ slug: "GoogleSlides", name: "Google Slides", category: "productivity" },
|
|
73
|
+
{ slug: "Hubspot", name: "HubSpot", category: "sales" },
|
|
74
|
+
{ slug: "HubspotAutomationApi", name: "HubSpot Automation API", category: "sales" },
|
|
75
|
+
{ slug: "HubspotCmsApi", name: "HubSpot CMS API", category: "sales" },
|
|
76
|
+
{ slug: "HubspotConversationsApi", name: "HubSpot Conversations API", category: "sales" },
|
|
77
|
+
{ slug: "HubspotCrmApi", name: "HubSpot CRM API", category: "sales" },
|
|
78
|
+
{ slug: "HubspotEventsApi", name: "HubSpot Events API", category: "sales" },
|
|
79
|
+
{ slug: "HubspotMarketingApi", name: "HubSpot Marketing API", category: "sales" },
|
|
80
|
+
{ slug: "HubspotMeetingsApi", name: "HubSpot Meetings API", category: "sales" },
|
|
81
|
+
{ slug: "HubspotUsersApi", name: "HubSpot Users API", category: "sales" },
|
|
82
|
+
{ slug: "Imgflip", name: "Imgflip", category: "entertainment" },
|
|
83
|
+
{ slug: "IntercomApi", name: "Intercom API", category: "customer-support" },
|
|
84
|
+
{ slug: "Jira", name: "Jira", category: "productivity" },
|
|
85
|
+
{ slug: "Linear", name: "Linear", category: "productivity" },
|
|
86
|
+
{ slug: "Linkedin", name: "LinkedIn", category: "social" },
|
|
87
|
+
{ slug: "LumaApi", name: "Luma API", category: "productivity" },
|
|
88
|
+
{ slug: "MailchimpMarketingApi", name: "Mailchimp API", category: "productivity" },
|
|
89
|
+
{ slug: "Math", name: "Math", category: "utility" },
|
|
90
|
+
{ slug: "Microsoft", name: "Microsoft", category: "productivity" },
|
|
91
|
+
{ slug: "MicrosoftOnedrive", name: "Microsoft OneDrive", category: "productivity" },
|
|
92
|
+
{ slug: "MicrosoftTeams", name: "Microsoft Teams", category: "social" },
|
|
93
|
+
{ slug: "MicrosoftWord", name: "Microsoft Word", category: "productivity" },
|
|
94
|
+
{ slug: "MiroApi", name: "Miro API", category: "productivity" },
|
|
95
|
+
{ slug: "NotionToolkit", name: "Notion", category: "productivity" },
|
|
96
|
+
{ slug: "OutlookCalendar", name: "Outlook Calendar", category: "productivity" },
|
|
97
|
+
{ slug: "OutlookMail", name: "Outlook Mail", category: "productivity" },
|
|
98
|
+
{ slug: "Pagerduty", name: "PagerDuty", category: "development" },
|
|
99
|
+
{ slug: "PagerdutyApi", name: "PagerDuty API", category: "development" },
|
|
100
|
+
{ slug: "PosthogApi", name: "PostHog API", category: "development" },
|
|
101
|
+
{ slug: "Pylon", name: "Pylon", category: "customer-support" },
|
|
102
|
+
{ slug: "PylonApi", name: "Pylon API", category: "customer-support" },
|
|
103
|
+
{ slug: "Reddit", name: "Reddit", category: "social" },
|
|
104
|
+
{ slug: "Salesforce", name: "Salesforce", category: "sales" },
|
|
105
|
+
{ slug: "Sharepoint", name: "Microsoft SharePoint", category: "productivity" },
|
|
106
|
+
{ slug: "Slack", name: "Slack", category: "social" },
|
|
107
|
+
{ slug: "SlackApi", name: "Slack API", category: "social" },
|
|
108
|
+
{ slug: "Spotify", name: "Spotify", category: "entertainment" },
|
|
109
|
+
{ slug: "SquareupApi", name: "SquareUp API", category: "productivity" },
|
|
110
|
+
{ slug: "Stripe", name: "Stripe", category: "payments" },
|
|
111
|
+
{ slug: "StripeApi", name: "Stripe API", category: "payments" },
|
|
112
|
+
{ slug: "TicktickApi", name: "TickTick API", category: "productivity" },
|
|
113
|
+
{ slug: "TrelloApi", name: "Trello API", category: "productivity" },
|
|
114
|
+
{ slug: "Twilio", name: "Twilio", category: "social" },
|
|
115
|
+
{ slug: "VercelApi", name: "Vercel API", category: "development" },
|
|
116
|
+
{ slug: "Walmart", name: "Walmart", category: "search" },
|
|
117
|
+
{ slug: "WeaviateApi", name: "Weaviate API", category: "development" },
|
|
118
|
+
{ slug: "X", name: "X", category: "social" },
|
|
119
|
+
{ slug: "XeroApi", name: "Xero API", category: "productivity" },
|
|
120
|
+
{ slug: "Youtube", name: "Youtube", category: "search" },
|
|
121
|
+
{ slug: "Zendesk", name: "Zendesk", category: "customer-support" },
|
|
122
|
+
{ slug: "ZohoBooksApi", name: "Zoho Books API", category: "payments" },
|
|
123
|
+
{ slug: "Zoom", name: "Zoom", category: "social" }
|
|
124
|
+
];
|
|
125
|
+
var ArcadeToolProvider = class {
|
|
126
|
+
constructor(config) {
|
|
127
|
+
this.info = {
|
|
128
|
+
id: "arcade",
|
|
129
|
+
name: "Arcade AI",
|
|
130
|
+
description: "Access 7,000+ tools from 130+ app integrations via Arcade AI"
|
|
131
|
+
};
|
|
132
|
+
this.client = null;
|
|
133
|
+
this.config = config;
|
|
134
|
+
this.toolkitCache = /* @__PURE__ */ new Map();
|
|
135
|
+
for (const tk of KNOWN_TOOLKITS) {
|
|
136
|
+
this.toolkitCache.set(tk.slug, {
|
|
137
|
+
slug: tk.slug,
|
|
138
|
+
name: tk.name,
|
|
139
|
+
description: tk.description ?? `Arcade AI ${tk.name} tools`,
|
|
140
|
+
icon: tk.category
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Get or create an Arcade client.
|
|
146
|
+
*/
|
|
147
|
+
getClient() {
|
|
148
|
+
if (!this.client) {
|
|
149
|
+
this.client = new import_arcadejs.Arcade({
|
|
150
|
+
apiKey: this.config.apiKey,
|
|
151
|
+
...this.config.baseURL ? { baseURL: this.config.baseURL } : {}
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
return this.client;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Absorb toolkit metadata from a tool listing into the cache.
|
|
158
|
+
* Returns true if any new toolkit was discovered.
|
|
159
|
+
*/
|
|
160
|
+
absorbToolkits(items) {
|
|
161
|
+
let discovered = false;
|
|
162
|
+
for (const tool of items) {
|
|
163
|
+
const tk = tool.toolkit;
|
|
164
|
+
if (tk?.name && !this.toolkitCache.has(tk.name)) {
|
|
165
|
+
this.toolkitCache.set(tk.name, {
|
|
166
|
+
slug: tk.name,
|
|
167
|
+
name: tk.name,
|
|
168
|
+
description: tk.description ?? `Arcade AI ${tk.name} tools`
|
|
169
|
+
});
|
|
170
|
+
discovered = true;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return discovered;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* List toolkits.
|
|
177
|
+
*
|
|
178
|
+
* Returns the pre-seeded catalog merged with any toolkits discovered at
|
|
179
|
+
* runtime via `listTools()` or `resolveTools()` calls.
|
|
180
|
+
*/
|
|
181
|
+
async listToolkits() {
|
|
182
|
+
const data = [...this.toolkitCache.values()].sort((a, b) => a.name.localeCompare(b.name));
|
|
183
|
+
return { data };
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* List available tools with optional toolkit and pagination filters.
|
|
187
|
+
* Uses `tools.list({ toolkit, limit, offset })`.
|
|
188
|
+
*/
|
|
189
|
+
async listTools(options) {
|
|
190
|
+
const client = this.getClient();
|
|
191
|
+
const limit = options?.perPage ?? 50;
|
|
192
|
+
const page = options?.page ?? 1;
|
|
193
|
+
const offset = (page - 1) * limit;
|
|
194
|
+
const query = { limit, offset };
|
|
195
|
+
if (options?.toolkit) query.toolkit = options.toolkit;
|
|
196
|
+
const result = await client.tools.list(query);
|
|
197
|
+
const items = result.items ?? [];
|
|
198
|
+
this.absorbToolkits(items);
|
|
199
|
+
let filtered = items;
|
|
200
|
+
if (options?.search) {
|
|
201
|
+
const searchLower = options.search.toLowerCase();
|
|
202
|
+
filtered = items.filter(
|
|
203
|
+
(t) => t.name?.toLowerCase().includes(searchLower) || t.description?.toLowerCase().includes(searchLower) || t.qualified_name?.toLowerCase().includes(searchLower)
|
|
204
|
+
);
|
|
205
|
+
}
|
|
206
|
+
const data = filtered.map((tool) => ({
|
|
207
|
+
slug: tool.qualified_name ?? `${tool.toolkit?.name}.${tool.name}`,
|
|
208
|
+
name: tool.name,
|
|
209
|
+
description: tool.description,
|
|
210
|
+
toolkit: tool.toolkit?.name
|
|
211
|
+
}));
|
|
212
|
+
return {
|
|
213
|
+
data,
|
|
214
|
+
pagination: {
|
|
215
|
+
page,
|
|
216
|
+
perPage: limit,
|
|
217
|
+
total: result.total_count,
|
|
218
|
+
hasMore: offset + items.length < (result.total_count ?? 0)
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Get the JSON schema for a specific tool by its qualified name (e.g., `Github.GetRepository`).
|
|
224
|
+
*/
|
|
225
|
+
async getToolSchema(toolSlug) {
|
|
226
|
+
try {
|
|
227
|
+
const client = this.getClient();
|
|
228
|
+
const tool = await client.tools.get(toolSlug);
|
|
229
|
+
if (!tool) return null;
|
|
230
|
+
const properties = {};
|
|
231
|
+
const required = [];
|
|
232
|
+
for (const param of tool.input?.parameters ?? []) {
|
|
233
|
+
properties[param.name] = {
|
|
234
|
+
...param.value_schema ?? {},
|
|
235
|
+
description: param.description
|
|
236
|
+
};
|
|
237
|
+
if (param.required) required.push(param.name);
|
|
238
|
+
}
|
|
239
|
+
return {
|
|
240
|
+
type: "object",
|
|
241
|
+
properties,
|
|
242
|
+
...required.length > 0 ? { required } : {}
|
|
243
|
+
};
|
|
244
|
+
} catch {
|
|
245
|
+
return null;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Resolve executable tools in Mastra's ToolAction format.
|
|
250
|
+
*
|
|
251
|
+
* Uses `toZodToolSet` from `@arcadeai/arcadejs/lib` to create ZodTool objects
|
|
252
|
+
* with Zod schemas and execute functions, then wraps them as ToolAction objects.
|
|
253
|
+
*/
|
|
254
|
+
async resolveTools(toolSlugs, toolConfigs, options) {
|
|
255
|
+
if (toolSlugs.length === 0) return {};
|
|
256
|
+
const client = this.getClient();
|
|
257
|
+
const userId = options?.userId ?? "default";
|
|
258
|
+
const toolDefs = await Promise.all(toolSlugs.map((slug) => client.tools.get(slug).catch(() => null)));
|
|
259
|
+
const validDefs = toolDefs.filter((d) => d !== null);
|
|
260
|
+
if (validDefs.length === 0) return {};
|
|
261
|
+
this.absorbToolkits(validDefs);
|
|
262
|
+
const zodToolSet = (0, import_lib.toZodToolSet)({
|
|
263
|
+
tools: validDefs,
|
|
264
|
+
client,
|
|
265
|
+
userId,
|
|
266
|
+
executeFactory: import_lib.executeOrAuthorizeZodTool
|
|
267
|
+
});
|
|
268
|
+
const result = {};
|
|
269
|
+
const normalizedToQualified = /* @__PURE__ */ new Map();
|
|
270
|
+
for (const d of validDefs) {
|
|
271
|
+
const qn = d.qualified_name ?? `${d.toolkit?.name}.${d.name}`;
|
|
272
|
+
normalizedToQualified.set(qn.replace(/\./g, "_"), qn);
|
|
273
|
+
}
|
|
274
|
+
for (const [key, zodTool] of Object.entries(zodToolSet)) {
|
|
275
|
+
const qualifiedName = normalizedToQualified.get(key) ?? key;
|
|
276
|
+
const descOverride = toolConfigs?.[qualifiedName]?.description ?? toolConfigs?.[key]?.description;
|
|
277
|
+
result[qualifiedName] = {
|
|
278
|
+
id: qualifiedName,
|
|
279
|
+
description: descOverride ?? zodTool.description ?? "",
|
|
280
|
+
inputSchema: zodTool.parameters,
|
|
281
|
+
outputSchema: zodTool.output,
|
|
282
|
+
execute: async (input) => {
|
|
283
|
+
return zodTool.execute(input);
|
|
284
|
+
}
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
return result;
|
|
288
|
+
}
|
|
289
|
+
};
|
|
290
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
291
|
+
0 && (module.exports = {
|
|
292
|
+
ArcadeToolProvider
|
|
293
|
+
});
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { ToolProvider, ToolProviderInfo, ToolProviderListResult, ToolProviderToolkit, ListToolProviderToolsOptions, ToolProviderToolInfo, ResolveToolProviderToolsOptions } from '@mastra/core/tool-provider';
|
|
2
|
+
import { ToolAction } from '@mastra/core/tools';
|
|
3
|
+
import { StorageToolConfig } from '@mastra/core/storage';
|
|
4
|
+
|
|
5
|
+
interface ArcadeToolProviderConfig {
|
|
6
|
+
/** Arcade AI API key */
|
|
7
|
+
apiKey: string;
|
|
8
|
+
/** Base URL for the Arcade API (defaults to https://api.arcade.dev) */
|
|
9
|
+
baseURL?: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Arcade AI tool provider adapter.
|
|
13
|
+
*
|
|
14
|
+
* Uses `@arcadeai/arcadejs` SDK for discovery and runtime tool resolution.
|
|
15
|
+
* The SDK is a static import and tree-shaken if this provider class isn't used.
|
|
16
|
+
*
|
|
17
|
+
* Arcade tools use `Toolkit.ToolName` naming (e.g., `Github.GetRepository`).
|
|
18
|
+
* Each toolkit groups related tools and manages its own auth requirements.
|
|
19
|
+
*
|
|
20
|
+
* Discovery methods (`listToolkits`, `listTools`, `getToolSchema`) use the
|
|
21
|
+
* standard `tools.list()` / `tools.get()` SDK methods.
|
|
22
|
+
*
|
|
23
|
+
* Runtime method (`resolveTools`) uses `toZodToolSet` from `@arcadeai/arcadejs/lib`
|
|
24
|
+
* to get executable ZodTool objects, then converts them to Mastra's ToolAction format.
|
|
25
|
+
*/
|
|
26
|
+
declare class ArcadeToolProvider implements ToolProvider {
|
|
27
|
+
readonly info: ToolProviderInfo;
|
|
28
|
+
private config;
|
|
29
|
+
private toolkitCache;
|
|
30
|
+
private client;
|
|
31
|
+
constructor(config: ArcadeToolProviderConfig);
|
|
32
|
+
/**
|
|
33
|
+
* Get or create an Arcade client.
|
|
34
|
+
*/
|
|
35
|
+
private getClient;
|
|
36
|
+
/**
|
|
37
|
+
* Absorb toolkit metadata from a tool listing into the cache.
|
|
38
|
+
* Returns true if any new toolkit was discovered.
|
|
39
|
+
*/
|
|
40
|
+
private absorbToolkits;
|
|
41
|
+
/**
|
|
42
|
+
* List toolkits.
|
|
43
|
+
*
|
|
44
|
+
* Returns the pre-seeded catalog merged with any toolkits discovered at
|
|
45
|
+
* runtime via `listTools()` or `resolveTools()` calls.
|
|
46
|
+
*/
|
|
47
|
+
listToolkits(): Promise<ToolProviderListResult<ToolProviderToolkit>>;
|
|
48
|
+
/**
|
|
49
|
+
* List available tools with optional toolkit and pagination filters.
|
|
50
|
+
* Uses `tools.list({ toolkit, limit, offset })`.
|
|
51
|
+
*/
|
|
52
|
+
listTools(options?: ListToolProviderToolsOptions): Promise<ToolProviderListResult<ToolProviderToolInfo>>;
|
|
53
|
+
/**
|
|
54
|
+
* Get the JSON schema for a specific tool by its qualified name (e.g., `Github.GetRepository`).
|
|
55
|
+
*/
|
|
56
|
+
getToolSchema(toolSlug: string): Promise<Record<string, unknown> | null>;
|
|
57
|
+
/**
|
|
58
|
+
* Resolve executable tools in Mastra's ToolAction format.
|
|
59
|
+
*
|
|
60
|
+
* Uses `toZodToolSet` from `@arcadeai/arcadejs/lib` to create ZodTool objects
|
|
61
|
+
* with Zod schemas and execute functions, then wraps them as ToolAction objects.
|
|
62
|
+
*/
|
|
63
|
+
resolveTools(toolSlugs: string[], toolConfigs?: Record<string, StorageToolConfig>, options?: ResolveToolProviderToolsOptions): Promise<Record<string, ToolAction<unknown, unknown>>>;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export { ArcadeToolProvider, type ArcadeToolProviderConfig };
|
package/dist/arcade.d.ts
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { ToolProvider, ToolProviderInfo, ToolProviderListResult, ToolProviderToolkit, ListToolProviderToolsOptions, ToolProviderToolInfo, ResolveToolProviderToolsOptions } from '@mastra/core/tool-provider';
|
|
2
|
+
import { ToolAction } from '@mastra/core/tools';
|
|
3
|
+
import { StorageToolConfig } from '@mastra/core/storage';
|
|
4
|
+
|
|
5
|
+
interface ArcadeToolProviderConfig {
|
|
6
|
+
/** Arcade AI API key */
|
|
7
|
+
apiKey: string;
|
|
8
|
+
/** Base URL for the Arcade API (defaults to https://api.arcade.dev) */
|
|
9
|
+
baseURL?: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Arcade AI tool provider adapter.
|
|
13
|
+
*
|
|
14
|
+
* Uses `@arcadeai/arcadejs` SDK for discovery and runtime tool resolution.
|
|
15
|
+
* The SDK is a static import and tree-shaken if this provider class isn't used.
|
|
16
|
+
*
|
|
17
|
+
* Arcade tools use `Toolkit.ToolName` naming (e.g., `Github.GetRepository`).
|
|
18
|
+
* Each toolkit groups related tools and manages its own auth requirements.
|
|
19
|
+
*
|
|
20
|
+
* Discovery methods (`listToolkits`, `listTools`, `getToolSchema`) use the
|
|
21
|
+
* standard `tools.list()` / `tools.get()` SDK methods.
|
|
22
|
+
*
|
|
23
|
+
* Runtime method (`resolveTools`) uses `toZodToolSet` from `@arcadeai/arcadejs/lib`
|
|
24
|
+
* to get executable ZodTool objects, then converts them to Mastra's ToolAction format.
|
|
25
|
+
*/
|
|
26
|
+
declare class ArcadeToolProvider implements ToolProvider {
|
|
27
|
+
readonly info: ToolProviderInfo;
|
|
28
|
+
private config;
|
|
29
|
+
private toolkitCache;
|
|
30
|
+
private client;
|
|
31
|
+
constructor(config: ArcadeToolProviderConfig);
|
|
32
|
+
/**
|
|
33
|
+
* Get or create an Arcade client.
|
|
34
|
+
*/
|
|
35
|
+
private getClient;
|
|
36
|
+
/**
|
|
37
|
+
* Absorb toolkit metadata from a tool listing into the cache.
|
|
38
|
+
* Returns true if any new toolkit was discovered.
|
|
39
|
+
*/
|
|
40
|
+
private absorbToolkits;
|
|
41
|
+
/**
|
|
42
|
+
* List toolkits.
|
|
43
|
+
*
|
|
44
|
+
* Returns the pre-seeded catalog merged with any toolkits discovered at
|
|
45
|
+
* runtime via `listTools()` or `resolveTools()` calls.
|
|
46
|
+
*/
|
|
47
|
+
listToolkits(): Promise<ToolProviderListResult<ToolProviderToolkit>>;
|
|
48
|
+
/**
|
|
49
|
+
* List available tools with optional toolkit and pagination filters.
|
|
50
|
+
* Uses `tools.list({ toolkit, limit, offset })`.
|
|
51
|
+
*/
|
|
52
|
+
listTools(options?: ListToolProviderToolsOptions): Promise<ToolProviderListResult<ToolProviderToolInfo>>;
|
|
53
|
+
/**
|
|
54
|
+
* Get the JSON schema for a specific tool by its qualified name (e.g., `Github.GetRepository`).
|
|
55
|
+
*/
|
|
56
|
+
getToolSchema(toolSlug: string): Promise<Record<string, unknown> | null>;
|
|
57
|
+
/**
|
|
58
|
+
* Resolve executable tools in Mastra's ToolAction format.
|
|
59
|
+
*
|
|
60
|
+
* Uses `toZodToolSet` from `@arcadeai/arcadejs/lib` to create ZodTool objects
|
|
61
|
+
* with Zod schemas and execute functions, then wraps them as ToolAction objects.
|
|
62
|
+
*/
|
|
63
|
+
resolveTools(toolSlugs: string[], toolConfigs?: Record<string, StorageToolConfig>, options?: ResolveToolProviderToolsOptions): Promise<Record<string, ToolAction<unknown, unknown>>>;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export { ArcadeToolProvider, type ArcadeToolProviderConfig };
|