diff --git a/docs/auth/byok.md b/docs/auth/byok.md index 83602c574..823c376b1 100644 --- a/docs/auth/byok.md +++ b/docs/auth/byok.md @@ -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() diff --git a/docs/features/custom-agents.md b/docs/features/custom-agents.md index cc5d70921..462161cfb 100644 --- a/docs/features/custom-agents.md +++ b/docs/features/custom-agents.md @@ -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(); @@ -356,6 +357,9 @@ var session = await client.CreateSessionAsync(new SessionConfig ```java +import com.github.copilot.sdk.json.*; +import java.util.List; + var session = client.createSession( new SessionConfig() .setCustomAgents(List.of( diff --git a/docs/features/hooks.md b/docs/features/hooks.md index e1b9d88d8..826ee5efd 100644 --- a/docs/features/hooks.md +++ b/docs/features/hooks.md @@ -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(); @@ -411,6 +412,13 @@ var session = await client.CreateSessionAsync(new SessionConfig Java ```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; var readOnlyTools = Set.of("read_file", "glob", "grep", "view"); var hooks = new SessionHooks() diff --git a/docs/features/image-input.md b/docs/features/image-input.md index a5902c0d4..91d3cc75a 100644 --- a/docs/features/image-input.md +++ b/docs/features/image-input.md @@ -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(); @@ -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(); diff --git a/docs/features/skills.md b/docs/features/skills.md index 9456d7e7a..882580fd4 100644 --- a/docs/features/skills.md +++ b/docs/features/skills.md @@ -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(); @@ -277,6 +278,9 @@ var session = await client.CreateSessionAsync(new SessionConfig Java ```java +import com.github.copilot.sdk.json.*; +import java.util.List; + var session = client.createSession( new SessionConfig() .setSkillDirectories(List.of("./skills")) diff --git a/docs/getting-started.md b/docs/getting-started.md index dea074aed..ab2893a27 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -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( @@ -475,6 +477,7 @@ public class HelloCopilot { new SessionConfig() .setModel("gpt-4.1") .setStreaming(true) + .setOnPermissionRequest(PermissionHandler.APPROVE_ALL) ).get(); // Listen for response chunks diff --git a/docs/hooks/error-handling.md b/docs/hooks/error-handling.md index e66dc32ff..b721a3b91 100644 --- a/docs/hooks/error-handling.md +++ b/docs/hooks/error-handling.md @@ -105,12 +105,13 @@ public delegate Task 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. ``` diff --git a/docs/hooks/index.md b/docs/hooks/index.md index b5b711888..3373602c4 100644 --- a/docs/hooks/index.md +++ b/docs/hooks/index.md @@ -185,6 +185,7 @@ try (var client = new CopilotClient()) { var session = client.createSession( new SessionConfig() .setHooks(hooks) + .setOnPermissionRequest(PermissionHandler.APPROVE_ALL) ).get(); } ``` diff --git a/docs/integrations/microsoft-agent-framework.md b/docs/integrations/microsoft-agent-framework.md index 01c785f27..dc37051d2 100644 --- a/docs/integrations/microsoft-agent-framework.md +++ b/docs/integrations/microsoft-agent-framework.md @@ -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( diff --git a/docs/setup/backend-services.md b/docs/setup/backend-services.md index b30843880..cc5a055b4 100644 --- a/docs/setup/backend-services.md +++ b/docs/setup/backend-services.md @@ -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") ); @@ -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() diff --git a/docs/setup/bundled-cli.md b/docs/setup/bundled-cli.md index 3360f0776..7a025385c 100644 --- a/docs/setup/bundled-cli.md +++ b/docs/setup/bundled-cli.md @@ -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(); diff --git a/docs/setup/github-oauth.md b/docs/setup/github-oauth.md index 200c7dfd4..553dde1cb 100644 --- a/docs/setup/github-oauth.md +++ b/docs/setup/github-oauth.md @@ -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()