Skip to content

Commit fcec7ff

Browse files
authored
Merge pull request #144 from github/copilot/update-copilot-sdk-to-1-0-40-0
Merge reference implementation SDK changes (2026-04-30)
2 parents bf36957 + 1cd3849 commit fcec7ff

8 files changed

Lines changed: 70 additions & 43 deletions

File tree

.lastmerge

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
dd2dcbc439256acfb9feb2cff07c0b9c820091b8
1+
e42b726ca42bd1b2e099a956c9287ba9435ba3e5

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@
9494
reference-impl-sync workflow and deal with the subsequent
9595
PR.
9696
-->
97-
<readonly-copilot-sdk-ref-impl-version-from-lastmerge-file-updated-by-reference-impl-sync>^1.0.36-0</readonly-copilot-sdk-ref-impl-version-from-lastmerge-file-updated-by-reference-impl-sync>
97+
<readonly-copilot-sdk-ref-impl-version-from-lastmerge-file-updated-by-reference-impl-sync>^1.0.40-0</readonly-copilot-sdk-ref-impl-version-from-lastmerge-file-updated-by-reference-impl-sync>
9898

9999
</properties>
100100

scripts/codegen/package-lock.json

Lines changed: 28 additions & 28 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/codegen/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"generate:java": "tsx java.ts"
88
},
99
"dependencies": {
10-
"@github/copilot": "^1.0.39",
10+
"@github/copilot": "^1.0.40-0",
1111
"json-schema": "^0.4.0",
1212
"tsx": "^4.20.6"
1313
}

src/main/java/com/github/copilot/sdk/CopilotClient.java

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -744,18 +744,15 @@ public CompletableFuture<String> getForegroundSessionId() {
744744
* if the operation fails
745745
*/
746746
public CompletableFuture<Void> setForegroundSessionId(String sessionId) {
747-
return ensureConnected()
748-
.thenCompose(
749-
connection -> connection.rpc
750-
.invoke("session.setForeground", Map.of("sessionId", sessionId),
751-
com.github.copilot.sdk.json.SetForegroundSessionResponse.class)
752-
.thenAccept(response -> {
753-
if (!response.success()) {
754-
throw new RuntimeException(response.error() != null
755-
? response.error()
756-
: "Failed to set foreground session");
757-
}
758-
}));
747+
return ensureConnected().thenCompose(connection -> connection.rpc
748+
.invoke("session.setForeground", new com.github.copilot.sdk.json.SetForegroundSessionRequest(sessionId),
749+
com.github.copilot.sdk.json.SetForegroundSessionResponse.class)
750+
.thenAccept(response -> {
751+
if (!response.success()) {
752+
throw new RuntimeException(
753+
response.error() != null ? response.error() : "Failed to set foreground session");
754+
}
755+
}));
759756
}
760757

761758
/**
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
*--------------------------------------------------------------------------------------------*/
4+
5+
package com.github.copilot.sdk.json;
6+
7+
import com.fasterxml.jackson.annotation.JsonProperty;
8+
9+
/**
10+
* Request body for session.setForeground RPC call.
11+
* <p>
12+
* Using an explicit record type (rather than an ad-hoc map) ensures correct
13+
* JSON serialization in all execution environments.
14+
*
15+
* @since 1.0.0
16+
*/
17+
public record SetForegroundSessionRequest(
18+
/** The session ID to bring to the foreground. */
19+
@JsonProperty("sessionId") String sessionId) {
20+
}

src/test/java/com/github/copilot/sdk/DataObjectCoverageTest.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import com.github.copilot.sdk.json.PreToolUseHookInput;
1919
import com.github.copilot.sdk.json.PreToolUseHookOutput;
2020
import com.github.copilot.sdk.json.SectionOverride;
21+
import com.github.copilot.sdk.json.SetForegroundSessionRequest;
2122
import com.github.copilot.sdk.json.SetForegroundSessionResponse;
2223
import com.github.copilot.sdk.json.ToolBinaryResult;
2324
import com.github.copilot.sdk.json.ToolResultObject;
@@ -86,6 +87,14 @@ void getForegroundSessionResponseRecord() {
8687
assertEquals("/home/user/project", response.workspacePath());
8788
}
8889

90+
// ===== SetForegroundSessionRequest record =====
91+
92+
@Test
93+
void setForegroundSessionRequestRecord() {
94+
var request = new SetForegroundSessionRequest("session-123");
95+
assertEquals("session-123", request.sessionId());
96+
}
97+
8998
// ===== SetForegroundSessionResponse record =====
9099

91100
@Test

src/test/java/com/github/copilot/sdk/E2ETestContext.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ public List<Map<String, Object>> getExchanges() throws IOException, InterruptedE
249249
public Map<String, String> getEnvironment() {
250250
Map<String, String> env = new HashMap<>(System.getenv());
251251
env.put("COPILOT_API_URL", proxyUrl);
252+
env.put("COPILOT_HOME", homeDir.toString());
252253
env.put("XDG_CONFIG_HOME", homeDir.toString());
253254
env.put("XDG_STATE_HOME", homeDir.toString());
254255
return env;

0 commit comments

Comments
 (0)