Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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 @@
c3fa6cbfb83d4a20b7912b1a17013d48f5a277a1
922959f4a7b83509c3620d4881733c6c5677f00c
46 changes: 46 additions & 0 deletions src/main/java/com/github/copilot/sdk/CopilotSession.java
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,7 @@ public CompletableFuture<String> send(MessageOptions options) {
request.setPrompt(options.getPrompt());
request.setAttachments(options.getAttachments());
request.setMode(options.getMode());
request.setRequestHeaders(options.getRequestHeaders());

return rpc.invoke("session.send", request, SendMessageResponse.class).thenApply(SendMessageResponse::messageId);
}
Expand Down Expand Up @@ -1552,6 +1553,51 @@ public CompletableFuture<Void> setModel(String model, String reasoningEffort) {
.thenApply(r -> null);
}

/**
* Changes the model for this session with optional reasoning effort and
* capability overrides.
* <p>
* The new model takes effect for the next message. Conversation history is
* preserved.
*
* <pre>{@code
* session.setModel("claude-sonnet-4.5", null,
* new ModelCapabilitiesOverride().setSupports(new ModelCapabilitiesOverride.Supports().setVision(false)))
* .get();
* }</pre>
*
* @param model
* the model ID to switch to (e.g., {@code "gpt-4.1"})
* @param reasoningEffort
* reasoning effort level (e.g., {@code "low"}, {@code "medium"},
* {@code "high"}, {@code "xhigh"}); {@code null} to use default
* @param modelCapabilities
* per-property overrides for model capabilities; {@code null} to use
* runtime defaults
* @return a future that completes when the model switch is acknowledged
* @throws IllegalStateException
* if this session has been terminated
* @since 1.3.0
*/
public CompletableFuture<Void> setModel(String model, String reasoningEffort,
com.github.copilot.sdk.json.ModelCapabilitiesOverride modelCapabilities) {
ensureNotTerminated();
SessionModelSwitchToParams.SessionModelSwitchToParamsModelCapabilities generatedCapabilities = null;
if (modelCapabilities != null) {
SessionModelSwitchToParams.SessionModelSwitchToParamsModelCapabilities.SessionModelSwitchToParamsModelCapabilitiesSupports supports = null;
if (modelCapabilities.getSupports() != null) {
var s = modelCapabilities.getSupports();
supports = new SessionModelSwitchToParams.SessionModelSwitchToParamsModelCapabilities.SessionModelSwitchToParamsModelCapabilitiesSupports(
s.getVision(), s.getReasoningEffort());
}
generatedCapabilities = new SessionModelSwitchToParams.SessionModelSwitchToParamsModelCapabilities(supports,
null);
Comment thread
edburns marked this conversation as resolved.
Outdated
}
return getRpc().model
.switchTo(new SessionModelSwitchToParams(sessionId, model, reasoningEffort, generatedCapabilities))
.thenApply(r -> null);
}

/**
* Changes the model for this session.
* <p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,16 @@ static CreateSessionRequest buildCreateRequest(SessionConfig config, String sess
request.setHooks(config.getHooks() != null && config.getHooks().hasHooks() ? true : null);
request.setWorkingDirectory(config.getWorkingDirectory());
request.setStreaming(config.isStreaming() ? true : null);
request.setIncludeSubAgentStreamingEvents(config.getIncludeSubAgentStreamingEvents());
request.setMcpServers(config.getMcpServers());
request.setCustomAgents(config.getCustomAgents());
request.setAgent(config.getAgent());
request.setInfiniteSessions(config.getInfiniteSessions());
request.setSkillDirectories(config.getSkillDirectories());
request.setDisabledSkills(config.getDisabledSkills());
request.setConfigDir(config.getConfigDir());
request.setEnableConfigDiscovery(config.getEnableConfigDiscovery());
request.setModelCapabilities(config.getModelCapabilities());

if (config.getCommands() != null && !config.getCommands().isEmpty()) {
var wireCommands = config.getCommands().stream()
Expand Down Expand Up @@ -185,14 +188,17 @@ static ResumeSessionRequest buildResumeRequest(String sessionId, ResumeSessionCo
request.setHooks(config.getHooks() != null && config.getHooks().hasHooks() ? true : null);
request.setWorkingDirectory(config.getWorkingDirectory());
request.setConfigDir(config.getConfigDir());
request.setEnableConfigDiscovery(config.getEnableConfigDiscovery());
request.setDisableResume(config.isDisableResume() ? true : null);
request.setStreaming(config.isStreaming() ? true : null);
request.setIncludeSubAgentStreamingEvents(config.getIncludeSubAgentStreamingEvents());
request.setMcpServers(config.getMcpServers());
request.setCustomAgents(config.getCustomAgents());
request.setAgent(config.getAgent());
request.setSkillDirectories(config.getSkillDirectories());
request.setDisabledSkills(config.getDisabledSkills());
request.setInfiniteSessions(config.getInfiniteSessions());
request.setModelCapabilities(config.getModelCapabilities());

if (config.getCommands() != null && !config.getCommands().isEmpty()) {
var wireCommands = config.getCommands().stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,11 @@ public final class CreateSessionRequest {
@JsonProperty("streaming")
private Boolean streaming;

@JsonProperty("includeSubAgentStreamingEvents")
private Boolean includeSubAgentStreamingEvents;

@JsonProperty("mcpServers")
private Map<String, Object> mcpServers;
private Map<String, McpServerConfig> mcpServers;

@JsonProperty("envValueMode")
private String envValueMode;
Expand All @@ -91,12 +94,18 @@ public final class CreateSessionRequest {
@JsonProperty("configDir")
private String configDir;

@JsonProperty("enableConfigDiscovery")
private Boolean enableConfigDiscovery;

@JsonProperty("commands")
private List<CommandWireDefinition> commands;

@JsonProperty("requestElicitation")
private Boolean requestElicitation;

@JsonProperty("modelCapabilities")
private ModelCapabilitiesOverride modelCapabilities;

/** Gets the model name. @return the model */
public String getModel() {
return model;
Expand Down Expand Up @@ -240,12 +249,12 @@ public void setStreaming(Boolean streaming) {
}

/** Gets MCP servers. @return the servers map */
public Map<String, Object> getMcpServers() {
public Map<String, McpServerConfig> getMcpServers() {
return mcpServers == null ? null : Collections.unmodifiableMap(mcpServers);
}

/** Sets MCP servers. @param mcpServers the servers map */
public void setMcpServers(Map<String, Object> mcpServers) {
public void setMcpServers(Map<String, McpServerConfig> mcpServers) {
this.mcpServers = mcpServers;
}

Expand Down Expand Up @@ -319,6 +328,29 @@ public void setConfigDir(String configDir) {
this.configDir = configDir;
}

/** Gets enable config discovery flag. @return the flag */
public Boolean getEnableConfigDiscovery() {
return enableConfigDiscovery;
}

/** Sets enable config discovery flag. @param enableConfigDiscovery the flag */
public void setEnableConfigDiscovery(Boolean enableConfigDiscovery) {
this.enableConfigDiscovery = enableConfigDiscovery;
}

/** Gets include sub-agent streaming events flag. @return the flag */
public Boolean getIncludeSubAgentStreamingEvents() {
return includeSubAgentStreamingEvents;
}

/**
* Sets include sub-agent streaming events flag. @param
* includeSubAgentStreamingEvents the flag
*/
public void setIncludeSubAgentStreamingEvents(Boolean includeSubAgentStreamingEvents) {
this.includeSubAgentStreamingEvents = includeSubAgentStreamingEvents;
}

/** Gets the commands wire definitions. @return the commands */
public List<CommandWireDefinition> getCommands() {
return commands == null ? null : Collections.unmodifiableList(commands);
Expand All @@ -338,4 +370,16 @@ public Boolean getRequestElicitation() {
public void setRequestElicitation(Boolean requestElicitation) {
this.requestElicitation = requestElicitation;
}

/** Gets the model capabilities override. @return the override */
public ModelCapabilitiesOverride getModelCapabilities() {
return modelCapabilities;
}

/**
* Sets the model capabilities override. @param modelCapabilities the override
*/
public void setModelCapabilities(ModelCapabilitiesOverride modelCapabilities) {
this.modelCapabilities = modelCapabilities;
}
}
36 changes: 33 additions & 3 deletions src/main/java/com/github/copilot/sdk/json/CustomAgentConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,14 @@ public class CustomAgentConfig {
private String prompt;

@JsonProperty("mcpServers")
private Map<String, Object> mcpServers;
private Map<String, McpServerConfig> mcpServers;

@JsonProperty("infer")
private Boolean infer;

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

/**
* Gets the unique identifier name for this agent.
*
Expand Down Expand Up @@ -175,7 +178,7 @@ public CustomAgentConfig setPrompt(String prompt) {
*
* @return the MCP servers map
*/
public Map<String, Object> getMcpServers() {
public Map<String, McpServerConfig> getMcpServers() {
return mcpServers == null ? null : Collections.unmodifiableMap(mcpServers);
}

Expand All @@ -186,7 +189,7 @@ public Map<String, Object> getMcpServers() {
* the MCP server configurations
* @return this config for method chaining
*/
public CustomAgentConfig setMcpServers(Map<String, Object> mcpServers) {
public CustomAgentConfig setMcpServers(Map<String, McpServerConfig> mcpServers) {
this.mcpServers = mcpServers;
return this;
}
Expand All @@ -211,4 +214,31 @@ public CustomAgentConfig setInfer(Boolean infer) {
this.infer = infer;
return this;
}

/**
* Gets the list of skill names to preload into this agent's context.
*
* @return the list of skill names, or {@code null} if not set
*/
public List<String> getSkills() {
return skills == null ? null : Collections.unmodifiableList(skills);
}

/**
* Sets the list of skill names to preload into this agent's context.
* <p>
* When set, the full content of each listed skill is eagerly injected into the
* agent's context at startup. Skills are resolved by name from the session's
* configured skill directories
* ({@link SessionConfig#setSkillDirectories(List)}). When omitted, no skills
* are injected (opt-in model).
*
* @param skills
* the list of skill names to preload
* @return this config for method chaining
*/
public CustomAgentConfig setSkills(List<String> skills) {
this.skills = skills;
return this;
}
}
106 changes: 106 additions & 0 deletions src/main/java/com/github/copilot/sdk/json/McpHttpServerConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
*--------------------------------------------------------------------------------------------*/

package com.github.copilot.sdk.json;

import java.util.Collections;
import java.util.List;
import java.util.Map;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;

/**
* Configuration for a remote HTTP/SSE MCP (Model Context Protocol) server.
* <p>
* Use this to configure an MCP server that communicates over HTTP or
* Server-Sent Events (SSE).
*
* <h2>Example Usage</h2>
*
* <pre>{@code
* var server = new McpHttpServerConfig().setUrl("https://mcp.example.com/sse").setTools(List.of("*"));
*
* var config = new SessionConfig().setMcpServers(Map.of("remote-server", server));
* }</pre>
*
* @see McpServerConfig
* @see SessionConfig#setMcpServers(java.util.Map)
* @since 1.3.0
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
public final class McpHttpServerConfig extends McpServerConfig {

@JsonProperty("type")
private final String type = "http";

@JsonProperty("url")
private String url;

@JsonProperty("headers")
private Map<String, String> headers;

/**
* Gets the server type discriminator.
*
* @return always {@code "http"}
*/
public String getType() {
return type;
}

/**
* Gets the URL of the remote server.
*
* @return the server URL
*/
public String getUrl() {
return url;
}

/**
* Sets the URL of the remote server.
*
* @param url
* the server URL
* @return this config for method chaining
*/
public McpHttpServerConfig setUrl(String url) {
this.url = url;
return this;
}

/**
* Gets the optional HTTP headers to include in requests.
*
* @return the headers map, or {@code null}
*/
public Map<String, String> getHeaders() {
return headers == null ? null : Collections.unmodifiableMap(headers);
}

/**
* Sets optional HTTP headers to include in requests to this server.
*
* @param headers
* the headers map
* @return this config for method chaining
*/
public McpHttpServerConfig setHeaders(Map<String, String> headers) {
this.headers = headers;
return this;
}

@Override
public McpHttpServerConfig setTools(List<String> tools) {
super.setTools(tools);
return this;
}

@Override
public McpHttpServerConfig setTimeout(Integer timeout) {
super.setTimeout(timeout);
return this;
}
}
Loading
Loading