Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions crates/goose/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
7 changes: 7 additions & 0 deletions crates/goose/src/agents/extension_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -182,6 +183,12 @@ async fn child_process_client(
command.process_group(0);
#[cfg(windows)]
command.creation_flags(CREATE_NO_WINDOW_FLAG);

command.env(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this overrides the main $PATH right? so user would need to know to set everything they need as not appending? (can the config include $PATH as an auto expanding var?)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

command.env overrides, but the search_path_var() function will do the appending

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah ok, nice.

"PATH",
search_path_var().map_err(|e| ExtensionError::ConfigError(format!("{}", e)))?,
);

let (transport, mut stderr) = TokioChildProcess::builder(command)
.stderr(Stdio::piped())
.spawn()?;
Expand Down
12 changes: 12 additions & 0 deletions crates/goose/src/config/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
///
Expand Down Expand Up @@ -730,6 +740,8 @@ impl Config {
};
Ok(())
}

declare_param!(GOOSE_SEARCH_PATHS, Vec<String>);
}

/// Load init-config.yaml from workspace root if it exists.
Expand Down
1 change: 1 addition & 0 deletions crates/goose/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
25 changes: 25 additions & 0 deletions crates/goose/src/config/search_path.rs
Original file line number Diff line number Diff line change
@@ -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)))
}
Loading