+
    D#j$                        ^ RI Ht ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIH	t	 ^ RI
Ht RR0t0 R
mtR0tRt ! R R	4      tR# )    )annotationsN)Path)runtime_dirhistory.jsonlzsession_index.jsonlinstallation_idc                  >   ] tR t^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 R llt	R&R R llt
]R R l4       tR R lt]R R l4       tR R lt]R R l4       t]R R l4       t]R R l4       t]R R l4       t]R  R! l4       t]R" R# l4       tR$tR# )'SharedCodexStateNc               $    V ^8  d   QhRRRRRR/# )   legacy_codex_homezPath | Noneaccounts_dirreturnNone )formats   "c/home/user/overdeck-private-tests/subrouter-s5-systray-latest/modules/systray/shared_codex_state.py__annotate__SharedCodexState.__annotate__   s(     

 

&

 "

 
	

    c                	    Ve   \        V4      M\         P                  ! 4       R,          V n        Ve   \        V4      V n        R # \        4       R,          V n        R # )Nz.codexaccounts)r   homer   r   r   )selfr   r   s   &&&r   __init__SharedCodexState.__init__   sR     (9'DD"#$))+X`J` 	 #/":D 	@KPZ@Z 	r   c                    V ^8  d   QhRRRR/# )r   account_homer   r   
list[Path]r   )r   s   "r   r   r   !   s      d z r   c                	   \        V4      pVP                  R R R7       V P                  P                  R R R7       VP                  4        Uu0 uF  q"P                  kK  	  ppVP                  R V P                  P                  4        4       4       . p\        V4       F  pV P                  V4      '       g/   V P                  V4      '       g   V P                  V4      '       d   V P                  W,          4       Ka  VP                  V P                  W,          V P                  V,          4      4       K  	  V# u upi )Tparentsexist_okc              3  8   "   T F  qP                   x  K  	  R # 5iNname).0paths   & r   	<genexpr>5SharedCodexState.sync_shared_links.<locals>.<genexpr>&   s     L+K4YY+Ks   )r   mkdirr   iterdirr&   updatesorted_is_credential_name_is_sqlite_state_name_is_ephemeral_runtime_name_unshare_account_entryextend_merge_and_link_shared_entry)r   r   r(   names	conflictsr&   s   &&    r   sync_shared_links"SharedCodexState.sync_shared_links!   s   L)4$7$$TD$A'3';';'=>'=t'=>L4+A+A+I+I+KLL "	5MD((..--d3322488++L,?@11 '**T1 " # ?s   E c                   V ^8  d   QhRR/# )r   r   r   r   )r   s   "r   r   r   8   s      z r   c                	$   V P                   P                  4       '       g   . # . p\        V P                   P                  4       4       FD  pVR ,          pVP	                  4       '       g   K$  VP                  V P                  V4      4       KF  	  V# )
CODEX_HOME)r   existsr.   r,   is_dirr3   r7   )r   r6   account_dir
codex_homes   &   r   sync_all_shared_links&SharedCodexState.sync_all_shared_links8   sy      ''))I "	!$"3"3";";"=>K$|3J  ""  !7!7
!CD ? r   c                    V ^8  d   QhRRRR/# )r   entryr   r   r   r   )r   s   "r   r   r   B   s     ( (D (T (r   c                	z   VP                  4       '       g   R # VP                  4       p VP                  V P                  P                  4       4       TP                  4       '       d   R # TP                  4        TP                  4       '       d   \        P                  ! Y!4       R # R #   \         d     R # i ; ir$   )

is_symlinkresolverelative_tor   
ValueErrorr=   unlinkis_fileshutilcopy2)r   rC   targets   && r   r2   'SharedCodexState._unshare_account_entryB   s    !!	t55==?@ ==??>>LL'   		s   )B+ +B:9B:c               $    V ^8  d   QhRRRRRR/# )r   sourcer   destinationr   r   r   )r   s   "r   r   r   P   s!      4 d z r   c                	.   VP                  4       '       d:   VP                  4       VP                  4       8X  d   . # V P                  V4       V.# VP                  4       '       d   VP                  4       '       g.   VP                  4       '       g   \        P
                  ! W4       MVP                  4       '       dW   VP                  4       '       dA   V P                  VVVP                  \        9   R 7      pV'       d   V# VP                  4        MJVP                  4       '       d2   VP                  4       '       d   V P                  W4      '       g   V.# MV.# VP                  4       '       d!   VP                  W"P                  4       R7       . # ))discard_conflicts)target_is_directory)rE   rF   _unshare_foreign_linkr<   osreplacer=   _merge_directoryr&   DISPOSABLE_STATE_DIR_NAMESrmdirrJ   _merge_file
symlink_to)r   rP   rQ   r6   s   &&& r   r4   -SharedCodexState._merge_and_link_shared_entryP   s;   ~~;#6#6#88	&&v.8O==??%%''0F0F0H0H

6/[%7%7%9%9 11&,kk5O&O 2 	
 $$!!k&9&9&;&;''<<"8O = xk?Q?Q?ST	r   c               (    V ^8  d   QhRRRRRRRR/# )r   rP   r   rQ   rS   boolr   r   r   )r   s   "r   r   r   k   s2         	
 
r   c                	H   VP                  R R R7       . p\        VP                  4       4       EFn  pW%P                  ,          pVP	                  4       '       d   VP                  4       '       g   VP                  4       '       d*   VP	                  4       '       g   VP                  V4       K  V P                  WVV4      pV'       d   VP                  V4       K  VP                  4        K  VP                  4       '       g0   VP                  4       '       g   \        P                  ! WV4       EK  VP                  4       '       dC   VP                  4       '       d-   V P                  WVV4      '       g   VP                  V4       EK]  VP                  V4       EKq  	  V# )Tr    )r+   r.   r,   r&   r=   rE   r<   appendrX   r3   rZ   rV   rW   rJ   r[   )r   rP   rQ   rS   r6   itemrM   nesteds   &&&&    r   rX   !SharedCodexState._merge_directoryk   s(    	$6 "	6>>+,D 99,F{{}}T__%6%6==??6==??$$T*..t=NO$$V,

==??6+<+<+>+>

4(||~~&.."2"2''6GHH$$T*T"' -( r   c               (    V ^8  d   QhRRRRRRRR/# )r   rP   r   rQ   rS   r_   r   r   )r   s   "r   r   r      s2         	
 
r   c                	   \         P                  ! WR R7      '       d   VP                  4        R# VP                  \        9   d   V P                  W4       R# VP                  R8X  d   V P                  W4      '       d   R# VP                  R8X  d   V P                  W4       R# V'       g   VP                  \        9   d   VP                  4        R# R # )F)shallowTz.jsonlz.log)
filecmpcmprI   r&   MERGEABLE_JSONL_NAMES_merge_jsonlsuffix_resolve_transcript_append_fileSHARED_SINGLETON_NAMES)r   rP   rQ   rS   s   &&&&r   r[   SharedCodexState._merge_file   s     ;;vE::MMO;;//f2==H$)A)A&)V)V==F"f2/E EMMOr   c               $    V ^8  d   QhRRRRRR/# )r   rP   r   rQ   r   r_   r   )r   s   "r   r   r      s!     
 
D 
t 
 
r   c                	n   \        W3R  R7      w  r#VP                  R4      ;_uu_ 4       pVP                  VP                  4       P                  4      pRRR4       XVP                  4       8w  d   R# W!8X  d   \        P                  ! W4       R# V P                  4        R#   + '       g   i     LW; i)c                6    V P                  4       P                  # r$   )statst_size)ps   &r   <lambda>6SharedCodexState._resolve_transcript.<locals>.<lambda>   s    affhFVFVr   keyrbNFT)	r.   openreadrt   ru   
read_bytesrV   rW   rI   )rP   rQ   shorterlongerhandleheads   &&    r   rm   $SharedCodexState._resolve_transcript   s     &!6<VW[[&;;w||~556D 7%%''!JJv+  MMO s   *B$$B4	c                    V ^8  d   QhRRRR/# )r   rP   r   r   r   r   )r   s   "r   r   r      s     ) )D )T )r   c                	    VP                  4       pVP                  4        VP                  4       '       d   \        P                  ! W!4       R # R # r$   )rF   rI   rJ   rK   rL   )r   rP   rM   s   && r   rU   &SharedCodexState._unshare_foreign_link   s5    !>>LL( r   c               $    V ^8  d   QhRRRRRR/# r   rP   r   rQ   r   r   r   )r   s   "r   r   r      s!      T   r   c                	*   V P                  4       pR pVP                  4       P                  '       dW   VP                  R4      ;_uu_ 4       pVP	                  R\
        P                  4       VP                  ^4      R8g  pRRR4       VP                  R4      ;_uu_ 4       pV'       d   V'       d   VP                  R4       VP                  V4       RRR4       V P                  4        R#   + '       g   i     Lv; i  + '       g   i     L5; i)Fr{      
Nab)
r~   rt   ru   r|   seekrV   SEEK_ENDr}   writerI   )rP   rQ   source_bytesneeds_separatorr   s   &&   r   rn   SharedCodexState._append_file   s    ((*%%%!!$''6B,"(++a.E"9 ( d##v<U#LL& $ 	 (' $#s   5C/"D3"D/C?	D	c               $    V ^8  d   QhRRRRRR/# r   r   )r   s   "r   r   r      s!     	 	4 	d 	t 	r   c                	   VP                  R R7      P                  4       pVP                  VP                  R R7      P                  4       4       \        \        P                  R V 4       4      4      pVP                  R8X  d   VP                  V P                  R7       MVP                  V P                  R7       T P                  TRP                  V4      V'       d   RMR,           4       VP                  4        R# )utf-8)encodingc              3  8   "   T F  q'       g   K  Vx  K  	  R # 5ir$   r   )r'   lines   & r   r)   0SharedCodexState._merge_jsonl.<locals>.<genexpr>   s     "BEDT44Es   	
r   ry   
 N)	read_text
splitlinesr3   listdictfromkeysr&   sort_history_sort_key_session_index_sort_key_atomic_write_textjoinrI   )r   rP   rQ   liness   &&& r   rk   SharedCodexState._merge_jsonl   s    %%w%7BBDV%%w%7BBDET]]"BE"BBC.JJ411J2JJ477J8TYYu-=TV-WXr   c                    V ^8  d   QhRRRR/# )r   r   strr   ztuple[bool, int]r   )r   s   "r   r   r      s     ` ` `(8 `r   c                	     \         P                  ! V 4      P                  R 4      p\        V\        4      '       * \        V\        4      '       d   V3# ^ 3#   \         P                  \        3 d    Rp LOi ; i)tsN)jsonloadsgetJSONDecodeErrorAttributeError
isinstanceintr   	timestamps   & r   r   "SharedCodexState._history_sort_key   sn    	

4(,,T2I y#..Z	SV=W=W	__]^__ $$n5 	I	   %A A76A7c                    V ^8  d   QhRRRR/# )r   r   r   r   ztuple[bool, str]r   )r   s   "r   r   r      s     a ac a.> ar   c                	     \         P                  ! V 4      P                  R 4      p\        V\        4      '       * \        V\        4      '       d   V3# R3#   \         P                  \        3 d    Rp LOi ; i)
updated_atNr   )r   r   r   r   r   r   r   r   s   & r   r   (SharedCodexState._session_index_sort_key   sn    	

4(,,\:I y#..Z	SV=W=W	``]_`` $$n5 	I	r   c                    V ^8  d   QhRRRR/# r   r&   r   r   r_   r   )r   s   "r   r   r      s     ? ?# ?$ ?r   c                	>    V R 8H  ;'       g    V P                  R4      # )z	auth.jsonzauth.)
startswithr%   s   &r   r/   $SharedCodexState._is_credential_name   s    {">>doog&>>r   c                    V ^8  d   QhRRRR/# r   r   )r   s   "r   r   r      s     9 9 9 9r   c                	,    V P                  \        4      # r$   )endswithEPHEMERAL_RUNTIME_SUFFIXESr%   s   &r   r1   +SharedCodexState._is_ephemeral_runtime_name   s    }}788r   c                    V ^8  d   QhRRRR/# r   r   )r   s   "r   r   r      s     R RC RD Rr   c                	4    \         P                  ! R V 4      RJ# )z"\.sqlite(?:-(?:wal|shm|journal))?$N)researchr%   s   &r   r0   &SharedCodexState._is_sqlite_state_name   s    yy>ETQQr   c               $    V ^8  d   QhRRRRRR/# )r   r(   r   contentr   r   r   r   )r   s   "r   r   r      s!     
$ 
$ 
$ 
$ 
$r   c                	8   V P                   P                  R R R7       \        P                  ! RRV P                   RR7      ;_uu_ 4       pVP	                  V4       VP
                  pRRR4       \        P                  ! XV 4       R#   + '       g   i     L); i)Tr    wr   F)r   dirdeleteN)parentr+   tempfileNamedTemporaryFiler   r&   rV   rW   )r(   r   r   	temp_names   &&  r   r   #SharedCodexState._atomic_write_text   sv    $6((	
 

 LL!I
 	

9d#
 
s   
B		B	)r   r   )NN)F)__name__
__module____qualname____firstlineno__r   r7   r@   r2   r4   rX   r[   staticmethodrm   rU   rn   rk   r   r   r/   r1   r0   r   __static_attributes__r   r   r   r	   r	      s    

.(6<4 
 
)  	 ` ` a a ? ? 9 9 R R 
$ 
$r   r	   >   tmpcache.tmp)z.lockz.pidz.sockz.socket)
__future__r   rh   r   rV   r   rK   r   pathlibr   runtime_pathsr   rj   rY   ro   r   r	   r   r   r   <module>r      sO    "   	 	    % )*?@ 5 +, B b$ b$r   