The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
feat(embed, tui): expose turn origin types and add crash reporting
Steven Enamakelb8b065e7578c
diff --git a/.gitignore b/.gitignoreindex b2230b67ef..09d4961f3c 100644--- a/.gitignore+++ b/.gitignore@@ -88,6 +88,7 @@ app/test/e2e/artifacts/tauri.keytauri.key.pub/target/+/crates/*/target/src-tauri/target/app/src-tauri-mobile/gen/app/src-tauri-mobile/target/diff --git a/crates/openhuman-embed/src/lib.rs b/crates/openhuman-embed/src/lib.rsindex 78c05ba898..bc18d102e4 100644--- a/crates/openhuman-embed/src/lib.rs+++ b/crates/openhuman-embed/src/lib.rs@@ -27,6 +27,10 @@pub use openhuman_core::agent_progress;pub use openhuman_core::embed::*;+pub use openhuman_core::openhuman::agent::turn_origin::{+ AgentTurnOrigin, TrustedAutomationSource,+};+pub use openhuman_core::openhuman::security::TrustedAccess;pub use openhuman_core::openhuman::tools::toolpacks::{GroupMode, ToolGroups};pub use openhuman_core::{CoreBuilder, CoreRuntime, DaemonConfig, DomainSet, HostKind, ServiceSet, TokenSource,diff --git a/crates/openhuman-embed/tests/public_api.rs b/crates/openhuman-embed/tests/public_api.rsindex a0bc659888..efa85d0a17 100644--- a/crates/openhuman-embed/tests/public_api.rs+++ b/crates/openhuman-embed/tests/public_api.rs@@ -1,8 +1,9 @@use std::sync::Arc;use openhuman_embed::{- set_product_identity, Access, Core, CoreBuilder, CoreRuntime, DomainSet, GroupMode, Harness,- HostKind, ProductIdentity, Provider, ServiceSet, ToolGroups, Workspace,+ set_product_identity, Access, AgentTurnOrigin, Core, CoreBuilder, CoreRuntime, DomainSet,+ GroupMode, Harness, HostKind, ProductIdentity, Provider, ServiceSet, ToolGroups,+ TrustedAccess, TrustedAutomationSource, Workspace,};#[test]@@ -14,6 +15,12 @@ fn exposes_the_host_facing_embedding_contract() {fn accepts_access(_: Access) {}fn accepts_provider(_: Provider) {}fn accepts_workspace(_: Workspace) {}+ fn applies_turn_origin<'a>(+ turn: openhuman_embed::Turn<'a>,+ origin: AgentTurnOrigin,+ ) -> openhuman_embed::Turn<'a> {+ turn.origin(origin)+ }let _ = accepts_core;let _ = accepts_builder;@@ -22,10 +29,18 @@ fn exposes_the_host_facing_embedding_contract() {let _ = accepts_access;let _ = accepts_provider;let _ = accepts_workspace;+ let _ = applies_turn_origin;let _ = DomainSet::embedded;let _ = ServiceSet::none;let _ = HostKind::Library;let _ = ToolGroups::none().with("documents", GroupMode::Advertised);+ let automation = AgentTurnOrigin::TrustedAutomation {+ job_id: "embed-public-api".to_string(),+ source: TrustedAutomationSource::Cron,+ };+ let _ = Access::full()+ .trust("/tmp/embed-public-api", TrustedAccess::ReadWrite)+ .origin(automation);let _ = set_product_identity;assert!(ProductIdentity::new("opencompany").is_some());}diff --git a/crates/openhuman-tui/Cargo.toml b/crates/openhuman-tui/Cargo.tomlindex 252966549e..d26f85321b 100644--- a/crates/openhuman-tui/Cargo.toml+++ b/crates/openhuman-tui/Cargo.toml@@ -7,6 +7,10 @@ license.workspace = truerepository.workspace = truepublish = false+[features]+default = ["crash-reporting"]+crash-reporting = ["dep:dotenvy", "dep:sentry", "openhuman-core/crash-reporting"]+[[bin]]name = "openhuman-tui"path = "src/main.rs"@@ -17,9 +21,11 @@ anyhow = "1"base64 = "0.22"chrono = "0.4"crossterm = "0.29"+dotenvy = { version = "0.15", optional = true }log = "0.4"ratatui = "0.30"serde_json = "1"+sentry = { version = "0.47.0", default-features = false, optional = true, features = ["backtrace", "contexts", "panic", "tracing", "debug-images", "httpdate"] }tokio = { version = "1", features = ["rt-multi-thread", "sync", "time"] }unicode-width = "0.2"uuid = { version = "1", features = ["v4"] }diff --git a/crates/openhuman-tui/src/crash_reporting.rs b/crates/openhuman-tui/src/crash_reporting.rsnew file mode 100644index 0000000000..e6c0b5b8a2--- /dev/null+++ b/crates/openhuman-tui/src/crash_reporting.rs@@ -0,0 +1,104 @@+//! Crash-reporting client ownership for the standalone terminal binary.++/// Initialize the Sentry client before the TUI installs its tracing subscriber.+///+/// The returned guard must live for the whole process. A build without the+/// `crash-reporting` feature retains the same call site and compiles to a no-op.+#[cfg(feature = "crash-reporting")]+pub fn init_crash_reporting() -> sentry::ClientInitGuard {+ // Match the core binary: startup consumers must see a repository-local+ // `.env`, while explicit process variables continue to take precedence.+ let _ = dotenvy::dotenv();++ sentry::init(sentry::ClientOptions {+ dsn: sentry_dsn(),+ release: Some(std::borrow::Cow::Owned(build_release_tag())),+ environment: Some(std::borrow::Cow::Owned(resolve_environment())),+ send_default_pii: false,+ before_send: Some(std::sync::Arc::new(|mut event| {+ event.server_name = None;+ for exception in &mut event.exception.values {+ if let Some(value) = exception.value.take() {+ exception.value = Some(+ openhuman_core::core::log_redaction::scrub_secrets(&value),+ );+ }+ }+ if let Some(message) = event.message.take() {+ event.message = Some(+ openhuman_core::core::log_redaction::scrub_secrets(&message),+ );+ }+ Some(event)+ })),+ sample_rate: 1.0,+ transport: Some(std::sync::Arc::new(+ openhuman_core::core::sentry_transport::factory,+ )),+ ..sentry::ClientOptions::default()+ })+}++#[cfg(not(feature = "crash-reporting"))]+pub fn init_crash_reporting() {}++#[cfg(feature = "crash-reporting")]+fn sentry_dsn() -> Option<sentry::types::Dsn> {+ std::env::var("OPENHUMAN_CORE_SENTRY_DSN")+ .ok()+ .filter(|value| !value.is_empty())+ .or_else(|| std::env::var("OPENHUMAN_SENTRY_DSN").ok())+ .filter(|value| !value.is_empty())+ .or_else(|| option_env!("OPENHUMAN_CORE_SENTRY_DSN").map(str::to_owned))+ .filter(|value| !value.is_empty())+ .or_else(|| option_env!("OPENHUMAN_SENTRY_DSN").map(str::to_owned))+ .filter(|value| !value.is_empty())+ .and_then(|value| value.parse().ok())+}++#[cfg(feature = "crash-reporting")]+fn build_release_tag() -> String {+ let version = env!("CARGO_PKG_VERSION");+ let short_sha: String = option_env!("OPENHUMAN_BUILD_SHA")+ .unwrap_or("")+ .trim()+ .chars()+ .take(12)+ .collect();+ if short_sha.is_empty() {+ format!("openhuman@{version}")+ } else {+ format!("openhuman@{version}+{short_sha}")+ }+}++#[cfg(feature = "crash-reporting")]+fn resolve_environment() -> String {+ if let Ok(value) = std::env::var("OPENHUMAN_APP_ENV") {+ let value = value.trim().to_ascii_lowercase();+ if !value.is_empty() {+ return value;+ }+ }+ if cfg!(debug_assertions) {+ "development".to_string()+ } else {+ "production".to_string()+ }+}++#[cfg(all(test, feature = "crash-reporting"))]+mod tests {+ use super::*;++ #[test]+ fn release_tag_uses_the_package_version_without_a_build_sha() {+ if option_env!("OPENHUMAN_BUILD_SHA")+ .unwrap_or("")+ .trim()+ .is_empty()+ {+ assert_eq!(build_release_tag(), format!("openhuman@{}", env!("CARGO_PKG_VERSION")));+ }+ }+}diff --git a/crates/openhuman-tui/src/lib.rs b/crates/openhuman-tui/src/lib.rsindex 0c05a33d9c..e5bae65995 100644--- a/crates/openhuman-tui/src/lib.rs+++ b/crates/openhuman-tui/src/lib.rs@@ -17,6 +17,7 @@ mod app;mod cockpit;mod composer;mod controls;+mod crash_reporting;mod render;mod runner;mod state;@@ -24,6 +25,7 @@ mod terminal;mod ui_state;pub use runner::run_from_cli;+pub use crash_reporting::init_crash_reporting;// State reducer is behaviour-only but has no terminal deps, so its tests run in// feature-on builds. Exported for the sibling submodules + tests.diff --git a/crates/openhuman-tui/src/main.rs b/crates/openhuman-tui/src/main.rsindex b22f93b50f..a036b17ef5 100644--- a/crates/openhuman-tui/src/main.rs+++ b/crates/openhuman-tui/src/main.rs@@ -1,4 +1,8 @@fn main() {+ // Keep the guard alive for the entire terminal session. `init_for_tui`+ // installs the tracing layer, while this creates the client that receives+ // its events and installs Sentry's panic integration.+ let _sentry_guard = openhuman_tui::init_crash_reporting();if let Err(error) = openhuman_tui::run_from_cli(&std::env::args().skip(1).collect::<Vec<_>>()) {eprintln!("Error: {error:#}");std::process::exit(1);