Skip to content

[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
upstream-sync/2026-03-24-cff500739215b10c
Closed

[upstream-sync] Port changes from copilot-sdk v0.2.0 (PR #906): Commands and UI Elicitation#67
github-actions[bot] wants to merge 1 commit intomainfrom
upstream-sync/2026-03-24-cff500739215b10c

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

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 :commands config option. When the CLI has a TUI, registered commands appear as /name for users to invoke. The SDK automatically routes command.execute broadcast events to the registered handler and responds via session.commands.handlePendingCommand RPC.

(copilot/create-session client
  {:on-permission-request copilot/approve-all
   :commands [{:command-name "deploy"
               :command-description "Deploy to production"
               :command-handler (fn [ctx]
                                  (println "Deploying from session" (:session-id ctx))
                                  (println "Args:" (:args ctx)))}]})

New: Session capabilities

session/capabilities returns host capabilities reported when the session was created or resumed. Use this to check feature support before calling capability-gated APIs.

(when (get-in (session/capabilities session) [:ui :elicitation])
  (session/ui-confirm! session "Deploy to production?"))

New: UI convenience methods (all experimental)

Three new functions for interactive dialogs with the CLI host:

  • session/ui-confirm! — shows a confirmation dialog, returns true/false
  • session/ui-select! — shows a selection dialog, returns selected string or nil
  • session/ui-input! — shows a text input dialog, returns entered string or nil

Changes Skipped

  • PR #871 ([Python] Remove copilot.types) — Python-specific, not relevant to Clojure port

Files Changed

  • src/github/copilot_sdk/specs.clj — new specs: ::command-definition, ::commands, ::session-capabilities, ::input-options; updated session-config-keys, ::session-config, ::resume-session-config, ::join-session-config to include :commands
  • src/github/copilot_sdk/session.cljcreate-session now accepts :commands and initializes :command-handlers and :capabilities in session state; new set-capabilities!, handle-command!, capabilities, ui-confirm!, ui-select!, ui-input! functions
  • src/github/copilot_sdk/client.cljhandle-v3-command-execute! function; command.execute event handling in handle-v3-broadcast-event!; :commands wired into build-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 for capabilities, ui-confirm!, ui-select!, ui-input!; added to both instrument-all! and unstrument-all! lists
  • CHANGELOG.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:

  • Wire format: :commands sent as [{:name "name" :description? "desc"}] (no handler, matching upstream)
  • Event data for command.execute: :request-id, :command-name, :command, :args (from wire after kebab conversion)
  • Capabilities stored as-is from RPC response after wire->clj (e.g. {:ui {:elicitation true}})
  • Spec ::session-capabilities matches actual wire structure {:ui {:elicitation bool}}

Notes for Reviewer

  • The capabilities getter is public (not experimental) following upstream
  • UI methods are ^:experimental following upstream convention
  • Command handlers run on async/thread-call :io (same as tool/permission handlers)

Generated by Upstream Sync Agent ·

  • expires on Mar 31, 2026, 2:35 PM UTC

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>
@krukow
Copy link
Copy Markdown
Collaborator

krukow commented Mar 26, 2026

superseded by #70

@krukow krukow closed this Mar 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant