pub enum HookEvent {
PreToolUse,
PostToolUse,
}Expand description
When a participant is consulted.
One variant per interception point mentra offers. It is spelled out rather
than assumed so a config file says when a hook fires — and the default is
PreToolUse, so every hooks file written before there
was a second point still means what it said.
The two are not two halves of one question. Before the call, the whole question is whether it should happen and in what form; afterwards it has happened, and the only thing left to decide is what the model is shown. A hook that wants both says so twice.
Variants§
PreToolUse
Before the tool runs — and, since mentra 0.24, before the schema check
and the ToolAuthorizer too.
So a hook is asked about every registered call, including ones the approver goes on to refuse: being consulted is not being approved, and a participant with side effects of its own must not read it that way. What it may take from the ordering is that a rewrite it returns is what the approver is then asked about.
PostToolUse
After the tool ran, before the model is shown what it returned.
Too late to stop anything: the side effects have happened and the unmodified result has already reached the event stream. What a participant still has is the output, which is the only place some questions can be answered at all — whether a grep pulled a credential out of a file nobody meant to expose, whether stderr carries an internal hostname.