+
    iHàj	  ã                  ó$  a € 0 t $ R t^ RIHt ^ RIt^ RIt^ RIHtHtH	t	 R.t
]P                  ! 4       t/ tR]R&   ]P                  ! 4       t]]].]3,          t]]].]	]]]3,          ,          3,          tR R ltR R	 lt]]].]3,          tR
 R ltR R ltR R ltR R ltR R lt/ tR]R&   / tR]R&   ]P                  ! 4       tR R lt R R lt!R R lt"R R lt#R/R  R! llt$R/R" R# llt%R$ R% lt&R& R' lt'R( R) lt(R* R+ lt)R, R- lt*R# )0uß  Per-process unlock state for external password managers.

An unlock is a session token minted by the manager's CLI from the master
password (``op signin --raw`` / ``bw unlock --raw``). The token lives in
process memory only, keyed by backend, and expires after an idle TTL or an
explicit lock. The master password itself is consumed by the CLI call and
dropped; nothing is written to disk or env.

The surface owns the prompt: ``set_unlock_prompt_callback`` is installed by
the CLI panel / TUI gateway bridge for the current thread, exactly like the
sudo-password callback. Headless contexts (cron, webhook, api_server,
single-query) install none and the vault stays locked â€” the same posture
approvals take where nobody can answer.
)ÚannotationsN)ÚCallableÚDictÚOptionalz(dict[tuple[str, str], tuple[str, float]]Ú	_sessionsc               ó    € V ^8„  d   QhRRRR/# )é   ÚcbúOptional[UnlockPrompt]ÚreturnÚNone© )Úformats   "Ú@/home/ubuntu/.hermes/hermes-agent/agent/vault_backends/unlock.pyÚ__annotate__r   "   s   € ÷ ñ Ð#9ð ¸dñ ó    c                ó   € V \         n        R# )zORegister the current surface's masked master-password prompt (per-thread slot).N)Ú_callback_tlsÚprompt©r	   s   &r   Úset_unlock_prompt_callbackr   "   s
   € à„MÖr   c               ó   € V ^8„  d   QhRR/# )r   r   r
   r   )r   s   "r   r   r   '   s   € ÷ 2ñ 2Ð$:ñ 2r   c                 ó$   € \        \        R R4      # )r   N©Úgetattrr   r   r   r   Úget_unlock_prompt_callbackr   '   s   € Ü”= (¨DÓ1Ð1r   c               ó    € V ^8„  d   QhRRRR/# )r   r	   úOptional[CodePrompt]r   r   r   )r   s   "r   r   r   /   s   € ÷ ñ Ð!5ð ¸$ñ r   c                ó   € V \         n        R# )zKRegister the surface's "enter the code {site} sent you" prompt, per thread.N)r   Úcoder   s   &r   Úset_code_prompt_callbackr    /   s
   € à„MÖr   c               ó   € V ^8„  d   QhRR/# )r   r   r   r   )r   s   "r   r   r   4   s   € ÷ 0ñ 0Ð"6ñ 0r   c                 ó$   € \        \        R R4      # )r   Nr   r   r   r   Úget_code_prompt_callbackr#   4   s   € Ü”= &¨$Ó/Ð/r   c               ó    € V ^8„  d   QhRRRR/# )r   r	   úOptional[SaveLoginPrompt]r   r   r   )r   s   "r   r   r   8   s   € ÷ "ñ "Ð'@ð "ÀTñ "r   c                ó   € V \         n        R# )z[Register the surface's "save this login" prompt (identifier + masked password), per thread.N)r   Ú
save_loginr   s   &r   Úset_save_login_prompt_callbackr(   8   s
   € à!„MÖr   c               ó   € V ^8„  d   QhRR/# )r   r   r%   r   )r   s   "r   r   r   =   s   € ÷ 6ñ 6Ð(Añ 6r   c                 ó$   € \        \        R R4      # )r'   Nr   r   r   r   Úget_save_login_prompt_callbackr+   =   s   € Ü”= ,°Ó5Ð5r   c               ó    € V ^8„  d   QhRRRR/# )r   ÚbackendÚstrr   útuple[str, str]r   )r   s   "r   r   r   A   s   € ÷ -ñ -�#ð -˜/ñ -r   c                ó2   € ^ RI Hp \        V! 4       4      V 3# )é    )Úget_hermes_home)Úhermes_constantsr2   r.   )r-   r2   s   & r   Ú_keyr4   A   s   € õ 1Ü‘Ó!Ó" GÐ,Ð,r   zdict[tuple[str, str], int]Ú_generationz$dict[tuple[str, str], Optional[str]]Ú_owner_sessionc               ó    € V ^8„  d   QhRRRR/# )r   Ú
session_idúOptional[str]r   r   r   )r   s   "r   r   r   R   s   € ÷ *ñ * }ð *¸ñ *r   c                ó   € V \         n        R# )zXGateway surfaces bind the session running on this thread so an unlock records its owner.N)Ú_current_session_tlsÚsid)r8   s   &r   Úset_current_session_idr=   R   s   € à)ÔÖr   c               ó$   € V ^8„  d   QhRRRRRR/# )r   r-   r.   ÚtouchÚboolr   r9   r   )r   s   "r   r   r   W   s!   € ÷ ñ �3ð  $ð ¨=ñ r   c               ó€  € \        V 4      p\        ;_uu_ 4        \        P                  V4      pVf    R R R 4       R # Vw  rE\        P
                  ! 4       V,
          \        8”  d   \        V  R R R 4       R # V'       d   V\        P
                  ! 4       3\        V&   VuuR R R 4       #   + '       g   i     R # ; i©N)r4   Ú_lockr   ÚgetÚtimeÚ	monotonicÚ_IDLE_TTL_S)r-   r?   ÚkeyÚentryÚtokenÚlasts   &$    r   Ú_liverL   W   s„   € Ü
ˆw‹-€Cß	ŽÜ—‘˜cÓ"ˆØŠ=Ø÷ 
‰ð ‰ˆÜ�>Š>Ó˜dÕ"¤[Ô0Ü˜#�Ø÷ 
‰÷ Ø#¤T§^¢^Ó%5Ð6ŒI�c‰NØ÷ 
��‹ús   šB,¿1B,Á:B,ÂB,Â,B=	c               ó    € V ^8„  d   QhRRRR/# )r   r-   r.   r   r9   r   )r   s   "r   r   r   f   s   € ÷ &ñ &˜sð & }ñ &r   c                ó   € \        V RR7      # )z8Token for a real manager call; refreshes the idle timer.T©r?   ©rL   ©r-   s   &r   Úget_session_tokenrR   f   s   € ä� Ô%Ð%r   c               ó    € V ^8„  d   QhRRRR/# )r   r-   r.   r   Úintr   )r   s   "r   r   r   k   s   € ÷ 1ñ 1˜#ð 1 #ñ 1r   c                óš   € \         ;_uu_ 4        \        P                  \        V 4      ^ 4      uuRRR4       #   + '       g   i     R# ; i)zaSnapshot the lock generation before spawning the manager CLI; pass it to ``store_session_token``.N)rC   r5   rD   r4   rQ   s   &r   Úbegin_unlockrV   k   s%   € ç	ŽÜ�‰œt G›}¨aÓ0÷ 
��‹ús	   �9¹A
	c               ó(   € V ^8„  d   QhRRRRRRRR/# )r   r-   r.   rJ   Ú
generationzOptional[int]r   r@   r   )r   s   "r   r   r   q   s)   € ÷ ñ  ð ¨Sð ¸mð ÐW[ñ r   c                ó4  € \        V 4      p\        ;_uu_ 4        Ve'   V\        P                  V^ 4      8w  d    RRR4       R# V\        P
                  ! 4       3\        V&   \        \        RR4      \        V&    RRR4       R#   + '       g   i     R# ; i)zbCommit an unlock. Returns False (and drops the token) when a Lock happened since ``begin_unlock``.NFr<   T)
r4   rC   r5   rD   rE   rF   r   r   r;   r6   )r-   rJ   rX   rH   s   &&& r   Ústore_session_tokenrZ   q   sl   € ä
ˆw‹-€Cß	ŽØÒ! j´K·O±OÀCÈÓ4KÔ&KØ÷ 
‰ð  ¤§¢Ó!1Ð2Œ	�#‰Ü%Ô&:¸EÀ4ÓHŒ�sÑØ÷ 
��Šús   š!BÁ7BÂB	c               ó    € V ^8„  d   QhRRRR/# )r   r-   r9   r   r   r   )r   s   "r   r   r   |   s   € ÷ 
ñ 
�-ð 
¨4ñ 
r   c                óˆ  € \        R4      ^ ,          p\        ;_uu_ 4        \        \        4      \        \        4      ,            Uu0 uF(  q"^ ,          V8X  g   K  V e   V^,          V 8X  g   K&  VkK*  	  ppV e   VP                  W34       V F  p\        V4       K  	  RRR4       R# u upi   + '       g   i     R# ; i)zPForget the current profile's session for one backend (or all of them when None).Ú N)r4   rC   Úlistr   r5   ÚaddÚ_forget)r-   ÚhomeÚkÚkeysrH   s   &    r   Úlockrd   |   s—   € ä�‹8�A�;€Dß	Žô  ¤	›?¬T´+Ó->Ö>ÓxÑ>�aÀAÅ$È$Á,”ÐT[ÒTcÐghÐijÕgkÐovÑgv—�Ñ>ˆÐxØÒØ�H‰H�d�_Ô%ÛˆCÜ�CŽLñ ÷ 
‰ùò y÷ 
�ˆús)   ¡&B0ÁB+ÁB+Á/B+Á5,B0Â+B0Â0C	c               ó    € V ^8„  d   QhRRRR/# )r   r8   r.   r   r   r   )r   s   "r   r   r   ‰   s   € ÷ ñ  ð ¨ñ r   c                óì   € \         ;_uu_ 4        \        P                  4        UUu. uF  w  rW 8X  g   K  VNK  	  upp F  p\        V4       K  	  RRR4       R# u uppi   + '       g   i     R# ; i)zDA gateway session ended: drop only the tokens that session unlocked.N)rC   r6   Úitemsr`   )r8   rb   r<   rH   s   &   r   Úrelease_sessionrh   ‰   sP   € ç	ŽÜ$2×$8Ñ$8Ô$:ÔPÑ$:™&˜!¸cÑ>O—A�AÑ$:ÕPˆCÜ�CŽLñ Q÷ 
‰ùÛP÷ 
�ˆús    �A"§
A
¶A
¼A"ÁA"Á"A3	c               ó    € V ^8„  d   QhRRRR/# )r   rH   r/   r   r   r   )r   s   "r   r   r   �   s   € ÷ 3ñ 3�ð 3 Tñ 3r   c                ó¦   € \         P                  V R 4       \        P                  V R 4       \        P	                  V ^ 4      ^,           \        V &   R # rB   )r   Úpopr6   r5   rD   ©rH   s   &r   r`   r`   �   s:   € Ü‡M�M�#�tÔÜ×Ñ�s˜DÔ!Ü"—‘ s¨AÓ.°Õ2„K�Ór   c               ó   € V ^8„  d   QhRR/# )r   r   r   r   )r   s   "r   r   r   –   s   € ÷ ñ ˜4ñ r   c                 óž   € \         ;_uu_ 4        \        \        4       F  p \        V 4       K  	  RRR4       R#   + '       g   i     R# ; i)z#Process shutdown: drop every token.N)rC   r^   r   r`   rl   s    r   Úlock_all_profilesro   –   s(   € ç	ŽÜœ	–?ˆCÜ�CŽLñ #÷ 
��Šús	   �";»A	c               ó    € V ^8„  d   QhRRRR/# )r   r-   r.   r   r@   r   )r   s   "r   r   r   �   s   € ÷ 3ñ 3˜ð 3 ñ 3r   c                ó    € \        V RR7      RJ# )zHStatus probe: does NOT extend the idle TTL (only real manager calls do).FrO   NrP   rQ   s   &r   Úis_unlockedrr   �   s   € ä� Ô&¨dÐ2Ð2r   c               ó   € V ^8„  d   QhRR/# )r   r   r@   r   )r   s   "r   r   r   ¢   s   € ÷ 4ñ 4˜ñ 4r   c                 óD   € ^ RI Hp  V ! 4       '       d   R# \        4       RJ# )zLFalse in contexts where no human can answer (cron, webhook, api_server, -q).©Ú_no_user_can_answerFN)Útools.approval_contextrv   r   ru   s    r   Úcan_prompt_hererx   ¢   s   € å:Ù×ÒÙÜ%Ó'¨tÐ3Ð3r   i  rB   )+Ú__conditional_annotations__Ú__doc__Ú
__future__r   Ú	threadingrE   Útypingr   r   r   rG   ÚLockrC   r   Ú__annotations__Úlocalr   r.   ÚUnlockPromptÚdictÚSaveLoginPromptr   r   Ú
CodePromptr    r#   r(   r+   r4   r5   r6   r;   r=   rL   rR   rV   rZ   rd   rh   r`   ro   rr   rx   )ry   s   @r   Ú<module>r…      s  øðôõ #ã Û ß +Ñ +à€à�ŠÓ€Ø68€	Ð3Ó 8Ø—’Ó!€à˜˜c˜
 C˜Õ(€ð ˜C ˜: x°°S¸#°XµÕ'?Ð?Õ@€õõ
2ð
 �s˜C�j #�oÕ&€
õõ
0õ"õ
6õ-ð +-€Ð'Ó ,ð 8:€Ð4Ó 9Ø —’Ó(Ð õ*õ
õ&õ
1÷÷
õõ3õõ3÷
4r   