mirror of
https://github.com/tinyhumansai/openhuman.git
synced 2026-07-30 06:32:24 +00:00
* Update Welcome page to integrate OAuth provider and adjust branding - Added OAuthProviderButton to the Welcome component for Google authentication. - Updated the branding from AlphaHuman to OpenHuman in the FeaturesStep component. - Removed unnecessary Lottie animation from the Onboarding page for a cleaner layout. - Changed the backend URL to point to the new API endpoint for TinyHumans. * Refactor routing and sidebar components for improved clarity - Commented out the Mnemonic route and related logic in AppRoutes for future consideration. - Updated MiniSidebar to comment out the Invite Friends section. - Removed unused navigation logic and upgrade call-to-action from the Home page. - Adjusted Onboarding navigation to redirect to Home instead of Mnemonic. * Comment out unused settings menu items for future consideration in SettingsHome component * Add core process and RPC functionality for Alphahuman - Introduced new binaries: `alphahuman-core` and `alphahuman-cli` for core process management and command-line interaction. - Implemented `CoreProcessHandle` for managing the lifecycle of the core process. - Added `core_rpc` module for handling RPC requests and responses. - Created `core_server` module to manage core server logic and routing. - Updated `alphahuman` commands to utilize the new RPC structure for health checks, security policies, and configuration management. - Refactored existing code to streamline interactions with the core process and improve overall architecture. * Update dependencies and enhance CLI functionality - Added `clap` for command-line argument parsing in the `alphahuman-cli`. - Updated `Cargo.lock` and `Cargo.toml` to include `clap` and its features. - Refactored `alphahuman-cli` to utilize structured command handling with subcommands. - Improved core process management and logging in `core_process.rs`. - Enhanced routing and error handling in `core_server.rs` with new root and not found handlers. - Updated various commands in `alphahuman.rs` to ensure core process is running before executing RPC calls. * Enhance service management and CLI functionality - Added new functions for daemon program arguments and command line construction in the service module. - Updated macOS and Linux installation functions to dynamically generate program arguments and command lines. - Introduced a new `Reinstall` command in the CLI for easier service management. - Refactored service command handling to utilize local service functions for improved clarity and maintainability. * Refactor daemon references to agent in components and hooks - Updated terminology from "Daemon" to "Agent" in MiniSidebar, DaemonHealthPanel, and TauriCommandsPanel for consistency. - Modified useDaemonHealth hook to probe agent status and handle agent lifecycle management. - Introduced new agent server status interface and function in Tauri commands for improved status checking. - Adjusted related comments and error handling to reflect the changes in terminology. * Refactor Home component and enhance macOS service management - Updated Home component to navigate to in-app conversations instead of opening a Telegram bot link. - Improved macOS service management by implementing modern lifecycle commands and adding compatibility fallbacks for service control. - Introduced new utility functions for handling macOS GUI domain and service targets. * Refactor Home component to enhance navigation - Removed SkillsGrid component and replaced it with a button that navigates to the Skills page. - Improved layout with additional margin for better spacing in the Home component.
89 lines
2.5 KiB
Rust
89 lines
2.5 KiB
Rust
use std::sync::Arc;
|
|
|
|
use tokio::process::{Child, Command};
|
|
use tokio::sync::Mutex;
|
|
|
|
#[derive(Clone)]
|
|
pub struct CoreProcessHandle {
|
|
child: Arc<Mutex<Option<Child>>>,
|
|
port: u16,
|
|
}
|
|
|
|
impl CoreProcessHandle {
|
|
pub fn new(port: u16) -> Self {
|
|
Self {
|
|
child: Arc::new(Mutex::new(None)),
|
|
port,
|
|
}
|
|
}
|
|
|
|
pub fn rpc_url(&self) -> String {
|
|
format!("http://127.0.0.1:{}/rpc", self.port)
|
|
}
|
|
|
|
pub async fn ensure_running(&self) -> Result<(), String> {
|
|
if crate::core_rpc::ping().await {
|
|
log::info!("[core] found existing core rpc endpoint at {}", self.rpc_url());
|
|
return Ok(());
|
|
}
|
|
|
|
let mut guard = self.child.lock().await;
|
|
if guard.is_none() {
|
|
let exe = std::env::current_exe()
|
|
.map_err(|e| format!("failed to resolve current executable: {e}"))?;
|
|
|
|
let mut cmd = Command::new(exe);
|
|
cmd.arg("core")
|
|
.arg("serve")
|
|
.arg("--port")
|
|
.arg(self.port.to_string());
|
|
|
|
log::info!("[core] spawning core process: {:?} core serve --port {}", cmd.as_std().get_program(), self.port);
|
|
|
|
let child = cmd
|
|
.spawn()
|
|
.map_err(|e| format!("failed to spawn core process: {e}"))?;
|
|
|
|
*guard = Some(child);
|
|
}
|
|
drop(guard);
|
|
|
|
for _ in 0..40 {
|
|
if crate::core_rpc::ping().await {
|
|
log::info!("[core] core rpc became ready at {}", self.rpc_url());
|
|
return Ok(());
|
|
}
|
|
|
|
let mut guard = self.child.lock().await;
|
|
if let Some(child) = guard.as_mut() {
|
|
match child.try_wait() {
|
|
Ok(Some(status)) => {
|
|
return Err(format!("core process exited before ready: {status}"));
|
|
}
|
|
Ok(None) => {}
|
|
Err(e) => return Err(format!("failed checking core process status: {e}")),
|
|
}
|
|
}
|
|
drop(guard);
|
|
tokio::time::sleep(std::time::Duration::from_millis(100)).await;
|
|
}
|
|
|
|
Err("core process did not become ready".to_string())
|
|
}
|
|
|
|
pub async fn shutdown(&self) {
|
|
let mut guard = self.child.lock().await;
|
|
if let Some(child) = guard.as_mut() {
|
|
let _ = child.kill().await;
|
|
}
|
|
*guard = None;
|
|
}
|
|
}
|
|
|
|
pub fn default_core_port() -> u16 {
|
|
std::env::var("ALPHAHUMAN_CORE_PORT")
|
|
.ok()
|
|
.and_then(|v| v.parse::<u16>().ok())
|
|
.unwrap_or(7788)
|
|
}
|