Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .lastmerge
Original file line number Diff line number Diff line change
@@ -1 +1 @@
e42b726ca42bd1b2e099a956c9287ba9435ba3e5
e8dabaf9d9734c92f4d1541dd8c4169cedbfb688
10 changes: 10 additions & 0 deletions src/main/java/com/github/copilot/sdk/CliServerManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,16 @@ ProcessInfo startCliServer() throws IOException, InterruptedException {
pb.environment().put("COPILOT_SDK_AUTH_TOKEN", options.getGitHubToken());
}

// Set connection token in environment if provided
if (options.getTcpConnectionToken() != null && !options.getTcpConnectionToken().isEmpty()) {
pb.environment().put("COPILOT_CONNECTION_TOKEN", options.getTcpConnectionToken());
}

// Set copilot home directory in environment if provided
if (options.getCopilotHome() != null && !options.getCopilotHome().isEmpty()) {
pb.environment().put("COPILOT_HOME", options.getCopilotHome());
}

// Set telemetry environment variables if configured
if (options.getTelemetry() != null) {
var telemetry = options.getTelemetry();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ static CreateSessionRequest buildCreateRequest(SessionConfig config, String sess
request.setAgent(config.getAgent());
request.setInfiniteSessions(config.getInfiniteSessions());
request.setSkillDirectories(config.getSkillDirectories());
request.setInstructionDirectories(config.getInstructionDirectories());
request.setDisabledSkills(config.getDisabledSkills());
request.setConfigDir(config.getConfigDir());
request.setEnableConfigDiscovery(config.getEnableConfigDiscovery());
Expand Down Expand Up @@ -199,8 +200,10 @@ static ResumeSessionRequest buildResumeRequest(String sessionId, ResumeSessionCo
request.setDefaultAgent(config.getDefaultAgent());
request.setAgent(config.getAgent());
request.setSkillDirectories(config.getSkillDirectories());
request.setInstructionDirectories(config.getInstructionDirectories());
request.setDisabledSkills(config.getDisabledSkills());
request.setInfiniteSessions(config.getInfiniteSessions());
request.setContinuePendingWork(config.getContinuePendingWork());
request.setModelCapabilities(config.getModelCapabilities());

if (config.getCommands() != null && !config.getCommands().isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,15 @@ public class CopilotClientOptions {
private String[] cliArgs;
private String cliPath;
private String cliUrl;
private String copilotHome;
private String cwd;
private Map<String, String> environment;
private Executor executor;
private String gitHubToken;
private String logLevel = "info";
private Supplier<CompletableFuture<List<ModelInfo>>> onListModels;
private int port;
private String tcpConnectionToken;
private TelemetryConfig telemetry;
private Integer sessionIdleTimeoutSeconds;
private Boolean useLoggedInUser;
Expand Down Expand Up @@ -214,6 +216,36 @@ public CopilotClientOptions setCwd(String cwd) {
return this;
}

/**
* Gets the base directory for Copilot data (session state, config, etc.).
*
* @return the copilot home directory path, or {@code null} to use the CLI
* default ({@code ~/.copilot})
* @since 1.4.0
*/
public String getCopilotHome() {
return copilotHome;
}

/**
* Sets the base directory for Copilot data (session state, config, etc.).
* <p>
* Sets the {@code COPILOT_HOME} environment variable on the spawned CLI
* process. When {@code null}, the CLI defaults to {@code ~/.copilot}.
* <p>
* This option is only used when the SDK spawns the CLI process; it is ignored
* when connecting to an external server via {@link #setCliUrl(String)}.
*
* @param copilotHome
* the directory path for Copilot data
* @return this options instance for method chaining
* @since 1.4.0
*/
public CopilotClientOptions setCopilotHome(String copilotHome) {
this.copilotHome = copilotHome;
return this;
}

/**
* Gets the environment variables for the CLI process.
* <p>
Expand Down Expand Up @@ -462,6 +494,33 @@ public CopilotClientOptions setSessionIdleTimeoutSeconds(Integer sessionIdleTime
return this;
}

/**
* Gets the connection token for the headless CLI server (TCP only).
*
* @return the connection token, or {@code null} if not set
* @since 1.4.0
*/
public String getTcpConnectionToken() {
return tcpConnectionToken;
}

/**
* Sets the connection token for the headless CLI server (TCP only).
* <p>
* When the SDK spawns its own CLI in TCP mode and this is omitted, a UUID is
* generated automatically so the loopback listener is safe by default. Cannot
* be combined with {@link #setUseStdio(boolean)} set to {@code true}.
*
* @param tcpConnectionToken
* the connection token (must be non-empty if provided)
* @return this options instance for method chaining
* @since 1.4.0
*/
public CopilotClientOptions setTcpConnectionToken(String tcpConnectionToken) {
this.tcpConnectionToken = tcpConnectionToken;
return this;
}

/**
* Returns whether to use the logged-in user for authentication.
*
Expand Down Expand Up @@ -533,6 +592,7 @@ public CopilotClientOptions clone() {
copy.cliArgs = this.cliArgs != null ? this.cliArgs.clone() : null;
copy.cliPath = this.cliPath;
copy.cliUrl = this.cliUrl;
copy.copilotHome = this.copilotHome;
copy.cwd = this.cwd;
copy.environment = this.environment != null ? new java.util.HashMap<>(this.environment) : null;
copy.executor = this.executor;
Expand All @@ -541,6 +601,7 @@ public CopilotClientOptions clone() {
copy.onListModels = this.onListModels;
copy.port = this.port;
copy.sessionIdleTimeoutSeconds = this.sessionIdleTimeoutSeconds;
copy.tcpConnectionToken = this.tcpConnectionToken;
copy.telemetry = this.telemetry;
copy.useLoggedInUser = this.useLoggedInUser;
copy.useStdio = this.useStdio;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ public final class CreateSessionRequest {
@JsonProperty("skillDirectories")
private List<String> skillDirectories;

@JsonProperty("instructionDirectories")
private List<String> instructionDirectories;

@JsonProperty("disabledSkills")
private List<String> disabledSkills;

Expand Down Expand Up @@ -326,6 +329,18 @@ public void setSkillDirectories(List<String> skillDirectories) {
this.skillDirectories = skillDirectories;
}

/** Gets instruction directories. @return the instruction directories */
public List<String> getInstructionDirectories() {
return instructionDirectories == null ? null : Collections.unmodifiableList(instructionDirectories);
}

/**
* Sets instruction directories. @param instructionDirectories the directories
*/
public void setInstructionDirectories(List<String> instructionDirectories) {
this.instructionDirectories = instructionDirectories;
}

/** Gets disabled skills. @return the disabled skill names */
public List<String> getDisabledSkills() {
return disabledSkills == null ? null : Collections.unmodifiableList(disabledSkills);
Expand Down
80 changes: 80 additions & 0 deletions src/main/java/com/github/copilot/sdk/json/McpHttpServerConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@ public final class McpHttpServerConfig extends McpServerConfig {
@JsonProperty("headers")
private Map<String, String> headers;

@JsonProperty("oauthClientId")
private String oauthClientId;

@JsonProperty("oauthPublicClient")
private Boolean oauthPublicClient;

@JsonProperty("oauthGrantType")
private String oauthGrantType;

/**
* Gets the server type discriminator.
*
Expand Down Expand Up @@ -92,6 +101,77 @@ public McpHttpServerConfig setHeaders(Map<String, String> headers) {
return this;
}

/**
* Gets the optional OAuth client ID for the remote server.
*
* @return the OAuth client ID, or {@code null}
* @since 1.4.0
*/
public String getOauthClientId() {
return oauthClientId;
}

/**
* Sets the optional OAuth client ID for the remote server.
*
* @param oauthClientId
* the OAuth client ID
* @return this config for method chaining
* @since 1.4.0
*/
public McpHttpServerConfig setOauthClientId(String oauthClientId) {
this.oauthClientId = oauthClientId;
return this;
}

/**
* Gets whether this is a public OAuth client.
*
* @return {@code true} if public OAuth client, or {@code null}
* @since 1.4.0
*/
public Boolean getOauthPublicClient() {
return oauthPublicClient;
}

/**
* Sets whether this is a public OAuth client.
*
* @param oauthPublicClient
* whether this is a public OAuth client
* @return this config for method chaining
* @since 1.4.0
*/
public McpHttpServerConfig setOauthPublicClient(Boolean oauthPublicClient) {
this.oauthPublicClient = oauthPublicClient;
return this;
}

/**
* Gets the optional OAuth grant type for the remote server.
*
* @return the OAuth grant type (e.g., "authorization_code" or
* "client_credentials"), or {@code null}
* @since 1.4.0
*/
public String getOauthGrantType() {
return oauthGrantType;
}

/**
* Sets the optional OAuth grant type for the remote server.
*
* @param oauthGrantType
* the OAuth grant type (e.g., "authorization_code" or
* "client_credentials")
* @return this config for method chaining
* @since 1.4.0
*/
public McpHttpServerConfig setOauthGrantType(String oauthGrantType) {
this.oauthGrantType = oauthGrantType;
return this;
}

@Override
public McpHttpServerConfig setTools(List<String> tools) {
super.setTools(tools);
Expand Down
60 changes: 60 additions & 0 deletions src/main/java/com/github/copilot/sdk/json/ResumeSessionConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,10 @@ public class ResumeSessionConfig {
private DefaultAgentConfig defaultAgent;
private String agent;
private List<String> skillDirectories;
private List<String> instructionDirectories;
private List<String> disabledSkills;
private InfiniteSessionConfig infiniteSessions;
private Boolean continuePendingWork;
private Consumer<SessionEvent> onEvent;
private List<CommandDefinition> commands;
private ElicitationHandler onElicitationRequest;
Expand Down Expand Up @@ -591,6 +593,29 @@ public ResumeSessionConfig setSkillDirectories(List<String> skillDirectories) {
return this;
}

/**
* Gets the instruction directories.
*
* @return the list of instruction directory paths
* @since 1.4.0
*/
public List<String> getInstructionDirectories() {
return instructionDirectories == null ? null : Collections.unmodifiableList(instructionDirectories);
}

/**
* Sets additional directories to search for custom instruction files.
*
* @param instructionDirectories
* the list of instruction directory paths
* @return this config for method chaining
* @since 1.4.0
*/
public ResumeSessionConfig setInstructionDirectories(List<String> instructionDirectories) {
this.instructionDirectories = instructionDirectories;
return this;
}

/**
* Gets the disabled skills.
*
Expand Down Expand Up @@ -635,6 +660,37 @@ public ResumeSessionConfig setInfiniteSessions(InfiniteSessionConfig infiniteSes
return this;
}

/**
* Gets whether to continue pending work on resume.
*
* @return {@code true} to continue pending work, {@code false} or {@code null}
* to treat pending work as interrupted
* @since 1.4.0
*/
public Boolean getContinuePendingWork() {
return continuePendingWork;
}

/**
* Sets whether to continue any tool calls or permission prompts that were still
* pending when the session was last suspended.
* <p>
* When {@code true}, the runtime continues pending work on resume. When
* {@code false} (the default), the runtime treats pending work as interrupted.
* For permission requests, the runtime re-emits {@code permission.requested} so
* the registered handler can re-prompt; for external tool calls, the consumer
* is expected to supply the result via the corresponding low-level RPC method.
*
* @param continuePendingWork
* whether to continue pending work
* @return this config for method chaining
* @since 1.4.0
*/
public ResumeSessionConfig setContinuePendingWork(Boolean continuePendingWork) {
this.continuePendingWork = continuePendingWork;
return this;
}

/**
* Gets the event handler registered before the session.resume RPC is issued.
*
Expand Down Expand Up @@ -775,8 +831,12 @@ public ResumeSessionConfig clone() {
copy.defaultAgent = this.defaultAgent;
copy.agent = this.agent;
copy.skillDirectories = this.skillDirectories != null ? new ArrayList<>(this.skillDirectories) : null;
copy.instructionDirectories = this.instructionDirectories != null
? new ArrayList<>(this.instructionDirectories)
: null;
copy.disabledSkills = this.disabledSkills != null ? new ArrayList<>(this.disabledSkills) : null;
copy.infiniteSessions = this.infiniteSessions;
copy.continuePendingWork = this.continuePendingWork;
copy.onEvent = this.onEvent;
copy.commands = this.commands != null ? new ArrayList<>(this.commands) : null;
copy.onElicitationRequest = this.onElicitationRequest;
Expand Down
Loading
Loading