Skip to content

Commit 4d26e30

Browse files
[Node] Add onElicitationRequest Callback for Elicitation Provider Support (#908)
* [Node] Add onElicitationRequest Callback for Elicitation Provider Support * React to runtime changes * Update to new CLI * Fix lint * Regen and CCR feedback * Mackinnon feedback
1 parent e3638da commit 4d26e30

File tree

19 files changed

+1064
-80
lines changed

19 files changed

+1064
-80
lines changed

dotnet/src/Generated/Rpc.cs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,6 +1044,42 @@ internal class SessionUiElicitationRequest
10441044
public SessionUiElicitationRequestRequestedSchema RequestedSchema { get => field ??= new(); set; }
10451045
}
10461046

1047+
/// <summary>RPC data type for SessionUiHandlePendingElicitation operations.</summary>
1048+
public class SessionUiHandlePendingElicitationResult
1049+
{
1050+
/// <summary>Whether the response was accepted. False if the request was already resolved by another client.</summary>
1051+
[JsonPropertyName("success")]
1052+
public bool Success { get; set; }
1053+
}
1054+
1055+
/// <summary>The elicitation response (accept with form values, decline, or cancel).</summary>
1056+
public class SessionUiHandlePendingElicitationRequestResult
1057+
{
1058+
/// <summary>The user's response: accept (submitted), decline (rejected), or cancel (dismissed).</summary>
1059+
[JsonPropertyName("action")]
1060+
public SessionUiElicitationResultAction Action { get; set; }
1061+
1062+
/// <summary>The form values submitted by the user (present when action is 'accept').</summary>
1063+
[JsonPropertyName("content")]
1064+
public Dictionary<string, object>? Content { get; set; }
1065+
}
1066+
1067+
/// <summary>RPC data type for SessionUiHandlePendingElicitation operations.</summary>
1068+
internal class SessionUiHandlePendingElicitationRequest
1069+
{
1070+
/// <summary>Target session identifier.</summary>
1071+
[JsonPropertyName("sessionId")]
1072+
public string SessionId { get; set; } = string.Empty;
1073+
1074+
/// <summary>The unique request ID from the elicitation.requested event.</summary>
1075+
[JsonPropertyName("requestId")]
1076+
public string RequestId { get; set; } = string.Empty;
1077+
1078+
/// <summary>The elicitation response (accept with form values, decline, or cancel).</summary>
1079+
[JsonPropertyName("result")]
1080+
public SessionUiHandlePendingElicitationRequestResult Result { get => field ??= new(); set; }
1081+
}
1082+
10471083
/// <summary>RPC data type for SessionPermissionsHandlePendingPermissionRequest operations.</summary>
10481084
public class SessionPermissionsHandlePendingPermissionRequestResult
10491085
{
@@ -1822,6 +1858,13 @@ public async Task<SessionUiElicitationResult> ElicitationAsync(string message, S
18221858
var request = new SessionUiElicitationRequest { SessionId = _sessionId, Message = message, RequestedSchema = requestedSchema };
18231859
return await CopilotClient.InvokeRpcAsync<SessionUiElicitationResult>(_rpc, "session.ui.elicitation", [request], cancellationToken);
18241860
}
1861+
1862+
/// <summary>Calls "session.ui.handlePendingElicitation".</summary>
1863+
public async Task<SessionUiHandlePendingElicitationResult> HandlePendingElicitationAsync(string requestId, SessionUiHandlePendingElicitationRequestResult result, CancellationToken cancellationToken = default)
1864+
{
1865+
var request = new SessionUiHandlePendingElicitationRequest { SessionId = _sessionId, RequestId = requestId, Result = result };
1866+
return await CopilotClient.InvokeRpcAsync<SessionUiHandlePendingElicitationResult>(_rpc, "session.ui.handlePendingElicitation", [request], cancellationToken);
1867+
}
18251868
}
18261869

18271870
/// <summary>Provides session-scoped Permissions APIs.</summary>
@@ -1961,6 +2004,9 @@ public async Task<SessionShellKillResult> KillAsync(string processId, SessionShe
19612004
[JsonSerializable(typeof(SessionUiElicitationRequest))]
19622005
[JsonSerializable(typeof(SessionUiElicitationRequestRequestedSchema))]
19632006
[JsonSerializable(typeof(SessionUiElicitationResult))]
2007+
[JsonSerializable(typeof(SessionUiHandlePendingElicitationRequest))]
2008+
[JsonSerializable(typeof(SessionUiHandlePendingElicitationRequestResult))]
2009+
[JsonSerializable(typeof(SessionUiHandlePendingElicitationResult))]
19642010
[JsonSerializable(typeof(SessionWorkspaceCreateFileRequest))]
19652011
[JsonSerializable(typeof(SessionWorkspaceCreateFileResult))]
19662012
[JsonSerializable(typeof(SessionWorkspaceListFilesRequest))]

dotnet/src/Generated/SessionEvents.cs

Lines changed: 134 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ namespace GitHub.Copilot.SDK;
2828
[JsonDerivedType(typeof(AssistantTurnEndEvent), "assistant.turn_end")]
2929
[JsonDerivedType(typeof(AssistantTurnStartEvent), "assistant.turn_start")]
3030
[JsonDerivedType(typeof(AssistantUsageEvent), "assistant.usage")]
31+
[JsonDerivedType(typeof(CapabilitiesChangedEvent), "capabilities.changed")]
3132
[JsonDerivedType(typeof(CommandCompletedEvent), "command.completed")]
3233
[JsonDerivedType(typeof(CommandExecuteEvent), "command.execute")]
3334
[JsonDerivedType(typeof(CommandQueuedEvent), "command.queued")]
@@ -45,6 +46,8 @@ namespace GitHub.Copilot.SDK;
4546
[JsonDerivedType(typeof(PendingMessagesModifiedEvent), "pending_messages.modified")]
4647
[JsonDerivedType(typeof(PermissionCompletedEvent), "permission.completed")]
4748
[JsonDerivedType(typeof(PermissionRequestedEvent), "permission.requested")]
49+
[JsonDerivedType(typeof(SamplingCompletedEvent), "sampling.completed")]
50+
[JsonDerivedType(typeof(SamplingRequestedEvent), "sampling.requested")]
4851
[JsonDerivedType(typeof(SessionBackgroundTasksChangedEvent), "session.background_tasks_changed")]
4952
[JsonDerivedType(typeof(SessionCompactionCompleteEvent), "session.compaction_complete")]
5053
[JsonDerivedType(typeof(SessionCompactionStartEvent), "session.compaction_start")]
@@ -60,6 +63,7 @@ namespace GitHub.Copilot.SDK;
6063
[JsonDerivedType(typeof(SessionModeChangedEvent), "session.mode_changed")]
6164
[JsonDerivedType(typeof(SessionModelChangeEvent), "session.model_change")]
6265
[JsonDerivedType(typeof(SessionPlanChangedEvent), "session.plan_changed")]
66+
[JsonDerivedType(typeof(SessionRemoteSteerableChangedEvent), "session.remote_steerable_changed")]
6367
[JsonDerivedType(typeof(SessionResumeEvent), "session.resume")]
6468
[JsonDerivedType(typeof(SessionShutdownEvent), "session.shutdown")]
6569
[JsonDerivedType(typeof(SessionSkillsLoadedEvent), "session.skills_loaded")]
@@ -151,6 +155,19 @@ public partial class SessionResumeEvent : SessionEvent
151155
public required SessionResumeData Data { get; set; }
152156
}
153157

158+
/// <summary>Notifies Mission Control that the session's remote steering capability has changed.</summary>
159+
/// <remarks>Represents the <c>session.remote_steerable_changed</c> event.</remarks>
160+
public partial class SessionRemoteSteerableChangedEvent : SessionEvent
161+
{
162+
/// <inheritdoc />
163+
[JsonIgnore]
164+
public override string Type => "session.remote_steerable_changed";
165+
166+
/// <summary>The <c>session.remote_steerable_changed</c> event payload.</summary>
167+
[JsonPropertyName("data")]
168+
public required SessionRemoteSteerableChangedData Data { get; set; }
169+
}
170+
154171
/// <summary>Error details for timeline display including message and optional diagnostic information.</summary>
155172
/// <remarks>Represents the <c>session.error</c> event.</remarks>
156173
public partial class SessionErrorEvent : SessionEvent
@@ -813,6 +830,32 @@ public partial class ElicitationCompletedEvent : SessionEvent
813830
public required ElicitationCompletedData Data { get; set; }
814831
}
815832

833+
/// <summary>Sampling request from an MCP server; contains the server name and a requestId for correlation.</summary>
834+
/// <remarks>Represents the <c>sampling.requested</c> event.</remarks>
835+
public partial class SamplingRequestedEvent : SessionEvent
836+
{
837+
/// <inheritdoc />
838+
[JsonIgnore]
839+
public override string Type => "sampling.requested";
840+
841+
/// <summary>The <c>sampling.requested</c> event payload.</summary>
842+
[JsonPropertyName("data")]
843+
public required SamplingRequestedData Data { get; set; }
844+
}
845+
846+
/// <summary>Sampling request completion notification signaling UI dismissal.</summary>
847+
/// <remarks>Represents the <c>sampling.completed</c> event.</remarks>
848+
public partial class SamplingCompletedEvent : SessionEvent
849+
{
850+
/// <inheritdoc />
851+
[JsonIgnore]
852+
public override string Type => "sampling.completed";
853+
854+
/// <summary>The <c>sampling.completed</c> event payload.</summary>
855+
[JsonPropertyName("data")]
856+
public required SamplingCompletedData Data { get; set; }
857+
}
858+
816859
/// <summary>OAuth authentication request for an MCP server.</summary>
817860
/// <remarks>Represents the <c>mcp.oauth_required</c> event.</remarks>
818861
public partial class McpOauthRequiredEvent : SessionEvent
@@ -917,6 +960,19 @@ public partial class CommandsChangedEvent : SessionEvent
917960
public required CommandsChangedData Data { get; set; }
918961
}
919962

963+
/// <summary>Session capability change notification.</summary>
964+
/// <remarks>Represents the <c>capabilities.changed</c> event.</remarks>
965+
public partial class CapabilitiesChangedEvent : SessionEvent
966+
{
967+
/// <inheritdoc />
968+
[JsonIgnore]
969+
public override string Type => "capabilities.changed";
970+
971+
/// <summary>The <c>capabilities.changed</c> event payload.</summary>
972+
[JsonPropertyName("data")]
973+
public required CapabilitiesChangedData Data { get; set; }
974+
}
975+
920976
/// <summary>Plan approval request with plan content and available user actions.</summary>
921977
/// <remarks>Represents the <c>exit_plan_mode.requested</c> event.</remarks>
922978
public partial class ExitPlanModeRequestedEvent : SessionEvent
@@ -1072,8 +1128,8 @@ public partial class SessionStartData
10721128

10731129
/// <summary>Whether this session supports remote steering via Mission Control.</summary>
10741130
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
1075-
[JsonPropertyName("steerable")]
1076-
public bool? Steerable { get; set; }
1131+
[JsonPropertyName("remoteSteerable")]
1132+
public bool? RemoteSteerable { get; set; }
10771133
}
10781134

10791135
/// <summary>Session resume metadata including current context and event count.</summary>
@@ -1106,6 +1162,19 @@ public partial class SessionResumeData
11061162
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
11071163
[JsonPropertyName("alreadyInUse")]
11081164
public bool? AlreadyInUse { get; set; }
1165+
1166+
/// <summary>Whether this session supports remote steering via Mission Control.</summary>
1167+
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
1168+
[JsonPropertyName("remoteSteerable")]
1169+
public bool? RemoteSteerable { get; set; }
1170+
}
1171+
1172+
/// <summary>Notifies Mission Control that the session's remote steering capability has changed.</summary>
1173+
public partial class SessionRemoteSteerableChangedData
1174+
{
1175+
/// <summary>Whether this session now supports remote steering via Mission Control.</summary>
1176+
[JsonPropertyName("remoteSteerable")]
1177+
public required bool RemoteSteerable { get; set; }
11091178
}
11101179

11111180
/// <summary>Error details for timeline display including message and optional diagnostic information.</summary>
@@ -1779,7 +1848,17 @@ public partial class AssistantUsageData
17791848
[JsonPropertyName("duration")]
17801849
public double? Duration { get; set; }
17811850

1782-
/// <summary>What initiated this API call (e.g., "sub-agent"); absent for user-initiated calls.</summary>
1851+
/// <summary>Time to first token in milliseconds. Only available for streaming requests.</summary>
1852+
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
1853+
[JsonPropertyName("ttftMs")]
1854+
public double? TtftMs { get; set; }
1855+
1856+
/// <summary>Average inter-token latency in milliseconds. Only available for streaming requests.</summary>
1857+
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
1858+
[JsonPropertyName("interTokenLatencyMs")]
1859+
public double? InterTokenLatencyMs { get; set; }
1860+
1861+
/// <summary>What initiated this API call (e.g., "sub-agent", "mcp-sampling"); absent for user-initiated calls.</summary>
17831862
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
17841863
[JsonPropertyName("initiator")]
17851864
public string? Initiator { get; set; }
@@ -2277,6 +2356,30 @@ public partial class ElicitationCompletedData
22772356
public required string RequestId { get; set; }
22782357
}
22792358

2359+
/// <summary>Sampling request from an MCP server; contains the server name and a requestId for correlation.</summary>
2360+
public partial class SamplingRequestedData
2361+
{
2362+
/// <summary>Unique identifier for this sampling request; used to respond via session.respondToSampling().</summary>
2363+
[JsonPropertyName("requestId")]
2364+
public required string RequestId { get; set; }
2365+
2366+
/// <summary>Name of the MCP server that initiated the sampling request.</summary>
2367+
[JsonPropertyName("serverName")]
2368+
public required string ServerName { get; set; }
2369+
2370+
/// <summary>The JSON-RPC request ID from the MCP protocol.</summary>
2371+
[JsonPropertyName("mcpRequestId")]
2372+
public required object McpRequestId { get; set; }
2373+
}
2374+
2375+
/// <summary>Sampling request completion notification signaling UI dismissal.</summary>
2376+
public partial class SamplingCompletedData
2377+
{
2378+
/// <summary>Request ID of the resolved sampling request; clients should dismiss any UI for this request.</summary>
2379+
[JsonPropertyName("requestId")]
2380+
public required string RequestId { get; set; }
2381+
}
2382+
22802383
/// <summary>OAuth authentication request for an MCP server.</summary>
22812384
public partial class McpOauthRequiredData
22822385
{
@@ -2397,6 +2500,15 @@ public partial class CommandsChangedData
23972500
public required CommandsChangedDataCommandsItem[] Commands { get; set; }
23982501
}
23992502

2503+
/// <summary>Session capability change notification.</summary>
2504+
public partial class CapabilitiesChangedData
2505+
{
2506+
/// <summary>UI capability changes.</summary>
2507+
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
2508+
[JsonPropertyName("ui")]
2509+
public CapabilitiesChangedDataUi? Ui { get; set; }
2510+
}
2511+
24002512
/// <summary>Plan approval request with plan content and available user actions.</summary>
24012513
public partial class ExitPlanModeRequestedData
24022514
{
@@ -3591,6 +3703,16 @@ public partial class CommandsChangedDataCommandsItem
35913703
public string? Description { get; set; }
35923704
}
35933705

3706+
/// <summary>UI capability changes.</summary>
3707+
/// <remarks>Nested data type for <c>CapabilitiesChangedDataUi</c>.</remarks>
3708+
public partial class CapabilitiesChangedDataUi
3709+
{
3710+
/// <summary>Whether elicitation is now supported.</summary>
3711+
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
3712+
[JsonPropertyName("elicitation")]
3713+
public bool? Elicitation { get; set; }
3714+
}
3715+
35943716
/// <summary>Nested data type for <c>SessionSkillsLoadedDataSkillsItem</c>.</summary>
35953717
public partial class SessionSkillsLoadedDataSkillsItem
35963718
{
@@ -3955,6 +4077,9 @@ public enum SessionExtensionsLoadedDataExtensionsItemStatus
39554077
[JsonSerializable(typeof(AssistantUsageDataCopilotUsage))]
39564078
[JsonSerializable(typeof(AssistantUsageDataCopilotUsageTokenDetailsItem))]
39574079
[JsonSerializable(typeof(AssistantUsageEvent))]
4080+
[JsonSerializable(typeof(CapabilitiesChangedData))]
4081+
[JsonSerializable(typeof(CapabilitiesChangedDataUi))]
4082+
[JsonSerializable(typeof(CapabilitiesChangedEvent))]
39584083
[JsonSerializable(typeof(CommandCompletedData))]
39594084
[JsonSerializable(typeof(CommandCompletedEvent))]
39604085
[JsonSerializable(typeof(CommandExecuteData))]
@@ -4005,6 +4130,10 @@ public enum SessionExtensionsLoadedDataExtensionsItemStatus
40054130
[JsonSerializable(typeof(PermissionRequestWrite))]
40064131
[JsonSerializable(typeof(PermissionRequestedData))]
40074132
[JsonSerializable(typeof(PermissionRequestedEvent))]
4133+
[JsonSerializable(typeof(SamplingCompletedData))]
4134+
[JsonSerializable(typeof(SamplingCompletedEvent))]
4135+
[JsonSerializable(typeof(SamplingRequestedData))]
4136+
[JsonSerializable(typeof(SamplingRequestedEvent))]
40084137
[JsonSerializable(typeof(SessionBackgroundTasksChangedData))]
40094138
[JsonSerializable(typeof(SessionBackgroundTasksChangedEvent))]
40104139
[JsonSerializable(typeof(SessionCompactionCompleteData))]
@@ -4044,6 +4173,8 @@ public enum SessionExtensionsLoadedDataExtensionsItemStatus
40444173
[JsonSerializable(typeof(SessionModelChangeEvent))]
40454174
[JsonSerializable(typeof(SessionPlanChangedData))]
40464175
[JsonSerializable(typeof(SessionPlanChangedEvent))]
4176+
[JsonSerializable(typeof(SessionRemoteSteerableChangedData))]
4177+
[JsonSerializable(typeof(SessionRemoteSteerableChangedEvent))]
40474178
[JsonSerializable(typeof(SessionResumeData))]
40484179
[JsonSerializable(typeof(SessionResumeDataContext))]
40494180
[JsonSerializable(typeof(SessionResumeEvent))]

0 commit comments

Comments
 (0)