extension.rs

 1use std::sync::Arc;
 2
 3use collections::HashMap;
 4use schemars::JsonSchema;
 5use serde::{Deserialize, Serialize};
 6use settings_macros::{MergeFrom, with_fallible_options};
 7
 8#[with_fallible_options]
 9#[derive(Debug, PartialEq, Clone, Default, Serialize, Deserialize, JsonSchema, MergeFrom)]
10pub struct ExtensionSettingsContent {
11    /// The extensions that should be automatically installed by Zed.
12    ///
13    /// This is used to make functionality provided by extensions (e.g., language support)
14    /// available out-of-the-box.
15    ///
16    /// Default: { "html": true }
17    #[serde(default)]
18    pub auto_install_extensions: HashMap<Arc<str>, bool>,
19    #[serde(default)]
20    pub auto_update_extensions: HashMap<Arc<str>, bool>,
21    /// The capabilities granted to extensions.
22    pub granted_extension_capabilities: Option<Vec<ExtensionCapabilityContent>>,
23    /// Extension language model providers that are allowed to read API keys from
24    /// environment variables. Each entry is a provider ID in the format
25    /// "extension_id:provider_id" (e.g., "openai:openai").
26    ///
27    /// Default: []
28    pub allowed_env_var_providers: Option<Vec<Arc<str>>>,
29    /// Tracks which legacy LLM providers have been migrated. This is an internal
30    /// setting used to prevent the migration from running multiple times.
31    pub migrated_llm_providers: Option<Vec<Arc<str>>>,
32}
33
34/// A capability for an extension.
35#[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize, JsonSchema)]
36#[serde(tag = "kind", rename_all = "snake_case")]
37pub enum ExtensionCapabilityContent {
38    #[serde(rename = "process:exec")]
39    ProcessExec {
40        /// The command to execute.
41        command: String,
42        /// The arguments to pass to the command. Use `*` for a single wildcard argument.
43        /// If the last element is `**`, then any trailing arguments are allowed.
44        args: Vec<String>,
45    },
46    DownloadFile {
47        host: String,
48        path: Vec<String>,
49    },
50    #[serde(rename = "npm:install")]
51    NpmInstallPackage {
52        package: String,
53    },
54}