Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
862 changes: 862 additions & 0 deletions codex-rs/core/src/arc_monitor.rs

Large diffs are not rendered by default.

10 changes: 7 additions & 3 deletions codex-rs/core/src/guardian.rs
Original file line number Diff line number Diff line change
Expand Up @@ -731,8 +731,8 @@ fn truncate_guardian_action_value(value: Value) -> Value {
}
}

fn format_guardian_action_pretty(action: &GuardianApprovalRequest) -> String {
let mut value = match action {
pub(crate) fn guardian_approval_request_to_json(action: &GuardianApprovalRequest) -> Value {
match action {
GuardianApprovalRequest::Shell {
command,
cwd,
Expand Down Expand Up @@ -871,7 +871,11 @@ fn format_guardian_action_pretty(action: &GuardianApprovalRequest) -> String {
}
action
}
};
}
}

fn format_guardian_action_pretty(action: &GuardianApprovalRequest) -> String {
let mut value = guardian_approval_request_to_json(action);
value = truncate_guardian_action_value(value);
serde_json::to_string_pretty(&value).unwrap_or_else(|_| "null".to_string())
}
Expand Down
39 changes: 39 additions & 0 deletions codex-rs/core/src/guardian_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,45 @@ fn format_guardian_action_pretty_truncates_large_string_fields() {
assert!(rendered.len() < patch.len());
}

#[test]
fn guardian_approval_request_to_json_renders_mcp_tool_call_shape() {
let action = GuardianApprovalRequest::McpToolCall {
server: "mcp_server".to_string(),
tool_name: "browser_navigate".to_string(),
arguments: Some(serde_json::json!({
"url": "https://example.com",
})),
connector_id: None,
connector_name: Some("Playwright".to_string()),
connector_description: None,
tool_title: Some("Navigate".to_string()),
tool_description: None,
annotations: Some(GuardianMcpAnnotations {
destructive_hint: Some(true),
open_world_hint: None,
read_only_hint: Some(false),
}),
};

assert_eq!(
guardian_approval_request_to_json(&action),
serde_json::json!({
"tool": "mcp_tool_call",
"server": "mcp_server",
"tool_name": "browser_navigate",
"arguments": {
"url": "https://example.com",
},
"connector_name": "Playwright",
"tool_title": "Navigate",
"annotations": {
"destructive_hint": true,
"read_only_hint": false,
},
})
);
}

#[test]
fn build_guardian_transcript_reserves_separate_budget_for_tool_evidence() {
let repeated = "signal ".repeat(8_000);
Expand Down
1 change: 1 addition & 0 deletions codex-rs/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ mod analytics_client;
pub mod api_bridge;
mod apply_patch;
mod apps;
mod arc_monitor;
pub mod auth;
mod client;
mod client_common;
Expand Down
Loading
Loading