feat: introduce ClientRequest::SendUserTurn (#2345)

This adds a new request type, `SendUserTurn`, that makes it possible to
submit a `Op::UserTurn` operation (introduced in #2329) to a
conversation. This PR also adds a new integration test that verifies
that changing from `AskForApproval::UnlessTrusted` to
`AskForApproval::Never` mid-conversation ensures that an elicitation is
no longer sent for running `python3 -c print(42)`.

---
[//]: # (BEGIN SAPLING FOOTER)
Stack created with [Sapling](https://sapling-scm.com). Best reviewed
with [ReviewStack](https://reviewstack.dev/openai/codex/pull/2345).
* __->__ #2345
* #2329
* #2343
* #2340
* #2338
This commit is contained in:
Michael Bolin
2025-08-15 10:05:58 -07:00
committed by GitHub
parent 17aa394ae7
commit eda50d8372
4 changed files with 279 additions and 1 deletions

View File

@@ -2,8 +2,12 @@ use std::collections::HashMap;
use std::fmt::Display;
use std::path::PathBuf;
use codex_core::config_types::ReasoningEffort;
use codex_core::config_types::ReasoningSummary;
use codex_core::protocol::AskForApproval;
use codex_core::protocol::FileChange;
use codex_core::protocol::ReviewDecision;
use codex_core::protocol::SandboxPolicy;
use mcp_types::RequestId;
use serde::Deserialize;
use serde::Serialize;
@@ -36,6 +40,11 @@ pub enum ClientRequest {
request_id: RequestId,
params: SendUserMessageParams,
},
SendUserTurn {
#[serde(rename = "id")]
request_id: RequestId,
params: SendUserTurnParams,
},
InterruptConversation {
#[serde(rename = "id")]
request_id: RequestId,
@@ -120,6 +129,23 @@ pub struct SendUserMessageParams {
pub items: Vec<InputItem>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct SendUserTurnParams {
pub conversation_id: ConversationId,
pub items: Vec<InputItem>,
pub cwd: PathBuf,
pub approval_policy: AskForApproval,
pub sandbox_policy: SandboxPolicy,
pub model: String,
pub effort: ReasoningEffort,
pub summary: ReasoningSummary,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct SendUserTurnResponse {}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct InterruptConversationParams {