Skip to content

armgit / codex

Public Imported from GitHub
0

Lightweight coding agent that runs in your terminal

Rust

Remove TUI exec-policy core exports (#31179)

Eric Traut8f5bb6171e0b
diff --git a/codex-rs/app-server-client/src/lib.rs b/codex-rs/app-server-client/src/lib.rs
index b7a958eff1..4eec8a2348 100644
--- a/codex-rs/app-server-client/src/lib.rs
+++ b/codex-rs/app-server-client/src/lib.rs
@@ -78,9 +78,6 @@ pub use crate::remote::RemoteAppServerEndpoint;
/// module exists so clients can remove a direct `codex-core` dependency
/// while legacy startup/config paths are migrated to RPCs.
pub mod legacy_core {
- pub use codex_core::check_execpolicy_for_warnings;
- pub use codex_core::format_exec_policy_error_with_source;
-
pub mod config {
pub use codex_core::config::*;
diff --git a/codex-rs/app-server/src/in_process.rs b/codex-rs/app-server/src/in_process.rs
index 938d539a9f..d8a2bc2276 100644
--- a/codex-rs/app-server/src/in_process.rs
+++ b/codex-rs/app-server/src/in_process.rs
@@ -80,6 +80,7 @@ use codex_arg0::Arg0DispatchPaths;
use codex_config::CloudConfigBundleLoader;
use codex_config::LoaderOverrides;
use codex_config::ThreadConfigLoader;
+use codex_core::check_execpolicy_for_warnings;
use codex_core::config::Config;
use codex_core::resolve_installation_id;
use codex_exec_server::EnvironmentManager;
@@ -349,7 +350,16 @@ impl InProcessClientHandle {
/// This function sends `initialize` followed by `initialized` before returning
/// the handle, so callers receive a ready-to-use runtime. If initialize fails,
/// the runtime is shut down and an `InvalidData` error is returned.
-pub async fn start(args: InProcessStartArgs) -> IoResult<InProcessClientHandle> {
+pub async fn start(mut args: InProcessStartArgs) -> IoResult<InProcessClientHandle> {
+ if let Ok(Some(err)) = check_execpolicy_for_warnings(&args.config.config_layer_stack).await {
+ let (path, range) = crate::exec_policy_warning_location(&err);
+ args.config_warnings.push(ConfigWarningNotification {
+ summary: "Error parsing rules; custom rules not applied.".to_string(),
+ details: Some(err.to_string()),
+ path,
+ range,
+ });
+ }
let initialize = args.initialize.clone();
let client = start_uninitialized(args).await?;
diff --git a/codex-rs/tui/src/lib.rs b/codex-rs/tui/src/lib.rs
index 96f442a88c..dc8262f7db 100644
--- a/codex-rs/tui/src/lib.rs
+++ b/codex-rs/tui/src/lib.rs
@@ -3,7 +3,6 @@
// alternate‑screen mode starts; that file opts‑out locally via `allow`.
#![deny(clippy::print_stdout, clippy::print_stderr)]
#![deny(clippy::disallowed_methods)]
-use crate::legacy_core::check_execpolicy_for_warnings;
use crate::legacy_core::config::Config;
use crate::legacy_core::config::ConfigBuilder;
use crate::legacy_core::config::ConfigOverrides;
@@ -13,7 +12,6 @@ use crate::legacy_core::config::resolve_bootstrap_auth_keyring_backend_kind;
use crate::legacy_core::config::resolve_bootstrap_auth_route_config;
use crate::legacy_core::config::resolve_oss_provider;
use crate::legacy_core::config::resolve_profile_v2_config_path;
-use crate::legacy_core::format_exec_policy_error_with_source;
use crate::session_resume::ResolveCwdOutcome;
use crate::session_resume::resolve_cwd_for_resume_or_fork;
pub use crate::startup_error::LocalStateDbStartupError;
@@ -1141,18 +1139,6 @@ pub async fn run_main(
.as_table()
.is_some_and(|table| table.contains_key("log_dir"));
- #[allow(clippy::print_stderr)]
- match check_execpolicy_for_warnings(&config.config_layer_stack).await {
- Ok(None) => {}
- Ok(Some(err)) | Err(err) => {
- eprintln!(
- "Error loading rules:\n{}",
- format_exec_policy_error_with_source(&err)
- );
- std::process::exit(1);
- }
- }
-
set_default_client_residency_requirement(config.enforce_residency.value());
if let Some(warning) = add_dir_warning_message(