diff --git a/src/main/java/com/github/copilot/sdk/CliServerManager.java b/src/main/java/com/github/copilot/sdk/CliServerManager.java index 3087966d3..bd4effe5a 100644 --- a/src/main/java/com/github/copilot/sdk/CliServerManager.java +++ b/src/main/java/com/github/copilot/sdk/CliServerManager.java @@ -90,16 +90,16 @@ ProcessInfo startCliServer() throws IOException, InterruptedException { } // Default UseLoggedInUser to false when GitHubToken is provided - boolean useLoggedInUser = options.getUseLoggedInUser() != null - ? options.getUseLoggedInUser() - : (options.getGitHubToken() == null || options.getGitHubToken().isEmpty()); + boolean useLoggedInUser = options.getUseLoggedInUser() + .orElse(options.getGitHubToken() == null || options.getGitHubToken().isEmpty()); if (!useLoggedInUser) { args.add("--no-auto-login"); } - if (options.getSessionIdleTimeoutSeconds() != null && options.getSessionIdleTimeoutSeconds() > 0) { + if (options.getSessionIdleTimeoutSeconds().isPresent() + && options.getSessionIdleTimeoutSeconds().getAsInt() > 0) { args.add("--session-idle-timeout"); - args.add(String.valueOf(options.getSessionIdleTimeoutSeconds())); + args.add(String.valueOf(options.getSessionIdleTimeoutSeconds().getAsInt())); } if (options.isRemote()) { @@ -159,9 +159,9 @@ ProcessInfo startCliServer() throws IOException, InterruptedException { if (telemetry.getSourceName() != null) { pb.environment().put("COPILOT_OTEL_SOURCE_NAME", telemetry.getSourceName()); } - if (telemetry.getCaptureContent() != null) { + if (telemetry.getCaptureContent().isPresent()) { pb.environment().put("OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT", - telemetry.getCaptureContent() ? "true" : "false"); + telemetry.getCaptureContent().get() ? "true" : "false"); } } diff --git a/src/main/java/com/github/copilot/sdk/CopilotClient.java b/src/main/java/com/github/copilot/sdk/CopilotClient.java index 5b988d9d2..4d0770319 100644 --- a/src/main/java/com/github/copilot/sdk/CopilotClient.java +++ b/src/main/java/com/github/copilot/sdk/CopilotClient.java @@ -120,7 +120,7 @@ public CopilotClient(CopilotClientOptions options) { // Validate auth options with external server if (this.options.getCliUrl() != null && !this.options.getCliUrl().isEmpty() - && (this.options.getGitHubToken() != null || this.options.getUseLoggedInUser() != null)) { + && (this.options.getGitHubToken() != null || this.options.getUseLoggedInUser().isPresent())) { throw new IllegalArgumentException( "GitHubToken and UseLoggedInUser cannot be used with CliUrl (external server manages its own auth)"); } diff --git a/src/main/java/com/github/copilot/sdk/CopilotSession.java b/src/main/java/com/github/copilot/sdk/CopilotSession.java index ad5561c09..a35ab7552 100644 --- a/src/main/java/com/github/copilot/sdk/CopilotSession.java +++ b/src/main/java/com/github/copilot/sdk/CopilotSession.java @@ -1118,7 +1118,7 @@ private void handleElicitationRequestAsync(ElicitationContext context, String re */ private void assertElicitation() { SessionCapabilities caps = capabilities; - if (caps == null || caps.getUi() == null || !Boolean.TRUE.equals(caps.getUi().getElicitation())) { + if (caps == null || caps.getUi() == null || !caps.getUi().getElicitation().orElse(false)) { throw new IllegalStateException("Elicitation is not supported by the host. " + "Check session.getCapabilities().getUi()?.getElicitation() before calling UI methods."); } @@ -1201,10 +1201,10 @@ public CompletableFuture input(String message, InputOptions options) { field.put("title", options.getTitle()); if (options.getDescription() != null) field.put("description", options.getDescription()); - if (options.getMinLength() != null) - field.put("minLength", options.getMinLength()); - if (options.getMaxLength() != null) - field.put("maxLength", options.getMaxLength()); + if (options.getMinLength().isPresent()) + field.put("minLength", options.getMinLength().getAsInt()); + if (options.getMaxLength().isPresent()) + field.put("maxLength", options.getMaxLength().getAsInt()); if (options.getFormat() != null) field.put("format", options.getFormat()); if (options.getDefaultValue() != null) @@ -1695,7 +1695,8 @@ public CompletableFuture setModel(String model, String reasoningEffort, ModelCapabilitiesOverrideSupports supports = null; if (modelCapabilities.getSupports() != null) { var s = modelCapabilities.getSupports(); - supports = new ModelCapabilitiesOverrideSupports(s.getVision(), s.getReasoningEffort()); + supports = new ModelCapabilitiesOverrideSupports(s.getVision().orElse(null), + s.getReasoningEffort().orElse(null)); } ModelCapabilitiesOverrideLimits limits = null; if (modelCapabilities.getLimits() != null) { diff --git a/src/main/java/com/github/copilot/sdk/SessionRequestBuilder.java b/src/main/java/com/github/copilot/sdk/SessionRequestBuilder.java index d9752db7e..1bd3a50cb 100644 --- a/src/main/java/com/github/copilot/sdk/SessionRequestBuilder.java +++ b/src/main/java/com/github/copilot/sdk/SessionRequestBuilder.java @@ -111,12 +111,18 @@ static CreateSessionRequest buildCreateRequest(SessionConfig config, String sess request.setAvailableTools(config.getAvailableTools()); request.setExcludedTools(config.getExcludedTools()); request.setProvider(config.getProvider()); - request.setEnableSessionTelemetry(config.getEnableSessionTelemetry()); - request.setRequestUserInput(config.getOnUserInputRequest() != null ? true : null); - request.setHooks(config.getHooks() != null && config.getHooks().hasHooks() ? true : null); + config.getEnableSessionTelemetry().ifPresent(request::setEnableSessionTelemetry); + if (config.getOnUserInputRequest() != null) { + request.setRequestUserInput(true); + } + if (config.getHooks() != null && config.getHooks().hasHooks()) { + request.setHooks(true); + } request.setWorkingDirectory(config.getWorkingDirectory()); - request.setStreaming(config.isStreaming() ? true : null); - request.setIncludeSubAgentStreamingEvents(config.getIncludeSubAgentStreamingEvents()); + if (config.isStreaming()) { + request.setStreaming(true); + } + config.getIncludeSubAgentStreamingEvents().ifPresent(request::setIncludeSubAgentStreamingEvents); request.setMcpServers(config.getMcpServers()); request.setCustomAgents(config.getCustomAgents()); request.setDefaultAgent(config.getDefaultAgent()); @@ -126,7 +132,7 @@ static CreateSessionRequest buildCreateRequest(SessionConfig config, String sess request.setInstructionDirectories(config.getInstructionDirectories()); request.setDisabledSkills(config.getDisabledSkills()); request.setConfigDir(config.getConfigDir()); - request.setEnableConfigDiscovery(config.getEnableConfigDiscovery()); + config.getEnableConfigDiscovery().ifPresent(request::setEnableConfigDiscovery); request.setModelCapabilities(config.getModelCapabilities()); if (config.getCommands() != null && !config.getCommands().isEmpty()) { @@ -194,15 +200,23 @@ static ResumeSessionRequest buildResumeRequest(String sessionId, ResumeSessionCo request.setAvailableTools(config.getAvailableTools()); request.setExcludedTools(config.getExcludedTools()); request.setProvider(config.getProvider()); - request.setEnableSessionTelemetry(config.getEnableSessionTelemetry()); - request.setRequestUserInput(config.getOnUserInputRequest() != null ? true : null); - request.setHooks(config.getHooks() != null && config.getHooks().hasHooks() ? true : null); + config.getEnableSessionTelemetry().ifPresent(request::setEnableSessionTelemetry); + if (config.getOnUserInputRequest() != null) { + request.setRequestUserInput(true); + } + if (config.getHooks() != null && config.getHooks().hasHooks()) { + request.setHooks(true); + } request.setWorkingDirectory(config.getWorkingDirectory()); request.setConfigDir(config.getConfigDir()); - request.setEnableConfigDiscovery(config.getEnableConfigDiscovery()); - request.setDisableResume(config.isDisableResume() ? true : null); - request.setStreaming(config.isStreaming() ? true : null); - request.setIncludeSubAgentStreamingEvents(config.getIncludeSubAgentStreamingEvents()); + config.getEnableConfigDiscovery().ifPresent(request::setEnableConfigDiscovery); + if (config.isDisableResume()) { + request.setDisableResume(true); + } + if (config.isStreaming()) { + request.setStreaming(true); + } + config.getIncludeSubAgentStreamingEvents().ifPresent(request::setIncludeSubAgentStreamingEvents); request.setMcpServers(config.getMcpServers()); request.setCustomAgents(config.getCustomAgents()); request.setDefaultAgent(config.getDefaultAgent()); 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 5517df631..a61c32fad 100644 --- a/src/main/java/com/github/copilot/sdk/json/CopilotClientOptions.java +++ b/src/main/java/com/github/copilot/sdk/json/CopilotClientOptions.java @@ -14,6 +14,9 @@ import java.util.function.Supplier; import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonIgnore; +import java.util.Optional; +import java.util.OptionalInt; /** * Configuration options for creating a @@ -499,34 +502,46 @@ public CopilotClientOptions setTelemetry(TelemetryConfig telemetry) { /** * Gets the server-wide idle timeout for sessions in seconds. * - * @return the session idle timeout in seconds, or {@code null} to disable - * (sessions live indefinitely) + * @return an {@link OptionalInt} containing the session idle timeout in + * seconds, or empty to disable (sessions live indefinitely) * @since 1.3.0 */ - public Integer getSessionIdleTimeoutSeconds() { - return sessionIdleTimeoutSeconds; + @JsonIgnore + public OptionalInt getSessionIdleTimeoutSeconds() { + return sessionIdleTimeoutSeconds == null ? OptionalInt.empty() : OptionalInt.of(sessionIdleTimeoutSeconds); } /** * Sets the server-wide idle timeout for sessions in seconds. *

* Sessions without activity for this duration are automatically cleaned up. Set - * to {@code 0} or leave as {@code null} to disable (sessions live - * indefinitely). + * to {@code 0} to disable (sessions live indefinitely). Use + * {@link #clearSessionIdleTimeoutSeconds()} to revert to the default. *

* This option is only used when the SDK spawns the CLI process; it is ignored * when connecting to an external server via {@link #setCliUrl(String)}. * * @param sessionIdleTimeoutSeconds - * the idle timeout in seconds, or {@code null} to disable + * the idle timeout in seconds * @return this options instance for method chaining * @since 1.3.0 */ - public CopilotClientOptions setSessionIdleTimeoutSeconds(Integer sessionIdleTimeoutSeconds) { + public CopilotClientOptions setSessionIdleTimeoutSeconds(int sessionIdleTimeoutSeconds) { this.sessionIdleTimeoutSeconds = sessionIdleTimeoutSeconds; return this; } + /** + * Clears the sessionIdleTimeoutSeconds setting, reverting to the default + * behavior. + * + * @return this instance for method chaining + */ + public CopilotClientOptions clearSessionIdleTimeoutSeconds() { + this.sessionIdleTimeoutSeconds = null; + return this; + } + /** * Gets the connection token for the headless CLI server (TCP only). * @@ -555,11 +570,11 @@ public CopilotClientOptions setTcpConnectionToken(String tcpConnectionToken) { /** * Returns whether to use the logged-in user for authentication. * - * @return {@code true} to use logged-in user auth, {@code false} to use only - * explicit tokens, or {@code null} to use default behavior + * @return an {@link Optional} containing the boolean value, or empty if not set */ - public Boolean getUseLoggedInUser() { - return useLoggedInUser; + @JsonIgnore + public Optional getUseLoggedInUser() { + return Optional.ofNullable(useLoggedInUser); } /** @@ -569,15 +584,23 @@ public Boolean getUseLoggedInUser() { * auth. When false, only explicit tokens (gitHubToken or environment variables) * are used. Default: true (but defaults to false when gitHubToken is provided). *

- * Passing {@code null} is equivalent to passing {@link Boolean#FALSE}. * * @param useLoggedInUser - * {@code true} to use logged-in user auth, {@code false} or - * {@code null} otherwise + * {@code true} to use logged-in user auth, {@code false} otherwise * @return this options instance for method chaining */ - public CopilotClientOptions setUseLoggedInUser(Boolean useLoggedInUser) { - this.useLoggedInUser = useLoggedInUser != null ? useLoggedInUser : Boolean.FALSE; + public CopilotClientOptions setUseLoggedInUser(boolean useLoggedInUser) { + this.useLoggedInUser = useLoggedInUser; + return this; + } + + /** + * Clears the useLoggedInUser setting, reverting to the default behavior. + * + * @return this instance for method chaining + */ + public CopilotClientOptions clearUseLoggedInUser() { + this.useLoggedInUser = null; return this; } 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 12bab4154..0160724be 100644 --- a/src/main/java/com/github/copilot/sdk/json/CreateSessionRequest.java +++ b/src/main/java/com/github/copilot/sdk/json/CreateSessionRequest.java @@ -224,40 +224,68 @@ public Boolean getEnableSessionTelemetry() { /** * Sets enable session telemetry flag. @param enableSessionTelemetry the flag */ - public void setEnableSessionTelemetry(Boolean enableSessionTelemetry) { + public void setEnableSessionTelemetry(boolean enableSessionTelemetry) { this.enableSessionTelemetry = enableSessionTelemetry; } + /** + * Clears the enableSessionTelemetry setting, reverting to the default behavior. + */ + public void clearEnableSessionTelemetry() { + this.enableSessionTelemetry = null; + } + /** Gets request permission flag. @return the flag */ public Boolean getRequestPermission() { return requestPermission; } /** Sets request permission flag. @param requestPermission the flag */ - public void setRequestPermission(Boolean requestPermission) { + public void setRequestPermission(boolean requestPermission) { this.requestPermission = requestPermission; } + /** + * Clears the requestPermission setting, reverting to the default behavior. + */ + public void clearRequestPermission() { + this.requestPermission = null; + } + /** Gets request user input flag. @return the flag */ public Boolean getRequestUserInput() { return requestUserInput; } /** Sets request user input flag. @param requestUserInput the flag */ - public void setRequestUserInput(Boolean requestUserInput) { + public void setRequestUserInput(boolean requestUserInput) { this.requestUserInput = requestUserInput; } + /** + * Clears the requestUserInput setting, reverting to the default behavior. + */ + public void clearRequestUserInput() { + this.requestUserInput = null; + } + /** Gets hooks flag. @return the flag */ public Boolean getHooks() { return hooks; } /** Sets hooks flag. @param hooks the flag */ - public void setHooks(Boolean hooks) { + public void setHooks(boolean hooks) { this.hooks = hooks; } + /** + * Clears the hooks setting, reverting to the default behavior. + */ + public void clearHooks() { + this.hooks = null; + } + /** Gets working directory. @return the working directory */ public String getWorkingDirectory() { return workingDirectory; @@ -274,10 +302,17 @@ public Boolean getStreaming() { } /** Sets streaming flag. @param streaming the flag */ - public void setStreaming(Boolean streaming) { + public void setStreaming(boolean streaming) { this.streaming = streaming; } + /** + * Clears the streaming setting, reverting to the default behavior. + */ + public void clearStreaming() { + this.streaming = null; + } + /** Gets MCP servers. @return the servers map */ public Map getMcpServers() { return mcpServers == null ? null : Collections.unmodifiableMap(mcpServers); @@ -388,10 +423,17 @@ public Boolean getEnableConfigDiscovery() { } /** Sets enable config discovery flag. @param enableConfigDiscovery the flag */ - public void setEnableConfigDiscovery(Boolean enableConfigDiscovery) { + public void setEnableConfigDiscovery(boolean enableConfigDiscovery) { this.enableConfigDiscovery = enableConfigDiscovery; } + /** + * Clears the enableConfigDiscovery setting, reverting to the default behavior. + */ + public void clearEnableConfigDiscovery() { + this.enableConfigDiscovery = null; + } + /** Gets include sub-agent streaming events flag. @return the flag */ public Boolean getIncludeSubAgentStreamingEvents() { return includeSubAgentStreamingEvents; @@ -401,10 +443,18 @@ public Boolean getIncludeSubAgentStreamingEvents() { * Sets include sub-agent streaming events flag. @param * includeSubAgentStreamingEvents the flag */ - public void setIncludeSubAgentStreamingEvents(Boolean includeSubAgentStreamingEvents) { + public void setIncludeSubAgentStreamingEvents(boolean includeSubAgentStreamingEvents) { this.includeSubAgentStreamingEvents = includeSubAgentStreamingEvents; } + /** + * Clears the includeSubAgentStreamingEvents setting, reverting to the default + * behavior. + */ + public void clearIncludeSubAgentStreamingEvents() { + this.includeSubAgentStreamingEvents = null; + } + /** Gets the commands wire definitions. @return the commands */ public List getCommands() { return commands == null ? null : Collections.unmodifiableList(commands); @@ -421,10 +471,17 @@ public Boolean getRequestElicitation() { } /** Sets the requestElicitation flag. @param requestElicitation the flag */ - public void setRequestElicitation(Boolean requestElicitation) { + public void setRequestElicitation(boolean requestElicitation) { this.requestElicitation = requestElicitation; } + /** + * Clears the requestElicitation setting, reverting to the default behavior. + */ + public void clearRequestElicitation() { + this.requestElicitation = null; + } + /** Gets the requestExitPlanMode flag. @return the flag */ public Boolean getRequestExitPlanMode() { return requestExitPlanMode; 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 1421db603..c40d1b3c5 100644 --- a/src/main/java/com/github/copilot/sdk/json/CustomAgentConfig.java +++ b/src/main/java/com/github/copilot/sdk/json/CustomAgentConfig.java @@ -10,6 +10,8 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonIgnore; +import java.util.Optional; /** * Configuration for a custom agent in a Copilot session. @@ -199,8 +201,9 @@ public CustomAgentConfig setMcpServers(Map mcpServers) * * @return the infer flag, or {@code null} if not set */ - public Boolean getInfer() { - return infer; + @JsonIgnore + public Optional getInfer() { + return Optional.ofNullable(infer); } /** @@ -210,11 +213,21 @@ public Boolean getInfer() { * {@code true} to enable inference mode * @return this config for method chaining */ - public CustomAgentConfig setInfer(Boolean infer) { + public CustomAgentConfig setInfer(boolean infer) { this.infer = infer; return this; } + /** + * Clears the infer setting, reverting to the default behavior. + * + * @return this instance for method chaining + */ + public CustomAgentConfig clearInfer() { + this.infer = null; + return this; + } + /** * Gets the list of skill names to preload into this agent's context. * diff --git a/src/main/java/com/github/copilot/sdk/json/InfiniteSessionConfig.java b/src/main/java/com/github/copilot/sdk/json/InfiniteSessionConfig.java index d45851f8a..561796ede 100644 --- a/src/main/java/com/github/copilot/sdk/json/InfiniteSessionConfig.java +++ b/src/main/java/com/github/copilot/sdk/json/InfiniteSessionConfig.java @@ -6,6 +6,9 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonIgnore; +import java.util.Optional; +import java.util.OptionalDouble; /** * Configuration for infinite sessions with automatic context compaction and @@ -43,10 +46,12 @@ public class InfiniteSessionConfig { /** * Gets whether infinite sessions are enabled. * - * @return {@code true} if enabled, {@code null} to use default (true) + * @return an {@link Optional} containing the boolean value, or empty to use + * default (true) */ - public Boolean getEnabled() { - return enabled; + @JsonIgnore + public Optional getEnabled() { + return Optional.ofNullable(enabled); } /** @@ -58,18 +63,32 @@ public Boolean getEnabled() { * {@code true} to enable infinite sessions * @return this config instance for method chaining */ - public InfiniteSessionConfig setEnabled(Boolean enabled) { + public InfiniteSessionConfig setEnabled(boolean enabled) { this.enabled = enabled; return this; } + /** + * Clears the enabled setting, reverting to the default behavior. + * + * @return this instance for method chaining + */ + public InfiniteSessionConfig clearEnabled() { + this.enabled = null; + return this; + } + /** * Gets the background compaction threshold. * - * @return the threshold (0.0-1.0), or {@code null} to use default + * @return an {@link OptionalDouble} containing the threshold (0.0-1.0), or + * empty to use default */ - public Double getBackgroundCompactionThreshold() { - return backgroundCompactionThreshold; + @JsonIgnore + public OptionalDouble getBackgroundCompactionThreshold() { + return backgroundCompactionThreshold == null + ? OptionalDouble.empty() + : OptionalDouble.of(backgroundCompactionThreshold); } /** @@ -82,18 +101,33 @@ public Double getBackgroundCompactionThreshold() { * the threshold (0.0-1.0) * @return this config instance for method chaining */ - public InfiniteSessionConfig setBackgroundCompactionThreshold(Double backgroundCompactionThreshold) { + public InfiniteSessionConfig setBackgroundCompactionThreshold(double backgroundCompactionThreshold) { this.backgroundCompactionThreshold = backgroundCompactionThreshold; return this; } + /** + * Clears the backgroundCompactionThreshold setting, reverting to the default + * behavior. + * + * @return this instance for method chaining + */ + public InfiniteSessionConfig clearBackgroundCompactionThreshold() { + this.backgroundCompactionThreshold = null; + return this; + } + /** * Gets the buffer exhaustion threshold. * - * @return the threshold (0.0-1.0), or {@code null} to use default + * @return an {@link OptionalDouble} containing the threshold (0.0-1.0), or + * empty to use default */ - public Double getBufferExhaustionThreshold() { - return bufferExhaustionThreshold; + @JsonIgnore + public OptionalDouble getBufferExhaustionThreshold() { + return bufferExhaustionThreshold == null + ? OptionalDouble.empty() + : OptionalDouble.of(bufferExhaustionThreshold); } /** @@ -107,8 +141,20 @@ public Double getBufferExhaustionThreshold() { * the threshold (0.0-1.0) * @return this config instance for method chaining */ - public InfiniteSessionConfig setBufferExhaustionThreshold(Double bufferExhaustionThreshold) { + public InfiniteSessionConfig setBufferExhaustionThreshold(double bufferExhaustionThreshold) { this.bufferExhaustionThreshold = bufferExhaustionThreshold; return this; } + + /** + * Clears the bufferExhaustionThreshold setting, reverting to the default + * behavior. + * + * @return this instance for method chaining + */ + public InfiniteSessionConfig clearBufferExhaustionThreshold() { + this.bufferExhaustionThreshold = null; + return this; + } + } diff --git a/src/main/java/com/github/copilot/sdk/json/InputOptions.java b/src/main/java/com/github/copilot/sdk/json/InputOptions.java index 9b0b6c8dd..3b66476a1 100644 --- a/src/main/java/com/github/copilot/sdk/json/InputOptions.java +++ b/src/main/java/com/github/copilot/sdk/json/InputOptions.java @@ -4,6 +4,8 @@ package com.github.copilot.sdk.json; +import java.util.OptionalInt; + /** * Options for the {@link SessionUiApi#input(String, InputOptions)} convenience * method. @@ -47,33 +49,53 @@ public InputOptions setDescription(String description) { } /** Gets the minimum character length. @return the min length */ - public Integer getMinLength() { - return minLength; + public OptionalInt getMinLength() { + return minLength == null ? OptionalInt.empty() : OptionalInt.of(minLength); } /** * Sets the minimum character length. @param minLength the min length @return * this */ - public InputOptions setMinLength(Integer minLength) { + public InputOptions setMinLength(int minLength) { this.minLength = minLength; return this; } + /** + * Clears the minLength setting, reverting to the default behavior. + * + * @return this instance for method chaining + */ + public InputOptions clearMinLength() { + this.minLength = null; + return this; + } + /** Gets the maximum character length. @return the max length */ - public Integer getMaxLength() { - return maxLength; + public OptionalInt getMaxLength() { + return maxLength == null ? OptionalInt.empty() : OptionalInt.of(maxLength); } /** * Sets the maximum character length. @param maxLength the max length @return * this */ - public InputOptions setMaxLength(Integer maxLength) { + public InputOptions setMaxLength(int maxLength) { this.maxLength = maxLength; return this; } + /** + * Clears the maxLength setting, reverting to the default behavior. + * + * @return this instance for method chaining + */ + public InputOptions clearMaxLength() { + this.maxLength = null; + return this; + } + /** * Gets the semantic format hint (e.g., {@code "email"}, {@code "uri"}, * {@code "date"}, {@code "date-time"}). diff --git a/src/main/java/com/github/copilot/sdk/json/McpHttpServerConfig.java b/src/main/java/com/github/copilot/sdk/json/McpHttpServerConfig.java index 7017db3d2..9c5b8dbed 100644 --- a/src/main/java/com/github/copilot/sdk/json/McpHttpServerConfig.java +++ b/src/main/java/com/github/copilot/sdk/json/McpHttpServerConfig.java @@ -99,7 +99,7 @@ public McpHttpServerConfig setTools(List tools) { } @Override - public McpHttpServerConfig setTimeout(Integer timeout) { + public McpHttpServerConfig setTimeout(int 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 index 7cf39af6b..b7f56b05a 100644 --- a/src/main/java/com/github/copilot/sdk/json/McpServerConfig.java +++ b/src/main/java/com/github/copilot/sdk/json/McpServerConfig.java @@ -11,6 +11,8 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonSubTypes; import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonIgnore; +import java.util.OptionalInt; /** * Abstract base class for MCP (Model Context Protocol) server configurations. @@ -68,21 +70,34 @@ public McpServerConfig setTools(List tools) { /** * Gets the optional timeout in milliseconds for tool calls to this server. * - * @return the timeout in milliseconds, or {@code null} for the default + * @return an {@link OptionalInt} containing the timeout in milliseconds, or + * empty for the default */ - public Integer getTimeout() { - return timeout; + @JsonIgnore + public OptionalInt getTimeout() { + return timeout == null ? OptionalInt.empty() : OptionalInt.of(timeout); } /** * Sets an optional timeout in milliseconds for tool calls to this server. * * @param timeout - * the timeout in milliseconds, or {@code null} for the default + * the timeout in milliseconds * @return this config for method chaining */ - public McpServerConfig setTimeout(Integer timeout) { + public McpServerConfig setTimeout(int timeout) { this.timeout = timeout; return this; } + + /** + * Clears the timeout setting, reverting to the default behavior. + * + * @return this instance for method chaining + */ + public McpServerConfig clearTimeout() { + this.timeout = null; + 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 index 900034be6..eef4d1e7d 100644 --- a/src/main/java/com/github/copilot/sdk/json/McpStdioServerConfig.java +++ b/src/main/java/com/github/copilot/sdk/json/McpStdioServerConfig.java @@ -148,7 +148,7 @@ public McpStdioServerConfig setTools(List tools) { } @Override - public McpStdioServerConfig setTimeout(Integer timeout) { + public McpStdioServerConfig setTimeout(int 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 index 18701ad67..ab242d83d 100644 --- a/src/main/java/com/github/copilot/sdk/json/ModelCapabilitiesOverride.java +++ b/src/main/java/com/github/copilot/sdk/json/ModelCapabilitiesOverride.java @@ -7,6 +7,9 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonIgnore; +import java.util.Optional; +import java.util.OptionalInt; /** * Per-property overrides for model capabilities, deep-merged over runtime @@ -109,8 +112,9 @@ public static class Supports { * @return {@code true} to enable vision, {@code false} to disable, or * {@code null} to use the runtime default */ - public Boolean getVision() { - return vision; + @JsonIgnore + public Optional getVision() { + return Optional.ofNullable(vision); } /** @@ -121,19 +125,30 @@ public Boolean getVision() { * to use the runtime default * @return this instance for method chaining */ - public Supports setVision(Boolean vision) { + public Supports setVision(boolean vision) { this.vision = vision; return this; } + /** + * Clears the vision setting, reverting to the default behavior. + * + * @return this instance for method chaining + */ + public Supports clearVision() { + this.vision = null; + return this; + } + /** * Gets the reasoning effort override. * * @return {@code true} to enable reasoning effort, {@code false} to disable, or * {@code null} to use the runtime default */ - public Boolean getReasoningEffort() { - return reasoningEffort; + @JsonIgnore + public Optional getReasoningEffort() { + return Optional.ofNullable(reasoningEffort); } /** @@ -144,10 +159,21 @@ public Boolean getReasoningEffort() { * to use the runtime default * @return this instance for method chaining */ - public Supports setReasoningEffort(Boolean reasoningEffort) { + public Supports setReasoningEffort(boolean reasoningEffort) { this.reasoningEffort = reasoningEffort; return this; } + + /** + * Clears the reasoningEffort setting, reverting to the default behavior. + * + * @return this instance for method chaining + */ + public Supports clearReasoningEffort() { + this.reasoningEffort = null; + return this; + } + } /** @@ -174,8 +200,9 @@ public static class Limits { * * @return the override value, or {@code null} to use the runtime default */ - public Integer getMaxPromptTokens() { - return maxPromptTokens; + @JsonIgnore + public OptionalInt getMaxPromptTokens() { + return maxPromptTokens == null ? OptionalInt.empty() : OptionalInt.of(maxPromptTokens); } /** @@ -185,18 +212,29 @@ public Integer getMaxPromptTokens() { * the override value, or {@code null} to use the runtime default * @return this instance for method chaining */ - public Limits setMaxPromptTokens(Integer maxPromptTokens) { + public Limits setMaxPromptTokens(int maxPromptTokens) { this.maxPromptTokens = maxPromptTokens; return this; } + /** + * Clears the maxPromptTokens setting, reverting to the default behavior. + * + * @return this instance for method chaining + */ + public Limits clearMaxPromptTokens() { + this.maxPromptTokens = null; + return this; + } + /** * Gets the maximum output tokens override. * * @return the override value, or {@code null} to use the runtime default */ - public Integer getMaxOutputTokens() { - return maxOutputTokens; + @JsonIgnore + public OptionalInt getMaxOutputTokens() { + return maxOutputTokens == null ? OptionalInt.empty() : OptionalInt.of(maxOutputTokens); } /** @@ -206,18 +244,29 @@ public Integer getMaxOutputTokens() { * the override value, or {@code null} to use the runtime default * @return this instance for method chaining */ - public Limits setMaxOutputTokens(Integer maxOutputTokens) { + public Limits setMaxOutputTokens(int maxOutputTokens) { this.maxOutputTokens = maxOutputTokens; return this; } + /** + * Clears the maxOutputTokens setting, reverting to the default behavior. + * + * @return this instance for method chaining + */ + public Limits clearMaxOutputTokens() { + this.maxOutputTokens = null; + return this; + } + /** * Gets the maximum context window tokens override. * * @return the override value, or {@code null} to use the runtime default */ - public Integer getMaxContextWindowTokens() { - return maxContextWindowTokens; + @JsonIgnore + public OptionalInt getMaxContextWindowTokens() { + return maxContextWindowTokens == null ? OptionalInt.empty() : OptionalInt.of(maxContextWindowTokens); } /** @@ -227,9 +276,20 @@ public Integer getMaxContextWindowTokens() { * the override value, or {@code null} to use the runtime default * @return this instance for method chaining */ - public Limits setMaxContextWindowTokens(Integer maxContextWindowTokens) { + public Limits setMaxContextWindowTokens(int maxContextWindowTokens) { this.maxContextWindowTokens = maxContextWindowTokens; return this; } + + /** + * Clears the maxContextWindowTokens setting, reverting to the default behavior. + * + * @return this instance for method chaining + */ + public Limits clearMaxContextWindowTokens() { + this.maxContextWindowTokens = null; + return this; + } + } } diff --git a/src/main/java/com/github/copilot/sdk/json/ModelLimits.java b/src/main/java/com/github/copilot/sdk/json/ModelLimits.java index 734a50ded..fedecd6d3 100644 --- a/src/main/java/com/github/copilot/sdk/json/ModelLimits.java +++ b/src/main/java/com/github/copilot/sdk/json/ModelLimits.java @@ -6,6 +6,8 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonIgnore; +import java.util.OptionalInt; /** * Model limits. @@ -24,15 +26,26 @@ public class ModelLimits { @JsonProperty("vision") private ModelVisionLimits vision; - public Integer getMaxPromptTokens() { - return maxPromptTokens; + @JsonIgnore + public OptionalInt getMaxPromptTokens() { + return maxPromptTokens == null ? OptionalInt.empty() : OptionalInt.of(maxPromptTokens); } - public ModelLimits setMaxPromptTokens(Integer maxPromptTokens) { + public ModelLimits setMaxPromptTokens(int maxPromptTokens) { this.maxPromptTokens = maxPromptTokens; return this; } + /** + * Clears the maxPromptTokens setting, reverting to the default behavior. + * + * @return this instance for method chaining + */ + public ModelLimits clearMaxPromptTokens() { + this.maxPromptTokens = null; + return this; + } + public int getMaxContextWindowTokens() { return maxContextWindowTokens; } diff --git a/src/main/java/com/github/copilot/sdk/json/ProviderConfig.java b/src/main/java/com/github/copilot/sdk/json/ProviderConfig.java index 8947696c9..3826f9dd8 100644 --- a/src/main/java/com/github/copilot/sdk/json/ProviderConfig.java +++ b/src/main/java/com/github/copilot/sdk/json/ProviderConfig.java @@ -9,6 +9,8 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonIgnore; +import java.util.OptionalInt; /** * Configuration for a custom API provider (BYOK - Bring Your Own Key). @@ -298,8 +300,9 @@ public ProviderConfig setWireModel(String wireModel) { * * @return the max prompt tokens, or {@code null} if not set */ - public Integer getMaxPromptTokens() { - return maxPromptTokens; + @JsonIgnore + public OptionalInt getMaxPromptTokens() { + return maxPromptTokens == null ? OptionalInt.empty() : OptionalInt.of(maxPromptTokens); } /** @@ -314,18 +317,29 @@ public Integer getMaxPromptTokens() { * the max prompt tokens * @return this config for method chaining */ - public ProviderConfig setMaxPromptTokens(Integer maxPromptTokens) { + public ProviderConfig setMaxPromptTokens(int maxPromptTokens) { this.maxPromptTokens = maxPromptTokens; return this; } + /** + * Clears the maxPromptTokens setting, reverting to the default behavior. + * + * @return this instance for method chaining + */ + public ProviderConfig clearMaxPromptTokens() { + this.maxPromptTokens = null; + return this; + } + /** * Gets the maximum output token override. * * @return the max output tokens, or {@code null} if not set */ - public Integer getMaxOutputTokens() { - return maxOutputTokens; + @JsonIgnore + public OptionalInt getMaxOutputTokens() { + return maxOutputTokens == null ? OptionalInt.empty() : OptionalInt.of(maxOutputTokens); } /** @@ -338,8 +352,19 @@ public Integer getMaxOutputTokens() { * the max output tokens * @return this config for method chaining */ - public ProviderConfig setMaxOutputTokens(Integer maxOutputTokens) { + public ProviderConfig setMaxOutputTokens(int maxOutputTokens) { this.maxOutputTokens = maxOutputTokens; return this; } + + /** + * Clears the maxOutputTokens setting, reverting to the default behavior. + * + * @return this instance for method chaining + */ + public ProviderConfig clearMaxOutputTokens() { + this.maxOutputTokens = null; + 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 f2caad771..9d7621214 100644 --- a/src/main/java/com/github/copilot/sdk/json/ResumeSessionConfig.java +++ b/src/main/java/com/github/copilot/sdk/json/ResumeSessionConfig.java @@ -11,8 +11,10 @@ import java.util.function.Consumer; import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonIgnore; import com.github.copilot.sdk.generated.SessionEvent; +import java.util.Optional; /** * Configuration for resuming an existing Copilot session. @@ -244,8 +246,9 @@ public ResumeSessionConfig setProvider(ProviderConfig provider) { * * @return whether session telemetry is enabled */ - public Boolean getEnableSessionTelemetry() { - return enableSessionTelemetry; + @JsonIgnore + public Optional getEnableSessionTelemetry() { + return Optional.ofNullable(enableSessionTelemetry); } /** @@ -259,11 +262,21 @@ public Boolean getEnableSessionTelemetry() { * whether to enable session telemetry * @return this config for method chaining */ - public ResumeSessionConfig setEnableSessionTelemetry(Boolean enableSessionTelemetry) { + public ResumeSessionConfig setEnableSessionTelemetry(boolean enableSessionTelemetry) { this.enableSessionTelemetry = enableSessionTelemetry; return this; } + /** + * Clears the enableSessionTelemetry setting, reverting to the default behavior. + * + * @return this instance for method chaining + */ + public ResumeSessionConfig clearEnableSessionTelemetry() { + this.enableSessionTelemetry = null; + return this; + } + /** * Gets the reasoning effort level. * @@ -403,8 +416,9 @@ public ResumeSessionConfig setConfigDir(String configDir) { * @return {@code true} to enable discovery, {@code false} to disable, or * {@code null} to use the runtime default */ - public Boolean getEnableConfigDiscovery() { - return enableConfigDiscovery; + @JsonIgnore + public Optional getEnableConfigDiscovery() { + return Optional.ofNullable(enableConfigDiscovery); } /** @@ -420,19 +434,30 @@ public Boolean getEnableConfigDiscovery() { * {@code null} to use the runtime default * @return this config for method chaining */ - public ResumeSessionConfig setEnableConfigDiscovery(Boolean enableConfigDiscovery) { + public ResumeSessionConfig setEnableConfigDiscovery(boolean enableConfigDiscovery) { this.enableConfigDiscovery = enableConfigDiscovery; return this; } + /** + * Clears the enableConfigDiscovery setting, reverting to the default behavior. + * + * @return this instance for method chaining + */ + public ResumeSessionConfig clearEnableConfigDiscovery() { + this.enableConfigDiscovery = null; + return this; + } + /** * Gets whether sub-agent streaming events are included. * * @return {@code true} to include sub-agent streaming events, {@code false} to * suppress them, or {@code null} to use the runtime default */ - public Boolean getIncludeSubAgentStreamingEvents() { - return includeSubAgentStreamingEvents; + @JsonIgnore + public Optional getIncludeSubAgentStreamingEvents() { + return Optional.ofNullable(includeSubAgentStreamingEvents); } /** @@ -443,11 +468,22 @@ public Boolean getIncludeSubAgentStreamingEvents() { * suppress * @return this config for method chaining */ - public ResumeSessionConfig setIncludeSubAgentStreamingEvents(Boolean includeSubAgentStreamingEvents) { + public ResumeSessionConfig setIncludeSubAgentStreamingEvents(boolean includeSubAgentStreamingEvents) { this.includeSubAgentStreamingEvents = includeSubAgentStreamingEvents; return this; } + /** + * Clears the includeSubAgentStreamingEvents setting, reverting to the default + * behavior. + * + * @return this instance for method chaining + */ + public ResumeSessionConfig clearIncludeSubAgentStreamingEvents() { + this.includeSubAgentStreamingEvents = null; + return this; + } + /** * Gets the model capabilities override. * 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 a1af26970..054fc8fba 100644 --- a/src/main/java/com/github/copilot/sdk/json/ResumeSessionRequest.java +++ b/src/main/java/com/github/copilot/sdk/json/ResumeSessionRequest.java @@ -231,40 +231,68 @@ public Boolean getEnableSessionTelemetry() { /** * Sets enable session telemetry flag. @param enableSessionTelemetry the flag */ - public void setEnableSessionTelemetry(Boolean enableSessionTelemetry) { + public void setEnableSessionTelemetry(boolean enableSessionTelemetry) { this.enableSessionTelemetry = enableSessionTelemetry; } + /** + * Clears the enableSessionTelemetry setting, reverting to the default behavior. + */ + public void clearEnableSessionTelemetry() { + this.enableSessionTelemetry = null; + } + /** Gets request permission flag. @return the flag */ public Boolean getRequestPermission() { return requestPermission; } /** Sets request permission flag. @param requestPermission the flag */ - public void setRequestPermission(Boolean requestPermission) { + public void setRequestPermission(boolean requestPermission) { this.requestPermission = requestPermission; } + /** + * Clears the requestPermission setting, reverting to the default behavior. + */ + public void clearRequestPermission() { + this.requestPermission = null; + } + /** Gets request user input flag. @return the flag */ public Boolean getRequestUserInput() { return requestUserInput; } /** Sets request user input flag. @param requestUserInput the flag */ - public void setRequestUserInput(Boolean requestUserInput) { + public void setRequestUserInput(boolean requestUserInput) { this.requestUserInput = requestUserInput; } + /** + * Clears the requestUserInput setting, reverting to the default behavior. + */ + public void clearRequestUserInput() { + this.requestUserInput = null; + } + /** Gets hooks flag. @return the flag */ public Boolean getHooks() { return hooks; } /** Sets hooks flag. @param hooks the flag */ - public void setHooks(Boolean hooks) { + public void setHooks(boolean hooks) { this.hooks = hooks; } + /** + * Clears the hooks setting, reverting to the default behavior. + */ + public void clearHooks() { + this.hooks = null; + } + /** Gets working directory. @return the working directory */ public String getWorkingDirectory() { return workingDirectory; @@ -291,30 +319,51 @@ public Boolean getEnableConfigDiscovery() { } /** Sets enable config discovery flag. @param enableConfigDiscovery the flag */ - public void setEnableConfigDiscovery(Boolean enableConfigDiscovery) { + public void setEnableConfigDiscovery(boolean enableConfigDiscovery) { this.enableConfigDiscovery = enableConfigDiscovery; } + /** + * Clears the enableConfigDiscovery setting, reverting to the default behavior. + */ + public void clearEnableConfigDiscovery() { + this.enableConfigDiscovery = null; + } + /** Gets disable resume flag. @return the flag */ public Boolean getDisableResume() { return disableResume; } /** Sets disable resume flag. @param disableResume the flag */ - public void setDisableResume(Boolean disableResume) { + public void setDisableResume(boolean disableResume) { this.disableResume = disableResume; } + /** + * Clears the disableResume setting, reverting to the default behavior. + */ + public void clearDisableResume() { + this.disableResume = null; + } + /** Gets streaming flag. @return the flag */ public Boolean getStreaming() { return streaming; } /** Sets streaming flag. @param streaming the flag */ - public void setStreaming(Boolean streaming) { + public void setStreaming(boolean streaming) { this.streaming = streaming; } + /** + * Clears the streaming setting, reverting to the default behavior. + */ + public void clearStreaming() { + this.streaming = null; + } + /** Gets include sub-agent streaming events flag. @return the flag */ public Boolean getIncludeSubAgentStreamingEvents() { return includeSubAgentStreamingEvents; @@ -324,10 +373,18 @@ public Boolean getIncludeSubAgentStreamingEvents() { * Sets include sub-agent streaming events flag. @param * includeSubAgentStreamingEvents the flag */ - public void setIncludeSubAgentStreamingEvents(Boolean includeSubAgentStreamingEvents) { + public void setIncludeSubAgentStreamingEvents(boolean includeSubAgentStreamingEvents) { this.includeSubAgentStreamingEvents = includeSubAgentStreamingEvents; } + /** + * Clears the includeSubAgentStreamingEvents setting, reverting to the default + * behavior. + */ + public void clearIncludeSubAgentStreamingEvents() { + this.includeSubAgentStreamingEvents = null; + } + /** Gets MCP servers. @return the servers map */ public Map getMcpServers() { return mcpServers == null ? null : Collections.unmodifiableMap(mcpServers); @@ -441,10 +498,17 @@ public Boolean getRequestElicitation() { } /** Sets the requestElicitation flag. @param requestElicitation the flag */ - public void setRequestElicitation(Boolean requestElicitation) { + public void setRequestElicitation(boolean requestElicitation) { this.requestElicitation = requestElicitation; } + /** + * Clears the requestElicitation setting, reverting to the default behavior. + */ + public void clearRequestElicitation() { + this.requestElicitation = null; + } + /** Gets the requestExitPlanMode flag. @return the flag */ public Boolean getRequestExitPlanMode() { return requestExitPlanMode; 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 51cad884e..c83aa00fc 100644 --- a/src/main/java/com/github/copilot/sdk/json/SessionConfig.java +++ b/src/main/java/com/github/copilot/sdk/json/SessionConfig.java @@ -11,8 +11,10 @@ import java.util.function.Consumer; import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonIgnore; import com.github.copilot.sdk.generated.SessionEvent; +import java.util.Optional; /** * Configuration for creating a new Copilot session. @@ -298,8 +300,9 @@ public SessionConfig setProvider(ProviderConfig provider) { * * @return whether session telemetry is enabled */ - public Boolean getEnableSessionTelemetry() { - return enableSessionTelemetry; + @JsonIgnore + public Optional getEnableSessionTelemetry() { + return Optional.ofNullable(enableSessionTelemetry); } /** @@ -313,11 +316,21 @@ public Boolean getEnableSessionTelemetry() { * whether to enable session telemetry * @return this config instance for method chaining */ - public SessionConfig setEnableSessionTelemetry(Boolean enableSessionTelemetry) { + public SessionConfig setEnableSessionTelemetry(boolean enableSessionTelemetry) { this.enableSessionTelemetry = enableSessionTelemetry; return this; } + /** + * Clears the enableSessionTelemetry setting, reverting to the default behavior. + * + * @return this instance for method chaining + */ + public SessionConfig clearEnableSessionTelemetry() { + this.enableSessionTelemetry = null; + return this; + } + /** * Gets the permission request handler. * @@ -661,8 +674,9 @@ public SessionConfig setConfigDir(String configDir) { * @return {@code true} to enable discovery, {@code false} to disable, or * {@code null} to use the runtime default */ - public Boolean getEnableConfigDiscovery() { - return enableConfigDiscovery; + @JsonIgnore + public Optional getEnableConfigDiscovery() { + return Optional.ofNullable(enableConfigDiscovery); } /** @@ -680,19 +694,30 @@ public Boolean getEnableConfigDiscovery() { * {@code null} to use the runtime default * @return this config instance for method chaining */ - public SessionConfig setEnableConfigDiscovery(Boolean enableConfigDiscovery) { + public SessionConfig setEnableConfigDiscovery(boolean enableConfigDiscovery) { this.enableConfigDiscovery = enableConfigDiscovery; return this; } + /** + * Clears the enableConfigDiscovery setting, reverting to the default behavior. + * + * @return this instance for method chaining + */ + public SessionConfig clearEnableConfigDiscovery() { + this.enableConfigDiscovery = null; + return this; + } + /** * Gets whether sub-agent streaming events are included. * * @return {@code true} to include sub-agent streaming events, {@code false} to * suppress them, or {@code null} to use the runtime default */ - public Boolean getIncludeSubAgentStreamingEvents() { - return includeSubAgentStreamingEvents; + @JsonIgnore + public Optional getIncludeSubAgentStreamingEvents() { + return Optional.ofNullable(includeSubAgentStreamingEvents); } /** @@ -709,11 +734,22 @@ public Boolean getIncludeSubAgentStreamingEvents() { * suppress * @return this config instance for method chaining */ - public SessionConfig setIncludeSubAgentStreamingEvents(Boolean includeSubAgentStreamingEvents) { + public SessionConfig setIncludeSubAgentStreamingEvents(boolean includeSubAgentStreamingEvents) { this.includeSubAgentStreamingEvents = includeSubAgentStreamingEvents; return this; } + /** + * Clears the includeSubAgentStreamingEvents setting, reverting to the default + * behavior. + * + * @return this instance for method chaining + */ + public SessionConfig clearIncludeSubAgentStreamingEvents() { + this.includeSubAgentStreamingEvents = null; + return this; + } + /** * Gets the model capabilities override. * diff --git a/src/main/java/com/github/copilot/sdk/json/SessionUiCapabilities.java b/src/main/java/com/github/copilot/sdk/json/SessionUiCapabilities.java index 9b8e0b587..06ddfc760 100644 --- a/src/main/java/com/github/copilot/sdk/json/SessionUiCapabilities.java +++ b/src/main/java/com/github/copilot/sdk/json/SessionUiCapabilities.java @@ -4,6 +4,11 @@ package com.github.copilot.sdk.json; +import java.util.Optional; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + /** * UI-specific capability flags for a session. * @@ -11,16 +16,17 @@ */ public class SessionUiCapabilities { + @JsonProperty("elicitation") private Boolean elicitation; /** * Returns whether the host supports interactive elicitation dialogs. * - * @return {@code true} if elicitation is supported, {@code false} or - * {@code null} otherwise + * @return an {@link Optional} containing the boolean value, or empty if not set */ - public Boolean getElicitation() { - return elicitation; + @JsonIgnore + public Optional getElicitation() { + return Optional.ofNullable(elicitation); } /** @@ -30,8 +36,19 @@ public Boolean getElicitation() { * {@code true} if elicitation is supported * @return this instance for method chaining */ - public SessionUiCapabilities setElicitation(Boolean elicitation) { + public SessionUiCapabilities setElicitation(boolean elicitation) { this.elicitation = elicitation; return this; } + + /** + * Clears the elicitation setting, reverting to the default behavior. + * + * @return this instance for method chaining + */ + public SessionUiCapabilities clearElicitation() { + this.elicitation = null; + return this; + } + } diff --git a/src/main/java/com/github/copilot/sdk/json/TelemetryConfig.java b/src/main/java/com/github/copilot/sdk/json/TelemetryConfig.java index 8407ab609..9b28a3150 100644 --- a/src/main/java/com/github/copilot/sdk/json/TelemetryConfig.java +++ b/src/main/java/com/github/copilot/sdk/json/TelemetryConfig.java @@ -4,6 +4,10 @@ package com.github.copilot.sdk.json; +import java.util.Optional; + +import com.fasterxml.jackson.annotation.JsonIgnore; + /** * OpenTelemetry configuration for the Copilot CLI server. *

@@ -131,8 +135,9 @@ public TelemetryConfig setSourceName(String sourceName) { * @return {@code true} to capture content, {@code false} to suppress it, or * {@code null} to use the default */ - public Boolean getCaptureContent() { - return captureContent; + @JsonIgnore + public Optional getCaptureContent() { + return Optional.ofNullable(captureContent); } /** @@ -142,8 +147,19 @@ public Boolean getCaptureContent() { * {@code true} to capture content, {@code false} to suppress it * @return this config for method chaining */ - public TelemetryConfig setCaptureContent(Boolean captureContent) { + public TelemetryConfig setCaptureContent(boolean captureContent) { this.captureContent = captureContent; return this; } + + /** + * Clears the captureContent setting, reverting to the default behavior. + * + * @return this instance for method chaining + */ + public TelemetryConfig clearCaptureContent() { + this.captureContent = null; + return this; + } + } diff --git a/src/main/java/com/github/copilot/sdk/json/UserInputRequest.java b/src/main/java/com/github/copilot/sdk/json/UserInputRequest.java index 9b466f866..dfbb1b6da 100644 --- a/src/main/java/com/github/copilot/sdk/json/UserInputRequest.java +++ b/src/main/java/com/github/copilot/sdk/json/UserInputRequest.java @@ -9,6 +9,8 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonIgnore; +import java.util.Optional; /** * Request for user input from the agent. @@ -78,8 +80,9 @@ public UserInputRequest setChoices(List choices) { * @return {@code true} if freeform input is allowed, {@code null} if not * specified */ - public Boolean getAllowFreeform() { - return allowFreeform; + @JsonIgnore + public Optional getAllowFreeform() { + return Optional.ofNullable(allowFreeform); } /** @@ -89,8 +92,19 @@ public Boolean getAllowFreeform() { * {@code true} to allow freeform input * @return this instance for method chaining */ - public UserInputRequest setAllowFreeform(Boolean allowFreeform) { + public UserInputRequest setAllowFreeform(boolean allowFreeform) { this.allowFreeform = allowFreeform; return this; } + + /** + * Clears the allowFreeform setting, reverting to the default behavior. + * + * @return this instance for method chaining + */ + public UserInputRequest clearAllowFreeform() { + this.allowFreeform = null; + return this; + } + } diff --git a/src/test/java/com/github/copilot/sdk/ConfigCloneTest.java b/src/test/java/com/github/copilot/sdk/ConfigCloneTest.java index 7abc47e4a..09bd3ee38 100644 --- a/src/test/java/com/github/copilot/sdk/ConfigCloneTest.java +++ b/src/test/java/com/github/copilot/sdk/ConfigCloneTest.java @@ -203,7 +203,7 @@ void sessionConfigEnableSessionTelemetryCopied() { SessionConfig cloned = original.clone(); - assertFalse(cloned.getEnableSessionTelemetry()); + assertFalse(cloned.getEnableSessionTelemetry().orElse(true)); } @Test @@ -212,7 +212,7 @@ void sessionConfigEnableSessionTelemetryDefaultIsNull() { SessionConfig cloned = original.clone(); - assertNull(cloned.getEnableSessionTelemetry()); + assertTrue(cloned.getEnableSessionTelemetry().isEmpty()); } @Test @@ -222,7 +222,7 @@ void resumeSessionConfigEnableSessionTelemetryCopied() { ResumeSessionConfig cloned = original.clone(); - assertFalse(cloned.getEnableSessionTelemetry()); + assertFalse(cloned.getEnableSessionTelemetry().orElse(true)); } @Test @@ -231,7 +231,7 @@ void resumeSessionConfigEnableSessionTelemetryDefaultIsNull() { ResumeSessionConfig cloned = original.clone(); - assertNull(cloned.getEnableSessionTelemetry()); + assertTrue(cloned.getEnableSessionTelemetry().isEmpty()); } @Test @@ -301,11 +301,11 @@ void copilotClientOptionsSetTelemetry() { } @Test - void copilotClientOptionsSetUseLoggedInUserNull() { + void copilotClientOptionsClearUseLoggedInUser() { var opts = new CopilotClientOptions(); - opts.setUseLoggedInUser(null); - // null → Boolean.FALSE - assertEquals(Boolean.FALSE, opts.getUseLoggedInUser()); + opts.setUseLoggedInUser(true); + opts.clearUseLoggedInUser(); + assertTrue(opts.getUseLoggedInUser().isEmpty()); } @Test @@ -375,7 +375,7 @@ void copilotClientOptionsSessionIdleTimeoutCloned() { CopilotClientOptions cloned = original.clone(); - assertEquals(600, cloned.getSessionIdleTimeoutSeconds()); + assertEquals(600, cloned.getSessionIdleTimeoutSeconds().getAsInt()); } @Test diff --git a/src/test/java/com/github/copilot/sdk/CopilotClientTest.java b/src/test/java/com/github/copilot/sdk/CopilotClientTest.java index b0430959b..14ed8ca89 100644 --- a/src/test/java/com/github/copilot/sdk/CopilotClientTest.java +++ b/src/test/java/com/github/copilot/sdk/CopilotClientTest.java @@ -20,6 +20,7 @@ import java.util.concurrent.ExecutionException; import static org.junit.jupiter.api.Assertions.*; +import java.util.Optional; /** * Tests for CopilotClient. @@ -153,14 +154,14 @@ void testGitHubTokenOptionAccepted() { void testUseLoggedInUserDefaultsToNull() { var options = new CopilotClientOptions().setCliPath("/path/to/cli"); - assertNull(options.getUseLoggedInUser()); + assertTrue(options.getUseLoggedInUser().isEmpty()); } @Test void testExplicitUseLoggedInUserFalse() { var options = new CopilotClientOptions().setCliPath("/path/to/cli").setUseLoggedInUser(false); - assertEquals(false, options.getUseLoggedInUser()); + assertEquals(Optional.of(false), options.getUseLoggedInUser()); } @Test @@ -168,7 +169,7 @@ void testExplicitUseLoggedInUserTrueWithGitHubToken() { var options = new CopilotClientOptions().setCliPath("/path/to/cli").setGitHubToken("gho_test_token") .setUseLoggedInUser(true); - assertEquals(true, options.getUseLoggedInUser()); + assertEquals(Optional.of(true), options.getUseLoggedInUser()); } @Test @@ -189,14 +190,14 @@ void testUseLoggedInUserWithCliUrlThrows() { void testSessionIdleTimeoutSecondsDefaultsToNull() { var options = new CopilotClientOptions(); - assertNull(options.getSessionIdleTimeoutSeconds()); + assertTrue(options.getSessionIdleTimeoutSeconds().isEmpty()); } @Test void testSessionIdleTimeoutSecondsOptionAccepted() { var options = new CopilotClientOptions().setSessionIdleTimeoutSeconds(600); - assertEquals(600, options.getSessionIdleTimeoutSeconds()); + assertEquals(600, options.getSessionIdleTimeoutSeconds().getAsInt()); } @Test diff --git a/src/test/java/com/github/copilot/sdk/DataObjectCoverageTest.java b/src/test/java/com/github/copilot/sdk/DataObjectCoverageTest.java index b61c93559..e8e983a4c 100644 --- a/src/test/java/com/github/copilot/sdk/DataObjectCoverageTest.java +++ b/src/test/java/com/github/copilot/sdk/DataObjectCoverageTest.java @@ -194,7 +194,7 @@ void mcpHttpServerConfigCoversGettersAndFluentSetters() { assertEquals("https://mcp.example.com/sse", cfg.getUrl()); assertEquals("Bearer token", cfg.getHeaders().get("Authorization")); assertEquals(tools, cfg.getTools()); - assertEquals(45, cfg.getTimeout()); + assertEquals(45, cfg.getTimeout().getAsInt()); } @Test @@ -212,22 +212,21 @@ void mcpStdioServerConfigCoversGettersAndFluentSetters() { assertEquals("1", cfg.getEnv().get("DEBUG")); assertEquals("/tmp", cfg.getWorkingDirectory()); assertEquals(tools, cfg.getTools()); - assertEquals(30, cfg.getTimeout()); + assertEquals(30, cfg.getTimeout().getAsInt()); } @Test void modelCapabilitiesOverrideCoversNestedSupportsAndLimits() { - var supports = new ModelCapabilitiesOverride.Supports().setVision(Boolean.TRUE) - .setReasoningEffort(Boolean.FALSE); + var supports = new ModelCapabilitiesOverride.Supports().setVision(true).setReasoningEffort(false); var limits = new ModelCapabilitiesOverride.Limits().setMaxPromptTokens(2048).setMaxOutputTokens(512) .setMaxContextWindowTokens(8192); var override = new ModelCapabilitiesOverride().setSupports(supports).setLimits(limits); - assertTrue(override.getSupports().getVision()); - assertFalse(override.getSupports().getReasoningEffort()); - assertEquals(2048, override.getLimits().getMaxPromptTokens()); - assertEquals(512, override.getLimits().getMaxOutputTokens()); - assertEquals(8192, override.getLimits().getMaxContextWindowTokens()); + assertTrue(override.getSupports().getVision().orElse(false)); + assertFalse(override.getSupports().getReasoningEffort().orElse(true)); + assertEquals(2048, override.getLimits().getMaxPromptTokens().getAsInt()); + assertEquals(512, override.getLimits().getMaxOutputTokens().getAsInt()); + assertEquals(8192, override.getLimits().getMaxContextWindowTokens().getAsInt()); } } diff --git a/src/test/java/com/github/copilot/sdk/ElicitationTest.java b/src/test/java/com/github/copilot/sdk/ElicitationTest.java index 6b748b4cc..bf3c0bfb2 100644 --- a/src/test/java/com/github/copilot/sdk/ElicitationTest.java +++ b/src/test/java/com/github/copilot/sdk/ElicitationTest.java @@ -40,7 +40,7 @@ void sessionCapabilitiesTypesAreProperlyStructured() { var capabilities = new SessionCapabilities().setUi(new SessionUiCapabilities().setElicitation(true)); assertNotNull(capabilities.getUi()); - assertTrue(capabilities.getUi().getElicitation()); + assertTrue(capabilities.getUi().getElicitation().get()); // Test with null UI var emptyCapabilities = new SessionCapabilities(); @@ -119,8 +119,8 @@ void inputOptionsHasAllFields() { assertEquals("My Title", opts.getTitle()); assertEquals("My Desc", opts.getDescription()); - assertEquals(1, opts.getMinLength()); - assertEquals(100, opts.getMaxLength()); + assertEquals(1, opts.getMinLength().getAsInt()); + assertEquals(100, opts.getMaxLength().getAsInt()); assertEquals("email", opts.getFormat()); assertEquals("default@example.com", opts.getDefaultValue()); } @@ -164,7 +164,7 @@ void buildCreateRequestSetsRequestElicitationWhenHandlerPresent() { var request = SessionRequestBuilder.buildCreateRequest(config); - assertTrue(Boolean.TRUE.equals(request.getRequestElicitation())); + assertTrue(request.getRequestElicitation()); } @Test @@ -186,6 +186,6 @@ void buildResumeRequestSetsRequestElicitationWhenHandlerPresent() { var request = SessionRequestBuilder.buildResumeRequest("session-1", config); - assertTrue(Boolean.TRUE.equals(request.getRequestElicitation())); + assertTrue(request.getRequestElicitation()); } } diff --git a/src/test/java/com/github/copilot/sdk/MetadataApiTest.java b/src/test/java/com/github/copilot/sdk/MetadataApiTest.java index 3a9120a52..91ab62843 100644 --- a/src/test/java/com/github/copilot/sdk/MetadataApiTest.java +++ b/src/test/java/com/github/copilot/sdk/MetadataApiTest.java @@ -156,7 +156,7 @@ void testModelInfoDeserialization() throws Exception { // Capabilities assertNotNull(model.getCapabilities()); assertTrue(model.getCapabilities().getSupports().isVision()); - assertEquals(8192, model.getCapabilities().getLimits().getMaxPromptTokens()); + assertEquals(8192, model.getCapabilities().getLimits().getMaxPromptTokens().getAsInt()); assertEquals(128000, model.getCapabilities().getLimits().getMaxContextWindowTokens()); // Vision limits diff --git a/src/test/java/com/github/copilot/sdk/ProviderConfigTest.java b/src/test/java/com/github/copilot/sdk/ProviderConfigTest.java index e7602619c..6bbb3ae28 100644 --- a/src/test/java/com/github/copilot/sdk/ProviderConfigTest.java +++ b/src/test/java/com/github/copilot/sdk/ProviderConfigTest.java @@ -410,8 +410,8 @@ void testProviderModelIdAndWireModelSerialization() throws Exception { ProviderConfig deserialized = MAPPER.readValue(MAPPER.writeValueAsString(provider), ProviderConfig.class); assertEquals("gpt-4o", deserialized.getModelId()); assertEquals("my-finetune-v3", deserialized.getWireModel()); - assertEquals(100_000, deserialized.getMaxPromptTokens()); - assertEquals(4096, deserialized.getMaxOutputTokens()); + assertEquals(100_000, deserialized.getMaxPromptTokens().getAsInt()); + assertEquals(4096, deserialized.getMaxOutputTokens().getAsInt()); } @Test @@ -419,8 +419,8 @@ void testProviderModelFieldsDefaultToNull() { var provider = new ProviderConfig(); assertNull(provider.getModelId()); assertNull(provider.getWireModel()); - assertNull(provider.getMaxPromptTokens()); - assertNull(provider.getMaxOutputTokens()); + assertTrue(provider.getMaxPromptTokens().isEmpty()); + assertTrue(provider.getMaxOutputTokens().isEmpty()); } @Test diff --git a/src/test/java/com/github/copilot/sdk/TelemetryConfigTest.java b/src/test/java/com/github/copilot/sdk/TelemetryConfigTest.java index 99b360d2d..278777ce1 100644 --- a/src/test/java/com/github/copilot/sdk/TelemetryConfigTest.java +++ b/src/test/java/com/github/copilot/sdk/TelemetryConfigTest.java @@ -22,7 +22,7 @@ void defaultValuesAreNull() { assertNull(config.getFilePath()); assertNull(config.getExporterType()); assertNull(config.getSourceName()); - assertNull(config.getCaptureContent()); + assertTrue(config.getCaptureContent().isEmpty()); } @Test @@ -57,10 +57,10 @@ void sourceNameGetterSetter() { void captureContentGetterSetter() { var config = new TelemetryConfig(); config.setCaptureContent(true); - assertTrue(config.getCaptureContent()); + assertTrue(config.getCaptureContent().get()); config.setCaptureContent(false); - assertFalse(config.getCaptureContent()); + assertFalse(config.getCaptureContent().get()); } @Test @@ -72,6 +72,6 @@ void fluentChainingReturnsThis() { assertEquals("/tmp/spans.json", config.getFilePath()); assertEquals("file", config.getExporterType()); assertEquals("sdk-test", config.getSourceName()); - assertTrue(config.getCaptureContent()); + assertTrue(config.getCaptureContent().get()); } }