Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions mesh/docs/plugins/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ For the maintained source-owned sample, start with
[`docs/plugins/exemplars/web-ui/`](exemplars/web-ui/README.md). The manifest,
bundle, config, and lifecycle fixtures there are part of the contract, and the
tests read them directly so the docs and implementation stay aligned.
Use the [React and Vite starter](exemplars/web-ui/react/README.md) to build
the same contributions from TSX and ship them in your plugin archive.

### Manifest Fields

Expand Down
49 changes: 33 additions & 16 deletions mesh/docs/plugins/exemplars/web-ui/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ drift.
| `bundle/host-contract.d.ts` | Self-contained public TypeScript author contract; it does not import console source. |
| `bundle/register-mesh-plugin-ui.js` | Directly shippable ES module loaded by the React host. |
| `bundle/register-mesh-plugin-ui.ts` | Typed author-source variant of the same bundle behavior. |
| [`react/`](react/README.md) | React and Vite starter for the same page and settings section. |
| `lifecycle-states.json` | Canonical state examples for `none`, `ready`, `disabled`, `invalid`, and `plugin_not_running`. |

## Build, Package, And Install Locally
Expand All @@ -30,41 +31,56 @@ plugin store below the exemplar's ignored `target/` directory, so they do not
change your normal mesh-llm installation.

```bash
EXEMPLAR=docs/plugins/exemplars/web-ui
EXEMPLAR=mesh/docs/plugins/exemplars/web-ui
MESH_LLM_BIN="${MESH_LLM_BIN:-mesh-llm}"
PLUGIN_UI_ENTRY="${PLUGIN_UI_ENTRY:-$EXEMPLAR/bundle/register-mesh-plugin-ui.js}"
PACKAGE_ROOT="$EXEMPLAR/target/package/web-ui-exemplar"
ARCHIVE="$EXEMPLAR/target/web-ui-exemplar-0.1.0-local.tar.gz"
STORE="$EXEMPLAR/target/plugin-store"

cargo build --release --manifest-path "$EXEMPLAR/Cargo.toml"
rm -rf "$EXEMPLAR/target/package" "$STORE"
mkdir -p "$PACKAGE_ROOT"
mkdir -p "$PACKAGE_ROOT/bundle"
cp "$EXEMPLAR/target/release/web-ui-exemplar" "$PACKAGE_ROOT/web-ui-exemplar"
cp "$EXEMPLAR/plugin.toml" "$PACKAGE_ROOT/plugin.toml"
cp -R "$EXEMPLAR/bundle" "$PACKAGE_ROOT/bundle"
cp "$PLUGIN_UI_ENTRY" "$PACKAGE_ROOT/bundle/register-mesh-plugin-ui.js"
"$EXEMPLAR/target/release/web-ui-exemplar" --print-package-manifest \
> "$PACKAGE_ROOT/plugin-manifest.json"
tar -C "$EXEMPLAR/target/package" -czf "$ARCHIVE" web-ui-exemplar

MESH_LLM_PLUGIN_DIR="$STORE" ./target/debug/mesh-llm plugins install \
MESH_LLM_PLUGIN_DIR="$STORE" "$MESH_LLM_BIN" plugins install \
--archive "$ARCHIVE" --name web-ui-exemplar --version 0.1.0
MESH_LLM_PLUGIN_DIR="$STORE" ./target/debug/mesh-llm plugins info web-ui-exemplar
MESH_LLM_PLUGIN_DIR="$STORE" "$MESH_LLM_BIN" plugins info web-ui-exemplar
```

To install the React variant, [build its bundle](react/README.md) and set
`PLUGIN_UI_ENTRY=mesh/docs/plugins/exemplars/web-ui/react/dist/register-mesh-plugin-ui.js`
before running the packaging commands. Both variants use the same manifest,
route, and settings.

On Windows, copy `web-ui-exemplar.exe`, package a `.zip`, and pass that archive
to the same `plugins install --archive` command. Local install accepts only
`.tar.gz` and `.zip`; `--name` is required and `--version` defaults to `dev`.

## Run And Verify

Start a client-only node so validation does not require a model or GPU:
For the complete walkthrough, set `EXEMPLAR_GGUF` to a local model file and
start a serving node. Client-only nodes expose the plugin page and API but
hide Configuration. Set `MESH_LLM_BIN=./target/debug/mesh-llm` before the
install steps if you are testing a local debug build.

```bash
./target/debug/mesh-llm auth status
# If no local owner identity exists, create an unencrypted development identity:
./target/debug/mesh-llm auth init --no-passphrase
cp "$EXEMPLAR/config.toml" "$EXEMPLAR/target/runtime-config.toml"
MESH_LLM_PLUGIN_DIR="$STORE" MESH_LLM_BIN=target/debug/mesh-llm just mesh-client \
"" 19337 13131 "$EXEMPLAR/target/runtime-config.toml"
STATE="$PWD/$EXEMPLAR/target/local-state"
mkdir -p "$STATE"
cp "$EXEMPLAR/config.toml" "$STATE/config.toml"
if [ ! -f "$STATE/owner-keystore.json" ]; then
"$MESH_LLM_BIN" auth init --owner-key "$STATE/owner-keystore.json" --no-passphrase
fi
MESH_LLM_PLUGIN_DIR="$STORE" MESH_LLM_NO_DEFAULT_PLUGINS=1 \
MESH_LLM_NODE_KEY_PATH="$STATE/node.key" MESH_LLM_DATA_DIR="$STATE/data" \
MESH_LLM_RUNTIME_ROOT="$STATE/runtime" \
"$MESH_LLM_BIN" serve --gguf "$EXEMPLAR_GGUF" --port 19337 --console 13131 \
--config "$STATE/config.toml" --owner-key "$STATE/owner-keystore.json"
```

Owner identity is required for the settings save exercised below. Use a
Expand All @@ -84,9 +100,10 @@ curl --fail -X POST http://127.0.0.1:13131/api/plugins/web-ui-exemplar/tools/sta
Open `http://127.0.0.1:13131/` in live data mode. Confirm `Exemplar Notes`
appears as a direct auxiliary navigation item, click it, and add a sample note.
The page must show the configured retention window and name
`exemplar.notes.v1`. Open Configuration -> Plugins, confirm the Plugin settings
banner is the first item, select the Web UI Exemplar category, and change
Retention days with the host-rendered numeric control. Save the configuration,
`exemplar.notes.v1`. Open Configuration → Plugins. If prompted, unlock owner
controls with the local token in `"$STATE/owner-control-token-v2"`. Confirm the
Plugin settings banner is the first item, select the Web UI Exemplar category,
and change Retention days with the host-rendered numeric control. Save the configuration,
return through the `Exemplar Notes` navigation item, and confirm the retention
window and new sample-note message use the saved value.

Expand All @@ -103,7 +120,7 @@ test "$(curl -s -o /dev/null -w '%{http_code}' \
```

Re-enable the projection with the same PATCH body using `true`. Stop the node
with Ctrl-C when finished, then remove `docs/plugins/exemplars/web-ui/target/`
with Ctrl-C when finished, then remove `mesh/docs/plugins/exemplars/web-ui/target/`
to clean every build, archive, store, and installed-plugin artifact.

## Contract Summary
Expand Down
2 changes: 2 additions & 0 deletions mesh/docs/plugins/exemplars/web-ui/react/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/node_modules/
/dist/
44 changes: 44 additions & 0 deletions mesh/docs/plugins/exemplars/web-ui/react/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# React plugin UI starter

Build a React page and a Configuration → Plugins section using the
[same example plugin](../README.md). In your own project, start with the files
in this directory and copy the public [host declarations](../bundle/host-contract.d.ts)
alongside them. Adjust their import path and match the registration keys to the
IDs in your plugin manifest.

## Build and install

From the MeshLLM checkout root, with Node.js 24 or newer and pnpm 10 or newer:

```bash
EXEMPLAR=mesh/docs/plugins/exemplars/web-ui
pnpm --dir "$EXEMPLAR/react" install --frozen-lockfile
pnpm --dir "$EXEMPLAR/react" build
PLUGIN_UI_ENTRY="$EXEMPLAR/react/dist/register-mesh-plugin-ui.js"
```

The build produces a browser ES module with React and React DOM included. In
the same shell, follow the [archive install steps](../README.md#build-package-and-install-locally)
to package `PLUGIN_UI_ENTRY` as `bundle/register-mesh-plugin-ui.js`. Open **Exemplar Notes**,
add a sample note, and [change the retention setting](../README.md#persisted-setting-reproduction).
Disable the projection and confirm the [MCP tool still responds](../README.md#run-and-verify).
To switch back to the plain JavaScript example, unset `PLUGIN_UI_ENTRY`,
repackage and reinstall the archive, and restart the example node.

## Extend the example

- **Page and settings section.** Export `registerMeshPluginUi`, then map the
manifest IDs `overview` and `page-actions` to mount functions. Each mount gets
its own React root and calls `root.unmount()` when the host removes it.
- **Theme and settings.** The sample styles its own elements with
`host.appearance.tokens` and reads `host.config.visible.settings`. The host's
schema controls handle editing and saving `retention_days`.
- **A request-inspector contribution.** Declare a `logs_request` contribution
in your manifest and register a mount under the same ID in `contributions`.
The host passes `requestId` and, when available, `exchangeId`. For a shipped
example, see [how Capsules registers and mounts its Evidence link](https://github.com/Mesh-LLM/capsules-plugin/blob/v0.1.4/web-ui/src/register-mesh-plugin-ui.tsx)
and [how it looks up the record](https://github.com/Mesh-LLM/capsules-plugin/blob/v0.1.4/web-ui/src/features/capsules/contributions/EvidenceChip.tsx).

MeshLLM imports the finished bundle into the console origin. Install bundles
from publishers you trust. When adding styles, scope them to the elements you
mount so they do not affect the console or other plugins.
24 changes: 24 additions & 0 deletions mesh/docs/plugins/exemplars/web-ui/react/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "mesh-plugin-web-ui-react-starter",
"private": true,
"type": "module",
"packageManager": "pnpm@10.34.5",
"engines": {
"node": ">=24",
"pnpm": ">=10"
},
"scripts": {
"typecheck": "tsc6 --noEmit",
"build": "pnpm typecheck && vite build"
},
"dependencies": {
"react": "19.2.8",
"react-dom": "19.2.8"
},
"devDependencies": {
"@types/react": "19.2.18",
"@types/react-dom": "19.2.7",
"typescript": "npm:@typescript/typescript6@6.0.2",
"vite": "8.2.2"
}
}
Loading
Loading