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.

- Copilot SDK for Java + Copilot SDK for Java

## Table of Contents @@ -41,7 +41,7 @@ Run `mvn install` locally, then configure the dependency in your project. io.github.copilot-community-sdk copilot-sdk - 1.0.0 + 1.0.1 ``` @@ -50,12 +50,12 @@ Run `mvn install` locally, then configure the dependency in your project. Groovy: ```groovy -implementation 'io.github.copilot-community-sdk:copilot-sdk:1.0.0' +implementation 'io.github.copilot-community-sdk:copilot-sdk:1.0.1' ``` Kotlin ```kotlin -implementation("io.github.copilot-community-sdk:copilot-sdk:1.0.0") +implementation("io.github.copilot-community-sdk:copilot-sdk:1.0.1") ``` ## Quick Start @@ -117,12 +117,12 @@ jbang jbang-example.java The `jbang-example.java` file includes the dependency declaration and can be run directly: ```java -//DEPS io.github.copilot-community-sdk:copilot-sdk:1.0.0 +//DEPS io.github.copilot-community-sdk:copilot-sdk:1.0.1 ``` ## Documentation -For detailed API reference and advanced usage examples, see [DOCS.md](DOCS.md). +For detailed API reference and advanced usage examples, see the [Documentation](src/site/markdown/documentation.md). ## Building and Testing diff --git a/checkstyle.xml b/checkstyle.xml new file mode 100644 index 000000000..6e65e7cb9 --- /dev/null +++ b/checkstyle.xml @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/jbang-example.java b/jbang-example.java index d410e8264..e58f21b6c 100644 --- a/jbang-example.java +++ b/jbang-example.java @@ -1,5 +1,5 @@ -//DEPS io.github.copilot-community-sdk:copilot-sdk:1.0.0 +//DEPS io.github.copilot-community-sdk:copilot-sdk:1.0.1 import com.github.copilot.sdk.*; import com.github.copilot.sdk.events.*; import com.github.copilot.sdk.json.*; diff --git a/pom.xml b/pom.xml index 1ff7fe973..b2b8c61ff 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ io.github.copilot-community-sdk copilot-sdk - 1.0.1 + 1.0.2 jar GitHub Copilot Community SDK :: Java @@ -33,7 +33,7 @@ scm:git:https://github.com/copilot-community-sdk/copilot-sdk-java.git scm:git:https://github.com/copilot-community-sdk/copilot-sdk-java.git https://github.com/copilot-community-sdk/copilot-sdk-java - v1.0.1 + v1.0.2 @@ -78,6 +78,27 @@ maven-compiler-plugin 3.14.1 + + + org.apache.maven.plugins + maven-antrun-plugin + 3.1.0 + + + copy-readme-to-site + pre-site + + run + + + + + + + + + + org.codehaus.mojo @@ -151,9 +172,72 @@ + + org.apache.maven.plugins + maven-checkstyle-plugin + 3.6.0 + + checkstyle.xml + true + true + false + + + + validate + validate + + check + + + + + + com.puppycrawl.tools + checkstyle + 10.21.4 + + + + + + org.apache.maven.plugins + maven-site-plugin + 4.0.0-M16 + + + + + + + org.apache.maven.plugins + maven-project-info-reports-plugin + 3.9.0 + + + + org.apache.maven.plugins + maven-javadoc-plugin + 3.12.0 + + public + true + none + + + + + javadoc + + + + + + + release diff --git a/src/main/java/com/github/copilot/sdk/CopilotClient.java b/src/main/java/com/github/copilot/sdk/CopilotClient.java index 4ac2172ff..8035b6780 100644 --- a/src/main/java/com/github/copilot/sdk/CopilotClient.java +++ b/src/main/java/com/github/copilot/sdk/CopilotClient.java @@ -425,10 +425,12 @@ public CompletableFuture createSession(SessionConfig config) { request.setStreaming(config.isStreaming() ? true : null); request.setMcpServers(config.getMcpServers()); request.setCustomAgents(config.getCustomAgents()); + request.setInfiniteSessions(config.getInfiniteSessions()); } return connection.rpc.invoke("session.create", request, CreateSessionResponse.class).thenApply(response -> { - CopilotSession session = new CopilotSession(response.getSessionId(), connection.rpc); + CopilotSession session = new CopilotSession(response.getSessionId(), connection.rpc, + response.getWorkspacePath()); if (config != null && config.getTools() != null) { session.registerTools(config.getTools()); } @@ -484,7 +486,8 @@ public CompletableFuture resumeSession(String sessionId, ResumeS } return connection.rpc.invoke("session.resume", request, ResumeSessionResponse.class).thenApply(response -> { - CopilotSession session = new CopilotSession(response.getSessionId(), connection.rpc); + CopilotSession session = new CopilotSession(response.getSessionId(), connection.rpc, + response.getWorkspacePath()); if (config != null && config.getTools() != null) { session.registerTools(config.getTools()); } diff --git a/src/main/java/com/github/copilot/sdk/CopilotSession.java b/src/main/java/com/github/copilot/sdk/CopilotSession.java index d97c12dd7..96e9a0226 100644 --- a/src/main/java/com/github/copilot/sdk/CopilotSession.java +++ b/src/main/java/com/github/copilot/sdk/CopilotSession.java @@ -77,6 +77,7 @@ public final class CopilotSession implements AutoCloseable { private static final ObjectMapper MAPPER = JsonRpcClient.getObjectMapper(); private final String sessionId; + private final String workspacePath; private final JsonRpcClient rpc; private final Set> eventHandlers = ConcurrentHashMap.newKeySet(); private final Map toolHandlers = new ConcurrentHashMap<>(); @@ -94,8 +95,26 @@ public final class CopilotSession implements AutoCloseable { * the JSON-RPC client for communication */ CopilotSession(String sessionId, JsonRpcClient rpc) { + this(sessionId, rpc, null); + } + + /** + * Creates a new session with the given ID, RPC client, and workspace path. + *

+ * 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 customAgents; + @JsonProperty("infiniteSessions") + private InfiniteSessionConfig infiniteSessions; + /** Gets the model name. @return the model */ public String getModel() { return model; @@ -165,4 +168,14 @@ public List getCustomAgents() { public void setCustomAgents(List customAgents) { this.customAgents = customAgents; } + + /** Gets infinite sessions config. @return the config */ + public InfiniteSessionConfig getInfiniteSessions() { + return infiniteSessions; + } + + /** Sets infinite sessions config. @param infiniteSessions the config */ + public void setInfiniteSessions(InfiniteSessionConfig infiniteSessions) { + this.infiniteSessions = infiniteSessions; + } } diff --git a/src/main/java/com/github/copilot/sdk/json/CreateSessionResponse.java b/src/main/java/com/github/copilot/sdk/json/CreateSessionResponse.java index 930417872..644114d8a 100644 --- a/src/main/java/com/github/copilot/sdk/json/CreateSessionResponse.java +++ b/src/main/java/com/github/copilot/sdk/json/CreateSessionResponse.java @@ -8,10 +8,25 @@ public final class CreateSessionResponse { @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/InfiniteSessionConfig.java b/src/main/java/com/github/copilot/sdk/json/InfiniteSessionConfig.java new file mode 100644 index 000000000..f0b2ca8f7 --- /dev/null +++ b/src/main/java/com/github/copilot/sdk/json/InfiniteSessionConfig.java @@ -0,0 +1,113 @@ +/*--------------------------------------------------------------------------------------------- + * 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; + +/** + * Configuration for infinite sessions with automatic context compaction and + * workspace persistence. + *

+ * When enabled, sessions automatically manage context window limits through + * background compaction and persist state to a workspace directory. + * + *

Example 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. + *

+ * 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 mcpServers; private List customAgents; + private InfiniteSessionConfig infiniteSessions; /** * Gets the custom session ID. @@ -309,4 +310,31 @@ public SessionConfig setCustomAgents(List customAgents) { this.customAgents = customAgents; return this; } + + /** + * Gets the infinite sessions configuration. + * + * @return the infinite sessions config + */ + public InfiniteSessionConfig getInfiniteSessions() { + return infiniteSessions; + } + + /** + * Sets the infinite session configuration for persistent workspaces and + * automatic compaction. + *

+ * 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(): CompletableFuture` + +Get CLI status including version and protocol information. + +##### `getAuthStatus(): CompletableFuture` + +Get current authentication status. + +##### `listModels(): CompletableFuture>` + +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` + +Convenience method to send a simple text message. Equivalent to `send(new MessageOptions().setPrompt(prompt))`. + ##### `send(MessageOptions options): CompletableFuture` Send a message to the session. @@ -123,10 +141,18 @@ Send a message to the session. Returns the message ID. -##### `sendAndWait(MessageOptions options, long timeoutMs): CompletableFuture` +##### `sendAndWait(String prompt): CompletableFuture` + +Convenience method to send a simple text message and wait for the session to become idle. Equivalent to `sendAndWait(new MessageOptions().setPrompt(prompt))`. + +##### `sendAndWait(MessageOptions options): CompletableFuture` Send a message and wait for the session to become idle. Default timeout is 60 seconds. +##### `sendAndWait(MessageOptions options, long timeoutMs): CompletableFuture` + +Send a message and wait for the session to become idle with custom timeout. + ##### `on(Consumer handler): Closeable` Subscribe to session events. Returns a `Closeable` to unsubscribe. @@ -211,6 +237,45 @@ session.send(new MessageOptions().setPrompt("Tell me a short story")).get(); done.get(); ``` +## Listing Models + +Query available models and their capabilities before creating a session: + +```java +try (var client = new CopilotClient()) { + client.start().get(); + + // List all available models + List models = client.listModels().get(); + + for (ModelInfo model : models) { + System.out.println("Model: " + model.getId()); + System.out.println(" Name: " + model.getName()); + + if (model.getCapabilities() != null) { + System.out.println(" Max Output Tokens: " + model.getCapabilities().getMaxOutputTokens()); + } + + if (model.getPolicy() != null) { + System.out.println(" State: " + model.getPolicy().getState()); + } + } + + // Use a specific model from the list + var session = client.createSession( + new SessionConfig().setModel(models.get(0).getId()) + ).get(); +} +``` + +Each `ModelInfo` contains: + +- `id` - Model identifier (e.g., "claude-sonnet-4.5", "gpt-4o") +- `name` - Human-readable display name +- `capabilities` - Model limits including max output tokens +- `policy` - Policy state information +- `billing` - Billing/usage information + ## Advanced Usage ### Manual Server Control @@ -349,6 +414,78 @@ var session = client.createSession( ).get(); ``` +### Infinite Sessions + +Infinite sessions enable automatic context management for long-running conversations. When enabled (default), the session automatically manages context window limits through background compaction and persists state to a workspace directory. + +#### How It Works + +As conversations grow, they eventually approach the model's context window limit. Infinite sessions solve this by: + +1. **Background Compaction**: When context utilization reaches the background threshold (default 80%), the session starts compacting older messages asynchronously while continuing to process new messages. + +2. **Buffer Exhaustion Protection**: If context reaches the exhaustion threshold (default 95%) before compaction completes, the session blocks until compaction finishes to prevent overflow. + +3. **Workspace Persistence**: Session state is persisted to a workspace directory containing: + - `checkpoints/` - Session checkpoints for resumption + - `plan.md` - Current conversation plan + - `files/` - Associated files + +#### Configuration + +```java +var infiniteConfig = new InfiniteSessionConfig() + .setEnabled(true) + .setBackgroundCompactionThreshold(0.80) // Start compacting at 80% utilization + .setBufferExhaustionThreshold(0.95); // Block at 95% until compaction completes + +var session = client.createSession( + new SessionConfig() + .setModel("gpt-5") + .setInfiniteSessions(infiniteConfig) +).get(); +``` + +#### Configuration Options + +| Option | Default | Description | +|--------|---------|-------------| +| `enabled` | `true` | Whether infinite sessions are enabled | +| `backgroundCompactionThreshold` | `0.80` | Context utilization (0.0-1.0) at which background compaction starts | +| `bufferExhaustionThreshold` | `0.95` | Context utilization (0.0-1.0) at which the session blocks until compaction completes | + +#### Accessing the Workspace + +When infinite sessions are enabled, you can access the workspace path: + +```java +var session = client.createSession( + new SessionConfig() + .setModel("gpt-5") + .setInfiniteSessions(new InfiniteSessionConfig().setEnabled(true)) +).get(); + +String workspacePath = session.getWorkspacePath(); +if (workspacePath != null) { + System.out.println("Session workspace: " + workspacePath); + // Access checkpoints/, plan.md, files/ subdirectories +} +``` + +#### Disabling Infinite Sessions + +For short conversations where context management isn't needed: + +```java +var session = client.createSession( + new SessionConfig() + .setModel("gpt-5") + .setInfiniteSessions(new InfiniteSessionConfig().setEnabled(false)) +).get(); + +// session.getWorkspacePath() will return null +``` + ## Error Handling ```java diff --git a/src/site/resources/.gitignore b/src/site/resources/.gitignore new file mode 100644 index 000000000..4ccc5817f --- /dev/null +++ b/src/site/resources/.gitignore @@ -0,0 +1,2 @@ +# Copied from root during pre-site phase - do not edit here +image.png diff --git a/src/site/site.xml b/src/site/site.xml new file mode 100644 index 000000000..3fcc921fd --- /dev/null +++ b/src/site/site.xml @@ -0,0 +1,62 @@ + + + + + + org.apache.maven.skins + maven-fluido-skin + 2.0.0-M11 + + + + + + + + + + ]]> + + + + + + + + + +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + +