Replace item sandbox metadata with user message type metadata

This commit is contained in:
Roy Han
2026-03-11 15:19:15 -07:00
parent 9e058f1bc5
commit 2fa740749e
2 changed files with 29 additions and 17 deletions

View File

@@ -25,7 +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::UserMessageType as CoreUserMessageType;
use codex_protocol::items::TurnItem as CoreTurnItem;
use codex_protocol::items::TurnItemMetadata as CoreTurnItemMetadata;
use codex_protocol::mcp::Resource as McpResource;
@@ -3799,18 +3799,26 @@ 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,
pub enum UserMessageType {
Prompt,
PromptSteering,
PromptQueued,
PromptWithIdeContext,
AgentsMdDefault,
AgentsMdCustom,
EnvironmentContext,
}
impl From<CoreItemSandboxPolicy> for ItemSandboxPolicy {
fn from(value: CoreItemSandboxPolicy) -> Self {
impl From<CoreUserMessageType> for UserMessageType {
fn from(value: CoreUserMessageType) -> Self {
match value {
CoreItemSandboxPolicy::ReadOnly => ItemSandboxPolicy::ReadOnly,
CoreItemSandboxPolicy::Sandbox => ItemSandboxPolicy::Sandbox,
CoreItemSandboxPolicy::FullAccess => ItemSandboxPolicy::FullAccess,
CoreUserMessageType::Prompt => UserMessageType::Prompt,
CoreUserMessageType::PromptSteering => UserMessageType::PromptSteering,
CoreUserMessageType::PromptQueued => UserMessageType::PromptQueued,
CoreUserMessageType::PromptWithIdeContext => UserMessageType::PromptWithIdeContext,
CoreUserMessageType::AgentsMdDefault => UserMessageType::AgentsMdDefault,
CoreUserMessageType::AgentsMdCustom => UserMessageType::AgentsMdCustom,
CoreUserMessageType::EnvironmentContext => UserMessageType::EnvironmentContext,
}
}
}
@@ -3820,13 +3828,13 @@ impl From<CoreItemSandboxPolicy> for ItemSandboxPolicy {
pub struct ItemMetadata {
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub sandbox_policy: Option<ItemSandboxPolicy>,
pub user_message_type: Option<UserMessageType>,
}
impl From<CoreTurnItemMetadata> for ItemMetadata {
fn from(value: CoreTurnItemMetadata) -> Self {
Self {
sandbox_policy: value.sandbox_policy.map(Into::into),
user_message_type: value.user_message_type.map(Into::into),
}
}
}

View File

@@ -32,17 +32,21 @@ pub enum TurnItem {
#[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,
pub enum UserMessageType {
Prompt,
PromptSteering,
PromptQueued,
PromptWithIdeContext,
AgentsMdDefault,
AgentsMdCustom,
EnvironmentContext,
}
#[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>,
pub user_message_type: Option<UserMessageType>,
}
#[derive(Debug, Clone, Deserialize, Serialize, TS, JsonSchema)]