/** * Adapter-aware hook output JSON. Each adapter target has its own protocol * shape, so encode it once here so post-emit handlers don't have to branch on * `adapter` everywhere. * * Shapes (verified against live dispatchers + each adapter's upstream hooks docs): * * - **Claude Code**: `{hookSpecificOutput: {hookEventName, additionalContext}}` * for SessionStart / UserPromptSubmit / SubagentStart; deny uses * `{hookSpecificOutput: {hookEventName: "PreToolUse", permissionDecision: "deny", permissionDecisionReason}}`. * - **Cursor**: `{additional_context}` flat for context-capable events, * including beforeSubmitPrompt. Deny uses * `{permission: "deny", agent_message, user_message}`. * - **Codex**: structurally identical to Claude Code for context and tool * denials. Stop blocks are deliberately suppressed because their automatic * continuation can replace a completed user-facing answer. * * Every helper writes to process.stdout + newline-terminates so callers can * fire-and-forget. Empty text is a no-op. */ import type { Adapter } from "../../adapter.js"; export type SystemEvent = "SessionStart" | "UserPromptSubmit" | "SubagentStart" | "PreToolUse" | "PostToolUse"; export interface StopOutputOptions { /** Existing coordination verdict. Omit when that check passed. */ verdict?: { reason?: string; rule: string; }; } /** Emit a context-injection (peer table, wiring check, council pending, …). */ export declare function emitContext(adapter: Adapter, event: SystemEvent, text: string): boolean; /** Emit a PreToolUse deny: blocks the tool call with `reason` shown to the model. */ export declare function emitDeny(adapter: Adapter, reason: string): void; /** * Emit a Stop-hook block in the firing adapter's enforcement channel and return * the process exit code the caller should use. * * The verdict (allow/block + reason) is computed adapter-agnostically in * agents/rules/stop-hook.ts; this function only shapes *how the block is * communicated back*, because each adapter has a different mechanism: * * - **Claude Code** honors `exit 2` + a stderr reason as a turn block, and the * adapter re-prompts the model with the stderr text. * - **Codex** also supports that channel, but Harnery must not use it for * coordination reminders. A Stop continuation can replace the completed * answer in clients that retain only the final continuation response. Return * success without output as a defense in depth behind the observe-only * verdict in `agents/rules/stop-hook.ts`. * - **Cursor** ignores stop-hook exit codes (non-zero = fail-open, the turn * proceeds) and re-prompts ONLY via a `followup_message` field in stdout * JSON, which it auto-submits as the next user message: the sanctioned * "iterate until a goal is met" channel, capped by `loop_limit` (default 5). * We exit 0 so Cursor treats the run as a success and honors the output. * (Confirmed against cursor.com/docs/agent/hooks.) */ export declare function emitStopBlock(adapter: Adapter, verdict: { reason?: string; rule: string; }, coordRoot?: string): 0 | 2; /** * Emit the adapter-specific response for one Stop outcome. */ export declare function emitStopOutcome(adapter: Adapter, options: StopOutputOptions, coordRoot?: string): 0 | 2; //# sourceMappingURL=output.d.ts.map