Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

refactor(core): move user identity accessor to credentials module

Steven Enamakel7282f25d5b15
diff --git a/crates/openhuman-core/src/agent/harness/session/turn/context.rs b/crates/openhuman-core/src/agent/harness/session/turn/context.rs
index 1fbbb9f769..152944f1f7 100644
--- a/crates/openhuman-core/src/agent/harness/session/turn/context.rs
+++ b/crates/openhuman-core/src/agent/harness/session/turn/context.rs
@@ -332,7 +332,7 @@ impl Agent {
include_profile: !self.omit_profile,
include_memory_md: !self.omit_memory_md,
curated_snapshot: None,
- user_identity: crate::desktop::app_state::peek_cached_current_user_identity(),
+ user_identity: crate::security::credentials::identity::peek_credential_user_identity(),
// Profile SOUL.md and curated MEMORY.md are bound at session
// construction so the normal identity/user-files sections use
// them instead of their workspace-root fallbacks.
diff --git a/crates/openhuman-core/src/agent/harness/subagent_runner/ops/runner.rs b/crates/openhuman-core/src/agent/harness/subagent_runner/ops/runner.rs
index 044d64c052..f510c0f83a 100644
--- a/crates/openhuman-core/src/agent/harness/subagent_runner/ops/runner.rs
+++ b/crates/openhuman-core/src/agent/harness/subagent_runner/ops/runner.rs
@@ -1392,7 +1392,7 @@ async fn run_typed_mode(
include_profile: !definition.omit_profile,
include_memory_md: !definition.omit_memory_md,
curated_snapshot: None,
- user_identity: crate::desktop::app_state::peek_cached_current_user_identity(),
+ user_identity: crate::security::credentials::identity::peek_credential_user_identity(),
personality_soul_md: None,
personality_memory_md: None,
personality_roster: vec![],
diff --git a/crates/openhuman-core/src/agent/prompts/types.rs b/crates/openhuman-core/src/agent/prompts/types.rs
index 481e63f8f5..e74d36017e 100644
--- a/crates/openhuman-core/src/agent/prompts/types.rs
+++ b/crates/openhuman-core/src/agent/prompts/types.rs
@@ -306,7 +306,7 @@ pub enum ToolCallFormat {
/// Only **identifying** fields land here; tokens, refresh tokens, and
/// any opaque credential material are forbidden. The struct is
/// constructed from the cached `auth_get_me` response in
-/// `app_state::ops::peek_cached_current_user_identity`, which strips
+/// `credentials::identity::peek_credential_user_identity`, which strips
/// everything but `id` / `email` / `name` before returning.
#[derive(Debug, Clone, Default)]
pub struct UserIdentity {
diff --git a/crates/openhuman-core/src/agent/tinyagents/host/context_composer.rs b/crates/openhuman-core/src/agent/tinyagents/host/context_composer.rs
index ba2ee33d26..22a0c9516a 100644
--- a/crates/openhuman-core/src/agent/tinyagents/host/context_composer.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/host/context_composer.rs
@@ -13,7 +13,7 @@
//! never reads them itself.
//! * [`crate::config::Config`] — supplies `workspace_dir`,
//! `action_dir`, the default model, and the `agents_md_enabled` gate.
-//! * [`crate::desktop::app_state::peek_cached_current_user_identity`] — the
+//! * [`crate::security::credentials::identity::peek_credential_user_identity`] — the
//! non-secret `id`/`name`/`email` triple. Deliberately read through the
//! *cache peek*, which is the accessor that strips credential material; this
//! adapter must not reach for a richer user record to fill the prompt.
@@ -289,7 +289,7 @@ impl ContextComposer for OpenHumanContextComposer {
// files sections fall back to the workspace files, which is the
// documented `None` behaviour.
curated_snapshot: None,
- user_identity: crate::desktop::app_state::peek_cached_current_user_identity(),
+ user_identity: crate::security::credentials::identity::peek_credential_user_identity(),
personality_soul_md: None,
personality_memory_md: None,
// TODO(phase4): the master agent's personality roster is built
diff --git a/crates/openhuman-core/src/agent/tinyagents/payload_summarizer.rs b/crates/openhuman-core/src/agent/tinyagents/payload_summarizer.rs
index 8c1e1af607..b52672cfc8 100644
--- a/crates/openhuman-core/src/agent/tinyagents/payload_summarizer.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/payload_summarizer.rs
@@ -465,7 +465,7 @@ impl SubagentPayloadSummarizer {
include_profile: !self.definition.omit_profile,
include_memory_md: !self.definition.omit_memory_md,
curated_snapshot: None,
- user_identity: crate::desktop::app_state::peek_cached_current_user_identity(),
+ user_identity: crate::security::credentials::identity::peek_credential_user_identity(),
personality_soul_md: None,
personality_memory_md: None,
personality_roster: vec![],
diff --git a/crates/openhuman-core/src/main.rs b/crates/openhuman-core/src/main.rs
index 8ba5c36fb2..69c8662407 100644
--- a/crates/openhuman-core/src/main.rs
+++ b/crates/openhuman-core/src/main.rs
@@ -258,7 +258,7 @@ fn main() {
// the cache is empty (root cause of the original userCount=0).
if event.user.is_none() {
event.user =
- openhuman_core::desktop::app_state::peek_cached_current_user_identity()
+ openhuman_core::security::credentials::identity::peek_credential_user_identity()
.and_then(|identity| identity.id)
.map(|id| sentry::User {
id: Some(id),
diff --git a/crates/openhuman-core/src/security/credentials/sentry_scope.rs b/crates/openhuman-core/src/security/credentials/sentry_scope.rs
index 4d91ae179d..39a5766839 100644
--- a/crates/openhuman-core/src/security/credentials/sentry_scope.rs
+++ b/crates/openhuman-core/src/security/credentials/sentry_scope.rs
@@ -3,7 +3,7 @@
//! Issue #3135 — direct-mode core events (`tauri-rust` / `core-rust`) were
//! landing in Sentry with `userCount=0` because the `before_send` filter in
//! `src/main.rs` / `crates/openhuman-app/src/lib.rs` reads
-//! [`peek_cached_current_user_identity`](crate::desktop::app_state::peek_cached_current_user_identity),
+//! [`peek_credential_user_identity`](crate::security::credentials::identity::peek_credential_user_identity),
//! and that cache is only ever populated by the frontend-driven
//! `app_state_snapshot` RPC. Background loops (Composio sync tick, etc.) fire
//! before — or independent of — any snapshot, so events miss user attribution.
diff --git a/crates/openhuman-core/src/web_chat/progress_bridge.rs b/crates/openhuman-core/src/web_chat/progress_bridge.rs
index e432dda077..1a56313e65 100644
--- a/crates/openhuman-core/src/web_chat/progress_bridge.rs
+++ b/crates/openhuman-core/src/web_chat/progress_bridge.rs
@@ -391,7 +391,7 @@ pub(crate) fn spawn_progress_bridge(
// the separate `client.id` metadata attribute. When no identity is
// cached (signed-out / fresh install), fall back to the client id
// so the trace still carries some attribution.
- let identity = crate::desktop::app_state::peek_cached_current_user_identity();
+ let identity = crate::security::credentials::identity::peek_credential_user_identity();
let user_attributed = identity.is_some();
let user_id = identity
.and_then(|i| i.id.or(i.email))