mirror of
https://github.com/openai/codex.git
synced 2026-10-31 19:28:49 +00:00
## What changed - Add discovery and listing APIs for environment-owned required hooks, with command and MCP execution routed to the owning environment. - Use each environment's working directory in hook input, withhold controller transcript paths, and prevent environment hooks from granting permission requests. - Resolve `command_windows` against the environment's platform and, when hooks are enabled, reject unloadable required hooks before accepting environment configurations at startup or readiness. ## Testing Add regression coverage for invalid managed hook matchers at startup and readiness, successful readiness after correction, and per-hook working directory and transcript path scoping for `SubagentStop`. GitOrigin-RevId: 1ac0ab3778ba608c72e5917fcbaebcc1d454887f
36 lines
1.1 KiB
Rust
36 lines
1.1 KiB
Rust
//! Owner-admitted hooks bound to the exact environment that supplied them.
|
|
|
|
use std::collections::HashMap;
|
|
use std::time::Duration;
|
|
|
|
use codex_protocol::hooks::HookEventsToml;
|
|
use codex_utils_path_uri::PathUri;
|
|
use futures::future::BoxFuture;
|
|
|
|
/// An admitted requirements source. The owner must not populate this from user configuration.
|
|
pub struct EnvironmentHookSource {
|
|
pub environment_id: String,
|
|
/// Working directory from the same captured environment used for execution.
|
|
pub cwd: PathUri,
|
|
pub hooks: HookEventsToml,
|
|
}
|
|
|
|
/// Executes commands in ready environments without coupling the hooks engine to core or transports.
|
|
/// Implementations must honor the timeout, terminate timed-out processes, and bound captured output.
|
|
pub trait HookEnvironmentExecutor: Send + Sync {
|
|
fn execute(
|
|
&self,
|
|
environment_id: &str,
|
|
command: &str,
|
|
env: &HashMap<String, String>,
|
|
input_json: &str,
|
|
timeout: Duration,
|
|
) -> BoxFuture<'_, anyhow::Result<EnvironmentHookOutput>>;
|
|
}
|
|
|
|
pub struct EnvironmentHookOutput {
|
|
pub exit_code: i32,
|
|
pub stdout: String,
|
|
pub stderr: String,
|
|
}
|