Skip to content

Commit f57db27

Browse files
authored
Merge pull request #37 from copilot-community-sdk/upstream-sync/2026-03-02-bbca1053a6e0e066
[upstream-sync] Port upstream CLI 0.0.420 protocol changes (copilot-sdk PR #605)
2 parents 3cbf9e4 + fd7ba76 commit f57db27

5 files changed

Lines changed: 53 additions & 6 deletions

File tree

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. This change
33

44
## [Unreleased]
55

6+
### Added (upstream PR #605 sync)
7+
- `:copilot/subagent.deselected` event type added to `::event-type` spec, `event-types` var, and API reference table (upstream PR #605 / CLI 0.0.420).
8+
- `:github-reference` attachment type: represents a GitHub issue, PR, or discussion attached to a user message. Added to `::attachment-type` spec and `::attachment` spec. Data fields: `number`, `title`, `reference-type` (`"issue"/"pr"/"discussion"`), `state`, `url` (upstream PR #605).
9+
- `::assistant.turn_start-data` spec with `turn-id` (required) and `interaction-id` (optional).
10+
- `:interaction-id` optional field added to `::user.message-data`, `::assistant.turn_start-data`, `::assistant.message_delta-data`, and `::tool.execution_complete-data` specs (upstream PR #605).
11+
- `:model` optional field added to `::tool.execution_complete-data` spec — model used for the tool execution (upstream PR #605).
12+
- `:plugin-name` and `:plugin-version` optional fields added to `::skill.invoked-data` spec (upstream PR #605).
13+
614
### Added (documentation)
715
- Azure Managed Identity BYOK guide (`doc/auth/azure-managed-identity.md`): shows how to use `DefaultAzureCredential` with short-lived bearer tokens for Azure AI Foundry, with Clojure examples for basic usage and token refresh (upstream PR #498).
816
- Updated BYOK limitations to link to the Managed Identity workaround instead of listing it as fully unsupported.

doc/reference/API.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,7 @@ Send a message to the session. Returns immediately with the message ID.
594594
| `:file` | `:type`, `:path` | `:display-name`, `:line-range` | File attachment |
595595
| `:directory` | `:type`, `:path` | `:display-name`, `:line-range` | Directory attachment |
596596
| `:selection` | `:type`, `:file-path`, `:display-name` | `:selection-range`, `:text` | Code selection attachment |
597+
| `:github-reference` | `:type`, `:number`, `:title`, `:reference-type`, `:state`, `:url` || GitHub issue, PR, or discussion reference |
597598

598599
`:line-range` is a map with `:start` and `:end` line numbers (zero-based) to restrict the attachment to a range of lines:
599600

@@ -887,6 +888,7 @@ copilot/tool-events
887888
| `:copilot/subagent.completed` | Subagent completed |
888889
| `:copilot/subagent.failed` | Subagent failed |
889890
| `:copilot/subagent.selected` | Subagent selected |
891+
| `:copilot/subagent.deselected` | Subagent deselected |
890892
| `:copilot/hook.start` | Hook invocation started |
891893
| `:copilot/hook.end` | Hook invocation finished |
892894
| `:copilot/system.message` | System message emitted |

src/github/copilot_sdk.clj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
:copilot/subagent.completed
7373
:copilot/subagent.failed
7474
:copilot/subagent.selected
75+
:copilot/subagent.deselected
7576
:copilot/skill.invoked
7677
:copilot/hook.start
7778
:copilot/hook.end

src/github/copilot_sdk/specs.clj

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@
240240
;; -----------------------------------------------------------------------------
241241

242242
(s/def ::prompt ::non-blank-string)
243-
(s/def ::attachment-type #{:file :directory :selection})
243+
(s/def ::attachment-type #{:file :directory :selection :github-reference})
244244
(s/def ::type ::attachment-type)
245245
(s/def ::path ::non-blank-string)
246246
(s/def ::file-path ::non-blank-string)
@@ -274,9 +274,26 @@
274274
:opt-un [::selection-range ::text])
275275
#(= :selection (:type %))))
276276

277+
;; GitHub reference attachment (issue, PR, or discussion)
278+
;; Note: ::state is already defined as (instance? Atom) for the client record,
279+
;; so we cannot use s/keys here — manual predicates validate the :state field instead.
280+
(s/def ::number nat-int?)
281+
(s/def ::reference-type #{"issue" "pr" "discussion"})
282+
(s/def ::url string?)
283+
(s/def ::attachment-state string?)
284+
(s/def ::github-reference-attachment
285+
(s/and map?
286+
#(= :github-reference (:type %))
287+
#(nat-int? (:number %))
288+
#(string? (:title %))
289+
#(contains? #{"issue" "pr" "discussion"} (:reference-type %))
290+
#(string? (:state %))
291+
#(string? (:url %))))
292+
277293
(s/def ::attachment
278294
(s/or :file-or-directory ::file-or-directory-attachment
279-
:selection ::selection-attachment))
295+
:selection ::selection-attachment
296+
:github-reference ::github-reference-attachment))
280297

281298
(s/def ::attachments (s/coll-of ::attachment))
282299
(s/def ::mode #{:enqueue :immediate})
@@ -365,6 +382,7 @@
365382
:copilot/tool.user_requested :copilot/tool.execution_start :copilot/tool.execution_partial_result
366383
:copilot/tool.execution_progress :copilot/tool.execution_complete
367384
:copilot/subagent.started :copilot/subagent.completed :copilot/subagent.failed :copilot/subagent.selected
385+
:copilot/subagent.deselected
368386
:copilot/skill.invoked
369387
:copilot/hook.start :copilot/hook.end
370388
:copilot/system.message})
@@ -381,20 +399,26 @@
381399
(s/def ::session.idle-data map?)
382400

383401
(s/def ::agent-mode #{:interactive :plan :autopilot :shell})
402+
(s/def ::interaction-id string?)
384403

385404
(s/def ::user.message-data
386405
(s/keys :req-un [::content]
387-
:opt-un [::transformed-content ::attachments ::source ::agent-mode]))
406+
:opt-un [::transformed-content ::attachments ::source ::agent-mode ::interaction-id]))
388407

389408
(s/def ::assistant.message-data
390409
(s/keys :req-un [::message-id ::content]
391410
:opt-un [::tool-requests ::parent-tool-call-id]))
392411

393412
(s/def ::total-response-size-bytes nat-int?)
413+
(s/def ::turn-id ::non-blank-string)
414+
415+
(s/def ::assistant.turn_start-data
416+
(s/keys :req-un [::turn-id]
417+
:opt-un [::interaction-id]))
394418

395419
(s/def ::assistant.message_delta-data
396420
(s/keys :req-un [::message-id ::delta-content]
397-
:opt-un [::parent-tool-call-id]))
421+
:opt-un [::parent-tool-call-id ::interaction-id]))
398422

399423
(s/def ::assistant.streaming_delta-data
400424
(s/keys :req-un [::total-response-size-bytes]))
@@ -410,7 +434,8 @@
410434

411435
(s/def ::tool.execution_complete-data
412436
(s/keys :req-un [::tool-call-id ::success?]
413-
:opt-un [::is-user-requested? ::result ::error ::tool-telemetry ::parent-tool-call-id]))
437+
:opt-un [::is-user-requested? ::result ::error ::tool-telemetry ::parent-tool-call-id
438+
::model ::interaction-id]))
414439

415440
;; Session shutdown event
416441
(s/def ::shutdown-type #{"routine" "error"})
@@ -465,10 +490,12 @@
465490

466491
;; Skill invoked event
467492
(s/def ::allowed-tools (s/coll-of string?))
493+
(s/def ::plugin-name string?)
494+
(s/def ::plugin-version string?)
468495

469496
(s/def ::skill.invoked-data
470497
(s/keys :req-un [::name ::path ::content]
471-
:opt-un [::allowed-tools]))
498+
:opt-un [::allowed-tools ::plugin-name ::plugin-version]))
472499

473500
;; Generic session event
474501
(s/def ::session-event
@@ -641,4 +668,5 @@
641668
;; Session model operations (session.model.getCurrent / switchTo)
642669
;; -----------------------------------------------------------------------------
643670

671+
(s/def ::model string?)
644672
(s/def ::model-id (s/nilable string?))

src/github/copilot_sdk/util.clj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,14 @@
9797
(:selection-range att) (assoc :selection (clj->wire (:selection-range att)))
9898
(:text att) (assoc :text (:text att)))
9999

100+
:github-reference
101+
{:type "github_reference"
102+
:number (:number att)
103+
:title (:title att)
104+
:referenceType (name (:reference-type att))
105+
:state (:state att)
106+
:url (:url att)}
107+
100108
;; :file and :directory
101109
(cond-> {:type (name (:type att))
102110
:path (:path att)}

0 commit comments

Comments
 (0)