mirror of
https://github.com/openai/codex.git
synced 2026-11-08 20:40:33 +00:00
## Why After `hooks/list` exposes the hook inventory, clients need a way to persist user hook preferences, make those changes effective in already-open sessions, and distinguish user-controllable hooks from managed requirements without adding another bespoke app-server write API. ## What - Extends `hooks/list` entries with effective `enabled` state. - Persists user-level hook state under `hooks.state.<hook-id>` so the model can grow beyond a single boolean over time. - Uses the existing `config/batchWrite` path for hook state updates instead of introducing a dedicated hook write RPC. - Refreshes live session hook engines after config writes so already-open threads observe updated enablement without a restart. ## Stack 1. openai/codex#19705 2. openai/codex#19778 3. This PR - openai/codex#19840 4. openai/codex#19882 ## Reviewer Notes The generated schema files account for much of the raw diff. The core behavior is in: - `hooks/src/config_rules.rs`, which resolves per-hook user state from the config layer stack. - `hooks/src/engine/discovery.rs`, which projects effective enablement into `hooks/list` from source-derived managedness. - `config/src/hook_config.rs`, which defines the new `hooks.state` representation. - `core/src/session/mod.rs`, which rebuilds live hook state after user config reloads. --------- Co-authored-by: Codex <noreply@openai.com>
76 lines
3.3 KiB
Rust
76 lines
3.3 KiB
Rust
use std::collections::HashMap;
|
|
use std::sync::Arc;
|
|
|
|
use crate::SkillsManager;
|
|
use crate::agent::AgentControl;
|
|
use crate::client::ModelClient;
|
|
use crate::config::StartedNetworkProxy;
|
|
use crate::exec_policy::ExecPolicyManager;
|
|
use crate::guardian::GuardianRejection;
|
|
use crate::guardian::GuardianRejectionCircuitBreaker;
|
|
use crate::mcp::McpManager;
|
|
use crate::plugins::PluginsManager;
|
|
use crate::skills_watcher::SkillsWatcher;
|
|
use crate::tools::code_mode::CodeModeService;
|
|
use crate::tools::network_approval::NetworkApprovalService;
|
|
use crate::tools::sandboxing::ApprovalStore;
|
|
use crate::unified_exec::UnifiedExecProcessManager;
|
|
use arc_swap::ArcSwap;
|
|
use codex_analytics::AnalyticsEventsClient;
|
|
use codex_exec_server::EnvironmentManager;
|
|
use codex_hooks::Hooks;
|
|
use codex_login::AuthManager;
|
|
use codex_mcp::McpConnectionManager;
|
|
use codex_models_manager::manager::SharedModelsManager;
|
|
use codex_otel::SessionTelemetry;
|
|
use codex_rollout::state_db::StateDbHandle;
|
|
use codex_rollout_trace::ThreadTraceContext;
|
|
use codex_thread_store::LiveThread;
|
|
use codex_thread_store::ThreadStore;
|
|
use std::path::PathBuf;
|
|
use tokio::runtime::Handle;
|
|
use tokio::sync::Mutex;
|
|
use tokio::sync::RwLock;
|
|
use tokio::sync::watch;
|
|
use tokio_util::sync::CancellationToken;
|
|
|
|
pub(crate) struct SessionServices {
|
|
pub(crate) mcp_connection_manager: Arc<RwLock<McpConnectionManager>>,
|
|
pub(crate) mcp_startup_cancellation_token: Mutex<CancellationToken>,
|
|
pub(crate) unified_exec_manager: UnifiedExecProcessManager,
|
|
#[cfg_attr(not(unix), allow(dead_code))]
|
|
pub(crate) shell_zsh_path: Option<PathBuf>,
|
|
#[cfg_attr(not(unix), allow(dead_code))]
|
|
pub(crate) main_execve_wrapper_exe: Option<PathBuf>,
|
|
pub(crate) analytics_events_client: AnalyticsEventsClient,
|
|
pub(crate) hooks: ArcSwap<Hooks>,
|
|
pub(crate) rollout_thread_trace: ThreadTraceContext,
|
|
pub(crate) user_shell: Arc<crate::shell::Shell>,
|
|
pub(crate) shell_snapshot_tx: watch::Sender<Option<Arc<crate::shell_snapshot::ShellSnapshot>>>,
|
|
pub(crate) show_raw_agent_reasoning: bool,
|
|
pub(crate) exec_policy: Arc<ExecPolicyManager>,
|
|
pub(crate) auth_manager: Arc<AuthManager>,
|
|
pub(crate) models_manager: SharedModelsManager,
|
|
pub(crate) session_telemetry: SessionTelemetry,
|
|
pub(crate) tool_approvals: Mutex<ApprovalStore>,
|
|
pub(crate) guardian_rejections: Mutex<HashMap<String, GuardianRejection>>,
|
|
pub(crate) guardian_rejection_circuit_breaker: Mutex<GuardianRejectionCircuitBreaker>,
|
|
pub(crate) runtime_handle: Handle,
|
|
pub(crate) skills_manager: Arc<SkillsManager>,
|
|
pub(crate) plugins_manager: Arc<PluginsManager>,
|
|
pub(crate) mcp_manager: Arc<McpManager>,
|
|
pub(crate) skills_watcher: Arc<SkillsWatcher>,
|
|
pub(crate) agent_control: AgentControl,
|
|
pub(crate) network_proxy: Option<StartedNetworkProxy>,
|
|
pub(crate) network_approval: Arc<NetworkApprovalService>,
|
|
pub(crate) state_db: Option<StateDbHandle>,
|
|
pub(crate) live_thread: Option<LiveThread>,
|
|
pub(crate) thread_store: Arc<dyn ThreadStore>,
|
|
/// Session-scoped model client shared across turns.
|
|
pub(crate) model_client: ModelClient,
|
|
pub(crate) code_mode_service: CodeModeService,
|
|
/// Shared process-level environment registry. Sessions carry an `Arc` handle so they can pass
|
|
/// the same manager through child-thread spawn paths without reconstructing it.
|
|
pub(crate) environment_manager: Arc<EnvironmentManager>,
|
|
}
|