Class RuntimeConnection
java.lang.Object
com.github.copilot.rpc.RuntimeConnection
- Direct Known Subclasses:
InProcessRuntimeConnection, StdioRuntimeConnection, TcpRuntimeConnection, UriRuntimeConnection
@CopilotExperimental
public abstract sealed class RuntimeConnection
extends Object
permits StdioRuntimeConnection, TcpRuntimeConnection, UriRuntimeConnection, InProcessRuntimeConnection
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 Summary
Modifier and TypeMethodDescriptionstatic InProcessRuntimeConnectionHosts 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.static StdioRuntimeConnectionforStdio()Spawns a runtime child process and communicates over its stdin/stdout.static StdioRuntimeConnectionSpawns a runtime child process at the given path and communicates over its stdin/stdout.static TcpRuntimeConnectionforTcp()Spawns a runtime child process that listens on a TCP socket and connects to it.static UriRuntimeConnectionConnects to an already-running runtime at the given URL.
-
Method Details
-
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
Spawns a runtime child process at the given path and communicates over its stdin/stdout.- Parameters:
path- path to the runtime executable, ornullto use the runtime discovered on thePATH- Returns:
- a new stdio connection
-
forTcp
Spawns a runtime child process that listens on a TCP socket and connects to it.- Returns:
- a new TCP connection
-
forUri
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- ifurlisnullor empty
-
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
-