+
    ~j                         R t ^ RIHt ^ RIt^ RIt^ RIt^ RIHtHt ^ RI	H
t
 ^ RIHt ^RIHt ]'       d   ^ RIHt ]P"                  ! ]4      tRt ! R	 R
]P*                  4      tR R ltRR/R R lltR R ltR# )uN   ComputerTool — Anthropic computer_use Toolset backed by browser PageActions.)annotationsN)TYPE_CHECKINGAny)rtc)llm)ComputerUse)PageActionsg333333?c                  \   a  ] tR t^tRtRRRR/R V 3R llltR R	 ltR
 V 3R lltRtV ;t	# )ComputerToolzAnthropic computer_use tool backed by browser PageActions.

Usage::

    from livekit.plugins.browser import PageActions

    actions = PageActions(page=page)
    tool = ComputerTool(actions=actions, width=1280, height=720)
widthi   heighti  c               (    V ^8  d   QhRRRRRRRR/# )   actionsr   r   intr   returnNone )formats   "|/Users/mitch_tango/dev/rabbit-r1-livekit/agent/.venv/lib/python3.14/site-packages/livekit/plugins/anthropic/computer_tool.py__annotate__ComputerTool.__annotate__"   s4           	 
   
     c               	L   < \         SV `  R \        W#R7      .R7       Wn        R# )computer)display_width_pxdisplay_height_px)idtoolsN)super__init__r   _actions)selfr   r   r   	__class__s   &$$$r   r    ComputerTool.__init__"   s,     	PQ 	 	
  r   c               $    V ^8  d   QhRRRRRR/# )r   actionstrkwargsr   r   list[dict[str, Any]]r   )r   s   "r   r   r   /   s"     >* >*C >*3 >*;O >*r   c                
  "   V P                   pT;R8X  d    EM;R8X  d;    \        V4      w  rEVP                  WEVP                  R4      R7      G Rj  xL
  EM;R8X  d*    \        V4      w  rEVP	                  WE4      G Rj  xL
  EM;R8X  d*    \        V4      w  rEVP                  WE4      G Rj  xL
  EM[;R8X  d*    \        V4      w  rEVP                  WE4      G Rj  xL
  EM+;R	8X  d*    \        V4      w  rEVP                  WE4      G Rj  xL
  EM;R
8X  d*    \        V4      w  rEVP                  WE4      G Rj  xL
  EM;R8X  d;    \        VRR7      w  rg\        V4      w  rVP                  WgWR7      G Rj  xL
  EM;R8X  d*    \        V4      w  rEVP                  WE4      G Rj  xL
  EMZ;R8X  d*    \        V4      w  rEVP                  WE4      G Rj  xL
  EM*;R8X  dV    \        V4      w  rEVP                  VVVP                  RR4      \        VP                  R^4      4      R7      G Rj  xL
  M;R8X  d&    VP                  \        VR4      4      G Rj  xL
  M;R8X  d&    VP!                  \        VR4      4      G Rj  xL
  Mv;R8X  dA    VP#                  \        VR4      \%        VP                  RR4      4      R7      G Rj  xL
  M/R8X  d   VP'                  4       G Rj  xL
  M \)        RV: 24      h\*        P,                  ! \.        4      G Rj  xL
  VP0                  p
V
f   RRRR/.# \3        V
4      #  EL EL EL EL ELR EL% EL EL EL EL3 EL
 L L L~ LM5i)zHDispatch an Anthropic computer_use action and return screenshot content.
screenshot
left_clicktext)	modifiersNright_clickdouble_clicktriple_clickmiddle_click
mouse_moveleft_click_dragstart_coordinate)key)start_xstart_yend_xend_yleft_mouse_downleft_mouse_upscrollscroll_directiondownscroll_amount)	directionamounttyper6   hold_keydurationg      ?)rE   waitzUnknown computer_use action: z(no frame available yet))r!   _require_coordinater,   getr/   r0   r1   r2   r3   r4   r;   r<   r=   r   	type_text_requirer6   rD   floatrF   
ValueErrorasynciosleep_POST_ACTION_DELAY
last_frame_screenshot_content)r"   r&   r(   r   xysxsyexeyframes   &&,        r   executeComputerTool.execute/   s    --*62((F9K(LLL*62))!///*62**1000*62**1000*62**1000*62((...",V9KL,V4--bB-YYY"*62--a333 *62++A111*62nn$jj);VDvzz/1=>	 %    ''(@AAAkk(66":;;;&&VV,"6::j##>? '    lln$$ #@
!KLLmm.///""=VV-GHII"5))k M 0 1 1 1 / Z 4 2 B;
 % 	0s  ANM/NM/N4M 5/N$M#%/NM&/NM)A NM,/N5M/6/N%M2&ANM5+N.M8/+NM;AN!M="N M?2N3N4'NN N#N&N)N,N/N2N5N8N;N=N?NNc                   V ^8  d   QhRR/# )r   r   r   r   )r   s   "r   r   r   o   s      d r   c                	t   <"   \         SV `  4       G R j  xL
  V P                  P                  4        R #  L 5i)N)r   acloser!   )r"   r#   s   &r   r]   ComputerTool.acloseo   s+     gn 	s   86!8)r!   )
__name__
__module____qualname____firstlineno____doc__r    rY   r]   __static_attributes____classcell__)r#   s   @r   r
   r
      s6      	 
    >*@ r   r
   c               $    V ^8  d   QhRRRRRR/# )r   r(   dict[str, Any]r6   r'   r   r   r   )r   s   "r   r   r   t   s!      ^ # # r   c                <    W9  d   \        RV: 24      hW,          # )z;Extract a required argument, raising ValueError if missing.zMissing required argument: )rL   )r(   r6   s   &&r   rJ   rJ   t   s#    
6sg>??;r   r6   
coordinatec               $    V ^8  d   QhRRRRRR/# )r   r(   rg   r6   r'   r   ztuple[int, int]r   )r   s   "r   r   r   {   s!     ( ( ( ( (r   c               `    \        W4      p\        V^ ,          4      \        V^,          4      3# )zDExtract and unpack a coordinate pair from Anthropic's [x, y] format.)rJ   r   )r(   r6   coords   &$ r   rG   rG   {   s'    V!EuQx=#eAh-''r   c                    V ^8  d   QhRRRR/# )r   rX   zrtc.VideoFramer   r)   r   )r   s   "r   r   r      s      ~ 2F r   c           	         ^ RI HpHp V! W! RR7      4      p\        P                  ! V4      P                  R4      pRRRRRR	R
RV//.# )z=Build Anthropic tool_result content blocks with a screenshot.)EncodeOptionsencodePNG)r   zutf-8rC   imagesourcebase64
media_typez	image/pngdata)livekit.agents.utils.imagesro   rp   rt   	b64encodedecode)rX   ro   rp   	png_bytesb64s   &    r   rQ   rQ      s^    Aum59:I


9
%
,
,W
5C Gk	
	 	r   )rc   
__future__r   rM   rt   loggingtypingr   r   livekitr   livekit.agentsr   r   r   livekit.plugins.browserr   	getLoggerr_   loggerrO   Toolsetr
   rJ   rG   rQ   r   r   r   <module>r      se    T "    %   3			8	$ Z3;; Zz(l (r   