@mastra/editor 0.13.8 → 0.13.9

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/dist/arcade.js CHANGED
@@ -1,269 +1,648 @@
1
- // src/providers/arcade.ts
2
1
  import { MASTRA_RESOURCE_ID_KEY } from "@mastra/core/request-context";
3
2
  import { Arcade } from "@arcadeai/arcadejs";
4
- import { toZodToolSet, executeOrAuthorizeZodTool } from "@arcadeai/arcadejs/lib/index";
5
- var KNOWN_TOOLKITS = [
6
- { slug: "AirtableApi", name: "Airtable API", category: "productivity" },
7
- { slug: "ArcadeEngineApi", name: "Arcade Engine API", category: "development" },
8
- { slug: "Asana", name: "Asana", category: "productivity" },
9
- { slug: "AsanaApi", name: "Asana API", category: "productivity" },
10
- { slug: "AshbyApi", name: "Ashby API", category: "productivity" },
11
- { slug: "Attio", name: "Attio", category: "sales" },
12
- { slug: "BoxApi", name: "Box API", category: "productivity" },
13
- { slug: "Brightdata", name: "Bright Data", category: "development" },
14
- { slug: "CalendlyApi", name: "Calendly API", category: "productivity" },
15
- { slug: "Clickup", name: "ClickUp", category: "productivity" },
16
- { slug: "ClickupApi", name: "ClickUp API", category: "productivity" },
17
- { slug: "Confluence", name: "Confluence", category: "productivity" },
18
- { slug: "CursorAgentsApi", name: "Cursor Agents API", category: "development" },
19
- { slug: "CustomerioApi", name: "Customer.io API", category: "customer-support" },
20
- { slug: "CustomerioPipelinesApi", name: "Customer.io Pipelines API", category: "customer-support" },
21
- { slug: "CustomerioTrackApi", name: "Customer.io Track API", category: "customer-support" },
22
- { slug: "DatadogApi", name: "Datadog API", category: "development" },
23
- { slug: "Dropbox", name: "Dropbox", category: "productivity" },
24
- { slug: "E2b", name: "E2B", category: "development" },
25
- { slug: "ExaApi", name: "Exa API", category: "search" },
26
- { slug: "Figma", name: "Figma", category: "productivity" },
27
- { slug: "FigmaApi", name: "Figma API", category: "productivity" },
28
- { slug: "Firecrawl", name: "Firecrawl", category: "development" },
29
- { slug: "FreshserviceApi", name: "Freshservice API", category: "customer-support" },
30
- { slug: "Github", name: "GitHub", category: "development" },
31
- { slug: "GithubApi", name: "GitHub API", category: "development" },
32
- { slug: "Gmail", name: "Gmail", category: "productivity" },
33
- { slug: "Google", name: "Google", category: "search" },
34
- { slug: "GoogleCalendar", name: "Google Calendar", category: "productivity" },
35
- { slug: "GoogleContacts", name: "Google Contacts", category: "productivity" },
36
- { slug: "GoogleDocs", name: "Google Docs", category: "productivity" },
37
- { slug: "GoogleDrive", name: "Google Drive", category: "productivity" },
38
- { slug: "GoogleFinance", name: "Google Finance", category: "search" },
39
- { slug: "GoogleFlights", name: "Google Flights", category: "search" },
40
- { slug: "GoogleHotels", name: "Google Hotels", category: "search" },
41
- { slug: "GoogleJobs", name: "Google Jobs", category: "search" },
42
- { slug: "GoogleMaps", name: "Google Maps", category: "search" },
43
- { slug: "GoogleNews", name: "Google News", category: "search" },
44
- { slug: "GoogleSearch", name: "Google Search", category: "search" },
45
- { slug: "GoogleSheets", name: "Google Sheets", category: "productivity" },
46
- { slug: "GoogleShopping", name: "Google Shopping", category: "search" },
47
- { slug: "GoogleSlides", name: "Google Slides", category: "productivity" },
48
- { slug: "Hubspot", name: "HubSpot", category: "sales" },
49
- { slug: "HubspotAutomationApi", name: "HubSpot Automation API", category: "sales" },
50
- { slug: "HubspotCmsApi", name: "HubSpot CMS API", category: "sales" },
51
- { slug: "HubspotConversationsApi", name: "HubSpot Conversations API", category: "sales" },
52
- { slug: "HubspotCrmApi", name: "HubSpot CRM API", category: "sales" },
53
- { slug: "HubspotEventsApi", name: "HubSpot Events API", category: "sales" },
54
- { slug: "HubspotMarketingApi", name: "HubSpot Marketing API", category: "sales" },
55
- { slug: "HubspotMeetingsApi", name: "HubSpot Meetings API", category: "sales" },
56
- { slug: "HubspotUsersApi", name: "HubSpot Users API", category: "sales" },
57
- { slug: "Imgflip", name: "Imgflip", category: "entertainment" },
58
- { slug: "IntercomApi", name: "Intercom API", category: "customer-support" },
59
- { slug: "Jira", name: "Jira", category: "productivity" },
60
- { slug: "Linear", name: "Linear", category: "productivity" },
61
- { slug: "Linkedin", name: "LinkedIn", category: "social" },
62
- { slug: "LumaApi", name: "Luma API", category: "productivity" },
63
- { slug: "MailchimpMarketingApi", name: "Mailchimp API", category: "productivity" },
64
- { slug: "Math", name: "Math", category: "utility" },
65
- { slug: "Microsoft", name: "Microsoft", category: "productivity" },
66
- { slug: "MicrosoftOnedrive", name: "Microsoft OneDrive", category: "productivity" },
67
- { slug: "MicrosoftTeams", name: "Microsoft Teams", category: "social" },
68
- { slug: "MicrosoftWord", name: "Microsoft Word", category: "productivity" },
69
- { slug: "MiroApi", name: "Miro API", category: "productivity" },
70
- { slug: "NotionToolkit", name: "Notion", category: "productivity" },
71
- { slug: "OutlookCalendar", name: "Outlook Calendar", category: "productivity" },
72
- { slug: "OutlookMail", name: "Outlook Mail", category: "productivity" },
73
- { slug: "Pagerduty", name: "PagerDuty", category: "development" },
74
- { slug: "PagerdutyApi", name: "PagerDuty API", category: "development" },
75
- { slug: "PosthogApi", name: "PostHog API", category: "development" },
76
- { slug: "Pylon", name: "Pylon", category: "customer-support" },
77
- { slug: "PylonApi", name: "Pylon API", category: "customer-support" },
78
- { slug: "Reddit", name: "Reddit", category: "social" },
79
- { slug: "Salesforce", name: "Salesforce", category: "sales" },
80
- { slug: "Sharepoint", name: "Microsoft SharePoint", category: "productivity" },
81
- { slug: "Slack", name: "Slack", category: "social" },
82
- { slug: "SlackApi", name: "Slack API", category: "social" },
83
- { slug: "Spotify", name: "Spotify", category: "entertainment" },
84
- { slug: "SquareupApi", name: "SquareUp API", category: "productivity" },
85
- { slug: "Stripe", name: "Stripe", category: "payments" },
86
- { slug: "StripeApi", name: "Stripe API", category: "payments" },
87
- { slug: "TicktickApi", name: "TickTick API", category: "productivity" },
88
- { slug: "TrelloApi", name: "Trello API", category: "productivity" },
89
- { slug: "Twilio", name: "Twilio", category: "social" },
90
- { slug: "VercelApi", name: "Vercel API", category: "development" },
91
- { slug: "Walmart", name: "Walmart", category: "search" },
92
- { slug: "WeaviateApi", name: "Weaviate API", category: "development" },
93
- { slug: "X", name: "X", category: "social" },
94
- { slug: "XeroApi", name: "Xero API", category: "productivity" },
95
- { slug: "Youtube", name: "Youtube", category: "search" },
96
- { slug: "Zendesk", name: "Zendesk", category: "customer-support" },
97
- { slug: "ZohoBooksApi", name: "Zoho Books API", category: "payments" },
98
- { slug: "Zoom", name: "Zoom", category: "social" }
3
+ import { executeOrAuthorizeZodTool, toZodToolSet } from "@arcadeai/arcadejs/lib/index";
4
+ //#region src/providers/arcade.ts
5
+ const KNOWN_TOOLKITS = [
6
+ {
7
+ slug: "AirtableApi",
8
+ name: "Airtable API",
9
+ category: "productivity"
10
+ },
11
+ {
12
+ slug: "ArcadeEngineApi",
13
+ name: "Arcade Engine API",
14
+ category: "development"
15
+ },
16
+ {
17
+ slug: "Asana",
18
+ name: "Asana",
19
+ category: "productivity"
20
+ },
21
+ {
22
+ slug: "AsanaApi",
23
+ name: "Asana API",
24
+ category: "productivity"
25
+ },
26
+ {
27
+ slug: "AshbyApi",
28
+ name: "Ashby API",
29
+ category: "productivity"
30
+ },
31
+ {
32
+ slug: "Attio",
33
+ name: "Attio",
34
+ category: "sales"
35
+ },
36
+ {
37
+ slug: "BoxApi",
38
+ name: "Box API",
39
+ category: "productivity"
40
+ },
41
+ {
42
+ slug: "Brightdata",
43
+ name: "Bright Data",
44
+ category: "development"
45
+ },
46
+ {
47
+ slug: "CalendlyApi",
48
+ name: "Calendly API",
49
+ category: "productivity"
50
+ },
51
+ {
52
+ slug: "Clickup",
53
+ name: "ClickUp",
54
+ category: "productivity"
55
+ },
56
+ {
57
+ slug: "ClickupApi",
58
+ name: "ClickUp API",
59
+ category: "productivity"
60
+ },
61
+ {
62
+ slug: "Confluence",
63
+ name: "Confluence",
64
+ category: "productivity"
65
+ },
66
+ {
67
+ slug: "CursorAgentsApi",
68
+ name: "Cursor Agents API",
69
+ category: "development"
70
+ },
71
+ {
72
+ slug: "CustomerioApi",
73
+ name: "Customer.io API",
74
+ category: "customer-support"
75
+ },
76
+ {
77
+ slug: "CustomerioPipelinesApi",
78
+ name: "Customer.io Pipelines API",
79
+ category: "customer-support"
80
+ },
81
+ {
82
+ slug: "CustomerioTrackApi",
83
+ name: "Customer.io Track API",
84
+ category: "customer-support"
85
+ },
86
+ {
87
+ slug: "DatadogApi",
88
+ name: "Datadog API",
89
+ category: "development"
90
+ },
91
+ {
92
+ slug: "Dropbox",
93
+ name: "Dropbox",
94
+ category: "productivity"
95
+ },
96
+ {
97
+ slug: "E2b",
98
+ name: "E2B",
99
+ category: "development"
100
+ },
101
+ {
102
+ slug: "ExaApi",
103
+ name: "Exa API",
104
+ category: "search"
105
+ },
106
+ {
107
+ slug: "Figma",
108
+ name: "Figma",
109
+ category: "productivity"
110
+ },
111
+ {
112
+ slug: "FigmaApi",
113
+ name: "Figma API",
114
+ category: "productivity"
115
+ },
116
+ {
117
+ slug: "Firecrawl",
118
+ name: "Firecrawl",
119
+ category: "development"
120
+ },
121
+ {
122
+ slug: "FreshserviceApi",
123
+ name: "Freshservice API",
124
+ category: "customer-support"
125
+ },
126
+ {
127
+ slug: "Github",
128
+ name: "GitHub",
129
+ category: "development"
130
+ },
131
+ {
132
+ slug: "GithubApi",
133
+ name: "GitHub API",
134
+ category: "development"
135
+ },
136
+ {
137
+ slug: "Gmail",
138
+ name: "Gmail",
139
+ category: "productivity"
140
+ },
141
+ {
142
+ slug: "Google",
143
+ name: "Google",
144
+ category: "search"
145
+ },
146
+ {
147
+ slug: "GoogleCalendar",
148
+ name: "Google Calendar",
149
+ category: "productivity"
150
+ },
151
+ {
152
+ slug: "GoogleContacts",
153
+ name: "Google Contacts",
154
+ category: "productivity"
155
+ },
156
+ {
157
+ slug: "GoogleDocs",
158
+ name: "Google Docs",
159
+ category: "productivity"
160
+ },
161
+ {
162
+ slug: "GoogleDrive",
163
+ name: "Google Drive",
164
+ category: "productivity"
165
+ },
166
+ {
167
+ slug: "GoogleFinance",
168
+ name: "Google Finance",
169
+ category: "search"
170
+ },
171
+ {
172
+ slug: "GoogleFlights",
173
+ name: "Google Flights",
174
+ category: "search"
175
+ },
176
+ {
177
+ slug: "GoogleHotels",
178
+ name: "Google Hotels",
179
+ category: "search"
180
+ },
181
+ {
182
+ slug: "GoogleJobs",
183
+ name: "Google Jobs",
184
+ category: "search"
185
+ },
186
+ {
187
+ slug: "GoogleMaps",
188
+ name: "Google Maps",
189
+ category: "search"
190
+ },
191
+ {
192
+ slug: "GoogleNews",
193
+ name: "Google News",
194
+ category: "search"
195
+ },
196
+ {
197
+ slug: "GoogleSearch",
198
+ name: "Google Search",
199
+ category: "search"
200
+ },
201
+ {
202
+ slug: "GoogleSheets",
203
+ name: "Google Sheets",
204
+ category: "productivity"
205
+ },
206
+ {
207
+ slug: "GoogleShopping",
208
+ name: "Google Shopping",
209
+ category: "search"
210
+ },
211
+ {
212
+ slug: "GoogleSlides",
213
+ name: "Google Slides",
214
+ category: "productivity"
215
+ },
216
+ {
217
+ slug: "Hubspot",
218
+ name: "HubSpot",
219
+ category: "sales"
220
+ },
221
+ {
222
+ slug: "HubspotAutomationApi",
223
+ name: "HubSpot Automation API",
224
+ category: "sales"
225
+ },
226
+ {
227
+ slug: "HubspotCmsApi",
228
+ name: "HubSpot CMS API",
229
+ category: "sales"
230
+ },
231
+ {
232
+ slug: "HubspotConversationsApi",
233
+ name: "HubSpot Conversations API",
234
+ category: "sales"
235
+ },
236
+ {
237
+ slug: "HubspotCrmApi",
238
+ name: "HubSpot CRM API",
239
+ category: "sales"
240
+ },
241
+ {
242
+ slug: "HubspotEventsApi",
243
+ name: "HubSpot Events API",
244
+ category: "sales"
245
+ },
246
+ {
247
+ slug: "HubspotMarketingApi",
248
+ name: "HubSpot Marketing API",
249
+ category: "sales"
250
+ },
251
+ {
252
+ slug: "HubspotMeetingsApi",
253
+ name: "HubSpot Meetings API",
254
+ category: "sales"
255
+ },
256
+ {
257
+ slug: "HubspotUsersApi",
258
+ name: "HubSpot Users API",
259
+ category: "sales"
260
+ },
261
+ {
262
+ slug: "Imgflip",
263
+ name: "Imgflip",
264
+ category: "entertainment"
265
+ },
266
+ {
267
+ slug: "IntercomApi",
268
+ name: "Intercom API",
269
+ category: "customer-support"
270
+ },
271
+ {
272
+ slug: "Jira",
273
+ name: "Jira",
274
+ category: "productivity"
275
+ },
276
+ {
277
+ slug: "Linear",
278
+ name: "Linear",
279
+ category: "productivity"
280
+ },
281
+ {
282
+ slug: "Linkedin",
283
+ name: "LinkedIn",
284
+ category: "social"
285
+ },
286
+ {
287
+ slug: "LumaApi",
288
+ name: "Luma API",
289
+ category: "productivity"
290
+ },
291
+ {
292
+ slug: "MailchimpMarketingApi",
293
+ name: "Mailchimp API",
294
+ category: "productivity"
295
+ },
296
+ {
297
+ slug: "Math",
298
+ name: "Math",
299
+ category: "utility"
300
+ },
301
+ {
302
+ slug: "Microsoft",
303
+ name: "Microsoft",
304
+ category: "productivity"
305
+ },
306
+ {
307
+ slug: "MicrosoftOnedrive",
308
+ name: "Microsoft OneDrive",
309
+ category: "productivity"
310
+ },
311
+ {
312
+ slug: "MicrosoftTeams",
313
+ name: "Microsoft Teams",
314
+ category: "social"
315
+ },
316
+ {
317
+ slug: "MicrosoftWord",
318
+ name: "Microsoft Word",
319
+ category: "productivity"
320
+ },
321
+ {
322
+ slug: "MiroApi",
323
+ name: "Miro API",
324
+ category: "productivity"
325
+ },
326
+ {
327
+ slug: "NotionToolkit",
328
+ name: "Notion",
329
+ category: "productivity"
330
+ },
331
+ {
332
+ slug: "OutlookCalendar",
333
+ name: "Outlook Calendar",
334
+ category: "productivity"
335
+ },
336
+ {
337
+ slug: "OutlookMail",
338
+ name: "Outlook Mail",
339
+ category: "productivity"
340
+ },
341
+ {
342
+ slug: "Pagerduty",
343
+ name: "PagerDuty",
344
+ category: "development"
345
+ },
346
+ {
347
+ slug: "PagerdutyApi",
348
+ name: "PagerDuty API",
349
+ category: "development"
350
+ },
351
+ {
352
+ slug: "PosthogApi",
353
+ name: "PostHog API",
354
+ category: "development"
355
+ },
356
+ {
357
+ slug: "Pylon",
358
+ name: "Pylon",
359
+ category: "customer-support"
360
+ },
361
+ {
362
+ slug: "PylonApi",
363
+ name: "Pylon API",
364
+ category: "customer-support"
365
+ },
366
+ {
367
+ slug: "Reddit",
368
+ name: "Reddit",
369
+ category: "social"
370
+ },
371
+ {
372
+ slug: "Salesforce",
373
+ name: "Salesforce",
374
+ category: "sales"
375
+ },
376
+ {
377
+ slug: "Sharepoint",
378
+ name: "Microsoft SharePoint",
379
+ category: "productivity"
380
+ },
381
+ {
382
+ slug: "Slack",
383
+ name: "Slack",
384
+ category: "social"
385
+ },
386
+ {
387
+ slug: "SlackApi",
388
+ name: "Slack API",
389
+ category: "social"
390
+ },
391
+ {
392
+ slug: "Spotify",
393
+ name: "Spotify",
394
+ category: "entertainment"
395
+ },
396
+ {
397
+ slug: "SquareupApi",
398
+ name: "SquareUp API",
399
+ category: "productivity"
400
+ },
401
+ {
402
+ slug: "Stripe",
403
+ name: "Stripe",
404
+ category: "payments"
405
+ },
406
+ {
407
+ slug: "StripeApi",
408
+ name: "Stripe API",
409
+ category: "payments"
410
+ },
411
+ {
412
+ slug: "TicktickApi",
413
+ name: "TickTick API",
414
+ category: "productivity"
415
+ },
416
+ {
417
+ slug: "TrelloApi",
418
+ name: "Trello API",
419
+ category: "productivity"
420
+ },
421
+ {
422
+ slug: "Twilio",
423
+ name: "Twilio",
424
+ category: "social"
425
+ },
426
+ {
427
+ slug: "VercelApi",
428
+ name: "Vercel API",
429
+ category: "development"
430
+ },
431
+ {
432
+ slug: "Walmart",
433
+ name: "Walmart",
434
+ category: "search"
435
+ },
436
+ {
437
+ slug: "WeaviateApi",
438
+ name: "Weaviate API",
439
+ category: "development"
440
+ },
441
+ {
442
+ slug: "X",
443
+ name: "X",
444
+ category: "social"
445
+ },
446
+ {
447
+ slug: "XeroApi",
448
+ name: "Xero API",
449
+ category: "productivity"
450
+ },
451
+ {
452
+ slug: "Youtube",
453
+ name: "Youtube",
454
+ category: "search"
455
+ },
456
+ {
457
+ slug: "Zendesk",
458
+ name: "Zendesk",
459
+ category: "customer-support"
460
+ },
461
+ {
462
+ slug: "ZohoBooksApi",
463
+ name: "Zoho Books API",
464
+ category: "payments"
465
+ },
466
+ {
467
+ slug: "Zoom",
468
+ name: "Zoom",
469
+ category: "social"
470
+ }
99
471
  ];
472
+ /**
473
+ * Arcade AI tool provider adapter.
474
+ *
475
+ * Uses `@arcadeai/arcadejs` SDK for discovery and runtime tool resolution.
476
+ * The SDK is a static import and tree-shaken if this provider class isn't used.
477
+ *
478
+ * Arcade tools use `Toolkit.ToolName` naming (e.g., `Github.GetRepository`).
479
+ * Each toolkit groups related tools and manages its own auth requirements.
480
+ *
481
+ * Discovery methods (`listToolkits`, `listTools`, `getToolSchema`) use the
482
+ * standard `tools.list()` / `tools.get()` SDK methods.
483
+ *
484
+ * Runtime method (`resolveTools`) uses `toZodToolSet` from `@arcadeai/arcadejs/lib`
485
+ * to get executable ZodTool objects, then converts them to Mastra's ToolAction format.
486
+ */
100
487
  var ArcadeToolProvider = class {
101
- constructor(config) {
102
- this.info = {
103
- id: "arcade",
104
- name: "Arcade AI",
105
- description: "Access 7,000+ tools from 130+ app integrations via Arcade AI"
106
- };
107
- this.client = null;
108
- this.config = config;
109
- this.toolkitCache = /* @__PURE__ */ new Map();
110
- for (const tk of KNOWN_TOOLKITS) {
111
- this.toolkitCache.set(tk.slug, {
112
- slug: tk.slug,
113
- name: tk.name,
114
- description: tk.description ?? `Arcade AI ${tk.name} tools`,
115
- icon: tk.category
116
- });
117
- }
118
- }
119
- /**
120
- * Get or create an Arcade client.
121
- */
122
- getClient() {
123
- if (!this.client) {
124
- this.client = new Arcade({
125
- apiKey: this.config.apiKey,
126
- ...this.config.baseURL ? { baseURL: this.config.baseURL } : {}
127
- });
128
- }
129
- return this.client;
130
- }
131
- /**
132
- * Absorb toolkit metadata from a tool listing into the cache.
133
- * Returns true if any new toolkit was discovered.
134
- */
135
- absorbToolkits(items) {
136
- let discovered = false;
137
- for (const tool of items) {
138
- const tk = tool.toolkit;
139
- if (tk?.name && !this.toolkitCache.has(tk.name)) {
140
- this.toolkitCache.set(tk.name, {
141
- slug: tk.name,
142
- name: tk.name,
143
- description: tk.description ?? `Arcade AI ${tk.name} tools`
144
- });
145
- discovered = true;
146
- }
147
- }
148
- return discovered;
149
- }
150
- /**
151
- * List toolkits.
152
- *
153
- * Returns the pre-seeded catalog merged with any toolkits discovered at
154
- * runtime via `listTools()` or `resolveTools()` calls.
155
- */
156
- async listToolkits() {
157
- const data = [...this.toolkitCache.values()].sort((a, b) => a.name.localeCompare(b.name));
158
- return { data };
159
- }
160
- /**
161
- * List available tools with optional toolkit and pagination filters.
162
- * Uses `tools.list({ toolkit, limit, offset })`.
163
- */
164
- async listTools(options) {
165
- const client = this.getClient();
166
- const limit = options?.perPage ?? 50;
167
- const page = options?.page ?? 1;
168
- const offset = (page - 1) * limit;
169
- const query = { limit, offset };
170
- if (options?.toolkit) query.toolkit = options.toolkit;
171
- const result = await client.tools.list(query);
172
- const items = result.items ?? [];
173
- this.absorbToolkits(items);
174
- let filtered = items;
175
- if (options?.search) {
176
- const searchLower = options.search.toLowerCase();
177
- filtered = items.filter(
178
- (t) => t.name?.toLowerCase().includes(searchLower) || t.description?.toLowerCase().includes(searchLower) || t.qualified_name?.toLowerCase().includes(searchLower)
179
- );
180
- }
181
- const data = filtered.map((tool) => ({
182
- slug: tool.qualified_name ?? `${tool.toolkit?.name}.${tool.name}`,
183
- name: tool.name,
184
- description: tool.description,
185
- toolkit: tool.toolkit?.name
186
- }));
187
- return {
188
- data,
189
- pagination: {
190
- page,
191
- perPage: limit,
192
- total: result.total_count,
193
- hasMore: offset + items.length < (result.total_count ?? 0)
194
- }
195
- };
196
- }
197
- /**
198
- * Get the JSON schema for a specific tool by its qualified name (e.g., `Github.GetRepository`).
199
- */
200
- async getToolSchema(toolSlug) {
201
- try {
202
- const client = this.getClient();
203
- const tool = await client.tools.get(toolSlug);
204
- if (!tool) return null;
205
- const properties = {};
206
- const required = [];
207
- for (const param of tool.input?.parameters ?? []) {
208
- properties[param.name] = {
209
- ...param.value_schema ?? {},
210
- description: param.description
211
- };
212
- if (param.required) required.push(param.name);
213
- }
214
- return {
215
- type: "object",
216
- properties,
217
- ...required.length > 0 ? { required } : {}
218
- };
219
- } catch {
220
- return null;
221
- }
222
- }
223
- /**
224
- * Resolve executable tools in Mastra's ToolAction format.
225
- *
226
- * Uses `toZodToolSet` from `@arcadeai/arcadejs/lib` to create ZodTool objects
227
- * with Zod schemas and execute functions, then wraps them as ToolAction objects.
228
- */
229
- async resolveTools(toolSlugs, toolConfigs, options) {
230
- if (toolSlugs.length === 0) return {};
231
- const client = this.getClient();
232
- const resourceId = options?.requestContext?.[MASTRA_RESOURCE_ID_KEY];
233
- const userId = typeof resourceId === "string" ? resourceId : options?.userId ?? "default";
234
- const toolDefs = await Promise.all(toolSlugs.map((slug) => client.tools.get(slug).catch(() => null)));
235
- const validDefs = toolDefs.filter((d) => d !== null);
236
- if (validDefs.length === 0) return {};
237
- this.absorbToolkits(validDefs);
238
- const zodToolSet = toZodToolSet({
239
- tools: validDefs,
240
- client,
241
- userId,
242
- executeFactory: executeOrAuthorizeZodTool
243
- });
244
- const result = {};
245
- const normalizedToQualified = /* @__PURE__ */ new Map();
246
- for (const d of validDefs) {
247
- const qn = d.qualified_name ?? `${d.toolkit?.name}.${d.name}`;
248
- normalizedToQualified.set(qn.replace(/\./g, "_"), qn);
249
- }
250
- for (const [key, zodTool] of Object.entries(zodToolSet)) {
251
- const qualifiedName = normalizedToQualified.get(key) ?? key;
252
- const descOverride = toolConfigs?.[qualifiedName]?.description ?? toolConfigs?.[key]?.description;
253
- result[qualifiedName] = {
254
- id: qualifiedName,
255
- description: descOverride ?? zodTool.description ?? "",
256
- inputSchema: zodTool.parameters,
257
- outputSchema: zodTool.output,
258
- execute: async (input) => {
259
- return zodTool.execute(input);
260
- }
261
- };
262
- }
263
- return result;
264
- }
265
- };
266
- export {
267
- ArcadeToolProvider
488
+ constructor(config) {
489
+ this.info = {
490
+ id: "arcade",
491
+ name: "Arcade AI",
492
+ description: "Access 7,000+ tools from 130+ app integrations via Arcade AI"
493
+ };
494
+ this.client = null;
495
+ this.config = config;
496
+ this.toolkitCache = /* @__PURE__ */ new Map();
497
+ for (const tk of KNOWN_TOOLKITS) this.toolkitCache.set(tk.slug, {
498
+ slug: tk.slug,
499
+ name: tk.name,
500
+ description: tk.description ?? `Arcade AI ${tk.name} tools`,
501
+ icon: tk.category
502
+ });
503
+ }
504
+ /**
505
+ * Get or create an Arcade client.
506
+ */
507
+ getClient() {
508
+ if (!this.client) this.client = new Arcade({
509
+ apiKey: this.config.apiKey,
510
+ ...this.config.baseURL ? { baseURL: this.config.baseURL } : {}
511
+ });
512
+ return this.client;
513
+ }
514
+ /**
515
+ * Absorb toolkit metadata from a tool listing into the cache.
516
+ * Returns true if any new toolkit was discovered.
517
+ */
518
+ absorbToolkits(items) {
519
+ let discovered = false;
520
+ for (const tool of items) {
521
+ const tk = tool.toolkit;
522
+ if (tk?.name && !this.toolkitCache.has(tk.name)) {
523
+ this.toolkitCache.set(tk.name, {
524
+ slug: tk.name,
525
+ name: tk.name,
526
+ description: tk.description ?? `Arcade AI ${tk.name} tools`
527
+ });
528
+ discovered = true;
529
+ }
530
+ }
531
+ return discovered;
532
+ }
533
+ /**
534
+ * List toolkits.
535
+ *
536
+ * Returns the pre-seeded catalog merged with any toolkits discovered at
537
+ * runtime via `listTools()` or `resolveTools()` calls.
538
+ */
539
+ async listToolkits() {
540
+ return { data: [...this.toolkitCache.values()].sort((a, b) => a.name.localeCompare(b.name)) };
541
+ }
542
+ /**
543
+ * List available tools with optional toolkit and pagination filters.
544
+ * Uses `tools.list({ toolkit, limit, offset })`.
545
+ */
546
+ async listTools(options) {
547
+ const client = this.getClient();
548
+ const limit = options?.perPage ?? 50;
549
+ const page = options?.page ?? 1;
550
+ const offset = (page - 1) * limit;
551
+ const query = {
552
+ limit,
553
+ offset
554
+ };
555
+ if (options?.toolkit) query.toolkit = options.toolkit;
556
+ const result = await client.tools.list(query);
557
+ const items = result.items ?? [];
558
+ this.absorbToolkits(items);
559
+ let filtered = items;
560
+ if (options?.search) {
561
+ const searchLower = options.search.toLowerCase();
562
+ filtered = items.filter((t) => t.name?.toLowerCase().includes(searchLower) || t.description?.toLowerCase().includes(searchLower) || t.qualified_name?.toLowerCase().includes(searchLower));
563
+ }
564
+ return {
565
+ data: filtered.map((tool) => ({
566
+ slug: tool.qualified_name ?? `${tool.toolkit?.name}.${tool.name}`,
567
+ name: tool.name,
568
+ description: tool.description,
569
+ toolkit: tool.toolkit?.name
570
+ })),
571
+ pagination: {
572
+ page,
573
+ perPage: limit,
574
+ total: result.total_count,
575
+ hasMore: offset + items.length < (result.total_count ?? 0)
576
+ }
577
+ };
578
+ }
579
+ /**
580
+ * Get the JSON schema for a specific tool by its qualified name (e.g., `Github.GetRepository`).
581
+ */
582
+ async getToolSchema(toolSlug) {
583
+ try {
584
+ const tool = await this.getClient().tools.get(toolSlug);
585
+ if (!tool) return null;
586
+ const properties = {};
587
+ const required = [];
588
+ for (const param of tool.input?.parameters ?? []) {
589
+ properties[param.name] = {
590
+ ...param.value_schema ?? {},
591
+ description: param.description
592
+ };
593
+ if (param.required) required.push(param.name);
594
+ }
595
+ return {
596
+ type: "object",
597
+ properties,
598
+ ...required.length > 0 ? { required } : {}
599
+ };
600
+ } catch {
601
+ return null;
602
+ }
603
+ }
604
+ /**
605
+ * Resolve executable tools in Mastra's ToolAction format.
606
+ *
607
+ * Uses `toZodToolSet` from `@arcadeai/arcadejs/lib` to create ZodTool objects
608
+ * with Zod schemas and execute functions, then wraps them as ToolAction objects.
609
+ */
610
+ async resolveTools(toolSlugs, toolConfigs, options) {
611
+ if (toolSlugs.length === 0) return {};
612
+ const client = this.getClient();
613
+ const resourceId = options?.requestContext?.[MASTRA_RESOURCE_ID_KEY];
614
+ const userId = typeof resourceId === "string" ? resourceId : options?.userId ?? "default";
615
+ const validDefs = (await Promise.all(toolSlugs.map((slug) => client.tools.get(slug).catch(() => null)))).filter((d) => d !== null);
616
+ if (validDefs.length === 0) return {};
617
+ this.absorbToolkits(validDefs);
618
+ const zodToolSet = toZodToolSet({
619
+ tools: validDefs,
620
+ client,
621
+ userId,
622
+ executeFactory: executeOrAuthorizeZodTool
623
+ });
624
+ const result = {};
625
+ const normalizedToQualified = /* @__PURE__ */ new Map();
626
+ for (const d of validDefs) {
627
+ const qn = d.qualified_name ?? `${d.toolkit?.name}.${d.name}`;
628
+ normalizedToQualified.set(qn.replace(/\./g, "_"), qn);
629
+ }
630
+ for (const [key, zodTool] of Object.entries(zodToolSet)) {
631
+ const qualifiedName = normalizedToQualified.get(key) ?? key;
632
+ result[qualifiedName] = {
633
+ id: qualifiedName,
634
+ description: toolConfigs?.[qualifiedName]?.description ?? toolConfigs?.[key]?.description ?? zodTool.description ?? "",
635
+ inputSchema: zodTool.parameters,
636
+ outputSchema: zodTool.output,
637
+ execute: async (input) => {
638
+ return zodTool.execute(input);
639
+ }
640
+ };
641
+ }
642
+ return result;
643
+ }
268
644
  };
645
+ //#endregion
646
+ export { ArcadeToolProvider };
647
+
269
648
  //# sourceMappingURL=arcade.js.map