Class CopilotClientOptions

java.lang.Object
com.github.copilot.sdk.json.CopilotClientOptions

public class CopilotClientOptions extends Object
Configuration options for creating a 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);
 
Since:
1.0.0
See Also:
  • Constructor Details

    • CopilotClientOptions

      public CopilotClientOptions()
  • Method Details

    • getCliPath

      public String getCliPath()
      Gets the path to the Copilot CLI executable.
      Returns:
      the CLI path, or null to use "copilot" from PATH
    • setCliPath

      public CopilotClientOptions setCliPath(String cliPath)
      Sets the path to the Copilot CLI executable.
      Parameters:
      cliPath - the path to the CLI executable, or null to use "copilot" from PATH
      Returns:
      this options instance for method chaining
    • getCliArgs

      public String[] getCliArgs()
      Gets the extra CLI arguments.
      Returns:
      the extra arguments to pass to the CLI
    • setCliArgs

      public CopilotClientOptions setCliArgs(String[] cliArgs)
      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

      public String getCwd()
      Gets the working directory for the CLI process.
      Returns:
      the working directory path
    • setCwd

      public CopilotClientOptions setCwd(String cwd)
      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

      public CopilotClientOptions setPort(int port)
      Sets the TCP port for the CLI server to listen on.

      This is only used when isUseStdio() is false.

      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:
      true to use stdio (default), false to use TCP
    • setUseStdio

      public CopilotClientOptions setUseStdio(boolean useStdio)
      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 - true to use stdio, false to use TCP
      Returns:
      this options instance for method chaining
    • getCliUrl

      public String getCliUrl()
      Gets the URL of an existing CLI server to connect to.
      Returns:
      the CLI server URL, or null to spawn a new process
    • setCliUrl

      public CopilotClientOptions setCliUrl(String cliUrl)
      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) and setCliPath(String).

      Parameters:
      cliUrl - the CLI server URL to connect to
      Returns:
      this options instance for method chaining
    • getLogLevel

      public String getLogLevel()
      Gets the log level for the CLI process.
      Returns:
      the log level (default: "info")
    • setLogLevel

      public CopilotClientOptions setLogLevel(String logLevel)
      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:
      true to auto-start (default), false for manual start
    • setAutoStart

      public CopilotClientOptions setAutoStart(boolean autoStart)
      Sets whether the client should automatically start the CLI server when the first request is made.
      Parameters:
      autoStart - true to auto-start, false for 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:
      true to auto-restart (default), false otherwise
    • setAutoRestart

      public CopilotClientOptions setAutoRestart(boolean autoRestart)
      Sets whether the client should automatically restart the CLI server if it crashes unexpectedly.
      Parameters:
      autoRestart - true to auto-restart, false otherwise
      Returns:
      this options instance for method chaining
    • getEnvironment

      public Map<String,String> getEnvironment()
      Gets the environment variables for the CLI process.
      Returns:
      the environment variables map
    • setEnvironment

      public CopilotClientOptions setEnvironment(Map<String,String> environment)
      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

      public Logger getLogger()
      Gets the custom logger for the client.
      Returns:
      the logger instance
    • setLogger

      public CopilotClientOptions setLogger(Logger logger)
      Sets a custom logger for the client.
      Parameters:
      logger - the logger instance to use
      Returns:
      this options instance for method chaining