[upstream-sync] Port changes from copilot-sdk v0.2.0 (PR #906): Commands and UI Elicitation#67
Closed
github-actions[bot] wants to merge 1 commit intomainfrom
Closed
Conversation
Ports [Node] Add Commands and UI Elicitation Support to SDK (#906)
from github/copilot-sdk.
New features:
- :commands session config option: register slash commands with handlers
{:command-name "name" :command-handler (fn [ctx] ...) :command-description "desc"}
Commands appear as /name in CLI TUI; handler receives context map
{:session-id :command-name :command :args}
- command.execute broadcast event handled via session.commands.handlePendingCommand RPC
- session/capabilities: returns host capabilities from create/resume response
e.g. {:ui {:elicitation true}}
- New specs: ::command-definition, ::commands, ::session-capabilities, ::input-options
- Instrumentation/fdefs for all new public functions
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Collaborator
|
superseded by #70 |
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.
Summary
Ports upstream PR #906 ([Node] Add Commands and UI Elicitation Support to SDK) from
github/copilot-sdk.Upstream Changes Ported
PR #906 — Commands and UI Elicitation Support
New: Slash command registration
Sessions can now register slash commands via the
:commandsconfig option. When the CLI has a TUI, registered commands appear as/namefor users to invoke. The SDK automatically routescommand.executebroadcast events to the registered handler and responds viasession.commands.handlePendingCommandRPC.New: Session capabilities
session/capabilitiesreturns host capabilities reported when the session was created or resumed. Use this to check feature support before calling capability-gated APIs.New: UI convenience methods (all experimental)
Three new functions for interactive dialogs with the CLI host:
session/ui-confirm!— shows a confirmation dialog, returnstrue/falsesession/ui-select!— shows a selection dialog, returns selected string ornilsession/ui-input!— shows a text input dialog, returns entered string ornilChanges Skipped
copilot.types) — Python-specific, not relevant to Clojure portFiles Changed
src/github/copilot_sdk/specs.clj— new specs:::command-definition,::commands,::session-capabilities,::input-options; updatedsession-config-keys,::session-config,::resume-session-config,::join-session-configto include:commandssrc/github/copilot_sdk/session.clj—create-sessionnow accepts:commandsand initializes:command-handlersand:capabilitiesin session state; newset-capabilities!,handle-command!,capabilities,ui-confirm!,ui-select!,ui-input!functionssrc/github/copilot_sdk/client.clj—handle-v3-command-execute!function;command.executeevent handling inhandle-v3-broadcast-event!;:commandswired intobuild-create-session-params,build-resume-session-params,pre-register-session;set-capabilities!called after create/resume RPC (sync and async variants)src/github/copilot_sdk/instrument.clj— fdefs forcapabilities,ui-confirm!,ui-select!,ui-input!; added to bothinstrument-all!andunstrument-all!listsCHANGELOG.md— documented changes under[Unreleased]Testing
The test suite requires network access to download Clojure dependencies (Maven), which is not available in this environment. The implementation follows the exact same patterns as existing handlers (
handle-v3-tool-requested!,handle-v3-permission-requested!) and the code compiles syntactically (paren-balanced, verified).Key correctness notes:
:commandssent as[{:name "name" :description? "desc"}](no handler, matching upstream)command.execute::request-id,:command-name,:command,:args(from wire after kebab conversion)wire->clj(e.g.{:ui {:elicitation true}})::session-capabilitiesmatches actual wire structure{:ui {:elicitation bool}}Notes for Reviewer
capabilitiesgetter is public (not experimental) following upstream^:experimentalfollowing upstream conventionasync/thread-call :io(same as tool/permission handlers)