Skip to repository content40 lines · 1.1 KB · rust
tenant.openagents/omega
No repository description is available.
OpenAgents Git authority 2026-07-28T05:10:32.472Z Public web read
NIP-34 coordinate
30617:7649603503856e5148d571eac2766b288a8ff1e9e35d380337a1d2b0015b4f92:omegaMaintainersHidden in public view
References2 branches · 1 tag
Read-only clone
git clone https://openagents.com/git/tenant.openagents/omega.gitBrowse files
npm_install_package_capability.rs
1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize)]
4#[serde(rename_all = "snake_case")]
5pub struct NpmInstallPackageCapability {
6 pub package: String,
7}
8
9impl NpmInstallPackageCapability {
10 /// Returns whether the capability allows installing the given NPM package.
11 pub fn allows(&self, package: &str) -> bool {
12 self.package == "*" || self.package == package
13 }
14}
15
16#[cfg(test)]
17mod tests {
18 use pretty_assertions::assert_eq;
19
20 use super::*;
21
22 #[test]
23 fn test_allows() {
24 let capability = NpmInstallPackageCapability {
25 package: "*".to_string(),
26 };
27 assert_eq!(capability.allows("package"), true);
28
29 let capability = NpmInstallPackageCapability {
30 package: "react".to_string(),
31 };
32 assert_eq!(capability.allows("react"), true);
33
34 let capability = NpmInstallPackageCapability {
35 package: "react".to_string(),
36 };
37 assert_eq!(capability.allows("malicious-package"), false);
38 }
39}
40