Ë
    ñÏj%  ã                  ó¬  — d Z ddlmZ ddlZddlmZmZ ddlmZm	Z	m
Z
mZ  G d„ de
«      Zeeef   Zeeef   Zdd„Zdd	„Zdd
„Zd d„Zd!d„Z	 	 	 	 d"d„Zd#d„Zd$d„Zddddœ	 	 	 	 	 	 	 d%d„Zedddddœ	 	 	 	 	 	 	 	 	 	 	 	 	 d&d„«       Zeddddddœ	 	 	 	 	 	 	 	 	 	 	 	 	 d'd„«       Zdddddddœ	 	 	 	 	 	 	 	 	 	 	 	 	 d(d„Zdddddœ	 	 	 	 	 	 	 	 	 	 	 d)d„Zy)*z2Helpers for building sandbox proxy configurations.é    )ÚannotationsN)ÚMappingÚSequence)ÚAnyÚLiteralÚ	TypedDictÚoverloadc                  ó&   — e Zd ZU dZded<   ded<   y)ÚSandboxProxySecretz7A secret value that can be used by sandbox proxy rules.z%Literal['workspace_secret', 'opaque']ÚtypeÚstrÚvalueN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú__annotations__© ó    ú\/var/www/html/gaurav-v2/venv/lib/python3.12/site-packages/langsmith/sandbox/_proxy_config.pyr   r   
   s   … ÙAà
/Ó/Ø„Jr   r   c                ó~   — t        | t        «      r| j                  «       st        |› d�«      ‚| j                  «       S )Nz must be a non-empty string)Ú
isinstancer   ÚstripÚ
ValueError)r   Úfields     r   Ú_require_non_empty_stringr      s3   € Ü�eœSÔ!¨¯©¬Ü˜E˜7Ð"=Ð>Ó?Ð?Ø�;‰;‹=Ðr   c                ó‚   — t        | t        «      s| st        |› d�«      ‚| D �cg c]  }t        ||«      ‘Œ }}|S c c}w )Nz$ must be a non-empty list of strings)r   r   r   r   )Úvaluesr   r   Ú
normalizeds       r   Ú_require_non_empty_string_listr       sI   € Ü�&œ#Ô¡fÜ˜E˜7Ð"FÐGÓHÐHÙGMÓNÁv¸eÔ+¨E°5Õ9Àv€JÐNØÐùò Os   ¥<c                ó²   — t        | t        «      r| st        d«      ‚i }| j                  «       D ]$  \  }}t	        |d|› d�«       ||t	        |d«      <   Œ& |S )Nz7env_vars must be a non-empty mapping of names to valuesz	env_vars[Ú]zenv_vars name)r   r   r   Úitemsr   )Úenv_varsÚresolvedÚnamer   s       r   Ú_require_env_varsr'   "   s`   € Ü�h¤Ô(±ÜÐRÓSÐSØ!€HØ—~‘~Ö'‰ˆˆeä! %¨9°T°F¸!Ð)<Ô=ØEJˆÔ*¨4°ÓAÒBð (ð €Or   c                óÜ   — t        | d«      }|j                  d«      }|j                  d«      }||k7  rt        d«      ‚|r|dd j	                  «       st        d«      ‚|r|nd|› d�}d|d	œS )
a"  Create a LangSmith workspace secret reference for a proxy configuration.

    Args:
        name: Workspace secret name, with or without surrounding braces.

    Returns:
        A proxy secret reference such as
        ``{"type": "workspace_secret", "value": "{AWS_ACCESS_KEY_ID}"}``.
    r&   Ú{Ú}z5workspace secret must be a name or a {NAME} referenceé   éÿÿÿÿz.workspace secret reference must contain a nameÚworkspace_secret©r   r   )r   Ú
startswithÚendswithr   r   )r&   r   ÚstartsÚendsr   s        r   r-   r-   -   s�   € ô +¨4°Ó8€JØ×"Ñ" 3Ó'€FØ×Ñ˜sÓ#€DØ�‚~ÜÐPÓQÐQÙ�j  2Ð&×,Ñ,Ô.ÜÐIÓJÐJÙ ‰J¨¨:¨,°bÐ&9€EØ&°Ñ7Ð7r   c                ó    — dt        | d«      dœS )záProvide a write-only secret value for a proxy configuration.

    The value is sent when creating or updating the sandbox proxy config, but
    LangSmith stores it as an opaque secret and does not return it from the API.
    Úopaquer   r.   )r   )r   s    r   Úopaque_secretr5   B   s   € ð Ô'@ÀÈÓ'PÑQÐQr   c                óè   — | €g S t        | t        «      st        | t        «      rt        d«      ‚g }| D ];  }t        |t        «      r|st        d«      ‚t	        |«       |j                  |«       Œ= |S )Nz/rules must be a list of proxy rule dictionaries)r   Údictr   r   Ú_validate_proxy_provider_ruleÚappend)Úrulesr   Úrules      r   Ú_normalize_proxy_rulesr<   K   sr   € ð €}Øˆ	Ü�%œÔ¤*¨U´CÔ"8ÜÐJÓKÐKØ)+€JÛˆÜ˜$¤Ô%©TÜÐNÓOÐOÜ% dÔ+Ø×Ñ˜$Õð	 ð
 Ðr   c                ó.  — | j                  d«      dk(  r-| j                  d«      }t        |t        «      rt        |«       y | j                  d«      dk7  ry | j                  d«      }t        |t        «      rd|vrt	        d«      ‚t        |d   d«       y )Nr   ÚawsÚgcpÚscopesz#gcp proxy auth rules require scopes)Úgetr   r7   Ú_get_aws_role_arnr   r    )r;   r>   r?   s      r   r8   r8   [   s�   € Ø‡x�x�Ó˜5Ò Ø�h‰h�u‹oˆÜ�cœ4Ô Ü˜cÔ"ØØ‡x�x�Ó˜5Ò ØØ
�(‰(�5‹/€CÜ�cœ4Ô  H°CÑ$7ÜÐ>Ó?Ð?Ü" 3 x¡=°(Õ;r   r>   c                ór   — d| vs| d   dk(  ryt        | d   d«      }t        | «      dhk7  rt        d«      ‚|S )zGValidate role-only descriptors without tightening legacy static inputs.Úrole_arnÚ Nz(AWS role auth must contain only role_arn)r   Úsetr   )r>   rD   s     r   rB   rB   i   sG   € à˜Ñ  J¡°2Ò 5ØÜ(¨¨Z©¸*ÓE€HÜ
ˆ3ƒx�J�<ÒÜÐCÓDÐDØ€Or   )r:   Úno_proxyÚaccess_controlc                ó²   — |�t        j                  dt        d¬«       dt        | «      i}|�)t	        |t
        «      st        d«      ‚t        |«      |d<   |S )aN  Build a sandbox proxy config from one or more proxy rules.

    Use provider-specific rule helpers such as ``aws_auth`` and ``gcp_auth``
    when a sandbox needs multiple auth flows.

    Args:
        no_proxy: Deprecated and ignored. The sandbox runtime intercepts
            egress transparently and has no proxy bypass list.
    zPno_proxy is deprecated and ignored; the sandbox runtime has no proxy bypass listé   )Ú
stacklevelr:   z#access_control must be a dictionaryrH   )ÚwarningsÚwarnÚDeprecationWarningr<   r   r7   r   )r:   rG   rH   Úconfigs       r   Úproxy_configrP   s   sd   € ð ÐÜ�‰ð äØõ		
ð #*Ô+AÀ%Ó+HÐ!I€FØÐ!Ü˜.¬$Ô/ÜÐBÓCÐCÜ#'¨Ó#7ˆÐÑ Ø€Mr   T)rD   r&   Úenabledr$   c                 ó   — y ©Nr   ©Úaccess_key_idÚsecret_access_keyrD   r&   rQ   r$   s         r   Úaws_authrW   ‘   ó   € ð r   )rU   rV   r&   rQ   r$   c                 ó   — y rS   r   )rD   rU   rV   r&   rQ   r$   s         r   rW   rW   �   rX   r   rT   c                óÆ   — t        |d«      }i }|�||d<   | �| |d<   |�||d<   t        |«      }|�d|i}n| �|€t        d«      ‚| |dœ}|d||dœ}	|�t        |«      |	d	<   |	S )
a  Build a sandbox proxy rule that signs AWS HTTPS requests.

    The sandbox proxy keeps the real AWS credentials outside the sandbox and
    signs supported AWS requests with SigV4 on the sandbox's behalf.
    Provide either ``role_arn`` or both static credentials, supplied as
    ``workspace_secret`` or ``opaque`` values. IAM-role support must be enabled
    on the backend. LangSmith supplies the workspace External ID and renews
    credentials; clients must not provide temporary credentials or External IDs.

    In ``proxy_config``, a role uses its effective IAM permissions. In
    ``mount_config(auth=[...])``, it is restricted to the configured S3 mounts.
    Role authentication is configured at sandbox creation, not through updates.

    Args:
        env_vars: Plaintext environment variables set for every command in the
            sandbox while this rule is enabled, for tools that refuse to run
            unless a credential variable is present even though the proxy
            injects the real credential on the wire.
    r&   rD   rU   rV   z5AWS auth requires role_arn or both static credentials)rU   rV   r>   )r&   r   rQ   r>   r$   )r   rB   r   r'   )
rU   rV   rD   r&   rQ   r$   Ú	rule_namer>   Únormalized_roler;   s
             r   rW   rW   ©   sµ   € ô8 *¨$°Ó7€IØ€CØÐØ"ˆˆJ‰ØÐ Ø,ˆˆOÑØÐ$Ø#4ˆÐÑ Ü'¨Ó,€OØÐ"Ø˜?Ð+‰àÐ Ð$5Ð$=ÜÐTÓUÐUà*Ø!2ñ
ˆð
 ØØØñ	€Dð ÐÜ,¨XÓ6ˆˆZÑØ€Kr   r?   )r@   r&   rQ   r$   c                óv   — t        |d«      }d| i}|�t        |d«      |d<   |d||dœ}|�t        |«      |d<   |S )a¢  Build a sandbox proxy rule that injects GCP OAuth bearer auth.

    The sandbox proxy keeps the service account JSON outside the sandbox and
    injects OAuth bearer tokens for built-in Google API host matching.
    ``service_account_json`` must be supplied as a ``workspace_secret`` or
    ``opaque`` value; plaintext service account JSON is intentionally not
    supported.

    Args:
        env_vars: Plaintext environment variables set for every command in the
            sandbox while this rule is enabled, for tools that refuse to run
            unless a credential variable is present even though the proxy
            injects the real credential on the wire.
    r&   Úservice_account_jsonr@   r?   )r&   r   rQ   r?   r$   )r   r    r'   )r^   r@   r&   rQ   r$   r[   Ú
gcp_configr;   s           r   Úgcp_authr`   â   se   € ô, *¨$°Ó7€IàÐ 4ð"€Jð ÐÜ=¸fÀhÓOˆ
�8ÑàØØØñ	€Dð ÐÜ,¨XÓ6ˆˆZÑØ€Kr   )r   r   r   r   Úreturnr   )r   zSequence[str]r   r   ra   z	list[str])r$   zMapping[str, str]ra   zdict[str, str])r&   r   ra   r   )r   r   ra   r   )r:   ú!Sequence[SandboxProxyRule] | Nonera   zlist[SandboxProxyRule])r;   ÚSandboxProxyRulera   ÚNone)r>   zdict[str, Any]ra   ú
str | None)r:   rb   rG   úSequence[str] | NonerH   zdict[str, Any] | Nonera   ÚSandboxProxyConfig)rU   r   rV   r   rD   zLiteral[''] | Noner&   r   rQ   Úboolr$   úMapping[str, str] | Nonera   rc   )rD   r   rU   rd   rV   rd   r&   r   rQ   rh   r$   ri   ra   rc   )rU   úSandboxProxySecret | NonerV   rj   rD   re   r&   r   rQ   rh   r$   ri   ra   rc   )r^   r   r@   rf   r&   r   rQ   rh   r$   ri   ra   rc   )r   Ú
__future__r   rL   Úcollections.abcr   r   Útypingr   r   r   r	   r   r7   r   rc   rg   r   r    r'   r-   r5   r<   r8   rB   rP   rW   r`   r   r   r   Ú<module>rn      s*  ðÙ 8å "ã ß -ß 4Ó 4ô˜ô ð ˜˜S˜‘>Ð Ø˜#˜s˜(‘^Ð óóóó8ó*RðØ,ðàóó <óð 04Ø%)Ø,0ñ	à,ðð #ðð *ð	ð
 óð< 
ð
 $(ØØØ)-ñà%ðð *ðð !ð	ð
 ðð ðð 'ðð òó 
ðð 
ð Ø"ØØØ)-ñàðð ðð ð	ð
 ðð ðð 'ðð òó 
ðð 04Ø37ØØØØ)-ñ6à,ð6ð 1ð6ð ð	6ð
 ð6ð ð6ð 'ð6ð ó6ðx $(ØØØ)-ñ$à,ð$ð !ð$ð ð	$ð
 ð$ð 'ð$ð ô$r   