Skip to content

Commit 616d4a0

Browse files
committed
release: sync copilot-sdk-cpp v0.3.0 from private
Re-pins the SDK to the official github/copilot-sdk@7a916f8 surface (@github/copilot@1.0.83-0, wire protocol 3) and adds a schema-driven codegen pipeline so future re-pins are mechanical. Generated surface (tools/generate_protocol_types.py + schemas/official-baseline.json): 1,218 API definitions, 535 event definitions, 367 RPC methods, 133 event variants. Regenerating is deterministic; `--check` guards it via the codegen_check test. New public surface: - factory, canvas and extension APIs - FFI transport (include/copilot/transport_ffi.hpp) - request-handler bridge for llmInference streaming - session.sandbox.getEnforcementStatus, session.factory.runFromTool/resumeFromTool - gitHubToken.getToken via ClientOptions::github_token_provider; the runtime addresses the callback by an opaque registrationId exposed as Client::github_token_registration_id(), for installation as a token-provider AuthInfo. Enforces the schema's expiresIn >= 3601 minimum. Event typing: all 133 generated wire types now resolve to a typed SessionEventType. 52 previously fell through to Unknown with raw JSON -- 11 new in this re-pin, 41 pre-existing. Note this makes SessionEventData a 132-alternative variant, which requires /bigobj on MSVC; it is applied as a PUBLIC compile option so consumers inherit it. Bug fixes: - TcpTransport::connect no longer burns its full timeout on a refused address. getaddrinfo(AF_UNSPEC) commonly returns ::1 before 127.0.0.1, and on Windows a refused non-blocking connect is signalled through select()'s exceptfds, which was passed as nullptr. Now monitors exceptfds and budgets the timeout across the candidate list. - Client::parse_cli_url no longer misreads "127.0.0.1:54321" as port 127. std::stoi stops at the first non-digit, so the bare-port branch matched any host:port whose first octet was a valid port number. Validated: 464/464 tests pass, codegen check green. Authenticated E2E was not run for this pin.
1 parent d7e8267 commit 616d4a0

42 files changed

Lines changed: 50958 additions & 369 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎CMakeLists.txt‎

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
cmake_minimum_required(VERSION 3.20)
2-
project(copilot_sdk_cpp VERSION 0.2.0 LANGUAGES CXX)
2+
project(copilot_sdk_cpp VERSION 0.3.0 LANGUAGES CXX)
33

44
# Enable folder organization in IDEs
55
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
@@ -18,6 +18,23 @@ option(COPILOT_BUILD_EXAMPLES "Build examples" ON)
1818
option(COPILOT_BUILD_SNAPSHOT_TESTS "Build snapshot conformance tests (requires upstream snapshots + Python)" OFF)
1919
option(COPILOT_WITH_FASTMCPP "Build in-process MCP examples with fastmcpp" OFF)
2020

21+
# Protocol code generation
22+
find_package(Python3 COMPONENTS Interpreter QUIET)
23+
if(Python3_Interpreter_FOUND)
24+
add_custom_target(copilot_codegen
25+
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/tools/generate_protocol_types.py
26+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
27+
COMMENT "Regenerating C++ protocol types from the official baseline"
28+
VERBATIM
29+
)
30+
add_custom_target(copilot_codegen_check
31+
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/tools/generate_protocol_types.py --check
32+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
33+
COMMENT "Checking generated C++ protocol types"
34+
VERBATIM
35+
)
36+
endif()
37+
2138
# Find dependencies
2239
find_package(nlohmann_json CONFIG QUIET)
2340

@@ -55,23 +72,39 @@ add_library(copilot_sdk_cpp
5572
include/copilot/copilot.hpp
5673
include/copilot/types.hpp
5774
include/copilot/events.hpp
75+
include/copilot/extension.hpp
76+
include/copilot/factory.hpp
77+
include/copilot/generated/api_types.hpp
78+
include/copilot/generated/compatibility_types.hpp
79+
include/copilot/generated/protocol_version.hpp
80+
include/copilot/generated/schema_coverage.hpp
81+
include/copilot/generated/schema_value.hpp
82+
include/copilot/generated/session_events.hpp
5883
include/copilot/transport.hpp
5984
include/copilot/transport_stdio.hpp
6085
include/copilot/transport_tcp.hpp
86+
include/copilot/transport_ffi.hpp
6187
include/copilot/jsonrpc.hpp
6288
include/copilot/process.hpp
89+
include/copilot/request_handler.hpp
6390
include/copilot/client.hpp
91+
include/copilot/canvas.hpp
6492
include/copilot/session.hpp
6593
include/copilot/rpc_methods.hpp
6694
include/copilot/rpc_types.hpp
6795
# Sources
6896
src/types.cpp
6997
src/events.cpp
98+
src/extension.cpp
99+
src/factory.cpp
70100
src/transport.cpp
101+
src/transport_ffi.cpp
71102
src/jsonrpc.cpp
72103
src/process_win32.cpp
73104
src/process_posix.cpp
105+
src/request_handler.cpp
74106
src/client.cpp
107+
src/canvas.cpp
75108
src/session.cpp
76109
)
77110
add_library(copilot::copilot_sdk_cpp ALIAS copilot_sdk_cpp)
@@ -87,6 +120,8 @@ target_include_directories(copilot_sdk_cpp
87120
target_link_libraries(copilot_sdk_cpp
88121
PUBLIC
89122
nlohmann_json::nlohmann_json
123+
PRIVATE
124+
${CMAKE_DL_LIBS}
90125
)
91126

92127
# Platform-specific settings
@@ -96,6 +131,12 @@ if(WIN32)
96131
target_link_libraries(copilot_sdk_cpp PUBLIC ws2_32)
97132
endif()
98133

134+
if(MSVC)
135+
# SessionEventData is a std::variant with one alternative per event type; instantiating it
136+
# exceeds the default COFF section limit. PUBLIC because consumers instantiate it too.
137+
target_compile_options(copilot_sdk_cpp PUBLIC /bigobj)
138+
endif()
139+
99140
# Set target properties
100141
set_target_properties(copilot_sdk_cpp PROPERTIES
101142
VERSION ${PROJECT_VERSION}

‎README.md‎

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,49 @@ Snapshot conformance tests (optional):
3333
- Enable with `-DCOPILOT_BUILD_SNAPSHOT_TESTS=ON` and set `-DCOPILOT_SDK_CPP_SNAPSHOT_DIR=...` if auto-detection fails.
3434
- Run: `cmake --build build --target run_snapshot_tests --config Release`
3535

36+
## Official protocol baseline and code generation
37+
38+
`schemas/official-baseline.json` pins the official SDK commit, protocol version,
39+
schema hashes, and the complete generated surface: 1,203 API definitions, 494
40+
session-event definitions, 363 RPC methods, and 122 event variants. Generated
41+
wire-preserving types live under `include/copilot/generated/`; the existing
42+
handwritten public API remains the ergonomic layer.
43+
44+
```sh
45+
# Regenerate from the committed baseline
46+
cmake --build build --target copilot_codegen
47+
48+
# Fail if committed generated headers are stale
49+
cmake --build build --target copilot_codegen_check
50+
```
51+
52+
To refresh from a checked-out official SDK and the matching CLI package schemas:
53+
54+
```sh
55+
python tools/generate_protocol_types.py --refresh \
56+
--official-sdk-root ../copilot-sdk \
57+
--api-schema <path-to-api.schema.json> \
58+
--session-events-schema <path-to-session-events.schema.json>
59+
```
60+
61+
## Current public API surface
62+
63+
`ClientOptions` supports SDK modes plus stdio, TCP, URI, and declared in-process
64+
runtime connections. Session create/resume requests expose the current official
65+
configuration fields while preserving the existing handwritten C++ API.
66+
`Session::invoke`/`invoke_typed` provide low-level access, with typed convenience
67+
wrappers for MCP, authentication, agents, skills, tasks, commands, history,
68+
usage, and remote-session operations.
69+
70+
Advanced parity includes:
71+
72+
- `RuntimeConnection::for_in_process()` using the official
73+
`copilot_runtime_*` native ABI (`prebuilds/<platform>/runtime.node`).
74+
- `CopilotRequestHandler` and WebSocket handlers for streamed model-layer I/O.
75+
- Automatic MCP OAuth event handling and pending-request responses.
76+
- `create_canvas`, `define_factory`, `Session::factory()`, and `join_session`
77+
helpers for canvas, factory, and extension consumers.
78+
3679
## Custom Tools
3780

3881
Custom tools are provided when creating or resuming a session. The SDK auto-generates JSON schemas from C++ types.

‎cmake/copilot_sdk_cppConfig.cmake.in‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
@PACKAGE_INIT@
22

3-
include(CMakeFindDependencyMacro)
4-
53
# If the consumer didn't provide nlohmann_json, try to find it. If it still isn't
64
# available, fall back to the vendored headers installed with this package.
75
if(NOT TARGET nlohmann_json::nlohmann_json)
8-
find_dependency(nlohmann_json QUIET)
6+
find_package(nlohmann_json CONFIG QUIET)
97
endif()
108
if(NOT TARGET nlohmann_json::nlohmann_json)
119
add_library(nlohmann_json::nlohmann_json INTERFACE IMPORTED)

‎docs/validation-6e6eb55.md‎

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
# Validation report: official SDK `6e6eb55`
2+
3+
**Date:** 2026-08-24
4+
**Branch:** `sdk-parity/6e6eb55`
5+
**Official source:** `github/copilot-sdk` commit
6+
`6e6eb55f4d0f1ee222cfce3e64493781ef7c5be8`
7+
**Result:** **PASS — current-official parity validated on Windows x64**
8+
9+
## Environment
10+
11+
- Windows x64
12+
- Visual Studio 2022 / MSVC 19.44.35228
13+
- CMake 4.0
14+
- Python 3.13.15
15+
- SDK protocol version 3
16+
- Official schema package baseline `@github/copilot@1.0.81-6`
17+
- `copilot --version`: 1.0.81-8
18+
- Runtime reported by the connection handshake: 1.0.81-9, protocol 3
19+
20+
No credentials, tokens, account names, or other authentication material were
21+
captured in this report.
22+
23+
## Validation results
24+
25+
| Area | Command / evidence | Result |
26+
|---|---|---|
27+
| Fresh configure | `cmake -S . -B build-validation-final -DCOPILOT_BUILD_TESTS=ON -DCOPILOT_BUILD_EXAMPLES=ON` | Pass |
28+
| Fresh Release build | `cmake --build build-validation-final --config Release` | Pass; library, all tests, and all examples compiled |
29+
| Full non-auth suite | `COPILOT_SDK_CPP_SKIP_E2E=1 ctest --test-dir build-validation-final -C Release --output-on-failure` | **494/494 passed**, 71 authenticated E2E tests intentionally skipped |
30+
| Code generation | CMake `copilot_codegen_check` plus direct `generate_protocol_types.py --check --official-sdk-root ...` | Pass: 1,203 API definitions, 494 event definitions, 363 RPC methods, 122 event variants |
31+
| Official-shape goldens | Generated/public/advanced parity test filters | **26/26 passed** |
32+
| FFI architecture loader | `FfiTransportTest.*` using a DLL exporting the official `copilot_runtime_*` ABI | **3/3 passed**, including blocked-read cancellation and missing-library errors |
33+
| Installed CMake package | Install to a clean prefix, configure/build/run an external `find_package(copilot_sdk_cpp CONFIG REQUIRED)` consumer | Pass after fixing the bundled `nlohmann_json` fallback |
34+
| Examples / consumer compilation | Fresh build compiled all repository examples; external consumer compiled generated, canvas, session, and runtime APIs | Pass |
35+
36+
## Authenticated Copilot CLI validation
37+
38+
The complete authenticated matrix was run with a per-test 120-second bound.
39+
The consolidated result was **69 passed, 2 intentionally skipped, 0 failed**
40+
across 71 scenarios. The two skips are the legacy foreground-session tests;
41+
their RPCs are absent from the official `6e6eb55` generated API.
42+
43+
Validated live workflows include startup/shutdown, concurrent RPC, create and
44+
resume, tools and permissions, hooks, user input, elicitation registration,
45+
MCP and custom agents, attachments, streaming, compaction, model discovery,
46+
event parsing, lifecycle, status/auth, caching, and graceful/forced teardown.
47+
48+
The validation run discovered and fixed:
49+
50+
- ISO-8601 ping timestamp compatibility
51+
- fail-open preservation of evolved event payloads
52+
- protocol-v3 external-tool, permission, and user-input event handling
53+
- current `connect`/account status RPC usage
54+
- environment-dependent model selection in E2E tests
55+
- bounded process waits and client shutdown mutex deadlocks
56+
- resumable test cleanup
57+
- caller session-ID pre-registration/remapping
58+
- installed-package fallback when `nlohmann_json` is not separately installed
59+
- stdio reader shutdown after process termination
60+
- handler-enabled session creation with bounded E2E waits
61+
- protocol-v3 handler registration and payload compatibility
62+
63+
### Root-cause resolution
64+
65+
RPC tracing showed that handler-enabled `session.create` calls completed and
66+
returned valid responses. The apparent create hangs occurred during test
67+
cleanup: `JsonRpcClient::stop()` joined its stdio reader while
68+
`PipeTransport::close()` intentionally left the process-owned pipe handles
69+
open. A descendant runtime process could therefore keep `ReadFile` blocked.
70+
71+
The fix adds `Process::close_pipes()` on Windows and POSIX and calls it after
72+
bounded process termination but before joining the JSON-RPC reader. A
73+
time-bounded process regression test and 30-second handler-create E2E bounds
74+
prevent recurrence. Hook, user-input, and elicitation-enabled creation all
75+
pass against the authenticated runtime.
76+
77+
### Intentional skips
78+
79+
1. `ForegroundSessionSetAndGet`
80+
2. `ForegroundSessionInitiallyEmpty`
81+
82+
Both exercise legacy compatibility RPCs that do not exist in the official
83+
`6e6eb55` generated RPC surface.
84+
85+
`tests/byok.env` was not present. This did not block authenticated testing;
86+
the installed Copilot CLI authentication was used instead.
87+
88+
## Static analysis and sanitizers
89+
90+
No static-analysis or sanitizer target is defined by this repository.
91+
`clang-tidy`, `cppcheck`, and `clang-cl` were not installed on this machine, so
92+
those optional checks were skipped. The fresh MSVC build completed without
93+
compiler warnings in the validation output.
94+
95+
## Residual risks
96+
97+
- The native FFI loader was validated against the exact ABI with a test DLL,
98+
but not against a real packaged `runtime.node` in this run.
99+
- Linux, Linux-musl, and macOS builds were not executed; only Windows x64 was
100+
compiled and tested.
101+
- Cloud-session creation and parent-process extension joining were compile/
102+
golden tested but not exercised against a live host.
103+
- The local runtime was newer (`1.0.81-9`) than the official SDK schema package
104+
baseline (`1.0.81-6`), although both negotiated protocol version 3.
105+
106+
## Validation disposition
107+
108+
The current-official surface is validated for the tested Windows x64
109+
environment. Build, generated protocol coverage, packaging, external
110+
consumption, non-auth tests, and all applicable authenticated E2E scenarios
111+
pass.
112+
113+
Validation fixes are recorded in commits `38f8b5d` and `ebda3eb`.

0 commit comments

Comments
 (0)