Download mintlify-docs/app-devs/reference/system-apis.mdx from Anirudh1950/MentraOS: direct link, hf CLI and curl.
- Browser
- Download file 5.92 kB
-
https://huggingface.co/Anirudh1950/MentraOS/resolve/main/mintlify-docs/app-devs/reference/system-apis.mdx
- Command line
-
hf download hf://Anirudh1950/MentraOS/mintlify-docs/app-devs/reference/system-apis.mdx
-
curl -L -o system-apis.mdx https://huggingface.co/Anirudh1950/MentraOS/resolve/main/mintlify-docs/app-devs/reference/system-apis.mdx
5.92 kB
| --- | |
| title: "System Miniapp APIs" | |
| description: "APIs restricted to system miniapps for interop and privileged device controls." | |
| icon: "shield-halved" | |
| --- | |
| import BetaNote from '/snippets/beta-note.mdx' | |
| <BetaNote /> | |
| <Warning> | |
| These APIs are restricted to **system miniapps** (Mentra AI today). A regular | |
| miniapp that calls them gets `NOT_PERMITTED`. They're documented here for | |
| reference. To make your own miniapp callable, expose actions instead, see | |
| [Actions](/app-devs/core-concepts/miniapp-interop). | |
| </Warning> | |
| System miniapps can discover other miniapps, control their lifecycle, invoke | |
| the actions those miniapps expose, and use a small set of privileged device | |
| controls. | |
| ## Discover and control miniapps | |
| `session.miniapps` lists installed miniapps and starts or stops them. | |
| ```ts | |
| // Compatible miniapps only by default; each action can carry input and output schemas. | |
| const apps = await session.miniapps.list(); | |
| const all = await session.miniapps.list({ includeIncompatible: true }); | |
| // start() runs a miniapp in the BACKGROUND: it spawns the background context and | |
| // reports as running, without changing phone navigation or foregrounding anything | |
| // (the WebView mounts only if the user opens it). | |
| await session.miniapps.start("com.mentra.todo"); | |
| await session.miniapps.open("com.mentra.todo"); // start and bring its phone UI forward | |
| await session.miniapps.stop("com.mentra.todo"); | |
| ``` | |
| | Method | Returns | Notes | | |
| |---|---|---| | |
| | `list(options?)` | `Promise<MiniappInfo[]>` | `options.includeIncompatible` defaults to `false`. Each entry carries its declared `actions`. | | |
| | `start(packageName)` | `Promise<void>` | Background-spawn; no foreground change. | | |
| | `open(packageName)` | `Promise<void>` | Start and foreground the miniapp's phone UI. | | |
| | `stop(packageName)` | `Promise<void>` | Stop a running miniapp. | | |
| Each `MiniappInfo` also reports `system` (the Mentra App build ships this | |
| miniapp). Actions declared with `"audience": "host"` are not listed. | |
| ### Installing miniapps | |
| `session.miniapps.install({url})` installs the miniapp at a miniapp URL, the | |
| HTTPS address that serves its `miniapp.json`. The Mentra App shows no install | |
| sheet, so ask the person first. Only a miniapp on the Mentra App's system list | |
| may install; any other caller, a development build included, gets | |
| `NOT_PERMITTED`. | |
| ```ts | |
| if (session.hostFeatures?.miniappInstall) { | |
| const {packageName} = await session.miniapps.install({ | |
| url: "https://notes.example.com/", | |
| packageName: "com.example.notes", | |
| }); | |
| await session.miniapps.open(packageName); | |
| } | |
| ``` | |
| `packageName` is optional: the package the person agreed to. A URL that serves | |
| another one installs nothing and fails with `not_a_miniapp`. | |
| `session.hostFeatures.miniappInstall` says the Mentra App installs from a URL. | |
| Older Mentra Apps don't advertise it, and answer `install` with `NOT_PERMITTED`. | |
| The Mentra App installs it as it installs from a link: it fetches | |
| `miniapp.json`, checks the package name against the URL's domain, registers the | |
| URL with Mentra, checks the phone can run the miniapp, and downloads, verifies | |
| and installs its bundle. `status` is `installed`, `opened` (it was installed from | |
| that URL already, or a newer release of it is) or `deferred` (the miniapp is | |
| running, so its update waits until it stops or the person answers the Mentra | |
| App's update prompt). | |
| A failed install rejects with `INSTALL_FAILED`. Its `reason` says why: | |
| `not_a_miniapp`, `domain_mismatch`, `archived`, `needs_newer_app`, | |
| `access_denied`, `age_restricted`, `network`, `cancelled`, `integrity` or | |
| `signature_invalid`. | |
| `checkInstallCompatibility` checks a release's `minHostVersion`, `sdkVersion` | |
| and `hardwareRequirements` against the phone and the paired glasses, and reports | |
| what it finds. Only a `host` or `sdk` blocker stops an install; a `hardware` | |
| blocker never does. `uninstall(packageName)` removes | |
| a miniapp installed from a miniapp URL; a miniapp the Mentra App bundles, one a | |
| workspace manages and a development build stay, with `NOT_PERMITTED`. | |
| ## Invoke an action | |
| `session.actions.invoke` calls an action another miniapp exposed via | |
| `session.actions.handle`. It headless-wakes the target if it's stopped, runs the | |
| handler, and returns the result. | |
| ```ts | |
| const res = await session.actions.invoke( | |
| "com.mentra.todo", | |
| "add_todo", | |
| { text: "milk" }, | |
| { timeoutMs: 30000 }, // default 30s, max 120s | |
| ); | |
| ``` | |
| `invoke()` rejects with `{ code, message }` where `code` is one of: | |
| | Code | Meaning | | |
| |---|---| | |
| | `NOT_PERMITTED` | The caller isn't a system miniapp. | | |
| | `APP_NOT_FOUND` | No miniapp with that package name. | | |
| | `APP_NOT_COMPATIBLE` | The target can't run on the connected glasses. | | |
| | `ACTION_NOT_FOUND` | The target doesn't declare that action. | | |
| | `NO_ACTION_HANDLER` | The action is declared but no handler is registered. | | |
| | `WAKE_FAILED` | The target couldn't be headless-woken. | | |
| | `ACTION_TIMEOUT` | The handler didn't resolve within `timeoutMs`. | | |
| | `PAYLOAD_TOO_LARGE` | Params or result exceeded 256 KB. | | |
| A thrown handler in the target surfaces its own error message to the caller. | |
| The action descriptor returned by `session.miniapps.list()` includes an optional | |
| `outputSchema`, which describes the structured result for result-aware callers. | |
| ## Privileged device controls | |
| ### Wi-Fi ADB (Mentra Live) | |
| `session.glasses.setWifiAdbState` toggles wireless debugging on Mentra Live. | |
| The preference is persisted on the glasses and reapplied at boot (default | |
| **off**). Non-system callers get `NOT_PERMITTED`. | |
| ```ts | |
| await session.glasses.setWifiAdbState(true); // enable | |
| await session.glasses.setWifiAdbState(false); // disable | |
| ``` | |
| | Method | Returns | Notes | | |
| |---|---|---| | |
| | `setWifiAdbState(enabled)` | `Promise<void>` | Mentra Live only; other models no-op. SYSTEM-only. | | |