Skip to main content

vtcode_config/core/
plugins.rs

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