
    +j                     :   % S r SSKrSSKJrJr  SSKJr   " S S\5      rSSS	S
S.0r\	\
\4   \S'   S\
S\4S jr\S S S.r\	\
\4   \S'   S\
S\
S\4S jrS\	\
\4   4S jrS\R"                  S-  S-  SSS00S\R$                  S.r\	\
\4   \S'   \" 5       R)                  5        V Vs0 s H  u  pU \;  d  M  X_M     snn r0 \E\Er\	\
\4   \S'    S&S\	\
\	\
\4   4   S \
S!\
S"\S\4
S# jjrS\	\
\	\
\4   4   S \
S!\
S\4S$ jrS\	\
\4   4S% jrgs  snn f )'z
Feature flags module for ComfyUI WebSocket protocol negotiation.

This module handles capability negotiation between frontend and backend,
allowing graceful protocol evolution while maintaining backward compatibility.
    N)Any	TypedDict)argsc                   4    \ rS rSr% \\S'   \\S'   \\S'   Srg)FeatureFlagInfo   typedefaultdescription N)__name__
__module____qualname____firstlineno__str__annotations__r   __static_attributes__r       7/home/wildlama/comfy/ComfyUI/comfy_api/feature_flags.pyr   r      s    
ILr   r   show_signin_buttonboolFz?Show the sign-in button in the frontend even when not signed in)r	   r
   r   CLI_FEATURE_FLAG_REGISTRYvreturnc                 \    U R                  5       nUS:X  a  gUS:X  a  g[        SU < 35      e)zStrict bool coercion: only 'true'/'false' (case-insensitive).

Anything else raises ValueError so the caller can warn and drop the flag,
rather than silently treating typos like 'ture' or 'yes' as False.
trueTfalseFz expected 'true' or 'false', got )lower
ValueError)r   r   s     r   _coerce_boolr       s7     GGIE
7u=
>>r   c                     [        U 5      $ N)intr   s    r   <lambda>r%   /   s    SVr   c                     [        U 5      $ r"   )floatr$   s    r   r%   r%   0   s    uQxr   )r   r#   r'   _COERCE_FNSkey	raw_valuec                     [         R                  U 5      nUc  U$ [        R                  US   5      nUc  U$ U" U5      $ )a)  Coerce a raw string value using the registry type, or keep as string.

Returns the raw string if the key is unregistered or the type is unknown.
Raises ValueError/TypeError if the key is registered with a known type but
the value cannot be coerced; callers are expected to warn and drop the flag.
r	   )r   getr(   )r)   r*   infocoerces       r   _coerce_flag_valuer/   4   sG     %((-D|__T&\*F~)r   c                     0 n [        [        S/ 5       HU  nUR                  S5      u  p#nUR                  5       nU(       d  M0  U(       d  Sn [	        X$R                  5       5      X'   MW     U $ ! [
        [        4 aX  n[        R                  U0 5      n[        R                  " SX$R                  5       UR                  SS5      U5         SnAM  SnAff = f)a9  Parse --feature-flag key=value pairs from CLI args into a dict.

Items without '=' default to the value 'true' (bare flag form).
Flags whose value cannot be coerced to the registered type are dropped
with a warning, so a typo like '--feature-flag some_bool=ture' does not
silently take effect as the wrong value.
feature_flag=r   z@Could not coerce --feature-flag %s=%r to %s (%s); dropping flag.r	   ?N)getattrr   	partitionstripr/   r   	TypeErrorr   r,   loggingwarning)resultitemr)   sepr*   er-   s          r   _parse_cli_feature_flagsr>   D   s      Fnb1"nnS1)iikI	,S//2CDFK 2 M I& 	,00b9DOOR__&(=q 	s   A//C?ACCTi   managersupports_v4)supports_preview_metadatamax_upload_size	extensionnode_replacementsassets_CORE_FEATURE_FLAGSSERVER_FEATURE_FLAGSsockets_metadatasidfeature_namer
   c                 V    X;  a  U$ X   R                  S0 5      R                  X#5      $ )a)  
Get a feature flag value for a specific connection.

Args:
    sockets_metadata: Dictionary of socket metadata
    sid: Session ID of the connection
    feature_name: Name of the feature to check
    default: Default value if feature not found

Returns:
    Feature value or default if not found
feature_flags)r,   )rH   rI   rJ   r
   s       r   get_connection_featurerM   n   s0    $ " $$_b9==lTTr   c                      [        XUS5      SL $ )z
Check if a connection supports a specific feature.

Args:
    sockets_metadata: Dictionary of socket metadata
    sid: Session ID of the connection
    feature_name: Name of the feature to check

Returns:
    Boolean indicating if feature is supported
FT)rM   )rH   rI   rJ   s      r   supports_featurerO      s      ""2uMQUUUr   c                  *    [         R                  5       $ )zR
Get the server's feature flags.

Returns:
    Dictionary of server feature flags
)rG   copyr   r   r   get_server_featuresrR      s      $$&&r   )F)__doc__r8   typingr   r   comfy.cli_argsr   r   r   dictr   r   r   r    r(   r/   r>   rB   enable_assetsrF   items
_cli_flagsrG   rM   rO   rR   )kr   s   00r   <module>r[      s    ! i  X9 4_ 45 ?C ?D ? T#s(^ C C C  $sCx. : "&++d2T9mT23  ' T#s(^   89??AbAtqQNaEadadAb
'L*='L'L d38n L 	U3S#X./U	U U 	U
 	U0V3S#X./V	V V 
	V&'T#s(^ 'a cs   -D=D