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 / testRemoteAgentHost.sh 432 строк · изменён 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
#!/usr/bin/env bash
set -e
ROOT = "$(cd "$( dirname "$0 " ) /../../../../../.." && "
--server-port
--cdp-port
--timeout
--no-kill
false
--skip-message
true
-*
*
close /dev/null
CDP_PIDS
/dev/null
/dev/null
/dev/null
/dev/null
/dev/null
SLEEP_PIDS
/dev/null
SERVER_PIDS
/dev/null
cleanup EXIT
/dev/null
/dev/null
--enable-mock-agent
/dev/null
./scripts/code.sh
--skip-sessions-welcome
--remote-debugging-port
--user-data-dir
/dev/null
attach http://127.0.0.1: /dev/null
false
true
// Check radio buttons the session target picker
const buttons document.querySelectorAll
const btn of buttons
btn.textContent?.includes
Test Remote Agent Test Remote Agent
btn.click
Test Remote Agent
screenshot /dev/null
pwd
)
"
SERVER_PORT=8081
CDP_PORT=9224
RESPONSE_TIMEOUT=60
KILL_AFTER=true
SKIP_MESSAGE=false
MESSAGE="
while
[
[
$#
-gt
0
]
]
;
do
case
"$1 "
in
)
SERVER_PORT
=
"$2 "
shift
2
;
;
)
CDP_PORT
=
"$2 "
shift
2
;
;
)
RESPONSE_TIMEOUT
=
"$2 "
shift
2
;
;
)
KILL_AFTER
=
shift
;
;
)
SKIP_MESSAGE
=
shift
;
;
)
echo
"Unknown option: $1 "
>
&2
exit
1
;
;
)
MESSAGE
=
"$1 "
shift
;
;
esac
done
if
[
-z
"$MESSAGE "
]
&&
[
"$SKIP_MESSAGE "
=
false
]
;
then
MESSAGE
=
"Hello, what can you do?"
fi
AB
=
"npx @playwright/cli"
SERVER_PID
=
""
USERDATA_DIR
=
""
cleanup
(
)
{
echo
""
>
&2
echo
"=== Cleanup ==="
>
&2
$AB
2 >
||
true
if
[
"$KILL_AFTER "
=
true
]
;
then
local
CDP_PIDS
=
$( lsof -t -i : "$CDP_PORT " 2 > /dev/null || true )
if
[
-n
"$CDP_PIDS "
]
;
then
echo
"Killing Sessions app (CDP port $CDP_PORT )..."
>
&2
kill
$CDP_PIDS
2 >
||
true
fi
if
[
-n
"$SERVER_PID "
]
&&
kill
-0
"$SERVER_PID "
2 >
;
then
echo
"Killing agent host server (PID $SERVER_PID )..."
>
&2
kill
"$SERVER_PID "
2 >
||
true
sleep
0.5
if
kill
-0
"$SERVER_PID "
2 >
;
then
kill
-9
"$SERVER_PID "
2 >
||
true
fi
fi
local
SLEEP_PIDS
=
$( pgrep -P $$ -f "sleep 86400" 2 > /dev/null || true )
if
[
-n
"$SLEEP_PIDS "
]
;
then
kill
$SLEEP_PIDS
2 >
||
true
fi
local
SERVER_PIDS
=
$( lsof -t -i : "$SERVER_PORT " 2 > /dev/null || true )
if
[
-n
"$SERVER_PIDS "
]
;
then
kill
$SERVER_PIDS
2 >
||
true
fi
fi
if
[
-n
"$USERDATA_DIR "
]
&&
[
-d
"$USERDATA_DIR "
]
;
then
echo
"Cleaning up temp user data dir: $USERDATA_DIR "
>
&2
rm
-rf
"$USERDATA_DIR "
fi
}
trap
echo
"=== Step 1: Starting agent host server on port $SERVER_PORT ==="
>
&2
if
lsof
-i
:
"$SERVER_PORT "
>
2 >
&1
;
then
echo
"ERROR: Port $SERVER_PORT already in use"
>
&2
exit
1
fi
if
lsof
-i
:
"$CDP_PORT "
>
2 >
&1
;
then
echo
"ERROR: CDP port $CDP_PORT already in use"
>
&2
exit
1
fi
cd
"$ROOT "
SERVER_ENTRY
=
"$ROOT /out/vs/platform/agentHost/node/agentHostServerMain.js"
if
[
!
-f
"$SERVER_ENTRY "
]
;
then
echo
"ERROR: Server entry point not found: $SERVER_ENTRY "
>
&2
echo
" Run the build first (npm run compile or the watch task)"
>
&2
exit
1
fi
SERVER_READY_FILE
=
$( mktemp)
node
"$SERVER_ENTRY "
--port
"$SERVER_PORT "
--quiet
\
<
<
(
sleep
86400
)
>
"$SERVER_READY_FILE "
2 >
&
SERVER_PID
=
$!
echo
"Server PID: $SERVER_PID "
>
&2
echo
"Waiting for server to start..."
>
&2
SERVER_ADDR
=
""
for
i
in
$( seq 1 30 )
;
do
READY_MATCH
=
$( grep -o 'READY:[0-9]*' "$SERVER_READY_FILE " 2 > /dev/null || true )
if
[
-n
"$READY_MATCH "
]
;
then
READY_PORT
=
$( echo "$READY_MATCH " | cut -d: -f2 )
SERVER_ADDR
=
"ws://127.0.0.1:${READY_PORT} "
break
fi
sleep
1
done
rm
-f
"$SERVER_READY_FILE "
if
[
-z
"$SERVER_ADDR "
]
;
then
echo
"ERROR: Server did not start within 30 seconds"
>
&2
exit
1
fi
echo
"Agent host server ready at $SERVER_ADDR "
>
&2
echo
"=== Step 2: Configuring Sessions app settings ==="
>
&2
REMOTE_ADDR
=
$( echo "$SERVER_ADDR " | sed 's|^ws://||' )
USERDATA_DIR
=
$( mktemp -d )
SETTINGS_DIR
=
"$USERDATA_DIR /User"
mkdir
-p
"$SETTINGS_DIR "
cat
>
"$SETTINGS_DIR /settings.json"
<<
EOF
{
"chat.remoteAgentHosts": [
{
"address": "$REMOTE_ADDR ",
"name": "Test Remote Agent"
}
],
"window.titleBarStyle": "custom"
}
EOF
echo
"Settings configured: $SETTINGS_DIR /settings.json"
>
&2
echo
" Remote address: $REMOTE_ADDR "
>
&2
echo
"=== Step 3: Launching Sessions app ==="
>
&2
cd
"$ROOT "
VSCODE_SKIP_PRELAUNCH
=
1
ELECTRON_RUN_AS_NODE
=
\
--agents
\
\
=
"$CDP_PORT "
\
=
"$USERDATA_DIR "
\
&>
&
echo
"Waiting for Sessions app to start..."
>
&2
for
i
in
$( seq 1 30 )
;
do
if
$AB
--cdp
=
$CDP_PORT
2 >
;
then
break
fi
sleep
2
if
[
"$i "
-eq
30
]
;
then
echo
"ERROR: Sessions app did not start within 60 seconds"
>
&2
exit
1
fi
done
echo
"Connected to Sessions app via CDP"
>
&2
sleep
3
echo
"=== Step 4: Validating remote agent host connection ==="
>
&2
REMOTE_FOUND
=
for
i
in
$( seq 1 20 )
;
do
SNAPSHOT
=
$( $AB snapshot 2 >&1 || true )
if
echo
"$SNAPSHOT "
|
grep
-qi
"Test Remote Agent\|remote.*agent"
;
then
REMOTE_FOUND
=
break
fi
REMOTE_CHECK
=
$( $AB eval '
(( ) = > {
const text = document.body.innerText || "" ;
if ( text.includes( "Test Remote Agent" ) )
return
"found"
;
in
=
(
".monaco-custom-radio > .monaco-button"
)
;
for
(
)
{
if
(
(
"Test Remote Agent"
))
return
"found"
;
}
return
"not found"
;
}
)
(
)
' 2>&1 || true)
if echo "$REMOTE_CHECK" | grep -q "found"; then
REMOTE_FOUND=true
break
fi
sleep 2
done
if [ "$REMOTE_FOUND" = true ]; then
echo "SUCCESS: Remote agent host '
' is visible in the Sessions app" >&2
else
echo "ERROR: Could not find remote agent host '
' in the Sessions app UI" >&2
echo "Snapshot excerpt:" >&2
echo "$SNAPSHOT" | head -30 >&2
exit 1
fi
# ---- Step 5: Send a message (optional) --------------------------------------
if [ "$SKIP_MESSAGE" = true ]; then
echo "=== Skipping message send (--skip-message) ===" >&2
echo "Remote agent host test completed successfully." >&2
exit 0
fi
echo "=== Step 5: Switching to remote session target and sending message ===" >&2
# Take a screenshot before interaction
SCREENSHOT_DIR="/tmp/remote-agent-test-$(date +%Y-%m-%dT%H-%M-%S)"
mkdir -p "$SCREENSHOT_DIR"
$AB screenshot --filename="$SCREENSHOT_DIR/01-before-interaction.png" 2>/dev/null || true
# Click the session target radio button for the remote agent host
CLICK_RESULT=$($AB eval '
(( ) = > {
const buttons = document.querySelectorAll( ".monaco- custom- radio > .monaco- button") ;
for ( const btn of buttons) {
if ( btn.textContent? .includes( "Test Remote Agent"))
{
(
)
;
return
"clicked"
;
}
}
return
"not found"
;
}
)
(
)
' 2>&1 || true)
if echo "$CLICK_RESULT" | grep -q "not found"; then
echo "ERROR: Could not find '
' radio button to click" >&2
$AB screenshot --filename="$SCREENSHOT_DIR/02-click-failed.png" 2>/dev/null || true
exit 1
fi
echo "Switched to remote session target" >&2
sleep 1
$AB screenshot --filename="$SCREENSHOT_DIR/02-after-target-switch.png" 2>/dev/null || true
# Fill in the remote folder path input (required for remote sessions)
echo "Setting remote folder path..." >&2
FOLDER_SET=$($AB eval '
(( ) = > {
const input = document.querySelector( "input.sessions- chat- remote- folder- text") ;
if ( ! input) return "no input";
input.focus( ) ;
return "focused";
}) ( ) ' 2 > & 1 || true)
if echo "$FOLDER_SET" | grep - q "no input"; then
echo "WARNING: Could not find remote folder input, continuing anyway..." > & 2
else
# Type a folder path using clipboard paste for speed
echo "/ tmp" | pbcopy
$AB press Meta+ a 2 > / dev/ null || true
$AB press Meta+ v 2 > / dev/ null || true
sleep 0.3
# Press Enter to confirm the folder path
$AB press Enter 2 > / dev/ null || true
sleep 0.5
echo "Remote folder path set to / tmp" > & 2
fi
$AB screenshot -- filename= "$SCREENSHOT_DIR/ 03 - after- folder.png" 2 > / dev/ null || true
# Type the message into the chat editor using clipboard paste for speed
echo "Typing message: $MESSAGE" > & 2
$AB eval '
(( ) = > {
/ / Focus the chat editor textarea
const textarea = document.querySelector( ".new- chat- widget .monaco- editor textarea") ;
if ( textarea) { textarea.focus( ) ; return "focused editor"; }
return "editor not found";
}) ( ) ' 2 > / dev/ null || true
sleep 0.3
echo - n "$MESSAGE" | pbcopy
$AB press Meta+ v 2 > / dev/ null || true
sleep 0.5
$AB screenshot -- filename= "$SCREENSHOT_DIR/ 04 - after- type.png" 2 > / dev/ null || true
# Send the message via the send button or keyboard
$AB eval '
(( ) = > {
/ / Try clicking the send button directly
const sendBtn = document.querySelector( ".new- chat- widget .codicon- send") ;
if ( sendBtn) {
const btn = sendBtn.closest( "a, button, .monaco- button") ;
if ( btn) { btn.click( ) ; return "clicked send"; }
}
return "send button not found";
}) ( ) ' 2 > / dev/ null || true
$AB screenshot -- filename= "$SCREENSHOT_DIR/ 05 - after- send.png" 2 > / dev/ null || true
# -- -- Step 6 : Wait for response -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
echo "Waiting for response ( timeout: ${RESPONSE_TIMEOUT}s) ..." > & 2
RESPONSE= ""
for i in $( seq 1 "$RESPONSE_TIMEOUT") ; do
sleep 1
# Check for response content in the chat area
RESPONSE= $( $AB eval '
(( ) = > {
/ / Sessions app uses the main chat area ( not sidebar)
const items = document.querySelectorAll( ".interactive- item- container") ;
if ( items.length < 2 ) return "";
const lastItem = items[items.length - 1 ];
const text = lastItem.textContent || "";
if ( text.length > 20 ) return text;
return "";
}) ( ) ' 2 > & 1 | sed 's/ ^ "/ / ; s/ "$/ / ')
if [ - n "$RESPONSE" ]; then
break
fi
# Progress indicator
if (( i % 10 == 0 ))
;
then
echo
" Still waiting... (${i} s)"
>
&2
fi
done
$AB
--filename
=
"$SCREENSHOT_DIR /04-response.png"
2 >
||
true
if
[
-z
"$RESPONSE "
]
;
then
echo
"WARNING: No response received within ${RESPONSE_TIMEOUT} s"
>
&2
echo
"Screenshots saved to: $SCREENSHOT_DIR "
>
&2
exit
1
fi
echo
"=== Response ==="
>
&2
echo
"$RESPONSE "
echo
""
>
&2
echo
"Screenshots saved to: $SCREENSHOT_DIR "
>
&2
echo
"Remote agent host test completed successfully."
>
&2