Skip to main content

rain_engine_skills/
lib.rs

1//! Built-in native skills for RainEngine.
2//!
3//! These skills give the agent "hands" — the ability to interact with
4//! the local filesystem, execute commands, make HTTP requests, and
5//! search session memory.
6
7pub mod file_ops;
8pub mod http_fetch;
9pub mod memory_search;
10pub mod shell_exec;
11pub mod web_reader;
12
13use rain_engine_core::{RetryPolicy, SkillManifest};
14use std::collections::HashSet;
15use std::sync::Arc;
16use tokio::sync::RwLock;
17
18#[derive(Debug, Clone, PartialEq, Eq)]
19pub struct AccessPolicy {
20    pub allowlist: HashSet<String>,
21    pub permissive: bool,
22}
23
24impl AccessPolicy {
25    pub fn new(allowlist: HashSet<String>, permissive: bool) -> Self {
26        Self {
27            allowlist,
28            permissive,
29        }
30    }
31}
32
33pub type SharedAccessPolicy = Arc<RwLock<AccessPolicy>>;
34
35pub fn shared_access_policy(allowlist: HashSet<String>, permissive: bool) -> SharedAccessPolicy {
36    Arc::new(RwLock::new(AccessPolicy::new(allowlist, permissive)))
37}
38
39/// Helper to build a SkillManifest with common defaults.
40fn base_manifest(name: &str, description: &str, input_schema: serde_json::Value) -> SkillManifest {
41    SkillManifest {
42        name: name.to_string(),
43        description: description.to_string(),
44        input_schema,
45        required_scopes: vec!["tool:run".to_string()],
46        capability_grants: vec![],
47        resource_policy: rain_engine_core::ResourcePolicy {
48            timeout_ms: 30_000,
49            max_memory_bytes: 16 * 1024 * 1024,
50            max_fuel: None,
51            priority_class: 0,
52            retry_policy: RetryPolicy {
53                max_attempts: 3,
54                initial_interval_ms: 250,
55                backoff_multiplier: 2.0,
56                max_interval_ms: 10_000,
57            },
58            dry_run_supported: false,
59        },
60        approval_required: false,
61        circuit_breaker_threshold: 0.5,
62    }
63}