config: add optional extension description (#1743)
This commit is contained in:
@@ -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>,
|
||||
@@ -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")]
|
||||
@@ -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()),
|
||||
}
|
||||
}
|
||||
@@ -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,
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user