Hook-driven face_say safety net for Claude/Codex/Gemini (v1.16.0)#50
Merged
Conversation
Adds a runtime-agnostic hook bridge so the 3D face speaks even when an agent forgets to call face_say voluntarily. Wires Claude Code's Notification + Stop, Codex's PermissionRequest + Stop, and Gemini CLI's Notification + AfterAgent into a single wrapper script that emits face_say + face_event and (for helpers) an owner-inbox entry tagged source=mh_hook. End-to-end verified across all three runtimes; design notes in .agent/PLANS_47_HOOK_DRIVEN_FACE_SAY.md. - Adds `face.hook` MCP tool and the face-app `hook_bridge` orchestrator with per-agent CJK-heuristic language detection, variant-rotation template selection, and owner-inbox routing via existing assignment state. - Adds `scripts/mh-hook.mjs` (the wrapper invoked by each runtime's hook config) with strict "stdout silent / exit 0 always" discipline required by Gemini AfterAgent's retry-on-exit-2 semantics. - Adds `scripts/grant-codex-hook-trust.sh` to automate Codex's one-time /hooks browser trust grant via a private tmux server. - Forwards MH_FACE_AUTH_TOKEN as ?auth_token query param from mh-hook so it works against face-app instances that require auth. - Templates default to ja+en built-in, overridable via ~/.minimum-headroom/face-templates.json. - Adds 22 unit tests (mh-hook + hook_bridge); full suite 325 passing. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
face_sayvoluntarily. Wires Claude Code'sNotification+Stop, Codex'sPermissionRequest+Stop, and Gemini CLI'sNotification+AfterAgentinto a single wrapper that emitsface_say+face_eventand (for helpers) an owner-inbox entry taggedsource=mh_hook.face.hookMCP tool,face-app/dist/hook_bridge.jsorchestrator (per-agent CJK language detection, variant-rotation template selection, owner-inbox routing),scripts/mh-hook.mjswrapper,scripts/grant-codex-hook-trust.shfor Codex's one-time trust grant.~/.minimum-headroom/face-templates.json.1.15.1 → 1.16.0(package.json, mcp-server SERVER_VERSION, tts-worker / asr-worker pyproject.toml).Design notes and end-to-end verification log:
.agent/PLANS_47_HOOK_DRIVEN_FACE_SAY.md(gitignored, lives only in the local clone).Per-runtime status (verified 2026-05-10)
scripts/grant-codex-hook-trust.shafter editing configCodex trust grant
Codex silently filters user-defined hooks until trusted at user level (in
[hooks.state.*]). Grant is once-per-edit, user-wide, inherited by every helper spawned afterward. Two paths:./scripts/grant-codex-hook-trust.sh(private tmux server, walks/hooksbrowser, exits)codexinteractively →/hooks→ per-event Enter →t→ Esc →/quitmh-hook.mjsis hard-wired to write nothing to stdout and exit0always — required because Gemini's AfterAgent treats exit2as "retry this turn with stderr as feedback prompt" and Gemini parses stdout as JSON.Test plan
npm testpasses locally (325/325, includes the 22 new mh-hook + hook_bridge tests).doc/hook-bridge/{claude-settings.json.example, codex-config.toml.example, gemini-settings.json.example}into your local~/.claude/settings.json,~/.codex/config.toml,~/.gemini/settings.json(substitute/ABS/PATH/).scripts/grant-codex-hook-trust.shonce. Confirm~/.codex/config.tomlgrows two[hooks.state.*]tables.MH_FACE_AGENT_ID.agent.spawnwithagent_cmd=claude|codex|gemini), assign a mission that triggers a permission prompt, observe: (a) the face speaks "Approval needed." (or a Japanese variant), (b)owner.inbox.listshows asource=mh_hookentry tagged with the helper's id and runtime.idle_after_responsesource=mh_hook doneentry appears (Claude Stop / Codex Stop / Gemini AfterAgent).🤖 Generated with Claude Code