Ë
    tPêjŸ  ã            	       ój  — U d dl Z d dlZd dlZd dlmZmZ d dlmZ d dlm	Z	 d dl
mZ d dlmZ d dlZd dlmZ d dlmZmZ d	Zeed
<    eeeef   «      Zeeeeef         ed<   defd„Zdeeef   fd„Zdeeef   ddfd„Zdededz  fd„Zdedz  dee   fd„Zdee   fd„Zdedefd„Zdedefd„Z  e	deee i«      Z!eeeeegef   f      ed<    e"e!«      Z#ee"edf      ed<    ejH                  d¬«      d'd„«       Z%e%jM                  d¬«       ejN                  d«       ejN                  d«      dededdfd „«       «       «       Z(e%jM                  d!¬«       ejN                  dd"¬#«      dedz  ddfd$„«       «       Z)e%jM                  d%¬«       ejN                  d«      deddfd&„«       «       Z*y)(é    N)ÚCallableÚMapping)ÚPath)ÚMappingProxyType)ÚFinal)Úurlparse)ÚTypeAdapter)Úensure_private_dirÚwrite_private_jsonÚhidden_commandsÚHIDDEN_COMMANDS_KEYÚ_config_adapterÚreturnc                  óP   — t        j                  «       } | dz  }t        |dz  «      S )z.Get the path to the persistent CLI config filez.litellmzconfig.json)r   ÚhomeÚstr)Úhome_dirÚ
config_dirs     úm/home/oem/CyberBrain26-unified/.venv/lib/python3.12/site-packages/litellm/proxy/client/cli/commands/config.pyÚget_config_file_pathr      s'   € ä—i‘i“k€HØ  :Ñ-€JÜˆz˜MÑ)Ó*Ð*ó    c                  óˆ  — 	 t        «       } t        j                  j	                  | «      si S 	 t        | d«      5 }t        j                  t        j                  |«      «      cddd«       S # t        $ r i cY S w xY w# 1 sw Y   yxY w# t        t        f$ r)}t        j                  d| › d|› �d¬«       i cY d}~S d}~ww xY w)z>Load CLI config from file; returns {} if missing or unreadableÚrNz&Warning: ignoring invalid config file z: T©Úerr)r   ÚRuntimeErrorÚosÚpathÚexistsÚopenr   Úvalidate_pythonÚjsonÚloadÚOSErrorÚ
ValueErrorÚclickÚecho)Úconfig_fileÚfÚes      r   Úload_configr+      s¸   € ðÜ1Ó3ˆô �7‰7�>‰>˜+Ô&Øˆ	ðÜ�+˜sÓ#ð 	A qÜ"×2Ñ2´4·9±9¸Q³<Ó@÷	Añ 	Aøô ò ØŠ	ðú÷
	Að 	Aûä”ZÐ ò Ü�
‰
Ð;¸K¸=ÈÈ1È#ÐNÐTXÕYØ�	ûðúsK   ‚
A, ®B	 º(A=Á"	B	 Á,A:Á9A:Á=BÂB	 ÂB	 Â	CÂB<Â6CÂ<CÚconfigc                 ó~   — t        t        «       «      }t        |j                  «       t	        t        |«      | «       y)zSave CLI config to fileN)r   r   r
   Úparentr   r   )r,   r(   s     r   Úsave_configr/   +   s-   € äÔ2Ó4Ó5€KÜ�{×)Ñ)Ô*Ü”s˜;Ó'¨Õ0r   Úkeyc                 ó4   — t        «       j                  | «      S )z1Get a single value from the persistent CLI config)r+   Úget)r0   s    r   Úget_config_valuer3   2   s   € ä‹=×Ñ˜SÓ!Ð!r   Úrawc                 óL   — t        d„ | xs dj                  d«      D «       «      S )z?Split a stored `hidden_commands` value, e.g. "codex, opencode".c              3   ó^   K  — | ]%  }|j                  «       sŒ|j                  «       –— Œ' y ­w)N)Ústrip©Ú.0Únames     r   ú	<genexpr>z(parse_hidden_commands.<locals>.<genexpr>9   s   è ø€ ÒU dÈÏ
É
Í�T—Z‘Z—\ÑUùs   ‚-˜-Ú ú,)Ú	frozensetÚsplit)r4   s    r   Úparse_hidden_commandsr@   7   s"   € äÑU¨sªy°b×.?Ñ.?ÀÓ.DÔUÓUÐUr   c                  ó2   — t        t        t        «      «      S )zGTop-level commands the operator chose to keep out of `lite`'s listings.)r@   r3   r   © r   r   Úhidden_command_namesrC   <   s   € ä Ô!1Ô2EÓ!FÓGÐGr   Úvaluec                 óÒ   — t        | «      }|j                  dvs|j                  st        j                  d«      ‚d| v sd| v rt        j                  d«      ‚| j                  d«      S )N)ÚhttpÚhttpsz@base_url must be a full http:// or https:// URL including a hostú?ú#z4base_url must not include a query string or fragmentú/)r   ÚschemeÚnetlocr&   Ú
UsageErrorÚrstrip)rD   Úparseds     r   Ú_normalize_base_urlrP   A   s^   € Ü˜U“O€FØ‡}�}Ð-Ñ-°V·]²]Ü×ÑÐaÓbÐbØ
ˆe�|�s˜e‘|Ü×ÑÐUÓVÐVØ�<‰<˜ÓÐr   c                 ó   — t        | «      }|s*t        j                  t        › dt        › dt        › d�«      ‚t	        d„ |D «       «      rt        j                  t        › d�«      ‚dj                  t        |«      «      S )NzH must be a comma-separated list of command names, e.g. `lite config set zC codex,opencode`. To list everything again, run `lite config unset ú`c              3   ó$   K  — | ]  }d |v –— Œ
 y­w)ú NrB   r8   s     r   r;   z-_normalize_hidden_commands.<locals>.<genexpr>R   s   è ø€ Ò
)˜4ˆ3�$Œ;Ñ
)ùs   ‚z5 entries must be single command names, without spacesr=   )r@   r&   rM   r   ÚanyÚjoinÚsorted)rD   Únamess     r   Ú_normalize_hidden_commandsrY   J   sƒ   € Ü(¨Ó/€EÙÜ×ÑÜ"Ð#ð $ Ü 3Ð4ð 5&Ü&9Ð%:¸!ð=ó
ð 	
ô
 Ñ
) 5Ô
)Ô)Ü×ÑÔ"5Ð!6Ð6kÐlÓmÐmØ�8‰8”F˜5“MÓ"Ð"r   Úbase_urlÚ_NORMALIZERS.ÚALLOWED_CONFIG_KEYS)r:   c                   ó   — y)z<Manage persistent CLI configuration (~/.litellm/config.json)NrB   rB   r   r   Úconfig_commandsr^   a   s   � r   Úsetc           	      ó  — t         j                  | «      }|€.t        j                  d| › ddj	                  t
        «      › �«      ‚ ||«      }t        i t        «       ¥| |i¥«       t        j                  d| › d|› dt        «       › �«       y)zZSet a config KEY to VALUE (e.g. `lite config set base_url https://your-proxy.example.com`)NzUnknown config key 'z'. Allowed keys: z, zSet ú = z in )
r[   r2   r&   rM   rV   r\   r/   r+   r'   r   )r0   rD   Ú
normalizerÚnormalized_values       r   Ú
set_configrd   f   sŽ   € ô
 %×(Ñ(¨Ó-€JØÐÜ×ÑÐ!5°c°UÐ:KÈDÏIÉIÔViÓLjÐKkÐlÓmÐmá(¨Ó/ÐÜÐ8”;“=Ð8 #Ð'7Ñ8Ô9Ü	‡J�J��c�U˜#Ð.Ð/¨tÔ4HÓ4JÐ3KÐLÕMr   r2   F)Úrequiredc                 ó`  — t        «       }| �X|j                  | «      }|€/t        j                  | › d�d¬«       t	        j
                  d«       t        j                  |«       y|st        j                  d«       y|j                  «       D ]  \  }}t        j                  |› d|› �«       Œ! y)z@Print the value of KEY, or all stored config when KEY is omittedNz is not setTr   é   z(no config set)ra   )r+   r2   r&   r'   ÚsysÚexitÚitems)r0   r,   rD   Ú	entry_keyÚentry_values        r   Ú
get_configrm   t   s•   € ô  “M€Fà
€Ø—z‘z #“ˆØˆ=Ü�J‰J˜#˜˜kÐ*°Õ5Ü�H‰H�QŒKÜ�
‰
�5ÔØáÜ�
‰
Ð$Ô%Øà"(§,¡,£.ò 3Ñˆ	�;Ü�
‰
�i�[  K =Ð1Õ2ñ3r   Úunsetc                 ó
  — t        «       }| |vrt        j                  | › d�«       yt        |j	                  «       D ��ci c]  \  }}|| k7  sŒ||“Œ c}}«       t        j                  d| › dt        «       › �«       yc c}}w )zRemove KEY from the config filez was not setNzRemoved z from )r+   r&   r'   r/   rj   r   )r0   r,   ÚkÚvs       r   Úunset_configrr   Š   ss   € ô  “M€FØ
�&ÑÜ�
‰
�c�U˜,Ð'Ô(Øä &§,¡,£.×=™$˜!˜Q°A¸³H��A‘Ó=Ô>Ü	‡J�J�˜#˜˜fÔ%9Ó%;Ð$<Ð=Õ>ùó >s   Á A?
ÁA?
)r   N)+r"   r   rh   Úcollections.abcr   r   Úpathlibr   Útypesr   Útypingr   Úurllib.parser   r&   Úpydanticr	   Ú'litellm.litellm_core_utils.private_jsonr
   r   r   Ú__annotations__r   r   r   r+   r/   r3   r>   r@   rC   rP   rY   r[   Útupler\   Úgroupr^   ÚcommandÚargumentrd   rm   rr   rB   r   r   ú<module>r      st  ðÜ Û 	Û 
ß -Ý Ý "Ý Ý !ã Ý  ç Zà.Ð �UÓ .á9DÀWÈSÐRUÈXÑEVÓ9W€��{ 7¨3°¨8Ñ#4Ñ5Ñ6Ó Wð+˜có +ð�W˜S #˜XÑ&ó ð 1˜  S Ñ)ð 1¨dó 1ð"˜#ð " #¨¡*ó "ð
V˜s T™zð V¨i¸©nó Vð
H˜i¨™nó Hð
˜sð  só ð
# cð 
#¨có 
#ñ ;KàÐ'ØÐ7ðó;€ˆe�G˜C ¨3¨%°¨*Ñ!5Ð5Ñ6Ñ7ó ñ /4°LÓ.AÐ �U˜5  c ™?Ñ+Ó Að €‡��(ÔòGó ðGð ×Ñ˜eÐÓ$Ø€‡��ÓØ€‡��ÓðN�Cð N ð N¨ò Nó ó ó %ðNð ×Ñ˜eÐÓ$Ø€‡�� Ô&ð3�C˜$‘Jð 3 4ò 3ó 'ó %ð3ð( ×Ñ˜gÐÓ&Ø€‡��Óð?�cð ?˜dò ?ó ó 'ñ?r   