mirror of
https://github.com/openai/codex.git
synced 2026-12-06 01:10:58 +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
@@ -25,6 +25,8 @@ pub(crate) struct GeneratedHookSchemas {
|
||||
pub user_prompt_submit_command_output: Value,
|
||||
pub stop_command_input: Value,
|
||||
pub stop_command_output: Value,
|
||||
pub interrupt_command_input: Value,
|
||||
pub interrupt_command_output: Value,
|
||||
}
|
||||
|
||||
pub(crate) fn generated_hook_schemas() -> &'static GeneratedHookSchemas {
|
||||
@@ -114,6 +116,14 @@ pub(crate) fn generated_hook_schemas() -> &'static GeneratedHookSchemas {
|
||||
"stop.command.output",
|
||||
include_str!("../../schema/generated/stop.command.output.schema.json"),
|
||||
),
|
||||
interrupt_command_input: parse_json_schema(
|
||||
"interrupt.command.input",
|
||||
include_str!("../../schema/generated/interrupt.command.input.schema.json"),
|
||||
),
|
||||
interrupt_command_output: parse_json_schema(
|
||||
"interrupt.command.output",
|
||||
include_str!("../../schema/generated/interrupt.command.output.schema.json"),
|
||||
),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -152,5 +162,7 @@ mod tests {
|
||||
assert_eq!(schemas.user_prompt_submit_command_output["type"], "object");
|
||||
assert_eq!(schemas.stop_command_input["type"], "object");
|
||||
assert_eq!(schemas.stop_command_output["type"], "object");
|
||||
assert_eq!(schemas.interrupt_command_input["type"], "object");
|
||||
assert_eq!(schemas.interrupt_command_output["type"], "object");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user