
    `gj                    P    d Z ddlmZ  eh d      ZddZ	 	 	 	 	 	 	 	 	 	 	 	 ddZy)	u  Resolve gateway ``terminal.cwd`` placeholder values to ``TERMINAL_CWD``.

When ``terminal.cwd`` is unset or a placeholder (``.``, ``auto``, ``cwd``),
the gateway must not blindly map host ``Path.home()`` into container backends.
Docker with workspace mounting still needs an explicit host path signal
(``MESSAGING_CWD`` or an absolute config path) for ``terminal_tool`` to map
``/host/project`` → ``/workspace``.
    )annotations>   cwdauto.c                J    | xs dj                         j                         dv S )N >   1yestrue)striplower)values    J/root/.hermes/venv/lib/python3.12/site-packages/gateway/cwd_placeholder.py_truthy_envr      s$    KR &&(,@@@    c                    | r
| t         vr| S |xs dj                         j                         }|dk(  r|xs dj                         }|xs |S |dk(  r"|r |xs dj                         }|r
|t         vr|S y)u  Return the ``TERMINAL_CWD`` value to set, or ``None`` to leave it unset.

    Cases:
      - **local** + placeholder → ``MESSAGING_CWD`` or ``home_fallback``
      - **docker** + placeholder + mount on + host ``MESSAGING_CWD`` → host path
        (for ``terminal_tool`` ``/workspace`` mapping)
      - **docker** + placeholder + mount off → ``None`` (sandbox default)
      - other non-local backends + placeholder → ``None``
    localr   dockerN)CWD_PLACEHOLDERSr   r   )configured_cwdterminal_backendmessaging_cwddocker_mount_cwd_to_workspacehome_fallbackbackend	messagings          r    resolve_placeholder_terminal_cwdr      s    " .0@@*711399;G'"(b//1	)M)(<"(b//1	*::r   N)r   
str | Nonereturnbool)r   strr   r!   r   r   r   r    r   r!   r   r   )__doc__
__future__r   	frozensetr   r   r    r   r   <module>r&      s`    #12 A  	
 $(  r   