Skip to content

AsyncHerdrClient

Asynchronous client for the herdr Unix socket API.

The constructor page is the shortlink hub for the complete asynchronous client reference. Await every operation and use the subscription pages for streaming events.

Constructor

Create an asynchronous client for a Herdr Unix socket.

Parameters:

Name Type Description Default
socket_path str | Path | None

Explicit socket path. When omitted, use Herdr's standard socket resolution order.

None
timeout float

Timeout in seconds for connect, write and read operations.

5.0
session str | None

Named Herdr session to resolve instead of socket_path.

None

Raises:

Type Description
ValueError

If both socket_path and session are provided, or if timeout is not positive.

Example
from herdr_client import AsyncHerdrClient

client = AsyncHerdrClient(session="work", timeout=5.0)
print(client.socket_path)
Source code in src/herdr_client/async_client/client.py
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
def __init__(
    self,
    socket_path: str | Path | None = None,
    timeout: float = 5.0,
    session: str | None = None,
) -> None:
    """Create an asynchronous client for a Herdr Unix socket.

    Args:
        socket_path: Explicit socket path. When omitted, use Herdr's standard
            socket resolution order.
        timeout: Timeout in seconds for connect, write and read operations.
        session: Named Herdr session to resolve instead of ``socket_path``.

    Raises:
        ValueError: If both ``socket_path`` and ``session`` are provided, or if
            ``timeout`` is not positive.

    Example:
        ```python
        from herdr_client import AsyncHerdrClient

        client = AsyncHerdrClient(session="work", timeout=5.0)
        print(client.socket_path)
        ```
    """
    if socket_path is not None and session is not None:
        raise ValueError("socket_path and session are mutually exclusive")
    if timeout <= 0:
        raise ValueError("timeout must be greater than zero")
    self.socket_path = (
        Path(socket_path)
        if socket_path is not None
        else resolve_socket_path(session=session)
    )
    self.timeout = timeout
Method Purpose
request Send a raw or canonical protocol request
ping Check that the server is reachable
workspace_list List workspaces
tab_list List tabs, optionally by workspace
pane_list List panes, optionally by workspace
pane_send_text Send literal text to a pane
pane_send_keys Send named keys to a pane
pane_send_input Send text and keys in one operation
pane_read Read pane output
pane_wait_for_output Wait for matching output
subscribe Open a server-event subscription