config: add optional extension description (#1743)
This commit is contained in:
@@ -504,15 +504,31 @@ pub fn configure_extensions_dialog() -> Result<(), Box<dyn Error>> {
|
|||||||
.placeholder(&goose::config::DEFAULT_EXTENSION_TIMEOUT.to_string())
|
.placeholder(&goose::config::DEFAULT_EXTENSION_TIMEOUT.to_string())
|
||||||
.validate(|input: &String| match input.parse::<u64>() {
|
.validate(|input: &String| match input.parse::<u64>() {
|
||||||
Ok(_) => Ok(()),
|
Ok(_) => Ok(()),
|
||||||
Err(_) => Err("Please enter a valide timeout"),
|
Err(_) => Err("Please enter a valid timeout"),
|
||||||
})
|
})
|
||||||
.interact()?;
|
.interact()?;
|
||||||
|
|
||||||
// Split the command string into command and args
|
// 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 mut parts = command_str.split_whitespace();
|
||||||
let cmd = parts.next().unwrap_or("").to_string();
|
let cmd = parts.next().unwrap_or("").to_string();
|
||||||
let args: Vec<String> = parts.map(String::from).collect();
|
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 =
|
let add_env =
|
||||||
cliclack::confirm("Would you like to add environment variables?").interact()?;
|
cliclack::confirm("Would you like to add environment variables?").interact()?;
|
||||||
|
|
||||||
@@ -542,6 +558,7 @@ pub fn configure_extensions_dialog() -> Result<(), Box<dyn Error>> {
|
|||||||
cmd,
|
cmd,
|
||||||
args,
|
args,
|
||||||
envs: Envs::new(envs),
|
envs: Envs::new(envs),
|
||||||
|
description,
|
||||||
timeout: Some(timeout),
|
timeout: Some(timeout),
|
||||||
},
|
},
|
||||||
})?;
|
})?;
|
||||||
@@ -580,10 +597,25 @@ pub fn configure_extensions_dialog() -> Result<(), Box<dyn Error>> {
|
|||||||
.placeholder(&goose::config::DEFAULT_EXTENSION_TIMEOUT.to_string())
|
.placeholder(&goose::config::DEFAULT_EXTENSION_TIMEOUT.to_string())
|
||||||
.validate(|input: &String| match input.parse::<u64>() {
|
.validate(|input: &String| match input.parse::<u64>() {
|
||||||
Ok(_) => Ok(()),
|
Ok(_) => Ok(()),
|
||||||
Err(_) => Err("Please enter a valide timeout"),
|
Err(_) => Err("Please enter a valid timeout"),
|
||||||
})
|
})
|
||||||
.interact()?;
|
.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 =
|
let add_env =
|
||||||
cliclack::confirm("Would you like to add environment variables?").interact()?;
|
cliclack::confirm("Would you like to add environment variables?").interact()?;
|
||||||
|
|
||||||
@@ -612,6 +644,7 @@ pub fn configure_extensions_dialog() -> Result<(), Box<dyn Error>> {
|
|||||||
name: name.clone(),
|
name: name.clone(),
|
||||||
uri,
|
uri,
|
||||||
envs: Envs::new(envs),
|
envs: Envs::new(envs),
|
||||||
|
description,
|
||||||
timeout: Some(timeout),
|
timeout: Some(timeout),
|
||||||
},
|
},
|
||||||
})?;
|
})?;
|
||||||
|
|||||||
@@ -109,6 +109,7 @@ impl Session {
|
|||||||
cmd,
|
cmd,
|
||||||
args: parts.iter().map(|s| s.to_string()).collect(),
|
args: parts.iter().map(|s| s.to_string()).collect(),
|
||||||
envs: Envs::new(envs),
|
envs: Envs::new(envs),
|
||||||
|
description: Some(goose::config::DEFAULT_EXTENSION_DESCRIPTION.to_string()),
|
||||||
// TODO: should set timeout
|
// TODO: should set timeout
|
||||||
timeout: Some(goose::config::DEFAULT_EXTENSION_TIMEOUT),
|
timeout: Some(goose::config::DEFAULT_EXTENSION_TIMEOUT),
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -115,6 +115,7 @@ async fn add_extension(
|
|||||||
name,
|
name,
|
||||||
uri,
|
uri,
|
||||||
envs: Envs::new(env_map),
|
envs: Envs::new(env_map),
|
||||||
|
description: None,
|
||||||
timeout,
|
timeout,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -151,6 +152,7 @@ async fn add_extension(
|
|||||||
name,
|
name,
|
||||||
cmd,
|
cmd,
|
||||||
args,
|
args,
|
||||||
|
description: None,
|
||||||
envs: Envs::new(env_map),
|
envs: Envs::new(env_map),
|
||||||
timeout,
|
timeout,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
use dotenv::dotenv;
|
use dotenv::dotenv;
|
||||||
use futures::StreamExt;
|
use futures::StreamExt;
|
||||||
use goose::agents::{AgentFactory, ExtensionConfig};
|
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::message::Message;
|
||||||
use goose::providers::databricks::DatabricksProvider;
|
use goose::providers::databricks::DatabricksProvider;
|
||||||
|
|
||||||
@@ -18,6 +18,7 @@ async fn main() {
|
|||||||
let config = ExtensionConfig::stdio(
|
let config = ExtensionConfig::stdio(
|
||||||
"developer",
|
"developer",
|
||||||
"./target/debug/developer",
|
"./target/debug/developer",
|
||||||
|
DEFAULT_EXTENSION_DESCRIPTION,
|
||||||
DEFAULT_EXTENSION_TIMEOUT,
|
DEFAULT_EXTENSION_TIMEOUT,
|
||||||
);
|
);
|
||||||
agent.add_extension(config).await.unwrap();
|
agent.add_extension(config).await.unwrap();
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ pub enum ExtensionConfig {
|
|||||||
uri: String,
|
uri: String,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
envs: Envs,
|
envs: Envs,
|
||||||
|
description: Option<String>,
|
||||||
// NOTE: set timeout to be optional for compatibility.
|
// NOTE: set timeout to be optional for compatibility.
|
||||||
// However, new configurations should include this field.
|
// However, new configurations should include this field.
|
||||||
timeout: Option<u64>,
|
timeout: Option<u64>,
|
||||||
@@ -70,6 +71,7 @@ pub enum ExtensionConfig {
|
|||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
envs: Envs,
|
envs: Envs,
|
||||||
timeout: Option<u64>,
|
timeout: Option<u64>,
|
||||||
|
description: Option<String>,
|
||||||
},
|
},
|
||||||
/// Built-in extension that is part of the goose binary
|
/// Built-in extension that is part of the goose binary
|
||||||
#[serde(rename = "builtin")]
|
#[serde(rename = "builtin")]
|
||||||
@@ -90,21 +92,28 @@ impl Default for ExtensionConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl 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 {
|
Self::Sse {
|
||||||
name: name.into(),
|
name: name.into(),
|
||||||
uri: uri.into(),
|
uri: uri.into(),
|
||||||
envs: Envs::default(),
|
envs: Envs::default(),
|
||||||
|
description: Some(description.into()),
|
||||||
timeout: Some(timeout.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 {
|
Self::Stdio {
|
||||||
name: name.into(),
|
name: name.into(),
|
||||||
cmd: cmd.into(),
|
cmd: cmd.into(),
|
||||||
args: vec![],
|
args: vec![],
|
||||||
envs: Envs::default(),
|
envs: Envs::default(),
|
||||||
|
description: Some(description.into()),
|
||||||
timeout: Some(timeout.into()),
|
timeout: Some(timeout.into()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -120,12 +129,14 @@ impl ExtensionConfig {
|
|||||||
cmd,
|
cmd,
|
||||||
envs,
|
envs,
|
||||||
timeout,
|
timeout,
|
||||||
|
description,
|
||||||
..
|
..
|
||||||
} => Self::Stdio {
|
} => Self::Stdio {
|
||||||
name,
|
name,
|
||||||
cmd,
|
cmd,
|
||||||
envs,
|
envs,
|
||||||
args: args.into_iter().map(Into::into).collect(),
|
args: args.into_iter().map(Into::into).collect(),
|
||||||
|
description,
|
||||||
timeout,
|
timeout,
|
||||||
},
|
},
|
||||||
other => other,
|
other => other,
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ use utoipa::ToSchema;
|
|||||||
|
|
||||||
pub const DEFAULT_EXTENSION: &str = "developer";
|
pub const DEFAULT_EXTENSION: &str = "developer";
|
||||||
pub const DEFAULT_EXTENSION_TIMEOUT: u64 = 300;
|
pub const DEFAULT_EXTENSION_TIMEOUT: u64 = 300;
|
||||||
|
pub const DEFAULT_EXTENSION_DESCRIPTION: &str = "";
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Serialize, Clone, ToSchema)]
|
#[derive(Debug, Deserialize, Serialize, Clone, ToSchema)]
|
||||||
pub struct ExtensionEntry {
|
pub struct ExtensionEntry {
|
||||||
|
|||||||
@@ -8,4 +8,5 @@ pub use experiments::ExperimentManager;
|
|||||||
pub use extensions::{ExtensionEntry, ExtensionManager};
|
pub use extensions::{ExtensionEntry, ExtensionManager};
|
||||||
|
|
||||||
pub use extensions::DEFAULT_EXTENSION;
|
pub use extensions::DEFAULT_EXTENSION;
|
||||||
|
pub use extensions::DEFAULT_EXTENSION_DESCRIPTION;
|
||||||
pub use extensions::DEFAULT_EXTENSION_TIMEOUT;
|
pub use extensions::DEFAULT_EXTENSION_TIMEOUT;
|
||||||
|
|||||||
Reference in New Issue
Block a user