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

Function derive_agent_author

atomic-agent/src/identity.rs:298–314  ·  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

296/// If the user has no email, uses the agent name with the user's
297/// public key reference.
298fn derive_agent_author(user: &UserIdentityInfo, options: &AgentAuthorOptions<'_>) -> Author {
299 let session_short = extract_session_short(options.session_id);
300 let agent_tag = format!(
301 "{}+{}",
302 normalize_agent_name(options.agent_name),
303 session_short
304 );
305
306 match &user.email {
307 Some(email) => Author::with_identity(
308 &agent_tag,
309 Some(email.clone()),
310 user.public_key_base32.clone(),
311 ),
312 None => Author::with_identity(&agent_tag, None::<String>, user.public_key_base32.clone()),
313 }
314}
315
316/// Fallback author when no user identity is configured.
317fn fallback_agent_author(options: &AgentAuthorOptions<'_>) -> Author {

Calls 2

extract_session_shortFunction · 0.85
cloneMethod · 0.45