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 / toolApproval.integrationTest.ts 230 строк · изменён 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
import assert from 'assert' ;
import { mkdtempSync, rmSync } from 'fs' ;
import { tmpdir } from 'os' ;
import { join } from '../../../../../base/common/path.js' ;
import { URI } from '../../../../../base/common/uri.js' ;
import type { IResponsePartAction } from '../../../common/state/sessionActions.js' ;
import { ResponsePartKind, type MarkdownResponsePart } from '../../../common/state/sessionState.js' ;
import
createAndSubscribeSession
defaultChatChannel
dispatchTurnStarted
getAgentHostE2ETestTimeout
getActionEnvelope
IServerHandle
isActionNotification
startServer
stopServer
TestProtocolClient
server IServerHandle
client TestProtocolClient
workspace
workspace
server env workspace
server
workspace recursive force
client server port
client
client
sessionUri client
client sessionUri
client n n
client n n
client
clientSeq
channel sessionUri
action
type
turnId
toolCallId
approved
responsePart client n n
responsePartAction responsePart action IResponsePartAction
assert responsePartAction part kind ResponsePartKind Markdown
assert responsePartAction part MarkdownResponsePart content
client n n
sessionUri client workspace
client
client sessionUri
client n n
client n n
client n n
pendingConfirmNotifs client n
n
action n action confirmed
action confirmed
assert pendingConfirmNotifs length
sessionUri client workspace
client
client sessionUri
client n n
client n n
client
clientSeq
channel sessionUri
action
type
turnId
toolCallId
approved
confirmed
client n n
sessionUri client
client
client sessionUri
client n n
client n n
client n n
pendingConfirmNotifs client n
n
action n action confirmed
action confirmed
assert pendingConfirmNotifs length
sessionUri client
client
client sessionUri
client n n
client n n
client
clientSeq
channel sessionUri
action
type
turnId
toolCallId
approved
confirmed
client n n
sessionUri client workspace
client
client sessionUri
readyNotif client n
n
n action toolCallId toolCallId
assert readyNotif action toolCallId toolCallId
client n
n
n action part content part content
{
,
,
,
,
,
,
,
,
,
,
}
from
'../serverIntegrationTestHelpers.js'
;
suite
(
'Protocol WebSocket — Permissions & Auto-Approve'
,
function
(
)
{
let
:
;
let
:
;
let
:
string
;
suiteSetup
(
async
function
(
)
{
this
.
timeout
(
getAgentHostE2ETestTimeout
(
15_000
,
60_000
)
)
;
=
mkdtempSync
(
join
(
tmpdir
(
)
,
'agent-host-tool-approval-'
)
)
;
=
await
startServer
(
{
:
{
VSCODE_AGENT_HOST_MOCK_WORKSPACE
:
}
}
)
;
}
)
;
suiteTeardown
(
async
function
(
)
{
this
.
timeout
(
getAgentHostE2ETestTimeout
(
20_000
,
50_000
)
)
;
await
stopServer
(
)
;
rmSync
(
,
{
:
true
,
:
true
}
)
;
}
)
;
setup
(
async
function
(
)
{
this
.
timeout
(
10_000
)
;
=
new
TestProtocolClient
(
.
)
;
await
.
connect
(
)
;
}
)
;
teardown
(
function
(
)
{
.
close
(
)
;
}
)
;
test
(
'permission request → resolve → response'
,
async
function
(
)
{
this
.
timeout
(
10_000
)
;
const
=
await
createAndSubscribeSession
(
,
'test-permission'
)
;
dispatchTurnStarted
(
,
,
'turn-perm'
,
'permission'
,
1
)
;
await
.
waitForNotification
(
=>
isActionNotification
(
,
'chat/toolCallStart'
)
)
;
await
.
waitForNotification
(
=>
isActionNotification
(
,
'chat/toolCallReady'
)
)
;
.
notify
(
'dispatchAction'
,
{
:
2
,
:
defaultChatChannel
(
)
,
:
{
:
'chat/toolCallConfirmed'
,
:
'turn-perm'
,
:
'tc-perm-1'
,
:
true
,
}
,
}
)
;
const
=
await
.
waitForNotification
(
=>
isActionNotification
(
,
'chat/responsePart'
)
)
;
const
=
getActionEnvelope
(
)
.
as
;
.
strictEqual
(
.
.
,
.
)
;
.
strictEqual
(
(
.
as
)
.
,
'Allowed.'
)
;
await
.
waitForNotification
(
=>
isActionNotification
(
,
'chat/turnComplete'
)
)
;
}
)
;
test
(
'auto-approves write to regular file (no pending confirmation)'
,
async
function
(
)
{
this
.
timeout
(
10_000
)
;
const
=
await
createAndSubscribeSession
(
,
'test-autoapprove'
,
URI
.
file
(
)
.
toString
(
)
)
;
.
clearReceived
(
)
;
dispatchTurnStarted
(
,
,
'turn-autoapprove'
,
'write-file'
,
1
)
;
await
.
waitForNotification
(
=>
isActionNotification
(
,
'chat/toolCallStart'
)
)
;
await
.
waitForNotification
(
=>
isActionNotification
(
,
'chat/toolCallComplete'
)
)
;
await
.
waitForNotification
(
=>
isActionNotification
(
,
'chat/turnComplete'
)
)
;
const
=
.
receivedNotifications
(
=>
{
if
(
!
isActionNotification
(
,
'chat/toolCallReady'
)
)
{
return
false
;
}
const
=
getActionEnvelope
(
)
.
as
{
?
:
string
}
;
return
!
.
;
}
)
;
.
strictEqual
(
.
,
0
,
'should not have received pending-confirmation toolCallReady for auto-approved write'
)
;
}
)
;
test
(
'blocks write to .env file (requires manual confirmation)'
,
async
function
(
)
{
this
.
timeout
(
10_000
)
;
const
=
await
createAndSubscribeSession
(
,
'test-autoapprove-deny'
,
URI
.
file
(
)
.
toString
(
)
)
;
.
clearReceived
(
)
;
dispatchTurnStarted
(
,
,
'turn-deny'
,
'write-env'
,
1
)
;
await
.
waitForNotification
(
=>
isActionNotification
(
,
'chat/toolCallStart'
)
)
;
await
.
waitForNotification
(
=>
isActionNotification
(
,
'chat/toolCallReady'
)
)
;
.
notify
(
'dispatchAction'
,
{
:
2
,
:
defaultChatChannel
(
)
,
:
{
:
'chat/toolCallConfirmed'
,
:
'turn-deny'
,
:
'tc-write-env-1'
,
:
true
,
:
'user-action'
,
}
,
}
)
;
await
.
waitForNotification
(
=>
isActionNotification
(
,
'chat/turnComplete'
)
)
;
}
)
;
test
(
'auto-approves allowed shell command (no pending confirmation)'
,
async
function
(
)
{
this
.
timeout
(
10_000
)
;
const
=
await
createAndSubscribeSession
(
,
'test-shell-approve'
)
;
.
clearReceived
(
)
;
dispatchTurnStarted
(
,
,
'turn-shell-approve'
,
'run-safe-command'
,
1
)
;
await
.
waitForNotification
(
=>
isActionNotification
(
,
'chat/toolCallStart'
)
)
;
await
.
waitForNotification
(
=>
isActionNotification
(
,
'chat/toolCallComplete'
)
)
;
await
.
waitForNotification
(
=>
isActionNotification
(
,
'chat/turnComplete'
)
)
;
const
=
.
receivedNotifications
(
=>
{
if
(
!
isActionNotification
(
,
'chat/toolCallReady'
)
)
{
return
false
;
}
const
=
getActionEnvelope
(
)
.
as
{
?
:
string
}
;
return
!
.
;
}
)
;
.
strictEqual
(
.
,
0
,
'should not have received pending-confirmation toolCallReady for allowed shell command'
)
;
}
)
;
test
(
'blocks denied shell command (requires manual confirmation)'
,
async
function
(
)
{
this
.
timeout
(
10_000
)
;
const
=
await
createAndSubscribeSession
(
,
'test-shell-deny'
)
;
.
clearReceived
(
)
;
dispatchTurnStarted
(
,
,
'turn-shell-deny'
,
'run-dangerous-command'
,
1
)
;
await
.
waitForNotification
(
=>
isActionNotification
(
,
'chat/toolCallStart'
)
)
;
await
.
waitForNotification
(
=>
isActionNotification
(
,
'chat/toolCallReady'
)
)
;
.
notify
(
'dispatchAction'
,
{
:
2
,
:
defaultChatChannel
(
)
,
:
{
:
'chat/toolCallConfirmed'
,
:
'turn-shell-deny'
,
:
'tc-shell-deny-1'
,
:
true
,
:
'user-action'
,
}
,
}
)
;
await
.
waitForNotification
(
=>
isActionNotification
(
,
'chat/turnComplete'
)
)
;
}
)
;
test
(
'dispatches pending_confirmation that arrives without an active turn (does not hang)'
,
async
function
(
)
{
this
.
timeout
(
10_000
)
;
const
=
await
createAndSubscribeSession
(
,
'test-orphan-confirmation'
,
URI
.
file
(
)
.
toString
(
)
)
;
.
clearReceived
(
)
;
dispatchTurnStarted
(
,
,
'turn-orphan'
,
'orphan-confirmation'
,
1
)
;
const
=
await
.
waitForNotification
(
=>
isActionNotification
(
,
'chat/toolCallReady'
)
&&
(
getActionEnvelope
(
)
.
as
{
?
:
string
}
)
.
===
'tc-orphan'
,
8_000
)
;
.
strictEqual
(
(
getActionEnvelope
(
)
.
as
{
:
string
}
)
.
,
'tc-orphan'
)
;
await
.
waitForNotification
(
=>
isActionNotification
(
,
'chat/responsePart'
)
&&
(
(
getActionEnvelope
(
)
.
as
{
?
:
{
?
:
string
}
}
)
.
?.
===
'continued-after-hook'
)
,
8_000
)
;
}
)
;
}
)
;