Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@ All notable changes to this project will be documented in this file. This change

## [Unreleased]

### Added (v0.2.2 sync)
- **`enableConfigDiscovery` session option** — new boolean `:enable-config-discovery` on session and resume configs. Auto-discovers `.mcp.json`, `.vscode/mcp.json`, skills, etc. Instruction files are always loaded regardless. (upstream PR #1044)
- **`modelCapabilities` override** — new `:model-capabilities` option on session config, resume config, and `switch-model!`/`set-model!`. Pass a partial capabilities map (e.g. `{:model-supports {:supports-vision true}}`) to override model capabilities for the session. (upstream PR #1029)
- **`history-truncate!`** — new experimental function to trigger manual truncation of session context (upstream PR #1039)
- **`sessions-fork!`** — new experimental function to fork the current session (upstream PR #1039)
- Integration tests for all new features (wire param verification, RPC routing)

### Changed (v0.2.2 sync)
- **`compaction-compact!` RPC renamed** — underlying JSON-RPC method changed from `session.compaction.compact` to `session.history.compact` (upstream PR #1039). The Clojure function name is unchanged for backward compatibility.

## [0.2.1.1] - 2026-04-04
### Added
- **Session RPC wrappers** — new experimental functions for session-level RPCs previously only accessible via `proto/send-request!`:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Add to your `deps.edn`:

```clojure
;; From Maven Central
io.github.copilot-community-sdk/copilot-sdk-clojure {:mvn/version "0.2.1.1"}
io.github.copilot-community-sdk/copilot-sdk-clojure {:mvn/version "0.2.2.0"}

;; Or git dependency
io.github.copilot-community-sdk/copilot-sdk-clojure {:git/url "https://github.com/copilot-community-sdk/copilot-sdk-clojure.git"
Expand Down
2 changes: 1 addition & 1 deletion build.clj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
(:import [java.io File]))

(def lib 'io.github.copilot-community-sdk/copilot-sdk-clojure)
(def version "0.2.1.1")
(def version "0.2.2.0")
(def class-dir "target/classes")

(defn- try-sh
Expand Down
14 changes: 13 additions & 1 deletion doc/reference/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,8 @@ Create a client and session together, ensuring both are cleaned up on exit.
| `:on-event` | fn | Event handler (1-arg fn receiving event maps). Registered before the RPC call, guaranteeing early events like `session.start` are not missed. |
| `:on-elicitation-request` | fn | Handler for elicitation requests from the agent. When provided, advertises `requestElicitation=true` and handles `elicitation.requested` broadcast events. Single-arg handler receives an `ElicitationContext` map with `:session-id`, `:message`, `:requested-schema`, `:mode`, `:elicitation-source`, `:url`. Returns an `ElicitationResult` map `{:action "accept"/"decline"/"cancel" :content {...}}`. See [Elicitation Provider](#elicitation-provider) |
| `:create-session-fs-handler` | fn | Factory for session filesystem handlers. Required when `:session-fs` is set on the client. Called as `(factory session)`, returns a map of FS handler functions. See [Session Filesystem](#session-filesystem) |
| `:enable-config-discovery` | boolean | Auto-discover `.mcp.json`, `.vscode/mcp.json`, skills, etc. Instruction files always load regardless. (upstream PR #1044) |
| `:model-capabilities` | map | Model capabilities override. DeepPartial of model capabilities, e.g. `{:model-supports {:supports-vision true}}`. (upstream PR #1029) |

#### `resume-session`

Expand Down Expand Up @@ -846,10 +848,18 @@ Get the current model for this session. Returns the model ID string, or nil if n
```clojure
(copilot/switch-model! session "claude-sonnet-4.5")
;; => "claude-sonnet-4.5"

;; With model capabilities override (upstream PR #1029):
(copilot/switch-model! session "gpt-5.4"
{:model-capabilities {:model-supports {:supports-vision true}}})
```

Switch the model for this session mid-conversation. Returns the new model ID string, or nil.

Optional opts map:
- `:reasoning-effort` — Reasoning effort level ("low", "medium", "high", "xhigh")
- `:model-capabilities` — Model capabilities override map, e.g. `{:model-supports {:supports-vision true}}`

#### `set-model!`

```clojure
Expand Down Expand Up @@ -1051,7 +1061,9 @@ Get the client that owns this session.
| Function | Description |
|----------|-------------|
| `session/plugins-list` | List plugins. |
| `session/compaction-compact!` | Trigger manual context compaction. |
| `session/compaction-compact!` | Trigger manual context compaction (uses `session.history.compact` RPC). |
| `session/history-truncate!` | Trigger manual context truncation. |
| `session/sessions-fork!` | Fork the current session. |
| `session/shell-exec!` | Execute a shell command. |
| `session/shell-kill!` | Kill a running shell process. |

Expand Down
15 changes: 15 additions & 0 deletions src/github/copilot_sdk/client.clj
Original file line number Diff line number Diff line change
Expand Up @@ -1380,6 +1380,10 @@
true (assoc :request-user-input (boolean (:on-user-input-request config)))
true (assoc :request-elicitation (boolean (:on-elicitation-request config)))
true (assoc :hooks (boolean (:hooks config)))
(some? (:enable-config-discovery config))
(assoc :enable-config-discovery (:enable-config-discovery config))
(:model-capabilities config)
(assoc :model-capabilities (util/clj->wire (:model-capabilities config)))
true (assoc :env-value-mode "direct"))))

(defn- build-resume-session-params
Expand Down Expand Up @@ -1437,6 +1441,10 @@
true (assoc :hooks (boolean (:hooks config)))
(:working-directory config) (assoc :working-directory (:working-directory config))
(:disable-resume? config) (assoc :disable-resume (:disable-resume? config))
(some? (:enable-config-discovery config))
(assoc :enable-config-discovery (:enable-config-discovery config))
(:model-capabilities config)
(assoc :model-capabilities (util/clj->wire (:model-capabilities config)))
true (assoc :env-value-mode "direct"))))

(defn- pre-register-session
Expand Down Expand Up @@ -1493,6 +1501,11 @@
:on-session-start, :on-session-end, :on-error-occurred}
- :on-event - Event handler (1-arg fn) registered before the RPC call.
Guarantees early events like session.start are not missed.
- :enable-config-discovery - Boolean. Auto-discover .mcp.json, .vscode/mcp.json, skills, etc.
Instruction files are always loaded regardless. (upstream PR #1044)
- :model-capabilities - Model capabilities override map (upstream PR #1029).
DeepPartial of model capabilities, e.g.
{:model-supports {:supports-vision true}}

Returns a CopilotSession."
[client config]
Expand Down Expand Up @@ -1553,6 +1566,8 @@
- :hooks - Lifecycle hooks map
- :on-event - Event handler (1-arg fn) registered before the RPC call.
Guarantees early events like session.start are not missed.
- :enable-config-discovery - Boolean. Auto-discover .mcp.json, skills, etc. (upstream PR #1044)
- :model-capabilities - Model capabilities override map (upstream PR #1029).

Returns a CopilotSession."
[client session-id config]
Expand Down
12 changes: 12 additions & 0 deletions src/github/copilot_sdk/instrument.clj
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,14 @@
:args (s/cat :session ::specs/session)
:ret map?)

(s/fdef github.copilot-sdk.session/history-truncate!
:args (s/cat :session ::specs/session)
:ret map?)

(s/fdef github.copilot-sdk.session/sessions-fork!
:args (s/cat :session ::specs/session)
:ret map?)
Comment on lines +299 to +305

(s/fdef github.copilot-sdk.session/shell-exec!
:args (s/cat :session ::specs/session :command string?)
:ret map?)
Expand Down Expand Up @@ -490,6 +498,8 @@
github.copilot-sdk.session/extensions-reload!
github.copilot-sdk.session/plugins-list
github.copilot-sdk.session/compaction-compact!
github.copilot-sdk.session/history-truncate!
github.copilot-sdk.session/sessions-fork!
github.copilot-sdk.session/shell-exec!
github.copilot-sdk.session/shell-kill!
github.copilot-sdk.session/mode-get
Expand Down Expand Up @@ -582,6 +592,8 @@
github.copilot-sdk.session/extensions-reload!
github.copilot-sdk.session/plugins-list
github.copilot-sdk.session/compaction-compact!
github.copilot-sdk.session/history-truncate!
github.copilot-sdk.session/sessions-fork!
github.copilot-sdk.session/shell-exec!
github.copilot-sdk.session/shell-kill!
github.copilot-sdk.session/mode-get
Expand Down
32 changes: 27 additions & 5 deletions src/github/copilot_sdk/session.clj
Original file line number Diff line number Diff line change
Expand Up @@ -944,7 +944,9 @@
The new model takes effect for the next message. Conversation history is preserved.

Optional opts map:
- :reasoning-effort - Reasoning effort level for the new model (\"low\", \"medium\", \"high\", \"xhigh\")
- :reasoning-effort - Reasoning effort level for the new model (\"low\", \"medium\", \"high\", \"xhigh\")
- :model-capabilities - Model capabilities override map (upstream PR #1029)
e.g. {:model-supports {:supports-vision true}}

Returns the new model ID string, or nil."
([session model-id] (switch-model! session model-id nil))
Expand All @@ -953,7 +955,9 @@
conn (connection-io client)
params (cond-> {:sessionId session-id
:modelId model-id}
(:reasoning-effort opts) (assoc :reasoningEffort (:reasoning-effort opts)))
(:reasoning-effort opts) (assoc :reasoningEffort (:reasoning-effort opts))
(:model-capabilities opts) (assoc :modelCapabilities
(util/clj->wire (:model-capabilities opts))))
result (proto/send-request! conn "session.model.switchTo" params)]
(:model-id result))))

Expand Down Expand Up @@ -1100,15 +1104,33 @@
(util/wire->clj
(proto/send-request! conn "session.plugins.list" {:sessionId session-id}))))

;; -- Compaction --------------------------------------------------------------
;; -- History (compaction / truncation) ----------------------------------------

(defn ^:experimental compaction-compact!
"Trigger manual compaction of the session context."
"Trigger manual compaction of the session context.
Note: renamed from session.compaction.compact to session.history.compact in upstream #1039."
[session]
(let [{:keys [session-id client]} session
conn (connection-io client)]
(util/wire->clj
(proto/send-request! conn "session.compaction.compact" {:sessionId session-id}))))
(proto/send-request! conn "session.history.compact" {:sessionId session-id}))))

(defn ^:experimental history-truncate!
"Trigger manual truncation of the session context (upstream #1039)."
[session]
(let [{:keys [session-id client]} session
conn (connection-io client)]
(util/wire->clj
(proto/send-request! conn "session.history.truncate" {:sessionId session-id}))))

(defn ^:experimental sessions-fork!
"Fork the current session (upstream #1039).
This is a server-scoped RPC."
[session]
(let [{:keys [session-id client]} session
conn (connection-io client)]
(util/wire->clj
(proto/send-request! conn "sessions.fork" {:sessionId session-id}))))

;; -- Shell -------------------------------------------------------------------

Expand Down
20 changes: 15 additions & 5 deletions src/github/copilot_sdk/specs.clj
Original file line number Diff line number Diff line change
Expand Up @@ -352,14 +352,21 @@

(s/def ::client-name ::non-blank-string)

;; enableConfigDiscovery: auto-discover MCP configs, skills, instruction files (upstream PR #1044)
(s/def ::enable-config-discovery boolean?)

;; modelCapabilities override for session config / setModel (upstream PR #1029).
;; DeepPartial<ModelCapabilities> — same shape as ::model-capabilities since all fields are already optional.

(def session-config-keys
#{:session-id :client-name :model :tools :commands :system-message
:available-tools :excluded-tools :provider
:on-permission-request :streaming? :mcp-servers
:custom-agents :config-dir :skill-directories
:disabled-skills :large-output :infinite-sessions
:reasoning-effort :on-user-input-request :on-elicitation-request :hooks
:working-directory :agent :on-event :create-session-fs-handler})
:working-directory :agent :on-event :create-session-fs-handler
:enable-config-discovery :model-capabilities})

(s/def ::session-config
(closed-keys
Expand All @@ -370,7 +377,8 @@
::custom-agents ::config-dir ::skill-directories
::disabled-skills ::large-output ::infinite-sessions
::reasoning-effort ::on-user-input-request ::on-elicitation-request ::hooks
::working-directory ::agent ::on-event ::create-session-fs-handler])
::working-directory ::agent ::on-event ::create-session-fs-handler
::enable-config-discovery ::model-capabilities])
session-config-keys))

(def ^:private resume-session-config-keys
Expand All @@ -379,7 +387,7 @@
:mcp-servers :custom-agents :config-dir :skill-directories
:disabled-skills :infinite-sessions :reasoning-effort
:on-user-input-request :on-elicitation-request :hooks :working-directory :disable-resume? :agent :on-event
:create-session-fs-handler})
:create-session-fs-handler :enable-config-discovery :model-capabilities})

(s/def ::resume-session-config
(closed-keys
Expand All @@ -389,7 +397,8 @@
::mcp-servers ::custom-agents ::config-dir ::skill-directories
::disabled-skills ::infinite-sessions ::reasoning-effort
::on-user-input-request ::on-elicitation-request ::hooks ::working-directory ::disable-resume? ::agent
::on-event ::create-session-fs-handler])
::on-event ::create-session-fs-handler
::enable-config-discovery ::model-capabilities])
resume-session-config-keys))

;; join-session config: same as resume-session-config but :on-permission-request is optional.
Expand All @@ -402,7 +411,8 @@
::mcp-servers ::custom-agents ::config-dir ::skill-directories
::disabled-skills ::infinite-sessions ::reasoning-effort
::on-user-input-request ::on-elicitation-request ::hooks ::working-directory ::disable-resume? ::agent
::on-event ::create-session-fs-handler])
::on-event ::create-session-fs-handler
::enable-config-discovery ::model-capabilities])
resume-session-config-keys))

;; -----------------------------------------------------------------------------
Expand Down
Loading
Loading