AI Agent OS
Native OS-level monitoring agent with Hyprland integration, built in Rust for maximum performance.
π― Overviewβ
AI Agent OS is a lightweight, high-performance system monitoring agent designed to run natively on NixOS with deep Hyprland/Wayland integration. It provides:
- Real-time system monitoring (CPU, memory, disk, thermal, network)
- Journald log collection with intelligent filtering
- Hyprland IPC integration for compositor-level control
- Alert system for proactive issue detection
- Minimal footprint (< 20MB idle, < 100MB active)
ποΈ Architectureβ
The project is organized as a Cargo workspace with four crates:
ai-agent-os/
βββ crates/
β βββ agent-core/ # Main orchestrator
β βββ system-monitor/ # System metrics collection
β βββ hyprland-ipc/ # Hyprland compositor integration
β βββ log-collector/ # Journald log streaming
βββ Cargo.toml # Workspace configuration
βββ flake.nix # Nix build configuration
Component Detailsβ
1. hyprland-ipcβ
- Unix socket communication with Hyprland
- Workspace and window management
- Event subscription (window open/close, workspace changes)
- Screen capture capabilities
2. system-monitorβ
- CPU usage (global + per-core)
- Memory and swap metrics
- Disk usage and I/O
- Thermal sensors
- Network interfaces
- Load averages
3. log-collectorβ
- Systemd journal integration
- Real-time log streaming
- Priority-based filtering
- Unit-specific log queries
- Critical error detection
4. agent-coreβ
- Orchestrates all subsystems
- Alert generation and management
- Configuration management
- Async task coordination
π Quick Startβ
Development with Nixβ
# Enter development shell
cd ai-agent-os
nix develop
# Build the project
cargo build
# Run the agent
cargo run
# Watch mode (auto-rebuild on changes)
cargo watch -x run
# Run tests
cargo test
Building with Nixβ
# Build the package
nix build .#ai-agent
# Run directly
nix run .#ai-agent
π¦ Installationβ
NixOS Integrationβ
Add to your NixOS configuration:
{
environment.systemPackages = [
(pkgs.callPackage ./ai-agent-os { })
];
# Optional: Run as systemd service
systemd.user.services.ai-agent = {
description = "AI Agent OS Monitoring";
wantedBy = [ "default.target" ];
serviceConfig = {
ExecStart = "${pkgs.ai-agent}/bin/ai-agent";
Restart = "on-failure";
};
};
}
βοΈ Configurationβ
The agent can be configured via AgentConfig:
use agent_core::{Agent, AgentConfig};
let config = AgentConfig {
monitoring_interval_secs: 5, // Metrics collection interval
thermal_threshold_celsius: 75.0, // Temperature alert threshold
memory_threshold_percent: 85.0, // Memory usage alert threshold
enable_hyprland: true, // Enable Hyprland integration
..Default::default()
};
let agent = Agent::with_config(config)?;
π§ Developmentβ
Requirementsβ
- Rust 1.75+ (provided by Nix)
- systemd (for journald integration)
- Hyprland (optional, for compositor integration)
Project Structureβ
crates/
βββ agent-core/
β βββ src/
β β βββ lib.rs # Core agent logic
β β βββ main.rs # CLI binary
β βββ Cargo.toml
βββ system-monitor/
β βββ src/lib.rs # System metrics
β βββ Cargo.toml
βββ hyprland-ipc/
β βββ src/lib.rs # Hyprland IPC client
β βββ Cargo.toml
βββ log-collector/
βββ src/lib.rs # Journald integration
βββ Cargo.toml
Testingβ
# Run all tests
cargo test
# Test specific crate
cargo test -p system-monitor
# Run with logging
RUST_LOG=debug cargo run
Lintingβ
# Run clippy
cargo clippy
# Format code
cargo fmt
# Check formatting
cargo fmt -- --check
π Performance Targetsβ
- Memory: < 20MB idle, < 100MB active
- CPU: < 1% idle, < 10% active
- Startup: < 200ms
- Latency: < 1ms p50, < 10ms p99
π― Roadmapβ
Phase 1: Foundation β β
- Rust workspace structure
- Hyprland IPC basics
- System monitoring
- Log collection
- Nix integration
Phase 2: Intelligence (Next)β
- ML-based anomaly detection
- Predictive alerts
- Pattern recognition
- Auto-remediation
Phase 3: UI Integrationβ
- Tauri desktop app
- Real-time dashboard
- Visual analytics
- Global hotkeys
Phase 4: Multimodal AIβ
- Vision capabilities (screen analysis)
- Voice interface (Whisper)
- LLM integration (problem-solving)
- Proactive assistance
π Securityβ
- Runs with minimal privileges
- No network access required
- Sandbox-friendly design
- Audit logging
- SOPS integration for secrets
π Licenseβ
MIT License - See LICENSE file for details
π€ Contributingβ
Contributions welcome! Please:
- Fork the repository
- Create a feature branch
- Write tests for new functionality
- Ensure
cargo testandcargo clippypass - Submit a pull request
π Documentationβ
For detailed architecture documentation, see:
docs/AI-AGENT-OS-ARCHITECTURE.md- Individual crate
src/lib.rsfiles for API documentation
π Troubleshootingβ
"Failed to open systemd journal"β
- Ensure systemd is running
- Check user has access to journal:
journalctl --user
"Hyprland socket not found"β
- Verify running under Hyprland:
echo $HYPRLAND_INSTANCE_SIGNATURE - Check socket exists:
ls $XDG_RUNTIME_DIR/hypr/*/
Build issuesβ
- Update Rust:
rustup update - Clean build:
cargo clean && cargo build - Check Nix:
nix flake check
π§ Contactβ
For questions or issues, please open a GitHub issue.