Skip to content

feat: add hook config support#232

Draft
PeterCardenas wants to merge 1 commit intoagentclientprotocol:mainfrom
PeterCardenas:support-hooks
Draft

feat: add hook config support#232
PeterCardenas wants to merge 1 commit intoagentclientprotocol:mainfrom
PeterCardenas:support-hooks

Conversation

@PeterCardenas
Copy link
Copy Markdown

Closes #144

Add support for specifying hookConfigs when creating a session to react to hook events.

Hooks are specified with the following type:

export type HookConfig = {
  /** The hook event to listen for */
  event: HookEvent;
  /** 
   * Optional matcher string to filter which tools trigger this hook.
   * Only relevant for tool-related hooks: PreToolUse, PostToolUse, PostToolUseFailure, PermissionRequest
   */
  matcher?: string;
  /** Command to execute */
  command: string;
  /** Arguments for the command */
  args?: string[];
  /** Environment variables to pass to the command */
  env?: Record<string, string>;
};

These commands are executed with environment variables populated with the tool input, so arguments or the command itself can handle the input accordingly.
To give hook output, the command must print, and only print, a JSON string to stdout which will be parsed to use as the hook result. Otherwise, the agent will continue.

@cla-bot
Copy link
Copy Markdown

cla-bot bot commented Jan 3, 2026

We require contributors to sign our Contributor License Agreement, and we don't have @PeterCardenas on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'.

@PeterCardenas
Copy link
Copy Markdown
Author

@cla-bot check

@cla-bot cla-bot bot added the cla-signed label Jan 3, 2026
@cla-bot
Copy link
Copy Markdown

cla-bot bot commented Jan 3, 2026

The cla-bot has been summoned, and re-checked this pull request!

@AlephNotation
Copy link
Copy Markdown

Checking in on this. It would be nice to support some of the popular tools that use hooks

AlephNotation added a commit to AlephNotation/claude-code-acp that referenced this pull request Jan 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for hooks

2 participants