From dfe8b1704a3fb9a2d8af7021325d626dbc63f7cf Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 13 Apr 2026 10:32:56 +0000 Subject: [PATCH 1/3] Initial plan From 89cc261ee167cb8596227a7bf5761f6ba4e3d548 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 13 Apr 2026 10:51:47 +0000 Subject: [PATCH 2/3] Port enableConfigDiscovery, ModelCapabilitiesOverride, McpServerConfig types, and setModel overload Agent-Logs-Url: https://github.com/github/copilot-sdk-java/sessions/6440ac65-a609-41e9-8afc-718bccbef08a Co-authored-by: edburns <75821+edburns@users.noreply.github.com> --- README.md | 2 +- .../github/copilot/sdk/CopilotSession.java | 36 ++++- .../copilot/sdk/SessionRequestBuilder.java | 4 + .../sdk/json/CreateSessionRequest.java | 36 ++++- .../copilot/sdk/json/CustomAgentConfig.java | 6 +- .../copilot/sdk/json/McpHttpServerConfig.java | 82 ++++++++++++ .../copilot/sdk/json/McpServerConfig.java | 98 ++++++++++++++ .../sdk/json/McpStdioServerConfig.java | 123 ++++++++++++++++++ .../sdk/json/ModelCapabilitiesOverride.java | 61 +++++++++ .../json/ModelCapabilitiesOverrideLimits.java | 73 +++++++++++ ...ModelCapabilitiesOverrideLimitsVision.java | 61 +++++++++ .../ModelCapabilitiesOverrideSupports.java | 45 +++++++ .../copilot/sdk/json/ResumeSessionConfig.java | 64 ++++++++- .../sdk/json/ResumeSessionRequest.java | 36 ++++- .../copilot/sdk/json/SessionConfig.java | 79 ++++++++++- src/site/markdown/index.md | 2 +- .../github/copilot/sdk/McpAndAgentsTest.java | 24 ++-- 17 files changed, 798 insertions(+), 34 deletions(-) create mode 100644 src/main/java/com/github/copilot/sdk/json/McpHttpServerConfig.java create mode 100644 src/main/java/com/github/copilot/sdk/json/McpServerConfig.java create mode 100644 src/main/java/com/github/copilot/sdk/json/McpStdioServerConfig.java create mode 100644 src/main/java/com/github/copilot/sdk/json/ModelCapabilitiesOverride.java create mode 100644 src/main/java/com/github/copilot/sdk/json/ModelCapabilitiesOverrideLimits.java create mode 100644 src/main/java/com/github/copilot/sdk/json/ModelCapabilitiesOverrideLimitsVision.java create mode 100644 src/main/java/com/github/copilot/sdk/json/ModelCapabilitiesOverrideSupports.java diff --git a/README.md b/README.md index a33aaedda..e88f8eb92 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ Java SDK for programmatic control of GitHub Copilot CLI, enabling you to build A ### Requirements - Java 17 or later. **JDK 25 recommended**. Selecting JDK 25 enables the use of virtual threads, as shown in the [Quick Start](#quick-start). -- GitHub Copilot CLI 1.0.17 or later installed and in `PATH` (or provide custom `cliPath`) +- GitHub Copilot CLI 1.0.22 or later installed and in `PATH` (or provide custom `cliPath`) ### Maven diff --git a/src/main/java/com/github/copilot/sdk/CopilotSession.java b/src/main/java/com/github/copilot/sdk/CopilotSession.java index 23b1b5368..ff9c3e241 100644 --- a/src/main/java/com/github/copilot/sdk/CopilotSession.java +++ b/src/main/java/com/github/copilot/sdk/CopilotSession.java @@ -53,6 +53,7 @@ import com.github.copilot.sdk.json.HookInvocation; import com.github.copilot.sdk.json.InputOptions; import com.github.copilot.sdk.json.MessageOptions; +import com.github.copilot.sdk.json.ModelCapabilitiesOverride; import com.github.copilot.sdk.json.PermissionHandler; import com.github.copilot.sdk.json.PermissionInvocation; import com.github.copilot.sdk.json.PermissionRequest; @@ -1496,6 +1497,36 @@ public CompletableFuture abort() { * @since 1.2.0 */ public CompletableFuture setModel(String model, String reasoningEffort) { + return setModel(model, reasoningEffort, null); + } + + /** + * Changes the model for this session with optional reasoning effort level and + * model capabilities overrides. + *

+ * The new model takes effect for the next message. Conversation history is + * preserved. + * + *

{@code
+     * session.setModel("claude-sonnet-4.5", null,
+     * 		new ModelCapabilitiesOverride().setSupports(new ModelCapabilitiesOverrideSupports().setVision(true))).get();
+     * }
+ * + * @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, deep-merged over + * runtime defaults; {@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.4.0 + */ + public CompletableFuture setModel(String model, String reasoningEffort, + ModelCapabilitiesOverride modelCapabilities) { ensureNotTerminated(); var params = new java.util.HashMap(); params.put("sessionId", sessionId); @@ -1503,6 +1534,9 @@ public CompletableFuture setModel(String model, String reasoningEffort) { if (reasoningEffort != null) { params.put("reasoningEffort", reasoningEffort); } + if (modelCapabilities != null) { + params.put("modelCapabilities", modelCapabilities); + } return rpc.invoke("session.model.switchTo", params, Void.class); } @@ -1524,7 +1558,7 @@ public CompletableFuture setModel(String model, String reasoningEffort) { * @since 1.0.11 */ public CompletableFuture setModel(String model) { - return setModel(model, null); + return setModel(model, null, null); } /** diff --git a/src/main/java/com/github/copilot/sdk/SessionRequestBuilder.java b/src/main/java/com/github/copilot/sdk/SessionRequestBuilder.java index d74bbfaf3..8822b20fa 100644 --- a/src/main/java/com/github/copilot/sdk/SessionRequestBuilder.java +++ b/src/main/java/com/github/copilot/sdk/SessionRequestBuilder.java @@ -122,6 +122,8 @@ static CreateSessionRequest buildCreateRequest(SessionConfig config, String sess 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() @@ -193,6 +195,8 @@ static ResumeSessionRequest buildResumeRequest(String sessionId, ResumeSessionCo request.setSkillDirectories(config.getSkillDirectories()); request.setDisabledSkills(config.getDisabledSkills()); request.setInfiniteSessions(config.getInfiniteSessions()); + request.setEnableConfigDiscovery(config.getEnableConfigDiscovery()); + request.setModelCapabilities(config.getModelCapabilities()); if (config.getCommands() != null && !config.getCommands().isEmpty()) { var wireCommands = config.getCommands().stream() diff --git a/src/main/java/com/github/copilot/sdk/json/CreateSessionRequest.java b/src/main/java/com/github/copilot/sdk/json/CreateSessionRequest.java index d030631de..52a810d8b 100644 --- a/src/main/java/com/github/copilot/sdk/json/CreateSessionRequest.java +++ b/src/main/java/com/github/copilot/sdk/json/CreateSessionRequest.java @@ -68,7 +68,7 @@ public final class CreateSessionRequest { private Boolean streaming; @JsonProperty("mcpServers") - private Map mcpServers; + private Map mcpServers; @JsonProperty("envValueMode") private String envValueMode; @@ -91,6 +91,12 @@ public final class CreateSessionRequest { @JsonProperty("configDir") private String configDir; + @JsonProperty("enableConfigDiscovery") + private Boolean enableConfigDiscovery; + + @JsonProperty("modelCapabilities") + private ModelCapabilitiesOverride modelCapabilities; + @JsonProperty("commands") private List commands; @@ -240,12 +246,12 @@ public void setStreaming(Boolean streaming) { } /** Gets MCP servers. @return the servers map */ - public Map getMcpServers() { + public Map getMcpServers() { return mcpServers == null ? null : Collections.unmodifiableMap(mcpServers); } /** Sets MCP servers. @param mcpServers the servers map */ - public void setMcpServers(Map mcpServers) { + public void setMcpServers(Map mcpServers) { this.mcpServers = mcpServers; } @@ -319,6 +325,30 @@ public void setConfigDir(String configDir) { this.configDir = configDir; } + /** Gets the enableConfigDiscovery flag. @return the flag */ + public Boolean getEnableConfigDiscovery() { + return enableConfigDiscovery; + } + + /** + * Sets the enableConfigDiscovery flag. @param enableConfigDiscovery the flag + */ + public void setEnableConfigDiscovery(Boolean enableConfigDiscovery) { + this.enableConfigDiscovery = enableConfigDiscovery; + } + + /** 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; + } + /** Gets the commands wire definitions. @return the commands */ public List getCommands() { return commands == null ? null : Collections.unmodifiableList(commands); diff --git a/src/main/java/com/github/copilot/sdk/json/CustomAgentConfig.java b/src/main/java/com/github/copilot/sdk/json/CustomAgentConfig.java index 99731ddfb..bfb782c5c 100644 --- a/src/main/java/com/github/copilot/sdk/json/CustomAgentConfig.java +++ b/src/main/java/com/github/copilot/sdk/json/CustomAgentConfig.java @@ -50,7 +50,7 @@ public class CustomAgentConfig { private String prompt; @JsonProperty("mcpServers") - private Map mcpServers; + private Map mcpServers; @JsonProperty("infer") private Boolean infer; @@ -175,7 +175,7 @@ public CustomAgentConfig setPrompt(String prompt) { * * @return the MCP servers map */ - public Map getMcpServers() { + public Map getMcpServers() { return mcpServers == null ? null : Collections.unmodifiableMap(mcpServers); } @@ -186,7 +186,7 @@ public Map getMcpServers() { * the MCP server configurations * @return this config for method chaining */ - public CustomAgentConfig setMcpServers(Map mcpServers) { + public CustomAgentConfig setMcpServers(Map mcpServers) { this.mcpServers = mcpServers; return this; } diff --git a/src/main/java/com/github/copilot/sdk/json/McpHttpServerConfig.java b/src/main/java/com/github/copilot/sdk/json/McpHttpServerConfig.java new file mode 100644 index 000000000..e117a6a7d --- /dev/null +++ b/src/main/java/com/github/copilot/sdk/json/McpHttpServerConfig.java @@ -0,0 +1,82 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + *--------------------------------------------------------------------------------------------*/ + +package com.github.copilot.sdk.json; + +import java.util.Map; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Configuration for a remote HTTP/SSE MCP server. + *

+ * Use this class to configure an MCP server accessed via HTTP or Server-Sent + * Events. + * + *

Example

+ * + *
{@code
+ * var server = new McpHttpServerConfig().setUrl("https://example.com/mcp")
+ * 		.setHeaders(Map.of("Authorization", "Bearer token")).setTools(List.of("*"));
+ * }
+ * + * @see McpServerConfig + * @since 1.4.0 + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +public final class McpHttpServerConfig extends McpServerConfig { + + @JsonProperty("url") + private String url; + + @JsonProperty("headers") + private Map headers; + + /** Returns the URL of the remote server. */ + public String getUrl() { + return url; + } + + /** + * Sets the URL of the remote server. + * + * @param url + * the server URL + * @return this instance for method chaining + */ + public McpHttpServerConfig setUrl(String url) { + this.url = url; + return this; + } + + /** Returns the optional HTTP headers to include in requests. */ + public Map getHeaders() { + return headers; + } + + /** + * Sets optional HTTP headers to include in requests. + * + * @param headers + * HTTP header map + * @return this instance for method chaining + */ + public McpHttpServerConfig setHeaders(Map headers) { + this.headers = headers; + return this; + } + + @Override + public McpHttpServerConfig setTools(java.util.List tools) { + super.setTools(tools); + return this; + } + + @Override + public McpHttpServerConfig setTimeout(Integer timeout) { + super.setTimeout(timeout); + return this; + } +} diff --git a/src/main/java/com/github/copilot/sdk/json/McpServerConfig.java b/src/main/java/com/github/copilot/sdk/json/McpServerConfig.java new file mode 100644 index 000000000..a4531db36 --- /dev/null +++ b/src/main/java/com/github/copilot/sdk/json/McpServerConfig.java @@ -0,0 +1,98 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + *--------------------------------------------------------------------------------------------*/ + +package com.github.copilot.sdk.json; + +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; + +/** + * Abstract base class for MCP server configurations. + *

+ * Use {@link McpStdioServerConfig} for local/stdio MCP servers or + * {@link McpHttpServerConfig} for remote HTTP/SSE MCP servers. + * + *

Example: Local server

+ * + *
{@code
+ * var servers = Map.of("my-server",
+ * 		new McpStdioServerConfig().setCommand("node").setArgs(List.of("mcp-server.js")).setTools(List.of("*")));
+ * var session = client.createSession(new SessionConfig().setMcpServers(servers)).get();
+ * }
+ * + *

Example: Remote server

+ * + *
{@code
+ * var servers = Map.of("remote-server",
+ * 		new McpHttpServerConfig().setUrl("https://example.com/mcp").setTools(List.of("*")));
+ * var session = client.createSession(new SessionConfig().setMcpServers(servers)).get();
+ * }
+ * + * @see McpStdioServerConfig + * @see McpHttpServerConfig + * @see SessionConfig#setMcpServers(java.util.Map) + * @since 1.4.0 + */ +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type", defaultImpl = McpStdioServerConfig.class) +@JsonSubTypes({@JsonSubTypes.Type(value = McpStdioServerConfig.class, name = "stdio"), + @JsonSubTypes.Type(value = McpHttpServerConfig.class, name = "http")}) +@JsonInclude(JsonInclude.Include.NON_NULL) +public abstract class McpServerConfig { + + @JsonProperty("tools") + private List tools; + + @JsonProperty("timeout") + private Integer timeout; + + /** + * Private constructor to prevent direct subclassing outside this package. + */ + McpServerConfig() { + } + + /** + * Returns the list of tools to include from this server. An empty list means + * none; use {@code "*"} for all. + */ + public List getTools() { + return tools; + } + + /** + * Sets the list of tools to include from this server. Use {@code "*"} to + * include all tools. + * + * @param tools + * tool names, or {@code List.of("*")} for all + * @return this instance for method chaining + */ + public McpServerConfig setTools(List tools) { + this.tools = tools; + return this; + } + + /** + * Returns the optional timeout in milliseconds for tool calls to this server. + */ + public Integer getTimeout() { + return timeout; + } + + /** + * Sets the optional timeout in milliseconds for tool calls to this server. + * + * @param timeout + * timeout in milliseconds, or {@code null} for no override + * @return this instance for method chaining + */ + public McpServerConfig setTimeout(Integer timeout) { + this.timeout = timeout; + return this; + } +} diff --git a/src/main/java/com/github/copilot/sdk/json/McpStdioServerConfig.java b/src/main/java/com/github/copilot/sdk/json/McpStdioServerConfig.java new file mode 100644 index 000000000..53a513fb8 --- /dev/null +++ b/src/main/java/com/github/copilot/sdk/json/McpStdioServerConfig.java @@ -0,0 +1,123 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + *--------------------------------------------------------------------------------------------*/ + +package com.github.copilot.sdk.json; + +import java.util.List; +import java.util.Map; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Configuration for a local/stdio MCP server. + *

+ * Use this class to configure an MCP server that communicates over + * stdin/stdout. + * + *

Example

+ * + *
{@code
+ * var server = new McpStdioServerConfig().setCommand("node").setArgs(List.of("mcp-server.js"))
+ * 		.setEnv(Map.of("API_KEY", "secret")).setTools(List.of("*"));
+ * }
+ * + * @see McpServerConfig + * @since 1.4.0 + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +public final class McpStdioServerConfig extends McpServerConfig { + + @JsonProperty("command") + private String command; + + @JsonProperty("args") + private List args; + + @JsonProperty("env") + private Map env; + + @JsonProperty("cwd") + private String cwd; + + /** Returns the command to run the MCP server. */ + public String getCommand() { + return command; + } + + /** + * Sets the command to run the MCP server. + * + * @param command + * the executable command + * @return this instance for method chaining + */ + public McpStdioServerConfig setCommand(String command) { + this.command = command; + return this; + } + + /** Returns the arguments to pass to the command. */ + public List getArgs() { + return args; + } + + /** + * Sets the arguments to pass to the command. + * + * @param args + * command-line arguments + * @return this instance for method chaining + */ + public McpStdioServerConfig setArgs(List args) { + this.args = args; + return this; + } + + /** Returns the environment variables to pass to the server process. */ + public Map getEnv() { + return env; + } + + /** + * Sets the environment variables to pass to the server process. + * + * @param env + * environment variable map + * @return this instance for method chaining + */ + public McpStdioServerConfig setEnv(Map env) { + this.env = env; + return this; + } + + /** Returns the working directory for the server process. */ + public String getCwd() { + return cwd; + } + + /** + * Sets the working directory for the server process. + * + * @param cwd + * working directory path + * @return this instance for method chaining + */ + public McpStdioServerConfig setCwd(String cwd) { + this.cwd = cwd; + return this; + } + + @Override + public McpStdioServerConfig setTools(java.util.List tools) { + super.setTools(tools); + return this; + } + + @Override + public McpStdioServerConfig setTimeout(Integer timeout) { + super.setTimeout(timeout); + return this; + } +} diff --git a/src/main/java/com/github/copilot/sdk/json/ModelCapabilitiesOverride.java b/src/main/java/com/github/copilot/sdk/json/ModelCapabilitiesOverride.java new file mode 100644 index 000000000..a1d6d4762 --- /dev/null +++ b/src/main/java/com/github/copilot/sdk/json/ModelCapabilitiesOverride.java @@ -0,0 +1,61 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + *--------------------------------------------------------------------------------------------*/ + +package com.github.copilot.sdk.json; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Per-property overrides for model capabilities, deep-merged over runtime + * defaults. + *

+ * Use this class to override specific model capabilities when creating a + * session or switching models. Only the fields you set will be overridden; + * others remain at runtime defaults. + * + *

Example: Disable vision

+ * + *
{@code
+ * var session = client.createSession(new SessionConfig().setModel("claude-sonnet-4.5").setModelCapabilities(
+ * 		new ModelCapabilitiesOverride().setSupports(new ModelCapabilitiesOverrideSupports().setVision(false))))
+ * 		.get();
+ * }
+ * + * @see SessionConfig#setModelCapabilities(ModelCapabilitiesOverride) + * @see com.github.copilot.sdk.CopilotSession#setModel(String, String, + * ModelCapabilitiesOverride) + * @since 1.4.0 + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +public class ModelCapabilitiesOverride { + + @JsonProperty("supports") + private ModelCapabilitiesOverrideSupports supports; + + @JsonProperty("limits") + private ModelCapabilitiesOverrideLimits limits; + + /** Returns the feature flag overrides. */ + public ModelCapabilitiesOverrideSupports getSupports() { + return supports; + } + + /** Sets the feature flag overrides. */ + public ModelCapabilitiesOverride setSupports(ModelCapabilitiesOverrideSupports supports) { + this.supports = supports; + return this; + } + + /** Returns the token limit overrides. */ + public ModelCapabilitiesOverrideLimits getLimits() { + return limits; + } + + /** Sets the token limit overrides. */ + public ModelCapabilitiesOverride setLimits(ModelCapabilitiesOverrideLimits limits) { + this.limits = limits; + return this; + } +} diff --git a/src/main/java/com/github/copilot/sdk/json/ModelCapabilitiesOverrideLimits.java b/src/main/java/com/github/copilot/sdk/json/ModelCapabilitiesOverrideLimits.java new file mode 100644 index 000000000..d197c0a3c --- /dev/null +++ b/src/main/java/com/github/copilot/sdk/json/ModelCapabilitiesOverrideLimits.java @@ -0,0 +1,73 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + *--------------------------------------------------------------------------------------------*/ + +package com.github.copilot.sdk.json; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Per-property overrides for token limits within model capabilities. + * + * @since 1.4.0 + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +public class ModelCapabilitiesOverrideLimits { + + @JsonProperty("max_prompt_tokens") + private Double maxPromptTokens; + + @JsonProperty("max_output_tokens") + private Double maxOutputTokens; + + @JsonProperty("max_context_window_tokens") + private Double maxContextWindowTokens; + + @JsonProperty("vision") + private ModelCapabilitiesOverrideLimitsVision vision; + + /** Returns the maximum prompt tokens override. */ + public Double getMaxPromptTokens() { + return maxPromptTokens; + } + + /** Sets the maximum prompt tokens override. */ + public ModelCapabilitiesOverrideLimits setMaxPromptTokens(Double maxPromptTokens) { + this.maxPromptTokens = maxPromptTokens; + return this; + } + + /** Returns the maximum output tokens override. */ + public Double getMaxOutputTokens() { + return maxOutputTokens; + } + + /** Sets the maximum output tokens override. */ + public ModelCapabilitiesOverrideLimits setMaxOutputTokens(Double maxOutputTokens) { + this.maxOutputTokens = maxOutputTokens; + return this; + } + + /** Returns the maximum context window tokens override. */ + public Double getMaxContextWindowTokens() { + return maxContextWindowTokens; + } + + /** Sets the maximum context window tokens override. */ + public ModelCapabilitiesOverrideLimits setMaxContextWindowTokens(Double maxContextWindowTokens) { + this.maxContextWindowTokens = maxContextWindowTokens; + return this; + } + + /** Returns the vision limits override. */ + public ModelCapabilitiesOverrideLimitsVision getVision() { + return vision; + } + + /** Sets the vision limits override. */ + public ModelCapabilitiesOverrideLimits setVision(ModelCapabilitiesOverrideLimitsVision vision) { + this.vision = vision; + return this; + } +} diff --git a/src/main/java/com/github/copilot/sdk/json/ModelCapabilitiesOverrideLimitsVision.java b/src/main/java/com/github/copilot/sdk/json/ModelCapabilitiesOverrideLimitsVision.java new file mode 100644 index 000000000..dd283fa21 --- /dev/null +++ b/src/main/java/com/github/copilot/sdk/json/ModelCapabilitiesOverrideLimitsVision.java @@ -0,0 +1,61 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + *--------------------------------------------------------------------------------------------*/ + +package com.github.copilot.sdk.json; + +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Per-property overrides for vision limits within model capabilities. + * + * @since 1.4.0 + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +public class ModelCapabilitiesOverrideLimitsVision { + + @JsonProperty("supported_media_types") + private List supportedMediaTypes; + + @JsonProperty("max_prompt_images") + private Double maxPromptImages; + + @JsonProperty("max_prompt_image_size") + private Double maxPromptImageSize; + + /** Returns the supported media types. */ + public List getSupportedMediaTypes() { + return supportedMediaTypes; + } + + /** Sets the supported media types. */ + public ModelCapabilitiesOverrideLimitsVision setSupportedMediaTypes(List supportedMediaTypes) { + this.supportedMediaTypes = supportedMediaTypes; + return this; + } + + /** Returns the maximum number of images per prompt. */ + public Double getMaxPromptImages() { + return maxPromptImages; + } + + /** Sets the maximum number of images per prompt. */ + public ModelCapabilitiesOverrideLimitsVision setMaxPromptImages(Double maxPromptImages) { + this.maxPromptImages = maxPromptImages; + return this; + } + + /** Returns the maximum image size in bytes. */ + public Double getMaxPromptImageSize() { + return maxPromptImageSize; + } + + /** Sets the maximum image size in bytes. */ + public ModelCapabilitiesOverrideLimitsVision setMaxPromptImageSize(Double maxPromptImageSize) { + this.maxPromptImageSize = maxPromptImageSize; + return this; + } +} diff --git a/src/main/java/com/github/copilot/sdk/json/ModelCapabilitiesOverrideSupports.java b/src/main/java/com/github/copilot/sdk/json/ModelCapabilitiesOverrideSupports.java new file mode 100644 index 000000000..654a06853 --- /dev/null +++ b/src/main/java/com/github/copilot/sdk/json/ModelCapabilitiesOverrideSupports.java @@ -0,0 +1,45 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + *--------------------------------------------------------------------------------------------*/ + +package com.github.copilot.sdk.json; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Per-property overrides for model capability feature flags. + * + * @since 1.4.0 + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +public class ModelCapabilitiesOverrideSupports { + + @JsonProperty("vision") + private Boolean vision; + + @JsonProperty("reasoningEffort") + private Boolean reasoningEffort; + + /** Returns the vision capability override. */ + public Boolean getVision() { + return vision; + } + + /** Sets the vision capability override. */ + public ModelCapabilitiesOverrideSupports setVision(Boolean vision) { + this.vision = vision; + return this; + } + + /** Returns the reasoning effort capability override. */ + public Boolean getReasoningEffort() { + return reasoningEffort; + } + + /** Sets the reasoning effort capability override. */ + public ModelCapabilitiesOverrideSupports setReasoningEffort(Boolean reasoningEffort) { + this.reasoningEffort = reasoningEffort; + return this; + } +} diff --git a/src/main/java/com/github/copilot/sdk/json/ResumeSessionConfig.java b/src/main/java/com/github/copilot/sdk/json/ResumeSessionConfig.java index 139f5238b..22701fae7 100644 --- a/src/main/java/com/github/copilot/sdk/json/ResumeSessionConfig.java +++ b/src/main/java/com/github/copilot/sdk/json/ResumeSessionConfig.java @@ -51,12 +51,14 @@ public class ResumeSessionConfig { private String configDir; private boolean disableResume; private boolean streaming; - private Map mcpServers; + private Map mcpServers; private List customAgents; private String agent; private List skillDirectories; private List disabledSkills; private InfiniteSessionConfig infiniteSessions; + private Boolean enableConfigDiscovery; + private ModelCapabilitiesOverride modelCapabilities; private Consumer onEvent; private List commands; private ElicitationHandler onElicitationRequest; @@ -405,7 +407,7 @@ public ResumeSessionConfig setStreaming(boolean streaming) { * * @return the MCP servers map */ - public Map getMcpServers() { + public Map getMcpServers() { return mcpServers == null ? null : Collections.unmodifiableMap(mcpServers); } @@ -415,8 +417,10 @@ public Map getMcpServers() { * @param mcpServers * the MCP servers configuration map * @return this config for method chaining + * @see McpStdioServerConfig + * @see McpHttpServerConfig */ - public ResumeSessionConfig setMcpServers(Map mcpServers) { + public ResumeSessionConfig setMcpServers(Map mcpServers) { this.mcpServers = mcpServers; return this; } @@ -531,6 +535,58 @@ public ResumeSessionConfig setInfiniteSessions(InfiniteSessionConfig infiniteSes return this; } + /** + * Gets the enableConfigDiscovery flag. + * + * @return {@code true} if config discovery is enabled, {@code false} if + * disabled, or {@code null} to use the server default + */ + public Boolean getEnableConfigDiscovery() { + return enableConfigDiscovery; + } + + /** + * Sets whether to automatically discover MCP server configurations and skill + * directories from the working directory. + *

+ * When {@code true}, the runtime automatically discovers MCP server + * configurations (e.g. {@code .mcp.json}, {@code .vscode/mcp.json}) and skill + * directories from the working directory and merges them with any explicitly + * provided values, with explicit values taking precedence on name collision. + * + * @param enableConfigDiscovery + * {@code true} to enable auto-discovery, {@code false} to disable, + * {@code null} to use the server default + * @return this config for method chaining + */ + public ResumeSessionConfig setEnableConfigDiscovery(Boolean enableConfigDiscovery) { + this.enableConfigDiscovery = enableConfigDiscovery; + return this; + } + + /** + * Gets the model capabilities override. + * + * @return the model capabilities override, or {@code null} if not set + */ + public ModelCapabilitiesOverride getModelCapabilities() { + return modelCapabilities; + } + + /** + * Sets per-property overrides for model capabilities, deep-merged over runtime + * defaults. + * + * @param modelCapabilities + * the capabilities override + * @return this config for method chaining + * @see ModelCapabilitiesOverride + */ + public ResumeSessionConfig setModelCapabilities(ModelCapabilitiesOverride modelCapabilities) { + this.modelCapabilities = modelCapabilities; + return this; + } + /** * Gets the event handler registered before the session.resume RPC is issued. * @@ -642,6 +698,8 @@ public ResumeSessionConfig clone() { copy.skillDirectories = this.skillDirectories != null ? new ArrayList<>(this.skillDirectories) : null; copy.disabledSkills = this.disabledSkills != null ? new ArrayList<>(this.disabledSkills) : null; copy.infiniteSessions = this.infiniteSessions; + copy.enableConfigDiscovery = this.enableConfigDiscovery; + copy.modelCapabilities = this.modelCapabilities; copy.onEvent = this.onEvent; copy.commands = this.commands != null ? new ArrayList<>(this.commands) : null; copy.onElicitationRequest = this.onElicitationRequest; diff --git a/src/main/java/com/github/copilot/sdk/json/ResumeSessionRequest.java b/src/main/java/com/github/copilot/sdk/json/ResumeSessionRequest.java index 7be9a6281..14e40574b 100644 --- a/src/main/java/com/github/copilot/sdk/json/ResumeSessionRequest.java +++ b/src/main/java/com/github/copilot/sdk/json/ResumeSessionRequest.java @@ -75,7 +75,7 @@ public final class ResumeSessionRequest { private Boolean streaming; @JsonProperty("mcpServers") - private Map mcpServers; + private Map mcpServers; @JsonProperty("envValueMode") private String envValueMode; @@ -95,6 +95,12 @@ public final class ResumeSessionRequest { @JsonProperty("infiniteSessions") private InfiniteSessionConfig infiniteSessions; + @JsonProperty("enableConfigDiscovery") + private Boolean enableConfigDiscovery; + + @JsonProperty("modelCapabilities") + private ModelCapabilitiesOverride modelCapabilities; + @JsonProperty("commands") private List commands; @@ -267,12 +273,12 @@ public void setStreaming(Boolean streaming) { } /** Gets MCP servers. @return the servers map */ - public Map getMcpServers() { + public Map getMcpServers() { return mcpServers == null ? null : Collections.unmodifiableMap(mcpServers); } /** Sets MCP servers. @param mcpServers the servers map */ - public void setMcpServers(Map mcpServers) { + public void setMcpServers(Map mcpServers) { this.mcpServers = mcpServers; } @@ -339,6 +345,30 @@ public void setInfiniteSessions(InfiniteSessionConfig infiniteSessions) { this.infiniteSessions = infiniteSessions; } + /** Gets the enableConfigDiscovery flag. @return the flag */ + public Boolean getEnableConfigDiscovery() { + return enableConfigDiscovery; + } + + /** + * Sets the enableConfigDiscovery flag. @param enableConfigDiscovery the flag + */ + public void setEnableConfigDiscovery(Boolean enableConfigDiscovery) { + this.enableConfigDiscovery = enableConfigDiscovery; + } + + /** 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; + } + /** Gets the commands wire definitions. @return the commands */ public List getCommands() { return commands == null ? null : Collections.unmodifiableList(commands); diff --git a/src/main/java/com/github/copilot/sdk/json/SessionConfig.java b/src/main/java/com/github/copilot/sdk/json/SessionConfig.java index 5dcd39788..fe7f24913 100644 --- a/src/main/java/com/github/copilot/sdk/json/SessionConfig.java +++ b/src/main/java/com/github/copilot/sdk/json/SessionConfig.java @@ -6,6 +6,7 @@ import java.util.ArrayList; import java.util.Collections; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.function.Consumer; @@ -50,13 +51,15 @@ public class SessionConfig { private SessionHooks hooks; private String workingDirectory; private boolean streaming; - private Map mcpServers; + private Map mcpServers; private List customAgents; private String agent; private InfiniteSessionConfig infiniteSessions; private List skillDirectories; private List disabledSkills; private String configDir; + private Boolean enableConfigDiscovery; + private ModelCapabilitiesOverride modelCapabilities; private Consumer onEvent; private List commands; private ElicitationHandler onElicitationRequest; @@ -401,7 +404,7 @@ public SessionConfig setStreaming(boolean streaming) { * * @return the MCP servers map */ - public Map getMcpServers() { + public Map getMcpServers() { return mcpServers == null ? null : Collections.unmodifiableMap(mcpServers); } @@ -409,13 +412,16 @@ public Map getMcpServers() { * Sets MCP (Model Context Protocol) server configurations. *

* MCP servers extend the assistant's capabilities by providing additional - * context sources and tools. + * context sources and tools. Use {@link McpStdioServerConfig} for local/stdio + * servers and {@link McpHttpServerConfig} for remote HTTP servers. * * @param mcpServers * the MCP servers configuration map * @return this config instance for method chaining + * @see McpStdioServerConfig + * @see McpHttpServerConfig */ - public SessionConfig setMcpServers(Map mcpServers) { + public SessionConfig setMcpServers(Map mcpServers) { this.mcpServers = mcpServers; return this; } @@ -568,6 +574,67 @@ public SessionConfig setConfigDir(String configDir) { return this; } + /** + * Gets the enableConfigDiscovery flag. + * + * @return {@code true} if config discovery is enabled, {@code false} if + * disabled, or {@code null} to use the server default + */ + public Boolean getEnableConfigDiscovery() { + return enableConfigDiscovery; + } + + /** + * Sets whether to automatically discover MCP server configurations and skill + * directories from the working directory. + *

+ * When {@code true}, the runtime automatically discovers MCP server + * configurations (e.g. {@code .mcp.json}, {@code .vscode/mcp.json}) and skill + * directories from the working directory and merges them with any explicitly + * provided {@link #setMcpServers(Map) McpServers} and + * {@link #setSkillDirectories(List) SkillDirectories}, with explicit values + * taking precedence on name collision. + *

+ * Custom instruction files ({@code .github/copilot-instructions.md}, + * {@code AGENTS.md}, etc.) are always loaded from the working directory + * regardless of this setting. + * + * @param enableConfigDiscovery + * {@code true} to enable auto-discovery, {@code false} to disable, + * {@code null} to use the server default + * @return this config instance for method chaining + */ + public SessionConfig setEnableConfigDiscovery(Boolean enableConfigDiscovery) { + this.enableConfigDiscovery = enableConfigDiscovery; + return this; + } + + /** + * Gets the model capabilities override. + * + * @return the model capabilities override, or {@code null} if not set + */ + public ModelCapabilitiesOverride getModelCapabilities() { + return modelCapabilities; + } + + /** + * Sets per-property overrides for model capabilities, deep-merged over runtime + * defaults. + *

+ * Use this to override specific capabilities such as vision support or token + * limits for the session. + * + * @param modelCapabilities + * the capabilities override + * @return this config instance for method chaining + * @see ModelCapabilitiesOverride + */ + public SessionConfig setModelCapabilities(ModelCapabilitiesOverride modelCapabilities) { + this.modelCapabilities = modelCapabilities; + return this; + } + /** * Gets the event handler registered before the session.create RPC is issued. * @@ -675,13 +742,15 @@ public SessionConfig clone() { copy.hooks = this.hooks; copy.workingDirectory = this.workingDirectory; copy.streaming = this.streaming; - copy.mcpServers = this.mcpServers != null ? new java.util.HashMap<>(this.mcpServers) : null; + copy.mcpServers = this.mcpServers != null ? new HashMap<>(this.mcpServers) : null; copy.customAgents = this.customAgents != null ? new ArrayList<>(this.customAgents) : null; copy.agent = this.agent; copy.infiniteSessions = this.infiniteSessions; copy.skillDirectories = this.skillDirectories != null ? new ArrayList<>(this.skillDirectories) : null; copy.disabledSkills = this.disabledSkills != null ? new ArrayList<>(this.disabledSkills) : null; copy.configDir = this.configDir; + copy.enableConfigDiscovery = this.enableConfigDiscovery; + copy.modelCapabilities = this.modelCapabilities; copy.onEvent = this.onEvent; copy.commands = this.commands != null ? new ArrayList<>(this.commands) : null; copy.onElicitationRequest = this.onElicitationRequest; diff --git a/src/site/markdown/index.md b/src/site/markdown/index.md index 60b96ce9d..e31699cf3 100644 --- a/src/site/markdown/index.md +++ b/src/site/markdown/index.md @@ -9,7 +9,7 @@ Welcome to the documentation for the **GitHub Copilot SDK for Java** — a Java ### Requirements - Java 17 or later -- GitHub Copilot CLI 1.0.17 or later installed and in PATH (or provide custom `cliPath`) +- GitHub Copilot CLI 1.0.22 or later installed and in PATH (or provide custom `cliPath`) ### Installation diff --git a/src/test/java/com/github/copilot/sdk/McpAndAgentsTest.java b/src/test/java/com/github/copilot/sdk/McpAndAgentsTest.java index 84aa3b341..98313503c 100644 --- a/src/test/java/com/github/copilot/sdk/McpAndAgentsTest.java +++ b/src/test/java/com/github/copilot/sdk/McpAndAgentsTest.java @@ -8,7 +8,6 @@ import java.util.HashMap; import java.util.List; -import java.util.Map; import java.util.concurrent.TimeUnit; import org.junit.jupiter.api.AfterAll; @@ -17,6 +16,8 @@ import com.github.copilot.sdk.events.AssistantMessageEvent; import com.github.copilot.sdk.json.CustomAgentConfig; +import com.github.copilot.sdk.json.McpServerConfig; +import com.github.copilot.sdk.json.McpStdioServerConfig; import com.github.copilot.sdk.json.MessageOptions; import com.github.copilot.sdk.json.PermissionHandler; import com.github.copilot.sdk.json.ResumeSessionConfig; @@ -46,14 +47,9 @@ static void teardown() throws Exception { } } - // Helper method to create an MCP local server configuration - private Map createLocalMcpServer(String command, List args) { - var server = new HashMap(); - server.put("type", "local"); - server.put("command", command); - server.put("args", args); - server.put("tools", List.of("*")); - return server; + // Helper method to create an MCP stdio server configuration + private McpStdioServerConfig createLocalMcpServer(String command, List args) { + return new McpStdioServerConfig().setCommand(command).setArgs(args).setTools(List.of("*")); } // ============ MCP Server Tests ============ @@ -68,7 +64,7 @@ private Map createLocalMcpServer(String command, List ar void testShouldAcceptMcpServerConfigurationOnSessionCreate() throws Exception { ctx.configureForTest("mcp_and_agents", "should_accept_mcp_server_configuration_on_session_create"); - var mcpServers = new HashMap(); + var mcpServers = new HashMap(); mcpServers.put("test-server", createLocalMcpServer("echo", List.of("hello"))); try (CopilotClient client = ctx.createClient()) { @@ -108,7 +104,7 @@ void testShouldAcceptMcpServerConfigurationOnSessionResume() throws Exception { session1.sendAndWait(new MessageOptions().setPrompt("What is 1+1?")).get(60, TimeUnit.SECONDS); // Resume with MCP servers - var mcpServers = new HashMap(); + var mcpServers = new HashMap(); mcpServers.put("test-server", createLocalMcpServer("echo", List.of("hello"))); CopilotSession session2 = client.resumeSession(sessionId, new ResumeSessionConfig() @@ -139,7 +135,7 @@ void testShouldHandleMultipleMcpServers() throws Exception { // count ctx.configureForTest("mcp_and_agents", "should_accept_mcp_server_configuration_on_session_create"); - var mcpServers = new HashMap(); + var mcpServers = new HashMap(); mcpServers.put("server1", createLocalMcpServer("echo", List.of("server1"))); mcpServers.put("server2", createLocalMcpServer("echo", List.of("server2"))); @@ -261,7 +257,7 @@ void testShouldAcceptCustomAgentWithMcpServers() throws Exception { // Use combined snapshot since this uses both MCP servers and custom agents ctx.configureForTest("mcp_and_agents", "should_accept_both_mcp_servers_and_custom_agents"); - var agentMcpServers = new HashMap(); + var agentMcpServers = new HashMap(); agentMcpServers.put("agent-server", createLocalMcpServer("echo", List.of("agent-mcp"))); List customAgents = List.of(new CustomAgentConfig().setName("mcp-agent") @@ -315,7 +311,7 @@ void testShouldAcceptMultipleCustomAgents() throws Exception { void testShouldAcceptBothMcpServersAndCustomAgents() throws Exception { ctx.configureForTest("mcp_and_agents", "should_accept_both_mcp_servers_and_custom_agents"); - var mcpServers = new HashMap(); + var mcpServers = new HashMap(); mcpServers.put("shared-server", createLocalMcpServer("echo", List.of("shared"))); List customAgents = List.of(new CustomAgentConfig().setName("combined-agent") From aa17d3a2a8e718711698aab14a69799fef9d16eb Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 13 Apr 2026 11:08:18 +0000 Subject: [PATCH 3/3] Port Session FS support: SessionFsHandler, types, config, and RPC registration Agent-Logs-Url: https://github.com/github/copilot-sdk-java/sessions/6440ac65-a609-41e9-8afc-718bccbef08a Co-authored-by: edburns <75821+edburns@users.noreply.github.com> --- .lastmerge | 2 +- .../com/github/copilot/sdk/CopilotClient.java | 38 ++++++++ .../github/copilot/sdk/CopilotSession.java | 20 ++++ .../copilot/sdk/RpcHandlerDispatcher.java | 92 +++++++++++++++++++ .../sdk/json/CopilotClientOptions.java | 32 +++++++ .../copilot/sdk/json/ResumeSessionConfig.java | 33 +++++++ .../copilot/sdk/json/SessionConfig.java | 35 +++++++ .../sdk/json/SessionFsAppendFileParams.java | 65 +++++++++++++ .../copilot/sdk/json/SessionFsConfig.java | 85 +++++++++++++++++ .../sdk/json/SessionFsConventions.java | 23 +++++ .../sdk/json/SessionFsCopyDirParams.java | 50 ++++++++++ .../copilot/sdk/json/SessionFsCpParams.java | 65 +++++++++++++ .../sdk/json/SessionFsDirentEntry.java | 37 ++++++++ .../sdk/json/SessionFsExistsParams.java | 37 ++++++++ .../sdk/json/SessionFsExistsResult.java | 24 +++++ .../copilot/sdk/json/SessionFsGlobParams.java | 39 ++++++++ .../copilot/sdk/json/SessionFsGlobResult.java | 26 ++++++ .../copilot/sdk/json/SessionFsHandler.java | 79 ++++++++++++++++ .../sdk/json/SessionFsMkdirParams.java | 65 +++++++++++++ .../sdk/json/SessionFsReadFileParams.java | 37 ++++++++ .../sdk/json/SessionFsReadFileResult.java | 24 +++++ .../sdk/json/SessionFsReaddirParams.java | 37 ++++++++ .../sdk/json/SessionFsReaddirResult.java | 26 ++++++ .../json/SessionFsReaddirWithTypesResult.java | 26 ++++++ .../sdk/json/SessionFsRenameParams.java | 65 +++++++++++++ .../copilot/sdk/json/SessionFsRmParams.java | 65 +++++++++++++ .../copilot/sdk/json/SessionFsStatParams.java | 37 ++++++++ .../copilot/sdk/json/SessionFsStatResult.java | 76 +++++++++++++++ .../sdk/json/SessionFsWriteFileParams.java | 65 +++++++++++++ 29 files changed, 1304 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/github/copilot/sdk/json/SessionFsAppendFileParams.java create mode 100644 src/main/java/com/github/copilot/sdk/json/SessionFsConfig.java create mode 100644 src/main/java/com/github/copilot/sdk/json/SessionFsConventions.java create mode 100644 src/main/java/com/github/copilot/sdk/json/SessionFsCopyDirParams.java create mode 100644 src/main/java/com/github/copilot/sdk/json/SessionFsCpParams.java create mode 100644 src/main/java/com/github/copilot/sdk/json/SessionFsDirentEntry.java create mode 100644 src/main/java/com/github/copilot/sdk/json/SessionFsExistsParams.java create mode 100644 src/main/java/com/github/copilot/sdk/json/SessionFsExistsResult.java create mode 100644 src/main/java/com/github/copilot/sdk/json/SessionFsGlobParams.java create mode 100644 src/main/java/com/github/copilot/sdk/json/SessionFsGlobResult.java create mode 100644 src/main/java/com/github/copilot/sdk/json/SessionFsHandler.java create mode 100644 src/main/java/com/github/copilot/sdk/json/SessionFsMkdirParams.java create mode 100644 src/main/java/com/github/copilot/sdk/json/SessionFsReadFileParams.java create mode 100644 src/main/java/com/github/copilot/sdk/json/SessionFsReadFileResult.java create mode 100644 src/main/java/com/github/copilot/sdk/json/SessionFsReaddirParams.java create mode 100644 src/main/java/com/github/copilot/sdk/json/SessionFsReaddirResult.java create mode 100644 src/main/java/com/github/copilot/sdk/json/SessionFsReaddirWithTypesResult.java create mode 100644 src/main/java/com/github/copilot/sdk/json/SessionFsRenameParams.java create mode 100644 src/main/java/com/github/copilot/sdk/json/SessionFsRmParams.java create mode 100644 src/main/java/com/github/copilot/sdk/json/SessionFsStatParams.java create mode 100644 src/main/java/com/github/copilot/sdk/json/SessionFsStatResult.java create mode 100644 src/main/java/com/github/copilot/sdk/json/SessionFsWriteFileParams.java diff --git a/.lastmerge b/.lastmerge index 83feb636c..1d71f1f4c 100644 --- a/.lastmerge +++ b/.lastmerge @@ -1 +1 @@ -c3fa6cbfb83d4a20b7912b1a17013d48f5a277a1 +16f0ba278ebb25e2cd6326f932d60517ea926431 diff --git a/src/main/java/com/github/copilot/sdk/CopilotClient.java b/src/main/java/com/github/copilot/sdk/CopilotClient.java index f00e2fd11..8e88b7999 100644 --- a/src/main/java/com/github/copilot/sdk/CopilotClient.java +++ b/src/main/java/com/github/copilot/sdk/CopilotClient.java @@ -33,6 +33,8 @@ import com.github.copilot.sdk.json.ResumeSessionConfig; import com.github.copilot.sdk.json.ResumeSessionResponse; import com.github.copilot.sdk.json.SessionConfig; +import com.github.copilot.sdk.json.SessionFsConventions; +import com.github.copilot.sdk.json.SessionFsHandler; import com.github.copilot.sdk.json.SessionLifecycleHandler; import com.github.copilot.sdk.json.SessionListFilter; import com.github.copilot.sdk.json.SessionMetadata; @@ -189,6 +191,9 @@ private Connection startCoreBody() { // Verify protocol version verifyProtocolVersion(connection); + // Register as sessionFs provider if configured + configureSessionFs(connection); + LOG.info("Copilot client connected"); return connection; } catch (Exception e) { @@ -202,6 +207,37 @@ private Connection startCoreBody() { private static final int MIN_PROTOCOL_VERSION = 2; + private void configureSessionFs(Connection connection) throws Exception { + var sessionFsOptions = options.getSessionFs(); + if (sessionFsOptions == null) { + return; + } + var params = new HashMap(); + params.put("initialCwd", sessionFsOptions.getInitialCwd()); + params.put("sessionStatePath", sessionFsOptions.getSessionStatePath()); + SessionFsConventions conventions = sessionFsOptions.getConventions(); + if (conventions != null) { + params.put("conventions", conventions == SessionFsConventions.POSIX ? "posix" : "windows"); + } + connection.rpc.invoke("sessionFs.setProvider", params, Void.class).get(30, TimeUnit.SECONDS); + } + + private void configureSessionFsHandler(CopilotSession session, + java.util.function.Function createSessionFsHandler) { + if (options.getSessionFs() == null) { + return; + } + if (createSessionFsHandler == null) { + throw new IllegalArgumentException( + "CreateSessionFsHandler is required in the session config when CopilotClientOptions.sessionFs is configured."); + } + SessionFsHandler handler = createSessionFsHandler.apply(session); + if (handler == null) { + throw new IllegalArgumentException("createSessionFsHandler returned null."); + } + session.registerSessionFsHandler(handler); + } + private void verifyProtocolVersion(Connection connection) throws Exception { int expectedVersion = SdkProtocolVersion.get(); var params = new HashMap(); @@ -357,6 +393,7 @@ public CompletableFuture createSession(SessionConfig config) { session.setExecutor(options.getExecutor()); } SessionRequestBuilder.configureSession(session, config); + configureSessionFsHandler(session, config.getCreateSessionFsHandler()); sessions.put(sessionId, session); // Extract transform callbacks from the system message config. @@ -431,6 +468,7 @@ public CompletableFuture resumeSession(String sessionId, ResumeS session.setExecutor(options.getExecutor()); } SessionRequestBuilder.configureSession(session, config); + configureSessionFsHandler(session, config.getCreateSessionFsHandler()); sessions.put(sessionId, session); // Extract transform callbacks from the system message config. diff --git a/src/main/java/com/github/copilot/sdk/CopilotSession.java b/src/main/java/com/github/copilot/sdk/CopilotSession.java index ff9c3e241..18aeb1c3c 100644 --- a/src/main/java/com/github/copilot/sdk/CopilotSession.java +++ b/src/main/java/com/github/copilot/sdk/CopilotSession.java @@ -55,6 +55,7 @@ import com.github.copilot.sdk.json.MessageOptions; import com.github.copilot.sdk.json.ModelCapabilitiesOverride; import com.github.copilot.sdk.json.PermissionHandler; +import com.github.copilot.sdk.json.SessionFsHandler; import com.github.copilot.sdk.json.PermissionInvocation; import com.github.copilot.sdk.json.PermissionRequest; import com.github.copilot.sdk.json.PermissionRequestResult; @@ -143,6 +144,7 @@ public final class CopilotSession implements AutoCloseable { private final AtomicReference userInputHandler = new AtomicReference<>(); private final AtomicReference elicitationHandler = new AtomicReference<>(); private final AtomicReference hooksHandler = new AtomicReference<>(); + private final AtomicReference sessionFsHandler = new AtomicReference<>(); private volatile EventErrorHandler eventErrorHandler; private volatile EventErrorPolicy eventErrorPolicy = EventErrorPolicy.PROPAGATE_AND_LOG_ERRORS; private volatile Map>> transformCallbacks; @@ -1299,6 +1301,24 @@ void registerHooks(SessionHooks hooks) { hooksHandler.set(hooks); } + /** + * Registers the session filesystem handler for this session. + * + * @param handler + * the handler to register + */ + void registerSessionFsHandler(SessionFsHandler handler) { + sessionFsHandler.set(handler); + } + + /** + * Returns the registered session filesystem handler, or {@code null} if none is + * registered. + */ + SessionFsHandler getSessionFsHandler() { + return sessionFsHandler.get(); + } + /** * Registers transform callbacks for system message sections. *

diff --git a/src/main/java/com/github/copilot/sdk/RpcHandlerDispatcher.java b/src/main/java/com/github/copilot/sdk/RpcHandlerDispatcher.java index f1d488105..9079e236f 100644 --- a/src/main/java/com/github/copilot/sdk/RpcHandlerDispatcher.java +++ b/src/main/java/com/github/copilot/sdk/RpcHandlerDispatcher.java @@ -20,6 +20,19 @@ import com.github.copilot.sdk.events.SessionEventParser; import com.github.copilot.sdk.json.PermissionRequestResult; import com.github.copilot.sdk.json.PermissionRequestResultKind; +import com.github.copilot.sdk.json.SessionFsAppendFileParams; +import com.github.copilot.sdk.json.SessionFsCopyDirParams; +import com.github.copilot.sdk.json.SessionFsCpParams; +import com.github.copilot.sdk.json.SessionFsExistsParams; +import com.github.copilot.sdk.json.SessionFsGlobParams; +import com.github.copilot.sdk.json.SessionFsHandler; +import com.github.copilot.sdk.json.SessionFsMkdirParams; +import com.github.copilot.sdk.json.SessionFsReaddirParams; +import com.github.copilot.sdk.json.SessionFsReadFileParams; +import com.github.copilot.sdk.json.SessionFsRenameParams; +import com.github.copilot.sdk.json.SessionFsRmParams; +import com.github.copilot.sdk.json.SessionFsStatParams; +import com.github.copilot.sdk.json.SessionFsWriteFileParams; import com.github.copilot.sdk.json.SessionLifecycleEvent; import com.github.copilot.sdk.json.SessionLifecycleEventMetadata; import com.github.copilot.sdk.json.ToolDefinition; @@ -83,6 +96,32 @@ void registerHandlers(JsonRpcClient rpc) { rpc.registerMethodHandler("hooks.invoke", (requestId, params) -> handleHooksInvoke(rpc, requestId, params)); rpc.registerMethodHandler("systemMessage.transform", (requestId, params) -> handleSystemMessageTransform(rpc, requestId, params)); + rpc.registerMethodHandler("sessionFs.readFile", (requestId, params) -> handleSessionFsCall(rpc, requestId, + params, "readFile", SessionFsReadFileParams.class, (h, p) -> h.readFile(p))); + rpc.registerMethodHandler("sessionFs.writeFile", (requestId, params) -> handleSessionFsVoidCall(rpc, requestId, + params, "writeFile", SessionFsWriteFileParams.class, (h, p) -> h.writeFile(p))); + rpc.registerMethodHandler("sessionFs.appendFile", (requestId, params) -> handleSessionFsVoidCall(rpc, requestId, + params, "appendFile", SessionFsAppendFileParams.class, (h, p) -> h.appendFile(p))); + rpc.registerMethodHandler("sessionFs.exists", (requestId, params) -> handleSessionFsCall(rpc, requestId, params, + "exists", SessionFsExistsParams.class, (h, p) -> h.exists(p))); + rpc.registerMethodHandler("sessionFs.stat", (requestId, params) -> handleSessionFsCall(rpc, requestId, params, + "stat", SessionFsStatParams.class, (h, p) -> h.stat(p))); + rpc.registerMethodHandler("sessionFs.mkdir", (requestId, params) -> handleSessionFsVoidCall(rpc, requestId, + params, "mkdir", SessionFsMkdirParams.class, (h, p) -> h.mkdir(p))); + rpc.registerMethodHandler("sessionFs.readdir", (requestId, params) -> handleSessionFsCall(rpc, requestId, + params, "readdir", SessionFsReaddirParams.class, (h, p) -> h.readdir(p))); + rpc.registerMethodHandler("sessionFs.readdirWithTypes", (requestId, params) -> handleSessionFsCall(rpc, + requestId, params, "readdirWithTypes", SessionFsReaddirParams.class, (h, p) -> h.readdirWithTypes(p))); + rpc.registerMethodHandler("sessionFs.rm", (requestId, params) -> handleSessionFsVoidCall(rpc, requestId, params, + "rm", SessionFsRmParams.class, (h, p) -> h.rm(p))); + rpc.registerMethodHandler("sessionFs.rename", (requestId, params) -> handleSessionFsVoidCall(rpc, requestId, + params, "rename", SessionFsRenameParams.class, (h, p) -> h.rename(p))); + rpc.registerMethodHandler("sessionFs.cp", (requestId, params) -> handleSessionFsVoidCall(rpc, requestId, params, + "cp", SessionFsCpParams.class, (h, p) -> h.cp(p))); + rpc.registerMethodHandler("sessionFs.copyDir", (requestId, params) -> handleSessionFsVoidCall(rpc, requestId, + params, "copyDir", SessionFsCopyDirParams.class, (h, p) -> h.copyDir(p))); + rpc.registerMethodHandler("sessionFs.glob", (requestId, params) -> handleSessionFsCall(rpc, requestId, params, + "glob", SessionFsGlobParams.class, (h, p) -> h.glob(p))); } private void handleSessionEvent(JsonNode params) { @@ -379,4 +418,57 @@ private void runAsync(Runnable task) { task.run(); } } + + @FunctionalInterface + private interface SessionFsOp { + + CompletableFuture call(SessionFsHandler handler, P params); + } + + private void handleSessionFsCall(JsonRpcClient rpc, String requestId, JsonNode params, String opName, + Class

paramsClass, SessionFsOp op) { + runAsync(() -> { + try { + P p = MAPPER.treeToValue(params, paramsClass); + String sessionId = params.has("sessionId") ? params.get("sessionId").asText() : null; + CopilotSession session = sessionId != null ? sessions.get(sessionId) : null; + if (session == null) { + rpc.sendErrorResponse(Long.parseLong(requestId), -32602, "Unknown session: " + sessionId); + return; + } + SessionFsHandler handler = session.getSessionFsHandler(); + if (handler == null) { + rpc.sendErrorResponse(Long.parseLong(requestId), -32603, + "No sessionFs handler registered for session: " + sessionId); + return; + } + op.call(handler, p).thenAccept(result -> { + try { + rpc.sendResponse(Long.parseLong(requestId), result); + } catch (Exception e) { + LOG.log(Level.SEVERE, "Error sending sessionFs." + opName + " response", e); + } + }).exceptionally(ex -> { + try { + rpc.sendErrorResponse(Long.parseLong(requestId), -32603, ex.getMessage()); + } catch (IOException e) { + LOG.log(Level.SEVERE, "Failed to send sessionFs." + opName + " error", e); + } + return null; + }); + } catch (Exception e) { + LOG.log(Level.SEVERE, "Error handling sessionFs." + opName, e); + try { + rpc.sendErrorResponse(Long.parseLong(requestId), -32603, e.getMessage()); + } catch (IOException ioe) { + LOG.log(Level.SEVERE, "Failed to send error response", ioe); + } + } + }); + } + + private

void handleSessionFsVoidCall(JsonRpcClient rpc, String requestId, JsonNode params, String opName, + Class

paramsClass, SessionFsOp op) { + handleSessionFsCall(rpc, requestId, params, opName, paramsClass, (h, p) -> op.call(h, p).thenApply(v -> null)); + } } diff --git a/src/main/java/com/github/copilot/sdk/json/CopilotClientOptions.java b/src/main/java/com/github/copilot/sdk/json/CopilotClientOptions.java index 2e9a80456..f6d063737 100644 --- a/src/main/java/com/github/copilot/sdk/json/CopilotClientOptions.java +++ b/src/main/java/com/github/copilot/sdk/json/CopilotClientOptions.java @@ -51,6 +51,7 @@ public class CopilotClientOptions { private String logLevel = "info"; private Supplier>> onListModels; private int port; + private SessionFsConfig sessionFs; private TelemetryConfig telemetry; private Boolean useLoggedInUser; private boolean useStdio = true; @@ -404,6 +405,36 @@ public CopilotClientOptions setPort(int port) { return this; } + /** + * Gets the session filesystem configuration. + * + * @return the session filesystem config, or {@code null} if not set + * @since 1.4.0 + */ + public SessionFsConfig getSessionFs() { + return sessionFs; + } + + /** + * Sets the session filesystem provider configuration. + *

+ * When set, the client registers as the session filesystem provider on connect, + * routing session-scoped file I/O through per-session handlers created via + * {@link SessionConfig#setCreateSessionFsHandler(java.util.function.Function) + * SessionConfig.createSessionFsHandler} or + * {@link ResumeSessionConfig#setCreateSessionFsHandler(java.util.function.Function) + * ResumeSessionConfig.createSessionFsHandler}. + * + * @param sessionFs + * the session filesystem configuration + * @return this options instance for method chaining + * @since 1.4.0 + */ + public CopilotClientOptions setSessionFs(SessionFsConfig sessionFs) { + this.sessionFs = sessionFs; + return this; + } + /** * Gets the OpenTelemetry configuration for the CLI server. * @@ -508,6 +539,7 @@ public CopilotClientOptions clone() { copy.logLevel = this.logLevel; copy.onListModels = this.onListModels; copy.port = this.port; + copy.sessionFs = this.sessionFs; copy.telemetry = this.telemetry; copy.useLoggedInUser = this.useLoggedInUser; copy.useStdio = this.useStdio; diff --git a/src/main/java/com/github/copilot/sdk/json/ResumeSessionConfig.java b/src/main/java/com/github/copilot/sdk/json/ResumeSessionConfig.java index 22701fae7..cb6af253e 100644 --- a/src/main/java/com/github/copilot/sdk/json/ResumeSessionConfig.java +++ b/src/main/java/com/github/copilot/sdk/json/ResumeSessionConfig.java @@ -9,6 +9,7 @@ import java.util.List; import java.util.Map; import java.util.function.Consumer; +import java.util.function.Function; import com.fasterxml.jackson.annotation.JsonInclude; @@ -59,6 +60,7 @@ public class ResumeSessionConfig { private InfiniteSessionConfig infiniteSessions; private Boolean enableConfigDiscovery; private ModelCapabilitiesOverride modelCapabilities; + private Function createSessionFsHandler; private Consumer onEvent; private List commands; private ElicitationHandler onElicitationRequest; @@ -587,6 +589,36 @@ public ResumeSessionConfig setModelCapabilities(ModelCapabilitiesOverride modelC return this; } + /** + * Gets the session filesystem handler factory. + * + * @return the handler factory, or {@code null} if not set + * @since 1.4.0 + */ + public Function getCreateSessionFsHandler() { + return createSessionFsHandler; + } + + /** + * Sets a factory function that creates a {@link SessionFsHandler} for each + * session. + *

+ * This is only used when + * {@link com.github.copilot.sdk.json.CopilotClientOptions#setSessionFs(SessionFsConfig) + * CopilotClientOptions.sessionFs} is configured. + * + * @param createSessionFsHandler + * the handler factory + * @return this config for method chaining + * @see SessionFsHandler + * @since 1.4.0 + */ + public ResumeSessionConfig setCreateSessionFsHandler( + Function createSessionFsHandler) { + this.createSessionFsHandler = createSessionFsHandler; + return this; + } + /** * Gets the event handler registered before the session.resume RPC is issued. * @@ -700,6 +732,7 @@ public ResumeSessionConfig clone() { copy.infiniteSessions = this.infiniteSessions; copy.enableConfigDiscovery = this.enableConfigDiscovery; copy.modelCapabilities = this.modelCapabilities; + copy.createSessionFsHandler = this.createSessionFsHandler; copy.onEvent = this.onEvent; copy.commands = this.commands != null ? new ArrayList<>(this.commands) : null; copy.onElicitationRequest = this.onElicitationRequest; diff --git a/src/main/java/com/github/copilot/sdk/json/SessionConfig.java b/src/main/java/com/github/copilot/sdk/json/SessionConfig.java index fe7f24913..ab13acdeb 100644 --- a/src/main/java/com/github/copilot/sdk/json/SessionConfig.java +++ b/src/main/java/com/github/copilot/sdk/json/SessionConfig.java @@ -10,6 +10,7 @@ import java.util.List; import java.util.Map; import java.util.function.Consumer; +import java.util.function.Function; import com.fasterxml.jackson.annotation.JsonInclude; @@ -60,6 +61,7 @@ public class SessionConfig { private String configDir; private Boolean enableConfigDiscovery; private ModelCapabilitiesOverride modelCapabilities; + private Function createSessionFsHandler; private Consumer onEvent; private List commands; private ElicitationHandler onElicitationRequest; @@ -635,6 +637,38 @@ public SessionConfig setModelCapabilities(ModelCapabilitiesOverride modelCapabil return this; } + /** + * Gets the session filesystem handler factory. + * + * @return the handler factory, or {@code null} if not set + * @since 1.4.0 + */ + public Function getCreateSessionFsHandler() { + return createSessionFsHandler; + } + + /** + * Sets a factory function that creates a {@link SessionFsHandler} for each + * session. + *

+ * This is only used when + * {@link com.github.copilot.sdk.json.CopilotClientOptions#setSessionFs(SessionFsConfig) + * CopilotClientOptions.sessionFs} is configured. The factory is called with the + * session instance when the session is created, and the returned handler is + * used to route file I/O for that session. + * + * @param createSessionFsHandler + * the handler factory + * @return this config instance for method chaining + * @see SessionFsHandler + * @since 1.4.0 + */ + public SessionConfig setCreateSessionFsHandler( + Function createSessionFsHandler) { + this.createSessionFsHandler = createSessionFsHandler; + return this; + } + /** * Gets the event handler registered before the session.create RPC is issued. * @@ -751,6 +785,7 @@ public SessionConfig clone() { copy.configDir = this.configDir; copy.enableConfigDiscovery = this.enableConfigDiscovery; copy.modelCapabilities = this.modelCapabilities; + copy.createSessionFsHandler = this.createSessionFsHandler; copy.onEvent = this.onEvent; copy.commands = this.commands != null ? new ArrayList<>(this.commands) : null; copy.onElicitationRequest = this.onElicitationRequest; diff --git a/src/main/java/com/github/copilot/sdk/json/SessionFsAppendFileParams.java b/src/main/java/com/github/copilot/sdk/json/SessionFsAppendFileParams.java new file mode 100644 index 000000000..c1f3126fc --- /dev/null +++ b/src/main/java/com/github/copilot/sdk/json/SessionFsAppendFileParams.java @@ -0,0 +1,65 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + *--------------------------------------------------------------------------------------------*/ + +package com.github.copilot.sdk.json; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** Parameters for sessionFs.appendFile. */ +@JsonInclude(JsonInclude.Include.NON_NULL) +public class SessionFsAppendFileParams { + + @JsonProperty("sessionId") + private String sessionId; + + @JsonProperty("path") + private String path; + + @JsonProperty("content") + private String content; + + @JsonProperty("mode") + private Double mode; + + /** Returns the session ID. */ + public String getSessionId() { + return sessionId; + } + + /** Sets the session ID. */ + public void setSessionId(String sessionId) { + this.sessionId = sessionId; + } + + /** Returns the path. */ + public String getPath() { + return path; + } + + /** Sets the path. */ + public void setPath(String path) { + this.path = path; + } + + /** Returns the content to append. */ + public String getContent() { + return content; + } + + /** Sets the content to append. */ + public void setContent(String content) { + this.content = content; + } + + /** Returns the optional POSIX-style mode. */ + public Double getMode() { + return mode; + } + + /** Sets the optional POSIX-style mode. */ + public void setMode(Double mode) { + this.mode = mode; + } +} diff --git a/src/main/java/com/github/copilot/sdk/json/SessionFsConfig.java b/src/main/java/com/github/copilot/sdk/json/SessionFsConfig.java new file mode 100644 index 000000000..7f75d66ea --- /dev/null +++ b/src/main/java/com/github/copilot/sdk/json/SessionFsConfig.java @@ -0,0 +1,85 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + *--------------------------------------------------------------------------------------------*/ + +package com.github.copilot.sdk.json; + +/** + * Configuration for a custom session filesystem provider. + *

+ * When set on {@link com.github.copilot.sdk.json.CopilotClientOptions}, the + * client registers as the session filesystem provider on connect, routing + * session-scoped file I/O through per-session handlers created by the + * {@code createSessionFsHandler} function in {@link SessionConfig} or + * {@link ResumeSessionConfig}. + * + * @see com.github.copilot.sdk.json.CopilotClientOptions#setSessionFs(SessionFsConfig) + * @see SessionConfig#setCreateSessionFsHandler(java.util.function.Function) + * @since 1.4.0 + */ +public class SessionFsConfig { + + private String initialCwd; + private String sessionStatePath; + private SessionFsConventions conventions; + + /** + * Returns the initial working directory for sessions (user's project + * directory). + */ + public String getInitialCwd() { + return initialCwd; + } + + /** + * Sets the initial working directory for sessions. + * + * @param initialCwd + * the initial working directory + * @return this instance for method chaining + */ + public SessionFsConfig setInitialCwd(String initialCwd) { + this.initialCwd = initialCwd; + return this; + } + + /** + * Returns the path within each session's SessionFs where the runtime stores + * session-scoped files (events, workspace, checkpoints, and temp files). + */ + public String getSessionStatePath() { + return sessionStatePath; + } + + /** + * Sets the path within each session's SessionFs where the runtime stores + * session-scoped files. + * + * @param sessionStatePath + * the session state path + * @return this instance for method chaining + */ + public SessionFsConfig setSessionStatePath(String sessionStatePath) { + this.sessionStatePath = sessionStatePath; + return this; + } + + /** + * Returns the path conventions used by this filesystem provider. + */ + public SessionFsConventions getConventions() { + return conventions; + } + + /** + * Sets the path conventions used by this filesystem provider. + * + * @param conventions + * the path conventions + * @return this instance for method chaining + */ + public SessionFsConfig setConventions(SessionFsConventions conventions) { + this.conventions = conventions; + return this; + } +} diff --git a/src/main/java/com/github/copilot/sdk/json/SessionFsConventions.java b/src/main/java/com/github/copilot/sdk/json/SessionFsConventions.java new file mode 100644 index 000000000..27640ae4d --- /dev/null +++ b/src/main/java/com/github/copilot/sdk/json/SessionFsConventions.java @@ -0,0 +1,23 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + *--------------------------------------------------------------------------------------------*/ + +package com.github.copilot.sdk.json; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Path conventions used by the session filesystem provider. + * + * @since 1.4.0 + */ +public enum SessionFsConventions { + + /** Windows-style path conventions (backslash separator). */ + @JsonProperty("windows") + WINDOWS, + + /** POSIX-style path conventions (forward slash separator). */ + @JsonProperty("posix") + POSIX; +} diff --git a/src/main/java/com/github/copilot/sdk/json/SessionFsCopyDirParams.java b/src/main/java/com/github/copilot/sdk/json/SessionFsCopyDirParams.java new file mode 100644 index 000000000..a67d70113 --- /dev/null +++ b/src/main/java/com/github/copilot/sdk/json/SessionFsCopyDirParams.java @@ -0,0 +1,50 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + *--------------------------------------------------------------------------------------------*/ + +package com.github.copilot.sdk.json; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** Parameters for sessionFs.copyDir. */ +public class SessionFsCopyDirParams { + + @JsonProperty("sessionId") + private String sessionId; + + @JsonProperty("src") + private String src; + + @JsonProperty("dst") + private String dst; + + /** Returns the session ID. */ + public String getSessionId() { + return sessionId; + } + + /** Sets the session ID. */ + public void setSessionId(String sessionId) { + this.sessionId = sessionId; + } + + /** Returns the source directory path. */ + public String getSrc() { + return src; + } + + /** Sets the source directory path. */ + public void setSrc(String src) { + this.src = src; + } + + /** Returns the destination directory path. */ + public String getDst() { + return dst; + } + + /** Sets the destination directory path. */ + public void setDst(String dst) { + this.dst = dst; + } +} diff --git a/src/main/java/com/github/copilot/sdk/json/SessionFsCpParams.java b/src/main/java/com/github/copilot/sdk/json/SessionFsCpParams.java new file mode 100644 index 000000000..125369959 --- /dev/null +++ b/src/main/java/com/github/copilot/sdk/json/SessionFsCpParams.java @@ -0,0 +1,65 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + *--------------------------------------------------------------------------------------------*/ + +package com.github.copilot.sdk.json; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** Parameters for sessionFs.cp. */ +@JsonInclude(JsonInclude.Include.NON_NULL) +public class SessionFsCpParams { + + @JsonProperty("sessionId") + private String sessionId; + + @JsonProperty("src") + private String src; + + @JsonProperty("dst") + private String dst; + + @JsonProperty("recursive") + private Boolean recursive; + + /** Returns the session ID. */ + public String getSessionId() { + return sessionId; + } + + /** Sets the session ID. */ + public void setSessionId(String sessionId) { + this.sessionId = sessionId; + } + + /** Returns the source path. */ + public String getSrc() { + return src; + } + + /** Sets the source path. */ + public void setSrc(String src) { + this.src = src; + } + + /** Returns the destination path. */ + public String getDst() { + return dst; + } + + /** Sets the destination path. */ + public void setDst(String dst) { + this.dst = dst; + } + + /** Returns whether to copy recursively. */ + public Boolean getRecursive() { + return recursive; + } + + /** Sets whether to copy recursively. */ + public void setRecursive(Boolean recursive) { + this.recursive = recursive; + } +} diff --git a/src/main/java/com/github/copilot/sdk/json/SessionFsDirentEntry.java b/src/main/java/com/github/copilot/sdk/json/SessionFsDirentEntry.java new file mode 100644 index 000000000..61dab59d4 --- /dev/null +++ b/src/main/java/com/github/copilot/sdk/json/SessionFsDirentEntry.java @@ -0,0 +1,37 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + *--------------------------------------------------------------------------------------------*/ + +package com.github.copilot.sdk.json; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** An entry in a directory listing with type information. */ +public class SessionFsDirentEntry { + + @JsonProperty("name") + private String name; + + @JsonProperty("type") + private String type; + + /** Returns the entry name. */ + public String getName() { + return name; + } + + /** Sets the entry name. */ + public void setName(String name) { + this.name = name; + } + + /** Returns the entry type (e.g., "file", "directory"). */ + public String getType() { + return type; + } + + /** Sets the entry type. */ + public void setType(String type) { + this.type = type; + } +} diff --git a/src/main/java/com/github/copilot/sdk/json/SessionFsExistsParams.java b/src/main/java/com/github/copilot/sdk/json/SessionFsExistsParams.java new file mode 100644 index 000000000..937c7b5d1 --- /dev/null +++ b/src/main/java/com/github/copilot/sdk/json/SessionFsExistsParams.java @@ -0,0 +1,37 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + *--------------------------------------------------------------------------------------------*/ + +package com.github.copilot.sdk.json; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** Parameters for sessionFs.exists. */ +public class SessionFsExistsParams { + + @JsonProperty("sessionId") + private String sessionId; + + @JsonProperty("path") + private String path; + + /** Returns the session ID. */ + public String getSessionId() { + return sessionId; + } + + /** Sets the session ID. */ + public void setSessionId(String sessionId) { + this.sessionId = sessionId; + } + + /** Returns the path. */ + public String getPath() { + return path; + } + + /** Sets the path. */ + public void setPath(String path) { + this.path = path; + } +} diff --git a/src/main/java/com/github/copilot/sdk/json/SessionFsExistsResult.java b/src/main/java/com/github/copilot/sdk/json/SessionFsExistsResult.java new file mode 100644 index 000000000..274a53d7a --- /dev/null +++ b/src/main/java/com/github/copilot/sdk/json/SessionFsExistsResult.java @@ -0,0 +1,24 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + *--------------------------------------------------------------------------------------------*/ + +package com.github.copilot.sdk.json; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** Result from sessionFs.exists. */ +public class SessionFsExistsResult { + + @JsonProperty("exists") + private boolean exists; + + /** Returns whether the path exists. */ + public boolean isExists() { + return exists; + } + + /** Sets whether the path exists. */ + public void setExists(boolean exists) { + this.exists = exists; + } +} diff --git a/src/main/java/com/github/copilot/sdk/json/SessionFsGlobParams.java b/src/main/java/com/github/copilot/sdk/json/SessionFsGlobParams.java new file mode 100644 index 000000000..143be6844 --- /dev/null +++ b/src/main/java/com/github/copilot/sdk/json/SessionFsGlobParams.java @@ -0,0 +1,39 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + *--------------------------------------------------------------------------------------------*/ + +package com.github.copilot.sdk.json; + +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** Parameters for sessionFs.glob. */ +public class SessionFsGlobParams { + + @JsonProperty("sessionId") + private String sessionId; + + @JsonProperty("patterns") + private List patterns; + + /** Returns the session ID. */ + public String getSessionId() { + return sessionId; + } + + /** Sets the session ID. */ + public void setSessionId(String sessionId) { + this.sessionId = sessionId; + } + + /** Returns the glob patterns. */ + public List getPatterns() { + return patterns; + } + + /** Sets the glob patterns. */ + public void setPatterns(List patterns) { + this.patterns = patterns; + } +} diff --git a/src/main/java/com/github/copilot/sdk/json/SessionFsGlobResult.java b/src/main/java/com/github/copilot/sdk/json/SessionFsGlobResult.java new file mode 100644 index 000000000..558b09a3f --- /dev/null +++ b/src/main/java/com/github/copilot/sdk/json/SessionFsGlobResult.java @@ -0,0 +1,26 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + *--------------------------------------------------------------------------------------------*/ + +package com.github.copilot.sdk.json; + +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** Result from sessionFs.glob. */ +public class SessionFsGlobResult { + + @JsonProperty("matches") + private List matches; + + /** Returns the matching paths. */ + public List getMatches() { + return matches; + } + + /** Sets the matching paths. */ + public void setMatches(List matches) { + this.matches = matches; + } +} diff --git a/src/main/java/com/github/copilot/sdk/json/SessionFsHandler.java b/src/main/java/com/github/copilot/sdk/json/SessionFsHandler.java new file mode 100644 index 000000000..632c2ef3d --- /dev/null +++ b/src/main/java/com/github/copilot/sdk/json/SessionFsHandler.java @@ -0,0 +1,79 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + *--------------------------------------------------------------------------------------------*/ + +package com.github.copilot.sdk.json; + +import java.util.concurrent.CompletableFuture; + +/** + * Handler interface for session filesystem operations. + *

+ * Implement this interface to provide a custom filesystem backend for + * session-scoped file I/O. The handler is called by the SDK when the Copilot + * CLI routes file operations through the session filesystem provider. + * + *

Example Implementation

+ * + *
{@code
+ * class LocalFsHandler implements SessionFsHandler {
+ * 	private final String rootDir;
+ *
+ * 	LocalFsHandler(String sessionId, String baseDir) {
+ * 		this.rootDir = baseDir + "/" + sessionId;
+ * 	}
+ *
+ * 	public CompletableFuture readFile(SessionFsReadFileParams params) {
+ * 		var result = new SessionFsReadFileResult();
+ * 		result.setContent(Files.readString(Path.of(rootDir + params.getPath())));
+ * 		return CompletableFuture.completedFuture(result);
+ * 	}
+ * 	// ... implement other methods
+ * }
+ * }
+ * + * @see SessionFsConfig + * @see SessionConfig#setCreateSessionFsHandler(java.util.function.Function) + * @since 1.4.0 + */ +public interface SessionFsHandler { + + /** Reads the contents of a file. */ + CompletableFuture readFile(SessionFsReadFileParams params); + + /** Writes content to a file, creating or overwriting it. */ + CompletableFuture writeFile(SessionFsWriteFileParams params); + + /** Appends content to a file. */ + CompletableFuture appendFile(SessionFsAppendFileParams params); + + /** Checks whether a path exists. */ + CompletableFuture exists(SessionFsExistsParams params); + + /** Returns metadata about a file or directory. */ + CompletableFuture stat(SessionFsStatParams params); + + /** Creates a directory. */ + CompletableFuture mkdir(SessionFsMkdirParams params); + + /** Lists the entries in a directory. */ + CompletableFuture readdir(SessionFsReaddirParams params); + + /** Lists the entries in a directory with type information. */ + CompletableFuture readdirWithTypes(SessionFsReaddirParams params); + + /** Removes a file or directory. */ + CompletableFuture rm(SessionFsRmParams params); + + /** Renames a file or directory. */ + CompletableFuture rename(SessionFsRenameParams params); + + /** Copies a file or directory. */ + CompletableFuture cp(SessionFsCpParams params); + + /** Copies a directory and its contents. */ + CompletableFuture copyDir(SessionFsCopyDirParams params); + + /** Finds files matching glob patterns. */ + CompletableFuture glob(SessionFsGlobParams params); +} diff --git a/src/main/java/com/github/copilot/sdk/json/SessionFsMkdirParams.java b/src/main/java/com/github/copilot/sdk/json/SessionFsMkdirParams.java new file mode 100644 index 000000000..4cf9cb8d5 --- /dev/null +++ b/src/main/java/com/github/copilot/sdk/json/SessionFsMkdirParams.java @@ -0,0 +1,65 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + *--------------------------------------------------------------------------------------------*/ + +package com.github.copilot.sdk.json; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** Parameters for sessionFs.mkdir. */ +@JsonInclude(JsonInclude.Include.NON_NULL) +public class SessionFsMkdirParams { + + @JsonProperty("sessionId") + private String sessionId; + + @JsonProperty("path") + private String path; + + @JsonProperty("recursive") + private Boolean recursive; + + @JsonProperty("mode") + private Double mode; + + /** Returns the session ID. */ + public String getSessionId() { + return sessionId; + } + + /** Sets the session ID. */ + public void setSessionId(String sessionId) { + this.sessionId = sessionId; + } + + /** Returns the path. */ + public String getPath() { + return path; + } + + /** Sets the path. */ + public void setPath(String path) { + this.path = path; + } + + /** Returns whether to create parent directories as needed. */ + public Boolean getRecursive() { + return recursive; + } + + /** Sets whether to create parent directories as needed. */ + public void setRecursive(Boolean recursive) { + this.recursive = recursive; + } + + /** Returns the optional POSIX-style mode for newly created directories. */ + public Double getMode() { + return mode; + } + + /** Sets the optional POSIX-style mode for newly created directories. */ + public void setMode(Double mode) { + this.mode = mode; + } +} diff --git a/src/main/java/com/github/copilot/sdk/json/SessionFsReadFileParams.java b/src/main/java/com/github/copilot/sdk/json/SessionFsReadFileParams.java new file mode 100644 index 000000000..fad65829b --- /dev/null +++ b/src/main/java/com/github/copilot/sdk/json/SessionFsReadFileParams.java @@ -0,0 +1,37 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + *--------------------------------------------------------------------------------------------*/ + +package com.github.copilot.sdk.json; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** Parameters for sessionFs.readFile. */ +public class SessionFsReadFileParams { + + @JsonProperty("sessionId") + private String sessionId; + + @JsonProperty("path") + private String path; + + /** Returns the session ID. */ + public String getSessionId() { + return sessionId; + } + + /** Sets the session ID. */ + public void setSessionId(String sessionId) { + this.sessionId = sessionId; + } + + /** Returns the path. */ + public String getPath() { + return path; + } + + /** Sets the path. */ + public void setPath(String path) { + this.path = path; + } +} diff --git a/src/main/java/com/github/copilot/sdk/json/SessionFsReadFileResult.java b/src/main/java/com/github/copilot/sdk/json/SessionFsReadFileResult.java new file mode 100644 index 000000000..5c01a7e6d --- /dev/null +++ b/src/main/java/com/github/copilot/sdk/json/SessionFsReadFileResult.java @@ -0,0 +1,24 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + *--------------------------------------------------------------------------------------------*/ + +package com.github.copilot.sdk.json; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** Result from sessionFs.readFile. */ +public class SessionFsReadFileResult { + + @JsonProperty("content") + private String content; + + /** Returns the file content. */ + public String getContent() { + return content; + } + + /** Sets the file content. */ + public void setContent(String content) { + this.content = content; + } +} diff --git a/src/main/java/com/github/copilot/sdk/json/SessionFsReaddirParams.java b/src/main/java/com/github/copilot/sdk/json/SessionFsReaddirParams.java new file mode 100644 index 000000000..94025de91 --- /dev/null +++ b/src/main/java/com/github/copilot/sdk/json/SessionFsReaddirParams.java @@ -0,0 +1,37 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + *--------------------------------------------------------------------------------------------*/ + +package com.github.copilot.sdk.json; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** Parameters for sessionFs.readdir. */ +public class SessionFsReaddirParams { + + @JsonProperty("sessionId") + private String sessionId; + + @JsonProperty("path") + private String path; + + /** Returns the session ID. */ + public String getSessionId() { + return sessionId; + } + + /** Sets the session ID. */ + public void setSessionId(String sessionId) { + this.sessionId = sessionId; + } + + /** Returns the path. */ + public String getPath() { + return path; + } + + /** Sets the path. */ + public void setPath(String path) { + this.path = path; + } +} diff --git a/src/main/java/com/github/copilot/sdk/json/SessionFsReaddirResult.java b/src/main/java/com/github/copilot/sdk/json/SessionFsReaddirResult.java new file mode 100644 index 000000000..48e854e49 --- /dev/null +++ b/src/main/java/com/github/copilot/sdk/json/SessionFsReaddirResult.java @@ -0,0 +1,26 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + *--------------------------------------------------------------------------------------------*/ + +package com.github.copilot.sdk.json; + +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** Result from sessionFs.readdir. */ +public class SessionFsReaddirResult { + + @JsonProperty("entries") + private List entries; + + /** Returns the entry names in the directory. */ + public List getEntries() { + return entries; + } + + /** Sets the entry names in the directory. */ + public void setEntries(List entries) { + this.entries = entries; + } +} diff --git a/src/main/java/com/github/copilot/sdk/json/SessionFsReaddirWithTypesResult.java b/src/main/java/com/github/copilot/sdk/json/SessionFsReaddirWithTypesResult.java new file mode 100644 index 000000000..860a1de2c --- /dev/null +++ b/src/main/java/com/github/copilot/sdk/json/SessionFsReaddirWithTypesResult.java @@ -0,0 +1,26 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + *--------------------------------------------------------------------------------------------*/ + +package com.github.copilot.sdk.json; + +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** Result from sessionFs.readdirWithTypes. */ +public class SessionFsReaddirWithTypesResult { + + @JsonProperty("entries") + private List entries; + + /** Returns the entries with type information. */ + public List getEntries() { + return entries; + } + + /** Sets the entries with type information. */ + public void setEntries(List entries) { + this.entries = entries; + } +} diff --git a/src/main/java/com/github/copilot/sdk/json/SessionFsRenameParams.java b/src/main/java/com/github/copilot/sdk/json/SessionFsRenameParams.java new file mode 100644 index 000000000..92c89495d --- /dev/null +++ b/src/main/java/com/github/copilot/sdk/json/SessionFsRenameParams.java @@ -0,0 +1,65 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + *--------------------------------------------------------------------------------------------*/ + +package com.github.copilot.sdk.json; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** Parameters for sessionFs.rename. */ +@JsonInclude(JsonInclude.Include.NON_NULL) +public class SessionFsRenameParams { + + @JsonProperty("sessionId") + private String sessionId; + + @JsonProperty("oldPath") + private String oldPath; + + @JsonProperty("newPath") + private String newPath; + + @JsonProperty("overwrite") + private Boolean overwrite; + + /** Returns the session ID. */ + public String getSessionId() { + return sessionId; + } + + /** Sets the session ID. */ + public void setSessionId(String sessionId) { + this.sessionId = sessionId; + } + + /** Returns the source path. */ + public String getOldPath() { + return oldPath; + } + + /** Sets the source path. */ + public void setOldPath(String oldPath) { + this.oldPath = oldPath; + } + + /** Returns the destination path. */ + public String getNewPath() { + return newPath; + } + + /** Sets the destination path. */ + public void setNewPath(String newPath) { + this.newPath = newPath; + } + + /** Returns whether to overwrite an existing destination. */ + public Boolean getOverwrite() { + return overwrite; + } + + /** Sets whether to overwrite an existing destination. */ + public void setOverwrite(Boolean overwrite) { + this.overwrite = overwrite; + } +} diff --git a/src/main/java/com/github/copilot/sdk/json/SessionFsRmParams.java b/src/main/java/com/github/copilot/sdk/json/SessionFsRmParams.java new file mode 100644 index 000000000..64473c39f --- /dev/null +++ b/src/main/java/com/github/copilot/sdk/json/SessionFsRmParams.java @@ -0,0 +1,65 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + *--------------------------------------------------------------------------------------------*/ + +package com.github.copilot.sdk.json; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** Parameters for sessionFs.rm. */ +@JsonInclude(JsonInclude.Include.NON_NULL) +public class SessionFsRmParams { + + @JsonProperty("sessionId") + private String sessionId; + + @JsonProperty("path") + private String path; + + @JsonProperty("recursive") + private Boolean recursive; + + @JsonProperty("force") + private Boolean force; + + /** Returns the session ID. */ + public String getSessionId() { + return sessionId; + } + + /** Sets the session ID. */ + public void setSessionId(String sessionId) { + this.sessionId = sessionId; + } + + /** Returns the path. */ + public String getPath() { + return path; + } + + /** Sets the path. */ + public void setPath(String path) { + this.path = path; + } + + /** Returns whether to remove directories recursively. */ + public Boolean getRecursive() { + return recursive; + } + + /** Sets whether to remove directories recursively. */ + public void setRecursive(Boolean recursive) { + this.recursive = recursive; + } + + /** Returns whether to ignore non-existent files. */ + public Boolean getForce() { + return force; + } + + /** Sets whether to ignore non-existent files. */ + public void setForce(Boolean force) { + this.force = force; + } +} diff --git a/src/main/java/com/github/copilot/sdk/json/SessionFsStatParams.java b/src/main/java/com/github/copilot/sdk/json/SessionFsStatParams.java new file mode 100644 index 000000000..3491ffb26 --- /dev/null +++ b/src/main/java/com/github/copilot/sdk/json/SessionFsStatParams.java @@ -0,0 +1,37 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + *--------------------------------------------------------------------------------------------*/ + +package com.github.copilot.sdk.json; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** Parameters for sessionFs.stat. */ +public class SessionFsStatParams { + + @JsonProperty("sessionId") + private String sessionId; + + @JsonProperty("path") + private String path; + + /** Returns the session ID. */ + public String getSessionId() { + return sessionId; + } + + /** Sets the session ID. */ + public void setSessionId(String sessionId) { + this.sessionId = sessionId; + } + + /** Returns the path. */ + public String getPath() { + return path; + } + + /** Sets the path. */ + public void setPath(String path) { + this.path = path; + } +} diff --git a/src/main/java/com/github/copilot/sdk/json/SessionFsStatResult.java b/src/main/java/com/github/copilot/sdk/json/SessionFsStatResult.java new file mode 100644 index 000000000..cc791b1b4 --- /dev/null +++ b/src/main/java/com/github/copilot/sdk/json/SessionFsStatResult.java @@ -0,0 +1,76 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + *--------------------------------------------------------------------------------------------*/ + +package com.github.copilot.sdk.json; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** Result from sessionFs.stat. */ +public class SessionFsStatResult { + + @JsonProperty("isFile") + private boolean isFile; + + @JsonProperty("isDirectory") + private boolean isDirectory; + + @JsonProperty("size") + private double size; + + @JsonProperty("mtime") + private String mtime; + + @JsonProperty("birthtime") + private String birthtime; + + /** Returns whether the path is a file. */ + public boolean isFile() { + return isFile; + } + + /** Sets whether the path is a file. */ + public void setFile(boolean isFile) { + this.isFile = isFile; + } + + /** Returns whether the path is a directory. */ + public boolean isDirectory() { + return isDirectory; + } + + /** Sets whether the path is a directory. */ + public void setDirectory(boolean isDirectory) { + this.isDirectory = isDirectory; + } + + /** Returns the file size in bytes. */ + public double getSize() { + return size; + } + + /** Sets the file size in bytes. */ + public void setSize(double size) { + this.size = size; + } + + /** Returns the ISO 8601 timestamp of last modification. */ + public String getMtime() { + return mtime; + } + + /** Sets the ISO 8601 timestamp of last modification. */ + public void setMtime(String mtime) { + this.mtime = mtime; + } + + /** Returns the ISO 8601 timestamp of creation. */ + public String getBirthtime() { + return birthtime; + } + + /** Sets the ISO 8601 timestamp of creation. */ + public void setBirthtime(String birthtime) { + this.birthtime = birthtime; + } +} diff --git a/src/main/java/com/github/copilot/sdk/json/SessionFsWriteFileParams.java b/src/main/java/com/github/copilot/sdk/json/SessionFsWriteFileParams.java new file mode 100644 index 000000000..b56f5dc59 --- /dev/null +++ b/src/main/java/com/github/copilot/sdk/json/SessionFsWriteFileParams.java @@ -0,0 +1,65 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + *--------------------------------------------------------------------------------------------*/ + +package com.github.copilot.sdk.json; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** Parameters for sessionFs.writeFile. */ +@JsonInclude(JsonInclude.Include.NON_NULL) +public class SessionFsWriteFileParams { + + @JsonProperty("sessionId") + private String sessionId; + + @JsonProperty("path") + private String path; + + @JsonProperty("content") + private String content; + + @JsonProperty("mode") + private Double mode; + + /** Returns the session ID. */ + public String getSessionId() { + return sessionId; + } + + /** Sets the session ID. */ + public void setSessionId(String sessionId) { + this.sessionId = sessionId; + } + + /** Returns the path. */ + public String getPath() { + return path; + } + + /** Sets the path. */ + public void setPath(String path) { + this.path = path; + } + + /** Returns the content. */ + public String getContent() { + return content; + } + + /** Sets the content. */ + public void setContent(String content) { + this.content = content; + } + + /** Returns the optional POSIX-style mode. */ + public Double getMode() { + return mode; + } + + /** Sets the optional POSIX-style mode. */ + public void setMode(Double mode) { + this.mode = mode; + } +}