Skip to main content

corvus/
lib.rs

1#![warn(clippy::all, clippy::pedantic)]
2#![allow(
3    clippy::assigning_clones,
4    clippy::bool_to_int_with_if,
5    clippy::case_sensitive_file_extension_comparisons,
6    clippy::cast_possible_wrap,
7    clippy::doc_markdown,
8    clippy::field_reassign_with_default,
9    clippy::float_cmp,
10    clippy::implicit_clone,
11    clippy::items_after_statements,
12    clippy::map_unwrap_or,
13    clippy::manual_let_else,
14    clippy::large_stack_arrays,
15    clippy::missing_errors_doc,
16    clippy::missing_panics_doc,
17    clippy::module_name_repetitions,
18    clippy::must_use_candidate,
19    clippy::new_without_default,
20    clippy::needless_pass_by_value,
21    clippy::needless_raw_string_hashes,
22    clippy::redundant_closure_for_method_calls,
23    clippy::return_self_not_must_use,
24    clippy::similar_names,
25    clippy::single_match_else,
26    clippy::struct_field_names,
27    clippy::too_many_lines,
28    clippy::uninlined_format_args,
29    clippy::unnecessary_cast,
30    clippy::unnecessary_lazy_evaluations,
31    clippy::unnecessary_literal_bound,
32    clippy::unnecessary_map_or,
33    clippy::unused_self,
34    clippy::cast_precision_loss,
35    clippy::unnecessary_wraps,
36    dead_code
37)]
38
39use clap::{Subcommand, ValueEnum};
40use serde::{Deserialize, Serialize};
41
42pub mod agent;
43pub mod approval;
44pub mod auth;
45pub mod bootstrap;
46pub mod channels;
47pub mod config;
48pub mod cost;
49pub mod cron;
50pub mod daemon;
51pub mod doctor;
52pub mod gateway;
53pub mod hardware;
54pub mod health;
55pub mod heartbeat;
56pub mod identity;
57pub mod integrations;
58pub mod memory;
59pub mod migration;
60pub mod observability;
61pub mod onboard;
62pub mod peripherals;
63pub mod pre_execution;
64pub mod providers;
65pub mod rag;
66pub mod runtime;
67pub mod security;
68pub mod service;
69pub mod skills;
70#[cfg(test)]
71pub mod test_support;
72pub mod tools;
73pub mod tunnel;
74pub mod update;
75pub mod util;
76
77pub use config::Config;
78
79#[derive(Debug, Clone, Copy, ValueEnum, Serialize, Deserialize, PartialEq, Eq)]
80pub enum ServiceLingerMode {
81    Keep,
82    On,
83    Off,
84}
85
86/// Service management subcommands
87#[derive(Subcommand, Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
88pub enum ServiceCommands {
89    /// Install daemon service unit for auto-start and restart
90    Install {
91        /// Linux only: keep user service active without an interactive session
92        #[arg(long, value_enum, default_value_t = ServiceLingerMode::Keep)]
93        linger: ServiceLingerMode,
94    },
95    /// Start daemon service
96    Start,
97    /// Restart daemon service
98    Restart,
99    /// Stop daemon service
100    Stop,
101    /// Check daemon service status
102    Status,
103    /// Uninstall daemon service unit
104    Uninstall,
105}
106
107/// Channel management subcommands
108#[derive(Subcommand, Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
109pub enum ChannelCommands {
110    /// List all configured channels
111    List,
112    /// Start all configured channels (handled in main.rs for async)
113    Start,
114    /// Run health checks for configured channels (handled in main.rs for async)
115    Doctor,
116    /// Add a new channel configuration
117    Add {
118        /// Channel type (telegram, discord, slack, whatsapp, matrix, imessage, email)
119        channel_type: String,
120        /// Optional configuration as JSON
121        config: String,
122    },
123    /// Remove a channel configuration
124    Remove {
125        /// Channel name to remove
126        name: String,
127    },
128    /// Bind a Telegram identity (username or numeric user ID) into allowlist
129    BindTelegram {
130        /// Telegram identity to allow (username without '@' or numeric user ID)
131        identity: String,
132    },
133}
134
135/// Skills management subcommands
136#[derive(Subcommand, Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
137pub enum SkillCommands {
138    /// List all installed skills
139    List,
140    /// Install a new skill from a URL or local path
141    Install {
142        /// Source URL or local path
143        source: String,
144    },
145    /// Remove an installed skill
146    Remove {
147        /// Skill name to remove
148        name: String,
149    },
150}
151
152/// Migration subcommands
153#[derive(Subcommand, Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
154pub enum MigrateCommands {
155    /// Import memory from an `OpenClaw` workspace into this `Corvus` workspace
156    Openclaw {
157        /// Optional path to `OpenClaw` workspace (defaults to ~/.openclaw/workspace)
158        #[arg(long)]
159        source: Option<std::path::PathBuf>,
160
161        /// Validate and preview migration without writing any data
162        #[arg(long)]
163        dry_run: bool,
164    },
165}
166
167/// Cron subcommands
168#[derive(Subcommand, Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
169pub enum CronCommands {
170    /// List all scheduled tasks
171    List,
172    /// Add a new scheduled task
173    Add {
174        /// Cron expression
175        expression: String,
176        /// Optional IANA timezone (e.g. America/Los_Angeles)
177        #[arg(long)]
178        tz: Option<String>,
179        /// Command to run
180        command: String,
181    },
182    /// Add a one-shot scheduled task at an RFC3339 timestamp
183    AddAt {
184        /// One-shot timestamp in RFC3339 format
185        at: String,
186        /// Command to run
187        command: String,
188    },
189    /// Add a fixed-interval scheduled task
190    AddEvery {
191        /// Interval in milliseconds
192        every_ms: u64,
193        /// Command to run
194        command: String,
195    },
196    /// Add a one-shot delayed task (e.g. "30m", "2h", "1d")
197    Once {
198        /// Delay duration
199        delay: String,
200        /// Command to run
201        command: String,
202    },
203    /// Remove a scheduled task
204    Remove {
205        /// Task ID
206        id: String,
207    },
208    /// Pause a scheduled task
209    Pause {
210        /// Task ID
211        id: String,
212    },
213    /// Resume a paused task
214    Resume {
215        /// Task ID
216        id: String,
217    },
218}
219
220/// Integration subcommands
221#[derive(Subcommand, Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
222pub enum IntegrationCommands {
223    /// Show details about a specific integration
224    Info {
225        /// Integration name
226        name: String,
227    },
228}
229
230/// Hardware discovery subcommands
231#[derive(Subcommand, Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
232pub enum HardwareCommands {
233    /// Enumerate USB devices (VID/PID) and show known boards
234    Discover,
235    /// Introspect a device by path (e.g. /dev/ttyACM0)
236    Introspect {
237        /// Serial or device path
238        path: String,
239    },
240    /// Get chip info via USB (probe-rs over ST-Link). No firmware needed on target.
241    Info {
242        /// Chip name (e.g. STM32F401RETx). Default: STM32F401RETx for Nucleo-F401RE
243        #[arg(long, default_value = "STM32F401RETx")]
244        chip: String,
245    },
246}
247
248/// Peripheral (hardware) management subcommands
249#[derive(Subcommand, Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
250pub enum PeripheralCommands {
251    /// List configured peripherals
252    List,
253    /// Add a peripheral (board path, e.g. nucleo-f401re /dev/ttyACM0)
254    Add {
255        /// Board type (nucleo-f401re, rpi-gpio, esp32)
256        board: String,
257        /// Path for serial transport (/dev/ttyACM0) or "native" for local GPIO
258        path: String,
259    },
260    /// Flash Corvus firmware to Arduino (creates .ino, installs arduino-cli if needed, uploads)
261    Flash {
262        /// Serial port (e.g. /dev/cu.usbmodem12345). If omitted, uses first arduino-uno from config.
263        #[arg(short, long)]
264        port: Option<String>,
265    },
266    /// Setup Arduino Uno Q Bridge app (deploy GPIO bridge for agent control)
267    SetupUnoQ {
268        /// Uno Q IP (e.g. 192.168.0.48). If omitted, assumes running ON the Uno Q.
269        #[arg(long)]
270        host: Option<String>,
271    },
272    /// Flash Corvus firmware to Nucleo-F401RE (builds + probe-rs run)
273    FlashNucleo,
274}