Configurable search paths (#5356)
This commit is contained in:
Generated
+4
-2
@@ -2648,6 +2648,7 @@ dependencies = [
|
|||||||
"opentelemetry",
|
"opentelemetry",
|
||||||
"opentelemetry-otlp",
|
"opentelemetry-otlp",
|
||||||
"opentelemetry_sdk",
|
"opentelemetry_sdk",
|
||||||
|
"paste",
|
||||||
"rand 0.8.5",
|
"rand 0.8.5",
|
||||||
"regex",
|
"regex",
|
||||||
"reqwest 0.12.12",
|
"reqwest 0.12.12",
|
||||||
@@ -2659,6 +2660,7 @@ dependencies = [
|
|||||||
"serde_yaml",
|
"serde_yaml",
|
||||||
"serial_test",
|
"serial_test",
|
||||||
"sha2",
|
"sha2",
|
||||||
|
"shellexpand",
|
||||||
"sqlx",
|
"sqlx",
|
||||||
"sys-info",
|
"sys-info",
|
||||||
"temp-env",
|
"temp-env",
|
||||||
@@ -6129,9 +6131,9 @@ checksum = "24188a676b6ae68c3b2cb3a01be17fbf7240ce009799bb56d5b1409051e78fde"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "shellexpand"
|
name = "shellexpand"
|
||||||
version = "3.1.0"
|
version = "3.1.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "da03fa3b94cc19e3ebfc88c4229c49d8f08cdbd1228870a45f0ffdf84988e14b"
|
checksum = "8b1fdf65dd6331831494dd616b30351c38e96e45921a27745cf98490458b90bb"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"dirs",
|
"dirs",
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -105,6 +105,8 @@ sys-info = "0.9"
|
|||||||
oauth2 = "5.0.0"
|
oauth2 = "5.0.0"
|
||||||
schemars = { version = "1.0.4", default-features = false, features = ["derive"] }
|
schemars = { version = "1.0.4", default-features = false, features = ["derive"] }
|
||||||
insta = "1.43.2"
|
insta = "1.43.2"
|
||||||
|
paste = "1.0.0"
|
||||||
|
shellexpand = "3.1.1"
|
||||||
|
|
||||||
|
|
||||||
[target.'cfg(target_os = "windows")'.dependencies]
|
[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::{Envs, ProcessExit};
|
||||||
use crate::agents::extension_malware_check;
|
use crate::agents::extension_malware_check;
|
||||||
use crate::agents::mcp_client::{McpClient, McpClientTrait};
|
use crate::agents::mcp_client::{McpClient, McpClientTrait};
|
||||||
|
use crate::config::search_path::search_path_var;
|
||||||
use crate::config::{get_all_extensions, Config};
|
use crate::config::{get_all_extensions, Config};
|
||||||
use crate::oauth::oauth_flow;
|
use crate::oauth::oauth_flow;
|
||||||
use crate::prompt_template;
|
use crate::prompt_template;
|
||||||
@@ -182,6 +183,12 @@ async fn child_process_client(
|
|||||||
command.process_group(0);
|
command.process_group(0);
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
command.creation_flags(CREATE_NO_WINDOW_FLAG);
|
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)
|
let (transport, mut stderr) = TokioChildProcess::builder(command)
|
||||||
.stderr(Stdio::piped())
|
.stderr(Stdio::piped())
|
||||||
.spawn()?;
|
.spawn()?;
|
||||||
|
|||||||
@@ -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 {
|
impl Config {
|
||||||
/// Get the global configuration instance.
|
/// Get the global configuration instance.
|
||||||
///
|
///
|
||||||
@@ -730,6 +740,8 @@ impl Config {
|
|||||||
};
|
};
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
declare_param!(GOOSE_SEARCH_PATHS, Vec<String>);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Load init-config.yaml from workspace root if it exists.
|
/// Load init-config.yaml from workspace root if it exists.
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ mod experiments;
|
|||||||
pub mod extensions;
|
pub mod extensions;
|
||||||
pub mod paths;
|
pub mod paths;
|
||||||
pub mod permission;
|
pub mod permission;
|
||||||
|
pub mod search_path;
|
||||||
pub mod signup_openrouter;
|
pub mod signup_openrouter;
|
||||||
pub mod signup_tetrate;
|
pub mod signup_tetrate;
|
||||||
|
|
||||||
|
|||||||
@@ -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)))
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user