diff --git a/mesh/docs/plugins/README.md b/mesh/docs/plugins/README.md index c0fc656724..8c3f1dbdad 100644 --- a/mesh/docs/plugins/README.md +++ b/mesh/docs/plugins/README.md @@ -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 diff --git a/mesh/docs/plugins/exemplars/web-ui/README.md b/mesh/docs/plugins/exemplars/web-ui/README.md index 3dcf3c4b9a..f0dea309fe 100644 --- a/mesh/docs/plugins/exemplars/web-ui/README.md +++ b/mesh/docs/plugins/exemplars/web-ui/README.md @@ -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 @@ -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 @@ -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. @@ -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 diff --git a/mesh/docs/plugins/exemplars/web-ui/react/.gitignore b/mesh/docs/plugins/exemplars/web-ui/react/.gitignore new file mode 100644 index 0000000000..b0a5c349ca --- /dev/null +++ b/mesh/docs/plugins/exemplars/web-ui/react/.gitignore @@ -0,0 +1,2 @@ +/node_modules/ +/dist/ diff --git a/mesh/docs/plugins/exemplars/web-ui/react/README.md b/mesh/docs/plugins/exemplars/web-ui/react/README.md new file mode 100644 index 0000000000..ca9702d478 --- /dev/null +++ b/mesh/docs/plugins/exemplars/web-ui/react/README.md @@ -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. diff --git a/mesh/docs/plugins/exemplars/web-ui/react/package.json b/mesh/docs/plugins/exemplars/web-ui/react/package.json new file mode 100644 index 0000000000..7d02d6b5be --- /dev/null +++ b/mesh/docs/plugins/exemplars/web-ui/react/package.json @@ -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" + } +} diff --git a/mesh/docs/plugins/exemplars/web-ui/react/pnpm-lock.yaml b/mesh/docs/plugins/exemplars/web-ui/react/pnpm-lock.yaml new file mode 100644 index 0000000000..b4b1716ed3 --- /dev/null +++ b/mesh/docs/plugins/exemplars/web-ui/react/pnpm-lock.yaml @@ -0,0 +1,579 @@ +lockfileVersion: '9.0' + +settings: + autoInstallPeers: true + excludeLinksFromLockfile: false + +importers: + + .: + dependencies: + react: + specifier: 19.2.8 + version: 19.2.8 + react-dom: + specifier: 19.2.8 + version: 19.2.8(react@19.2.8) + devDependencies: + '@types/react': + specifier: 19.2.18 + version: 19.2.18 + '@types/react-dom': + specifier: 19.2.7 + version: 19.2.7(@types/react@19.2.18) + typescript: + specifier: npm:@typescript/typescript6@6.0.2 + version: '@typescript/typescript6@6.0.2' + vite: + specifier: 8.2.2 + version: 8.2.2 + +packages: + + '@emnapi/core@2.0.0-beta.2': + resolution: {integrity: sha512-MzCVoWtcg4Pm2B3je5mMvYMvj3MmBKw+fU7vbsJc9/iT8ip6/eYIHo/Dsm/mr+wsHB6SEyJDuxB09Yy6r/8+4A==} + + '@emnapi/runtime@2.0.0-beta.2': + resolution: {integrity: sha512-JcrSPzPvZuNZvJqPTF9Fw25LbOJ8avzFVlaf2grmH4Cku0oGP47tRgqPZadcfj3YoZMHkFVnCYFbQM8I+i5QEw==} + + '@emnapi/wasi-threads@2.2.0': + resolution: {integrity: sha512-JP7OYH38Q7+pyTAe14raZHLQIK7BDKbdwji+Xi3pcd/6QkJYQH3SX4wu6EplGrGJWRepoNzedfm0G3B9Z4e9Rw==} + + '@napi-rs/wasm-runtime@1.2.6': + resolution: {integrity: sha512-mRyDmEw9/fCDXCGfL1sbgIw/GUK0PVxRW4YwgPN61F3LQ+fSyoBFarJVzgGyhF6kRzEQZ0FejDqm4WLXSeqQmw==} + engines: {node: ^20.19.0 || ^22.13.0 || >=23.5.0} + peerDependencies: + '@emnapi/core': ^1.7.1 || 2.0.0-beta.2 + '@emnapi/runtime': ^1.7.1 || 2.0.0-beta.2 + + '@oxc-project/types@0.156.0': + resolution: {integrity: sha512-1Duyg48TdJNdyhEB8Xn1L36bT9Pv6GUtlKjHxOys8xkaF/rQq3XJE+bAurSK/AgIz5mGFsb77cn9Pb20+WCScw==} + + '@rolldown/binding-android-arm-eabi@1.2.19': + resolution: {integrity: sha512-e+Ebe0WT+9tbXmNKPIiC8YrWAHYwug3m6i4p3rZGGulfZri1jtI4HslT+OZnFf/OIHowWF71DTlHwXBP2SiA7A==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm] + os: [android] + + '@rolldown/binding-android-arm64@1.2.19': + resolution: {integrity: sha512-hOombrTJ+szt2ciEzS7oCA78lMPBgF5UMQWCJIyNfnrI7GLl8HYoFqCnpL2gcPOaXMqryGCU5ExdQKyDDcC+yA==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [android] + + '@rolldown/binding-darwin-arm64@1.2.19': + resolution: {integrity: sha512-XoMA2pwCKGTQzUjPgtRwkedH4WmXhdIPKT6l6oOxd1PUbNodGI6DcBekgN7EC//+x3pfBYX/qL1gNmZAqivw5g==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [darwin] + + '@rolldown/binding-darwin-x64@1.2.19': + resolution: {integrity: sha512-zo8EsSSwMZCY/e+fRnGaX02YGgvJD0yvhNi/9hpGPA2MJ9ZF8dPCw75UGfpI6OpQ/myR/dIYmogRvqiZD0TrXg==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [darwin] + + '@rolldown/binding-freebsd-x64@1.2.19': + resolution: {integrity: sha512-O8ISAOfI1nj7AuBPd30FSF47z7f7lzlk5poQVGgiikvQuGEBFYvW8ki+UEnT+YJPnNGjQzn304klt4O9FUE7mA==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [freebsd] + + '@rolldown/binding-linux-arm-gnueabihf@1.2.19': + resolution: {integrity: sha512-/lYCba5NO0yq4S0jGMH8QTBtkvQxoXjoQWzF5BcWp9MjB9jxVRD1GQDNofkVjcOj30DWyhLIN/4Oe60JKzaONw==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm] + os: [linux] + + '@rolldown/binding-linux-arm64-gnu@1.2.19': + resolution: {integrity: sha512-pm/apFMBnSbFb3O6nG5pHO1iqHhZrjGDFEjSm+ot9J17XXPvH9L90y5h+jgfHCE+Qdlsvy8qKEcU4VKxgjD+vA==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [linux] + libc: [glibc] + + '@rolldown/binding-linux-arm64-musl@1.2.19': + resolution: {integrity: sha512-K1SmQp3FFichn8oqrNIwvFoZ5wcvjC7goBzpaMNvLf9FZc+QB/QvLmnpJZgAAGHiD980tP8FZZnXk2K94rvlxg==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [linux] + libc: [musl] + + '@rolldown/binding-linux-ppc64-gnu@1.2.19': + resolution: {integrity: sha512-I0xwD57jP/3A7+5UPZin2w8Y7XHEmEM5zqpYZOcQ45MlNW6tUJUziymV3yRr7rL4vwyfEcRsRksC4a7Kc08p5Q==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [ppc64] + os: [linux] + libc: [glibc] + + '@rolldown/binding-linux-s390x-gnu@1.2.19': + resolution: {integrity: sha512-BrtEHT24SNXj9HiXqy+s/kXiSiQGt6EKCPUlRirAoIioVxKGnbXBUEkbZASAei7iZJB0/Ynm+0JP00Ipx7AnSw==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [s390x] + os: [linux] + libc: [glibc] + + '@rolldown/binding-linux-x64-gnu@1.2.19': + resolution: {integrity: sha512-rm75/9DkHKeU2WnA8w4X94WGYgLlDCFCfkQC+4bguVJmC/jvDRv2B+2wLOYhyE0fVuv7//Ckk39OoOufyCu76Q==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [linux] + libc: [glibc] + + '@rolldown/binding-linux-x64-musl@1.2.19': + resolution: {integrity: sha512-irh/4+iYFM4GAzpluDErgjz89bj6NDtqqMAG/6O1LG38Ed3NpyebzCpcVNkFW8uhy+/3/BocUvnXDR33CXWe9A==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [linux] + libc: [musl] + + '@rolldown/binding-openharmony-arm64@1.2.19': + resolution: {integrity: sha512-+KWTWNoPt+CfSq94CiceWu3yPE+QzkaG+phPyz9G60tmZLwfQkcA4AeksafzvJAw4pvg1mcd5a1TkUqVv0s4JA==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [openharmony] + + '@rolldown/binding-wasm32-wasi@1.2.19': + resolution: {integrity: sha512-7EH+skOsl5qpWnK0vzamgJFhOv1cwxQpsxm8tI883K9fur5c27p8q87fzEO6BbBPabA2/+s/zR63/pLc137iOg==} + engines: {node: ^20.19.0 || ^22.13.0 || >=23.5.0} + cpu: [wasm32] + + '@rolldown/binding-win32-arm64-msvc@1.2.19': + resolution: {integrity: sha512-3Q1Yg1Q7tEvBWoZf5rFvG/GKZQPgwfru+p4wBajDfJFBs0SHCpL++dfTjW9gyAKd1T7ZpIYvdaUax7Pa/IhFVQ==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [win32] + + '@rolldown/binding-win32-x64-msvc@1.2.19': + resolution: {integrity: sha512-y/sqRRc6d7hECzOFc5n3LSeqctmIp9mMjY1Kq4s14uLPd/LZ4z7i1zrW6fMtp2mPeuQIC4e6ULMcwQzMomqQag==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [win32] + + '@rolldown/pluginutils@1.1.1': + resolution: {integrity: sha512-glFIJDvLNDtJhT9qrMFWLPbvS+skxgt4L0K8Ei2YtnhPysAJnsI7nyxSJxKj4ADeKX0OLjC4ntRkwpLOoS3rwA==} + + '@tybys/wasm-util@0.10.5': + resolution: {integrity: sha512-dOGOPxlaNV+G046mZzN+9C0dAcQZeSKcXiVaM0TYy/LM4ttTmgSBDxYfovcYI8Em3+eAbiAYpvWLOv8+ZVRJKA==} + + '@types/react-dom@19.2.7': + resolution: {integrity: sha512-I8bPpDLcHBv1qiIiXDCy71Rt8eQDKJP0sMSWJphDdAcdqiJ1sGpZamavoEIRZmYzjia9LuEb2HlYdDpmoENpvQ==} + peerDependencies: + '@types/react': ^19.2.0 + + '@types/react@19.2.18': + resolution: {integrity: sha512-AnzbBERsrLKtk2XSfTbYRLjQPdy116Sty4q+T+Bp3IC4l6jNBvreVPAHmpq9qhXQM7CXZPjLVmGMw9sy+hxQ3w==} + + '@typescript/typescript6@6.0.2': + resolution: {integrity: sha512-mbCddXd+jm7hfx7w2YU64/Av4/NqqeG3GoRZgxPcgoTxYjhrcfJRw9ULch71SS4G+Q3bOXFhRvPqjguN0Hyp5w==} + hasBin: true + + csstype@3.2.4: + resolution: {integrity: sha512-PoKaoPzQapnEoqUSnHx1u6W6ku8CVEgKsnpmmzU3m1nwkidpPBQ8V/Zq2+bWNrsOKoKLwTGdbx6xF7BXP1zLVQ==} + + detect-libc@2.1.2: + resolution: {integrity: sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==} + engines: {node: '>=8'} + + fdir@6.5.0: + resolution: {integrity: sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==} + engines: {node: '>=12.0.0'} + peerDependencies: + picomatch: ^3 || ^4 + peerDependenciesMeta: + picomatch: + optional: true + + fsevents@2.3.3: + resolution: {integrity: sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==} + engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0} + os: [darwin] + + lightningcss-android-arm64@1.33.0: + resolution: {integrity: sha512-gEpRTalKdosp4Bb8qWtc2iOgE5SeIHlpS1up9bFq2wAyYhl1UdTObYiHe98zEM9SQvSoqQZ1IQD0JNpg3Ml5pg==} + engines: {node: '>= 12.0.0'} + cpu: [arm64] + os: [android] + + lightningcss-darwin-arm64@1.33.0: + resolution: {integrity: sha512-Sciaz8eenNTKn9b3t7+xr0ipTp9YxKQY4npwQ3mrRuL0BAVHBLyZxofhaKBAVtzmtRZ/zTyo0/to4B1uWG/Djg==} + engines: {node: '>= 12.0.0'} + cpu: [arm64] + os: [darwin] + + lightningcss-darwin-x64@1.33.0: + resolution: {integrity: sha512-Z5UPAxzrjlWNNyGy6i65cJzzvgJ5D3T6wMvs+gWpY9d7qRhANrxqAp6LhxIgZhWEw18RfJTGcRxjuLIBr+m8XQ==} + engines: {node: '>= 12.0.0'} + cpu: [x64] + os: [darwin] + + lightningcss-freebsd-x64@1.33.0: + resolution: {integrity: sha512-QQM/Ti/hQajJwCY+RiWuCZ9sdtI/XQk7nDK5vC8kkdwixezOlDgvDx7+RT+QjK6FcFT4MpsuoBnHIo/O3StRRg==} + engines: {node: '>= 12.0.0'} + cpu: [x64] + os: [freebsd] + + lightningcss-linux-arm-gnueabihf@1.33.0: + resolution: {integrity: sha512-N7FVBe6iS24MlM6R/4RBTxGhQheZGs7tiQ9U32UtF75NzP5Q7xWPRqLBCKxlRQRk3rY1jCIPLzx7WzOhuUIRLQ==} + engines: {node: '>= 12.0.0'} + cpu: [arm] + os: [linux] + + lightningcss-linux-arm64-gnu@1.33.0: + resolution: {integrity: sha512-j2v/itmy4HlNxlc6voKXYgBqNi0Ng2LShg4z7GufpEgs05P+2suBVyi9I6YHq5uoVFx9ETin3eCEhLVyXGQnKg==} + engines: {node: '>= 12.0.0'} + cpu: [arm64] + os: [linux] + libc: [glibc] + + lightningcss-linux-arm64-musl@1.33.0: + resolution: {integrity: sha512-yiO5ROMuYQgXbC60yjZU5CYSFZGKXL0HFATXt9mHJn1+zW55oCtMI9NfcVhYLMFDL7gV7oBPon/EmMMGg2OvtQ==} + engines: {node: '>= 12.0.0'} + cpu: [arm64] + os: [linux] + libc: [musl] + + lightningcss-linux-x64-gnu@1.33.0: + resolution: {integrity: sha512-ar+Ju7LmcN0Jo4FpL4hpFybwNG9/3A/Br5KW2n2jyODg3MEZXaDYADdemoNS+BDNfMgKvylJLj4S5tyRActuAg==} + engines: {node: '>= 12.0.0'} + cpu: [x64] + os: [linux] + libc: [glibc] + + lightningcss-linux-x64-musl@1.33.0: + resolution: {integrity: sha512-RYiYbkokw0trfKqqzfF55lginwEPrD3OJDfTuJzFs1MK6iFnDenaz1fqLLtX4ITG3OktJQXOeTaw1awrBAlZPw==} + engines: {node: '>= 12.0.0'} + cpu: [x64] + os: [linux] + libc: [musl] + + lightningcss-win32-arm64-msvc@1.33.0: + resolution: {integrity: sha512-1K+MPfLSFVpphzpdbfkhlWk6wBrTObBzS2T6db10PNOZgR9GoVsAWzwNyuhUYYbTp23j+4RrncfujZ4uAzXvwA==} + engines: {node: '>= 12.0.0'} + cpu: [arm64] + os: [win32] + + lightningcss-win32-x64-msvc@1.33.0: + resolution: {integrity: sha512-OlEICDx/Xl0FqSp4bry8zFnCvGpig3Gl4gCquvYwHuqJKEC1+n9NgDniFvqHGmMv1ZkqDJrDqKKSykTDX+ehuA==} + engines: {node: '>= 12.0.0'} + cpu: [x64] + os: [win32] + + lightningcss@1.33.0: + resolution: {integrity: sha512-WkUDrojuJs0xkgGf2udWxa3yGBRxPtxUkB79i6aCZLRgc7PM8fZe9TosfPDcvEpQZbuFASnHYmRLBLUbmLOIIA==} + engines: {node: '>= 12.0.0'} + + nanoid@3.3.20: + resolution: {integrity: sha512-uKdg2G3GNCKQn9byYOpxbGqrT2fGO5KRt5J/8b3pok8rT6qxGWF6hxMyJiEYtAf+FVyYuD9hRaDqX5uPFYJ4ZQ==} + engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} + hasBin: true + + picocolors@1.1.1: + resolution: {integrity: sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==} + + picomatch@4.0.7: + resolution: {integrity: sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA==} + engines: {node: '>=12'} + + postcss@8.5.34: + resolution: {integrity: sha512-P1Qzj0XXZjMda74C7qiVnBG90UKNbyNUAOeQRBW8X63RsIMV57gevRqjnkELdwtZ/S2/uQFksJhmwuN8xShLPw==} + engines: {node: ^10 || ^12 || >=14} + + react-dom@19.2.8: + resolution: {integrity: sha512-rVprimfGBG3DR+Tq0IQG2DT5PxKth1WIGDmj5yPmlzr4YBe7uyE+Du4oVqTDXZSHGGGXRtTJEGSSePyQCMBglQ==} + peerDependencies: + react: ^19.2.8 + + react@19.2.8: + resolution: {integrity: sha512-PWaYA1L/q9u2u7xYQi+Y3L3Yfnie7XyLeaJICV1MGD6LprsBxcAqGjYyr0eY3p+QdsA+x/Irkt4Qif8D63+Sbw==} + engines: {node: '>=0.10.0'} + + rolldown@1.2.19: + resolution: {integrity: sha512-QIiV1J9d0pzN4jeeTH4sjPy0AZ6cAy2cG0ExeoE1+U8Rvj+hR3gYkokx0YbeUNGlZqiQJJ2utcETe0oKXwzsuA==} + engines: {node: ^20.19.0 || >=22.12.0} + hasBin: true + + scheduler@0.27.0: + resolution: {integrity: sha512-eNv+WrVbKu1f3vbYJT/xtiF5syA5HPIMtf9IgY/nKg0sWqzAUEvqY/xm7OcZc/qafLx/iO9FgOmeSAp4v5ti/Q==} + + source-map-js@1.2.4: + resolution: {integrity: sha512-J7ZjMvHd9O1fcT/5V09QWaaSl2BbWx3F6O08spde82Namf9UB0GxRVIPiNbVsdKkoizHiSpTodo3vp2bAy91MA==} + engines: {node: '>=6.0.0'} + + tinyglobby@0.2.17: + resolution: {integrity: sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g==} + engines: {node: '>=12.0.0'} + + tslib@2.9.1: + resolution: {integrity: sha512-a4Ux9VKuIMHsOS7ENbEq6hK2ZGYIT27Rtl0E4eD9KqwxhKiQeMZE/9xb3IdYwWaSOyIBQLExhQgXDTYoiCxnWA==} + + typescript@6.0.3: + resolution: {integrity: sha512-y2TvuxSZPDyQakkFRPZHKFm+KKVqIisdg9/CZwm9ftvKXLP8NRWj38/ODjNbr43SsoXqNuAisEf1GdCxqWcdBw==} + engines: {node: '>=14.17'} + hasBin: true + + vite@8.2.2: + resolution: {integrity: sha512-cFKLV/PRgAUlIRm5WjMjJ86jrftzpqcgH+Us+DS8mI3CDNiH30Whrz8uHL3+MOLPAgqbMBAqWdAHAphOAM+z/Q==} + engines: {node: ^20.19.0 || >=22.12.0} + hasBin: true + peerDependencies: + '@types/node': ^20.19.0 || >=22.12.0 + '@vitejs/devtools': ^0.4.0 || ^0.5.0 + esbuild: ^0.27.0 || ^0.28.0 + jiti: '>=1.21.0' + less: ^4.0.0 + sass: ^1.70.0 + sass-embedded: ^1.70.0 + stylus: '>=0.54.8' + sugarss: ^5.0.0 + terser: ^5.16.0 + tsx: ^4.8.1 + yaml: ^2.4.2 + peerDependenciesMeta: + '@types/node': + optional: true + '@vitejs/devtools': + optional: true + esbuild: + optional: true + jiti: + optional: true + less: + optional: true + sass: + optional: true + sass-embedded: + optional: true + stylus: + optional: true + sugarss: + optional: true + terser: + optional: true + tsx: + optional: true + yaml: + optional: true + +snapshots: + + '@emnapi/core@2.0.0-beta.2': + dependencies: + '@emnapi/wasi-threads': 2.2.0 + tslib: 2.9.1 + optional: true + + '@emnapi/runtime@2.0.0-beta.2': + dependencies: + tslib: 2.9.1 + optional: true + + '@emnapi/wasi-threads@2.2.0': + dependencies: + tslib: 2.9.1 + optional: true + + '@napi-rs/wasm-runtime@1.2.6(@emnapi/core@2.0.0-beta.2)(@emnapi/runtime@2.0.0-beta.2)': + dependencies: + '@emnapi/core': 2.0.0-beta.2 + '@emnapi/runtime': 2.0.0-beta.2 + '@tybys/wasm-util': 0.10.5 + optional: true + + '@oxc-project/types@0.156.0': {} + + '@rolldown/binding-android-arm-eabi@1.2.19': + optional: true + + '@rolldown/binding-android-arm64@1.2.19': + optional: true + + '@rolldown/binding-darwin-arm64@1.2.19': + optional: true + + '@rolldown/binding-darwin-x64@1.2.19': + optional: true + + '@rolldown/binding-freebsd-x64@1.2.19': + optional: true + + '@rolldown/binding-linux-arm-gnueabihf@1.2.19': + optional: true + + '@rolldown/binding-linux-arm64-gnu@1.2.19': + optional: true + + '@rolldown/binding-linux-arm64-musl@1.2.19': + optional: true + + '@rolldown/binding-linux-ppc64-gnu@1.2.19': + optional: true + + '@rolldown/binding-linux-s390x-gnu@1.2.19': + optional: true + + '@rolldown/binding-linux-x64-gnu@1.2.19': + optional: true + + '@rolldown/binding-linux-x64-musl@1.2.19': + optional: true + + '@rolldown/binding-openharmony-arm64@1.2.19': + optional: true + + '@rolldown/binding-wasm32-wasi@1.2.19': + dependencies: + '@emnapi/core': 2.0.0-beta.2 + '@emnapi/runtime': 2.0.0-beta.2 + '@napi-rs/wasm-runtime': 1.2.6(@emnapi/core@2.0.0-beta.2)(@emnapi/runtime@2.0.0-beta.2) + optional: true + + '@rolldown/binding-win32-arm64-msvc@1.2.19': + optional: true + + '@rolldown/binding-win32-x64-msvc@1.2.19': + optional: true + + '@rolldown/pluginutils@1.1.1': {} + + '@tybys/wasm-util@0.10.5': + dependencies: + tslib: 2.9.1 + optional: true + + '@types/react-dom@19.2.7(@types/react@19.2.18)': + dependencies: + '@types/react': 19.2.18 + + '@types/react@19.2.18': + dependencies: + csstype: 3.2.4 + + '@typescript/typescript6@6.0.2': + dependencies: + '@typescript/old': typescript@6.0.3 + + csstype@3.2.4: {} + + detect-libc@2.1.2: {} + + fdir@6.5.0(picomatch@4.0.7): + optionalDependencies: + picomatch: 4.0.7 + + fsevents@2.3.3: + optional: true + + lightningcss-android-arm64@1.33.0: + optional: true + + lightningcss-darwin-arm64@1.33.0: + optional: true + + lightningcss-darwin-x64@1.33.0: + optional: true + + lightningcss-freebsd-x64@1.33.0: + optional: true + + lightningcss-linux-arm-gnueabihf@1.33.0: + optional: true + + lightningcss-linux-arm64-gnu@1.33.0: + optional: true + + lightningcss-linux-arm64-musl@1.33.0: + optional: true + + lightningcss-linux-x64-gnu@1.33.0: + optional: true + + lightningcss-linux-x64-musl@1.33.0: + optional: true + + lightningcss-win32-arm64-msvc@1.33.0: + optional: true + + lightningcss-win32-x64-msvc@1.33.0: + optional: true + + lightningcss@1.33.0: + dependencies: + detect-libc: 2.1.2 + optionalDependencies: + lightningcss-android-arm64: 1.33.0 + lightningcss-darwin-arm64: 1.33.0 + lightningcss-darwin-x64: 1.33.0 + lightningcss-freebsd-x64: 1.33.0 + lightningcss-linux-arm-gnueabihf: 1.33.0 + lightningcss-linux-arm64-gnu: 1.33.0 + lightningcss-linux-arm64-musl: 1.33.0 + lightningcss-linux-x64-gnu: 1.33.0 + lightningcss-linux-x64-musl: 1.33.0 + lightningcss-win32-arm64-msvc: 1.33.0 + lightningcss-win32-x64-msvc: 1.33.0 + + nanoid@3.3.20: {} + + picocolors@1.1.1: {} + + picomatch@4.0.7: {} + + postcss@8.5.34: + dependencies: + nanoid: 3.3.20 + picocolors: 1.1.1 + source-map-js: 1.2.4 + + react-dom@19.2.8(react@19.2.8): + dependencies: + react: 19.2.8 + scheduler: 0.27.0 + + react@19.2.8: {} + + rolldown@1.2.19: + dependencies: + '@oxc-project/types': 0.156.0 + '@rolldown/pluginutils': 1.1.1 + optionalDependencies: + '@rolldown/binding-android-arm-eabi': 1.2.19 + '@rolldown/binding-android-arm64': 1.2.19 + '@rolldown/binding-darwin-arm64': 1.2.19 + '@rolldown/binding-darwin-x64': 1.2.19 + '@rolldown/binding-freebsd-x64': 1.2.19 + '@rolldown/binding-linux-arm-gnueabihf': 1.2.19 + '@rolldown/binding-linux-arm64-gnu': 1.2.19 + '@rolldown/binding-linux-arm64-musl': 1.2.19 + '@rolldown/binding-linux-ppc64-gnu': 1.2.19 + '@rolldown/binding-linux-s390x-gnu': 1.2.19 + '@rolldown/binding-linux-x64-gnu': 1.2.19 + '@rolldown/binding-linux-x64-musl': 1.2.19 + '@rolldown/binding-openharmony-arm64': 1.2.19 + '@rolldown/binding-wasm32-wasi': 1.2.19 + '@rolldown/binding-win32-arm64-msvc': 1.2.19 + '@rolldown/binding-win32-x64-msvc': 1.2.19 + + scheduler@0.27.0: {} + + source-map-js@1.2.4: {} + + tinyglobby@0.2.17: + dependencies: + fdir: 6.5.0(picomatch@4.0.7) + picomatch: 4.0.7 + + tslib@2.9.1: + optional: true + + typescript@6.0.3: {} + + vite@8.2.2: + dependencies: + lightningcss: 1.33.0 + picomatch: 4.0.7 + postcss: 8.5.34 + rolldown: 1.2.19 + tinyglobby: 0.2.17 + optionalDependencies: + fsevents: 2.3.3 diff --git a/mesh/docs/plugins/exemplars/web-ui/react/register-mesh-plugin-ui.tsx b/mesh/docs/plugins/exemplars/web-ui/react/register-mesh-plugin-ui.tsx new file mode 100644 index 0000000000..2e94d44069 --- /dev/null +++ b/mesh/docs/plugins/exemplars/web-ui/react/register-mesh-plugin-ui.tsx @@ -0,0 +1,87 @@ +import { useState, type CSSProperties, type ReactNode } from 'react' +import { createRoot } from 'react-dom/client' +import type { MeshPluginUiBundleModule, MeshPluginUiHost, MeshPluginUiMountHandle } from '../bundle/host-contract' + +function mount(element: HTMLElement, content: ReactNode): MeshPluginUiMountHandle { + const root = createRoot(element) + root.render(content) + return { unmount: () => root.unmount() } +} + +function configuredRetentionDays(host: MeshPluginUiHost): number { + const setting = host.config.visible.settings.retention_days + return typeof setting === 'number' ? setting : 14 +} + +function buttonStyle(host: MeshPluginUiHost): CSSProperties { + const { tokens } = host.appearance + return { + background: tokens.panelStrong, + border: `1px solid ${tokens.border}`, + borderRadius: tokens.radius, + color: tokens.foreground, + padding: '6px 12px' + } +} + +function Notes({ host, title }: { host: MeshPluginUiHost; title: string }) { + const retentionDays = configuredRetentionDays(host) + const [noteCount, setNoteCount] = useState(0) + const { tokens } = host.appearance + const button = buttonStyle(host) + + return ( +
+

{title}

+

The exemplar.notes.v1 capability remains available when the UI is disabled.

+
+

{retentionDays} days

+ +
+
+ + +
+

+ {noteCount === 0 + ? 'No sample notes yet.' + : `Sample note ${noteCount} will be retained for ${retentionDays} days.`} +

+
+ ) +} + +function PageActions({ host }: { host: MeshPluginUiHost }) { + const retentionDays = configuredRetentionDays(host) + + return ( +
+

Current retention: {retentionDays} days

+ +
+ ) +} + +export const registerMeshPluginUi: MeshPluginUiBundleModule['registerMeshPluginUi'] = () => ({ + pages: { + overview: ({ element, host, page }) => mount(element, ) + }, + configSections: { + 'page-actions': ({ element, host }) => mount(element, ) + } +}) diff --git a/mesh/docs/plugins/exemplars/web-ui/react/tsconfig.json b/mesh/docs/plugins/exemplars/web-ui/react/tsconfig.json new file mode 100644 index 0000000000..c81cf42d46 --- /dev/null +++ b/mesh/docs/plugins/exemplars/web-ui/react/tsconfig.json @@ -0,0 +1,11 @@ +{ + "compilerOptions": { + "target": "ES2022", + "lib": ["ES2022", "DOM"], + "module": "ESNext", + "moduleResolution": "Bundler", + "jsx": "react-jsx", + "strict": true + }, + "include": ["register-mesh-plugin-ui.tsx"] +} diff --git a/mesh/docs/plugins/exemplars/web-ui/react/vite.config.ts b/mesh/docs/plugins/exemplars/web-ui/react/vite.config.ts new file mode 100644 index 0000000000..374c7d94cc --- /dev/null +++ b/mesh/docs/plugins/exemplars/web-ui/react/vite.config.ts @@ -0,0 +1,13 @@ +import { defineConfig } from 'vite' + +export default defineConfig({ + define: { 'process.env.NODE_ENV': JSON.stringify('production') }, + build: { + target: 'es2022', + lib: { + entry: 'register-mesh-plugin-ui.tsx', + formats: ['es'], + fileName: () => 'register-mesh-plugin-ui.js' + } + } +}) diff --git a/mesh/website/src/docs/pages/developing-plugins.md b/mesh/website/src/docs/pages/developing-plugins.md index b93cfe3844..9af4c8063a 100644 --- a/mesh/website/src/docs/pages/developing-plugins.md +++ b/mesh/website/src/docs/pages/developing-plugins.md @@ -333,9 +333,12 @@ Plugins → Integrations**. Operators can set `web_ui_enabled = false` or use th console toggle to hide that projection without affecting the plugin's other capabilities. -The maintained [web UI exemplar](https://github.com/Mesh-LLM/mesh-llm/tree/main/docs/plugins/exemplars/web-ui) +The maintained [web UI exemplar](https://github.com/Mesh-LLM/mesh-llm/tree/main/mesh/docs/plugins/exemplars/web-ui) includes a matching author manifest, packaged metadata, config, typed bundle, and lifecycle-state reference. Use it as the release check for this contract. +The [React and Vite starter](https://github.com/Mesh-LLM/mesh-llm/tree/main/mesh/docs/plugins/exemplars/web-ui/react) +builds the same page and settings section from TSX as a self-contained bundle +that you can ship in your plugin archive. ## Package and release a plugin