Files
openhuman/src-tauri/build.rs
T
c2ff8b693b feat/openclaw (#128)
* feat: add initial project structure and documentation

- Introduced the GNU General Public License (GPL) v3 in LICENSE file.
- Added MCP configuration in .claude/mcp.json for server integration.
- Created architecture documentation in docs/ARCHITECTURE.md outlining the platform's design and components.
- Defined MVP specifications in docs/MVP.md for the Telegram-based Agent Assistant.
- Established API reference for team management in docs/teams-api-reference.md.
- Set up basic HTML structure in public/index.html and added logo image in public/logo.png.

* feat: add initial project documentation and HTML structure

- Introduced CODE_OF_CONDUCT.md to establish community guidelines and standards for behavior.
- Created CONTRIBUTING.md to outline contribution process, development setup, and project conventions.
- Added SECURITY.md to define the security policy, supported versions, and reporting procedures for vulnerabilities.
- Established basic HTML structure in index.html for the application interface.

* chore: remove hello-python skill files

- Deleted skill.json and skill.py files for the Hello Python example runtime skill, as they are no longer needed in the project.

* feat: port tinyhuman agent runtime from ZeroClaw into Tauri backend

Port daemon supervisor, health registry, security (policy, secrets, audit,
pairing), agent traits, and config modules from ZeroClaw (MIT) into a new
tinyhuman/ module under src-tauri/src/. The daemon auto-starts on desktop
and shuts down gracefully on app exit via CancellationToken.

- health: global HealthRegistry with component tracking and JSON snapshots
- security/policy: SecurityPolicy with command validation, risk levels, rate limiting
- security/secrets: ChaCha20-Poly1305 SecretStore with legacy XOR migration
- security/audit: AuditLogger with JSON-line events and log rotation
- security/pairing: PairingGuard with brute-force protection and SHA-256 hashing
- security/traits: Sandbox trait + NoopSandbox
- config: minimal DaemonConfig with autonomy, reliability, secrets, audit sub-configs
- daemon: supervisor with health state writer emitting Tauri events
- agent/traits: Provider, Tool, Memory, Observer, RuntimeAdapter traits + Noop impls
- commands/tinyhuman: Tauri commands for health, security policy, encrypt/decrypt
- 185 inline unit tests across all modules
- README updated with custom inference/tunneling/memory positioning

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* feat: update README to reflect AlphaHuman Mk1 branding and enhanced description

- Changed project title to "AlphaHuman Mk1" for clarity.
- Revised project description to emphasize user-friendly AI capabilities and the use of the Neocortex Mk1 model.
- Removed outdated sections on custom inference, tunneling, and memory, streamlining the content for better readability.

* update readme

* Port zeroclaw runtime into tinyhuman

* Replace CLI mentions with UI language

* Split gateway module into smaller units

* Split channels and config schema modules

* Fix tinyhuman build, tests, and tunnel integration

* feat(tinyhuman): add missing modules and ui-friendly services

* refactor: rename tinyhuman to alphahuman

* chore: remove bottom text from Welcome component

* feat(settings): add tauri command console

* feat(daemon): enhance daemon mode handling and integrate rustls with ring feature

* feat(settings): implement comprehensive configuration management in TauriCommandsPanel

* refactor(TauriCommandsPanel): streamline error handling and enhance async function usage

* feat(settings): add skill management functionality to TauriCommandsPanel

* style(TauriCommandsPanel): update input styles for improved readability and user experience

* feat(settings): add Skills and Agent Chat panels with navigation and integration management

* feat(settings): implement browser access management in SkillsPanel and enhance AgentChatPanel with local storage functionality

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-20 13:03:15 +04:00

165 lines
5.7 KiB
Rust

use std::env;
use std::path::PathBuf;
fn main() {
maybe_override_tauri_config_for_tests();
setup_tdlib();
tauri_build::build();
}
fn maybe_override_tauri_config_for_tests() {
let profile = env::var("PROFILE").unwrap_or_default();
let skip_resources = env::var("TAURI_SKIP_RESOURCES").is_ok() || profile == "test";
if !skip_resources {
return;
}
let manifest_dir =
PathBuf::from(env::var("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR not set"));
let config_path = manifest_dir.join("tauri.conf.json");
let Ok(raw) = std::fs::read_to_string(&config_path) else {
println!("cargo:warning=Failed to read tauri.conf.json; keeping default config");
return;
};
let mut value: serde_json::Value = match serde_json::from_str(&raw) {
Ok(value) => value,
Err(err) => {
println!("cargo:warning=Failed to parse tauri.conf.json: {err}");
return;
}
};
if let Some(bundle) = value.get_mut("bundle").and_then(|b| b.as_object_mut()) {
bundle.insert("resources".to_string(), serde_json::Value::Array(Vec::new()));
}
let out_dir = env::var("OUT_DIR").unwrap_or_else(|_| ".".into());
let override_path = PathBuf::from(out_dir).join("tauri.conf.test.json");
if std::fs::write(&override_path, serde_json::to_string_pretty(&value).unwrap_or(raw)).is_ok()
{
env::set_var("TAURI_CONFIG", &override_path);
println!(
"cargo:warning=TAURI resources disabled for test build (using {})",
override_path.display()
);
}
}
#[cfg(not(any(target_os = "android", target_os = "ios")))]
fn setup_tdlib() {
// download-tdlib: downloads prebuilt TDLib and configures linker flags
tdlib_rs::build::build(None);
// On macOS, replace the bundled dylib with our source-built version
// that targets macOS 10.15 (the prebuilt one targets macOS 14.0)
#[cfg(target_os = "macos")]
copy_local_tdlib_for_bundle();
}
#[cfg(any(target_os = "android", target_os = "ios"))]
fn setup_tdlib() {
// No TDLib on mobile
}
/// On macOS, copy the source-built TDLib dylib (with 10.15 deployment target)
/// to libraries/ for Tauri bundler. Lookup order:
/// 1. tdlib-prebuilt/macos-<arch>/ (committed to git, no build needed)
/// 2. tdlib-local/lib/ (local build via build-tdlib-from-source.sh)
/// 3. download-tdlib output (fallback, targets macOS 14.0+)
#[cfg(target_os = "macos")]
fn copy_local_tdlib_for_bundle() {
use std::path::PathBuf;
let manifest_dir =
PathBuf::from(env::var("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR not set"));
let libraries_dir = manifest_dir.join("libraries");
// Use CARGO_CFG_TARGET_ARCH to handle cross-compilation (e.g. arm64 host → x86_64 target)
let target_arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap_or_else(|_| "aarch64".into());
let arch_name = match target_arch.as_str() {
"aarch64" => "arm64",
other => other,
};
let tdlib_version = "1.8.29";
let dylib_name = format!("libtdjson.{tdlib_version}.dylib");
// 1. Check tdlib-prebuilt/ (committed to git)
let prebuilt = manifest_dir
.join("tdlib-prebuilt")
.join(format!("macos-{arch_name}"))
.join(&dylib_name);
// 2. Check tdlib-local/<arch>/ (local source build)
let local = manifest_dir
.join("tdlib-local")
.join(arch_name)
.join("lib")
.join(&dylib_name);
let src_dylib = if prebuilt.exists() {
println!("cargo:warning=Using prebuilt TDLib from {}", prebuilt.display());
prebuilt
} else if local.exists() {
println!("cargo:warning=Using locally-built TDLib from {}", local.display());
local
} else {
// 3. Fall back to the download-tdlib output
println!(
"cargo:warning=No source-built TDLib found for macos-{arch_name}. \
The prebuilt TDLib will be bundled instead (targets macOS 14.0+). \
Run: cd src-tauri && ./scripts/build-tdlib-from-source.sh"
);
let out_dir = env::var("OUT_DIR").unwrap();
PathBuf::from(&out_dir).join("tdlib").join("lib").join(&dylib_name)
};
if !src_dylib.exists() {
println!("cargo:warning=TDLib dylib not found at {}", src_dylib.display());
return;
}
let dst_dylib = libraries_dir.join(&dylib_name);
std::fs::create_dir_all(&libraries_dir).expect("Failed to create libraries/");
std::fs::copy(&src_dylib, &dst_dylib).expect("Failed to copy TDLib dylib to libraries/");
set_permissions_rw(&dst_dylib);
fix_install_name(&dst_dylib, &dylib_name);
// Add rpath so the binary finds the dylib in Contents/Frameworks/
println!("cargo:rustc-link-arg=-Wl,-rpath,@executable_path/../Frameworks");
}
#[cfg(target_os = "macos")]
fn fix_install_name(dylib_path: &std::path::Path, dylib_name: &str) {
run_cmd(
"install_name_tool",
&[
"-id",
&format!("@rpath/{dylib_name}"),
dylib_path.to_str().unwrap(),
],
);
}
#[cfg(target_os = "macos")]
fn set_permissions_rw(path: &std::path::Path) {
use std::os::unix::fs::PermissionsExt;
let mut perms = std::fs::metadata(path)
.expect("Failed to read metadata")
.permissions();
perms.set_mode(0o755);
std::fs::set_permissions(path, perms).expect("Failed to set permissions");
}
#[cfg(target_os = "macos")]
fn run_cmd(cmd: &str, args: &[&str]) {
let status = std::process::Command::new(cmd)
.args(args)
.status()
.unwrap_or_else(|e| panic!("Failed to run {cmd}: {e}"));
if !status.success() {
panic!("{cmd} failed with exit code {:?}", status.code());
}
}