mirror of
https://github.com/openai/codex.git
synced 2026-11-17 22:10:37 +00:00
initial surface projection for sandbox
This commit is contained in:
@@ -204,7 +204,11 @@ 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 });
|
||||
turn.items.push(ThreadItem::UserMessage {
|
||||
id,
|
||||
content,
|
||||
metadata: None,
|
||||
});
|
||||
self.current_turn = Some(turn);
|
||||
}
|
||||
|
||||
@@ -214,9 +218,12 @@ impl ThreadHistoryBuilder {
|
||||
}
|
||||
|
||||
let id = self.next_item_id();
|
||||
self.ensure_turn()
|
||||
.items
|
||||
.push(ThreadItem::AgentMessage { id, text, phase });
|
||||
self.ensure_turn().items.push(ThreadItem::AgentMessage {
|
||||
id,
|
||||
text,
|
||||
phase,
|
||||
metadata: None,
|
||||
});
|
||||
}
|
||||
|
||||
fn handle_agent_reasoning(&mut self, payload: &AgentReasoningEvent) {
|
||||
@@ -236,6 +243,7 @@ impl ThreadHistoryBuilder {
|
||||
id,
|
||||
summary: vec![payload.text.clone()],
|
||||
content: Vec::new(),
|
||||
metadata: None,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -256,6 +264,7 @@ impl ThreadHistoryBuilder {
|
||||
id,
|
||||
summary: Vec::new(),
|
||||
content: vec![payload.text.clone()],
|
||||
metadata: None,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -304,6 +313,7 @@ impl ThreadHistoryBuilder {
|
||||
id: payload.call_id.clone(),
|
||||
query: String::new(),
|
||||
action: None,
|
||||
metadata: None,
|
||||
};
|
||||
self.upsert_item_in_current_turn(item);
|
||||
}
|
||||
@@ -313,6 +323,7 @@ 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);
|
||||
}
|
||||
@@ -336,6 +347,7 @@ impl ThreadHistoryBuilder {
|
||||
aggregated_output: None,
|
||||
exit_code: None,
|
||||
duration_ms: None,
|
||||
metadata: None,
|
||||
};
|
||||
self.upsert_item_in_turn_id(&payload.turn_id, item);
|
||||
}
|
||||
@@ -366,6 +378,7 @@ 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
|
||||
@@ -380,6 +393,7 @@ 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);
|
||||
@@ -393,6 +407,7 @@ 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,6 +422,7 @@ 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);
|
||||
@@ -427,6 +443,7 @@ 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);
|
||||
@@ -450,6 +467,7 @@ 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);
|
||||
@@ -472,6 +490,7 @@ impl ThreadHistoryBuilder {
|
||||
result: None,
|
||||
error: None,
|
||||
duration_ms: None,
|
||||
metadata: None,
|
||||
};
|
||||
self.upsert_item_in_current_turn(item);
|
||||
}
|
||||
@@ -511,6 +530,7 @@ impl ThreadHistoryBuilder {
|
||||
result,
|
||||
error,
|
||||
duration_ms,
|
||||
metadata: None,
|
||||
};
|
||||
self.upsert_item_in_current_turn(item);
|
||||
}
|
||||
@@ -519,6 +539,7 @@ 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);
|
||||
}
|
||||
@@ -529,6 +550,7 @@ impl ThreadHistoryBuilder {
|
||||
status: String::new(),
|
||||
revised_prompt: None,
|
||||
result: String::new(),
|
||||
metadata: None,
|
||||
};
|
||||
self.upsert_item_in_current_turn(item);
|
||||
}
|
||||
@@ -539,6 +561,7 @@ 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);
|
||||
}
|
||||
@@ -555,6 +578,7 @@ impl ThreadHistoryBuilder {
|
||||
receiver_thread_ids: Vec::new(),
|
||||
prompt: Some(payload.prompt.clone()),
|
||||
agents_states: HashMap::new(),
|
||||
metadata: None,
|
||||
};
|
||||
self.upsert_item_in_current_turn(item);
|
||||
}
|
||||
@@ -588,6 +612,7 @@ impl ThreadHistoryBuilder {
|
||||
receiver_thread_ids,
|
||||
prompt: Some(payload.prompt.clone()),
|
||||
agents_states,
|
||||
metadata: None,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -603,6 +628,7 @@ impl ThreadHistoryBuilder {
|
||||
receiver_thread_ids: vec![payload.receiver_thread_id.to_string()],
|
||||
prompt: Some(payload.prompt.clone()),
|
||||
agents_states: HashMap::new(),
|
||||
metadata: None,
|
||||
};
|
||||
self.upsert_item_in_current_turn(item);
|
||||
}
|
||||
@@ -625,6 +651,7 @@ impl ThreadHistoryBuilder {
|
||||
receiver_thread_ids: vec![receiver_id.clone()],
|
||||
prompt: Some(payload.prompt.clone()),
|
||||
agents_states: [(receiver_id, received_status)].into_iter().collect(),
|
||||
metadata: None,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -644,6 +671,7 @@ impl ThreadHistoryBuilder {
|
||||
.collect(),
|
||||
prompt: None,
|
||||
agents_states: HashMap::new(),
|
||||
metadata: None,
|
||||
};
|
||||
self.upsert_item_in_current_turn(item);
|
||||
}
|
||||
@@ -677,6 +705,7 @@ impl ThreadHistoryBuilder {
|
||||
receiver_thread_ids,
|
||||
prompt: None,
|
||||
agents_states,
|
||||
metadata: None,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -692,6 +721,7 @@ impl ThreadHistoryBuilder {
|
||||
receiver_thread_ids: vec![payload.receiver_thread_id.to_string()],
|
||||
prompt: None,
|
||||
agents_states: HashMap::new(),
|
||||
metadata: None,
|
||||
};
|
||||
self.upsert_item_in_current_turn(item);
|
||||
}
|
||||
@@ -716,6 +746,7 @@ impl ThreadHistoryBuilder {
|
||||
receiver_thread_ids: vec![receiver_id],
|
||||
prompt: None,
|
||||
agents_states,
|
||||
metadata: None,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -731,6 +762,7 @@ impl ThreadHistoryBuilder {
|
||||
receiver_thread_ids: vec![payload.receiver_thread_id.to_string()],
|
||||
prompt: None,
|
||||
agents_states: HashMap::new(),
|
||||
metadata: None,
|
||||
};
|
||||
self.upsert_item_in_current_turn(item);
|
||||
}
|
||||
@@ -758,6 +790,7 @@ impl ThreadHistoryBuilder {
|
||||
receiver_thread_ids: vec![receiver_id],
|
||||
prompt: None,
|
||||
agents_states,
|
||||
metadata: None,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -765,7 +798,7 @@ impl ThreadHistoryBuilder {
|
||||
let id = self.next_item_id();
|
||||
self.ensure_turn()
|
||||
.items
|
||||
.push(ThreadItem::ContextCompaction { id });
|
||||
.push(ThreadItem::ContextCompaction { id, metadata: None });
|
||||
}
|
||||
|
||||
fn handle_entered_review_mode(&mut self, payload: &codex_protocol::protocol::ReviewRequest) {
|
||||
@@ -776,7 +809,11 @@ impl ThreadHistoryBuilder {
|
||||
let id = self.next_item_id();
|
||||
self.ensure_turn()
|
||||
.items
|
||||
.push(ThreadItem::EnteredReviewMode { id, review });
|
||||
.push(ThreadItem::EnteredReviewMode {
|
||||
id,
|
||||
review,
|
||||
metadata: None,
|
||||
});
|
||||
}
|
||||
|
||||
fn handle_exited_review_mode(
|
||||
@@ -789,9 +826,11 @@ 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 });
|
||||
self.ensure_turn().items.push(ThreadItem::ExitedReviewMode {
|
||||
id,
|
||||
review,
|
||||
metadata: None,
|
||||
});
|
||||
}
|
||||
|
||||
fn handle_error(&mut self, payload: &ErrorEvent) {
|
||||
@@ -1201,6 +1240,7 @@ mod tests {
|
||||
url: "https://example.com/one.png".into(),
|
||||
}
|
||||
],
|
||||
metadata: None,
|
||||
}
|
||||
);
|
||||
assert_eq!(
|
||||
@@ -1209,6 +1249,7 @@ mod tests {
|
||||
id: "item-2".into(),
|
||||
text: "Hi there".into(),
|
||||
phase: None,
|
||||
metadata: None,
|
||||
}
|
||||
);
|
||||
assert_eq!(
|
||||
@@ -1217,6 +1258,7 @@ mod tests {
|
||||
id: "item-3".into(),
|
||||
summary: vec!["thinking".into()],
|
||||
content: vec!["full reasoning".into()],
|
||||
metadata: None,
|
||||
}
|
||||
);
|
||||
|
||||
@@ -1232,6 +1274,7 @@ mod tests {
|
||||
text: "Second turn".into(),
|
||||
text_elements: Vec::new(),
|
||||
}],
|
||||
metadata: None,
|
||||
}
|
||||
);
|
||||
assert_eq!(
|
||||
@@ -1240,6 +1283,7 @@ mod tests {
|
||||
id: "item-5".into(),
|
||||
text: "Reply two".into(),
|
||||
phase: None,
|
||||
metadata: None,
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -1266,6 +1310,7 @@ mod tests {
|
||||
item: CoreTurnItem::UserMessage(CoreUserMessageItem {
|
||||
id: "user-item-id".to_string(),
|
||||
content: Vec::new(),
|
||||
metadata: None,
|
||||
}),
|
||||
}),
|
||||
EventMsg::TurnComplete(TurnCompleteEvent {
|
||||
@@ -1289,6 +1334,7 @@ mod tests {
|
||||
text: "hello".into(),
|
||||
text_elements: Vec::new(),
|
||||
}],
|
||||
metadata: None,
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -1312,6 +1358,7 @@ mod tests {
|
||||
id: "item-1".into(),
|
||||
text: "Final reply".into(),
|
||||
phase: Some(MessagePhase::FinalAnswer),
|
||||
metadata: None,
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -1355,6 +1402,7 @@ mod tests {
|
||||
id: "item-2".into(),
|
||||
summary: vec!["first summary".into()],
|
||||
content: vec!["first content".into()],
|
||||
metadata: None,
|
||||
}
|
||||
);
|
||||
assert_eq!(
|
||||
@@ -1363,6 +1411,7 @@ mod tests {
|
||||
id: "item-4".into(),
|
||||
summary: vec!["second summary".into()],
|
||||
content: Vec::new(),
|
||||
metadata: None,
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -1414,6 +1463,7 @@ mod tests {
|
||||
text: "Please do the thing".into(),
|
||||
text_elements: Vec::new(),
|
||||
}],
|
||||
metadata: None,
|
||||
}
|
||||
);
|
||||
assert_eq!(
|
||||
@@ -1422,6 +1472,7 @@ mod tests {
|
||||
id: "item-2".into(),
|
||||
text: "Working...".into(),
|
||||
phase: None,
|
||||
metadata: None,
|
||||
}
|
||||
);
|
||||
|
||||
@@ -1436,6 +1487,7 @@ mod tests {
|
||||
text: "Let's try again".into(),
|
||||
text_elements: Vec::new(),
|
||||
}],
|
||||
metadata: None,
|
||||
}
|
||||
);
|
||||
assert_eq!(
|
||||
@@ -1444,6 +1496,7 @@ mod tests {
|
||||
id: "item-4".into(),
|
||||
text: "Second attempt complete.".into(),
|
||||
phase: None,
|
||||
metadata: None,
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -1504,11 +1557,13 @@ mod tests {
|
||||
text: "First".into(),
|
||||
text_elements: Vec::new(),
|
||||
}],
|
||||
metadata: None,
|
||||
},
|
||||
ThreadItem::AgentMessage {
|
||||
id: "item-2".into(),
|
||||
text: "A1".into(),
|
||||
phase: None,
|
||||
metadata: None,
|
||||
},
|
||||
]
|
||||
);
|
||||
@@ -1521,11 +1576,13 @@ mod tests {
|
||||
text: "Third".into(),
|
||||
text_elements: Vec::new(),
|
||||
}],
|
||||
metadata: None,
|
||||
},
|
||||
ThreadItem::AgentMessage {
|
||||
id: "item-4".into(),
|
||||
text: "A3".into(),
|
||||
phase: None,
|
||||
metadata: None,
|
||||
},
|
||||
]
|
||||
);
|
||||
@@ -1607,6 +1664,7 @@ mod tests {
|
||||
text: "Start".into(),
|
||||
text_elements: Vec::new(),
|
||||
}],
|
||||
metadata: None,
|
||||
},
|
||||
ThreadItem::UserMessage {
|
||||
id: "item-2".into(),
|
||||
@@ -1614,6 +1672,7 @@ mod tests {
|
||||
text: "Steer".into(),
|
||||
text_elements: Vec::new(),
|
||||
}],
|
||||
metadata: None,
|
||||
},
|
||||
]
|
||||
);
|
||||
@@ -1688,6 +1747,7 @@ mod tests {
|
||||
query: Some("codex".into()),
|
||||
queries: None,
|
||||
}),
|
||||
metadata: None,
|
||||
}
|
||||
);
|
||||
assert_eq!(
|
||||
@@ -1704,6 +1764,7 @@ mod tests {
|
||||
aggregated_output: Some("hello world\n".into()),
|
||||
exit_code: Some(0),
|
||||
duration_ms: Some(12),
|
||||
metadata: None,
|
||||
}
|
||||
);
|
||||
assert_eq!(
|
||||
@@ -1719,6 +1780,7 @@ mod tests {
|
||||
message: "boom".into(),
|
||||
}),
|
||||
duration_ms: Some(8),
|
||||
metadata: None,
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -1778,6 +1840,7 @@ mod tests {
|
||||
}]),
|
||||
success: Some(true),
|
||||
duration_ms: Some(42),
|
||||
metadata: None,
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -1852,6 +1915,7 @@ mod tests {
|
||||
aggregated_output: Some("exec command rejected by user".into()),
|
||||
exit_code: Some(-1),
|
||||
duration_ms: Some(0),
|
||||
metadata: None,
|
||||
}
|
||||
);
|
||||
assert_eq!(
|
||||
@@ -1864,6 +1928,7 @@ mod tests {
|
||||
diff: "hello\n".into(),
|
||||
}],
|
||||
status: PatchApplyStatus::Declined,
|
||||
metadata: None,
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -1946,6 +2011,7 @@ mod tests {
|
||||
aggregated_output: Some("done\n".into()),
|
||||
exit_code: Some(0),
|
||||
duration_ms: Some(5),
|
||||
metadata: None,
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -2022,6 +2088,7 @@ mod tests {
|
||||
text: "second".into(),
|
||||
text_elements: Vec::new(),
|
||||
}],
|
||||
metadata: None,
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -2075,6 +2142,7 @@ mod tests {
|
||||
text: "apply patch".into(),
|
||||
text_elements: Vec::new(),
|
||||
}],
|
||||
metadata: None,
|
||||
},
|
||||
ThreadItem::FileChange {
|
||||
id: "patch-call".into(),
|
||||
@@ -2084,6 +2152,7 @@ mod tests {
|
||||
diff: "hello\n".into(),
|
||||
}],
|
||||
status: PatchApplyStatus::InProgress,
|
||||
metadata: None,
|
||||
},
|
||||
]
|
||||
);
|
||||
@@ -2139,6 +2208,7 @@ mod tests {
|
||||
text: "apply patch".into(),
|
||||
text_elements: Vec::new(),
|
||||
}],
|
||||
metadata: None,
|
||||
},
|
||||
ThreadItem::FileChange {
|
||||
id: "patch-call".into(),
|
||||
@@ -2148,6 +2218,7 @@ mod tests {
|
||||
diff: "hello\n".into(),
|
||||
}],
|
||||
status: PatchApplyStatus::InProgress,
|
||||
metadata: None,
|
||||
},
|
||||
]
|
||||
);
|
||||
@@ -2334,6 +2405,7 @@ mod tests {
|
||||
)]
|
||||
.into_iter()
|
||||
.collect(),
|
||||
metadata: None,
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -2409,6 +2481,7 @@ mod tests {
|
||||
text: "hello".into(),
|
||||
text_elements: Vec::new(),
|
||||
}],
|
||||
metadata: None,
|
||||
}],
|
||||
}
|
||||
);
|
||||
|
||||
@@ -25,7 +25,9 @@ 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;
|
||||
@@ -3794,6 +3796,41 @@ 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 {
|
||||
@@ -3850,7 +3887,12 @@ impl UserInput {
|
||||
pub enum ThreadItem {
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(rename_all = "camelCase")]
|
||||
UserMessage { id: String, content: Vec<UserInput> },
|
||||
UserMessage {
|
||||
id: String,
|
||||
content: Vec<UserInput>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
metadata: Option<ItemMetadata>,
|
||||
},
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(rename_all = "camelCase")]
|
||||
AgentMessage {
|
||||
@@ -3858,12 +3900,19 @@ 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 },
|
||||
Plan {
|
||||
id: String,
|
||||
text: String,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
metadata: Option<ItemMetadata>,
|
||||
},
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(rename_all = "camelCase")]
|
||||
Reasoning {
|
||||
@@ -3872,6 +3921,8 @@ 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")]
|
||||
@@ -3895,6 +3946,8 @@ 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")]
|
||||
@@ -3902,6 +3955,8 @@ 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")]
|
||||
@@ -3916,6 +3971,8 @@ 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")]
|
||||
@@ -3929,6 +3986,8 @@ 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")]
|
||||
@@ -3948,6 +4007,8 @@ 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")]
|
||||
@@ -3955,10 +4016,17 @@ 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 },
|
||||
ImageView {
|
||||
id: String,
|
||||
path: String,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
metadata: Option<ItemMetadata>,
|
||||
},
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(rename_all = "camelCase")]
|
||||
ImageGeneration {
|
||||
@@ -3966,16 +4034,32 @@ 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 },
|
||||
EnteredReviewMode {
|
||||
id: String,
|
||||
review: String,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
metadata: Option<ItemMetadata>,
|
||||
},
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(rename_all = "camelCase")]
|
||||
ExitedReviewMode { id: String, review: String },
|
||||
ExitedReviewMode {
|
||||
id: String,
|
||||
review: String,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
metadata: Option<ItemMetadata>,
|
||||
},
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(rename_all = "camelCase")]
|
||||
ContextCompaction { id: String },
|
||||
ContextCompaction {
|
||||
id: String,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
metadata: Option<ItemMetadata>,
|
||||
},
|
||||
}
|
||||
|
||||
impl ThreadItem {
|
||||
@@ -4043,6 +4127,7 @@ 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
|
||||
@@ -4056,31 +4141,37 @@ 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 }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6807,6 +6898,7 @@ mod tests {
|
||||
path: "app://demo-app".to_string(),
|
||||
},
|
||||
],
|
||||
metadata: None,
|
||||
});
|
||||
|
||||
assert_eq!(
|
||||
@@ -6833,6 +6925,7 @@ mod tests {
|
||||
path: "app://demo-app".to_string(),
|
||||
},
|
||||
],
|
||||
metadata: None,
|
||||
}
|
||||
);
|
||||
|
||||
@@ -6847,6 +6940,7 @@ mod tests {
|
||||
},
|
||||
],
|
||||
phase: None,
|
||||
metadata: None,
|
||||
});
|
||||
|
||||
assert_eq!(
|
||||
@@ -6855,6 +6949,7 @@ mod tests {
|
||||
id: "agent-1".to_string(),
|
||||
text: "Hello world".to_string(),
|
||||
phase: None,
|
||||
metadata: None,
|
||||
}
|
||||
);
|
||||
|
||||
@@ -6864,6 +6959,7 @@ mod tests {
|
||||
text: "final".to_string(),
|
||||
}],
|
||||
phase: Some(MessagePhase::FinalAnswer),
|
||||
metadata: None,
|
||||
});
|
||||
|
||||
assert_eq!(
|
||||
@@ -6872,6 +6968,7 @@ mod tests {
|
||||
id: "agent-2".to_string(),
|
||||
text: "final".to_string(),
|
||||
phase: Some(MessagePhase::FinalAnswer),
|
||||
metadata: None,
|
||||
}
|
||||
);
|
||||
|
||||
@@ -6879,6 +6976,7 @@ 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!(
|
||||
@@ -6887,6 +6985,7 @@ mod tests {
|
||||
id: "reasoning-1".to_string(),
|
||||
summary: vec!["line one".to_string(), "line two".to_string()],
|
||||
content: vec![],
|
||||
metadata: None,
|
||||
}
|
||||
);
|
||||
|
||||
@@ -6897,6 +6996,7 @@ mod tests {
|
||||
query: Some("docs".to_string()),
|
||||
queries: None,
|
||||
},
|
||||
metadata: None,
|
||||
});
|
||||
|
||||
assert_eq!(
|
||||
@@ -6908,6 +7008,7 @@ mod tests {
|
||||
query: Some("docs".to_string()),
|
||||
queries: None,
|
||||
}),
|
||||
metadata: None,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user