perl-dap 0.12.2

Debug Adapter Protocol server for Perl
Documentation
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
//! DAP Protocol Types
//!
//! This module defines the JSON-RPC 2.0 message types for the Debug Adapter Protocol.
//! It follows the DAP 1.x specification with support for Perl-specific features.
//!
//! # Message Transport
//!
//! Messages are framed using Content-Length headers:
//! ```text
//! Content-Length: <length>\r\n
//! \r\n
//! <JSON message>
//! ```
//!
//! # References
//!
//! - [DAP Protocol Schema](../../docs/reference/DAP_PROTOCOL_SCHEMA.md)
//! - [Debug Adapter Protocol Specification](https://microsoft.github.io/debug-adapter-protocol/)

use serde::{Deserialize, Serialize};
use std::collections::HashMap;

/// Base request message
///
/// All DAP requests follow this structure with command-specific arguments.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Request {
    /// Sequence number (incremented for each message)
    pub seq: i64,
    /// Message type (always "request")
    #[serde(rename = "type")]
    pub msg_type: String,
    /// Command name (e.g., "initialize", "setBreakpoints")
    pub command: String,
    /// Command-specific arguments
    #[serde(skip_serializing_if = "Option::is_none")]
    pub arguments: Option<serde_json::Value>,
}

/// Base response message
///
/// All DAP responses follow this structure with command-specific body.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Response {
    /// Sequence number
    pub seq: i64,
    /// Message type (always "response")
    #[serde(rename = "type")]
    pub msg_type: String,
    /// Sequence number of corresponding request
    pub request_seq: i64,
    /// Whether the request succeeded
    pub success: bool,
    /// Command name
    pub command: String,
    /// Error message (if success=false)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub message: Option<String>,
    /// Command-specific response body
    #[serde(skip_serializing_if = "Option::is_none")]
    pub body: Option<serde_json::Value>,
}

/// Base event message
///
/// DAP events notify the client of state changes.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Event {
    /// Sequence number
    pub seq: i64,
    /// Message type (always "event")
    #[serde(rename = "type")]
    pub msg_type: String,
    /// Event name (e.g., "initialized", "stopped")
    pub event: String,
    /// Event-specific body
    #[serde(skip_serializing_if = "Option::is_none")]
    pub body: Option<serde_json::Value>,
}

// ============================================================================
// Breakpoint Request/Response Types (AC7)
// ============================================================================

/// Source reference in breakpoint requests
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Source {
    /// Absolute file path
    #[serde(skip_serializing_if = "Option::is_none")]
    pub path: Option<String>,
    /// File name (optional)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub name: Option<String>,
}

/// Source breakpoint in request
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SourceBreakpoint {
    /// Line number (1-based)
    pub line: i64,
    /// Column number (0-based, optional)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub column: Option<i64>,
    /// Breakpoint condition (optional)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub condition: Option<String>,
    /// Hit-condition expression (optional), e.g. `>= 10` or `%2`.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub hit_condition: Option<String>,
    /// Logpoint message (optional). When present, breakpoint logs and continues.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub log_message: Option<String>,
}

/// Arguments for setBreakpoints request
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SetBreakpointsArguments {
    /// Source file reference
    pub source: Source,
    /// Array of breakpoints to set (REPLACE semantics: clears existing)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub breakpoints: Option<Vec<SourceBreakpoint>>,
    /// Whether source file was modified
    #[serde(skip_serializing_if = "Option::is_none")]
    pub source_modified: Option<bool>,
}

/// Verified breakpoint in response
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Breakpoint {
    /// Unique breakpoint identifier
    pub id: i64,
    /// Whether breakpoint was successfully verified
    pub verified: bool,
    /// Actual line number (may differ from requested if adjusted)
    pub line: i64,
    /// Actual column number (optional)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub column: Option<i64>,
    /// Error/warning message if not verified or adjusted
    #[serde(skip_serializing_if = "Option::is_none")]
    pub message: Option<String>,
}

/// Response body for setBreakpoints request
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SetBreakpointsResponseBody {
    /// Array of verified breakpoints (SAME ORDER as request)
    pub breakpoints: Vec<Breakpoint>,
}

// ============================================================================
// Inline Values Request/Response Types (Custom)
// ============================================================================

/// Arguments for inlineValues request
///
/// This request is a lightweight, Perl-specific extension that mirrors the
/// LSP inlineValue provider using a source file and line range.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct InlineValuesArguments {
    /// Source file reference
    pub source: Source,
    /// Start line (1-based, inclusive)
    pub start_line: i64,
    /// End line (1-based, inclusive)
    pub end_line: i64,
}

/// Inline value hint for a single variable
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct InlineValueText {
    /// Line number (1-based)
    pub line: i64,
    /// Column number (1-based)
    pub column: i64,
    /// Rendered inline value text
    pub text: String,
}

/// Response body for inlineValues request
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct InlineValuesResponseBody {
    /// Inline values for the requested range
    pub inline_values: Vec<InlineValueText>,
}

// ============================================================================
// Initialize Request/Response Types (AC5)
// ============================================================================

/// Arguments for initialize request
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct InitializeRequestArguments {
    /// Client ID (e.g., "vscode")
    #[serde(skip_serializing_if = "Option::is_none")]
    pub client_id: Option<String>,
    /// Client name (e.g., "Visual Studio Code")
    #[serde(skip_serializing_if = "Option::is_none")]
    pub client_name: Option<String>,
    /// Adapter ID (e.g., "perl-rs")
    pub adapter_id: String,
    /// Locale (e.g., "en-US")
    #[serde(skip_serializing_if = "Option::is_none")]
    pub locale: Option<String>,
    /// Lines are 1-based
    #[serde(skip_serializing_if = "Option::is_none")]
    pub lines_start_at1: Option<bool>,
    /// Columns are 1-based
    #[serde(skip_serializing_if = "Option::is_none")]
    pub columns_start_at1: Option<bool>,
    /// Path format ("path" or "uri")
    #[serde(skip_serializing_if = "Option::is_none")]
    pub path_format: Option<String>,
}

/// Response body for initialize request
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Capabilities {
    /// Supports configuration done request
    #[serde(skip_serializing_if = "Option::is_none")]
    pub supports_configuration_done_request: Option<bool>,
    /// Supports evaluate for hovers
    #[serde(skip_serializing_if = "Option::is_none")]
    pub supports_evaluate_for_hovers: Option<bool>,
    /// Supports conditional breakpoints
    #[serde(skip_serializing_if = "Option::is_none")]
    pub supports_conditional_breakpoints: Option<bool>,
    /// Supports hit-conditional breakpoints
    #[serde(skip_serializing_if = "Option::is_none")]
    pub supports_hit_conditional_breakpoints: Option<bool>,
    /// Supports logpoints
    #[serde(skip_serializing_if = "Option::is_none")]
    pub supports_log_points: Option<bool>,
    /// Supports exception breakpoint options
    #[serde(skip_serializing_if = "Option::is_none")]
    pub supports_exception_options: Option<bool>,
    /// Supports exception filter options
    #[serde(skip_serializing_if = "Option::is_none")]
    pub supports_exception_filter_options: Option<bool>,
    /// Supports terminate request
    #[serde(skip_serializing_if = "Option::is_none")]
    pub supports_terminate_request: Option<bool>,
    /// Supports custom inlineValues request for inline debug hints
    #[serde(skip_serializing_if = "Option::is_none")]
    pub supports_inline_values: Option<bool>,
    /// Supports function breakpoints
    #[serde(skip_serializing_if = "Option::is_none")]
    pub supports_function_breakpoints: Option<bool>,
    /// Supports setting variables
    #[serde(skip_serializing_if = "Option::is_none")]
    pub supports_set_variable: Option<bool>,
    /// Supports value formatting options
    #[serde(skip_serializing_if = "Option::is_none")]
    pub supports_value_formatting_options: Option<bool>,
    /// Supports terminating the debuggee on disconnect
    #[serde(skip_serializing_if = "Option::is_none")]
    pub support_terminate_debuggee: Option<bool>,
    /// Supports stepping backwards
    #[serde(skip_serializing_if = "Option::is_none")]
    pub supports_step_back: Option<bool>,
    /// Supports data breakpoints
    #[serde(skip_serializing_if = "Option::is_none")]
    pub supports_data_breakpoints: Option<bool>,
    /// Exception breakpoint filters
    #[serde(skip_serializing_if = "Option::is_none")]
    pub exception_breakpoint_filters: Option<Vec<ExceptionBreakpointFilter>>,
}

// ============================================================================
// Launch Request/Response Types
// ============================================================================

/// Arguments for launch request
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct LaunchRequestArguments {
    /// Absolute path to Perl script
    pub program: String,
    /// Command-line arguments
    #[serde(skip_serializing_if = "Option::is_none")]
    pub args: Option<Vec<String>>,
    /// Working directory
    #[serde(skip_serializing_if = "Option::is_none")]
    pub cwd: Option<String>,
    /// Environment variables
    #[serde(skip_serializing_if = "Option::is_none")]
    pub env: Option<HashMap<String, String>>,
    /// Path to Perl executable
    #[serde(skip_serializing_if = "Option::is_none")]
    pub perl_path: Option<String>,
    /// Stop on entry
    #[serde(skip_serializing_if = "Option::is_none")]
    pub stop_on_entry: Option<bool>,
}

// ============================================================================
// Attach Request/Response Types
// ============================================================================

/// Arguments for attach request
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct AttachRequestArguments {
    /// Process ID to attach to
    #[serde(skip_serializing_if = "Option::is_none")]
    pub process_id: Option<u32>,
    /// Host to connect to (for TCP attachment)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub host: Option<String>,
    /// Port number for TCP attachment
    #[serde(skip_serializing_if = "Option::is_none")]
    pub port: Option<u16>,
    /// Connection timeout in milliseconds
    #[serde(skip_serializing_if = "Option::is_none")]
    pub timeout: Option<u32>,
}

// ============================================================================
// Stack/Variables/Scopes Request Arguments (AC8)
// ============================================================================

/// Arguments for stackTrace request
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct StackTraceArguments {
    /// Thread to retrieve the stack trace for
    pub thread_id: i64,
    /// Index of the first frame to return (0-based)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub start_frame: Option<i64>,
    /// Maximum number of frames to return
    #[serde(skip_serializing_if = "Option::is_none")]
    pub levels: Option<i64>,
}

/// Arguments for scopes request
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ScopesArguments {
    /// Frame identifier to retrieve scopes for
    pub frame_id: i64,
}

/// Arguments for variables request
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct VariablesArguments {
    /// Reference to the variable container
    pub variables_reference: i64,
    /// Optional filter ("indexed" or "named")
    #[serde(skip_serializing_if = "Option::is_none")]
    pub filter: Option<String>,
    /// Start index of variables to return
    #[serde(skip_serializing_if = "Option::is_none")]
    pub start: Option<i64>,
    /// Number of variables to return
    #[serde(skip_serializing_if = "Option::is_none")]
    pub count: Option<i64>,
}

/// Arguments for evaluate request
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct EvaluateArguments {
    /// Expression to evaluate
    pub expression: String,
    /// Stack frame context for evaluation
    #[serde(skip_serializing_if = "Option::is_none")]
    pub frame_id: Option<i64>,
    /// Evaluation context ("watch", "repl", "hover", "clipboard")
    #[serde(skip_serializing_if = "Option::is_none")]
    pub context: Option<String>,
    /// Whether side effects are allowed during evaluation
    #[serde(skip_serializing_if = "Option::is_none")]
    pub allow_side_effects: Option<bool>,
}

// ============================================================================
// Control Flow Request Arguments (AC9)
// ============================================================================

/// Arguments for continue request
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ContinueArguments {
    /// Thread to continue
    pub thread_id: i64,
}

/// Arguments for next (step over) request
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct NextArguments {
    /// Thread to step
    pub thread_id: i64,
}

/// Arguments for stepIn request
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct StepInArguments {
    /// Thread to step into
    pub thread_id: i64,
}

/// Arguments for stepOut request
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct StepOutArguments {
    /// Thread to step out of
    pub thread_id: i64,
}

/// Arguments for pause request
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PauseArguments {
    /// Thread to pause
    pub thread_id: i64,
}

// ============================================================================
// Variable Modification Request Arguments (AC8)
// ============================================================================

/// Arguments for setVariable request
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SetVariableArguments {
    /// Reference to the variable container
    pub variables_reference: i64,
    /// Name of the variable to set
    pub name: String,
    /// New value for the variable
    pub value: String,
}

// ============================================================================
// Session Lifecycle Request Arguments (AC5)
// ============================================================================

/// Arguments for disconnect request
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct DisconnectArguments {
    /// Whether to restart the debug session
    #[serde(skip_serializing_if = "Option::is_none")]
    pub restart: Option<bool>,
    /// Whether to terminate the debuggee process
    #[serde(skip_serializing_if = "Option::is_none")]
    pub terminate_debuggee: Option<bool>,
}

/// Arguments for terminate request
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct TerminateArguments {
    /// Whether to restart after termination
    #[serde(skip_serializing_if = "Option::is_none")]
    pub restart: Option<bool>,
}

// ============================================================================
// Extended Breakpoint Request Arguments (AC7)
// ============================================================================

/// Arguments for setFunctionBreakpoints request
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SetFunctionBreakpointsArguments {
    /// Function breakpoints to set
    pub breakpoints: Vec<FunctionBreakpoint>,
}

/// Arguments for setExceptionBreakpoints request
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SetExceptionBreakpointsArguments {
    /// Exception filter IDs to activate
    pub filters: Vec<String>,
    /// Additional exception filter options
    #[serde(skip_serializing_if = "Option::is_none")]
    pub filter_options: Option<Vec<ExceptionFilterOption>>,
}

// ============================================================================
// Supporting Types
// ============================================================================

/// Function breakpoint specification
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct FunctionBreakpoint {
    /// Name of the function to break on
    pub name: String,
    /// Breakpoint condition expression
    #[serde(skip_serializing_if = "Option::is_none")]
    pub condition: Option<String>,
    /// Hit-condition expression
    #[serde(skip_serializing_if = "Option::is_none")]
    pub hit_condition: Option<String>,
}

/// Exception filter option for fine-grained exception breakpoints
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ExceptionFilterOption {
    /// ID of the exception filter
    pub filter_id: String,
    /// Condition expression for the filter
    #[serde(skip_serializing_if = "Option::is_none")]
    pub condition: Option<String>,
}

/// Exception breakpoint filter descriptor (reported in capabilities)
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ExceptionBreakpointFilter {
    /// Unique filter identifier
    pub filter: String,
    /// Human-readable label for the filter
    pub label: String,
    /// Whether this filter is enabled by default
    #[serde(skip_serializing_if = "Option::is_none")]
    pub default: Option<bool>,
}

/// A thread in the debuggee
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Thread {
    /// Thread identifier
    pub id: i64,
    /// Human-readable thread name
    pub name: String,
}

/// A scope within a stack frame
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Scope {
    /// Scope name (e.g., "Locals", "Globals")
    pub name: String,
    /// Presentation hint ("arguments", "locals", "registers")
    #[serde(skip_serializing_if = "Option::is_none")]
    pub presentation_hint: Option<String>,
    /// Reference to the variables in this scope
    pub variables_reference: i64,
    /// Whether fetching variables is expensive
    pub expensive: bool,
}

/// A variable in the debuggee
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ProtocolVariable {
    /// Variable name
    pub name: String,
    /// String representation of the variable value
    pub value: String,
    /// Type of the variable
    #[serde(rename = "type", skip_serializing_if = "Option::is_none")]
    pub type_: Option<String>,
    /// Reference for child variables (0 means no children)
    pub variables_reference: i64,
    /// Number of named child variables
    #[serde(skip_serializing_if = "Option::is_none")]
    pub named_variables: Option<i64>,
    /// Number of indexed child variables
    #[serde(skip_serializing_if = "Option::is_none")]
    pub indexed_variables: Option<i64>,
}

/// A stack frame in the call stack
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ProtocolStackFrame {
    /// Frame identifier
    pub id: i64,
    /// Name of the frame (typically the function name)
    pub name: String,
    /// Source location of the frame
    #[serde(skip_serializing_if = "Option::is_none")]
    pub source: Option<Source>,
    /// Line number (1-based)
    pub line: i64,
    /// Column number (1-based)
    pub column: i64,
    /// End line number (optional)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub end_line: Option<i64>,
    /// End column number (optional)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub end_column: Option<i64>,
}

// ============================================================================
// Response Body Types
// ============================================================================

/// Response body for threads request
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ThreadsResponseBody {
    /// All threads in the debuggee
    pub threads: Vec<Thread>,
}

/// Response body for stackTrace request
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct StackTraceResponseBody {
    /// Stack frames in the call stack
    pub stack_frames: Vec<ProtocolStackFrame>,
    /// Total number of frames available
    #[serde(skip_serializing_if = "Option::is_none")]
    pub total_frames: Option<i64>,
}

/// Response body for scopes request
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ScopesResponseBody {
    /// Scopes in the specified stack frame
    pub scopes: Vec<Scope>,
}

/// Response body for variables request
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct VariablesResponseBody {
    /// Variables in the specified scope or container
    pub variables: Vec<ProtocolVariable>,
}

/// Response body for continue request
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ContinueResponseBody {
    /// Whether all threads were continued
    pub all_threads_continued: bool,
}

/// Response body for evaluate request
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct EvaluateResponseBody {
    /// String representation of the evaluation result
    pub result: String,
    /// Type of the result
    #[serde(rename = "type", skip_serializing_if = "Option::is_none")]
    pub type_: Option<String>,
    /// Reference for structured result (0 means no children)
    pub variables_reference: i64,
}

/// Response body for setVariable request
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SetVariableResponseBody {
    /// New string representation of the variable value
    pub value: String,
    /// Type of the variable after setting
    #[serde(rename = "type", skip_serializing_if = "Option::is_none")]
    pub type_: Option<String>,
    /// Reference for child variables (0 means no children)
    pub variables_reference: i64,
}

// ============================================================================
// Breakpoint Locations Request/Response Types
// ============================================================================

/// Arguments for `breakpointLocations` request
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct BreakpointLocationsArguments {
    /// The source location of the breakpoints
    pub source: Source,
    /// Start line of range to query (1-based)
    pub line: i64,
    /// Optional end line of range (1-based, defaults to line)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub end_line: Option<i64>,
}

/// A breakpoint location
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct BreakpointLocation {
    /// Line number (1-based)
    pub line: i64,
    /// Optional column number (1-based)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub column: Option<i64>,
    /// Optional end line
    #[serde(skip_serializing_if = "Option::is_none")]
    pub end_line: Option<i64>,
    /// Optional end column
    #[serde(skip_serializing_if = "Option::is_none")]
    pub end_column: Option<i64>,
}

/// Response body for `breakpointLocations` request
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct BreakpointLocationsResponseBody {
    /// Sorted set of possible breakpoint locations
    pub breakpoints: Vec<BreakpointLocation>,
}

// ============================================================================
// Source Request/Response Types
// ============================================================================

/// Arguments for `source` request
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SourceArguments {
    /// Source reference (> 0)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub source_reference: Option<i64>,
    /// The source to retrieve content for
    #[serde(skip_serializing_if = "Option::is_none")]
    pub source: Option<Source>,
}

/// Response body for `source` request
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SourceResponseBody {
    /// Content of the source
    pub content: String,
    /// MIME type of the content
    #[serde(skip_serializing_if = "Option::is_none")]
    pub mime_type: Option<String>,
}

// ============================================================================
// Step In Targets Request/Response Types
// ============================================================================

/// Arguments for `stepInTargets` request
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct StepInTargetsArguments {
    /// The frame for which to retrieve step-in targets
    pub frame_id: i64,
}

/// A step-in target
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct StepInTarget {
    /// Unique identifier for this target
    pub id: i64,
    /// The name of the target
    pub label: String,
}

/// Response body for `stepInTargets` request
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct StepInTargetsResponseBody {
    /// The step-in targets
    pub targets: Vec<StepInTarget>,
}

// ============================================================================
// Goto Targets Request/Response Types
// ============================================================================

/// Arguments for `gotoTargets` request
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct GotoTargetsArguments {
    /// The source for which to find targets
    pub source: Source,
    /// The line for which to find targets
    pub line: i64,
    /// Optional column for which to find targets
    #[serde(skip_serializing_if = "Option::is_none")]
    pub column: Option<i64>,
}

/// A goto target
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct GotoTarget {
    /// Unique identifier for this target
    pub id: i64,
    /// The name of the target
    pub label: String,
    /// The line of the target
    pub line: i64,
    /// Optional column of the target
    #[serde(skip_serializing_if = "Option::is_none")]
    pub column: Option<i64>,
    /// Optional end line of the target
    #[serde(skip_serializing_if = "Option::is_none")]
    pub end_line: Option<i64>,
    /// Optional end column of the target
    #[serde(skip_serializing_if = "Option::is_none")]
    pub end_column: Option<i64>,
}

/// Response body for `gotoTargets` request
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct GotoTargetsResponseBody {
    /// The goto targets
    pub targets: Vec<GotoTarget>,
}

// ============================================================================
// Exception Info Request/Response Types
// ============================================================================

/// Arguments for `exceptionInfo` request
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ExceptionInfoArguments {
    /// Thread for which to retrieve exception info
    pub thread_id: i64,
}

/// Detailed information about an exception
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ExceptionDetails {
    /// Message contained in the exception
    #[serde(skip_serializing_if = "Option::is_none")]
    pub message: Option<String>,
    /// Short type name of the exception object
    #[serde(rename = "typeName", skip_serializing_if = "Option::is_none")]
    pub type_name: Option<String>,
    /// Formatted stack trace for the exception
    #[serde(skip_serializing_if = "Option::is_none")]
    pub stack_trace: Option<String>,
}

/// Response body for `exceptionInfo` request
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ExceptionInfoResponseBody {
    /// ID of the exception that was thrown
    pub exception_id: String,
    /// Descriptive text for the exception
    #[serde(skip_serializing_if = "Option::is_none")]
    pub description: Option<String>,
    /// Mode that caused the exception notification (never, always, unhandled, userUnhandled)
    pub break_mode: String,
    /// Detailed information about the exception
    #[serde(skip_serializing_if = "Option::is_none")]
    pub details: Option<ExceptionDetails>,
}

// ============================================================================
// Set Expression Request/Response Types
// ============================================================================

/// Arguments for `setExpression` request
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SetExpressionArguments {
    /// The l-value expression to assign to
    pub expression: String,
    /// The value expression to assign
    pub value: String,
    /// Evaluate the expressions in the scope of this stack frame (optional)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub frame_id: Option<i64>,
}

/// Response body for `setExpression` request
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SetExpressionResponseBody {
    /// The new value of the expression
    pub value: String,
    /// The type of the value
    #[serde(rename = "type", skip_serializing_if = "Option::is_none")]
    pub type_: Option<String>,
    /// Reference for structured result (0 means no children)
    pub variables_reference: i64,
}

// ============================================================================
// Restart Request Types
// ============================================================================

/// Arguments for `restart` request
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct RestartArguments {
    /// Updated launch/attach configuration arguments (optional)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub arguments: Option<serde_json::Value>,
}

// ============================================================================
// Loaded Sources Request/Response Types
// ============================================================================

/// Response body for `loadedSources` request
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct LoadedSourcesResponseBody {
    /// Set of loaded sources
    pub sources: Vec<Source>,
}

// ============================================================================
// Modules Request/Response Types
// ============================================================================

/// Arguments for `modules` request
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ModulesArguments {
    /// Index of the first module to return (0-based)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub start_module: Option<i64>,
    /// Number of modules to return
    #[serde(skip_serializing_if = "Option::is_none")]
    pub module_count: Option<i64>,
}

/// A module in the debuggee
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Module {
    /// Unique identifier for the module
    pub id: String,
    /// Module name (e.g., "Foo::Bar")
    pub name: String,
    /// Absolute path on disk
    #[serde(skip_serializing_if = "Option::is_none")]
    pub path: Option<String>,
}

/// Response body for `modules` request
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ModulesResponseBody {
    /// All modules
    pub modules: Vec<Module>,
    /// Total number of modules available
    #[serde(skip_serializing_if = "Option::is_none")]
    pub total_modules: Option<i64>,
}

// ============================================================================
// Completions Request/Response Types
// ============================================================================

/// Arguments for `completions` request
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct CompletionsArguments {
    /// The text to compute completions for
    pub text: String,
    /// The column position (0-based) within `text` for which to compute completions
    pub column: i64,
    /// Frame ID for context (optional)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub frame_id: Option<i64>,
    /// Line number (optional, for multi-line text)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub line: Option<i64>,
}

/// A single completion item
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct CompletionItem {
    /// The label of this completion item (shown in the UI)
    pub label: String,
    /// Type classification of this item
    #[serde(rename = "type", skip_serializing_if = "Option::is_none")]
    pub type_: Option<String>,
    /// Replacement text (if different from label)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub text: Option<String>,
    /// Sort text used for ordering
    #[serde(skip_serializing_if = "Option::is_none")]
    pub sort_text: Option<String>,
    /// Detailed information about this item
    #[serde(skip_serializing_if = "Option::is_none")]
    pub detail: Option<String>,
    /// Start position for text replacement (0-based column)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub start: Option<i64>,
    /// Number of characters to replace
    #[serde(skip_serializing_if = "Option::is_none")]
    pub length: Option<i64>,
}

/// Response body for `completions` request
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct CompletionsResponseBody {
    /// The completion items
    pub targets: Vec<CompletionItem>,
}

// ============================================================================
// Data Breakpoint Info Request/Response Types
// ============================================================================

/// Arguments for `dataBreakpointInfo` request
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct DataBreakpointInfoArguments {
    /// Variable name to get data breakpoint info for
    pub name: String,
    /// Reference to the variable container
    #[serde(skip_serializing_if = "Option::is_none")]
    pub variables_reference: Option<i64>,
    /// Frame ID for context
    #[serde(skip_serializing_if = "Option::is_none")]
    pub frame_id: Option<i64>,
}

/// Response body for `dataBreakpointInfo` request
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct DataBreakpointInfoResponseBody {
    /// Identifier for the data (null/None means not available)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub data_id: Option<String>,
    /// Description of the data
    pub description: String,
    /// Available access types for this data
    #[serde(skip_serializing_if = "Option::is_none")]
    pub access_types: Option<Vec<String>>,
}

// ============================================================================
// Set Data Breakpoints Request/Response Types
// ============================================================================

/// A data breakpoint in the request
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct DataBreakpoint {
    /// Identifier obtained from `dataBreakpointInfo`
    pub data_id: String,
    /// Access type (e.g., "write", "read", "readWrite")
    #[serde(skip_serializing_if = "Option::is_none")]
    pub access_type: Option<String>,
    /// Optional condition expression
    #[serde(skip_serializing_if = "Option::is_none")]
    pub condition: Option<String>,
    /// Optional hit condition
    #[serde(skip_serializing_if = "Option::is_none")]
    pub hit_condition: Option<String>,
}

/// Arguments for `setDataBreakpoints` request
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SetDataBreakpointsArguments {
    /// The data breakpoints to set (replaces all existing)
    pub breakpoints: Vec<DataBreakpoint>,
}

/// Response body for `setDataBreakpoints` request
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SetDataBreakpointsResponseBody {
    /// Information about the data breakpoints (same order as request)
    pub breakpoints: Vec<Breakpoint>,
}

// ============================================================================
// Goto Request Types
// ============================================================================

/// Arguments for goto request
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct GotoArguments {
    /// Thread to perform the goto on
    pub thread_id: i64,
    /// Target obtained from gotoTargets
    pub target_id: i64,
}

// ============================================================================
// Cancel Request Types
// ============================================================================

/// Arguments for cancel request
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct CancelArguments {
    /// ID of the request to cancel
    #[serde(skip_serializing_if = "Option::is_none")]
    pub request_id: Option<i64>,
    /// ID of the progress to cancel
    #[serde(skip_serializing_if = "Option::is_none")]
    pub progress_id: Option<String>,
}

// ============================================================================
// Restart Frame Request Types
// ============================================================================

/// Arguments for restartFrame request
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct RestartFrameArguments {
    /// Frame to restart
    pub frame_id: i64,
}

// ============================================================================
// Terminate Threads Request Types
// ============================================================================

/// Arguments for terminateThreads request
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct TerminateThreadsArguments {
    /// IDs of threads to terminate
    #[serde(skip_serializing_if = "Option::is_none")]
    pub thread_ids: Option<Vec<i64>>,
}