Это ide на основе vs code(code oss), в ней будет встроенный умный апи роутинг, свой маркет с плагинами(агент харнесс, поддержка java/kotlin/мобильной разработки, командная разработка проектов, orca, оркестратор агентов
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/// @ts-check/**
* Shared utilities for chat performance benchmarks and leak checks.
*
* Platform: macOS and Linux only. Windows is not supported — several
* utilities (`sqlite3`, `sleep`, `pkill`) are Unix-specific.
* CI runs on ubuntu-latest.
*/const path =require('path');const fs =require('fs');const os =require('os');const http =require('http');const{ execSync, execFileSync, spawn }=require('child_process');constROOT= path.join__dirname
path
text
raw fspath__dirname
config raw
configsection
buildIdx electronPath
buildIdx
posixIdx electronPath
posixIdx
electronPath posixIdx
electronPath buildIdx
product path
process
path product
process
path product
path
value value
value
value
process
appDir exePath
pathappDir
process
pathpathexePath
pathpathexePath
buildArg
buildArg
downloadAndUnzipVSCode resolveCliArgsFromVSCodeExecutablePath
exePath buildArg
builtinExtDir exePath
hasCopilotBuiltin builtinExtDir fsbuiltinExtDir
fsbuiltinExtDir e
hasCopilotBuiltin
extDir path
fsextDir
cli cliArgs exePath
extId
spawnSync
result cli cliArgs extDir extId
process
result
exePath
pathbuildArg
globalStorageDir pathuserDataDir
fsglobalStorageDir
dbPath pathglobalStorageDir
sql
dbPath sql
env
process
mockServer mockServer
isDevBuild
env
env
env
env
userDataDir extDir logsDir isDevBuild extHostInspectPort traceFile appRoot gcObjectStats
chromiumFlags
traceFile
gcCategories gcObjectStats
chromiumFlags
chromiumFlags
chromiumFlags
args
chromiumFlags
appRoot
isDevBuild
args
process
args
process process
args
extHostInspectPort
args
args
settingsDir pathuserDataDir
fssettingsDir
fspathsettingsDir
mockServer
mockServer
overrides
tmpBase pathos
userDataDir pathtmpBase
extDir path
logsDir pathtmpBase
attempt attempt attempt
fsuserDataDir
err
error err
attempt error
error
fsuserDataDir
fsextDir
fslogsDir
userDataDir
userDataDir mockServer settingsOverrides
userDataDir extDir logsDir
nextExtHostPort
nextExtHostPort
verbose timeoutMs opts
deadline timeoutMs
wsUrl
deadline
targets
targets targets
wsUrl targets
r
wsUrl
verbose
ws wsUrl
ws resolve
ws reject
msgId
pending
eventListeners
ws data
msg data
msg
p pendingmsg
p
pendingmsg
msg p msg
pmsg
msg
listeners eventListenersmsg
listener listeners msg
port
id msgId
pendingid resolve reject
ws id method params
pendingid
pendingid
list eventListenersevent
listlistener
eventListenersevent list
ws
httpurl
data
res data chunk
res
data
reject
deadline timeoutMs
deadline
r
deadline timeoutMs
deadline
pages browser ctx
page pages
hasWorkbench page
globalThiswhenWorkbenchRestored
hasWorkbench
page
r
nextPort
chromium
port nextPort
args launchArgs
isShell process
opts
child executable args
env
isShell
opts
exitError
child
exitError
exitError
port
e
exitError exitError
e
browser chromium
page browser
page
browser
quitKey process
pagequitKey
pid child
timer
pid
child
child timer
browser
r
sorted values a b
mid sorted
sorted sortedmid sortedmid sortedmid
values values
sorted values a b
q1 sortedsorted
q3 sortedsorted
iqr q3 q1
lo q1 iqr
hi q3 iqr
sorted v lo v hi
x
x
x a a b
x b a
lnBeta a b a b
front x a x b lnBeta a
maxIter
eps
c d a b x a
d eps d eps
d d
result d
m m maxIter m
num m b m x a m a m
d num d d eps d eps d d
c num c c eps c eps
result d c
num a m a b m x a m a m
d num d d eps d eps d d
c num c c eps c eps
delta d c
result delta
delta eps
front result
g
coef
z
z z
z
x coef
i i g i x coefi z i
t z g
z t t x
x df df t t
x df
a b
meanA a s v a
meanB b s v b
varA a s v meanA a
varB b s v meanB b
seA varA a
seB varB b
seDiff seA seB
seDiff
t meanB meanA seDiff
df seA seB seA a seB b
pValue t df
significant pValue
confidence
pValue confidence
pValue confidence
pValue confidence
confidence
t df pValue significant confidence
valid raw v
valid
cleaned valid
cleaned
sorted cleaned a b
med sorted
p95 sortedsorted sorted
mean sorted a b sorted
variance sorted a b mean sorted
stddev variance
cv mean stddev mean
med
p95
sorted
sortedsorted
mean
stddev
cv
sorted
valid cleaned
n values
n
sumX sumY sumXY sumX2
i i n i
sumX i
sumY valuesi
sumXY i valuesi
sumX2 i i
n sumXY sumX sumY n sumX2 sumX sumX
s values
s
cv s
outliers s
fromMark marks m
toMark marks m to
fromMark toMark
toMark fromMark
module
loadConfig
getElectronPath
getRepoRoot
isVersionString
resolveBuild
preseedStorage
buildEnv
buildArgs
writeSettings
prepareRunDir
median
removeOutliers
robustStats
welchTTest
linearRegressionSlope
summarize
markDuration
launchVSCode
getNextExtHostInspectPort
connectToExtHostInspector
/**
* Load a namespaced section from config.jsonc.
* @param{string}section - Top-level key (e.g. 'perfRegression', 'memLeaks')
* @returns{Record<string, any>}
*/
function
loadConfig
(
section
)
{
const
=
.
readFileSync
(
.
join
(
,
'..'
,
'config.jsonc'
)
,
'utf-8'
)
;
const
=
JSON
.
parse
(
stripJsoncComments
(
)
)
;
return
[
]
??
{
}
;
}
// -- Electron path resolution ------------------------------------------------
/**
* Derive the VS Code repo root from an Electron executable path.
* Dev builds live at `<repo>/.build/electron/<app>/`, so we walk up
* from the path to find the directory containing `.build`.
* Returns `undefined` if the path doesn't look like a dev build.
* @param{string}electronPath
* @returns{string |undefined}
*/
function
getRepoRoot
(
electronPath
)
{
const
=
.
indexOf
(
`${path.sep}.build${path.sep}`
)
;
if
(
===
-
1
)
{
// Also check for posix separators (path may be user-supplied)
const
=
.
indexOf
(
'/.build/'
)
;
if
(
===
-
1
)
{
return
undefined
;
}
return
.
slice
(
0
,
)
;
}
return
.
slice
(
0
,
)
;
}
function
getElectronPath
(
)
{
const
=
require
(
.
join
(
ROOT
,
'product.json'
)
)
;
if
(
.
platform
===
'darwin'
)
{
return
.
join
(
ROOT
,
'.build'
,
'electron'
,
`${product.nameLong}.app`
,
'Contents'
,
'MacOS'
,
.
nameShort
)
;
}
else
if
(
.
platform
===
'linux'
)
{
return
.
join
(
ROOT
,
'.build'
,
'electron'
,
.
applicationName
)
;
}
else
{
return
.
join
(
ROOT
,
'.build'
,
'electron'
,
`${product.nameShort}.exe`
)
;
}
}
/**
* Returns true if the string looks like a VS Code version or commit hash
* rather than a file path.
* @param{string}value
*/
function
isVersionString
(
value
)
{
if
(
===
'insiders'
||
===
'stable'
)
{
return
true
;
}
if
(
/^\d+\.\d+\.\d+/
.
test
(
)
)
{
return
true
;
}
if
(
/^[0-9a-f]{7,40}$/
.
test
(
)
)
{
return
true
;
}
return
false
;
}
/**
* Get the built-in extensions directory for a VS Code executable.
* @param{string}exePath
* @returns{string |undefined}
*/
function
getBuiltinExtensionsDir
(
exePath
)
{
if
(
.
platform
===
'darwin'
)
{
const
=
.
split
(
'/Contents/'
)
[
0
]
;
return
.
join
(
,
'Contents'
,
'Resources'
,
'app'
,
'extensions'
)
;
}
else
if
(
.
platform
===
'linux'
)
{
return
.
join
(
.
dirname
(
)
,
'resources'
,
'app'
,
'extensions'
)
;
}
else
{
return
.
join
(
.
dirname
(
)
,
'resources'
,
'app'
,
'extensions'
)
;
}
}
/**
* Resolve a build arg to an executable path.
* Version strings are downloaded via @vscode/test-electron.
* @param{string |undefined}buildArg
* @returns{Promise<string>}
*/
async
function
resolveBuild
(
buildArg
)
{
if
(
!
)
{
return
getElectronPath
(
)
;
}
if
(
isVersionString
(
)
)
{
console
.
log
(
`[chat-simulation] Downloading VS Code ${buildArg}...`
)
;
const
{
,
}
=
require
(
'@vscode/test-electron'
)
;
const
=
await
downloadAndUnzipVSCode
(
)
;
console
.
log
(
`[chat-simulation] Downloaded: ${exePath}`
)
;
// Check if copilot is already bundled as a built-in extension
// (recent Insiders/Stable builds ship it in the app's extensions/ dir).
const
=
getBuiltinExtensionsDir
(
)
;
const
=
&&
.
existsSync
(
)
&&
.
readdirSync
(
)
.
some
(
e
=>
===
'copilot'
)
;
if
(
)
{
console
.
log
(
`[chat-simulation] Copilot is bundled as a built-in extension`
)
;
}
else
{
// Install copilot-chat from the marketplace into our shared
// extensions dir so it's available when we launch with
// --extensions-dir=DATA_DIR/extensions.
const
=
.
join
(
DATA_DIR
,
'extensions'
)
;
.
mkdirSync
(
,
{
recursive
:
true
}
)
;
const
[
,
...
]
=
resolveCliArgsFromVSCodeExecutablePath
(
)
;
const
=
'GitHub.copilot-chat'
;
console
.
log
(
`[chat-simulation] Installing ${extId} into ${extDir}...`
)
;
const
{
}
=
require
(
'child_process'
)
;
const
=
spawnSync
(
,
[
...
,
'--extensions-dir'
,
,
'--install-extension'
,
]
,
{
encoding
:
'utf-8'
,
stdio
:
'pipe'
,
shell
:
.
platform
===
'win32'
,
timeout
:
120_000
,
}
)
;
if
(
.
status
!==
0
)
{
console
.
warn
(
`[chat-simulation] Extension install exited with ${result.status}: ${(result.stderr||'').substring(0,500)}`
/**
* Pre-seed the VS Code storage database to prevent the
* BuiltinChatExtensionEnablementMigration from disabling the copilot
* extension on fresh user data directories.
*
* Requires `sqlite3` on PATH (pre-installed on macOS and Ubuntu).
* @param{string}userDataDir
*/
function
preseedStorage
(
userDataDir
)
{
const
=
.
join
(
,
'User'
,
'globalStorage'
)
;
.
mkdirSync
(
,
{
recursive
:
true
}
)
;
const
=
.
join
(
,
'state.vscdb'
)
;
const
=
[
'CREATE TABLE IF NOT EXISTS ItemTable (key TEXT UNIQUE ON CONFLICT REPLACE, value BLOB);'
,
'INSERT INTO ItemTable (key, value) VALUES (\'builtinChatExtensionEnablementMigration\', \'true\');'
,
'INSERT INTO ItemTable (key, value) VALUES (\'chat.tools.global.autoApprove.optIn\', \'true\');'
// Enable extension host inspector for profiling/heap snapshots
if
(
>
0
)
{
.
push
(
`--inspect-extensions=${extHostInspectPort}`
)
;
}
return
;
}
/**
* Write VS Code settings that point the copilot extension at the mock server.
* @param{string}userDataDir
* @param{{ url: string }}mockServer
* @param{Record<string, any>}[overrides]
*/
function
writeSettings
(
userDataDir, mockServer, overrides
)
{
const
=
.
join
(
,
'User'
)
;
.
mkdirSync
(
,
{
recursive
:
true
}
)
;
.
writeFileSync
(
.
join
(
,
'settings.json'
)
,
JSON
.
stringify
(
{
'github.copilot.advanced.debug.overrideProxyUrl'
:
.
url
,
'github.copilot.advanced.debug.overrideCapiUrl'
:
.
url
,
'chat.allowAnonymousAccess'
:
true
,
// Disable MCP servers — they start async and add unpredictable
// delay that pollutes perf measurements.
'chat.mcp.discovery.enabled'
:
false
,
'chat.mcp.enabled'
:
false
,
'github.copilot.chat.githubMcpServer.enabled'
:
false
,
'github.copilot.chat.cli.mcp.enabled'
:
false
,
// Auto-approve all tool invocations (YOLO mode) so tool call
/**
* Connect to the extension host's Node inspector via WebSocket.
* The extension host must be started with `--inspect-extensions=<port>`.
*
* @param{number}port
* @param{{ verbose?: boolean, timeoutMs?: number }}[opts]
* @returns{Promise<{ send:(method: string, params?: any)=> Promise<any>, on:(event: string, listener:(params: any)=>void)=>void, close:()=>void, port: number }>}
*/
async
function
connectToExtHostInspector
(
port, opts ={}
)
{
const
{
=
false
,
=
30_000
}
=
;
// Wait for the inspector endpoint to be available
const
=
Date
.
now
(
)
+
;
/** @type{any} */
let
;
while
(
Date
.
now
(
)
<
)
{
try
{
const
=
await
getJson
(
`http://127.0.0.1:${port}/json`
)
;
if
(
.
length
>
0
&&
[
0
]
.
webSocketDebuggerUrl
)
{
=
[
0
]
.
webSocketDebuggerUrl
;
break
;
}
}
catch
{
}
await
new
Promise
(
r
=>
setTimeout
(
,
500
)
)
;
}
if
(
!
)
{
throw
new
Error
(
`Timed out waiting for extension host inspector on port ${port}`
/**
* Fetch JSON from a URL. Used to probe the CDP endpoint.
* @param{string}url
* @returns{Promise<any>}
*/
function
getJson
(
url
)
{
return
new
Promise
(
(
resolve, reject
)
=>
{
.
get
(
,
res
=>
{
let
=
''
;
.
on
(
'data'
,
chunk
=>
{
+=
;
}
)
;
.
on
(
'end'
,
(
)
=>
{
try
{
resolve
(
JSON
.
parse
(
)
)
;
}
catch
{
reject
(
new
Error
(
`Invalid JSON from ${url}`
)
)
;
}
}
)
;
}
)
.
on
(
'error'
,
)
;
}
)
;
}
/**
* Wait until VS Code exposes its CDP endpoint.
* @param{number}port
* @param{number}timeoutMs
* @returns{Promise<void>}
*/
async
function
waitForCDP
(
port, timeoutMs =60_000
)
{
const
=
Date
.
now
(
)
+
;
while
(
Date
.
now
(
)
<
)
{
try
{
await
getJson
(
`http://127.0.0.1:${port}/json/version`
)
;
return
;
}
catch
{
await
new
Promise
(
r
=>
setTimeout
(
,
500
)
)
;
}
}
throw
new
Error
(
`Timed out waiting for CDP on port ${port}`
)
;
}
/**
* Find the workbench page among all CDP pages.
* For dev builds this checks for `globalThis.driver` (smoke-test driver).
* For stable builds it checks for `.monaco-workbench` in the DOM.
* @param{import('playwright').Browser}browser
* @param{number}timeoutMs
* @returns{Promise<import('playwright').Page>}
*/
async
function
findWorkbenchPage
(
browser, timeoutMs =60_000
)
{
const
=
Date
.
now
(
)
+
;
while
(
Date
.
now
(
)
<
)
{
const
=
.
contexts
(
)
.
flatMap
(
ctx
=>
.
pages
(
)
)
;
for
(
const
of
)
{
const
=
await
.
evaluate
(
(
)
=>
// @ts-ignore
!
!
.
driver
?.
||
!
!
document
.
querySelector
(
'.monaco-workbench'
)
)
.
catch
(
(
)
=>
false
)
;
if
(
)
{
return
;
}
}
await
new
Promise
(
r
=>
setTimeout
(
,
500
)
)
;
}
throw
new
Error
(
'Timed out waiting for the workbench page'
)
;
}
/** @type{number} */
let
=
19222
;
/**
* Launch VS Code via child_process and connect via CDP.
* Works with dev builds, insiders, and stable releases.
*
* @param{string}executable - Path to the VS Code executable (Electron binary or CLI)
* @param{string[]}launchArgs - Arguments to pass to the executable
* @param{Record<string, string>}env - Environment variables
* @param{{ verbose?: boolean }}[opts]
* @returns{Promise<{ page:import('playwright').Page, browser:import('playwright').Browser, close:()=> Promise<void>}>}
*/
/**
* Regularized incomplete beta function I_x(a, b) via continued fraction.
* Used for computing t-distribution CDF / p-values.
* @param{number}x
* @param{number}a
* @param{number}b
* @returns{number}
*/
function
betaIncomplete
(
x, a, b
)
{
if
(
<=
0
)
{
return
0
;
}
if
(
>=
1
)
{
return
1
;
}
// Use symmetry relation when x > (a+1)/(a+b+2) for better convergence
if
(
>
(
+
1
)
/
(
+
+
2
)
)
{
return
1
-
betaIncomplete
(
1
-
,
,
)
;
}
// Log-beta via Stirling: lnBeta(a,b) = lnGamma(a)+lnGamma(b)-lnGamma(a+b)