Skip to main content

codetether_agent/tui/app/state/
agent_profile.rs

1//! Agent identity profile lookup.
2//!
3//! Maps agent names to codenames, collaboration styles, and signature moves
4//! using keyword matching with FNV-1a hash fallback.
5
6use crate::session::Session;
7
8use super::profile_defs::{self, AgentProfile, *};
9
10/// A spawned sub-agent with its own independent LLM session.
11#[allow(dead_code)]
12pub struct SpawnedAgent {
13    /// User-facing name (e.g. "planner", "coder")
14    pub name: String,
15    /// System instructions for this agent
16    pub instructions: String,
17    /// Independent conversation session
18    pub session: Session,
19    /// Whether this agent is currently processing a message
20    pub is_processing: bool,
21}
22
23/// Map an agent name to its codename profile.
24pub fn agent_profile(agent_name: &str) -> AgentProfile {
25    let normalized = agent_name.to_ascii_lowercase();
26
27    if normalized.contains("planner") {
28        return PROFILE_PLANNER;
29    }
30    if normalized.contains("research") {
31        return PROFILE_RESEARCH;
32    }
33    if normalized.contains("coder") || normalized.contains("implement") {
34        return PROFILE_CODER;
35    }
36    if normalized.contains("review") {
37        return PROFILE_REVIEW;
38    }
39    if normalized.contains("tester") || normalized.contains("test") {
40        return PROFILE_TESTER;
41    }
42    if normalized.contains("integrat") {
43        return PROFILE_INTEGRATOR;
44    }
45    if normalized.contains("skeptic") || normalized.contains("risk") {
46        return PROFILE_SKEPTIC;
47    }
48    if normalized.contains("summary") || normalized.contains("summarizer") {
49        return PROFILE_SUMMARIZER;
50    }
51
52    // FNV-1a hash into fallback profiles
53    let mut hash: u64 = 2_166_136_261;
54    for byte in normalized.bytes() {
55        hash = (hash ^ u64::from(byte)).wrapping_mul(16_777_619);
56    }
57    FALLBACK_PROFILES[hash as usize % FALLBACK_PROFILES.len()]
58}