forked from github/copilot-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathzrpc_encoding.go
More file actions
1640 lines (1540 loc) · 43.1 KB
/
Copy pathzrpc_encoding.go
File metadata and controls
1640 lines (1540 loc) · 43.1 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
// Code generated by scripts/codegen/go.ts; DO NOT EDIT.
// Source: api.schema.json
package rpc
import (
"encoding/json"
"errors"
)
func unmarshalQueuedCommandResult(data []byte) (QueuedCommandResult, error) {
if string(data) == "null" {
return nil, nil
}
type rawUnion struct {
Handled *bool `json:"handled"`
}
var raw rawUnion
if err := json.Unmarshal(data, &raw); err != nil {
return nil, err
}
if raw.Handled == nil {
return nil, errors.New("data did not match any union variant for QueuedCommandResult")
}
switch *raw.Handled {
case false:
var d QueuedCommandNotHandled
if err := json.Unmarshal(data, &d); err != nil {
return nil, err
}
return &d, nil
case true:
var d QueuedCommandHandled
if err := json.Unmarshal(data, &d); err != nil {
return nil, err
}
return &d, nil
}
return nil, errors.New("data did not match any union variant for QueuedCommandResult")
}
func (r QueuedCommandHandled) MarshalJSON() ([]byte, error) {
type alias QueuedCommandHandled
return json.Marshal(struct {
Handled bool `json:"handled"`
alias
}{
Handled: r.Handled(),
alias: alias(r),
})
}
func (r QueuedCommandNotHandled) MarshalJSON() ([]byte, error) {
type alias QueuedCommandNotHandled
return json.Marshal(struct {
Handled bool `json:"handled"`
alias
}{
Handled: r.Handled(),
alias: alias(r),
})
}
func (r *CommandsRespondToQueuedCommandRequest) UnmarshalJSON(data []byte) error {
type rawCommandsRespondToQueuedCommandRequest struct {
RequestID string `json:"requestId"`
Result json.RawMessage `json:"result"`
}
var raw rawCommandsRespondToQueuedCommandRequest
if err := json.Unmarshal(data, &raw); err != nil {
return err
}
r.RequestID = raw.RequestID
if raw.Result != nil {
value, err := unmarshalQueuedCommandResult(raw.Result)
if err != nil {
return err
}
r.Result = value
}
return nil
}
func unmarshalExternalToolTextResultForLlmContent(data []byte) (ExternalToolTextResultForLlmContent, error) {
if string(data) == "null" {
return nil, nil
}
type rawUnion struct {
Type ExternalToolTextResultForLlmContentType `json:"type"`
}
var raw rawUnion
if err := json.Unmarshal(data, &raw); err != nil {
return nil, err
}
switch raw.Type {
case ExternalToolTextResultForLlmContentTypeAudio:
var d ExternalToolTextResultForLlmContentAudio
if err := json.Unmarshal(data, &d); err != nil {
return nil, err
}
return &d, nil
case ExternalToolTextResultForLlmContentTypeImage:
var d ExternalToolTextResultForLlmContentImage
if err := json.Unmarshal(data, &d); err != nil {
return nil, err
}
return &d, nil
case ExternalToolTextResultForLlmContentTypeResource:
var d ExternalToolTextResultForLlmContentResource
if err := json.Unmarshal(data, &d); err != nil {
return nil, err
}
return &d, nil
case ExternalToolTextResultForLlmContentTypeResourceLink:
var d ExternalToolTextResultForLlmContentResourceLink
if err := json.Unmarshal(data, &d); err != nil {
return nil, err
}
return &d, nil
case ExternalToolTextResultForLlmContentTypeTerminal:
var d ExternalToolTextResultForLlmContentTerminal
if err := json.Unmarshal(data, &d); err != nil {
return nil, err
}
return &d, nil
case ExternalToolTextResultForLlmContentTypeText:
var d ExternalToolTextResultForLlmContentText
if err := json.Unmarshal(data, &d); err != nil {
return nil, err
}
return &d, nil
default:
return &RawExternalToolTextResultForLlmContentData{Discriminator: raw.Type, Raw: data}, nil
}
}
func (r RawExternalToolTextResultForLlmContentData) MarshalJSON() ([]byte, error) {
if r.Raw != nil {
return r.Raw, nil
}
return json.Marshal(struct {
Type ExternalToolTextResultForLlmContentType `json:"type"`
}{
Type: r.Discriminator,
})
}
func (r ExternalToolTextResultForLlmContentAudio) MarshalJSON() ([]byte, error) {
type alias ExternalToolTextResultForLlmContentAudio
return json.Marshal(struct {
Type ExternalToolTextResultForLlmContentType `json:"type"`
alias
}{
Type: r.Type(),
alias: alias(r),
})
}
func (r ExternalToolTextResultForLlmContentImage) MarshalJSON() ([]byte, error) {
type alias ExternalToolTextResultForLlmContentImage
return json.Marshal(struct {
Type ExternalToolTextResultForLlmContentType `json:"type"`
alias
}{
Type: r.Type(),
alias: alias(r),
})
}
func matchesEmbeddedBlobResourceContents(data []byte) bool {
var rawGroup0 struct {
Blob json.RawMessage `json:"blob"`
Text json.RawMessage `json:"text"`
}
if err := json.Unmarshal(data, &rawGroup0); err != nil {
return false
}
if rawGroup0.Blob == nil {
return false
}
return rawGroup0.Text == nil
}
func matchesEmbeddedTextResourceContents(data []byte) bool {
var rawGroup0 struct {
Blob json.RawMessage `json:"blob"`
Text json.RawMessage `json:"text"`
}
if err := json.Unmarshal(data, &rawGroup0); err != nil {
return false
}
if rawGroup0.Text == nil {
return false
}
return rawGroup0.Blob == nil
}
func unmarshalExternalToolTextResultForLlmContentResourceDetails(data []byte) (ExternalToolTextResultForLlmContentResourceDetails, error) {
if string(data) == "null" {
return nil, nil
}
if matchesEmbeddedBlobResourceContents(data) {
var d EmbeddedBlobResourceContents
if err := json.Unmarshal(data, &d); err != nil {
return nil, err
}
return &d, nil
}
if matchesEmbeddedTextResourceContents(data) {
var d EmbeddedTextResourceContents
if err := json.Unmarshal(data, &d); err != nil {
return nil, err
}
return &d, nil
}
return &RawExternalToolTextResultForLlmContentResourceDetailsData{Raw: data}, nil
}
func (r RawExternalToolTextResultForLlmContentResourceDetailsData) MarshalJSON() ([]byte, error) {
if r.Raw != nil {
return r.Raw, nil
}
return []byte("null"), nil
}
func (r *ExternalToolTextResultForLlmContentResource) UnmarshalJSON(data []byte) error {
type rawExternalToolTextResultForLlmContentResource struct {
Resource json.RawMessage `json:"resource"`
}
var raw rawExternalToolTextResultForLlmContentResource
if err := json.Unmarshal(data, &raw); err != nil {
return err
}
if raw.Resource != nil {
value, err := unmarshalExternalToolTextResultForLlmContentResourceDetails(raw.Resource)
if err != nil {
return err
}
r.Resource = value
}
return nil
}
func (r ExternalToolTextResultForLlmContentResource) MarshalJSON() ([]byte, error) {
type alias ExternalToolTextResultForLlmContentResource
return json.Marshal(struct {
Type ExternalToolTextResultForLlmContentType `json:"type"`
alias
}{
Type: r.Type(),
alias: alias(r),
})
}
func (r ExternalToolTextResultForLlmContentResourceLink) MarshalJSON() ([]byte, error) {
type alias ExternalToolTextResultForLlmContentResourceLink
return json.Marshal(struct {
Type ExternalToolTextResultForLlmContentType `json:"type"`
alias
}{
Type: r.Type(),
alias: alias(r),
})
}
func (r ExternalToolTextResultForLlmContentTerminal) MarshalJSON() ([]byte, error) {
type alias ExternalToolTextResultForLlmContentTerminal
return json.Marshal(struct {
Type ExternalToolTextResultForLlmContentType `json:"type"`
alias
}{
Type: r.Type(),
alias: alias(r),
})
}
func (r ExternalToolTextResultForLlmContentText) MarshalJSON() ([]byte, error) {
type alias ExternalToolTextResultForLlmContentText
return json.Marshal(struct {
Type ExternalToolTextResultForLlmContentType `json:"type"`
alias
}{
Type: r.Type(),
alias: alias(r),
})
}
func (r *ExternalToolTextResultForLlm) UnmarshalJSON(data []byte) error {
type rawExternalToolTextResultForLlm struct {
Contents []json.RawMessage `json:"contents,omitempty"`
Error *string `json:"error,omitempty"`
ResultType *string `json:"resultType,omitempty"`
SessionLog *string `json:"sessionLog,omitempty"`
TextResultForLlm string `json:"textResultForLlm"`
ToolTelemetry map[string]any `json:"toolTelemetry,omitempty"`
}
var raw rawExternalToolTextResultForLlm
if err := json.Unmarshal(data, &raw); err != nil {
return err
}
if raw.Contents != nil {
r.Contents = make([]ExternalToolTextResultForLlmContent, 0, len(raw.Contents))
for _, rawItem := range raw.Contents {
value, err := unmarshalExternalToolTextResultForLlmContent(rawItem)
if err != nil {
return err
}
r.Contents = append(r.Contents, value)
}
}
r.Error = raw.Error
r.ResultType = raw.ResultType
r.SessionLog = raw.SessionLog
r.TextResultForLlm = raw.TextResultForLlm
r.ToolTelemetry = raw.ToolTelemetry
return nil
}
func unmarshalExternalToolResult(data []byte) (ExternalToolResult, error) {
if string(data) == "null" {
return nil, nil
}
{
var value string
if err := json.Unmarshal(data, &value); err == nil {
return ExternalToolStringResult(value), nil
}
}
{
var value ExternalToolTextResultForLlm
if err := json.Unmarshal(data, &value); err == nil {
return &value, nil
}
}
return nil, errors.New("data did not match any union variant for ExternalToolResult")
}
func unmarshalFilterMapping(data []byte) (FilterMapping, error) {
if string(data) == "null" {
return nil, nil
}
{
var value FilterMappingEnumMap
if err := json.Unmarshal(data, &value); err == nil {
return value, nil
}
}
{
var value FilterMappingString
if err := json.Unmarshal(data, &value); err == nil {
return value, nil
}
}
return nil, errors.New("data did not match any union variant for FilterMapping")
}
func (r *HandlePendingToolCallRequest) UnmarshalJSON(data []byte) error {
type rawHandlePendingToolCallRequest struct {
Error *string `json:"error,omitempty"`
RequestID string `json:"requestId"`
Result json.RawMessage `json:"result,omitempty"`
}
var raw rawHandlePendingToolCallRequest
if err := json.Unmarshal(data, &raw); err != nil {
return err
}
r.Error = raw.Error
r.RequestID = raw.RequestID
if raw.Result != nil {
value, err := unmarshalExternalToolResult(raw.Result)
if err != nil {
return err
}
r.Result = value
}
return nil
}
func matchesMcpServerConfigHTTP(data []byte) bool {
var rawGroup0 struct {
Args json.RawMessage `json:"args"`
Command json.RawMessage `json:"command"`
URL json.RawMessage `json:"url"`
}
if err := json.Unmarshal(data, &rawGroup0); err != nil {
return false
}
if rawGroup0.URL == nil {
return false
}
if rawGroup0.Args != nil {
return false
}
return rawGroup0.Command == nil
}
func matchesMcpServerConfigLocal(data []byte) bool {
var rawGroup0 struct {
Args json.RawMessage `json:"args"`
Command json.RawMessage `json:"command"`
URL json.RawMessage `json:"url"`
}
if err := json.Unmarshal(data, &rawGroup0); err != nil {
return false
}
if rawGroup0.Args == nil {
return false
}
if rawGroup0.Command == nil {
return false
}
return rawGroup0.URL == nil
}
func unmarshalMcpServerConfig(data []byte) (McpServerConfig, error) {
if string(data) == "null" {
return nil, nil
}
if matchesMcpServerConfigHTTP(data) {
var d McpServerConfigHTTP
if err := json.Unmarshal(data, &d); err != nil {
return nil, err
}
return &d, nil
}
if matchesMcpServerConfigLocal(data) {
var d McpServerConfigLocal
if err := json.Unmarshal(data, &d); err != nil {
return nil, err
}
return &d, nil
}
return &RawMcpServerConfigData{Raw: data}, nil
}
func (r RawMcpServerConfigData) MarshalJSON() ([]byte, error) {
if r.Raw != nil {
return r.Raw, nil
}
return []byte("null"), nil
}
func (r *McpServerConfigHTTP) UnmarshalJSON(data []byte) error {
type rawMcpServerConfigHTTP struct {
FilterMapping json.RawMessage `json:"filterMapping,omitempty"`
Headers map[string]string `json:"headers,omitempty"`
IsDefaultServer *bool `json:"isDefaultServer,omitempty"`
OauthClientID *string `json:"oauthClientId,omitempty"`
OauthGrantType *McpServerConfigHTTPOauthGrantType `json:"oauthGrantType,omitempty"`
OauthPublicClient *bool `json:"oauthPublicClient,omitempty"`
Timeout *int64 `json:"timeout,omitempty"`
Tools []string `json:"tools,omitempty"`
Type *McpServerConfigHTTPType `json:"type,omitempty"`
URL string `json:"url"`
}
var raw rawMcpServerConfigHTTP
if err := json.Unmarshal(data, &raw); err != nil {
return err
}
if raw.FilterMapping != nil {
value, err := unmarshalFilterMapping(raw.FilterMapping)
if err != nil {
return err
}
r.FilterMapping = value
}
r.Headers = raw.Headers
r.IsDefaultServer = raw.IsDefaultServer
r.OauthClientID = raw.OauthClientID
r.OauthGrantType = raw.OauthGrantType
r.OauthPublicClient = raw.OauthPublicClient
r.Timeout = raw.Timeout
r.Tools = raw.Tools
r.Type = raw.Type
r.URL = raw.URL
return nil
}
func (r *McpServerConfigLocal) UnmarshalJSON(data []byte) error {
type rawMcpServerConfigLocal struct {
Args []string `json:"args"`
Command string `json:"command"`
Cwd *string `json:"cwd,omitempty"`
Env map[string]string `json:"env,omitempty"`
FilterMapping json.RawMessage `json:"filterMapping,omitempty"`
IsDefaultServer *bool `json:"isDefaultServer,omitempty"`
Timeout *int64 `json:"timeout,omitempty"`
Tools []string `json:"tools,omitempty"`
Type *McpServerConfigLocalType `json:"type,omitempty"`
}
var raw rawMcpServerConfigLocal
if err := json.Unmarshal(data, &raw); err != nil {
return err
}
r.Args = raw.Args
r.Command = raw.Command
r.Cwd = raw.Cwd
r.Env = raw.Env
if raw.FilterMapping != nil {
value, err := unmarshalFilterMapping(raw.FilterMapping)
if err != nil {
return err
}
r.FilterMapping = value
}
r.IsDefaultServer = raw.IsDefaultServer
r.Timeout = raw.Timeout
r.Tools = raw.Tools
r.Type = raw.Type
return nil
}
func (r *McpConfigAddRequest) UnmarshalJSON(data []byte) error {
type rawMcpConfigAddRequest struct {
Config json.RawMessage `json:"config"`
Name string `json:"name"`
}
var raw rawMcpConfigAddRequest
if err := json.Unmarshal(data, &raw); err != nil {
return err
}
if raw.Config != nil {
value, err := unmarshalMcpServerConfig(raw.Config)
if err != nil {
return err
}
r.Config = value
}
r.Name = raw.Name
return nil
}
func (r *McpConfigList) UnmarshalJSON(data []byte) error {
type rawMcpConfigList struct {
Servers map[string]json.RawMessage `json:"servers"`
}
var raw rawMcpConfigList
if err := json.Unmarshal(data, &raw); err != nil {
return err
}
if raw.Servers != nil {
r.Servers = make(map[string]McpServerConfig, len(raw.Servers))
for key, rawValue := range raw.Servers {
value, err := unmarshalMcpServerConfig(rawValue)
if err != nil {
return err
}
r.Servers[key] = value
}
}
return nil
}
func (r *McpConfigUpdateRequest) UnmarshalJSON(data []byte) error {
type rawMcpConfigUpdateRequest struct {
Config json.RawMessage `json:"config"`
Name string `json:"name"`
}
var raw rawMcpConfigUpdateRequest
if err := json.Unmarshal(data, &raw); err != nil {
return err
}
if raw.Config != nil {
value, err := unmarshalMcpServerConfig(raw.Config)
if err != nil {
return err
}
r.Config = value
}
r.Name = raw.Name
return nil
}
func unmarshalPermissionDecision(data []byte) (PermissionDecision, error) {
if string(data) == "null" {
return nil, nil
}
type rawUnion struct {
Kind PermissionDecisionKind `json:"kind"`
}
var raw rawUnion
if err := json.Unmarshal(data, &raw); err != nil {
return nil, err
}
switch raw.Kind {
case PermissionDecisionKindApproveForLocation:
var d PermissionDecisionApproveForLocation
if err := json.Unmarshal(data, &d); err != nil {
return nil, err
}
return &d, nil
case PermissionDecisionKindApproveForSession:
var d PermissionDecisionApproveForSession
if err := json.Unmarshal(data, &d); err != nil {
return nil, err
}
return &d, nil
case PermissionDecisionKindApproveOnce:
var d PermissionDecisionApproveOnce
if err := json.Unmarshal(data, &d); err != nil {
return nil, err
}
return &d, nil
case PermissionDecisionKindApprovePermanently:
var d PermissionDecisionApprovePermanently
if err := json.Unmarshal(data, &d); err != nil {
return nil, err
}
return &d, nil
case PermissionDecisionKindReject:
var d PermissionDecisionReject
if err := json.Unmarshal(data, &d); err != nil {
return nil, err
}
return &d, nil
case PermissionDecisionKindUserNotAvailable:
var d PermissionDecisionUserNotAvailable
if err := json.Unmarshal(data, &d); err != nil {
return nil, err
}
return &d, nil
default:
return &RawPermissionDecisionData{Discriminator: raw.Kind, Raw: data}, nil
}
}
func (r RawPermissionDecisionData) MarshalJSON() ([]byte, error) {
if r.Raw != nil {
return r.Raw, nil
}
return json.Marshal(struct {
Kind PermissionDecisionKind `json:"kind"`
}{
Kind: r.Discriminator,
})
}
func unmarshalPermissionDecisionApproveForLocationApproval(data []byte) (PermissionDecisionApproveForLocationApproval, error) {
if string(data) == "null" {
return nil, nil
}
type rawUnion struct {
Kind PermissionDecisionApproveForLocationApprovalKind `json:"kind"`
}
var raw rawUnion
if err := json.Unmarshal(data, &raw); err != nil {
return nil, err
}
switch raw.Kind {
case PermissionDecisionApproveForLocationApprovalKindCommands:
var d PermissionDecisionApproveForLocationApprovalCommands
if err := json.Unmarshal(data, &d); err != nil {
return nil, err
}
return &d, nil
case PermissionDecisionApproveForLocationApprovalKindCustomTool:
var d PermissionDecisionApproveForLocationApprovalCustomTool
if err := json.Unmarshal(data, &d); err != nil {
return nil, err
}
return &d, nil
case PermissionDecisionApproveForLocationApprovalKindExtensionManagement:
var d PermissionDecisionApproveForLocationApprovalExtensionManagement
if err := json.Unmarshal(data, &d); err != nil {
return nil, err
}
return &d, nil
case PermissionDecisionApproveForLocationApprovalKindExtensionPermissionAccess:
var d PermissionDecisionApproveForLocationApprovalExtensionPermissionAccess
if err := json.Unmarshal(data, &d); err != nil {
return nil, err
}
return &d, nil
case PermissionDecisionApproveForLocationApprovalKindMcp:
var d PermissionDecisionApproveForLocationApprovalMcp
if err := json.Unmarshal(data, &d); err != nil {
return nil, err
}
return &d, nil
case PermissionDecisionApproveForLocationApprovalKindMcpSampling:
var d PermissionDecisionApproveForLocationApprovalMcpSampling
if err := json.Unmarshal(data, &d); err != nil {
return nil, err
}
return &d, nil
case PermissionDecisionApproveForLocationApprovalKindMemory:
var d PermissionDecisionApproveForLocationApprovalMemory
if err := json.Unmarshal(data, &d); err != nil {
return nil, err
}
return &d, nil
case PermissionDecisionApproveForLocationApprovalKindRead:
var d PermissionDecisionApproveForLocationApprovalRead
if err := json.Unmarshal(data, &d); err != nil {
return nil, err
}
return &d, nil
case PermissionDecisionApproveForLocationApprovalKindWrite:
var d PermissionDecisionApproveForLocationApprovalWrite
if err := json.Unmarshal(data, &d); err != nil {
return nil, err
}
return &d, nil
default:
return &RawPermissionDecisionApproveForLocationApprovalData{Discriminator: raw.Kind, Raw: data}, nil
}
}
func (r RawPermissionDecisionApproveForLocationApprovalData) MarshalJSON() ([]byte, error) {
if r.Raw != nil {
return r.Raw, nil
}
return json.Marshal(struct {
Kind PermissionDecisionApproveForLocationApprovalKind `json:"kind"`
}{
Kind: r.Discriminator,
})
}
func (r PermissionDecisionApproveForLocationApprovalCommands) MarshalJSON() ([]byte, error) {
type alias PermissionDecisionApproveForLocationApprovalCommands
return json.Marshal(struct {
Kind PermissionDecisionApproveForLocationApprovalKind `json:"kind"`
alias
}{
Kind: r.Kind(),
alias: alias(r),
})
}
func (r PermissionDecisionApproveForLocationApprovalCustomTool) MarshalJSON() ([]byte, error) {
type alias PermissionDecisionApproveForLocationApprovalCustomTool
return json.Marshal(struct {
Kind PermissionDecisionApproveForLocationApprovalKind `json:"kind"`
alias
}{
Kind: r.Kind(),
alias: alias(r),
})
}
func (r PermissionDecisionApproveForLocationApprovalExtensionManagement) MarshalJSON() ([]byte, error) {
type alias PermissionDecisionApproveForLocationApprovalExtensionManagement
return json.Marshal(struct {
Kind PermissionDecisionApproveForLocationApprovalKind `json:"kind"`
alias
}{
Kind: r.Kind(),
alias: alias(r),
})
}
func (r PermissionDecisionApproveForLocationApprovalExtensionPermissionAccess) MarshalJSON() ([]byte, error) {
type alias PermissionDecisionApproveForLocationApprovalExtensionPermissionAccess
return json.Marshal(struct {
Kind PermissionDecisionApproveForLocationApprovalKind `json:"kind"`
alias
}{
Kind: r.Kind(),
alias: alias(r),
})
}
func (r PermissionDecisionApproveForLocationApprovalMcp) MarshalJSON() ([]byte, error) {
type alias PermissionDecisionApproveForLocationApprovalMcp
return json.Marshal(struct {
Kind PermissionDecisionApproveForLocationApprovalKind `json:"kind"`
alias
}{
Kind: r.Kind(),
alias: alias(r),
})
}
func (r PermissionDecisionApproveForLocationApprovalMcpSampling) MarshalJSON() ([]byte, error) {
type alias PermissionDecisionApproveForLocationApprovalMcpSampling
return json.Marshal(struct {
Kind PermissionDecisionApproveForLocationApprovalKind `json:"kind"`
alias
}{
Kind: r.Kind(),
alias: alias(r),
})
}
func (r PermissionDecisionApproveForLocationApprovalMemory) MarshalJSON() ([]byte, error) {
type alias PermissionDecisionApproveForLocationApprovalMemory
return json.Marshal(struct {
Kind PermissionDecisionApproveForLocationApprovalKind `json:"kind"`
alias
}{
Kind: r.Kind(),
alias: alias(r),
})
}
func (r PermissionDecisionApproveForLocationApprovalRead) MarshalJSON() ([]byte, error) {
type alias PermissionDecisionApproveForLocationApprovalRead
return json.Marshal(struct {
Kind PermissionDecisionApproveForLocationApprovalKind `json:"kind"`
alias
}{
Kind: r.Kind(),
alias: alias(r),
})
}
func (r PermissionDecisionApproveForLocationApprovalWrite) MarshalJSON() ([]byte, error) {
type alias PermissionDecisionApproveForLocationApprovalWrite
return json.Marshal(struct {
Kind PermissionDecisionApproveForLocationApprovalKind `json:"kind"`
alias
}{
Kind: r.Kind(),
alias: alias(r),
})
}
func (r *PermissionDecisionApproveForLocation) UnmarshalJSON(data []byte) error {
type rawPermissionDecisionApproveForLocation struct {
Approval json.RawMessage `json:"approval"`
LocationKey string `json:"locationKey"`
}
var raw rawPermissionDecisionApproveForLocation
if err := json.Unmarshal(data, &raw); err != nil {
return err
}
if raw.Approval != nil {
value, err := unmarshalPermissionDecisionApproveForLocationApproval(raw.Approval)
if err != nil {
return err
}
r.Approval = value
}
r.LocationKey = raw.LocationKey
return nil
}
func (r PermissionDecisionApproveForLocation) MarshalJSON() ([]byte, error) {
type alias PermissionDecisionApproveForLocation
return json.Marshal(struct {
Kind PermissionDecisionKind `json:"kind"`
alias
}{
Kind: r.Kind(),
alias: alias(r),
})
}
func unmarshalPermissionDecisionApproveForSessionApproval(data []byte) (PermissionDecisionApproveForSessionApproval, error) {
if string(data) == "null" {
return nil, nil
}
type rawUnion struct {
Kind PermissionDecisionApproveForSessionApprovalKind `json:"kind"`
}
var raw rawUnion
if err := json.Unmarshal(data, &raw); err != nil {
return nil, err
}
switch raw.Kind {
case PermissionDecisionApproveForSessionApprovalKindCommands:
var d PermissionDecisionApproveForSessionApprovalCommands
if err := json.Unmarshal(data, &d); err != nil {
return nil, err
}
return &d, nil
case PermissionDecisionApproveForSessionApprovalKindCustomTool:
var d PermissionDecisionApproveForSessionApprovalCustomTool
if err := json.Unmarshal(data, &d); err != nil {
return nil, err
}
return &d, nil
case PermissionDecisionApproveForSessionApprovalKindExtensionManagement:
var d PermissionDecisionApproveForSessionApprovalExtensionManagement
if err := json.Unmarshal(data, &d); err != nil {
return nil, err
}
return &d, nil
case PermissionDecisionApproveForSessionApprovalKindExtensionPermissionAccess:
var d PermissionDecisionApproveForSessionApprovalExtensionPermissionAccess
if err := json.Unmarshal(data, &d); err != nil {
return nil, err
}
return &d, nil
case PermissionDecisionApproveForSessionApprovalKindMcp:
var d PermissionDecisionApproveForSessionApprovalMcp
if err := json.Unmarshal(data, &d); err != nil {
return nil, err
}
return &d, nil
case PermissionDecisionApproveForSessionApprovalKindMcpSampling:
var d PermissionDecisionApproveForSessionApprovalMcpSampling
if err := json.Unmarshal(data, &d); err != nil {
return nil, err
}
return &d, nil
case PermissionDecisionApproveForSessionApprovalKindMemory:
var d PermissionDecisionApproveForSessionApprovalMemory
if err := json.Unmarshal(data, &d); err != nil {
return nil, err
}
return &d, nil
case PermissionDecisionApproveForSessionApprovalKindRead:
var d PermissionDecisionApproveForSessionApprovalRead
if err := json.Unmarshal(data, &d); err != nil {
return nil, err
}
return &d, nil
case PermissionDecisionApproveForSessionApprovalKindWrite:
var d PermissionDecisionApproveForSessionApprovalWrite
if err := json.Unmarshal(data, &d); err != nil {
return nil, err
}
return &d, nil
default:
return &RawPermissionDecisionApproveForSessionApprovalData{Discriminator: raw.Kind, Raw: data}, nil
}
}
func (r RawPermissionDecisionApproveForSessionApprovalData) MarshalJSON() ([]byte, error) {
if r.Raw != nil {
return r.Raw, nil
}
return json.Marshal(struct {
Kind PermissionDecisionApproveForSessionApprovalKind `json:"kind"`
}{
Kind: r.Discriminator,
})
}
func (r PermissionDecisionApproveForSessionApprovalCommands) MarshalJSON() ([]byte, error) {
type alias PermissionDecisionApproveForSessionApprovalCommands
return json.Marshal(struct {
Kind PermissionDecisionApproveForSessionApprovalKind `json:"kind"`
alias
}{
Kind: r.Kind(),
alias: alias(r),
})
}
func (r PermissionDecisionApproveForSessionApprovalCustomTool) MarshalJSON() ([]byte, error) {
type alias PermissionDecisionApproveForSessionApprovalCustomTool
return json.Marshal(struct {
Kind PermissionDecisionApproveForSessionApprovalKind `json:"kind"`
alias
}{
Kind: r.Kind(),
alias: alias(r),
})
}
func (r PermissionDecisionApproveForSessionApprovalExtensionManagement) MarshalJSON() ([]byte, error) {
type alias PermissionDecisionApproveForSessionApprovalExtensionManagement
return json.Marshal(struct {
Kind PermissionDecisionApproveForSessionApprovalKind `json:"kind"`
alias
}{
Kind: r.Kind(),
alias: alias(r),
})
}
func (r PermissionDecisionApproveForSessionApprovalExtensionPermissionAccess) MarshalJSON() ([]byte, error) {
type alias PermissionDecisionApproveForSessionApprovalExtensionPermissionAccess
return json.Marshal(struct {
Kind PermissionDecisionApproveForSessionApprovalKind `json:"kind"`
alias
}{
Kind: r.Kind(),
alias: alias(r),
})
}
func (r PermissionDecisionApproveForSessionApprovalMcp) MarshalJSON() ([]byte, error) {
type alias PermissionDecisionApproveForSessionApprovalMcp
return json.Marshal(struct {
Kind PermissionDecisionApproveForSessionApprovalKind `json:"kind"`
alias
}{
Kind: r.Kind(),
alias: alias(r),
})
}
func (r PermissionDecisionApproveForSessionApprovalMcpSampling) MarshalJSON() ([]byte, error) {
type alias PermissionDecisionApproveForSessionApprovalMcpSampling
return json.Marshal(struct {
Kind PermissionDecisionApproveForSessionApprovalKind `json:"kind"`
alias
}{
Kind: r.Kind(),
alias: alias(r),
})