use agent_client_protocol_conductor::{ConductorImpl, McpBridgeMode, ProxiesAndAgent};
use agent_client_protocol_test::test_binaries::{arrow_proxy_example, testy};
use agent_client_protocol_test::testy::TestyCommand;
use agent_client_protocol_tokio::AcpAgent;
use tokio::io::duplex;
use tokio_util::compat::{TokioAsyncReadCompatExt, TokioAsyncWriteCompatExt};
#[tokio::test]
async fn test_conductor_with_two_external_arrow_proxies() -> Result<(), agent_client_protocol::Error>
{
let arrow_proxy1 = AcpAgent::from_args([arrow_proxy_example().to_string_lossy().to_string()])?;
let arrow_proxy2 = AcpAgent::from_args([arrow_proxy_example().to_string_lossy().to_string()])?;
let agent = testy();
let (editor_write, conductor_read) = duplex(8192);
let (conductor_write, editor_read) = duplex(8192);
let conductor_handle = tokio::spawn(async move {
ConductorImpl::new_agent(
"test-conductor".to_string(),
ProxiesAndAgent::new(agent)
.proxy(arrow_proxy1)
.proxy(arrow_proxy2),
McpBridgeMode::default(),
)
.run(agent_client_protocol::ByteStreams::new(
conductor_write.compat_write(),
conductor_read.compat(),
))
.await
});
let result = tokio::time::timeout(std::time::Duration::from_secs(30), async move {
let result = yopo::prompt(
agent_client_protocol::ByteStreams::new(
editor_write.compat_write(),
editor_read.compat(),
),
TestyCommand::Greet.to_prompt(),
)
.await?;
expect_test::expect![[r#"
">>Hello, world!"
"#]]
.assert_debug_eq(&result);
Ok::<String, agent_client_protocol::Error>(result)
})
.await
.expect("Test timed out")
.expect("Editor failed");
tracing::info!(
?result,
"Test completed successfully with double-arrow-prefixed response"
);
conductor_handle.abort();
Ok(())
}