# Trae adapter

Shows the sessions of the agent of Trae, the IDE `Trae.app`, in the notch: working, done when a task ends, needing you while Trae waits for a confirmation, an answer, a review of a document or something in its browser, what the tool in use does, its first prompt, its repository and its branch as its name, and its tool calls as steps.
Trae reports through hooks: each hook posts its event with `curl` to a Unix socket in your own folder, `~/Library/Application Support/Blossom/trae/socket`, where this adapter listens. Blossom launches the adapter.
The hooks of Trae take the format of those of Claude Code, with no transcript in their payload and the names of its own tools in `tool_name`, such as `RunCommand`, so this adapter reads them with the same code of the SDK as the Claude Code adapter, through a dialect of its own.
The hooks are an entry `hooks` of your global hooks of Trae, `~/.trae/hooks.json`, added after yours. The hooks of a project, `.trae/hooks.json` in its folder, are never touched.

**Permissions are answered in Trae, not in Blossom.** Trae has no `PermissionRequest` event. The hook that can decide a call, `PreToolUse`, runs on every call, also on those Trae would not ask about, and its documentation says an `allow` does not skip the confirmation of a tool that asks for one, so no hook can approve only what Trae was going to ask. Blossom shows that the session needs you, from the notification Trae sends while it waits, and you answer in Trae.

**This adapter was written from the documentation of Trae and was never run against a real one.** What the documentation says and what is only supposed is in [../../documentation/roadmap/trae.md](../../documentation/roadmap/trae.md); the checks at the end say what to look at.

You need:

- Blossom. It includes this adapter and the Bun that runs it; from a clone, `bun run build` makes one.
- Trae, `Trae.app` in `/Applications` or `~/Applications`, signed in. The hooks follow the pages [Hook configuration reference](https://docs.trae.ai/ide/hook-configuration-reference) and [Automate actions with hooks](https://docs.trae.ai/ide/automate-actions-with-hooks), read on 3 December 2026.
- **Hooks run locally.** In Trae, Settings > Hooks: the global hooks turned on, and the execution mode **Run Automatically Locally**. In the other mode, Run in Sandbox, the documentation says the sandbox restricts file access and system permissions, so a hook may not reach the socket of Blossom: the session then never shows, and nothing else breaks, since a hook that cannot post prints nothing and exits 0.
- `curl` and `ps`, which every hook runs by their full paths under `/usr/bin` and `/bin`. The documentation says Trae runs a hook with Bash on macOS; the hooks were tested with `sh`, `bash` and `zsh`.

## Connect from Blossom

The quickest way. Blossom finds `Trae.app` in `/Applications` or `~/Applications`, and connecting it is one click: "Continue" on the second step of the introduction, with Trae checked, or its switch in Settings > Agents. Blossom then adds this adapter to its configuration, starts it, and puts the hooks of `adapters/trae/hooks.json` in `~/.trae/hooks.json`, after the hooks you already have, as it does for Claude Code. Nothing of yours changes, `"version": 1` included, and a file that does not exist is created with the hooks alone, which Trae reads as version 1, its default.

Before it writes over the file, Blossom keeps a copy of it in `~/Library/Application Support/Blossom/backups/trae/`, named after the moment in UTC, and puts the new content in place in one rename. A file that is not plain JSON is left alone and the row says why. "Repair" puts the hooks back when they are missing or not the ones this Blossom installs. "Disconnect", shown while the agent is off, takes the adapter out of Blossom and its hooks out of the file, which then holds what it held before. What Blossom writes and why is in [the decision](../../documentation/decisions/connecting.md).

Then open Settings > Hooks in Trae, turn the global hooks on if they are off, and choose Run Automatically Locally; the row of the agent in Settings > Agents says so. Whether Trae reads a changed file at once or at its next start is not documented: if a new session does not show, quit Trae and open it again.

## Run Blossom with the adapter

From the root of the clone:

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

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

An app opened from Finder reads `~/Library/Application Support/Blossom/configuration.json`; name the adapter there by its package, `{ "adapters": [{ "package": "trae" }] }`.

## What you should see

- Nothing when the session opens. The tile appears next to the notch with the first prompt, with the mark of Trae, named after the first line of that prompt and the repository of the folder of the workspace, with its branch beside it.
- No badge while it works, and the tool in use in live.
- The amber badge, and no panel, while Trae waits for you: a confirmation of a tool, a question it asks, the review of a plan or a spec, or something in its browser. Answer in Trae.
- The green badge when the agent ends its answer or Trae says the task is complete.
- The tile gone when Trae quits.

## Install by hand

For a clone without the app. The `hooks` of `adapters/trae/hooks.json` go into your `~/.trae/hooks.json`, next to the hooks you have; the merge of [the Claude Code adapter](../claude/README.md#install-by-hand) does it, with `~/.trae/hooks.json` and `adapters/trae/hooks.json` in place of the files of Claude Code. Then turn the hooks on and choose the local mode, as above.

## Remove by hand

After an install by hand; after connecting from Blossom, Disconnect does it, and removing Blossom takes out the hooks of every tool, see [Removing it](../../documentation/privacy.md#removing-it). The `jq` command of [the Claude Code adapter](../claude/README.md#remove-by-hand) does it, with `~/.trae/hooks.json` and `Blossom/trae/socket`. Then check that nothing is left; this prints `0`:

```sh
grep -c 'Blossom/trae/socket' ~/.trae/hooks.json
```

## What to know

- **Needing you comes from a notification.** A `Notification` of `permission_prompt`, `ask_user_question`, `document_review` or `browser_interaction` makes the session need you until its next event. One of `idle_prompt`, which Trae sends when the agent completes a task, makes it done, as `Stop` does. Trae sends its notifications without waiting for the hook, so one may reach Blossom after the event that follows it.
- **A session shows up with its first prompt.** `SessionStart` is not installed. Trae has no `SessionEnd`: a session leaves when the process that runs its hooks ends.
- **The name and the steps** follow the Claude Code adapter: the first line of the first prompt, the repository and the branch of the folder Trae gives a hook, the root of the first folder of the workspace; one step per tool call, paired by `tool_use_id`, saying what it does and never what it holds. The documentation names the tools but not the fields of most of their inputs, so a step is a label, such as `Running a command` for `RunCommand` or `Writing a file` for `Write`, without the name of the file. A call whose `PostToolUse` never comes fails when the turn ends. Trae reports no subagents.
- **The terminal of a session.** The hook of `UserPromptSubmit` runs the shell of the SDK that finds the terminal of a session. A hook of Trae runs outside any terminal, so it finds no terminal device: it sends the processes above the hook and, when Trae passes it on, the bundle identifier of the app. A jump to such a session can at most bring Trae forward.
- **The hooks send the whole payload, and the adapter keeps a few fields.** Each hook posts the payload as Trae gives it on standard input, your prompt and the input and output of tools included. The adapter keeps the identifier of the session, the title taken from the first line of the prompt, the name of the tool and the words of its step, the folder and the type of a notification. Nothing else is kept, logged or sent to Blossom.
- **The hooks print nothing and decide nothing.** Every hook sends what `curl` receives to `/dev/null`, and every command ends with `|| /usr/bin/true`, so a hook never fails, never exits 2, which blocks a prompt or a call, and prints no JSON or text, which Trae would read as a decision or add to the context of the model. With Blossom closed, each hook gives up at once and Trae works as before. The documentation gives a hook thirty seconds; these end within one.
- **A session whose Trae was quit or killed leaves within seconds.** Every command names the parent of its shell, which is supposed to be a process of Trae that lives as long as it does, in the header `Blossom-Process`, and every five seconds the adapter asks whether it still exists.
- **The hooks name `$HOME` and nothing else without a default**, and ignore your curl configuration with `-q`.
- **Trae can also run the hooks of Claude Code**, once you turn on "Import Hook configuration in CLAUDE" in its Settings > Hooks. Those hooks end at once when `TRAE_PROJECT_DIR`, which Trae sets for every hook, has a value, so a session of Trae is not counted as one of Claude Code too; a test runs both sets as Trae would.
- **Trae CN and TRAE CLI are not covered.** Trae CN keeps its files in `~/.trae-cn`, and TRAE CLI documents no file of hooks.
- **The socket is yours alone.** See [../../documentation/decisions/socket.md](../../documentation/decisions/socket.md).

### Not confirmed

Read in the documentation, never seen in a run:

1. That the global hooks are on for a `~/.trae/hooks.json` that Blossom created, without a step in Settings > Hooks.
2. That Trae reads a changed `~/.trae/hooks.json` without a restart.
3. That the parent of the shell of a hook is a process of Trae that lives as long as Trae, the same on every event of a session.
4. That a hook in Run Automatically Locally reaches a socket in `~/Library/Application Support`, and that one in Run in Sandbox does not.
5. That `TRAE_PROJECT_DIR` is set for a hook imported from Claude Code too.
6. That `Trae.app` is the name of the app in `/Applications`, which the cask of Homebrew installs; the documentation names no folder.

## Checks by hand

The adapter was tested with its hook commands run by `sh`, `bash` and `zsh` against the socket, with payloads written from the documentation, never captured from a run. Each check needs Trae signed in, connected from Blossom with its hooks on in Run Automatically Locally, and Blossom running with the adapter. Write down what the line in italics asks.

1. **A turn.** In a folder, ask the agent `hi`. *Does the tile appear with the prompt, with no badge, and turn green when the answer ends?*
2. **A confirmation.** With commands set to ask, ask `run the command touch probe.txt`. *Does the tile turn amber, with no panel, while Trae asks, and does the badge leave once you answer there?*
3. **A question.** Ask for something unclear enough that the agent asks back. *Does the tile turn amber?*
4. **The sandbox.** Choose Run in Sandbox and ask `hi` in a new session. *Does the session show? Does Trae report a failed hook in its Agent Hooks logs?*
5. **The import.** Turn on the import of the hooks of Claude Code with Blossom connected to both. *Does a session of Trae show once, as Trae?*
6. **The end.** Quit Trae. *Does the tile leave within about five seconds?*
