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
37 changes: 35 additions & 2 deletions crates/goose-cli/src/commands/configure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -504,15 +504,31 @@ pub fn configure_extensions_dialog() -> Result<(), Box<dyn Error>> {
.placeholder(&goose::config::DEFAULT_EXTENSION_TIMEOUT.to_string())
.validate(|input: &String| match input.parse::<u64>() {
Ok(_) => Ok(()),
Err(_) => Err("Please enter a valide timeout"),
Err(_) => Err("Please enter a valid timeout"),
})
.interact()?;

// Split the command string into command and args
// TODO: find a way to expose this to the frontend so we dont need to re-write code
let mut parts = command_str.split_whitespace();
let cmd = parts.next().unwrap_or("").to_string();
let args: Vec<String> = parts.map(String::from).collect();

let add_desc = cliclack::confirm("Would you like to add a description?").interact()?;

let description = if add_desc {
let desc = cliclack::input("Enter a description for this extension:")
.placeholder("Description")
.validate(|input: &String| match input.parse::<String>() {
Ok(_) => Ok(()),
Err(_) => Err("Please enter a valid description"),
})
.interact()?;
Some(desc)
} else {
None
};

let add_env =
cliclack::confirm("Would you like to add environment variables?").interact()?;

Expand Down Expand Up @@ -542,6 +558,7 @@ pub fn configure_extensions_dialog() -> Result<(), Box<dyn Error>> {
cmd,
args,
envs: Envs::new(envs),
description,
timeout: Some(timeout),
},
})?;
Expand Down Expand Up @@ -580,10 +597,25 @@ pub fn configure_extensions_dialog() -> Result<(), Box<dyn Error>> {
.placeholder(&goose::config::DEFAULT_EXTENSION_TIMEOUT.to_string())
.validate(|input: &String| match input.parse::<u64>() {
Ok(_) => Ok(()),
Err(_) => Err("Please enter a valide timeout"),
Err(_) => Err("Please enter a valid timeout"),
})
.interact()?;

let add_desc = cliclack::confirm("Would you like to add a description?").interact()?;

let description = if add_desc {
let desc = cliclack::input("Enter a description for this extension:")
.placeholder("Description")
.validate(|input: &String| match input.parse::<String>() {
Ok(_) => Ok(()),
Err(_) => Err("Please enter a valid description"),
})
.interact()?;
Some(desc)
} else {
None
};

let add_env =
cliclack::confirm("Would you like to add environment variables?").interact()?;

Expand Down Expand Up @@ -612,6 +644,7 @@ pub fn configure_extensions_dialog() -> Result<(), Box<dyn Error>> {
name: name.clone(),
uri,
envs: Envs::new(envs),
description,
timeout: Some(timeout),
},
})?;
Expand Down
1 change: 1 addition & 0 deletions crates/goose-cli/src/session/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ impl Session {
cmd,
args: parts.iter().map(|s| s.to_string()).collect(),
envs: Envs::new(envs),
description: Some(goose::config::DEFAULT_EXTENSION_DESCRIPTION.to_string()),
// TODO: should set timeout
timeout: Some(goose::config::DEFAULT_EXTENSION_TIMEOUT),
};
Expand Down
2 changes: 2 additions & 0 deletions crates/goose-server/src/routes/extension.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ async fn add_extension(
name,
uri,
envs: Envs::new(env_map),
description: None,
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: i dont think this is in use yet but we'd want to expose this in the request and let it be set here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's in use, and im just putting a placeholder there because i think new endpoints will be slightly different and i dont want to accidentally mess things up?

timeout,
}
}
Expand Down Expand Up @@ -151,6 +152,7 @@ async fn add_extension(
name,
cmd,
args,
description: None,
envs: Envs::new(env_map),
timeout,
}
Expand Down
3 changes: 2 additions & 1 deletion crates/goose/examples/agent.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use dotenv::dotenv;
use futures::StreamExt;
use goose::agents::{AgentFactory, ExtensionConfig};
use goose::config::DEFAULT_EXTENSION_TIMEOUT;
use goose::config::{DEFAULT_EXTENSION_DESCRIPTION, DEFAULT_EXTENSION_TIMEOUT};
use goose::message::Message;
use goose::providers::databricks::DatabricksProvider;

Expand All @@ -18,6 +18,7 @@ async fn main() {
let config = ExtensionConfig::stdio(
"developer",
"./target/debug/developer",
DEFAULT_EXTENSION_DESCRIPTION,
DEFAULT_EXTENSION_TIMEOUT,
);
agent.add_extension(config).await.unwrap();
Expand Down
15 changes: 13 additions & 2 deletions crates/goose/src/agents/extension.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ pub enum ExtensionConfig {
uri: String,
#[serde(default)]
envs: Envs,
description: Option<String>,
// NOTE: set timeout to be optional for compatibility.
// However, new configurations should include this field.
timeout: Option<u64>,
Expand All @@ -70,6 +71,7 @@ pub enum ExtensionConfig {
#[serde(default)]
envs: Envs,
timeout: Option<u64>,
description: Option<String>,
},
/// Built-in extension that is part of the goose binary
#[serde(rename = "builtin")]
Expand All @@ -90,21 +92,28 @@ impl Default for ExtensionConfig {
}

impl ExtensionConfig {
pub fn sse<S: Into<String>, T: Into<u64>>(name: S, uri: S, timeout: T) -> Self {
pub fn sse<S: Into<String>, T: Into<u64>>(name: S, uri: S, description: S, timeout: T) -> Self {
Self::Sse {
name: name.into(),
uri: uri.into(),
envs: Envs::default(),
description: Some(description.into()),
timeout: Some(timeout.into()),
}
}

pub fn stdio<S: Into<String>, T: Into<u64>>(name: S, cmd: S, timeout: T) -> Self {
pub fn stdio<S: Into<String>, T: Into<u64>>(
name: S,
cmd: S,
description: S,
timeout: T,
) -> Self {
Self::Stdio {
name: name.into(),
cmd: cmd.into(),
args: vec![],
envs: Envs::default(),
description: Some(description.into()),
timeout: Some(timeout.into()),
}
}
Expand All @@ -120,12 +129,14 @@ impl ExtensionConfig {
cmd,
envs,
timeout,
description,
..
} => Self::Stdio {
name,
cmd,
envs,
args: args.into_iter().map(Into::into).collect(),
description,
timeout,
},
other => other,
Expand Down
1 change: 1 addition & 0 deletions crates/goose/src/config/extensions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use utoipa::ToSchema;

pub const DEFAULT_EXTENSION: &str = "developer";
pub const DEFAULT_EXTENSION_TIMEOUT: u64 = 300;
pub const DEFAULT_EXTENSION_DESCRIPTION: &str = "";

#[derive(Debug, Deserialize, Serialize, Clone, ToSchema)]
pub struct ExtensionEntry {
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 @@ -8,4 +8,5 @@ pub use experiments::ExperimentManager;
pub use extensions::{ExtensionEntry, ExtensionManager};

pub use extensions::DEFAULT_EXTENSION;
pub use extensions::DEFAULT_EXTENSION_DESCRIPTION;
pub use extensions::DEFAULT_EXTENSION_TIMEOUT;
Loading