Skip to content

Commit 034e320

Browse files
committed
release: sync copilot-sdk-cpp v0.4.1
Re-pins to @github/copilot 1.0.84-6 (github/copilot-sdk e5c53790) and closes the two lifecycle gaps carried over from the previous release. Read this before upgrading: NOT binary-compatible Despite the patch-level version, relinking a prebuilt library against 0.4.0 headers is unsafe. SessionEventType gained three values ahead of Unknown, so Unknown renumbers from 144 to 147, and struct layouts changed. Recompiling against these headers is safe and requires no source changes. Fixes - Session teardown now issues session.detach rather than session.destroy, following upstream. Session::detach() returns the runtime's {success, error}; destroy() is kept, implemented on top of it, and drops a soft failure because its signature cannot carry one. A declined detach is not raised -- teardown should not fail because the runtime already considers a session gone. - Host tool invocations are cancelled when the connection closes. Tool handlers run on a background task and answer with session.tools.handlePendingToolCall; because session destruction waits on those tasks, a handler finishing during shutdown would answer over a transport already being torn down. Client::stop() and force_stop() now cancel first, so the result is dropped instead. The handler itself is your code and is not interrupted. Session::cancel_pending_tool_invocations() and pending_tool_invocations() are public, so the behaviour is observable rather than implicit. Protocol Regenerated from CLI 1.0.84-6: API definitions 1293 -> 1306, event definitions 576 -> 582, event variants 144 -> 147. Three new skill.* events are mapped rather than degrading to SessionEventType::Unknown. RPC methods went 384 -> 383: sessions.registerExtensionToolsOnSession was removed upstream. Nothing in the hand-written API referenced it. The wire protocol is unchanged at version 3. Suite: 468 tests, 0 failed.
1 parent 8243614 commit 034e320

11 files changed

Lines changed: 795 additions & 191 deletions

File tree

‎CMakeLists.txt‎

Lines changed: 1 addition & 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.4.0 LANGUAGES CXX)
2+
project(copilot_sdk_cpp VERSION 0.4.1 LANGUAGES CXX)
33

44
# Enable folder organization in IDEs
55
set_property(GLOBAL PROPERTY USE_FOLDERS ON)

‎include/copilot/events.hpp‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3118,6 +3118,10 @@ enum class SessionEventType
31183118
PermissionMessageAuthorizationDegraded,
31193119
SessionMcpServerRemoved,
31203120
SessionMcpServerNeedsReconnect,
3121+
// Added with the @github/copilot 1.0.84-6 re-pin (upstream e5c53790).
3122+
SkillInvokedRef,
3123+
SkillContextDelivered,
3124+
SkillContextDeliveredRef,
31213125
Unknown
31223126
};
31233127

@@ -3466,6 +3470,10 @@ inline SessionEvent parse_session_event(const json& j)
34663470
SessionEventType::PermissionMessageAuthorizationDegraded},
34673471
{"session.mcp_server_removed", SessionEventType::SessionMcpServerRemoved},
34683472
{"session.mcp_server_needs_reconnect", SessionEventType::SessionMcpServerNeedsReconnect},
3473+
// @github/copilot 1.0.84-6 (upstream e5c53790).
3474+
{"skill.invoked_ref", SessionEventType::SkillInvokedRef},
3475+
{"skill.context_delivered", SessionEventType::SkillContextDelivered},
3476+
{"skill.context_delivered_ref", SessionEventType::SkillContextDeliveredRef},
34693477
};
34703478

34713479
auto it = type_map.find(event.type_string);

‎include/copilot/generated/api_types.hpp‎

Lines changed: 221 additions & 53 deletions
Large diffs are not rendered by default.

‎include/copilot/generated/protocol_version.hpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace copilot::generated
99

1010
inline constexpr int kSdkProtocolVersion = 3;
1111
inline constexpr int kMinProtocolVersion = 2;
12-
inline constexpr std::string_view kOfficialSdkCommit = "f45c46fd1812f8bed5b4cbc250f47177c83068f0";
13-
inline constexpr std::string_view kOfficialSchemaPackageVersion = "1.0.84-5";
12+
inline constexpr std::string_view kOfficialSdkCommit = "e5c53790c6a8aa253aa3887ebb8958646bd60452";
13+
inline constexpr std::string_view kOfficialSchemaPackageVersion = "1.0.84-6";
1414

1515
} // namespace copilot::generated

‎include/copilot/generated/schema_coverage.hpp‎

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@
88
namespace copilot::generated::coverage
99
{
1010

11-
inline constexpr std::size_t kApiDefinitionCount = 1293;
12-
inline constexpr std::size_t kSessionEventDefinitionCount = 576;
11+
inline constexpr std::size_t kApiDefinitionCount = 1306;
12+
inline constexpr std::size_t kSessionEventDefinitionCount = 582;
1313
inline constexpr std::size_t kSharedDefinitionCount = 58;
14-
inline constexpr std::size_t kUniqueDefinitionCount = 1811;
15-
inline constexpr std::size_t kRpcMethodCount = 384;
16-
inline constexpr std::size_t kSessionEventVariantCount = 144;
17-
inline constexpr std::string_view kApiSchemaSha256 = "5835517c600d1661bb857aa74deeb2abd2cfb9ed1e69cdedd1402181ea9eca98";
18-
inline constexpr std::string_view kSessionEventsSchemaSha256 = "fded8ae9faa212cc84adae273c8b107a450b90ab66a723ee03e9057d41f8e4c5";
19-
inline constexpr std::string_view kApiDefinitionNamesSha256 = "374f18544d37959a909d1852524008b95b656b1db7f53890abc606cee8120077";
20-
inline constexpr std::string_view kSessionEventDefinitionNamesSha256 = "21e92237ac86ce0a8e6a2e1554369b83a413f9a6006c03d40f0709a409758ffc";
21-
inline constexpr std::string_view kRpcMethodNamesSha256 = "940bc904071d6292b0707fc71523fc78aad5cd73a2a1df8dc03f388bc1ef1b27";
22-
inline constexpr std::string_view kSessionEventWireTypesSha256 = "e149d65f991cac05fd210a93dd034d4bad7c4ba02e1bf443fb5c9b5af8850e33";
23-
inline constexpr std::string_view kSurfaceSha256 = "d8c46b04dd0fee2eee2552833266fa12a97b403667c9f541d59716e602229689";
14+
inline constexpr std::size_t kUniqueDefinitionCount = 1830;
15+
inline constexpr std::size_t kRpcMethodCount = 383;
16+
inline constexpr std::size_t kSessionEventVariantCount = 147;
17+
inline constexpr std::string_view kApiSchemaSha256 = "443958cfdccb9323b13c20ce5133817c1800b8e9e700ae3b9520bcc6f2a66340";
18+
inline constexpr std::string_view kSessionEventsSchemaSha256 = "d34b2b2af8f20c2118f1d07d1409bceac10d400c0878e987b9af68f903103d8c";
19+
inline constexpr std::string_view kApiDefinitionNamesSha256 = "1a0c4ed01b23fd47aa97d01ac99c29ba6861873c61d0f8d9e9b95c80ef293b95";
20+
inline constexpr std::string_view kSessionEventDefinitionNamesSha256 = "528849e2f18ec2429afb1ad0201b0a317c8be84ec6c6fa823a288da129b598e1";
21+
inline constexpr std::string_view kRpcMethodNamesSha256 = "37f118b1fbbb0f3442d0b366e3f4d73ebc5ba287b7dcb5ca75448dd2c86345dc";
22+
inline constexpr std::string_view kSessionEventWireTypesSha256 = "d45372a060c9f6851e5438ac8a5d14073dff77f44138dc2e6be51dc556bd979f";
23+
inline constexpr std::string_view kSurfaceSha256 = "02dd29c3d305ad86ecaabd8879afa5cd418039ac6f564819297a5c45c5384769";
2424

2525
} // namespace copilot::generated::coverage

‎include/copilot/generated/session_events.hpp‎

Lines changed: 92 additions & 11 deletions
Large diffs are not rendered by default.

‎include/copilot/rpc_methods.hpp‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ inline constexpr const char* kSessionGetMetadata = "session.getMetadata";
173173
inline constexpr const char* kSessionDelete = "session.delete";
174174
inline constexpr const char* kSessionGetLastId = "session.getLastId";
175175
inline constexpr const char* kSessionDestroy = "session.destroy";
176+
inline constexpr const char* kSessionDetach = "session.detach";
176177
inline constexpr const char* kSessionSend = "session.send";
177178
inline constexpr const char* kSessionAbort = "session.abort";
178179
inline constexpr const char* kSessionGetMessages = "session.getMessages";

‎include/copilot/session.hpp‎

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,8 +285,45 @@ class Session : public std::enable_shared_from_this<Session>
285285
// Lifecycle
286286
// =========================================================================
287287

288-
/// Destroy the session on the server
289-
/// @return Future that completes when destroyed
288+
/// Stop answering host tool invocations on this session.
289+
///
290+
/// A handler already running is user code on a background task and cannot be
291+
/// interrupted; this ensures that when it returns, its result is dropped
292+
/// instead of being sent as `session.tools.handlePendingToolCall` over a
293+
/// connection that is closing. Called by Client during stop, mirroring
294+
/// upstream github/copilot-sdk 53e74d81.
295+
void cancel_pending_tool_invocations() noexcept;
296+
297+
/// Host tool invocations dispatched but not yet answered. Exposed so the
298+
/// cancellation contract is observable from a test.
299+
int pending_tool_invocations() const noexcept;
300+
301+
/// Outcome of detach(). Mirrors upstream's SessionDetachResponse.
302+
struct DetachResult
303+
{
304+
/// Whether the runtime released the session.
305+
bool success = false;
306+
/// Runtime-supplied reason when `success` is false.
307+
std::optional<std::string> error;
308+
/// Full response, so fields not surfaced above stay reachable.
309+
json raw;
310+
};
311+
312+
/// Detach the session from this connection.
313+
///
314+
/// Calls `session.detach`, which replaced `session.destroy` as the SDK
315+
/// teardown RPC upstream (github/copilot-sdk fcffcdf0). A `success: false`
316+
/// response is reported here rather than thrown: teardown should not fail
317+
/// because the runtime declined to release a session.
318+
std::future<DetachResult> detach();
319+
320+
/// Destroy the session on the server.
321+
///
322+
/// Retained for source compatibility and implemented in terms of detach().
323+
/// A soft failure (`success: false`) is **discarded** here because the
324+
/// signature cannot carry it — call detach() directly if you need to know.
325+
/// Transport and RPC errors still propagate.
326+
/// @return Future that completes when the session has been detached
290327
std::future<void> destroy();
291328

292329
/// Disconnect this SDK participant while leaving the session resumable.
@@ -451,6 +488,13 @@ class Session : public std::enable_shared_from_this<Session>
451488

452489
std::mutex background_tasks_mutex_;
453490
std::vector<std::future<void>> background_tasks_;
491+
492+
/// Set when the connection is going away. A host tool handler already running
493+
/// cannot be interrupted -- it is user code on a detached task -- but once it
494+
/// returns we must not answer into a connection that is being torn down.
495+
std::atomic<bool> tool_invocations_cancelled_{false};
496+
/// Host tool invocations dispatched but not yet answered.
497+
std::atomic<int> pending_tool_invocations_{0};
454498
};
455499

456500
} // namespace copilot

0 commit comments

Comments
 (0)