@elementor/editor-mcp 4.1.0-716 → 4.1.0-718
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 +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +13 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +13 -10
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
- package/src/angie-annotations.ts +1 -0
- package/src/mcp-registry.ts +18 -12
package/dist/index.d.mts
CHANGED
|
@@ -42,7 +42,7 @@ interface MCPRegistryEntry {
|
|
|
42
42
|
expiresAt: number;
|
|
43
43
|
};
|
|
44
44
|
sendResourceUpdated: McpServer['server']['sendResourceUpdated'];
|
|
45
|
-
resource: McpServer['
|
|
45
|
+
resource: McpServer['registerResource'];
|
|
46
46
|
mcpServer: McpServer;
|
|
47
47
|
waitForReady: () => Promise<void>;
|
|
48
48
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -42,7 +42,7 @@ interface MCPRegistryEntry {
|
|
|
42
42
|
expiresAt: number;
|
|
43
43
|
};
|
|
44
44
|
sendResourceUpdated: McpServer['server']['sendResourceUpdated'];
|
|
45
|
-
resource: McpServer['
|
|
45
|
+
resource: McpServer['registerResource'];
|
|
46
46
|
mcpServer: McpServer;
|
|
47
47
|
waitForReady: () => Promise<void>;
|
|
48
48
|
}
|
package/dist/index.js
CHANGED
|
@@ -77,6 +77,7 @@ var import_mcp = require("@modelcontextprotocol/sdk/server/mcp.js");
|
|
|
77
77
|
|
|
78
78
|
// src/angie-annotations.ts
|
|
79
79
|
var ANGIE_MODEL_PREFERENCES = "angie/modelPreferences";
|
|
80
|
+
var ANGIE_REQUIRED_RESOURCES = "angie/requiredResources";
|
|
80
81
|
function createDefaultModelPreferences() {
|
|
81
82
|
return {
|
|
82
83
|
hints: [{ name: "claude-sonnet-4-5" }],
|
|
@@ -169,12 +170,14 @@ var getMCPByDomain = (namespace, options) => {
|
|
|
169
170
|
// @ts-expect-error: TS is unable to infer the type here
|
|
170
171
|
resource: async (...args) => {
|
|
171
172
|
await getSDK().waitForReady();
|
|
172
|
-
return mcpServer.
|
|
173
|
+
return mcpServer.registerResource(...args);
|
|
173
174
|
},
|
|
174
175
|
sendResourceUpdated: (...args) => {
|
|
175
|
-
return
|
|
176
|
-
|
|
177
|
-
|
|
176
|
+
return getSDK().waitForReady().then(() => mcpServer.server.sendResourceUpdated(...args)).catch((error) => {
|
|
177
|
+
if (error?.message?.includes("Not connected")) {
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
throw error;
|
|
178
181
|
});
|
|
179
182
|
},
|
|
180
183
|
mcpServer,
|
|
@@ -214,7 +217,6 @@ function createToolRegistry(server) {
|
|
|
214
217
|
try {
|
|
215
218
|
const invocationResult = await opts.handler(opts.schema ? args : {}, extra);
|
|
216
219
|
return {
|
|
217
|
-
// TODO: Uncomment this when the outputSchema is stable
|
|
218
220
|
// structuredContent: typeof invocationResult === 'string' ? undefined : invocationResult,
|
|
219
221
|
content: [
|
|
220
222
|
{
|
|
@@ -243,10 +245,10 @@ function createToolRegistry(server) {
|
|
|
243
245
|
readOnlyHint: opts.isDestructive ? false : void 0,
|
|
244
246
|
title: opts.name
|
|
245
247
|
};
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
248
|
+
const angieAnnotations = {
|
|
249
|
+
[ANGIE_MODEL_PREFERENCES]: opts.modelPreferences ?? createDefaultModelPreferences(),
|
|
250
|
+
[ANGIE_REQUIRED_RESOURCES]: opts.requiredResources ?? void 0
|
|
251
|
+
};
|
|
250
252
|
server.registerTool(
|
|
251
253
|
opts.name,
|
|
252
254
|
{
|
|
@@ -255,7 +257,8 @@ function createToolRegistry(server) {
|
|
|
255
257
|
// TODO: Uncomment this when the outputSchema is stable
|
|
256
258
|
// outputSchema,
|
|
257
259
|
title: opts.name,
|
|
258
|
-
annotations
|
|
260
|
+
annotations,
|
|
261
|
+
_meta: angieAnnotations
|
|
259
262
|
},
|
|
260
263
|
toolCallback
|
|
261
264
|
);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/utils/get-sdk.ts","../src/init.ts","../src/mcp-registry.ts","../src/angie-annotations.ts","../src/test-utils/mock-mcp-registry.ts","../src/utils/is-angie-available.ts","../src/utils/is-angie-sidebar-open.ts","../src/sampler.ts","../src/utils/prompt-builder.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"],"sourcesContent":["import { getSDK } 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 { init } from './init';\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, type AngieModelPreferences } from './angie-annotations';\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 const getAngieSdk = () => getSDK();\n","import { AngieMcpSdk } from '@elementor-external/angie-sdk';\n\nlet sdk: AngieMcpSdk;\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 AngieMcpSdk();\n\t}\n\treturn sdk;\n};\n","import { isExperimentActive } from '@elementor/editor-v1-adapters';\n\nimport { activateMcpRegistration } from './mcp-registry';\nimport { getSDK } from './utils/get-sdk';\nimport { isAngieAvailable } from './utils/is-angie-available';\n\nexport function init() {\n\tif ( isExperimentActive( 'editor_mcp' ) && isAngieAvailable() ) {\n\t\treturn getSDK().waitForReady();\n\t}\n\treturn Promise.resolve();\n}\n\nexport function startMCPServer() {\n\tif ( isExperimentActive( 'editor_mcp' ) && isAngieAvailable() ) {\n\t\tconst sdk = getSDK();\n\t\tsdk.waitForReady().then( () => activateMcpRegistration( sdk ) );\n\t}\n\treturn Promise.resolve();\n}\n\ndocument.addEventListener(\n\t'DOMContentLoaded',\n\t() => {\n\t\tstartMCPServer();\n\t},\n\t{\n\t\tonce: true,\n\t}\n);\n","import { z, type z3 } from '@elementor/schema';\nimport { type AngieMcpSdk } from '@elementor-external/angie-sdk';\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 {\n\tANGIE_MODEL_PREFERENCES,\n\ttype AngieModelPreferences,\n\tcreateDefaultModelPreferences,\n} from './angie-annotations';\nimport { mockMcpRegistry } from './test-utils/mock-mcp-registry';\nimport { getSDK } from './utils/get-sdk';\n\ntype ZodRawShape = z3.ZodRawShape;\n\nconst mcpRegistry: { [ namespace: string ]: McpServer } = {};\nconst mcpDescriptions: { [ namespace: string ]: string } = {};\n// @ts-ignore - QUnit fails this\nlet isMcpRegistrationActivated = false || typeof globalThis.jest !== 'undefined';\n\nexport const registerMcp = ( mcp: McpServer, name: string ) => {\n\tconst mcpName = isAlphabet( name );\n\tmcpRegistry[ mcpName ] = mcp;\n};\n\nexport async function activateMcpRegistration( sdk: AngieMcpSdk ) {\n\tif ( isMcpRegistrationActivated ) {\n\t\treturn;\n\t}\n\tisMcpRegistrationActivated = true;\n\tconst mcpServerList = Object.entries( mcpRegistry );\n\tfor await ( const entry of mcpServerList ) {\n\t\tconst [ key, mcpServer ] = entry;\n\t\tawait sdk.registerLocalServer( {\n\t\t\tname: `editor-${ key }`,\n\t\t\tserver: mcpServer,\n\t\t\tversion: '1.0.0',\n\t\t\tdescription: mcpDescriptions[ key ] || key,\n\t\t} );\n\t}\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 *\n * @param namespace The namespace of the MCP server. It should contain only lowercase alphabetic characters.\n * @param options\n * @param options.instructions\n */\nexport const getMCPByDomain = ( namespace: string, options?: { instructions?: string } ): MCPRegistryEntry => {\n\tconst mcpName = `editor-${ isAlphabet( 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{\n\t\t\t\tname: mcpName,\n\t\t\t\tversion: '1.0.0',\n\t\t\t},\n\t\t\t{\n\t\t\t\tinstructions: options?.instructions,\n\t\t\t}\n\t\t);\n\t}\n\tconst mcpServer = mcpRegistry[ namespace ];\n\tconst { addTool } = createToolRegistry( mcpServer );\n\treturn {\n\t\twaitForReady: () => getSDK().waitForReady(),\n\t\t// @ts-expect-error: TS is unable to infer the type here\n\t\tresource: async ( ...args: Parameters< McpServer[ 'resource' ] > ) => {\n\t\t\tawait getSDK().waitForReady();\n\t\t\treturn mcpServer.resource( ...args );\n\t\t},\n\t\tsendResourceUpdated: ( ...args: Parameters< McpServer[ 'server' ][ 'sendResourceUpdated' ] > ) => {\n\t\t\treturn new Promise( async () => {\n\t\t\t\tawait getSDK().waitForReady();\n\t\t\t\tmcpServer.server.sendResourceUpdated( ...args );\n\t\t\t} );\n\t\t},\n\t\tmcpServer,\n\t\taddTool,\n\t\tsetMCPDescription: ( description: string ) => {\n\t\t\tmcpDescriptions[ namespace ] = description;\n\t\t},\n\t\tgetActiveChatInfo: () => {\n\t\t\tconst info = localStorage.getItem( 'angie_active_chat_id' );\n\t\t\tif ( ! info ) {\n\t\t\t\treturn {\n\t\t\t\t\texpiresAt: 0,\n\t\t\t\t\tsessionId: '',\n\t\t\t\t};\n\t\t\t}\n\t\t\tconst rawData = JSON.parse( info );\n\t\t\treturn {\n\t\t\t\texpiresAt: rawData.expiresAt as number,\n\t\t\t\tsessionId: rawData.sessionId as string,\n\t\t\t};\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\tgetActiveChatInfo: () => { sessionId: string; expiresAt: number };\n\tsendResourceUpdated: McpServer[ 'server' ][ 'sendResourceUpdated' ];\n\tresource: McpServer[ 'resource' ];\n\tmcpServer: McpServer;\n\twaitForReady: () => Promise< void >;\n}\n\ntype ResourceList = {\n\turi: string;\n\tdescription: string;\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 ) {\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// TODO: Uncomment this when the outputSchema is stable\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: ( error as Error ).message || 'Unknown 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\tif ( opts.requiredResources ) {\n\t\t\tannotations[ 'angie/requiredResources' ] = opts.requiredResources;\n\t\t}\n\t\tannotations[ ANGIE_MODEL_PREFERENCES ] = opts.modelPreferences ?? createDefaultModelPreferences();\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},\n\t\t\ttoolCallback\n\t\t);\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 ANGIE_MODEL_PREFERENCES = 'angie/modelPreferences' 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-5' } ],\n\t\tintelligencePriority: 0.8,\n\t\tspeedPriority: 0.7,\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\tgetActiveChatInfo() {\n\t\t\treturn { sessionId: 'mock-session-id', expiresAt: Date.now() + 3600000 };\n\t\t},\n\t\tmcpServer: mock as McpServer,\n\t};\n};\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 { 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\n${ this._parameters.length ? '# Parameters' : '' }\n${ Object.values( this._parameters ).join( '\\n\\n' ) }\n\n${ this._examples.length ? '# Examples' : '' }\n${ this.examples }\n\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","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\tconst success = setReferrerRedirect( window.location.href, prompt );\n\n\tif ( ! success ) {\n\t\treturn;\n\t}\n\n\twindow.location.href = ANGIE_INSTALL_URL;\n};\n","import { 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\tconst success = setReferrerRedirect( window.location.href, prompt );\n\n\tif ( ! success ) {\n\t\treturn;\n\t}\n\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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,uBAA4B;AAE5B,IAAI;AAEG,IAAM,SAAS,MAAM;AAE3B,QAAM,gBAAgB,CAAC,CAAI,WAA0C;AACrE,MAAK,eAAgB;AACpB,WAAO,CAAC;A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S,MAAM,MAAO;AAElE,MAAK,CAAE,SAAU;AAChB;AAAA,EACD;AAEA,SAAO,SAAS,OAAO;AACxB;;;ACZA,uBAAqB;AAerB,IAAM,aAAa;AAEnB,IAAM,wBAAwB,CAAE,aAAwD;AACvF,SAAO,OAAO,aAAa,YAAY,aAAa,QAAQ,UAAU,YAAY,aAAa;AAChG;AAEA,IAAM,iBAAiB,OAAQ,eAAmD;AACjF,aAAO,iBAAAC,SAA4B;AAAA,IAClC,MAAM,kBAAmB,UAAW;AAAA,IACpC,QAAQ;AAAA,IACR,MAAM,EAAE,QAAQ,SAAS;AAAA,EAC1B,CAAE;AACH;AAEA,IAAM,gBAAgB,YAAuC;AAC5D,MAAI;AACH,WAAO,UAAM,iBAAAA,SAA4B;AAAA,MACxC,MAAM;AAAA,MACN,QAAQ;AAAA,MACR,MAAM;AAAA,QACL,MAAM;AAAA,QACN,QAAQ;AAAA,MACT;AAAA,IACD,CAAE;AAAA,EACH,SAAU,OAAiB;AAC1B,QAAK,sBAAuB,KAAM,KAAK,MAAM,SAAS,iBAAkB;AACvE,aAAO,eAAgB,GAAI,UAAW,IAAK,UAAW,EAAG;AAAA,IAC1D;AAEA,UAAM;AAAA,EACP;AACD;AAEO,IAAM,qBAAqB,YAA2C;AAC5E,MAAI;AACH,UAAM,cAAc;AAEpB,WAAO,EAAE,SAAS,KAAK;AAAA,EACxB,SAAU,OAAiB;AAC1B,QAAK,sBAAuB,KAAM,GAAI;AACrC,aAAO,EAAE,SAAS,OAAO,OAAO,MAAM,SAAS,MAAM,MAAM,KAAK;AAAA,IACjE;AAEA,WAAO,EAAE,SAAS,OAAO,OAAO,yBAAyB;AAAA,EAC1D;AACD;;;AbxCO,IAAM,cAAc,MAAM,OAAO;","names":["import_mcp","import_types","sdk","import_angie_sdk","sdk","import_angie_sdk","import_angie_sdk","import_angie_sdk","import_angie_sdk","apiFetch"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/utils/get-sdk.ts","../src/init.ts","../src/mcp-registry.ts","../src/angie-annotations.ts","../src/test-utils/mock-mcp-registry.ts","../src/utils/is-angie-available.ts","../src/utils/is-angie-sidebar-open.ts","../src/sampler.ts","../src/utils/prompt-builder.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"],"sourcesContent":["import { getSDK } 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 { init } from './init';\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, type AngieModelPreferences } from './angie-annotations';\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 const getAngieSdk = () => getSDK();\n","import { AngieMcpSdk } from '@elementor-external/angie-sdk';\n\nlet sdk: AngieMcpSdk;\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 AngieMcpSdk();\n\t}\n\treturn sdk;\n};\n","import { isExperimentActive } from '@elementor/editor-v1-adapters';\n\nimport { activateMcpRegistration } from './mcp-registry';\nimport { getSDK } from './utils/get-sdk';\nimport { isAngieAvailable } from './utils/is-angie-available';\n\nexport function init() {\n\tif ( isExperimentActive( 'editor_mcp' ) && isAngieAvailable() ) {\n\t\treturn getSDK().waitForReady();\n\t}\n\treturn Promise.resolve();\n}\n\nexport function startMCPServer() {\n\tif ( isExperimentActive( 'editor_mcp' ) && isAngieAvailable() ) {\n\t\tconst sdk = getSDK();\n\t\tsdk.waitForReady().then( () => activateMcpRegistration( sdk ) );\n\t}\n\treturn Promise.resolve();\n}\n\ndocument.addEventListener(\n\t'DOMContentLoaded',\n\t() => {\n\t\tstartMCPServer();\n\t},\n\t{\n\t\tonce: true,\n\t}\n);\n","import { z, type z3 } from '@elementor/schema';\nimport { type AngieMcpSdk } from '@elementor-external/angie-sdk';\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 {\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 { getSDK } from './utils/get-sdk';\n\ntype ZodRawShape = z3.ZodRawShape;\n\nconst mcpRegistry: { [ namespace: string ]: McpServer } = {};\nconst mcpDescriptions: { [ namespace: string ]: string } = {};\n// @ts-ignore - QUnit fails this\nlet isMcpRegistrationActivated = false || typeof globalThis.jest !== 'undefined';\n\nexport const registerMcp = ( mcp: McpServer, name: string ) => {\n\tconst mcpName = isAlphabet( name );\n\tmcpRegistry[ mcpName ] = mcp;\n};\n\nexport async function activateMcpRegistration( sdk: AngieMcpSdk ) {\n\tif ( isMcpRegistrationActivated ) {\n\t\treturn;\n\t}\n\tisMcpRegistrationActivated = true;\n\tconst mcpServerList = Object.entries( mcpRegistry );\n\tfor await ( const entry of mcpServerList ) {\n\t\tconst [ key, mcpServer ] = entry;\n\t\tawait sdk.registerLocalServer( {\n\t\t\tname: `editor-${ key }`,\n\t\t\tserver: mcpServer,\n\t\t\tversion: '1.0.0',\n\t\t\tdescription: mcpDescriptions[ key ] || key,\n\t\t} );\n\t}\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 *\n * @param namespace The namespace of the MCP server. It should contain only lowercase alphabetic characters.\n * @param options\n * @param options.instructions\n */\nexport const getMCPByDomain = ( namespace: string, options?: { instructions?: string } ): MCPRegistryEntry => {\n\tconst mcpName = `editor-${ isAlphabet( 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{\n\t\t\t\tname: mcpName,\n\t\t\t\tversion: '1.0.0',\n\t\t\t},\n\t\t\t{\n\t\t\t\tinstructions: options?.instructions,\n\t\t\t}\n\t\t);\n\t}\n\tconst mcpServer = mcpRegistry[ namespace ];\n\tconst { addTool } = createToolRegistry( mcpServer );\n\treturn {\n\t\twaitForReady: () => getSDK().waitForReady(),\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\tawait getSDK().waitForReady();\n\t\t\treturn mcpServer.registerResource( ...args );\n\t\t},\n\t\tsendResourceUpdated: ( ...args: Parameters< McpServer[ 'server' ][ 'sendResourceUpdated' ] > ) => {\n\t\t\treturn getSDK()\n\t\t\t\t.waitForReady()\n\t\t\t\t.then( () => mcpServer.server.sendResourceUpdated( ...args ) )\n\t\t\t\t.catch( ( error: Error ) => {\n\t\t\t\t\tif ( error?.message?.includes( 'Not connected' ) ) {\n\t\t\t\t\t\treturn; // Expected when no MCP client is connected yet\n\t\t\t\t\t}\n\t\t\t\t\tthrow error;\n\t\t\t\t} );\n\t\t},\n\t\tmcpServer,\n\t\taddTool,\n\t\tsetMCPDescription: ( description: string ) => {\n\t\t\tmcpDescriptions[ namespace ] = description;\n\t\t},\n\t\tgetActiveChatInfo: () => {\n\t\t\tconst info = localStorage.getItem( 'angie_active_chat_id' );\n\t\t\tif ( ! info ) {\n\t\t\t\treturn {\n\t\t\t\t\texpiresAt: 0,\n\t\t\t\t\tsessionId: '',\n\t\t\t\t};\n\t\t\t}\n\t\t\tconst rawData = JSON.parse( info );\n\t\t\treturn {\n\t\t\t\texpiresAt: rawData.expiresAt as number,\n\t\t\t\tsessionId: rawData.sessionId as string,\n\t\t\t};\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\tgetActiveChatInfo: () => { sessionId: string; expiresAt: number };\n\tsendResourceUpdated: McpServer[ 'server' ][ 'sendResourceUpdated' ];\n\tresource: McpServer[ 'registerResource' ];\n\tmcpServer: McpServer;\n\twaitForReady: () => Promise< void >;\n}\n\ntype ResourceList = {\n\turi: string;\n\tdescription: string;\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 ) {\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: ( error as Error ).message || 'Unknown 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 angieAnnotations = {\n\t\t\t[ ANGIE_MODEL_PREFERENCES ]: opts.modelPreferences ?? createDefaultModelPreferences(),\n\t\t\t[ ANGIE_REQUIRED_RESOURCES ]: opts.requiredResources ?? undefined,\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\tif ( isMcpRegistrationActivated ) {\n\t\t\tserver.sendToolListChanged();\n\t\t}\n\t}\n\treturn {\n\t\taddTool,\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-5' } ],\n\t\tintelligencePriority: 0.8,\n\t\tspeedPriority: 0.7,\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\tgetActiveChatInfo() {\n\t\t\treturn { sessionId: 'mock-session-id', expiresAt: Date.now() + 3600000 };\n\t\t},\n\t\tmcpServer: mock as McpServer,\n\t};\n};\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 { 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\n${ this._parameters.length ? '# Parameters' : '' }\n${ Object.values( this._parameters ).join( '\\n\\n' ) }\n\n${ this._examples.length ? '# Examples' : '' }\n${ this.examples }\n\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","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\tconst success = setReferrerRedirect( window.location.href, prompt );\n\n\tif ( ! success ) {\n\t\treturn;\n\t}\n\n\twindow.location.href = ANGIE_INSTALL_URL;\n};\n","import { 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\tconst success = setReferrerRedirect( window.location.href, prompt );\n\n\tif ( ! success ) {\n\t\treturn;\n\t}\n\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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,uBAA4B;AAE5B,IAAI;AAEG,IAAM,SAAS,MAAM;AAE3B,Q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C1D;AACD;;;AbxCO,IAAM,cAAc,MAAM,OAAO;","names":["import_mcp","import_types","sdk","import_angie_sdk","sdk","import_angie_sdk","import_angie_sdk","import_angie_sdk","import_angie_sdk","apiFetch"]}
|
package/dist/index.mjs
CHANGED
|
@@ -28,6 +28,7 @@ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
|
28
28
|
|
|
29
29
|
// src/angie-annotations.ts
|
|
30
30
|
var ANGIE_MODEL_PREFERENCES = "angie/modelPreferences";
|
|
31
|
+
var ANGIE_REQUIRED_RESOURCES = "angie/requiredResources";
|
|
31
32
|
function createDefaultModelPreferences() {
|
|
32
33
|
return {
|
|
33
34
|
hints: [{ name: "claude-sonnet-4-5" }],
|
|
@@ -120,12 +121,14 @@ var getMCPByDomain = (namespace, options) => {
|
|
|
120
121
|
// @ts-expect-error: TS is unable to infer the type here
|
|
121
122
|
resource: async (...args) => {
|
|
122
123
|
await getSDK().waitForReady();
|
|
123
|
-
return mcpServer.
|
|
124
|
+
return mcpServer.registerResource(...args);
|
|
124
125
|
},
|
|
125
126
|
sendResourceUpdated: (...args) => {
|
|
126
|
-
return
|
|
127
|
-
|
|
128
|
-
|
|
127
|
+
return getSDK().waitForReady().then(() => mcpServer.server.sendResourceUpdated(...args)).catch((error) => {
|
|
128
|
+
if (error?.message?.includes("Not connected")) {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
throw error;
|
|
129
132
|
});
|
|
130
133
|
},
|
|
131
134
|
mcpServer,
|
|
@@ -165,7 +168,6 @@ function createToolRegistry(server) {
|
|
|
165
168
|
try {
|
|
166
169
|
const invocationResult = await opts.handler(opts.schema ? args : {}, extra);
|
|
167
170
|
return {
|
|
168
|
-
// TODO: Uncomment this when the outputSchema is stable
|
|
169
171
|
// structuredContent: typeof invocationResult === 'string' ? undefined : invocationResult,
|
|
170
172
|
content: [
|
|
171
173
|
{
|
|
@@ -194,10 +196,10 @@ function createToolRegistry(server) {
|
|
|
194
196
|
readOnlyHint: opts.isDestructive ? false : void 0,
|
|
195
197
|
title: opts.name
|
|
196
198
|
};
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
199
|
+
const angieAnnotations = {
|
|
200
|
+
[ANGIE_MODEL_PREFERENCES]: opts.modelPreferences ?? createDefaultModelPreferences(),
|
|
201
|
+
[ANGIE_REQUIRED_RESOURCES]: opts.requiredResources ?? void 0
|
|
202
|
+
};
|
|
201
203
|
server.registerTool(
|
|
202
204
|
opts.name,
|
|
203
205
|
{
|
|
@@ -206,7 +208,8 @@ function createToolRegistry(server) {
|
|
|
206
208
|
// TODO: Uncomment this when the outputSchema is stable
|
|
207
209
|
// outputSchema,
|
|
208
210
|
title: opts.name,
|
|
209
|
-
annotations
|
|
211
|
+
annotations,
|
|
212
|
+
_meta: angieAnnotations
|
|
210
213
|
},
|
|
211
214
|
toolCallback
|
|
212
215
|
);
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/get-sdk.ts","../src/index.ts","../src/init.ts","../src/mcp-registry.ts","../src/angie-annotations.ts","../src/test-utils/mock-mcp-registry.ts","../src/utils/is-angie-available.ts","../src/utils/is-angie-sidebar-open.ts","../src/sampler.ts","../src/utils/prompt-builder.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"],"sourcesContent":["import { AngieMcpSdk } from '@elementor-external/angie-sdk';\n\nlet sdk: AngieMcpSdk;\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 AngieMcpSdk();\n\t}\n\treturn sdk;\n};\n","import { getSDK } 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 { init } from './init';\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, type AngieModelPreferences } from './angie-annotations';\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 const getAngieSdk = () => getSDK();\n","import { isExperimentActive } from '@elementor/editor-v1-adapters';\n\nimport { activateMcpRegistration } from './mcp-registry';\nimport { getSDK } from './utils/get-sdk';\nimport { isAngieAvailable } from './utils/is-angie-available';\n\nexport function init() {\n\tif ( isExperimentActive( 'editor_mcp' ) && isAngieAvailable() ) {\n\t\treturn getSDK().waitForReady();\n\t}\n\treturn Promise.resolve();\n}\n\nexport function startMCPServer() {\n\tif ( isExperimentActive( 'editor_mcp' ) && isAngieAvailable() ) {\n\t\tconst sdk = getSDK();\n\t\tsdk.waitForReady().then( () => activateMcpRegistration( sdk ) );\n\t}\n\treturn Promise.resolve();\n}\n\ndocument.addEventListener(\n\t'DOMContentLoaded',\n\t() => {\n\t\tstartMCPServer();\n\t},\n\t{\n\t\tonce: true,\n\t}\n);\n","import { z, type z3 } from '@elementor/schema';\nimport { type AngieMcpSdk } from '@elementor-external/angie-sdk';\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 {\n\tANGIE_MODEL_PREFERENCES,\n\ttype AngieModelPreferences,\n\tcreateDefaultModelPreferences,\n} from './angie-annotations';\nimport { mockMcpRegistry } from './test-utils/mock-mcp-registry';\nimport { getSDK } from './utils/get-sdk';\n\ntype ZodRawShape = z3.ZodRawShape;\n\nconst mcpRegistry: { [ namespace: string ]: McpServer } = {};\nconst mcpDescriptions: { [ namespace: string ]: string } = {};\n// @ts-ignore - QUnit fails this\nlet isMcpRegistrationActivated = false || typeof globalThis.jest !== 'undefined';\n\nexport const registerMcp = ( mcp: McpServer, name: string ) => {\n\tconst mcpName = isAlphabet( name );\n\tmcpRegistry[ mcpName ] = mcp;\n};\n\nexport async function activateMcpRegistration( sdk: AngieMcpSdk ) {\n\tif ( isMcpRegistrationActivated ) {\n\t\treturn;\n\t}\n\tisMcpRegistrationActivated = true;\n\tconst mcpServerList = Object.entries( mcpRegistry );\n\tfor await ( const entry of mcpServerList ) {\n\t\tconst [ key, mcpServer ] = entry;\n\t\tawait sdk.registerLocalServer( {\n\t\t\tname: `editor-${ key }`,\n\t\t\tserver: mcpServer,\n\t\t\tversion: '1.0.0',\n\t\t\tdescription: mcpDescriptions[ key ] || key,\n\t\t} );\n\t}\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 *\n * @param namespace The namespace of the MCP server. It should contain only lowercase alphabetic characters.\n * @param options\n * @param options.instructions\n */\nexport const getMCPByDomain = ( namespace: string, options?: { instructions?: string } ): MCPRegistryEntry => {\n\tconst mcpName = `editor-${ isAlphabet( 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{\n\t\t\t\tname: mcpName,\n\t\t\t\tversion: '1.0.0',\n\t\t\t},\n\t\t\t{\n\t\t\t\tinstructions: options?.instructions,\n\t\t\t}\n\t\t);\n\t}\n\tconst mcpServer = mcpRegistry[ namespace ];\n\tconst { addTool } = createToolRegistry( mcpServer );\n\treturn {\n\t\twaitForReady: () => getSDK().waitForReady(),\n\t\t// @ts-expect-error: TS is unable to infer the type here\n\t\tresource: async ( ...args: Parameters< McpServer[ 'resource' ] > ) => {\n\t\t\tawait getSDK().waitForReady();\n\t\t\treturn mcpServer.resource( ...args );\n\t\t},\n\t\tsendResourceUpdated: ( ...args: Parameters< McpServer[ 'server' ][ 'sendResourceUpdated' ] > ) => {\n\t\t\treturn new Promise( async () => {\n\t\t\t\tawait getSDK().waitForReady();\n\t\t\t\tmcpServer.server.sendResourceUpdated( ...args );\n\t\t\t} );\n\t\t},\n\t\tmcpServer,\n\t\taddTool,\n\t\tsetMCPDescription: ( description: string ) => {\n\t\t\tmcpDescriptions[ namespace ] = description;\n\t\t},\n\t\tgetActiveChatInfo: () => {\n\t\t\tconst info = localStorage.getItem( 'angie_active_chat_id' );\n\t\t\tif ( ! info ) {\n\t\t\t\treturn {\n\t\t\t\t\texpiresAt: 0,\n\t\t\t\t\tsessionId: '',\n\t\t\t\t};\n\t\t\t}\n\t\t\tconst rawData = JSON.parse( info );\n\t\t\treturn {\n\t\t\t\texpiresAt: rawData.expiresAt as number,\n\t\t\t\tsessionId: rawData.sessionId as string,\n\t\t\t};\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\tgetActiveChatInfo: () => { sessionId: string; expiresAt: number };\n\tsendResourceUpdated: McpServer[ 'server' ][ 'sendResourceUpdated' ];\n\tresource: McpServer[ 'resource' ];\n\tmcpServer: McpServer;\n\twaitForReady: () => Promise< void >;\n}\n\ntype ResourceList = {\n\turi: string;\n\tdescription: string;\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 ) {\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// TODO: Uncomment this when the outputSchema is stable\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: ( error as Error ).message || 'Unknown 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\tif ( opts.requiredResources ) {\n\t\t\tannotations[ 'angie/requiredResources' ] = opts.requiredResources;\n\t\t}\n\t\tannotations[ ANGIE_MODEL_PREFERENCES ] = opts.modelPreferences ?? createDefaultModelPreferences();\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},\n\t\t\ttoolCallback\n\t\t);\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 ANGIE_MODEL_PREFERENCES = 'angie/modelPreferences' 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-5' } ],\n\t\tintelligencePriority: 0.8,\n\t\tspeedPriority: 0.7,\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\tgetActiveChatInfo() {\n\t\t\treturn { sessionId: 'mock-session-id', expiresAt: Date.now() + 3600000 };\n\t\t},\n\t\tmcpServer: mock as McpServer,\n\t};\n};\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 { 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\n${ this._parameters.length ? '# Parameters' : '' }\n${ Object.values( this._parameters ).join( '\\n\\n' ) }\n\n${ this._examples.length ? '# Examples' : '' }\n${ this.examples }\n\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","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\tconst success = setReferrerRedirect( window.location.href, prompt );\n\n\tif ( ! success ) {\n\t\treturn;\n\t}\n\n\twindow.location.href = ANGIE_INSTALL_URL;\n};\n","import { 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\tconst success = setReferrerRedirect( window.location.href, prompt );\n\n\tif ( ! success ) {\n\t\treturn;\n\t}\n\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"],"mappings":";AAAA,SAAS,mBAAmB;AAE5B,IAAI;AAEG,IAAM,SAAS,MAAM;AAE3B,QAAM,gBAAgB,CAAC,CAAI,WAA0C;AACrE,MAAK,eAAgB;AACpB,WAAO,CAAC;AAAA,EACT;AACA,MAAK,CAAE,KAAM;AACZ,UAAM,IAAI,YAAY;AAAA,EACvB;AACA,SAAO;AACR;;;ACZA;AAAA,EACC,aAAAA;AAAA,EACA;AAAA,OAGM;AACP,SAAS,yBAAAC,8BAA6B;;;ACRtC,SAAS,0BAA0B;;;ACAnC,SAAS,SAAkB;AAE3B,SAAS,iBAAoC;;;ACFtC,IAAM,0BAA0B;AAShC,SAAS,gCAAuD;AACtE,SAAO;AAAA,IACN,OAAO,CAAE,EAAE,MAAM,oBAAoB,CAAE;AAAA,IACvC,sBAAsB;AAAA,IACtB,eAAe;AAAA,EAChB;AACD;;;ACXA,IAAM,OAAO,IAAI;AAAA,EAChB,CAAC;AAAA,EACD;AAAA,IACC,KAAK,MAAM;AAEV,eAAS,YAAa,GAAe;AAAA,MAAC;AACtC,aAAO;AAAA,IACR;AAAA,EACD;AACD;AAEO,IAAM,kBAAkB,MAAwB;AACtD,SAAO;AAAA;AAAA,IAEN,UAAU,YAAY;AAAA,IAAC;AAAA;AAAA,IAEvB,qBAAqB,MAAM;AAAA,IAAC;AAAA,IAC5B,SAAS,MAAM;AAAA,IAAC;AAAA,IAChB,mBAAmB,MAAM;AAAA,IAAC;AAAA,IAC1B,oBAAoB;AACnB,aAAO,EAAE,WAAW,mBAAmB,WAAW,KAAK,IAAI,IAAI,KAAQ;AAAA,IACxE;AAAA,IACA,WAAW;AAAA,EACZ;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AM,cAAc;AAEpB,WAAO,EAAE,SAAS,KAAK;AAAA,EACxB,SAAU,OAAiB;AAC1B,QAAK,sBAAuB,KAAM,GAAI;AACrC,aAAO,EAAE,SAAS,OAAO,OAAO,MAAM,SAAS,MAAM,MAAM,KAAK;AAAA,IACjE;AAEA,WAAO,EAAE,SAAS,OAAO,OAAO,yBAAyB;AAAA,EAC1D;AACD;;;AZxCO,IAAM,cAAc,MAAM,OAAO;","names":["McpServer","SamplingMessageSchema","sdk","sdk","getAngieIframe","setReferrerRedirect"]}
|
|
1
|
+
{"version":3,"sources":["../src/utils/get-sdk.ts","../src/index.ts","../src/init.ts","../src/mcp-registry.ts","../src/angie-annotations.ts","../src/test-utils/mock-mcp-registry.ts","../src/utils/is-angie-available.ts","../src/utils/is-angie-sidebar-open.ts","../src/sampler.ts","../src/utils/prompt-builder.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"],"sourcesContent":["import { AngieMcpSdk } from '@elementor-external/angie-sdk';\n\nlet sdk: AngieMcpSdk;\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 AngieMcpSdk();\n\t}\n\treturn sdk;\n};\n","import { getSDK } 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 { init } from './init';\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, type AngieModelPreferences } from './angie-annotations';\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 const getAngieSdk = () => getSDK();\n","import { isExperimentActive } from '@elementor/editor-v1-adapters';\n\nimport { activateMcpRegistration } from './mcp-registry';\nimport { getSDK } from './utils/get-sdk';\nimport { isAngieAvailable } from './utils/is-angie-available';\n\nexport function init() {\n\tif ( isExperimentActive( 'editor_mcp' ) && isAngieAvailable() ) {\n\t\treturn getSDK().waitForReady();\n\t}\n\treturn Promise.resolve();\n}\n\nexport function startMCPServer() {\n\tif ( isExperimentActive( 'editor_mcp' ) && isAngieAvailable() ) {\n\t\tconst sdk = getSDK();\n\t\tsdk.waitForReady().then( () => activateMcpRegistration( sdk ) );\n\t}\n\treturn Promise.resolve();\n}\n\ndocument.addEventListener(\n\t'DOMContentLoaded',\n\t() => {\n\t\tstartMCPServer();\n\t},\n\t{\n\t\tonce: true,\n\t}\n);\n","import { z, type z3 } from '@elementor/schema';\nimport { type AngieMcpSdk } from '@elementor-external/angie-sdk';\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 {\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 { getSDK } from './utils/get-sdk';\n\ntype ZodRawShape = z3.ZodRawShape;\n\nconst mcpRegistry: { [ namespace: string ]: McpServer } = {};\nconst mcpDescriptions: { [ namespace: string ]: string } = {};\n// @ts-ignore - QUnit fails this\nlet isMcpRegistrationActivated = false || typeof globalThis.jest !== 'undefined';\n\nexport const registerMcp = ( mcp: McpServer, name: string ) => {\n\tconst mcpName = isAlphabet( name );\n\tmcpRegistry[ mcpName ] = mcp;\n};\n\nexport async function activateMcpRegistration( sdk: AngieMcpSdk ) {\n\tif ( isMcpRegistrationActivated ) {\n\t\treturn;\n\t}\n\tisMcpRegistrationActivated = true;\n\tconst mcpServerList = Object.entries( mcpRegistry );\n\tfor await ( const entry of mcpServerList ) {\n\t\tconst [ key, mcpServer ] = entry;\n\t\tawait sdk.registerLocalServer( {\n\t\t\tname: `editor-${ key }`,\n\t\t\tserver: mcpServer,\n\t\t\tversion: '1.0.0',\n\t\t\tdescription: mcpDescriptions[ key ] || key,\n\t\t} );\n\t}\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 *\n * @param namespace The namespace of the MCP server. It should contain only lowercase alphabetic characters.\n * @param options\n * @param options.instructions\n */\nexport const getMCPByDomain = ( namespace: string, options?: { instructions?: string } ): MCPRegistryEntry => {\n\tconst mcpName = `editor-${ isAlphabet( 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{\n\t\t\t\tname: mcpName,\n\t\t\t\tversion: '1.0.0',\n\t\t\t},\n\t\t\t{\n\t\t\t\tinstructions: options?.instructions,\n\t\t\t}\n\t\t);\n\t}\n\tconst mcpServer = mcpRegistry[ namespace ];\n\tconst { addTool } = createToolRegistry( mcpServer );\n\treturn {\n\t\twaitForReady: () => getSDK().waitForReady(),\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\tawait getSDK().waitForReady();\n\t\t\treturn mcpServer.registerResource( ...args );\n\t\t},\n\t\tsendResourceUpdated: ( ...args: Parameters< McpServer[ 'server' ][ 'sendResourceUpdated' ] > ) => {\n\t\t\treturn getSDK()\n\t\t\t\t.waitForReady()\n\t\t\t\t.then( () => mcpServer.server.sendResourceUpdated( ...args ) )\n\t\t\t\t.catch( ( error: Error ) => {\n\t\t\t\t\tif ( error?.message?.includes( 'Not connected' ) ) {\n\t\t\t\t\t\treturn; // Expected when no MCP client is connected yet\n\t\t\t\t\t}\n\t\t\t\t\tthrow error;\n\t\t\t\t} );\n\t\t},\n\t\tmcpServer,\n\t\taddTool,\n\t\tsetMCPDescription: ( description: string ) => {\n\t\t\tmcpDescriptions[ namespace ] = description;\n\t\t},\n\t\tgetActiveChatInfo: () => {\n\t\t\tconst info = localStorage.getItem( 'angie_active_chat_id' );\n\t\t\tif ( ! info ) {\n\t\t\t\treturn {\n\t\t\t\t\texpiresAt: 0,\n\t\t\t\t\tsessionId: '',\n\t\t\t\t};\n\t\t\t}\n\t\t\tconst rawData = JSON.parse( info );\n\t\t\treturn {\n\t\t\t\texpiresAt: rawData.expiresAt as number,\n\t\t\t\tsessionId: rawData.sessionId as string,\n\t\t\t};\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\tgetActiveChatInfo: () => { sessionId: string; expiresAt: number };\n\tsendResourceUpdated: McpServer[ 'server' ][ 'sendResourceUpdated' ];\n\tresource: McpServer[ 'registerResource' ];\n\tmcpServer: McpServer;\n\twaitForReady: () => Promise< void >;\n}\n\ntype ResourceList = {\n\turi: string;\n\tdescription: string;\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 ) {\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: ( error as Error ).message || 'Unknown 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 angieAnnotations = {\n\t\t\t[ ANGIE_MODEL_PREFERENCES ]: opts.modelPreferences ?? createDefaultModelPreferences(),\n\t\t\t[ ANGIE_REQUIRED_RESOURCES ]: opts.requiredResources ?? undefined,\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\tif ( isMcpRegistrationActivated ) {\n\t\t\tserver.sendToolListChanged();\n\t\t}\n\t}\n\treturn {\n\t\taddTool,\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-5' } ],\n\t\tintelligencePriority: 0.8,\n\t\tspeedPriority: 0.7,\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\tgetActiveChatInfo() {\n\t\t\treturn { sessionId: 'mock-session-id', expiresAt: Date.now() + 3600000 };\n\t\t},\n\t\tmcpServer: mock as McpServer,\n\t};\n};\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 { 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\n${ this._parameters.length ? '# Parameters' : '' }\n${ Object.values( this._parameters ).join( '\\n\\n' ) }\n\n${ this._examples.length ? '# Examples' : '' }\n${ this.examples }\n\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","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\tconst success = setReferrerRedirect( window.location.href, prompt );\n\n\tif ( ! success ) {\n\t\treturn;\n\t}\n\n\twindow.location.href = ANGIE_INSTALL_URL;\n};\n","import { 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\tconst success = setReferrerRedirect( window.location.href, prompt );\n\n\tif ( ! success ) {\n\t\treturn;\n\t}\n\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"],"mappings":";AAAA,SAAS,mBAAmB;AAE5B,IAAI;AAEG,IAAM,SAAS,MAAM;AAE3B,QAAM,gBAAgB,CAAC,CAAI,WAA0C;AACrE,MAAK,eAAgB;AACpB,WAAO,CAAC;AAAA,EACT;AACA,MAAK,CAAE,KAAM;AACZ,UAAM,IAAI,YAAY;AAAA,EACvB;AACA,SAAO;AACR;;;ACZA;AAAA,EACC,aAAAA;AAAA,EACA;AAAA,OAGM;AACP,SAAS,yBAAAC,8BAA6B;;;ACRtC,SAAS,0BAA0B;;;ACAnC,SAAS,SAAkB;AAE3B,SAAS,iBAAoC;;;ACFtC,IAAM,0BAA0B;AAChC,IAAM,2BAA2B;AASjC,SAAS,gCAAuD;AACtE,SAAO;AAAA,IACN,OAAO,CAAE,EAAE,MAAM,oBAAoB,CAAE;AAAA,IACvC,sBAAsB;AAAA,IACtB,eAAe;AAAA,EAChB;AACD;;;ACZA,IAAM,OAAO,IAAI;AAAA,EAChB,CAAC;AAAA,EACD;AAAA,IACC,KAAK,MAAM;AAEV,eAAS,YAAa,GAAe;AAAA,MAAC;AACtC,aAAO;AAAA,IACR;AAAA,EACD;AACD;AAEO,IAAM,kBAAkB,MAAwB;AACtD,SAAO;AAAA;AAAA,IAEN,UAAU,YAAY;AAAA,IAAC;AAAA;AAAA,IAEvB,qBAAqB,MAAM;AAAA,IAAC;AAAA,IAC5B,SAAS,MAAM;AAAA,IAAC;AAAA,IAChB,mBAAmB,MAAM;AAAA,IAAC;AAAA,IAC1B,oBAAoB;AACnB,aAAO,EAAE,WAAW,mBAAmB,WAAW,KAAK,IAAI,IAAI,KAAQ;AAAA,IACxE;AAAA,IACA,WAAW;AAAA,EACZ;AACD;;;AFXA,IAAM,cAAoD,C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1D;AAEA,UAAM;AAAA,EACP;AACD;AAEO,IAAM,qBAAqB,YAA2C;AAC5E,MAAI;AACH,UAAM,cAAc;AAEpB,WAAO,EAAE,SAAS,KAAK;AAAA,EACxB,SAAU,OAAiB;AAC1B,QAAK,sBAAuB,KAAM,GAAI;AACrC,aAAO,EAAE,SAAS,OAAO,OAAO,MAAM,SAAS,MAAM,MAAM,KAAK;AAAA,IACjE;AAEA,WAAO,EAAE,SAAS,OAAO,OAAO,yBAAyB;AAAA,EAC1D;AACD;;;AZxCO,IAAM,cAAc,MAAM,OAAO;","names":["McpServer","SamplingMessageSchema","sdk","sdk","getAngieIframe","setReferrerRedirect"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elementor/editor-mcp",
|
|
3
|
-
"version": "4.1.0-
|
|
3
|
+
"version": "4.1.0-718",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "Elementor Team",
|
|
6
6
|
"homepage": "https://elementor.com/",
|
|
@@ -42,10 +42,10 @@
|
|
|
42
42
|
"tsup": "^8.3.5"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@elementor-external/angie-sdk": "npm:@elementor/angie-sdk@^1.
|
|
46
|
-
"@elementor/editor-v1-adapters": "4.1.0-
|
|
47
|
-
"@elementor/schema": "4.1.0-
|
|
48
|
-
"@elementor/store": "4.1.0-
|
|
45
|
+
"@elementor-external/angie-sdk": "npm:@elementor/angie-sdk@^1.4.5",
|
|
46
|
+
"@elementor/editor-v1-adapters": "4.1.0-718",
|
|
47
|
+
"@elementor/schema": "4.1.0-718",
|
|
48
|
+
"@elementor/store": "4.1.0-718",
|
|
49
49
|
"@modelcontextprotocol/sdk": "1.27.1",
|
|
50
50
|
"@wordpress/api-fetch": "^6.42.0",
|
|
51
51
|
"zod-to-json-schema": "3.24.6"
|
package/src/angie-annotations.ts
CHANGED
package/src/mcp-registry.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { type ServerNotification, type ServerRequest } from '@modelcontextprotoc
|
|
|
6
6
|
|
|
7
7
|
import {
|
|
8
8
|
ANGIE_MODEL_PREFERENCES,
|
|
9
|
+
ANGIE_REQUIRED_RESOURCES,
|
|
9
10
|
type AngieModelPreferences,
|
|
10
11
|
createDefaultModelPreferences,
|
|
11
12
|
} from './angie-annotations';
|
|
@@ -77,15 +78,20 @@ export const getMCPByDomain = ( namespace: string, options?: { instructions?: st
|
|
|
77
78
|
return {
|
|
78
79
|
waitForReady: () => getSDK().waitForReady(),
|
|
79
80
|
// @ts-expect-error: TS is unable to infer the type here
|
|
80
|
-
resource: async ( ...args: Parameters< McpServer[ '
|
|
81
|
+
resource: async ( ...args: Parameters< McpServer[ 'registerResource' ] > ) => {
|
|
81
82
|
await getSDK().waitForReady();
|
|
82
|
-
return mcpServer.
|
|
83
|
+
return mcpServer.registerResource( ...args );
|
|
83
84
|
},
|
|
84
85
|
sendResourceUpdated: ( ...args: Parameters< McpServer[ 'server' ][ 'sendResourceUpdated' ] > ) => {
|
|
85
|
-
return
|
|
86
|
-
|
|
87
|
-
mcpServer.server.sendResourceUpdated( ...args )
|
|
88
|
-
|
|
86
|
+
return getSDK()
|
|
87
|
+
.waitForReady()
|
|
88
|
+
.then( () => mcpServer.server.sendResourceUpdated( ...args ) )
|
|
89
|
+
.catch( ( error: Error ) => {
|
|
90
|
+
if ( error?.message?.includes( 'Not connected' ) ) {
|
|
91
|
+
return; // Expected when no MCP client is connected yet
|
|
92
|
+
}
|
|
93
|
+
throw error;
|
|
94
|
+
} );
|
|
89
95
|
},
|
|
90
96
|
mcpServer,
|
|
91
97
|
addTool,
|
|
@@ -116,7 +122,7 @@ export interface MCPRegistryEntry {
|
|
|
116
122
|
setMCPDescription: ( description: string ) => void;
|
|
117
123
|
getActiveChatInfo: () => { sessionId: string; expiresAt: number };
|
|
118
124
|
sendResourceUpdated: McpServer[ 'server' ][ 'sendResourceUpdated' ];
|
|
119
|
-
resource: McpServer[ '
|
|
125
|
+
resource: McpServer[ 'registerResource' ];
|
|
120
126
|
mcpServer: McpServer;
|
|
121
127
|
waitForReady: () => Promise< void >;
|
|
122
128
|
}
|
|
@@ -173,7 +179,6 @@ function createToolRegistry( server: McpServer ) {
|
|
|
173
179
|
try {
|
|
174
180
|
const invocationResult = await opts.handler( opts.schema ? args : {}, extra );
|
|
175
181
|
return {
|
|
176
|
-
// TODO: Uncomment this when the outputSchema is stable
|
|
177
182
|
// structuredContent: typeof invocationResult === 'string' ? undefined : invocationResult,
|
|
178
183
|
content: [
|
|
179
184
|
{
|
|
@@ -205,10 +210,10 @@ function createToolRegistry( server: McpServer ) {
|
|
|
205
210
|
readOnlyHint: opts.isDestructive ? false : undefined,
|
|
206
211
|
title: opts.name,
|
|
207
212
|
};
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
213
|
+
const angieAnnotations = {
|
|
214
|
+
[ ANGIE_MODEL_PREFERENCES ]: opts.modelPreferences ?? createDefaultModelPreferences(),
|
|
215
|
+
[ ANGIE_REQUIRED_RESOURCES ]: opts.requiredResources ?? undefined,
|
|
216
|
+
};
|
|
212
217
|
server.registerTool(
|
|
213
218
|
opts.name,
|
|
214
219
|
{
|
|
@@ -218,6 +223,7 @@ function createToolRegistry( server: McpServer ) {
|
|
|
218
223
|
// outputSchema,
|
|
219
224
|
title: opts.name,
|
|
220
225
|
annotations,
|
|
226
|
+
_meta: angieAnnotations,
|
|
221
227
|
},
|
|
222
228
|
toolCallback
|
|
223
229
|
);
|