Skip to content

Commit 6c0b8b1

Browse files
authored
Update protocol version, add tests, synchronize session events
1 parent e07f66e commit 6c0b8b1

14 files changed

Lines changed: 369 additions & 14 deletions

File tree

dotnet/src/Generated/SessionEvents.cs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
//
77
// Generated from: @github/copilot/session-events.schema.json
88
// Generated by: scripts/generate-session-types.ts
9-
// Generated at: 2026-01-21T14:50:29.306Z
9+
// Generated at: 2026-01-22T04:11:05.393Z
1010
//
1111
// To update these types:
1212
// 1. Update the schema in copilot-agent-runtime
@@ -58,6 +58,7 @@ namespace GitHub.Copilot.SDK
5858
[JsonDerivedType(typeof(SystemMessageEvent), "system.message")]
5959
[JsonDerivedType(typeof(ToolExecutionCompleteEvent), "tool.execution_complete")]
6060
[JsonDerivedType(typeof(ToolExecutionPartialResultEvent), "tool.execution_partial_result")]
61+
[JsonDerivedType(typeof(ToolExecutionProgressEvent), "tool.execution_progress")]
6162
[JsonDerivedType(typeof(ToolExecutionStartEvent), "tool.execution_start")]
6263
[JsonDerivedType(typeof(ToolUserRequestedEvent), "tool.user_requested")]
6364
[JsonDerivedType(typeof(UserMessageEvent), "user.message")]
@@ -389,6 +390,18 @@ public partial class ToolExecutionPartialResultEvent : SessionEvent
389390
public required ToolExecutionPartialResultData Data { get; set; }
390391
}
391392

393+
/// <summary>
394+
/// Event: tool.execution_progress
395+
/// </summary>
396+
public partial class ToolExecutionProgressEvent : SessionEvent
397+
{
398+
[JsonIgnore]
399+
public override string Type => "tool.execution_progress";
400+
401+
[JsonPropertyName("data")]
402+
public required ToolExecutionProgressData Data { get; set; }
403+
}
404+
392405
/// <summary>
393406
/// Event: tool.execution_complete
394407
/// </summary>
@@ -850,6 +863,15 @@ public partial class ToolExecutionPartialResultData
850863
public required string PartialOutput { get; set; }
851864
}
852865

866+
public partial class ToolExecutionProgressData
867+
{
868+
[JsonPropertyName("toolCallId")]
869+
public required string ToolCallId { get; set; }
870+
871+
[JsonPropertyName("progressMessage")]
872+
public required string ProgressMessage { get; set; }
873+
}
874+
853875
public partial class ToolExecutionCompleteData
854876
{
855877
[JsonPropertyName("toolCallId")]

dotnet/src/SdkProtocolVersion.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ internal static class SdkProtocolVersion
1111
/// <summary>
1212
/// The SDK protocol version.
1313
/// </summary>
14-
public const int Version = 1;
14+
public const int Version = 2;
1515

1616
/// <summary>
1717
/// Gets the SDK protocol version.

dotnet/test/ClientTests.cs

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,87 @@ public async Task Should_Force_Stop_Without_Cleanup()
8989

9090
Assert.Equal(ConnectionState.Disconnected, client.State);
9191
}
92+
93+
[Fact]
94+
public async Task Should_Get_Status_With_Version_And_Protocol_Info()
95+
{
96+
using var client = new CopilotClient(new CopilotClientOptions { CliPath = _cliPath, UseStdio = true });
97+
98+
try
99+
{
100+
await client.StartAsync();
101+
102+
var status = await client.GetStatusAsync();
103+
Assert.NotNull(status.Version);
104+
Assert.NotEmpty(status.Version);
105+
Assert.True(status.ProtocolVersion >= 1);
106+
107+
await client.StopAsync();
108+
}
109+
finally
110+
{
111+
await client.ForceStopAsync();
112+
}
113+
}
114+
115+
[Fact]
116+
public async Task Should_Get_Auth_Status()
117+
{
118+
using var client = new CopilotClient(new CopilotClientOptions { CliPath = _cliPath, UseStdio = true });
119+
120+
try
121+
{
122+
await client.StartAsync();
123+
124+
var authStatus = await client.GetAuthStatusAsync();
125+
// isAuthenticated is a bool, just verify we got a response
126+
if (authStatus.IsAuthenticated)
127+
{
128+
Assert.NotNull(authStatus.AuthType);
129+
Assert.NotNull(authStatus.StatusMessage);
130+
}
131+
132+
await client.StopAsync();
133+
}
134+
finally
135+
{
136+
await client.ForceStopAsync();
137+
}
138+
}
139+
140+
[Fact]
141+
public async Task Should_List_Models_When_Authenticated()
142+
{
143+
using var client = new CopilotClient(new CopilotClientOptions { CliPath = _cliPath, UseStdio = true });
144+
145+
try
146+
{
147+
await client.StartAsync();
148+
149+
var authStatus = await client.GetAuthStatusAsync();
150+
if (!authStatus.IsAuthenticated)
151+
{
152+
// Skip if not authenticated - models.list requires auth
153+
await client.StopAsync();
154+
return;
155+
}
156+
157+
var models = await client.ListModelsAsync();
158+
Assert.NotNull(models);
159+
if (models.Count > 0)
160+
{
161+
var model = models[0];
162+
Assert.NotNull(model.Id);
163+
Assert.NotEmpty(model.Id);
164+
Assert.NotNull(model.Name);
165+
Assert.NotNull(model.Capabilities);
166+
}
167+
168+
await client.StopAsync();
169+
}
170+
finally
171+
{
172+
await client.ForceStopAsync();
173+
}
174+
}
92175
}

go/e2e/client_test.go

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,4 +130,100 @@ func TestClient(t *testing.T) {
130130
t.Errorf("Expected state to be 'disconnected', got %q", client.GetState())
131131
}
132132
})
133+
134+
t.Run("should get status with version and protocol info", func(t *testing.T) {
135+
client := copilot.NewClient(&copilot.ClientOptions{
136+
CLIPath: cliPath,
137+
UseStdio: true,
138+
})
139+
t.Cleanup(func() { client.ForceStop() })
140+
141+
if err := client.Start(); err != nil {
142+
t.Fatalf("Failed to start client: %v", err)
143+
}
144+
145+
status, err := client.GetStatus()
146+
if err != nil {
147+
t.Fatalf("Failed to get status: %v", err)
148+
}
149+
150+
if status.Version == "" {
151+
t.Error("Expected status.Version to be non-empty")
152+
}
153+
154+
if status.ProtocolVersion < 1 {
155+
t.Errorf("Expected status.ProtocolVersion >= 1, got %d", status.ProtocolVersion)
156+
}
157+
158+
client.Stop()
159+
})
160+
161+
t.Run("should get auth status", func(t *testing.T) {
162+
client := copilot.NewClient(&copilot.ClientOptions{
163+
CLIPath: cliPath,
164+
UseStdio: true,
165+
})
166+
t.Cleanup(func() { client.ForceStop() })
167+
168+
if err := client.Start(); err != nil {
169+
t.Fatalf("Failed to start client: %v", err)
170+
}
171+
172+
authStatus, err := client.GetAuthStatus()
173+
if err != nil {
174+
t.Fatalf("Failed to get auth status: %v", err)
175+
}
176+
177+
// isAuthenticated is a bool, just verify we got a response
178+
if authStatus.IsAuthenticated {
179+
if authStatus.AuthType == nil {
180+
t.Error("Expected authType to be set when authenticated")
181+
}
182+
if authStatus.StatusMessage == nil {
183+
t.Error("Expected statusMessage to be set when authenticated")
184+
}
185+
}
186+
187+
client.Stop()
188+
})
189+
190+
t.Run("should list models when authenticated", func(t *testing.T) {
191+
client := copilot.NewClient(&copilot.ClientOptions{
192+
CLIPath: cliPath,
193+
UseStdio: true,
194+
})
195+
t.Cleanup(func() { client.ForceStop() })
196+
197+
if err := client.Start(); err != nil {
198+
t.Fatalf("Failed to start client: %v", err)
199+
}
200+
201+
authStatus, err := client.GetAuthStatus()
202+
if err != nil {
203+
t.Fatalf("Failed to get auth status: %v", err)
204+
}
205+
206+
if !authStatus.IsAuthenticated {
207+
// Skip if not authenticated - models.list requires auth
208+
client.Stop()
209+
return
210+
}
211+
212+
models, err := client.ListModels()
213+
if err != nil {
214+
t.Fatalf("Failed to list models: %v", err)
215+
}
216+
217+
if len(models) > 0 {
218+
model := models[0]
219+
if model.ID == "" {
220+
t.Error("Expected model.ID to be non-empty")
221+
}
222+
if model.Name == "" {
223+
t.Error("Expected model.Name to be non-empty")
224+
}
225+
}
226+
227+
client.Stop()
228+
})
133229
}

go/generated_session_events.go

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

go/sdk_protocol_version.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

nodejs/scripts/generate-session-types.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,22 @@ async function generatePythonTypes(schemaPath: string) {
211211
// dataclass rules. We post-process to add "= None" to these unconstrained "Any" fields.
212212
generatedCode = generatedCode.replace(/: Any$/gm, ": Any = None");
213213

214+
// Add UNKNOWN enum value and _missing_ handler for forward compatibility
215+
// This ensures that new event types from the server don't cause errors
216+
generatedCode = generatedCode.replace(
217+
/^(class SessionEventType\(Enum\):.*?)(^\s*\n@dataclass)/ms,
218+
`$1 # UNKNOWN is used for forward compatibility - new event types from the server
219+
# will map to this value instead of raising an error
220+
UNKNOWN = "unknown"
221+
222+
@classmethod
223+
def _missing_(cls, value: object) -> "SessionEventType":
224+
"""Handle unknown event types gracefully for forward compatibility."""
225+
return cls.UNKNOWN
226+
227+
$2`
228+
);
229+
214230
const banner = `"""
215231
AUTO-GENERATED FILE - DO NOT EDIT
216232

nodejs/src/generated/session-events.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Generated from: @github/copilot/session-events.schema.json
55
* Generated by: scripts/generate-session-types.ts
6-
* Generated at: 2026-01-20T04:18:06.227Z
6+
* Generated at: 2026-01-22T04:11:04.988Z
77
*
88
* To update these types:
99
* 1. Update the schema in copilot-agent-runtime
@@ -354,6 +354,17 @@ export type SessionEvent =
354354
partialOutput: string;
355355
};
356356
}
357+
| {
358+
id: string;
359+
timestamp: string;
360+
parentId: string | null;
361+
ephemeral: true;
362+
type: "tool.execution_progress";
363+
data: {
364+
toolCallId: string;
365+
progressMessage: string;
366+
};
367+
}
357368
| {
358369
id: string;
359370
timestamp: string;

nodejs/src/sdkProtocolVersion.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* The SDK protocol version.
99
* This must match the version expected by the copilot-agent-runtime server.
1010
*/
11-
export const SDK_PROTOCOL_VERSION = 1;
11+
export const SDK_PROTOCOL_VERSION = 2;
1212

1313
/**
1414
* Gets the SDK protocol version.

0 commit comments

Comments
 (0)