#!/usr/bin/env node /** * Minimal Codex hook bridge. */ import { pathToFileURL } from "node:url"; import { type AgentHookEvent, type AgentHookInput, handleAgentHook, quiet, readStdinJson } from "./agent-hook.js"; export async function handleCodexHook(event: AgentHookEvent, input: AgentHookInput) { return handleAgentHook("codex", event, input); } async function main(): Promise { const event = process.argv[2] as AgentHookEvent | undefined; if (!event || !["SessionStart", "PostToolUse", "Stop"].includes(event)) { console.log(JSON.stringify(quiet())); return; } try { const input = await readStdinJson(); console.log(JSON.stringify(await handleCodexHook(event, input))); } catch { console.log(JSON.stringify(quiet())); } } if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) { void main(); }