fix(hooks): pass expectedEventName so a mismatched hookSpecificOutput block is discarded

Wire the bridges to the codec's new discriminator check (merged down from
dsh-hook-protocol): each bridge passes its firing `point` as `expectedEventName`
to runHook, so a hook whose `hookSpecificOutput.hookEventName` names a different
event has its event-scoped fields discarded. Bridge-level guard test: a
PreToolUse hook emitting a UserPromptSubmit-labeled deny no longer denies the
tool (proven red without the wiring, then reverted).
This commit is contained in:
Tianyi Cui
2026-07-01 10:56:34 +08:00
parent 5304d4ef29
commit 253eded47b
3 changed files with 21 additions and 0 deletions
+2
View File
@@ -107,6 +107,8 @@ export function apply(ctx: Context, config: Config): void {
...opts.signal ? { signal: opts.signal } : {},
defaultTimeoutMs,
trailingNewline: false, // Codex writes stdin WITHOUT a trailing newline.
// Discard a `hookSpecificOutput` block naming a different event.
expectedEventName: point,
}, () => performance.now())
// Codex's SessionStart/UserPromptSubmit treat a clean hook's PLAIN
// (non-JSON) stdout as additionalContext. The codec keeps that raw text on