1interface dap {
2 use common.{env-vars};
3
4 /// Resolves a specified TcpArgumentsTemplate into TcpArguments
5 resolve-tcp-template: func(template: tcp-arguments-template) -> result<tcp-arguments, string>;
6
7 record launch-request {
8 program: string,
9 cwd: option<string>,
10 args: list<string>,
11 envs: env-vars,
12 }
13
14 record attach-request {
15 process-id: option<u32>,
16 }
17
18 variant debug-request {
19 launch(launch-request),
20 attach(attach-request)
21 }
22
23 record tcp-arguments {
24 port: u16,
25 host: u32,
26 timeout: option<u64>,
27 }
28
29 record tcp-arguments-template {
30 port: option<u16>,
31 host: option<u32>,
32 timeout: option<u64>,
33 }
34
35 /// Debug Config is the "highest-level" configuration for a debug session.
36 /// It comes from a new process modal UI; thus, it is essentially debug-adapter-agnostic.
37 /// It is expected of the extension to translate this generic configuration into something that can be debugged by the adapter (debug scenario).
38 record debug-config {
39 /// Name of the debug task
40 label: string,
41 /// The debug adapter to use
42 adapter: string,
43 request: debug-request,
44 stop-on-entry: option<bool>,
45 }
46
47 record task-template {
48 /// Human readable name of the task to display in the UI.
49 label: string,
50 /// Executable command to spawn.
51 command: string,
52 args: list<string>,
53 env: env-vars,
54 cwd: option<string>,
55 }
56
57 /// A task template with substituted task variables.
58 type resolved-task = task-template;
59
60 /// A task template for building a debug target.
61 type build-task-template = task-template;
62
63 variant build-task-definition {
64 by-name(string),
65 template(build-task-definition-template-payload )
66 }
67 record build-task-definition-template-payload {
68 locator-name: option<string>,
69 template: build-task-template
70 }
71
72 /// Debug Scenario is the user-facing configuration type (used in debug.json). It is still concerned with what to debug and not necessarily how to do it (except for any
73 /// debug-adapter-specific configuration options).
74 record debug-scenario {
75 /// Unsubstituted label for the task.DebugAdapterBinary
76 label: string,
77 /// Name of the Debug Adapter this configuration is intended for.
78 adapter: string,
79 /// An optional build step to be ran prior to starting a debug session. Build steps are used by Zed's locators to locate the executable to debug.
80 build: option<build-task-definition>,
81 /// JSON-encoded configuration for a given debug adapter.
82 config: string,
83 /// TCP connection parameters (if they were specified by user)
84 tcp-connection: option<tcp-arguments-template>,
85 }
86
87 enum start-debugging-request-arguments-request {
88 launch,
89 attach,
90 }
91
92 record debug-task-definition {
93 /// Unsubstituted label for the task.DebugAdapterBinary
94 label: string,
95 /// Name of the Debug Adapter this configuration is intended for.
96 adapter: string,
97 /// JSON-encoded configuration for a given debug adapter.
98 config: string,
99 /// TCP connection parameters (if they were specified by user)
100 tcp-connection: option<tcp-arguments-template>,
101 }
102
103 record start-debugging-request-arguments {
104 /// JSON-encoded configuration for a given debug adapter. It is specific to each debug adapter.
105 /// `configuration` will have it's Zed variable references substituted prior to being passed to the debug adapter.
106 configuration: string,
107 request: start-debugging-request-arguments-request,
108 }
109
110 /// The lowest-level representation of a debug session, which specifies:
111 /// - How to start a debug adapter process
112 /// - How to start a debug session with it (using DAP protocol)
113 /// for a given debug scenario.
114 record debug-adapter-binary {
115 command: option<string>,
116 arguments: list<string>,
117 envs: env-vars,
118 cwd: option<string>,
119 /// Zed will use TCP transport if `connection` is specified.
120 connection: option<tcp-arguments>,
121 request-args: start-debugging-request-arguments
122 }
123}