fix: remove data_dir from AcpServerFactoryConfig, resolve from Paths::data_dir() (#12203)
This commit is contained in:
@@ -1799,7 +1799,6 @@ async fn handle_serve_command(args: ServeCommandArgs) -> Result<()> {
|
||||
|
||||
let server = Arc::new(AcpServer::new(AcpServerFactoryConfig {
|
||||
builtins,
|
||||
data_dir: Paths::data_dir(),
|
||||
config_dir: Paths::config_dir(),
|
||||
goose_platform: platform.into(),
|
||||
additional_source_roots,
|
||||
|
||||
@@ -698,7 +698,6 @@ async fn handle_share(
|
||||
|
||||
let acp_server = Arc::new(AcpServer::new(AcpServerFactoryConfig {
|
||||
builtins,
|
||||
data_dir: Paths::data_dir(),
|
||||
config_dir: Paths::config_dir(),
|
||||
goose_platform: GoosePlatform::GooseCli,
|
||||
additional_source_roots: Vec::new(),
|
||||
|
||||
@@ -944,7 +944,6 @@ impl GooseAcpAgent {
|
||||
.unwrap_or(false)
|
||||
}
|
||||
|
||||
// TODO: goose reads Paths::in_state_dir globally (e.g. RequestLog), ignoring this data_dir.
|
||||
pub async fn new(options: GooseAcpAgentOptions) -> Result<Self> {
|
||||
let session_manager = Arc::new(SessionManager::new(options.data_dir));
|
||||
|
||||
@@ -2713,7 +2712,6 @@ pub async fn run(builtins: Vec<String>, enable_scheduler: bool) -> Result<()> {
|
||||
let server = crate::acp::server_factory::AcpServer::new(
|
||||
crate::acp::server_factory::AcpServerFactoryConfig {
|
||||
builtins: AcpBuiltinSelection::from_requested(builtins),
|
||||
data_dir: Paths::data_dir(),
|
||||
config_dir: Paths::config_dir(),
|
||||
goose_platform: GoosePlatform::GooseCli,
|
||||
additional_source_roots: Vec::new(),
|
||||
@@ -3272,11 +3270,12 @@ print(\"hello, world\")
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(empty_audience_content.len(), 2);
|
||||
assert!(empty_audience_content.iter().all(|text| text
|
||||
.annotations
|
||||
.as_ref()
|
||||
.and_then(|annotations| annotations.audience.as_ref())
|
||||
.is_some_and(Vec::is_empty)));
|
||||
assert!(empty_audience_content.iter().all(|text| {
|
||||
text.annotations
|
||||
.as_ref()
|
||||
.and_then(|annotations| annotations.audience.as_ref())
|
||||
.is_some_and(Vec::is_empty)
|
||||
}));
|
||||
assert!(audience_omitted_content.annotations.is_none());
|
||||
assert!(user_content.as_concat_text().contains("visible text"));
|
||||
assert!(user_content
|
||||
|
||||
@@ -371,7 +371,6 @@ mod tests {
|
||||
]);
|
||||
let server = AcpServer::new(AcpServerFactoryConfig {
|
||||
builtins: AcpBuiltinSelection::default(),
|
||||
data_dir: root.path().join("data"),
|
||||
config_dir: root.path().join("config"),
|
||||
goose_platform: GoosePlatform::GooseCli,
|
||||
additional_source_roots: Vec::new(),
|
||||
|
||||
@@ -3,6 +3,7 @@ use crate::acp::server::{
|
||||
GooseAcpAgentOptions, LiveVoiceService,
|
||||
};
|
||||
use crate::agents::GoosePlatform;
|
||||
use crate::config::paths::Paths;
|
||||
use crate::scheduler_trait::SchedulerTrait;
|
||||
use crate::session::SessionManager;
|
||||
use crate::source_roots::SourceRoot;
|
||||
@@ -13,7 +14,6 @@ use tracing::info;
|
||||
|
||||
pub struct AcpServerFactoryConfig {
|
||||
pub builtins: AcpBuiltinSelection,
|
||||
pub data_dir: std::path::PathBuf,
|
||||
pub config_dir: std::path::PathBuf,
|
||||
pub goose_platform: GoosePlatform,
|
||||
pub additional_source_roots: Vec<SourceRoot>,
|
||||
@@ -26,6 +26,7 @@ pub struct AcpServerFactoryConfig {
|
||||
|
||||
pub struct AcpServer {
|
||||
config: AcpServerFactoryConfig,
|
||||
data_dir: std::path::PathBuf,
|
||||
scheduler: OnceCell<Arc<dyn SchedulerTrait>>,
|
||||
active_runs: Arc<ActiveRunRegistry>,
|
||||
live_voice: Arc<crate::acp::server::LiveVoiceService>,
|
||||
@@ -33,10 +34,12 @@ pub struct AcpServer {
|
||||
|
||||
impl AcpServer {
|
||||
pub fn new(config: AcpServerFactoryConfig) -> Self {
|
||||
let data_dir = Paths::data_dir();
|
||||
let active_runs = Arc::new(ActiveRunRegistry::default());
|
||||
let live_voice = Arc::new(LiveVoiceService::from_config(active_runs.clone()));
|
||||
Self {
|
||||
config,
|
||||
data_dir,
|
||||
scheduler: OnceCell::new(),
|
||||
active_runs,
|
||||
live_voice,
|
||||
@@ -55,7 +58,7 @@ impl AcpServer {
|
||||
return Ok(None);
|
||||
}
|
||||
|
||||
let data_dir = self.config.data_dir.clone();
|
||||
let data_dir = self.data_dir.clone();
|
||||
self.scheduler
|
||||
.get_or_try_init(|| async move {
|
||||
let session_manager = Arc::new(SessionManager::new(data_dir.clone()));
|
||||
@@ -121,7 +124,7 @@ impl AcpServer {
|
||||
let agent = GooseAcpAgent::new(GooseAcpAgentOptions {
|
||||
provider_factory,
|
||||
builtin_selection: self.config.builtins.clone(),
|
||||
data_dir: self.config.data_dir.clone(),
|
||||
data_dir: self.data_dir.clone(),
|
||||
config_dir: self.config.config_dir.clone(),
|
||||
disable_session_naming,
|
||||
goose_platform: self.config.goose_platform.clone(),
|
||||
@@ -136,6 +139,22 @@ impl AcpServer {
|
||||
|
||||
Ok(Arc::new(agent))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
pub(crate) fn new_for_test(
|
||||
config: AcpServerFactoryConfig,
|
||||
data_dir: std::path::PathBuf,
|
||||
) -> Self {
|
||||
let active_runs = Arc::new(ActiveRunRegistry::default());
|
||||
let live_voice = Arc::new(LiveVoiceService::from_config(active_runs.clone()));
|
||||
Self {
|
||||
config,
|
||||
data_dir,
|
||||
scheduler: OnceCell::new(),
|
||||
active_runs,
|
||||
live_voice,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
@@ -143,15 +162,17 @@ mod tests {
|
||||
use super::*;
|
||||
|
||||
fn server(data_dir: std::path::PathBuf, enable_scheduler: bool) -> AcpServer {
|
||||
AcpServer::new(AcpServerFactoryConfig {
|
||||
builtins: AcpBuiltinSelection::default(),
|
||||
config_dir: data_dir.clone(),
|
||||
AcpServer::new_for_test(
|
||||
AcpServerFactoryConfig {
|
||||
builtins: AcpBuiltinSelection::default(),
|
||||
config_dir: data_dir.clone(),
|
||||
goose_platform: GoosePlatform::GooseCli,
|
||||
additional_source_roots: Vec::new(),
|
||||
session_cwd: None,
|
||||
enable_scheduler,
|
||||
},
|
||||
data_dir,
|
||||
goose_platform: GoosePlatform::GooseCli,
|
||||
additional_source_roots: Vec::new(),
|
||||
session_cwd: None,
|
||||
enable_scheduler,
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
|
||||
@@ -19,7 +19,6 @@ fn test_router(require_token: bool, dir: &tempfile::TempDir) -> Router {
|
||||
fn test_acp_router(dir: &tempfile::TempDir) -> Router {
|
||||
let server = Arc::new(AcpServer::new(AcpServerFactoryConfig {
|
||||
builtins: AcpBuiltinSelection::default(),
|
||||
data_dir: dir.path().join("data"),
|
||||
config_dir: dir.path().join("config"),
|
||||
goose_platform: GoosePlatform::GooseCli,
|
||||
additional_source_roots: Vec::new(),
|
||||
@@ -32,7 +31,6 @@ fn test_acp_router(dir: &tempfile::TempDir) -> Router {
|
||||
fn test_authenticated_acp_router(dir: &tempfile::TempDir) -> Router {
|
||||
let server = Arc::new(AcpServer::new(AcpServerFactoryConfig {
|
||||
builtins: AcpBuiltinSelection::default(),
|
||||
data_dir: dir.path().join("data"),
|
||||
config_dir: dir.path().join("config"),
|
||||
goose_platform: GoosePlatform::GooseCli,
|
||||
additional_source_roots: Vec::new(),
|
||||
@@ -49,7 +47,6 @@ fn test_router_with_origins(
|
||||
) -> Router {
|
||||
let server = Arc::new(AcpServer::new(AcpServerFactoryConfig {
|
||||
builtins: AcpBuiltinSelection::default(),
|
||||
data_dir: dir.path().join("data"),
|
||||
config_dir: dir.path().join("config"),
|
||||
goose_platform: GoosePlatform::GooseCli,
|
||||
additional_source_roots: Vec::new(),
|
||||
|
||||
Reference in New Issue
Block a user