@elementor/editor-mcp 4.4.0-beta3 → 4.4.1
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/index.d.mts +63 -1
- package/dist/index.d.ts +63 -1
- package/dist/index.js +103 -57
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +97 -57
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -6
- package/src/index.ts +13 -1
- package/src/init.ts +3 -1
- package/src/mcp-registry.ts +14 -7
- package/src/types/open-angie-request.ts +34 -0
- package/src/utils/can-create-widget.ts +3 -0
- package/src/utils/install-angie-plugin.ts +3 -0
- package/src/utils/open-angie-in-ask-mode.ts +34 -1
- package/src/utils/redirect-to-app-admin.ts +4 -0
- package/src/utils/redirect-to-installation.ts +4 -0
- package/src/utils/send-prompt-to-angie.ts +7 -1
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/get-sdk.ts","../src/index.ts","../src/utils/is-angie-available.ts","../src/utils/is-angie-sidebar-open.ts","../src/mcp-registry.ts","../src/utils/to-mcp-title.ts","../src/adapters/angie-adapter.ts","../src/adapters/web-mcp-adapter.ts","../src/utils/register-model-context-tool.ts","../src/angie-annotations.ts","../src/test-utils/mock-mcp-registry.ts","../src/utils/get-model-context.ts","../src/utils/merge-required-resources.ts","../src/utils/create-simple-resource-handler.ts","../src/utils/register-server-docs-resource.ts","../src/sampler.ts","../src/utils/prompt-builder.ts","../src/utils/get-active-chat-info.ts","../src/utils/open-angie-in-ask-mode.ts","../src/utils/send-prompt-to-angie.ts","../src/utils/redirect-to-installation.ts","../src/utils/redirect-to-app-admin.ts","../src/utils/install-angie-plugin.ts","../src/utils/save-angie-consent.ts","../src/init.ts","../src/events/mcp-styles-applied-event.ts"],"sourcesContent":["import { AngieMcpSdk } from '@elementor-external/angie-sdk';\nexport { getAngieIframe, MessageEventType } from '@elementor-external/angie-sdk';\n\nlet sdk: AngieMcpSdk;\n\nclass RetriableAngieSDK extends AngieMcpSdk {\n\tpublic async waitForReady(): Promise< void > {\n\t\tlet retryCount = 3;\n\t\twhile ( retryCount > 0 ) {\n\t\t\ttry {\n\t\t\t\tawait super.waitForReady();\n\t\t\t\treturn;\n\t\t\t} catch {\n\t\t\t\tretryCount--;\n\t\t\t\tawait sleep();\n\t\t\t}\n\t\t}\n\t\treturn new Promise( () => {} ); // never resolves\n\t}\n}\n\nconst sleep = ( ms = 10_000 ) =>\n\tnew Promise( ( resolve ) => {\n\t\tsetTimeout( resolve, ms );\n\t} );\n\nexport const getSDK = () => {\n\t// @ts-ignore - QUnit fails this\n\tconst isMCPDisabled = !! ( globalThis as Record< string, unknown > ).__ELEMENTOR_MCP_DISABLED__;\n\tif ( isMCPDisabled ) {\n\t\treturn {} as unknown as AngieMcpSdk;\n\t}\n\tif ( ! sdk ) {\n\t\tsdk = new RetriableAngieSDK();\n\t}\n\treturn sdk;\n};\n","import { getSDK } from './utils/get-sdk';\nexport { getAngieIframe, MessageEventType as AngieMessageEvenetType } from './utils/get-sdk';\n\nexport {\n\tMcpServer,\n\tResourceTemplate,\n\ttype RegisteredResource,\n\ttype ToolCallback,\n} from '@modelcontextprotocol/sdk/server/mcp.js';\nexport { SamplingMessageSchema } from '@modelcontextprotocol/sdk/types.js';\nexport { isAngieAvailable } from './utils/is-angie-available';\nexport { isAngieSidebarOpen } from './utils/is-angie-sidebar-open';\nexport * from './mcp-registry';\nexport { createSampler } from './sampler';\nexport { toolPrompts } from './utils/prompt-builder';\nexport { ANGIE_MODEL_PREFERENCES, ANGIE_REQUIRED_RESOURCES, type AngieModelPreferences } from './angie-annotations';\nexport { getActiveChatInfo, type ActiveChatInfo } from './utils/get-active-chat-info';\nexport { openAngieInAskMode } from './utils/open-angie-in-ask-mode';\nexport { sendPromptToAngie } from './utils/send-prompt-to-angie';\nexport { redirectToInstallation } from './utils/redirect-to-installation';\nexport { redirectToAppAdmin } from './utils/redirect-to-app-admin';\nexport { installAngiePlugin, type InstallAngieResult } from './utils/install-angie-plugin';\nexport { saveAngieConsent } from './utils/save-angie-consent';\nexport const getAngieSdk = () => getSDK();\nexport * from './init';\nexport {\n\tdispatchMcpStylesAppliedEvent,\n\tMCP_STYLES_APPLIED_EVENT,\n\ttype McpStylesAppliedPayload,\n} from './events/mcp-styles-applied-event';\n","import { getAngieIframe } from '@elementor-external/angie-sdk';\n\nexport const isAngieAvailable = (): boolean => {\n\treturn !! getAngieIframe();\n};\n","import { ANGIE_SIDEBAR_STATE_OPEN, getAngieSidebarSavedState } from '@elementor-external/angie-sdk';\n\nexport const isAngieSidebarOpen = (): boolean => {\n\treturn getAngieSidebarSavedState() === ANGIE_SIDEBAR_STATE_OPEN;\n};\n","import { z, type z3 } from '@elementor/schema';\nimport { McpServer, type ToolCallback } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { type RequestHandlerExtra } from '@modelcontextprotocol/sdk/shared/protocol.js';\nimport { type ServerNotification, type ServerRequest } from '@modelcontextprotocol/sdk/types.js';\n\nimport { AngieMcpAdapter } from './adapters/angie-adapter';\nimport { type IMcpRegistrationAdapter, type McpResourceHandler, type McpResourceUriOrTemplate } from './adapters/types';\nimport { WebMCPAdapter } from './adapters/web-mcp-adapter';\nimport {\n\tANGIE_MODEL_PREFERENCES,\n\tANGIE_REQUIRED_RESOURCES,\n\ttype AngieModelPreferences,\n\tcreateDefaultModelPreferences,\n} from './angie-annotations';\nimport { mockMcpRegistry } from './test-utils/mock-mcp-registry';\nimport { getModelContext } from './utils/get-model-context';\nimport { getSDK } from './utils/get-sdk';\nimport { isAngieAvailable } from './utils/is-angie-available';\nimport { mergeRequiredResources, type ResourceList } from './utils/merge-required-resources';\nimport { registerServerDocsResource } from './utils/register-server-docs-resource';\nimport { toMCPTitle } from './utils/to-mcp-title';\n\ntype ZodRawShape = z3.ZodRawShape;\n\nconst mcpRegistry: { [ namespace: string ]: McpServer } = {};\nconst mcpDescriptions: { [ namespace: string ]: string } = {};\n// @ts-ignore - QUnit fails this\nconst isMcpRegistrationActivated = false || typeof globalThis.jest !== 'undefined';\n\nconst registrationAdapters: IMcpRegistrationAdapter[] = [];\nconst bufferedTools: Parameters< IMcpRegistrationAdapter[ 'onToolRegistered' ] >[] = [];\nconst bufferedResources: Parameters< IMcpRegistrationAdapter[ 'onResourceRegistered' ] >[] = [];\n\nlet resolveReady!: () => void;\nconst readyPromise = new Promise< void >( ( resolve ) => {\n\tresolveReady = resolve;\n} );\n\nexport const registerMcpAdapter = ( adapter: IMcpRegistrationAdapter ): void => {\n\tregistrationAdapters.push( adapter );\n\tfor ( const tool of bufferedTools ) {\n\t\ttry {\n\t\t\tadapter.onToolRegistered( tool[ 0 ], tool[ 1 ] );\n\t\t} catch {\n\t\t\t// exit quietly\n\t\t}\n\t}\n\tfor ( const resource of bufferedResources ) {\n\t\ttry {\n\t\t\tadapter.onResourceRegistered( ...resource );\n\t\t} catch {\n\t\t\t// exit quietly\n\t\t}\n\t}\n};\n\nexport const signalMcpReady = (): void => {\n\tresolveReady();\n};\n\nexport const createAndRegisterAdapters = async (): Promise< void > => {\n\tconst modelContext = getModelContext();\n\n\tif ( modelContext ) {\n\t\tregisterMcpAdapter( new WebMCPAdapter( modelContext ) );\n\t}\n\n\tif ( isAngieAvailable() ) {\n\t\tregisterMcpAdapter( new AngieMcpAdapter( getSDK(), getRegisteredMcpServers ) );\n\t}\n\n\tawait Promise.all( registrationAdapters.map( ( adapter ) => adapter.activate() ) );\n};\n\n// utility function to run a callback on all MCP interfaces\nfunction callAdapters( fn: ( adapter: IMcpRegistrationAdapter ) => unknown ) {\n\tfor ( const adapter of registrationAdapters ) {\n\t\ttry {\n\t\t\tfn( adapter );\n\t\t} catch {\n\t\t\t// adapter failed — exit quietly, continue to next\n\t\t}\n\t}\n}\n\nexport const registerMcp = ( mcp: McpServer, name: string ) => {\n\tconst mcpName = isAlphabet( name );\n\tmcpRegistry[ mcpName ] = mcp;\n};\n\nexport const getRegisteredMcpServers = (): Array< [ string, McpServer, string ] > => {\n\treturn Object.entries( mcpRegistry ).map( ( [ key, server ] ) => [ key, server, mcpDescriptions[ key ] || key ] );\n};\n\nconst isAlphabet = ( str: string ): string | never => {\n\tconst passes = !! str && /^[a-z_]+$/.test( str );\n\tif ( ! passes ) {\n\t\tthrow new Error( 'Not alphabet' );\n\t}\n\treturn str;\n};\n\n/**\n * @param namespace The namespace of the MCP server. It should contain only lowercase alphabetic characters.\n * @param options\n * @param options.instructions Short hint about the MCP and its toolset (MCP SDK `instructions`; keeps payload small).\n * @param options.docs Full documentation registered as a lazy-loaded resource.\n * When provided, it is registered at elementor://{namespace}/server-docs\n * and auto-injected into every tool's requiredResources.\n */\nexport const getMCPByDomain = (\n\tnamespace: string,\n\toptions?: { docs?: string; instructions?: string }\n): MCPRegistryEntry => {\n\tconst mcpName = `editor-${ isAlphabet( namespace ) }`;\n\tconst title = toMCPTitle( namespace );\n\t// @ts-ignore - QUnit fails this\n\tif ( typeof globalThis.jest !== 'undefined' ) {\n\t\treturn mockMcpRegistry();\n\t}\n\tif ( ! mcpRegistry[ namespace ] ) {\n\t\tmcpRegistry[ namespace ] = new McpServer(\n\t\t\t{ name: mcpName, title, version: '1.0.0' },\n\t\t\t{ instructions: options?.instructions, capabilities: { resources: { subscribe: true } } }\n\t\t);\n\t\tif ( options?.docs ) {\n\t\t\tregisterServerDocsResource( mcpRegistry[ namespace ], namespace, title, options.docs, ( ...args ) => {\n\t\t\t\tbufferedResources.push( args );\n\t\t\t\tcallAdapters( ( adapter ) => adapter.onResourceRegistered( ...args ) );\n\t\t\t} );\n\t\t}\n\t}\n\tconst mcpServer = mcpRegistry[ namespace ];\n\tconst serverDocsUri = options?.docs ? `elementor://${ namespace }/server-docs` : undefined;\n\tconst { addTool } = createToolRegistry( mcpServer, mcpName, serverDocsUri );\n\treturn {\n\t\twaitForReady: () => readyPromise,\n\t\t// @ts-expect-error: TS is unable to infer the type here\n\t\tresource: async ( ...args: Parameters< McpServer[ 'registerResource' ] > ) => {\n\t\t\tconst [ name, uriOrTemplate, ...rest ] = args as [ string, unknown, ...unknown[] ];\n\t\t\tconst handler = rest[ rest.length - 1 ] as McpResourceHandler;\n\t\t\tconst resourceArgs: Parameters< IMcpRegistrationAdapter[ 'onResourceRegistered' ] > = [\n\t\t\t\tname,\n\t\t\t\turiOrTemplate as McpResourceUriOrTemplate,\n\t\t\t\thandler,\n\t\t\t];\n\t\t\tbufferedResources.push( resourceArgs );\n\t\t\tcallAdapters( ( adapter ) => adapter.onResourceRegistered( ...resourceArgs ) );\n\t\t\treturn mcpServer.registerResource( ...args );\n\t\t},\n\t\tsendResourceUpdated: ( ...args: Parameters< McpServer[ 'server' ][ 'sendResourceUpdated' ] > ) => {\n\t\t\tcallAdapters( ( adapter ) => adapter.sendResourceUpdated( { uri: args[ 0 ].uri } ) );\n\t\t\treturn Promise.resolve( mcpServer.server.sendResourceUpdated( ...args ) ).catch( ( error: Error ) => {\n\t\t\t\tif ( error?.message?.includes( 'Not connected' ) ) {\n\t\t\t\t\treturn; // Expected when no MCP client is connected yet\n\t\t\t\t}\n\t\t\t\tif ( error?.message?.includes( 'does not support notifying about resources' ) ) {\n\t\t\t\t\treturn; // Server capability not declared — safe to ignore\n\t\t\t\t}\n\t\t\t\tthrow error;\n\t\t\t} );\n\t\t},\n\t\taddTool,\n\t\tsetMCPDescription: ( description: string ) => {\n\t\t\tmcpDescriptions[ namespace ] = description;\n\t\t},\n\t};\n};\n\nexport interface MCPRegistryEntry {\n\taddTool: < T extends undefined | z.ZodRawShape = undefined, O extends undefined | z.ZodRawShape = undefined >(\n\t\topts: ToolRegistrationOptions< T, O >\n\t) => void;\n\tsetMCPDescription: ( description: string ) => void;\n\tsendResourceUpdated: McpServer[ 'server' ][ 'sendResourceUpdated' ];\n\tresource: McpServer[ 'registerResource' ];\n\twaitForReady: () => Promise< void >;\n}\n\ntype ToolRegistrationOptions<\n\tInputArgs extends undefined | z.ZodRawShape = undefined,\n\tOutputSchema extends undefined | z.ZodRawShape = undefined,\n\tExpectedOutput = OutputSchema extends z.ZodRawShape ? z.objectOutputType< OutputSchema, z.ZodTypeAny > : string,\n> = {\n\tname: string;\n\tdescription: string;\n\tschema?: InputArgs;\n\t/**\n\t * Auto added fields:\n\t * @param errors z.string().optional().describe('Error message if the tool failed')\n\t */\n\toutputSchema?: OutputSchema;\n\thandler: InputArgs extends z.ZodRawShape\n\t\t? (\n\t\t\t\targs: z.objectOutputType< InputArgs, z.ZodTypeAny >,\n\t\t\t\textra: RequestHandlerExtra< ServerRequest, ServerNotification >\n\t\t ) => ExpectedOutput | Promise< ExpectedOutput >\n\t\t: (\n\t\t\t\targs: unknown,\n\t\t\t\textra: RequestHandlerExtra< ServerRequest, ServerNotification >\n\t\t ) => ExpectedOutput | Promise< ExpectedOutput >;\n\tisDestructive?: boolean;\n\trequiredResources?: ResourceList;\n\tmodelPreferences?: AngieModelPreferences;\n};\n\nfunction createToolRegistry( server: McpServer, serverName: string, serverDocsUri?: string ) {\n\tfunction addTool<\n\t\tT extends undefined | z.ZodRawShape = undefined,\n\t\tO extends undefined | z.ZodRawShape = undefined,\n\t>( opts: ToolRegistrationOptions< T, O > ) {\n\t\tconst outputSchema = opts.outputSchema as ZodRawShape | undefined;\n\t\tif ( outputSchema ) {\n\t\t\tObject.assign(\n\t\t\t\toutputSchema,\n\t\t\t\toutputSchema.errors ?? {\n\t\t\t\t\terrors: z.string().optional().describe( 'Error message if the tool failed' ),\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t\t// @ts-ignore: TS is unable to infer the type here\n\t\tconst inputSchema: ZodRawShape = opts.schema ? opts.schema : {};\n\t\tconst toolCallback: ToolCallback< ZodRawShape > = async function ( args, extra ) {\n\t\t\ttry {\n\t\t\t\tconst invocationResult = await opts.handler( opts.schema ? args : {}, extra );\n\t\t\t\treturn {\n\t\t\t\t\t// structuredContent: typeof invocationResult === 'string' ? undefined : invocationResult,\n\t\t\t\t\tcontent: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: 'text',\n\t\t\t\t\t\t\ttext:\n\t\t\t\t\t\t\t\ttypeof invocationResult === 'string'\n\t\t\t\t\t\t\t\t\t? invocationResult\n\t\t\t\t\t\t\t\t\t: JSON.stringify( invocationResult ),\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t};\n\t\t\t} catch ( error ) {\n\t\t\t\treturn {\n\t\t\t\t\tisError: true,\n\t\t\t\t\tstructuredContent: {\n\t\t\t\t\t\terrors: ( error as Error ).message || 'Unknown error',\n\t\t\t\t\t},\n\t\t\t\t\tcontent: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: 'text',\n\t\t\t\t\t\t\ttext:\n\t\t\t\t\t\t\t\t( ( error as Error ).message || 'Unknown error' ) +\n\t\t\t\t\t\t\t\tJSON.stringify( ( error as { response?: { data: unknown } } ).response?.data || error ),\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t};\n\t\t\t}\n\t\t};\n\t\tconst annotations: Record< string, unknown > = {\n\t\t\tdestructiveHint: opts.isDestructive,\n\t\t\treadOnlyHint: opts.isDestructive ? false : undefined,\n\t\t\ttitle: opts.name,\n\t\t};\n\t\tconst mergedResources = mergeRequiredResources( opts.requiredResources, serverDocsUri );\n\t\tconst angieAnnotations = {\n\t\t\t[ ANGIE_MODEL_PREFERENCES ]: opts.modelPreferences ?? createDefaultModelPreferences(),\n\t\t\t[ ANGIE_REQUIRED_RESOURCES ]: mergedResources,\n\t\t};\n\t\tserver.registerTool(\n\t\t\topts.name,\n\t\t\t{\n\t\t\t\tdescription: opts.description,\n\t\t\t\tinputSchema,\n\t\t\t\t// TODO: Uncomment this when the outputSchema is stable\n\t\t\t\t// outputSchema,\n\t\t\t\ttitle: opts.name,\n\t\t\t\tannotations,\n\t\t\t\t_meta: angieAnnotations,\n\t\t\t},\n\t\t\ttoolCallback\n\t\t);\n\t\tconst toolDescriptor = {\n\t\t\tname: opts.name,\n\t\t\tdescription: opts.description,\n\t\t\tinputSchema: inputSchema as object,\n\t\t\texecute: ( params: Record< string, unknown > ) =>\n\t\t\t\ttoolCallback(\n\t\t\t\t\tparams as Parameters< typeof toolCallback >[ 0 ],\n\t\t\t\t\t/* WebMCP: no protocol session — handlers must not rely on `extra` here */\n\t\t\t\t\t{} as RequestHandlerExtra< ServerRequest, ServerNotification >\n\t\t\t\t) as Promise< unknown >,\n\t\t};\n\t\tconst extraData = {\n\t\t\tresources: [ `Server resource name: ${ serverName }, Required to fetch!` ],\n\t\t\trequiredResources: mergedResources?.map( ( resource ) => resource.uri ) ?? [],\n\t\t};\n\t\tbufferedTools.push( [ toolDescriptor, extraData ] );\n\t\tcallAdapters( ( adapter ) => adapter.onToolRegistered( toolDescriptor, extraData ) );\n\t\tif ( isMcpRegistrationActivated ) {\n\t\t\tserver.sendToolListChanged();\n\t\t}\n\t}\n\treturn {\n\t\taddTool,\n\t};\n}\n","export const toMCPTitle = ( namespace: string ): string => {\n\tconst capitalized = namespace.charAt( 0 ).toUpperCase() + namespace.slice( 1 );\n\treturn `Editor ${ capitalized }`;\n};\n","import { type AngieMcpSdk } from '@elementor-external/angie-sdk';\n\nimport { type getRegisteredMcpServers as _getRegisteredMcpServers } from '../mcp-registry';\nimport { toMCPTitle } from '../utils/to-mcp-title';\nimport { type IMcpRegistrationAdapter } from './types';\n\nconst MAX_RETRIES = 3;\n\nexport class AngieMcpAdapter implements IMcpRegistrationAdapter {\n\tconstructor(\n\t\tprivate readonly sdk: AngieMcpSdk,\n\t\tprivate readonly getRegisteredMcpServers: typeof _getRegisteredMcpServers\n\t) {}\n\n\tasync activate(): Promise< void > {\n\t\t// No waitForReady() here: registerLocalServer queues the server and the SDK flushes\n\t\t// the queue once Angie reports ready. waitForReady() only resolves for the SDK copy\n\t\t// that booted the sidebar, which is the host integration, never the editor bundle.\n\t\tawait this.registerEntries( this.getRegisteredMcpServers(), MAX_RETRIES );\n\t}\n\n\tprivate async registerEntries(\n\t\tentries: ReturnType< typeof _getRegisteredMcpServers >,\n\t\tretry: number\n\t): Promise< void > {\n\t\tif ( retry === 0 ) {\n\t\t\t/* eslint-disable-next-line no-console */\n\t\t\tconsole.error(\n\t\t\t\t'Failed to register MCP after 3 retries. failed entries: ',\n\t\t\t\tentries.map( ( [ key ] ) => key )\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tconst failed: typeof entries = [];\n\t\tfor ( const [ key, mcpServer, description ] of entries ) {\n\t\t\ttry {\n\t\t\t\tawait this.sdk.registerLocalServer( {\n\t\t\t\t\ttitle: toMCPTitle( key ),\n\t\t\t\t\tname: `editor-${ key }`,\n\t\t\t\t\tserver: mcpServer,\n\t\t\t\t\tversion: '1.0.0',\n\t\t\t\t\tdescription,\n\t\t\t\t} );\n\t\t\t} catch {\n\t\t\t\tfailed.push( [ key, mcpServer, description ] );\n\t\t\t}\n\t\t}\n\n\t\tif ( failed.length > 0 ) {\n\t\t\treturn this.registerEntries( failed, retry - 1 );\n\t\t}\n\t}\n\n\tonToolRegistered(): void {\n\t\t// Angie tools are registered via McpServer (at activate time).\n\t}\n\n\tonResourceRegistered(): void {\n\t\t// Resources are registered on the McpServer instance directly.\n\t}\n\n\tsendResourceUpdated(): void {\n\t\t// Resource update notifications are sent via MCPRegistryEntry.sendResourceUpdated.\n\t}\n}\n","import { zodToJsonSchema } from 'zod-to-json-schema';\nimport { z, type z3 } from '@elementor/schema';\n\nimport { type ModelContextRegisterTool, registerModelContextTool } from '../utils/register-model-context-tool';\nimport {\n\ttype IMcpRegistrationAdapter,\n\ttype McpResourceHandler,\n\ttype McpResourceUriOrTemplate,\n\ttype McpToolDescriptor,\n\ttype UriTemplate,\n} from './types';\n\ntype ZodRawShape = z3.ZodRawShape;\n\nexport type ModelContext = {\n\tregisterTool: ModelContextRegisterTool;\n\tunregisterTool?: ( name: string ) => void;\n};\n\ntype ResourceEntry = {\n\tpattern: string;\n\tmatch: ( uri: string ) => Record< string, string | string[] > | null;\n\thandler: McpResourceHandler;\n};\n\nexport class WebMCPAdapter implements IMcpRegistrationAdapter {\n\tprivate readonly registeredToolNames = new Set< string >();\n\tprivate readonly resourceEntries: ResourceEntry[] = [];\n\tprivate activated = false;\n\n\tconstructor( private readonly ctx: ModelContext ) {}\n\n\tactivate(): Promise< void > {\n\t\tif ( this.activated ) {\n\t\t\treturn Promise.resolve();\n\t\t}\n\t\tthis.activated = true;\n\t\treturn registerModelContextTool( this.ctx.registerTool, {\n\t\t\tname: 'editor-resource-getter',\n\t\t\tdescription:\n\t\t\t\t'Get an editor resource by URI, or search for available resources by partial URI. Pass a full URI to retrieve content, or a partial string to discover matching patterns.',\n\t\t\tinputSchema: {\n\t\t\t\ttype: 'object',\n\t\t\t\tproperties: {\n\t\t\t\t\turi: {\n\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t'A full resource URI (e.g. elementor://style/best-practices) or a partial string to search across available resource patterns.',\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\trequired: [ 'uri' ],\n\t\t\t},\n\t\t\texecute: async ( params ) => {\n\t\t\t\tconst query = params.uri as string;\n\t\t\t\tconst entries = this.resourceEntries;\n\n\t\t\t\tif ( entries.length === 0 ) {\n\t\t\t\t\treturn 'No resources are registered yet.';\n\t\t\t\t}\n\n\t\t\t\t// Exact URI match\n\t\t\t\tfor ( const entry of entries ) {\n\t\t\t\t\tconst variables = entry.match( query );\n\t\t\t\t\tif ( variables !== null ) {\n\t\t\t\t\t\tlet resourceUrl: URL;\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tresourceUrl = new URL( query );\n\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\treturn `Invalid URI '${ query }'. Provide a valid resource URI or a partial string to search patterns.`;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst result = await entry.handler( resourceUrl, variables );\n\t\t\t\t\t\treturn result.contents?.[ 0 ]?.text ?? JSON.stringify( result );\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Partial search fallback\n\t\t\t\tconst matches = entries.map( ( e ) => e.pattern ).filter( ( pattern ) => pattern.includes( query ) );\n\t\t\t\tif ( matches.length > 0 ) {\n\t\t\t\t\treturn `Found ${ matches.length } matching resource pattern(s):\\n${ matches.join(\n\t\t\t\t\t\t'\\n'\n\t\t\t\t\t) }\\n\\nProvide a full URI to retrieve the resource content.`;\n\t\t\t\t}\n\n\t\t\t\tconst available = entries.map( ( e ) => e.pattern ).join( '\\n' );\n\t\t\t\tthrow new Error( `No resource matched '${ query }'.\\n\\nAvailable patterns:\\n${ available }` );\n\t\t\t},\n\t\t} );\n\t}\n\n\tonToolRegistered(\n\t\ttool: McpToolDescriptor,\n\t\textraData?: { resources: string[]; requiredResources: string[] }\n\t): void {\n\t\tlet jsonSchema: object;\n\t\ttry {\n\t\t\tjsonSchema = zodToJsonSchema( z.object( tool.inputSchema as ZodRawShape ) );\n\t\t} catch {\n\t\t\tjsonSchema = tool.inputSchema;\n\t\t}\n\n\t\tif ( this.registeredToolNames.has( tool.name ) ) {\n\t\t\tthis.ctx.unregisterTool?.( tool.name );\n\t\t\tthis.registeredToolNames.delete( tool.name );\n\t\t}\n\n\t\tlet resourcesDescription = '';\n\t\tif ( extraData ) {\n\t\t\tif ( extraData.resources?.length > 0 ) {\n\t\t\t\tresourcesDescription += `#Resources:\\n${ extraData.resources?.join( '\\n' ) }\\n\\n`;\n\t\t\t}\n\t\t\tif ( extraData.requiredResources?.length > 0 ) {\n\t\t\t\tresourcesDescription += `#Required Resources:\\n${ extraData.requiredResources?.join( '\\n' ) }\\n\\n`;\n\t\t\t}\n\t\t\tresourcesDescription += `To read resources, use editor-resource-getter tool.\\n\\n`;\n\t\t}\n\t\tvoid registerModelContextTool( this.ctx.registerTool, {\n\t\t\tname: tool.name,\n\t\t\tdescription: `${ resourcesDescription }${ tool.description }`,\n\t\t\tinputSchema: jsonSchema,\n\t\t\texecute: tool.execute,\n\t\t} ).then( () => {\n\t\t\tthis.registeredToolNames.add( tool.name );\n\t\t} );\n\t}\n\n\tonResourceRegistered( _name: string, uriOrTemplate: McpResourceUriOrTemplate, handler: McpResourceHandler ): void {\n\t\tif ( typeof uriOrTemplate === 'string' ) {\n\t\t\tthis.resourceEntries.push( {\n\t\t\t\tpattern: uriOrTemplate,\n\t\t\t\tmatch: ( uri ) => ( uri === uriOrTemplate ? {} : null ),\n\t\t\t\thandler,\n\t\t\t} );\n\t\t} else {\n\t\t\tconst template = uriOrTemplate.uriTemplate as UriTemplate;\n\t\t\tthis.resourceEntries.push( {\n\t\t\t\tpattern: template.toString(),\n\t\t\t\tmatch: ( uri ) => template.match( uri ),\n\t\t\t\thandler,\n\t\t\t} );\n\t\t}\n\t}\n\n\tsendResourceUpdated(): void {\n\t\t// WebMCP has no server-push mechanism — no-op\n\t}\n}\n","import { type McpToolDescriptor } from '../adapters/types';\n\nexport type ModelContextRegisterTool = ( tool: McpToolDescriptor ) => void | Promise< void >;\n\nexport async function registerModelContextTool(\n\tregisterTool: ModelContextRegisterTool,\n\ttool: McpToolDescriptor\n): Promise< void > {\n\ttry {\n\t\tawait Promise.resolve( registerTool( tool ) );\n\t} catch ( error ) {\n\t\t/* eslint-disable-next-line no-console */\n\t\tconsole.error( 'Tool registration failed:', error );\n\t}\n}\n","export const ANGIE_MODEL_PREFERENCES = 'angie/modelPreferences' as const;\nexport const ANGIE_REQUIRED_RESOURCES = 'angie/requiredResources' as const;\n\nexport interface AngieModelPreferences {\n\thints?: Array< { name: string } >;\n\tcostPriority?: number; // 0-1 (future use)\n\tspeedPriority?: number; // 0-1 (future use)\n\tintelligencePriority?: number; // 0-1 (future use)\n}\n\nexport function createDefaultModelPreferences(): AngieModelPreferences {\n\treturn {\n\t\thints: [ { name: 'claude-sonnet-4-6' } ],\n\t};\n}\n","import { type McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\n\nimport { type MCPRegistryEntry } from '../mcp-registry';\n\nconst mock = new Proxy(\n\t{},\n\t{\n\t\tget: () => {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unused-vars\n\t\t\tfunction mockedFn( ..._: unknown[] ) {}\n\t\t\treturn mockedFn;\n\t\t},\n\t}\n);\n\nexport const mockMcpRegistry = (): MCPRegistryEntry => {\n\treturn {\n\t\t// @ts-ignore\n\t\tresource: async () => {},\n\t\t// @ts-ignore\n\t\tsendResourceUpdated: () => {},\n\t\taddTool: () => {},\n\t\tsetMCPDescription: () => {},\n\t\tmcpServer: mock as McpServer,\n\t};\n};\n","import { type ModelContext } from '../adapters/web-mcp-adapter';\n\ntype ModelContextHost = {\n\tmodelContext?: ModelContext;\n};\n\nfunction bindModelContextMethods( host: ModelContext ): ModelContext {\n\treturn {\n\t\tregisterTool: host.registerTool.bind( host ),\n\t\tunregisterTool: host.unregisterTool ? host.unregisterTool.bind( host ) : undefined,\n\t};\n}\n\nexport function getModelContext(): ModelContext | undefined {\n\tconst documentModelContext =\n\t\ttypeof document !== 'undefined' ? ( document as unknown as ModelContextHost ).modelContext : undefined;\n\tif ( documentModelContext?.registerTool ) {\n\t\treturn bindModelContextMethods( documentModelContext );\n\t}\n\tconst navigatorModelContext =\n\t\ttypeof navigator !== 'undefined' ? ( navigator as unknown as ModelContextHost ).modelContext : undefined;\n\tif ( navigatorModelContext?.registerTool ) {\n\t\treturn bindModelContextMethods( navigatorModelContext );\n\t}\n\n\treturn undefined;\n}\n","export type ResourceList = {\n\turi: string;\n\tdescription: string;\n}[];\n\nexport const mergeRequiredResources = (\n\ttoolResources: ResourceList | undefined,\n\tserverDocsUri: string | undefined\n): ResourceList | undefined => {\n\tif ( ! serverDocsUri ) {\n\t\treturn toolResources;\n\t}\n\tif ( toolResources?.some( ( r ) => r.uri === serverDocsUri ) ) {\n\t\treturn toolResources;\n\t}\n\treturn [ ...( toolResources ?? [] ), { uri: serverDocsUri, description: 'Server docs' } ];\n};\n","export const createSimpleResourceHandler = ( text: string ) => async ( uri: URL ) => ( {\n\tcontents: [ { uri: uri.href, mimeType: 'text/plain', text } ],\n} );\n","import { type McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\n\nimport { type IMcpRegistrationAdapter } from '../adapters/types';\nimport { createSimpleResourceHandler } from './create-simple-resource-handler';\n\ntype OnResourceRegistered = ( ...args: Parameters< IMcpRegistrationAdapter[ 'onResourceRegistered' ] > ) => void;\n\nexport const registerServerDocsResource = (\n\tserver: McpServer,\n\tnamespace: string,\n\ttitle: string,\n\tdocs: string,\n\tonRegistered: OnResourceRegistered\n): void => {\n\tconst uri = `elementor://${ namespace }/server-docs`;\n\tconst name = `${ namespace }-server-docs`;\n\tconst handler = createSimpleResourceHandler( docs );\n\tserver.registerResource(\n\t\tname,\n\t\turi,\n\t\t{\n\t\t\ttitle: `${ title } server docs`,\n\t\t\tdescription: 'Full MCP documentation (lazy-loaded)',\n\t\t\tmimeType: 'text/plain',\n\t\t},\n\t\thandler\n\t);\n\tonRegistered( name, uri, handler );\n};\n","import { type z } from '@elementor/schema';\nimport { type RequestHandlerExtra } from '@modelcontextprotocol/sdk/shared/protocol.js';\nimport { SamplingMessageSchema, type ServerNotification, type ServerRequest } from '@modelcontextprotocol/sdk/types.js';\n\ntype Server = RequestHandlerExtra< ServerRequest, ServerNotification >;\ntype Opts = {\n\tmaxTokens?: number;\n\tmodelPreferences?: string;\n\tmodel?: string;\n};\n\nconst DEFAULT_OPTS: Opts = {\n\tmaxTokens: 10000,\n\tmodelPreferences: 'openai',\n\tmodel: 'gpt-4o',\n};\n\ntype SamplingOpts = {\n\tsystemPrompt?: string;\n\tstructuredOutput?: z.ZodTypeAny;\n\tmessages: { role: 'user' | 'assistant'; content: { type: 'text'; text: string } }[];\n\trequestParams?: { [ key: string ]: string };\n};\n\nconst DEFAULT_STRUCTURED_OUTPUT = {\n\ttype: 'object',\n\tproperties: {\n\t\tcontent: {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Result',\n\t\t},\n\t},\n\trequired: [ 'content' ],\n\tadditionalProperties: false,\n};\n\nexport const createSampler = ( server: Server, opts: Opts = DEFAULT_OPTS ) => {\n\tconst { maxTokens = 1000, modelPreferences = 'openai', model = 'gpt-4o' } = opts;\n\tconst exec = async ( payload: SamplingOpts ) => {\n\t\tconst systemPromptObject = { ...( payload.systemPrompt ? { systemPrompt: payload.systemPrompt } : {} ) };\n\t\tconst requestParams = payload.requestParams || {};\n\t\tconst result = await server.sendRequest(\n\t\t\t{\n\t\t\t\tmethod: 'sampling/createMessage',\n\t\t\t\tparams: {\n\t\t\t\t\t...requestParams,\n\t\t\t\t\tmaxTokens,\n\t\t\t\t\tmodelPreferences: {\n\t\t\t\t\t\thints: [ { name: modelPreferences } ],\n\t\t\t\t\t},\n\t\t\t\t\tmetadata: {\n\t\t\t\t\t\tmodel,\n\t\t\t\t\t\t...systemPromptObject,\n\t\t\t\t\t\t...{ structured_output: payload.structuredOutput || DEFAULT_STRUCTURED_OUTPUT },\n\t\t\t\t\t},\n\t\t\t\t\tmessages: payload.messages,\n\t\t\t\t},\n\t\t\t\t// ...systemPromptObject,\n\t\t\t},\n\t\t\tSamplingMessageSchema\n\t\t);\n\t\treturn result.content;\n\t};\n\treturn exec;\n};\n","class ToolPrompts {\n\tpublic _description = '';\n\tpublic _parameters: Record< string, string > = {};\n\tpublic _examples: string[] = [];\n\tpublic _furtherInstructions: string[] = [];\n\n\tconstructor( public name: string ) {}\n\n\tdescription(): string;\n\tdescription( desc: string ): this;\n\tdescription( desc?: string | undefined ) {\n\t\tif ( typeof desc === 'undefined' ) {\n\t\t\treturn this._description;\n\t\t}\n\t\tthis._description = desc;\n\t\treturn this;\n\t}\n\n\tparameter( key: string ): string;\n\tparameter( key: string, description: string ): this;\n\tparameter( key: string, description?: string ) {\n\t\tif ( typeof description === 'undefined' ) {\n\t\t\treturn this._parameters[ key ];\n\t\t}\n\t\tthis._parameters[ key ] = `**${ key }**:\\n${ description }`;\n\t\treturn this;\n\t}\n\n\tinstruction( instruction: string ): this {\n\t\tthis._furtherInstructions.push( instruction );\n\t\treturn this;\n\t}\n\n\texample( example: string ): this {\n\t\tthis._examples.push( example );\n\t\treturn this;\n\t}\n\n\tpublic get examples() {\n\t\treturn this._examples.join( '\\n\\n' );\n\t}\n\n\tprompt(): string {\n\t\treturn `# ${ this.name }\n# Description\n${ this._description }\n${ this._parameters.length ? '# Parameters\\n' + Object.values( this._parameters ).join( '\\n\\n' ) : '' }\n${ this._examples.length ? '# Examples\\n' + this.examples : '' }\n${ this._furtherInstructions.length ? '# Further Instructions\\n' + this._furtherInstructions.join( '\\n\\n' ) : '' }\n`.trim();\n\t}\n}\n\nexport const toolPrompts = ( name: string ) => {\n\treturn new ToolPrompts( name );\n};\n","export type ActiveChatInfo = {\n\tsessionId: string;\n\texpiresAt: number;\n};\n\nexport const getActiveChatInfo = (): ActiveChatInfo => {\n\tconst info = localStorage.getItem( 'angie_active_chat_id' );\n\tif ( ! info ) {\n\t\treturn {\n\t\t\texpiresAt: 0,\n\t\t\tsessionId: '',\n\t\t};\n\t}\n\tconst rawData = JSON.parse( info );\n\treturn {\n\t\texpiresAt: rawData.expiresAt as number,\n\t\tsessionId: rawData.sessionId as string,\n\t};\n};\n","import {\n\tAngieInteractionMode,\n\tgetAngieIframe,\n\tsetAngieInteractionMode,\n\ttoggleAngieSidebar,\n} from '@elementor-external/angie-sdk';\n\nimport { isAngieAvailable } from './is-angie-available';\n\nexport const openAngieInAskMode = ( prompt?: string ): void => {\n\tif ( ! isAngieAvailable() ) {\n\t\treturn;\n\t}\n\n\tconst angieSidebar = getAngieIframe();\n\n\tif ( ! angieSidebar ) {\n\t\treturn;\n\t}\n\n\ttoggleAngieSidebar( angieSidebar, true );\n\tsetAngieInteractionMode( AngieInteractionMode.ASK );\n\n\tif ( prompt ) {\n\t\twindow.location.hash = `angie-prompt=${ encodeURIComponent( prompt ) }`;\n\t}\n};\n","import { getAngieIframe, toggleAngieSidebar } from '@elementor-external/angie-sdk';\n\nexport const sendPromptToAngie = ( prompt?: string ) => {\n\tconst angieSidebar = getAngieIframe();\n\n\tif ( ! angieSidebar ) {\n\t\treturn;\n\t}\n\n\ttoggleAngieSidebar( angieSidebar, true );\n\n\tif ( ! prompt ) {\n\t\treturn;\n\t}\n\n\twindow.location.hash = `angie-prompt=${ encodeURIComponent( prompt ) }`;\n};\n","import { setReferrerRedirect } from '@elementor-external/angie-sdk';\n\nconst ANGIE_INSTALL_URL = '/wp-admin/plugin-install.php?s=angie&tab=search&type=term';\n\nexport const redirectToInstallation = ( prompt?: string ) => {\n\tsetReferrerRedirect( window.location.href, prompt );\n\twindow.location.href = ANGIE_INSTALL_URL;\n};\n","import { ANGIE_SIDEBAR_STATE_OPEN, saveState, setReferrerRedirect } from '@elementor-external/angie-sdk';\n\nconst ANGIE_APP_URL = '/wp-admin/admin.php?page=angie-app';\n\nexport const redirectToAppAdmin = ( prompt?: string ) => {\n\tsetReferrerRedirect( window.location.href, prompt );\n\tsaveState( ANGIE_SIDEBAR_STATE_OPEN );\n\twindow.location.href = ANGIE_APP_URL;\n};\n","import apiFetch from '@wordpress/api-fetch';\n\ntype PluginResponse = {\n\tplugin: string;\n\tstatus: 'active' | 'inactive';\n\tname: string;\n};\n\ntype PluginErrorResponse = {\n\tcode: string;\n\tmessage: string;\n};\n\nexport type InstallAngieResult = { success: true } | { success: false; error: string; code?: string };\n\nconst ANGIE_SLUG = 'angie';\n\nconst isPluginErrorResponse = ( response: unknown ): response is PluginErrorResponse => {\n\treturn typeof response === 'object' && response !== null && 'code' in response && 'message' in response;\n};\n\nconst activatePlugin = async ( pluginPath: string ): Promise< PluginResponse > => {\n\treturn apiFetch< PluginResponse >( {\n\t\tpath: `/wp/v2/plugins/${ pluginPath }`,\n\t\tmethod: 'POST',\n\t\tdata: { status: 'active' },\n\t} );\n};\n\nconst installPlugin = async (): Promise< PluginResponse > => {\n\ttry {\n\t\treturn await apiFetch< PluginResponse >( {\n\t\t\tpath: '/wp/v2/plugins',\n\t\t\tmethod: 'POST',\n\t\t\tdata: {\n\t\t\t\tslug: ANGIE_SLUG,\n\t\t\t\tstatus: 'active',\n\t\t\t},\n\t\t} );\n\t} catch ( error: unknown ) {\n\t\tif ( isPluginErrorResponse( error ) && error.code === 'folder_exists' ) {\n\t\t\treturn activatePlugin( `${ ANGIE_SLUG }/${ ANGIE_SLUG }` );\n\t\t}\n\n\t\tthrow error;\n\t}\n};\n\nexport const installAngiePlugin = async (): Promise< InstallAngieResult > => {\n\ttry {\n\t\tawait installPlugin();\n\n\t\treturn { success: true };\n\t} catch ( error: unknown ) {\n\t\tif ( isPluginErrorResponse( error ) ) {\n\t\t\treturn { success: false, error: error.message, code: error.code };\n\t\t}\n\n\t\treturn { success: false, error: 'Unknown error occurred' };\n\t}\n};\n","import apiFetch from '@wordpress/api-fetch';\n\nexport const saveAngieConsent = async (): Promise< void > => {\n\tawait apiFetch( {\n\t\tpath: '/elementor/v1/angie/consent',\n\t\tmethod: 'POST',\n\t} );\n};\n","import { createAndRegisterAdapters, signalMcpReady } from './mcp-registry';\n\nlet isInitialized = false;\nexport async function startMCPServer() {\n\tif ( isInitialized ) {\n\t\treturn;\n\t}\n\tisInitialized = true;\n\ttry {\n\t\tawait createAndRegisterAdapters();\n\t} catch ( error ) {\n\t\t/* eslint-disable-next-line no-console */\n\t\tconsole.error( 'MCP adapter activation failed:', error );\n\t} finally {\n\t\tsignalMcpReady();\n\t}\n}\n\nif ( typeof document !== 'undefined' ) {\n\tdocument.addEventListener( 'DOMContentLoaded', () => void startMCPServer(), { once: true } );\n} else {\n\tvoid startMCPServer();\n}\n","export const MCP_STYLES_APPLIED_EVENT = 'elementor/mcp/styles-applied';\n\nexport type McpStylesAppliedPayload = {\n\tstyleValue: Record< string, unknown >;\n};\n\nexport function dispatchMcpStylesAppliedEvent( payload: McpStylesAppliedPayload ): void {\n\twindow.dispatchEvent( new CustomEvent( MCP_STYLES_APPLIED_EVENT, { detail: payload } ) );\n}\n"],"mappings":";AAAA,SAAS,mBAAmB;AAC5B,SAAS,gBAAgB,wBAAwB;AAEjD,IAAI;AAEJ,IAAM,oBAAN,cAAgC,YAAY;AAAA,EAC3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gB;AAChB,MAAI;AACH,UAAM,0BAA0B;AAAA,EACjC,SAAU,OAAQ;AAEjB,YAAQ,MAAO,kCAAkC,KAAM;AAAA,EACxD,UAAE;AACD,mBAAe;AAAA,EAChB;AACD;AAEA,IAAK,OAAO,aAAa,aAAc;AACtC,WAAS,iBAAkB,oBAAoB,MAAM,KAAK,eAAe,GAAG,EAAE,MAAM,KAAK,CAAE;AAC5F,OAAO;AACN,OAAK,eAAe;AACrB;;;ACtBO,IAAM,2BAA2B;AAMjC,SAAS,8BAA+B,SAAyC;AACvF,SAAO,cAAe,IAAI,YAAa,0BAA0B,EAAE,QAAQ,QAAQ,CAAE,CAAE;AACxF;;;AxBeO,IAAM,cAAc,MAAM,OAAO;","names":["McpServer","SamplingMessageSchema","getAngieIframe","z","sdk","getRegisteredMcpServers","z","getAngieIframe","getAngieIframe","getAngieIframe","toggleAngieSidebar","ANGIE_SIDEBAR_STATE_OPEN","setReferrerRedirect","apiFetch"]}
|
|
1
|
+
{"version":3,"sources":["../src/utils/get-sdk.ts","../src/index.ts","../src/utils/is-angie-available.ts","../src/utils/can-create-widget.ts","../src/utils/is-angie-sidebar-open.ts","../src/mcp-registry.ts","../src/adapters/web-mcp-adapter.ts","../src/utils/register-model-context-tool.ts","../src/angie-annotations.ts","../src/test-utils/mock-mcp-registry.ts","../src/utils/get-model-context.ts","../src/utils/merge-required-resources.ts","../src/utils/create-simple-resource-handler.ts","../src/utils/register-server-docs-resource.ts","../src/utils/to-mcp-title.ts","../src/adapters/angie-adapter.ts","../src/sampler.ts","../src/utils/prompt-builder.ts","../src/utils/get-active-chat-info.ts","../src/utils/open-angie-in-ask-mode.ts","../src/utils/send-prompt-to-angie.ts","../src/utils/redirect-to-installation.ts","../src/utils/redirect-to-app-admin.ts","../src/utils/install-angie-plugin.ts","../src/utils/save-angie-consent.ts","../src/init.ts","../src/events/mcp-styles-applied-event.ts"],"sourcesContent":["import { AngieMcpSdk } from '@elementor-external/angie-sdk';\nexport { getAngieIframe, MessageEventType } from '@elementor-external/angie-sdk';\n\nlet sdk: AngieMcpSdk;\n\nclass RetriableAngieSDK extends AngieMcpSdk {\n\tpublic async waitForReady(): Promise< void > {\n\t\tlet retryCount = 3;\n\t\twhile ( retryCount > 0 ) {\n\t\t\ttry {\n\t\t\t\tawait super.waitForReady();\n\t\t\t\treturn;\n\t\t\t} catch {\n\t\t\t\tretryCount--;\n\t\t\t\tawait sleep();\n\t\t\t}\n\t\t}\n\t\treturn new Promise( () => {} ); // never resolves\n\t}\n}\n\nconst sleep = ( ms = 10_000 ) =>\n\tnew Promise( ( resolve ) => {\n\t\tsetTimeout( resolve, ms );\n\t} );\n\nexport const getSDK = () => {\n\t// @ts-ignore - QUnit fails this\n\tconst isMCPDisabled = !! ( globalThis as Record< string, unknown > ).__ELEMENTOR_MCP_DISABLED__;\n\tif ( isMCPDisabled ) {\n\t\treturn {} as unknown as AngieMcpSdk;\n\t}\n\tif ( ! sdk ) {\n\t\tsdk = new RetriableAngieSDK();\n\t}\n\treturn sdk;\n};\n","import './types/open-angie-request';\n\nimport { getSDK } from './utils/get-sdk';\nexport { getAngieIframe, MessageEventType as AngieMessageEvenetType } from './utils/get-sdk';\n\nexport {\n\tMcpServer,\n\tResourceTemplate,\n\ttype RegisteredResource,\n\ttype ToolCallback,\n} from '@modelcontextprotocol/sdk/server/mcp.js';\nexport { SamplingMessageSchema } from '@modelcontextprotocol/sdk/types.js';\nexport { isAngieAvailable } from './utils/is-angie-available';\nexport { canCreateWidget } from './utils/can-create-widget';\nexport { isAngieSidebarOpen } from './utils/is-angie-sidebar-open';\nexport * from './mcp-registry';\nexport { AngieMcpAdapter } from './adapters/angie-adapter';\nexport type { IMcpRegistrationAdapter } from './adapters/types';\nexport { createSampler } from './sampler';\nexport { toolPrompts } from './utils/prompt-builder';\nexport { ANGIE_MODEL_PREFERENCES, ANGIE_REQUIRED_RESOURCES, type AngieModelPreferences } from './angie-annotations';\nexport { getActiveChatInfo, type ActiveChatInfo } from './utils/get-active-chat-info';\nexport { hasLoadedEditorAngie, openAngieInAgentMode, openAngieInAskMode } from './utils/open-angie-in-ask-mode';\nexport type {\n\tEditorAngieWindowHost,\n\tOpenAngieCommonProperties,\n\tOpenAngiePluginProperties,\n\tOpenAngieRequest,\n\tOpenAngieSdkProperties,\n} from './types/open-angie-request';\nexport { sendPromptToAngie } from './utils/send-prompt-to-angie';\nexport { redirectToInstallation } from './utils/redirect-to-installation';\nexport { redirectToAppAdmin } from './utils/redirect-to-app-admin';\nexport { installAngiePlugin, type InstallAngieResult } from './utils/install-angie-plugin';\nexport { saveAngieConsent } from './utils/save-angie-consent';\nexport const getAngieSdk = () => getSDK();\nexport * from './init';\nexport {\n\tdispatchMcpStylesAppliedEvent,\n\tMCP_STYLES_APPLIED_EVENT,\n\ttype McpStylesAppliedPayload,\n} from './events/mcp-styles-applied-event';\n","import { getAngieIframe } from '@elementor-external/angie-sdk';\n\nexport const isAngieAvailable = (): boolean => {\n\treturn !! getAngieIframe();\n};\n","export const canCreateWidget = (): boolean => {\n\treturn Boolean( window.elementor?.config?.widgetCreation?.canCreateWidget );\n};\n","import { ANGIE_SIDEBAR_STATE_OPEN, getAngieSidebarSavedState } from '@elementor-external/angie-sdk';\n\nexport const isAngieSidebarOpen = (): boolean => {\n\treturn getAngieSidebarSavedState() === ANGIE_SIDEBAR_STATE_OPEN;\n};\n","import { z, type z3 } from '@elementor/schema';\nimport { McpServer, type ToolCallback } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { type RequestHandlerExtra } from '@modelcontextprotocol/sdk/shared/protocol.js';\nimport { type ServerNotification, type ServerRequest } from '@modelcontextprotocol/sdk/types.js';\n\nimport { type IMcpRegistrationAdapter, type McpResourceHandler, type McpResourceUriOrTemplate } from './adapters/types';\nimport { WebMCPAdapter } from './adapters/web-mcp-adapter';\nimport {\n\tANGIE_MODEL_PREFERENCES,\n\tANGIE_REQUIRED_RESOURCES,\n\ttype AngieModelPreferences,\n\tcreateDefaultModelPreferences,\n} from './angie-annotations';\nimport { mockMcpRegistry } from './test-utils/mock-mcp-registry';\nimport { getModelContext } from './utils/get-model-context';\nimport { mergeRequiredResources, type ResourceList } from './utils/merge-required-resources';\nimport { registerServerDocsResource } from './utils/register-server-docs-resource';\nimport { toMCPTitle } from './utils/to-mcp-title';\n\ntype ZodRawShape = z3.ZodRawShape;\n\nconst mcpRegistry: { [ namespace: string ]: McpServer } = {};\nconst mcpDescriptions: { [ namespace: string ]: string } = {};\n// @ts-ignore - QUnit fails this\nconst isMcpRegistrationActivated = false || typeof globalThis.jest !== 'undefined';\n\nconst registrationAdapters: IMcpRegistrationAdapter[] = [];\nconst bufferedTools: Parameters< IMcpRegistrationAdapter[ 'onToolRegistered' ] >[] = [];\nconst bufferedResources: Parameters< IMcpRegistrationAdapter[ 'onResourceRegistered' ] >[] = [];\n\nlet resolveReady!: () => void;\nconst readyPromise = new Promise< void >( ( resolve ) => {\n\tresolveReady = resolve;\n} );\n\nexport const registerMcpAdapter = ( adapter: IMcpRegistrationAdapter ): void => {\n\tregistrationAdapters.push( adapter );\n\tfor ( const tool of bufferedTools ) {\n\t\ttry {\n\t\t\tadapter.onToolRegistered( tool[ 0 ], tool[ 1 ] );\n\t\t} catch {\n\t\t\t// exit quietly\n\t\t}\n\t}\n\tfor ( const resource of bufferedResources ) {\n\t\ttry {\n\t\t\tadapter.onResourceRegistered( ...resource );\n\t\t} catch {\n\t\t\t// exit quietly\n\t\t}\n\t}\n};\n\nexport const signalMcpReady = (): void => {\n\tresolveReady();\n};\n\nexport const waitForMcpReady = (): Promise< void > => readyPromise;\n\n/**\n * Registers and activates an adapter that becomes available after startup.\n * Waits for the startup activation so the adapter is activated exactly once.\n *\n * @param adapter - Adapter to register and activate.\n */\nexport const activateMcpAdapter = async ( adapter: IMcpRegistrationAdapter ): Promise< void > => {\n\tawait readyPromise;\n\tregisterMcpAdapter( adapter );\n\tawait adapter.activate();\n};\n\nexport const createAndRegisterAdapters = async (): Promise< void > => {\n\tconst modelContext = getModelContext();\n\n\tif ( modelContext ) {\n\t\tregisterMcpAdapter( new WebMCPAdapter( modelContext ) );\n\t}\n\n\tawait Promise.all( registrationAdapters.map( ( adapter ) => adapter.activate() ) );\n};\n\n// utility function to run a callback on all MCP interfaces\nfunction callAdapters( fn: ( adapter: IMcpRegistrationAdapter ) => unknown ) {\n\tfor ( const adapter of registrationAdapters ) {\n\t\ttry {\n\t\t\tfn( adapter );\n\t\t} catch {\n\t\t\t// adapter failed — exit quietly, continue to next\n\t\t}\n\t}\n}\n\nexport const registerMcp = ( mcp: McpServer, name: string ) => {\n\tconst mcpName = isAlphabet( name );\n\tmcpRegistry[ mcpName ] = mcp;\n};\n\nexport const getRegisteredMcpServers = (): Array< [ string, McpServer, string ] > => {\n\treturn Object.entries( mcpRegistry ).map( ( [ key, server ] ) => [ key, server, mcpDescriptions[ key ] || key ] );\n};\n\nconst isAlphabet = ( str: string ): string | never => {\n\tconst passes = !! str && /^[a-z_]+$/.test( str );\n\tif ( ! passes ) {\n\t\tthrow new Error( 'Not alphabet' );\n\t}\n\treturn str;\n};\n\n/**\n * @param namespace The namespace of the MCP server. It should contain only lowercase alphabetic characters.\n * @param options\n * @param options.instructions Short hint about the MCP and its toolset (MCP SDK `instructions`; keeps payload small).\n * @param options.docs Full documentation registered as a lazy-loaded resource.\n * When provided, it is registered at elementor://{namespace}/server-docs\n * and auto-injected into every tool's requiredResources.\n */\nexport const getMCPByDomain = (\n\tnamespace: string,\n\toptions?: { docs?: string; instructions?: string }\n): MCPRegistryEntry => {\n\tconst mcpName = `editor-${ isAlphabet( namespace ) }`;\n\tconst title = toMCPTitle( namespace );\n\t// @ts-ignore - QUnit fails this\n\tif ( typeof globalThis.jest !== 'undefined' ) {\n\t\treturn mockMcpRegistry();\n\t}\n\tif ( ! mcpRegistry[ namespace ] ) {\n\t\tmcpRegistry[ namespace ] = new McpServer(\n\t\t\t{ name: mcpName, title, version: '1.0.0' },\n\t\t\t{ instructions: options?.instructions, capabilities: { resources: { subscribe: true } } }\n\t\t);\n\t\tif ( options?.docs ) {\n\t\t\tregisterServerDocsResource( mcpRegistry[ namespace ], namespace, title, options.docs, ( ...args ) => {\n\t\t\t\tbufferedResources.push( args );\n\t\t\t\tcallAdapters( ( adapter ) => adapter.onResourceRegistered( ...args ) );\n\t\t\t} );\n\t\t}\n\t}\n\tconst mcpServer = mcpRegistry[ namespace ];\n\tconst serverDocsUri = options?.docs ? `elementor://${ namespace }/server-docs` : undefined;\n\tconst { addTool } = createToolRegistry( mcpServer, mcpName, serverDocsUri );\n\treturn {\n\t\twaitForReady: () => readyPromise,\n\t\t// @ts-expect-error: TS is unable to infer the type here\n\t\tresource: async ( ...args: Parameters< McpServer[ 'registerResource' ] > ) => {\n\t\t\tconst [ name, uriOrTemplate, ...rest ] = args as [ string, unknown, ...unknown[] ];\n\t\t\tconst handler = rest[ rest.length - 1 ] as McpResourceHandler;\n\t\t\tconst resourceArgs: Parameters< IMcpRegistrationAdapter[ 'onResourceRegistered' ] > = [\n\t\t\t\tname,\n\t\t\t\turiOrTemplate as McpResourceUriOrTemplate,\n\t\t\t\thandler,\n\t\t\t];\n\t\t\tbufferedResources.push( resourceArgs );\n\t\t\tcallAdapters( ( adapter ) => adapter.onResourceRegistered( ...resourceArgs ) );\n\t\t\treturn mcpServer.registerResource( ...args );\n\t\t},\n\t\tsendResourceUpdated: ( ...args: Parameters< McpServer[ 'server' ][ 'sendResourceUpdated' ] > ) => {\n\t\t\tcallAdapters( ( adapter ) => adapter.sendResourceUpdated( { uri: args[ 0 ].uri } ) );\n\t\t\treturn Promise.resolve( mcpServer.server.sendResourceUpdated( ...args ) ).catch( ( error: Error ) => {\n\t\t\t\tif ( error?.message?.includes( 'Not connected' ) ) {\n\t\t\t\t\treturn; // Expected when no MCP client is connected yet\n\t\t\t\t}\n\t\t\t\tif ( error?.message?.includes( 'does not support notifying about resources' ) ) {\n\t\t\t\t\treturn; // Server capability not declared — safe to ignore\n\t\t\t\t}\n\t\t\t\tthrow error;\n\t\t\t} );\n\t\t},\n\t\taddTool,\n\t\tsetMCPDescription: ( description: string ) => {\n\t\t\tmcpDescriptions[ namespace ] = description;\n\t\t},\n\t};\n};\n\nexport interface MCPRegistryEntry {\n\taddTool: < T extends undefined | z.ZodRawShape = undefined, O extends undefined | z.ZodRawShape = undefined >(\n\t\topts: ToolRegistrationOptions< T, O >\n\t) => void;\n\tsetMCPDescription: ( description: string ) => void;\n\tsendResourceUpdated: McpServer[ 'server' ][ 'sendResourceUpdated' ];\n\tresource: McpServer[ 'registerResource' ];\n\twaitForReady: () => Promise< void >;\n}\n\ntype ToolRegistrationOptions<\n\tInputArgs extends undefined | z.ZodRawShape = undefined,\n\tOutputSchema extends undefined | z.ZodRawShape = undefined,\n\tExpectedOutput = OutputSchema extends z.ZodRawShape ? z.objectOutputType< OutputSchema, z.ZodTypeAny > : string,\n> = {\n\tname: string;\n\tdescription: string;\n\tschema?: InputArgs;\n\t/**\n\t * Auto added fields:\n\t * @param errors z.string().optional().describe('Error message if the tool failed')\n\t */\n\toutputSchema?: OutputSchema;\n\thandler: InputArgs extends z.ZodRawShape\n\t\t? (\n\t\t\t\targs: z.objectOutputType< InputArgs, z.ZodTypeAny >,\n\t\t\t\textra: RequestHandlerExtra< ServerRequest, ServerNotification >\n\t\t ) => ExpectedOutput | Promise< ExpectedOutput >\n\t\t: (\n\t\t\t\targs: unknown,\n\t\t\t\textra: RequestHandlerExtra< ServerRequest, ServerNotification >\n\t\t ) => ExpectedOutput | Promise< ExpectedOutput >;\n\tisDestructive?: boolean;\n\trequiredResources?: ResourceList;\n\tmodelPreferences?: AngieModelPreferences;\n};\n\nfunction createToolRegistry( server: McpServer, serverName: string, serverDocsUri?: string ) {\n\tfunction addTool<\n\t\tT extends undefined | z.ZodRawShape = undefined,\n\t\tO extends undefined | z.ZodRawShape = undefined,\n\t>( opts: ToolRegistrationOptions< T, O > ) {\n\t\tconst outputSchema = opts.outputSchema as ZodRawShape | undefined;\n\t\tif ( outputSchema ) {\n\t\t\tObject.assign(\n\t\t\t\toutputSchema,\n\t\t\t\toutputSchema.errors ?? {\n\t\t\t\t\terrors: z.string().optional().describe( 'Error message if the tool failed' ),\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t\t// @ts-ignore: TS is unable to infer the type here\n\t\tconst inputSchema: ZodRawShape = opts.schema ? opts.schema : {};\n\t\tconst toolCallback: ToolCallback< ZodRawShape > = async function ( args, extra ) {\n\t\t\ttry {\n\t\t\t\tconst invocationResult = await opts.handler( opts.schema ? args : {}, extra );\n\t\t\t\treturn {\n\t\t\t\t\t// structuredContent: typeof invocationResult === 'string' ? undefined : invocationResult,\n\t\t\t\t\tcontent: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: 'text',\n\t\t\t\t\t\t\ttext:\n\t\t\t\t\t\t\t\ttypeof invocationResult === 'string'\n\t\t\t\t\t\t\t\t\t? invocationResult\n\t\t\t\t\t\t\t\t\t: JSON.stringify( invocationResult ),\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t};\n\t\t\t} catch ( error ) {\n\t\t\t\treturn {\n\t\t\t\t\tisError: true,\n\t\t\t\t\tstructuredContent: {\n\t\t\t\t\t\terrors: ( error as Error ).message || 'Unknown error',\n\t\t\t\t\t},\n\t\t\t\t\tcontent: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: 'text',\n\t\t\t\t\t\t\ttext:\n\t\t\t\t\t\t\t\t( ( error as Error ).message || 'Unknown error' ) +\n\t\t\t\t\t\t\t\tJSON.stringify( ( error as { response?: { data: unknown } } ).response?.data || error ),\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t};\n\t\t\t}\n\t\t};\n\t\tconst annotations: Record< string, unknown > = {\n\t\t\tdestructiveHint: opts.isDestructive,\n\t\t\treadOnlyHint: opts.isDestructive ? false : undefined,\n\t\t\ttitle: opts.name,\n\t\t};\n\t\tconst mergedResources = mergeRequiredResources( opts.requiredResources, serverDocsUri );\n\t\tconst angieAnnotations = {\n\t\t\t[ ANGIE_MODEL_PREFERENCES ]: opts.modelPreferences ?? createDefaultModelPreferences(),\n\t\t\t[ ANGIE_REQUIRED_RESOURCES ]: mergedResources,\n\t\t};\n\t\tserver.registerTool(\n\t\t\topts.name,\n\t\t\t{\n\t\t\t\tdescription: opts.description,\n\t\t\t\tinputSchema,\n\t\t\t\t// TODO: Uncomment this when the outputSchema is stable\n\t\t\t\t// outputSchema,\n\t\t\t\ttitle: opts.name,\n\t\t\t\tannotations,\n\t\t\t\t_meta: angieAnnotations,\n\t\t\t},\n\t\t\ttoolCallback\n\t\t);\n\t\tconst toolDescriptor = {\n\t\t\tname: opts.name,\n\t\t\tdescription: opts.description,\n\t\t\tinputSchema: inputSchema as object,\n\t\t\texecute: ( params: Record< string, unknown > ) =>\n\t\t\t\ttoolCallback(\n\t\t\t\t\tparams as Parameters< typeof toolCallback >[ 0 ],\n\t\t\t\t\t/* WebMCP: no protocol session — handlers must not rely on `extra` here */\n\t\t\t\t\t{} as RequestHandlerExtra< ServerRequest, ServerNotification >\n\t\t\t\t) as Promise< unknown >,\n\t\t};\n\t\tconst extraData = {\n\t\t\tresources: [ `Server resource name: ${ serverName }, Required to fetch!` ],\n\t\t\trequiredResources: mergedResources?.map( ( resource ) => resource.uri ) ?? [],\n\t\t};\n\t\tbufferedTools.push( [ toolDescriptor, extraData ] );\n\t\tcallAdapters( ( adapter ) => adapter.onToolRegistered( toolDescriptor, extraData ) );\n\t\tif ( isMcpRegistrationActivated ) {\n\t\t\tserver.sendToolListChanged();\n\t\t}\n\t}\n\treturn {\n\t\taddTool,\n\t};\n}\n","import { zodToJsonSchema } from 'zod-to-json-schema';\nimport { z, type z3 } from '@elementor/schema';\n\nimport { type ModelContextRegisterTool, registerModelContextTool } from '../utils/register-model-context-tool';\nimport {\n\ttype IMcpRegistrationAdapter,\n\ttype McpResourceHandler,\n\ttype McpResourceUriOrTemplate,\n\ttype McpToolDescriptor,\n\ttype UriTemplate,\n} from './types';\n\ntype ZodRawShape = z3.ZodRawShape;\n\nexport type ModelContext = {\n\tregisterTool: ModelContextRegisterTool;\n\tunregisterTool?: ( name: string ) => void;\n};\n\ntype ResourceEntry = {\n\tpattern: string;\n\tmatch: ( uri: string ) => Record< string, string | string[] > | null;\n\thandler: McpResourceHandler;\n};\n\nexport class WebMCPAdapter implements IMcpRegistrationAdapter {\n\tprivate readonly registeredToolNames = new Set< string >();\n\tprivate readonly resourceEntries: ResourceEntry[] = [];\n\tprivate activated = false;\n\n\tconstructor( private readonly ctx: ModelContext ) {}\n\n\tactivate(): Promise< void > {\n\t\tif ( this.activated ) {\n\t\t\treturn Promise.resolve();\n\t\t}\n\t\tthis.activated = true;\n\t\treturn registerModelContextTool( this.ctx.registerTool, {\n\t\t\tname: 'editor-resource-getter',\n\t\t\tdescription:\n\t\t\t\t'Get an editor resource by URI, or search for available resources by partial URI. Pass a full URI to retrieve content, or a partial string to discover matching patterns.',\n\t\t\tinputSchema: {\n\t\t\t\ttype: 'object',\n\t\t\t\tproperties: {\n\t\t\t\t\turi: {\n\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t'A full resource URI (e.g. elementor://style/best-practices) or a partial string to search across available resource patterns.',\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\trequired: [ 'uri' ],\n\t\t\t},\n\t\t\texecute: async ( params ) => {\n\t\t\t\tconst query = params.uri as string;\n\t\t\t\tconst entries = this.resourceEntries;\n\n\t\t\t\tif ( entries.length === 0 ) {\n\t\t\t\t\treturn 'No resources are registered yet.';\n\t\t\t\t}\n\n\t\t\t\t// Exact URI match\n\t\t\t\tfor ( const entry of entries ) {\n\t\t\t\t\tconst variables = entry.match( query );\n\t\t\t\t\tif ( variables !== null ) {\n\t\t\t\t\t\tlet resourceUrl: URL;\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tresourceUrl = new URL( query );\n\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\treturn `Invalid URI '${ query }'. Provide a valid resource URI or a partial string to search patterns.`;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst result = await entry.handler( resourceUrl, variables );\n\t\t\t\t\t\treturn result.contents?.[ 0 ]?.text ?? JSON.stringify( result );\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Partial search fallback\n\t\t\t\tconst matches = entries.map( ( e ) => e.pattern ).filter( ( pattern ) => pattern.includes( query ) );\n\t\t\t\tif ( matches.length > 0 ) {\n\t\t\t\t\treturn `Found ${ matches.length } matching resource pattern(s):\\n${ matches.join(\n\t\t\t\t\t\t'\\n'\n\t\t\t\t\t) }\\n\\nProvide a full URI to retrieve the resource content.`;\n\t\t\t\t}\n\n\t\t\t\tconst available = entries.map( ( e ) => e.pattern ).join( '\\n' );\n\t\t\t\tthrow new Error( `No resource matched '${ query }'.\\n\\nAvailable patterns:\\n${ available }` );\n\t\t\t},\n\t\t} );\n\t}\n\n\tonToolRegistered(\n\t\ttool: McpToolDescriptor,\n\t\textraData?: { resources: string[]; requiredResources: string[] }\n\t): void {\n\t\tlet jsonSchema: object;\n\t\ttry {\n\t\t\tjsonSchema = zodToJsonSchema( z.object( tool.inputSchema as ZodRawShape ) );\n\t\t} catch {\n\t\t\tjsonSchema = tool.inputSchema;\n\t\t}\n\n\t\tif ( this.registeredToolNames.has( tool.name ) ) {\n\t\t\tthis.ctx.unregisterTool?.( tool.name );\n\t\t\tthis.registeredToolNames.delete( tool.name );\n\t\t}\n\n\t\tlet resourcesDescription = '';\n\t\tif ( extraData ) {\n\t\t\tif ( extraData.resources?.length > 0 ) {\n\t\t\t\tresourcesDescription += `#Resources:\\n${ extraData.resources?.join( '\\n' ) }\\n\\n`;\n\t\t\t}\n\t\t\tif ( extraData.requiredResources?.length > 0 ) {\n\t\t\t\tresourcesDescription += `#Required Resources:\\n${ extraData.requiredResources?.join( '\\n' ) }\\n\\n`;\n\t\t\t}\n\t\t\tresourcesDescription += `To read resources, use editor-resource-getter tool.\\n\\n`;\n\t\t}\n\t\tvoid registerModelContextTool( this.ctx.registerTool, {\n\t\t\tname: tool.name,\n\t\t\tdescription: `${ resourcesDescription }${ tool.description }`,\n\t\t\tinputSchema: jsonSchema,\n\t\t\texecute: tool.execute,\n\t\t} ).then( () => {\n\t\t\tthis.registeredToolNames.add( tool.name );\n\t\t} );\n\t}\n\n\tonResourceRegistered( _name: string, uriOrTemplate: McpResourceUriOrTemplate, handler: McpResourceHandler ): void {\n\t\tif ( typeof uriOrTemplate === 'string' ) {\n\t\t\tthis.resourceEntries.push( {\n\t\t\t\tpattern: uriOrTemplate,\n\t\t\t\tmatch: ( uri ) => ( uri === uriOrTemplate ? {} : null ),\n\t\t\t\thandler,\n\t\t\t} );\n\t\t} else {\n\t\t\tconst template = uriOrTemplate.uriTemplate as UriTemplate;\n\t\t\tthis.resourceEntries.push( {\n\t\t\t\tpattern: template.toString(),\n\t\t\t\tmatch: ( uri ) => template.match( uri ),\n\t\t\t\thandler,\n\t\t\t} );\n\t\t}\n\t}\n\n\tsendResourceUpdated(): void {\n\t\t// WebMCP has no server-push mechanism — no-op\n\t}\n}\n","import { type McpToolDescriptor } from '../adapters/types';\n\nexport type ModelContextRegisterTool = ( tool: McpToolDescriptor ) => void | Promise< void >;\n\nexport async function registerModelContextTool(\n\tregisterTool: ModelContextRegisterTool,\n\ttool: McpToolDescriptor\n): Promise< void > {\n\ttry {\n\t\tawait Promise.resolve( registerTool( tool ) );\n\t} catch ( error ) {\n\t\t/* eslint-disable-next-line no-console */\n\t\tconsole.error( 'Tool registration failed:', error );\n\t}\n}\n","export const ANGIE_MODEL_PREFERENCES = 'angie/modelPreferences' as const;\nexport const ANGIE_REQUIRED_RESOURCES = 'angie/requiredResources' as const;\n\nexport interface AngieModelPreferences {\n\thints?: Array< { name: string } >;\n\tcostPriority?: number; // 0-1 (future use)\n\tspeedPriority?: number; // 0-1 (future use)\n\tintelligencePriority?: number; // 0-1 (future use)\n}\n\nexport function createDefaultModelPreferences(): AngieModelPreferences {\n\treturn {\n\t\thints: [ { name: 'claude-sonnet-4-6' } ],\n\t};\n}\n","import { type McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\n\nimport { type MCPRegistryEntry } from '../mcp-registry';\n\nconst mock = new Proxy(\n\t{},\n\t{\n\t\tget: () => {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unused-vars\n\t\t\tfunction mockedFn( ..._: unknown[] ) {}\n\t\t\treturn mockedFn;\n\t\t},\n\t}\n);\n\nexport const mockMcpRegistry = (): MCPRegistryEntry => {\n\treturn {\n\t\t// @ts-ignore\n\t\tresource: async () => {},\n\t\t// @ts-ignore\n\t\tsendResourceUpdated: () => {},\n\t\taddTool: () => {},\n\t\tsetMCPDescription: () => {},\n\t\tmcpServer: mock as McpServer,\n\t};\n};\n","import { type ModelContext } from '../adapters/web-mcp-adapter';\n\ntype ModelContextHost = {\n\tmodelContext?: ModelContext;\n};\n\nfunction bindModelContextMethods( host: ModelContext ): ModelContext {\n\treturn {\n\t\tregisterTool: host.registerTool.bind( host ),\n\t\tunregisterTool: host.unregisterTool ? host.unregisterTool.bind( host ) : undefined,\n\t};\n}\n\nexport function getModelContext(): ModelContext | undefined {\n\tconst documentModelContext =\n\t\ttypeof document !== 'undefined' ? ( document as unknown as ModelContextHost ).modelContext : undefined;\n\tif ( documentModelContext?.registerTool ) {\n\t\treturn bindModelContextMethods( documentModelContext );\n\t}\n\tconst navigatorModelContext =\n\t\ttypeof navigator !== 'undefined' ? ( navigator as unknown as ModelContextHost ).modelContext : undefined;\n\tif ( navigatorModelContext?.registerTool ) {\n\t\treturn bindModelContextMethods( navigatorModelContext );\n\t}\n\n\treturn undefined;\n}\n","export type ResourceList = {\n\turi: string;\n\tdescription: string;\n}[];\n\nexport const mergeRequiredResources = (\n\ttoolResources: ResourceList | undefined,\n\tserverDocsUri: string | undefined\n): ResourceList | undefined => {\n\tif ( ! serverDocsUri ) {\n\t\treturn toolResources;\n\t}\n\tif ( toolResources?.some( ( r ) => r.uri === serverDocsUri ) ) {\n\t\treturn toolResources;\n\t}\n\treturn [ ...( toolResources ?? [] ), { uri: serverDocsUri, description: 'Server docs' } ];\n};\n","export const createSimpleResourceHandler = ( text: string ) => async ( uri: URL ) => ( {\n\tcontents: [ { uri: uri.href, mimeType: 'text/plain', text } ],\n} );\n","import { type McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\n\nimport { type IMcpRegistrationAdapter } from '../adapters/types';\nimport { createSimpleResourceHandler } from './create-simple-resource-handler';\n\ntype OnResourceRegistered = ( ...args: Parameters< IMcpRegistrationAdapter[ 'onResourceRegistered' ] > ) => void;\n\nexport const registerServerDocsResource = (\n\tserver: McpServer,\n\tnamespace: string,\n\ttitle: string,\n\tdocs: string,\n\tonRegistered: OnResourceRegistered\n): void => {\n\tconst uri = `elementor://${ namespace }/server-docs`;\n\tconst name = `${ namespace }-server-docs`;\n\tconst handler = createSimpleResourceHandler( docs );\n\tserver.registerResource(\n\t\tname,\n\t\turi,\n\t\t{\n\t\t\ttitle: `${ title } server docs`,\n\t\t\tdescription: 'Full MCP documentation (lazy-loaded)',\n\t\t\tmimeType: 'text/plain',\n\t\t},\n\t\thandler\n\t);\n\tonRegistered( name, uri, handler );\n};\n","export const toMCPTitle = ( namespace: string ): string => {\n\tconst capitalized = namespace.charAt( 0 ).toUpperCase() + namespace.slice( 1 );\n\treturn `Editor ${ capitalized }`;\n};\n","import { type AngieMcpSdk } from '@elementor-external/angie-sdk';\n\nimport { type getRegisteredMcpServers as _getRegisteredMcpServers } from '../mcp-registry';\nimport { toMCPTitle } from '../utils/to-mcp-title';\nimport { type IMcpRegistrationAdapter } from './types';\n\nconst MAX_RETRIES = 3;\n\nexport class AngieMcpAdapter implements IMcpRegistrationAdapter {\n\tconstructor(\n\t\tprivate readonly sdk: AngieMcpSdk,\n\t\tprivate readonly getRegisteredMcpServers: typeof _getRegisteredMcpServers\n\t) {}\n\n\tasync activate(): Promise< void > {\n\t\t// No waitForReady() here: registerLocalServer queues the server and the SDK flushes\n\t\t// the queue once Angie reports ready. waitForReady() only resolves for the SDK copy\n\t\t// that booted the sidebar, which is the host integration, never the editor bundle.\n\t\tawait this.registerEntries( this.getRegisteredMcpServers(), MAX_RETRIES );\n\t}\n\n\tprivate async registerEntries(\n\t\tentries: ReturnType< typeof _getRegisteredMcpServers >,\n\t\tretry: number\n\t): Promise< void > {\n\t\tif ( retry === 0 ) {\n\t\t\t/* eslint-disable-next-line no-console */\n\t\t\tconsole.error(\n\t\t\t\t'Failed to register MCP after 3 retries. failed entries: ',\n\t\t\t\tentries.map( ( [ key ] ) => key )\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tconst failed: typeof entries = [];\n\t\tfor ( const [ key, mcpServer, description ] of entries ) {\n\t\t\ttry {\n\t\t\t\tawait this.sdk.registerLocalServer( {\n\t\t\t\t\ttitle: toMCPTitle( key ),\n\t\t\t\t\tname: `editor-${ key }`,\n\t\t\t\t\tserver: mcpServer,\n\t\t\t\t\tversion: '1.0.0',\n\t\t\t\t\tdescription,\n\t\t\t\t} );\n\t\t\t} catch {\n\t\t\t\tfailed.push( [ key, mcpServer, description ] );\n\t\t\t}\n\t\t}\n\n\t\tif ( failed.length > 0 ) {\n\t\t\treturn this.registerEntries( failed, retry - 1 );\n\t\t}\n\t}\n\n\tonToolRegistered(): void {\n\t\t// Angie tools are registered via McpServer (at activate time).\n\t}\n\n\tonResourceRegistered(): void {\n\t\t// Resources are registered on the McpServer instance directly.\n\t}\n\n\tsendResourceUpdated(): void {\n\t\t// Resource update notifications are sent via MCPRegistryEntry.sendResourceUpdated.\n\t}\n}\n","import { type z } from '@elementor/schema';\nimport { type RequestHandlerExtra } from '@modelcontextprotocol/sdk/shared/protocol.js';\nimport { SamplingMessageSchema, type ServerNotification, type ServerRequest } from '@modelcontextprotocol/sdk/types.js';\n\ntype Server = RequestHandlerExtra< ServerRequest, ServerNotification >;\ntype Opts = {\n\tmaxTokens?: number;\n\tmodelPreferences?: string;\n\tmodel?: string;\n};\n\nconst DEFAULT_OPTS: Opts = {\n\tmaxTokens: 10000,\n\tmodelPreferences: 'openai',\n\tmodel: 'gpt-4o',\n};\n\ntype SamplingOpts = {\n\tsystemPrompt?: string;\n\tstructuredOutput?: z.ZodTypeAny;\n\tmessages: { role: 'user' | 'assistant'; content: { type: 'text'; text: string } }[];\n\trequestParams?: { [ key: string ]: string };\n};\n\nconst DEFAULT_STRUCTURED_OUTPUT = {\n\ttype: 'object',\n\tproperties: {\n\t\tcontent: {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Result',\n\t\t},\n\t},\n\trequired: [ 'content' ],\n\tadditionalProperties: false,\n};\n\nexport const createSampler = ( server: Server, opts: Opts = DEFAULT_OPTS ) => {\n\tconst { maxTokens = 1000, modelPreferences = 'openai', model = 'gpt-4o' } = opts;\n\tconst exec = async ( payload: SamplingOpts ) => {\n\t\tconst systemPromptObject = { ...( payload.systemPrompt ? { systemPrompt: payload.systemPrompt } : {} ) };\n\t\tconst requestParams = payload.requestParams || {};\n\t\tconst result = await server.sendRequest(\n\t\t\t{\n\t\t\t\tmethod: 'sampling/createMessage',\n\t\t\t\tparams: {\n\t\t\t\t\t...requestParams,\n\t\t\t\t\tmaxTokens,\n\t\t\t\t\tmodelPreferences: {\n\t\t\t\t\t\thints: [ { name: modelPreferences } ],\n\t\t\t\t\t},\n\t\t\t\t\tmetadata: {\n\t\t\t\t\t\tmodel,\n\t\t\t\t\t\t...systemPromptObject,\n\t\t\t\t\t\t...{ structured_output: payload.structuredOutput || DEFAULT_STRUCTURED_OUTPUT },\n\t\t\t\t\t},\n\t\t\t\t\tmessages: payload.messages,\n\t\t\t\t},\n\t\t\t\t// ...systemPromptObject,\n\t\t\t},\n\t\t\tSamplingMessageSchema\n\t\t);\n\t\treturn result.content;\n\t};\n\treturn exec;\n};\n","class ToolPrompts {\n\tpublic _description = '';\n\tpublic _parameters: Record< string, string > = {};\n\tpublic _examples: string[] = [];\n\tpublic _furtherInstructions: string[] = [];\n\n\tconstructor( public name: string ) {}\n\n\tdescription(): string;\n\tdescription( desc: string ): this;\n\tdescription( desc?: string | undefined ) {\n\t\tif ( typeof desc === 'undefined' ) {\n\t\t\treturn this._description;\n\t\t}\n\t\tthis._description = desc;\n\t\treturn this;\n\t}\n\n\tparameter( key: string ): string;\n\tparameter( key: string, description: string ): this;\n\tparameter( key: string, description?: string ) {\n\t\tif ( typeof description === 'undefined' ) {\n\t\t\treturn this._parameters[ key ];\n\t\t}\n\t\tthis._parameters[ key ] = `**${ key }**:\\n${ description }`;\n\t\treturn this;\n\t}\n\n\tinstruction( instruction: string ): this {\n\t\tthis._furtherInstructions.push( instruction );\n\t\treturn this;\n\t}\n\n\texample( example: string ): this {\n\t\tthis._examples.push( example );\n\t\treturn this;\n\t}\n\n\tpublic get examples() {\n\t\treturn this._examples.join( '\\n\\n' );\n\t}\n\n\tprompt(): string {\n\t\treturn `# ${ this.name }\n# Description\n${ this._description }\n${ this._parameters.length ? '# Parameters\\n' + Object.values( this._parameters ).join( '\\n\\n' ) : '' }\n${ this._examples.length ? '# Examples\\n' + this.examples : '' }\n${ this._furtherInstructions.length ? '# Further Instructions\\n' + this._furtherInstructions.join( '\\n\\n' ) : '' }\n`.trim();\n\t}\n}\n\nexport const toolPrompts = ( name: string ) => {\n\treturn new ToolPrompts( name );\n};\n","export type ActiveChatInfo = {\n\tsessionId: string;\n\texpiresAt: number;\n};\n\nexport const getActiveChatInfo = (): ActiveChatInfo => {\n\tconst info = localStorage.getItem( 'angie_active_chat_id' );\n\tif ( ! info ) {\n\t\treturn {\n\t\t\texpiresAt: 0,\n\t\t\tsessionId: '',\n\t\t};\n\t}\n\tconst rawData = JSON.parse( info );\n\treturn {\n\t\texpiresAt: rawData.expiresAt as number,\n\t\tsessionId: rawData.sessionId as string,\n\t};\n};\n","import {\n\tAngieInteractionMode,\n\tgetAngieIframe,\n\tsetAngieInteractionMode,\n\ttoggleAngieSidebar,\n} from '@elementor-external/angie-sdk';\n\nimport { isAngieAvailable } from './is-angie-available';\n\nconst getLoadedEditorAngie = () => {\n\treturn window.elementorV2?.editorAngie?.openAngie;\n};\n\nexport const hasLoadedEditorAngie = (): boolean => Boolean( getLoadedEditorAngie() );\n\nexport const openLoadedEditorAngie = ( prompt: string | undefined, mode: AngieInteractionMode ): boolean => {\n\tconst openAngie = getLoadedEditorAngie();\n\n\tif ( ! openAngie ) {\n\t\treturn false;\n\t}\n\n\tPromise.resolve( openAngie( { prompt: prompt ?? '', mode } ) ).catch( ( error ) => {\n\t\t// eslint-disable-next-line no-console\n\t\tconsole.error( 'Failed to open Angie:', error );\n\t} );\n\n\treturn true;\n};\n\nexport const openAngieInAskMode = ( prompt?: string ): void => {\n\topenAngieInMode( prompt, AngieInteractionMode.ASK );\n};\n\nexport const openAngieInAgentMode = ( prompt?: string ): void => {\n\topenAngieInMode( prompt, AngieInteractionMode.AGENT );\n};\n\nconst openAngieInMode = ( prompt: string | undefined, mode: AngieInteractionMode ): void => {\n\tif ( openLoadedEditorAngie( prompt, mode ) ) {\n\t\treturn;\n\t}\n\n\tif ( ! isAngieAvailable() ) {\n\t\treturn;\n\t}\n\n\tconst angieSidebar = getAngieIframe();\n\n\tif ( ! angieSidebar ) {\n\t\treturn;\n\t}\n\n\ttoggleAngieSidebar( angieSidebar, true );\n\tsetAngieInteractionMode( mode );\n\n\tif ( prompt ) {\n\t\twindow.location.hash = `angie-prompt=${ encodeURIComponent( prompt ) }`;\n\t}\n};\n","import { AngieInteractionMode, getAngieIframe, toggleAngieSidebar } from '@elementor-external/angie-sdk';\n\nimport { openLoadedEditorAngie } from './open-angie-in-ask-mode';\n\nexport const sendPromptToAngie = ( prompt?: string ) => {\n\tif ( openLoadedEditorAngie( prompt, AngieInteractionMode.AGENT ) ) {\n\t\treturn;\n\t}\n\n\tconst angieSidebar = getAngieIframe();\n\n\tif ( ! angieSidebar ) {\n\t\treturn;\n\t}\n\n\ttoggleAngieSidebar( angieSidebar, true );\n\n\tif ( ! prompt ) {\n\t\treturn;\n\t}\n\n\twindow.location.hash = `angie-prompt=${ encodeURIComponent( prompt ) }`;\n};\n","import { setReferrerRedirect } from '@elementor-external/angie-sdk';\n\nconst ANGIE_INSTALL_URL = '/wp-admin/plugin-install.php?s=angie&tab=search&type=term';\n\n/**\n * @deprecated Kept only for Elementor Pro compatibility. Will be removed in a future version.\n * @param prompt Optional prompt to pass after redirect.\n */\nexport const redirectToInstallation = ( prompt?: string ) => {\n\tsetReferrerRedirect( window.location.href, prompt );\n\twindow.location.href = ANGIE_INSTALL_URL;\n};\n","import { ANGIE_SIDEBAR_STATE_OPEN, saveState, setReferrerRedirect } from '@elementor-external/angie-sdk';\n\nconst ANGIE_APP_URL = '/wp-admin/admin.php?page=angie-app';\n\n/**\n * @deprecated Kept only for Elementor Pro compatibility. Will be removed in a future version.\n * @param prompt Optional prompt to pass after redirect.\n */\nexport const redirectToAppAdmin = ( prompt?: string ) => {\n\tsetReferrerRedirect( window.location.href, prompt );\n\tsaveState( ANGIE_SIDEBAR_STATE_OPEN );\n\twindow.location.href = ANGIE_APP_URL;\n};\n","import apiFetch from '@wordpress/api-fetch';\n\ntype PluginResponse = {\n\tplugin: string;\n\tstatus: 'active' | 'inactive';\n\tname: string;\n};\n\ntype PluginErrorResponse = {\n\tcode: string;\n\tmessage: string;\n};\n\nexport type InstallAngieResult = { success: true } | { success: false; error: string; code?: string };\n\nconst ANGIE_SLUG = 'angie';\n\nconst isPluginErrorResponse = ( response: unknown ): response is PluginErrorResponse => {\n\treturn typeof response === 'object' && response !== null && 'code' in response && 'message' in response;\n};\n\nconst activatePlugin = async ( pluginPath: string ): Promise< PluginResponse > => {\n\treturn apiFetch< PluginResponse >( {\n\t\tpath: `/wp/v2/plugins/${ pluginPath }`,\n\t\tmethod: 'POST',\n\t\tdata: { status: 'active' },\n\t} );\n};\n\nconst installPlugin = async (): Promise< PluginResponse > => {\n\ttry {\n\t\treturn await apiFetch< PluginResponse >( {\n\t\t\tpath: '/wp/v2/plugins',\n\t\t\tmethod: 'POST',\n\t\t\tdata: {\n\t\t\t\tslug: ANGIE_SLUG,\n\t\t\t\tstatus: 'active',\n\t\t\t},\n\t\t} );\n\t} catch ( error: unknown ) {\n\t\tif ( isPluginErrorResponse( error ) && error.code === 'folder_exists' ) {\n\t\t\treturn activatePlugin( `${ ANGIE_SLUG }/${ ANGIE_SLUG }` );\n\t\t}\n\n\t\tthrow error;\n\t}\n};\n\n/**\n * @deprecated Kept only for Elementor Pro compatibility. Will be removed in a future version.\n */\nexport const installAngiePlugin = async (): Promise< InstallAngieResult > => {\n\ttry {\n\t\tawait installPlugin();\n\n\t\treturn { success: true };\n\t} catch ( error: unknown ) {\n\t\tif ( isPluginErrorResponse( error ) ) {\n\t\t\treturn { success: false, error: error.message, code: error.code };\n\t\t}\n\n\t\treturn { success: false, error: 'Unknown error occurred' };\n\t}\n};\n","import apiFetch from '@wordpress/api-fetch';\n\nexport const saveAngieConsent = async (): Promise< void > => {\n\tawait apiFetch( {\n\t\tpath: '/elementor/v1/angie/consent',\n\t\tmethod: 'POST',\n\t} );\n};\n","import { createAndRegisterAdapters, signalMcpReady } from './mcp-registry';\n\nlet isInitialized = false;\nexport async function startMCPServer() {\n\tif ( isInitialized ) {\n\t\treturn;\n\t}\n\tisInitialized = true;\n\ttry {\n\t\tawait createAndRegisterAdapters();\n\t} catch ( error ) {\n\t\t/* eslint-disable-next-line no-console */\n\t\tconsole.error( 'MCP adapter activation failed:', error );\n\t} finally {\n\t\tsignalMcpReady();\n\t}\n}\n\n// Start right away when the bundle loads after DOMContentLoaded (late or deferred load): the event will\n// not fire again, and `waitForMcpReady()` callers would wait forever.\nif ( typeof document !== 'undefined' && document.readyState === 'loading' ) {\n\tdocument.addEventListener( 'DOMContentLoaded', () => void startMCPServer(), { once: true } );\n} else {\n\tvoid startMCPServer();\n}\n","export const MCP_STYLES_APPLIED_EVENT = 'elementor/mcp/styles-applied';\n\nexport type McpStylesAppliedPayload = {\n\tstyleValue: Record< string, unknown >;\n};\n\nexport function dispatchMcpStyles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S,iBAAkB,oBAAoB,MAAM,KAAK,eAAe,GAAG,EAAE,MAAM,KAAK,CAAE;AAC5F,OAAO;AACN,OAAK,eAAe;AACrB;;;ACxBO,IAAM,2BAA2B;AAMjC,SAAS,8BAA+B,SAAyC;AACvF,SAAO,cAAe,IAAI,YAAa,0BAA0B,EAAE,QAAQ,QAAQ,CAAE,CAAE;AACxF;;;AzB2BO,IAAM,cAAc,MAAM,OAAO;","names":["McpServer","SamplingMessageSchema","getAngieIframe","z","z","sdk","getRegisteredMcpServers","getAngieIframe","getAngieIframe","AngieInteractionMode","getAngieIframe","toggleAngieSidebar","AngieInteractionMode","getAngieIframe","toggleAngieSidebar","ANGIE_SIDEBAR_STATE_OPEN","setReferrerRedirect","apiFetch"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elementor/editor-mcp",
|
|
3
|
-
"version": "4.4.
|
|
3
|
+
"version": "4.4.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "Elementor Team",
|
|
6
6
|
"homepage": "https://elementor.com/",
|
|
@@ -42,11 +42,11 @@
|
|
|
42
42
|
"tsup": "^8.3.5"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@elementor-external/angie-sdk": "npm:@elementor/angie-sdk
|
|
46
|
-
"@elementor/editor-v1-adapters": "4.4.
|
|
47
|
-
"@elementor/schema": "4.4.
|
|
48
|
-
"@elementor/store": "4.4.
|
|
49
|
-
"@modelcontextprotocol/sdk": "1.
|
|
45
|
+
"@elementor-external/angie-sdk": "npm:@elementor/angie-sdk@1.10.1",
|
|
46
|
+
"@elementor/editor-v1-adapters": "4.4.1",
|
|
47
|
+
"@elementor/schema": "4.4.1",
|
|
48
|
+
"@elementor/store": "4.4.1",
|
|
49
|
+
"@modelcontextprotocol/sdk": "1.32.2",
|
|
50
50
|
"@wordpress/api-fetch": "^6.42.0",
|
|
51
51
|
"zod-to-json-schema": "3.24.6"
|
|
52
52
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import './types/open-angie-request';
|
|
2
|
+
|
|
1
3
|
import { getSDK } from './utils/get-sdk';
|
|
2
4
|
export { getAngieIframe, MessageEventType as AngieMessageEvenetType } from './utils/get-sdk';
|
|
3
5
|
|
|
@@ -9,13 +11,23 @@ export {
|
|
|
9
11
|
} from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
10
12
|
export { SamplingMessageSchema } from '@modelcontextprotocol/sdk/types.js';
|
|
11
13
|
export { isAngieAvailable } from './utils/is-angie-available';
|
|
14
|
+
export { canCreateWidget } from './utils/can-create-widget';
|
|
12
15
|
export { isAngieSidebarOpen } from './utils/is-angie-sidebar-open';
|
|
13
16
|
export * from './mcp-registry';
|
|
17
|
+
export { AngieMcpAdapter } from './adapters/angie-adapter';
|
|
18
|
+
export type { IMcpRegistrationAdapter } from './adapters/types';
|
|
14
19
|
export { createSampler } from './sampler';
|
|
15
20
|
export { toolPrompts } from './utils/prompt-builder';
|
|
16
21
|
export { ANGIE_MODEL_PREFERENCES, ANGIE_REQUIRED_RESOURCES, type AngieModelPreferences } from './angie-annotations';
|
|
17
22
|
export { getActiveChatInfo, type ActiveChatInfo } from './utils/get-active-chat-info';
|
|
18
|
-
export { openAngieInAskMode } from './utils/open-angie-in-ask-mode';
|
|
23
|
+
export { hasLoadedEditorAngie, openAngieInAgentMode, openAngieInAskMode } from './utils/open-angie-in-ask-mode';
|
|
24
|
+
export type {
|
|
25
|
+
EditorAngieWindowHost,
|
|
26
|
+
OpenAngieCommonProperties,
|
|
27
|
+
OpenAngiePluginProperties,
|
|
28
|
+
OpenAngieRequest,
|
|
29
|
+
OpenAngieSdkProperties,
|
|
30
|
+
} from './types/open-angie-request';
|
|
19
31
|
export { sendPromptToAngie } from './utils/send-prompt-to-angie';
|
|
20
32
|
export { redirectToInstallation } from './utils/redirect-to-installation';
|
|
21
33
|
export { redirectToAppAdmin } from './utils/redirect-to-app-admin';
|
package/src/init.ts
CHANGED
|
@@ -16,7 +16,9 @@ export async function startMCPServer() {
|
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
// Start right away when the bundle loads after DOMContentLoaded (late or deferred load): the event will
|
|
20
|
+
// not fire again, and `waitForMcpReady()` callers would wait forever.
|
|
21
|
+
if ( typeof document !== 'undefined' && document.readyState === 'loading' ) {
|
|
20
22
|
document.addEventListener( 'DOMContentLoaded', () => void startMCPServer(), { once: true } );
|
|
21
23
|
} else {
|
|
22
24
|
void startMCPServer();
|
package/src/mcp-registry.ts
CHANGED
|
@@ -3,7 +3,6 @@ import { McpServer, type ToolCallback } from '@modelcontextprotocol/sdk/server/m
|
|
|
3
3
|
import { type RequestHandlerExtra } from '@modelcontextprotocol/sdk/shared/protocol.js';
|
|
4
4
|
import { type ServerNotification, type ServerRequest } from '@modelcontextprotocol/sdk/types.js';
|
|
5
5
|
|
|
6
|
-
import { AngieMcpAdapter } from './adapters/angie-adapter';
|
|
7
6
|
import { type IMcpRegistrationAdapter, type McpResourceHandler, type McpResourceUriOrTemplate } from './adapters/types';
|
|
8
7
|
import { WebMCPAdapter } from './adapters/web-mcp-adapter';
|
|
9
8
|
import {
|
|
@@ -14,8 +13,6 @@ import {
|
|
|
14
13
|
} from './angie-annotations';
|
|
15
14
|
import { mockMcpRegistry } from './test-utils/mock-mcp-registry';
|
|
16
15
|
import { getModelContext } from './utils/get-model-context';
|
|
17
|
-
import { getSDK } from './utils/get-sdk';
|
|
18
|
-
import { isAngieAvailable } from './utils/is-angie-available';
|
|
19
16
|
import { mergeRequiredResources, type ResourceList } from './utils/merge-required-resources';
|
|
20
17
|
import { registerServerDocsResource } from './utils/register-server-docs-resource';
|
|
21
18
|
import { toMCPTitle } from './utils/to-mcp-title';
|
|
@@ -58,6 +55,20 @@ export const signalMcpReady = (): void => {
|
|
|
58
55
|
resolveReady();
|
|
59
56
|
};
|
|
60
57
|
|
|
58
|
+
export const waitForMcpReady = (): Promise< void > => readyPromise;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Registers and activates an adapter that becomes available after startup.
|
|
62
|
+
* Waits for the startup activation so the adapter is activated exactly once.
|
|
63
|
+
*
|
|
64
|
+
* @param adapter - Adapter to register and activate.
|
|
65
|
+
*/
|
|
66
|
+
export const activateMcpAdapter = async ( adapter: IMcpRegistrationAdapter ): Promise< void > => {
|
|
67
|
+
await readyPromise;
|
|
68
|
+
registerMcpAdapter( adapter );
|
|
69
|
+
await adapter.activate();
|
|
70
|
+
};
|
|
71
|
+
|
|
61
72
|
export const createAndRegisterAdapters = async (): Promise< void > => {
|
|
62
73
|
const modelContext = getModelContext();
|
|
63
74
|
|
|
@@ -65,10 +76,6 @@ export const createAndRegisterAdapters = async (): Promise< void > => {
|
|
|
65
76
|
registerMcpAdapter( new WebMCPAdapter( modelContext ) );
|
|
66
77
|
}
|
|
67
78
|
|
|
68
|
-
if ( isAngieAvailable() ) {
|
|
69
|
-
registerMcpAdapter( new AngieMcpAdapter( getSDK(), getRegisteredMcpServers ) );
|
|
70
|
-
}
|
|
71
|
-
|
|
72
79
|
await Promise.all( registrationAdapters.map( ( adapter ) => adapter.activate() ) );
|
|
73
80
|
};
|
|
74
81
|
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { AngieInteractionMode, AngieTriggerRequest } from '@elementor-external/angie-sdk';
|
|
2
|
+
|
|
3
|
+
export type OpenAngieCommonProperties = {
|
|
4
|
+
prompt: string;
|
|
5
|
+
mode: AngieInteractionMode;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export type OpenAngieSdkProperties = {
|
|
9
|
+
context?: AngieTriggerRequest[ 'context' ];
|
|
10
|
+
options?: AngieTriggerRequest[ 'options' ];
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export type OpenAngiePluginProperties = Record< string, never >;
|
|
14
|
+
|
|
15
|
+
export type OpenAngieRequest = OpenAngieCommonProperties & {
|
|
16
|
+
sdk?: OpenAngieSdkProperties;
|
|
17
|
+
plugin?: OpenAngiePluginProperties;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export type EditorAngieWindowHost = {
|
|
21
|
+
openAngie?: ( request: OpenAngieRequest ) => Promise< void > | void;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
declare global {
|
|
25
|
+
interface ElementorV2Global {
|
|
26
|
+
editorAngie?: EditorAngieWindowHost;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
interface Window {
|
|
30
|
+
elementorV2?: ElementorV2Global;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export {};
|
|
@@ -46,6 +46,9 @@ const installPlugin = async (): Promise< PluginResponse > => {
|
|
|
46
46
|
}
|
|
47
47
|
};
|
|
48
48
|
|
|
49
|
+
/**
|
|
50
|
+
* @deprecated Kept only for Elementor Pro compatibility. Will be removed in a future version.
|
|
51
|
+
*/
|
|
49
52
|
export const installAngiePlugin = async (): Promise< InstallAngieResult > => {
|
|
50
53
|
try {
|
|
51
54
|
await installPlugin();
|
|
@@ -7,7 +7,40 @@ import {
|
|
|
7
7
|
|
|
8
8
|
import { isAngieAvailable } from './is-angie-available';
|
|
9
9
|
|
|
10
|
+
const getLoadedEditorAngie = () => {
|
|
11
|
+
return window.elementorV2?.editorAngie?.openAngie;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const hasLoadedEditorAngie = (): boolean => Boolean( getLoadedEditorAngie() );
|
|
15
|
+
|
|
16
|
+
export const openLoadedEditorAngie = ( prompt: string | undefined, mode: AngieInteractionMode ): boolean => {
|
|
17
|
+
const openAngie = getLoadedEditorAngie();
|
|
18
|
+
|
|
19
|
+
if ( ! openAngie ) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
Promise.resolve( openAngie( { prompt: prompt ?? '', mode } ) ).catch( ( error ) => {
|
|
24
|
+
// eslint-disable-next-line no-console
|
|
25
|
+
console.error( 'Failed to open Angie:', error );
|
|
26
|
+
} );
|
|
27
|
+
|
|
28
|
+
return true;
|
|
29
|
+
};
|
|
30
|
+
|
|
10
31
|
export const openAngieInAskMode = ( prompt?: string ): void => {
|
|
32
|
+
openAngieInMode( prompt, AngieInteractionMode.ASK );
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export const openAngieInAgentMode = ( prompt?: string ): void => {
|
|
36
|
+
openAngieInMode( prompt, AngieInteractionMode.AGENT );
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const openAngieInMode = ( prompt: string | undefined, mode: AngieInteractionMode ): void => {
|
|
40
|
+
if ( openLoadedEditorAngie( prompt, mode ) ) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
|
|
11
44
|
if ( ! isAngieAvailable() ) {
|
|
12
45
|
return;
|
|
13
46
|
}
|
|
@@ -19,7 +52,7 @@ export const openAngieInAskMode = ( prompt?: string ): void => {
|
|
|
19
52
|
}
|
|
20
53
|
|
|
21
54
|
toggleAngieSidebar( angieSidebar, true );
|
|
22
|
-
setAngieInteractionMode(
|
|
55
|
+
setAngieInteractionMode( mode );
|
|
23
56
|
|
|
24
57
|
if ( prompt ) {
|
|
25
58
|
window.location.hash = `angie-prompt=${ encodeURIComponent( prompt ) }`;
|
|
@@ -2,6 +2,10 @@ import { ANGIE_SIDEBAR_STATE_OPEN, saveState, setReferrerRedirect } from '@eleme
|
|
|
2
2
|
|
|
3
3
|
const ANGIE_APP_URL = '/wp-admin/admin.php?page=angie-app';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated Kept only for Elementor Pro compatibility. Will be removed in a future version.
|
|
7
|
+
* @param prompt Optional prompt to pass after redirect.
|
|
8
|
+
*/
|
|
5
9
|
export const redirectToAppAdmin = ( prompt?: string ) => {
|
|
6
10
|
setReferrerRedirect( window.location.href, prompt );
|
|
7
11
|
saveState( ANGIE_SIDEBAR_STATE_OPEN );
|
|
@@ -2,6 +2,10 @@ import { setReferrerRedirect } from '@elementor-external/angie-sdk';
|
|
|
2
2
|
|
|
3
3
|
const ANGIE_INSTALL_URL = '/wp-admin/plugin-install.php?s=angie&tab=search&type=term';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated Kept only for Elementor Pro compatibility. Will be removed in a future version.
|
|
7
|
+
* @param prompt Optional prompt to pass after redirect.
|
|
8
|
+
*/
|
|
5
9
|
export const redirectToInstallation = ( prompt?: string ) => {
|
|
6
10
|
setReferrerRedirect( window.location.href, prompt );
|
|
7
11
|
window.location.href = ANGIE_INSTALL_URL;
|
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
import { getAngieIframe, toggleAngieSidebar } from '@elementor-external/angie-sdk';
|
|
1
|
+
import { AngieInteractionMode, getAngieIframe, toggleAngieSidebar } from '@elementor-external/angie-sdk';
|
|
2
|
+
|
|
3
|
+
import { openLoadedEditorAngie } from './open-angie-in-ask-mode';
|
|
2
4
|
|
|
3
5
|
export const sendPromptToAngie = ( prompt?: string ) => {
|
|
6
|
+
if ( openLoadedEditorAngie( prompt, AngieInteractionMode.AGENT ) ) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
|
|
4
10
|
const angieSidebar = getAngieIframe();
|
|
5
11
|
|
|
6
12
|
if ( ! angieSidebar ) {
|