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 / turnExecution.integrationTest.ts 273 строк · изменён 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
import assert from 'assert' ;
import { timeout } from '../../../../../base/common/async.js' ;
import { SubscribeResult } from '../../../common/state/protocol/commands.js' ;
import { PROTOCOL_VERSION } from '../../../common/state/protocol/version/registry.js' ;
import type { IResponsePartAction } from '../../../common/state/sessionActions.js' ;
import type { FetchTurnsResult, ListSessionsResult } from '../../../common/state/sessionProtocol.js' ;
import { ResponsePartKind, ROOT_STATE_URI , buildSubagentChatUri, isSubagentSession
createAndSubscribeSession
defaultChatChannel
dispatchTurnStarted
fetchSessionWithChat
getAgentHostE2ETestTimeout
getActionEnvelope
IServerHandle
isActionNotification
startServer
stopServer
TestProtocolClient
notification Parameters isActionNotification turnId
notification
notification action turnId turnId turnId
server IServerHandle
client TestProtocolClient
server
server
client server port
client
client
sessionUri client
client sessionUri
responsePart client n n
responsePartAction responsePart action IResponsePartAction
assert responsePartAction part kind ResponsePartKind Markdown
assert responsePartAction part MarkdownResponsePart content
client n n
sessionUri client
client sessionUri
client n n
client n n
toolComplete client n n
tcAction toolComplete action
tcAction type
assert tcAction result success
client n n
client n n
sessionUri client
client sessionUri
errorNotif client n n
errorAction errorNotif action
errorAction type
assert errorAction part error message
sessionUri client
client sessionUri
client
channel sessionUri
clientSeq
action type turnId duration
client n n
state client sessionUri
assert state turns length
assert state turns state turns length state
sessionUri client
client sessionUri
client n n
client sessionUri
client n n
state client sessionUri
assert state turns length
assert state turns id
assert state turns id
sessionUri client
client sessionUri
client n n
client sessionUri
client n n
loadedPromise client n n
result client channel sessionUri
assert result
loaded loadedPromise
action loaded action type turns turnsNextCursor
assert action turns
assert action turnsNextCursor
channel protocolVersions clientId
assert channel
sessionUri client
assert
channel sessionUri
cursor
sessionUri client
client sessionUri
usageNotif client n n
usageAction usageNotif action type usage inputTokens outputTokens _meta Record
assert usageAction usage inputTokens
assert usageAction usage outputTokens
assert usageAction usage _meta cost
client n n
state client sessionUri
assert state turns length
turn state turns state turns length
assert turn usage
assert turn usage inputTokens
assert turn usage outputTokens
assert turn usage _meta cost
sessionUri client
initialSnapshot client channel sessionUri
initialModifiedAt Date initialSnapshot snapshot state ISessionWithDefaultChat chats modifiedAt
client sessionUri
client n n
updatedSnapshot client channel sessionUri
updatedModifiedAt Date updatedSnapshot snapshot state ISessionWithDefaultChat chats modifiedAt
assert updatedModifiedAt initialModifiedAt
sessionUri client
client sessionUri
client n n
childUri sessionUri
parentState client sessionUri
childState client childUri
parentTurn parentState turns parentState turns length
parentToolCalls parentTurn responseParts p p kind ResponsePartKind ToolCall
parentToolNames parentToolCalls p p toolCall toolName
assert parentToolNames
assert childState turns length
childTurn childState turns childState turns length
childToolCalls childTurn responseParts p p kind ResponsePartKind ToolCall
childToolNames childToolCalls p p toolCall toolName
assert childToolNames
sessionUri client
client sessionUri
client n n
childUri sessionUri
childSnapshot client channel childUri
assert childSnapshot snapshot
result client channel
assert
subagentSessions result items s s resource s s resource
includesParent result items s s resource sessionUri
subagentSessions
includesParent
,
type
MarkdownResponsePart
,
type
ISessionWithDefaultChat
}
from
'../../../common/state/sessionState.js'
;
import
{
,
,
,
,
,
,
,
,
,
,
,
}
from
'../serverIntegrationTestHelpers.js'
;
function
isTurnComplete
(
:
<
typeof
>
[
0
]
,
:
string
)
:
boolean
{
return
isActionNotification
(
,
'chat/turnComplete'
)
&&
(
getActionEnvelope
(
)
.
as
{
?
:
string
}
)
.
===
;
}
suite
(
'Protocol WebSocket — Turn Execution'
,
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
(
getAgentHostE2ETestTimeout
(
10_000
,
30_000
)
)
;
=
new
TestProtocolClient
(
.
)
;
await
.
connect
(
)
;
}
)
;
teardown
(
function
(
)
{
.
close
(
)
;
}
)
;
test
(
'send message and receive responsePart + turnComplete'
,
async
function
(
)
{
this
.
timeout
(
getAgentHostE2ETestTimeout
(
10_000
,
30_000
)
)
;
const
=
await
createAndSubscribeSession
(
,
'test-send-message'
)
;
dispatchTurnStarted
(
,
,
'turn-1'
,
'hello'
,
1
)
;
const
=
await
.
waitForNotification
(
=>
isActionNotification
(
,
'chat/responsePart'
)
)
;
const
=
getActionEnvelope
(
)
.
as
;
.
strictEqual
(
.
.
,
.
)
;
.
strictEqual
(
(
.
as
)
.
,
'Hello, world!'
)
;
await
.
waitForNotification
(
=>
isActionNotification
(
,
'chat/turnComplete'
)
)
;
}
)
;
test
(
'tool invocation: toolCallStart → toolCallComplete → responsePart → turnComplete'
,
async
function
(
)
{
this
.
timeout
(
getAgentHostE2ETestTimeout
(
10_000
,
30_000
)
)
;
const
=
await
createAndSubscribeSession
(
,
'test-tool-invocation'
)
;
dispatchTurnStarted
(
,
,
'turn-tool'
,
'use-tool'
,
1
)
;
await
.
waitForNotification
(
=>
isActionNotification
(
,
'chat/toolCallStart'
)
)
;
await
.
waitForNotification
(
=>
isActionNotification
(
,
'chat/toolCallReady'
)
)
;
const
=
await
.
waitForNotification
(
=>
isActionNotification
(
,
'chat/toolCallComplete'
)
)
;
const
=
getActionEnvelope
(
)
.
;
if
(
.
===
'chat/toolCallComplete'
)
{
.
strictEqual
(
.
.
,
true
)
;
}
await
.
waitForNotification
(
=>
isActionNotification
(
,
'chat/responsePart'
)
)
;
await
.
waitForNotification
(
=>
isActionNotification
(
,
'chat/turnComplete'
)
)
;
}
)
;
test
(
'error prompt triggers chat/error'
,
async
function
(
)
{
this
.
timeout
(
getAgentHostE2ETestTimeout
(
10_000
,
30_000
)
)
;
const
=
await
createAndSubscribeSession
(
,
'test-error'
)
;
dispatchTurnStarted
(
,
,
'turn-err'
,
'error'
,
1
)
;
const
=
await
.
waitForNotification
(
=>
isActionNotification
(
,
'chat/error'
)
)
;
const
=
getActionEnvelope
(
)
.
;
if
(
.
===
'chat/error'
)
{
.
strictEqual
(
.
.
.
,
'Something went wrong'
)
;
}
}
)
;
test
(
'cancel turn stops in-progress processing'
,
async
function
(
)
{
this
.
timeout
(
getAgentHostE2ETestTimeout
(
10_000
,
30_000
)
)
;
const
=
await
createAndSubscribeSession
(
,
'test-cancel'
)
;
dispatchTurnStarted
(
,
,
'turn-cancel'
,
'slow'
,
1
)
;
.
notify
(
'dispatchAction'
,
{
:
defaultChatChannel
(
)
,
:
2
,
:
{
:
'chat/turnCancelled'
,
:
'turn-cancel'
,
:
10
}
,
}
)
;
await
.
waitForNotification
(
=>
isActionNotification
(
,
'chat/turnCancelled'
)
)
;
const
=
await
fetchSessionWithChat
(
,
)
;
.
ok
(
.
.
>=
1
)
;
.
strictEqual
(
.
[
.
.
-
1
]
.
,
'cancelled'
)
;
}
)
;
test
(
'multiple sequential turns accumulate in history'
,
async
function
(
)
{
this
.
timeout
(
getAgentHostE2ETestTimeout
(
15_000
,
45_000
)
)
;
const
=
await
createAndSubscribeSession
(
,
'test-multi-turns'
)
;
dispatchTurnStarted
(
,
,
'turn-m1'
,
'hello'
,
1
)
;
await
.
waitForNotification
(
=>
isTurnComplete
(
,
'turn-m1'
)
)
;
dispatchTurnStarted
(
,
,
'turn-m2'
,
'hello'
,
2
)
;
await
.
waitForNotification
(
=>
isTurnComplete
(
,
'turn-m2'
)
)
;
const
=
await
fetchSessionWithChat
(
,
)
;
.
ok
(
.
.
>=
2
,
` expected >= 2 turns but got ${ state. turns. length} `
)
;
.
strictEqual
(
.
[
0
]
.
,
'turn-m1'
)
;
.
strictEqual
(
.
[
1
]
.
,
'turn-m2'
)
;
}
)
;
test
(
'fetchTurns acknowledges completed turn history loading'
,
async
function
(
)
{
this
.
timeout
(
getAgentHostE2ETestTimeout
(
15_000
,
45_000
)
)
;
const
=
await
createAndSubscribeSession
(
,
'test-fetchTurns'
)
;
dispatchTurnStarted
(
,
,
'turn-ft-1'
,
'hello'
,
1
)
;
await
.
waitForNotification
(
=>
isTurnComplete
(
,
'turn-ft-1'
)
)
;
dispatchTurnStarted
(
,
,
'turn-ft-2'
,
'hello'
,
2
)
;
await
.
waitForNotification
(
=>
isTurnComplete
(
,
'turn-ft-2'
)
)
;
const
=
.
waitForNotification
(
=>
isActionNotification
(
,
'chat/turnsLoaded'
)
)
;
const
=
await
.
call < FetchTurnsResult>
(
'fetchTurns'
,
{
:
defaultChatChannel
(
)
}
)
;
.
deepStrictEqual
(
,
{
}
)
;
const
=
await
;
const
=
getActionEnvelope
(
)
.
as
{
:
string
;
:
unknown
[
]
;
?
:
string
}
;
.
deepStrictEqual
(
.
,
[
]
)
;
.
strictEqual
(
.
,
undefined
)
;
}
)
;
test
(
'fetchTurns rejects an unknown chat'
,
async
function
(
)
{
this
.
timeout
(
getAgentHostE2ETestTimeout
(
10_000
,
60_000
)
)
;
await
client
.
call
(
'initialize'
,
{
:
ROOT_STATE_URI
,
:
[
PROTOCOL_VERSION
]
,
:
'test-fetchTurns-missing'
}
)
;
await
.
rejects
(
(
)
=>
client
.
call
(
'fetchTurns'
,
{
:
'ahp-chat:/missing-session/missing-chat'
}
)
,
/ session not found / i
)
;
}
)
;
test
(
'fetchTurns rejects an unrecognized cursor'
,
async
function
(
)
{
this
.
timeout
(
getAgentHostE2ETestTimeout
(
10_000
,
60_000
)
)
;
const
=
await
createAndSubscribeSession
(
,
'test-fetchTurns-cursor'
)
;
await
.
rejects
(
(
)
=>
client
.
call
(
'fetchTurns'
,
{
:
defaultChatChannel
(
)
,
:
'unknown-cursor'
,
}
)
,
/ unrecognized fetchTurns cursor / i
)
;
}
)
;
test
(
'usage info is captured on completed turn'
,
async
function
(
)
{
this
.
timeout
(
getAgentHostE2ETestTimeout
(
10_000
,
30_000
)
)
;
const
=
await
createAndSubscribeSession
(
,
'test-usage'
)
;
dispatchTurnStarted
(
,
,
'turn-usage'
,
'with-usage'
,
1
)
;
const
=
await
.
waitForNotification
(
=>
isActionNotification
(
,
'chat/usage'
)
)
;
const
=
getActionEnvelope
(
)
.
as
{
:
string
;
:
{
:
number
;
:
number
;
?
:
<
string
,
unknown
>
}
}
;
.
strictEqual
(
.
.
,
100
)
;
.
strictEqual
(
.
.
,
50
)
;
.
deepStrictEqual
(
.
.
,
{
:
0.5
}
)
;
await
.
waitForNotification
(
=>
isActionNotification
(
,
'chat/turnComplete'
)
)
;
const
=
await
fetchSessionWithChat
(
,
)
;
.
ok
(
.
.
>=
1
)
;
const
=
.
[
.
.
-
1
]
;
.
ok
(
.
)
;
.
strictEqual
(
.
!
.
,
100
)
;
.
strictEqual
(
.
!
.
,
50
)
;
.
deepStrictEqual
(
.
!
.
,
{
:
0.5
}
)
;
}
)
;
test
(
'modifiedAt updates on turn completion'
,
async
function
(
)
{
this
.
timeout
(
getAgentHostE2ETestTimeout
(
10_000
,
30_000
)
)
;
const
=
await
createAndSubscribeSession
(
,
'test-modifiedAt'
)
;
const
=
await
.
call < SubscribeResult>
(
'subscribe'
,
{
:
}
)
;
const
=
.
parse
(
(
.
!
.
as
)
.
[
0
]
.
)
;
await
timeout
(
50
)
;
dispatchTurnStarted
(
,
,
'turn-mod'
,
'hello'
,
1
)
;
await
.
waitForNotification
(
=>
isActionNotification
(
,
'chat/turnComplete'
)
)
;
const
=
await
.
call < SubscribeResult>
(
'subscribe'
,
{
:
}
)
;
const
=
.
parse
(
(
.
!
.
as
)
.
[
0
]
.
)
;
.
ok
(
>=
)
;
}
)
;
test
(
'subagent: inner tool calls land in child session, not parent'
,
async
function
(
)
{
this
.
timeout
(
getAgentHostE2ETestTimeout
(
15_000
,
45_000
)
)
;
const
=
await
createAndSubscribeSession
(
,
'test-subagent'
)
;
dispatchTurnStarted
(
,
,
'turn-sa'
,
'subagent'
,
1
)
;
await
.
waitForNotification
(
=>
isActionNotification
(
,
'chat/turnComplete'
)
)
;
const
=
buildSubagentChatUri
(
,
'tc-task-1'
)
;
const
=
await
fetchSessionWithChat
(
,
)
;
const
=
await
fetchSessionWithChat
(
,
)
;
const
=
.
[
.
.
-
1
]
;
const
=
.
.
filter
(
=>
.
===
.
)
;
const
=
.
map
(
=>
.
.
)
;
.
deepStrictEqual
(
,
[
'task'
]
,
'parent turn should only contain the `task` tool call (inner tool must route to subagent)'
)
;
.
ok
(
.
.
>=
1
,
'child subagent session should have at least one turn'
)
;
const
=
.
[
.
.
-
1
]
;
const
=
.
.
filter
(
=>
.
===
.
)
;
const
=
.
map
(
=>
.
.
)
;
.
deepStrictEqual
(
,
[
'echo_tool'
]
,
'child subagent session should contain the inner `echo_tool` call'
)
;
}
)
;
test
(
'subagent: child sessions never appear in listSessions'
,
async
function
(
)
{
this
.
timeout
(
getAgentHostE2ETestTimeout
(
15_000
,
90_000
)
)
;
const
=
await
createAndSubscribeSession
(
,
'test-subagent-list'
)
;
dispatchTurnStarted
(
,
,
'turn-sa-list'
,
'subagent'
,
1
)
;
await
.
waitForNotification
(
=>
isActionNotification
(
,
'chat/turnComplete'
)
)
;
const
=
buildSubagentChatUri
(
,
'tc-task-1'
)
;
const
=
await
.
call < SubscribeResult>
(
'subscribe'
,
{
:
}
)
;
.
ok
(
.
,
'subagent child session should be live'
)
;
const
=
await
.
call < ListSessionsResult>
(
'listSessions'
,
{
:
ROOT_STATE_URI
}
,
getAgentHostE2ETestTimeout
(
5_000
,
30_000
)
)
;
.
deepStrictEqual
(
{
:
.
.
filter
(
=>
isSubagentSession
(
.
)
)
.
map
(
=>
.
)
,
:
.
.
some
(
=>
.
===
)
,
}
,
{
:
[
]
,
:
true
,
}
,
)
;
}
)
;
}
)
;