Skip to content

Event hooks: run a command when a session blocks, finishes, exits or a run fails #170

Open

Description

@AThraen

This was generated by AI during triage.

Summary

Event hooks: run a user-configured command when something happens to a session. For example: session becomes blocked or waiting for approval, an agent finishes, a run command fails, a session exits.

Motivation

A frequent want is "ping my phone when an agent needs me". Today that needs CSM to grow a feature per destination: Telegram, Slack, ntfy, a sound.

Herdr's plugin system is the heavy version:

  • a manifest of actions, event hooks, panes and link handlers;
  • distribution from GitHub, plus a marketplace;
  • the cookbook includes agent-telegram-notify.

The event hook is the piece that gives most of the value for least cost.

Proposal (deliberately smaller than plugins)

  • Configuration. Settings ▸ Hooks: a list of { event, command }. The command is an argv array, run without a shell (CLAUDE.md, "Never interpolate a value into a command line").
  • Events.
  • Context. Passed as environment variables plus a JSON payload on stdin: session id, name, folder, alert message, and for runs the run label and exit code.
    • Not as argv substitution: the alert text comes from terminal output and is untrusted.
  • Execution.
    • Off the UI thread (Task.Run), with a timeout (e.g. 10 s), so output can't stall CSM.
    • Debounced per session and event.
    • Failures logged to crash.log.
  • --clean. Hooks are disabled in --clean runs.

Out of scope

Related: #149, the clickable-notifications issue filed alongside this one, #154.

Activity

  1. AThraen commented on Nov 10, 2026

    @AThraen
    ContributorAuthor

    This was generated by AI during triage.

    An event source now exists (#190). The OSC 7501 transitions into blocked (with kind: permission/question/auth), done and error are exactly the hook triggers this issue proposes, and they are no longer regex guesses. Pass the record id, app and decoded msg to the hook as environment variables (CSM_STATUS_ID, …), never on the command line. The same applies to anything else that comes from terminal output.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions