Ë
    ³Œjy9  ã                  óX  — d Z ddlmZ ddlmZ ddlmZmZmZm	Z	 ddl
mZ ddlmZmZmZ  G d„ ded	¬
«      Z G d„ ded	¬
«      Z G d„ de«      Z G d„ ded	¬
«      Z G d„ de«      Z G d„ de«      Z G d„ ded	¬
«      Z G d„ de«      Z G d„ de«      Z G d„ de«      Z G d„ ded	¬
«      Z G d„ d e«      Z G d!„ d"e«      Z G d#„ d$ed	¬
«      Z G d%„ d&e«      Ze	eeeef   Z G d'„ d(e«      Z  G d)„ d*e«      Z! G d+„ d,ed	¬
«      Z"eZ# G d-„ d.e«      Z$dGd/„Z%dHd0„Z&dId1„Z'dJd2„Z(dKd3„Z)d4d5d6d	d5d5d7œ	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dLd8„Z*d5d5d9œ	 	 	 	 	 	 	 	 	 	 	 dMd:„Z+d5d5d5d;œ	 	 	 	 	 	 	 	 	 	 	 	 	 dNd<„Z,d5d=œ	 	 	 	 	 	 	 	 	 dOd>„Z-dPd?„Z.h d@£Z/dQdA„Z0	 	 	 	 dRdB„Z1dCdDœ	 	 	 	 	 dSdE„Z2	 	 	 	 	 	 dTdF„Z3y5)Uz>Helpers and type definitions for sandbox mount configurations.é    )Úannotations)ÚSequence)ÚAnyÚLiteralÚ	TypedDictÚUnion)Úurlsplit)ÚSandboxProxyConfigÚSandboxProxyRuleÚSandboxProxySecretc                  ó&   — e Zd ZU dZded<   ded<   y)ÚMountCacheConfigzBOptional per-mount cache configuration supported by bucket mounts.ÚintÚmax_size_bytesÚwriteback_secondsN©Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú__annotations__© ó    úc/var/www/html/Fitness-lenito-AI-main/venv/lib/python3.12/site-packages/langsmith/sandbox/_mounts.pyr   r      s   … ÙLàÓØÔr   r   F)Útotalc                  ó&   — e Zd ZU dZded<   ded<   y)ÚBucketMountSpecBasez8Optional fields applied per bucket-backed sandbox mount.ÚboolÚ	read_onlyr   ÚcacheNr   r   r   r   r   r      s   … ÙBàƒOØÔr   r   c                  ó0   — e Zd ZU dZded<   ded<   ded<   y)ÚS3MountConfigRequiredz.Required S3 configuration for a sandbox mount.ÚstrÚendpoint_urlÚregionÚbucketNr   r   r   r   r"   r"      s   … Ù8àÓØƒKØ„Kr   r"   c                  ó&   — e Zd ZU dZded<   ded<   y)ÚS3MountConfigz%S3 configuration for a sandbox mount.r#   Úprefixr   Ú
path_styleNr   r   r   r   r(   r(   &   s   … Ù/àƒKØÔr   r(   c                  ó:   — e Zd ZU dZded<   ded<   ded<   ded<   y	)
ÚS3MountSpecz&S3-backed sandbox mount specification.r#   ÚidzLiteral['s3']ÚtypeÚ
mount_pathr(   Ús3Nr   r   r   r   r,   r,   -   s   … Ù0àƒGØ
ÓØƒOØÔr   r,   c                  ó   — e Zd ZU dZded<   y)ÚGCSMountConfigRequiredz/Required GCS configuration for a sandbox mount.r#   r&   Nr   r   r   r   r2   r2   6   s
   … Ù9à„Kr   r2   c                  ó   — e Zd ZU dZded<   y)ÚGCSMountConfigz&GCS configuration for a sandbox mount.r#   r)   Nr   r   r   r   r4   r4   <   s
   … Ù0à„Kr   r4   c                  ó:   — e Zd ZU dZded<   ded<   ded<   ded<   y	)
ÚGCSMountSpecz'GCS-backed sandbox mount specification.r#   r-   zLiteral['gcs']r.   r/   r4   ÚgcsNr   r   r   r   r6   r6   B   ó   … Ù1àƒGØ
ÓØƒOØ	Ôr   r6   c                  ó&   — e Zd ZU dZded<   ded<   y)ÚGitMountRefSpecz%Git ref selected for a sandbox mount.zLiteral['branch', 'tag']r.   r#   ÚnameNr   r   r   r   r:   r:   K   s   … Ù/à
"Ó"Ø
„Ir   r:   c                  ó   — e Zd ZU dZded<   y)ÚGitMountConfigRequiredz/Required Git configuration for a sandbox mount.r#   Ú
remote_urlNr   r   r   r   r=   r=   R   s
   … Ù9à„Or   r=   c                  ó&   — e Zd ZU dZded<   ded<   y)ÚGitMountConfigz&Git configuration for a sandbox mount.r:   Úrefr   Úrefresh_interval_secondsNr   r   r   r   r@   r@   X   s   … Ù0à	ÓØ!Ô!r   r@   c                  ó:   — e Zd ZU dZded<   ded<   ded<   ded<   y	)
ÚGitMountSpecz'Git-backed sandbox mount specification.r#   r-   zLiteral['git']r.   r/   r@   ÚgitNr   r   r   r   rD   rD   _   r8   r   rD   c                  ó   — e Zd ZU dZded<   y)ÚContextHubMountConfigRequiredz7Required Context Hub configuration for a sandbox mount.r#   ÚrepoNr   r   r   r   rG   rG   h   s
   … ÙAà
„Ir   rG   c                  ó   — e Zd ZU dZded<   y)ÚContextHubMountConfigz.Context Hub configuration for a sandbox mount.r   Úinitial_pull_onlyNr   r   r   r   rJ   rJ   n   s   … Ù8àÔr   rJ   c                  ó:   — e Zd ZU dZded<   ded<   ded<   ded<   y	)
ÚContextHubMountSpecz9Read-only Context Hub-backed sandbox mount specification.r#   r-   zLiteral['contexthub']r.   r/   rJ   Ú
contexthubNr   r   r   r   rM   rM   t   s   … ÙCàƒGØ
ÓØƒOØ%Ô%r   rM   c                  ó&   — e Zd ZU dZded<   ded<   y)ÚAWSMountAuthConfigz>AWS credentials used by the backend to authenticate S3 mounts.r   Úaccess_key_idÚsecret_access_keyNr   r   r   r   rP   rP   €   s   … ÙHà%Ó%Ø)Ô)r   rP   c                  ó   — e Zd ZU dZded<   y)ÚGCPMountAuthConfigz?GCP credentials used by the backend to authenticate GCS mounts.r   Úservice_account_jsonNr   r   r   r   rT   rT   ‡   s   … ÙIà,Ô,r   rT   c                  ó&   — e Zd ZU dZded<   ded<   y)ÚSandboxMountAuthConfigz(Provider auth blocks for sandbox mounts.rP   ÚawsrT   ÚgcpNr   r   r   r   rW   rW   �   s   … Ù2à	ÓØ	Ôr   rW   c                  ó&   — e Zd ZU dZded<   ded<   y)ÚSandboxMountConfigz,Public mount config sent to the sandbox API.rW   Úauthúlist[SandboxMount]ÚmountsNr   r   r   r   r[   r[   —   s   … Ù6à
 Ó ØÔr   r[   c                ó~   — t        | t        «      r| j                  «       st        |› d�«      ‚| j                  «       S )Nz must be a non-empty string)Ú
isinstancer#   ÚstripÚ
ValueError)ÚvalueÚfields     r   Ú_require_non_empty_stringre   ž   s3   € Ü�eœSÔ!¨¯©¬Ü˜E˜7Ð"=Ð>Ó?Ð?Ø�;‰;‹=Ðr   c                ó:   — i }d| v r| d   |d<   d| v r| d   |d<   |S )Nr   r   r   )r    Úcopieds     r   Ú_copy_cache_configrh   ¤   s>   € Ø!€FØ˜5Ñ Ø#(Ð)9Ñ#:ˆÐÑ Ø˜eÑ#Ø&+Ð,?Ñ&@ˆÐ"Ñ#Ø€Mr   c                ó  — t        | t        «      st        |› d�«      ‚| j                  d«      }|dvrt        |› d�«      ‚| j                  d«      }t        |t        «      r|j                  «       st        |› d�«      ‚||dœS )Nz must be a sandbox secretr.   >   ÚopaqueÚworkspace_secretz$ must use workspace_secret or opaquerc   z!.value must be a non-empty string)r.   rc   )r`   Údictrb   Úgetr#   ra   )Úsecretrd   Úsecret_typerc   s       r   Ú_copy_mount_secretrp   ­   s‡   € Ü�fœdÔ#Ü˜E˜7Ð";Ð<Ó=Ð=Ø—*‘*˜VÓ$€KØÐ8Ñ8Ü˜E˜7Ð"FÐGÓHÐHØ�J‰J�wÓ€EÜ�eœSÔ!¨¯©¬Ü˜E˜7Ð"CÐDÓEÐEØ¨%Ñ0Ð0r   c                óà  — t        | t        «      r| dk(  rt        d«      ‚| | j                  «       k7  st	        d„ | D «       «      rt        d«      ‚t        | «      }|j                  dk7  s|j                  st        d«      ‚|j                  s|j                  rt        d«      ‚|j                  r|j                  dk(  rt        d	«      ‚|j                  s|j                  rt        d
«      ‚| S )NÚ z%remote_url must be a non-empty stringc              3  óJ   K  — | ]  }|j                  «       xs |d k(  –— Œ y­w)Ú N)Úisspace)Ú.0Úchars     r   Ú	<genexpr>z*_require_git_remote_url.<locals>.<genexpr>¼   s&   è ø€ ð /Ù5?¨Tˆ�‰‹Ò(˜$ &™.Ó(±Zùs   ‚!#z3remote_url must not contain whitespace or NUL bytesÚhttpsz(remote_url must be an absolute HTTPS URLz0remote_url must not include embedded credentialsÚ/z)remote_url must include a repository pathz-remote_url must not include query or fragment)r`   r#   rb   ra   Úanyr	   ÚschemeÚnetlocÚusernameÚpasswordÚpathÚqueryÚfragment)r>   Úparseds     r   Ú_require_git_remote_urlr„   ¹   sÐ   € Ü�j¤#Ô&¨*¸Ò*:ÜÐ@ÓAÐAØ�Z×%Ñ%Ó'Ò'¬3ñ /Ù5?ó/ô ,ô ÐNÓOÐOä�jÓ!€FØ‡}�}˜Ò v§}¢}ÜÐCÓDÐDØ‡‚˜&Ÿ/š/ÜÐKÓLÐLØ�;Š;˜&Ÿ+™+¨Ò,ÜÐDÓEÐEØ‡|‚|�v—’ÜÐHÓIÐIØÐr   c                ó¶   — t        | t        «      st        d«      ‚| j                  d«      }|dvrt        d«      ‚|t	        | j                  dd«      d«      dœS )	Nzref must be a dictionaryr.   >   ÚtagÚbranchzref.type must be branch or tagr;   rr   zref.name)r.   r;   )r`   rl   rb   rm   re   )rA   Úref_types     r   Ú_copy_git_refr‰   Í   s\   € Ü�cœ4Ô ÜÐ3Ó4Ð4Ø�w‰w�v‹€HØÐ(Ñ(ÜÐ9Ó:Ð:àÜ)¨#¯'©'°&¸"Ó*=¸zÓJñð r   z	us-east-1Nzhttps://s3.amazonaws.com)r%   r)   r$   r*   r   r    c        	        óÖ   — t        |d«      t        |d«      t        |d«      |dœ}	|�t        |d«      |	d<   t        | d«      dt        |d«      |	d	œ}
|�||
d
<   |�t        |«      |
d<   |
S )z/Build an S3-backed sandbox mount specification.r$   r%   r&   )r$   r%   r&   r*   r)   r-   r0   r/   )r-   r.   r/   r0   r   r    ©re   rh   )r-   r/   r&   r%   r)   r$   r*   r   r    r0   Úmounts              r   Ús3_mountr�   Ù   s’   € ô 2°,ÀÓOÜ+¨F°HÓ=Ü+¨F°HÓ=Ø ñ	€Bð ÐÜ0°¸ÓBˆˆ8‰ô (¨¨DÓ1ØÜ/°
¸LÓIØñ	€Eð ÐØ&ˆˆkÑØÐÜ+¨EÓ2ˆˆg‰Ø€Lr   )rA   rB   c                ó    — dt        |«      i}|�t        |«      |d<   |�|dk  rt        d«      ‚||d<   t        | d«      dt        |d«      |d	œS )
z6Build a public Git-backed sandbox mount specification.r>   rA   é   z+refresh_interval_seconds must be at least 1rB   r-   rE   r/   )r-   r.   r/   rE   )r„   r‰   rb   re   )r-   r/   r>   rA   rB   rE   s         r   Ú	git_mountr�   ü   sv   € ð 	Ô-¨jÓ9ð€Cð €Ü" 3Ó'ˆˆE‰
ØÐ+Ø# aÒ'ÜÐJÓKÐKØ*BˆÐ&Ñ'ô (¨¨DÓ1ØÜ/°
¸LÓIØñ	ð r   )r)   r   r    c                ó¨   — dt        |d«      i}|�t        |d«      |d<   t        | d«      dt        |d«      |dœ}|�||d<   |�t        |«      |d<   |S )	z/Build a GCS-backed sandbox mount specification.r&   r)   r-   r7   r/   )r-   r.   r/   r7   r   r    r‹   )r-   r/   r&   r)   r   r    r7   rŒ   s           r   Ú	gcs_mountr’     s~   € ð 	Ô+¨F°HÓ=ð€Cð ÐÜ1°&¸(ÓCˆˆH‰ô (¨¨DÓ1ØÜ/°
¸LÓIØñ	€Eð ÐØ&ˆˆkÑØÐÜ+¨EÓ2ˆˆg‰Ø€Lr   )rK   c                óf   — dt        |d«      i}|�||d<   t        | d«      dt        |d«      |dœ}|S )aw  Build a read-only Context Hub-backed sandbox mount specification.

    The repo's latest commit tree is mirrored into ``mount_path`` and kept in
    sync for the sandbox's lifetime unless ``initial_pull_only`` is set. The
    sync is one-way: files written under ``mount_path`` inside the sandbox are
    never pushed back to the repo, and the next sync overwrites them.
    rH   rK   r-   rN   r/   )r-   r.   r/   rN   )re   )r-   r/   rH   rK   rN   rŒ   s         r   Úcontext_hub_mountr”   4  sU   € ð 	Ô)¨$°Ó7ð)€Jð Ð$Ø*;ˆ
Ð&Ñ'ô (¨¨DÓ1ØÜ/°
¸LÓIØ ñ	"€Eð €Lr   c                ó$  — t        | t        «      st        | t        «      s| st        d«      ‚g }| D ][  }t        |t        «      r|st        d«      ‚|j	                  d«      }|dvrt        d«      ‚t        |«       |j                  |«       Œ] |S )Nz5mounts must be a non-empty list of mount dictionariesr.   >   r0   r7   rE   rN   z>mount_config only supports s3, gcs, git, and contexthub mounts)r`   rl   r#   rb   rm   Ú%_reject_provider_credentials_in_mountÚappend)r^   Ú
normalizedrŒ   Ú
mount_types       r   Ú_normalize_mountsrš   Q  s‘   € Ü�&œ$Ô¤:¨f´cÔ#:Á&ÜÐPÓQÐQØ%'€JÛˆÜ˜%¤Ô&©eÜÐTÓUÐUØ—Y‘Y˜vÓ&ˆ
ØÐ?Ñ?ÜØPóð ô 	.¨eÔ4Ø×Ñ˜%Õ ð ð Ðr   >   Ú
credentialÚcredentialsÚaccess_tokenrQ   Úrefresh_tokenÚsession_tokenrR   rU   c                óØ   — t        | t        «      r7| j                  «       D ]#  \  }}|t        v rt	        d«      ‚t        |«       Œ% y t        | t        «      r| D ]  }t        |«       Œ y y )NzVprovider credentials must be supplied in mount_config.auth, not individual mount specs)r`   rl   ÚitemsÚ"_FORBIDDEN_MOUNT_CREDENTIAL_FIELDSrb   r–   Úlist)rc   ÚkeyÚchilds      r   r–   r–   n  sh   € Ü�%œÔØŸ+™+ž-‰JˆC�ØÔ8Ñ8Ü ð1óð ô 2°%Õ8ñ (ô 
�Eœ4Ô	 ÛˆEÜ1°%Õ8ñ ð 
!r   c                ó‚  — t        | t        «      st        | t        «      rt        d«      ‚i }| D �]  }t        |t        «      r|st        d«      ‚|j	                  d«      }|dvrt        d«      ‚||v rt        d|› d�«      ‚|dk(  rg|j	                  d«      }t        |t        «      st        d«      ‚t        |j	                  d	«      d	«      t        |j	                  d
«      d
«      dœ|d<   ŒÀ|j	                  d«      }t        |t        «      st        d«      ‚dt        |j	                  d«      d«      i|d<   �Œ |S )Nz+auth must be a list of provider auth blocksr.   ¾   rX   rY   z2mount_config auth only supports aws and gcp blocksz
duplicate z auth rule in mount_configrX   z(aws mount auth must include an aws blockrQ   rR   )rQ   rR   rY   z'gcp mount auth must include a gcp blockrU   )r`   rl   r#   rb   rm   rp   )r\   Úby_providerÚblockÚproviderrX   rY   s         r   Ú_normalize_mount_authr«   |  sF  € ô �$œÔ¤¨D´#Ô!6ÜÐFÓGÐGØ*,€KÜˆÜ˜%¤Ô&©eÜÐJÓKÐKØ—9‘9˜VÓ$ˆØ˜>Ñ)ÜÐQÓRÐRØ�{Ñ"Ü˜z¨(¨Ð3MÐNÓOÐOØ�uÒØ—)‘)˜EÓ"ˆCÜ˜c¤4Ô(Ü Ð!KÓLÐLä!3Ø—G‘G˜OÓ,¨oó"ô &8Ø—G‘GÐ/Ó0Ð2Eó&ñ	"ˆK˜Òð —)‘)˜EÓ"ˆCÜ˜c¤4Ô(Ü Ð!JÓKÐKà&Ô(:Ø—G‘GÐ2Ó3Ð5Kó)ð"ˆK˜Óð1 ð: Ðr   r   )r\   c                óþ   — t        | «      }t        |«      }|D �ch c]  }|d   ’Œ	 }}d|v rd|vrt        d«      ‚d|v rd|vrt        d«      ‚d|v rd|vrt        d«      ‚d|v rd|vrt        d	«      ‚||d
œS c c}w )zÎBuild a high-level mount config from provider auth and mount specs.

    The returned value is sent as the public ``mount_config`` field. The
    backend expands provider auth into runtime proxy rules.
    r.   r0   rX   z*s3 mounts require aws auth in mount_configr7   rY   z+gcs mounts require gcp auth in mount_configz7aws auth requires at least one s3 mount in mount_configz8gcp auth requires at least one gcs mount in mount_config)r\   r^   )rš   r«   rb   )r^   r\   Únormalized_mountsÚauth_by_providerrŒ   Úmount_providerss         r   Úmount_configr°   ¢  s¼   € ô *¨&Ó1ÐÜ,¨TÓ2ÐÙ2CÓDÑ2C¨�u˜V“}Ð2C€OÐDàˆÑ 5Ð0@Ñ#@ÜÐEÓFÐFØ�Ñ EÐ1AÑ$AÜÐFÓGÐGØÐ Ñ  T°Ñ%@ÜÐRÓSÐSØÐ Ñ  U°/Ñ%AÜÐSÓTÐTð !Ø#ñð ùò Es   ›A:c                ó  — |€y| j                  di «      }|j                  dg «      }t        |t        «      st        d«      ‚|D ];  }t        |t        «      sŒ|j                  d«      }|dv sŒ*||v sŒ/t        |› d�«      ‚ y)z@Reject explicit provider proxy rules owned by mount_config auth.Nr\   Úrulesz!proxy_config rules must be a listr.   r§   z> auth cannot be provided in both mount_config and proxy_config)rm   r`   r£   rb   rl   )r°   Úproxy_configr\   r²   ÚruleÚ	rule_types         r   Ú"validate_mount_config_proxy_configr¶   ¿  s—   € ð
 ÐØØ×Ñ˜F BÓ'€DØ×Ñ˜W bÓ)€EÜ�eœTÔ"ÜÐ<Ó=Ð=ÛˆÜ˜$¤Ô%ØØ—H‘H˜VÓ$ˆ	Ø˜Ò&¨9¸Ò+<ÜØ�+ð 0ð 0óð ñ r   )rc   r#   rd   r#   Úreturnr#   )r    r   r·   r   )rn   r   rd   r#   r·   r   )r>   r#   r·   r#   )rA   r:   r·   r:   )r-   r#   r/   r#   r&   r#   r%   r#   r)   ú
str | Noner$   r#   r*   r   r   úbool | Noner    úMountCacheConfig | Noner·   r,   )r-   r#   r/   r#   r>   r#   rA   zGitMountRefSpec | NonerB   z
int | Noner·   rD   )r-   r#   r/   r#   r&   r#   r)   r¸   r   r¹   r    rº   r·   r6   )
r-   r#   r/   r#   rH   r#   rK   r¹   r·   rM   )r^   úSequence[SandboxMount]r·   r]   )rc   r   r·   ÚNone)r\   úSequence[SandboxMountAuth]r·   rW   )r^   r»   r\   r½   r·   r[   )r°   r[   r³   zSandboxProxyConfig | Noner·   r¼   )4r   Ú
__future__r   Úcollections.abcr   Útypingr   r   r   r   Úurllib.parser	   Úlangsmith.sandbox._proxy_configr
   r   r   r   r   r"   r(   r,   r2   r4   r6   r:   r=   r@   rD   rG   rJ   rM   ÚSandboxMountrP   rT   rW   ÚSandboxMountAuthr[   re   rh   rp   r„   r‰   r�   r�   r’   r”   rš   r¢   r–   r«   r°   r¶   r   r   r   Ú<module>rÅ      s  ðÙ Då "å $ß 1Ó 1Ý !÷ñ ô�y¨õ ô˜)¨5õ ô˜Iô ôÐ)°õ ôÐ%ô ô˜Yô ôÐ+°5õ ôÐ&ô ô�iô ô˜Yô ô"Ð+°5õ "ô�9ô ô Iô ôÐ9Àõ ô&˜)ô &ð �[ ,°Ð>QÐQÑR€ô*˜ô *ô-˜ô -ô˜Y¨eõ ð $Ð ô˜ô óóó	1óó(	ð" ØØ2ØØ!Ø%)ñ àð ð ð ð ð	 ð
 ð ð ð ð ð ð ð ð ð ð #ð ð ó ðP #'Ø+/ñàðð ðð ð	ð
 
 ðð )ðð óð@ Ø!Ø%)ñàðð ðð ð	ð
 ðð ðð #ðð óðD &*ñàðð ðð ð	ð
 #ðð óó:ò"	&Ð "ó9ð#Ø
$ð#àó#ðR (*ñà"ðð %ðð ó	ð:Ø$ðà+ðð 
ôr   