ai-agent 0.13.4

Idiomatic agent sdk inspired by the claude code source leak
Documentation
// Source: /data/home/swei/claudecode/openclaudecode/src/utils/ink.ts
//! Ink color conversion utilities
//!
//! Convert color strings to Ink's TextProps['color'] format.

/// Default agent theme color for subagents
const DEFAULT_AGENT_THEME_COLOR: &str = "cyan_FOR_SUBAGENTS_ONLY";

/// Agent color name to theme color mapping
///
/// Note: This mapping would be populated from the actual agent color manager
const AGENT_COLOR_TO_THEME_COLOR: &[(&str, &str)] = &[
    ("black", "black"),
    ("red", "red"),
    ("green", "green"),
    ("yellow", "yellow"),
    ("blue", "blue"),
    ("magenta", "magenta"),
    ("cyan", "cyan"),
    ("white", "white"),
    ("gray", "gray"),
    ("grey", "gray"),
];

/// Convert a color string to Ink's TextProps['color'] format.
///
/// Colors are typically AgentColorName values like 'blue', 'green', etc.
/// This converts them to theme keys so they respect the current theme.
/// Falls back to the raw ANSI color if the color is not a known agent color.
///
/// # Arguments
/// * `color` - The color string to convert
///
/// # Returns
/// The Ink-compatible color value
pub fn to_ink_color(color: Option<&str>) -> String {
    let color = match color {
        Some(c) => c,
        None => return DEFAULT_AGENT_THEME_COLOR.to_string(),
    };

    // Try to map to a theme color if it's a known agent color
    for (agent_color, theme_color) in AGENT_COLOR_TO_THEME_COLOR {
        if agent_color.eq_ignore_ascii_case(color) {
            return theme_color.to_string();
        }
    }

    // Fall back to raw ANSI color for unknown colors
    format!("ansi:{}", color)
}