mirror of
https://github.com/openai/codex.git
synced 2026-11-21 22:50:37 +00:00
## Why `codex exec resume` sends the current process's sandbox defaults as overrides. A session started with `:read-only` can therefore resume with workspace write access when the configured default is `:workspace`. ## What changed - Restore the saved permission selection, working directory, and workspace roots by default. Honor explicit overrides and append directories requested with `--add-dir` to the resumed workspace roots. - Recover built-in read-only permissions from older history without widening current read access. Require an explicit permission selection when a saved named profile cannot be loaded or saved read-only access cannot be restored. - Report sandbox permissions and writable roots from the running thread. ## Testing Add regression coverage for a denied write on the first resumed shell call, legacy read-only history, explicit permission overrides, and workspace root preservation with and without `--add-dir`. GitOrigin-RevId: ed2cf3132f9ce34570661f801c9534a55696e3a5
52 lines
1.6 KiB
Rust
52 lines
1.6 KiB
Rust
use anyhow::Context;
|
|
use std::path::Path;
|
|
|
|
use codex_app_server_protocol::ServerNotification;
|
|
use codex_core::config::Config;
|
|
use codex_exec_server::BoundOutput;
|
|
use codex_protocol::protocol::SessionConfiguredEvent;
|
|
use codex_utils_path_uri::PathUri;
|
|
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
pub enum CodexStatus {
|
|
Running,
|
|
InitiateShutdown,
|
|
}
|
|
|
|
pub(crate) trait EventProcessor {
|
|
/// Print summary of effective configuration and user prompt.
|
|
fn print_config_summary(
|
|
&mut self,
|
|
config: &Config,
|
|
prompt: &str,
|
|
session_configured: &SessionConfiguredEvent,
|
|
workspace_roots: &[PathUri],
|
|
);
|
|
|
|
fn print_thread_started(&mut self, thread_id: &str);
|
|
|
|
/// Handle a single typed app-server notification emitted by the agent.
|
|
fn process_server_notification(&mut self, notification: ServerNotification) -> CodexStatus;
|
|
|
|
/// Handle a local exec warning that is not represented as an app-server notification.
|
|
fn process_warning(&mut self, message: String) -> CodexStatus;
|
|
|
|
fn print_final_output(&mut self, output: Option<BoundOutput>) -> anyhow::Result<()>;
|
|
}
|
|
|
|
pub(crate) fn handle_last_message(
|
|
last_agent_message: Option<&str>,
|
|
path: &Path,
|
|
file: BoundOutput,
|
|
) -> anyhow::Result<()> {
|
|
file.write(last_agent_message.unwrap_or_default().as_bytes())
|
|
.with_context(|| format!("Failed to write last message file {path:?}"))?;
|
|
if last_agent_message.is_none() {
|
|
eprintln!(
|
|
"Warning: no last agent message; wrote empty content to {}",
|
|
path.display()
|
|
);
|
|
}
|
|
Ok(())
|
|
}
|