ide на основе vs code · VibeGit
ide на основе vs code Это ide на основе vs code(code oss), в ней будет встроенный умный апи роутинг, свой маркет с плагинами(агент харнесс, поддержка java/kotlin/мобильной разработки, командная разработка проектов, orca, оркестратор агентов
krutaya-ide-na-osnove-vs-code / cli / src / tunnels / protocol.rs 497 строк · изменён 14 нояб., 04:52
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
use std:: collections:: HashMap ;
use crate :: {
constants:: { PROTOCOL_VERSION , VSCODE_CLI_VERSION } ,
options:: Quality ,
update_service:: Platform ,
} ;
use serde:: { Deserialize , Serialize } ;
#[derive(Serialize, Debug)]
#[serde(tag = "method" , content = "params" , rename_all = "camelCase" )]
#[allow(non_camel_case_types)]
pub enum ClientRequestMethod < 'a
segment
complete
req_id
url
method
req_id
status_code
headers
req_id
port
public
port
uri
socket_id
commit_id
quality
extensions
connection_token
use_local_download
compress
do_update
i
body
i
i
body
up_to_date
did_update
id
params
line
level
value
env
os_platform
os_release
pid
success
path
kind
kind
kind
kind
exists
size
kind
contents
name
kind
from_path
to_path
port
host
path
method
headers
body
status
body
headers
version
protocol_version
version
protocol_version
command
args
cwd
env
platform
quality
commit_id
spawn
message
exit_code
token
challenge
response
f
f
number
privacy
protocol
ports
port_format
level
prefix
message
level
prefix
message
name
tunnel_id
has_editor_link
status
started_at
tunnel
last_connected_at
last_disconnected_at
last_fail_reason
started_at
tunnel
last_connected_at
last_disconnected_at
last_fail_reason
legacy
name
tunnel_id
has_editor_link
status
legacy
parsed legacy
parsed name parsed has_editor_link
expected
name
tunnel_id
has_editor_link
status
parsed
expected
parsed name parsed tunnel_id
legacy
name
tunnel_id
has_editor_link
status
legacy
parsed legacy
parsed tunnel_id
>
{
servermsg
(
RefServerMessageParams
<
'a
>
)
,
serverclose
(
ServerClosedParams
)
,
serverlog
(
ServerLog
<
'a
>
)
,
makehttpreq
(
HttpRequestParams
<
'a
>
)
,
version
(
VersionResponse
)
,
}
#[derive(Deserialize, Debug)]
pub
struct
HttpBodyParams
{
#[serde(with = "serde_bytes" )]
pub
:
Vec
<
u8
>
,
pub
:
bool
,
pub
:
u32
,
}
#[derive(Serialize, Debug)]
pub
struct
HttpRequestParams
<
'a
>
{
pub
:
&
'a
str
,
pub
:
&
'static
str
,
pub
:
u32
,
}
#[derive(Deserialize, Debug)]
pub
struct
HttpHeadersParams
{
pub
:
u16
,
pub
:
Vec
<
(
String
,
String
)
>
,
pub
:
u32
,
}
#[derive(Deserialize, Debug)]
pub
struct
ForwardParams
{
pub
:
u16
,
#[serde(default)]
pub
:
bool
,
}
#[derive(Deserialize, Debug)]
pub
struct
UnforwardParams
{
pub
:
u16
,
}
#[derive(Serialize)]
pub
struct
ForwardResult
{
pub
:
String
,
}
#[derive(Deserialize, Debug)]
pub
struct
ServeParams
{
pub
:
u16
,
pub
:
Option
<
String
>
,
pub
:
Quality
,
pub
:
Vec
<
String
>
,
#[serde(default)]
pub
:
Option
<
String
>
,
#[serde(default)]
pub
:
bool
,
#[serde(default)]
pub
:
bool
,
}
#[derive(Deserialize, Serialize, Debug)]
pub
struct
EmptyObject
{
}
#[derive(Serialize, Deserialize, Debug)]
pub
struct
UpdateParams
{
pub
:
bool
,
}
#[derive(Deserialize, Debug)]
pub
struct
ServerMessageParams
{
pub
:
u16
,
#[serde(with = "serde_bytes" )]
pub
:
Vec
<
u8
>
,
}
#[derive(Serialize, Debug)]
pub
struct
ServerClosedParams
{
pub
:
u16
,
}
#[derive(Serialize, Debug)]
pub
struct
RefServerMessageParams
<
'a
>
{
pub
:
u16
,
#[serde(with = "serde_bytes" )]
pub
:
&
'a
[
u8
]
,
}
#[derive(Serialize)]
pub
struct
UpdateResult
{
pub
:
bool
,
pub
:
bool
,
}
#[derive(Serialize, Debug)]
pub
struct
ToClientRequest
<
'a
>
{
pub
:
Option
<
u32
>
,
#[serde(flatten)]
pub
:
ClientRequestMethod
<
'a
>
,
}
#[derive(Debug, Default, Serialize)]
pub
struct
ServerLog
<
'a
>
{
pub
:
&
'a
str
,
pub
:
u8
,
}
#[derive(Serialize)]
pub
struct
GetHostnameResponse
{
pub
:
String
,
}
#[derive(Serialize)]
pub
struct
GetEnvResponse
{
pub
:
HashMap
<
String
,
String
>
,
pub
:
&
'static
str
,
pub
:
String
,
}
#[derive(Deserialize)]
pub
struct
SysKillRequest
{
pub
:
u32
,
}
#[derive(Serialize)]
pub
struct
SysKillResponse
{
pub
:
bool
,
}
#[derive(Deserialize)]
pub
struct
FsSinglePathRequest
{
pub
:
String
,
}
#[derive(Serialize)]
pub
enum
FsFileKind
{
#[serde(rename = "dir" )]
Directory
,
#[serde(rename = "file" )]
File
,
#[serde(rename = "link" )]
Link
,
}
impl
From
<
std:: fs::
FileType
>
for
FsFileKind
{
fn
from
(
:
std:: fs::
FileType
)
->
Self
{
if
.
is_dir
(
)
{
Self
::
Directory
}
else
if
.
is_file
(
)
{
Self
::
File
}
else
if
.
is_symlink
(
)
{
Self
::
Link
}
else
{
unreachable!
(
)
}
}
}
#[derive(Serialize, Default)]
pub
struct
FsStatResponse
{
pub
:
bool
,
pub
:
Option
<
u64
>
,
#[serde(rename = "type" )]
pub
:
Option
<
FsFileKind
>
,
}
#[derive(Serialize)]
pub
struct
FsReadDirResponse
{
pub
:
Vec
<
FsReadDirEntry
>
,
}
#[derive(Serialize)]
pub
struct
FsReadDirEntry
{
pub
:
String
,
#[serde(rename = "type" )]
pub
:
Option
<
FsFileKind
>
,
}
#[derive(Deserialize)]
pub
struct
FsRenameRequest
{
pub
:
String
,
pub
:
String
,
}
#[derive(Deserialize)]
pub
struct
NetConnectRequest
{
pub
:
u16
,
pub
:
String
,
}
#[derive(Deserialize, Debug)]
pub
struct
CallServerHttpParams
{
pub
:
String
,
pub
:
String
,
pub
:
HashMap
<
String
,
String
>
,
pub
:
Option
<
Vec
<
u8
>>
,
}
#[derive(Serialize)]
pub
struct
CallServerHttpResult
{
pub
:
u16
,
#[serde(with = "serde_bytes" )]
pub
:
Vec
<
u8
>
,
pub
:
HashMap
<
String
,
String
>
,
}
#[derive(Serialize, Debug)]
pub
struct
VersionResponse
{
pub
:
&
'static
str
,
pub
:
u32
,
}
impl
Default
for
VersionResponse
{
fn
default
(
)
->
Self
{
Self
{
:
VSCODE_CLI_VERSION
.
unwrap_or
(
"dev"
)
,
:
PROTOCOL_VERSION
,
}
}
}
#[derive(Deserialize)]
pub
struct
SpawnParams
{
pub
:
String
,
pub
:
Vec
<
String
>
,
#[serde(default)]
pub
:
Option
<
String
>
,
#[serde(default)]
pub
:
HashMap
<
String
,
String
>
,
}
#[derive(Deserialize)]
pub
struct
AcquireCliParams
{
pub
:
Platform
,
pub
:
Quality
,
pub
:
Option
<
String
>
,
#[serde(flatten)]
pub
:
SpawnParams
,
}
#[derive(Serialize)]
pub
struct
SpawnResult
{
pub
:
String
,
pub
:
i32
,
}
pub
const
METHOD_CHALLENGE_ISSUE
:
&
str
=
"challenge_issue"
;
pub
const
METHOD_CHALLENGE_VERIFY
:
&
str
=
"challenge_verify"
;
#[derive(Serialize, Deserialize)]
pub
struct
ChallengeIssueParams
{
pub
:
Option
<
String
>
,
}
#[derive(Serialize, Deserialize)]
pub
struct
ChallengeIssueResponse
{
pub
:
String
,
}
#[derive(Deserialize, Serialize)]
pub
struct
ChallengeVerifyParams
{
pub
:
String
,
}
#[derive(Serialize, Deserialize, PartialEq, Eq, Copy, Clone, Debug)]
#[serde(rename_all = "lowercase" )]
pub
enum
PortPrivacy
{
Public
,
Private
,
}
#[derive(Serialize, Deserialize, PartialEq, Copy, Eq, Clone, Debug, Default)]
#[serde(rename_all = "lowercase" )]
pub
enum
PortProtocol
{
#[default]
Auto
,
Http
,
Https
,
}
impl
std:: fmt::
Display
for
PortProtocol
{
fn
fmt
(
&
self
,
:
&
mut
std:: fmt::
Formatter
<
'_
>
)
->
std:: fmt::
Result
{
write!
(
,
"{}"
,
self
.
to_contract_str
(
)
)
}
}
impl
PortProtocol
{
pub
fn
to_contract_str
(
&
self
)
->
&
'static
str
{
match
*
self
{
Self
::
Auto
=>
tunnels:: contracts::
TUNNEL_PROTOCOL_AUTO
,
Self
::
Http
=>
tunnels:: contracts::
TUNNEL_PROTOCOL_HTTP
,
Self
::
Https
=>
tunnels:: contracts::
TUNNEL_PROTOCOL_HTTPS
,
}
}
}
pub
mod
forward_singleton
{
use
serde::
{
Deserialize
,
Serialize
}
;
use
super
::
{
PortPrivacy
,
PortProtocol
}
;
pub
const
METHOD_SET_PORTS
:
&
str
=
"set_ports"
;
#[derive(Serialize, Deserialize, PartialEq, Eq, Clone, Debug)]
pub
struct
PortRec
{
pub
:
u16
,
pub
:
PortPrivacy
,
pub
:
PortProtocol
,
}
pub
type
PortList
=
Vec
<
PortRec
>
;
#[derive(Serialize, Deserialize)]
pub
struct
SetPortsParams
{
pub
:
PortList
,
}
#[derive(Serialize, Deserialize)]
pub
struct
SetPortsResponse
{
pub
:
Option
<
String
>
,
}
}
pub
mod
singleton
{
use
crate
:: log
;
use
jiff::
Timestamp
;
use
serde::
{
Deserialize
,
Serialize
}
;
pub
const
METHOD_RESTART
:
&
str
=
"restart"
;
pub
const
METHOD_SHUTDOWN
:
&
str
=
"shutdown"
;
pub
const
METHOD_STATUS
:
&
str
=
"status"
;
pub
const
METHOD_LOG
:
&
str
=
"log"
;
pub
const
METHOD_LOG_REPLY_DONE
:
&
str
=
"log_done"
;
pub
const
METHOD_MACHINE_STATUS
:
&
str
=
"machine_status"
;
#[derive(Serialize)]
pub
struct
LogMessage
<
'a
>
{
pub
:
Option
<
log::
Level
>
,
pub
:
&
'a
str
,
pub
:
&
'a
str
,
}
#[derive(Deserialize)]
pub
struct
LogMessageOwned
{
pub
:
Option
<
log::
Level
>
,
pub
:
String
,
pub
:
String
,
}
#[derive(Serialize, Deserialize, Clone, Default)]
pub
struct
StatusWithTunnelName
{
pub
:
Option
<
String
>
,
#[serde(default)]
pub
:
Option
<
String
>
,
#[serde(default)]
pub
:
Option
<
bool
>
,
#[serde(flatten)]
pub
:
Status
,
}
#[derive(Serialize, Deserialize, Clone)]
pub
struct
Status
{
pub
:
Timestamp
,
pub
:
TunnelState
,
pub
:
Option
<
Timestamp
>
,
pub
:
Option
<
Timestamp
>
,
pub
:
Option
<
String
>
,
}
impl
Default
for
Status
{
fn
default
(
)
->
Self
{
Self
{
:
Timestamp
::
now
(
)
,
:
TunnelState
::
Disconnected
,
:
None
,
:
None
,
:
None
,
}
}
}
#[derive(Deserialize, Serialize, Debug)]
pub
struct
LogReplayFinished
{
}
#[derive(Deserialize, Serialize, Debug, Default, Clone)]
pub
enum
TunnelState
{
#[default]
Disconnected
,
Connected
,
}
#[cfg(test)]
mod
tests
{
use
super
::
*
;
#[test]
fn
status_without_editor_link_field_deserializes_as_unknown
(
)
{
let
mut
=
serde_json::
to_value
(
StatusWithTunnelName
{
:
Some
(
"tunnel-name"
.
to_string
(
)
)
,
:
None
,
:
Some
(
true
)
,
:
Status
::
default
(
)
,
}
)
.
unwrap
(
)
;
.
as_object_mut
(
)
.
unwrap
(
)
.
remove
(
"has_editor_link"
)
.
unwrap
(
)
;
let
:
StatusWithTunnelName
=
serde_json::
from_value
(
)
.
unwrap
(
)
;
assert_eq!
(
(
.
.
as_deref
(
)
,
.
)
,
(
Some
(
"tunnel-name"
)
,
None
)
)
;
}
#[test]
fn
status_with_tunnel_id_round_trips
(
)
{
let
=
StatusWithTunnelName
{
:
Some
(
"tunnel-name"
.
to_string
(
)
)
,
:
Some
(
"tunnel-id"
.
to_string
(
)
)
,
:
Some
(
true
)
,
:
Status
::
default
(
)
,
}
;
let
:
StatusWithTunnelName
=
serde_json::
from_value
(
serde_json::
to_value
(
&
)
.
unwrap
(
)
)
.
unwrap
(
)
;
assert_eq!
(
(
.
.
as_deref
(
)
,
.
.
as_deref
(
)
)
,
(
Some
(
"tunnel-name"
)
,
Some
(
"tunnel-id"
)
)
)
;
}
#[test]
fn
status_without_tunnel_id_field_deserializes_as_unknown
(
)
{
let
mut
=
serde_json::
to_value
(
StatusWithTunnelName
{
:
Some
(
"tunnel-name"
.
to_string
(
)
)
,
:
Some
(
"tunnel-id"
.
to_string
(
)
)
,
:
Some
(
true
)
,
:
Status
::
default
(
)
,
}
)
.
unwrap
(
)
;
.
as_object_mut
(
)
.
unwrap
(
)
.
remove
(
"tunnel_id"
)
.
unwrap
(
)
;
let
:
StatusWithTunnelName
=
serde_json::
from_value
(
)
.
unwrap
(
)
;
assert_eq!
(
.
,
None
)
;
}
}
}