Lightweight coding agent that runs in your terminal
Rust
chore: add model/list call to app-server-test-client (#8331)
Owen Lincab7136fb38e
diff --git a/codex-rs/app-server-test-client/src/main.rs b/codex-rs/app-server-test-client/src/main.rsindex b66c59d55a..eefd123182 100644--- a/codex-rs/app-server-test-client/src/main.rs+++ b/codex-rs/app-server-test-client/src/main.rs@@ -35,6 +35,8 @@ use codex_app_server_protocol::JSONRPCRequest;use codex_app_server_protocol::JSONRPCResponse;use codex_app_server_protocol::LoginChatGptCompleteNotification;use codex_app_server_protocol::LoginChatGptResponse;+use codex_app_server_protocol::ModelListParams;+use codex_app_server_protocol::ModelListResponse;use codex_app_server_protocol::NewConversationParams;use codex_app_server_protocol::NewConversationResponse;use codex_app_server_protocol::RequestId;@@ -113,6 +115,9 @@ enum CliCommand {TestLogin,/// Fetch the current account rate limits from the Codex app-server.GetAccountRateLimits,+ /// List the available models from the Codex app-server.+ #[command(name = "model-list")]+ ModelList,}fn main() -> Result<()> {@@ -134,6 +139,7 @@ fn main() -> Result<()> {} => send_follow_up_v2(codex_bin, first_message, follow_up_message),CliCommand::TestLogin => test_login(codex_bin),CliCommand::GetAccountRateLimits => get_account_rate_limits(codex_bin),+ CliCommand::ModelList => model_list(codex_bin),}}@@ -301,6 +307,18 @@ fn get_account_rate_limits(codex_bin: String) -> Result<()> {Ok(())}+fn model_list(codex_bin: String) -> Result<()> {+ let mut client = CodexClient::spawn(codex_bin)?;++ let initialize = client.initialize()?;+ println!("< initialize response: {initialize:?}");++ let response = client.model_list(ModelListParams::default())?;+ println!("< model/list response: {response:?}");++ Ok(())+}+struct CodexClient {child: Child,stdin: Option<ChildStdin>,@@ -452,6 +470,16 @@ impl CodexClient {self.send_request(request, request_id, "account/rateLimits/read")}+ fn model_list(&mut self, params: ModelListParams) -> Result<ModelListResponse> {+ let request_id = self.request_id();+ let request = ClientRequest::ModelList {+ request_id: request_id.clone(),+ params,+ };++ self.send_request(request, request_id, "model/list")+ }+fn stream_conversation(&mut self, conversation_id: &ConversationId) -> Result<()> {loop {let notification = self.next_notification()?;