-
Notifications
You must be signed in to change notification settings - Fork 8
feat - LSP data layer + confirmationService skeleton (Auto-approve Part 1 ) #132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
xinyi-gong
wants to merge
3
commits into
feature/auto-approve
Choose a base branch
from
tori/auto-approve-task-1
base: feature/auto-approve
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
...copilot.eclipse.core/src/com/microsoft/copilot/eclipse/core/chat/ConfirmationHandler.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT license. | ||
|
|
||
| package com.microsoft.copilot.eclipse.core.chat; | ||
|
|
||
| import com.microsoft.copilot.eclipse.core.lsp.protocol.InvokeClientToolConfirmationParams; | ||
|
|
||
| /** | ||
| * Evaluates whether a tool confirmation request can be auto-approved. | ||
| * Each implementation handles a specific category of tool (terminal, file operations, MCP, etc.). | ||
| */ | ||
| public interface ConfirmationHandler { | ||
|
|
||
| /** | ||
| * Evaluates whether the given confirmation request should be auto-approved. | ||
| * | ||
| * @param params the confirmation request parameters from CLS | ||
| * @return ConfirmationResult.AUTO_APPROVED if the tool call can proceed without user | ||
| * confirmation, or ConfirmationResult.NEEDS_CONFIRMATION if the user must approve | ||
| */ | ||
| ConfirmationResult evaluate(InvokeClientToolConfirmationParams params); | ||
| } | ||
19 changes: 19 additions & 0 deletions
19
....copilot.eclipse.core/src/com/microsoft/copilot/eclipse/core/chat/ConfirmationResult.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT license. | ||
|
|
||
| package com.microsoft.copilot.eclipse.core.chat; | ||
|
|
||
| /** | ||
| * Result of evaluating an auto-approve confirmation request. | ||
| */ | ||
| public enum ConfirmationResult { | ||
| /** | ||
| * The tool invocation is automatically approved and no user confirmation is needed. | ||
| */ | ||
| AUTO_APPROVED, | ||
|
|
||
| /** | ||
| * The tool invocation requires user confirmation before proceeding. | ||
| */ | ||
| NEEDS_CONFIRMATION | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
...lot.eclipse.core/src/com/microsoft/copilot/eclipse/core/lsp/protocol/ToolAnnotations.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT license. | ||
|
|
||
| package com.microsoft.copilot.eclipse.core.lsp.protocol; | ||
|
|
||
| import java.util.Objects; | ||
|
|
||
| import org.apache.commons.lang3.builder.ToStringBuilder; | ||
|
|
||
| /** | ||
| * MCP tool annotations describing tool behavior hints (e.g., readOnly, destructive). | ||
| * Provided by CLS, originally sourced from the MCP server's tool definition. | ||
| */ | ||
| public class ToolAnnotations { | ||
| private boolean readOnlyHint; | ||
| private boolean destructiveHint; | ||
| private boolean idempotentHint; | ||
| private boolean openWorldHint; | ||
|
|
||
| public boolean isReadOnlyHint() { | ||
| return readOnlyHint; | ||
| } | ||
|
|
||
| public void setReadOnlyHint(boolean readOnlyHint) { | ||
| this.readOnlyHint = readOnlyHint; | ||
| } | ||
|
|
||
| public boolean isDestructiveHint() { | ||
| return destructiveHint; | ||
| } | ||
|
|
||
| public void setDestructiveHint(boolean destructiveHint) { | ||
| this.destructiveHint = destructiveHint; | ||
| } | ||
|
|
||
| public boolean isIdempotentHint() { | ||
| return idempotentHint; | ||
| } | ||
|
|
||
| public void setIdempotentHint(boolean idempotentHint) { | ||
| this.idempotentHint = idempotentHint; | ||
| } | ||
|
|
||
| public boolean isOpenWorldHint() { | ||
| return openWorldHint; | ||
| } | ||
|
|
||
| public void setOpenWorldHint(boolean openWorldHint) { | ||
| this.openWorldHint = openWorldHint; | ||
| } | ||
|
|
||
| @Override | ||
| public int hashCode() { | ||
| return Objects.hash(readOnlyHint, destructiveHint, idempotentHint, openWorldHint); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean equals(Object obj) { | ||
| if (this == obj) { | ||
| return true; | ||
| } | ||
| if (obj == null) { | ||
| return false; | ||
| } | ||
| if (getClass() != obj.getClass()) { | ||
| return false; | ||
| } | ||
| ToolAnnotations other = (ToolAnnotations) obj; | ||
| return readOnlyHint == other.readOnlyHint | ||
| && destructiveHint == other.destructiveHint | ||
| && idempotentHint == other.idempotentHint | ||
| && openWorldHint == other.openWorldHint; | ||
| } | ||
|
|
||
| @Override | ||
| public String toString() { | ||
| ToStringBuilder builder = new ToStringBuilder(this); | ||
| builder.append("readOnlyHint", readOnlyHint); | ||
| builder.append("destructiveHint", destructiveHint); | ||
| builder.append("idempotentHint", idempotentHint); | ||
| builder.append("openWorldHint", openWorldHint); | ||
| return builder.toString(); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.