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
13 changes: 1 addition & 12 deletions codex-rs/exec/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,20 +64,9 @@ pub struct Cli {
pub color: Color,

/// Print events to stdout as JSONL.
#[arg(
long = "json",
default_value_t = false,
conflicts_with = "experimental_json"
)]
#[arg(long = "json", alias = "experimental-json", default_value_t = false)]
pub json: bool,

#[arg(
long = "experimental-json",
default_value_t = false,
conflicts_with = "json"
)]
pub experimental_json: bool,

/// Whether to include the plan tool in the conversation.
#[arg(long = "include-plan-tool", default_value_t = false)]
pub include_plan_tool: bool,
Expand Down
64 changes: 0 additions & 64 deletions codex-rs/exec/src/event_processor_with_json_output.rs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ use codex_core::protocol::WebSearchEndEvent;
use tracing::error;
use tracing::warn;

pub struct ExperimentalEventProcessorWithJsonOutput {
pub struct EventProcessorWithJsonOutput {
last_message_path: Option<PathBuf>,
next_event_id: AtomicU64,
// Tracks running commands by call_id, including the associated item id.
Expand Down Expand Up @@ -83,7 +83,7 @@ struct RunningMcpToolCall {
item_id: String,
}

impl ExperimentalEventProcessorWithJsonOutput {
impl EventProcessorWithJsonOutput {
pub fn new(last_message_path: Option<PathBuf>) -> Self {
Self {
last_message_path,
Expand Down Expand Up @@ -420,7 +420,7 @@ impl ExperimentalEventProcessorWithJsonOutput {
}
}

impl EventProcessor for ExperimentalEventProcessorWithJsonOutput {
impl EventProcessor for EventProcessorWithJsonOutput {
fn print_config_summary(&mut self, _: &Config, _: &str, ev: &SessionConfiguredEvent) {
self.process_event(Event {
id: "".to_string(),
Expand Down
20 changes: 4 additions & 16 deletions codex-rs/exec/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
mod cli;
mod event_processor;
mod event_processor_with_human_output;
pub mod event_processor_with_json_output;
pub mod event_processor_with_jsonl_output;
pub mod exec_events;
pub mod experimental_event_processor_with_json_output;

pub use cli::Cli;
use codex_core::AuthManager;
Expand All @@ -22,8 +21,7 @@ use codex_core::protocol::TaskCompleteEvent;
use codex_ollama::DEFAULT_OSS_MODEL;
use codex_protocol::config_types::SandboxMode;
use event_processor_with_human_output::EventProcessorWithHumanOutput;
use event_processor_with_json_output::EventProcessorWithJsonOutput;
use experimental_event_processor_with_json_output::ExperimentalEventProcessorWithJsonOutput;
use event_processor_with_jsonl_output::EventProcessorWithJsonOutput;
use opentelemetry_appender_tracing::layer::OpenTelemetryTracingBridge;
use serde_json::Value;
use std::io::IsTerminal;
Expand Down Expand Up @@ -59,7 +57,6 @@ pub async fn run_main(cli: Cli, codex_linux_sandbox_exe: Option<PathBuf>) -> any
color,
last_message_file,
json: json_mode,
experimental_json,
sandbox_mode: sandbox_mode_cli_arg,
prompt,
output_schema: output_schema_path,
Expand Down Expand Up @@ -212,17 +209,8 @@ pub async fn run_main(cli: Cli, codex_linux_sandbox_exe: Option<PathBuf>) -> any
let _ = tracing_subscriber::registry().with(fmt_layer).try_init();
}

let mut event_processor: Box<dyn EventProcessor> = match (json_mode, experimental_json) {
(_, true) => Box::new(ExperimentalEventProcessorWithJsonOutput::new(
last_message_file.clone(),
)),
(true, _) => {
eprintln!(
"The existing `--json` output format is being deprecated. Please try the new format using `--experimental-json`."
);

Box::new(EventProcessorWithJsonOutput::new(last_message_file.clone()))
}
let mut event_processor: Box<dyn EventProcessor> = match json_mode {
true => Box::new(EventProcessorWithJsonOutput::new(last_message_file.clone())),
_ => Box::new(EventProcessorWithHumanOutput::create_with_ansi(
stdout_with_ansi,
&config,
Expand Down
38 changes: 19 additions & 19 deletions codex-rs/exec/tests/event_processor_with_json_output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use codex_core::protocol::PatchApplyBeginEvent;
use codex_core::protocol::PatchApplyEndEvent;
use codex_core::protocol::SessionConfiguredEvent;
use codex_core::protocol::WebSearchEndEvent;
use codex_exec::event_processor_with_jsonl_output::EventProcessorWithJsonOutput;
use codex_exec::exec_events::AssistantMessageItem;
use codex_exec::exec_events::CommandExecutionItem;
use codex_exec::exec_events::CommandExecutionStatus;
Expand All @@ -36,7 +37,6 @@ use codex_exec::exec_events::TurnFailedEvent;
use codex_exec::exec_events::TurnStartedEvent;
use codex_exec::exec_events::Usage;
use codex_exec::exec_events::WebSearchItem;
use codex_exec::experimental_event_processor_with_json_output::ExperimentalEventProcessorWithJsonOutput;
use mcp_types::CallToolResult;
use pretty_assertions::assert_eq;
use std::path::PathBuf;
Expand All @@ -51,7 +51,7 @@ fn event(id: &str, msg: EventMsg) -> Event {

#[test]
fn session_configured_produces_thread_started_event() {
let mut ep = ExperimentalEventProcessorWithJsonOutput::new(None);
let mut ep = EventProcessorWithJsonOutput::new(None);
let session_id = codex_protocol::mcp_protocol::ConversationId::from_string(
"67e55044-10b1-426f-9247-bb680e5fe0c8",
)
Expand Down Expand Up @@ -80,7 +80,7 @@ fn session_configured_produces_thread_started_event() {

#[test]
fn task_started_produces_turn_started_event() {
let mut ep = ExperimentalEventProcessorWithJsonOutput::new(None);
let mut ep = EventProcessorWithJsonOutput::new(None);
let out = ep.collect_thread_events(&event(
"t1",
EventMsg::TaskStarted(codex_core::protocol::TaskStartedEvent {
Expand All @@ -93,7 +93,7 @@ fn task_started_produces_turn_started_event() {

#[test]
fn web_search_end_emits_item_completed() {
let mut ep = ExperimentalEventProcessorWithJsonOutput::new(None);
let mut ep = EventProcessorWithJsonOutput::new(None);
let query = "rust async await".to_string();
let out = ep.collect_thread_events(&event(
"w1",
Expand All @@ -120,7 +120,7 @@ fn plan_update_emits_todo_list_started_updated_and_completed() {
use codex_core::plan_tool::StepStatus;
use codex_core::plan_tool::UpdatePlanArgs;

let mut ep = ExperimentalEventProcessorWithJsonOutput::new(None);
let mut ep = EventProcessorWithJsonOutput::new(None);

// First plan update => item.started (todo_list)
let first = event(
Expand Down Expand Up @@ -237,7 +237,7 @@ fn plan_update_emits_todo_list_started_updated_and_completed() {

#[test]
fn mcp_tool_call_begin_and_end_emit_item_events() {
let mut ep = ExperimentalEventProcessorWithJsonOutput::new(None);
let mut ep = EventProcessorWithJsonOutput::new(None);
let invocation = McpInvocation {
server: "server_a".to_string(),
tool: "tool_x".to_string(),
Expand Down Expand Up @@ -297,7 +297,7 @@ fn mcp_tool_call_begin_and_end_emit_item_events() {

#[test]
fn mcp_tool_call_failure_sets_failed_status() {
let mut ep = ExperimentalEventProcessorWithJsonOutput::new(None);
let mut ep = EventProcessorWithJsonOutput::new(None);
let invocation = McpInvocation {
server: "server_b".to_string(),
tool: "tool_y".to_string(),
Expand Down Expand Up @@ -344,7 +344,7 @@ fn plan_update_after_complete_starts_new_todo_list_with_new_id() {
use codex_core::plan_tool::StepStatus;
use codex_core::plan_tool::UpdatePlanArgs;

let mut ep = ExperimentalEventProcessorWithJsonOutput::new(None);
let mut ep = EventProcessorWithJsonOutput::new(None);

// First turn: start + complete
let start = event(
Expand Down Expand Up @@ -389,7 +389,7 @@ fn plan_update_after_complete_starts_new_todo_list_with_new_id() {

#[test]
fn agent_reasoning_produces_item_completed_reasoning() {
let mut ep = ExperimentalEventProcessorWithJsonOutput::new(None);
let mut ep = EventProcessorWithJsonOutput::new(None);
let ev = event(
"e1",
EventMsg::AgentReasoning(AgentReasoningEvent {
Expand All @@ -412,7 +412,7 @@ fn agent_reasoning_produces_item_completed_reasoning() {

#[test]
fn agent_message_produces_item_completed_assistant_message() {
let mut ep = ExperimentalEventProcessorWithJsonOutput::new(None);
let mut ep = EventProcessorWithJsonOutput::new(None);
let ev = event(
"e1",
EventMsg::AgentMessage(AgentMessageEvent {
Expand All @@ -435,7 +435,7 @@ fn agent_message_produces_item_completed_assistant_message() {

#[test]
fn error_event_produces_error() {
let mut ep = ExperimentalEventProcessorWithJsonOutput::new(None);
let mut ep = EventProcessorWithJsonOutput::new(None);
let out = ep.collect_thread_events(&event(
"e1",
EventMsg::Error(codex_core::protocol::ErrorEvent {
Expand All @@ -452,7 +452,7 @@ fn error_event_produces_error() {

#[test]
fn stream_error_event_produces_error() {
let mut ep = ExperimentalEventProcessorWithJsonOutput::new(None);
let mut ep = EventProcessorWithJsonOutput::new(None);
let out = ep.collect_thread_events(&event(
"e1",
EventMsg::StreamError(codex_core::protocol::StreamErrorEvent {
Expand All @@ -469,7 +469,7 @@ fn stream_error_event_produces_error() {

#[test]
fn error_followed_by_task_complete_produces_turn_failed() {
let mut ep = ExperimentalEventProcessorWithJsonOutput::new(None);
let mut ep = EventProcessorWithJsonOutput::new(None);

let error_event = event(
"e1",
Expand Down Expand Up @@ -502,7 +502,7 @@ fn error_followed_by_task_complete_produces_turn_failed() {

#[test]
fn exec_command_end_success_produces_completed_command_item() {
let mut ep = ExperimentalEventProcessorWithJsonOutput::new(None);
let mut ep = EventProcessorWithJsonOutput::new(None);

// Begin -> no output
let begin = event(
Expand Down Expand Up @@ -562,7 +562,7 @@ fn exec_command_end_success_produces_completed_command_item() {

#[test]
fn exec_command_end_failure_produces_failed_command_item() {
let mut ep = ExperimentalEventProcessorWithJsonOutput::new(None);
let mut ep = EventProcessorWithJsonOutput::new(None);

// Begin -> no output
let begin = event(
Expand Down Expand Up @@ -621,7 +621,7 @@ fn exec_command_end_failure_produces_failed_command_item() {

#[test]
fn exec_command_end_without_begin_is_ignored() {
let mut ep = ExperimentalEventProcessorWithJsonOutput::new(None);
let mut ep = EventProcessorWithJsonOutput::new(None);

// End event arrives without a prior Begin; should produce no thread events.
let end_only = event(
Expand All @@ -642,7 +642,7 @@ fn exec_command_end_without_begin_is_ignored() {

#[test]
fn patch_apply_success_produces_item_completed_patchapply() {
let mut ep = ExperimentalEventProcessorWithJsonOutput::new(None);
let mut ep = EventProcessorWithJsonOutput::new(None);

// Prepare a patch with multiple kinds of changes
let mut changes = std::collections::HashMap::new();
Expand Down Expand Up @@ -724,7 +724,7 @@ fn patch_apply_success_produces_item_completed_patchapply() {

#[test]
fn patch_apply_failure_produces_item_completed_patchapply_failed() {
let mut ep = ExperimentalEventProcessorWithJsonOutput::new(None);
let mut ep = EventProcessorWithJsonOutput::new(None);

let mut changes = std::collections::HashMap::new();
changes.insert(
Expand Down Expand Up @@ -778,7 +778,7 @@ fn patch_apply_failure_produces_item_completed_patchapply_failed() {

#[test]
fn task_complete_produces_turn_completed_with_usage() {
let mut ep = ExperimentalEventProcessorWithJsonOutput::new(None);
let mut ep = EventProcessorWithJsonOutput::new(None);

// First, feed a TokenCount event with known totals.
let usage = codex_core::protocol::TokenUsage {
Expand Down
Loading