diff --git a/.github/workflows/publish-maven.yml b/.github/workflows/publish-maven.yml index 7b41bc0a9..ea31a52e7 100644 --- a/.github/workflows/publish-maven.yml +++ b/.github/workflows/publish-maven.yml @@ -176,11 +176,11 @@ jobs: EOF ) - gh release create "${VERSION}" \ + gh release create "v${VERSION}" \ ${{ inputs.prerelease == true && '--prerelease' || '' }} \ - --title "Copilot Community Java SDK ${VERSION}" \ + --title "Copilot Java SDK ${VERSION}" \ --notes "${RELEASE_NOTES}" \ --generate-notes \ - --target "${VERSION}" + --target "v${VERSION}" env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/sdk-build.yml b/.github/workflows/sdk-build.yml index e025682a9..5e66b4fc2 100644 --- a/.github/workflows/sdk-build.yml +++ b/.github/workflows/sdk-build.yml @@ -4,6 +4,9 @@ env: COPILOT_GITHUB_TOKEN: ${{ secrets.COPILOT_GITHUB_TOKEN }} on: + schedule: + # Run once a day at 00:00 UTC + - cron: '0 0 * * *' push: branches: [main] pull_request: diff --git a/.github/workflows/site.yml b/.github/workflows/site.yml new file mode 100644 index 000000000..d5827da69 --- /dev/null +++ b/.github/workflows/site.yml @@ -0,0 +1,60 @@ +# Simple workflow for deploying static content to GitHub Pages +name: Deploy Maven Site to Pages + +on: + # Runs on pushes targeting the default branch + push: + branches: ["main"] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages +permissions: + contents: read + pages: write + id-token: write + +# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. +# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. +concurrency: + group: "pages" + cancel-in-progress: false + +jobs: + # Build Maven Site + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v6 + + - name: Set up JDK 17 + uses: actions/setup-java@v5 + with: + java-version: '17' + distribution: 'temurin' + + - name: Build Maven Site with Javadoc + run: ./mvnw clean site -DskipTests -Dcheckstyle.skip=true + + - name: Setup Pages + uses: actions/configure-pages@v5 + + - name: Upload artifact + uses: actions/upload-pages-artifact@v4 + with: + # Upload the generated site + path: 'target/site' + + # Deploy to GitHub Pages + deploy: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + needs: build + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 diff --git a/README.md b/README.md index 186d064c7..e72f146e9 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Java SDK for programmatic control of GitHub Copilot CLI. > **Note:** This SDK may change in breaking ways.
-
+
+ * This constructor is package-private. Sessions should be created via + * {@link CopilotClient#createSession} or {@link CopilotClient#resumeSession}. + * + * @param sessionId + * the unique session identifier + * @param rpc + * the JSON-RPC client for communication + * @param workspacePath + * the workspace path if infinite sessions are enabled + */ + CopilotSession(String sessionId, JsonRpcClient rpc, String workspacePath) { this.sessionId = sessionId; this.rpc = rpc; + this.workspacePath = workspacePath; } /** @@ -107,6 +126,19 @@ public String getSessionId() { return sessionId; } + /** + * Gets the path to the session workspace directory when infinite sessions are + * enabled. + *
+ * The workspace directory contains checkpoints/, plan.md, and files/ + * subdirectories. + * + * @return the workspace path, or {@code null} if infinite sessions are disabled + */ + public String getWorkspacePath() { + return workspacePath; + } + /** * Sends a simple text message to the Copilot session. *
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 c725a2348..32ab67f6b 100644
--- a/src/main/java/com/github/copilot/sdk/json/CreateSessionRequest.java
+++ b/src/main/java/com/github/copilot/sdk/json/CreateSessionRequest.java
@@ -56,6 +56,9 @@ public final class CreateSessionRequest {
@JsonProperty("customAgents")
private List
+ * When enabled, sessions automatically manage context window limits through
+ * background compaction and persist state to a workspace directory.
+ *
+ *
+ * Default: true
+ *
+ * @param enabled
+ * {@code true} to enable infinite sessions
+ * @return this config instance for method chaining
+ */
+ public InfiniteSessionConfig setEnabled(Boolean enabled) {
+ this.enabled = enabled;
+ return this;
+ }
+
+ /**
+ * Gets the background compaction threshold.
+ *
+ * @return the threshold (0.0-1.0), or {@code null} to use default
+ */
+ public Double getBackgroundCompactionThreshold() {
+ return backgroundCompactionThreshold;
+ }
+
+ /**
+ * Sets the context utilization threshold at which background compaction starts.
+ *
+ * Compaction runs asynchronously, allowing the session to continue processing.
+ * Default: 0.80
+ *
+ * @param backgroundCompactionThreshold
+ * the threshold (0.0-1.0)
+ * @return this config instance for method chaining
+ */
+ public InfiniteSessionConfig setBackgroundCompactionThreshold(Double backgroundCompactionThreshold) {
+ this.backgroundCompactionThreshold = backgroundCompactionThreshold;
+ return this;
+ }
+
+ /**
+ * Gets the buffer exhaustion threshold.
+ *
+ * @return the threshold (0.0-1.0), or {@code null} to use default
+ */
+ public Double getBufferExhaustionThreshold() {
+ return bufferExhaustionThreshold;
+ }
+
+ /**
+ * Sets the context utilization threshold at which the session blocks until
+ * compaction completes.
+ *
+ * This prevents context overflow when compaction hasn't finished in time.
+ * Default: 0.95
+ *
+ * @param bufferExhaustionThreshold
+ * the threshold (0.0-1.0)
+ * @return this config instance for method chaining
+ */
+ public InfiniteSessionConfig setBufferExhaustionThreshold(Double bufferExhaustionThreshold) {
+ this.bufferExhaustionThreshold = bufferExhaustionThreshold;
+ return this;
+ }
+}
diff --git a/src/main/java/com/github/copilot/sdk/json/ResumeSessionResponse.java b/src/main/java/com/github/copilot/sdk/json/ResumeSessionResponse.java
index 615bf462c..dd9e8b050 100644
--- a/src/main/java/com/github/copilot/sdk/json/ResumeSessionResponse.java
+++ b/src/main/java/com/github/copilot/sdk/json/ResumeSessionResponse.java
@@ -8,10 +8,25 @@ public final class ResumeSessionResponse {
@JsonProperty("sessionId")
private String sessionId;
+ @JsonProperty("workspacePath")
+ private String workspacePath;
+
public String getSessionId() {
return sessionId;
}
public void setSessionId(String sessionId) {
this.sessionId = sessionId;
}
+
+ /**
+ * Gets the workspace path when infinite sessions are enabled.
+ *
+ * @return the workspace path, or {@code null} if infinite sessions are disabled
+ */
+ public String getWorkspacePath() {
+ return workspacePath;
+ }
+ public void setWorkspacePath(String workspacePath) {
+ this.workspacePath = workspacePath;
+ }
}
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 b1ea7df75..341ddb2f7 100644
--- a/src/main/java/com/github/copilot/sdk/json/SessionConfig.java
+++ b/src/main/java/com/github/copilot/sdk/json/SessionConfig.java
@@ -41,6 +41,7 @@ public class SessionConfig {
private boolean streaming;
private Map
+ * When enabled (default), sessions automatically manage context limits and
+ * persist state to a workspace directory. The workspace contains checkpoints/,
+ * plan.md, and files/ subdirectories.
+ *
+ * @param infiniteSessions
+ * the infinite sessions configuration
+ * @return this config instance for method chaining
+ * @see InfiniteSessionConfig
+ */
+ public SessionConfig setInfiniteSessions(InfiniteSessionConfig infiniteSessions) {
+ this.infiniteSessions = infiniteSessions;
+ return this;
+ }
}
diff --git a/src/site/markdown/.gitignore b/src/site/markdown/.gitignore
new file mode 100644
index 000000000..0982931ec
--- /dev/null
+++ b/src/site/markdown/.gitignore
@@ -0,0 +1,2 @@
+# Copied from root during pre-site phase - do not edit here
+index.md
diff --git a/DOCS.md b/src/site/markdown/documentation.md
similarity index 62%
rename from DOCS.md
rename to src/site/markdown/documentation.md
index c8673a10a..9c8cb119d 100644
--- a/DOCS.md
+++ b/src/site/markdown/documentation.md
@@ -4,20 +4,22 @@ This document provides detailed API reference and usage examples for the Copilot
## Table of Contents
-- [API Reference](#api-reference)
- - [CopilotClient](#copilotclient)
- - [CopilotSession](#copilotsession)
-- [Event Types](#event-types)
-- [Streaming](#streaming)
-- [Advanced Usage](#advanced-usage)
- - [Manual Server Control](#manual-server-control)
- - [Tools](#tools)
- - [System Message Customization](#system-message-customization)
- - [Multiple Sessions](#multiple-sessions)
- - [File Attachments](#file-attachments)
- - [Bring Your Own Key (BYOK)](#bring-your-own-key-byok)
- - [Permission Handling](#permission-handling)
-- [Error Handling](#error-handling)
+- [API Reference](#API_Reference)
+ - [CopilotClient](#CopilotClient)
+ - [CopilotSession](#CopilotSession)
+- [Event Types](#Event_Types)
+- [Streaming](#Streaming)
+- [Listing Models](#Listing_Models)
+- [Advanced Usage](#Advanced_Usage)
+ - [Manual Server Control](#Manual_Server_Control)
+ - [Tools](#Tools)
+ - [System Message Customization](#System_Message_Customization)
+ - [Multiple Sessions](#Multiple_Sessions)
+ - [File Attachments](#File_Attachments)
+ - [Bring Your Own Key (BYOK)](#Bring_Your_Own_Key_.28BYOK.29)
+ - [Permission Handling](#Permission_Handling)
+ - [Infinite Sessions](#Infinite_Sessions)
+- [Error Handling](#Error_Handling)
## API Reference
@@ -83,6 +85,18 @@ Resume an existing session.
Ping the server to check connectivity.
+##### `getStatus(): CompletableFutureExample Usage
+ *
+ * {@code
+ * var infiniteConfig = new InfiniteSessionConfig().setEnabled(true).setBackgroundCompactionThreshold(0.80)
+ * .setBufferExhaustionThreshold(0.95);
+ *
+ * var config = new SessionConfig().setInfiniteSessions(infiniteConfig);
+ *
+ * var session = client.createSession(config).get();
+ * }
+ *
+ * @see SessionConfig#setInfiniteSessions(InfiniteSessionConfig)
+ */
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class InfiniteSessionConfig {
+
+ @JsonProperty("enabled")
+ private Boolean enabled;
+
+ @JsonProperty("backgroundCompactionThreshold")
+ private Double backgroundCompactionThreshold;
+
+ @JsonProperty("bufferExhaustionThreshold")
+ private Double bufferExhaustionThreshold;
+
+ /**
+ * Gets whether infinite sessions are enabled.
+ *
+ * @return {@code true} if enabled, {@code null} to use default (true)
+ */
+ public Boolean getEnabled() {
+ return enabled;
+ }
+
+ /**
+ * Sets whether infinite sessions are enabled.
+ * >`
+
+List available models with their metadata (id, name, capabilities, billing info).
+
##### `getState(): ConnectionState`
Get current connection state. Returns one of: `DISCONNECTED`, `CONNECTING`, `CONNECTED`, `ERROR`.
@@ -111,6 +125,10 @@ Represents a single conversation session.
#### Methods
+##### `send(String prompt): CompletableFuture