-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy pathsession_events.rs
More file actions
5602 lines (5284 loc) · 239 KB
/
Copy pathsession_events.rs
File metadata and controls
5602 lines (5284 loc) · 239 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//! Auto-generated from session-events.schema.json — do not edit manually.
#![allow(deprecated)]
use std::collections::HashMap;
use serde::{Deserialize, Serialize};
use crate::types::{RequestId, SessionId};
/// Identifies the kind of session event.
#[derive(Debug, Clone, Default, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum SessionEventType {
#[serde(rename = "session.start")]
SessionStart,
#[serde(rename = "session.resume")]
SessionResume,
#[serde(rename = "session.remote_steerable_changed")]
SessionRemoteSteerableChanged,
#[serde(rename = "session.error")]
SessionError,
#[serde(rename = "session.idle")]
SessionIdle,
#[serde(rename = "session.title_changed")]
SessionTitleChanged,
#[serde(rename = "session.schedule_created")]
SessionScheduleCreated,
#[serde(rename = "session.schedule_cancelled")]
SessionScheduleCancelled,
#[serde(rename = "session.schedule_rearmed")]
SessionScheduleRearmed,
#[serde(rename = "session.autopilot_objective_changed")]
SessionAutopilotObjectiveChanged,
#[serde(rename = "session.info")]
SessionInfo,
#[serde(rename = "session.warning")]
SessionWarning,
#[serde(rename = "session.model_change")]
SessionModelChange,
#[serde(rename = "session.mode_changed")]
SessionModeChanged,
#[serde(rename = "session.session_limits_changed")]
SessionSessionLimitsChanged,
#[serde(rename = "session.permissions_changed")]
SessionPermissionsChanged,
#[serde(rename = "session.plan_changed")]
SessionPlanChanged,
#[serde(rename = "session.todos_changed")]
SessionTodosChanged,
#[serde(rename = "session.workspace_file_changed")]
SessionWorkspaceFileChanged,
#[serde(rename = "session.handoff")]
SessionHandoff,
#[serde(rename = "session.truncation")]
SessionTruncation,
#[serde(rename = "session.snapshot_rewind")]
SessionSnapshotRewind,
#[serde(rename = "session.shutdown")]
SessionShutdown,
#[serde(rename = "session.usage_checkpoint")]
SessionUsageCheckpoint,
#[serde(rename = "session.context_changed")]
SessionContextChanged,
#[serde(rename = "session.usage_info")]
SessionUsageInfo,
#[serde(rename = "session.compaction_start")]
SessionCompactionStart,
#[serde(rename = "session.compaction_complete")]
SessionCompactionComplete,
#[serde(rename = "session.task_complete")]
SessionTaskComplete,
#[serde(rename = "user.message")]
UserMessage,
#[serde(rename = "pending_messages.modified")]
PendingMessagesModified,
#[serde(rename = "assistant.turn_start")]
AssistantTurnStart,
#[serde(rename = "assistant.intent")]
AssistantIntent,
#[serde(rename = "assistant.reasoning")]
AssistantReasoning,
#[serde(rename = "assistant.reasoning_delta")]
AssistantReasoningDelta,
#[serde(rename = "assistant.tool_call_delta")]
AssistantToolCallDelta,
#[serde(rename = "assistant.streaming_delta")]
AssistantStreamingDelta,
#[serde(rename = "assistant.message")]
AssistantMessage,
#[serde(rename = "assistant.message_start")]
AssistantMessageStart,
#[serde(rename = "assistant.message_delta")]
AssistantMessageDelta,
#[serde(rename = "assistant.turn_end")]
AssistantTurnEnd,
#[serde(rename = "assistant.idle")]
AssistantIdle,
#[serde(rename = "assistant.usage")]
AssistantUsage,
#[serde(rename = "model.call_failure")]
ModelCallFailure,
#[serde(rename = "abort")]
Abort,
#[serde(rename = "tool.user_requested")]
ToolUserRequested,
#[serde(rename = "tool.execution_start")]
ToolExecutionStart,
#[serde(rename = "tool.execution_partial_result")]
ToolExecutionPartialResult,
#[serde(rename = "tool.execution_progress")]
ToolExecutionProgress,
#[serde(rename = "tool.execution_complete")]
ToolExecutionComplete,
#[serde(rename = "skill.invoked")]
SkillInvoked,
#[serde(rename = "subagent.started")]
SubagentStarted,
#[serde(rename = "subagent.completed")]
SubagentCompleted,
#[serde(rename = "subagent.failed")]
SubagentFailed,
#[serde(rename = "subagent.selected")]
SubagentSelected,
#[serde(rename = "subagent.deselected")]
SubagentDeselected,
#[serde(rename = "hook.start")]
HookStart,
#[serde(rename = "hook.end")]
HookEnd,
#[serde(rename = "hook.progress")]
HookProgress,
///
/// <div class="warning">
///
/// **Experimental.** This type is part of an experimental wire-protocol surface
/// and may change or be removed in future SDK or CLI releases.
///
/// </div>
#[serde(rename = "session.binary_asset")]
SessionBinaryAsset,
#[serde(rename = "system.message")]
SystemMessage,
#[serde(rename = "system.notification")]
SystemNotification,
#[serde(rename = "permission.requested")]
PermissionRequested,
#[serde(rename = "permission.completed")]
PermissionCompleted,
#[serde(rename = "user_input.requested")]
UserInputRequested,
#[serde(rename = "user_input.completed")]
UserInputCompleted,
#[serde(rename = "elicitation.requested")]
ElicitationRequested,
#[serde(rename = "elicitation.completed")]
ElicitationCompleted,
#[serde(rename = "sampling.requested")]
SamplingRequested,
#[serde(rename = "sampling.completed")]
SamplingCompleted,
#[serde(rename = "mcp.oauth_required")]
McpOauthRequired,
#[serde(rename = "mcp.oauth_completed")]
McpOauthCompleted,
#[serde(rename = "mcp.headers_refresh_required")]
McpHeadersRefreshRequired,
#[serde(rename = "mcp.headers_refresh_completed")]
McpHeadersRefreshCompleted,
#[serde(rename = "session.custom_notification")]
SessionCustomNotification,
#[serde(rename = "external_tool.requested")]
ExternalToolRequested,
#[serde(rename = "external_tool.completed")]
ExternalToolCompleted,
#[serde(rename = "command.queued")]
CommandQueued,
#[serde(rename = "command.execute")]
CommandExecute,
#[serde(rename = "command.completed")]
CommandCompleted,
#[serde(rename = "auto_mode_switch.requested")]
AutoModeSwitchRequested,
#[serde(rename = "auto_mode_switch.completed")]
AutoModeSwitchCompleted,
#[serde(rename = "session_limits_exhausted.requested")]
SessionLimitsExhaustedRequested,
#[serde(rename = "session_limits_exhausted.completed")]
SessionLimitsExhaustedCompleted,
#[serde(rename = "commands.changed")]
CommandsChanged,
#[serde(rename = "capabilities.changed")]
CapabilitiesChanged,
#[serde(rename = "exit_plan_mode.requested")]
ExitPlanModeRequested,
#[serde(rename = "exit_plan_mode.completed")]
ExitPlanModeCompleted,
#[serde(rename = "session.tools_updated")]
SessionToolsUpdated,
#[serde(rename = "session.background_tasks_changed")]
SessionBackgroundTasksChanged,
#[serde(rename = "session.skills_loaded")]
SessionSkillsLoaded,
#[serde(rename = "session.custom_agents_updated")]
SessionCustomAgentsUpdated,
#[serde(rename = "session.mcp_servers_loaded")]
SessionMcpServersLoaded,
#[serde(rename = "session.mcp_server_status_changed")]
SessionMcpServerStatusChanged,
#[serde(rename = "session.extensions_loaded")]
SessionExtensionsLoaded,
///
/// <div class="warning">
///
/// **Experimental.** This type is part of an experimental wire-protocol surface
/// and may change or be removed in future SDK or CLI releases.
///
/// </div>
#[serde(rename = "session.canvas.opened")]
SessionCanvasOpened,
///
/// <div class="warning">
///
/// **Experimental.** This type is part of an experimental wire-protocol surface
/// and may change or be removed in future SDK or CLI releases.
///
/// </div>
#[serde(rename = "session.canvas.registry_changed")]
SessionCanvasRegistryChanged,
///
/// <div class="warning">
///
/// **Experimental.** This type is part of an experimental wire-protocol surface
/// and may change or be removed in future SDK or CLI releases.
///
/// </div>
#[serde(rename = "session.canvas.closed")]
SessionCanvasClosed,
///
/// <div class="warning">
///
/// **Experimental.** This type is part of an experimental wire-protocol surface
/// and may change or be removed in future SDK or CLI releases.
///
/// </div>
#[serde(rename = "session.canvas.unavailable")]
SessionCanvasUnavailable,
///
/// <div class="warning">
///
/// **Experimental.** This type is part of an experimental wire-protocol surface
/// and may change or be removed in future SDK or CLI releases.
///
/// </div>
#[serde(rename = "session.canvas.recorded")]
SessionCanvasRecorded,
///
/// <div class="warning">
///
/// **Experimental.** This type is part of an experimental wire-protocol surface
/// and may change or be removed in future SDK or CLI releases.
///
/// </div>
#[serde(rename = "session.canvas.removed")]
SessionCanvasRemoved,
#[serde(rename = "session.extensions.attachments_pushed")]
SessionExtensionsAttachmentsPushed,
#[serde(rename = "mcp_app.tool_call_complete")]
McpAppToolCallComplete,
/// Unknown event type for forward compatibility.
#[default]
#[serde(other)]
Unknown,
}
/// Typed session event data, discriminated by the event `type` field.
///
/// Use with [`TypedSessionEvent`] for fully typed event handling.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(tag = "type", content = "data")]
pub enum SessionEventData {
#[serde(rename = "session.start")]
SessionStart(SessionStartData),
#[serde(rename = "session.resume")]
SessionResume(SessionResumeData),
#[serde(rename = "session.remote_steerable_changed")]
SessionRemoteSteerableChanged(SessionRemoteSteerableChangedData),
#[serde(rename = "session.error")]
SessionError(SessionErrorData),
#[serde(rename = "session.idle")]
SessionIdle(SessionIdleData),
#[serde(rename = "session.title_changed")]
SessionTitleChanged(SessionTitleChangedData),
#[serde(rename = "session.schedule_created")]
SessionScheduleCreated(SessionScheduleCreatedData),
#[serde(rename = "session.schedule_cancelled")]
SessionScheduleCancelled(SessionScheduleCancelledData),
#[serde(rename = "session.schedule_rearmed")]
SessionScheduleRearmed(SessionScheduleRearmedData),
#[serde(rename = "session.autopilot_objective_changed")]
SessionAutopilotObjectiveChanged(SessionAutopilotObjectiveChangedData),
#[serde(rename = "session.info")]
SessionInfo(SessionInfoData),
#[serde(rename = "session.warning")]
SessionWarning(SessionWarningData),
#[serde(rename = "session.model_change")]
SessionModelChange(SessionModelChangeData),
#[serde(rename = "session.mode_changed")]
SessionModeChanged(SessionModeChangedData),
#[serde(rename = "session.session_limits_changed")]
SessionSessionLimitsChanged(SessionSessionLimitsChangedData),
#[serde(rename = "session.permissions_changed")]
SessionPermissionsChanged(SessionPermissionsChangedData),
#[serde(rename = "session.plan_changed")]
SessionPlanChanged(SessionPlanChangedData),
#[serde(rename = "session.todos_changed")]
SessionTodosChanged(SessionTodosChangedData),
#[serde(rename = "session.workspace_file_changed")]
SessionWorkspaceFileChanged(SessionWorkspaceFileChangedData),
#[serde(rename = "session.handoff")]
SessionHandoff(SessionHandoffData),
#[serde(rename = "session.truncation")]
SessionTruncation(SessionTruncationData),
#[serde(rename = "session.snapshot_rewind")]
SessionSnapshotRewind(SessionSnapshotRewindData),
#[serde(rename = "session.shutdown")]
SessionShutdown(SessionShutdownData),
#[serde(rename = "session.usage_checkpoint")]
SessionUsageCheckpoint(SessionUsageCheckpointData),
#[serde(rename = "session.context_changed")]
SessionContextChanged(SessionContextChangedData),
#[serde(rename = "session.usage_info")]
SessionUsageInfo(SessionUsageInfoData),
#[serde(rename = "session.compaction_start")]
SessionCompactionStart(SessionCompactionStartData),
#[serde(rename = "session.compaction_complete")]
SessionCompactionComplete(SessionCompactionCompleteData),
#[serde(rename = "session.task_complete")]
SessionTaskComplete(SessionTaskCompleteData),
#[serde(rename = "user.message")]
UserMessage(UserMessageData),
#[serde(rename = "pending_messages.modified")]
PendingMessagesModified(PendingMessagesModifiedData),
#[serde(rename = "assistant.turn_start")]
AssistantTurnStart(AssistantTurnStartData),
#[serde(rename = "assistant.intent")]
AssistantIntent(AssistantIntentData),
#[serde(rename = "assistant.reasoning")]
AssistantReasoning(AssistantReasoningData),
#[serde(rename = "assistant.reasoning_delta")]
AssistantReasoningDelta(AssistantReasoningDeltaData),
#[serde(rename = "assistant.tool_call_delta")]
AssistantToolCallDelta(AssistantToolCallDeltaData),
#[serde(rename = "assistant.streaming_delta")]
AssistantStreamingDelta(AssistantStreamingDeltaData),
#[serde(rename = "assistant.message")]
AssistantMessage(AssistantMessageData),
#[serde(rename = "assistant.message_start")]
AssistantMessageStart(AssistantMessageStartData),
#[serde(rename = "assistant.message_delta")]
AssistantMessageDelta(AssistantMessageDeltaData),
#[serde(rename = "assistant.turn_end")]
AssistantTurnEnd(AssistantTurnEndData),
#[serde(rename = "assistant.idle")]
AssistantIdle(AssistantIdleData),
#[serde(rename = "assistant.usage")]
AssistantUsage(AssistantUsageData),
#[serde(rename = "model.call_failure")]
ModelCallFailure(ModelCallFailureData),
#[serde(rename = "abort")]
Abort(AbortData),
#[serde(rename = "tool.user_requested")]
ToolUserRequested(ToolUserRequestedData),
#[serde(rename = "tool.execution_start")]
ToolExecutionStart(ToolExecutionStartData),
#[serde(rename = "tool.execution_partial_result")]
ToolExecutionPartialResult(ToolExecutionPartialResultData),
#[serde(rename = "tool.execution_progress")]
ToolExecutionProgress(ToolExecutionProgressData),
#[serde(rename = "tool.execution_complete")]
ToolExecutionComplete(ToolExecutionCompleteData),
#[serde(rename = "skill.invoked")]
SkillInvoked(SkillInvokedData),
#[serde(rename = "subagent.started")]
SubagentStarted(SubagentStartedData),
#[serde(rename = "subagent.completed")]
SubagentCompleted(SubagentCompletedData),
#[serde(rename = "subagent.failed")]
SubagentFailed(SubagentFailedData),
#[serde(rename = "subagent.selected")]
SubagentSelected(SubagentSelectedData),
#[serde(rename = "subagent.deselected")]
SubagentDeselected(SubagentDeselectedData),
#[serde(rename = "hook.start")]
HookStart(HookStartData),
#[serde(rename = "hook.end")]
HookEnd(HookEndData),
#[serde(rename = "hook.progress")]
HookProgress(HookProgressData),
#[serde(rename = "session.binary_asset")]
SessionBinaryAsset(SessionBinaryAssetData),
#[serde(rename = "system.message")]
SystemMessage(SystemMessageData),
#[serde(rename = "system.notification")]
SystemNotification(SystemNotificationData),
#[serde(rename = "permission.requested")]
PermissionRequested(PermissionRequestedData),
#[serde(rename = "permission.completed")]
PermissionCompleted(PermissionCompletedData),
#[serde(rename = "user_input.requested")]
UserInputRequested(UserInputRequestedData),
#[serde(rename = "user_input.completed")]
UserInputCompleted(UserInputCompletedData),
#[serde(rename = "elicitation.requested")]
ElicitationRequested(ElicitationRequestedData),
#[serde(rename = "elicitation.completed")]
ElicitationCompleted(ElicitationCompletedData),
#[serde(rename = "sampling.requested")]
SamplingRequested(SamplingRequestedData),
#[serde(rename = "sampling.completed")]
SamplingCompleted(SamplingCompletedData),
#[serde(rename = "mcp.oauth_required")]
McpOauthRequired(McpOauthRequiredData),
#[serde(rename = "mcp.oauth_completed")]
McpOauthCompleted(McpOauthCompletedData),
#[serde(rename = "mcp.headers_refresh_required")]
McpHeadersRefreshRequired(McpHeadersRefreshRequiredData),
#[serde(rename = "mcp.headers_refresh_completed")]
McpHeadersRefreshCompleted(McpHeadersRefreshCompletedData),
#[serde(rename = "session.custom_notification")]
SessionCustomNotification(SessionCustomNotificationData),
#[serde(rename = "external_tool.requested")]
ExternalToolRequested(ExternalToolRequestedData),
#[serde(rename = "external_tool.completed")]
ExternalToolCompleted(ExternalToolCompletedData),
#[serde(rename = "command.queued")]
CommandQueued(CommandQueuedData),
#[serde(rename = "command.execute")]
CommandExecute(CommandExecuteData),
#[serde(rename = "command.completed")]
CommandCompleted(CommandCompletedData),
#[serde(rename = "auto_mode_switch.requested")]
AutoModeSwitchRequested(AutoModeSwitchRequestedData),
#[serde(rename = "auto_mode_switch.completed")]
AutoModeSwitchCompleted(AutoModeSwitchCompletedData),
#[serde(rename = "session_limits_exhausted.requested")]
SessionLimitsExhaustedRequested(SessionLimitsExhaustedRequestedData),
#[serde(rename = "session_limits_exhausted.completed")]
SessionLimitsExhaustedCompleted(SessionLimitsExhaustedCompletedData),
#[serde(rename = "commands.changed")]
CommandsChanged(CommandsChangedData),
#[serde(rename = "capabilities.changed")]
CapabilitiesChanged(CapabilitiesChangedData),
#[serde(rename = "exit_plan_mode.requested")]
ExitPlanModeRequested(ExitPlanModeRequestedData),
#[serde(rename = "exit_plan_mode.completed")]
ExitPlanModeCompleted(ExitPlanModeCompletedData),
#[serde(rename = "session.tools_updated")]
SessionToolsUpdated(SessionToolsUpdatedData),
#[serde(rename = "session.background_tasks_changed")]
SessionBackgroundTasksChanged(SessionBackgroundTasksChangedData),
#[serde(rename = "session.skills_loaded")]
SessionSkillsLoaded(SessionSkillsLoadedData),
#[serde(rename = "session.custom_agents_updated")]
SessionCustomAgentsUpdated(SessionCustomAgentsUpdatedData),
#[serde(rename = "session.mcp_servers_loaded")]
SessionMcpServersLoaded(SessionMcpServersLoadedData),
#[serde(rename = "session.mcp_server_status_changed")]
SessionMcpServerStatusChanged(SessionMcpServerStatusChangedData),
#[serde(rename = "session.extensions_loaded")]
SessionExtensionsLoaded(SessionExtensionsLoadedData),
///
/// <div class="warning">
///
/// **Experimental.** This type is part of an experimental wire-protocol surface
/// and may change or be removed in future SDK or CLI releases.
///
/// </div>
#[serde(rename = "session.canvas.opened")]
SessionCanvasOpened(SessionCanvasOpenedData),
///
/// <div class="warning">
///
/// **Experimental.** This type is part of an experimental wire-protocol surface
/// and may change or be removed in future SDK or CLI releases.
///
/// </div>
#[serde(rename = "session.canvas.registry_changed")]
SessionCanvasRegistryChanged(SessionCanvasRegistryChangedData),
///
/// <div class="warning">
///
/// **Experimental.** This type is part of an experimental wire-protocol surface
/// and may change or be removed in future SDK or CLI releases.
///
/// </div>
#[serde(rename = "session.canvas.closed")]
SessionCanvasClosed(SessionCanvasClosedData),
///
/// <div class="warning">
///
/// **Experimental.** This type is part of an experimental wire-protocol surface
/// and may change or be removed in future SDK or CLI releases.
///
/// </div>
#[serde(rename = "session.canvas.unavailable")]
SessionCanvasUnavailable(SessionCanvasUnavailableData),
///
/// <div class="warning">
///
/// **Experimental.** This type is part of an experimental wire-protocol surface
/// and may change or be removed in future SDK or CLI releases.
///
/// </div>
#[serde(rename = "session.canvas.recorded")]
SessionCanvasRecorded(SessionCanvasRecordedData),
///
/// <div class="warning">
///
/// **Experimental.** This type is part of an experimental wire-protocol surface
/// and may change or be removed in future SDK or CLI releases.
///
/// </div>
#[serde(rename = "session.canvas.removed")]
SessionCanvasRemoved(SessionCanvasRemovedData),
#[serde(rename = "session.extensions.attachments_pushed")]
SessionExtensionsAttachmentsPushed(SessionExtensionsAttachmentsPushedData),
#[serde(rename = "mcp_app.tool_call_complete")]
McpAppToolCallComplete(McpAppToolCallCompleteData),
}
/// A session event with typed data payload.
///
/// The common event fields (id, timestamp, parentId, ephemeral, agentId)
/// are available directly. The event-specific data is in the `payload`
/// field as a [`SessionEventData`] enum.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct TypedSessionEvent {
/// Unique event identifier (UUID v4).
pub id: String,
/// ISO 8601 timestamp when the event was created.
pub timestamp: String,
/// ID of the preceding event in the chain.
#[serde(skip_serializing_if = "Option::is_none")]
pub parent_id: Option<String>,
/// When true, the event is transient and not persisted.
#[serde(skip_serializing_if = "Option::is_none")]
pub ephemeral: Option<bool>,
/// Sub-agent instance identifier. Absent for events from the root /
/// main agent and session-level events.
#[serde(skip_serializing_if = "Option::is_none")]
pub agent_id: Option<String>,
/// The typed event payload (discriminated by event type).
#[serde(flatten)]
pub payload: SessionEventData,
}
/// Working directory and git context at session start
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct WorkingDirectoryContext {
/// Base commit of current git branch at session start time
#[serde(skip_serializing_if = "Option::is_none")]
pub base_commit: Option<String>,
/// Current git branch name
#[serde(skip_serializing_if = "Option::is_none")]
pub branch: Option<String>,
/// Current working directory path
pub cwd: String,
/// Root directory of the git repository, resolved via git rev-parse
#[serde(skip_serializing_if = "Option::is_none")]
pub git_root: Option<String>,
/// Head commit of current git branch at session start time
#[serde(skip_serializing_if = "Option::is_none")]
pub head_commit: Option<String>,
/// Hosting platform type of the repository (github or ado)
#[serde(skip_serializing_if = "Option::is_none")]
pub host_type: Option<WorkingDirectoryContextHostType>,
/// Repository identifier derived from the git remote URL ("owner/name" for GitHub, "org/project/repo" for Azure DevOps)
#[serde(skip_serializing_if = "Option::is_none")]
pub repository: Option<String>,
/// Raw host string from the git remote URL (e.g. "github.com", "mycompany.ghe.com", "dev.azure.com")
#[serde(skip_serializing_if = "Option::is_none")]
pub repository_host: Option<String>,
}
/// Optional session limits.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionLimitsConfig {
/// Maximum AI Credits allowed across the session's current accounting window.
#[serde(skip_serializing_if = "Option::is_none")]
pub max_ai_credits: Option<f64>,
}
/// Session event "session.start". Session initialization metadata including context and configuration
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionStartData {
/// Whether the session was already in use by another client at start time
#[serde(skip_serializing_if = "Option::is_none")]
pub already_in_use: Option<bool>,
/// Working directory and git context at session start
#[serde(skip_serializing_if = "Option::is_none")]
pub context: Option<WorkingDirectoryContext>,
/// Context tier selected at session creation time for models with tiered context pricing; null when no tier is selected (e.g., non-tiered model)
#[serde(skip_serializing_if = "Option::is_none")]
pub context_tier: Option<ContextTier>,
/// Version string of the Copilot application
pub copilot_version: String,
/// When set, identifies a parent session whose context this session continues — e.g., a detached headless rem-agent run launched on the parent's interactive shutdown. Telemetry from this session is reported under the parent's session_id.
#[serde(skip_serializing_if = "Option::is_none")]
pub detached_from_spawning_parent_session_id: Option<String>,
/// Identifier of the software producing the events (e.g., "copilot-agent")
pub producer: String,
/// Reasoning effort level used for model calls, if applicable (e.g. "none", "low", "medium", "high", "xhigh", "max")
#[serde(skip_serializing_if = "Option::is_none")]
pub reasoning_effort: Option<String>,
/// Reasoning summary mode used for model calls, if applicable (e.g. "none", "concise", "detailed")
#[serde(skip_serializing_if = "Option::is_none")]
pub reasoning_summary: Option<ReasoningSummary>,
/// Whether this session supports remote steering via GitHub
#[serde(skip_serializing_if = "Option::is_none")]
pub remote_steerable: Option<bool>,
/// Model selected at session creation time, if any
#[serde(skip_serializing_if = "Option::is_none")]
pub selected_model: Option<String>,
/// Unique identifier for the session
pub session_id: SessionId,
/// Session limits configured at session creation time, if any
#[serde(skip_serializing_if = "Option::is_none")]
pub session_limits: Option<SessionLimitsConfig>,
/// ISO 8601 timestamp when the session was created
pub start_time: String,
/// Output verbosity level used for model calls, if applicable (e.g. "low", "medium", "high")
#[serde(skip_serializing_if = "Option::is_none")]
pub verbosity: Option<Verbosity>,
/// Schema version number for the session event format
pub version: i64,
}
/// Session event "session.resume". Session resume metadata including current context and event count
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionResumeData {
/// Whether the session was already in use by another client at resume time
#[serde(skip_serializing_if = "Option::is_none")]
pub already_in_use: Option<bool>,
/// Updated working directory and git context at resume time
#[serde(skip_serializing_if = "Option::is_none")]
pub context: Option<WorkingDirectoryContext>,
/// Context tier currently selected at resume time; null when no tier is active
#[serde(skip_serializing_if = "Option::is_none")]
pub context_tier: Option<ContextTier>,
/// When true, tool calls and permission requests left in flight by the previous session lifetime remain pending after resume and the agentic loop awaits their results. User sends are queued behind the pending work until all such requests reach a terminal state. When false (the default), any such tool calls and permission requests are immediately marked as interrupted on resume.
#[serde(skip_serializing_if = "Option::is_none")]
pub continue_pending_work: Option<bool>,
/// Total number of persisted events in the session at the time of resume
pub event_count: i64,
/// On-disk byte size of the session's persisted events.jsonl file at resume time; omitted when the file does not exist or cannot be stat'd
#[serde(skip_serializing_if = "Option::is_none")]
pub events_file_size_bytes: Option<i64>,
/// Reasoning effort level used for model calls, if applicable (e.g. "none", "low", "medium", "high", "xhigh", "max")
#[serde(skip_serializing_if = "Option::is_none")]
pub reasoning_effort: Option<String>,
/// Reasoning summary mode used for model calls, if applicable (e.g. "none", "concise", "detailed")
#[serde(skip_serializing_if = "Option::is_none")]
pub reasoning_summary: Option<ReasoningSummary>,
/// Whether this session supports remote steering via GitHub
#[serde(skip_serializing_if = "Option::is_none")]
pub remote_steerable: Option<bool>,
/// ISO 8601 timestamp when the session was resumed
pub resume_time: String,
/// Model currently selected at resume time
#[serde(skip_serializing_if = "Option::is_none")]
pub selected_model: Option<String>,
/// Session limits currently configured at resume time; null when no limits are active
#[serde(skip_serializing_if = "Option::is_none")]
pub session_limits: Option<SessionLimitsConfig>,
/// True when this resume attached to a session that the runtime already had running in-memory (for example, an extension joining a session another client was actively driving). False (or omitted) for cold resumes — the runtime had to reconstitute the session from its persisted event log.
#[serde(skip_serializing_if = "Option::is_none")]
pub session_was_active: Option<bool>,
/// Output verbosity level used for model calls, if applicable (e.g. "low", "medium", "high")
#[serde(skip_serializing_if = "Option::is_none")]
pub verbosity: Option<Verbosity>,
}
/// Session event "session.remote_steerable_changed". Notifies that the session's remote steering capability has changed
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionRemoteSteerableChangedData {
/// Whether this session now supports remote steering via GitHub
pub remote_steerable: bool,
}
/// Session event "session.error". Error details for timeline display including message and optional diagnostic information
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionErrorData {
/// Only set on `errorType: "rate_limit"`. When `true`, the runtime will follow this error with an `auto_mode_switch.requested` event (or silently switch if `continueOnAutoMode` is enabled). UI clients can use this flag to suppress duplicate rendering of the rate-limit error when they show their own auto-mode-switch prompt.
#[serde(skip_serializing_if = "Option::is_none")]
pub eligible_for_auto_switch: Option<bool>,
/// Fine-grained error code from the upstream provider, when available. For `errorType: "rate_limit"`, this is one of the `RateLimitErrorCode` values (e.g., `"user_weekly_rate_limited"`, `"user_global_rate_limited"`, `"rate_limited"`, `"user_model_rate_limited"`, `"integration_rate_limited"`). For `errorType: "quota"`, this is the CAPI quota error code (e.g., `"quota_exceeded"`, `"session_quota_exceeded"`, `"billing_not_configured"`).
#[serde(skip_serializing_if = "Option::is_none")]
pub error_code: Option<String>,
/// Category of error (e.g., "authentication", "authorization", "quota", "rate_limit", "context_limit", "query")
pub error_type: String,
/// Human-readable error message
pub message: String,
/// GitHub request tracing ID (x-github-request-id header) for correlating with server-side logs
#[serde(skip_serializing_if = "Option::is_none")]
pub provider_call_id: Option<String>,
/// Copilot service request ID (x-copilot-service-request-id header) for CAPI log correlation
#[serde(skip_serializing_if = "Option::is_none")]
pub service_request_id: Option<String>,
/// Error stack trace, when available
#[serde(skip_serializing_if = "Option::is_none")]
pub stack: Option<String>,
/// HTTP status code from the upstream request, if applicable
#[serde(skip_serializing_if = "Option::is_none")]
pub status_code: Option<i32>,
/// Optional URL associated with this error that the user can open in a browser
#[serde(skip_serializing_if = "Option::is_none")]
pub url: Option<String>,
}
/// Session event "session.idle". Payload indicating the session is idle with no background agents or attached shell commands in flight
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionIdleData {
/// True when the preceding agentic loop was cancelled via abort signal
#[serde(skip_serializing_if = "Option::is_none")]
pub aborted: Option<bool>,
}
/// Session event "session.title_changed". Session title change payload containing the new display title
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionTitleChangedData {
/// The new display title for the session
pub title: String,
}
/// Session event "session.schedule_created". Scheduled prompt registered via /every or /after
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionScheduleCreatedData {
/// Absolute fire time (epoch milliseconds) for a one-shot calendar schedule
#[serde(skip_serializing_if = "Option::is_none")]
pub at: Option<i64>,
/// 5-field cron expression for a recurring calendar schedule, evaluated in `tz`
#[serde(skip_serializing_if = "Option::is_none")]
pub cron: Option<String>,
/// Optional user-facing label shown in the timeline instead of the actual prompt (e.g. `/skill-name args` when the prompt is a skill invocation expansion)
#[serde(skip_serializing_if = "Option::is_none")]
pub display_prompt: Option<String>,
/// Sequential id assigned to the scheduled prompt within the session
pub id: i64,
/// Interval between ticks in milliseconds (relative-interval schedules)
#[serde(skip_serializing_if = "Option::is_none")]
pub interval_ms: Option<i64>,
/// Prompt text that gets enqueued on every tick
pub prompt: String,
/// Whether the schedule re-arms after each tick (`/every`) or fires once (`/after`)
#[serde(skip_serializing_if = "Option::is_none")]
pub recurring: Option<bool>,
/// True for a self-paced (`dynamic`) schedule: no fixed cadence; the model arms each next run via the `manage_schedule` `wakeup` action. `nextRunAt` is model-controlled rather than auto-computed.
#[serde(skip_serializing_if = "Option::is_none")]
pub self_paced: Option<bool>,
/// IANA timezone the `cron` expression is evaluated in
#[serde(skip_serializing_if = "Option::is_none")]
pub tz: Option<String>,
}
/// Session event "session.schedule_cancelled". Scheduled prompt cancelled from the schedule manager dialog
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionScheduleCancelledData {
/// Id of the scheduled prompt that was cancelled
pub id: i64,
}
/// Session event "session.schedule_rearmed". Self-paced schedule re-armed for its next run
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionScheduleRearmedData {
/// Id of the self-paced schedule that was re-armed
pub id: i64,
/// Absolute time (epoch milliseconds) the model armed the next run to fire
pub next_run_at: i64,
}
/// Session event "session.autopilot_objective_changed". Autopilot objective state file operation details indicating what changed
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionAutopilotObjectiveChangedData {
/// Current autopilot objective id, if one exists
#[serde(skip_serializing_if = "Option::is_none")]
pub id: Option<i64>,
/// The type of operation performed on the autopilot objective state file
pub operation: AutopilotObjectiveChangedOperation,
/// Current autopilot objective status, if one exists
#[serde(skip_serializing_if = "Option::is_none")]
pub status: Option<AutopilotObjectiveChangedStatus>,
}
/// Session event "session.info". Informational message for timeline display with categorization
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionInfoData {
/// Category of informational message (e.g., "notification", "timing", "context_window", "mcp", "snapshot", "configuration", "authentication", "model")
pub info_type: String,
/// Human-readable informational message for display in the timeline
pub message: String,
/// Optional actionable tip displayed with this message
#[serde(skip_serializing_if = "Option::is_none")]
pub tip: Option<String>,
/// Optional URL associated with this message that the user can open in a browser
#[serde(skip_serializing_if = "Option::is_none")]
pub url: Option<String>,
}
/// Session event "session.warning". Warning message for timeline display with categorization
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionWarningData {
/// Human-readable warning message for display in the timeline
pub message: String,
/// Optional URL associated with this warning that the user can open in a browser
#[serde(skip_serializing_if = "Option::is_none")]
pub url: Option<String>,
/// Category of warning (e.g., "subscription", "policy", "mcp")
pub warning_type: String,
}
/// Session event "session.model_change". Model change details including previous and new model identifiers
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionModelChangeData {
/// Reason the change happened, when not user-initiated. Currently `"rate_limit_auto_switch"` for changes triggered by the auto-mode-switch rate-limit recovery path. UI clients can use this to render contextual copy.
#[serde(skip_serializing_if = "Option::is_none")]
pub cause: Option<String>,
/// Context tier after the model change; null explicitly clears a previously selected tier
#[serde(skip_serializing_if = "Option::is_none")]
pub context_tier: Option<ContextTier>,
/// Newly selected model identifier
pub new_model: String,
/// Model that was previously selected, if any
#[serde(skip_serializing_if = "Option::is_none")]
pub previous_model: Option<String>,
/// Reasoning effort level before the model change, if applicable
#[serde(skip_serializing_if = "Option::is_none")]
pub previous_reasoning_effort: Option<String>,
/// Reasoning summary mode before the model change, if applicable
#[serde(skip_serializing_if = "Option::is_none")]
pub previous_reasoning_summary: Option<ReasoningSummary>,
/// Output verbosity level before the model change, if applicable
#[serde(skip_serializing_if = "Option::is_none")]
pub previous_verbosity: Option<Verbosity>,
/// Reasoning effort level after the model change, if applicable
#[serde(skip_serializing_if = "Option::is_none")]
pub reasoning_effort: Option<String>,
/// Reasoning summary mode after the model change, if applicable
#[serde(skip_serializing_if = "Option::is_none")]
pub reasoning_summary: Option<ReasoningSummary>,
/// Output verbosity level after the model change, if applicable
#[serde(skip_serializing_if = "Option::is_none")]
pub verbosity: Option<Verbosity>,
}
/// Session event "session.mode_changed". Agent mode change details including previous and new modes
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionModeChangedData {
/// The session mode the agent is operating in
pub new_mode: SessionMode,
/// The session mode the agent is operating in
pub previous_mode: SessionMode,
}
/// Session event "session.session_limits_changed". Session limits update details. Null clears the limits.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionSessionLimitsChangedData {
/// Current session limits, or null when no limits are active
pub session_limits: Option<SessionLimitsConfig>,
}
/// Session event "session.permissions_changed". Permissions change details carrying the aggregate allow-all transition.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionPermissionsChangedData {
/// Allow-all mode after the change
///
/// <div class="warning">
///
/// **Experimental.** This type is part of an experimental wire-protocol surface
/// and may change or be removed in future SDK or CLI releases.
///
/// </div>
#[serde(skip_serializing_if = "Option::is_none")]
pub allow_all_permission_mode: Option<PermissionAllowAllMode>,
/// Aggregate allow-all flag after the change
pub allow_all_permissions: bool,
/// Allow-all mode before the change
///
/// <div class="warning">
///
/// **Experimental.** This type is part of an experimental wire-protocol surface
/// and may change or be removed in future SDK or CLI releases.
///
/// </div>
#[serde(skip_serializing_if = "Option::is_none")]
pub previous_allow_all_permission_mode: Option<PermissionAllowAllMode>,
/// Aggregate allow-all flag before the change
pub previous_allow_all_permissions: bool,
}
/// Session event "session.plan_changed". Plan file operation details indicating what changed
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionPlanChangedData {
/// The type of operation performed on the plan file
pub operation: PlanChangedOperation,
}
/// Session event "session.todos_changed". Signal-only event: the agent's todos or todo_deps table was written to. No payload — clients should call session.plan.readSqlTodosWithDependencies() to fetch the current state. Events arrive in order; clients can debounce on arrival if needed.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionTodosChangedData {}
/// Session event "session.workspace_file_changed". Workspace file change details including path and operation type
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionWorkspaceFileChangedData {
/// Whether the file was newly created or updated
pub operation: WorkspaceFileChangedOperation,
/// Relative path within the session workspace files directory
pub path: String,
}
/// Repository context for the handed-off session
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct HandoffRepository {
/// Git branch name, if applicable
#[serde(skip_serializing_if = "Option::is_none")]
pub branch: Option<String>,
/// Repository name
pub name: String,
/// Repository owner (user or organization)
pub owner: String,
}
/// Session event "session.handoff". Session handoff metadata including source, context, and repository information
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionHandoffData {
/// Additional context information for the handoff
#[serde(skip_serializing_if = "Option::is_none")]
pub context: Option<String>,
/// ISO 8601 timestamp when the handoff occurred
pub handoff_time: String,
/// GitHub host URL for the source session (e.g., https://github.com or https://tenant.ghe.com)
#[serde(skip_serializing_if = "Option::is_none")]
pub host: Option<String>,
/// Session ID of the remote session being handed off
#[serde(skip_serializing_if = "Option::is_none")]
pub remote_session_id: Option<SessionId>,
/// Repository context for the handed-off session
#[serde(skip_serializing_if = "Option::is_none")]
pub repository: Option<HandoffRepository>,
/// Origin type of the session being handed off
pub source_type: HandoffSourceType,
/// Summary of the work done in the source session
#[serde(skip_serializing_if = "Option::is_none")]
pub summary: Option<String>,
}
/// Session event "session.truncation". Conversation truncation statistics including token counts and removed content metrics
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionTruncationData {
/// Number of messages removed by truncation
pub messages_removed_during_truncation: i64,
/// Identifier of the component that performed truncation (e.g., "BasicTruncator")
pub performed_by: String,
/// Number of conversation messages after truncation
pub post_truncation_messages_length: i64,
/// Total tokens in conversation messages after truncation
pub post_truncation_tokens_in_messages: i64,
/// Number of conversation messages before truncation
pub pre_truncation_messages_length: i64,
/// Total tokens in conversation messages before truncation
pub pre_truncation_tokens_in_messages: i64,
/// Maximum token count for the model's context window
pub token_limit: i64,
/// Number of tokens removed by truncation
pub tokens_removed_during_truncation: i64,
}