vtcode_config/core/
plugins.rs

1use serde::{Deserialize, Serialize};
2
3/// Trust model for third-party plugins.
4#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
5#[derive(Debug, Clone, Copy, Deserialize, Serialize, PartialEq, Eq, Default)]
6#[serde(rename_all = "snake_case")]
7pub enum PluginTrustLevel {
8    /// Default sandboxed mode; restricts elevated capabilities.
9    #[default]
10    Sandbox,
11    /// Explicitly trusted plugins that may request expanded capabilities.
12    Trusted,
13    /// Untrusted plugins run with strict isolation.
14    Untrusted,
15}
16
17/// Runtime configuration for dynamic plugin loading.
18#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
19#[derive(Debug, Clone, Deserialize, Serialize)]
20pub struct PluginRuntimeConfig {
21    /// Toggle the plugin runtime. When disabled, manifests are ignored.
22    #[serde(default = "default_enabled")]
23    pub enabled: bool,
24
25    /// Manifest paths (files or directories) that should be scanned for plugins.
26    #[serde(default)]
27    pub manifests: Vec<String>,
28
29    /// Default trust level when a manifest omits trust metadata.
30    #[serde(default)]
31    pub default_trust: PluginTrustLevel,
32
33    /// Explicit allow-list of plugin identifiers permitted to load.
34    #[serde(default)]
35    pub allow: Vec<String>,
36
37    /// Explicit block-list of plugin identifiers that must be rejected.
38    #[serde(default)]
39    pub deny: Vec<String>,
40
41    /// Enable hot-reload polling for manifests to support rapid iteration.
42    #[serde(default)]
43    pub auto_reload: bool,
44}
45
46impl Default for PluginRuntimeConfig {
47    fn default() -> Self {
48        Self {
49            enabled: true,
50            manifests: Vec::new(),
51            default_trust: PluginTrustLevel::Sandbox,
52            allow: Vec::new(),
53            deny: Vec::new(),
54            auto_reload: true,
55        }
56    }
57}
58
59fn default_enabled() -> bool {
60    true
61}