MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / derive_agent_author

Function derive_agent_author

atomic-agent/src/identity.rs:115–131  ·  view source on GitHub ↗

Derive the agent author from the user's identity. Constructs: `{agent_name}+{session_short} <{user_email}>` If the user has no email, uses the agent name with the user's public key reference.

(user: &UserIdentityInfo, options: &AgentAuthorOptions<'_>)

Source from the content-addressed store, hash-verified

113/// If the user has no email, uses the agent name with the user's
114/// public key reference.
115fn derive_agent_author(user: &UserIdentityInfo, options: &AgentAuthorOptions<'_>) -> Author {
116 let session_short = extract_session_short(options.session_id);
117 let agent_tag = format!(
118 "{}+{}",
119 normalize_agent_name(options.agent_name),
120 session_short
121 );
122
123 match &user.email {
124 Some(email) => Author::with_identity(
125 &agent_tag,
126 Some(email.clone()),
127 user.public_key_base32.clone(),
128 ),
129 None => Author::with_identity(&agent_tag, None::<String>, user.public_key_base32.clone()),
130 }
131}
132
133/// Fallback author when no user identity is configured.
134fn fallback_agent_author(options: &AgentAuthorOptions<'_>) -> Author {

Calls 2

extract_session_shortFunction · 0.85
cloneMethod · 0.45