ó
    °"³jÿ  ã                  ó  • S r SSKJr  SSKJrJrJrJrJr  SSK	J
r
  / SQrSr Sr Sr S	r\
S
   r SS jrSrSS jrSS jr\" SSS9r " S S\\\4   5      rSS jr  S     SS jjr  S     SS jjrS S jrg)!a]  Tracking for SDK helper usage via the x-stainless-helper header.

This module is the single source of truth for the helper-telemetry header
keys and the closed tag vocabulary. The append-don't-clobber merge for the
header itself lives in `anthropic._base_client.merge_headers`; here
we only carry the constants and the per-object tagging machinery.
é    )Úannotations)ÚAnyÚDictÚMappingÚTypeVarÚcast)ÚLiteral)ÚSTAINLESS_HELPER_HEADERÚSTAINLESS_HELPER_METHOD_HEADERÚSTAINLESS_STREAM_HELPER_HEADERÚHELPER_METHOD_STREAMÚStainlessHelperHeaderValueÚhelper_headerÚ
tag_helperÚget_helper_tagÚcarry_helper_tagÚcollect_helpersÚstainless_helper_headerÚ!stainless_helper_header_from_filezx-stainless-helperzx-stainless-helper-methodzx-stainless-stream-helperÚstream)zbeta.messages.parseÚBetaToolRunnerÚ
compactionzenvironments-work-pollerzenvironments-workerzfallback-refusal-middlewareÚmcp_contentÚmcp_messageÚmcp_resource_to_contentÚmcp_resource_to_fileÚmcp_toolzmessages.parsezsession-tool-runnerc                ó   • [         U 0$ )zÀThe `x-stainless-helper: <value>` header dict, for passing into a
`merge_headers` call or as `extra_headers`/`default_headers`.

Typing keeps the value drawn from the closed vocabulary above.
)r
   )Úvalues    Ú]/home/mande/repo/quber/.venv/lib/python3.13/site-packages/anthropic/lib/_stainless_helpers.pyr   r   I   s   € ô $ UÐ+Ð+ó    Ú_stainless_helperc                óh   •  [         R                  U [        U5        g! [        [        4 a     gf = f)z0Mark an object as created by a named SDK helper.N)ÚobjectÚ__setattr__Ú_HELPER_ATTRÚAttributeErrorÚ	TypeError)ÚobjÚnames     r    r   r   U   s0   € ðÜ×Ñ˜3¤¨dÕ3øÜœIÐ&ó Ùðús   ‚ ž1°1c                ó$   • [        U [        S5      $ )z+Get the helper name from an object, if any.N)Úgetattrr&   )r)   s    r    r   r   ]   s   € ä�3œ dÓ+Ð+r!   Ú	_MappingTzMapping[str, object])Úboundc                  ó   • \ rS rSrSrSrg)Ú_TaggedDictée   zMA plain `dict` rejects `object.__setattr__`; this subclass can carry the tag.© N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú__static_attributes__r2   r!   r    r0   r0   e   s   † ÜWr!   r0   c                óŽ   • [        U 5      nUc  U$ [        U5      n[        R                  U[        U5        [        [        U5      $ )z`Return `params` carrying `source`'s helper tag, so the tag survives serializing a tagged object.)r   r0   r$   r%   r&   r   r-   )ÚsourceÚparamsÚtagÚtaggeds       r    r   r   i   s?   € ä
˜Ó
 €CØ
�{ØˆÜ˜Ó €FÜ
×Ñ�vœ|¨SÔ1Ü”	˜6Ó"Ð"r!   Nc                óÊ  ^• / mSU4S jjnU (       a  U  H  nU" [        U5      5        M     U(       a¯  U H©  nU" [        U5      5        [        U[        5      (       a-  [        [        [        [
        4   U5      R                  S5      nO[        USS5      n[        U[        5      (       d  Mz  [        [        [           U5       H  nU" [        U5      5        M     M«     T$ )z:Collect deduplicated helper names from tools and messages.c                ó>   >• U b  U T;  a  TR                  U 5        g g g )N)Úappend)r<   Úhelperss    €r    Ú_addÚcollect_helpers.<locals>._addz   s"   ø€ Ø‰?˜s¨'Ó1Ø�N‰N˜3Õð  2ˆ?r!   ÚcontentN)r<   ú
str | NoneÚreturnÚNone)
r   Ú
isinstanceÚdictr   Ústrr   Úgetr,   Úlistr$   )ÚtoolsÚmessagesrB   ÚtoolÚmessageÚblocksÚblockrA   s          @r    r   r   s   s·   ø€ ð
 €G÷ ö ÛˆDÙ” Ó%Ö&ñ ö ÛˆGÙ” Ó(Ô)ä˜'¤4×(Ñ(Ü"¤4¬¬S¨¡>°7Ó;×?Ñ?À	ÓJ‘ä  ¨)°TÓ:�Ü˜&¤$×'Ó'Ü!¤$¤v¡,°Ö7�EÙœ¨Ó.Ö/ó 8ñ  ð €Nr!   c                óX   • [        X5      nU(       d  0 $ [        SR                  U5      0$ )znBuild x-stainless-helper header dict from tools and messages.

Returns an empty dict if no helpers are found.
z, )r   r
   Újoin)rM   rN   rA   s      r    r   r   ‘   s*   € ô ˜eÓ.€GÞØˆ	Ü# T§Y¡Y¨wÓ%7Ð8Ð8r!   c                ó2   • [        U 5      nUc  0 $ [        U0$ )z8Build x-stainless-helper header dict from a file object.)r   r
   )Úfiler<   s     r    r   r   Ÿ   s!   € ä
˜Ó
€CØ
�{Øˆ	Ü# SÐ)Ð)r!   )r   r   rF   údict[str, str])r)   r   r*   r   rF   rG   )r)   r$   rF   rE   )r:   r$   r;   r-   rF   r-   )NN)rM   r   rN   r   rF   z	list[str])rM   r   rN   r   rF   rW   )rV   r$   rF   rW   )r7   Ú
__future__r   Útypingr   r   r   r   r   Útyping_extensionsr	   Ú__all__r
   r   r   r   r   r   r&   r   r   r-   rJ   r0   r   r   r   r   r2   r!   r    Ú<module>r\      sð   ðñõ #ç 4Õ 4Ý %ò€ð  /Ð ðð "=Ð Ø Dà!<Ð Ø KàÐ ð %ðñÐ ðô,ð #€ôô,ñ
 �KÐ'=Ñ>€	ôX�$�s˜C�x‘.ô Xô#ð ØðØðàðð õð> Øð9Øð9àð9ð õ9õ*r!   