# MiMoCode adapter

Shows the sessions of MiMoCode, the coding agent `mimo` of Xiaomi, a fork of OpenCode, in the notch: working, done when a turn ends, needing you while it waits for a permission or an answer to a question, what the tool in use does, its first prompt, its repository and its branch as its name, and its tool calls as steps. Nothing is answered from Blossom.
MiMoCode has no hooks of the shell. It loads plugins in TypeScript into its own process. Blossom installs one of its own, `~/.config/mimocode/plugins/blossom.ts`, a copy of [`plugin.ts`](plugin.ts), which posts a few fields of the events of MiMoCode to a Unix socket in your own folder, `~/Library/Application Support/Blossom/mimo/socket`, where this adapter listens. Blossom launches the adapter.

**This adapter was written from the source of MiMoCode and was never run against a real one.** What the source says and what is only supposed is in [../../documentation/roadmap/mimo.md](../../documentation/roadmap/mimo.md); the checks at the end say what to look at. Why Blossom installs a module, and what it may and may not do, is in [the decision](../../documentation/decisions/module.md).

You need:

- Blossom. It includes this adapter and the Bun that runs it; from a clone, `bun run build` makes one.
- MiMoCode, `mimo`. The plugin follows the source of [XiaomiMiMo/MiMo-Code](https://github.com/XiaomiMiMo/MiMo-Code) at commit `a2ad358ac6612a567240e143124b32978f31ebd6` of 30 November 2026, its version 0.1.18.

## Connect from Blossom

The quickest way. Blossom finds `mimo` in your `PATH` or in the usual folders, and connecting it is one click: "Continue" on the second step of the introduction, with MiMoCode checked, or its switch in Settings > Agents. Blossom then adds this adapter to its configuration, starts it, and writes `~/.config/mimocode/plugins/blossom.ts`, readable by you alone, creating the folders it needs. No file of yours is changed: your configuration and your other plugins stay as they are.

"Repair" in the row writes the plugin again when it is missing, when you changed it or when an update of Blossom brings another one; it keeps a copy of the file it replaces in `~/Library/Application Support/Blossom/backups/mimo/`. "Disconnect", shown while the agent is off, takes the adapter out of Blossom and deletes `blossom.ts`, after the same copy. A file named `blossom.ts` there that is not Blossom's, because it does not name the socket, is left alone and the row says so. Blossom does not follow `MIMOCODE_HOME` or `XDG_CONFIG_HOME`: a MiMoCode that uses another folder does not load the plugin. `MIMOCODE_PURE` turns every plugin off, this one included.

MiMoCode loads its plugins when it starts. A MiMoCode that was open when you connected reports from its next start.

## Run Blossom with the adapter

From the root of the clone:

```sh
bun install && bun run bootstrap && bun run build
BLOSSOM_CONFIGURATION=adapters/mimo/configuration.json apps/macos/build/Build/Products/Debug/Blossom.app/Contents/MacOS/Blossom
```

The notch shows nothing until a session of MiMoCode reports. Run one Blossom at a time: the adapter holds the socket, and the adapter of a second Blossom logs `cannot listen for the plugin of mimocode` and exits.

### From Finder

An app opened from Finder reads `~/Library/Application Support/Blossom/configuration.json`. Name the adapter by its package:

```json
{ "adapters": [{ "package": "mimo" }] }
```

## Install by hand

For a clone without the app:

```sh
mkdir -p ~/.config/mimocode/plugins
cp adapters/mimo/plugin.ts ~/.config/mimocode/plugins/blossom.ts
```

## Remove by hand

After an install by hand; after connecting from Blossom, Disconnect does it, and removing Blossom deletes the plugin, see [Removing it](../../documentation/privacy.md#removing-it).

```sh
rm ~/.config/mimocode/plugins/blossom.ts
```

## What to know

- **Why a plugin, and not a client of its server.** Blossom reaches OpenCode 2 through the background service it shares between its clients. MiMoCode forked OpenCode 1, which has no such service: its terminal opens a server on the loopback with a password it draws at random, keeps in memory and never writes anywhere, so nothing outside the process can use it unless you start MiMoCode with `MIMOCODE_SERVER_PASSWORD` or with `mimo serve`. A plugin sees every session of a `mimo` started as usual. So the adapter shares no code with the one of OpenCode.
- **Permissions and questions are answered in MiMoCode.** Between `permission.asked` and `permission.replied`, and between `question.asked` and its answer or its dismissal, the session needs you, a subagent's included. Its hook `permission.ask` is declared and never called in the source, and answering through the client a plugin is given would act with the credential of MiMoCode, so the plugin answers nothing.
- **What the plugin does.** It returns two hooks and no other: `event`, which MiMoCode calls for every event of its bus without waiting for it, and `chat.message`, which it calls when a message of yours is created and waits for. Both return at once with nothing and change nothing; the posts go one after the other in the background, one second each at most. With Blossom closed, every post fails at once and MiMoCode notices nothing. Every hook runs inside `try`: one that throws in `event` would stop MiMoCode from telling its plugins anything more, and one that throws in `chat.message` would fail the prompt. It imports `node:http` alone, reads no file, logs nothing, runs no command and never uses the client MiMoCode gives a plugin. Listening to these hooks changes nothing in MiMoCode.
- **What it sends.** The identifier of the session, the folder MiMoCode runs in and its process with every event; the first 4096 characters of the first text you typed in a message, never a part MiMoCode adds itself; the identifier of a call, the name of its tool, `file_path` of its arguments and whether it failed; the identifier of a permission and its kind, such as `bash` or `edit`, or of a question. Never a command, a pattern of a permission, the content of a file, what a tool printed or an answer of the model. The adapter keeps the title, the name of the tool and the words of its step, and the folder.
- **A session shows up with its first prompt.** A message of yours, or `session.status` busy, starts a session. The title is the first line of the first prompt, cut to 60 characters; a prompt that starts with `/` or `!` titles nothing.
- **Steps are tool calls.** A call is a step from the first update of its part that says `running` to the one that says `completed` or `error`. `read`, `edit`, `multiedit` and `write` show the name of their file without its folder; `bash` shows "Running a command"; the others a label. A step still running when the turn ends is shown failed.
- **How a turn ends.** `session.status` idle ends it, and busy starts it again; `retry` and `notice` change nothing.
- **Subagents are part of their session.** A session MiMoCode creates with a parent is a subagent's: it never shows as a session, and its permissions and questions make the session you started need you.
- **How a session ends.** `session.deleted` closes it. A session whose `mimo` quit or was killed leaves within five seconds.
- **The terminal of a session.** With each message of yours, the plugin sends the variables a terminal sets and the processes of MiMoCode and of its parent; the adapter reads its terminal device with `/bin/ps` and checks every value as it checks those of a hook.
- **The socket is yours alone.** A process that runs as you can still post to it or listen on it while Blossom is closed. See [../../documentation/decisions/socket.md](../../documentation/decisions/socket.md).
- **Sixty-four sessions at most.** When a sixty-fifth starts, the adapter closes the one it heard from least recently.

### Not confirmed

Read in the source, never seen in a run:

1. That MiMoCode loads `~/.config/mimocode/plugins/blossom.ts` as a plugin whose default export is a function, and that `node:http` reaches a Unix socket from it.
2. That its interactive `mimo` runs its plugins in its own process, the one in the terminal.
3. That every update of a tool part reaches the event hook, `running` before `completed`.
4. That a subagent's session is created with `parentID` before it does anything.

## Checks by hand

The plugin was loaded into a double of the plugin API of MiMoCode, written from its source, and its posts reached the adapter through a real socket; it never ran inside MiMoCode. Each check below needs `mimo` with a provider.

1. **It loads.** Connect MiMoCode from Blossom and start `mimo` in a new folder. *Does it start with no error about a plugin?*
2. **A turn.** Ask `hi`. *Does the tile appear, titled `hi` and named after the folder, and turn green when the answer ends?*
3. **A tool.** Ask `read the file package.json`. *Does detail list `Read package.json` as a step, once?*
4. **A permission.** With a configuration that asks before running commands, ask `run the shell command ls`. *Does the tile turn amber until you answer in MiMoCode?*
5. **A subagent.** Ask for a task that delegates to a subagent. *Does one tile stay, with no second tile?*
6. **The end.** Quit `mimo`. *Does the tile leave?*
7. **Without Blossom.** Quit Blossom and ask `hi`. *Does MiMoCode answer as before?*
8. **Disconnect.** Disconnect MiMoCode in Settings > Agents. *Is `~/.config/mimocode/plugins/blossom.ts` gone, and your other plugins still there?*
