pub enum HookOutput {
Allow(AllowOutput),
AllowWithModifiedCommand(AllowWithModifiedCommandOutput),
Deny(DenyOutput),
}Expand description
Output sent back to Claude Code from PreToolUse hook.
Variants§
Allow(AllowOutput)
Allow the command to proceed (empty object or no output).
AllowWithModifiedCommand(AllowWithModifiedCommandOutput)
Allow with a modified/replaced command (for transparent interception). Used when RCH has already executed the command remotely and wants to replace the original command with a no-op for transparency.
Deny(DenyOutput)
Deny the command with a reason.
Implementations§
Source§impl HookOutput
impl HookOutput
Sourcepub fn allow_with_modified_command(
replacement_command: impl Into<String>,
) -> Self
pub fn allow_with_modified_command( replacement_command: impl Into<String>, ) -> Self
Create an allow output with a modified/replaced command.
This is used for transparent interception: RCH has already executed the command remotely, so we replace it with a no-op to prevent double execution. The agent sees the remote output but thinks the command ran locally.
§Arguments
replacement_command- The command to substitute (typically “true” for a no-op)
Sourcepub fn rewrite_with_permission_check(
replacement_command: impl Into<String>,
) -> Self
pub fn rewrite_with_permission_check( replacement_command: impl Into<String>, ) -> Self
Rewrite the command but let the user’s permission rules decide.
For a compound command the rewrite keeps the user’s own prefix
(cd x && <anything> && rch exec -- cargo build); answering “allow”
would approve that prefix without the prompt the user’s rules call
for. Claude Code still applies updatedInput without a decision.
Sourcepub fn to_hook_json(
&self,
original_tool_input: Option<&Value>,
) -> Result<String>
pub fn to_hook_json( &self, original_tool_input: Option<&Value>, ) -> Result<String>
Serialize for Claude Code, carrying the original tool input through.
updatedInput replaces the entire tool input, so a rewrite that sends
only command silently drops the Bash tool’s other fields: an offloaded
build lost the agent’s extended timeout (and was killed at the default)
and its run_in_background. Every original field other than command is
copied into updatedInput unchanged.