feat: ACP providers for claude code and codex (#6605)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
This commit is contained in:
@@ -4,15 +4,12 @@
|
||||
|
||||
#[path = "../fixtures/mod.rs"]
|
||||
pub mod fixtures;
|
||||
use fixtures::{
|
||||
initialize_agent, Connection, OpenAiFixture, PermissionDecision, Session, TestConnectionConfig,
|
||||
};
|
||||
use fixtures::{Connection, OpenAiFixture, PermissionDecision, Session, TestConnectionConfig};
|
||||
use fs_err as fs;
|
||||
use goose::config::base::CONFIG_YAML_NAME;
|
||||
use goose::config::GooseMode;
|
||||
use goose::providers::provider_registry::ProviderConstructor;
|
||||
use goose_acp::server::GooseAcpAgent;
|
||||
use goose_test_support::{ExpectedSessionId, McpFixture, FAKE_CODE, TEST_MODEL};
|
||||
use goose_test_support::{ExpectedSessionId, McpFixture, FAKE_CODE, TEST_IMAGE_B64, TEST_MODEL};
|
||||
use sacp::schema::{McpServer, McpServerHttp, ModelId, ToolCallStatus};
|
||||
use std::sync::Arc;
|
||||
|
||||
@@ -57,29 +54,20 @@ pub async fn run_config_mcp<C: Connection>() {
|
||||
expected_session_id.assert_matches(&session.session_id().0);
|
||||
}
|
||||
|
||||
pub async fn run_initialize_without_provider() {
|
||||
let temp_dir = tempfile::tempdir().unwrap();
|
||||
|
||||
pub async fn run_initialize_doesnt_hit_provider<C: Connection>() {
|
||||
let provider_factory: ProviderConstructor =
|
||||
Arc::new(|_, _| Box::pin(async { Err(anyhow::anyhow!("no provider configured")) }));
|
||||
|
||||
let agent = Arc::new(
|
||||
GooseAcpAgent::new(
|
||||
provider_factory,
|
||||
vec![],
|
||||
temp_dir.path().to_path_buf(),
|
||||
temp_dir.path().to_path_buf(),
|
||||
GooseMode::Auto,
|
||||
false,
|
||||
)
|
||||
.await
|
||||
.unwrap(),
|
||||
);
|
||||
let openai = OpenAiFixture::new(vec![], ExpectedSessionId::default()).await;
|
||||
let config = TestConnectionConfig {
|
||||
provider_factory: Some(provider_factory),
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
let resp = initialize_agent(agent).await;
|
||||
assert!(!resp.auth_methods.is_empty());
|
||||
assert!(resp
|
||||
.auth_methods
|
||||
let conn = C::new(config, openai).await;
|
||||
assert!(!conn.auth_methods().is_empty());
|
||||
assert!(conn
|
||||
.auth_methods()
|
||||
.iter()
|
||||
.any(|m| &*m.id.0 == "goose-provider"));
|
||||
}
|
||||
@@ -334,6 +322,33 @@ pub async fn run_prompt_image<C: Connection>() {
|
||||
expected_session_id.assert_matches(&session.session_id().0);
|
||||
}
|
||||
|
||||
pub async fn run_prompt_image_attachment<C: Connection>() {
|
||||
let expected_session_id = ExpectedSessionId::default();
|
||||
let openai = OpenAiFixture::new(
|
||||
vec![(
|
||||
r#""type":"image_url""#.into(),
|
||||
include_str!("../test_data/openai_image_attachment.txt"),
|
||||
)],
|
||||
expected_session_id.clone(),
|
||||
)
|
||||
.await;
|
||||
|
||||
let mut conn = C::new(TestConnectionConfig::default(), openai).await;
|
||||
let (mut session, _) = conn.new_session().await;
|
||||
expected_session_id.set(session.session_id().0.to_string());
|
||||
|
||||
let output = session
|
||||
.prompt_with_image(
|
||||
"Describe what you see in this image",
|
||||
TEST_IMAGE_B64,
|
||||
"image/png",
|
||||
PermissionDecision::Cancel,
|
||||
)
|
||||
.await;
|
||||
assert!(output.text.contains("Hello Goose!"));
|
||||
expected_session_id.assert_matches(&session.session_id().0);
|
||||
}
|
||||
|
||||
pub async fn run_prompt_mcp<C: Connection>() {
|
||||
let expected_session_id = ExpectedSessionId::default();
|
||||
let mcp = McpFixture::new(Some(expected_session_id.clone())).await;
|
||||
|
||||
Reference in New Issue
Block a user