Skip to content

Conversation

@PeterCardenas
Copy link

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

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
Author

@cla-bot check

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

cla-bot bot commented Jan 3, 2026

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

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

1 participant