Skip to content

Transport

Sub classes

Name Children Inherits
SubprocessCLITransport
clawd_code_sdk._internal.transport.subprocess_cli
Subprocess transport using Claude Code CLI.

    Base classes

    Name Children Inherits
    ABC
    abc
    Helper class that provides a standard way to create an ABC using

    ⋔ Inheritance diagram

    graph TD
      1708862286["transport.Transport"]
      925645236["abc.ABC"]
      2751680898["builtins.object"]
      925645236 --> 1708862286
      2751680898 --> 925645236

    🛈 DocStrings

    Bases: ABC

    Abstract transport for Claude communication.

    WARNING: This internal API is exposed for custom transport implementations (e.g., remote Claude Code connections). The Claude Code team may change or or remove this abstract class in any future release. Custom implementations must be updated to match interface changes.

    This is a low-level transport interface that handles raw I/O with the Claude process or service. The Query class builds on top of this to implement the control protocol and message routing.

    Source code in src/clawd_code_sdk/_internal/transport/__init__.py
    class Transport(ABC):
        """Abstract transport for Claude communication.
    
        WARNING: This internal API is exposed for custom transport implementations
        (e.g., remote Claude Code connections). The Claude Code team may change or
        or remove this abstract class in any future release. Custom implementations
        must be updated to match interface changes.
    
        This is a low-level transport interface that handles raw I/O with the Claude
        process or service. The Query class builds on top of this to implement the
        control protocol and message routing.
        """
    
        @abstractmethod
        async def connect(self) -> None:
            """Connect the transport and prepare for communication.
    
            For subprocess transports, this starts the process.
            For network transports, this establishes the connection.
            """
    
        @abstractmethod
        async def write(self, data: str) -> None:
            """Write raw data to the transport.
    
            Args:
                data: Raw string data to write (typically JSON + newline)
            """
    
        @abstractmethod
        def read_messages(self) -> AsyncIterator[dict[str, Any]]:
            """Read and parse messages from the transport.
    
            Yields:
                Parsed JSON messages from the transport
            """
    
        @abstractmethod
        async def close(self) -> None:
            """Close the transport connection and clean up resources."""
    
        @abstractmethod
        async def end_input(self) -> None:
            """End the input stream (close stdin for process transports)."""
    

    close abstractmethod async

    close() -> None
    

    Close the transport connection and clean up resources.

    Source code in src/clawd_code_sdk/_internal/transport/__init__.py
    @abstractmethod
    async def close(self) -> None:
        """Close the transport connection and clean up resources."""
    

    connect abstractmethod async

    connect() -> None
    

    Connect the transport and prepare for communication.

    For subprocess transports, this starts the process. For network transports, this establishes the connection.

    Source code in src/clawd_code_sdk/_internal/transport/__init__.py
    @abstractmethod
    async def connect(self) -> None:
        """Connect the transport and prepare for communication.
    
        For subprocess transports, this starts the process.
        For network transports, this establishes the connection.
        """
    

    end_input abstractmethod async

    end_input() -> None
    

    End the input stream (close stdin for process transports).

    Source code in src/clawd_code_sdk/_internal/transport/__init__.py
    @abstractmethod
    async def end_input(self) -> None:
        """End the input stream (close stdin for process transports)."""
    

    read_messages abstractmethod

    read_messages() -> AsyncIterator[dict[str, Any]]
    

    Read and parse messages from the transport.

    Yields:

    Type Description
    AsyncIterator[dict[str, Any]]

    Parsed JSON messages from the transport

    Source code in src/clawd_code_sdk/_internal/transport/__init__.py
    @abstractmethod
    def read_messages(self) -> AsyncIterator[dict[str, Any]]:
        """Read and parse messages from the transport.
    
        Yields:
            Parsed JSON messages from the transport
        """
    

    write abstractmethod async

    write(data: str) -> None
    

    Write raw data to the transport.

    Parameters:

    Name Type Description Default
    data str

    Raw string data to write (typically JSON + newline)

    required
    Source code in src/clawd_code_sdk/_internal/transport/__init__.py
    @abstractmethod
    async def write(self, data: str) -> None:
        """Write raw data to the transport.
    
        Args:
            data: Raw string data to write (typically JSON + newline)
        """
    

    :fa-brands-github: Show source on GitHub