Revert "initial surface projection for sandbox"

This reverts commit 79d8f99a7f.
This commit is contained in:
Roy Han
2026-03-13 17:29:32 -07:00
parent 8c019789b3
commit f9570b714c
14 changed files with 27 additions and 300 deletions
@@ -204,11 +204,7 @@ impl ThreadHistoryBuilder {
.unwrap_or_else(|| self.new_turn(None));
let id = self.next_item_id();
let content = self.build_user_inputs(payload);
turn.items.push(ThreadItem::UserMessage {
id,
content,
metadata: None,
});
turn.items.push(ThreadItem::UserMessage { id, content });
self.current_turn = Some(turn);
}
@@ -218,12 +214,9 @@ impl ThreadHistoryBuilder {
}
let id = self.next_item_id();
self.ensure_turn().items.push(ThreadItem::AgentMessage {
id,
text,
phase,
metadata: None,
});
self.ensure_turn()
.items
.push(ThreadItem::AgentMessage { id, text, phase });
}
fn handle_agent_reasoning(&mut self, payload: &AgentReasoningEvent) {
@@ -243,7 +236,6 @@ impl ThreadHistoryBuilder {
id,
summary: vec![payload.text.clone()],
content: Vec::new(),
metadata: None,
});
}
@@ -264,7 +256,6 @@ impl ThreadHistoryBuilder {
id,
summary: Vec::new(),
content: vec![payload.text.clone()],
metadata: None,
});
}
@@ -313,7 +304,6 @@ impl ThreadHistoryBuilder {
id: payload.call_id.clone(),
query: String::new(),
action: None,
metadata: None,
};
self.upsert_item_in_current_turn(item);
}
@@ -323,7 +313,6 @@ impl ThreadHistoryBuilder {
id: payload.call_id.clone(),
query: payload.query.clone(),
action: Some(WebSearchAction::from(payload.action.clone())),
metadata: None,
};
self.upsert_item_in_current_turn(item);
}
@@ -347,7 +336,6 @@ impl ThreadHistoryBuilder {
aggregated_output: None,
exit_code: None,
duration_ms: None,
metadata: None,
};
self.upsert_item_in_turn_id(&payload.turn_id, item);
}
@@ -378,7 +366,6 @@ impl ThreadHistoryBuilder {
aggregated_output,
exit_code: Some(payload.exit_code),
duration_ms: Some(duration_ms),
metadata: None,
};
// Command completions can arrive out of order. Unified exec may return
// while a PTY is still running, then emit ExecCommandEnd later from a
@@ -393,7 +380,6 @@ impl ThreadHistoryBuilder {
id: payload.call_id.clone(),
changes: convert_patch_changes(&payload.changes),
status: PatchApplyStatus::InProgress,
metadata: None,
};
if payload.turn_id.is_empty() {
self.upsert_item_in_current_turn(item);
@@ -407,7 +393,6 @@ impl ThreadHistoryBuilder {
id: payload.call_id.clone(),
changes: convert_patch_changes(&payload.changes),
status: PatchApplyStatus::InProgress,
metadata: None,
};
if payload.turn_id.is_empty() {
self.upsert_item_in_current_turn(item);
@@ -422,7 +407,6 @@ impl ThreadHistoryBuilder {
id: payload.call_id.clone(),
changes: convert_patch_changes(&payload.changes),
status,
metadata: None,
};
if payload.turn_id.is_empty() {
self.upsert_item_in_current_turn(item);
@@ -443,7 +427,6 @@ impl ThreadHistoryBuilder {
content_items: None,
success: None,
duration_ms: None,
metadata: None,
};
if payload.turn_id.is_empty() {
self.upsert_item_in_current_turn(item);
@@ -467,7 +450,6 @@ impl ThreadHistoryBuilder {
content_items: Some(convert_dynamic_tool_content_items(&payload.content_items)),
success: Some(payload.success),
duration_ms,
metadata: None,
};
if payload.turn_id.is_empty() {
self.upsert_item_in_current_turn(item);
@@ -490,7 +472,6 @@ impl ThreadHistoryBuilder {
result: None,
error: None,
duration_ms: None,
metadata: None,
};
self.upsert_item_in_current_turn(item);
}
@@ -530,7 +511,6 @@ impl ThreadHistoryBuilder {
result,
error,
duration_ms,
metadata: None,
};
self.upsert_item_in_current_turn(item);
}
@@ -539,7 +519,6 @@ impl ThreadHistoryBuilder {
let item = ThreadItem::ImageView {
id: payload.call_id.clone(),
path: payload.path.to_string_lossy().into_owned(),
metadata: None,
};
self.upsert_item_in_current_turn(item);
}
@@ -550,7 +529,6 @@ impl ThreadHistoryBuilder {
status: String::new(),
revised_prompt: None,
result: String::new(),
metadata: None,
};
self.upsert_item_in_current_turn(item);
}
@@ -561,7 +539,6 @@ impl ThreadHistoryBuilder {
status: payload.status.clone(),
revised_prompt: payload.revised_prompt.clone(),
result: payload.result.clone(),
metadata: None,
};
self.upsert_item_in_current_turn(item);
}
@@ -580,7 +557,6 @@ impl ThreadHistoryBuilder {
model: Some(payload.model.clone()),
reasoning_effort: Some(payload.reasoning_effort),
agents_states: HashMap::new(),
metadata: None,
};
self.upsert_item_in_current_turn(item);
}
@@ -616,7 +592,6 @@ impl ThreadHistoryBuilder {
model: Some(payload.model.clone()),
reasoning_effort: Some(payload.reasoning_effort),
agents_states,
metadata: None,
});
}
@@ -634,7 +609,6 @@ impl ThreadHistoryBuilder {
model: None,
reasoning_effort: None,
agents_states: HashMap::new(),
metadata: None,
};
self.upsert_item_in_current_turn(item);
}
@@ -659,7 +633,6 @@ impl ThreadHistoryBuilder {
model: None,
reasoning_effort: None,
agents_states: [(receiver_id, received_status)].into_iter().collect(),
metadata: None,
});
}
@@ -681,7 +654,6 @@ impl ThreadHistoryBuilder {
model: None,
reasoning_effort: None,
agents_states: HashMap::new(),
metadata: None,
};
self.upsert_item_in_current_turn(item);
}
@@ -717,7 +689,6 @@ impl ThreadHistoryBuilder {
model: None,
reasoning_effort: None,
agents_states,
metadata: None,
});
}
@@ -735,7 +706,6 @@ impl ThreadHistoryBuilder {
model: None,
reasoning_effort: None,
agents_states: HashMap::new(),
metadata: None,
};
self.upsert_item_in_current_turn(item);
}
@@ -762,7 +732,6 @@ impl ThreadHistoryBuilder {
model: None,
reasoning_effort: None,
agents_states,
metadata: None,
});
}
@@ -780,7 +749,6 @@ impl ThreadHistoryBuilder {
model: None,
reasoning_effort: None,
agents_states: HashMap::new(),
metadata: None,
};
self.upsert_item_in_current_turn(item);
}
@@ -810,7 +778,6 @@ impl ThreadHistoryBuilder {
model: None,
reasoning_effort: None,
agents_states,
metadata: None,
});
}
@@ -818,7 +785,7 @@ impl ThreadHistoryBuilder {
let id = self.next_item_id();
self.ensure_turn()
.items
.push(ThreadItem::ContextCompaction { id, metadata: None });
.push(ThreadItem::ContextCompaction { id });
}
fn handle_entered_review_mode(&mut self, payload: &codex_protocol::protocol::ReviewRequest) {
@@ -829,11 +796,7 @@ impl ThreadHistoryBuilder {
let id = self.next_item_id();
self.ensure_turn()
.items
.push(ThreadItem::EnteredReviewMode {
id,
review,
metadata: None,
});
.push(ThreadItem::EnteredReviewMode { id, review });
}
fn handle_exited_review_mode(
@@ -846,11 +809,9 @@ impl ThreadHistoryBuilder {
.map(render_review_output_text)
.unwrap_or_else(|| REVIEW_FALLBACK_MESSAGE.to_string());
let id = self.next_item_id();
self.ensure_turn().items.push(ThreadItem::ExitedReviewMode {
id,
review,
metadata: None,
});
self.ensure_turn()
.items
.push(ThreadItem::ExitedReviewMode { id, review });
}
fn handle_error(&mut self, payload: &ErrorEvent) {
@@ -1260,7 +1221,6 @@ mod tests {
url: "https://example.com/one.png".into(),
}
],
metadata: None,
}
);
assert_eq!(
@@ -1269,7 +1229,6 @@ mod tests {
id: "item-2".into(),
text: "Hi there".into(),
phase: None,
metadata: None,
}
);
assert_eq!(
@@ -1278,7 +1237,6 @@ mod tests {
id: "item-3".into(),
summary: vec!["thinking".into()],
content: vec!["full reasoning".into()],
metadata: None,
}
);
@@ -1294,7 +1252,6 @@ mod tests {
text: "Second turn".into(),
text_elements: Vec::new(),
}],
metadata: None,
}
);
assert_eq!(
@@ -1303,7 +1260,6 @@ mod tests {
id: "item-5".into(),
text: "Reply two".into(),
phase: None,
metadata: None,
}
);
}
@@ -1330,7 +1286,6 @@ mod tests {
item: CoreTurnItem::UserMessage(CoreUserMessageItem {
id: "user-item-id".to_string(),
content: Vec::new(),
metadata: None,
}),
}),
EventMsg::TurnComplete(TurnCompleteEvent {
@@ -1354,7 +1309,6 @@ mod tests {
text: "hello".into(),
text_elements: Vec::new(),
}],
metadata: None,
}
);
}
@@ -1378,7 +1332,6 @@ mod tests {
id: "item-1".into(),
text: "Final reply".into(),
phase: Some(MessagePhase::FinalAnswer),
metadata: None,
}
);
}
@@ -1422,7 +1375,6 @@ mod tests {
id: "item-2".into(),
summary: vec!["first summary".into()],
content: vec!["first content".into()],
metadata: None,
}
);
assert_eq!(
@@ -1431,7 +1383,6 @@ mod tests {
id: "item-4".into(),
summary: vec!["second summary".into()],
content: Vec::new(),
metadata: None,
}
);
}
@@ -1483,7 +1434,6 @@ mod tests {
text: "Please do the thing".into(),
text_elements: Vec::new(),
}],
metadata: None,
}
);
assert_eq!(
@@ -1492,7 +1442,6 @@ mod tests {
id: "item-2".into(),
text: "Working...".into(),
phase: None,
metadata: None,
}
);
@@ -1507,7 +1456,6 @@ mod tests {
text: "Let's try again".into(),
text_elements: Vec::new(),
}],
metadata: None,
}
);
assert_eq!(
@@ -1516,7 +1464,6 @@ mod tests {
id: "item-4".into(),
text: "Second attempt complete.".into(),
phase: None,
metadata: None,
}
);
}
@@ -1577,13 +1524,11 @@ mod tests {
text: "First".into(),
text_elements: Vec::new(),
}],
metadata: None,
},
ThreadItem::AgentMessage {
id: "item-2".into(),
text: "A1".into(),
phase: None,
metadata: None,
},
]
);
@@ -1596,13 +1541,11 @@ mod tests {
text: "Third".into(),
text_elements: Vec::new(),
}],
metadata: None,
},
ThreadItem::AgentMessage {
id: "item-4".into(),
text: "A3".into(),
phase: None,
metadata: None,
},
]
);
@@ -1684,7 +1627,6 @@ mod tests {
text: "Start".into(),
text_elements: Vec::new(),
}],
metadata: None,
},
ThreadItem::UserMessage {
id: "item-2".into(),
@@ -1692,7 +1634,6 @@ mod tests {
text: "Steer".into(),
text_elements: Vec::new(),
}],
metadata: None,
},
]
);
@@ -1767,7 +1708,6 @@ mod tests {
query: Some("codex".into()),
queries: None,
}),
metadata: None,
}
);
assert_eq!(
@@ -1784,7 +1724,6 @@ mod tests {
aggregated_output: Some("hello world\n".into()),
exit_code: Some(0),
duration_ms: Some(12),
metadata: None,
}
);
assert_eq!(
@@ -1800,7 +1739,6 @@ mod tests {
message: "boom".into(),
}),
duration_ms: Some(8),
metadata: None,
}
);
}
@@ -1860,7 +1798,6 @@ mod tests {
}]),
success: Some(true),
duration_ms: Some(42),
metadata: None,
}
);
}
@@ -1935,7 +1872,6 @@ mod tests {
aggregated_output: Some("exec command rejected by user".into()),
exit_code: Some(-1),
duration_ms: Some(0),
metadata: None,
}
);
assert_eq!(
@@ -1948,7 +1884,6 @@ mod tests {
diff: "hello\n".into(),
}],
status: PatchApplyStatus::Declined,
metadata: None,
}
);
}
@@ -2031,7 +1966,6 @@ mod tests {
aggregated_output: Some("done\n".into()),
exit_code: Some(0),
duration_ms: Some(5),
metadata: None,
}
);
}
@@ -2108,7 +2042,6 @@ mod tests {
text: "second".into(),
text_elements: Vec::new(),
}],
metadata: None,
}
);
}
@@ -2162,7 +2095,6 @@ mod tests {
text: "apply patch".into(),
text_elements: Vec::new(),
}],
metadata: None,
},
ThreadItem::FileChange {
id: "patch-call".into(),
@@ -2172,7 +2104,6 @@ mod tests {
diff: "hello\n".into(),
}],
status: PatchApplyStatus::InProgress,
metadata: None,
},
]
);
@@ -2228,7 +2159,6 @@ mod tests {
text: "apply patch".into(),
text_elements: Vec::new(),
}],
metadata: None,
},
ThreadItem::FileChange {
id: "patch-call".into(),
@@ -2238,7 +2168,6 @@ mod tests {
diff: "hello\n".into(),
}],
status: PatchApplyStatus::InProgress,
metadata: None,
},
]
);
@@ -2427,7 +2356,6 @@ mod tests {
)]
.into_iter()
.collect(),
metadata: None,
}
);
}
@@ -2561,7 +2489,6 @@ mod tests {
text: "hello".into(),
text_elements: Vec::new(),
}],
metadata: None,
}],
}
);
+9 -110
View File
@@ -25,9 +25,7 @@ use codex_protocol::config_types::Verbosity;
use codex_protocol::config_types::WebSearchMode;
use codex_protocol::config_types::WebSearchToolConfig;
use codex_protocol::items::AgentMessageContent as CoreAgentMessageContent;
use codex_protocol::items::ItemSandboxPolicy as CoreItemSandboxPolicy;
use codex_protocol::items::TurnItem as CoreTurnItem;
use codex_protocol::items::TurnItemMetadata as CoreTurnItemMetadata;
use codex_protocol::mcp::Resource as McpResource;
use codex_protocol::mcp::ResourceTemplate as McpResourceTemplate;
use codex_protocol::mcp::Tool as McpTool;
@@ -3796,41 +3794,6 @@ pub enum UserInput {
},
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS)]
#[serde(rename_all = "snake_case")]
#[ts(rename_all = "snake_case", export_to = "v2/")]
pub enum ItemSandboxPolicy {
ReadOnly,
Sandbox,
FullAccess,
}
impl From<CoreItemSandboxPolicy> for ItemSandboxPolicy {
fn from(value: CoreItemSandboxPolicy) -> Self {
match value {
CoreItemSandboxPolicy::ReadOnly => ItemSandboxPolicy::ReadOnly,
CoreItemSandboxPolicy::Sandbox => ItemSandboxPolicy::Sandbox,
CoreItemSandboxPolicy::FullAccess => ItemSandboxPolicy::FullAccess,
}
}
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS)]
#[ts(export_to = "v2/")]
pub struct ItemMetadata {
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub sandbox_policy: Option<ItemSandboxPolicy>,
}
impl From<CoreTurnItemMetadata> for ItemMetadata {
fn from(value: CoreTurnItemMetadata) -> Self {
Self {
sandbox_policy: value.sandbox_policy.map(Into::into),
}
}
}
impl UserInput {
pub fn into_core(self) -> CoreUserInput {
match self {
@@ -3887,12 +3850,7 @@ impl UserInput {
pub enum ThreadItem {
#[serde(rename_all = "camelCase")]
#[ts(rename_all = "camelCase")]
UserMessage {
id: String,
content: Vec<UserInput>,
#[serde(default, skip_serializing_if = "Option::is_none")]
metadata: Option<ItemMetadata>,
},
UserMessage { id: String, content: Vec<UserInput> },
#[serde(rename_all = "camelCase")]
#[ts(rename_all = "camelCase")]
AgentMessage {
@@ -3900,19 +3858,12 @@ pub enum ThreadItem {
text: String,
#[serde(default)]
phase: Option<MessagePhase>,
#[serde(default, skip_serializing_if = "Option::is_none")]
metadata: Option<ItemMetadata>,
},
#[serde(rename_all = "camelCase")]
#[ts(rename_all = "camelCase")]
/// EXPERIMENTAL - proposed plan item content. The completed plan item is
/// authoritative and may not match the concatenation of `PlanDelta` text.
Plan {
id: String,
text: String,
#[serde(default, skip_serializing_if = "Option::is_none")]
metadata: Option<ItemMetadata>,
},
Plan { id: String, text: String },
#[serde(rename_all = "camelCase")]
#[ts(rename_all = "camelCase")]
Reasoning {
@@ -3921,8 +3872,6 @@ pub enum ThreadItem {
summary: Vec<String>,
#[serde(default)]
content: Vec<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
metadata: Option<ItemMetadata>,
},
#[serde(rename_all = "camelCase")]
#[ts(rename_all = "camelCase")]
@@ -3946,8 +3895,6 @@ pub enum ThreadItem {
/// The duration of the command execution in milliseconds.
#[ts(type = "number | null")]
duration_ms: Option<i64>,
#[serde(default, skip_serializing_if = "Option::is_none")]
metadata: Option<ItemMetadata>,
},
#[serde(rename_all = "camelCase")]
#[ts(rename_all = "camelCase")]
@@ -3955,8 +3902,6 @@ pub enum ThreadItem {
id: String,
changes: Vec<FileUpdateChange>,
status: PatchApplyStatus,
#[serde(default, skip_serializing_if = "Option::is_none")]
metadata: Option<ItemMetadata>,
},
#[serde(rename_all = "camelCase")]
#[ts(rename_all = "camelCase")]
@@ -3971,8 +3916,6 @@ pub enum ThreadItem {
/// The duration of the MCP tool call in milliseconds.
#[ts(type = "number | null")]
duration_ms: Option<i64>,
#[serde(default, skip_serializing_if = "Option::is_none")]
metadata: Option<ItemMetadata>,
},
#[serde(rename_all = "camelCase")]
#[ts(rename_all = "camelCase")]
@@ -3986,8 +3929,6 @@ pub enum ThreadItem {
/// The duration of the dynamic tool call in milliseconds.
#[ts(type = "number | null")]
duration_ms: Option<i64>,
#[serde(default, skip_serializing_if = "Option::is_none")]
metadata: Option<ItemMetadata>,
},
#[serde(rename_all = "camelCase")]
#[ts(rename_all = "camelCase")]
@@ -4007,8 +3948,6 @@ pub enum ThreadItem {
prompt: Option<String>,
/// Last known status of the target agents, when available.
agents_states: HashMap<String, CollabAgentState>,
#[serde(default, skip_serializing_if = "Option::is_none")]
metadata: Option<ItemMetadata>,
},
#[serde(rename_all = "camelCase")]
#[ts(rename_all = "camelCase")]
@@ -4016,17 +3955,10 @@ pub enum ThreadItem {
id: String,
query: String,
action: Option<WebSearchAction>,
#[serde(default, skip_serializing_if = "Option::is_none")]
metadata: Option<ItemMetadata>,
},
#[serde(rename_all = "camelCase")]
#[ts(rename_all = "camelCase")]
ImageView {
id: String,
path: String,
#[serde(default, skip_serializing_if = "Option::is_none")]
metadata: Option<ItemMetadata>,
},
ImageView { id: String, path: String },
#[serde(rename_all = "camelCase")]
#[ts(rename_all = "camelCase")]
ImageGeneration {
@@ -4034,32 +3966,16 @@ pub enum ThreadItem {
status: String,
revised_prompt: Option<String>,
result: String,
#[serde(default, skip_serializing_if = "Option::is_none")]
metadata: Option<ItemMetadata>,
},
#[serde(rename_all = "camelCase")]
#[ts(rename_all = "camelCase")]
EnteredReviewMode {
id: String,
review: String,
#[serde(default, skip_serializing_if = "Option::is_none")]
metadata: Option<ItemMetadata>,
},
EnteredReviewMode { id: String, review: String },
#[serde(rename_all = "camelCase")]
#[ts(rename_all = "camelCase")]
ExitedReviewMode {
id: String,
review: String,
#[serde(default, skip_serializing_if = "Option::is_none")]
metadata: Option<ItemMetadata>,
},
ExitedReviewMode { id: String, review: String },
#[serde(rename_all = "camelCase")]
#[ts(rename_all = "camelCase")]
ContextCompaction {
id: String,
#[serde(default, skip_serializing_if = "Option::is_none")]
metadata: Option<ItemMetadata>,
},
ContextCompaction { id: String },
}
impl ThreadItem {
@@ -4127,7 +4043,6 @@ impl From<CoreTurnItem> for ThreadItem {
CoreTurnItem::UserMessage(user) => ThreadItem::UserMessage {
id: user.id,
content: user.content.into_iter().map(UserInput::from).collect(),
metadata: user.metadata.map(Into::into),
},
CoreTurnItem::AgentMessage(agent) => {
let text = agent
@@ -4141,37 +4056,31 @@ impl From<CoreTurnItem> for ThreadItem {
id: agent.id,
text,
phase: agent.phase,
metadata: agent.metadata.map(Into::into),
}
}
CoreTurnItem::Plan(plan) => ThreadItem::Plan {
id: plan.id,
text: plan.text,
metadata: plan.metadata.map(Into::into),
},
CoreTurnItem::Reasoning(reasoning) => ThreadItem::Reasoning {
id: reasoning.id,
summary: reasoning.summary_text,
content: reasoning.raw_content,
metadata: reasoning.metadata.map(Into::into),
},
CoreTurnItem::WebSearch(search) => ThreadItem::WebSearch {
id: search.id,
query: search.query,
action: Some(WebSearchAction::from(search.action)),
metadata: search.metadata.map(Into::into),
},
CoreTurnItem::ImageGeneration(image) => ThreadItem::ImageGeneration {
id: image.id,
status: image.status,
revised_prompt: image.revised_prompt,
result: image.result,
metadata: image.metadata.map(Into::into),
},
CoreTurnItem::ContextCompaction(compaction) => ThreadItem::ContextCompaction {
id: compaction.id,
metadata: compaction.metadata.map(Into::into),
},
CoreTurnItem::ContextCompaction(compaction) => {
ThreadItem::ContextCompaction { id: compaction.id }
}
}
}
}
@@ -6898,7 +6807,6 @@ mod tests {
path: "app://demo-app".to_string(),
},
],
metadata: None,
});
assert_eq!(
@@ -6925,7 +6833,6 @@ mod tests {
path: "app://demo-app".to_string(),
},
],
metadata: None,
}
);
@@ -6940,7 +6847,6 @@ mod tests {
},
],
phase: None,
metadata: None,
});
assert_eq!(
@@ -6949,7 +6855,6 @@ mod tests {
id: "agent-1".to_string(),
text: "Hello world".to_string(),
phase: None,
metadata: None,
}
);
@@ -6959,7 +6864,6 @@ mod tests {
text: "final".to_string(),
}],
phase: Some(MessagePhase::FinalAnswer),
metadata: None,
});
assert_eq!(
@@ -6968,7 +6872,6 @@ mod tests {
id: "agent-2".to_string(),
text: "final".to_string(),
phase: Some(MessagePhase::FinalAnswer),
metadata: None,
}
);
@@ -6976,7 +6879,6 @@ mod tests {
id: "reasoning-1".to_string(),
summary_text: vec!["line one".to_string(), "line two".to_string()],
raw_content: vec![],
metadata: None,
});
assert_eq!(
@@ -6985,7 +6887,6 @@ mod tests {
id: "reasoning-1".to_string(),
summary: vec!["line one".to_string(), "line two".to_string()],
content: vec![],
metadata: None,
}
);
@@ -6996,7 +6897,6 @@ mod tests {
query: Some("docs".to_string()),
queries: None,
},
metadata: None,
});
assert_eq!(
@@ -7008,7 +6908,6 @@ mod tests {
query: Some("docs".to_string()),
queries: None,
}),
metadata: None,
}
);
}
@@ -389,7 +389,6 @@ pub(crate) async fn apply_bespoke_event_handling(
id: item_id.clone(),
changes: patch_changes.clone(),
status: PatchApplyStatus::InProgress,
metadata: None,
};
let notification = ItemStartedNotification {
thread_id: conversation_id.to_string(),
@@ -751,7 +750,6 @@ pub(crate) async fn apply_bespoke_event_handling(
content_items: None,
success: None,
duration_ms: None,
metadata: None,
};
let notification = ItemStartedNotification {
thread_id: conversation_id.to_string(),
@@ -822,7 +820,6 @@ pub(crate) async fn apply_bespoke_event_handling(
),
success: Some(response.success),
duration_ms,
metadata: None,
};
let notification = ItemCompletedNotification {
thread_id: conversation_id.to_string(),
@@ -868,7 +865,6 @@ pub(crate) async fn apply_bespoke_event_handling(
model: Some(begin_event.model),
reasoning_effort: Some(begin_event.reasoning_effort),
agents_states: HashMap::new(),
metadata: None,
};
let notification = ItemStartedNotification {
thread_id: conversation_id.to_string(),
@@ -908,7 +904,6 @@ pub(crate) async fn apply_bespoke_event_handling(
model: Some(end_event.model),
reasoning_effort: Some(end_event.reasoning_effort),
agents_states,
metadata: None,
};
let notification = ItemCompletedNotification {
thread_id: conversation_id.to_string(),
@@ -931,7 +926,6 @@ pub(crate) async fn apply_bespoke_event_handling(
model: None,
reasoning_effort: None,
agents_states: HashMap::new(),
metadata: None,
};
let notification = ItemStartedNotification {
thread_id: conversation_id.to_string(),
@@ -960,7 +954,6 @@ pub(crate) async fn apply_bespoke_event_handling(
model: None,
reasoning_effort: None,
agents_states: [(receiver_id, received_status)].into_iter().collect(),
metadata: None,
};
let notification = ItemCompletedNotification {
thread_id: conversation_id.to_string(),
@@ -987,7 +980,6 @@ pub(crate) async fn apply_bespoke_event_handling(
model: None,
reasoning_effort: None,
agents_states: HashMap::new(),
metadata: None,
};
let notification = ItemStartedNotification {
thread_id: conversation_id.to_string(),
@@ -1026,7 +1018,6 @@ pub(crate) async fn apply_bespoke_event_handling(
model: None,
reasoning_effort: None,
agents_states,
metadata: None,
};
let notification = ItemCompletedNotification {
thread_id: conversation_id.to_string(),
@@ -1048,7 +1039,6 @@ pub(crate) async fn apply_bespoke_event_handling(
model: None,
reasoning_effort: None,
agents_states: HashMap::new(),
metadata: None,
};
let notification = ItemStartedNotification {
thread_id: conversation_id.to_string(),
@@ -1091,7 +1081,6 @@ pub(crate) async fn apply_bespoke_event_handling(
model: None,
reasoning_effort: None,
agents_states,
metadata: None,
};
let notification = ItemCompletedNotification {
thread_id: conversation_id.to_string(),
@@ -1274,7 +1263,6 @@ pub(crate) async fn apply_bespoke_event_handling(
let item = ThreadItem::ImageView {
id: view_image_event.call_id.clone(),
path: view_image_event.path.to_string_lossy().into_owned(),
metadata: None,
};
let started = ItemStartedNotification {
thread_id: conversation_id.to_string(),
@@ -1300,7 +1288,6 @@ pub(crate) async fn apply_bespoke_event_handling(
let item = ThreadItem::EnteredReviewMode {
id: event_turn_id.clone(),
review,
metadata: None,
};
let started = ItemStartedNotification {
thread_id: conversation_id.to_string(),
@@ -1373,7 +1360,6 @@ pub(crate) async fn apply_bespoke_event_handling(
let item = ThreadItem::ExitedReviewMode {
id: event_turn_id.clone(),
review,
metadata: None,
};
let started = ItemStartedNotification {
thread_id: conversation_id.to_string(),
@@ -1420,7 +1406,6 @@ pub(crate) async fn apply_bespoke_event_handling(
id: item_id.clone(),
changes,
status: PatchApplyStatus::InProgress,
metadata: None,
};
let notification = ItemStartedNotification {
thread_id: conversation_id.to_string(),
@@ -1479,7 +1464,6 @@ pub(crate) async fn apply_bespoke_event_handling(
aggregated_output: None,
exit_code: None,
duration_ms: None,
metadata: None,
};
let notification = ItemStartedNotification {
thread_id: conversation_id.to_string(),
@@ -1589,7 +1573,6 @@ pub(crate) async fn apply_bespoke_event_handling(
aggregated_output,
exit_code: Some(exit_code),
duration_ms: Some(duration_ms),
metadata: None,
};
let notification = ItemCompletedNotification {
@@ -1829,7 +1812,6 @@ async fn complete_file_change_item(
id: item_id,
changes,
status,
metadata: None,
};
let notification = ItemCompletedNotification {
thread_id: conversation_id.to_string(),
@@ -1863,7 +1845,6 @@ async fn complete_command_execution_item(
aggregated_output: None,
exit_code: None,
duration_ms: None,
metadata: None,
};
let notification = ItemCompletedNotification {
thread_id: conversation_id.to_string(),
@@ -2553,7 +2534,6 @@ fn collab_resume_begin_item(
model: None,
reasoning_effort: None,
agents_states: HashMap::new(),
metadata: None,
}
}
@@ -2580,7 +2560,6 @@ fn collab_resume_end_item(end_event: codex_protocol::protocol::CollabResumeEndEv
model: None,
reasoning_effort: None,
agents_states,
metadata: None,
}
}
@@ -2599,7 +2578,6 @@ async fn construct_mcp_tool_call_notification(
result: None,
error: None,
duration_ms: None,
metadata: None,
};
ItemStartedNotification {
thread_id,
@@ -2646,7 +2624,6 @@ async fn construct_mcp_tool_call_end_notification(
result,
error,
duration_ms,
metadata: None,
};
ItemCompletedNotification {
thread_id,
@@ -2957,7 +2934,6 @@ mod tests {
model: None,
reasoning_effort: None,
agents_states: HashMap::new(),
metadata: None,
};
assert_eq!(item, expected);
}
@@ -2990,7 +2966,6 @@ mod tests {
)]
.into_iter()
.collect(),
metadata: None,
};
assert_eq!(item, expected);
}
@@ -3354,7 +3329,6 @@ mod tests {
result: None,
error: None,
duration_ms: None,
metadata: None,
},
};
@@ -3491,7 +3465,6 @@ mod tests {
result: None,
error: None,
duration_ms: None,
metadata: None,
},
};
@@ -3546,7 +3519,6 @@ mod tests {
}),
error: None,
duration_ms: Some(0),
metadata: None,
},
};
@@ -3589,7 +3561,6 @@ mod tests {
message: "boom".to_string(),
}),
duration_ms: Some(1),
metadata: None,
},
};
@@ -6194,7 +6194,6 @@ impl CodexMessageProcessor {
// Review prompt display text is synthesized; no UI element ranges to preserve.
text_elements: Vec::new(),
}],
metadata: None,
}]
};
@@ -88,13 +88,10 @@ async fn auto_compaction_local_emits_started_and_completed_items() -> Result<()>
let started = wait_for_context_compaction_started(&mut mcp).await?;
let completed = wait_for_context_compaction_completed(&mut mcp).await?;
let ThreadItem::ContextCompaction { id: started_id, .. } = started.item else {
let ThreadItem::ContextCompaction { id: started_id } = started.item else {
unreachable!("started item should be context compaction");
};
let ThreadItem::ContextCompaction {
id: completed_id, ..
} = completed.item
else {
let ThreadItem::ContextCompaction { id: completed_id } = completed.item else {
unreachable!("completed item should be context compaction");
};
@@ -180,13 +177,10 @@ async fn auto_compaction_remote_emits_started_and_completed_items() -> Result<()
let started = wait_for_context_compaction_started(&mut mcp).await?;
let completed = wait_for_context_compaction_completed(&mut mcp).await?;
let ThreadItem::ContextCompaction { id: started_id, .. } = started.item else {
let ThreadItem::ContextCompaction { id: started_id } = started.item else {
unreachable!("started item should be context compaction");
};
let ThreadItem::ContextCompaction {
id: completed_id, ..
} = completed.item
else {
let ThreadItem::ContextCompaction { id: completed_id } = completed.item else {
unreachable!("completed item should be context compaction");
};
@@ -246,13 +240,10 @@ async fn thread_compact_start_triggers_compaction_and_returns_empty_response() -
let started = wait_for_context_compaction_started(&mut mcp).await?;
let completed = wait_for_context_compaction_completed(&mut mcp).await?;
let ThreadItem::ContextCompaction { id: started_id, .. } = started.item else {
let ThreadItem::ContextCompaction { id: started_id } = started.item else {
unreachable!("started item should be context compaction");
};
let ThreadItem::ContextCompaction {
id: completed_id, ..
} = completed.item
else {
let ThreadItem::ContextCompaction { id: completed_id } = completed.item else {
unreachable!("completed item should be context compaction");
};
@@ -200,7 +200,6 @@ async fn dynamic_tool_call_round_trip_sends_text_content_items_to_model() -> Res
content_items,
success,
duration_ms,
..
} = started.item
else {
panic!("expected dynamic tool call item");
@@ -254,7 +253,6 @@ async fn dynamic_tool_call_round_trip_sends_text_content_items_to_model() -> Res
content_items,
success,
duration_ms,
..
} = completed.item
else {
panic!("expected dynamic tool call item");
@@ -67,7 +67,6 @@ async fn plan_mode_uses_proposed_plan_block_for_plan_item() -> Result<()> {
let expected_plan = ThreadItem::Plan {
id: format!("{}-plan", turn.id),
text: "# Final plan\n- first\n- second\n".to_string(),
metadata: None,
};
let expected_plan_id = format!("{}-plan", turn.id);
let streamed_plan = plan_deltas
+2 -2
View File
@@ -97,7 +97,7 @@ async fn review_start_runs_review_turn_and_emits_code_review_item() -> Result<()
let started: ItemStartedNotification =
serde_json::from_value(item_started.params.expect("params must be present"))?;
match started.item {
ThreadItem::EnteredReviewMode { id, review, .. } => {
ThreadItem::EnteredReviewMode { id, review } => {
assert_eq!(id, turn_id);
assert_eq!(review, "commit 1234567: Tidy UI colors");
saw_entered_review_mode = true;
@@ -123,7 +123,7 @@ async fn review_start_runs_review_turn_and_emits_code_review_item() -> Result<()
let completed: ItemCompletedNotification =
serde_json::from_value(review_notif.params.expect("params must be present"))?;
match completed.item {
ThreadItem::ExitedReviewMode { id, review, .. } => {
ThreadItem::ExitedReviewMode { id, review } => {
assert_eq!(id, turn_id);
review_body = Some(review);
break;
@@ -1238,7 +1238,6 @@ async fn thread_resume_replays_pending_file_change_request_approval() -> Result<
diff: "new line\n".to_string(),
}],
status: PatchApplyStatus::InProgress,
metadata: None,
};
assert_eq!(original_started, expected_file_change);
@@ -1553,7 +1553,6 @@ async fn turn_start_file_change_approval_v2() -> Result<()> {
ref id,
status,
ref changes,
..
} = started_file_change
else {
unreachable!("loop ensures we break on file change items");
@@ -2128,7 +2127,6 @@ async fn turn_start_file_change_approval_decline_v2() -> Result<()> {
ref id,
status,
ref changes,
..
} = started_file_change
else {
unreachable!("loop ensures we break on file change items");
-3
View File
@@ -6470,7 +6470,6 @@ impl ProposedPlanItemState {
let item = TurnItem::Plan(PlanItem {
id: self.item_id.clone(),
text: String::new(),
metadata: None,
});
sess.emit_turn_item_started(turn_context, &item).await;
}
@@ -6505,7 +6504,6 @@ impl ProposedPlanItemState {
let item = TurnItem::Plan(PlanItem {
id: self.item_id.clone(),
text,
metadata: None,
});
sess.emit_turn_item_completed(turn_context, item).await;
}
@@ -6818,7 +6816,6 @@ async fn emit_agent_message_in_plan_mode(
id: agent_message_id.clone(),
content: Vec::new(),
phase: None,
metadata: None,
})
});
sess.emit_turn_item_started(turn_context, &start_item).await;
+1 -9
View File
@@ -83,12 +83,7 @@ fn parse_agent_message(
}
}
let id = id.cloned().unwrap_or_else(|| Uuid::new_v4().to_string());
AgentMessageItem {
id,
content,
phase,
metadata: None,
}
AgentMessageItem { id, content, phase }
}
pub fn parse_turn_item(item: &ResponseItem) -> Option<TurnItem> {
@@ -134,7 +129,6 @@ pub fn parse_turn_item(item: &ResponseItem) -> Option<TurnItem> {
id: id.clone(),
summary_text,
raw_content,
metadata: None,
}))
}
ResponseItem::WebSearchCall { id, action, .. } => {
@@ -146,7 +140,6 @@ pub fn parse_turn_item(item: &ResponseItem) -> Option<TurnItem> {
id: id.clone().unwrap_or_default(),
query,
action,
metadata: None,
}))
}
ResponseItem::ImageGenerationCall {
@@ -161,7 +154,6 @@ pub fn parse_turn_item(item: &ResponseItem) -> Option<TurnItem> {
revised_prompt: revised_prompt.clone(),
result: result.clone(),
saved_path: None,
metadata: None,
},
)),
_ => None,
-40
View File
@@ -29,29 +29,10 @@ pub enum TurnItem {
ContextCompaction(ContextCompactionItem),
}
#[derive(Debug, Clone, Deserialize, Serialize, TS, JsonSchema, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
#[ts(rename_all = "snake_case")]
pub enum ItemSandboxPolicy {
ReadOnly,
Sandbox,
FullAccess,
}
#[derive(Debug, Clone, Default, Deserialize, Serialize, TS, JsonSchema, PartialEq, Eq)]
pub struct TurnItemMetadata {
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub sandbox_policy: Option<ItemSandboxPolicy>,
}
#[derive(Debug, Clone, Deserialize, Serialize, TS, JsonSchema)]
pub struct UserMessageItem {
pub id: String,
pub content: Vec<UserInput>,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub metadata: Option<TurnItemMetadata>,
}
#[derive(Debug, Clone, Deserialize, Serialize, TS, JsonSchema)]
@@ -77,18 +58,12 @@ pub struct AgentMessageItem {
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub phase: Option<MessagePhase>,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub metadata: Option<TurnItemMetadata>,
}
#[derive(Debug, Clone, Deserialize, Serialize, TS, JsonSchema)]
pub struct PlanItem {
pub id: String,
pub text: String,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub metadata: Option<TurnItemMetadata>,
}
#[derive(Debug, Clone, Deserialize, Serialize, TS, JsonSchema)]
@@ -97,9 +72,6 @@ pub struct ReasoningItem {
pub summary_text: Vec<String>,
#[serde(default)]
pub raw_content: Vec<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub metadata: Option<TurnItemMetadata>,
}
#[derive(Debug, Clone, Deserialize, Serialize, TS, JsonSchema, PartialEq)]
@@ -107,9 +79,6 @@ pub struct WebSearchItem {
pub id: String,
pub query: String,
pub action: WebSearchAction,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub metadata: Option<TurnItemMetadata>,
}
#[derive(Debug, Clone, Deserialize, Serialize, TS, JsonSchema, PartialEq)]
@@ -123,24 +92,17 @@ pub struct ImageGenerationItem {
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub saved_path: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub metadata: Option<TurnItemMetadata>,
}
#[derive(Debug, Clone, Deserialize, Serialize, TS, JsonSchema)]
pub struct ContextCompactionItem {
pub id: String,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub metadata: Option<TurnItemMetadata>,
}
impl ContextCompactionItem {
pub fn new() -> Self {
Self {
id: uuid::Uuid::new_v4().to_string(),
metadata: None,
}
}
@@ -160,7 +122,6 @@ impl UserMessageItem {
Self {
id: uuid::Uuid::new_v4().to_string(),
content: content.to_vec(),
metadata: None,
}
}
@@ -240,7 +201,6 @@ impl AgentMessageItem {
id: uuid::Uuid::new_v4().to_string(),
content: content.to_vec(),
phase: None,
metadata: None,
}
}
-3
View File
@@ -3899,7 +3899,6 @@ mod tests {
query: Some("find docs".into()),
queries: None,
},
metadata: None,
}),
};
@@ -3933,7 +3932,6 @@ mod tests {
revised_prompt: None,
result: String::new(),
saved_path: None,
metadata: None,
}),
};
@@ -3956,7 +3954,6 @@ mod tests {
revised_prompt: Some("A tiny blue square".into()),
result: "Zm9v".into(),
saved_path: Some("/tmp/ig-1.png".into()),
metadata: None,
}),
};