+
    5mj                        ^ RI Ht ^ RIt^ RIt^ RIt^ RIHt ^ RIHt ^ RI	H
t
HtHtHt ^ RIHtHtHtHt ^ RIHt Rt ! R	 R
]4      t ! R R4      t ! R R4      tR# )    )annotationsN)Iterator)Path)Account
AccountRefAccountRegistryStagedAccount)GrokOAuthSessionpoll_device_codestart_device_codewrite_auth_file)LifecycleEventzroy-grokc                      ] tR t^tRtR# )GrokAuthOperationError N)__name__
__module____qualname____firstlineno____static_attributes__r       ]/home/user/overdeck-private-tests/workstation-ai-broad/modules/systray/grok_auth_operation.pyr   r      s    r   r   c                      ] tR t^tR R ltRRRR/R R lltR R	 ltR]R
]RR/R R lltRR/R R llt	R R lt
R R ltRtR# )GrokAuthOperationc                    V ^8  d   QhRRRR/# )   registryr   returnNoner   )formats   "r   __annotate__GrokAuthOperation.__annotate__   s     ! ! !T !r   c                	    Wn         R # Nr   )selfr   s   &&r   __init__GrokAuthOperation.__init__   s     r   
login_hintNslugc               (    V ^8  d   QhRRRRRRRR/# )r   aliasstrr)   
str | Noner*   r   Iterator[LifecycleEvent]r   )r    s   "r   r!   r"      s8     B BB 	B
 B 
"Br   c             #  	  "   ?R pR p V P                   P                  WR7      pV P                  V4      p\	        RTR7      x   \        4       p\        TP                  R4      ;'       g    TP                  R	4      ;'       g    R
4      p\        TP                  R4      ;'       g    R
4      p	\	        RTRT RT	 2\        Y RT	 2R7      R R7      x  \        T4      p
\        T
P                  R4      ;'       g    R
4      p\        T
P                  R4      ;'       g    R
4      pT'       d	   T'       g   \        R4      hTP                  R,          p\        TTT\        T
P                  R4      \        \        34      '       d   \        T
R,          4      MR R7       T P!                  TP                  T4      pT P#                  TP                  R4      TP                  R4      4      pTe1   TP%                  4        \	        RTTRTP&                   2R7      x  R # TP)                  4       p\	        RTR7      x  R #   \         d"   p\	        RRT RT 2TR7      x   R p?R # R p?ii ; i  \         dF   pTe#   TP*                  '       g   TP%                  4        \	        RTRT 2TR7      x   R p?R # R p?ii ; i5i) Nr*   failurezAdding Grok account z	 failed: )kindmessageerrorstartedr3   accountverification_uri_completeverification_uri 	user_codeprompt_readyzGrok device login: open  code 
urlraw_textr3   r8   r4   promptsessionaccess_tokenrefresh_tokendevice login missing tokens	auth.json
expires_inaccessrefreshrJ   
account_idemail	collisionz$Grok identity already registered as )r3   r8   rP   r4   successzAdding Grok account failed: r3   r8   r4   r5   )r   	stage_add_pending_account	Exceptionr   r   r-   get_Promptr   r   account_homer   
isinstanceintfloat_write_identity_find_collisionrollbackr,   commit_closed)r&   r,   r)   r*   stagedpendingexcdeviceurir<   tokensrL   rM   	auth_pathidentityrP   r8   s   &&$$             r   addGrokAuthOperation.add   s     '+"&		]],,U,>F++F3G )W==,	&(Ffjj!<=eeL^A_eecefCFJJ{399r:I #23%vi[I359+1FG  &f-FN399r:F&**_5;;<G,-JKK++k9I:DVZZP\E]`cej_k:l:l5!56rv	 ++F,?,?KH,,X\\,-GV]I^_I$!$$#'B9??BST	  mmoG iAAY  	 .ugYseD 
 	Z  	!&...! 6se<	  	s   K-I K?I5 #I5 *A9I5 $I5 3I5 ;C(I5 #K%I5 KI2I-'K-I22K5K K $K :K KKc                    V ^8  d   QhRRRR/# )r   r8   r   r   r/   r   )r    s   "r   r!   r"   a   s     ' 'g '2J 'r   c              #  	P  "   VP                   \        8X  d7   \        P                  P	                  R 4      R8w  d   \        RVRR7      x  R# \        RVR7      x   \        4       p\        VP	                  R4      ;'       g    VP	                  R	4      ;'       g    R
4      p\        VP	                  R4      ;'       g    R
4      p\        RVRV RV 2\        W3 RV 2R7      RR7      x  \        V4      p\        VP	                  R4      ;'       g    R
4      p\        VP	                  R4      ;'       g    R
4      pV'       d	   V'       g   \        R4      h\        VP                  R,          TT\        VP	                  R4      \        \        34      '       d   \        VR,          4      MRR7       V P!                  VP                  VP                  R,          4       \        RVR7      x  R#   \"         d    p\        RTRT 2TR7      x   Rp?R# Rp?ii ; i5i)SYSTRAY_ALLOW_ROY_GROK_MUTATION1r2   zGroy-grok is protected; set SYSTRAY_ALLOW_ROY_GROK_MUTATION=1 to re-auth)r3   r8   r4   Nr6   r7   r9   r:   r;   r<   r=   zGrok re-auth: open r>   r?   r@   rC   rF   rG   rH   rI   rJ   rK   rQ   zGrok re-auth failed: rR   )r*   PROTECTED_SLUGosenvironrV   r   r   r-   rW   r   r   r   rX   rY   rZ   r[   r\   rU   )	r&   r8   rd   re   r<   rf   rL   rM   rc   s	   &&       r   reauthenticate GrokAuthOperation.reauthenticatea   s    <<>)bjjnn=^._cf.f a 
 )W==	&(Ffjj!<=eeL^A_eecefCFJJ{399r:I #-cU&D359+1FG  &f-FN399r:F&**_5;;<G,-JKK$${2:DVZZP\E]`cej_k:l:l5!56rv	   !5!5w7K7Kk7YZ iAA 	 /u5	  	sP   AH&?G9 #G9 A9G9 <G9 G9 B$G9 7H&9H#HH&H##H&r,   legacy_authc               (    V ^8  d   QhRRRRRRRR/# )r   r*   r-   r,   rt   zPath | Noner   r   r   )r    s   "r   r!   r"      s4        	
 ! 
r   c                 a T;'       g$    \         P                  ! 4       R,          R,          pVP                  4       '       g   \        RV 24      h\	        V3R lV P
                  P                  4        4       R4      pVe   V# V P
                  P                  SV4      pVR,          p\        P                  ! WG4       \        P                  ! VR4        V P                  WgRR7       \	        V3R	 lV P
                  P                  4        4       4      pV P
                  P                  V4       V#   \         d     LWi ; i)
zECopy-only import of ~/.grok/auth.json. Never hits the token endpoint.z.grokrI   zmissing Grok auth at c              3  L   <"   T F  qP                   S8X  g   K  Vx  K  	  R # 5ir$   r1   .0ar*   s   & r   	<genexpr><GrokAuthOperation.import_from_legacy_home.<locals>.<genexpr>   s     K$8qFFdN$8   $
$N  Fallow_refreshc              3  L   <"   T F  qP                   S8X  g   K  Vx  K  	  R # 5ir$   r1   rx   s   & r   r{   r|      s     I"6Q&&D.qq"6r}   )r   homeis_filer   nextr   listadd_dirshutilcopy2rp   chmodr\   rU   set_default)	r&   r*   r,   rt   sourceexistingrX   destr8   s	   &d$$     r   import_from_legacy_home)GrokAuthOperation.import_from_legacy_home   s    EEw!6!D~~(+@)IJJKDMM$6$6$8KTRO}},,T59k)V"
u	  5 I I$--"4"4"6II!!'*  		s   D7 7EEr   Tc               (    V ^8  d   QhRRRRRRRR/# )r   rX   r   rg   r   boolr   zdict[str, str | None]r   )r    s   "r   r!   r"      s8     H HH H
 H 
Hr   c               	L   \        V4      pVP                  VR 7      p\        VP                  R4      \        4      '       d   VP                  R4      MRp\        VP                  R4      \        4      '       d   VP                  R4      M7\        VP                  R4      \        4      '       d   VP                  R4      MRpRpRVRVRV/p	VR,          p
V
P                  \        P                  ! V	^R	7      R
,           RR7       \        P                  ! V
R4       RVRVRV/# )r   rO   NprincipalIduserIdgrokorg_idsubscription_typezaccount_identity.json)indentr?   zutf-8)encodingr~   rN   plan)
r
   get_userrY   rV   r-   
write_textjsondumpsrp   r   )r&   rX   rg   r   rE   userrO   rN   r   rh   paths   &&&$       r   r\   !GrokAuthOperation._write_identity   s    #9-m<%/0A3%G%G!T $((=1377 HH]# $((8,c22 (# 	 Uj

 55

8A6=P
uj&$GGr   c               $    V ^8  d   QhRRRRRR/# )r   rN   r.   rO   r   zAccount | Noner   )r    s   "r   r!   r"      s!      * Z N r   c                	    V P                   P                  4        Fo  pV'       d   VP                  V8X  d   Vu # V'       g   K*  VP                  '       g   K>  VP                  P	                  4       VP	                  4       8X  g   Km  Vu # 	  R # r$   )r   r   rN   rO   lower)r&   rN   rO   r8   s   &&& r   r]   !GrokAuthOperation._find_collision   s_    }}))+Gg00J>u7==+>+>+@EKKM+Q	 ,
 r   c                    V ^8  d   QhRRRR/# )r   ra   r	   r   r   r   )r    s   "r   r!   r"      s     
 
} 
 
r   c           	     	    \        \        V P                  P                  P                  VP
                  4      VP                  VP                  R R R R7      # )N)refr,   rX   rO   r   rN   )r   r   r   r3   valuer*   r,   rX   )r&   ra   s   &&r   rT   "GrokAuthOperation._pending_account   sF    4==--33V[[A,,,,
 	
r   r%   )r   r   r   r   r'   ri   rr   ro   r   r\   r]   rT   r   r   r   r   r   r      sm    !B "&	B
  BH'R # $	
 $(:H
 #H8
 
r   r   c                  "    ] tR t^tR R ltRtR# )rW   c               $    V ^8  d   QhRRRRRR/# )r   rA   r-   rB   r   r   r   )r    s   "r   r!   _Prompt.__annotate__   s!     ! !C !3 !4 !r   c                	    Wn         W n        R # r$   r@   )r&   rA   rB   s   &&&r   r'   _Prompt.__init__   s     r   )rB   rA   N)r   r   r   r   r'   r   r   r   r   rW   rW      s    ! !r   rW   )
__future__r   r   rp   r   collections.abcr   pathlibr   account_registryr   r   r   r	   
grok_oauthr
   r   r   r   provider_servicesr   ro   RuntimeErrorr   r   rW   r   r   r   <module>r      sT    "  	  $  P P  -	\ 	z
 z
z! !r   