# Mini App SDK

A Mini App is a web page that Cowork opens in its own tab. Inside it, Cowork adds one global object, `window.MAESTROSDK`, through which the page talks to Cowork. This chapter lists the modules of that object that Cowork supports and every function in them, in the same layout as a method reference.

> **Release status**
> Functions marked <Badge type="warning" text="Not yet released" /> are in Cowork's source but not in a released version yet. Check that a function exists before you call it (see [Check what is available](#check-what-is-available)).

## Modules

| Module | Functions | What it is for |
|---|---|---|
| [Lifecycle](https://docs.micromeet.ai/miniapp-sdk/lifecycle.md) | `beforeRefresh(handler)` | Keep unsaved work when someone refreshes the tab |
| [Interaction](https://docs.micromeet.ai/miniapp-sdk/interaction.md) | `confirm(request)` | Ask the person a yes / no question in a native dialog |
| [Models](https://docs.micromeet.ai/miniapp-sdk/llm.md) | `llm.providers()` · `llm.complete(request)` | Use one of the AI models Cowork already has set up |
| [Package](https://docs.micromeet.ai/miniapp-sdk/package.md) | `package.get()` | Read the package this Mini App came from, and which extensions it has |
| [Sign-in](https://docs.micromeet.ai/miniapp-sdk/auth.md) | `auth.login(params?)` · `auth.status()` | Sign the person in with their Micromeet account (signed packages only) |

To build a Mini App that signs people in with Micromeet, start with [Build a Sign-in Mini App](https://docs.micromeet.ai/miniapp-sdk/sign-in-guide.md). To package a Mini App and have Micromeet sign it, see [Build and Sign](https://docs.micromeet.ai/miniapp-sdk/build.md); every rule the package must meet is in [Package Spec](https://docs.micromeet.ai/miniapp-sdk/package-spec.md).

Every function above returns a `Promise` except `beforeRefresh`, and none of them throws for an expected failure: each returns `false`, `null`, an empty list or `{ ok: false, error }`, as its section says.

The object also has a `connectors` module (`root`, `list`, `agentMdPath`, `readAgentMd`, `writeAgentMd`, `onAgentMdChange`). Cowork does not support it: its functions return empty results, `{ ok: false, reason: 'unsupported' }`, or throw `unsupported`. Do not use it in a Cowork Mini App.

## The Mini App folder <Badge type="warning" text="Not yet released" />

In 0.1.41 only the Mini Apps that come with Cowork exist; you cannot install your own. From the next version:

```text
miniapp/
  manifest.json    { appId, name, version, entry }
  index.html       the entry page
  app.js  app.css  anything else it loads, by relative path
```

The file is `manifest.json` from Cowork 0.1.46; earlier builds read `miniapp.json`, so keep a copy under that name while people still use one. A Mini App can also be a signed package (`app.asar`): see [Build and Sign](https://docs.micromeet.ai/miniapp-sdk/build.md).

| Field | Type | Required | Description |
|---|---|---|---|
| `appId` | `string` | Yes | Reverse-domain id, lowercase, such as `ai.micromeet.janeapp-operator`; at most 128 characters. The tab is `miniapp:<appId>` |
| `name` | `string` or `{ zh, en }` | Yes | Name in the tab and menus; at most 60 characters |
| `version` | `string` | Yes | At most 32 characters |
| `entry` | `string` | No | Entry page, a relative path inside the folder, at most 256 characters. Default `index.html` |
| `extension` | `string` | No | Only for a Mini App installed on its own: a folder inside it holding its one extension. A Mini App in a package leaves it out |

- Pages load by relative path and use hash routing (`#/page`).
- Each Mini App keeps its own storage (cookies, `localStorage`), separate from web tabs and other Mini Apps. Uninstalling clears it.
- Install it as part of a package, together with its extensions and skills: see [Extension Overview](https://docs.micromeet.ai/extend/overview.md).

## Check what is available

```js
const sdk = window.MAESTROSDK;
if (sdk && sdk.package && typeof sdk.package.get === 'function') {
  const info = await sdk.package.get();
}
```

On an older Cowork, a module that is not there yet is simply missing; show the person a short note instead of failing.

## Related

- [Extension SDK](https://docs.micromeet.ai/extension-sdk/overview.md): What the extensions of the same package can call
- [Mini App](https://docs.micromeet.ai/extend/mini-apps.md): The Mini Apps that come with Cowork
- [Extension Overview](https://docs.micromeet.ai/extend/overview.md): Which kind of addition to build
