Skip to content

Commit 4f52b3d

Browse files
committed
Implement metadata APIs and tool execution progress event; refactor model handling
1 parent 05851af commit 4f52b3d

18 files changed

Lines changed: 936 additions & 67 deletions

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public class Example {
7575

7676
// Create a session
7777
var session = client.createSession(
78-
new SessionConfig().setModel(CopilotModel.CLAUDE_SONNET_4_5.toString())
78+
new SessionConfig().setModel("claude-sonnet-4.5")
7979
).get();
8080

8181
// Wait for response using session.idle event

‎jbang-example.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public static void main(String[] args) throws Exception {
1313

1414
// Create a session
1515
var session = client.createSession(
16-
new SessionConfig().setModel(CopilotModel.CLAUDE_SONNET_4_5.toString())).get();
16+
new SessionConfig().setModel("claude-sonnet-4.5")).get();
1717

1818
// Wait for response using session.idle event
1919
var done = new CompletableFuture<Void>();

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

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,12 @@
3333
import com.github.copilot.sdk.json.CreateSessionRequest;
3434
import com.github.copilot.sdk.json.CreateSessionResponse;
3535
import com.github.copilot.sdk.json.DeleteSessionResponse;
36+
import com.github.copilot.sdk.json.GetAuthStatusResponse;
3637
import com.github.copilot.sdk.json.GetLastSessionIdResponse;
38+
import com.github.copilot.sdk.json.GetModelsResponse;
39+
import com.github.copilot.sdk.json.GetStatusResponse;
3740
import com.github.copilot.sdk.json.ListSessionsResponse;
41+
import com.github.copilot.sdk.json.ModelInfo;
3842
import com.github.copilot.sdk.json.PermissionRequestResult;
3943
import com.github.copilot.sdk.json.PingResponse;
4044
import com.github.copilot.sdk.json.ResumeSessionConfig;
@@ -537,6 +541,40 @@ public CompletableFuture<PingResponse> ping(String message) {
537541
Map.of("message", message != null ? message : ""), PingResponse.class));
538542
}
539543

544+
/**
545+
* Gets CLI status including version and protocol information.
546+
*
547+
* @return a future that resolves with the status response containing version
548+
* and protocol version
549+
* @see GetStatusResponse
550+
*/
551+
public CompletableFuture<GetStatusResponse> getStatus() {
552+
return ensureConnected()
553+
.thenCompose(connection -> connection.rpc.invoke("status.get", Map.of(), GetStatusResponse.class));
554+
}
555+
556+
/**
557+
* Gets current authentication status.
558+
*
559+
* @return a future that resolves with the authentication status
560+
* @see GetAuthStatusResponse
561+
*/
562+
public CompletableFuture<GetAuthStatusResponse> getAuthStatus() {
563+
return ensureConnected().thenCompose(
564+
connection -> connection.rpc.invoke("auth.getStatus", Map.of(), GetAuthStatusResponse.class));
565+
}
566+
567+
/**
568+
* Lists available models with their metadata.
569+
*
570+
* @return a future that resolves with a list of available models
571+
* @see ModelInfo
572+
*/
573+
public CompletableFuture<List<ModelInfo>> listModels() {
574+
return ensureConnected().thenCompose(connection -> connection.rpc
575+
.invoke("models.list", Map.of(), GetModelsResponse.class).thenApply(GetModelsResponse::getModels));
576+
}
577+
540578
/**
541579
* Gets the ID of the most recently used session.
542580
* <p>

‎src/main/java/com/github/copilot/sdk/CopilotModel.java‎

Lines changed: 0 additions & 64 deletions
This file was deleted.

‎src/main/java/com/github/copilot/sdk/events/AbstractSessionEvent.java‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ public abstract sealed class AbstractSessionEvent permits
5757
AssistantTurnStartEvent, AssistantIntentEvent, AssistantReasoningEvent, AssistantReasoningDeltaEvent,
5858
AssistantMessageEvent, AssistantMessageDeltaEvent, AssistantTurnEndEvent, AssistantUsageEvent, AbortEvent,
5959
// Tool events
60-
ToolUserRequestedEvent, ToolExecutionStartEvent, ToolExecutionPartialResultEvent, ToolExecutionCompleteEvent,
60+
ToolUserRequestedEvent, ToolExecutionStartEvent, ToolExecutionPartialResultEvent, ToolExecutionProgressEvent,
61+
ToolExecutionCompleteEvent,
6162
// User events
6263
UserMessageEvent, PendingMessagesModifiedEvent,
6364
// Other events

‎src/main/java/com/github/copilot/sdk/events/SessionEventParser.java‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ public class SessionEventParser {
7373
TYPE_MAP.put("tool.user_requested", ToolUserRequestedEvent.class);
7474
TYPE_MAP.put("tool.execution_start", ToolExecutionStartEvent.class);
7575
TYPE_MAP.put("tool.execution_partial_result", ToolExecutionPartialResultEvent.class);
76+
TYPE_MAP.put("tool.execution_progress", ToolExecutionProgressEvent.class);
7677
TYPE_MAP.put("tool.execution_complete", ToolExecutionCompleteEvent.class);
7778
TYPE_MAP.put("subagent.started", SubagentStartedEvent.class);
7879
TYPE_MAP.put("subagent.completed", SubagentCompletedEvent.class);
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
*--------------------------------------------------------------------------------------------*/
4+
5+
package com.github.copilot.sdk.events;
6+
7+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
8+
import com.fasterxml.jackson.annotation.JsonProperty;
9+
10+
/**
11+
* Event fired when a tool execution reports progress.
12+
* <p>
13+
* This event provides progress updates during tool execution.
14+
*/
15+
@JsonIgnoreProperties(ignoreUnknown = true)
16+
public final class ToolExecutionProgressEvent extends AbstractSessionEvent {
17+
18+
public static final String TYPE = "tool.execution_progress";
19+
20+
@JsonProperty("data")
21+
private ToolExecutionProgressData data;
22+
23+
@Override
24+
public String getType() {
25+
return TYPE;
26+
}
27+
28+
public ToolExecutionProgressData getData() {
29+
return data;
30+
}
31+
32+
public ToolExecutionProgressEvent setData(ToolExecutionProgressData data) {
33+
this.data = data;
34+
return this;
35+
}
36+
37+
@JsonIgnoreProperties(ignoreUnknown = true)
38+
public static class ToolExecutionProgressData {
39+
40+
@JsonProperty("toolCallId")
41+
private String toolCallId;
42+
43+
@JsonProperty("progressMessage")
44+
private String progressMessage;
45+
46+
public String getToolCallId() {
47+
return toolCallId;
48+
}
49+
50+
public ToolExecutionProgressData setToolCallId(String toolCallId) {
51+
this.toolCallId = toolCallId;
52+
return this;
53+
}
54+
55+
public String getProgressMessage() {
56+
return progressMessage;
57+
}
58+
59+
public ToolExecutionProgressData setProgressMessage(String progressMessage) {
60+
this.progressMessage = progressMessage;
61+
return this;
62+
}
63+
}
64+
}
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
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.JsonIgnoreProperties;
8+
import com.fasterxml.jackson.annotation.JsonProperty;
9+
10+
/**
11+
* Response from the auth.getStatus RPC call.
12+
* <p>
13+
* Contains information about the current authentication status.
14+
*/
15+
@JsonIgnoreProperties(ignoreUnknown = true)
16+
public class GetAuthStatusResponse {
17+
18+
/**
19+
* Whether the user is authenticated.
20+
*/
21+
@JsonProperty("isAuthenticated")
22+
private boolean isAuthenticated;
23+
24+
/**
25+
* Authentication type (user, env, gh-cli, hmac, api-key, token).
26+
*/
27+
@JsonProperty("authType")
28+
private String authType;
29+
30+
/**
31+
* GitHub host URL.
32+
*/
33+
@JsonProperty("host")
34+
private String host;
35+
36+
/**
37+
* User login name.
38+
*/
39+
@JsonProperty("login")
40+
private String login;
41+
42+
/**
43+
* Human-readable status message.
44+
*/
45+
@JsonProperty("statusMessage")
46+
private String statusMessage;
47+
48+
public boolean isAuthenticated() {
49+
return isAuthenticated;
50+
}
51+
52+
public GetAuthStatusResponse setAuthenticated(boolean authenticated) {
53+
isAuthenticated = authenticated;
54+
return this;
55+
}
56+
57+
public String getAuthType() {
58+
return authType;
59+
}
60+
61+
public GetAuthStatusResponse setAuthType(String authType) {
62+
this.authType = authType;
63+
return this;
64+
}
65+
66+
public String getHost() {
67+
return host;
68+
}
69+
70+
public GetAuthStatusResponse setHost(String host) {
71+
this.host = host;
72+
return this;
73+
}
74+
75+
public String getLogin() {
76+
return login;
77+
}
78+
79+
public GetAuthStatusResponse setLogin(String login) {
80+
this.login = login;
81+
return this;
82+
}
83+
84+
public String getStatusMessage() {
85+
return statusMessage;
86+
}
87+
88+
public GetAuthStatusResponse setStatusMessage(String statusMessage) {
89+
this.statusMessage = statusMessage;
90+
return this;
91+
}
92+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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.JsonIgnoreProperties;
8+
import com.fasterxml.jackson.annotation.JsonProperty;
9+
10+
import java.util.List;
11+
12+
/**
13+
* Response from the models.list RPC call.
14+
* <p>
15+
* Contains a list of available models with their metadata.
16+
*/
17+
@JsonIgnoreProperties(ignoreUnknown = true)
18+
public class GetModelsResponse {
19+
20+
@JsonProperty("models")
21+
private List<ModelInfo> models;
22+
23+
public List<ModelInfo> getModels() {
24+
return models;
25+
}
26+
27+
public GetModelsResponse setModels(List<ModelInfo> models) {
28+
this.models = models;
29+
return this;
30+
}
31+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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.JsonIgnoreProperties;
8+
import com.fasterxml.jackson.annotation.JsonProperty;
9+
10+
/**
11+
* Response from the status.get RPC call.
12+
* <p>
13+
* Contains information about the CLI version and protocol version.
14+
*/
15+
@JsonIgnoreProperties(ignoreUnknown = true)
16+
public class GetStatusResponse {
17+
18+
/**
19+
* Package version (e.g., "1.0.0").
20+
*/
21+
@JsonProperty("version")
22+
private String version;
23+
24+
/**
25+
* Protocol version for SDK compatibility.
26+
*/
27+
@JsonProperty("protocolVersion")
28+
private int protocolVersion;
29+
30+
public String getVersion() {
31+
return version;
32+
}
33+
34+
public GetStatusResponse setVersion(String version) {
35+
this.version = version;
36+
return this;
37+
}
38+
39+
public int getProtocolVersion() {
40+
return protocolVersion;
41+
}
42+
43+
public GetStatusResponse setProtocolVersion(int protocolVersion) {
44+
this.protocolVersion = protocolVersion;
45+
return this;
46+
}
47+
}

0 commit comments

Comments
 (0)