Skip to repository content

tenant.openagents/omega

No repository description is available.

OpenAgents Git authority 2026-07-28T05:10:32.472Z Public web read
NIP-34 coordinate30617:7649603503856e5148d571eac2766b288a8ff1e9e35d380337a1d2b0015b4f92:omega
MaintainersHidden in public view
References2 branches · 1 tag
Read-only clonegit clone https://openagents.com/git/tenant.openagents/omega.git
Browse files

npm_install_package_capability.rs

40 lines · 1.1 KB · rust
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
Served at tenant.openagents/omega Member data and write actions are omitted.