
    ^(j                     $   U d Z ddlZddlmZmZ ddlmZ  G d de      Zddd	d
diZe	e
ef   ed<   de
defdZed d dZe	e
ef   ed<   de
de
defdZde	e
ef   fdZdej"                  dz  dz  dddiidej$                  dZe	e
ef   ed<    e       j)                         D  ci c]  \  } }| evs| | c}} Zi eeZe	e
ef   ed<   	 d&de	e
e	e
ef   f   d e
d!e
d"edef
d#Zde	e
e	e
ef   f   d e
d!e
defd$Zde	e
ef   fd%Zyc c}} w )'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                   ,    e Zd ZU eed<   eed<   eed<   y)FeatureFlagInfotypedefaultdescriptionN)__name__
__module____qualname__str__annotations__r        A/Users/danicosta/Desktop/Flux2/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                 V    | j                         }|dk(  ry|dk(  ryt        d|       )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                     t        |       S N)intr   s    r   <lambda>r"   /   s    SVr   c                     t        |       S r   )floatr!   s    r   r"   r"   0   s    uQxr   )r   r    r$   _COERCE_FNSkey	raw_valuec                 |    t         j                  |       }||S t        j                  |d         }||S  ||      S )a9  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                     i } t        t        dg       D ]L  }|j                  d      \  }}}|j                         }|s+|sd}	 t	        ||j                               | |<   N | S # t
        t        f$ rW}t        j                  |i       }t        j                  d||j                         |j                  dd      |       Y d}~d}~ww xY w)aM  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S)iikI	,S)//2CDF3K 2 M I& 	,00b9DOORY__&(=q 	s   A%%C4A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                 X    || vr|S | |   j                  di       j                  ||      S )aM  
    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)   )rE   rF   rG   r	   s       r   get_connection_featurerJ   n   s7    $ ""C $$_b9==lGTTr   c                 "    t        | ||d      du S )a  
    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)rJ   )rE   rF   rG   s      r   supports_featurerL      s      ""2CuMQUUUr   c                  *    t         j                         S )zb
    Get the server's feature flags.

    Returns:
        Dictionary of server feature flags
    )rD   copyr   r   r   get_server_featuresrO      s      $$&&r   )F)__doc__r5   typingr   r   comfy.cli_argsr   r   r   dictr   r   r   r   r%   r,   r;   r?   enable_assetsrC   items
_cli_flagsrD   rJ   rL   rO   )kr   s   00r   <module>rX      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Atq!QNaEaad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7D