Skip to main content

hyprstream_core/cli/
mod.rs

1//! Command-line interface module.
2//!
3//! This module provides the CLI functionality for:
4//! - Server management
5//! - Configuration handling
6//! - Model management (HuggingFace, etc.)
7//! - LoRA adapter creation and training
8
9pub mod commands;
10pub mod context;
11pub mod daemon;
12pub mod enroll;
13pub mod git_handlers;
14pub mod gpu_detect;
15pub mod handlers;
16pub mod pds_handlers;
17pub mod policy_handlers;
18// Deployment-roster provisioning/inspection reads the checkpointed PDS
19// store; the concrete type is rocksdb-only today (pure-RDS-without-rocksdb
20// is future work).
21pub mod bootstrap_manager;
22#[cfg(feature = "rocksdb")]
23pub mod deployment_bootstrap;
24pub mod quick;
25pub mod registry_readback;
26pub mod remote_handlers;
27pub mod schema_cli;
28pub mod service_handlers;
29pub mod shell_handlers;
30pub mod sign_challenge;
31pub mod systemd_setup;
32pub mod training_handlers;
33pub mod trust;
34pub mod trust_ceremony;
35pub mod tui_handlers;
36pub mod update_handlers;
37pub mod user_handlers;
38pub mod wizard_handlers;
39pub mod worker_handlers;
40pub mod worktree_handlers;
41
42pub use context::AppContext;
43pub use git_handlers::{
44    apply_policy_template_to_model, handle_branch, handle_checkout, handle_clone, handle_infer,
45    handle_info, handle_list, handle_load, handle_notify_command, handle_pull, handle_remove,
46    handle_status, handle_unload, parse_filters, parse_status_filter,
47};
48
49pub use crate::auth::policy_templates::{get_template, get_templates, PolicyTemplate};
50#[cfg(feature = "experimental")]
51pub use git_handlers::{handle_commit, handle_merge, handle_promote, handle_push, MergeOptions};
52pub use handlers::handle_config;
53pub use policy_handlers::{
54    handle_policy_apply, handle_policy_apply_template, handle_policy_check, handle_policy_diff,
55    handle_policy_edit, handle_policy_history, handle_policy_list_templates,
56    handle_policy_role_add, handle_policy_role_list, handle_policy_role_remove,
57    handle_policy_rollback, handle_policy_show, handle_token_create, load_or_generate_signing_key,
58};
59pub use remote_handlers::{
60    handle_remote_add, handle_remote_list, handle_remote_remove, handle_remote_rename,
61    handle_remote_set_url,
62};
63pub use service_handlers::{
64    handle_service_install, handle_service_provision_policy_templates, handle_service_start,
65    handle_service_status, handle_service_stop, handle_service_uninstall,
66};
67pub use sign_challenge::handle_sign_challenge;
68pub use training_handlers::{
69    handle_training_batch, handle_training_checkpoint, handle_training_infer, handle_training_init,
70};
71pub use user_handlers::{
72    handle_user_create, handle_user_keys_import, handle_user_keys_list, handle_user_keys_remove,
73    handle_user_list, handle_user_register, handle_user_remove,
74};
75pub use wizard_handlers::{handle_wizard, handle_wizard_tui, WizardOptions};
76pub use worker_handlers::{
77    handle_images_df, handle_images_list, handle_images_pull, handle_images_rm, handle_worker_exec,
78    handle_worker_list, handle_worker_restart, handle_worker_rm, handle_worker_run,
79    handle_worker_start, handle_worker_stats, handle_worker_status, handle_worker_stop,
80    handle_worker_terminal,
81};
82pub use worktree_handlers::{
83    handle_worktree_add, handle_worktree_info, handle_worktree_list, handle_worktree_remove,
84};
85
86/// Device preference strategy
87#[derive(Debug, Clone, Copy)]
88pub enum DevicePreference {
89    /// Request GPU if available, fall back to CPU gracefully
90    RequestGPU,
91    /// Request CPU-only execution
92    RequestCPU,
93    /// Require GPU, fail if not available
94    RequireGPU,
95}
96
97/// Device configuration for command execution
98#[derive(Debug, Clone)]
99pub struct DeviceConfig {
100    /// Device preference strategy
101    pub preference: DevicePreference,
102    /// Specific CUDA device ID (None = auto-detect)
103    pub cuda_device: Option<u32>,
104    /// Specific ROCm device ID (None = auto-detect)
105    pub rocm_device: Option<u32>,
106}
107
108impl DeviceConfig {
109    /// Create a GPU request config with auto-detection
110    pub fn request_gpu() -> Self {
111        Self {
112            preference: DevicePreference::RequestGPU,
113            cuda_device: None,
114            rocm_device: None,
115        }
116    }
117
118    /// Create a CPU-only config
119    pub fn request_cpu() -> Self {
120        Self {
121            preference: DevicePreference::RequestCPU,
122            cuda_device: None,
123            rocm_device: None,
124        }
125    }
126
127    /// Create a GPU requirement config with auto-detection
128    pub fn require_gpu() -> Self {
129        Self {
130            preference: DevicePreference::RequireGPU,
131            cuda_device: None,
132            rocm_device: None,
133        }
134    }
135
136    /// Create a config with specific CUDA device
137    pub fn cuda_device(device_id: u32) -> Self {
138        Self {
139            preference: DevicePreference::RequireGPU,
140            cuda_device: Some(device_id),
141            rocm_device: None,
142        }
143    }
144
145    /// Create a config with specific ROCm device
146    pub fn rocm_device(device_id: u32) -> Self {
147        Self {
148            preference: DevicePreference::RequireGPU,
149            cuda_device: None,
150            rocm_device: Some(device_id),
151        }
152    }
153}
154
155/// Runtime configuration for commands
156#[derive(Debug, Clone)]
157pub struct RuntimeConfig {
158    pub device: DeviceConfig,
159    pub multi_threaded: bool,
160}