From e0758c32118f2aa006db3d8fa4b41833fe6e7ead Mon Sep 17 00:00:00 2001 From: Ogulcan Celik Date: Fri, 17 Jul 2026 23:55:08 +0300 Subject: feat: harden named agent cli workflows refs #1525 --- src/cli.rs | 45 +-------------------------------------------- 1 file changed, 1 insertion(+), 44 deletions(-) (limited to 'src/cli.rs') diff --git a/src/cli.rs b/src/cli.rs index e59be830..ecca934e 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -1,4 +1,4 @@ -use std::time::{Duration, SystemTime, UNIX_EPOCH}; +use std::time::{SystemTime, UNIX_EPOCH}; use serde::Serialize; @@ -932,42 +932,6 @@ fn wait_for_agent_status_change( } } -pub(super) fn wait_for_agent_change( - request: Request, - timeout_ms: Option, - timeout_message: &str, -) -> std::io::Result { - let read_timeout = timeout_ms.map(Duration::from_millis); - let client = ApiClient::local(); - ensure_server_protocol_compatible(&client, &request.id)?; - let (ack, mut stream) = client - .subscribe_value(&request, read_timeout) - .map_err(api_client_error_to_io)?; - if let Err(err) = crate::api::client::parse_response_value(ack) { - if let ApiClientError::ErrorResponse(response) = err { - eprintln!("{}", serde_json::to_string(&response).unwrap()); - return Ok(1); - } - return Err(api_client_error_to_io(err)); - } - - match stream.next_event() { - Ok(None) => { - eprintln!("subscription closed before event arrived"); - Ok(1) - } - Ok(Some(event_value)) => { - println!("{}", serde_json::to_string(&event_value).unwrap()); - Ok(0) - } - Err(ApiClientError::Io(err)) if api_timeout_error(&err) => { - eprintln!("{timeout_message}"); - Ok(1) - } - Err(err) => Err(api_client_error_to_io(err)), - } -} - pub(super) fn print_response(response: &serde_json::Value) -> std::io::Result { if response.get("error").is_some() { eprintln!("{}", serde_json::to_string(response).unwrap()); @@ -1030,13 +994,6 @@ pub(crate) fn protocol_mismatch_was_reported(err: &std::io::Error) -> bool { protocol_guard::was_reported(err) } -fn api_timeout_error(err: &std::io::Error) -> bool { - matches!( - err.kind(), - std::io::ErrorKind::TimedOut | std::io::ErrorKind::WouldBlock - ) -} - fn api_client_error_to_io(err: ApiClientError) -> std::io::Error { match err { ApiClientError::Io(err) => err, -- cgit v1.2.3