# ZCode adapter

Shows the sessions of ZCode, the desktop app of Z.ai and its command `zcode`, in the notch, and lets you answer its permission requests from Blossom: working, done when a turn ends, what the tool in use does, its first prompt, its repository and its branch as its name, and its tool calls as steps.
ZCode reports through hooks: each hook posts its event with `curl` to a Unix socket in your own folder, `~/Library/Application Support/Blossom/zcode/socket`, where this adapter listens. Blossom launches the adapter.
The hooks of ZCode take the payload and the answers of the hooks of Claude Code, so this adapter reads them with the same code of the SDK as the Claude Code adapter. Its configuration differs: the events sit under `hooks.events`, and the hooks run only while `hooks.enabled` is `true`.
The hooks are in your configuration of ZCode, `~/.zcode/cli/config.json`, after yours. The configuration of a workspace, `<project>/.zcode/config.json` or `<project>/zcode.json`, and the hooks of plugins are never touched.

**This adapter was written from the documentation of ZCode and was never run against a real one.** What the documentation says and what is only supposed is in [../../documentation/roadmap/zcode.md](../../documentation/roadmap/zcode.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.
- ZCode, with its command `zcode` in your `PATH` or the usual folders, which is how Blossom finds it. The hooks follow the page [Hooks](https://zcode.z.ai/en/docs/hooks), read on 2 December 2026.
- `curl` and `ps`, which every hook runs by their full paths under `/usr/bin` and `/bin`. ZCode passes a hook of the runner `command` to the shell of the system; the hooks were tested with `sh`, `bash` and `zsh`.

## Connect from Blossom

The quickest way. Blossom finds `zcode` on your Mac, and connecting it is one click: "Continue" on the second step of the introduction, with ZCode checked, or its switch in Settings > Agents. Blossom then adds this adapter to its configuration, starts it, and puts the hooks of `adapters/zcode/config.json` in `~/.zcode/cli/config.json`: its groups go under `hooks.events`, after the groups you have for the same event, and `"enabled": true` goes into `hooks` when it is missing, as the page asks of a configuration edited by hand. Nothing else of yours changes, and a file that does not exist is created with the hooks alone.

Before it writes over the file, Blossom keeps a copy of it in `~/Library/Application Support/Blossom/backups/zcode/`, 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. **A file whose `hooks.enabled` is `false` is left alone too**: you turned the hooks of ZCode off, and the row says that its configuration turns its hooks off; Blossom does not turn them on. Blossom does not change `timeoutMs` or `maxOutputBytes`. "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; it takes out `events` when nothing of yours is left in it, and `"enabled": true` only when nothing else is left in `hooks`, so a file Blossom created or found without `hooks` comes back as it was. What Blossom writes and why is in [the decision](../../documentation/decisions/connecting.md).

The page says each session reads the hooks once, when it starts: a session open while you connect reports after `/reload`, or from the next session.

## Run Blossom with the adapter

From the root of the clone:

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

The notch shows nothing until a session of ZCode 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 zcode` and exits.

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

## What you should see

- Nothing when the session opens. The tile appears next to the notch with the first prompt, in initials, named after the first line of that prompt and the repository, with its branch beside it.
- No badge while it works, and the tool in use in live.
- A permission request in the request panel when ZCode needs your confirmation before a tool: what it wants to run, with Allow and Reject. For `Write` it also carries the path and the content of the file, which the panel shows unless "Show what a request would do" is off.
- The green badge when a turn ends.
- The tile gone within seconds of the end of the process that ran the hooks of the session.

## Install by hand

For a clone without the app. With `jq`, write the merged configuration to a new file, review it, and put it in place:

```sh
jq -n --slurpfile user ~/.zcode/cli/config.json --slurpfile blossom adapters/zcode/config.json '
  ($user[0] // {}) | .hooks.enabled //= true | .hooks.events = reduce ($blossom[0].hooks.events | to_entries[]) as $event
    (.hooks.events // {}; .[$event.key] += $event.value)
' > ~/.zcode/cli/config.merged.json
```

If `~/.zcode/cli/config.json` does not exist, copy `adapters/zcode/config.json` there instead. A configuration whose `hooks.enabled` is `false` gets the hooks but does not run them.

## 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). Write the configuration without the hooks of the adapter to a new file, review it and put it in place:

```sh
jq '
  def blossom: (.command // "") | contains("Application Support/Blossom/zcode/socket");
  .hooks.events |= (map_values(map(.hooks |= map(select(blossom | not)) | select(.hooks | length > 0)) | select(length > 0)))
' ~/.zcode/cli/config.json > ~/.zcode/cli/config.cleaned.json
```

Then check that nothing is left; this prints `0`:

```sh
grep -c 'Blossom/zcode/socket' ~/.zcode/cli/config.json
```

## What to know

- **Permissions are answered in Blossom, or in ZCode.** The page says ZCode runs `PermissionRequest` only when a tool needs your confirmation, and reads `hookSpecificOutput.decision.behavior`, `allow` or `deny`, as its answer. Allow answers `allow`; Reject answers `deny` with the message "Rejected in Blossom.". When the hook prints nothing, ZCode goes on as it would without the hook. The rules are those of the Claude Code adapter, with one difference: a request not answered within fifty seconds leaves the panel. ZCode waits 60 seconds for a hook by default; the hook of `PermissionRequest` names its own `timeout` of 55 seconds, the field the page gives in seconds, and gives up at fifty, so it ends before that default even if the timeout of a hook were ignored. Always is offered only when ZCode suggests a rule in the shape of Claude Code, which its page does not show.
- **What a request would do.** The input of `Write`, `file_path` and `content`, is the one the page shows, so it travels with the request. The page shows no other input, so any other tool carries its title alone.
- **A session shows up with its first prompt**, or with a permission request. `SessionStart` is not installed.
- **The name and the steps** follow the Claude Code adapter: the first line of the first prompt, the repository and the branch; one step per tool call of the session, paired by `tool_use_id`, saying what it does and never what it holds: the name of the file of `Write`, and a label for the rest. Subagents are not counted: ZCode sends no event of a subagent.
- **The end of a session.** ZCode sends no event when a session ends. Every command names the parent of its shell, which is supposed to be the process of ZCode that runs the session, in the header `Blossom-Process`, and every five seconds the adapter asks whether it still exists; the tile leaves when it does not. If that process outlives its sessions, as the app itself would, a tile stays until ZCode quits.
- **`transcript_path` is required, never read.** The page says it names a temporary file deleted after the hook. The adapter takes a payload only when it carries `transcript_path` as text, as the code of the SDK does for Claude Code, and never opens it.
- **The terminal of a session.** The hook of `UserPromptSubmit` also finds where the session runs, with the shell of the SDK, and sends it in headers. A session of the app has no terminal device; the hook still sends the application that started it, from `__CFBundleIdentifier`, when ZCode passes it on.
- **The hooks send the whole payload, and the adapter keeps a few fields.** Each hook posts the payload as ZCode gives it on standard input, your prompt and the input of tools included. The adapter keeps the identifier of the session and of the call, the title taken from the first line of the prompt, the name of the tool and the words of its step, the folder, and for a permission request what it would do while it waits. Nothing else is kept, logged or sent to Blossom.
- **The hooks print nothing but the answer to a permission.** Every hook but that of `PermissionRequest` sends what `curl` receives to `/dev/null`, and every command ends with `|| /usr/bin/true`, so a hook never fails and never blocks: it never exits 2, which ZCode reads as a block. With Blossom closed, each hook gives up at once and ZCode works as before.
- **No matcher.** The groups of Blossom have no `matcher`, which the page reads as every tool; an empty `matcher` would keep the whole file from loading.
- **The hooks name `$HOME` and nothing else without a default**, and ignore your curl configuration with `-q`.
- **The hooks of Claude Code.** ZCode lists the hooks of `.claude/settings.json` as Legacy and does not run them unless you import them in its settings. Do not import the hooks Blossom puts there for Claude Code: imported, they would post the sessions of ZCode as sessions of Claude Code, since they carry the transcript Claude Code always sends. The guard of those hooks does not test `ZCODE_SESSION_ID`, which the page says ZCode sets for its hooks: adding it would change the hook of every user of Claude Code and ask each to repair it, for a step only you can take.
- **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 `zcode` is a command on the `PATH` of a Mac with ZCode, which is how Blossom finds it.
2. That the parent of the shell of a hook is a process of ZCode that ends with its session.
3. That the shell of the system that runs a hook of the runner `command` is `sh`, `bash` or `zsh`.
4. That `timeout` of a hook, in seconds, holds against a smaller `timeoutMs` of the whole file.
5. That ZCode does not show its own dialog of confirmation while the hook of `PermissionRequest` waits, or shows it at the same time.
6. That `permission_suggestions` and `updatedPermissions` take the shape of Claude Code.
7. That the user configuration needs no review, which the page asks only of the hooks of a workspace.

## 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 ZCode signed in, connected from Blossom, and Blossom running with the adapter. Write down what the line in italics asks.

1. **A turn.** In a new folder, start a session and ask `hi`. *Does the tile appear with the prompt, with no badge, and turn green when the answer ends?*
2. **A permission.** Ask for a file to be written, with confirmations on. *Does the request panel open with the path and the content, and does ZCode show a dialog of its own at the same time?* Answer Allow. *Is the file written?* Ask again and answer Reject: *is there no file, and does ZCode say it was rejected in Blossom?*
3. **Answering nowhere.** Ask for another write and wait more than a minute. *Does the request leave the panel after fifty seconds, and what does ZCode do then?*
4. **The end.** Close the session, then quit ZCode. *When does the tile leave?*
5. **Turned off.** Turn the hooks off in Settings → Hooks of ZCode. *Does the row of ZCode in Settings > Agents say that its configuration turns its hooks off?*
