+
    jHàj  ã                  óV  a € 0 t $ R t^ RIHt ^ RIt^ RIHt ^ RIHt ^ RI	H
t
Ht ^ RIHt ]P                  ! R4      tR R	 ltR
 R ltRR/R R lltR R lt]! RRR7       ! R R4      4       tRR 3RR 3RR 3RR 3RR 33tR ]R!&   RRR"R/R# R$ lltRRR%R/R& R' lltR( R) ltR# )*a#  The desktop's welcome trial: free inference on ``nous/welcome`` for a first install, once per OS user.

Only the backend the desktop spawned on this machine can claim it, only when this OS user has never
used Hermes here (``install_state``), and only with no provider and no Nous identity yet. The claim
mints a guest stamped with ``WELCOME_CLAIM_FLAG`` in the mint's own write and writes the OS user's
marker, so the trial is never claimed twice for that user. Another OS account on the same computer is
a separate first install. A claim that is lost later (the guest is reaped, ``auth.json`` is
deleted, the user signs in) is never made again: that user lands on provider setup and sign-in like
anyone else.

Enforcement is client-side; the account service's own entitlement check follows separately.
)ÚannotationsN)Ú	dataclass)ÚCallable)ÚAnyÚOptional)Ú	anon_authzhermes_cli.authc               ó   € V ^8„  d   QhRR/# ©é   ÚreturnÚbool© )Úformats   "Ú=/home/ubuntu/.hermes/hermes-agent/hermes_cli/welcome_trial.pyÚ__annotate__r      s   € ÷ _ñ _˜Dñ _ó    c                 ó^   € ^ RI Hp  \        P                  ! 4       RJ;'       g
    V ! 4       RJ# )é    ©Ú_read_shared_nous_stateN)Úhermes_cli.auth_nousr   r   Úcurrent_nous_stater   s    r   Ú_has_nous_identityr      s+   € Ý<ä×'Ò'Ó)°Ð5×^Ð^Ñ9PÓ9RÐZ^Ð9^Ð^r   c               ó   € V ^8„  d   QhRR/# r	   r   )r   s   "r   r   r       s   € ÷ 
;ñ 
;˜Tñ 
;r   c                 óš   € ^ RI Hp  ^ RIHp  V ! RRR7      pTR8g  ;'       g    \        P
                  ! 4       '       * #   T d     R# i ; i)z¦Something besides the welcome trial carries inference: a key, a config pin, a sign-in, a host
credential. The resolver itself answers, with the free-tier rung hidden.)Úresolve_provider)Ú	AuthErrorÚautoT)Úskip_free_tierFÚnous)Úhermes_cli.authr   Úhermes_cli.auth_constantsr   r   Ú	has_guest)r   r   Úproviders      r   Úprovider_configuredr$       sP   € õ 1Ý3ðÙ# F¸4Ô@ˆð �vÑ×:Ð:¤Y×%8Ò%8Ó%:Ô!:Ð:øð ô Úðús   Ž
? ¿A
Á	A
Úassume_freshFc               ó    € V ^8„  d   QhRRRR/# ©r
   r%   r   r   r   )r   s   "r   r   r   -   s   € ÷ añ a¨ð a¸$ñ ar   c                ó€   € \         P                  ! 4       '       d   R# \        4       pT;'       g    \        WR7      RJ # )z¦Something can carry a first chat on this backend: the trial (claimed, or claimable now) or a
configured provider. One walk of the provider ladder answers both halves.T©r%   Ú
configuredN)r   Úfree_inference_activer$   Úclaim_blockerr)   s   $ r   Úinference_availabler-   -   s7   € ô ×&Ò&×(Ò(ÙÜ$Ó&€JØ×`Ð`œ°LÔXÐ\`Ð`Ð`r   c               ó    € V ^8„  d   QhRRRR/# r'   r   )r   s   "r   r   r   6   s   € ÷ Jñ J 4ð J¨Dñ Jr   c                óz   € ^ RI HpHp V '       * ;'       d&    V! 4       P                  ;'       d    V! 4       '       * # )r   )ÚprobeÚtrial_reserved)Úhermes_cli.install_stater0   r1   Úexisting)r%   r0   r1   s   &  r   Ú_machine_is_usedr4   6   s,   € ß>àÔ×IÐI¡£× 0Ñ 0×IÐI¹Ó9IÔ5IÐIr   T)ÚfrozenÚslotsc                  ó,   € ] tR t^<t$ R]R&   R]R&   RtR# )Ú_Askr   r%   úOptional[bool]r*   r   N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__annotations__Ú__static_attributes__r   r   r   r8   r8   <   s   ‡ àÓØ×r   r8   znot the desktop's local backendc                ó6   € \         P                  ! 4       '       * # ©N)r   Úon_local_desktop_backend©Ú_asks   &r   Ú<lambda>rE   D   s   € ¼×9[Ò9[Ó9]Õ5]r   zguests are switched offc                ó6   € \         P                  ! 4       '       * # rA   )r   Úguest_allowedrC   s   &r   rE   rE   E   s   € ´×1HÒ1HÓ1JÕ-Jr   za Nous identity existsc                ó   € \        4       # rA   )r   rC   s   &r   rE   rE   F   s   € Ô,>Ô,@r   za provider is configuredc                óJ   € V P                   f   \        4       # V P                   # rA   )r*   r$   ©Úasks   &r   rE   rE   H   s   € ¨#¯.©.Ò*@Ô$Ó&ÐTÀcÇnÁnÐTr   zHermes was used on this machinec                ó,   € \        V P                  4      # rA   )r4   r%   rJ   s   &r   rE   rE   I   s   € Ô4DÀS×EUÑEUÔ4Vr   z.tuple[tuple[str, Callable[[_Ask], bool]], ...]Ú_CLAIM_BLOCKERSr*   c               ó$   € V ^8„  d   QhRRRRRR/# )r
   r%   r   r*   r9   r   zOptional[str]r   )r   s   "r   r   r   M   s'   € ÷ Uñ U 4ð U¸^ð UÐWdñ Ur   c                óN   a€ \        W4      o\        V3R l\         4       R4      # )a  Why the trial cannot be claimed here, or None when it can. *assume_fresh* is the unpackaged
desktop's ``--fresh-install`` switch: it skips only the machine check. *configured* is a
``provider_configured()`` answer the caller already has, so the ladder is not walked twice.c              3  óL   <"  € T F  w  rV! S4      '       g   K  Vx € K  	  R # 5irA   r   )Ú.0ÚreasonÚblocksrK   s   &  €r   Ú	<genexpr>Ú claim_blocker.<locals>.<genexpr>R   s   øé € ÐM©o™N˜FÁÈÇ—’«oùs   ƒ$š
$N)r8   ÚnextrM   )r%   r*   rK   s   $$@r   r,   r,   M   s"   ø€ ô ˆ|Ó
(€CÜÔM­oÓMÈtÓTÐTr   Úforcec               ó$   € V ^8„  d   QhRRRRRR/# )r
   r%   r   rW   r   zOptional[dict[str, Any]]r   )r   s   "r   r   r   U   s"   € ÷ ñ ¨Tð À$ð ÐSkñ r   c           
     ó(  € ^ RI Hp VP                  4       ;_uu_ 4        VP                  P	                  4        \        4        \        V R7      ;p'       d"   \        P                  RV4        RRR4       R# \        P                  ! RVRR7      pVf½   \        P                  ! 4       ;'       g    / p\        P                  ! \        VP                  R4      ;'       g&    \        P                  \        P                   ,          4      \        VP                  R4      ;'       g    \        P                   4      VP                  R	4      R
7      hVP#                  4        RRR4       \        P%                  R4       X#   + '       g   i     L'; i)a´  Claim the trial when nothing blocks it: mint the guest, stamp the claim, mark the machine.
Returns the claimed state, or None when the trial is not available here. A failed mint raises
the coded ``AuthError`` from :func:`anon_auth.ensure_portal_identity` (memoised with its cooldown;
*force* is the user's own retry). Held under the OS user's claim lock from the checks to the
marker write, so two installs starting together claim once.)Úinstall_state)r%   zwelcome trial not claimed: %sNT)ÚexplicitrW   Úwelcome_claimÚerrorÚ
error_codeÚretry_after)r_   z5Nous free tier: welcome trial claimed on this machine)Ú
hermes_clirZ   Ú
claim_lockr0   Úcache_clearÚsettle_interrupted_claimr,   ÚloggerÚdebugr   Úensure_portal_identityÚlast_mint_failureÚ	_anon_errÚstrÚgetÚANON_FAILURE_COPYÚANON_SERVER_ERRORÚmark_machine_usedÚinfo)r%   rW   rZ   rR   ÚstateÚfailures   $$    r   Úclaim_desktop_free_tierrq   U   s"  € õ )à	×	!Ñ	!×	#Õ	#Ø×Ñ×'Ñ'Ô)Ü Ô"Ü"°Ô=Ð=ˆ6Ö=Ü�L‰LÐ8¸&ÔAØ÷ 
$Ñ	#ô ×0Ò0¸$ÀeÐ[_Ô`ˆØŠ=Ü×1Ò1Ó3×9Ð9°rˆGÜ×%Ò%Ü�G—K‘K Ó(×dÐd¬I×,GÑ,GÌ	×HcÑHcÕ,dÓeÜ�G—K‘K Ó-×LÐL´×1LÑ1LÓMØ#ŸK™K¨Ó6ô8ð 8ð 	×'Ñ'Ô)÷ 
$ô ‡K�KÐGÔHØ€L÷ 
$×	#ús%   ŸAFÁ98FÂ2/FÃ"AFÄ(:FÆF	c               ó   € V ^8„  d   QhRR/# r	   r   )r   s   "r   r   r   o   s   € ÷ ñ  $ñ r   c                 ó(  € ^ RI Hp  ^ RIHpHp V! 4       '       g   R# \
        P                  ! 4       V ! 4       3p\        ;QJ d    R V 4       F  '       g   K   RM	  RM! R V 4       4      '       g   R# V! 4        \        P                  R4       R# )a!  A claim cut off between its guest write and its marker write leaves the reservation behind.
The stamped guest is the claim, so the reservation goes: kept, it would let a second trial through
once that guest is reaped or deleted. Runs before every claim and at serve boot; True when it did.r   )rm   r1   Fc              3  ó    "  € T FD  p\         P                  ! V4      ;'       d"    VP                  \         P                  4      R J x € KF  	  R# 5i)TN)r   Úis_guest_staterj   ÚWELCOME_CLAIM_FLAG)rQ   Úss   & r   rT   Ú+settle_interrupted_claim.<locals>.<genexpr>y   s>   é € ÐkÑdjÐ_`Œy×'Ò'¨Ó*×ZÐZ¨q¯u©u´Y×5QÑ5QÓ/RÐVZÐ/ZÔZÓdjùs
   ‚!A¤*ATz>Nous free tier: an interrupted welcome-trial claim was settled)
r   r   r2   rm   r1   r   r   Úanyrd   rn   )r   rm   r1   Ústoress       r   rc   rc   o   si   € õ =ßJá×ÒÙÜ×*Ò*Ó,Ñ.EÓ.GÐH€Fß‹3ÑkÑdjÓk�3�3Š3ÑkÑdjÓk×kÒkÙÙÔÜ
‡K�KÐPÔQÙr   )Ú__conditional_annotations__Ú__doc__Ú
__future__r   ÚloggingÚdataclassesr   Úcollections.abcr   Útypingr   r   r`   r   Ú	getLoggerrd   r   r$   r-   r4   r8   rM   r>   r,   rq   rc   )r{   s   @r   Ú<module>rƒ      sß   øðôõ #ã Ý !Ý $ß  å  à	×	Ò	Ð,Ó	-€õ_õ
;ða°÷ aõJñ �$˜dÔ#÷ð ó $ðð 'Ñ(]Ð^ØÑ JÐKØÑ@ÐAØÙTðVà&Ñ(VÐWðC€Ð?ó ðU¨%ð UÈd÷ Uð°Eð È÷ ÷4r   