From 5f2815715005177ad0f96e3e0c9eb4dcb6462310 Mon Sep 17 00:00:00 2001 From: Oli Larkin Date: Tue, 15 Sep 2026 11:27:05 +0200 Subject: [PATCH] Wire the templates up to the iPlug2 WebMCP agent bridge Update the iPlug2 submodule to the wasm/web-mcp branch, which adds a WebMCP agent bridge to the Wasm host pages (parameter automation, state snapshot/restore, IGraphics inspection and manipulation, pointer and keyboard simulation, screenshots, WebView actions). TemplateProjectWebView: annotate the editor-size buttons with data-iplug-action ids, register a reset-gain action through window.iPlugWebMCP, and stop the knob's decorative SVG strokes from intercepting pointer input. TemplateProject: the Makefile distribution script now copies the shared host scripts (footer UI and bridge) next to the generated page. CLAUDE.md points at the bridge documentation. --- CLAUDE.md | 8 +++++++ TemplateProject/scripts/makedist-wasm.sh | 4 ++++ .../resources/web/index.html | 23 ++++++++++++++++--- .../resources/web/knob-control.js | 2 ++ iPlug2 | 2 +- 5 files changed, 35 insertions(+), 4 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index 32f3913..19d31c3 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -33,6 +33,14 @@ git add [PluginName]/* .vscode/* .github/* bump_version.py git commit -m "created [PluginName] based on TemplateProject" ``` +## WebMCP agent bridge (Wasm builds) + +Every Wasm host page registers WebMCP tools (`navigator.modelContext`) so a browser agent can +set parameters, snapshot/restore state, inspect and manipulate IGraphics controls, simulate +input and take screenshots. Without WebMCP the same tools are reachable from DevTools via +`window.__iplugWebMCPShim.list()` / `.call(name, input)`. See the "WebMCP Agent Bridge" +section of @iPlug2/Documentation/wasm.md. + ## Additional Context - iPlug2 framework: @iPlug2/CLAUDE.md diff --git a/TemplateProject/scripts/makedist-wasm.sh b/TemplateProject/scripts/makedist-wasm.sh index ba3f6a4..fed4e3a 100755 --- a/TemplateProject/scripts/makedist-wasm.sh +++ b/TemplateProject/scripts/makedist-wasm.sh @@ -210,6 +210,10 @@ cp "$IPLUG2_ROOT/IPlug/WEB/TemplateWasm/scripts/IPlugWasmProcessor.js.template" sed -i"$BAK_SUFFIX" "s/NAME_PLACEHOLDER_LC/$PROJECT_NAME_LC/g" "scripts/$PROJECT_NAME-processor.js" sed -i"$BAK_SUFFIX" "s/NAME_PLACEHOLDER/$PROJECT_NAME/g" "scripts/$PROJECT_NAME-processor.js" +# Copy the shared host page scripts (footer UI + WebMCP agent bridge), used verbatim +cp "$IPLUG2_ROOT/IPlug/WEB/TemplateWasm/scripts/IPlugWasmHostControls.js" scripts/IPlugWasmHostControls.js +cp "$IPLUG2_ROOT/IPlug/WEB/TemplateWasm/scripts/IPlugWasmWebMCP.js" scripts/IPlugWasmWebMCP.js + # Copy and process HTML template # IMPORTANT: Replace NAME_PLACEHOLDER_LC first (longer match) before NAME_PLACEHOLDER cp "$IPLUG2_ROOT/IPlug/WEB/TemplateWasm/index.html" index.html diff --git a/TemplateProjectWebView/resources/web/index.html b/TemplateProjectWebView/resources/web/index.html index e7b8664..3f9a95c 100644 --- a/TemplateProjectWebView/resources/web/index.html +++ b/TemplateProjectWebView/resources/web/index.html @@ -104,6 +104,23 @@ function OnControlChange(ctrlTag, value) {} + // Optional: expose an explicit action to browser agents (WebMCP) when the + // UI is hosted by the Wasm host page. Clickable elements can instead be + // annotated with data-iplug-action="id" (see the size buttons below). + window.iPlugWebMCP?.registerAction({ + id: 'reset-gain', + label: 'Reset gain to its default', + run: async () => { + const info = window['parameters']?.[0]; + const normalized = info ? (info.default - info.min) / (info.max - info.min) : 1; + BPCFUI(0); + SPVFUI(0, normalized); + EPCFUI(0); + OnParamChange(0, normalized); + return { normalized }; + } + }); + // Called by script.js for arbitrary messages from the plugin. The plugin // sends the parameter list as JSON once the web content has loaded. function OnMessage(msgTag, dataSize, data) { @@ -133,9 +150,9 @@

TemplateProjectWebView

Editor size - Small - Medium - Large + Small + Medium + Large
diff --git a/TemplateProjectWebView/resources/web/knob-control.js b/TemplateProjectWebView/resources/web/knob-control.js index a9fb3b6..26a1412 100644 --- a/TemplateProjectWebView/resources/web/knob-control.js +++ b/TemplateProjectWebView/resources/web/knob-control.js @@ -55,6 +55,8 @@ class KnobControl extends HTMLElement { width: var(--knob-size, 80px); height: var(--knob-size, 80px); } + /* Decorative strokes must not intercept the circle's pointer handlers. */ + svg path, svg line { pointer-events: none; } .hidden-cursor { cursor: none; } diff --git a/iPlug2 b/iPlug2 index 5c2df9d..ae70a71 160000 --- a/iPlug2 +++ b/iPlug2 @@ -1 +1 @@ -Subproject commit 5c2df9dce3f5258acfeff3846a6a9563f382212c +Subproject commit ae70a716a33adf2f7c851fbd6ecce1cc423a7182