Skip to main content

Module protocol

Module protocol 

Source
Expand description

Hook protocol abstraction for multi-agent support.

Each coding agent sends/receives hook JSON in a different format. The HookProtocol trait encapsulates these differences so the core permission logic works identically regardless of which agent is calling.

Most methods have default implementations that handle the common case. Adding a new agent typically requires overriding only HookProtocol::agent and HookProtocol::parse_tool_use. Override format methods only if the agent uses a non-standard output format.

Traits§

HookProtocol
Abstraction over agent-specific hook JSON formats.

Functions§

get_protocol
Construct the appropriate protocol implementation for an agent.
json_str
Extract a string field from JSON, returning “” if missing.
json_str_any
Extract a string from one of several possible field names.
json_str_or
Extract a string field from JSON with a default value.
json_value_any
Extract an optional Value from one of several possible field names.
shell_escape
Shell-escape a string for safe inclusion in a shell command.