Skip to content

Port upstream v0.2.1: commands, UI elicitation, COPILOT_CLI_PATH#70

Merged
krukow merged 10 commits intomainfrom
upstream-sync/v0.2.1
Mar 26, 2026
Merged

Port upstream v0.2.1: commands, UI elicitation, COPILOT_CLI_PATH#70
krukow merged 10 commits intomainfrom
upstream-sync/v0.2.1

Conversation

@krukow
Copy link
Copy Markdown
Collaborator

@krukow krukow commented Mar 26, 2026

Summary

Port upstream copilot-sdk changes from v0.2.0 → v0.2.1-preview.1 (PR #906 and related).

Changes

Commands Support

  • New :commands option in session config for registering slash commands
  • Each command definition: {:name "deploy" :description "Deploy" :command-handler (fn [ctx] ...)}
  • Commands sent on wire (name + description only), handlers stored locally
  • command.execute broadcast event routing with handlePendingCommand RPC callback
  • Error handling for unknown commands and handler exceptions

UI Elicitation Convenience API

  • capabilities — accessor for host capabilities from session create/resume response
  • elicitation-supported? — predicate checking {:ui {:elicitation true}}
  • confirm! — boolean confirmation dialog
  • select! — selection from options, returns string or nil
  • input! — text input with options, returns string or nil
  • ui-elicitation! promoted from experimental, now asserts elicitation support

Other

  • COPILOT_CLI_PATH env var — fallback for CLI path resolution when no explicit :cli-path or :cli-url
  • session.custom_agents_updated event type added
  • Version bump to 0.2.1.0

Files Changed (11 files, +668/-24)

  • specs.clj — command, capabilities, elicitation specs
  • session.clj — command handling, elicitation convenience API
  • client.clj — wire format, capabilities, event routing, CLI path env var
  • copilot_sdk.clj — public API delegates, event type sets
  • instrument.clj — fdefs for 6 new functions
  • integration_test.clj — 8 new tests
  • mock_server.clj — handlePendingCommand support, hook response merging
  • API.md — Commands section, UI Elicitation section, updated tables
  • CHANGELOG.md — v0.2.1 sync entries
  • build.clj / README.md — version bump

Testing

  • ✅ 106 tests, 361 assertions (including E2E), 0 failures
  • ✅ Documentation valid, 0 warnings
  • ✅ All examples pass
  • ✅ JAR builds successfully

Add commands support, UI elicitation convenience API, COPILOT_CLI_PATH
env var fallback, and session.custom_agents_updated event type.

## Commands
- :commands option in session config for slash commands
- command.execute event routing via handlePendingCommand RPC
- Integration tests for wire format, routing, errors

## UI Elicitation
- capabilities accessor from session create/resume response
- elicitation-supported? predicate
- ui-elicitation! promoted from experimental, now asserts support

## Other
- COPILOT_CLI_PATH env var fallback for CLI path resolution
- session.custom_agents_updated event type
- Version bump to 0.2.1.0

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 26, 2026 08:04
@krukow krukow marked this pull request as ready for review March 26, 2026 08:04
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Ports upstream copilot-sdk changes from v0.2.0v0.2.1-preview.1 into the Clojure SDK, adding new session features (commands, UI elicitation helpers) and a CLI path resolution fallback.

Changes:

  • Add per-session slash command registration (:commands) and route command.execute v3 broadcast events to local handlers with handlePendingCommand RPC responses.
  • Add UI elicitation convenience APIs (capabilities, elicitation-supported?, confirm!, select!, input!) and promote ui-elicitation! to non-experimental with support assertions.
  • Add COPILOT_CLI_PATH environment-variable fallback for resolving the CLI executable when :cli-path/:cli-url aren’t explicitly provided, plus version/docs/changelog updates.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
test/github/copilot_sdk/mock_server.clj Adds mock support for session.commands.handlePendingCommand and allows request hooks to merge response data.
test/github/copilot_sdk/integration_test.clj Adds integration coverage for commands-on-wire, v3 command execution routing/errors, and capabilities/elicitation guards.
src/github/copilot_sdk/specs.clj Introduces new specs for commands, capabilities, and elicitation/input options; expands session config keys; adds new event type.
src/github/copilot_sdk/session.clj Stores command handlers + capabilities in session state; implements v3 command execution handler and UI elicitation helpers.
src/github/copilot_sdk/instrument.clj Adds fdefs/instrumentation entries for new public session APIs and tightens ui-elicitation! arg spec.
src/github/copilot_sdk/client.clj Adds COPILOT_CLI_PATH fallback, wires :commands onto create/resume params, and routes v3 command.execute broadcast events.
src/github/copilot_sdk.clj Exposes new UI elicitation functions from the public facade and adds session.custom_agents_updated to event sets.
doc/reference/API.md Documents commands and UI elicitation APIs; updates client option docs for COPILOT_CLI_PATH fallback; adds new event type.
build.clj Bumps library version to 0.2.1.0.
README.md Updates dependency version to 0.2.1.0.
CHANGELOG.md Adds v0.2.1 sync notes under [Unreleased].
Comments suppressed due to low confidence (2)

test/github/copilot_sdk/integration_test.clj:1320

  • Same issue here: (.await rpc-latch ...) return value isn’t asserted. If the latch times out, the test may still pass depending on later assertions; assert the boolean result so the test fails fast on timeout.
      (.await rpc-latch 5 java.util.concurrent.TimeUnit/SECONDS)
      (let [cmd-rpcs (filter #(= "session.commands.handlePendingCommand" (:method %)) @requests)]
        (is (= 1 (count cmd-rpcs)))

test/github/copilot_sdk/integration_test.clj:1290

  • Same issue here: (.await rpc-latch ...) return value isn’t asserted, so a timeout won’t necessarily fail the test. Assert the return value to make the test reliably catch missing/late RPCs.
      (.await rpc-latch 5 java.util.concurrent.TimeUnit/SECONDS)
      (let [cmd-rpcs (filter #(= "session.commands.handlePendingCommand" (:method %)) @requests)]
        (is (= 1 (count cmd-rpcs)))

Comment thread src/github/copilot_sdk.clj Outdated
Comment thread src/github/copilot_sdk/specs.clj Outdated
Comment thread src/github/copilot_sdk/specs.clj Outdated
Comment thread test/github/copilot_sdk/integration_test.clj Outdated
Comment thread src/github/copilot_sdk/instrument.clj
Comment thread src/github/copilot_sdk/specs.clj Outdated
Comment thread src/github/copilot_sdk/client.clj
Comment thread doc/reference/API.md
- Fix input! to multi-arity [session message] / [session message opts]
  instead of varargs, fixing delegate forwarding (review #2993144101)
- Add non-blank validation to ::command-definition via s/and predicate
  (review #2993144151)
- Fix ::elicitation-content to use keyword keys matching wire->clj output
  (review #2993144169)
- Fix ::elicitation-action to use strings matching wire format
  (review #2993144218)
- Fix ::elicitation-result to use ::action/::content key names
  (review #2993144218)
- Assert .await return value in 3 command integration tests
  (review #2993144181)
- Fix effective-env to merge system env with :env overrides
  (review #2993144245)
- Fix API.md elicitation action values to use strings not keywords
  (review #2993144257)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.

Comments suppressed due to low confidence (1)

src/github/copilot_sdk/client.clj:1292

  • Same as above: wire-commands for resume currently emits :description nil for commands without descriptions, which will serialize to null. Prefer omitting :description when absent to keep wire payloads consistent with other optional fields and reduce risk of protocol validation differences.
        wire-commands (when-let [cmds (:commands config)]
                        (mapv (fn [c] {:name (:name c)
                                       :description (:description c)})
                              cmds))]

Comment thread src/github/copilot_sdk/specs.clj Outdated
Comment thread doc/reference/API.md Outdated
Comment thread src/github/copilot_sdk/client.clj Outdated
- Fix ::session-capabilities spec to use ::ui key matching wire shape
- Fix input! docs to show opts map instead of keyword args
- Omit :description from wire-commands when nil (both create and resume)
- Update test assertion for command without description

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.

Comment thread doc/reference/API.md Outdated
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.

Comment thread test/github/copilot_sdk/integration_test.clj
Comment thread test/github/copilot_sdk/mock_server.clj Outdated
Comment thread src/github/copilot_sdk/session.clj Outdated
- Make mock server response merge opt-in via ::merge-response sentinel
  key, preventing accidental mutation from spy hooks
- Remove dead register-commands! function (command handlers already
  indexed in create-session)
- Update capabilities test to use ::mock/merge-response

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.

Comment thread src/github/copilot_sdk/session.clj
Comment thread test/github/copilot_sdk/mock_server.clj Outdated
Comment thread test/github/copilot_sdk/mock_server.clj Outdated
- Fix mock server hook comment to match opt-in merge behavior
- Add guard against non-map ::merge-response values with clear error

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.

Comment thread src/github/copilot_sdk/specs.clj
Comment thread src/github/copilot_sdk/specs.clj
- Add (s/def ::message ::non-blank-string) for elicitation params
- Add (s/def ::default string?) for input options
- Remove duplicate ::requested-schema definition

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.

Comment thread src/github/copilot_sdk/session.clj
Prevents indefinite blocking when a command handler returns a
slow/stuck core.async channel. Reuses tool-timeout-ms (default 120s).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.

Comment thread src/github/copilot_sdk/client.clj
Comment thread src/github/copilot_sdk/client.clj Outdated
- Guard handle-v3-command-execute! on both request-id and command-name
- Include :session-id in all handlePendingCommand RPC payloads for
  consistency with permission/tool v3 handlers

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.

Comment thread src/github/copilot_sdk/client.clj
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.

Comment thread doc/reference/API.md
Port upstream PR #900 change: session.handoff event data now
includes optional :host and :remote-session-id fields. Adds
::session.handoff-data and ::remote-session-id specs. Updates
API.md event table with data shape documentation.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@krukow krukow merged commit 7a30402 into main Mar 26, 2026
1 check passed
@krukow krukow deleted the upstream-sync/v0.2.1 branch March 26, 2026 12:15
github-actions Bot pushed a commit that referenced this pull request Mar 26, 2026
Document the new commands and UI elicitation capabilities from v0.2.1 (PR #70)
in the README key features list.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants