English · Русский
The agent edits a file, you see the diff on a card in your editor and press "allow". The edit lands in the editor's buffer, where you can see it and undo it, instead of going to disk behind your back. Inside runs ordinary Claude Code: its own system prompt, its own tools, CLAUDE.md, skills, subagents, your settings and your MCP servers. Outside it speaks Agent Client Protocol to the editor, and the engine is the Claude Agent SDK.
Warning
A turn is paid for by whatever the local Claude Code is logged in to. Anthropic does not allow third-party products to use claude.ai login or subscription limits without its approval, so an editor working through this host on Pro or Max puts the account at risk.
You need Node 22 or newer and Claude Code logged in to your account. Nothing is published to npm, so the agent is run from this repository:
npx github:GlebSmolyakov/claude-proxy --helpThat builds it on the way in, and the editor can be pointed at the same command. To work on it instead, clone it:
git clone https://github.com/GlebSmolyakov/claude-proxy.git
cd claude-proxy
pnpm installpnpm install builds it too; after that the agent is node dist/index.js.
The Claude Code binary is the one that ships with the SDK. To run the claude you installed yourself, put its path in CLAUDE_CODE_EXECUTABLE.
In JetBrains Air: task panel → agent picker → Add ACP Agent. Air opens acp.json, on macOS ~/Library/Application Support/JetBrains/Air/acp.json. Zed keeps the same shape under agent_servers in its settings.json.
{
"agent_servers": {
"Claude Code": {
"command": "npx",
"args": ["-y", "github:GlebSmolyakov/claude-proxy"]
}
}
}The agent shows up in the picker and works in the open project. A clone is pointed at the file it built, which is what to use while changing it:
{
"agent_servers": {
"Claude Code": {
"command": "node",
"args": ["/Users/you/WebstormProjects/claude-proxy/dist/index.js"]
}
}
}The editor starts dist/index.js as a plain program and talks to it over stdin and stdout with JSON-RPC. Nothing but the protocol goes to stdout; logs go to stderr.
editor ──stdio──▶ claude-proxy ──▶ Claude Code (Agent SDK)
▲ │
└── session events ◀┘ cards, text, permissions, files, terminal
session/new sets up a session: the project folder, the permission mode, the model. No process yet. The first prompt starts one, and it stays: later prompts go into the same input stream, while the conversation, its compaction and its context live inside the CLI. A turn pays for no spawn and no transcript replay.
An agent nobody has used for 30 minutes is stopped and its session stays behind. The next prompt starts a new agent and resumes the conversation by the session id, which is also what happens after a process dies mid-work. session/close stops the agent at once and hands its terminals back to the editor.
Every message from the SDK becomes a session/update:
| From the agent | In the editor |
|---|---|
| text and thinking | the answer as it is written |
| the start of a tool call | a card for the action |
| its input and its result | title, the diff of an edit, output, status |
TodoWrite and tasks |
the plan as a list |
| token counts | what the context holds and what the turn cost |
| a compacted conversation | a mark in the timeline where it was shortened |
| subscription spend | a word when a limit window crosses a threshold |
A card opens as soon as the tool is named and is refined when its full input arrives: first "Edit", then "Edit src/a.ts" with the diff. The session is named after the first thing asked of it, so it is not nameless in the editor's list while it is the one you are working in. The compaction mark is an extension, and goes only to an editor that asked for it.
All of this follows what the editor said about itself in initialize.
- Files. With
fs/read_text_fileandfs/write_text_file, the built-inRead,WriteandEditare redirected to them. The agent sees unsaved changes, and its own edits land in the buffer. - Terminal. With
terminal/create,Bashruns in a terminal the editor opens, and that terminal stays on the tool call's card while the command runs. Each command gets a terminal of its own, so a lonecdis answered here instead: the session remembers where it moved to and the commands after it run there. - Permissions. Whatever the session mode and your settings leave open goes to a dialog: "Allow", "Always allow" when the CLI suggested a rule, and "Reject". Reading inside the session's folders passes without a dialog, as the built-in
Readdoes. - Questions. With form elicitation, the agent asks through
AskUserQuestion, and an MCP server's request for input goes the same way. Without it, asking is off. - Sign-in. With terminal authentication, the sign-in list gets an entry that runs
claude auth login.
What the editor did not claim stays with the agent: files go to disk, commands run out of sight, questions are not asked.
session/set_mode switches between default, acceptEdits, plan, dontAsk and bypassPermissions. session/set_config_option changes the model, the effort level and thinking. The model switches on a running agent; effort and thinking are set when an agent starts, so an idle one is stopped for them and the next prompt starts one that has them, with the conversation intact.
The model list starts as the aliases and is replaced by what the account really has once an agent has run. The editor gets the CLI's slash commands at the same time, your own among them; a command typed as a prompt runs and answers as a message from the agent.
A few commands are answered here instead of by the model. They stand in the same list as the CLI's, and a prompt that is one of them never reaches the agent.
/rewindputs the files back as they were before one of your earlier prompts. The CLI keeps a backup before every edit; this asks which prompt to return to — a form when the editor can show one,/rewind 2when it cannot — and says which files changed back./usagesays where the subscription windows and the context stand right now, rather than waiting for a limit to move./mcplists the MCP servers of the session: the CLI's own with their connection status, and the ones this host carries over itself./mcp off db,/mcp on dband/mcp reconnect dbpass an order to the CLI about one of its own.
The editor and the CLI know nothing about each other. The editor speaks ACP to the host, the CLI works as a plain CLI, and everything in between happens here. So the MCP servers an editor passes in session/new do not reach the CLI by default: they would meet behind the host's back, and a stdio server is also a program the editor named being run. Every such server is logged with its command or its address, and --allow-mcp Air or --allow-mcp all lets them through.
When the editor's tools are wanted anyway, the host takes them on itself: --proxy-mcp Air or --proxy-mcp "Air:browser-read-page,browser-screenshot" connects the server to the host rather than to the CLI. The agent sees the chosen tools as this host's own, named like Air: browser-read-page, and every call goes through the same dialog and the same card as everything else.
Reading without a dialog works only in the session's folders, and a folder has to be narrow enough for it. A home directory, the filesystem root and anything a home sits in are too broad: every file there goes through the dialog.
session/list names the conversations the CLI saved under a folder: their ids, titles and when they were last touched, fifty at a time with a cursor for the rest. session/load reads the conversation the CLI saved and replays it as events: the user's messages, the agent's text and thinking, a card per tool call with its result, the plan. The next prompt then carries on in that same session.
| Option | Default | What it sets |
|---|---|---|
--permission-mode |
default |
Mode of new sessions |
--model |
the CLI's own | Model of every session: an alias or a full id |
--idle-minutes |
30 |
When to stop an agent left unused; 0 keeps it running |
--login |
Hand the terminal to Claude Code's own sign-in | |
LOG_LEVEL |
info |
debug adds the CLI's stderr |
Flags set the behaviour of the whole process, while the editor opens different projects in it. A .claude-proxy.json next to the code narrows the flags for its own folder:
{
"model": "haiku",
"permissionMode": "plan",
"allowMcp": ["Air"],
"proxyMcp": { "Air": ["browser-read-page"] }
}Whatever the file leaves out comes from the flags, and the file can only ask for less than they allow. A mode freer than the one the host was started with is refused, and so is a server that --allow-mcp or --proxy-mcp never named: the file arrives with the code, and cloning a repository is not the same as deciding what its agent may do. A field the host cannot use is skipped, with a line in the log.
- A redirected
Bashhas no shell that rememberscdbetween calls, and a background command's output stays in the editor's terminal only. - Subagents show their tool calls but not their text: ACP 1.4 has no nested transcript to put it in.
- A
urlelicitation from an MCP server is declined: finishing one in a browser needs a channel back that this host does not have. - Fast mode is not a session option;
query()has none to carry it.
The rest is in TODO.md.
pnpm test
pnpm run checkThe editor runs the built dist/index.js, so a change needs a rebuild and a restart of the agent in the editor.
Most of them are unit tests beside the module they cover. Two layers go wider:
editor-work.test.tsplays a day's work through the protocol. Both ends are real — an ACP editor with buffers, terminals and dialogs on one side, the host's own tool handlers on the other — and only the model's decisions are a script of what the CLI would print. The two halves live ineditor.test-support.ts(the editor) andagent.test-support.ts(the CLI, which asks for permission and runs tools in the order a real one does).cli.e2e.test.tsstarts the built program as a child process and talks to it over stdin and stdout, so the flags, the stdio wiring and the shutdown are tested as an editor meets them. It rebuilds first when the sources are newer thandist.
src/
├── index.ts arguments, the CLI binary, the ACP app on stdio
├── acp-agent.ts session methods, permissions, questions, the agent's life
├── agent.ts query() options and the session's input stream
├── session.ts session state and tool call cards
├── updates.ts SDK messages → session/update events
├── tools.ts a card's title, kind, diff and result, and the plan
├── editor-tools.ts files and commands through the editor
├── terminal.ts bash in the editor's terminal
├── questions.ts the agent's and an MCP server's questions as a form
├── config.ts model, effort, thinking
├── permissions.ts session modes and the answers a dialog offers
├── prompt.ts an ACP prompt → the agent's user message
├── models.ts which model names `--model` takes
└── log.ts logging to stderr