> ## Documentation Index
> Fetch the complete documentation index at: https://agent.minimax.io/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Extensions reference

> Quick reference for the extension package layout, the extension tool, events, ctx methods, sites, elements, and limits.

For the release status of each capability, see [Capabilities and progress](https://agent.minimax.io/docs/extension/progress.md).

This page lists every extension interface in tables, and each item links to the page that explains it. The API version is `0.1.0`.

> [!NOTE]
>
> The type files are the full source of truth for the interface. `init` writes the type declarations into `.minimax-plugin/types/` in the development folder, and every `preview` refreshes them. If this page disagrees with the type files, trust the type files.

## Package layout

```text theme={null}
<development-folder>/
├── .minimax-plugin/plugin.json   # "hooks": ["hooks/hooks.json"]; name equals pluginId
├── .minimax-plugin/types/        # Editor types maintained by the host; not counted as package contents
├── hooks/hooks.json              # { "modules": ["./register.tsx"] }
├── hooks/register.tsx            # export const register: Register = (on) => { … }
├── hooks/state.ts                # defineState({ … })
├── hooks/*.test.tsx              # Tests. The module doesn't import them
├── <server>.mcp.json             # Optional: an MCP server bundled with the plugin
├── tsconfig.json                 # Yours. It only needs to extend ./.minimax-plugin/types/tsconfig.json
└── icon.png
```

| File | Required | Contents |
| - | - | - |
| `.minimax-plugin/plugin.json` | Yes | The plugin manifest. An extension needs `"hooks": ["hooks/hooks.json"]`. `name` must equal `pluginId`, or you get `EXTENSION_NAME_MISMATCH`. Other required fields: `schemaVersion: 1`, `version`, `description`, `author`, `icon`, `category`, `exampleQueries`, `apps`, `mcpServers`, `skills` |
| `hooks/hooks.json` | Yes | Only the single entry `{ "modules": ["./register.tsx"] }` |
| `hooks/register.tsx` | Yes | The extension module and only entry point. It exports `register`. See [Register hooks](https://agent.minimax.io/docs/extension/events.md#register) |
| `hooks/state.ts` | When you use `ctx.state` | `defineState({ … })`, re-exported by the module with `export { state } from './state'`. See [Save state](https://agent.minimax.io/docs/extension/api.md#state) |
| `hooks/*.test.tsx` | No | Tests. See [Write tests](https://agent.minimax.io/docs/extension/testing.md#write-tests) |
| `<server>.mcp.json` | No | An MCP server bundled with the plugin. List it in the manifest's `mcpServers` and keep the server files in the package. See [Call MCP tools](https://agent.minimax.io/docs/extension/api.md#mcp-call) |
| `.minimax-plugin/types/` | No | Type files written by `init` and refreshed by `preview`. The host maintains them, and they aren't copied on install |
| `tsconfig.json` | No | Yours to manage. The host doesn't read it |

The package needs only the files above. Modules import only files inside the package and `@minimax/mcode-plugin-extension` (importing any other module reports `EXTENSION_IMPORT_FORBIDDEN`).

### Modules you can import

| Module specifier | Who can import it | Contents |
| - | - | - |
| `@minimax/mcode-plugin-extension` | Modules and tests | Types and functions such as `Register` and `defineState` |
| `@minimax/mcode-plugin-extension/ui` | Modules and tests | Elements: `Box`, `Text`, `Markdown`, `Code`, `Tag`, `Button`, `Input`, `Select`, `Switch`, `Spinner`, `Progress`, `Link`, `Svg` |
| `@minimax/mcode-plugin-extension/jsx-runtime`, `/jsx-dev-runtime` | Modules and tests | The JSX runtime. `.tsx` files use it automatically, so you rarely write it yourself |
| `@minimax/mcode-plugin-extension/testing` | Tests only | Test utilities |
| Relative paths inside the package | Modules and tests | For example `./state` |

Any other import reports `EXTENSION_IMPORT_FORBIDDEN`: paths outside the package, bare module names, `node:`, `data:`, absolute paths, and value imports from `.minimax-plugin/types/`, the root `tsconfig.json`, `dist/`, or `node_modules/`. The host configures JSX, so files don't carry a JSX pragma at the top.

## The extension tool

You develop extensions by having the Agent call the `extension` tool. See [Write your first extension](https://agent.minimax.io/docs/extension/quickstart.md).

| Action | Parameters | What it does |
| - | - | - |
| `init` | `pluginId`, `title?` | Writes the template package and returns the development folder `packagePath`. If the package already exists, it only refreshes the editor types. Only `init` accepts `title`, which becomes the template button's text and the draft prefix |
| `test` | `pluginId`, `sourcePath?` | Validates by the `preview` rules, then runs all tests in a real extension host. See [Run tests](https://agent.minimax.io/docs/extension/testing.md#run-tests) |
| `preview` | `pluginId`, `sourcePath?` | Needs the user's permission. Validates the package and loads it into the current session |
| `inspect` | `pluginId` | Returns `source` (validation summary), `preview` (the running version), and `runtime` (diagnostics, console output). See [Check state with inspect](https://agent.minimax.io/docs/extension/testing.md#inspect) |
| `withdraw` | `pluginId` | Withdraws the preview from this session. Files and stored data are kept |

* `pluginId` is the plugin name. It starts with a lowercase letter and is made of lowercase letters and digits, which can be joined by a single `-`, `_`, or `.` (such as `sprint-board`). It's at most 80 characters.
* `sourcePath` is an absolute path that makes `test` and `preview` read a package in another folder. By default they read the development folder returned by `init`. When `sourcePath` points outside the development folder, `test` also shows a permission card, as `preview` does.

## Events

You can call `on(event, matcher?, hook)` only at the top level of `register`, with a literal matcher. See [Events (hooks)](https://agent.minimax.io/docs/extension/events.md#register) and [Static rules](https://agent.minimax.io/docs/extension/events.md#static-rules).

| Event | When it fires | Matcher fields | Main fields of `e` |
| - | - | - | - |
| [`ui.render`](https://agent.minimax.io/docs/extension/interface#sites) | When the host needs to draw a site | `site` (required): `'above-prompt'`, `'pane'`, or `'backdrop'`, plus `'above-prompt-list'` Coming soon; `id` (only for `pane`, optional) | Status band: `{ site: 'above-prompt' }`; panel: `{ site: 'pane', id }`; backdrop: `{ site: 'backdrop', props: { plugin, scene, revision } }`; arranging the status band's rows Coming soon: `{ site: 'above-prompt-list', props: { rows } }`. The hook also receives `next` |
| [`session.start`](https://agent.minimax.io/docs/extension/events#session-start) | When the plugin is activated in a session, including install mid-session, reloads, and Runtime restarts. Once per Activation | None | `cwd` |
| [`turn.start`](https://agent.minimax.io/docs/extension/events#turn-events) | A turn starts | None | `startedAt`, `prompt?: { text, attachments? }` |
| [`turn.complete`](https://agent.minimax.io/docs/extension/events#turn-events) | A turn ends (main Agent or sub-agent) | None | `status` (`completed` / `aborted` / `error`), `durationMs`, `usage?`; sub-agents you started also have `answer?`, `answerTruncated?`, `reason?` |
| [`tool.call`](https://agent.minimax.io/docs/extension/events#tool-events) | When the Agent calls a tool | `tool?`, `server?` | `toolCallId`, `toolName`, `server?`, `startedAt`, `input?` |
| [`tool.result`](https://agent.minimax.io/docs/extension/events#tool-events) | When a tool call has a result | `tool?`, `server?` | `toolCallId`, `toolName`, `status` (`ok` / `error` / `denied`), `durationMs`, `output?: { text?, result? }` |
| [`session.measure`](https://agent.minimax.io/docs/extension/events#session-measure) | After a main Agent turn ends, when context usage differs from what was last sent | None | `sessionId`, `context`, `rateLimits`, `changed` |
| [`ui.close`](https://agent.minimax.io/docs/extension/events#ui-close) | The user closed your pane tab | `id?` | `sessionId`, `id` |
| [`command.run`](https://agent.minimax.io/docs/extension/events#command-run) | The user ran a slash command (`/` command) you registered | `command` (required; a command name this module registers, case-insensitive) | `sessionId`, `command`, `args` (the text after the command name, with leading and trailing whitespace trimmed). The hook returns `{ text }` or nothing |

`turn.*` and `tool.*` events carry `sessionId`, `turnId`, and `agentId` (the main Agent has no `agentId`). `session.measure`, `ui.close`, and `command.run` carry only `sessionId`, with no `turnId` or `agentId`. `session.start` carries only `cwd`. `command.run` runs right away, like a button action: it doesn't wait for the turn and doesn't queue behind observe events. Observe events let you read what happens in the conversation. See [Observe events](https://agent.minimax.io/docs/extension/events.md#observe-events).

## ctx methods

Hooks receive `ctx`, and callbacks use the `ctx` of the enclosing hook. Write each call in the full `ctx.<domain>.<method>(…)` form.

| Method | What it does | Main parameters and return | Limits |
| - | - | - | - |
| [`ctx.state.get(key)`](https://agent.minimax.io/docs/extension/api#state) | Reads this session's state | The value | Redraws automatically when a key read by the draw changes |
| [`ctx.state.set(key, value)`, `update(key, fn)`](https://agent.minimax.io/docs/extension/api#state) | Writes this session's state | `Promise<void>` | Write from callbacks, `ctx.clock` callbacks, or observe events; a write during a draw reports `STATE_WRITE_IN_RENDER`; at most 256 keys; 64 KB per value, 1 MB total per session |
| [`ctx.store.get / set / delete / keys`](https://agent.minimax.io/docs/extension/api#store) | Reads and writes data saved across sessions | JSON values | Keys match `^[A-Za-z0-9._-]{1,128}$`; 256 KB per value, 8 MB total per plugin; needs `ctx.ui.invalidate()` after a write to redraw |
| [`ctx.store.onDidChange(listener)`](https://agent.minimax.io/docs/extension/api#store) | Listens for store changes | The callback receives `{ key, value }`; returns `{ dispose() }` | |
| [`ctx.mcp.call(server, tool, args?, { signal? })`](https://agent.minimax.io/docs/extension/api#mcp-call) | Calls an MCP tool | Returns `{ content, isError? }` | `server` must be a literal; 60 calls per plugin per minute; may show a permission card |
| [`ctx.ui.toast(text, { tone? })`](https://agent.minimax.io/docs/extension/api#ui) | Shows a toast | `tone`: `secondary`, `success`, `warning`, `danger` | 6 per plugin per minute; truncated past 500 characters |
| [`ctx.ui.invalidate()`](https://agent.minimax.io/docs/extension/interface#redraw) | Requests a redraw | No return value | |
| [`ctx.ui.open({ id, title, focus? })`](https://agent.minimax.io/docs/extension/api#ui) | Opens or updates a pane tab | `Promise<void>` | `id` up to 200 characters; at most 16 panels per plugin per session |
| [`ctx.ui.close(id)`](https://agent.minimax.io/docs/extension/api#ui) | Closes a panel | `Promise<void>` | Closing a panel that isn't open does nothing |
| [`ctx.prompt.fill({ text, mode? })`](https://agent.minimax.io/docs/extension/api#prompt-fill) | Writes a draft into the message box without sending | `{ written: true }` or `{ written: false, reason }`; `reason`: `draft`, `modal`, `no-composer` | `mode`: `replace` (default, only writes an empty message box) or `append` |
| [`ctx.prompt.suggest({ text })`](https://agent.minimax.io/docs/extension/api#prompt-suggest) | Shows a gray suggestion in the message box | `{ isShown: true }` or `{ isShown: false, reason }`; `reason`: `draft-not-empty`, `turn-running`, `dismissed`, `no-turn`, `no-composer` | One line of text, non-empty after trimming whitespace, at most 120 characters |
| [`ctx.prompt.read()`](https://agent.minimax.io/docs/extension/api#prompt-read) | Reads the message box draft | `{ text }` | Must be in `calls:`; reports `PROMPT_READ_UNAVAILABLE` with no response within 2 seconds |
| [`ctx.model.complete({ model, prompt, system?, maxTokens?, timeoutMs?, signal? })`](https://agent.minimax.io/docs/extension/api#model-complete) | Calls a model once, without conversation history or tools | `{ isAnswered: true, text, usage? }` or `{ isAnswered: false, reason, usage? }`; `reason`: `empty-reply`, `timeout`, `aborted`, `model-unavailable`, `provider-error` | `model` is required, in `provider/model` format; no confirmation prompt |
| [`ctx.agent.spawn({ prompt, description?, agentType?, model? })`](https://agent.minimax.io/docs/extension/api#agent-spawn) | Starts a background sub-agent | Returns `{ agentId, model }` right away | No confirmation prompt; the number running at once is capped by the session's sub-agent limit |
| [`ctx.agent.list()`](https://agent.minimax.io/docs/extension/api#agent-spawn) | Lists this session's sub-agents | `AgentInfo[]`: `id`, `description`, `type`, `status`, and more | |
| [`ctx.session.id / cwd / root / model`](https://agent.minimax.io/docs/extension/api#session) | Session info | Strings; `root` is absent outside a git repository | A snapshot taken when the Invocation starts |
| [`ctx.session.usage()`](https://agent.minimax.io/docs/extension/api#session) | Reads context usage | `{ startedAt, context: { window, tokens?, percent?, breakdown? }, rateLimits }` | A missing field means not measured yet, not 0 |
| [`ctx.clock.after(ms, fn)`, `every(ms, fn)`](https://agent.minimax.io/docs/extension/api#clock) | Timers | Returns `{ dispose() }` | `ms` is at least 1000 |
| [`ctx.clock.now()`](https://agent.minimax.io/docs/extension/api#clock) | The host's current time | Unix ms | |
| [`ctx.plugin`](https://agent.minimax.io/docs/extension/api#session) | The running plugin | `{ id, version }` | |
| [`ctx.command.register({ name, description, argumentHint? })`](https://agent.minimax.io/docs/extension/api#command) | Adds a command to the `/` menu in the message box | Returns `{ command }` | Call it in `session.start`, inside `try/catch`; write the argument as an object literal with a literal `name`; rejected when the name is taken (`COMMAND_NAME_RESERVED`, `COMMAND_NAME_TAKEN`). See the command rows of [Limits](#limits) |
| [`ctx.command.list()`](https://agent.minimax.io/docs/extension/api#command) | Lists this session's plugin commands | `{ pluginId, displayName?, name, description, argumentHint? }[]` | Built-in commands aren't included |
| [`ctx.theme.set({ backdrop?, colors? })`](https://agent.minimax.io/docs/extension/api#theme) | Sets this session's plugin theme: the backdrop and the colors | `Promise<void>` | Give at least one field; replaces the current theme as a whole, one theme per session; kept only in memory. Too little color contrast reports `THEME_PALETTE_REJECTED`, invalid arguments report `ARGUMENT_INVALID`. See the theme rows of [Limits](#limits) for values |
| [`ctx.theme.clear()`](https://agent.minimax.io/docs/extension/api#theme) | Removes this session's plugin theme | `Promise<void>` | |

`ctx.mcp.call` and `ctx.model.complete` accept a `signal` for cancellation. See [Cancel a call](https://agent.minimax.io/docs/extension/api.md#cancel).

## Sites

| Site | Location | Accepted elements | Notes |
| - | - | - | - |
| [`above-prompt`](https://agent.minimax.io/docs/extension/interface#above-prompt) | **Status band**: the strip above the message box, inside its border. All plugins share one band, and each draws a line or two in it | `Box`, `Text`, `Button`, `Tag`, `Spinner`, plus `Progress`, `Link`, and `Svg` Coming soon | One per session, drawn in layers by all plugins; about 12 lines tall, scrolls inside when taller. Coming soon Once the band is drawn in two steps, each plugin draws only its own row, and returning `undefined` draws nothing |
| [`above-prompt-list`](https://agent.minimax.io/docs/extension/interface#above-prompt-list) Coming soon | **Arranging the status band's rows**: the same band, run after every plugin's row is drawn | Same as `above-prompt` | One per session, drawn in layers by all plugins. `e.props.rows` holds the rows the plugins drew (`{ plugin, tree }[]`); filter or reorder them and pass them unchanged to `next(e)`. Changing, making up, or repeating a row reports `EXTENSION_ROWS_INVALID` |
| [`pane`](https://agent.minimax.io/docs/extension/interface#pane) | **Panel**: a tab in the conversation's side panel on the right, next to tabs such as Files and Browser | All 13 elements (`Svg` included) | Opened by `ctx.ui.open`; each panel is identified by its `id` |
| [`backdrop`](https://agent.minimax.io/docs/extension/interface#backdrop) | **Backdrop**: the backdrop behind the conversation, a layer in the main window under every panel. It replaces the wallpaper while a theme is active | `Box`, `Text`, `Svg` | One per session, drawn in layers by all plugins; drawn only when the session has a plugin theme (`ctx.theme.set({ backdrop })`). Every layer runs, so draw only your own theme, checked by `e.props.plugin` and `e.props.scene`, and `return next()` otherwise; takes no presses or input |

All three sites draw through the [render chain](https://agent.minimax.io/docs/extension/interface.md#render-chain), so keep `await next()` in what you draw. Coming soon Once the status band is drawn in two steps, `above-prompt` draws only your plugin's own row and the render chain runs on `above-prompt-list` instead; drawings on `above-prompt-list`, `pane`, and `backdrop` still need `next`.

## Elements

Write elements in JSX, such as `<Text size="lg" weight="semibold">Title</Text>` or `<Button variant="plain" icon="refresh" label="Refresh" onPress={…} />`. Every element can take a `key` attribute (such as `key="counter"`). See [Key rules](https://agent.minimax.io/docs/extension/interface.md#keys). For details, see [Elements](https://agent.minimax.io/docs/extension/interface.md#elements).

| Element | Where it works | Main properties |
| - | - | - |
| `<Box>` | Status band, panel, backdrop | `direction` (`row` / `column`), `gap`, `padding`, `paddingX`, `paddingY`, `align`, `justify`, `wrap`, `grow`, `shrink`, `width`, `scrollX`, `border`, `radius`, `background`, `hover: { background?, display?: 'show' \| 'hide' }`, `scope` (hover group name), child elements |
| `<Text>` | Status band, panel, backdrop | `size`, `weight`, `tone`, `background`, `truncate`, `maxLines`, `mono`, `tabular`, children (text) |
| `<Tag>` | Status band, panel | `label`, `tone` |
| `<Button>` | Status band, panel | `label`, `icon`, `tone`, `size`, `variant` (`default` / `plain`), `role` (`'dismiss'`) Coming soon, `disabled`, `onPress={() => …}` |
| `<Spinner>` | Status band, panel | `label` |
| `<Progress>` | Status band, panel | `label` (required), `value`, `max`, `valueText`, `tone` |
| `<Link>` | Status band, panel | `href` (required), `label`, `size`, children (text) |
| `<Markdown>` | Panel | `text`, `dim` |
| `<Code>` | Panel | `source`, `language`, `wrap` |
| `<Input>` | Panel | `value`, `placeholder`, `label`, `rows`, `submitLabel`, `onInput={(value) => …}`, `onSubmit={(value) => …}` |
| `<Select>` | Panel | `value`, `options: { value, label }[]`, `label`, `onSelect={(value) => …}` |
| `<Switch>` | Panel | `checked`, `label`, `onChange={(checked) => …}` |
| `<Svg>` | Backdrop, status band, panel Coming soon | `source` (required, the SVG source), `alt`, `width`, `height`; no children |

What some properties do:

| Property | What it does |
| - | - |
| `<Box width="50%">` | Takes a percentage of the parent's width |
| `<Box shrink={false}>` | Keeps its own size when a row runs out of room |
| `<Box scrollX>` | Scrolls horizontally when its content is wider than it is |
| `<Box paddingX="2" paddingY="1">` | Sets horizontal or vertical padding on its own, overriding `padding` |
| `<Text mono>` | Monospace font at the same size |
| `<Text tabular>` | Fixed-width digits, for numbers that line up or change in place |
| `<Text maxLines={2}>` | Truncates after this many lines; takes precedence over `truncate` |
| `<Markdown dim>` | Body text (including quotes, list markers, table headers, and inline code) uses the secondary tone; code blocks keep their colors |
| `<Code wrap>` | Fixes whether this code wraps and hides the wrap toggle; without it, the user's own setting applies |
| `<Input rows={4}>` | 2 or more is a fixed-height multi-line input that scrolls inside. With `onSubmit`, `Enter`, `Cmd+Enter`, and `Ctrl+Enter` submit, and `Shift+Enter` adds a new line |
| `<Input submitLabel="Send">` | With `onSubmit`, shows a submit button that does the same as pressing `Enter` |
| `<Progress label="Sync" value={0.4} />` | With `value`, draws a progress bar and a number; without `value`, draws a task in progress (a spinner with text) |
| `<Button role="dismiss" label="Close">` | Coming soon Draws as a compact `×` button at the end of its row, with `label` as the name screen readers read. `onPress` runs as usual, so change `ctx.state` in it to hide the row |
| `<Link href="https://…">Docs</Link>` | Shows the child text, or `label` when there's none, or the address when there's neither. A click follows the user's link-opening setting, and `Cmd` / `Ctrl` click opens the system browser |
| `<Svg source={…} alt="" />` | Draws the SVG as an image. `<style>`, CSS animations, and SMIL animations all work. On the backdrop, animations are removed when the user turns on reduced motion |

Property values:

| Property | Allowed values |
| - | - |
| Spacing (`gap`, `padding`) | `1`, `1.5`, `2`, `3`, `4`, `5`, `6` |
| Font size (`size`) | `xs`, `sm`, `base`, `lg` |
| Font weight (`weight`) | `default`, `medium`, `semibold` |
| Tone (`tone`, `background`) | `primary`, `secondary`, `tertiary`, `accent`, `danger`, `success`, `warning` |
| Color (`tone` and `background` on `<Text>`, `background` on `<Box>`, `tone` on `<Progress>`) | The tones above, or a hex color: `#rgb`, `#rgba`, `#rrggbb`, `#rrggbbaa`. Tones follow light and dark mode; hex colors draw as written in both modes. `hover.background` on `<Box>` and `tone` on `<Button>` and `<Tag>` accept only tones |
| Width (`width` on `<Box>`) | An integer percentage, `"1%"` to `"100%"` |
| Lines (`maxLines` on `<Text>`) | An integer, 1 to 100 |
| Lines (`rows` on `<Input>`) | An integer, 1 to 12, default 1 |
| `submitLabel` on `<Input>` | Not blank, at most 64 characters; shown only with `onSubmit` |
| `label`, `valueText` on `<Progress>` | `label` is not blank, at most 256 characters; `valueText` is at most 256 characters, such as `"412 / 900"` |
| `value`, `max` on `<Progress>` | `max` defaults to 1, so `value: 0.4` is 40%. A progress bar is drawn when `value` and `max` are both finite and `max` is greater than 0. Without `valueText`, it shows an integer percentage, and shows 0% or 100% only exactly at the ends (below 0 shows 0%, above `max` shows 100%); values in between show 1% to 99%. When `value` is missing, `NaN`, or infinite, or `max` is 0 or less, it draws a task in progress |
| `href` on `<Link>` | At most 2048 characters. It opens only for `https:` addresses, or `http://localhost` on any port, with no username or password; other addresses show as plain text, with no error. Links in `<Markdown>` follow the same rule |
| Corner radius (`radius`) | `sm`, `md`, `lg`, `full` |
| Alignment (`align`) | `start`, `center`, `end`, `stretch` |
| Distribution (`justify`) | `start`, `center`, `end`, `between` |

For which values combine well on screen, see [Design rules](https://agent.minimax.io/docs/extension/interface.md#design-rules). There are 33 button icons. See [Icons](https://agent.minimax.io/docs/extension/interface.md#icons). For how to write `<Svg>` and its values, see [Backdrop](https://agent.minimax.io/docs/extension/interface.md#backdrop) and [Limits](#limits) below.

## Testing API

Test files import these functions from `@minimax/mcode-plugin-extension/testing`. See [Write tests](https://agent.minimax.io/docs/extension/testing.md#write-tests).

| API | What it does | See |
| - | - | - |
| `test(name, fn)` | Defines a test. A single test can run up to 10 seconds | [Write tests](https://agent.minimax.io/docs/extension/testing.md#write-tests) |
| `mount(options)` | Loads the module in the real extension host, draws one site, and returns `site` | [Load a site](https://agent.minimax.io/docs/extension/testing.md#mount) |
| `find(site, query)`, `findAll(site, query)` | Finds the first or every matching element; returns `{ node, path }` | [Find elements and press buttons](https://agent.minimax.io/docs/extension/testing.md#find-press) |
| `press(site, target?, value?)` | Runs the element's callback and returns after the redraw finishes | [Find elements and press buttons](https://agent.minimax.io/docs/extension/testing.md#find-press) |
| `waitFor(assertion, { timeoutMs? })` | Runs the assertion repeatedly until it passes | [Find elements and press buttons](https://agent.minimax.io/docs/extension/testing.md#find-press) |
| `unmount(site)` | Ends this load | [Find elements and press buttons](https://agent.minimax.io/docs/extension/testing.md#find-press) |
| `completeAgent(site, { agentId, answer, reason? })` | Simulates a sub-agent finishing and sends `turn.complete` | [Test sub-agents](https://agent.minimax.io/docs/extension/testing.md#agent-test) |
| `runCommand(site, name, args?)` | Runs a command as if the user typed `/<name> <args>`, and returns the answer `{ text }`; fails with codes such as `COMMAND_UNHANDLED`, `COMMAND_FAILED`, and `COMMAND_UNKNOWN` | [Test commands](https://agent.minimax.io/docs/extension/testing.md#command-test) |
| `listCommands(site)` | Returns the list `ctx.command.list()` would return | [Test commands](https://agent.minimax.io/docs/extension/testing.md#command-test) |
| `expect(actual)` | Assertions: `toBe`, `toEqual`, `toBeTruthy`, `toBeDefined`, `toContain`, `toMatch`; add `.not` to negate | [Check the results](https://agent.minimax.io/docs/extension/testing.md#results) |
| `site.slot`, `site.key` | The loaded site (`slot`) and its full key | [Load a site](https://agent.minimax.io/docs/extension/testing.md#mount) |
| `site.tree()` | The element tree on the current screen | [Find elements and press buttons](https://agent.minimax.io/docs/extension/testing.md#find-press) |
| `site.state()`, `site.effects`, `site.diagnostics` | The current `ctx.state`, the effects sent to the UI (including `theme.set` and `theme.clear`), and diagnostics | [Check the results](https://agent.minimax.io/docs/extension/testing.md#results) |
| `site.advance(ms)` | Advances the fake clock and fires due timers | [Answer for the host: fakes](https://agent.minimax.io/docs/extension/testing.md#fakes) |

## Limits

| Item | Limit |
| - | - |
| Own time of one hook, press, or observe event Invocation | 10 seconds (`EXTENSION_HOOK_EXPIRED`); synchronous code 2 seconds (`timeout`) |
| Total time of one draw | 30 seconds (`EXTENSION_RENDER_DEADLINE`) |
| Consecutive failures before a pause | 3 (`EXTENSION_DISABLED`), current session only |
| `ctx.clock` interval | At least 1000 ms |
| `ctx.ui.toast` | 6 per plugin per minute (`toast.dropped`); text truncated past 500 characters |
| `ctx.mcp.call` | 60 calls per plugin per minute (`MCP_CALL_RATE_LIMITED`) |
| Queued button actions and commands / observe events | One queue each per plugin in each session, 10 / 32 (including the one running). Button actions and commands share the first queue. While an earlier hook is still running, later ones queue. Past the limit, the newest button action is rejected (`GESTURE_QUEUE_FULL`, and the UI asks the user to try again later), the newest command is rejected with `COMMAND_BUSY`, and the newest observe event is dropped, with a `GESTURE_QUEUE_FULL` entry in `inspect.runtime.diagnostics` |
| Panels one plugin opens in a session | 16; opening more reports `ARGUMENT_INVALID` |
| Panel `id` / title | `id` up to 200 characters; titles truncated past 200 characters |
| Status band height | About 12 lines; scrolls vertically inside when taller |
| Status band design budget (recommended) | 1 line per plugin, 2 at most; at most 3 buttons; short lists at most 3 items |
| Element tree | At most 5000 nodes, 24 levels deep, 200 KB, 10 000 characters per text run |
| `ctx.prompt.suggest` | One line of text, non-empty after trimming whitespace, at most 120 characters (whitespace counts), or you get `ARGUMENT_INVALID` |
| `ctx.prompt.fill` | Text up to 100 000 characters |
| `ctx.prompt.read`, `suggest` waiting for the message box | 2 seconds |
| `ctx.model.complete` | `maxTokens` defaults to 1024 and can't exceed the model's output limit (64000 at most); `timeoutMs` has no default, maximum 2147483647 |
| `ctx.agent.spawn` | `description` up to 50 characters; running sub-agents can't exceed the session's sub-agent limit (`AGENT_CONCURRENCY_LIMIT`) |
| Sub-agent `answer` | Up to 32 KB, truncated past that with `answerTruncated: true`; `turn.complete` can arrive up to 10 seconds late |
| `ctx.state` | At most 256 keys; keys use letters, digits, and `_ $ . -`, 1 to 128 characters; 64 KB per value, 1 MB total per session, or you get `ARGUMENT_INVALID` |
| `ctx.store` | 256 KB per value, 8 MB total per plugin. Past a limit, `ctx.store.set` throws `EXTENSION_SERVICE_FAILED`, and `message` names the limit |
| `ctx.store` keys | Must match `^[A-Za-z0-9._-]{1,128}$` and be something other than `.` or `..`. An invalid key gives the extension `EXTENSION_SERVICE_FAILED` |
| `console` output | 200 lines per plugin per minute (`console.dropped`) |
| Command name (`name` in `ctx.command.register`) | A string literal matching `^[A-Za-z0-9_-]{1,64}$`, without `/`, compared case-insensitively. It can't be a built-in command (`advisor`, `btw`, `clear`, `cloud`, `compact`, `fork`, `goal`, `mcp`, `memory`, `new`, `new-bunny`, `plan`, `review`, `sidechat`, `turn-to-session`), and can't match a Skill or a plugin command registered earlier. When `test` and `preview` validate the package, a name that breaks the rule or is a built-in command gives `EXTENSION_COMMAND_NAME_INVALID`. At run time, `register` gives `COMMAND_NAME_RESERVED` for a name a built-in command or a Skill holds, and `COMMAND_NAME_TAKEN` for a name another plugin's command holds |
| Command `description` / `argumentHint` | 1 to 200 characters / 1 to 64 characters; longer values are rejected (`ARGUMENT_INVALID`), not truncated |
| Number of commands | At most 32 plugin commands per session; at most 64 `register` calls that change commands per Activation. Repeating an identical registration and rejected registrations don't count. Past either limit, `register` gives `COMMAND_LIMIT_REACHED` |
| Command `args` (`e.args`) | At most 4096 characters after trimming leading and trailing whitespace, also in `runCommand` in tests (`COMMAND_ARGS_TOO_LONG`) |
| `text` in a `command.run` answer | At most 500 characters, truncated past that (`COMMAND_TEXT_TRUNCATED`); doesn't count toward the `ctx.ui.toast` limit |
| Wait time for one command | 15 seconds, including time in the queue (`COMMAND_TIMEOUT`) |
| `source` on `<Svg>` | Not blank, at most 131 072 characters (measured by JS `String.length`); it also counts toward the 200 KB element tree limit |
| `width`, `height` on `<Svg>` | CSS pixels, finite, greater than 0, at most 4096. When absent: on the backdrop, fills the area in that direction; in the status band and panels, the image shows at its own size, and without `width` its width fits the content |
| One `<Svg>` image on the backdrop | At most 5000 nodes (elements and text, plus the elements each `<use>` copies); at most 16 elements in one `marker`, and no `marker` inside a `marker`; a `<use>` can't point to another `<use>` or to an element containing a `<use>` (`EXTENSION_SVG_REFUSED`) |
| Theme `backdrop` | `scene`: 1 to 64 characters, required; `blur`: 0 to 30, default 0; `dim`: 0 to 100, default 22 |
| Theme `backdrop.glass` | `{ blur?, tint?, opacity? }` or `false` (no reading surface under the reply area). `blur`: 0 to 30 pixels, default 8; `tint`: a hex color, defaults to the panel color; `opacity`: 0 to 1, defaults to the color's own alpha |
| Theme `colors` | One set of anchor colors, or `{ light?, dark? }` split by mode (at least one). Each set has 2 to 7 anchors: `surface-0` and `text-primary` are required; `surface-1`, `text-secondary`, `text-tertiary`, `accent`, and `border` are optional. Colors are hex: `#rgb`, `#rgba`, `#rrggbb`, `#rrggbbaa`. Mixing anchors with modes, unknown keys, and empty objects all report `ARGUMENT_INVALID` |
| Theme contrast | Computed from the colors you wrote. If a text anchor is below 3:1 against a surface anchor in the same set, the whole set is rejected (`THEME_PALETTE_REJECTED`). At 3:1 or more it's accepted, and text colors below 4.5:1 are darkened or lightened to get as close to 4.5:1 as possible, with a `THEME_PALETTE_ADJUSTED` record |
| A single test | 10 seconds |

## Next steps

> [card] [Diagnostic codes](https://agent.minimax.io/docs/extension/errors.md)
>
> What each diagnostic code means and how to fix it.

> [card] [Write your first extension](https://agent.minimax.io/docs/extension/quickstart.md)
>
> The full flow from init to install.

> [card] [Test and troubleshoot](https://agent.minimax.io/docs/extension/testing.md)
>
> Write tests, read inspect, troubleshoot by symptom.
