diff --git a/codex-rs/app-server-test-client/README.md b/codex-rs/app-server-test-client/README.md index ab11f12353..9a55391327 100644 --- a/codex-rs/app-server-test-client/README.md +++ b/codex-rs/app-server-test-client/README.md @@ -18,6 +18,15 @@ cargo run -p codex-app-server-test-client -- \ cargo run -p codex-app-server-test-client -- model-list ``` +## Watching Raw Inbound Traffic + +Initialize a connection, then print every inbound JSON-RPC message until you stop it with +`Ctrl+C`: + +```bash +cargo run -p codex-app-server-test-client -- watch +``` + ## Testing Thread Rejoin Behavior Build and start an app server using commands above. The app-server log is written to `/tmp/codex-app-server-test-client/app-server.log` diff --git a/codex-rs/app-server-test-client/src/lib.rs b/codex-rs/app-server-test-client/src/lib.rs index 27203c6012..0454d0522a 100644 --- a/codex-rs/app-server-test-client/src/lib.rs +++ b/codex-rs/app-server-test-client/src/lib.rs @@ -188,6 +188,10 @@ enum CliCommand { /// Existing thread id to resume. thread_id: String, }, + /// Initialize the app-server and dump all inbound messages until interrupted. + /// + /// This command does not auto-exit; stop it with SIGINT/SIGTERM/SIGKILL. + Watch, /// Start a V2 turn that elicits an ExecCommand approval. #[command(name = "trigger-cmd-approval")] TriggerCmdApproval { @@ -291,6 +295,11 @@ pub fn run() -> Result<()> { let endpoint = resolve_endpoint(codex_bin, url)?; thread_resume_follow(&endpoint, &config_overrides, thread_id) } + CliCommand::Watch => { + ensure_dynamic_tools_unused(&dynamic_tools, "watch")?; + let endpoint = resolve_endpoint(codex_bin, url)?; + watch(&endpoint, &config_overrides) + } CliCommand::TriggerCmdApproval { user_message } => { let endpoint = resolve_endpoint(codex_bin, url)?; trigger_cmd_approval(&endpoint, &config_overrides, user_message, &dynamic_tools) @@ -698,6 +707,16 @@ fn thread_resume_follow( client.stream_notifications_forever() } +fn watch(endpoint: &Endpoint, config_overrides: &[String]) -> Result<()> { + let mut client = CodexClient::connect(endpoint, config_overrides)?; + + let initialize = client.initialize()?; + println!("< initialize response: {initialize:?}"); + println!("< streaming inbound messages until process is terminated"); + + client.stream_notifications_forever() +} + fn trigger_cmd_approval( endpoint: &Endpoint, config_overrides: &[String],