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 / providerIntegration / copilotMockLlm.integrationTest.ts 301 строк · изменён 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
import assert from 'assert' ;
import { existsSync } from 'fs' ;
import { mkdtemp, readFile, rm, writeFile } from 'fs/promises' ;
import { tmpdir } from 'os' ;
import { timeout } from '../../../../../base/common/async.js' ;
import { join } from '../../../../../base/common/path.js' ;
import { isWindows } from '../../../../../base/common/platform.js' ;
import {
ActionType
buildDefaultChatUri ResponsePartKind SessionStatus
ToolCallConfirmationReason
AgentHostSessionReleaseRetryMsEnvVar AgentHostSessionResidencyLimitEnvVar
createProviderSession dispatchTurn
fetchSessionWithChat getActionEnvelope isActionNotification IServerHandle startRealServer stopServer TestProtocolClient
IAgentHostProviderTestConfig
provider
scheme
githubToken
value
isWindows
server IServerHandle
client TestProtocolClient
suiteHome
createdSessions
tempDirs
suiteHome
server
mockLlm
homeDir suiteHome
userDataDir suiteHome
server
suiteHome recursive force maxRetries retryDelay
client server port
client
session createdSessions
session
createdSessions length
client
dir tempDirs
dir recursive force maxRetries retryDelay
tempDirs length
probeToken
workspaceDir
tempDirs workspaceDir
sessionUri client createdSessions workspaceDir
client sessionUri
client n n
err
assert server mockLlm
state client sessionUri
turn state turns t t id
markdownText turn responseParts p p kind ResponsePartKind Markdown p content
assert markdownText length
assert markdownText
server IServerHandle
client TestProtocolClient
suiteHome
detachedCompletionMarker
createdSessions
tempDirs
suiteHome
detachedCompletionMarker suiteHome
detachedScript suiteHome
detachedScript
command
server
mockLlm
homeDir suiteHome
userDataDir suiteHome
env
AgentHostSessionResidencyLimitEnvVar
AgentHostSessionReleaseRetryMsEnvVar
mockScenarios
id
definition
type
turns
kind
toolCalls
toolNamePattern
arguments
command
description
mode
detach
initial_wait
kind chunks content delayMs
server
suiteHome recursive force maxRetries retryDelay
client server port
client
session createdSessions
session
createdSessions length
client
dir tempDirs
dir recursive force maxRetries retryDelay
tempDirs length
workspaceDir
tempDirs workspaceDir
sessionUri client createdSessions workspaceDir
turnId
client sessionUri turnId
readyNotification client n
n
n action ChatToolCallReadyAction confirmed
readyEnvelope readyNotification
readyAction readyEnvelope action ChatToolCallReadyAction
client
channel readyEnvelope channel
clientSeq
action
type ActionType ChatToolCallConfirmed
turnId readyAction turnId
toolCallId readyAction toolCallId
approved
confirmed ToolCallConfirmationReason UserAction
completeNotification client n n
completeAction completeNotification action ChatToolCallCompleteAction
assert completeAction result
client n n
idle client sessionUri
assert
activeTurn idle activeTurn
inProgress idle status SessionStatus InProgress
activeTurn
inProgress
channel sessionUri sessionUri
client channel
attempt attempt detachedCompletionMarker attempt
assert detachedCompletionMarker
assistantMarkdown turns ISessionWithDefaultChat turnId
turns t t id turnId responseParts p p kind ResponsePartKind Markdown p content
transcript turns ISessionWithDefaultChat
turns t message t message text markdown turns t id
workspaceDir
tempDirs workspaceDir
sessionUri client createdSessions workspaceDir
firstProbe
client sessionUri
client n n
before client sessionUri
assert before turns
channel sessionUri sessionUri
client channel
after client sessionUri
assert after turns before turns
client
secondProbe
client sessionUri
client n n
final client sessionUri
assert final turns
URI
}
from
'../../../../../base/common/uri.js'
;
import
{
,
type
ChatToolCallCompleteAction
,
type
ChatToolCallReadyAction
}
from
'../../../common/state/sessionActions.js'
;
import
{
,
,
,
type
ISessionWithDefaultChat
}
from
'../../../common/state/sessionState.js'
;
import
{
}
from
'../../../common/state/protocol/channels-chat/state.js'
;
import
{
,
}
from
'../../../common/agentService.js'
;
import
{
,
,
type
IAgentHostProviderTestConfig
}
from
'../providerIntegrationTestHelpers.js'
;
import
{
,
,
,
,
,
,
}
from
'../serverIntegrationTestHelpers.js'
;
const
COPILOT_CONFIG
:
=
{
:
'copilotcli'
,
:
'copilotcli'
,
:
'not-a-real-token'
,
}
;
const
DETACHED_SHELL_SCENARIO_ID
=
'detached-shell-idle-release'
;
const
DETACHED_SHELL_DELAY_MS
=
6000
;
function
quoteShellArgument
(
:
string
)
:
string
{
return
?
` ' ${ value. replace ( / ' / g , '\'\'' ) } ' `
:
` ' ${ value. replace ( / ' / g , ` '\\'' ` ) } ' `
;
}
suite
(
'Agent Host Provider Integration — Copilot with Mock LLM'
,
function
(
)
{
let
:
;
let
:
;
let
:
string
;
const
:
string
[
]
=
[
]
;
const
:
string
[
]
=
[
]
;
suiteSetup
(
async
function
(
)
{
this
.
timeout
(
120_000
)
;
=
await
mkdtemp
(
` ${ tmpdir ( ) } /test-mock-copilot-home- `
)
;
=
await
startRealServer
(
{
:
true
,
:
,
:
join
(
,
'user-data'
)
,
}
)
;
}
)
;
suiteTeardown
(
async
function
(
)
{
await
stopServer
(
)
;
await
rm
(
,
{
:
true
,
:
true
,
:
5
,
:
200
}
)
;
}
)
;
setup
(
async
function
(
)
{
this
.
timeout
(
120_000
)
;
=
new
TestProtocolClient
(
.
)
;
await
.
connect
(
)
;
}
)
;
teardown
(
async
function
(
)
{
for
(
const
of
)
{
try
{
await
client
.
call
(
'disposeSession'
,
{
}
,
5000
)
;
}
catch
{
}
}
.
=
0
;
.
close
(
)
;
for
(
const
of
)
{
try
{
await
rm
(
,
{
:
true
,
:
true
,
:
5
,
:
200
}
)
;
}
catch
{
}
}
.
=
0
;
}
)
;
test
(
'returns a hello response via mock LLM'
,
async
function
(
)
{
this
.
timeout
(
180_000
)
;
const
=
'MOCK_REQUEST_PROBE_12345'
;
const
=
await
mkdtemp
(
` ${ tmpdir ( ) } /test-mock-hello `
)
;
.
push
(
)
;
const
=
await
createProviderSession
(
,
COPILOT_CONFIG
,
'real-sdk-mock-hello'
,
,
URI
.
file
(
)
)
;
dispatchTurn
(
,
,
'turn-mock-hello'
,
` Reply with exactly: ${ probeToken} `
,
1
)
;
try
{
await
.
waitForNotification
(
=>
isActionNotification
(
,
'chat/turnComplete'
)
,
90_000
)
;
}
catch
(
)
{
console
.
error
(
` Failed to receive chat/turnComplete notification within timeout: ${ err} , receivedNotifications: ${ JSON . stringify ( client. receivedNotifications ( ) ) } , logMessages: ${ server. mockLlm?. logMessages. join ( '\n' ) ?? 'no mockllm server' } `
)
;
throw
new
Error
(
` Failed to receive chat/turnComplete notification within timeout: ${ err} , receivedNotifications: ${ JSON . stringify ( client. receivedNotifications ( ) ) } , logMessages: ${ server. mockLlm?. logMessages. join ( '\n' ) ?? 'no mockllm server' } `
)
;
}
.
ok
(
(
.
?.
requestCount
(
)
??
0
)
>=
1
,
'expected at least one request to the mock LLM'
)
;
const
=
await
fetchSessionWithChat
(
,
)
;
const
=
.
.
find
(
=>
.
===
'turn-mock-hello'
)
;
const
=
?.
.
map
(
=>
.
===
.
?
.
:
''
)
.
join
(
'\n'
)
??
` `
;
.
ok
(
.
trim
(
)
.
>
0
,
` expected non-empty assistant markdown; got: ${ JSON . stringify ( markdownText) } `
)
;
.
match
(
,
new
RegExp
(
` \\b ${ probeToken} \\b `
,
'i'
)
,
` expected probe token in assistant markdown; got: ${ JSON . stringify ( markdownText) } `
)
;
}
)
;
}
)
;
suite
(
'Agent Host Provider Integration — Copilot Idle Release'
,
function
(
)
{
const
RELEASE_RETRY_MS
=
500
;
let
:
;
let
:
;
let
:
string
;
let
:
string
;
const
:
string
[
]
=
[
]
;
const
:
string
[
]
=
[
]
;
suiteSetup
(
async
function
(
)
{
this
.
timeout
(
120_000
)
;
=
await
mkdtemp
(
` ${ tmpdir ( ) } /test-mock-idle-release-home `
)
;
=
join
(
,
'detached-shell-complete'
)
;
const
=
join
(
,
'detached-shell.js'
)
;
await
writeFile
(
,
` setTimeout(() => require('fs').writeFileSync( ${ JSON . stringify ( detachedCompletionMarker) } , 'done'), ${ DETACHED_SHELL_DELAY_MS } ); `
)
;
const
=
` node ${ quoteShellArgument ( detachedScript) } `
;
=
await
startRealServer
(
{
:
true
,
:
,
:
join
(
,
'user-data'
)
,
:
{
[
]
:
'0'
,
[
]
:
String
(
RELEASE_RETRY_MS
)
,
}
,
:
[
{
:
DETACHED_SHELL_SCENARIO_ID
,
:
{
:
'multi-turn'
,
:
[
{
:
'tool-calls'
,
:
[
{
:
/ ^ ( bash| powershell) $ /
,
:
{
,
:
'Run detached shell release probe'
,
:
'async'
,
:
true
,
:
30
,
}
,
}
]
,
}
,
{
:
'content'
,
:
[
{
:
'Waiting for detached shell completion.'
,
:
0
}
]
}
,
]
,
}
,
}
]
,
}
)
;
}
)
;
suiteTeardown
(
async
function
(
)
{
await
stopServer
(
)
;
await
rm
(
,
{
:
true
,
:
true
,
:
5
,
:
200
}
)
;
}
)
;
setup
(
async
function
(
)
{
this
.
timeout
(
120_000
)
;
=
new
TestProtocolClient
(
.
)
;
await
.
connect
(
)
;
}
)
;
teardown
(
async
function
(
)
{
for
(
const
of
)
{
try
{
await
client
.
call
(
'disposeSession'
,
{
}
,
5000
)
;
}
catch
{
}
}
.
=
0
;
.
close
(
)
;
for
(
const
of
)
{
try
{
await
rm
(
,
{
:
true
,
:
true
,
:
5
,
:
200
}
)
;
}
catch
{
}
}
.
=
0
;
}
)
;
test
(
'keeps a detached shell running after an idle session loses all subscribers (mock LLM)'
,
async
function
(
)
{
this
.
timeout
(
180_000
)
;
const
=
await
mkdtemp
(
` ${ tmpdir ( ) } /test-mock-detached-release `
)
;
.
push
(
)
;
const
=
await
createProviderSession
(
,
COPILOT_CONFIG
,
'real-sdk-mock-detached-release'
,
,
URI
.
file
(
)
)
;
const
=
'turn-detached-release'
;
dispatchTurn
(
,
,
,
` [scenario: ${ DETACHED_SHELL_SCENARIO_ID } ] Start the detached shell. `
,
1
)
;
const
=
await
.
waitForNotification
(
=>
{
if
(
!
isActionNotification
(
,
'chat/toolCallReady'
)
)
{
return
false
;
}
return
!
(
getActionEnvelope
(
)
.
as
)
.
;
}
,
90_000
)
;
const
=
getActionEnvelope
(
)
;
const
=
.
as
;
.
dispatch
(
{
:
.
,
:
2
,
:
{
:
.
,
:
.
,
:
.
,
:
true
,
:
.
,
}
,
}
)
;
const
=
await
.
waitForNotification
(
=>
isActionNotification
(
,
'chat/toolCallComplete'
)
,
90_000
)
;
const
=
getActionEnvelope
(
)
.
as
;
.
match
(
JSON
.
stringify
(
.
)
,
/ detached background /
)
;
await
.
waitForNotification
(
=>
isActionNotification
(
,
'chat/turnComplete'
)
,
90_000
)
;
const
=
await
fetchSessionWithChat
(
,
)
;
.
deepStrictEqual
(
{
:
.
,
:
(
.
&
.
)
!==
0
,
}
,
{
:
undefined
,
:
false
,
}
)
;
for
(
const
of
[
buildDefaultChatUri
(
)
,
]
)
{
.
notify
(
'unsubscribe'
,
{
}
)
;
}
await
timeout
(
RELEASE_RETRY_MS
+
1000
)
;
for
(
let
=
0
;
<
150
&&
!
existsSync
(
)
;
++
)
{
await
timeout
(
100
)
;
}
.
strictEqual
(
await
readFile
(
,
'utf8'
)
,
'done'
)
;
}
)
;
test
(
'releases an idle session and resumes it losslessly on re-subscribe (mock LLM)'
,
async
function
(
)
{
this
.
timeout
(
180_000
)
;
const
=
(
:
[
'turns'
]
,
:
string
)
:
string
=>
.
find
(
=>
.
===
)
?.
.
map
(
=>
.
===
.
?
.
:
''
)
.
join
(
'\n'
)
??
''
;
const
=
(
:
[
'turns'
]
)
=>
.
map
(
=>
(
{
:
.
.
,
:
assistantMarkdown
(
,
.
)
}
)
)
;
const
=
await
mkdtemp
(
` ${ tmpdir ( ) } /test-mock-release-resume `
)
;
.
push
(
)
;
const
=
await
createProviderSession
(
,
COPILOT_CONFIG
,
'real-sdk-mock-release'
,
,
URI
.
file
(
)
)
;
const
=
'MOCK_RELEASE_PROBE_1'
;
dispatchTurn
(
,
,
'turn-release-1'
,
` Reply with exactly: ${ firstProbe} `
,
1
)
;
await
.
waitForNotification
(
=>
isActionNotification
(
,
'chat/turnComplete'
)
,
90_000
)
;
const
=
await
fetchSessionWithChat
(
,
)
;
.
match
(
assistantMarkdown
(
.
,
'turn-release-1'
)
,
new
RegExp
(
` \\b ${ firstProbe} \\b `
,
'i'
)
,
'first turn should have completed before release'
)
;
for
(
const
of
[
buildDefaultChatUri
(
)
,
]
)
{
.
notify
(
'unsubscribe'
,
{
}
)
;
}
await
timeout
(
RELEASE_RETRY_MS
+
2000
)
;
const
=
await
fetchSessionWithChat
(
,
)
;
.
deepStrictEqual
(
transcript
(
.
)
,
transcript
(
.
)
,
'restored transcript must match the pre-release state'
)
;
.
clearReceived
(
)
;
const
=
'MOCK_RELEASE_PROBE_2'
;
dispatchTurn
(
,
,
'turn-release-2'
,
` Reply with exactly: ${ secondProbe} `
,
2
)
;
await
.
waitForNotification
(
=>
isActionNotification
(
,
'chat/turnComplete'
)
,
90_000
)
;
const
=
await
fetchSessionWithChat
(
,
)
;
.
match
(
assistantMarkdown
(
.
,
'turn-release-2'
)
,
new
RegExp
(
` \\b ${ secondProbe} \\b `
,
'i'
)
,
'a follow-up turn must complete after the release/resume cycle'
)
;
}
)
;
}
)
;