@elementor/editor-mcp 4.5.0-1220 → 4.5.0-1221
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 +3 -6
- package/dist/index.d.ts +3 -6
- package/dist/index.js +25 -63
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +14 -50
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
- package/src/adapters/angie-adapter.ts +2 -3
- package/src/index.ts +1 -3
- package/src/types/open-angie-request.ts +1 -1
- package/src/utils/is-angie-available.ts +1 -1
- package/src/utils/is-angie-sidebar-open.ts +1 -1
- package/src/utils/open-angie-in-ask-mode.ts +1 -1
- package/src/utils/redirect-to-app-admin.ts +1 -1
- package/src/utils/redirect-to-installation.ts +1 -1
- package/src/utils/send-prompt-to-angie.ts +1 -1
- package/src/utils/get-sdk.ts +0 -37
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
export { MessageEventType as AngieMessageEvenetType, getAngieIframe } from '@elementor-external/angie-sdk';
|
|
1
|
+
import { AngieInteractionMode, AngieTriggerRequest, AngieMcpSdk } from '@elementor/editor-angie-sdk';
|
|
2
|
+
export { MessageEventType as AngieMessageEvenetType, getAngieIframe, getAngieSdk } from '@elementor/editor-angie-sdk';
|
|
4
3
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
5
4
|
export { McpServer, RegisteredResource, ResourceTemplate, ToolCallback } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
6
5
|
import { ServerRequest, ServerNotification } from '@modelcontextprotocol/sdk/types.js';
|
|
@@ -469,6 +468,4 @@ type McpStylesAppliedPayload = {
|
|
|
469
468
|
};
|
|
470
469
|
declare function dispatchMcpStylesAppliedEvent(payload: McpStylesAppliedPayload): void;
|
|
471
470
|
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
export { ANGIE_MODEL_PREFERENCES, ANGIE_REQUIRED_RESOURCES, type ActiveChatInfo, AngieMcpAdapter, type AngieModelPreferences, type EditorAngieWindowHost, type IMcpRegistrationAdapter, type InstallAngieResult, type MCPRegistryEntry, MCP_STYLES_APPLIED_EVENT, type McpStylesAppliedPayload, type OpenAngieCommonProperties, type OpenAngiePluginProperties, type OpenAngieRequest, type OpenAngieSdkProperties, activateMcpAdapter, canCreateWidget, createAndRegisterAdapters, createSampler, dispatchMcpStylesAppliedEvent, getActiveChatInfo, getAngieSdk, getMCPByDomain, getRegisteredMcpServers, hasLoadedEditorAngie, installAngiePlugin, isAngieAvailable, isAngieSidebarOpen, openAngieInAgentMode, openAngieInAskMode, redirectToAppAdmin, redirectToInstallation, registerMcp, registerMcpAdapter, saveAngieConsent, sendPromptToAngie, signalMcpReady, startMCPServer, toolPrompts, waitForMcpReady };
|
|
471
|
+
export { ANGIE_MODEL_PREFERENCES, ANGIE_REQUIRED_RESOURCES, type ActiveChatInfo, AngieMcpAdapter, type AngieModelPreferences, type EditorAngieWindowHost, type IMcpRegistrationAdapter, type InstallAngieResult, type MCPRegistryEntry, MCP_STYLES_APPLIED_EVENT, type McpStylesAppliedPayload, type OpenAngieCommonProperties, type OpenAngiePluginProperties, type OpenAngieRequest, type OpenAngieSdkProperties, activateMcpAdapter, canCreateWidget, createAndRegisterAdapters, createSampler, dispatchMcpStylesAppliedEvent, getActiveChatInfo, getMCPByDomain, getRegisteredMcpServers, hasLoadedEditorAngie, installAngiePlugin, isAngieAvailable, isAngieSidebarOpen, openAngieInAgentMode, openAngieInAskMode, redirectToAppAdmin, redirectToInstallation, registerMcp, registerMcpAdapter, saveAngieConsent, sendPromptToAngie, signalMcpReady, startMCPServer, toolPrompts, waitForMcpReady };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
export { MessageEventType as AngieMessageEvenetType, getAngieIframe } from '@elementor-external/angie-sdk';
|
|
1
|
+
import { AngieInteractionMode, AngieTriggerRequest, AngieMcpSdk } from '@elementor/editor-angie-sdk';
|
|
2
|
+
export { MessageEventType as AngieMessageEvenetType, getAngieIframe, getAngieSdk } from '@elementor/editor-angie-sdk';
|
|
4
3
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
5
4
|
export { McpServer, RegisteredResource, ResourceTemplate, ToolCallback } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
6
5
|
import { ServerRequest, ServerNotification } from '@modelcontextprotocol/sdk/types.js';
|
|
@@ -469,6 +468,4 @@ type McpStylesAppliedPayload = {
|
|
|
469
468
|
};
|
|
470
469
|
declare function dispatchMcpStylesAppliedEvent(payload: McpStylesAppliedPayload): void;
|
|
471
470
|
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
export { ANGIE_MODEL_PREFERENCES, ANGIE_REQUIRED_RESOURCES, type ActiveChatInfo, AngieMcpAdapter, type AngieModelPreferences, type EditorAngieWindowHost, type IMcpRegistrationAdapter, type InstallAngieResult, type MCPRegistryEntry, MCP_STYLES_APPLIED_EVENT, type McpStylesAppliedPayload, type OpenAngieCommonProperties, type OpenAngiePluginProperties, type OpenAngieRequest, type OpenAngieSdkProperties, activateMcpAdapter, canCreateWidget, createAndRegisterAdapters, createSampler, dispatchMcpStylesAppliedEvent, getActiveChatInfo, getAngieSdk, getMCPByDomain, getRegisteredMcpServers, hasLoadedEditorAngie, installAngiePlugin, isAngieAvailable, isAngieSidebarOpen, openAngieInAgentMode, openAngieInAskMode, redirectToAppAdmin, redirectToInstallation, registerMcp, registerMcpAdapter, saveAngieConsent, sendPromptToAngie, signalMcpReady, startMCPServer, toolPrompts, waitForMcpReady };
|
|
471
|
+
export { ANGIE_MODEL_PREFERENCES, ANGIE_REQUIRED_RESOURCES, type ActiveChatInfo, AngieMcpAdapter, type AngieModelPreferences, type EditorAngieWindowHost, type IMcpRegistrationAdapter, type InstallAngieResult, type MCPRegistryEntry, MCP_STYLES_APPLIED_EVENT, type McpStylesAppliedPayload, type OpenAngieCommonProperties, type OpenAngiePluginProperties, type OpenAngieRequest, type OpenAngieSdkProperties, activateMcpAdapter, canCreateWidget, createAndRegisterAdapters, createSampler, dispatchMcpStylesAppliedEvent, getActiveChatInfo, getMCPByDomain, getRegisteredMcpServers, hasLoadedEditorAngie, installAngiePlugin, isAngieAvailable, isAngieSidebarOpen, openAngieInAgentMode, openAngieInAskMode, redirectToAppAdmin, redirectToInstallation, registerMcp, registerMcpAdapter, saveAngieConsent, sendPromptToAngie, signalMcpReady, startMCPServer, toolPrompts, waitForMcpReady };
|
package/dist/index.js
CHANGED
|
@@ -33,7 +33,7 @@ __export(index_exports, {
|
|
|
33
33
|
ANGIE_MODEL_PREFERENCES: () => ANGIE_MODEL_PREFERENCES,
|
|
34
34
|
ANGIE_REQUIRED_RESOURCES: () => ANGIE_REQUIRED_RESOURCES,
|
|
35
35
|
AngieMcpAdapter: () => AngieMcpAdapter,
|
|
36
|
-
AngieMessageEvenetType: () =>
|
|
36
|
+
AngieMessageEvenetType: () => import_editor_angie_sdk7.MessageEventType,
|
|
37
37
|
MCP_STYLES_APPLIED_EVENT: () => MCP_STYLES_APPLIED_EVENT,
|
|
38
38
|
McpServer: () => import_mcp2.McpServer,
|
|
39
39
|
ResourceTemplate: () => import_mcp2.ResourceTemplate,
|
|
@@ -44,8 +44,8 @@ __export(index_exports, {
|
|
|
44
44
|
createSampler: () => createSampler,
|
|
45
45
|
dispatchMcpStylesAppliedEvent: () => dispatchMcpStylesAppliedEvent,
|
|
46
46
|
getActiveChatInfo: () => getActiveChatInfo,
|
|
47
|
-
getAngieIframe: () =>
|
|
48
|
-
getAngieSdk: () => getAngieSdk,
|
|
47
|
+
getAngieIframe: () => import_editor_angie_sdk7.getAngieIframe,
|
|
48
|
+
getAngieSdk: () => import_editor_angie_sdk7.getAngieSdk,
|
|
49
49
|
getMCPByDomain: () => getMCPByDomain,
|
|
50
50
|
getRegisteredMcpServers: () => getRegisteredMcpServers,
|
|
51
51
|
hasLoadedEditorAngie: () => hasLoadedEditorAngie,
|
|
@@ -66,49 +66,14 @@ __export(index_exports, {
|
|
|
66
66
|
waitForMcpReady: () => waitForMcpReady
|
|
67
67
|
});
|
|
68
68
|
module.exports = __toCommonJS(index_exports);
|
|
69
|
-
|
|
70
|
-
// src/utils/get-sdk.ts
|
|
71
|
-
var import_angie_sdk = require("@elementor-external/angie-sdk");
|
|
72
|
-
var import_angie_sdk2 = require("@elementor-external/angie-sdk");
|
|
73
|
-
var sdk;
|
|
74
|
-
var RetriableAngieSDK = class extends import_angie_sdk.AngieMcpSdk {
|
|
75
|
-
async waitForReady() {
|
|
76
|
-
let retryCount = 3;
|
|
77
|
-
while (retryCount > 0) {
|
|
78
|
-
try {
|
|
79
|
-
await super.waitForReady();
|
|
80
|
-
return;
|
|
81
|
-
} catch {
|
|
82
|
-
retryCount--;
|
|
83
|
-
await sleep();
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
return new Promise(() => {
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
};
|
|
90
|
-
var sleep = (ms = 1e4) => new Promise((resolve) => {
|
|
91
|
-
setTimeout(resolve, ms);
|
|
92
|
-
});
|
|
93
|
-
var getSDK = () => {
|
|
94
|
-
const isMCPDisabled = !!globalThis.__ELEMENTOR_MCP_DISABLED__;
|
|
95
|
-
if (isMCPDisabled) {
|
|
96
|
-
return {};
|
|
97
|
-
}
|
|
98
|
-
if (!sdk) {
|
|
99
|
-
sdk = new RetriableAngieSDK();
|
|
100
|
-
}
|
|
101
|
-
return sdk;
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
// src/index.ts
|
|
69
|
+
var import_editor_angie_sdk7 = require("@elementor/editor-angie-sdk");
|
|
105
70
|
var import_mcp2 = require("@modelcontextprotocol/sdk/server/mcp.js");
|
|
106
71
|
var import_types2 = require("@modelcontextprotocol/sdk/types.js");
|
|
107
72
|
|
|
108
73
|
// src/utils/is-angie-available.ts
|
|
109
|
-
var
|
|
74
|
+
var import_editor_angie_sdk = require("@elementor/editor-angie-sdk");
|
|
110
75
|
var isAngieAvailable = () => {
|
|
111
|
-
return !!(0,
|
|
76
|
+
return !!(0, import_editor_angie_sdk.getAngieIframe)();
|
|
112
77
|
};
|
|
113
78
|
|
|
114
79
|
// src/utils/can-create-widget.ts
|
|
@@ -117,9 +82,9 @@ var canCreateWidget = () => {
|
|
|
117
82
|
};
|
|
118
83
|
|
|
119
84
|
// src/utils/is-angie-sidebar-open.ts
|
|
120
|
-
var
|
|
85
|
+
var import_editor_angie_sdk2 = require("@elementor/editor-angie-sdk");
|
|
121
86
|
var isAngieSidebarOpen = () => {
|
|
122
|
-
return (0,
|
|
87
|
+
return (0, import_editor_angie_sdk2.getAngieSidebarSavedState)() === import_editor_angie_sdk2.ANGIE_SIDEBAR_STATE_OPEN;
|
|
123
88
|
};
|
|
124
89
|
|
|
125
90
|
// src/mcp-registry.ts
|
|
@@ -562,8 +527,8 @@ function createToolRegistry(server, serverName, serverDocsUri) {
|
|
|
562
527
|
// src/adapters/angie-adapter.ts
|
|
563
528
|
var MAX_RETRIES = 3;
|
|
564
529
|
var AngieMcpAdapter = class {
|
|
565
|
-
constructor(
|
|
566
|
-
this.sdk =
|
|
530
|
+
constructor(sdk, getRegisteredMcpServers2) {
|
|
531
|
+
this.sdk = sdk;
|
|
567
532
|
this.getRegisteredMcpServers = getRegisteredMcpServers2;
|
|
568
533
|
}
|
|
569
534
|
async activate() {
|
|
@@ -717,7 +682,7 @@ var getActiveChatInfo = () => {
|
|
|
717
682
|
};
|
|
718
683
|
|
|
719
684
|
// src/utils/open-angie-in-ask-mode.ts
|
|
720
|
-
var
|
|
685
|
+
var import_editor_angie_sdk3 = require("@elementor/editor-angie-sdk");
|
|
721
686
|
var getLoadedEditorAngie = () => {
|
|
722
687
|
return window.elementorV2?.editorAngie?.openAngie;
|
|
723
688
|
};
|
|
@@ -733,10 +698,10 @@ var openLoadedEditorAngie = (prompt, mode) => {
|
|
|
733
698
|
return true;
|
|
734
699
|
};
|
|
735
700
|
var openAngieInAskMode = (prompt) => {
|
|
736
|
-
openAngieInMode(prompt,
|
|
701
|
+
openAngieInMode(prompt, import_editor_angie_sdk3.AngieInteractionMode.ASK);
|
|
737
702
|
};
|
|
738
703
|
var openAngieInAgentMode = (prompt) => {
|
|
739
|
-
openAngieInMode(prompt,
|
|
704
|
+
openAngieInMode(prompt, import_editor_angie_sdk3.AngieInteractionMode.AGENT);
|
|
740
705
|
};
|
|
741
706
|
var openAngieInMode = (prompt, mode) => {
|
|
742
707
|
if (openLoadedEditorAngie(prompt, mode)) {
|
|
@@ -745,28 +710,28 @@ var openAngieInMode = (prompt, mode) => {
|
|
|
745
710
|
if (!isAngieAvailable()) {
|
|
746
711
|
return;
|
|
747
712
|
}
|
|
748
|
-
const angieSidebar = (0,
|
|
713
|
+
const angieSidebar = (0, import_editor_angie_sdk3.getAngieIframe)();
|
|
749
714
|
if (!angieSidebar) {
|
|
750
715
|
return;
|
|
751
716
|
}
|
|
752
|
-
(0,
|
|
753
|
-
(0,
|
|
717
|
+
(0, import_editor_angie_sdk3.toggleAngieSidebar)(angieSidebar, true);
|
|
718
|
+
(0, import_editor_angie_sdk3.setAngieInteractionMode)(mode);
|
|
754
719
|
if (prompt) {
|
|
755
720
|
window.location.hash = `angie-prompt=${encodeURIComponent(prompt)}`;
|
|
756
721
|
}
|
|
757
722
|
};
|
|
758
723
|
|
|
759
724
|
// src/utils/send-prompt-to-angie.ts
|
|
760
|
-
var
|
|
725
|
+
var import_editor_angie_sdk4 = require("@elementor/editor-angie-sdk");
|
|
761
726
|
var sendPromptToAngie = (prompt) => {
|
|
762
|
-
if (openLoadedEditorAngie(prompt,
|
|
727
|
+
if (openLoadedEditorAngie(prompt, import_editor_angie_sdk4.AngieInteractionMode.AGENT)) {
|
|
763
728
|
return;
|
|
764
729
|
}
|
|
765
|
-
const angieSidebar = (0,
|
|
730
|
+
const angieSidebar = (0, import_editor_angie_sdk4.getAngieIframe)();
|
|
766
731
|
if (!angieSidebar) {
|
|
767
732
|
return;
|
|
768
733
|
}
|
|
769
|
-
(0,
|
|
734
|
+
(0, import_editor_angie_sdk4.toggleAngieSidebar)(angieSidebar, true);
|
|
770
735
|
if (!prompt) {
|
|
771
736
|
return;
|
|
772
737
|
}
|
|
@@ -774,19 +739,19 @@ var sendPromptToAngie = (prompt) => {
|
|
|
774
739
|
};
|
|
775
740
|
|
|
776
741
|
// src/utils/redirect-to-installation.ts
|
|
777
|
-
var
|
|
742
|
+
var import_editor_angie_sdk5 = require("@elementor/editor-angie-sdk");
|
|
778
743
|
var ANGIE_INSTALL_URL = "/wp-admin/plugin-install.php?s=angie&tab=search&type=term";
|
|
779
744
|
var redirectToInstallation = (prompt) => {
|
|
780
|
-
(0,
|
|
745
|
+
(0, import_editor_angie_sdk5.setReferrerRedirect)(window.location.href, prompt);
|
|
781
746
|
window.location.href = ANGIE_INSTALL_URL;
|
|
782
747
|
};
|
|
783
748
|
|
|
784
749
|
// src/utils/redirect-to-app-admin.ts
|
|
785
|
-
var
|
|
750
|
+
var import_editor_angie_sdk6 = require("@elementor/editor-angie-sdk");
|
|
786
751
|
var ANGIE_APP_URL = "/wp-admin/admin.php?page=angie-app";
|
|
787
752
|
var redirectToAppAdmin = (prompt) => {
|
|
788
|
-
(0,
|
|
789
|
-
(0,
|
|
753
|
+
(0, import_editor_angie_sdk6.setReferrerRedirect)(window.location.href, prompt);
|
|
754
|
+
(0, import_editor_angie_sdk6.saveState)(import_editor_angie_sdk6.ANGIE_SIDEBAR_STATE_OPEN);
|
|
790
755
|
window.location.href = ANGIE_APP_URL;
|
|
791
756
|
};
|
|
792
757
|
|
|
@@ -867,9 +832,6 @@ var MCP_STYLES_APPLIED_EVENT = "elementor/mcp/styles-applied";
|
|
|
867
832
|
function dispatchMcpStylesAppliedEvent(payload) {
|
|
868
833
|
window.dispatchEvent(new CustomEvent(MCP_STYLES_APPLIED_EVENT, { detail: payload }));
|
|
869
834
|
}
|
|
870
|
-
|
|
871
|
-
// src/index.ts
|
|
872
|
-
var getAngieSdk = () => getSDK();
|
|
873
835
|
// Annotate the CommonJS export names for ESM import in node:
|
|
874
836
|
0 && (module.exports = {
|
|
875
837
|
ANGIE_MODEL_PREFERENCES,
|
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/can-create-widget.ts","../src/utils/is-angie-sidebar-open.ts","../src/mcp-registry.ts","../src/adapters/web-mcp-adapter.ts","../src/utils/register-model-context-tool.ts","../src/angie-annotations.ts","../src/test-utils/mock-mcp-registry.ts","../src/utils/get-model-context.ts","../src/utils/merge-required-resources.ts","../src/utils/create-simple-resource-handler.ts","../src/utils/register-server-docs-resource.ts","../src/utils/to-mcp-title.ts","../src/adapters/angie-adapter.ts","../src/sampler.ts","../src/utils/prompt-builder.ts","../src/utils/get-active-chat-info.ts","../src/utils/open-angie-in-ask-mode.ts","../src/utils/send-prompt-to-angie.ts","../src/utils/redirect-to-installation.ts","../src/utils/redirect-to-app-admin.ts","../src/utils/install-angie-plugin.ts","../src/utils/save-angie-consent.ts","../src/init.ts","../src/events/mcp-styles-applied-event.ts"],"sourcesContent":["import './types/open-angie-request';\n\nimport { getSDK } from './utils/get-sdk';\nexport { getAngieIframe, MessageEventType as AngieMessageEvenetType } from './utils/get-sdk';\n\nexport {\n\tMcpServer,\n\tResourceTemplate,\n\ttype RegisteredResource,\n\ttype ToolCallback,\n} from '@modelcontextprotocol/sdk/server/mcp.js';\nexport { SamplingMessageSchema } from '@modelcontextprotocol/sdk/types.js';\nexport { isAngieAvailable } from './utils/is-angie-available';\nexport { canCreateWidget } from './utils/can-create-widget';\nexport { isAngieSidebarOpen } from './utils/is-angie-sidebar-open';\nexport * from './mcp-registry';\nexport { AngieMcpAdapter } from './adapters/angie-adapter';\nexport type { IMcpRegistrationAdapter } from './adapters/types';\nexport { createSampler } from './sampler';\nexport { toolPrompts } from './utils/prompt-builder';\nexport { ANGIE_MODEL_PREFERENCES, ANGIE_REQUIRED_RESOURCES, type AngieModelPreferences } from './angie-annotations';\nexport { getActiveChatInfo, type ActiveChatInfo } from './utils/get-active-chat-info';\nexport { hasLoadedEditorAngie, openAngieInAgentMode, openAngieInAskMode } from './utils/open-angie-in-ask-mode';\nexport type {\n\tEditorAngieWindowHost,\n\tOpenAngieCommonProperties,\n\tOpenAngiePluginProperties,\n\tOpenAngieRequest,\n\tOpenAngieSdkProperties,\n} from './types/open-angie-request';\nexport { sendPromptToAngie } from './utils/send-prompt-to-angie';\nexport { redirectToInstallation } from './utils/redirect-to-installation';\nexport { redirectToAppAdmin } from './utils/redirect-to-app-admin';\nexport { installAngiePlugin, type InstallAngieResult } from './utils/install-angie-plugin';\nexport { saveAngieConsent } from './utils/save-angie-consent';\nexport const getAngieSdk = () => getSDK();\nexport * from './init';\nexport {\n\tdispatchMcpStylesAppliedEvent,\n\tMCP_STYLES_APPLIED_EVENT,\n\ttype McpStylesAppliedPayload,\n} from './events/mcp-styles-applied-event';\n","import { AngieMcpSdk } from '@elementor-external/angie-sdk';\nexport { getAngieIframe, MessageEventType } from '@elementor-external/angie-sdk';\n\nlet sdk: AngieMcpSdk;\n\nclass RetriableAngieSDK extends AngieMcpSdk {\n\tpublic async waitForReady(): Promise< void > {\n\t\tlet retryCount = 3;\n\t\twhile ( retryCount > 0 ) {\n\t\t\ttry {\n\t\t\t\tawait super.waitForReady();\n\t\t\t\treturn;\n\t\t\t} catch {\n\t\t\t\tretryCount--;\n\t\t\t\tawait sleep();\n\t\t\t}\n\t\t}\n\t\treturn new Promise( () => {} ); // never resolves\n\t}\n}\n\nconst sleep = ( ms = 10_000 ) =>\n\tnew Promise( ( resolve ) => {\n\t\tsetTimeout( resolve, ms );\n\t} );\n\nexport const getSDK = () => {\n\t// @ts-ignore - QUnit fails this\n\tconst isMCPDisabled = !! ( globalThis as Record< string, unknown > ).__ELEMENTOR_MCP_DISABLED__;\n\tif ( isMCPDisabled ) {\n\t\treturn {} as unknown as AngieMcpSdk;\n\t}\n\tif ( ! sdk ) {\n\t\tsdk = new RetriableAngieSDK();\n\t}\n\treturn sdk;\n};\n","import { getAngieIframe } from '@elementor-external/angie-sdk';\n\nexport const isAngieAvailable = (): boolean => {\n\treturn !! getAngieIframe();\n};\n","export const canCreateWidget = (): boolean => {\n\treturn Boolean( window.elementor?.config?.widgetCreation?.canCreateWidget );\n};\n","import { ANGIE_SIDEBAR_STATE_OPEN, getAngieSidebarSavedState } from '@elementor-external/angie-sdk';\n\nexport const isAngieSidebarOpen = (): boolean => {\n\treturn getAngieSidebarSavedState() === ANGIE_SIDEBAR_STATE_OPEN;\n};\n","import { z, type z3 } from '@elementor/schema';\nimport { McpServer, type ToolCallback } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { type RequestHandlerExtra } from '@modelcontextprotocol/sdk/shared/protocol.js';\nimport { type ServerNotification, type ServerRequest } from '@modelcontextprotocol/sdk/types.js';\n\nimport { type IMcpRegistrationAdapter, type McpResourceHandler, type McpResourceUriOrTemplate } from './adapters/types';\nimport { WebMCPAdapter } from './adapters/web-mcp-adapter';\nimport {\n\tANGIE_MODEL_PREFERENCES,\n\tANGIE_REQUIRED_RESOURCES,\n\ttype AngieModelPreferences,\n\tcreateDefaultModelPreferences,\n} from './angie-annotations';\nimport { mockMcpRegistry } from './test-utils/mock-mcp-registry';\nimport { getModelContext } from './utils/get-model-context';\nimport { mergeRequiredResources, type ResourceList } from './utils/merge-required-resources';\nimport { registerServerDocsResource } from './utils/register-server-docs-resource';\nimport { toMCPTitle } from './utils/to-mcp-title';\n\ntype ZodRawShape = z3.ZodRawShape;\n\nconst mcpRegistry: { [ namespace: string ]: McpServer } = {};\nconst mcpDescriptions: { [ namespace: string ]: string } = {};\n// @ts-ignore - QUnit fails this\nconst isMcpRegistrationActivated = false || typeof globalThis.jest !== 'undefined';\n\nconst registrationAdapters: IMcpRegistrationAdapter[] = [];\nconst bufferedTools: Parameters< IMcpRegistrationAdapter[ 'onToolRegistered' ] >[] = [];\nconst bufferedResources: Parameters< IMcpRegistrationAdapter[ 'onResourceRegistered' ] >[] = [];\n\nlet resolveReady!: () => void;\nconst readyPromise = new Promise< void >( ( resolve ) => {\n\tresolveReady = resolve;\n} );\n\nexport const registerMcpAdapter = ( adapter: IMcpRegistrationAdapter ): void => {\n\tregistrationAdapters.push( adapter );\n\tfor ( const tool of bufferedTools ) {\n\t\ttry {\n\t\t\tadapter.onToolRegistered( tool[ 0 ], tool[ 1 ] );\n\t\t} catch {\n\t\t\t// exit quietly\n\t\t}\n\t}\n\tfor ( const resource of bufferedResources ) {\n\t\ttry {\n\t\t\tadapter.onResourceRegistered( ...resource );\n\t\t} catch {\n\t\t\t// exit quietly\n\t\t}\n\t}\n};\n\nexport const signalMcpReady = (): void => {\n\tresolveReady();\n};\n\nexport const waitForMcpReady = (): Promise< void > => readyPromise;\n\n/**\n * Registers and activates an adapter that becomes available after startup.\n * Waits for the startup activation so the adapter is activated exactly once.\n *\n * @param adapter - Adapter to register and activate.\n */\nexport const activateMcpAdapter = async ( adapter: IMcpRegistrationAdapter ): Promise< void > => {\n\tawait readyPromise;\n\tregisterMcpAdapter( adapter );\n\tawait adapter.activate();\n};\n\nexport const createAndRegisterAdapters = async (): Promise< void > => {\n\tconst modelContext = getModelContext();\n\n\tif ( modelContext ) {\n\t\tregisterMcpAdapter( new WebMCPAdapter( modelContext ) );\n\t}\n\n\tawait Promise.all( registrationAdapters.map( ( adapter ) => adapter.activate() ) );\n};\n\n// utility function to run a callback on all MCP interfaces\nfunction callAdapters( fn: ( adapter: IMcpRegistrationAdapter ) => unknown ) {\n\tfor ( const adapter of registrationAdapters ) {\n\t\ttry {\n\t\t\tfn( adapter );\n\t\t} catch {\n\t\t\t// adapter failed — exit quietly, continue to next\n\t\t}\n\t}\n}\n\nexport const registerMcp = ( mcp: McpServer, name: string ) => {\n\tconst mcpName = isAlphabet( name );\n\tmcpRegistry[ mcpName ] = mcp;\n};\n\nexport const getRegisteredMcpServers = (): Array< [ string, McpServer, string ] > => {\n\treturn Object.entries( mcpRegistry ).map( ( [ key, server ] ) => [ key, server, mcpDescriptions[ key ] || key ] );\n};\n\nconst isAlphabet = ( str: string ): string | never => {\n\tconst passes = !! str && /^[a-z_]+$/.test( str );\n\tif ( ! passes ) {\n\t\tthrow new Error( 'Not alphabet' );\n\t}\n\treturn str;\n};\n\n/**\n * @param namespace The namespace of the MCP server. It should contain only lowercase alphabetic characters.\n * @param options\n * @param options.instructions Short hint about the MCP and its toolset (MCP SDK `instructions`; keeps payload small).\n * @param options.docs Full documentation registered as a lazy-loaded resource.\n * When provided, it is registered at elementor://{namespace}/server-docs\n * and auto-injected into every tool's requiredResources.\n */\nexport const getMCPByDomain = (\n\tnamespace: string,\n\toptions?: { docs?: string; instructions?: string }\n): MCPRegistryEntry => {\n\tconst mcpName = `editor-${ isAlphabet( namespace ) }`;\n\tconst title = toMCPTitle( namespace );\n\t// @ts-ignore - QUnit fails this\n\tif ( typeof globalThis.jest !== 'undefined' ) {\n\t\treturn mockMcpRegistry();\n\t}\n\tif ( ! mcpRegistry[ namespace ] ) {\n\t\tmcpRegistry[ namespace ] = new McpServer(\n\t\t\t{ name: mcpName, title, version: '1.0.0' },\n\t\t\t{ instructions: options?.instructions, capabilities: { resources: { subscribe: true } } }\n\t\t);\n\t\tif ( options?.docs ) {\n\t\t\tregisterServerDocsResource( mcpRegistry[ namespace ], namespace, title, options.docs, ( ...args ) => {\n\t\t\t\tbufferedResources.push( args );\n\t\t\t\tcallAdapters( ( adapter ) => adapter.onResourceRegistered( ...args ) );\n\t\t\t} );\n\t\t}\n\t}\n\tconst mcpServer = mcpRegistry[ namespace ];\n\tconst serverDocsUri = options?.docs ? `elementor://${ namespace }/server-docs` : undefined;\n\tconst { addTool } = createToolRegistry( mcpServer, mcpName, serverDocsUri );\n\treturn {\n\t\twaitForReady: () => readyPromise,\n\t\t// @ts-expect-error: TS is unable to infer the type here\n\t\tresource: async ( ...args: Parameters< McpServer[ 'registerResource' ] > ) => {\n\t\t\tconst [ name, uriOrTemplate, ...rest ] = args as [ string, unknown, ...unknown[] ];\n\t\t\tconst handler = rest[ rest.length - 1 ] as McpResourceHandler;\n\t\t\tconst resourceArgs: Parameters< IMcpRegistrationAdapter[ 'onResourceRegistered' ] > = [\n\t\t\t\tname,\n\t\t\t\turiOrTemplate as McpResourceUriOrTemplate,\n\t\t\t\thandler,\n\t\t\t];\n\t\t\tbufferedResources.push( resourceArgs );\n\t\t\tcallAdapters( ( adapter ) => adapter.onResourceRegistered( ...resourceArgs ) );\n\t\t\treturn mcpServer.registerResource( ...args );\n\t\t},\n\t\tsendResourceUpdated: ( ...args: Parameters< McpServer[ 'server' ][ 'sendResourceUpdated' ] > ) => {\n\t\t\tcallAdapters( ( adapter ) => adapter.sendResourceUpdated( { uri: args[ 0 ].uri } ) );\n\t\t\treturn Promise.resolve( mcpServer.server.sendResourceUpdated( ...args ) ).catch( ( error: Error ) => {\n\t\t\t\tif ( error?.message?.includes( 'Not connected' ) ) {\n\t\t\t\t\treturn; // Expected when no MCP client is connected yet\n\t\t\t\t}\n\t\t\t\tif ( error?.message?.includes( 'does not support notifying about resources' ) ) {\n\t\t\t\t\treturn; // Server capability not declared — safe to ignore\n\t\t\t\t}\n\t\t\t\tthrow error;\n\t\t\t} );\n\t\t},\n\t\taddTool,\n\t\tsetMCPDescription: ( description: string ) => {\n\t\t\tmcpDescriptions[ namespace ] = description;\n\t\t},\n\t};\n};\n\nexport interface MCPRegistryEntry {\n\taddTool: < T extends undefined | z.ZodRawShape = undefined, O extends undefined | z.ZodRawShape = undefined >(\n\t\topts: ToolRegistrationOptions< T, O >\n\t) => void;\n\tsetMCPDescription: ( description: string ) => void;\n\tsendResourceUpdated: McpServer[ 'server' ][ 'sendResourceUpdated' ];\n\tresource: McpServer[ 'registerResource' ];\n\twaitForReady: () => Promise< void >;\n}\n\ntype ToolRegistrationOptions<\n\tInputArgs extends undefined | z.ZodRawShape = undefined,\n\tOutputSchema extends undefined | z.ZodRawShape = undefined,\n\tExpectedOutput = OutputSchema extends z.ZodRawShape ? z.objectOutputType< OutputSchema, z.ZodTypeAny > : string,\n> = {\n\tname: string;\n\tdescription: string;\n\tschema?: InputArgs;\n\t/**\n\t * Auto added fields:\n\t * @param errors z.string().optional().describe('Error message if the tool failed')\n\t */\n\toutputSchema?: OutputSchema;\n\thandler: InputArgs extends z.ZodRawShape\n\t\t? (\n\t\t\t\targs: z.objectOutputType< InputArgs, z.ZodTypeAny >,\n\t\t\t\textra: RequestHandlerExtra< ServerRequest, ServerNotification >\n\t\t ) => ExpectedOutput | Promise< ExpectedOutput >\n\t\t: (\n\t\t\t\targs: unknown,\n\t\t\t\textra: RequestHandlerExtra< ServerRequest, ServerNotification >\n\t\t ) => ExpectedOutput | Promise< ExpectedOutput >;\n\tisDestructive?: boolean;\n\trequiredResources?: ResourceList;\n\tmodelPreferences?: AngieModelPreferences;\n};\n\nfunction createToolRegistry( server: McpServer, serverName: string, serverDocsUri?: string ) {\n\tfunction addTool<\n\t\tT extends undefined | z.ZodRawShape = undefined,\n\t\tO extends undefined | z.ZodRawShape = undefined,\n\t>( opts: ToolRegistrationOptions< T, O > ) {\n\t\tconst outputSchema = opts.outputSchema as ZodRawShape | undefined;\n\t\tif ( outputSchema ) {\n\t\t\tObject.assign(\n\t\t\t\toutputSchema,\n\t\t\t\toutputSchema.errors ?? {\n\t\t\t\t\terrors: z.string().optional().describe( 'Error message if the tool failed' ),\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t\t// @ts-ignore: TS is unable to infer the type here\n\t\tconst inputSchema: ZodRawShape = opts.schema ? opts.schema : {};\n\t\tconst toolCallback: ToolCallback< ZodRawShape > = async function ( args, extra ) {\n\t\t\ttry {\n\t\t\t\tconst invocationResult = await opts.handler( opts.schema ? args : {}, extra );\n\t\t\t\treturn {\n\t\t\t\t\t// structuredContent: typeof invocationResult === 'string' ? undefined : invocationResult,\n\t\t\t\t\tcontent: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: 'text',\n\t\t\t\t\t\t\ttext:\n\t\t\t\t\t\t\t\ttypeof invocationResult === 'string'\n\t\t\t\t\t\t\t\t\t? invocationResult\n\t\t\t\t\t\t\t\t\t: JSON.stringify( invocationResult ),\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t};\n\t\t\t} catch ( error ) {\n\t\t\t\treturn {\n\t\t\t\t\tisError: true,\n\t\t\t\t\tstructuredContent: {\n\t\t\t\t\t\terrors: ( error as Error ).message || 'Unknown error',\n\t\t\t\t\t},\n\t\t\t\t\tcontent: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: 'text',\n\t\t\t\t\t\t\ttext:\n\t\t\t\t\t\t\t\t( ( error as Error ).message || 'Unknown error' ) +\n\t\t\t\t\t\t\t\tJSON.stringify( ( error as { response?: { data: unknown } } ).response?.data || error ),\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t};\n\t\t\t}\n\t\t};\n\t\tconst annotations: Record< string, unknown > = {\n\t\t\tdestructiveHint: opts.isDestructive,\n\t\t\treadOnlyHint: opts.isDestructive ? false : undefined,\n\t\t\ttitle: opts.name,\n\t\t};\n\t\tconst mergedResources = mergeRequiredResources( opts.requiredResources, serverDocsUri );\n\t\tconst angieAnnotations = {\n\t\t\t[ ANGIE_MODEL_PREFERENCES ]: opts.modelPreferences ?? createDefaultModelPreferences(),\n\t\t\t[ ANGIE_REQUIRED_RESOURCES ]: mergedResources,\n\t\t};\n\t\tserver.registerTool(\n\t\t\topts.name,\n\t\t\t{\n\t\t\t\tdescription: opts.description,\n\t\t\t\tinputSchema,\n\t\t\t\t// TODO: Uncomment this when the outputSchema is stable\n\t\t\t\t// outputSchema,\n\t\t\t\ttitle: opts.name,\n\t\t\t\tannotations,\n\t\t\t\t_meta: angieAnnotations,\n\t\t\t},\n\t\t\ttoolCallback\n\t\t);\n\t\tconst toolDescriptor = {\n\t\t\tname: opts.name,\n\t\t\tdescription: opts.description,\n\t\t\tinputSchema: inputSchema as object,\n\t\t\texecute: ( params: Record< string, unknown > ) =>\n\t\t\t\ttoolCallback(\n\t\t\t\t\tparams as Parameters< typeof toolCallback >[ 0 ],\n\t\t\t\t\t/* WebMCP: no protocol session — handlers must not rely on `extra` here */\n\t\t\t\t\t{} as RequestHandlerExtra< ServerRequest, ServerNotification >\n\t\t\t\t) as Promise< unknown >,\n\t\t};\n\t\tconst extraData = {\n\t\t\tresources: [ `Server resource name: ${ serverName }, Required to fetch!` ],\n\t\t\trequiredResources: mergedResources?.map( ( resource ) => resource.uri ) ?? [],\n\t\t};\n\t\tbufferedTools.push( [ toolDescriptor, extraData ] );\n\t\tcallAdapters( ( adapter ) => adapter.onToolRegistered( toolDescriptor, extraData ) );\n\t\tif ( isMcpRegistrationActivated ) {\n\t\t\tserver.sendToolListChanged();\n\t\t}\n\t}\n\treturn {\n\t\taddTool,\n\t};\n}\n","import { zodToJsonSchema } from 'zod-to-json-schema';\nimport { z, type z3 } from '@elementor/schema';\n\nimport { type ModelContextRegisterTool, registerModelContextTool } from '../utils/register-model-context-tool';\nimport {\n\ttype IMcpRegistrationAdapter,\n\ttype McpResourceHandler,\n\ttype McpResourceUriOrTemplate,\n\ttype McpToolDescriptor,\n\ttype UriTemplate,\n} from './types';\n\ntype ZodRawShape = z3.ZodRawShape;\n\nexport type ModelContext = {\n\tregisterTool: ModelContextRegisterTool;\n\tunregisterTool?: ( name: string ) => void;\n};\n\ntype ResourceEntry = {\n\tpattern: string;\n\tmatch: ( uri: string ) => Record< string, string | string[] > | null;\n\thandler: McpResourceHandler;\n};\n\nexport class WebMCPAdapter implements IMcpRegistrationAdapter {\n\tprivate readonly registeredToolNames = new Set< string >();\n\tprivate readonly resourceEntries: ResourceEntry[] = [];\n\tprivate activated = false;\n\n\tconstructor( private readonly ctx: ModelContext ) {}\n\n\tactivate(): Promise< void > {\n\t\tif ( this.activated ) {\n\t\t\treturn Promise.resolve();\n\t\t}\n\t\tthis.activated = true;\n\t\treturn registerModelContextTool( this.ctx.registerTool, {\n\t\t\tname: 'editor-resource-getter',\n\t\t\tdescription:\n\t\t\t\t'Get an editor resource by URI, or search for available resources by partial URI. Pass a full URI to retrieve content, or a partial string to discover matching patterns.',\n\t\t\tinputSchema: {\n\t\t\t\ttype: 'object',\n\t\t\t\tproperties: {\n\t\t\t\t\turi: {\n\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t'A full resource URI (e.g. elementor://style/best-practices) or a partial string to search across available resource patterns.',\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\trequired: [ 'uri' ],\n\t\t\t},\n\t\t\texecute: async ( params ) => {\n\t\t\t\tconst query = params.uri as string;\n\t\t\t\tconst entries = this.resourceEntries;\n\n\t\t\t\tif ( entries.length === 0 ) {\n\t\t\t\t\treturn 'No resources are registered yet.';\n\t\t\t\t}\n\n\t\t\t\t// Exact URI match\n\t\t\t\tfor ( const entry of entries ) {\n\t\t\t\t\tconst variables = entry.match( query );\n\t\t\t\t\tif ( variables !== null ) {\n\t\t\t\t\t\tlet resourceUrl: URL;\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tresourceUrl = new URL( query );\n\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\treturn `Invalid URI '${ query }'. Provide a valid resource URI or a partial string to search patterns.`;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst result = await entry.handler( resourceUrl, variables );\n\t\t\t\t\t\treturn result.contents?.[ 0 ]?.text ?? JSON.stringify( result );\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Partial search fallback\n\t\t\t\tconst matches = entries.map( ( e ) => e.pattern ).filter( ( pattern ) => pattern.includes( query ) );\n\t\t\t\tif ( matches.length > 0 ) {\n\t\t\t\t\treturn `Found ${ matches.length } matching resource pattern(s):\\n${ matches.join(\n\t\t\t\t\t\t'\\n'\n\t\t\t\t\t) }\\n\\nProvide a full URI to retrieve the resource content.`;\n\t\t\t\t}\n\n\t\t\t\tconst available = entries.map( ( e ) => e.pattern ).join( '\\n' );\n\t\t\t\tthrow new Error( `No resource matched '${ query }'.\\n\\nAvailable patterns:\\n${ available }` );\n\t\t\t},\n\t\t} );\n\t}\n\n\tonToolRegistered(\n\t\ttool: McpToolDescriptor,\n\t\textraData?: { resources: string[]; requiredResources: string[] }\n\t): void {\n\t\tlet jsonSchema: object;\n\t\ttry {\n\t\t\tjsonSchema = zodToJsonSchema( z.object( tool.inputSchema as ZodRawShape ) );\n\t\t} catch {\n\t\t\tjsonSchema = tool.inputSchema;\n\t\t}\n\n\t\tif ( this.registeredToolNames.has( tool.name ) ) {\n\t\t\tthis.ctx.unregisterTool?.( tool.name );\n\t\t\tthis.registeredToolNames.delete( tool.name );\n\t\t}\n\n\t\tlet resourcesDescription = '';\n\t\tif ( extraData ) {\n\t\t\tif ( extraData.resources?.length > 0 ) {\n\t\t\t\tresourcesDescription += `#Resources:\\n${ extraData.resources?.join( '\\n' ) }\\n\\n`;\n\t\t\t}\n\t\t\tif ( extraData.requiredResources?.length > 0 ) {\n\t\t\t\tresourcesDescription += `#Required Resources:\\n${ extraData.requiredResources?.join( '\\n' ) }\\n\\n`;\n\t\t\t}\n\t\t\tresourcesDescription += `To read resources, use editor-resource-getter tool.\\n\\n`;\n\t\t}\n\t\tvoid registerModelContextTool( this.ctx.registerTool, {\n\t\t\tname: tool.name,\n\t\t\tdescription: `${ resourcesDescription }${ tool.description }`,\n\t\t\tinputSchema: jsonSchema,\n\t\t\texecute: tool.execute,\n\t\t} ).then( () => {\n\t\t\tthis.registeredToolNames.add( tool.name );\n\t\t} );\n\t}\n\n\tonResourceRegistered( _name: string, uriOrTemplate: McpResourceUriOrTemplate, handler: McpResourceHandler ): void {\n\t\tif ( typeof uriOrTemplate === 'string' ) {\n\t\t\tthis.resourceEntries.push( {\n\t\t\t\tpattern: uriOrTemplate,\n\t\t\t\tmatch: ( uri ) => ( uri === uriOrTemplate ? {} : null ),\n\t\t\t\thandler,\n\t\t\t} );\n\t\t} else {\n\t\t\tconst template = uriOrTemplate.uriTemplate as UriTemplate;\n\t\t\tthis.resourceEntries.push( {\n\t\t\t\tpattern: template.toString(),\n\t\t\t\tmatch: ( uri ) => template.match( uri ),\n\t\t\t\thandler,\n\t\t\t} );\n\t\t}\n\t}\n\n\tsendResourceUpdated(): void {\n\t\t// WebMCP has no server-push mechanism — no-op\n\t}\n}\n","import { type McpToolDescriptor } from '../adapters/types';\n\nexport type ModelContextRegisterTool = ( tool: McpToolDescriptor ) => void | Promise< void >;\n\nexport async function registerModelContextTool(\n\tregisterTool: ModelContextRegisterTool,\n\ttool: McpToolDescriptor\n): Promise< void > {\n\ttry {\n\t\tawait Promise.resolve( registerTool( tool ) );\n\t} catch ( error ) {\n\t\t/* eslint-disable-next-line no-console */\n\t\tconsole.error( 'Tool registration failed:', error );\n\t}\n}\n","export const ANGIE_MODEL_PREFERENCES = 'angie/modelPreferences' as const;\nexport const ANGIE_REQUIRED_RESOURCES = 'angie/requiredResources' as const;\n\nexport interface AngieModelPreferences {\n\thints?: Array< { name: string } >;\n\tcostPriority?: number; // 0-1 (future use)\n\tspeedPriority?: number; // 0-1 (future use)\n\tintelligencePriority?: number; // 0-1 (future use)\n}\n\nexport function createDefaultModelPreferences(): AngieModelPreferences {\n\treturn {\n\t\thints: [ { name: 'claude-sonnet-4-6' } ],\n\t};\n}\n","import { type McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\n\nimport { type MCPRegistryEntry } from '../mcp-registry';\n\nconst mock = new Proxy(\n\t{},\n\t{\n\t\tget: () => {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unused-vars\n\t\t\tfunction mockedFn( ..._: unknown[] ) {}\n\t\t\treturn mockedFn;\n\t\t},\n\t}\n);\n\nexport const mockMcpRegistry = (): MCPRegistryEntry => {\n\treturn {\n\t\t// @ts-ignore\n\t\tresource: async () => {},\n\t\t// @ts-ignore\n\t\tsendResourceUpdated: () => {},\n\t\taddTool: () => {},\n\t\tsetMCPDescription: () => {},\n\t\tmcpServer: mock as McpServer,\n\t};\n};\n","import { type ModelContext } from '../adapters/web-mcp-adapter';\n\ntype ModelContextHost = {\n\tmodelContext?: ModelContext;\n};\n\nfunction bindModelContextMethods( host: ModelContext ): ModelContext {\n\treturn {\n\t\tregisterTool: host.registerTool.bind( host ),\n\t\tunregisterTool: host.unregisterTool ? host.unregisterTool.bind( host ) : undefined,\n\t};\n}\n\nexport function getModelContext(): ModelContext | undefined {\n\tconst documentModelContext =\n\t\ttypeof document !== 'undefined' ? ( document as unknown as ModelContextHost ).modelContext : undefined;\n\tif ( documentModelContext?.registerTool ) {\n\t\treturn bindModelContextMethods( documentModelContext );\n\t}\n\tconst navigatorModelContext =\n\t\ttypeof navigator !== 'undefined' ? ( navigator as unknown as ModelContextHost ).modelContext : undefined;\n\tif ( navigatorModelContext?.registerTool ) {\n\t\treturn bindModelContextMethods( navigatorModelContext );\n\t}\n\n\treturn undefined;\n}\n","export type ResourceList = {\n\turi: string;\n\tdescription: string;\n}[];\n\nexport const mergeRequiredResources = (\n\ttoolResources: ResourceList | undefined,\n\tserverDocsUri: string | undefined\n): ResourceList | undefined => {\n\tif ( ! serverDocsUri ) {\n\t\treturn toolResources;\n\t}\n\tif ( toolResources?.some( ( r ) => r.uri === serverDocsUri ) ) {\n\t\treturn toolResources;\n\t}\n\treturn [ ...( toolResources ?? [] ), { uri: serverDocsUri, description: 'Server docs' } ];\n};\n","export const createSimpleResourceHandler = ( text: string ) => async ( uri: URL ) => ( {\n\tcontents: [ { uri: uri.href, mimeType: 'text/plain', text } ],\n} );\n","import { type McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\n\nimport { type IMcpRegistrationAdapter } from '../adapters/types';\nimport { createSimpleResourceHandler } from './create-simple-resource-handler';\n\ntype OnResourceRegistered = ( ...args: Parameters< IMcpRegistrationAdapter[ 'onResourceRegistered' ] > ) => void;\n\nexport const registerServerDocsResource = (\n\tserver: McpServer,\n\tnamespace: string,\n\ttitle: string,\n\tdocs: string,\n\tonRegistered: OnResourceRegistered\n): void => {\n\tconst uri = `elementor://${ namespace }/server-docs`;\n\tconst name = `${ namespace }-server-docs`;\n\tconst handler = createSimpleResourceHandler( docs );\n\tserver.registerResource(\n\t\tname,\n\t\turi,\n\t\t{\n\t\t\ttitle: `${ title } server docs`,\n\t\t\tdescription: 'Full MCP documentation (lazy-loaded)',\n\t\t\tmimeType: 'text/plain',\n\t\t},\n\t\thandler\n\t);\n\tonRegistered( name, uri, handler );\n};\n","export const toMCPTitle = ( namespace: string ): string => {\n\tconst label = namespace\n\t\t.split( '_' )\n\t\t.filter( Boolean )\n\t\t.map( ( word ) => word.charAt( 0 ).toUpperCase() + word.slice( 1 ) )\n\t\t.join( ' ' );\n\n\treturn `Editor ${ label }`;\n};\n","import { type AngieMcpSdk } from '@elementor-external/angie-sdk';\n\nimport { type getRegisteredMcpServers as _getRegisteredMcpServers } from '../mcp-registry';\nimport { toMCPTitle } from '../utils/to-mcp-title';\nimport { type IMcpRegistrationAdapter } from './types';\n\nconst MAX_RETRIES = 3;\n\nexport class AngieMcpAdapter implements IMcpRegistrationAdapter {\n\tconstructor(\n\t\tprivate readonly sdk: AngieMcpSdk,\n\t\tprivate readonly getRegisteredMcpServers: typeof _getRegisteredMcpServers\n\t) {}\n\n\tasync activate(): Promise< void > {\n\t\t// No waitForReady() here: registerLocalServer queues the server and the SDK flushes\n\t\t// the queue once Angie reports ready. waitForReady() only resolves for the SDK copy\n\t\t// that booted the sidebar, which is the host integration, never the editor bundle.\n\t\tawait this.registerEntries( this.getRegisteredMcpServers(), MAX_RETRIES );\n\t}\n\n\tprivate async registerEntries(\n\t\tentries: ReturnType< typeof _getRegisteredMcpServers >,\n\t\tretry: number\n\t): Promise< void > {\n\t\tif ( retry === 0 ) {\n\t\t\t/* eslint-disable-next-line no-console */\n\t\t\tconsole.error(\n\t\t\t\t'Failed to register MCP after 3 retries. failed entries: ',\n\t\t\t\tentries.map( ( [ key ] ) => key )\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tconst failed: typeof entries = [];\n\t\tfor ( const [ key, mcpServer, description ] of entries ) {\n\t\t\ttry {\n\t\t\t\tawait this.sdk.registerLocalServer( {\n\t\t\t\t\ttitle: toMCPTitle( key ),\n\t\t\t\t\tname: `editor-${ key }`,\n\t\t\t\t\tserver: mcpServer,\n\t\t\t\t\tversion: '1.0.0',\n\t\t\t\t\tdescription,\n\t\t\t\t} );\n\t\t\t} catch {\n\t\t\t\tfailed.push( [ key, mcpServer, description ] );\n\t\t\t}\n\t\t}\n\n\t\tif ( failed.length > 0 ) {\n\t\t\treturn this.registerEntries( failed, retry - 1 );\n\t\t}\n\t}\n\n\tonToolRegistered(): void {\n\t\t// Angie tools are registered via McpServer (at activate time).\n\t}\n\n\tonResourceRegistered(): void {\n\t\t// Resources are registered on the McpServer instance directly.\n\t}\n\n\tsendResourceUpdated(): void {\n\t\t// Resource update notifications are sent via MCPRegistryEntry.sendResourceUpdated.\n\t}\n}\n","import { type z } from '@elementor/schema';\nimport { type RequestHandlerExtra } from '@modelcontextprotocol/sdk/shared/protocol.js';\nimport { SamplingMessageSchema, type ServerNotification, type ServerRequest } from '@modelcontextprotocol/sdk/types.js';\n\ntype Server = RequestHandlerExtra< ServerRequest, ServerNotification >;\ntype Opts = {\n\tmaxTokens?: number;\n\tmodelPreferences?: string;\n\tmodel?: string;\n};\n\nconst DEFAULT_OPTS: Opts = {\n\tmaxTokens: 10000,\n\tmodelPreferences: 'openai',\n\tmodel: 'gpt-4o',\n};\n\ntype SamplingOpts = {\n\tsystemPrompt?: string;\n\tstructuredOutput?: z.ZodTypeAny;\n\tmessages: { role: 'user' | 'assistant'; content: { type: 'text'; text: string } }[];\n\trequestParams?: { [ key: string ]: string };\n};\n\nconst DEFAULT_STRUCTURED_OUTPUT = {\n\ttype: 'object',\n\tproperties: {\n\t\tcontent: {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Result',\n\t\t},\n\t},\n\trequired: [ 'content' ],\n\tadditionalProperties: false,\n};\n\nexport const createSampler = ( server: Server, opts: Opts = DEFAULT_OPTS ) => {\n\tconst { maxTokens = 1000, modelPreferences = 'openai', model = 'gpt-4o' } = opts;\n\tconst exec = async ( payload: SamplingOpts ) => {\n\t\tconst systemPromptObject = { ...( payload.systemPrompt ? { systemPrompt: payload.systemPrompt } : {} ) };\n\t\tconst requestParams = payload.requestParams || {};\n\t\tconst result = await server.sendRequest(\n\t\t\t{\n\t\t\t\tmethod: 'sampling/createMessage',\n\t\t\t\tparams: {\n\t\t\t\t\t...requestParams,\n\t\t\t\t\tmaxTokens,\n\t\t\t\t\tmodelPreferences: {\n\t\t\t\t\t\thints: [ { name: modelPreferences } ],\n\t\t\t\t\t},\n\t\t\t\t\tmetadata: {\n\t\t\t\t\t\tmodel,\n\t\t\t\t\t\t...systemPromptObject,\n\t\t\t\t\t\t...{ structured_output: payload.structuredOutput || DEFAULT_STRUCTURED_OUTPUT },\n\t\t\t\t\t},\n\t\t\t\t\tmessages: payload.messages,\n\t\t\t\t},\n\t\t\t\t// ...systemPromptObject,\n\t\t\t},\n\t\t\tSamplingMessageSchema\n\t\t);\n\t\treturn result.content;\n\t};\n\treturn exec;\n};\n","class ToolPrompts {\n\tpublic _description = '';\n\tpublic _parameters: Record< string, string > = {};\n\tpublic _examples: string[] = [];\n\tpublic _furtherInstructions: string[] = [];\n\n\tconstructor( public name: string ) {}\n\n\tdescription(): string;\n\tdescription( desc: string ): this;\n\tdescription( desc?: string | undefined ) {\n\t\tif ( typeof desc === 'undefined' ) {\n\t\t\treturn this._description;\n\t\t}\n\t\tthis._description = desc;\n\t\treturn this;\n\t}\n\n\tparameter( key: string ): string;\n\tparameter( key: string, description: string ): this;\n\tparameter( key: string, description?: string ) {\n\t\tif ( typeof description === 'undefined' ) {\n\t\t\treturn this._parameters[ key ];\n\t\t}\n\t\tthis._parameters[ key ] = `**${ key }**:\\n${ description }`;\n\t\treturn this;\n\t}\n\n\tinstruction( instruction: string ): this {\n\t\tthis._furtherInstructions.push( instruction );\n\t\treturn this;\n\t}\n\n\texample( example: string ): this {\n\t\tthis._examples.push( example );\n\t\treturn this;\n\t}\n\n\tpublic get examples() {\n\t\treturn this._examples.join( '\\n\\n' );\n\t}\n\n\tprompt(): string {\n\t\treturn `# ${ this.name }\n# Description\n${ this._description }\n${ this._parameters.length ? '# Parameters\\n' + Object.values( this._parameters ).join( '\\n\\n' ) : '' }\n${ this._examples.length ? '# Examples\\n' + this.examples : '' }\n${ this._furtherInstructions.length ? '# Further Instructions\\n' + this._furtherInstructions.join( '\\n\\n' ) : '' }\n`.trim();\n\t}\n}\n\nexport const toolPrompts = ( name: string ) => {\n\treturn new ToolPrompts( name );\n};\n","export type ActiveChatInfo = {\n\tsessionId: string;\n\texpiresAt: number;\n};\n\nexport const getActiveChatInfo = (): ActiveChatInfo => {\n\tconst info = localStorage.getItem( 'angie_active_chat_id' );\n\tif ( ! info ) {\n\t\treturn {\n\t\t\texpiresAt: 0,\n\t\t\tsessionId: '',\n\t\t};\n\t}\n\tconst rawData = JSON.parse( info );\n\treturn {\n\t\texpiresAt: rawData.expiresAt as number,\n\t\tsessionId: rawData.sessionId as string,\n\t};\n};\n","import {\n\tAngieInteractionMode,\n\tgetAngieIframe,\n\tsetAngieInteractionMode,\n\ttoggleAngieSidebar,\n} from '@elementor-external/angie-sdk';\n\nimport { isAngieAvailable } from './is-angie-available';\n\nconst getLoadedEditorAngie = () => {\n\treturn window.elementorV2?.editorAngie?.openAngie;\n};\n\nexport const hasLoadedEditorAngie = (): boolean => Boolean( getLoadedEditorAngie() );\n\nexport const openLoadedEditorAngie = ( prompt: string | undefined, mode: AngieInteractionMode ): boolean => {\n\tconst openAngie = getLoadedEditorAngie();\n\n\tif ( ! openAngie ) {\n\t\treturn false;\n\t}\n\n\tPromise.resolve( openAngie( { prompt: prompt ?? '', mode } ) ).catch( ( error ) => {\n\t\t// eslint-disable-next-line no-console\n\t\tconsole.error( 'Failed to open Angie:', error );\n\t} );\n\n\treturn true;\n};\n\nexport const openAngieInAskMode = ( prompt?: string ): void => {\n\topenAngieInMode( prompt, AngieInteractionMode.ASK );\n};\n\nexport const openAngieInAgentMode = ( prompt?: string ): void => {\n\topenAngieInMode( prompt, AngieInteractionMode.AGENT );\n};\n\nconst openAngieInMode = ( prompt: string | undefined, mode: AngieInteractionMode ): void => {\n\tif ( openLoadedEditorAngie( prompt, mode ) ) {\n\t\treturn;\n\t}\n\n\tif ( ! isAngieAvailable() ) {\n\t\treturn;\n\t}\n\n\tconst angieSidebar = getAngieIframe();\n\n\tif ( ! angieSidebar ) {\n\t\treturn;\n\t}\n\n\ttoggleAngieSidebar( angieSidebar, true );\n\tsetAngieInteractionMode( mode );\n\n\tif ( prompt ) {\n\t\twindow.location.hash = `angie-prompt=${ encodeURIComponent( prompt ) }`;\n\t}\n};\n","import { AngieInteractionMode, getAngieIframe, toggleAngieSidebar } from '@elementor-external/angie-sdk';\n\nimport { openLoadedEditorAngie } from './open-angie-in-ask-mode';\n\nexport const sendPromptToAngie = ( prompt?: string ) => {\n\tif ( openLoadedEditorAngie( prompt, AngieInteractionMode.AGENT ) ) {\n\t\treturn;\n\t}\n\n\tconst angieSidebar = getAngieIframe();\n\n\tif ( ! angieSidebar ) {\n\t\treturn;\n\t}\n\n\ttoggleAngieSidebar( angieSidebar, true );\n\n\tif ( ! prompt ) {\n\t\treturn;\n\t}\n\n\twindow.location.hash = `angie-prompt=${ encodeURIComponent( prompt ) }`;\n};\n","import { setReferrerRedirect } from '@elementor-external/angie-sdk';\n\nconst ANGIE_INSTALL_URL = '/wp-admin/plugin-install.php?s=angie&tab=search&type=term';\n\n/**\n * @deprecated Kept only for Elementor Pro compatibility. Will be removed in a future version.\n * @param prompt Optional prompt to pass after redirect.\n */\nexport const redirectToInstallation = ( prompt?: string ) => {\n\tsetReferrerRedirect( window.location.href, prompt );\n\twindow.location.href = ANGIE_INSTALL_URL;\n};\n","import { ANGIE_SIDEBAR_STATE_OPEN, saveState, setReferrerRedirect } from '@elementor-external/angie-sdk';\n\nconst ANGIE_APP_URL = '/wp-admin/admin.php?page=angie-app';\n\n/**\n * @deprecated Kept only for Elementor Pro compatibility. Will be removed in a future version.\n * @param prompt Optional prompt to pass after redirect.\n */\nexport const redirectToAppAdmin = ( prompt?: string ) => {\n\tsetReferrerRedirect( window.location.href, prompt );\n\tsaveState( ANGIE_SIDEBAR_STATE_OPEN );\n\twindow.location.href = ANGIE_APP_URL;\n};\n","import apiFetch from '@wordpress/api-fetch';\n\ntype PluginResponse = {\n\tplugin: string;\n\tstatus: 'active' | 'inactive';\n\tname: string;\n};\n\ntype PluginErrorResponse = {\n\tcode: string;\n\tmessage: string;\n};\n\nexport type InstallAngieResult = { success: true } | { success: false; error: string; code?: string };\n\nconst ANGIE_SLUG = 'angie';\n\nconst isPluginErrorResponse = ( response: unknown ): response is PluginErrorResponse => {\n\treturn typeof response === 'object' && response !== null && 'code' in response && 'message' in response;\n};\n\nconst activatePlugin = async ( pluginPath: string ): Promise< PluginResponse > => {\n\treturn apiFetch< PluginResponse >( {\n\t\tpath: `/wp/v2/plugins/${ pluginPath }`,\n\t\tmethod: 'POST',\n\t\tdata: { status: 'active' },\n\t} );\n};\n\nconst installPlugin = async (): Promise< PluginResponse > => {\n\ttry {\n\t\treturn await apiFetch< PluginResponse >( {\n\t\t\tpath: '/wp/v2/plugins',\n\t\t\tmethod: 'POST',\n\t\t\tdata: {\n\t\t\t\tslug: ANGIE_SLUG,\n\t\t\t\tstatus: 'active',\n\t\t\t},\n\t\t} );\n\t} catch ( error: unknown ) {\n\t\tif ( isPluginErrorResponse( error ) && error.code === 'folder_exists' ) {\n\t\t\treturn activatePlugin( `${ ANGIE_SLUG }/${ ANGIE_SLUG }` );\n\t\t}\n\n\t\tthrow error;\n\t}\n};\n\n/**\n * @deprecated Kept only for Elementor Pro compatibility. Will be removed in a future version.\n */\nexport const installAngiePlugin = async (): Promise< InstallAngieResult > => {\n\ttry {\n\t\tawait installPlugin();\n\n\t\treturn { success: true };\n\t} catch ( error: unknown ) {\n\t\tif ( isPluginErrorResponse( error ) ) {\n\t\t\treturn { success: false, error: error.message, code: error.code };\n\t\t}\n\n\t\treturn { success: false, error: 'Unknown error occurred' };\n\t}\n};\n","import apiFetch from '@wordpress/api-fetch';\n\nexport const saveAngieConsent = async (): Promise< void > => {\n\tawait apiFetch( {\n\t\tpath: '/elementor/v1/angie/consent',\n\t\tmethod: 'POST',\n\t} );\n};\n","import { createAndRegisterAdapters, signalMcpReady } from './mcp-registry';\n\nlet isInitialized = false;\nexport async function startMCPServer() {\n\tif ( isInitialized ) {\n\t\treturn;\n\t}\n\tisInitialized = true;\n\ttry {\n\t\tawait createAndRegisterAdapters();\n\t} catch ( error ) {\n\t\t/* eslint-disable-next-line no-console */\n\t\tconsole.error( 'MCP adapter activation failed:', error );\n\t} finally {\n\t\tsignalMcpReady();\n\t}\n}\n\n// Start right away when the bundle loads after DOMContentLoaded (late or deferred load): the event will\n// not fire again, and `waitForMcpReady()` callers would wait forever.\nif ( typeof document !== 'undefined' && document.readyState === 'loading' ) {\n\tdocument.addEventListener( 'DOMContentLoaded', () => void startMCPServer(), { once: true } );\n} else {\n\tvoid startMCPServer();\n}\n","export const MCP_STYLES_APPLIED_EVENT = 'elementor/mcp/styles-applied';\n\nexport type McpStylesAppliedPayload = {\n\tstyleValue: Record< string, unknown >;\n};\n\nexport function dispatchMcpStylesAppliedEvent( payload: McpStylesAppliedPayload ): void {\n\twindow.dispatchEvent( new CustomEvent( MCP_STYLES_APPLIED_EVENT, { detail: payload } ) );\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;AAAA;AAAA;AAAA;AAAA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AE,QAAQ,QAAQ,CAAE,CAAE;AACxF;;;A1B2BO,IAAM,cAAc,MAAM,OAAO;","names":["import_angie_sdk","import_mcp","import_types","import_angie_sdk","import_angie_sdk","import_schema","sdk","getRegisteredMcpServers","import_angie_sdk","import_angie_sdk","import_angie_sdk","import_angie_sdk","apiFetch","import_api_fetch","apiFetch"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/utils/is-angie-available.ts","../src/utils/can-create-widget.ts","../src/utils/is-angie-sidebar-open.ts","../src/mcp-registry.ts","../src/adapters/web-mcp-adapter.ts","../src/utils/register-model-context-tool.ts","../src/angie-annotations.ts","../src/test-utils/mock-mcp-registry.ts","../src/utils/get-model-context.ts","../src/utils/merge-required-resources.ts","../src/utils/create-simple-resource-handler.ts","../src/utils/register-server-docs-resource.ts","../src/utils/to-mcp-title.ts","../src/adapters/angie-adapter.ts","../src/sampler.ts","../src/utils/prompt-builder.ts","../src/utils/get-active-chat-info.ts","../src/utils/open-angie-in-ask-mode.ts","../src/utils/send-prompt-to-angie.ts","../src/utils/redirect-to-installation.ts","../src/utils/redirect-to-app-admin.ts","../src/utils/install-angie-plugin.ts","../src/utils/save-angie-consent.ts","../src/init.ts","../src/events/mcp-styles-applied-event.ts"],"sourcesContent":["import './types/open-angie-request';\n\nexport { getAngieIframe, getAngieSdk, MessageEventType as AngieMessageEvenetType } from '@elementor/editor-angie-sdk';\n\nexport {\n\tMcpServer,\n\tResourceTemplate,\n\ttype RegisteredResource,\n\ttype ToolCallback,\n} from '@modelcontextprotocol/sdk/server/mcp.js';\nexport { SamplingMessageSchema } from '@modelcontextprotocol/sdk/types.js';\nexport { isAngieAvailable } from './utils/is-angie-available';\nexport { canCreateWidget } from './utils/can-create-widget';\nexport { isAngieSidebarOpen } from './utils/is-angie-sidebar-open';\nexport * from './mcp-registry';\nexport { AngieMcpAdapter } from './adapters/angie-adapter';\nexport type { IMcpRegistrationAdapter } from './adapters/types';\nexport { createSampler } from './sampler';\nexport { toolPrompts } from './utils/prompt-builder';\nexport { ANGIE_MODEL_PREFERENCES, ANGIE_REQUIRED_RESOURCES, type AngieModelPreferences } from './angie-annotations';\nexport { getActiveChatInfo, type ActiveChatInfo } from './utils/get-active-chat-info';\nexport { hasLoadedEditorAngie, openAngieInAgentMode, openAngieInAskMode } from './utils/open-angie-in-ask-mode';\nexport type {\n\tEditorAngieWindowHost,\n\tOpenAngieCommonProperties,\n\tOpenAngiePluginProperties,\n\tOpenAngieRequest,\n\tOpenAngieSdkProperties,\n} from './types/open-angie-request';\nexport { sendPromptToAngie } from './utils/send-prompt-to-angie';\nexport { redirectToInstallation } from './utils/redirect-to-installation';\nexport { redirectToAppAdmin } from './utils/redirect-to-app-admin';\nexport { installAngiePlugin, type InstallAngieResult } from './utils/install-angie-plugin';\nexport { saveAngieConsent } from './utils/save-angie-consent';\nexport * from './init';\nexport {\n\tdispatchMcpStylesAppliedEvent,\n\tMCP_STYLES_APPLIED_EVENT,\n\ttype McpStylesAppliedPayload,\n} from './events/mcp-styles-applied-event';\n","import { getAngieIframe } from '@elementor/editor-angie-sdk';\n\nexport const isAngieAvailable = (): boolean => {\n\treturn !! getAngieIframe();\n};\n","export const canCreateWidget = (): boolean => {\n\treturn Boolean( window.elementor?.config?.widgetCreation?.canCreateWidget );\n};\n","import { ANGIE_SIDEBAR_STATE_OPEN, getAngieSidebarSavedState } from '@elementor/editor-angie-sdk';\n\nexport const isAngieSidebarOpen = (): boolean => {\n\treturn getAngieSidebarSavedState() === ANGIE_SIDEBAR_STATE_OPEN;\n};\n","import { z, type z3 } from '@elementor/schema';\nimport { McpServer, type ToolCallback } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { type RequestHandlerExtra } from '@modelcontextprotocol/sdk/shared/protocol.js';\nimport { type ServerNotification, type ServerRequest } from '@modelcontextprotocol/sdk/types.js';\n\nimport { type IMcpRegistrationAdapter, type McpResourceHandler, type McpResourceUriOrTemplate } from './adapters/types';\nimport { WebMCPAdapter } from './adapters/web-mcp-adapter';\nimport {\n\tANGIE_MODEL_PREFERENCES,\n\tANGIE_REQUIRED_RESOURCES,\n\ttype AngieModelPreferences,\n\tcreateDefaultModelPreferences,\n} from './angie-annotations';\nimport { mockMcpRegistry } from './test-utils/mock-mcp-registry';\nimport { getModelContext } from './utils/get-model-context';\nimport { mergeRequiredResources, type ResourceList } from './utils/merge-required-resources';\nimport { registerServerDocsResource } from './utils/register-server-docs-resource';\nimport { toMCPTitle } from './utils/to-mcp-title';\n\ntype ZodRawShape = z3.ZodRawShape;\n\nconst mcpRegistry: { [ namespace: string ]: McpServer } = {};\nconst mcpDescriptions: { [ namespace: string ]: string } = {};\n// @ts-ignore - QUnit fails this\nconst isMcpRegistrationActivated = false || typeof globalThis.jest !== 'undefined';\n\nconst registrationAdapters: IMcpRegistrationAdapter[] = [];\nconst bufferedTools: Parameters< IMcpRegistrationAdapter[ 'onToolRegistered' ] >[] = [];\nconst bufferedResources: Parameters< IMcpRegistrationAdapter[ 'onResourceRegistered' ] >[] = [];\n\nlet resolveReady!: () => void;\nconst readyPromise = new Promise< void >( ( resolve ) => {\n\tresolveReady = resolve;\n} );\n\nexport const registerMcpAdapter = ( adapter: IMcpRegistrationAdapter ): void => {\n\tregistrationAdapters.push( adapter );\n\tfor ( const tool of bufferedTools ) {\n\t\ttry {\n\t\t\tadapter.onToolRegistered( tool[ 0 ], tool[ 1 ] );\n\t\t} catch {\n\t\t\t// exit quietly\n\t\t}\n\t}\n\tfor ( const resource of bufferedResources ) {\n\t\ttry {\n\t\t\tadapter.onResourceRegistered( ...resource );\n\t\t} catch {\n\t\t\t// exit quietly\n\t\t}\n\t}\n};\n\nexport const signalMcpReady = (): void => {\n\tresolveReady();\n};\n\nexport const waitForMcpReady = (): Promise< void > => readyPromise;\n\n/**\n * Registers and activates an adapter that becomes available after startup.\n * Waits for the startup activation so the adapter is activated exactly once.\n *\n * @param adapter - Adapter to register and activate.\n */\nexport const activateMcpAdapter = async ( adapter: IMcpRegistrationAdapter ): Promise< void > => {\n\tawait readyPromise;\n\tregisterMcpAdapter( adapter );\n\tawait adapter.activate();\n};\n\nexport const createAndRegisterAdapters = async (): Promise< void > => {\n\tconst modelContext = getModelContext();\n\n\tif ( modelContext ) {\n\t\tregisterMcpAdapter( new WebMCPAdapter( modelContext ) );\n\t}\n\n\tawait Promise.all( registrationAdapters.map( ( adapter ) => adapter.activate() ) );\n};\n\n// utility function to run a callback on all MCP interfaces\nfunction callAdapters( fn: ( adapter: IMcpRegistrationAdapter ) => unknown ) {\n\tfor ( const adapter of registrationAdapters ) {\n\t\ttry {\n\t\t\tfn( adapter );\n\t\t} catch {\n\t\t\t// adapter failed — exit quietly, continue to next\n\t\t}\n\t}\n}\n\nexport const registerMcp = ( mcp: McpServer, name: string ) => {\n\tconst mcpName = isAlphabet( name );\n\tmcpRegistry[ mcpName ] = mcp;\n};\n\nexport const getRegisteredMcpServers = (): Array< [ string, McpServer, string ] > => {\n\treturn Object.entries( mcpRegistry ).map( ( [ key, server ] ) => [ key, server, mcpDescriptions[ key ] || key ] );\n};\n\nconst isAlphabet = ( str: string ): string | never => {\n\tconst passes = !! str && /^[a-z_]+$/.test( str );\n\tif ( ! passes ) {\n\t\tthrow new Error( 'Not alphabet' );\n\t}\n\treturn str;\n};\n\n/**\n * @param namespace The namespace of the MCP server. It should contain only lowercase alphabetic characters.\n * @param options\n * @param options.instructions Short hint about the MCP and its toolset (MCP SDK `instructions`; keeps payload small).\n * @param options.docs Full documentation registered as a lazy-loaded resource.\n * When provided, it is registered at elementor://{namespace}/server-docs\n * and auto-injected into every tool's requiredResources.\n */\nexport const getMCPByDomain = (\n\tnamespace: string,\n\toptions?: { docs?: string; instructions?: string }\n): MCPRegistryEntry => {\n\tconst mcpName = `editor-${ isAlphabet( namespace ) }`;\n\tconst title = toMCPTitle( namespace );\n\t// @ts-ignore - QUnit fails this\n\tif ( typeof globalThis.jest !== 'undefined' ) {\n\t\treturn mockMcpRegistry();\n\t}\n\tif ( ! mcpRegistry[ namespace ] ) {\n\t\tmcpRegistry[ namespace ] = new McpServer(\n\t\t\t{ name: mcpName, title, version: '1.0.0' },\n\t\t\t{ instructions: options?.instructions, capabilities: { resources: { subscribe: true } } }\n\t\t);\n\t\tif ( options?.docs ) {\n\t\t\tregisterServerDocsResource( mcpRegistry[ namespace ], namespace, title, options.docs, ( ...args ) => {\n\t\t\t\tbufferedResources.push( args );\n\t\t\t\tcallAdapters( ( adapter ) => adapter.onResourceRegistered( ...args ) );\n\t\t\t} );\n\t\t}\n\t}\n\tconst mcpServer = mcpRegistry[ namespace ];\n\tconst serverDocsUri = options?.docs ? `elementor://${ namespace }/server-docs` : undefined;\n\tconst { addTool } = createToolRegistry( mcpServer, mcpName, serverDocsUri );\n\treturn {\n\t\twaitForReady: () => readyPromise,\n\t\t// @ts-expect-error: TS is unable to infer the type here\n\t\tresource: async ( ...args: Parameters< McpServer[ 'registerResource' ] > ) => {\n\t\t\tconst [ name, uriOrTemplate, ...rest ] = args as [ string, unknown, ...unknown[] ];\n\t\t\tconst handler = rest[ rest.length - 1 ] as McpResourceHandler;\n\t\t\tconst resourceArgs: Parameters< IMcpRegistrationAdapter[ 'onResourceRegistered' ] > = [\n\t\t\t\tname,\n\t\t\t\turiOrTemplate as McpResourceUriOrTemplate,\n\t\t\t\thandler,\n\t\t\t];\n\t\t\tbufferedResources.push( resourceArgs );\n\t\t\tcallAdapters( ( adapter ) => adapter.onResourceRegistered( ...resourceArgs ) );\n\t\t\treturn mcpServer.registerResource( ...args );\n\t\t},\n\t\tsendResourceUpdated: ( ...args: Parameters< McpServer[ 'server' ][ 'sendResourceUpdated' ] > ) => {\n\t\t\tcallAdapters( ( adapter ) => adapter.sendResourceUpdated( { uri: args[ 0 ].uri } ) );\n\t\t\treturn Promise.resolve( mcpServer.server.sendResourceUpdated( ...args ) ).catch( ( error: Error ) => {\n\t\t\t\tif ( error?.message?.includes( 'Not connected' ) ) {\n\t\t\t\t\treturn; // Expected when no MCP client is connected yet\n\t\t\t\t}\n\t\t\t\tif ( error?.message?.includes( 'does not support notifying about resources' ) ) {\n\t\t\t\t\treturn; // Server capability not declared — safe to ignore\n\t\t\t\t}\n\t\t\t\tthrow error;\n\t\t\t} );\n\t\t},\n\t\taddTool,\n\t\tsetMCPDescription: ( description: string ) => {\n\t\t\tmcpDescriptions[ namespace ] = description;\n\t\t},\n\t};\n};\n\nexport interface MCPRegistryEntry {\n\taddTool: < T extends undefined | z.ZodRawShape = undefined, O extends undefined | z.ZodRawShape = undefined >(\n\t\topts: ToolRegistrationOptions< T, O >\n\t) => void;\n\tsetMCPDescription: ( description: string ) => void;\n\tsendResourceUpdated: McpServer[ 'server' ][ 'sendResourceUpdated' ];\n\tresource: McpServer[ 'registerResource' ];\n\twaitForReady: () => Promise< void >;\n}\n\ntype ToolRegistrationOptions<\n\tInputArgs extends undefined | z.ZodRawShape = undefined,\n\tOutputSchema extends undefined | z.ZodRawShape = undefined,\n\tExpectedOutput = OutputSchema extends z.ZodRawShape ? z.objectOutputType< OutputSchema, z.ZodTypeAny > : string,\n> = {\n\tname: string;\n\tdescription: string;\n\tschema?: InputArgs;\n\t/**\n\t * Auto added fields:\n\t * @param errors z.string().optional().describe('Error message if the tool failed')\n\t */\n\toutputSchema?: OutputSchema;\n\thandler: InputArgs extends z.ZodRawShape\n\t\t? (\n\t\t\t\targs: z.objectOutputType< InputArgs, z.ZodTypeAny >,\n\t\t\t\textra: RequestHandlerExtra< ServerRequest, ServerNotification >\n\t\t ) => ExpectedOutput | Promise< ExpectedOutput >\n\t\t: (\n\t\t\t\targs: unknown,\n\t\t\t\textra: RequestHandlerExtra< ServerRequest, ServerNotification >\n\t\t ) => ExpectedOutput | Promise< ExpectedOutput >;\n\tisDestructive?: boolean;\n\trequiredResources?: ResourceList;\n\tmodelPreferences?: AngieModelPreferences;\n};\n\nfunction createToolRegistry( server: McpServer, serverName: string, serverDocsUri?: string ) {\n\tfunction addTool<\n\t\tT extends undefined | z.ZodRawShape = undefined,\n\t\tO extends undefined | z.ZodRawShape = undefined,\n\t>( opts: ToolRegistrationOptions< T, O > ) {\n\t\tconst outputSchema = opts.outputSchema as ZodRawShape | undefined;\n\t\tif ( outputSchema ) {\n\t\t\tObject.assign(\n\t\t\t\toutputSchema,\n\t\t\t\toutputSchema.errors ?? {\n\t\t\t\t\terrors: z.string().optional().describe( 'Error message if the tool failed' ),\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t\t// @ts-ignore: TS is unable to infer the type here\n\t\tconst inputSchema: ZodRawShape = opts.schema ? opts.schema : {};\n\t\tconst toolCallback: ToolCallback< ZodRawShape > = async function ( args, extra ) {\n\t\t\ttry {\n\t\t\t\tconst invocationResult = await opts.handler( opts.schema ? args : {}, extra );\n\t\t\t\treturn {\n\t\t\t\t\t// structuredContent: typeof invocationResult === 'string' ? undefined : invocationResult,\n\t\t\t\t\tcontent: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: 'text',\n\t\t\t\t\t\t\ttext:\n\t\t\t\t\t\t\t\ttypeof invocationResult === 'string'\n\t\t\t\t\t\t\t\t\t? invocationResult\n\t\t\t\t\t\t\t\t\t: JSON.stringify( invocationResult ),\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t};\n\t\t\t} catch ( error ) {\n\t\t\t\treturn {\n\t\t\t\t\tisError: true,\n\t\t\t\t\tstructuredContent: {\n\t\t\t\t\t\terrors: ( error as Error ).message || 'Unknown error',\n\t\t\t\t\t},\n\t\t\t\t\tcontent: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: 'text',\n\t\t\t\t\t\t\ttext:\n\t\t\t\t\t\t\t\t( ( error as Error ).message || 'Unknown error' ) +\n\t\t\t\t\t\t\t\tJSON.stringify( ( error as { response?: { data: unknown } } ).response?.data || error ),\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t};\n\t\t\t}\n\t\t};\n\t\tconst annotations: Record< string, unknown > = {\n\t\t\tdestructiveHint: opts.isDestructive,\n\t\t\treadOnlyHint: opts.isDestructive ? false : undefined,\n\t\t\ttitle: opts.name,\n\t\t};\n\t\tconst mergedResources = mergeRequiredResources( opts.requiredResources, serverDocsUri );\n\t\tconst angieAnnotations = {\n\t\t\t[ ANGIE_MODEL_PREFERENCES ]: opts.modelPreferences ?? createDefaultModelPreferences(),\n\t\t\t[ ANGIE_REQUIRED_RESOURCES ]: mergedResources,\n\t\t};\n\t\tserver.registerTool(\n\t\t\topts.name,\n\t\t\t{\n\t\t\t\tdescription: opts.description,\n\t\t\t\tinputSchema,\n\t\t\t\t// TODO: Uncomment this when the outputSchema is stable\n\t\t\t\t// outputSchema,\n\t\t\t\ttitle: opts.name,\n\t\t\t\tannotations,\n\t\t\t\t_meta: angieAnnotations,\n\t\t\t},\n\t\t\ttoolCallback\n\t\t);\n\t\tconst toolDescriptor = {\n\t\t\tname: opts.name,\n\t\t\tdescription: opts.description,\n\t\t\tinputSchema: inputSchema as object,\n\t\t\texecute: ( params: Record< string, unknown > ) =>\n\t\t\t\ttoolCallback(\n\t\t\t\t\tparams as Parameters< typeof toolCallback >[ 0 ],\n\t\t\t\t\t/* WebMCP: no protocol session — handlers must not rely on `extra` here */\n\t\t\t\t\t{} as RequestHandlerExtra< ServerRequest, ServerNotification >\n\t\t\t\t) as Promise< unknown >,\n\t\t};\n\t\tconst extraData = {\n\t\t\tresources: [ `Server resource name: ${ serverName }, Required to fetch!` ],\n\t\t\trequiredResources: mergedResources?.map( ( resource ) => resource.uri ) ?? [],\n\t\t};\n\t\tbufferedTools.push( [ toolDescriptor, extraData ] );\n\t\tcallAdapters( ( adapter ) => adapter.onToolRegistered( toolDescriptor, extraData ) );\n\t\tif ( isMcpRegistrationActivated ) {\n\t\t\tserver.sendToolListChanged();\n\t\t}\n\t}\n\treturn {\n\t\taddTool,\n\t};\n}\n","import { zodToJsonSchema } from 'zod-to-json-schema';\nimport { z, type z3 } from '@elementor/schema';\n\nimport { type ModelContextRegisterTool, registerModelContextTool } from '../utils/register-model-context-tool';\nimport {\n\ttype IMcpRegistrationAdapter,\n\ttype McpResourceHandler,\n\ttype McpResourceUriOrTemplate,\n\ttype McpToolDescriptor,\n\ttype UriTemplate,\n} from './types';\n\ntype ZodRawShape = z3.ZodRawShape;\n\nexport type ModelContext = {\n\tregisterTool: ModelContextRegisterTool;\n\tunregisterTool?: ( name: string ) => void;\n};\n\ntype ResourceEntry = {\n\tpattern: string;\n\tmatch: ( uri: string ) => Record< string, string | string[] > | null;\n\thandler: McpResourceHandler;\n};\n\nexport class WebMCPAdapter implements IMcpRegistrationAdapter {\n\tprivate readonly registeredToolNames = new Set< string >();\n\tprivate readonly resourceEntries: ResourceEntry[] = [];\n\tprivate activated = false;\n\n\tconstructor( private readonly ctx: ModelContext ) {}\n\n\tactivate(): Promise< void > {\n\t\tif ( this.activated ) {\n\t\t\treturn Promise.resolve();\n\t\t}\n\t\tthis.activated = true;\n\t\treturn registerModelContextTool( this.ctx.registerTool, {\n\t\t\tname: 'editor-resource-getter',\n\t\t\tdescription:\n\t\t\t\t'Get an editor resource by URI, or search for available resources by partial URI. Pass a full URI to retrieve content, or a partial string to discover matching patterns.',\n\t\t\tinputSchema: {\n\t\t\t\ttype: 'object',\n\t\t\t\tproperties: {\n\t\t\t\t\turi: {\n\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t'A full resource URI (e.g. elementor://style/best-practices) or a partial string to search across available resource patterns.',\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\trequired: [ 'uri' ],\n\t\t\t},\n\t\t\texecute: async ( params ) => {\n\t\t\t\tconst query = params.uri as string;\n\t\t\t\tconst entries = this.resourceEntries;\n\n\t\t\t\tif ( entries.length === 0 ) {\n\t\t\t\t\treturn 'No resources are registered yet.';\n\t\t\t\t}\n\n\t\t\t\t// Exact URI match\n\t\t\t\tfor ( const entry of entries ) {\n\t\t\t\t\tconst variables = entry.match( query );\n\t\t\t\t\tif ( variables !== null ) {\n\t\t\t\t\t\tlet resourceUrl: URL;\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tresourceUrl = new URL( query );\n\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\treturn `Invalid URI '${ query }'. Provide a valid resource URI or a partial string to search patterns.`;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst result = await entry.handler( resourceUrl, variables );\n\t\t\t\t\t\treturn result.contents?.[ 0 ]?.text ?? JSON.stringify( result );\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Partial search fallback\n\t\t\t\tconst matches = entries.map( ( e ) => e.pattern ).filter( ( pattern ) => pattern.includes( query ) );\n\t\t\t\tif ( matches.length > 0 ) {\n\t\t\t\t\treturn `Found ${ matches.length } matching resource pattern(s):\\n${ matches.join(\n\t\t\t\t\t\t'\\n'\n\t\t\t\t\t) }\\n\\nProvide a full URI to retrieve the resource content.`;\n\t\t\t\t}\n\n\t\t\t\tconst available = entries.map( ( e ) => e.pattern ).join( '\\n' );\n\t\t\t\tthrow new Error( `No resource matched '${ query }'.\\n\\nAvailable patterns:\\n${ available }` );\n\t\t\t},\n\t\t} );\n\t}\n\n\tonToolRegistered(\n\t\ttool: McpToolDescriptor,\n\t\textraData?: { resources: string[]; requiredResources: string[] }\n\t): void {\n\t\tlet jsonSchema: object;\n\t\ttry {\n\t\t\tjsonSchema = zodToJsonSchema( z.object( tool.inputSchema as ZodRawShape ) );\n\t\t} catch {\n\t\t\tjsonSchema = tool.inputSchema;\n\t\t}\n\n\t\tif ( this.registeredToolNames.has( tool.name ) ) {\n\t\t\tthis.ctx.unregisterTool?.( tool.name );\n\t\t\tthis.registeredToolNames.delete( tool.name );\n\t\t}\n\n\t\tlet resourcesDescription = '';\n\t\tif ( extraData ) {\n\t\t\tif ( extraData.resources?.length > 0 ) {\n\t\t\t\tresourcesDescription += `#Resources:\\n${ extraData.resources?.join( '\\n' ) }\\n\\n`;\n\t\t\t}\n\t\t\tif ( extraData.requiredResources?.length > 0 ) {\n\t\t\t\tresourcesDescription += `#Required Resources:\\n${ extraData.requiredResources?.join( '\\n' ) }\\n\\n`;\n\t\t\t}\n\t\t\tresourcesDescription += `To read resources, use editor-resource-getter tool.\\n\\n`;\n\t\t}\n\t\tvoid registerModelContextTool( this.ctx.registerTool, {\n\t\t\tname: tool.name,\n\t\t\tdescription: `${ resourcesDescription }${ tool.description }`,\n\t\t\tinputSchema: jsonSchema,\n\t\t\texecute: tool.execute,\n\t\t} ).then( () => {\n\t\t\tthis.registeredToolNames.add( tool.name );\n\t\t} );\n\t}\n\n\tonResourceRegistered( _name: string, uriOrTemplate: McpResourceUriOrTemplate, handler: McpResourceHandler ): void {\n\t\tif ( typeof uriOrTemplate === 'string' ) {\n\t\t\tthis.resourceEntries.push( {\n\t\t\t\tpattern: uriOrTemplate,\n\t\t\t\tmatch: ( uri ) => ( uri === uriOrTemplate ? {} : null ),\n\t\t\t\thandler,\n\t\t\t} );\n\t\t} else {\n\t\t\tconst template = uriOrTemplate.uriTemplate as UriTemplate;\n\t\t\tthis.resourceEntries.push( {\n\t\t\t\tpattern: template.toString(),\n\t\t\t\tmatch: ( uri ) => template.match( uri ),\n\t\t\t\thandler,\n\t\t\t} );\n\t\t}\n\t}\n\n\tsendResourceUpdated(): void {\n\t\t// WebMCP has no server-push mechanism — no-op\n\t}\n}\n","import { type McpToolDescriptor } from '../adapters/types';\n\nexport type ModelContextRegisterTool = ( tool: McpToolDescriptor ) => void | Promise< void >;\n\nexport async function registerModelContextTool(\n\tregisterTool: ModelContextRegisterTool,\n\ttool: McpToolDescriptor\n): Promise< void > {\n\ttry {\n\t\tawait Promise.resolve( registerTool( tool ) );\n\t} catch ( error ) {\n\t\t/* eslint-disable-next-line no-console */\n\t\tconsole.error( 'Tool registration failed:', error );\n\t}\n}\n","export const ANGIE_MODEL_PREFERENCES = 'angie/modelPreferences' as const;\nexport const ANGIE_REQUIRED_RESOURCES = 'angie/requiredResources' as const;\n\nexport interface AngieModelPreferences {\n\thints?: Array< { name: string } >;\n\tcostPriority?: number; // 0-1 (future use)\n\tspeedPriority?: number; // 0-1 (future use)\n\tintelligencePriority?: number; // 0-1 (future use)\n}\n\nexport function createDefaultModelPreferences(): AngieModelPreferences {\n\treturn {\n\t\thints: [ { name: 'claude-sonnet-4-6' } ],\n\t};\n}\n","import { type McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\n\nimport { type MCPRegistryEntry } from '../mcp-registry';\n\nconst mock = new Proxy(\n\t{},\n\t{\n\t\tget: () => {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unused-vars\n\t\t\tfunction mockedFn( ..._: unknown[] ) {}\n\t\t\treturn mockedFn;\n\t\t},\n\t}\n);\n\nexport const mockMcpRegistry = (): MCPRegistryEntry => {\n\treturn {\n\t\t// @ts-ignore\n\t\tresource: async () => {},\n\t\t// @ts-ignore\n\t\tsendResourceUpdated: () => {},\n\t\taddTool: () => {},\n\t\tsetMCPDescription: () => {},\n\t\tmcpServer: mock as McpServer,\n\t};\n};\n","import { type ModelContext } from '../adapters/web-mcp-adapter';\n\ntype ModelContextHost = {\n\tmodelContext?: ModelContext;\n};\n\nfunction bindModelContextMethods( host: ModelContext ): ModelContext {\n\treturn {\n\t\tregisterTool: host.registerTool.bind( host ),\n\t\tunregisterTool: host.unregisterTool ? host.unregisterTool.bind( host ) : undefined,\n\t};\n}\n\nexport function getModelContext(): ModelContext | undefined {\n\tconst documentModelContext =\n\t\ttypeof document !== 'undefined' ? ( document as unknown as ModelContextHost ).modelContext : undefined;\n\tif ( documentModelContext?.registerTool ) {\n\t\treturn bindModelContextMethods( documentModelContext );\n\t}\n\tconst navigatorModelContext =\n\t\ttypeof navigator !== 'undefined' ? ( navigator as unknown as ModelContextHost ).modelContext : undefined;\n\tif ( navigatorModelContext?.registerTool ) {\n\t\treturn bindModelContextMethods( navigatorModelContext );\n\t}\n\n\treturn undefined;\n}\n","export type ResourceList = {\n\turi: string;\n\tdescription: string;\n}[];\n\nexport const mergeRequiredResources = (\n\ttoolResources: ResourceList | undefined,\n\tserverDocsUri: string | undefined\n): ResourceList | undefined => {\n\tif ( ! serverDocsUri ) {\n\t\treturn toolResources;\n\t}\n\tif ( toolResources?.some( ( r ) => r.uri === serverDocsUri ) ) {\n\t\treturn toolResources;\n\t}\n\treturn [ ...( toolResources ?? [] ), { uri: serverDocsUri, description: 'Server docs' } ];\n};\n","export const createSimpleResourceHandler = ( text: string ) => async ( uri: URL ) => ( {\n\tcontents: [ { uri: uri.href, mimeType: 'text/plain', text } ],\n} );\n","import { type McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\n\nimport { type IMcpRegistrationAdapter } from '../adapters/types';\nimport { createSimpleResourceHandler } from './create-simple-resource-handler';\n\ntype OnResourceRegistered = ( ...args: Parameters< IMcpRegistrationAdapter[ 'onResourceRegistered' ] > ) => void;\n\nexport const registerServerDocsResource = (\n\tserver: McpServer,\n\tnamespace: string,\n\ttitle: string,\n\tdocs: string,\n\tonRegistered: OnResourceRegistered\n): void => {\n\tconst uri = `elementor://${ namespace }/server-docs`;\n\tconst name = `${ namespace }-server-docs`;\n\tconst handler = createSimpleResourceHandler( docs );\n\tserver.registerResource(\n\t\tname,\n\t\turi,\n\t\t{\n\t\t\ttitle: `${ title } server docs`,\n\t\t\tdescription: 'Full MCP documentation (lazy-loaded)',\n\t\t\tmimeType: 'text/plain',\n\t\t},\n\t\thandler\n\t);\n\tonRegistered( name, uri, handler );\n};\n","export const toMCPTitle = ( namespace: string ): string => {\n\tconst label = namespace\n\t\t.split( '_' )\n\t\t.filter( Boolean )\n\t\t.map( ( word ) => word.charAt( 0 ).toUpperCase() + word.slice( 1 ) )\n\t\t.join( ' ' );\n\n\treturn `Editor ${ label }`;\n};\n","import { type AngieMcpSdk } from '@elementor/editor-angie-sdk';\n\nimport { type getRegisteredMcpServers as _getRegisteredMcpServers } from '../mcp-registry';\nimport { toMCPTitle } from '../utils/to-mcp-title';\nimport { type IMcpRegistrationAdapter } from './types';\n\nconst MAX_RETRIES = 3;\n\nexport class AngieMcpAdapter implements IMcpRegistrationAdapter {\n\tconstructor(\n\t\tprivate readonly sdk: AngieMcpSdk,\n\t\tprivate readonly getRegisteredMcpServers: typeof _getRegisteredMcpServers\n\t) {}\n\n\tasync activate(): Promise< void > {\n\t\t// No waitForReady() here: registerLocalServer queues the server and the SDK flushes\n\t\t// the queue once Angie reports ready.\n\t\tawait this.registerEntries( this.getRegisteredMcpServers(), MAX_RETRIES );\n\t}\n\n\tprivate async registerEntries(\n\t\tentries: ReturnType< typeof _getRegisteredMcpServers >,\n\t\tretry: number\n\t): Promise< void > {\n\t\tif ( retry === 0 ) {\n\t\t\t/* eslint-disable-next-line no-console */\n\t\t\tconsole.error(\n\t\t\t\t'Failed to register MCP after 3 retries. failed entries: ',\n\t\t\t\tentries.map( ( [ key ] ) => key )\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tconst failed: typeof entries = [];\n\t\tfor ( const [ key, mcpServer, description ] of entries ) {\n\t\t\ttry {\n\t\t\t\tawait this.sdk.registerLocalServer( {\n\t\t\t\t\ttitle: toMCPTitle( key ),\n\t\t\t\t\tname: `editor-${ key }`,\n\t\t\t\t\tserver: mcpServer,\n\t\t\t\t\tversion: '1.0.0',\n\t\t\t\t\tdescription,\n\t\t\t\t} );\n\t\t\t} catch {\n\t\t\t\tfailed.push( [ key, mcpServer, description ] );\n\t\t\t}\n\t\t}\n\n\t\tif ( failed.length > 0 ) {\n\t\t\treturn this.registerEntries( failed, retry - 1 );\n\t\t}\n\t}\n\n\tonToolRegistered(): void {\n\t\t// Angie tools are registered via McpServer (at activate time).\n\t}\n\n\tonResourceRegistered(): void {\n\t\t// Resources are registered on the McpServer instance directly.\n\t}\n\n\tsendResourceUpdated(): void {\n\t\t// Resource update notifications are sent via MCPRegistryEntry.sendResourceUpdated.\n\t}\n}\n","import { type z } from '@elementor/schema';\nimport { type RequestHandlerExtra } from '@modelcontextprotocol/sdk/shared/protocol.js';\nimport { SamplingMessageSchema, type ServerNotification, type ServerRequest } from '@modelcontextprotocol/sdk/types.js';\n\ntype Server = RequestHandlerExtra< ServerRequest, ServerNotification >;\ntype Opts = {\n\tmaxTokens?: number;\n\tmodelPreferences?: string;\n\tmodel?: string;\n};\n\nconst DEFAULT_OPTS: Opts = {\n\tmaxTokens: 10000,\n\tmodelPreferences: 'openai',\n\tmodel: 'gpt-4o',\n};\n\ntype SamplingOpts = {\n\tsystemPrompt?: string;\n\tstructuredOutput?: z.ZodTypeAny;\n\tmessages: { role: 'user' | 'assistant'; content: { type: 'text'; text: string } }[];\n\trequestParams?: { [ key: string ]: string };\n};\n\nconst DEFAULT_STRUCTURED_OUTPUT = {\n\ttype: 'object',\n\tproperties: {\n\t\tcontent: {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Result',\n\t\t},\n\t},\n\trequired: [ 'content' ],\n\tadditionalProperties: false,\n};\n\nexport const createSampler = ( server: Server, opts: Opts = DEFAULT_OPTS ) => {\n\tconst { maxTokens = 1000, modelPreferences = 'openai', model = 'gpt-4o' } = opts;\n\tconst exec = async ( payload: SamplingOpts ) => {\n\t\tconst systemPromptObject = { ...( payload.systemPrompt ? { systemPrompt: payload.systemPrompt } : {} ) };\n\t\tconst requestParams = payload.requestParams || {};\n\t\tconst result = await server.sendRequest(\n\t\t\t{\n\t\t\t\tmethod: 'sampling/createMessage',\n\t\t\t\tparams: {\n\t\t\t\t\t...requestParams,\n\t\t\t\t\tmaxTokens,\n\t\t\t\t\tmodelPreferences: {\n\t\t\t\t\t\thints: [ { name: modelPreferences } ],\n\t\t\t\t\t},\n\t\t\t\t\tmetadata: {\n\t\t\t\t\t\tmodel,\n\t\t\t\t\t\t...systemPromptObject,\n\t\t\t\t\t\t...{ structured_output: payload.structuredOutput || DEFAULT_STRUCTURED_OUTPUT },\n\t\t\t\t\t},\n\t\t\t\t\tmessages: payload.messages,\n\t\t\t\t},\n\t\t\t\t// ...systemPromptObject,\n\t\t\t},\n\t\t\tSamplingMessageSchema\n\t\t);\n\t\treturn result.content;\n\t};\n\treturn exec;\n};\n","class ToolPrompts {\n\tpublic _description = '';\n\tpublic _parameters: Record< string, string > = {};\n\tpublic _examples: string[] = [];\n\tpublic _furtherInstructions: string[] = [];\n\n\tconstructor( public name: string ) {}\n\n\tdescription(): string;\n\tdescription( desc: string ): this;\n\tdescription( desc?: string | undefined ) {\n\t\tif ( typeof desc === 'undefined' ) {\n\t\t\treturn this._description;\n\t\t}\n\t\tthis._description = desc;\n\t\treturn this;\n\t}\n\n\tparameter( key: string ): string;\n\tparameter( key: string, description: string ): this;\n\tparameter( key: string, description?: string ) {\n\t\tif ( typeof description === 'undefined' ) {\n\t\t\treturn this._parameters[ key ];\n\t\t}\n\t\tthis._parameters[ key ] = `**${ key }**:\\n${ description }`;\n\t\treturn this;\n\t}\n\n\tinstruction( instruction: string ): this {\n\t\tthis._furtherInstructions.push( instruction );\n\t\treturn this;\n\t}\n\n\texample( example: string ): this {\n\t\tthis._examples.push( example );\n\t\treturn this;\n\t}\n\n\tpublic get examples() {\n\t\treturn this._examples.join( '\\n\\n' );\n\t}\n\n\tprompt(): string {\n\t\treturn `# ${ this.name }\n# Description\n${ this._description }\n${ this._parameters.length ? '# Parameters\\n' + Object.values( this._parameters ).join( '\\n\\n' ) : '' }\n${ this._examples.length ? '# Examples\\n' + this.examples : '' }\n${ this._furtherInstructions.length ? '# Further Instructions\\n' + this._furtherInstructions.join( '\\n\\n' ) : '' }\n`.trim();\n\t}\n}\n\nexport const toolPrompts = ( name: string ) => {\n\treturn new ToolPrompts( name );\n};\n","export type ActiveChatInfo = {\n\tsessionId: string;\n\texpiresAt: number;\n};\n\nexport const getActiveChatInfo = (): ActiveChatInfo => {\n\tconst info = localStorage.getItem( 'angie_active_chat_id' );\n\tif ( ! info ) {\n\t\treturn {\n\t\t\texpiresAt: 0,\n\t\t\tsessionId: '',\n\t\t};\n\t}\n\tconst rawData = JSON.parse( info );\n\treturn {\n\t\texpiresAt: rawData.expiresAt as number,\n\t\tsessionId: rawData.sessionId as string,\n\t};\n};\n","import {\n\tAngieInteractionMode,\n\tgetAngieIframe,\n\tsetAngieInteractionMode,\n\ttoggleAngieSidebar,\n} from '@elementor/editor-angie-sdk';\n\nimport { isAngieAvailable } from './is-angie-available';\n\nconst getLoadedEditorAngie = () => {\n\treturn window.elementorV2?.editorAngie?.openAngie;\n};\n\nexport const hasLoadedEditorAngie = (): boolean => Boolean( getLoadedEditorAngie() );\n\nexport const openLoadedEditorAngie = ( prompt: string | undefined, mode: AngieInteractionMode ): boolean => {\n\tconst openAngie = getLoadedEditorAngie();\n\n\tif ( ! openAngie ) {\n\t\treturn false;\n\t}\n\n\tPromise.resolve( openAngie( { prompt: prompt ?? '', mode } ) ).catch( ( error ) => {\n\t\t// eslint-disable-next-line no-console\n\t\tconsole.error( 'Failed to open Angie:', error );\n\t} );\n\n\treturn true;\n};\n\nexport const openAngieInAskMode = ( prompt?: string ): void => {\n\topenAngieInMode( prompt, AngieInteractionMode.ASK );\n};\n\nexport const openAngieInAgentMode = ( prompt?: string ): void => {\n\topenAngieInMode( prompt, AngieInteractionMode.AGENT );\n};\n\nconst openAngieInMode = ( prompt: string | undefined, mode: AngieInteractionMode ): void => {\n\tif ( openLoadedEditorAngie( prompt, mode ) ) {\n\t\treturn;\n\t}\n\n\tif ( ! isAngieAvailable() ) {\n\t\treturn;\n\t}\n\n\tconst angieSidebar = getAngieIframe();\n\n\tif ( ! angieSidebar ) {\n\t\treturn;\n\t}\n\n\ttoggleAngieSidebar( angieSidebar, true );\n\tsetAngieInteractionMode( mode );\n\n\tif ( prompt ) {\n\t\twindow.location.hash = `angie-prompt=${ encodeURIComponent( prompt ) }`;\n\t}\n};\n","import { AngieInteractionMode, getAngieIframe, toggleAngieSidebar } from '@elementor/editor-angie-sdk';\n\nimport { openLoadedEditorAngie } from './open-angie-in-ask-mode';\n\nexport const sendPromptToAngie = ( prompt?: string ) => {\n\tif ( openLoadedEditorAngie( prompt, AngieInteractionMode.AGENT ) ) {\n\t\treturn;\n\t}\n\n\tconst angieSidebar = getAngieIframe();\n\n\tif ( ! angieSidebar ) {\n\t\treturn;\n\t}\n\n\ttoggleAngieSidebar( angieSidebar, true );\n\n\tif ( ! prompt ) {\n\t\treturn;\n\t}\n\n\twindow.location.hash = `angie-prompt=${ encodeURIComponent( prompt ) }`;\n};\n","import { setReferrerRedirect } from '@elementor/editor-angie-sdk';\n\nconst ANGIE_INSTALL_URL = '/wp-admin/plugin-install.php?s=angie&tab=search&type=term';\n\n/**\n * @deprecated Kept only for Elementor Pro compatibility. Will be removed in a future version.\n * @param prompt Optional prompt to pass after redirect.\n */\nexport const redirectToInstallation = ( prompt?: string ) => {\n\tsetReferrerRedirect( window.location.href, prompt );\n\twindow.location.href = ANGIE_INSTALL_URL;\n};\n","import { ANGIE_SIDEBAR_STATE_OPEN, saveState, setReferrerRedirect } from '@elementor/editor-angie-sdk';\n\nconst ANGIE_APP_URL = '/wp-admin/admin.php?page=angie-app';\n\n/**\n * @deprecated Kept only for Elementor Pro compatibility. Will be removed in a future version.\n * @param prompt Optional prompt to pass after redirect.\n */\nexport const redirectToAppAdmin = ( prompt?: string ) => {\n\tsetReferrerRedirect( window.location.href, prompt );\n\tsaveState( ANGIE_SIDEBAR_STATE_OPEN );\n\twindow.location.href = ANGIE_APP_URL;\n};\n","import apiFetch from '@wordpress/api-fetch';\n\ntype PluginResponse = {\n\tplugin: string;\n\tstatus: 'active' | 'inactive';\n\tname: string;\n};\n\ntype PluginErrorResponse = {\n\tcode: string;\n\tmessage: string;\n};\n\nexport type InstallAngieResult = { success: true } | { success: false; error: string; code?: string };\n\nconst ANGIE_SLUG = 'angie';\n\nconst isPluginErrorResponse = ( response: unknown ): response is PluginErrorResponse => {\n\treturn typeof response === 'object' && response !== null && 'code' in response && 'message' in response;\n};\n\nconst activatePlugin = async ( pluginPath: string ): Promise< PluginResponse > => {\n\treturn apiFetch< PluginResponse >( {\n\t\tpath: `/wp/v2/plugins/${ pluginPath }`,\n\t\tmethod: 'POST',\n\t\tdata: { status: 'active' },\n\t} );\n};\n\nconst installPlugin = async (): Promise< PluginResponse > => {\n\ttry {\n\t\treturn await apiFetch< PluginResponse >( {\n\t\t\tpath: '/wp/v2/plugins',\n\t\t\tmethod: 'POST',\n\t\t\tdata: {\n\t\t\t\tslug: ANGIE_SLUG,\n\t\t\t\tstatus: 'active',\n\t\t\t},\n\t\t} );\n\t} catch ( error: unknown ) {\n\t\tif ( isPluginErrorResponse( error ) && error.code === 'folder_exists' ) {\n\t\t\treturn activatePlugin( `${ ANGIE_SLUG }/${ ANGIE_SLUG }` );\n\t\t}\n\n\t\tthrow error;\n\t}\n};\n\n/**\n * @deprecated Kept only for Elementor Pro compatibility. Will be removed in a future version.\n */\nexport const installAngiePlugin = async (): Promise< InstallAngieResult > => {\n\ttry {\n\t\tawait installPlugin();\n\n\t\treturn { success: true };\n\t} catch ( error: unknown ) {\n\t\tif ( isPluginErrorResponse( error ) ) {\n\t\t\treturn { success: false, error: error.message, code: error.code };\n\t\t}\n\n\t\treturn { success: false, error: 'Unknown error occurred' };\n\t}\n};\n","import apiFetch from '@wordpress/api-fetch';\n\nexport const saveAngieConsent = async (): Promise< void > => {\n\tawait apiFetch( {\n\t\tpath: '/elementor/v1/angie/consent',\n\t\tmethod: 'POST',\n\t} );\n};\n","import { createAndRegisterAdapters, signalMcpReady } from './mcp-registry';\n\nlet isInitialized = false;\nexport async function startMCPServer() {\n\tif ( isInitialized ) {\n\t\treturn;\n\t}\n\tisInitialized = true;\n\ttry {\n\t\tawait createAndRegisterAdapters();\n\t} catch ( error ) {\n\t\t/* eslint-disable-next-line no-console */\n\t\tconsole.error( 'MCP adapter activation failed:', error );\n\t} finally {\n\t\tsignalMcpReady();\n\t}\n}\n\n// Start right away when the bundle loads after DOMContentLoaded (late or deferred load): the event will\n// not fire again, and `waitForMcpReady()` callers would wait forever.\nif ( typeof document !== 'undefined' && document.readyState === 'loading' ) {\n\tdocument.addEventListener( 'DOMContentLoaded', () => void startMCPServer(), { once: true } );\n} else {\n\tvoid startMCPServer();\n}\n","export const MCP_STYLES_APPLIED_EVENT = 'elementor/mcp/styles-applied';\n\nexport type McpStylesAppliedPayload = {\n\tstyleValue: Record< string, unknown >;\n};\n\nexport function dispatchMcpStylesAppliedEvent( payload: McpStylesAppliedPayload ): void {\n\twindow.dispatchEvent( new CustomEvent( MCP_STYLES_APPLIED_EVENT, { detail: payload } ) );\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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,IAAAA,2BAAwF;AAExF,IAAAC,cAKO;AACP,IAAAC,gBAAsC;;;ACVtC,8BAA+B;AAExB,IAAM,mBAAmB,MAAe;AAC9C,SAAO,CAAC,KAAE,wCAAe;AAC1B;;;ACJO,IAAM,kBAAkB,MAAe;AAC7C,SAAO,QAAS,OAAO,WAAW,QAAQ,gBAAgB,eAAgB;AAC3E;;;ACFA,IAAAC,2BAAoE;AAE7D,IAAM,qBAAqB,MAAe;AAChD,aAAO,oDAA0B,MAAM;AACxC;;;ACJA,IAAAC,iBAA2B;AAC3B,iBAA6C;;;ACD7C,gCAAgC;AAChC,oBAA2B;;;ACG3B,eAAsB,yBACrB,cACA,MACkB;AAClB,MAAI;AACH,UAAM,QAAQ,QAAS,aAAc,IAAK,CAAE;AAAA,EAC7C,SAAU,OAAQ;AAEjB,YAAQ,MAAO,6BAA6B,KAAM;AAAA,EACnD;AACD;;;ADWO,IAAM,gBAAN,MAAuD;AAAA,EAK7D,YAA8B,KAAoB;AAApB;AAAA,EAAqB;AAAA,EAJlC,sBAAsB,oBAAI,IAAc;AAAA,EACxC,kBAAmC,CAAC;AAAA,EAC7C,YAAY;AAAA,EAIpB,WA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IACD,CAAE;AAAA,EACH,SAAU,OAAiB;AAC1B,QAAK,sBAAuB,KAAM,KAAK,MAAM,SAAS,iBAAkB;AACvE,aAAO,eAAgB,GAAI,UAAW,IAAK,UAAW,EAAG;AAAA,IAC1D;AAEA,UAAM;AAAA,EACP;AACD;AAKO,IAAM,qBAAqB,YAA2C;AAC5E,MAAI;AACH,UAAM,cAAc;AAEpB,WAAO,EAAE,SAAS,KAAK;AAAA,EACxB,SAAU,OAAiB;AAC1B,QAAK,sBAAuB,KAAM,GAAI;AACrC,aAAO,EAAE,SAAS,OAAO,OAAO,MAAM,SAAS,MAAM,MAAM,KAAK;AAAA,IACjE;AAEA,WAAO,EAAE,SAAS,OAAO,OAAO,yBAAyB;AAAA,EAC1D;AACD;;;AC/DA,IAAAC,oBAAqB;AAEd,IAAM,mBAAmB,YAA6B;AAC5D,YAAM,kBAAAC,SAAU;AAAA,IACf,MAAM;AAAA,IACN,QAAQ;AAAA,EACT,CAAE;AACH;;;ACLA,IAAI,gBAAgB;AACpB,eAAsB,iBAAiB;AACtC,MAAK,eAAgB;AACpB;AAAA,EACD;AACA,kBAAgB;AAChB,MAAI;AACH,UAAM,0BAA0B;AAAA,EACjC,SAAU,OAAQ;AAEjB,YAAQ,MAAO,kCAAkC,KAAM;AAAA,EACxD,UAAE;AACD,mBAAe;AAAA,EAChB;AACD;AAIA,IAAK,OAAO,aAAa,eAAe,SAAS,eAAe,WAAY;AAC3E,WAAS,iBAAkB,oBAAoB,MAAM,KAAK,eAAe,GAAG,EAAE,MAAM,KAAK,CAAE;AAC5F,OAAO;AACN,OAAK,eAAe;AACrB;;;ACxBO,IAAM,2BAA2B;AAMjC,SAAS,8BAA+B,SAAyC;AACvF,SAAO,cAAe,IAAI,YAAa,0BAA0B,EAAE,QAAQ,QAAQ,CAAE,CAAE;AACxF;","names":["import_editor_angie_sdk","import_mcp","import_types","import_editor_angie_sdk","import_schema","getRegisteredMcpServers","import_editor_angie_sdk","import_editor_angie_sdk","import_editor_angie_sdk","import_editor_angie_sdk","apiFetch","import_api_fetch","apiFetch"]}
|
package/dist/index.mjs
CHANGED
|
@@ -1,38 +1,5 @@
|
|
|
1
|
-
// src/utils/get-sdk.ts
|
|
2
|
-
import { AngieMcpSdk } from "@elementor-external/angie-sdk";
|
|
3
|
-
import { getAngieIframe, MessageEventType } from "@elementor-external/angie-sdk";
|
|
4
|
-
var sdk;
|
|
5
|
-
var RetriableAngieSDK = class extends AngieMcpSdk {
|
|
6
|
-
async waitForReady() {
|
|
7
|
-
let retryCount = 3;
|
|
8
|
-
while (retryCount > 0) {
|
|
9
|
-
try {
|
|
10
|
-
await super.waitForReady();
|
|
11
|
-
return;
|
|
12
|
-
} catch {
|
|
13
|
-
retryCount--;
|
|
14
|
-
await sleep();
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
return new Promise(() => {
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
var sleep = (ms = 1e4) => new Promise((resolve) => {
|
|
22
|
-
setTimeout(resolve, ms);
|
|
23
|
-
});
|
|
24
|
-
var getSDK = () => {
|
|
25
|
-
const isMCPDisabled = !!globalThis.__ELEMENTOR_MCP_DISABLED__;
|
|
26
|
-
if (isMCPDisabled) {
|
|
27
|
-
return {};
|
|
28
|
-
}
|
|
29
|
-
if (!sdk) {
|
|
30
|
-
sdk = new RetriableAngieSDK();
|
|
31
|
-
}
|
|
32
|
-
return sdk;
|
|
33
|
-
};
|
|
34
|
-
|
|
35
1
|
// src/index.ts
|
|
2
|
+
import { getAngieIframe as getAngieIframe4, getAngieSdk, MessageEventType } from "@elementor/editor-angie-sdk";
|
|
36
3
|
import {
|
|
37
4
|
McpServer as McpServer2,
|
|
38
5
|
ResourceTemplate
|
|
@@ -40,9 +7,9 @@ import {
|
|
|
40
7
|
import { SamplingMessageSchema as SamplingMessageSchema2 } from "@modelcontextprotocol/sdk/types.js";
|
|
41
8
|
|
|
42
9
|
// src/utils/is-angie-available.ts
|
|
43
|
-
import { getAngieIframe
|
|
10
|
+
import { getAngieIframe } from "@elementor/editor-angie-sdk";
|
|
44
11
|
var isAngieAvailable = () => {
|
|
45
|
-
return !!
|
|
12
|
+
return !!getAngieIframe();
|
|
46
13
|
};
|
|
47
14
|
|
|
48
15
|
// src/utils/can-create-widget.ts
|
|
@@ -51,7 +18,7 @@ var canCreateWidget = () => {
|
|
|
51
18
|
};
|
|
52
19
|
|
|
53
20
|
// src/utils/is-angie-sidebar-open.ts
|
|
54
|
-
import { ANGIE_SIDEBAR_STATE_OPEN, getAngieSidebarSavedState } from "@elementor-
|
|
21
|
+
import { ANGIE_SIDEBAR_STATE_OPEN, getAngieSidebarSavedState } from "@elementor/editor-angie-sdk";
|
|
55
22
|
var isAngieSidebarOpen = () => {
|
|
56
23
|
return getAngieSidebarSavedState() === ANGIE_SIDEBAR_STATE_OPEN;
|
|
57
24
|
};
|
|
@@ -496,8 +463,8 @@ function createToolRegistry(server, serverName, serverDocsUri) {
|
|
|
496
463
|
// src/adapters/angie-adapter.ts
|
|
497
464
|
var MAX_RETRIES = 3;
|
|
498
465
|
var AngieMcpAdapter = class {
|
|
499
|
-
constructor(
|
|
500
|
-
this.sdk =
|
|
466
|
+
constructor(sdk, getRegisteredMcpServers2) {
|
|
467
|
+
this.sdk = sdk;
|
|
501
468
|
this.getRegisteredMcpServers = getRegisteredMcpServers2;
|
|
502
469
|
}
|
|
503
470
|
async activate() {
|
|
@@ -653,10 +620,10 @@ var getActiveChatInfo = () => {
|
|
|
653
620
|
// src/utils/open-angie-in-ask-mode.ts
|
|
654
621
|
import {
|
|
655
622
|
AngieInteractionMode,
|
|
656
|
-
getAngieIframe as
|
|
623
|
+
getAngieIframe as getAngieIframe2,
|
|
657
624
|
setAngieInteractionMode,
|
|
658
625
|
toggleAngieSidebar
|
|
659
|
-
} from "@elementor-
|
|
626
|
+
} from "@elementor/editor-angie-sdk";
|
|
660
627
|
var getLoadedEditorAngie = () => {
|
|
661
628
|
return window.elementorV2?.editorAngie?.openAngie;
|
|
662
629
|
};
|
|
@@ -684,7 +651,7 @@ var openAngieInMode = (prompt, mode) => {
|
|
|
684
651
|
if (!isAngieAvailable()) {
|
|
685
652
|
return;
|
|
686
653
|
}
|
|
687
|
-
const angieSidebar =
|
|
654
|
+
const angieSidebar = getAngieIframe2();
|
|
688
655
|
if (!angieSidebar) {
|
|
689
656
|
return;
|
|
690
657
|
}
|
|
@@ -696,12 +663,12 @@ var openAngieInMode = (prompt, mode) => {
|
|
|
696
663
|
};
|
|
697
664
|
|
|
698
665
|
// src/utils/send-prompt-to-angie.ts
|
|
699
|
-
import { AngieInteractionMode as AngieInteractionMode2, getAngieIframe as
|
|
666
|
+
import { AngieInteractionMode as AngieInteractionMode2, getAngieIframe as getAngieIframe3, toggleAngieSidebar as toggleAngieSidebar2 } from "@elementor/editor-angie-sdk";
|
|
700
667
|
var sendPromptToAngie = (prompt) => {
|
|
701
668
|
if (openLoadedEditorAngie(prompt, AngieInteractionMode2.AGENT)) {
|
|
702
669
|
return;
|
|
703
670
|
}
|
|
704
|
-
const angieSidebar =
|
|
671
|
+
const angieSidebar = getAngieIframe3();
|
|
705
672
|
if (!angieSidebar) {
|
|
706
673
|
return;
|
|
707
674
|
}
|
|
@@ -713,7 +680,7 @@ var sendPromptToAngie = (prompt) => {
|
|
|
713
680
|
};
|
|
714
681
|
|
|
715
682
|
// src/utils/redirect-to-installation.ts
|
|
716
|
-
import { setReferrerRedirect } from "@elementor-
|
|
683
|
+
import { setReferrerRedirect } from "@elementor/editor-angie-sdk";
|
|
717
684
|
var ANGIE_INSTALL_URL = "/wp-admin/plugin-install.php?s=angie&tab=search&type=term";
|
|
718
685
|
var redirectToInstallation = (prompt) => {
|
|
719
686
|
setReferrerRedirect(window.location.href, prompt);
|
|
@@ -721,7 +688,7 @@ var redirectToInstallation = (prompt) => {
|
|
|
721
688
|
};
|
|
722
689
|
|
|
723
690
|
// src/utils/redirect-to-app-admin.ts
|
|
724
|
-
import { ANGIE_SIDEBAR_STATE_OPEN as ANGIE_SIDEBAR_STATE_OPEN2, saveState, setReferrerRedirect as setReferrerRedirect2 } from "@elementor-
|
|
691
|
+
import { ANGIE_SIDEBAR_STATE_OPEN as ANGIE_SIDEBAR_STATE_OPEN2, saveState, setReferrerRedirect as setReferrerRedirect2 } from "@elementor/editor-angie-sdk";
|
|
725
692
|
var ANGIE_APP_URL = "/wp-admin/admin.php?page=angie-app";
|
|
726
693
|
var redirectToAppAdmin = (prompt) => {
|
|
727
694
|
setReferrerRedirect2(window.location.href, prompt);
|
|
@@ -806,9 +773,6 @@ var MCP_STYLES_APPLIED_EVENT = "elementor/mcp/styles-applied";
|
|
|
806
773
|
function dispatchMcpStylesAppliedEvent(payload) {
|
|
807
774
|
window.dispatchEvent(new CustomEvent(MCP_STYLES_APPLIED_EVENT, { detail: payload }));
|
|
808
775
|
}
|
|
809
|
-
|
|
810
|
-
// src/index.ts
|
|
811
|
-
var getAngieSdk = () => getSDK();
|
|
812
776
|
export {
|
|
813
777
|
ANGIE_MODEL_PREFERENCES,
|
|
814
778
|
ANGIE_REQUIRED_RESOURCES,
|
|
@@ -824,7 +788,7 @@ export {
|
|
|
824
788
|
createSampler,
|
|
825
789
|
dispatchMcpStylesAppliedEvent,
|
|
826
790
|
getActiveChatInfo,
|
|
827
|
-
getAngieIframe,
|
|
791
|
+
getAngieIframe4 as getAngieIframe,
|
|
828
792
|
getAngieSdk,
|
|
829
793
|
getMCPByDomain,
|
|
830
794
|
getRegisteredMcpServers,
|
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/can-create-widget.ts","../src/utils/is-angie-sidebar-open.ts","../src/mcp-registry.ts","../src/adapters/web-mcp-adapter.ts","../src/utils/register-model-context-tool.ts","../src/angie-annotations.ts","../src/test-utils/mock-mcp-registry.ts","../src/utils/get-model-context.ts","../src/utils/merge-required-resources.ts","../src/utils/create-simple-resource-handler.ts","../src/utils/register-server-docs-resource.ts","../src/utils/to-mcp-title.ts","../src/adapters/angie-adapter.ts","../src/sampler.ts","../src/utils/prompt-builder.ts","../src/utils/get-active-chat-info.ts","../src/utils/open-angie-in-ask-mode.ts","../src/utils/send-prompt-to-angie.ts","../src/utils/redirect-to-installation.ts","../src/utils/redirect-to-app-admin.ts","../src/utils/install-angie-plugin.ts","../src/utils/save-angie-consent.ts","../src/init.ts","../src/events/mcp-styles-applied-event.ts"],"sourcesContent":["import { AngieMcpSdk } from '@elementor-external/angie-sdk';\nexport { getAngieIframe, MessageEventType } from '@elementor-external/angie-sdk';\n\nlet sdk: AngieMcpSdk;\n\nclass RetriableAngieSDK extends AngieMcpSdk {\n\tpublic async waitForReady(): Promise< void > {\n\t\tlet retryCount = 3;\n\t\twhile ( retryCount > 0 ) {\n\t\t\ttry {\n\t\t\t\tawait super.waitForReady();\n\t\t\t\treturn;\n\t\t\t} catch {\n\t\t\t\tretryCount--;\n\t\t\t\tawait sleep();\n\t\t\t}\n\t\t}\n\t\treturn new Promise( () => {} ); // never resolves\n\t}\n}\n\nconst sleep = ( ms = 10_000 ) =>\n\tnew Promise( ( resolve ) => {\n\t\tsetTimeout( resolve, ms );\n\t} );\n\nexport const getSDK = () => {\n\t// @ts-ignore - QUnit fails this\n\tconst isMCPDisabled = !! ( globalThis as Record< string, unknown > ).__ELEMENTOR_MCP_DISABLED__;\n\tif ( isMCPDisabled ) {\n\t\treturn {} as unknown as AngieMcpSdk;\n\t}\n\tif ( ! sdk ) {\n\t\tsdk = new RetriableAngieSDK();\n\t}\n\treturn sdk;\n};\n","import './types/open-angie-request';\n\nimport { getSDK } from './utils/get-sdk';\nexport { getAngieIframe, MessageEventType as AngieMessageEvenetType } from './utils/get-sdk';\n\nexport {\n\tMcpServer,\n\tResourceTemplate,\n\ttype RegisteredResource,\n\ttype ToolCallback,\n} from '@modelcontextprotocol/sdk/server/mcp.js';\nexport { SamplingMessageSchema } from '@modelcontextprotocol/sdk/types.js';\nexport { isAngieAvailable } from './utils/is-angie-available';\nexport { canCreateWidget } from './utils/can-create-widget';\nexport { isAngieSidebarOpen } from './utils/is-angie-sidebar-open';\nexport * from './mcp-registry';\nexport { AngieMcpAdapter } from './adapters/angie-adapter';\nexport type { IMcpRegistrationAdapter } from './adapters/types';\nexport { createSampler } from './sampler';\nexport { toolPrompts } from './utils/prompt-builder';\nexport { ANGIE_MODEL_PREFERENCES, ANGIE_REQUIRED_RESOURCES, type AngieModelPreferences } from './angie-annotations';\nexport { getActiveChatInfo, type ActiveChatInfo } from './utils/get-active-chat-info';\nexport { hasLoadedEditorAngie, openAngieInAgentMode, openAngieInAskMode } from './utils/open-angie-in-ask-mode';\nexport type {\n\tEditorAngieWindowHost,\n\tOpenAngieCommonProperties,\n\tOpenAngiePluginProperties,\n\tOpenAngieRequest,\n\tOpenAngieSdkProperties,\n} from './types/open-angie-request';\nexport { sendPromptToAngie } from './utils/send-prompt-to-angie';\nexport { redirectToInstallation } from './utils/redirect-to-installation';\nexport { redirectToAppAdmin } from './utils/redirect-to-app-admin';\nexport { installAngiePlugin, type InstallAngieResult } from './utils/install-angie-plugin';\nexport { saveAngieConsent } from './utils/save-angie-consent';\nexport const getAngieSdk = () => getSDK();\nexport * from './init';\nexport {\n\tdispatchMcpStylesAppliedEvent,\n\tMCP_STYLES_APPLIED_EVENT,\n\ttype McpStylesAppliedPayload,\n} from './events/mcp-styles-applied-event';\n","import { getAngieIframe } from '@elementor-external/angie-sdk';\n\nexport const isAngieAvailable = (): boolean => {\n\treturn !! getAngieIframe();\n};\n","export const canCreateWidget = (): boolean => {\n\treturn Boolean( window.elementor?.config?.widgetCreation?.canCreateWidget );\n};\n","import { ANGIE_SIDEBAR_STATE_OPEN, getAngieSidebarSavedState } from '@elementor-external/angie-sdk';\n\nexport const isAngieSidebarOpen = (): boolean => {\n\treturn getAngieSidebarSavedState() === ANGIE_SIDEBAR_STATE_OPEN;\n};\n","import { z, type z3 } from '@elementor/schema';\nimport { McpServer, type ToolCallback } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { type RequestHandlerExtra } from '@modelcontextprotocol/sdk/shared/protocol.js';\nimport { type ServerNotification, type ServerRequest } from '@modelcontextprotocol/sdk/types.js';\n\nimport { type IMcpRegistrationAdapter, type McpResourceHandler, type McpResourceUriOrTemplate } from './adapters/types';\nimport { WebMCPAdapter } from './adapters/web-mcp-adapter';\nimport {\n\tANGIE_MODEL_PREFERENCES,\n\tANGIE_REQUIRED_RESOURCES,\n\ttype AngieModelPreferences,\n\tcreateDefaultModelPreferences,\n} from './angie-annotations';\nimport { mockMcpRegistry } from './test-utils/mock-mcp-registry';\nimport { getModelContext } from './utils/get-model-context';\nimport { mergeRequiredResources, type ResourceList } from './utils/merge-required-resources';\nimport { registerServerDocsResource } from './utils/register-server-docs-resource';\nimport { toMCPTitle } from './utils/to-mcp-title';\n\ntype ZodRawShape = z3.ZodRawShape;\n\nconst mcpRegistry: { [ namespace: string ]: McpServer } = {};\nconst mcpDescriptions: { [ namespace: string ]: string } = {};\n// @ts-ignore - QUnit fails this\nconst isMcpRegistrationActivated = false || typeof globalThis.jest !== 'undefined';\n\nconst registrationAdapters: IMcpRegistrationAdapter[] = [];\nconst bufferedTools: Parameters< IMcpRegistrationAdapter[ 'onToolRegistered' ] >[] = [];\nconst bufferedResources: Parameters< IMcpRegistrationAdapter[ 'onResourceRegistered' ] >[] = [];\n\nlet resolveReady!: () => void;\nconst readyPromise = new Promise< void >( ( resolve ) => {\n\tresolveReady = resolve;\n} );\n\nexport const registerMcpAdapter = ( adapter: IMcpRegistrationAdapter ): void => {\n\tregistrationAdapters.push( adapter );\n\tfor ( const tool of bufferedTools ) {\n\t\ttry {\n\t\t\tadapter.onToolRegistered( tool[ 0 ], tool[ 1 ] );\n\t\t} catch {\n\t\t\t// exit quietly\n\t\t}\n\t}\n\tfor ( const resource of bufferedResources ) {\n\t\ttry {\n\t\t\tadapter.onResourceRegistered( ...resource );\n\t\t} catch {\n\t\t\t// exit quietly\n\t\t}\n\t}\n};\n\nexport const signalMcpReady = (): void => {\n\tresolveReady();\n};\n\nexport const waitForMcpReady = (): Promise< void > => readyPromise;\n\n/**\n * Registers and activates an adapter that becomes available after startup.\n * Waits for the startup activation so the adapter is activated exactly once.\n *\n * @param adapter - Adapter to register and activate.\n */\nexport const activateMcpAdapter = async ( adapter: IMcpRegistrationAdapter ): Promise< void > => {\n\tawait readyPromise;\n\tregisterMcpAdapter( adapter );\n\tawait adapter.activate();\n};\n\nexport const createAndRegisterAdapters = async (): Promise< void > => {\n\tconst modelContext = getModelContext();\n\n\tif ( modelContext ) {\n\t\tregisterMcpAdapter( new WebMCPAdapter( modelContext ) );\n\t}\n\n\tawait Promise.all( registrationAdapters.map( ( adapter ) => adapter.activate() ) );\n};\n\n// utility function to run a callback on all MCP interfaces\nfunction callAdapters( fn: ( adapter: IMcpRegistrationAdapter ) => unknown ) {\n\tfor ( const adapter of registrationAdapters ) {\n\t\ttry {\n\t\t\tfn( adapter );\n\t\t} catch {\n\t\t\t// adapter failed — exit quietly, continue to next\n\t\t}\n\t}\n}\n\nexport const registerMcp = ( mcp: McpServer, name: string ) => {\n\tconst mcpName = isAlphabet( name );\n\tmcpRegistry[ mcpName ] = mcp;\n};\n\nexport const getRegisteredMcpServers = (): Array< [ string, McpServer, string ] > => {\n\treturn Object.entries( mcpRegistry ).map( ( [ key, server ] ) => [ key, server, mcpDescriptions[ key ] || key ] );\n};\n\nconst isAlphabet = ( str: string ): string | never => {\n\tconst passes = !! str && /^[a-z_]+$/.test( str );\n\tif ( ! passes ) {\n\t\tthrow new Error( 'Not alphabet' );\n\t}\n\treturn str;\n};\n\n/**\n * @param namespace The namespace of the MCP server. It should contain only lowercase alphabetic characters.\n * @param options\n * @param options.instructions Short hint about the MCP and its toolset (MCP SDK `instructions`; keeps payload small).\n * @param options.docs Full documentation registered as a lazy-loaded resource.\n * When provided, it is registered at elementor://{namespace}/server-docs\n * and auto-injected into every tool's requiredResources.\n */\nexport const getMCPByDomain = (\n\tnamespace: string,\n\toptions?: { docs?: string; instructions?: string }\n): MCPRegistryEntry => {\n\tconst mcpName = `editor-${ isAlphabet( namespace ) }`;\n\tconst title = toMCPTitle( namespace );\n\t// @ts-ignore - QUnit fails this\n\tif ( typeof globalThis.jest !== 'undefined' ) {\n\t\treturn mockMcpRegistry();\n\t}\n\tif ( ! mcpRegistry[ namespace ] ) {\n\t\tmcpRegistry[ namespace ] = new McpServer(\n\t\t\t{ name: mcpName, title, version: '1.0.0' },\n\t\t\t{ instructions: options?.instructions, capabilities: { resources: { subscribe: true } } }\n\t\t);\n\t\tif ( options?.docs ) {\n\t\t\tregisterServerDocsResource( mcpRegistry[ namespace ], namespace, title, options.docs, ( ...args ) => {\n\t\t\t\tbufferedResources.push( args );\n\t\t\t\tcallAdapters( ( adapter ) => adapter.onResourceRegistered( ...args ) );\n\t\t\t} );\n\t\t}\n\t}\n\tconst mcpServer = mcpRegistry[ namespace ];\n\tconst serverDocsUri = options?.docs ? `elementor://${ namespace }/server-docs` : undefined;\n\tconst { addTool } = createToolRegistry( mcpServer, mcpName, serverDocsUri );\n\treturn {\n\t\twaitForReady: () => readyPromise,\n\t\t// @ts-expect-error: TS is unable to infer the type here\n\t\tresource: async ( ...args: Parameters< McpServer[ 'registerResource' ] > ) => {\n\t\t\tconst [ name, uriOrTemplate, ...rest ] = args as [ string, unknown, ...unknown[] ];\n\t\t\tconst handler = rest[ rest.length - 1 ] as McpResourceHandler;\n\t\t\tconst resourceArgs: Parameters< IMcpRegistrationAdapter[ 'onResourceRegistered' ] > = [\n\t\t\t\tname,\n\t\t\t\turiOrTemplate as McpResourceUriOrTemplate,\n\t\t\t\thandler,\n\t\t\t];\n\t\t\tbufferedResources.push( resourceArgs );\n\t\t\tcallAdapters( ( adapter ) => adapter.onResourceRegistered( ...resourceArgs ) );\n\t\t\treturn mcpServer.registerResource( ...args );\n\t\t},\n\t\tsendResourceUpdated: ( ...args: Parameters< McpServer[ 'server' ][ 'sendResourceUpdated' ] > ) => {\n\t\t\tcallAdapters( ( adapter ) => adapter.sendResourceUpdated( { uri: args[ 0 ].uri } ) );\n\t\t\treturn Promise.resolve( mcpServer.server.sendResourceUpdated( ...args ) ).catch( ( error: Error ) => {\n\t\t\t\tif ( error?.message?.includes( 'Not connected' ) ) {\n\t\t\t\t\treturn; // Expected when no MCP client is connected yet\n\t\t\t\t}\n\t\t\t\tif ( error?.message?.includes( 'does not support notifying about resources' ) ) {\n\t\t\t\t\treturn; // Server capability not declared — safe to ignore\n\t\t\t\t}\n\t\t\t\tthrow error;\n\t\t\t} );\n\t\t},\n\t\taddTool,\n\t\tsetMCPDescription: ( description: string ) => {\n\t\t\tmcpDescriptions[ namespace ] = description;\n\t\t},\n\t};\n};\n\nexport interface MCPRegistryEntry {\n\taddTool: < T extends undefined | z.ZodRawShape = undefined, O extends undefined | z.ZodRawShape = undefined >(\n\t\topts: ToolRegistrationOptions< T, O >\n\t) => void;\n\tsetMCPDescription: ( description: string ) => void;\n\tsendResourceUpdated: McpServer[ 'server' ][ 'sendResourceUpdated' ];\n\tresource: McpServer[ 'registerResource' ];\n\twaitForReady: () => Promise< void >;\n}\n\ntype ToolRegistrationOptions<\n\tInputArgs extends undefined | z.ZodRawShape = undefined,\n\tOutputSchema extends undefined | z.ZodRawShape = undefined,\n\tExpectedOutput = OutputSchema extends z.ZodRawShape ? z.objectOutputType< OutputSchema, z.ZodTypeAny > : string,\n> = {\n\tname: string;\n\tdescription: string;\n\tschema?: InputArgs;\n\t/**\n\t * Auto added fields:\n\t * @param errors z.string().optional().describe('Error message if the tool failed')\n\t */\n\toutputSchema?: OutputSchema;\n\thandler: InputArgs extends z.ZodRawShape\n\t\t? (\n\t\t\t\targs: z.objectOutputType< InputArgs, z.ZodTypeAny >,\n\t\t\t\textra: RequestHandlerExtra< ServerRequest, ServerNotification >\n\t\t ) => ExpectedOutput | Promise< ExpectedOutput >\n\t\t: (\n\t\t\t\targs: unknown,\n\t\t\t\textra: RequestHandlerExtra< ServerRequest, ServerNotification >\n\t\t ) => ExpectedOutput | Promise< ExpectedOutput >;\n\tisDestructive?: boolean;\n\trequiredResources?: ResourceList;\n\tmodelPreferences?: AngieModelPreferences;\n};\n\nfunction createToolRegistry( server: McpServer, serverName: string, serverDocsUri?: string ) {\n\tfunction addTool<\n\t\tT extends undefined | z.ZodRawShape = undefined,\n\t\tO extends undefined | z.ZodRawShape = undefined,\n\t>( opts: ToolRegistrationOptions< T, O > ) {\n\t\tconst outputSchema = opts.outputSchema as ZodRawShape | undefined;\n\t\tif ( outputSchema ) {\n\t\t\tObject.assign(\n\t\t\t\toutputSchema,\n\t\t\t\toutputSchema.errors ?? {\n\t\t\t\t\terrors: z.string().optional().describe( 'Error message if the tool failed' ),\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t\t// @ts-ignore: TS is unable to infer the type here\n\t\tconst inputSchema: ZodRawShape = opts.schema ? opts.schema : {};\n\t\tconst toolCallback: ToolCallback< ZodRawShape > = async function ( args, extra ) {\n\t\t\ttry {\n\t\t\t\tconst invocationResult = await opts.handler( opts.schema ? args : {}, extra );\n\t\t\t\treturn {\n\t\t\t\t\t// structuredContent: typeof invocationResult === 'string' ? undefined : invocationResult,\n\t\t\t\t\tcontent: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: 'text',\n\t\t\t\t\t\t\ttext:\n\t\t\t\t\t\t\t\ttypeof invocationResult === 'string'\n\t\t\t\t\t\t\t\t\t? invocationResult\n\t\t\t\t\t\t\t\t\t: JSON.stringify( invocationResult ),\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t};\n\t\t\t} catch ( error ) {\n\t\t\t\treturn {\n\t\t\t\t\tisError: true,\n\t\t\t\t\tstructuredContent: {\n\t\t\t\t\t\terrors: ( error as Error ).message || 'Unknown error',\n\t\t\t\t\t},\n\t\t\t\t\tcontent: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: 'text',\n\t\t\t\t\t\t\ttext:\n\t\t\t\t\t\t\t\t( ( error as Error ).message || 'Unknown error' ) +\n\t\t\t\t\t\t\t\tJSON.stringify( ( error as { response?: { data: unknown } } ).response?.data || error ),\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t};\n\t\t\t}\n\t\t};\n\t\tconst annotations: Record< string, unknown > = {\n\t\t\tdestructiveHint: opts.isDestructive,\n\t\t\treadOnlyHint: opts.isDestructive ? false : undefined,\n\t\t\ttitle: opts.name,\n\t\t};\n\t\tconst mergedResources = mergeRequiredResources( opts.requiredResources, serverDocsUri );\n\t\tconst angieAnnotations = {\n\t\t\t[ ANGIE_MODEL_PREFERENCES ]: opts.modelPreferences ?? createDefaultModelPreferences(),\n\t\t\t[ ANGIE_REQUIRED_RESOURCES ]: mergedResources,\n\t\t};\n\t\tserver.registerTool(\n\t\t\topts.name,\n\t\t\t{\n\t\t\t\tdescription: opts.description,\n\t\t\t\tinputSchema,\n\t\t\t\t// TODO: Uncomment this when the outputSchema is stable\n\t\t\t\t// outputSchema,\n\t\t\t\ttitle: opts.name,\n\t\t\t\tannotations,\n\t\t\t\t_meta: angieAnnotations,\n\t\t\t},\n\t\t\ttoolCallback\n\t\t);\n\t\tconst toolDescriptor = {\n\t\t\tname: opts.name,\n\t\t\tdescription: opts.description,\n\t\t\tinputSchema: inputSchema as object,\n\t\t\texecute: ( params: Record< string, unknown > ) =>\n\t\t\t\ttoolCallback(\n\t\t\t\t\tparams as Parameters< typeof toolCallback >[ 0 ],\n\t\t\t\t\t/* WebMCP: no protocol session — handlers must not rely on `extra` here */\n\t\t\t\t\t{} as RequestHandlerExtra< ServerRequest, ServerNotification >\n\t\t\t\t) as Promise< unknown >,\n\t\t};\n\t\tconst extraData = {\n\t\t\tresources: [ `Server resource name: ${ serverName }, Required to fetch!` ],\n\t\t\trequiredResources: mergedResources?.map( ( resource ) => resource.uri ) ?? [],\n\t\t};\n\t\tbufferedTools.push( [ toolDescriptor, extraData ] );\n\t\tcallAdapters( ( adapter ) => adapter.onToolRegistered( toolDescriptor, extraData ) );\n\t\tif ( isMcpRegistrationActivated ) {\n\t\t\tserver.sendToolListChanged();\n\t\t}\n\t}\n\treturn {\n\t\taddTool,\n\t};\n}\n","import { zodToJsonSchema } from 'zod-to-json-schema';\nimport { z, type z3 } from '@elementor/schema';\n\nimport { type ModelContextRegisterTool, registerModelContextTool } from '../utils/register-model-context-tool';\nimport {\n\ttype IMcpRegistrationAdapter,\n\ttype McpResourceHandler,\n\ttype McpResourceUriOrTemplate,\n\ttype McpToolDescriptor,\n\ttype UriTemplate,\n} from './types';\n\ntype ZodRawShape = z3.ZodRawShape;\n\nexport type ModelContext = {\n\tregisterTool: ModelContextRegisterTool;\n\tunregisterTool?: ( name: string ) => void;\n};\n\ntype ResourceEntry = {\n\tpattern: string;\n\tmatch: ( uri: string ) => Record< string, string | string[] > | null;\n\thandler: McpResourceHandler;\n};\n\nexport class WebMCPAdapter implements IMcpRegistrationAdapter {\n\tprivate readonly registeredToolNames = new Set< string >();\n\tprivate readonly resourceEntries: ResourceEntry[] = [];\n\tprivate activated = false;\n\n\tconstructor( private readonly ctx: ModelContext ) {}\n\n\tactivate(): Promise< void > {\n\t\tif ( this.activated ) {\n\t\t\treturn Promise.resolve();\n\t\t}\n\t\tthis.activated = true;\n\t\treturn registerModelContextTool( this.ctx.registerTool, {\n\t\t\tname: 'editor-resource-getter',\n\t\t\tdescription:\n\t\t\t\t'Get an editor resource by URI, or search for available resources by partial URI. Pass a full URI to retrieve content, or a partial string to discover matching patterns.',\n\t\t\tinputSchema: {\n\t\t\t\ttype: 'object',\n\t\t\t\tproperties: {\n\t\t\t\t\turi: {\n\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t'A full resource URI (e.g. elementor://style/best-practices) or a partial string to search across available resource patterns.',\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\trequired: [ 'uri' ],\n\t\t\t},\n\t\t\texecute: async ( params ) => {\n\t\t\t\tconst query = params.uri as string;\n\t\t\t\tconst entries = this.resourceEntries;\n\n\t\t\t\tif ( entries.length === 0 ) {\n\t\t\t\t\treturn 'No resources are registered yet.';\n\t\t\t\t}\n\n\t\t\t\t// Exact URI match\n\t\t\t\tfor ( const entry of entries ) {\n\t\t\t\t\tconst variables = entry.match( query );\n\t\t\t\t\tif ( variables !== null ) {\n\t\t\t\t\t\tlet resourceUrl: URL;\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tresourceUrl = new URL( query );\n\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\treturn `Invalid URI '${ query }'. Provide a valid resource URI or a partial string to search patterns.`;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst result = await entry.handler( resourceUrl, variables );\n\t\t\t\t\t\treturn result.contents?.[ 0 ]?.text ?? JSON.stringify( result );\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Partial search fallback\n\t\t\t\tconst matches = entries.map( ( e ) => e.pattern ).filter( ( pattern ) => pattern.includes( query ) );\n\t\t\t\tif ( matches.length > 0 ) {\n\t\t\t\t\treturn `Found ${ matches.length } matching resource pattern(s):\\n${ matches.join(\n\t\t\t\t\t\t'\\n'\n\t\t\t\t\t) }\\n\\nProvide a full URI to retrieve the resource content.`;\n\t\t\t\t}\n\n\t\t\t\tconst available = entries.map( ( e ) => e.pattern ).join( '\\n' );\n\t\t\t\tthrow new Error( `No resource matched '${ query }'.\\n\\nAvailable patterns:\\n${ available }` );\n\t\t\t},\n\t\t} );\n\t}\n\n\tonToolRegistered(\n\t\ttool: McpToolDescriptor,\n\t\textraData?: { resources: string[]; requiredResources: string[] }\n\t): void {\n\t\tlet jsonSchema: object;\n\t\ttry {\n\t\t\tjsonSchema = zodToJsonSchema( z.object( tool.inputSchema as ZodRawShape ) );\n\t\t} catch {\n\t\t\tjsonSchema = tool.inputSchema;\n\t\t}\n\n\t\tif ( this.registeredToolNames.has( tool.name ) ) {\n\t\t\tthis.ctx.unregisterTool?.( tool.name );\n\t\t\tthis.registeredToolNames.delete( tool.name );\n\t\t}\n\n\t\tlet resourcesDescription = '';\n\t\tif ( extraData ) {\n\t\t\tif ( extraData.resources?.length > 0 ) {\n\t\t\t\tresourcesDescription += `#Resources:\\n${ extraData.resources?.join( '\\n' ) }\\n\\n`;\n\t\t\t}\n\t\t\tif ( extraData.requiredResources?.length > 0 ) {\n\t\t\t\tresourcesDescription += `#Required Resources:\\n${ extraData.requiredResources?.join( '\\n' ) }\\n\\n`;\n\t\t\t}\n\t\t\tresourcesDescription += `To read resources, use editor-resource-getter tool.\\n\\n`;\n\t\t}\n\t\tvoid registerModelContextTool( this.ctx.registerTool, {\n\t\t\tname: tool.name,\n\t\t\tdescription: `${ resourcesDescription }${ tool.description }`,\n\t\t\tinputSchema: jsonSchema,\n\t\t\texecute: tool.execute,\n\t\t} ).then( () => {\n\t\t\tthis.registeredToolNames.add( tool.name );\n\t\t} );\n\t}\n\n\tonResourceRegistered( _name: string, uriOrTemplate: McpResourceUriOrTemplate, handler: McpResourceHandler ): void {\n\t\tif ( typeof uriOrTemplate === 'string' ) {\n\t\t\tthis.resourceEntries.push( {\n\t\t\t\tpattern: uriOrTemplate,\n\t\t\t\tmatch: ( uri ) => ( uri === uriOrTemplate ? {} : null ),\n\t\t\t\thandler,\n\t\t\t} );\n\t\t} else {\n\t\t\tconst template = uriOrTemplate.uriTemplate as UriTemplate;\n\t\t\tthis.resourceEntries.push( {\n\t\t\t\tpattern: template.toString(),\n\t\t\t\tmatch: ( uri ) => template.match( uri ),\n\t\t\t\thandler,\n\t\t\t} );\n\t\t}\n\t}\n\n\tsendResourceUpdated(): void {\n\t\t// WebMCP has no server-push mechanism — no-op\n\t}\n}\n","import { type McpToolDescriptor } from '../adapters/types';\n\nexport type ModelContextRegisterTool = ( tool: McpToolDescriptor ) => void | Promise< void >;\n\nexport async function registerModelContextTool(\n\tregisterTool: ModelContextRegisterTool,\n\ttool: McpToolDescriptor\n): Promise< void > {\n\ttry {\n\t\tawait Promise.resolve( registerTool( tool ) );\n\t} catch ( error ) {\n\t\t/* eslint-disable-next-line no-console */\n\t\tconsole.error( 'Tool registration failed:', error );\n\t}\n}\n","export const ANGIE_MODEL_PREFERENCES = 'angie/modelPreferences' as const;\nexport const ANGIE_REQUIRED_RESOURCES = 'angie/requiredResources' as const;\n\nexport interface AngieModelPreferences {\n\thints?: Array< { name: string } >;\n\tcostPriority?: number; // 0-1 (future use)\n\tspeedPriority?: number; // 0-1 (future use)\n\tintelligencePriority?: number; // 0-1 (future use)\n}\n\nexport function createDefaultModelPreferences(): AngieModelPreferences {\n\treturn {\n\t\thints: [ { name: 'claude-sonnet-4-6' } ],\n\t};\n}\n","import { type McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\n\nimport { type MCPRegistryEntry } from '../mcp-registry';\n\nconst mock = new Proxy(\n\t{},\n\t{\n\t\tget: () => {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unused-vars\n\t\t\tfunction mockedFn( ..._: unknown[] ) {}\n\t\t\treturn mockedFn;\n\t\t},\n\t}\n);\n\nexport const mockMcpRegistry = (): MCPRegistryEntry => {\n\treturn {\n\t\t// @ts-ignore\n\t\tresource: async () => {},\n\t\t// @ts-ignore\n\t\tsendResourceUpdated: () => {},\n\t\taddTool: () => {},\n\t\tsetMCPDescription: () => {},\n\t\tmcpServer: mock as McpServer,\n\t};\n};\n","import { type ModelContext } from '../adapters/web-mcp-adapter';\n\ntype ModelContextHost = {\n\tmodelContext?: ModelContext;\n};\n\nfunction bindModelContextMethods( host: ModelContext ): ModelContext {\n\treturn {\n\t\tregisterTool: host.registerTool.bind( host ),\n\t\tunregisterTool: host.unregisterTool ? host.unregisterTool.bind( host ) : undefined,\n\t};\n}\n\nexport function getModelContext(): ModelContext | undefined {\n\tconst documentModelContext =\n\t\ttypeof document !== 'undefined' ? ( document as unknown as ModelContextHost ).modelContext : undefined;\n\tif ( documentModelContext?.registerTool ) {\n\t\treturn bindModelContextMethods( documentModelContext );\n\t}\n\tconst navigatorModelContext =\n\t\ttypeof navigator !== 'undefined' ? ( navigator as unknown as ModelContextHost ).modelContext : undefined;\n\tif ( navigatorModelContext?.registerTool ) {\n\t\treturn bindModelContextMethods( navigatorModelContext );\n\t}\n\n\treturn undefined;\n}\n","export type ResourceList = {\n\turi: string;\n\tdescription: string;\n}[];\n\nexport const mergeRequiredResources = (\n\ttoolResources: ResourceList | undefined,\n\tserverDocsUri: string | undefined\n): ResourceList | undefined => {\n\tif ( ! serverDocsUri ) {\n\t\treturn toolResources;\n\t}\n\tif ( toolResources?.some( ( r ) => r.uri === serverDocsUri ) ) {\n\t\treturn toolResources;\n\t}\n\treturn [ ...( toolResources ?? [] ), { uri: serverDocsUri, description: 'Server docs' } ];\n};\n","export const createSimpleResourceHandler = ( text: string ) => async ( uri: URL ) => ( {\n\tcontents: [ { uri: uri.href, mimeType: 'text/plain', text } ],\n} );\n","import { type McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\n\nimport { type IMcpRegistrationAdapter } from '../adapters/types';\nimport { createSimpleResourceHandler } from './create-simple-resource-handler';\n\ntype OnResourceRegistered = ( ...args: Parameters< IMcpRegistrationAdapter[ 'onResourceRegistered' ] > ) => void;\n\nexport const registerServerDocsResource = (\n\tserver: McpServer,\n\tnamespace: string,\n\ttitle: string,\n\tdocs: string,\n\tonRegistered: OnResourceRegistered\n): void => {\n\tconst uri = `elementor://${ namespace }/server-docs`;\n\tconst name = `${ namespace }-server-docs`;\n\tconst handler = createSimpleResourceHandler( docs );\n\tserver.registerResource(\n\t\tname,\n\t\turi,\n\t\t{\n\t\t\ttitle: `${ title } server docs`,\n\t\t\tdescription: 'Full MCP documentation (lazy-loaded)',\n\t\t\tmimeType: 'text/plain',\n\t\t},\n\t\thandler\n\t);\n\tonRegistered( name, uri, handler );\n};\n","export const toMCPTitle = ( namespace: string ): string => {\n\tconst label = namespace\n\t\t.split( '_' )\n\t\t.filter( Boolean )\n\t\t.map( ( word ) => word.charAt( 0 ).toUpperCase() + word.slice( 1 ) )\n\t\t.join( ' ' );\n\n\treturn `Editor ${ label }`;\n};\n","import { type AngieMcpSdk } from '@elementor-external/angie-sdk';\n\nimport { type getRegisteredMcpServers as _getRegisteredMcpServers } from '../mcp-registry';\nimport { toMCPTitle } from '../utils/to-mcp-title';\nimport { type IMcpRegistrationAdapter } from './types';\n\nconst MAX_RETRIES = 3;\n\nexport class AngieMcpAdapter implements IMcpRegistrationAdapter {\n\tconstructor(\n\t\tprivate readonly sdk: AngieMcpSdk,\n\t\tprivate readonly getRegisteredMcpServers: typeof _getRegisteredMcpServers\n\t) {}\n\n\tasync activate(): Promise< void > {\n\t\t// No waitForReady() here: registerLocalServer queues the server and the SDK flushes\n\t\t// the queue once Angie reports ready. waitForReady() only resolves for the SDK copy\n\t\t// that booted the sidebar, which is the host integration, never the editor bundle.\n\t\tawait this.registerEntries( this.getRegisteredMcpServers(), MAX_RETRIES );\n\t}\n\n\tprivate async registerEntries(\n\t\tentries: ReturnType< typeof _getRegisteredMcpServers >,\n\t\tretry: number\n\t): Promise< void > {\n\t\tif ( retry === 0 ) {\n\t\t\t/* eslint-disable-next-line no-console */\n\t\t\tconsole.error(\n\t\t\t\t'Failed to register MCP after 3 retries. failed entries: ',\n\t\t\t\tentries.map( ( [ key ] ) => key )\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tconst failed: typeof entries = [];\n\t\tfor ( const [ key, mcpServer, description ] of entries ) {\n\t\t\ttry {\n\t\t\t\tawait this.sdk.registerLocalServer( {\n\t\t\t\t\ttitle: toMCPTitle( key ),\n\t\t\t\t\tname: `editor-${ key }`,\n\t\t\t\t\tserver: mcpServer,\n\t\t\t\t\tversion: '1.0.0',\n\t\t\t\t\tdescription,\n\t\t\t\t} );\n\t\t\t} catch {\n\t\t\t\tfailed.push( [ key, mcpServer, description ] );\n\t\t\t}\n\t\t}\n\n\t\tif ( failed.length > 0 ) {\n\t\t\treturn this.registerEntries( failed, retry - 1 );\n\t\t}\n\t}\n\n\tonToolRegistered(): void {\n\t\t// Angie tools are registered via McpServer (at activate time).\n\t}\n\n\tonResourceRegistered(): void {\n\t\t// Resources are registered on the McpServer instance directly.\n\t}\n\n\tsendResourceUpdated(): void {\n\t\t// Resource update notifications are sent via MCPRegistryEntry.sendResourceUpdated.\n\t}\n}\n","import { type z } from '@elementor/schema';\nimport { type RequestHandlerExtra } from '@modelcontextprotocol/sdk/shared/protocol.js';\nimport { SamplingMessageSchema, type ServerNotification, type ServerRequest } from '@modelcontextprotocol/sdk/types.js';\n\ntype Server = RequestHandlerExtra< ServerRequest, ServerNotification >;\ntype Opts = {\n\tmaxTokens?: number;\n\tmodelPreferences?: string;\n\tmodel?: string;\n};\n\nconst DEFAULT_OPTS: Opts = {\n\tmaxTokens: 10000,\n\tmodelPreferences: 'openai',\n\tmodel: 'gpt-4o',\n};\n\ntype SamplingOpts = {\n\tsystemPrompt?: string;\n\tstructuredOutput?: z.ZodTypeAny;\n\tmessages: { role: 'user' | 'assistant'; content: { type: 'text'; text: string } }[];\n\trequestParams?: { [ key: string ]: string };\n};\n\nconst DEFAULT_STRUCTURED_OUTPUT = {\n\ttype: 'object',\n\tproperties: {\n\t\tcontent: {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Result',\n\t\t},\n\t},\n\trequired: [ 'content' ],\n\tadditionalProperties: false,\n};\n\nexport const createSampler = ( server: Server, opts: Opts = DEFAULT_OPTS ) => {\n\tconst { maxTokens = 1000, modelPreferences = 'openai', model = 'gpt-4o' } = opts;\n\tconst exec = async ( payload: SamplingOpts ) => {\n\t\tconst systemPromptObject = { ...( payload.systemPrompt ? { systemPrompt: payload.systemPrompt } : {} ) };\n\t\tconst requestParams = payload.requestParams || {};\n\t\tconst result = await server.sendRequest(\n\t\t\t{\n\t\t\t\tmethod: 'sampling/createMessage',\n\t\t\t\tparams: {\n\t\t\t\t\t...requestParams,\n\t\t\t\t\tmaxTokens,\n\t\t\t\t\tmodelPreferences: {\n\t\t\t\t\t\thints: [ { name: modelPreferences } ],\n\t\t\t\t\t},\n\t\t\t\t\tmetadata: {\n\t\t\t\t\t\tmodel,\n\t\t\t\t\t\t...systemPromptObject,\n\t\t\t\t\t\t...{ structured_output: payload.structuredOutput || DEFAULT_STRUCTURED_OUTPUT },\n\t\t\t\t\t},\n\t\t\t\t\tmessages: payload.messages,\n\t\t\t\t},\n\t\t\t\t// ...systemPromptObject,\n\t\t\t},\n\t\t\tSamplingMessageSchema\n\t\t);\n\t\treturn result.content;\n\t};\n\treturn exec;\n};\n","class ToolPrompts {\n\tpublic _description = '';\n\tpublic _parameters: Record< string, string > = {};\n\tpublic _examples: string[] = [];\n\tpublic _furtherInstructions: string[] = [];\n\n\tconstructor( public name: string ) {}\n\n\tdescription(): string;\n\tdescription( desc: string ): this;\n\tdescription( desc?: string | undefined ) {\n\t\tif ( typeof desc === 'undefined' ) {\n\t\t\treturn this._description;\n\t\t}\n\t\tthis._description = desc;\n\t\treturn this;\n\t}\n\n\tparameter( key: string ): string;\n\tparameter( key: string, description: string ): this;\n\tparameter( key: string, description?: string ) {\n\t\tif ( typeof description === 'undefined' ) {\n\t\t\treturn this._parameters[ key ];\n\t\t}\n\t\tthis._parameters[ key ] = `**${ key }**:\\n${ description }`;\n\t\treturn this;\n\t}\n\n\tinstruction( instruction: string ): this {\n\t\tthis._furtherInstructions.push( instruction );\n\t\treturn this;\n\t}\n\n\texample( example: string ): this {\n\t\tthis._examples.push( example );\n\t\treturn this;\n\t}\n\n\tpublic get examples() {\n\t\treturn this._examples.join( '\\n\\n' );\n\t}\n\n\tprompt(): string {\n\t\treturn `# ${ this.name }\n# Description\n${ this._description }\n${ this._parameters.length ? '# Parameters\\n' + Object.values( this._parameters ).join( '\\n\\n' ) : '' }\n${ this._examples.length ? '# Examples\\n' + this.examples : '' }\n${ this._furtherInstructions.length ? '# Further Instructions\\n' + this._furtherInstructions.join( '\\n\\n' ) : '' }\n`.trim();\n\t}\n}\n\nexport const toolPrompts = ( name: string ) => {\n\treturn new ToolPrompts( name );\n};\n","export type ActiveChatInfo = {\n\tsessionId: string;\n\texpiresAt: number;\n};\n\nexport const getActiveChatInfo = (): ActiveChatInfo => {\n\tconst info = localStorage.getItem( 'angie_active_chat_id' );\n\tif ( ! info ) {\n\t\treturn {\n\t\t\texpiresAt: 0,\n\t\t\tsessionId: '',\n\t\t};\n\t}\n\tconst rawData = JSON.parse( info );\n\treturn {\n\t\texpiresAt: rawData.expiresAt as number,\n\t\tsessionId: rawData.sessionId as string,\n\t};\n};\n","import {\n\tAngieInteractionMode,\n\tgetAngieIframe,\n\tsetAngieInteractionMode,\n\ttoggleAngieSidebar,\n} from '@elementor-external/angie-sdk';\n\nimport { isAngieAvailable } from './is-angie-available';\n\nconst getLoadedEditorAngie = () => {\n\treturn window.elementorV2?.editorAngie?.openAngie;\n};\n\nexport const hasLoadedEditorAngie = (): boolean => Boolean( getLoadedEditorAngie() );\n\nexport const openLoadedEditorAngie = ( prompt: string | undefined, mode: AngieInteractionMode ): boolean => {\n\tconst openAngie = getLoadedEditorAngie();\n\n\tif ( ! openAngie ) {\n\t\treturn false;\n\t}\n\n\tPromise.resolve( openAngie( { prompt: prompt ?? '', mode } ) ).catch( ( error ) => {\n\t\t// eslint-disable-next-line no-console\n\t\tconsole.error( 'Failed to open Angie:', error );\n\t} );\n\n\treturn true;\n};\n\nexport const openAngieInAskMode = ( prompt?: string ): void => {\n\topenAngieInMode( prompt, AngieInteractionMode.ASK );\n};\n\nexport const openAngieInAgentMode = ( prompt?: string ): void => {\n\topenAngieInMode( prompt, AngieInteractionMode.AGENT );\n};\n\nconst openAngieInMode = ( prompt: string | undefined, mode: AngieInteractionMode ): void => {\n\tif ( openLoadedEditorAngie( prompt, mode ) ) {\n\t\treturn;\n\t}\n\n\tif ( ! isAngieAvailable() ) {\n\t\treturn;\n\t}\n\n\tconst angieSidebar = getAngieIframe();\n\n\tif ( ! angieSidebar ) {\n\t\treturn;\n\t}\n\n\ttoggleAngieSidebar( angieSidebar, true );\n\tsetAngieInteractionMode( mode );\n\n\tif ( prompt ) {\n\t\twindow.location.hash = `angie-prompt=${ encodeURIComponent( prompt ) }`;\n\t}\n};\n","import { AngieInteractionMode, getAngieIframe, toggleAngieSidebar } from '@elementor-external/angie-sdk';\n\nimport { openLoadedEditorAngie } from './open-angie-in-ask-mode';\n\nexport const sendPromptToAngie = ( prompt?: string ) => {\n\tif ( openLoadedEditorAngie( prompt, AngieInteractionMode.AGENT ) ) {\n\t\treturn;\n\t}\n\n\tconst angieSidebar = getAngieIframe();\n\n\tif ( ! angieSidebar ) {\n\t\treturn;\n\t}\n\n\ttoggleAngieSidebar( angieSidebar, true );\n\n\tif ( ! prompt ) {\n\t\treturn;\n\t}\n\n\twindow.location.hash = `angie-prompt=${ encodeURIComponent( prompt ) }`;\n};\n","import { setReferrerRedirect } from '@elementor-external/angie-sdk';\n\nconst ANGIE_INSTALL_URL = '/wp-admin/plugin-install.php?s=angie&tab=search&type=term';\n\n/**\n * @deprecated Kept only for Elementor Pro compatibility. Will be removed in a future version.\n * @param prompt Optional prompt to pass after redirect.\n */\nexport const redirectToInstallation = ( prompt?: string ) => {\n\tsetReferrerRedirect( window.location.href, prompt );\n\twindow.location.href = ANGIE_INSTALL_URL;\n};\n","import { ANGIE_SIDEBAR_STATE_OPEN, saveState, setReferrerRedirect } from '@elementor-external/angie-sdk';\n\nconst ANGIE_APP_URL = '/wp-admin/admin.php?page=angie-app';\n\n/**\n * @deprecated Kept only for Elementor Pro compatibility. Will be removed in a future version.\n * @param prompt Optional prompt to pass after redirect.\n */\nexport const redirectToAppAdmin = ( prompt?: string ) => {\n\tsetReferrerRedirect( window.location.href, prompt );\n\tsaveState( ANGIE_SIDEBAR_STATE_OPEN );\n\twindow.location.href = ANGIE_APP_URL;\n};\n","import apiFetch from '@wordpress/api-fetch';\n\ntype PluginResponse = {\n\tplugin: string;\n\tstatus: 'active' | 'inactive';\n\tname: string;\n};\n\ntype PluginErrorResponse = {\n\tcode: string;\n\tmessage: string;\n};\n\nexport type InstallAngieResult = { success: true } | { success: false; error: string; code?: string };\n\nconst ANGIE_SLUG = 'angie';\n\nconst isPluginErrorResponse = ( response: unknown ): response is PluginErrorResponse => {\n\treturn typeof response === 'object' && response !== null && 'code' in response && 'message' in response;\n};\n\nconst activatePlugin = async ( pluginPath: string ): Promise< PluginResponse > => {\n\treturn apiFetch< PluginResponse >( {\n\t\tpath: `/wp/v2/plugins/${ pluginPath }`,\n\t\tmethod: 'POST',\n\t\tdata: { status: 'active' },\n\t} );\n};\n\nconst installPlugin = async (): Promise< PluginResponse > => {\n\ttry {\n\t\treturn await apiFetch< PluginResponse >( {\n\t\t\tpath: '/wp/v2/plugins',\n\t\t\tmethod: 'POST',\n\t\t\tdata: {\n\t\t\t\tslug: ANGIE_SLUG,\n\t\t\t\tstatus: 'active',\n\t\t\t},\n\t\t} );\n\t} catch ( error: unknown ) {\n\t\tif ( isPluginErrorResponse( error ) && error.code === 'folder_exists' ) {\n\t\t\treturn activatePlugin( `${ ANGIE_SLUG }/${ ANGIE_SLUG }` );\n\t\t}\n\n\t\tthrow error;\n\t}\n};\n\n/**\n * @deprecated Kept only for Elementor Pro compatibility. Will be removed in a future version.\n */\nexport const installAngiePlugin = async (): Promise< InstallAngieResult > => {\n\ttry {\n\t\tawait installPlugin();\n\n\t\treturn { success: true };\n\t} catch ( error: unknown ) {\n\t\tif ( isPluginErrorResponse( error ) ) {\n\t\t\treturn { success: false, error: error.message, code: error.code };\n\t\t}\n\n\t\treturn { success: false, error: 'Unknown error occurred' };\n\t}\n};\n","import apiFetch from '@wordpress/api-fetch';\n\nexport const saveAngieConsent = async (): Promise< void > => {\n\tawait apiFetch( {\n\t\tpath: '/elementor/v1/angie/consent',\n\t\tmethod: 'POST',\n\t} );\n};\n","import { createAndRegisterAdapters, signalMcpReady } from './mcp-registry';\n\nlet isInitialized = false;\nexport async function startMCPServer() {\n\tif ( isInitialized ) {\n\t\treturn;\n\t}\n\tisInitialized = true;\n\ttry {\n\t\tawait createAndRegisterAdapters();\n\t} catch ( error ) {\n\t\t/* eslint-disable-next-line no-console */\n\t\tconsole.error( 'MCP adapter activation failed:', error );\n\t} finally {\n\t\tsignalMcpReady();\n\t}\n}\n\n// Start right away when the bundle loads after DOMContentLoaded (late or deferred load): the event will\n// not fire again, and `waitForMcpReady()` callers would wait forever.\nif ( typeof document !== 'undefined' && document.readyState === 'loading' ) {\n\tdocument.addEventListener( 'DOMContentLoaded', () => void startMCPServer(), { once: true } );\n} else {\n\tvoid startMCPServer();\n}\n","export const MCP_STYLES_APPLIED_EVENT = 'elementor/mcp/styles-applied';\n\nexport type McpStylesAppliedPayload = {\n\tstyleValue: Record< string, unknown >;\n};\n\nexport function dispatchMcpStylesAppliedEvent( payload: McpStylesAppliedPayload ): void {\n\twindow.dispatchEvent( new CustomEvent( MCP_STYLES_APPLIED_EVENT, { detail: payload } ) );\n}\n"],"mappings":";AAAA,SAAS,mBAAmB;AAC5B,SAAS,gBAAgB,wBAAwB;AAEjD,IAAI;AAEJ,IAAM,oBAAN,cAAgC,YAAY;AAAA,EAC3C,MAAa,eAAgC;AAC5C,QAAI,aAAa;AACjB,WAAQ,aAAa,GAAI;AACxB,UAAI;AACH,cAAM,MAAM,aAAa;AACzB;AAAA,MACD,QAAQ;AACP;AACA,cAAM,MAAM;AAAA,MACb;AAAA,IACD;AACA,WAAO,IAAI,QAAS,MAAM;AAAA,IAAC,CAAE;AAAA,EAC9B;AACD;AAEA,IAAM,QAAQ,CAAE,KAAK,QACpB,IAAI,QAAS,CAAE,YAAa;AAC3B,aAAY,SAAS,EAAG;AACzB,CAAE;AAEI,IAAM,SAAS,MAAM;AAE3B,QAAM,gBAAgB,CAAC,CAAI,WAA0C;AACrE,MAAK,eAAgB;AACpB,WAAO,CAAC;AAAA,EACT;AACA,MAAK,CAAE,KAAM;AACZ,UAAM,IAAI,kBAAkB;AAAA,EAC7B;AACA,SAAO;AACR;;;AC/BA;AAAA,EACC,aAAAA;AAAA,EACA;AAAA,OAGM;AACP,SAAS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,SAAS,MAAM,MAAM,KAAK;AAAA,IACjE;AAEA,WAAO,EAAE,SAAS,OAAO,OAAO,yBAAyB;AAAA,EAC1D;AACD;;;AC/DA,OAAOE,eAAc;AAEd,IAAM,mBAAmB,YAA6B;AAC5D,QAAMA,UAAU;AAAA,IACf,MAAM;AAAA,IACN,QAAQ;AAAA,EACT,CAAE;AACH;;;ACLA,IAAI,gBAAgB;AACpB,eAAsB,iBAAiB;AACtC,MAAK,eAAgB;AACpB;AAAA,EACD;AACA,kBAAgB;AAChB,MAAI;AACH,UAAM,0BAA0B;AAAA,EACjC,SAAU,OAAQ;AAEjB,YAAQ,MAAO,kCAAkC,KAAM;AAAA,EACxD,UAAE;AACD,mBAAe;AAAA,EAChB;AACD;AAIA,IAAK,OAAO,aAAa,eAAe,SAAS,eAAe,WAAY;AAC3E,WAAS,iBAAkB,oBAAoB,MAAM,KAAK,eAAe,GAAG,EAAE,MAAM,KAAK,CAAE;AAC5F,OAAO;AACN,OAAK,eAAe;AACrB;;;ACxBO,IAAM,2BAA2B;AAMjC,SAAS,8BAA+B,SAAyC;AACvF,SAAO,cAAe,IAAI,YAAa,0BAA0B,EAAE,QAAQ,QAAQ,CAAE,CAAE;AACxF;;;AzB2BO,IAAM,cAAc,MAAM,OAAO;","names":["McpServer","SamplingMessageSchema","getAngieIframe","z","z","sdk","getRegisteredMcpServers","getAngieIframe","getAngieIframe","AngieInteractionMode","getAngieIframe","toggleAngieSidebar","AngieInteractionMode","getAngieIframe","toggleAngieSidebar","ANGIE_SIDEBAR_STATE_OPEN","setReferrerRedirect","apiFetch"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/utils/is-angie-available.ts","../src/utils/can-create-widget.ts","../src/utils/is-angie-sidebar-open.ts","../src/mcp-registry.ts","../src/adapters/web-mcp-adapter.ts","../src/utils/register-model-context-tool.ts","../src/angie-annotations.ts","../src/test-utils/mock-mcp-registry.ts","../src/utils/get-model-context.ts","../src/utils/merge-required-resources.ts","../src/utils/create-simple-resource-handler.ts","../src/utils/register-server-docs-resource.ts","../src/utils/to-mcp-title.ts","../src/adapters/angie-adapter.ts","../src/sampler.ts","../src/utils/prompt-builder.ts","../src/utils/get-active-chat-info.ts","../src/utils/open-angie-in-ask-mode.ts","../src/utils/send-prompt-to-angie.ts","../src/utils/redirect-to-installation.ts","../src/utils/redirect-to-app-admin.ts","../src/utils/install-angie-plugin.ts","../src/utils/save-angie-consent.ts","../src/init.ts","../src/events/mcp-styles-applied-event.ts"],"sourcesContent":["import './types/open-angie-request';\n\nexport { getAngieIframe, getAngieSdk, MessageEventType as AngieMessageEvenetType } from '@elementor/editor-angie-sdk';\n\nexport {\n\tMcpServer,\n\tResourceTemplate,\n\ttype RegisteredResource,\n\ttype ToolCallback,\n} from '@modelcontextprotocol/sdk/server/mcp.js';\nexport { SamplingMessageSchema } from '@modelcontextprotocol/sdk/types.js';\nexport { isAngieAvailable } from './utils/is-angie-available';\nexport { canCreateWidget } from './utils/can-create-widget';\nexport { isAngieSidebarOpen } from './utils/is-angie-sidebar-open';\nexport * from './mcp-registry';\nexport { AngieMcpAdapter } from './adapters/angie-adapter';\nexport type { IMcpRegistrationAdapter } from './adapters/types';\nexport { createSampler } from './sampler';\nexport { toolPrompts } from './utils/prompt-builder';\nexport { ANGIE_MODEL_PREFERENCES, ANGIE_REQUIRED_RESOURCES, type AngieModelPreferences } from './angie-annotations';\nexport { getActiveChatInfo, type ActiveChatInfo } from './utils/get-active-chat-info';\nexport { hasLoadedEditorAngie, openAngieInAgentMode, openAngieInAskMode } from './utils/open-angie-in-ask-mode';\nexport type {\n\tEditorAngieWindowHost,\n\tOpenAngieCommonProperties,\n\tOpenAngiePluginProperties,\n\tOpenAngieRequest,\n\tOpenAngieSdkProperties,\n} from './types/open-angie-request';\nexport { sendPromptToAngie } from './utils/send-prompt-to-angie';\nexport { redirectToInstallation } from './utils/redirect-to-installation';\nexport { redirectToAppAdmin } from './utils/redirect-to-app-admin';\nexport { installAngiePlugin, type InstallAngieResult } from './utils/install-angie-plugin';\nexport { saveAngieConsent } from './utils/save-angie-consent';\nexport * from './init';\nexport {\n\tdispatchMcpStylesAppliedEvent,\n\tMCP_STYLES_APPLIED_EVENT,\n\ttype McpStylesAppliedPayload,\n} from './events/mcp-styles-applied-event';\n","import { getAngieIframe } from '@elementor/editor-angie-sdk';\n\nexport const isAngieAvailable = (): boolean => {\n\treturn !! getAngieIframe();\n};\n","export const canCreateWidget = (): boolean => {\n\treturn Boolean( window.elementor?.config?.widgetCreation?.canCreateWidget );\n};\n","import { ANGIE_SIDEBAR_STATE_OPEN, getAngieSidebarSavedState } from '@elementor/editor-angie-sdk';\n\nexport const isAngieSidebarOpen = (): boolean => {\n\treturn getAngieSidebarSavedState() === ANGIE_SIDEBAR_STATE_OPEN;\n};\n","import { z, type z3 } from '@elementor/schema';\nimport { McpServer, type ToolCallback } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { type RequestHandlerExtra } from '@modelcontextprotocol/sdk/shared/protocol.js';\nimport { type ServerNotification, type ServerRequest } from '@modelcontextprotocol/sdk/types.js';\n\nimport { type IMcpRegistrationAdapter, type McpResourceHandler, type McpResourceUriOrTemplate } from './adapters/types';\nimport { WebMCPAdapter } from './adapters/web-mcp-adapter';\nimport {\n\tANGIE_MODEL_PREFERENCES,\n\tANGIE_REQUIRED_RESOURCES,\n\ttype AngieModelPreferences,\n\tcreateDefaultModelPreferences,\n} from './angie-annotations';\nimport { mockMcpRegistry } from './test-utils/mock-mcp-registry';\nimport { getModelContext } from './utils/get-model-context';\nimport { mergeRequiredResources, type ResourceList } from './utils/merge-required-resources';\nimport { registerServerDocsResource } from './utils/register-server-docs-resource';\nimport { toMCPTitle } from './utils/to-mcp-title';\n\ntype ZodRawShape = z3.ZodRawShape;\n\nconst mcpRegistry: { [ namespace: string ]: McpServer } = {};\nconst mcpDescriptions: { [ namespace: string ]: string } = {};\n// @ts-ignore - QUnit fails this\nconst isMcpRegistrationActivated = false || typeof globalThis.jest !== 'undefined';\n\nconst registrationAdapters: IMcpRegistrationAdapter[] = [];\nconst bufferedTools: Parameters< IMcpRegistrationAdapter[ 'onToolRegistered' ] >[] = [];\nconst bufferedResources: Parameters< IMcpRegistrationAdapter[ 'onResourceRegistered' ] >[] = [];\n\nlet resolveReady!: () => void;\nconst readyPromise = new Promise< void >( ( resolve ) => {\n\tresolveReady = resolve;\n} );\n\nexport const registerMcpAdapter = ( adapter: IMcpRegistrationAdapter ): void => {\n\tregistrationAdapters.push( adapter );\n\tfor ( const tool of bufferedTools ) {\n\t\ttry {\n\t\t\tadapter.onToolRegistered( tool[ 0 ], tool[ 1 ] );\n\t\t} catch {\n\t\t\t// exit quietly\n\t\t}\n\t}\n\tfor ( const resource of bufferedResources ) {\n\t\ttry {\n\t\t\tadapter.onResourceRegistered( ...resource );\n\t\t} catch {\n\t\t\t// exit quietly\n\t\t}\n\t}\n};\n\nexport const signalMcpReady = (): void => {\n\tresolveReady();\n};\n\nexport const waitForMcpReady = (): Promise< void > => readyPromise;\n\n/**\n * Registers and activates an adapter that becomes available after startup.\n * Waits for the startup activation so the adapter is activated exactly once.\n *\n * @param adapter - Adapter to register and activate.\n */\nexport const activateMcpAdapter = async ( adapter: IMcpRegistrationAdapter ): Promise< void > => {\n\tawait readyPromise;\n\tregisterMcpAdapter( adapter );\n\tawait adapter.activate();\n};\n\nexport const createAndRegisterAdapters = async (): Promise< void > => {\n\tconst modelContext = getModelContext();\n\n\tif ( modelContext ) {\n\t\tregisterMcpAdapter( new WebMCPAdapter( modelContext ) );\n\t}\n\n\tawait Promise.all( registrationAdapters.map( ( adapter ) => adapter.activate() ) );\n};\n\n// utility function to run a callback on all MCP interfaces\nfunction callAdapters( fn: ( adapter: IMcpRegistrationAdapter ) => unknown ) {\n\tfor ( const adapter of registrationAdapters ) {\n\t\ttry {\n\t\t\tfn( adapter );\n\t\t} catch {\n\t\t\t// adapter failed — exit quietly, continue to next\n\t\t}\n\t}\n}\n\nexport const registerMcp = ( mcp: McpServer, name: string ) => {\n\tconst mcpName = isAlphabet( name );\n\tmcpRegistry[ mcpName ] = mcp;\n};\n\nexport const getRegisteredMcpServers = (): Array< [ string, McpServer, string ] > => {\n\treturn Object.entries( mcpRegistry ).map( ( [ key, server ] ) => [ key, server, mcpDescriptions[ key ] || key ] );\n};\n\nconst isAlphabet = ( str: string ): string | never => {\n\tconst passes = !! str && /^[a-z_]+$/.test( str );\n\tif ( ! passes ) {\n\t\tthrow new Error( 'Not alphabet' );\n\t}\n\treturn str;\n};\n\n/**\n * @param namespace The namespace of the MCP server. It should contain only lowercase alphabetic characters.\n * @param options\n * @param options.instructions Short hint about the MCP and its toolset (MCP SDK `instructions`; keeps payload small).\n * @param options.docs Full documentation registered as a lazy-loaded resource.\n * When provided, it is registered at elementor://{namespace}/server-docs\n * and auto-injected into every tool's requiredResources.\n */\nexport const getMCPByDomain = (\n\tnamespace: string,\n\toptions?: { docs?: string; instructions?: string }\n): MCPRegistryEntry => {\n\tconst mcpName = `editor-${ isAlphabet( namespace ) }`;\n\tconst title = toMCPTitle( namespace );\n\t// @ts-ignore - QUnit fails this\n\tif ( typeof globalThis.jest !== 'undefined' ) {\n\t\treturn mockMcpRegistry();\n\t}\n\tif ( ! mcpRegistry[ namespace ] ) {\n\t\tmcpRegistry[ namespace ] = new McpServer(\n\t\t\t{ name: mcpName, title, version: '1.0.0' },\n\t\t\t{ instructions: options?.instructions, capabilities: { resources: { subscribe: true } } }\n\t\t);\n\t\tif ( options?.docs ) {\n\t\t\tregisterServerDocsResource( mcpRegistry[ namespace ], namespace, title, options.docs, ( ...args ) => {\n\t\t\t\tbufferedResources.push( args );\n\t\t\t\tcallAdapters( ( adapter ) => adapter.onResourceRegistered( ...args ) );\n\t\t\t} );\n\t\t}\n\t}\n\tconst mcpServer = mcpRegistry[ namespace ];\n\tconst serverDocsUri = options?.docs ? `elementor://${ namespace }/server-docs` : undefined;\n\tconst { addTool } = createToolRegistry( mcpServer, mcpName, serverDocsUri );\n\treturn {\n\t\twaitForReady: () => readyPromise,\n\t\t// @ts-expect-error: TS is unable to infer the type here\n\t\tresource: async ( ...args: Parameters< McpServer[ 'registerResource' ] > ) => {\n\t\t\tconst [ name, uriOrTemplate, ...rest ] = args as [ string, unknown, ...unknown[] ];\n\t\t\tconst handler = rest[ rest.length - 1 ] as McpResourceHandler;\n\t\t\tconst resourceArgs: Parameters< IMcpRegistrationAdapter[ 'onResourceRegistered' ] > = [\n\t\t\t\tname,\n\t\t\t\turiOrTemplate as McpResourceUriOrTemplate,\n\t\t\t\thandler,\n\t\t\t];\n\t\t\tbufferedResources.push( resourceArgs );\n\t\t\tcallAdapters( ( adapter ) => adapter.onResourceRegistered( ...resourceArgs ) );\n\t\t\treturn mcpServer.registerResource( ...args );\n\t\t},\n\t\tsendResourceUpdated: ( ...args: Parameters< McpServer[ 'server' ][ 'sendResourceUpdated' ] > ) => {\n\t\t\tcallAdapters( ( adapter ) => adapter.sendResourceUpdated( { uri: args[ 0 ].uri } ) );\n\t\t\treturn Promise.resolve( mcpServer.server.sendResourceUpdated( ...args ) ).catch( ( error: Error ) => {\n\t\t\t\tif ( error?.message?.includes( 'Not connected' ) ) {\n\t\t\t\t\treturn; // Expected when no MCP client is connected yet\n\t\t\t\t}\n\t\t\t\tif ( error?.message?.includes( 'does not support notifying about resources' ) ) {\n\t\t\t\t\treturn; // Server capability not declared — safe to ignore\n\t\t\t\t}\n\t\t\t\tthrow error;\n\t\t\t} );\n\t\t},\n\t\taddTool,\n\t\tsetMCPDescription: ( description: string ) => {\n\t\t\tmcpDescriptions[ namespace ] = description;\n\t\t},\n\t};\n};\n\nexport interface MCPRegistryEntry {\n\taddTool: < T extends undefined | z.ZodRawShape = undefined, O extends undefined | z.ZodRawShape = undefined >(\n\t\topts: ToolRegistrationOptions< T, O >\n\t) => void;\n\tsetMCPDescription: ( description: string ) => void;\n\tsendResourceUpdated: McpServer[ 'server' ][ 'sendResourceUpdated' ];\n\tresource: McpServer[ 'registerResource' ];\n\twaitForReady: () => Promise< void >;\n}\n\ntype ToolRegistrationOptions<\n\tInputArgs extends undefined | z.ZodRawShape = undefined,\n\tOutputSchema extends undefined | z.ZodRawShape = undefined,\n\tExpectedOutput = OutputSchema extends z.ZodRawShape ? z.objectOutputType< OutputSchema, z.ZodTypeAny > : string,\n> = {\n\tname: string;\n\tdescription: string;\n\tschema?: InputArgs;\n\t/**\n\t * Auto added fields:\n\t * @param errors z.string().optional().describe('Error message if the tool failed')\n\t */\n\toutputSchema?: OutputSchema;\n\thandler: InputArgs extends z.ZodRawShape\n\t\t? (\n\t\t\t\targs: z.objectOutputType< InputArgs, z.ZodTypeAny >,\n\t\t\t\textra: RequestHandlerExtra< ServerRequest, ServerNotification >\n\t\t ) => ExpectedOutput | Promise< ExpectedOutput >\n\t\t: (\n\t\t\t\targs: unknown,\n\t\t\t\textra: RequestHandlerExtra< ServerRequest, ServerNotification >\n\t\t ) => ExpectedOutput | Promise< ExpectedOutput >;\n\tisDestructive?: boolean;\n\trequiredResources?: ResourceList;\n\tmodelPreferences?: AngieModelPreferences;\n};\n\nfunction createToolRegistry( server: McpServer, serverName: string, serverDocsUri?: string ) {\n\tfunction addTool<\n\t\tT extends undefined | z.ZodRawShape = undefined,\n\t\tO extends undefined | z.ZodRawShape = undefined,\n\t>( opts: ToolRegistrationOptions< T, O > ) {\n\t\tconst outputSchema = opts.outputSchema as ZodRawShape | undefined;\n\t\tif ( outputSchema ) {\n\t\t\tObject.assign(\n\t\t\t\toutputSchema,\n\t\t\t\toutputSchema.errors ?? {\n\t\t\t\t\terrors: z.string().optional().describe( 'Error message if the tool failed' ),\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t\t// @ts-ignore: TS is unable to infer the type here\n\t\tconst inputSchema: ZodRawShape = opts.schema ? opts.schema : {};\n\t\tconst toolCallback: ToolCallback< ZodRawShape > = async function ( args, extra ) {\n\t\t\ttry {\n\t\t\t\tconst invocationResult = await opts.handler( opts.schema ? args : {}, extra );\n\t\t\t\treturn {\n\t\t\t\t\t// structuredContent: typeof invocationResult === 'string' ? undefined : invocationResult,\n\t\t\t\t\tcontent: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: 'text',\n\t\t\t\t\t\t\ttext:\n\t\t\t\t\t\t\t\ttypeof invocationResult === 'string'\n\t\t\t\t\t\t\t\t\t? invocationResult\n\t\t\t\t\t\t\t\t\t: JSON.stringify( invocationResult ),\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t};\n\t\t\t} catch ( error ) {\n\t\t\t\treturn {\n\t\t\t\t\tisError: true,\n\t\t\t\t\tstructuredContent: {\n\t\t\t\t\t\terrors: ( error as Error ).message || 'Unknown error',\n\t\t\t\t\t},\n\t\t\t\t\tcontent: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: 'text',\n\t\t\t\t\t\t\ttext:\n\t\t\t\t\t\t\t\t( ( error as Error ).message || 'Unknown error' ) +\n\t\t\t\t\t\t\t\tJSON.stringify( ( error as { response?: { data: unknown } } ).response?.data || error ),\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t};\n\t\t\t}\n\t\t};\n\t\tconst annotations: Record< string, unknown > = {\n\t\t\tdestructiveHint: opts.isDestructive,\n\t\t\treadOnlyHint: opts.isDestructive ? false : undefined,\n\t\t\ttitle: opts.name,\n\t\t};\n\t\tconst mergedResources = mergeRequiredResources( opts.requiredResources, serverDocsUri );\n\t\tconst angieAnnotations = {\n\t\t\t[ ANGIE_MODEL_PREFERENCES ]: opts.modelPreferences ?? createDefaultModelPreferences(),\n\t\t\t[ ANGIE_REQUIRED_RESOURCES ]: mergedResources,\n\t\t};\n\t\tserver.registerTool(\n\t\t\topts.name,\n\t\t\t{\n\t\t\t\tdescription: opts.description,\n\t\t\t\tinputSchema,\n\t\t\t\t// TODO: Uncomment this when the outputSchema is stable\n\t\t\t\t// outputSchema,\n\t\t\t\ttitle: opts.name,\n\t\t\t\tannotations,\n\t\t\t\t_meta: angieAnnotations,\n\t\t\t},\n\t\t\ttoolCallback\n\t\t);\n\t\tconst toolDescriptor = {\n\t\t\tname: opts.name,\n\t\t\tdescription: opts.description,\n\t\t\tinputSchema: inputSchema as object,\n\t\t\texecute: ( params: Record< string, unknown > ) =>\n\t\t\t\ttoolCallback(\n\t\t\t\t\tparams as Parameters< typeof toolCallback >[ 0 ],\n\t\t\t\t\t/* WebMCP: no protocol session — handlers must not rely on `extra` here */\n\t\t\t\t\t{} as RequestHandlerExtra< ServerRequest, ServerNotification >\n\t\t\t\t) as Promise< unknown >,\n\t\t};\n\t\tconst extraData = {\n\t\t\tresources: [ `Server resource name: ${ serverName }, Required to fetch!` ],\n\t\t\trequiredResources: mergedResources?.map( ( resource ) => resource.uri ) ?? [],\n\t\t};\n\t\tbufferedTools.push( [ toolDescriptor, extraData ] );\n\t\tcallAdapters( ( adapter ) => adapter.onToolRegistered( toolDescriptor, extraData ) );\n\t\tif ( isMcpRegistrationActivated ) {\n\t\t\tserver.sendToolListChanged();\n\t\t}\n\t}\n\treturn {\n\t\taddTool,\n\t};\n}\n","import { zodToJsonSchema } from 'zod-to-json-schema';\nimport { z, type z3 } from '@elementor/schema';\n\nimport { type ModelContextRegisterTool, registerModelContextTool } from '../utils/register-model-context-tool';\nimport {\n\ttype IMcpRegistrationAdapter,\n\ttype McpResourceHandler,\n\ttype McpResourceUriOrTemplate,\n\ttype McpToolDescriptor,\n\ttype UriTemplate,\n} from './types';\n\ntype ZodRawShape = z3.ZodRawShape;\n\nexport type ModelContext = {\n\tregisterTool: ModelContextRegisterTool;\n\tunregisterTool?: ( name: string ) => void;\n};\n\ntype ResourceEntry = {\n\tpattern: string;\n\tmatch: ( uri: string ) => Record< string, string | string[] > | null;\n\thandler: McpResourceHandler;\n};\n\nexport class WebMCPAdapter implements IMcpRegistrationAdapter {\n\tprivate readonly registeredToolNames = new Set< string >();\n\tprivate readonly resourceEntries: ResourceEntry[] = [];\n\tprivate activated = false;\n\n\tconstructor( private readonly ctx: ModelContext ) {}\n\n\tactivate(): Promise< void > {\n\t\tif ( this.activated ) {\n\t\t\treturn Promise.resolve();\n\t\t}\n\t\tthis.activated = true;\n\t\treturn registerModelContextTool( this.ctx.registerTool, {\n\t\t\tname: 'editor-resource-getter',\n\t\t\tdescription:\n\t\t\t\t'Get an editor resource by URI, or search for available resources by partial URI. Pass a full URI to retrieve content, or a partial string to discover matching patterns.',\n\t\t\tinputSchema: {\n\t\t\t\ttype: 'object',\n\t\t\t\tproperties: {\n\t\t\t\t\turi: {\n\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t'A full resource URI (e.g. elementor://style/best-practices) or a partial string to search across available resource patterns.',\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\trequired: [ 'uri' ],\n\t\t\t},\n\t\t\texecute: async ( params ) => {\n\t\t\t\tconst query = params.uri as string;\n\t\t\t\tconst entries = this.resourceEntries;\n\n\t\t\t\tif ( entries.length === 0 ) {\n\t\t\t\t\treturn 'No resources are registered yet.';\n\t\t\t\t}\n\n\t\t\t\t// Exact URI match\n\t\t\t\tfor ( const entry of entries ) {\n\t\t\t\t\tconst variables = entry.match( query );\n\t\t\t\t\tif ( variables !== null ) {\n\t\t\t\t\t\tlet resourceUrl: URL;\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tresourceUrl = new URL( query );\n\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\treturn `Invalid URI '${ query }'. Provide a valid resource URI or a partial string to search patterns.`;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst result = await entry.handler( resourceUrl, variables );\n\t\t\t\t\t\treturn result.contents?.[ 0 ]?.text ?? JSON.stringify( result );\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Partial search fallback\n\t\t\t\tconst matches = entries.map( ( e ) => e.pattern ).filter( ( pattern ) => pattern.includes( query ) );\n\t\t\t\tif ( matches.length > 0 ) {\n\t\t\t\t\treturn `Found ${ matches.length } matching resource pattern(s):\\n${ matches.join(\n\t\t\t\t\t\t'\\n'\n\t\t\t\t\t) }\\n\\nProvide a full URI to retrieve the resource content.`;\n\t\t\t\t}\n\n\t\t\t\tconst available = entries.map( ( e ) => e.pattern ).join( '\\n' );\n\t\t\t\tthrow new Error( `No resource matched '${ query }'.\\n\\nAvailable patterns:\\n${ available }` );\n\t\t\t},\n\t\t} );\n\t}\n\n\tonToolRegistered(\n\t\ttool: McpToolDescriptor,\n\t\textraData?: { resources: string[]; requiredResources: string[] }\n\t): void {\n\t\tlet jsonSchema: object;\n\t\ttry {\n\t\t\tjsonSchema = zodToJsonSchema( z.object( tool.inputSchema as ZodRawShape ) );\n\t\t} catch {\n\t\t\tjsonSchema = tool.inputSchema;\n\t\t}\n\n\t\tif ( this.registeredToolNames.has( tool.name ) ) {\n\t\t\tthis.ctx.unregisterTool?.( tool.name );\n\t\t\tthis.registeredToolNames.delete( tool.name );\n\t\t}\n\n\t\tlet resourcesDescription = '';\n\t\tif ( extraData ) {\n\t\t\tif ( extraData.resources?.length > 0 ) {\n\t\t\t\tresourcesDescription += `#Resources:\\n${ extraData.resources?.join( '\\n' ) }\\n\\n`;\n\t\t\t}\n\t\t\tif ( extraData.requiredResources?.length > 0 ) {\n\t\t\t\tresourcesDescription += `#Required Resources:\\n${ extraData.requiredResources?.join( '\\n' ) }\\n\\n`;\n\t\t\t}\n\t\t\tresourcesDescription += `To read resources, use editor-resource-getter tool.\\n\\n`;\n\t\t}\n\t\tvoid registerModelContextTool( this.ctx.registerTool, {\n\t\t\tname: tool.name,\n\t\t\tdescription: `${ resourcesDescription }${ tool.description }`,\n\t\t\tinputSchema: jsonSchema,\n\t\t\texecute: tool.execute,\n\t\t} ).then( () => {\n\t\t\tthis.registeredToolNames.add( tool.name );\n\t\t} );\n\t}\n\n\tonResourceRegistered( _name: string, uriOrTemplate: McpResourceUriOrTemplate, handler: McpResourceHandler ): void {\n\t\tif ( typeof uriOrTemplate === 'string' ) {\n\t\t\tthis.resourceEntries.push( {\n\t\t\t\tpattern: uriOrTemplate,\n\t\t\t\tmatch: ( uri ) => ( uri === uriOrTemplate ? {} : null ),\n\t\t\t\thandler,\n\t\t\t} );\n\t\t} else {\n\t\t\tconst template = uriOrTemplate.uriTemplate as UriTemplate;\n\t\t\tthis.resourceEntries.push( {\n\t\t\t\tpattern: template.toString(),\n\t\t\t\tmatch: ( uri ) => template.match( uri ),\n\t\t\t\thandler,\n\t\t\t} );\n\t\t}\n\t}\n\n\tsendResourceUpdated(): void {\n\t\t// WebMCP has no server-push mechanism — no-op\n\t}\n}\n","import { type McpToolDescriptor } from '../adapters/types';\n\nexport type ModelContextRegisterTool = ( tool: McpToolDescriptor ) => void | Promise< void >;\n\nexport async function registerModelContextTool(\n\tregisterTool: ModelContextRegisterTool,\n\ttool: McpToolDescriptor\n): Promise< void > {\n\ttry {\n\t\tawait Promise.resolve( registerTool( tool ) );\n\t} catch ( error ) {\n\t\t/* eslint-disable-next-line no-console */\n\t\tconsole.error( 'Tool registration failed:', error );\n\t}\n}\n","export const ANGIE_MODEL_PREFERENCES = 'angie/modelPreferences' as const;\nexport const ANGIE_REQUIRED_RESOURCES = 'angie/requiredResources' as const;\n\nexport interface AngieModelPreferences {\n\thints?: Array< { name: string } >;\n\tcostPriority?: number; // 0-1 (future use)\n\tspeedPriority?: number; // 0-1 (future use)\n\tintelligencePriority?: number; // 0-1 (future use)\n}\n\nexport function createDefaultModelPreferences(): AngieModelPreferences {\n\treturn {\n\t\thints: [ { name: 'claude-sonnet-4-6' } ],\n\t};\n}\n","import { type McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\n\nimport { type MCPRegistryEntry } from '../mcp-registry';\n\nconst mock = new Proxy(\n\t{},\n\t{\n\t\tget: () => {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unused-vars\n\t\t\tfunction mockedFn( ..._: unknown[] ) {}\n\t\t\treturn mockedFn;\n\t\t},\n\t}\n);\n\nexport const mockMcpRegistry = (): MCPRegistryEntry => {\n\treturn {\n\t\t// @ts-ignore\n\t\tresource: async () => {},\n\t\t// @ts-ignore\n\t\tsendResourceUpdated: () => {},\n\t\taddTool: () => {},\n\t\tsetMCPDescription: () => {},\n\t\tmcpServer: mock as McpServer,\n\t};\n};\n","import { type ModelContext } from '../adapters/web-mcp-adapter';\n\ntype ModelContextHost = {\n\tmodelContext?: ModelContext;\n};\n\nfunction bindModelContextMethods( host: ModelContext ): ModelContext {\n\treturn {\n\t\tregisterTool: host.registerTool.bind( host ),\n\t\tunregisterTool: host.unregisterTool ? host.unregisterTool.bind( host ) : undefined,\n\t};\n}\n\nexport function getModelContext(): ModelContext | undefined {\n\tconst documentModelContext =\n\t\ttypeof document !== 'undefined' ? ( document as unknown as ModelContextHost ).modelContext : undefined;\n\tif ( documentModelContext?.registerTool ) {\n\t\treturn bindModelContextMethods( documentModelContext );\n\t}\n\tconst navigatorModelContext =\n\t\ttypeof navigator !== 'undefined' ? ( navigator as unknown as ModelContextHost ).modelContext : undefined;\n\tif ( navigatorModelContext?.registerTool ) {\n\t\treturn bindModelContextMethods( navigatorModelContext );\n\t}\n\n\treturn undefined;\n}\n","export type ResourceList = {\n\turi: string;\n\tdescription: string;\n}[];\n\nexport const mergeRequiredResources = (\n\ttoolResources: ResourceList | undefined,\n\tserverDocsUri: string | undefined\n): ResourceList | undefined => {\n\tif ( ! serverDocsUri ) {\n\t\treturn toolResources;\n\t}\n\tif ( toolResources?.some( ( r ) => r.uri === serverDocsUri ) ) {\n\t\treturn toolResources;\n\t}\n\treturn [ ...( toolResources ?? [] ), { uri: serverDocsUri, description: 'Server docs' } ];\n};\n","export const createSimpleResourceHandler = ( text: string ) => async ( uri: URL ) => ( {\n\tcontents: [ { uri: uri.href, mimeType: 'text/plain', text } ],\n} );\n","import { type McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\n\nimport { type IMcpRegistrationAdapter } from '../adapters/types';\nimport { createSimpleResourceHandler } from './create-simple-resource-handler';\n\ntype OnResourceRegistered = ( ...args: Parameters< IMcpRegistrationAdapter[ 'onResourceRegistered' ] > ) => void;\n\nexport const registerServerDocsResource = (\n\tserver: McpServer,\n\tnamespace: string,\n\ttitle: string,\n\tdocs: string,\n\tonRegistered: OnResourceRegistered\n): void => {\n\tconst uri = `elementor://${ namespace }/server-docs`;\n\tconst name = `${ namespace }-server-docs`;\n\tconst handler = createSimpleResourceHandler( docs );\n\tserver.registerResource(\n\t\tname,\n\t\turi,\n\t\t{\n\t\t\ttitle: `${ title } server docs`,\n\t\t\tdescription: 'Full MCP documentation (lazy-loaded)',\n\t\t\tmimeType: 'text/plain',\n\t\t},\n\t\thandler\n\t);\n\tonRegistered( name, uri, handler );\n};\n","export const toMCPTitle = ( namespace: string ): string => {\n\tconst label = namespace\n\t\t.split( '_' )\n\t\t.filter( Boolean )\n\t\t.map( ( word ) => word.charAt( 0 ).toUpperCase() + word.slice( 1 ) )\n\t\t.join( ' ' );\n\n\treturn `Editor ${ label }`;\n};\n","import { type AngieMcpSdk } from '@elementor/editor-angie-sdk';\n\nimport { type getRegisteredMcpServers as _getRegisteredMcpServers } from '../mcp-registry';\nimport { toMCPTitle } from '../utils/to-mcp-title';\nimport { type IMcpRegistrationAdapter } from './types';\n\nconst MAX_RETRIES = 3;\n\nexport class AngieMcpAdapter implements IMcpRegistrationAdapter {\n\tconstructor(\n\t\tprivate readonly sdk: AngieMcpSdk,\n\t\tprivate readonly getRegisteredMcpServers: typeof _getRegisteredMcpServers\n\t) {}\n\n\tasync activate(): Promise< void > {\n\t\t// No waitForReady() here: registerLocalServer queues the server and the SDK flushes\n\t\t// the queue once Angie reports ready.\n\t\tawait this.registerEntries( this.getRegisteredMcpServers(), MAX_RETRIES );\n\t}\n\n\tprivate async registerEntries(\n\t\tentries: ReturnType< typeof _getRegisteredMcpServers >,\n\t\tretry: number\n\t): Promise< void > {\n\t\tif ( retry === 0 ) {\n\t\t\t/* eslint-disable-next-line no-console */\n\t\t\tconsole.error(\n\t\t\t\t'Failed to register MCP after 3 retries. failed entries: ',\n\t\t\t\tentries.map( ( [ key ] ) => key )\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tconst failed: typeof entries = [];\n\t\tfor ( const [ key, mcpServer, description ] of entries ) {\n\t\t\ttry {\n\t\t\t\tawait this.sdk.registerLocalServer( {\n\t\t\t\t\ttitle: toMCPTitle( key ),\n\t\t\t\t\tname: `editor-${ key }`,\n\t\t\t\t\tserver: mcpServer,\n\t\t\t\t\tversion: '1.0.0',\n\t\t\t\t\tdescription,\n\t\t\t\t} );\n\t\t\t} catch {\n\t\t\t\tfailed.push( [ key, mcpServer, description ] );\n\t\t\t}\n\t\t}\n\n\t\tif ( failed.length > 0 ) {\n\t\t\treturn this.registerEntries( failed, retry - 1 );\n\t\t}\n\t}\n\n\tonToolRegistered(): void {\n\t\t// Angie tools are registered via McpServer (at activate time).\n\t}\n\n\tonResourceRegistered(): void {\n\t\t// Resources are registered on the McpServer instance directly.\n\t}\n\n\tsendResourceUpdated(): void {\n\t\t// Resource update notifications are sent via MCPRegistryEntry.sendResourceUpdated.\n\t}\n}\n","import { type z } from '@elementor/schema';\nimport { type RequestHandlerExtra } from '@modelcontextprotocol/sdk/shared/protocol.js';\nimport { SamplingMessageSchema, type ServerNotification, type ServerRequest } from '@modelcontextprotocol/sdk/types.js';\n\ntype Server = RequestHandlerExtra< ServerRequest, ServerNotification >;\ntype Opts = {\n\tmaxTokens?: number;\n\tmodelPreferences?: string;\n\tmodel?: string;\n};\n\nconst DEFAULT_OPTS: Opts = {\n\tmaxTokens: 10000,\n\tmodelPreferences: 'openai',\n\tmodel: 'gpt-4o',\n};\n\ntype SamplingOpts = {\n\tsystemPrompt?: string;\n\tstructuredOutput?: z.ZodTypeAny;\n\tmessages: { role: 'user' | 'assistant'; content: { type: 'text'; text: string } }[];\n\trequestParams?: { [ key: string ]: string };\n};\n\nconst DEFAULT_STRUCTURED_OUTPUT = {\n\ttype: 'object',\n\tproperties: {\n\t\tcontent: {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Result',\n\t\t},\n\t},\n\trequired: [ 'content' ],\n\tadditionalProperties: false,\n};\n\nexport const createSampler = ( server: Server, opts: Opts = DEFAULT_OPTS ) => {\n\tconst { maxTokens = 1000, modelPreferences = 'openai', model = 'gpt-4o' } = opts;\n\tconst exec = async ( payload: SamplingOpts ) => {\n\t\tconst systemPromptObject = { ...( payload.systemPrompt ? { systemPrompt: payload.systemPrompt } : {} ) };\n\t\tconst requestParams = payload.requestParams || {};\n\t\tconst result = await server.sendRequest(\n\t\t\t{\n\t\t\t\tmethod: 'sampling/createMessage',\n\t\t\t\tparams: {\n\t\t\t\t\t...requestParams,\n\t\t\t\t\tmaxTokens,\n\t\t\t\t\tmodelPreferences: {\n\t\t\t\t\t\thints: [ { name: modelPreferences } ],\n\t\t\t\t\t},\n\t\t\t\t\tmetadata: {\n\t\t\t\t\t\tmodel,\n\t\t\t\t\t\t...systemPromptObject,\n\t\t\t\t\t\t...{ structured_output: payload.structuredOutput || DEFAULT_STRUCTURED_OUTPUT },\n\t\t\t\t\t},\n\t\t\t\t\tmessages: payload.messages,\n\t\t\t\t},\n\t\t\t\t// ...systemPromptObject,\n\t\t\t},\n\t\t\tSamplingMessageSchema\n\t\t);\n\t\treturn result.content;\n\t};\n\treturn exec;\n};\n","class ToolPrompts {\n\tpublic _description = '';\n\tpublic _parameters: Record< string, string > = {};\n\tpublic _examples: string[] = [];\n\tpublic _furtherInstructions: string[] = [];\n\n\tconstructor( public name: string ) {}\n\n\tdescription(): string;\n\tdescription( desc: string ): this;\n\tdescription( desc?: string | undefined ) {\n\t\tif ( typeof desc === 'undefined' ) {\n\t\t\treturn this._description;\n\t\t}\n\t\tthis._description = desc;\n\t\treturn this;\n\t}\n\n\tparameter( key: string ): string;\n\tparameter( key: string, description: string ): this;\n\tparameter( key: string, description?: string ) {\n\t\tif ( typeof description === 'undefined' ) {\n\t\t\treturn this._parameters[ key ];\n\t\t}\n\t\tthis._parameters[ key ] = `**${ key }**:\\n${ description }`;\n\t\treturn this;\n\t}\n\n\tinstruction( instruction: string ): this {\n\t\tthis._furtherInstructions.push( instruction );\n\t\treturn this;\n\t}\n\n\texample( example: string ): this {\n\t\tthis._examples.push( example );\n\t\treturn this;\n\t}\n\n\tpublic get examples() {\n\t\treturn this._examples.join( '\\n\\n' );\n\t}\n\n\tprompt(): string {\n\t\treturn `# ${ this.name }\n# Description\n${ this._description }\n${ this._parameters.length ? '# Parameters\\n' + Object.values( this._parameters ).join( '\\n\\n' ) : '' }\n${ this._examples.length ? '# Examples\\n' + this.examples : '' }\n${ this._furtherInstructions.length ? '# Further Instructions\\n' + this._furtherInstructions.join( '\\n\\n' ) : '' }\n`.trim();\n\t}\n}\n\nexport const toolPrompts = ( name: string ) => {\n\treturn new ToolPrompts( name );\n};\n","export type ActiveChatInfo = {\n\tsessionId: string;\n\texpiresAt: number;\n};\n\nexport const getActiveChatInfo = (): ActiveChatInfo => {\n\tconst info = localStorage.getItem( 'angie_active_chat_id' );\n\tif ( ! info ) {\n\t\treturn {\n\t\t\texpiresAt: 0,\n\t\t\tsessionId: '',\n\t\t};\n\t}\n\tconst rawData = JSON.parse( info );\n\treturn {\n\t\texpiresAt: rawData.expiresAt as number,\n\t\tsessionId: rawData.sessionId as string,\n\t};\n};\n","import {\n\tAngieInteractionMode,\n\tgetAngieIframe,\n\tsetAngieInteractionMode,\n\ttoggleAngieSidebar,\n} from '@elementor/editor-angie-sdk';\n\nimport { isAngieAvailable } from './is-angie-available';\n\nconst getLoadedEditorAngie = () => {\n\treturn window.elementorV2?.editorAngie?.openAngie;\n};\n\nexport const hasLoadedEditorAngie = (): boolean => Boolean( getLoadedEditorAngie() );\n\nexport const openLoadedEditorAngie = ( prompt: string | undefined, mode: AngieInteractionMode ): boolean => {\n\tconst openAngie = getLoadedEditorAngie();\n\n\tif ( ! openAngie ) {\n\t\treturn false;\n\t}\n\n\tPromise.resolve( openAngie( { prompt: prompt ?? '', mode } ) ).catch( ( error ) => {\n\t\t// eslint-disable-next-line no-console\n\t\tconsole.error( 'Failed to open Angie:', error );\n\t} );\n\n\treturn true;\n};\n\nexport const openAngieInAskMode = ( prompt?: string ): void => {\n\topenAngieInMode( prompt, AngieInteractionMode.ASK );\n};\n\nexport const openAngieInAgentMode = ( prompt?: string ): void => {\n\topenAngieInMode( prompt, AngieInteractionMode.AGENT );\n};\n\nconst openAngieInMode = ( prompt: string | undefined, mode: AngieInteractionMode ): void => {\n\tif ( openLoadedEditorAngie( prompt, mode ) ) {\n\t\treturn;\n\t}\n\n\tif ( ! isAngieAvailable() ) {\n\t\treturn;\n\t}\n\n\tconst angieSidebar = getAngieIframe();\n\n\tif ( ! angieSidebar ) {\n\t\treturn;\n\t}\n\n\ttoggleAngieSidebar( angieSidebar, true );\n\tsetAngieInteractionMode( mode );\n\n\tif ( prompt ) {\n\t\twindow.location.hash = `angie-prompt=${ encodeURIComponent( prompt ) }`;\n\t}\n};\n","import { AngieInteractionMode, getAngieIframe, toggleAngieSidebar } from '@elementor/editor-angie-sdk';\n\nimport { openLoadedEditorAngie } from './open-angie-in-ask-mode';\n\nexport const sendPromptToAngie = ( prompt?: string ) => {\n\tif ( openLoadedEditorAngie( prompt, AngieInteractionMode.AGENT ) ) {\n\t\treturn;\n\t}\n\n\tconst angieSidebar = getAngieIframe();\n\n\tif ( ! angieSidebar ) {\n\t\treturn;\n\t}\n\n\ttoggleAngieSidebar( angieSidebar, true );\n\n\tif ( ! prompt ) {\n\t\treturn;\n\t}\n\n\twindow.location.hash = `angie-prompt=${ encodeURIComponent( prompt ) }`;\n};\n","import { setReferrerRedirect } from '@elementor/editor-angie-sdk';\n\nconst ANGIE_INSTALL_URL = '/wp-admin/plugin-install.php?s=angie&tab=search&type=term';\n\n/**\n * @deprecated Kept only for Elementor Pro compatibility. Will be removed in a future version.\n * @param prompt Optional prompt to pass after redirect.\n */\nexport const redirectToInstallation = ( prompt?: string ) => {\n\tsetReferrerRedirect( window.location.href, prompt );\n\twindow.location.href = ANGIE_INSTALL_URL;\n};\n","import { ANGIE_SIDEBAR_STATE_OPEN, saveState, setReferrerRedirect } from '@elementor/editor-angie-sdk';\n\nconst ANGIE_APP_URL = '/wp-admin/admin.php?page=angie-app';\n\n/**\n * @deprecated Kept only for Elementor Pro compatibility. Will be removed in a future version.\n * @param prompt Optional prompt to pass after redirect.\n */\nexport const redirectToAppAdmin = ( prompt?: string ) => {\n\tsetReferrerRedirect( window.location.href, prompt );\n\tsaveState( ANGIE_SIDEBAR_STATE_OPEN );\n\twindow.location.href = ANGIE_APP_URL;\n};\n","import apiFetch from '@wordpress/api-fetch';\n\ntype PluginResponse = {\n\tplugin: string;\n\tstatus: 'active' | 'inactive';\n\tname: string;\n};\n\ntype PluginErrorResponse = {\n\tcode: string;\n\tmessage: string;\n};\n\nexport type InstallAngieResult = { success: true } | { success: false; error: string; code?: string };\n\nconst ANGIE_SLUG = 'angie';\n\nconst isPluginErrorResponse = ( response: unknown ): response is PluginErrorResponse => {\n\treturn typeof response === 'object' && response !== null && 'code' in response && 'message' in response;\n};\n\nconst activatePlugin = async ( pluginPath: string ): Promise< PluginResponse > => {\n\treturn apiFetch< PluginResponse >( {\n\t\tpath: `/wp/v2/plugins/${ pluginPath }`,\n\t\tmethod: 'POST',\n\t\tdata: { status: 'active' },\n\t} );\n};\n\nconst installPlugin = async (): Promise< PluginResponse > => {\n\ttry {\n\t\treturn await apiFetch< PluginResponse >( {\n\t\t\tpath: '/wp/v2/plugins',\n\t\t\tmethod: 'POST',\n\t\t\tdata: {\n\t\t\t\tslug: ANGIE_SLUG,\n\t\t\t\tstatus: 'active',\n\t\t\t},\n\t\t} );\n\t} catch ( error: unknown ) {\n\t\tif ( isPluginErrorResponse( error ) && error.code === 'folder_exists' ) {\n\t\t\treturn activatePlugin( `${ ANGIE_SLUG }/${ ANGIE_SLUG }` );\n\t\t}\n\n\t\tthrow error;\n\t}\n};\n\n/**\n * @deprecated Kept only for Elementor Pro compatibility. Will be removed in a future version.\n */\nexport const installAngiePlugin = async (): Promise< InstallAngieResult > => {\n\ttry {\n\t\tawait installPlugin();\n\n\t\treturn { success: true };\n\t} catch ( error: unknown ) {\n\t\tif ( isPluginErrorResponse( error ) ) {\n\t\t\treturn { success: false, error: error.message, code: error.code };\n\t\t}\n\n\t\treturn { success: false, error: 'Unknown error occurred' };\n\t}\n};\n","import apiFetch from '@wordpress/api-fetch';\n\nexport const saveAngieConsent = async (): Promise< void > => {\n\tawait apiFetch( {\n\t\tpath: '/elementor/v1/angie/consent',\n\t\tmethod: 'POST',\n\t} );\n};\n","import { createAndRegisterAdapters, signalMcpReady } from './mcp-registry';\n\nlet isInitialized = false;\nexport async function startMCPServer() {\n\tif ( isInitialized ) {\n\t\treturn;\n\t}\n\tisInitialized = true;\n\ttry {\n\t\tawait createAndRegisterAdapters();\n\t} catch ( error ) {\n\t\t/* eslint-disable-next-line no-console */\n\t\tconsole.error( 'MCP adapter activation failed:', error );\n\t} finally {\n\t\tsignalMcpReady();\n\t}\n}\n\n// Start right away when the bundle loads after DOMContentLoaded (late or deferred load): the event will\n// not fire again, and `waitForMcpReady()` callers would wait forever.\nif ( typeof document !== 'undefined' && document.readyState === 'loading' ) {\n\tdocument.addEventListener( 'DOMContentLoaded', () => void startMCPServer(), { once: true } );\n} else {\n\tvoid startMCPServer();\n}\n","export const MCP_STYLES_APPLIED_EVENT = 'elementor/mcp/styles-applied';\n\nexport type McpStylesAppliedPayload = {\n\tstyleValue: Record< string, unknown >;\n};\n\nexport function dispatchMcpStylesAppliedEvent( payload: McpStylesAppliedPayload ): void {\n\twindow.dispatchEvent( new CustomEvent( MCP_STYLES_APPLIED_EVENT, { detail: payload } ) );\n}\n"],"mappings":";AAEA,SAAS,kBAAAA,iBAAgB,aAAiC,wBAA8B;AAExF;AAAA,EACC,aAAAC;AAAA,EACA;AAAA,OAGM;AACP,SAAS,yBAAAC,8BAA6B;;;ACVtC,SAAS,sBAAsB;AAExB,IAAM,mBAAmB,MAAe;AAC9C,SAAO,CAAC,CAAE,eAAe;AAC1B;;;ACJO,IAAM,kBAA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A6B;AAC5D,QAAMA,UAAU;AAAA,IACf,MAAM;AAAA,IACN,QAAQ;AAAA,EACT,CAAE;AACH;;;ACLA,IAAI,gBAAgB;AACpB,eAAsB,iBAAiB;AACtC,MAAK,eAAgB;AACpB;AAAA,EACD;AACA,kBAAgB;AAChB,MAAI;AACH,UAAM,0BAA0B;AAAA,EACjC,SAAU,OAAQ;AAEjB,YAAQ,MAAO,kCAAkC,KAAM;AAAA,EACxD,UAAE;AACD,mBAAe;AAAA,EAChB;AACD;AAIA,IAAK,OAAO,aAAa,eAAe,SAAS,eAAe,WAAY;AAC3E,WAAS,iBAAkB,oBAAoB,MAAM,KAAK,eAAe,GAAG,EAAE,MAAM,KAAK,CAAE;AAC5F,OAAO;AACN,OAAK,eAAe;AACrB;;;ACxBO,IAAM,2BAA2B;AAMjC,SAAS,8BAA+B,SAAyC;AACvF,SAAO,cAAe,IAAI,YAAa,0BAA0B,EAAE,QAAQ,QAAQ,CAAE,CAAE;AACxF;","names":["getAngieIframe","McpServer","SamplingMessageSchema","z","z","getRegisteredMcpServers","getAngieIframe","getAngieIframe","AngieInteractionMode","getAngieIframe","toggleAngieSidebar","AngieInteractionMode","getAngieIframe","toggleAngieSidebar","ANGIE_SIDEBAR_STATE_OPEN","setReferrerRedirect","apiFetch"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elementor/editor-mcp",
|
|
3
|
-
"version": "4.5.0-
|
|
3
|
+
"version": "4.5.0-1221",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "Elementor Team",
|
|
6
6
|
"homepage": "https://elementor.com/",
|
|
@@ -42,10 +42,10 @@
|
|
|
42
42
|
"tsup": "^8.3.5"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@elementor-
|
|
46
|
-
"@elementor/editor-v1-adapters": "4.5.0-
|
|
47
|
-
"@elementor/schema": "4.5.0-
|
|
48
|
-
"@elementor/store": "4.5.0-
|
|
45
|
+
"@elementor/editor-angie-sdk": "4.5.0-1221",
|
|
46
|
+
"@elementor/editor-v1-adapters": "4.5.0-1221",
|
|
47
|
+
"@elementor/schema": "4.5.0-1221",
|
|
48
|
+
"@elementor/store": "4.5.0-1221",
|
|
49
49
|
"@modelcontextprotocol/sdk": "1.32.2",
|
|
50
50
|
"@wordpress/api-fetch": "^6.42.0",
|
|
51
51
|
"zod-to-json-schema": "3.24.6"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type AngieMcpSdk } from '@elementor-
|
|
1
|
+
import { type AngieMcpSdk } from '@elementor/editor-angie-sdk';
|
|
2
2
|
|
|
3
3
|
import { type getRegisteredMcpServers as _getRegisteredMcpServers } from '../mcp-registry';
|
|
4
4
|
import { toMCPTitle } from '../utils/to-mcp-title';
|
|
@@ -14,8 +14,7 @@ export class AngieMcpAdapter implements IMcpRegistrationAdapter {
|
|
|
14
14
|
|
|
15
15
|
async activate(): Promise< void > {
|
|
16
16
|
// No waitForReady() here: registerLocalServer queues the server and the SDK flushes
|
|
17
|
-
// the queue once Angie reports ready.
|
|
18
|
-
// that booted the sidebar, which is the host integration, never the editor bundle.
|
|
17
|
+
// the queue once Angie reports ready.
|
|
19
18
|
await this.registerEntries( this.getRegisteredMcpServers(), MAX_RETRIES );
|
|
20
19
|
}
|
|
21
20
|
|
package/src/index.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import './types/open-angie-request';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
export { getAngieIframe, MessageEventType as AngieMessageEvenetType } from './utils/get-sdk';
|
|
3
|
+
export { getAngieIframe, getAngieSdk, MessageEventType as AngieMessageEvenetType } from '@elementor/editor-angie-sdk';
|
|
5
4
|
|
|
6
5
|
export {
|
|
7
6
|
McpServer,
|
|
@@ -33,7 +32,6 @@ export { redirectToInstallation } from './utils/redirect-to-installation';
|
|
|
33
32
|
export { redirectToAppAdmin } from './utils/redirect-to-app-admin';
|
|
34
33
|
export { installAngiePlugin, type InstallAngieResult } from './utils/install-angie-plugin';
|
|
35
34
|
export { saveAngieConsent } from './utils/save-angie-consent';
|
|
36
|
-
export const getAngieSdk = () => getSDK();
|
|
37
35
|
export * from './init';
|
|
38
36
|
export {
|
|
39
37
|
dispatchMcpStylesAppliedEvent,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ANGIE_SIDEBAR_STATE_OPEN, getAngieSidebarSavedState } from '@elementor-
|
|
1
|
+
import { ANGIE_SIDEBAR_STATE_OPEN, getAngieSidebarSavedState } from '@elementor/editor-angie-sdk';
|
|
2
2
|
|
|
3
3
|
export const isAngieSidebarOpen = (): boolean => {
|
|
4
4
|
return getAngieSidebarSavedState() === ANGIE_SIDEBAR_STATE_OPEN;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ANGIE_SIDEBAR_STATE_OPEN, saveState, setReferrerRedirect } from '@elementor-
|
|
1
|
+
import { ANGIE_SIDEBAR_STATE_OPEN, saveState, setReferrerRedirect } from '@elementor/editor-angie-sdk';
|
|
2
2
|
|
|
3
3
|
const ANGIE_APP_URL = '/wp-admin/admin.php?page=angie-app';
|
|
4
4
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AngieInteractionMode, getAngieIframe, toggleAngieSidebar } from '@elementor-
|
|
1
|
+
import { AngieInteractionMode, getAngieIframe, toggleAngieSidebar } from '@elementor/editor-angie-sdk';
|
|
2
2
|
|
|
3
3
|
import { openLoadedEditorAngie } from './open-angie-in-ask-mode';
|
|
4
4
|
|
package/src/utils/get-sdk.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { AngieMcpSdk } from '@elementor-external/angie-sdk';
|
|
2
|
-
export { getAngieIframe, MessageEventType } from '@elementor-external/angie-sdk';
|
|
3
|
-
|
|
4
|
-
let sdk: AngieMcpSdk;
|
|
5
|
-
|
|
6
|
-
class RetriableAngieSDK extends AngieMcpSdk {
|
|
7
|
-
public async waitForReady(): Promise< void > {
|
|
8
|
-
let retryCount = 3;
|
|
9
|
-
while ( retryCount > 0 ) {
|
|
10
|
-
try {
|
|
11
|
-
await super.waitForReady();
|
|
12
|
-
return;
|
|
13
|
-
} catch {
|
|
14
|
-
retryCount--;
|
|
15
|
-
await sleep();
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
return new Promise( () => {} ); // never resolves
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const sleep = ( ms = 10_000 ) =>
|
|
23
|
-
new Promise( ( resolve ) => {
|
|
24
|
-
setTimeout( resolve, ms );
|
|
25
|
-
} );
|
|
26
|
-
|
|
27
|
-
export const getSDK = () => {
|
|
28
|
-
// @ts-ignore - QUnit fails this
|
|
29
|
-
const isMCPDisabled = !! ( globalThis as Record< string, unknown > ).__ELEMENTOR_MCP_DISABLED__;
|
|
30
|
-
if ( isMCPDisabled ) {
|
|
31
|
-
return {} as unknown as AngieMcpSdk;
|
|
32
|
-
}
|
|
33
|
-
if ( ! sdk ) {
|
|
34
|
-
sdk = new RetriableAngieSDK();
|
|
35
|
-
}
|
|
36
|
-
return sdk;
|
|
37
|
-
};
|