Register Command • AI Agent SDK

register_command: Register a shell command as a hook.

register_command

Method

</div>

This is a method of the HookRegistry class in the registry module.

Register a shell command as a hook.

Signature

python
def register_command(event: HookEvent, command: str, matcher: Optional[str], name: Optional[str], description: Optional[str], sequential: bool, timeout: float, env: Optional[Dict[str, str]], shell: bool, priority: int) -> str

Parameters

ParamField HookEvent

The event to hook

ParamField str

The shell command to execute

ParamField Optional[str]

Optional regex pattern to match targets

ParamField Optional[str]

Optional name for the hook

ParamField Optional[str]

Optional description

ParamField bool

Whether to run sequentially

ParamField float

Timeout in seconds

ParamField Optional

Additional environment variables

ParamField bool

Whether to run in shell mode

ParamField int

Execution order (lower runs earlier). Default 100

Returns

ResponseField str

The hook ID

Uses

  • CommandHook
  • register

Source

View on GitHub

praisonaiagents/hooks/registry.py at line 134