+
    iHàj1  ã                  ó\   € R t ^ RIHt ^ RIt^ RIHtHtHtHtH	t	 ^ RI
Ht  ! R R]4      tR# )u·  Terminal Environment Provider ABC.

Pluggable-backend interface for terminal execution environments (cloud sandboxes, remote
runners). Providers register via :meth:`PluginContext.register_terminal_environment_provider`;
:func:`tools.terminal_tool_backends._create_environment` consults the registry for any ``TERMINAL_ENV``
/ ``terminal.backend`` value that is not a built-in (built-ins stay in ``tools/environments/``;
third-party sandbox vendors do NOT have to live in core). :meth:`create_environment` returns
any ``BaseEnvironment`` duck type (``execute()``, ``cleanup()`` â€¦); the factory stamps
``_hermes_backend_name`` on the result so file-path resolution can identify plugin backends.
)ÚannotationsN)ÚAnyÚDictÚListÚOptionalÚTuple)ÚProviderBasec                  óx  € ] tR t^t$ RtRtR]R&   RtR]R&   RtR]R&   Rt	R]R&   ]
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]P$                  R R l4       tR R ltR R ltR R ltR R ltR R  lt]P$                  R!R"R#R$R%R$/R& R' ll4       tR(tR$# ))ÚTerminalEnvironmentProviderué	  Abstract base class for a pluggable terminal execution backend.

:attr:`name` is the ``terminal.backend`` / ``TERMINAL_ENV`` value (``[a-z0-9_]``); the
registry rejects built-in backend names.

Classification contract â€” each core policy decision that was historically a frozenset of
built-in names is a declarative attribute so a new backend cannot silently miss one:

* ``is_remote`` â€” commands run off-host: suppresses host OS/home/cwd hints in the system
  prompt, the host Python probe, and remote-aware skill env handling.
* ``is_container`` â€” own filesystem rooted away from the host: container resource config
  passed through, host-looking cwds sanitized, file tools use container path resolution.
* ``skip_container_guards`` â€” sandbox disposable enough to skip dangerous-command approval
  prompts. Defaults to ``is_container``; backends that can mount host paths override to False.
* ``cache_path_base`` â€” where auto-synced ``~/.hermes/cache`` files land inside the backend
  (``"~/.hermes"``, ``"/root/.hermes"``), or ``None`` when host paths remain correct.
* ``strip_env_keys`` â€” vendor credential env vars, stripped from every subprocess the agent
  spawns so a model-authored command can never read them.
* ``session_isolated_when_nonpersistent`` â€” non-persistent mode gives each session its own
  sandbox identity; opt in when a shared name would let two ephemeral runs destroy each other.
* ``default_cwd`` â€” where commands start when ``terminal.cwd`` is unset or unusable there: an
  absolute in-sandbox path, or ``"~"`` for each sandbox's own home. With ``"~"``,
  ``create_environment`` receives ``cwd="~"`` (never expanded on the host) and the environment sets
  ``self.cwd`` to the absolute home it resolved; commands may also arrive with ``cwd="~"``.
  ``None`` keeps the generic ``/root``.
* ``supports_streams`` â€” environments implement ``exec_prefix(*, user=None, interactive=True)``:
  a local argv that runs its remainder (``bash -c <script>``, passed through as separate words)
  inside the sandbox with stdin/stdout open, or ``None`` when it cannot right now. Bot Desktop,
  ``computer_use`` and the browser then follow the terminal into this backend, as they do for
  docker/ssh, instead of refusing.

``default_cwd`` home resolution and ``exec_prefix`` need the environment object itself, so they
work for in-process plugins only; under ``plugins.isolation: host`` the environment reaches Hermes
as an opaque placeholder and Bot Desktop placement refuses a ``supports_streams`` backend.
TÚboolÚ	is_remoteÚis_containerFÚ#session_isolated_when_nonpersistentÚsupports_streamsc               ó   € V ^8„  d   QhRR/# ©é   ÚreturnÚstr© )Úformats   "Ú@/home/ubuntu/.hermes/hermes-agent/agent/terminal_env_provider.pyÚ__annotate__Ú(TerminalEnvironmentProvider.__annotate__?   s   € ÷ Eñ E˜Sñ Eó    c                ó"   € RV P                    R2# )z.One-line description shown in backend pickers.zRun commands in a z environment.©Údisplay_name©Úselfs   &r   ÚdescriptionÚ'TerminalEnvironmentProvider.description>   s   € ð $ D×$5Ñ$5Ð#6°mÐDÐDr   c               ó   € V ^8„  d   QhRR/# ©r   r   r   r   )r   s   "r   r   r   D   s   € ÷ !ñ ! tñ !r   c                	ó   € V P                   # ©N)r   r   s   &r   Úskip_container_guardsÚ1TerminalEnvironmentProvider.skip_container_guardsC   s   € à× Ñ Ð r   c               ó   € V ^8„  d   QhRR/# ©r   r   úOptional[str]r   )r   s   "r   r   r   H   s   € ÷ ñ  ñ r   c                	ó   € R # r%   r   r   s   &r   Úcache_path_baseÚ+TerminalEnvironmentProvider.cache_path_baseG   ó   € ár   c               ó   € V ^8„  d   QhRR/# r)   r   )r   s   "r   r   r   L   s   € ÷ ñ ˜]ñ r   c                	ó   € R # r%   r   r   s   &r   Údefault_cwdÚ'TerminalEnvironmentProvider.default_cwdK   r.   r   c               ó   € V ^8„  d   QhRR/# )r   r   Ú	frozensetr   )r   s   "r   r   r   P   s   € ÷ ñ  	ñ r   c                	ó   € \        4       # r%   )r4   r   s   &r   Ústrip_env_keysÚ*TerminalEnvironmentProvider.strip_env_keysO   s
   € ä‹{Ðr   c               ó   € V ^8„  d   QhRR/# r   r   )r   s   "r   r   r   T   s   € ÷ Cñ C ñ Cr   c                ó"   € RV P                    R2# )zrPrompt-builder fallback for where commands run when the live probe fails (e.g. ``"a Daytona workspace (Linux)"``).za z environment (likely Linux)r   r   s   &r   Úenv_descriptionÚ+TerminalEnvironmentProvider.env_descriptionS   s   € ð �D×%Ñ%Ð&Ð&AÐBÐBr   c               ó   € V ^8„  d   QhRR/# r#   r   )r   s   "r   r   r   Y   s   € ÷ kñ k˜dñ kr   c                ó   € R# )z\True when this backend can service commands. Cheap, NO network calls: runs during UI paints.Nr   r   s   &r   Úis_availableÚ(TerminalEnvironmentProvider.is_availableX   ó   ‚ r   c               ó    € V ^8„  d   QhRRRR/# )r   Úconfigzdict[str, Any]r   r   r   )r   s   "r   r   r   \   s   € ÷ #ñ #¨ð #¸Dñ #r   c                ó"   € V P                  4       # )zjFull requirements check with the merged terminal env config; log actionable errors before returning False.)r>   )r   rB   s   &&r   Úcheck_requirementsÚ.TerminalEnvironmentProvider.check_requirements\   s   € à× Ñ Ó"Ð"r   c               ó   € V ^8„  d   QhRR/# )r   r   ztuple[str, str]r   )r   s   "r   r   r   `   s   € ÷ tñ t�ñ tr   c                óT   € V P                  4       '       d   R# RV P                   R23# )zrDashboard picker health ``(status, detail)``; status ``ready``/``needs_setup``/``unavailable``. Never raise; <~2s.Úneeds_setupz is not configured.)ÚreadyÚ )r>   r   r   s   &r   ÚprobeÚ!TerminalEnvironmentProvider.probe`   s/   € à $× 1Ñ 1× 3Ò 3ˆ}Ðs¸-ÈD×L]ÑL]ÐK^Ð^qÐIrÐ9sÐsr   c               ó   € V ^8„  d   QhRR/# )r   r   z	list[str]r   )r   s   "r   r   r   d   s   € ÷ ñ  Iñ r   c                ó   € . # )zdLines printed by ``hermes setup`` after selection (the wizard persists ``terminal.backend`` itself).r   r   s   &r   Úsetup_instructionsÚ.TerminalEnvironmentProvider.setup_instructionsd   s   € àˆ	r   c               ó   € V ^8„  d   QhRR/# )r   r   ÚNoner   )r   s   "r   r   r   h   s   € ÷ sñ s˜Dñ sr   c                ó   € R# )zdOptional interactive hook run by ``hermes setup`` after selection (prompt for tokens, install SDKs).Nr   r   s   &r   Ú
post_setupÚ&TerminalEnvironmentProvider.post_setuph   r@   r   c               ó   € V ^8„  d   QhRR/# )r   r   zlist[tuple[bool, str, str]]r   )r   s   "r   r   r   k   s   € ÷ ñ Ð:ñ r   c                ó˜   €  \        V P                  4       4      pYP                   R2V'       d   R3.# R3.#   \         d    Rp L-i ; i)zV``hermes doctor`` rows ``(ok, label, detail)``; default reflects :meth:`is_available`.Fz backendz(configured)u+   (not configured â€” see setup instructions))r   r>   Ú	Exceptionr   )r   Úoks   & r   Údoctor_checksÚ)TerminalEnvironmentProvider.doctor_checksk   s\   € ð	Ü�d×'Ñ'Ó)Ó*ˆBð ×)Ñ)Ð*¨(Ð3Çr°^Ð}Ð~Ð~ÐO|Ð}Ð~Ð~øô ô 	ØŠBð	ús   ‚9 ¹A	ÁA	Útask_idÚdefaultÚimageNÚcontainer_configc               ó0   € V ^8„  d   QhRRRRRRRRRR	R
R/# )r   Úcwdr   ÚtimeoutÚintr\   r^   r*   r_   zOptional[dict[str, Any]]Úkwargsr   r   )r   s   "r   r   r   t   sD   € ÷ lñ lØðlØ$'ðlØ25ðlØJWðlà2ðlàEHñlr   c               ó   € R# )a0  Create an execution environment (``BaseEnvironment`` duck type). MUST accept ``**kwargs`` and ignore
unknown keys so the factory can evolve without breaking older plugins. ``task_id`` keys reuse/persistence;
``container_config`` carries ``container_cpu/memory/disk/persistent`` when :attr:`is_container`.Nr   )r   ra   rb   r\   r^   r_   rd   s   &$$$$$,r   Úcreate_environmentÚ.TerminalEnvironmentProvider.create_environments   r@   r   r   )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   Ú__annotations__r   r   r   Úpropertyr    r&   r,   r1   r6   r:   ÚabcÚabstractmethodr>   rD   rK   rO   rT   rZ   rf   Ú__static_attributes__r   r   r   r
   r
      s  ‡ ñ"ðH €IˆtÓØ€L�$ÓØ05Ð'¨Ó5Ø"Ð�dÓ"àôEó ðEð ô!ó ð!ð ôó ðð ôó ðð ôó ðð ôCó ðCð 	×Ñôkó ðkõ#õtõõsõð 	×ÑðlØ8AðlØZ^ðlà59öló ôlr   r
   )rl   Ú
__future__r   ro   Útypingr   r   r   r   r   Úagent.provider_baser   r
   r   r   r   Ú<module>ru      s+   ðñ	õ #ã 
ß 3Õ 3å ,ôfl ,ö flr   