forked from github/copilot-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerated_session_events.go
More file actions
1201 lines (1121 loc) · 45 KB
/
Copy pathgenerated_session_events.go
File metadata and controls
1201 lines (1121 loc) · 45 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 FILE - DO NOT EDIT
// Generated from: session-events.schema.json
// Code generated from JSON Schema using quicktype. DO NOT EDIT.
// To parse and unparse this JSON data, add this code to your project and do:
//
// sessionEvent, err := UnmarshalSessionEvent(bytes)
// bytes, err = sessionEvent.Marshal()
package copilot
import "bytes"
import "errors"
import "time"
import "encoding/json"
func UnmarshalSessionEvent(data []byte) (SessionEvent, error) {
var r SessionEvent
err := json.Unmarshal(data, &r)
return r, err
}
func (r *SessionEvent) Marshal() ([]byte, error) {
return json.Marshal(r)
}
type SessionEvent struct {
// Payload indicating the agent is idle; includes any background tasks still in flight
//
// Empty payload; the event signals that LLM-powered conversation compaction has begun
//
// Empty payload; the event signals that the pending message queue has changed
//
// Empty payload; the event signals that the custom agent was deselected, returning to the
// default agent
Data Data `json:"data"`
// When true, the event is transient and not persisted to the session event log on disk
Ephemeral *bool `json:"ephemeral,omitempty"`
// Unique event identifier (UUID v4), generated when the event is emitted
ID string `json:"id"`
// ID of the chronologically preceding event in the session, forming a linked chain. Null
// for the first event.
ParentID *string `json:"parentId"`
// ISO 8601 timestamp when the event was created
Timestamp time.Time `json:"timestamp"`
Type SessionEventType `json:"type"`
}
// Payload indicating the agent is idle; includes any background tasks still in flight
//
// Empty payload; the event signals that LLM-powered conversation compaction has begun
//
// Empty payload; the event signals that the pending message queue has changed
//
// Empty payload; the event signals that the custom agent was deselected, returning to the
// default agent
type Data struct {
// Working directory and git context at session start
//
// Updated working directory and git context at resume time
//
// Additional context information for the handoff
Context *ContextUnion `json:"context"`
// Version string of the Copilot application
CopilotVersion *string `json:"copilotVersion,omitempty"`
// Identifier of the software producing the events (e.g., "copilot-agent")
Producer *string `json:"producer,omitempty"`
// Model selected at session creation time, if any
SelectedModel *string `json:"selectedModel,omitempty"`
// Unique identifier for the session
//
// Session ID that this external tool request belongs to
SessionID *string `json:"sessionId,omitempty"`
// ISO 8601 timestamp when the session was created
StartTime *time.Time `json:"startTime,omitempty"`
// Schema version number for the session event format
Version *float64 `json:"version,omitempty"`
// Total number of persisted events in the session at the time of resume
EventCount *float64 `json:"eventCount,omitempty"`
// ISO 8601 timestamp when the session was resumed
ResumeTime *time.Time `json:"resumeTime,omitempty"`
// Category of error (e.g., "authentication", "authorization", "quota", "rate_limit",
// "query")
ErrorType *string `json:"errorType,omitempty"`
// Human-readable error message
//
// Human-readable informational message for display in the timeline
//
// Human-readable warning message for display in the timeline
//
// Message describing what information is needed from the user
Message *string `json:"message,omitempty"`
// GitHub request tracing ID (x-github-request-id header) for correlating with server-side
// logs
//
// GitHub request tracing ID (x-github-request-id header) for server-side log correlation
ProviderCallID *string `json:"providerCallId,omitempty"`
// Error stack trace, when available
Stack *string `json:"stack,omitempty"`
// HTTP status code from the upstream request, if applicable
StatusCode *int64 `json:"statusCode,omitempty"`
// Background tasks still running when the agent became idle
BackgroundTasks *BackgroundTasks `json:"backgroundTasks,omitempty"`
// The new display title for the session
Title *string `json:"title,omitempty"`
// Category of informational message (e.g., "notification", "timing", "context_window",
// "mcp", "snapshot", "configuration", "authentication", "model")
InfoType *string `json:"infoType,omitempty"`
// Category of warning (e.g., "subscription", "policy", "mcp")
WarningType *string `json:"warningType,omitempty"`
// Newly selected model identifier
NewModel *string `json:"newModel,omitempty"`
// Model that was previously selected, if any
PreviousModel *string `json:"previousModel,omitempty"`
// Agent mode after the change (e.g., "interactive", "plan", "autopilot")
NewMode *string `json:"newMode,omitempty"`
// Agent mode before the change (e.g., "interactive", "plan", "autopilot")
PreviousMode *string `json:"previousMode,omitempty"`
// The type of operation performed on the plan file
//
// Whether the file was newly created or updated
Operation *Operation `json:"operation,omitempty"`
// Relative path within the session workspace files directory
//
// File path to the SKILL.md definition
Path *string `json:"path,omitempty"`
// ISO 8601 timestamp when the handoff occurred
HandoffTime *time.Time `json:"handoffTime,omitempty"`
// Session ID of the remote session being handed off
RemoteSessionID *string `json:"remoteSessionId,omitempty"`
// Repository context for the handed-off session
//
// Repository identifier in "owner/name" format, derived from the git remote URL
Repository *RepositoryUnion `json:"repository"`
// Origin type of the session being handed off
SourceType *SourceType `json:"sourceType,omitempty"`
// Summary of the work done in the source session
//
// Optional summary of the completed task, provided by the agent
//
// Summary of the plan that was created
Summary *string `json:"summary,omitempty"`
// Number of messages removed by truncation
MessagesRemovedDuringTruncation *float64 `json:"messagesRemovedDuringTruncation,omitempty"`
// Identifier of the component that performed truncation (e.g., "BasicTruncator")
PerformedBy *string `json:"performedBy,omitempty"`
// Number of conversation messages after truncation
PostTruncationMessagesLength *float64 `json:"postTruncationMessagesLength,omitempty"`
// Total tokens in conversation messages after truncation
PostTruncationTokensInMessages *float64 `json:"postTruncationTokensInMessages,omitempty"`
// Number of conversation messages before truncation
PreTruncationMessagesLength *float64 `json:"preTruncationMessagesLength,omitempty"`
// Total tokens in conversation messages before truncation
PreTruncationTokensInMessages *float64 `json:"preTruncationTokensInMessages,omitempty"`
// Maximum token count for the model's context window
TokenLimit *float64 `json:"tokenLimit,omitempty"`
// Number of tokens removed by truncation
TokensRemovedDuringTruncation *float64 `json:"tokensRemovedDuringTruncation,omitempty"`
// Number of events that were removed by the rewind
EventsRemoved *float64 `json:"eventsRemoved,omitempty"`
// Event ID that was rewound to; all events after this one were removed
UpToEventID *string `json:"upToEventId,omitempty"`
// Aggregate code change metrics for the session
CodeChanges *CodeChanges `json:"codeChanges,omitempty"`
// Model that was selected at the time of shutdown
CurrentModel *string `json:"currentModel,omitempty"`
// Error description when shutdownType is "error"
ErrorReason *string `json:"errorReason,omitempty"`
// Per-model usage breakdown, keyed by model identifier
ModelMetrics map[string]ModelMetric `json:"modelMetrics,omitempty"`
// Unix timestamp (milliseconds) when the session started
SessionStartTime *float64 `json:"sessionStartTime,omitempty"`
// Whether the session ended normally ("routine") or due to a crash/fatal error ("error")
ShutdownType *ShutdownType `json:"shutdownType,omitempty"`
// Cumulative time spent in API calls during the session, in milliseconds
TotalAPIDurationMS *float64 `json:"totalApiDurationMs,omitempty"`
// Total number of premium API requests used during the session
TotalPremiumRequests *float64 `json:"totalPremiumRequests,omitempty"`
// Current git branch name
Branch *string `json:"branch,omitempty"`
// Current working directory path
Cwd *string `json:"cwd,omitempty"`
// Root directory of the git repository, resolved via git rev-parse
GitRoot *string `json:"gitRoot,omitempty"`
// Current number of tokens in the context window
CurrentTokens *float64 `json:"currentTokens,omitempty"`
// Current number of messages in the conversation
MessagesLength *float64 `json:"messagesLength,omitempty"`
// Checkpoint snapshot number created for recovery
CheckpointNumber *float64 `json:"checkpointNumber,omitempty"`
// File path where the checkpoint was stored
CheckpointPath *string `json:"checkpointPath,omitempty"`
// Token usage breakdown for the compaction LLM call
CompactionTokensUsed *CompactionTokensUsed `json:"compactionTokensUsed,omitempty"`
// Error message if compaction failed
//
// Error details when the tool execution failed
//
// Error message describing why the sub-agent failed
//
// Error details when the hook failed
Error *ErrorUnion `json:"error"`
// Number of messages removed during compaction
MessagesRemoved *float64 `json:"messagesRemoved,omitempty"`
// Total tokens in conversation after compaction
PostCompactionTokens *float64 `json:"postCompactionTokens,omitempty"`
// Number of messages before compaction
PreCompactionMessagesLength *float64 `json:"preCompactionMessagesLength,omitempty"`
// Total tokens in conversation before compaction
PreCompactionTokens *float64 `json:"preCompactionTokens,omitempty"`
// GitHub request tracing ID (x-github-request-id header) for the compaction LLM call
//
// Unique identifier for this permission request; used to respond via
// session.respondToPermission()
//
// Request ID of the resolved permission request; clients should dismiss any UI for this
// request
//
// Unique identifier for this input request; used to respond via
// session.respondToUserInput()
//
// Request ID of the resolved user input request; clients should dismiss any UI for this
// request
//
// Unique identifier for this elicitation request; used to respond via
// session.respondToElicitation()
//
// Request ID of the resolved elicitation request; clients should dismiss any UI for this
// request
//
// Unique identifier for this request; used to respond via session.respondToExternalTool()
//
// Request ID of the resolved external tool request; clients should dismiss any UI for this
// request
//
// Unique identifier for this request; used to respond via session.respondToQueuedCommand()
//
// Request ID of the resolved command request; clients should dismiss any UI for this
// request
//
// Unique identifier for this request; used to respond via session.respondToExitPlanMode()
//
// Request ID of the resolved exit plan mode request; clients should dismiss any UI for this
// request
RequestID *string `json:"requestId,omitempty"`
// Whether compaction completed successfully
//
// Whether the tool execution completed successfully
//
// Whether the hook completed successfully
Success *bool `json:"success,omitempty"`
// LLM-generated summary of the compacted conversation history
SummaryContent *string `json:"summaryContent,omitempty"`
// Number of tokens removed during compaction
TokensRemoved *float64 `json:"tokensRemoved,omitempty"`
// The agent mode that was active when this message was sent
AgentMode *AgentMode `json:"agentMode,omitempty"`
// Files, selections, or GitHub references attached to the message
Attachments []Attachment `json:"attachments,omitempty"`
// The user's message text as displayed in the timeline
//
// The complete extended thinking text from the model
//
// The assistant's text response content
//
// Full content of the skill file, injected into the conversation for the model
//
// The system or developer prompt text
Content *string `json:"content,omitempty"`
// CAPI interaction ID for correlating this user message with its turn
//
// CAPI interaction ID for correlating this turn with upstream telemetry
//
// CAPI interaction ID for correlating this message with upstream telemetry
//
// CAPI interaction ID for correlating this tool execution with upstream telemetry
InteractionID *string `json:"interactionId,omitempty"`
// Origin of this message, used for timeline filtering (e.g., "skill-pdf" for skill-injected
// messages that should be hidden from the user)
Source *string `json:"source,omitempty"`
// Transformed version of the message sent to the model, with XML wrapping, timestamps, and
// other augmentations for prompt caching
TransformedContent *string `json:"transformedContent,omitempty"`
// Identifier for this turn within the agentic loop, typically a stringified turn number
//
// Identifier of the turn that has ended, matching the corresponding assistant.turn_start
// event
TurnID *string `json:"turnId,omitempty"`
// Short description of what the agent is currently doing or planning to do
Intent *string `json:"intent,omitempty"`
// Unique identifier for this reasoning block
//
// Reasoning block ID this delta belongs to, matching the corresponding assistant.reasoning
// event
ReasoningID *string `json:"reasoningId,omitempty"`
// Incremental text chunk to append to the reasoning content
//
// Incremental text chunk to append to the message content
DeltaContent *string `json:"deltaContent,omitempty"`
// Cumulative total bytes received from the streaming response so far
TotalResponseSizeBytes *float64 `json:"totalResponseSizeBytes,omitempty"`
// Encrypted reasoning content from OpenAI models. Session-bound and stripped on resume.
EncryptedContent *string `json:"encryptedContent,omitempty"`
// Unique identifier for this assistant message
//
// Message ID this delta belongs to, matching the corresponding assistant.message event
MessageID *string `json:"messageId,omitempty"`
// Actual output token count from the API response (completion_tokens), used for accurate
// token accounting
//
// Number of output tokens produced
OutputTokens *float64 `json:"outputTokens,omitempty"`
// Tool call ID of the parent tool invocation when this event originates from a sub-agent
//
// Parent tool call ID when this usage originates from a sub-agent
ParentToolCallID *string `json:"parentToolCallId,omitempty"`
// Generation phase for phased-output models (e.g., thinking vs. response phases)
Phase *string `json:"phase,omitempty"`
// Opaque/encrypted extended thinking data from Anthropic models. Session-bound and stripped
// on resume.
ReasoningOpaque *string `json:"reasoningOpaque,omitempty"`
// Readable reasoning text from the model's extended thinking
ReasoningText *string `json:"reasoningText,omitempty"`
// Tool invocations requested by the assistant in this message
ToolRequests []ToolRequest `json:"toolRequests,omitempty"`
// Completion ID from the model provider (e.g., chatcmpl-abc123)
APICallID *string `json:"apiCallId,omitempty"`
// Number of tokens read from prompt cache
CacheReadTokens *float64 `json:"cacheReadTokens,omitempty"`
// Number of tokens written to prompt cache
CacheWriteTokens *float64 `json:"cacheWriteTokens,omitempty"`
// Per-request cost and usage data from the CAPI copilot_usage response field
CopilotUsage *CopilotUsage `json:"copilotUsage,omitempty"`
// Model multiplier cost for billing purposes
Cost *float64 `json:"cost,omitempty"`
// Duration of the API call in milliseconds
Duration *float64 `json:"duration,omitempty"`
// What initiated this API call (e.g., "sub-agent"); absent for user-initiated calls
Initiator *string `json:"initiator,omitempty"`
// Number of input tokens consumed
InputTokens *float64 `json:"inputTokens,omitempty"`
// Model identifier used for this API call
//
// Model identifier that generated this tool call
Model *string `json:"model,omitempty"`
// Per-quota resource usage snapshots, keyed by quota identifier
QuotaSnapshots map[string]QuotaSnapshot `json:"quotaSnapshots,omitempty"`
// Reason the current turn was aborted (e.g., "user initiated")
Reason *string `json:"reason,omitempty"`
// Arguments for the tool invocation
//
// Arguments passed to the tool
//
// Arguments to pass to the external tool
Arguments interface{} `json:"arguments"`
// Unique identifier for this tool call
//
// Tool call ID this partial result belongs to
//
// Tool call ID this progress notification belongs to
//
// Unique identifier for the completed tool call
//
// Tool call ID of the parent tool invocation that spawned this sub-agent
//
// Tool call ID assigned to this external tool invocation
ToolCallID *string `json:"toolCallId,omitempty"`
// Name of the tool the user wants to invoke
//
// Name of the tool being executed
//
// Name of the external tool to invoke
ToolName *string `json:"toolName,omitempty"`
// Name of the MCP server hosting this tool, when the tool is an MCP tool
MCPServerName *string `json:"mcpServerName,omitempty"`
// Original tool name on the MCP server, when the tool is an MCP tool
MCPToolName *string `json:"mcpToolName,omitempty"`
// Incremental output chunk from the running tool
PartialOutput *string `json:"partialOutput,omitempty"`
// Human-readable progress status message (e.g., from an MCP server)
ProgressMessage *string `json:"progressMessage,omitempty"`
// Whether this tool call was explicitly requested by the user rather than the assistant
IsUserRequested *bool `json:"isUserRequested,omitempty"`
// Tool execution result on success
//
// The result of the permission request
Result *Result `json:"result,omitempty"`
// Tool-specific telemetry data (e.g., CodeQL check counts, grep match counts)
ToolTelemetry map[string]interface{} `json:"toolTelemetry,omitempty"`
// Tool names that should be auto-approved when this skill is active
AllowedTools []string `json:"allowedTools,omitempty"`
// Name of the invoked skill
//
// Optional name identifier for the message source
Name *string `json:"name,omitempty"`
// Name of the plugin this skill originated from, when applicable
PluginName *string `json:"pluginName,omitempty"`
// Version of the plugin this skill originated from, when applicable
PluginVersion *string `json:"pluginVersion,omitempty"`
// Description of what the sub-agent does
AgentDescription *string `json:"agentDescription,omitempty"`
// Human-readable display name of the sub-agent
//
// Human-readable display name of the selected custom agent
AgentDisplayName *string `json:"agentDisplayName,omitempty"`
// Internal name of the sub-agent
//
// Internal name of the selected custom agent
AgentName *string `json:"agentName,omitempty"`
// List of tool names available to this agent, or null for all tools
Tools []string `json:"tools"`
// Unique identifier for this hook invocation
//
// Identifier matching the corresponding hook.start event
HookInvocationID *string `json:"hookInvocationId,omitempty"`
// Type of hook being invoked (e.g., "preToolUse", "postToolUse", "sessionStart")
//
// Type of hook that was invoked (e.g., "preToolUse", "postToolUse", "sessionStart")
HookType *string `json:"hookType,omitempty"`
// Input data passed to the hook
Input interface{} `json:"input"`
// Output data produced by the hook
Output interface{} `json:"output"`
// Metadata about the prompt template and its construction
Metadata *Metadata `json:"metadata,omitempty"`
// Message role: "system" for system prompts, "developer" for developer-injected instructions
Role *Role `json:"role,omitempty"`
// Details of the permission being requested
PermissionRequest *PermissionRequest `json:"permissionRequest,omitempty"`
// Whether the user can provide a free-form text response in addition to predefined choices
AllowFreeform *bool `json:"allowFreeform,omitempty"`
// Predefined choices for the user to select from, if applicable
Choices []string `json:"choices,omitempty"`
// The question or prompt to present to the user
Question *string `json:"question,omitempty"`
// Elicitation mode; currently only "form" is supported. Defaults to "form" when absent.
Mode *Mode `json:"mode,omitempty"`
// JSON Schema describing the form fields to present to the user
RequestedSchema *RequestedSchema `json:"requestedSchema,omitempty"`
// The slash command text to be executed (e.g., /help, /clear)
Command *string `json:"command,omitempty"`
// Available actions the user can take (e.g., approve, edit, reject)
Actions []string `json:"actions,omitempty"`
// Full content of the plan file
PlanContent *string `json:"planContent,omitempty"`
// The recommended action for the user to take
RecommendedAction *string `json:"recommendedAction,omitempty"`
}
type Attachment struct {
// User-facing display name for the attachment
//
// User-facing display name for the selection
DisplayName *string `json:"displayName,omitempty"`
// Optional line range to scope the attachment to a specific section of the file
LineRange *LineRange `json:"lineRange,omitempty"`
// Absolute file or directory path
Path *string `json:"path,omitempty"`
// Attachment type discriminator
Type AttachmentType `json:"type"`
// Absolute path to the file containing the selection
FilePath *string `json:"filePath,omitempty"`
// Position range of the selection within the file
Selection *SelectionClass `json:"selection,omitempty"`
// The selected text content
Text *string `json:"text,omitempty"`
// Issue, pull request, or discussion number
Number *float64 `json:"number,omitempty"`
// Type of GitHub reference
ReferenceType *ReferenceType `json:"referenceType,omitempty"`
// Current state of the referenced item (e.g., open, closed, merged)
State *string `json:"state,omitempty"`
// Title of the referenced item
Title *string `json:"title,omitempty"`
// URL to the referenced item on GitHub
URL *string `json:"url,omitempty"`
}
// Optional line range to scope the attachment to a specific section of the file
type LineRange struct {
// End line number (1-based, inclusive)
End float64 `json:"end"`
// Start line number (1-based)
Start float64 `json:"start"`
}
// Position range of the selection within the file
type SelectionClass struct {
End End `json:"end"`
Start Start `json:"start"`
}
type End struct {
// End character offset within the line (0-based)
Character float64 `json:"character"`
// End line number (0-based)
Line float64 `json:"line"`
}
type Start struct {
// Start character offset within the line (0-based)
Character float64 `json:"character"`
// Start line number (0-based)
Line float64 `json:"line"`
}
// Background tasks still running when the agent became idle
type BackgroundTasks struct {
// Currently running background agents
Agents []Agent `json:"agents"`
// Currently running background shell commands
Shells []Shell `json:"shells"`
}
type Agent struct {
// Unique identifier of the background agent
AgentID string `json:"agentId"`
// Type of the background agent
AgentType string `json:"agentType"`
// Human-readable description of the agent task
Description *string `json:"description,omitempty"`
}
type Shell struct {
// Human-readable description of the shell command
Description *string `json:"description,omitempty"`
// Unique identifier of the background shell
ShellID string `json:"shellId"`
}
// Aggregate code change metrics for the session
type CodeChanges struct {
// List of file paths that were modified during the session
FilesModified []string `json:"filesModified"`
// Total number of lines added during the session
LinesAdded float64 `json:"linesAdded"`
// Total number of lines removed during the session
LinesRemoved float64 `json:"linesRemoved"`
}
// Token usage breakdown for the compaction LLM call
type CompactionTokensUsed struct {
// Cached input tokens reused in the compaction LLM call
CachedInput float64 `json:"cachedInput"`
// Input tokens consumed by the compaction LLM call
Input float64 `json:"input"`
// Output tokens produced by the compaction LLM call
Output float64 `json:"output"`
}
// Working directory and git context at session start
//
// Updated working directory and git context at resume time
type ContextClass struct {
// Current git branch name
Branch *string `json:"branch,omitempty"`
// Current working directory path
Cwd string `json:"cwd"`
// Root directory of the git repository, resolved via git rev-parse
GitRoot *string `json:"gitRoot,omitempty"`
// Repository identifier in "owner/name" format, derived from the git remote URL
Repository *string `json:"repository,omitempty"`
}
// Per-request cost and usage data from the CAPI copilot_usage response field
type CopilotUsage struct {
// Itemized token usage breakdown
TokenDetails []TokenDetail `json:"tokenDetails"`
// Total cost in nano-AIU (AI Units) for this request
TotalNanoAiu float64 `json:"totalNanoAiu"`
}
type TokenDetail struct {
// Number of tokens in this billing batch
BatchSize float64 `json:"batchSize"`
// Cost per batch of tokens
CostPerBatch float64 `json:"costPerBatch"`
// Total token count for this entry
TokenCount float64 `json:"tokenCount"`
// Token category (e.g., "input", "output")
TokenType string `json:"tokenType"`
}
// Error details when the tool execution failed
//
// Error details when the hook failed
type ErrorClass struct {
// Machine-readable error code
Code *string `json:"code,omitempty"`
// Human-readable error message
Message string `json:"message"`
// Error stack trace, when available
Stack *string `json:"stack,omitempty"`
}
// Metadata about the prompt template and its construction
type Metadata struct {
// Version identifier of the prompt template used
PromptVersion *string `json:"promptVersion,omitempty"`
// Template variables used when constructing the prompt
Variables map[string]interface{} `json:"variables,omitempty"`
}
type ModelMetric struct {
// Request count and cost metrics
Requests Requests `json:"requests"`
// Token usage breakdown
Usage Usage `json:"usage"`
}
// Request count and cost metrics
type Requests struct {
// Cumulative cost multiplier for requests to this model
Cost float64 `json:"cost"`
// Total number of API requests made to this model
Count float64 `json:"count"`
}
// Token usage breakdown
type Usage struct {
// Total tokens read from prompt cache across all requests
CacheReadTokens float64 `json:"cacheReadTokens"`
// Total tokens written to prompt cache across all requests
CacheWriteTokens float64 `json:"cacheWriteTokens"`
// Total input tokens consumed across all requests to this model
InputTokens float64 `json:"inputTokens"`
// Total output tokens produced across all requests to this model
OutputTokens float64 `json:"outputTokens"`
}
// Details of the permission being requested
type PermissionRequest struct {
// Whether the UI can offer session-wide approval for this command pattern
CanOfferSessionApproval *bool `json:"canOfferSessionApproval,omitempty"`
// Parsed command identifiers found in the command text
Commands []Command `json:"commands,omitempty"`
// The complete shell command text to be executed
FullCommandText *string `json:"fullCommandText,omitempty"`
// Whether the command includes a file write redirection (e.g., > or >>)
HasWriteFileRedirection *bool `json:"hasWriteFileRedirection,omitempty"`
// Human-readable description of what the command intends to do
//
// Human-readable description of the intended file change
//
// Human-readable description of why the file is being read
//
// Human-readable description of why the URL is being accessed
Intention *string `json:"intention,omitempty"`
// Permission kind discriminator
Kind PermissionRequestKind `json:"kind"`
// File paths that may be read or written by the command
PossiblePaths []string `json:"possiblePaths,omitempty"`
// URLs that may be accessed by the command
PossibleUrls []PossibleURL `json:"possibleUrls,omitempty"`
// Tool call ID that triggered this permission request
ToolCallID *string `json:"toolCallId,omitempty"`
// Optional warning message about risks of running this command
Warning *string `json:"warning,omitempty"`
// Unified diff showing the proposed changes
Diff *string `json:"diff,omitempty"`
// Path of the file being written to
FileName *string `json:"fileName,omitempty"`
// Complete new file contents for newly created files
NewFileContents *string `json:"newFileContents,omitempty"`
// Path of the file or directory being read
Path *string `json:"path,omitempty"`
// Arguments to pass to the MCP tool
//
// Arguments to pass to the custom tool
Args interface{} `json:"args"`
// Whether this MCP tool is read-only (no side effects)
ReadOnly *bool `json:"readOnly,omitempty"`
// Name of the MCP server providing the tool
ServerName *string `json:"serverName,omitempty"`
// Internal name of the MCP tool
//
// Name of the custom tool
ToolName *string `json:"toolName,omitempty"`
// Human-readable title of the MCP tool
ToolTitle *string `json:"toolTitle,omitempty"`
// URL to be fetched
URL *string `json:"url,omitempty"`
// Source references for the stored fact
Citations *string `json:"citations,omitempty"`
// The fact or convention being stored
Fact *string `json:"fact,omitempty"`
// Topic or subject of the memory being stored
Subject *string `json:"subject,omitempty"`
// Description of what the custom tool does
ToolDescription *string `json:"toolDescription,omitempty"`
}
type Command struct {
// Command identifier (e.g., executable name)
Identifier string `json:"identifier"`
// Whether this command is read-only (no side effects)
ReadOnly bool `json:"readOnly"`
}
type PossibleURL struct {
// URL that may be accessed by the command
URL string `json:"url"`
}
type QuotaSnapshot struct {
// Total requests allowed by the entitlement
EntitlementRequests float64 `json:"entitlementRequests"`
// Whether the user has an unlimited usage entitlement
IsUnlimitedEntitlement bool `json:"isUnlimitedEntitlement"`
// Number of requests over the entitlement limit
Overage float64 `json:"overage"`
// Whether overage is allowed when quota is exhausted
OverageAllowedWithExhaustedQuota bool `json:"overageAllowedWithExhaustedQuota"`
// Percentage of quota remaining (0.0 to 1.0)
RemainingPercentage float64 `json:"remainingPercentage"`
// Date when the quota resets
ResetDate *time.Time `json:"resetDate,omitempty"`
// Whether usage is still permitted after quota exhaustion
UsageAllowedWithExhaustedQuota bool `json:"usageAllowedWithExhaustedQuota"`
// Number of requests already consumed
UsedRequests float64 `json:"usedRequests"`
}
// Repository context for the handed-off session
type RepositoryClass struct {
// Git branch name, if applicable
Branch *string `json:"branch,omitempty"`
// Repository name
Name string `json:"name"`
// Repository owner (user or organization)
Owner string `json:"owner"`
}
// JSON Schema describing the form fields to present to the user
type RequestedSchema struct {
// Form field definitions, keyed by field name
Properties map[string]interface{} `json:"properties"`
// List of required field names
Required []string `json:"required,omitempty"`
Type RequestedSchemaType `json:"type"`
}
// Tool execution result on success
//
// The result of the permission request
type Result struct {
// Concise tool result text sent to the LLM for chat completion, potentially truncated for
// token efficiency
Content *string `json:"content,omitempty"`
// Structured content blocks (text, images, audio, resources) returned by the tool in their
// native format
Contents []Content `json:"contents,omitempty"`
// Full detailed tool result for UI/timeline display, preserving complete content such as
// diffs. Falls back to content when absent.
DetailedContent *string `json:"detailedContent,omitempty"`
// The outcome of the permission request
Kind *ResultKind `json:"kind,omitempty"`
}
type Content struct {
// The text content
//
// Terminal/shell output text
Text *string `json:"text,omitempty"`
// Content block type discriminator
Type ContentType `json:"type"`
// Working directory where the command was executed
Cwd *string `json:"cwd,omitempty"`
// Process exit code, if the command has completed
ExitCode *float64 `json:"exitCode,omitempty"`
// Base64-encoded image data
//
// Base64-encoded audio data
Data *string `json:"data,omitempty"`
// MIME type of the image (e.g., image/png, image/jpeg)
//
// MIME type of the audio (e.g., audio/wav, audio/mpeg)
//
// MIME type of the resource content
MIMEType *string `json:"mimeType,omitempty"`
// Human-readable description of the resource
Description *string `json:"description,omitempty"`
// Icons associated with this resource
Icons []Icon `json:"icons,omitempty"`
// Resource name identifier
Name *string `json:"name,omitempty"`
// Size of the resource in bytes
Size *float64 `json:"size,omitempty"`
// Human-readable display title for the resource
Title *string `json:"title,omitempty"`
// URI identifying the resource
URI *string `json:"uri,omitempty"`
// The embedded resource contents, either text or base64-encoded binary
Resource *ResourceClass `json:"resource,omitempty"`
}
type Icon struct {
// MIME type of the icon image
MIMEType *string `json:"mimeType,omitempty"`
// Available icon sizes (e.g., ['16x16', '32x32'])
Sizes []string `json:"sizes,omitempty"`
// URL or path to the icon image
Src string `json:"src"`
// Theme variant this icon is intended for
Theme *Theme `json:"theme,omitempty"`
}
// The embedded resource contents, either text or base64-encoded binary
type ResourceClass struct {
// MIME type of the text content
//
// MIME type of the blob content
MIMEType *string `json:"mimeType,omitempty"`
// Text content of the resource
Text *string `json:"text,omitempty"`
// URI identifying the resource
URI string `json:"uri"`
// Base64-encoded binary content of the resource
Blob *string `json:"blob,omitempty"`
}
type ToolRequest struct {
// Arguments to pass to the tool, format depends on the tool
Arguments interface{} `json:"arguments"`
// Name of the tool being invoked
Name string `json:"name"`
// Unique identifier for this tool call
ToolCallID string `json:"toolCallId"`
// Tool call type: "function" for standard tool calls, "custom" for grammar-based tool
// calls. Defaults to "function" when absent.
Type *ToolRequestType `json:"type,omitempty"`
}
// The agent mode that was active when this message was sent
type AgentMode string
const (
AgentModeShell AgentMode = "shell"
Autopilot AgentMode = "autopilot"
Interactive AgentMode = "interactive"
Plan AgentMode = "plan"
)
// Type of GitHub reference
type ReferenceType string
const (
Discussion ReferenceType = "discussion"
Issue ReferenceType = "issue"
PR ReferenceType = "pr"
)
type AttachmentType string
const (
Directory AttachmentType = "directory"
File AttachmentType = "file"
GithubReference AttachmentType = "github_reference"
Selection AttachmentType = "selection"
)
type Mode string
const (
Form Mode = "form"
)
// The type of operation performed on the plan file
//
// Whether the file was newly created or updated
type Operation string
const (
Create Operation = "create"
Delete Operation = "delete"
Update Operation = "update"
)
type PermissionRequestKind string
const (
CustomTool PermissionRequestKind = "custom-tool"
KindShell PermissionRequestKind = "shell"
MCP PermissionRequestKind = "mcp"
Memory PermissionRequestKind = "memory"
Read PermissionRequestKind = "read"
URL PermissionRequestKind = "url"
Write PermissionRequestKind = "write"
)
type RequestedSchemaType string
const (
Object RequestedSchemaType = "object"
)
// Theme variant this icon is intended for
type Theme string
const (
Dark Theme = "dark"
Light Theme = "light"
)
type ContentType string
const (
Audio ContentType = "audio"
Image ContentType = "image"
Resource ContentType = "resource"
ResourceLink ContentType = "resource_link"
Terminal ContentType = "terminal"
Text ContentType = "text"
)
// The outcome of the permission request
type ResultKind string
const (
Approved ResultKind = "approved"
DeniedByContentExclusionPolicy ResultKind = "denied-by-content-exclusion-policy"
DeniedByRules ResultKind = "denied-by-rules"
DeniedInteractivelyByUser ResultKind = "denied-interactively-by-user"
DeniedNoApprovalRuleAndCouldNotRequestFromUser ResultKind = "denied-no-approval-rule-and-could-not-request-from-user"
)
// Message role: "system" for system prompts, "developer" for developer-injected instructions
type Role string
const (
Developer Role = "developer"
System Role = "system"
)
// Whether the session ended normally ("routine") or due to a crash/fatal error ("error")
type ShutdownType string
const (
Error ShutdownType = "error"
Routine ShutdownType = "routine"
)
// Origin type of the session being handed off
type SourceType string
const (
Local SourceType = "local"
Remote SourceType = "remote"
)
// Tool call type: "function" for standard tool calls, "custom" for grammar-based tool
// calls. Defaults to "function" when absent.
type ToolRequestType string
const (
Custom ToolRequestType = "custom"
Function ToolRequestType = "function"
)
type SessionEventType string
const (
Abort SessionEventType = "abort"
AssistantIntent SessionEventType = "assistant.intent"
AssistantMessage SessionEventType = "assistant.message"
AssistantMessageDelta SessionEventType = "assistant.message_delta"
AssistantReasoning SessionEventType = "assistant.reasoning"
AssistantReasoningDelta SessionEventType = "assistant.reasoning_delta"
AssistantStreamingDelta SessionEventType = "assistant.streaming_delta"
AssistantTurnEnd SessionEventType = "assistant.turn_end"
AssistantTurnStart SessionEventType = "assistant.turn_start"
AssistantUsage SessionEventType = "assistant.usage"
CommandCompleted SessionEventType = "command.completed"
CommandQueued SessionEventType = "command.queued"
ElicitationCompleted SessionEventType = "elicitation.completed"
ElicitationRequested SessionEventType = "elicitation.requested"
ExitPlanModeCompleted SessionEventType = "exit_plan_mode.completed"
ExitPlanModeRequested SessionEventType = "exit_plan_mode.requested"
ExternalToolCompleted SessionEventType = "external_tool.completed"
ExternalToolRequested SessionEventType = "external_tool.requested"
HookEnd SessionEventType = "hook.end"
HookStart SessionEventType = "hook.start"
PendingMessagesModified SessionEventType = "pending_messages.modified"
PermissionCompleted SessionEventType = "permission.completed"
PermissionRequested SessionEventType = "permission.requested"
SessionCompactionComplete SessionEventType = "session.compaction_complete"
SessionCompactionStart SessionEventType = "session.compaction_start"
SessionContextChanged SessionEventType = "session.context_changed"
SessionError SessionEventType = "session.error"
SessionHandoff SessionEventType = "session.handoff"
SessionIdle SessionEventType = "session.idle"
SessionInfo SessionEventType = "session.info"
SessionModeChanged SessionEventType = "session.mode_changed"
SessionModelChange SessionEventType = "session.model_change"
SessionPlanChanged SessionEventType = "session.plan_changed"
SessionResume SessionEventType = "session.resume"
SessionShutdown SessionEventType = "session.shutdown"
SessionSnapshotRewind SessionEventType = "session.snapshot_rewind"
SessionStart SessionEventType = "session.start"