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
docs(core): clarify app state and API docs around session ownership
Steven Enamakel7490149fb4ea
diff --git a/crates/openhuman-core/src/api/README.md b/crates/openhuman-core/src/api/README.mdindex f4c3f02975..85594175f5 100644--- a/crates/openhuman-core/src/api/README.md+++ b/crates/openhuman-core/src/api/README.md@@ -100,18 +100,21 @@ OpenHuman-configured `reqwest::Client` (`x-core-version`, optional- `authed_json` / `fetch_billing_summary` — send an authenticated request androute the result through `finish_authed_json`.-- Typed route helpers (`fetch_current_user`, `create_channel_link_token`,+- Typed route helpers (`fetch_profile`, `create_channel_link_token`,`list_integrations`, `fetch_integration_tokens_handoff`, `fetch_client_key`,`send_channel_*`, `*_channel_thread`, `revoke_integration`) all go through- `authed_json`. `consume_login_token` is the exception: it calls the SDK's- typed `auth()` API directly.-- `connect`, `login_url`, `url_for`, `raw_client` — OAuth connect flow and- URL helpers for callers that need to drive a non-JSON request (e.g.- multipart uploads) without re-implementing TLS/proxy setup.+ `authed_json`. Every one of them is bearer-only: the core never obtains,+ exchanges or validates a session — login-token exchange and `/auth/me`+ validation live in the host's session owner (`crates/openhuman-session`),+ and `fetch_profile` exists only for channel link-checks that read a+ connected channel id off the profile.+- `connect`, `url_for`, `raw_client` — OAuth connect flow and URL helpers for+ callers that need to drive a non-JSON request (e.g. multipart uploads)+ without re-implementing TLS/proxy setup.- `ConnectResponse`, `IntegrationSummary`, `IntegrationTokensHandoff` — typedbackend response shapes.-- `user_id_from_auth_me_payload` / `user_id_from_profile_payload` — pull the- user id out of the `/auth/me` envelope variants.+- `user_id_from_profile_payload` — pull the user id out of the `/auth/me`+ envelope variants.- `decrypt_handoff_blob` — AES-256-GCM decrypt for integration token handoff,compatible with the backend's `encryptMessageFromString`.diff --git a/crates/openhuman-core/src/desktop/app_state/README.md b/crates/openhuman-core/src/desktop/app_state/README.mdindex dace2bd553..55468851bb 100644--- a/crates/openhuman-core/src/desktop/app_state/README.md+++ b/crates/openhuman-core/src/desktop/app_state/README.md@@ -1,58 +1,51 @@# App State-Aggregator that the React shell polls every few seconds (`openhuman.app_state_snapshot`) to render the OS-level chrome: auth user, local-AI status, service health, onboarding tasks, keyring status, config-recovery notice. Owns the on-disk `app-state.json`, the in-memory current-user cache (positive result, negative backoff record, last-success timestamp), and the merge/patch surface for shell-managed local fields. Does NOT own any of the underlying domain state — it assembles snapshots from peer domains and persists shell-side onboarding metadata.+Aggregator that the React shell polls every few seconds (`openhuman.app_state_snapshot`) to render the OS-level chrome: the stored credential and user, local-AI status, service health, onboarding tasks, keyring status, config-recovery notice. Owns the on-disk `app-state.json` and the merge/patch surface for shell-managed local fields. Does NOT own any of the underlying domain state — it assembles snapshots from peer domains and persists shell-side onboarding metadata.++The snapshot never talks to the backend. The user it reports is the payload the host handed the core with `auth.set_credential` (the host's own `/auth/me` answer); the *live* current user is the session owner's business — the Tauri shell's `openhuman-session` cache (`crates/openhuman-session`) — and the frontend merges it in (`app/src/services/coreStateApi.ts`).## Key files| File | Role || --- | --- || `mod.rs` | `pub use ops::*`, `recovery_signal::{config_recovered_this_session, latch_from_config}`, and the `all_app_state_*` / `app_state_schemas` controller aggregators. |-| `ops.rs` | Aggregator only: declares the submodules below and attaches the sibling test files. |+| `ops.rs` | Aggregator only: declares the submodules below and attaches the sibling test file. || `ops/types.rs` | Serde types (`StoredOnboardingTasks`, `StoredAppState`, `AppStateSnapshot`, `RuntimeSnapshot`, `StoredAppStatePatch`). || `ops/state_file.rs` | `app-state.json` load/save with corruption quarantine (`load_stored_app_state`, `save_app_state`). |-| `ops/current_user_fetch.rs` | The current-user HTTP fetch (`fetch_current_user`). |-| `ops/current_user.rs` | `fetch_current_user_cached` (5s TTL + failure backoff capped at 60s) and `peek_cached_current_user_identity`. |+| `ops/runtime_snapshot.rs` | The local-AI + service half of the snapshot (10s cache, single-flighted, #4249). || `ops/snapshot.rs` | `snapshot()` and `update_local_state()`. |-| `ops/auth_timeout.rs` | `OPENHUMAN_AUTH_FETCH_TIMEOUT_SECS` parsing, clamped to 2–12s (default 5s). |-| `ops/staleness.rs` | `LAST_CURRENT_USER_SUCCESS`, feeding `current_user_stale` / `current_user_stale_seconds` (#5930). |-| `ops/current_user_generation.rs` | `CURRENT_USER_GENERATION` counter, `CURRENT_USER_SESSION_MUTATION_LOCK`, `forget_current_user_caches` (sign-out invalidation). || `recovery_signal.rs` | Process-lifetime latch for "config.toml was recovered from corruption this session" (#5167). || `schemas.rs` | `app_state` controller schemas and thin handlers. || `*_tests.rs` | Sibling test files attached with `#[cfg(test)] #[path = ...] mod`. |## Public surface-- `AppStateSnapshot` — composite payload: `auth`, `session_token`, `current_user`, `onboarding_completed`, `chat_onboarding_completed`, `analytics_enabled`, `local_state`, `keyring_status`, `runtime` (`RuntimeSnapshot { local_ai: LocalAiStatus, service: ServiceStatus }`), `health`, `config_recovered`, `current_user_stale`, `current_user_stale_seconds`.+- `AppStateSnapshot` — composite payload: `auth` (`AuthStateResponse`: `isAuthenticated`, `userId`, `user`, `profileId`, `credential`, `expiresAt`), `session_token`, `current_user` (= `auth.user`), `onboarding_completed`, `chat_onboarding_completed`, `analytics_enabled`, `local_state`, `keyring_status`, `runtime` (`RuntimeSnapshot { local_ai: LocalAiStatus, service: ServiceStatus }`), `health`, `config_recovered`.- `StoredAppState` — disk schema persisted to `<workspace_dir>/state/app-state.json` (`encryption_key`, `onboarding_tasks`, `keyring_consent`). `StoredOnboardingTasks` holds the shell-tracked onboarding flags plus `enabled_tools` and `connected_sources`.- `StoredAppStatePatch` — partial update (`Option<Option<_>>` per field) applied by `update_local_state`.-- `pub async fn snapshot() -> Result<RpcOutcome<AppStateSnapshot>, String>` — full snapshot; runtime sub-snapshot is cached for 10s and single-flighted (#4249).+- `pub async fn snapshot() -> Result<RpcOutcome<AppStateSnapshot>, String>` — full snapshot; one auth-profile load per call, no network.- `pub async fn update_local_state(StoredAppStatePatch) -> Result<RpcOutcome<StoredAppState>, String>` — merge under `APP_STATE_FILE_LOCK` and save atomically.- `pub(crate) fn load_stored_app_state(&Config)` / `pub fn save_app_state(&Config, &StoredAppState)` — direct disk access; a corrupt file is renamed to `app-state.json.corrupted.<ts>` and replaced with defaults.-- `pub fn peek_cached_current_user_identity() -> Option<UserIdentity>` — id/name/email from the cache, ignoring the TTL; never returns tokens.-- `pub fn forget_current_user_caches()` and `pub static CURRENT_USER_SESSION_MUTATION_LOCK` — sign-out hooks used by the credentials domain.- `latch_from_config(&Config)` / `config_recovered_this_session()` — recovery latch.-- Auth-fetch timeout constants and `parse_auth_fetch_timeout_secs`.- RPC `app_state.{snapshot, update_local_state}` via `all_app_state_controller_schemas` / `all_app_state_registered_controllers`.+The signed-in identity for prompts and Sentry is `security::credentials::identity::peek_credential_user_identity()`, seeded from the same stored payload.+## Calls into-- `crate::config` — `config::rpc::load_config_with_timeout`, `read_active_user_id` / `write_active_user_id`, `default_root_openhuman_dir`.-- `crate::security::credentials` — `session_support::{load_app_session_profile, session_state_from_profile, session_token_from_profile, is_local_session_token}`, `AuthService`, `start_login_gated_services` / `stop_login_gated_services`, `sentry_scope`; `crate::security::keyring_consent` for `KeyringStatus` / `ConsentPreference`.-- `crate::api::{config, jwt, rest, product}` — backend base URL, bearer header, profile-payload user id, and the `x-sdk-name` product identity headers for the `GET /auth/me` fetch (built on `crate::util::tls::tls_client_builder`).+- `crate::config` — `config::rpc::load_config_with_timeout`.+- `crate::security::credentials` — `session_support::{load_app_session_profile, session_state_from_profile, session_token_from_profile}`; `crate::security::keyring_consent` for `KeyringStatus` / `ConsentPreference`.- `crate::inference` — `LocalAiStatus` via `inference::rpc::inference_status`.- `crate::platform::service` — `ServiceState` / `ServiceStatus`; `crate::platform::health::snapshot`.-- `crate::cron::scheduler_gate::set_signed_out`, `crate::cron::seed::prune_retired_jobs`, `crate::memory::conversations::{purge_threads, register_conversation_persistence_subscriber}`, and `CoreContext::rebind_default_workspace` when a pending session is validated or a deferred rejection is cleaned up.## Called by- `crates/openhuman-core/src/core/all.rs` — registers `all_app_state_registered_controllers()`; the shell reaches them through `coreRpcClient` → `relay_http_rpc`.- `crates/openhuman-core/src/core/jsonrpc.rs` — `latch_from_config` at runtime bootstrap.- `crates/openhuman-core/src/agent/harness/session/builder/factory.rs` — `load_stored_app_state` to read `onboarding_tasks.enabled_tools` for tool filtering.-- `peek_cached_current_user_identity` — `agent/harness/session/turn/context.rs`, `agent/tinyagents/host/context_composer.rs`, `agent/tinyagents/payload_summarizer.rs`, `web_chat/progress_bridge.rs`, and the Sentry `before_send` filters in `main.rs` and `crates/openhuman-app/src/lib.rs`.-- `crates/openhuman-core/src/security/credentials/ops/session_query.rs` — takes `CURRENT_USER_SESSION_MUTATION_LOCK` and calls `forget_current_user_caches` on sign-out.- `crates/openhuman-core/src/security/keyring_consent/ops.rs` — persists the consent choice through `update_local_state`.## Tests-- `ops_tests.rs`, `ops_current_user_backoff_tests.rs`, `ops_snapshot_latency_tests.rs`, `ops_signout_cache_tests.rs`, `recovery_signal_tests.rs`, `schemas_tests.rs`.-- JSON-RPC shape: `tests/json_rpc_e2e.rs` (`json_rpc_app_state_snapshot_returns_runtime_shape`) and `tests/config_auth_app_state_connectivity_e2e.rs`.+- `ops_tests.rs`, `recovery_signal_tests.rs`, `schemas_tests.rs`.+- JSON-RPC shape: `tests/json_rpc_e2e.rs` (`json_rpc_app_state_snapshot_returns_runtime_shape`), `tests/config_auth_app_state_connectivity_e2e.rs`, and `tests/raw_coverage/app_state_credentials_raw_coverage_e2e.rs`.