Require approval for input to escalated terminals (#40978)

## What changed

- Add the `write_stdin_approval` feature flag, disabled by default, to require a fresh approval before sending non-empty input to an escalated unified-exec terminal.
- Route these reviews through hooks, Guardian, app-server, and the TUI as `writeStdin` approvals while keeping the parent command item unchanged.
- Preserve the terminal environment, launch directory, and escalation state across turns, and revalidate the process identity after approval before writing input.

## Testing

- Cover approval routing, policy decisions, process reuse, terminal identity preservation, app-server events, analytics, and TUI rendering.

GitOrigin-RevId: 4ba29eaae6208e934737ba078c96e589c7c2164d
This commit is contained in:
Dylan Hurd authored and copyberry committed 2026-08-26 21:39:05 +00:00
1 parent 21ff2e802c
commit a57b398351
41 files changed
+861 -169

No files matched your search

@@ -352,6 +352,7 @@ fn exec_server_env_keeps_command_native_and_carries_sandbox_context() {
let request = attempt
.env_for_exec_server(command(), options())
.expect("prepare remote exec request");
assert!(!attempt.is_escalated());
assert_eq!(
request.command,
@@ -390,8 +391,15 @@ fn exec_server_env_keeps_command_native_and_carries_sandbox_context() {
let request = attempt
.env_for_exec_server(command(), options())
.expect("prepare unsandboxed remote exec request");
assert!(attempt.is_escalated());
assert_eq!(request.exec_server_sandbox, None);
assert!(!request.exec_server_enforce_managed_network);
assert_eq!(request.exec_server_managed_network, Some(managed_network));
let full_access = codex_protocol::models::PermissionProfile::Disabled;
attempt.permissions = &full_access;
attempt.exec_server_permissions = &full_access;
attempt.enforce_managed_network = false;
assert!(!attempt.is_escalated(), "full access is not an escalation");
}