mirror of
https://github.com/openai/codex.git
synced 2026-10-26 18:38:47 +00:00
permissions: finish profile-backed app surfaces
This commit is contained in:
@@ -575,7 +575,6 @@ async fn run_exec_session(args: ExecRunArgs) -> anyhow::Result<()> {
|
||||
|
||||
let default_cwd = config.cwd.to_path_buf();
|
||||
let default_approval_policy = config.permissions.approval_policy.value();
|
||||
let default_sandbox_policy = config.permissions.sandbox_policy.get();
|
||||
let default_effort = config.model_reasoning_effort;
|
||||
|
||||
let (initial_operation, prompt_summary) = match (command.as_ref(), prompt, images) {
|
||||
@@ -717,7 +716,7 @@ async fn run_exec_session(args: ExecRunArgs) -> anyhow::Result<()> {
|
||||
event_processor.print_config_summary(&config, &prompt_summary, &session_configured);
|
||||
if !json_mode
|
||||
&& let Some(message) =
|
||||
codex_core::config::system_bwrap_warning(config.permissions.sandbox_policy.get())
|
||||
codex_core::config::system_bwrap_warning(config.permissions.permission_profile.get())
|
||||
{
|
||||
event_processor.process_warning(message);
|
||||
}
|
||||
@@ -737,10 +736,7 @@ async fn run_exec_session(args: ExecRunArgs) -> anyhow::Result<()> {
|
||||
items,
|
||||
output_schema,
|
||||
} => {
|
||||
let permission_profile = permission_profile_override_from_config(&config);
|
||||
let sandbox_policy = permission_profile
|
||||
.is_none()
|
||||
.then(|| default_sandbox_policy.clone().into());
|
||||
let permission_profile = Some(config.permissions.permission_profile().into());
|
||||
let response: TurnStartResponse = send_request_with_response(
|
||||
&client,
|
||||
ClientRequest::TurnStart {
|
||||
@@ -753,7 +749,7 @@ async fn run_exec_session(args: ExecRunArgs) -> anyhow::Result<()> {
|
||||
cwd: Some(default_cwd),
|
||||
approval_policy: Some(default_approval_policy.into()),
|
||||
approvals_reviewer: None,
|
||||
sandbox_policy,
|
||||
sandbox_policy: None,
|
||||
permission_profile,
|
||||
model: None,
|
||||
service_tier: None,
|
||||
@@ -910,37 +906,15 @@ async fn run_exec_session(args: ExecRunArgs) -> anyhow::Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn sandbox_mode_from_policy(
|
||||
sandbox_policy: &codex_protocol::protocol::SandboxPolicy,
|
||||
) -> Option<codex_app_server_protocol::SandboxMode> {
|
||||
match sandbox_policy {
|
||||
codex_protocol::protocol::SandboxPolicy::DangerFullAccess => {
|
||||
Some(codex_app_server_protocol::SandboxMode::DangerFullAccess)
|
||||
}
|
||||
codex_protocol::protocol::SandboxPolicy::ReadOnly { .. } => {
|
||||
Some(codex_app_server_protocol::SandboxMode::ReadOnly)
|
||||
}
|
||||
codex_protocol::protocol::SandboxPolicy::WorkspaceWrite { .. } => {
|
||||
Some(codex_app_server_protocol::SandboxMode::WorkspaceWrite)
|
||||
}
|
||||
codex_protocol::protocol::SandboxPolicy::ExternalSandbox { .. } => None,
|
||||
}
|
||||
}
|
||||
|
||||
fn thread_start_params_from_config(config: &Config) -> ThreadStartParams {
|
||||
let permission_profile = permission_profile_override_from_config(config);
|
||||
let sandbox = permission_profile
|
||||
.is_none()
|
||||
.then(|| sandbox_mode_from_policy(config.permissions.sandbox_policy.get()))
|
||||
.flatten();
|
||||
ThreadStartParams {
|
||||
model: config.model.clone(),
|
||||
model_provider: Some(config.model_provider_id.clone()),
|
||||
cwd: Some(config.cwd.to_string_lossy().to_string()),
|
||||
approval_policy: Some(config.permissions.approval_policy.value().into()),
|
||||
approvals_reviewer: approvals_reviewer_override_from_config(config),
|
||||
sandbox,
|
||||
permission_profile,
|
||||
sandbox: None,
|
||||
permission_profile: Some(config.permissions.permission_profile().into()),
|
||||
config: config_request_overrides_from_config(config),
|
||||
ephemeral: Some(config.ephemeral),
|
||||
..ThreadStartParams::default()
|
||||
@@ -948,11 +922,6 @@ fn thread_start_params_from_config(config: &Config) -> ThreadStartParams {
|
||||
}
|
||||
|
||||
fn thread_resume_params_from_config(config: &Config, thread_id: String) -> ThreadResumeParams {
|
||||
let permission_profile = permission_profile_override_from_config(config);
|
||||
let sandbox = permission_profile
|
||||
.is_none()
|
||||
.then(|| sandbox_mode_from_policy(config.permissions.sandbox_policy.get()))
|
||||
.flatten();
|
||||
ThreadResumeParams {
|
||||
thread_id,
|
||||
model: config.model.clone(),
|
||||
@@ -960,26 +929,13 @@ fn thread_resume_params_from_config(config: &Config, thread_id: String) -> Threa
|
||||
cwd: Some(config.cwd.to_string_lossy().to_string()),
|
||||
approval_policy: Some(config.permissions.approval_policy.value().into()),
|
||||
approvals_reviewer: approvals_reviewer_override_from_config(config),
|
||||
sandbox,
|
||||
permission_profile,
|
||||
sandbox: None,
|
||||
permission_profile: Some(config.permissions.permission_profile().into()),
|
||||
config: config_request_overrides_from_config(config),
|
||||
..ThreadResumeParams::default()
|
||||
}
|
||||
}
|
||||
|
||||
fn permission_profile_override_from_config(
|
||||
config: &Config,
|
||||
) -> Option<codex_app_server_protocol::PermissionProfile> {
|
||||
if matches!(
|
||||
config.permissions.sandbox_policy.get(),
|
||||
SandboxPolicy::ExternalSandbox { .. }
|
||||
) {
|
||||
None
|
||||
} else {
|
||||
Some(config.permissions.permission_profile().into())
|
||||
}
|
||||
}
|
||||
|
||||
fn config_request_overrides_from_config(config: &Config) -> Option<HashMap<String, Value>> {
|
||||
config
|
||||
.active_profile
|
||||
|
||||
Reference in New Issue
Block a user