@elementor/editor-mcp 4.4.0 → 4.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +22 -2
- package/dist/index.d.ts +22 -2
- package/dist/index.js +75 -58
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +70 -57
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
- package/src/index.ts +3 -1
- package/src/init.ts +3 -1
- package/src/mcp-registry.ts +14 -7
- package/src/utils/open-angie-in-ask-mode.ts +10 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _elementor_external_angie_sdk from '@elementor-external/angie-sdk';
|
|
2
|
-
import { AngieInteractionMode, AngieTriggerRequest } from '@elementor-external/angie-sdk';
|
|
2
|
+
import { AngieInteractionMode, AngieTriggerRequest, AngieMcpSdk } from '@elementor-external/angie-sdk';
|
|
3
3
|
export { MessageEventType as AngieMessageEvenetType, getAngieIframe } from '@elementor-external/angie-sdk';
|
|
4
4
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
5
5
|
export { McpServer, RegisteredResource, ResourceTemplate, ToolCallback } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
@@ -99,6 +99,14 @@ type ResourceList = {
|
|
|
99
99
|
|
|
100
100
|
declare const registerMcpAdapter: (adapter: IMcpRegistrationAdapter) => void;
|
|
101
101
|
declare const signalMcpReady: () => void;
|
|
102
|
+
declare const waitForMcpReady: () => Promise<void>;
|
|
103
|
+
/**
|
|
104
|
+
* Registers and activates an adapter that becomes available after startup.
|
|
105
|
+
* Waits for the startup activation so the adapter is activated exactly once.
|
|
106
|
+
*
|
|
107
|
+
* @param adapter - Adapter to register and activate.
|
|
108
|
+
*/
|
|
109
|
+
declare const activateMcpAdapter: (adapter: IMcpRegistrationAdapter) => Promise<void>;
|
|
102
110
|
declare const createAndRegisterAdapters: () => Promise<void>;
|
|
103
111
|
declare const registerMcp: (mcp: McpServer, name: string) => void;
|
|
104
112
|
declare const getRegisteredMcpServers: () => Array<[string, McpServer, string]>;
|
|
@@ -136,6 +144,17 @@ type ToolRegistrationOptions<InputArgs extends undefined | z.ZodRawShape = undef
|
|
|
136
144
|
modelPreferences?: AngieModelPreferences;
|
|
137
145
|
};
|
|
138
146
|
|
|
147
|
+
declare class AngieMcpAdapter implements IMcpRegistrationAdapter {
|
|
148
|
+
private readonly sdk;
|
|
149
|
+
private readonly getRegisteredMcpServers;
|
|
150
|
+
constructor(sdk: AngieMcpSdk, getRegisteredMcpServers: typeof getRegisteredMcpServers);
|
|
151
|
+
activate(): Promise<void>;
|
|
152
|
+
private registerEntries;
|
|
153
|
+
onToolRegistered(): void;
|
|
154
|
+
onResourceRegistered(): void;
|
|
155
|
+
sendResourceUpdated(): void;
|
|
156
|
+
}
|
|
157
|
+
|
|
139
158
|
type Server = RequestHandlerExtra<ServerRequest, ServerNotification>;
|
|
140
159
|
type Opts = {
|
|
141
160
|
maxTokens?: number;
|
|
@@ -412,6 +431,7 @@ declare const getActiveChatInfo: () => ActiveChatInfo;
|
|
|
412
431
|
|
|
413
432
|
declare const hasLoadedEditorAngie: () => boolean;
|
|
414
433
|
declare const openAngieInAskMode: (prompt?: string) => void;
|
|
434
|
+
declare const openAngieInAgentMode: (prompt?: string) => void;
|
|
415
435
|
|
|
416
436
|
declare const sendPromptToAngie: (prompt?: string) => void;
|
|
417
437
|
|
|
@@ -451,4 +471,4 @@ declare function dispatchMcpStylesAppliedEvent(payload: McpStylesAppliedPayload)
|
|
|
451
471
|
|
|
452
472
|
declare const getAngieSdk: () => _elementor_external_angie_sdk.AngieMcpSdk;
|
|
453
473
|
|
|
454
|
-
export { ANGIE_MODEL_PREFERENCES, ANGIE_REQUIRED_RESOURCES, type ActiveChatInfo, type AngieModelPreferences, type EditorAngieWindowHost, type InstallAngieResult, type MCPRegistryEntry, MCP_STYLES_APPLIED_EVENT, type McpStylesAppliedPayload, type OpenAngieCommonProperties, type OpenAngiePluginProperties, type OpenAngieRequest, type OpenAngieSdkProperties, canCreateWidget, createAndRegisterAdapters, createSampler, dispatchMcpStylesAppliedEvent, getActiveChatInfo, getAngieSdk, getMCPByDomain, getRegisteredMcpServers, hasLoadedEditorAngie, installAngiePlugin, isAngieAvailable, isAngieSidebarOpen, openAngieInAskMode, redirectToAppAdmin, redirectToInstallation, registerMcp, registerMcpAdapter, saveAngieConsent, sendPromptToAngie, signalMcpReady, startMCPServer, toolPrompts };
|
|
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _elementor_external_angie_sdk from '@elementor-external/angie-sdk';
|
|
2
|
-
import { AngieInteractionMode, AngieTriggerRequest } from '@elementor-external/angie-sdk';
|
|
2
|
+
import { AngieInteractionMode, AngieTriggerRequest, AngieMcpSdk } from '@elementor-external/angie-sdk';
|
|
3
3
|
export { MessageEventType as AngieMessageEvenetType, getAngieIframe } from '@elementor-external/angie-sdk';
|
|
4
4
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
5
5
|
export { McpServer, RegisteredResource, ResourceTemplate, ToolCallback } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
@@ -99,6 +99,14 @@ type ResourceList = {
|
|
|
99
99
|
|
|
100
100
|
declare const registerMcpAdapter: (adapter: IMcpRegistrationAdapter) => void;
|
|
101
101
|
declare const signalMcpReady: () => void;
|
|
102
|
+
declare const waitForMcpReady: () => Promise<void>;
|
|
103
|
+
/**
|
|
104
|
+
* Registers and activates an adapter that becomes available after startup.
|
|
105
|
+
* Waits for the startup activation so the adapter is activated exactly once.
|
|
106
|
+
*
|
|
107
|
+
* @param adapter - Adapter to register and activate.
|
|
108
|
+
*/
|
|
109
|
+
declare const activateMcpAdapter: (adapter: IMcpRegistrationAdapter) => Promise<void>;
|
|
102
110
|
declare const createAndRegisterAdapters: () => Promise<void>;
|
|
103
111
|
declare const registerMcp: (mcp: McpServer, name: string) => void;
|
|
104
112
|
declare const getRegisteredMcpServers: () => Array<[string, McpServer, string]>;
|
|
@@ -136,6 +144,17 @@ type ToolRegistrationOptions<InputArgs extends undefined | z.ZodRawShape = undef
|
|
|
136
144
|
modelPreferences?: AngieModelPreferences;
|
|
137
145
|
};
|
|
138
146
|
|
|
147
|
+
declare class AngieMcpAdapter implements IMcpRegistrationAdapter {
|
|
148
|
+
private readonly sdk;
|
|
149
|
+
private readonly getRegisteredMcpServers;
|
|
150
|
+
constructor(sdk: AngieMcpSdk, getRegisteredMcpServers: typeof getRegisteredMcpServers);
|
|
151
|
+
activate(): Promise<void>;
|
|
152
|
+
private registerEntries;
|
|
153
|
+
onToolRegistered(): void;
|
|
154
|
+
onResourceRegistered(): void;
|
|
155
|
+
sendResourceUpdated(): void;
|
|
156
|
+
}
|
|
157
|
+
|
|
139
158
|
type Server = RequestHandlerExtra<ServerRequest, ServerNotification>;
|
|
140
159
|
type Opts = {
|
|
141
160
|
maxTokens?: number;
|
|
@@ -412,6 +431,7 @@ declare const getActiveChatInfo: () => ActiveChatInfo;
|
|
|
412
431
|
|
|
413
432
|
declare const hasLoadedEditorAngie: () => boolean;
|
|
414
433
|
declare const openAngieInAskMode: (prompt?: string) => void;
|
|
434
|
+
declare const openAngieInAgentMode: (prompt?: string) => void;
|
|
415
435
|
|
|
416
436
|
declare const sendPromptToAngie: (prompt?: string) => void;
|
|
417
437
|
|
|
@@ -451,4 +471,4 @@ declare function dispatchMcpStylesAppliedEvent(payload: McpStylesAppliedPayload)
|
|
|
451
471
|
|
|
452
472
|
declare const getAngieSdk: () => _elementor_external_angie_sdk.AngieMcpSdk;
|
|
453
473
|
|
|
454
|
-
export { ANGIE_MODEL_PREFERENCES, ANGIE_REQUIRED_RESOURCES, type ActiveChatInfo, type AngieModelPreferences, type EditorAngieWindowHost, type InstallAngieResult, type MCPRegistryEntry, MCP_STYLES_APPLIED_EVENT, type McpStylesAppliedPayload, type OpenAngieCommonProperties, type OpenAngiePluginProperties, type OpenAngieRequest, type OpenAngieSdkProperties, canCreateWidget, createAndRegisterAdapters, createSampler, dispatchMcpStylesAppliedEvent, getActiveChatInfo, getAngieSdk, getMCPByDomain, getRegisteredMcpServers, hasLoadedEditorAngie, installAngiePlugin, isAngieAvailable, isAngieSidebarOpen, openAngieInAskMode, redirectToAppAdmin, redirectToInstallation, registerMcp, registerMcpAdapter, saveAngieConsent, sendPromptToAngie, signalMcpReady, startMCPServer, toolPrompts };
|
|
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 };
|
package/dist/index.js
CHANGED
|
@@ -32,11 +32,13 @@ var index_exports = {};
|
|
|
32
32
|
__export(index_exports, {
|
|
33
33
|
ANGIE_MODEL_PREFERENCES: () => ANGIE_MODEL_PREFERENCES,
|
|
34
34
|
ANGIE_REQUIRED_RESOURCES: () => ANGIE_REQUIRED_RESOURCES,
|
|
35
|
+
AngieMcpAdapter: () => AngieMcpAdapter,
|
|
35
36
|
AngieMessageEvenetType: () => import_angie_sdk2.MessageEventType,
|
|
36
37
|
MCP_STYLES_APPLIED_EVENT: () => MCP_STYLES_APPLIED_EVENT,
|
|
37
38
|
McpServer: () => import_mcp2.McpServer,
|
|
38
39
|
ResourceTemplate: () => import_mcp2.ResourceTemplate,
|
|
39
40
|
SamplingMessageSchema: () => import_types2.SamplingMessageSchema,
|
|
41
|
+
activateMcpAdapter: () => activateMcpAdapter,
|
|
40
42
|
canCreateWidget: () => canCreateWidget,
|
|
41
43
|
createAndRegisterAdapters: () => createAndRegisterAdapters,
|
|
42
44
|
createSampler: () => createSampler,
|
|
@@ -50,6 +52,7 @@ __export(index_exports, {
|
|
|
50
52
|
installAngiePlugin: () => installAngiePlugin,
|
|
51
53
|
isAngieAvailable: () => isAngieAvailable,
|
|
52
54
|
isAngieSidebarOpen: () => isAngieSidebarOpen,
|
|
55
|
+
openAngieInAgentMode: () => openAngieInAgentMode,
|
|
53
56
|
openAngieInAskMode: () => openAngieInAskMode,
|
|
54
57
|
redirectToAppAdmin: () => redirectToAppAdmin,
|
|
55
58
|
redirectToInstallation: () => redirectToInstallation,
|
|
@@ -59,7 +62,8 @@ __export(index_exports, {
|
|
|
59
62
|
sendPromptToAngie: () => sendPromptToAngie,
|
|
60
63
|
signalMcpReady: () => signalMcpReady,
|
|
61
64
|
startMCPServer: () => startMCPServer,
|
|
62
|
-
toolPrompts: () => toolPrompts
|
|
65
|
+
toolPrompts: () => toolPrompts,
|
|
66
|
+
waitForMcpReady: () => waitForMcpReady
|
|
63
67
|
});
|
|
64
68
|
module.exports = __toCommonJS(index_exports);
|
|
65
69
|
|
|
@@ -122,56 +126,6 @@ var isAngieSidebarOpen = () => {
|
|
|
122
126
|
var import_schema2 = require("@elementor/schema");
|
|
123
127
|
var import_mcp = require("@modelcontextprotocol/sdk/server/mcp.js");
|
|
124
128
|
|
|
125
|
-
// src/utils/to-mcp-title.ts
|
|
126
|
-
var toMCPTitle = (namespace) => {
|
|
127
|
-
const capitalized = namespace.charAt(0).toUpperCase() + namespace.slice(1);
|
|
128
|
-
return `Editor ${capitalized}`;
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
// src/adapters/angie-adapter.ts
|
|
132
|
-
var MAX_RETRIES = 3;
|
|
133
|
-
var AngieMcpAdapter = class {
|
|
134
|
-
constructor(sdk2, getRegisteredMcpServers2) {
|
|
135
|
-
this.sdk = sdk2;
|
|
136
|
-
this.getRegisteredMcpServers = getRegisteredMcpServers2;
|
|
137
|
-
}
|
|
138
|
-
async activate() {
|
|
139
|
-
await this.registerEntries(this.getRegisteredMcpServers(), MAX_RETRIES);
|
|
140
|
-
}
|
|
141
|
-
async registerEntries(entries, retry) {
|
|
142
|
-
if (retry === 0) {
|
|
143
|
-
console.error(
|
|
144
|
-
"Failed to register MCP after 3 retries. failed entries: ",
|
|
145
|
-
entries.map(([key]) => key)
|
|
146
|
-
);
|
|
147
|
-
return;
|
|
148
|
-
}
|
|
149
|
-
const failed = [];
|
|
150
|
-
for (const [key, mcpServer, description] of entries) {
|
|
151
|
-
try {
|
|
152
|
-
await this.sdk.registerLocalServer({
|
|
153
|
-
title: toMCPTitle(key),
|
|
154
|
-
name: `editor-${key}`,
|
|
155
|
-
server: mcpServer,
|
|
156
|
-
version: "1.0.0",
|
|
157
|
-
description
|
|
158
|
-
});
|
|
159
|
-
} catch {
|
|
160
|
-
failed.push([key, mcpServer, description]);
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
if (failed.length > 0) {
|
|
164
|
-
return this.registerEntries(failed, retry - 1);
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
onToolRegistered() {
|
|
168
|
-
}
|
|
169
|
-
onResourceRegistered() {
|
|
170
|
-
}
|
|
171
|
-
sendResourceUpdated() {
|
|
172
|
-
}
|
|
173
|
-
};
|
|
174
|
-
|
|
175
129
|
// src/adapters/web-mcp-adapter.ts
|
|
176
130
|
var import_zod_to_json_schema = require("zod-to-json-schema");
|
|
177
131
|
var import_schema = require("@elementor/schema");
|
|
@@ -394,6 +348,12 @@ var registerServerDocsResource = (server, namespace, title, docs, onRegistered)
|
|
|
394
348
|
onRegistered(name, uri, handler);
|
|
395
349
|
};
|
|
396
350
|
|
|
351
|
+
// src/utils/to-mcp-title.ts
|
|
352
|
+
var toMCPTitle = (namespace) => {
|
|
353
|
+
const capitalized = namespace.charAt(0).toUpperCase() + namespace.slice(1);
|
|
354
|
+
return `Editor ${capitalized}`;
|
|
355
|
+
};
|
|
356
|
+
|
|
397
357
|
// src/mcp-registry.ts
|
|
398
358
|
var mcpRegistry = {};
|
|
399
359
|
var mcpDescriptions = {};
|
|
@@ -423,14 +383,17 @@ var registerMcpAdapter = (adapter) => {
|
|
|
423
383
|
var signalMcpReady = () => {
|
|
424
384
|
resolveReady();
|
|
425
385
|
};
|
|
386
|
+
var waitForMcpReady = () => readyPromise;
|
|
387
|
+
var activateMcpAdapter = async (adapter) => {
|
|
388
|
+
await readyPromise;
|
|
389
|
+
registerMcpAdapter(adapter);
|
|
390
|
+
await adapter.activate();
|
|
391
|
+
};
|
|
426
392
|
var createAndRegisterAdapters = async () => {
|
|
427
393
|
const modelContext = getModelContext();
|
|
428
394
|
if (modelContext) {
|
|
429
395
|
registerMcpAdapter(new WebMCPAdapter(modelContext));
|
|
430
396
|
}
|
|
431
|
-
if (isAngieAvailable()) {
|
|
432
|
-
registerMcpAdapter(new AngieMcpAdapter(getSDK(), getRegisteredMcpServers));
|
|
433
|
-
}
|
|
434
397
|
await Promise.all(registrationAdapters.map((adapter) => adapter.activate()));
|
|
435
398
|
};
|
|
436
399
|
function callAdapters(fn) {
|
|
@@ -596,6 +559,50 @@ function createToolRegistry(server, serverName, serverDocsUri) {
|
|
|
596
559
|
};
|
|
597
560
|
}
|
|
598
561
|
|
|
562
|
+
// src/adapters/angie-adapter.ts
|
|
563
|
+
var MAX_RETRIES = 3;
|
|
564
|
+
var AngieMcpAdapter = class {
|
|
565
|
+
constructor(sdk2, getRegisteredMcpServers2) {
|
|
566
|
+
this.sdk = sdk2;
|
|
567
|
+
this.getRegisteredMcpServers = getRegisteredMcpServers2;
|
|
568
|
+
}
|
|
569
|
+
async activate() {
|
|
570
|
+
await this.registerEntries(this.getRegisteredMcpServers(), MAX_RETRIES);
|
|
571
|
+
}
|
|
572
|
+
async registerEntries(entries, retry) {
|
|
573
|
+
if (retry === 0) {
|
|
574
|
+
console.error(
|
|
575
|
+
"Failed to register MCP after 3 retries. failed entries: ",
|
|
576
|
+
entries.map(([key]) => key)
|
|
577
|
+
);
|
|
578
|
+
return;
|
|
579
|
+
}
|
|
580
|
+
const failed = [];
|
|
581
|
+
for (const [key, mcpServer, description] of entries) {
|
|
582
|
+
try {
|
|
583
|
+
await this.sdk.registerLocalServer({
|
|
584
|
+
title: toMCPTitle(key),
|
|
585
|
+
name: `editor-${key}`,
|
|
586
|
+
server: mcpServer,
|
|
587
|
+
version: "1.0.0",
|
|
588
|
+
description
|
|
589
|
+
});
|
|
590
|
+
} catch {
|
|
591
|
+
failed.push([key, mcpServer, description]);
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
if (failed.length > 0) {
|
|
595
|
+
return this.registerEntries(failed, retry - 1);
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
onToolRegistered() {
|
|
599
|
+
}
|
|
600
|
+
onResourceRegistered() {
|
|
601
|
+
}
|
|
602
|
+
sendResourceUpdated() {
|
|
603
|
+
}
|
|
604
|
+
};
|
|
605
|
+
|
|
599
606
|
// src/sampler.ts
|
|
600
607
|
var import_types = require("@modelcontextprotocol/sdk/types.js");
|
|
601
608
|
var DEFAULT_OPTS = {
|
|
@@ -726,7 +733,13 @@ var openLoadedEditorAngie = (prompt, mode) => {
|
|
|
726
733
|
return true;
|
|
727
734
|
};
|
|
728
735
|
var openAngieInAskMode = (prompt) => {
|
|
729
|
-
|
|
736
|
+
openAngieInMode(prompt, import_angie_sdk5.AngieInteractionMode.ASK);
|
|
737
|
+
};
|
|
738
|
+
var openAngieInAgentMode = (prompt) => {
|
|
739
|
+
openAngieInMode(prompt, import_angie_sdk5.AngieInteractionMode.AGENT);
|
|
740
|
+
};
|
|
741
|
+
var openAngieInMode = (prompt, mode) => {
|
|
742
|
+
if (openLoadedEditorAngie(prompt, mode)) {
|
|
730
743
|
return;
|
|
731
744
|
}
|
|
732
745
|
if (!isAngieAvailable()) {
|
|
@@ -737,7 +750,7 @@ var openAngieInAskMode = (prompt) => {
|
|
|
737
750
|
return;
|
|
738
751
|
}
|
|
739
752
|
(0, import_angie_sdk5.toggleAngieSidebar)(angieSidebar, true);
|
|
740
|
-
(0, import_angie_sdk5.setAngieInteractionMode)(
|
|
753
|
+
(0, import_angie_sdk5.setAngieInteractionMode)(mode);
|
|
741
754
|
if (prompt) {
|
|
742
755
|
window.location.hash = `angie-prompt=${encodeURIComponent(prompt)}`;
|
|
743
756
|
}
|
|
@@ -843,7 +856,7 @@ async function startMCPServer() {
|
|
|
843
856
|
signalMcpReady();
|
|
844
857
|
}
|
|
845
858
|
}
|
|
846
|
-
if (typeof document !== "undefined") {
|
|
859
|
+
if (typeof document !== "undefined" && document.readyState === "loading") {
|
|
847
860
|
document.addEventListener("DOMContentLoaded", () => void startMCPServer(), { once: true });
|
|
848
861
|
} else {
|
|
849
862
|
void startMCPServer();
|
|
@@ -861,11 +874,13 @@ var getAngieSdk = () => getSDK();
|
|
|
861
874
|
0 && (module.exports = {
|
|
862
875
|
ANGIE_MODEL_PREFERENCES,
|
|
863
876
|
ANGIE_REQUIRED_RESOURCES,
|
|
877
|
+
AngieMcpAdapter,
|
|
864
878
|
AngieMessageEvenetType,
|
|
865
879
|
MCP_STYLES_APPLIED_EVENT,
|
|
866
880
|
McpServer,
|
|
867
881
|
ResourceTemplate,
|
|
868
882
|
SamplingMessageSchema,
|
|
883
|
+
activateMcpAdapter,
|
|
869
884
|
canCreateWidget,
|
|
870
885
|
createAndRegisterAdapters,
|
|
871
886
|
createSampler,
|
|
@@ -879,6 +894,7 @@ var getAngieSdk = () => getSDK();
|
|
|
879
894
|
installAngiePlugin,
|
|
880
895
|
isAngieAvailable,
|
|
881
896
|
isAngieSidebarOpen,
|
|
897
|
+
openAngieInAgentMode,
|
|
882
898
|
openAngieInAskMode,
|
|
883
899
|
redirectToAppAdmin,
|
|
884
900
|
redirectToInstallation,
|
|
@@ -888,6 +904,7 @@ var getAngieSdk = () => getSDK();
|
|
|
888
904
|
sendPromptToAngie,
|
|
889
905
|
signalMcpReady,
|
|
890
906
|
startMCPServer,
|
|
891
|
-
toolPrompts
|
|
907
|
+
toolPrompts,
|
|
908
|
+
waitForMcpReady
|
|
892
909
|
});
|
|
893
910
|
//# sourceMappingURL=index.js.map
|
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/utils/to-mcp-title.ts","../src/adapters/angie-adapter.ts","../src/adapters/web-mcp-adapter.ts","../src/utils/register-model-context-tool.ts","../src/angie-annotations.ts","../src/test-utils/mock-mcp-registry.ts","../src/utils/get-model-context.ts","../src/utils/merge-required-resources.ts","../src/utils/create-simple-resource-handler.ts","../src/utils/register-server-docs-resource.ts","../src/sampler.ts","../src/utils/prompt-builder.ts","../src/utils/get-active-chat-info.ts","../src/utils/open-angie-in-ask-mode.ts","../src/utils/send-prompt-to-angie.ts","../src/utils/redirect-to-installation.ts","../src/utils/redirect-to-app-admin.ts","../src/utils/install-angie-plugin.ts","../src/utils/save-angie-consent.ts","../src/init.ts","../src/events/mcp-styles-applied-event.ts"],"sourcesContent":["import './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 { 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, 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 { AngieMcpAdapter } from './adapters/angie-adapter';\nimport { type IMcpRegistrationAdapter, type McpResourceHandler, type McpResourceUriOrTemplate } from './adapters/types';\nimport { WebMCPAdapter } from './adapters/web-mcp-adapter';\nimport {\n\tANGIE_MODEL_PREFERENCES,\n\tANGIE_REQUIRED_RESOURCES,\n\ttype AngieModelPreferences,\n\tcreateDefaultModelPreferences,\n} from './angie-annotations';\nimport { mockMcpRegistry } from './test-utils/mock-mcp-registry';\nimport { getModelContext } from './utils/get-model-context';\nimport { getSDK } from './utils/get-sdk';\nimport { isAngieAvailable } from './utils/is-angie-available';\nimport { mergeRequiredResources, type ResourceList } from './utils/merge-required-resources';\nimport { registerServerDocsResource } from './utils/register-server-docs-resource';\nimport { toMCPTitle } from './utils/to-mcp-title';\n\ntype ZodRawShape = z3.ZodRawShape;\n\nconst mcpRegistry: { [ namespace: string ]: McpServer } = {};\nconst mcpDescriptions: { [ namespace: string ]: string } = {};\n// @ts-ignore - QUnit fails this\nconst isMcpRegistrationActivated = false || typeof globalThis.jest !== 'undefined';\n\nconst registrationAdapters: IMcpRegistrationAdapter[] = [];\nconst bufferedTools: Parameters< IMcpRegistrationAdapter[ 'onToolRegistered' ] >[] = [];\nconst bufferedResources: Parameters< IMcpRegistrationAdapter[ 'onResourceRegistered' ] >[] = [];\n\nlet resolveReady!: () => void;\nconst readyPromise = new Promise< void >( ( resolve ) => {\n\tresolveReady = resolve;\n} );\n\nexport const registerMcpAdapter = ( adapter: IMcpRegistrationAdapter ): void => {\n\tregistrationAdapters.push( adapter );\n\tfor ( const tool of bufferedTools ) {\n\t\ttry {\n\t\t\tadapter.onToolRegistered( tool[ 0 ], tool[ 1 ] );\n\t\t} catch {\n\t\t\t// exit quietly\n\t\t}\n\t}\n\tfor ( const resource of bufferedResources ) {\n\t\ttry {\n\t\t\tadapter.onResourceRegistered( ...resource );\n\t\t} catch {\n\t\t\t// exit quietly\n\t\t}\n\t}\n};\n\nexport const signalMcpReady = (): void => {\n\tresolveReady();\n};\n\nexport const createAndRegisterAdapters = async (): Promise< void > => {\n\tconst modelContext = getModelContext();\n\n\tif ( modelContext ) {\n\t\tregisterMcpAdapter( new WebMCPAdapter( modelContext ) );\n\t}\n\n\tif ( isAngieAvailable() ) {\n\t\tregisterMcpAdapter( new AngieMcpAdapter( getSDK(), getRegisteredMcpServers ) );\n\t}\n\n\tawait Promise.all( registrationAdapters.map( ( adapter ) => adapter.activate() ) );\n};\n\n// utility function to run a callback on all MCP interfaces\nfunction callAdapters( fn: ( adapter: IMcpRegistrationAdapter ) => unknown ) {\n\tfor ( const adapter of registrationAdapters ) {\n\t\ttry {\n\t\t\tfn( adapter );\n\t\t} catch {\n\t\t\t// adapter failed — exit quietly, continue to next\n\t\t}\n\t}\n}\n\nexport const registerMcp = ( mcp: McpServer, name: string ) => {\n\tconst mcpName = isAlphabet( name );\n\tmcpRegistry[ mcpName ] = mcp;\n};\n\nexport const getRegisteredMcpServers = (): Array< [ string, McpServer, string ] > => {\n\treturn Object.entries( mcpRegistry ).map( ( [ key, server ] ) => [ key, server, mcpDescriptions[ key ] || key ] );\n};\n\nconst isAlphabet = ( str: string ): string | never => {\n\tconst passes = !! str && /^[a-z_]+$/.test( str );\n\tif ( ! passes ) {\n\t\tthrow new Error( 'Not alphabet' );\n\t}\n\treturn str;\n};\n\n/**\n * @param namespace The namespace of the MCP server. It should contain only lowercase alphabetic characters.\n * @param options\n * @param options.instructions Short hint about the MCP and its toolset (MCP SDK `instructions`; keeps payload small).\n * @param options.docs Full documentation registered as a lazy-loaded resource.\n * When provided, it is registered at elementor://{namespace}/server-docs\n * and auto-injected into every tool's requiredResources.\n */\nexport const getMCPByDomain = (\n\tnamespace: string,\n\toptions?: { docs?: string; instructions?: string }\n): MCPRegistryEntry => {\n\tconst mcpName = `editor-${ isAlphabet( namespace ) }`;\n\tconst title = toMCPTitle( namespace );\n\t// @ts-ignore - QUnit fails this\n\tif ( typeof globalThis.jest !== 'undefined' ) {\n\t\treturn mockMcpRegistry();\n\t}\n\tif ( ! mcpRegistry[ namespace ] ) {\n\t\tmcpRegistry[ namespace ] = new McpServer(\n\t\t\t{ name: mcpName, title, version: '1.0.0' },\n\t\t\t{ instructions: options?.instructions, capabilities: { resources: { subscribe: true } } }\n\t\t);\n\t\tif ( options?.docs ) {\n\t\t\tregisterServerDocsResource( mcpRegistry[ namespace ], namespace, title, options.docs, ( ...args ) => {\n\t\t\t\tbufferedResources.push( args );\n\t\t\t\tcallAdapters( ( adapter ) => adapter.onResourceRegistered( ...args ) );\n\t\t\t} );\n\t\t}\n\t}\n\tconst mcpServer = mcpRegistry[ namespace ];\n\tconst serverDocsUri = options?.docs ? `elementor://${ namespace }/server-docs` : undefined;\n\tconst { addTool } = createToolRegistry( mcpServer, mcpName, serverDocsUri );\n\treturn {\n\t\twaitForReady: () => readyPromise,\n\t\t// @ts-expect-error: TS is unable to infer the type here\n\t\tresource: async ( ...args: Parameters< McpServer[ 'registerResource' ] > ) => {\n\t\t\tconst [ name, uriOrTemplate, ...rest ] = args as [ string, unknown, ...unknown[] ];\n\t\t\tconst handler = rest[ rest.length - 1 ] as McpResourceHandler;\n\t\t\tconst resourceArgs: Parameters< IMcpRegistrationAdapter[ 'onResourceRegistered' ] > = [\n\t\t\t\tname,\n\t\t\t\turiOrTemplate as McpResourceUriOrTemplate,\n\t\t\t\thandler,\n\t\t\t];\n\t\t\tbufferedResources.push( resourceArgs );\n\t\t\tcallAdapters( ( adapter ) => adapter.onResourceRegistered( ...resourceArgs ) );\n\t\t\treturn mcpServer.registerResource( ...args );\n\t\t},\n\t\tsendResourceUpdated: ( ...args: Parameters< McpServer[ 'server' ][ 'sendResourceUpdated' ] > ) => {\n\t\t\tcallAdapters( ( adapter ) => adapter.sendResourceUpdated( { uri: args[ 0 ].uri } ) );\n\t\t\treturn Promise.resolve( mcpServer.server.sendResourceUpdated( ...args ) ).catch( ( error: Error ) => {\n\t\t\t\tif ( error?.message?.includes( 'Not connected' ) ) {\n\t\t\t\t\treturn; // Expected when no MCP client is connected yet\n\t\t\t\t}\n\t\t\t\tif ( error?.message?.includes( 'does not support notifying about resources' ) ) {\n\t\t\t\t\treturn; // Server capability not declared — safe to ignore\n\t\t\t\t}\n\t\t\t\tthrow error;\n\t\t\t} );\n\t\t},\n\t\taddTool,\n\t\tsetMCPDescription: ( description: string ) => {\n\t\t\tmcpDescriptions[ namespace ] = description;\n\t\t},\n\t};\n};\n\nexport interface MCPRegistryEntry {\n\taddTool: < T extends undefined | z.ZodRawShape = undefined, O extends undefined | z.ZodRawShape = undefined >(\n\t\topts: ToolRegistrationOptions< T, O >\n\t) => void;\n\tsetMCPDescription: ( description: string ) => void;\n\tsendResourceUpdated: McpServer[ 'server' ][ 'sendResourceUpdated' ];\n\tresource: McpServer[ 'registerResource' ];\n\twaitForReady: () => Promise< void >;\n}\n\ntype ToolRegistrationOptions<\n\tInputArgs extends undefined | z.ZodRawShape = undefined,\n\tOutputSchema extends undefined | z.ZodRawShape = undefined,\n\tExpectedOutput = OutputSchema extends z.ZodRawShape ? z.objectOutputType< OutputSchema, z.ZodTypeAny > : string,\n> = {\n\tname: string;\n\tdescription: string;\n\tschema?: InputArgs;\n\t/**\n\t * Auto added fields:\n\t * @param errors z.string().optional().describe('Error message if the tool failed')\n\t */\n\toutputSchema?: OutputSchema;\n\thandler: InputArgs extends z.ZodRawShape\n\t\t? (\n\t\t\t\targs: z.objectOutputType< InputArgs, z.ZodTypeAny >,\n\t\t\t\textra: RequestHandlerExtra< ServerRequest, ServerNotification >\n\t\t ) => ExpectedOutput | Promise< ExpectedOutput >\n\t\t: (\n\t\t\t\targs: unknown,\n\t\t\t\textra: RequestHandlerExtra< ServerRequest, ServerNotification >\n\t\t ) => ExpectedOutput | Promise< ExpectedOutput >;\n\tisDestructive?: boolean;\n\trequiredResources?: ResourceList;\n\tmodelPreferences?: AngieModelPreferences;\n};\n\nfunction createToolRegistry( server: McpServer, serverName: string, serverDocsUri?: string ) {\n\tfunction addTool<\n\t\tT extends undefined | z.ZodRawShape = undefined,\n\t\tO extends undefined | z.ZodRawShape = undefined,\n\t>( opts: ToolRegistrationOptions< T, O > ) {\n\t\tconst outputSchema = opts.outputSchema as ZodRawShape | undefined;\n\t\tif ( outputSchema ) {\n\t\t\tObject.assign(\n\t\t\t\toutputSchema,\n\t\t\t\toutputSchema.errors ?? {\n\t\t\t\t\terrors: z.string().optional().describe( 'Error message if the tool failed' ),\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t\t// @ts-ignore: TS is unable to infer the type here\n\t\tconst inputSchema: ZodRawShape = opts.schema ? opts.schema : {};\n\t\tconst toolCallback: ToolCallback< ZodRawShape > = async function ( args, extra ) {\n\t\t\ttry {\n\t\t\t\tconst invocationResult = await opts.handler( opts.schema ? args : {}, extra );\n\t\t\t\treturn {\n\t\t\t\t\t// structuredContent: typeof invocationResult === 'string' ? undefined : invocationResult,\n\t\t\t\t\tcontent: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: 'text',\n\t\t\t\t\t\t\ttext:\n\t\t\t\t\t\t\t\ttypeof invocationResult === 'string'\n\t\t\t\t\t\t\t\t\t? invocationResult\n\t\t\t\t\t\t\t\t\t: JSON.stringify( invocationResult ),\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t};\n\t\t\t} catch ( error ) {\n\t\t\t\treturn {\n\t\t\t\t\tisError: true,\n\t\t\t\t\tstructuredContent: {\n\t\t\t\t\t\terrors: ( error as Error ).message || 'Unknown error',\n\t\t\t\t\t},\n\t\t\t\t\tcontent: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: 'text',\n\t\t\t\t\t\t\ttext:\n\t\t\t\t\t\t\t\t( ( error as Error ).message || 'Unknown error' ) +\n\t\t\t\t\t\t\t\tJSON.stringify( ( error as { response?: { data: unknown } } ).response?.data || error ),\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t};\n\t\t\t}\n\t\t};\n\t\tconst annotations: Record< string, unknown > = {\n\t\t\tdestructiveHint: opts.isDestructive,\n\t\t\treadOnlyHint: opts.isDestructive ? false : undefined,\n\t\t\ttitle: opts.name,\n\t\t};\n\t\tconst mergedResources = mergeRequiredResources( opts.requiredResources, serverDocsUri );\n\t\tconst angieAnnotations = {\n\t\t\t[ ANGIE_MODEL_PREFERENCES ]: opts.modelPreferences ?? createDefaultModelPreferences(),\n\t\t\t[ ANGIE_REQUIRED_RESOURCES ]: mergedResources,\n\t\t};\n\t\tserver.registerTool(\n\t\t\topts.name,\n\t\t\t{\n\t\t\t\tdescription: opts.description,\n\t\t\t\tinputSchema,\n\t\t\t\t// TODO: Uncomment this when the outputSchema is stable\n\t\t\t\t// outputSchema,\n\t\t\t\ttitle: opts.name,\n\t\t\t\tannotations,\n\t\t\t\t_meta: angieAnnotations,\n\t\t\t},\n\t\t\ttoolCallback\n\t\t);\n\t\tconst toolDescriptor = {\n\t\t\tname: opts.name,\n\t\t\tdescription: opts.description,\n\t\t\tinputSchema: inputSchema as object,\n\t\t\texecute: ( params: Record< string, unknown > ) =>\n\t\t\t\ttoolCallback(\n\t\t\t\t\tparams as Parameters< typeof toolCallback >[ 0 ],\n\t\t\t\t\t/* WebMCP: no protocol session — handlers must not rely on `extra` here */\n\t\t\t\t\t{} as RequestHandlerExtra< ServerRequest, ServerNotification >\n\t\t\t\t) as Promise< unknown >,\n\t\t};\n\t\tconst extraData = {\n\t\t\tresources: [ `Server resource name: ${ serverName }, Required to fetch!` ],\n\t\t\trequiredResources: mergedResources?.map( ( resource ) => resource.uri ) ?? [],\n\t\t};\n\t\tbufferedTools.push( [ toolDescriptor, extraData ] );\n\t\tcallAdapters( ( adapter ) => adapter.onToolRegistered( toolDescriptor, extraData ) );\n\t\tif ( isMcpRegistrationActivated ) {\n\t\t\tserver.sendToolListChanged();\n\t\t}\n\t}\n\treturn {\n\t\taddTool,\n\t};\n}\n","export const toMCPTitle = ( namespace: string ): string => {\n\tconst capitalized = namespace.charAt( 0 ).toUpperCase() + namespace.slice( 1 );\n\treturn `Editor ${ capitalized }`;\n};\n","import { type AngieMcpSdk } from '@elementor-external/angie-sdk';\n\nimport { type getRegisteredMcpServers as _getRegisteredMcpServers } from '../mcp-registry';\nimport { toMCPTitle } from '../utils/to-mcp-title';\nimport { type IMcpRegistrationAdapter } from './types';\n\nconst MAX_RETRIES = 3;\n\nexport class AngieMcpAdapter implements IMcpRegistrationAdapter {\n\tconstructor(\n\t\tprivate readonly sdk: AngieMcpSdk,\n\t\tprivate readonly getRegisteredMcpServers: typeof _getRegisteredMcpServers\n\t) {}\n\n\tasync activate(): Promise< void > {\n\t\t// No waitForReady() here: registerLocalServer queues the server and the SDK flushes\n\t\t// the queue once Angie reports ready. waitForReady() only resolves for the SDK copy\n\t\t// that booted the sidebar, which is the host integration, never the editor bundle.\n\t\tawait this.registerEntries( this.getRegisteredMcpServers(), MAX_RETRIES );\n\t}\n\n\tprivate async registerEntries(\n\t\tentries: ReturnType< typeof _getRegisteredMcpServers >,\n\t\tretry: number\n\t): Promise< void > {\n\t\tif ( retry === 0 ) {\n\t\t\t/* eslint-disable-next-line no-console */\n\t\t\tconsole.error(\n\t\t\t\t'Failed to register MCP after 3 retries. failed entries: ',\n\t\t\t\tentries.map( ( [ key ] ) => key )\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tconst failed: typeof entries = [];\n\t\tfor ( const [ key, mcpServer, description ] of entries ) {\n\t\t\ttry {\n\t\t\t\tawait this.sdk.registerLocalServer( {\n\t\t\t\t\ttitle: toMCPTitle( key ),\n\t\t\t\t\tname: `editor-${ key }`,\n\t\t\t\t\tserver: mcpServer,\n\t\t\t\t\tversion: '1.0.0',\n\t\t\t\t\tdescription,\n\t\t\t\t} );\n\t\t\t} catch {\n\t\t\t\tfailed.push( [ key, mcpServer, description ] );\n\t\t\t}\n\t\t}\n\n\t\tif ( failed.length > 0 ) {\n\t\t\treturn this.registerEntries( failed, retry - 1 );\n\t\t}\n\t}\n\n\tonToolRegistered(): void {\n\t\t// Angie tools are registered via McpServer (at activate time).\n\t}\n\n\tonResourceRegistered(): void {\n\t\t// Resources are registered on the McpServer instance directly.\n\t}\n\n\tsendResourceUpdated(): void {\n\t\t// Resource update notifications are sent via MCPRegistryEntry.sendResourceUpdated.\n\t}\n}\n","import { zodToJsonSchema } from 'zod-to-json-schema';\nimport { z, type z3 } from '@elementor/schema';\n\nimport { type ModelContextRegisterTool, registerModelContextTool } from '../utils/register-model-context-tool';\nimport {\n\ttype IMcpRegistrationAdapter,\n\ttype McpResourceHandler,\n\ttype McpResourceUriOrTemplate,\n\ttype McpToolDescriptor,\n\ttype UriTemplate,\n} from './types';\n\ntype ZodRawShape = z3.ZodRawShape;\n\nexport type ModelContext = {\n\tregisterTool: ModelContextRegisterTool;\n\tunregisterTool?: ( name: string ) => void;\n};\n\ntype ResourceEntry = {\n\tpattern: string;\n\tmatch: ( uri: string ) => Record< string, string | string[] > | null;\n\thandler: McpResourceHandler;\n};\n\nexport class WebMCPAdapter implements IMcpRegistrationAdapter {\n\tprivate readonly registeredToolNames = new Set< string >();\n\tprivate readonly resourceEntries: ResourceEntry[] = [];\n\tprivate activated = false;\n\n\tconstructor( private readonly ctx: ModelContext ) {}\n\n\tactivate(): Promise< void > {\n\t\tif ( this.activated ) {\n\t\t\treturn Promise.resolve();\n\t\t}\n\t\tthis.activated = true;\n\t\treturn registerModelContextTool( this.ctx.registerTool, {\n\t\t\tname: 'editor-resource-getter',\n\t\t\tdescription:\n\t\t\t\t'Get an editor resource by URI, or search for available resources by partial URI. Pass a full URI to retrieve content, or a partial string to discover matching patterns.',\n\t\t\tinputSchema: {\n\t\t\t\ttype: 'object',\n\t\t\t\tproperties: {\n\t\t\t\t\turi: {\n\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t'A full resource URI (e.g. elementor://style/best-practices) or a partial string to search across available resource patterns.',\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\trequired: [ 'uri' ],\n\t\t\t},\n\t\t\texecute: async ( params ) => {\n\t\t\t\tconst query = params.uri as string;\n\t\t\t\tconst entries = this.resourceEntries;\n\n\t\t\t\tif ( entries.length === 0 ) {\n\t\t\t\t\treturn 'No resources are registered yet.';\n\t\t\t\t}\n\n\t\t\t\t// Exact URI match\n\t\t\t\tfor ( const entry of entries ) {\n\t\t\t\t\tconst variables = entry.match( query );\n\t\t\t\t\tif ( variables !== null ) {\n\t\t\t\t\t\tlet resourceUrl: URL;\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tresourceUrl = new URL( query );\n\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\treturn `Invalid URI '${ query }'. Provide a valid resource URI or a partial string to search patterns.`;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst result = await entry.handler( resourceUrl, variables );\n\t\t\t\t\t\treturn result.contents?.[ 0 ]?.text ?? JSON.stringify( result );\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Partial search fallback\n\t\t\t\tconst matches = entries.map( ( e ) => e.pattern ).filter( ( pattern ) => pattern.includes( query ) );\n\t\t\t\tif ( matches.length > 0 ) {\n\t\t\t\t\treturn `Found ${ matches.length } matching resource pattern(s):\\n${ matches.join(\n\t\t\t\t\t\t'\\n'\n\t\t\t\t\t) }\\n\\nProvide a full URI to retrieve the resource content.`;\n\t\t\t\t}\n\n\t\t\t\tconst available = entries.map( ( e ) => e.pattern ).join( '\\n' );\n\t\t\t\tthrow new Error( `No resource matched '${ query }'.\\n\\nAvailable patterns:\\n${ available }` );\n\t\t\t},\n\t\t} );\n\t}\n\n\tonToolRegistered(\n\t\ttool: McpToolDescriptor,\n\t\textraData?: { resources: string[]; requiredResources: string[] }\n\t): void {\n\t\tlet jsonSchema: object;\n\t\ttry {\n\t\t\tjsonSchema = zodToJsonSchema( z.object( tool.inputSchema as ZodRawShape ) );\n\t\t} catch {\n\t\t\tjsonSchema = tool.inputSchema;\n\t\t}\n\n\t\tif ( this.registeredToolNames.has( tool.name ) ) {\n\t\t\tthis.ctx.unregisterTool?.( tool.name );\n\t\t\tthis.registeredToolNames.delete( tool.name );\n\t\t}\n\n\t\tlet resourcesDescription = '';\n\t\tif ( extraData ) {\n\t\t\tif ( extraData.resources?.length > 0 ) {\n\t\t\t\tresourcesDescription += `#Resources:\\n${ extraData.resources?.join( '\\n' ) }\\n\\n`;\n\t\t\t}\n\t\t\tif ( extraData.requiredResources?.length > 0 ) {\n\t\t\t\tresourcesDescription += `#Required Resources:\\n${ extraData.requiredResources?.join( '\\n' ) }\\n\\n`;\n\t\t\t}\n\t\t\tresourcesDescription += `To read resources, use editor-resource-getter tool.\\n\\n`;\n\t\t}\n\t\tvoid registerModelContextTool( this.ctx.registerTool, {\n\t\t\tname: tool.name,\n\t\t\tdescription: `${ resourcesDescription }${ tool.description }`,\n\t\t\tinputSchema: jsonSchema,\n\t\t\texecute: tool.execute,\n\t\t} ).then( () => {\n\t\t\tthis.registeredToolNames.add( tool.name );\n\t\t} );\n\t}\n\n\tonResourceRegistered( _name: string, uriOrTemplate: McpResourceUriOrTemplate, handler: McpResourceHandler ): void {\n\t\tif ( typeof uriOrTemplate === 'string' ) {\n\t\t\tthis.resourceEntries.push( {\n\t\t\t\tpattern: uriOrTemplate,\n\t\t\t\tmatch: ( uri ) => ( uri === uriOrTemplate ? {} : null ),\n\t\t\t\thandler,\n\t\t\t} );\n\t\t} else {\n\t\t\tconst template = uriOrTemplate.uriTemplate as UriTemplate;\n\t\t\tthis.resourceEntries.push( {\n\t\t\t\tpattern: template.toString(),\n\t\t\t\tmatch: ( uri ) => template.match( uri ),\n\t\t\t\thandler,\n\t\t\t} );\n\t\t}\n\t}\n\n\tsendResourceUpdated(): void {\n\t\t// WebMCP has no server-push mechanism — no-op\n\t}\n}\n","import { type McpToolDescriptor } from '../adapters/types';\n\nexport type ModelContextRegisterTool = ( tool: McpToolDescriptor ) => void | Promise< void >;\n\nexport async function registerModelContextTool(\n\tregisterTool: ModelContextRegisterTool,\n\ttool: McpToolDescriptor\n): Promise< void > {\n\ttry {\n\t\tawait Promise.resolve( registerTool( tool ) );\n\t} catch ( error ) {\n\t\t/* eslint-disable-next-line no-console */\n\t\tconsole.error( 'Tool registration failed:', error );\n\t}\n}\n","export const ANGIE_MODEL_PREFERENCES = 'angie/modelPreferences' as const;\nexport const ANGIE_REQUIRED_RESOURCES = 'angie/requiredResources' as const;\n\nexport interface AngieModelPreferences {\n\thints?: Array< { name: string } >;\n\tcostPriority?: number; // 0-1 (future use)\n\tspeedPriority?: number; // 0-1 (future use)\n\tintelligencePriority?: number; // 0-1 (future use)\n}\n\nexport function createDefaultModelPreferences(): AngieModelPreferences {\n\treturn {\n\t\thints: [ { name: 'claude-sonnet-4-6' } ],\n\t};\n}\n","import { type McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\n\nimport { type MCPRegistryEntry } from '../mcp-registry';\n\nconst mock = new Proxy(\n\t{},\n\t{\n\t\tget: () => {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unused-vars\n\t\t\tfunction mockedFn( ..._: unknown[] ) {}\n\t\t\treturn mockedFn;\n\t\t},\n\t}\n);\n\nexport const mockMcpRegistry = (): MCPRegistryEntry => {\n\treturn {\n\t\t// @ts-ignore\n\t\tresource: async () => {},\n\t\t// @ts-ignore\n\t\tsendResourceUpdated: () => {},\n\t\taddTool: () => {},\n\t\tsetMCPDescription: () => {},\n\t\tmcpServer: mock as McpServer,\n\t};\n};\n","import { type ModelContext } from '../adapters/web-mcp-adapter';\n\ntype ModelContextHost = {\n\tmodelContext?: ModelContext;\n};\n\nfunction bindModelContextMethods( host: ModelContext ): ModelContext {\n\treturn {\n\t\tregisterTool: host.registerTool.bind( host ),\n\t\tunregisterTool: host.unregisterTool ? host.unregisterTool.bind( host ) : undefined,\n\t};\n}\n\nexport function getModelContext(): ModelContext | undefined {\n\tconst documentModelContext =\n\t\ttypeof document !== 'undefined' ? ( document as unknown as ModelContextHost ).modelContext : undefined;\n\tif ( documentModelContext?.registerTool ) {\n\t\treturn bindModelContextMethods( documentModelContext );\n\t}\n\tconst navigatorModelContext =\n\t\ttypeof navigator !== 'undefined' ? ( navigator as unknown as ModelContextHost ).modelContext : undefined;\n\tif ( navigatorModelContext?.registerTool ) {\n\t\treturn bindModelContextMethods( navigatorModelContext );\n\t}\n\n\treturn undefined;\n}\n","export type ResourceList = {\n\turi: string;\n\tdescription: string;\n}[];\n\nexport const mergeRequiredResources = (\n\ttoolResources: ResourceList | undefined,\n\tserverDocsUri: string | undefined\n): ResourceList | undefined => {\n\tif ( ! serverDocsUri ) {\n\t\treturn toolResources;\n\t}\n\tif ( toolResources?.some( ( r ) => r.uri === serverDocsUri ) ) {\n\t\treturn toolResources;\n\t}\n\treturn [ ...( toolResources ?? [] ), { uri: serverDocsUri, description: 'Server docs' } ];\n};\n","export const createSimpleResourceHandler = ( text: string ) => async ( uri: URL ) => ( {\n\tcontents: [ { uri: uri.href, mimeType: 'text/plain', text } ],\n} );\n","import { type McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\n\nimport { type IMcpRegistrationAdapter } from '../adapters/types';\nimport { createSimpleResourceHandler } from './create-simple-resource-handler';\n\ntype OnResourceRegistered = ( ...args: Parameters< IMcpRegistrationAdapter[ 'onResourceRegistered' ] > ) => void;\n\nexport const registerServerDocsResource = (\n\tserver: McpServer,\n\tnamespace: string,\n\ttitle: string,\n\tdocs: string,\n\tonRegistered: OnResourceRegistered\n): void => {\n\tconst uri = `elementor://${ namespace }/server-docs`;\n\tconst name = `${ namespace }-server-docs`;\n\tconst handler = createSimpleResourceHandler( docs );\n\tserver.registerResource(\n\t\tname,\n\t\turi,\n\t\t{\n\t\t\ttitle: `${ title } server docs`,\n\t\t\tdescription: 'Full MCP documentation (lazy-loaded)',\n\t\t\tmimeType: 'text/plain',\n\t\t},\n\t\thandler\n\t);\n\tonRegistered( name, uri, handler );\n};\n","import { type z } from '@elementor/schema';\nimport { type RequestHandlerExtra } from '@modelcontextprotocol/sdk/shared/protocol.js';\nimport { SamplingMessageSchema, type ServerNotification, type ServerRequest } from '@modelcontextprotocol/sdk/types.js';\n\ntype Server = RequestHandlerExtra< ServerRequest, ServerNotification >;\ntype Opts = {\n\tmaxTokens?: number;\n\tmodelPreferences?: string;\n\tmodel?: string;\n};\n\nconst DEFAULT_OPTS: Opts = {\n\tmaxTokens: 10000,\n\tmodelPreferences: 'openai',\n\tmodel: 'gpt-4o',\n};\n\ntype SamplingOpts = {\n\tsystemPrompt?: string;\n\tstructuredOutput?: z.ZodTypeAny;\n\tmessages: { role: 'user' | 'assistant'; content: { type: 'text'; text: string } }[];\n\trequestParams?: { [ key: string ]: string };\n};\n\nconst DEFAULT_STRUCTURED_OUTPUT = {\n\ttype: 'object',\n\tproperties: {\n\t\tcontent: {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Result',\n\t\t},\n\t},\n\trequired: [ 'content' ],\n\tadditionalProperties: false,\n};\n\nexport const createSampler = ( server: Server, opts: Opts = DEFAULT_OPTS ) => {\n\tconst { maxTokens = 1000, modelPreferences = 'openai', model = 'gpt-4o' } = opts;\n\tconst exec = async ( payload: SamplingOpts ) => {\n\t\tconst systemPromptObject = { ...( payload.systemPrompt ? { systemPrompt: payload.systemPrompt } : {} ) };\n\t\tconst requestParams = payload.requestParams || {};\n\t\tconst result = await server.sendRequest(\n\t\t\t{\n\t\t\t\tmethod: 'sampling/createMessage',\n\t\t\t\tparams: {\n\t\t\t\t\t...requestParams,\n\t\t\t\t\tmaxTokens,\n\t\t\t\t\tmodelPreferences: {\n\t\t\t\t\t\thints: [ { name: modelPreferences } ],\n\t\t\t\t\t},\n\t\t\t\t\tmetadata: {\n\t\t\t\t\t\tmodel,\n\t\t\t\t\t\t...systemPromptObject,\n\t\t\t\t\t\t...{ structured_output: payload.structuredOutput || DEFAULT_STRUCTURED_OUTPUT },\n\t\t\t\t\t},\n\t\t\t\t\tmessages: payload.messages,\n\t\t\t\t},\n\t\t\t\t// ...systemPromptObject,\n\t\t\t},\n\t\t\tSamplingMessageSchema\n\t\t);\n\t\treturn result.content;\n\t};\n\treturn exec;\n};\n","class ToolPrompts {\n\tpublic _description = '';\n\tpublic _parameters: Record< string, string > = {};\n\tpublic _examples: string[] = [];\n\tpublic _furtherInstructions: string[] = [];\n\n\tconstructor( public name: string ) {}\n\n\tdescription(): string;\n\tdescription( desc: string ): this;\n\tdescription( desc?: string | undefined ) {\n\t\tif ( typeof desc === 'undefined' ) {\n\t\t\treturn this._description;\n\t\t}\n\t\tthis._description = desc;\n\t\treturn this;\n\t}\n\n\tparameter( key: string ): string;\n\tparameter( key: string, description: string ): this;\n\tparameter( key: string, description?: string ) {\n\t\tif ( typeof description === 'undefined' ) {\n\t\t\treturn this._parameters[ key ];\n\t\t}\n\t\tthis._parameters[ key ] = `**${ key }**:\\n${ description }`;\n\t\treturn this;\n\t}\n\n\tinstruction( instruction: string ): this {\n\t\tthis._furtherInstructions.push( instruction );\n\t\treturn this;\n\t}\n\n\texample( example: string ): this {\n\t\tthis._examples.push( example );\n\t\treturn this;\n\t}\n\n\tpublic get examples() {\n\t\treturn this._examples.join( '\\n\\n' );\n\t}\n\n\tprompt(): string {\n\t\treturn `# ${ this.name }\n# Description\n${ this._description }\n${ this._parameters.length ? '# Parameters\\n' + Object.values( this._parameters ).join( '\\n\\n' ) : '' }\n${ this._examples.length ? '# Examples\\n' + this.examples : '' }\n${ this._furtherInstructions.length ? '# Further Instructions\\n' + this._furtherInstructions.join( '\\n\\n' ) : '' }\n`.trim();\n\t}\n}\n\nexport const toolPrompts = ( name: string ) => {\n\treturn new ToolPrompts( name );\n};\n","export type ActiveChatInfo = {\n\tsessionId: string;\n\texpiresAt: number;\n};\n\nexport const getActiveChatInfo = (): ActiveChatInfo => {\n\tconst info = localStorage.getItem( 'angie_active_chat_id' );\n\tif ( ! info ) {\n\t\treturn {\n\t\t\texpiresAt: 0,\n\t\t\tsessionId: '',\n\t\t};\n\t}\n\tconst rawData = JSON.parse( info );\n\treturn {\n\t\texpiresAt: rawData.expiresAt as number,\n\t\tsessionId: rawData.sessionId as string,\n\t};\n};\n","import {\n\tAngieInteractionMode,\n\tgetAngieIframe,\n\tsetAngieInteractionMode,\n\ttoggleAngieSidebar,\n} from '@elementor-external/angie-sdk';\n\nimport { isAngieAvailable } from './is-angie-available';\n\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\tif ( openLoadedEditorAngie( prompt, AngieInteractionMode.ASK ) ) {\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( AngieInteractionMode.ASK );\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\nif ( typeof document !== 'undefined' ) {\n\tdocument.addEventListener( 'DOMContentLoaded', () => void startMCPServer(), { once: true } );\n} else {\n\tvoid startMCPServer();\n}\n","export const MCP_STYLES_APPLIED_EVENT = 'elementor/mcp/styles-applied';\n\nexport type McpStylesAppliedPayload = {\n\tstyleValue: Record< string, unknown >;\n};\n\nexport function dispatchMcpStylesAppliedEvent( payload: McpStylesAppliedPayload ): void {\n\twindow.dispatchEvent( new CustomEvent( MCP_STYLES_APPLIED_EVENT, { detail: payload } ) );\n}\n"],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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/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 capitalized = namespace.charAt( 0 ).toUpperCase() + namespace.slice( 1 );\n\treturn `Editor ${ capitalized }`;\n};\n","import { type AngieMcpSdk } from '@elementor-external/angie-sdk';\n\nimport { type getRegisteredMcpServers as _getRegisteredMcpServers } from '../mcp-registry';\nimport { toMCPTitle } from '../utils/to-mcp-title';\nimport { type IMcpRegistrationAdapter } from './types';\n\nconst MAX_RETRIES = 3;\n\nexport class AngieMcpAdapter implements IMcpRegistrationAdapter {\n\tconstructor(\n\t\tprivate readonly sdk: AngieMcpSdk,\n\t\tprivate readonly getRegisteredMcpServers: typeof _getRegisteredMcpServers\n\t) {}\n\n\tasync activate(): Promise< void > {\n\t\t// No waitForReady() here: registerLocalServer queues the server and the SDK flushes\n\t\t// the queue once Angie reports ready. waitForReady() only resolves for the SDK copy\n\t\t// that booted the sidebar, which is the host integration, never the editor bundle.\n\t\tawait this.registerEntries( this.getRegisteredMcpServers(), MAX_RETRIES );\n\t}\n\n\tprivate async registerEntries(\n\t\tentries: ReturnType< typeof _getRegisteredMcpServers >,\n\t\tretry: number\n\t): Promise< void > {\n\t\tif ( retry === 0 ) {\n\t\t\t/* eslint-disable-next-line no-console */\n\t\t\tconsole.error(\n\t\t\t\t'Failed to register MCP after 3 retries. failed entries: ',\n\t\t\t\tentries.map( ( [ key ] ) => key )\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tconst failed: typeof entries = [];\n\t\tfor ( const [ key, mcpServer, description ] of entries ) {\n\t\t\ttry {\n\t\t\t\tawait this.sdk.registerLocalServer( {\n\t\t\t\t\ttitle: toMCPTitle( key ),\n\t\t\t\t\tname: `editor-${ key }`,\n\t\t\t\t\tserver: mcpServer,\n\t\t\t\t\tversion: '1.0.0',\n\t\t\t\t\tdescription,\n\t\t\t\t} );\n\t\t\t} catch {\n\t\t\t\tfailed.push( [ key, mcpServer, description ] );\n\t\t\t}\n\t\t}\n\n\t\tif ( failed.length > 0 ) {\n\t\t\treturn this.registerEntries( failed, retry - 1 );\n\t\t}\n\t}\n\n\tonToolRegistered(): void {\n\t\t// Angie tools are registered via McpServer (at activate time).\n\t}\n\n\tonResourceRegistered(): void {\n\t\t// Resources are registered on the McpServer instance directly.\n\t}\n\n\tsendResourceUpdated(): void {\n\t\t// Resource update notifications are sent via MCPRegistryEntry.sendResourceUpdated.\n\t}\n}\n","import { type z } from '@elementor/schema';\nimport { type RequestHandlerExtra } from '@modelcontextprotocol/sdk/shared/protocol.js';\nimport { SamplingMessageSchema, type ServerNotification, type ServerRequest } from '@modelcontextprotocol/sdk/types.js';\n\ntype Server = RequestHandlerExtra< ServerRequest, ServerNotification >;\ntype Opts = {\n\tmaxTokens?: number;\n\tmodelPreferences?: string;\n\tmodel?: string;\n};\n\nconst DEFAULT_OPTS: Opts = {\n\tmaxTokens: 10000,\n\tmodelPreferences: 'openai',\n\tmodel: 'gpt-4o',\n};\n\ntype SamplingOpts = {\n\tsystemPrompt?: string;\n\tstructuredOutput?: z.ZodTypeAny;\n\tmessages: { role: 'user' | 'assistant'; content: { type: 'text'; text: string } }[];\n\trequestParams?: { [ key: string ]: string };\n};\n\nconst DEFAULT_STRUCTURED_OUTPUT = {\n\ttype: 'object',\n\tproperties: {\n\t\tcontent: {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Result',\n\t\t},\n\t},\n\trequired: [ 'content' ],\n\tadditionalProperties: false,\n};\n\nexport const createSampler = ( server: Server, opts: Opts = DEFAULT_OPTS ) => {\n\tconst { maxTokens = 1000, modelPreferences = 'openai', model = 'gpt-4o' } = opts;\n\tconst exec = async ( payload: SamplingOpts ) => {\n\t\tconst systemPromptObject = { ...( payload.systemPrompt ? { systemPrompt: payload.systemPrompt } : {} ) };\n\t\tconst requestParams = payload.requestParams || {};\n\t\tconst result = await server.sendRequest(\n\t\t\t{\n\t\t\t\tmethod: 'sampling/createMessage',\n\t\t\t\tparams: {\n\t\t\t\t\t...requestParams,\n\t\t\t\t\tmaxTokens,\n\t\t\t\t\tmodelPreferences: {\n\t\t\t\t\t\thints: [ { name: modelPreferences } ],\n\t\t\t\t\t},\n\t\t\t\t\tmetadata: {\n\t\t\t\t\t\tmodel,\n\t\t\t\t\t\t...systemPromptObject,\n\t\t\t\t\t\t...{ structured_output: payload.structuredOutput || DEFAULT_STRUCTURED_OUTPUT },\n\t\t\t\t\t},\n\t\t\t\t\tmessages: payload.messages,\n\t\t\t\t},\n\t\t\t\t// ...systemPromptObject,\n\t\t\t},\n\t\t\tSamplingMessageSchema\n\t\t);\n\t\treturn result.content;\n\t};\n\treturn exec;\n};\n","class ToolPrompts {\n\tpublic _description = '';\n\tpublic _parameters: Record< string, string > = {};\n\tpublic _examples: string[] = [];\n\tpublic _furtherInstructions: string[] = [];\n\n\tconstructor( public name: string ) {}\n\n\tdescription(): string;\n\tdescription( desc: string ): this;\n\tdescription( desc?: string | undefined ) {\n\t\tif ( typeof desc === 'undefined' ) {\n\t\t\treturn this._description;\n\t\t}\n\t\tthis._description = desc;\n\t\treturn this;\n\t}\n\n\tparameter( key: string ): string;\n\tparameter( key: string, description: string ): this;\n\tparameter( key: string, description?: string ) {\n\t\tif ( typeof description === 'undefined' ) {\n\t\t\treturn this._parameters[ key ];\n\t\t}\n\t\tthis._parameters[ key ] = `**${ key }**:\\n${ description }`;\n\t\treturn this;\n\t}\n\n\tinstruction( instruction: string ): this {\n\t\tthis._furtherInstructions.push( instruction );\n\t\treturn this;\n\t}\n\n\texample( example: string ): this {\n\t\tthis._examples.push( example );\n\t\treturn this;\n\t}\n\n\tpublic get examples() {\n\t\treturn this._examples.join( '\\n\\n' );\n\t}\n\n\tprompt(): string {\n\t\treturn `# ${ this.name }\n# Description\n${ this._description }\n${ this._parameters.length ? '# Parameters\\n' + Object.values( this._parameters ).join( '\\n\\n' ) : '' }\n${ this._examples.length ? '# Examples\\n' + this.examples : '' }\n${ this._furtherInstructions.length ? '# Further Instructions\\n' + this._furtherInstructions.join( '\\n\\n' ) : '' }\n`.trim();\n\t}\n}\n\nexport const toolPrompts = ( name: string ) => {\n\treturn new ToolPrompts( name );\n};\n","export type ActiveChatInfo = {\n\tsessionId: string;\n\texpiresAt: number;\n};\n\nexport const getActiveChatInfo = (): ActiveChatInfo => {\n\tconst info = localStorage.getItem( 'angie_active_chat_id' );\n\tif ( ! info ) {\n\t\treturn {\n\t\t\texpiresAt: 0,\n\t\t\tsessionId: '',\n\t\t};\n\t}\n\tconst rawData = JSON.parse( info );\n\treturn {\n\t\texpiresAt: rawData.expiresAt as number,\n\t\tsessionId: rawData.sessionId as string,\n\t};\n};\n","import {\n\tAngieInteractionMode,\n\tgetAngieIframe,\n\tsetAngieInteractionMode,\n\ttoggleAngieSidebar,\n} from '@elementor-external/angie-sdk';\n\nimport { isAngieAvailable } from './is-angie-available';\n\nconst getLoadedEditorAngie = () => {\n\treturn window.elementorV2?.editorAngie?.openAngie;\n};\n\nexport const hasLoadedEditorAngie = (): boolean => Boolean( getLoadedEditorAngie() );\n\nexport const openLoadedEditorAngie = ( prompt: string | undefined, mode: AngieInteractionMode ): boolean => {\n\tconst openAngie = getLoadedEditorAngie();\n\n\tif ( ! openAngie ) {\n\t\treturn false;\n\t}\n\n\tPromise.resolve( openAngie( { prompt: prompt ?? '', mode } ) ).catch( ( error ) => {\n\t\t// eslint-disable-next-line no-console\n\t\tconsole.error( 'Failed to open Angie:', error );\n\t} );\n\n\treturn true;\n};\n\nexport const openAngieInAskMode = ( prompt?: string ): void => {\n\topenAngieInMode( prompt, AngieInteractionMode.ASK );\n};\n\nexport const openAngieInAgentMode = ( prompt?: string ): void => {\n\topenAngieInMode( prompt, AngieInteractionMode.AGENT );\n};\n\nconst openAngieInMode = ( prompt: string | undefined, mode: AngieInteractionMode ): void => {\n\tif ( openLoadedEditorAngie( prompt, mode ) ) {\n\t\treturn;\n\t}\n\n\tif ( ! isAngieAvailable() ) {\n\t\treturn;\n\t}\n\n\tconst angieSidebar = getAngieIframe();\n\n\tif ( ! angieSidebar ) {\n\t\treturn;\n\t}\n\n\ttoggleAngieSidebar( angieSidebar, true );\n\tsetAngieInteractionMode( mode );\n\n\tif ( prompt ) {\n\t\twindow.location.hash = `angie-prompt=${ encodeURIComponent( prompt ) }`;\n\t}\n};\n","import { AngieInteractionMode, getAngieIframe, toggleAngieSidebar } from '@elementor-external/angie-sdk';\n\nimport { openLoadedEditorAngie } from './open-angie-in-ask-mode';\n\nexport const sendPromptToAngie = ( prompt?: string ) => {\n\tif ( openLoadedEditorAngie( prompt, AngieInteractionMode.AGENT ) ) {\n\t\treturn;\n\t}\n\n\tconst angieSidebar = getAngieIframe();\n\n\tif ( ! angieSidebar ) {\n\t\treturn;\n\t}\n\n\ttoggleAngieSidebar( angieSidebar, true );\n\n\tif ( ! prompt ) {\n\t\treturn;\n\t}\n\n\twindow.location.hash = `angie-prompt=${ encodeURIComponent( prompt ) }`;\n};\n","import { setReferrerRedirect } from '@elementor-external/angie-sdk';\n\nconst ANGIE_INSTALL_URL = '/wp-admin/plugin-install.php?s=angie&tab=search&type=term';\n\n/**\n * @deprecated Kept only for Elementor Pro compatibility. Will be removed in a future version.\n * @param prompt Optional prompt to pass after redirect.\n */\nexport const redirectToInstallation = ( prompt?: string ) => {\n\tsetReferrerRedirect( window.location.href, prompt );\n\twindow.location.href = ANGIE_INSTALL_URL;\n};\n","import { ANGIE_SIDEBAR_STATE_OPEN, saveState, setReferrerRedirect } from '@elementor-external/angie-sdk';\n\nconst ANGIE_APP_URL = '/wp-admin/admin.php?page=angie-app';\n\n/**\n * @deprecated Kept only for Elementor Pro compatibility. Will be removed in a future version.\n * @param prompt Optional prompt to pass after redirect.\n */\nexport const redirectToAppAdmin = ( prompt?: string ) => {\n\tsetReferrerRedirect( window.location.href, prompt );\n\tsaveState( ANGIE_SIDEBAR_STATE_OPEN );\n\twindow.location.href = ANGIE_APP_URL;\n};\n","import apiFetch from '@wordpress/api-fetch';\n\ntype PluginResponse = {\n\tplugin: string;\n\tstatus: 'active' | 'inactive';\n\tname: string;\n};\n\ntype PluginErrorResponse = {\n\tcode: string;\n\tmessage: string;\n};\n\nexport type InstallAngieResult = { success: true } | { success: false; error: string; code?: string };\n\nconst ANGIE_SLUG = 'angie';\n\nconst isPluginErrorResponse = ( response: unknown ): response is PluginErrorResponse => {\n\treturn typeof response === 'object' && response !== null && 'code' in response && 'message' in response;\n};\n\nconst activatePlugin = async ( pluginPath: string ): Promise< PluginResponse > => {\n\treturn apiFetch< PluginResponse >( {\n\t\tpath: `/wp/v2/plugins/${ pluginPath }`,\n\t\tmethod: 'POST',\n\t\tdata: { status: 'active' },\n\t} );\n};\n\nconst installPlugin = async (): Promise< PluginResponse > => {\n\ttry {\n\t\treturn await apiFetch< PluginResponse >( {\n\t\t\tpath: '/wp/v2/plugins',\n\t\t\tmethod: 'POST',\n\t\t\tdata: {\n\t\t\t\tslug: ANGIE_SLUG,\n\t\t\t\tstatus: 'active',\n\t\t\t},\n\t\t} );\n\t} catch ( error: unknown ) {\n\t\tif ( isPluginErrorResponse( error ) && error.code === 'folder_exists' ) {\n\t\t\treturn activatePlugin( `${ ANGIE_SLUG }/${ ANGIE_SLUG }` );\n\t\t}\n\n\t\tthrow error;\n\t}\n};\n\n/**\n * @deprecated Kept only for Elementor Pro compatibility. Will be removed in a future version.\n */\nexport const installAngiePlugin = async (): Promise< InstallAngieResult > => {\n\ttry {\n\t\tawait installPlugin();\n\n\t\treturn { success: true };\n\t} catch ( error: unknown ) {\n\t\tif ( isPluginErrorResponse( error ) ) {\n\t\t\treturn { success: false, error: error.message, code: error.code };\n\t\t}\n\n\t\treturn { success: false, error: 'Unknown error occurred' };\n\t}\n};\n","import apiFetch from '@wordpress/api-fetch';\n\nexport const saveAngieConsent = async (): Promise< void > => {\n\tawait apiFetch( {\n\t\tpath: '/elementor/v1/angie/consent',\n\t\tmethod: 'POST',\n\t} );\n};\n","import { createAndRegisterAdapters, signalMcpReady } from './mcp-registry';\n\nlet isInitialized = false;\nexport async function startMCPServer() {\n\tif ( isInitialized ) {\n\t\treturn;\n\t}\n\tisInitialized = true;\n\ttry {\n\t\tawait createAndRegisterAdapters();\n\t} catch ( error ) {\n\t\t/* eslint-disable-next-line no-console */\n\t\tconsole.error( 'MCP adapter activation failed:', error );\n\t} finally {\n\t\tsignalMcpReady();\n\t}\n}\n\n// Start right away when the bundle loads after DOMContentLoaded (late or deferred load): the event will\n// not fire again, and `waitForMcpReady()` callers would wait forever.\nif ( typeof document !== 'undefined' && document.readyState === 'loading' ) {\n\tdocument.addEventListener( 'DOMContentLoaded', () => void startMCPServer(), { once: true } );\n} else {\n\tvoid startMCPServer();\n}\n","export const MCP_STYLES_APPLIED_EVENT = 'elementor/mcp/styles-applied';\n\nexport type McpStylesAppliedPayload = {\n\tstyleValue: Record< string, unknown >;\n};\n\nexport function 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;;;ACAA,uBAA4B;AAC5B,IAAAA,oBAAiD;AAEjD,IAAI;AAEJ,IAAM,oBAAN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AAK,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;;;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"]}
|
package/dist/index.mjs
CHANGED
|
@@ -60,56 +60,6 @@ var isAngieSidebarOpen = () => {
|
|
|
60
60
|
import { z as z2 } from "@elementor/schema";
|
|
61
61
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
62
62
|
|
|
63
|
-
// src/utils/to-mcp-title.ts
|
|
64
|
-
var toMCPTitle = (namespace) => {
|
|
65
|
-
const capitalized = namespace.charAt(0).toUpperCase() + namespace.slice(1);
|
|
66
|
-
return `Editor ${capitalized}`;
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
// src/adapters/angie-adapter.ts
|
|
70
|
-
var MAX_RETRIES = 3;
|
|
71
|
-
var AngieMcpAdapter = class {
|
|
72
|
-
constructor(sdk2, getRegisteredMcpServers2) {
|
|
73
|
-
this.sdk = sdk2;
|
|
74
|
-
this.getRegisteredMcpServers = getRegisteredMcpServers2;
|
|
75
|
-
}
|
|
76
|
-
async activate() {
|
|
77
|
-
await this.registerEntries(this.getRegisteredMcpServers(), MAX_RETRIES);
|
|
78
|
-
}
|
|
79
|
-
async registerEntries(entries, retry) {
|
|
80
|
-
if (retry === 0) {
|
|
81
|
-
console.error(
|
|
82
|
-
"Failed to register MCP after 3 retries. failed entries: ",
|
|
83
|
-
entries.map(([key]) => key)
|
|
84
|
-
);
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
const failed = [];
|
|
88
|
-
for (const [key, mcpServer, description] of entries) {
|
|
89
|
-
try {
|
|
90
|
-
await this.sdk.registerLocalServer({
|
|
91
|
-
title: toMCPTitle(key),
|
|
92
|
-
name: `editor-${key}`,
|
|
93
|
-
server: mcpServer,
|
|
94
|
-
version: "1.0.0",
|
|
95
|
-
description
|
|
96
|
-
});
|
|
97
|
-
} catch {
|
|
98
|
-
failed.push([key, mcpServer, description]);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
if (failed.length > 0) {
|
|
102
|
-
return this.registerEntries(failed, retry - 1);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
onToolRegistered() {
|
|
106
|
-
}
|
|
107
|
-
onResourceRegistered() {
|
|
108
|
-
}
|
|
109
|
-
sendResourceUpdated() {
|
|
110
|
-
}
|
|
111
|
-
};
|
|
112
|
-
|
|
113
63
|
// src/adapters/web-mcp-adapter.ts
|
|
114
64
|
import { zodToJsonSchema } from "zod-to-json-schema";
|
|
115
65
|
import { z } from "@elementor/schema";
|
|
@@ -332,6 +282,12 @@ var registerServerDocsResource = (server, namespace, title, docs, onRegistered)
|
|
|
332
282
|
onRegistered(name, uri, handler);
|
|
333
283
|
};
|
|
334
284
|
|
|
285
|
+
// src/utils/to-mcp-title.ts
|
|
286
|
+
var toMCPTitle = (namespace) => {
|
|
287
|
+
const capitalized = namespace.charAt(0).toUpperCase() + namespace.slice(1);
|
|
288
|
+
return `Editor ${capitalized}`;
|
|
289
|
+
};
|
|
290
|
+
|
|
335
291
|
// src/mcp-registry.ts
|
|
336
292
|
var mcpRegistry = {};
|
|
337
293
|
var mcpDescriptions = {};
|
|
@@ -361,14 +317,17 @@ var registerMcpAdapter = (adapter) => {
|
|
|
361
317
|
var signalMcpReady = () => {
|
|
362
318
|
resolveReady();
|
|
363
319
|
};
|
|
320
|
+
var waitForMcpReady = () => readyPromise;
|
|
321
|
+
var activateMcpAdapter = async (adapter) => {
|
|
322
|
+
await readyPromise;
|
|
323
|
+
registerMcpAdapter(adapter);
|
|
324
|
+
await adapter.activate();
|
|
325
|
+
};
|
|
364
326
|
var createAndRegisterAdapters = async () => {
|
|
365
327
|
const modelContext = getModelContext();
|
|
366
328
|
if (modelContext) {
|
|
367
329
|
registerMcpAdapter(new WebMCPAdapter(modelContext));
|
|
368
330
|
}
|
|
369
|
-
if (isAngieAvailable()) {
|
|
370
|
-
registerMcpAdapter(new AngieMcpAdapter(getSDK(), getRegisteredMcpServers));
|
|
371
|
-
}
|
|
372
331
|
await Promise.all(registrationAdapters.map((adapter) => adapter.activate()));
|
|
373
332
|
};
|
|
374
333
|
function callAdapters(fn) {
|
|
@@ -534,6 +493,50 @@ function createToolRegistry(server, serverName, serverDocsUri) {
|
|
|
534
493
|
};
|
|
535
494
|
}
|
|
536
495
|
|
|
496
|
+
// src/adapters/angie-adapter.ts
|
|
497
|
+
var MAX_RETRIES = 3;
|
|
498
|
+
var AngieMcpAdapter = class {
|
|
499
|
+
constructor(sdk2, getRegisteredMcpServers2) {
|
|
500
|
+
this.sdk = sdk2;
|
|
501
|
+
this.getRegisteredMcpServers = getRegisteredMcpServers2;
|
|
502
|
+
}
|
|
503
|
+
async activate() {
|
|
504
|
+
await this.registerEntries(this.getRegisteredMcpServers(), MAX_RETRIES);
|
|
505
|
+
}
|
|
506
|
+
async registerEntries(entries, retry) {
|
|
507
|
+
if (retry === 0) {
|
|
508
|
+
console.error(
|
|
509
|
+
"Failed to register MCP after 3 retries. failed entries: ",
|
|
510
|
+
entries.map(([key]) => key)
|
|
511
|
+
);
|
|
512
|
+
return;
|
|
513
|
+
}
|
|
514
|
+
const failed = [];
|
|
515
|
+
for (const [key, mcpServer, description] of entries) {
|
|
516
|
+
try {
|
|
517
|
+
await this.sdk.registerLocalServer({
|
|
518
|
+
title: toMCPTitle(key),
|
|
519
|
+
name: `editor-${key}`,
|
|
520
|
+
server: mcpServer,
|
|
521
|
+
version: "1.0.0",
|
|
522
|
+
description
|
|
523
|
+
});
|
|
524
|
+
} catch {
|
|
525
|
+
failed.push([key, mcpServer, description]);
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
if (failed.length > 0) {
|
|
529
|
+
return this.registerEntries(failed, retry - 1);
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
onToolRegistered() {
|
|
533
|
+
}
|
|
534
|
+
onResourceRegistered() {
|
|
535
|
+
}
|
|
536
|
+
sendResourceUpdated() {
|
|
537
|
+
}
|
|
538
|
+
};
|
|
539
|
+
|
|
537
540
|
// src/sampler.ts
|
|
538
541
|
import { SamplingMessageSchema } from "@modelcontextprotocol/sdk/types.js";
|
|
539
542
|
var DEFAULT_OPTS = {
|
|
@@ -669,7 +672,13 @@ var openLoadedEditorAngie = (prompt, mode) => {
|
|
|
669
672
|
return true;
|
|
670
673
|
};
|
|
671
674
|
var openAngieInAskMode = (prompt) => {
|
|
672
|
-
|
|
675
|
+
openAngieInMode(prompt, AngieInteractionMode.ASK);
|
|
676
|
+
};
|
|
677
|
+
var openAngieInAgentMode = (prompt) => {
|
|
678
|
+
openAngieInMode(prompt, AngieInteractionMode.AGENT);
|
|
679
|
+
};
|
|
680
|
+
var openAngieInMode = (prompt, mode) => {
|
|
681
|
+
if (openLoadedEditorAngie(prompt, mode)) {
|
|
673
682
|
return;
|
|
674
683
|
}
|
|
675
684
|
if (!isAngieAvailable()) {
|
|
@@ -680,7 +689,7 @@ var openAngieInAskMode = (prompt) => {
|
|
|
680
689
|
return;
|
|
681
690
|
}
|
|
682
691
|
toggleAngieSidebar(angieSidebar, true);
|
|
683
|
-
setAngieInteractionMode(
|
|
692
|
+
setAngieInteractionMode(mode);
|
|
684
693
|
if (prompt) {
|
|
685
694
|
window.location.hash = `angie-prompt=${encodeURIComponent(prompt)}`;
|
|
686
695
|
}
|
|
@@ -786,7 +795,7 @@ async function startMCPServer() {
|
|
|
786
795
|
signalMcpReady();
|
|
787
796
|
}
|
|
788
797
|
}
|
|
789
|
-
if (typeof document !== "undefined") {
|
|
798
|
+
if (typeof document !== "undefined" && document.readyState === "loading") {
|
|
790
799
|
document.addEventListener("DOMContentLoaded", () => void startMCPServer(), { once: true });
|
|
791
800
|
} else {
|
|
792
801
|
void startMCPServer();
|
|
@@ -803,11 +812,13 @@ var getAngieSdk = () => getSDK();
|
|
|
803
812
|
export {
|
|
804
813
|
ANGIE_MODEL_PREFERENCES,
|
|
805
814
|
ANGIE_REQUIRED_RESOURCES,
|
|
815
|
+
AngieMcpAdapter,
|
|
806
816
|
MessageEventType as AngieMessageEvenetType,
|
|
807
817
|
MCP_STYLES_APPLIED_EVENT,
|
|
808
818
|
McpServer2 as McpServer,
|
|
809
819
|
ResourceTemplate,
|
|
810
820
|
SamplingMessageSchema2 as SamplingMessageSchema,
|
|
821
|
+
activateMcpAdapter,
|
|
811
822
|
canCreateWidget,
|
|
812
823
|
createAndRegisterAdapters,
|
|
813
824
|
createSampler,
|
|
@@ -821,6 +832,7 @@ export {
|
|
|
821
832
|
installAngiePlugin,
|
|
822
833
|
isAngieAvailable,
|
|
823
834
|
isAngieSidebarOpen,
|
|
835
|
+
openAngieInAgentMode,
|
|
824
836
|
openAngieInAskMode,
|
|
825
837
|
redirectToAppAdmin,
|
|
826
838
|
redirectToInstallation,
|
|
@@ -830,6 +842,7 @@ export {
|
|
|
830
842
|
sendPromptToAngie,
|
|
831
843
|
signalMcpReady,
|
|
832
844
|
startMCPServer,
|
|
833
|
-
toolPrompts
|
|
845
|
+
toolPrompts,
|
|
846
|
+
waitForMcpReady
|
|
834
847
|
};
|
|
835
848
|
//# sourceMappingURL=index.mjs.map
|
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/utils/to-mcp-title.ts","../src/adapters/angie-adapter.ts","../src/adapters/web-mcp-adapter.ts","../src/utils/register-model-context-tool.ts","../src/angie-annotations.ts","../src/test-utils/mock-mcp-registry.ts","../src/utils/get-model-context.ts","../src/utils/merge-required-resources.ts","../src/utils/create-simple-resource-handler.ts","../src/utils/register-server-docs-resource.ts","../src/sampler.ts","../src/utils/prompt-builder.ts","../src/utils/get-active-chat-info.ts","../src/utils/open-angie-in-ask-mode.ts","../src/utils/send-prompt-to-angie.ts","../src/utils/redirect-to-installation.ts","../src/utils/redirect-to-app-admin.ts","../src/utils/install-angie-plugin.ts","../src/utils/save-angie-consent.ts","../src/init.ts","../src/events/mcp-styles-applied-event.ts"],"sourcesContent":["import { AngieMcpSdk } from '@elementor-external/angie-sdk';\nexport { getAngieIframe, MessageEventType } from '@elementor-external/angie-sdk';\n\nlet sdk: AngieMcpSdk;\n\nclass RetriableAngieSDK extends AngieMcpSdk {\n\tpublic async waitForReady(): Promise< void > {\n\t\tlet retryCount = 3;\n\t\twhile ( retryCount > 0 ) {\n\t\t\ttry {\n\t\t\t\tawait super.waitForReady();\n\t\t\t\treturn;\n\t\t\t} catch {\n\t\t\t\tretryCount--;\n\t\t\t\tawait sleep();\n\t\t\t}\n\t\t}\n\t\treturn new Promise( () => {} ); // never resolves\n\t}\n}\n\nconst sleep = ( ms = 10_000 ) =>\n\tnew Promise( ( resolve ) => {\n\t\tsetTimeout( resolve, ms );\n\t} );\n\nexport const getSDK = () => {\n\t// @ts-ignore - QUnit fails this\n\tconst isMCPDisabled = !! ( globalThis as Record< string, unknown > ).__ELEMENTOR_MCP_DISABLED__;\n\tif ( isMCPDisabled ) {\n\t\treturn {} as unknown as AngieMcpSdk;\n\t}\n\tif ( ! sdk ) {\n\t\tsdk = new RetriableAngieSDK();\n\t}\n\treturn sdk;\n};\n","import './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 { 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, 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 { AngieMcpAdapter } from './adapters/angie-adapter';\nimport { type IMcpRegistrationAdapter, type McpResourceHandler, type McpResourceUriOrTemplate } from './adapters/types';\nimport { WebMCPAdapter } from './adapters/web-mcp-adapter';\nimport {\n\tANGIE_MODEL_PREFERENCES,\n\tANGIE_REQUIRED_RESOURCES,\n\ttype AngieModelPreferences,\n\tcreateDefaultModelPreferences,\n} from './angie-annotations';\nimport { mockMcpRegistry } from './test-utils/mock-mcp-registry';\nimport { getModelContext } from './utils/get-model-context';\nimport { getSDK } from './utils/get-sdk';\nimport { isAngieAvailable } from './utils/is-angie-available';\nimport { mergeRequiredResources, type ResourceList } from './utils/merge-required-resources';\nimport { registerServerDocsResource } from './utils/register-server-docs-resource';\nimport { toMCPTitle } from './utils/to-mcp-title';\n\ntype ZodRawShape = z3.ZodRawShape;\n\nconst mcpRegistry: { [ namespace: string ]: McpServer } = {};\nconst mcpDescriptions: { [ namespace: string ]: string } = {};\n// @ts-ignore - QUnit fails this\nconst isMcpRegistrationActivated = false || typeof globalThis.jest !== 'undefined';\n\nconst registrationAdapters: IMcpRegistrationAdapter[] = [];\nconst bufferedTools: Parameters< IMcpRegistrationAdapter[ 'onToolRegistered' ] >[] = [];\nconst bufferedResources: Parameters< IMcpRegistrationAdapter[ 'onResourceRegistered' ] >[] = [];\n\nlet resolveReady!: () => void;\nconst readyPromise = new Promise< void >( ( resolve ) => {\n\tresolveReady = resolve;\n} );\n\nexport const registerMcpAdapter = ( adapter: IMcpRegistrationAdapter ): void => {\n\tregistrationAdapters.push( adapter );\n\tfor ( const tool of bufferedTools ) {\n\t\ttry {\n\t\t\tadapter.onToolRegistered( tool[ 0 ], tool[ 1 ] );\n\t\t} catch {\n\t\t\t// exit quietly\n\t\t}\n\t}\n\tfor ( const resource of bufferedResources ) {\n\t\ttry {\n\t\t\tadapter.onResourceRegistered( ...resource );\n\t\t} catch {\n\t\t\t// exit quietly\n\t\t}\n\t}\n};\n\nexport const signalMcpReady = (): void => {\n\tresolveReady();\n};\n\nexport const createAndRegisterAdapters = async (): Promise< void > => {\n\tconst modelContext = getModelContext();\n\n\tif ( modelContext ) {\n\t\tregisterMcpAdapter( new WebMCPAdapter( modelContext ) );\n\t}\n\n\tif ( isAngieAvailable() ) {\n\t\tregisterMcpAdapter( new AngieMcpAdapter( getSDK(), getRegisteredMcpServers ) );\n\t}\n\n\tawait Promise.all( registrationAdapters.map( ( adapter ) => adapter.activate() ) );\n};\n\n// utility function to run a callback on all MCP interfaces\nfunction callAdapters( fn: ( adapter: IMcpRegistrationAdapter ) => unknown ) {\n\tfor ( const adapter of registrationAdapters ) {\n\t\ttry {\n\t\t\tfn( adapter );\n\t\t} catch {\n\t\t\t// adapter failed — exit quietly, continue to next\n\t\t}\n\t}\n}\n\nexport const registerMcp = ( mcp: McpServer, name: string ) => {\n\tconst mcpName = isAlphabet( name );\n\tmcpRegistry[ mcpName ] = mcp;\n};\n\nexport const getRegisteredMcpServers = (): Array< [ string, McpServer, string ] > => {\n\treturn Object.entries( mcpRegistry ).map( ( [ key, server ] ) => [ key, server, mcpDescriptions[ key ] || key ] );\n};\n\nconst isAlphabet = ( str: string ): string | never => {\n\tconst passes = !! str && /^[a-z_]+$/.test( str );\n\tif ( ! passes ) {\n\t\tthrow new Error( 'Not alphabet' );\n\t}\n\treturn str;\n};\n\n/**\n * @param namespace The namespace of the MCP server. It should contain only lowercase alphabetic characters.\n * @param options\n * @param options.instructions Short hint about the MCP and its toolset (MCP SDK `instructions`; keeps payload small).\n * @param options.docs Full documentation registered as a lazy-loaded resource.\n * When provided, it is registered at elementor://{namespace}/server-docs\n * and auto-injected into every tool's requiredResources.\n */\nexport const getMCPByDomain = (\n\tnamespace: string,\n\toptions?: { docs?: string; instructions?: string }\n): MCPRegistryEntry => {\n\tconst mcpName = `editor-${ isAlphabet( namespace ) }`;\n\tconst title = toMCPTitle( namespace );\n\t// @ts-ignore - QUnit fails this\n\tif ( typeof globalThis.jest !== 'undefined' ) {\n\t\treturn mockMcpRegistry();\n\t}\n\tif ( ! mcpRegistry[ namespace ] ) {\n\t\tmcpRegistry[ namespace ] = new McpServer(\n\t\t\t{ name: mcpName, title, version: '1.0.0' },\n\t\t\t{ instructions: options?.instructions, capabilities: { resources: { subscribe: true } } }\n\t\t);\n\t\tif ( options?.docs ) {\n\t\t\tregisterServerDocsResource( mcpRegistry[ namespace ], namespace, title, options.docs, ( ...args ) => {\n\t\t\t\tbufferedResources.push( args );\n\t\t\t\tcallAdapters( ( adapter ) => adapter.onResourceRegistered( ...args ) );\n\t\t\t} );\n\t\t}\n\t}\n\tconst mcpServer = mcpRegistry[ namespace ];\n\tconst serverDocsUri = options?.docs ? `elementor://${ namespace }/server-docs` : undefined;\n\tconst { addTool } = createToolRegistry( mcpServer, mcpName, serverDocsUri );\n\treturn {\n\t\twaitForReady: () => readyPromise,\n\t\t// @ts-expect-error: TS is unable to infer the type here\n\t\tresource: async ( ...args: Parameters< McpServer[ 'registerResource' ] > ) => {\n\t\t\tconst [ name, uriOrTemplate, ...rest ] = args as [ string, unknown, ...unknown[] ];\n\t\t\tconst handler = rest[ rest.length - 1 ] as McpResourceHandler;\n\t\t\tconst resourceArgs: Parameters< IMcpRegistrationAdapter[ 'onResourceRegistered' ] > = [\n\t\t\t\tname,\n\t\t\t\turiOrTemplate as McpResourceUriOrTemplate,\n\t\t\t\thandler,\n\t\t\t];\n\t\t\tbufferedResources.push( resourceArgs );\n\t\t\tcallAdapters( ( adapter ) => adapter.onResourceRegistered( ...resourceArgs ) );\n\t\t\treturn mcpServer.registerResource( ...args );\n\t\t},\n\t\tsendResourceUpdated: ( ...args: Parameters< McpServer[ 'server' ][ 'sendResourceUpdated' ] > ) => {\n\t\t\tcallAdapters( ( adapter ) => adapter.sendResourceUpdated( { uri: args[ 0 ].uri } ) );\n\t\t\treturn Promise.resolve( mcpServer.server.sendResourceUpdated( ...args ) ).catch( ( error: Error ) => {\n\t\t\t\tif ( error?.message?.includes( 'Not connected' ) ) {\n\t\t\t\t\treturn; // Expected when no MCP client is connected yet\n\t\t\t\t}\n\t\t\t\tif ( error?.message?.includes( 'does not support notifying about resources' ) ) {\n\t\t\t\t\treturn; // Server capability not declared — safe to ignore\n\t\t\t\t}\n\t\t\t\tthrow error;\n\t\t\t} );\n\t\t},\n\t\taddTool,\n\t\tsetMCPDescription: ( description: string ) => {\n\t\t\tmcpDescriptions[ namespace ] = description;\n\t\t},\n\t};\n};\n\nexport interface MCPRegistryEntry {\n\taddTool: < T extends undefined | z.ZodRawShape = undefined, O extends undefined | z.ZodRawShape = undefined >(\n\t\topts: ToolRegistrationOptions< T, O >\n\t) => void;\n\tsetMCPDescription: ( description: string ) => void;\n\tsendResourceUpdated: McpServer[ 'server' ][ 'sendResourceUpdated' ];\n\tresource: McpServer[ 'registerResource' ];\n\twaitForReady: () => Promise< void >;\n}\n\ntype ToolRegistrationOptions<\n\tInputArgs extends undefined | z.ZodRawShape = undefined,\n\tOutputSchema extends undefined | z.ZodRawShape = undefined,\n\tExpectedOutput = OutputSchema extends z.ZodRawShape ? z.objectOutputType< OutputSchema, z.ZodTypeAny > : string,\n> = {\n\tname: string;\n\tdescription: string;\n\tschema?: InputArgs;\n\t/**\n\t * Auto added fields:\n\t * @param errors z.string().optional().describe('Error message if the tool failed')\n\t */\n\toutputSchema?: OutputSchema;\n\thandler: InputArgs extends z.ZodRawShape\n\t\t? (\n\t\t\t\targs: z.objectOutputType< InputArgs, z.ZodTypeAny >,\n\t\t\t\textra: RequestHandlerExtra< ServerRequest, ServerNotification >\n\t\t ) => ExpectedOutput | Promise< ExpectedOutput >\n\t\t: (\n\t\t\t\targs: unknown,\n\t\t\t\textra: RequestHandlerExtra< ServerRequest, ServerNotification >\n\t\t ) => ExpectedOutput | Promise< ExpectedOutput >;\n\tisDestructive?: boolean;\n\trequiredResources?: ResourceList;\n\tmodelPreferences?: AngieModelPreferences;\n};\n\nfunction createToolRegistry( server: McpServer, serverName: string, serverDocsUri?: string ) {\n\tfunction addTool<\n\t\tT extends undefined | z.ZodRawShape = undefined,\n\t\tO extends undefined | z.ZodRawShape = undefined,\n\t>( opts: ToolRegistrationOptions< T, O > ) {\n\t\tconst outputSchema = opts.outputSchema as ZodRawShape | undefined;\n\t\tif ( outputSchema ) {\n\t\t\tObject.assign(\n\t\t\t\toutputSchema,\n\t\t\t\toutputSchema.errors ?? {\n\t\t\t\t\terrors: z.string().optional().describe( 'Error message if the tool failed' ),\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t\t// @ts-ignore: TS is unable to infer the type here\n\t\tconst inputSchema: ZodRawShape = opts.schema ? opts.schema : {};\n\t\tconst toolCallback: ToolCallback< ZodRawShape > = async function ( args, extra ) {\n\t\t\ttry {\n\t\t\t\tconst invocationResult = await opts.handler( opts.schema ? args : {}, extra );\n\t\t\t\treturn {\n\t\t\t\t\t// structuredContent: typeof invocationResult === 'string' ? undefined : invocationResult,\n\t\t\t\t\tcontent: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: 'text',\n\t\t\t\t\t\t\ttext:\n\t\t\t\t\t\t\t\ttypeof invocationResult === 'string'\n\t\t\t\t\t\t\t\t\t? invocationResult\n\t\t\t\t\t\t\t\t\t: JSON.stringify( invocationResult ),\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t};\n\t\t\t} catch ( error ) {\n\t\t\t\treturn {\n\t\t\t\t\tisError: true,\n\t\t\t\t\tstructuredContent: {\n\t\t\t\t\t\terrors: ( error as Error ).message || 'Unknown error',\n\t\t\t\t\t},\n\t\t\t\t\tcontent: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: 'text',\n\t\t\t\t\t\t\ttext:\n\t\t\t\t\t\t\t\t( ( error as Error ).message || 'Unknown error' ) +\n\t\t\t\t\t\t\t\tJSON.stringify( ( error as { response?: { data: unknown } } ).response?.data || error ),\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t};\n\t\t\t}\n\t\t};\n\t\tconst annotations: Record< string, unknown > = {\n\t\t\tdestructiveHint: opts.isDestructive,\n\t\t\treadOnlyHint: opts.isDestructive ? false : undefined,\n\t\t\ttitle: opts.name,\n\t\t};\n\t\tconst mergedResources = mergeRequiredResources( opts.requiredResources, serverDocsUri );\n\t\tconst angieAnnotations = {\n\t\t\t[ ANGIE_MODEL_PREFERENCES ]: opts.modelPreferences ?? createDefaultModelPreferences(),\n\t\t\t[ ANGIE_REQUIRED_RESOURCES ]: mergedResources,\n\t\t};\n\t\tserver.registerTool(\n\t\t\topts.name,\n\t\t\t{\n\t\t\t\tdescription: opts.description,\n\t\t\t\tinputSchema,\n\t\t\t\t// TODO: Uncomment this when the outputSchema is stable\n\t\t\t\t// outputSchema,\n\t\t\t\ttitle: opts.name,\n\t\t\t\tannotations,\n\t\t\t\t_meta: angieAnnotations,\n\t\t\t},\n\t\t\ttoolCallback\n\t\t);\n\t\tconst toolDescriptor = {\n\t\t\tname: opts.name,\n\t\t\tdescription: opts.description,\n\t\t\tinputSchema: inputSchema as object,\n\t\t\texecute: ( params: Record< string, unknown > ) =>\n\t\t\t\ttoolCallback(\n\t\t\t\t\tparams as Parameters< typeof toolCallback >[ 0 ],\n\t\t\t\t\t/* WebMCP: no protocol session — handlers must not rely on `extra` here */\n\t\t\t\t\t{} as RequestHandlerExtra< ServerRequest, ServerNotification >\n\t\t\t\t) as Promise< unknown >,\n\t\t};\n\t\tconst extraData = {\n\t\t\tresources: [ `Server resource name: ${ serverName }, Required to fetch!` ],\n\t\t\trequiredResources: mergedResources?.map( ( resource ) => resource.uri ) ?? [],\n\t\t};\n\t\tbufferedTools.push( [ toolDescriptor, extraData ] );\n\t\tcallAdapters( ( adapter ) => adapter.onToolRegistered( toolDescriptor, extraData ) );\n\t\tif ( isMcpRegistrationActivated ) {\n\t\t\tserver.sendToolListChanged();\n\t\t}\n\t}\n\treturn {\n\t\taddTool,\n\t};\n}\n","export const toMCPTitle = ( namespace: string ): string => {\n\tconst capitalized = namespace.charAt( 0 ).toUpperCase() + namespace.slice( 1 );\n\treturn `Editor ${ capitalized }`;\n};\n","import { type AngieMcpSdk } from '@elementor-external/angie-sdk';\n\nimport { type getRegisteredMcpServers as _getRegisteredMcpServers } from '../mcp-registry';\nimport { toMCPTitle } from '../utils/to-mcp-title';\nimport { type IMcpRegistrationAdapter } from './types';\n\nconst MAX_RETRIES = 3;\n\nexport class AngieMcpAdapter implements IMcpRegistrationAdapter {\n\tconstructor(\n\t\tprivate readonly sdk: AngieMcpSdk,\n\t\tprivate readonly getRegisteredMcpServers: typeof _getRegisteredMcpServers\n\t) {}\n\n\tasync activate(): Promise< void > {\n\t\t// No waitForReady() here: registerLocalServer queues the server and the SDK flushes\n\t\t// the queue once Angie reports ready. waitForReady() only resolves for the SDK copy\n\t\t// that booted the sidebar, which is the host integration, never the editor bundle.\n\t\tawait this.registerEntries( this.getRegisteredMcpServers(), MAX_RETRIES );\n\t}\n\n\tprivate async registerEntries(\n\t\tentries: ReturnType< typeof _getRegisteredMcpServers >,\n\t\tretry: number\n\t): Promise< void > {\n\t\tif ( retry === 0 ) {\n\t\t\t/* eslint-disable-next-line no-console */\n\t\t\tconsole.error(\n\t\t\t\t'Failed to register MCP after 3 retries. failed entries: ',\n\t\t\t\tentries.map( ( [ key ] ) => key )\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tconst failed: typeof entries = [];\n\t\tfor ( const [ key, mcpServer, description ] of entries ) {\n\t\t\ttry {\n\t\t\t\tawait this.sdk.registerLocalServer( {\n\t\t\t\t\ttitle: toMCPTitle( key ),\n\t\t\t\t\tname: `editor-${ key }`,\n\t\t\t\t\tserver: mcpServer,\n\t\t\t\t\tversion: '1.0.0',\n\t\t\t\t\tdescription,\n\t\t\t\t} );\n\t\t\t} catch {\n\t\t\t\tfailed.push( [ key, mcpServer, description ] );\n\t\t\t}\n\t\t}\n\n\t\tif ( failed.length > 0 ) {\n\t\t\treturn this.registerEntries( failed, retry - 1 );\n\t\t}\n\t}\n\n\tonToolRegistered(): void {\n\t\t// Angie tools are registered via McpServer (at activate time).\n\t}\n\n\tonResourceRegistered(): void {\n\t\t// Resources are registered on the McpServer instance directly.\n\t}\n\n\tsendResourceUpdated(): void {\n\t\t// Resource update notifications are sent via MCPRegistryEntry.sendResourceUpdated.\n\t}\n}\n","import { zodToJsonSchema } from 'zod-to-json-schema';\nimport { z, type z3 } from '@elementor/schema';\n\nimport { type ModelContextRegisterTool, registerModelContextTool } from '../utils/register-model-context-tool';\nimport {\n\ttype IMcpRegistrationAdapter,\n\ttype McpResourceHandler,\n\ttype McpResourceUriOrTemplate,\n\ttype McpToolDescriptor,\n\ttype UriTemplate,\n} from './types';\n\ntype ZodRawShape = z3.ZodRawShape;\n\nexport type ModelContext = {\n\tregisterTool: ModelContextRegisterTool;\n\tunregisterTool?: ( name: string ) => void;\n};\n\ntype ResourceEntry = {\n\tpattern: string;\n\tmatch: ( uri: string ) => Record< string, string | string[] > | null;\n\thandler: McpResourceHandler;\n};\n\nexport class WebMCPAdapter implements IMcpRegistrationAdapter {\n\tprivate readonly registeredToolNames = new Set< string >();\n\tprivate readonly resourceEntries: ResourceEntry[] = [];\n\tprivate activated = false;\n\n\tconstructor( private readonly ctx: ModelContext ) {}\n\n\tactivate(): Promise< void > {\n\t\tif ( this.activated ) {\n\t\t\treturn Promise.resolve();\n\t\t}\n\t\tthis.activated = true;\n\t\treturn registerModelContextTool( this.ctx.registerTool, {\n\t\t\tname: 'editor-resource-getter',\n\t\t\tdescription:\n\t\t\t\t'Get an editor resource by URI, or search for available resources by partial URI. Pass a full URI to retrieve content, or a partial string to discover matching patterns.',\n\t\t\tinputSchema: {\n\t\t\t\ttype: 'object',\n\t\t\t\tproperties: {\n\t\t\t\t\turi: {\n\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t'A full resource URI (e.g. elementor://style/best-practices) or a partial string to search across available resource patterns.',\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\trequired: [ 'uri' ],\n\t\t\t},\n\t\t\texecute: async ( params ) => {\n\t\t\t\tconst query = params.uri as string;\n\t\t\t\tconst entries = this.resourceEntries;\n\n\t\t\t\tif ( entries.length === 0 ) {\n\t\t\t\t\treturn 'No resources are registered yet.';\n\t\t\t\t}\n\n\t\t\t\t// Exact URI match\n\t\t\t\tfor ( const entry of entries ) {\n\t\t\t\t\tconst variables = entry.match( query );\n\t\t\t\t\tif ( variables !== null ) {\n\t\t\t\t\t\tlet resourceUrl: URL;\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tresourceUrl = new URL( query );\n\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\treturn `Invalid URI '${ query }'. Provide a valid resource URI or a partial string to search patterns.`;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst result = await entry.handler( resourceUrl, variables );\n\t\t\t\t\t\treturn result.contents?.[ 0 ]?.text ?? JSON.stringify( result );\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Partial search fallback\n\t\t\t\tconst matches = entries.map( ( e ) => e.pattern ).filter( ( pattern ) => pattern.includes( query ) );\n\t\t\t\tif ( matches.length > 0 ) {\n\t\t\t\t\treturn `Found ${ matches.length } matching resource pattern(s):\\n${ matches.join(\n\t\t\t\t\t\t'\\n'\n\t\t\t\t\t) }\\n\\nProvide a full URI to retrieve the resource content.`;\n\t\t\t\t}\n\n\t\t\t\tconst available = entries.map( ( e ) => e.pattern ).join( '\\n' );\n\t\t\t\tthrow new Error( `No resource matched '${ query }'.\\n\\nAvailable patterns:\\n${ available }` );\n\t\t\t},\n\t\t} );\n\t}\n\n\tonToolRegistered(\n\t\ttool: McpToolDescriptor,\n\t\textraData?: { resources: string[]; requiredResources: string[] }\n\t): void {\n\t\tlet jsonSchema: object;\n\t\ttry {\n\t\t\tjsonSchema = zodToJsonSchema( z.object( tool.inputSchema as ZodRawShape ) );\n\t\t} catch {\n\t\t\tjsonSchema = tool.inputSchema;\n\t\t}\n\n\t\tif ( this.registeredToolNames.has( tool.name ) ) {\n\t\t\tthis.ctx.unregisterTool?.( tool.name );\n\t\t\tthis.registeredToolNames.delete( tool.name );\n\t\t}\n\n\t\tlet resourcesDescription = '';\n\t\tif ( extraData ) {\n\t\t\tif ( extraData.resources?.length > 0 ) {\n\t\t\t\tresourcesDescription += `#Resources:\\n${ extraData.resources?.join( '\\n' ) }\\n\\n`;\n\t\t\t}\n\t\t\tif ( extraData.requiredResources?.length > 0 ) {\n\t\t\t\tresourcesDescription += `#Required Resources:\\n${ extraData.requiredResources?.join( '\\n' ) }\\n\\n`;\n\t\t\t}\n\t\t\tresourcesDescription += `To read resources, use editor-resource-getter tool.\\n\\n`;\n\t\t}\n\t\tvoid registerModelContextTool( this.ctx.registerTool, {\n\t\t\tname: tool.name,\n\t\t\tdescription: `${ resourcesDescription }${ tool.description }`,\n\t\t\tinputSchema: jsonSchema,\n\t\t\texecute: tool.execute,\n\t\t} ).then( () => {\n\t\t\tthis.registeredToolNames.add( tool.name );\n\t\t} );\n\t}\n\n\tonResourceRegistered( _name: string, uriOrTemplate: McpResourceUriOrTemplate, handler: McpResourceHandler ): void {\n\t\tif ( typeof uriOrTemplate === 'string' ) {\n\t\t\tthis.resourceEntries.push( {\n\t\t\t\tpattern: uriOrTemplate,\n\t\t\t\tmatch: ( uri ) => ( uri === uriOrTemplate ? {} : null ),\n\t\t\t\thandler,\n\t\t\t} );\n\t\t} else {\n\t\t\tconst template = uriOrTemplate.uriTemplate as UriTemplate;\n\t\t\tthis.resourceEntries.push( {\n\t\t\t\tpattern: template.toString(),\n\t\t\t\tmatch: ( uri ) => template.match( uri ),\n\t\t\t\thandler,\n\t\t\t} );\n\t\t}\n\t}\n\n\tsendResourceUpdated(): void {\n\t\t// WebMCP has no server-push mechanism — no-op\n\t}\n}\n","import { type McpToolDescriptor } from '../adapters/types';\n\nexport type ModelContextRegisterTool = ( tool: McpToolDescriptor ) => void | Promise< void >;\n\nexport async function registerModelContextTool(\n\tregisterTool: ModelContextRegisterTool,\n\ttool: McpToolDescriptor\n): Promise< void > {\n\ttry {\n\t\tawait Promise.resolve( registerTool( tool ) );\n\t} catch ( error ) {\n\t\t/* eslint-disable-next-line no-console */\n\t\tconsole.error( 'Tool registration failed:', error );\n\t}\n}\n","export const ANGIE_MODEL_PREFERENCES = 'angie/modelPreferences' as const;\nexport const ANGIE_REQUIRED_RESOURCES = 'angie/requiredResources' as const;\n\nexport interface AngieModelPreferences {\n\thints?: Array< { name: string } >;\n\tcostPriority?: number; // 0-1 (future use)\n\tspeedPriority?: number; // 0-1 (future use)\n\tintelligencePriority?: number; // 0-1 (future use)\n}\n\nexport function createDefaultModelPreferences(): AngieModelPreferences {\n\treturn {\n\t\thints: [ { name: 'claude-sonnet-4-6' } ],\n\t};\n}\n","import { type McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\n\nimport { type MCPRegistryEntry } from '../mcp-registry';\n\nconst mock = new Proxy(\n\t{},\n\t{\n\t\tget: () => {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unused-vars\n\t\t\tfunction mockedFn( ..._: unknown[] ) {}\n\t\t\treturn mockedFn;\n\t\t},\n\t}\n);\n\nexport const mockMcpRegistry = (): MCPRegistryEntry => {\n\treturn {\n\t\t// @ts-ignore\n\t\tresource: async () => {},\n\t\t// @ts-ignore\n\t\tsendResourceUpdated: () => {},\n\t\taddTool: () => {},\n\t\tsetMCPDescription: () => {},\n\t\tmcpServer: mock as McpServer,\n\t};\n};\n","import { type ModelContext } from '../adapters/web-mcp-adapter';\n\ntype ModelContextHost = {\n\tmodelContext?: ModelContext;\n};\n\nfunction bindModelContextMethods( host: ModelContext ): ModelContext {\n\treturn {\n\t\tregisterTool: host.registerTool.bind( host ),\n\t\tunregisterTool: host.unregisterTool ? host.unregisterTool.bind( host ) : undefined,\n\t};\n}\n\nexport function getModelContext(): ModelContext | undefined {\n\tconst documentModelContext =\n\t\ttypeof document !== 'undefined' ? ( document as unknown as ModelContextHost ).modelContext : undefined;\n\tif ( documentModelContext?.registerTool ) {\n\t\treturn bindModelContextMethods( documentModelContext );\n\t}\n\tconst navigatorModelContext =\n\t\ttypeof navigator !== 'undefined' ? ( navigator as unknown as ModelContextHost ).modelContext : undefined;\n\tif ( navigatorModelContext?.registerTool ) {\n\t\treturn bindModelContextMethods( navigatorModelContext );\n\t}\n\n\treturn undefined;\n}\n","export type ResourceList = {\n\turi: string;\n\tdescription: string;\n}[];\n\nexport const mergeRequiredResources = (\n\ttoolResources: ResourceList | undefined,\n\tserverDocsUri: string | undefined\n): ResourceList | undefined => {\n\tif ( ! serverDocsUri ) {\n\t\treturn toolResources;\n\t}\n\tif ( toolResources?.some( ( r ) => r.uri === serverDocsUri ) ) {\n\t\treturn toolResources;\n\t}\n\treturn [ ...( toolResources ?? [] ), { uri: serverDocsUri, description: 'Server docs' } ];\n};\n","export const createSimpleResourceHandler = ( text: string ) => async ( uri: URL ) => ( {\n\tcontents: [ { uri: uri.href, mimeType: 'text/plain', text } ],\n} );\n","import { type McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\n\nimport { type IMcpRegistrationAdapter } from '../adapters/types';\nimport { createSimpleResourceHandler } from './create-simple-resource-handler';\n\ntype OnResourceRegistered = ( ...args: Parameters< IMcpRegistrationAdapter[ 'onResourceRegistered' ] > ) => void;\n\nexport const registerServerDocsResource = (\n\tserver: McpServer,\n\tnamespace: string,\n\ttitle: string,\n\tdocs: string,\n\tonRegistered: OnResourceRegistered\n): void => {\n\tconst uri = `elementor://${ namespace }/server-docs`;\n\tconst name = `${ namespace }-server-docs`;\n\tconst handler = createSimpleResourceHandler( docs );\n\tserver.registerResource(\n\t\tname,\n\t\turi,\n\t\t{\n\t\t\ttitle: `${ title } server docs`,\n\t\t\tdescription: 'Full MCP documentation (lazy-loaded)',\n\t\t\tmimeType: 'text/plain',\n\t\t},\n\t\thandler\n\t);\n\tonRegistered( name, uri, handler );\n};\n","import { type z } from '@elementor/schema';\nimport { type RequestHandlerExtra } from '@modelcontextprotocol/sdk/shared/protocol.js';\nimport { SamplingMessageSchema, type ServerNotification, type ServerRequest } from '@modelcontextprotocol/sdk/types.js';\n\ntype Server = RequestHandlerExtra< ServerRequest, ServerNotification >;\ntype Opts = {\n\tmaxTokens?: number;\n\tmodelPreferences?: string;\n\tmodel?: string;\n};\n\nconst DEFAULT_OPTS: Opts = {\n\tmaxTokens: 10000,\n\tmodelPreferences: 'openai',\n\tmodel: 'gpt-4o',\n};\n\ntype SamplingOpts = {\n\tsystemPrompt?: string;\n\tstructuredOutput?: z.ZodTypeAny;\n\tmessages: { role: 'user' | 'assistant'; content: { type: 'text'; text: string } }[];\n\trequestParams?: { [ key: string ]: string };\n};\n\nconst DEFAULT_STRUCTURED_OUTPUT = {\n\ttype: 'object',\n\tproperties: {\n\t\tcontent: {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Result',\n\t\t},\n\t},\n\trequired: [ 'content' ],\n\tadditionalProperties: false,\n};\n\nexport const createSampler = ( server: Server, opts: Opts = DEFAULT_OPTS ) => {\n\tconst { maxTokens = 1000, modelPreferences = 'openai', model = 'gpt-4o' } = opts;\n\tconst exec = async ( payload: SamplingOpts ) => {\n\t\tconst systemPromptObject = { ...( payload.systemPrompt ? { systemPrompt: payload.systemPrompt } : {} ) };\n\t\tconst requestParams = payload.requestParams || {};\n\t\tconst result = await server.sendRequest(\n\t\t\t{\n\t\t\t\tmethod: 'sampling/createMessage',\n\t\t\t\tparams: {\n\t\t\t\t\t...requestParams,\n\t\t\t\t\tmaxTokens,\n\t\t\t\t\tmodelPreferences: {\n\t\t\t\t\t\thints: [ { name: modelPreferences } ],\n\t\t\t\t\t},\n\t\t\t\t\tmetadata: {\n\t\t\t\t\t\tmodel,\n\t\t\t\t\t\t...systemPromptObject,\n\t\t\t\t\t\t...{ structured_output: payload.structuredOutput || DEFAULT_STRUCTURED_OUTPUT },\n\t\t\t\t\t},\n\t\t\t\t\tmessages: payload.messages,\n\t\t\t\t},\n\t\t\t\t// ...systemPromptObject,\n\t\t\t},\n\t\t\tSamplingMessageSchema\n\t\t);\n\t\treturn result.content;\n\t};\n\treturn exec;\n};\n","class ToolPrompts {\n\tpublic _description = '';\n\tpublic _parameters: Record< string, string > = {};\n\tpublic _examples: string[] = [];\n\tpublic _furtherInstructions: string[] = [];\n\n\tconstructor( public name: string ) {}\n\n\tdescription(): string;\n\tdescription( desc: string ): this;\n\tdescription( desc?: string | undefined ) {\n\t\tif ( typeof desc === 'undefined' ) {\n\t\t\treturn this._description;\n\t\t}\n\t\tthis._description = desc;\n\t\treturn this;\n\t}\n\n\tparameter( key: string ): string;\n\tparameter( key: string, description: string ): this;\n\tparameter( key: string, description?: string ) {\n\t\tif ( typeof description === 'undefined' ) {\n\t\t\treturn this._parameters[ key ];\n\t\t}\n\t\tthis._parameters[ key ] = `**${ key }**:\\n${ description }`;\n\t\treturn this;\n\t}\n\n\tinstruction( instruction: string ): this {\n\t\tthis._furtherInstructions.push( instruction );\n\t\treturn this;\n\t}\n\n\texample( example: string ): this {\n\t\tthis._examples.push( example );\n\t\treturn this;\n\t}\n\n\tpublic get examples() {\n\t\treturn this._examples.join( '\\n\\n' );\n\t}\n\n\tprompt(): string {\n\t\treturn `# ${ this.name }\n# Description\n${ this._description }\n${ this._parameters.length ? '# Parameters\\n' + Object.values( this._parameters ).join( '\\n\\n' ) : '' }\n${ this._examples.length ? '# Examples\\n' + this.examples : '' }\n${ this._furtherInstructions.length ? '# Further Instructions\\n' + this._furtherInstructions.join( '\\n\\n' ) : '' }\n`.trim();\n\t}\n}\n\nexport const toolPrompts = ( name: string ) => {\n\treturn new ToolPrompts( name );\n};\n","export type ActiveChatInfo = {\n\tsessionId: string;\n\texpiresAt: number;\n};\n\nexport const getActiveChatInfo = (): ActiveChatInfo => {\n\tconst info = localStorage.getItem( 'angie_active_chat_id' );\n\tif ( ! info ) {\n\t\treturn {\n\t\t\texpiresAt: 0,\n\t\t\tsessionId: '',\n\t\t};\n\t}\n\tconst rawData = JSON.parse( info );\n\treturn {\n\t\texpiresAt: rawData.expiresAt as number,\n\t\tsessionId: rawData.sessionId as string,\n\t};\n};\n","import {\n\tAngieInteractionMode,\n\tgetAngieIframe,\n\tsetAngieInteractionMode,\n\ttoggleAngieSidebar,\n} from '@elementor-external/angie-sdk';\n\nimport { isAngieAvailable } from './is-angie-available';\n\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\tif ( openLoadedEditorAngie( prompt, AngieInteractionMode.ASK ) ) {\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( AngieInteractionMode.ASK );\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\nif ( typeof document !== 'undefined' ) {\n\tdocument.addEventListener( 'DOMContentLoaded', () => void startMCPServer(), { once: true } );\n} else {\n\tvoid startMCPServer();\n}\n","export const MCP_STYLES_APPLIED_EVENT = 'elementor/mcp/styles-applied';\n\nexport type McpStylesAppliedPayload = {\n\tstyleValue: Record< string, unknown >;\n};\n\nexport function dispatchMcpStylesAppliedEvent( payload: McpStylesAppliedPayload ): void {\n\twindow.dispatchEvent( new CustomEvent( MCP_STYLES_APPLIED_EVENT, { detail: payload } ) );\n}\n"],"mappings":";AAAA,SAAS,mBAAmB;AAC5B,SAAS,gBAAgB,wBAAwB;AAEjD,IAAI;AAEJ,IAAM,oBAAN,cAAgC,YAAY;AAAA,EAC3C,MAAa,eAAgC;AAC5C,QAAI,aAAa;AACjB,WAAQ,aAAa,GAAI;AACxB,UAAI;AACH,cAAM,MAA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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,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;AAEA,IAAK,OAAO,aAAa,aAAc;AACtC,WAAS,iBAAkB,oBAAoB,MAAM,KAAK,eAAe,GAAG,EAAE,MAAM,KAAK,CAAE;AAC5F,OAAO;AACN,OAAK,eAAe;AACrB;;;ACtBO,IAAM,2BAA2B;AAMjC,SAAS,8BAA+B,SAAyC;AACvF,SAAO,cAAe,IAAI,YAAa,0BAA0B,EAAE,QAAQ,QAAQ,CAAE,CAAE;AACxF;;;AzByBO,IAAM,cAAc,MAAM,OAAO;","names":["McpServer","SamplingMessageSchema","getAngieIframe","z","sdk","getRegisteredMcpServers","z","getAngieIframe","getAngieIframe","AngieInteractionMode","getAngieIframe","toggleAngieSidebar","AngieInteractionMode","getAngieIframe","toggleAngieSidebar","ANGIE_SIDEBAR_STATE_OPEN","setReferrerRedirect","apiFetch"]}
|
|
1
|
+
{"version":3,"sources":["../src/utils/get-sdk.ts","../src/index.ts","../src/utils/is-angie-available.ts","../src/utils/can-create-widget.ts","../src/utils/is-angie-sidebar-open.ts","../src/mcp-registry.ts","../src/adapters/web-mcp-adapter.ts","../src/utils/register-model-context-tool.ts","../src/angie-annotations.ts","../src/test-utils/mock-mcp-registry.ts","../src/utils/get-model-context.ts","../src/utils/merge-required-resources.ts","../src/utils/create-simple-resource-handler.ts","../src/utils/register-server-docs-resource.ts","../src/utils/to-mcp-title.ts","../src/adapters/angie-adapter.ts","../src/sampler.ts","../src/utils/prompt-builder.ts","../src/utils/get-active-chat-info.ts","../src/utils/open-angie-in-ask-mode.ts","../src/utils/send-prompt-to-angie.ts","../src/utils/redirect-to-installation.ts","../src/utils/redirect-to-app-admin.ts","../src/utils/install-angie-plugin.ts","../src/utils/save-angie-consent.ts","../src/init.ts","../src/events/mcp-styles-applied-event.ts"],"sourcesContent":["import { AngieMcpSdk } from '@elementor-external/angie-sdk';\nexport { getAngieIframe, MessageEventType } from '@elementor-external/angie-sdk';\n\nlet sdk: AngieMcpSdk;\n\nclass RetriableAngieSDK extends AngieMcpSdk {\n\tpublic async waitForReady(): Promise< void > {\n\t\tlet retryCount = 3;\n\t\twhile ( retryCount > 0 ) {\n\t\t\ttry {\n\t\t\t\tawait super.waitForReady();\n\t\t\t\treturn;\n\t\t\t} catch {\n\t\t\t\tretryCount--;\n\t\t\t\tawait sleep();\n\t\t\t}\n\t\t}\n\t\treturn new Promise( () => {} ); // never resolves\n\t}\n}\n\nconst sleep = ( ms = 10_000 ) =>\n\tnew Promise( ( resolve ) => {\n\t\tsetTimeout( resolve, ms );\n\t} );\n\nexport const getSDK = () => {\n\t// @ts-ignore - QUnit fails this\n\tconst isMCPDisabled = !! ( globalThis as Record< string, unknown > ).__ELEMENTOR_MCP_DISABLED__;\n\tif ( isMCPDisabled ) {\n\t\treturn {} as unknown as AngieMcpSdk;\n\t}\n\tif ( ! sdk ) {\n\t\tsdk = new RetriableAngieSDK();\n\t}\n\treturn sdk;\n};\n","import './types/open-angie-request';\n\nimport { getSDK } from './utils/get-sdk';\nexport { getAngieIframe, MessageEventType as AngieMessageEvenetType } from './utils/get-sdk';\n\nexport {\n\tMcpServer,\n\tResourceTemplate,\n\ttype RegisteredResource,\n\ttype ToolCallback,\n} from '@modelcontextprotocol/sdk/server/mcp.js';\nexport { SamplingMessageSchema } from '@modelcontextprotocol/sdk/types.js';\nexport { isAngieAvailable } from './utils/is-angie-available';\nexport { canCreateWidget } from './utils/can-create-widget';\nexport { isAngieSidebarOpen } from './utils/is-angie-sidebar-open';\nexport * from './mcp-registry';\nexport { AngieMcpAdapter } from './adapters/angie-adapter';\nexport type { IMcpRegistrationAdapter } from './adapters/types';\nexport { createSampler } from './sampler';\nexport { toolPrompts } from './utils/prompt-builder';\nexport { ANGIE_MODEL_PREFERENCES, ANGIE_REQUIRED_RESOURCES, type AngieModelPreferences } from './angie-annotations';\nexport { getActiveChatInfo, type ActiveChatInfo } from './utils/get-active-chat-info';\nexport { hasLoadedEditorAngie, openAngieInAgentMode, openAngieInAskMode } from './utils/open-angie-in-ask-mode';\nexport type {\n\tEditorAngieWindowHost,\n\tOpenAngieCommonProperties,\n\tOpenAngiePluginProperties,\n\tOpenAngieRequest,\n\tOpenAngieSdkProperties,\n} from './types/open-angie-request';\nexport { sendPromptToAngie } from './utils/send-prompt-to-angie';\nexport { redirectToInstallation } from './utils/redirect-to-installation';\nexport { redirectToAppAdmin } from './utils/redirect-to-app-admin';\nexport { installAngiePlugin, type InstallAngieResult } from './utils/install-angie-plugin';\nexport { saveAngieConsent } from './utils/save-angie-consent';\nexport const getAngieSdk = () => getSDK();\nexport * from './init';\nexport {\n\tdispatchMcpStylesAppliedEvent,\n\tMCP_STYLES_APPLIED_EVENT,\n\ttype McpStylesAppliedPayload,\n} from './events/mcp-styles-applied-event';\n","import { getAngieIframe } from '@elementor-external/angie-sdk';\n\nexport const isAngieAvailable = (): boolean => {\n\treturn !! getAngieIframe();\n};\n","export const canCreateWidget = (): boolean => {\n\treturn Boolean( window.elementor?.config?.widgetCreation?.canCreateWidget );\n};\n","import { ANGIE_SIDEBAR_STATE_OPEN, getAngieSidebarSavedState } from '@elementor-external/angie-sdk';\n\nexport const isAngieSidebarOpen = (): boolean => {\n\treturn getAngieSidebarSavedState() === ANGIE_SIDEBAR_STATE_OPEN;\n};\n","import { z, type z3 } from '@elementor/schema';\nimport { McpServer, type ToolCallback } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { type RequestHandlerExtra } from '@modelcontextprotocol/sdk/shared/protocol.js';\nimport { type ServerNotification, type ServerRequest } from '@modelcontextprotocol/sdk/types.js';\n\nimport { type IMcpRegistrationAdapter, type McpResourceHandler, type McpResourceUriOrTemplate } from './adapters/types';\nimport { WebMCPAdapter } from './adapters/web-mcp-adapter';\nimport {\n\tANGIE_MODEL_PREFERENCES,\n\tANGIE_REQUIRED_RESOURCES,\n\ttype AngieModelPreferences,\n\tcreateDefaultModelPreferences,\n} from './angie-annotations';\nimport { mockMcpRegistry } from './test-utils/mock-mcp-registry';\nimport { getModelContext } from './utils/get-model-context';\nimport { mergeRequiredResources, type ResourceList } from './utils/merge-required-resources';\nimport { registerServerDocsResource } from './utils/register-server-docs-resource';\nimport { toMCPTitle } from './utils/to-mcp-title';\n\ntype ZodRawShape = z3.ZodRawShape;\n\nconst mcpRegistry: { [ namespace: string ]: McpServer } = {};\nconst mcpDescriptions: { [ namespace: string ]: string } = {};\n// @ts-ignore - QUnit fails this\nconst isMcpRegistrationActivated = false || typeof globalThis.jest !== 'undefined';\n\nconst registrationAdapters: IMcpRegistrationAdapter[] = [];\nconst bufferedTools: Parameters< IMcpRegistrationAdapter[ 'onToolRegistered' ] >[] = [];\nconst bufferedResources: Parameters< IMcpRegistrationAdapter[ 'onResourceRegistered' ] >[] = [];\n\nlet resolveReady!: () => void;\nconst readyPromise = new Promise< void >( ( resolve ) => {\n\tresolveReady = resolve;\n} );\n\nexport const registerMcpAdapter = ( adapter: IMcpRegistrationAdapter ): void => {\n\tregistrationAdapters.push( adapter );\n\tfor ( const tool of bufferedTools ) {\n\t\ttry {\n\t\t\tadapter.onToolRegistered( tool[ 0 ], tool[ 1 ] );\n\t\t} catch {\n\t\t\t// exit quietly\n\t\t}\n\t}\n\tfor ( const resource of bufferedResources ) {\n\t\ttry {\n\t\t\tadapter.onResourceRegistered( ...resource );\n\t\t} catch {\n\t\t\t// exit quietly\n\t\t}\n\t}\n};\n\nexport const signalMcpReady = (): void => {\n\tresolveReady();\n};\n\nexport const waitForMcpReady = (): Promise< void > => readyPromise;\n\n/**\n * Registers and activates an adapter that becomes available after startup.\n * Waits for the startup activation so the adapter is activated exactly once.\n *\n * @param adapter - Adapter to register and activate.\n */\nexport const activateMcpAdapter = async ( adapter: IMcpRegistrationAdapter ): Promise< void > => {\n\tawait readyPromise;\n\tregisterMcpAdapter( adapter );\n\tawait adapter.activate();\n};\n\nexport const createAndRegisterAdapters = async (): Promise< void > => {\n\tconst modelContext = getModelContext();\n\n\tif ( modelContext ) {\n\t\tregisterMcpAdapter( new WebMCPAdapter( modelContext ) );\n\t}\n\n\tawait Promise.all( registrationAdapters.map( ( adapter ) => adapter.activate() ) );\n};\n\n// utility function to run a callback on all MCP interfaces\nfunction callAdapters( fn: ( adapter: IMcpRegistrationAdapter ) => unknown ) {\n\tfor ( const adapter of registrationAdapters ) {\n\t\ttry {\n\t\t\tfn( adapter );\n\t\t} catch {\n\t\t\t// adapter failed — exit quietly, continue to next\n\t\t}\n\t}\n}\n\nexport const registerMcp = ( mcp: McpServer, name: string ) => {\n\tconst mcpName = isAlphabet( name );\n\tmcpRegistry[ mcpName ] = mcp;\n};\n\nexport const getRegisteredMcpServers = (): Array< [ string, McpServer, string ] > => {\n\treturn Object.entries( mcpRegistry ).map( ( [ key, server ] ) => [ key, server, mcpDescriptions[ key ] || key ] );\n};\n\nconst isAlphabet = ( str: string ): string | never => {\n\tconst passes = !! str && /^[a-z_]+$/.test( str );\n\tif ( ! passes ) {\n\t\tthrow new Error( 'Not alphabet' );\n\t}\n\treturn str;\n};\n\n/**\n * @param namespace The namespace of the MCP server. It should contain only lowercase alphabetic characters.\n * @param options\n * @param options.instructions Short hint about the MCP and its toolset (MCP SDK `instructions`; keeps payload small).\n * @param options.docs Full documentation registered as a lazy-loaded resource.\n * When provided, it is registered at elementor://{namespace}/server-docs\n * and auto-injected into every tool's requiredResources.\n */\nexport const getMCPByDomain = (\n\tnamespace: string,\n\toptions?: { docs?: string; instructions?: string }\n): MCPRegistryEntry => {\n\tconst mcpName = `editor-${ isAlphabet( namespace ) }`;\n\tconst title = toMCPTitle( namespace );\n\t// @ts-ignore - QUnit fails this\n\tif ( typeof globalThis.jest !== 'undefined' ) {\n\t\treturn mockMcpRegistry();\n\t}\n\tif ( ! mcpRegistry[ namespace ] ) {\n\t\tmcpRegistry[ namespace ] = new McpServer(\n\t\t\t{ name: mcpName, title, version: '1.0.0' },\n\t\t\t{ instructions: options?.instructions, capabilities: { resources: { subscribe: true } } }\n\t\t);\n\t\tif ( options?.docs ) {\n\t\t\tregisterServerDocsResource( mcpRegistry[ namespace ], namespace, title, options.docs, ( ...args ) => {\n\t\t\t\tbufferedResources.push( args );\n\t\t\t\tcallAdapters( ( adapter ) => adapter.onResourceRegistered( ...args ) );\n\t\t\t} );\n\t\t}\n\t}\n\tconst mcpServer = mcpRegistry[ namespace ];\n\tconst serverDocsUri = options?.docs ? `elementor://${ namespace }/server-docs` : undefined;\n\tconst { addTool } = createToolRegistry( mcpServer, mcpName, serverDocsUri );\n\treturn {\n\t\twaitForReady: () => readyPromise,\n\t\t// @ts-expect-error: TS is unable to infer the type here\n\t\tresource: async ( ...args: Parameters< McpServer[ 'registerResource' ] > ) => {\n\t\t\tconst [ name, uriOrTemplate, ...rest ] = args as [ string, unknown, ...unknown[] ];\n\t\t\tconst handler = rest[ rest.length - 1 ] as McpResourceHandler;\n\t\t\tconst resourceArgs: Parameters< IMcpRegistrationAdapter[ 'onResourceRegistered' ] > = [\n\t\t\t\tname,\n\t\t\t\turiOrTemplate as McpResourceUriOrTemplate,\n\t\t\t\thandler,\n\t\t\t];\n\t\t\tbufferedResources.push( resourceArgs );\n\t\t\tcallAdapters( ( adapter ) => adapter.onResourceRegistered( ...resourceArgs ) );\n\t\t\treturn mcpServer.registerResource( ...args );\n\t\t},\n\t\tsendResourceUpdated: ( ...args: Parameters< McpServer[ 'server' ][ 'sendResourceUpdated' ] > ) => {\n\t\t\tcallAdapters( ( adapter ) => adapter.sendResourceUpdated( { uri: args[ 0 ].uri } ) );\n\t\t\treturn Promise.resolve( mcpServer.server.sendResourceUpdated( ...args ) ).catch( ( error: Error ) => {\n\t\t\t\tif ( error?.message?.includes( 'Not connected' ) ) {\n\t\t\t\t\treturn; // Expected when no MCP client is connected yet\n\t\t\t\t}\n\t\t\t\tif ( error?.message?.includes( 'does not support notifying about resources' ) ) {\n\t\t\t\t\treturn; // Server capability not declared — safe to ignore\n\t\t\t\t}\n\t\t\t\tthrow error;\n\t\t\t} );\n\t\t},\n\t\taddTool,\n\t\tsetMCPDescription: ( description: string ) => {\n\t\t\tmcpDescriptions[ namespace ] = description;\n\t\t},\n\t};\n};\n\nexport interface MCPRegistryEntry {\n\taddTool: < T extends undefined | z.ZodRawShape = undefined, O extends undefined | z.ZodRawShape = undefined >(\n\t\topts: ToolRegistrationOptions< T, O >\n\t) => void;\n\tsetMCPDescription: ( description: string ) => void;\n\tsendResourceUpdated: McpServer[ 'server' ][ 'sendResourceUpdated' ];\n\tresource: McpServer[ 'registerResource' ];\n\twaitForReady: () => Promise< void >;\n}\n\ntype ToolRegistrationOptions<\n\tInputArgs extends undefined | z.ZodRawShape = undefined,\n\tOutputSchema extends undefined | z.ZodRawShape = undefined,\n\tExpectedOutput = OutputSchema extends z.ZodRawShape ? z.objectOutputType< OutputSchema, z.ZodTypeAny > : string,\n> = {\n\tname: string;\n\tdescription: string;\n\tschema?: InputArgs;\n\t/**\n\t * Auto added fields:\n\t * @param errors z.string().optional().describe('Error message if the tool failed')\n\t */\n\toutputSchema?: OutputSchema;\n\thandler: InputArgs extends z.ZodRawShape\n\t\t? (\n\t\t\t\targs: z.objectOutputType< InputArgs, z.ZodTypeAny >,\n\t\t\t\textra: RequestHandlerExtra< ServerRequest, ServerNotification >\n\t\t ) => ExpectedOutput | Promise< ExpectedOutput >\n\t\t: (\n\t\t\t\targs: unknown,\n\t\t\t\textra: RequestHandlerExtra< ServerRequest, ServerNotification >\n\t\t ) => ExpectedOutput | Promise< ExpectedOutput >;\n\tisDestructive?: boolean;\n\trequiredResources?: ResourceList;\n\tmodelPreferences?: AngieModelPreferences;\n};\n\nfunction createToolRegistry( server: McpServer, serverName: string, serverDocsUri?: string ) {\n\tfunction addTool<\n\t\tT extends undefined | z.ZodRawShape = undefined,\n\t\tO extends undefined | z.ZodRawShape = undefined,\n\t>( opts: ToolRegistrationOptions< T, O > ) {\n\t\tconst outputSchema = opts.outputSchema as ZodRawShape | undefined;\n\t\tif ( outputSchema ) {\n\t\t\tObject.assign(\n\t\t\t\toutputSchema,\n\t\t\t\toutputSchema.errors ?? {\n\t\t\t\t\terrors: z.string().optional().describe( 'Error message if the tool failed' ),\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t\t// @ts-ignore: TS is unable to infer the type here\n\t\tconst inputSchema: ZodRawShape = opts.schema ? opts.schema : {};\n\t\tconst toolCallback: ToolCallback< ZodRawShape > = async function ( args, extra ) {\n\t\t\ttry {\n\t\t\t\tconst invocationResult = await opts.handler( opts.schema ? args : {}, extra );\n\t\t\t\treturn {\n\t\t\t\t\t// structuredContent: typeof invocationResult === 'string' ? undefined : invocationResult,\n\t\t\t\t\tcontent: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: 'text',\n\t\t\t\t\t\t\ttext:\n\t\t\t\t\t\t\t\ttypeof invocationResult === 'string'\n\t\t\t\t\t\t\t\t\t? invocationResult\n\t\t\t\t\t\t\t\t\t: JSON.stringify( invocationResult ),\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t};\n\t\t\t} catch ( error ) {\n\t\t\t\treturn {\n\t\t\t\t\tisError: true,\n\t\t\t\t\tstructuredContent: {\n\t\t\t\t\t\terrors: ( error as Error ).message || 'Unknown error',\n\t\t\t\t\t},\n\t\t\t\t\tcontent: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: 'text',\n\t\t\t\t\t\t\ttext:\n\t\t\t\t\t\t\t\t( ( error as Error ).message || 'Unknown error' ) +\n\t\t\t\t\t\t\t\tJSON.stringify( ( error as { response?: { data: unknown } } ).response?.data || error ),\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t};\n\t\t\t}\n\t\t};\n\t\tconst annotations: Record< string, unknown > = {\n\t\t\tdestructiveHint: opts.isDestructive,\n\t\t\treadOnlyHint: opts.isDestructive ? false : undefined,\n\t\t\ttitle: opts.name,\n\t\t};\n\t\tconst mergedResources = mergeRequiredResources( opts.requiredResources, serverDocsUri );\n\t\tconst angieAnnotations = {\n\t\t\t[ ANGIE_MODEL_PREFERENCES ]: opts.modelPreferences ?? createDefaultModelPreferences(),\n\t\t\t[ ANGIE_REQUIRED_RESOURCES ]: mergedResources,\n\t\t};\n\t\tserver.registerTool(\n\t\t\topts.name,\n\t\t\t{\n\t\t\t\tdescription: opts.description,\n\t\t\t\tinputSchema,\n\t\t\t\t// TODO: Uncomment this when the outputSchema is stable\n\t\t\t\t// outputSchema,\n\t\t\t\ttitle: opts.name,\n\t\t\t\tannotations,\n\t\t\t\t_meta: angieAnnotations,\n\t\t\t},\n\t\t\ttoolCallback\n\t\t);\n\t\tconst toolDescriptor = {\n\t\t\tname: opts.name,\n\t\t\tdescription: opts.description,\n\t\t\tinputSchema: inputSchema as object,\n\t\t\texecute: ( params: Record< string, unknown > ) =>\n\t\t\t\ttoolCallback(\n\t\t\t\t\tparams as Parameters< typeof toolCallback >[ 0 ],\n\t\t\t\t\t/* WebMCP: no protocol session — handlers must not rely on `extra` here */\n\t\t\t\t\t{} as RequestHandlerExtra< ServerRequest, ServerNotification >\n\t\t\t\t) as Promise< unknown >,\n\t\t};\n\t\tconst extraData = {\n\t\t\tresources: [ `Server resource name: ${ serverName }, Required to fetch!` ],\n\t\t\trequiredResources: mergedResources?.map( ( resource ) => resource.uri ) ?? [],\n\t\t};\n\t\tbufferedTools.push( [ toolDescriptor, extraData ] );\n\t\tcallAdapters( ( adapter ) => adapter.onToolRegistered( toolDescriptor, extraData ) );\n\t\tif ( isMcpRegistrationActivated ) {\n\t\t\tserver.sendToolListChanged();\n\t\t}\n\t}\n\treturn {\n\t\taddTool,\n\t};\n}\n","import { zodToJsonSchema } from 'zod-to-json-schema';\nimport { z, type z3 } from '@elementor/schema';\n\nimport { type ModelContextRegisterTool, registerModelContextTool } from '../utils/register-model-context-tool';\nimport {\n\ttype IMcpRegistrationAdapter,\n\ttype McpResourceHandler,\n\ttype McpResourceUriOrTemplate,\n\ttype McpToolDescriptor,\n\ttype UriTemplate,\n} from './types';\n\ntype ZodRawShape = z3.ZodRawShape;\n\nexport type ModelContext = {\n\tregisterTool: ModelContextRegisterTool;\n\tunregisterTool?: ( name: string ) => void;\n};\n\ntype ResourceEntry = {\n\tpattern: string;\n\tmatch: ( uri: string ) => Record< string, string | string[] > | null;\n\thandler: McpResourceHandler;\n};\n\nexport class WebMCPAdapter implements IMcpRegistrationAdapter {\n\tprivate readonly registeredToolNames = new Set< string >();\n\tprivate readonly resourceEntries: ResourceEntry[] = [];\n\tprivate activated = false;\n\n\tconstructor( private readonly ctx: ModelContext ) {}\n\n\tactivate(): Promise< void > {\n\t\tif ( this.activated ) {\n\t\t\treturn Promise.resolve();\n\t\t}\n\t\tthis.activated = true;\n\t\treturn registerModelContextTool( this.ctx.registerTool, {\n\t\t\tname: 'editor-resource-getter',\n\t\t\tdescription:\n\t\t\t\t'Get an editor resource by URI, or search for available resources by partial URI. Pass a full URI to retrieve content, or a partial string to discover matching patterns.',\n\t\t\tinputSchema: {\n\t\t\t\ttype: 'object',\n\t\t\t\tproperties: {\n\t\t\t\t\turi: {\n\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t'A full resource URI (e.g. elementor://style/best-practices) or a partial string to search across available resource patterns.',\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\trequired: [ 'uri' ],\n\t\t\t},\n\t\t\texecute: async ( params ) => {\n\t\t\t\tconst query = params.uri as string;\n\t\t\t\tconst entries = this.resourceEntries;\n\n\t\t\t\tif ( entries.length === 0 ) {\n\t\t\t\t\treturn 'No resources are registered yet.';\n\t\t\t\t}\n\n\t\t\t\t// Exact URI match\n\t\t\t\tfor ( const entry of entries ) {\n\t\t\t\t\tconst variables = entry.match( query );\n\t\t\t\t\tif ( variables !== null ) {\n\t\t\t\t\t\tlet resourceUrl: URL;\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tresourceUrl = new URL( query );\n\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\treturn `Invalid URI '${ query }'. Provide a valid resource URI or a partial string to search patterns.`;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst result = await entry.handler( resourceUrl, variables );\n\t\t\t\t\t\treturn result.contents?.[ 0 ]?.text ?? JSON.stringify( result );\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Partial search fallback\n\t\t\t\tconst matches = entries.map( ( e ) => e.pattern ).filter( ( pattern ) => pattern.includes( query ) );\n\t\t\t\tif ( matches.length > 0 ) {\n\t\t\t\t\treturn `Found ${ matches.length } matching resource pattern(s):\\n${ matches.join(\n\t\t\t\t\t\t'\\n'\n\t\t\t\t\t) }\\n\\nProvide a full URI to retrieve the resource content.`;\n\t\t\t\t}\n\n\t\t\t\tconst available = entries.map( ( e ) => e.pattern ).join( '\\n' );\n\t\t\t\tthrow new Error( `No resource matched '${ query }'.\\n\\nAvailable patterns:\\n${ available }` );\n\t\t\t},\n\t\t} );\n\t}\n\n\tonToolRegistered(\n\t\ttool: McpToolDescriptor,\n\t\textraData?: { resources: string[]; requiredResources: string[] }\n\t): void {\n\t\tlet jsonSchema: object;\n\t\ttry {\n\t\t\tjsonSchema = zodToJsonSchema( z.object( tool.inputSchema as ZodRawShape ) );\n\t\t} catch {\n\t\t\tjsonSchema = tool.inputSchema;\n\t\t}\n\n\t\tif ( this.registeredToolNames.has( tool.name ) ) {\n\t\t\tthis.ctx.unregisterTool?.( tool.name );\n\t\t\tthis.registeredToolNames.delete( tool.name );\n\t\t}\n\n\t\tlet resourcesDescription = '';\n\t\tif ( extraData ) {\n\t\t\tif ( extraData.resources?.length > 0 ) {\n\t\t\t\tresourcesDescription += `#Resources:\\n${ extraData.resources?.join( '\\n' ) }\\n\\n`;\n\t\t\t}\n\t\t\tif ( extraData.requiredResources?.length > 0 ) {\n\t\t\t\tresourcesDescription += `#Required Resources:\\n${ extraData.requiredResources?.join( '\\n' ) }\\n\\n`;\n\t\t\t}\n\t\t\tresourcesDescription += `To read resources, use editor-resource-getter tool.\\n\\n`;\n\t\t}\n\t\tvoid registerModelContextTool( this.ctx.registerTool, {\n\t\t\tname: tool.name,\n\t\t\tdescription: `${ resourcesDescription }${ tool.description }`,\n\t\t\tinputSchema: jsonSchema,\n\t\t\texecute: tool.execute,\n\t\t} ).then( () => {\n\t\t\tthis.registeredToolNames.add( tool.name );\n\t\t} );\n\t}\n\n\tonResourceRegistered( _name: string, uriOrTemplate: McpResourceUriOrTemplate, handler: McpResourceHandler ): void {\n\t\tif ( typeof uriOrTemplate === 'string' ) {\n\t\t\tthis.resourceEntries.push( {\n\t\t\t\tpattern: uriOrTemplate,\n\t\t\t\tmatch: ( uri ) => ( uri === uriOrTemplate ? {} : null ),\n\t\t\t\thandler,\n\t\t\t} );\n\t\t} else {\n\t\t\tconst template = uriOrTemplate.uriTemplate as UriTemplate;\n\t\t\tthis.resourceEntries.push( {\n\t\t\t\tpattern: template.toString(),\n\t\t\t\tmatch: ( uri ) => template.match( uri ),\n\t\t\t\thandler,\n\t\t\t} );\n\t\t}\n\t}\n\n\tsendResourceUpdated(): void {\n\t\t// WebMCP has no server-push mechanism — no-op\n\t}\n}\n","import { type McpToolDescriptor } from '../adapters/types';\n\nexport type ModelContextRegisterTool = ( tool: McpToolDescriptor ) => void | Promise< void >;\n\nexport async function registerModelContextTool(\n\tregisterTool: ModelContextRegisterTool,\n\ttool: McpToolDescriptor\n): Promise< void > {\n\ttry {\n\t\tawait Promise.resolve( registerTool( tool ) );\n\t} catch ( error ) {\n\t\t/* eslint-disable-next-line no-console */\n\t\tconsole.error( 'Tool registration failed:', error );\n\t}\n}\n","export const ANGIE_MODEL_PREFERENCES = 'angie/modelPreferences' as const;\nexport const ANGIE_REQUIRED_RESOURCES = 'angie/requiredResources' as const;\n\nexport interface AngieModelPreferences {\n\thints?: Array< { name: string } >;\n\tcostPriority?: number; // 0-1 (future use)\n\tspeedPriority?: number; // 0-1 (future use)\n\tintelligencePriority?: number; // 0-1 (future use)\n}\n\nexport function createDefaultModelPreferences(): AngieModelPreferences {\n\treturn {\n\t\thints: [ { name: 'claude-sonnet-4-6' } ],\n\t};\n}\n","import { type McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\n\nimport { type MCPRegistryEntry } from '../mcp-registry';\n\nconst mock = new Proxy(\n\t{},\n\t{\n\t\tget: () => {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unused-vars\n\t\t\tfunction mockedFn( ..._: unknown[] ) {}\n\t\t\treturn mockedFn;\n\t\t},\n\t}\n);\n\nexport const mockMcpRegistry = (): MCPRegistryEntry => {\n\treturn {\n\t\t// @ts-ignore\n\t\tresource: async () => {},\n\t\t// @ts-ignore\n\t\tsendResourceUpdated: () => {},\n\t\taddTool: () => {},\n\t\tsetMCPDescription: () => {},\n\t\tmcpServer: mock as McpServer,\n\t};\n};\n","import { type ModelContext } from '../adapters/web-mcp-adapter';\n\ntype ModelContextHost = {\n\tmodelContext?: ModelContext;\n};\n\nfunction bindModelContextMethods( host: ModelContext ): ModelContext {\n\treturn {\n\t\tregisterTool: host.registerTool.bind( host ),\n\t\tunregisterTool: host.unregisterTool ? host.unregisterTool.bind( host ) : undefined,\n\t};\n}\n\nexport function getModelContext(): ModelContext | undefined {\n\tconst documentModelContext =\n\t\ttypeof document !== 'undefined' ? ( document as unknown as ModelContextHost ).modelContext : undefined;\n\tif ( documentModelContext?.registerTool ) {\n\t\treturn bindModelContextMethods( documentModelContext );\n\t}\n\tconst navigatorModelContext =\n\t\ttypeof navigator !== 'undefined' ? ( navigator as unknown as ModelContextHost ).modelContext : undefined;\n\tif ( navigatorModelContext?.registerTool ) {\n\t\treturn bindModelContextMethods( navigatorModelContext );\n\t}\n\n\treturn undefined;\n}\n","export type ResourceList = {\n\turi: string;\n\tdescription: string;\n}[];\n\nexport const mergeRequiredResources = (\n\ttoolResources: ResourceList | undefined,\n\tserverDocsUri: string | undefined\n): ResourceList | undefined => {\n\tif ( ! serverDocsUri ) {\n\t\treturn toolResources;\n\t}\n\tif ( toolResources?.some( ( r ) => r.uri === serverDocsUri ) ) {\n\t\treturn toolResources;\n\t}\n\treturn [ ...( toolResources ?? [] ), { uri: serverDocsUri, description: 'Server docs' } ];\n};\n","export const createSimpleResourceHandler = ( text: string ) => async ( uri: URL ) => ( {\n\tcontents: [ { uri: uri.href, mimeType: 'text/plain', text } ],\n} );\n","import { type McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\n\nimport { type IMcpRegistrationAdapter } from '../adapters/types';\nimport { createSimpleResourceHandler } from './create-simple-resource-handler';\n\ntype OnResourceRegistered = ( ...args: Parameters< IMcpRegistrationAdapter[ 'onResourceRegistered' ] > ) => void;\n\nexport const registerServerDocsResource = (\n\tserver: McpServer,\n\tnamespace: string,\n\ttitle: string,\n\tdocs: string,\n\tonRegistered: OnResourceRegistered\n): void => {\n\tconst uri = `elementor://${ namespace }/server-docs`;\n\tconst name = `${ namespace }-server-docs`;\n\tconst handler = createSimpleResourceHandler( docs );\n\tserver.registerResource(\n\t\tname,\n\t\turi,\n\t\t{\n\t\t\ttitle: `${ title } server docs`,\n\t\t\tdescription: 'Full MCP documentation (lazy-loaded)',\n\t\t\tmimeType: 'text/plain',\n\t\t},\n\t\thandler\n\t);\n\tonRegistered( name, uri, handler );\n};\n","export const toMCPTitle = ( namespace: string ): string => {\n\tconst capitalized = namespace.charAt( 0 ).toUpperCase() + namespace.slice( 1 );\n\treturn `Editor ${ capitalized }`;\n};\n","import { type AngieMcpSdk } from '@elementor-external/angie-sdk';\n\nimport { type getRegisteredMcpServers as _getRegisteredMcpServers } from '../mcp-registry';\nimport { toMCPTitle } from '../utils/to-mcp-title';\nimport { type IMcpRegistrationAdapter } from './types';\n\nconst MAX_RETRIES = 3;\n\nexport class AngieMcpAdapter implements IMcpRegistrationAdapter {\n\tconstructor(\n\t\tprivate readonly sdk: AngieMcpSdk,\n\t\tprivate readonly getRegisteredMcpServers: typeof _getRegisteredMcpServers\n\t) {}\n\n\tasync activate(): Promise< void > {\n\t\t// No waitForReady() here: registerLocalServer queues the server and the SDK flushes\n\t\t// the queue once Angie reports ready. waitForReady() only resolves for the SDK copy\n\t\t// that booted the sidebar, which is the host integration, never the editor bundle.\n\t\tawait this.registerEntries( this.getRegisteredMcpServers(), MAX_RETRIES );\n\t}\n\n\tprivate async registerEntries(\n\t\tentries: ReturnType< typeof _getRegisteredMcpServers >,\n\t\tretry: number\n\t): Promise< void > {\n\t\tif ( retry === 0 ) {\n\t\t\t/* eslint-disable-next-line no-console */\n\t\t\tconsole.error(\n\t\t\t\t'Failed to register MCP after 3 retries. failed entries: ',\n\t\t\t\tentries.map( ( [ key ] ) => key )\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tconst failed: typeof entries = [];\n\t\tfor ( const [ key, mcpServer, description ] of entries ) {\n\t\t\ttry {\n\t\t\t\tawait this.sdk.registerLocalServer( {\n\t\t\t\t\ttitle: toMCPTitle( key ),\n\t\t\t\t\tname: `editor-${ key }`,\n\t\t\t\t\tserver: mcpServer,\n\t\t\t\t\tversion: '1.0.0',\n\t\t\t\t\tdescription,\n\t\t\t\t} );\n\t\t\t} catch {\n\t\t\t\tfailed.push( [ key, mcpServer, description ] );\n\t\t\t}\n\t\t}\n\n\t\tif ( failed.length > 0 ) {\n\t\t\treturn this.registerEntries( failed, retry - 1 );\n\t\t}\n\t}\n\n\tonToolRegistered(): void {\n\t\t// Angie tools are registered via McpServer (at activate time).\n\t}\n\n\tonResourceRegistered(): void {\n\t\t// Resources are registered on the McpServer instance directly.\n\t}\n\n\tsendResourceUpdated(): void {\n\t\t// Resource update notifications are sent via MCPRegistryEntry.sendResourceUpdated.\n\t}\n}\n","import { type z } from '@elementor/schema';\nimport { type RequestHandlerExtra } from '@modelcontextprotocol/sdk/shared/protocol.js';\nimport { SamplingMessageSchema, type ServerNotification, type ServerRequest } from '@modelcontextprotocol/sdk/types.js';\n\ntype Server = RequestHandlerExtra< ServerRequest, ServerNotification >;\ntype Opts = {\n\tmaxTokens?: number;\n\tmodelPreferences?: string;\n\tmodel?: string;\n};\n\nconst DEFAULT_OPTS: Opts = {\n\tmaxTokens: 10000,\n\tmodelPreferences: 'openai',\n\tmodel: 'gpt-4o',\n};\n\ntype SamplingOpts = {\n\tsystemPrompt?: string;\n\tstructuredOutput?: z.ZodTypeAny;\n\tmessages: { role: 'user' | 'assistant'; content: { type: 'text'; text: string } }[];\n\trequestParams?: { [ key: string ]: string };\n};\n\nconst DEFAULT_STRUCTURED_OUTPUT = {\n\ttype: 'object',\n\tproperties: {\n\t\tcontent: {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Result',\n\t\t},\n\t},\n\trequired: [ 'content' ],\n\tadditionalProperties: false,\n};\n\nexport const createSampler = ( server: Server, opts: Opts = DEFAULT_OPTS ) => {\n\tconst { maxTokens = 1000, modelPreferences = 'openai', model = 'gpt-4o' } = opts;\n\tconst exec = async ( payload: SamplingOpts ) => {\n\t\tconst systemPromptObject = { ...( payload.systemPrompt ? { systemPrompt: payload.systemPrompt } : {} ) };\n\t\tconst requestParams = payload.requestParams || {};\n\t\tconst result = await server.sendRequest(\n\t\t\t{\n\t\t\t\tmethod: 'sampling/createMessage',\n\t\t\t\tparams: {\n\t\t\t\t\t...requestParams,\n\t\t\t\t\tmaxTokens,\n\t\t\t\t\tmodelPreferences: {\n\t\t\t\t\t\thints: [ { name: modelPreferences } ],\n\t\t\t\t\t},\n\t\t\t\t\tmetadata: {\n\t\t\t\t\t\tmodel,\n\t\t\t\t\t\t...systemPromptObject,\n\t\t\t\t\t\t...{ structured_output: payload.structuredOutput || DEFAULT_STRUCTURED_OUTPUT },\n\t\t\t\t\t},\n\t\t\t\t\tmessages: payload.messages,\n\t\t\t\t},\n\t\t\t\t// ...systemPromptObject,\n\t\t\t},\n\t\t\tSamplingMessageSchema\n\t\t);\n\t\treturn result.content;\n\t};\n\treturn exec;\n};\n","class ToolPrompts {\n\tpublic _description = '';\n\tpublic _parameters: Record< string, string > = {};\n\tpublic _examples: string[] = [];\n\tpublic _furtherInstructions: string[] = [];\n\n\tconstructor( public name: string ) {}\n\n\tdescription(): string;\n\tdescription( desc: string ): this;\n\tdescription( desc?: string | undefined ) {\n\t\tif ( typeof desc === 'undefined' ) {\n\t\t\treturn this._description;\n\t\t}\n\t\tthis._description = desc;\n\t\treturn this;\n\t}\n\n\tparameter( key: string ): string;\n\tparameter( key: string, description: string ): this;\n\tparameter( key: string, description?: string ) {\n\t\tif ( typeof description === 'undefined' ) {\n\t\t\treturn this._parameters[ key ];\n\t\t}\n\t\tthis._parameters[ key ] = `**${ key }**:\\n${ description }`;\n\t\treturn this;\n\t}\n\n\tinstruction( instruction: string ): this {\n\t\tthis._furtherInstructions.push( instruction );\n\t\treturn this;\n\t}\n\n\texample( example: string ): this {\n\t\tthis._examples.push( example );\n\t\treturn this;\n\t}\n\n\tpublic get examples() {\n\t\treturn this._examples.join( '\\n\\n' );\n\t}\n\n\tprompt(): string {\n\t\treturn `# ${ this.name }\n# Description\n${ this._description }\n${ this._parameters.length ? '# Parameters\\n' + Object.values( this._parameters ).join( '\\n\\n' ) : '' }\n${ this._examples.length ? '# Examples\\n' + this.examples : '' }\n${ this._furtherInstructions.length ? '# Further Instructions\\n' + this._furtherInstructions.join( '\\n\\n' ) : '' }\n`.trim();\n\t}\n}\n\nexport const toolPrompts = ( name: string ) => {\n\treturn new ToolPrompts( name );\n};\n","export type ActiveChatInfo = {\n\tsessionId: string;\n\texpiresAt: number;\n};\n\nexport const getActiveChatInfo = (): ActiveChatInfo => {\n\tconst info = localStorage.getItem( 'angie_active_chat_id' );\n\tif ( ! info ) {\n\t\treturn {\n\t\t\texpiresAt: 0,\n\t\t\tsessionId: '',\n\t\t};\n\t}\n\tconst rawData = JSON.parse( info );\n\treturn {\n\t\texpiresAt: rawData.expiresAt as number,\n\t\tsessionId: rawData.sessionId as string,\n\t};\n};\n","import {\n\tAngieInteractionMode,\n\tgetAngieIframe,\n\tsetAngieInteractionMode,\n\ttoggleAngieSidebar,\n} from '@elementor-external/angie-sdk';\n\nimport { isAngieAvailable } from './is-angie-available';\n\nconst getLoadedEditorAngie = () => {\n\treturn window.elementorV2?.editorAngie?.openAngie;\n};\n\nexport const hasLoadedEditorAngie = (): boolean => Boolean( getLoadedEditorAngie() );\n\nexport const openLoadedEditorAngie = ( prompt: string | undefined, mode: AngieInteractionMode ): boolean => {\n\tconst openAngie = getLoadedEditorAngie();\n\n\tif ( ! openAngie ) {\n\t\treturn false;\n\t}\n\n\tPromise.resolve( openAngie( { prompt: prompt ?? '', mode } ) ).catch( ( error ) => {\n\t\t// eslint-disable-next-line no-console\n\t\tconsole.error( 'Failed to open Angie:', error );\n\t} );\n\n\treturn true;\n};\n\nexport const openAngieInAskMode = ( prompt?: string ): void => {\n\topenAngieInMode( prompt, AngieInteractionMode.ASK );\n};\n\nexport const openAngieInAgentMode = ( prompt?: string ): void => {\n\topenAngieInMode( prompt, AngieInteractionMode.AGENT );\n};\n\nconst openAngieInMode = ( prompt: string | undefined, mode: AngieInteractionMode ): void => {\n\tif ( openLoadedEditorAngie( prompt, mode ) ) {\n\t\treturn;\n\t}\n\n\tif ( ! isAngieAvailable() ) {\n\t\treturn;\n\t}\n\n\tconst angieSidebar = getAngieIframe();\n\n\tif ( ! angieSidebar ) {\n\t\treturn;\n\t}\n\n\ttoggleAngieSidebar( angieSidebar, true );\n\tsetAngieInteractionMode( mode );\n\n\tif ( prompt ) {\n\t\twindow.location.hash = `angie-prompt=${ encodeURIComponent( prompt ) }`;\n\t}\n};\n","import { AngieInteractionMode, getAngieIframe, toggleAngieSidebar } from '@elementor-external/angie-sdk';\n\nimport { openLoadedEditorAngie } from './open-angie-in-ask-mode';\n\nexport const sendPromptToAngie = ( prompt?: string ) => {\n\tif ( openLoadedEditorAngie( prompt, AngieInteractionMode.AGENT ) ) {\n\t\treturn;\n\t}\n\n\tconst angieSidebar = getAngieIframe();\n\n\tif ( ! angieSidebar ) {\n\t\treturn;\n\t}\n\n\ttoggleAngieSidebar( angieSidebar, true );\n\n\tif ( ! prompt ) {\n\t\treturn;\n\t}\n\n\twindow.location.hash = `angie-prompt=${ encodeURIComponent( prompt ) }`;\n};\n","import { setReferrerRedirect } from '@elementor-external/angie-sdk';\n\nconst ANGIE_INSTALL_URL = '/wp-admin/plugin-install.php?s=angie&tab=search&type=term';\n\n/**\n * @deprecated Kept only for Elementor Pro compatibility. Will be removed in a future version.\n * @param prompt Optional prompt to pass after redirect.\n */\nexport const redirectToInstallation = ( prompt?: string ) => {\n\tsetReferrerRedirect( window.location.href, prompt );\n\twindow.location.href = ANGIE_INSTALL_URL;\n};\n","import { ANGIE_SIDEBAR_STATE_OPEN, saveState, setReferrerRedirect } from '@elementor-external/angie-sdk';\n\nconst ANGIE_APP_URL = '/wp-admin/admin.php?page=angie-app';\n\n/**\n * @deprecated Kept only for Elementor Pro compatibility. Will be removed in a future version.\n * @param prompt Optional prompt to pass after redirect.\n */\nexport const redirectToAppAdmin = ( prompt?: string ) => {\n\tsetReferrerRedirect( window.location.href, prompt );\n\tsaveState( ANGIE_SIDEBAR_STATE_OPEN );\n\twindow.location.href = ANGIE_APP_URL;\n};\n","import apiFetch from '@wordpress/api-fetch';\n\ntype PluginResponse = {\n\tplugin: string;\n\tstatus: 'active' | 'inactive';\n\tname: string;\n};\n\ntype PluginErrorResponse = {\n\tcode: string;\n\tmessage: string;\n};\n\nexport type InstallAngieResult = { success: true } | { success: false; error: string; code?: string };\n\nconst ANGIE_SLUG = 'angie';\n\nconst isPluginErrorResponse = ( response: unknown ): response is PluginErrorResponse => {\n\treturn typeof response === 'object' && response !== null && 'code' in response && 'message' in response;\n};\n\nconst activatePlugin = async ( pluginPath: string ): Promise< PluginResponse > => {\n\treturn apiFetch< PluginResponse >( {\n\t\tpath: `/wp/v2/plugins/${ pluginPath }`,\n\t\tmethod: 'POST',\n\t\tdata: { status: 'active' },\n\t} );\n};\n\nconst installPlugin = async (): Promise< PluginResponse > => {\n\ttry {\n\t\treturn await apiFetch< PluginResponse >( {\n\t\t\tpath: '/wp/v2/plugins',\n\t\t\tmethod: 'POST',\n\t\t\tdata: {\n\t\t\t\tslug: ANGIE_SLUG,\n\t\t\t\tstatus: 'active',\n\t\t\t},\n\t\t} );\n\t} catch ( error: unknown ) {\n\t\tif ( isPluginErrorResponse( error ) && error.code === 'folder_exists' ) {\n\t\t\treturn activatePlugin( `${ ANGIE_SLUG }/${ ANGIE_SLUG }` );\n\t\t}\n\n\t\tthrow error;\n\t}\n};\n\n/**\n * @deprecated Kept only for Elementor Pro compatibility. Will be removed in a future version.\n */\nexport const installAngiePlugin = async (): Promise< InstallAngieResult > => {\n\ttry {\n\t\tawait installPlugin();\n\n\t\treturn { success: true };\n\t} catch ( error: unknown ) {\n\t\tif ( isPluginErrorResponse( error ) ) {\n\t\t\treturn { success: false, error: error.message, code: error.code };\n\t\t}\n\n\t\treturn { success: false, error: 'Unknown error occurred' };\n\t}\n};\n","import apiFetch from '@wordpress/api-fetch';\n\nexport const saveAngieConsent = async (): Promise< void > => {\n\tawait apiFetch( {\n\t\tpath: '/elementor/v1/angie/consent',\n\t\tmethod: 'POST',\n\t} );\n};\n","import { createAndRegisterAdapters, signalMcpReady } from './mcp-registry';\n\nlet isInitialized = false;\nexport async function startMCPServer() {\n\tif ( isInitialized ) {\n\t\treturn;\n\t}\n\tisInitialized = true;\n\ttry {\n\t\tawait createAndRegisterAdapters();\n\t} catch ( error ) {\n\t\t/* eslint-disable-next-line no-console */\n\t\tconsole.error( 'MCP adapter activation failed:', error );\n\t} finally {\n\t\tsignalMcpReady();\n\t}\n}\n\n// Start right away when the bundle loads after DOMContentLoaded (late or deferred load): the event will\n// not fire again, and `waitForMcpReady()` callers would wait forever.\nif ( typeof document !== 'undefined' && document.readyState === 'loading' ) {\n\tdocument.addEventListener( 'DOMContentLoaded', () => void startMCPServer(), { once: true } );\n} else {\n\tvoid startMCPServer();\n}\n","export const MCP_STYLES_APPLIED_EVENT = 'elementor/mcp/styles-applied';\n\nexport type McpStylesAppliedPayload = {\n\tstyleValue: Record< string, unknown >;\n};\n\nexport function 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,C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B,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,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"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elementor/editor-mcp",
|
|
3
|
-
"version": "4.4.
|
|
3
|
+
"version": "4.4.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "Elementor Team",
|
|
6
6
|
"homepage": "https://elementor.com/",
|
|
@@ -43,9 +43,9 @@
|
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@elementor-external/angie-sdk": "npm:@elementor/angie-sdk@1.10.1",
|
|
46
|
-
"@elementor/editor-v1-adapters": "4.4.
|
|
47
|
-
"@elementor/schema": "4.4.
|
|
48
|
-
"@elementor/store": "4.4.
|
|
46
|
+
"@elementor/editor-v1-adapters": "4.4.1",
|
|
47
|
+
"@elementor/schema": "4.4.1",
|
|
48
|
+
"@elementor/store": "4.4.1",
|
|
49
49
|
"@modelcontextprotocol/sdk": "1.32.2",
|
|
50
50
|
"@wordpress/api-fetch": "^6.42.0",
|
|
51
51
|
"zod-to-json-schema": "3.24.6"
|
package/src/index.ts
CHANGED
|
@@ -14,11 +14,13 @@ export { isAngieAvailable } from './utils/is-angie-available';
|
|
|
14
14
|
export { canCreateWidget } from './utils/can-create-widget';
|
|
15
15
|
export { isAngieSidebarOpen } from './utils/is-angie-sidebar-open';
|
|
16
16
|
export * from './mcp-registry';
|
|
17
|
+
export { AngieMcpAdapter } from './adapters/angie-adapter';
|
|
18
|
+
export type { IMcpRegistrationAdapter } from './adapters/types';
|
|
17
19
|
export { createSampler } from './sampler';
|
|
18
20
|
export { toolPrompts } from './utils/prompt-builder';
|
|
19
21
|
export { ANGIE_MODEL_PREFERENCES, ANGIE_REQUIRED_RESOURCES, type AngieModelPreferences } from './angie-annotations';
|
|
20
22
|
export { getActiveChatInfo, type ActiveChatInfo } from './utils/get-active-chat-info';
|
|
21
|
-
export { hasLoadedEditorAngie, openAngieInAskMode } from './utils/open-angie-in-ask-mode';
|
|
23
|
+
export { hasLoadedEditorAngie, openAngieInAgentMode, openAngieInAskMode } from './utils/open-angie-in-ask-mode';
|
|
22
24
|
export type {
|
|
23
25
|
EditorAngieWindowHost,
|
|
24
26
|
OpenAngieCommonProperties,
|
package/src/init.ts
CHANGED
|
@@ -16,7 +16,9 @@ export async function startMCPServer() {
|
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
// Start right away when the bundle loads after DOMContentLoaded (late or deferred load): the event will
|
|
20
|
+
// not fire again, and `waitForMcpReady()` callers would wait forever.
|
|
21
|
+
if ( typeof document !== 'undefined' && document.readyState === 'loading' ) {
|
|
20
22
|
document.addEventListener( 'DOMContentLoaded', () => void startMCPServer(), { once: true } );
|
|
21
23
|
} else {
|
|
22
24
|
void startMCPServer();
|
package/src/mcp-registry.ts
CHANGED
|
@@ -3,7 +3,6 @@ import { McpServer, type ToolCallback } from '@modelcontextprotocol/sdk/server/m
|
|
|
3
3
|
import { type RequestHandlerExtra } from '@modelcontextprotocol/sdk/shared/protocol.js';
|
|
4
4
|
import { type ServerNotification, type ServerRequest } from '@modelcontextprotocol/sdk/types.js';
|
|
5
5
|
|
|
6
|
-
import { AngieMcpAdapter } from './adapters/angie-adapter';
|
|
7
6
|
import { type IMcpRegistrationAdapter, type McpResourceHandler, type McpResourceUriOrTemplate } from './adapters/types';
|
|
8
7
|
import { WebMCPAdapter } from './adapters/web-mcp-adapter';
|
|
9
8
|
import {
|
|
@@ -14,8 +13,6 @@ import {
|
|
|
14
13
|
} from './angie-annotations';
|
|
15
14
|
import { mockMcpRegistry } from './test-utils/mock-mcp-registry';
|
|
16
15
|
import { getModelContext } from './utils/get-model-context';
|
|
17
|
-
import { getSDK } from './utils/get-sdk';
|
|
18
|
-
import { isAngieAvailable } from './utils/is-angie-available';
|
|
19
16
|
import { mergeRequiredResources, type ResourceList } from './utils/merge-required-resources';
|
|
20
17
|
import { registerServerDocsResource } from './utils/register-server-docs-resource';
|
|
21
18
|
import { toMCPTitle } from './utils/to-mcp-title';
|
|
@@ -58,6 +55,20 @@ export const signalMcpReady = (): void => {
|
|
|
58
55
|
resolveReady();
|
|
59
56
|
};
|
|
60
57
|
|
|
58
|
+
export const waitForMcpReady = (): Promise< void > => readyPromise;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Registers and activates an adapter that becomes available after startup.
|
|
62
|
+
* Waits for the startup activation so the adapter is activated exactly once.
|
|
63
|
+
*
|
|
64
|
+
* @param adapter - Adapter to register and activate.
|
|
65
|
+
*/
|
|
66
|
+
export const activateMcpAdapter = async ( adapter: IMcpRegistrationAdapter ): Promise< void > => {
|
|
67
|
+
await readyPromise;
|
|
68
|
+
registerMcpAdapter( adapter );
|
|
69
|
+
await adapter.activate();
|
|
70
|
+
};
|
|
71
|
+
|
|
61
72
|
export const createAndRegisterAdapters = async (): Promise< void > => {
|
|
62
73
|
const modelContext = getModelContext();
|
|
63
74
|
|
|
@@ -65,10 +76,6 @@ export const createAndRegisterAdapters = async (): Promise< void > => {
|
|
|
65
76
|
registerMcpAdapter( new WebMCPAdapter( modelContext ) );
|
|
66
77
|
}
|
|
67
78
|
|
|
68
|
-
if ( isAngieAvailable() ) {
|
|
69
|
-
registerMcpAdapter( new AngieMcpAdapter( getSDK(), getRegisteredMcpServers ) );
|
|
70
|
-
}
|
|
71
|
-
|
|
72
79
|
await Promise.all( registrationAdapters.map( ( adapter ) => adapter.activate() ) );
|
|
73
80
|
};
|
|
74
81
|
|
|
@@ -29,7 +29,15 @@ export const openLoadedEditorAngie = ( prompt: string | undefined, mode: AngieIn
|
|
|
29
29
|
};
|
|
30
30
|
|
|
31
31
|
export const openAngieInAskMode = ( prompt?: string ): void => {
|
|
32
|
-
|
|
32
|
+
openAngieInMode( prompt, AngieInteractionMode.ASK );
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export const openAngieInAgentMode = ( prompt?: string ): void => {
|
|
36
|
+
openAngieInMode( prompt, AngieInteractionMode.AGENT );
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const openAngieInMode = ( prompt: string | undefined, mode: AngieInteractionMode ): void => {
|
|
40
|
+
if ( openLoadedEditorAngie( prompt, mode ) ) {
|
|
33
41
|
return;
|
|
34
42
|
}
|
|
35
43
|
|
|
@@ -44,7 +52,7 @@ export const openAngieInAskMode = ( prompt?: string ): void => {
|
|
|
44
52
|
}
|
|
45
53
|
|
|
46
54
|
toggleAngieSidebar( angieSidebar, true );
|
|
47
|
-
setAngieInteractionMode(
|
|
55
|
+
setAngieInteractionMode( mode );
|
|
48
56
|
|
|
49
57
|
if ( prompt ) {
|
|
50
58
|
window.location.hash = `angie-prompt=${ encodeURIComponent( prompt ) }`;
|