/ utils / standaloneAgent.ts
standaloneAgent.ts
 1  /**
 2   * Standalone agent utilities for sessions with custom names/colors
 3   *
 4   * These helpers provide access to standalone agent context (name and color)
 5   * for sessions that are NOT part of a swarm team. When a session is part
 6   * of a swarm, these functions return undefined to let swarm context take
 7   * precedence.
 8   */
 9  
10  import type { AppState } from '../state/AppState.js'
11  import { getTeamName } from './teammate.js'
12  
13  /**
14   * Returns the standalone agent name if set and not a swarm teammate.
15   * Uses getTeamName() for consistency with isTeammate() swarm detection.
16   */
17  export function getStandaloneAgentName(appState: AppState): string | undefined {
18    // If in a team (swarm), don't return standalone name
19    if (getTeamName()) {
20      return undefined
21    }
22    return appState.standaloneAgentContext?.name
23  }