-
Sample WASM Platform Note
-
-
Waiting to write platform note
-
-
OS-
-
Arch-
-
mkdir-
-
write-
-
Desktop file-
-
Desktop size-
-
Desktop list-
-
Desktop read-
-
-
-
diff --git a/plugins/sample-wasm-platform-note/sample-wasm-platform-note.js b/plugins/sample-wasm-platform-note/sample-wasm-platform-note.js
deleted file mode 100644
index d8188e0..0000000
--- a/plugins/sample-wasm-platform-note/sample-wasm-platform-note.js
+++ /dev/null
@@ -1,101 +0,0 @@
-(() => {
- const out = document.getElementById("sample-wasm-platform-note-output");
- const btn = document.getElementById("sample-wasm-platform-note-run");
- const status = document.getElementById("sample-wasm-platform-note-status");
- const fields = {
- os: document.getElementById("sample-wasm-platform-note-os"),
- arch: document.getElementById("sample-wasm-platform-note-arch"),
- mkdir: document.getElementById("sample-wasm-platform-note-mkdir"),
- write: document.getElementById("sample-wasm-platform-note-write"),
- desktopFile: document.getElementById("sample-wasm-platform-note-desktop-file"),
- desktopSize: document.getElementById("sample-wasm-platform-note-desktop-size"),
- desktopList: document.getElementById("sample-wasm-platform-note-desktop-list"),
- desktopRead: document.getElementById("sample-wasm-platform-note-desktop-read"),
- };
- const clientId = new URLSearchParams(window.location.search).get("clientId");
- const pluginId = "sample-wasm-platform-note";
- let polling = false;
-
- function log(message) {
- if (out) out.textContent = `${message}\n${out.textContent || ""}`;
- }
-
- function setStatus(message) {
- if (status) status.textContent = message;
- }
-
- function parsePayload(payload) {
- if (payload == null) return {};
- if (typeof payload === "string") {
- try { return JSON.parse(payload); } catch (_) { return { raw: payload }; }
- }
- return payload;
- }
-
- function renderPlatformNote(payload) {
- const info = parsePayload(payload);
- if (fields.os) fields.os.textContent = info.os || "-";
- if (fields.arch) fields.arch.textContent = info.arch || "-";
- if (fields.mkdir) fields.mkdir.textContent = String(info.mkdir ?? "-");
- if (fields.write) fields.write.textContent = String(info.write ?? "-");
- if (fields.desktopFile) fields.desktopFile.textContent = info.desktopFile || "(no readable file found)";
- if (fields.desktopSize) fields.desktopSize.textContent = Number.isFinite(info.desktopSize) && info.desktopSize >= 0 ? `${info.desktopSize} bytes` : "-";
- if (fields.desktopList) fields.desktopList.textContent = String(info.desktopList ?? "-");
- if (fields.desktopRead) fields.desktopRead.textContent = String(info.desktopRead ?? "-");
- setStatus(info.write === 0 ? "Platform note written" : "Platform note result received");
- log(JSON.stringify(info, null, 2));
- }
-
- function handlePluginEvent(event, payload) {
- if (event === "ready") {
- setStatus("Plugin loaded");
- log(JSON.stringify(parsePayload(payload), null, 2));
- return;
- }
- if (event === "platform_note") renderPlatformNote(payload);
- }
-
- window.addEventListener("message", (e) => {
- if (!e.data || e.data.type !== "plugin_event") return;
- if (e.data.pluginId && e.data.pluginId !== pluginId) return;
- handlePluginEvent(e.data.event, e.data.payload);
- });
-
- async function pollEvents() {
- if (!clientId || polling) return;
- polling = true;
- try {
- const res = await fetch(`/api/clients/${encodeURIComponent(clientId)}/plugins/${pluginId}/events`, {
- headers: { Accept: "application/json" },
- });
- if (res.ok) {
- const data = await res.json();
- if (data.events) data.events.forEach((e) => handlePluginEvent(e.event, e.payload));
- }
- } catch (_) {
- // Polling is best-effort; the next interval can recover.
- } finally {
- polling = false;
- }
- }
-
- btn?.addEventListener("click", async () => {
- if (!clientId) {
- setStatus("Open this plugin from a client row so clientId is present.");
- return;
- }
- setStatus("Writing platform note");
- const res = await fetch(`/api/clients/${encodeURIComponent(clientId)}/plugins/sample-wasm-platform-note/event`, {
- method: "POST",
- headers: { "Content-Type": "application/json" },
- body: JSON.stringify({ event: "write_note", payload: {} }),
- });
- if (!res.ok) setStatus(`Send failed: ${res.status}`);
- setTimeout(pollEvents, 250);
- });
-
- if (clientId) {
- setInterval(pollEvents, 1500);
- setTimeout(pollEvents, 300);
- }
-})();
diff --git a/plugins/sample-wasm/README.md b/plugins/sample-wasm/README.md
deleted file mode 100644
index 4457d75..0000000
--- a/plugins/sample-wasm/README.md
+++ /dev/null
@@ -1,9 +0,0 @@
-# Sample WASM Plugin
-
-This is a Plugin 2.0 sample. It declares broad file needs in `config.json`, then uses the agent WASM host imports to write to `pluginData` and list `downloads`.
-
-On Windows, run this sample's local `build.bat`. The builder uses a WASI-capable `clang` to compile `native/sample_wasm.c`, writes `sample-wasm.wasm`, and creates `sample-wasm.zip`.
-
-You can also build `native/sample_wasm.c` manually with a WASI-capable clang, copy the resulting `sample-wasm.wasm` into this folder, then zip the folder contents.
-
-The server will show the declared needs before the module can be sent to an agent.
diff --git a/plugins/sample-wasm/build.bat b/plugins/sample-wasm/build.bat
deleted file mode 100644
index 076c095..0000000
--- a/plugins/sample-wasm/build.bat
+++ /dev/null
@@ -1,60 +0,0 @@
-@echo off
-setlocal enabledelayedexpansion
-
-set "PLUGIN_DIR=%~dp0"
-set "PLUGIN_NAME=sample-wasm"
-
-set "NATIVE_DIR=%PLUGIN_DIR%\native"
-set "WASM_OUT=%PLUGIN_DIR%\%PLUGIN_NAME%.wasm"
-set "ZIP_OUT=%PLUGIN_DIR%\%PLUGIN_NAME%.zip"
-
-if not exist "%PLUGIN_DIR%\config.json" (
- echo [error] config.json not found in %PLUGIN_DIR%
- exit /b 1
-)
-
-set "WASM_SOURCE="
-if exist "%NATIVE_DIR%" (
- for %%S in ("%NATIVE_DIR%\*.c") do (
- if not defined WASM_SOURCE set "WASM_SOURCE=%%~fS"
- )
-)
-
-if defined WASM_SOURCE (
- where clang >nul 2>&1
- if errorlevel 1 (
- echo [error] clang was not found. Install a WASI-capable clang or provide %WASM_OUT% yourself.
- exit /b 1
- )
-
- echo [build] clang --target=wasm32-wasi -O2 "!WASM_SOURCE!" ^> "%WASM_OUT%"
- clang --target=wasm32-wasi -O2 -Wl,--no-entry -Wl,--allow-undefined -Wl,--export=overlord_alloc -Wl,--export=overlord_free -Wl,--export=overlord_on_load -Wl,--export=overlord_on_event -Wl,--export=overlord_on_unload -o "%WASM_OUT%" "!WASM_SOURCE!"
- if errorlevel 1 (
- echo [error] WASM build failed
- exit /b 1
- )
-)
-
-if exist "%ZIP_OUT%" del /f /q "%ZIP_OUT%"
-
-pushd "%PLUGIN_DIR%"
-powershell -NoProfile -ExecutionPolicy Bypass -Command "$zip = '%ZIP_OUT%'; $items = @(); foreach ($file in @('config.json', '%PLUGIN_NAME%.html', '%PLUGIN_NAME%.css', '%PLUGIN_NAME%.js', '%PLUGIN_NAME%.wasm', 'server.js')) { if (Test-Path -LiteralPath $file -PathType Leaf) { $items += $file } }; foreach ($dir in @('src', 'assets')) { if (Test-Path -LiteralPath $dir -PathType Container) { $items += $dir } }; if ($items.Count -eq 0) { throw 'No plugin files found to package' }; Compress-Archive -Path $items -DestinationPath $zip -Force"
-set "ZIP_STATUS=%ERRORLEVEL%"
-popd
-if not "%ZIP_STATUS%"=="0" exit /b %ZIP_STATUS%
-if errorlevel 1 (
- echo [error] zip failed
- exit /b 1
-)
-
-if defined PLUGIN_SIGN_KEY (
- where bun >nul 2>&1
- if not errorlevel 1 (
- echo [sign] Signing plugin with key: %PLUGIN_SIGN_KEY%
- bun run "%~dp0..\..\Overlord-Server\scripts\plugin-sign.ts" --key "%PLUGIN_SIGN_KEY%" "%ZIP_OUT%"
- ) else (
- echo [warn] bun not found, skipping plugin signing
- )
-)
-
-echo [ok] %ZIP_OUT%
diff --git a/plugins/sample-wasm/native/sample_wasm.c b/plugins/sample-wasm/native/sample_wasm.c
deleted file mode 100644
index c372b11..0000000
--- a/plugins/sample-wasm/native/sample_wasm.c
+++ /dev/null
@@ -1,69 +0,0 @@
-// Build with a WASI-capable clang:
-// clang --target=wasm32-wasi -O2 -Wl,--no-entry -Wl,--export=overlord_alloc \
-// -Wl,--export=overlord_free -Wl,--export=overlord_on_load \
-// -Wl,--export=overlord_on_event -Wl,--export=overlord_on_unload \
-// -o sample-wasm.wasm sample_wasm.c
-
-#include