Class RuntimeConnection

java.lang.Object
com.github.copilot.rpc.RuntimeConnection
Direct Known Subclasses:
InProcessRuntimeConnection, StdioRuntimeConnection, TcpRuntimeConnection, UriRuntimeConnection

Configures how a CopilotClient connects to the Copilot runtime.

Instances are created through the factory methods on this class and assigned with CopilotClientOptions.setConnection(RuntimeConnection):

// Spawn a runtime child process and talk over stdin/stdout (the default).
new CopilotClientOptions().setConnection(RuntimeConnection.forStdio());

// Spawn a runtime child process listening on a TCP socket.
new CopilotClientOptions().setConnection(RuntimeConnection.forTcp().setPath("/usr/local/bin/copilot"));

// Connect to an already-running runtime.
new CopilotClientOptions().setConnection(RuntimeConnection.forUri("localhost:3000"));
Since:
1.0.0
  • Method Details

    • forStdio

      public static StdioRuntimeConnection forStdio()
      Spawns a runtime child process and communicates over its stdin/stdout. This is the default when no connection is configured.
      Returns:
      a new stdio connection
    • forStdio

      public static StdioRuntimeConnection forStdio(String path)
      Spawns a runtime child process at the given path and communicates over its stdin/stdout.
      Parameters:
      path - path to the runtime executable, or null to use the runtime discovered on the PATH
      Returns:
      a new stdio connection
    • forTcp

      public static TcpRuntimeConnection forTcp()
      Spawns a runtime child process that listens on a TCP socket and connects to it.
      Returns:
      a new TCP connection
    • forUri

      public static UriRuntimeConnection forUri(String url)
      Connects to an already-running runtime at the given URL.
      Parameters:
      url - URL of the runtime to connect to; accepts "port", "host:port", or a full URL
      Returns:
      a new URI connection
      Throws:
      IllegalArgumentException - if url is null or empty
    • forInProcess

      @CopilotExperimental public static InProcessRuntimeConnection forInProcess()
      Hosts the runtime in-process by loading its native library and communicating over the C ABI — no child process is spawned by the SDK for JSON-RPC transport.
      Returns:
      a new in-process connection