Configurable search paths (#5356)

This commit is contained in:
Jack Amadeo
2025-10-29 11:34:13 -04:00
committed by GitHub
parent e7ca2e3bf7
commit aaef18217f
6 changed files with 51 additions and 2 deletions
+2
View File
@@ -105,6 +105,8 @@ sys-info = "0.9"
oauth2 = "5.0.0"
schemars = { version = "1.0.4", default-features = false, features = ["derive"] }
insta = "1.43.2"
paste = "1.0.0"
shellexpand = "3.1.1"
[target.'cfg(target_os = "windows")'.dependencies]
@@ -32,6 +32,7 @@ use super::tool_execution::ToolCallResult;
use crate::agents::extension::{Envs, ProcessExit};
use crate::agents::extension_malware_check;
use crate::agents::mcp_client::{McpClient, McpClientTrait};
use crate::config::search_path::search_path_var;
use crate::config::{get_all_extensions, Config};
use crate::oauth::oauth_flow;
use crate::prompt_template;
@@ -182,6 +183,12 @@ async fn child_process_client(
command.process_group(0);
#[cfg(windows)]
command.creation_flags(CREATE_NO_WINDOW_FLAG);
command.env(
"PATH",
search_path_var().map_err(|e| ExtensionError::ConfigError(format!("{}", e)))?,
);
let (transport, mut stderr) = TokioChildProcess::builder(command)
.stderr(Stdio::piped())
.spawn()?;
+12
View File
@@ -136,6 +136,16 @@ impl Default for Config {
}
}
macro_rules! declare_param {
($param_name:ident, $param_type:ty) => {
paste::paste! {
pub fn [<get_ $param_name:lower>](&self) -> Result<$param_type, ConfigError> {
self.get_param(stringify!($param_name))
}
}
};
}
impl Config {
/// Get the global configuration instance.
///
@@ -730,6 +740,8 @@ impl Config {
};
Ok(())
}
declare_param!(GOOSE_SEARCH_PATHS, Vec<String>);
}
/// Load init-config.yaml from workspace root if it exists.
+1
View File
@@ -4,6 +4,7 @@ mod experiments;
pub mod extensions;
pub mod paths;
pub mod permission;
pub mod search_path;
pub mod signup_openrouter;
pub mod signup_tetrate;
+25
View File
@@ -0,0 +1,25 @@
use std::{env, ffi::OsString, path::PathBuf};
use crate::config::{Config, ConfigError};
pub fn search_path_var() -> Result<OsString, ConfigError> {
let paths = Config::global()
.get_goose_search_paths()
.or_else(|err| match err {
ConfigError::NotFound(_) => Ok(vec![]),
err => Err(err),
})?
.into_iter()
.map(|s| PathBuf::from(shellexpand::tilde(&s).as_ref()));
env::join_paths(
paths.chain(
env::var_os("PATH")
.as_ref()
.map(env::split_paths)
.into_iter()
.flatten(),
),
)
.map_err(|e| ConfigError::DeserializeError(format!("{}", e)))
}