> ## 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 overview

> What an extension is, what it can do, how it works, where it runs, and what it can reach.

This page is for developers who want to write their own extensions. It covers the basic concepts and how extensions work. If you just want the Agent to build one for you, see [Plugin Extensions](https://agent.minimax.io/docs/code/agents/extensions.md). For the release status of each capability, see [Capabilities and progress](https://agent.minimax.io/docs/extension/progress.md).

## What an extension is

An extension (full name "plugin extension") is a TypeScript program inside a plugin. It can draw a line or two in the status band, add its own panel to the conversation's side panel, give the conversation its own backdrop and colors, add commands to the `/` menu in the message box, and react to events in the conversation, such as the end of a turn or the Agent calling a tool.

* **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. Its site name in code is `above-prompt`.
* **Panel**: a tab in the conversation's side panel on the right, next to tabs such as Files and Browser. Its site name in code is `pane`.
* **Backdrop** Coming soon: the backdrop behind the conversation in the main window, a layer under all the panels. It replaces the wallpaper while a plugin theme is active. Its site name in code is `backdrop`.

The entry point of an extension is one module file in the plugin, `hooks/register.tsx`. It exports a `register` function, and you register handlers inside it with `on(...)`.

Some terms:

| Term | Meaning |
| - | - |
| hook | In these docs, a hook is a handler registered with `on(...)` in extension code. The `hooks.json` feature that runs commands on events is called command hooks, and these docs don't cover it |
| site | A place where an extension displays content. There are three: `above-prompt` (the status band), `pane` (the panel), and `backdrop` (the backdrop). There's also `above-prompt-list` Coming soon, which arranges the status band's rows across plugins |
| render chain | Several plugins draw the same site in layers. Each plugin is one layer |

> [!NOTE]
>
> Extensions here have nothing to do with "model access extensions" ("My extensions") in usage settings, and they aren't Chrome browser extensions.

## What an extension can do

* Draw a line or two in the status band (`above-prompt`).
* Add its own panel to the side panel (`pane`).
* Coming soon Set a theme for the conversation: draw an SVG picture on the backdrop (`backdrop`), and generate a full palette from a few anchor colors (`ctx.theme`).
* Coming soon Add commands to the `/` menu in the message box (`ctx.command`). A command runs right away when the user picks one without an argument hint from the menu, or types `/command arguments` and presses Enter. The result shows as a notice and isn't sent to the model.
* Observe events: session start, turn start and end, tool calls and results, context usage changes, the user closing the panel.
* Call MCP tools that ship with the plugin or are already configured (`ctx.mcp.call`), and read and write files or access the network through them.
* Save state: session state (`ctx.state`) and data that persists across sessions (`ctx.store`).
* Fill text into the message box, show a gray suggestion, and read the draft (`ctx.prompt`). Sending stays up to the user.
* Run one inference call on the model (`ctx.model.complete`).
* Start a background subagent (`ctx.agent.spawn`).
* Read context usage (`ctx.session.usage()`).
* Show toasts (`ctx.ui.toast`) and set timers with `ctx.clock`.

Observe events run alongside the conversation. A hook doesn't need to return anything, and if it's slow or throws, the turn carries on as usual.

## How extensions work

### File structure

An extension lives in an ordinary plugin package:

```text theme={null}
tool-counter/
├── .minimax-plugin/plugin.json   # "hooks": ["hooks/hooks.json"]; name is the plugin name
├── .minimax-plugin/types/        # Type files for your editor, generated by the host; don't edit
├── hooks/hooks.json              # { "modules": ["./register.tsx"] }
├── hooks/register.tsx            # Extension module: export const register: Register = (on) => { … }
├── hooks/state.ts                # defineState({ … }), declares session state
├── hooks/*.test.tsx              # Tests; the module can't import them
├── <server>.mcp.json             # Optional: an MCP server that ships with the plugin; list it in the manifest's mcpServers
├── tsconfig.json                 # Yours; only extends ./.minimax-plugin/types/tsconfig.json
└── icon.png
```

* `plugin.json` points to `hooks.json` with `"hooks": ["hooks/hooks.json"]`.
* `modules` in `hooks.json` can have only one entry: `"./register.tsx"`.
* The package has no `package.json` and no installed dependencies. A module imports only from files in the package and `@minimax/mcode-plugin-extension` (plus `/ui`, `/jsx-runtime`, and `/jsx-dev-runtime`; tests can also import `/testing`).

### A minimal extension

This is the template the Agent generates when it runs `init` with the `extension` tool and the title `Counter`, written here in JSX. It shows a click count in the status band. When you press the button, the count goes up by one, a toast appears, and some text is filled into the message box.

```ts hooks/state.ts theme={null}
import { defineState } from '@minimax/mcode-plugin-extension';

export const state = defineState({ count: { default: 0 } });

// Tells the editor which keys ctx.state has and what type each one is.
declare module '@minimax/mcode-plugin-extension' {
  interface ExtensionStateRegistry {
    readonly spec: typeof state.spec;
  }
}
```

```tsx hooks/register.tsx theme={null}
import type { Register } from '@minimax/mcode-plugin-extension';
import { Box, Button, Text } from '@minimax/mcode-plugin-extension/ui';

export { state } from './state';

// register runs once, to register hooks.
export const register: Register = (on) => {
  // Draw a row in the status band above the message box.
  on('ui.render', { site: 'above-prompt' }, async (ctx, e, next) => (
    <Box direction="column" gap="1">
      <Box direction="row" gap="2" align="center">
        <Text size="sm">{`Pressed ${ctx.state.get('count')} times`}</Text>
        <Button
          key="counter"
          label="Counter"
          icon="plus"
          onPress={async () => {
            // Writing ctx.state redraws the status band automatically.
            await ctx.state.set('count', ctx.state.get('count') + 1);
            await ctx.ui.toast(`Pressed ${ctx.state.get('count')} times`);
            await ctx.prompt.fill({ text: 'Counter: ' });
          }}
        />
      </Box>
      {/* next() returns what the plugins after you in the render chain drew. */}
      {await next()}
    </Box>
  ));
};
```

### `register(on)`

`register` runs once when the extension loads. You can only call `on()` at its top level: not inside an `if`, a loop, or a callback, and not after an `await`. A matcher (such as `{ site: 'above-prompt' }`) must be an object literal whose values are string literals. Static checks enforce these rules. See [Events](https://agent.minimax.io/docs/extension/events.md).

There are two kinds of hooks:

* `ui.render`: the host calls it when it needs to draw a site, and it returns an element tree.
* Observe events: `session.start`, `turn.start`, `turn.complete`, `tool.call`, `tool.result`, `session.measure`, `ui.close`.

Only hooks receive `ctx`. Callbacks such as a button's `onPress` receive only their own value and use the enclosing hook's `ctx` through a closure. Always write `ctx` out in full (`ctx.state.set(...)`). Don't destructure it or rename it.

### The render chain and `next()`

Each session has one status band, shared by every plugin that draws `above-prompt`. The panel works the same way: every plugin that matches the panel takes part in drawing it. Each plugin is a layer in the render chain, and `await next()` returns what the layers after yours drew.

So put `await next()` in your element tree, usually as the last child of a vertical `Box`. If you leave it out, the plugins after you can't draw, and you get the diagnostic `EXTENSION_SHADOWING`.

Coming soon The status band will be drawn in two steps: each plugin's `above-prompt` draws its own row, independently of the others. Filtering and ordering across plugins move to `above-prompt-list`, where the render chain runs over those rows. Keeping `await next()` in `above-prompt` stays compatible. See [Status band row arrangement](https://agent.minimax.io/docs/extension/interface.md#above-prompt-list).

The host keeps the drawn result and only redraws when a `ctx.state` key read during drawing changes, or after you call `ctx.ui.invalidate()`. See [Interface: sites and elements](https://agent.minimax.io/docs/extension/interface.md).

## Where it runs

Extensions run in the main window of local sessions in the MiniMax Code desktop app. You develop, preview, and use installed extensions there: the status band shows above the message box, and the panel shows in the side panel on the right.

## Choosing between extensions and other features

| Feature | What it is | When to use it |
| - | - | - |
| Extension | A TypeScript module in a plugin that draws a status band and side panel with MiniMax Code's native components, and observes conversation events | You need a lightweight status band, a side panel, or something that happens automatically when a turn ends or a tool is called |
| [Mini App](https://agent.minimax.io/docs/code/agents/mini-apps.md) | An app with a full frontend and backend that opens on the side | You want to design the interface yourself and need a full frontend and backend |
| [Skill](https://agent.minimax.io/docs/code/agents/skills) | Domain knowledge and instructions for the Agent | You want the Agent to work a certain way |
| [MCP](https://agent.minimax.io/docs/code/agents/mcp.md) | Tools for the Agent (and extensions) | You want the Agent to call external systems or local commands; extensions also get data through it |
| command hooks | Commands in `hooks.json` that run on events | Not covered in these docs |

Extensions and MCP often work together: the plugin includes an MCP server that reads and writes data, and the extension calls it with `ctx.mcp.call` and draws the result in the status band or panel.

## What an extension can reach

> [!WARNING]
>
> Extensions run as you. Only install and preview extensions you trust.

| What | Details |
| - | - |
| Conversation content | Observe events include your prompt (`prompt` in `turn.start`), the full input of tool calls (`input` in `tool.call`), and their output (`output` in `tool.result`), with no truncation or redaction. Thinking never appears. The Agent's replies only reach the extension from subagents it started itself |
| MCP tools | `ctx.mcp.call` follows the existing permission rules: if an allow rule exists, the call goes ahead; if a deny rule exists, it fails. When the user needs to be asked, a standard permission card appears and names the plugin that made the call. The card's allow option, "Only this chat", allows only that one call, and the next call asks again. No reply saves a permission rule. An extension in preview doesn't inherit allow rules from the installed version |
| Model calls | `ctx.model.complete` doesn't ask for confirmation and uses the session's account and quota |
| Background subagents | `ctx.agent.spawn` doesn't ask for confirmation. When the subagent calls tools itself, the usual rules for asking still apply. It appears in the Subagents list in the workspace panel |
| MCP servers that ship with the plugin | Servers listed in `mcpServers` start as local processes, the same as servers from other installed plugins |
| Message box | It can fill text into the draft (it never sends for you) and show suggestions. It can read the draft only if its code calls `ctx.prompt.read()` (preview records the call in `calls:` automatically) |
| Files, network, system | Extensions read and write files, access the network, and run local commands through MCP tools. These calls follow the MCP tool permission rules above |
| Appearance | `ctx.theme.set` doesn't ask for confirmation. The plugin's backdrop replaces the user's wallpaper and the plugin's palette (`colors`) replaces the user's color settings. The user's font, density, and contrast settings still apply. When the plugin clears its theme, or is withdrawn, disabled, or uninstalled, the look goes back to how it was |
| Slash commands | `ctx.command.register` doesn't ask for confirmation. A command's arguments are text the user typed, and the plugin should check them before passing them to a model or an MCP tool |

Previewing an extension also needs permission. The first time the Agent runs `preview` in a session, a permission card appears. You can allow it for this chat only, or always allow it.

## How to get an extension

* **Have the Agent write it**: describe what you want in a sentence. The Agent writes the code and previews it, and you install it once you're happy. See [Plugin Extensions](https://agent.minimax.io/docs/code/agents/extensions.md).
* **Write it yourself**: write the code in your editor, then test, preview, and install it through the Agent. See [Write your first extension](https://agent.minimax.io/docs/extension/quickstart.md).
* **Install an official plugin**: official plugins in the plugin marketplace can also include extensions. Once installed, they work in all local sessions.

## Version

These docs cover extension API `0.1.0`. If the type files in `.minimax-plugin/types/` in your plugin package differ from the docs, the type files win.

## Next steps

> [card] [Write your first extension](https://agent.minimax.io/docs/extension/quickstart.md)
>
> Go from init to install and build a status band that shows tool call counts.

> [card] [Interface: sites and elements](https://agent.minimax.io/docs/extension/interface.md)
>
> Rules for the status band and panel, and the elements you can use.

> [card] [Events (hooks)](https://agent.minimax.io/docs/extension/events.md)
>
> `ui.render` and each observe event.

> [card] [Extension API](https://agent.minimax.io/docs/extension/api.md)
>
> State, MCP, the message box, the model, and subagents.
