+
    lHàj#  ã                  óì   € R t ^ RIHt ^ RIt^ RIHtHt ^ RIHtH	t	 ^ RI
HtHtHtHtHt ^ RIHt ] ! R R4      4       t] ! R	 R
4      4       t] ! R R4      4       t ! R R]4      t ! R R]4      tR# )aƒ  Abstract backend interface for computer use. Any implementation (cua-driver over MCP, a plugin
driver, the test noop) returns the shapes below. All methods are synchronous; async is handled inside
the backend implementation if needed. :class:`ComputerUseProvider` is the factory a provider plugin
registers (see :mod:`plugins.computer_use`); ``computer_use.backend`` selects exactly one.)ÚannotationsN)ÚABCÚabstractmethod)Ú	dataclassÚfield)ÚAnyÚDictÚListÚOptionalÚTuple)ÚProviderBasec                  ó    € ] tR t^t$ RtR]R&   R]R&   RtR]R&   RtR]R	&   RtR]R
&   ^ t	R]R&   ^ t
R]R&   ]! ]R7      tR]R&   RtR]R&   RtR# )Ú	UIElementz/One interactable element on the current screen.ÚintÚindexÚstrÚroleÚ Úlabelztuple[int, int, int, int]ÚboundsÚappÚpidÚ	window_id©Údefault_factoryúdict[str, Any]Ú
attributesNúOptional[str]Úelement_token© )é    r    r    r    )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú__annotations__r   r   r   r   r   r   Údictr   r   Ú__static_attributes__r   ó    Ú?/home/ubuntu/.hermes/hermes-agent/tools/computer_use/backend.pyr   r      sZ   ‡ á9àƒJØ
ƒIØ€Eˆ3ƒOØ(4€FÐ%Ó4Ø€CˆƒMØ€CˆƒLØ€IˆsÓÙ!&°tÔ!<€J�Ó<ð $(€M�=×'r)   r   c                  ó¸   € ] tR t^"t$ RtR]R&   R]R&   R]R&   RtR]R	&   ]! ]R
7      t	R]R&   Rt
R]R&   RtR]R&   ^ tR]R&   RtR]R&   RtR]R&   ^ tR]R&   RtR# )ÚCaptureResultuø   Result of a screen capture call. mode="vision" â†’ png_b64 only; mode="ax" â†’ elements
only; mode="som" (default) â†’ both: the PNG already carries numbered overlays drawn by
the backend and `elements` holds the matching index â†’ element mapping.r   Úmoder   ÚwidthÚheightNr   Úpng_b64r   zlist[UIElement]Úelementsr   r   Úwindow_titleÚpng_bytes_lenÚimage_mime_typeÚnoteÚax_max_elementsr   )r!   r"   r#   r$   r%   r&   r0   r   Úlistr1   r   r2   r3   r4   r5   r6   r(   r   r)   r*   r,   r,   "   sr   ‡ ñPð ƒIØƒJØƒKØ!€Gˆ]Ó!Ù %°dÔ ;€HˆoÓ;Ø€CˆƒMØ€L�#ÓØ€M�3Óð &*€O�]Ó)ð €Dˆ#ƒNð €O�S×r)   r,   c                  óÊ   € ] tR t^<t$ RtR]R&   R]R&   RtR]R&   RtR	]R
&   ]! ]	R7      t
R]R&   RtR]R&   RtR]R&   RtR]R&   RtR]R&   RtR]R&   RtR]R&   RtR]R&   RtR# )ÚActionResultuL  Result of any action (click / type / scroll / drag / key / wait). ``ok`` is
tool/transport success only â€” NOT the semantic verdict; read ``effect`` / ``escalation``
(cua-driver's structured verdict) to pick the next rung of the verify â†’ escalate ladder.
Structured fields are optional and additive: an older driver that omits
``structuredContent`` leaves them ``None``, behavior unchanged.

Beyond the transport-level ``ok`` flag, this carries cua-driver's structured action verdict so the model
can follow the documented verify â†’ escalate ladder (NousResearch/hermes-agent#67052).
ÚboolÚokr   Úactionr   ÚmessageNzOptional[CaptureResult]Úcapturer   r   ÚmetazOptional[bool]Úverifiedr   ÚeffectzOptional[dict[str, Any]]Ú
escalationÚpathÚdegradedÚdelivery_modeÚcoder   )r!   r"   r#   r$   r%   r&   r=   r>   r   r'   r?   r@   rA   rB   rC   rD   rE   rF   r(   r   r)   r*   r9   r9   <   s~   ‡ ñð 	ƒHØƒKØ€GˆSÓØ'+€GÐ$Ó+Ù °Ô6€Dˆ.Ó6Ø#€HˆnÓ#Ø €FˆMÓ à+/€JÐ(Ó/Ø€Dˆ-ÓØ#€HˆnÓ#Ø#'€M�=Ó'Ø€Dˆ-×r)   r9   c                  óÆ  € ] tR t^WtRt]R R l4       t]R R l4       t]R R l4       t]R/R	 R
 ll4       t	]RRRRRRRRR^RRRRRR/R R ll4       t
]RRRRRRRRRRRRRRRR/R R ll4       t]R^RRRRRRRRRRRR/R R ll4       t]RRRR/R  R! ll4       t]RRRR/R" R# ll4       t]R$ R% l4       tR& R' lt]R0R( R) ll4       t]R1R* R+ ll4       tR, R- ltR.tR# )2ÚComputerUseBackenda¯  Lifecycle: `start()` before first use, `stop()` at shutdown. Pointer/keyboard actions
take ``delivery_mode`` (background (default) | foreground) and ``bring_to_front``;
``button`` is left | right | middle; ``modifiers`` a list of key names. ``element`` args
are 1-based SOM indices from a prior capture. `direction` is up | down | left | right and
`amount` is wheel ticks; `keys` is a combo such as 'cmd+s', 'ctrl+alt+t', 'return'.c               ó   € V ^8„  d   QhRR/# ©é   ÚreturnÚNoner   )Úformats   "r*   Ú__annotate__ÚComputerUseBackend.__annotate___   s   € × Ñ �tÑ r)   c                	ó   € R # ©Nr   ©Úselfs   &r*   ÚstartÚComputerUseBackend.start^   s   € Ù r)   c               ó   € V ^8„  d   QhRR/# rJ   r   )rN   s   "r*   rO   rP   b   s   € ×Ñ�dÑr)   c                	ó   € R # rR   r   rS   s   &r*   ÚstopÚComputerUseBackend.stopa   s   € Ùr)   c               ó   € V ^8„  d   QhRR/# ©rK   rL   r:   r   )rN   s   "r*   rO   rP   e   s   € ×'Ñ'˜dÑ'r)   c                	ó   € R # rR   r   rS   s   &r*   Úis_availableÚComputerUseBackend.is_availabled   s   € Ù$'r)   Nc          
     ó,   € V ^8„  d   QhRRRRRRRRRR	/# )
rK   r-   r   r   r   r   úOptional[int]r   rL   r,   r   )rN   s   "r*   rO   rP   h   s8   € ÷ Gñ G˜Cð G¨mð GÈð GØ(ðGØ4AñGr)   c                	ó   € R # rR   r   )rT   r-   r   r   r   s   &&&&&r*   r>   ÚComputerUseBackend.captureg   s   € áCFr)   ÚelementÚxÚyÚbuttonÚleftÚclick_countÚ	modifiersrE   Úbring_to_frontFc               ó<   € V ^8„  d   QhRRRRRRRRRRR	R
RRRRRR/	# )rK   rd   ra   re   rf   rg   r   ri   r   rj   úOptional[list[str]]rE   r   rk   r:   rL   r9   r   )rN   s   "r*   rO   rP   l   s]   € ÷ fñ f ð f¸ð fÐR_ð fØðfØ14ðfØEXðfà*ðfàCGðfàT`ñfr)   c               	ó   € R # rR   r   )	rT   rd   re   rf   rg   ri   rj   rE   rk   s	   &$$$$$$$$r*   ÚclickÚComputerUseBackend.clickk   s	   € ñ cfr)   Úfrom_elementÚ
to_elementÚfrom_xyÚto_xyc               ó<   € V ^8„  d   QhRRRRRRRRRRR	R
RRRRRR/	# )rK   rq   ra   rr   rs   zOptional[tuple[int, int]]rt   rg   r   rj   rm   rE   r   rk   r:   rL   r9   r   )rN   s   "r*   rO   rP   q   sg   € ÷ eñ e Mð eÀmð eØ/ðeØ?Xðeàðeà.Aðeð *ðeð CGðeð T`ñer)   c               	ó   € R # rR   r   )	rT   rq   rr   rs   rt   rg   rj   rE   rk   s	   &$$$$$$$$r*   ÚdragÚComputerUseBackend.dragp   s	   € ñ ber)   Úamountc               ó<   € V ^8„  d   QhRRRRRRRRRRR	R
RRRRRR/	# )rK   Ú	directionr   ry   r   rd   ra   re   rf   rj   rm   rE   r   rk   r:   rL   r9   r   )rN   s   "r*   rO   rP   w   s\   € ÷ gñ g 3ð g°ð gÀ-ð gØðgØ+8ðgØL_ðgà+ðgàDHðgàUañgr)   c               	ó   € R # rR   r   )	rT   r{   ry   rd   re   rf   rj   rE   rk   s	   &$$$$$$$$r*   ÚscrollÚComputerUseBackend.scrollv   s	   € ñ dgr)   c               ó(   € V ^8„  d   QhRRRRRRRR/# )	rK   Útextr   rE   r   rk   r:   rL   r9   r   )rN   s   "r*   rO   rP   |   s0   € ÷ Eñ E˜cð E°]ð EØ"&ðEØ3?ñEr)   c               	ó   € R # rR   r   )rT   r€   rE   rk   s   &&$$r*   Ú	type_textÚComputerUseBackend.type_text{   s   € áADr)   c               ó(   € V ^8„  d   QhRRRRRRRR/# )	rK   Úkeysr   rE   r   rk   r:   rL   r9   r   )rN   s   "r*   rO   rP   €   s   € ×wÑw˜Ðw¨}ÐwÐUYÐwÐfrÑwr)   c               	ó   € R # rR   r   )rT   r…   rE   rk   s   &&$$r*   ÚkeyÚComputerUseBackend.key   s   € Ùtwr)   c               ó   € V ^8„  d   QhRR/# ©rK   rL   zlist[dict[str, Any]]r   )rN   s   "r*   rO   rP   ƒ   s   € ×4Ñ4Ð/Ñ4r)   c                	ó   € R # rR   r   rS   s   &r*   Ú	list_appsÚComputerUseBackend.list_apps‚   s   € Ù14r)   c               ó   € V ^8„  d   QhRR/# rŠ   r   )rN   s   "r*   rO   rP   …   s   € ÷ ñ Ð2ñ r)   c                ó   € . # )zžVisible native windows with PID and window identifiers. Optional compatibility hook: backends that
predate window discovery stay instantiable and report none.r   rS   s   &r*   Úlist_windowsÚComputerUseBackend.list_windows…   s	   € ð ˆ	r)   c               ó$   € V ^8„  d   QhRRRRRR/# )rK   r   r   Úraise_windowr:   rL   r9   r   )rN   s   "r*   rO   rP   ‹   s   € ×RÑR˜SÐR°ÐRÀÑRr)   c                	ó   € R # rR   r   )rT   r   r“   s   &&&r*   Ú	focus_appÚComputerUseBackend.focus_appŠ   s   € ÙORr)   c               ó$   € V ^8„  d   QhRRRRRR/# )rK   Úvaluer   rd   ra   rL   r9   r   )rN   s   "r*   rO   rP   Ž   s   € ×WÑW˜sÐW¨]ÐWÀlÑWr)   c                	ó   € R # rR   r   )rT   r˜   rd   s   &&&r*   Ú	set_valueÚComputerUseBackend.set_value�   s   € ÙTWr)   c               ó    € V ^8„  d   QhRRRR/# )rK   ÚsecondsÚfloatrL   r9   r   )rN   s   "r*   rO   rP   �   s   € ÷ Vñ V˜Eð V lñ Vr)   c           	     	ó|   € \         P                  ! \        R \        VR4      4      4       \	        RRRVR R2R7      # )g        g      >@TÚwaitzwaited z.2fÚs)r;   r<   r=   )ÚtimeÚsleepÚmaxÚminr9   )rT   r�   s   &&r*   r    ÚComputerUseBackend.wait�   s7   € Ü�
Š
”3�sœC ¨Ó.Ó/Ô0Ü˜t¨F¸gÀgÈcÀ]ÐRSÐ<TÔUÐUr)   r   )ÚsomNNN)FrR   )r!   r"   r#   r$   r%   r   rU   rY   r^   r>   ro   rw   r}   r‚   r‡   rŒ   r�   r•   rš   r    r(   r   r)   r*   rH   rH   W   sÚ  † ñ[ð Ü ó Ø àÜó ØàÜ'ó Ø'àöGó ðGð ðf°ð fÈð fÐbfð fØ"ðfØ78ðfØ[_ðfà-1ðfàJOöfó ðfð ðe°Dð eÐVZð eØ26ðeØ[_ðeà!ðeàDHðeð -1ðeð JOöeó ðeð
 ðg°að gÐRVð gØ"&ðgØ;?ðgØbfðgà.2ðgàKPögó ðgð ðEÀTð EØ).öEó ðEð Øw¸tÐwÐ\aÖwó ØwàÜ4ó Ø4õð
 ÞRó ØRàÞWó ØW÷Vñ Vr)   rH   c                  óH   € ] tR t^•tRt]R R l4       tR R ltR R ltRt	R	# )
ÚComputerUseProvideraÜ  Factory for one computer_use driver, registered via ``ctx.register_computer_use_provider`` from a provider
plugin whose directory name is the ``computer_use.backend`` value (built-in: ``plugins/computer_use/cua``). Only
the selected provider is imported and instantiated. The model-facing tool schema is identical for every backend:
an action the driver cannot perform returns ``ActionResult(ok=False, code="unsupported_action", message=...)``
rather than changing the schema.c               ó    € V ^8„  d   QhRRRR/# )rK   Úpermission_moder   rL   rH   r   )rN   s   "r*   rO   Ú ComputerUseProvider.__annotate__�   s   € ÷ jñ j°ð jÐ9Kñ jr)   c               ó   € R# )z¹A fresh, unstarted backend for one Hermes session (the tool calls ``start()``/``stop()``).
``permission_mode`` is ``standard`` | ``bounded`` | ``unrestricted`` (approval bypass active).Nr   )rT   r«   s   &$r*   Úcreate_backendÚ"ComputerUseProvider.create_backendœ   s   ‚ r)   c               ó   € V ^8„  d   QhRR/# r\   r   )rN   s   "r*   rO   r¬   ¡   s   € ÷ ñ ˜dñ r)   c                ó   € R# )zXUsable on this host right now (the tool's ``check_fn``). Cheap: no network, no spawning.Tr   rS   s   &r*   r^   Ú ComputerUseProvider.is_available¡   s   € ár)   c               ó   € V ^8„  d   QhRR/# )rK   rL   ra   r   )rN   s   "r*   rO   r¬   ¥   s   € ÷ ñ ˜ñ r)   c                ó   € R# )zŒ``hermes computer-use doctor`` for this backend: print findings, return the exit code.
``None`` (default) means the backend ships no doctor.Nr   rS   s   &r*   ÚdoctorÚComputerUseProvider.doctor¥   s   € ñ r)   r   N)
r!   r"   r#   r$   r%   r   r®   r^   rµ   r(   r   r)   r*   r©   r©   •   s,   † ñ(ð ôjó ðjõ÷ñ r)   r©   )r%   Ú
__future__r   r¢   Úabcr   r   Údataclassesr   r   Útypingr   r   r	   r
   r   Úagent.provider_baser   r   r,   r9   rH   r©   r   r)   r*   Ú<module>r¼      sˆ   ðñ^õ
 #ã ß #ß (ß 3Õ 3å ,ð ÷(ð (ó ð(ð" ÷ð ó ðð2 ÷ð ó ðô4;V˜ô ;Vô|˜,ö r)   