Class CopilotClientOptions
CopilotClient.
This class provides a fluent API for configuring how the client connects to
and manages the Copilot CLI server. All setter methods return this
for method chaining.
Example Usage
var options = new CopilotClientOptions().setCliPath("/usr/local/bin/copilot").setLogLevel("debug")
.setAutoStart(true);
var client = new CopilotClient(options);
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionString[]Gets the extra CLI arguments.Gets the path to the Copilot CLI executable.Gets the URL of an existing CLI server to connect to.getCwd()Gets the working directory for the CLI process.Gets the environment variables for the CLI process.Gets the custom logger for the client.Gets the log level for the CLI process.intgetPort()Gets the TCP port for the CLI server.booleanReturns whether the client should automatically restart the server on crash.booleanReturns whether the client should automatically start the server.booleanReturns whether to use stdio transport instead of TCP.setAutoRestart(boolean autoRestart) Sets whether the client should automatically restart the CLI server if it crashes unexpectedly.setAutoStart(boolean autoStart) Sets whether the client should automatically start the CLI server when the first request is made.setCliArgs(String[] cliArgs) Sets extra arguments to pass to the CLI process.setCliPath(String cliPath) Sets the path to the Copilot CLI executable.Sets the URL of an existing CLI server to connect to.Sets the working directory for the CLI process.setEnvironment(Map<String, String> environment) Sets environment variables to pass to the CLI process.Sets a custom logger for the client.setLogLevel(String logLevel) Sets the log level for the CLI process.setPort(int port) Sets the TCP port for the CLI server to listen on.setUseStdio(boolean useStdio) Sets whether to use stdio transport instead of TCP.
-
Constructor Details
-
CopilotClientOptions
public CopilotClientOptions()
-
-
Method Details
-
getCliPath
Gets the path to the Copilot CLI executable.- Returns:
- the CLI path, or
nullto use "copilot" from PATH
-
setCliPath
Sets the path to the Copilot CLI executable.- Parameters:
cliPath- the path to the CLI executable, ornullto use "copilot" from PATH- Returns:
- this options instance for method chaining
-
getCliArgs
Gets the extra CLI arguments.- Returns:
- the extra arguments to pass to the CLI
-
setCliArgs
Sets extra arguments to pass to the CLI process.These arguments are prepended before SDK-managed flags.
- Parameters:
cliArgs- the extra arguments to pass- Returns:
- this options instance for method chaining
-
getCwd
Gets the working directory for the CLI process.- Returns:
- the working directory path
-
setCwd
Sets the working directory for the CLI process.- Parameters:
cwd- the working directory path- Returns:
- this options instance for method chaining
-
getPort
public int getPort()Gets the TCP port for the CLI server.- Returns:
- the port number, or 0 for a random port
-
setPort
Sets the TCP port for the CLI server to listen on.This is only used when
isUseStdio()isfalse.- Parameters:
port- the port number, or 0 for a random port- Returns:
- this options instance for method chaining
-
isUseStdio
public boolean isUseStdio()Returns whether to use stdio transport instead of TCP.- Returns:
trueto use stdio (default),falseto use TCP
-
setUseStdio
Sets whether to use stdio transport instead of TCP.Stdio transport is more efficient and is the default. TCP transport can be useful for debugging or connecting to remote servers.
- Parameters:
useStdio-trueto use stdio,falseto use TCP- Returns:
- this options instance for method chaining
-
getCliUrl
Gets the URL of an existing CLI server to connect to.- Returns:
- the CLI server URL, or
nullto spawn a new process
-
setCliUrl
Sets the URL of an existing CLI server to connect to.When provided, the client will not spawn a CLI process but will connect to the specified URL instead. Format: "host:port" or "http://host:port".
Note: This is mutually exclusive with
setUseStdio(boolean)andsetCliPath(String).- Parameters:
cliUrl- the CLI server URL to connect to- Returns:
- this options instance for method chaining
-
getLogLevel
Gets the log level for the CLI process.- Returns:
- the log level (default: "info")
-
setLogLevel
Sets the log level for the CLI process.Valid levels include: "error", "warn", "info", "debug", "trace".
- Parameters:
logLevel- the log level- Returns:
- this options instance for method chaining
-
isAutoStart
public boolean isAutoStart()Returns whether the client should automatically start the server.- Returns:
trueto auto-start (default),falsefor manual start
-
setAutoStart
Sets whether the client should automatically start the CLI server when the first request is made.- Parameters:
autoStart-trueto auto-start,falsefor manual start- Returns:
- this options instance for method chaining
-
isAutoRestart
public boolean isAutoRestart()Returns whether the client should automatically restart the server on crash.- Returns:
trueto auto-restart (default),falseotherwise
-
setAutoRestart
Sets whether the client should automatically restart the CLI server if it crashes unexpectedly.- Parameters:
autoRestart-trueto auto-restart,falseotherwise- Returns:
- this options instance for method chaining
-
getEnvironment
Gets the environment variables for the CLI process.- Returns:
- the environment variables map
-
setEnvironment
Sets environment variables to pass to the CLI process.When set, these environment variables replace the inherited environment.
- Parameters:
environment- the environment variables map- Returns:
- this options instance for method chaining
-
getLogger
Gets the custom logger for the client.- Returns:
- the logger instance
-
setLogger
Sets a custom logger for the client.- Parameters:
logger- the logger instance to use- Returns:
- this options instance for method chaining
-