Read `data.hook_event_name` from the stdin payload and fall back to the Gemini/non-Gemini heuristic only when the field is absent or blank. Fixes Claude Code rejecting output with "expected Stop but got PostToolUse" when the monitor is called by Stop, SubagentStop, or PreCompact hooks. Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -182,7 +182,8 @@ process.stdin.on('end', () => {
|
||||
|
||||
const output = {
|
||||
hookSpecificOutput: {
|
||||
hookEventName: process.env.GEMINI_API_KEY ? "AfterTool" : "PostToolUse",
|
||||
hookEventName: (data.hook_event_name && data.hook_event_name.trim())
|
||||
|| (process.env.GEMINI_API_KEY ? "AfterTool" : "PostToolUse"),
|
||||
additionalContext: message
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user