o
     
j                     @   s   U d Z ddlZddlmZ dZeedf ed< dZeeeedf ef df ed< d	hd
d eD B Z	dee fddZ
defddZdS )a  Detect whether the process is being invoked by an AI coding agent.

Detection is based on environment variables that AI agents set in their shell
sessions.  ``AI_AGENT`` and ``AGENT`` are treated as a universal standard (any
tool can set it); the remaining checks are tool-specific and ordered by
prevalence.

Inspired by ``@vercel/detect-agent`` (https://github.com/vercel/vercel/tree/main/packages/detect-agent).
    N)Optional)AI_AGENTAGENT._STANDARD_AGENT_VARS)))ANTIGRAVITY_AGENTantigravity))AUGMENT_AGENTzaugment-cli))CLINE_ACTIVEcline))CLAUDE_CODE_IS_COWORKcowork))
CLAUDECODECLAUDE_CODEzclaude-code))CODEX_SANDBOXCODEX_CICODEX_THREAD_IDcodex))CURSOR_TRACE_IDcursor))CURSOR_AGENTz
cursor-cli))
GEMINI_CLIgemini))COPILOT_MODELCOPILOT_ALLOW_ALLCOPILOT_GITHUB_TOKENzgithub-copilot))GOOSE_TERMINALgoose))OPENCLAW_SHELLopenclaw))OPENCODE_CLIENTopencode))PI_CODING_AGENTpi))REPL_IDreplit))
ROO_ACTIVEzroo-code))TRAE_AI_SHELL_IDtrae_TOOL_AGENTSdevinc                 C   s   h | ]\}}|qS  r*   ).0_agentr*   r*   V/home/kuhnn/.local/lib/python3.10/site-packages/huggingface_hub/utils/_detect_agent.py	<setcomp>7   s    r/   returnc                  C   sh   t D ]} tj| d  }|r|tv r|  S d  S qtD ]\}}tdd |D r1|  S q dS )a!  Return the name of the detected AI agent or ``None``.

    Checks environment variables in priority order and returns on the first
    match.  When ``AI_AGENT`` or ``AGENT`` is set, the value is checked against
    known agent names, unrecognized values are returned as ``"unknown"``.
     unknownc                 s   s    | ]	}t j|V  qd S )N)osenvironget)r+   varr*   r*   r.   	<genexpr>G   s    zdetect_agent.<locals>.<genexpr>N)	r   r3   r4   r5   striplower_KNOWN_AGENTSr(   any)r6   nameenv_vars
agent_namer*   r*   r.   detect_agent:   s   r?   c                   C   s
   t  duS )zFReturn ``True`` if the process is being invoked by an AI coding agent.N)r?   r*   r*   r*   r.   is_agentM   s   
r@   )__doc__r3   typingr   r   tuplestr__annotations__r(   r:   r?   boolr@   r*   r*   r*   r.   <module>   s   
$