@mastra/editor 0.9.1-alpha.1 → 0.10.0-alpha.2

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 CHANGED
@@ -1,5 +1,48 @@
1
1
  # @mastra/editor
2
2
 
3
+ ## 0.10.0-alpha.2
4
+
5
+ ### Minor Changes
6
+
7
+ - Ship `EditorAgentBuilder` and Agent Builder runtime through the `@mastra/editor/ee` subpath. ([#16948](https://github.com/mastra-ai/mastra/pull/16948))
8
+ - Adds `EditorAgentBuilder` class and supporting types under `@mastra/editor/ee` (dormant unless `MastraEditorConfig.builder` is configured).
9
+ - Wires builder resolution on `MastraEditor`: `hasEnabledBuilderConfig()`, `resolveBuilder()`, `ensureBuilderWorkspaces()`, and `reconcileBuilderWorkspaces()`.
10
+ - Adds builder defaults plumbing in the agent namespace (`applyBuilderDefaults`, `BUILDER_BASELINE_DEFAULTS` enabling `observationalMemory: true` by default for Builder-created agents).
11
+ - Adds a defense-in-depth license guard inside `MastraEditor.resolveBuilder()` that mirrors the server-startup check in `MastraServer.validateAgentBuilderLicense()`. Dev environments bypass via `isEEEnabled()`; production without a valid `MASTRA_EE_LICENSE` throws `[mastra/auth-ee] Agent Builder is configured but no valid EE license was found.`
12
+ - Bumps the `@mastra/core` peer dependency to `>=1.34.0-0 <2.0.0-0` to cover the `@mastra/core/agent-builder/ee` and `@mastra/core/auth/ee` subpaths consumed by the builder runtime.
13
+
14
+ Opt-in usage:
15
+
16
+ ```ts
17
+ import { Mastra } from '@mastra/core';
18
+ import { MastraEditor } from '@mastra/editor';
19
+
20
+ const editor = new MastraEditor({
21
+ builder: {
22
+ enabled: true,
23
+ configuration: {
24
+ agent: {
25
+ models: { default: { provider: 'openai', modelId: 'gpt-4o-mini' } },
26
+ },
27
+ },
28
+ },
29
+ });
30
+
31
+ new Mastra({ storage, editor });
32
+
33
+ // Later, on demand:
34
+ const builder = await editor.resolveBuilder();
35
+ // `builder` is undefined when the builder is not configured/enabled.
36
+ // In production it requires a valid MASTRA_EE_LICENSE; dev environments bypass.
37
+ ```
38
+
39
+ This is plumbing — no UI consumer ships in this release.
40
+
41
+ ### Patch Changes
42
+
43
+ - Updated dependencies [[`b7286f4`](https://github.com/mastra-ai/mastra/commit/b7286f4308267f5fd70e6bfee10dba9472640906), [`a481027`](https://github.com/mastra-ai/mastra/commit/a481027b549ba1018414990c8f045eaee7b9f413), [`801baa0`](https://github.com/mastra-ai/mastra/commit/801baa07cccdbaec1d00942a92bdc831111744a2), [`b3c3b18`](https://github.com/mastra-ai/mastra/commit/b3c3b189121489a3a51a8fd8204b569be9a89fe5)]:
44
+ - @mastra/core@1.37.0-alpha.4
45
+
3
46
  ## 0.9.1-alpha.1
4
47
 
5
48
  ### Patch Changes
package/dist/arcade.cjs CHANGED
@@ -293,3 +293,4 @@ var ArcadeToolProvider = class {
293
293
  0 && (module.exports = {
294
294
  ArcadeToolProvider
295
295
  });
296
+ //# sourceMappingURL=arcade.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/arcade.ts","../src/providers/arcade.ts"],"sourcesContent":["export { ArcadeToolProvider } from './providers/arcade';\nexport type { ArcadeToolProviderConfig } from './providers/arcade';\n","import type {\n ToolProvider,\n ToolProviderInfo,\n ToolProviderToolkit,\n ToolProviderToolInfo,\n ToolProviderListResult,\n ListToolProviderToolsOptions,\n ResolveToolProviderToolsOptions,\n} from '@mastra/core/tool-provider';\nimport type { ToolAction } from '@mastra/core/tools';\nimport type { StorageToolConfig } from '@mastra/core/storage';\nimport { MASTRA_RESOURCE_ID_KEY } from '@mastra/core/request-context';\n\nimport { Arcade } from '@arcadeai/arcadejs';\nimport type {\n ToolDefinition,\n ExecuteToolResponse,\n ToolListParams as ArcadeToolListParams,\n} from '@arcadeai/arcadejs/resources';\nimport { toZodToolSet, executeOrAuthorizeZodTool } from '@arcadeai/arcadejs/lib/index';\nimport type { ZodTool, ToolAuthorizationResponse } from '@arcadeai/arcadejs/lib/index';\n\nexport interface ArcadeToolProviderConfig {\n /** Arcade AI API key */\n apiKey: string;\n /** Base URL for the Arcade API (defaults to https://api.arcade.dev) */\n baseURL?: string;\n}\n\n/*\n * Pre-seeded catalog of known Arcade toolkits, sourced from the Arcade\n * integrations page and verified against the API. This avoids the need to\n * paginate through 7 000+ tools just to list toolkit names.\n *\n * The cache is updated at runtime when `listTools()` or `resolveTools()` encounters\n * a toolkit that isn't already present, so newly-added Arcade integrations are\n * picked up automatically.\n */\nconst KNOWN_TOOLKITS: readonly { slug: string; name: string; description?: string; category?: string }[] = [\n { slug: 'AirtableApi', name: 'Airtable API', category: 'productivity' },\n { slug: 'ArcadeEngineApi', name: 'Arcade Engine API', category: 'development' },\n { slug: 'Asana', name: 'Asana', category: 'productivity' },\n { slug: 'AsanaApi', name: 'Asana API', category: 'productivity' },\n { slug: 'AshbyApi', name: 'Ashby API', category: 'productivity' },\n { slug: 'Attio', name: 'Attio', category: 'sales' },\n { slug: 'BoxApi', name: 'Box API', category: 'productivity' },\n { slug: 'Brightdata', name: 'Bright Data', category: 'development' },\n { slug: 'CalendlyApi', name: 'Calendly API', category: 'productivity' },\n { slug: 'Clickup', name: 'ClickUp', category: 'productivity' },\n { slug: 'ClickupApi', name: 'ClickUp API', category: 'productivity' },\n { slug: 'Confluence', name: 'Confluence', category: 'productivity' },\n { slug: 'CursorAgentsApi', name: 'Cursor Agents API', category: 'development' },\n { slug: 'CustomerioApi', name: 'Customer.io API', category: 'customer-support' },\n { slug: 'CustomerioPipelinesApi', name: 'Customer.io Pipelines API', category: 'customer-support' },\n { slug: 'CustomerioTrackApi', name: 'Customer.io Track API', category: 'customer-support' },\n { slug: 'DatadogApi', name: 'Datadog API', category: 'development' },\n { slug: 'Dropbox', name: 'Dropbox', category: 'productivity' },\n { slug: 'E2b', name: 'E2B', category: 'development' },\n { slug: 'ExaApi', name: 'Exa API', category: 'search' },\n { slug: 'Figma', name: 'Figma', category: 'productivity' },\n { slug: 'FigmaApi', name: 'Figma API', category: 'productivity' },\n { slug: 'Firecrawl', name: 'Firecrawl', category: 'development' },\n { slug: 'FreshserviceApi', name: 'Freshservice API', category: 'customer-support' },\n { slug: 'Github', name: 'GitHub', category: 'development' },\n { slug: 'GithubApi', name: 'GitHub API', category: 'development' },\n { slug: 'Gmail', name: 'Gmail', category: 'productivity' },\n { slug: 'Google', name: 'Google', category: 'search' },\n { slug: 'GoogleCalendar', name: 'Google Calendar', category: 'productivity' },\n { slug: 'GoogleContacts', name: 'Google Contacts', category: 'productivity' },\n { slug: 'GoogleDocs', name: 'Google Docs', category: 'productivity' },\n { slug: 'GoogleDrive', name: 'Google Drive', category: 'productivity' },\n { slug: 'GoogleFinance', name: 'Google Finance', category: 'search' },\n { slug: 'GoogleFlights', name: 'Google Flights', category: 'search' },\n { slug: 'GoogleHotels', name: 'Google Hotels', category: 'search' },\n { slug: 'GoogleJobs', name: 'Google Jobs', category: 'search' },\n { slug: 'GoogleMaps', name: 'Google Maps', category: 'search' },\n { slug: 'GoogleNews', name: 'Google News', category: 'search' },\n { slug: 'GoogleSearch', name: 'Google Search', category: 'search' },\n { slug: 'GoogleSheets', name: 'Google Sheets', category: 'productivity' },\n { slug: 'GoogleShopping', name: 'Google Shopping', category: 'search' },\n { slug: 'GoogleSlides', name: 'Google Slides', category: 'productivity' },\n { slug: 'Hubspot', name: 'HubSpot', category: 'sales' },\n { slug: 'HubspotAutomationApi', name: 'HubSpot Automation API', category: 'sales' },\n { slug: 'HubspotCmsApi', name: 'HubSpot CMS API', category: 'sales' },\n { slug: 'HubspotConversationsApi', name: 'HubSpot Conversations API', category: 'sales' },\n { slug: 'HubspotCrmApi', name: 'HubSpot CRM API', category: 'sales' },\n { slug: 'HubspotEventsApi', name: 'HubSpot Events API', category: 'sales' },\n { slug: 'HubspotMarketingApi', name: 'HubSpot Marketing API', category: 'sales' },\n { slug: 'HubspotMeetingsApi', name: 'HubSpot Meetings API', category: 'sales' },\n { slug: 'HubspotUsersApi', name: 'HubSpot Users API', category: 'sales' },\n { slug: 'Imgflip', name: 'Imgflip', category: 'entertainment' },\n { slug: 'IntercomApi', name: 'Intercom API', category: 'customer-support' },\n { slug: 'Jira', name: 'Jira', category: 'productivity' },\n { slug: 'Linear', name: 'Linear', category: 'productivity' },\n { slug: 'Linkedin', name: 'LinkedIn', category: 'social' },\n { slug: 'LumaApi', name: 'Luma API', category: 'productivity' },\n { slug: 'MailchimpMarketingApi', name: 'Mailchimp API', category: 'productivity' },\n { slug: 'Math', name: 'Math', category: 'utility' },\n { slug: 'Microsoft', name: 'Microsoft', category: 'productivity' },\n { slug: 'MicrosoftOnedrive', name: 'Microsoft OneDrive', category: 'productivity' },\n { slug: 'MicrosoftTeams', name: 'Microsoft Teams', category: 'social' },\n { slug: 'MicrosoftWord', name: 'Microsoft Word', category: 'productivity' },\n { slug: 'MiroApi', name: 'Miro API', category: 'productivity' },\n { slug: 'NotionToolkit', name: 'Notion', category: 'productivity' },\n { slug: 'OutlookCalendar', name: 'Outlook Calendar', category: 'productivity' },\n { slug: 'OutlookMail', name: 'Outlook Mail', category: 'productivity' },\n { slug: 'Pagerduty', name: 'PagerDuty', category: 'development' },\n { slug: 'PagerdutyApi', name: 'PagerDuty API', category: 'development' },\n { slug: 'PosthogApi', name: 'PostHog API', category: 'development' },\n { slug: 'Pylon', name: 'Pylon', category: 'customer-support' },\n { slug: 'PylonApi', name: 'Pylon API', category: 'customer-support' },\n { slug: 'Reddit', name: 'Reddit', category: 'social' },\n { slug: 'Salesforce', name: 'Salesforce', category: 'sales' },\n { slug: 'Sharepoint', name: 'Microsoft SharePoint', category: 'productivity' },\n { slug: 'Slack', name: 'Slack', category: 'social' },\n { slug: 'SlackApi', name: 'Slack API', category: 'social' },\n { slug: 'Spotify', name: 'Spotify', category: 'entertainment' },\n { slug: 'SquareupApi', name: 'SquareUp API', category: 'productivity' },\n { slug: 'Stripe', name: 'Stripe', category: 'payments' },\n { slug: 'StripeApi', name: 'Stripe API', category: 'payments' },\n { slug: 'TicktickApi', name: 'TickTick API', category: 'productivity' },\n { slug: 'TrelloApi', name: 'Trello API', category: 'productivity' },\n { slug: 'Twilio', name: 'Twilio', category: 'social' },\n { slug: 'VercelApi', name: 'Vercel API', category: 'development' },\n { slug: 'Walmart', name: 'Walmart', category: 'search' },\n { slug: 'WeaviateApi', name: 'Weaviate API', category: 'development' },\n { slug: 'X', name: 'X', category: 'social' },\n { slug: 'XeroApi', name: 'Xero API', category: 'productivity' },\n { slug: 'Youtube', name: 'Youtube', category: 'search' },\n { slug: 'Zendesk', name: 'Zendesk', category: 'customer-support' },\n { slug: 'ZohoBooksApi', name: 'Zoho Books API', category: 'payments' },\n { slug: 'Zoom', name: 'Zoom', category: 'social' },\n] as const;\n\n/**\n * Arcade AI tool provider adapter.\n *\n * Uses `@arcadeai/arcadejs` SDK for discovery and runtime tool resolution.\n * The SDK is a static import and tree-shaken if this provider class isn't used.\n *\n * Arcade tools use `Toolkit.ToolName` naming (e.g., `Github.GetRepository`).\n * Each toolkit groups related tools and manages its own auth requirements.\n *\n * Discovery methods (`listToolkits`, `listTools`, `getToolSchema`) use the\n * standard `tools.list()` / `tools.get()` SDK methods.\n *\n * Runtime method (`resolveTools`) uses `toZodToolSet` from `@arcadeai/arcadejs/lib`\n * to get executable ZodTool objects, then converts them to Mastra's ToolAction format.\n */\nexport class ArcadeToolProvider implements ToolProvider {\n readonly info: ToolProviderInfo = {\n id: 'arcade',\n name: 'Arcade AI',\n description: 'Access 7,000+ tools from 130+ app integrations via Arcade AI',\n };\n\n private config: ArcadeToolProviderConfig;\n private toolkitCache: Map<string, ToolProviderToolkit>;\n private client: Arcade | null = null;\n\n constructor(config: ArcadeToolProviderConfig) {\n this.config = config;\n this.toolkitCache = new Map();\n for (const tk of KNOWN_TOOLKITS) {\n this.toolkitCache.set(tk.slug, {\n slug: tk.slug,\n name: tk.name,\n description: tk.description ?? `Arcade AI ${tk.name} tools`,\n icon: tk.category,\n });\n }\n }\n\n /**\n * Get or create an Arcade client.\n */\n private getClient(): Arcade {\n if (!this.client) {\n this.client = new Arcade({\n apiKey: this.config.apiKey,\n ...(this.config.baseURL ? { baseURL: this.config.baseURL } : {}),\n });\n }\n return this.client;\n }\n\n /**\n * Absorb toolkit metadata from a tool listing into the cache.\n * Returns true if any new toolkit was discovered.\n */\n private absorbToolkits(items: ToolDefinition[]): boolean {\n let discovered = false;\n for (const tool of items) {\n const tk = tool.toolkit;\n if (tk?.name && !this.toolkitCache.has(tk.name)) {\n this.toolkitCache.set(tk.name, {\n slug: tk.name,\n name: tk.name,\n description: tk.description ?? `Arcade AI ${tk.name} tools`,\n });\n discovered = true;\n }\n }\n return discovered;\n }\n\n /**\n * List toolkits.\n *\n * Returns the pre-seeded catalog merged with any toolkits discovered at\n * runtime via `listTools()` or `resolveTools()` calls.\n */\n async listToolkits(): Promise<ToolProviderListResult<ToolProviderToolkit>> {\n const data = [...this.toolkitCache.values()].sort((a, b) => a.name.localeCompare(b.name));\n return { data };\n }\n\n /**\n * List available tools with optional toolkit and pagination filters.\n * Uses `tools.list({ toolkit, limit, offset })`.\n */\n async listTools(options?: ListToolProviderToolsOptions): Promise<ToolProviderListResult<ToolProviderToolInfo>> {\n const client = this.getClient();\n\n const limit = options?.perPage ?? 50;\n const page = options?.page ?? 1;\n const offset = (page - 1) * limit;\n\n const query: ArcadeToolListParams = { limit, offset };\n if (options?.toolkit) query.toolkit = options.toolkit;\n\n const result = await client.tools.list(query);\n const items: ToolDefinition[] = result.items ?? [];\n\n // Update toolkit cache with any newly-discovered toolkits\n this.absorbToolkits(items);\n\n let filtered: ToolDefinition[] = items;\n if (options?.search) {\n const searchLower = options.search.toLowerCase();\n filtered = items.filter(\n t =>\n t.name?.toLowerCase().includes(searchLower) ||\n t.description?.toLowerCase().includes(searchLower) ||\n t.qualified_name?.toLowerCase().includes(searchLower),\n );\n }\n\n const data: ToolProviderToolInfo[] = filtered.map(tool => ({\n slug: tool.qualified_name ?? `${tool.toolkit?.name}.${tool.name}`,\n name: tool.name,\n description: tool.description,\n toolkit: tool.toolkit?.name,\n }));\n\n return {\n data,\n pagination: {\n page,\n perPage: limit,\n total: result.total_count,\n hasMore: offset + items.length < (result.total_count ?? 0),\n },\n };\n }\n\n /**\n * Get the JSON schema for a specific tool by its qualified name (e.g., `Github.GetRepository`).\n */\n async getToolSchema(toolSlug: string): Promise<Record<string, unknown> | null> {\n try {\n const client = this.getClient();\n const tool: ToolDefinition = await client.tools.get(toolSlug);\n if (!tool) return null;\n\n // Convert Arcade's parameter array to a JSON Schema-like object\n const properties: Record<string, Record<string, unknown>> = {};\n const required: string[] = [];\n\n for (const param of tool.input?.parameters ?? []) {\n properties[param.name] = {\n ...(param.value_schema ?? {}),\n description: param.description,\n };\n if (param.required) required.push(param.name);\n }\n\n return {\n type: 'object',\n properties,\n ...(required.length > 0 ? { required } : {}),\n };\n } catch {\n return null;\n }\n }\n\n /**\n * Resolve executable tools in Mastra's ToolAction format.\n *\n * Uses `toZodToolSet` from `@arcadeai/arcadejs/lib` to create ZodTool objects\n * with Zod schemas and execute functions, then wraps them as ToolAction objects.\n */\n async resolveTools(\n toolSlugs: string[],\n toolConfigs?: Record<string, StorageToolConfig>,\n options?: ResolveToolProviderToolsOptions,\n ): Promise<Record<string, ToolAction<unknown, unknown>>> {\n if (toolSlugs.length === 0) return {};\n\n const client = this.getClient();\n const resourceId = options?.requestContext?.[MASTRA_RESOURCE_ID_KEY];\n const userId = typeof resourceId === 'string' ? resourceId : (options?.userId ?? 'default');\n\n // Fetch tool definitions for the requested slugs\n const toolDefs = await Promise.all(toolSlugs.map(slug => client.tools.get(slug).catch(() => null)));\n const validDefs: ToolDefinition[] = toolDefs.filter((d): d is ToolDefinition => d !== null);\n\n if (validDefs.length === 0) return {};\n\n // Update toolkit cache with any newly-discovered toolkits\n this.absorbToolkits(validDefs);\n\n // Convert to executable ZodTool objects using Arcade's helper\n const zodToolSet: Record<string, ZodTool<ExecuteToolResponse | ToolAuthorizationResponse>> = toZodToolSet({\n tools: validDefs,\n client,\n userId,\n executeFactory: executeOrAuthorizeZodTool,\n });\n\n // Convert ZodTool objects to Mastra ToolAction format\n const result: Record<string, ToolAction<unknown, unknown>> = {};\n\n // Build a lookup from normalized name (Github_GetRepository) to qualified name (Github.GetRepository)\n const normalizedToQualified = new Map<string, string>();\n for (const d of validDefs) {\n const qn = d.qualified_name ?? `${d.toolkit?.name}.${d.name}`;\n normalizedToQualified.set(qn.replace(/\\./g, '_'), qn);\n }\n\n for (const [key, zodTool] of Object.entries(zodToolSet)) {\n const qualifiedName = normalizedToQualified.get(key) ?? key;\n const descOverride = toolConfigs?.[qualifiedName]?.description ?? toolConfigs?.[key]?.description;\n\n // Arcade SDK bundles a different Zod minor version than Mastra, so the\n // schema types are structurally identical at runtime but nominally\n // incompatible in TS. Cast through `unknown` to bridge the gap.\n result[qualifiedName] = {\n id: qualifiedName,\n description: descOverride ?? zodTool.description ?? '',\n inputSchema: zodTool.parameters as unknown as ToolAction<unknown, unknown>['inputSchema'],\n outputSchema: zodTool.output as unknown as ToolAction<unknown, unknown>['outputSchema'],\n execute: async (input: unknown) => {\n return zodTool.execute(input);\n },\n };\n }\n\n return result;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACWA,6BAAuC;AAEvC,sBAAuB;AAMvB,iBAAwD;AAmBxD,IAAM,iBAAqG;AAAA,EACzG,EAAE,MAAM,eAAe,MAAM,gBAAgB,UAAU,eAAe;AAAA,EACtE,EAAE,MAAM,mBAAmB,MAAM,qBAAqB,UAAU,cAAc;AAAA,EAC9E,EAAE,MAAM,SAAS,MAAM,SAAS,UAAU,eAAe;AAAA,EACzD,EAAE,MAAM,YAAY,MAAM,aAAa,UAAU,eAAe;AAAA,EAChE,EAAE,MAAM,YAAY,MAAM,aAAa,UAAU,eAAe;AAAA,EAChE,EAAE,MAAM,SAAS,MAAM,SAAS,UAAU,QAAQ;AAAA,EAClD,EAAE,MAAM,UAAU,MAAM,WAAW,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AAI,GAAG,QAAQ,OAAO,GAAG,GAAG,EAAE;AAAA,IACtD;AAEA,eAAW,CAAC,KAAK,OAAO,KAAK,OAAO,QAAQ,UAAU,GAAG;AACvD,YAAM,gBAAgB,sBAAsB,IAAI,GAAG,KAAK;AACxD,YAAM,eAAe,cAAc,aAAa,GAAG,eAAe,cAAc,GAAG,GAAG;AAKtF,aAAO,aAAa,IAAI;AAAA,QACtB,IAAI;AAAA,QACJ,aAAa,gBAAgB,QAAQ,eAAe;AAAA,QACpD,aAAa,QAAQ;AAAA,QACrB,cAAc,QAAQ;AAAA,QACtB,SAAS,OAAO,UAAmB;AACjC,iBAAO,QAAQ,QAAQ,KAAK;AAAA,QAC9B;AAAA,MACF;AAAA,IACF;AAEA,WAAO;AAAA,EACT;AACF;","names":[]}
package/dist/arcade.js CHANGED
@@ -266,3 +266,4 @@ var ArcadeToolProvider = class {
266
266
  export {
267
267
  ArcadeToolProvider
268
268
  };
269
+ //# sourceMappingURL=arcade.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/providers/arcade.ts"],"sourcesContent":["import type {\n ToolProvider,\n ToolProviderInfo,\n ToolProviderToolkit,\n ToolProviderToolInfo,\n ToolProviderListResult,\n ListToolProviderToolsOptions,\n ResolveToolProviderToolsOptions,\n} from '@mastra/core/tool-provider';\nimport type { ToolAction } from '@mastra/core/tools';\nimport type { StorageToolConfig } from '@mastra/core/storage';\nimport { MASTRA_RESOURCE_ID_KEY } from '@mastra/core/request-context';\n\nimport { Arcade } from '@arcadeai/arcadejs';\nimport type {\n ToolDefinition,\n ExecuteToolResponse,\n ToolListParams as ArcadeToolListParams,\n} from '@arcadeai/arcadejs/resources';\nimport { toZodToolSet, executeOrAuthorizeZodTool } from '@arcadeai/arcadejs/lib/index';\nimport type { ZodTool, ToolAuthorizationResponse } from '@arcadeai/arcadejs/lib/index';\n\nexport interface ArcadeToolProviderConfig {\n /** Arcade AI API key */\n apiKey: string;\n /** Base URL for the Arcade API (defaults to https://api.arcade.dev) */\n baseURL?: string;\n}\n\n/*\n * Pre-seeded catalog of known Arcade toolkits, sourced from the Arcade\n * integrations page and verified against the API. This avoids the need to\n * paginate through 7 000+ tools just to list toolkit names.\n *\n * The cache is updated at runtime when `listTools()` or `resolveTools()` encounters\n * a toolkit that isn't already present, so newly-added Arcade integrations are\n * picked up automatically.\n */\nconst KNOWN_TOOLKITS: readonly { slug: string; name: string; description?: string; category?: string }[] = [\n { slug: 'AirtableApi', name: 'Airtable API', category: 'productivity' },\n { slug: 'ArcadeEngineApi', name: 'Arcade Engine API', category: 'development' },\n { slug: 'Asana', name: 'Asana', category: 'productivity' },\n { slug: 'AsanaApi', name: 'Asana API', category: 'productivity' },\n { slug: 'AshbyApi', name: 'Ashby API', category: 'productivity' },\n { slug: 'Attio', name: 'Attio', category: 'sales' },\n { slug: 'BoxApi', name: 'Box API', category: 'productivity' },\n { slug: 'Brightdata', name: 'Bright Data', category: 'development' },\n { slug: 'CalendlyApi', name: 'Calendly API', category: 'productivity' },\n { slug: 'Clickup', name: 'ClickUp', category: 'productivity' },\n { slug: 'ClickupApi', name: 'ClickUp API', category: 'productivity' },\n { slug: 'Confluence', name: 'Confluence', category: 'productivity' },\n { slug: 'CursorAgentsApi', name: 'Cursor Agents API', category: 'development' },\n { slug: 'CustomerioApi', name: 'Customer.io API', category: 'customer-support' },\n { slug: 'CustomerioPipelinesApi', name: 'Customer.io Pipelines API', category: 'customer-support' },\n { slug: 'CustomerioTrackApi', name: 'Customer.io Track API', category: 'customer-support' },\n { slug: 'DatadogApi', name: 'Datadog API', category: 'development' },\n { slug: 'Dropbox', name: 'Dropbox', category: 'productivity' },\n { slug: 'E2b', name: 'E2B', category: 'development' },\n { slug: 'ExaApi', name: 'Exa API', category: 'search' },\n { slug: 'Figma', name: 'Figma', category: 'productivity' },\n { slug: 'FigmaApi', name: 'Figma API', category: 'productivity' },\n { slug: 'Firecrawl', name: 'Firecrawl', category: 'development' },\n { slug: 'FreshserviceApi', name: 'Freshservice API', category: 'customer-support' },\n { slug: 'Github', name: 'GitHub', category: 'development' },\n { slug: 'GithubApi', name: 'GitHub API', category: 'development' },\n { slug: 'Gmail', name: 'Gmail', category: 'productivity' },\n { slug: 'Google', name: 'Google', category: 'search' },\n { slug: 'GoogleCalendar', name: 'Google Calendar', category: 'productivity' },\n { slug: 'GoogleContacts', name: 'Google Contacts', category: 'productivity' },\n { slug: 'GoogleDocs', name: 'Google Docs', category: 'productivity' },\n { slug: 'GoogleDrive', name: 'Google Drive', category: 'productivity' },\n { slug: 'GoogleFinance', name: 'Google Finance', category: 'search' },\n { slug: 'GoogleFlights', name: 'Google Flights', category: 'search' },\n { slug: 'GoogleHotels', name: 'Google Hotels', category: 'search' },\n { slug: 'GoogleJobs', name: 'Google Jobs', category: 'search' },\n { slug: 'GoogleMaps', name: 'Google Maps', category: 'search' },\n { slug: 'GoogleNews', name: 'Google News', category: 'search' },\n { slug: 'GoogleSearch', name: 'Google Search', category: 'search' },\n { slug: 'GoogleSheets', name: 'Google Sheets', category: 'productivity' },\n { slug: 'GoogleShopping', name: 'Google Shopping', category: 'search' },\n { slug: 'GoogleSlides', name: 'Google Slides', category: 'productivity' },\n { slug: 'Hubspot', name: 'HubSpot', category: 'sales' },\n { slug: 'HubspotAutomationApi', name: 'HubSpot Automation API', category: 'sales' },\n { slug: 'HubspotCmsApi', name: 'HubSpot CMS API', category: 'sales' },\n { slug: 'HubspotConversationsApi', name: 'HubSpot Conversations API', category: 'sales' },\n { slug: 'HubspotCrmApi', name: 'HubSpot CRM API', category: 'sales' },\n { slug: 'HubspotEventsApi', name: 'HubSpot Events API', category: 'sales' },\n { slug: 'HubspotMarketingApi', name: 'HubSpot Marketing API', category: 'sales' },\n { slug: 'HubspotMeetingsApi', name: 'HubSpot Meetings API', category: 'sales' },\n { slug: 'HubspotUsersApi', name: 'HubSpot Users API', category: 'sales' },\n { slug: 'Imgflip', name: 'Imgflip', category: 'entertainment' },\n { slug: 'IntercomApi', name: 'Intercom API', category: 'customer-support' },\n { slug: 'Jira', name: 'Jira', category: 'productivity' },\n { slug: 'Linear', name: 'Linear', category: 'productivity' },\n { slug: 'Linkedin', name: 'LinkedIn', category: 'social' },\n { slug: 'LumaApi', name: 'Luma API', category: 'productivity' },\n { slug: 'MailchimpMarketingApi', name: 'Mailchimp API', category: 'productivity' },\n { slug: 'Math', name: 'Math', category: 'utility' },\n { slug: 'Microsoft', name: 'Microsoft', category: 'productivity' },\n { slug: 'MicrosoftOnedrive', name: 'Microsoft OneDrive', category: 'productivity' },\n { slug: 'MicrosoftTeams', name: 'Microsoft Teams', category: 'social' },\n { slug: 'MicrosoftWord', name: 'Microsoft Word', category: 'productivity' },\n { slug: 'MiroApi', name: 'Miro API', category: 'productivity' },\n { slug: 'NotionToolkit', name: 'Notion', category: 'productivity' },\n { slug: 'OutlookCalendar', name: 'Outlook Calendar', category: 'productivity' },\n { slug: 'OutlookMail', name: 'Outlook Mail', category: 'productivity' },\n { slug: 'Pagerduty', name: 'PagerDuty', category: 'development' },\n { slug: 'PagerdutyApi', name: 'PagerDuty API', category: 'development' },\n { slug: 'PosthogApi', name: 'PostHog API', category: 'development' },\n { slug: 'Pylon', name: 'Pylon', category: 'customer-support' },\n { slug: 'PylonApi', name: 'Pylon API', category: 'customer-support' },\n { slug: 'Reddit', name: 'Reddit', category: 'social' },\n { slug: 'Salesforce', name: 'Salesforce', category: 'sales' },\n { slug: 'Sharepoint', name: 'Microsoft SharePoint', category: 'productivity' },\n { slug: 'Slack', name: 'Slack', category: 'social' },\n { slug: 'SlackApi', name: 'Slack API', category: 'social' },\n { slug: 'Spotify', name: 'Spotify', category: 'entertainment' },\n { slug: 'SquareupApi', name: 'SquareUp API', category: 'productivity' },\n { slug: 'Stripe', name: 'Stripe', category: 'payments' },\n { slug: 'StripeApi', name: 'Stripe API', category: 'payments' },\n { slug: 'TicktickApi', name: 'TickTick API', category: 'productivity' },\n { slug: 'TrelloApi', name: 'Trello API', category: 'productivity' },\n { slug: 'Twilio', name: 'Twilio', category: 'social' },\n { slug: 'VercelApi', name: 'Vercel API', category: 'development' },\n { slug: 'Walmart', name: 'Walmart', category: 'search' },\n { slug: 'WeaviateApi', name: 'Weaviate API', category: 'development' },\n { slug: 'X', name: 'X', category: 'social' },\n { slug: 'XeroApi', name: 'Xero API', category: 'productivity' },\n { slug: 'Youtube', name: 'Youtube', category: 'search' },\n { slug: 'Zendesk', name: 'Zendesk', category: 'customer-support' },\n { slug: 'ZohoBooksApi', name: 'Zoho Books API', category: 'payments' },\n { slug: 'Zoom', name: 'Zoom', category: 'social' },\n] as const;\n\n/**\n * Arcade AI tool provider adapter.\n *\n * Uses `@arcadeai/arcadejs` SDK for discovery and runtime tool resolution.\n * The SDK is a static import and tree-shaken if this provider class isn't used.\n *\n * Arcade tools use `Toolkit.ToolName` naming (e.g., `Github.GetRepository`).\n * Each toolkit groups related tools and manages its own auth requirements.\n *\n * Discovery methods (`listToolkits`, `listTools`, `getToolSchema`) use the\n * standard `tools.list()` / `tools.get()` SDK methods.\n *\n * Runtime method (`resolveTools`) uses `toZodToolSet` from `@arcadeai/arcadejs/lib`\n * to get executable ZodTool objects, then converts them to Mastra's ToolAction format.\n */\nexport class ArcadeToolProvider implements ToolProvider {\n readonly info: ToolProviderInfo = {\n id: 'arcade',\n name: 'Arcade AI',\n description: 'Access 7,000+ tools from 130+ app integrations via Arcade AI',\n };\n\n private config: ArcadeToolProviderConfig;\n private toolkitCache: Map<string, ToolProviderToolkit>;\n private client: Arcade | null = null;\n\n constructor(config: ArcadeToolProviderConfig) {\n this.config = config;\n this.toolkitCache = new Map();\n for (const tk of KNOWN_TOOLKITS) {\n this.toolkitCache.set(tk.slug, {\n slug: tk.slug,\n name: tk.name,\n description: tk.description ?? `Arcade AI ${tk.name} tools`,\n icon: tk.category,\n });\n }\n }\n\n /**\n * Get or create an Arcade client.\n */\n private getClient(): Arcade {\n if (!this.client) {\n this.client = new Arcade({\n apiKey: this.config.apiKey,\n ...(this.config.baseURL ? { baseURL: this.config.baseURL } : {}),\n });\n }\n return this.client;\n }\n\n /**\n * Absorb toolkit metadata from a tool listing into the cache.\n * Returns true if any new toolkit was discovered.\n */\n private absorbToolkits(items: ToolDefinition[]): boolean {\n let discovered = false;\n for (const tool of items) {\n const tk = tool.toolkit;\n if (tk?.name && !this.toolkitCache.has(tk.name)) {\n this.toolkitCache.set(tk.name, {\n slug: tk.name,\n name: tk.name,\n description: tk.description ?? `Arcade AI ${tk.name} tools`,\n });\n discovered = true;\n }\n }\n return discovered;\n }\n\n /**\n * List toolkits.\n *\n * Returns the pre-seeded catalog merged with any toolkits discovered at\n * runtime via `listTools()` or `resolveTools()` calls.\n */\n async listToolkits(): Promise<ToolProviderListResult<ToolProviderToolkit>> {\n const data = [...this.toolkitCache.values()].sort((a, b) => a.name.localeCompare(b.name));\n return { data };\n }\n\n /**\n * List available tools with optional toolkit and pagination filters.\n * Uses `tools.list({ toolkit, limit, offset })`.\n */\n async listTools(options?: ListToolProviderToolsOptions): Promise<ToolProviderListResult<ToolProviderToolInfo>> {\n const client = this.getClient();\n\n const limit = options?.perPage ?? 50;\n const page = options?.page ?? 1;\n const offset = (page - 1) * limit;\n\n const query: ArcadeToolListParams = { limit, offset };\n if (options?.toolkit) query.toolkit = options.toolkit;\n\n const result = await client.tools.list(query);\n const items: ToolDefinition[] = result.items ?? [];\n\n // Update toolkit cache with any newly-discovered toolkits\n this.absorbToolkits(items);\n\n let filtered: ToolDefinition[] = items;\n if (options?.search) {\n const searchLower = options.search.toLowerCase();\n filtered = items.filter(\n t =>\n t.name?.toLowerCase().includes(searchLower) ||\n t.description?.toLowerCase().includes(searchLower) ||\n t.qualified_name?.toLowerCase().includes(searchLower),\n );\n }\n\n const data: ToolProviderToolInfo[] = filtered.map(tool => ({\n slug: tool.qualified_name ?? `${tool.toolkit?.name}.${tool.name}`,\n name: tool.name,\n description: tool.description,\n toolkit: tool.toolkit?.name,\n }));\n\n return {\n data,\n pagination: {\n page,\n perPage: limit,\n total: result.total_count,\n hasMore: offset + items.length < (result.total_count ?? 0),\n },\n };\n }\n\n /**\n * Get the JSON schema for a specific tool by its qualified name (e.g., `Github.GetRepository`).\n */\n async getToolSchema(toolSlug: string): Promise<Record<string, unknown> | null> {\n try {\n const client = this.getClient();\n const tool: ToolDefinition = await client.tools.get(toolSlug);\n if (!tool) return null;\n\n // Convert Arcade's parameter array to a JSON Schema-like object\n const properties: Record<string, Record<string, unknown>> = {};\n const required: string[] = [];\n\n for (const param of tool.input?.parameters ?? []) {\n properties[param.name] = {\n ...(param.value_schema ?? {}),\n description: param.description,\n };\n if (param.required) required.push(param.name);\n }\n\n return {\n type: 'object',\n properties,\n ...(required.length > 0 ? { required } : {}),\n };\n } catch {\n return null;\n }\n }\n\n /**\n * Resolve executable tools in Mastra's ToolAction format.\n *\n * Uses `toZodToolSet` from `@arcadeai/arcadejs/lib` to create ZodTool objects\n * with Zod schemas and execute functions, then wraps them as ToolAction objects.\n */\n async resolveTools(\n toolSlugs: string[],\n toolConfigs?: Record<string, StorageToolConfig>,\n options?: ResolveToolProviderToolsOptions,\n ): Promise<Record<string, ToolAction<unknown, unknown>>> {\n if (toolSlugs.length === 0) return {};\n\n const client = this.getClient();\n const resourceId = options?.requestContext?.[MASTRA_RESOURCE_ID_KEY];\n const userId = typeof resourceId === 'string' ? resourceId : (options?.userId ?? 'default');\n\n // Fetch tool definitions for the requested slugs\n const toolDefs = await Promise.all(toolSlugs.map(slug => client.tools.get(slug).catch(() => null)));\n const validDefs: ToolDefinition[] = toolDefs.filter((d): d is ToolDefinition => d !== null);\n\n if (validDefs.length === 0) return {};\n\n // Update toolkit cache with any newly-discovered toolkits\n this.absorbToolkits(validDefs);\n\n // Convert to executable ZodTool objects using Arcade's helper\n const zodToolSet: Record<string, ZodTool<ExecuteToolResponse | ToolAuthorizationResponse>> = toZodToolSet({\n tools: validDefs,\n client,\n userId,\n executeFactory: executeOrAuthorizeZodTool,\n });\n\n // Convert ZodTool objects to Mastra ToolAction format\n const result: Record<string, ToolAction<unknown, unknown>> = {};\n\n // Build a lookup from normalized name (Github_GetRepository) to qualified name (Github.GetRepository)\n const normalizedToQualified = new Map<string, string>();\n for (const d of validDefs) {\n const qn = d.qualified_name ?? `${d.toolkit?.name}.${d.name}`;\n normalizedToQualified.set(qn.replace(/\\./g, '_'), qn);\n }\n\n for (const [key, zodTool] of Object.entries(zodToolSet)) {\n const qualifiedName = normalizedToQualified.get(key) ?? key;\n const descOverride = toolConfigs?.[qualifiedName]?.description ?? toolConfigs?.[key]?.description;\n\n // Arcade SDK bundles a different Zod minor version than Mastra, so the\n // schema types are structurally identical at runtime but nominally\n // incompatible in TS. Cast through `unknown` to bridge the gap.\n result[qualifiedName] = {\n id: qualifiedName,\n description: descOverride ?? zodTool.description ?? '',\n inputSchema: zodTool.parameters as unknown as ToolAction<unknown, unknown>['inputSchema'],\n outputSchema: zodTool.output as unknown as ToolAction<unknown, unknown>['outputSchema'],\n execute: async (input: unknown) => {\n return zodTool.execute(input);\n },\n };\n }\n\n return result;\n }\n}\n"],"mappings":";AAWA,SAAS,8BAA8B;AAEvC,SAAS,cAAc;AAMvB,SAAS,cAAc,iCAAiC;AAmBxD,IAAM,iBAAqG;AAAA,EACzG,EAAE,MAAM,eAAe,MAAM,gBAAgB,UAAU,eAAe;AAAA,EACtE,EAAE,MAAM,mBAAmB,MAAM,qBAAqB,UAAU,cAAc;AAAA,EAC9E,EAAE,MAAM,SAAS,MAAM,SAAS,UAAU,eAAe;AAAA,EACzD,EAAE,MAAM,YAAY,MAAM,aAAa,UAAU,eAAe;AAAA,EAChE,EAAE,MAAM,YAAY,MAAM,aAAa,UAAU,eAAe;AAAA,EAChE,EAAE,MAAM,SAAS,MAAM,SAAS,UAAU,QAAQ;AAAA,EAClD,EAAE,MAAM,UAAU,MAAM,WAAW,UAAU,eAAe;AAAA,EAC5D,EAAE,MAAM,cAAc,MAAM,eAAe,UAAU,cAAc;AAAA,EACnE,EAAE,MAAM,eAAe,MAAM,gBAAgB,UAAU,eAA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M,gBAAgB,sBAAsB,IAAI,GAAG,KAAK;AACxD,YAAM,eAAe,cAAc,aAAa,GAAG,eAAe,cAAc,GAAG,GAAG;AAKtF,aAAO,aAAa,IAAI;AAAA,QACtB,IAAI;AAAA,QACJ,aAAa,gBAAgB,QAAQ,eAAe;AAAA,QACpD,aAAa,QAAQ;AAAA,QACrB,cAAc,QAAQ;AAAA,QACtB,SAAS,OAAO,UAAmB;AACjC,iBAAO,QAAQ,QAAQ,KAAK;AAAA,QAC9B;AAAA,MACF;AAAA,IACF;AAEA,WAAO;AAAA,EACT;AACF;","names":[]}
package/dist/composio.cjs CHANGED
@@ -143,3 +143,4 @@ var ComposioToolProvider = class {
143
143
  0 && (module.exports = {
144
144
  ComposioToolProvider
145
145
  });
146
+ //# sourceMappingURL=composio.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/composio.ts","../src/providers/composio.ts"],"sourcesContent":["export { ComposioToolProvider } from './providers/composio';\nexport type { ComposioToolProviderConfig } from './providers/composio';\n","import type {\n ToolProvider,\n ToolProviderInfo,\n ToolProviderToolkit,\n ToolProviderToolInfo,\n ToolProviderListResult,\n ListToolProviderToolsOptions,\n ResolveToolProviderToolsOptions,\n} from '@mastra/core/tool-provider';\nimport type { ToolAction } from '@mastra/core/tools';\nimport type { StorageToolConfig } from '@mastra/core/storage';\nimport { MASTRA_RESOURCE_ID_KEY } from '@mastra/core/request-context';\n\nimport { Composio } from '@composio/core';\nimport type { Tool as ComposioTool, ToolKitItem, ToolListParams as ComposioToolListParams } from '@composio/core';\nimport { MastraProvider } from '@composio/mastra';\nimport type { MastraTool, MastraToolCollection } from '@composio/mastra';\n\nexport interface ComposioToolProviderConfig {\n /** Composio API key */\n apiKey: string;\n}\n\n/**\n * Composio tool provider adapter.\n *\n * Uses `@composio/core` + `@composio/mastra` SDKs for both tool discovery\n * and runtime resolution. Both packages are optional peer dependencies and\n * tree-shaken if this provider class isn't imported.\n *\n * Discovery methods (`listToolkits`, `listTools`, `getToolSchema`) use the\n * raw Composio client (no userId required).\n *\n * Runtime method (`resolveTools`) uses the MastraProvider so returned tools are\n * already in Mastra's `createTool()` format.\n */\nexport class ComposioToolProvider implements ToolProvider {\n readonly info: ToolProviderInfo = {\n id: 'composio',\n name: 'Composio',\n description: 'Access 10,000+ tools from 150+ apps via Composio',\n };\n\n private apiKey: string;\n private rawClient: Composio | null = null;\n private mastraClient: Composio<MastraProvider> | null = null;\n\n constructor(config: ComposioToolProviderConfig) {\n this.apiKey = config.apiKey;\n }\n\n /**\n * Get or create a raw Composio client (no provider — for discovery only).\n */\n private getRawClient(): Composio {\n if (!this.rawClient) {\n this.rawClient = new Composio({ apiKey: this.apiKey });\n }\n return this.rawClient;\n }\n\n /**\n * Get or create a Composio client with MastraProvider (for runtime tools).\n */\n private getMastraClient(): Composio<MastraProvider> {\n if (!this.mastraClient) {\n this.mastraClient = new Composio({\n apiKey: this.apiKey,\n provider: new MastraProvider(),\n });\n }\n return this.mastraClient;\n }\n\n /**\n * List available toolkits via `composio.toolkits.get({})`.\n * Returns: `ToolKitListResponse` — an array of `{ slug, name, meta: { description, logo, ... } }`.\n */\n async listToolkits(): Promise<ToolProviderListResult<ToolProviderToolkit>> {\n const composio = this.getRawClient();\n const toolkits: ToolKitItem[] = await composio.toolkits.get({});\n\n const data: ToolProviderToolkit[] = toolkits.map(tk => ({\n slug: tk.slug,\n name: tk.name,\n description: tk.meta?.description,\n icon: tk.meta?.logo,\n }));\n return { data };\n }\n\n /**\n * List available tools via `composio.tools.getRawComposioTools()`.\n * No userId required — returns raw tool definitions for UI browsing.\n */\n async listTools(options?: ListToolProviderToolsOptions): Promise<ToolProviderListResult<ToolProviderToolInfo>> {\n const composio = this.getRawClient();\n\n // ToolListParams is a discriminated union in TypeScript but the\n // underlying Zod schema accepts `limit` on every variant. We cast\n // through the base type so `limit` is always forwarded.\n const limit = options?.perPage;\n const query: ComposioToolListParams = (\n options?.toolkit\n ? { toolkits: [options.toolkit], limit, search: options?.search }\n : options?.search\n ? { search: options.search, limit }\n : { toolkits: [] as string[], limit }\n ) as ComposioToolListParams;\n\n const rawTools: ComposioTool[] = await composio.tools.getRawComposioTools(query);\n\n const data: ToolProviderToolInfo[] = rawTools.map(tool => ({\n slug: tool.slug,\n name: tool.name ?? tool.slug,\n description: tool.description,\n toolkit: tool.toolkit?.slug,\n }));\n\n return {\n data,\n pagination: {\n page: options?.page ?? 1,\n perPage: limit,\n hasMore: limit !== undefined && rawTools.length >= limit,\n },\n };\n }\n\n /**\n * Get JSON schema for a specific tool via `composio.tools.getRawComposioToolBySlug()`.\n */\n async getToolSchema(toolSlug: string): Promise<Record<string, unknown> | null> {\n try {\n const composio = this.getRawClient();\n const tool: ComposioTool = await composio.tools.getRawComposioToolBySlug(toolSlug);\n if (!tool) return null;\n return (tool.inputParameters ?? {}) as Record<string, unknown>;\n } catch {\n return null;\n }\n }\n\n /**\n * Resolve executable tools in Mastra format via `composio.tools.get(userId, { tools: [...] })`.\n *\n * Uses MastraProvider so returned tools are `ReturnType<typeof createTool>` — compatible\n * with Mastra's `ToolAction` interface.\n */\n async resolveTools(\n toolSlugs: string[],\n toolConfigs?: Record<string, StorageToolConfig>,\n options?: ResolveToolProviderToolsOptions,\n ): Promise<Record<string, ToolAction<unknown, unknown>>> {\n if (toolSlugs.length === 0) return {};\n\n const resourceId = options?.requestContext?.[MASTRA_RESOURCE_ID_KEY];\n const userId = typeof resourceId === 'string' ? resourceId : (options?.userId ?? 'default');\n const composio = this.getMastraClient();\n\n // composio.tools.get returns MastraToolCollection = Record<string, MastraTool>\n const mastraTools: MastraToolCollection = await composio.tools.get(userId, { tools: toolSlugs });\n\n const result: Record<string, ToolAction<unknown, unknown>> = {};\n const entries: [string, MastraTool][] = Object.entries(mastraTools ?? {});\n\n for (const [key, tool] of entries) {\n if (!tool) continue;\n const slug = tool.id ?? key;\n const descOverride = toolConfigs?.[slug]?.description;\n if (descOverride) {\n result[slug] = { ...tool, description: descOverride };\n } else {\n result[slug] = tool;\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,CAAC,KAAM;AACX,YAAM,OAAO,KAAK,MAAM;AACxB,YAAM,eAAe,cAAc,IAAI,GAAG;AAC1C,UAAI,cAAc;AAChB,eAAO,IAAI,IAAI,EAAE,GAAG,MAAM,aAAa,aAAa;AAAA,MACtD,OAAO;AACL,eAAO,IAAI,IAAI;AAAA,MACjB;AAAA,IACF;AAEA,WAAO;AAAA,EACT;AACF;","names":[]}
package/dist/composio.js CHANGED
@@ -116,3 +116,4 @@ var ComposioToolProvider = class {
116
116
  export {
117
117
  ComposioToolProvider
118
118
  };
119
+ //# sourceMappingURL=composio.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/providers/composio.ts"],"sourcesContent":["import type {\n ToolProvider,\n ToolProviderInfo,\n ToolProviderToolkit,\n ToolProviderToolInfo,\n ToolProviderListResult,\n ListToolProviderToolsOptions,\n ResolveToolProviderToolsOptions,\n} from '@mastra/core/tool-provider';\nimport type { ToolAction } from '@mastra/core/tools';\nimport type { StorageToolConfig } from '@mastra/core/storage';\nimport { MASTRA_RESOURCE_ID_KEY } from '@mastra/core/request-context';\n\nimport { Composio } from '@composio/core';\nimport type { Tool as ComposioTool, ToolKitItem, ToolListParams as ComposioToolListParams } from '@composio/core';\nimport { MastraProvider } from '@composio/mastra';\nimport type { MastraTool, MastraToolCollection } from '@composio/mastra';\n\nexport interface ComposioToolProviderConfig {\n /** Composio API key */\n apiKey: string;\n}\n\n/**\n * Composio tool provider adapter.\n *\n * Uses `@composio/core` + `@composio/mastra` SDKs for both tool discovery\n * and runtime resolution. Both packages are optional peer dependencies and\n * tree-shaken if this provider class isn't imported.\n *\n * Discovery methods (`listToolkits`, `listTools`, `getToolSchema`) use the\n * raw Composio client (no userId required).\n *\n * Runtime method (`resolveTools`) uses the MastraProvider so returned tools are\n * already in Mastra's `createTool()` format.\n */\nexport class ComposioToolProvider implements ToolProvider {\n readonly info: ToolProviderInfo = {\n id: 'composio',\n name: 'Composio',\n description: 'Access 10,000+ tools from 150+ apps via Composio',\n };\n\n private apiKey: string;\n private rawClient: Composio | null = null;\n private mastraClient: Composio<MastraProvider> | null = null;\n\n constructor(config: ComposioToolProviderConfig) {\n this.apiKey = config.apiKey;\n }\n\n /**\n * Get or create a raw Composio client (no provider — for discovery only).\n */\n private getRawClient(): Composio {\n if (!this.rawClient) {\n this.rawClient = new Composio({ apiKey: this.apiKey });\n }\n return this.rawClient;\n }\n\n /**\n * Get or create a Composio client with MastraProvider (for runtime tools).\n */\n private getMastraClient(): Composio<MastraProvider> {\n if (!this.mastraClient) {\n this.mastraClient = new Composio({\n apiKey: this.apiKey,\n provider: new MastraProvider(),\n });\n }\n return this.mastraClient;\n }\n\n /**\n * List available toolkits via `composio.toolkits.get({})`.\n * Returns: `ToolKitListResponse` — an array of `{ slug, name, meta: { description, logo, ... } }`.\n */\n async listToolkits(): Promise<ToolProviderListResult<ToolProviderToolkit>> {\n const composio = this.getRawClient();\n const toolkits: ToolKitItem[] = await composio.toolkits.get({});\n\n const data: ToolProviderToolkit[] = toolkits.map(tk => ({\n slug: tk.slug,\n name: tk.name,\n description: tk.meta?.description,\n icon: tk.meta?.logo,\n }));\n return { data };\n }\n\n /**\n * List available tools via `composio.tools.getRawComposioTools()`.\n * No userId required — returns raw tool definitions for UI browsing.\n */\n async listTools(options?: ListToolProviderToolsOptions): Promise<ToolProviderListResult<ToolProviderToolInfo>> {\n const composio = this.getRawClient();\n\n // ToolListParams is a discriminated union in TypeScript but the\n // underlying Zod schema accepts `limit` on every variant. We cast\n // through the base type so `limit` is always forwarded.\n const limit = options?.perPage;\n const query: ComposioToolListParams = (\n options?.toolkit\n ? { toolkits: [options.toolkit], limit, search: options?.search }\n : options?.search\n ? { search: options.search, limit }\n : { toolkits: [] as string[], limit }\n ) as ComposioToolListParams;\n\n const rawTools: ComposioTool[] = await composio.tools.getRawComposioTools(query);\n\n const data: ToolProviderToolInfo[] = rawTools.map(tool => ({\n slug: tool.slug,\n name: tool.name ?? tool.slug,\n description: tool.description,\n toolkit: tool.toolkit?.slug,\n }));\n\n return {\n data,\n pagination: {\n page: options?.page ?? 1,\n perPage: limit,\n hasMore: limit !== undefined && rawTools.length >= limit,\n },\n };\n }\n\n /**\n * Get JSON schema for a specific tool via `composio.tools.getRawComposioToolBySlug()`.\n */\n async getToolSchema(toolSlug: string): Promise<Record<string, unknown> | null> {\n try {\n const composio = this.getRawClient();\n const tool: ComposioTool = await composio.tools.getRawComposioToolBySlug(toolSlug);\n if (!tool) return null;\n return (tool.inputParameters ?? {}) as Record<string, unknown>;\n } catch {\n return null;\n }\n }\n\n /**\n * Resolve executable tools in Mastra format via `composio.tools.get(userId, { tools: [...] })`.\n *\n * Uses MastraProvider so returned tools are `ReturnType<typeof createTool>` — compatible\n * with Mastra's `ToolAction` interface.\n */\n async resolveTools(\n toolSlugs: string[],\n toolConfigs?: Record<string, StorageToolConfig>,\n options?: ResolveToolProviderToolsOptions,\n ): Promise<Record<string, ToolAction<unknown, unknown>>> {\n if (toolSlugs.length === 0) return {};\n\n const resourceId = options?.requestContext?.[MASTRA_RESOURCE_ID_KEY];\n const userId = typeof resourceId === 'string' ? resourceId : (options?.userId ?? 'default');\n const composio = this.getMastraClient();\n\n // composio.tools.get returns MastraToolCollection = Record<string, MastraTool>\n const mastraTools: MastraToolCollection = await composio.tools.get(userId, { tools: toolSlugs });\n\n const result: Record<string, ToolAction<unknown, unknown>> = {};\n const entries: [string, MastraTool][] = Object.entries(mastraTools ?? {});\n\n for (const [key, tool] of entries) {\n if (!tool) continue;\n const slug = tool.id ?? key;\n const descOverride = toolConfigs?.[slug]?.description;\n if (descOverride) {\n result[slug] = { ...tool, description: descOverride };\n } else {\n result[slug] = tool;\n }\n }\n\n return result;\n }\n}\n"],"mappings":";AAWA,SAAS,8BAA8B;AAEvC,SAAS,gBAAgB;AAEzB,SAAS,sBAAsB;AAqBxB,IAAM,uBAAN,MAAmD;AAAA,EAWxD,YAAY,QAAoC;AAVhD,SAAS,OAAyB;AAAA,MAChC,IAAI;AAAA,MACJ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;","names":[]}
@@ -0,0 +1,281 @@
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/ee/index.ts
21
+ var ee_exports = {};
22
+ __export(ee_exports, {
23
+ EditorAgentBuilder: () => EditorAgentBuilder,
24
+ createBuilderAgent: () => createBuilderAgent
25
+ });
26
+ module.exports = __toCommonJS(ee_exports);
27
+
28
+ // src/ee/agent-builder.ts
29
+ var import_ee = require("@mastra/core/agent-builder/ee");
30
+ var EditorAgentBuilder = class {
31
+ constructor(options) {
32
+ this.modelPolicyWarnings = [];
33
+ /** Non-fatal warnings for browser config issues (surfaced alongside model policy warnings). */
34
+ this.browserConfigWarnings = [];
35
+ const source = options ?? {};
36
+ this.options = {
37
+ ...source,
38
+ features: source.features ? {
39
+ ...source.features,
40
+ agent: source.features.agent ? { ...source.features.agent } : void 0
41
+ } : void 0
42
+ };
43
+ this.validateModelPolicy();
44
+ this.validateBrowserConfig();
45
+ this.resolvedFeatures = {
46
+ agent: (0, import_ee.resolveAgentFeatures)(this.options.features?.agent, {
47
+ hasBrowserConfig: this.hasValidBrowserConfig()
48
+ })
49
+ };
50
+ }
51
+ get enabled() {
52
+ return this.options.enabled !== false;
53
+ }
54
+ getFeatures() {
55
+ return this.resolvedFeatures;
56
+ }
57
+ getConfiguration() {
58
+ return this.options.configuration;
59
+ }
60
+ getRegistries() {
61
+ return this.options.registries;
62
+ }
63
+ getModelPolicyWarnings() {
64
+ return [...this.modelPolicyWarnings, ...this.browserConfigWarnings];
65
+ }
66
+ /**
67
+ * True when `configuration.agent.browser` declares a provider. The
68
+ * EditorAgentBuilder does NOT verify the provider is registered with the
69
+ * Mastra instance — that cross-validation lives in `MastraEditor.resolveBuilder`
70
+ * because only the editor knows the registered browser providers.
71
+ */
72
+ hasValidBrowserConfig() {
73
+ const browserConfig = this.options.configuration?.agent?.browser;
74
+ return Boolean(browserConfig?.config?.provider);
75
+ }
76
+ /**
77
+ * Browser config validation only runs for **explicit** `browser: true`.
78
+ * With default-on semantics, an omitted `browser` no longer means "admin
79
+ * opted in" — it means "admin didn't opt out". The default-on path is
80
+ * resolved later by `resolveAgentFeatures`, which already gates `browser`
81
+ * on `hasValidBrowserConfig`. We don't want to spam every default-config
82
+ * deployment with warnings.
83
+ */
84
+ validateBrowserConfig() {
85
+ const explicitBrowser = this.options.features?.agent?.browser;
86
+ if (explicitBrowser !== true) return;
87
+ const browserConfig = this.options.configuration?.agent?.browser;
88
+ if (!browserConfig) {
89
+ const warning = 'Agent Builder browser feature is enabled but no default browser config was provided. Set `editor.builder.configuration.agent.browser` to a valid browser config (e.g. `{ type: "inline", config: { provider: "stagehand" } }`). The browser toggle will be hidden until a default is configured.';
90
+ this.browserConfigWarnings.push(warning);
91
+ console.warn(`[mastra:editor:builder] ${warning}`);
92
+ if (this.options.features?.agent) {
93
+ this.options.features.agent.browser = false;
94
+ }
95
+ return;
96
+ }
97
+ if (!browserConfig.config?.provider) {
98
+ const warning = 'Agent Builder browser config is missing a `provider` field. Set `editor.builder.configuration.agent.browser.config.provider` (e.g. `"stagehand"`). The browser toggle will be hidden until a provider is configured.';
99
+ this.browserConfigWarnings.push(warning);
100
+ console.warn(`[mastra:editor:builder] ${warning}`);
101
+ if (this.options.features?.agent) {
102
+ this.options.features.agent.browser = false;
103
+ }
104
+ }
105
+ }
106
+ validateModelPolicy() {
107
+ const enabled = this.options.enabled !== false;
108
+ const explicitModel = this.options.features?.agent?.model;
109
+ const pickerVisible = explicitModel !== false;
110
+ const models = this.options.configuration?.agent?.models;
111
+ const allowed = models?.allowed;
112
+ const defaultModel = models?.default;
113
+ const active = (0, import_ee.isBuilderModelPolicyActive)({
114
+ enabled,
115
+ pickerVisible,
116
+ allowed,
117
+ default: defaultModel
118
+ });
119
+ if (!active) return;
120
+ if (explicitModel === false && defaultModel === void 0) {
121
+ throw new Error(
122
+ "Agent Builder model policy is active in locked mode but no default was set. Set `editor.builder.configuration.agent.models.default`, or remove `editor.builder.features.agent.model = false` to allow end-users to pick a model."
123
+ );
124
+ }
125
+ if (defaultModel !== void 0 && allowed !== void 0 && allowed.length > 0) {
126
+ if (!(0, import_ee.isModelAllowed)(allowed, defaultModel)) {
127
+ throw new Error(
128
+ "Agent Builder default model is not in the allowlist. Either add it to `editor.builder.configuration.agent.models.allowed` or change `editor.builder.configuration.agent.models.default`."
129
+ );
130
+ }
131
+ }
132
+ }
133
+ };
134
+
135
+ // src/ee/agent-builder-agent.ts
136
+ var import_agent = require("@mastra/core/agent");
137
+ var import_memory = require("@mastra/memory");
138
+ function createBuilderAgent() {
139
+ const memory = new import_memory.Memory();
140
+ return new import_agent.Agent({
141
+ id: "builder-agent",
142
+ name: "Agent Builder Agent",
143
+ description: "An agent that can build agents",
144
+ instructions: `You are the Agent Builder.
145
+
146
+ Your job: turn a non-technical user's plain-language request into a fully configured, production-quality agent in a single turn.
147
+
148
+ # Non-negotiables
149
+
150
+ - Never ask the user follow-up questions. Make the most reasonable assumption and move forward.
151
+ - Never expose internal names, tool ids, file paths, schemas, code, or jargon to the user.
152
+ - Speak only in user-facing capability terms.
153
+ - Always finish the build in the same turn as the request \u2014 configure the agent end-to-end and deliver a short summary.
154
+ - Always define the new agent's name, description, model, and system prompt yourself. Do not ask the user for any of these.
155
+
156
+ Examples of communication style:
157
+ - Bad: "Added weatherTool to agent-yzx capabilities."
158
+ - Good: "Your new agent can now check the weather for you."
159
+ - Bad: "Calling set-agent-tools with [weatherTool]."
160
+ - Good: "Checking what capabilities to bring to your agent\u2026"
161
+ - Bad: "Agent created with weatherTool and recipeWorkflow attached."
162
+ - Good: "Your agent can check the weather and suggest recipes that match the day's conditions."
163
+
164
+ # Authoring loop
165
+
166
+ Follow these five steps in order, every time:
167
+
168
+ ## Step A \u2014 Understand the real outcome
169
+
170
+ Analyze what the user actually wants to achieve. Focus on the final result, not just the literal wording of the request.
171
+
172
+ Ask yourself:
173
+ - What should the agent help the user accomplish?
174
+ - Who will use this agent?
175
+ - What decisions should the agent make on its own?
176
+ - What kind of output should the agent produce?
177
+ - What recurring tasks, reasoning, or actions does the agent need to perform?
178
+
179
+ ## Step B \u2014 Define the agent's identity
180
+
181
+ Before building the agent, define:
182
+ - Agent name: short, memorable, anchored to the outcome. Never "Agent X" or generic labels
183
+ - Description: exactly one sentence in plain user-facing language explaining what the agent helps with.
184
+
185
+ Call \`set-agent-name\` and \`set-agent-description\` to set the agent's identity. Skip any whose feature is not available in the form snapshot.
186
+
187
+ ## Step C \u2014 Decide capabilities
188
+
189
+ Read the form snapshot already injected into your context. It lists the user's current selections plus the available tools, agents, workflows, stored skills, models, and workspaces.
190
+
191
+ Then:
192
+ - Pick the *minimum* set of existing tools/agents/workflows/stored skills that satisfies the outcome. Adding irrelevant capabilities makes the agent worse, not better.
193
+ - Prefer existing tools, workflows, agents, and stored skills before creating anything new.
194
+ - \`set-agent-skills\` attaches user-available stored skills from the form snapshot.
195
+ - Only call \`createSkillTool\` when (a) no existing stored skill matches reusable operating instructions the produced agent needs, AND (b) that operating instruction is genuinely needed for the outcome. Do not use stored skills as a substitute for missing integrations or tools.
196
+ - If a specific external connection is required (e.g. a sheet tool for a spreadsheet-driven outcome) and none is available, the new agent's system prompt must instruct it to refuse cleanly and explain what the user needs to connect.
197
+
198
+ ## Step D \u2014 Synthesize the run contract
199
+
200
+ Before calling \`set-agent-instructions\`, privately write a concrete run contract for the produced agent. The system prompt must instantiate each item:
201
+
202
+ 1. **Trigger / input** \u2014 what user request, schedule, event, file, row, ticket, or message starts a run.
203
+ 2. **Owned outcome** \u2014 the exact result the produced agent is responsible for finishing.
204
+ 3. **Available capabilities** \u2014 only capabilities actually attached or already available from the form snapshot, described in user-facing outcome terms.
205
+ 4. **Missing-capability fallback** \u2014 what the produced agent does when a required integration, workspace, credential, or source is absent.
206
+ 5. **Done criteria** \u2014 verifiable conditions that prove the job is finished, including tool confirmation or an explicit "not run" reason when verification is impossible.
207
+ 6. **Final response format** \u2014 the receipt, summary, draft, diff summary, report, or confirmation the user receives.
208
+
209
+ ## Step E \u2014 Write the agent
210
+
211
+ Call the capability tools. Skip any whose feature is not available in the form snapshot.
212
+
213
+ 1. \`set-agent-model\` \u2014 pick the best model for the use case from the available models list. Rules:
214
+ - Choose only a model id that appears in the available models list. Never invent, assume, or copy example model ids.
215
+ - For coding, reasoning-heavy, or planning agents, prefer the most capable available model.
216
+ - For short, simple, structured, or high-volume tasks, prefer a lower-latency/lower-cost available model when quality will not materially suffer.
217
+ - If several plausible models are available, choose the newest or strongest option based on the metadata visible in the snapshot.
218
+ 2. \`set-agent-tools\` \u2014 attach the minimum set chosen in Step C. Also use \`set-agent-skills\` and \`set-agent-browser-enabled\` only when applicable and supported by the snapshot.
219
+ 3. \`set-agent-instructions\` \u2014 write the new agent's system prompt from scratch, tailored to the user's specific outcome and the run contract from Step D.
220
+
221
+ Before calling \`set-agent-instructions\`, self-audit the draft. It must pass every check:
222
+ - No placeholders remain (no \`<...>\`, "TBD", "TODO", "your tool", or generic policy gaps).
223
+ - No internal tool ids, file paths, schemas, or builder-only terms appear.
224
+ - No generic "helpful assistant" identity remains.
225
+ - No unsupported capabilities are promised.
226
+ - Completion criteria are present, concrete, and tool-aware.
227
+ - Refusal / fallback path is present for missing integrations, credentials, permissions, workspace, or sources.
228
+ - Final response format is specified.
229
+
230
+ ## Step F \u2014 Confirm the agent configuration to the user
231
+
232
+ End your turn with one short, friendly paragraph confirming that the agent has been configured and is ready to use.
233
+
234
+ Use this shape:
235
+
236
+ "Your agent, [Agent Name], has been configured with its initial parameters. It can now [plain-language outcome]. You can adjust its instructions, inputs, or connected capabilities whenever your needs change."
237
+
238
+ Do not mention internal capability names, tools, workflows, skills, or configuration steps.
239
+
240
+ Good:
241
+ "Your agent, Sales Drop Watcher, has been configured with its initial parameters. It can now review your weekly sales sheet, flag accounts that dropped more than 10%, and prepare follow-up drafts for each one. You can adjust its instructions, thresholds, or connected data sources whenever your needs change."
242
+
243
+ Bad:
244
+ "Agent created with sheetsTool, scoringWorkflow, and emailSkill attached."
245
+
246
+ Bad:
247
+ "I configured the sheets integration and called set-agent-instructions."
248
+
249
+ # Quality bar for the produced agent's system prompt
250
+
251
+ The system prompt written into \`set-agent-instructions\` MUST include all of the following:
252
+
253
+ 1. **Role and outcome.** Define what the agent is and the concrete result it owns.
254
+ 2. **Trigger and input.** Define what starts a run and what input the agent expects.
255
+ 3. **Decision rules.** Explain how the agent resolves ambiguity, what defaults it should apply, and what it should skip without asking the user.
256
+ 4. **Capability awareness.** Describe only the tools, integrations, workspaces, or data sources the agent actually has, phrased in terms of what they let the agent accomplish.
257
+ 5. **Missing-capability fallback.** Explain what the agent should do when a required integration, credential, permission, workspace, or source is unavailable.
258
+ 6. **Completion criteria.** Define exactly when the task is done in observable, verifiable terms.
259
+ 7. **Final response format.** Specify the exact shape of the agent's final answer, report, draft, receipt, or confirmation.
260
+ 8. **Communication style.** Require plain language, short answers, no jargon, and structure only when useful.
261
+ 9. **Refusal rules.** State what the agent must refuse and how it should explain the refusal clearly.
262
+ 10. **Worked example.** Include at least one short input \u2192 output example showing a complete successful run.
263
+
264
+ # Hard rules
265
+
266
+ - If the user's request requires CLI or local-machine actions and no workspace is connected, refuse in plain language and tell the user they need to connect a workspace first.
267
+ - Never reveal that you are calling configuration tools. Describe progress only in terms of the user's intended outcome.
268
+ - Never produce a system prompt without explicit completion criteria.
269
+ - Never attach a capability "just in case." Every tool, agent, workflow, or skill must directly support the requested outcome.
270
+ - The final message to the user must be concise, friendly, and focused on what the configured agent can now do.
271
+ - The final message should make clear that the agent starts with initial parameters and can be adjusted later.`,
272
+ model: "openai/gpt-5.5",
273
+ memory
274
+ });
275
+ }
276
+ // Annotate the CommonJS export names for ESM import in node:
277
+ 0 && (module.exports = {
278
+ EditorAgentBuilder,
279
+ createBuilderAgent
280
+ });
281
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/ee/index.ts","../../src/ee/agent-builder.ts","../../src/ee/agent-builder-agent.ts"],"sourcesContent":["export { EditorAgentBuilder } from './agent-builder';\nexport { createBuilderAgent } from './agent-builder-agent';\n","import type { AgentBuilderOptions, AgentFeatures, IAgentBuilder } from '@mastra/core/agent-builder/ee';\nimport { isBuilderModelPolicyActive, isModelAllowed, resolveAgentFeatures } from '@mastra/core/agent-builder/ee';\n\n/**\n * Concrete implementation of the Agent Builder EE feature.\n * Instantiated by MastraEditor.resolveBuilder() when builder config is enabled.\n *\n * The constructor performs fail-fast validation of the admin's model policy\n * (Phase 4) so misconfiguration is caught at boot, not at first request.\n *\n * Feature toggles use **default-on semantics**: omitted keys resolve to\n * `true`. Admins opt out by setting a key to `false`. The resolved features\n * are computed once in the constructor (after validation) and returned\n * verbatim by {@link getFeatures} so all downstream consumers (server route,\n * UI hooks, policy derivation) see the same effective values.\n */\nexport class EditorAgentBuilder implements IAgentBuilder {\n private readonly options: AgentBuilderOptions;\n private readonly modelPolicyWarnings: string[] = [];\n\n /** Non-fatal warnings for browser config issues (surfaced alongside model policy warnings). */\n private readonly browserConfigWarnings: string[] = [];\n\n /**\n * Resolved (default-on normalized) features. Computed once in the\n * constructor; `undefined` only if the builder was constructed with\n * `enabled: false` (we still allocate features for the OFF path so callers\n * can introspect, but we keep the field optional to preserve the existing\n * API contract where `getFeatures()` may legitimately return `undefined`\n * if no `features` was provided AND no defaults could be applied).\n *\n * In practice this is always populated: `resolveAgentFeatures` returns a\n * fully-populated object regardless of input.\n */\n private readonly resolvedFeatures: AgentBuilderOptions['features'];\n\n constructor(options?: AgentBuilderOptions) {\n // Shallow-clone the paths the validators mutate so we never leak side\n // effects into the caller's `MastraEditorConfig.builder` object.\n // `validateBrowserConfig` writes to `features.agent.browser`; nothing\n // else is mutated, so `configuration` and `registries` stay aliased.\n const source = options ?? {};\n this.options = {\n ...source,\n features: source.features\n ? {\n ...source.features,\n agent: source.features.agent ? { ...source.features.agent } : undefined,\n }\n : undefined,\n };\n this.validateModelPolicy();\n this.validateBrowserConfig();\n // Resolve features AFTER browser-config validation so that an explicit\n // `browser: true` with bad config is already mutated to `false` on\n // `this.options.features.agent.browser`. The resolver then sees the\n // downgraded value and returns it as-is.\n this.resolvedFeatures = {\n agent: resolveAgentFeatures(this.options.features?.agent, {\n hasBrowserConfig: this.hasValidBrowserConfig(),\n }),\n };\n }\n\n get enabled(): boolean {\n return this.options.enabled !== false;\n }\n\n getFeatures(): AgentBuilderOptions['features'] {\n return this.resolvedFeatures;\n }\n\n getConfiguration(): AgentBuilderOptions['configuration'] {\n return this.options.configuration;\n }\n\n getRegistries(): AgentBuilderOptions['registries'] {\n return this.options.registries;\n }\n\n getModelPolicyWarnings(): string[] {\n return [...this.modelPolicyWarnings, ...this.browserConfigWarnings];\n }\n\n /**\n * True when `configuration.agent.browser` declares a provider. The\n * EditorAgentBuilder does NOT verify the provider is registered with the\n * Mastra instance — that cross-validation lives in `MastraEditor.resolveBuilder`\n * because only the editor knows the registered browser providers.\n */\n private hasValidBrowserConfig(): boolean {\n const browserConfig = this.options.configuration?.agent?.browser;\n return Boolean(browserConfig?.config?.provider);\n }\n\n /**\n * Browser config validation only runs for **explicit** `browser: true`.\n * With default-on semantics, an omitted `browser` no longer means \"admin\n * opted in\" — it means \"admin didn't opt out\". The default-on path is\n * resolved later by `resolveAgentFeatures`, which already gates `browser`\n * on `hasValidBrowserConfig`. We don't want to spam every default-config\n * deployment with warnings.\n */\n private validateBrowserConfig(): void {\n const explicitBrowser = this.options.features?.agent?.browser;\n if (explicitBrowser !== true) return;\n\n const browserConfig = this.options.configuration?.agent?.browser;\n if (!browserConfig) {\n const warning =\n 'Agent Builder browser feature is enabled but no default browser config was provided. ' +\n 'Set `editor.builder.configuration.agent.browser` to a valid browser config ' +\n '(e.g. `{ type: \"inline\", config: { provider: \"stagehand\" } }`). ' +\n 'The browser toggle will be hidden until a default is configured.';\n this.browserConfigWarnings.push(warning);\n // eslint-disable-next-line no-console\n console.warn(`[mastra:editor:builder] ${warning}`);\n // Downgrade so the resolved feature ends up `false`.\n if (this.options.features?.agent) {\n this.options.features.agent.browser = false;\n }\n return;\n }\n\n if (!browserConfig.config?.provider) {\n const warning =\n 'Agent Builder browser config is missing a `provider` field. ' +\n 'Set `editor.builder.configuration.agent.browser.config.provider` ' +\n '(e.g. `\"stagehand\"`). The browser toggle will be hidden until a provider is configured.';\n this.browserConfigWarnings.push(warning);\n // eslint-disable-next-line no-console\n console.warn(`[mastra:editor:builder] ${warning}`);\n if (this.options.features?.agent) {\n this.options.features.agent.browser = false;\n }\n }\n }\n\n private validateModelPolicy(): void {\n const enabled = this.options.enabled !== false;\n // Locked-mode is only triggered by an explicit `model: false` from the\n // admin. With default-on semantics, an omitted `model` resolves to\n // `true` (picker visible), which is open mode and has no\n // locked-mode-default invariant.\n const explicitModel = this.options.features?.agent?.model;\n const pickerVisible = explicitModel !== false;\n const models = this.options.configuration?.agent?.models;\n const allowed = models?.allowed;\n const defaultModel = models?.default;\n\n const active = isBuilderModelPolicyActive({\n enabled,\n pickerVisible,\n allowed,\n default: defaultModel,\n });\n\n if (!active) return;\n\n // Locked mode (picker hidden) requires an admin-pinned default. Phase 3's\n // create-path decision matrix relies on this invariant: a locked policy\n // without a default is unreachable. Only fires when the admin has\n // explicitly opted out of the picker.\n if (explicitModel === false && defaultModel === undefined) {\n throw new Error(\n 'Agent Builder model policy is active in locked mode but no default was set. ' +\n 'Set `editor.builder.configuration.agent.models.default`, or remove ' +\n '`editor.builder.features.agent.model = false` to allow end-users to pick a model.',\n );\n }\n\n // When an allowlist is set, the default (if any) must satisfy it. An\n // empty `allowed: []` means \"unrestricted\" so we skip this check.\n if (defaultModel !== undefined && allowed !== undefined && allowed.length > 0) {\n if (!isModelAllowed(allowed, defaultModel)) {\n throw new Error(\n 'Agent Builder default model is not in the allowlist. ' +\n 'Either add it to `editor.builder.configuration.agent.models.allowed` ' +\n 'or change `editor.builder.configuration.agent.models.default`.',\n );\n }\n }\n }\n}\n\n// AgentFeatures imported for documentation reference in this file's jsdoc.\nexport type { AgentFeatures };\n","import { Agent } from '@mastra/core/agent';\nimport { Memory } from '@mastra/memory';\n\n/**\n * Agent Builder Agent\n *\n * Audience: non-technical users (Product, founders, operators, business stakeholders).\n * Goal: turn a plain-language description of a desired outcome into a fully\n * configured, production-quality agent — name, description, model, capabilities,\n * and system prompt — without asking the user follow-up questions.\n *\n * Capability tools the playground UI injects as client tools:\n * - set-agent-name, set-agent-description, set-agent-instructions, set-agent-workspace-id (always on)\n * - set-agent-tools (gated by features.tools)\n * - set-agent-skills (gated by features.skills + skills available)\n * - set-agent-model (gated by features.model + models available)\n * - set-agent-browser-enabled (gated by features.browser)\n * - createSkillTool (gated by features.skills) — only when a needed capability does not exist\n */\n\nexport function createBuilderAgent(): Agent {\n const memory = new Memory();\n return new Agent({\n id: 'builder-agent',\n name: 'Agent Builder Agent',\n description: 'An agent that can build agents',\n instructions: `You are the Agent Builder.\n\nYour job: turn a non-technical user's plain-language request into a fully configured, production-quality agent in a single turn.\n\n# Non-negotiables\n\n- Never ask the user follow-up questions. Make the most reasonable assumption and move forward.\n- Never expose internal names, tool ids, file paths, schemas, code, or jargon to the user.\n- Speak only in user-facing capability terms.\n- Always finish the build in the same turn as the request — configure the agent end-to-end and deliver a short summary.\n- Always define the new agent's name, description, model, and system prompt yourself. Do not ask the user for any of these.\n\nExamples of communication style:\n- Bad: \"Added weatherTool to agent-yzx capabilities.\"\n- Good: \"Your new agent can now check the weather for you.\"\n- Bad: \"Calling set-agent-tools with [weatherTool].\"\n- Good: \"Checking what capabilities to bring to your agent…\"\n- Bad: \"Agent created with weatherTool and recipeWorkflow attached.\"\n- Good: \"Your agent can check the weather and suggest recipes that match the day's conditions.\"\n\n# Authoring loop\n\nFollow these five steps in order, every time:\n\n## Step A — Understand the real outcome\n\nAnalyze what the user actually wants to achieve. Focus on the final result, not just the literal wording of the request.\n\nAsk yourself:\n- What should the agent help the user accomplish?\n- Who will use this agent?\n- What decisions should the agent make on its own?\n- What kind of output should the agent produce?\n- What recurring tasks, reasoning, or actions does the agent need to perform?\n\n## Step B — Define the agent's identity\n\nBefore building the agent, define:\n- Agent name: short, memorable, anchored to the outcome. Never \"Agent X\" or generic labels\n- Description: exactly one sentence in plain user-facing language explaining what the agent helps with.\n\nCall \\`set-agent-name\\` and \\`set-agent-description\\` to set the agent's identity. Skip any whose feature is not available in the form snapshot.\n\n## Step C — Decide capabilities\n\nRead the form snapshot already injected into your context. It lists the user's current selections plus the available tools, agents, workflows, stored skills, models, and workspaces.\n\nThen:\n- Pick the *minimum* set of existing tools/agents/workflows/stored skills that satisfies the outcome. Adding irrelevant capabilities makes the agent worse, not better.\n- Prefer existing tools, workflows, agents, and stored skills before creating anything new.\n- \\`set-agent-skills\\` attaches user-available stored skills from the form snapshot.\n- Only call \\`createSkillTool\\` when (a) no existing stored skill matches reusable operating instructions the produced agent needs, AND (b) that operating instruction is genuinely needed for the outcome. Do not use stored skills as a substitute for missing integrations or tools.\n- If a specific external connection is required (e.g. a sheet tool for a spreadsheet-driven outcome) and none is available, the new agent's system prompt must instruct it to refuse cleanly and explain what the user needs to connect.\n\n## Step D — Synthesize the run contract\n\nBefore calling \\`set-agent-instructions\\`, privately write a concrete run contract for the produced agent. The system prompt must instantiate each item:\n\n1. **Trigger / input** — what user request, schedule, event, file, row, ticket, or message starts a run.\n2. **Owned outcome** — the exact result the produced agent is responsible for finishing.\n3. **Available capabilities** — only capabilities actually attached or already available from the form snapshot, described in user-facing outcome terms.\n4. **Missing-capability fallback** — what the produced agent does when a required integration, workspace, credential, or source is absent.\n5. **Done criteria** — verifiable conditions that prove the job is finished, including tool confirmation or an explicit \"not run\" reason when verification is impossible.\n6. **Final response format** — the receipt, summary, draft, diff summary, report, or confirmation the user receives.\n\n## Step E — Write the agent\n\nCall the capability tools. Skip any whose feature is not available in the form snapshot.\n\n1. \\`set-agent-model\\` — pick the best model for the use case from the available models list. Rules:\n - Choose only a model id that appears in the available models list. Never invent, assume, or copy example model ids.\n - For coding, reasoning-heavy, or planning agents, prefer the most capable available model.\n - For short, simple, structured, or high-volume tasks, prefer a lower-latency/lower-cost available model when quality will not materially suffer.\n - If several plausible models are available, choose the newest or strongest option based on the metadata visible in the snapshot.\n2. \\`set-agent-tools\\` — attach the minimum set chosen in Step C. Also use \\`set-agent-skills\\` and \\`set-agent-browser-enabled\\` only when applicable and supported by the snapshot.\n3. \\`set-agent-instructions\\` — write the new agent's system prompt from scratch, tailored to the user's specific outcome and the run contract from Step D.\n\nBefore calling \\`set-agent-instructions\\`, self-audit the draft. It must pass every check:\n- No placeholders remain (no \\`<...>\\`, \"TBD\", \"TODO\", \"your tool\", or generic policy gaps).\n- No internal tool ids, file paths, schemas, or builder-only terms appear.\n- No generic \"helpful assistant\" identity remains.\n- No unsupported capabilities are promised.\n- Completion criteria are present, concrete, and tool-aware.\n- Refusal / fallback path is present for missing integrations, credentials, permissions, workspace, or sources.\n- Final response format is specified.\n\n## Step F — Confirm the agent configuration to the user\n\nEnd your turn with one short, friendly paragraph confirming that the agent has been configured and is ready to use.\n\nUse this shape:\n\n\"Your agent, [Agent Name], has been configured with its initial parameters. It can now [plain-language outcome]. You can adjust its instructions, inputs, or connected capabilities whenever your needs change.\"\n\nDo not mention internal capability names, tools, workflows, skills, or configuration steps.\n\nGood:\n\"Your agent, Sales Drop Watcher, has been configured with its initial parameters. It can now review your weekly sales sheet, flag accounts that dropped more than 10%, and prepare follow-up drafts for each one. You can adjust its instructions, thresholds, or connected data sources whenever your needs change.\"\n\nBad:\n\"Agent created with sheetsTool, scoringWorkflow, and emailSkill attached.\"\n\nBad:\n\"I configured the sheets integration and called set-agent-instructions.\"\n\n# Quality bar for the produced agent's system prompt\n\nThe system prompt written into \\`set-agent-instructions\\` MUST include all of the following:\n\n1. **Role and outcome.** Define what the agent is and the concrete result it owns.\n2. **Trigger and input.** Define what starts a run and what input the agent expects.\n3. **Decision rules.** Explain how the agent resolves ambiguity, what defaults it should apply, and what it should skip without asking the user.\n4. **Capability awareness.** Describe only the tools, integrations, workspaces, or data sources the agent actually has, phrased in terms of what they let the agent accomplish.\n5. **Missing-capability fallback.** Explain what the agent should do when a required integration, credential, permission, workspace, or source is unavailable.\n6. **Completion criteria.** Define exactly when the task is done in observable, verifiable terms.\n7. **Final response format.** Specify the exact shape of the agent's final answer, report, draft, receipt, or confirmation.\n8. **Communication style.** Require plain language, short answers, no jargon, and structure only when useful.\n9. **Refusal rules.** State what the agent must refuse and how it should explain the refusal clearly.\n10. **Worked example.** Include at least one short input → output example showing a complete successful run.\n\n# Hard rules\n\n- If the user's request requires CLI or local-machine actions and no workspace is connected, refuse in plain language and tell the user they need to connect a workspace first.\n- Never reveal that you are calling configuration tools. Describe progress only in terms of the user's intended outcome.\n- Never produce a system prompt without explicit completion criteria.\n- Never attach a capability \"just in case.\" Every tool, agent, workflow, or skill must directly support the requested outcome.\n- The final message to the user must be concise, friendly, and focused on what the configured agent can now do.\n- The final message should make clear that the agent starts with initial parameters and can be adjusted later.`,\n model: 'openai/gpt-5.5',\n memory,\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,gBAAiF;AAe1E,IAAM,qBAAN,MAAkD;AAAA,EAoBvD,YAAY,SAA+B;AAlB3C,SAAiB,sBAAgC,CAAC;AAGlD;AAAA,SAAiB,wBAAkC,CAAC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