@elementor/editor-mcp 4.1.0-838 → 4.1.0-beta2
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 +16 -9
- package/dist/index.d.ts +16 -9
- package/dist/index.js +66 -39
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +65 -40
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
- package/src/index.ts +2 -1
- package/src/mcp-registry.ts +23 -28
- package/src/utils/create-simple-resource-handler.ts +3 -0
- package/src/utils/merge-required-resources.ts +17 -0
- package/src/utils/prompt-builder.ts +3 -9
- package/src/utils/redirect-to-app-admin.ts +4 -8
- package/src/utils/redirect-to-installation.ts +2 -7
- package/src/utils/register-server-docs-resource.ts +29 -0
- package/src/utils/save-angie-consent.ts +8 -0
package/dist/index.d.mts
CHANGED
|
@@ -54,6 +54,7 @@ interface IMcpRegistrationAdapter {
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
declare const ANGIE_MODEL_PREFERENCES: "angie/modelPreferences";
|
|
57
|
+
declare const ANGIE_REQUIRED_RESOURCES: "angie/requiredResources";
|
|
57
58
|
interface AngieModelPreferences {
|
|
58
59
|
hints?: Array<{
|
|
59
60
|
name: string;
|
|
@@ -63,6 +64,11 @@ interface AngieModelPreferences {
|
|
|
63
64
|
intelligencePriority?: number;
|
|
64
65
|
}
|
|
65
66
|
|
|
67
|
+
type ResourceList = {
|
|
68
|
+
uri: string;
|
|
69
|
+
description: string;
|
|
70
|
+
}[];
|
|
71
|
+
|
|
66
72
|
declare const registerMcpAdapter: (adapter: IMcpRegistrationAdapter) => void;
|
|
67
73
|
declare const signalMcpReady: () => void;
|
|
68
74
|
declare const activateAdapters: () => void;
|
|
@@ -70,12 +76,15 @@ declare const registerMcp: (mcp: McpServer, name: string) => void;
|
|
|
70
76
|
declare const getRegisteredMcpServers: () => Array<[string, McpServer, string]>;
|
|
71
77
|
declare const toMCPTitle: (namespace: string) => string;
|
|
72
78
|
/**
|
|
73
|
-
*
|
|
74
79
|
* @param namespace The namespace of the MCP server. It should contain only lowercase alphabetic characters.
|
|
75
80
|
* @param options
|
|
76
|
-
* @param options.instructions
|
|
81
|
+
* @param options.instructions Short hint about the MCP and its toolset (MCP SDK `instructions`; keeps payload small).
|
|
82
|
+
* @param options.docs Full documentation registered as a lazy-loaded resource.
|
|
83
|
+
* When provided, it is registered at elementor://{namespace}/server-docs
|
|
84
|
+
* and auto-injected into every tool's requiredResources.
|
|
77
85
|
*/
|
|
78
86
|
declare const getMCPByDomain: (namespace: string, options?: {
|
|
87
|
+
docs?: string;
|
|
79
88
|
instructions?: string;
|
|
80
89
|
}) => MCPRegistryEntry;
|
|
81
90
|
interface MCPRegistryEntry {
|
|
@@ -85,10 +94,6 @@ interface MCPRegistryEntry {
|
|
|
85
94
|
resource: McpServer['registerResource'];
|
|
86
95
|
waitForReady: () => Promise<void>;
|
|
87
96
|
}
|
|
88
|
-
type ResourceList = {
|
|
89
|
-
uri: string;
|
|
90
|
-
description: string;
|
|
91
|
-
}[];
|
|
92
97
|
type ToolRegistrationOptions<InputArgs extends undefined | z.ZodRawShape = undefined, OutputSchema extends undefined | z.ZodRawShape = undefined, ExpectedOutput = OutputSchema extends z.ZodRawShape ? z.objectOutputType<OutputSchema, z.ZodTypeAny> : string> = {
|
|
93
98
|
name: string;
|
|
94
99
|
description: string;
|
|
@@ -378,9 +383,9 @@ declare const getActiveChatInfo: () => ActiveChatInfo;
|
|
|
378
383
|
|
|
379
384
|
declare const sendPromptToAngie: (prompt?: string) => void;
|
|
380
385
|
|
|
381
|
-
declare const redirectToInstallation: (prompt
|
|
386
|
+
declare const redirectToInstallation: (prompt?: string) => void;
|
|
382
387
|
|
|
383
|
-
declare const redirectToAppAdmin: (prompt
|
|
388
|
+
declare const redirectToAppAdmin: (prompt?: string) => void;
|
|
384
389
|
|
|
385
390
|
type InstallAngieResult = {
|
|
386
391
|
success: true;
|
|
@@ -391,8 +396,10 @@ type InstallAngieResult = {
|
|
|
391
396
|
};
|
|
392
397
|
declare const installAngiePlugin: () => Promise<InstallAngieResult>;
|
|
393
398
|
|
|
399
|
+
declare const saveAngieConsent: () => Promise<void>;
|
|
400
|
+
|
|
394
401
|
declare function startMCPServer(): void;
|
|
395
402
|
|
|
396
403
|
declare const getAngieSdk: () => _elementor_external_angie_sdk.AngieMcpSdk;
|
|
397
404
|
|
|
398
|
-
export { ANGIE_MODEL_PREFERENCES, type ActiveChatInfo, type AngieModelPreferences, type InstallAngieResult, type MCPRegistryEntry, activateAdapters, createSampler, getActiveChatInfo, getAngieSdk, getMCPByDomain, getRegisteredMcpServers, installAngiePlugin, isAngieAvailable, isAngieSidebarOpen, redirectToAppAdmin, redirectToInstallation, registerMcp, registerMcpAdapter, sendPromptToAngie, signalMcpReady, startMCPServer, toMCPTitle, toolPrompts };
|
|
405
|
+
export { ANGIE_MODEL_PREFERENCES, ANGIE_REQUIRED_RESOURCES, type ActiveChatInfo, type AngieModelPreferences, type InstallAngieResult, type MCPRegistryEntry, activateAdapters, createSampler, getActiveChatInfo, getAngieSdk, getMCPByDomain, getRegisteredMcpServers, installAngiePlugin, isAngieAvailable, isAngieSidebarOpen, redirectToAppAdmin, redirectToInstallation, registerMcp, registerMcpAdapter, saveAngieConsent, sendPromptToAngie, signalMcpReady, startMCPServer, toMCPTitle, toolPrompts };
|
package/dist/index.d.ts
CHANGED
|
@@ -54,6 +54,7 @@ interface IMcpRegistrationAdapter {
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
declare const ANGIE_MODEL_PREFERENCES: "angie/modelPreferences";
|
|
57
|
+
declare const ANGIE_REQUIRED_RESOURCES: "angie/requiredResources";
|
|
57
58
|
interface AngieModelPreferences {
|
|
58
59
|
hints?: Array<{
|
|
59
60
|
name: string;
|
|
@@ -63,6 +64,11 @@ interface AngieModelPreferences {
|
|
|
63
64
|
intelligencePriority?: number;
|
|
64
65
|
}
|
|
65
66
|
|
|
67
|
+
type ResourceList = {
|
|
68
|
+
uri: string;
|
|
69
|
+
description: string;
|
|
70
|
+
}[];
|
|
71
|
+
|
|
66
72
|
declare const registerMcpAdapter: (adapter: IMcpRegistrationAdapter) => void;
|
|
67
73
|
declare const signalMcpReady: () => void;
|
|
68
74
|
declare const activateAdapters: () => void;
|
|
@@ -70,12 +76,15 @@ declare const registerMcp: (mcp: McpServer, name: string) => void;
|
|
|
70
76
|
declare const getRegisteredMcpServers: () => Array<[string, McpServer, string]>;
|
|
71
77
|
declare const toMCPTitle: (namespace: string) => string;
|
|
72
78
|
/**
|
|
73
|
-
*
|
|
74
79
|
* @param namespace The namespace of the MCP server. It should contain only lowercase alphabetic characters.
|
|
75
80
|
* @param options
|
|
76
|
-
* @param options.instructions
|
|
81
|
+
* @param options.instructions Short hint about the MCP and its toolset (MCP SDK `instructions`; keeps payload small).
|
|
82
|
+
* @param options.docs Full documentation registered as a lazy-loaded resource.
|
|
83
|
+
* When provided, it is registered at elementor://{namespace}/server-docs
|
|
84
|
+
* and auto-injected into every tool's requiredResources.
|
|
77
85
|
*/
|
|
78
86
|
declare const getMCPByDomain: (namespace: string, options?: {
|
|
87
|
+
docs?: string;
|
|
79
88
|
instructions?: string;
|
|
80
89
|
}) => MCPRegistryEntry;
|
|
81
90
|
interface MCPRegistryEntry {
|
|
@@ -85,10 +94,6 @@ interface MCPRegistryEntry {
|
|
|
85
94
|
resource: McpServer['registerResource'];
|
|
86
95
|
waitForReady: () => Promise<void>;
|
|
87
96
|
}
|
|
88
|
-
type ResourceList = {
|
|
89
|
-
uri: string;
|
|
90
|
-
description: string;
|
|
91
|
-
}[];
|
|
92
97
|
type ToolRegistrationOptions<InputArgs extends undefined | z.ZodRawShape = undefined, OutputSchema extends undefined | z.ZodRawShape = undefined, ExpectedOutput = OutputSchema extends z.ZodRawShape ? z.objectOutputType<OutputSchema, z.ZodTypeAny> : string> = {
|
|
93
98
|
name: string;
|
|
94
99
|
description: string;
|
|
@@ -378,9 +383,9 @@ declare const getActiveChatInfo: () => ActiveChatInfo;
|
|
|
378
383
|
|
|
379
384
|
declare const sendPromptToAngie: (prompt?: string) => void;
|
|
380
385
|
|
|
381
|
-
declare const redirectToInstallation: (prompt
|
|
386
|
+
declare const redirectToInstallation: (prompt?: string) => void;
|
|
382
387
|
|
|
383
|
-
declare const redirectToAppAdmin: (prompt
|
|
388
|
+
declare const redirectToAppAdmin: (prompt?: string) => void;
|
|
384
389
|
|
|
385
390
|
type InstallAngieResult = {
|
|
386
391
|
success: true;
|
|
@@ -391,8 +396,10 @@ type InstallAngieResult = {
|
|
|
391
396
|
};
|
|
392
397
|
declare const installAngiePlugin: () => Promise<InstallAngieResult>;
|
|
393
398
|
|
|
399
|
+
declare const saveAngieConsent: () => Promise<void>;
|
|
400
|
+
|
|
394
401
|
declare function startMCPServer(): void;
|
|
395
402
|
|
|
396
403
|
declare const getAngieSdk: () => _elementor_external_angie_sdk.AngieMcpSdk;
|
|
397
404
|
|
|
398
|
-
export { ANGIE_MODEL_PREFERENCES, type ActiveChatInfo, type AngieModelPreferences, type InstallAngieResult, type MCPRegistryEntry, activateAdapters, createSampler, getActiveChatInfo, getAngieSdk, getMCPByDomain, getRegisteredMcpServers, installAngiePlugin, isAngieAvailable, isAngieSidebarOpen, redirectToAppAdmin, redirectToInstallation, registerMcp, registerMcpAdapter, sendPromptToAngie, signalMcpReady, startMCPServer, toMCPTitle, toolPrompts };
|
|
405
|
+
export { ANGIE_MODEL_PREFERENCES, ANGIE_REQUIRED_RESOURCES, type ActiveChatInfo, type AngieModelPreferences, type InstallAngieResult, type MCPRegistryEntry, activateAdapters, createSampler, getActiveChatInfo, getAngieSdk, getMCPByDomain, getRegisteredMcpServers, installAngiePlugin, isAngieAvailable, isAngieSidebarOpen, redirectToAppAdmin, redirectToInstallation, registerMcp, registerMcpAdapter, saveAngieConsent, sendPromptToAngie, signalMcpReady, startMCPServer, toMCPTitle, toolPrompts };
|
package/dist/index.js
CHANGED
|
@@ -31,6 +31,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
31
|
var index_exports = {};
|
|
32
32
|
__export(index_exports, {
|
|
33
33
|
ANGIE_MODEL_PREFERENCES: () => ANGIE_MODEL_PREFERENCES,
|
|
34
|
+
ANGIE_REQUIRED_RESOURCES: () => ANGIE_REQUIRED_RESOURCES,
|
|
34
35
|
AngieMessageEvenetType: () => import_angie_sdk2.MessageEventType,
|
|
35
36
|
McpServer: () => import_mcp2.McpServer,
|
|
36
37
|
ResourceTemplate: () => import_mcp2.ResourceTemplate,
|
|
@@ -49,6 +50,7 @@ __export(index_exports, {
|
|
|
49
50
|
redirectToInstallation: () => redirectToInstallation,
|
|
50
51
|
registerMcp: () => registerMcp,
|
|
51
52
|
registerMcpAdapter: () => registerMcpAdapter,
|
|
53
|
+
saveAngieConsent: () => saveAngieConsent,
|
|
52
54
|
sendPromptToAngie: () => sendPromptToAngie,
|
|
53
55
|
signalMcpReady: () => signalMcpReady,
|
|
54
56
|
startMCPServer: () => startMCPServer,
|
|
@@ -91,7 +93,6 @@ var isAngieSidebarOpen = () => {
|
|
|
91
93
|
// src/mcp-registry.ts
|
|
92
94
|
var import_schema = require("@elementor/schema");
|
|
93
95
|
var import_mcp = require("@modelcontextprotocol/sdk/server/mcp.js");
|
|
94
|
-
var import_uriTemplate = require("@modelcontextprotocol/sdk/shared/uriTemplate.js");
|
|
95
96
|
|
|
96
97
|
// src/angie-annotations.ts
|
|
97
98
|
var ANGIE_MODEL_PREFERENCES = "angie/modelPreferences";
|
|
@@ -131,6 +132,40 @@ var mockMcpRegistry = () => {
|
|
|
131
132
|
};
|
|
132
133
|
};
|
|
133
134
|
|
|
135
|
+
// src/utils/merge-required-resources.ts
|
|
136
|
+
var mergeRequiredResources = (toolResources, serverDocsUri) => {
|
|
137
|
+
if (!serverDocsUri) {
|
|
138
|
+
return toolResources;
|
|
139
|
+
}
|
|
140
|
+
if (toolResources?.some((r) => r.uri === serverDocsUri)) {
|
|
141
|
+
return toolResources;
|
|
142
|
+
}
|
|
143
|
+
return [...toolResources ?? [], { uri: serverDocsUri, description: "Server docs" }];
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
// src/utils/create-simple-resource-handler.ts
|
|
147
|
+
var createSimpleResourceHandler = (text) => async (uri) => ({
|
|
148
|
+
contents: [{ uri: uri.href, mimeType: "text/plain", text }]
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
// src/utils/register-server-docs-resource.ts
|
|
152
|
+
var registerServerDocsResource = (server, namespace, title, docs, onRegistered) => {
|
|
153
|
+
const uri = `elementor://${namespace}/server-docs`;
|
|
154
|
+
const name = `${namespace}-server-docs`;
|
|
155
|
+
const handler = createSimpleResourceHandler(docs);
|
|
156
|
+
server.registerResource(
|
|
157
|
+
name,
|
|
158
|
+
uri,
|
|
159
|
+
{
|
|
160
|
+
title: `${title} server docs`,
|
|
161
|
+
description: "Full MCP documentation (lazy-loaded)",
|
|
162
|
+
mimeType: "text/plain"
|
|
163
|
+
},
|
|
164
|
+
handler
|
|
165
|
+
);
|
|
166
|
+
onRegistered(name, uri, handler);
|
|
167
|
+
};
|
|
168
|
+
|
|
134
169
|
// src/mcp-registry.ts
|
|
135
170
|
var mcpRegistry = {};
|
|
136
171
|
var mcpDescriptions = {};
|
|
@@ -193,28 +228,19 @@ var getMCPByDomain = (namespace, options) => {
|
|
|
193
228
|
}
|
|
194
229
|
if (!mcpRegistry[namespace]) {
|
|
195
230
|
mcpRegistry[namespace] = new import_mcp.McpServer(
|
|
196
|
-
{
|
|
197
|
-
|
|
198
|
-
title,
|
|
199
|
-
version: "1.0.0"
|
|
200
|
-
},
|
|
201
|
-
{
|
|
202
|
-
instructions: options?.instructions,
|
|
203
|
-
capabilities: { resources: { subscribe: true } }
|
|
204
|
-
}
|
|
231
|
+
{ name: mcpName, title, version: "1.0.0" },
|
|
232
|
+
{ instructions: options?.instructions, capabilities: { resources: { subscribe: true } } }
|
|
205
233
|
);
|
|
206
|
-
if (
|
|
207
|
-
|
|
208
|
-
(
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
() => Promise.resolve({ contents: [{ text: options.instructions ?? "" }] })
|
|
212
|
-
)
|
|
213
|
-
);
|
|
234
|
+
if (options?.docs) {
|
|
235
|
+
registerServerDocsResource(mcpRegistry[namespace], namespace, title, options.docs, (...args) => {
|
|
236
|
+
bufferedResources.push(args);
|
|
237
|
+
callAdapters((adapter) => adapter.onResourceRegistered(...args));
|
|
238
|
+
});
|
|
214
239
|
}
|
|
215
240
|
}
|
|
216
241
|
const mcpServer = mcpRegistry[namespace];
|
|
217
|
-
const
|
|
242
|
+
const serverDocsUri = options?.docs ? `elementor://${namespace}/server-docs` : void 0;
|
|
243
|
+
const { addTool } = createToolRegistry(mcpServer, mcpName, serverDocsUri);
|
|
218
244
|
return {
|
|
219
245
|
waitForReady: () => readyPromise,
|
|
220
246
|
// @ts-expect-error: TS is unable to infer the type here
|
|
@@ -248,7 +274,7 @@ var getMCPByDomain = (namespace, options) => {
|
|
|
248
274
|
}
|
|
249
275
|
};
|
|
250
276
|
};
|
|
251
|
-
function createToolRegistry(server, serverName) {
|
|
277
|
+
function createToolRegistry(server, serverName, serverDocsUri) {
|
|
252
278
|
function addTool(opts) {
|
|
253
279
|
const outputSchema = opts.outputSchema;
|
|
254
280
|
if (outputSchema) {
|
|
@@ -292,9 +318,10 @@ function createToolRegistry(server, serverName) {
|
|
|
292
318
|
readOnlyHint: opts.isDestructive ? false : void 0,
|
|
293
319
|
title: opts.name
|
|
294
320
|
};
|
|
321
|
+
const mergedResources = mergeRequiredResources(opts.requiredResources, serverDocsUri);
|
|
295
322
|
const angieAnnotations = {
|
|
296
323
|
[ANGIE_MODEL_PREFERENCES]: opts.modelPreferences ?? createDefaultModelPreferences(),
|
|
297
|
-
[ANGIE_REQUIRED_RESOURCES]:
|
|
324
|
+
[ANGIE_REQUIRED_RESOURCES]: mergedResources
|
|
298
325
|
};
|
|
299
326
|
server.registerTool(
|
|
300
327
|
opts.name,
|
|
@@ -323,7 +350,7 @@ function createToolRegistry(server, serverName) {
|
|
|
323
350
|
};
|
|
324
351
|
const extraData = {
|
|
325
352
|
resources: [`Server resource name: ${serverName}, Required to fetch!`],
|
|
326
|
-
requiredResources:
|
|
353
|
+
requiredResources: mergedResources?.map((resource) => resource.uri) ?? []
|
|
327
354
|
};
|
|
328
355
|
bufferedTools.push([toolDescriptor, extraData]);
|
|
329
356
|
callAdapters((adapter) => adapter.onToolRegistered(toolDescriptor, extraData));
|
|
@@ -423,15 +450,9 @@ ${description}`;
|
|
|
423
450
|
return `# ${this.name}
|
|
424
451
|
# Description
|
|
425
452
|
${this._description}
|
|
426
|
-
|
|
427
|
-
${this.
|
|
428
|
-
${
|
|
429
|
-
|
|
430
|
-
${this._examples.length ? "# Examples" : ""}
|
|
431
|
-
${this.examples}
|
|
432
|
-
|
|
433
|
-
${this._furtherInstructions.length ? "# Further Instructions" : ""}
|
|
434
|
-
${this._furtherInstructions.join("\n\n")}
|
|
453
|
+
${this._parameters.length ? "# Parameters\n" + Object.values(this._parameters).join("\n\n") : ""}
|
|
454
|
+
${this._examples.length ? "# Examples\n" + this.examples : ""}
|
|
455
|
+
${this._furtherInstructions.length ? "# Further Instructions\n" + this._furtherInstructions.join("\n\n") : ""}
|
|
435
456
|
`.trim();
|
|
436
457
|
}
|
|
437
458
|
};
|
|
@@ -473,10 +494,7 @@ var sendPromptToAngie = (prompt) => {
|
|
|
473
494
|
var import_angie_sdk6 = require("@elementor-external/angie-sdk");
|
|
474
495
|
var ANGIE_INSTALL_URL = "/wp-admin/plugin-install.php?s=angie&tab=search&type=term";
|
|
475
496
|
var redirectToInstallation = (prompt) => {
|
|
476
|
-
|
|
477
|
-
if (!success) {
|
|
478
|
-
return;
|
|
479
|
-
}
|
|
497
|
+
(0, import_angie_sdk6.setReferrerRedirect)(window.location.href, prompt);
|
|
480
498
|
window.location.href = ANGIE_INSTALL_URL;
|
|
481
499
|
};
|
|
482
500
|
|
|
@@ -484,10 +502,8 @@ var redirectToInstallation = (prompt) => {
|
|
|
484
502
|
var import_angie_sdk7 = require("@elementor-external/angie-sdk");
|
|
485
503
|
var ANGIE_APP_URL = "/wp-admin/admin.php?page=angie-app";
|
|
486
504
|
var redirectToAppAdmin = (prompt) => {
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
return;
|
|
490
|
-
}
|
|
505
|
+
(0, import_angie_sdk7.setReferrerRedirect)(window.location.href, prompt);
|
|
506
|
+
(0, import_angie_sdk7.saveState)(import_angie_sdk7.ANGIE_SIDEBAR_STATE_OPEN);
|
|
491
507
|
window.location.href = ANGIE_APP_URL;
|
|
492
508
|
};
|
|
493
509
|
|
|
@@ -533,6 +549,15 @@ var installAngiePlugin = async () => {
|
|
|
533
549
|
}
|
|
534
550
|
};
|
|
535
551
|
|
|
552
|
+
// src/utils/save-angie-consent.ts
|
|
553
|
+
var import_api_fetch2 = __toESM(require("@wordpress/api-fetch"));
|
|
554
|
+
var saveAngieConsent = async () => {
|
|
555
|
+
await (0, import_api_fetch2.default)({
|
|
556
|
+
path: "/elementor/v1/angie/consent",
|
|
557
|
+
method: "POST"
|
|
558
|
+
});
|
|
559
|
+
};
|
|
560
|
+
|
|
536
561
|
// src/adapters/angie-adapter.ts
|
|
537
562
|
var MAX_RETRIES = 3;
|
|
538
563
|
var AngieMcpAdapter = class {
|
|
@@ -721,6 +746,7 @@ var getAngieSdk = () => getSDK();
|
|
|
721
746
|
// Annotate the CommonJS export names for ESM import in node:
|
|
722
747
|
0 && (module.exports = {
|
|
723
748
|
ANGIE_MODEL_PREFERENCES,
|
|
749
|
+
ANGIE_REQUIRED_RESOURCES,
|
|
724
750
|
AngieMessageEvenetType,
|
|
725
751
|
McpServer,
|
|
726
752
|
ResourceTemplate,
|
|
@@ -739,6 +765,7 @@ var getAngieSdk = () => getSDK();
|
|
|
739
765
|
redirectToInstallation,
|
|
740
766
|
registerMcp,
|
|
741
767
|
registerMcpAdapter,
|
|
768
|
+
saveAngieConsent,
|
|
742
769
|
sendPromptToAngie,
|
|
743
770
|
signalMcpReady,
|
|
744
771
|
startMCPServer,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/utils/get-sdk.ts","../src/utils/is-angie-available.ts","../src/utils/is-angie-sidebar-open.ts","../src/mcp-registry.ts","../src/angie-annotations.ts","../src/test-utils/mock-mcp-registry.ts","../src/sampler.ts","../src/utils/prompt-builder.ts","../src/utils/get-active-chat-info.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/adapters/angie-adapter.ts","../src/adapters/web-mcp-adapter.ts","../src/init.ts"],"sourcesContent":["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, type AngieModelPreferences } from './angie-annotations';\nexport { getActiveChatInfo, type ActiveChatInfo } from './utils/get-active-chat-info';\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();\nexport * from './init';\n","import { AngieMcpSdk } from '@elementor-external/angie-sdk';\nexport { getAngieIframe, MessageEventType } 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 { 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 { UriTemplate } from '@modelcontextprotocol/sdk/shared/uriTemplate.js';\nimport { type ServerNotification, type ServerRequest } from '@modelcontextprotocol/sdk/types.js';\n\nimport { type IMcpRegistrationAdapter, type McpResourceHandler, type McpResourceUriOrTemplate } from './adapters/types';\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';\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 => resolveReady();\n\nexport const activateAdapters = (): void => callAdapters( ( adapter ) => adapter.activate() );\n\nfunction callAdapters( fn: ( adapter: IMcpRegistrationAdapter ) => void ): void {\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\nexport const toMCPTitle = ( namespace: string ): string => {\n\tconst capitalized = namespace.charAt( 0 ).toUpperCase() + namespace.slice( 1 );\n\treturn `Editor ${ capitalized }`;\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\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{\n\t\t\t\tname: mcpName,\n\t\t\t\ttitle,\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\tcapabilities: { resources: { subscribe: true } },\n\t\t\t}\n\t\t);\n\t\tif ( !! options?.instructions ) {\n\t\t\tcallAdapters( ( adapter ) =>\n\t\t\t\tadapter.onResourceRegistered( `${ mcpName }`, { uriTemplate: new UriTemplate( mcpName ) }, () =>\n\t\t\t\t\tPromise.resolve( { contents: [ { text: options.instructions ?? '' } ] } )\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\t}\n\tconst mcpServer = mcpRegistry[ namespace ];\n\tconst { addTool } = createToolRegistry( mcpServer, mcpName );\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 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, serverName: 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: ( 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\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\tPromise.resolve(\n\t\t\t\t\ttoolCallback(\n\t\t\t\t\t\tparams as Parameters< typeof toolCallback >[ 0 ],\n\t\t\t\t\t\t/* WebMCP: no protocol session — handlers must not rely on `extra` here */\n\t\t\t\t\t\t{} as RequestHandlerExtra< ServerRequest, ServerNotification >\n\t\t\t\t\t)\n\t\t\t\t),\n\t\t};\n\t\tconst extraData = {\n\t\t\tresources: [ `Server resource name: ${ serverName }, Required to fetch!` ],\n\t\t\trequiredResources: opts.requiredResources?.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 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\tmcpServer: mock as McpServer,\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\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","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 { 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","import { type AngieMcpSdk } from '@elementor-external/angie-sdk';\n\nimport { getRegisteredMcpServers, toMCPTitle } from '../mcp-registry';\nimport { type IMcpRegistrationAdapter } from './types';\n\nconst MAX_RETRIES = 3;\n\nexport class AngieMcpAdapter implements IMcpRegistrationAdapter {\n\tconstructor( private readonly sdk: AngieMcpSdk ) {}\n\n\tasync activate(): Promise< void > {\n\t\tawait this.sdk.waitForReady();\n\t\tawait this.registerEntries( 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 {\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: ( tool: McpToolDescriptor ) => void;\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(): void {\n\t\tif ( this.activated ) {\n\t\t\treturn;\n\t\t}\n\t\tthis.activated = true;\n\t\tthis.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://styles/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}\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\tthis.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} );\n\t\tthis.registeredToolNames.add( tool.name );\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 { AngieMcpAdapter } from './adapters/angie-adapter';\nimport { type ModelContext, WebMCPAdapter } from './adapters/web-mcp-adapter';\nimport { activateAdapters, registerMcpAdapter, signalMcpReady } from './mcp-registry';\nimport { getSDK } from './utils/get-sdk';\nimport { isAngieAvailable } from './utils/is-angie-available';\n\nexport function startMCPServer() {\n\tif ( typeof navigator !== 'undefined' && 'modelContext' in navigator ) {\n\t\tregisterMcpAdapter(\n\t\t\tnew WebMCPAdapter( ( navigator as unknown as { modelContext: ModelContext } ).modelContext )\n\t\t);\n\t}\n\n\tif ( isAngieAvailable() ) {\n\t\tregisterMcpAdapter( new AngieMcpAdapter( getSDK() ) );\n\t}\n\n\tactivateAdapters();\n\tsignalMcpReady();\n}\n\nif ( typeof document !== 'undefined' ) {\n\tdocument.addEventListener( 'DOMContentLoaded', () => startMCPServer(), { once: true } );\n} else {\n\tstartMCPServer();\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,uBAA4B;AAC5B,IAAAA,oBAAiD;AAEjD,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,6BAAY;AAAA,EACvB;AACA,SAAO;AACR;;;ADZA,IAAAC,cAKO;AACP,IAAAC,gBAAsC;;;AETtC,IAAAC,oBAA+B;AAExB,IAAM,mBAAmB,MAAe;AAC9C,SAAO,CAAC,KAAE,kCAAe;AAC1B;;;ACJA,IAAAC,oBAAoE;AAE7D,IAAM,qBAAqB,MAAe;AAChD,aAAO,6CAA0B,MAAM;AACxC;;;ACJA,oBAA2B;AAC3B,iBAA6C;AAE7C,yBAA4B;;;ACHrB,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;AAA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,oBAAoB,IAAK,KAAK,IAAK;AAAA,EACzC;AAAA,EAEA,qBAAsB,OAAe,eAAyC,SAAoC;AACjH,QAAK,OAAO,kBAAkB,UAAW;AACxC,WAAK,gBAAgB,KAAM;AAAA,QAC1B,SAAS;AAAA,QACT,OAAO,CAAE,QAAW,QAAQ,gBAAgB,CAAC,IAAI;AAAA,QACjD;AAAA,MACD,CAAE;AAAA,IACH,OAAO;AACN,YAAM,WAAW,cAAc;AAC/B,WAAK,gBAAgB,KAAM;AAAA,QAC1B,SAAS,SAAS,SAAS;AAAA,QAC3B,OAAO,CAAE,QAAS,SAAS,MAAO,GAAI;AAAA,QACtC;AAAA,MACD,CAAE;AAAA,IACH;AAAA,EACD;AAAA,EAEA,sBAA4B;AAAA,EAE5B;AACD;;;ACxIO,SAAS,iBAAiB;AAChC,MAAK,OAAO,cAAc,eAAe,kBAAkB,WAAY;AACtE;AAAA,MACC,IAAI,cAAiB,UAAyD,YAAa;AAAA,IAC5F;AAAA,EACD;AAEA,MAAK,iBAAiB,GAAI;AACzB,uBAAoB,IAAI,gBAAiB,OAAO,CAAE,CAAE;AAAA,EACrD;AAEA,mBAAiB;AACjB,iBAAe;AAChB;AAEA,IAAK,OAAO,aAAa,aAAc;AACtC,WAAS,iBAAkB,oBAAoB,MAAM,eAAe,GAAG,EAAE,MAAM,KAAK,CAAE;AACvF,OAAO;AACN,iBAAe;AAChB;;;AhBJO,IAAM,cAAc,MAAM,OAAO;","names":["import_angie_sdk","import_mcp","import_types","import_angie_sdk","import_angie_sdk","import_angie_sdk","import_angie_sdk","import_angie_sdk","apiFetch","sdk","import_schema"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/utils/get-sdk.ts","../src/utils/is-angie-available.ts","../src/utils/is-angie-sidebar-open.ts","../src/mcp-registry.ts","../src/angie-annotations.ts","../src/test-utils/mock-mcp-registry.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/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/adapters/angie-adapter.ts","../src/adapters/web-mcp-adapter.ts","../src/init.ts"],"sourcesContent":["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 { 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';\n","import { AngieMcpSdk } from '@elementor-external/angie-sdk';\nexport { getAngieIframe, MessageEventType } 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 { 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 { type IMcpRegistrationAdapter, type McpResourceHandler, type McpResourceUriOrTemplate } from './adapters/types';\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 { mergeRequiredResources, type ResourceList } from './utils/merge-required-resources';\nimport { registerServerDocsResource } from './utils/register-server-docs-resource';\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 => resolveReady();\n\nexport const activateAdapters = (): void => callAdapters( ( adapter ) => adapter.activate() );\n\nfunction callAdapters( fn: ( adapter: IMcpRegistrationAdapter ) => void ): void {\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\nexport const toMCPTitle = ( namespace: string ): string => {\n\tconst capitalized = namespace.charAt( 0 ).toUpperCase() + namespace.slice( 1 );\n\treturn `Editor ${ capitalized }`;\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: ( 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 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\tPromise.resolve(\n\t\t\t\t\ttoolCallback(\n\t\t\t\t\t\tparams as Parameters< typeof toolCallback >[ 0 ],\n\t\t\t\t\t\t/* WebMCP: no protocol session — handlers must not rely on `extra` here */\n\t\t\t\t\t\t{} as RequestHandlerExtra< ServerRequest, ServerNotification >\n\t\t\t\t\t)\n\t\t\t\t),\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 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\tmcpServer: mock as McpServer,\n\t};\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 { 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 { type AngieMcpSdk } from '@elementor-external/angie-sdk';\n\nimport { getRegisteredMcpServers, toMCPTitle } from '../mcp-registry';\nimport { type IMcpRegistrationAdapter } from './types';\n\nconst MAX_RETRIES = 3;\n\nexport class AngieMcpAdapter implements IMcpRegistrationAdapter {\n\tconstructor( private readonly sdk: AngieMcpSdk ) {}\n\n\tasync activate(): Promise< void > {\n\t\tawait this.sdk.waitForReady();\n\t\tawait this.registerEntries( 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 {\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: ( tool: McpToolDescriptor ) => void;\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(): void {\n\t\tif ( this.activated ) {\n\t\t\treturn;\n\t\t}\n\t\tthis.activated = true;\n\t\tthis.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://styles/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}\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\tthis.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} );\n\t\tthis.registeredToolNames.add( tool.name );\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 { AngieMcpAdapter } from './adapters/angie-adapter';\nimport { type ModelContext, WebMCPAdapter } from './adapters/web-mcp-adapter';\nimport { activateAdapters, registerMcpAdapter, signalMcpReady } from './mcp-registry';\nimport { getSDK } from './utils/get-sdk';\nimport { isAngieAvailable } from './utils/is-angie-available';\n\nexport function startMCPServer() {\n\tif ( typeof navigator !== 'undefined' && 'modelContext' in navigator ) {\n\t\tregisterMcpAdapter(\n\t\t\tnew WebMCPAdapter( ( navigator as unknown as { modelContext: ModelContext } ).modelContext )\n\t\t);\n\t}\n\n\tif ( isAngieAvailable() ) {\n\t\tregisterMcpAdapter( new AngieMcpAdapter( getSDK() ) );\n\t}\n\n\tactivateAdapters();\n\tsignalMcpReady();\n}\n\nif ( typeof document !== 'undefined' ) {\n\tdocument.addEventListener( 'DOMContentLoaded', () => startMCPServer(), { once: true } );\n} else {\n\tstartMCPServer();\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,uBAA4B;AAC5B,IAAAA,oBAAiD;AAEjD,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,6BAAY;AAAA,EACvB;AACA,SAAO;AACR;;;ADZA,IAAAC,cAKO;AACP,IAAAC,gBAAsC;;;AETtC,IAAAC,oBAA+B;AAExB,IAAM,mBAAmB,MAAe;AAC9C,SAAO,CAAC,KAAE,kCAAe;AAC1B;;;ACJA,IAAAC,oBAAoE;AAE7D,IAAM,qBAAqB,MAAe;AAChD,aAAO,6CAA0B,MAAM;AACxC;;;ACJA,oBAA2B;AAC3B,iBAA6C;;;ACDtC,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,IAEv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aAAa,aAAc;AACtC,WAAS,iBAAkB,oBAAoB,MAAM,eAAe,GAAG,EAAE,MAAM,KAAK,CAAE;AACvF,OAAO;AACN,iBAAe;AAChB;;;ApBHO,IAAM,cAAc,MAAM,OAAO;","names":["import_angie_sdk","import_mcp","import_types","import_angie_sdk","import_angie_sdk","import_angie_sdk","import_angie_sdk","import_angie_sdk","apiFetch","import_api_fetch","apiFetch","sdk","import_schema"]}
|
package/dist/index.mjs
CHANGED
|
@@ -35,7 +35,6 @@ var isAngieSidebarOpen = () => {
|
|
|
35
35
|
// src/mcp-registry.ts
|
|
36
36
|
import { z } from "@elementor/schema";
|
|
37
37
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
38
|
-
import { UriTemplate } from "@modelcontextprotocol/sdk/shared/uriTemplate.js";
|
|
39
38
|
|
|
40
39
|
// src/angie-annotations.ts
|
|
41
40
|
var ANGIE_MODEL_PREFERENCES = "angie/modelPreferences";
|
|
@@ -75,6 +74,40 @@ var mockMcpRegistry = () => {
|
|
|
75
74
|
};
|
|
76
75
|
};
|
|
77
76
|
|
|
77
|
+
// src/utils/merge-required-resources.ts
|
|
78
|
+
var mergeRequiredResources = (toolResources, serverDocsUri) => {
|
|
79
|
+
if (!serverDocsUri) {
|
|
80
|
+
return toolResources;
|
|
81
|
+
}
|
|
82
|
+
if (toolResources?.some((r) => r.uri === serverDocsUri)) {
|
|
83
|
+
return toolResources;
|
|
84
|
+
}
|
|
85
|
+
return [...toolResources ?? [], { uri: serverDocsUri, description: "Server docs" }];
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
// src/utils/create-simple-resource-handler.ts
|
|
89
|
+
var createSimpleResourceHandler = (text) => async (uri) => ({
|
|
90
|
+
contents: [{ uri: uri.href, mimeType: "text/plain", text }]
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
// src/utils/register-server-docs-resource.ts
|
|
94
|
+
var registerServerDocsResource = (server, namespace, title, docs, onRegistered) => {
|
|
95
|
+
const uri = `elementor://${namespace}/server-docs`;
|
|
96
|
+
const name = `${namespace}-server-docs`;
|
|
97
|
+
const handler = createSimpleResourceHandler(docs);
|
|
98
|
+
server.registerResource(
|
|
99
|
+
name,
|
|
100
|
+
uri,
|
|
101
|
+
{
|
|
102
|
+
title: `${title} server docs`,
|
|
103
|
+
description: "Full MCP documentation (lazy-loaded)",
|
|
104
|
+
mimeType: "text/plain"
|
|
105
|
+
},
|
|
106
|
+
handler
|
|
107
|
+
);
|
|
108
|
+
onRegistered(name, uri, handler);
|
|
109
|
+
};
|
|
110
|
+
|
|
78
111
|
// src/mcp-registry.ts
|
|
79
112
|
var mcpRegistry = {};
|
|
80
113
|
var mcpDescriptions = {};
|
|
@@ -137,28 +170,19 @@ var getMCPByDomain = (namespace, options) => {
|
|
|
137
170
|
}
|
|
138
171
|
if (!mcpRegistry[namespace]) {
|
|
139
172
|
mcpRegistry[namespace] = new McpServer(
|
|
140
|
-
{
|
|
141
|
-
|
|
142
|
-
title,
|
|
143
|
-
version: "1.0.0"
|
|
144
|
-
},
|
|
145
|
-
{
|
|
146
|
-
instructions: options?.instructions,
|
|
147
|
-
capabilities: { resources: { subscribe: true } }
|
|
148
|
-
}
|
|
173
|
+
{ name: mcpName, title, version: "1.0.0" },
|
|
174
|
+
{ instructions: options?.instructions, capabilities: { resources: { subscribe: true } } }
|
|
149
175
|
);
|
|
150
|
-
if (
|
|
151
|
-
|
|
152
|
-
(
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
() => Promise.resolve({ contents: [{ text: options.instructions ?? "" }] })
|
|
156
|
-
)
|
|
157
|
-
);
|
|
176
|
+
if (options?.docs) {
|
|
177
|
+
registerServerDocsResource(mcpRegistry[namespace], namespace, title, options.docs, (...args) => {
|
|
178
|
+
bufferedResources.push(args);
|
|
179
|
+
callAdapters((adapter) => adapter.onResourceRegistered(...args));
|
|
180
|
+
});
|
|
158
181
|
}
|
|
159
182
|
}
|
|
160
183
|
const mcpServer = mcpRegistry[namespace];
|
|
161
|
-
const
|
|
184
|
+
const serverDocsUri = options?.docs ? `elementor://${namespace}/server-docs` : void 0;
|
|
185
|
+
const { addTool } = createToolRegistry(mcpServer, mcpName, serverDocsUri);
|
|
162
186
|
return {
|
|
163
187
|
waitForReady: () => readyPromise,
|
|
164
188
|
// @ts-expect-error: TS is unable to infer the type here
|
|
@@ -192,7 +216,7 @@ var getMCPByDomain = (namespace, options) => {
|
|
|
192
216
|
}
|
|
193
217
|
};
|
|
194
218
|
};
|
|
195
|
-
function createToolRegistry(server, serverName) {
|
|
219
|
+
function createToolRegistry(server, serverName, serverDocsUri) {
|
|
196
220
|
function addTool(opts) {
|
|
197
221
|
const outputSchema = opts.outputSchema;
|
|
198
222
|
if (outputSchema) {
|
|
@@ -236,9 +260,10 @@ function createToolRegistry(server, serverName) {
|
|
|
236
260
|
readOnlyHint: opts.isDestructive ? false : void 0,
|
|
237
261
|
title: opts.name
|
|
238
262
|
};
|
|
263
|
+
const mergedResources = mergeRequiredResources(opts.requiredResources, serverDocsUri);
|
|
239
264
|
const angieAnnotations = {
|
|
240
265
|
[ANGIE_MODEL_PREFERENCES]: opts.modelPreferences ?? createDefaultModelPreferences(),
|
|
241
|
-
[ANGIE_REQUIRED_RESOURCES]:
|
|
266
|
+
[ANGIE_REQUIRED_RESOURCES]: mergedResources
|
|
242
267
|
};
|
|
243
268
|
server.registerTool(
|
|
244
269
|
opts.name,
|
|
@@ -267,7 +292,7 @@ function createToolRegistry(server, serverName) {
|
|
|
267
292
|
};
|
|
268
293
|
const extraData = {
|
|
269
294
|
resources: [`Server resource name: ${serverName}, Required to fetch!`],
|
|
270
|
-
requiredResources:
|
|
295
|
+
requiredResources: mergedResources?.map((resource) => resource.uri) ?? []
|
|
271
296
|
};
|
|
272
297
|
bufferedTools.push([toolDescriptor, extraData]);
|
|
273
298
|
callAdapters((adapter) => adapter.onToolRegistered(toolDescriptor, extraData));
|
|
@@ -367,15 +392,9 @@ ${description}`;
|
|
|
367
392
|
return `# ${this.name}
|
|
368
393
|
# Description
|
|
369
394
|
${this._description}
|
|
370
|
-
|
|
371
|
-
${this.
|
|
372
|
-
${
|
|
373
|
-
|
|
374
|
-
${this._examples.length ? "# Examples" : ""}
|
|
375
|
-
${this.examples}
|
|
376
|
-
|
|
377
|
-
${this._furtherInstructions.length ? "# Further Instructions" : ""}
|
|
378
|
-
${this._furtherInstructions.join("\n\n")}
|
|
395
|
+
${this._parameters.length ? "# Parameters\n" + Object.values(this._parameters).join("\n\n") : ""}
|
|
396
|
+
${this._examples.length ? "# Examples\n" + this.examples : ""}
|
|
397
|
+
${this._furtherInstructions.length ? "# Further Instructions\n" + this._furtherInstructions.join("\n\n") : ""}
|
|
379
398
|
`.trim();
|
|
380
399
|
}
|
|
381
400
|
};
|
|
@@ -417,21 +436,16 @@ var sendPromptToAngie = (prompt) => {
|
|
|
417
436
|
import { setReferrerRedirect } from "@elementor-external/angie-sdk";
|
|
418
437
|
var ANGIE_INSTALL_URL = "/wp-admin/plugin-install.php?s=angie&tab=search&type=term";
|
|
419
438
|
var redirectToInstallation = (prompt) => {
|
|
420
|
-
|
|
421
|
-
if (!success) {
|
|
422
|
-
return;
|
|
423
|
-
}
|
|
439
|
+
setReferrerRedirect(window.location.href, prompt);
|
|
424
440
|
window.location.href = ANGIE_INSTALL_URL;
|
|
425
441
|
};
|
|
426
442
|
|
|
427
443
|
// src/utils/redirect-to-app-admin.ts
|
|
428
|
-
import { setReferrerRedirect as setReferrerRedirect2 } from "@elementor-external/angie-sdk";
|
|
444
|
+
import { ANGIE_SIDEBAR_STATE_OPEN as ANGIE_SIDEBAR_STATE_OPEN2, saveState, setReferrerRedirect as setReferrerRedirect2 } from "@elementor-external/angie-sdk";
|
|
429
445
|
var ANGIE_APP_URL = "/wp-admin/admin.php?page=angie-app";
|
|
430
446
|
var redirectToAppAdmin = (prompt) => {
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
return;
|
|
434
|
-
}
|
|
447
|
+
setReferrerRedirect2(window.location.href, prompt);
|
|
448
|
+
saveState(ANGIE_SIDEBAR_STATE_OPEN2);
|
|
435
449
|
window.location.href = ANGIE_APP_URL;
|
|
436
450
|
};
|
|
437
451
|
|
|
@@ -477,6 +491,15 @@ var installAngiePlugin = async () => {
|
|
|
477
491
|
}
|
|
478
492
|
};
|
|
479
493
|
|
|
494
|
+
// src/utils/save-angie-consent.ts
|
|
495
|
+
import apiFetch2 from "@wordpress/api-fetch";
|
|
496
|
+
var saveAngieConsent = async () => {
|
|
497
|
+
await apiFetch2({
|
|
498
|
+
path: "/elementor/v1/angie/consent",
|
|
499
|
+
method: "POST"
|
|
500
|
+
});
|
|
501
|
+
};
|
|
502
|
+
|
|
480
503
|
// src/adapters/angie-adapter.ts
|
|
481
504
|
var MAX_RETRIES = 3;
|
|
482
505
|
var AngieMcpAdapter = class {
|
|
@@ -664,6 +687,7 @@ if (typeof document !== "undefined") {
|
|
|
664
687
|
var getAngieSdk = () => getSDK();
|
|
665
688
|
export {
|
|
666
689
|
ANGIE_MODEL_PREFERENCES,
|
|
690
|
+
ANGIE_REQUIRED_RESOURCES,
|
|
667
691
|
MessageEventType as AngieMessageEvenetType,
|
|
668
692
|
McpServer2 as McpServer,
|
|
669
693
|
ResourceTemplate,
|
|
@@ -682,6 +706,7 @@ export {
|
|
|
682
706
|
redirectToInstallation,
|
|
683
707
|
registerMcp,
|
|
684
708
|
registerMcpAdapter,
|
|
709
|
+
saveAngieConsent,
|
|
685
710
|
sendPromptToAngie,
|
|
686
711
|
signalMcpReady,
|
|
687
712
|
startMCPServer,
|
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/angie-annotations.ts","../src/test-utils/mock-mcp-registry.ts","../src/sampler.ts","../src/utils/prompt-builder.ts","../src/utils/get-active-chat-info.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/adapters/angie-adapter.ts","../src/adapters/web-mcp-adapter.ts","../src/init.ts"],"sourcesContent":["import { AngieMcpSdk } from '@elementor-external/angie-sdk';\nexport { getAngieIframe, MessageEventType } 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';\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, type AngieModelPreferences } from './angie-annotations';\nexport { getActiveChatInfo, type ActiveChatInfo } from './utils/get-active-chat-info';\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();\nexport * from './init';\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 { UriTemplate } from '@modelcontextprotocol/sdk/shared/uriTemplate.js';\nimport { type ServerNotification, type ServerRequest } from '@modelcontextprotocol/sdk/types.js';\n\nimport { type IMcpRegistrationAdapter, type McpResourceHandler, type McpResourceUriOrTemplate } from './adapters/types';\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';\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 => resolveReady();\n\nexport const activateAdapters = (): void => callAdapters( ( adapter ) => adapter.activate() );\n\nfunction callAdapters( fn: ( adapter: IMcpRegistrationAdapter ) => void ): void {\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\nexport const toMCPTitle = ( namespace: string ): string => {\n\tconst capitalized = namespace.charAt( 0 ).toUpperCase() + namespace.slice( 1 );\n\treturn `Editor ${ capitalized }`;\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\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{\n\t\t\t\tname: mcpName,\n\t\t\t\ttitle,\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\tcapabilities: { resources: { subscribe: true } },\n\t\t\t}\n\t\t);\n\t\tif ( !! options?.instructions ) {\n\t\t\tcallAdapters( ( adapter ) =>\n\t\t\t\tadapter.onResourceRegistered( `${ mcpName }`, { uriTemplate: new UriTemplate( mcpName ) }, () =>\n\t\t\t\t\tPromise.resolve( { contents: [ { text: options.instructions ?? '' } ] } )\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\t}\n\tconst mcpServer = mcpRegistry[ namespace ];\n\tconst { addTool } = createToolRegistry( mcpServer, mcpName );\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 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, serverName: 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: ( 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\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\tPromise.resolve(\n\t\t\t\t\ttoolCallback(\n\t\t\t\t\t\tparams as Parameters< typeof toolCallback >[ 0 ],\n\t\t\t\t\t\t/* WebMCP: no protocol session — handlers must not rely on `extra` here */\n\t\t\t\t\t\t{} as RequestHandlerExtra< ServerRequest, ServerNotification >\n\t\t\t\t\t)\n\t\t\t\t),\n\t\t};\n\t\tconst extraData = {\n\t\t\tresources: [ `Server resource name: ${ serverName }, Required to fetch!` ],\n\t\t\trequiredResources: opts.requiredResources?.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 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\tmcpServer: mock as McpServer,\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\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","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 { 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","import { type AngieMcpSdk } from '@elementor-external/angie-sdk';\n\nimport { getRegisteredMcpServers, toMCPTitle } from '../mcp-registry';\nimport { type IMcpRegistrationAdapter } from './types';\n\nconst MAX_RETRIES = 3;\n\nexport class AngieMcpAdapter implements IMcpRegistrationAdapter {\n\tconstructor( private readonly sdk: AngieMcpSdk ) {}\n\n\tasync activate(): Promise< void > {\n\t\tawait this.sdk.waitForReady();\n\t\tawait this.registerEntries( 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 {\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: ( tool: McpToolDescriptor ) => void;\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(): void {\n\t\tif ( this.activated ) {\n\t\t\treturn;\n\t\t}\n\t\tthis.activated = true;\n\t\tthis.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://styles/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}\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\tthis.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} );\n\t\tthis.registeredToolNames.add( tool.name );\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 { AngieMcpAdapter } from './adapters/angie-adapter';\nimport { type ModelContext, WebMCPAdapter } from './adapters/web-mcp-adapter';\nimport { activateAdapters, registerMcpAdapter, signalMcpReady } from './mcp-registry';\nimport { getSDK } from './utils/get-sdk';\nimport { isAngieAvailable } from './utils/is-angie-available';\n\nexport function startMCPServer() {\n\tif ( typeof navigator !== 'undefined' && 'modelContext' in navigator ) {\n\t\tregisterMcpAdapter(\n\t\t\tnew WebMCPAdapter( ( navigator as unknown as { modelContext: ModelContext } ).modelContext )\n\t\t);\n\t}\n\n\tif ( isAngieAvailable() ) {\n\t\tregisterMcpAdapter( new AngieMcpAdapter( getSDK() ) );\n\t}\n\n\tactivateAdapters();\n\tsignalMcpReady();\n}\n\nif ( typeof document !== 'undefined' ) {\n\tdocument.addEventListener( 'DOMContentLoaded', () => startMCPServer(), { once: true } );\n} else {\n\tstartMCPServer();\n}\n"],"mappings":";AAAA,SAAS,mBAA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ACH;AAAA,EACD;AAAA,EAEA,sBAA4B;AAAA,EAE5B;AACD;;;ACxIO,SAAS,iBAAiB;AAChC,MAAK,OAAO,cAAc,eAAe,kBAAkB,WAAY;AACtE;AAAA,MACC,IAAI,cAAiB,UAAyD,YAAa;AAAA,IAC5F;AAAA,EACD;AAEA,MAAK,iBAAiB,GAAI;AACzB,uBAAoB,IAAI,gBAAiB,OAAO,CAAE,CAAE;AAAA,EACrD;AAEA,mBAAiB;AACjB,iBAAe;AAChB;AAEA,IAAK,OAAO,aAAa,aAAc;AACtC,WAAS,iBAAkB,oBAAoB,MAAM,eAAe,GAAG,EAAE,MAAM,KAAK,CAAE;AACvF,OAAO;AACN,iBAAe;AAChB;;;AfJO,IAAM,cAAc,MAAM,OAAO;","names":["McpServer","SamplingMessageSchema","getAngieIframe","getAngieIframe","setReferrerRedirect","sdk","z"]}
|
|
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/angie-annotations.ts","../src/test-utils/mock-mcp-registry.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/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/adapters/angie-adapter.ts","../src/adapters/web-mcp-adapter.ts","../src/init.ts"],"sourcesContent":["import { AngieMcpSdk } from '@elementor-external/angie-sdk';\nexport { getAngieIframe, MessageEventType } 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';\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 { 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';\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 { type IMcpRegistrationAdapter, type McpResourceHandler, type McpResourceUriOrTemplate } from './adapters/types';\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 { mergeRequiredResources, type ResourceList } from './utils/merge-required-resources';\nimport { registerServerDocsResource } from './utils/register-server-docs-resource';\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 => resolveReady();\n\nexport const activateAdapters = (): void => callAdapters( ( adapter ) => adapter.activate() );\n\nfunction callAdapters( fn: ( adapter: IMcpRegistrationAdapter ) => void ): void {\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\nexport const toMCPTitle = ( namespace: string ): string => {\n\tconst capitalized = namespace.charAt( 0 ).toUpperCase() + namespace.slice( 1 );\n\treturn `Editor ${ capitalized }`;\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: ( 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 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\tPromise.resolve(\n\t\t\t\t\ttoolCallback(\n\t\t\t\t\t\tparams as Parameters< typeof toolCallback >[ 0 ],\n\t\t\t\t\t\t/* WebMCP: no protocol session — handlers must not rely on `extra` here */\n\t\t\t\t\t\t{} as RequestHandlerExtra< ServerRequest, ServerNotification >\n\t\t\t\t\t)\n\t\t\t\t),\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 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\tmcpServer: mock as McpServer,\n\t};\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 { 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 { type AngieMcpSdk } from '@elementor-external/angie-sdk';\n\nimport { getRegisteredMcpServers, toMCPTitle } from '../mcp-registry';\nimport { type IMcpRegistrationAdapter } from './types';\n\nconst MAX_RETRIES = 3;\n\nexport class AngieMcpAdapter implements IMcpRegistrationAdapter {\n\tconstructor( private readonly sdk: AngieMcpSdk ) {}\n\n\tasync activate(): Promise< void > {\n\t\tawait this.sdk.waitForReady();\n\t\tawait this.registerEntries( 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 {\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: ( tool: McpToolDescriptor ) => void;\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(): void {\n\t\tif ( this.activated ) {\n\t\t\treturn;\n\t\t}\n\t\tthis.activated = true;\n\t\tthis.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://styles/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}\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\tthis.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} );\n\t\tthis.registeredToolNames.add( tool.name );\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 { AngieMcpAdapter } from './adapters/angie-adapter';\nimport { type ModelContext, WebMCPAdapter } from './adapters/web-mcp-adapter';\nimport { activateAdapters, registerMcpAdapter, signalMcpReady } from './mcp-registry';\nimport { getSDK } from './utils/get-sdk';\nimport { isAngieAvailable } from './utils/is-angie-available';\n\nexport function startMCPServer() {\n\tif ( typeof navigator !== 'undefined' && 'modelContext' in navigator ) {\n\t\tregisterMcpAdapter(\n\t\t\tnew WebMCPAdapter( ( navigator as unknown as { modelContext: ModelContext } ).modelContext )\n\t\t);\n\t}\n\n\tif ( isAngieAvailable() ) {\n\t\tregisterMcpAdapter( new AngieMcpAdapter( getSDK() ) );\n\t}\n\n\tactivateAdapters();\n\tsignalMcpReady();\n}\n\nif ( typeof document !== 'undefined' ) {\n\tdocument.addEventListener( 'DOMContentLoaded', () => startMCPServer(), { once: true } );\n} else {\n\tstartMCPServer();\n}\n"],"mappings":";AAAA,SAAS,mBAAmB;AAC5B,SAAS,gBAAgB,wBAAwB;AAEjD,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;;;ACTtC,SAAS,kBAAAC,uBAAsB;AAExB,IAAM,m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AAK,OAAO,kBAAkB,UAAW;AACxC,WAAK,gBAAgB,KAAM;AAAA,QAC1B,SAAS;AAAA,QACT,OAAO,CAAE,QAAW,QAAQ,gBAAgB,CAAC,IAAI;AAAA,QACjD;AAAA,MACD,CAAE;AAAA,IACH,OAAO;AACN,YAAM,WAAW,cAAc;AAC/B,WAAK,gBAAgB,KAAM;AAAA,QAC1B,SAAS,SAAS,SAAS;AAAA,QAC3B,OAAO,CAAE,QAAS,SAAS,MAAO,GAAI;AAAA,QACtC;AAAA,MACD,CAAE;AAAA,IACH;AAAA,EACD;AAAA,EAEA,sBAA4B;AAAA,EAE5B;AACD;;;ACxIO,SAAS,iBAAiB;AAChC,MAAK,OAAO,cAAc,eAAe,kBAAkB,WAAY;AACtE;AAAA,MACC,IAAI,cAAiB,UAAyD,YAAa;AAAA,IAC5F;AAAA,EACD;AAEA,MAAK,iBAAiB,GAAI;AACzB,uBAAoB,IAAI,gBAAiB,OAAO,CAAE,CAAE;AAAA,EACrD;AAEA,mBAAiB;AACjB,iBAAe;AAChB;AAEA,IAAK,OAAO,aAAa,aAAc;AACtC,WAAS,iBAAkB,oBAAoB,MAAM,eAAe,GAAG,EAAE,MAAM,KAAK,CAAE;AACvF,OAAO;AACN,iBAAe;AAChB;;;AnBHO,IAAM,cAAc,MAAM,OAAO;","names":["McpServer","SamplingMessageSchema","getAngieIframe","getAngieIframe","ANGIE_SIDEBAR_STATE_OPEN","setReferrerRedirect","apiFetch","sdk","z"]}
|
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-beta2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "Elementor Team",
|
|
6
6
|
"homepage": "https://elementor.com/",
|
|
@@ -43,9 +43,9 @@
|
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@elementor-external/angie-sdk": "npm:@elementor/angie-sdk@^1.4.5",
|
|
46
|
-
"@elementor/editor-v1-adapters": "4.1.0-
|
|
47
|
-
"@elementor/schema": "4.1.0-
|
|
48
|
-
"@elementor/store": "4.1.0-
|
|
46
|
+
"@elementor/editor-v1-adapters": "4.1.0-beta2",
|
|
47
|
+
"@elementor/schema": "4.1.0-beta2",
|
|
48
|
+
"@elementor/store": "4.1.0-beta2",
|
|
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/index.ts
CHANGED
|
@@ -13,11 +13,12 @@ export { isAngieSidebarOpen } from './utils/is-angie-sidebar-open';
|
|
|
13
13
|
export * from './mcp-registry';
|
|
14
14
|
export { createSampler } from './sampler';
|
|
15
15
|
export { toolPrompts } from './utils/prompt-builder';
|
|
16
|
-
export { ANGIE_MODEL_PREFERENCES, type AngieModelPreferences } from './angie-annotations';
|
|
16
|
+
export { ANGIE_MODEL_PREFERENCES, ANGIE_REQUIRED_RESOURCES, type AngieModelPreferences } from './angie-annotations';
|
|
17
17
|
export { getActiveChatInfo, type ActiveChatInfo } from './utils/get-active-chat-info';
|
|
18
18
|
export { sendPromptToAngie } from './utils/send-prompt-to-angie';
|
|
19
19
|
export { redirectToInstallation } from './utils/redirect-to-installation';
|
|
20
20
|
export { redirectToAppAdmin } from './utils/redirect-to-app-admin';
|
|
21
21
|
export { installAngiePlugin, type InstallAngieResult } from './utils/install-angie-plugin';
|
|
22
|
+
export { saveAngieConsent } from './utils/save-angie-consent';
|
|
22
23
|
export const getAngieSdk = () => getSDK();
|
|
23
24
|
export * from './init';
|
package/src/mcp-registry.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { z, type z3 } from '@elementor/schema';
|
|
2
2
|
import { McpServer, type ToolCallback } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
3
3
|
import { type RequestHandlerExtra } from '@modelcontextprotocol/sdk/shared/protocol.js';
|
|
4
|
-
import { UriTemplate } from '@modelcontextprotocol/sdk/shared/uriTemplate.js';
|
|
5
4
|
import { type ServerNotification, type ServerRequest } from '@modelcontextprotocol/sdk/types.js';
|
|
6
5
|
|
|
7
6
|
import { type IMcpRegistrationAdapter, type McpResourceHandler, type McpResourceUriOrTemplate } from './adapters/types';
|
|
@@ -12,6 +11,8 @@ import {
|
|
|
12
11
|
createDefaultModelPreferences,
|
|
13
12
|
} from './angie-annotations';
|
|
14
13
|
import { mockMcpRegistry } from './test-utils/mock-mcp-registry';
|
|
14
|
+
import { mergeRequiredResources, type ResourceList } from './utils/merge-required-resources';
|
|
15
|
+
import { registerServerDocsResource } from './utils/register-server-docs-resource';
|
|
15
16
|
|
|
16
17
|
type ZodRawShape = z3.ZodRawShape;
|
|
17
18
|
|
|
@@ -84,12 +85,17 @@ export const toMCPTitle = ( namespace: string ): string => {
|
|
|
84
85
|
};
|
|
85
86
|
|
|
86
87
|
/**
|
|
87
|
-
*
|
|
88
88
|
* @param namespace The namespace of the MCP server. It should contain only lowercase alphabetic characters.
|
|
89
89
|
* @param options
|
|
90
|
-
* @param options.instructions
|
|
90
|
+
* @param options.instructions Short hint about the MCP and its toolset (MCP SDK `instructions`; keeps payload small).
|
|
91
|
+
* @param options.docs Full documentation registered as a lazy-loaded resource.
|
|
92
|
+
* When provided, it is registered at elementor://{namespace}/server-docs
|
|
93
|
+
* and auto-injected into every tool's requiredResources.
|
|
91
94
|
*/
|
|
92
|
-
export const getMCPByDomain = (
|
|
95
|
+
export const getMCPByDomain = (
|
|
96
|
+
namespace: string,
|
|
97
|
+
options?: { docs?: string; instructions?: string }
|
|
98
|
+
): MCPRegistryEntry => {
|
|
93
99
|
const mcpName = `editor-${ isAlphabet( namespace ) }`;
|
|
94
100
|
const title = toMCPTitle( namespace );
|
|
95
101
|
// @ts-ignore - QUnit fails this
|
|
@@ -98,26 +104,19 @@ export const getMCPByDomain = ( namespace: string, options?: { instructions?: st
|
|
|
98
104
|
}
|
|
99
105
|
if ( ! mcpRegistry[ namespace ] ) {
|
|
100
106
|
mcpRegistry[ namespace ] = new McpServer(
|
|
101
|
-
{
|
|
102
|
-
|
|
103
|
-
title,
|
|
104
|
-
version: '1.0.0',
|
|
105
|
-
},
|
|
106
|
-
{
|
|
107
|
-
instructions: options?.instructions,
|
|
108
|
-
capabilities: { resources: { subscribe: true } },
|
|
109
|
-
}
|
|
107
|
+
{ name: mcpName, title, version: '1.0.0' },
|
|
108
|
+
{ instructions: options?.instructions, capabilities: { resources: { subscribe: true } } }
|
|
110
109
|
);
|
|
111
|
-
if (
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
);
|
|
110
|
+
if ( options?.docs ) {
|
|
111
|
+
registerServerDocsResource( mcpRegistry[ namespace ], namespace, title, options.docs, ( ...args ) => {
|
|
112
|
+
bufferedResources.push( args );
|
|
113
|
+
callAdapters( ( adapter ) => adapter.onResourceRegistered( ...args ) );
|
|
114
|
+
} );
|
|
117
115
|
}
|
|
118
116
|
}
|
|
119
117
|
const mcpServer = mcpRegistry[ namespace ];
|
|
120
|
-
const
|
|
118
|
+
const serverDocsUri = options?.docs ? `elementor://${ namespace }/server-docs` : undefined;
|
|
119
|
+
const { addTool } = createToolRegistry( mcpServer, mcpName, serverDocsUri );
|
|
121
120
|
return {
|
|
122
121
|
waitForReady: () => readyPromise,
|
|
123
122
|
// @ts-expect-error: TS is unable to infer the type here
|
|
@@ -162,11 +161,6 @@ export interface MCPRegistryEntry {
|
|
|
162
161
|
waitForReady: () => Promise< void >;
|
|
163
162
|
}
|
|
164
163
|
|
|
165
|
-
type ResourceList = {
|
|
166
|
-
uri: string;
|
|
167
|
-
description: string;
|
|
168
|
-
}[];
|
|
169
|
-
|
|
170
164
|
type ToolRegistrationOptions<
|
|
171
165
|
InputArgs extends undefined | z.ZodRawShape = undefined,
|
|
172
166
|
OutputSchema extends undefined | z.ZodRawShape = undefined,
|
|
@@ -194,7 +188,7 @@ type ToolRegistrationOptions<
|
|
|
194
188
|
modelPreferences?: AngieModelPreferences;
|
|
195
189
|
};
|
|
196
190
|
|
|
197
|
-
function createToolRegistry( server: McpServer, serverName: string ) {
|
|
191
|
+
function createToolRegistry( server: McpServer, serverName: string, serverDocsUri?: string ) {
|
|
198
192
|
function addTool<
|
|
199
193
|
T extends undefined | z.ZodRawShape = undefined,
|
|
200
194
|
O extends undefined | z.ZodRawShape = undefined,
|
|
@@ -245,9 +239,10 @@ function createToolRegistry( server: McpServer, serverName: string ) {
|
|
|
245
239
|
readOnlyHint: opts.isDestructive ? false : undefined,
|
|
246
240
|
title: opts.name,
|
|
247
241
|
};
|
|
242
|
+
const mergedResources = mergeRequiredResources( opts.requiredResources, serverDocsUri );
|
|
248
243
|
const angieAnnotations = {
|
|
249
244
|
[ ANGIE_MODEL_PREFERENCES ]: opts.modelPreferences ?? createDefaultModelPreferences(),
|
|
250
|
-
[ ANGIE_REQUIRED_RESOURCES ]:
|
|
245
|
+
[ ANGIE_REQUIRED_RESOURCES ]: mergedResources,
|
|
251
246
|
};
|
|
252
247
|
server.registerTool(
|
|
253
248
|
opts.name,
|
|
@@ -277,7 +272,7 @@ function createToolRegistry( server: McpServer, serverName: string ) {
|
|
|
277
272
|
};
|
|
278
273
|
const extraData = {
|
|
279
274
|
resources: [ `Server resource name: ${ serverName }, Required to fetch!` ],
|
|
280
|
-
requiredResources:
|
|
275
|
+
requiredResources: mergedResources?.map( ( resource ) => resource.uri ) ?? [],
|
|
281
276
|
};
|
|
282
277
|
bufferedTools.push( [ toolDescriptor, extraData ] );
|
|
283
278
|
callAdapters( ( adapter ) => adapter.onToolRegistered( toolDescriptor, extraData ) );
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type ResourceList = {
|
|
2
|
+
uri: string;
|
|
3
|
+
description: string;
|
|
4
|
+
}[];
|
|
5
|
+
|
|
6
|
+
export const mergeRequiredResources = (
|
|
7
|
+
toolResources: ResourceList | undefined,
|
|
8
|
+
serverDocsUri: string | undefined
|
|
9
|
+
): ResourceList | undefined => {
|
|
10
|
+
if ( ! serverDocsUri ) {
|
|
11
|
+
return toolResources;
|
|
12
|
+
}
|
|
13
|
+
if ( toolResources?.some( ( r ) => r.uri === serverDocsUri ) ) {
|
|
14
|
+
return toolResources;
|
|
15
|
+
}
|
|
16
|
+
return [ ...( toolResources ?? [] ), { uri: serverDocsUri, description: 'Server docs' } ];
|
|
17
|
+
};
|
|
@@ -44,15 +44,9 @@ class ToolPrompts {
|
|
|
44
44
|
return `# ${ this.name }
|
|
45
45
|
# Description
|
|
46
46
|
${ this._description }
|
|
47
|
-
|
|
48
|
-
${ this.
|
|
49
|
-
${
|
|
50
|
-
|
|
51
|
-
${ this._examples.length ? '# Examples' : '' }
|
|
52
|
-
${ this.examples }
|
|
53
|
-
|
|
54
|
-
${ this._furtherInstructions.length ? '# Further Instructions' : '' }
|
|
55
|
-
${ this._furtherInstructions.join( '\n\n' ) }
|
|
47
|
+
${ this._parameters.length ? '# Parameters\n' + Object.values( this._parameters ).join( '\n\n' ) : '' }
|
|
48
|
+
${ this._examples.length ? '# Examples\n' + this.examples : '' }
|
|
49
|
+
${ this._furtherInstructions.length ? '# Further Instructions\n' + this._furtherInstructions.join( '\n\n' ) : '' }
|
|
56
50
|
`.trim();
|
|
57
51
|
}
|
|
58
52
|
}
|
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
import { setReferrerRedirect } from '@elementor-external/angie-sdk';
|
|
1
|
+
import { ANGIE_SIDEBAR_STATE_OPEN, saveState, setReferrerRedirect } from '@elementor-external/angie-sdk';
|
|
2
2
|
|
|
3
3
|
const ANGIE_APP_URL = '/wp-admin/admin.php?page=angie-app';
|
|
4
4
|
|
|
5
|
-
export const redirectToAppAdmin = ( prompt
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
if ( ! success ) {
|
|
9
|
-
return;
|
|
10
|
-
}
|
|
11
|
-
|
|
5
|
+
export const redirectToAppAdmin = ( prompt?: string ) => {
|
|
6
|
+
setReferrerRedirect( window.location.href, prompt );
|
|
7
|
+
saveState( ANGIE_SIDEBAR_STATE_OPEN );
|
|
12
8
|
window.location.href = ANGIE_APP_URL;
|
|
13
9
|
};
|
|
@@ -2,12 +2,7 @@ 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
|
-
export const redirectToInstallation = ( prompt
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
if ( ! success ) {
|
|
9
|
-
return;
|
|
10
|
-
}
|
|
11
|
-
|
|
5
|
+
export const redirectToInstallation = ( prompt?: string ) => {
|
|
6
|
+
setReferrerRedirect( window.location.href, prompt );
|
|
12
7
|
window.location.href = ANGIE_INSTALL_URL;
|
|
13
8
|
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
|
|
3
|
+
import { type IMcpRegistrationAdapter } from '../adapters/types';
|
|
4
|
+
import { createSimpleResourceHandler } from './create-simple-resource-handler';
|
|
5
|
+
|
|
6
|
+
type OnResourceRegistered = ( ...args: Parameters< IMcpRegistrationAdapter[ 'onResourceRegistered' ] > ) => void;
|
|
7
|
+
|
|
8
|
+
export const registerServerDocsResource = (
|
|
9
|
+
server: McpServer,
|
|
10
|
+
namespace: string,
|
|
11
|
+
title: string,
|
|
12
|
+
docs: string,
|
|
13
|
+
onRegistered: OnResourceRegistered
|
|
14
|
+
): void => {
|
|
15
|
+
const uri = `elementor://${ namespace }/server-docs`;
|
|
16
|
+
const name = `${ namespace }-server-docs`;
|
|
17
|
+
const handler = createSimpleResourceHandler( docs );
|
|
18
|
+
server.registerResource(
|
|
19
|
+
name,
|
|
20
|
+
uri,
|
|
21
|
+
{
|
|
22
|
+
title: `${ title } server docs`,
|
|
23
|
+
description: 'Full MCP documentation (lazy-loaded)',
|
|
24
|
+
mimeType: 'text/plain',
|
|
25
|
+
},
|
|
26
|
+
handler
|
|
27
|
+
);
|
|
28
|
+
onRegistered( name, uri, handler );
|
|
29
|
+
};
|