hx is driven headless by an orchestrator (hx -p TEXT --mode json, extensions via [[extensions]]). The direct Claude provider is not usable under the subscription terms, so claude_cli (hx starts the official claude -p) is the provider that has to work. In that mode the orchestrator cannot enforce a tool allowlist, because the claude binary executes tools itself and hx' event bus never sees them.
Facts (read in the code, hx at 7218d14; claude 2.1.318)
crates/hx-core/src/approve.rsserve() answers claude's --permission-prompt-tool mcp__hx__approve questions with question() + gate_why() only. It has no access to the agent Bus, so extensions (hook::Hook, ext.rs) never see the question.
gate_why returns Ok immediately when no permit hook is set (print mode -p), so the bridge allows everything headless.
approve::question() skips Read/Grep/Glob/LS/Task/Agent/mcp__hx__* on purpose; reads are never asked (only secret-looking paths).
crates/hx-ai/src/claude_cli.rs turns a claude tool_use block into a text line [claude Bash: ...] in the stream; it emits no Event::ToolCall / ToolResult. NDJSON/RPC consumers see no tool use at all (hx -p "run ls" --mode json | grep tool_call prints nothing) and hx stats shows 1 request per run.
claude 2.1.318 has --allowedTools, --disallowedTools, --tools, --settings, --permission-mode, and --permission-prompts <target> ("none" = prompts denied automatically; per the help text a permission handler approves writes to settings/git/tool-configuration).
Wanted
Route the permission bridge through the bus: serve() gets the agent bus (set up in main.rs next to approve::serve); each question becomes Event::ToolCall with names/args mapped to hx' vocabulary (Bash->bash{command}, Write->write{path}, Edit/MultiEdit->edit{path}, Read->read{path}, other tools by claude's name). A block from any hook/extension denies the call with its reason. Read-class tools must be asked too when an extension is subscribed (or always; they are cheap).
Headless default: when -p has no permit hook, keep "allow" for compatibility but let a config value (e.g. permissions = "deny", or "extensions-only") make unanswered questions a deny. Needed so a guard that dies cannot leave the run open (today hx treats a dead extension as "continue").
Emit Event::ToolCall / Event::ToolResult for claude's tools (from the assistant tool_use blocks and the matching tool results in the stream-json), so the NDJSON stream, hx stats, audit and turn budgets work in this mode. Keep the [claude ...] text line.
Verify that claude actually asks for reads inside the project. If it does not (default permission mode), start claude so that it does (--permission-mode/--settings), or document that a read allowlist needs --tools/--disallowedTools in claude_cli = [...].
Done when
A test with the REAL hx binary and a fake claude that asks mcp__hx__approve for Read of a secret file and Bashcurl x: an extension subscribed to tool_call blocks both, claude receives deny with the extension's reason; without the extension behaviour is unchanged.
The NDJSON stream contains tool_call/tool_result for claude's tools in claude_cli mode.
Consumer: johannes/orch#17 (profile allow is refused in claude_cli mode until this lands).
hx is driven headless by an orchestrator (`hx -p TEXT --mode json`, extensions via `[[extensions]]`). The direct Claude provider is not usable under the subscription terms, so `claude_cli` (hx starts the official `claude -p`) is the provider that has to work. In that mode the orchestrator cannot enforce a tool allowlist, because the `claude` binary executes tools itself and hx' event bus never sees them.
## Facts (read in the code, hx at 7218d14; claude 2.1.318)
- `crates/hx-core/src/approve.rs` `serve()` answers claude's `--permission-prompt-tool mcp__hx__approve` questions with `question()` + `gate_why()` only. It has no access to the agent `Bus`, so extensions (`hook::Hook`, `ext.rs`) never see the question.
- `gate_why` returns `Ok` immediately when no `permit` hook is set (print mode `-p`), so the bridge allows everything headless.
- `approve::question()` skips Read/Grep/Glob/LS/Task/Agent/`mcp__hx__*` on purpose; reads are never asked (only secret-looking paths).
- `crates/hx-ai/src/claude_cli.rs` turns a claude `tool_use` block into a text line `[claude Bash: ...]` in the stream; it emits no `Event::ToolCall` / `ToolResult`. NDJSON/RPC consumers see no tool use at all (`hx -p "run ls" --mode json | grep tool_call` prints nothing) and `hx stats` shows 1 request per run.
- claude 2.1.318 has `--allowedTools`, `--disallowedTools`, `--tools`, `--settings`, `--permission-mode`, and `--permission-prompts <target>` ("none" = prompts denied automatically; per the help text a permission handler approves writes to settings/git/tool-configuration).
## Wanted
1. Route the permission bridge through the bus: `serve()` gets the agent bus (set up in `main.rs` next to `approve::serve`); each question becomes `Event::ToolCall` with names/args mapped to hx' vocabulary (`Bash`->`bash{command}`, `Write`->`write{path}`, `Edit`/`MultiEdit`->`edit{path}`, `Read`->`read{path}`, other tools by claude's name). A `block` from any hook/extension denies the call with its reason. Read-class tools must be asked too when an extension is subscribed (or always; they are cheap).
2. Headless default: when `-p` has no permit hook, keep "allow" for compatibility but let a config value (e.g. `permissions = "deny"`, or `"extensions-only"`) make unanswered questions a deny. Needed so a guard that dies cannot leave the run open (today hx treats a dead extension as "continue").
3. Emit `Event::ToolCall` / `Event::ToolResult` for claude's tools (from the `assistant` tool_use blocks and the matching tool results in the stream-json), so the NDJSON stream, `hx stats`, audit and turn budgets work in this mode. Keep the `[claude ...]` text line.
4. Verify that claude actually asks for reads inside the project. If it does not (default permission mode), start claude so that it does (`--permission-mode`/`--settings`), or document that a read allowlist needs `--tools`/`--disallowedTools` in `claude_cli = [...]`.
## Done when
- A test with the REAL hx binary and a fake `claude` that asks `mcp__hx__approve` for `Read` of a secret file and `Bash` `curl x`: an extension subscribed to `tool_call` blocks both, claude receives `deny` with the extension's reason; without the extension behaviour is unchanged.
- The NDJSON stream contains `tool_call`/`tool_result` for claude's tools in `claude_cli` mode.
- `tests/all.sh` (incl. `tests/claude_cli_e2e.sh`) stays green.
Consumer: johannes/orch#17 (profile `allow` is refused in claude_cli mode until this lands).
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
hx is driven headless by an orchestrator (
hx -p TEXT --mode json, extensions via[[extensions]]). The direct Claude provider is not usable under the subscription terms, soclaude_cli(hx starts the officialclaude -p) is the provider that has to work. In that mode the orchestrator cannot enforce a tool allowlist, because theclaudebinary executes tools itself and hx' event bus never sees them.Facts (read in the code, hx at 7218d14; claude 2.1.318)
crates/hx-core/src/approve.rsserve()answers claude's--permission-prompt-tool mcp__hx__approvequestions withquestion()+gate_why()only. It has no access to the agentBus, so extensions (hook::Hook,ext.rs) never see the question.gate_whyreturnsOkimmediately when nopermithook is set (print mode-p), so the bridge allows everything headless.approve::question()skips Read/Grep/Glob/LS/Task/Agent/mcp__hx__*on purpose; reads are never asked (only secret-looking paths).crates/hx-ai/src/claude_cli.rsturns a claudetool_useblock into a text line[claude Bash: ...]in the stream; it emits noEvent::ToolCall/ToolResult. NDJSON/RPC consumers see no tool use at all (hx -p "run ls" --mode json | grep tool_callprints nothing) andhx statsshows 1 request per run.--allowedTools,--disallowedTools,--tools,--settings,--permission-mode, and--permission-prompts <target>("none" = prompts denied automatically; per the help text a permission handler approves writes to settings/git/tool-configuration).Wanted
serve()gets the agent bus (set up inmain.rsnext toapprove::serve); each question becomesEvent::ToolCallwith names/args mapped to hx' vocabulary (Bash->bash{command},Write->write{path},Edit/MultiEdit->edit{path},Read->read{path}, other tools by claude's name). Ablockfrom any hook/extension denies the call with its reason. Read-class tools must be asked too when an extension is subscribed (or always; they are cheap).-phas no permit hook, keep "allow" for compatibility but let a config value (e.g.permissions = "deny", or"extensions-only") make unanswered questions a deny. Needed so a guard that dies cannot leave the run open (today hx treats a dead extension as "continue").Event::ToolCall/Event::ToolResultfor claude's tools (from theassistanttool_use blocks and the matching tool results in the stream-json), so the NDJSON stream,hx stats, audit and turn budgets work in this mode. Keep the[claude ...]text line.--permission-mode/--settings), or document that a read allowlist needs--tools/--disallowedToolsinclaude_cli = [...].Done when
claudethat asksmcp__hx__approveforReadof a secret file andBashcurl x: an extension subscribed totool_callblocks both, claude receivesdenywith the extension's reason; without the extension behaviour is unchanged.tool_call/tool_resultfor claude's tools inclaude_climode.tests/all.sh(incl.tests/claude_cli_e2e.sh) stays green.Consumer: johannes/orch#17 (profile
allowis refused in claude_cli mode until this lands).hermes referenced this issue from johannes/orch2026-11-13 19:14:30 +00:00