Package com.github.copilot.sdk.json
Interface PermissionHandler
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Functional interface for handling permission requests from the AI assistant.
When the assistant needs permission to perform certain actions (such as executing tools or accessing resources), this handler is invoked to approve or deny the request.
Example Implementation
PermissionHandler handler = (request, invocation) -> {
// Check the permission kind
if ("dangerous-action".equals(request.getKind())) {
// Deny dangerous actions
return CompletableFuture.completedFuture(new PermissionRequestResult().setKind("user-denied"));
}
// Approve other requests
return CompletableFuture.completedFuture(new PermissionRequestResult().setKind("user-approved"));
};
A pre-built handler that approves all requests is available as
APPROVE_ALL.
- Since:
- 1.0.0
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final PermissionHandlerA pre-built handler that approves all permission requests. -
Method Summary
Modifier and TypeMethodDescriptionhandle(PermissionRequest request, PermissionInvocation invocation) Handles a permission request from the assistant.
-
Field Details
-
APPROVE_ALL
A pre-built handler that approves all permission requests.- Since:
- 1.0.11
-
-
Method Details
-
handle
CompletableFuture<PermissionRequestResult> handle(PermissionRequest request, PermissionInvocation invocation) Handles a permission request from the assistant.The handler should evaluate the request and return a result indicating whether the permission is granted or denied.
- Parameters:
request- the permission request detailsinvocation- the invocation context with session information- Returns:
- a future that completes with the permission decision
-