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 / sessionFeatures.integrationTest.ts 440 строк · изменён 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
import assert from 'assert' ;
import { timeout } from '../../../../../base/common/async.js' ;
import { SubscribeResult } from '../../../common/state/protocol/commands.js' ;
import { ActionType, type IResponsePartAction , type ITurnStartedAction , type ITitleChangedAction } from '../../../common/state/sessionActions.js' ;
import type { ListSessionsResult } from '../../../common/state/sessionProtocol.js' ;
import { MessageKind, PendingMessageKind, ResponsePartKind, ROOT_STATE_URI ,
createAndSubscribeSession
defaultChatChannel
dispatchTurnStarted
fetchSessionWithChat
getAgentHostE2ETestTimeout
getActionEnvelope
isActionNotification
IServerHandle
startServer
stopServer
TestProtocolClient
server IServerHandle
client TestProtocolClient
server
server
client server port
client
client
sessionUri client
client
channel sessionUri
clientSeq
action
type
title
titleNotif client n n
titleAction titleNotif action ITitleChangedAction
assert titleAction title
snapshot client channel sessionUri
state snapshot snapshot state ISessionWithDefaultChat
assert state title
sessionUri client
client sessionUri
titleNotif client n
n
action n action ITitleChangedAction
action title
titleAction titleNotif action ITitleChangedAction
assert titleAction title
client n n
snapshot client channel sessionUri
state snapshot snapshot state ISessionWithDefaultChat
assert state title
sessionUri client
before client channel sessionUri
assert before snapshot state ISessionWithDefaultChat title
client sessionUri
titleNotif client n n
titleAction titleNotif action ITitleChangedAction
assert titleAction title
result client channel
session result items s s resource sessionUri
assert session
assert session title
sessionUri client
client
channel sessionUri
clientSeq
action
type
title
client n
n
action n action ITitleChangedAction
action title
session title
i i i
result client channel
session result items s s resource sessionUri
session title
assert session
assert session title
sessionUri client
client
channel sessionUri
clientSeq
action
type ActionType ChatTurnStarted
turnId
startedAt
message text origin kind MessageKind User model id
turnStartedNotif client n n
turnStartedAction turnStartedNotif action ITurnStartedAction
assert turnStartedAction message model id
client n n
state client sessionUri
assert state turns message model id
sessionUri client
client sessionUri
reasoningPart client n
n
action n action IResponsePartAction
action part kind ResponsePartKind Reasoning
reasoningAction reasoningPart action IResponsePartAction
assert reasoningAction part kind ResponsePartKind Reasoning
appendNotif client n n
appendAction appendNotif action
assert appendAction type
appendAction type
assert appendAction content
mdPart client n
n
action n action IResponsePartAction
action part kind ResponsePartKind Markdown
assert mdPart
client n n
sessionUri client
client
client
channel sessionUri
clientSeq
action
type
kind PendingMessageKind Queued
id
message text origin kind MessageKind User
client n n
client n n
client n n
state client sessionUri
assert state turns length
assert state turns state turns length message text
assert state queuedMessages length
sessionUri client
client sessionUri
client n n
client
channel sessionUri
clientSeq
action
type
kind PendingMessageKind Queued
id
message text origin kind MessageKind User
firstComplete client n
n
n action turnId turnId
firstSeq firstComplete serverSeq
secondComplete client n
n
envelope n
envelope action turnId turnId
envelope serverSeq firstSeq
assert secondComplete
state client sessionUri
assert state turns length
sessionUri client
client sessionUri
client
channel sessionUri
clientSeq
action
type
kind PendingMessageKind Steering
id
message text origin kind MessageKind User
setNotif client n n
assert setNotif
removedNotif client n n
assert removedNotif
client n n
state client sessionUri
assert state steeringMessage
sessionUri client
client sessionUri
client n n n action turnId turnId
client
client sessionUri
client n n n action turnId turnId
state client sessionUri
assert state turns length
client
client
channel sessionUri
clientSeq
action type turnId
client n n
state client sessionUri
assert state turns length
assert state turns id
sessionUri client
client sessionUri
client n n
client
client
channel sessionUri
clientSeq
action type
client n n
state client sessionUri
assert state turns length
sessionUri client
client sessionUri
client n n n action turnId turnId
client
client sessionUri
client n n n action turnId turnId
client
client
channel sessionUri
clientSeq
action type turnId
client n n
client sessionUri
client n n
state client sessionUri
assert state turns length
assert state turns id
assert state turns id
type
ISessionWithDefaultChat
}
from
'../../../common/state/sessionState.js'
;
import
{
MOCK_AUTO_TITLE
}
from
'../mockAgent.js'
;
import
{
,
,
,
,
,
,
,
,
,
,
,
}
from
'../serverIntegrationTestHelpers.js'
;
suite
(
'Protocol WebSocket — Session Features'
,
function
(
)
{
let
:
;
let
:
;
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
(
10_000
)
;
=
new
TestProtocolClient
(
.
)
;
await
.
connect
(
)
;
}
)
;
teardown
(
function
(
)
{
.
close
(
)
;
}
)
;
test
(
'client titleChanged updates session state snapshot'
,
async
function
(
)
{
this
.
timeout
(
10_000
)
;
const
=
await
createAndSubscribeSession
(
,
'test-titleChanged'
)
;
.
notify
(
'dispatchAction'
,
{
:
,
:
1
,
:
{
:
'session/titleChanged'
,
:
'My Custom Title'
,
}
,
}
)
;
const
=
await
.
waitForNotification
(
=>
isActionNotification
(
,
'session/titleChanged'
)
)
;
const
=
getActionEnvelope
(
)
.
as
;
.
strictEqual
(
.
,
'My Custom Title'
)
;
const
=
await
.
call < SubscribeResult>
(
'subscribe'
,
{
:
}
)
;
const
=
.
!
.
as
;
.
strictEqual
(
.
,
'My Custom Title'
)
;
}
)
;
test
(
'agent-generated titleChanged is broadcast'
,
async
function
(
)
{
this
.
timeout
(
10_000
)
;
const
=
await
createAndSubscribeSession
(
,
'test-agent-title'
)
;
dispatchTurnStarted
(
,
,
'turn-title'
,
'with-title'
,
1
)
;
const
=
await
.
waitForNotification
(
=>
{
if
(
!
isActionNotification
(
,
'session/titleChanged'
)
)
{
return
false
;
}
const
=
getActionEnvelope
(
)
.
as
;
return
.
===
MOCK_AUTO_TITLE
;
}
)
;
const
=
getActionEnvelope
(
)
.
as
;
.
strictEqual
(
.
,
MOCK_AUTO_TITLE
)
;
await
.
waitForNotification
(
=>
isActionNotification
(
,
'chat/turnComplete'
)
)
;
const
=
await
.
call < SubscribeResult>
(
'subscribe'
,
{
:
}
)
;
const
=
.
!
.
as
;
.
strictEqual
(
.
,
MOCK_AUTO_TITLE
)
;
}
)
;
test
(
'first turn immediately sets title to user message'
,
async
function
(
)
{
this
.
timeout
(
10_000
)
;
const
=
await
createAndSubscribeSession
(
,
'test-immediate-title'
)
;
const
=
await
.
call < SubscribeResult>
(
'subscribe'
,
{
:
}
)
;
.
strictEqual
(
(
.
!
.
as
)
.
,
''
)
;
dispatchTurnStarted
(
,
,
'turn-immediate'
,
'Fix the login bug'
,
1
)
;
const
=
await
.
waitForNotification
(
=>
isActionNotification
(
,
'session/titleChanged'
)
)
;
const
=
getActionEnvelope
(
)
.
as
;
.
strictEqual
(
.
,
'Fix the login bug'
)
;
const
=
await
.
call < ListSessionsResult>
(
'listSessions'
,
{
:
ROOT_STATE_URI
}
)
;
const
=
.
.
find
(
=>
.
===
)
;
.
ok
(
,
'session should appear in listSessions'
)
;
.
strictEqual
(
.
,
'Fix the login bug'
)
;
}
)
;
test
(
'renamed session title persists across listSessions'
,
async
function
(
)
{
this
.
timeout
(
10_000
)
;
const
=
await
createAndSubscribeSession
(
,
'test-title-list'
)
;
.
notify
(
'dispatchAction'
,
{
:
,
:
1
,
:
{
:
'session/titleChanged'
,
:
'Persisted Title'
,
}
,
}
)
;
await
.
waitForNotification
(
=>
{
if
(
!
isActionNotification
(
,
'session/titleChanged'
)
)
{
return
false
;
}
const
=
getActionEnvelope
(
)
.
as
;
return
.
===
'Persisted Title'
;
}
)
;
let
:
{
:
string
}
|
undefined
;
for
(
let
=
0
;
<
20
;
++
)
{
const
=
await
.
call < ListSessionsResult>
(
'listSessions'
,
{
:
ROOT_STATE_URI
}
)
;
=
.
.
find
(
=>
.
===
)
;
if
(
?.
===
'Persisted Title'
)
{
break
;
}
await
timeout
(
100
)
;
}
.
ok
(
,
'session should appear in listSessions'
)
;
.
strictEqual
(
.
,
'Persisted Title'
)
;
}
)
;
test
(
'message model flows through turn dispatch and subscribe'
,
async
function
(
)
{
this
.
timeout
(
10_000
)
;
const
=
await
createAndSubscribeSession
(
,
'test-message-model'
)
;
.
dispatch
(
{
:
defaultChatChannel
(
)
,
:
1
,
:
{
:
.
,
:
'turn-model'
,
:
new
Date
(
)
.
toISOString
(
)
,
:
{
:
'hello'
,
:
{
:
.
}
,
:
{
:
'mock-model'
}
}
,
}
,
}
)
;
const
=
await
.
waitForNotification
(
=>
isActionNotification
(
,
'chat/turnStarted'
)
)
;
const
=
getActionEnvelope
(
)
.
as
;
.
deepStrictEqual
(
.
.
,
{
:
'mock-model'
}
)
;
await
.
waitForNotification
(
=>
isActionNotification
(
,
'chat/turnComplete'
)
)
;
const
=
await
fetchSessionWithChat
(
,
)
;
.
deepStrictEqual
(
.
.
at
(
-
1
)
?.
.
,
{
:
'mock-model'
}
)
;
}
)
;
test
(
'reasoning events produce reasoning response parts and append actions'
,
async
function
(
)
{
this
.
timeout
(
10_000
)
;
const
=
await
createAndSubscribeSession
(
,
'test-reasoning'
)
;
dispatchTurnStarted
(
,
,
'turn-reasoning'
,
'with-reasoning'
,
1
)
;
const
=
await
.
waitForNotification
(
=>
{
if
(
!
isActionNotification
(
,
'chat/responsePart'
)
)
{
return
false
;
}
const
=
getActionEnvelope
(
)
.
as
;
return
.
.
===
.
;
}
)
;
const
=
getActionEnvelope
(
)
.
as
;
.
strictEqual
(
.
.
,
.
)
;
const
=
await
.
waitForNotification
(
=>
isActionNotification
(
,
'chat/reasoning'
)
)
;
const
=
getActionEnvelope
(
)
.
;
.
strictEqual
(
.
,
'chat/reasoning'
)
;
if
(
.
===
'chat/reasoning'
)
{
.
strictEqual
(
.
,
' about this...'
)
;
}
const
=
await
.
waitForNotification
(
=>
{
if
(
!
isActionNotification
(
,
'chat/responsePart'
)
)
{
return
false
;
}
const
=
getActionEnvelope
(
)
.
as
;
return
.
.
===
.
;
}
)
;
.
ok
(
)
;
await
.
waitForNotification
(
=>
isActionNotification
(
,
'chat/turnComplete'
)
)
;
}
)
;
test
(
'queued message is auto-consumed when session is idle'
,
async
function
(
)
{
this
.
timeout
(
10_000
)
;
const
=
await
createAndSubscribeSession
(
,
'test-queue-idle'
)
;
.
clearReceived
(
)
;
.
notify
(
'dispatchAction'
,
{
:
defaultChatChannel
(
)
,
:
1
,
:
{
:
'chat/pendingMessageSet'
,
:
.
,
:
'q-1'
,
:
{
:
'hello'
,
:
{
:
.
}
}
,
}
,
}
)
;
await
.
waitForNotification
(
=>
isActionNotification
(
,
'chat/turnStarted'
)
)
;
await
.
waitForNotification
(
=>
isActionNotification
(
,
'chat/responsePart'
)
)
;
await
.
waitForNotification
(
=>
isActionNotification
(
,
'chat/turnComplete'
)
)
;
const
=
await
fetchSessionWithChat
(
,
)
;
.
ok
(
.
.
>=
1
)
;
.
strictEqual
(
.
[
.
.
-
1
]
.
.
,
'hello'
)
;
.
ok
(
!
.
?.
,
'queued messages should be empty after consumption'
)
;
}
)
;
test
(
'queued message waits for in-progress turn to complete'
,
async
function
(
)
{
this
.
timeout
(
15_000
)
;
const
=
await
createAndSubscribeSession
(
,
'test-queue-wait'
)
;
dispatchTurnStarted
(
,
,
'turn-first'
,
'hello'
,
1
)
;
await
.
waitForNotification
(
=>
isActionNotification
(
,
'chat/responsePart'
)
)
;
.
notify
(
'dispatchAction'
,
{
:
defaultChatChannel
(
)
,
:
2
,
:
{
:
'chat/pendingMessageSet'
,
:
.
,
:
'q-wait-1'
,
:
{
:
'hello'
,
:
{
:
.
}
}
,
}
,
}
)
;
const
=
await
.
waitForNotification
(
=>
{
if
(
!
isActionNotification
(
,
'chat/turnComplete'
)
)
{
return
false
;
}
return
(
getActionEnvelope
(
)
.
as
{
:
string
}
)
.
===
'turn-first'
;
}
)
;
const
=
getActionEnvelope
(
)
.
;
const
=
await
.
waitForNotification
(
=>
{
if
(
!
isActionNotification
(
,
'chat/turnComplete'
)
)
{
return
false
;
}
const
=
getActionEnvelope
(
)
;
return
(
.
as
{
:
string
}
)
.
!==
'turn-first'
&&
.
>
;
}
)
;
.
ok
(
,
'should receive a second turnComplete from the queued message'
)
;
const
=
await
fetchSessionWithChat
(
,
)
;
.
ok
(
.
.
>=
2
,
` expected >= 2 turns but got ${ state. turns. length} `
)
;
}
)
;
test
(
'steering message is set and consumed by agent'
,
async
function
(
)
{
this
.
timeout
(
10_000
)
;
const
=
await
createAndSubscribeSession
(
,
'test-steering'
)
;
dispatchTurnStarted
(
,
,
'turn-steer'
,
'hello'
,
1
)
;
.
notify
(
'dispatchAction'
,
{
:
defaultChatChannel
(
)
,
:
2
,
:
{
:
'chat/pendingMessageSet'
,
:
.
,
:
'steer-1'
,
:
{
:
'Please be concise'
,
:
{
:
.
}
}
,
}
,
}
)
;
const
=
await
.
waitForNotification
(
=>
isActionNotification
(
,
'chat/pendingMessageSet'
)
)
;
.
ok
(
,
'should see pendingMessageSet action'
)
;
const
=
await
.
waitForNotification
(
=>
isActionNotification
(
,
'chat/pendingMessageRemoved'
)
)
;
.
ok
(
,
'should see pendingMessageRemoved after agent consumes steering'
)
;
await
.
waitForNotification
(
=>
isActionNotification
(
,
'chat/turnComplete'
)
)
;
const
=
await
fetchSessionWithChat
(
,
)
;
.
ok
(
!
.
,
'steering message should be cleared after consumption'
)
;
}
)
;
test
(
'truncate session removes turns after specified turn'
,
async
function
(
)
{
this
.
timeout
(
15_000
)
;
const
=
await
createAndSubscribeSession
(
,
'test-truncate'
)
;
dispatchTurnStarted
(
,
,
'turn-t1'
,
'hello'
,
1
)
;
await
.
waitForNotification
(
=>
isActionNotification
(
,
'chat/turnComplete'
)
&&
(
getActionEnvelope
(
)
.
as
{
:
string
}
)
.
===
'turn-t1'
)
;
.
clearReceived
(
)
;
dispatchTurnStarted
(
,
,
'turn-t2'
,
'hello'
,
2
)
;
await
.
waitForNotification
(
=>
isActionNotification
(
,
'chat/turnComplete'
)
&&
(
getActionEnvelope
(
)
.
as
{
:
string
}
)
.
===
'turn-t2'
)
;
let
=
await
fetchSessionWithChat
(
,
)
;
.
strictEqual
(
.
.
,
2
)
;
.
clearReceived
(
)
;
.
notify
(
'dispatchAction'
,
{
:
defaultChatChannel
(
)
,
:
3
,
:
{
:
'chat/truncated'
,
:
'turn-t1'
}
,
}
)
;
await
.
waitForNotification
(
=>
isActionNotification
(
,
'chat/truncated'
)
)
;
=
await
fetchSessionWithChat
(
,
)
;
.
strictEqual
(
.
.
,
1
)
;
.
strictEqual
(
.
[
0
]
.
,
'turn-t1'
)
;
}
)
;
test
(
'truncate all turns clears session history'
,
async
function
(
)
{
this
.
timeout
(
15_000
)
;
const
=
await
createAndSubscribeSession
(
,
'test-truncate-all'
)
;
dispatchTurnStarted
(
,
,
'turn-ta1'
,
'hello'
,
1
)
;
await
.
waitForNotification
(
=>
isActionNotification
(
,
'chat/turnComplete'
)
)
;
.
clearReceived
(
)
;
.
notify
(
'dispatchAction'
,
{
:
defaultChatChannel
(
)
,
:
2
,
:
{
:
'chat/truncated'
}
,
}
)
;
await
.
waitForNotification
(
=>
isActionNotification
(
,
'chat/truncated'
)
)
;
const
=
await
fetchSessionWithChat
(
,
)
;
.
strictEqual
(
.
.
,
0
)
;
}
)
;
test
(
'new turn after truncation works correctly'
,
async
function
(
)
{
this
.
timeout
(
15_000
)
;
const
=
await
createAndSubscribeSession
(
,
'test-truncate-resume'
)
;
dispatchTurnStarted
(
,
,
'turn-tr1'
,
'hello'
,
1
)
;
await
.
waitForNotification
(
=>
isActionNotification
(
,
'chat/turnComplete'
)
&&
(
getActionEnvelope
(
)
.
as
{
:
string
}
)
.
===
'turn-tr1'
)
;
.
clearReceived
(
)
;
dispatchTurnStarted
(
,
,
'turn-tr2'
,
'hello'
,
2
)
;
await
.
waitForNotification
(
=>
isActionNotification
(
,
'chat/turnComplete'
)
&&
(
getActionEnvelope
(
)
.
as
{
:
string
}
)
.
===
'turn-tr2'
)
;
.
clearReceived
(
)
;
.
notify
(
'dispatchAction'
,
{
:
defaultChatChannel
(
)
,
:
3
,
:
{
:
'chat/truncated'
,
:
'turn-tr1'
}
,
}
)
;
await
.
waitForNotification
(
=>
isActionNotification
(
,
'chat/truncated'
)
)
;
dispatchTurnStarted
(
,
,
'turn-tr3'
,
'hello'
,
4
)
;
await
.
waitForNotification
(
=>
isActionNotification
(
,
'chat/turnComplete'
)
)
;
const
=
await
fetchSessionWithChat
(
,
)
;
.
strictEqual
(
.
.
,
2
)
;
.
strictEqual
(
.
[
0
]
.
,
'turn-tr1'
)
;
.
strictEqual
(
.
[
1
]
.
,
'turn-tr3'
)
;
}
)
;
}
)
;