aien-sovereign-core-mv
AienOS host runtime: inference scheduling, paged KV state, the aien CLI and Spark verification tooling. Its inference engine is in alpha testing (DGX Spark GB10); Omega is the implementation destination.
Brought by drakestapleton
aien-sovereign-core-mv / crates / aien-cli / src / ui.rs
| 1 | // SPDX-License-Identifier: Apache-2.0 |
| 2 | // Copyright 2026 Drake Stapleton (AIEN / aien-dev) |
| 3 | // |
| 4 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | // you may not use this file except in compliance with the License. |
| 6 | // You may obtain a copy of the License at |
| 7 | // |
| 8 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | // |
| 10 | // Unless required by applicable law or agreed to in writing, software |
| 11 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | // See the License for the specific language governing permissions and |
| 14 | // limitations under the License. |
| 15 | |
| 16 | use crate::telemetry::get_gpu_telemetry; |
| 17 | use colored::*; |
| 18 | use std::io::{stdout, Write}; |
| 19 | |
| 20 | /// Second banner line (sc#414): the runtime is the native Rust daemon. Modular |
| 21 | /// MAX was left on 2026-10-02 and no model seat listens on port 18006 here. |
| 22 | pub fn banner_runtime_line() -> String { |
| 23 | let text = "Grace Blackwell GB10 • Native Rust runtime • Local model, no cloud"; |
| 24 | let inner = 76; |
| 25 | let pad = inner - 2 - text.chars().count(); |
| 26 | format!("│ {text}{}│", " ".repeat(pad)) |
| 27 | } |
| 28 | |
| 29 | pub fn print_banner() { |
| 30 | println!( |
| 31 | "{}", |
| 32 | "╭────────────────────────────────────────────────────────────────────────────╮" |
| 33 | .cyan() |
| 34 | .bold() |
| 35 | ); |
| 36 | println!( |
| 37 | "{}", |
| 38 | "│ ⚡ AIEN • Autonomous Intelligence & Execution Node (NVIDIA DGX Spark) │" |
| 39 | .cyan() |
| 40 | .bold() |
| 41 | ); |
| 42 | println!("{}", banner_runtime_line().cyan()); |
| 43 | println!( |
| 44 | "{}", |
| 45 | "╰────────────────────────────────────────────────────────────────────────────╯" |
| 46 | .cyan() |
| 47 | .bold() |
| 48 | ); |
| 49 | print_status_bar(); |
| 50 | println!(); |
| 51 | } |
| 52 | |
| 53 | pub fn print_status_bar() { |
| 54 | let gpu = get_gpu_telemetry(); |
| 55 | let gpu_status = if gpu.available { |
| 56 | let temp = gpu.display_temp(); |
| 57 | let used_gb = gpu |
| 58 | .used_mb |
| 59 | .map(|u| format!("{:.1} GB", u as f64 / 1024.0)) |
| 60 | .unwrap_or_else(|| "? GB".to_string()); |
| 61 | let total_gb = gpu |
| 62 | .total_mb |
| 63 | .map(|t| format!("{:.1} GB", t as f64 / 1024.0)) |
| 64 | .unwrap_or_else(|| "? GB".to_string()); |
| 65 | format!("GPU: {} | {}/{}", temp, used_gb, total_gb) |
| 66 | } else { |
| 67 | "GPU: Offline / Unavailable".to_string() |
| 68 | }; |
| 69 | |
| 70 | let status = format!( |
| 71 | "[{}] • Runtime: native AIEN daemon • Mask: AIEN • Swarm: aien-hive", |
| 72 | gpu_status |
| 73 | ); |
| 74 | println!("{}", status.black().on_cyan().bold()); |
| 75 | } |
| 76 | |
| 77 | pub fn print_tool_start(tool_name: &str, summary: &str) { |
| 78 | print!( |
| 79 | "{} {}", |
| 80 | "⚙ [Executing:".yellow().bold(), |
| 81 | format!("{}({})]...", tool_name, summary).yellow() |
| 82 | ); |
| 83 | let _ = stdout().flush(); |
| 84 | } |
| 85 | |
| 86 | pub fn print_tool_done(tool_name: &str, elapsed_ms: u128, success: bool) { |
| 87 | if success { |
| 88 | println!( |
| 89 | "\r{}", |
| 90 | format!("✓ [{}] Done ({}ms)", tool_name, elapsed_ms) |
| 91 | .green() |
| 92 | .bold() |
| 93 | ); |
| 94 | } else { |
| 95 | println!( |
| 96 | "\r{}", |
| 97 | format!("✗ [{}] Failed ({}ms)", tool_name, elapsed_ms) |
| 98 | .red() |
| 99 | .bold() |
| 100 | ); |
| 101 | } |
| 102 | let _ = stdout().flush(); |
| 103 | } |
| 104 | |
| 105 | pub fn print_safety_prompt(cmd: &str) -> bool { |
| 106 | use std::io::IsTerminal; |
| 107 | // CI and a non-interactive stdin have no person to answer. Do not block. |
| 108 | if std::env::var_os("CI").is_some() || !std::io::stdin().is_terminal() { |
| 109 | return false; |
| 110 | } |
| 111 | println!( |
| 112 | "\n{}", |
| 113 | "⚠ [SAFETY GATE] AIEN requested high-risk operation:" |
| 114 | .red() |
| 115 | .bold() |
| 116 | ); |
| 117 | println!(" {}", cmd.yellow()); |
| 118 | print!("{}", "Do you approve execution? [y/N]: ".bold()); |
| 119 | let _ = stdout().flush(); |
| 120 | |
| 121 | let mut input = String::new(); |
| 122 | if std::io::stdin().read_line(&mut input).is_ok() { |
| 123 | let trimmed = input.trim().to_lowercase(); |
| 124 | return trimmed == "y" || trimmed == "yes"; |
| 125 | } |
| 126 | false |
| 127 | } |
| 128 | |
| 129 | #[cfg(test)] |
| 130 | mod tests { |
| 131 | use super::*; |
| 132 | |
| 133 | #[test] |
| 134 | fn banner_describes_native_runtime_not_max() { |
| 135 | let l = banner_runtime_line(); |
| 136 | assert!(l.contains("Native Rust runtime"), "{l}"); |
| 137 | for stale in ["MAX", "26.5", "18006"] { |
| 138 | assert!(!l.contains(stale), "stale banner text {stale}: {l}"); |
| 139 | } |
| 140 | assert_eq!(l.chars().count(), 78, "box width: {l}"); |
| 141 | } |
| 142 | } |