Skip to content
Crystal CodeDocs
ENEnglish

Bridge

crystal bridge is the third operator surface, beside the terminal and crystal server. An editor that speaks the Agent Client Protocol (ACP), such as Zed, starts it as a subprocess and drives one session over stdin and stdout. It is not crystal server, not crystal run, and not an engine protocol.

Approval, workspace trust, the workspace fence, and tool policy are unchanged. Bridge only carries their questions to the editor and brings the answers back. It listens on no port. Its only peer is the process that started it.

The messages, mappings, and error codes are in Bridge protocol. This page covers starting it and what the editor gets.

Configure the editor to run the command with the bridge argument:

{"command": "crystal", "args": ["bridge"]}
crystal bridge [session launch options] [-w|--workspace <PATH>] [--space]
Option Meaning
Session launch options The set crystal accepts. They shape this process only and are not written to config.json or prompt.json. A later /model may save the launch provider and model, as on the terminal
-w, --workspace <PATH> Workspace for a session request that has no cwd
--space Use the operator space for a session request that has no cwd. Cannot be combined with --workspace
--config-options <IDS>, --default-config-options, --all-config-options Which session options the editor sees as config options, for this process only. They are mutually exclusive. <IDS> is a comma-separated list such as mode,model,approval, and all means every option. See Config options
--workspace-trust <on|off> Trust check for this process, ahead of bridge.workspaceTrust. Not written to config.json
--debug [FILE] Log every JSON-RPC message in both directions. See Debug log

ACP always sends cwd, so in practice the editor chooses the workspace. No secret is a command flag. Provider keys come from the data directory and the environment. See Credentials.

The editor configuration can name the flags, for example {"command": "crystal", "args": ["bridge", "--all-config-options"]}.

--debug writes one line per message with a UTC timestamp and the direction (client -> bridge or bridge -> client). A bare --debug writes to stderr, which editors usually collect in their agent log. --debug FILE appends to that file instead, and a relative path resolves against the process directory. A file that cannot be opened stops startup.

The log is a diagnostic aid, not a transcript. The values of mcpServers, env, headers, and credential-like fields (apiKey, token, authorization, password, secret, credentials) are replaced with [redacted] at any depth. Strings longer than 256 characters are cut and shown with their length. Prompt text and tool arguments that fit are logged as sent, so treat the file like the conversation.

  • stdout carries protocol lines only. Before anything else runs, the command hands the raw stdout stream to Bridge and points console output at stderr, so a plugin or tool that writes to the console cannot corrupt the stream.
  • stderr carries diagnostics in plain English. Nothing secret is written there.
  • stdin closing, SIGINT, SIGTERM, or SIGHUP start shutdown. The turn is interrupted without starting queued work, pending questions are cancelled, running requests are answered as cancelled, the session is saved, and the process exits with code 0. A second signal ends the process at once.

One process hosts one active session. session/new, session/load, session/resume, and the fork request save the active session and replace it, as /resume does. A request that names another session id is an error. An editor that wants parallel sessions starts more processes.

  • Start, load, resume, list, fork, and close saved sessions. Loading replays the conversation. /clear inside a session keeps the session id the editor knows.
  • Send prompts with text, images, embedded resources, and resource links, including local image files. A block the session cannot use becomes a one-line mention in the message instead of an error. Text that starts with / is a slash command, as in the terminal.
  • Receive replies and reasoning as streamed chunks; tool calls with titles, kinds, file locations, and diffs; permission requests; todos as the plan; usage; slash commands; and /help, /status, /stats, /tools, and /todos reports.
  • Change session settings through config options. Each option runs the same slash command as the terminal, so validation, refusal while a turn is busy, and writes to config.json match. thinking, context, tier, and speed appear only when the model offers a choice.
  • Run /pursue as one prompt turn. The reply arrives when the whole run ends. Editors that opt in also receive _crystal/pursue and _crystal/pursueChecked.
  • Sign in to an account provider with /login <provider>, and sign out with /logout <provider>. The sign-in link reaches the editor as a form. Bridge never opens a browser. See Credentials.
  • Use the rest of the session through _crystal/* requests: snapshot, recall, the queue (release and retract), verbose output, images, quick prompts, side questions, children, export, compaction, and structured reports. Live state that ACP has no update for arrives as _crystal/* notifications, sent only to an editor that opts in.
  • The editor’s cwd is the workspace. It must be an absolute path.
  • Trust follows the workspaceTrust switch. The question reaches the editor as a form. An editor without form support gets an error that names the directory and says to run crystal there once, or to turn the switch off. An untrusted directory is never trusted silently. The operator space is trusted as elsewhere.
  • Loading or resuming a session with a cwd that differs from the saved workspace moves the session into that directory after the trust check, as /resume <path> does.
  • /cd, /space, and /access still work inside a session. The change is reported to the editor.

The editor’s additionalDirectories become session write rules, the same as --allow-write. Each request’s list is the complete set of directories outside the workspace for the resulting session. Saved outside rules and access.json defaults outside the workspace are not applied. Omitting the list or sending [] means none.

Read rules on the workspace or a directory inside it only narrow access, so they stay. An entry inside the workspace, a relative path, a missing directory, or a credential path is rejected. The rules are saved with the session, so a later crystal --resume sees them. They are never written to access.json.

The editor’s MCP servers become session servers. They replace a Home or Project server of the same name, use the same MCP client, approval, mcpToolApproval (following the Project choice), timeouts, and notes as local servers, and are not saved in the session file. The editor sends them again on load and resume. A stdio command must be an absolute path. Their command, arguments, environment, headers, and URL never appear in an event, a note, /mcp, a log, or an error. /mcp lists them with the source Session. See MCP servers.

With editor support for forms, the question tool, MCP elicitation, workspace trust, and the /resume and /child choices appear as editor forms. Without it:

  • the question tool is dismissed, and the model gets the usual dismissed result;
  • MCP elicitation is cancelled;
  • trust is refused with an error;
  • choices are declined. /resume <id> and /child <id> still work.

Approval modes, grants, forced prompts, review, and extended review are unchanged. Each permission request offers allow once, and, when the call can reuse a grant, allow for this session and always allow, plus deny. A cancelled request, an unknown option, or a closed connection counts as deny. An editor that auto-approves permissions has made the operator’s choice, the same as Full. See Approval.

An editor shows every config option as a control, so Bridge offers a short list by default: mode, model, thinking, approval, and agents. Other options stay slash commands (for example /tokens on or /compact micro on) and are refused as config options with -32602.

The list is chosen in this order, and the first rule that applies wins:

  1. A command-line flag, for this process only: --config-options <IDS>, --all-config-options, or --default-config-options.
  2. The bridge section of config.json, only while customConfigOptions is true. configOptions takes ids or all. An empty list, an empty entry, or an unknown id stops startup.
  3. The built-in default.

A process flag does not change config.json. Hiding an option does not change its value. The full id table is in Bridge protocol.

Child Agents appear as progress on the parent task tool call. An editor that opts in gets them as separate subagent sessions instead. Without the opt-in, child approvals reach the editor under the parent session and the parent task call. See Child Agents.

  • The editor’s file system and terminal methods. Tools run in this process under the workspace fence, budgets, and timeouts.
  • The ACP authenticate and logout methods. Provider keys stay in credentials.json and the environment, and a missing key is a launch error. Account sign-in is available through the /login and /logout slash commands, as described above.
  • Deleting saved sessions, a client-provided system prompt, audio input, URL-mode elicitation, MCP over ACP, and several concurrent sessions in one process.