mirror of
https://github.com/openai/codex.git
synced 2026-11-18 22:20:48 +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:
committed by
copyberry
parent
9b2ef38f54
commit
cbfd999db7
@@ -6,6 +6,8 @@ use crate::events::compact::PostCompactRequest;
|
||||
use crate::events::compact::PreCompactOutcome;
|
||||
use crate::events::compact::PreCompactRequest;
|
||||
use crate::events::compact::StatelessHookOutcome;
|
||||
use crate::events::interrupt::InterruptOutcome;
|
||||
use crate::events::interrupt::InterruptRequest;
|
||||
use crate::events::permission_request::PermissionRequestOutcome;
|
||||
use crate::events::permission_request::PermissionRequestRequest;
|
||||
use crate::events::post_tool_use::PostToolUseOutcome;
|
||||
@@ -276,6 +278,14 @@ impl Hooks {
|
||||
pub async fn run_session_end(&self, request: SessionEndRequest) -> SessionEndOutcome {
|
||||
self.engine.run_session_end(request).await
|
||||
}
|
||||
|
||||
pub fn preview_interrupt(&self) -> Vec<codex_protocol::protocol::HookRunSummary> {
|
||||
self.engine.preview_interrupt()
|
||||
}
|
||||
|
||||
pub async fn run_interrupt(&self, request: InterruptRequest) -> InterruptOutcome {
|
||||
self.engine.run_interrupt(request).await
|
||||
}
|
||||
}
|
||||
|
||||
pub fn list_hooks(config: HooksConfig) -> HookListOutcome {
|
||||
|
||||
Reference in New Issue
Block a user