+
    lHàj?  ã                  óê   € R t ^ RIHt ^ RIt^ RIHt ^ RIHtHt ]P                  ! ]
4      tRtRtRtRt]! RR	7       ! R
 R4      4       tR R ltR R ltR R ltR R ltR R ltRR/R R lltR# )a§  Where this profile's desktop lives: the gateway host or inside the configured terminal backend.

``bot_desktop.placement``:
  ``auto``      (default) follow the terminal backend when it is a sandbox that can host a stream
                (docker / ssh, or a plugin backend declaring ``supports_streams``); the
                gateway host when ``terminal.backend`` is local. A
                sandbox backend that CANNOT host one (modal, daytona, vercel) resolves to ``refused``:
                the user chose a sandbox for the agent's actions, so quietly running the screen, cua-driver
                and the browser on the host beside it would hand the agent a desktop outside that sandbox.
  ``terminal``  always the terminal backend; error when it cannot host one.
  ``gateway``   always the gateway host (the pre-#108914 behaviour for sandboxed users, now an explicit
                opt-in because it is the boundary-crossing shape).

``resolve()`` is pure config + backend-class reasoning: it never starts a sandbox. ``terminal_environment()``
does acquire the profile's terminal environment (creating the container if needed) because a screen cannot
exist before the sandbox does.
)ÚannotationsN)Ú	dataclass)ÚAnyÚOptionalÚgatewayÚterminalÚrefusedT)Úfrozenc                  ó:   € ] tR t^ t$ R]R&   R]R&   RtR]R&   RtR# )Ú	PlacementÚstrÚwhereÚbackendÚ Úreason© N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__annotations__r   Ú__static_attributes__r   ó    Ú@/home/ubuntu/.hermes/hermes-agent/tools/bot_desktop/placement.pyr   r       s   ‡ àƒJØƒLØ€FˆC×r   r   c               ó   € V ^8„  d   QhRR/# ©é   Úreturnr   r   )Úformats   "r   Ú__annotate__r   '   s   € ÷ Eñ E�#ñ Er   c                 óú   € ^ RI Hp  V ! 4       P                  R4      ;'       g    / p\        VP                  R4      ;'       g    R4      P	                  4       P                  4       pVR\        \        39   d   V# R# )é    )Úload_config_readonlyÚbot_desktopÚ	placementÚauto)Úhermes_cli.configr"   Úgetr   ÚstripÚlowerÚTERMINALÚGATEWAY)r"   ÚcfgÚvalues      r   Ú_settingr.   '   sf   € Ý6Ù
Ó
 ×
$Ñ
$ ]Ó
3×
9Ð
9°r€CÜ�—‘˜Ó$×.Ð.¨Ó/×5Ñ5Ó7×=Ñ=Ó?€EØ˜f¤h´Ð8Ô8ˆ5ÐD¸fÐDr   c               ó   € V ^8„  d   QhRR/# r   r   )r   s   "r   r   r   .   s   € ÷ =ñ =˜3ñ =r   c                 ó`   € ^ RI Hp  \        V ! 4       P                  R4      ;'       g    R4      # )r!   ©Ú_get_env_configÚenv_typeÚlocal)Útools.terminal_toolr2   r   r'   r1   s    r   Ú_terminal_backendr6   .   s&   € Ý3Ü‰Ó ×$Ñ$ ZÓ0×;Ð;°GÓ<Ð<r   c               ó    € V ^8„  d   QhRRRR/# )r   r   r   r   Úboolr   )r   s   "r   r   r   3   s   € ÷ Añ A˜Sð A Tñ Ar   c                ó$   € ^ RI Hp V! V R4      RJ # )r!   )Ú_plugin_env_flagÚsupports_streamsT)Útools.terminal_tool_configr:   )r   r:   s   & r   Ú_plugin_streamsr=   3   s   € Ý;Ù˜GÐ%7Ó8¸DÐ@Ð@r   c               ó   € V ^8„  d   QhRR/# )r   r   r8   r   )r   s   "r   r   r   8   s   € ÷ .ñ .˜tñ .r   c                 ó&   € ^ RI Hp Hp V! 4       V 8H  # )r!   ©ÚISOLATION_HOSTÚisolation_mode)Úhermes_cli.plugin_isolationrA   rB   r@   s     r   Ú_plugin_host_isolatedrD   8   s   € ÷ KÙÓ˜~Ñ-Ð-r   c               ó   € V ^8„  d   QhRR/# )r   r   r   r   )r   s   "r   r   r   @   s   € ÷ /ñ /�ñ /r   c                 ó~  € \        4       p V R 8X  d   \        \        V R4      # \        4       pV\        8X  d   \        \        V 4      # V \        9   d   \        \
        V 4      # \        V 4      '       d6   \        4       '       g   \        \
        V 4      # \        \        V RV  R24      # RV  R2p\        \        W4      # )r4   z>terminal.backend is local, so the terminal IS the gateway hostzterminal.backend is a  , a plugin that runs in the plugin host (plugins.isolation: host), and the host cannot hand its sandbox's exec channel to Hermes, so the screen cannot follow it. Set plugins.isolation: in_process, or bot_desktop.placement: gateway to run the desktop on the gateway host.zç, which cannot host a screen yet, and running the desktop on the gateway host would put the agent's screen, browser and computer_use outside the sandbox you chose for it. Set bot_desktop.placement: gateway to allow that explicitly.)	r6   r   r+   r.   Ú_STREAM_BACKENDSr*   r=   rD   ÚREFUSED)r   Úsettingr   s      r   ÚresolverJ   @   s¿   € ô  Ó!€GØ�'ÔÜœ 'Ð+kÓlÐlÜ‹j€GØ”'ÔÜœ 'Ó*Ð*ØÔ"Ô"Üœ 7Ó+Ð+Ü�w×ÒÜ$×&Ò&ÜœX wÓ/Ð/Üœ 'Ø" 7 )ð ,ð óð 	ð
 % W Ið .Uð V€Fô ”W˜gÓ.Ð.r   Úcreatec               ó    € V ^8„  d   QhRRRR/# )r   rK   r8   r   zOptional[Any]r   )r   s   "r   r   r   Y   s   € ÷ 4ñ 4 Dð 4°Mñ 4r   c                ó€  € ^ RI Hp VP                  R4      pVP                  ;_uu_ 4        VP	                  VR4      pRRR4       Xf	   V '       g   V# VP                  RRR7       VP                  ;_uu_ 4        VP	                  VR4      uuRRR4       #   + '       g   i     Lb; i  + '       g   i     R# ; i)z‰This profile's terminal environment object (the one ``terminal`` runs commands in). ``create=False``
only returns an already-running one.)Úterminal_toolNÚtrue)Útask_id)ÚtoolsrN   Ú_resolve_container_task_idÚ	_env_lockÚ_lookup_active_env)rK   ÚttrP   Úenvs   $   r   Úterminal_environmentrW   Y   sŠ   € õ *Ø×+Ñ+¨DÓ1€GØ	��‹Ø×#Ñ# G¨TÓ2ˆ÷ 
à
‚ŸfØˆ
ð ×Ñ�V TÐÔ*Ø	��‹Ø×$Ñ$ W¨dÓ3÷ 
Š÷ 
�ú÷ 
�ˆús   ¬BÁ<B,ÂB)	Â,B=	)ÚdockerÚssh)Ú__doc__Ú
__future__r   ÚloggingÚdataclassesr   Útypingr   r   Ú	getLoggerr   Úloggerr+   r*   rH   rG   r   r.   r6   r=   rD   rJ   rW   r   r   r   Ú<module>ra      s‡   ðñõ" #ã Ý !ß  à	×	Ò	˜8Ó	$€à
€Ø€Ø
€Ø$Ð ñ �$Ô÷ð ó ðõEõ=õ
Aõ
.õ/ð24¨4÷ 4ñ 4r   