feat: add no-result permission outcome for extensions (upstream PR #802)#56
Merged
feat: add no-result permission outcome for extensions (upstream PR #802)#56
Conversation
Extensions can attach to sessions without actively answering permission
requests by returning {:kind :no-result} from their :on-permission-request
handler.
- v3 protocol: skip handlePendingPermissionRequest RPC call
- v2 protocol: propagate as JSON-RPC internal error (-32603)
- Handle both direct {:kind :no-result} and wrapped {:result {:kind :no-result}}
- Add :no-result to ::permission-result-kind spec
- Add tests for both direct and wrapped no-result on v2 path
- Update API.md and CHANGELOG.md
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Ports upstream copilot-sdk PR #802 by introducing a :no-result permission outcome so extensions can attach to sessions without actively answering permission requests, with protocol-specific behavior for v2 vs v3.
Changes:
- Add
:no-resultto permission result specs and document it in the public API reference. - Normalize permission handler returns to a
{:result :no-result}sentinel insession/handle-permission-request!. - Implement protocol-specific handling: v3 skips
handlePendingPermissionRequestRPC; v2 propagates-32603as an error, with integration tests for v2.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
test/github/copilot_sdk/integration_test.clj |
Adds v2 protocol integration tests for direct and wrapped :no-result permission handler returns. |
src/github/copilot_sdk/specs.clj |
Extends ::permission-result-kind to include :no-result. |
src/github/copilot_sdk/session.clj |
Normalizes permission handler responses and introduces {:result :no-result} sentinel. |
src/github/copilot_sdk/client.clj |
Implements v3 “skip RPC on no-result” and v2 “return -32603 error on no-result” behavior. |
doc/reference/API.md |
Documents {:kind :no-result} as a permission handler return option. |
CHANGELOG.md |
Adds an Unreleased changelog entry describing the new :no-result outcome and v2/v3 semantics. |
- Clarify handle-permission-request! docstring for v2 vs v3 behavior - Add integration test for v3 permission.requested no-result path - Add integration test for v3 permission.requested approved path - Add handlePendingPermissionRequest handler to mock server Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Motivation
Upstream copilot-sdk PR #802 adds a
no-resultpermission outcome so extensions can attach to sessions without actively answering permission requests. This is the idiomatic Clojure port.Approach
When a permission handler returns
{:kind :no-result}, the SDK treats it as "this extension declines to answer" rather than a deny:handlePendingPermissionRequestRPC call is skipped entirely — the extension stays silent and another handler may respond.-32603) is propagated to the CLI, matching upstream behavior where the thrown error signals no answer was given.The sentinel value
{:result :no-result}(a keyword instead of a map) flows through the internalhandle-permission-request!→ caller pipeline so both v2 and v3 code paths can distinguish it from a normal permission result.Key decisions
{:kind :no-result}(direct) or{:result {:kind :no-result}}(wrapped). Both are normalized to the sentinel before reaching callers.-32603matches the upstream Node.js SDK's internal error semantics for v2 no-result propagation.Changes
specs.clj—:no-resultadded to::permission-result-kindsession.clj—handle-permission-request!returns sentinel for no-resultclient.clj— v3 handler skips RPC; v2 handler returns errorintegration_test.clj— Tests for both direct and wrapped no-result on v2API.md— Documents:no-resultin permission result examplesCHANGELOG.md— Entry under[Unreleased]Validation
bb validate-docspassesCreated with GitHub Desktop