This commit is contained in:
jif-oai
2026-03-25 14:37:22 +00:00
parent ce3c6e28eb
commit 924ee68649
2 changed files with 29 additions and 26 deletions

View File

@@ -7,7 +7,7 @@ use crate::exec::ExecCapturePolicy;
use crate::exec::ExecExpiration;
use crate::sandboxing::ExecRequest;
use crate::tools::context::ExecCommandToolOutput;
use crate::truncate::approx_token_count;
use codex_utils_output_truncation::approx_token_count;
use crate::unified_exec::WriteStdinRequest;
use crate::unified_exec::process::OutputHandles;
use codex_sandboxing::SandboxType;
@@ -46,23 +46,27 @@ fn test_exec_request(
cwd: PathBuf,
env: HashMap<String, String>,
) -> ExecRequest {
ExecRequest {
let windows_sandbox_private_desktop = false;
let sandbox_policy = turn.sandbox_policy.get().clone();
let file_system_sandbox_policy = turn.file_system_sandbox_policy.clone();
let network_sandbox_policy = turn.network_sandbox_policy;
let network = None;
let arg0 = None;
ExecRequest::new(
command,
cwd,
env,
network: None,
expiration: ExecExpiration::DefaultTimeout,
capture_policy: ExecCapturePolicy::ShellTool,
sandbox: SandboxType::None,
windows_sandbox_level: turn.windows_sandbox_level,
windows_sandbox_private_desktop: false,
sandbox_permissions: SandboxPermissions::UseDefault,
sandbox_policy: turn.sandbox_policy.get().clone(),
file_system_sandbox_policy: turn.file_system_sandbox_policy.clone(),
network_sandbox_policy: turn.network_sandbox_policy,
justification: None,
arg0: None,
}
network,
ExecExpiration::DefaultTimeout,
ExecCapturePolicy::ShellTool,
SandboxType::None,
turn.windows_sandbox_level,
windows_sandbox_private_desktop,
sandbox_policy,
file_system_sandbox_policy,
network_sandbox_policy,
arg0,
)
}
async fn exec_command_with_tty(

View File

@@ -132,7 +132,6 @@ impl UnifiedExecProcess {
.writer_sender()
.send(data.to_vec())
.await
.map(|()| ())
.map_err(|_| UnifiedExecError::WriteToStdin),
ProcessHandle::Remote(process_handle) => {
match process_handle.write(data.to_vec()).await {
@@ -334,14 +333,17 @@ impl UnifiedExecProcess {
fn spawn_remote_output_task(
started: StartedExecProcess,
output_buffer: OutputBuffer,
output_notify: Arc<Notify>,
output_closed: Arc<AtomicBool>,
output_closed_notify: Arc<Notify>,
output_handles: OutputHandles,
output_tx: broadcast::Sender<Vec<u8>>,
state_tx: watch::Sender<ProcessState>,
cancellation_token: CancellationToken,
) -> JoinHandle<()> {
let OutputHandles {
output_buffer,
output_notify,
output_closed,
output_closed_notify,
cancellation_token,
} = output_handles;
let StartedExecProcess { mut events, .. } = started;
tokio::spawn(async move {
loop {
@@ -427,15 +429,12 @@ impl From<(StartedExecProcess, SandboxType)> for UnifiedExecProcess {
fn from((started, sandbox_type): (StartedExecProcess, SandboxType)) -> Self {
let process_handle = ProcessHandle::Remote(Arc::clone(&started.process));
let mut managed = Self::new(process_handle, sandbox_type, /*spawn_lifecycle*/ None);
let output_handles = managed.output_handles();
managed.output_task = Some(Self::spawn_remote_output_task(
started,
Arc::clone(&managed.output_buffer),
Arc::clone(&managed.output_notify),
Arc::clone(&managed.output_closed),
Arc::clone(&managed.output_closed_notify),
output_handles,
managed.output_tx.clone(),
managed.state_tx.clone(),
managed.cancellation_token.clone(),
));
managed
}