mirror of
https://github.com/openai/codex.git
synced 2026-11-23 07:17:11 +00:00
Add hooks for interrupted turns (#40511)
## What changed - Add an `Interrupt` hook event that runs for an active top-level turn before its interrupted abort event is emitted. - Flush the turn transcript before invoking the hook and provide the session, turn, transcript, working directory, model, and permission mode in its input. - Support command and MCP handlers, including asynchronous commands, with a one-second default timeout and a three-second maximum. - Expose the event through hook configuration, managed requirements, app-server notifications, generated schemas, analytics, and the TUI hook views. ## Testing - Cover handler discovery, timeout normalization, output parsing, protocol compatibility, TUI rendering, and interrupt execution ordering. GitOrigin-RevId: 163fa7c098d94ac2775f6d137f8e916f8ea9b6eb
This commit is contained in:
1 parent
9b2ef38f54
commit
cbfd999db7
49 files changed
+1393
-48
No files matched your search
@@ -20,7 +20,7 @@ pub use engine::dispatcher::hook_execution_mode_label;
|
||||
pub use engine::dispatcher::hook_handler_type_label;
|
||||
pub use events::common::SubagentHookContext;
|
||||
/// Hook event names as they appear in hooks JSON and config files.
|
||||
pub const HOOK_EVENT_NAMES: [&str; 11] = [
|
||||
pub const HOOK_EVENT_NAMES: [&str; 12] = [
|
||||
"PreToolUse",
|
||||
"PermissionRequest",
|
||||
"PostToolUse",
|
||||
@@ -32,6 +32,7 @@ pub const HOOK_EVENT_NAMES: [&str; 11] = [
|
||||
"SubagentStart",
|
||||
"SubagentStop",
|
||||
"Stop",
|
||||
"Interrupt",
|
||||
];
|
||||
|
||||
/// Hook event names whose matcher fields are meaningful during dispatch.
|
||||
@@ -55,6 +56,8 @@ pub use events::compact::PostCompactRequest;
|
||||
pub use events::compact::PreCompactOutcome;
|
||||
pub use events::compact::PreCompactRequest;
|
||||
pub use events::compact::StatelessHookOutcome;
|
||||
pub use events::interrupt::InterruptOutcome;
|
||||
pub use events::interrupt::InterruptRequest;
|
||||
pub use events::permission_request::PermissionRequestDecision;
|
||||
pub use events::permission_request::PermissionRequestOutcome;
|
||||
pub use events::permission_request::PermissionRequestRequest;
|
||||
@@ -102,6 +105,7 @@ pub fn hook_event_key_label(event_name: HookEventName) -> &'static str {
|
||||
HookEventName::SubagentStart => "subagent_start",
|
||||
HookEventName::SubagentStop => "subagent_stop",
|
||||
HookEventName::Stop => "stop",
|
||||
HookEventName::Interrupt => "interrupt",
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user