+
    D#joE                       ^ RI Ht ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RI	H
t
HtHtHt ^ RIHt ^ RIHt ^ RIHt ^ RIHt RtR	t^MtR?t]! 0 R@m4      t]P8                  ! R
4      t]P8                  ! R4      t]P8                  ! R4      t]P8                  ! R]P@                  4      t!^@t" ! R R]#4      t$ ! R R]$4      t% ! R R]$4      t& ! R R]$4      t']! RRR7       ! R R4      4       t(]! RRR7       ! R R4      4       t)R R lt*R R lt+ ! R  R!4      t,R" R# lt-RAR$ R% llt.R& R' lt/R( R) lt0R* R+ lt1R, R- lt2R. R/ lt3R0 R1 lt4R2 R3 lt5R4].R5R/R6 R7 llt6R8 R9 lt7R:R/R; R< llt8R= R> lt9R# )B    )annotationsN)CallableIterableIteratorMapping)contextmanager)	dataclass)Path)Literalzaccount_locks.jsonzaccount-lock/v1z/agent\.slice(?:/|$)z$/[^/]*[Dd]ispatch[^/]*\.scope(?:/|$)z/human\.slice(?:/|$)z6(?:libpod|docker|containerd|/machine\.slice/|kubepods)c                  .    ] tR t^!tRt]tRtR R ltRt	R# )AccountLockErrorz8Base refusal for account-lock policy and state failures.zaccount-lock-refusedc                   V ^8  d   QhRR/#    returnzdict[str, object] )formats   "]/home/user/overdeck-private-tests/subrouter-s5-systray-latest/modules/systray/account_lock.py__annotate__AccountLockError.__annotate__'   s     
 
!2 
    c                	&    R RRRRV P                   /# )okFdetailaccount-lockedreason)r   selfs   &r   refusal_payload AccountLockError.refusal_payload'   s     %&dkk
 	
r   r   N)
__name__
__module____qualname____firstlineno____doc__ACCOUNT_LOCK_EXIT_CODE	exit_coder   r   __static_attributes__r   r   r   r   r   !   s    B&I#F
 
r   r   c                  D   a  ] tR t^/tRtR V 3R lltR V 3R lltRtV ;t# )AccountLockStateErroraccount-lock-state-invalidc               $    V ^8  d   QhRRRRRR/# )r   pathr
   r   strr   Noner   )r   s   "r   r   "AccountLockStateError.__annotate__2   s&     T TT T3 T4 Tr   c                	f   < \        V4      V n        \        SV `  R V P                   RV 24       R# )z!account lock state is invalid at : N)r
   r-   super__init__)r   r-   r   	__class__s   &&&r   r4   AccountLockStateError.__init__2   s-    J	<TYYKr&RSr   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r0   6         !2 r   c                	.   < \         SV `  4       pR VR&   V# )r+   r   r3   r   r   payloadr5   s   & r   r   %AccountLockStateError.refusal_payload6   s    ')+8r   )r-   	r!   r"   r#   r$   r   r4   r   r(   __classcell__r5   s   @r   r*   r*   /   s    )FT T r   r*   c                  L   a  ] tR t^<tRtRR/R V 3R llltR V 3R lltRtV ;t# )	AccountLockedErrorr   commandNc               (    V ^8  d   QhRRRRRRRR/# )	r   toolr.   slugsIterable[str]rC   
str | Noner   r/   r   )r   s   "r   r   AccountLockedError.__annotate__?   s)     	
 	
S 	
 	
J 	
Z^ 	
r   c               	   <a \        \        P                  R  V 4       4      4      pSV n        W@n        RP                  V3R lV 4       4      ;'       g    SpV'       d   V R2MRp\        SV `  V RV R24       R# )c              3  8   "   T F  q'       g   K  Vx  K  	  R # 5iNr   ).0slugs   & r   	<genexpr>.AccountLockedError.__init__.<locals>.<genexpr>@   s     (H%$4%   	
z, c              3  2   <"   T F  pS R V 2x  K  	  R# 5i):Nr   )rM   rN   rE   s   & r   rO   rP   C   s      IjdD64&!1js   r2    zaccount lock blocks zg; unlock it in Systray AI or use --human-override-lock with an explicit --account from a human terminalN)tupledictfromkeysrE   rF   joinr3   r4   )r   rE   rF   rC   
normalizedaccount_textprefixr5   s   &f&$   r   r4   AccountLockedError.__init__?   sx    4==(H%(HHI
	
yy Ij IIQQT#*G9Bh*<. 9U U	
r   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   rI   J   r8   r   c                	   < \         SV `  4       pV P                   Uu. uF  q P                   R V 2NK  	  upVR&   V# u upi )rS   accounts)r3   r   rF   rE   )r   r<   rN   r5   s   &  r   r   "AccountLockedError.refusal_payloadJ   sE    ')+AEL))AdV4L
 Ms   ?)rF   rE   r>   r@   s   @r   rB   rB   <   s$    F	
QU 	
 	
 r   rB   c                  2   a  ] tR t^PtRtR V 3R lltRtV ;t# )HumanOverrideErrorhuman-override-deniedc                   V ^8  d   QhRR/# r   r   )r   s   "r   r   HumanOverrideError.__annotate__S   r8   r   c                	.   < \         SV `  4       pR VR&   V# )rc   r   r:   r;   s   & r   r   "HumanOverrideError.refusal_payloadS   s    ')+3r   r   )r!   r"   r#   r$   r   r   r(   r?   r@   s   @r   rb   rb   P   s    $F r   rb   T)frozenslotsc                  ,    ] tR t^Yt$ R]R&   R]R&   RtR# )HumanSessionVerdictboolhumanr.   r   r   N)r!   r"   r#   r$   __annotations__r(   r   r   r   rk   rk   Y   s    KKr   rk   c                  L    ] tR t^_t$ R]R&   R]R&   R]R&   ]R R l4       tRtR	# )
AccountUseAuthorizationr.   rE   rN   rl   locked_overridec                   V ^8  d   QhRR/# )r   r   r.   r   )r   s   "r   r   $AccountUseAuthorization.__annotate__f   s     1 1S 1r   c                	B    \        V P                  V P                  4      # rL   )account_keyrE   rN   r   s   &r   keyAccountUseAuthorization.keye   s    499dii00r   r   N)r!   r"   r#   r$   rn   propertyrv   r(   r   r   r   rp   rp   _   s$    
I
I1 1r   rp   c               $    V ^8  d   QhRRRRRR/# )r   rE   r.   rN   r   r   )r   s   "r   r   r   j   s!     2 2c 2 2 2r   c                P   V P                  4       pVP                  4       pV\        9  d   \        R V : 24      hV'       dP   RV9   gI   RV9   gB   RV9   g;   \        ;QJ d    R V 4       F  '       g   K   RM	  RM! R V 4       4      '       d   \        RV: 24      hV RV 2# )unsupported account-lock tool: rS   /\c              3  j   "   T F)  p\        V4      ^ 8  ;'       g    \        V4      ^8H  x  K+  	  R# 5i)    N)ord)rM   chars   & r   rO   account_key.<locals>.<genexpr>t   s,     Nods4y2~11Tc!11os   33TFz'invalid account slug for account lock: )stripACCOUNT_LOCK_TOOLS
ValueErrorany)rE   rN   normalized_toolnormalized_slugs   &&  r   ru   ru   j   s    jjlOjjlO00:4(CDD/!/!?"3NoN333NoNNNB4(KLLa011r   c                    V ^8  d   QhRRRR/# )r   rv   r.   r   ztuple[str, str]r   )r   s   "r   r   r   z   s      3 ? r   c                    \        V \        4      '       d   R V 9  d   \        R4      hV P                  R ^4      w  r\	        W4       W3# )rS   z,account lock entries must use tool:slug keys)
isinstancer.   r   splitru   )rv   rE   rN   s   &  r   split_account_keyr   z   sC    c33c>GHH3"JD:r   c                      ] tR t^tRtR R ltR R ltR R ltR R	 ltR
 R lt	R R lt
R R ltR R lt]R R l4       tR R ltR R ltRtR# )AccountLockStorezGPersistent shared-tier admission state for new account-backed sessions.c                    V ^8  d   QhRRRR/# )r   base_dirr
   r   r/   r   )r   s   "r   r   AccountLockStore.__annotate__   s     ? ? ?$ ?r   c                	    \        V4      V n        V P                  \        ,          V n        V P                  R ,          V n        R# )z.account_locks.lockN)r
   r   ACCOUNT_LOCKS_FILENAMEr-   	lock_path)r   r   s   &&r   r4   AccountLockStore.__init__   s/    XMM$::	)>>r   c                   V ^8  d   QhRR/# )r   r   frozenset[str]r   )r   s   "r   r   r      s     4 4^ 4r   c                	    V P                  4       ;_uu_ 4        \        V P                  4       4      uuR R R 4       #   + '       g   i     R # ; irL   )_state_lock	frozenset_read_unlockedr   s   &r   locked_keysAccountLockStore.locked_keys   s1    T0023  s	   =A	c                    V ^8  d   QhRRRR/# )r   rE   r.   r   r   r   )r   s   "r   r   r      s     
 
 
 
r   c                	   a V\         9  d   \        R V: 24      hV R2o\        V3R lV P                  4        4       4      # )r{   rS   c              3  p   <"   T F+  qP                  S4      '       g   K  V\        S4      R  x  K-  	  R # 5irL   )
startswithlen)rM   rv   r[   s   & r   rO   0AccountLockStore.locked_slugs.<locals>.<genexpr>   s,      
*<3v@VCF*<s   66)r   r   r   r   )r   rE   r[   s   &&@r   locked_slugsAccountLockStore.locked_slugs   sM    ))>thGHH6 
*.*:*:*<
 
 	
r   c               $    V ^8  d   QhRRRRRR/# r   rE   r.   rN   r   rl   r   )r   s   "r   r   r      s!     = =c = = =r   c                	:    \        W4      V P                  4       9   # rL   )ru   r   r   rE   rN   s   &&&r   	is_lockedAccountLockStore.is_locked   s    4&$*:*:*<<<r   c               (    V ^8  d   QhRRRRRRRR/# )r   rE   r.   rN   lockedrl   r   r   )r   s   "r   r   r      s(      s # t  r   c                	f   \        W4      pV P                  4       ;_uu_ 4        V P                  4       pV'       d   WE9  MWE9   pV'       g    R R R 4       R# V'       d   VP                  V4       MVP	                  V4       V P                  V4        R R R 4       R#   + '       g   i     R # ; iNFT)ru   r   r   addremove_write_unlocked)r   rE   rN   r   rv   keyschangeds   &&&&   r   
set_lockedAccountLockStore.set_locked   s    $%&&(D+1sG	  
 C   &  s   (BBB 5BB0	c               (    V ^8  d   QhRRRRRRRR/# )r   rE   r.   old_slugnew_slugr   rl   r   )r   s   "r   r   r      s(     
 
# 
 
 
 
r   c                	F   \        W4      p\        W4      pV P                  4       ;_uu_ 4        V P                  4       pWF9  d    R R R 4       R# VP                  V4       VP	                  V4       V P                  V4        R R R 4       R#   + '       g   i     R # ; ir   )ru   r   r   r   r   r   )r   rE   r   r   old_keynew_keyr   s   &&&&   r   rekeyAccountLockStore.rekey   s~    d-d-&&(D"   KK HHW  &  s   B4BB 	c               $    V ^8  d   QhRRRRRR/# r   r   )r   s   "r   r   r      s!     2 2 2C 2D 2r   c                	&    V P                  WR 4      # )F)r   r   s   &&&r   dropAccountLockStore.drop   s    t511r   c                    V ^8  d   QhRRRR/# )r   stateszMapping[str, bool]r   rl   r   )r   s   "r   r   r      s      );  r   c           	        VP                  4        UUu/ uF!  w  r#\        \        V4      !  \        V4      bK#  	  pppV P	                  4       ;_uu_ 4        V P                  4       p\        V4      pVP                  4        F1  w  r#V'       d   VP                  V4       K   VP                  V4       K3  	  WV8X  d    RRR4       R# V P                  V4        RRR4       R# u uppi   + '       g   i     R# ; i)zFRestore selected keys without clobbering unrelated concurrent updates.NFT)
itemsru   r   rl   r   r   setr   discardr   )r   r   rv   r   rY   r   befores   &&     r   restore_key_states#AccountLockStore.restore_key_states   s    
  &||~
- *3/0$v,>- 	 
 &&(DYF)//1HHSMLL%	  2
 ~     &  	
  s   'C$A(C*C**C;	c                   V ^8  d   QhRR/# )r   r   zIterator[None]r   )r   s   "r   r   r      s      ^ r   c              #  	  "    V P                   P                  R R R7       \        P
                  \        P                  ,          p\        \        R4      '       d   T\        P                  ,          p\        \        R4      '       d   T\        P                  ,          p \        P                  ! T P                  TR4      p \        P                  ! T4      p\         P"                  ! TP$                  4      '       g   \        T P                  R4      h\        P&                  ! TR4       \(        P*                  ! T\(        P,                  4        Rx  \(        P*                  ! T\(        P.                  4        \        P0                  ! T4       R#   \         d    p\        T P                   RT 24      ThRp?ii ; i  \         dI   pTP                  \        P                  8X  d   RM
\        T4      p\        T P                  T4      ThRp?ii ; i  \(        P*                  ! T\(        P.                  4       i ; i  \        P0                  ! T4       i ; i5i)	Tparentsexist_okz&cannot create account-lock directory: N	O_CLOEXEC
O_NOFOLLOW  zlock path must not be a symlinkzlock path is not a regular file)r   mkdirOSErrorr*   osO_RDWRO_CREAThasattrr   r   openr   errnoELOOPr.   fstatstatS_ISREGst_modefchmodfcntlflockLOCK_EXLOCK_UNclose)r   excflagsfdr   	lock_stats   &     r   r   AccountLockStore._state_lock   s    	MMt<
 		BJJ&2{##R\\!E2|$$R]]"E	I6B	I<<	 1 122+DNN<]^^IIb% KKEMM*/B.HHRL3  	'!GuM	  	I:=))u{{:R6X[\_X`F'?SH	I B.HHRLs~   IF A?I!"G ;I  AI H %I =IF? F::F??IHAHHI'H??I IIc                   V ^8  d   QhRR/# )r   r   zset[str]r   )r   s   "r   r   r      s     ; ; ;r   c                	   \         P                  p\        \         R 4      '       d   V\         P                  ,          p\        \         R4      '       d   V\         P                  ,          p \         P
                  ! V P                  V4      p \         P                  ! T4      p\        P                   ! TP"                  4      '       g   \        T P                  R4      hTP$                  \&        8  d   \        T P                  R4      hTP"                  \        P(                  \        P*                  ,          ,          '       d   \        T P                  R4      h. p\&        ^,           pT^ 8  dP   \         P,                  ! T\/        TR4      4      pT'       g   M%TP1                  T4       T\3        T4      ,          pKV  RP5                  T4      p	\         P6                  ! T4       \3        T	4      \&        8  d   \        T P                  R4      h \8        P:                  ! T	P=                  R	R
R7      4      p
\C        T
\D        4      '       g   \        T P                  R4      hT
PG                  R4      \H        8w  d   \        T P                  R\H        : 24      hT
PG                  R4      p\C        T\J        4      '       g   \        T P                  R4      h\        4       p T FE  p\C        T\        4      '       g   \M        R4      hTPO                  \Q        \S        T4      !  4       KG  	  \3        T4      \3        T4      8w  d   \        T P                  R4      hT#   \         d    \        4       u # \         dI   pTP                  \        P                  8X  d   RM
\        T4      p\        T P                  T4      ThRp?ii ; i  \         P6                  ! T4       i ; i  \>        \8        P@                  3 d   p\        T P                  R4      ThRp?ii ; i  \L         d&   p\        T P                  \        T4      4      ThRp?ii ; i)r   r   z state path must not be a symlinkNz state path is not a regular filezstate file is too largez"state file is group/world writablei    r   utf-8strict)errorsz"state file is not valid UTF-8 JSONzstate root must be an objectversionzversion must be r   zlocked must be a listz$account lock entries must be stringsz!locked contains duplicate entries)*r   O_RDONLYr   r   r   r   r-   FileNotFoundErrorr   r   r   r   r.   r*   r   r   r   r   st_sizeACCOUNT_LOCK_MAX_BYTESS_IWGRPS_IWOTHreadminappendr   rX   r   jsonloadsdecodeUnicodeDecodeErrorJSONDecodeErrorr   rV   getACCOUNT_LOCK_SCHEMAlistr   r   ru   r   )r   r   r   r   r   
state_statchunks	remainingchunkrawr<   r   rY   rv   s   &             r   r   AccountLockStore._read_unlocked   s>   2{##R\\!E2|$$R]]"E	DE*B	"J<<
 2 233+DII7YZZ!!$::+DII7PQQ!!T\\DLL%@AA+DII7[\\"$F.2Ia-C	4$89e$SZ'	((6"CHHRLs8,,'		3LMM	bjjGH!EFG '4(('		3QRR;;y!%88'		-.A-DE  X&&$'''		3JKK"u
	F!#s++$%KLL{,=c,BCD  z?c&k)'		3VWWg ! 	5L 	D;>99;S7Y\]`YaF'		6:C	D, HHRL #D$8$89 	b'		3WX^aa	b"  	F'		3s8<#E	Fsp   ,!M# ;O 
A<O BO 'O* 'AP$ #O:OOAOOO'*P!PP!$Q/ QQc                    V ^8  d   QhRRRR/# )r   r   rG   r   r/   r   )r   s   "r   r   r   &  s     % %M %d %r   c           
     	h   \        V Uu0 uF  p\        \        V4      !  kK  	  up4      pR \        RV/pV P                  P                  RRR7       Rp \        P                  ! RRV P                  RRR	R
7      ;_uu_ 4       p\        P                  ! WF^RR7       VP                  R4       VP                  4        \        P                  ! VP                  4       4       \        P                  ! VP                  4       R4       \!        VP"                  4      pRRR4       \        P$                  ! WPP&                  4       \        P(                  ! V P                  \        P*                  4      p \        P                  ! V4       \        P,                  ! V4        TeB    TP3                  4       '       g   TP5                  4       '       d   TP7                  4        R# R# R# u upi   + '       g   i     L; i  \        P,                  ! T4       i ; i  \.         d    p\1        T P&                  RT 24      ThRp?ii ; i  \.         d     R# i ; i  TeQ    TP3                  4       '       g   TP5                  4       '       d   TP7                  4        i i   \.         d     i i ; ii ; i)r   r   Tr   Nwr   z.account_locks.z.tmpF)encodingdirr[   suffixdelete)indent	sort_keys
r   zcannot write state: )sortedru   r   r  r   r   tempfileNamedTemporaryFiler   dumpwriteflushr   fsyncfilenor   r
   namereplacer-   r   r   r   r   r*   exists
is_symlinkunlink)	r   r   rv   rY   r<   	temp_pathhandledirectory_fdr   s	   &&       r   r    AccountLockStore._write_unlocked&  s#   TRTc[*;C*@ATRS
*j
 	D48!%		,, MM(  		'!tDT")		&--/51 -	 JJy)),774=="++>L'&& $ ''))Y-A-A-C-C!((* .D %? S & & 	Z'		5I#3OPVYY	Z  	 $ ''))Y-A-A-C-C!((* .D 	 %s   G).H BG.AH 5H H 'I	 =I	 I	 .G>	9H HH I'III 	IIJ1!J7JJJ1J-*J1,J--J1)r   r   r-   N)r!   r"   r#   r$   r%   r4   r   r   r   r   r   r   r   r   r   r   r   r(   r   r   r   r   r      sQ    Q?
4
=
2(  <;z% %r   r   c               (    V ^8  d   QhRRRRRRRR/# )	r   cgroup_pathsrG   controlling_ttyrl   container_signalrH   r   rk   r   )r   s   "r   r   r   N  s2     0 00 0 !	0
 0r   c                  \         ;QJ d    . R  V  4       F  NK  	  5M! R  V  4       4      pV FJ  p\        P                  V4      '       g   \        P                  V4      '       g   K;  \	        RRV 24      u # 	  Ve   \	        RRV 24      # V F/  p\
        P                  V4      '       g   K   \	        RRV 24      u # 	  V'       d   \	        RR4      # \	        RR4      # )c              3  8   "   T F  q'       g   K  Vx  K  	  R # 5irL   r   rM   r-   s   & r   rO   )classify_human_session.<locals>.<genexpr>T  s     8<44$$<rQ   Fzagent-cgroup:zin-container:Tzhuman-cgroup:zcontrolling-ttyzno-tty)rU   _AGENT_CGROUP_REsearch_DISPATCH_CGROUP_RErk   _HUMAN_CGROUP_RE)r&  r'  r(  pathsr-   s   &$$  r   classify_human_sessionr2  N  s     E8<8EE8<88E""4((,?,F,Ft,L,L&udV.DEE  #"5M:J9K*LMM""4((&t}TF-CDD  "4):;;uh//r   c                    V ^8  d   QhRRRR/# )r   pid
int | Noner   rk   r   )r   s   "r   r   r   b  s      Z 3F r   c                    V f   \         P                  ! 4       MT p\        \        V4      4      p\	        V\        V4      \        V4      R7      # )N)r'  r(  )r   getpidrU   _cgroup_ancestryr2  _has_controlling_tty_container_signal)r4  
target_pidcgroupss   &  r   probe_human_sessionr=  b  sC     #J$Z01G!,Z8*73 r   c                    V ^8  d   QhRRRR/# )r   r4  intr   zIterator[str]r   )r   s   "r   r   r   l  s      # - r   c              #     "   T p\        \        4       F:  pV^8:  d    R# \        V4      pVe   Vx  \        V4      pVe   WA8X  d    R# TpK<  	  R# 5i)   N)range_CGROUP_ANCESTRY_MAX
_cgroup_of_ppid_of)r4  current_depthcgroupparents   &    r   r8  r8  l  sU     G,-a<G$L'">V. .s   AAc                    V ^8  d   QhRRRR/# )r   r4  r?  r   rH   r   )r   s   "r   r   r   z  s     1 1C 1J 1r   c                f    \        R 4      \        V 4      ,          R,          P                  RR7      P                  4       ^ ,          pTP                  R4      '       d
   TR,          # TP                  R^4      p\        T4      ^8X  d
   T^,          # R#   \        \
        \        3 d     R# i ; i)/procrH  r   r  Nz0:::   NNrS   )
r
   r.   	read_text
splitlinesr   
IndexErrorUnicodeErrorr   r   r   )r4  linepartss   &  r   rD  rD  z  s    WC(83>>>P[[]^_` uBxJJsAE5zQ580D0 Z. s   AB B0/B0c                    V ^8  d   QhRRRR/# )r   r4  r?  r   zlist[str] | Noner   )r   s   "r   r   r     s     % % %!1 %r   c                     \        R 4      \        V 4      ,          R,          P                  RR7      pTP                  R4      pT^ 8  d   R# Y^,           R P                  4       #   \        \        3 d     R# i ; i)rL  r   r   rM  Nz) )r
   r.   rO  r   rR  rfindr   )r4  r  markers   &  r   _proc_stat_tailrY    sv    G}s3x'&0;;W;M YYt_Fzz|""$$ \" s   2A' 'A<;A<c                    V ^8  d   QhRRRR/# )r   r4  r?  r   r5  r   )r   s   "r   r   r     s      # * r   c                    \        V 4      pVe   \        V4      ^8  d   R #  \        V^,          4      #   \         d     R # i ; irL   rY  r   r?  r   r4  fieldss   & r   rE  rE    sC    S!F~Vq6!9~ s   5 AAc                    V ^8  d   QhRRRR/# )r   r4  r?  r   rl   r   )r   s   "r   r   r     s      c d r   c                    \        V 4      pVe   \        V4      ^8  d   R#  \        V^,          4      ^ 8g  #   \         d     R# i ; i)NFr\  r]  s   & r   r9  r9    sH    S!F~Vq6!9~"" s   8 AAc                    V ^8  d   QhRRRR/# )r   r<  rG   r   rH   r   )r   s   "r   r   r     s     
 
} 
 
r   c                Z   \        R 4      P                  4       '       d   R# \        R4      P                  4       '       d   R# \        P                  P	                  R4      pV'       d   RV 2# \
        ;QJ d    R V  4       F  '       g   K   RM	  RM! R V  4       4      '       d   R	# R
# )z/run/.containerenvzfile:/run/.containerenvz/.dockerenvzfile:/.dockerenv	containerzenv:container=c              3  L   "   T F  p\         P                  V4      x  K  	  R # 5irL   )_CONTAINER_CGROUP_REr.  r+  s   & r   rO   $_container_signal.<locals>.<genexpr>  s     
A&&t,,s   "$TFzcgroup:/proc ancestryN)r
   r  r   environr  r   )r<  rc  s   & r   r:  r:    sz     !((**(M!!##!

{+I	{++
s
A
Asss
A
AAA&r   c               (    V ^8  d   QhRRRRRRRR/# )r   action%Literal['lock', 'unlock', 'use-once']rE   r.   rN   r   r   )r   s   "r   r   r     s2     
C 
C1
C9<
CDG
C
Cr   c                ~    \        W4      pV R 8X  d   RV 2# V R8X  d   RV 2# V R8X  d   RV R2# \        RV  24      h)lockzLOCK unlockzUNLOCK use-oncezUSE z ONCEz!unsupported account lock action: )ru   r   )ri  rE   rN   rv   s   &&& r   confirmation_phrasero    s`     d
!Cse}cU%  
8A
BBr   session_probeconfirmation_readerc               0    V ^8  d   QhRRRRRRRRRR	R
R/# )r   ri  rj  rE   r.   rN   rp  z!Callable[[], HumanSessionVerdict]rq  zCallable[[str], str] | Noner   r/   r   )r   s   "r   r   r     sL     L L1L
L L
 5L 5L 
Lr   c               F   V! 4       pVP                   '       g   \        R VP                   R24      h\        WV4      pRV: R2pT;'       g    \        p V! V4      p	T	P                  4       T8w  d   \        R4      hR#   \
         d   p
\        RT
 24      T
hRp
?
ii ; i)z7account lock action requires a human terminal; denied ()zType z to confirm: z4account lock action requires /dev/tty confirmation: Nz'account lock confirmation did not match)rm   rb   r   ro  _read_confirmation_from_ttyr   r   )ri  rE   rN   rp  rq  verdictphrasepromptreaderenteredr   s   &&&$$      r   confirm_human_actionr{    s     oG=== EgnnEUUVW
 	
 !t4FVJm,F ??$?F.
 }}&  !JKK !	   B3%H
	s   B B BB c                    V ^8  d   QhRRRR/# )r   rx  r.   r   r   )r   s   "r   r   r     s     & & & &r   c                    \        R 4      P                  RR^R7      ;_uu_ 4       pVP                  V 4       VP                  4        VP	                  R4      uuRRR4       #   + '       g   i     R# ; i)z/dev/ttyzr+r   )r  	bufferingi   N)r
   r   r  r  readline)rx  terminals   & r   ru  ru    sU    	j			tg		C	Cxv  % 
D	C	C	Cs   2A##A4	rC   c               4    V ^8  d   QhRRRRRRRRRRR	R
RR/# )r   r   r
   rE   r.   rN   allow_lockedrl   explicit_accountrC   rH   r   rp   r   )r   s   "r   r   r     sN     5 55
5 5
 5 5 5 5r   c                  \        V 4      pVP                  W4      '       g   \        WR 4      # V'       g   \        W3VR7      hV'       g   V'       d   V R2MRp\	        V R24      h\        RW4       \        WR4      # )F)rC   r2   rT   z4--human-override-lock requires an explicit --accountrn  T)r   r   rp   rB   rb   r{  )r   rE   rN   r  r  rC   storer[   s   &&&$$$  r   authorize_account_user    s     X&E??4&&&t599 w@@#*G9B hJK
 	
 T0"4t44r   c               $    V ^8  d   QhRRRRRR/# )r   r   r
   authorizationrp   r   r/   r   )r   s   "r   r   r     s(     L LT L:Q LVZ Lr   c                    \        V 4      P                  VP                  VP                  4      pVP                  '       d   R # V'       d"   \        VP                  VP                  34      hR # rL   )r   r   rE   rN   rq   rB   )r   r  r   s   && r   revalidate_account_user    s]    h'11M..F $$$ !3!3m6H6H5JKK r   i   >   grokcodexclauderL   ):
__future__r   r   r   r   r   rer   r  collections.abcr   r   r   r   
contextlibr   dataclassesr	   pathlibr
   typingr   r   r  r&   r   r   r   compiler-  r/  r0  
IGNORECASEre  rC  RuntimeErrorr   r*   rB   rb   rk   rp   ru   r   r   r2  r=  r8  rD  rY  rE  r9  r:  ro  r{  ru  r  r  r   r   r   <module>r     s   "    	 	   A A % !  - '  " :;  ::56 jj!HI ::56 zz=r}}   
| 

, 
) ()  $d#  $
 $d#1 1 $12 I IX0(1%

CL
 8KL 8<L4&5 5.Lr   