new plugin system

This commit is contained in:
KingKDot
2026-03-19 16:29:26 -05:00
parent 2aeac06b1a
commit cf314b5189
31 changed files with 1942 additions and 517 deletions
+18 -18
View File
@@ -1,49 +1,49 @@
# Sample Go WASM Plugin (sample)
# Sample Go Plugin (sample)
This sample lives at the repo root and builds a WASI-compatible Go plugin.
This sample lives at the repo root and builds a native Go plugin.
## Files to include in the plugin zip
At the root of the zip:
- sample.wasm
- sample-linux-amd64.so / sample-darwin-arm64.dylib / sample-windows-amd64.dll
- sample.html
- sample.css
- sample.js
## Build the WASM
## Build
Recommended: Go WASI (most compatible with wazero)
Use the provided build scripts:
1) Build the WASM with Go 1.21+:
```bash
# Linux/macOS
./build-plugin.sh
GOOS=wasip1 GOARCH=wasm go build -o sample.wasm ./wasm
# Multiple targets
BUILD_TARGETS="linux-amd64 linux-arm64 darwin-arm64" ./build-plugin.sh
2) Optional TinyGo fallback:
tinygo build -o sample.wasm -target wasi -scheduler=none -gc=leaking ./wasm
# Windows
build-plugin.bat
```
## Create the zip
Create a zip named sample.zip containing:
- sample.wasm
- sample.html
- sample.css
- sample.js
The build script automatically creates `sample.zip` containing the built
binaries and web assets.
Then place sample.zip in Overlord-Server/plugins.
Then place `sample.zip` in `Overlord-Server/plugins`.
## Open the UI
Navigate to:
- /plugins/sample?clientId=<CLIENT_ID>
Click "Send event" and the WASM plugin will echo back to the server logs.
Click "Send event" and the plugin will echo back to the server logs.
## OS detection (Windows-only logic)
The plugin receives host metadata in the `init` payload. The sample plugin shows
how to detect the host OS and branch logic (see
[plugin-sample-go/wasm/main.go](plugin-sample-go/wasm/main.go)). For example:
`plugin-sample-go/native/main.go`). For example:
- If `host.os == "windows"`, you can safely run Windows-only flows (e.g., WinAPI-backed behavior).
- Otherwise, skip or provide a fallback path.