
    i                         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eD  ch c]  \  } }|	 c}} z  Z	d
ee   fdZ
d
efdZyc c}} w )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))REPL_IDreplit))
ROO_ACTIVEzroo-code))TRAE_AI_SHELL_IDtrae_TOOL_AGENTSdevinreturnc                      t         D ]P  } t        j                  j                  | d      j	                         j                         }|sB|t        v r|c S dc S  t        D ]  \  }}t        d |D              s|c S  y)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              3   Z   K   | ]#  }t         j                  j                  |       % y w)N)osenvironget).0vars     t/var/www/vps2.regionflexible.com/Desarrollo/venv/lib/python3.12/site-packages/huggingface_hub/utils/_detect_agent.py	<genexpr>zdetect_agent.<locals>.<genexpr>F   s     7srzz~~c"7s   )+N)	r   r.   r/   r0   striplower_KNOWN_AGENTSr'   any)r2   nameenv_vars
agent_names       r3   detect_agentr<   9   s     $ @zz~~c2&,,.446=04?i?@
 !- *7h77     c                      t               duS )zFReturn ``True`` if the process is being invoked by an AI coding agent.N)r<    r=   r3   is_agentr@   L   s    >%%r=   )__doc__r.   typingr   r   tuplestr__annotations__r'   r7   r<   boolr@   )_agents   00r3   <module>rI      s    
  )> eCHo =9eE%S/3./45 & 	<@xq%U@@hsm &&$ &- As   A