+
    l1j  c                      ^ RI t^ RIHu 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 ^ RIHt ^ RIHt ^ RIHt  ! R R]P,                  4      t ! R R]P,                  4      t]R	8X  d   ]P4                  ! 4        R# R# )
    N)
HTTPServer)patch)attention_hookc                   >   a  ] tR t^t o R tR tR tR tR tRt	V t
R# )AttentionHookTestsc           	        \         P                  ! R RRRRRR/4      pV P                  VR,          R 4       V P                  VR,          R4       V P                  VR,          R4       V P                  VR,          R4       R	# )
Codexhook_event_namePermissionRequest
session_idzsession-123cwd)/Users/jameslopez/projects/CodexBar-ESP32providereventNr   build_attention_payloadassertEqualselfpayloads   & F/Users/jameslopez/projects/CodexBar-ESP32/tests/test_attention_hook.py,test_build_payload_uses_standard_hook_fields?AttentionHookTests.test_build_payload_uses_standard_hook_fields   s     88!#6mB
 	,g6)+>?.>)TU    c                >   \         P                  ! R RRRRRRRR/4      pV P                  VR	,          R 4       V P                  VR
,          R4       V P                  VR,          R4       V P                  VR,          R4       V P                  VR,          R4       R# )ClaudehookEventNameSessionStart	sessionIdzsession-abcr   z/tmp/projectlastAssistantMessagezDone.r   r   r   last_assistant_messageNr   r   s   & r   0test_build_payload_supports_camel_case_fallbacksCAttentionHookTests.test_build_payload_supports_camel_case_fallbacks   s     88]~&	
 	,h7)>:.>8!9:GDr   c                   \         P                  ! \        R RR7      ;_uu_ 4        \        P                  ! RRR/4      pRRR4       V P                  XR,          R4       V P                  VR,          R4       R#   + '       g   i     LD; i)getcwdz/tmp/fallback)return_valuer   r   StopNr   )r   objectosr   r   r   r   s   & r   0test_build_payload_uses_process_cwd_when_missingCAttentionHookTests.test_build_payload_uses_process_cwd_when_missing0   sh    \\"h_EE$<<WwPVFWXG F 	)629	 FEs   A<<B	c           	     r    \         P                  ! R RRRRRR/4      pV P                  VR,          R4       R# )r   r   Notificationr   /tmp/pmessagez,Automatic approval review approved: Bash(ls)Nr   r   s   & r   )test_build_payload_forwards_message_field<AttentionHookTests.test_build_payload_forwards_message_field7   s>     88neXyBpq
 	+-[\r   c                `    \         P                  ! R RRRR/4      pV P                  RV4       R# )r   r   r,   r   r-   r.   N)r   r   assertNotInr   s   & r   ,test_build_payload_omits_message_when_absent?AttentionHookTests.test_build_payload_omits_message_when_absent>   s3     88neX6
 	G,r    N)__name__
__module____qualname____firstlineno__r   r!   r)   r/   r3   __static_attributes____classdictcell____classdict__s   @r   r   r      s&     VE":]- -r   r   c                   >   a  ] tR t^Ft o R tR tR tR tR tRt	V t
R# )AttentionHookIntegrationTestsc                   R \         n        \         P                  ;_uu_ 4        \         P                  P	                  4        ^ \         n        RRR4       \         P                  ! 4        \        R\         P                  4      V n	        V P                  P                  ^,          V n        \        P                  ! V P                  P                  RR7      V n        V P                  P!                  4        R#   + '       g   i     L; i) NT)targetdaemon)z	127.0.0.1r   )server
NTFY_TOPIC_attention_lock_attention_recordsclear_attention_seq_invalidate_usage_cacher   Handlerhttpdserver_addressport	threadingThreadserve_foreverthreadstartr   s   &r   setUp#AttentionHookIntegrationTests.setUpG   s    ###%%++-$%F! $ 	&&( 0&..A
JJ--a0	&&djj.F.FtT $#s   *C99D		c                    V P                   P                  4        V P                   P                  4        V P                  P	                  ^R7       R# )   timeoutN)rL   shutdownserver_closerR   joinrT   s   &r   tearDown&AttentionHookIntegrationTests.tearDownR   s7    



!#r   c           	        \         P                  ! R RRRRR/4      p\        P                  P	                  4       pRV P
                   R2VR&   \        P                  ! \        P                  R	R
.VRR^VR7      pV P                  VP                  ^ 4       \        P                  P                  RV P
                   R2^R7      ;_uu_ 4       p\         P                  ! VP!                  4       4      pRRR4       XR,          ^,          R,          pV P                  VR,          R4       V P                  VR,          R4       R#   + '       g   i     L[; i)r	   r
   r   zsubprocess-sessionr   r   http://127.0.0.1:
/attentionCODEXBAR_ATTENTION_URLzcompanion/attention_hook.pyr   Tinputtextcapture_outputrZ   env/statusrY   N	providers	attentionstate
needs_userprimary_projectzCodexBar-ESP32)jsondumpsr(   environcopyrN   
subprocessrunsys
executabler   
returncodeurllibrequesturlopenloadsreadr   
hook_inputrh   resultrespbodycodexs   &      r   ,test_hook_script_posts_to_companion_endpointJAttentionHookIntegrationTests.test_hook_script_posts_to_companion_endpointW   s$   ZZ2.>!
 

 jjoo*;DII;j(Q$%^^:GD
 	**A.^^##&7		{'$JTU#VVZ^::diik*D W[!!$[1w6013CD	 WVs   %EE	c           	        \         P                  ! R RRR/4      p\        P                  P	                  4       pRV P
                   R2VR&   \        P                  ! \        P                  R.VRR^VR	7      pV P                  VP                  ^ VP                  4       \        P                  P                  RV P
                   R
2^R7      ;_uu_ 4       pV P                  VP                   ^4       \         P"                  ! VP%                  4       4      pRRR4       XR,          ^,          R,          pV P                  VR,          R4       V P                  VR,          R4       R#   + '       g   i     L[; i)r   znotify-sessionr   r   ra   rb   rc   zcompanion/codex_notify.pyTrd   ri   rY   Nrj   rk   rl   rm   reasonnotification)ro   rp   r(   rq   rr   rN   rs   rt   ru   rv   r   rw   stderrrx   ry   rz   statusr{   r|   r}   s   &      r   6test_codex_notify_wrapper_posts_notification_attentionTAttentionHookIntegrationTests.test_codex_notify_wrapper_posts_notification_attentionp   s5   ZZ*>!
 
 jjoo*;DII;j(Q$%^^89
 	**Av}}=^^##&7		{'$JTU#VVZ^T[[#.::diik*D W [!!$[1w6x.9 WVs   AE**E:	c           	        \         P                  ! R RRR/4      p\        P                  P	                  4       pRV P
                   R2VR&   \        P                  ! \        P                  R.VRR^VR	7      pV P                  VP                  ^ VP                  4       \        P                  P                  RV P
                   R
2^R7      ;_uu_ 4       p\         P                   ! VP#                  4       4      pRRR4       T P                  XR,           Uu. uF  qfR,          NK  	  upRR.4       R#   + '       g   i     LC; iu upi )r   zlmstudio-sessionr   r   ra   rb   rc   zcompanion/lmstudio_notify.pyTrd   ri   rY   Nrj   namer   r   )ro   rp   r(   rq   rr   rN   rs   rt   ru   rv   r   rw   r   rx   ry   rz   r{   r|   )r   r~   rh   r   r   r   r   s   &      r   /test_lmstudio_notify_posts_completion_attentionMAttentionHookIntegrationTests.test_lmstudio_notify_posts_completion_attention   s   ZZ,>!
 
 jjoo*;DII;j(Q$%^^;<
 	**Av}}=^^##&7		{'$JTU#VVZ^::diik*D W4;LM;Lx6**;LMPXZaObc WVMs   %D6E	6E	)rL   rN   rR   N)r6   r7   r8   r9   rU   r^   r   r   r   r:   r;   r<   s   @r   r?   r?   F   s&     	$
E2:4d dr   r?   __main__)builtins@py_builtins_pytest.assertion.rewrite	assertionrewrite
@pytest_arr(   ro   rs   ru   rO   unittesturllib.requestrx   http.serverr   unittest.mockr   	companionr   companion.serverrD   TestCaser   r?   r6   mainr5   r   r   <module>r      sl      	   
    "  $ !4-** 4-nXdH$5$5 Xdv zMMO r   