diff --git a/CHANGELOG.md b/CHANGELOG.md index 4696e3d4..8ea2cd33 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,9 @@ All notable changes to this project will be documented in this file. This change ## [Unreleased] ### Added (v0.2.1 sync) +- **`onElicitationRequest` handler** — new `:on-elicitation-request` option in session config (both `create-session` and `resume-session`). When provided, the session registers as an elicitation provider: the `requestElicitation` capability is advertised on the wire, and incoming `elicitation.requested` broadcast events are dispatched to the handler. The handler receives a request map `{:message :requested-schema :mode :elicitation-source :url}` and an invocation map `{:session-id}`, and must return a result map `{:action "accept"|"decline"|"cancel" :content {..}}`. On handler failure, a cancel response is automatically sent to avoid hanging requests (upstream PR #908). +- **`capabilities.changed` event handling** — sessions now automatically merge incoming `capabilities.changed` broadcast events into their stored capabilities, so `(capabilities session)` reflects the latest state as providers join/leave (upstream PR #908). +- **New event types**: `capabilities.changed`, `sampling.requested`, `sampling.completed`, `session.remote_steerable_changed` added to the event type enum (upstream PR #908). - **`steerable` field on `session.start` events** — `session.start` event data now includes optional `:steerable?` boolean field indicating whether the session supports remote steering via Mission Control. New `::steerable?` spec added (upstream PR #927). - **`get-session-metadata`** — new function on client for efficient O(1) session lookup by ID. Returns session metadata map if found, or `nil` if not found. Sends `session.getMetadata` JSON-RPC call. Shared `wire->session-metadata` helper extracted from `list-sessions` to eliminate duplication (upstream PR #899). diff --git a/src/github/copilot_sdk/client.clj b/src/github/copilot_sdk/client.clj index ba2a4e28..dcc9842e 100644 --- a/src/github/copilot_sdk/client.clj +++ b/src/github/copilot_sdk/client.clj @@ -351,7 +351,53 @@ :error (ex-message e)})))) (catch Exception _ nil)))))))) -(defn- handle-v3-broadcast-event! +(defn- handle-v3-elicitation-requested! + "Handle v3 elicitation.requested broadcast event. + Calls the session's elicitation handler and responds via the + session.ui.handlePendingElicitation RPC method. + On handler failure, sends a cancel response so the request doesn't hang." + [client session-id event] + (let [data (:data event) + request-id (:request-id data) + request (select-keys data [:message :requested-schema :mode :elicitation-source :url])] + (when request-id + (go + (try + (let [elicit-response (