mirror of
https://github.com/openai/codex.git
synced 2026-06-01 19:02:59 +00:00
chore: use AVAILABLE and ON_INSTALL as default plugin install and auth policies (#14407)
make `AVAILABLE` the default plugin installPolicy when unset in `marketplace.json`. similarly, make `ON_INSTALL` the default authPolicy. this means, when unset, plugins are available to be installed (but not auto-installed), and the contained connectors will be authed at install-time. updated tests.
This commit is contained in:
@@ -75,7 +75,7 @@ pub struct PluginInstallOutcome {
|
||||
pub plugin_id: PluginId,
|
||||
pub plugin_version: String,
|
||||
pub installed_path: AbsolutePathBuf,
|
||||
pub auth_policy: Option<MarketplacePluginAuthPolicy>,
|
||||
pub auth_policy: MarketplacePluginAuthPolicy,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
@@ -90,8 +90,8 @@ pub struct ConfiguredMarketplacePluginSummary {
|
||||
pub id: String,
|
||||
pub name: String,
|
||||
pub source: MarketplacePluginSourceSummary,
|
||||
pub install_policy: Option<MarketplacePluginInstallPolicy>,
|
||||
pub auth_policy: Option<MarketplacePluginAuthPolicy>,
|
||||
pub install_policy: MarketplacePluginInstallPolicy,
|
||||
pub auth_policy: MarketplacePluginAuthPolicy,
|
||||
pub interface: Option<PluginManifestInterfaceSummary>,
|
||||
pub installed: bool,
|
||||
pub enabled: bool,
|
||||
@@ -1972,7 +1972,7 @@ mod tests {
|
||||
plugin_id: PluginId::new("sample-plugin".to_string(), "debug".to_string()).unwrap(),
|
||||
plugin_version: "local".to_string(),
|
||||
installed_path: AbsolutePathBuf::try_from(installed_path).unwrap(),
|
||||
auth_policy: Some(MarketplacePluginAuthPolicy::OnUse),
|
||||
auth_policy: MarketplacePluginAuthPolicy::OnUse,
|
||||
}
|
||||
);
|
||||
|
||||
@@ -2102,8 +2102,8 @@ enabled = false
|
||||
path: AbsolutePathBuf::try_from(tmp.path().join("repo/enabled-plugin"))
|
||||
.unwrap(),
|
||||
},
|
||||
install_policy: None,
|
||||
auth_policy: None,
|
||||
install_policy: MarketplacePluginInstallPolicy::Available,
|
||||
auth_policy: MarketplacePluginAuthPolicy::OnInstall,
|
||||
interface: None,
|
||||
installed: true,
|
||||
enabled: true,
|
||||
@@ -2117,8 +2117,8 @@ enabled = false
|
||||
)
|
||||
.unwrap(),
|
||||
},
|
||||
install_policy: None,
|
||||
auth_policy: None,
|
||||
install_policy: MarketplacePluginInstallPolicy::Available,
|
||||
auth_policy: MarketplacePluginAuthPolicy::OnInstall,
|
||||
interface: None,
|
||||
installed: true,
|
||||
enabled: false,
|
||||
@@ -2184,8 +2184,8 @@ enabled = false
|
||||
path: AbsolutePathBuf::try_from(curated_root.join("plugins/linear"))
|
||||
.unwrap(),
|
||||
},
|
||||
install_policy: None,
|
||||
auth_policy: None,
|
||||
install_policy: MarketplacePluginInstallPolicy::Available,
|
||||
auth_policy: MarketplacePluginAuthPolicy::OnInstall,
|
||||
interface: None,
|
||||
installed: false,
|
||||
enabled: false,
|
||||
@@ -2284,8 +2284,8 @@ enabled = false
|
||||
source: MarketplacePluginSourceSummary::Local {
|
||||
path: AbsolutePathBuf::try_from(tmp.path().join("repo-a/from-a")).unwrap(),
|
||||
},
|
||||
install_policy: None,
|
||||
auth_policy: None,
|
||||
install_policy: MarketplacePluginInstallPolicy::Available,
|
||||
auth_policy: MarketplacePluginAuthPolicy::OnInstall,
|
||||
interface: None,
|
||||
installed: false,
|
||||
enabled: true,
|
||||
@@ -2310,8 +2310,8 @@ enabled = false
|
||||
source: MarketplacePluginSourceSummary::Local {
|
||||
path: AbsolutePathBuf::try_from(tmp.path().join("repo-b/from-b-only")).unwrap(),
|
||||
},
|
||||
install_policy: None,
|
||||
auth_policy: None,
|
||||
install_policy: MarketplacePluginInstallPolicy::Available,
|
||||
auth_policy: MarketplacePluginAuthPolicy::OnInstall,
|
||||
interface: None,
|
||||
installed: false,
|
||||
enabled: false,
|
||||
@@ -2389,8 +2389,8 @@ enabled = true
|
||||
path: AbsolutePathBuf::try_from(tmp.path().join("repo/sample-plugin"))
|
||||
.unwrap(),
|
||||
},
|
||||
install_policy: None,
|
||||
auth_policy: None,
|
||||
install_policy: MarketplacePluginInstallPolicy::Available,
|
||||
auth_policy: MarketplacePluginAuthPolicy::OnInstall,
|
||||
interface: None,
|
||||
installed: false,
|
||||
enabled: true,
|
||||
|
||||
@@ -21,7 +21,7 @@ const MARKETPLACE_RELATIVE_PATH: &str = ".agents/plugins/marketplace.json";
|
||||
pub struct ResolvedMarketplacePlugin {
|
||||
pub plugin_id: PluginId,
|
||||
pub source_path: AbsolutePathBuf,
|
||||
pub auth_policy: Option<MarketplacePluginAuthPolicy>,
|
||||
pub auth_policy: MarketplacePluginAuthPolicy,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
@@ -35,8 +35,8 @@ pub struct MarketplaceSummary {
|
||||
pub struct MarketplacePluginSummary {
|
||||
pub name: String,
|
||||
pub source: MarketplacePluginSourceSummary,
|
||||
pub install_policy: Option<MarketplacePluginInstallPolicy>,
|
||||
pub auth_policy: Option<MarketplacePluginAuthPolicy>,
|
||||
pub install_policy: MarketplacePluginInstallPolicy,
|
||||
pub auth_policy: MarketplacePluginAuthPolicy,
|
||||
pub interface: Option<PluginManifestInterfaceSummary>,
|
||||
}
|
||||
|
||||
@@ -45,18 +45,20 @@ pub enum MarketplacePluginSourceSummary {
|
||||
Local { path: AbsolutePathBuf },
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Deserialize)]
|
||||
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Deserialize)]
|
||||
pub enum MarketplacePluginInstallPolicy {
|
||||
#[serde(rename = "NOT_AVAILABLE")]
|
||||
NotAvailable,
|
||||
#[default]
|
||||
#[serde(rename = "AVAILABLE")]
|
||||
Available,
|
||||
#[serde(rename = "INSTALLED_BY_DEFAULT")]
|
||||
InstalledByDefault,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Deserialize)]
|
||||
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Deserialize)]
|
||||
pub enum MarketplacePluginAuthPolicy {
|
||||
#[default]
|
||||
#[serde(rename = "ON_INSTALL")]
|
||||
OnInstall,
|
||||
#[serde(rename = "ON_USE")]
|
||||
@@ -148,7 +150,7 @@ pub fn resolve_marketplace_plugin(
|
||||
auth_policy,
|
||||
..
|
||||
} = plugin;
|
||||
if install_policy == Some(MarketplacePluginInstallPolicy::NotAvailable) {
|
||||
if install_policy == MarketplacePluginInstallPolicy::NotAvailable {
|
||||
return Err(MarketplaceError::PluginNotAvailable {
|
||||
plugin_name: name,
|
||||
marketplace_name,
|
||||
@@ -365,9 +367,9 @@ struct MarketplacePlugin {
|
||||
name: String,
|
||||
source: MarketplacePluginSource,
|
||||
#[serde(default)]
|
||||
install_policy: Option<MarketplacePluginInstallPolicy>,
|
||||
install_policy: MarketplacePluginInstallPolicy,
|
||||
#[serde(default)]
|
||||
auth_policy: Option<MarketplacePluginAuthPolicy>,
|
||||
auth_policy: MarketplacePluginAuthPolicy,
|
||||
#[serde(default)]
|
||||
category: Option<String>,
|
||||
}
|
||||
@@ -420,7 +422,7 @@ mod tests {
|
||||
plugin_id: PluginId::new("local-plugin".to_string(), "codex-curated".to_string())
|
||||
.unwrap(),
|
||||
source_path: AbsolutePathBuf::try_from(repo_root.join("plugin-1")).unwrap(),
|
||||
auth_policy: None,
|
||||
auth_policy: MarketplacePluginAuthPolicy::OnInstall,
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -527,8 +529,8 @@ mod tests {
|
||||
path: AbsolutePathBuf::try_from(home_root.join("home-shared"))
|
||||
.unwrap(),
|
||||
},
|
||||
install_policy: None,
|
||||
auth_policy: None,
|
||||
install_policy: MarketplacePluginInstallPolicy::Available,
|
||||
auth_policy: MarketplacePluginAuthPolicy::OnInstall,
|
||||
interface: None,
|
||||
},
|
||||
MarketplacePluginSummary {
|
||||
@@ -537,8 +539,8 @@ mod tests {
|
||||
path: AbsolutePathBuf::try_from(home_root.join("home-only"))
|
||||
.unwrap(),
|
||||
},
|
||||
install_policy: None,
|
||||
auth_policy: None,
|
||||
install_policy: MarketplacePluginInstallPolicy::Available,
|
||||
auth_policy: MarketplacePluginAuthPolicy::OnInstall,
|
||||
interface: None,
|
||||
},
|
||||
],
|
||||
@@ -556,8 +558,8 @@ mod tests {
|
||||
path: AbsolutePathBuf::try_from(repo_root.join("repo-shared"))
|
||||
.unwrap(),
|
||||
},
|
||||
install_policy: None,
|
||||
auth_policy: None,
|
||||
install_policy: MarketplacePluginInstallPolicy::Available,
|
||||
auth_policy: MarketplacePluginAuthPolicy::OnInstall,
|
||||
interface: None,
|
||||
},
|
||||
MarketplacePluginSummary {
|
||||
@@ -566,8 +568,8 @@ mod tests {
|
||||
path: AbsolutePathBuf::try_from(repo_root.join("repo-only"))
|
||||
.unwrap(),
|
||||
},
|
||||
install_policy: None,
|
||||
auth_policy: None,
|
||||
install_policy: MarketplacePluginInstallPolicy::Available,
|
||||
auth_policy: MarketplacePluginAuthPolicy::OnInstall,
|
||||
interface: None,
|
||||
},
|
||||
],
|
||||
@@ -638,8 +640,8 @@ mod tests {
|
||||
source: MarketplacePluginSourceSummary::Local {
|
||||
path: AbsolutePathBuf::try_from(home_root.join("home-plugin")).unwrap(),
|
||||
},
|
||||
install_policy: None,
|
||||
auth_policy: None,
|
||||
install_policy: MarketplacePluginInstallPolicy::Available,
|
||||
auth_policy: MarketplacePluginAuthPolicy::OnInstall,
|
||||
interface: None,
|
||||
}],
|
||||
},
|
||||
@@ -651,8 +653,8 @@ mod tests {
|
||||
source: MarketplacePluginSourceSummary::Local {
|
||||
path: AbsolutePathBuf::try_from(repo_root.join("repo-plugin")).unwrap(),
|
||||
},
|
||||
install_policy: None,
|
||||
auth_policy: None,
|
||||
install_policy: MarketplacePluginInstallPolicy::Available,
|
||||
auth_policy: MarketplacePluginAuthPolicy::OnInstall,
|
||||
interface: None,
|
||||
}],
|
||||
},
|
||||
@@ -717,8 +719,8 @@ mod tests {
|
||||
source: MarketplacePluginSourceSummary::Local {
|
||||
path: AbsolutePathBuf::try_from(repo_root.join("plugin")).unwrap(),
|
||||
},
|
||||
install_policy: None,
|
||||
auth_policy: None,
|
||||
install_policy: MarketplacePluginInstallPolicy::Available,
|
||||
auth_policy: MarketplacePluginAuthPolicy::OnInstall,
|
||||
interface: None,
|
||||
}],
|
||||
}]
|
||||
@@ -774,11 +776,11 @@ mod tests {
|
||||
|
||||
assert_eq!(
|
||||
marketplaces[0].plugins[0].install_policy,
|
||||
Some(MarketplacePluginInstallPolicy::Available)
|
||||
MarketplacePluginInstallPolicy::Available
|
||||
);
|
||||
assert_eq!(
|
||||
marketplaces[0].plugins[0].auth_policy,
|
||||
Some(MarketplacePluginAuthPolicy::OnInstall)
|
||||
MarketplacePluginAuthPolicy::OnInstall
|
||||
);
|
||||
assert_eq!(
|
||||
marketplaces[0].plugins[0].interface,
|
||||
@@ -868,8 +870,14 @@ mod tests {
|
||||
screenshots: Vec::new(),
|
||||
})
|
||||
);
|
||||
assert_eq!(marketplaces[0].plugins[0].install_policy, None);
|
||||
assert_eq!(marketplaces[0].plugins[0].auth_policy, None);
|
||||
assert_eq!(
|
||||
marketplaces[0].plugins[0].install_policy,
|
||||
MarketplacePluginInstallPolicy::Available
|
||||
);
|
||||
assert_eq!(
|
||||
marketplaces[0].plugins[0].auth_policy,
|
||||
MarketplacePluginAuthPolicy::OnInstall
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user