Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions docs/auth/byok.md
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,7 @@ var client = new CopilotClient(new CopilotClientOptions
```java
import com.github.copilot.sdk.CopilotClient;
import com.github.copilot.sdk.json.*;
import java.util.List;
import java.util.concurrent.CompletableFuture;

var client = new CopilotClient(new CopilotClientOptions()
Expand Down
8 changes: 8 additions & 0 deletions docs/features/custom-agents.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ await using var session = await client.CreateSessionAsync(new SessionConfig
import com.github.copilot.sdk.CopilotClient;
import com.github.copilot.sdk.events.*;
import com.github.copilot.sdk.json.*;
import java.util.List;

try (var client = new CopilotClient()) {
client.start().get();
Expand Down Expand Up @@ -356,6 +357,13 @@ var session = await client.CreateSessionAsync(new SessionConfig

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

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

Comment thread
brunoborges marked this conversation as resolved.
Outdated
var session = client.createSession(
new SessionConfig()
.setCustomAgents(List.of(
Expand Down
4 changes: 4 additions & 0 deletions docs/features/hooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ var session = await client.CreateSessionAsync(new SessionConfig
import com.github.copilot.sdk.CopilotClient;
import com.github.copilot.sdk.events.*;
import com.github.copilot.sdk.json.*;
import java.util.concurrent.CompletableFuture;

try (var client = new CopilotClient()) {
client.start().get();
Expand Down Expand Up @@ -411,6 +412,9 @@ var session = await client.CreateSessionAsync(new SessionConfig
<summary><strong>Java</strong></summary>

```java
import java.util.Set;
import java.util.concurrent.CompletableFuture;

Comment thread
brunoborges marked this conversation as resolved.
var readOnlyTools = Set.of("read_file", "glob", "grep", "view");

var hooks = new SessionHooks()
Expand Down
2 changes: 2 additions & 0 deletions docs/features/image-input.md
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ await session.SendAsync(new MessageOptions
import com.github.copilot.sdk.CopilotClient;
import com.github.copilot.sdk.events.*;
import com.github.copilot.sdk.json.*;
import java.util.List;

try (var client = new CopilotClient()) {
client.start().get();
Expand Down Expand Up @@ -435,6 +436,7 @@ await session.SendAsync(new MessageOptions
import com.github.copilot.sdk.CopilotClient;
import com.github.copilot.sdk.events.*;
import com.github.copilot.sdk.json.*;
import java.util.List;

try (var client = new CopilotClient()) {
client.start().get();
Expand Down
4 changes: 4 additions & 0 deletions docs/features/skills.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ await session.SendAndWaitAsync(new MessageOptions
import com.github.copilot.sdk.CopilotClient;
import com.github.copilot.sdk.events.*;
import com.github.copilot.sdk.json.*;
import java.util.List;

try (var client = new CopilotClient()) {
client.start().get();
Expand Down Expand Up @@ -277,6 +278,9 @@ var session = await client.CreateSessionAsync(new SessionConfig
<summary><strong>Java</strong></summary>

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

var session = client.createSession(
new SessionConfig()
.setSkillDirectories(List.of("./skills"))
Expand Down
5 changes: 4 additions & 1 deletion docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,9 @@ public class HelloCopilot {
client.start().get();

var session = client.createSession(
new SessionConfig().setModel("gpt-4.1")
new SessionConfig()
.setModel("gpt-4.1")
.setOnPermissionRequest(PermissionHandler.APPROVE_ALL)
).get();

var response = session.sendAndWait(
Expand Down Expand Up @@ -475,6 +477,7 @@ public class HelloCopilot {
new SessionConfig()
.setModel("gpt-4.1")
.setStreaming(true)
.setOnPermissionRequest(PermissionHandler.APPROVE_ALL)
).get();

// Listen for response chunks
Expand Down
13 changes: 7 additions & 6 deletions docs/hooks/error-handling.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,13 @@ public delegate Task<ErrorOccurredHookOutput?> ErrorOccurredHandler(
```java
// Note: Java SDK does not have an onErrorOccurred hook.
// Use EventErrorPolicy and EventErrorHandler instead:
import com.github.copilot.sdk.*;

session.setEventErrorPolicy(EventErrorPolicy.SUPPRESS_AND_LOG_ERRORS);
session.setEventErrorHandler((event, ex) -> {
System.err.println("Error in " + event.getType() + ": " + ex.getMessage());
});
//
// session.setEventErrorPolicy(EventErrorPolicy.SUPPRESS_AND_LOG_ERRORS);
// session.setEventErrorHandler((event, ex) -> {
// System.err.println("Error in " + event.getType() + ": " + ex.getMessage());
// });
//
// See the "Basic Error Logging" example below for a complete snippet.
```

</details>
Expand Down
1 change: 1 addition & 0 deletions docs/hooks/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ try (var client = new CopilotClient()) {
var session = client.createSession(
new SessionConfig()
.setHooks(hooks)
.setOnPermissionRequest(PermissionHandler.APPROVE_ALL)
).get();
}
```
Expand Down
2 changes: 2 additions & 0 deletions docs/integrations/microsoft-agent-framework.md
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,8 @@ await session.sendAndWait({ prompt: "What's the weather like in Seattle?" });
import com.github.copilot.sdk.CopilotClient;
import com.github.copilot.sdk.events.*;
import com.github.copilot.sdk.json.*;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;

var getWeather = ToolDefinition.create(
Expand Down
5 changes: 4 additions & 1 deletion docs/setup/backend-services.md
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,9 @@ import com.github.copilot.sdk.CopilotClient;
import com.github.copilot.sdk.events.*;
import com.github.copilot.sdk.json.*;

var userId = "user1";
var message = "Hello!";

var client = new CopilotClient(new CopilotClientOptions()
.setCliUrl("localhost:4321")
);
Expand All @@ -241,7 +244,7 @@ try {
var session = client.createSession(new SessionConfig()
.setSessionId(String.format("user-%s-%d", userId, System.currentTimeMillis() / 1000))
.setModel("gpt-4.1")
.setOnPermissionRequest(request -> request.allow())
.setOnPermissionRequest(PermissionHandler.APPROVE_ALL)
).get();

var response = session.sendAndWait(new MessageOptions()
Expand Down
4 changes: 3 additions & 1 deletion docs/setup/bundled-cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,9 @@ var client = new CopilotClient(new CopilotClientOptions()
client.start().get();

var session = client.createSession(new SessionConfig()
.setModel("gpt-4.1")).get();
.setModel("gpt-4.1")
.setOnPermissionRequest(PermissionHandler.APPROVE_ALL)
).get();

var response = session.sendAndWait(new MessageOptions()
.setPrompt("Hello!")).get();
Expand Down
2 changes: 2 additions & 0 deletions docs/setup/github-oauth.md
Original file line number Diff line number Diff line change
Expand Up @@ -293,10 +293,12 @@ CopilotClient createClientForUser(String userToken) throws Exception {
}

// Usage — use try-with-resources to ensure cleanup
var userId = "user1";
try (var client = createClientForUser("gho_user_access_token")) {
var session = client.createSession(new SessionConfig()
.setSessionId(String.format("user-%s-session", userId))
.setModel("gpt-4.1")
.setOnPermissionRequest(PermissionHandler.APPROVE_ALL)
).get();

var response = session.sendAndWait(new MessageOptions()
Expand Down
Loading