Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/workflows/codegen-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ on:
- 'go/generated_*.go'
- 'go/rpc/**'
- 'rust/src/generated/**'
- 'sdk-protocol-version.json'
- 'java/src/main/java/com/github/copilot/SdkProtocolVersion.java'
- '.github/workflows/codegen-check.yml'
workflow_dispatch:

Expand Down Expand Up @@ -78,4 +80,13 @@ jobs:
git diff
exit 1
fi

- name: Verify Java protocol version matches
run: |
EXPECTED=$(jq -r '.version' sdk-protocol-version.json)
ACTUAL=$(grep -oP 'LATEST\(\K[0-9]+' java/src/main/java/com/github/copilot/SdkProtocolVersion.java)
if [ "$EXPECTED" != "$ACTUAL" ]; then
echo "::error::Java SDK protocol version ($ACTUAL) does not match sdk-protocol-version.json ($EXPECTED). Java manages its own SdkProtocolVersion.java via java/scripts/codegen/. Update it to match."
exit 1
fi
echo "✅ Generated files are up-to-date"
30 changes: 30 additions & 0 deletions .github/workflows/docs-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:
- 'python/copilot/**'
- 'go/**/*.go'
- 'dotnet/src/**'
- 'java/src/**'
- 'scripts/docs-validation/**'
- '.github/workflows/docs-validation.yml'
workflow_dispatch:
Expand Down Expand Up @@ -126,3 +127,32 @@ jobs:
- name: Extract and validate C#
working-directory: scripts/docs-validation
run: npm run extract && npm run validate:cs

validate-java:
name: "Validate Java"
if: github.event.repository.fork == false
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6

- uses: actions/setup-node@v6
with:
node-version: 22

- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
cache: 'maven'

- name: Install SDK to local repo
working-directory: java
run: mvn install -DskipTests -q

- name: Install validation dependencies
working-directory: scripts/docs-validation
run: npm ci

- name: Extract and validate Java
working-directory: scripts/docs-validation
run: npm run extract && npm run validate:java
44 changes: 44 additions & 0 deletions .github/workflows/scenario-builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ on:
- "dotnet/src/**"
- "rust/src/**"
- "rust/Cargo.toml"
- "java/src/**"
- ".github/workflows/scenario-builds.yml"
push:
branches:
Expand Down Expand Up @@ -235,3 +236,46 @@ jobs:
echo -e "Failures:$FAILURES"
exit 1
fi

# ── Java ────────────────────────────────────────────────────────────
build-java:
name: "Java scenarios"
if: github.event.repository.fork == false
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6

- uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: "17"
cache: "maven"

# Install SDK to local Maven repo so scenarios can resolve it
- name: Install SDK to local repo
working-directory: java
run: mvn install -DskipTests -q

- name: Build all Java scenarios
run: |
PASS=0; FAIL=0; FAILURES=""
for pom in $(find test/scenarios -path '*/java/pom.xml' | sort); do
dir=$(dirname "$pom")
scenario="${dir#test/scenarios/}"
echo "::group::$scenario"
if (cd "$dir" && mvn compile -q 2>&1); then
echo "✅ $scenario"
PASS=$((PASS + 1))
else
echo "❌ $scenario"
FAIL=$((FAIL + 1))
FAILURES="$FAILURES\n $scenario"
fi
echo "::endgroup::"
done
echo ""
echo "Java builds: $PASS passed, $FAIL failed"
if [ "$FAIL" -gt 0 ]; then
echo -e "Failures:$FAILURES"
exit 1
fi
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@
},
"[go]": {
"editor.defaultFormatter": "golang.go"
}
},
"java.configuration.updateBuildConfiguration": "automatic"
}
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ The GitHub Copilot SDK exposes the same engine behind Copilot CLI: a production-
| **Go** | [`go/`](./go/) | [Cookbook](https://github.com/github/awesome-copilot/blob/main/cookbook/copilot-sdk/go/README.md) | `go get github.com/github/copilot-sdk/go` |
| **.NET** | [`dotnet/`](./dotnet/) | [Cookbook](https://github.com/github/awesome-copilot/blob/main/cookbook/copilot-sdk/dotnet/README.md) | `dotnet add package GitHub.Copilot.SDK` |
| **Rust** | [`rust/`](./rust/) | — | `cargo add github-copilot-sdk` |
| **Java** | [`github/copilot-sdk-java`](https://github.com/github/copilot-sdk-java) | [Cookbook](https://github.com/github/awesome-copilot/blob/main/cookbook/copilot-sdk/java/README.md) | Maven coordinates<br>`com.github:copilot-sdk-java`<br>See instructions for [Maven](https://github.com/github/copilot-sdk-java?tab=readme-ov-file#maven) and [Gradle](https://github.com/github/copilot-sdk-java?tab=readme-ov-file#gradle) |
| **Java** | [`java/`](./java/) | [Cookbook](https://github.com/github/awesome-copilot/blob/main/cookbook/copilot-sdk/java/README.md) | Maven coordinates<br>`com.github:copilot-sdk-java`<br>See instructions for [Maven](https://github.com/github/copilot-sdk-java?tab=readme-ov-file#maven) and [Gradle](https://github.com/github/copilot-sdk-java?tab=readme-ov-file#gradle) |

See the individual SDK READMEs for installation, usage examples, and API reference.

Expand All @@ -37,7 +37,7 @@ Quick steps:
1. **(Optional) Install the Copilot CLI**

For Node.js, Python, and .NET SDKs, the Copilot CLI is bundled automatically and no separate installation is required.
For the Go and Rust SDKs, [install the CLI manually](https://github.com/features/copilot/cli) or ensure `copilot` is available in your PATH unless you opt into their application-level CLI bundling features.
For the Go, Java and Rust SDKs, [install the CLI manually](https://github.com/features/copilot/cli) or ensure `copilot` is available in your PATH unless you opt into their application-level CLI bundling features.

2. **Install your preferred SDK** using the commands above.

Expand Down Expand Up @@ -88,7 +88,7 @@ See the **[Authentication documentation](./docs/auth/index.md)** for details on

No — for Node.js, Python, and .NET SDKs, the Copilot CLI is bundled automatically as a dependency. You do not need to install it separately.

For Go and Rust SDKs, the CLI is not bundled by default. Install the CLI manually, ensure `copilot` is available in your PATH, or opt into their application-level CLI bundling features.
For Go, Java and Rust SDKs, the CLI is **not** bundled by default. Install the CLI manually, ensure `copilot` is available in your PATH, or opt into their application-level CLI bundling features.

Advanced: You can override the CLI binary or connect to an external server. See the individual SDK README for language-specific options.

Expand All @@ -109,7 +109,7 @@ Yes, check out the custom instructions and SDK-specific guidance:
- **[.NET](https://github.com/github/awesome-copilot/blob/main/instructions/copilot-sdk-csharp.instructions.md)**
- **[Go](https://github.com/github/awesome-copilot/blob/main/instructions/copilot-sdk-go.instructions.md)**
- **[Rust](./rust/README.md)** (SDK guidance; custom instructions not yet published)
- **[Java](https://github.com/github/copilot-sdk-java/blob/main/instructions/copilot-sdk-java.instructions.md)**
- **[Java](https://github.com/github/awesome-copilot/blob/main/instructions/copilot-sdk-java.instructions.md)**

### What models are supported?

Expand Down
11 changes: 6 additions & 5 deletions docs/auth/authenticate.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ await using var client = new CopilotClient();
<summary><strong>Java</strong></summary>

```java
import com.github.copilot.sdk.CopilotClient;
import com.github.copilot.CopilotClient;

// Default: uses logged-in user credentials
var client = new CopilotClient();
Expand Down Expand Up @@ -205,9 +205,10 @@ await using var client = new CopilotClient(new CopilotClientOptions
<details>
<summary><strong>Java</strong></summary>

<!-- docs-validate: skip -->
```java
import com.github.copilot.sdk.CopilotClient;
import com.github.copilot.sdk.json.*;
import com.github.copilot.CopilotClient;
import com.github.copilot.rpc.*;

var client = new CopilotClient(new CopilotClientOptions()
.setGitHubToken(userAccessToken) // Token from OAuth flow
Expand Down Expand Up @@ -384,8 +385,8 @@ await using var client = new CopilotClient(new CopilotClientOptions
<summary><strong>Java</strong></summary>

```java
import com.github.copilot.sdk.CopilotClient;
import com.github.copilot.sdk.json.*;
import com.github.copilot.CopilotClient;
import com.github.copilot.rpc.*;

var client = new CopilotClient(new CopilotClientOptions()
.setUseLoggedInUser(false) // Only use explicit tokens
Expand Down
9 changes: 4 additions & 5 deletions docs/auth/byok.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,8 @@ Console.WriteLine(response?.Data.Content);
<summary><strong>Java</strong></summary>

```java
import com.github.copilot.sdk.CopilotClient;
import com.github.copilot.sdk.events.*;
import com.github.copilot.sdk.json.*;
import com.github.copilot.CopilotClient;
import com.github.copilot.rpc.*;

var client = new CopilotClient();
client.start().get();
Expand Down Expand Up @@ -450,8 +449,8 @@ var client = new CopilotClient(new CopilotClientOptions
<summary><strong>Java</strong></summary>

```java
import com.github.copilot.sdk.CopilotClient;
import com.github.copilot.sdk.json.*;
import com.github.copilot.CopilotClient;
import com.github.copilot.rpc.*;
import java.util.List;
import java.util.concurrent.CompletableFuture;

Expand Down
10 changes: 5 additions & 5 deletions docs/features/custom-agents.md
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,8 @@ await using var session = await client.CreateSessionAsync(new SessionConfig
<summary><strong>Java</strong></summary>

```java
import com.github.copilot.sdk.CopilotClient;
import com.github.copilot.sdk.events.*;
import com.github.copilot.sdk.json.*;
import com.github.copilot.CopilotClient;
import com.github.copilot.rpc.*;
import java.util.List;

try (var client = new CopilotClient()) {
Expand Down Expand Up @@ -387,7 +386,7 @@ var session = await client.CreateSessionAsync(new SessionConfig

<!-- docs-validate: skip -->
```java
import com.github.copilot.sdk.json.*;
import com.github.copilot.rpc.*;
import java.util.List;

var session = client.createSession(
Expand Down Expand Up @@ -656,6 +655,7 @@ await session.SendAndWaitAsync(new MessageOptions
<details>
<summary><strong>Java</strong></summary>

<!-- docs-validate: skip -->
```java
session.on(event -> {
if (event instanceof SubagentStartedEvent e) {
Expand Down Expand Up @@ -980,4 +980,4 @@ session.on((event) => {
// Show error in UI, retry, or fall back to parent agent
}
});
```
```
16 changes: 8 additions & 8 deletions docs/features/hooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,8 @@ var session = await client.CreateSessionAsync(new SessionConfig
<summary><strong>Java</strong></summary>

```java
import com.github.copilot.sdk.CopilotClient;
import com.github.copilot.sdk.events.*;
import com.github.copilot.sdk.json.*;
import com.github.copilot.CopilotClient;
import com.github.copilot.rpc.*;
import java.util.concurrent.CompletableFuture;

try (var client = new CopilotClient()) {
Expand Down Expand Up @@ -430,14 +429,15 @@ var session = await client.CreateSessionAsync(new SessionConfig
<details>
<summary><strong>Java</strong></summary>

<!-- docs-validate: skip -->
```java
import java.util.Set;
import java.util.concurrent.CompletableFuture;

import com.github.copilot.sdk.PermissionHandler;
import com.github.copilot.sdk.SessionConfig;
import com.github.copilot.sdk.SessionHooks;
import com.github.copilot.sdk.json.PreToolUseHookOutput;
import com.github.copilot.rpc.PermissionHandler;
import com.github.copilot.rpc.SessionConfig;
import com.github.copilot.rpc.SessionHooks;
import com.github.copilot.rpc.PreToolUseHookOutput;
var readOnlyTools = Set.of("read_file", "glob", "grep", "view");

var hooks = new SessionHooks()
Expand Down Expand Up @@ -1063,4 +1063,4 @@ For full type definitions, input/output field tables, and additional examples fo
- [Getting Started](../getting-started.md)
- [Custom Agents & Sub-Agent Orchestration](./custom-agents.md)
- [Streaming Session Events](./streaming-events.md)
- [Debugging Guide](../troubleshooting/debugging.md)
- [Debugging Guide](../troubleshooting/debugging.md)
10 changes: 4 additions & 6 deletions docs/features/image-input.md
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,8 @@ await session.SendAsync(new MessageOptions
<summary><strong>Java</strong></summary>

```java
import com.github.copilot.sdk.CopilotClient;
import com.github.copilot.sdk.events.*;
import com.github.copilot.sdk.json.*;
import com.github.copilot.CopilotClient;
import com.github.copilot.rpc.*;
import java.util.List;

try (var client = new CopilotClient()) {
Expand Down Expand Up @@ -434,9 +433,8 @@ await session.SendAsync(new MessageOptions
<summary><strong>Java</strong></summary>

```java
import com.github.copilot.sdk.CopilotClient;
import com.github.copilot.sdk.events.*;
import com.github.copilot.sdk.json.*;
import com.github.copilot.CopilotClient;
import com.github.copilot.rpc.*;
import java.util.List;

try (var client = new CopilotClient()) {
Expand Down
10 changes: 5 additions & 5 deletions docs/features/skills.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,8 @@ await session.SendAndWaitAsync(new MessageOptions
<summary><strong>Java</strong></summary>

```java
import com.github.copilot.sdk.CopilotClient;
import com.github.copilot.sdk.events.*;
import com.github.copilot.sdk.json.*;
import com.github.copilot.CopilotClient;
import com.github.copilot.rpc.*;
import java.util.List;

try (var client = new CopilotClient()) {
Expand Down Expand Up @@ -280,8 +279,9 @@ var session = await client.CreateSessionAsync(new SessionConfig
<details>
<summary><strong>Java</strong></summary>

<!-- docs-validate: skip -->
```java
import com.github.copilot.sdk.json.*;
import com.github.copilot.rpc.*;
import java.util.List;

var session = client.createSession(
Expand Down Expand Up @@ -422,4 +422,4 @@ If multiple skills provide conflicting instructions:

* [Custom Agents](../getting-started.md#create-custom-agents) - Define specialized AI personas
* [Custom Tools](../getting-started.md#step-4-add-a-custom-tool) - Build your own tools
* [MCP Servers](./mcp.md) - Connect external tool providers
* [MCP Servers](./mcp.md) - Connect external tool providers
10 changes: 4 additions & 6 deletions docs/features/steering-and-queueing.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,8 @@ await session.SendAsync(new MessageOptions
<summary><strong>Java</strong></summary>

```java
import com.github.copilot.sdk.CopilotClient;
import com.github.copilot.sdk.events.*;
import com.github.copilot.sdk.json.*;
import com.github.copilot.CopilotClient;
import com.github.copilot.rpc.*;

try (var client = new CopilotClient()) {
client.start().get();
Expand Down Expand Up @@ -427,9 +426,8 @@ await session.SendAsync(new MessageOptions
<summary><strong>Java</strong></summary>

```java
import com.github.copilot.sdk.CopilotClient;
import com.github.copilot.sdk.events.*;
import com.github.copilot.sdk.json.*;
import com.github.copilot.CopilotClient;
import com.github.copilot.rpc.*;

try (var client = new CopilotClient()) {
client.start().get();
Expand Down
3 changes: 2 additions & 1 deletion docs/features/streaming-events.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ session.On<SessionEvent>(evt =>
<details>
<summary><strong>Java</strong></summary>

<!-- docs-validate: skip -->
```java
// All events
session.on(event -> System.out.println(event.getType()));
Expand Down Expand Up @@ -793,4 +794,4 @@ session.idle → Ready for next message (ephemeral)
| `command.queued` | ✅ | Command | `requestId`, `command` |
| `command.completed` | ✅ | Command | `requestId` |
| `exit_plan_mode.requested` | ✅ | Plan Mode | `requestId`, `summary`, `planContent`, `actions` |
| `exit_plan_mode.completed` | ✅ | Plan Mode | `requestId` |
| `exit_plan_mode.completed` | ✅ | Plan Mode | `requestId` |
Loading
Loading