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