Skip to content

fix(#41457): register shell hooks in TUI gateway and ACP adapter at startup - #41548

Closed
iamlukethedev wants to merge 1 commit into
NousResearch:mainfrom
iamlukethedev:fix/41457-shell-hooks-tui-acp-registration
Closed

fix(#41457): register shell hooks in TUI gateway and ACP adapter at startup#41548
iamlukethedev wants to merge 1 commit into
NousResearch:mainfrom
iamlukethedev:fix/41457-shell-hooks-tui-acp-registration

Conversation

@iamlukethedev

Copy link
Copy Markdown
Contributor

Problem

Shell hooks (configured in config.yaml's hooks: block) implement security checks like pre_tool_call blockers to veto dangerous operations (e.g., rm -rf, writes to protected paths). These hooks work correctly in the CLI and messaging gateway, but are silently ignored in the TUI gateway (desktop app) and ACP adapter (IDE integration).

This creates a security gap: a user who configures a pre_tool_call shell hook to block dangerous operations will have that protection enforced in the CLI and gateway, but not when driving the same agent from the desktop app or an IDE. The divergence is especially concerning because hermes hooks doctor passes (script validation, etc.) while the hook remains inert in those surfaces.

Solution

Call register_from_config() at startup in both TUI gateway and ACP adapter entry points, mirroring the existing gateway implementation.

  • tui_gateway/entry.py — Register right after sidecar publisher setup, before MCP discovery
  • acp_adapter/entry.py — Register right after MCP tool discovery, before building the first agent

Both use the same best-effort error handling: failures log to debug but never block startup.

Implementation details

  • is idempotent (dedupes by event/matcher/command), so adding it to additional entry points is safe
  • Uses accept_hooks=False to let the function resolve the effective value from env + config itself (no re-reading of hooks_auto_accept)
  • Wrapped in try/except so registration failures can never block platform startup
  • No changes to the config schema, hook execution logic, or tool dispatch — purely adds the missing registration step

Testing

  • ✓ Imports: both tui_gateway/entry.py and acp_adapter/entry.py import successfully
  • ✓ No new dependencies or external APIs

Impact

  • Users can now rely on shell hook vetoes (security checks, safety guards) across all surfaces (CLI, gateway, desktop, IDE)
  • Pre_tool_call blockers are now enforced consistently
  • No breaking changes; purely adds missing registrations for existing features

Fixes #41457

…adapter at startup

Shell hooks (pre_tool_call blockers, etc. from config.yaml) are now
registered in both TUI gateway (desktop app) and ACP adapter (IDE) entry
points, fixing a security gap where hook-based tool vetoes were silently
ignored in these surfaces.

The hooks were already working correctly in CLI and messaging gateway,
but missing from the desktop/IDE paths. This registered-them at agent
build time, creating a divergence where the same hook configuration
would work in CLI but be ineffective in the TUI or IDE.

Now both entry points call register_from_config() during startup,
mirroring the existing gateway implementation:

- tui_gateway/entry.py: register right after sidecar publisher setup
- acp_adapter/entry.py: register right after MCP tool discovery

Both use the same best-effort error handling: failures log to debug but
never block startup. register_from_config() is idempotent, so adding
it to additional entry points is safe.

Fixes NousResearch#41457
@iamlukethedev

Copy link
Copy Markdown
Contributor Author

Closing as duplicate. Issue #41457 already has linked PR #41464 in progress. My apologies for the redundant work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Shell hooks not registered in desktop (TUI gateway) and ACP adapter — pre_tool_call block hooks silently ignored

1 participant