Skip to content

Commit 91d2500

Browse files
committed
Merge upstream SDK changes from f902b76
Port changes from github/copilot-sdk PR #208: Update generated events to match schemas New features: - Add SessionSnapshotRewindEvent for session.snapshot_rewind events - Includes upToEventId and eventsRemoved fields Enhanced event data: - ToolExecutionStartEvent: Add mcpServerName and mcpToolName fields for MCP tool support - ToolExecutionCompleteEvent.Result: Add detailedContent field - UserMessageEvent.Attachment: Extended to support selection-type attachments - Add filePath, text fields - Add Selection inner class with start/end Position for line/character ranges Infrastructure: - Register SessionSnapshotRewindEvent in sealed permits clause - Register session.snapshot_rewind in SessionEventParser type map - Update .lastmerge to f902b76032287f9d48a24ebc382ec61c09e3bd36
1 parent d19c8c5 commit 91d2500

7 files changed

Lines changed: 214 additions & 3 deletions

File tree

.lastmerge

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
19a1d09619e695bdec81d331ec5fb160b585ecbb
1+
f902b76032287f9d48a24ebc382ec61c09e3bd36

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@
5151
public abstract sealed class AbstractSessionEvent permits
5252
// Session events
5353
SessionStartEvent, SessionResumeEvent, SessionErrorEvent, SessionIdleEvent, SessionInfoEvent,
54-
SessionModelChangeEvent, SessionHandoffEvent, SessionTruncationEvent, SessionUsageInfoEvent,
55-
SessionCompactionStartEvent, SessionCompactionCompleteEvent,
54+
SessionModelChangeEvent, SessionHandoffEvent, SessionTruncationEvent, SessionSnapshotRewindEvent,
55+
SessionUsageInfoEvent, SessionCompactionStartEvent, SessionCompactionCompleteEvent,
5656
// Assistant events
5757
AssistantTurnStartEvent, AssistantIntentEvent, AssistantReasoningEvent, AssistantReasoningDeltaEvent,
5858
AssistantMessageEvent, AssistantMessageDeltaEvent, AssistantTurnEndEvent, AssistantUsageEvent, AbortEvent,

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ public class SessionEventParser {
5656
TYPE_MAP.put("session.model_change", SessionModelChangeEvent.class);
5757
TYPE_MAP.put("session.handoff", SessionHandoffEvent.class);
5858
TYPE_MAP.put("session.truncation", SessionTruncationEvent.class);
59+
TYPE_MAP.put("session.snapshot_rewind", SessionSnapshotRewindEvent.class);
5960
TYPE_MAP.put("session.usage_info", SessionUsageInfoEvent.class);
6061
TYPE_MAP.put("session.compaction_start", SessionCompactionStartEvent.class);
6162
TYPE_MAP.put("session.compaction_complete", SessionCompactionCompleteEvent.class);
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
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: session.snapshot_rewind
12+
* <p>
13+
* Indicates that the session has been rewound to a previous snapshot.
14+
*/
15+
@JsonIgnoreProperties(ignoreUnknown = true)
16+
public final class SessionSnapshotRewindEvent extends AbstractSessionEvent {
17+
18+
@JsonProperty("data")
19+
private SessionSnapshotRewindData data;
20+
21+
@Override
22+
public String getType() {
23+
return "session.snapshot_rewind";
24+
}
25+
26+
public SessionSnapshotRewindData getData() {
27+
return data;
28+
}
29+
30+
public void setData(SessionSnapshotRewindData data) {
31+
this.data = data;
32+
}
33+
34+
@JsonIgnoreProperties(ignoreUnknown = true)
35+
public static class SessionSnapshotRewindData {
36+
37+
@JsonProperty("upToEventId")
38+
private String upToEventId;
39+
40+
@JsonProperty("eventsRemoved")
41+
private int eventsRemoved;
42+
43+
public String getUpToEventId() {
44+
return upToEventId;
45+
}
46+
47+
public void setUpToEventId(String upToEventId) {
48+
this.upToEventId = upToEventId;
49+
}
50+
51+
public int getEventsRemoved() {
52+
return eventsRemoved;
53+
}
54+
55+
public void setEventsRemoved(int eventsRemoved) {
56+
this.eventsRemoved = eventsRemoved;
57+
}
58+
}
59+
}

src/main/java/com/github/copilot/sdk/events/ToolExecutionCompleteEvent.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,24 @@ public static class Result {
117117
@JsonProperty("content")
118118
private String content;
119119

120+
@JsonProperty("detailedContent")
121+
private String detailedContent;
122+
120123
public String getContent() {
121124
return content;
122125
}
123126

124127
public void setContent(String content) {
125128
this.content = content;
126129
}
130+
131+
public String getDetailedContent() {
132+
return detailedContent;
133+
}
134+
135+
public void setDetailedContent(String detailedContent) {
136+
this.detailedContent = detailedContent;
137+
}
127138
}
128139

129140
@JsonIgnoreProperties(ignoreUnknown = true)

src/main/java/com/github/copilot/sdk/events/ToolExecutionStartEvent.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ public static class ToolExecutionStartData {
4141
@JsonProperty("arguments")
4242
private Object arguments;
4343

44+
@JsonProperty("mcpServerName")
45+
private String mcpServerName;
46+
47+
@JsonProperty("mcpToolName")
48+
private String mcpToolName;
49+
4450
@JsonProperty("parentToolCallId")
4551
private String parentToolCallId;
4652

@@ -68,6 +74,22 @@ public void setArguments(Object arguments) {
6874
this.arguments = arguments;
6975
}
7076

77+
public String getMcpServerName() {
78+
return mcpServerName;
79+
}
80+
81+
public void setMcpServerName(String mcpServerName) {
82+
this.mcpServerName = mcpServerName;
83+
}
84+
85+
public String getMcpToolName() {
86+
return mcpToolName;
87+
}
88+
89+
public void setMcpToolName(String mcpToolName) {
90+
this.mcpToolName = mcpToolName;
91+
}
92+
7193
public String getParentToolCallId() {
7294
return parentToolCallId;
7395
}

src/main/java/com/github/copilot/sdk/events/UserMessageEvent.java

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,18 @@ public static class Attachment {
8787
@JsonProperty("path")
8888
private String path;
8989

90+
@JsonProperty("filePath")
91+
private String filePath;
92+
9093
@JsonProperty("displayName")
9194
private String displayName;
9295

96+
@JsonProperty("text")
97+
private String text;
98+
99+
@JsonProperty("selection")
100+
private Selection selection;
101+
93102
public String getType() {
94103
return type;
95104
}
@@ -106,13 +115,122 @@ public void setPath(String path) {
106115
this.path = path;
107116
}
108117

118+
/**
119+
* Gets the file path (used for selection attachments).
120+
*
121+
* @return the file path
122+
*/
123+
public String getFilePath() {
124+
return filePath;
125+
}
126+
127+
/**
128+
* Sets the file path (used for selection attachments).
129+
*
130+
* @param filePath
131+
* the file path
132+
*/
133+
public void setFilePath(String filePath) {
134+
this.filePath = filePath;
135+
}
136+
109137
public String getDisplayName() {
110138
return displayName;
111139
}
112140

113141
public void setDisplayName(String displayName) {
114142
this.displayName = displayName;
115143
}
144+
145+
/**
146+
* Gets the text content (used for selection attachments).
147+
*
148+
* @return the selected text
149+
*/
150+
public String getText() {
151+
return text;
152+
}
153+
154+
/**
155+
* Sets the text content (used for selection attachments).
156+
*
157+
* @param text
158+
* the selected text
159+
*/
160+
public void setText(String text) {
161+
this.text = text;
162+
}
163+
164+
/**
165+
* Gets the selection range (used for selection attachments).
166+
*
167+
* @return the selection range
168+
*/
169+
public Selection getSelection() {
170+
return selection;
171+
}
172+
173+
/**
174+
* Sets the selection range (used for selection attachments).
175+
*
176+
* @param selection
177+
* the selection range
178+
*/
179+
public void setSelection(Selection selection) {
180+
this.selection = selection;
181+
}
182+
183+
@JsonIgnoreProperties(ignoreUnknown = true)
184+
public static class Selection {
185+
186+
@JsonProperty("start")
187+
private Position start;
188+
189+
@JsonProperty("end")
190+
private Position end;
191+
192+
public Position getStart() {
193+
return start;
194+
}
195+
196+
public void setStart(Position start) {
197+
this.start = start;
198+
}
199+
200+
public Position getEnd() {
201+
return end;
202+
}
203+
204+
public void setEnd(Position end) {
205+
this.end = end;
206+
}
207+
208+
@JsonIgnoreProperties(ignoreUnknown = true)
209+
public static class Position {
210+
211+
@JsonProperty("line")
212+
private int line;
213+
214+
@JsonProperty("character")
215+
private int character;
216+
217+
public int getLine() {
218+
return line;
219+
}
220+
221+
public void setLine(int line) {
222+
this.line = line;
223+
}
224+
225+
public int getCharacter() {
226+
return character;
227+
}
228+
229+
public void setCharacter(int character) {
230+
this.character = character;
231+
}
232+
}
233+
}
116234
}
117235
}
118236
}

0 commit comments

Comments
 (0)