ide на основе vs code · VibeGit
ide на основе vs code Это ide на основе vs code(code oss), в ней будет встроенный умный апи роутинг, свой маркет с плагинами(агент харнесс, поддержка java/kotlin/мобильной разработки, командная разработка проектов, orca, оркестратор агентов
krutaya-ide-na-osnove-vs-code / src / vs / platform / agentHost / test / node / protocol / multiClient.integrationTest.ts 339 строк · изменён 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
import assert from 'assert' ;
import type { SessionAddedParams, SessionRemovedParams } from '../../../common/state/protocol/notifications.js' ;
import { ActionType } from '../../../common/state/sessionActions.js' ;
import { PROTOCOL_VERSION } from '../../../common/state/protocol/version/registry.js' ;
import type { ReconnectResult } from '../../../common/state/sessionProtocol.js' ;
import { ROOT_STATE_URI , buildDefaultChatUri } from '../../../common/state/sessionState.js' ;
import {
createAndSubscribeSession,
dispatchTurnStarted,
fetchSessionWithChat
getAgentHostE2ETestTimeout
getActionEnvelope
IServerHandle
isActionNotification
nextSessionUri
startServer
stopServer
TestProtocolClient
server IServerHandle
client TestProtocolClient
secondaryClients TestProtocolClient
TestProtocolClient
secondaryClient server port
secondaryClients secondaryClient
secondaryClient
server
server
client server port
client
client
secondaryClient secondaryClients
secondaryClient
channel protocolVersions clientId
client2
client2
channel protocolVersions clientId
client
client2
channel provider
n1 client n
n method
n2 client2 n
n method
assert n1
assert n2
uri1 n1 params SessionAddedParams summary resource
uri2 n2 params SessionAddedParams summary resource
assert uri1 uri2
sessionUri client
client2
client2
channel protocolVersions clientId
client2
channel sessionUri
n1 client n
n method
n2 client2 n
n method
assert n1
assert n2
removed1 n1 params SessionRemovedParams
removed2 n2 params SessionRemovedParams
assert removed1 session sessionUri
assert removed2 session sessionUri
sessionUri client
client2
client2
channel protocolVersions clientId
channel sessionUri
channel sessionUri
client2
client sessionUri
d1 client n n
d2 client2 n n
assert d1
assert d2
client n n
client2 n n
sessionUri client
client2
client2
channel protocolVersions clientId
channel sessionUri
channel sessionUri
client
client2
client2 sessionUri
r1 client n n
r2 client2 n n
assert r1
assert r2
client n n
client2 n n
sessionUri client
client2
client2
channel protocolVersions clientId
channel sessionUri
channel sessionUri
client
client2
client sessionUri
c client client2
c n n
c n n
c n n
c n n
c n n
sessionUri client
client channel sessionUri
client
client2
client2
channel protocolVersions clientId
channel sessionUri
client2
channel sessionUri
clientSeq
action type ActionType SessionTitleChanged title
client2 n
n ActionType SessionTitleChanged
n channel sessionUri
sessionActions client n n method n channel sessionUri
assert sessionActions length
sessionUri client
client2
client2
channel protocolVersions clientId
client2
client sessionUri
client n n
sessionActions client2 n n method
assert sessionActions length
client2
channel sessionUri
removed client2 n
n method
assert removed
sessionUri client
client sessionUri
client n n
client2
client2
channel protocolVersions clientId
state client2 sessionUri
assert state turns length
assert state turns id
assert state turns state
sessionUri client
client2
client2
channel protocolVersions clientId
channel sessionUri
channel sessionUri
client
client2
client sessionUri
client n n
client2 n n
client n n
client2 n n
client2
channel sessionUri
clientSeq
action
type
turnId
toolCallId
approved
client n n
client2 n n
client n n
client2 n n
sessionUri client
client sessionUri
client n n
allActions client n n method
assert allActions length
missedFromSeq allActions serverSeq
client
client2
client2
result client2
clientId
lastSeenServerSeq missedFromSeq
subscriptions sessionUri
assert result type result type
result type
assert result actions length
,
,
,
,
,
,
,
,
,
}
from
'../serverIntegrationTestHelpers.js'
;
suite
(
'Protocol WebSocket — Multi-Client'
,
function
(
)
{
let
:
;
let
:
;
const
:
[
]
=
[
]
;
function
createSecondaryClient
(
)
:
{
const
=
new
TestProtocolClient
(
.
)
;
.
push
(
)
;
return
;
}
suiteSetup
(
async
function
(
)
{
this
.
timeout
(
getAgentHostE2ETestTimeout
(
15_000
,
60_000
)
)
;
=
await
startServer
(
)
;
}
)
;
suiteTeardown
(
async
function
(
)
{
this
.
timeout
(
getAgentHostE2ETestTimeout
(
20_000
,
50_000
)
)
;
await
stopServer
(
)
;
}
)
;
setup
(
async
function
(
)
{
this
.
timeout
(
getAgentHostE2ETestTimeout
(
10_000
,
30_000
)
)
;
=
new
TestProtocolClient
(
.
)
;
await
.
connect
(
)
;
}
)
;
teardown
(
function
(
)
{
.
close
(
)
;
for
(
const
of
.
splice
(
0
)
)
{
.
close
(
)
;
}
}
)
;
test
(
'sessionAdded notification is broadcast to all connected clients'
,
async
function
(
)
{
this
.
timeout
(
10_000
)
;
await
client
.
call
(
'initialize'
,
{
:
ROOT_STATE_URI
,
:
[
PROTOCOL_VERSION
]
,
:
'test-broadcast-add-1'
}
)
;
const
=
createSecondaryClient
(
)
;
await
.
connect
(
)
;
await
client2
.
call
(
'initialize'
,
{
:
ROOT_STATE_URI
,
:
[
PROTOCOL_VERSION
]
,
:
'test-broadcast-add-2'
}
)
;
.
clearReceived
(
)
;
.
clearReceived
(
)
;
await
client
.
call
(
'createSession'
,
{
:
nextSessionUri
(
)
,
:
'mock'
}
)
;
const
=
await
.
waitForNotification
(
=>
.
===
'root/sessionAdded'
)
;
const
=
await
.
waitForNotification
(
=>
.
===
'root/sessionAdded'
)
;
.
ok
(
,
'client 1 should receive sessionAdded'
)
;
.
ok
(
,
'client 2 should receive sessionAdded'
)
;
const
=
(
.
as
)
.
.
;
const
=
(
.
as
)
.
.
;
.
strictEqual
(
,
,
'both clients should see the same session URI'
)
;
}
)
;
test
(
'sessionRemoved notification is broadcast to all connected clients'
,
async
function
(
)
{
this
.
timeout
(
getAgentHostE2ETestTimeout
(
10_000
,
30_000
)
)
;
const
=
await
createAndSubscribeSession
(
,
'test-broadcast-remove-1'
)
;
const
=
createSecondaryClient
(
)
;
await
.
connect
(
)
;
await
client2
.
call
(
'initialize'
,
{
:
ROOT_STATE_URI
,
:
[
PROTOCOL_VERSION
]
,
:
'test-broadcast-remove-2'
}
)
;
.
clearReceived
(
)
;
await
client
.
call
(
'disposeSession'
,
{
:
}
)
;
const
=
await
.
waitForNotification
(
=>
.
===
'root/sessionRemoved'
)
;
const
=
await
.
waitForNotification
(
=>
.
===
'root/sessionRemoved'
)
;
.
ok
(
,
'client 1 should receive sessionRemoved'
)
;
.
ok
(
,
'client 2 should receive sessionRemoved even without subscribing'
)
;
const
=
.
as
;
const
=
.
as
;
.
strictEqual
(
.
.
toString
(
)
,
.
toString
(
)
)
;
.
strictEqual
(
.
.
toString
(
)
,
.
toString
(
)
)
;
}
)
;
test
(
'two clients on same session both see actions'
,
async
function
(
)
{
this
.
timeout
(
10_000
)
;
const
=
await
createAndSubscribeSession
(
,
'test-multi-client-1'
)
;
const
=
createSecondaryClient
(
)
;
await
.
connect
(
)
;
await
client2
.
call
(
'initialize'
,
{
:
ROOT_STATE_URI
,
:
[
PROTOCOL_VERSION
]
,
:
'test-multi-client-2'
}
)
;
await
client2
.
call
(
'subscribe'
,
{
:
}
)
;
await
client2
.
call
(
'subscribe'
,
{
:
buildDefaultChatUri
(
)
}
)
;
.
clearReceived
(
)
;
dispatchTurnStarted
(
,
,
'turn-mc'
,
'hello'
,
1
)
;
const
=
await
.
waitForNotification
(
=>
isActionNotification
(
,
'chat/responsePart'
)
)
;
const
=
await
.
waitForNotification
(
=>
isActionNotification
(
,
'chat/responsePart'
)
)
;
.
ok
(
)
;
.
ok
(
)
;
await
.
waitForNotification
(
=>
isActionNotification
(
,
'chat/turnComplete'
)
)
;
await
.
waitForNotification
(
=>
isActionNotification
(
,
'chat/turnComplete'
)
)
;
}
)
;
test
(
'client B sends message on session created by client A'
,
async
function
(
)
{
this
.
timeout
(
10_000
)
;
const
=
await
createAndSubscribeSession
(
,
'test-cross-msg-1'
)
;
const
=
createSecondaryClient
(
)
;
await
.
connect
(
)
;
await
client2
.
call
(
'initialize'
,
{
:
ROOT_STATE_URI
,
:
[
PROTOCOL_VERSION
]
,
:
'test-cross-msg-2'
}
)
;
await
client2
.
call
(
'subscribe'
,
{
:
}
)
;
await
client2
.
call
(
'subscribe'
,
{
:
buildDefaultChatUri
(
)
}
)
;
.
clearReceived
(
)
;
.
clearReceived
(
)
;
dispatchTurnStarted
(
,
,
'turn-cross'
,
'hello'
,
1
)
;
const
=
await
.
waitForNotification
(
=>
isActionNotification
(
,
'chat/responsePart'
)
)
;
const
=
await
.
waitForNotification
(
=>
isActionNotification
(
,
'chat/responsePart'
)
)
;
.
ok
(
,
'client A should see responsePart from client B turn'
)
;
.
ok
(
,
'client B should see its own responsePart'
)
;
await
.
waitForNotification
(
=>
isActionNotification
(
,
'chat/turnComplete'
)
)
;
await
.
waitForNotification
(
=>
isActionNotification
(
,
'chat/turnComplete'
)
)
;
}
)
;
test
(
'both clients receive full tool progress updates'
,
async
function
(
)
{
this
.
timeout
(
10_000
)
;
const
=
await
createAndSubscribeSession
(
,
'test-tool-progress-1'
)
;
const
=
createSecondaryClient
(
)
;
await
.
connect
(
)
;
await
client2
.
call
(
'initialize'
,
{
:
ROOT_STATE_URI
,
:
[
PROTOCOL_VERSION
]
,
:
'test-tool-progress-2'
}
)
;
await
client2
.
call
(
'subscribe'
,
{
:
}
)
;
await
client2
.
call
(
'subscribe'
,
{
:
buildDefaultChatUri
(
)
}
)
;
.
clearReceived
(
)
;
.
clearReceived
(
)
;
dispatchTurnStarted
(
,
,
'turn-tool-mc'
,
'use-tool'
,
1
)
;
for
(
const
of
[
,
]
)
{
await
.
waitForNotification
(
=>
isActionNotification
(
,
'chat/toolCallStart'
)
)
;
await
.
waitForNotification
(
=>
isActionNotification
(
,
'chat/toolCallReady'
)
)
;
await
.
waitForNotification
(
=>
isActionNotification
(
,
'chat/toolCallComplete'
)
)
;
await
.
waitForNotification
(
=>
isActionNotification
(
,
'chat/responsePart'
)
)
;
await
.
waitForNotification
(
=>
isActionNotification
(
,
'chat/turnComplete'
)
)
;
}
}
)
;
test
(
'unsubscribe stops receiving session actions'
,
async
function
(
)
{
this
.
timeout
(
getAgentHostE2ETestTimeout
(
10_000
,
30_000
)
)
;
const
=
await
createAndSubscribeSession
(
,
'test-unsubscribe'
)
;
.
notify
(
'unsubscribe'
,
{
:
}
)
;
await
client
.
call
(
'ping'
)
;
.
clearReceived
(
)
;
const
=
createSecondaryClient
(
)
;
await
.
connect
(
)
;
await
client2
.
call
(
'initialize'
,
{
:
ROOT_STATE_URI
,
:
[
PROTOCOL_VERSION
]
,
:
'test-unsub-helper'
}
)
;
await
client2
.
call
(
'subscribe'
,
{
:
}
)
;
.
dispatch
(
{
:
,
:
1
,
:
{
:
.
,
:
'Updated by subscribed client'
}
,
}
)
;
await
.
waitForNotification
(
=>
isActionNotification
(
,
.
)
&&
getActionEnvelope
(
)
.
===
)
;
await
client
.
call
(
'ping'
)
;
const
=
.
receivedNotifications
(
=>
.
===
'action'
&&
getActionEnvelope
(
)
.
===
)
;
.
strictEqual
(
.
,
0
,
'unsubscribed client should not receive session actions'
)
;
}
)
;
test
(
'unsubscribed client receives no actions but still gets notifications'
,
async
function
(
)
{
this
.
timeout
(
getAgentHostE2ETestTimeout
(
10_000
,
30_000
)
)
;
const
=
await
createAndSubscribeSession
(
,
'test-scoping-1'
)
;
const
=
createSecondaryClient
(
)
;
await
.
connect
(
)
;
await
client2
.
call
(
'initialize'
,
{
:
ROOT_STATE_URI
,
:
[
PROTOCOL_VERSION
]
,
:
'test-scoping-2'
}
)
;
.
clearReceived
(
)
;
dispatchTurnStarted
(
,
,
'turn-scoped'
,
'hello'
,
1
)
;
await
.
waitForNotification
(
=>
isActionNotification
(
,
'chat/turnComplete'
)
)
;
await
client2
.
call
(
'ping'
)
;
const
=
.
receivedNotifications
(
=>
.
===
'action'
)
;
.
strictEqual
(
.
,
0
,
'unsubscribed client should receive no session actions'
)
;
.
clearReceived
(
)
;
await
client
.
call
(
'disposeSession'
,
{
:
}
)
;
const
=
await
.
waitForNotification
(
=>
.
===
'root/sessionRemoved'
)
;
.
ok
(
,
'unsubscribed client should still receive sessionRemoved notification'
)
;
}
)
;
test
(
'late subscriber gets current state via snapshot'
,
async
function
(
)
{
this
.
timeout
(
15_000
)
;
const
=
await
createAndSubscribeSession
(
,
'test-late-sub'
)
;
dispatchTurnStarted
(
,
,
'turn-late'
,
'hello'
,
1
)
;
await
.
waitForNotification
(
=>
isActionNotification
(
,
'chat/turnComplete'
)
)
;
const
=
createSecondaryClient
(
)
;
await
.
connect
(
)
;
await
client2
.
call
(
'initialize'
,
{
:
ROOT_STATE_URI
,
:
[
PROTOCOL_VERSION
]
,
:
'test-late-sub-2'
}
)
;
const
=
await
fetchSessionWithChat
(
,
)
;
.
ok
(
.
.
>=
1
,
` late subscriber should see completed turn, got ${ state. turns. length} `
)
;
.
strictEqual
(
.
[
0
]
.
,
'turn-late'
)
;
.
strictEqual
(
.
[
0
]
.
,
'complete'
)
;
}
)
;
test
(
'permission flow: client B confirms tool started by client A'
,
async
function
(
)
{
this
.
timeout
(
10_000
)
;
const
=
await
createAndSubscribeSession
(
,
'test-cross-perm-1'
)
;
const
=
createSecondaryClient
(
)
;
await
.
connect
(
)
;
await
client2
.
call
(
'initialize'
,
{
:
ROOT_STATE_URI
,
:
[
PROTOCOL_VERSION
]
,
:
'test-cross-perm-2'
}
)
;
await
client2
.
call
(
'subscribe'
,
{
:
}
)
;
await
client2
.
call
(
'subscribe'
,
{
:
buildDefaultChatUri
(
)
}
)
;
.
clearReceived
(
)
;
.
clearReceived
(
)
;
dispatchTurnStarted
(
,
,
'turn-cross-perm'
,
'permission'
,
1
)
;
await
.
waitForNotification
(
=>
isActionNotification
(
,
'chat/toolCallStart'
)
)
;
await
.
waitForNotification
(
=>
isActionNotification
(
,
'chat/toolCallStart'
)
)
;
await
.
waitForNotification
(
=>
isActionNotification
(
,
'chat/toolCallReady'
)
)
;
await
.
waitForNotification
(
=>
isActionNotification
(
,
'chat/toolCallReady'
)
)
;
.
notify
(
'dispatchAction'
,
{
:
buildDefaultChatUri
(
)
,
:
1
,
:
{
:
'chat/toolCallConfirmed'
,
:
'turn-cross-perm'
,
:
'tc-perm-1'
,
:
true
,
}
,
}
)
;
await
.
waitForNotification
(
=>
isActionNotification
(
,
'chat/responsePart'
)
)
;
await
.
waitForNotification
(
=>
isActionNotification
(
,
'chat/responsePart'
)
)
;
await
.
waitForNotification
(
=>
isActionNotification
(
,
'chat/turnComplete'
)
)
;
await
.
waitForNotification
(
=>
isActionNotification
(
,
'chat/turnComplete'
)
)
;
}
)
;
test
(
'reconnect replays missed actions'
,
async
function
(
)
{
this
.
timeout
(
15_000
)
;
const
=
await
createAndSubscribeSession
(
,
'test-reconnect'
)
;
dispatchTurnStarted
(
,
,
'turn-recon'
,
'hello'
,
1
)
;
await
.
waitForNotification
(
=>
isActionNotification
(
,
'chat/turnComplete'
)
)
;
const
=
.
receivedNotifications
(
=>
.
===
'action'
)
;
.
ok
(
.
>
0
)
;
const
=
getActionEnvelope
(
[
0
]
)
.
-
1
;
.
close
(
)
;
const
=
createSecondaryClient
(
)
;
await
.
connect
(
)
;
const
=
await
.
call < ReconnectResult>
(
'reconnect'
,
{
:
'test-reconnect'
,
:
,
:
[
]
,
}
)
;
.
ok
(
.
===
'replay'
||
.
===
'snapshot'
,
'should receive replay or snapshot'
)
;
if
(
.
===
'replay'
)
{
.
ok
(
.
.
>
0
,
'should have replayed actions'
)
;
}
}
)
;
}
)
;