extensions: add a display name field (#1759)
This commit is contained in:
@@ -10,6 +10,27 @@ use serde_json::{json, Value};
|
||||
use std::collections::HashMap;
|
||||
use std::error::Error;
|
||||
|
||||
fn get_display_name(extension_id: &str) -> String {
|
||||
match extension_id {
|
||||
"developer" => "Developer Tools".to_string(),
|
||||
"computercontroller" => "Computer Controller".to_string(),
|
||||
"googledrive" => "Google Drive".to_string(),
|
||||
"memory" => "Memory".to_string(),
|
||||
"tutorial" => "Tutorial".to_string(),
|
||||
"jetbrains" => "JetBrains".to_string(),
|
||||
// Add other extensions as needed
|
||||
_ => {
|
||||
extension_id
|
||||
.chars()
|
||||
.next()
|
||||
.unwrap_or_default()
|
||||
.to_uppercase()
|
||||
.collect::<String>()
|
||||
+ &extension_id[1..]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn handle_configure() -> Result<(), Box<dyn Error>> {
|
||||
let config = Config::global();
|
||||
|
||||
@@ -39,6 +60,7 @@ pub async fn handle_configure() -> Result<(), Box<dyn Error>> {
|
||||
enabled: true,
|
||||
config: ExtensionConfig::Builtin {
|
||||
name: "developer".to_string(),
|
||||
display_name: Some(goose::config::DEFAULT_DISPLAY_NAME.to_string()),
|
||||
timeout: Some(goose::config::DEFAULT_EXTENSION_TIMEOUT),
|
||||
},
|
||||
})?;
|
||||
@@ -464,10 +486,13 @@ pub fn configure_extensions_dialog() -> Result<(), Box<dyn Error>> {
|
||||
})
|
||||
.interact()?;
|
||||
|
||||
let display_name = get_display_name(&extension);
|
||||
|
||||
ExtensionManager::set(ExtensionEntry {
|
||||
enabled: true,
|
||||
config: ExtensionConfig::Builtin {
|
||||
name: extension.clone(),
|
||||
display_name: Some(display_name),
|
||||
timeout: Some(timeout),
|
||||
},
|
||||
})?;
|
||||
|
||||
@@ -133,6 +133,7 @@ impl Session {
|
||||
for name in builtin_name.split(',') {
|
||||
let config = ExtensionConfig::Builtin {
|
||||
name: name.trim().to_string(),
|
||||
display_name: None,
|
||||
// TODO: should set a timeout
|
||||
timeout: Some(goose::config::DEFAULT_EXTENSION_TIMEOUT),
|
||||
};
|
||||
|
||||
@@ -45,6 +45,7 @@ enum ExtensionConfigRequest {
|
||||
Builtin {
|
||||
/// The name of the built-in extension.
|
||||
name: String,
|
||||
display_name: Option<String>,
|
||||
timeout: Option<u64>,
|
||||
},
|
||||
}
|
||||
@@ -157,9 +158,15 @@ async fn add_extension(
|
||||
timeout,
|
||||
}
|
||||
}
|
||||
ExtensionConfigRequest::Builtin { name, timeout } => {
|
||||
ExtensionConfig::Builtin { name, timeout }
|
||||
}
|
||||
ExtensionConfigRequest::Builtin {
|
||||
name,
|
||||
display_name,
|
||||
timeout,
|
||||
} => ExtensionConfig::Builtin {
|
||||
name,
|
||||
display_name,
|
||||
timeout,
|
||||
},
|
||||
};
|
||||
|
||||
// Acquire a lock on the agent and attempt to add the extension.
|
||||
|
||||
@@ -134,7 +134,12 @@ impl Capabilities {
|
||||
);
|
||||
Box::new(McpClient::new(service))
|
||||
}
|
||||
ExtensionConfig::Builtin { name, timeout } => {
|
||||
#[allow(unused_variables)]
|
||||
ExtensionConfig::Builtin {
|
||||
name,
|
||||
display_name,
|
||||
timeout,
|
||||
} => {
|
||||
// For builtin extensions, we run the current executable with mcp and extension name
|
||||
let cmd = std::env::current_exe()
|
||||
.expect("should find the current executable")
|
||||
|
||||
@@ -78,6 +78,7 @@ pub enum ExtensionConfig {
|
||||
Builtin {
|
||||
/// The name used to identify this extension
|
||||
name: String,
|
||||
display_name: Option<String>, // needed for the UI
|
||||
timeout: Option<u64>,
|
||||
},
|
||||
}
|
||||
@@ -86,6 +87,7 @@ impl Default for ExtensionConfig {
|
||||
fn default() -> Self {
|
||||
Self::Builtin {
|
||||
name: config::DEFAULT_EXTENSION.to_string(),
|
||||
display_name: Some(config::DEFAULT_DISPLAY_NAME.to_string()),
|
||||
timeout: Some(config::DEFAULT_EXTENSION_TIMEOUT),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ use utoipa::ToSchema;
|
||||
pub const DEFAULT_EXTENSION: &str = "developer";
|
||||
pub const DEFAULT_EXTENSION_TIMEOUT: u64 = 300;
|
||||
pub const DEFAULT_EXTENSION_DESCRIPTION: &str = "";
|
||||
pub const DEFAULT_DISPLAY_NAME: &str = "Developer";
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize, Clone, ToSchema)]
|
||||
pub struct ExtensionEntry {
|
||||
@@ -42,6 +43,7 @@ impl ExtensionManager {
|
||||
enabled: true,
|
||||
config: ExtensionConfig::Builtin {
|
||||
name: DEFAULT_EXTENSION.to_string(),
|
||||
display_name: Some(DEFAULT_DISPLAY_NAME.to_string()),
|
||||
timeout: Some(DEFAULT_EXTENSION_TIMEOUT),
|
||||
},
|
||||
},
|
||||
|
||||
@@ -7,6 +7,7 @@ pub use base::{Config, ConfigError, APP_STRATEGY};
|
||||
pub use experiments::ExperimentManager;
|
||||
pub use extensions::{ExtensionEntry, ExtensionManager};
|
||||
|
||||
pub use extensions::DEFAULT_DISPLAY_NAME;
|
||||
pub use extensions::DEFAULT_EXTENSION;
|
||||
pub use extensions::DEFAULT_EXTENSION_DESCRIPTION;
|
||||
pub use extensions::DEFAULT_EXTENSION_TIMEOUT;
|
||||
|
||||
Reference in New Issue
Block a user