Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .copilot-schema-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.48
1.0.49-1
53 changes: 53 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,65 @@ All notable changes to this project will be documented in this file. This change
## [Unreleased]

### Added (post-v1.0.0-beta.4 sync)
- **`:session-id` on hook input maps** — `:on-hook-invoke` handlers now receive
a `:session-id` key on the input map. When the upstream wire payload includes
a `sessionId` (sub-agent hooks), the wire-provided value is preserved;
otherwise the SDK fills in the parent session id as a convenience.
(upstream PR #1290)
- **`:cloud` session config option (create only)** — `create-session` accepts
an optional `:cloud` map for creating a remote cloud session. Shape:
`{:repository {:owner "octocat" :name "hello-world" :branch "main"}}` — `:owner`
and `:name` are required non-blank strings; `:branch` is optional. Forwarded on
the wire as `cloud.repository.*`. Matches upstream's `CloudSessionOptions` /
`CloudSessionRepository`. Not accepted on `resume-session` / `join-session`,
matching upstream `ResumeSessionConfig` (Pick excludes `cloud`).
(upstream PR #1306)
- **Optional permission and tool callbacks (manual pending RPCs)** — Following
upstream PR #1308, `:on-permission-request` is now **optional** on
`create-session` and `resume-session`, and `:handler` is optional on tools
built via `tools/define-tool`. When omitted, the runtime no longer
auto-responds to permission requests or tool calls. Applications can resolve
these requests asynchronously via the new public functions:
- `sdk/handle-pending-tool-call!` / `sdk/<handle-pending-tool-call!`
- `sdk/handle-pending-permission-request!` / `sdk/<handle-pending-permission-request!`

Useful for human-in-the-loop UIs that surface pending tool/permission
requests through `sdk/get-messages` and resolve them later.
**Note:** This is a behavioural change — previously the SDK threw if
`:on-permission-request` was missing; now it's accepted and the request is
treated as pending until the application resolves it. (upstream PR #1308)
- **`:agent-model` on custom-agent configs** — Custom agent maps in
`:custom-agents` now accept an optional `:agent-model` string (e.g.
`"claude-haiku-4.5"`). When set, the runtime attempts to use that model
for the agent, falling back to the parent session model if unavailable.
Forwarded on the wire as `agentModel` on each entry in `customAgents`
for both `session.create` and `session.resume`. (upstream PR #1309)
- **Schema bump** — `.copilot-schema-version` advanced from `1.0.48` to
`1.0.49-1`. Generated wire specs and coercions regenerated; new pass-through
event fields include `:display-prompt`, `:reasoning-summary`,
`:previous-reasoning-summary`. (upstream PRs #1305, #1307)

### Fixed (post-v1.0.0-beta.4 sync, review iteration)
- `::cloud-repository` spec now enforces non-blank `:name` (was just `string?`
via the shared `::name` spec, allowing blanks despite docs).
- `handle-pending-tool-call!` and `<handle-pending-tool-call!` now throw when
neither `:result` nor `:error` is supplied (previously fell through to a
default "tool returned no result" payload).
- `handle-pending-tool-call!` / `<handle-pending-tool-call!` validate that
`:error`, when supplied, is a string.
- All four pending-RPC resolvers (`handle-pending-tool-call!`,
`<handle-pending-tool-call!`, `handle-pending-permission-request!`,
`<handle-pending-permission-request!`) now require `:request-id` to be a
non-blank string.
- `handle-pending-permission-request!` and async variant validate that
`:result :kind` is a keyword in the documented decision set — matches
the upstream `PermissionDecision` schema:
`:approve-once`, `:approve-for-session`, `:approve-for-location`,
`:approve-permanently`, `:reject`, `:user-not-available`. Previously
unsupported values (e.g. `{:kind 42}`) would be sent on the wire and
surface as opaque server-side errors.
- `tools/define-tool-from-spec` mirrors `tools/define-tool`: when `:handler`
is omitted, no `:tool-handler` wrapper is installed (declaration-only tool).

### Notes (v1.0.0-beta.4 sync)
Upstream `v1.0.0-beta.4` shipped no new Node.js SDK API surface relative to
Expand Down
58 changes: 54 additions & 4 deletions doc/reference/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ Create a client and session together, ensuring both are cleaned up on exit.
| `:commands` | vector | Command definitions (slash commands). See [Commands](#commands) |
| `:custom-agents` | vector | Custom agent configs. Each agent map: `:agent-name` (required), `:agent-prompt` (required), `:agent-display-name`, `:agent-description`, `:agent-tools`, `:agent-infer?`, `:agent-skills` (vector of strings), `:agent-model` (string, e.g. `"claude-haiku-4.5"`; when set the runtime tries this model for the agent, falling back to the parent session model — upstream PR #1309), `:mcp-servers` |
| `:default-agent` | map | Built-in/default agent config. Use `{:excluded-tools [...]}` to hide tools from the default agent while leaving them available to custom agents |
| `:on-permission-request` | fn | **Required.** Permission handler function. Use `copilot/approve-all` to approve everything. |
| `:on-permission-request` | fn | Permission handler function. **Optional** (upstream PR #1308). When omitted, permission requests are not auto-resolved; resolve them manually via `handle-pending-permission-request!`. Use `copilot/approve-all` to approve everything. |
| `:streaming?` | boolean | Enable streaming deltas |
| `:config-dir` | string | Override config directory for CLI |
| `:skill-directories` | vector | Additional skill directories to load |
Expand All @@ -266,6 +266,7 @@ Create a client and session together, ensuring both are cleaned up on exit.
| `:model-capabilities` | map | Model capabilities override. DeepPartial of model capabilities, e.g. `{:model-supports {:supports-vision true}}`. (upstream PR #1029) |
| `:include-sub-agent-streaming-events?` | boolean | Forward streaming events from sub-agents to the parent session's event stream. Defaults to `true` on the wire. (upstream PR #1108) |
| `:remote-session` | keyword | Per-session Mission Control mode: `:off`, `:export`, or `:on`. When omitted, the CLI applies its default. `:off` disables remote, `:export` exports session events to Mission Control without enabling remote steering, `:on` enables both. Forwarded as `remoteSession`. (upstream PR #1295, CLI 1.0.48) |
| `:cloud` | map | (create-session only) Creates a remote cloud session. Shape: `{:repository {:owner "octocat" :name "hello-world" :branch "main"}}` — `:owner` and `:name` are required non-blank strings; `:branch` is optional. Forwarded as `cloud.repository.*` on `session.create`. Not accepted on `resume-session` (matches upstream `ResumeSessionConfig`). (upstream PR #1306) |

#### `resume-session`

Expand Down Expand Up @@ -853,6 +854,35 @@ Abort the currently processing message.

Get all events/messages from this session.

#### `handle-pending-tool-call!` / `<handle-pending-tool-call!`

```clojure
(copilot/handle-pending-tool-call! session
{:request-id "tool-req-7"
:result "STATUS_OK"})
;; or async:
(copilot/<handle-pending-tool-call! session {:request-id "tool-req-7"
:error "lookup failed"})
```

Resolve a tool call that was not auto-handled (because `:handler` was omitted
from `define-tool`). The args map accepts `:request-id` plus either `:result`
(string or full result map) or `:error` (string). Sent on the wire as
`session.tools.handlePendingToolCall`. (upstream PR #1308)

#### `handle-pending-permission-request!` / `<handle-pending-permission-request!`

```clojure
(copilot/handle-pending-permission-request! session
{:request-id "perm-req-3"
:result {:kind :approve-once}})
```

Resolve a permission request that was not auto-handled (because
`:on-permission-request` was omitted from the session config). The result map
must contain a `:kind` other than `:no-result`. Sent on the wire as
`session.permissions.handlePendingPermissionRequest`. (upstream PR #1308)

#### `get-current-model`

```clojure
Expand Down Expand Up @@ -1520,6 +1550,23 @@ Let the CLI call back into your process when the model needs capabilities you pr

When Copilot invokes `lookup_issue`, the SDK automatically runs your handler and responds to the CLI.

**Declaration-only tools (manual resolution):**

The `:handler` key is **optional** (upstream PR #1308). When omitted, the SDK does not auto-respond to tool calls — the call surfaces as a `:copilot/external_tool.requested` event with a pending request id, and the application resolves it later via `handle-pending-tool-call!`. Useful for human-in-the-loop UIs or out-of-process tool execution.

```clojure
(def manual-tool
(copilot/define-tool "manual_lookup"
{:description "Look up status manually"
:parameters {:type "object"
:properties {:id {:type "string"}}
:required ["id"]}}))
;; …later, after a human reviews the request:
(copilot/handle-pending-tool-call! session
{:request-id "tool-req-7"
:result "STATUS_OK"})
```

**Overriding built-in tools:**

Set `:overrides-built-in-tool true` to override a built-in tool (e.g., `grep`, `edit_file`). Without this flag, defining a tool whose name clashes with a built-in tool causes an error.
Expand Down Expand Up @@ -1857,9 +1904,12 @@ Sessions emit `:session.compaction_start` and `:session.compaction_complete` eve

The SDK uses a **deny-by-default** permission model. All permission requests
(file writes, shell commands, URL fetches, custom tool execution, etc.) are denied unless your
session config provides an `:on-permission-request` handler (required for
`create-session` and `resume-session`; optional for `join-session` which
defaults to `{:kind :no-result}`).
session config provides an `:on-permission-request` handler. The handler is
optional on `create-session`, `resume-session`, and `join-session` (upstream
PR #1308): when omitted, permission requests are not auto-resolved and
applications must resolve them via `handle-pending-permission-request!`.
`join-session` historically defaulted to `{:kind :no-result}` and continues to
behave that way.

Use `approve-all` to opt into approving everything:

Expand Down
2 changes: 1 addition & 1 deletion schemas/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ These files are fetched verbatim from the `@github/copilot` npm package at the v

**Do not edit by hand.** To update, run `bb schemas:fetch` after bumping `.copilot-schema-version`.

Currently pinned version: `1.0.48`
Currently pinned version: `1.0.49-1`
Loading
Loading